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,201 +0,0 @@
1
- /**
2
- * `/[locale]/sign-up` — the site's sign-up page (#5963).
3
- *
4
- * RSC. Branches on `isSignUpOpen()`:
5
- * - open → the sign-up form island, wired to Better Auth exactly as
6
- * `/sign-in`'s island is (providers + method from auth-env).
7
- * With the email sign-in link on, the method is the one-field
8
- * "Send me a magic link" body (#9667 D6): the link creates the
9
- * account on verify, and a failed link lands back here with
10
- * `?error=<code>`, mapped to fixed copy.
11
- * - closed → AuthCard's `invitation` intent: copy only. This is the
12
- * DEFAULT — `apps/web/auth.ts` does not enable
13
- * `emailAndPassword`, so a scaffold offers no public sign-up and
14
- * the page must not advertise one.
15
- *
16
- * The one card (#9662) frames both: the site's mark, "Sign up", the
17
- * "Already have an account? Sign in" line to `/sign-in` (in place of the
18
- * footer's cross-link) and the Terms + Privacy acknowledgement. A closed site
19
- * keeps its invitation copy inside that frame — never a form the server
20
- * would refuse (operator, 2026-10-24).
21
- *
22
- * `?next=` (#9912 D4, D5) is read through `resolveNextPath`, the call
23
- * `/sign-in` makes. The validated `next` is where every method completes —
24
- * the password verification link, the magic link and Google — and both the
25
- * "Sign in" toggle and the failed-link return carry it, so a buyer sent here
26
- * by a spoke's round trip ends back on the spoke. A refused or absent `next`
27
- * gives `/account` and the bare links, as before.
28
- *
29
- * `AuthShell` (the (auth) group's layout) owns the 400px column; the card
30
- * carries the site's mark (#8790 D3).
31
- */
32
-
33
- import { localeHref } from "@working-theory/ui";
34
- import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
35
- import {
36
- resolveConsentStatement,
37
- SITE_CONSENT_CONFIG_DEFAULTS,
38
- signUpAgreements,
39
- } from "@working-theory/validation";
40
- import type { Metadata } from "next";
41
- import { getTranslations } from "next-intl/server";
42
- import type { ReactElement } from "react";
43
-
44
- import { getActiveProviderIds, isSignUpOpen } from "../../../../lib/auth-env";
45
- import { consentPoliciesFor } from "../../../../lib/consent-policies";
46
- import { siteLogo } from "../../../../lib/site-logo";
47
- import { legalFootnote } from "../legal-footnote";
48
- import { hrefWithNext, resolveNextPath } from "../sign-in/next-path";
49
- import { resolveSignInCardText } from "../sign-in/sign-in-text";
50
-
51
- import { SignUpCard, type SignUpProvider } from "./sign-up-card";
52
-
53
- interface Props {
54
- params: Promise<{ locale: string }>;
55
- searchParams?: Promise<{
56
- next?: string | string[];
57
- error?: string | string[];
58
- }>;
59
- }
60
-
61
- /**
62
- * The magic-link verify's `?error=<code>` (#9667 D6), mapped to fixed copy —
63
- * never the value itself. A repeated `error` reads its first value.
64
- */
65
- const EXPIRED_LINK_ERRORS: ReadonlySet<string> = new Set([
66
- "INVALID_TOKEN",
67
- "new_user_signup_disabled",
68
- ]);
69
-
70
- function linkNoticeKey(
71
- error: string | string[] | undefined,
72
- ): "signUpLinkExpired" | "signUpAgreementsRequired" | "signUpFailed" | null {
73
- if (error === undefined) return null;
74
- const code = Array.isArray(error) ? error[0] : error;
75
- if (code === undefined) return null;
76
- if (EXPIRED_LINK_ERRORS.has(code)) return "signUpLinkExpired";
77
- return code === "AGREEMENTS_REQUIRED"
78
- ? "signUpAgreementsRequired"
79
- : "signUpFailed";
80
- }
81
-
82
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
83
- const { locale } = await params;
84
- const t = await getTranslations({ locale, namespace: "auth" });
85
- return { title: t("signUpTitle"), description: t("signUpDescription") };
86
- }
87
-
88
- export default async function SignUpPage({
89
- params,
90
- searchParams,
91
- }: Props): Promise<ReactElement> {
92
- const { locale } = await params;
93
- const { next: rawNext, error } = (await searchParams) ?? {};
94
- const t = await getTranslations({ locale, namespace: "auth" });
95
- const fallback = localeHref(locale, "/account");
96
- const next = resolveNextPath(rawNext, fallback);
97
- // The toggle line to /sign-in, and the acknowledgement /sign-in shares.
98
- const prospect = {
99
- prompt: t("signUpFooterPrompt"),
100
- linkLabel: t("signUpFooterLink"),
101
- href: hrefWithNext(localeHref(locale, "/sign-in"), next, fallback),
102
- };
103
- const footnote = legalFootnote(
104
- locale,
105
- (await resolveSignInCardText(locale)).acknowledgement,
106
- );
107
-
108
- if (!isSignUpOpen()) {
109
- const closedLabels: AuthCardLabels = {
110
- invitationHeading: t("signUpHeading"),
111
- invitationBody: t("invitationBody"),
112
- };
113
- return (
114
- <div className="flex flex-col gap-4" data-testid="sign-up-page">
115
- <AuthCard
116
- logo={siteLogo()}
117
- intent="invitation"
118
- footer="none"
119
- subhead=""
120
- prospect={prospect}
121
- footnote={footnote}
122
- labels={closedLabels}
123
- />
124
- </div>
125
- );
126
- }
127
-
128
- const active = getActiveProviderIds();
129
- // Exactly the OAuth providers auth-env reports — never a default set.
130
- const providers = active.filter(
131
- (id): id is SignUpProvider => id === "google" || id === "github",
132
- );
133
- const method = active.includes("magic-link")
134
- ? "magic-link"
135
- : active.includes("email")
136
- ? "password"
137
- : "sso";
138
- const noticeKey = method === "magic-link" ? linkNoticeKey(error) : null;
139
-
140
- const labels: AuthCardLabels = {
141
- signUpHeading: t("signUpHeading"),
142
- signUpSubmit: t("signUpSubmit"),
143
- ssoPrefix: t("ssoPrefix"),
144
- google: t("google"),
145
- github: t("github"),
146
- email: t("email"),
147
- password: t("password"),
148
- orContinue: t("orContinue"),
149
- magicLinkSubmit: t("magicLinkSubmit"),
150
- emailLinkDivider: t("orContinue"),
151
- };
152
-
153
- // #8438 D13 — the site's sign-up agreements, resolved to this locale. No
154
- // per-site registry row is wired yet (C1), so this always reads the
155
- // platform default — the same registry the member Privacy tab and the
156
- // account-settings write both read from. Their links resolve through the
157
- // one localized policy map every agreement surface uses (#8765 D9).
158
- const agreements = signUpAgreements(SITE_CONSENT_CONFIG_DEFAULTS).map(
159
- (purpose) => ({
160
- id: purpose.id,
161
- required: purpose.required,
162
- statement: resolveConsentStatement(purpose, locale).statement,
163
- }),
164
- );
165
-
166
- return (
167
- <SignUpCard
168
- logo={siteLogo()}
169
- providers={providers}
170
- method={method}
171
- next={next}
172
- prospect={prospect}
173
- footnote={footnote}
174
- labels={labels}
175
- notConfiguredSubhead={t("signUpNotConfiguredSubhead")}
176
- errorLabels={{
177
- signUpFailed: t("signUpFailed"),
178
- providerFailed: t("providerFailed"),
179
- agreementsRequired: t("signUpAgreementsRequired"),
180
- }}
181
- agreements={agreements}
182
- agreementPolicies={consentPoliciesFor(locale)}
183
- agreementsLegend={t("signUpAgreementsLegend")}
184
- locale={locale}
185
- errorCallbackURL={hrefWithNext(
186
- localeHref(locale, "/sign-up"),
187
- next,
188
- fallback,
189
- )}
190
- {...(noticeKey ? { linkNotice: t(noticeKey) } : {})}
191
- linkLabels={{
192
- sentHeading: t("sentHeading"),
193
- sentSubhead: t("sentSubhead"),
194
- sentBody: t("signUpLinkSentBody"),
195
- back: t("signUpLinkBack"),
196
- failed: t("signUpLinkFailed"),
197
- rateLimited: t("signUpLinkRateLimited"),
198
- }}
199
- />
200
- );
201
- }
@@ -1,366 +0,0 @@
1
- "use client"; // Better Auth's client calls (signUp.email / signIn.social / $fetch) + error state
2
-
3
- /**
4
- * SignUpCard — the /sign-up page's client island (#5963).
5
- *
6
- * The sign-in island's twin: composes `AuthCard` (`intent="sign-up"`) and
7
- * wires its provider buttons / password form to the Better Auth client via
8
- * the shared `useAuthCardFlow` hook (#6018 AC-3) — the same hook
9
- * `SignInCard` next door uses. The page (RSC) decides providers + method from
10
- * auth-env and hands them in; this component never reads env.
11
- *
12
- * Inert until an operator enables `emailAndPassword` server-side — the same
13
- * documented posture the sign-in island already carries for its password
14
- * path. The page only renders this island at all when `isSignUpOpen()`.
15
- *
16
- * The one card (#9662): the page hands in the site's mark (`logo`), the
17
- * "Already have an account? Sign in" line (`prospect`, in place of AuthCard's
18
- * footer cross-link) and the Terms + Privacy acknowledgement (`footnote`).
19
- * The heading stands alone — no subhead unless the card is inert.
20
- *
21
- * Error surface: `AuthCard`'s `errors` prop is per-field, so a failed provider
22
- * launch lands on `errors.email` (the social row sits inside the password form
23
- * beside the email field). The SSO body has no fields, so the same message is
24
- * rendered as an `Alert` above the card for `method="sso"`.
25
- *
26
- * #8438 D13 — the site's sign-up agreements. `AuthCard` has no slot to render
27
- * inside and no external "disabled" hook (packages/ui is not this unit's to
28
- * change), so the card composes its own `ConsentGroup` below `AuthCard` and
29
- * GATES every entry point from the outside: the password submit and every
30
- * provider's click both run through this component's own closures, which do
31
- * nothing until every required agreement is ticked. A wrapping div's
32
- * `aria-disabled` + `pointer-events-none` styling carries the same state
33
- * visually for a mouse/touch pointer in a real browser.
34
- *
35
- * #8765 D10 — the gate above is a convenience; the server decides. The
36
- * password submit sends the ticked ids as `agreements`, with `locale`, in the
37
- * sign-up body, and Better Auth refuses a body without them
38
- * (`AGREEMENTS_REQUIRED`, shown on the agreements, not the password field).
39
- * Each provider click carries the same pair as `signIn.social`'s
40
- * `additionalData`, which Better Auth keeps in the OAuth state for the
41
- * callback. The server writes the grants with the user
42
- * (`lib/sign-up-agreements.ts`); no cookie carries them.
43
- *
44
- * #9667 D6 — the magic-link method. With the email sign-in link on, the card
45
- * is AuthCard's one-field "Send me a magic link" body, gated the same way.
46
- * The request goes through the shared client's `$fetch`, never the
47
- * `magicLinkClient()` plugin (for the reason `sign-in-card.tsx` records), with
48
- * the agreements and locale in its `metadata` — which is what makes it a
49
- * sign-up request. The server binds them to the token and creates the account
50
- * on verify. The sent state never says whether the address had an account.
51
- */
52
-
53
- import {
54
- AuthCard,
55
- ConsentGroup,
56
- type AuthCardLabels,
57
- type AuthSubmitData,
58
- } from "@working-theory/ui/blocks";
59
- import { Alert, AlertDescription } from "@working-theory/ui/primitives";
60
- import { SIGN_UP_AGREEMENTS_FIELD } from "@working-theory/validation";
61
- import {
62
- useRef,
63
- useState,
64
- type MouseEvent,
65
- type ReactElement,
66
- type ReactNode,
67
- } from "react";
68
-
69
- import { authClient, useAuthCardFlow } from "../use-auth-card-flow";
70
-
71
- /** The OAuth providers this page can launch — a subset of AuthCard's. */
72
- export type SignUpProvider = "google" | "github";
73
-
74
- /** One site agreement asked at sign-up (#8438 D1's `signUp` purposes). */
75
- export interface SignUpAgreement {
76
- id: string;
77
- required: boolean;
78
- /** Resolved to the active locale, link tokens included (D1). */
79
- statement: string;
80
- }
81
-
82
- /** Translated copy for the magic-link sign-up (#9667 D6). */
83
- export interface SignUpLinkLabels {
84
- sentHeading: string;
85
- sentSubhead: string;
86
- sentBody: string;
87
- /** The sent state's "Back to sign up" link. */
88
- back: string;
89
- /** Any failed request other than a rate limit or the agreements. */
90
- failed: string;
91
- /** A 429 from Better Auth's per-IP limit. */
92
- rateLimited: string;
93
- }
94
-
95
- export interface SignUpCardProps {
96
- /** The site's mark, centred in the card at 48px (#8790 D3). */
97
- logo?: ReactNode;
98
- /** Active OAuth providers, exactly as auth-env reports them. */
99
- providers: SignUpProvider[];
100
- /**
101
- * "magic-link" when the email sign-in link is active, else "password" when
102
- * the email provider is, otherwise "sso".
103
- */
104
- method: "sso" | "password" | "magic-link";
105
- /** Post-sign-up path. */
106
- next: string;
107
- /** The "Already have an account? Sign in" line to /sign-in (#9662). */
108
- prospect: { prompt: string; linkLabel: string; href: string };
109
- /** The acknowledgement sentence(s) at the card's foot (#9662). */
110
- footnote: ReactNode;
111
- /** Translated AuthCard labels (resolved server-side by the page). */
112
- labels: AuthCardLabels;
113
- /** Subhead shown when no provider is configured. */
114
- notConfiguredSubhead: string;
115
- /** Translated error copy. */
116
- errorLabels: {
117
- signUpFailed: string;
118
- providerFailed: string;
119
- /** Shown on the agreements when the server answers `AGREEMENTS_REQUIRED`. */
120
- agreementsRequired: string;
121
- };
122
- /** The site's `signUp` agreements — always at least `account_terms`. */
123
- agreements: SignUpAgreement[];
124
- /** Policy key → href, for the statements' inline links (D1/D3). */
125
- agreementPolicies: Record<string, string>;
126
- /** The consent fieldset's legend (`auth.signUp.agreementsLegend`). */
127
- agreementsLegend: string;
128
- /** The page's locale, sent with the agreements (the statements' language). */
129
- locale: string;
130
- /** Where a failed link lands (`/sign-up`); Better Auth appends `?error`. */
131
- errorCallbackURL?: string;
132
- /** Fixed copy for a failed link (`?error=` mapped by the page), shown above the card. */
133
- linkNotice?: string;
134
- /** The magic-link method's copy; required when `method` is "magic-link". */
135
- linkLabels?: SignUpLinkLabels;
136
- }
137
-
138
- /** The server's body key for the ticked ids — also the group's control name. */
139
- const AGREEMENTS_FIELD_NAME = SIGN_UP_AGREEMENTS_FIELD;
140
-
141
- /** The server's refusal of a sign-up without the agreements (#8765 D3). */
142
- const AGREEMENTS_REQUIRED = "AGREEMENTS_REQUIRED";
143
-
144
- function errorCode(result: unknown): unknown {
145
- if (typeof result !== "object" || result === null) return undefined;
146
- const error: unknown = Reflect.get(result, "error");
147
- return typeof error === "object" && error !== null
148
- ? Reflect.get(error, "code")
149
- : undefined;
150
- }
151
-
152
- export function SignUpCard({
153
- providers,
154
- method,
155
- next,
156
- prospect,
157
- footnote,
158
- labels,
159
- notConfiguredSubhead,
160
- errorLabels,
161
- agreements,
162
- agreementPolicies,
163
- agreementsLegend,
164
- logo,
165
- locale,
166
- errorCallbackURL,
167
- linkNotice,
168
- linkLabels,
169
- }: SignUpCardProps): ReactElement {
170
- const { errors, providerError, launchProvider, submitPassword } =
171
- useAuthCardFlow(next, {
172
- providerFailed: errorLabels.providerFailed,
173
- passwordFailed: errorLabels.signUpFailed,
174
- });
175
-
176
- const requiredAgreementIds = agreements
177
- .filter((a) => a.required)
178
- .map((a) => a.id);
179
- const [ticked, setTicked] = useState<ReadonlySet<string>>(new Set());
180
- const [agreementsError, setAgreementsError] = useState<string | undefined>(
181
- undefined,
182
- );
183
- const [linkSent, setLinkSent] = useState(false);
184
- const [linkError, setLinkError] = useState<string | undefined>(undefined);
185
- // One request at a time: a double-click would spend two of the per-IP
186
- // sends and mint two live tokens (as sign-in-card.tsx).
187
- const linkPending = useRef(false);
188
- const allAgreed = requiredAgreementIds.every((id) => ticked.has(id));
189
- // What the server checks and records (D10): the ticked ids, in the order shown.
190
- const agreed = (): { agreements: string[]; locale: string } => ({
191
- [SIGN_UP_AGREEMENTS_FIELD]: agreements
192
- .filter((a) => ticked.has(a.id))
193
- .map((a) => a.id),
194
- locale,
195
- });
196
-
197
- // `ConsentGroup`'s checkboxes are uncontrolled, by design (#5275), and
198
- // always start unticked (no `defaults` are ever passed here) — so a click
199
- // on one is always a plain toggle of the LOCAL record below; this never
200
- // reads the Radix root's own post-click DOM state, which a same-tick
201
- // ancestor listener could still see as stale.
202
- function handleAgreementsClick(event: MouseEvent<HTMLDivElement>): void {
203
- const target = (event.target as HTMLElement).closest<HTMLElement>(
204
- '[role="checkbox"]',
205
- );
206
- if (!target?.id) return;
207
- const purposeId = target.id.slice(`${AGREEMENTS_FIELD_NAME}.`.length);
208
- setTicked((previous) => {
209
- const updated = new Set(previous);
210
- if (updated.has(purposeId)) updated.delete(purposeId);
211
- else updated.add(purposeId);
212
- return updated;
213
- });
214
- }
215
-
216
- const notConfigured = method === "sso" && providers.length === 0;
217
-
218
- const providerButtons = providers.map((provider) => ({
219
- provider,
220
- // Gated: a provider launch that would create the account is refused
221
- // until every required agreement is ticked, exactly as the password
222
- // submit below. The agreements ride in the OAuth state (D10).
223
- onClick: () => {
224
- if (!allAgreed) return;
225
- void launchProvider(provider, agreed());
226
- },
227
- }));
228
-
229
- const handleSubmit = (data: AuthSubmitData): void => {
230
- if (!allAgreed) return;
231
- setAgreementsError(undefined);
232
- // Better Auth requires a `name` on email sign-up; this card collects
233
- // none, so the address doubles as the display name until the person
234
- // sets one. Better Auth ignores body keys it does not know, so
235
- // `agreements` and `locale` never reach the User row.
236
- const outcome = authClient.signUp.email({
237
- email: data.email,
238
- password: data.password ?? "",
239
- name: data.email,
240
- callbackURL: next,
241
- ...agreed(),
242
- });
243
- // The agreements refusal belongs to the agreements, not the password
244
- // field; any other failure keeps the password-field message.
245
- void submitPassword(
246
- outcome.then((result) => {
247
- if (errorCode(result) !== AGREEMENTS_REQUIRED) return result;
248
- setAgreementsError(errorLabels.agreementsRequired);
249
- return null;
250
- }),
251
- );
252
- };
253
-
254
- const requestSignUpLink = async (email: string): Promise<void> => {
255
- if (!allAgreed || linkPending.current) return;
256
- linkPending.current = true;
257
- setAgreementsError(undefined);
258
- setLinkError(undefined);
259
- try {
260
- const { error } = await authClient.$fetch("/sign-in/magic-link", {
261
- method: "POST",
262
- body: {
263
- email,
264
- // As the password submit: Better Auth wants a name on a new user.
265
- name: email,
266
- callbackURL: next,
267
- errorCallbackURL,
268
- metadata: agreed(),
269
- },
270
- });
271
- if (!error) {
272
- setLinkSent(true);
273
- return;
274
- }
275
- if (errorCode({ error }) === AGREEMENTS_REQUIRED) {
276
- setAgreementsError(errorLabels.agreementsRequired);
277
- } else {
278
- setLinkError(
279
- error.status === 429 ? linkLabels?.rateLimited : linkLabels?.failed,
280
- );
281
- }
282
- } catch {
283
- setLinkError(linkLabels?.failed);
284
- } finally {
285
- linkPending.current = false;
286
- }
287
- };
288
-
289
- if (method === "magic-link" && linkSent && linkLabels) {
290
- // No `sentTo`: both a new and a taken address get a link, and the state
291
- // must not say which.
292
- return (
293
- <div className="flex flex-col gap-4" data-testid="sign-up-page">
294
- <AuthCard
295
- {...(logo !== undefined ? { logo } : {})}
296
- intent="sent"
297
- footer="cross-link"
298
- // "Back to sign up": this page, where a failed link also lands.
299
- {...(errorCallbackURL !== undefined
300
- ? { signInHref: errorCallbackURL }
301
- : {})}
302
- labels={{
303
- sentHeading: linkLabels.sentHeading,
304
- sentSubhead: linkLabels.sentSubhead,
305
- sentBody: linkLabels.sentBody,
306
- backToSignIn: linkLabels.back,
307
- }}
308
- />
309
- </div>
310
- );
311
- }
312
-
313
- return (
314
- <div className="flex flex-col gap-4" data-testid="sign-up-page">
315
- {linkNotice ? (
316
- <Alert variant="error" data-testid="sign-up-link-notice">
317
- <AlertDescription>{linkNotice}</AlertDescription>
318
- </Alert>
319
- ) : null}
320
- {method === "sso" && providerError ? (
321
- <Alert variant="error" data-testid="sign-up-provider-error">
322
- <AlertDescription>{providerError}</AlertDescription>
323
- </Alert>
324
- ) : null}
325
- <div
326
- aria-disabled={!allAgreed}
327
- className={allAgreed ? undefined : "pointer-events-none opacity-60"}
328
- data-testid="sign-up-card-gate"
329
- >
330
- <AuthCard
331
- {...(logo !== undefined ? { logo } : {})}
332
- intent="sign-up"
333
- method={method}
334
- footer="none"
335
- subhead={notConfigured ? notConfiguredSubhead : ""}
336
- prospect={prospect}
337
- footnote={footnote}
338
- providers={providerButtons}
339
- onSubmit={
340
- method === "magic-link"
341
- ? (data) => void requestSignUpLink(data.email)
342
- : handleSubmit
343
- }
344
- errors={linkError ? { ...errors, email: linkError } : errors}
345
- labels={labels}
346
- />
347
- </div>
348
- {/* eslint-disable-next-line -- delegated-click capture over ConsentGroup's own real `role="checkbox"` descendants (Radix), which are themselves already keyboard-operable and dispatch a native click on Enter/Space; this wrapper adds no interactive semantics of its own and is never itself focused. (Bare directive, not named rules: `jsx-a11y/*` is registered in this monorepo's own lint but not in a scaffolded site's trimmed eslint config.) */}
349
- <div
350
- onClick={handleAgreementsClick}
351
- // Below `md` the card is borderless with a 20px inset; the agreements
352
- // keep that inset so they line up with its fields.
353
- className="px-5 md:px-0"
354
- data-testid="sign-up-agreements"
355
- >
356
- <ConsentGroup
357
- name={AGREEMENTS_FIELD_NAME}
358
- legend={agreementsLegend}
359
- purposes={agreements}
360
- policies={agreementPolicies}
361
- error={agreementsError}
362
- />
363
- </div>
364
- </div>
365
- );
366
- }
@@ -1,116 +0,0 @@
1
- "use client"; // useState + the Better Auth client's browser-side calls
2
-
3
- /**
4
- * useAuthCardFlow — the provider-launch + password-submit boilerplate shared
5
- * by SignInCard and SignUpCard (#6018 AC-3).
6
- *
7
- * Both cards wire an `AuthCard`'s provider buttons and password form to the
8
- * same two moves: launch a Better Auth OAuth provider (a failed launch lands
9
- * the shared `providerFailed` message on the email field, and — for an
10
- * SSO-only card with no fields — as a banner above the card) and submit the
11
- * password form (a failed submit lands a caller-named message on the
12
- * password field).
13
- *
14
- * What differs between sign-in and sign-up is the underlying Better Auth CALL
15
- * itself — `signIn.email(...)` vs `signUp.email(...)`, the latter needing a
16
- * `name` — so `submitPassword` takes the call's own promise as an argument
17
- * rather than owning the choice of which Better Auth method to invoke. The
18
- * single shared `authClient` this module exports is what each card's
19
- * `onSubmit` calls that method on.
20
- */
21
-
22
- import { createAuthClient } from "better-auth/react";
23
- import { useState } from "react";
24
-
25
- export const authClient = createAuthClient();
26
-
27
- /** The OAuth providers either card can launch. */
28
- export type AuthProvider = "google" | "github";
29
-
30
- export interface AuthCardFlowErrorLabels {
31
- /** Shown on a failed OAuth provider launch (shared by both cards). */
32
- providerFailed: string;
33
- /** Shown on a failed password submit — signInFailed or signUpFailed, caller-named. */
34
- passwordFailed: string;
35
- }
36
-
37
- interface FieldErrors {
38
- email?: string;
39
- password?: string;
40
- }
41
-
42
- /** The shape every Better Auth client call this hook awaits resolves to. */
43
- type AuthResult = { error?: unknown } | null | undefined;
44
-
45
- export interface AuthCardFlow {
46
- /** Per-field form errors, in `AuthCard`'s `errors` prop shape. */
47
- errors: FieldErrors;
48
- /** The SSO-body error banner text, or null when none is pending. */
49
- providerError: string | null;
50
- /**
51
- * Launches an OAuth provider via `signIn.social`. `additionalData` rides
52
- * in Better Auth's OAuth state to the callback — the sign-up card's ticked
53
- * agreements and locale (#8765 D10); the sign-in card passes none.
54
- */
55
- launchProvider: (
56
- provider: AuthProvider,
57
- additionalData?: Record<string, unknown>,
58
- ) => Promise<void>;
59
- /**
60
- * Awaits the caller's own Better Auth call (`signIn.email(...)` or
61
- * `signUp.email(...)`) and surfaces a `{ error }` result — or a rejection —
62
- * on the password field.
63
- */
64
- submitPassword: (action: Promise<AuthResult>) => Promise<void>;
65
- }
66
-
67
- /**
68
- * @param next - the post-auth `callbackURL` every provider launch uses.
69
- * @param errorLabels - translated copy for the two failure cases.
70
- */
71
- export function useAuthCardFlow(
72
- next: string,
73
- errorLabels: AuthCardFlowErrorLabels,
74
- ): AuthCardFlow {
75
- const [errors, setErrors] = useState<FieldErrors>({});
76
- const [providerError, setProviderError] = useState<string | null>(null);
77
-
78
- const launchProvider = async (
79
- provider: AuthProvider,
80
- additionalData?: Record<string, unknown>,
81
- ): Promise<void> => {
82
- setProviderError(null);
83
- // Better Auth reports a failed launch as `{ error }`; a network/runtime
84
- // failure rejects. Both land on the same providerFailed message.
85
- const failed = await authClient.signIn
86
- .social({
87
- provider,
88
- callbackURL: next,
89
- ...(additionalData ? { additionalData } : {}),
90
- })
91
- .then(
92
- (res: AuthResult) => Boolean(res?.error),
93
- () => true,
94
- );
95
- if (failed) {
96
- setProviderError(errorLabels.providerFailed);
97
- setErrors((prev) => ({ ...prev, email: errorLabels.providerFailed }));
98
- }
99
- };
100
-
101
- const submitPassword = async (action: Promise<AuthResult>): Promise<void> => {
102
- setErrors({});
103
- // Mirrors launchProvider's own resilience: a `{ error }` result AND a
104
- // rejected promise both land on the same passwordFailed message, so a
105
- // network/runtime failure from the caller's signIn.email/signUp.email
106
- // call surfaces in the form rather than becoming an unhandled rejection
107
- // (code review, #6018).
108
- const failed = await action.then(
109
- (res) => Boolean(res?.error),
110
- () => true,
111
- );
112
- if (failed) setErrors({ password: errorLabels.passwordFailed });
113
- };
114
-
115
- return { errors, providerError, launchProvider, submitPassword };
116
- }