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,164 +0,0 @@
1
- /**
2
- * The MCP consent page (#10357 D6, AC-6). `auth` is mocked — the endpoints it
3
- * calls run for real in `__tests__/auth/mcp-oauth-flow.test.ts`; this suite
4
- * proves what the page renders from their answer and what it never reads.
5
- *
6
- * `next-intl/server` is mocked globally (apps/web/__tests__/setup.ts) against
7
- * the real en.json.
8
- */
9
- import { fireEvent, render, screen } from "@testing-library/react";
10
-
11
- const mockGetSession = jest.fn();
12
- const mockDetails = jest.fn();
13
-
14
- // eslint-disable-next-line no-restricted-syntax -- #507: auth.ts loads ESM-only better-auth; its consent endpoints run for real in mcp-oauth-flow.test.ts.
15
- jest.mock("../../../../../auth", () => ({
16
- auth: {
17
- api: {
18
- getSession: (...args: unknown[]) => mockGetSession(...args),
19
- mcpConsentDetails: (...args: unknown[]) => mockDetails(...args),
20
- },
21
- },
22
- }));
23
-
24
- // eslint-disable-next-line no-restricted-syntax -- #507: the server action imports auth.ts (ESM-only better-auth).
25
- jest.mock("../consent.actions", () => ({ decideConsent: jest.fn() }));
26
-
27
- jest.mock("next/headers", () => ({
28
- headers: jest.fn().mockResolvedValue(new Headers({ cookie: "session=1" })),
29
- }));
30
-
31
- jest.mock("better-auth/react", () => ({
32
- __esModule: true,
33
- createAuthClient: () => ({ signOut: jest.fn() }),
34
- }));
35
-
36
- // The shared mock neither interpolates nor reads nested keys; this page shows
37
- // the email, the client name and the scope labels, so this suite's mock does.
38
- jest.mock("next-intl/server", () => {
39
- const catalog = jest.requireActual("../../../../../messages/en.json") as Record<string, unknown>;
40
- return {
41
- getTranslations: async ({ namespace }: { namespace: string }) =>
42
- (key: string, values: Record<string, string> = {}) => {
43
- const found = `${namespace}.${key}`
44
- .split(".")
45
- .reduce<unknown>((node, part) => (node as Record<string, unknown> | undefined)?.[part], catalog);
46
- return String(found ?? `${namespace}.${key}`).replace(/\{(\w+)\}/g, (_, name: string) => values[name] ?? "");
47
- },
48
- };
49
- });
50
-
51
- jest.mock("next/navigation", () => ({
52
- useRouter: () => ({ push: jest.fn(), refresh: jest.fn() }),
53
- redirect: jest.fn(),
54
- }));
55
-
56
- import en from "../../../../../messages/en.json";
57
- import ConsentPage, { generateMetadata } from "../page";
58
-
59
- const params = Promise.resolve({ locale: "en" });
60
- const MEMBER_SCOPES = ["ailk:people-read", "ailk:member-pieces-manage", "ailk:people-memory-propose", "ailk:inbox-act"];
61
- const t = en.mcpConsent;
62
-
63
- const twoWorkspaces = {
64
- client: { name: "Some App", redirectOrigin: "http://127.0.0.1:53682" },
65
- workspaces: [
66
- { id: "wksp_a", name: "Alpha", organizationName: "Alpha Co", role: "member", offered: MEMBER_SCOPES },
67
- { id: "wksp_b", name: "Beta", organizationName: "Beta Co", role: "member", offered: MEMBER_SCOPES },
68
- ],
69
- };
70
-
71
- async function renderPage(query: Record<string, string> = { consent_code: "code-1" }) {
72
- render(await ConsentPage({ params, searchParams: Promise.resolve(query) }));
73
- }
74
-
75
- beforeEach(() => {
76
- mockGetSession.mockResolvedValue({ user: { email: "person@example.test" } });
77
- mockDetails.mockResolvedValue(twoWorkspaces);
78
- });
79
-
80
- describe("the consent page (#10357 AC-6)", () => {
81
- it("names the signed-in person, the client's own claim and where the code goes", async () => {
82
- await renderPage();
83
- expect(screen.getByTestId("mcp-consent-signed-in")).toHaveTextContent("person@example.test");
84
- expect(screen.getByTestId("mcp-consent-client")).toHaveTextContent(
85
- t.clientClaim.replace("{name}", "Some App"),
86
- );
87
- expect(screen.getByTestId("mcp-consent-redirect-origin")).toHaveTextContent("http://127.0.0.1:53682");
88
- expect(screen.getByTestId("mcp-consent-sign-out")).toBeInTheDocument();
89
- });
90
-
91
- it("renders one radio per workspace, none checked when there are two, and Allow disabled", async () => {
92
- await renderPage();
93
- for (const id of ["wksp_a", "wksp_b"]) {
94
- expect(screen.getByTestId(`mcp-consent-workspace-${id}`)).toHaveAttribute("aria-checked", "false");
95
- }
96
- expect(screen.getByTestId("mcp-consent-allow")).toBeDisabled();
97
- expect(screen.queryByTestId("mcp-consent-scope-people-read")).toBeNull();
98
- });
99
-
100
- it("on choosing a workspace shows its offered scopes unticked, the member-reads line, and enables Allow", async () => {
101
- await renderPage();
102
- fireEvent.click(screen.getByTestId("mcp-consent-workspace-wksp_b"));
103
- for (const scope of MEMBER_SCOPES) {
104
- const permission = scope.slice("ailk:".length);
105
- expect(screen.getByTestId(`mcp-consent-scope-${permission}`)).toHaveAttribute("aria-checked", "false");
106
- }
107
- expect(screen.queryByTestId("mcp-consent-scope-content-edit")).toBeNull();
108
- expect(screen.getByText(t.scopes["people-read"])).toBeInTheDocument();
109
- expect(screen.getByTestId("mcp-consent-member-reads")).toHaveTextContent(t.memberReads);
110
- expect(screen.getByTestId("mcp-consent-allow")).not.toBeDisabled();
111
- });
112
-
113
- it("pre-selects the only workspace", async () => {
114
- mockDetails.mockResolvedValue({ ...twoWorkspaces, workspaces: [twoWorkspaces.workspaces[0]] });
115
- await renderPage();
116
- expect(screen.getByTestId("mcp-consent-workspace-wksp_a")).toHaveAttribute("aria-checked", "true");
117
- expect(screen.getByTestId("mcp-consent-allow")).not.toBeDisabled();
118
- });
119
-
120
- it("reads only consent_code from its query — never a client-controlled scope or client_id", async () => {
121
- await renderPage({ consent_code: "code-1", scope: "ailk:content-edit", client_id: "evil" });
122
- expect(mockDetails).toHaveBeenCalledWith(
123
- expect.objectContaining({ query: { consent_code: "code-1" } }),
124
- );
125
- fireEvent.click(screen.getByTestId("mcp-consent-workspace-wksp_a"));
126
- expect(screen.queryByTestId("mcp-consent-scope-content-edit")).toBeNull();
127
- expect(document.body.textContent).not.toContain(t.scopes["content-edit"]);
128
- expect(document.body.textContent).not.toContain("evil");
129
- });
130
-
131
- it("has Allow and Deny as 44 px buttons in one form", async () => {
132
- await renderPage();
133
- expect(screen.getByTestId("mcp-consent-form")).toContainElement(screen.getByTestId("mcp-consent-deny"));
134
- expect(screen.getByTestId("mcp-consent-deny").className).toContain("control-height-big");
135
- });
136
-
137
- it("renders the unavailable line and no form when details are refused", async () => {
138
- mockDetails.mockRejectedValue(new Error("invalid_request"));
139
- await renderPage();
140
- expect(screen.getByTestId("mcp-consent-unavailable")).toHaveTextContent(t.unavailable);
141
- expect(screen.queryByTestId("mcp-consent-form")).toBeNull();
142
- });
143
-
144
- it("renders the unavailable line with no session, and without a consent_code", async () => {
145
- mockGetSession.mockResolvedValue(null);
146
- await renderPage();
147
- expect(screen.getByTestId("mcp-consent-unavailable")).toBeInTheDocument();
148
- mockGetSession.mockResolvedValue({ user: { email: "person@example.test" } });
149
- });
150
-
151
- it("offers Deny only when the person has no workspace", async () => {
152
- mockDetails.mockResolvedValue({ ...twoWorkspaces, workspaces: [] });
153
- await renderPage();
154
- expect(screen.getByTestId("mcp-consent-no-workspace")).toHaveTextContent(t.noWorkspace);
155
- expect(screen.queryByTestId("mcp-consent-allow")).toBeNull();
156
- expect(screen.getByTestId("mcp-consent-deny")).toBeInTheDocument();
157
- });
158
-
159
- it("is noindex and sends no cross-site referrer", async () => {
160
- const metadata = await generateMetadata({ params, searchParams: Promise.resolve({}) });
161
- expect(metadata.robots).toEqual({ index: false, follow: false });
162
- expect(metadata.referrer).toBe("same-origin");
163
- });
164
- });
@@ -1,132 +0,0 @@
1
- "use client"; // the workspace choice decides which scopes show and whether Allow is enabled
2
-
3
- /**
4
- * The consent page's client island (#10357 D6): the workspace radio list, the
5
- * chosen workspace's offered scopes as checkboxes — none ticked — and Allow,
6
- * disabled until a workspace is chosen. Deliberate selection is the defence
7
- * against a phished authorization (SEC-10357-11, -13). Strings arrive
8
- * translated from the server page.
9
- */
10
- import {
11
- Button,
12
- Checkbox,
13
- Input,
14
- Label,
15
- RadioGroup,
16
- RadioGroupItem,
17
- Text,
18
- } from "@working-theory/ui/primitives";
19
- import type { ReactElement } from "react";
20
- import { useState } from "react";
21
-
22
- import { decideConsent } from "./consent.actions";
23
-
24
- export interface ConsentWorkspace {
25
- id: string;
26
- name: string;
27
- organizationName: string;
28
- /** Each offered scope with its label. */
29
- offered: Array<{ scope: string; permission: string; label: string }>;
30
- }
31
-
32
- export interface ConsentFormText {
33
- workspaceLegend: string;
34
- scopesLegend: string;
35
- memberReads: string;
36
- noScopes: string;
37
- allow: string;
38
- deny: string;
39
- }
40
-
41
- export interface ConsentFormProps {
42
- consentCode: string;
43
- locale: string;
44
- workspaces: ConsentWorkspace[];
45
- text: ConsentFormText;
46
- }
47
-
48
- export function ConsentForm({ consentCode, locale, workspaces, text }: ConsentFormProps): ReactElement {
49
- const [workspaceId, setWorkspaceId] = useState<string>(
50
- workspaces.length === 1 ? (workspaces[0]?.id ?? "") : "",
51
- );
52
- const chosen = workspaces.find((w) => w.id === workspaceId);
53
-
54
- return (
55
- <form action={decideConsent} className="flex flex-col gap-6" data-testid="mcp-consent-form">
56
- <Input type="hidden" name="consent_code" value={consentCode} />
57
- <Input type="hidden" name="locale" value={locale} />
58
- {workspaces.length > 0 ? (
59
- <div className="flex flex-col gap-3">
60
- <Text as="p" variant="body-sm" className="font-semibold">
61
- {text.workspaceLegend}
62
- </Text>
63
- <RadioGroup
64
- name="workspace_id"
65
- value={workspaceId}
66
- onValueChange={setWorkspaceId}
67
- aria-label={text.workspaceLegend}
68
- >
69
- {workspaces.map((w) => (
70
- <div key={w.id} className="flex min-h-11 items-center gap-3">
71
- <RadioGroupItem
72
- id={`mcp-consent-ws-${w.id}`}
73
- value={w.id}
74
- data-testid={`mcp-consent-workspace-${w.id}`}
75
- />
76
- <Label htmlFor={`mcp-consent-ws-${w.id}`}>
77
- {/* i18n-allow: a separator between two data values */}
78
- {w.name} · {w.organizationName}
79
- </Label>
80
- </div>
81
- ))}
82
- </RadioGroup>
83
- </div>
84
- ) : null}
85
- {chosen ? (
86
- <div className="flex flex-col gap-3">
87
- <Text as="p" variant="body-sm" className="font-semibold">
88
- {text.scopesLegend}
89
- </Text>
90
- {chosen.offered.length === 0 ? (
91
- <Text as="p" variant="body-sm" tone="muted">
92
- {text.noScopes}
93
- </Text>
94
- ) : (
95
- chosen.offered.map((o) => (
96
- <div key={o.scope} className="flex min-h-11 items-center gap-3">
97
- <Checkbox
98
- id={`mcp-consent-scope-${o.permission}`}
99
- name="scopes"
100
- value={o.scope}
101
- defaultChecked={false}
102
- data-testid={`mcp-consent-scope-${o.permission}`}
103
- />
104
- <Label htmlFor={`mcp-consent-scope-${o.permission}`}>{o.label}</Label>
105
- </div>
106
- ))
107
- )}
108
- <Text as="p" variant="body-sm" tone="muted" data-testid="mcp-consent-member-reads">
109
- {text.memberReads}
110
- </Text>
111
- </div>
112
- ) : null}
113
- <div className="flex flex-wrap gap-3">
114
- {workspaces.length > 0 ? (
115
- <Button
116
- type="submit"
117
- name="decision"
118
- value="allow"
119
- size="big"
120
- disabled={!chosen}
121
- data-testid="mcp-consent-allow"
122
- >
123
- {text.allow}
124
- </Button>
125
- ) : null}
126
- <Button type="submit" name="decision" value="deny" variant="secondary" size="big" data-testid="mcp-consent-deny">
127
- {text.deny}
128
- </Button>
129
- </div>
130
- </form>
131
- );
132
- }
@@ -1,51 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * `decideConsent` — the consent page's Allow and Deny (#10357 D6).
5
- *
6
- * Hands the person's choice to AILK's `POST /mcp/consent` in-process
7
- * (`auth.api.mcpConsent`), which checks the session, the signed consent
8
- * cookie and the role bound on every scope, and answers the client's own
9
- * callback URL. Next's Server Action origin check plus that cookie match make
10
- * a cross-site submit fail. A refusal returns to the page, which then renders
11
- * what is still true.
12
- */
13
- import { localeHref } from "@working-theory/ui";
14
- import { headers } from "next/headers";
15
- import { redirect } from "next/navigation";
16
-
17
- import { auth } from "../../../../auth";
18
-
19
- const LOCALE_PATTERN = /^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/;
20
-
21
- export async function decideConsent(formData: FormData): Promise<void> {
22
- const field = (name: string): string => {
23
- const value = formData.get(name);
24
- return typeof value === "string" ? value : "";
25
- };
26
- const consentCode = field("consent_code");
27
- // The fallback redirect is built from it, so only a locale-shaped value
28
- // counts: `/evil.example` would make `//evil.example/…`.
29
- const locale = LOCALE_PATTERN.test(field("locale")) ? field("locale") : "en";
30
- const accept = formData.get("decision") === "allow";
31
- const workspaceId = formData.get("workspace_id");
32
- const scopes = formData.getAll("scopes").filter((s): s is string => typeof s === "string");
33
-
34
- let redirectURI: string | null;
35
- try {
36
- const answer = await auth.api.mcpConsent({
37
- headers: await headers(),
38
- body: {
39
- consent_code: consentCode,
40
- accept,
41
- ...(accept && typeof workspaceId === "string" ? { workspace_id: workspaceId, scopes } : {}),
42
- },
43
- });
44
- redirectURI = answer.redirectURI;
45
- } catch {
46
- redirectURI = null;
47
- }
48
- redirect(
49
- redirectURI ?? localeHref(locale, `/consent?consent_code=${encodeURIComponent(consentCode)}`),
50
- );
51
- }
@@ -1,144 +0,0 @@
1
- /**
2
- * `/[locale]/consent` — the MCP consent step (#10357 D6).
3
- *
4
- * The `mcp` plugin sends every authorization here (AILK's before-hook forces
5
- * `prompt=consent`, D2) with a `consent_code` and a signed cookie. The page
6
- * reads ONLY `consent_code` from its query — never `client_id` or `scope`,
7
- * which the client controls — and asks AILK's `GET /mcp/consent-details`
8
- * in-process. That endpoint checks the session, the cookie and that the code
9
- * was issued to this person, and answers the client's self-claimed name,
10
- * where the code will go, and each workspace with the scopes the person's
11
- * role there may approve. Any refusal, or no session, renders the
12
- * `unavailable` line and no form.
13
- *
14
- * It names who is signed in (with a sign-out back to this page), names the
15
- * client as the client names itself — an unchecked claim — and its redirect
16
- * origin, then hands the workspaces to the `ConsentForm` island. `noindex`,
17
- * `referrer: same-origin` (the `account/connect` precedent). Framed by
18
- * `AuthShell` like sign-in: `"consent"` is an `AUTH_SEGMENTS` entry.
19
- */
20
- import { localeHref } from "@working-theory/ui";
21
- import { Button, Heading, Text } from "@working-theory/ui/primitives";
22
- import { SCOPE_GRANT_MAP, type McpScope } from "@working-theory/validation";
23
- import type { Metadata } from "next";
24
- import { headers } from "next/headers";
25
- import { getTranslations } from "next-intl/server";
26
- import type { ReactElement } from "react";
27
-
28
- import { auth } from "../../../../auth";
29
- import { SignOutTrigger } from "../../../../components/sign-out-trigger";
30
-
31
- import { ConsentForm, type ConsentWorkspace } from "./consent-form";
32
-
33
- interface Props {
34
- params: Promise<{ locale: string }>;
35
- searchParams: Promise<{ consent_code?: string | string[] }>;
36
- }
37
-
38
- interface ConsentDetails {
39
- client: { name: string; redirectOrigin: string };
40
- workspaces: Array<{ id: string; name: string; organizationName: string; offered: McpScope[] }>;
41
- }
42
-
43
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
44
- const { locale } = await params;
45
- const t = await getTranslations({ locale, namespace: "mcpConsent" });
46
- return {
47
- title: t("metaTitle"),
48
- robots: { index: false, follow: false },
49
- referrer: "same-origin",
50
- };
51
- }
52
-
53
- /** The details and the signed-in email, or `null` on any refusal. */
54
- async function readDetails(consentCode: string): Promise<{ details: ConsentDetails; email: string } | null> {
55
- try {
56
- const requestHeaders = await headers();
57
- const session = await auth.api.getSession({ headers: requestHeaders });
58
- if (!session) return null;
59
- const details = (await auth.api.mcpConsentDetails({
60
- headers: requestHeaders,
61
- query: { consent_code: consentCode },
62
- })) as ConsentDetails;
63
- return { details, email: session.user.email };
64
- } catch {
65
- return null;
66
- }
67
- }
68
-
69
- export default async function ConsentPage({ params, searchParams }: Props): Promise<ReactElement> {
70
- const { locale } = await params;
71
- const { consent_code: raw } = await searchParams;
72
- const t = await getTranslations({ locale, namespace: "mcpConsent" });
73
- const consentCode = typeof raw === "string" ? raw : "";
74
- const read = consentCode ? await readDetails(consentCode) : null;
75
-
76
- if (!read) {
77
- return (
78
- <div className="flex flex-col gap-4" data-testid="mcp-consent-unavailable">
79
- <Heading level={1} visual={3}>
80
- {t("heading")}
81
- </Heading>
82
- <Text as="p" variant="body-sm" tone="muted">
83
- {t("unavailable")}
84
- </Text>
85
- </div>
86
- );
87
- }
88
-
89
- const { details, email } = read;
90
- const here = localeHref(locale, `/consent?consent_code=${encodeURIComponent(consentCode)}`);
91
- const workspaces: ConsentWorkspace[] = details.workspaces.map((w) => ({
92
- id: w.id,
93
- name: w.name,
94
- organizationName: w.organizationName,
95
- offered: w.offered.map((scope) => {
96
- const permission = SCOPE_GRANT_MAP[scope];
97
- return { scope, permission, label: t(`scopes.${permission}`) };
98
- }),
99
- }));
100
-
101
- return (
102
- <div className="flex flex-col gap-6" data-testid="mcp-consent">
103
- <div className="flex flex-col gap-2">
104
- <Heading level={1} visual={3}>
105
- {t("heading")}
106
- </Heading>
107
- <Text as="p" variant="body-sm" data-testid="mcp-consent-signed-in">
108
- {t("signedInAs", { email })}
109
- </Text>
110
- <SignOutTrigger homeHref={here}>
111
- <Button type="button" variant="link" data-testid="mcp-consent-sign-out">
112
- {t("signOut")}
113
- </Button>
114
- </SignOutTrigger>
115
- </div>
116
- <div className="flex flex-col gap-2">
117
- <Text as="p" variant="body-sm" data-testid="mcp-consent-client">
118
- {t("clientClaim", { name: details.client.name })}
119
- </Text>
120
- <Text as="p" variant="body-sm" tone="muted" data-testid="mcp-consent-redirect-origin">
121
- {t("returnsTo", { origin: details.client.redirectOrigin })}
122
- </Text>
123
- </div>
124
- {workspaces.length === 0 ? (
125
- <Text as="p" variant="body-sm" tone="muted" data-testid="mcp-consent-no-workspace">
126
- {t("noWorkspace")}
127
- </Text>
128
- ) : null}
129
- <ConsentForm
130
- consentCode={consentCode}
131
- locale={locale}
132
- workspaces={workspaces}
133
- text={{
134
- workspaceLegend: t("workspaceLegend"),
135
- scopesLegend: t("scopesLegend"),
136
- memberReads: t("memberReads"),
137
- noScopes: t("noScopes"),
138
- allow: t("allow"),
139
- deny: t("deny"),
140
- }}
141
- />
142
- </div>
143
- );
144
- }
@@ -1,101 +0,0 @@
1
- "use client"; // Better Auth's client call (requestPasswordReset) + the sent/error state
2
-
3
- /**
4
- * ForgotPasswordCard — `/forgot-password`'s client island (#5962).
5
- *
6
- * #5963 shipped this page as a static `forgot` intent with no `onSubmit`, so
7
- * the form was a deliberate no-op. This island is what makes it work.
8
- *
9
- * `redirectTo` IS MANDATORY, and that is not a detail. Better Auth builds the
10
- * emailed link's `callbackURL` from it, and `/reset-password/:token` REJECTS an
11
- * empty `callbackURL` outright — so without it every emitted reset link would
12
- * dead-end at an error page and the whole flow would be unreachable while
13
- * looking configured.
14
- *
15
- * It is absolute and same-origin, resolved SERVER-side from `BETTER_AUTH_URL`
16
- * and handed down as a prop — never from `window.location`, which is the value
17
- * an attacker influences and the one the pinned `trustedOrigins` exists to stop
18
- * trusting.
19
- *
20
- * The card swaps to the `sent` intent only on a SUCCESSFUL response, which is
21
- * what keeps "check your email" honest on a site whose transport is missing:
22
- * the server refuses, and the visitor sees the error state instead.
23
- *
24
- * The success copy is identical for a known and an unknown address — the whole
25
- * point of the endpoint's constant body — so this component must never branch
26
- * its rendering on anything the response says about the address.
27
- */
28
-
29
- import {
30
- AuthCard,
31
- type AuthCardLabels,
32
- type AuthSubmitData,
33
- } from "@working-theory/ui/blocks";
34
- import { createAuthClient } from "better-auth/react";
35
- import type { ReactElement, ReactNode } from "react";
36
- import { useState } from "react";
37
-
38
- const authClient = createAuthClient();
39
-
40
- export interface ForgotPasswordCardProps {
41
- /** The site's mark, centred in the card at 48px (#8790 D3). */
42
- logo?: ReactNode;
43
- /** Absolute same-origin URL of `/reset-password`, resolved server-side. */
44
- resetUrl: string;
45
- /** Href for the card footer's "Back to sign in". */
46
- signInHref: string;
47
- /** Translated AuthCard labels (resolved server-side by the page). */
48
- labels: AuthCardLabels;
49
- /** Translated error copy. */
50
- errorLabels: { requestFailed: string };
51
- }
52
-
53
- export function ForgotPasswordCard({
54
- resetUrl,
55
- signInHref,
56
- labels,
57
- errorLabels,
58
- logo,
59
- }: ForgotPasswordCardProps): ReactElement {
60
- const [sent, setSent] = useState(false);
61
- const [sentTo, setSentTo] = useState("");
62
- const [errors, setErrors] = useState<{ email?: string }>({});
63
-
64
- const submit = async (email: string): Promise<void> => {
65
- setErrors({});
66
- // A network-level failure rejects; a refusal (the method disabled, the
67
- // rate limit tripped) resolves with `{ error }`. Both land on the same
68
- // message — neither may hint at whether the address exists.
69
- const failed = await authClient
70
- .requestPasswordReset({ email, redirectTo: resetUrl })
71
- .then(
72
- (res) => Boolean(res?.error),
73
- () => true,
74
- );
75
-
76
- if (failed) {
77
- setErrors({ email: errorLabels.requestFailed });
78
- return;
79
- }
80
- setSentTo(email);
81
- setSent(true);
82
- };
83
-
84
- const handleSubmit = (data: AuthSubmitData): void => {
85
- void submit(data.email);
86
- };
87
-
88
- return (
89
- <div className="flex flex-col gap-4" data-testid="forgot-password-page">
90
- <AuthCard
91
- {...(logo !== undefined ? { logo } : {})}
92
- intent={sent ? "sent" : "forgot"}
93
- signInHref={signInHref}
94
- labels={labels}
95
- {...(sent ? { sentTo } : {})}
96
- onSubmit={handleSubmit}
97
- errors={errors}
98
- />
99
- </div>
100
- );
101
- }