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
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The site's sign-in configuration (#11257; ADR 0040 rule 4) — the one typed
3
+ * file through which this site customizes and serves `@working-theory/auth`.
4
+ *
5
+ * The default export is `defineAuthConfig({ … })`, which the generated
6
+ * `(auth)` layout file passes to the layout as `config`; it carries no
7
+ * extension point yet (rule 8), and a misspelled key fails `tsc`.
8
+ *
9
+ * The named export `site` is the runtime-services seam (`AuthSite`) the
10
+ * package's pages, actions and handlers read through
11
+ * `@working-theory/auth/site` (aliased here by `next.config.mjs` and
12
+ * `jest.config.cjs`). It never imports `./auth`: Better Auth arrives through
13
+ * the generated topology seam's `loadAuth()` — a dynamic import on a hub,
14
+ * `null` on a spoke — so a spoke keeps this file. A spoke's copy passes
15
+ * `hub: null` and imports none of the hub-only libs.
16
+ *
17
+ * Every value the generated topology seam owns is read through on access,
18
+ * never copied at load: a spoke's topology seam imports the package's
19
+ * hub-session entry, which can load before this file finishes.
20
+ */
21
+ import { type AuthSite, defineAuthConfig } from "@working-theory/auth";
22
+
23
+ import { browserApiOrigin } from "./lib/api-origin.generated";
24
+ import {
25
+ buildAuthEmailRequest,
26
+ confirmSignUpEmail,
27
+ makeSendAccountOpen,
28
+ purchaseCapture,
29
+ } from "./lib/auth-email";
30
+ import {
31
+ getActiveProviderIds,
32
+ hasAnyProvider,
33
+ isAuthRequired,
34
+ isResetAvailable,
35
+ isSignUpOpen,
36
+ magicLinkSendConfigured,
37
+ phoneVerificationConfigured,
38
+ resetSendConfigured,
39
+ } from "./lib/auth-env";
40
+ import { resolveSecret } from "./lib/auth-secret";
41
+ import { runBotCheck } from "./lib/bot-check";
42
+ import { consentPoliciesFor } from "./lib/consent-policies";
43
+ import { SITE_NAME } from "./lib/site-brand";
44
+ import { siteLogo } from "./lib/site-logo";
45
+ import {
46
+ loadAuth,
47
+ readSession,
48
+ SIGN_IN_PROVIDER,
49
+ SIGN_OUT_ENDPOINT,
50
+ TOPOLOGY,
51
+ } from "./lib/topology.generated";
52
+ import {
53
+ clientIpFromHeaders,
54
+ takeVisitorLimit,
55
+ UNKNOWN_VISITOR_FACTOR,
56
+ } from "./src/lib/rate-limit";
57
+ import { resolveBaseUrl } from "./src/lib/routes";
58
+
59
+ export default defineAuthConfig({});
60
+
61
+ export const site = {
62
+ loadAuth: () => loadAuth(),
63
+ env: {
64
+ isAuthRequired: () => isAuthRequired(),
65
+ isSignUpOpen: () => isSignUpOpen(),
66
+ isResetAvailable: () => isResetAvailable(),
67
+ getActiveProviderIds: () => getActiveProviderIds(),
68
+ magicLinkSendConfigured: () => magicLinkSendConfigured(),
69
+ hasAnyProvider: () => hasAnyProvider(),
70
+ resetSendConfigured: () => resetSendConfigured(),
71
+ phoneVerificationConfigured: () => phoneVerificationConfigured(),
72
+ },
73
+ siteLogo: () => siteLogo(),
74
+ get siteName() {
75
+ return SITE_NAME;
76
+ },
77
+ resolveBaseUrl: () => resolveBaseUrl(),
78
+ browserApiOrigin: () => browserApiOrigin(),
79
+ runBotCheck: (input) => runBotCheck(input),
80
+ takeVisitorLimit: (scope, headers, limit, windowMs) =>
81
+ takeVisitorLimit(scope, headers, limit, windowMs),
82
+ clientIpFromHeaders: (headers) => clientIpFromHeaders(headers),
83
+ get unknownVisitorFactor() {
84
+ return UNKNOWN_VISITOR_FACTOR;
85
+ },
86
+ get topology() {
87
+ return TOPOLOGY;
88
+ },
89
+ get signInProvider() {
90
+ return SIGN_IN_PROVIDER;
91
+ },
92
+ get signOutEndpoint() {
93
+ return SIGN_OUT_ENDPOINT;
94
+ },
95
+ readSession: (headers) => readSession(headers),
96
+ hub: {
97
+ resolveSecret: () => resolveSecret(),
98
+ consentPoliciesFor: (locale) => consentPoliciesFor(locale),
99
+ email: {
100
+ confirmSignUpEmail: (nonce) => confirmSignUpEmail(nonce),
101
+ makeSendAccountOpen: (deps) => makeSendAccountOpen(deps),
102
+ buildAuthEmailRequest: (payload, secret) =>
103
+ buildAuthEmailRequest(payload, secret),
104
+ purchaseCapture,
105
+ },
106
+ },
107
+ } satisfies AuthSite;
@@ -25,6 +25,7 @@
25
25
  * docs/internal/specs/ailk-pre-oss-security-phase-0.5-s0.5-better-auth-migration-spec.md.
