create-ailk 0.36.0 → 0.37.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/component-catalog.json +40 -1
- package/component-catalog.md +7 -5
- package/dist/surfaces.js +60 -19
- package/dist/update.d.ts +19 -1
- package/dist/update.js +293 -35
- package/package.json +3 -3
- package/templates/.env.example +17 -0
- package/templates/apps/api/.env.example +38 -0
- package/templates/apps/api/CLAUDE.md +3 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +1 -1
- package/templates/apps/web/CLAUDE.md +28 -1
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +240 -76
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +369 -196
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +19 -3
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +309 -113
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +192 -65
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +55 -58
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +2 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +3 -2
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +18 -21
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +263 -0
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
- package/templates/apps/web/lib/account-config.ts +132 -8
- package/templates/apps/web/lib/auth-routes.ts +11 -6
- package/templates/apps/web/lib/offerings-pricing.ts +4 -1
- package/templates/apps/web/messages/en.json +156 -80
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
|
@@ -75,6 +75,7 @@ Routes are versioned under `/v1/*`:
|
|
|
75
75
|
- `/v1/workspaces/:workspaceId/meetings` (GET/PUT) — the operator's enabled-slug gate for meeting types (#6183 S9b, `src/routes/workspaces/meetings.ts`). Beside the three siblings above in URL shape and tenant-isolation posture, but registered in its OWN scope, gated on `isModuleEnabled("scheduling")` ALONE — not the `workspace`/`multi-tenant` scope its siblings share, because its GET reaches `services/scheduling/` (see below), which a scaffold without that module does not carry (#5701; since #9565 the package boundary — `@working-theory/api-scheduling` owns both files). PUT needs `meeting-types-manage` (owner, admin — `@working-theory/validation`'s permission table (#7636 D2)) because this blob decides which pages the public site serves. GET answers `meeting-types-manage` with the full join and `meeting-types-read` (every role, a member included) with the ENABLED rows only (#7636 D6) — since it does NOT just return the stored blob, it echoes the deployment's whole provider catalog, including the rows the operator chose not to publish (security review, 2026-09-19), which a member never sees. GET is the one segment in this file's family that does NOT just return the stored blob: it ALSO lists the scheduling provider's own bookable event types (`listEventTypes`, #6182), joined with `enabled: boolean` (Live, at any visibility) and `visibility`; an unconfigured/unreachable provider answers the same `SchedulingErrorKind` outcome `/v1/schedule/*` uses, distinct from an empty list. **`visibility` is on every row (#11122 D4)** — `public`, `private` or `authenticated`, from the stored lists by `@working-theory/validation`'s `meetingVisibilityOf` (`authenticated` when `customerSlugs` holds the slug, else `private` when `privateSlugs` does, else `public`) — with the provider's `providerEventTypeId` and `createdAt` when it serves them; `providerEditUrl` (the provider's edit page for the type) is on the `meeting-types-manage` full join only, never a `meeting-types-read` caller's. There is no `include` query any more (it was a comma list, #9128): a caller still sending one gets the same body. **`customerSlugs` (#8171 D5) and `privateSlugs` (#8843 D2) are exclusive (#11122 D5)** — `customerSlugs` makes a type Authenticated (booked from the member area only, never listed on the site), `privateSlugs` Private (listed on `/private` rather than `/meet`). A body naming one slug in both is `400 validation_failed`; a list the body leaves out keeps the stored list less every slug the sent list holds, so the sent list wins (a read then a write, last-writer-wins) and the public toggle never erases either. `enabledSlugs` keeps its whole-list meaning — Live at any visibility — so a writer of either list sends the `enabledSlugs` it read. An agent's PUT is audited `meetings.set_customers` when it carries `customerSlugs`, else `meetings.set_enabled`. Its MCP twins are the signed-in `list_meeting_types` (GET) and `save_meeting_types` (PUT) (#10950, `@working-theory/mcp-scheduling`); both parse `@working-theory/validation` schemas — `inboxWorkspaceParamsSchema`, `meetingsConfigSchema` (site-config's `MeetingsSchema`, moved). The `…/meetings/connection` routes have no tool, by decision (`scheduling-connection` is never agent-grantable).
|
|
76
76
|
- `/v1/workspaces/:workspaceId/meetings/connection` (GET, PUT, DELETE) — the workspace's own scheduling connection (#7533, `src/routes/workspaces/meetings.ts`; data access and the cipher in `src/services/scheduling/connections.ts`, the only file that touches `prisma.schedulingConnection`). Same registration, scope and tenant guard as the meetings route above. GET, PUT and DELETE all need `scheduling-connection` (owner, admin — `@working-theory/validation`'s permission table (#7636 D2), the operator's 2026-10-04 decision overturning SEC-7533-11's owner-only write). GET answers `null` or a summary — `provider`, `baseUrl`, `webhookPath`, `createdAt`, `updatedAt` — with no credential, secret, ciphertext or hint of one. PUT takes a strict `{ provider, apiKey, baseUrl? }`; create and replace are one operation, and every PUT mints a new webhook token and secret, returning the secret this once (`Cache-Control: no-store`) so the operator can paste it into the provider — a replace cuts off the previous entry point. `baseUrl` must be `https://api.cal.com` or the deployment's own `CAL_API_BASE_URL` origin, with no path, query or userinfo (`400 base_url_not_allowed`); only the bare origin is stored. The credential and the secret are AES-256-GCM ciphertext under `SCHEDULING_CREDENTIAL_KEY`, bound to the workspace and the column; with the key unset, PUT answers `503 credential_key_not_configured` before any write. DELETE is idempotent (`{ revoked }`) and unconfigures the workspace at once. Because a connection replaces the account every provider call uses, every successful PUT, and every DELETE that revoked a row, writes one `recordAgentAction` audit row (`scheduling.connection.{connect,replace,remove}`; a PUT is `replace` whenever the workspace was served by any provider before it — its own row, or the env credential on a one-workspace deployment) and emails every OTHER owner of the organization through `@working-theory/email`'s `sendSchedulingConnectionChangedEmail` (#7636 D7). Neither step can fail the write: a failed audit is logged at `error`, and the notify step runs in its own `try`, so the one-time secret is always returned; with no sender address or no Resend key it is skipped with a `warn`. Logs carry the recipient count, never an address. The meetings GET above, and the three anonymous `/v1/schedule/*` provider routes below, resolve their provider through `src/services/scheduling/resolve.ts`: a workspace's own row always wins; `CAL_API_KEY` serves a workspace only on a one-workspace deployment; otherwise `not_configured`. No MCP twin — identity-bound tenant routes (#3591 exception).
|
|
77
77
|
- `/v1/workspaces/:workspaceId/slack-connection` (GET, POST, DELETE) — the Organization's own Slack connection (#9748, `packages-paid/api-workspace/src/routes/workspaces/slack-connection.ts`; data access, the Slack calls and the cipher in `packages/api/src/services/slack/connection.ts`, the only file that touches `prisma.slackConnection`). One `TENANCY` row in the `tenant:settings` scope, so it loads on single-tenant Pro, multi-tenant Pro Plus and the hub, and a selected but unlicensed build answers `403 feature_required`; the tenant guard refuses another Organization's `:workspaceId`, and every route acts on `request.tenant.organizationId` only. GET needs any tenant (an agent included) and answers exactly `{ connected: false }` or `{ connected: true, teamName, connectedAt }` — a missing row, a row failing its grammar and a value that does not decrypt all read as not connected, never a throw (there is no environment credential). POST and DELETE need `billing-manage` (the owner alone) and refuse an agent tenant (`403`). POST's order: tenant → owner → write budget (`slackconn`, 10 an hour per Organization, 20 per person, `429` with `Retry-After`) → `SLACK_CONNECTION_KEY` (`503 credential_key_not_configured`) → the strict `{ botToken, signingSecret }` body (4 KiB, `400 validation_failed`) → Slack: `auth.test` (validity, a bot token of one workspace, the granted scopes) then `team.billing.info` (the plan), one 10 s budget, the token only in the `Authorization` header with redirects refused. Refusals: `400 slack_token_refused` (`reason` `token_refused`, `not_bot_token` or `enterprise_install`), `400 slack_scopes_missing` naming every missing one of the nine bot scopes (`conversations.connect:write`, `groups:write`, `channels:manage`, `chat:write`, `team.billing:read`, and since #9854 `groups:read`, `groups:history`, `users:read`, `users:read.email` — an Organization connected before #9854 still reads connected, but its owner lookup answers `missing_scope` and no events arrive until the owner reconnects), `400 slack_paid_plan_required` on Slack's free plan, `502 slack_unavailable`, `409 slack_team_connected_elsewhere` (one Slack team, one Organization) and `409 connection_changed` (the row moved during verification) — each storing nothing. Success answers the status shape; the token and secret are AES-256-GCM ciphertext under `SLACK_CONNECTION_KEY` (`_PREVIOUS` decrypts during a rotation), bound to the Organization, the Slack team and the column. DELETE needs no key, touches no prospect-channel settings or channel record, and answers `{ removed }` — it does NOT revoke the token at Slack, which stays valid until the owner rotates it or uninstalls the app. Connect, replace and remove each write one `integrations.slack_connection.{connect,replace,remove}` audit row (summary: the team id) and email every owner, the actor included, through `sendSlackConnectionChangedEmail`; neither can change the answer. No response, log line, audit row or email carries the token, the secret or a ciphertext. No MCP twin for connect or disconnect — a person's act, recorded as no-tool rows in `tests/parity/README.md`; the status read's twin is the signed-in `get_slack_connection_status` (#9749), for which GET parses its `:workspaceId` (`400 validation_failed` when malformed).
|
|
78
|
+
- `/v1/workspaces/:workspaceId/connections` (GET), `/v1/workspaces/:workspaceId/connections/:provider` (GET, PUT, DELETE), `/v1/workspaces/:workspaceId/connections/:provider/oauth/start` and `…/oauth/callback` (POST) — the shared connection model (#11173, ADR 0039; `packages-paid/api-workspace/src/routes/workspaces/connections.ts`; the five verbs in `packages/api/src/services/connections/`, whose `store.ts` is the only file that touches `prisma.connection`). One `TENANCY` row in the `tenant:settings` scope beside the Slack routes above, behind the same tenant guard. The list and the one-provider read answer every registered provider record's four-state status — `google`, `stripe`, `slack`, and `cal-com` where the scheduling slice is present — to a caller who may read it (a record's `readPermission` / `agentReadable`; an omitted record is absent from the list and `404 provider_unknown` alone, so the gate leaks nothing). Every write is a person's act: the scope's permission (`billing-manage` for an Organization-scoped record, `workspace-settings` for a workspace-scoped one), never an agent; the `connwrite` budget (10 an hour per Organization, 20 per person); `CONNECTION_KEY` (503 `credential_key_not_configured`). `PUT` is the key-only and webhook connect (`{ credential, settings? }`, the record's own strict schemas); a legacy name (Stripe, Slack, Cal.com) is `409 provider_legacy` — their own routes stay the way to change them. The OAuth pair: start answers `{ authorizeUrl, state }` with a sealed, bound state the Admin keeps in the browser that started; the callback verifies the state locally before the budget is charged, exchanges the code with the PKCE verifier, and writes the grant as `connect`, `replace` or `reconnect`. `DELETE` deletes by compare-and-swap and then revokes the deleted row's own grant, answering `{ removed, revoked }`. After a write: one audit row (`integrations` / `connection.<action>`, the opaque account id, never an email) and one `sendConnectionChangedEmail` to every owner. No response or log line carries a token, a code, a verifier, a state token or a ciphertext; every response is `Cache-Control: private, no-store`. No MCP twin for any of the six, by decision (tests/parity/README.md): the status reads' twin is deferred to the Google Analytics unit.
|
|
78
79
|
- `/v1/workspaces/:workspaceId/prospect-channel` (GET, PUT) — the workspace's prospect-channel settings (#9749, spec `docs/specs/9749-workspace-prospect-channel-settings-get-spec.md`; `packages-paid/api-scheduling/src/routes/workspaces/meetings.ts`, beside the meetings routes, so the same `SCHEDULING` row and `tenant:schedule` scope; data access only through `tenantDb(tenant).prospectChannelSettings`). The blob is `prospectChannelSettingsSchema` (#9747): `enabled`, `memberIds` (Slack member ids invited in addition to the owner who connected Slack, who the channel step always invites), `welcomeTemplate?`, `channelPrefix`, `archiveDays`. GET needs `meeting-types-read` and answers the schema's defaults (`{ enabled: false, memberIds: [], channelPrefix: "prospect", archiveDays: 30 }`) when no row — or a row the schema refuses, logged `settings_unreadable` — is stored. PUT needs `meeting-types-manage` (owner, admin, or an agent an owner or admin granted it; a member is `403` before the body is read), replaces the whole blob after the strict schema accepts the body (32 KiB limit; an omitted field returns to its default; last writer wins), and is refused `409 slack_not_connected` whenever `getSlackConnectionStatus(tenant.organizationId)` answers not connected, whatever the body. An agent's PUT may change `enabled`, `channelPrefix` and `archiveDays` only: a `memberIds` or `welcomeTemplate` different from what is stored is `403 prospect_channel_needs_person`. Every saved PUT writes one `scheduling.prospect_channel.update` audit row naming its actor, person or agent, with the saved `enabled` and `memberIds` and whether the welcome changed (never its text). Every answer is `Cache-Control: private, no-store`; an unexpected error is `500 internal`, logged by class name. Twins: the signed-in `get_prospect_channel_settings` and `set_prospect_channel_settings`, served from `@working-theory/mcp-scheduling`.
|
|
79
80
|
- `/v1/workspaces/:workspaceId/general` (GET/PUT) — the workspace's own display name and logo, the Pro `workspace` module's general-settings surface (#5371). Registered under `isModuleEnabled("workspace") || isModuleEnabled("multi-tenant")` alongside the site-config routes above, behind the same tenant guard; the scope is always `request.tenant.workspaceId`, never the path param (the guard 403s a mismatch before any handler runs). PUT takes a strict `{ name, logo }` body (name 1–200 chars, trimmed; `logo` an https:// URL, or `null`/empty to clear it) and answers `{ name, logo }`; GET answers `{ name, logo, emailFrom }` (`logo` `null` when the organization's applies, #10021; `emailFrom` #7519 D6), where `emailFrom` is the deployment's sender (`deliverableSenderAddress()` — `AILK_DELIVERABLE_EMAIL_FROM ?? AILK_LEAD_NOTIFICATION_FROM`, the resolver the fulfillment service sends with) or `null` when neither is set, so the Admin's magnet wizard can show it read-only. Role floor on PUT: `workspace-settings` (owner, admin — `@working-theory/validation`'s permission table (#7636 D2)) — renaming is an org-level settings write; GET stays open to every member. MCP parity: the GET's twin is `get_workspace_settings` on `/mcp/workspace` (#10951); the PUT has no tool — it needs `workspace-settings`, which is never agent-grantable — recorded in `tests/parity/README.md`.
|
|
80
81
|
- `/v1/workspaces/:workspaceId/messages/threads` (GET, `?view=&page=`), `/v1/workspaces/:workspaceId/messages` (GET, `?limit=`), `/v1/workspaces/:workspaceId/messages/:leadId` (GET, PATCH) — the Inbox message API (#6216 S7e, `src/routes/workspaces/messages.ts`): the thread list (#9686 — a client with a message, or a message with no client, newest first, 25 to a page, with a true count per view `open`/`resolved`/`all`/`archived`; twin `list_inbox_threads`), the workspace's messages whose thread is not archived newest first, the item read (resolves a message handled or not, serving `handledAt`), and Done, which archives the message's thread (#9686 D4). Registered under `isModuleEnabled("workspace") || isModuleEnabled("multi-tenant")`, the same scope as the two routes above. A message is a `Lead` whose `source` is in #6204's closed `MESSAGE_LEAD_SOURCE_LIST` allowlist and that is not an order (#9170, the orders bullet below) — both checked only in `tenantDb(tenant).leads`, never in this file; a non-message lead is a 404 on the item read and the PATCH and absent from the list, the SAME 404 body as an absent id, another workspace's id, or an unbackfilled `workspaceId`. **One served row across all four routes** — `id`, `name`, `email`, `source`, `createdAt`, `handledAt`, `personId`, `body`, `excerpt` — and nothing else (#9349, superseding the 2026-09-19 six-key ruling): `personId` is the lead's Person or `null`; `body` is `payload.message` alone — cut to 16384 code units, line breaks normalized, control, bidi, zero-width and tag characters stripped (`\t` and `\n` kept), trimmed and cut at 4096 code points (`inbox-messages.ts`'s `readMessageBody`), else `null`; `excerpt` is its first line, cut at 140 code points. `payload` itself and every other payload key never cross, and every success body is re-parsed against `inboxMessageSchema` (`inboxMessageListSchema` for the list) — a mismatch is `500 internal_error` logged with issue codes and paths only. `leads-inbox.ts`'s `GET /v1/leads` row is unchanged. PATCH takes `{ "handled": true }` only, `.strict()`, so `{ "handled": false }` is a 400 — Unarchive is #9681's `PATCH …/people/:personId/thread`. **Since #9686 Done is Archive:** it archives the message's client thread through `tenantDb.people.setThreadState` (idempotent) and writes no `handledAt` — that column is read-only legacy, loaded as Archived by the `20261030120000_inbox_thread_state_backfill` migration — and a message with no client is `409 no_thread`; accept no longer marks the message handled. Role floor: the inbox gate `inboxAllowed` (`services/inbox-messages.ts`) — `inbox-read` on the GETs and `inbox-act` on PATCH and accept (`@working-theory/validation`'s permission table (#7636 D2) — every role, a member included), and an AGENT also needs the per-agent `inbox-act` grant on every inbox route, the member-area `…/people/:personId/messages` pair included (#9686 D9, closing SEC-9679-1); checked before any read or write. An Admin listing decision that changes the listing resolves the applicant's thread (`services/thread-auto-resolve.ts`, #9686 D8). The role is not self-servable: since #7523 `multi-tenant`'s null-binding fallback grants the default tenant only to the pinned, verified operator, the same check the base `workspace`-only guard applies (see the `AILK_OPERATOR_EMAIL` paragraph below). No anonymous MCP twin — identity-bound tenant routes, and the anonymous `/mcp` carries no caller identity. Each route's twin is a signed-in tool on `/mcp/workspace` (#3591 D13), which forwards the caller's agent key here: `list_inbox_messages` (list), `get_inbox_message` (item read), `mark_inbox_message_done` (PATCH) and `accept_inbox_message` (`POST …/:leadId/accept`). **Agent-session audit (#9683, spec `docs/specs/9683-agent-session-audit-knowledge-spec.md`):** an AGENT's call to any of these four routes, or to the member-area `GET`/`POST …/people/:personId/messages`, writes exactly one audit row whatever its outcome (`inbox.list_messages`, `inbox.get_message`, `inbox.mark_message_done`, `inbox.accept_message`, `people.message.list`, `people.message.create`; a `403`/`400` is `refused` against the workspace), carrying `metadata.agentSession` `{ sessionId, threadId, reason }` from `X-Agent-Session` / `X-Agent-Reason` through `api-workspace/src/lib/agent-session.ts`. `threadId` is derived by the route, never a header: `hub:<personId>` when the call resolved that Person in this workspace, else `workspace:<workspaceId>`. A person's call writes what it wrote before — nothing on these routes (#3591 § 2.3) — except Done, which is a state change and writes one `inbox.mark_message_done` row for every actor (#9686 D10); the thread list writes `inbox.list_threads` per agent call. **Accept links, never creates (#9690 D5, closing #8601):** `POST …/messages/:leadId/accept` stamps `promotedUserId` with the user the lead's Person is already linked to, and only when `personAddressProved` holds; a sender with no proved account is `409 no_account` ("Invite them to sign up"), nothing written — no code path creates a user from an inbox message, and nothing reads the deployment-wide `User` table by a typed address.
|
|
@@ -237,6 +238,8 @@ sweep's own DB constraint (never a caller-side lock).
|
|
|
237
238
|
|
|
238
239
|
Last updated: 2026-11-08 — #11122 (D4–D6): the workspace meetings bullet names `visibility` on every row, the provider's `providerEventTypeId`, `createdAt` and manage-only `providerEditUrl`, the removed `include` query and the exclusive `customerSlugs` / `privateSlugs`; the member reads join `customerSlugs` ∩ `enabledSlugs`; the `/v1/schedule/meetings` Live set is `enabledSlugs` less `customerSlugs` — per spec `docs/specs/11122-the-appointment-detail-on-the-spec.md`, against `packages/validation/src/schemas/scheduling.ts` and `packages-paid/api-scheduling/src/routes/workspaces/meetings.ts`.
|
|
239
240
|
|
|
241
|
+
Prior: 2026-11-09 — #11173: the shared connection model's six routes, their check order, the read gate and the no-twin footing — verified against `packages-paid/api-workspace/src/routes/workspaces/connections.ts`, `packages/api/src/services/connections/{index,oauth,provider,store}.ts` and `packages/api/src/config/modules.ts`.
|
|
242
|
+
|
|
240
243
|
Prior: 2026-11-07 — #11096: the `/v1/hub-sign-in/entry` and `/v1/hub-sign-in/google` bullet, their client authentication, buckets, One Tap setting and no-twin footing — verified against `packages-paid/api-hub/src/routes/auth/hub-sign-in.ts` and `packages-paid/api-hub/src/services/hub-sign-in.ts`.
|
|
241
244
|
|
|
242
245
|
Prior: 2026-11-04 — #10819: the magnets bullet names `who` (a People type) in place of the member-area customer boolean, and the standard-magnet, onboarding, request-form and `409 onboarding_off` mentions key on `who: "user"` — verified against `packages-paid/api-signal-collectors/src/routes/magnets/index.ts`, `packages/api/src/lib/{tenant-db,member-store}.ts`, `packages/api/src/services/tenant-context.ts` and `packages-paid/api-workspace/src/routes/workspaces/messages-out.ts`.
|
|
@@ -482,6 +482,13 @@ export const prisma = {
|
|
|
482
482
|
upsert: jest.fn(),
|
|
483
483
|
deleteMany: jest.fn(),
|
|
484
484
|
},
|
|
485
|
+
// #11173 D11 — the shared connection model's four calls (`services/connections/store.ts`).
|
|
486
|
+
connection: {
|
|
487
|
+
findUnique: jest.fn(),
|
|
488
|
+
create: jest.fn(),
|
|
489
|
+
updateMany: jest.fn(),
|
|
490
|
+
deleteMany: jest.fn(),
|
|
491
|
+
},
|
|
485
492
|
// ── #7532 — the hub's spoke registry (auth) and the booking origin (inbox) ─
|
|
486
493
|
// `spoke.findUnique` — the resolver's one lookup by credential digest;
|
|
487
494
|
// `create`/`updateMany`/`findMany` — the operator CLI's register, revoke and
|
|
@@ -209,7 +209,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
|
|
|
209
209
|
tools, `list_proposals` and `create_proposal`, twinning `GET`/`POST
|
|
210
210
|
/v1/workspaces/:workspaceId/people/:personId/proposals` with the same grant: a proposal is
|
|
211
211
|
private to one client, `payments` says whether approval leads to a Stripe page, and an agent's
|
|
212
|
-
price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, takes `eventTypeId` for one type's bookings (#11122 D12), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address), never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and (#10733, issue 10905, #10952) the seven Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `delete_language_item`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT`/`DELETE …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed, and the delete `content-publish` too — it removes the item from every Live page, no route restores it, and its slug stays taken; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and `PATCH …/magnets/:id` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the PATCH body whole, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot change what a magnet charges (`403 magnet_pricing_needs_person`); create and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live (and `delete_language_item`, with the same grant, clears it) — the access route answers every agent 403 `agent_refused`, and the publish, Live and Language delete routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
|
|
212
|
+
price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, takes `eventTypeId` for one type's bookings (#11122 D12), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address), never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and (#10733, issue 10905, #10952) the seven Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `delete_language_item`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT`/`DELETE …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed, and the delete `content-publish` too — it removes the item from every Live page, no route restores it, and its slug stays taken; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and `PATCH …/magnets/:id` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the PATCH body whole, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot change what a magnet charges (`403 magnet_pricing_needs_person`); create and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live (and `delete_language_item`, with the same grant, clears it) — the access route answers every agent 403 `agent_refused`, and the publish, Live and Language delete routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
|
|
213
213
|
`data`. They are in the parity guard like every other tool, and never in
|
|
214
214
|
`/.well-known/mcp.json`.
|
|
215
215
|
- **The OAuth bearer branch (#10391).** When `BETTER_AUTH_URL` (the site's origin, its OAuth
|
|
@@ -203,6 +203,31 @@ the page moves. `middleware.ts` adds Google's One Tap origins
|
|
|
203
203
|
spoke route is same-origin only, and every body is `.strict()`: a password is
|
|
204
204
|
never accepted. `claim` is in both telemetry scrub lists.
|
|
205
205
|
|
|
206
|
+
**A spoke's Security tab hosts the Password row; the hub does the sending
|
|
207
|
+
(#11162).** On a spoke that signs in through its hub, `/account/security`
|
|
208
|
+
renders the same Sign-in methods panel a hub does — no "managed at <hub>"
|
|
209
|
+
sentence and no link to the hub's Security page (that `SecuritySettings`
|
|
210
|
+
variant is retired, #11190). Its Set / Not set is read from the hub's
|
|
211
|
+
`GET /v1/hub-sign-in/me` with the session's own credential
|
|
212
|
+
(`account/security/security-source.ts`); a hub that answers no state renders
|
|
213
|
+
the panel's unavailable line, never a form. Set / Change password POSTs
|
|
214
|
+
`{ locale }` — strict, so a `password` key is 400 — to the spoke's own
|
|
215
|
+
`POST /api/hub-session/password` (same-origin, the sealed session's person,
|
|
216
|
+
never a body address), which asks the hub web's `POST /api/auth/hub/password`
|
|
217
|
+
server to server as the spoke's client: the hub API's
|
|
218
|
+
`POST /v1/hub-sign-in/password` checks the client and that the credential is
|
|
219
|
+
a live grant of THIS client, and the hub web mints Better Auth's own
|
|
220
|
+
`reset-password:<token>` row and mails the link through the signed relay, its
|
|
221
|
+
`callbackURL` the hub's `/reset-password` carrying a sealed `?ref=` of the
|
|
222
|
+
client's REGISTERED origin plus the Security path (`app/api/auth/hub/password/return.ts`).
|
|
223
|
+
`resetSendConfigured()` is checked before that API call, which charges the
|
|
224
|
+
send budgets. A completed reset ends every spoke credential
|
|
225
|
+
(`onPasswordReset`), so the hub's page returns the person to the spoke's
|
|
226
|
+
`GET /api/hub-session/password/return?next=<path>`, which clears the session
|
|
227
|
+
cookie only on the hub's 401 and 303s to `next`; the gate then shows the
|
|
228
|
+
spoke's own sign-in and brings the person back to the tab. `app/api/auth` is a
|
|
229
|
+
spoke removal seed, so no spoke carries the hub route.
|
|
230
|
+
|
|
206
231
|
## The MCP authorization server
|
|
207
232
|
|
|
208
233
|
**The site is the OAuth 2.1 authorization server an MCP client signs in through (#10357).** `auth.ts`'s block between `// mcp-oauth:begin` and `// mcp-oauth:end` installs better-auth's `mcp` plugin (dynamic client registration, S256 PKCE, one-hour access tokens, seven-day refresh tokens) and AILK's `lib/mcp-oauth.ts` beside it, only when `BETTER_AUTH_URL` pins the issuer. The plugin is configured, never patched: every AILK behaviour is a hook or an endpoint in that file.
|
|
@@ -684,7 +709,9 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
|
|
|
684
709
|
- Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
|
|
685
710
|
- Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
|
|
686
711
|
|
|
687
|
-
Last updated: 2026-11-
|
|
712
|
+
Last updated: 2026-11-08 — § The `(auth)` route group: a spoke's Security tab hosts the Password row and the hub does the sending — the spoke's `POST /api/hub-session/password` and `GET /api/hub-session/password/return`, the hub's `POST /api/auth/hub/password` and its sealed return ref (#11162, #11190) — verified against `app/api/hub-session/password/{route.ts,return/route.ts}`, `app/api/auth/hub/password/{route.ts,return.ts}` and `app/[locale]/(authed)/account/security/{page.tsx,security-source.ts}`.
|
|
713
|
+
|
|
714
|
+
Prior: 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
715
|
|
|
689
716
|
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`.
|
|
690
717
|
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/reset-password` returns a spoke's person to their Security tab (#11162
|
|
3
|
+
* AC-2).
|
|
4
|
+
*
|
|
5
|
+
* The page's decision is under test — which `completeHref`, if any, it hands
|
|
6
|
+
* the island for a `?ref=` — so the island is a double that records its
|
|
7
|
+
* props; its own navigation is pinned below with the real card and an
|
|
8
|
+
* injected `navigate`, the sibling `password-reset.test.tsx`'s idiom.
|
|
9
|
+
*/
|
|
10
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
11
|
+
import userEvent from "@testing-library/user-event";
|
|
12
|
+
|
|
13
|
+
const mockResetSendConfigured = jest.fn();
|
|
14
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: auth-env.ts is a pure env-introspection module with no external boundary to mock instead.
|
|
15
|
+
jest.mock("../../../../../lib/auth-env", () => ({
|
|
16
|
+
__esModule: true,
|
|
17
|
+
getActiveProviderIds: () => ["email"],
|
|
18
|
+
isSignUpOpen: () => false,
|
|
19
|
+
isResetAvailable: () => mockResetSendConfigured(),
|
|
20
|
+
resetSendConfigured: () => mockResetSendConfigured(),
|
|
21
|
+
phoneVerificationConfigured: () => false,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const mockResetPassword = jest.fn();
|
|
25
|
+
jest.mock("better-auth/react", () => ({
|
|
26
|
+
__esModule: true,
|
|
27
|
+
createAuthClient: () => ({
|
|
28
|
+
resetPassword: (...args: unknown[]) => mockResetPassword(...args),
|
|
29
|
+
}),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const mockCard = jest.fn();
|
|
33
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: the island's post-reset navigation is `window.location.assign`, which jsdom cannot observe; the page's one decision — the `completeHref` it hands the island — is read from the island's props, and the real island is pinned below with an injected `navigate`.
|
|
34
|
+
jest.mock("../reset-password-card", () => ({
|
|
35
|
+
__esModule: true,
|
|
36
|
+
ResetPasswordCard: (props: Record<string, unknown>) => {
|
|
37
|
+
mockCard(props);
|
|
38
|
+
return <div data-testid="reset-card-double" />;
|
|
39
|
+
},
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
import en from "../../../../../messages/en.json";
|
|
43
|
+
import { mintSecurityReturn } from "../../../../api/auth/hub/password/return";
|
|
44
|
+
import ResetPasswordPage from "../page";
|
|
45
|
+
|
|
46
|
+
const { ResetPasswordCard } = jest.requireActual<typeof import("../reset-password-card")>(
|
|
47
|
+
"../reset-password-card",
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const SECRET = "s".repeat(43);
|
|
51
|
+
const SPOKE = "https://spoke.example";
|
|
52
|
+
/** The spoke's return route, which drops the revoked session before the tab (#11162). */
|
|
53
|
+
const LANDING = `${SPOKE}/api/hub-session/password/return?next=${encodeURIComponent("/account/security")}`;
|
|
54
|
+
const ORIGINAL_ENV = process.env;
|
|
55
|
+
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
jest.clearAllMocks();
|
|
58
|
+
process.env = { ...ORIGINAL_ENV, BETTER_AUTH_SECRET: SECRET, BETTER_AUTH_URL: "https://hub.example/api/auth" };
|
|
59
|
+
mockResetSendConfigured.mockReturnValue(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
afterAll(() => {
|
|
63
|
+
process.env = ORIGINAL_ENV;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
async function renderPage(query: Record<string, string>): Promise<void> {
|
|
67
|
+
render(
|
|
68
|
+
await ResetPasswordPage({
|
|
69
|
+
params: Promise.resolve({ locale: "en" }),
|
|
70
|
+
searchParams: Promise.resolve(query),
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The props the page handed the island. */
|
|
76
|
+
function cardProps(): Record<string, unknown> {
|
|
77
|
+
expect(mockCard).toHaveBeenCalledTimes(1);
|
|
78
|
+
return mockCard.mock.calls[0]?.[0] as Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe("the page's return decision", () => {
|
|
82
|
+
it("a ref the hub sealed sends a completed reset to the spoke's return route, bound for its Security tab", async () => {
|
|
83
|
+
const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
|
|
84
|
+
await renderPage({ token: "tok_live", ref });
|
|
85
|
+
expect(cardProps()).toMatchObject({
|
|
86
|
+
token: "tok_live",
|
|
87
|
+
signInHref: "/sign-in",
|
|
88
|
+
completeHref: LANDING,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it.each([
|
|
93
|
+
["no ref", {}],
|
|
94
|
+
["a ref sealed under another secret", { ref: mintSecurityReturn(SPOKE, "/account/security", "x".repeat(43)) }],
|
|
95
|
+
["a ref that is not one", { ref: "https://evil.example/account/security" }],
|
|
96
|
+
["an expired ref", { ref: mintSecurityReturn(SPOKE, "/account/security", SECRET, Date.now() - 5_000_000) }],
|
|
97
|
+
] as Array<[string, Record<string, string>]>)("%s leaves the completed reset on the hub's sign-in", async (_label, query) => {
|
|
98
|
+
await renderPage({ token: "tok_live", ...query });
|
|
99
|
+
const props = cardProps();
|
|
100
|
+
expect(props.signInHref).toBe("/sign-in");
|
|
101
|
+
expect(props).not.toHaveProperty("completeHref");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("a repeated ref reads as its first value only", async () => {
|
|
105
|
+
const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
|
|
106
|
+
render(
|
|
107
|
+
await ResetPasswordPage({
|
|
108
|
+
params: Promise.resolve({ locale: "en" }),
|
|
109
|
+
searchParams: Promise.resolve({ token: "tok_live", ref: [ref, "second"] }),
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
expect(cardProps()).toMatchObject({ completeHref: LANDING });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("the expired-token state ignores the ref and renders no island", async () => {
|
|
116
|
+
const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
|
|
117
|
+
await renderPage({ error: "INVALID_TOKEN", ref });
|
|
118
|
+
expect(screen.getByTestId("reset-token-error")).toBeInTheDocument();
|
|
119
|
+
expect(mockCard).not.toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("the island honours completeHref", () => {
|
|
124
|
+
const labels = {
|
|
125
|
+
resetHeading: en.auth.resetHeading,
|
|
126
|
+
resetSubmit: en.auth.resetSubmit,
|
|
127
|
+
newPassword: en.auth.newPassword,
|
|
128
|
+
confirmPassword: en.auth.confirmPassword,
|
|
129
|
+
backToSignIn: en.auth.backToSignIn,
|
|
130
|
+
};
|
|
131
|
+
const errorLabels = {
|
|
132
|
+
resetFailed: en.auth.resetFailed,
|
|
133
|
+
invalidToken: en.auth.resetExpiredSubhead,
|
|
134
|
+
mismatch: en.auth.passwordMismatch,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
async function submit(): Promise<void> {
|
|
138
|
+
const user = userEvent.setup();
|
|
139
|
+
await user.type(screen.getByTestId("auth-password"), "a-long-enough-pw");
|
|
140
|
+
await user.type(screen.getByTestId("auth-confirm-password"), "a-long-enough-pw");
|
|
141
|
+
await user.click(screen.getByTestId("auth-submit"));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
it("a completed reset lands on the spoke's return route, and the back link stays the hub's sign-in", async () => {
|
|
145
|
+
mockResetPassword.mockResolvedValue({});
|
|
146
|
+
const navigate = jest.fn();
|
|
147
|
+
render(
|
|
148
|
+
<ResetPasswordCard
|
|
149
|
+
token="tok_live"
|
|
150
|
+
signInHref="/sign-in"
|
|
151
|
+
completeHref={LANDING}
|
|
152
|
+
labels={labels}
|
|
153
|
+
errorLabels={errorLabels}
|
|
154
|
+
navigate={navigate}
|
|
155
|
+
/>,
|
|
156
|
+
);
|
|
157
|
+
expect(screen.getByRole("link", { name: en.auth.backToSignIn })).toHaveAttribute("href", "/sign-in");
|
|
158
|
+
await submit();
|
|
159
|
+
await waitFor(() => expect(navigate).toHaveBeenCalledWith(LANDING));
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("a failed reset navigates nowhere", async () => {
|
|
163
|
+
mockResetPassword.mockResolvedValue({ error: { message: "nope" } });
|
|
164
|
+
const navigate = jest.fn();
|
|
165
|
+
render(
|
|
166
|
+
<ResetPasswordCard
|
|
167
|
+
token="tok_live"
|
|
168
|
+
signInHref="/sign-in"
|
|
169
|
+
completeHref={LANDING}
|
|
170
|
+
labels={labels}
|
|
171
|
+
errorLabels={errorLabels}
|
|
172
|
+
navigate={navigate}
|
|
173
|
+
/>,
|
|
174
|
+
);
|
|
175
|
+
await submit();
|
|
176
|
+
await waitFor(() => expect(mockResetPassword).toHaveBeenCalled());
|
|
177
|
+
expect(navigate).not.toHaveBeenCalled();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -28,6 +28,15 @@
|
|
|
28
28
|
* The token is read from `searchParams` and handed to the island as a prop. It
|
|
29
29
|
* is the credential, so nothing here logs it and nothing re-appends it to a
|
|
30
30
|
* URL.
|
|
31
|
+
*
|
|
32
|
+
* `?ref=` (#11162) is the sealed return of a link the hub mailed for a
|
|
33
|
+
* spoke's Security tab (`app/api/auth/hub/password/return.ts`): opened, it
|
|
34
|
+
* names the spoke's registered origin and its `/account/security`, and a
|
|
35
|
+
* completed reset lands on that spoke's return route bound for the tab
|
|
36
|
+
* instead of this hub's sign-in (the reset ended the spoke's credential, so
|
|
37
|
+
* the spoke drops its session there and signs the person back in). A ref
|
|
38
|
+
* that does not open is ignored — never a redirect to a URL this hub did
|
|
39
|
+
* not seal.
|
|
31
40
|
*/
|
|
32
41
|
|
|
33
42
|
import { localeHref } from "@working-theory/ui";
|
|
@@ -37,13 +46,19 @@ import { getTranslations } from "next-intl/server";
|
|
|
37
46
|
import type { ReactElement } from "react";
|
|
38
47
|
|
|
39
48
|
import { resetSendConfigured } from "../../../../lib/auth-env";
|
|
49
|
+
import { resolveSecret } from "../../../../lib/auth-secret";
|
|
50
|
+
import { siteLogo } from "../../../../lib/site-logo";
|
|
51
|
+
import { openSecurityReturn } from "../../../api/auth/hub/password/return";
|
|
40
52
|
|
|
41
53
|
import { ResetPasswordCard } from "./reset-password-card";
|
|
42
|
-
import { siteLogo } from "../../../../lib/site-logo";
|
|
43
54
|
|
|
44
55
|
interface Props {
|
|
45
56
|
params: Promise<{ locale: string }>;
|
|
46
|
-
searchParams?: Promise<{
|
|
57
|
+
searchParams?: Promise<{
|
|
58
|
+
token?: string | string[];
|
|
59
|
+
error?: string | string[];
|
|
60
|
+
ref?: string | string[];
|
|
61
|
+
}>;
|
|
47
62
|
}
|
|
48
63
|
|
|
49
64
|
/** First value only — a repeated query param must not become an array here. */
|
|
@@ -69,6 +84,7 @@ export default async function ResetPasswordPage({
|
|
|
69
84
|
const query = searchParams ? await searchParams : {};
|
|
70
85
|
const token = firstValue(query.token);
|
|
71
86
|
const error = firstValue(query.error);
|
|
87
|
+
const ref = firstValue(query.ref);
|
|
72
88
|
|
|
73
89
|
const available = resetSendConfigured();
|
|
74
90
|
|
|
@@ -121,11 +137,15 @@ export default async function ResetPasswordPage({
|
|
|
121
137
|
backToSignIn: t("backToSignIn"),
|
|
122
138
|
};
|
|
123
139
|
|
|
140
|
+
// A spoke's Security tab, when the link was mailed for one (#11162).
|
|
141
|
+
const returnHref = ref ? openSecurityReturn(ref, resolveSecret()) : null;
|
|
142
|
+
|
|
124
143
|
return (
|
|
125
144
|
<ResetPasswordCard
|
|
126
145
|
logo={siteLogo()}
|
|
127
146
|
token={token}
|
|
128
147
|
signInHref={signInHref}
|
|
148
|
+
{...(returnHref !== null ? { completeHref: returnHref } : {})}
|
|
129
149
|
labels={labels}
|
|
130
150
|
errorLabels={{
|
|
131
151
|
resetFailed: t("resetFailed"),
|
|
@@ -33,8 +33,14 @@ export interface ResetPasswordCardProps {
|
|
|
33
33
|
logo?: ReactNode;
|
|
34
34
|
/** The `?token=` Better Auth redirected back with. May be empty. */
|
|
35
35
|
token: string;
|
|
36
|
-
/**
|
|
36
|
+
/** The sign-in page — the card's back link, and where a completed reset lands by default. */
|
|
37
37
|
signInHref: string;
|
|
38
|
+
/**
|
|
39
|
+
* Where a completed reset lands instead (#11162): a spoke's Security tab,
|
|
40
|
+
* for a link the hub mailed on that spoke's behalf. The page opens it from
|
|
41
|
+
* a sealed ref; this card never builds one.
|
|
42
|
+
*/
|
|
43
|
+
completeHref?: string;
|
|
38
44
|
/** Translated AuthCard labels (resolved server-side by the page). */
|
|
39
45
|
labels: AuthCardLabels;
|
|
40
46
|
/** Translated error copy. */
|
|
@@ -59,6 +65,7 @@ const defaultNavigate = (href: string): void => {
|
|
|
59
65
|
export function ResetPasswordCard({
|
|
60
66
|
token,
|
|
61
67
|
signInHref,
|
|
68
|
+
completeHref,
|
|
62
69
|
labels,
|
|
63
70
|
errorLabels,
|
|
64
71
|
navigate = defaultNavigate,
|
|
@@ -97,7 +104,7 @@ export function ResetPasswordCard({
|
|
|
97
104
|
return;
|
|
98
105
|
}
|
|
99
106
|
|
|
100
|
-
navigate(signInHref);
|
|
107
|
+
navigate(completeHref ?? signInHref);
|
|
101
108
|
};
|
|
102
109
|
|
|
103
110
|
const handleSubmit = (data: AuthSubmitData): void => {
|