create-ailk 0.38.0 → 0.40.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/dist/add-route.js +16 -1
- package/dist/body-heading.d.ts +2 -1
- package/dist/body-heading.js +31 -3
- package/dist/derive-architecture.js +3 -1
- package/dist/module-architecture.js +0 -3
- package/dist/remove-module.js +27 -14
- package/dist/routes.d.ts +36 -2
- package/dist/routes.js +269 -23
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -3
- package/dist/site-roster.js +48 -22
- package/dist/surfaces.d.ts +13 -3
- package/dist/surfaces.js +128 -194
- package/dist/sync-routes.js +22 -5
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +11 -0
- package/dist/topology.js +253 -3
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +32 -4
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +6 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +6 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +2 -3
- 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 +1 -1
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +2 -2
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +13 -2
- package/templates/apps/web/jest.config.cjs +10 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +3 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/server-api.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/in-page-magnet.ts +2 -2
- package/templates/apps/web/lib/pricing-page.ts +3 -3
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +0 -271
- package/templates/apps/web/middleware.ts +12 -25
- package/templates/apps/web/next.config.mjs +15 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +85 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/tools/body-heading.ts +30 -3
- package/versions.json +50 -48
- 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/appointments/[slug]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -10
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
- package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
- package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
- package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
- package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
- package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
- package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
- package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
- package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
- package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
- package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
- package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
- package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
- package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
- package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
- package/templates/apps/web/app/[locale]/page.tsx +0 -147
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
- package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
- package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
- package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
- package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
- package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
- package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
- package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
- package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
- package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
- package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
- package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
- package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
- package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
- package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
- package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
- package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
- package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
- 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__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
- package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
- package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
- package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/hub-children.tsx +0 -351
- 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/meet-placeholder.ts +0 -5
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/lib/posting-title.ts +0 -39
- package/templates/apps/web/lib/route-family.ts +0 -69
- package/templates/apps/web/lib/service-listing.ts +0 -89
- package/templates/apps/web/lib/template-listing.ts +0 -169
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
- package/templates/apps/web/src/lib/lead-write.ts +0 -90
- /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment node
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The spoke's hub-session module (#7894 D7, D12, D13; spec
|
|
7
|
-
* docs/specs/7894-the-hub-signs-in-its-spec.md AC-5, AC-7, AC-8).
|
|
8
|
-
*
|
|
9
|
-
* Covers the sealed cookie (a value sealed under a key derived from the
|
|
10
|
-
* CLIENT secret never opens — AC-5), the configuration, the session read, the
|
|
11
|
-
* one request-init re-target `forwardedCookieInit()` makes on a hub-mode spoke
|
|
12
|
-
* (AC-7), and the buyer read that never trusts the cookie for a customer id
|
|
13
|
-
* (AC-8). The api-client's `hubSignIn` is the one external boundary mocked.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { createCipheriv, hkdfSync, randomBytes } from "node:crypto";
|
|
17
|
-
|
|
18
|
-
const mockMe = jest.fn();
|
|
19
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
20
|
-
__esModule: true,
|
|
21
|
-
hubSignIn: { me: (...args: unknown[]) => mockMe(...args) },
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
const mockHeaders = jest.fn();
|
|
25
|
-
jest.mock("next/headers", () => ({
|
|
26
|
-
__esModule: true,
|
|
27
|
-
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
28
|
-
cookies: jest.fn(),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
// 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.
|
|
32
|
-
jest.mock("../../topology.generated", () => ({
|
|
33
|
-
__esModule: true,
|
|
34
|
-
SIGN_IN_PROVIDER: "hub",
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
import { cookies } from "next/headers";
|
|
38
|
-
|
|
39
|
-
import { forwardedCookieInit } from "../../server-api";
|
|
40
|
-
import { hubSessionConfig } from "../config";
|
|
41
|
-
import { resealHubSession } from "../reseal";
|
|
42
|
-
import { seal, unseal } from "../seal";
|
|
43
|
-
import {
|
|
44
|
-
type HubSessionPayload,
|
|
45
|
-
hubNextPath,
|
|
46
|
-
hubSessionBuyer,
|
|
47
|
-
hubSessionInit,
|
|
48
|
-
readHubSession,
|
|
49
|
-
sessionCookieName,
|
|
50
|
-
} from "../session";
|
|
51
|
-
|
|
52
|
-
const ENV = process.env;
|
|
53
|
-
const SESSION_SECRET = "s".repeat(43);
|
|
54
|
-
const CLIENT_SECRET = `ailk_hcs_${"c".repeat(43)}`;
|
|
55
|
-
const CREDENTIAL = `ailk_hst_${"t".repeat(43)}`;
|
|
56
|
-
const COOKIE = "ailk-hub-session";
|
|
57
|
-
|
|
58
|
-
const USER = {
|
|
59
|
-
name: "Ada Lovelace",
|
|
60
|
-
email: "ada@example.com",
|
|
61
|
-
emailVerified: true,
|
|
62
|
-
createdAt: "2026-09-01T00:00:00.000Z",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
function configure(overrides: Record<string, string | undefined> = {}): void {
|
|
66
|
-
process.env = {
|
|
67
|
-
...ENV,
|
|
68
|
-
AILK_HUB_SIGN_IN_URL: "https://hub.example.com",
|
|
69
|
-
AILK_HUB_CLIENT_ID: "spoke_0001",
|
|
70
|
-
AILK_HUB_CLIENT_SECRET: CLIENT_SECRET,
|
|
71
|
-
AILK_HUB_SESSION_SECRET: SESSION_SECRET,
|
|
72
|
-
NEXT_PUBLIC_BASE_URL: "http://127.0.0.1:3100",
|
|
73
|
-
...overrides,
|
|
74
|
-
};
|
|
75
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
76
|
-
if (value === undefined) delete process.env[key];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function payload(overrides: Partial<HubSessionPayload> = {}): HubSessionPayload {
|
|
81
|
-
return {
|
|
82
|
-
v: 1,
|
|
83
|
-
accessToken: CREDENTIAL,
|
|
84
|
-
expiresAt: Date.now() + 60_000,
|
|
85
|
-
user: USER,
|
|
86
|
-
...overrides,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function headersWith(value: string, name = COOKIE): Headers {
|
|
91
|
-
return new Headers({ cookie: `other=1; ${name}=${value}` });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
beforeEach(() => {
|
|
95
|
-
configure();
|
|
96
|
-
mockMe.mockReset();
|
|
97
|
-
mockHeaders.mockReset();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
afterAll(() => {
|
|
101
|
-
process.env = ENV;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("seal", () => {
|
|
105
|
-
it("round-trips a value for the same secret, purpose and cookie name", () => {
|
|
106
|
-
const sealed = seal({ a: 1 }, SESSION_SECRET, "session", COOKIE);
|
|
107
|
-
expect(unseal(sealed, SESSION_SECRET, "session", COOKIE)).toEqual({ a: 1 });
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("opens nothing under another secret, purpose or cookie name, or altered", () => {
|
|
111
|
-
const sealed = seal({ a: 1 }, SESSION_SECRET, "session", COOKIE);
|
|
112
|
-
expect(unseal(sealed, "x".repeat(43), "session", COOKIE)).toBeNull();
|
|
113
|
-
expect(unseal(sealed, SESSION_SECRET, "flow", COOKIE)).toBeNull();
|
|
114
|
-
expect(unseal(sealed, SESSION_SECRET, "session", "ailk-hub-flow")).toBeNull();
|
|
115
|
-
const flipped = Buffer.from(sealed, "base64url");
|
|
116
|
-
flipped[flipped.length - 1] = (flipped[flipped.length - 1] ?? 0) ^ 1;
|
|
117
|
-
expect(unseal(flipped.toString("base64url"), SESSION_SECRET, "session", COOKIE)).toBeNull();
|
|
118
|
-
expect(unseal("", SESSION_SECRET, "session", COOKIE)).toBeNull();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// #8146 AC-4: the `continue` purpose was added to seal.ts. These two
|
|
122
|
-
// ciphertexts were sealed on `main` BEFORE that edit and committed as
|
|
123
|
-
// literals, so any change to INFO.session, INFO.flow or deriveKey fails
|
|
124
|
-
// here — the round trips above cannot see a key change (a changed key still
|
|
125
|
-
// round-trips with itself, and would silently log out every live spoke).
|
|
126
|
-
it("still opens a `session` value sealed before the `continue` purpose existed", () => {
|
|
127
|
-
const sealed =
|
|
128
|
-
"T0OSblxM1tRcJ4f5OP4VDvQA5TvWQdW3K_GvZlFzETSgVCw1tzEEaDWfAhHz0HZgY1sg8vA2fy0au73t";
|
|
129
|
-
expect(unseal(sealed, SESSION_SECRET, "session", COOKIE)).toEqual({
|
|
130
|
-
v: 1,
|
|
131
|
-
fixed: "session-vector",
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("still opens a `flow` value sealed before the `continue` purpose existed", () => {
|
|
136
|
-
const sealed =
|
|
137
|
-
"TI60LmvzNlRIp6a4BexFT9zmNoOWn8ZYBhW2VtOklk6lwUtrEWwtJ15XSJeAfgeNpSc322z-PWlZ";
|
|
138
|
-
expect(unseal(sealed, SESSION_SECRET, "flow", "ailk-hub-flow")).toEqual({
|
|
139
|
-
v: 1,
|
|
140
|
-
fixed: "flow-vector",
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("uses a fresh IV per seal", () => {
|
|
145
|
-
expect(seal({ a: 1 }, SESSION_SECRET, "session", COOKIE)).not.toBe(
|
|
146
|
-
seal({ a: 1 }, SESSION_SECRET, "session", COOKIE),
|
|
147
|
-
);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
describe("hubSessionConfig", () => {
|
|
152
|
-
it("reads the four variables and the site origin; the redirect URI is the site's, never a header's", () => {
|
|
153
|
-
expect(hubSessionConfig()).toEqual({
|
|
154
|
-
hubOrigin: "https://hub.example.com",
|
|
155
|
-
clientId: "spoke_0001",
|
|
156
|
-
clientSecret: CLIENT_SECRET,
|
|
157
|
-
sessionSecret: SESSION_SECRET,
|
|
158
|
-
siteOrigin: "http://127.0.0.1:3100",
|
|
159
|
-
redirectUri: "http://127.0.0.1:3100/api/hub-session/callback",
|
|
160
|
-
secure: false,
|
|
161
|
-
oneTap: false,
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// #11096 D10 — One Tap is on only for exactly `on`.
|
|
166
|
-
it.each([
|
|
167
|
-
["on", true],
|
|
168
|
-
["ON", false],
|
|
169
|
-
["1", false],
|
|
170
|
-
["", false],
|
|
171
|
-
])("AILK_HUB_ONE_TAP=%p reads oneTap %p", (value, expected) => {
|
|
172
|
-
configure({ AILK_HUB_ONE_TAP: value });
|
|
173
|
-
expect(hubSessionConfig()?.oneTap).toBe(expected);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("is secure on an https site", () => {
|
|
177
|
-
configure({ NEXT_PUBLIC_BASE_URL: "https://spoke.example.com/" });
|
|
178
|
-
expect(hubSessionConfig()).toMatchObject({
|
|
179
|
-
siteOrigin: "https://spoke.example.com",
|
|
180
|
-
secure: true,
|
|
181
|
-
});
|
|
182
|
-
expect(sessionCookieName({ secure: true })).toBe("__Host-ailk-hub-session");
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it.each([
|
|
186
|
-
["no hub origin", { AILK_HUB_SIGN_IN_URL: undefined }],
|
|
187
|
-
["an http hub off loopback", { AILK_HUB_SIGN_IN_URL: "http://hub.example.com" }],
|
|
188
|
-
["a hub URL with a path", { AILK_HUB_SIGN_IN_URL: "https://hub.example.com/x" }],
|
|
189
|
-
["no client id", { AILK_HUB_CLIENT_ID: undefined }],
|
|
190
|
-
["no client secret", { AILK_HUB_CLIENT_SECRET: undefined }],
|
|
191
|
-
["a short session secret", { AILK_HUB_SESSION_SECRET: "short" }],
|
|
192
|
-
["an http site off loopback", { NEXT_PUBLIC_BASE_URL: "http://spoke.example.com" }],
|
|
193
|
-
])("is null with %s", (_label, overrides) => {
|
|
194
|
-
configure(overrides);
|
|
195
|
-
expect(hubSessionConfig()).toBeNull();
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
describe("readHubSession", () => {
|
|
200
|
-
it("reads the person from a sealed, unexpired cookie", async () => {
|
|
201
|
-
const sealed = seal(payload(), SESSION_SECRET, "session", COOKIE);
|
|
202
|
-
await expect(readHubSession(headersWith(sealed))).resolves.toEqual({ user: USER });
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("reads null with no cookie, an expired one, or with no configuration", async () => {
|
|
206
|
-
await expect(readHubSession(new Headers())).resolves.toBeNull();
|
|
207
|
-
const expired = seal(payload({ expiresAt: Date.now() - 1 }), SESSION_SECRET, "session", COOKIE);
|
|
208
|
-
await expect(readHubSession(headersWith(expired))).resolves.toBeNull();
|
|
209
|
-
const sealed = seal(payload(), SESSION_SECRET, "session", COOKIE);
|
|
210
|
-
configure({ AILK_HUB_SESSION_SECRET: undefined });
|
|
211
|
-
await expect(readHubSession(headersWith(sealed))).resolves.toBeNull();
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("AC-5: a cookie sealed with a key derived from AILK_HUB_CLIENT_SECRET reads as null", async () => {
|
|
215
|
-
// Every way the client secret could have keyed the cookie: the module's own
|
|
216
|
-
// seal with the client secret as the session secret, and a raw HKDF of it.
|
|
217
|
-
const viaSeal = seal(payload(), CLIENT_SECRET, "session", COOKIE);
|
|
218
|
-
await expect(readHubSession(headersWith(viaSeal))).resolves.toBeNull();
|
|
219
|
-
|
|
220
|
-
const key = Buffer.from(hkdfSync("sha256", CLIENT_SECRET, Buffer.alloc(0), "ailk-hub-session/v1", 32));
|
|
221
|
-
const iv = randomBytes(12);
|
|
222
|
-
const cipher = createCipheriv("aes-256-gcm", key, iv);
|
|
223
|
-
cipher.setAAD(Buffer.from(COOKIE));
|
|
224
|
-
const body = Buffer.concat([cipher.update(JSON.stringify(payload())), cipher.final()]);
|
|
225
|
-
const forged = Buffer.concat([iv, cipher.getAuthTag(), body]).toString("base64url");
|
|
226
|
-
await expect(readHubSession(headersWith(forged))).resolves.toBeNull();
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("reads null for a well-sealed value of the wrong shape", async () => {
|
|
230
|
-
const sealed = seal({ v: 2, accessToken: CREDENTIAL }, SESSION_SECRET, "session", COOKIE);
|
|
231
|
-
await expect(readHubSession(headersWith(sealed))).resolves.toBeNull();
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe("AC-7 — forwardedCookieInit on a hub-mode spoke", () => {
|
|
236
|
-
it("is exactly the Bearer credential signed in", async () => {
|
|
237
|
-
const sealed = seal(payload(), SESSION_SECRET, "session", COOKIE);
|
|
238
|
-
mockHeaders.mockResolvedValue(headersWith(sealed));
|
|
239
|
-
await expect(forwardedCookieInit()).resolves.toEqual({
|
|
240
|
-
headers: { authorization: `Bearer ${CREDENTIAL}` },
|
|
241
|
-
});
|
|
242
|
-
await expect(hubSessionInit()).resolves.toEqual({
|
|
243
|
-
headers: { authorization: `Bearer ${CREDENTIAL}` },
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("is exactly no header signed out — never the visitor's cookie", async () => {
|
|
248
|
-
mockHeaders.mockResolvedValue(new Headers({ cookie: "better-auth.session_token=abc" }));
|
|
249
|
-
await expect(forwardedCookieInit()).resolves.toEqual({ headers: {} });
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
describe("AC-8 — hubSessionBuyer reads the customer live, never from the cookie", () => {
|
|
254
|
-
function request(cookie?: string): Request {
|
|
255
|
-
return new Request("http://127.0.0.1:3100/api/buy", {
|
|
256
|
-
headers: cookie === undefined ? {} : { cookie: `${COOKIE}=${cookie}` },
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
const signedIn = (): Request => request(seal(payload(), SESSION_SECRET, "session", COOKIE));
|
|
260
|
-
|
|
261
|
-
it("returns the customer /me vouches for, sending the credential", async () => {
|
|
262
|
-
mockMe.mockResolvedValue({ ok: true, body: { user: USER, billingCustomerId: "cus_known" } });
|
|
263
|
-
await expect(hubSessionBuyer(signedIn())).resolves.toEqual({ customerId: "cus_known" });
|
|
264
|
-
expect(mockMe).toHaveBeenCalledWith({ headers: { authorization: `Bearer ${CREDENTIAL}` } });
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it("is null with no session, without calling the hub", async () => {
|
|
268
|
-
await expect(hubSessionBuyer(request())).resolves.toBeNull();
|
|
269
|
-
expect(mockMe).not.toHaveBeenCalled();
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("is null when /me refuses the credential though the cookie is intact (a revoked credential)", async () => {
|
|
273
|
-
mockMe.mockResolvedValue({ ok: false, status: 401, body: null });
|
|
274
|
-
await expect(hubSessionBuyer(signedIn())).resolves.toBeNull();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it("is null when /me names no customer, or the read throws", async () => {
|
|
278
|
-
mockMe.mockResolvedValueOnce({ ok: true, body: { user: USER, billingCustomerId: null } });
|
|
279
|
-
await expect(hubSessionBuyer(signedIn())).resolves.toBeNull();
|
|
280
|
-
mockMe.mockRejectedValueOnce(new Error("network"));
|
|
281
|
-
await expect(hubSessionBuyer(signedIn())).resolves.toBeNull();
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
describe("hubNextPath", () => {
|
|
286
|
-
it.each([
|
|
287
|
-
["/account", "/account"],
|
|
288
|
-
["/fr/account/inbox?tab=x", "/fr/account/inbox?tab=x"],
|
|
289
|
-
["https://evil.example.com/", "/account"],
|
|
290
|
-
["//evil.example.com", "/account"],
|
|
291
|
-
["/api/hub-session/sign-out", "/account"],
|
|
292
|
-
["/api", "/account"],
|
|
293
|
-
["/en/../api/hub-session/sign-in?next=/account", "/account"],
|
|
294
|
-
["/%2e%2e/api/hub-session/sign-in", "/account"],
|
|
295
|
-
["/\u65e5\u672c", "/account"],
|
|
296
|
-
[null, "/account"],
|
|
297
|
-
])("%s → %s", (raw, expected) => {
|
|
298
|
-
expect(hubNextPath(raw)).toBe(expected);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
// #8232 D11 (spec docs/specs/8232-member-settings-account-general-and-spec.md
|
|
303
|
-
// AC-5) — after a member's profile save, the spoke re-seals its session from
|
|
304
|
-
// the hub's /me. Only `user` changes; the credential and its expiry are kept,
|
|
305
|
-
// so a re-seal never extends a session (SEC-8232-1), and the cookie is
|
|
306
|
-
// written with the attributes the callback writes at sign-in (SEC-8232-2).
|
|
307
|
-
describe("#8232 AC-5 — resealHubSession", () => {
|
|
308
|
-
const mockSet = jest.fn();
|
|
309
|
-
const RENAMED = { ...USER, name: "Ada King" };
|
|
310
|
-
|
|
311
|
-
beforeEach(() => {
|
|
312
|
-
mockSet.mockReset();
|
|
313
|
-
jest.mocked(cookies).mockResolvedValue({ set: mockSet } as never);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
function signedIn(overrides: Partial<HubSessionPayload> = {}, name = COOKIE): void {
|
|
317
|
-
mockHeaders.mockResolvedValue(headersWith(seal(payload(overrides), SESSION_SECRET, "session", name), name));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
it("re-seals the session with /me's person, keeping the credential and expiry, once, with the sign-in attributes", async () => {
|
|
321
|
-
const expiresAt = Date.now() + 60_000;
|
|
322
|
-
signedIn({ expiresAt });
|
|
323
|
-
mockMe.mockResolvedValue({ ok: true, body: { user: RENAMED, billingCustomerId: null } });
|
|
324
|
-
|
|
325
|
-
await expect(resealHubSession()).resolves.toBe("resealed");
|
|
326
|
-
|
|
327
|
-
expect(mockMe).toHaveBeenCalledTimes(1);
|
|
328
|
-
expect(mockMe).toHaveBeenCalledWith({ headers: { authorization: `Bearer ${CREDENTIAL}` } });
|
|
329
|
-
expect(mockSet).toHaveBeenCalledTimes(1);
|
|
330
|
-
const [name, value, options] = mockSet.mock.calls[0] as [string, string, Record<string, unknown>];
|
|
331
|
-
expect(name).toBe(COOKIE);
|
|
332
|
-
expect(options).toEqual({
|
|
333
|
-
httpOnly: true,
|
|
334
|
-
sameSite: "lax",
|
|
335
|
-
path: "/",
|
|
336
|
-
secure: false,
|
|
337
|
-
maxAge: expect.any(Number),
|
|
338
|
-
});
|
|
339
|
-
expect(options["maxAge"]).toBeGreaterThan(0);
|
|
340
|
-
expect(options["maxAge"]).toBeLessThanOrEqual(60);
|
|
341
|
-
expect(unseal(value, SESSION_SECRET, "session", COOKIE)).toEqual({
|
|
342
|
-
v: 1,
|
|
343
|
-
accessToken: CREDENTIAL,
|
|
344
|
-
expiresAt,
|
|
345
|
-
user: RENAMED,
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it("writes the __Host- cookie with Secure on an https site", async () => {
|
|
350
|
-
configure({ NEXT_PUBLIC_BASE_URL: "https://spoke.example.com" });
|
|
351
|
-
signedIn({}, "__Host-ailk-hub-session");
|
|
352
|
-
mockMe.mockResolvedValue({ ok: true, body: { user: RENAMED, billingCustomerId: null } });
|
|
353
|
-
|
|
354
|
-
await expect(resealHubSession()).resolves.toBe("resealed");
|
|
355
|
-
const [name, , options] = mockSet.mock.calls[0] as [string, string, Record<string, unknown>];
|
|
356
|
-
expect(name).toBe("__Host-ailk-hub-session");
|
|
357
|
-
expect(options).toMatchObject({ secure: true, httpOnly: true });
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it("is skipped with no configuration (a single site), calling neither /me nor set", async () => {
|
|
361
|
-
signedIn();
|
|
362
|
-
configure({ AILK_HUB_SESSION_SECRET: undefined });
|
|
363
|
-
await expect(resealHubSession()).resolves.toBe("skipped");
|
|
364
|
-
expect(mockMe).not.toHaveBeenCalled();
|
|
365
|
-
expect(mockSet).not.toHaveBeenCalled();
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it("is skipped with no session cookie, calling neither /me nor set", async () => {
|
|
369
|
-
mockHeaders.mockResolvedValue(new Headers());
|
|
370
|
-
await expect(resealHubSession()).resolves.toBe("skipped");
|
|
371
|
-
expect(mockMe).not.toHaveBeenCalled();
|
|
372
|
-
expect(mockSet).not.toHaveBeenCalled();
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it.each([
|
|
376
|
-
["a non-2xx", () => mockMe.mockResolvedValue({ ok: false, status: 401, body: null })],
|
|
377
|
-
["a throw", () => mockMe.mockRejectedValue(new Error("network"))],
|
|
378
|
-
[
|
|
379
|
-
"a user with a non-string email",
|
|
380
|
-
() => mockMe.mockResolvedValue({ ok: true, body: { user: { ...RENAMED, email: 42 }, billingCustomerId: null } }),
|
|
381
|
-
],
|
|
382
|
-
[
|
|
383
|
-
"a user with a non-boolean emailVerified",
|
|
384
|
-
() =>
|
|
385
|
-
mockMe.mockResolvedValue({ ok: true, body: { user: { ...RENAMED, emailVerified: "yes" }, billingCustomerId: null } }),
|
|
386
|
-
],
|
|
387
|
-
[
|
|
388
|
-
"a user with a non-string createdAt",
|
|
389
|
-
() => mockMe.mockResolvedValue({ ok: true, body: { user: { ...RENAMED, createdAt: 1 }, billingCustomerId: null } }),
|
|
390
|
-
],
|
|
391
|
-
[
|
|
392
|
-
"a user whose name is neither a string nor null",
|
|
393
|
-
() => mockMe.mockResolvedValue({ ok: true, body: { user: { ...RENAMED, name: 7 }, billingCustomerId: null } }),
|
|
394
|
-
],
|
|
395
|
-
])("fails on %s from /me and leaves the cookie as it is", async (_label, arrange) => {
|
|
396
|
-
signedIn();
|
|
397
|
-
arrange();
|
|
398
|
-
await expect(resealHubSession()).resolves.toBe("failed");
|
|
399
|
-
expect(mockSet).not.toHaveBeenCalled();
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it("is skipped when the session has under a second left, with no call and no write", async () => {
|
|
403
|
-
signedIn({ expiresAt: Date.now() + 500 });
|
|
404
|
-
await expect(resealHubSession()).resolves.toBe("skipped");
|
|
405
|
-
expect(mockMe).not.toHaveBeenCalled();
|
|
406
|
-
expect(mockSet).not.toHaveBeenCalled();
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it("fails, never throws, when the cookie write is refused", async () => {
|
|
410
|
-
signedIn();
|
|
411
|
-
mockMe.mockResolvedValue({ ok: true, body: { user: RENAMED, billingCustomerId: null } });
|
|
412
|
-
mockSet.mockImplementation(() => {
|
|
413
|
-
throw new Error("Cookies can only be modified in a Server Action or Route Handler");
|
|
414
|
-
});
|
|
415
|
-
await expect(resealHubSession()).resolves.toBe("failed");
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
describe("readBodyText (#11096) — the spoke's body read caps BYTES, not characters", () => {
|
|
420
|
-
const post = (body: string): Request =>
|
|
421
|
-
new Request("https://spoke.example/api/hub-session/email", { method: "POST", body });
|
|
422
|
-
|
|
423
|
-
it("reads a body within 8 KB", async () => {
|
|
424
|
-
const { readBodyText } = await import("../entry");
|
|
425
|
-
await expect(readBodyText(post("a".repeat(8_192)))).resolves.toBe("a".repeat(8_192));
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it("refuses a body under 8 K characters but over 8 KB of UTF-8", async () => {
|
|
429
|
-
const { readBodyText } = await import("../entry");
|
|
430
|
-
// 3 000 three-byte characters: 3 000 characters, 9 000 bytes.
|
|
431
|
-
await expect(readBodyText(post("€".repeat(3_000)))).resolves.toBeNull();
|
|
432
|
-
});
|
|
433
|
-
});
|