Skip to content

3.0.4#376

Merged
Dargon789 merged 5 commits intoDargon789:masterfrom
0xsequence:master
Mar 19, 2026
Merged

3.0.4#376
Dargon789 merged 5 commits intoDargon789:masterfrom
0xsequence:master

Conversation

@Dargon789
Copy link
Copy Markdown
Owner

@Dargon789 Dargon789 commented Mar 17, 2026

Summary by Sourcery

Add id-token based login support across the wallet stack and normalize Google auth handlers to a canonical signer kind while preserving redirect flows as default.

New Features:

  • Support signing up and logging in with OIDC ID tokens for Google, Apple, and custom identity providers, including a unified UI registration hook for ID token prompts.

Enhancements:

  • Normalize Google PKCE signers to the canonical Google login kind and ensure legacy signer kinds are handled transparently in signer resolution and sessions.
  • Extend identity configuration to choose between redirect-based auth and id-token flows per provider, with appropriate handler validation and error reporting.
  • Preserve underlying guard errors as the cause when wrapping them in high-level guard signing failures.

Build:

  • Bump package versions to 3.0.4 across services, wallet, and utility packages to align with the new id-token login capability.

Documentation:

  • Document id-token login support and behaviour in changelogs across affected packages.

Tests:

  • Add comprehensive tests for id-token signup flows, handler registration, custom provider behaviour, Google signer kind normalization, and guard error propagation.

taylanpince and others added 5 commits March 16, 2026 09:44
* Add WDK Google ID token auth flow

* Unify Google WDK auth kinds

* Refine WDK Google id token flow

* Fix id-token auth key cleanup on signer mismatch

* Restore guard error logging

* Unify Google WDK signer kind

* Fix WDK auth flow cleanup and implicit session metadata
@codesandbox
Copy link
Copy Markdown

codesandbox bot commented Mar 17, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 17, 2026

@taylanpince is attempting to deploy a commit to the Foundry development Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 17, 2026

Reviewer's Guide

Adds first-class ID token login support (Google, Apple, custom OIDC) to the wallet WDK, refactors handler registration and signer kinds to use canonical login-google/apple keys, wires UI registration for ID token flows, preserves guard error causes, and bumps package versions to 3.0.4 with changelog updates.

Sequence diagram for ID token signup flow

sequenceDiagram
  actor User
  participant DappClient
  participant Wallets
  participant SharedHandlers
  participant IdTokenHandler
  participant IdentityInstrument
  participant DbAuthKeys

  User->>DappClient: Clicks sign up with Google (id-token)
  DappClient->>Wallets: signUp({ kind: google-id-token, idToken })
  Wallets->>SharedHandlers: get(Kinds.LoginGoogle)
  SharedHandlers-->>Wallets: IdTokenHandler
  Wallets->>IdTokenHandler: completeAuth(idToken)
  IdTokenHandler->>IdentityInstrument: nitroCommitVerifier(IdTokenChallenge)
  IdentityInstrument-->>IdTokenHandler: commit verified
  IdTokenHandler->>IdentityInstrument: nitroCompleteAuth(IdTokenChallenge)
  IdentityInstrument-->>IdTokenHandler: { signer, email }
  IdTokenHandler->>DbAuthKeys: store auth key for signer
  IdTokenHandler-->>Wallets: [signer, { email }]
  Wallets-->>DappClient: { signer, extra.signerKind = Kinds.LoginGoogle, loginEmail }
  DappClient-->>User: Wallet created and logged in
Loading

Class diagram for ID token and auth handlers

