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,190 +0,0 @@
1
- /**
2
- * A delivered version's file, re-served (#8234, spec
3
- * docs/specs/8234-member-artifacts-account-artifacts-and-spec.md D5) —
4
- * `GET /[locale]/account/artifacts/:pieceId/versions/:version/file`.
5
- *
6
- * A file version's Download on the artifact page links here. The browser
7
- * holds neither the client's hub credential nor this site's spoke key, so
8
- * this route reads `GET /v1/member/artifacts/:pieceId/versions/:version/file`
9
- * with `forwardedCookieInit()` — the caller's own credential, so a client
10
- * only ever gets their own file — and streams the bytes back unread. It
11
- * mirrors `inbox/message/[id]/file/route.ts`: an app route file is not a
12
- * shared module, so the header map and the refusal mapping are copied.
13
- *
14
- * SEC-7877-D (the obligation in `@working-theory/api-client`'s `member.ts`):
15
- * the bytes go out with all five hub headers UNCHANGED — `Content-Type`,
16
- * `Content-Disposition` (attachment), `X-Content-Type-Options: nosniff`, the
17
- * sandbox `Content-Security-Policy` and `Cache-Control: private, no-store` —
18
- * so the file is never a document on this origin and never cached on the way.
19
- * A hub answer missing any of the five is refused 502 rather than served
20
- * without it — and so is one whose safety headers carry the wrong value
21
- * (#8320, #9965 D8): presence alone is not the hub's promise.
22
- *
23
- * #11161 — the preview mode, the one amendment to that obligation (recorded
24
- * in `docs/security/member-artifact-preview.md`): `?inline=1` asks for the
25
- * bytes as a document the artifact page can render in place. The route
26
- * answers `Content-Disposition: inline` ONLY when the hub's `Content-Type`
27
- * is `image/*` (never SVG) or `application/pdf`, with the download name the
28
- * hub pinned and the other four headers still unchanged — so the document
29
- * renders inside the sandbox CSP's opaque origin (no script, no cookie, no
30
- * same-origin access) and `nosniff` holds the type. Any other type, and
31
- * every request without the flag, is `attachment` exactly as the hub sent
32
- * it. The hub itself never answers inline.
33
- *
34
- * The params are shape-checked before any call (a malformed piece id or a
35
- * version that is not a whole number from 1 is a 404 with no call). A
36
- * refusal has no body: no credential (signed out) is a 401, a hub 4xx keeps
37
- * its status, and a hub 5xx, a transport the api-client refuses or a hub call
38
- * that throws is a 502.
39
- */
40
- import { member, type MemberFileHeaders } from "@working-theory/api-client";
41
- import { memberArtifactFileParamsSchema } from "@working-theory/validation";
42
-
43
- import { forwardedCookieInit } from "../../../../../../../../../lib/server-api";
44
-
45
- interface Context {
46
- params: Promise<{ locale: string; pieceId: string; version: string }>;
47
- }
48
-
49
- /** The response header each of the five hub headers goes out under. */
50
- const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
51
- contentType: "Content-Type",
52
- contentDisposition: "Content-Disposition",
53
- contentTypeOptions: "X-Content-Type-Options",
54
- contentSecurityPolicy: "Content-Security-Policy",
55
- cacheControl: "Cache-Control",
56
- };
57
-
58
- /**
59
- * HTTP's own whitespace — SP and HTAB, never JS `\s`. A browser reads any
60
- * other byte (a non-breaking space among them) as part of the token, so a
61
- * check that trimmed or split on it would pass a value it does not describe.
62
- */
63
- const HTTP_VALUE = /^[\t\x20-\x7e]*$/;
64
- const httpTrim = (value: string) => value.replace(/^[ \t]+|[ \t]+$/g, "");
65
-
66
- /**
67
- * #11161 — the two type families a preview may render inline: raster images
68
- * and PDF. SVG is refused by name (it is not attachable either, SEC-7877-D),
69
- * so a hub that ever stored one still serves it as an attachment.
70
- */
71
- export function isInlinePreviewType(contentType: string): boolean {
72
- const type = httpTrim(contentType.split(";")[0] ?? "").toLowerCase();
73
- return type === "application/pdf" || (type.startsWith("image/") && type !== "image/svg+xml");
74
- }
75
-
76
- /**
77
- * The CSP's directives by name, or `null` for two policies joined or a
78
- * directive named twice — a browser enforces the first copy, so a check that
79
- * read a later one could pass a policy it does not describe.
80
- */
81
- function cspDirectives(policy: string): Map<string, string> | null {
82
- // `Headers.get` joins two CSP headers with ", " — a second policy the hub
83
- // never sent (#9965 SEC-9965-16).
84
- if (policy.includes(",")) return null;
85
- const directives = new Map<string, string>();
86
- for (const part of policy.split(";")) {
87
- const [name = "", ...rest] = httpTrim(part).split(/[ \t]+/);
88
- if (!name) continue;
89
- if (directives.has(name)) return null;
90
- directives.set(name, rest.join(" "));
91
- }
92
- return directives;
93
- }
94
-
95
- /**
96
- * Whether each safety header carries the value the hub sends (D8). Every
97
- * comparison is case-insensitive and trimmed of SP and HTAB, and a value
98
- * carrying any byte outside visible ASCII, SP and HTAB is refused before it
99
- * is parsed. `Content-Type` is not checked: the other four contain it.
100
- */
101
- const SAFE_VALUE: Partial<
102
- Record<keyof MemberFileHeaders, (value: string) => boolean>
103
- > = {
104
- contentTypeOptions: (value) => value === "nosniff",
105
- contentDisposition: (value) => /^attachment[ \t]*(;|$)/.test(value),
106
- contentSecurityPolicy: (value) => {
107
- const directives = cspDirectives(value);
108
- const sandbox = directives?.get("sandbox");
109
- return (
110
- sandbox !== undefined &&
111
- !sandbox.split(" ").includes("allow-scripts") &&
112
- directives?.get("default-src") === "'none'"
113
- );
114
- },
115
- cacheControl: (value) => {
116
- const directives = value.split(",").map((part) => part.trim());
117
- return directives.includes("private") && directives.includes("no-store");
118
- },
119
- };
120
-
121
- function refusal(status: number): Response {
122
- return new Response(null, {
123
- status,
124
- headers: { "Cache-Control": "private, no-store" },
125
- });
126
- }
127
-
128
- /** The refusal's status, from the api-client's `{ ok: false, status, body }`. */
129
- function refusalStatus(status: number, body: unknown): number {
130
- if (status === 0) {
131
- const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
132
- return code === "unauthorized" ? 401 : 502;
133
- }
134
- return status >= 500 ? 502 : status;
135
- }
136
-
137
- // platform-decisions-waiver: api-versioning — a page-scoped download link on the site's own account area, not an API contract; it re-serves the versioned hub route /v1/member/artifacts/:pieceId/versions/:version/file
138
- export async function GET(
139
- request: Request,
140
- { params }: Context,
141
- ): Promise<Response> {
142
- // Exactly the two segments the strict schema takes — `params` also carries `locale`.
143
- const { pieceId, version } = await params;
144
- const inline = new URL(request.url).searchParams.get("inline") === "1";
145
- const parsed = memberArtifactFileParamsSchema.safeParse({ pieceId, version });
146
- if (!parsed.success) return refusal(404);
147
-
148
- // The api-client throws, rather than answering `{ ok: false }`, on a
149
- // network failure or a redirect — that is a 502 too, never Next's own 500.
150
- let res: Awaited<ReturnType<typeof member.artifactFile>>;
151
- try {
152
- res = await member.artifactFile(
153
- parsed.data.pieceId,
154
- parsed.data.version,
155
- await forwardedCookieInit(),
156
- );
157
- } catch {
158
- return refusal(502);
159
- }
160
- if (!res.ok) return refusal(refusalStatus(res.status, res.body));
161
-
162
- const { stream, headers } = res.body;
163
- const out = new Headers();
164
- for (const [key, name] of Object.entries(FILE_HEADER_NAMES) as [
165
- keyof MemberFileHeaders,
166
- string,
167
- ][]) {
168
- const value = headers[key];
169
- const check = SAFE_VALUE[key];
170
- const safe =
171
- value !== null &&
172
- (check === undefined ||
173
- (HTTP_VALUE.test(value) && check(httpTrim(value).toLowerCase())));
174
- if (!safe) {
175
- await stream.cancel();
176
- return refusal(502);
177
- }
178
- out.set(name, value);
179
- }
180
- // #11161 — the preview mode: inline for an image or a PDF, the hub's
181
- // attachment disposition (already checked above) rewritten in place with
182
- // the same pinned filename; everything else stays an attachment.
183
- if (inline && headers.contentType !== null && isInlinePreviewType(headers.contentType)) {
184
- out.set(
185
- "Content-Disposition",
186
- (out.get("Content-Disposition") ?? "").replace(/^[ \t]*attachment/i, "inline"),
187
- );
188
- }
189
- return new Response(stream, { status: 200, headers: out });
190
- }
@@ -1,333 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
-
5
- /**
6
- * A delivered version's file, re-served (#8234, spec 8234 D5, AC-3;
7
- * SEC-7877-D) — `GET /[locale]/account/artifacts/:pieceId/versions/:version/file`.
8
- *
9
- * The api-client's `member.artifactFile` is the one external boundary
10
- * mocked; `forwardedCookieInit()` and the route's decisions are real (the
11
- * build's own sign-in, a single site: the caller's session cookie). Covers:
12
- * - the read carries exactly the piece id, the version as a number and the
13
- * caller's credential, and the bytes come back with all five hub headers
14
- * unchanged;
15
- * - a hub answer missing any of the five is refused 502, its stream
16
- * cancelled — never bytes on this origin without them;
17
- * - so is one carrying a safety header with the wrong value (#8320, #9965
18
- * D8): presence is not enough;
19
- * - malformed params are a 404 with no call — and `locale`, which Next
20
- * always passes, never makes a real request fail;
21
- * - refusals map to a status with no body and `private, no-store`;
22
- * - the preview mode (#11161 AC-4): `?inline=1` answers `inline` for an
23
- * image or a PDF only — the other four headers unchanged — and
24
- * `attachment` for every other type, and without the flag always;
25
- * - the route reads no topology constant.
26
- */
27
-
28
- import { readFileSync } from "node:fs";
29
- import { join } from "node:path";
30
-
31
- const mockArtifactFile = jest.fn();
32
- jest.mock("@working-theory/api-client", () => ({
33
- __esModule: true,
34
- member: { artifactFile: (...args: unknown[]) => mockArtifactFile(...args) },
35
- }));
36
-
37
- const mockHeaders = jest.fn();
38
- const mockCookies = jest.fn();
39
- jest.mock("next/headers", () => ({
40
- __esModule: true,
41
- headers: (...args: unknown[]) => mockHeaders(...args),
42
- cookies: (...args: unknown[]) => mockCookies(...args),
43
- }));
44
-
45
- import { previewKind } from "@working-theory/templates/account";
46
-
47
- import { GET, isInlinePreviewType } from "../[pieceId]/versions/[version]/file/route";
48
-
49
- const SITE = "https://site.example.com";
50
- const PIECE = "piece_01920000-0000-7000-8000-000000000001";
51
- const ROUTE_FILE = join(
52
- __dirname,
53
- "..",
54
- "[pieceId]",
55
- "versions",
56
- "[version]",
57
- "file",
58
- "route.ts",
59
- );
60
-
61
- const FILE_HEADERS = {
62
- contentType: "application/pdf",
63
- contentDisposition: 'attachment; filename="brief-v2.pdf"',
64
- contentTypeOptions: "nosniff",
65
- contentSecurityPolicy: "default-src 'none'; sandbox",
66
- cacheControl: "private, no-store",
67
- };
68
-
69
- function fileResult(
70
- headers: Partial<Record<keyof typeof FILE_HEADERS, string | null>> = {},
71
- ) {
72
- return {
73
- ok: true,
74
- body: {
75
- stream: new Response("%PDF-1.7 bytes").body,
76
- headers: { ...FILE_HEADERS, ...headers },
77
- },
78
- };
79
- }
80
-
81
- function get(pieceId = PIECE, version = "2", query = ""): Promise<Response> {
82
- return GET(
83
- new Request(
84
- `${SITE}/account/artifacts/${pieceId}/versions/${version}/file${query}`,
85
- ),
86
- {
87
- params: Promise.resolve({ locale: "en", pieceId, version }),
88
- },
89
- );
90
- }
91
-
92
- async function expectBodylessRefusal(
93
- res: Response,
94
- status: number,
95
- ): Promise<void> {
96
- expect(res.status).toBe(status);
97
- expect(res.headers.get("cache-control")).toBe("private, no-store");
98
- expect(res.headers.get("content-disposition")).toBeNull();
99
- await expect(res.text()).resolves.toBe("");
100
- }
101
-
102
- beforeEach(() => {
103
- mockHeaders.mockReset().mockResolvedValue(new Headers());
104
- mockCookies.mockReset().mockResolvedValue({ toString: () => "session=abc" });
105
- mockArtifactFile.mockReset().mockResolvedValue(fileResult());
106
- });
107
-
108
- describe("the version file read", () => {
109
- it("reads the file with the piece id, the version as a number and the caller's credential, and re-serves it with all five headers unchanged", async () => {
110
- const res = await get();
111
- expect(mockArtifactFile).toHaveBeenCalledTimes(1);
112
- expect(mockArtifactFile).toHaveBeenCalledWith(PIECE, 2, {
113
- headers: { cookie: "session=abc" },
114
- });
115
- expect(res.status).toBe(200);
116
- expect(res.headers.get("content-type")).toBe(FILE_HEADERS.contentType);
117
- expect(res.headers.get("content-disposition")).toBe(
118
- FILE_HEADERS.contentDisposition,
119
- );
120
- expect(res.headers.get("x-content-type-options")).toBe(
121
- FILE_HEADERS.contentTypeOptions,
122
- );
123
- expect(res.headers.get("content-security-policy")).toBe(
124
- FILE_HEADERS.contentSecurityPolicy,
125
- );
126
- expect(res.headers.get("cache-control")).toBe(FILE_HEADERS.cacheControl);
127
- await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
128
- });
129
-
130
- it("forwards the request's Origin with the cookie, as forwardedCookieInit builds it", async () => {
131
- mockHeaders.mockResolvedValue(new Headers({ origin: SITE }));
132
- await get();
133
- expect(mockArtifactFile).toHaveBeenCalledWith(PIECE, 2, {
134
- headers: { cookie: "session=abc", origin: SITE },
135
- });
136
- });
137
-
138
- it.each(Object.keys(FILE_HEADERS) as (keyof typeof FILE_HEADERS)[])(
139
- "refuses 502 with no bytes when the hub's answer lacks %s",
140
- async (name) => {
141
- const result = fileResult({ [name]: null });
142
- const cancel = jest.spyOn(result.body.stream as ReadableStream, "cancel");
143
- mockArtifactFile.mockResolvedValue(result);
144
- const res = await get();
145
- expect(cancel).toHaveBeenCalled();
146
- await expectBodylessRefusal(res, 502);
147
- },
148
- );
149
-
150
- it.each([
151
- [
152
- "an inline Content-Disposition",
153
- { contentDisposition: "inline; filename=a.pdf" },
154
- ],
155
- [
156
- "X-Content-Type-Options other than nosniff",
157
- { contentTypeOptions: "sniff" },
158
- ],
159
- [
160
- "a Content-Security-Policy with no sandbox",
161
- { contentSecurityPolicy: "default-src *" },
162
- ],
163
- [
164
- "a sandbox that allows scripts",
165
- { contentSecurityPolicy: "default-src 'none'; sandbox allow-scripts" },
166
- ],
167
- [
168
- "a sandbox with default-src other than 'none'",
169
- { contentSecurityPolicy: "default-src *; sandbox" },
170
- ],
171
- [
172
- "two CSP headers, joined (the hub's plus default-src *)",
173
- { contentSecurityPolicy: "default-src 'none'; sandbox, default-src *" },
174
- ],
175
- [
176
- "a repeated sandbox directive, whose first copy allows scripts",
177
- {
178
- contentSecurityPolicy:
179
- "sandbox allow-scripts; sandbox; default-src 'none'",
180
- },
181
- ],
182
- // HTTP whitespace is SP and HTAB only: a browser reads a non-breaking
183
- // space as part of the token, so a value JS would trim to the safe one
184
- // is not the safe one.
185
- [
186
- "an attachment Content-Disposition with a non-breaking space",
187
- { contentDisposition: "attachment\u00a0; filename=x.html" },
188
- ],
189
- [
190
- "nosniff followed by a non-breaking space",
191
- { contentTypeOptions: "nosniff\u00a0" },
192
- ],
193
- [
194
- "a CSP whose directives are split by non-breaking spaces",
195
- { contentSecurityPolicy: "default-src\u00a0'none'; sandbox\u00a0" },
196
- ],
197
- [
198
- "a public, cacheable Cache-Control",
199
- { cacheControl: "public, max-age=3600" },
200
- ],
201
- [
202
- "a Cache-Control without no-store",
203
- { cacheControl: "private, max-age=60" },
204
- ],
205
- ])("refuses 502 with no bytes on %s", async (_case, headers) => {
206
- const result = fileResult(headers);
207
- const cancel = jest.spyOn(result.body.stream as ReadableStream, "cancel");
208
- mockArtifactFile.mockResolvedValue(result);
209
- const res = await get();
210
- expect(cancel).toHaveBeenCalled();
211
- await expectBodylessRefusal(res, 502);
212
- });
213
-
214
- it("serves the hub's own attachment policy, compared case-insensitively", async () => {
215
- mockArtifactFile.mockResolvedValue(
216
- fileResult({
217
- contentDisposition: 'Attachment; filename="brief-v2.pdf"',
218
- contentTypeOptions: "NoSniff",
219
- contentSecurityPolicy:
220
- "default-src 'none'; sandbox; frame-ancestors 'none'; form-action 'none'; base-uri 'none'",
221
- cacheControl: "no-store, Private",
222
- }),
223
- );
224
- const res = await get();
225
- expect(res.status).toBe(200);
226
- await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
227
- });
228
-
229
- it.each([
230
- ["a version of 0", PIECE, "0"],
231
- ["a version that is not a number", PIECE, "abc"],
232
- ["a fractional version", PIECE, "1.5"],
233
- ["a malformed piece id", "x", "2"],
234
- ])("%s is a 404 with no call", async (_case, pieceId, version) => {
235
- const res = await get(pieceId, version);
236
- expect(mockArtifactFile).not.toHaveBeenCalled();
237
- await expectBodylessRefusal(res, 404);
238
- });
239
-
240
- it.each([
241
- ["a status-0 unauthorized (signed out)", 0, "unauthorized", 401],
242
- ["a status-0 insecure_transport", 0, "insecure_transport", 502],
243
- ["a hub 404", 404, "not_found", 404],
244
- ["a hub 403", 403, "forbidden", 403],
245
- ["a hub 500", 500, "internal", 502],
246
- ])("%s answers %#", async (_case, hubStatus, code, status) => {
247
- mockArtifactFile.mockResolvedValue({
248
- ok: false,
249
- status: hubStatus,
250
- body: { ok: false, error: { code, message: "x" } },
251
- });
252
- await expectBodylessRefusal(await get(), status);
253
- });
254
-
255
- it("a hub call that throws answers 502 with no body", async () => {
256
- mockArtifactFile.mockRejectedValue(new TypeError("fetch failed"));
257
- await expectBodylessRefusal(await get(), 502);
258
- });
259
-
260
- describe("the preview mode (#11161 AC-4)", () => {
261
- it.each([
262
- ["a PDF", "application/pdf"],
263
- ["a PNG", "image/png"],
264
- ["a JPEG with a parameter", "image/jpeg; charset=binary"],
265
- ])("?inline=1 answers %s inline, the pinned filename and the other four headers unchanged", async (_case, contentType) => {
266
- mockArtifactFile.mockResolvedValue(fileResult({ contentType }));
267
- const res = await get(PIECE, "2", "?inline=1");
268
- expect(res.status).toBe(200);
269
- expect(res.headers.get("content-type")).toBe(contentType);
270
- expect(res.headers.get("content-disposition")).toBe('inline; filename="brief-v2.pdf"');
271
- expect(res.headers.get("x-content-type-options")).toBe("nosniff");
272
- expect(res.headers.get("content-security-policy")).toBe(FILE_HEADERS.contentSecurityPolicy);
273
- expect(res.headers.get("cache-control")).toBe("private, no-store");
274
- await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
275
- });
276
-
277
- it.each([
278
- ["SVG", "image/svg+xml"],
279
- ["HTML", "text/html"],
280
- ["a zip", "application/zip"],
281
- ["an octet stream", "application/octet-stream"],
282
- ])("?inline=1 keeps %s an attachment", async (_case, contentType) => {
283
- mockArtifactFile.mockResolvedValue(fileResult({ contentType }));
284
- const res = await get(PIECE, "2", "?inline=1");
285
- expect(res.status).toBe(200);
286
- expect(res.headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
287
- });
288
-
289
- it("without the flag, a PDF stays an attachment; another value of the flag is no flag", async () => {
290
- expect((await get()).headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
291
- expect((await get(PIECE, "2", "?inline=true")).headers.get("content-disposition")).toBe(
292
- FILE_HEADERS.contentDisposition,
293
- );
294
- });
295
-
296
- it("the preview mode still refuses a hub answer that is not an attachment — it rewrites the checked value, never trusts an inline one", async () => {
297
- const result = fileResult({ contentDisposition: "inline; filename=a.pdf" });
298
- mockArtifactFile.mockResolvedValue(result);
299
- await expectBodylessRefusal(await get(PIECE, "2", "?inline=1"), 502);
300
- });
301
-
302
- it.each([
303
- "application/pdf",
304
- "Application/PDF",
305
- " image/png ",
306
- "image/jpeg; charset=binary",
307
- "image/webp",
308
- "image/svg+xml",
309
- "image/svg+xml;charset=utf-8",
310
- "text/html",
311
- "application/pdfx",
312
- "application/zip",
313
- "",
314
- ])("the page's previewKind agrees with the route's inline predicate on %j", (contentType) => {
315
- expect(previewKind(contentType) !== null).toBe(isInlinePreviewType(contentType));
316
- });
317
-
318
- it("isInlinePreviewType admits image/* but SVG and application/pdf, case-insensitively, and nothing else", () => {
319
- expect(isInlinePreviewType("application/pdf")).toBe(true);
320
- expect(isInlinePreviewType("Application/PDF")).toBe(true);
321
- expect(isInlinePreviewType("image/webp")).toBe(true);
322
- expect(isInlinePreviewType("image/svg+xml")).toBe(false);
323
- expect(isInlinePreviewType("text/html")).toBe(false);
324
- expect(isInlinePreviewType("application/pdfx")).toBe(false);
325
- });
326
- });
327
-
328
- it("reads no topology constant", () => {
329
- expect(readFileSync(ROUTE_FILE, "utf8")).not.toContain(
330
- "topology.generated",
331
- );
332
- });
333
- });