create-ailk 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/component-catalog.json +37 -4
- package/component-catalog.md +11 -9
- package/dist/add-module.js +7 -2
- package/dist/derive-architecture.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/env-catalog.js +8 -0
- package/dist/module-architecture.js +9 -0
- package/dist/programmatic.js +5 -2
- package/dist/site-listing-path.d.ts +8 -0
- package/dist/site-listing-path.js +8 -0
- package/dist/surfaces.d.ts +20 -0
- package/dist/surfaces.js +32 -3
- package/dist/template-record.js +2 -0
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.js +11 -0
- package/package.json +3 -3
- package/templates/.env.example +21 -0
- package/templates/apps/api/.env.example +7 -0
- package/templates/apps/api/CLAUDE.md +14 -9
- package/templates/apps/mcp/CLAUDE.md +18 -7
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +46 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
- package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +12 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +55 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +60 -6
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +32 -3
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +47 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +214 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +6 -4
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -1
- package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
- package/templates/apps/web/app/[locale]/layout.tsx +42 -76
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +189 -6
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +101 -31
- package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
- package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +475 -7
- package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
- package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
- package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
- package/templates/apps/web/app/llms.txt/route.ts +14 -2
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
- package/templates/apps/web/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
- package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
- package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
- package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
- package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
- package/templates/apps/web/lib/account-config.ts +24 -9
- package/templates/apps/web/lib/auth-email.ts +62 -6
- package/templates/apps/web/lib/auth-env.ts +13 -0
- package/templates/apps/web/lib/auth-sms.ts +180 -0
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
- package/templates/apps/web/lib/hub-session/config.ts +7 -1
- package/templates/apps/web/lib/hub-session/entry.ts +238 -0
- package/templates/apps/web/lib/hub-session/index.ts +1 -4
- package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
- package/templates/apps/web/lib/hub-session/session.ts +120 -2
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
- package/templates/apps/web/lib/site-header.ts +14 -1
- package/templates/apps/web/lib/site-listing.ts +7 -0
- package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
- package/templates/apps/web/lib/topology.generated.ts +39 -0
- package/templates/apps/web/messages/en.json +125 -21
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +47 -47
- package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
- package/templates/apps/web/components/signed-in-nav.tsx +0 -79
- package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
- package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client"; // "use client" — loads Google's Identity Services script and handles its credential callback in the browser.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OneTap — Google One Tap on a spoke's signed-out account page (#11096 D10).
|
|
5
|
+
*
|
|
6
|
+
* Rendered by `SpokeSignIn` only when the spoke sets `AILK_HUB_ONE_TAP=on`
|
|
7
|
+
* and its hub reports a One Tap client id. On mount it asks this site's
|
|
8
|
+
* `POST /api/hub-session/one-tap/nonce` for a nonce, loads
|
|
9
|
+
* `https://accounts.google.com/gsi/client`, and calls
|
|
10
|
+
* `google.accounts.id.initialize({ client_id, nonce, callback,
|
|
11
|
+
* use_fedcm_for_prompt: true })` then `prompt()`. Google's callback hands the
|
|
12
|
+
* ID token to `POST /api/hub-session/one-tap`; only on `{ ok: true }` — the
|
|
13
|
+
* session cookie is set by then — does the page move, to `next`, on this
|
|
14
|
+
* site. Any other answer leaves the form as it is. Nothing here logs the
|
|
15
|
+
* token or the nonce.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { type ReactElement, useEffect } from "react";
|
|
19
|
+
|
|
20
|
+
const GSI_SRC = "https://accounts.google.com/gsi/client";
|
|
21
|
+
|
|
22
|
+
interface GoogleIdentity {
|
|
23
|
+
accounts?: {
|
|
24
|
+
id?: {
|
|
25
|
+
initialize(options: {
|
|
26
|
+
client_id: string;
|
|
27
|
+
nonce: string;
|
|
28
|
+
callback: (response: { credential?: string }) => void;
|
|
29
|
+
use_fedcm_for_prompt: boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
prompt(): void;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The one navigation the island makes — a test seam. */
|
|
37
|
+
export const oneTapNavigation = {
|
|
38
|
+
assign(url: string): void {
|
|
39
|
+
window.location.assign(url);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function googleIdentity(): GoogleIdentity | undefined {
|
|
44
|
+
return (window as unknown as { google?: GoogleIdentity }).google;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** How long the island waits for Google's script before it gives up. */
|
|
48
|
+
const GSI_TIMEOUT_MS = 10_000;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Google's script, loaded once per page. Always settles: it rejects when the
|
|
52
|
+
* script fails, loads without `google.accounts.id`, or has not loaded within
|
|
53
|
+
* 10 s (a tag already on the page may have loaded before this listened). A
|
|
54
|
+
* rejection leaves the form as it is.
|
|
55
|
+
*/
|
|
56
|
+
export function loadGoogle(): Promise<void> {
|
|
57
|
+
if (googleIdentity()?.accounts?.id) return Promise.resolve();
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const fail = (): void => reject(new Error("gsi"));
|
|
60
|
+
const timer = setTimeout(fail, GSI_TIMEOUT_MS);
|
|
61
|
+
const existing = document.querySelector<HTMLScriptElement>(`script[src="${GSI_SRC}"]`);
|
|
62
|
+
const script = existing ?? document.createElement("script");
|
|
63
|
+
script.addEventListener(
|
|
64
|
+
"load",
|
|
65
|
+
() => {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
if (googleIdentity()?.accounts?.id) resolve();
|
|
68
|
+
else fail();
|
|
69
|
+
},
|
|
70
|
+
{ once: true },
|
|
71
|
+
);
|
|
72
|
+
script.addEventListener(
|
|
73
|
+
"error",
|
|
74
|
+
() => {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
fail();
|
|
77
|
+
},
|
|
78
|
+
{ once: true },
|
|
79
|
+
);
|
|
80
|
+
if (existing === null) {
|
|
81
|
+
script.src = GSI_SRC;
|
|
82
|
+
script.async = true;
|
|
83
|
+
document.head.appendChild(script);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function postJson(url: string, body: unknown): Promise<unknown> {
|
|
89
|
+
const res = await fetch(url, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
credentials: "same-origin",
|
|
92
|
+
headers: { "content-type": "application/json" },
|
|
93
|
+
body: JSON.stringify(body),
|
|
94
|
+
});
|
|
95
|
+
if (!res.ok) return null;
|
|
96
|
+
return res.json().catch(() => null);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface OneTapProps {
|
|
100
|
+
/** The hub's Google client id, from the hub's client info. */
|
|
101
|
+
clientId: string;
|
|
102
|
+
/** Where to land once signed in — a path on this site, already sanitized. */
|
|
103
|
+
next: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function OneTap({ clientId, next }: OneTapProps): ReactElement {
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
let cancelled = false;
|
|
109
|
+
const onCredential = async (response: { credential?: string }): Promise<void> => {
|
|
110
|
+
if (typeof response.credential !== "string") return;
|
|
111
|
+
const answer = await postJson("/api/hub-session/one-tap", {
|
|
112
|
+
credential: response.credential,
|
|
113
|
+
}).catch(() => null);
|
|
114
|
+
if (
|
|
115
|
+
typeof answer === "object" &&
|
|
116
|
+
answer !== null &&
|
|
117
|
+
(answer as { ok?: unknown }).ok === true
|
|
118
|
+
) {
|
|
119
|
+
oneTapNavigation.assign(next);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const start = async (): Promise<void> => {
|
|
123
|
+
const minted = await postJson("/api/hub-session/one-tap/nonce", {});
|
|
124
|
+
const nonce =
|
|
125
|
+
typeof minted === "object" && minted !== null
|
|
126
|
+
? (minted as { nonce?: unknown }).nonce
|
|
127
|
+
: undefined;
|
|
128
|
+
if (typeof nonce !== "string") return;
|
|
129
|
+
await loadGoogle();
|
|
130
|
+
const id = googleIdentity()?.accounts?.id;
|
|
131
|
+
if (cancelled || !id) return;
|
|
132
|
+
id.initialize({
|
|
133
|
+
client_id: clientId,
|
|
134
|
+
nonce,
|
|
135
|
+
callback: (response) => void onCredential(response),
|
|
136
|
+
use_fedcm_for_prompt: true,
|
|
137
|
+
});
|
|
138
|
+
id.prompt();
|
|
139
|
+
};
|
|
140
|
+
start().catch(() => undefined);
|
|
141
|
+
return () => {
|
|
142
|
+
cancelled = true;
|
|
143
|
+
};
|
|
144
|
+
}, [clientId, next]);
|
|
145
|
+
|
|
146
|
+
// Google draws its own prompt; this marker only names the island.
|
|
147
|
+
return <div hidden data-testid="spoke-sign-in-one-tap" data-client-id={clientId} />;
|
|
148
|
+
}
|
|
@@ -16,16 +16,22 @@
|
|
|
16
16
|
* - `hubSessionBuyer(request)` — a customer the hub vouches for at buy time
|
|
17
17
|
* (D13): read live from `GET /v1/hub-sign-in/me`, never from the cookie.
|
|
18
18
|
*
|
|
19
|
+
* And the two writers every route that starts or finishes a sign-in shares
|
|
20
|
+
* (#11096 D2, D6): `startHubFlow` seals a new flow, and `sessionCookieFor`
|
|
21
|
+
* seals a credential the hub answered into the session cookie.
|
|
22
|
+
*
|
|
19
23
|
* Nothing here logs a credential, a cookie value or an email.
|
|
20
24
|
*/
|
|
21
25
|
|
|
22
|
-
import {
|
|
26
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
27
|
+
|
|
28
|
+
import { type HubSignInTokenResponse, hubSignIn } from "@working-theory/api-client";
|
|
23
29
|
import { headers as requestHeaders } from "next/headers";
|
|
24
30
|
|
|
25
31
|
import { resolveNextPath } from "../next-path";
|
|
26
32
|
|
|
27
33
|
import { type HubSessionConfig, hubSessionConfig } from "./config";
|
|
28
|
-
import { unseal } from "./seal";
|
|
34
|
+
import { seal, unseal } from "./seal";
|
|
29
35
|
|
|
30
36
|
/** The session cookie: `__Host-` on an https site, plain on a loopback one. */
|
|
31
37
|
export function sessionCookieName(config: Pick<HubSessionConfig, "secure">): string {
|
|
@@ -37,6 +43,14 @@ export function flowCookieName(config: Pick<HubSessionConfig, "secure">): string
|
|
|
37
43
|
return config.secure ? "__Host-ailk-hub-flow" : "ailk-hub-flow";
|
|
38
44
|
}
|
|
39
45
|
|
|
46
|
+
/** One Tap's nonce cookie (#11096 D10), named as the other two are. */
|
|
47
|
+
export function oneTapCookieName(config: Pick<HubSessionConfig, "secure">): string {
|
|
48
|
+
return config.secure ? "__Host-ailk-hub-one-tap" : "ailk-hub-one-tap";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** How long a One Tap nonce lives — Google's prompt and the person's tap. */
|
|
52
|
+
export const ONE_TAP_NONCE_TTL_SECONDS = 300;
|
|
53
|
+
|
|
40
54
|
/** The person a hub session names — the fields the account area reads. */
|
|
41
55
|
export interface HubSessionUser {
|
|
42
56
|
name: string | null;
|
|
@@ -164,6 +178,13 @@ export async function hubSessionBuyer(
|
|
|
164
178
|
/** Where to land after signing in, when `next` is missing or refused. */
|
|
165
179
|
export const HUB_SESSION_FALLBACK_PATH = "/account";
|
|
166
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Where a sign-in this site cannot complete lands (#11095 D4): the site's
|
|
183
|
+
* home. Never `/account`, whose signed-out gate redirects straight back into
|
|
184
|
+
* the sign-in — a loop.
|
|
185
|
+
*/
|
|
186
|
+
export const HUB_SESSION_HOME_PATH = "/";
|
|
187
|
+
|
|
167
188
|
/**
|
|
168
189
|
* The post-sign-in path for `raw`: `resolveNextPath`'s same-origin rule,
|
|
169
190
|
* printable ASCII only (it becomes a `Location` header), and never a path
|
|
@@ -178,3 +199,100 @@ export function hubNextPath(raw: unknown): string {
|
|
|
178
199
|
? HUB_SESSION_FALLBACK_PATH
|
|
179
200
|
: next;
|
|
180
201
|
}
|
|
202
|
+
|
|
203
|
+
/** How long a sign-in may take on the hub before the flow cookie expires. */
|
|
204
|
+
export const FLOW_TTL_SECONDS = 600;
|
|
205
|
+
|
|
206
|
+
/** The longest session the spoke keeps — the hub's own credential lifetime (spec 7894 D5). */
|
|
207
|
+
const MAX_SESSION_SECONDS = 86_400;
|
|
208
|
+
|
|
209
|
+
/** A sign-in flow just started: what the hub is sent, and the cookie that remembers it. */
|
|
210
|
+
export interface HubFlow {
|
|
211
|
+
/** The opaque `state` the hub echoes back. */
|
|
212
|
+
state: string;
|
|
213
|
+
/** The S256 challenge of the sealed verifier. */
|
|
214
|
+
challenge: string;
|
|
215
|
+
/** The `Set-Cookie` value of the sealed flow cookie (ten minutes). */
|
|
216
|
+
cookie: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Start a sign-in through the hub (#7894 D2; shared by every route that
|
|
221
|
+
* starts one, #11096 D2): a `state` and a PKCE verifier (32 random bytes
|
|
222
|
+
* each, base64url) sealed with the sanitized `next` into the flow cookie.
|
|
223
|
+
* Nothing here logs the state, the verifier or the challenge.
|
|
224
|
+
*/
|
|
225
|
+
export function startHubFlow(config: HubSessionConfig, next: unknown): HubFlow {
|
|
226
|
+
const state = randomBytes(32).toString("base64url");
|
|
227
|
+
const verifier = randomBytes(32).toString("base64url");
|
|
228
|
+
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
|
229
|
+
const name = flowCookieName(config);
|
|
230
|
+
const flow = seal(
|
|
231
|
+
{
|
|
232
|
+
v: 1,
|
|
233
|
+
state,
|
|
234
|
+
verifier,
|
|
235
|
+
next: hubNextPath(next),
|
|
236
|
+
expiresAt: Date.now() + FLOW_TTL_SECONDS * 1000,
|
|
237
|
+
},
|
|
238
|
+
config.sessionSecret,
|
|
239
|
+
"flow",
|
|
240
|
+
name,
|
|
241
|
+
);
|
|
242
|
+
return { state, challenge, cookie: cookieHeader(name, flow, FLOW_TTL_SECONDS, config) };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The session cookie for a credential the hub answered (#11096 D6) — the
|
|
247
|
+
* callback's code exchange and One Tap's both mint one. `null` when
|
|
248
|
+
* `expiresIn` is not a whole number of seconds from 1 to a day: a malformed
|
|
249
|
+
* answer from the hub must never yield a session that does not expire.
|
|
250
|
+
*/
|
|
251
|
+
export function sessionCookieFor(
|
|
252
|
+
config: HubSessionConfig,
|
|
253
|
+
token: Pick<HubSignInTokenResponse, "accessToken" | "expiresIn" | "user">,
|
|
254
|
+
): string | null {
|
|
255
|
+
const { accessToken, expiresIn, user } = token;
|
|
256
|
+
if (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > MAX_SESSION_SECONDS) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const payload: HubSessionPayload = {
|
|
260
|
+
v: 1,
|
|
261
|
+
accessToken,
|
|
262
|
+
expiresAt: Date.now() + expiresIn * 1000,
|
|
263
|
+
user: {
|
|
264
|
+
name: user.name,
|
|
265
|
+
email: user.email,
|
|
266
|
+
emailVerified: user.emailVerified,
|
|
267
|
+
createdAt: user.createdAt,
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
const name = sessionCookieName(config);
|
|
271
|
+
return cookieHeader(name, seal(payload, config.sessionSecret, "session", name), expiresIn, config);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Whether `request` comes from a page on `siteOrigin`: a `Sec-Fetch-Site`
|
|
276
|
+
* other than `same-origin`, an `Origin` other than the site's, or a request
|
|
277
|
+
* carrying neither is not. The check every state-changing POST of this
|
|
278
|
+
* module's routes makes before anything else.
|
|
279
|
+
*/
|
|
280
|
+
export function isSameOrigin(request: Request, siteOrigin: string | null): boolean {
|
|
281
|
+
const fetchSite = request.headers.get("sec-fetch-site");
|
|
282
|
+
const origin = request.headers.get("origin");
|
|
283
|
+
if (fetchSite === null && origin === null) return false;
|
|
284
|
+
if (fetchSite !== null && fetchSite !== "same-origin") return false;
|
|
285
|
+
if (origin !== null && origin !== siteOrigin) return false;
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** A 303 with no cache and no referrer, carrying each `Set-Cookie` given. */
|
|
290
|
+
export function seeOther(location: string, setCookies: readonly string[] = []): Response {
|
|
291
|
+
const headers = new Headers({
|
|
292
|
+
Location: location,
|
|
293
|
+
"Cache-Control": "no-store",
|
|
294
|
+
"Referrer-Policy": "no-referrer",
|
|
295
|
+
});
|
|
296
|
+
for (const value of setCookies) headers.append("Set-Cookie", value);
|
|
297
|
+
return new Response(null, { status: 303, headers });
|
|
298
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpokeSignIn — the signed-out account page of a spoke that signs in through
|
|
3
|
+
* its hub (#11096 D1, D9, D10; spec docs/specs/11096-the-spoke-hosts-the-sign-spec.md).
|
|
4
|
+
*
|
|
5
|
+
* A Server Component, rendered by the `(authed)` layout through the generated
|
|
6
|
+
* gate seam (`signed-out-gate.generated.tsx`, its `signIn: "hub"` render) for
|
|
7
|
+
* every signed-out account path. The person never sees the hub's brand here:
|
|
8
|
+
*
|
|
9
|
+
* - **The form.** One email field, the hub's sign-up agreements under a
|
|
10
|
+
* "New here?" line (unticked; ticking them makes the request a sign-up),
|
|
11
|
+
* and Continue with Google. It is a native `<form method="post">` to this
|
|
12
|
+
* site's `/api/hub-session/email`, inside `AuthCard`'s `body` (#9662), so
|
|
13
|
+
* it works without JavaScript. No password field, ever (D5), and no link
|
|
14
|
+
* to a hub page: Google goes to this site's own sign-in route with
|
|
15
|
+
* `provider=google`, which the hub's authorize step turns into Google.
|
|
16
|
+
* The agreements' policy links are the hub's (D3).
|
|
17
|
+
* - **Its states**, read from the middleware's `x-search` (a layout gets no
|
|
18
|
+
* `searchParams`): `?sent=1` (check your email), `?error=agreements |
|
|
19
|
+
* unavailable | exists | claim`.
|
|
20
|
+
* - **The purchase link** (`?claim=`, D9): "Open your account", the
|
|
21
|
+
* agreements' statements and one "Open my account" button whose form
|
|
22
|
+
* POSTs the claim to `/api/hub-session/open`. No checkbox: the click is the
|
|
23
|
+
* acceptance. Rendering it changes nothing (SEC-11096-3).
|
|
24
|
+
* - **One Tap** (D10): the `OneTap` island, only when the spoke sets
|
|
25
|
+
* `AILK_HUB_ONE_TAP=on` and its hub reports a client id.
|
|
26
|
+
*
|
|
27
|
+
* Not configured (`hubSessionConfig()` is `null`), it says sign-in isn't
|
|
28
|
+
* available yet and links back to the site. Nothing here logs a claim or
|
|
29
|
+
* anything `x-search` carries.
|
|
30
|
+
*/
|
|
31
|
+
import { localeHref } from "@working-theory/ui";
|
|
32
|
+
import { AuthCard, ConsentStatement } from "@working-theory/ui/blocks";
|
|
33
|
+
import { NavBackLink } from "@working-theory/ui/chrome";
|
|
34
|
+
import {
|
|
35
|
+
Button,
|
|
36
|
+
Checkbox,
|
|
37
|
+
Field,
|
|
38
|
+
InlineMessage,
|
|
39
|
+
Input,
|
|
40
|
+
Link,
|
|
41
|
+
Text,
|
|
42
|
+
} from "@working-theory/ui/primitives";
|
|
43
|
+
import { type HubSignUpAgreement, hubPurchaseClaimSchema } from "@working-theory/validation";
|
|
44
|
+
import { getTranslations } from "next-intl/server";
|
|
45
|
+
import type { ReactElement, ReactNode } from "react";
|
|
46
|
+
|
|
47
|
+
import { SITE_NAME } from "../site-brand";
|
|
48
|
+
import { siteLogo } from "../site-logo";
|
|
49
|
+
|
|
50
|
+
import { hubSessionConfig } from "./config";
|
|
51
|
+
import { readHubSignUp, readOneTapClientId } from "./entry";
|
|
52
|
+
import { OneTap } from "./one-tap";
|
|
53
|
+
import { HUB_SESSION_FALLBACK_PATH, hubNextPath } from "./session";
|
|
54
|
+
|
|
55
|
+
/** The spoke's own routes the page posts or links to. */
|
|
56
|
+
const EMAIL_ROUTE = "/api/hub-session/email";
|
|
57
|
+
const OPEN_ROUTE = "/api/hub-session/open";
|
|
58
|
+
const SIGN_IN_ROUTE = "/api/hub-session/sign-in";
|
|
59
|
+
|
|
60
|
+
export interface SpokeSignInProps {
|
|
61
|
+
locale: string;
|
|
62
|
+
/** The incoming request's headers: `x-pathname` and `x-search` (middleware). */
|
|
63
|
+
requestHeaders: Headers;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type Translate = Awaited<ReturnType<typeof getTranslations>>;
|
|
67
|
+
|
|
68
|
+
/** The one value of `name` in `search`, or `null` (absent or repeated). */
|
|
69
|
+
function single(search: URLSearchParams, name: string): string | null {
|
|
70
|
+
const values = search.getAll(name);
|
|
71
|
+
return values.length === 1 ? (values[0] ?? null) : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The page's frame: the back arrow, then the card (the account gate's own shape, #8790). */
|
|
75
|
+
function Frame({
|
|
76
|
+
locale,
|
|
77
|
+
backLabel,
|
|
78
|
+
card,
|
|
79
|
+
}: {
|
|
80
|
+
locale: string;
|
|
81
|
+
backLabel: string;
|
|
82
|
+
card: ReactNode;
|
|
83
|
+
}): ReactElement {
|
|
84
|
+
return (
|
|
85
|
+
<div className="flex min-h-screen flex-col" data-testid="account-sign-in-gate">
|
|
86
|
+
<header className="flex h-16 items-center px-5 md:px-8" data-testid="account-sign-in-gate-header">
|
|
87
|
+
<NavBackLink href={localeHref(locale, "/")} label={backLabel} />
|
|
88
|
+
</header>
|
|
89
|
+
<div className="flex flex-1 flex-col items-center md:justify-center md:py-section">
|
|
90
|
+
{/* AuthShell's 400px column: the cap sits on the wrapper, never on the card. */}
|
|
91
|
+
<div className="w-full max-w-100">{card}</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** One agreement's checkbox and statement; posts its purpose id under `agreements`. */
|
|
98
|
+
function AgreementRow({ agreement }: { agreement: HubSignUpAgreement }): ReactElement {
|
|
99
|
+
const id = `spoke-sign-in-agreement-${agreement.purposeId}`;
|
|
100
|
+
return (
|
|
101
|
+
<div className="flex items-start gap-3">
|
|
102
|
+
<Checkbox
|
|
103
|
+
id={id}
|
|
104
|
+
name="agreements"
|
|
105
|
+
value={agreement.purposeId}
|
|
106
|
+
aria-labelledby={`${id}-statement`}
|
|
107
|
+
className="mt-0.5"
|
|
108
|
+
data-testid={id}
|
|
109
|
+
/>
|
|
110
|
+
<ConsentStatement id={`${id}-statement`} statement={agreement.statement} policies={agreement.policies} />
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The line a `?error=` state puts above the form, or `null`. */
|
|
116
|
+
function errorLine(error: string | null, t: Translate): ReactNode {
|
|
117
|
+
const lines: Record<string, [string, string]> = {
|
|
118
|
+
unavailable: ["spoke-sign-in-unavailable", t("unavailable")],
|
|
119
|
+
exists: ["spoke-sign-in-exists", t("exists")],
|
|
120
|
+
claim: ["spoke-sign-in-claim-error", t("claimInvalid")],
|
|
121
|
+
};
|
|
122
|
+
const line = error === null ? undefined : lines[error];
|
|
123
|
+
if (line === undefined) return null;
|
|
124
|
+
return (
|
|
125
|
+
<InlineMessage variant={error === "exists" ? "default" : "error"} role="alert" data-testid={line[0]}>
|
|
126
|
+
{line[1]}
|
|
127
|
+
</InlineMessage>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function SpokeSignIn({ locale, requestHeaders }: SpokeSignInProps): Promise<ReactElement> {
|
|
132
|
+
const t = await getTranslations({ locale, namespace: "account.spokeSignIn" });
|
|
133
|
+
const gate = await getTranslations({ locale, namespace: "account.gate" });
|
|
134
|
+
const config = hubSessionConfig();
|
|
135
|
+
|
|
136
|
+
if (config === null) {
|
|
137
|
+
return (
|
|
138
|
+
<Frame
|
|
139
|
+
locale={locale}
|
|
140
|
+
backLabel={gate("homeLink")}
|
|
141
|
+
card={
|
|
142
|
+
<AuthCard
|
|
143
|
+
intent="sign-in"
|
|
144
|
+
footer="none"
|
|
145
|
+
headingLevel={1}
|
|
146
|
+
logo={siteLogo()}
|
|
147
|
+
labels={{ signInHeading: gate("emptyHeadline") }}
|
|
148
|
+
subhead={gate("emptyDescription")}
|
|
149
|
+
body={
|
|
150
|
+
<Button asChild variant="secondary" size="big" className="w-full">
|
|
151
|
+
<Link href={localeHref(locale, "/")} variant="bare" data-testid="account-sign-in-gate-home">
|
|
152
|
+
{gate("homeLink")}
|
|
153
|
+
</Link>
|
|
154
|
+
</Button>
|
|
155
|
+
}
|
|
156
|
+
/>
|
|
157
|
+
}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const search = new URLSearchParams(requestHeaders.get("x-search") ?? "");
|
|
163
|
+
const next = hubNextPath(
|
|
164
|
+
requestHeaders.get("x-pathname") ?? localeHref(locale, HUB_SESSION_FALLBACK_PATH),
|
|
165
|
+
);
|
|
166
|
+
const info = await readHubSignUp(config, locale);
|
|
167
|
+
const agreements = info?.signUpOpen ? info.agreements : [];
|
|
168
|
+
const error = single(search, "error");
|
|
169
|
+
const rawClaim = single(search, "claim");
|
|
170
|
+
const claim = rawClaim !== null && hubPurchaseClaimSchema.safeParse(rawClaim).success ? rawClaim : null;
|
|
171
|
+
const card = (heading: string, subhead: string, body: ReactNode): ReactElement => (
|
|
172
|
+
<Frame
|
|
173
|
+
locale={locale}
|
|
174
|
+
backLabel={gate("homeLink")}
|
|
175
|
+
card={
|
|
176
|
+
<AuthCard
|
|
177
|
+
intent="sign-in"
|
|
178
|
+
footer="none"
|
|
179
|
+
headingLevel={1}
|
|
180
|
+
logo={siteLogo()}
|
|
181
|
+
labels={{ signInHeading: heading }}
|
|
182
|
+
subhead={subhead}
|
|
183
|
+
body={body}
|
|
184
|
+
/>
|
|
185
|
+
}
|
|
186
|
+
/>
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// D9 — the purchase link. Without the hub's agreements to show, there is
|
|
190
|
+
// nothing to accept, so no button: the form takes over.
|
|
191
|
+
if (claim !== null && agreements.length > 0) {
|
|
192
|
+
return card(
|
|
193
|
+
t("openHeading"),
|
|
194
|
+
t("openLead"),
|
|
195
|
+
<form method="post" action={OPEN_ROUTE} className="flex flex-col gap-4" data-testid="spoke-sign-in-open-form">
|
|
196
|
+
<Input type="hidden" name="claim" value={claim} />
|
|
197
|
+
<div className="flex flex-col gap-2" data-testid="spoke-sign-in-open-terms">
|
|
198
|
+
{agreements.map((agreement) => (
|
|
199
|
+
<ConsentStatement
|
|
200
|
+
key={agreement.purposeId}
|
|
201
|
+
statement={agreement.statement}
|
|
202
|
+
policies={agreement.policies}
|
|
203
|
+
/>
|
|
204
|
+
))}
|
|
205
|
+
</div>
|
|
206
|
+
<Button type="submit" size="big" className="w-full" data-testid="spoke-sign-in-open">
|
|
207
|
+
{t("open")}
|
|
208
|
+
</Button>
|
|
209
|
+
</form>,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (single(search, "sent") === "1") {
|
|
214
|
+
return card(
|
|
215
|
+
t("sent"),
|
|
216
|
+
t("sentBody"),
|
|
217
|
+
<div className="flex flex-col gap-4" data-testid="spoke-sign-in-sent">
|
|
218
|
+
<Button asChild variant="secondary" size="big" className="w-full">
|
|
219
|
+
<Link href={next} variant="bare" data-testid="spoke-sign-in-back">
|
|
220
|
+
{t("back")}
|
|
221
|
+
</Link>
|
|
222
|
+
</Button>
|
|
223
|
+
</div>,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const oneTapClientId = config.oneTap ? await readOneTapClientId(config) : null;
|
|
228
|
+
const googleHref = `${SIGN_IN_ROUTE}?${new URLSearchParams({ next, provider: "google" }).toString()}`;
|
|
229
|
+
return card(
|
|
230
|
+
t("heading", { site: SITE_NAME }),
|
|
231
|
+
t("subhead"),
|
|
232
|
+
<div className="flex flex-col gap-4">
|
|
233
|
+
{errorLine(claim !== null ? "unavailable" : error, t)}
|
|
234
|
+
<form method="post" action={EMAIL_ROUTE} className="flex flex-col gap-4" data-testid="spoke-sign-in-form">
|
|
235
|
+
<Input type="hidden" name="next" value={next} />
|
|
236
|
+
<Field label={t("emailLabel")} htmlFor="spoke-sign-in-email">
|
|
237
|
+
<Input
|
|
238
|
+
type="email"
|
|
239
|
+
name="email"
|
|
240
|
+
required
|
|
241
|
+
autoComplete="email"
|
|
242
|
+
size="big"
|
|
243
|
+
data-testid="auth-email"
|
|
244
|
+
/>
|
|
245
|
+
</Field>
|
|
246
|
+
{agreements.length > 0 ? (
|
|
247
|
+
<fieldset className="flex flex-col gap-3" data-testid="spoke-sign-in-agreements">
|
|
248
|
+
<legend className="mb-2">
|
|
249
|
+
<Text as="span" variant="body-sm" tone="muted">
|
|
250
|
+
{t("newHere")}
|
|
251
|
+
</Text>
|
|
252
|
+
</legend>
|
|
253
|
+
{error === "agreements" ? (
|
|
254
|
+
<InlineMessage variant="error" role="alert" data-testid="spoke-sign-in-agreements-error">
|
|
255
|
+
{t("agreementsError")}
|
|
256
|
+
</InlineMessage>
|
|
257
|
+
) : null}
|
|
258
|
+
{agreements.map((agreement) => (
|
|
259
|
+
<AgreementRow key={agreement.purposeId} agreement={agreement} />
|
|
260
|
+
))}
|
|
261
|
+
</fieldset>
|
|
262
|
+
) : null}
|
|
263
|
+
<Button type="submit" size="big" className="w-full" data-testid="spoke-sign-in-submit">
|
|
264
|
+
{t("submit")}
|
|
265
|
+
</Button>
|
|
266
|
+
</form>
|
|
267
|
+
{info?.google ? (
|
|
268
|
+
<Button asChild variant="secondary" size="big" className="w-full">
|
|
269
|
+
<Link href={googleHref} variant="bare" data-testid="spoke-sign-in-google">
|
|
270
|
+
{t("google")}
|
|
271
|
+
</Link>
|
|
272
|
+
</Button>
|
|
273
|
+
) : null}
|
|
274
|
+
{oneTapClientId !== null ? <OneTap clientId={oneTapClientId} next={next} /> : null}
|
|
275
|
+
</div>,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `header.cta` replaces the signed-out Sign in / Sign up pair with the site's
|
|
5
5
|
* own button; `header.signIn` keeps Sign in beside it as a quieter text link
|
|
6
|
-
* (`link`, the default) or hides it. Signed in, the header is
|
|
6
|
+
* (`link`, the default) or hides it. Signed in, the header is one "Your
|
|
7
|
+
* account" link to `/account`, where Sign out lives (#11095 D6).
|
|
7
8
|
*
|
|
8
9
|
* A local frontmatter read rather than `@working-theory/site-config/server`,
|
|
9
10
|
* for the same reason as `app/[locale]/contact/site-contact-email.ts`:
|
|
@@ -27,6 +28,9 @@ import { resolveContentRoot } from "./site-brand";
|
|
|
27
28
|
/** The `labelKey` the CTA action carries; its test id is `nav-action-headerCta`. */
|
|
28
29
|
export const HEADER_CTA_LABEL_KEY = "headerCta";
|
|
29
30
|
|
|
31
|
+
/** The signed-in action's `labelKey`, labelled from `account.yourAccount`. */
|
|
32
|
+
export const ACCOUNT_LABEL_KEY = "yourAccount";
|
|
33
|
+
|
|
30
34
|
type LinkAction = Extract<NavAction, { path: string }>;
|
|
31
35
|
|
|
32
36
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
@@ -92,3 +96,12 @@ export function signedOutHeaderActions(
|
|
|
92
96
|
{ labelKey: HEADER_CTA_LABEL_KEY, path: cta.href, variant: "primary" },
|
|
93
97
|
];
|
|
94
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The signed-in header actions (#11095 D6): one "Your account" link to
|
|
102
|
+
* `/account`. Sign out is the account shell's own Log out, never a header
|
|
103
|
+
* action, so the header is a plain link and the Nav stays a Server Component.
|
|
104
|
+
*/
|
|
105
|
+
export function signedInHeaderActions(): LinkAction[] {
|
|
106
|
+
return [{ labelKey: ACCOUNT_LABEL_KEY, path: "/account", variant: "outline-strong" }];
|
|
107
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// site-listing.ts — the site's own listing of its pages (#10940). Site-owned:
|
|
2
|
+
// `create-ailk update` never overwrites it. A key is a hub row (`Type/slug`);
|
|
3
|
+
// `listed: false` keeps it out of /sitemap.xml and /llms.txt, `path` lists it
|
|
4
|
+
// (and 308s its convention URL) at the route that serves it.
|
|
5
|
+
import type { SiteListing } from "@working-theory/page-renderer";
|
|
6
|
+
|
|
7
|
+
export const SITE_LISTING: SiteListing = {};
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
// `/verify-email` or listing resume link.
|
|
24
24
|
// `lead` joined by #10826 (D5, SEC-10826-7): a magnet Lead's id on its
|
|
25
25
|
// `/flows/<slug>/verify?lead=…&verify=…` confirm link.
|
|
26
|
+
// `claim` joined by #11096 (D9, SEC-11096-4): the sealed purchase claim on a
|
|
27
|
+
// spoke's `/account?claim=…` "Open your account" link.
|
|
26
28
|
export const TOKEN_QUERY_PARAMS = [
|
|
27
29
|
"g",
|
|
28
30
|
"session_id",
|
|
@@ -31,6 +33,7 @@ export const TOKEN_QUERY_PARAMS = [
|
|
|
31
33
|
"ref",
|
|
32
34
|
"verify",
|
|
33
35
|
"lead",
|
|
36
|
+
"claim",
|
|
34
37
|
];
|
|
35
38
|
|
|
36
39
|
// The same grant id rides a PATH too: `deliverables.openGrant` fetches
|
|
@@ -54,9 +57,17 @@ const STRIPE_ID_QUERY_PARAMS = ["customer"];
|
|
|
54
57
|
const STRIPE_CUSTOMER_SEGMENT = /\/cus_[A-Za-z0-9]+(?=[/?#\s]|$)/g;
|
|
55
58
|
const STRIPE_CUSTOMER_SEGMENT_REDACTED = "/cus_redacted";
|
|
56
59
|
|
|
60
|
+
// #11106 D9 — the phone a person verifies on the hub's Account page and the
|
|
61
|
+
// code texted to it. Neither rides a page URL (both travel in a Server Action
|
|
62
|
+
// body), so — like the Stripe ids above — the list is not mirrored into
|
|
63
|
+
// packages/analytics; it is here so that no server-side request URL, query or
|
|
64
|
+
// span the SDK records can carry either.
|
|
65
|
+
export const PHONE_QUERY_PARAMS = ["phoneNumber", "code"];
|
|
66
|
+
|
|
57
67
|
const SCRUBBED_QUERY_PARAMS = [
|
|
58
68
|
...TOKEN_QUERY_PARAMS,
|
|
59
69
|
...STRIPE_ID_QUERY_PARAMS,
|
|
70
|
+
...PHONE_QUERY_PARAMS,
|
|
60
71
|
];
|
|
61
72
|
|
|
62
73
|
// Sentry navigation breadcrumbs (`data.to`/`data.from`) are relative
|