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.
- package/README.md +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +19 -12
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +12 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +73 -2
- package/dist/routes.d.ts +130 -0
- package/dist/routes.js +954 -0
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -2
- package/dist/site-roster.js +63 -21
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +105 -293
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +108 -10
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +26 -1
- package/dist/topology.js +273 -7
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +87 -23
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +100 -0
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +46 -29
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +51 -1
- package/templates/apps/web/jest.config.cjs +17 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +8 -836
- package/templates/apps/web/middleware.ts +15 -26
- package/templates/apps/web/next.config.mjs +35 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +49 -47
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
- package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
- package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
- package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
- package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
- package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
- package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
- package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
- package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
- package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
- package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
- package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
- package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
- package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
- package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
- package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
- package/templates/apps/web/lib/hub-session/config.ts +0 -110
- package/templates/apps/web/lib/hub-session/entry.ts +0 -238
- package/templates/apps/web/lib/hub-session/index.ts +0 -21
- package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
- package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
- package/templates/apps/web/lib/hub-session/seal.ts +0 -86
- package/templates/apps/web/lib/hub-session/session.ts +0 -298
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use client"; // owns the save call and the router.refresh() that follows it
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* GeneralSettings — User settings › General's adapter over the shared
|
|
5
|
-
* `AccountSettings` composition (#8339 D8; builds on #8232 D3, D4).
|
|
6
|
-
*
|
|
7
|
-
* Rewritten in place from `ProfileForm` (#7430 → #8232), which rendered its
|
|
8
|
-
* own form. The form, the color logic and the markup now live in
|
|
9
|
-
* `@working-theory/templates/account`'s `AccountSettings` (spec 8339 D4);
|
|
10
|
-
* this file supplies `profile` and `onSave` from `via` (General's
|
|
11
|
-
* `loadProfileSource`, D3):
|
|
12
|
-
*
|
|
13
|
-
* - `member` — no Name field (#11167 ruling 5: the account name follows
|
|
14
|
-
* the contact's first and last names, `contact-actions.ts`), so the form
|
|
15
|
-
* saves the photo alone through `savePhoto` (`PATCH /v1/member/profile`
|
|
16
|
-
* with `image` only); a refusal keeps the field as typed.
|
|
17
|
-
* - `session` — a build with no member API: the name saves through
|
|
18
|
-
* Better Auth's own `updateUser`, and no photo field shows
|
|
19
|
-
* (`profile="name-only"`).
|
|
20
|
-
* - `none` — a hub-mode spoke whose hub answers no member route: no form,
|
|
21
|
-
* the name as read-only text (`profile="read-only"`).
|
|
22
|
-
*
|
|
23
|
-
* On success, both paths call `router.refresh()` so the rail's name follows
|
|
24
|
-
* the save.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
AccountSettings,
|
|
29
|
-
type AccountGeneralLabels,
|
|
30
|
-
type AccountSaveResult,
|
|
31
|
-
type AccountSettingsFrameProps,
|
|
32
|
-
} from "@working-theory/templates/account";
|
|
33
|
-
import { createAuthClient } from "better-auth/react";
|
|
34
|
-
import { useRouter } from "next/navigation";
|
|
35
|
-
import type { ReactElement, ReactNode } from "react";
|
|
36
|
-
|
|
37
|
-
import { savePhoto } from "./photo-actions";
|
|
38
|
-
|
|
39
|
-
const authClient = createAuthClient();
|
|
40
|
-
|
|
41
|
-
export interface GeneralSettingsLabels extends AccountGeneralLabels {
|
|
42
|
-
/** The `saveProfile` refusal lines not already in `AccountGeneralLabels`. */
|
|
43
|
-
unverified: string;
|
|
44
|
-
unavailable: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function GeneralSettings({
|
|
48
|
-
frame,
|
|
49
|
-
user,
|
|
50
|
-
labels,
|
|
51
|
-
colorMode,
|
|
52
|
-
via,
|
|
53
|
-
children,
|
|
54
|
-
}: {
|
|
55
|
-
frame: Omit<AccountSettingsFrameProps, "name" | "children">;
|
|
56
|
-
user: { name: string; email: string; image: string | null };
|
|
57
|
-
labels: GeneralSettingsLabels;
|
|
58
|
-
colorMode: { cookieName: string } | null;
|
|
59
|
-
via: "member" | "session" | "none";
|
|
60
|
-
children?: ReactNode;
|
|
61
|
-
}): ReactElement {
|
|
62
|
-
const router = useRouter();
|
|
63
|
-
|
|
64
|
-
async function onSave({
|
|
65
|
-
name,
|
|
66
|
-
image,
|
|
67
|
-
imageChanged,
|
|
68
|
-
}: {
|
|
69
|
-
name: string;
|
|
70
|
-
image: string | null;
|
|
71
|
-
imageChanged: boolean;
|
|
72
|
-
}): Promise<AccountSaveResult> {
|
|
73
|
-
if (via === "session") {
|
|
74
|
-
const { error } = await authClient.updateUser({ name });
|
|
75
|
-
if (error) return { ok: false, message: labels.saveError };
|
|
76
|
-
router.refresh();
|
|
77
|
-
return { ok: true };
|
|
78
|
-
}
|
|
79
|
-
// The member path saves the photo alone; `name` is the account's as it
|
|
80
|
-
// stands and never written here. Only a changed photo reaches here (Save
|
|
81
|
-
// is disabled otherwise), so the untouched-field rule (8232 D4/D6) holds.
|
|
82
|
-
if (!imageChanged) return { ok: true };
|
|
83
|
-
const res = await savePhoto(image);
|
|
84
|
-
if (!res.ok) {
|
|
85
|
-
if (res.reason === "photo") return { ok: false, field: "photo", message: labels.photoInvalid };
|
|
86
|
-
if (res.reason === "unverified") return { ok: false, message: labels.unverified };
|
|
87
|
-
if (res.reason === "unavailable") return { ok: false, message: labels.unavailable };
|
|
88
|
-
return { ok: false, message: labels.saveError };
|
|
89
|
-
}
|
|
90
|
-
router.refresh();
|
|
91
|
-
return { ok: true, image: res.image };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<AccountSettings
|
|
96
|
-
frame={frame}
|
|
97
|
-
user={user}
|
|
98
|
-
labels={labels}
|
|
99
|
-
colorMode={colorMode}
|
|
100
|
-
profile={via === "member" ? "editable" : via === "session" ? "name-only" : "read-only"}
|
|
101
|
-
nameField={via !== "member"}
|
|
102
|
-
{...(via === "none" ? {} : { onSave })}
|
|
103
|
-
>
|
|
104
|
-
{children}
|
|
105
|
-
</AccountSettings>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* general/profile-source.ts (server code) — who saves User settings ›
|
|
3
|
-
* General's profile and takes its deletion request, and the photo the
|
|
4
|
-
* profile form starts with (#8232, spec
|
|
5
|
-
* docs/specs/8232-member-settings-account-general-and-spec.md D3, C2, C5).
|
|
6
|
-
*
|
|
7
|
-
* `via` — whether the member API answers, read once per request from
|
|
8
|
-
* `member.pieces`, the cheapest member read:
|
|
9
|
-
*
|
|
10
|
-
* - `member` — any answer but a 404: a 2xx, any other refusal, a preflight
|
|
11
|
-
* refusal (status 0) or a throw. A refusal of another kind belongs to the
|
|
12
|
-
* write, which reports it honestly. A `503 tenant_unresolved` is
|
|
13
|
-
* `member` too: the writes answer the same 503, shown as unavailable.
|
|
14
|
-
* - on a 404, the sign-in seam (`signInMethod()`, D7) says who holds the
|
|
15
|
-
* account. A `site` sign-in gives `session`: this site's own sign-in
|
|
16
|
-
* holds it, and the 404 is a build with no tenancy module — every member
|
|
17
|
-
* read and write registers in one module block — so the name saves
|
|
18
|
-
* through Better Auth as before and deletion points at Support. A `hub`
|
|
19
|
-
* sign-in gives `none`: the hub holds the account and answers no member
|
|
20
|
-
* route for this spoke, and the spoke has no `/api/auth` of its own, so
|
|
21
|
-
* no write can reach the account from here.
|
|
22
|
-
*
|
|
23
|
-
* A 404 is a module-presence test, as `read()` in `lib/account-config.ts`
|
|
24
|
-
* already makes; this file names no topology constant itself.
|
|
25
|
-
*
|
|
26
|
-
* `image` — on the `member` path, the photo the member API holds for the
|
|
27
|
-
* caller's own row (`GET /v1/member/profile`, #11167): a spoke's hub session
|
|
28
|
-
* carries no photo, and this is how the Admin's Google photo reaches the
|
|
29
|
-
* spoke's General. A failed or refused read falls back to the session's photo,
|
|
30
|
-
* which Better Auth's session carries at run time though the generated
|
|
31
|
-
* `SiteSession` type does not declare it (a hub session carries none, C5).
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
import { member } from "@working-theory/api-client";
|
|
35
|
-
import type { AccountContext } from "@working-theory/templates/account";
|
|
36
|
-
import { headers } from "next/headers";
|
|
37
|
-
import { cache } from "react";
|
|
38
|
-
|
|
39
|
-
import { readSession } from "../../../../../lib/topology.generated";
|
|
40
|
-
import { signInMethod } from "../sign-in-method";
|
|
41
|
-
|
|
42
|
-
export interface ProfileSource {
|
|
43
|
-
via: "member" | "session" | "none";
|
|
44
|
-
image: string | null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** `user.image` as a trimmed non-blank string, else `null`. */
|
|
48
|
-
function sessionImage(session: unknown): string | null {
|
|
49
|
-
if (typeof session !== "object" || session === null) return null;
|
|
50
|
-
const user = (session as { user?: unknown }).user;
|
|
51
|
-
if (typeof user !== "object" || user === null) return null;
|
|
52
|
-
const image = (user as { image?: unknown }).image;
|
|
53
|
-
return typeof image === "string" && image.trim() !== "" ? image.trim() : null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function memberApiAnswers(ctx: AccountContext): Promise<boolean> {
|
|
57
|
-
try {
|
|
58
|
-
const res = await member.pieces(ctx.init);
|
|
59
|
-
return res.ok || res.status !== 404;
|
|
60
|
-
} catch {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** The caller's stored photo, or `null` when the read fails or holds none. */
|
|
66
|
-
async function memberImage(ctx: AccountContext): Promise<string | null> {
|
|
67
|
-
try {
|
|
68
|
-
const res = await member.profile(ctx.init);
|
|
69
|
-
return res.ok ? res.body.image?.trim() || null : null;
|
|
70
|
-
} catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const loadProfileSource = cache(async (ctx: AccountContext): Promise<ProfileSource> => {
|
|
76
|
-
// The photo is optional: a failed session read starts the field empty
|
|
77
|
-
// rather than failing the page.
|
|
78
|
-
const [answers, session] = await Promise.all([
|
|
79
|
-
memberApiAnswers(ctx),
|
|
80
|
-
headers()
|
|
81
|
-
.then((h) => readSession(h))
|
|
82
|
-
.catch(() => null),
|
|
83
|
-
]);
|
|
84
|
-
const via = answers ? "member" : signInMethod().kind === "site" ? "session" : "none";
|
|
85
|
-
const image = (via === "member" ? await memberImage(ctx) : null) ?? sessionImage(session);
|
|
86
|
-
return { via, image };
|
|
87
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /[locale]/account/inbox/[kind]/[id] — one Inbox item (#7430, spec 7423 U4;
|
|
3
|
-
* the D8 detail contract).
|
|
4
|
-
*
|
|
5
|
-
* RSC, inside the account layout's SignedInShell (the rail keeps Inbox
|
|
6
|
-
* selected here). The item is found the way the contract says: its kind's
|
|
7
|
-
* `load` runs again and the `[id]` is matched — so the page shows only what
|
|
8
|
-
* the caller's own reads return. The kind's `renderDetail` fills the shared
|
|
9
|
-
* `InboxItemFrame`; the area supplies the back link, the caption (the kind's
|
|
10
|
-
* label) and the title, so every kind's detail reads as one frame.
|
|
11
|
-
*
|
|
12
|
-
* #11007 — a conversation kind (`accountChatKinds`: a message) renders
|
|
13
|
-
* through the frame's chat layout — RecordHeader over the message as a
|
|
14
|
-
* start-side bubble; every other kind keeps the stacked head and fields.
|
|
15
|
-
* #11152 — such a kind's item also links to the member thread page
|
|
16
|
-
* (`../../thread`, Open conversation), first among its actions: the whole
|
|
17
|
-
* exchange, with the composer, is one step away from any one message.
|
|
18
|
-
*
|
|
19
|
-
* An unknown kind, or an id the kind did not load, is a not-found — never an
|
|
20
|
-
* empty frame. A failed read is not a not-found: it renders an error with
|
|
21
|
-
* Retry (D12's posture).
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { InboxItemFrame } from "@working-theory/templates/account";
|
|
25
|
-
import { localeHref } from "@working-theory/ui";
|
|
26
|
-
import type { Metadata } from "next";
|
|
27
|
-
import { notFound } from "next/navigation";
|
|
28
|
-
import { getTranslations } from "next-intl/server";
|
|
29
|
-
import type { ReactElement } from "react";
|
|
30
|
-
|
|
31
|
-
import { accountChatKinds, accountInboxKinds } from "../../../../../../../lib/account-config";
|
|
32
|
-
import { accountSession, logReadFailure } from "../../../account-data";
|
|
33
|
-
import { ErrorRow } from "../../../error-row";
|
|
34
|
-
|
|
35
|
-
interface Props {
|
|
36
|
-
params: Promise<{ locale: string; kind: string; id: string }>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A segment, percent-decoded when it decodes. The route param is matched in
|
|
41
|
-
* both forms (`matches` below), so an id is found whether or not the
|
|
42
|
-
* framework already decoded it — and an id that itself contains `%XX` still
|
|
43
|
-
* matches its raw form.
|
|
44
|
-
*/
|
|
45
|
-
function decodeSegment(segment: string): string {
|
|
46
|
-
try {
|
|
47
|
-
return decodeURIComponent(segment);
|
|
48
|
-
} catch {
|
|
49
|
-
return segment;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
54
|
-
const { locale } = await params;
|
|
55
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
56
|
-
return { title: t("inbox.title") };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default async function AccountInboxItemPage({ params }: Props): Promise<ReactElement> {
|
|
60
|
-
const { locale, kind: kindSegment, id: idSegment } = await params;
|
|
61
|
-
const matches = (value: string, segment: string): boolean =>
|
|
62
|
-
value === segment || value === decodeSegment(segment);
|
|
63
|
-
const kind = accountInboxKinds.find((k) => matches(k.kind, kindSegment));
|
|
64
|
-
if (!kind) notFound();
|
|
65
|
-
|
|
66
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
67
|
-
const session = await accountSession(locale);
|
|
68
|
-
if (!session) notFound();
|
|
69
|
-
|
|
70
|
-
const back = { href: localeHref(locale, "/account"), label: t("inbox.back") };
|
|
71
|
-
|
|
72
|
-
let items;
|
|
73
|
-
try {
|
|
74
|
-
items = await kind.load(session.ctx);
|
|
75
|
-
} catch (err) {
|
|
76
|
-
logReadFailure(`kind:${kind.kind}`, err);
|
|
77
|
-
return (
|
|
78
|
-
<div className="max-w-3xl py-8" data-testid="account-item">
|
|
79
|
-
<ErrorRow message={t("inbox.itemError")} retryLabel={t("inbox.retry")} />
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const item = items.find((candidate) => matches(candidate.id, idSegment));
|
|
85
|
-
if (!item) notFound();
|
|
86
|
-
|
|
87
|
-
const detail = kind.renderDetail(item, session.ctx);
|
|
88
|
-
const chat = accountChatKinds.has(kind.kind);
|
|
89
|
-
// #11152 — a conversation kind's item opens the thread; the kind's own actions follow.
|
|
90
|
-
const actions = [
|
|
91
|
-
...(chat
|
|
92
|
-
? [
|
|
93
|
-
{
|
|
94
|
-
key: "thread",
|
|
95
|
-
label: t("thread.open"),
|
|
96
|
-
variant: "outline" as const,
|
|
97
|
-
href: localeHref(locale, "/account/inbox/thread"),
|
|
98
|
-
},
|
|
99
|
-
]
|
|
100
|
-
: []),
|
|
101
|
-
...(detail.actions ?? []),
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<InboxItemFrame
|
|
106
|
-
back={back}
|
|
107
|
-
caption={session.ctx.t(kind.label)}
|
|
108
|
-
title={item.title}
|
|
109
|
-
lead={detail.lead}
|
|
110
|
-
status={detail.status}
|
|
111
|
-
{...(actions.length > 0 ? { actions } : {})}
|
|
112
|
-
fields={detail.fields}
|
|
113
|
-
{...(chat ? { layout: "chat" as const } : {})}
|
|
114
|
-
testIdPrefix="account-item"
|
|
115
|
-
>
|
|
116
|
-
{detail.body}
|
|
117
|
-
</InboxItemFrame>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment node
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The member file read, re-served by the spoke (#7920; SEC-7877-D) —
|
|
7
|
-
* `GET /[locale]/account/inbox/message/:id/file`.
|
|
8
|
-
*
|
|
9
|
-
* A message's file action links here: the browser holds neither the hub
|
|
10
|
-
* credential (sealed in the `hub-session` cookie) nor the spoke key, so the
|
|
11
|
-
* spoke's server reads `GET /v1/member/messages/:id/file` with
|
|
12
|
-
* `forwardedCookieInit()` and streams the bytes back. The api-client's
|
|
13
|
-
* `member.messageFile` is the one external boundary mocked; the seal, the
|
|
14
|
-
* cookie read and the route's decisions are real. Covers:
|
|
15
|
-
* - on a single site (`SIGN_IN_PROVIDER` `"site"`) the read carries the
|
|
16
|
-
* caller's session cookie to the site's own API, and serves the same
|
|
17
|
-
* way (#8231 D9) — the route itself tests no topology;
|
|
18
|
-
* - the read carries the signed-in caller's own credential, and the bytes
|
|
19
|
-
* come back with all five hub headers unchanged;
|
|
20
|
-
* - a hub answer missing any of the five is refused 502 — never bytes on
|
|
21
|
-
* this origin without them;
|
|
22
|
-
* - refusals map to a status with no body and `private, no-store`.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const mockMessageFile = jest.fn();
|
|
26
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
27
|
-
__esModule: true,
|
|
28
|
-
member: { messageFile: (...args: unknown[]) => mockMessageFile(...args) },
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
const mockProvider: { value: "site" | "hub" | "none" } = { value: "hub" };
|
|
32
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: the sign-in provider is a generated constant (#7894 D8), not a runtime input; the seam IS the boundary between a hub and a hub-mode spoke build, and no env or HTTP surface selects it.
|
|
33
|
-
jest.mock("../../../../../../../../../lib/topology.generated", () => ({
|
|
34
|
-
__esModule: true,
|
|
35
|
-
get SIGN_IN_PROVIDER() {
|
|
36
|
-
return mockProvider.value;
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
const mockHeaders = jest.fn();
|
|
41
|
-
const mockCookies = jest.fn();
|
|
42
|
-
jest.mock("next/headers", () => ({
|
|
43
|
-
__esModule: true,
|
|
44
|
-
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
45
|
-
cookies: (...args: unknown[]) => mockCookies(...args),
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
import { seal } from "../../../../../../../../../lib/hub-session/seal";
|
|
49
|
-
import { GET } from "../route";
|
|
50
|
-
|
|
51
|
-
const ENV = process.env;
|
|
52
|
-
const SITE = "https://spoke.example.com";
|
|
53
|
-
const SESSION_SECRET = "s".repeat(43);
|
|
54
|
-
const COOKIE = "__Host-ailk-hub-session";
|
|
55
|
-
const CREDENTIAL = `ailk_hst_${"t".repeat(43)}`;
|
|
56
|
-
const ID = "intx_01920000-0000-7000-8000-000000000004";
|
|
57
|
-
|
|
58
|
-
const FILE_HEADERS = {
|
|
59
|
-
contentType: "application/pdf",
|
|
60
|
-
contentDisposition: 'attachment; filename="brand-guide.pdf"',
|
|
61
|
-
contentTypeOptions: "nosniff",
|
|
62
|
-
contentSecurityPolicy: "default-src 'none'; sandbox",
|
|
63
|
-
cacheControl: "private, no-store",
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
function fileResult(headers: Partial<Record<keyof typeof FILE_HEADERS, string | null>> = {}) {
|
|
67
|
-
return {
|
|
68
|
-
ok: true,
|
|
69
|
-
body: {
|
|
70
|
-
stream: new Response("%PDF-1.7 bytes").body,
|
|
71
|
-
headers: { ...FILE_HEADERS, ...headers },
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function signedIn(): void {
|
|
77
|
-
const sealed = seal(
|
|
78
|
-
{
|
|
79
|
-
v: 1,
|
|
80
|
-
accessToken: CREDENTIAL,
|
|
81
|
-
expiresAt: Date.now() + 60_000,
|
|
82
|
-
user: { name: "Ada", email: "ada@example.com", emailVerified: true, createdAt: "2026-09-01T00:00:00.000Z" },
|
|
83
|
-
},
|
|
84
|
-
SESSION_SECRET,
|
|
85
|
-
"session",
|
|
86
|
-
COOKIE,
|
|
87
|
-
);
|
|
88
|
-
mockHeaders.mockResolvedValue(new Headers({ cookie: `${COOKIE}=${sealed}` }));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function get(id = ID): Promise<Response> {
|
|
92
|
-
return GET(new Request(`${SITE}/account/inbox/message/${id}/file`), {
|
|
93
|
-
params: Promise.resolve({ locale: "en", id }),
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
beforeEach(() => {
|
|
98
|
-
process.env = {
|
|
99
|
-
...ENV,
|
|
100
|
-
AILK_HUB_SIGN_IN_URL: "https://hub.example.com",
|
|
101
|
-
AILK_HUB_CLIENT_ID: "spoke_0001",
|
|
102
|
-
AILK_HUB_CLIENT_SECRET: `ailk_hcs_${"c".repeat(43)}`,
|
|
103
|
-
AILK_HUB_SESSION_SECRET: SESSION_SECRET,
|
|
104
|
-
NEXT_PUBLIC_BASE_URL: SITE,
|
|
105
|
-
};
|
|
106
|
-
mockProvider.value = "hub";
|
|
107
|
-
mockHeaders.mockReset().mockResolvedValue(new Headers());
|
|
108
|
-
mockCookies.mockReset().mockResolvedValue({ toString: () => "" });
|
|
109
|
-
mockMessageFile.mockReset().mockResolvedValue(fileResult());
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
afterAll(() => {
|
|
113
|
-
process.env = ENV;
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe("the member file read on a spoke that signs in through its hub", () => {
|
|
117
|
-
it("reads the file with the caller's own credential and re-serves it with all five headers unchanged", async () => {
|
|
118
|
-
signedIn();
|
|
119
|
-
const res = await get();
|
|
120
|
-
expect(mockMessageFile).toHaveBeenCalledWith(ID, {
|
|
121
|
-
headers: { authorization: `Bearer ${CREDENTIAL}` },
|
|
122
|
-
});
|
|
123
|
-
expect(res.status).toBe(200);
|
|
124
|
-
expect(res.headers.get("content-type")).toBe(FILE_HEADERS.contentType);
|
|
125
|
-
expect(res.headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
|
|
126
|
-
expect(res.headers.get("x-content-type-options")).toBe(FILE_HEADERS.contentTypeOptions);
|
|
127
|
-
expect(res.headers.get("content-security-policy")).toBe(FILE_HEADERS.contentSecurityPolicy);
|
|
128
|
-
expect(res.headers.get("cache-control")).toBe(FILE_HEADERS.cacheControl);
|
|
129
|
-
await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it.each(Object.keys(FILE_HEADERS) as (keyof typeof FILE_HEADERS)[])(
|
|
133
|
-
"refuses 502 with no bytes when the hub's answer lacks %s",
|
|
134
|
-
async (name) => {
|
|
135
|
-
signedIn();
|
|
136
|
-
const result = fileResult({ [name]: null });
|
|
137
|
-
const cancel = jest.spyOn(result.body.stream as ReadableStream, "cancel");
|
|
138
|
-
mockMessageFile.mockResolvedValue(result);
|
|
139
|
-
const refused = await get();
|
|
140
|
-
expect(refused.status).toBe(502);
|
|
141
|
-
expect(cancel).toHaveBeenCalled();
|
|
142
|
-
expect(refused.headers.get("cache-control")).toBe("private, no-store");
|
|
143
|
-
expect(refused.headers.get("content-disposition")).toBeNull();
|
|
144
|
-
await expect(refused.text()).resolves.toBe("");
|
|
145
|
-
},
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
it("signed out, the read goes with no credential and its refusal answers 401", async () => {
|
|
149
|
-
mockMessageFile.mockResolvedValue({
|
|
150
|
-
ok: false,
|
|
151
|
-
status: 0,
|
|
152
|
-
body: { ok: false, error: { code: "unauthorized", message: "No usable credential" } },
|
|
153
|
-
});
|
|
154
|
-
const res = await get();
|
|
155
|
-
expect(mockMessageFile).toHaveBeenCalledWith(ID, { headers: {} });
|
|
156
|
-
expect(res.status).toBe(401);
|
|
157
|
-
expect(res.headers.get("cache-control")).toBe("private, no-store");
|
|
158
|
-
await expect(res.text()).resolves.toBe("");
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it.each([
|
|
162
|
-
[404, 404],
|
|
163
|
-
[401, 401],
|
|
164
|
-
[403, 403],
|
|
165
|
-
[429, 429],
|
|
166
|
-
[500, 502],
|
|
167
|
-
[503, 502],
|
|
168
|
-
])("a hub %i answers %i, with no body", async (hubStatus, status) => {
|
|
169
|
-
signedIn();
|
|
170
|
-
mockMessageFile.mockResolvedValue({
|
|
171
|
-
ok: false,
|
|
172
|
-
status: hubStatus,
|
|
173
|
-
body: { ok: false, error: { code: "x", message: "x" } },
|
|
174
|
-
});
|
|
175
|
-
const res = await get();
|
|
176
|
-
expect(res.status).toBe(status);
|
|
177
|
-
expect(res.headers.get("cache-control")).toBe("private, no-store");
|
|
178
|
-
await expect(res.text()).resolves.toBe("");
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it("an API base the api-client refuses (insecure_transport) answers 502", async () => {
|
|
182
|
-
signedIn();
|
|
183
|
-
mockMessageFile.mockResolvedValue({
|
|
184
|
-
ok: false,
|
|
185
|
-
status: 0,
|
|
186
|
-
body: { ok: false, error: { code: "insecure_transport", message: "x" } },
|
|
187
|
-
});
|
|
188
|
-
expect((await get()).status).toBe(502);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("a hub call that throws (network failure, a redirect under redirect: error) answers 502 with no body", async () => {
|
|
192
|
-
signedIn();
|
|
193
|
-
mockMessageFile.mockRejectedValue(new TypeError("fetch failed"));
|
|
194
|
-
const res = await get();
|
|
195
|
-
expect(res.status).toBe(502);
|
|
196
|
-
expect(res.headers.get("cache-control")).toBe("private, no-store");
|
|
197
|
-
await expect(res.text()).resolves.toBe("");
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
describe("on a single site — its own sign-in (#8231 D9)", () => {
|
|
202
|
-
it("reads the file with the caller's session cookie and serves it with all five headers unchanged", async () => {
|
|
203
|
-
mockProvider.value = "site";
|
|
204
|
-
mockCookies.mockResolvedValue({ toString: () => "session=abc" });
|
|
205
|
-
const res = await get();
|
|
206
|
-
expect(mockMessageFile).toHaveBeenCalledWith(ID, { headers: { cookie: "session=abc" } });
|
|
207
|
-
expect(res.status).toBe(200);
|
|
208
|
-
expect(res.headers.get("content-type")).toBe(FILE_HEADERS.contentType);
|
|
209
|
-
expect(res.headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
|
|
210
|
-
expect(res.headers.get("x-content-type-options")).toBe(FILE_HEADERS.contentTypeOptions);
|
|
211
|
-
expect(res.headers.get("content-security-policy")).toBe(FILE_HEADERS.contentSecurityPolicy);
|
|
212
|
-
expect(res.headers.get("cache-control")).toBe(FILE_HEADERS.cacheControl);
|
|
213
|
-
await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
|
|
214
|
-
});
|
|
215
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The member file read, re-served (#7920) — `GET /[locale]/account/inbox/message/:id/file`.
|
|
3
|
-
*
|
|
4
|
-
* A message's file action (the `message` Inbox kind, `lib/account-config.ts`)
|
|
5
|
-
* links here. The browser holds neither the client's hub credential (sealed in
|
|
6
|
-
* the `hub-session` cookie) nor this site's spoke key, so this route reads
|
|
7
|
-
* `GET /v1/member/messages/:id/file` with `forwardedCookieInit()` — the
|
|
8
|
-
* caller's own credential, so a client only ever gets their own file — and
|
|
9
|
-
* streams the bytes back unread.
|
|
10
|
-
*
|
|
11
|
-
* SEC-7877-D (the obligation in `@working-theory/api-client`'s `member.ts`):
|
|
12
|
-
* the bytes go out with all five hub headers UNCHANGED — `Content-Type`,
|
|
13
|
-
* `Content-Disposition` (attachment), `X-Content-Type-Options: nosniff`, the
|
|
14
|
-
* sandbox `Content-Security-Policy` and `Cache-Control: private, no-store` —
|
|
15
|
-
* so the file is never a document on this origin and never cached on the way.
|
|
16
|
-
* A hub answer missing any of the five is refused 502 rather than served
|
|
17
|
-
* without it.
|
|
18
|
-
*
|
|
19
|
-
* On a single site the read carries the caller's session cookie; on a spoke
|
|
20
|
-
* that signs in through its hub, the client's hub credential (#8231 D9).
|
|
21
|
-
* A refusal has no body: no credential (signed out) is a 401, a hub 4xx keeps
|
|
22
|
-
* its status, and a hub 5xx, a transport the api-client refuses or a hub call
|
|
23
|
-
* that throws is a 502.
|
|
24
|
-
*/
|
|
25
|
-
import { member, type MemberFileHeaders } from "@working-theory/api-client";
|
|
26
|
-
|
|
27
|
-
import { forwardedCookieInit } from "../../../../../../../../lib/server-api";
|
|
28
|
-
|
|
29
|
-
interface Context {
|
|
30
|
-
params: Promise<{ locale: string; id: string }>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** The response header each of the five hub headers goes out under. */
|
|
34
|
-
const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
|
|
35
|
-
contentType: "Content-Type",
|
|
36
|
-
contentDisposition: "Content-Disposition",
|
|
37
|
-
contentTypeOptions: "X-Content-Type-Options",
|
|
38
|
-
contentSecurityPolicy: "Content-Security-Policy",
|
|
39
|
-
cacheControl: "Cache-Control",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function refusal(status: number): Response {
|
|
43
|
-
return new Response(null, { status, headers: { "Cache-Control": "private, no-store" } });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** The refusal's status, from the api-client's `{ ok: false, status, body }`. */
|
|
47
|
-
function refusalStatus(status: number, body: unknown): number {
|
|
48
|
-
if (status === 0) {
|
|
49
|
-
const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
|
|
50
|
-
return code === "unauthorized" ? 401 : 502;
|
|
51
|
-
}
|
|
52
|
-
return status >= 500 ? 502 : status;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 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/messages/:id/file
|
|
56
|
-
export async function GET(_request: Request, { params }: Context): Promise<Response> {
|
|
57
|
-
const { id } = await params;
|
|
58
|
-
|
|
59
|
-
// The api-client throws, rather than answering `{ ok: false }`, on a
|
|
60
|
-
// network failure or a redirect — that is a 502 too, never Next's own 500.
|
|
61
|
-
let res: Awaited<ReturnType<typeof member.messageFile>>;
|
|
62
|
-
try {
|
|
63
|
-
res = await member.messageFile(id, await forwardedCookieInit());
|
|
64
|
-
} catch {
|
|
65
|
-
return refusal(502);
|
|
66
|
-
}
|
|
67
|
-
if (!res.ok) return refusal(refusalStatus(res.status, res.body));
|
|
68
|
-
|
|
69
|
-
const { stream, headers } = res.body;
|
|
70
|
-
const out = new Headers();
|
|
71
|
-
for (const [key, name] of Object.entries(FILE_HEADER_NAMES) as [keyof MemberFileHeaders, string][]) {
|
|
72
|
-
const value = headers[key];
|
|
73
|
-
if (value === null) {
|
|
74
|
-
await stream.cancel();
|
|
75
|
-
return refusal(502);
|
|
76
|
-
}
|
|
77
|
-
out.set(name, value);
|
|
78
|
-
}
|
|
79
|
-
return new Response(stream, { status: 200, headers: out });
|
|
80
|
-
}
|
package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client"; // binds the shared composer to the member write and the route refresh
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* MemberThreadComposer — the member thread page's composer (#11152): the
|
|
5
|
-
* shared `ThreadComposer` (`@working-theory/templates/account`, the control
|
|
6
|
-
* the Admin's inbox thread shares) bound to `postThreadMessage` and to the
|
|
7
|
-
* router. A sent message refreshes the route, so the page's Server
|
|
8
|
-
* Components read the thread again and the new bubble appears with no
|
|
9
|
-
* reload (the New menu's own idiom after a post); a refusal shows the plain
|
|
10
|
-
* line its code maps to, with the body kept. Only strings cross to the
|
|
11
|
-
* client: the labels and the refusal lines, never the session.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { ThreadComposer, type ThreadComposerLabels } from "@working-theory/templates/account";
|
|
15
|
-
import { MESSAGE_BODY_MAX } from "@working-theory/validation";
|
|
16
|
-
import { useRouter } from "next/navigation";
|
|
17
|
-
import type { ReactElement } from "react";
|
|
18
|
-
|
|
19
|
-
import type { NewActionErrorCode } from "../../new-actions";
|
|
20
|
-
|
|
21
|
-
import { postThreadMessage } from "./thread-write";
|
|
22
|
-
|
|
23
|
-
export interface MemberThreadComposerProps {
|
|
24
|
-
labels: ThreadComposerLabels;
|
|
25
|
-
/** Each refusal code's plain line (`new.errors.*`). */
|
|
26
|
-
errors: Record<NewActionErrorCode, string>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function MemberThreadComposer({ labels, errors }: MemberThreadComposerProps): ReactElement {
|
|
30
|
-
const router = useRouter();
|
|
31
|
-
return (
|
|
32
|
-
<ThreadComposer
|
|
33
|
-
labels={labels}
|
|
34
|
-
maxLength={MESSAGE_BODY_MAX}
|
|
35
|
-
send={async (body) => {
|
|
36
|
-
const state = await postThreadMessage(body);
|
|
37
|
-
if (state.kind === "success") return { kind: "sent" };
|
|
38
|
-
return { kind: "refused", message: errors[state.kind === "error" ? state.code : "failed"] };
|
|
39
|
-
}}
|
|
40
|
-
onSent={() => router.refresh()}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
}
|