[samples] fix passkey challenge encoding in frontend sample#569
[samples] fix passkey challenge encoding in frontend sample#569claude[bot] wants to merge 1 commit into
Conversation
The Grid-issued passkey challenge is a lowercase hex string that should be UTF-8 encoded for WebAuthn, not base64url decoded. This aligns the sample with the clarified schema in #561. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryCorrects the WebAuthn challenge encoding in the embedded-wallet frontend sample so it uses
Confidence Score: 4/5Safe to merge — the encoding change is a straightforward one-liner that matches the documented API contract, and the only remaining concern is a dead The core fix is correct and validated against both the Mintlify docs and the API schema clarification. The samples/frontend/src/steps/embeddedWallet/AuthenticateAndSign.tsx — the now-unused
|
| Filename | Overview |
|---|---|
| samples/frontend/src/steps/embeddedWallet/AuthenticateAndSign.tsx | Fixes challenge encoding from base64url-decode to UTF-8 TextEncoder, matching docs and the schema clarification from #561. The now-unused base64urlToBytes helper remains as dead code. |
Sequence Diagram
sequenceDiagram
participant C as Client (Browser)
participant G as Grid API
participant A as Authenticator (OS)
C->>G: "POST /auth/credentials/{id}/challenge { clientPublicKey }"
G-->>C: "{ challenge (hex string), requestId }"
Note over C: new TextEncoder().encode(challenge)<br/>(UTF-8 bytes of hex string — this PR's fix)
C->>A: "navigator.credentials.get({ challenge: utf8Bytes })"
A-->>C: WebAuthn assertion
C->>G: "POST /auth/credentials/{id}/verify { assertion }<br/>Request-Id: requestId"
G-->>C: "{ encryptedSessionSigningKey }"
Comments Outside Diff (1)
-
samples/frontend/src/steps/embeddedWallet/AuthenticateAndSign.tsx, line 204-212 (link)The
base64urlToByteshelper is now unreferenced — its only call site was thechallengefield that this PR migrated toTextEncoder. Removing it eliminates dead code and avoids confusing future readers who might wonder whether base64url decoding is still part of any path.Prompt To Fix With AI
This is a comment left during a code review. Path: samples/frontend/src/steps/embeddedWallet/AuthenticateAndSign.tsx Line: 204-212 Comment: The `base64urlToBytes` helper is now unreferenced — its only call site was the `challenge` field that this PR migrated to `TextEncoder`. Removing it eliminates dead code and avoids confusing future readers who might wonder whether base64url decoding is still part of any path. How can I resolve this? If you propose a fix, please make it concise.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
samples/frontend/src/steps/embeddedWallet/AuthenticateAndSign.tsx:204-212
The `base64urlToBytes` helper is now unreferenced — its only call site was the `challenge` field that this PR migrated to `TextEncoder`. Removing it eliminates dead code and avoids confusing future readers who might wonder whether base64url decoding is still part of any path.
```suggestion
```
Reviews (1): Last reviewed commit: "[samples] fix passkey challenge encoding..." | Re-trigger Greptile
Summary
AuthenticateAndSign.tsxChanges
Frontend Sample:
base64urlToBytes(challenge.challenge)tonew TextEncoder().encode(challenge.challenge)for the WebAuthn assertionContext
PR #561 clarified that the passkey
challengefield fromPOST /auth/credentials/{id}/challengeis:The Mintlify documentation already correctly describes this encoding (showing
new TextEncoder().encode(gridChallenge)), but the frontend sample was using the wrong encoding method.Test plan
mintlify/snippets/global-accounts/authentication.mdx🤖 Generated with Claude Code