create-ailk 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +1 -1
  2. package/component-catalog.json +51 -1
  3. package/component-catalog.md +8 -5
  4. package/dist/lib/env-catalog.js +8 -0
  5. package/dist/surfaces.js +66 -22
  6. package/dist/topology.d.ts +4 -4
  7. package/dist/topology.js +104 -60
  8. package/dist/update.d.ts +19 -1
  9. package/dist/update.js +293 -35
  10. package/package.json +3 -3
  11. package/templates/.env.example +38 -0
  12. package/templates/apps/api/.env.example +45 -0
  13. package/templates/apps/api/CLAUDE.md +12 -4
  14. package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
  15. package/templates/apps/mcp/CLAUDE.md +4 -2
  16. package/templates/apps/web/.env.example +16 -0
  17. package/templates/apps/web/CLAUDE.md +73 -5
  18. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
  19. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
  20. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
  21. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
  22. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
  23. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
  24. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
  25. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
  26. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
  27. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
  28. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
  29. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
  30. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +241 -66
  31. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
  32. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
  33. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
  34. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
  37. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
  38. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
  39. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
  40. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
  41. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
  42. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
  43. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
  44. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
  45. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
  46. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
  47. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
  51. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
  53. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
  54. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
  55. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
  56. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
  57. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
  58. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
  59. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
  60. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
  61. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
  62. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
  63. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
  64. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
  65. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
  66. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
  67. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
  68. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
  69. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
  70. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
  71. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
  72. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +215 -0
  73. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
  74. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
  75. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
  76. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
  77. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
  78. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
  79. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
  80. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
  81. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
  82. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
  83. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
  84. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
  85. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
  86. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +9 -6
  87. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
  88. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
  89. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
  90. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
  91. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
  92. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
  93. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
  94. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
  95. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
  96. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
  97. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
  98. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
  99. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  100. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
  101. package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
  102. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
  103. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
  104. package/templates/apps/web/app/[locale]/layout.tsx +24 -75
  105. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
  106. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
  107. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
  108. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +166 -7
  109. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
  110. package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
  111. package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
  112. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
  113. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
  114. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
  115. package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
  116. package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
  117. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
  118. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
  119. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
  120. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
  121. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +738 -7
  122. package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
  123. package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
  124. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
  125. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
  126. package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
  127. package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
  128. package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
  129. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
  130. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
  131. package/templates/apps/web/auth.ts +133 -6
  132. package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
  133. package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
  134. package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
  135. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
  136. package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
  137. package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
  138. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
  139. package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
  140. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
  141. package/templates/apps/web/lib/account-config.ts +132 -8
  142. package/templates/apps/web/lib/auth-email.ts +62 -6
  143. package/templates/apps/web/lib/auth-env.ts +13 -0
  144. package/templates/apps/web/lib/auth-routes.ts +11 -6
  145. package/templates/apps/web/lib/auth-sms.ts +180 -0
  146. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
  147. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
  148. package/templates/apps/web/lib/hub-session/config.ts +7 -1
  149. package/templates/apps/web/lib/hub-session/entry.ts +238 -0
  150. package/templates/apps/web/lib/hub-session/index.ts +1 -4
  151. package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
  152. package/templates/apps/web/lib/hub-session/session.ts +120 -2
  153. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
  154. package/templates/apps/web/lib/offerings-pricing.ts +4 -1
  155. package/templates/apps/web/lib/site-header.ts +14 -1
  156. package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
  157. package/templates/apps/web/lib/topology.generated.ts +39 -0
  158. package/templates/apps/web/messages/en.json +264 -96
  159. package/templates/apps/web/middleware.ts +34 -2
  160. package/templates/apps/web/security-headers.config.ts +21 -0
  161. package/versions.json +48 -48
  162. package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
  163. package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
  164. package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
  165. package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
  166. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
  167. package/templates/apps/web/components/signed-in-nav.tsx +0 -79
  168. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
  169. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
@@ -1,162 +0,0 @@
1
- "use client"; // social sign-in requires a client-side Better Auth call
2
-
3
- /**
4
- * SignInGate — the `(authed)` group's own front door (#4665 D9).
5
- *
6
- * This gate composes the shipped `AuthPanel` section directly (so the
7
- * dashboard is reachable in place, unlike `apps-paid/admin`, which redirects
8
- * to "/" on no session) and ALSO links to `apps/web`'s own `/sign-in` page
9
- * (#4984) carrying `?next=<pathname>`, so a visitor who prefers the full
10
- * sign-in surface lands back on the exact page they requested.
11
- *
12
- * `providers` arrives as a prop, resolved by the `(authed)` layout (an RSC)
13
- * from the server's provider env (#7419). This module must never read that
14
- * env itself: it is bundled for the browser, where `GOOGLE_CLIENT_ID` and the
15
- * like are always unset, so a client-side read always came back empty.
16
- *
17
- * Zero active providers → an `EmptyState` naming the missing configuration
18
- * (the `AuthPanel` UI-contract forbids fabricating a session — spec
19
- * Clarifications), still followed by the sign-in link. `callbackURL` is the
20
- * current pathname (via `usePathname()`) so a successful social sign-in
21
- * lands back on the exact dashboard page the visitor requested.
22
- *
23
- * Email sign-in link (#7435 § D9): when the layout passes `card` with
24
- * `emailLink`, the gate renders `/sign-in`'s own `SignInCard` — the same
25
- * providers plus "Send me a magic link" — in place of `AuthPanel`, whose
26
- * email + password form has no submit wiring and would otherwise sit inert
27
- * beside the new field. Without the prop every render is what it was before.
28
- *
29
- * The one card (#9662): on the member `/account` gate the layout passes
30
- * `card` whenever a method is on, with the site's mark, the "Don't have an
31
- * account? Sign up" line and the Terms + Privacy acknowledgement, so the gate
32
- * renders the same card `/sign-in` does.
33
- */
34
-
35
- import { EmptyState, Link } from "@working-theory/ui/primitives";
36
- import { AuthPanel, type AuthPanelProvider } from "@working-theory/ui/sections";
37
- import { createAuthClient } from "better-auth/react";
38
- import { usePathname } from "next/navigation";
39
- import type { ReactElement, ReactNode } from "react";
40
-
41
- import { SignInCard } from "../(auth)/sign-in/sign-in-card";
42
- import type { SignInCardText } from "../(auth)/sign-in/sign-in-text";
43
-
44
- const authClient = createAuthClient();
45
-
46
- export interface SignInGateLabels {
47
- emptyHeadline: string;
48
- emptyDescription: string;
49
- /** Visible text of the link to the full sign-in page (#4984). */
50
- signInLinkLabel: string;
51
- }
52
-
53
- export interface SignInGateProps {
54
- labels: SignInGateLabels;
55
- /** Locale-prefixed sign-in page path — `localeHref(locale, "/sign-in")`. */
56
- signInPath: string;
57
- /** The active social providers, resolved server-side by the layout (#7419). */
58
- providers: AuthPanelProvider[];
59
- /**
60
- * Renders `SignInCard` in place of `AuthPanel` — present when the email
61
- * sign-in link is on (#7435) or on the member gate (#9662). The card's copy,
62
- * mark, prospect line and footnote are resolved server-side by the layout.
63
- */
64
- card?: {
65
- text: SignInCardText;
66
- /** Offer "Send me a magic link" — the email sign-in link is on. */
67
- emailLink: boolean;
68
- logo?: ReactNode;
69
- prospect?: { prompt: string; linkLabel: string; href: string };
70
- footnote?: ReactNode;
71
- };
72
- }
73
-
74
- export function SignInGate({
75
- labels,
76
- signInPath,
77
- providers,
78
- card,
79
- }: SignInGateProps): ReactElement {
80
- const pathname = usePathname();
81
- const signInHref = `${signInPath}?next=${encodeURIComponent(pathname)}`;
82
-
83
- const signInLink = (
84
- <Link
85
- href={signInHref}
86
- data-testid="sign-in-gate-link"
87
- // 24px hit-area floor (Rule 14) — a bare inline link's line-height box
88
- // falls short on its own.
89
- className="inline-flex min-h-6 items-center px-2"
90
- >
91
- {labels.signInLinkLabel}
92
- </Link>
93
- );
94
-
95
- if (card) {
96
- const { text } = card;
97
- return (
98
- <div
99
- className="flex min-h-screen flex-col items-center justify-center gap-4 py-section"
100
- data-testid="sign-in-gate"
101
- >
102
- {/* AuthShell's 400px column: the cap sits on the wrapper, never on the card (AuthShell.tsx). */}
103
- <div className="w-full max-w-100">
104
- <SignInCard
105
- providers={providers}
106
- method="sso"
107
- next={pathname}
108
- labels={text.labels}
109
- notConfiguredSubhead={text.notConfiguredSubhead}
110
- errorLabels={text.errorLabels}
111
- emailLink={card.emailLink}
112
- errorCallbackURL={signInHref}
113
- signInHref={signInHref}
114
- emailLinkLabels={text.emailLinkLabels}
115
- {...(card.logo !== undefined ? { logo: card.logo } : {})}
116
- {...(card.prospect !== undefined
117
- ? { prospect: card.prospect }
118
- : {})}
119
- {...(card.footnote !== undefined
120
- ? { footnote: card.footnote }
121
- : {})}
122
- />
123
- </div>
124
- {signInLink}
125
- </div>
126
- );
127
- }
128
-
129
- if (providers.length === 0) {
130
- return (
131
- <div
132
- className="flex min-h-screen flex-col items-center justify-center gap-4"
133
- data-testid="sign-in-gate-empty"
134
- >
135
- <EmptyState
136
- headline={labels.emptyHeadline}
137
- description={labels.emptyDescription}
138
- />
139
- {signInLink}
140
- </div>
141
- );
142
- }
143
-
144
- return (
145
- <div
146
- className="flex min-h-screen flex-col items-center justify-center gap-4 py-section"
147
- data-testid="sign-in-gate"
148
- >
149
- <AuthPanel
150
- sectionName="auth-panel"
151
- data={{ mode: "signin", providers }}
152
- onProviderClick={(provider) => {
153
- void authClient.signIn.social({
154
- provider,
155
- callbackURL: pathname,
156
- });
157
- }}
158
- />
159
- {signInLink}
160
- </div>
161
- );
162
- }
@@ -1,79 +0,0 @@
1
- "use client"; // owns renderFlowTrigger + navItems — functions that cannot cross the RSC boundary (#7402)
2
-
3
- /**
4
- * SignedInNav — the site Nav for a signed-in visitor (#7402).
5
- *
6
- * Signed in, the locale layout (RSC) authors two `kind: "flow"` Nav actions —
7
- * the visitor's name and "Sign out" — and Nav hands their rendered triggers
8
- * back through `renderFlowTrigger`. That composer is a function, and Nav
9
- * forwards it into NavMobileMenu ("use client"), so a Server Component that
10
- * passes it crashes every signed-in page with "Functions cannot be passed
11
- * directly to Client Components". Composing Nav HERE keeps the function on the
12
- * client side of the boundary.
13
- *
14
- * `navItems` is owned here for the same reason: a generated nav inventory
15
- * carries Lucide icon components on its flyout entries, and a component is a
16
- * function too. The layout passes only serializable props (labels, actions,
17
- * the brand elements); everything callable is imported or defined below.
18
- *
19
- * Signed out, the layout keeps rendering Nav as a Server Component — it has
20
- * no flow action, so nothing callable needs to cross.
21
- */
22
-
23
- import { Nav, type NavProps } from "@working-theory/ui/chrome";
24
- import type { ReactElement } from "react";
25
-
26
- import { withPublicDocsPaths } from "../lib/docs-path";
27
- import { navItems } from "../lib/nav-config";
28
- import { withPublicServicesPaths } from "../lib/services-path";
29
- import { siteChrome } from "../lib/site-chrome";
30
-
31
- import { SignOutTrigger } from "./sign-out-trigger";
32
-
33
- // #10041 D10 — nav paths at `/docs` render at the site's docs path.
34
- // `docs-path.ts` imports nothing, so it is safe on this side of the boundary.
35
- // #10043 D9 — likewise nav paths at `/services`, from `services-path.ts`.
36
- const publicNavItems = withPublicServicesPaths(withPublicDocsPaths(navItems));
37
-
38
- /** Nav's props minus every function-typed one — this type IS the boundary. */
39
- export type SignedInNavProps = Omit<
40
- NavProps,
41
- "navItems" | "renderFlowTrigger" | "translate" | "onSearchOpen"
42
- > & {
43
- /**
44
- * Where "Sign out" POSTs, from the generated seam's `SIGN_OUT_ENDPOINT`
45
- * (#7894 D10) — a spoke that signs in through its hub. Absent or `null`,
46
- * Sign out goes through Better Auth's client, as on a hub.
47
- */
48
- signOutEndpoint?: string | null;
49
- };
50
-
51
- export function SignedInNav({
52
- signOutEndpoint,
53
- ...props
54
- }: SignedInNavProps): ReactElement {
55
- return (
56
- <Nav
57
- {...props}
58
- navItems={siteChrome.nav === "mark-only" ? [] : publicNavItems}
59
- // Both signed-in actions are flows with no lightbox: Sign out becomes a
60
- // SignOutTrigger, the account action a non-navigating name label.
61
- renderFlowTrigger={(action, trigger) =>
62
- action.labelKey === "signOut" ? (
63
- <SignOutTrigger
64
- {...(signOutEndpoint ? { endpoint: signOutEndpoint } : {})}
65
- >
66
- {trigger}
67
- </SignOutTrigger>
68
- ) : (
69
- <span
70
- className="text-body-sm text-(--color-text-muted)"
71
- data-testid="nav-account-name"
72
- >
73
- {props.labels?.items.account}
74
- </span>
75
- )
76
- }
77
- />
78
- );
79
- }
@@ -1,180 +0,0 @@
1
- /**
2
- * HubSignInGate (#7894 D10) as #8790 AC-1/AC-2 and #9662 shape it: the site's
3
- * inner-page header (the back arrow), then the one hub sign-in action inside
4
- * the one card's frame — the mark in the tile, "Sign in to <site>", the toggle
5
- * line to the hub's /sign-up (or the site's own prospect line when its
6
- * messages carry one), and the Terms + Privacy acknowledgement.
7
- *
8
- * #9912 D1: that toggle reaches the hub's /sign-up through the same round trip
9
- * as Sign in — this site's own sign-in route with `prompt=create` and the
10
- * same `next` — so completing sign-up returns the buyer here.
11
- */
12
- import { render, screen, within } from "@testing-library/react";
13
- import en from "../../../messages/en.json";
14
- import { SITE_NAME } from "../../site-brand";
15
- import { HubSignInGate } from "../sign-in-gate";
16
-
17
- type Gate = Record<string, string>;
18
- let gateMessages: Gate;
19
-
20
- jest.mock("next-intl/server", () => ({
21
- __esModule: true,
22
- getTranslations: jest.fn(async ({ namespace }: { namespace: string }) => {
23
- const messages: Gate =
24
- namespace === "signIn" ? (en.signIn as Gate) : gateMessages;
25
- const t = (key: string, values?: Record<string, string>) =>
26
- (messages[key] ?? `copy:${key}`).replace(
27
- /\{(\w+)\}/g,
28
- (_match, name: string) => values?.[name] ?? `{${name}}`,
29
- );
30
- t.has = (key: string) => key in messages;
31
- return t;
32
- }),
33
- }));
34
-
35
- const mockConfig = jest.fn();
36
- // eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; hubSessionConfig() is a pure env read
37
- jest.mock("../config", () => ({
38
- __esModule: true,
39
- hubSessionConfig: () => mockConfig(),
40
- }));
41
-
42
- // eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; siteLogo() reads the site's brand files
43
- jest.mock("../../site-logo", () => ({
44
- __esModule: true,
45
- siteLogo: () => (
46
- <img src="/logomark.svg" alt="Site" data-testid="site-mark" />
47
- ),
48
- }));
49
-
50
- async function renderGate(pathname?: string): Promise<void> {
51
- const requestHeaders = new Headers();
52
- if (pathname) requestHeaders.set("x-pathname", pathname);
53
- render(await HubSignInGate({ locale: "en", requestHeaders }));
54
- }
55
-
56
- beforeEach(() => {
57
- gateMessages = { ...(en.account.gate as Gate) };
58
- mockConfig
59
- .mockReset()
60
- .mockReturnValue({ clientId: "spoke_1", hubOrigin: "https://hub.example" });
61
- });
62
-
63
- describe("<HubSignInGate/> (#8790 AC-1; #9662)", () => {
64
- it("wears the site's inner-page header: a back arrow to the home; the mark is the card's tile (#9662)", async () => {
65
- await renderGate("/account");
66
- const header = screen.getByTestId("account-sign-in-gate-header");
67
- const back = screen.getByTestId("nav-back-link");
68
- expect(header).toContainElement(back);
69
- expect(back).toHaveAttribute("href", "/");
70
- expect(back).toHaveAccessibleName(en.account.gate.homeLink);
71
- expect(header).not.toContainElement(screen.getByTestId("site-mark"));
72
- expect(screen.getByTestId("auth-card-logo")).toContainElement(
73
- screen.getByTestId("site-mark"),
74
- );
75
- });
76
-
77
- it("titles the card 'Sign in to <site>' from the deployment's own name and offers the one sign-in action inside it", async () => {
78
- await renderGate("/account/settings");
79
- // The gate is the whole page, so the card's heading is its one h1.
80
- expect(
81
- screen.getByRole("heading", {
82
- level: 1,
83
- name: `Sign in to ${SITE_NAME}`,
84
- }),
85
- ).toBeInTheDocument();
86
- const action = screen.getByTestId("account-hub-sign-in");
87
- expect(screen.getByTestId("auth-card")).toContainElement(action);
88
- expect(action).toHaveAttribute(
89
- "href",
90
- "/api/hub-session/sign-in?next=%2Faccount%2Fsettings",
91
- );
92
- });
93
-
94
- it("carries the toggle line to the hub's /sign-up and the acknowledgement on this site's policy routes (#9662)", async () => {
95
- await renderGate();
96
- expect(screen.getByTestId("auth-card-prospect")).toHaveTextContent(
97
- /^Don't have an account\? Sign up$/,
98
- );
99
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
100
- "href",
101
- "/api/hub-session/sign-in?next=%2Faccount&prompt=create",
102
- );
103
- expect(screen.getByTestId("account-hub-sign-in")).toHaveAttribute(
104
- "href",
105
- "/api/hub-session/sign-in?next=%2Faccount",
106
- );
107
- const footnote = screen.getByTestId("auth-card-footnote");
108
- expect(footnote).toHaveTextContent(
109
- /^You acknowledge that you read, and agree to our Terms of Service and our Privacy Policy\.$/,
110
- );
111
- expect(
112
- within(footnote).getByRole("link", { name: "Terms of Service" }),
113
- ).toHaveAttribute("href", "/terms");
114
- expect(
115
- within(footnote).getByRole("link", { name: "Privacy Policy" }),
116
- ).toHaveAttribute("href", "/privacy");
117
- });
118
-
119
- it("starts Sign up with the requested path as next, the Sign in button's own URL plus prompt=create (#9912 D1, AC-1)", async () => {
120
- await renderGate("/account/billing");
121
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
122
- "href",
123
- "/api/hub-session/sign-in?next=%2Faccount%2Fbilling&prompt=create",
124
- );
125
- expect(screen.getByTestId("account-hub-sign-in")).toHaveAttribute(
126
- "href",
127
- "/api/hub-session/sign-in?next=%2Faccount%2Fbilling",
128
- );
129
- });
130
- });
131
-
132
- describe("<HubSignInGate/> prospect line (#8790 AC-2)", () => {
133
- it("replaces the toggle line with the site's own when it fills all three keys", async () => {
134
- gateMessages.prospectPrompt = "New here?";
135
- gateMessages.prospectLink = "See if we fit";
136
- gateMessages.prospectHref = "/fit";
137
- await renderGate();
138
- // The card's line ends on its link — no trailing period (#9662).
139
- expect(screen.getByTestId("auth-card-prospect")).toHaveTextContent(
140
- /^New here\? See if we fit$/,
141
- );
142
- expect(screen.getByRole("link", { name: "See if we fit" })).toHaveAttribute(
143
- "href",
144
- "/fit",
145
- );
146
- });
147
-
148
- it("keeps the toggle line when any of the three keys is absent", async () => {
149
- gateMessages.prospectPrompt = "New here?";
150
- gateMessages.prospectLink = "See if we fit";
151
- await renderGate();
152
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
153
- "href",
154
- "/api/hub-session/sign-in?next=%2Faccount&prompt=create",
155
- );
156
- });
157
-
158
- it("draws no prospect line in the not-configured state, even with the site's three keys", async () => {
159
- mockConfig.mockReturnValue(null);
160
- gateMessages.prospectPrompt = "New here?";
161
- gateMessages.prospectLink = "See if we fit";
162
- gateMessages.prospectHref = "/fit";
163
- await renderGate();
164
- expect(screen.queryByTestId("auth-card-prospect")).toBeNull();
165
- });
166
-
167
- it("keeps the not-configured state when the hub is not configured", async () => {
168
- mockConfig.mockReturnValue(null);
169
- await renderGate();
170
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
171
- en.account.gate.emptyHeadline,
172
- );
173
- expect(screen.queryByTestId("auth-card-prospect")).toBeNull();
174
- expect(screen.getByTestId("account-sign-in-gate-home")).toHaveAttribute(
175
- "href",
176
- "/",
177
- );
178
- expect(screen.queryByTestId("account-hub-sign-in")).toBeNull();
179
- });
180
- });
@@ -1,162 +0,0 @@
1
- /**
2
- * HubSignInGate — the signed-out account gate of a spoke that signs in
3
- * through its hub (#7894 D10; #8790 AC-1/AC-2).
4
- *
5
- * A Server Component, rendered by the `(authed)` layout through the generated
6
- * gate seam (`signed-out-gate.generated.tsx`, its `signIn: "hub"` render). It
7
- * offers ONE action: a link to this site's own `/api/hub-session/sign-in`,
8
- * carrying the requested path as `next`, which starts the hub sign-in. The
9
- * link is a plain anchor (the `Link` primitive), so nothing prefetches the
10
- * route and starts a flow the visitor did not ask for.
11
- *
12
- * #8790 — the gate reads as one of the site's inner pages, not a bare
13
- * full-height stop: the back arrow at the start edge (`NavBackLink`), then the
14
- * card. The document title is the account page's job (`generateMetadata`
15
- * there reads the session and names this state "Sign in · <site>").
16
- *
17
- * The one card (#9662, operator 2026-10-24): the single hub action sits in
18
- * `AuthCard`'s frame — the site's mark in the 48px tile, "Sign in to <site>"
19
- * (`SITE_NAME`, the deployment's own name, never the request's), the
20
- * "Don't have an account? Sign up" line to this site's own sign-in route with
21
- * `prompt=create`, which lands on the hub's sign-up screen and returns here
22
- * (#9912 D1), and the Terms + Privacy acknowledgement on this site's own
23
- * policy routes. A site that fills `account.gate.prospectPrompt` +
24
- * `prospectLink` + `prospectHref` replaces the toggle line with its own. The
25
- * acknowledgement is built here rather than from the `(auth)` group's
26
- * builder: a spoke carries no `(auth)` group (create-ailk's
27
- * `SPOKE_REMOVAL_SEEDS`).
28
- *
29
- * Not configured (`hubSessionConfig()` is `null`: a client id, secret or
30
- * session secret missing), the card says "sign-in isn't available yet" and
31
- * its one action leads back to the site.
32
- */
33
- import { localeHref } from "@working-theory/ui";
34
- import { AuthCard } from "@working-theory/ui/blocks";
35
- import { NavBackLink } from "@working-theory/ui/chrome";
36
- import { Button, Link, Text } from "@working-theory/ui/primitives";
37
- import { getTranslations } from "next-intl/server";
38
- import type { ReactElement } from "react";
39
-
40
- import { SITE_NAME } from "../site-brand";
41
- import { siteLogo } from "../site-logo";
42
-
43
- import { hubSessionConfig } from "./config";
44
- import { HUB_SESSION_FALLBACK_PATH } from "./session";
45
-
46
- /** The route that starts the hub sign-in. */
47
- const HUB_SIGN_IN_ROUTE = "/api/hub-session/sign-in";
48
-
49
- export interface HubSignInGateProps {
50
- locale: string;
51
- /** The incoming request's headers; `x-pathname` is the page to return to. */
52
- requestHeaders: Headers;
53
- }
54
-
55
- export async function HubSignInGate({
56
- locale,
57
- requestHeaders,
58
- }: HubSignInGateProps): Promise<ReactElement> {
59
- const t = await getTranslations({ locale, namespace: "account.gate" });
60
- const signIn = await getTranslations({ locale, namespace: "signIn" });
61
- const config = hubSessionConfig();
62
- const next =
63
- requestHeaders.get("x-pathname") ??
64
- localeHref(locale, HUB_SESSION_FALLBACK_PATH);
65
- const signInHref = `${HUB_SIGN_IN_ROUTE}?next=${encodeURIComponent(next)}`;
66
- const home = localeHref(locale, "/");
67
- // The three prospect keys are optional extensions of the typed catalog (the
68
- // shipped en.json carries none — every leaf must be a non-empty string), so
69
- // presence is the switch; hence the cast on `has`.
70
- type Key = Parameters<typeof t.has>[0];
71
- const has = (key: string): boolean => t.has(key as Key);
72
- // Only a configured gate offers a way in; the not-configured state has none.
73
- const prospect = !config
74
- ? undefined
75
- : has("prospectPrompt") && has("prospectLink") && has("prospectHref")
76
- ? {
77
- prompt: t("prospectPrompt" as Key),
78
- linkLabel: t("prospectLink" as Key),
79
- href: t("prospectHref" as Key),
80
- }
81
- : {
82
- prompt: signIn("prospectPrompt"),
83
- linkLabel: signIn("prospectLink"),
84
- href: `${signInHref}&prompt=create`,
85
- };
86
-
87
- return (
88
- <div
89
- className="flex min-h-screen flex-col"
90
- data-testid="account-sign-in-gate"
91
- >
92
- {/* The site's inner-page header: the back arrow at the start (#8790 AC-1); the card carries the mark (#9662). */}
93
- <header
94
- className="flex h-16 items-center px-5 md:px-8"
95
- data-testid="account-sign-in-gate-header"
96
- >
97
- <NavBackLink href={home} label={t("homeLink")} />
98
- </header>
99
- <div className="flex flex-1 flex-col items-center md:justify-center md:py-section">
100
- {/* AuthShell's 400px column: the cap sits on the wrapper, never on the card (AuthShell.tsx). */}
101
- <div className="w-full max-w-100">
102
- <AuthCard
103
- intent="sign-in"
104
- footer="none"
105
- // The page's one heading (#7894): the gate is the whole page.
106
- headingLevel={1}
107
- logo={siteLogo()}
108
- labels={{
109
- signInHeading: config
110
- ? t("hubHeadline", { site: SITE_NAME })
111
- : t("emptyHeadline"),
112
- }}
113
- subhead={config ? t("hubDescription") : t("emptyDescription")}
114
- {...(prospect ? { prospect } : {})}
115
- body={
116
- config ? (
117
- // The primary action: full width at `big` (44px).
118
- <Button asChild size="big" className="w-full">
119
- <Link
120
- href={signInHref}
121
- variant="bare"
122
- data-testid="account-hub-sign-in"
123
- >
124
- {t("hubSignIn")}
125
- </Link>
126
- </Button>
127
- ) : (
128
- <Button
129
- asChild
130
- variant="secondary"
131
- size="big"
132
- className="w-full"
133
- >
134
- <Link
135
- href={home}
136
- variant="bare"
137
- data-testid="account-sign-in-gate-home"
138
- >
139
- {t("homeLink")}
140
- </Link>
141
- </Button>
142
- )
143
- }
144
- footnote={
145
- <Text as="p" variant="caption">
146
- {signIn("acknowledgement")}{" "}
147
- <Link variant="inline" href={localeHref(locale, "/terms")}>
148
- {signIn("termsLink")}
149
- </Link>{" "}
150
- {signIn("acknowledgementAnd")}{" "}
151
- <Link variant="inline" href={localeHref(locale, "/privacy")}>
152
- {signIn("privacyLink")}
153
- </Link>
154
- {signIn("acknowledgementEnd")}
155
- </Text>
156
- }
157
- />
158
- </div>
159
- </div>
160
- </div>
161
- );
162
- }