Skip to content

Commit 1ff29c6

Browse files
carsonp6Lightspark Eng
authored andcommitted
[js] gga example app: prune dead flows + stale PR-number comments (#28473)
## What Prune dead / reject-only flows and fix stale PR-number comments: demote the EMAIL_OTP "Add second" reject demo and OAUTH rechallenge no-op to Advanced (or remove), fold the duplicate EMAIL_OTP rechallenge into guided login, and reword the stale `"PR #28427:"` / `"PR 4 flow:"` comments to describe behavior. ## Why P4 example app, PR 3 in `40-example-app-design.md` §2/§5. These flows existed only to exercise reject paths or duplicated a guided step, and the PR-number comments anchor readers to specific (now-irrelevant) PRs rather than describing what the code does. Small, low-risk cleanup independent of the UI restructure. ## Place in the stack Base: #28472 (session.ts + status chip). Fourth PR of the **P4 example-app** stack. ## Notable points - Deletions/rewrites only; no new behavior. Reject/no-op demos are demoted, not silently lost. - Manual test tool; type gate: `build` + `lint`/`format`. --- Part of the Turnkey login-family migration program. See `sparkcore/sparkcore/grid/docs/login-migration/00-program-plan.md`. GitOrigin-RevId: 5158156f8af7183ce150e63815e4d2dd563b377b
1 parent 42dc5e3 commit 1ff29c6

4 files changed

Lines changed: 14 additions & 64 deletions

File tree

apps/examples/grid-global-accounts-example-app/index.html

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@
235235
<body>
236236
<h1>Grid Global Accounts - Example App</h1>
237237
<p class="note" style="margin-bottom: 12px">
238-
Signed-retry flows show the <code>requestId</code> /
239-
<code>payloadToSign</code> from step 1 so you can inspect them before
240-
step 2 forwards with
241-
<code>Grid-Wallet-Signature: sandbox-valid-signature</code>.
238+
Pick a mode at the top. Signed-retry flows are two-step — step 1 issues a
239+
202 challenge (<code>requestId</code> / <code>payloadToSign</code> you can
240+
inspect), step 2 forwards a <code>Grid-Wallet-Signature</code>: a magic
241+
value in sandbox, a real session stamp in production.
242242
</p>
243243

244244
<!-- ========== Shared Setup ========== -->
@@ -446,21 +446,12 @@ <h3>Verify → session (secure OTP)</h3>
446446

447447
<div class="subsection">
448448
<h3>
449-
Rechallenge (re-issue OTP)
450-
</h3>
451-
<p class="note">Uses Credential ID from Wallet Context.</p>
452-
<button id="btn-email_otp-rechallenge">Rechallenge</button>
453-
<div id="email_otp-rechallenge-status"></div>
454-
</div>
455-
456-
<div class="subsection">
457-
<h3>
458-
Add second EMAIL_OTP via signed retry
449+
Add second EMAIL_OTP (expected-reject demo)
459450
</h3>
460451
<p class="note">
461-
Rejects because one EMAIL_OTP already attached — step 1 exercises
462-
the reject path. Remove the first EMAIL_OTP to test the full add
463-
flow.
452+
Not a happy path. Rejects because one EMAIL_OTP is already attached
453+
— step 1 exercises the reject path. Remove the first EMAIL_OTP to
454+
test the full add flow.
464455
</p>
465456
<button id="btn-email_otp-add-issue">1. Issue add challenge</button>
466457
<div id="email_otp-add-issue-status"></div>
@@ -578,15 +569,6 @@ <h3>Verify → session</h3>
578569
<div id="oauth-verify-status"></div>
579570
</div>
580571

581-
<div class="subsection">
582-
<h3>Rechallenge</h3>
583-
<p class="note">
584-
OAUTH rechallenge is a no-op — just returns AuthMethod.
585-
</p>
586-
<button id="btn-oauth-rechallenge">Rechallenge</button>
587-
<div id="oauth-rechallenge-status"></div>
588-
</div>
589-
590572
<div class="subsection">
591573
<h3>
592574
Add additional OAUTH via signed retry
@@ -732,9 +714,9 @@ <h3>Create credential</h3>
732714
<div class="subsection">
733715
<h3>Session challenge</h3>
734716
<p class="note">
735-
PR 4 flow: <code>/challenge</code> returns
717+
<code>/challenge</code> returns
736718
<code>challenge = sha256(CREATE_READ_WRITE_SESSION body)</code> +
737-
<code>requestId</code>. Client signs the challenge via WebAuthn.
719+
<code>requestId</code>. The client signs the challenge via WebAuthn.
738720
</p>
739721
<label for="passkey-challenge-pubkey">Client Public Key (hex)</label>
740722
<input

apps/examples/grid-global-accounts-example-app/src/flows/email-otp.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMAIL_OTP lifecycle: create, secure-OTP challenge/verify, rechallenge, add.
1+
// EMAIL_OTP lifecycle: create, secure-OTP challenge/verify, add.
22

33
import { generateP256KeyPair } from "@turnkey/crypto";
44

@@ -134,22 +134,6 @@ export function wireEmailOtpFlows(): void {
134134
},
135135
);
136136

