-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4331 from WalletConnect/feat/auth
feat: auth aka sign 2.5
- Loading branch information
Showing
39 changed files
with
3,426 additions
and
108 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const AUTH_PROTOCOL = "wc"; | ||
export const AUTH_VERSION = 1.5; | ||
export const AUTH_CONTEXT = "auth"; | ||
export const AUTH_KEYS_CONTEXT = "authKeys"; | ||
export const AUTH_PAIRING_TOPIC_CONTEXT = "pairingTopics"; | ||
export const AUTH_REQUEST_CONTEXT = "requests"; | ||
|
||
export const AUTH_STORAGE_PREFIX = `${AUTH_PROTOCOL}@${AUTH_VERSION}:${AUTH_CONTEXT}:`; | ||
export const AUTH_PUBLIC_KEY_NAME = `${AUTH_STORAGE_PREFIX}:PUB_KEY`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Store } from "@walletconnect/core"; | ||
import { Logger } from "@walletconnect/logger"; | ||
import { ICore } from "@walletconnect/types"; | ||
|
||
import { AUTH_KEYS_CONTEXT, AUTH_STORAGE_PREFIX, AUTH_PUBLIC_KEY_NAME } from "../constants"; | ||
|
||
export class AuthKey extends Store<string, { responseTopic: string; publicKey: string }> { | ||
constructor(public core: ICore, public logger: Logger) { | ||
super(core, logger, AUTH_KEYS_CONTEXT, AUTH_STORAGE_PREFIX, () => AUTH_PUBLIC_KEY_NAME); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Store } from "@walletconnect/core"; | ||
import { Logger } from "@walletconnect/logger"; | ||
import { ICore } from "@walletconnect/types"; | ||
|
||
import { AUTH_PAIRING_TOPIC_CONTEXT, AUTH_STORAGE_PREFIX } from "../constants"; | ||
|
||
export class AuthPairingTopic extends Store<string, { topic: string; pairingTopic: string }> { | ||
constructor(public core: ICore, public logger: Logger) { | ||
super(core, logger, AUTH_PAIRING_TOPIC_CONTEXT, AUTH_STORAGE_PREFIX); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Store } from "@walletconnect/core"; | ||
import { Logger } from "@walletconnect/logger"; | ||
import { AuthTypes, ICore } from "@walletconnect/types"; | ||
|
||
import { AUTH_STORAGE_PREFIX, AUTH_REQUEST_CONTEXT } from "../constants"; | ||
|
||
export class AuthRequest extends Store<number, AuthTypes.PendingRequest> { | ||
constructor(public core: ICore, public logger: Logger) { | ||
super( | ||
core, | ||
logger, | ||
AUTH_REQUEST_CONTEXT, | ||
AUTH_STORAGE_PREFIX, | ||
(val: AuthTypes.PendingRequest) => val.id, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Logger } from "@walletconnect/logger"; | ||
import { IAuth, ICore } from "@walletconnect/types"; | ||
import { AuthPairingTopic } from "./authPairingTopic"; | ||
import { AuthRequest } from "./authRequest"; | ||
import { AuthKey } from "./authKey"; | ||
|
||
export class AuthStore { | ||
public authKeys: IAuth["authKeys"]; | ||
public pairingTopics: IAuth["pairingTopics"]; | ||
public requests: IAuth["requests"]; | ||
|
||
constructor(public core: ICore, public logger: Logger) { | ||
this.authKeys = new AuthKey(this.core, this.logger); | ||
this.pairingTopics = new AuthPairingTopic(this.core, this.logger); | ||
this.requests = new AuthRequest(this.core, this.logger); | ||
} | ||
|
||
public async init() { | ||
await this.authKeys.init(); | ||
await this.pairingTopics.init(); | ||
await this.requests.init(); | ||
} | ||
} |
Oops, something went wrong.