classDiagram
  class IdentityHandler {
    +Identity.IdentityInstrument nitro
    +Db.AuthKeys authKeys
    +Signatures signatures
    +Identity.IdentityType identityType
    +WdkEnv env
    +getAuthKeySigner(address Address.Address) IdentitySigner
    +createAuthKeySigner(authKey Db.AuthKey) IdentitySigner
    +clearAuthKeySigner(address string) void
  }

  class IdTokenHandler {
    +string signupKind
    +string issuer
    +string audience
    -PromptIdTokenHandler onPromptIdToken
    +IdTokenHandler(signupKind string, issuer string, audience string, nitro Identity.IdentityInstrument, signatures Signatures, authKeys Db.AuthKeys, env WdkEnv)
    +kind string
    +registerUI(onPromptIdToken PromptIdTokenHandler) function
    +unregisterUI() void
    +completeAuth(idToken string) IdentitySigner_map
    +getSigner() signer_Signers_Signer_email_string
    +status(address Address.Address, _imageHash Hex.Hex, request BaseSignatureRequest) SignerUnavailable_Ready_Actionable
    -handleAuth(onPromptIdToken PromptIdTokenHandler) signer_Signers_Signer_email_string
  }

  class AuthCodeHandler {
    +string signupKind
    +string issuer
    +string audience
    +kind string
  }

  class AuthCodePkceHandler {
    +string signupKind
    +string issuer
    +string audience
  }

  class ManagerOptions {
    +IdentityOptions identity
  }

  class IdentityOptions {
    +GoogleIdentityOptions google
    +AppleIdentityOptions apple
    +CustomIdentityProvider[] customProviders
  }

  class GoogleIdentityOptions {
    +boolean enabled
    +string clientId
    +string authMethod_authcode_pkce_or_id_token
  }

  class AppleIdentityOptions {
    +boolean enabled
    +string clientId
    +string authMethod_authcode_or_id_token
  }

  class CustomIdentityProvider {
    +string kind
    +string authMethod_id_token_or_authcode_or_authcode_pkce
    +string issuer
    +string oauthUrl
    +string clientId
  }

  class Manager {
    +shared handlers_Map
    +identityInstrument Identity.IdentityInstrument
    +modules signatures_Signatures
    +registerIdTokenUI(onPromptIdToken PromptIdTokenHandler) function
  }

  class Wallets {
    +shared Shared
    +signUp(args SignupArgs) Promise
    +startSignUpWithRedirect(args StartSignUpWithRedirectArgs) Promise
    +completeRedirect(args CompleteRedirectArgs) Promise
  }

  class SignupArgs {
  }

  class IdTokenSignupArgs {
    +string kind_google_id_token_or_apple_id_token_or_custom_string
    +string idToken
  }

  class Kinds {
    <<enumeration>>
    +LoginGoogle
    +LoginApple
  }

  IdentityHandler <|-- IdTokenHandler
  IdentityHandler <|-- AuthCodeHandler
  IdentityHandler <|-- AuthCodePkceHandler

  ManagerOptions o-- IdentityOptions
  IdentityOptions o-- GoogleIdentityOptions
  IdentityOptions o-- AppleIdentityOptions
  IdentityOptions o-- CustomIdentityProvider

  Manager o-- IdTokenHandler
  Manager o-- AuthCodeHandler
  Manager o-- AuthCodePkceHandler

  SignupArgs <|-- IdTokenSignupArgs
  Wallets ..> IdTokenHandler
  Wallets ..> AuthCodeHandler
  Wallets ..> AuthCodePkceHandler

  Kinds ..> IdTokenHandler
  Kinds ..> AuthCodeHandler
  Kinds ..> Wallets
Loading

File-Level Changes

Change Details Files
Introduce ID token authentication handler and flows for Google, Apple, and custom OIDC providers.
  • Add IdTokenHandler implementation with UI callback registration, token challenge verification, signer creation, and status handling including signer mismatch guard.
  • Add PromptIdTokenHandler type and registerIdTokenUI on Manager to fan out a single UI callback to all IdTokenHandler instances.
  • Update Sessions to hash issuer/audience for IdTokenHandler in the same way as other identity-based handlers.
packages/wallet/wdk/src/sequence/handlers/idtoken.ts
packages/wallet/wdk/src/sequence/handlers/index.ts
packages/wallet/wdk/src/sequence/manager.ts
packages/wallet/wdk/src/sequence/sessions.ts
Extend Wallets signup and redirect APIs to support ID token-based signups and enforce handler capability checks.
  • Introduce IdTokenSignupArgs and extend SignupArgs union; add isIdTokenArgs type guard.
  • Add helper functions to normalize signup handler keys and canonical signer kinds (including custom-* providers).
  • Wire google-id-token, apple-id-token, and custom id-token flows through IdTokenHandler.completeAuth, returning loginEmail and proper signerKind.
  • Update startSignUpWithRedirect and completeRedirect to use normalized handler keys and throw when handler is not an AuthCodeHandler (no redirect support).
