create-ailk 0.37.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +19 -12
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +12 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +73 -2
- package/dist/routes.d.ts +130 -0
- package/dist/routes.js +954 -0
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -2
- package/dist/site-roster.js +63 -21
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +105 -293
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +108 -10
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +26 -1
- package/dist/topology.js +273 -7
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +87 -23
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +100 -0
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +46 -29
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +51 -1
- package/templates/apps/web/jest.config.cjs +17 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +8 -836
- package/templates/apps/web/middleware.ts +15 -26
- package/templates/apps/web/next.config.mjs +35 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +49 -47
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
- package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
- package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
- package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
- package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
- package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
- package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
- package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
- package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
- package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
- package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
- package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
- package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
- package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
- package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
- package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
- package/templates/apps/web/lib/hub-session/config.ts +0 -110
- package/templates/apps/web/lib/hub-session/entry.ts +0 -238
- package/templates/apps/web/lib/hub-session/index.ts +0 -21
- package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
- package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
- package/templates/apps/web/lib/hub-session/seal.ts +0 -86
- package/templates/apps/web/lib/hub-session/session.ts +0 -298
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment node
|
|
3
|
-
*
|
|
4
|
-
* `confirmEmailAction` (#10820 D7) — the one place a sign-up link's nonce is
|
|
5
|
-
* spent. The per-visitor limit and the bot check run before any API call; the
|
|
6
|
-
* signed hop's answer picks the redirect; the nonce is in no redirect URL.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const mockRedirect = jest.fn((url: string) => {
|
|
10
|
-
throw new Error(`REDIRECT ${url}`);
|
|
11
|
-
});
|
|
12
|
-
jest.mock("next/navigation", () => ({
|
|
13
|
-
redirect: (url: string) => mockRedirect(url),
|
|
14
|
-
}));
|
|
15
|
-
jest.mock("next/headers", () => ({
|
|
16
|
-
headers: async () => new Headers(),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const mockRunBotCheck = jest.fn();
|
|
20
|
-
// eslint-disable-next-line no-restricted-syntax -- BotID is an external service boundary; lib/bot-check.ts is its one wrapper.
|
|
21
|
-
jest.mock("../../../../../lib/bot-check", () => ({
|
|
22
|
-
runBotCheck: (...args: unknown[]) => mockRunBotCheck(...args),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
const mockConfirmSignUpEmail = jest.fn();
|
|
26
|
-
// eslint-disable-next-line no-restricted-syntax -- the signed hop to apps/api is the HTTP boundary; lib/auth-email.ts's own suite pins its signing.
|
|
27
|
-
jest.mock("../../../../../lib/auth-email", () => ({
|
|
28
|
-
confirmSignUpEmail: (...args: unknown[]) => mockConfirmSignUpEmail(...args),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
import { __resetRateLimit } from "../../../../../src/lib/rate-limit";
|
|
32
|
-
import { confirmEmailAction } from "../actions";
|
|
33
|
-
|
|
34
|
-
const NONCE = "N".repeat(43);
|
|
35
|
-
|
|
36
|
-
async function redirectOf(nonce = NONCE): Promise<string> {
|
|
37
|
-
await expect(confirmEmailAction(nonce, "en")).rejects.toThrow(/^REDIRECT /);
|
|
38
|
-
const url = mockRedirect.mock.calls.at(-1)![0];
|
|
39
|
-
expect(url).not.toContain(nonce);
|
|
40
|
-
return url;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
jest.clearAllMocks();
|
|
45
|
-
__resetRateLimit();
|
|
46
|
-
mockRunBotCheck.mockResolvedValue("pass");
|
|
47
|
-
mockConfirmSignUpEmail.mockResolvedValue("verified");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe("confirmEmailAction (#10820 D7)", () => {
|
|
51
|
-
it.each(["verified", "already_verified"])(
|
|
52
|
-
"redirects to the verified card on %s",
|
|
53
|
-
async (outcome) => {
|
|
54
|
-
mockConfirmSignUpEmail.mockResolvedValue(outcome);
|
|
55
|
-
expect(await redirectOf()).toBe("/verify-email?confirmed=1");
|
|
56
|
-
expect(mockConfirmSignUpEmail).toHaveBeenCalledWith(NONCE);
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
it.each(["expired", "invalid", "failed"])(
|
|
61
|
-
"redirects to the expired-link card on %s",
|
|
62
|
-
async (outcome) => {
|
|
63
|
-
mockConfirmSignUpEmail.mockResolvedValue(outcome);
|
|
64
|
-
expect(await redirectOf()).toBe("/verify-email?error=invalid");
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
it("redirects to the expired-link card when the hop throws", async () => {
|
|
69
|
-
mockConfirmSignUpEmail.mockRejectedValue(new Error("boom"));
|
|
70
|
-
expect(await redirectOf()).toBe("/verify-email?error=invalid");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it.each(["bot", "unavailable"])(
|
|
74
|
-
"makes no API call when the bot check answers %s",
|
|
75
|
-
async (verdict) => {
|
|
76
|
-
mockRunBotCheck.mockResolvedValue(verdict);
|
|
77
|
-
expect(await redirectOf()).toBe("/verify-email?error=invalid");
|
|
78
|
-
expect(mockConfirmSignUpEmail).not.toHaveBeenCalled();
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
it("makes no API call once the visitor limit is spent", async () => {
|
|
83
|
-
// An unreadable address shares the unknown bucket, 10x the per-visitor 5.
|
|
84
|
-
for (let i = 0; i < 50; i += 1) await redirectOf();
|
|
85
|
-
mockConfirmSignUpEmail.mockClear();
|
|
86
|
-
expect(await redirectOf()).toBe("/verify-email?error=invalid");
|
|
87
|
-
expect(mockConfirmSignUpEmail).not.toHaveBeenCalled();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("redirects on the default locale for a locale outside the enabled set", async () => {
|
|
91
|
-
await expect(confirmEmailAction(NONCE, "/evil.example")).rejects.toThrow(/^REDIRECT /);
|
|
92
|
-
expect(mockRedirect).toHaveBeenLastCalledWith("/verify-email?confirmed=1");
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The sign-up confirm click (#10820 D7) — the one place a `/verify-email`
|
|
5
|
-
* link's nonce is spent.
|
|
6
|
-
*
|
|
7
|
-
* The page's GET renders a button and writes nothing, so a mail scanner or a
|
|
8
|
-
* link preview that fetches the link verifies nothing; only a person's POST
|
|
9
|
-
* reaches here. Before any API call it takes the per-visitor limit (5 per
|
|
10
|
-
* 10 minutes) and the bot check, because the API sees only this site's server
|
|
11
|
-
* address. Then the signed hop, `confirmSignUpEmail`, and a redirect: the
|
|
12
|
-
* verified card for `verified` and `already_verified`, the expired-link card
|
|
13
|
-
* for everything else. The nonce is never in either redirect URL, and never
|
|
14
|
-
* logged here.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { localeHref } from "@working-theory/ui";
|
|
18
|
-
import { headers } from "next/headers";
|
|
19
|
-
import { redirect } from "next/navigation";
|
|
20
|
-
|
|
21
|
-
import { confirmSignUpEmail } from "../../../../lib/auth-email";
|
|
22
|
-
import { runBotCheck } from "../../../../lib/bot-check";
|
|
23
|
-
import { takeVisitorLimit } from "../../../../src/lib/rate-limit";
|
|
24
|
-
|
|
25
|
-
const CONFIRM_LIMIT = 5;
|
|
26
|
-
const CONFIRM_WINDOW_MS = 10 * 60 * 1000;
|
|
27
|
-
const NO_HEADERS = { get: () => null };
|
|
28
|
-
|
|
29
|
-
async function confirmed(nonce: string): Promise<boolean> {
|
|
30
|
-
let requestHeaders: Awaited<ReturnType<typeof headers>> | undefined;
|
|
31
|
-
try {
|
|
32
|
-
requestHeaders = await headers();
|
|
33
|
-
} catch {
|
|
34
|
-
// No request scope to read — the shared unknown-visitor bucket.
|
|
35
|
-
}
|
|
36
|
-
const limit = takeVisitorLimit(
|
|
37
|
-
"verifyemail",
|
|
38
|
-
requestHeaders ?? NO_HEADERS,
|
|
39
|
-
CONFIRM_LIMIT,
|
|
40
|
-
CONFIRM_WINDOW_MS,
|
|
41
|
-
);
|
|
42
|
-
if (!limit.allowed) return false;
|
|
43
|
-
|
|
44
|
-
const bot = await runBotCheck({
|
|
45
|
-
source: "verify-email",
|
|
46
|
-
target: "confirmEmailAction",
|
|
47
|
-
scope: "write",
|
|
48
|
-
});
|
|
49
|
-
if (bot !== "pass") return false;
|
|
50
|
-
|
|
51
|
-
// `confirmSignUpEmail` never throws by contract; this guard keeps the
|
|
52
|
-
// action's own promise (a redirect, never a 500) if that ever changes.
|
|
53
|
-
try {
|
|
54
|
-
const outcome = await confirmSignUpEmail(nonce);
|
|
55
|
-
return outcome === "verified" || outcome === "already_verified";
|
|
56
|
-
} catch {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// The locale is a bound argument a direct call could set to anything, so the
|
|
62
|
-
// redirect's segment is checked against the build-time allowlist, never
|
|
63
|
-
// interpolated raw (the `checkout.actions.ts` idiom).
|
|
64
|
-
const DEFAULT_LOCALE = "en";
|
|
65
|
-
const ENABLED_LOCALES = (process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE).split(",");
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Bound by the page — `confirmEmailAction.bind(null, nonce, locale)` — so no
|
|
69
|
-
* hidden input carries the nonce; the form's own data is ignored.
|
|
70
|
-
*/
|
|
71
|
-
export async function confirmEmailAction(nonce: string, locale = "en"): Promise<never> {
|
|
72
|
-
const ok = await confirmed(nonce);
|
|
73
|
-
const safeLocale = ENABLED_LOCALES.includes(locale) ? locale : DEFAULT_LOCALE;
|
|
74
|
-
redirect(
|
|
75
|
-
localeHref(safeLocale, ok ? "/verify-email?confirmed=1" : "/verify-email?error=invalid"),
|
|
76
|
-
);
|
|
77
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `/[locale]/verify-email` — the check-your-email terminus (#5963, wired by
|
|
3
|
-
* #5962) and the sign-up confirm page (#10820 D7).
|
|
4
|
-
*
|
|
5
|
-
* Four states, in this precedence:
|
|
6
|
-
* - `?verify=<nonce>` → a confirm card holding ONE button. The GET writes
|
|
7
|
-
* nothing: the button posts to `confirmEmailAction`, bound
|
|
8
|
-
* to the nonce (no hidden input carries it), so a mail
|
|
9
|
-
* scanner or a link preview that fetches the link verifies
|
|
10
|
-
* nothing — only a person's click does.
|
|
11
|
-
* - `?confirmed=1` → the verified card, with the Sign in link.
|
|
12
|
-
* - `?error=…` → the same expired/invalid-link state `/reset-password`
|
|
13
|
-
* renders: the action's answer for an expired, unknown or
|
|
14
|
-
* refused confirm.
|
|
15
|
-
* - no query → the `sent` intent: this page states what just happened.
|
|
16
|
-
*
|
|
17
|
-
* The link is the API's single-use nonce (`services/email-verification.ts`):
|
|
18
|
-
* one confirm spends it, and it expires after 24 hours.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import { localeHref } from "@working-theory/ui";
|
|
22
|
-
import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
|
|
23
|
-
import { Button, Text } from "@working-theory/ui/primitives";
|
|
24
|
-
import type { Metadata } from "next";
|
|
25
|
-
import { getTranslations } from "next-intl/server";
|
|
26
|
-
import type { ReactElement } from "react";
|
|
27
|
-
|
|
28
|
-
import { siteLogo } from "../../../../lib/site-logo";
|
|
29
|
-
|
|
30
|
-
import { confirmEmailAction } from "./actions";
|
|
31
|
-
|
|
32
|
-
interface Props {
|
|
33
|
-
params: Promise<{ locale: string }>;
|
|
34
|
-
searchParams?: Promise<{
|
|
35
|
-
error?: string | string[];
|
|
36
|
-
verify?: string | string[];
|
|
37
|
-
confirmed?: string | string[];
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function firstValue(raw: string | string[] | undefined): string {
|
|
42
|
-
if (Array.isArray(raw)) return raw[0] ?? "";
|
|
43
|
-
return raw ?? "";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
47
|
-
const { locale } = await params;
|
|
48
|
-
const t = await getTranslations({ locale, namespace: "auth" });
|
|
49
|
-
return {
|
|
50
|
-
title: t("verifyEmailTitle"),
|
|
51
|
-
description: t("verifyEmailDescription"),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default async function VerifyEmailPage({
|
|
56
|
-
params,
|
|
57
|
-
searchParams,
|
|
58
|
-
}: Props): Promise<ReactElement> {
|
|
59
|
-
const { locale } = await params;
|
|
60
|
-
const t = await getTranslations({ locale, namespace: "auth" });
|
|
61
|
-
const signInHref = localeHref(locale, "/sign-in");
|
|
62
|
-
|
|
63
|
-
const query = searchParams ? await searchParams : {};
|
|
64
|
-
const error = firstValue(query.error);
|
|
65
|
-
const nonce = firstValue(query.verify);
|
|
66
|
-
|
|
67
|
-
if (nonce.length >= 1 && nonce.length <= 256) {
|
|
68
|
-
const labels: AuthCardLabels = {
|
|
69
|
-
sentHeading: t("confirmHeading"),
|
|
70
|
-
sentSubhead: t("confirmSubhead"),
|
|
71
|
-
backToSignIn: t("backToSignIn"),
|
|
72
|
-
};
|
|
73
|
-
return (
|
|
74
|
-
<div className="flex flex-col gap-4" data-testid="verify-email-page">
|
|
75
|
-
<div data-testid="verify-email-confirm">
|
|
76
|
-
<AuthCard
|
|
77
|
-
logo={siteLogo()}
|
|
78
|
-
intent="sent"
|
|
79
|
-
signInHref={signInHref}
|
|
80
|
-
labels={labels}
|
|
81
|
-
body={
|
|
82
|
-
<form
|
|
83
|
-
action={confirmEmailAction.bind(null, nonce, locale)}
|
|
84
|
-
className="flex flex-col gap-5 text-center"
|
|
85
|
-
>
|
|
86
|
-
<Text variant="body-sm" tone="muted">
|
|
87
|
-
{t("confirmBody")}
|
|
88
|
-
</Text>
|
|
89
|
-
<Button
|
|
90
|
-
type="submit"
|
|
91
|
-
size="big"
|
|
92
|
-
className="w-full"
|
|
93
|
-
data-testid="verify-email-confirm-button"
|
|
94
|
-
>
|
|
95
|
-
{t("confirmButton")}
|
|
96
|
-
</Button>
|
|
97
|
-
</form>
|
|
98
|
-
}
|
|
99
|
-
/>
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (firstValue(query.confirmed) === "1") {
|
|
106
|
-
const labels: AuthCardLabels = {
|
|
107
|
-
sentHeading: t("verifiedHeading"),
|
|
108
|
-
sentSubhead: t("verifiedSubhead"),
|
|
109
|
-
sentBody: t("verifiedBody"),
|
|
110
|
-
backToSignIn: t("backToSignIn"),
|
|
111
|
-
};
|
|
112
|
-
return (
|
|
113
|
-
<div className="flex flex-col gap-4" data-testid="verify-email-page">
|
|
114
|
-
<div data-testid="verify-email-confirmed">
|
|
115
|
-
<AuthCard logo={siteLogo()} intent="sent" signInHref={signInHref} labels={labels} />
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (error) {
|
|
122
|
-
const labels: AuthCardLabels = {
|
|
123
|
-
invitationHeading: t("verifyExpiredHeading"),
|
|
124
|
-
invitationSubhead: t("verifyExpiredSubhead"),
|
|
125
|
-
invitationBody: t("verifyExpiredBody"),
|
|
126
|
-
backToSignIn: t("backToSignIn"),
|
|
127
|
-
};
|
|
128
|
-
return (
|
|
129
|
-
<div className="flex flex-col gap-4" data-testid="verify-email-page">
|
|
130
|
-
<div data-testid="verify-token-error">
|
|
131
|
-
<AuthCard
|
|
132
|
-
logo={siteLogo()}
|
|
133
|
-
intent="invitation"
|
|
134
|
-
signInHref={signInHref}
|
|
135
|
-
labels={labels}
|
|
136
|
-
/>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const labels: AuthCardLabels = {
|
|
143
|
-
sentHeading: t("sentHeading"),
|
|
144
|
-
sentSubhead: t("sentSubhead"),
|
|
145
|
-
sentBody: t("sentBody"),
|
|
146
|
-
backToSignIn: t("backToSignIn"),
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<div className="flex flex-col gap-4" data-testid="verify-email-page">
|
|
151
|
-
<AuthCard logo={siteLogo()} intent="sent" signInHref={signInHref} labels={labels} />
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
}
|
package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Log out in AccountFrame (#8465).
|
|
3
|
-
*
|
|
4
|
-
* A spoke that signs in through its hub holds its session in the sealed
|
|
5
|
-
* hub-session cookie, which only `POST /api/hub-session/sign-out` clears
|
|
6
|
-
* (and which also revokes the hub credential); Better Auth's `signOut()` hits
|
|
7
|
-
* a route that spoke does not serve. The server layout hands the seam's
|
|
8
|
-
* `SIGN_OUT_ENDPOINT` down as `signOutEndpoint`:
|
|
9
|
-
*
|
|
10
|
-
* - with an endpoint, Log out POSTs it (same-origin), never calls Better
|
|
11
|
-
* Auth, and lands on the sign-in page once the answer is 2xx;
|
|
12
|
-
* - a refused or failed sign-out (403 on an Origin mismatch, 5xx, a
|
|
13
|
-
* rejected fetch) stays on the page, shows the translated error, and
|
|
14
|
-
* navigates nowhere — the cookie is still valid (#8467 review addendum);
|
|
15
|
-
* - without an endpoint (a hub or a single site) it calls Better Auth and
|
|
16
|
-
* routes home, as before.
|
|
17
|
-
*/
|
|
18
|
-
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
19
|
-
import type { ReactNode } from "react";
|
|
20
|
-
|
|
21
|
-
const mockSignOut = jest.fn();
|
|
22
|
-
jest.mock("better-auth/react", () => ({
|
|
23
|
-
__esModule: true,
|
|
24
|
-
createAuthClient: () => ({
|
|
25
|
-
signOut: (...args: unknown[]) => mockSignOut(...args),
|
|
26
|
-
}),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
const mockPush = jest.fn();
|
|
30
|
-
const mockRefresh = jest.fn();
|
|
31
|
-
jest.mock("next/navigation", () => ({
|
|
32
|
-
__esModule: true,
|
|
33
|
-
useRouter: () => ({ push: mockPush, refresh: mockRefresh }),
|
|
34
|
-
usePathname: () => "/account",
|
|
35
|
-
useSearchParams: () => new URLSearchParams(""),
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
jest.mock("@working-theory/templates/shells", () => ({
|
|
39
|
-
__esModule: true,
|
|
40
|
-
SignedInShell: ({
|
|
41
|
-
onSignOut,
|
|
42
|
-
children,
|
|
43
|
-
}: {
|
|
44
|
-
onSignOut: () => void;
|
|
45
|
-
children: ReactNode;
|
|
46
|
-
}) => (
|
|
47
|
-
<div>
|
|
48
|
-
<button type="button" data-testid="sign-out" onClick={onSignOut} />
|
|
49
|
-
{children}
|
|
50
|
-
</div>
|
|
51
|
-
),
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
jest.mock("@working-theory/templates/account", () => ({
|
|
55
|
-
__esModule: true,
|
|
56
|
-
ForYouPanel: () => null,
|
|
57
|
-
PhoneTabProvider: ({ children }: { children: ReactNode }) => children,
|
|
58
|
-
useForYouDismissed: () => [new Set<string>(), jest.fn()],
|
|
59
|
-
}));
|
|
60
|
-
|
|
61
|
-
import { AccountFrame, type AccountFrameProps } from "../account-frame";
|
|
62
|
-
|
|
63
|
-
const ENDPOINT = "/api/hub-session/sign-out";
|
|
64
|
-
const FAILED = "We couldn't log you out. You're still signed in; try again.";
|
|
65
|
-
const mockFetch = jest.fn();
|
|
66
|
-
|
|
67
|
-
function renderFrame(extra: Partial<AccountFrameProps> = {}): void {
|
|
68
|
-
render(
|
|
69
|
-
<AccountFrame
|
|
70
|
-
locale="en"
|
|
71
|
-
user={{ name: "Ada", email: "ada@example.com" }}
|
|
72
|
-
logo={null}
|
|
73
|
-
helpItems={[]}
|
|
74
|
-
// eslint-disable-next-line no-restricted-syntax -- partial fixture: the suite exercises only the sign-out form, so the full forYou/labels shapes are not built
|
|
75
|
-
forYou={{ items: [] } as unknown as AccountFrameProps["forYou"]}
|
|
76
|
-
labels={
|
|
77
|
-
// eslint-disable-next-line no-restricted-syntax -- partial fixture (see forYou above)
|
|
78
|
-
{
|
|
79
|
-
home: "Home",
|
|
80
|
-
signOutFailed: FAILED,
|
|
81
|
-
} as unknown as AccountFrameProps["labels"]
|
|
82
|
-
}
|
|
83
|
-
{...extra}
|
|
84
|
-
>
|
|
85
|
-
<p>page</p>
|
|
86
|
-
</AccountFrame>,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
beforeEach(() => {
|
|
91
|
-
jest.clearAllMocks();
|
|
92
|
-
globalThis.fetch = mockFetch.mockResolvedValue({ ok: true, status: 204 });
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("AccountFrame Log out — a spoke that signs in through its hub", () => {
|
|
96
|
-
it("POSTs the hub sign-out endpoint, never Better Auth, then lands on the sign-in page and refreshes", async () => {
|
|
97
|
-
renderFrame({ signOutEndpoint: ENDPOINT, signInHref: "/account" });
|
|
98
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
99
|
-
await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/account"));
|
|
100
|
-
expect(mockFetch).toHaveBeenCalledWith(ENDPOINT, {
|
|
101
|
-
method: "POST",
|
|
102
|
-
credentials: "same-origin",
|
|
103
|
-
});
|
|
104
|
-
expect(mockSignOut).not.toHaveBeenCalled();
|
|
105
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
106
|
-
expect(
|
|
107
|
-
screen.queryByTestId("account-sign-out-error"),
|
|
108
|
-
).not.toBeInTheDocument();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("falls back to the site home when no sign-in href is given", async () => {
|
|
112
|
-
renderFrame({ signOutEndpoint: ENDPOINT });
|
|
113
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
114
|
-
await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/"));
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it.each([
|
|
118
|
-
["a 403 (Origin mismatch)", { ok: false, status: 403 }],
|
|
119
|
-
["a 500", { ok: false, status: 500 }],
|
|
120
|
-
["a 404", { ok: false, status: 404 }],
|
|
121
|
-
])(
|
|
122
|
-
"%s stays on the page with the error and routes nowhere",
|
|
123
|
-
async (_label, response) => {
|
|
124
|
-
mockFetch.mockResolvedValue(response);
|
|
125
|
-
renderFrame({ signOutEndpoint: ENDPOINT, signInHref: "/account" });
|
|
126
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
127
|
-
expect(
|
|
128
|
-
await screen.findByTestId("account-sign-out-error"),
|
|
129
|
-
).toHaveTextContent(FAILED);
|
|
130
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
131
|
-
expect(mockRefresh).not.toHaveBeenCalled();
|
|
132
|
-
expect(mockSignOut).not.toHaveBeenCalled();
|
|
133
|
-
},
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
it("a rejected request stays on the page with the error and routes nowhere", async () => {
|
|
137
|
-
mockFetch.mockRejectedValue(new TypeError("network down"));
|
|
138
|
-
renderFrame({ signOutEndpoint: ENDPOINT, signInHref: "/account" });
|
|
139
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
140
|
-
expect(
|
|
141
|
-
await screen.findByTestId("account-sign-out-error"),
|
|
142
|
-
).toHaveTextContent(FAILED);
|
|
143
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
144
|
-
expect(mockRefresh).not.toHaveBeenCalled();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("a retry that succeeds clears the error and lands on the sign-in page", async () => {
|
|
148
|
-
mockFetch.mockResolvedValueOnce({ ok: false, status: 500 });
|
|
149
|
-
renderFrame({ signOutEndpoint: ENDPOINT, signInHref: "/account" });
|
|
150
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
151
|
-
await screen.findByTestId("account-sign-out-error");
|
|
152
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
153
|
-
await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/account"));
|
|
154
|
-
expect(
|
|
155
|
-
screen.queryByTestId("account-sign-out-error"),
|
|
156
|
-
).not.toBeInTheDocument();
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe("AccountFrame Log out — a hub or a single site", () => {
|
|
161
|
-
it.each([
|
|
162
|
-
["absent", {}],
|
|
163
|
-
["null", { signOutEndpoint: null }],
|
|
164
|
-
])(
|
|
165
|
-
"with the endpoint %s calls Better Auth, then routes home and refreshes",
|
|
166
|
-
async (_label, extra) => {
|
|
167
|
-
renderFrame(extra);
|
|
168
|
-
fireEvent.click(screen.getByTestId("sign-out"));
|
|
169
|
-
await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/"));
|
|
170
|
-
expect(mockSignOut).toHaveBeenCalledTimes(1);
|
|
171
|
-
expect(mockFetch).not.toHaveBeenCalled();
|
|
172
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
});
|