26
26
  */
27
27
 
28
+ import { sealMcpCallbacks } from "@working-theory/auth/mcp-continuation";
28
29
  import type { PrismaClient } from "@working-theory/database";
29
30
  import { MCP_SCOPES } from "@working-theory/validation";
30
31
  import { type BetterAuthPlugin, betterAuth } from "better-auth";
@@ -33,7 +34,7 @@ import type { AuthMiddleware } from "better-auth/api";
33
34
  import { nextCookies } from "better-auth/next-js";
34
35
  import { magicLink, mcp, phoneNumber } from "better-auth/plugins";
35
36
 
36
- import { sealMcpCallbacks } from "./app/api/auth/mcp/continuation";
37
+
37
38
  import {
38
39
  authEmailTransport,
39
40
  makeMagicLinkOptions,
@@ -22,11 +22,14 @@
22
22
  // and `purchase` keys of the checkout and purchase pages (#11253 D4), and
23
23
  // `@working-theory/ui-docs-blog` the `docs` and `blog` keys of the docs and
24
24
  // blog pages (#11254 D4), each read through the paid-sections registry, whose
25
- // stub answers `null` on a site without the module.
25
+ // stub answers `null` on a site without the module. `@working-theory/auth`
26
+ // ships the `auth`, `signIn`, `mcpConsent` and `spokeSignIn` keys of the
27
+ // sign-in surfaces (#11257 D12), added after the account catalog.
26
28
  //
27
29
  // Spec: docs/internal/specs/i18n-phase1-s2-next-intl-foundation-spec.md
28
30
 
29
31
  import { accountMessages } from "@working-theory/account";
32
+ import { authMessages } from "@working-theory/auth";
30
33
  import type { AbstractIntlMessages } from "next-intl";
31
34
  import { getRequestConfig } from "next-intl/server";
32
35
 
@@ -100,6 +103,7 @@ export default getRequestConfig(async ({ requestLocale }) => {
100
103
  // package; this site's catalog holds overrides only, so the package's keys
101
104
  // are added under it and a key the site carries keeps the site's value.
102
105
  const packaged = accountMessages(locale) ?? accountMessages(DEFAULT_LOCALE) ?? {};
106
+ const signIn = authMessages(locale) ?? authMessages(DEFAULT_LOCALE) ?? {};
103
107
  const signalCollectors = await loadUiSignalCollectors();
104
108
  const flows =
105
109
  signalCollectors?.flowsMessages(locale) ?? signalCollectors?.flowsMessages(DEFAULT_LOCALE) ?? {};
@@ -113,7 +117,10 @@ export default getRequestConfig(async ({ requestLocale }) => {
113
117
  docsBlog?.docsBlogMessages(locale) ?? docsBlog?.docsBlogMessages(DEFAULT_LOCALE) ?? {};
114
118
  const withPackages = mergeAddOnly(
115
119
  mergeAddOnly(
116
- mergeAddOnly(mergeAddOnly(mergeAddOnly(messages as Catalog, packaged), flows), schedule),
120
+ mergeAddOnly(
121
+ mergeAddOnly(mergeAddOnly(mergeAddOnly(messages as Catalog, packaged), signIn), flows),
122
+ schedule,
123
+ ),
117
124
  checkout,
118
125
  ),
119
126
  docsAndBlog,
@@ -145,6 +145,10 @@ module.exports = {
145
145
  // `exports` name the files, so node resolution lands on them and ts-jest
146
146
  // compiles them like this app's own.
147
147
  "^@working-theory/account/site$": "<rootDir>/account.config.tsx",
148
+ // #11257 — the sign-in package's site seam, the same way: next.config.mjs
149
+ // aliases it to auth.config.tsx. The package's own suites run on this
150
+ // config too (packages/auth/jest.config.cjs), against this site.
151
+ "^@working-theory/auth/site$": "<rootDir>/auth.config.tsx",
148
152
  // The package's modules resolve `next/headers` and `better-auth/react`
149
153
  // from their own install, a second physical copy of each (the #5025
150
154
  // class above), so a test's `jest.mock()` of either would miss them.
@@ -31,6 +31,9 @@ export function siteTopology(): typeof Seam & { __esModule: true } {
31
31
  const { auth } = await import("../../../auth");
32
32
  return auth.api.getSession({ headers });
33
33
  },
34
+ loadAuth() {
35
+ return import("../../../auth").then((m) => m.auth);
36
+ },
34
37
  async readOwnAccounts(headers) {
35
38
  const { auth } = await import("../../../auth");
36
39
  return auth.api.listUserAccounts({ headers });
@@ -27,7 +27,7 @@ jest.mock("../topology.generated", () => ({
27
27
 
28
28
  const mockHubSessionInit = jest.fn();
29
29
  // eslint-disable-next-line no-restricted-syntax -- #507: hubSessionInit is mocked so the hub branch is asserted without a sealed cookie (#11246)
30
- jest.mock("../hub-session/session", () => ({
30
+ jest.mock("@working-theory/auth/hub-session", () => ({
31
31
  __esModule: true,
32
32
  hubSessionInit: () => mockHubSessionInit(),
33
33
  }));
@@ -22,9 +22,9 @@
22
22
  * rather than re-parsing the wire envelope by hand).
23
23
  */
24
24
 
25
+ import { hubSessionInit } from "@working-theory/auth/hub-session";
25
26
  import { cookies, headers } from "next/headers";
26
27
 
27
- import { hubSessionInit } from "./hub-session/session";
28
28
  import { SIGN_IN_PROVIDER } from "./topology.generated";
29
29
 
30
30
  /**
@@ -14,6 +14,7 @@
14
14
  // readPhoneStep and loadPhoneApi read and write the account's phone step
15
15
  // through Better Auth on a hub (#11138); a spoke's hub holds the person, so
16
16
  // both answer null.
17
+ import type { AuthInstance } from "@working-theory/auth/site";
17
18
 
18
19
  export const TOPOLOGY: "hub" | "spoke" = "hub";
19
20
  export const UNSERVED_MCP_TOOLS: readonly string[] = [];
@@ -37,6 +38,10 @@ export async function readSession(headers: Headers): Promise<SiteSession> {
37
38
  return auth.api.getSession({ headers });
38
39
  }
39
40
 
41
+ export function loadAuth(): Promise<AuthInstance | null> {
42
+ return import("../auth").then((m) => m.auth);
43
+ }
44
+
40
45
  export async function readOwnAccounts(
41
46
  headers: Headers,
42
47
  ): Promise<ReadonlyArray<{ providerId: string }> | null> {
@@ -436,113 +436,6 @@
436
436
  "description": "In-depth research and strategy papers from this site's team.",
437
437
  "emptyState": "Whitepapers coming soon."
438
438
  },
439
- "signIn": {
440
- "title": "Sign in",
441
- "description": "Sign in to your account.",
442
- "heading": "Sign in to {site}",
443
- "notConfiguredSubhead": "Sign-in is not configured for this site yet. Set a provider's environment variables to enable it.",
444
- "ssoPrefix": "Sign in with",
445
- "google": "Google",
446
- "github": "GitHub",
447
- "email": "Email",
448
- "password": "Password",
449
- "forgot": "Forgot password?",
450
- "submit": "Sign in",
451
- "orContinue": "Or continue with",
452
- "signInFailed": "We couldn't sign you in. Check your details and try again.",
453
- "providerFailed": "We couldn't start sign-in with that provider. Try again.",
454
- "emailLinkSubmit": "Send me a magic link",
455
- "emailLinkDivider": "or",
456
- "emailLinkSentHeading": "Check your email",
457
- "emailLinkSentSubhead": "Look for a message from this site.",
458
- "emailLinkBack": "Back to sign in",
459
- "continueWith": "Continue with",
460
- "useAnotherWay": "Use another way",
461
- "emailLinkSentBody": "If an account uses that address, a sign-in link is on its way. It works once and expires in 5 minutes.",
462
- "emailLinkFailed": "We couldn't send a sign-in link. Try again.",
463
- "emailLinkRateLimited": "Too many requests. Wait a minute, then try again.",
464
- "emailLinkExpired": "That sign-in link has expired or was already used. Request a new one.",
465
- "useEmailLink": "Email me a sign-in link instead",
466
- "emailPlaceholder": "you@example.com",
467
- "backTo": "Back to {site}",
468
- "acknowledgement": "You acknowledge that you read, and agree to our",
469
- "termsLink": "Terms of Service",
470
- "privacyLink": "Privacy Policy",
471
- "acknowledgementAnd": "and our",
472
- "acknowledgementEnd": ".",
473
- "prospectPrompt": "Don't have an account?",
474
- "prospectLink": "Sign up"
475
- },
476
- "auth": {
477
- "signUpTitle": "Create an account",
478
- "signUpDescription": "Create an account on this site.",
479
- "forgotTitle": "Reset your password",
480
- "forgotDescription": "Request a password reset link.",
481
- "resetTitle": "Choose a new password",
482
- "resetDescription": "Set a new password for your account.",
483
- "verifyEmailTitle": "Check your email",
484
- "verifyEmailDescription": "Follow the link we sent to continue.",
485
- "email": "Email",
486
- "password": "Password",
487
- "confirmPassword": "Confirm password",
488
- "newPassword": "New password",
489
- "orContinue": "or",
490
- "ssoPrefix": "Continue with",
491
- "google": "Google",
492
- "github": "GitHub",
493
- "backToSignIn": "Back to sign in",
494
- "signUpHeading": "Sign up",
495
- "signUpSubmit": "Create account",
496
- "signUpFooterPrompt": "Already have an account?",
497
- "signUpFooterLink": "Sign in",
498
- "signUpAgreementsLegend": "Agreements",
499
- "signUpAgreementsRequired": "Accept the agreements to create an account.",
500
- "signUpNotConfiguredSubhead": "Sign-up is not configured for this site yet. Set a provider's environment variables to enable it.",
501
- "signUpFailed": "We couldn't create your account. Check your details and try again.",
502
- "magicLinkSubmit": "Send me a magic link",
503
- "signUpLinkSentBody": "A link to finish signing up is on its way. It works once and expires in 5 minutes.",
504
- "signUpLinkBack": "Back to sign up",
505
- "signUpLinkFailed": "We couldn't send a sign-up link. Try again.",
506
- "signUpLinkRateLimited": "Too many requests. Wait a minute, then try again.",
507
- "signUpLinkExpired": "That sign-up link has expired or was already used. Request a new one.",
508
- "providerFailed": "We couldn't start sign-up with that provider. Try again.",
509
- "invitationBody": "This site does not offer public sign-up. If you were invited, open the link in your invitation email to create your account.",
510
- "forgotHeading": "Reset your password",
511
- "forgotSubhead": "Enter your email and we will send a reset link.",
512
- "forgotSubmit": "Send reset link",
513
- "resetHeading": "Choose a new password",
514
- "resetSubhead": "Choose a new password for your account.",
515
- "resetSubmit": "Set new password",
516
- "forgotUnavailableHeading": "Password reset isn't available",
517
- "forgotUnavailableSubhead": "This site does not offer password reset.",
518
- "forgotUnavailableBody": "Sign in with one of the providers on the sign-in page, or ask the site owner for help getting back in.",
519
- "resetUnavailableHeading": "Password reset isn't available",
520
- "resetUnavailableSubhead": "This reset link cannot be used on this site.",
521
- "resetUnavailableBody": "Password reset is not enabled here. Sign in with one of the providers on the sign-in page instead.",
522
- "sentToPrefix": "We sent it to",
523
- "resetRequestFailed": "We couldn't send a reset link just now. Try again in a few minutes.",
524
- "resetFailed": "We couldn't set that password. The link may have expired — request a new one.",
525
- "passwordMismatch": "Both passwords must match.",
526
- "resetExpiredHeading": "This reset link has expired",
527
- "resetExpiredSubhead": "Reset links are single-use and last one hour.",
528
- "resetExpiredBody": "Request a new link from the sign-in page and follow the most recent email.",
529
- "verifyExpiredHeading": "This confirmation link has expired",
530
- "verifyExpiredSubhead": "Confirmation links last 24 hours.",
531
- "verifyExpiredBody": "Sign in again and we'll send you a fresh confirmation email.",
532
- "confirmHeading": "Confirm your email",
533
- "confirmSubhead": "One click and your address is confirmed.",
534
- "confirmBody": "Select the button below to confirm this email address for your account.",
535
- "confirmButton": "Confirm my email",
536
- "verifiedHeading": "Your email is confirmed",
537
- "verifiedSubhead": "Thanks — your address is verified.",
538
- "verifiedBody": "You can sign in now. You can close this tab once you're done.",
539
- "sentHeading": "Check your email",
540
- "sentSubhead": "Follow the link we just sent to continue.",
541
- "sentBody": "Check your inbox and follow the link to continue. You can close this tab once you're done.",
542
- "footerPrivacy": "Privacy",
543
- "footerTerms": "Terms",
544
- "footerHelp": "Help"
545
- },
546
439
  "account": {
547
440
  "yourAccount": "Your account",
548
441
  "gate": {
@@ -550,24 +443,6 @@
550
443
  "emptyDescription": "This site hasn't turned on sign-in for members yet. Check back soon, or contact the site owner.",
551
444
  "homeLink": "Back to the site"
552
445
  },
553
- "spokeSignIn": {
554
- "heading": "Sign in to {site}",
555
- "subhead": "Enter your email and we'll send you a link to sign in.",
556
- "emailLabel": "Email",
557
- "submit": "Email me a sign-in link",
558
- "newHere": "New here? Accept to create your account with the same link.",
559
- "agreementsError": "To create an account, accept every agreement.",
560
- "google": "Continue with Google",
561
- "sent": "Check your email",
562
- "sentBody": "If that address can sign in here, a sign-in link is on its way. It works for 5 minutes.",
563
- "back": "Use another email",
564
- "unavailable": "Sign-in isn't available right now. Try again in a few minutes.",
565
- "exists": "You already have an account. Enter your email to sign in.",
566
- "claimInvalid": "That link has expired or was already used. Enter your email to sign in.",
567
- "openHeading": "Open your account",
568
- "openLead": "By opening your account you accept:",
569
- "open": "Open my account"
570
- },
571
446
  "settings": {
572
447
  "general": {
573
448
  "title": "General"
@@ -1066,32 +941,5 @@
1066
941
  "body": "The link may have expired. Go back to the site you came from and sign in again.",
1067
942
  "back": "Back to the site"
1068
943
  }
1069
- },
1070
- "mcpConsent": {
1071
- "metaTitle": "Connect an app",
1072
- "heading": "Connect an app to a workspace",
1073
- "signedInAs": "Signed in as {email}.",
1074
- "signOut": "Not you? Sign out",
1075
- "clientClaim": "{name} — this app registered itself; the name is its own claim and has not been checked.",
1076
- "returnsTo": "If you allow it, access is sent to {origin}.",
1077
- "workspaceLegend": "Choose the workspace this app may use",
1078
- "scopesLegend": "What it may also do there",
1079
- "memberReads": "Any approval also lets the app read what a member can read in that workspace.",
1080
- "noScopes": "Your role in this workspace offers nothing beyond member reads.",
1081
- "allow": "Allow",
1082
- "deny": "Deny",
1083
- "unavailable": "This request can't continue. Go back to the app and connect again.",
1084
- "noWorkspace": "You have no workspace to connect this app to.",
1085
- "scopes": {
1086
- "content-edit": "Edit pages and docs",
1087
- "content-publish": "Publish pages and docs, and delete glossary terms, FAQs and topics",
1088
- "assets-write": "Upload and replace files",
1089
- "magnets-manage": "Manage forms and magnets",
1090
- "meeting-types-manage": "Manage meeting types",
1091
- "people-read": "See your people",
1092
- "member-pieces-manage": "Manage what members see",
1093
- "people-memory-propose": "Suggest notes about people",
1094
- "inbox-act": "Act on the inbox"
1095
- }
1096
944
  }
1097
945
  }
@@ -46,10 +46,14 @@
46
46
  // S2 spec: docs/internal/specs/i18n-phase1-s2-next-intl-foundation-spec.md
47
47
  // P2 S1 spec: docs/internal/specs/i18n-phase2-s1-hreflang-metadata-spec.md §3
48
48
 
49
+ import {
50
+ authResponseHeaders,
51
+ isBookingPath,
52
+ setAuthRequestHeaders,
53
+ } from "@working-theory/auth/edge";
49
54
  import { NextRequest, NextResponse } from "next/server";
50
55
  import createMiddleware from "next-intl/middleware";
51
56
 
52
- import { isAccountPath, isBookingPath } from "./lib/auth-routes";
53
57
  import {
54
58
  DOCS_PATH,
55
59
  DOCS_ROUTE,
@@ -178,16 +182,6 @@ const FILE_ROUTE_SECURITY_HEADERS: Readonly<Record<string, string>> =
178
182
  ),
179
183
  );
180
184
 
181
- /**
182
- * Whether this site signs in through its hub (#11096): the hub's sign-in
183
- * origin, which only a hub-sign-in spoke sets (`lib/hub-session/config.ts`).
184
- * Read from the environment, not `lib/topology.generated`, whose spoke render
185
- * imports the Node-only session module this Edge bundle must not carry.
186
- */
187
- function signsInThroughHub(): boolean {
188
- return (process.env.AILK_HUB_SIGN_IN_URL?.trim() ?? "") !== "";
189
- }
190
-
191
185
  export function middleware(request: NextRequest): NextResponse {
192
186
  // Step 1: Forward x-pathname to server components so generateMetadata can
193
187
  // build path-aware hreflang alternates (P2 S1). Clone the request headers
@@ -195,18 +189,10 @@ export function middleware(request: NextRequest): NextResponse {
195
189
  // doesn't clobber the original user-facing path.
196
190
  const requestHeaders = new Headers(request.headers);
197
191
  requestHeaders.set("x-pathname", request.nextUrl.pathname);
198
- // #11096 D1 — the (authed) gate renders from a layout, which gets no
199
- // searchParams, so on a hub-sign-in spoke an account path's query rides
200
- // beside the path. Always this request's own value: a client-sent
201
- // `x-search` is dropped everywhere. It can hold a purchase claim, so no
202
- // other path or topology carries it, and nothing logs or reports it.
203
- requestHeaders.delete("x-search");
204
- if (
205
- signsInThroughHub() &&
206
- isAccountPath(request.nextUrl.pathname, enabledLocales)
207
- ) {
208
- requestHeaders.set("x-search", request.nextUrl.search);
209
- }
192
+ // #11096 D1 — on a hub-sign-in spoke an account path's query rides beside
193
+ // the path as `x-search`; a client-sent one is dropped everywhere
194
+ // (`@working-theory/auth/edge`, #11257 D6).
195
+ setAuthRequestHeaders(request, requestHeaders, enabledLocales);
210
196
 
211
197
  // Non-locale routes are served as requested — no rewrite, no redirect.
212
198
  if (isNonLocaleRoute(request.nextUrl.pathname)) {
@@ -278,6 +264,7 @@ export function middleware(request: NextRequest): NextResponse {
278
264
  // file routes get the six others and keep their own sandbox CSP (#9162).
279
265
  // A hub-sign-in spoke that turned Google One Tap on (`AILK_HUB_ONE_TAP=on`)
280
266
  // gets Google's origins on its other pages (#11096 D10, SEC-11096-10).
267
+ const auth = authResponseHeaders(request);
281
268
  applyHeaders(
282
269
  intlResponse.headers,
283
270
  isFileRoutePath(request.nextUrl.pathname)
@@ -285,13 +272,13 @@ export function middleware(request: NextRequest): NextResponse {
285
272
  : SCHEDULING_PAGES &&
286
273
  isBookingPath(request.nextUrl.pathname, enabledLocales)
287
274
  ? SCHEDULING_SECURITY_HEADERS
288
- : signsInThroughHub() && process.env.AILK_HUB_ONE_TAP === "on"
275
+ : auth.oneTap
289
276
  ? ONE_TAP_SECURITY_HEADERS
290
277
  : DEFAULT_SECURITY_HEADERS,
291
278
  );
292
279
  // SEC-11096-4 — a page that carries a purchase claim in its query sends no
293
280
  // referrer, so no request it makes carries the claim in `Referer`.
294
- if (request.nextUrl.searchParams.has("claim")) {
281
+ if (auth.noReferrer) {
295
282
  intlResponse.headers.set("Referrer-Policy", "no-referrer");
296
283
  }
297
284
  // #10040 decision 7 — a site with neither marketing nor docs-blog (a hub)
@@ -332,6 +332,9 @@ const nextConfig = {
332
332
  // route files under app/[locale]/(authed)/account/ re-export it.
333
333
  "@working-theory/account",
334
334
  "@working-theory/analytics",
335
+ // #11257 (ADR 0040 phase 2): the sign-in pages, the hub-session client and
336
+ // the /api/auth and /api/hub-session handlers ship as TypeScript source.
337
+ "@working-theory/auth",
335
338
  "@working-theory/api-client",
336
339
  "@working-theory/content-adapters",
337
340
  "@working-theory/jsonld",
@@ -365,8 +368,13 @@ const nextConfig = {
365
368
  // import `@working-theory/ui-signal-collectors/site`, answered by
366
369
  // signal-collectors.config.tsx (`SignalCollectorsSite`). A site without the
367
370
  // module has no such file and no importer of the specifier.
371
+ // #11257 — the sign-in package's seam, the same way: its pages, actions and
372
+ // handlers import `@working-theory/auth/site`, answered by auth.config.tsx
373
+ // (`AuthSite`). `create-ailk routes --check` refuses a site whose manifests
374
+ // include the package and whose config lacks this line (SEC-11257-1).
368
375
  webpack(config) {
369
376
  config.resolve.alias["@working-theory/account/site$"] = join(process.cwd(), "account.config.tsx");
377
+ config.resolve.alias["@working-theory/auth/site$"] = join(process.cwd(), "auth.config.tsx");
370
378
  config.resolve.alias["@working-theory/ui-signal-collectors/site$"] = join(
371
379
  process.cwd(),
372
380
  "signal-collectors.config.tsx",
@@ -20,6 +20,7 @@
20
20
  "@working-theory/account": "workspace:*",
21
21
  "@working-theory/analytics": "workspace:*",
22
22
  "@working-theory/api-client": "workspace:*",
23
+ "@working-theory/auth": "workspace:*",
23
24
  "@working-theory/content-adapters": "workspace:*",
24
25
  "@working-theory/database": "workspace:*",
25
26
  "@working-theory/ids": "workspace:*",
@@ -8,9 +8,14 @@
8
8
  // To verify: intentionally misspell a key in a component and run
9
9
  // `pnpm --filter @working-theory/web type-check` — the compiler will error.
10
10
 
11
+ import type authMessages from "@working-theory/auth/messages/en";
12
+
11
13
  import type enMessages from "../messages/en.json";
12
14
 
13
- type Messages = typeof enMessages;
15
+ // #11257 D12 — the sign-in surfaces' keys ship in `@working-theory/auth`'s
16
+ // catalog, which `i18n/request.ts` merges under this site's, so the declared
17
+ // shape is the two together.
18
+ type Messages = typeof enMessages & typeof authMessages;
14
19
 
15
20
  declare global {
16
21
  // next-intl reads this via module augmentation.
package/versions.json CHANGED
@@ -1,67 +1,68 @@
1
1
  {
2
- "@working-theory/account": "0.62.0",
3
- "@working-theory/admin-ui": "0.62.0",
4
- "@working-theory/aeo": "0.62.0",
5
- "@working-theory/agent-context": "0.62.0",
2
+ "@working-theory/account": "0.63.0",
3
+ "@working-theory/admin-ui": "0.63.0",
4
+ "@working-theory/aeo": "0.63.0",
5
+ "@working-theory/agent-context": "0.63.0",
6
6
  "@working-theory/agent-contract": "0.1.0",
7
7
  "@working-theory/agent-memory": "0.0.0",
8
8
  "@working-theory/ai": "0.1.0",
9
- "@working-theory/analytics": "0.62.0",
10
- "@working-theory/api": "0.62.0",
11
- "@working-theory/api-client": "0.62.0",
9
+ "@working-theory/analytics": "0.63.0",
10
+ "@working-theory/api": "0.63.0",
11
+ "@working-theory/api-client": "0.63.0",
12
+ "@working-theory/auth": "0.63.0",
12
13
  "@working-theory/cda-filesystem": "0.0.0",
13
- "@working-theory/cli": "0.62.0",
14
- "@working-theory/common": "0.62.0",
14
+ "@working-theory/cli": "0.63.0",
15
+ "@working-theory/common": "0.63.0",
15
16
  "@working-theory/consent": "0.1.0",
16
- "@working-theory/content-adapters": "0.62.0",
17
- "@working-theory/content-projection": "0.62.0",
18
- "@working-theory/email": "0.62.0",
17
+ "@working-theory/content-adapters": "0.63.0",
18
+ "@working-theory/content-projection": "0.63.0",
19
+ "@working-theory/email": "0.63.0",
19
20
  "@working-theory/env": "0.0.0",
20
- "@working-theory/eslint-config": "0.62.0",
21
- "@working-theory/fumadocs-schema": "0.62.0",
21
+ "@working-theory/eslint-config": "0.63.0",
22
+ "@working-theory/fumadocs-schema": "0.63.0",
22
23
  "@working-theory/ids": "0.20.1",
23
- "@working-theory/jsonld": "0.62.0",
24
- "@working-theory/license": "0.62.0",
25
- "@working-theory/mcp-server": "0.62.0",
26
- "@working-theory/metadata": "0.62.0",
27
- "@working-theory/observability": "0.62.0",
28
- "@working-theory/page-renderer": "0.62.0",
24
+ "@working-theory/jsonld": "0.63.0",
25
+ "@working-theory/license": "0.63.0",
26
+ "@working-theory/mcp-server": "0.63.0",
27
+ "@working-theory/metadata": "0.63.0",
28
+ "@working-theory/observability": "0.63.0",
29
+ "@working-theory/page-renderer": "0.63.0",
29
30
  "@working-theory/plugin-mcp": "0.1.3",
30
- "@working-theory/schema": "0.62.0",
31
- "@working-theory/schema-pack-registry": "0.62.0",
32
- "@working-theory/schema-validator": "0.62.0",
33
- "@working-theory/sections-registry": "0.62.0",
34
- "@working-theory/site-config": "0.62.0",
35
- "@working-theory/spoke-checkout": "0.7.18",
36
- "@working-theory/stripe-client": "0.62.0",
37
- "@working-theory/templates": "0.62.0",
38
- "@working-theory/theme": "0.62.0",
39
- "@working-theory/ui": "0.62.0",
40
- "@working-theory/validation": "0.62.0",
41
- "@working-theory/web-i18n": "0.62.0",
42
- "@working-theory/admin": "0.16.0",
43
- "@working-theory/api-commerce": "0.1.16",
44
- "@working-theory/api-content-write": "0.10.0",
45
- "@working-theory/api-hub": "0.6.1",
46
- "@working-theory/api-multi-tenant": "0.3.2",
47
- "@working-theory/api-scheduling": "0.6.1",
48
- "@working-theory/api-signal-collectors": "0.6.2",
49
- "@working-theory/api-workspace": "0.10.0",
31
+ "@working-theory/schema": "0.63.0",
32
+ "@working-theory/schema-pack-registry": "0.63.0",
33
+ "@working-theory/schema-validator": "0.63.0",
34
+ "@working-theory/sections-registry": "0.63.0",
35
+ "@working-theory/site-config": "0.63.0",
36
+ "@working-theory/spoke-checkout": "0.7.19",
37
+ "@working-theory/stripe-client": "0.63.0",
38
+ "@working-theory/templates": "0.63.0",
39
+ "@working-theory/theme": "0.63.0",
40
+ "@working-theory/ui": "0.63.0",
41
+ "@working-theory/validation": "0.63.0",
42
+ "@working-theory/web-i18n": "0.63.0",
43
+ "@working-theory/admin": "0.16.1",
44
+ "@working-theory/api-commerce": "0.1.17",
45
+ "@working-theory/api-content-write": "0.10.1",
46
+ "@working-theory/api-hub": "0.6.2",
47
+ "@working-theory/api-multi-tenant": "0.3.3",
48
+ "@working-theory/api-scheduling": "0.6.2",
49
+ "@working-theory/api-signal-collectors": "0.6.3",
50
+ "@working-theory/api-workspace": "0.10.1",
50
51
  "@working-theory/billing-client": "0.0.0",
51
52
  "@working-theory/branding": "0.0.0",
52
53
  "@working-theory/license-client": "0.0.0",
53
54
  "@working-theory/license-manifest": "0.0.0",
54
- "@working-theory/mcp-scheduling": "0.4.3",
55
- "@working-theory/mcp-signal-collectors": "0.2.16",
56
- "@working-theory/mcp-workspace": "0.9.0",
55
+ "@working-theory/mcp-scheduling": "0.4.4",
56
+ "@working-theory/mcp-signal-collectors": "0.2.17",
57
+ "@working-theory/mcp-workspace": "0.9.1",
57
58
  "@working-theory/partner-session": "0.0.0",
58
59
  "@working-theory/preview-protocol": "0.0.0",
59
- "@working-theory/ui-commerce": "0.62.0",
60
- "@working-theory/ui-docs-blog": "0.62.0",
61
- "@working-theory/ui-scheduling": "0.62.0",
62
- "@working-theory/ui-signal-collectors": "0.62.0",
60
+ "@working-theory/ui-commerce": "0.63.0",
61
+ "@working-theory/ui-docs-blog": "0.63.0",
62
+ "@working-theory/ui-scheduling": "0.63.0",
63
+ "@working-theory/ui-signal-collectors": "0.63.0",
63
64
  "@working-theory/web": "0.0.0",
64
65
  "@working-theory/app-api": "1.0.0",
65
66
  "@working-theory/mcp": "0.0.0",
66
- "@working-theory/database": "0.62.0"
67
+ "@working-theory/database": "0.63.0"
67
68
  }