create-ailk 0.35.1 → 0.37.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 +51 -1
- package/component-catalog.md +8 -5
- package/dist/lib/env-catalog.js +8 -0
- package/dist/surfaces.js +66 -22
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.d.ts +19 -1
- package/dist/update.js +293 -35
- package/package.json +3 -3
- package/templates/.env.example +38 -0
- package/templates/apps/api/.env.example +45 -0
- package/templates/apps/api/CLAUDE.md +12 -4
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +73 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- 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 +241 -66
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- 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__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- 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/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
- 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 +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- 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 +9 -6
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- 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]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/[locale]/layout.tsx +24 -75
- 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 +166 -7
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
- 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/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -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 +738 -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/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -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/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -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__/offerings-pricing.test.ts +33 -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 +132 -8
- 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-routes.ts +11 -6
- 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/offerings-pricing.ts +4 -1
- package/templates/apps/web/lib/site-header.ts +14 -1
- 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 +264 -96
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
- 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,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
|
+
}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* 8876 D4, served by #8924) into two Pricing section fragments: one plan card
|
|
7
7
|
* per `ailkGroup: "plan"` Product and one add-on tile per `"addon"` Product,
|
|
8
8
|
* in the snapshot's order, each keyed by the Product's `{plan}` so `?plan=`
|
|
9
|
-
* (#8842) can match it. #
|
|
9
|
+
* (#8842) can match it. An `"offer"` Product (#11166) is in neither fragment:
|
|
10
|
+
* the member Billing's offer card renders it, never the pricing page. #8927
|
|
11
|
+
* places the fragments into `/pricing`.
|
|
10
12
|
*
|
|
11
13
|
* This is the one place Stripe text crosses into page markup, so contract
|
|
12
14
|
* docs/specs/8879-the-offerings-security-contract-key-spec.md binds it:
|
|
@@ -413,6 +415,7 @@ export function offeringsPricing(
|
|
|
413
415
|
shown.map((o) => o.requires).filter((plan) => plan !== undefined),
|
|
414
416
|
);
|
|
415
417
|
const offerings = narrowToPlans(shown, options.plans);
|
|
418
|
+
// #11166 — the two group reads are exact, so an `offer` falls into neither.
|
|
416
419
|
const planProducts = offerings.filter(
|
|
417
420
|
(o) => o.ailkGroup === "plan" && !requiredPlans.has(o.plan),
|
|
418
421
|
);
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
// signs in through its hub and carries commerce (#8217); elsewhere, null.
|
|
12
12
|
// readOwnAccounts lists the signed-in person's own sign-in accounts through
|
|
13
13
|
// Better Auth on a hub (#8431); a spoke has none here, so it answers null.
|
|
14
|
+
// readPhoneStep and loadPhoneApi read and write the account's phone step
|
|
15
|
+
// through Better Auth on a hub (#11138); a spoke's hub holds the person, so
|
|
16
|
+
// both answer null.
|
|
14
17
|
|
|
15
18
|
export const TOPOLOGY: "hub" | "spoke" = "hub";
|
|
16
19
|
export const UNSERVED_MCP_TOOLS: readonly string[] = [];
|
|
@@ -41,6 +44,42 @@ export async function readOwnAccounts(
|
|
|
41
44
|
return auth.api.listUserAccounts({ headers });
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
export type PhoneStep = {
|
|
48
|
+
available: boolean;
|
|
49
|
+
phone: { number: string; verified: boolean } | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type PhoneApi = {
|
|
53
|
+
sendPhoneNumberOTP: (input: { body: { phoneNumber: string }; headers: Headers }) => Promise<unknown>;
|
|
54
|
+
verifyPhoneNumber: (input: {
|
|
55
|
+
body: { phoneNumber: string; code: string; updatePhoneNumber: boolean };
|
|
56
|
+
headers: Headers;
|
|
57
|
+
}) => Promise<unknown>;
|
|
58
|
+
updateUser: (input: { body: { phoneNumber: null }; headers: Headers }) => Promise<unknown>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export async function readPhoneStep(headers: Headers): Promise<PhoneStep | null> {
|
|
62
|
+
const { auth } = await import("../auth");
|
|
63
|
+
// Whether the phone plugin is installed on this instance (#11106 D9).
|
|
64
|
+
const api: object = auth.api;
|
|
65
|
+
const available = "sendPhoneNumberOTP" in api;
|
|
66
|
+
if (!available) return { available, phone: null };
|
|
67
|
+
const session = await auth.api.getSession({ headers });
|
|
68
|
+
// The plugin's two user fields, which the conditional install leaves out
|
|
69
|
+
// of the inferred session type.
|
|
70
|
+
const user = (session?.user ?? {}) as { phoneNumber?: unknown; phoneNumberVerified?: unknown };
|
|
71
|
+
const phone =
|
|
72
|
+
typeof user.phoneNumber === "string" && user.phoneNumber !== ""
|
|
73
|
+
? { number: user.phoneNumber, verified: user.phoneNumberVerified === true }
|
|
74
|
+
: null;
|
|
75
|
+
return { available, phone };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function loadPhoneApi(): Promise<PhoneApi | null> {
|
|
79
|
+
const { auth, phoneStepActive } = await import("../auth");
|
|
80
|
+
return phoneStepActive() ? auth.api : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
44
83
|
export async function registerSiteStores(): Promise<void> {
|
|
45
84
|
const { registerLicenseKeyStore } = await import("./license-key-store");
|
|
46
85
|
await registerLicenseKeyStore();
|