packages/wallet/wdk/src/sequence/wallets.ts
Canonicalize Google and Apple identity handlers and signer kinds, including backward-compatibility for legacy google-pkce signers.
  • Change Kinds.LoginGooglePkce to Kinds.LoginGoogle and update Wallet.loginType docs accordingly.
  • Make Manager register Google and Apple handlers under canonical Kinds.LoginGoogle / Kinds.LoginApple regardless of auth method, choosing between AuthCode(Pkce) and IdToken handlers based on authMethod.
  • Add CustomIdentityProvider type splitting id-token vs redirect-capable providers and adjust identity options/resolution defaults (including default google/apple authMethod).
  • Update AuthCodeHandler.kind and AuthCodePkceHandler.kind for Google to return login-google, and normalize legacy login-google-pkce kind in Signers.toKnownKind.
  • Normalize commitment/handler lookup via helper functions so auth commitments and redirects still resolve correctly under canonical kinds.
packages/wallet/wdk/src/sequence/types/signer.ts
packages/wallet/wdk/src/sequence/types/wallet.ts
packages/wallet/wdk/src/sequence/handlers/authcode.ts
packages/wallet/wdk/src/sequence/signers.ts
packages/wallet/wdk/src/sequence/manager.ts
packages/wallet/wdk/src/sequence/wallets.ts
Tighten identity configuration behavior and tests for handler registration, including ID token vs redirect capabilities.
  • Update ManagerOptions and ResolvedIdentityOptions to support per-provider authMethod for google, apple, and customProviders (with id-token-only providers lacking oauthUrl).
  • Register custom id-token providers as IdTokenHandler instances without enabling redirect support; keep redirect-only providers as AuthCode/AuthCodePkce handlers.
  • Add tests verifying handler keys, default google PKCE behavior, explicit Google/Apple ID token handler registration, custom id-token provider registration, redirect rejection for id-token-only handlers, and id-token signup rejection when provider is redirect-only.
packages/wallet/wdk/src/sequence/manager.ts
packages/wallet/wdk/test/identity-auth-dbs.test.ts
packages/wallet/wdk/test/wallets.test.ts
Improve guard error reporting by preserving underlying failure as error cause and add regression test.
  • Wrap guard signPayload errors with a new Error('Error signing with guard', { cause }) instead of dropping original error.
  • Add test ensuring the outer error message is preserved and cause is a WebrpcRequestFailed error with original message.
packages/services/guard/src/sequence.ts
packages/services/guard/test/sequence.test.ts
Add unit and integration tests for new ID token flows, handler kinds, and Google PKCE canonicalization.
  • Extend wallets tests to cover google-id-token/apple-id-token signup flows, ID token UI registration, and rejection when misconfigured for redirect.
  • Add signers-kindof test to normalize legacy login-google-pkce witness metadata to Kinds.LoginGoogle.
  • Adjust AuthCodeHandler/AuthCodePkceHandler kind tests for updated canonical kind behavior.
  • Add placeholder test files for idtoken and sessions-idtoken flows (contents not shown in diff).
packages/wallet/wdk/test/wallets.test.ts
packages/wallet/wdk/test/signers-kindof.test.ts
packages/wallet/wdk/test/authcode.test.ts
packages/wallet/wdk/test/authcode-pkce.test.ts
packages/wallet/wdk/test/idtoken.test.ts
packages/wallet/wdk/test/sessions-idtoken.test.ts
Update package versions and changelogs across the monorepo for 3.0.4 release with id-token login support notes.
  • Bump version fields from 3.0.1 to 3.0.4 in affected package.json files for services, wallet, and utils packages.
  • Add 3.0.2–3.0.4 entries to various CHANGELOG.md files noting id-token login support, allow native self transfer, and dependency bumps.
