Skip to content

[grid] fix passkey registration samples#565

Merged
DhruvPareek merged 1 commit into
mainfrom
dp/fix-passkey-registration-samples
Jun 10, 2026
Merged

[grid] fix passkey registration samples#565
DhruvPareek merged 1 commit into
mainfrom
dp/fix-passkey-registration-samples

Conversation

@DhruvPareek

@DhruvPareek DhruvPareek commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Update the frontend passkey registration sample to handle Grid’s 202 signed-retry response before expecting an auth method id.
  • Forward Grid-Wallet-Signature and Request-Id through the Kotlin sample’s CredentialCreateParams on the signed retry.
  • Keep the local WebAuthn registration challenge valid through the signed retry and consume it only when registration completes.

Validation

  • npm run build in samples/frontend
  • Inspected the published Grid Kotlin SDK classes to confirm CredentialCreateParams supports gridWalletSignature and requestId
  • Kotlin compile was not run locally because this machine has Java 17 while the sample Gradle config requires Java 21

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
grid-flow-builder Ignored Ignored Preview Jun 10, 2026 6:28pm

Request Review

@DhruvPareek DhruvPareek marked this pull request as ready for review June 9, 2026 20:13
@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the passkey registration samples to handle Grid's two-phase 202 signed-retry flow, forwarding Grid-Wallet-Signature and Request-Id on the retry, and preserving the WebAuthn challenge in the Kotlin backend until registration actually completes.

  • Frontend (RegisterPasskey.tsx): Splits the single-POST flow into a conditional two-phase call: if the first response contains payloadToSign and requestId, a signed retry is made with the same attestation body plus the two new headers; the registrationSignature helper resolves the signature from env var, sandbox default, or throws in production.
  • Kotlin (AuthCredentials.kt): Switches from atomic consume to non-consuming isValid on first validation, defers consume until Grid returns any non-202 status (success or error), and forwards Grid-Wallet-Signature / Request-Id through the new CredentialCreateParams builder; the raw-response adapter is used so the backend can proxy the actual Grid HTTP status back to the client.

Confidence Score: 5/5

Safe to merge — both the frontend retry logic and the Kotlin challenge-lifecycle change are correct for the two-phase registration flow.

The two-phase flow is handled correctly end-to-end: apiPost returns normally for all 2xx responses (including 202), the isValid/deferred-consume pattern keeps the challenge alive exactly through the signed-retry round-trip, and the raw-response adapter accurately proxies Grid's status code back to the browser. No logic gaps or data-loss paths were found.

No files require special attention.

Important Files Changed

Filename Overview
samples/frontend/src/steps/embeddedWallet/RegisterPasskey.tsx Adds two-phase 202-signed-retry handling; registrationSignature helper resolves wallet signature from env var or sandbox default. Logic is correct — apiPost returns normally for all 2xx including 202, so the payloadToSign/requestId check reliably detects the retry case.
samples/kotlin/src/main/kotlin/com/grid/sample/routes/AuthCredentials.kt Introduces isValid (non-consuming peek) alongside the existing consume, defers challenge removal until Grid returns non-202, and threads gridWalletSignature/requestId through CredentialCreateParams. Raw-response adapter correctly proxies Grid's HTTP status back to the client.

Sequence Diagram

