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,43 +0,0 @@
1
- /**
2
- * The remembered-method cookie (#11095 D7, AC-6): it names one provider id
3
- * and nothing else, and only an id the page offers parses.
4
- */
5
- import {
6
- REMEMBERED_METHOD_COOKIE,
7
- parseRememberedMethod,
8
- rememberMethod,
9
- } from "../remembered-method";
10
-
11
- afterEach(() => {
12
- document.cookie = `${REMEMBERED_METHOD_COOKIE}=; Max-Age=0; Path=/`;
13
- });
14
-
15
- describe("parseRememberedMethod", () => {
16
- it("answers an active google or github", () => {
17
- expect(parseRememberedMethod("google", ["google", "github"])).toBe(
18
- "google",
19
- );
20
- expect(parseRememberedMethod("github", ["github"])).toBe("github");
21
- });
22
-
23
- it.each([
24
- [undefined, ["google"]],
25
- ["", ["google"]],
26
- ["evil", ["google"]],
27
- ["github", ["google"]],
28
- ["Google", ["google"]],
29
- ["google ", ["google"]],
30
- ] as const)("refuses %j with providers %j", (raw, providers) => {
31
- expect(parseRememberedMethod(raw, [...providers])).toBeUndefined();
32
- });
33
- });
34
-
35
- describe("rememberMethod", () => {
36
- it("writes the provider id alone, and null clears it", () => {
37
- expect(REMEMBERED_METHOD_COOKIE).toBe("ailk-sign-in-method");
38
- rememberMethod("google");
39
- expect(document.cookie).toBe("ailk-sign-in-method=google");
40
- rememberMethod(null);
41
- expect(document.cookie).toBe("");
42
- });
43
- });
@@ -1,266 +0,0 @@
1
- /**
2
- * Tests for `SignInCard`'s email sign-in link flow (#7435 § D8, AC-5).
3
- *
4
- * The card POSTs to Better Auth's `/sign-in/magic-link` through the shared
5
- * client's `$fetch` (not the `magicLinkClient()` plugin, so no ESM-only module
6
- * enters the client graph). Pinned here:
7
- * - the request carries the typed email, `callbackURL` = `next`, and the
8
- * `errorCallbackURL`;
9
- * - a success shows the neutral sent state — never the address, never
10
- * AuthCard's English "Follow the link we just sent" default;
11
- * - a 429 lands `rateLimited` on the field; any other error, or a
12
- * rejection, lands `failed`;
13
- * - with `emailLink` false the card renders as before.
14
- */
15
- import { render, screen } from "@testing-library/react";
16
- import userEvent from "@testing-library/user-event";
17
-
18
- const mockFetch = jest.fn();
19
- const mockSocial = jest.fn();
20
- jest.mock("better-auth/react", () => ({
21
- __esModule: true,
22
- createAuthClient: () => ({
23
- signIn: {
24
- social: (...args: unknown[]) => mockSocial(...args),
25
- email: jest.fn(),
26
- },
27
- $fetch: (...args: unknown[]) => mockFetch(...args),
28
- }),
29
- }));
30
-
31
- import { SignInCard, type SignInCardProps } from "../sign-in-card";
32
-
33
- const EMAIL_LINK_LABELS = {
34
- sentHeading: "Check your email",
35
- sentSubhead: "Look for a message from this site.",
36
- sentBody: "If an account uses that address, a sign-in link is on its way.",
37
- backToSignIn: "Back to sign in",
38
- failed: "We couldn't send a sign-in link. Try again.",
39
- rateLimited: "Too many requests. Wait a minute, then try again.",
40
- };
41
-
42
- function props(overrides: Partial<SignInCardProps> = {}): SignInCardProps {
43
- return {
44
- providers: ["google"],
45
- method: "sso",
46
- next: "/account",
47
- labels: { emailLinkSubmit: "Email me a sign-in link" },
48
- notConfiguredSubhead: "Sign-in is not configured.",
49
- errorLabels: { signInFailed: "Sign-in failed.", providerFailed: "Nope." },
50
- emailLink: true,
51
- errorCallbackURL: "/sign-in?next=%2Faccount",
52
- signInHref: "/sign-in?next=%2Faccount",
53
- emailLinkLabels: EMAIL_LINK_LABELS,
54
- ...overrides,
55
- };
56
- }
57
-
58
- async function requestLink(email = "member@example.com"): Promise<void> {
59
- const user = userEvent.setup();
60
- // #8790 D4 — one field, one action: the sign-in link is the card's own
61
- // email field and primary, not a second form.
62
- await user.type(screen.getByTestId("auth-email"), email);
63
- await user.click(screen.getByTestId("auth-submit"));
64
- }
65
-
66
- /** Clears every cookie jsdom holds, so each case starts with none. */
67
- function clearCookies(): void {
68
- for (const pair of document.cookie.split(";")) {
69
- const name = pair.split("=")[0]?.trim();
70
- if (name) document.cookie = `${name}=; Max-Age=0; Path=/`;
71
- }
72
- }
73
-
74
- beforeEach(() => {
75
- mockFetch.mockReset().mockResolvedValue({ data: { status: true }, error: null });
76
- mockSocial.mockReset().mockResolvedValue({ data: {}, error: null });
77
- clearCookies();
78
- });
79
-
80
- describe("SignInCard — email sign-in link (#7435)", () => {
81
- it("POSTs /sign-in/magic-link with the email, next and the errorCallbackURL", async () => {
82
- render(<SignInCard {...props()} />);
83
- await requestLink();
84
- expect(mockFetch).toHaveBeenCalledTimes(1);
85
- expect(mockFetch).toHaveBeenCalledWith("/sign-in/magic-link", {
86
- method: "POST",
87
- body: {
88
- email: "member@example.com",
89
- callbackURL: "/account",
90
- errorCallbackURL: "/sign-in?next=%2Faccount",
91
- },
92
- });
93
- });
94
-
95
- it("shows the neutral sent state on success — no address, no AuthCard defaults", async () => {
96
- render(<SignInCard {...props()} />);
97
- await requestLink();
98
- expect(
99
- await screen.findByText(EMAIL_LINK_LABELS.sentHeading),
100
- ).toBeInTheDocument();
101
- expect(screen.getByText(EMAIL_LINK_LABELS.sentSubhead)).toBeInTheDocument();
102
- expect(screen.getByText(EMAIL_LINK_LABELS.sentBody)).toBeInTheDocument();
103
- const back = screen.getByTestId("auth-footer-link");
104
- expect(back).toHaveTextContent(EMAIL_LINK_LABELS.backToSignIn);
105
- expect(back).toHaveAttribute("href", "/sign-in?next=%2Faccount");
106
- expect(document.body.textContent).not.toContain("member@example.com");
107
- expect(document.body.textContent).not.toContain("Follow the link we just sent");
108
- expect(screen.queryByTestId("auth-submit")).toBeNull();
109
- });
110
-
111
- it("lands rateLimited on the field for a 429", async () => {
112
- mockFetch.mockResolvedValue({
113
- data: null,
114
- error: { status: 429, statusText: "Too Many Requests" },
115
- });
116
- render(<SignInCard {...props()} />);
117
- await requestLink();
118
- expect(
119
- await screen.findByText(EMAIL_LINK_LABELS.rateLimited),
120
- ).toBeInTheDocument();
121
- expect(screen.getByTestId("auth-submit")).toBeInTheDocument();
122
- });
123
-
124
- it("lands failed on the field for any other error", async () => {
125
- mockFetch.mockResolvedValue({
126
- data: null,
127
- error: { status: 400, statusText: "Bad Request" },
128
- });
129
- render(<SignInCard {...props()} />);
130
- await requestLink();
131
- expect(await screen.findByText(EMAIL_LINK_LABELS.failed)).toBeInTheDocument();
132
- });
133
-
134
- it("lands failed on the field when the request rejects", async () => {
135
- mockFetch.mockRejectedValue(new Error("network"));
136
- render(<SignInCard {...props()} />);
137
- await requestLink();
138
- expect(await screen.findByText(EMAIL_LINK_LABELS.failed)).toBeInTheDocument();
139
- });
140
-
141
- it("sends one request for a double submit while the first is in flight", async () => {
142
- let resolve!: (v: unknown) => void;
143
- mockFetch.mockReturnValue(new Promise((r) => (resolve = r)));
144
- const user = userEvent.setup();
145
- render(<SignInCard {...props()} />);
146
- await user.type(screen.getByTestId("auth-email"), "member@example.com");
147
- await user.click(screen.getByTestId("auth-submit"));
148
- await user.click(screen.getByTestId("auth-submit"));
149
- expect(mockFetch).toHaveBeenCalledTimes(1);
150
- resolve({ data: { status: true }, error: null });
151
- expect(await screen.findByText(EMAIL_LINK_LABELS.sentHeading)).toBeInTheDocument();
152
- });
153
-
154
- it("renders the link notice above the card when given one", () => {
155
- render(<SignInCard {...props({ linkNotice: "That link expired." })} />);
156
- expect(screen.getByTestId("sign-in-link-notice")).toHaveTextContent(
157
- "That link expired.",
158
- );
159
- });
160
-
161
- it("renders the form alone, without the not-configured subhead, when it is the only method", () => {
162
- render(<SignInCard {...props({ providers: [] })} />);
163
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
164
- expect(screen.getByTestId("auth-submit")).toHaveTextContent("Email me a sign-in link");
165
- expect(screen.queryByText("Sign-in is not configured.")).toBeNull();
166
- });
167
-
168
- it("renders no email-link form when emailLink is false", () => {
169
- render(<SignInCard {...props({ emailLink: false, providers: [] })} />);
170
- expect(screen.queryByTestId("auth-submit")).toBeNull();
171
- expect(screen.getByText("Sign-in is not configured.")).toBeInTheDocument();
172
- });
173
- });
174
-
175
- // #11095 AC-6 (D7): the card remembers the provider a person launched, and a
176
- // returning person sees that one first, the rest behind "Use another way".
177
- describe("SignInCard — the remembered method (#11095 D7)", () => {
178
- const LABELS = {
179
- emailLinkSubmit: "Email me a sign-in link",
180
- ssoPrefix: "Sign in with",
181
- google: "Google",
182
- github: "GitHub",
183
- };
184
- const leadProps = (overrides: Partial<SignInCardProps> = {}) =>
185
- props({
186
- method: "password",
187
- providers: ["google", "github"],
188
- labels: LABELS,
189
- continueWith: "Continue with",
190
- useAnotherWay: "Use another way",
191
- ...overrides,
192
- });
193
-
194
- it("writes the provider id before the provider launch is called", async () => {
195
- const user = userEvent.setup();
196
- let cookieAtLaunch = "";
197
- mockSocial.mockImplementation(() => {
198
- cookieAtLaunch = document.cookie;
199
- return Promise.resolve({ data: {}, error: null });
200
- });
201
- render(<SignInCard {...leadProps()} />);
202
- await user.click(screen.getByTestId("auth-social-google"));
203
- expect(mockSocial).toHaveBeenCalledTimes(1);
204
- expect(cookieAtLaunch).toContain("ailk-sign-in-method=google");
205
- // It names the method only: no email, no user id, no time.
206
- expect(document.cookie).toBe("ailk-sign-in-method=google");
207
- });
208
-
209
- it("an email-link request clears it", async () => {
210
- document.cookie = "ailk-sign-in-method=google; Path=/";
211
- render(<SignInCard {...leadProps({ method: "sso", providers: [] })} />);
212
- await requestLink();
213
- expect(document.cookie).not.toContain("ailk-sign-in-method");
214
- });
215
-
216
- it("with a remembered provider: one Continue with button first, no email field, and Use another way", () => {
217
- render(<SignInCard {...leadProps({ remembered: "google" })} />);
218
- const lead = screen.getByTestId("auth-sso-google");
219
- expect(lead).toHaveTextContent("Continue with Google");
220
- expect(screen.getAllByRole("button")[0]).toBe(lead);
221
- expect(screen.queryByTestId("auth-sso-github")).toBeNull();
222
- expect(screen.queryByTestId("auth-email")).toBeNull();
223
- expect(screen.queryByTestId("auth-password")).toBeNull();
224
- expect(screen.getByTestId("sign-in-use-another-way")).toHaveTextContent(
225
- "Use another way",
226
- );
227
- });
228
-
229
- it("Use another way restores the full card", async () => {
230
- const user = userEvent.setup();
231
- render(<SignInCard {...leadProps({ remembered: "google" })} />);
232
- await user.click(screen.getByTestId("sign-in-use-another-way"));
233
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
234
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
235
- expect(screen.getByTestId("auth-social-github")).toBeInTheDocument();
236
- expect(screen.queryByTestId("auth-sso-google")).toBeNull();
237
- expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
238
- });
239
-
240
- it("the lead button launches its provider", async () => {
241
- const user = userEvent.setup();
242
- render(<SignInCard {...leadProps({ remembered: "google" })} />);
243
- await user.click(screen.getByTestId("auth-sso-google"));
244
- expect(mockSocial).toHaveBeenCalledTimes(1);
245
- expect(document.cookie).toBe("ailk-sign-in-method=google");
246
- });
247
-
248
- it("a failed launch from the lead button shows the provider error", async () => {
249
- const user = userEvent.setup();
250
- mockSocial.mockRejectedValueOnce(new Error("boom"));
251
- render(<SignInCard {...leadProps({ remembered: "google" })} />);
252
- await user.click(screen.getByTestId("auth-sso-google"));
253
- expect(await screen.findByTestId("sign-in-provider-error")).toBeInTheDocument();
254
- });
255
-
256
- it("with no remembered provider the card renders as today", () => {
257
- const { container: today } = render(
258
- <SignInCard {...props({ method: "password", providers: ["google"], labels: LABELS })} />,
259
- );
260
- const before = today.innerHTML;
261
- today.remove();
262
- const { container } = render(<SignInCard {...leadProps({ providers: ["google"] })} />);
263
- expect(container.innerHTML).toBe(before);
264
- expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
265
- });
266
- });
@@ -1,20 +0,0 @@
1
- /**
2
- * `?next=` sanitizer for the /sign-in page (#4984) — moved to
3
- * `lib/next-path.ts` (#7894 D7) so the hub-session callback, which a spoke
4
- * keeps when it drops this route group, shares it. Re-exported here so this
5
- * group's importers are unchanged.
6
- *
7
- * `hrefWithNext` (#9912 D4) builds the /sign-in ↔ /sign-up toggle: it carries
8
- * the page's validated `next` only when that is not the page's fallback, so a
9
- * refused or absent `next` gives today's bare link.
10
- */
11
- export { resolveNextPath } from "../../../../lib/next-path";
12
-
13
- /** `href` with `?next=<next>` when `next` is not the page's fallback, else `href`. */
14
- export function hrefWithNext(
15
- href: string,
16
- next: string,
17
- fallback: string,
18
- ): string {
19
- return next === fallback ? href : `${href}?next=${encodeURIComponent(next)}`;
20
- }
@@ -1,234 +0,0 @@
1
- /**
2
- * `/[locale]/sign-in` — the site's generic sign-in page (#4984).
3
- *
4
- * RSC: resolves the active providers from auth-env, the sign-in method
5
- * (password when the email provider is active, else sso), the sanitised
6
- * `?next=` return path, and the translated `signIn` labels — then renders the
7
- * `SignInCard` client island.
8
- *
9
- * Email sign-in link (#7435 § D9): offered when auth-env reports
10
- * "magic-link" — the predicate `auth.ts` registers the plugin on. A link that
11
- * fails verification lands back here with Better Auth's `?error=`, which maps
12
- * to FIXED copy; the raw value is never rendered.
13
- *
14
- * Hinted email (#8757 D9): a single `?email=` that `accountEmailHintSchema`
15
- * accepts is the starting value of every email input of the card (an account
16
- * link from a lead's thank-you or invite email). A refused or repeated value
17
- * is dropped. Only a field's starting value — it signs no one in.
18
- *
19
- * Since #5963 the page lives in the `(auth)` route group — the URL is
20
- * unchanged (a group contributes no path segment) but the frame is
21
- * `AuthShell`, not the marketing Nav + Footer. The shell owns the 400px
22
- * column; the card carries the site's mark (#8790 D3).
23
- *
24
- * The one card (#9662): "Sign in to <site>" (the name is the deployment's,
25
- * read in `resolveSignInCardText`, never the request's), the "Don't have an
26
- * account? Sign up" line to `/sign-up`, and the Terms + Privacy
27
- * acknowledgement. The Sign up line carries the validated `next` (#9912 D4),
28
- * so a buyer who switches to sign-up keeps the destination; a refused or
29
- * absent `next` gives the bare `/sign-up`.
30
- *
31
- * Signed-in visitors are not redirected here — the Nav's "Your account" link
32
- * is the affordance for them (#11095 D6).
33
- *
34
- * Remembered method (#11095 D7): the `ailk-sign-in-method` cookie, read here
35
- * and parsed against the active providers (`remembered-method.ts`), lets the
36
- * card lead with the provider the person last launched. A value that does
37
- * not parse is today's render.
38
- *
39
- * The spoke back link goes to the spoke's home (#11095 D5): its `/account`
40
- * would start the hub sign-in again.
41
- */
42
-
43
- import { hubSignIn } from "@working-theory/api-client";
44
- import { localeHref } from "@working-theory/ui";
45
- import { accountEmailHintSchema } from "@working-theory/validation";
46
- import type { Metadata } from "next";
47
- import { cookies } from "next/headers";
48
- import { getTranslations } from "next-intl/server";
49
- import type { ReactElement } from "react";
50
-
51
- import {
52
- getActiveProviderIds,
53
- resetSendConfigured,
54
- } from "../../../../lib/auth-env";
55
- import { siteLogo } from "../../../../lib/site-logo";
56
- import {
57
- CONTINUE_PATH,
58
- openContinuation,
59
- } from "../../../api/auth/hub/continuation";
60
- import { legalFootnote } from "../legal-footnote";
61
-
62
- import { hrefWithNext, resolveNextPath } from "./next-path";
63
- import {
64
- REMEMBERED_METHOD_COOKIE,
65
- parseRememberedMethod,
66
- } from "./remembered-method";
67
- import { SignInCard, type SignInProvider } from "./sign-in-card";
68
- import { resolveSignInCardText, type SignInCardText } from "./sign-in-text";
69
-
70
- interface Props {
71
- params: Promise<{ locale: string }>;
72
- searchParams: Promise<{
73
- next?: string | string[];
74
- error?: string | string[];
75
- email?: string | string[];
76
- }>;
77
- }
78
-
79
- /**
80
- * #8757 D9 — the hinted email, read once: a repeated `?email=` (an array) or a
81
- * value the hint schema refuses is dropped, never echoed.
82
- */
83
- function hintedEmail(raw: string | string[] | undefined): string | undefined {
84
- if (typeof raw !== "string") return undefined;
85
- const parsed = accountEmailHintSchema.safeParse(raw);
86
- return parsed.success ? parsed.data : undefined;
87
- }
88
-
89
- /**
90
- * Better Auth's magic-link verify redirects a failed link here with
91
- * `?error=<code>`. Expired / used / account-gone map to the expired copy;
92
- * anything else to the generic failure. Never the value itself.
93
- */
94
- const EXPIRED_LINK_ERRORS: ReadonlySet<string> = new Set([
95
- "INVALID_TOKEN",
96
- "new_user_signup_disabled",
97
- ]);
98
-
99
- function linkNoticeFor(
100
- error: string | string[] | undefined,
101
- text: SignInCardText,
102
- ): string | undefined {
103
- if (error === undefined) return undefined;
104
- const code = Array.isArray(error) ? error[0] : error;
105
- return code !== undefined && EXPIRED_LINK_ERRORS.has(code)
106
- ? text.emailLinkExpired
107
- : text.errorLabels.signInFailed;
108
- }
109
-
110
- /**
111
- * #11095 D7 — the raw remembered-method cookie. A read that throws (no
112
- * request scope) is no cookie, so the card renders as today.
113
- */
114
- async function rememberedCookie(): Promise<string | undefined> {
115
- try {
116
- return (await cookies()).get(REMEMBERED_METHOD_COOKIE)?.value;
117
- } catch {
118
- return undefined;
119
- }
120
- }
121
-
122
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
123
- const { locale } = await params;
124
- const t = await getTranslations({ locale, namespace: "signIn" });
125
- return { title: t("title"), description: t("description") };
126
- }
127
-
128
- /**
129
- * The spoke a hub sign-in continuation came from (#8790 D2), or `null`: not
130
- * a continuation, a continuation that does not open (expired, forged), a
131
- * client id the registry does not know, or no API. The spoke's identity is
132
- * read from the registry by `client_id` — never from a query parameter.
133
- */
134
- async function spokeFromNext(
135
- next: string,
136
- ): Promise<{ name: string; origin: string } | null> {
137
- const prefix = `${CONTINUE_PATH}/`;
138
- if (!next.startsWith(prefix)) return null;
139
- let query: string | null;
140
- try {
141
- // Lazy: `auth.ts` is Better Auth's server module. Only a continuation
142
- // needs its secret, so a direct visit — and every test of one — never
143
- // loads it (the `(authed)` gate takes the same care).
144
- const { resolveSecret } = await import("../../../../auth");
145
- query = openContinuation(next.slice(prefix.length), resolveSecret());
146
- } catch {
147
- return null;
148
- }
149
- if (query === null) return null;
150
- const clientId = new URLSearchParams(query).get("client_id");
151
- if (!clientId) return null;
152
- try {
153
- const result = await hubSignIn.clientInfo(clientId);
154
- return result.ok
155
- ? { name: result.body.name, origin: result.body.origin }
156
- : null;
157
- } catch {
158
- return null;
159
- }
160
- }
161
-
162
- export default async function SignInPage({
163
- params,
164
- searchParams,
165
- }: Props): Promise<ReactElement> {
166
- const { locale } = await params;
167
- const { next: rawNext, error, email: rawEmail } = await searchParams;
168
- const text = await resolveSignInCardText(locale);
169
-
170
- const active = getActiveProviderIds();
171
- // Exactly the OAuth providers auth-env reports — never a default set.
172
- const providers = active.filter(
173
- (id): id is SignInProvider => id === "google" || id === "github",
174
- );
175
- const method = active.includes("email") ? "password" : "sso";
176
- const emailLink = active.includes("magic-link");
177
- const fallback = localeHref(locale, "/account");
178
- const next = resolveNextPath(rawNext, fallback);
179
- // A failed link returns here, keeping the visitor's destination.
180
- const signInHref = `${localeHref(locale, "/sign-in")}?next=${encodeURIComponent(next)}`;
181
- // Only the email link produces `?error=` here; with it off, today's render.
182
- const linkNotice = emailLink ? linkNoticeFor(error, text) : undefined;
183
- const defaultEmail = hintedEmail(rawEmail);
184
- const remembered = parseRememberedMethod(await rememberedCookie(), providers);
185
-
186
- const spoke = await spokeFromNext(next);
187
- const t = await getTranslations({ locale, namespace: "signIn" });
188
- return (
189
- <SignInCard
190
- logo={siteLogo()}
191
- {...(spoke
192
- ? {
193
- backLink: {
194
- href: `${spoke.origin}/`,
195
- label: t("backTo", { site: spoke.name }),
196
- },
197
- }
198
- : {})}
199
- prospect={{
200
- ...text.prospect,
201
- href: hrefWithNext(localeHref(locale, "/sign-up"), next, fallback),
202
- }}
203
- footnote={legalFootnote(locale, text.acknowledgement)}
204
- providers={providers}
205
- method={method}
206
- next={next}
207
- // The "Forgot password?" link now has somewhere real to go (#5963);
208
- // AuthCard's default is a dead "#".
209
- forgotHref={localeHref(locale, "/forgot-password")}
210
- // Hide it entirely when reset isn't wired server-side, rather than
211
- // pointing at a page that renders its own not-available state (#6018).
212
- // `resetSendConfigured()`, not the flag: /forgot-password keys on the
213
- // send conjunction, so the flag alone would offer a link to a page
214
- // rendering its own not-available card (#6068 AC-2).
215
- forgot={resetSendConfigured() ? "link" : "none"}
216
- labels={text.labels}
217
- notConfiguredSubhead={text.notConfiguredSubhead}
218
- errorLabels={text.errorLabels}
219
- emailLink={emailLink}
220
- errorCallbackURL={signInHref}
221
- signInHref={signInHref}
222
- {...(linkNotice !== undefined ? { linkNotice } : {})}
223
- {...(defaultEmail !== undefined ? { defaultEmail } : {})}
224
- emailLinkLabels={text.emailLinkLabels}
225
- {...(remembered !== undefined
226
- ? {
227
- remembered,
228
- continueWith: text.continueWith,
229
- useAnotherWay: text.useAnotherWay,
230
- }
231
- : {})}
232
- />
233
- );
234
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * The remembered sign-in method (#11095 D7): one cookie naming the provider a
3
- * person last launched on this card, so a returning person sees that one
4
- * first. It names the method only — one of `google` or `github`, never an
5
- * email, a user id or a time — and only reorders the card: it never changes
6
- * who may sign in. An email method clears it, because the card already leads
7
- * with the email field.
8
- */
9
-
10
- import type { SignInProvider } from "./sign-in-card";
11
-
12
- export const REMEMBERED_METHOD_COOKIE = "ailk-sign-in-method";
13
-
14
- /** One year, in seconds. */
15
- const MAX_AGE_SECONDS = 31_536_000;
16
-
17
- /**
18
- * The remembered provider, only when the raw value is exactly `google` or
19
- * `github` and is one of the page's active `providers`; otherwise `undefined`.
20
- */
21
- export function parseRememberedMethod(
22
- raw: string | undefined,
23
- providers: readonly SignInProvider[],
24
- ): SignInProvider | undefined {
25
- if (raw !== "google" && raw !== "github") return undefined;
26
- return providers.includes(raw) ? raw : undefined;
27
- }
28
-
29
- /** Browser only: remember `provider`, or clear the cookie with `null`. */
30
- export function rememberMethod(provider: SignInProvider | null): void {
31
- if (typeof document === "undefined") return;
32
- const secure = window.location.protocol === "https:" ? "; Secure" : "";
33
- document.cookie =
34
- provider === null
35
- ? `${REMEMBERED_METHOD_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax${secure}`
36
- : `${REMEMBERED_METHOD_COOKIE}=${provider}; Path=/; Max-Age=${MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
37
- }