create-ailk 0.37.1 → 0.38.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.
Files changed (230) hide show
  1. package/README.md +129 -0
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +2 -2
  6. package/dist/add-route.js +18 -11
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +9 -15
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +86 -5
  37. package/dist/topology.d.ts +15 -1
  38. package/dist/topology.js +20 -4
  39. package/dist/update.d.ts +17 -2
  40. package/dist/update.js +480 -77
  41. package/package.json +3 -3
  42. package/templates/README.md +1 -1
  43. package/templates/apps/mcp/CLAUDE.md +5 -3
  44. package/templates/apps/web/CLAUDE.md +62 -20
  45. package/templates/apps/web/account.config.tsx +101 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  47. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  48. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  49. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  51. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  52. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  54. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  55. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  57. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  58. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  59. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  60. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  61. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  62. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  63. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  64. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  65. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  66. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  67. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  68. package/templates/apps/web/app/apple-icon.tsx +72 -0
  69. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  70. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  71. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  72. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  73. package/templates/apps/web/app/og/route.tsx +155 -72
  74. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  75. package/templates/apps/web/i18n/request.ts +44 -1
  76. package/templates/apps/web/jest.config.cjs +13 -1
  77. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  78. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  79. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  80. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  81. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  82. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  83. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  84. package/templates/apps/web/lib/listings.tsx +2 -2
  85. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  86. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  87. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  88. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  89. package/templates/apps/web/lib/served-pages.ts +95 -0
  90. package/templates/apps/web/lib/site-brand.tsx +3 -5
  91. package/templates/apps/web/messages/en.json +8 -684
  92. package/templates/apps/web/middleware.ts +3 -1
  93. package/templates/apps/web/next.config.mjs +27 -0
  94. package/templates/apps/web/package.json +1 -0
  95. package/templates/customizations.yaml +9 -0
  96. package/templates/package.json +3 -1
  97. package/templates/tools/lint-architecture.ts +164 -11
  98. package/versions.json +48 -47
  99. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  100. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  119. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  120. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  121. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  122. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  123. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  125. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  126. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  127. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  128. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  135. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  136. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  138. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  139. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  140. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  141. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  142. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  153. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  154. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  157. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  158. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  161. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  162. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  164. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  165. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  166. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  167. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  168. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  169. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  170. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  171. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  173. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  174. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  175. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  176. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  177. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  178. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  179. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  180. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  181. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  182. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  183. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  195. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  196. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  197. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  198. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  199. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  200. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  201. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  214. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  215. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  216. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  217. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  218. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  219. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  220. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  221. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  222. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  224. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  225. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  226. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  227. package/templates/apps/web/lib/account-config.ts +0 -678
  228. package/templates/apps/web/lib/checkout-config.ts +0 -16
  229. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  230. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,153 +0,0 @@