packages/wallet/wdk/CHANGELOG.md
packages/wallet/dapp-client/CHANGELOG.md
packages/wallet/core/CHANGELOG.md
packages/services/relayer/CHANGELOG.md
packages/services/api/CHANGELOG.md
packages/services/builder/CHANGELOG.md
packages/services/guard/CHANGELOG.md
packages/services/identity-instrument/CHANGELOG.md
packages/services/indexer/CHANGELOG.md
packages/services/marketplace/CHANGELOG.md
packages/services/metadata/CHANGELOG.md
packages/services/userdata/CHANGELOG.md
packages/utils/abi/CHANGELOG.md
packages/wallet/primitives/CHANGELOG.md
packages/services/api/package.json
packages/services/builder/package.json
packages/services/guard/package.json
packages/services/identity-instrument/package.json
packages/services/indexer/package.json
packages/services/marketplace/package.json
packages/services/metadata/package.json
packages/services/relayer/package.json
packages/services/userdata/package.json
packages/utils/abi/package.json
packages/wallet/core/package.json
packages/wallet/dapp-client/package.json
packages/wallet/primitives/package.json
packages/wallet/wdk/package.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Mar 17, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mergify
Copy link
Copy Markdown

mergify bot commented Mar 17, 2026

⚠️ The sha of the head commit of this PR conflicts with #321. Mergify cannot evaluate rules on this PR. Once #321 is merged or closed, Mergify will resume processing this PR. ⚠️

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 significantly expands the Wallet Development Kit's (WDK) authentication capabilities by integrating ID token login support for various OIDC providers, including Google, Apple, and custom solutions. This allows for more granular control over authentication flows, enabling developers to choose between traditional OAuth 2.0 Authorization Code Flow with PKCE and the new ID token method. Additionally, the changes include an important improvement to error handling in the guard service, ensuring that original error causes are retained for easier troubleshooting. The update also involves a version bump to 3.0.4 across several core packages.

Highlights

  • ID Token Login Support: Introduced comprehensive support for ID token-based authentication across Google, Apple, and custom OpenID Connect (OIDC) providers, allowing flexible configuration of authentication methods (auth code vs. ID token).
  • Improved Error Handling: Enhanced error handling within the guard service by preserving the original error as a cause, which significantly improves debugging capabilities.
  • Standardized Google Login Kind: Standardized the internal representation of Google login from login-google-pkce to login-google for better consistency and future compatibility.
  • Version Bumps: Updated package versions to 3.0.4 across numerous @0xsequence service and utility packages, reflecting the latest changes and dependencies.
