create-ailk 0.38.0 → 0.39.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 (135) hide show
  1. package/dist/add-route.js +1 -1
  2. package/dist/derive-architecture.js +3 -1
  3. package/dist/remove-module.js +18 -14
  4. package/dist/routes.d.ts +29 -2
  5. package/dist/routes.js +269 -23
  6. package/dist/site-manifest.js +6 -4
  7. package/dist/site-roster.d.ts +11 -3
  8. package/dist/site-roster.js +42 -22
  9. package/dist/surfaces.d.ts +11 -3
  10. package/dist/surfaces.js +69 -22
  11. package/dist/sync-routes.js +22 -5
  12. package/dist/template-record.js +3 -1
  13. package/dist/topology.d.ts +11 -0
  14. package/dist/topology.js +253 -3
  15. package/package.json +3 -3
  16. package/templates/apps/web/CLAUDE.md +26 -4
  17. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
  18. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
  19. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  20. package/templates/apps/web/account.config.tsx +2 -3
  21. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  22. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  23. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  24. package/templates/apps/web/app/[locale]/layout.tsx +1 -1
  25. package/templates/apps/web/auth.config.tsx +107 -0
  26. package/templates/apps/web/auth.ts +2 -1
  27. package/templates/apps/web/i18n/request.ts +9 -2
  28. package/templates/apps/web/jest.config.cjs +4 -0
  29. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +3 -0
  30. package/templates/apps/web/lib/__tests__/server-api.test.ts +1 -1
  31. package/templates/apps/web/lib/server-api.ts +1 -1
  32. package/templates/apps/web/lib/topology.generated.ts +5 -0
  33. package/templates/apps/web/messages/en.json +0 -152
  34. package/templates/apps/web/middleware.ts +12 -25
  35. package/templates/apps/web/next.config.mjs +8 -0
  36. package/templates/apps/web/package.json +1 -0
  37. package/templates/apps/web/types/messages.d.ts +6 -1
  38. package/versions.json +49 -48
  39. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  40. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  41. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  42. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  43. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  44. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  45. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  46. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  47. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  48. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  49. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  50. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  51. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  52. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  53. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  54. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  55. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  56. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  57. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  58. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  59. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  60. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  61. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  62. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  63. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  64. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  65. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  66. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  67. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  68. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  69. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  70. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -3
  71. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -3
  72. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -3
  73. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -2
  74. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -3
  75. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -12
  76. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -12
  77. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -12
  78. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -2
  79. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -12
  80. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -3
  81. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -10
  82. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -3
  83. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -3
  84. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -12
  85. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -2
  86. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -3
  87. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -3
  88. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  89. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -3
  90. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  91. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  92. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  93. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  94. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  95. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  96. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  97. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  98. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  99. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  100. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  101. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  102. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  103. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  104. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  105. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  106. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  107. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  108. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  109. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  110. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  111. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  112. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  113. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  114. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  115. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  116. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  117. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  118. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  119. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  120. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  121. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  122. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  123. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  124. package/templates/apps/web/lib/auth-routes.ts +0 -125
  125. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  126. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  127. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  128. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  129. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  130. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  131. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  132. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  133. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  134. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  135. package/templates/apps/web/lib/next-path.ts +0 -35