sequenceDiagram
    participant Browser
    participant KotlinBackend
    participant Grid

    Browser->>KotlinBackend: POST /api/auth/credentials/registration-challenge
    KotlinBackend->>KotlinBackend: RegistrationChallengeStore.mint()
    KotlinBackend-->>Browser: "{challenge, rp, user}"

    Browser->>Browser: navigator.credentials.create()
    Browser->>KotlinBackend: "POST /api/auth/credentials {attestation, challenge}"
    KotlinBackend->>KotlinBackend: isValid(challenge) → true (no consume)
    KotlinBackend->>Grid: credentials.create(params)
    alt Grid requires signed retry
        Grid-->>KotlinBackend: "202 {payloadToSign, requestId}"
        KotlinBackend-->>Browser: "202 {payloadToSign, requestId}"
        Note over Browser: registrationSignature(payloadToSign)
        Browser->>KotlinBackend: "POST /api/auth/credentials {attestation, challenge} + Grid-Wallet-Signature + Request-Id"
        KotlinBackend->>KotlinBackend: isValid(challenge) → true (still alive)
        KotlinBackend->>Grid: credentials.create(params + signature + requestId)
        Grid-->>KotlinBackend: "201 {id, ...}"
        KotlinBackend->>KotlinBackend: consume(challenge)
        KotlinBackend-->>Browser: "201 {id, ...}"
    else Direct success
        Grid-->>KotlinBackend: "201 {id, ...}"
        KotlinBackend->>KotlinBackend: consume(challenge)
        KotlinBackend-->>Browser: "201 {id, ...}"
    end
    Browser->>Browser: "onComplete({authMethodId})"
Loading

Reviews (3): Last reviewed commit: "[grid] fix passkey registration samples" | Re-trigger Greptile

Comment thread samples/frontend/src/steps/embeddedWallet/RegisterPasskey.tsx
@DhruvPareek DhruvPareek force-pushed the dp/fix-global-account-hpke-docs branch from 78c963c to a6cf246 Compare June 10, 2026 17:08
@DhruvPareek DhruvPareek force-pushed the dp/fix-passkey-registration-samples branch from bea498a to 167fdf7 Compare June 10, 2026 17:08
carsonp6
carsonp6 previously approved these changes Jun 10, 2026
@DhruvPareek DhruvPareek force-pushed the dp/fix-global-account-hpke-docs branch 2 times, most recently from 8c57d07 to 93849f9 Compare June 10, 2026 18:25
@DhruvPareek DhruvPareek force-pushed the dp/fix-passkey-registration-samples branch from 167fdf7 to c14ff52 Compare June 10, 2026 18:25

@restamp-bot restamp-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

c14ff52 is a pure rebase onto 93849f9. Approving based on @carsonp6's previous approval of 167fdf7.

@DhruvPareek DhruvPareek changed the base branch from dp/fix-global-account-hpke-docs to graphite-base/565 June 10, 2026 18:27

@restamp-bot restamp-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

c14ff52 is a pure rebase onto 93849f9. Approving based on @carsonp6's previous approval of 167fdf7.

@DhruvPareek DhruvPareek force-pushed the dp/fix-passkey-registration-samples branch from c14ff52 to bf8ca05 Compare June 10, 2026 18:27

@restamp-bot restamp-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bf8ca05 is a pure rebase onto 34cacac. Approving based on @carsonp6's previous approval of 167fdf7.

restamp-bot[bot]
restamp-bot Bot previously approved these changes Jun 10, 2026

@restamp-bot restamp-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bf8ca05 is a pure rebase onto 34cacac. Approving based on @carsonp6's previous approval of 167fdf7.

@graphite-app graphite-app Bot changed the base branch from graphite-base/565 to main June 10, 2026 18:28
@graphite-app graphite-app Bot dismissed stale reviews from restamp-bot[bot] and carsonp6 June 10, 2026 18:28

The base branch was changed.

@DhruvPareek DhruvPareek force-pushed the dp/fix-passkey-registration-samples branch from bf8ca05 to 2bf47ea Compare June 10, 2026 18:28

@restamp-bot restamp-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bf8ca05 is a pure rebase onto 34cacac. Approving based on @carsonp6's previous approval of 167fdf7.

@restamp-bot restamp-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2bf47ea is a pure rebase onto 34cacac. Approving based on @carsonp6's previous approval of 167fdf7.

@DhruvPareek DhruvPareek merged commit 43b4727 into main Jun 10, 2026
8 checks passed

Copy link
Copy Markdown
Contributor Author

Merge activity

@DhruvPareek DhruvPareek deleted the dp/fix-passkey-registration-samples branch June 10, 2026 18:33
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.

2 participants