Changelog
  • packages/services/api/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/api/package.json
    • Updated package version to 3.0.4.
  • packages/services/builder/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/builder/package.json
    • Updated package version to 3.0.4.
  • packages/services/guard/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/guard/package.json
    • Updated package version to 3.0.4.
  • packages/services/guard/src/sequence.ts
    • Modified error handling to include the original error as a cause.
  • packages/services/guard/test/sequence.test.ts
    • Added a test to verify that the original guard failure is preserved as a cause.
  • packages/services/identity-instrument/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/identity-instrument/package.json
    • Updated package version to 3.0.4.
  • packages/services/indexer/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/indexer/package.json
    • Updated package version to 3.0.4.
  • packages/services/marketplace/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/marketplace/package.json
    • Updated package version to 3.0.4.
  • packages/services/metadata/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/metadata/package.json
    • Updated package version to 3.0.4.
  • packages/services/relayer/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support', '3.0.3', 'allow native self transfer', and updated dependencies.
  • packages/services/relayer/package.json
    • Updated package version to 3.0.4.
  • packages/services/userdata/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/services/userdata/package.json
    • Updated package version to 3.0.4.
  • packages/utils/abi/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/utils/abi/package.json
    • Updated package version to 3.0.4.
  • packages/wallet/core/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support', '3.0.3', 'allow native self transfer', and updated dependencies.
  • packages/wallet/core/package.json
    • Updated package version to 3.0.4.
  • packages/wallet/dapp-client/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support', '3.0.3', 'allow native self transfer', and updated dependencies.
  • packages/wallet/dapp-client/package.json
    • Updated package version to 3.0.4.
  • packages/wallet/primitives/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support' and 'allow native self transfer'.
  • packages/wallet/primitives/package.json
    • Updated package version to 3.0.4.
  • packages/wallet/wdk/CHANGELOG.md
    • Added changelog entries for versions 3.0.4, 3.0.3, and 3.0.2, including 'id-token login support', '3.0.3', 'allow native self transfer', and updated dependencies.
  • packages/wallet/wdk/package.json
    • Updated package version to 3.0.4.
  • packages/wallet/wdk/src/sequence/handlers/authcode.ts
    • Modified the kind getter to normalize google-pkce to login-google.
  • packages/wallet/wdk/src/sequence/handlers/identity.ts
    • Added a protected method clearAuthKeySigner to remove authentication keys by signer address.
  • packages/wallet/wdk/src/sequence/handlers/idtoken.ts
    • Added a new handler for OIDC ID token-based authentication.
  • packages/wallet/wdk/src/sequence/handlers/index.ts
    • Exported the new IdTokenHandler.
  • packages/wallet/wdk/src/sequence/manager.ts
    • Imported IdTokenHandler.
    • Extended CustomIdentityProvider type to support id-token auth method.
    • Updated ManagerOptions and ResolvedIdentityOptions to allow specifying authMethod for Google and Apple.
    • Updated ManagerOptionsDefaults to include default authMethod for Google and Apple.
    • Modified the Manager constructor to conditionally instantiate IdTokenHandler or AuthCodeHandler based on the configured authMethod for Google and Apple, and to support id-token for custom providers.
    • Added registerIdTokenUI method to register UI callbacks for ID token handlers.
  • packages/wallet/wdk/src/sequence/sessions.ts
    • Imported AuthCodeHandler and IdTokenHandler.
    • Updated createSessionConfig to correctly handle IdTokenHandler instances when computing issuerHash and audienceHash.
  • packages/wallet/wdk/src/sequence/signers.ts
    • Added logic to normalize login-google-pkce kind to login-google for legacy witnesses.
  • packages/wallet/wdk/src/sequence/types/signer.ts
    • Renamed LoginGooglePkce to LoginGoogle.
  • packages/wallet/wdk/src/sequence/types/wallet.ts
    • Updated the loginType documentation example to reflect login-google.
  • packages/wallet/wdk/src/sequence/wallets.ts
    • Imported IdTokenHandler.
    • Introduced helper functions getSignupHandlerKey, getSignerKindForSignup, and getIdTokenSignupHandler.
    • Defined IdTokenSignupArgs type and updated SignupArgs to include it.
    • Added isIdTokenArgs type guard and refined isAuthCodeArgs.
    • Modified the signUp method to support google-id-token, apple-id-token, and custom id-token signups.
    • Updated startSignUpWithRedirect and completeSignUpWithRedirect to ensure correct handler type checking for redirect flows.
  • packages/wallet/wdk/test/authcode-pkce.test.ts
    • Updated test assertion for handler.kind to expect login-google.
  • packages/wallet/wdk/test/authcode.test.ts
    • Updated test assertions for handler.kind to expect login-google.
  • packages/wallet/wdk/test/identity-auth-dbs.test.ts
    • Updated test to verify Google handler registration under login-google kind.
    • Added tests for explicit Google and Apple ID token handler configurations.
    • Added a test for custom ID token providers, ensuring redirect flow is not enabled for them.
  • packages/wallet/wdk/test/identity-signer.test.ts
    • Changed global to globalThis for window property definition.
  • packages/wallet/wdk/test/idtoken.test.ts
    • Added new test suite for IdTokenHandler, covering constructor, UI registration, completeAuth, getSigner, and status methods.
  • packages/wallet/wdk/test/sessions-idtoken.test.ts
    • Added new test suite for ID token attestation in implicit session authorization for Google and Apple.
  • packages/wallet/wdk/test/signers-kindof.test.ts
    • Added a test to confirm normalization of legacy login-google-pkce signer kind.
  • packages/wallet/wdk/test/wallets.test.ts
    • Added tests for creating wallets using google-id-token and apple-id-token.
    • Added a test for registering and unregistering Google ID token UI callbacks.
    • Added tests to ensure Google PKCE remains default when authMethod is unspecified.
    • Added tests for rejecting ID token signups when providers are configured for redirect auth.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 8 security issues, 4 other issues, and left some high level feedback:

