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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Theme 1.9 — SSR theme + flash-prevention + CSS vars + meta + JSON-LD (#1322)
|
|
4
4
|
// Chrome extract — Nav + Footer from @working-theory/ui (#1451)
|
|
5
5
|
// Shell/Chrome composition — Nav + Footer wrap via @working-theory/templates MarketingShell (#2820)
|
|
6
|
-
// Session-aware Nav actions — Sign in
|
|
6
|
+
// Session-aware Nav actions — Sign in signed out, one "Your account" link signed in (#4984, #11095 D6)
|
|
7
7
|
// Auth route group — the marketing chrome is dropped on the five (auth) paths (#5963)
|
|
8
8
|
// Account area — the marketing chrome AND the consent Banner are dropped on /account paths (#7430)
|
|
9
9
|
// Site-declared theme — `_site.mdx` `theme:` block → token overlay → CSS vars
|
|
@@ -29,6 +29,7 @@ import { readFileSync } from "node:fs";
|
|
|
29
29
|
import { join } from "node:path";
|
|
30
30
|
|
|
31
31
|
import { Telemetry, VerificationMeta } from "@working-theory/analytics";
|
|
32
|
+
import { slugFormTarget } from "@working-theory/page-renderer";
|
|
32
33
|
import {
|
|
33
34
|
SiteConsentSchema,
|
|
34
35
|
type ConsentAppearance,
|
|
@@ -42,7 +43,7 @@ import {
|
|
|
42
43
|
Footer,
|
|
43
44
|
Nav,
|
|
44
45
|
type NavAction,
|
|
45
|
-
type
|
|
46
|
+
type NavProps,
|
|
46
47
|
} from "@working-theory/ui/chrome";
|
|
47
48
|
import {
|
|
48
49
|
cookiePurpose,
|
|
@@ -58,16 +59,13 @@ import {
|
|
|
58
59
|
import { BotIdClient } from "botid/client";
|
|
59
60
|
import type { Metadata, Viewport } from "next";
|
|
60
61
|
import { cookies, headers } from "next/headers";
|
|
62
|
+
import { permanentRedirect } from "next/navigation";
|
|
61
63
|
import { NextIntlClientProvider } from "next-intl";
|
|
62
64
|
import { getMessages, getTranslations } from "next-intl/server";
|
|
63
65
|
import type { ReactElement, ReactNode } from "react";
|
|
64
66
|
import { parse as parseYaml } from "yaml";
|
|
65
67
|
|
|
66
68
|
import { GoogleAnalytics } from "../../components/google-analytics";
|
|
67
|
-
import {
|
|
68
|
-
SignedInNav,
|
|
69
|
-
type SignedInNavProps,
|
|
70
|
-
} from "../../components/signed-in-nav";
|
|
71
69
|
import { isAccountPath, isAuthPath, isBookingPath } from "../../lib/auth-routes";
|
|
72
70
|
import { BOT_CLIENT_PROTECT, botCheckOn } from "../../lib/bot-check";
|
|
73
71
|
import { isClosingFooterPath } from "../../lib/closing-footer-path";
|
|
@@ -113,10 +111,13 @@ import {
|
|
|
113
111
|
} from "../../lib/site-brand";
|
|
114
112
|
import { siteChrome, type SiteChrome } from "../../lib/site-chrome";
|
|
115
113
|
import {
|
|
114
|
+
ACCOUNT_LABEL_KEY,
|
|
116
115
|
HEADER_CTA_LABEL_KEY,
|
|
117
116
|
readSiteHeader,
|
|
117
|
+
signedInHeaderActions,
|
|
118
118
|
signedOutHeaderActions,
|
|
119
119
|
} from "../../lib/site-header";
|
|
120
|
+
import { SITE_LISTING } from "../../lib/site-listing";
|
|
120
121
|
import { siteLogo } from "../../lib/site-logo";
|
|
121
122
|
// Registers the `_site.mdx` identity with page-renderer at module load, so
|
|
122
123
|
// every page rendered under this layout carries the sitewide JSON-LD (#6597).
|
|
@@ -128,11 +129,10 @@ import "../../lib/listings";
|
|
|
128
129
|
import { siteThemeHead } from "../../lib/site-theme-head";
|
|
129
130
|
import {
|
|
130
131
|
SIGN_IN_PATH,
|
|
131
|
-
SIGN_OUT_ENDPOINT,
|
|
132
132
|
SIGN_UP_PATH,
|
|
133
133
|
readSession,
|
|
134
134
|
} from "../../lib/topology.generated";
|
|
135
|
-
import { resolveBaseUrl } from "../../src/lib/routes";
|
|
135
|
+
import { pagePathFor, resolveBaseUrl } from "../../src/lib/routes";
|
|
136
136
|
|
|
137
137
|
import { ConsentBanner } from "./consent-banner";
|
|
138
138
|
import { readSiteContactLines } from "./contact/site-contact-lines";
|
|
@@ -164,26 +164,6 @@ const CONSENT_COOKIE_NAME = "ailk-consent";
|
|
|
164
164
|
|
|
165
165
|
type ThemeMode = "light" | "dark";
|
|
166
166
|
|
|
167
|
-
/**
|
|
168
|
-
* Placeholder flow for the signed-in Nav actions (#4984).
|
|
169
|
-
*
|
|
170
|
-
* `NavAction` has no client-handler kind — its shapes are `link` (navigate)
|
|
171
|
-
* and `flow` (open a StepFlow lightbox). The `flow` kind + Nav's
|
|
172
|
-
* `renderFlowTrigger` composer is Nav's ONE caller-composed seam (#4341): the
|
|
173
|
-
* caller receives the rendered trigger `<Button>` and decides what wraps it.
|
|
174
|
-
* The layout uses that seam WITHOUT a lightbox — `SignedInNav`'s
|
|
175
|
-
* `renderFlowTrigger` replaces both signed-in triggers (Account → a
|
|
176
|
-
* non-navigating name label, Sign out → `SignOutTrigger`), so this flow config
|
|
177
|
-
* is NEVER rendered. It only has to satisfy the type: one minimal fields-step
|
|
178
|
-
* and a dead `action`.
|
|
179
|
-
*/
|
|
180
|
-
const NAV_CLIENT_ACTION_FLOW: NavActionFlow["flow"] = {
|
|
181
|
-
steps: [
|
|
182
|
-
{ id: "noop", fields: [{ name: "noop", label: "noop", type: "text" }] },
|
|
183
|
-
],
|
|
184
|
-
action: "#",
|
|
185
|
-
};
|
|
186
|
-
|
|
187
167
|
// The member account shell's token reset (#8337 D3) — a package constant
|
|
188
168
|
// (no site, request or user input), computed once at module scope and
|
|
189
169
|
// emitted only on account routes, after `theme-vars`, below.
|
|
@@ -371,6 +351,20 @@ export default async function LocaleLayout({
|
|
|
371
351
|
// #6107 — a segment that is not an enabled locale is a 404, before any
|
|
372
352
|
// message load or session read.
|
|
373
353
|
assertEnabledLocale(locale);
|
|
354
|
+
// #10940 D4 — a row the site's listing moves answers its convention URL
|
|
355
|
+
// with a 308 to the route that serves it, locale kept. A missing
|
|
356
|
+
// `x-pathname` skips the check.
|
|
357
|
+
const requested = (await headers()).get("x-pathname");
|
|
358
|
+
const moved =
|
|
359
|
+
requested === null
|
|
360
|
+
? null
|
|
361
|
+
: slugFormTarget(
|
|
362
|
+
SITE_LISTING,
|
|
363
|
+
{ pathname: requested, locale },
|
|
364
|
+
pagePathFor,
|
|
365
|
+
);
|
|
366
|
+
if (moved !== null)
|
|
367
|
+
permanentRedirect(localeHref(locale, moved, DEFAULT_LOCALE));
|
|
374
368
|
const messages = await getMessages();
|
|
375
369
|
// #7742 D2 — `colorMode: "light"` pins the mode: a saved dark cookie is
|
|
376
370
|
// ignored, no flash script runs and no theme switch renders.
|
|
@@ -430,15 +424,13 @@ export default async function LocaleLayout({
|
|
|
430
424
|
const navItemLabels: Record<string, string> = Object.fromEntries(
|
|
431
425
|
[...navLabelKeys].map((key) => [key, navText(key)]),
|
|
432
426
|
);
|
|
433
|
-
//
|
|
434
|
-
//
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
navItemLabels["account"] = session.user.name ?? session.user.email;
|
|
438
|
-
}
|
|
427
|
+
// The signed-in action's label (#11095 D6): "Your account", from the
|
|
428
|
+
// `account` namespace, beside the nav keys.
|
|
429
|
+
const tAccount = await getTranslations({ locale, namespace: "account" });
|
|
430
|
+
navItemLabels[ACCOUNT_LABEL_KEY] = tAccount("yourAccount");
|
|
439
431
|
// The site's own signed-out header button (#10046) — `_site.mdx`'s
|
|
440
|
-
// `header.cta`. Its label is site content, written straight into the map
|
|
441
|
-
//
|
|
432
|
+
// `header.cta`. Its label is site content, written straight into the map;
|
|
433
|
+
// the composition is `signedOutHeaderActions` below.
|
|
442
434
|
const siteHeader = readSiteHeader();
|
|
443
435
|
if (siteHeader?.cta) {
|
|
444
436
|
navItemLabels[HEADER_CTA_LABEL_KEY] = siteHeader.cta.label;
|
|
@@ -469,11 +461,9 @@ export default async function LocaleLayout({
|
|
|
469
461
|
// route group, so both routes exist in every scaffold; whether the header
|
|
470
462
|
// shows them is the design's nav setting (#6797 — an earlier revision of
|
|
471
463
|
// this comment said the Free site had no sign-up flow; it renders both and
|
|
472
|
-
// the service shapes now roster both). Signed in →
|
|
473
|
-
//
|
|
474
|
-
//
|
|
475
|
-
// `renderFlowTrigger`, which `SignedInNav` owns (see NAV_CLIENT_ACTION_FLOW
|
|
476
|
-
// above).
|
|
464
|
+
// the service shapes now roster both). Signed in → one outline-strong
|
|
465
|
+
// "Your account" link to /account, where the account shell's Log out
|
|
466
|
+
// lives (#11095 D6) — a link action, so the Nav stays a Server Component.
|
|
477
467
|
// The signed-out auth pair, shared by the header (every page but the deck
|
|
478
468
|
// home) and the deck home's closing footer slide (#7718 D4).
|
|
479
469
|
// The pair comes from the generated seam (#7894 D10): a hub's /sign-in and
|
|
@@ -493,15 +483,7 @@ export default async function LocaleLayout({
|
|
|
493
483
|
: []),
|
|
494
484
|
];
|
|
495
485
|
const navActions: NavAction[] = session
|
|
496
|
-
?
|
|
497
|
-
{ labelKey: "account", kind: "flow", flow: NAV_CLIENT_ACTION_FLOW },
|
|
498
|
-
{
|
|
499
|
-
labelKey: "signOut",
|
|
500
|
-
kind: "flow",
|
|
501
|
-
flow: NAV_CLIENT_ACTION_FLOW,
|
|
502
|
-
variant: "outline-strong",
|
|
503
|
-
},
|
|
504
|
-
]
|
|
486
|
+
? signedInHeaderActions()
|
|
505
487
|
: signedOutHeaderActions(siteHeader, authActions);
|
|
506
488
|
|
|
507
489
|
// The announcement bar is HOME-ONLY (#5469 D5): its route gate matches the
|
|
@@ -546,13 +528,10 @@ export default async function LocaleLayout({
|
|
|
546
528
|
const headerIsFull = pageChrome.header === "full";
|
|
547
529
|
|
|
548
530
|
// Only a full header carries actions (#7718 D1, #10049). Under a bare or no
|
|
549
|
-
// header the auth links move to the footer — the auth pair signed out,
|
|
550
|
-
//
|
|
551
|
-
// user's name, `navLabels.items.account`).
|
|
531
|
+
// header the auth links move to the footer — the auth pair signed out,
|
|
532
|
+
// "Your account" signed in (the route where Sign out lives).
|
|
552
533
|
const headerActions: NavAction[] = headerIsFull ? navActions : [];
|
|
553
|
-
const deckFooterActions = session
|
|
554
|
-
? [{ labelKey: "account", path: "/account", variant: "outline-strong" as const }]
|
|
555
|
-
: [...authActions];
|
|
534
|
+
const deckFooterActions = session ? signedInHeaderActions() : [...authActions];
|
|
556
535
|
// #10550 D4 — the closing footer's site settings: its locality line, its
|
|
557
536
|
// actions (the primary, then the secondary — they replace the auth links
|
|
558
537
|
// on the closing footer in every header state) and its legal bar. The
|
|
@@ -586,19 +565,6 @@ export default async function LocaleLayout({
|
|
|
586
565
|
: []),
|
|
587
566
|
];
|
|
588
567
|
|
|
589
|
-
// A flow action needs `renderFlowTrigger`, a function — and this layout is a
|
|
590
|
-
// Server Component. Nav forwards that function into NavMobileMenu ("use
|
|
591
|
-
// client"), and React cannot serialize a function across the RSC boundary:
|
|
592
|
-
// passing it from here crashed EVERY signed-in page with "Functions cannot be
|
|
593
|
-
// passed directly to Client Components" (#7402). Nav's own
|
|
594
|
-
// `{...(renderFlowTrigger ? … : {})}` guard only skips the forward when the
|
|
595
|
-
// function is undefined; it never makes passing one legal. So a flow action
|
|
596
|
-
// routes the whole Nav through `SignedInNav` ("use client"), which defines
|
|
597
|
-
// `renderFlowTrigger` and imports `navItems` (icon components are functions
|
|
598
|
-
// too) on the client side. Without one, Nav stays a Server Component and
|
|
599
|
-
// nothing callable crosses.
|
|
600
|
-
const hasFlowAction = headerActions.some((action) => action.kind === "flow");
|
|
601
|
-
|
|
602
568
|
// Shared brand mark injected into both Nav and Footer chrome slots. The
|
|
603
569
|
// mark comes from site-logo.tsx (the mark the /sign-in card also renders);
|
|
604
570
|
// both add the shipped wordmark beside it — the Nav composes mark + wordmark
|
|
@@ -667,10 +633,10 @@ export default async function LocaleLayout({
|
|
|
667
633
|
!isMagnetWalkRoute &&
|
|
668
634
|
(await pageOptsIntoDeck({ pathname, locale }));
|
|
669
635
|
|
|
670
|
-
// Every Nav prop
|
|
671
|
-
//
|
|
672
|
-
//
|
|
673
|
-
const navProps:
|
|
636
|
+
// Every Nav prop but `navItems`, shared by the bare and the full Nav. No
|
|
637
|
+
// header action is a flow (#11095 D6), so nothing callable crosses the RSC
|
|
638
|
+
// boundary (#7402) and the Nav stays a Server Component in both states.
|
|
639
|
+
const navProps: Omit<NavProps, "navItems"> = {
|
|
674
640
|
locale,
|
|
675
641
|
labels: navLabels,
|
|
676
642
|
// Deck home (#5697): the two forwards that join #5426 D4 to a real deck.
|
|
@@ -970,14 +936,14 @@ export default async function LocaleLayout({
|
|
|
970
936
|
label: tNav("home"),
|
|
971
937
|
}}
|
|
972
938
|
/>
|
|
973
|
-
) : hasFlowAction ? (
|
|
974
|
-
<SignedInNav {...navProps} signOutEndpoint={SIGN_OUT_ENDPOINT} />
|
|
975
939
|
) : (
|
|
976
940
|
<Nav
|
|
977
941
|
{...navProps}
|
|
978
942
|
navItems={
|
|
979
943
|
siteChrome.nav === "mark-only" &&
|
|
980
|
-
(
|
|
944
|
+
(session !== null ||
|
|
945
|
+
pageChrome.header === "bare" ||
|
|
946
|
+
pageChrome.headerFromTemplate)
|
|
981
947
|
? []
|
|
982
948
|
: publicNavItems
|
|
983
949
|
}
|
|
@@ -85,6 +85,7 @@ jest.mock("../../../../src/lib/commerce-sections", () => ({
|
|
|
85
85
|
import { checkout } from "@working-theory/api-client";
|
|
86
86
|
import { notFound } from "next/navigation";
|
|
87
87
|
|
|
88
|
+
import { accountInviteHref } from "../../../../lib/account-invite";
|
|
88
89
|
import Page, { generateMetadata } from "../success/page";
|
|
89
90
|
|
|
90
91
|
const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
|
|
@@ -318,6 +319,55 @@ describe("/purchase/success", () => {
|
|
|
318
319
|
expect(metadata.robots).toEqual({ index: false, follow: true });
|
|
319
320
|
});
|
|
320
321
|
|
|
322
|
+
// ── #11095 D9, AC-7 — "Open your account" for the paid email ─────────────
|
|
323
|
+
|
|
324
|
+
it("a paid read with customerEmail renders Open your account at accountInviteHref, inside a data-sentry-block (AC-7)", async () => {
|
|
325
|
+
mockGetSession.mockResolvedValue({
|
|
326
|
+
ok: true,
|
|
327
|
+
body: { ...PAID_SESSION, customerEmail: "buyer@example.com" },
|
|
328
|
+
});
|
|
329
|
+
const { getByTestId } = await renderPage("cs_test_abc123");
|
|
330
|
+
const link = getByTestId("purchase-success-account");
|
|
331
|
+
expect(link.textContent).toBe("copy:success.openAccount");
|
|
332
|
+
const expected = accountInviteHref("en", "buyer@example.com");
|
|
333
|
+
expect(expected).not.toBeNull();
|
|
334
|
+
expect(link.getAttribute("href")).toBe(expected);
|
|
335
|
+
expect(link.closest("[data-sentry-block]")).not.toBeNull();
|
|
336
|
+
// The sections are unchanged in every state.
|
|
337
|
+
expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it.each([
|
|
341
|
+
["a paid read without customerEmail", { ok: true, body: PAID_SESSION }],
|
|
342
|
+
[
|
|
343
|
+
"an unpaid read, even with customerEmail",
|
|
344
|
+
{
|
|
345
|
+
ok: true,
|
|
346
|
+
body: { ...PAID_SESSION, paymentStatus: "unpaid", customerEmail: "buyer@example.com" },
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
["a 404 read", { ok: false, status: 404, body: { error: "unknown-session" } }],
|
|
350
|
+
])("%s renders no Open your account link (AC-7)", async (_label, response) => {
|
|
351
|
+
mockGetSession.mockResolvedValue(response);
|
|
352
|
+
const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
|
|
353
|
+
expect(queryByTestId("purchase-success-account")).toBeNull();
|
|
354
|
+
expect(queryByText("copy:success.openAccount")).toBeNull();
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it("a rejected read renders no Open your account link (AC-7)", async () => {
|
|
358
|
+
mockGetSession.mockRejectedValue(new Error("network"));
|
|
359
|
+
const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
|
|
360
|
+
expect(queryByTestId("purchase-success-account")).toBeNull();
|
|
361
|
+
expect(queryByText("copy:success.openAccount")).toBeNull();
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("sends no referrer (SEC-11095-5)", async () => {
|
|
365
|
+
const metadata = await generateMetadata({
|
|
366
|
+
params: Promise.resolve({ locale: "en" }),
|
|
367
|
+
});
|
|
368
|
+
expect(metadata.referrer).toBe("no-referrer");
|
|
369
|
+
});
|
|
370
|
+
|
|
321
371
|
// ── T-16 / D12 — the request-time commerce-claim gate ───────────────────
|
|
322
372
|
|
|
323
373
|
it("answers notFound() when the commerce claim is NOT held, before any API call (D12)", async () => {
|
|
@@ -52,9 +52,16 @@
|
|
|
52
52
|
*
|
|
53
53
|
* `noindex`: reachable only by finishing (or trying) a Checkout, never a
|
|
54
54
|
* page a crawler should list.
|
|
55
|
+
*
|
|
56
|
+
* #11095 D9 — "Open your account". A paid read whose answer carries
|
|
57
|
+
* `customerEmail` (the hub serves it only for a paid Offerings session of
|
|
58
|
+
* the caller's own workspace, under 24 h old) adds one link built by
|
|
59
|
+
* `accountInviteHref`. Session Replay records `href`s, so the link sits in a
|
|
60
|
+
* `data-sentry-block` wrapper, and the page sends no referrer (SEC-11095-5).
|
|
55
61
|
*/
|
|
56
62
|
import { checkout } from "@working-theory/api-client";
|
|
57
63
|
import type { CheckoutSessionReadResponse } from "@working-theory/api-client";
|
|
64
|
+
import { Button, Container, Link } from "@working-theory/ui";
|
|
58
65
|
import { SectionRenderer } from "@working-theory/ui/sections";
|
|
59
66
|
import type { PageSection } from "@working-theory/validation";
|
|
60
67
|
import { formatMoney } from "@working-theory/web-i18n";
|
|
@@ -64,6 +71,7 @@ import { notFound } from "next/navigation";
|
|
|
64
71
|
import { getTranslations } from "next-intl/server";
|
|
65
72
|
import type { ReactElement } from "react";
|
|
66
73
|
|
|
74
|
+
import { accountInviteHref } from "../../../../lib/account-invite";
|
|
67
75
|
import { resolveCommerceClaim } from "../../../../src/lib/commerce-claim";
|
|
68
76
|
import { ensureCommerceSectionsRegistered } from "../../../../src/lib/commerce-sections";
|
|
69
77
|
|
|
@@ -240,13 +248,23 @@ async function paidSections(
|
|
|
240
248
|
return [receipt, itemsSection(session.lineItems, t, locale), ctaSection(t)];
|
|
241
249
|
}
|
|
242
250
|
|
|
251
|
+
/** What the page renders: D6's sections, plus the paid read's account link (#11095 D9). */
|
|
252
|
+
interface SuccessView {
|
|
253
|
+
sections: PageSection[];
|
|
254
|
+
accountHref: string | null;
|
|
255
|
+
}
|
|
256
|
+
|
|
243
257
|
/** D6's five-row table, collapsed to the three code paths that produce distinct output. */
|
|
244
258
|
async function sectionsFor(
|
|
245
259
|
sessionId: string | undefined,
|
|
246
260
|
t: PurchaseT,
|
|
247
261
|
locale: string,
|
|
248
|
-
): Promise<
|
|
249
|
-
|
|
262
|
+
): Promise<SuccessView> {
|
|
263
|
+
const none = (sections: PageSection[]): SuccessView => ({
|
|
264
|
+
sections,
|
|
265
|
+
accountHref: null,
|
|
266
|
+
});
|
|
267
|
+
if (!sessionId) return none(unknownSections(t));
|
|
250
268
|
|
|
251
269
|
// A malformed/oversized id (D8's shape gate) or an unknown session both
|
|
252
270
|
// answer non-2xx here — the API's failure is logged server-side and never
|
|
@@ -261,15 +279,21 @@ async function sectionsFor(
|
|
|
261
279
|
try {
|
|
262
280
|
res = await checkout.getSession(sessionId, await resolveVisitorIpInit());
|
|
263
281
|
} catch {
|
|
264
|
-
return unknownSections(t);
|
|
282
|
+
return none(unknownSections(t));
|
|
265
283
|
}
|
|
266
|
-
if (!res.ok) return unknownSections(t);
|
|
284
|
+
if (!res.ok) return none(unknownSections(t));
|
|
267
285
|
|
|
268
286
|
if (res.body.paymentStatus !== "paid") {
|
|
269
|
-
return pendingSections(res.body, t, locale);
|
|
287
|
+
return none(pendingSections(res.body, t, locale));
|
|
270
288
|
}
|
|
271
289
|
|
|
272
|
-
|
|
290
|
+
const { customerEmail } = res.body;
|
|
291
|
+
return {
|
|
292
|
+
sections: await paidSections(res.body, t, locale),
|
|
293
|
+
accountHref: customerEmail
|
|
294
|
+
? accountInviteHref(locale, customerEmail)
|
|
295
|
+
: null,
|
|
296
|
+
};
|
|
273
297
|
}
|
|
274
298
|
|
|
275
299
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
@@ -279,6 +303,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
|
279
303
|
title: t("success.title"),
|
|
280
304
|
description: t("success.message"),
|
|
281
305
|
robots: { index: false, follow: true },
|
|
306
|
+
referrer: "no-referrer",
|
|
282
307
|
};
|
|
283
308
|
}
|
|
284
309
|
|
|
@@ -297,11 +322,27 @@ export default async function Page({
|
|
|
297
322
|
const query = searchParams ? await searchParams : {};
|
|
298
323
|
const sessionId = firstValue(query.session_id);
|
|
299
324
|
|
|
300
|
-
const sections = await sectionsFor(sessionId, t, locale);
|
|
325
|
+
const { sections, accountHref } = await sectionsFor(sessionId, t, locale);
|
|
301
326
|
|
|
302
327
|
return (
|
|
303
328
|
<main>
|
|
304
329
|
<SectionRenderer sections={sections} locale={locale} />
|
|
330
|
+
{accountHref !== null && (
|
|
331
|
+
// Session Replay records the DOM, so the link (it carries the email) is blocked from it.
|
|
332
|
+
<Container className="pb-section">
|
|
333
|
+
<div data-sentry-block>
|
|
334
|
+
<Button asChild size="big">
|
|
335
|
+
<Link
|
|
336
|
+
href={accountHref}
|
|
337
|
+
variant="bare"
|
|
338
|
+
data-testid="purchase-success-account"
|
|
339
|
+
>
|
|
340
|
+
{t("success.openAccount")}
|
|
341
|
+
</Link>
|
|
342
|
+
</Button>
|
|
343
|
+
</div>
|
|
344
|
+
</Container>
|
|
345
|
+
)}
|
|
305
346
|
</main>
|
|
306
347
|
);
|
|
307
348
|
}
|