create-ailk 0.34.1 → 0.36.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 +1 -1
- package/component-catalog.json +37 -4
- package/component-catalog.md +11 -9
- package/dist/add-module.js +7 -2
- package/dist/derive-architecture.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/env-catalog.js +8 -0
- package/dist/module-architecture.js +9 -0
- package/dist/programmatic.js +5 -2
- package/dist/site-listing-path.d.ts +8 -0
- package/dist/site-listing-path.js +8 -0
- package/dist/surfaces.d.ts +20 -0
- package/dist/surfaces.js +32 -3
- package/dist/template-record.js +2 -0
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.js +11 -0
- package/package.json +3 -3
- package/templates/.env.example +21 -0
- package/templates/apps/api/.env.example +7 -0
- package/templates/apps/api/CLAUDE.md +14 -9
- package/templates/apps/mcp/CLAUDE.md +18 -7
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +46 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
- package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +12 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +55 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +60 -6
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +32 -3
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +47 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +214 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +6 -4
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -1
- package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
- package/templates/apps/web/app/[locale]/layout.tsx +42 -76
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +189 -6
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +101 -31
- package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
- package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +475 -7
- package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
- package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
- package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
- package/templates/apps/web/app/llms.txt/route.ts +14 -2
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
- package/templates/apps/web/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
- package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
- package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
- package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
- package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
- package/templates/apps/web/lib/account-config.ts +24 -9
- package/templates/apps/web/lib/auth-email.ts +62 -6
- package/templates/apps/web/lib/auth-env.ts +13 -0
- package/templates/apps/web/lib/auth-sms.ts +180 -0
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
- package/templates/apps/web/lib/hub-session/config.ts +7 -1
- package/templates/apps/web/lib/hub-session/entry.ts +238 -0
- package/templates/apps/web/lib/hub-session/index.ts +1 -4
- package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
- package/templates/apps/web/lib/hub-session/session.ts +120 -2
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
- package/templates/apps/web/lib/site-header.ts +14 -1
- package/templates/apps/web/lib/site-listing.ts +7 -0
- package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
- package/templates/apps/web/lib/topology.generated.ts +39 -0
- package/templates/apps/web/messages/en.json +125 -21
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +47 -47
- package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
- package/templates/apps/web/components/signed-in-nav.tsx +0 -79
- package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
- package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
|
@@ -225,6 +225,15 @@ CONTENT_ADAPTER=mdx
|
|
|
225
225
|
# must never tell a visitor "check your email" for mail nothing can send.
|
|
226
226
|
# AUTH_EMAIL_WEBHOOK_SECRET=
|
|
227
227
|
#
|
|
228
|
+
# Phone verification (#11106 D9). With AUTH_EMAIL_WEBHOOK_SECRET and
|
|
229
|
+
# BETTER_AUTH_URL set (and never on a spoke), the Account page lets a signed-in
|
|
230
|
+
# person with a verified email set and verify a phone: the code is signed with
|
|
231
|
+
# the secret above and texted by apps/api's /v1/auth/transactional-sms
|
|
232
|
+
# (TWILIO_* live on the apps/api deployment). Phone is never a sign-in method.
|
|
233
|
+
# The calling codes a code may be texted to, comma-separated, default "1" —
|
|
234
|
+
# set the same value on apps/api, whose relay re-checks it.
|
|
235
|
+
# AILK_SMS_COUNTRY_CODES=1
|
|
236
|
+
#
|
|
228
237
|
# Comma-separated CIDRs of YOUR edge/proxy, for Better Auth's rate-limit IP key.
|
|
229
238
|
#
|
|
230
239
|
# Unset is the honest default — this repo cannot know your deployment's edge
|
|
@@ -272,6 +281,13 @@ CONTENT_ADAPTER=mdx
|
|
|
272
281
|
# The redirect URI is built from this site's NEXT_PUBLIC_BASE_URL (else the
|
|
273
282
|
# baseUrl in content/_site.mdx) — never from a request's Host — so set it to
|
|
274
283
|
# the origin you registered on the hub.
|
|
284
|
+
#
|
|
285
|
+
# Google One Tap for a returning Google person (#11096 D10), off by default.
|
|
286
|
+
# "on" renders Google's prompt on the signed-out /account and widens this
|
|
287
|
+
# site's CSP to Google's One Tap origins. It works only once the hub sets
|
|
288
|
+
# AILK_GOOGLE_ONE_TAP_CLIENT_ID and this origin is listed on that Google
|
|
289
|
+
# client's authorized JavaScript origins. Anything else, or unset, is off.
|
|
290
|
+
# AILK_HUB_ONE_TAP=on
|
|
275
291
|
|
|
276
292
|
# =============================================================================
|
|
277
293
|
# Observability
|
|
@@ -161,8 +161,47 @@ to the same route, which accepts only `Sec-Fetch-Site: same-origin` with the
|
|
|
161
161
|
pinned `Origin` (a missing or `null` one is refused) and is the one call site
|
|
162
162
|
that sends `consent: true` — beside `x-internal-auth` under the Offerings buy
|
|
163
163
|
route's rule, since the API honours consent only with it where
|
|
164
|
-
`OSS_API_INTERNAL_SECRET` is set.
|
|
165
|
-
|
|
164
|
+
`OSS_API_INTERNAL_SECRET` is set. Its navigating page is built only for an
|
|
165
|
+
`https:` or loopback `http:` callback; any other scheme answers 503 (#11095
|
|
166
|
+
D10). A client whose row is `trusted` (every client the operator CLI registers)
|
|
167
|
+
never sees the page: its code mints with no consent read (#11095 D1). A
|
|
168
|
+
password reset revokes the grant, so the next sign-in of an untrusted client
|
|
169
|
+
asks again; a spoke sign-out ends only the credential (#11095 D2). `ref` is in
|
|
170
|
+
both telemetry scrub lists.
|
|
171
|
+
|
|
172
|
+
**A spoke's sign-in entry is the spoke's own form (#11096).** On a spoke
|
|
173
|
+
that signs in through its hub, the gate seam renders
|
|
174
|
+
`lib/hub-session/spoke-sign-in.tsx` (`SpokeSignIn`) for every signed-out
|
|
175
|
+
`(authed)` path: one email field, the hub's sign-up agreements under "New
|
|
176
|
+
here?" (read from the hub web's `GET /api/auth/hub/sign-up`, shared 60 s, each
|
|
177
|
+
policy link the hub's) and Continue with Google — a native form, no password
|
|
178
|
+
field and no link to a hub sign-in page. It reads its state from
|
|
179
|
+
`x-search`, which `middleware.ts` sets from the request's own query
|
|
180
|
+
(`?sent=1`, `?error=agreements | unavailable | exists | claim`, `?claim=`).
|
|
181
|
+
The email POSTs to `/api/hub-session/email`, which starts a flow
|
|
182
|
+
(`startHubFlow`) and asks the hub web's `POST /api/auth/hub/email` server to
|
|
183
|
+
server, as the spoke's client (Basic + spoke key); the hub API's
|
|
184
|
+
`/v1/hub-sign-in/entry` checks the client before Better Auth mails its magic
|
|
185
|
+
link, whose use returns through redirects only. Ticked agreements make it a
|
|
186
|
+
sign-up request (#9667's shape); none ticked is a sign-in. Google goes to the
|
|
187
|
+
spoke's sign-in route with `provider=google`, which rides as `provider_hint`
|
|
188
|
+
and sends a visitor with no hub session straight to Google from the
|
|
189
|
+
authorize step. **The purchase link:** after a paid Offerings session the hub
|
|
190
|
+
mails "Open your account" to `<spoke>/account?claim=<claim>`; that page's GET
|
|
191
|
+
changes nothing, and its one "Open my account" button POSTs the claim to
|
|
192
|
+
`/api/hub-session/open`, which spends it at the hub web's
|
|
193
|
+
`POST /api/auth/hub/purchase` and 303s to the hub's verify URL (`409` →
|
|
194
|
+
`?error=exists`, anything else → `?error=claim`). `/account/billing` lists the
|
|
195
|
+
member's purchases (`member.purchases`, the verified-email join) on such a
|
|
196
|
+
spoke only. **One Tap** (off by default): `AILK_HUB_ONE_TAP=on` on the spoke
|
|
197
|
+
and `AILK_GOOGLE_ONE_TAP_CLIENT_ID` on the hub API render the `OneTap`
|
|
198
|
+
island, which takes a nonce from `/api/hub-session/one-tap/nonce` (a 300 s
|
|
199
|
+
sealed cookie) and posts Google's credential to `/api/hub-session/one-tap`;
|
|
200
|
+
the hub verifies it and the route seals the session (`sessionCookieFor`) before
|
|
201
|
+
the page moves. `middleware.ts` adds Google's One Tap origins
|
|
202
|
+
(`ONE_TAP_CSP`) to every page's CSP only while that setting is on. Every new
|
|
203
|
+
spoke route is same-origin only, and every body is `.strict()`: a password is
|
|
204
|
+
never accepted. `claim` is in both telemetry scrub lists.
|
|
166
205
|
|
|
167
206
|
## The MCP authorization server
|
|
168
207
|
|
|
@@ -598,7 +637,7 @@ A site serves its docs at `/docs` unless `content/_site.mdx` sets a top-level `d
|
|
|
598
637
|
|
|
599
638
|
- **Build.** `next.config.mjs` reads `docsPath`, bakes it into `NEXT_PUBLIC_AILK_DOCS_PATH`, and fails the build naming the value when it breaks the pattern, starts with `api`, `og`, `v1` or an enabled locale, sits under `/docs`, shadows a `ROUTES` page (a `:param` segment matches any segment, so `/products/docs` is refused) or sits under a catch-all (`/blog/...`), or when this site's `lib/source.ts` does not set `baseUrl: DOCS_PATH` — a site with no docs-blog module, or one whose docs-blog files predate the setting. Links inside a doc's body are re-pointed only on a site that sets `docsPath`; there they render through `Link`, which forwards a fixed prop set, so a body anchor's `title` / `target` / `rel` are not kept.
|
|
600
639
|
- **Request.** `middleware.ts` hands next-intl the internal `/docs/...` path for a request at or under `docsPath` (bare or locale-prefixed), so the browser keeps the public URL, and maps a redirect's `Location` and each hreflang `Link` entry back onto it. `/docs` and `/docs/...` answer with the site's 404 — rewritten to `/_ailk-docs-unmounted`, whose first segment is no locale, so the locale layout calls `notFound()`.
|
|
601
|
-
- **Surfaces.** The docs sidebar, index and search index (both sources' `baseUrl`), the doc's breadcrumb, links inside a doc's body, every nav and footer entry at `/docs` (mapped at render in the locale layout
|
|
640
|
+
- **Surfaces.** The docs sidebar, index and search index (both sources' `baseUrl`), the doc's breadcrumb, links inside a doc's body, every nav and footer entry at `/docs` (mapped at render in the locale layout; `nav-config.ts` is never edited), and the docs entries in `/sitemap.xml` and `/llms.txt` (`lib/docs-index.ts`, default locale only) all follow it. A site with no `docsPath` serves every URL exactly as before.
|
|
602
641
|
- **Existing docs sites.** `create-ailk update` carries the base readers but never refreshes a module bundle's files, so a docs-blog site installed before this release keeps a `lib/source.ts` without `DOCS_PATH` and its build refuses a `docsPath` until those files are re-installed — a standing gap no command fills yet (#10076).
|
|
603
642
|
- **Rollout.** A `@working-theory/site-config` older than this setting rejects a `_site.mdx` carrying `docsPath` (its schema is strict), and `@working-theory/api` / `@working-theory/mcp-server` then read the site as having no config. Set `docsPath` only once the site's packages carry it.
|
|
604
643
|
|
|
@@ -609,7 +648,7 @@ A site serves its services at `/services` unless `content/_site.mdx` sets `servi
|
|
|
609
648
|
- **Categories.** A category is itself a `Service` page. A service names its category with frontmatter `parent: <category-slug>` and is served at `/<base>/<category>/<slug>` (`services/[slug]/[child]/page.tsx`); its flat URL answers a permanent redirect there, and the nested URL answers 404 unless the `parent` names that category and the category has no `parent` of its own. A category page lists its services after its body (`lib/service-listing.ts`, the `services` messages' `childrenHeading` / `viewService`). One level only.
|
|
610
649
|
- **Build.** `next.config.mjs` reads `services.path`, bakes it into `NEXT_PUBLIC_AILK_SERVICES_PATH`, and fails the build naming the value when it breaks the pattern, starts with an enabled locale, shadows a `ROUTES` page, sits under a catch-all, or overlaps `docsPath` either way. It also fails, naming the file, on a default-locale `Service` whose `parent` names no Service or a Service with its own `parent`, and on any `parent` when the nested route is missing (`create-ailk sync-routes` adds it).
|
|
611
650
|
- **Request.** `middleware.ts` hands next-intl the internal `/services/...` path for a request at or under the base, keeps `x-pathname` public, and maps a redirect's `Location` and each hreflang `Link` entry back. `/services` and `/services/...` answer `308` onto the same rest under the base (query and locale prefix kept), so old links keep working; links inside content are not rewritten.
|
|
612
|
-
- **Surfaces.** The canonical, hreflang and `BreadcrumbList` (the base's title-cased last segment, then the category's title), `/sitemap.xml` and `/llms.txt` (`pagePathFor`), every nav and footer entry at `/services` (mapped in the locale layout
|
|
651
|
+
- **Surfaces.** The canonical, hreflang and `BreadcrumbList` (the base's title-cased last segment, then the category's title), `/sitemap.xml` and `/llms.txt` (`pagePathFor`), every nav and footer entry at `/services` (mapped in the locale layout), the hub's own section links, and route-family chrome (`lib/page-chrome.ts`) all follow it. A site that sets neither `services.path` nor any `parent` serves every URL exactly as before.
|
|
613
652
|
- **Moving it.** `/ailk:growth-ops page rename` moves the base (`--from <current base> --to <new base>`): it writes `services.path` and keeps a previous moved base redirecting.
|
|
614
653
|
|
|
615
654
|
## Nav-only lists (`navOnly`)
|
|
@@ -645,7 +684,9 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
|
|
|
645
684
|
- Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
|
|
646
685
|
- Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
|
|
647
686
|
|
|
648
|
-
Last updated: 2026-11-
|
|
687
|
+
Last updated: 2026-11-07 — § The `(auth)` route group: a spoke's sign-in entry is the spoke's own form — the email route, Google's `provider_hint`, the purchase link's "Open my account", the billing Purchases list and One Tap with its CSP (#11096) — verified against `lib/hub-session/{spoke-sign-in.tsx,entry.ts,one-tap.tsx,session.ts}`, `app/api/hub-session/{email,open,one-tap}/` and `middleware.ts`.
|
|
688
|
+
|
|
689
|
+
Prior: 2026-11-05 — § The MCP authorization server: one issuer per token — the plugin's optional `issuerTag` and `signInLocation`, the refusal of another issuer's token, refresh and code, and the Admin's byte-identical copy (#10912) — verified against `lib/mcp-oauth.ts` and `auth.ts`.
|
|
649
690
|
|
|
650
691
|
Prior: 2026-11-02 — § Theme & styling: `consent.appearance` named beside the other `_site.mdx` chrome keys, and the minimal deck home's hold-back is the band's alone, so a minimal site that picks the card sees it on load there too (#10721) — verified against `app/[locale]/layout.tsx`.
|
|
651
692
|
|
|
@@ -29,6 +29,8 @@ jest.mock("../../../../lib/auth-env", () => ({
|
|
|
29
29
|
isSignUpOpen: () => mockIsSignUpOpen(),
|
|
30
30
|
isResetAvailable: () => mockIsResetAvailable(),
|
|
31
31
|
resetSendConfigured: () => mockResetSendConfigured(),
|
|
32
|
+
// #11106 D9 — auth.ts asks whether to install the phone plugin.
|
|
33
|
+
phoneVerificationConfigured: () => false,
|
|
32
34
|
}));
|
|
33
35
|
|
|
34
36
|
const mockRequestPasswordReset = jest.fn();
|
|
@@ -78,6 +78,15 @@ jest.mock("../../../../../auth", () => ({
|
|
|
78
78
|
__esModule: true,
|
|
79
79
|
resolveSecret: () => TEST_SECRET,
|
|
80
80
|
}));
|
|
81
|
+
// #11095 D7 — the remembered-method cookie, read through `cookies()`.
|
|
82
|
+
const mockCookies: Record<string, string> = {};
|
|
83
|
+
jest.mock("next/headers", () => ({
|
|
84
|
+
__esModule: true,
|
|
85
|
+
cookies: async () => ({
|
|
86
|
+
get: (name: string) =>
|
|
87
|
+
name in mockCookies ? { name, value: mockCookies[name] } : undefined,
|
|
88
|
+
}),
|
|
89
|
+
}));
|
|
81
90
|
const mockClientInfo = jest.fn();
|
|
82
91
|
jest.mock("@working-theory/api-client", () => ({
|
|
83
92
|
__esModule: true,
|
|
@@ -123,6 +132,7 @@ async function renderPage(next?: string, error?: string): Promise<void> {
|
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
beforeEach(() => {
|
|
135
|
+
for (const name of Object.keys(mockCookies)) delete mockCookies[name];
|
|
126
136
|
mockGetActiveProviderIds.mockReset().mockReturnValue(["google"]);
|
|
127
137
|
mockIsResetAvailable.mockReset().mockReturnValue(false);
|
|
128
138
|
mockSocial.mockReset().mockResolvedValue({ data: {}, error: null });
|
|
@@ -365,7 +375,8 @@ describe("/sign-in page — the spoke back link (#8790 D2)", () => {
|
|
|
365
375
|
await renderPage(`/api/auth/hub/continue/${ref}`);
|
|
366
376
|
expect(mockClientInfo).toHaveBeenCalledWith("spoke_1");
|
|
367
377
|
const back = screen.getByTestId("auth-back-link");
|
|
368
|
-
|
|
378
|
+
// #11095 D5: the spoke's home — its /account would start the hub hop again.
|
|
379
|
+
expect(back).toHaveAttribute("href", "https://wendihenry.com/");
|
|
369
380
|
// This suite's next-intl shim returns messages uninterpolated, so the
|
|
370
381
|
// label's shape is what is asserted here; the ICU fill is next-intl's.
|
|
371
382
|
expect(back).toHaveTextContent(/^Back to/);
|
|
@@ -575,3 +586,43 @@ describe("/sign-in page — the Sign up toggle keeps the next (#9912 D4)", () =>
|
|
|
575
586
|
);
|
|
576
587
|
});
|
|
577
588
|
});
|
|
589
|
+
|
|
590
|
+
// #11095 AC-6 (D7): a returning person's card leads with the provider they
|
|
591
|
+
// last launched; a value that does not parse changes nothing.
|
|
592
|
+
describe("/sign-in page — the remembered method (#11095 D7)", () => {
|
|
593
|
+
it("with ailk-sign-in-method=google: Continue with Google first, no email field, and Use another way restores the card", async () => {
|
|
594
|
+
const user = userEvent.setup();
|
|
595
|
+
mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
|
|
596
|
+
mockCookies["ailk-sign-in-method"] = "google";
|
|
597
|
+
await renderPage();
|
|
598
|
+
const lead = screen.getByTestId("auth-sso-google");
|
|
599
|
+
expect(lead).toHaveTextContent(`${en.signIn.continueWith} ${en.signIn.google}`);
|
|
600
|
+
expect(screen.getAllByRole("button")[0]).toBe(lead);
|
|
601
|
+
expect(screen.queryByTestId("auth-email")).toBeNull();
|
|
602
|
+
const another = screen.getByTestId("sign-in-use-another-way");
|
|
603
|
+
expect(another).toHaveTextContent(en.signIn.useAnotherWay);
|
|
604
|
+
|
|
605
|
+
await user.click(another);
|
|
606
|
+
expect(screen.getByTestId("auth-email")).toBeInTheDocument();
|
|
607
|
+
expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
it.each([
|
|
611
|
+
["evil", ["google", "magic-link"]],
|
|
612
|
+
["github", ["google", "magic-link"]],
|
|
613
|
+
["", ["google", "magic-link"]],
|
|
614
|
+
])(
|
|
615
|
+
"a cookie of %j (not an active provider) renders exactly the no-cookie card",
|
|
616
|
+
async (value, active) => {
|
|
617
|
+
mockGetActiveProviderIds.mockReturnValue(active);
|
|
618
|
+
await renderPage();
|
|
619
|
+
const today = document.body.innerHTML;
|
|
620
|
+
document.body.innerHTML = "";
|
|
621
|
+
|
|
622
|
+
mockCookies["ailk-sign-in-method"] = value;
|
|
623
|
+
await renderPage();
|
|
624
|
+
expect(document.body.innerHTML).toBe(today);
|
|
625
|
+
expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
|
|
626
|
+
},
|
|
627
|
+
);
|
|
628
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The remembered-method cookie (#11095 D7, AC-6): it names one provider id
|
|
3
|
+
* and nothing else, and only an id the page offers parses.
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
REMEMBERED_METHOD_COOKIE,
|
|
7
|
+
parseRememberedMethod,
|
|
8
|
+
rememberMethod,
|
|
9
|
+
} from "../remembered-method";
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
document.cookie = `${REMEMBERED_METHOD_COOKIE}=; Max-Age=0; Path=/`;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("parseRememberedMethod", () => {
|
|
16
|
+
it("answers an active google or github", () => {
|
|
17
|
+
expect(parseRememberedMethod("google", ["google", "github"])).toBe(
|
|
18
|
+
"google",
|
|
19
|
+
);
|
|
20
|
+
expect(parseRememberedMethod("github", ["github"])).toBe("github");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it.each([
|
|
24
|
+
[undefined, ["google"]],
|
|
25
|
+
["", ["google"]],
|
|
26
|
+
["evil", ["google"]],
|
|
27
|
+
["github", ["google"]],
|
|
28
|
+
["Google", ["google"]],
|
|
29
|
+
["google ", ["google"]],
|
|
30
|
+
] as const)("refuses %j with providers %j", (raw, providers) => {
|
|
31
|
+
expect(parseRememberedMethod(raw, [...providers])).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("rememberMethod", () => {
|
|
36
|
+
it("writes the provider id alone, and null clears it", () => {
|
|
37
|
+
expect(REMEMBERED_METHOD_COOKIE).toBe("ailk-sign-in-method");
|
|
38
|
+
rememberMethod("google");
|
|
39
|
+
expect(document.cookie).toBe("ailk-sign-in-method=google");
|
|
40
|
+
rememberMethod(null);
|
|
41
|
+
expect(document.cookie).toBe("");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -16,10 +16,14 @@ import { render, screen } from "@testing-library/react";
|
|
|
16
16
|
import userEvent from "@testing-library/user-event";
|
|
17
17
|
|
|
18
18
|
const mockFetch = jest.fn();
|
|
19
|
+
const mockSocial = jest.fn();
|
|
19
20
|
jest.mock("better-auth/react", () => ({
|
|
20
21
|
__esModule: true,
|
|
21
22
|
createAuthClient: () => ({
|
|
22
|
-
signIn: {
|
|
23
|
+
signIn: {
|
|
24
|
+
social: (...args: unknown[]) => mockSocial(...args),
|
|
25
|
+
email: jest.fn(),
|
|
26
|
+
},
|
|
23
27
|
$fetch: (...args: unknown[]) => mockFetch(...args),
|
|
24
28
|
}),
|
|
25
29
|
}));
|
|
@@ -59,8 +63,18 @@ async function requestLink(email = "member@example.com"): Promise<void> {
|
|
|
59
63
|
await user.click(screen.getByTestId("auth-submit"));
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
/** Clears every cookie jsdom holds, so each case starts with none. */
|
|
67
|
+
function clearCookies(): void {
|
|
68
|
+
for (const pair of document.cookie.split(";")) {
|
|
69
|
+
const name = pair.split("=")[0]?.trim();
|
|
70
|
+
if (name) document.cookie = `${name}=; Max-Age=0; Path=/`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
beforeEach(() => {
|
|
63
75
|
mockFetch.mockReset().mockResolvedValue({ data: { status: true }, error: null });
|
|
76
|
+
mockSocial.mockReset().mockResolvedValue({ data: {}, error: null });
|
|
77
|
+
clearCookies();
|
|
64
78
|
});
|
|
65
79
|
|
|
66
80
|
describe("SignInCard — email sign-in link (#7435)", () => {
|
|
@@ -157,3 +171,96 @@ describe("SignInCard — email sign-in link (#7435)", () => {
|
|
|
157
171
|
expect(screen.getByText("Sign-in is not configured.")).toBeInTheDocument();
|
|
158
172
|
});
|
|
159
173
|
});
|
|
174
|
+
|
|
175
|
+
// #11095 AC-6 (D7): the card remembers the provider a person launched, and a
|
|
176
|
+
// returning person sees that one first, the rest behind "Use another way".
|
|
177
|
+
describe("SignInCard — the remembered method (#11095 D7)", () => {
|
|
178
|
+
const LABELS = {
|
|
179
|
+
emailLinkSubmit: "Email me a sign-in link",
|
|
180
|
+
ssoPrefix: "Sign in with",
|
|
181
|
+
google: "Google",
|
|
182
|
+
github: "GitHub",
|
|
183
|
+
};
|
|
184
|
+
const leadProps = (overrides: Partial<SignInCardProps> = {}) =>
|
|
185
|
+
props({
|
|
186
|
+
method: "password",
|
|
187
|
+
providers: ["google", "github"],
|
|
188
|
+
labels: LABELS,
|
|
189
|
+
continueWith: "Continue with",
|
|
190
|
+
useAnotherWay: "Use another way",
|
|
191
|
+
...overrides,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("writes the provider id before the provider launch is called", async () => {
|
|
195
|
+
const user = userEvent.setup();
|
|
196
|
+
let cookieAtLaunch = "";
|
|
197
|
+
mockSocial.mockImplementation(() => {
|
|
198
|
+
cookieAtLaunch = document.cookie;
|
|
199
|
+
return Promise.resolve({ data: {}, error: null });
|
|
200
|
+
});
|
|
201
|
+
render(<SignInCard {...leadProps()} />);
|
|
202
|
+
await user.click(screen.getByTestId("auth-social-google"));
|
|
203
|
+
expect(mockSocial).toHaveBeenCalledTimes(1);
|
|
204
|
+
expect(cookieAtLaunch).toContain("ailk-sign-in-method=google");
|
|
205
|
+
// It names the method only: no email, no user id, no time.
|
|
206
|
+
expect(document.cookie).toBe("ailk-sign-in-method=google");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("an email-link request clears it", async () => {
|
|
210
|
+
document.cookie = "ailk-sign-in-method=google; Path=/";
|
|
211
|
+
render(<SignInCard {...leadProps({ method: "sso", providers: [] })} />);
|
|
212
|
+
await requestLink();
|
|
213
|
+
expect(document.cookie).not.toContain("ailk-sign-in-method");
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("with a remembered provider: one Continue with button first, no email field, and Use another way", () => {
|
|
217
|
+
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
218
|
+
const lead = screen.getByTestId("auth-sso-google");
|
|
219
|
+
expect(lead).toHaveTextContent("Continue with Google");
|
|
220
|
+
expect(screen.getAllByRole("button")[0]).toBe(lead);
|
|
221
|
+
expect(screen.queryByTestId("auth-sso-github")).toBeNull();
|
|
222
|
+
expect(screen.queryByTestId("auth-email")).toBeNull();
|
|
223
|
+
expect(screen.queryByTestId("auth-password")).toBeNull();
|
|
224
|
+
expect(screen.getByTestId("sign-in-use-another-way")).toHaveTextContent(
|
|
225
|
+
"Use another way",
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("Use another way restores the full card", async () => {
|
|
230
|
+
const user = userEvent.setup();
|
|
231
|
+
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
232
|
+
await user.click(screen.getByTestId("sign-in-use-another-way"));
|
|
233
|
+
expect(screen.getByTestId("auth-email")).toBeInTheDocument();
|
|
234
|
+
expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
|
|
235
|
+
expect(screen.getByTestId("auth-social-github")).toBeInTheDocument();
|
|
236
|
+
expect(screen.queryByTestId("auth-sso-google")).toBeNull();
|
|
237
|
+
expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("the lead button launches its provider", async () => {
|
|
241
|
+
const user = userEvent.setup();
|
|
242
|
+
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
243
|
+
await user.click(screen.getByTestId("auth-sso-google"));
|
|
244
|
+
expect(mockSocial).toHaveBeenCalledTimes(1);
|
|
245
|
+
expect(document.cookie).toBe("ailk-sign-in-method=google");
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("a failed launch from the lead button shows the provider error", async () => {
|
|
249
|
+
const user = userEvent.setup();
|
|
250
|
+
mockSocial.mockRejectedValueOnce(new Error("boom"));
|
|
251
|
+
render(<SignInCard {...leadProps({ remembered: "google" })} />);
|
|
252
|
+
await user.click(screen.getByTestId("auth-sso-google"));
|
|
253
|
+
expect(await screen.findByTestId("sign-in-provider-error")).toBeInTheDocument();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it("with no remembered provider the card renders as today", () => {
|
|
257
|
+
const { container: today } = render(
|
|
258
|
+
<SignInCard {...props({ method: "password", providers: ["google"], labels: LABELS })} />,
|
|
259
|
+
);
|
|
260
|
+
const before = today.innerHTML;
|
|
261
|
+
today.remove();
|
|
262
|
+
const { container } = render(<SignInCard {...leadProps({ providers: ["google"] })} />);
|
|
263
|
+
expect(container.innerHTML).toBe(before);
|
|
264
|
+
expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
|
|
265
|
+
});
|
|
266
|
+
});
|
|
@@ -28,14 +28,23 @@
|
|
|
28
28
|
* so a buyer who switches to sign-up keeps the destination; a refused or
|
|
29
29
|
* absent `next` gives the bare `/sign-up`.
|
|
30
30
|
*
|
|
31
|
-
* Signed-in visitors are not redirected here — the Nav's
|
|
32
|
-
*
|
|
31
|
+
* Signed-in visitors are not redirected here — the Nav's "Your account" link
|
|
32
|
+
* is the affordance for them (#11095 D6).
|
|
33
|
+
*
|
|
34
|
+
* Remembered method (#11095 D7): the `ailk-sign-in-method` cookie, read here
|
|
35
|
+
* and parsed against the active providers (`remembered-method.ts`), lets the
|
|
36
|
+
* card lead with the provider the person last launched. A value that does
|
|
37
|
+
* not parse is today's render.
|
|
38
|
+
*
|
|
39
|
+
* The spoke back link goes to the spoke's home (#11095 D5): its `/account`
|
|
40
|
+
* would start the hub sign-in again.
|
|
33
41
|
*/
|
|
34
42
|
|
|
35
43
|
import { hubSignIn } from "@working-theory/api-client";
|
|
36
44
|
import { localeHref } from "@working-theory/ui";
|
|
37
45
|
import { accountEmailHintSchema } from "@working-theory/validation";
|
|
38
46
|
import type { Metadata } from "next";
|
|
47
|
+
import { cookies } from "next/headers";
|
|
39
48
|
import { getTranslations } from "next-intl/server";
|
|
40
49
|
import type { ReactElement } from "react";
|
|
41
50
|
|
|
@@ -51,6 +60,10 @@ import {
|
|
|
51
60
|
import { legalFootnote } from "../legal-footnote";
|
|
52
61
|
|
|
53
62
|
import { hrefWithNext, resolveNextPath } from "./next-path";
|
|
63
|
+
import {
|
|
64
|
+
REMEMBERED_METHOD_COOKIE,
|
|
65
|
+
parseRememberedMethod,
|
|
66
|
+
} from "./remembered-method";
|
|
54
67
|
import { SignInCard, type SignInProvider } from "./sign-in-card";
|
|
55
68
|
import { resolveSignInCardText, type SignInCardText } from "./sign-in-text";
|
|
56
69
|
|
|
@@ -94,6 +107,18 @@ function linkNoticeFor(
|
|
|
94
107
|
: text.errorLabels.signInFailed;
|
|
95
108
|
}
|
|
96
109
|
|
|
110
|
+
/**
|
|
111
|
+
* #11095 D7 — the raw remembered-method cookie. A read that throws (no
|
|
112
|
+
* request scope) is no cookie, so the card renders as today.
|
|
113
|
+
*/
|
|
114
|
+
async function rememberedCookie(): Promise<string | undefined> {
|
|
115
|
+
try {
|
|
116
|
+
return (await cookies()).get(REMEMBERED_METHOD_COOKIE)?.value;
|
|
117
|
+
} catch {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
97
122
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
98
123
|
const { locale } = await params;
|
|
99
124
|
const t = await getTranslations({ locale, namespace: "signIn" });
|
|
@@ -156,6 +181,7 @@ export default async function SignInPage({
|
|
|
156
181
|
// Only the email link produces `?error=` here; with it off, today's render.
|
|
157
182
|
const linkNotice = emailLink ? linkNoticeFor(error, text) : undefined;
|
|
158
183
|
const defaultEmail = hintedEmail(rawEmail);
|
|
184
|
+
const remembered = parseRememberedMethod(await rememberedCookie(), providers);
|
|
159
185
|
|
|
160
186
|
const spoke = await spokeFromNext(next);
|
|
161
187
|
const t = await getTranslations({ locale, namespace: "signIn" });
|
|
@@ -165,7 +191,7 @@ export default async function SignInPage({
|
|
|
165
191
|
{...(spoke
|
|
166
192
|
? {
|
|
167
193
|
backLink: {
|
|
168
|
-
href: `${spoke.origin}
|
|
194
|
+
href: `${spoke.origin}/`,
|
|
169
195
|
label: t("backTo", { site: spoke.name }),
|
|
170
196
|
},
|
|
171
197
|
}
|
|
@@ -196,6 +222,13 @@ export default async function SignInPage({
|
|
|
196
222
|
{...(linkNotice !== undefined ? { linkNotice } : {})}
|
|
197
223
|
{...(defaultEmail !== undefined ? { defaultEmail } : {})}
|
|
198
224
|
emailLinkLabels={text.emailLinkLabels}
|
|
225
|
+
{...(remembered !== undefined
|
|
226
|
+
? {
|
|
227
|
+
remembered,
|
|
228
|
+
continueWith: text.continueWith,
|
|
229
|
+
useAnotherWay: text.useAnotherWay,
|
|
230
|
+
}
|
|
231
|
+
: {})}
|
|
199
232
|
/>
|
|
200
233
|
);
|
|
201
234
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The remembered sign-in method (#11095 D7): one cookie naming the provider a
|
|
3
|
+
* person last launched on this card, so a returning person sees that one
|
|
4
|
+
* first. It names the method only — one of `google` or `github`, never an
|
|
5
|
+
* email, a user id or a time — and only reorders the card: it never changes
|
|
6
|
+
* who may sign in. An email method clears it, because the card already leads
|
|
7
|
+
* with the email field.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { SignInProvider } from "./sign-in-card";
|
|
11
|
+
|
|
12
|
+
export const REMEMBERED_METHOD_COOKIE = "ailk-sign-in-method";
|
|
13
|
+
|
|
14
|
+
/** One year, in seconds. */
|
|
15
|
+
const MAX_AGE_SECONDS = 31_536_000;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The remembered provider, only when the raw value is exactly `google` or
|
|
19
|
+
* `github` and is one of the page's active `providers`; otherwise `undefined`.
|
|
20
|
+
*/
|
|
21
|
+
export function parseRememberedMethod(
|
|
22
|
+
raw: string | undefined,
|
|
23
|
+
providers: readonly SignInProvider[],
|
|
24
|
+
): SignInProvider | undefined {
|
|
25
|
+
if (raw !== "google" && raw !== "github") return undefined;
|
|
26
|
+
return providers.includes(raw) ? raw : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Browser only: remember `provider`, or clear the cookie with `null`. */
|
|
30
|
+
export function rememberMethod(provider: SignInProvider | null): void {
|
|
31
|
+
if (typeof document === "undefined") return;
|
|
32
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
33
|
+
document.cookie =
|
|
34
|
+
provider === null
|
|
35
|
+
? `${REMEMBERED_METHOD_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax${secure}`
|
|
36
|
+
: `${REMEMBERED_METHOD_COOKIE}=${provider}; Path=/; Max-Age=${MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
|
|
37
|
+
}
|