[grid] fix passkey registration samples#565
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR updates the passkey registration samples to handle Grid's two-phase
Confidence Score: 5/5Safe 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: No files require special attention.
|
| 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})"
Reviews (3): Last reviewed commit: "[grid] fix passkey registration samples" | Re-trigger Greptile
78c963c to
a6cf246
Compare
bea498a to
167fdf7
Compare
8c57d07 to
93849f9
Compare
167fdf7 to
c14ff52
Compare
c14ff52 to
bf8ca05
Compare
93849f9 to
34cacac
Compare
The base branch was changed.
bf8ca05 to
2bf47ea
Compare
Merge activity
|

Summary
202signed-retry response before expecting an auth method id.Grid-Wallet-SignatureandRequest-Idthrough the Kotlin sample’sCredentialCreateParamson the signed retry.Validation
npm run buildinsamples/frontendCredentialCreateParamssupportsgridWalletSignatureandrequestId