1
- // oss: false
2
- /**
3
- * `/[locale]/flows/[slug]/verify` — a magnet Lead's confirm page (#10826,
4
- * spec docs/specs/10826-the-four-conversions-as-completion-spec.md D5).
5
- * `noindex`.
6
- *
7
- * Three states, in this precedence:
8
- * - `?lead=<id>&verify=<nonce>` → a confirm card holding ONE button. The GET
9
- * writes nothing and calls no API: the button posts to
10
- * `confirmLeadEmailAction`, bound to the slug, the Lead id,
11
- * the nonce and the locale (no hidden input carries them),
12
- * so a mail scanner or a link preview that fetches the
13
- * link verifies nothing — only a person's click does.
14
- * - `?confirmed=1` → the verified card, with a link back to the magnet.
15
- * - `?error=…`, or any other query → the expired-or-invalid card.
16
- *
17
- * The link is the API's single-use nonce (`services/email-verification.ts`):
18
- * one confirm spends it, and it expires after 24 hours. `lead` and `verify`
19
- * are in both telemetry scrub lists.
20
- */
21
-
22
- import { localeHref } from "@working-theory/ui";
23
- import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
24
- import { Button, Text } from "@working-theory/ui/primitives";
25
- import { flowSlugSchema } from "@working-theory/validation";
26
- import type { Metadata } from "next";
27
- import { notFound } from "next/navigation";
28
- import { getTranslations } from "next-intl/server";
29
- import type { ReactElement } from "react";
30
-
31
- import { siteLogo } from "../../../../../lib/site-logo";
32
- import { confirmLeadEmailAction } from "../verify.actions";
33
-
34
- interface Props {
35
- params: Promise<{ locale: string; slug: string }>;
36
- searchParams?: Promise<{
37
- lead?: string | string[];
38
- verify?: string | string[];
39
- confirmed?: string | string[];
40
- error?: string | string[];
41
- }>;
42
- }
43
-
44
- const LEAD_ID_RE = /^lead_[0-9a-f-]{36}$/;
45
-
46
- function firstValue(raw: string | string[] | undefined): string {
47
- if (Array.isArray(raw)) return raw[0] ?? "";
48
- return raw ?? "";
49
- }
50
-
51
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
52
- const { locale } = await params;
53
- const t = await getTranslations({ locale, namespace: "flowVerify" });
54
- return { title: t("title"), robots: { index: false, follow: false } };
55
- }
56
-
57
- export default async function FlowVerifyPage({
58
- params,
59
- searchParams,
60
- }: Props): Promise<ReactElement> {
61
- const { locale, slug } = await params;
62
- if (!flowSlugSchema.safeParse(slug).success) notFound();
63
- const t = await getTranslations({ locale, namespace: "flowVerify" });
64
- const magnetHref = localeHref(locale, `/flows/${slug}`);
65
-
66
- const query = searchParams ? await searchParams : {};
67
- const leadId = firstValue(query.lead);
68
- const nonce = firstValue(query.verify);
69
-
70
- if (LEAD_ID_RE.test(leadId) && nonce.length >= 1 && nonce.length <= 256) {
71
- const labels: AuthCardLabels = {
72
- sentHeading: t("confirmHeading"),
73
- sentSubhead: t("confirmSubhead"),
74
- backToSignIn: t("back"),
75
- };
76
- return (
77
- <div className="flex flex-col gap-4" data-testid="flow-verify-page">
78
- <div data-testid="flow-verify-confirm">
79
- <AuthCard
80
- logo={siteLogo()}
81
- intent="sent"
82
- signInHref={magnetHref}
83
- labels={labels}
84
- body={
85
- <form
86
- action={confirmLeadEmailAction.bind(
87
- null,
88
- slug,
89
- leadId,
90
- nonce,
91
- locale,
92
- )}
93
- className="flex flex-col gap-5 text-center"
94
- >
95
- <Text variant="body-sm" tone="muted">
96
- {t("confirmBody")}
97
- </Text>
98
- <Button
99
- type="submit"
100
- size="big"
101
- className="min-h-11 w-full"
102
- data-testid="flow-verify-confirm-button"
103
- >
104
- {t("confirmButton")}
105
- </Button>
106
- </form>
107
- }
108
- />
109
- </div>
110
- </div>
111
- );
112
- }
113
-
114
- if (firstValue(query.confirmed) === "1") {
115
- const labels: AuthCardLabels = {
116
- sentHeading: t("confirmedHeading"),
117
- sentSubhead: t("confirmedSubhead"),
118
- sentBody: t("confirmedBody"),
119
- backToSignIn: t("back"),
120
- };
121
- return (
122
- <div className="flex flex-col gap-4" data-testid="flow-verify-page">
123
- <div data-testid="flow-verify-confirmed">
124
- <AuthCard
125
- logo={siteLogo()}
126
- intent="sent"
127
- signInHref={magnetHref}
128
- labels={labels}
129
- />
130
- </div>
131
- </div>
132
- );
133
- }
134
-
135
- const labels: AuthCardLabels = {
136
- invitationHeading: t("errorHeading"),
137
- invitationSubhead: t("errorSubhead"),
138
- invitationBody: t("errorBody"),
139
- backToSignIn: t("back"),
140
- };
141
- return (
142
- <div className="flex flex-col gap-4" data-testid="flow-verify-page">
143
- <div data-testid="flow-verify-error">
144
- <AuthCard
145
- logo={siteLogo()}
146
- intent="invitation"
147
- signInHref={magnetHref}
148
- labels={labels}
149
- />
150
- </div>
151
- </div>
152
- );
153
- }
@@ -1,151 +0,0 @@
1
- // oss: false
2
- "use server";
3
-
4
- /**
5
- * confirmLeadEmailAction — a person's confirm of a magnet Lead's emailed link
6
- * (#10826, spec docs/specs/10826-the-four-conversions-as-completion-spec.md
7
- * D5). The one place that link's nonce is spent.
8
- *
9
- * The page's GET (`verify/page.tsx`) renders a button and writes nothing, so a
10
- * mail scanner or a link preview that fetches the link verifies nothing; only
11
- * a person's POST reaches here. In order:
12
- *
13
- * 1. Every bound argument is re-validated (SEC-10826-6) — a direct call can
14
- * set any of them: `slug` against `flowSlugSchema`, `leadId` against the
15
- * id shape, `nonce` at 1–256 characters, `locale` against the enabled
16
- * locales. A refusal makes no API call.
17
- * 2. The per-visitor limit (5 per 10 minutes) and the bot check, before any
18
- * API call, because the API sees only this site's server address.
19
- * 3. `flows.verifyLead`, forwarding the visitor's address (SEC-10826-8).
20
- * 4. A redirect: a `user` magnet's verified Lead to the sign-up landing
21
- * (`accountInviteHref`), a `lead-link` landing when it is a plain
22
- * site-relative path (SEC-10826-5), else the confirmed card; everything
23
- * else to the error card.
24
- *
25
- * The nonce is never in a redirect URL and never logged here. No MCP twin
26
- * (`WEB_ONLY_ACTIONS` in `apps/mcp/__tests__/parity.test.ts`): it spends an
27
- * address credential only the mailbox holder has.
28
- */
29
-
30
- import { flows } from "@working-theory/api-client";
31
- import { localeHref } from "@working-theory/ui";
32
- import { flowSlugSchema } from "@working-theory/validation";
33
- import { headers } from "next/headers";
34
- import { redirect } from "next/navigation";
35
-
36
- import { accountInviteHref } from "../../../../lib/account-invite";
37
- import { runBotCheck } from "../../../../lib/bot-check";
38
- import { takeVisitorLimit } from "../../../../src/lib/rate-limit";
39
-
40
- const CONFIRM_LIMIT = 5;
41
- const CONFIRM_WINDOW_MS = 10 * 60 * 1000;
42
- const NO_HEADERS = { get: () => null };
43
-
44
- const LEAD_ID_RE = /^lead_[0-9a-f-]{36}$/;
45
- const NONCE_MAX = 256;
46
-
47
- const DEFAULT_LOCALE = "en";
48
- const ENABLED_LOCALES = (
49
- process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE
50
- ).split(",");
51
-
52
- /**
53
- * SEC-10826-5 — a landing is followed only when it is one `/` followed by
54
- * neither `/` nor a backslash, with no backslash anywhere: a site-relative
55
- * path, never `//host`, `/\host` or an absolute URL.
56
- */
57
- function isSitePath(landing: string): boolean {
58
- // One leading `/`, then no `/` or backslash; no backslash, whitespace or
59
- // control character anywhere — a browser strips TAB/CR/LF, so `/\t/host`
60
- // would otherwise become `//host` (security review, #10826).
61
- return /^\/(?![/\\])[^\\\s\p{Cc}]*$/u.test(landing);
62
- }
63
-
64
- type Answer = { kind: "confirmed"; to: string | null } | { kind: "refused" };
65
-
66
- async function confirm(
67
- slug: string,
68
- leadId: string,
69
- nonce: string,
70
- locale: string,
71
- ): Promise<Answer> {
72
- let requestHeaders: Awaited<ReturnType<typeof headers>> | undefined;
73
- try {
74
- requestHeaders = await headers();
75
- } catch {
76
- // No request scope to read — the shared unknown-visitor bucket.
77
- }
78
- const limit = takeVisitorLimit(
79
- "flowverify",
80
- requestHeaders ?? NO_HEADERS,
81
- CONFIRM_LIMIT,
82
- CONFIRM_WINDOW_MS,
83
- );
84
- if (!limit.allowed) return { kind: "refused" };
85
-
86
- const bot = await runBotCheck({
87
- source: "flow-verify",
88
- target: "confirmLeadEmailAction",
89
- scope: "write",
90
- });
91
- if (bot !== "pass") return { kind: "refused" };
92
-
93
- const visitorIp =
94
- requestHeaders?.get("x-forwarded-for") ?? requestHeaders?.get("x-real-ip");
95
- try {
96
- const res = visitorIp
97
- ? await flows.verifyLead(
98
- slug,
99
- { leadId, nonce },
100
- { headers: { "x-forwarded-for": visitorIp } },
101
- )
102
- : await flows.verifyLead(slug, { leadId, nonce });
103
- if (!res.ok) return { kind: "refused" };
104
- const { outcome, landing, signUpEmail } = res.body;
105
- if (outcome !== "verified" && outcome !== "already_verified")
106
- return { kind: "refused" };
107
- if (typeof signUpEmail === "string") {
108
- const href = accountInviteHref(locale, signUpEmail);
109
- if (href !== null) return { kind: "confirmed", to: href };
110
- }
111
- if (typeof landing === "string" && isSitePath(landing)) {
112
- return { kind: "confirmed", to: localeHref(locale, landing) };
113
- }
114
- return { kind: "confirmed", to: null };
115
- } catch {
116
- return { kind: "refused" };
117
- }
118
- }
119
-
120
- /**
121
- * Bound by the page — `confirmLeadEmailAction.bind(null, slug, leadId, nonce,
122
- * locale)` — so no hidden input carries the nonce; the form's own data is
123
- * ignored.
124
- */
125
- export async function confirmLeadEmailAction(
126
- slug: string,
127
- leadId: string,
128
- nonce: string,
129
- locale = DEFAULT_LOCALE,
130
- ): Promise<never> {
131
- const slugOk = flowSlugSchema.safeParse(slug).success;
132
- const localeOk = ENABLED_LOCALES.includes(locale);
133
- const safeLocale = localeOk ? locale : DEFAULT_LOCALE;
134
- // An unreadable slug has no confirm page of its own to land on.
135
- const page = slugOk ? `/flows/${slug}/verify` : "/";
136
- const errorHref = localeHref(safeLocale, `${page}?error=invalid`);
137
-
138
- const argumentsOk =
139
- slugOk &&
140
- localeOk &&
141
- typeof leadId === "string" &&
142
- LEAD_ID_RE.test(leadId) &&
143
- typeof nonce === "string" &&
144
- nonce.length >= 1 &&
145
- nonce.length <= NONCE_MAX;
146
- if (!argumentsOk) redirect(errorHref);
147
-
148
- const answer = await confirm(slug, leadId, nonce, safeLocale);
149
- if (answer.kind === "refused") redirect(errorHref);
150
- redirect(answer.to ?? localeHref(safeLocale, `${page}?confirmed=1`));
151
- }
@@ -1,128 +0,0 @@
1
- // oss: false
2
- "use client"; // Reads sessionStorage (a browser API) once on mount — a server page cannot.
3
-
4
- /**
5
- * BookingHandOff — `/meet/confirmed`'s booked time and Slack next step
6
- * (#9853 D10). The booker writes one `sessionStorage` item before it
7
- * navigates here (`BOOKING_CONFIRMATION_STORAGE_KEY`); this reads it once and
8
- * removes it, the read-once hand-off pattern, so the page's
9
- * address carries nothing about the booking and a later visit shows nothing.
10
- *
11
- * It renders only an item written for this page (`to`'s path, without its
12
- * query or hash, is `/meet/confirmed` or `/<locale>/meet/confirmed`) in the last ten
13
- * minutes. The time is formatted in the zone Cal.com recorded, with the zone
14
- * named, so the page and the Slack welcome name the same one; a zone `Intl`
15
- * does not know renders nothing. Every string is a prop the server page read
16
- * from the `schedule` namespace.
17
- */
18
- import { Container, Heading, Text } from "@working-theory/ui";
19
- import {
20
- BOOKING_CONFIRMATION_STORAGE_KEY,
21
- BookingConfirmationHandOffSchema,
22
- } from "@working-theory/validation";
23
- import type { ReactElement } from "react";
24
- import { useEffect, useState } from "react";
25
-
26
- /** A reserved name that never resolves: only used to read the path of `to`. */
27
- const PLACEHOLDER_ORIGIN = "https://placeholder.invalid";
28
- const CONFIRMED_PATH = "/meet/confirmed";
29
- const MAX_AGE_MS = 10 * 60_000;
30
-
31
- interface Props {
32
- locale: string;
33
- /** `schedule.confirmed.bookedTimeHeading`. */
34
- bookedTimeHeading: string;
35
- /** `schedule.confirmed.slackHeadline`. */
36
- slackHeadline: string;
37
- /** `schedule.confirmed.slackBody`. */
38
- slackBody: string;
39
- }
40
-
41
- interface Shown {
42
- time: string;
43
- slackOptIn: boolean;
44
- }
45
-
46
- /** Whether `to` names this page, with or without this page's `/<locale>`. */
47
- function namesThisPage(to: string, locale: string): boolean {
48
- let url: URL;
49
- try {
50
- url = new URL(to, PLACEHOLDER_ORIGIN);
51
- } catch {
52
- return false;
53
- }
54
- if (url.origin !== PLACEHOLDER_ORIGIN) return false;
55
- return (
56
- url.pathname === CONFIRMED_PATH ||
57
- url.pathname === `/${locale}${CONFIRMED_PATH}`
58
- );
59
- }
60
-
61
- /** Read the hand-off once, remove it, and answer what to show (or `null`). */
62
- function takeHandOff(locale: string): Shown | null {
63
- try {
64
- const stored = window.sessionStorage.getItem(
65
- BOOKING_CONFIRMATION_STORAGE_KEY,
66
- );
67
- if (stored === null) return null;
68
- window.sessionStorage.removeItem(BOOKING_CONFIRMATION_STORAGE_KEY);
69
- const parsed = BookingConfirmationHandOffSchema.safeParse(
70
- JSON.parse(stored),
71
- );
72
- if (!parsed.success) return null;
73
- const { to, savedAt, start, timeZone, slackOptIn } = parsed.data;
74
- const age = Date.now() - savedAt;
75
- if (!namesThisPage(to, locale) || age < 0 || age >= MAX_AGE_MS) return null;
76
- const time = new Intl.DateTimeFormat(locale, {
77
- weekday: "long",
78
- month: "long",
79
- day: "numeric",
80
- hour: "numeric",
81
- minute: "2-digit",
82
- timeZone,
83
- timeZoneName: "longGeneric",
84
- }).format(new Date(start));
85
- return { time, slackOptIn };
86
- } catch {
87
- // Unparseable JSON, refused storage, or a zone `Intl` does not know.
88
- return null;
89
- }
90
- }
91
-
92
- export function BookingHandOff({
93
- locale,
94
- bookedTimeHeading,
95
- slackHeadline,
96
- slackBody,
97
- }: Props): ReactElement | null {
98
- const [shown, setShown] = useState<Shown | null>(null);
99
-
100
- useEffect(() => {
101
- // Only ever sets: React's development double-mount runs this twice, and
102
- // the second run finds the item already removed.
103
- const found = takeHandOff(locale);
104
- if (found !== null) setShown(found);
105
- }, [locale]);
106
-
107
- if (shown === null) return null;
108
- return (
109
- <Container className="pt-block-loose">
110
- <div role="status" data-testid="booking-hand-off">
111
- <Heading level={2} visual={4}>
112
- {bookedTimeHeading}
113
- </Heading>
114
- <Text className="mt-2">{shown.time}</Text>
115
- {shown.slackOptIn && (
116
- <>
117
- <Heading level={2} visual={4} className="mt-block-tight">
118
- {slackHeadline}
119
- </Heading>
120
- <Text tone="muted" className="mt-2">
121
- {slackBody}
122
- </Text>
123
- </>
124
- )}
125
- </div>
126
- </Container>
127
- );
128
- }
@@ -1,126 +0,0 @@
1
- // oss: false
2
- /**
3
- * Tests for `/meet/confirmed`'s booking hand-off (#9853 D9, D10; AC-7).
4
- *
5
- * The booker hands this page the booked time, its zone and the Slack opt-in
6
- * through one `sessionStorage` item, never the address. The component reads
7
- * it once and removes it, and shows it only when it was written for this page
8
- * in the last ten minutes, formatted in the zone Cal.com recorded — the
9
- * prospect's, not the viewer's. Anything else renders nothing.
10
- */
11
- import React from "react";
12
- import { act, render, screen } from "@testing-library/react";
13
-
14
- import { BookingHandOff } from "../BookingHandOff";
15
-
16
- const STORAGE_KEY = "ailk:booking-confirmation";
17
- const PROPS = {
18
- locale: "en",
19
- bookedTimeHeading: "copy:confirmed.bookedTimeHeading",
20
- slackHeadline: "copy:confirmed.slackHeadline",
21
- slackBody: "copy:confirmed.slackBody",
22
- };
23
-
24
- function handOff(overrides: Record<string, unknown> = {}) {
25
- return {
26
- to: "/meet/confirmed",
27
- savedAt: Date.now(),
28
- start: "2026-10-30T20:00:00.000Z",
29
- timeZone: "America/Denver",
30
- slackOptIn: true,
31
- ...overrides,
32
- };
33
- }
34
-
35
- function store(value: unknown): void {
36
- window.sessionStorage.setItem(
37
- STORAGE_KEY,
38
- typeof value === "string" ? value : JSON.stringify(value),
39
- );
40
- }
41
-
42
- async function renderHandOff() {
43
- let utils!: ReturnType<typeof render>;
44
- await act(async () => {
45
- utils = render(<BookingHandOff {...PROPS} />);
46
- });
47
- return utils;
48
- }
49
-
50
- beforeEach(() => {
51
- window.sessionStorage.clear();
52
- window.history.replaceState(null, "", "/en/meet/confirmed");
53
- });
54
-
55
- describe("<BookingHandOff/> (#9853 AC-7)", () => {
56
- it("shows the booked time in the prospect's zone, named, and the Slack step; then forgets it", async () => {
57
- store(handOff());
58
- const { container } = await renderHandOff();
59
-
60
- expect(screen.getByText(PROPS.bookedTimeHeading)).toBeInTheDocument();
61
- expect(container.textContent).toContain("2:00");
62
- expect(container.textContent).toContain("Mountain Time");
63
- expect(screen.getByText(PROPS.slackHeadline)).toBeInTheDocument();
64
- expect(screen.getByText(PROPS.slackBody)).toBeInTheDocument();
65
- expect(screen.getByRole("status")).toBeInTheDocument();
66
- expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
67
- });
68
-
69
- it("accepts a destination written with a locale prefix, a query or a hash", async () => {
70
- store(handOff({ to: "/en/meet/confirmed?x=1#top" }));
71
- const { container } = await renderHandOff();
72
- expect(container.textContent).toContain("Mountain Time");
73
- });
74
-
75
- it("shows no Slack text when the box was not ticked", async () => {
76
- store(handOff({ slackOptIn: false }));
77
- const { container } = await renderHandOff();
78
- expect(container.textContent).toContain("Mountain Time");
79
- expect(screen.queryByText(PROPS.slackHeadline)).toBeNull();
80
- expect(screen.queryByText(PROPS.slackBody)).toBeNull();
81
- });
82
-
83
- it.each<[string, () => void]>([
84
- ["no item", () => undefined],
85
- ["an unparseable item", () => store("{not json")],
86
- [
87
- "an item with an extra email key",
88
- () => store(handOff({ email: "ada@example.com" })),
89
- ],
90
- [
91
- "an item for another page",
92
- () => store(handOff({ to: "/before-your-call" })),
93
- ],
94
- [
95
- "an item eleven minutes old",
96
- () => store(handOff({ savedAt: Date.now() - 11 * 60_000 })),
97
- ],
98
- [
99
- "a zone Intl does not know",
100
- () => store(handOff({ timeZone: "Mars/Olympus" })),
101
- ],
102
- ])("renders nothing, and removes the item, for %s", async (_label, seed) => {
103
- seed();
104
- const { container } = await renderHandOff();
105
- expect(container).toBeEmptyDOMElement();
106
- expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
107
- });
108
-
109
- it("shows nothing on a later visit", async () => {
110
- store(handOff());
111
- const first = await renderHandOff();
112
- first.unmount();
113
- const { container } = await renderHandOff();
114
- expect(container).toBeEmptyDOMElement();
115
- });
116
-
117
- it.each([
118
- "/fr/meet/confirmed",
119
- "/anything/meet/confirmed",
120
- "//evil.example/meet/confirmed",
121
- ])("renders nothing for a destination of %s", async (to) => {
122
- store(handOff({ to }));
123
- const { container } = await renderHandOff();
124
- expect(container).toBeEmptyDOMElement();
125
- });
126
- });