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,554 +0,0 @@
1
- /**
2
- * @file password-reset.test.tsx — AC-2's scorer (#5962).
3
- *
4
- * The three pages' branch matrix, rendered against a mocked `auth-env` — the
5
- * idiom the sibling `auth-pages.test.tsx` and `sign-in/__tests__/page.test.tsx`
6
- * already use.
7
- *
8
- * "Never a 404" is STRUCTURAL rather than asserted here: the three segments
9
- * exist as files, so Next resolves them whatever the predicate says. What this
10
- * suite asserts is that each resolves to a real card in every branch.
11
- *
12
- * The seventh case is the one a page-render assertion would miss entirely:
13
- * `forgot-password-card` must pass a NON-EMPTY, ABSOLUTE `redirectTo`. Better
14
- * Auth rejects an empty `callbackURL` on the token route, so without it every
15
- * emitted reset link dead-ends at an error page while the page itself looks
16
- * perfectly correct.
17
- */
18
- import { render, screen, waitFor } from "@testing-library/react";
19
- import userEvent from "@testing-library/user-event";
20
-
21
- const mockIsResetAvailable = jest.fn();
22
- const mockResetSendConfigured = jest.fn();
23
- const mockGetActiveProviderIds = jest.fn();
24
- const mockIsSignUpOpen = jest.fn();
25
- // eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth-env.ts is a pure env-introspection module with no external boundary to mock instead.
26
- jest.mock("../../../../lib/auth-env", () => ({
27
- __esModule: true,
28
- getActiveProviderIds: () => mockGetActiveProviderIds(),
29
- isSignUpOpen: () => mockIsSignUpOpen(),
30
- isResetAvailable: () => mockIsResetAvailable(),
31
- resetSendConfigured: () => mockResetSendConfigured(),
32
- // #11106 D9 — auth.ts asks whether to install the phone plugin.
33
- phoneVerificationConfigured: () => false,
34
- }));
35
-
36
- const mockRequestPasswordReset = jest.fn();
37
- const mockResetPassword = jest.fn();
38
- jest.mock("better-auth/react", () => ({
39
- __esModule: true,
40
- createAuthClient: () => ({
41
- requestPasswordReset: (...args: unknown[]) =>
42
- mockRequestPasswordReset(...args),
43
- resetPassword: (...args: unknown[]) => mockResetPassword(...args),
44
- signIn: { social: jest.fn(), email: jest.fn() },
45
- }),
46
- }));
47
-
48
- /**
49
- * #6068 AC-1 exercises `createAuth()`'s `onPasswordReset` callback, so the
50
- * three Better Auth entry points it touches are stubbed the way the sibling
51
- * `apps/web/__tests__/auth/password-reset-config.test.ts` stubs them — the
52
- * real ESM-only module never loads under the Jest CJS preset, and `betterAuth`
53
- * returning `{ options }` is what makes the wired callback reachable at all.
54
- */
55
- jest.mock("better-auth", () => ({
56
- betterAuth: (options: unknown) => ({ options }),
57
- }));
58
-
59
- jest.mock("better-auth/adapters/prisma", () => ({
60
- prismaAdapter: () => ({ id: "mock-prisma-adapter" }),
61
- }));
62
-
63
- jest.mock("better-auth/next-js", () => ({
64
- nextCookies: () => ({ id: "next-cookies" }),
65
- }));
66
-
67
- jest.mock("better-auth/plugins", () => ({
68
- magicLink: () => ({ id: "magic-link" }),
69
- mcp: () => ({ id: "mcp" }),
70
- }));
71
-
72
- // The MCP authorization server (#10357 D12): its ESM-only module never loads here.
73
- // eslint-disable-next-line no-restricted-syntax -- #507: lib/mcp-oauth statically imports ESM-only better-auth/api, which CommonJS Jest cannot load.
74
- jest.mock("../../../../lib/mcp-oauth", () => ({ mcpOAuthPlugin: () => ({ id: "ailk-mcp-oauth" }) }));
75
-
76
- /**
77
- * The signer seam. `buildAuthEmailRequest` has exactly one external
78
- * dependency — `node:crypto`'s `createHmac` — so a throwing `createHmac` is a
79
- * throwing `buildAuthEmailRequest` reached through the real call path, with no
80
- * stub standing in for the function under test. Every other member is the real
81
- * one, and the default implementation below is the real `createHmac`, so only
82
- * the case that opts in sees a failure.
83
- */
84
- const mockCreateHmac = jest.fn();
85
- jest.mock("node:crypto", () => {
86
- const actual = jest.requireActual("node:crypto");
87
- return {
88
- ...actual,
89
- createHmac: (...args: unknown[]) => mockCreateHmac(...args),
90
- };
91
- });
92
-
93
- /**
94
- * #10820 D7 — the confirm page's server action. Rendering `?verify=` must
95
- * spend nothing: the action is the only path to the confirm hop, so a GET that
96
- * called it is the mail-scanner hole this page exists to close.
97
- */
98
- const mockConfirmEmailAction = jest.fn();
99
- // eslint-disable-next-line no-restricted-syntax -- the "use server" action is the page's network boundary (it reaches apps/api over HTTP); its own suite, verify-email/__tests__/actions.test.ts, exercises it.
100
- jest.mock("../verify-email/actions", () => ({
101
- confirmEmailAction: (...args: unknown[]) => mockConfirmEmailAction(...args),
102
- }));
103
-
104
- import en from "../../../../messages/en.json";
105
- import { createAuth } from "../../../../auth";
106
- import ForgotPasswordPage from "../forgot-password/page";
107
- import ResetPasswordPage from "../reset-password/page";
108
- import { ResetPasswordCard } from "../reset-password/reset-password-card";
109
- import SignInPage from "../sign-in/page";
110
- import VerifyEmailPage from "../verify-email/page";
111
-
112
- const ORIGINAL_ENV = process.env;
113
-
114
- /** The slice of Better Auth's options object #6068 AC-1 reads. */
115
- type AuthOptionsUnderTest = {
116
- emailAndPassword?: {
117
- onPasswordReset?: (args: {
118
- user: { id: string; email: string };
119
- }) => Promise<void>;
120
- };
121
- };
122
-
123
- /**
124
- * `NonNullable` on BOTH levels, exactly as the sibling config suite does it:
125
- * the inner one strips the `| undefined` off the optional `prisma` member,
126
- * without which `exactOptionalPropertyTypes: true` rejects the assignment.
127
- */
128
- type AuthPrisma = NonNullable<
129
- NonNullable<Parameters<typeof createAuth>[0]>["prisma"]
130
- >;
131
-
132
- async function renderForgot(): Promise<void> {
133
- render(await ForgotPasswordPage({ params: Promise.resolve({ locale: "en" }) }));
134
- }
135
-
136
- async function renderReset(
137
- query: Record<string, string> = {},
138
- ): Promise<void> {
139
- render(
140
- await ResetPasswordPage({
141
- params: Promise.resolve({ locale: "en" }),
142
- searchParams: Promise.resolve(query),
143
- }),
144
- );
145
- }
146
-
147
- async function renderVerify(
148
- query: Record<string, string> = {},
149
- ): Promise<void> {
150
- render(
151
- await VerifyEmailPage({
152
- params: Promise.resolve({ locale: "en" }),
153
- searchParams: Promise.resolve(query),
154
- }),
155
- );
156
- }
157
-
158
- beforeEach(() => {
159
- process.env = { ...ORIGINAL_ENV, BETTER_AUTH_URL: "https://site.example" };
160
- jest.clearAllMocks();
161
- mockIsResetAvailable.mockReturnValue(true);
162
- mockResetSendConfigured.mockReturnValue(true);
163
- mockGetActiveProviderIds.mockReturnValue(["email"]);
164
- mockIsSignUpOpen.mockReturnValue(false);
165
- mockRequestPasswordReset.mockResolvedValue({ data: {}, error: null });
166
- mockResetPassword.mockResolvedValue({ data: {}, error: null });
167
- // The real signer by default — only the #6068 case below makes it throw.
168
- mockCreateHmac.mockImplementation((...args: unknown[]) =>
169
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- forwarding an untyped rest to the real overloaded builtin
170
- (jest.requireActual("node:crypto") as any).createHmac(...args),
171
- );
172
- });
173
-
174
- afterAll(() => {
175
- process.env = ORIGINAL_ENV;
176
- });
177
-
178
- // ── The six states AC-2 names ───────────────────────────────────────────────
179
-
180
- describe("/forgot-password", () => {
181
- it("renders the forgot form when reset is available", async () => {
182
- await renderForgot();
183
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
184
- });
185
-
186
- it("renders the not-available state — never a 404 — when it is not", async () => {
187
- mockResetSendConfigured.mockReturnValue(false);
188
- await renderForgot();
189
- expect(screen.getByTestId("forgot-password-page")).toBeInTheDocument();
190
- expect(screen.getByTestId("auth-invitation-body")).toHaveTextContent(
191
- en.auth.forgotUnavailableBody,
192
- );
193
- expect(screen.queryByTestId("auth-email")).not.toBeInTheDocument();
194
- });
195
- });
196
-
197
- describe("/reset-password", () => {
198
- it("renders the password fields when it carries a token", async () => {
199
- await renderReset({ token: "tok_live" });
200
- expect(screen.getByTestId("auth-password")).toBeInTheDocument();
201
- expect(screen.getByTestId("auth-confirm-password")).toBeInTheDocument();
202
- });
203
-
204
- it("renders the expired-token state — and NO password field — on ?error", async () => {
205
- await renderReset({ error: "INVALID_TOKEN" });
206
- expect(screen.getByTestId("reset-token-error")).toBeInTheDocument();
207
- expect(
208
- screen.getByRole("heading", { name: en.auth.resetExpiredHeading }),
209
- ).toBeInTheDocument();
210
- expect(screen.queryByTestId("auth-password")).not.toBeInTheDocument();
211
- });
212
-
213
- it("renders its own not-available copy when reset is off", async () => {
214
- mockResetSendConfigured.mockReturnValue(false);
215
- await renderReset({ token: "tok_live" });
216
- expect(screen.getByTestId("auth-invitation-body")).toHaveTextContent(
217
- en.auth.resetUnavailableBody,
218
- );
219
- expect(screen.queryByTestId("auth-password")).not.toBeInTheDocument();
220
- });
221
- });
222
-
223
- describe("/verify-email", () => {
224
- it("renders the sent terminus with no ?error", async () => {
225
- await renderVerify();
226
- expect(screen.getByTestId("auth-sent-body")).toBeInTheDocument();
227
- });
228
-
229
- it("renders the expired-token state on ?error", async () => {
230
- await renderVerify({ error: "TOKEN_EXPIRED" });
231
- expect(screen.getByTestId("verify-token-error")).toBeInTheDocument();
232
- expect(screen.queryByTestId("auth-sent-body")).not.toBeInTheDocument();
233
- });
234
-
235
- it("renders a confirm button on ?verify= and spends nothing while rendering (#10820)", async () => {
236
- await renderVerify({ verify: "N".repeat(43) });
237
- expect(screen.getByTestId("verify-email-confirm")).toBeInTheDocument();
238
- expect(screen.getByTestId("verify-email-confirm-button")).toHaveTextContent(
239
- en.auth.confirmButton,
240
- );
241
- expect(mockConfirmEmailAction).not.toHaveBeenCalled();
242
- expect(document.body.innerHTML).not.toContain("N".repeat(43));
243
- });
244
-
245
- it("renders the verified card on ?confirmed=1 (#10820)", async () => {
246
- await renderVerify({ confirmed: "1" });
247
- expect(screen.getByTestId("verify-email-confirmed")).toHaveTextContent(
248
- en.auth.verifiedHeading,
249
- );
250
- });
251
- });
252
-
253
- // ── The flag-alone configuration: intent set, send impossible ──────────────
254
-
255
- describe("the flag alone does not open either page", () => {
256
- /**
257
- * `AILK_AUTH_PASSWORD_RESET=1` with a send conjunct missing is a real
258
- * deployment state, and it is the one a flag-only predicate reads as
259
- * "available". On the request page that renders a live form whose only
260
- * possible outcome is the error card; on the consume page it renders a live
261
- * password field over a POST Better Auth still serves. Both pages key on
262
- * `resetSendConfigured()` so neither can be reached in that state.
263
- */
264
- beforeEach(() => {
265
- mockIsResetAvailable.mockReturnValue(true);
266
- mockResetSendConfigured.mockReturnValue(false);
267
- });
268
-
269
- it("/forgot-password renders not-available, not the form", async () => {
270
- await renderForgot();
271
- expect(screen.getByTestId("auth-invitation-body")).toHaveTextContent(
272
- en.auth.forgotUnavailableBody,
273
- );
274
- expect(screen.queryByTestId("auth-email")).not.toBeInTheDocument();
275
- });
276
-
277
- it("/reset-password renders not-available even carrying a live token", async () => {
278
- await renderReset({ token: "tok_live" });
279
- expect(screen.getByTestId("auth-invitation-body")).toHaveTextContent(
280
- en.auth.resetUnavailableBody,
281
- );
282
- expect(screen.queryByTestId("auth-password")).not.toBeInTheDocument();
283
- });
284
- });
285
-
286
- // ── The seventh case: the redirectTo a render assertion cannot see ──────────
287
-
288
- describe("the forgot island's requestPasswordReset call", () => {
289
- it("passes a non-empty, ABSOLUTE, same-origin redirectTo", async () => {
290
- const user = userEvent.setup();
291
- await renderForgot();
292
-
293
- await user.type(screen.getByTestId("auth-email"), "person@example.com");
294
- await user.click(screen.getByTestId("auth-submit"));
295
-
296
- await waitFor(() => expect(mockRequestPasswordReset).toHaveBeenCalled());
297
- const [args] = mockRequestPasswordReset.mock.calls[0];
298
- expect(args.email).toBe("person@example.com");
299
- expect(args.redirectTo).toBe("https://site.example/reset-password");
300
- // Absolute: originCheck compares an ORIGIN, and an empty callbackURL makes
301
- // Better Auth reject the emitted link outright.
302
- expect(args.redirectTo.startsWith("https://")).toBe(true);
303
- });
304
-
305
- it("swaps to the sent intent only on success", async () => {
306
- const user = userEvent.setup();
307
- await renderForgot();
308
-
309
- await user.type(screen.getByTestId("auth-email"), "person@example.com");
310
- await user.click(screen.getByTestId("auth-submit"));
311
-
312
- await waitFor(() =>
313
- expect(screen.getByTestId("auth-sent-body")).toBeInTheDocument(),
314
- );
315
- });
316
-
317
- it("shows the error state — never 'check your email' — when the server refuses", async () => {
318
- mockRequestPasswordReset.mockResolvedValue({
319
- error: { code: "RESET_PASSWORD_DISABLED" },
320
- });
321
- const user = userEvent.setup();
322
- await renderForgot();
323
-
324
- await user.type(screen.getByTestId("auth-email"), "person@example.com");
325
- await user.click(screen.getByTestId("auth-submit"));
326
-
327
- await waitFor(() =>
328
- expect(screen.getByText(en.auth.resetRequestFailed)).toBeInTheDocument(),
329
- );
330
- // The whole point: a site that cannot send never claims it did.
331
- expect(screen.queryByTestId("auth-sent-body")).not.toBeInTheDocument();
332
- });
333
- });
334
-
335
- describe("the reset island's resetPassword call", () => {
336
- it("sends the token in the body and routes to sign-in on success", async () => {
337
- // The island directly, so the post-reset navigation is observable —
338
- // jsdom's `window.location` is read-only, which is why the component takes
339
- // an injectable `navigate` at all.
340
- const navigate = jest.fn();
341
- const user = userEvent.setup();
342
- render(
343
- <ResetPasswordCard
344
- token="tok_live"
345
- signInHref="/sign-in"
346
- labels={{
347
- resetHeading: en.auth.resetHeading,
348
- resetSubmit: en.auth.resetSubmit,
349
- newPassword: en.auth.newPassword,
350
- confirmPassword: en.auth.confirmPassword,
351
- backToSignIn: en.auth.backToSignIn,
352
- }}
353
- errorLabels={{
354
- resetFailed: en.auth.resetFailed,
355
- invalidToken: en.auth.resetExpiredSubhead,
356
- mismatch: en.auth.passwordMismatch,
357
- }}
358
- navigate={navigate}
359
- />,
360
- );
361
-
362
- await user.type(screen.getByTestId("auth-password"), "a-long-enough-pw");
363
- await user.type(
364
- screen.getByTestId("auth-confirm-password"),
365
- "a-long-enough-pw",
366
- );
367
- await user.click(screen.getByTestId("auth-submit"));
368
-
369
- await waitFor(() => expect(mockResetPassword).toHaveBeenCalled());
370
- expect(mockResetPassword.mock.calls[0][0]).toEqual({
371
- newPassword: "a-long-enough-pw",
372
- token: "tok_live",
373
- });
374
- await waitFor(() => expect(navigate).toHaveBeenCalledWith("/sign-in"));
375
- });
376
-
377
- it("refuses mismatched passwords without calling the server", async () => {
378
- const user = userEvent.setup();
379
- await renderReset({ token: "tok_live" });
380
-
381
- await user.type(screen.getByTestId("auth-password"), "a-long-enough-pw");
382
- await user.type(screen.getByTestId("auth-confirm-password"), "different-pw");
383
- await user.click(screen.getByTestId("auth-submit"));
384
-
385
- await waitFor(() =>
386
- expect(screen.getByText(en.auth.passwordMismatch)).toBeInTheDocument(),
387
- );
388
- expect(mockResetPassword).not.toHaveBeenCalled();
389
- });
390
-
391
- it("treats an absent token as an expired one, and does not call the server", async () => {
392
- const user = userEvent.setup();
393
- await renderReset({});
394
-
395
- await user.type(screen.getByTestId("auth-password"), "a-long-enough-pw");
396
- await user.type(
397
- screen.getByTestId("auth-confirm-password"),
398
- "a-long-enough-pw",
399
- );
400
- await user.click(screen.getByTestId("auth-submit"));
401
-
402
- await waitFor(() =>
403
- expect(
404
- screen.getByText(en.auth.resetExpiredSubhead),
405
- ).toBeInTheDocument(),
406
- );
407
- expect(mockResetPassword).not.toHaveBeenCalled();
408
- });
409
- });
410
-
411
- // ── #6068 AC-1: a throwing signer cannot reject onPasswordReset ─────────────
412
-
413
- /**
414
- * The reset has ALREADY SUCCEEDED by the time `onPasswordReset` runs: the new
415
- * password is written and the presented token is consumed. A rejection here is
416
- * therefore not "the reset failed" — it is a 500 handed to a visitor whose
417
- * password DID change, over a token they can no longer retry with.
418
- *
419
- * `sendPasswordChangedNotice` carries a "never throws by construction"
420
- * invariant, and before #6068 that invariant had a hole: `dispatch()` built
421
- * and SIGNED the request OUTSIDE its own try, so anything `buildAuthEmailRequest`
422
- * threw propagated all the way out. #6061 made this callback unconditional, so
423
- * it now runs in degraded configurations — exactly where a signer is most
424
- * likely to be unhappy.
425
- *
426
- * The signer's one external dependency is `node:crypto`'s `createHmac`, so a
427
- * throwing `createHmac` IS a throwing `buildAuthEmailRequest`, reached through
428
- * the real call path rather than a stubbed-out seam.
429
- */
430
- describe("onPasswordReset survives a throwing buildAuthEmailRequest (#6068)", () => {
431
- const user = { id: "usr_reset", email: "person@example.com" };
432
-
433
- function onPasswordResetUnderTest(deleteMany: jest.Mock): (args: {
434
- user: { id: string; email: string };
435
- }) => Promise<void> {
436
- // `unknown` on the way in, exactly as the sibling config suite does it, so
437
- // the stub needs ONE assertion rather than a double one.
438
- const prismaStub: unknown = { verification: { deleteMany } };
439
- const auth = createAuth({ prisma: prismaStub as AuthPrisma });
440
- // The `betterAuth` mock above returns `{ options }` rather than a real
441
- // instance, so the declared return type is not the runtime shape. There is
442
- // no boundary type to fix: the double assertion IS the mock seam — the
443
- // same seam, and the same justification, as the sibling config suite.
444
- // eslint-disable-next-line no-restricted-syntax -- see above.
445
- const { options } = auth as unknown as { options: AuthOptionsUnderTest };
446
- const callback = options.emailAndPassword?.onPasswordReset;
447
- // Guarded rather than asserted inline: without it the cases below would
448
- // read `undefined(...)` and fail with a TypeError instead of a diagnosis.
449
- if (!callback) throw new Error("onPasswordReset was not wired");
450
- return callback;
451
- }
452
-
453
- beforeEach(() => {
454
- // Past `dispatch()`'s `not_configured` early return — without a secret the
455
- // signer is never reached and the case would pass vacuously.
456
- process.env.AUTH_EMAIL_WEBHOOK_SECRET = "whsec_test";
457
- process.env.AUTH_EMAIL_FROM = "noreply@site.example";
458
- mockCreateHmac.mockImplementation(() => {
459
- throw new Error("signer unavailable");
460
- });
461
- });
462
-
463
- it("resolves rather than rejecting — the completed reset is not turned into a 500", async () => {
464
- const deleteMany = jest.fn().mockResolvedValue({ count: 1 });
465
- await expect(
466
- onPasswordResetUnderTest(deleteMany)({ user }),
467
- ).resolves.toBeUndefined();
468
- });
469
-
470
- it("still consumes the user's other outstanding reset tokens", async () => {
471
- const deleteMany = jest.fn().mockResolvedValue({ count: 2 });
472
- await onPasswordResetUnderTest(deleteMany)({ user });
473
- // The sibling invalidation runs BEFORE the notice, so a notice that threw
474
- // would leave it done-but-unreported; what it may never do is leave the
475
- // caller with a rejected promise over work that already landed.
476
- expect(deleteMany).toHaveBeenCalledWith({
477
- where: {
478
- value: user.id,
479
- identifier: { startsWith: "reset-password:" },
480
- },
481
- });
482
- });
483
- });
484
-
485
- // ── #6068 AC-2: the flag-alone config, read through the REAL predicate ──────
486
-
487
- /**
488
- * The sibling "the flag alone does not open either page" block above drives
489
- * the two reset pages through the MOCKED predicate — it asserts the pages
490
- * branch correctly once `resetSendConfigured()` has already answered false.
491
- * This block asserts the answer itself, and the third affordance: with
492
- * `AILK_AUTH_PASSWORD_RESET=1` and `AUTH_EMAIL_WEBHOOK_SECRET` unset — intent
493
- * set, transport missing, every other conjunct satisfied — the REAL
494
- * `resetSendConfigured()` is what decides, and `/sign-in` must render no
495
- * "Forgot password?" link while `/forgot-password` renders its not-available
496
- * card. A flag-keyed link in this state is the dangling link #6018 shipped to
497
- * prevent and #6061 left behind on this one surface.
498
- *
499
- * The module mock stays (the two pages share it with the whole file); its
500
- * members are re-bound here to `jest.requireActual`'s real implementations, so
501
- * the env vars below — not a `mockReturnValue` — are what the pages read.
502
- */
503
- describe("the flag alone hides the /sign-in forgot link (#6068 AC-2)", () => {
504
- const realAuthEnv = jest.requireActual<
505
- typeof import("../../../../lib/auth-env")
506
- >("../../../../lib/auth-env");
507
-
508
- beforeEach(() => {
509
- mockIsResetAvailable.mockImplementation(() => realAuthEnv.isResetAvailable());
510
- mockResetSendConfigured.mockImplementation(() =>
511
- realAuthEnv.resetSendConfigured(),
512
- );
513
- mockGetActiveProviderIds.mockImplementation(() =>
514
- realAuthEnv.getActiveProviderIds(),
515
- );
516
-
517
- // Every conjunct of `resetSendConfigured()` satisfied EXCEPT the send
518
- // secret: the operator meant to offer reset and the relay cannot sign.
519
- process.env.AILK_AUTH_PASSWORD_RESET = "1";
520
- process.env.AUTH_EMAIL_SERVER = "smtp://mail.example";
521
- process.env.AUTH_EMAIL_FROM = "noreply@site.example";
522
- process.env.BETTER_AUTH_URL = "https://site.example";
523
- process.env.BETTER_AUTH_SECRET = "test-secret";
524
- delete process.env.AUTH_EMAIL_WEBHOOK_SECRET;
525
- });
526
-
527
- it("is a state the two predicates genuinely disagree about", () => {
528
- // Without this the two cases below could pass for the wrong reason — a
529
- // config neither predicate calls available proves nothing about which one
530
- // an affordance keys on.
531
- expect(realAuthEnv.isResetAvailable()).toBe(true);
532
- expect(realAuthEnv.resetSendConfigured()).toBe(false);
533
- });
534
-
535
- it("/sign-in renders the password form and NO forgot link", async () => {
536
- render(
537
- await SignInPage({
538
- params: Promise.resolve({ locale: "en" }),
539
- searchParams: Promise.resolve({}),
540
- }),
541
- );
542
- // The card itself is live — this is a hidden affordance, not a dead page.
543
- expect(screen.getByTestId("auth-password")).toBeInTheDocument();
544
- expect(screen.queryByTestId("auth-forgot")).toBeNull();
545
- });
546
-
547
- it("/forgot-password renders the not-available card", async () => {
548
- await renderForgot();
549
- expect(screen.getByTestId("auth-invitation-body")).toHaveTextContent(
550
- en.auth.forgotUnavailableBody,
551
- );
552
- expect(screen.queryByTestId("auth-email")).not.toBeInTheDocument();
553
- });
554
- });
@@ -1,56 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- *
4
- * `decideConsent` — the consent page's Allow and Deny (#10357 D6). `auth` is
5
- * mocked; `POST /mcp/consent` runs for real in
6
- * `__tests__/auth/mcp-oauth-flow.test.ts`. This suite proves the fallback
7
- * redirect is always a path on this site.
8
- */
9
- const mockConsent = jest.fn();
10
- const mockRedirect = jest.fn();
11
-
12
- // eslint-disable-next-line no-restricted-syntax -- #507: auth.ts loads ESM-only better-auth; its consent endpoint runs for real in mcp-oauth-flow.test.ts.
13
- jest.mock("../../../../../auth", () => ({
14
- auth: { api: { mcpConsent: (...args: unknown[]) => mockConsent(...args) } },
15
- }));
16
-
17
- jest.mock("next/headers", () => ({ headers: jest.fn().mockResolvedValue(new Headers()) }));
18
-
19
- jest.mock("next/navigation", () => ({ redirect: (...args: unknown[]) => mockRedirect(...args) }));
20
-
21
- import { decideConsent } from "../consent.actions";
22
-
23
- function form(values: Record<string, string>): FormData {
24
- const data = new FormData();
25
- for (const [key, value] of Object.entries(values)) data.append(key, value);
26
- return data;
27
- }
28
-
29
- beforeEach(() => {
30
- mockConsent.mockReset();
31
- mockRedirect.mockReset();
32
- });
33
-
34
- it("goes to the client's callback when the consent endpoint answers one", async () => {
35
- mockConsent.mockResolvedValue({ redirectURI: "http://127.0.0.1:53682/callback?code=c" });
36
- await decideConsent(form({ consent_code: "abc", locale: "en", decision: "deny" }));
37
- expect(mockRedirect).toHaveBeenCalledWith("http://127.0.0.1:53682/callback?code=c");
38
- });
39
-
40
- it("returns to this site's consent page on a refusal", async () => {
41
- mockConsent.mockRejectedValue(new Error("refused"));
42
- await decideConsent(form({ consent_code: "abc", locale: "en", decision: "allow" }));
43
- expect(mockRedirect).toHaveBeenCalledWith(expect.stringMatching(/^\/(en\/)?consent\?consent_code=abc$/));
44
- });
45
-
46
- it.each(["/evil.example", "//evil.example", "en/../..", "https://evil.example"])(
47
- "never builds the fallback from a posted locale of %s",
48
- async (locale) => {
49
- mockConsent.mockRejectedValue(new Error("refused"));
50
- await decideConsent(form({ consent_code: "abc", locale, decision: "allow" }));
51
- const target = String(mockRedirect.mock.calls[0]?.[0]);
52
- expect(target.startsWith("//")).toBe(false);
53
- expect(target).not.toContain("evil.example");
54
- expect(target).toMatch(/^\/(en\/)?consent\?consent_code=abc$/);
55
- },
56
- );