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,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The remembered-method cookie (#11095 D7, AC-6): it names one provider id
|
|
3
|
-
* and nothing else, and only an id the page offers parses.
|
|
4
|
-
*/
|
|
5
|
-
import {
|
|
6
|
-
REMEMBERED_METHOD_COOKIE,
|
|
7
|
-
parseRememberedMethod,
|
|
8
|
-
rememberMethod,
|
|
9
|
-
} from "../remembered-method";
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
document.cookie = `${REMEMBERED_METHOD_COOKIE}=; Max-Age=0; Path=/`;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe("parseRememberedMethod", () => {
|
|
16
|
-
it("answers an active google or github", () => {
|
|
17
|
-
expect(parseRememberedMethod("google", ["google", "github"])).toBe(
|
|
18
|
-
"google",
|
|
19
|
-
);
|
|
20
|
-
expect(parseRememberedMethod("github", ["github"])).toBe("github");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it.each([
|
|
24
|
-
[undefined, ["google"]],
|
|
25
|
-
["", ["google"]],
|
|
26
|
-
["evil", ["google"]],
|
|
27
|
-
["github", ["google"]],
|
|
28
|
-
["Google", ["google"]],
|
|
29
|
-
["google ", ["google"]],
|
|
30
|
-
] as const)("refuses %j with providers %j", (raw, providers) => {
|
|
31
|
-
expect(parseRememberedMethod(raw, [...providers])).toBeUndefined();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("rememberMethod", () => {
|
|
36
|
-
it("writes the provider id alone, and null clears it", () => {
|
|
37
|
-
expect(REMEMBERED_METHOD_COOKIE).toBe("ailk-sign-in-method");
|
|
38
|
-
rememberMethod("google");
|
|
39
|
-
expect(document.cookie).toBe("ailk-sign-in-method=google");
|
|
40
|
-
rememberMethod(null);
|
|
41
|
-
expect(document.cookie).toBe("");
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for `SignInCard`'s email sign-in link flow (#7435 § D8, AC-5).
|
|
3
|
-
*
|
|
4
|
-
* The card POSTs to Better Auth's `/sign-in/magic-link` through the shared
|
|
5
|
-
* client's `$fetch` (not the `magicLinkClient()` plugin, so no ESM-only module
|
|
6
|
-
* enters the client graph). Pinned here:
|
|
7
|
-
* - the request carries the typed email, `callbackURL` = `next`, and the
|
|
8
|
-
* `errorCallbackURL`;
|
|
9
|
-
* - a success shows the neutral sent state — never the address, never
|
|
10
|
-
* AuthCard's English "Follow the link we just sent" default;
|
|
11
|
-
* - a 429 lands `rateLimited` on the field; any other error, or a
|
|
12
|
-
* rejection, lands `failed`;
|
|
13
|
-
* - with `emailLink` false the card renders as before.
|
|
14
|
-
*/
|
|
15
|
-
import { render, screen } from "@testing-library/react";
|
|
16
|
-
import userEvent from "@testing-library/user-event";
|
|
17
|
-
|
|
18
|
-
const mockFetch = jest.fn();
|
|
19
|
-
const mockSocial = jest.fn();
|
|
20
|
-
jest.mock("better-auth/react", () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
createAuthClient: () => ({
|
|
23
|
-
signIn: {
|
|
24
|
-
social: (...args: unknown[]) => mockSocial(...args),
|
|
25
|
-
email: jest.fn(),
|
|
26
|
-
},
|
|
27
|
-
$fetch: (...args: unknown[]) => mockFetch(...args),
|
|
28
|
-
}),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
import { SignInCard, type SignInCardProps } from "../sign-in-card";
|
|
32
|
-
|
|
33
|
-
const EMAIL_LINK_LABELS = {
|
|
34
|
-
sentHeading: "Check your email",
|
|
35
|
-
sentSubhead: "Look for a message from this site.",
|
|
36
|
-
sentBody: "If an account uses that address, a sign-in link is on its way.",
|
|
37
|
-
backToSignIn: "Back to sign in",
|
|
38
|
-
failed: "We couldn't send a sign-in link. Try again.",
|
|
39
|
-
rateLimited: "Too many requests. Wait a minute, then try again.",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function props(overrides: Partial<SignInCardProps> = {}): SignInCardProps {
|
|
43
|
-
return {
|
|
44
|
-
providers: ["google"],
|
|
45
|
-
method: "sso",
|
|
46
|
-
next: "/account",
|
|
47
|
-
labels: { emailLinkSubmit: "Email me a sign-in link" },
|
|
48
|
-
notConfiguredSubhead: "Sign-in is not configured.",
|
|
49
|
-
errorLabels: { signInFailed: "Sign-in failed.", providerFailed: "Nope." },
|
|
50
|
-
emailLink: true,
|
|
51
|
-
errorCallbackURL: "/sign-in?next=%2Faccount",
|
|
52
|
-
signInHref: "/sign-in?next=%2Faccount",
|
|
53
|
-
emailLinkLabels: EMAIL_LINK_LABELS,
|
|
54
|
-
...overrides,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function requestLink(email = "member@example.com"): Promise<void> {
|
|
59
|
-
const user = userEvent.setup();
|
|
60
|
-
// #8790 D4 — one field, one action: the sign-in link is the card's own
|
|
61
|
-
// email field and primary, not a second form.
|
|
62
|
-
await user.type(screen.getByTestId("auth-email"), email);
|
|
63
|
-
await user.click(screen.getByTestId("auth-submit"));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Clears every cookie jsdom holds, so each case starts with none. */
|
|
67
|
-
function clearCookies(): void {
|
|
68
|
-
for (const pair of document.cookie.split(";")) {
|
|
69
|
-
const name = pair.split("=")[0]?.trim();
|
|
70
|
-
if (name) document.cookie = `${name}=; Max-Age=0; Path=/`;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
mockFetch.mockReset().mockResolvedValue({ data: { status: true }, error: null });
|
|
76
|
-
mockSocial.mockReset().mockResolvedValue({ data: {}, error: null });
|
|
77
|
-
clearCookies();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe("SignInCard — email sign-in link (#7435)", () => {
|
|
81
|
-
it("POSTs /sign-in/magic-link with the email, next and the errorCallbackURL", async () => {
|
|
82
|
-
render(<SignInCard {...props()} />);
|
|
83
|
-
await requestLink();
|
|
84
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
85
|
-
expect(mockFetch).toHaveBeenCalledWith("/sign-in/magic-link", {
|
|
86
|
-
method: "POST",
|
|
87
|
-
body: {
|
|
88
|
-
email: "member@example.com",
|
|
89
|
-
callbackURL: "/account",
|
|
90
|
-
errorCallbackURL: "/sign-in?next=%2Faccount",
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("shows the neutral sent state on success — no address, no AuthCard defaults", async () => {
|
|
96
|
-
render(<SignInCard {...props()} />);
|
|
97
|
-
await requestLink();
|
|
98
|
-
expect(
|
|
99
|
-
await screen.findByText(EMAIL_LINK_LABELS.sentHeading),
|
|
100
|
-
).toBeInTheDocument();
|
|
101
|
-
expect(screen.getByText(EMAIL_LINK_LABELS.sentSubhead)).toBeInTheDocument();
|
|
102
|
-
expect(screen.getByText(EMAIL_LINK_LABELS.sentBody)).toBeInTheDocument();
|
|
103
|
-
const back = screen.getByTestId("auth-footer-link");
|
|
104
|
-
expect(back).toHaveTextContent(EMAIL_LINK_LABELS.backToSignIn);
|
|
105
|
-
expect(back).toHaveAttribute("href", "/sign-in?next=%2Faccount");
|
|
106
|
-
expect(document.body.textContent).not.toContain("member@example.com");
|
|
107
|
-
expect(document.body.textContent).not.toContain("Follow the link we just sent");
|
|
108
|
-
expect(screen.queryByTestId("auth-submit")).toBeNull();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("lands rateLimited on the field for a 429", async () => {
|
|
112
|
-
mockFetch.mockResolvedValue({
|
|
113
|
-
data: null,
|
|
114
|
-
error: { status: 429, statusText: "Too Many Requests" },
|
|
115
|
-
});
|
|
116
|
-
render(<SignInCard {...props()} />);
|
|
117
|
-
await requestLink();
|
|
118
|
-
expect(
|
|
119
|
-
await screen.findByText(EMAIL_LINK_LABELS.rateLimited),
|
|
120
|
-
).toBeInTheDocument();
|
|
121
|
-
expect(screen.getByTestId("auth-submit")).toBeInTheDocument();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("lands failed on the field for any other error", async () => {
|
|
125
|
-
mockFetch.mockResolvedValue({
|
|
126
|
-
data: null,
|
|
127
|
-
error: { status: 400, statusText: "Bad Request" },
|
|
128
|
-
});
|
|
129
|
-
render(<SignInCard {...props()} />);
|
|
130
|
-
await requestLink();
|
|
131
|
-
expect(await screen.findByText(EMAIL_LINK_LABELS.failed)).toBeInTheDocument();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("lands failed on the field when the request rejects", async () => {
|
|
135
|
-
mockFetch.mockRejectedValue(new Error("network"));
|
|
136
|
-
render(<SignInCard {...props()} />);
|
|
137
|
-
await requestLink();
|
|
138
|
-
expect(await screen.findByText(EMAIL_LINK_LABELS.failed)).toBeInTheDocument();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("sends one request for a double submit while the first is in flight", async () => {
|
|
142
|
-
let resolve!: (v: unknown) => void;
|
|
143
|
-
mockFetch.mockReturnValue(new Promise((r) => (resolve = r)));
|
|
144
|
-
const user = userEvent.setup();
|
|
145
|
-
render(<SignInCard {...props()} />);
|
|
146
|
-
await user.type(screen.getByTestId("auth-email"), "member@example.com");
|
|
147
|
-
await user.click(screen.getByTestId("auth-submit"));
|
|
148
|
-
await user.click(screen.getByTestId("auth-submit"));
|
|
149
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
150
|
-
resolve({ data: { status: true }, error: null });
|
|
151
|
-
expect(await screen.findByText(EMAIL_LINK_LABELS.sentHeading)).toBeInTheDocument();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("renders the link notice above the card when given one", () => {
|
|
155
|
-
render(<SignInCard {...props({ linkNotice: "That link expired." })} />);
|
|
156
|
-
expect(screen.getByTestId("sign-in-link-notice")).toHaveTextContent(
|
|
157
|
-
"That link expired.",
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("renders the form alone, without the not-configured subhead, when it is the only method", () => {
|
|
162
|
-
render(<SignInCard {...props({ providers: [] })} />);
|
|
163
|
-
expect(screen.getByTestId("auth-email")).toBeInTheDocument();
|
|
164
|
-
expect(screen.getByTestId("auth-submit")).toHaveTextContent("Email me a sign-in link");
|
|
165
|
-
expect(screen.queryByText("Sign-in is not configured.")).toBeNull();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("renders no email-link form when emailLink is false", () => {
|
|
169
|
-
render(<SignInCard {...props({ emailLink: false, providers: [] })} />);
|
|
170
|
-
expect(screen.queryByTestId("auth-submit")).toBeNull();
|
|
171
|
-
expect(screen.getByText("Sign-in is not configured.")).toBeInTheDocument();
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// #11095 AC-6 (D7): the card remembers the provider a person launched, and a
|
|
176
|
-
// returning person sees that one first, the rest behind "Use another way".
|
|
177
|
-
describe("SignInCard — the remembered method (#11095 D7)", () => {
|
|
178
|
-
const LABELS = {
|
|
179
|
-
emailLinkSubmit: "Email me a sign-in link",
|
|
180
|
-
ssoPrefix: "Sign in with",
|
|
181
|
-
google: "Google",
|
|
182
|
-
github: "GitHub",
|
|
183
|
-
};
|
|
184
|
-
const leadProps = (overrides: Partial<SignInCardProps> = {}) =>
|
|
185
|
-
props({
|
|
186
|
-
method: "password",
|
|
187
|
-
providers: ["google", "github"],
|
|
188
|
-
labels: LABELS,
|
|
189
|
-
continueWith: "Continue with",
|
|
190
|
-
useAnotherWay: "Use another way",
|
|
191
|
-
...overrides,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it("writes the provider id before the provider launch is called", async () => {
|
|
195
|
-
const user = userEvent.setup();
|
|
196
|
-
let cookieAtLaunch = "";
|
|
197
|
-
mockSocial.mockImplementation(() => {
|
|
198
|
-
cookieAtLaunch = document.cookie;
|
|
199
|
-
return Promise.resolve({ data: {}, error: null });
|
|
200
|
-
});
|
|
201
|
-
render(<SignInCard {...leadProps()} />);
|
|
202
|
-
await user.click(screen.getByTestId("auth-social-google"));
|
|
203
|
-
expect(mockSocial).toHaveBeenCalledTimes(1);
|
|
204
|
-
expect(cookieAtLaunch).toContain("ailk-sign-in-method=google");
|
|
205
|
-
// It names the method only: no email, no user id, no time.
|
|
206
|
-
expect(document.cookie).toBe("ailk-sign-in-method=google");
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("an email-link request clears it", async () => {
|
|
210
|
-
document.cookie = "ailk-sign-in-method=google; Path=/";
|
|
211
|
-
render(<SignInCard {...leadProps({ method: "sso", providers: [] })} />);
|
|
212
|
-
await requestLink();
|
|
213
|
-
expect(document.cookie).not.toContain("ailk-sign-in-method");
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it("with a remembered provider: one Continue with button first, no email field, and Use another way", () => {
|
|
217
|
-
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
218
|
-
const lead = screen.getByTestId("auth-sso-google");
|
|
219
|
-
expect(lead).toHaveTextContent("Continue with Google");
|
|
220
|
-
expect(screen.getAllByRole("button")[0]).toBe(lead);
|
|
221
|
-
expect(screen.queryByTestId("auth-sso-github")).toBeNull();
|
|
222
|
-
expect(screen.queryByTestId("auth-email")).toBeNull();
|
|
223
|
-
expect(screen.queryByTestId("auth-password")).toBeNull();
|
|
224
|
-
expect(screen.getByTestId("sign-in-use-another-way")).toHaveTextContent(
|
|
225
|
-
"Use another way",
|
|
226
|
-
);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("Use another way restores the full card", async () => {
|
|
230
|
-
const user = userEvent.setup();
|
|
231
|
-
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
232
|
-
await user.click(screen.getByTestId("sign-in-use-another-way"));
|
|
233
|
-
expect(screen.getByTestId("auth-email")).toBeInTheDocument();
|
|
234
|
-
expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
|
|
235
|
-
expect(screen.getByTestId("auth-social-github")).toBeInTheDocument();
|
|
236
|
-
expect(screen.queryByTestId("auth-sso-google")).toBeNull();
|
|
237
|
-
expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("the lead button launches its provider", async () => {
|
|
241
|
-
const user = userEvent.setup();
|
|
242
|
-
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
243
|
-
await user.click(screen.getByTestId("auth-sso-google"));
|
|
244
|
-
expect(mockSocial).toHaveBeenCalledTimes(1);
|
|
245
|
-
expect(document.cookie).toBe("ailk-sign-in-method=google");
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("a failed launch from the lead button shows the provider error", async () => {
|
|
249
|
-
const user = userEvent.setup();
|
|
250
|
-
mockSocial.mockRejectedValueOnce(new Error("boom"));
|
|
251
|
-
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
252
|
-
await user.click(screen.getByTestId("auth-sso-google"));
|
|
253
|
-
expect(await screen.findByTestId("sign-in-provider-error")).toBeInTheDocument();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it("with no remembered provider the card renders as today", () => {
|
|
257
|
-
const { container: today } = render(
|
|
258
|
-
<SignInCard {...props({ method: "password", providers: ["google"], labels: LABELS })} />,
|
|
259
|
-
);
|
|
260
|
-
const before = today.innerHTML;
|
|
261
|
-
today.remove();
|
|
262
|
-
const { container } = render(<SignInCard {...leadProps({ providers: ["google"] })} />);
|
|
263
|
-
expect(container.innerHTML).toBe(before);
|
|
264
|
-
expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
|
|
265
|
-
});
|
|
266
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `?next=` sanitizer for the /sign-in page (#4984) — moved to
|
|
3
|
-
* `lib/next-path.ts` (#7894 D7) so the hub-session callback, which a spoke
|
|
4
|
-
* keeps when it drops this route group, shares it. Re-exported here so this
|
|
5
|
-
* group's importers are unchanged.
|
|
6
|
-
*
|
|
7
|
-
* `hrefWithNext` (#9912 D4) builds the /sign-in ↔ /sign-up toggle: it carries
|
|
8
|
-
* the page's validated `next` only when that is not the page's fallback, so a
|
|
9
|
-
* refused or absent `next` gives today's bare link.
|
|
10
|
-
*/
|
|
11
|
-
export { resolveNextPath } from "../../../../lib/next-path";
|
|
12
|
-
|
|
13
|
-
/** `href` with `?next=<next>` when `next` is not the page's fallback, else `href`. */
|
|
14
|
-
export function hrefWithNext(
|
|
15
|
-
href: string,
|
|
16
|
-
next: string,
|
|
17
|
-
fallback: string,
|
|
18
|
-
): string {
|
|
19
|
-
return next === fallback ? href : `${href}?next=${encodeURIComponent(next)}`;
|
|
20
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `/[locale]/sign-in` — the site's generic sign-in page (#4984).
|
|
3
|
-
*
|
|
4
|
-
* RSC: resolves the active providers from auth-env, the sign-in method
|
|
5
|
-
* (password when the email provider is active, else sso), the sanitised
|
|
6
|
-
* `?next=` return path, and the translated `signIn` labels — then renders the
|
|
7
|
-
* `SignInCard` client island.
|
|
8
|
-
*
|
|
9
|
-
* Email sign-in link (#7435 § D9): offered when auth-env reports
|
|
10
|
-
* "magic-link" — the predicate `auth.ts` registers the plugin on. A link that
|
|
11
|
-
* fails verification lands back here with Better Auth's `?error=`, which maps
|
|
12
|
-
* to FIXED copy; the raw value is never rendered.
|
|
13
|
-
*
|
|
14
|
-
* Hinted email (#8757 D9): a single `?email=` that `accountEmailHintSchema`
|
|
15
|
-
* accepts is the starting value of every email input of the card (an account
|
|
16
|
-
* link from a lead's thank-you or invite email). A refused or repeated value
|
|
17
|
-
* is dropped. Only a field's starting value — it signs no one in.
|
|
18
|
-
*
|
|
19
|
-
* Since #5963 the page lives in the `(auth)` route group — the URL is
|
|
20
|
-
* unchanged (a group contributes no path segment) but the frame is
|
|
21
|
-
* `AuthShell`, not the marketing Nav + Footer. The shell owns the 400px
|
|
22
|
-
* column; the card carries the site's mark (#8790 D3).
|
|
23
|
-
*
|
|
24
|
-
* The one card (#9662): "Sign in to <site>" (the name is the deployment's,
|
|
25
|
-
* read in `resolveSignInCardText`, never the request's), the "Don't have an
|
|
26
|
-
* account? Sign up" line to `/sign-up`, and the Terms + Privacy
|
|
27
|
-
* acknowledgement. The Sign up line carries the validated `next` (#9912 D4),
|
|
28
|
-
* so a buyer who switches to sign-up keeps the destination; a refused or
|
|
29
|
-
* absent `next` gives the bare `/sign-up`.
|
|
30
|
-
*
|
|
31
|
-
* Signed-in visitors are not redirected here — the Nav's "Your account" link
|
|
32
|
-
* is the affordance for them (#11095 D6).
|
|
33
|
-
*
|
|
34
|
-
* Remembered method (#11095 D7): the `ailk-sign-in-method` cookie, read here
|
|
35
|
-
* and parsed against the active providers (`remembered-method.ts`), lets the
|
|
36
|
-
* card lead with the provider the person last launched. A value that does
|
|
37
|
-
* not parse is today's render.
|
|
38
|
-
*
|
|
39
|
-
* The spoke back link goes to the spoke's home (#11095 D5): its `/account`
|
|
40
|
-
* would start the hub sign-in again.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
import { hubSignIn } from "@working-theory/api-client";
|
|
44
|
-
import { localeHref } from "@working-theory/ui";
|
|
45
|
-
import { accountEmailHintSchema } from "@working-theory/validation";
|
|
46
|
-
import type { Metadata } from "next";
|
|
47
|
-
import { cookies } from "next/headers";
|
|
48
|
-
import { getTranslations } from "next-intl/server";
|
|
49
|
-
import type { ReactElement } from "react";
|
|
50
|
-
|
|
51
|
-
import {
|
|
52
|
-
getActiveProviderIds,
|
|
53
|
-
resetSendConfigured,
|
|
54
|
-
} from "../../../../lib/auth-env";
|
|
55
|
-
import { siteLogo } from "../../../../lib/site-logo";
|
|
56
|
-
import {
|
|
57
|
-
CONTINUE_PATH,
|
|
58
|
-
openContinuation,
|
|
59
|
-
} from "../../../api/auth/hub/continuation";
|
|
60
|
-
import { legalFootnote } from "../legal-footnote";
|
|
61
|
-
|
|
62
|
-
import { hrefWithNext, resolveNextPath } from "./next-path";
|
|
63
|
-
import {
|
|
64
|
-
REMEMBERED_METHOD_COOKIE,
|
|
65
|
-
parseRememberedMethod,
|
|
66
|
-
} from "./remembered-method";
|
|
67
|
-
import { SignInCard, type SignInProvider } from "./sign-in-card";
|
|
68
|
-
import { resolveSignInCardText, type SignInCardText } from "./sign-in-text";
|
|
69
|
-
|
|
70
|
-
interface Props {
|
|
71
|
-
params: Promise<{ locale: string }>;
|
|
72
|
-
searchParams: Promise<{
|
|
73
|
-
next?: string | string[];
|
|
74
|
-
error?: string | string[];
|
|
75
|
-
email?: string | string[];
|
|
76
|
-
}>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* #8757 D9 — the hinted email, read once: a repeated `?email=` (an array) or a
|
|
81
|
-
* value the hint schema refuses is dropped, never echoed.
|
|
82
|
-
*/
|
|
83
|
-
function hintedEmail(raw: string | string[] | undefined): string | undefined {
|
|
84
|
-
if (typeof raw !== "string") return undefined;
|
|
85
|
-
const parsed = accountEmailHintSchema.safeParse(raw);
|
|
86
|
-
return parsed.success ? parsed.data : undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Better Auth's magic-link verify redirects a failed link here with
|
|
91
|
-
* `?error=<code>`. Expired / used / account-gone map to the expired copy;
|
|
92
|
-
* anything else to the generic failure. Never the value itself.
|
|
93
|
-
*/
|
|
94
|
-
const EXPIRED_LINK_ERRORS: ReadonlySet<string> = new Set([
|
|
95
|
-
"INVALID_TOKEN",
|
|
96
|
-
"new_user_signup_disabled",
|
|
97
|
-
]);
|
|
98
|
-
|
|
99
|
-
function linkNoticeFor(
|
|
100
|
-
error: string | string[] | undefined,
|
|
101
|
-
text: SignInCardText,
|
|
102
|
-
): string | undefined {
|
|
103
|
-
if (error === undefined) return undefined;
|
|
104
|
-
const code = Array.isArray(error) ? error[0] : error;
|
|
105
|
-
return code !== undefined && EXPIRED_LINK_ERRORS.has(code)
|
|
106
|
-
? text.emailLinkExpired
|
|
107
|
-
: text.errorLabels.signInFailed;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* #11095 D7 — the raw remembered-method cookie. A read that throws (no
|
|
112
|
-
* request scope) is no cookie, so the card renders as today.
|
|
113
|
-
*/
|
|
114
|
-
async function rememberedCookie(): Promise<string | undefined> {
|
|
115
|
-
try {
|
|
116
|
-
return (await cookies()).get(REMEMBERED_METHOD_COOKIE)?.value;
|
|
117
|
-
} catch {
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
123
|
-
const { locale } = await params;
|
|
124
|
-
const t = await getTranslations({ locale, namespace: "signIn" });
|
|
125
|
-
return { title: t("title"), description: t("description") };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The spoke a hub sign-in continuation came from (#8790 D2), or `null`: not
|
|
130
|
-
* a continuation, a continuation that does not open (expired, forged), a
|
|
131
|
-
* client id the registry does not know, or no API. The spoke's identity is
|
|
132
|
-
* read from the registry by `client_id` — never from a query parameter.
|
|
133
|
-
*/
|
|
134
|
-
async function spokeFromNext(
|
|
135
|
-
next: string,
|
|
136
|
-
): Promise<{ name: string; origin: string } | null> {
|
|
137
|
-
const prefix = `${CONTINUE_PATH}/`;
|
|
138
|
-
if (!next.startsWith(prefix)) return null;
|
|
139
|
-
let query: string | null;
|
|
140
|
-
try {
|
|
141
|
-
// Lazy: `auth.ts` is Better Auth's server module. Only a continuation
|
|
142
|
-
// needs its secret, so a direct visit — and every test of one — never
|
|
143
|
-
// loads it (the `(authed)` gate takes the same care).
|
|
144
|
-
const { resolveSecret } = await import("../../../../auth");
|
|
145
|
-
query = openContinuation(next.slice(prefix.length), resolveSecret());
|
|
146
|
-
} catch {
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
if (query === null) return null;
|
|
150
|
-
const clientId = new URLSearchParams(query).get("client_id");
|
|
151
|
-
if (!clientId) return null;
|
|
152
|
-
try {
|
|
153
|
-
const result = await hubSignIn.clientInfo(clientId);
|
|
154
|
-
return result.ok
|
|
155
|
-
? { name: result.body.name, origin: result.body.origin }
|
|
156
|
-
: null;
|
|
157
|
-
} catch {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export default async function SignInPage({
|
|
163
|
-
params,
|
|
164
|
-
searchParams,
|
|
165
|
-
}: Props): Promise<ReactElement> {
|
|
166
|
-
const { locale } = await params;
|
|
167
|
-
const { next: rawNext, error, email: rawEmail } = await searchParams;
|
|
168
|
-
const text = await resolveSignInCardText(locale);
|
|
169
|
-
|
|
170
|
-
const active = getActiveProviderIds();
|
|
171
|
-
// Exactly the OAuth providers auth-env reports — never a default set.
|
|
172
|
-
const providers = active.filter(
|
|
173
|
-
(id): id is SignInProvider => id === "google" || id === "github",
|
|
174
|
-
);
|
|
175
|
-
const method = active.includes("email") ? "password" : "sso";
|
|
176
|
-
const emailLink = active.includes("magic-link");
|
|
177
|
-
const fallback = localeHref(locale, "/account");
|
|
178
|
-
const next = resolveNextPath(rawNext, fallback);
|
|
179
|
-
// A failed link returns here, keeping the visitor's destination.
|
|
180
|
-
const signInHref = `${localeHref(locale, "/sign-in")}?next=${encodeURIComponent(next)}`;
|
|
181
|
-
// Only the email link produces `?error=` here; with it off, today's render.
|
|
182
|
-
const linkNotice = emailLink ? linkNoticeFor(error, text) : undefined;
|
|
183
|
-
const defaultEmail = hintedEmail(rawEmail);
|
|
184
|
-
const remembered = parseRememberedMethod(await rememberedCookie(), providers);
|
|
185
|
-
|
|
186
|
-
const spoke = await spokeFromNext(next);
|
|
187
|
-
const t = await getTranslations({ locale, namespace: "signIn" });
|
|
188
|
-
return (
|
|
189
|
-
<SignInCard
|
|
190
|
-
logo={siteLogo()}
|
|
191
|
-
{...(spoke
|
|
192
|
-
? {
|
|
193
|
-
backLink: {
|
|
194
|
-
href: `${spoke.origin}/`,
|
|
195
|
-
label: t("backTo", { site: spoke.name }),
|
|
196
|
-
},
|
|
197
|
-
}
|
|
198
|
-
: {})}
|
|
199
|
-
prospect={{
|
|
200
|
-
...text.prospect,
|
|
201
|
-
href: hrefWithNext(localeHref(locale, "/sign-up"), next, fallback),
|
|
202
|
-
}}
|
|
203
|
-
footnote={legalFootnote(locale, text.acknowledgement)}
|
|
204
|
-
providers={providers}
|
|
205
|
-
method={method}
|
|
206
|
-
next={next}
|
|
207
|
-
// The "Forgot password?" link now has somewhere real to go (#5963);
|
|
208
|
-
// AuthCard's default is a dead "#".
|
|
209
|
-
forgotHref={localeHref(locale, "/forgot-password")}
|
|
210
|
-
// Hide it entirely when reset isn't wired server-side, rather than
|
|
211
|
-
// pointing at a page that renders its own not-available state (#6018).
|
|
212
|
-
// `resetSendConfigured()`, not the flag: /forgot-password keys on the
|
|
213
|
-
// send conjunction, so the flag alone would offer a link to a page
|
|
214
|
-
// rendering its own not-available card (#6068 AC-2).
|
|
215
|
-
forgot={resetSendConfigured() ? "link" : "none"}
|
|
216
|
-
labels={text.labels}
|
|
217
|
-
notConfiguredSubhead={text.notConfiguredSubhead}
|
|
218
|
-
errorLabels={text.errorLabels}
|
|
219
|
-
emailLink={emailLink}
|
|
220
|
-
errorCallbackURL={signInHref}
|
|
221
|
-
signInHref={signInHref}
|
|
222
|
-
{...(linkNotice !== undefined ? { linkNotice } : {})}
|
|
223
|
-
{...(defaultEmail !== undefined ? { defaultEmail } : {})}
|
|
224
|
-
emailLinkLabels={text.emailLinkLabels}
|
|
225
|
-
{...(remembered !== undefined
|
|
226
|
-
? {
|
|
227
|
-
remembered,
|
|
228
|
-
continueWith: text.continueWith,
|
|
229
|
-
useAnotherWay: text.useAnotherWay,
|
|
230
|
-
}
|
|
231
|
-
: {})}
|
|
232
|
-
/>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The remembered sign-in method (#11095 D7): one cookie naming the provider a
|
|
3
|
-
* person last launched on this card, so a returning person sees that one
|
|
4
|
-
* first. It names the method only — one of `google` or `github`, never an
|
|
5
|
-
* email, a user id or a time — and only reorders the card: it never changes
|
|
6
|
-
* who may sign in. An email method clears it, because the card already leads
|
|
7
|
-
* with the email field.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { SignInProvider } from "./sign-in-card";
|
|
11
|
-
|
|
12
|
-
export const REMEMBERED_METHOD_COOKIE = "ailk-sign-in-method";
|
|
13
|
-
|
|
14
|
-
/** One year, in seconds. */
|
|
15
|
-
const MAX_AGE_SECONDS = 31_536_000;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The remembered provider, only when the raw value is exactly `google` or
|
|
19
|
-
* `github` and is one of the page's active `providers`; otherwise `undefined`.
|
|
20
|
-
*/
|
|
21
|
-
export function parseRememberedMethod(
|
|
22
|
-
raw: string | undefined,
|
|
23
|
-
providers: readonly SignInProvider[],
|
|
24
|
-
): SignInProvider | undefined {
|
|
25
|
-
if (raw !== "google" && raw !== "github") return undefined;
|
|
26
|
-
return providers.includes(raw) ? raw : undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Browser only: remember `provider`, or clear the cookie with `null`. */
|
|
30
|
-
export function rememberMethod(provider: SignInProvider | null): void {
|
|
31
|
-
if (typeof document === "undefined") return;
|
|
32
|
-
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
33
|
-
document.cookie =
|
|
34
|
-
provider === null
|
|
35
|
-
? `${REMEMBERED_METHOD_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax${secure}`
|
|
36
|
-
: `${REMEMBERED_METHOD_COOKIE}=${provider}; Path=/; Max-Age=${MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
|
|
37
|
-
}
|