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,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /[locale]/account/privacy — User settings › Privacy (#8438 D14; #11164 —
|
|
3
|
-
* Ploy's row-and-card shape, operator rulings 2026-11-08).
|
|
4
|
-
*
|
|
5
|
-
* RSC, outside the account layout's SignedInShell (#8430), in the member's
|
|
6
|
-
* settings frame (D7) — standalone, the Admin's shape. In DOM order:
|
|
7
|
-
*
|
|
8
|
-
* 1. The title and the lead, with "Privacy Policy" linked to the site's
|
|
9
|
-
* privacy policy (`consentPoliciesFor(locale).privacy`, #8765 D9).
|
|
10
|
-
* 2. One card:
|
|
11
|
-
* - account-privacy-data-use — "How we use your data", collapsed, a
|
|
12
|
-
* disclosure button whose chevron expands it in place to the two
|
|
13
|
-
* bullets (`DataUseDisclosure`);
|
|
14
|
-
* - account-privacy-data-consent — one `ConsentSwitchList` row per
|
|
15
|
-
* `area: "data"` purpose, the shipped one being "Help improve our AI
|
|
16
|
-
* models" (`ai_training`, #11164 AC-2: a consent, off until ticked,
|
|
17
|
-
* written through `setConsentAction`), with its description and the
|
|
18
|
-
* given/withdrawn date line; a site that declares none shows the one
|
|
19
|
-
* line. A failed consents read shows the unavailable line in its place
|
|
20
|
-
* and everything else still renders.
|
|
21
|
-
* 3. One card: account-privacy-your-data — the "Your data" table
|
|
22
|
-
* (`AccountDataTable`): Export data, a download of the person's own
|
|
23
|
-
* records through this site's `./export` route; Delete stored sessions,
|
|
24
|
-
* which confirms first, then calls `deleteStoredSessionsAction` and
|
|
25
|
-
* reports the count. The same card on every surface, a spoke that
|
|
26
|
-
* signs in through its hub included (#11194): the two member routes
|
|
27
|
-
* the table calls are on `HUB_SESSION_ROUTES`, each answered for the
|
|
28
|
-
* spoke's own workspace from the hub session.
|
|
29
|
-
*
|
|
30
|
-
* Gone (#11164 rulings 1, 2, 5, 6): the Cookies section (the choice cannot
|
|
31
|
-
* change without a new banner prompt), the summary row, the agreements list
|
|
32
|
-
* (the ledger keeps the record) and the account-deletion line and button. An
|
|
33
|
-
* account-deletion request now lives in the Delete row's confirmation, which
|
|
34
|
-
* points at Support — on every surface but a hub-mode spoke whose hub answers
|
|
35
|
-
* no member route (`via: "none"`), where Support must not take it
|
|
36
|
-
* (SEC-7894-11); `POST /v1/member/deletion-request` is unchanged.
|
|
37
|
-
*
|
|
38
|
-
* The registry purpose this app names itself: `ai_training` →
|
|
39
|
-
* `settings.privacy.purposes.ai_training` (title, description); a purpose a
|
|
40
|
-
* site adds is labelled by its statement and described by its description.
|
|
41
|
-
* The lead is one `t.rich` message whose `<policy>` tag is the link (the
|
|
42
|
-
* billing tab's `accessEnds` idiom); the metadata description is the same
|
|
43
|
-
* message through `t.markup` with the tag dropped.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
import { member } from "@working-theory/api-client";
|
|
47
|
-
import {
|
|
48
|
-
AccountDataTable,
|
|
49
|
-
AccountSettingsFrame,
|
|
50
|
-
AccountSettingsPane,
|
|
51
|
-
ConsentSwitchList,
|
|
52
|
-
DataUseDisclosure,
|
|
53
|
-
type ConsentSwitchRow,
|
|
54
|
-
} from "@working-theory/templates/account";
|
|
55
|
-
import { localeHref } from "@working-theory/ui";
|
|
56
|
-
import {
|
|
57
|
-
Link,
|
|
58
|
-
SERVER_TIME_ZONE,
|
|
59
|
-
Text,
|
|
60
|
-
formatLocalTime,
|
|
61
|
-
} from "@working-theory/ui/primitives";
|
|
62
|
-
import { AI_TRAINING_PURPOSE_ID } from "@working-theory/validation";
|
|
63
|
-
import type { Metadata } from "next";
|
|
64
|
-
import { getTranslations } from "next-intl/server";
|
|
65
|
-
import type { ReactElement } from "react";
|
|
66
|
-
|
|
67
|
-
import { consentPoliciesFor } from "../../../../../lib/consent-policies";
|
|
68
|
-
import { accountSession } from "../account-data";
|
|
69
|
-
import { loadProfileSource } from "../general/profile-source";
|
|
70
|
-
import { memberSettingsFrame, type Translate } from "../settings-frame";
|
|
71
|
-
|
|
72
|
-
import { deleteStoredSessionsAction, setConsentAction } from "./actions";
|
|
73
|
-
|
|
74
|
-
interface Props {
|
|
75
|
-
params: Promise<{ locale: string }>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
79
|
-
const { locale } = await params;
|
|
80
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
81
|
-
return {
|
|
82
|
-
title: t("settings.privacy.title"),
|
|
83
|
-
description: t.markup("settings.privacy.lead", {
|
|
84
|
-
policy: (chunks) => chunks,
|
|
85
|
-
}),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export default async function AccountPrivacyPage({
|
|
90
|
-
params,
|
|
91
|
-
}: Props): Promise<ReactElement> {
|
|
92
|
-
const { locale } = await params;
|
|
93
|
-
const t = await getTranslations({ locale, namespace: "account" });
|
|
94
|
-
const session = await accountSession(locale);
|
|
95
|
-
const frame = memberSettingsFrame(
|
|
96
|
-
locale,
|
|
97
|
-
t as unknown as Translate,
|
|
98
|
-
"privacy",
|
|
99
|
-
);
|
|
100
|
-
const policyHref =
|
|
101
|
-
consentPoliciesFor(locale)["privacy"] ?? localeHref(locale, "/privacy");
|
|
102
|
-
const lead = t.rich("settings.privacy.lead", {
|
|
103
|
-
policy: (chunks) => (
|
|
104
|
-
<Link href={policyHref} data-testid="account-privacy-policy">
|
|
105
|
-
{chunks}
|
|
106
|
-
</Link>
|
|
107
|
-
),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Unreachable behind the (authed) gate; a session that expired between
|
|
111
|
-
// the layout and the page renders the pane's title alone.
|
|
112
|
-
if (!session) {
|
|
113
|
-
return (
|
|
114
|
-
<AccountSettingsFrame {...frame} name="">
|
|
115
|
-
<AccountSettingsPane
|
|
116
|
-
id="account-settings-privacy"
|
|
117
|
-
title={t("settings.privacy.title")}
|
|
118
|
-
lead={lead}
|
|
119
|
-
>
|
|
120
|
-
{null}
|
|
121
|
-
</AccountSettingsPane>
|
|
122
|
-
</AccountSettingsFrame>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const { ctx } = session;
|
|
127
|
-
const name = ctx.user.name || ctx.user.email;
|
|
128
|
-
const source = await loadProfileSource(ctx);
|
|
129
|
-
|
|
130
|
-
let dataRows: ConsentSwitchRow[] = [];
|
|
131
|
-
let consentsAvailable = true;
|
|
132
|
-
try {
|
|
133
|
-
const res = await member.consents(ctx.init, { locale });
|
|
134
|
-
if (res.ok) {
|
|
135
|
-
dataRows = res.body.purposes
|
|
136
|
-
.filter((purpose) => purpose.area === "data")
|
|
137
|
-
.map((purpose) => ({
|
|
138
|
-
id: purpose.id,
|
|
139
|
-
...(purpose.id === AI_TRAINING_PURPOSE_ID
|
|
140
|
-
? {
|
|
141
|
-
label: t("settings.privacy.purposes.ai_training.title"),
|
|
142
|
-
description: t(
|
|
143
|
-
"settings.privacy.purposes.ai_training.description",
|
|
144
|
-
),
|
|
145
|
-
}
|
|
146
|
-
: {
|
|
147
|
-
label: purpose.statement,
|
|
148
|
-
...(purpose.description
|
|
149
|
-
? { description: purpose.description }
|
|
150
|
-
: {}),
|
|
151
|
-
}),
|
|
152
|
-
granted: purpose.effective,
|
|
153
|
-
...(purpose.state
|
|
154
|
-
? {
|
|
155
|
-
dateLine: purpose.state.granted
|
|
156
|
-
? t("settings.privacy.given", {
|
|
157
|
-
date: formatDate(purpose.state.at, locale),
|
|
158
|
-
})
|
|
159
|
-
: t("settings.privacy.withdrawn", {
|
|
160
|
-
date: formatDate(purpose.state.at, locale),
|
|
161
|
-
}),
|
|
162
|
-
}
|
|
163
|
-
: {}),
|
|
164
|
-
}));
|
|
165
|
-
} else {
|
|
166
|
-
consentsAvailable = false;
|
|
167
|
-
}
|
|
168
|
-
} catch {
|
|
169
|
-
consentsAvailable = false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<AccountSettingsFrame {...frame} name={name}>
|
|
174
|
-
<AccountSettingsPane
|
|
175
|
-
id="account-settings-privacy"
|
|
176
|
-
title={t("settings.privacy.title")}
|
|
177
|
-
lead={lead}
|
|
178
|
-
>
|
|
179
|
-
<>
|
|
180
|
-
<DataUseDisclosure
|
|
181
|
-
title={t("settings.privacy.dataUse.title")}
|
|
182
|
-
bullets={[
|
|
183
|
-
t("settings.privacy.dataUse.bullet1"),
|
|
184
|
-
t("settings.privacy.dataUse.bullet2"),
|
|
185
|
-
]}
|
|
186
|
-
testId="account-privacy-data-use"
|
|
187
|
-
/>
|
|
188
|
-
{consentsAvailable ? (
|
|
189
|
-
<ConsentSwitchList
|
|
190
|
-
rows={dataRows}
|
|
191
|
-
onChange={setConsentAction}
|
|
192
|
-
emptyLine={t("settings.privacy.consentsEmpty")}
|
|
193
|
-
testIdPrefix="account-privacy-data-consent"
|
|
194
|
-
/>
|
|
195
|
-
) : (
|
|
196
|
-
<span data-testid="account-privacy-unavailable">
|
|
197
|
-
<Text as="p" variant="body-sm" tone="muted" className="pt-3">
|
|
198
|
-
{t("settings.privacy.unavailable")}
|
|
199
|
-
</Text>
|
|
200
|
-
</span>
|
|
201
|
-
)}
|
|
202
|
-
</>
|
|
203
|
-
<AccountDataTable
|
|
204
|
-
exportHref={localeHref(locale, "/account/privacy/export")}
|
|
205
|
-
onDeleteSessions={deleteStoredSessionsAction}
|
|
206
|
-
supportHref={
|
|
207
|
-
source.via === "none"
|
|
208
|
-
? null
|
|
209
|
-
: localeHref(locale, "/account/support")
|
|
210
|
-
}
|
|
211
|
-
testIdPrefix="account-privacy-your-data"
|
|
212
|
-
labels={{
|
|
213
|
-
title: t("settings.privacy.yourData.title"),
|
|
214
|
-
exportLabel: t("settings.privacy.yourData.exportLabel"),
|
|
215
|
-
exportButton: t("settings.privacy.yourData.exportButton"),
|
|
216
|
-
deleteLabel: t("settings.privacy.yourData.deleteLabel"),
|
|
217
|
-
deleteDescription: t("settings.privacy.yourData.deleteDescription"),
|
|
218
|
-
deleteButton: t("settings.privacy.yourData.deleteButton"),
|
|
219
|
-
confirmTitle: t("settings.privacy.yourData.confirmTitle"),
|
|
220
|
-
confirmBody: t("settings.privacy.yourData.confirmBody"),
|
|
221
|
-
confirmCancel: t("settings.privacy.yourData.confirmCancel"),
|
|
222
|
-
confirmDelete: t("settings.privacy.yourData.confirmDelete"),
|
|
223
|
-
deleting: t("settings.privacy.yourData.deleting"),
|
|
224
|
-
deleteFailed: t("settings.privacy.yourData.deleteFailed"),
|
|
225
|
-
accountDeletion: t("settings.privacy.yourData.accountDeletion"),
|
|
226
|
-
accountDeletionLink: t(
|
|
227
|
-
"settings.privacy.yourData.accountDeletionLink",
|
|
228
|
-
),
|
|
229
|
-
}}
|
|
230
|
-
/>
|
|
231
|
-
</AccountSettingsPane>
|
|
232
|
-
</AccountSettingsFrame>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// #11159: a `t()` argument is a string, so this RSC reads the day in the
|
|
237
|
-
// server fallback zone — never the host's, which the unpinned form read.
|
|
238
|
-
function formatDate(iso: string, locale: string): string {
|
|
239
|
-
return formatLocalTime(iso, "date", { timeZone: SERVER_TIME_ZONE, locale });
|
|
240
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* account/profile-actions.ts — User settings › General's two member writes
|
|
5
|
-
* (#8232, spec docs/specs/8232-member-settings-account-general-and-spec.md
|
|
6
|
-
* D6; the writes are #8170's).
|
|
7
|
-
*
|
|
8
|
-
* - `saveProfile` — the member's name and photo, `member.updateProfile`
|
|
9
|
-
* (`PATCH /v1/member/profile`). On a spoke the hub-session cookie is then
|
|
10
|
-
* re-sealed from the hub's `/me` (`resealHubSession`, D11), so the new
|
|
11
|
-
* name shows on the next render.
|
|
12
|
-
* - `requestAccountDeletion` — `member.requestDeletion`
|
|
13
|
-
* (`POST /v1/member/deletion-request`). The API files it with the
|
|
14
|
-
* deployment that holds the account (8170 D9) and answers which operator
|
|
15
|
-
* it went to, so nothing here tests the topology.
|
|
16
|
-
*
|
|
17
|
-
* Both send `forwardedCookieInit()`'s init: on a single site the session
|
|
18
|
-
* cookie plus the request's `Origin`, which `apps/api`'s cookie CSRF check
|
|
19
|
-
* needs; on a hub-mode spoke the hub credential. Neither takes an identity
|
|
20
|
-
* argument — who comes from the forwarded credential alone (8170 D1).
|
|
21
|
-
*
|
|
22
|
-
* Not a `*.actions.ts` file and no `*Action`-suffixed export: these writes
|
|
23
|
-
* have no MCP twin by decision (8170's header), and apps/mcp's parity test
|
|
24
|
-
* reads that suffix. `resealHubSession` is imported by its own path, never
|
|
25
|
-
* through `lib/hub-session/index.ts`: `sync-routes` never overwrites a
|
|
26
|
-
* scaffold's existing `index.ts`, so an import through it would not compile
|
|
27
|
-
* there (D13). Logs carry a status or `err.name` only — never a name, a
|
|
28
|
-
* link, an email or a credential.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
import { member } from "@working-theory/api-client";
|
|
32
|
-
|
|
33
|
-
import { resealHubSession } from "../../../../lib/hub-session/reseal";
|
|
34
|
-
import { forwardedCookieInit } from "../../../../lib/server-api";
|
|
35
|
-
|
|
36
|
-
/** PII-safe error identity for logs (the `checkout.actions.ts` idiom: `err.name` only). */
|
|
37
|
-
function errorName(err: unknown): string {
|
|
38
|
-
return err instanceof Error ? err.name : "unknown";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** The `error.code` of a member write's refusal body, when it has one. */
|
|
42
|
-
function errorCode(body: unknown): string | null {
|
|
43
|
-
if (typeof body !== "object" || body === null) return null;
|
|
44
|
-
const error = (body as { error?: unknown }).error;
|
|
45
|
-
if (typeof error !== "object" || error === null) return null;
|
|
46
|
-
const code = (error as { code?: unknown }).code;
|
|
47
|
-
return typeof code === "string" ? code : null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type SaveProfileResult =
|
|
51
|
-
| { ok: true; name: string | null; image: string | null }
|
|
52
|
-
| { ok: false; reason: "required" | "photo" | "unverified" | "unavailable" | "failed" };
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Saves the member's name, and their photo when `image` is present:
|
|
56
|
-
* `null` (or a blank link) clears it, and an absent key leaves it as it is.
|
|
57
|
-
*/
|
|
58
|
-
export async function saveProfile(input: {
|
|
59
|
-
name: string;
|
|
60
|
-
image?: string | null;
|
|
61
|
-
}): Promise<SaveProfileResult> {
|
|
62
|
-
// Action input is untrusted: a hand-built call may send anything.
|
|
63
|
-
const { name: rawName, image } = (typeof input === "object" && input !== null ? input : {}) as {
|
|
64
|
-
name?: unknown;
|
|
65
|
-
image?: unknown;
|
|
66
|
-
};
|
|
67
|
-
const name = typeof rawName === "string" ? rawName.trim() : "";
|
|
68
|
-
if (!name) return { ok: false, reason: "required" };
|
|
69
|
-
// Anything but a string or null is refused, never read as "clear the photo".
|
|
70
|
-
if (image !== undefined && image !== null && typeof image !== "string") {
|
|
71
|
-
return { ok: false, reason: "photo" };
|
|
72
|
-
}
|
|
73
|
-
const body = image === undefined ? { name } : { name, image: image?.trim() || null };
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const res = await member.updateProfile(body, await forwardedCookieInit());
|
|
77
|
-
if (res.ok) {
|
|
78
|
-
if ((await resealHubSession()) === "failed") {
|
|
79
|
-
console.error("[profile-actions] saveProfile reseal=failed");
|
|
80
|
-
}
|
|
81
|
-
return { ok: true, name: res.body.name, image: res.body.image };
|
|
82
|
-
}
|
|
83
|
-
console.error(`[profile-actions] saveProfile status=${res.status}`);
|
|
84
|
-
if (res.status === 400 && errorCode(res.body) === "link_not_https") {
|
|
85
|
-
return { ok: false, reason: "photo" };
|
|
86
|
-
}
|
|
87
|
-
if (res.status === 403) return { ok: false, reason: "unverified" };
|
|
88
|
-
if (res.status === 404 || res.status === 503) return { ok: false, reason: "unavailable" };
|
|
89
|
-
return { ok: false, reason: "failed" };
|
|
90
|
-
} catch (err) {
|
|
91
|
-
console.error(`[profile-actions] saveProfile errName=${errorName(err)}`);
|
|
92
|
-
return { ok: false, reason: "failed" };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type AccountDeletionResult =
|
|
97
|
-
| { ok: true; sentTo: "site-operator" | "hub-operator" }
|
|
98
|
-
| { ok: false; reason: "unverified" | "unavailable" | "failed" };
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Asks the operator who holds the account to delete it. The body is empty,
|
|
102
|
-
* so the API's own subject and message go to the operator.
|
|
103
|
-
*/
|
|
104
|
-
export async function requestAccountDeletion(): Promise<AccountDeletionResult> {
|
|
105
|
-
try {
|
|
106
|
-
const res = await member.requestDeletion({}, await forwardedCookieInit());
|
|
107
|
-
if (res.ok) return { ok: true, sentTo: res.body.sentTo };
|
|
108
|
-
console.error(`[profile-actions] requestAccountDeletion status=${res.status}`);
|
|
109
|
-
if (res.status === 403) return { ok: false, reason: "unverified" };
|
|
110
|
-
if (res.status === 404 || res.status === 503) return { ok: false, reason: "unavailable" };
|
|
111
|
-
return { ok: false, reason: "failed" };
|
|
112
|
-
} catch (err) {
|
|
113
|
-
console.error(`[profile-actions] requestAccountDeletion errName=${errorName(err)}`);
|
|
114
|
-
return { ok: false, reason: "failed" };
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client"; // Retry re-runs the page's server reads through the router
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* RetryButton — the Inbox error row's Retry control (#7430, spec 7423 D12).
|
|
5
|
-
*
|
|
6
|
-
* `router.refresh()` re-renders the route's Server Components, so every
|
|
7
|
-
* account read runs again without a full page load.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Button } from "@working-theory/ui/primitives";
|
|
11
|
-
import { useRouter } from "next/navigation";
|
|
12
|
-
import type { ReactElement } from "react";
|
|
13
|
-
|
|
14
|
-
export function RetryButton({ label }: { label: string }): ReactElement {
|
|
15
|
-
const router = useRouter();
|
|
16
|
-
return (
|
|
17
|
-
<Button
|
|
18
|
-
variant="secondary"
|
|
19
|
-
// 44px on a phone (a touch-first context), the 36px default from md up.
|
|
20
|
-
className="max-md:min-h-11"
|
|
21
|
-
onClick={() => router.refresh()}
|
|
22
|
-
data-testid="inbox-retry"
|
|
23
|
-
>
|
|
24
|
-
{label}
|
|
25
|
-
</Button>
|
|
26
|
-
);
|
|
27
|
-
}
|
package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security on a spoke that signs in through its hub (#11162 AC-1, AC-3).
|
|
3
|
-
*
|
|
4
|
-
* The generated web seam is mocked to its `signIn: "hub"` render, as
|
|
5
|
-
* `account/__tests__/hub-mode.test.tsx` mocks it; this suite sits beside the
|
|
6
|
-
* route so it copies with it. Covers:
|
|
7
|
-
*
|
|
8
|
-
* - AC-1: the tab renders the Sign-in methods panel — the Password row
|
|
9
|
-
* with Set / Not set read from the hub's `me` for the signed-in person
|
|
10
|
-
* (the Bearer credential, never a cookie), the secure-link line naming
|
|
11
|
-
* the person's email, Set password or Change password — and Log out; no
|
|
12
|
-
* "managed at <host>" sentence and no link to the hub's Security page,
|
|
13
|
-
* and the seam's accounts reader is never asked.
|
|
14
|
-
* - AC-2 (the spoke's half): Set / Change password POSTs `{ locale }` to
|
|
15
|
-
* the spoke's own `/api/hub-session/password`, same-origin, and asks
|
|
16
|
-
* Better Auth for nothing; a 202 is "Link sent", anything else the
|
|
17
|
-
* failure line.
|
|
18
|
-
* - AC-3: a hub that answers no state — no `hasPassword`, a refusal, a
|
|
19
|
-
* failed read — renders the panel's unavailable line, never a form.
|
|
20
|
-
*/
|
|
21
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
22
|
-
import { tmpdir } from "node:os";
|
|
23
|
-
import { join } from "node:path";
|
|
24
|
-
|
|
25
|
-
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
26
|
-
|
|
27
|
-
jest.mock("next-intl/server", () => {
|
|
28
|
-
const msgs: unknown = require("../../../../../../messages/en.json");
|
|
29
|
-
const dig = (obj: unknown, path: string): unknown =>
|
|
30
|
-
path.split(".").reduce<unknown>(
|
|
31
|
-
(acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
|
|
32
|
-
obj,
|
|
33
|
-
);
|
|
34
|
-
return {
|
|
35
|
-
__esModule: true,
|
|
36
|
-
getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
|
|
37
|
-
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
38
|
-
const messages = dig(msgs, ns);
|
|
39
|
-
return (key: string, values?: Record<string, unknown>): string => {
|
|
40
|
-
const value = dig(messages, key);
|
|
41
|
-
if (typeof value !== "string") return `${ns}.${key}`;
|
|
42
|
-
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
43
|
-
values && name in values ? String(values[name]) : m,
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const mockHeaders = jest.fn();
|
|
51
|
-
jest.mock("next/headers", () => ({
|
|
52
|
-
__esModule: true,
|
|
53
|
-
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
54
|
-
cookies: jest.fn().mockImplementation(async () => ({ toString: () => "", set: jest.fn() })),
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
const mockReadSession = jest.fn();
|
|
58
|
-
const mockReadOwnAccounts = jest.fn();
|
|
59
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: the seam is generated per build (#7894 D8); its `signIn: "hub"` render is the boundary under test, and no env or HTTP surface selects it.
|
|
60
|
-
jest.mock("../../../../../../lib/topology.generated", () => ({
|
|
61
|
-
__esModule: true,
|
|
62
|
-
TOPOLOGY: "spoke",
|
|
63
|
-
SIGN_IN_ENABLED: true,
|
|
64
|
-
SIGN_IN_PROVIDER: "hub",
|
|
65
|
-
SIGN_IN_PATH: "/account",
|
|
66
|
-
SIGN_UP_PATH: null,
|
|
67
|
-
SIGN_OUT_ENDPOINT: "/api/hub-session/sign-out",
|
|
68
|
-
readSession: (...args: unknown[]) => mockReadSession(...args),
|
|
69
|
-
registerSiteStores: () => Promise.resolve(),
|
|
70
|
-
loadSpokeBilling: () => Promise.resolve(null),
|
|
71
|
-
readOwnAccounts: (...args: unknown[]) => mockReadOwnAccounts(...args),
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
const mockHubMe = jest.fn();
|
|
75
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
76
|
-
__esModule: true,
|
|
77
|
-
visitorForwardHeaders: () => null,
|
|
78
|
-
hubSignIn: { me: (...args: unknown[]) => mockHubMe(...args) },
|
|
79
|
-
}));
|
|
80
|
-
|
|
81
|
-
const mockRequestPasswordReset = jest.fn();
|
|
82
|
-
const mockSignOut = jest.fn();
|
|
83
|
-
jest.mock("better-auth/react", () => ({
|
|
84
|
-
__esModule: true,
|
|
85
|
-
createAuthClient: () => ({
|
|
86
|
-
requestPasswordReset: (...args: unknown[]) => mockRequestPasswordReset(...args),
|
|
87
|
-
signOut: (...args: unknown[]) => mockSignOut(...args),
|
|
88
|
-
}),
|
|
89
|
-
}));
|
|
90
|
-
|
|
91
|
-
const mockPush = jest.fn();
|
|
92
|
-
jest.mock("next/navigation", () => ({
|
|
93
|
-
__esModule: true,
|
|
94
|
-
useRouter: () => ({ push: mockPush, refresh: jest.fn(), replace: jest.fn() }),
|
|
95
|
-
usePathname: () => "/account/security",
|
|
96
|
-
redirect: jest.fn(),
|
|
97
|
-
}));
|
|
98
|
-
|
|
99
|
-
import { seal } from "../../../../../../lib/hub-session/seal";
|
|
100
|
-
import SecurityPage from "../page";
|
|
101
|
-
|
|
102
|
-
const HUB = "https://hub.example.com";
|
|
103
|
-
const SESSION_SECRET = "s".repeat(43);
|
|
104
|
-
const CREDENTIAL = `ailk_hst_${"t".repeat(43)}`;
|
|
105
|
-
const BEARER = { headers: { authorization: `Bearer ${CREDENTIAL}` } };
|
|
106
|
-
const USER = {
|
|
107
|
-
name: "Ada Lovelace",
|
|
108
|
-
email: "ada@example.com",
|
|
109
|
-
emailVerified: true,
|
|
110
|
-
createdAt: "2026-09-01T00:00:00.000Z",
|
|
111
|
-
};
|
|
112
|
-
const WIRE_USER = { id: "user_1", ...USER };
|
|
113
|
-
|
|
114
|
-
const ENV = process.env;
|
|
115
|
-
let contentRoot: string;
|
|
116
|
-
const realFetch = Object.getOwnPropertyDescriptor(globalThis, "fetch");
|
|
117
|
-
const mockFetch = jest.fn();
|
|
118
|
-
|
|
119
|
-
beforeEach(() => {
|
|
120
|
-
contentRoot = mkdtempSync(join(tmpdir(), "ailk-security-hub-"));
|
|
121
|
-
writeFileSync(join(contentRoot, "_site.mdx"), '---\nsiteName: "Test"\n---\n');
|
|
122
|
-
process.env = {
|
|
123
|
-
...ENV,
|
|
124
|
-
AILK_CONTENT_ROOT: contentRoot,
|
|
125
|
-
AILK_HUB_SIGN_IN_URL: HUB,
|
|
126
|
-
AILK_HUB_CLIENT_ID: "spoke_0001",
|
|
127
|
-
AILK_HUB_CLIENT_SECRET: `ailk_hcs_${"c".repeat(43)}`,
|
|
128
|
-
AILK_HUB_SESSION_SECRET: SESSION_SECRET,
|
|
129
|
-
NEXT_PUBLIC_BASE_URL: "https://spoke.example.com",
|
|
130
|
-
};
|
|
131
|
-
const sealed = seal(
|
|
132
|
-
{ v: 1, accessToken: CREDENTIAL, expiresAt: Date.now() + 60_000, user: USER },
|
|
133
|
-
SESSION_SECRET,
|
|
134
|
-
"session",
|
|
135
|
-
"__Host-ailk-hub-session",
|
|
136
|
-
);
|
|
137
|
-
mockHeaders.mockReset().mockResolvedValue(new Headers({ cookie: `__Host-ailk-hub-session=${sealed}` }));
|
|
138
|
-
mockReadSession.mockReset().mockResolvedValue({ user: USER });
|
|
139
|
-
mockReadOwnAccounts.mockReset().mockResolvedValue(null);
|
|
140
|
-
mockHubMe.mockReset();
|
|
141
|
-
mockRequestPasswordReset.mockReset();
|
|
142
|
-
mockSignOut.mockReset();
|
|
143
|
-
mockPush.mockReset();
|
|
144
|
-
mockFetch.mockReset();
|
|
145
|
-
Object.defineProperty(globalThis, "fetch", { value: mockFetch, writable: true, configurable: true });
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
afterEach(() => {
|
|
149
|
-
rmSync(contentRoot, { recursive: true, force: true });
|
|
150
|
-
process.env = ENV;
|
|
151
|
-
if (realFetch) Object.defineProperty(globalThis, "fetch", realFetch);
|
|
152
|
-
else Reflect.deleteProperty(globalThis, "fetch");
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
function hubAnswers(body: Record<string, unknown>): void {
|
|
156
|
-
mockHubMe.mockResolvedValue({ ok: true, status: 200, body: { user: WIRE_USER, billingCustomerId: null, ...body } });
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async function renderSecurity(): Promise<void> {
|
|
160
|
-
render(await SecurityPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** The panel's shape every hub render shares: Log out, and none of the retired pointer. */
|
|
164
|
-
function expectNoPointer(): void {
|
|
165
|
-
expect(screen.getByTestId("account-security-log-out")).toBeInTheDocument();
|
|
166
|
-
expect(screen.queryByTestId("account-security-hub")).not.toBeInTheDocument();
|
|
167
|
-
expect(screen.queryByTestId("account-security-hub-link")).not.toBeInTheDocument();
|
|
168
|
-
expect(screen.queryByTestId("account-security-sentence")).not.toBeInTheDocument();
|
|
169
|
-
expect(screen.queryByText(/managed at/i)).toBeNull();
|
|
170
|
-
expect(screen.queryByText(/main site/i)).toBeNull();
|
|
171
|
-
expect(mockReadOwnAccounts).not.toHaveBeenCalled();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
describe("AC-1 — the Sign-in methods panel on a hub-mode spoke", () => {
|
|
175
|
-
it("renders the Password row as Set, the change line naming the email, and Change password, read from the hub with the credential", async () => {
|
|
176
|
-
hubAnswers({ hasPassword: true });
|
|
177
|
-
await renderSecurity();
|
|
178
|
-
|
|
179
|
-
expect(mockHubMe).toHaveBeenCalledTimes(1);
|
|
180
|
-
expect(mockHubMe).toHaveBeenCalledWith(BEARER);
|
|
181
|
-
expect(screen.getByText("Sign-in methods")).toBeInTheDocument();
|
|
182
|
-
expect(screen.getByTestId("account-security-password")).toBeInTheDocument();
|
|
183
|
-
expect(screen.getByTestId("account-security-password-status")).toHaveTextContent("Set");
|
|
184
|
-
expect(screen.getByTestId("account-security-password-note")).toHaveTextContent(
|
|
185
|
-
"We'll email ada@example.com a secure link to change your password.",
|
|
186
|
-
);
|
|
187
|
-
expect(screen.getByTestId("account-security-password-request")).toHaveTextContent("Change password");
|
|
188
|
-
expectNoPointer();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("renders the Password row as Not set, the set line naming the email, and Set password", async () => {
|
|
192
|
-
hubAnswers({ hasPassword: false });
|
|
193
|
-
await renderSecurity();
|
|
194
|
-
|
|
195
|
-
expect(screen.getByTestId("account-security-password-status")).toHaveTextContent("Not set");
|
|
196
|
-
expect(screen.getByTestId("account-security-password-note")).toHaveTextContent(
|
|
197
|
-
"We'll email ada@example.com a secure link to create your password.",
|
|
198
|
-
);
|
|
199
|
-
expect(screen.getByTestId("account-security-password-request")).toHaveTextContent("Set password");
|
|
200
|
-
expectNoPointer();
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
describe("AC-2 — Set / Change password asks the spoke's own route", () => {
|
|
205
|
-
it("POSTs { locale } to /api/hub-session/password same-origin, asks Better Auth nothing, and a 202 is Link sent", async () => {
|
|
206
|
-
hubAnswers({ hasPassword: false });
|
|
207
|
-
mockFetch.mockResolvedValue({ ok: true, status: 202 });
|
|
208
|
-
await renderSecurity();
|
|
209
|
-
|
|
210
|
-
await act(async () => {
|
|
211
|
-
fireEvent.click(screen.getByTestId("account-security-password-request"));
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
215
|
-
expect(mockFetch).toHaveBeenCalledWith("/api/hub-session/password", {
|
|
216
|
-
method: "POST",
|
|
217
|
-
credentials: "same-origin",
|
|
218
|
-
headers: { "content-type": "application/json" },
|
|
219
|
-
body: JSON.stringify({ locale: "en" }),
|
|
220
|
-
});
|
|
221
|
-
expect(mockRequestPasswordReset).not.toHaveBeenCalled();
|
|
222
|
-
expect(await screen.findByTestId("account-security-password-sent")).toBeInTheDocument();
|
|
223
|
-
expect(screen.queryByTestId("account-security-password-error")).not.toBeInTheDocument();
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("anything but a 202 is the failure line, and nothing navigates", async () => {
|
|
227
|
-
hubAnswers({ hasPassword: true });
|
|
228
|
-
mockFetch.mockResolvedValue({ ok: false, status: 503 });
|
|
229
|
-
await renderSecurity();
|
|
230
|
-
|
|
231
|
-
await act(async () => {
|
|
232
|
-
fireEvent.click(screen.getByTestId("account-security-password-request"));
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
expect(await screen.findByTestId("account-security-password-error")).toBeInTheDocument();
|
|
236
|
-
expect(screen.queryByTestId("account-security-password-sent")).not.toBeInTheDocument();
|
|
237
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
238
|
-
expect(mockRequestPasswordReset).not.toHaveBeenCalled();
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe("AC-3 — a hub that answers no state renders the unavailable line, never a form", () => {
|
|
243
|
-
it.each([
|
|
244
|
-
["a hub older than #11162 (no hasPassword)", () => hubAnswers({})],
|
|
245
|
-
["a refused credential", () => mockHubMe.mockResolvedValue({ ok: false, status: 401, body: { ok: false } })],
|
|
246
|
-
["a failed read", () => mockHubMe.mockRejectedValue(new Error("network"))],
|
|
247
|
-
])("%s", async (_label, arrange) => {
|
|
248
|
-
jest.spyOn(console, "error").mockImplementation(() => undefined);
|
|
249
|
-
arrange();
|
|
250
|
-
await renderSecurity();
|
|
251
|
-
|
|
252
|
-
expect(screen.getByTestId("inbox-error")).toHaveTextContent("We couldn't check your password settings.");
|
|
253
|
-
expect(screen.queryByTestId("account-security-password")).not.toBeInTheDocument();
|
|
254
|
-
expect(screen.queryByTestId("account-security-password-request")).not.toBeInTheDocument();
|
|
255
|
-
expect(screen.queryByText(/Sign-in methods/)).toBeNull();
|
|
256
|
-
expectNoPointer();
|
|
257
|
-
});
|
|
258
|
-
});
|