137-
bindClick(
138-
"btn-email_otp-rechallenge",
139-
"email_otp-rechallenge-status",
140-
"EMAIL_OTP Rechallenge",
141-
"Re-issuing OTP...",
142-
async () => {
143-
const credId = requireCredentialId();
144-
const { data } = await apiPost(
145-
`/auth/credentials/${encodeURIComponent(credId)}/challenge`,
146-
{},
147-
);
148-
addLog("EMAIL_OTP Rechallenge", data);
149-
return JSON.stringify(data, null, 2);
150-
},
151-
);
152-
153137
const emailOtpAddRequestId = el<HTMLInputElement>("email_otp-add-request-id");
154138
bindClick(
155139
"btn-email_otp-add-issue",

apps/examples/grid-global-accounts-example-app/src/flows/oauth.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// OAUTH lifecycle: create, verify (→ session), rechallenge (no-op), add.
1+
// OAUTH lifecycle: create, verify (→ session), add.
22

33
import { SANDBOX_SIG } from "../config";
44
import { apiPost } from "../api-client";
@@ -61,22 +61,6 @@ export function wireOauthFlows(): void {
6161
},
6262
);
6363

64-
bindClick(
65-
"btn-oauth-rechallenge",
66-
"oauth-rechallenge-status",
67-
"OAUTH Rechallenge",
68-
"Running no-op rechallenge...",
69-
async () => {
70-
const credId = requireCredentialId();
71-
const { data } = await apiPost(
72-
`/auth/credentials/${encodeURIComponent(credId)}/challenge`,
73-
{},
74-
);
75-
addLog("OAUTH Rechallenge", data);
76-
return JSON.stringify(data, null, 2);
77-
},
78-
);
79-
8064
const oauthAddRequestId = el<HTMLInputElement>("oauth-add-request-id");
8165
bindClick(
8266
"btn-oauth-add-issue",

apps/examples/grid-global-accounts-example-app/src/webauthn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export async function signWithPasskey(
9292
"No challenge — issue a session challenge (step above) first.",
9393
);
9494
}
95-
// PR #28427: Turnkey's WebAuthn challenge is the UTF-8 bytes of the
96-
// sha256-hex challenge string returned by /challenge — NOT base64url-decoded.
95+
// Turnkey's WebAuthn challenge is the UTF-8 bytes of the sha256-hex challenge
96+
// string returned by /challenge — NOT base64url-decoded.
9797
const challenge = new TextEncoder().encode(challengeValue);
9898
const allowCredentials: PublicKeyCredentialDescriptor[] = credentialId
9999
? [{ type: "public-key", id: b64UrlToBytes(credentialId) as BufferSource }]

0 commit comments

Comments
 (0)