Conversation
* Add env injection for core and wdk * wdk: use injected timer for auth key retry delay
* feat: add ethauth option for dapp client connect * Update tests
|
|
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
This comment was marked as resolved.
This comment was marked as resolved.
Reviewer's GuideThis PR generalizes environment access (crypto, storage, timers, fetch, IndexedDB, URL/navigation, WebAuthn) across wallet-core and wallet-wdk, introduces an injectable passkey provider, adds ETHAuth support to the dapp client (including proof storage and surfaces), improves robustness of cron, recovery, and identity flows, and adds a new wagmi demo project plus CI/config/issue templates and version bumps for a new beta release. Sequence diagram for connect flow with ETHAuth proof creation and storagesequenceDiagram
actor DappUser
participant DappClient
participant ChainSessionManager
participant DappTransport
participant WalletApp
participant WalletBackend
participant SequenceStorage
DappUser->>DappClient: connect(ethAuthSettings)
DappClient->>ChainSessionManager: initializeAndConnect(options)
ChainSessionManager->>DappTransport: sendConnectRequest(payload with ethAuth)
DappTransport->>WalletApp: openWalletAndPostMessage(request)
WalletApp->>WalletBackend: handleConnectRequest(request)
WalletBackend->>WalletBackend: authenticateUser
WalletBackend->>WalletBackend: buildETHAuthTypedData
WalletBackend->>WalletBackend: signTypedData
WalletBackend-->>WalletApp: connectResponse(ethAuthProof)
WalletApp-->>DappTransport: postMessage(connectResponse)
DappTransport-->>ChainSessionManager: deliverConnectResponse
ChainSessionManager->>ChainSessionManager: _saveEthAuthProofIfProvided(ethAuthProof)
ChainSessionManager->>SequenceStorage: saveEthAuthProof(ethAuthProof)
SequenceStorage-->>ChainSessionManager: ok
ChainSessionManager-->>DappClient: connect completed
DappClient-->>DappUser: connected
DappUser->>DappClient: getEthAuthProof()
DappClient->>SequenceStorage: getEthAuthProof()
SequenceStorage-->>DappClient: ETHAuthProof
DappClient-->>DappUser: return ETHAuthProof
Class diagram for CoreEnv and WdkEnv abstractions and main consumersclassDiagram
class CoreEnv {
+fetch: fetch
+crypto: CryptoLike
+storage: StorageLike
+indexedDB: IDBFactory
+text: TextEncodingLike
}
class StorageLike {
+getItem(key: string) string
+setItem(key: string, value: string) void
+removeItem(key: string) void
}
class CryptoLike {
+subtle: SubtleCrypto
+getRandomValues(array: ArrayBufferView) ArrayBufferView
}
class TextEncodingLike {
+TextEncoder: TextEncoder
+TextDecoder: TextDecoder
}
class WdkEnv {
+fetch: fetch
+crypto: CryptoLike
+storage: StorageLike
+indexedDB: IDBFactory
+text: TextEncodingLike
+timers: TimersLike
+locks: LockManagerLike
+navigation: NavigationLike
+urlSearchParams: URLSearchParams
}
class TimersLike {
+setTimeout(handler: Function, timeout: number) any
+clearTimeout(id: any) void
+setInterval(handler: Function, timeout: number) any
+clearInterval(id: any) void
}
class LockManagerLike {
+request(name: string, callback: Function) Promise~void~
}
class NavigationLike {
+getPathname() string
+redirect(url: string) void
}
class EnvFunctionsCore {
+resolveCoreEnv(env: CoreEnv) CoreEnv
}
class EnvFunctionsWdk {
+resolveWdkEnv(env: WdkEnv) WdkEnv
}
class EncryptedPksDb {
-localStorageKeyPrefix: string
-tableName: string
-env: CoreEnv
+EncryptedPksDb(localStorageKeyPrefix: string, tableName: string, env: CoreEnv)
+generateAndStore() Promise~EncryptedData~
+getEncryptedPkStore(address: Address) Promise~EncryptedPkStore~
+listAddresses() Promise~Address[]~
+delete(address: Address) Promise~void~
-getIndexedDB() IDBFactory
-getStorage() StorageLike
-getCrypto() CryptoLike
-getTextEncoderCtor() TextEncoder
-getTextDecoderCtor() TextDecoder
-openDB() Promise~IDBDatabase~
}
class EncryptedPkStore {
-encrypted: EncryptedData
-env: CoreEnv
+EncryptedPkStore(encrypted: EncryptedData, env: CoreEnv)
+address() Address
+signDigest(digest: Bytes) Promise~SignatureParts~
-getStorage() StorageLike
-getCrypto() CryptoLike
-getTextDecoderCtor() TextDecoder
}
class IndexedDbStore {
-dbName: string
-_db: IDBDatabase
-env: CoreEnv
+IndexedDbStore(dbName: string, env: CoreEnv)
-getIndexedDB() IDBFactory
-openDB() Promise~IDBDatabase~
}
class PimlicoBundler {
+id: string
+provider: Provider
+bundlerRpcUrl: string
-fetcher: fetch
+PimlicoBundler(bundlerRpcUrl: string, provider: Provider, fetcher: fetch)
-bundlerRpc(method: string, params: any[]) Promise~any~
}
class DevHttpProvider {
-baseUrl: string
-fetcher: fetch
+DevHttpProvider(baseUrl: string, fetcher: fetch)
-request(method: string, path: string, body: any) Promise~any~
}
class StateSequenceProvider {
-service: Sessions
+Provider(host: string, fetcher: Fetch)
}
class AuthKeysDb {
-expirationTimers: Map~string, any~
-env: WdkEnv
+AuthKeys(dbName: string, env: WdkEnv)
+getBySigner(signer: string, attempt: number) Promise~AuthKey~
-scheduleExpiration(authKey: AuthKey) void
-clearExpiration(address: string) void
}
class Cron {
-STORAGE_KEY: string
-isStopping: boolean
-currentCheckJobsPromise: Promise~void~
-checkInterval: any
-env: WdkEnv
+Cron(shared: Shared)
-start() void
-checkJobs() Promise~void~
-runJobs() Promise~void~
-getStorageState() Promise~Map~string, any~~
-syncWithStorage() Promise~void~
-isAbortError(error: any) boolean
}
class IdentityHandler {
-nitro: IdentityInstrument
-authKeys: AuthKeysDb
-signatures: Signatures
+identityType: IdentityType
+env: WdkEnv
+IdentityHandler(nitro: IdentityInstrument, authKeys: AuthKeysDb, signatures: Signatures, identityType: IdentityType, env: WdkEnv)
+onStatusChange(cb: Function) Function
+commitVerifier(challenge: Hex) Promise~CommitResult~
+completeAuth(challenge: Hex, signer: string) Promise~CompleteResult~
+getIdentitySigner(signer: string) Promise~IdentitySigner~
-getAuthKey(signer: string) Promise~AuthKey~
}
CoreEnv <|-- WdkEnv
EnvFunctionsCore ..> CoreEnv
EnvFunctionsWdk ..> WdkEnv
EncryptedPksDb --> CoreEnv
EncryptedPkStore --> CoreEnv
IndexedDbStore --> CoreEnv
PimlicoBundler --> CoreEnv : uses fetch
DevHttpProvider --> CoreEnv : uses fetch
StateSequenceProvider --> CoreEnv : uses fetch
AuthKeysDb --> WdkEnv
Cron --> WdkEnv
IdentityHandler --> WdkEnv
WdkEnv --> TimersLike
WdkEnv --> LockManagerLike
WdkEnv --> NavigationLike
Class diagram for passkey provider, handlers, and wallet integrationclassDiagram
class PasskeySigner {
<<interface>>
+credentialId: string
+publicKey: PasskeysPublicKey
+imageHash: Hex
+signSapient(wallet: Address, chainId: number, payload: Payload, imageHash: Hex) Promise~any~
}
class PasskeyProvider {
<<interface>>
+create(extensions: PasskeysExtensions, options: CreatePasskeyOptions) Promise~PasskeySigner~
+find(stateReader: StateReader, extensions: PasskeysExtensions, options: FindPasskeyOptions) Promise~PasskeySigner~
+loadFromWitness(stateReader: StateReader, extensions: PasskeysExtensions, wallet: Address, imageHash: Hex, options: FindPasskeyOptions) Promise~PasskeySigner~
+fromCredential(args: FromCredentialArgs) PasskeySigner
+isSigner(signer: unknown) boolean
}
class DefaultPasskeyProvider {
+create(extensions: PasskeysExtensions, options: CreatePasskeyOptions) Promise~PasskeySigner~
+find(stateReader: StateReader, extensions: PasskeysExtensions, options: FindPasskeyOptions) Promise~PasskeySigner~
+loadFromWitness(stateReader: StateReader, extensions: PasskeysExtensions, wallet: Address, imageHash: Hex, options: FindPasskeyOptions) Promise~PasskeySigner~
+fromCredential(args: FromCredentialArgs) PasskeySigner
+isSigner(signer: unknown) boolean
}
class CorePasskey {
+address: Address
+credentialId: string
+publicKey: PasskeysPublicKey
+imageHash: Hex
+Passkey(options: PasskeyOptions)
+signSapient(wallet: Address, chainId: number, payload: Payload, imageHash: Hex) Promise~Signature~
+create(extensions: PasskeysExtensions, options: CreatePasskeyOptions) Promise~CorePasskey~
+find(stateReader: StateReader, extensions: PasskeysExtensions, options: FindPasskeyOptions) Promise~CorePasskey~
+loadFromWitness(stateReader: StateReader, extensions: PasskeysExtensions, wallet: Address, imageHash: Hex, options: FindPasskeyOptions) Promise~CorePasskey~
}
class PasskeysHandler {
+kind: string
-readySigners: Map~string, PasskeySigner~
-signatures: Signatures
-extensions: PasskeysExtensions
-stateReader: StateReader
-passkeyProvider: PasskeyProvider
+PasskeysHandler(signatures: Signatures, extensions: PasskeysExtensions, stateReader: StateReader, passkeyProvider: PasskeyProvider)
+onStatusChange(cb: Function) Function
+addReadySigner(signer: PasskeySigner) void
+handle(request: BaseSignatureRequest) Promise~SignerUnavailable \| SignerActionable~
-loadPasskey(wallet: Address, imageHash: Hex) Promise~PasskeySigner~
}
class Wallets {
-shared: Shared
+Wallets(shared: Shared)
+startSignUp(args: StartSignUpArgs) Promise~any~
+login(args: LoginArgs) Promise~any~
-isPasskeySigner(signer: unknown) boolean
}
class Shared {
+sequence: Sequence
+databases: Databases
+env: WdkEnv
+passkeyProvider: PasskeyProvider
}
class ManagerOptions {
+env: WdkEnv
+passkeyProvider: PasskeyProvider
}
class ResolvedManagerOptions {
+env: WdkEnv
+passkeyProvider: PasskeyProvider
}
class Manager {
-ops: ResolvedManagerOptions
-passkeysHandler: PasskeysHandler
+Manager(options: ManagerOptions)
}
PasskeyProvider <|.. DefaultPasskeyProvider
PasskeySigner <|.. CorePasskey
DefaultPasskeyProvider ..> CorePasskey
PasskeysHandler --> PasskeyProvider
PasskeysHandler --> PasskeySigner
Shared --> PasskeyProvider
Wallets --> Shared
Wallets --> PasskeySigner
ManagerOptions --> PasskeyProvider
ResolvedManagerOptions --> PasskeyProvider
Manager --> ResolvedManagerOptions
Manager --> PasskeysHandler
Class diagram for DappClient ETHAuth types and storage integrationclassDiagram
class EthAuthSettings {
+app: string
+expiry: number
+origin: string
+nonce: number
}
class ETHAuthProof {
+typedData: TypedDataToSign
+ewtString: string
}
class CreateNewSessionPayload {
+origin: string
+session: ExplicitSession
+includeImplicitSession: boolean
+ethAuth: EthAuthSettings
+preferredLoginMethod: LoginMethod
+email: string
}
class CreateNewSessionResponse {
+session: ExplicitSession
+walletAddress: Address
+userEmail: string
+loginMethod: LoginMethod
+guard: GuardConfig
+ethAuthProof: ETHAuthProof
}
class SequenceStorage {
<<interface>>
+saveEthAuthProof(proof: ETHAuthProof) Promise~void~
+getEthAuthProof() Promise~ETHAuthProof~
+clearEthAuthProof() Promise~void~
}
class WebStorage {
+saveEthAuthProof(proof: ETHAuthProof) Promise~void~
+getEthAuthProof() Promise~ETHAuthProof~
+clearEthAuthProof() Promise~void~
}
class ChainSessionManager {
-sequenceStorage: SequenceStorage
+connect(options: ConnectOptions) Promise~void~
+_saveEthAuthProofIfProvided(ethAuthProof: ETHAuthProof) Promise~void~
}
class DappClient {
-sequenceStorage: SequenceStorage
+connect(options: ConnectOptions) Promise~void~
+getEthAuthProof() Promise~ETHAuthProof~
}
SequenceStorage <|.. WebStorage
ChainSessionManager --> SequenceStorage
ChainSessionManager --> CreateNewSessionPayload
ChainSessionManager --> CreateNewSessionResponse
ChainSessionManager --> ETHAuthProof
DappClient --> ChainSessionManager
DappClient --> SequenceStorage
DappClient --> EthAuthSettings
DappClient --> ETHAuthProof
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
⛔ Snyk checks have failed. 1 issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Sorry @Dargon789, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Summary of ChangesHello @Dargon789, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces significant updates across several core packages, focusing on enhancing the relayer and userdata services, improving environment abstraction for better testability, and integrating ETHAuth proof handling in the dapp client. It also refines passkey management, updates network configurations, and includes a broad range of dependency and version updates to ensure stability and incorporate the latest features. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is a substantial pull request that introduces several major features and improvements across the wallet-sdk. Key changes include the addition of ETHAuth support, a comprehensive environment abstraction layer (CoreEnv and WdkEnv) to decouple from browser-specific APIs, and a pluggable PasskeyProvider for greater flexibility. The relayer API has also been updated for more explicit transaction destination handling.
The code quality is high, and the architectural changes for environment abstraction are well-executed, enhancing portability and testability. I've found one medium-severity issue related to URL query serialization in non-browser environments, for which I've provided a suggestion. Overall, this is an excellent set of updates that significantly modernizes the codebase.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary by Sourcery
Add ETHAuth support and environment abstraction across wallet core/WDK, improve passkey handling, and update infrastructure, networks, and demos.
New Features:
Enhancements:
Build:
CI:
Documentation:
Tests:
Chores: