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,153 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* `/[locale]/flows/[slug]/verify` — a magnet Lead's confirm page (#10826,
|
|
4
|
-
* spec docs/specs/10826-the-four-conversions-as-completion-spec.md D5).
|
|
5
|
-
* `noindex`.
|
|
6
|
-
*
|
|
7
|
-
* Three states, in this precedence:
|
|
8
|
-
* - `?lead=<id>&verify=<nonce>` → a confirm card holding ONE button. The GET
|
|
9
|
-
* writes nothing and calls no API: the button posts to
|
|
10
|
-
* `confirmLeadEmailAction`, bound to the slug, the Lead id,
|
|
11
|
-
* the nonce and the locale (no hidden input carries them),
|
|
12
|
-
* so a mail scanner or a link preview that fetches the
|
|
13
|
-
* link verifies nothing — only a person's click does.
|
|
14
|
-
* - `?confirmed=1` → the verified card, with a link back to the magnet.
|
|
15
|
-
* - `?error=…`, or any other query → the expired-or-invalid card.
|
|
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. `lead` and `verify`
|
|
19
|
-
* are in both telemetry scrub lists.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { localeHref } from "@working-theory/ui";
|
|
23
|
-
import { AuthCard, type AuthCardLabels } from "@working-theory/ui/blocks";
|
|
24
|
-
import { Button, Text } from "@working-theory/ui/primitives";
|
|
25
|
-
import { flowSlugSchema } from "@working-theory/validation";
|
|
26
|
-
import type { Metadata } from "next";
|
|
27
|
-
import { notFound } from "next/navigation";
|
|
28
|
-
import { getTranslations } from "next-intl/server";
|
|
29
|
-
import type { ReactElement } from "react";
|
|
30
|
-
|
|
31
|
-
import { siteLogo } from "../../../../../lib/site-logo";
|
|
32
|
-
import { confirmLeadEmailAction } from "../verify.actions";
|
|
33
|
-
|
|
34
|
-
interface Props {
|
|
35
|
-
params: Promise<{ locale: string; slug: string }>;
|
|
36
|
-
searchParams?: Promise<{
|
|
37
|
-
lead?: string | string[];
|
|
38
|
-
verify?: string | string[];
|
|
39
|
-
confirmed?: string | string[];
|
|
40
|
-
error?: string | string[];
|
|
41
|
-
}>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const LEAD_ID_RE = /^lead_[0-9a-f-]{36}$/;
|
|
45
|
-
|
|
46
|
-
function firstValue(raw: string | string[] | undefined): string {
|
|
47
|
-
if (Array.isArray(raw)) return raw[0] ?? "";
|
|
48
|
-
return raw ?? "";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
52
|
-
const { locale } = await params;
|
|
53
|
-
const t = await getTranslations({ locale, namespace: "flowVerify" });
|
|
54
|
-
return { title: t("title"), robots: { index: false, follow: false } };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default async function FlowVerifyPage({
|
|
58
|
-
params,
|
|
59
|
-
searchParams,
|
|
60
|
-
}: Props): Promise<ReactElement> {
|
|
61
|
-
const { locale, slug } = await params;
|
|
62
|
-
if (!flowSlugSchema.safeParse(slug).success) notFound();
|
|
63
|
-
const t = await getTranslations({ locale, namespace: "flowVerify" });
|
|
64
|
-
const magnetHref = localeHref(locale, `/flows/${slug}`);
|
|
65
|
-
|
|
66
|
-
const query = searchParams ? await searchParams : {};
|
|
67
|
-
const leadId = firstValue(query.lead);
|
|
68
|
-
const nonce = firstValue(query.verify);
|
|
69
|
-
|
|
70
|
-
if (LEAD_ID_RE.test(leadId) && nonce.length >= 1 && nonce.length <= 256) {
|
|
71
|
-
const labels: AuthCardLabels = {
|
|
72
|
-
sentHeading: t("confirmHeading"),
|
|
73
|
-
sentSubhead: t("confirmSubhead"),
|
|
74
|
-
backToSignIn: t("back"),
|
|
75
|
-
};
|
|
76
|
-
return (
|
|
77
|
-
<div className="flex flex-col gap-4" data-testid="flow-verify-page">
|
|
78
|
-
<div data-testid="flow-verify-confirm">
|
|
79
|
-
<AuthCard
|
|
80
|
-
logo={siteLogo()}
|
|
81
|
-
intent="sent"
|
|
82
|
-
signInHref={magnetHref}
|
|
83
|
-
labels={labels}
|
|
84
|
-
body={
|
|
85
|
-
<form
|
|
86
|
-
action={confirmLeadEmailAction.bind(
|
|
87
|
-
null,
|
|
88
|
-
slug,
|
|
89
|
-
leadId,
|
|
90
|
-
nonce,
|
|
91
|
-
locale,
|
|
92
|
-
)}
|
|
93
|
-
className="flex flex-col gap-5 text-center"
|
|
94
|
-
>
|
|
95
|
-
<Text variant="body-sm" tone="muted">
|
|
96
|
-
{t("confirmBody")}
|
|
97
|
-
</Text>
|
|
98
|
-
<Button
|
|
99
|
-
type="submit"
|
|
100
|
-
size="big"
|
|
101
|
-
className="min-h-11 w-full"
|
|
102
|
-
data-testid="flow-verify-confirm-button"
|
|
103
|
-
>
|
|
104
|
-
{t("confirmButton")}
|
|
105
|
-
</Button>
|
|
106
|
-
</form>
|
|
107
|
-
}
|
|
108
|
-
/>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (firstValue(query.confirmed) === "1") {
|
|
115
|
-
const labels: AuthCardLabels = {
|
|
116
|
-
sentHeading: t("confirmedHeading"),
|
|
117
|
-
sentSubhead: t("confirmedSubhead"),
|
|
118
|
-
sentBody: t("confirmedBody"),
|
|
119
|
-
backToSignIn: t("back"),
|
|
120
|
-
};
|
|
121
|
-
return (
|
|
122
|
-
<div className="flex flex-col gap-4" data-testid="flow-verify-page">
|
|
123
|
-
<div data-testid="flow-verify-confirmed">
|
|
124
|
-
<AuthCard
|
|
125
|
-
logo={siteLogo()}
|
|
126
|
-
intent="sent"
|
|
127
|
-
signInHref={magnetHref}
|
|
128
|
-
labels={labels}
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const labels: AuthCardLabels = {
|
|
136
|
-
invitationHeading: t("errorHeading"),
|
|
137
|
-
invitationSubhead: t("errorSubhead"),
|
|
138
|
-
invitationBody: t("errorBody"),
|
|
139
|
-
backToSignIn: t("back"),
|
|
140
|
-
};
|
|
141
|
-
return (
|
|
142
|
-
<div className="flex flex-col gap-4" data-testid="flow-verify-page">
|
|
143
|
-
<div data-testid="flow-verify-error">
|
|
144
|
-
<AuthCard
|
|
145
|
-
logo={siteLogo()}
|
|
146
|
-
intent="invitation"
|
|
147
|
-
signInHref={magnetHref}
|
|
148
|
-
labels={labels}
|
|
149
|
-
/>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
"use server";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* confirmLeadEmailAction — a person's confirm of a magnet Lead's emailed link
|
|
6
|
-
* (#10826, spec docs/specs/10826-the-four-conversions-as-completion-spec.md
|
|
7
|
-
* D5). The one place that link's nonce is spent.
|
|
8
|
-
*
|
|
9
|
-
* The page's GET (`verify/page.tsx`) renders a button and writes nothing, so a
|
|
10
|
-
* mail scanner or a link preview that fetches the link verifies nothing; only
|
|
11
|
-
* a person's POST reaches here. In order:
|
|
12
|
-
*
|
|
13
|
-
* 1. Every bound argument is re-validated (SEC-10826-6) — a direct call can
|
|
14
|
-
* set any of them: `slug` against `flowSlugSchema`, `leadId` against the
|
|
15
|
-
* id shape, `nonce` at 1–256 characters, `locale` against the enabled
|
|
16
|
-
* locales. A refusal makes no API call.
|
|
17
|
-
* 2. The per-visitor limit (5 per 10 minutes) and the bot check, before any
|
|
18
|
-
* API call, because the API sees only this site's server address.
|
|
19
|
-
* 3. `flows.verifyLead`, forwarding the visitor's address (SEC-10826-8).
|
|
20
|
-
* 4. A redirect: a `user` magnet's verified Lead to the sign-up landing
|
|
21
|
-
* (`accountInviteHref`), a `lead-link` landing when it is a plain
|
|
22
|
-
* site-relative path (SEC-10826-5), else the confirmed card; everything
|
|
23
|
-
* else to the error card.
|
|
24
|
-
*
|
|
25
|
-
* The nonce is never in a redirect URL and never logged here. No MCP twin
|
|
26
|
-
* (`WEB_ONLY_ACTIONS` in `apps/mcp/__tests__/parity.test.ts`): it spends an
|
|
27
|
-
* address credential only the mailbox holder has.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import { flows } from "@working-theory/api-client";
|
|
31
|
-
import { localeHref } from "@working-theory/ui";
|
|
32
|
-
import { flowSlugSchema } from "@working-theory/validation";
|
|
33
|
-
import { headers } from "next/headers";
|
|
34
|
-
import { redirect } from "next/navigation";
|
|
35
|
-
|
|
36
|
-
import { accountInviteHref } from "../../../../lib/account-invite";
|
|
37
|
-
import { runBotCheck } from "../../../../lib/bot-check";
|
|
38
|
-
import { takeVisitorLimit } from "../../../../src/lib/rate-limit";
|
|
39
|
-
|
|
40
|
-
const CONFIRM_LIMIT = 5;
|
|
41
|
-
const CONFIRM_WINDOW_MS = 10 * 60 * 1000;
|
|
42
|
-
const NO_HEADERS = { get: () => null };
|
|
43
|
-
|
|
44
|
-
const LEAD_ID_RE = /^lead_[0-9a-f-]{36}$/;
|
|
45
|
-
const NONCE_MAX = 256;
|
|
46
|
-
|
|
47
|
-
const DEFAULT_LOCALE = "en";
|
|
48
|
-
const ENABLED_LOCALES = (
|
|
49
|
-
process.env.NEXT_PUBLIC_ENABLED_LOCALES ?? DEFAULT_LOCALE
|
|
50
|
-
).split(",");
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* SEC-10826-5 — a landing is followed only when it is one `/` followed by
|
|
54
|
-
* neither `/` nor a backslash, with no backslash anywhere: a site-relative
|
|
55
|
-
* path, never `//host`, `/\host` or an absolute URL.
|
|
56
|
-
*/
|
|
57
|
-
function isSitePath(landing: string): boolean {
|
|
58
|
-
// One leading `/`, then no `/` or backslash; no backslash, whitespace or
|
|
59
|
-
// control character anywhere — a browser strips TAB/CR/LF, so `/\t/host`
|
|
60
|
-
// would otherwise become `//host` (security review, #10826).
|
|
61
|
-
return /^\/(?![/\\])[^\\\s\p{Cc}]*$/u.test(landing);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
type Answer = { kind: "confirmed"; to: string | null } | { kind: "refused" };
|
|
65
|
-
|
|
66
|
-
async function confirm(
|
|
67
|
-
slug: string,
|
|
68
|
-
leadId: string,
|
|
69
|
-
nonce: string,
|
|
70
|
-
locale: string,
|
|
71
|
-
): Promise<Answer> {
|
|
72
|
-
let requestHeaders: Awaited<ReturnType<typeof headers>> | undefined;
|
|
73
|
-
try {
|
|
74
|
-
requestHeaders = await headers();
|
|
75
|
-
} catch {
|
|
76
|
-
// No request scope to read — the shared unknown-visitor bucket.
|
|
77
|
-
}
|
|
78
|
-
const limit = takeVisitorLimit(
|
|
79
|
-
"flowverify",
|
|
80
|
-
requestHeaders ?? NO_HEADERS,
|
|
81
|
-
CONFIRM_LIMIT,
|
|
82
|
-
CONFIRM_WINDOW_MS,
|
|
83
|
-
);
|
|
84
|
-
if (!limit.allowed) return { kind: "refused" };
|
|
85
|
-
|
|
86
|
-
const bot = await runBotCheck({
|
|
87
|
-
source: "flow-verify",
|
|
88
|
-
target: "confirmLeadEmailAction",
|
|
89
|
-
scope: "write",
|
|
90
|
-
});
|
|
91
|
-
if (bot !== "pass") return { kind: "refused" };
|
|
92
|
-
|
|
93
|
-
const visitorIp =
|
|
94
|
-
requestHeaders?.get("x-forwarded-for") ?? requestHeaders?.get("x-real-ip");
|
|
95
|
-
try {
|
|
96
|
-
const res = visitorIp
|
|
97
|
-
? await flows.verifyLead(
|
|
98
|
-
slug,
|
|
99
|
-
{ leadId, nonce },
|
|
100
|
-
{ headers: { "x-forwarded-for": visitorIp } },
|
|
101
|
-
)
|
|
102
|
-
: await flows.verifyLead(slug, { leadId, nonce });
|
|
103
|
-
if (!res.ok) return { kind: "refused" };
|
|
104
|
-
const { outcome, landing, signUpEmail } = res.body;
|
|
105
|
-
if (outcome !== "verified" && outcome !== "already_verified")
|
|
106
|
-
return { kind: "refused" };
|
|
107
|
-
if (typeof signUpEmail === "string") {
|
|
108
|
-
const href = accountInviteHref(locale, signUpEmail);
|
|
109
|
-
if (href !== null) return { kind: "confirmed", to: href };
|
|
110
|
-
}
|
|
111
|
-
if (typeof landing === "string" && isSitePath(landing)) {
|
|
112
|
-
return { kind: "confirmed", to: localeHref(locale, landing) };
|
|
113
|
-
}
|
|
114
|
-
return { kind: "confirmed", to: null };
|
|
115
|
-
} catch {
|
|
116
|
-
return { kind: "refused" };
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Bound by the page — `confirmLeadEmailAction.bind(null, slug, leadId, nonce,
|
|
122
|
-
* locale)` — so no hidden input carries the nonce; the form's own data is
|
|
123
|
-
* ignored.
|
|
124
|
-
*/
|
|
125
|
-
export async function confirmLeadEmailAction(
|
|
126
|
-
slug: string,
|
|
127
|
-
leadId: string,
|
|
128
|
-
nonce: string,
|
|
129
|
-
locale = DEFAULT_LOCALE,
|
|
130
|
-
): Promise<never> {
|
|
131
|
-
const slugOk = flowSlugSchema.safeParse(slug).success;
|
|
132
|
-
const localeOk = ENABLED_LOCALES.includes(locale);
|
|
133
|
-
const safeLocale = localeOk ? locale : DEFAULT_LOCALE;
|
|
134
|
-
// An unreadable slug has no confirm page of its own to land on.
|
|
135
|
-
const page = slugOk ? `/flows/${slug}/verify` : "/";
|
|
136
|
-
const errorHref = localeHref(safeLocale, `${page}?error=invalid`);
|
|
137
|
-
|
|
138
|
-
const argumentsOk =
|
|
139
|
-
slugOk &&
|
|
140
|
-
localeOk &&
|
|
141
|
-
typeof leadId === "string" &&
|
|
142
|
-
LEAD_ID_RE.test(leadId) &&
|
|
143
|
-
typeof nonce === "string" &&
|
|
144
|
-
nonce.length >= 1 &&
|
|
145
|
-
nonce.length <= NONCE_MAX;
|
|
146
|
-
if (!argumentsOk) redirect(errorHref);
|
|
147
|
-
|
|
148
|
-
const answer = await confirm(slug, leadId, nonce, safeLocale);
|
|
149
|
-
if (answer.kind === "refused") redirect(errorHref);
|
|
150
|
-
redirect(answer.to ?? localeHref(safeLocale, `${page}?confirmed=1`));
|
|
151
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
"use client"; // Reads sessionStorage (a browser API) once on mount — a server page cannot.
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* BookingHandOff — `/meet/confirmed`'s booked time and Slack next step
|
|
6
|
-
* (#9853 D10). The booker writes one `sessionStorage` item before it
|
|
7
|
-
* navigates here (`BOOKING_CONFIRMATION_STORAGE_KEY`); this reads it once and
|
|
8
|
-
* removes it, the read-once hand-off pattern, so the page's
|
|
9
|
-
* address carries nothing about the booking and a later visit shows nothing.
|
|
10
|
-
*
|
|
11
|
-
* It renders only an item written for this page (`to`'s path, without its
|
|
12
|
-
* query or hash, is `/meet/confirmed` or `/<locale>/meet/confirmed`) in the last ten
|
|
13
|
-
* minutes. The time is formatted in the zone Cal.com recorded, with the zone
|
|
14
|
-
* named, so the page and the Slack welcome name the same one; a zone `Intl`
|
|
15
|
-
* does not know renders nothing. Every string is a prop the server page read
|
|
16
|
-
* from the `schedule` namespace.
|
|
17
|
-
*/
|
|
18
|
-
import { Container, Heading, Text } from "@working-theory/ui";
|
|
19
|
-
import {
|
|
20
|
-
BOOKING_CONFIRMATION_STORAGE_KEY,
|
|
21
|
-
BookingConfirmationHandOffSchema,
|
|
22
|
-
} from "@working-theory/validation";
|
|
23
|
-
import type { ReactElement } from "react";
|
|
24
|
-
import { useEffect, useState } from "react";
|
|
25
|
-
|
|
26
|
-
/** A reserved name that never resolves: only used to read the path of `to`. */
|
|
27
|
-
const PLACEHOLDER_ORIGIN = "https://placeholder.invalid";
|
|
28
|
-
const CONFIRMED_PATH = "/meet/confirmed";
|
|
29
|
-
const MAX_AGE_MS = 10 * 60_000;
|
|
30
|
-
|
|
31
|
-
interface Props {
|
|
32
|
-
locale: string;
|
|
33
|
-
/** `schedule.confirmed.bookedTimeHeading`. */
|
|
34
|
-
bookedTimeHeading: string;
|
|
35
|
-
/** `schedule.confirmed.slackHeadline`. */
|
|
36
|
-
slackHeadline: string;
|
|
37
|
-
/** `schedule.confirmed.slackBody`. */
|
|
38
|
-
slackBody: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface Shown {
|
|
42
|
-
time: string;
|
|
43
|
-
slackOptIn: boolean;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Whether `to` names this page, with or without this page's `/<locale>`. */
|
|
47
|
-
function namesThisPage(to: string, locale: string): boolean {
|
|
48
|
-
let url: URL;
|
|
49
|
-
try {
|
|
50
|
-
url = new URL(to, PLACEHOLDER_ORIGIN);
|
|
51
|
-
} catch {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if (url.origin !== PLACEHOLDER_ORIGIN) return false;
|
|
55
|
-
return (
|
|
56
|
-
url.pathname === CONFIRMED_PATH ||
|
|
57
|
-
url.pathname === `/${locale}${CONFIRMED_PATH}`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Read the hand-off once, remove it, and answer what to show (or `null`). */
|
|
62
|
-
function takeHandOff(locale: string): Shown | null {
|
|
63
|
-
try {
|
|
64
|
-
const stored = window.sessionStorage.getItem(
|
|
65
|
-
BOOKING_CONFIRMATION_STORAGE_KEY,
|
|
66
|
-
);
|
|
67
|
-
if (stored === null) return null;
|
|
68
|
-
window.sessionStorage.removeItem(BOOKING_CONFIRMATION_STORAGE_KEY);
|
|
69
|
-
const parsed = BookingConfirmationHandOffSchema.safeParse(
|
|
70
|
-
JSON.parse(stored),
|
|
71
|
-
);
|
|
72
|
-
if (!parsed.success) return null;
|
|
73
|
-
const { to, savedAt, start, timeZone, slackOptIn } = parsed.data;
|
|
74
|
-
const age = Date.now() - savedAt;
|
|
75
|
-
if (!namesThisPage(to, locale) || age < 0 || age >= MAX_AGE_MS) return null;
|
|
76
|
-
const time = new Intl.DateTimeFormat(locale, {
|
|
77
|
-
weekday: "long",
|
|
78
|
-
month: "long",
|
|
79
|
-
day: "numeric",
|
|
80
|
-
hour: "numeric",
|
|
81
|
-
minute: "2-digit",
|
|
82
|
-
timeZone,
|
|
83
|
-
timeZoneName: "longGeneric",
|
|
84
|
-
}).format(new Date(start));
|
|
85
|
-
return { time, slackOptIn };
|
|
86
|
-
} catch {
|
|
87
|
-
// Unparseable JSON, refused storage, or a zone `Intl` does not know.
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function BookingHandOff({
|
|
93
|
-
locale,
|
|
94
|
-
bookedTimeHeading,
|
|
95
|
-
slackHeadline,
|
|
96
|
-
slackBody,
|
|
97
|
-
}: Props): ReactElement | null {
|
|
98
|
-
const [shown, setShown] = useState<Shown | null>(null);
|
|
99
|
-
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
// Only ever sets: React's development double-mount runs this twice, and
|
|
102
|
-
// the second run finds the item already removed.
|
|
103
|
-
const found = takeHandOff(locale);
|
|
104
|
-
if (found !== null) setShown(found);
|
|
105
|
-
}, [locale]);
|
|
106
|
-
|
|
107
|
-
if (shown === null) return null;
|
|
108
|
-
return (
|
|
109
|
-
<Container className="pt-block-loose">
|
|
110
|
-
<div role="status" data-testid="booking-hand-off">
|
|
111
|
-
<Heading level={2} visual={4}>
|
|
112
|
-
{bookedTimeHeading}
|
|
113
|
-
</Heading>
|
|
114
|
-
<Text className="mt-2">{shown.time}</Text>
|
|
115
|
-
{shown.slackOptIn && (
|
|
116
|
-
<>
|
|
117
|
-
<Heading level={2} visual={4} className="mt-block-tight">
|
|
118
|
-
{slackHeadline}
|
|
119
|
-
</Heading>
|
|
120
|
-
<Text tone="muted" className="mt-2">
|
|
121
|
-
{slackBody}
|
|
122
|
-
</Text>
|
|
123
|
-
</>
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
</Container>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* Tests for `/meet/confirmed`'s booking hand-off (#9853 D9, D10; AC-7).
|
|
4
|
-
*
|
|
5
|
-
* The booker hands this page the booked time, its zone and the Slack opt-in
|
|
6
|
-
* through one `sessionStorage` item, never the address. The component reads
|
|
7
|
-
* it once and removes it, and shows it only when it was written for this page
|
|
8
|
-
* in the last ten minutes, formatted in the zone Cal.com recorded — the
|
|
9
|
-
* prospect's, not the viewer's. Anything else renders nothing.
|
|
10
|
-
*/
|
|
11
|
-
import React from "react";
|
|
12
|
-
import { act, render, screen } from "@testing-library/react";
|
|
13
|
-
|
|
14
|
-
import { BookingHandOff } from "../BookingHandOff";
|
|
15
|
-
|
|
16
|
-
const STORAGE_KEY = "ailk:booking-confirmation";
|
|
17
|
-
const PROPS = {
|
|
18
|
-
locale: "en",
|
|
19
|
-
bookedTimeHeading: "copy:confirmed.bookedTimeHeading",
|
|
20
|
-
slackHeadline: "copy:confirmed.slackHeadline",
|
|
21
|
-
slackBody: "copy:confirmed.slackBody",
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function handOff(overrides: Record<string, unknown> = {}) {
|
|
25
|
-
return {
|
|
26
|
-
to: "/meet/confirmed",
|
|
27
|
-
savedAt: Date.now(),
|
|
28
|
-
start: "2026-10-30T20:00:00.000Z",
|
|
29
|
-
timeZone: "America/Denver",
|
|
30
|
-
slackOptIn: true,
|
|
31
|
-
...overrides,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function store(value: unknown): void {
|
|
36
|
-
window.sessionStorage.setItem(
|
|
37
|
-
STORAGE_KEY,
|
|
38
|
-
typeof value === "string" ? value : JSON.stringify(value),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function renderHandOff() {
|
|
43
|
-
let utils!: ReturnType<typeof render>;
|
|
44
|
-
await act(async () => {
|
|
45
|
-
utils = render(<BookingHandOff {...PROPS} />);
|
|
46
|
-
});
|
|
47
|
-
return utils;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
window.sessionStorage.clear();
|
|
52
|
-
window.history.replaceState(null, "", "/en/meet/confirmed");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe("<BookingHandOff/> (#9853 AC-7)", () => {
|
|
56
|
-
it("shows the booked time in the prospect's zone, named, and the Slack step; then forgets it", async () => {
|
|
57
|
-
store(handOff());
|
|
58
|
-
const { container } = await renderHandOff();
|
|
59
|
-
|
|
60
|
-
expect(screen.getByText(PROPS.bookedTimeHeading)).toBeInTheDocument();
|
|
61
|
-
expect(container.textContent).toContain("2:00");
|
|
62
|
-
expect(container.textContent).toContain("Mountain Time");
|
|
63
|
-
expect(screen.getByText(PROPS.slackHeadline)).toBeInTheDocument();
|
|
64
|
-
expect(screen.getByText(PROPS.slackBody)).toBeInTheDocument();
|
|
65
|
-
expect(screen.getByRole("status")).toBeInTheDocument();
|
|
66
|
-
expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("accepts a destination written with a locale prefix, a query or a hash", async () => {
|
|
70
|
-
store(handOff({ to: "/en/meet/confirmed?x=1#top" }));
|
|
71
|
-
const { container } = await renderHandOff();
|
|
72
|
-
expect(container.textContent).toContain("Mountain Time");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("shows no Slack text when the box was not ticked", async () => {
|
|
76
|
-
store(handOff({ slackOptIn: false }));
|
|
77
|
-
const { container } = await renderHandOff();
|
|
78
|
-
expect(container.textContent).toContain("Mountain Time");
|
|
79
|
-
expect(screen.queryByText(PROPS.slackHeadline)).toBeNull();
|
|
80
|
-
expect(screen.queryByText(PROPS.slackBody)).toBeNull();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it.each<[string, () => void]>([
|
|
84
|
-
["no item", () => undefined],
|
|
85
|
-
["an unparseable item", () => store("{not json")],
|
|
86
|
-
[
|
|
87
|
-
"an item with an extra email key",
|
|
88
|
-
() => store(handOff({ email: "ada@example.com" })),
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
"an item for another page",
|
|
92
|
-
() => store(handOff({ to: "/before-your-call" })),
|
|
93
|
-
],
|
|
94
|
-
[
|
|
95
|
-
"an item eleven minutes old",
|
|
96
|
-
() => store(handOff({ savedAt: Date.now() - 11 * 60_000 })),
|
|
97
|
-
],
|
|
98
|
-
[
|
|
99
|
-
"a zone Intl does not know",
|
|
100
|
-
() => store(handOff({ timeZone: "Mars/Olympus" })),
|
|
101
|
-
],
|
|
102
|
-
])("renders nothing, and removes the item, for %s", async (_label, seed) => {
|
|
103
|
-
seed();
|
|
104
|
-
const { container } = await renderHandOff();
|
|
105
|
-
expect(container).toBeEmptyDOMElement();
|
|
106
|
-
expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("shows nothing on a later visit", async () => {
|
|
110
|
-
store(handOff());
|
|
111
|
-
const first = await renderHandOff();
|
|
112
|
-
first.unmount();
|
|
113
|
-
const { container } = await renderHandOff();
|
|
114
|
-
expect(container).toBeEmptyDOMElement();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it.each([
|
|
118
|
-
"/fr/meet/confirmed",
|
|
119
|
-
"/anything/meet/confirmed",
|
|
120
|
-
"//evil.example/meet/confirmed",
|
|
121
|
-
])("renders nothing for a destination of %s", async (to) => {
|
|
122
|
-
store(handOff({ to }));
|
|
123
|
-
const { container } = await renderHandOff();
|
|
124
|
-
expect(container).toBeEmptyDOMElement();
|
|
125
|
-
});
|
|
126
|
-
});
|