Security issues:

  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)
  • Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data. (link)

General comments:

  • In IdTokenHandler.handleAuth you're creating a new Promise with an async executor, which can lead to unhandled rejections; consider removing the async from the executor and treating onPromptIdToken/respond as plain promise chains instead.
  • In IdTokenHandler.status, when handling an id-token-signer-mismatch you call clearAuthKeySigner with the returned signer address; double-check that this is the intended key to delete in the auth key store and that you don't inadvertently clear valid auth for identities that might still be in use elsewhere.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `IdTokenHandler.handleAuth` you're creating a `new Promise` with an `async` executor, which can lead to unhandled rejections; consider removing the `async` from the executor and treating `onPromptIdToken`/`respond` as plain promise chains instead.
- In `IdTokenHandler.status`, when handling an `id-token-signer-mismatch` you call `clearAuthKeySigner` with the returned signer address; double-check that this is the intended key to delete in the auth key store and that you don't inadvertently clear valid auth for identities that might still be in use elsewhere.

## Individual Comments

### Comment 1
<location path="packages/wallet/wdk/src/sequence/wallets.ts" line_range="801-807" />
<code_context>
   }

   async startSignUpWithRedirect(args: StartSignUpWithRedirectArgs) {
-    const kind = args.kind.startsWith('custom-') ? args.kind : 'login-' + args.kind
-    const handler = this.shared.handlers.get(kind) as AuthCodeHandler
+    const kind = getSignupHandlerKey(args.kind)
+    const handler = this.shared.handlers.get(kind)
     if (!handler) {
       throw new Error('handler-not-registered')
     }
+    if (!(handler instanceof AuthCodeHandler)) {
+      throw new Error('handler-does-not-support-redirect')
+    }
</code_context>
<issue_to_address>
**issue (bug_risk):** Redirect sign-up now rejects AuthCodePkceHandler handlers, breaking Google PKCE redirect flows.

The previous version effectively treated the handler as any object with `commitAuth`, so both `AuthCodeHandler` and `AuthCodePkceHandler` (and other compatible handlers) worked. The new `instanceof AuthCodeHandler` guard causes a `AuthCodePkceHandler` registered under `Kinds.LoginGoogle` to fail with `handler-does-not-support-redirect`, breaking Google PKCE sign-up when `authMethod: 'authcode-pkce'`.

Please relax the check to allow both handler types, e.g.:

```ts
const handler = this.shared.handlers.get(kind)
if (!handler) throw new Error('handler-not-registered')
if (!(handler instanceof AuthCodeHandler) && !(handler instanceof AuthCodePkceHandler)) {
  throw new Error('handler-does-not-support-redirect')
}
```

Alternatively, check for the required methods (e.g. `commitAuth`/`completeAuth`) instead of relying solely on `instanceof`, so any compatible redirect handler continues to work.
</issue_to_address>

### Comment 2
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="204-30" />
<code_context>
+    ).rejects.toThrow('handler-does-not-support-id-token')
+  })
+
+  it('Should reject custom ID token signup when the provider uses redirect auth', async () => {
+    manager = newManager({
+      identity: {
+        customProviders: [
+          {
+            kind: 'custom-oidc',
+            authMethod: 'authcode',
+            issuer: 'https://issuer.example.com',
+            oauthUrl: 'https://issuer.example.com/oauth/authorize',
+            clientId: 'test-custom-client-id',
+          },
+        ],
+      },
+    })
+
+    await expect(
</code_context>
<issue_to_address>
**suggestion (testing):** Add a positive-path test for custom ID token providers to complement the rejection test

To fully exercise the new behavior, please also add a positive-path test where a custom provider is configured with `authMethod: 'id-token'` and `signUp({ kind: 'custom-...', idToken })` succeeds, asserting that the wallet is created, the signer kind matches the custom provider, and metadata such as `loginEmail` is propagated correctly.

Suggested implementation:

```typescript
  it('Should allow custom ID token signup when the provider uses id-token auth', async () => {
    manager = newManager({
      identity: {
        customProviders: [
          {
            kind: 'custom-oidc',
            authMethod: 'id-token',
            issuer: 'https://issuer.example.com',
            oauthUrl: 'https://issuer.example.com/oauth/authorize',
            clientId: 'test-custom-client-id',
          },
        ],
      },
    })

    const wallet = await manager.wallets.signUp({
      kind: 'custom-oidc',
      idToken: 'eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImN1c3RvbS11c2VyQGV4YW1wbGUuY29tIn0.',
      noGuard: true,
    })

    expect(wallet).toBeDefined()
    expect(wallet.signer.kind).toBe('custom-oidc')
    // Depending on the wallet shape, adjust this assertion to where loginEmail is stored
    expect(
      // prefer loginEmail if present, otherwise fall back to a generic email field
      (wallet as any).metadata?.loginEmail ?? (wallet as any).metadata?.email,
    ).toBe('custom-user@example.com')
  })

  it('Should reject apple-id-token signup when Apple is configured for redirect auth', async () => {
    manager = newManager({

```

You may need to adjust a few details to match the existing test helpers and types:

1. If the `kind` used for custom providers in signUp is namespaced (e.g. `'custom-oidc:issuer.example.com'` or similar), update the `kind: 'custom-oidc'` argument to whatever value the other custom-provider tests in this file use.
2. The ID token here is a simple, unsigned JWT-like string with an email claim; if your test utilities already expose a helper for generating ID tokens (e.g. `makeIdToken({ email: ... })`), replace the hard-coded string with that helper.
3. Update the expectations to match the actual wallet shape:
   - If `wallet.signer` is nested differently (e.g. `wallet.signer.kind` vs `wallet.signer.type` or `wallet.signerInfo.kind`), adjust the assertion accordingly.
   - If `loginEmail` is stored somewhere else (e.g. `wallet.loginEmail`, `wallet.profile.email`, or `wallet.metadata.identity.loginEmail`), change the metadata assertion to point to the correct path and drop the `(wallet as any)` cast once you know the correct type.
4. If the test suite uses typed helpers like `createTestManager()` instead of `newManager`, ensure the new test uses the same helper for consistency.
</issue_to_address>

### Comment 3
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="116-30" />
<code_context>
+    expect(configuration.login[0]!.kind).toBe(Kinds.LoginApple)
+  })
+
+  it('Should register and unregister Google ID token UI callbacks through the manager', async () => {
+    manager = newManager({
+      identity: {
+        google: {
+          enabled: true,
+          clientId: 'test-google-client-id',
+          authMethod: 'id-token',
+        },
+      },
+    })
+
+    const handler = (manager as any).shared.handlers.get(Kinds.LoginGoogle) as IdTokenHandler
</code_context>
<issue_to_address>
**suggestion (testing):** Extend `registerIdTokenUI` tests to cover multiple ID token handlers (Apple/custom) and cleanup

Currently this only verifies wiring for a single Google handler. Since `registerIdTokenUI` iterates over all handlers, please add a test with multiple providers enabled (e.g., Google + Apple, and optionally a custom provider) to assert that:
- each relevant `IdTokenHandler` receives the same callback, and
- the returned `unregister` clears `onPromptIdToken` on all of them.
This will validate behavior in multi-provider setups.

Suggested implementation:

```typescript
    manager = newManager({
      identity: {
        google: {
          enabled: true,
          clientId: 'test-google-client-id',
          authMethod: 'id-token',
        },
        apple: {
          enabled: true,
          clientId: 'test-apple-client-id',
          authMethod: 'id-token',
        },
      },
    })

    const googleHandler = (manager as any).shared.handlers.get(Kinds.LoginGoogle) as IdTokenHandler
    const appleHandler = (manager as any).shared.handlers.get(Kinds.LoginApple) as IdTokenHandler

    expect(googleHandler).toBeDefined()
    expect(appleHandler).toBeDefined()

    const callback = vi.fn()
    const unregister = manager.registerIdTokenUI(callback)

    expect(googleHandler.onPromptIdToken).toBe(callback)
    expect(appleHandler.onPromptIdToken).toBe(callback)

    unregister()

    expect(googleHandler.onPromptIdToken).toBeUndefined()
    expect(appleHandler.onPromptIdToken).toBeUndefined()

```

If your codebase supports additional custom ID token providers with their own `Kinds.*` enum entries and `IdTokenHandler`s, you can extend this test further by:
1. Enabling the custom provider in the `identity` configuration of `newManager`.
2. Fetching its handler from `(manager as any).shared.handlers`.
3. Adding it to the shared expectations that `onPromptIdToken` is set to the same callback and cleared by `unregister`.
</issue_to_address>

### Comment 4
<location path="packages/wallet/wdk/src/sequence/handlers/idtoken.ts" line_range="125" />
<code_context>
+    }
+  }
+
+  private handleAuth(
+    onPromptIdToken: PromptIdTokenHandler,
+  ): Promise<{ signer: Signers.Signer & Signers.Witnessable; email: string }> {
</code_context>
<issue_to_address>
**issue (complexity):** Consider refactoring `handleAuth` to delegate the callback-to-promise wiring to a small helper so the method itself can be a simple async function with a single, linear error path.

The main complexity comes from `handleAuth` using an async promise executor with nested try/catch. You can keep the existing `PromptIdTokenHandler` contract and move the awkward promise wiring into a small helper, then make `handleAuth` a straightforward `async` function with a single error path.

For example:

```ts
// Keep existing type, just allow non-async respond as well if you like.
type RespondFn = (idToken: string) => void | Promise<void>

export type PromptIdTokenHandler = (
  kind: 'google-id-token' | 'apple-id-token' | `custom-${string}`,
  respond: RespondFn,
) => Promise<void>

// Small helper to isolate the callback → Promise conversion
private waitForIdToken(onPromptIdToken: PromptIdTokenHandler): Promise<string> {
  return new Promise<string>((resolve, reject) => {
    const respond: RespondFn = async (idToken) => {
      // No try/catch here: if this throws, the caller of `respond` sees it
      resolve(idToken)
    }

    // Capture errors from the UI prompt itself
    onPromptIdToken(this.signupKind, respond).catch(reject)
  })
}

// `handleAuth` becomes linear and easy to reason about
private async handleAuth(
  onPromptIdToken: PromptIdTokenHandler,
): Promise<{ signer: Signers.Signer & Signers.Witnessable; email: string }> {
  const idToken = await this.waitForIdToken(onPromptIdToken)
  const [signer, metadata] = await this.completeAuth(idToken)
  return { signer, email: metadata.email || '' }
}
```

This keeps:

- The same external `PromptIdTokenHandler`/`RespondFn` signature.
- All current behavior (UI still calls `onPromptIdToken(kind, respond)` and awaits its own promise).

But it:

- Removes the async executor + nested try/catch from `handleAuth`.
- Centralizes the “callback → Promise” logic and error propagation in one small helper.
- Makes `handleAuth` and callers like `status` much easier to follow.
</issue_to_address>

### Comment 5
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="98" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 6
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="103" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 7
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="198" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 8
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="56" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 9
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="61" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 10
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="137" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 11
<location path="packages/wallet/wdk/test/wallets.test.ts" line_range="161" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

### Comment 12
<location path="packages/wallet/wdk/test/idtoken.test.ts" line_range="149" />
<code_context>
eyJhbGciOiJub25lIn0.eyJleHAiOjQxMDI0NDQ4MDB9.
</code_context>
<issue_to_address>
**security (jwt):** Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

*Source: gitleaks*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for ID token-based login across the wallet stack, normalizes Google auth handlers, and updates package versions. The changes include modifications to several packages, adding a new IdTokenHandler, and updating the manager.ts to handle different authentication flows. The code changes look good, but there is an opportunity to improve the error message in packages/services/guard/src/sequence.ts.

@Dargon789
Copy link
Copy Markdown
Owner Author

@Mergifyio refresh

1 similar comment
@Dargon789
Copy link
Copy Markdown
Owner Author

@Mergifyio refresh

@mergify
Copy link
Copy Markdown

mergify bot commented Mar 19, 2026

refresh

☑️ Command refresh ignored because it is already running from a previous command.

@mergify
Copy link
Copy Markdown

mergify bot commented Mar 19, 2026

refresh

✅ Pull request refreshed

@Dargon789 Dargon789 merged commit c91776b into Dargon789:master Mar 19, 2026
10 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants