create-ailk 0.37.1 → 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 (318) hide show
  1. package/README.md +129 -0
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +2 -2
  6. package/dist/add-route.js +19 -12
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +12 -16
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +73 -2
  26. package/dist/routes.d.ts +130 -0
  27. package/dist/routes.js +954 -0
  28. package/dist/site-manifest.js +6 -4
  29. package/dist/site-roster.d.ts +11 -2
  30. package/dist/site-roster.js +63 -21
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +26 -0
  34. package/dist/surfaces.js +105 -293
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +108 -10
  37. package/dist/template-record.js +3 -1
  38. package/dist/topology.d.ts +26 -1
  39. package/dist/topology.js +273 -7
  40. package/dist/update.d.ts +17 -2
  41. package/dist/update.js +480 -77
  42. package/package.json +3 -3
  43. package/templates/README.md +1 -1
  44. package/templates/apps/mcp/CLAUDE.md +5 -3
  45. package/templates/apps/web/CLAUDE.md +87 -23
  46. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
  47. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
  48. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  49. package/templates/apps/web/account.config.tsx +100 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  51. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
  52. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/layout.tsx +46 -29
  54. package/templates/apps/web/app/apple-icon.tsx +72 -0
  55. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  56. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  57. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  58. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  59. package/templates/apps/web/app/og/route.tsx +155 -72
  60. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  61. package/templates/apps/web/auth.config.tsx +107 -0
  62. package/templates/apps/web/auth.ts +2 -1
  63. package/templates/apps/web/i18n/request.ts +51 -1
  64. package/templates/apps/web/jest.config.cjs +17 -1
  65. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  66. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
  67. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  68. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  69. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  70. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  71. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  72. package/templates/apps/web/lib/listings.tsx +2 -2
  73. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  74. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  75. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  76. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  77. package/templates/apps/web/lib/served-pages.ts +95 -0
  78. package/templates/apps/web/lib/server-api.ts +1 -1
  79. package/templates/apps/web/lib/site-brand.tsx +3 -5
  80. package/templates/apps/web/lib/topology.generated.ts +5 -0
  81. package/templates/apps/web/messages/en.json +8 -836
  82. package/templates/apps/web/middleware.ts +15 -26
  83. package/templates/apps/web/next.config.mjs +35 -0
  84. package/templates/apps/web/package.json +2 -0
  85. package/templates/apps/web/types/messages.d.ts +6 -1
  86. package/templates/customizations.yaml +9 -0
  87. package/templates/package.json +3 -1
  88. package/templates/tools/lint-architecture.ts +164 -11
  89. package/versions.json +49 -47
  90. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  91. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  92. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  93. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  94. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  95. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  96. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  97. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  98. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  99. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  100. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  101. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  102. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  103. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  104. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  105. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  106. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  107. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  108. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  109. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  110. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  111. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  112. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  113. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  114. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  115. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  116. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  117. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  118. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  119. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  120. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  121. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  122. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  123. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  124. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  125. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  126. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  127. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  128. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  129. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  130. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  131. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  132. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  133. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  134. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  135. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  136. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  137. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  138. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  139. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  140. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  141. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  142. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  143. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  144. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  145. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  146. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  147. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
  148. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  149. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  150. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
  151. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
  152. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  153. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  154. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
  155. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  156. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  157. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  158. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  159. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  160. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  161. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
  162. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  163. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  164. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
  165. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  166. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  167. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  168. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  169. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  170. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  171. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  172. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  173. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  174. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  175. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  176. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
  177. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  178. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  179. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  180. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  181. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  182. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
  183. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  184. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
  185. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  186. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
  187. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  188. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  189. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  190. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  191. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  192. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  193. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
  194. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
  195. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  196. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  197. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  198. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
  199. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  200. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  201. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
  202. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
  203. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  204. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  205. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
  206. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
  207. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  208. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  209. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  210. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
  211. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  212. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  213. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
  214. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  215. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  216. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
  217. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  218. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  219. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  220. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  221. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  222. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  223. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  224. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  225. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  226. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  227. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  228. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  229. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  230. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  231. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  232. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  233. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  234. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  235. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  236. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  237. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  238. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  239. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  240. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  241. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  242. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  243. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  244. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  245. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  246. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  247. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  248. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  249. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  250. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  251. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  252. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  253. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  254. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  255. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  256. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  257. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  258. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  259. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  260. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  261. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  262. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  263. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  264. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  265. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  266. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  267. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  268. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  269. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  270. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  271. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  272. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  273. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  274. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  275. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  276. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  277. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  278. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  279. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  280. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  281. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  282. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  283. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  284. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  285. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  286. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  287. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  288. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  289. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  290. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  291. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  292. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  293. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  294. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  295. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  296. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  297. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  298. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  299. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  300. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  301. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  302. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  303. package/templates/apps/web/lib/account-config.ts +0 -678
  304. package/templates/apps/web/lib/auth-routes.ts +0 -125
  305. package/templates/apps/web/lib/checkout-config.ts +0 -16
  306. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  307. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  308. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  309. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  310. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  311. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  312. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  313. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  314. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  315. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  316. package/templates/apps/web/lib/next-path.ts +0 -35
  317. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  318. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,111 +0,0 @@
1
- /**
2
- * `/[locale]/forgot-password` — request a password-reset link (#5963, wired by #5962).
3
- *
4
- * RSC. #5963 shipped this as a static `forgot` intent with no `onSubmit`;
5
- * #5962 hands the available branch to a client island that calls Better Auth.
6
- *
7
- * Unavailable (the default) renders the `invitation` skeleton relabelled
8
- * through `labels`: copy only, with the footer's "Back to sign in". Never a
9
- * 404 — the segment exists as a file, so Next resolves it whatever the
10
- * predicate says.
11
- *
12
- * The predicate is `resetSendConfigured()`, NOT the flag-only
13
- * `isResetAvailable()`. The flag alone is the operator's INTENT; the
14
- * conjunction is whether the flow can actually complete. Keying the page on
15
- * intent would render a live form on a deployment whose server refuses to
16
- * send — a form whose only possible outcome is the error state.
17
- *
18
- * WHAT SHARES THAT PREDICATE, AND WHAT DOES NOT (#6068). One predicate decides
19
- * this page, `/reset-password`, and whether `sendResetPassword` is wired at
20
- * all, so no visitor is offered a step the server would refuse. `auth.ts`'s
21
- * `onPasswordReset` is DELIBERATELY OUTSIDE it: Better Auth registers the
22
- * `/reset-password` POST on `emailAndPassword.enabled` rather than on the send
23
- * conjunction, so a token minted before an operator removed a conjunct stays
24
- * consumable for its whole hour. Gating that callback too would make exactly
25
- * those resets the ones that skip sibling-token invalidation and the § D17
26
- * notice — the degraded deployment getting the weaker guarantee. Offering a
27
- * step is predicated; cleaning up after one that already happened is not.
28
- *
29
- * The `redirectTo` the island needs is built HERE, server-side, from
30
- * `BETTER_AUTH_URL`. Resolving it in the browser from `window.location` would
31
- * hand an attacker-influenced origin to the one call that mints a credential.
32
- */
33
-
34
- import { localeHref } from "@working-theory/ui";
35
- import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
36
- import type { Metadata } from "next";
37
- import { getTranslations } from "next-intl/server";
38
- import type { ReactElement } from "react";
39
-
40
- import { resetSendConfigured } from "../../../../lib/auth-env";
41
-
42
- import { ForgotPasswordCard } from "./forgot-password-card";
43
- import { siteLogo } from "../../../../lib/site-logo";
44
-
45
- interface Props {
46
- params: Promise<{ locale: string }>;
47
- }
48
-
49
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
50
- const { locale } = await params;
51
- const t = await getTranslations({ locale, namespace: "auth" });
52
- return { title: t("forgotTitle"), description: t("forgotDescription") };
53
- }
54
-
55
- export default async function ForgotPasswordPage({
56
- params,
57
- }: Props): Promise<ReactElement> {
58
- const { locale } = await params;
59
- const t = await getTranslations({ locale, namespace: "auth" });
60
- const signInHref = localeHref(locale, "/sign-in");
61
-
62
- const available = resetSendConfigured();
63
-
64
- if (!available) {
65
- const labels: AuthCardLabels = {
66
- invitationHeading: t("forgotUnavailableHeading"),
67
- invitationSubhead: t("forgotUnavailableSubhead"),
68
- invitationBody: t("forgotUnavailableBody"),
69
- backToSignIn: t("backToSignIn"),
70
- };
71
- return (
72
- <div className="flex flex-col gap-4" data-testid="forgot-password-page">
73
- <AuthCard
74
- intent="invitation"
75
- signInHref={signInHref}
76
- labels={labels}
77
- />
78
- </div>
79
- );
80
- }
81
-
82
- const labels: AuthCardLabels = {
83
- forgotHeading: t("forgotHeading"),
84
- forgotSubhead: t("forgotSubhead"),
85
- forgotSubmit: t("forgotSubmit"),
86
- email: t("email"),
87
- backToSignIn: t("backToSignIn"),
88
- sentHeading: t("sentHeading"),
89
- sentSubhead: t("sentSubhead"),
90
- sentBody: t("sentBody"),
91
- sentToPrefix: t("sentToPrefix"),
92
- };
93
-
94
- // Absolute and same-origin: `originCheck` compares an ORIGIN, and the
95
- // trusted allow-list has exactly one member. An empty or relative value
96
- // would make Better Auth reject the emitted link's own callback.
97
- const resetUrl = `${process.env.BETTER_AUTH_URL ?? ""}${localeHref(
98
- locale,
99
- "/reset-password",
100
- )}`;
101
-
102
- return (
103
- <ForgotPasswordCard
104
- logo={siteLogo()}
105
- resetUrl={resetUrl}
106
- signInHref={signInHref}
107
- labels={labels}
108
- errorLabels={{ requestFailed: t("resetRequestFailed") }}
109
- />
110
- );
111
- }
@@ -1,81 +0,0 @@
1
- /**
2
- * `/[locale]/(auth)` — the auth route group's layout (#5963).
3
- *
4
- * Mounts `AuthShell` for the five auth pages (`/sign-in`, `/sign-up`,
5
- * `/forgot-password`, `/reset-password`, `/verify-email`). A route group
6
- * contributes no URL segment, so every existing link to `/sign-in` keeps
7
- * working; what changes is the frame.
8
- *
9
- * The marketing Nav + Footer are dropped ONE level up, in
10
- * `app/[locale]/layout.tsx`: a route group's layout nests INSIDE its parent
11
- * segment's layout, so this file cannot escape an ancestor's chrome on its
12
- * own. It branches on `lib/auth-routes.ts`'s `isAuthPath()` — the same module
13
- * that names the five segments below.
14
- *
15
- * Slots only: the shell owns the geometry, this layout supplies the site's own
16
- * brand mark, footer hrefs and language switcher.
17
- */
18
-
19
- import { AuthShell } from "@working-theory/templates/shells";
20
- import { localeHref } from "@working-theory/ui";
21
- import { LocaleSwitcherNav } from "@working-theory/ui/blocks";
22
- import { readLocales } from "@working-theory/web-i18n";
23
- import { headers } from "next/headers";
24
- import { getTranslations } from "next-intl/server";
25
- import type { ReactElement, ReactNode } from "react";
26
-
27
-
28
- interface Props {
29
- children: ReactNode;
30
- params: Promise<{ locale: string }>;
31
- }
32
-
33
- export default async function AuthLayout({
34
- children,
35
- params,
36
- }: Props): Promise<ReactElement> {
37
- const { locale } = await params;
38
- const t = await getTranslations({ locale, namespace: "auth" });
39
-
40
- // `/faq` is the third always-scaffolded core route beside `/privacy` and
41
- // `/terms` (the locale layout's own `legalLinks` comment): there is no
42
- // `/help` segment in the tree, and inventing one is out of scope.
43
- const footerLinks = [
44
- { label: t("footerPrivacy"), href: localeHref(locale, "/privacy") },
45
- { label: t("footerTerms"), href: localeHref(locale, "/terms") },
46
- { label: t("footerHelp"), href: localeHref(locale, "/faq") },
47
- ];
48
-
49
- const pathname = (await headers()).get("x-pathname") ?? "/";
50
-
51
- return (
52
- <AuthShell
53
- // No brand row (#8790 D3): every auth card now carries the site's mark
54
- // centred at 48px (`AuthCard`'s `logo` slot), so the shell's top-start
55
- // corner is free for a page's own affordance (the sign-in's back link).
56
- footerLinks={footerLinks}
57
- languageSwitcher={
58
- <LocaleSwitcherNav
59
- current={locale}
60
- locales={readLocales()}
61
- pathname={pathname}
62
- // AuthShell's footer link rows are already drawn at a 44px tap
63
- // target (`max-md:py-3.5`) below `md` — this matches the
64
- // switcher's DRAWN size to them so it doesn't read as a stray
65
- // smaller control (#6018 A2). Not a new accessibility fix: the
66
- // switcher's touch TARGET was already 44px via its own hit-area
67
- // overlay (#5989) regardless of this prop.
68
- size="touch"
69
- />
70
- }
71
- >
72
- {/*
73
- * ADR-0027 — exactly one <main> per page. AuthShell's content slot is a
74
- * non-landmark <div> (the shell's own contract), and every page in this
75
- * group is one card, so the group's layout owns the landmark rather than
76
- * repeating it in five thin pages.
77
- */}
78
- <main>{children}</main>
79
- </AuthShell>
80
- );
81
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * The acknowledgement at the foot of every auth card (#8790 D6) — "You
3
- * acknowledge that you read, and agree to our Terms of Service and our Privacy
4
- * Policy." (#9662) — linking the site's own policy routes through the inline
5
- * link variant, so the card never hardcodes a path.
6
- *
7
- * One builder for `/sign-in`, `/sign-up` and the `(authed)` gate.
8
- * `caption` is the muted footnote role; a default `Text` would re-impose body
9
- * size and the foreground colour over the card's footnote wrapper.
10
- */
11
-
12
- import { localeHref } from "@working-theory/ui";
13
- import { Link, Text } from "@working-theory/ui/primitives";
14
- import type { ReactElement } from "react";
15
-
16
- import type { SignInCardText } from "./sign-in/sign-in-text";
17
-
18
- export function legalFootnote(
19
- locale: string,
20
- text: SignInCardText["acknowledgement"],
21
- ): ReactElement {
22
- return (
23
- <Text as="p" variant="caption">
24
- {text.lead}{" "}
25
- <Link variant="inline" href={localeHref(locale, "/terms")}>
26
- {text.terms}
27
- </Link>{" "}
28
- {text.and}{" "}
29
- <Link variant="inline" href={localeHref(locale, "/privacy")}>
30
- {text.privacy}
31
- </Link>
32
- {text.end}
33
- </Text>
34
- );
35
- }
@@ -1,179 +0,0 @@
1
- /**
2
- * `/reset-password` returns a spoke's person to their Security tab (#11162
3
- * AC-2).
4
- *
5
- * The page's decision is under test — which `completeHref`, if any, it hands
6
- * the island for a `?ref=` — so the island is a double that records its
7
- * props; its own navigation is pinned below with the real card and an
8
- * injected `navigate`, the sibling `password-reset.test.tsx`'s idiom.
9
- */
10
- import { render, screen, waitFor } from "@testing-library/react";
11
- import userEvent from "@testing-library/user-event";
12
-
13
- const mockResetSendConfigured = jest.fn();
14
- // eslint-disable-next-line no-restricted-syntax -- #507: auth-env.ts is a pure env-introspection module with no external boundary to mock instead.
15
- jest.mock("../../../../../lib/auth-env", () => ({
16
- __esModule: true,
17
- getActiveProviderIds: () => ["email"],
18
- isSignUpOpen: () => false,
19
- isResetAvailable: () => mockResetSendConfigured(),
20
- resetSendConfigured: () => mockResetSendConfigured(),
21
- phoneVerificationConfigured: () => false,
22
- }));
23
-
24
- const mockResetPassword = jest.fn();
25
- jest.mock("better-auth/react", () => ({
26
- __esModule: true,
27
- createAuthClient: () => ({
28
- resetPassword: (...args: unknown[]) => mockResetPassword(...args),
29
- }),
30
- }));
31
-
32
- const mockCard = jest.fn();
33
- // eslint-disable-next-line no-restricted-syntax -- #507: the island's post-reset navigation is `window.location.assign`, which jsdom cannot observe; the page's one decision — the `completeHref` it hands the island — is read from the island's props, and the real island is pinned below with an injected `navigate`.
34
- jest.mock("../reset-password-card", () => ({
35
- __esModule: true,
36
- ResetPasswordCard: (props: Record<string, unknown>) => {
37
- mockCard(props);
38
- return <div data-testid="reset-card-double" />;
39
- },
40
- }));
41
-
42
- import en from "../../../../../messages/en.json";
43
- import { mintSecurityReturn } from "../../../../api/auth/hub/password/return";
44
- import ResetPasswordPage from "../page";
45
-
46
- const { ResetPasswordCard } = jest.requireActual<typeof import("../reset-password-card")>(
47
- "../reset-password-card",
48
- );
49
-
50
- const SECRET = "s".repeat(43);
51
- const SPOKE = "https://spoke.example";
52
- /** The spoke's return route, which drops the revoked session before the tab (#11162). */
53
- const LANDING = `${SPOKE}/api/hub-session/password/return?next=${encodeURIComponent("/account/security")}`;
54
- const ORIGINAL_ENV = process.env;
55
-
56
- beforeEach(() => {
57
- jest.clearAllMocks();
58
- process.env = { ...ORIGINAL_ENV, BETTER_AUTH_SECRET: SECRET, BETTER_AUTH_URL: "https://hub.example/api/auth" };
59
- mockResetSendConfigured.mockReturnValue(true);
60
- });
61
-
62
- afterAll(() => {
63
- process.env = ORIGINAL_ENV;
64
- });
65
-
66
- async function renderPage(query: Record<string, string>): Promise<void> {
67
- render(
68
- await ResetPasswordPage({
69
- params: Promise.resolve({ locale: "en" }),
70
- searchParams: Promise.resolve(query),
71
- }),
72
- );
73
- }
74
-
75
- /** The props the page handed the island. */
76
- function cardProps(): Record<string, unknown> {
77
- expect(mockCard).toHaveBeenCalledTimes(1);
78
- return mockCard.mock.calls[0]?.[0] as Record<string, unknown>;
79
- }
80
-
81
- describe("the page's return decision", () => {
82
- it("a ref the hub sealed sends a completed reset to the spoke's return route, bound for its Security tab", async () => {
83
- const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
84
- await renderPage({ token: "tok_live", ref });
85
- expect(cardProps()).toMatchObject({
86
- token: "tok_live",
87
- signInHref: "/sign-in",
88
- completeHref: LANDING,
89
- });
90
- });
91
-
92
- it.each([
93
- ["no ref", {}],
94
- ["a ref sealed under another secret", { ref: mintSecurityReturn(SPOKE, "/account/security", "x".repeat(43)) }],
95
- ["a ref that is not one", { ref: "https://evil.example/account/security" }],
96
- ["an expired ref", { ref: mintSecurityReturn(SPOKE, "/account/security", SECRET, Date.now() - 5_000_000) }],
97
- ] as Array<[string, Record<string, string>]>)("%s leaves the completed reset on the hub's sign-in", async (_label, query) => {
98
- await renderPage({ token: "tok_live", ...query });
99
- const props = cardProps();
100
- expect(props.signInHref).toBe("/sign-in");
101
- expect(props).not.toHaveProperty("completeHref");
102
- });
103
-
104
- it("a repeated ref reads as its first value only", async () => {
105
- const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
106
- render(
107
- await ResetPasswordPage({
108
- params: Promise.resolve({ locale: "en" }),
109
- searchParams: Promise.resolve({ token: "tok_live", ref: [ref, "second"] }),
110
- }),
111
- );
112
- expect(cardProps()).toMatchObject({ completeHref: LANDING });
113
- });
114
-
115
- it("the expired-token state ignores the ref and renders no island", async () => {
116
- const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
117
- await renderPage({ error: "INVALID_TOKEN", ref });
118
- expect(screen.getByTestId("reset-token-error")).toBeInTheDocument();
119
- expect(mockCard).not.toHaveBeenCalled();
120
- });
121
- });
122
-
123
- describe("the island honours completeHref", () => {
124
- const labels = {
125
- resetHeading: en.auth.resetHeading,
126
- resetSubmit: en.auth.resetSubmit,
127
- newPassword: en.auth.newPassword,
128
- confirmPassword: en.auth.confirmPassword,
129
- backToSignIn: en.auth.backToSignIn,
130
- };
131
- const errorLabels = {
132
- resetFailed: en.auth.resetFailed,
133
- invalidToken: en.auth.resetExpiredSubhead,
134
- mismatch: en.auth.passwordMismatch,
135
- };
136
-
137
- async function submit(): Promise<void> {
138
- const user = userEvent.setup();
139
- await user.type(screen.getByTestId("auth-password"), "a-long-enough-pw");
140
- await user.type(screen.getByTestId("auth-confirm-password"), "a-long-enough-pw");
141
- await user.click(screen.getByTestId("auth-submit"));
142
- }
143
-
144
- it("a completed reset lands on the spoke's return route, and the back link stays the hub's sign-in", async () => {
145
- mockResetPassword.mockResolvedValue({});
146
- const navigate = jest.fn();
147
- render(
148
- <ResetPasswordCard
149
- token="tok_live"
150
- signInHref="/sign-in"
151
- completeHref={LANDING}
152
- labels={labels}
153
- errorLabels={errorLabels}
154
- navigate={navigate}
155
- />,
156
- );
157
- expect(screen.getByRole("link", { name: en.auth.backToSignIn })).toHaveAttribute("href", "/sign-in");
158
- await submit();
159
- await waitFor(() => expect(navigate).toHaveBeenCalledWith(LANDING));
160
- });
161
-
162
- it("a failed reset navigates nowhere", async () => {
163
- mockResetPassword.mockResolvedValue({ error: { message: "nope" } });
164
- const navigate = jest.fn();
165
- render(
166
- <ResetPasswordCard
167
- token="tok_live"
168
- signInHref="/sign-in"
169
- completeHref={LANDING}
170
- labels={labels}
171
- errorLabels={errorLabels}
172
- navigate={navigate}
173
- />,
174
- );
175
- await submit();
176
- await waitFor(() => expect(mockResetPassword).toHaveBeenCalled());
177
- expect(navigate).not.toHaveBeenCalled();
178
- });
179
- });
@@ -1,157 +0,0 @@
1
- /**
2
- * `/[locale]/reset-password` — set a new password (#5963, wired by #5962).
3
- *
4
- * Three states, decided server-side:
5
- * - reset not available → the relabelled `invitation` skeleton. A
6
- * reset link cannot be used on a site that
7
- * does not offer reset.
8
- * - available, `?error=…` → the expired/invalid-token state. Better
9
- * Auth redirects here with `?error=INVALID_TOKEN`
10
- * when the token is missing, unknown or past
11
- * its hour.
12
- * - available, otherwise → the `reset` island, carrying `?token=`.
13
- *
14
- * Never a 404 in any of the three — the segment is a file.
15
- *
16
- * The availability predicate is `resetSendConfigured()`, NOT the flag-only
17
- * `isResetAvailable()` (code review, AC-2). This is the CONSUME half of the
18
- * flow, and Better Auth registers its `/reset-password` POST on
19
- * `emailAndPassword.enabled` — which stays true when a send conjunct goes
20
- * away. So for the token's whole hour after an operator removes, say,
21
- * `BETTER_AUTH_URL`, an outstanding link would otherwise still set a password
22
- * on a site that has stopped offering reset. Keying this page on the same
23
- * predicate that decides `sendResetPassword` closes the visible half; the
24
- * server-side half is `onPasswordReset` in `auth.ts`, which is now
25
- * unconditional so a consumed token always invalidates its siblings and
26
- * always attempts the § D17 notice, configured or not.
27
- *
28
- * The token is read from `searchParams` and handed to the island as a prop. It
29
- * is the credential, so nothing here logs it and nothing re-appends it to a
30
- * URL.
31
- *
32
- * `?ref=` (#11162) is the sealed return of a link the hub mailed for a
33
- * spoke's Security tab (`app/api/auth/hub/password/return.ts`): opened, it
34
- * names the spoke's registered origin and its `/account/security`, and a
35
- * completed reset lands on that spoke's return route bound for the tab
36
- * instead of this hub's sign-in (the reset ended the spoke's credential, so
37
- * the spoke drops its session there and signs the person back in). A ref
38
- * that does not open is ignored — never a redirect to a URL this hub did
39
- * not seal.
40
- */
41
-
42
- import { localeHref } from "@working-theory/ui";
43
- import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
44
- import type { Metadata } from "next";
45
- import { getTranslations } from "next-intl/server";
46
- import type { ReactElement } from "react";
47
-
48
- import { resetSendConfigured } from "../../../../lib/auth-env";
49
- import { resolveSecret } from "../../../../lib/auth-secret";
50
- import { siteLogo } from "../../../../lib/site-logo";
51
- import { openSecurityReturn } from "../../../api/auth/hub/password/return";
52
-
53
- import { ResetPasswordCard } from "./reset-password-card";
54
-
55
- interface Props {
56
- params: Promise<{ locale: string }>;
57
- searchParams?: Promise<{
58
- token?: string | string[];
59
- error?: string | string[];
60
- ref?: string | string[];
61
- }>;
62
- }
63
-
64
- /** First value only — a repeated query param must not become an array here. */
65
- function firstValue(raw: string | string[] | undefined): string {
66
- if (Array.isArray(raw)) return raw[0] ?? "";
67
- return raw ?? "";
68
- }
69
-
70
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
71
- const { locale } = await params;
72
- const t = await getTranslations({ locale, namespace: "auth" });
73
- return { title: t("resetTitle"), description: t("resetDescription") };
74
- }
75
-
76
- export default async function ResetPasswordPage({
77
- params,
78
- searchParams,
79
- }: Props): Promise<ReactElement> {
80
- const { locale } = await params;
81
- const t = await getTranslations({ locale, namespace: "auth" });
82
- const signInHref = localeHref(locale, "/sign-in");
83
-
84
- const query = searchParams ? await searchParams : {};
85
- const token = firstValue(query.token);
86
- const error = firstValue(query.error);
87
- const ref = firstValue(query.ref);
88
-
89
- const available = resetSendConfigured();
90
-
91
- if (!available) {
92
- const labels: AuthCardLabels = {
93
- invitationHeading: t("resetUnavailableHeading"),
94
- invitationSubhead: t("resetUnavailableSubhead"),
95
- invitationBody: t("resetUnavailableBody"),
96
- backToSignIn: t("backToSignIn"),
97
- };
98
- return (
99
- <div className="flex flex-col gap-4" data-testid="reset-password-page">
100
- <AuthCard intent="invitation" signInHref={signInHref} labels={labels} />
101
- </div>
102
- );
103
- }
104
-
105
- if (error) {
106
- // The `invitation` skeleton relabelled again — copy only, with the route
107
- // back to sign-in. No new AuthCard intent and no new prop: `resolveLabel()`
108
- // is the seam that already exists, so `packages/ui` stays out of this diff.
109
- const labels: AuthCardLabels = {
110
- invitationHeading: t("resetExpiredHeading"),
111
- invitationSubhead: t("resetExpiredSubhead"),
112
- invitationBody: t("resetExpiredBody"),
113
- backToSignIn: t("backToSignIn"),
114
- };
115
- return (
116
- <div
117
- className="flex flex-col gap-4"
118
- data-testid="reset-password-page"
119
- >
120
- <div data-testid="reset-token-error">
121
- <AuthCard
122
- intent="invitation"
123
- signInHref={signInHref}
124
- labels={labels}
125
- />
126
- </div>
127
- </div>
128
- );
129
- }
130
-
131
- const labels: AuthCardLabels = {
132
- resetHeading: t("resetHeading"),
133
- resetSubhead: t("resetSubhead"),
134
- resetSubmit: t("resetSubmit"),
135
- newPassword: t("newPassword"),
136
- confirmPassword: t("confirmPassword"),
137
- backToSignIn: t("backToSignIn"),
138
- };
139
-
140
- // A spoke's Security tab, when the link was mailed for one (#11162).
141
- const returnHref = ref ? openSecurityReturn(ref, resolveSecret()) : null;
142
-
143
- return (
144
- <ResetPasswordCard
145
- logo={siteLogo()}
146
- token={token}
147
- signInHref={signInHref}
148
- {...(returnHref !== null ? { completeHref: returnHref } : {})}
149
- labels={labels}
150
- errorLabels={{
151
- resetFailed: t("resetFailed"),
152
- invalidToken: t("resetExpiredSubhead"),
153
- mismatch: t("passwordMismatch"),
154
- }}
155
- />
156
- );
157
- }
@@ -1,126 +0,0 @@
1
- "use client"; // Better Auth's client call (resetPassword) + the error state
2
-
3
- /**
4
- * ResetPasswordCard — `/reset-password`'s client island (#5962).
5
- *
6
- * The token identifies the account, so the card renders no email field. It is
7
- * passed to `authClient.resetPassword` in the request BODY and is never
8
- * re-appended to a URL by this component — the one it arrived on is already in
9
- * the browser's history and in every access log between here and the edge, and
10
- * a second copy buys nothing but more places to leak from.
11
- *
12
- * On success it hard-navigates rather than routing client-side — see the
13
- * comment at the call.
14
- *
15
- * An absent token is treated exactly like an expired one. That case is
16
- * reachable — someone opening `/reset-password` directly — and a form that
17
- * submits nothing and fails obscurely is worse than the honest message.
18
- */
19
-
20
- import {
21
- AuthCard,
22
- type AuthCardLabels,
23
- type AuthSubmitData,
24
- } from "@working-theory/ui/blocks";
25
- import { createAuthClient } from "better-auth/react";
26
- import type { ReactElement, ReactNode } from "react";
27
- import { useState } from "react";
28
-
29
- const authClient = createAuthClient();
30
-
31
- export interface ResetPasswordCardProps {
32
- /** The site's mark, centred in the card at 48px (#8790 D3). */
33
- logo?: ReactNode;
34
- /** The `?token=` Better Auth redirected back with. May be empty. */
35
- token: string;
36
- /** The sign-in page — the card's back link, and where a completed reset lands by default. */
37
- signInHref: string;
38
- /**
39
- * Where a completed reset lands instead (#11162): a spoke's Security tab,
40
- * for a link the hub mailed on that spoke's behalf. The page opens it from
41
- * a sealed ref; this card never builds one.
42
- */
43
- completeHref?: string;
44
- /** Translated AuthCard labels (resolved server-side by the page). */
45
- labels: AuthCardLabels;
46
- /** Translated error copy. */
47
- errorLabels: { resetFailed: string; invalidToken: string; mismatch: string };
48
- /**
49
- * How a completed reset leaves the page. Defaults to a FULL navigation,
50
- * deliberately: the reset just revoked every session this browser held, so
51
- * every piece of client state behind it is stale and a hard load is the
52
- * honest way to drop it.
53
- *
54
- * Injectable for the same reason `createAuth` takes an optional `prisma` —
55
- * jsdom's `window.location` is read-only, so a test cannot observe the real
56
- * one. No production caller passes this.
57
- */
58
- navigate?: (href: string) => void;
59
- }
60
-
61
- const defaultNavigate = (href: string): void => {
62
- window.location.assign(href);
63
- };
64
-
65
- export function ResetPasswordCard({
66
- token,
67
- signInHref,
68
- completeHref,
69
- labels,
70
- errorLabels,
71
- navigate = defaultNavigate,
72
- logo,
73
- }: ResetPasswordCardProps): ReactElement {
74
- const [errors, setErrors] = useState<{
75
- password?: string;
76
- confirmPassword?: string;
77
- }>({});
78
-
79
- const submit = async (
80
- password: string,
81
- confirmPassword: string,
82
- ): Promise<void> => {
83
- setErrors({});
84
-
85
- if (password !== confirmPassword) {
86
- setErrors({ confirmPassword: errorLabels.mismatch });
87
- return;
88
- }
89
-
90
- if (!token) {
91
- setErrors({ password: errorLabels.invalidToken });
92
- return;
93
- }
94
-
95
- const failed = await authClient
96
- .resetPassword({ newPassword: password, token })
97
- .then(
98
- (res) => Boolean(res?.error),
99
- () => true,
100
- );
101
-
102
- if (failed) {
103
- setErrors({ password: errorLabels.resetFailed });
104
- return;
105
- }
106
-
107
- navigate(completeHref ?? signInHref);
108
- };
109
-
110
- const handleSubmit = (data: AuthSubmitData): void => {
111
- void submit(data.password ?? "", data.confirmPassword ?? "");
112
- };
113
-
114
- return (
115
- <div className="flex flex-col gap-4" data-testid="reset-password-page">
116
- <AuthCard
117
- {...(logo !== undefined ? { logo } : {})}
118
- intent="reset"
119
- signInHref={signInHref}
120
- labels={labels}
121
- onSubmit={handleSubmit}
122
- errors={errors}
123
- />
124
- </div>
125
- );
126
- }