@@ -1,94 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- *
4
- * `confirmEmailAction` (#10820 D7) — the one place a sign-up link's nonce is
5
- * spent. The per-visitor limit and the bot check run before any API call; the
6
- * signed hop's answer picks the redirect; the nonce is in no redirect URL.
7
- */
8
-
9
- const mockRedirect = jest.fn((url: string) => {
10
- throw new Error(`REDIRECT ${url}`);
11
- });
12
- jest.mock("next/navigation", () => ({
13
- redirect: (url: string) => mockRedirect(url),
14
- }));
15
- jest.mock("next/headers", () => ({
16
- headers: async () => new Headers(),
17
- }));
18
-
19
- const mockRunBotCheck = jest.fn();
20
- // eslint-disable-next-line no-restricted-syntax -- BotID is an external service boundary; lib/bot-check.ts is its one wrapper.
21
- jest.mock("../../../../../lib/bot-check", () => ({
22
- runBotCheck: (...args: unknown[]) => mockRunBotCheck(...args),
23
- }));
24
-
25
- const mockConfirmSignUpEmail = jest.fn();
26
- // eslint-disable-next-line no-restricted-syntax -- the signed hop to apps/api is the HTTP boundary; lib/auth-email.ts's own suite pins its signing.
27
- jest.mock("../../../../../lib/auth-email", () => ({
28
- confirmSignUpEmail: (...args: unknown[]) => mockConfirmSignUpEmail(...args),
29
- }));
30
-
31
- import { __resetRateLimit } from "../../../../../src/lib/rate-limit";
32
- import { confirmEmailAction } from "../actions";
33
-
34
- const NONCE = "N".repeat(43);
35
-
36
- async function redirectOf(nonce = NONCE): Promise<string> {
37
- await expect(confirmEmailAction(nonce, "en")).rejects.toThrow(/^REDIRECT /);
38
- const url = mockRedirect.mock.calls.at(-1)![0];
39
- expect(url).not.toContain(nonce);
40
- return url;
41
- }
42
-
43
- beforeEach(() => {
44
- jest.clearAllMocks();
45
- __resetRateLimit();
46
- mockRunBotCheck.mockResolvedValue("pass");
47
- mockConfirmSignUpEmail.mockResolvedValue("verified");
48
- });
49
-
50
- describe("confirmEmailAction (#10820 D7)", () => {
51
- it.each(["verified", "already_verified"])(
52
- "redirects to the verified card on %s",
53
- async (outcome) => {
54
- mockConfirmSignUpEmail.mockResolvedValue(outcome);
55
- expect(await redirectOf()).toBe("/verify-email?confirmed=1");
56
- expect(mockConfirmSignUpEmail).toHaveBeenCalledWith(NONCE);
57
- },
58
- );
59
-
60
- it.each(["expired", "invalid", "failed"])(
61
- "redirects to the expired-link card on %s",
62
- async (outcome) => {
63
- mockConfirmSignUpEmail.mockResolvedValue(outcome);
64
- expect(await redirectOf()).toBe("/verify-email?error=invalid");
65
- },
66
- );
67
-
68
- it("redirects to the expired-link card when the hop throws", async () => {
69
- mockConfirmSignUpEmail.mockRejectedValue(new Error("boom"));
70
- expect(await redirectOf()).toBe("/verify-email?error=invalid");
71
- });
72
-
73
- it.each(["bot", "unavailable"])(
74
- "makes no API call when the bot check answers %s",
75
- async (verdict) => {
76
- mockRunBotCheck.mockResolvedValue(verdict);
77
- expect(await redirectOf()).toBe("/verify-email?error=invalid");
78
- expect(mockConfirmSignUpEmail).not.toHaveBeenCalled();
79
- },
80
- );
81
-
82
- it("makes no API call once the visitor limit is spent", async () => {
83
- // An unreadable address shares the unknown bucket, 10x the per-visitor 5.
84
- for (let i = 0; i < 50; i += 1) await redirectOf();
85
- mockConfirmSignUpEmail.mockClear();
86
- expect(await redirectOf()).toBe("/verify-email?error=invalid");
87
- expect(mockConfirmSignUpEmail).not.toHaveBeenCalled();
88
- });
89
-
90
- it("redirects on the default locale for a locale outside the enabled set", async () => {
91
- await expect(confirmEmailAction(NONCE, "/evil.example")).rejects.toThrow(/^REDIRECT /);
92
- expect(mockRedirect).toHaveBeenLastCalledWith("/verify-email?confirmed=1");
93
- });
94
- });
@@ -1,77 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * The sign-up confirm click (#10820 D7) — the one place a `/verify-email`
5
- * link's nonce is spent.
6
- *
7
- * The page's GET renders a button and writes nothing, so a mail scanner or a
8
- * link preview that fetches the link verifies nothing; only a person's POST
9
- * reaches here. Before any API call it takes the per-visitor limit (5 per
10
- * 10 minutes) and the bot check, because the API sees only this site's server
11
- * address. Then the signed hop, `confirmSignUpEmail`, and a redirect: the
12
- * verified card for `verified` and `already_verified`, the expired-link card
13
- * for everything else. The nonce is never in either redirect URL, and never
14
- * logged here.
15
- */
16
-
17
- import { localeHref } from "@working-theory/ui";
18
- import { headers } from "next/headers";
19
- import { redirect } from "next/navigation";
20
-
21
- import { confirmSignUpEmail } from "../../../../lib/auth-email";
22
- import { runBotCheck } from "../../../../lib/bot-check";
23
- import { takeVisitorLimit } from "../../../../src/lib/rate-limit";
24
-
25
- const CONFIRM_LIMIT = 5;
26
- const CONFIRM_WINDOW_MS = 10 * 60 * 1000;
27
- const NO_HEADERS = { get: () => null };
28
-
29
- async function confirmed(nonce: string): Promise<boolean> {
30
- let requestHeaders: Awaited<ReturnType<typeof headers>> | undefined;
31
- try {
32
- requestHeaders = await headers();
33
- } catch {
34
- // No request scope to read — the shared unknown-visitor bucket.
35
- }
36
- const limit = takeVisitorLimit(
37
- "verifyemail",
38
- requestHeaders ?? NO_HEADERS,
39
- CONFIRM_LIMIT,
40
- CONFIRM_WINDOW_MS,
41
- );
42
- if (!limit.allowed) return false;
43
-
44
- const bot = await runBotCheck({
45
- source: "verify-email",
46
- target: "confirmEmailAction",
47
- scope: "write",
48
- });
49
- if (bot !== "pass") return false;
50
-
51
- // `confirmSignUpEmail` never throws by contract; this guard keeps the
52
- // action's own promise (a redirect, never a 500) if that ever changes.
53
- try {
54
- const outcome = await confirmSignUpEmail(nonce);
55
- return outcome === "verified" || outcome === "already_verified";
56
- } catch {
57
- return false;
58
- }
59
- }
60
-
61
- // The locale is a bound argument a direct call could set to anything, so the
62
- // redirect's segment is checked against the build-time allowlist, never
63
- // interpolated raw (the `checkout.actions.ts` idiom).
64
- const DEFAULT_LOCALE = "en";
65
- const ENABLED_LOCALES = (process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE).split(",");
66
-
67
- /**
68
- * Bound by the page — `confirmEmailAction.bind(null, nonce, locale)` — so no
69
- * hidden input carries the nonce; the form's own data is ignored.
70
- */
71
- export async function confirmEmailAction(nonce: string, locale = "en"): Promise<never> {
72
- const ok = await confirmed(nonce);
73
- const safeLocale = ENABLED_LOCALES.includes(locale) ? locale : DEFAULT_LOCALE;
74
- redirect(
75
- localeHref(safeLocale, ok ? "/verify-email?confirmed=1" : "/verify-email?error=invalid"),
76
- );
77
- }
@@ -1,154 +0,0 @@
1
- /**
2
- * `/[locale]/verify-email` — the check-your-email terminus (#5963, wired by
3
- * #5962) and the sign-up confirm page (#10820 D7).
4
- *
5
- * Four states, in this precedence:
6
- * - `?verify=<nonce>` → a confirm card holding ONE button. The GET writes
7
- * nothing: the button posts to `confirmEmailAction`, bound
8
- * to the nonce (no hidden input carries it), so a mail
9
- * scanner or a link preview that fetches the link verifies
10
- * nothing — only a person's click does.
11
- * - `?confirmed=1` → the verified card, with the Sign in link.
12
- * - `?error=…` → the same expired/invalid-link state `/reset-password`
13
- * renders: the action's answer for an expired, unknown or
14
- * refused confirm.
15
- * - no query → the `sent` intent: this page states what just happened.
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.
19
- */
20
-
21
- import { localeHref } from "@working-theory/ui";
22
- import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
23
- import { Button, Text } from "@working-theory/ui/primitives";
24
- import type { Metadata } from "next";
25
- import { getTranslations } from "next-intl/server";
26
- import type { ReactElement } from "react";
27
-
28
- import { siteLogo } from "../../../../lib/site-logo";
29
-
30
- import { confirmEmailAction } from "./actions";
31
-
32
- interface Props {
33
- params: Promise<{ locale: string }>;
34
- searchParams?: Promise<{
35
- error?: string | string[];
36
- verify?: string | string[];
37
- confirmed?: string | string[];
38
- }>;
39
- }
40
-
41
- function firstValue(raw: string | string[] | undefined): string {
42
- if (Array.isArray(raw)) return raw[0] ?? "";
43
- return raw ?? "";
44
- }
45
-
46
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
47
- const { locale } = await params;
48
- const t = await getTranslations({ locale, namespace: "auth" });
49
- return {
50
- title: t("verifyEmailTitle"),
51
- description: t("verifyEmailDescription"),
52
- };
53
- }
54
-
55
- export default async function VerifyEmailPage({
56
- params,
57
- searchParams,
58
- }: Props): Promise<ReactElement> {
59
- const { locale } = await params;
60
- const t = await getTranslations({ locale, namespace: "auth" });
61
- const signInHref = localeHref(locale, "/sign-in");
62
-
63
- const query = searchParams ? await searchParams : {};
64
- const error = firstValue(query.error);
65
- const nonce = firstValue(query.verify);
66
-
67
- if (nonce.length >= 1 && nonce.length <= 256) {
68
- const labels: AuthCardLabels = {
69
- sentHeading: t("confirmHeading"),
70
- sentSubhead: t("confirmSubhead"),
71
- backToSignIn: t("backToSignIn"),
72
- };
73
- return (
74
- <div className="flex flex-col gap-4" data-testid="verify-email-page">
75
- <div data-testid="verify-email-confirm">
76
- <AuthCard
77
- logo={siteLogo()}
78
- intent="sent"
79
- signInHref={signInHref}
80
- labels={labels}
81
- body={
82
- <form
83
- action={confirmEmailAction.bind(null, nonce, locale)}
84
- className="flex flex-col gap-5 text-center"
85
- >
86
- <Text variant="body-sm" tone="muted">
87
- {t("confirmBody")}
88
- </Text>
89
- <Button
90
- type="submit"
91
- size="big"
92
- className="w-full"
93
- data-testid="verify-email-confirm-button"
94
- >
95
- {t("confirmButton")}
96
- </Button>
97
- </form>
98
- }
99
- />
100
- </div>
101
- </div>
102
- );
103
- }
104
-
105
- if (firstValue(query.confirmed) === "1") {
106
- const labels: AuthCardLabels = {
107
- sentHeading: t("verifiedHeading"),
108
- sentSubhead: t("verifiedSubhead"),
109
- sentBody: t("verifiedBody"),
110
- backToSignIn: t("backToSignIn"),
111
- };
112
- return (
113
- <div className="flex flex-col gap-4" data-testid="verify-email-page">
114
- <div data-testid="verify-email-confirmed">
115
- <AuthCard logo={siteLogo()} intent="sent" signInHref={signInHref} labels={labels} />
116
- </div>
117
- </div>
118
- );
119
- }
120
-
121
- if (error) {
122
- const labels: AuthCardLabels = {
123
- invitationHeading: t("verifyExpiredHeading"),
124
- invitationSubhead: t("verifyExpiredSubhead"),
125
- invitationBody: t("verifyExpiredBody"),
126
- backToSignIn: t("backToSignIn"),
127
- };
128
- return (
129
- <div className="flex flex-col gap-4" data-testid="verify-email-page">
130
- <div data-testid="verify-token-error">
131
- <AuthCard
132
- logo={siteLogo()}
133
- intent="invitation"
134
- signInHref={signInHref}
135
- labels={labels}
136
- />
137
- </div>
138
- </div>
139
- );
140
- }
141
-
142
- const labels: AuthCardLabels = {
143
- sentHeading: t("sentHeading"),
144
- sentSubhead: t("sentSubhead"),
145
- sentBody: t("sentBody"),
146
- backToSignIn: t("backToSignIn"),
147
- };
148
-
149
- return (
150
- <div className="flex flex-col gap-4" data-testid="verify-email-page">
151
- <AuthCard logo={siteLogo()} intent="sent" signInHref={signInHref} labels={labels} />
152
- </div>
153
- );
154
- }
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/appointments/[slug]/page";
3
- export { generateMetadata } from "@working-theory/account/appointments/[slug]/page";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/appointments/page";
3
- export { generateMetadata } from "@working-theory/account/appointments/page";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/artifacts/[pieceId]/page";
3
- export { generateMetadata } from "@working-theory/account/artifacts/[pieceId]/page";
@@ -1,2 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { GET } from "@working-theory/account/artifacts/[pieceId]/versions/[version]/file/route";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/artifacts/page";
3
- export { generateMetadata } from "@working-theory/account/artifacts/page";
@@ -1,12 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- import Page from "@working-theory/account/billing/page";
3
-
4
- import config from "../../../../../account.config";
5
-
6
- export { generateMetadata } from "@working-theory/account/billing/page";
7
-
8
- export default async function Route(
9
- props: Omit<Parameters<typeof Page>[0], "config">,
10
- ) {
11
- return Page({ ...props, config });
12
- }
@@ -1,12 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- import Page from "@working-theory/account/general/page";
3
-
4
- import config from "../../../../../account.config";
5
-
6
- export { generateMetadata } from "@working-theory/account/general/page";
7
-
8
- export default async function Route(
9
- props: Omit<Parameters<typeof Page>[0], "config">,
10
- ) {
11
- return Page({ ...props, config });
12
- }
@@ -1,12 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- import Page from "@working-theory/account/inbox/[kind]/[id]/page";
3
-
4
- import config from "../../../../../../../account.config";
5
-
6
- export { generateMetadata } from "@working-theory/account/inbox/[kind]/[id]/page";
7
-
8
- export default async function Route(
9
- props: Omit<Parameters<typeof Page>[0], "config">,
10
- ) {
11
- return Page({ ...props, config });
12
- }
@@ -1,2 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { GET } from "@working-theory/account/inbox/message/[id]/file/route";
@@ -1,12 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- import Page from "@working-theory/account/inbox/thread/page";
3
-
4
- import config from "../../../../../../account.config";
5
-
6
- export { generateMetadata } from "@working-theory/account/inbox/thread/page";
7
-
8
- export default async function Route(
9
- props: Omit<Parameters<typeof Page>[0], "config">,
10
- ) {
11
- return Page({ ...props, config });
12
- }
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/invitations/[invitationId]/page";
3
- export { generateMetadata } from "@working-theory/account/invitations/[invitationId]/page";
@@ -1,10 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- import Page from "@working-theory/account/layout";
3
-
4
- import config from "../../../../account.config";
5
-
6
- export default async function Route(
7
- props: Omit<Parameters<typeof Page>[0], "config">,
8
- ) {
9
- return Page({ ...props, config });
10
- }
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/notifications/page";
3
- export { generateMetadata } from "@working-theory/account/notifications/page";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/onboarding/page";
3
- export { generateMetadata } from "@working-theory/account/onboarding/page";
@@ -1,12 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- import Page from "@working-theory/account/page";
3
-
4
- import config from "../../../../account.config";
5
-
6
- export { generateMetadata } from "@working-theory/account/page";
7
-
8
- export default async function Route(
9
- props: Omit<Parameters<typeof Page>[0], "config">,
10
- ) {
11
- return Page({ ...props, config });
12
- }
@@ -1,2 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { GET } from "@working-theory/account/privacy/export/route";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/privacy/page";
3
- export { generateMetadata } from "@working-theory/account/privacy/page";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/security/page";
3
- export { generateMetadata } from "@working-theory/account/security/page";
@@ -1,2 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/settings/page";
@@ -1,3 +0,0 @@
1
- // Generated by create-ailk routes from @working-theory/account 0.61.0 — do not edit.
2
- export { default } from "@working-theory/account/support/page";
3
- export { generateMetadata } from "@working-theory/account/support/page";
@@ -1,16 +0,0 @@
1
- /**
2
- * Better Auth catch-all route handler.
3
- *
4
- * Mounts Better Auth at /api/auth/* per its convention. This is the only
5
- * api-shaped code permitted in apps/web — all other HTTP logic lives in
6
- * apps/api (architecture.yaml).
7
- *
8
- * Replaces the deleted NextAuth catch-all at app/api/auth/[...nextauth]/.
9
- * Better Auth's toNextJsHandler returns GET + POST Web Fetch handlers that
10
- * Next.js App Router calls directly.
11
- */
12
- import { toNextJsHandler } from "better-auth/next-js";
13
-
14
- import { auth } from "../../../../auth";
15
-
16
- export const { GET, POST } = toNextJsHandler(auth.handler);
@@ -1,143 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
-
5
- /**
6
- * The hub's sign-in continuation module (#8146 D3; spec AC-3(b), AC-4).
7
- * Pure functions over `seal.ts`; no mocks.
8
- */
9
- import { seal } from "../../../../../lib/hub-session/seal";
10
- import {
11
- CONTINUATION_REF_MAX,
12
- CONTINUATION_TTL_SECONDS,
13
- CONTINUE_PATH,
14
- mintContinuation,
15
- openContinuation,
16
- } from "../continuation";
17
-
18
- const SECRET = "k".repeat(43);
19
- const T = 1_790_000_000_000;
20
-
21
- const Q = new URLSearchParams({
22
- response_type: "code",
23
- client_id: "spoke_abc",
24
- redirect_uri: "https://spoke.example.com/api/hub-session/callback",
25
- state: "s".repeat(43),
26
- code_challenge: "c".repeat(43),
27
- code_challenge_method: "S256",
28
- }).toString();
29
-
30
- describe("constants", () => {
31
- it("pins the path, the ref cap and the 600 s life", () => {
32
- expect(CONTINUE_PATH).toBe("/api/auth/hub/continue");
33
- expect(CONTINUATION_REF_MAX).toBe(4096);
34
- expect(CONTINUATION_TTL_SECONDS).toBe(600);
35
- });
36
- });
37
-
38
- describe("AC-4 — the continuation lives 600 s and round-trips", () => {
39
- it("opens to the query it was minted from, up to the last millisecond", () => {
40
- const ref = mintContinuation(Q, SECRET, T);
41
- expect(openContinuation(ref, SECRET, T + 599_000)).toBe(Q);
42
- expect(openContinuation(ref, SECRET, T + 599_999)).toBe(Q);
43
- });
44
-
45
- it("is gone at exactly 600 s (exp <= now)", () => {
46
- const ref = mintContinuation(Q, SECRET, T);
47
- expect(openContinuation(ref, SECRET, T + 600_000)).toBeNull();
48
- expect(openContinuation(ref, SECRET, T + 600_001)).toBeNull();
49
- });
50
-
51
- it("is base64url only, so no decode can change it", () => {
52
- const ref = mintContinuation(Q, SECRET, T);
53
- expect(ref).toMatch(/^[A-Za-z0-9_-]+$/);
54
- expect(decodeURIComponent(decodeURIComponent(ref))).toBe(ref);
55
- expect(ref.length).toBeLessThan(CONTINUATION_REF_MAX);
56
- });
57
- });
58
-
59
- describe("AC-3(b) — a ref that is not ours opens to null", () => {
60
- const good = mintContinuation(Q, SECRET, T);
61
-
62
- it("flips the first character", () => {
63
- const flipped = (good[0] === "A" ? "B" : "A") + good.slice(1);
64
- expect(openContinuation(flipped, SECRET, T)).toBeNull();
65
- });
66
-
67
- it("sealed under another secret", () => {
68
- const other = mintContinuation(Q, "x".repeat(43), T);
69
- expect(openContinuation(other, SECRET, T)).toBeNull();
70
- });
71
-
72
- it('a valid payload sealed with purpose "flow" and the SAME AAD (only the key differs)', () => {
73
- const forged = seal(
74
- { v: 1, q: Q, exp: T + 600_000 },
75
- SECRET,
76
- "flow",
77
- "hub-continue",
78
- );
79
- expect(openContinuation(forged, SECRET, T)).toBeNull();
80
- });
81
-
82
- it("a value sealed under another name never opens as a continuation", () => {
83
- const forged = seal(
84
- { v: 1, q: Q, exp: T + 600_000 },
85
- SECRET,
86
- "continue",
87
- "ailk-hub-flow",
88
- );
89
- expect(openContinuation(forged, SECRET, T)).toBeNull();
90
- });
91
-
92
- it("exp in the past", () => {
93
- const expired = seal(
94
- { v: 1, q: Q, exp: T - 1 },
95
- SECRET,
96
- "continue",
97
- "hub-continue",
98
- );
99
- expect(openContinuation(expired, SECRET, T)).toBeNull();
100
- });
101
-
102
- it("4097 characters", () => {
103
- expect(openContinuation("A".repeat(4097), SECRET, T)).toBeNull();
104
- });
105
-
106
- it("a character outside base64url", () => {
107
- expect(openContinuation(`${good}%`, SECRET, T)).toBeNull();
108
- expect(openContinuation(`${good}?x=1`, SECRET, T)).toBeNull();
109
- expect(openContinuation("", SECRET, T)).toBeNull();
110
- });
111
-
112
- it("the base64url of plain JSON, unsealed", () => {
113
- const plain = Buffer.from(
114
- JSON.stringify({ v: 1, q: Q, exp: T + 600_000 }),
115
- ).toString("base64url");
116
- expect(openContinuation(plain, SECRET, T)).toBeNull();
117
- });
118
-
119
- it.each([
120
- ["a wrong version", { v: 2, q: Q, exp: T + 1000 }],
121
- ["an empty q", { v: 1, q: "", exp: T + 1000 }],
122
- ["a non-string q", { v: 1, q: 5, exp: T + 1000 }],
123
- ["a non-number exp", { v: 1, q: Q, exp: "later" }],
124
- ["a bare string", "hello"],
125
- ["null", null],
126
- ])("a sealed value with %s", (_name, value) => {
127
- const ref = seal(value, SECRET, "continue", "hub-continue");
128
- expect(openContinuation(ref, SECRET, T)).toBeNull();
129
- });
130
-
131
- it("re-serializes a forged q so a CR/LF is percent-encoded and never throws", () => {
132
- const ref = seal(
133
- { v: 1, q: "a=1\r\nX-Injected: 1", exp: T + 600_000 },
134
- SECRET,
135
- "continue",
136
- "hub-continue",
137
- );
138
- const opened = openContinuation(ref, SECRET, T);
139
- expect(opened).not.toBeNull();
140
- expect(opened).not.toMatch(/[\r\n]/);
141
- expect(() => new Headers({ Location: `/x?${opened}` })).not.toThrow();
142
- });
143
- });