Repository navigation
fix(console): Settings, Packages, Audit Log and the connector pages send the stored bearer token - #37077
Conversation
…ie-only requests The settings client, the audit log read, the connector credential and connection doors and the Packages reads are pinned to carry the stored bearer token, with a cookie-only control, and the audit log failure state is pinned apart from its empty state. These fail before the fix. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
…thenticated fetch Settings (every namespace and the judged-address read), the audit log, the connector credential and connection doors, the Packages list and held list reads, and the runtime's own install-ledger and cloud-connection reads called fetch with the session cookie only, so a session held by its bearer token alone read a 401 there while the rest of the console worked. They now go through createAuthenticatedFetch, the path every other console request takes, which keeps the cookie and reports a 401 to the session-ended check. A failed audit log read no longer draws the no-entries empty state, and its alert shows the envelope's sentence or the page's own failure text instead of the raw response body. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
…package list read A module-level createAuthenticatedFetch() runs at import, before a test's hoisted auth mock can supply it, so each door now builds the wrapper per call, as approvalsApi does. The session's held package list read is left as it was: it serves the shell on every page, not these Setup doors, and is reported for its own card. The Response doubles of the affected page tests gain the headers member the authenticated fetch reads. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
…ders member The authenticated fetch reads the response's headers for a rotated session token, as a real Response always has them; the doubles of the settings, connector and Packages page tests carried only ok, status and json. The changeset no longer names the held package list read. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
…rough its authenticated fetch mock The audit log's ledger read now goes through createAuthenticatedFetch, which this harness mocks with a fixed empty answer; a case that stubs the wire is now answered by its stub. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
…d Packages and connector page tests check:test-source-alias judges the test files a change edits; these four reach the lazily loaded formula and lint packages from a case, so each loads them at module top, as the other Packages page tests do. Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8 席位核对 — ACCEPT · repo:objectstack#3 · head 7d86018 · 2026-11-24T19:19ZL1 read of #37077 (card #36981, p1) at The fence (read hardest): attach the existing token only. Every changed call site swaps Against the card. All five surfaces in the card's table are covered. Behind the bearer, a Changeset. It names Nits.
Mechanical. All-checks: 38 success · 13 expected skips · 0 failed · 0 pending. Floor checks are green, Every open finding is a nit. ACCEPT, ordinary queue landing. |
Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#3 · os-support-ai · session_01WGufziG2t1d9cfRQJDrHkB Landing: 2026-11-24T19:46Z · area ux-C · p1 · head
L1 N1 is answered in the PR body (one line on what the shared wrapper also stamps). State: ready + auto-merge (merge queue). |
…dio-design reads and writes send the stored bearer token (objectstack-ai#37185) Fixes objectstack-ai#37080 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:浏览器里只剩登录令牌(会话 Cookie 被替换、拦截或清掉)的用户,侧边栏、应用头部、命令面板和 Studio 入口里的应用包列表不再消失,AI 对话列表、建议权限绑定、提交历史、草稿面板等也正常加载;只用 Cookie 登录的用户看不到任何变化。 - 为什么做:控制台其它请求都会带上登录令牌,这一批读写漏带,属于"控制台登录状态体验"这一块的缺陷,替所有处于这种登录状态的用户解决,并加了一道测试防止以后再写出漏带令牌的请求。 - 出错会怎样:最坏情况是这些地方重新读不到数据,与修复前一样;不改服务端接受什么、不改登录方式,可以直接撤回。 - 要你做什么:无。 ## What changes Same-server `/api/` reads and writes in app-shell and the console that called the bare global `fetch` with `credentials: 'include'` (the session cookie and nothing else) now go through `createAuthenticatedFetch` from `@object-ui/auth`, exactly as objectstack-ai#37077 did for the Setup pages: built per call (`createAuthenticatedFetch()(input, init)`, a local `authFetch` in each module), `credentials: 'include'` kept on every call, so the cookie still rides along and a `401` now reaches the console's session-ended check. No second auth-fetch helper and no new export. Nothing changes in what the server accepts. The measured case: under a bearer-only session, `readPackagesPayload` (`GET /api/v1/packages`, the session's held package list read by the sidebar, the app header, the command palette and the Studio entries) sends the bearer and the list loads (pinned below). ### The family, measured at `origin/main` 63ab479 79 non-test files under `ui/packages/app-shell/src` and `ui/apps/console/src` contain `credentials: 'include'`. Read call by call (AST scan of every `credentials: 'include'` property and the call it is handed to): **Converted here: 64 calls in 39 files.** | File | Calls | |---|---| | `app-shell/.../studio-design/packages-io.ts` | `readPackagesPayload` (`GET /api/v1/packages`, the measured case), `ensureCustomizationPackage`, `duplicatePackage` | | `app-shell/.../studio-design/packageCustomizations-io.ts`, `PackageSwitcher.tsx`, `AutomationsPillar.tsx`, `FlowItemMoreMenu.tsx` | 1 each (customizations read, switcher list, automation status, flow clone) | | `app-shell/src/hooks/useConversationList.ts` | 4 (list, detail, rename, delete) | | `app-shell/src/hooks/useChatConversation.ts` | 3 (read, create, update) | | `app-shell/src/console/ai/buildDebugApi.ts` | 1 (build-debug report) | | `app-shell/src/hooks/useAiUsage.ts` | 1 | | `app-shell/src/services/suggestedBindingsApi.ts` | 4 (list, confirm, dismiss, reopen) | | `app-shell/src/preview/commitHistory.ts` | 2 (timeline, revert) | | `app-shell/src/preview/DraftChangesPanel.tsx`, `UnpublishedAppBar.tsx`, `usePendingDrafts.ts` | 2, 1, 1 | | `app-shell/src/preview/flowDraftChecks.ts` | the default transport (`opts.fetchImpl ?? createAuthenticatedFetch()`) | | `app-shell/src/views/changeOwner.ts` | the fallback transport (`apiFetch ?? createAuthenticatedFetch()`) | | `app-shell/src/views/metadata-admin/` `PackageFormDialog.tsx`, `catalog-activation.ts`, `permission-set-clone.ts`, `sharing-rule-catalog.ts` | 1, 2, 1, 1 | | `app-shell/src/views/metadata-admin/inspectors/` `FlowReferenceField.tsx`, `connector-input-fields.ts` | 2, 1 | | `app-shell/src/views/metadata-admin/previews/` `FlowRunsPanel.tsx`, `useFlowNodePalette.ts`, `PagePreview.tsx` | 1, 1, 2 | | `app-shell/src/views/setup/` `packagedActionLedger.ts`, `packagedFlowLedger.ts` | 2, 1 | | `app-shell/src/hooks/` `useRecordApprovals.ts`, `sharedUserFeeds.ts`, `useInboxBell.ts` | 1 each | | `app-shell/src/console/` `AppNoAccessEmptyState.tsx`, `connect/ConnectAgentWidget.tsx`, `deployment-notice/deploymentNoticeState.ts` | 1, 2, 2 | | `app-shell/src/console/marketplace/marketplaceApi.ts` | 5 same-server calls onto the existing `serverFetch` (`/cloud-connection/install`, `install-namespace`, `installation`, and on the control plane its own `install_package` action and installed-state route) | | `app-shell/src/layout/designModeMenuSave.ts` | 1 (`/api/v1/i18n/locales`) | | `app-shell/src/layout/ContextSelectors.tsx` | 1, with `{ sameOriginOnly: true }`: the endpoint is author-written (`optionsSource.endpoint`) and may name another host | | `console/src/pages/developer/` `AgentConnectSection.tsx`, `IntegrationsPage.tsx` | 2, 1 | | `console/src/pages/auth/DeviceAuthPage.tsx` | 3 (claim, approve, deny: a signed-in act) | Of the card's named ones: `packages-io.ts` `readPackagesPayload`, `useConversationList`, `useChatConversation`, `suggestedBindingsApi` and the studio-design writes (ensure-customization, duplicate, customizations, flow clone) are all converted. `suggestedBindingsApi`, `useRecordApprovals`, `sharedUserFeeds`, `useInboxBell`, `ConnectAgentWidget`, `deploymentNoticeState` and three `marketplaceApi` calls already set the bearer header by hand (`authHeaders` / `bearerAuthHeaders` / `withEnvAuth`), so those were not cookie-only; they are converted anyway for the session-ended check and the one mechanism, and their hand-rolled header is left in place (the wrapper sets the same value). **Already authenticated or injected (not the family): 24 files.** `settings/api.ts`, `AuditLogPage.tsx`, `approvalsApi.ts`, `studioEntry.ts`, `ExcelImportBar.tsx`, `CloudAiModelStatus.tsx`, `useEnvironmentEntitlements.ts`, `storageUsageEndpoint.ts`, `ImpersonationBanner.tsx`, `useImpersonationExit.ts`, `RecordAttachmentsPanel.tsx`, `RecordDetailView.tsx`, `useConsoleActionRuntime.tsx`, `AccessExplainPanel.tsx`, `MetadataTypeActions.tsx`, `PackagesPage.tsx`, `DatasourceResourcePage.tsx`, `personalViews.ts`, `connectorConnections.ts`, `connectorCredentials.ts`, and the injected transports of `myPreferences.ts`, `slackDoors.ts`, `orgEnvironments.ts`, `useLauncherApps.tsx`. `App.tsx` names the string in a comment only. **Left, on the pin's shrink-only list: 21 calls in 15 files**, each with its reason in the pin (`sameServerFetch.bearer.ratchet.test.ts`, `ALLOWED`): - `console/src/LocalizationFetchProvider.tsx` (1) and `console/src/languageSeed.ts` (not counted by the pin: it hands `sharedGetJson` a transport argument that may be `undefined`): the boot read of `/api/v1/auth/me/localization`, shared in flight by a key built from the init with the early request `index.html` sends. A session it cannot see reads `authenticated: false` and falls back to the browser language rather than failing. Its transport is its own decision (Acceptance notes). - `console/src/components/FormPage.tsx` (1): the bare channel is the public form route's on purpose. - `console/src/lib/auth-preflight.ts`, `console/src/lib/early-discovery.ts` (1 each): set the bearer header themselves on purpose. - `console/src/pages/auth/OAuthConsentPage.tsx` (3), `followAuthorize.ts` (1), `handoffClientName.ts` (1): the OAuth hand-off, whose authorize step is a top-level navigation that can only carry the cookie. - `console/src/pages/auth/SetupPage.tsx`, `app-shell/src/console/auth/bootstrapStatus.ts`, `console/src/pages/auth/VerifyEmailPage.tsx`, `app-shell/src/chrome/ConditionalAuthWrapper.tsx`, `app-shell/src/runtime-config.ts` (1 each): read before or without a session. - `app-shell/src/console/ai/AiChatPage.tsx` (1): an open PR (objectstack-ai#37123) edits this file; its call moves with that work. - `app-shell/src/console/marketplace/marketplaceApi.ts` (5): each targets `getCloudBase() || SERVER_URL`, the cloud control plane's own origin whenever one is configured, which must never see this runtime's bearer. - `app-shell/src/views/metadata-admin/previews/ActionPreview.tsx` (1): the test request of an `api` action preview, sent to the author-written target; its transport is not decided here. The other two fenced files hold no family call: `RecordDetailView.tsx` and `useConsoleActionRuntime.tsx` already route every `credentials: 'include'` call through their `authFetch`. Neither was edited. ## Tests - `ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts` (new, the enumeration pin; runs in **Test UI**, app-shell's `unit` project): parses every non-test source file of both trees with the TypeScript parser and refuses a bare cookie-only call (the transport is the global `fetch`, `window.fetch`, `globalThis.fetch`, `self.fetch`, one of those as a `??` / `||` fallback, or `sharedGetJson` without its transport argument; the init carries `credentials: 'include'`, inline or as a `const` of the file, `as const` included). The URL is not judged: a call that must stay bare is a counted row with its reason. Four cases: the scan reads both trees (more than 500 and 100 files); a 13-case detector battery (each bare spelling found, each authenticated one not); every bare call is a counted row; every row is still exact (a file that sheds a call must shrink its row). - `ui/packages/app-shell/src/views/studio-design/packages-io.bearerSession.test.ts` (new): against a server that refuses any request without the bearer, with a token stored, `fetchPackages` loads the list and its one request carries `Authorization: Bearer TOKEN` and `credentials: 'include'`; `fetchListedPackageIds` likewise; the duplicate write, the commit timeline and revert, suggested bindings and the build-debug report carry the bearer. Each with a cookie-only control (no token stored: no `Authorization`, `credentials: 'include'`). Test doubles that moved (118 files, no assertion weakened): - 102 files: hand-rolled `Response` doubles (`{ ok, status, json }`) gain `headers: new Headers()`, the headers a real `Response` carries and the authenticated fetch reads (`set-auth-token`), as objectstack-ai#37077 did. The 102nd, `StudioPaletteGroups.surfaceScope-36900` (the command-palette suite that reached `main` after round 0), doubles `GET /api/v1/packages`: without the headers the converted `readPackagesPayload` threw on the double and the palette drew no Packages group. For `fetchInstalledPackageRow-7881` and `StudioDesignSurface.readOnlyPosture-12453` the headers are added at the one stub instead of each answer. - 8 files whose `@object-ui/auth` mock answered `createAuthenticatedFetch: () => vi.fn()` (a transport that answers nothing) now hand the authenticated fetch's requests to the global `fetch` the file already stubs: the four `RecordApprovalsPanel` suites and `RecordDetailView` `editLockedByState-32756`, `phoneFace-27058`, `userActionPredicates`, `harness`. - 5 `RecordDetailView` approval suites whose `authFetchSpy` stands for the action door: approvals reads (now through the authenticated fetch too) are handed to the file's wire double, as before (`approvalRecallGate`, `accessEndedAfterDecision-26589`, `approvalDeclaredActions`, `approvalLock-12220`, `approvalLock-25934`). - `StudioRoute.searchPalette-11863` (console): its auth mock answers the Studio permissions read and hands every other request (the package list) to the wire double. - 3 assertions read the init the wire received (the last two files are also among the 101): `useConversationList` and `BuildDebugDrawer` assert `{ credentials: 'include', headers: expect.any(Headers) }` (exact keys, as before); `DraftChangesPanel.flowChecks-34818` reads `Accept-Language` off a `Headers`. - `RecordDetailView.headerApiInterpolation`: the flow-trigger case asserts exactly one call to the trigger door, filtered by its path, since the page's own reads now share that spy. ## Acceptance notes - Same defect family outside the two trees, not touched (the card scopes the `plugin-*` hooks out unless measured here): `credentials: 'include'` with the bare `fetch` remains in `ui/packages/plugin-chatbot` (`useAgents`, `useAiModels`, `useHitlInChat`, `usePendingActions`), `plugin-detail` (`queueClaim`, `stageChangeStarts`, `useRecordEditable`), `plugin-grid` (`useRecordCrudVerdicts`, `useRowApprovalLocks`), `plugin-dashboard` (`DatasetWidget`), `plugin-charts` (`ObjectChart`), `fields` (`ShareableObjectRefField`, `preferenceOptions`), `components` (`ShareDialog`) and `permissions` (`MePermissionsProvider`). Not each read call by call. - A bare `fetch('/api/…')` with no init at all is cookie-only as well (the default `same-origin` credentials) and is outside the pin's spelling: `views/metadata-admin/widgets.tsx` `fetchFieldSelectorOptions` (`GET /api/v1/objects/:name/fields`). - `LocalizationFetchProvider` and `languageSeed` read `/api/v1/auth/me/localization` cookie-only; under a bearer-only session that read answers anonymously and the console falls back to the browser language instead of the user's own locale. Not measured in a browser; left because the request key is shared with the early request `index.html` sends. - The hand-rolled bearer helpers left beside converted calls (`authHeaders` in `suggestedBindingsApi`, `bearerAuthHeaders`, `withEnvAuth`) are now redundant there; not removed here. ## Verification <details><summary>The measured case and the pins (green at the head)</summary> `packages-io.bearerSession.test.ts` and the ratchet are in the rerun below (all green). The ratchet's detector battery first went red on a real detector issue: at a script's top level `await (x)(…)` parses as a call of `await`, so the `(apiFetch ?? fetch)` case read 0; the cases now run inside an async function. </details> <details><summary>Ablation: one conversion reverted, both pins red</summary> Through `scripts/ablation-replace.mjs` on `packages-io.ts`: anchor `const res = await authFetch('/api/v1/packages', {` hit 1 → 0, blob `d3c93d771344` → `42f8862ba05e`; the ratchet and the bearer-session file run under the lock: ```text FAIL sameServerFetch.bearer.ratchet.test.ts > every bare cookie-only call is a counted row of the shrink-only allow-list + "packages/app-shell/src/views/studio-design/packages-io.ts:398 :: fetch('/api/v1/packages', …)" FAIL packages-io.bearerSession.test.ts > loads the package list, sending the stored bearer beside the cookie FAIL packages-io.bearerSession.test.ts > answers the listed-id read from the same authenticated request Test Files 2 failed (2) Tests 3 failed | 14 passed (17) ``` The cookie-only control stayed green. Restored: blob `d3c93d771344` equal to `HEAD`, `git diff HEAD` empty. </details> <details><summary>Suites</summary> The whole `@object-ui/app-shell` and `@object-ui/console` suites, under the shared verify lock, in six shards (`cd ui && pnpm exec vitest run --maxWorkers=3 --shard=k/6 packages/app-shell apps/console`) at `32505939` (the final source; only test files changed after it). These are the readings BEFORE the doubles moved, and they are how the moved doubles were found: ```text shard 1/6: Test Files 21 failed | 440 passed (461) · Tests 121 failed | 4304 passed (4425) shard 2/6: Test Files 16 failed | 446 passed (462) · Tests 64 failed | 4352 passed | 1 skipped (4417) shard 3/6: Test Files 23 failed | 439 passed (462) · Tests 104 failed | 4111 passed (4215) shard 4/6: Test Files 17 failed | 445 passed | 1 skipped (463) · Tests 87 failed | 4383 passed | 8 skipped (4478) shard 5/6: Test Files 26 failed | 436 passed (462) · Tests 116 failed | 4636 passed (4752) shard 6/6: Test Files 14 failed | 448 passed (462) · Tests 77 failed | 4286 passed (4363) ``` The 117 failing files are exactly the 117 moved doubles. Each was re-run after its fix (the two new pin files with them): `Test Files 116 passed | 3 failed (119)`, then the three fixed again `Test Files 3 passed (3)`. After the last two type fixes `Test Files 2 passed (2)`, and after the collection-time imports the 34 files that gained one `Test Files 34 passed (34)` / `Tests 319 passed (319)`, at `5dde589a8c`. The 2,655 files that passed in the shards were not edited. A full re-run after the fixes was not done locally (NOT MEASURED, reason: about 90 minutes of shared lock); Test UI runs the full affected set on this PR. Type-check through turbo (dependency closure built): `@object-ui/app-shell` and `@object-ui/console` `type-check` `Tasks: 77 successful, 77 total` at `3080a68173`; `@object-ui/app-shell` again at `5dde589a8c` after the last test edits, `Tasks: 69 successful, 69 total`. The first run found two type errors in my test edits (a typed tuple, an object literal against a declared parameter type), fixed in `3080a68173`. `pnpm --dir ui exec vitest run scripts/` after building the seven `@objectstack` packages as Test UI does: `Test Files 172 passed | 2 skipped (174)`, `Tests 5131 passed | 2 skipped (5133)`. </details> <details><summary>Gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` (no paths, merge base `63ab4794`): 39 families. All 39 run locally, each exit captured before any pipe; 37 lock-free families re-run at `5dde589a8c`, all exit 0; `pnpm check:type-check-debt` exit 0 (`0 raw tsc error(s) total, none above its recorded number`); the ui `scripts/` suite above exit 0. Reconciled: `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero)`. `check:test-source-alias` first went red on the edited suites (exit 1): 34 of them reach a dynamic `import('@objectstack/lint')`, `import('@objectstack/formula')` or `import('@object-ui/plugin-detail')` in the source under test with no collection-time load. Each gained the module-top side-effect import the gate prescribes (`5dde589a8c`), then exit 0. `overlap-check` before every push: at `4a990ef7` it merges cleanly with `origin/main` (`93bd4595`) and with objectstack-ai#37204, objectstack-ai#37188 and objectstack-ai#37148, and exits 1 on textual conflicts with three open Studio PRs that edit the same test files: objectstack-ai#37166, objectstack-ai#37168, objectstack-ai#37169 (in `StudioDesignSurface.*`, `BuilderLanding.*`, `CommandPalette.studioScope-11863`, `StudioRoute.searchPalette-11863`, and objectstack-ai#37166/objectstack-ai#37169 also in `PackageSwitcher.tsx`, `FlowItemMoreMenu.tsx`). Whichever lands second takes the merge. </details> <details><summary>Round 1: main merged at 3b4f0b9, re-measured at e055596</summary> CI at `5dde589a` was red on two causes, both from `main` moving (the ⌘K palette work): - `check:test-source-alias` exit 1: four edited suites (`StudioDesignSurface` `entryReadsOnce-11797`, `itemDraftLine-12725`, `notFound-26708`, `readOnlyPosture-12453`) now reach `import('@object-ui/plugin-detail')` through the surface's command palette and its record preview. Each gained the prescribed module-top `import '@object-ui/plugin-detail';` (38 files carry a collection-time import in all). Then exit 0. - `StudioPaletteGroups.surfaceScope-36900`: 3 failed, 8 passed; after its package-list double gained `headers` (above), 11 passed. No assertion changed. Readings at `e0555965`, under the shared verify lock: ```text ratchet + bearer-session pin + main's 35 incoming app-shell/console test files + the 5 edited files: Test Files 41 passed (41) · Tests 394 passed (394) whole @object-ui/app-shell + @object-ui/console (cd ui && pnpm exec vitest run --maxWorkers=3 packages/app-shell/ apps/console/): Test Files 1 failed | 2779 passed | 1 skipped (2781) · Tests 2 failed | 26745 passed | 9 skipped (26756) ``` The one failing file is `ReportNewPage-36692.test.tsx`, which this branch does not touch (nor its page); it passed 3 of 3 runs alone (`Tests 6 passed (6)` each). Its second failure received the first case's save call, late: its cases flush by `setTimeout(0)` rounds while the page loads its Han romanizer lazily, so on a loaded box the save can land after the case ends. `@object-ui/app-shell` `type-check` through turbo: `Tasks: 69 successful, 69 total`. `pnpm --dir ui exec vitest run scripts/`: `Test Files 172 passed | 2 skipped (174)`, `Tests 5131 passed | 2 skipped (5133)`. Gates: `dispatch-gates --commands` (merge base `3b4f0b98`): 39 families, all run, each exit captured before any pipe, all exit 0. `check:type-check-debt` first answered exit 3 (its closure build queued behind the suite above and never got the lock: not measured), then exit 0 under the lock (`0 raw tsc error(s) total, none above its recorded number`). `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)`. </details> ## Read first 1. `ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts`: the detector and the `ALLOWED` rows (each reason is a claim about a call left bare). 2. `ui/packages/app-shell/src/layout/ContextSelectors.tsx`: the one conversion with `sameOriginOnly`, because its URL is author-written. 3. `ui/packages/app-shell/src/console/marketplace/marketplaceApi.ts`: which calls moved onto `serverFetch` and which stay bare because they may target the cloud origin. Two-minute check: `cd ui && pnpm exec vitest run packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts packages/app-shell/src/views/studio-design/packages-io.bearerSession.test.ts`, expect `Test Files 2 passed (2)`. <details><summary>Round 2: main merged at 93bd459, re-measured at 4a990ef</summary> - objectstack-ai#37089 landed on `main` after round 1 and left this PR conflicting in `StudioDesignSurface.notFound-26708` and `StudioDesignSurface.readOnlyPosture-12453`: both sides add the same `import '@object-ui/plugin-detail';` with a different comment. The merge (`48321c62`) keeps one import with `main`'s comment, so against `main` those two files differ only by round 0's doubles. - Main's ten new commits add no `credentials: 'include'` line under `ui/packages/app-shell/src` or `ui/apps/console/src`, and their one new hand-rolled Response double already carries `headers: new Headers()`. - The two changesets (`4a990ef7`) now name every converted door in user terms (flow clone, permission-set clone, page preview, the no-access state and the design-mode language list were missing) and claim only "the other same-server console requests", since the 21 listed calls stay cookie-only. Readings at `4a990ef7`, under the shared verify lock (`packages/spec` moved on `main`: the seven `@objectstack` packages Test UI builds were rebuilt first, and `pnpm --filter @objectstack/spec check:generated` reads `All 14 generated artifacts are up to date`): ```text the ratchet, the bearer-session pin, the 5 test files edited in round 1, every existing test file the merge touched in the two trees, and the suites named for each source file it touched: Test Files 311 passed (311) · Tests 2133 passed (2133) ``` `check:test-source-alias` exit 0. `@object-ui/app-shell` `type-check` through turbo: `Tasks: 69 successful, 69 total`. `dispatch-gates --commands` (merge base `93bd4595`): the same 39 families, all run, each exit captured before any pipe, all exit 0 (`check:type-check-debt`: `0 raw tsc error(s) total, none above its recorded number`; the ui `scripts/` suite `Test Files 172 passed | 2 skipped (174)`). `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)`. The whole app-shell and console suites were not re-run this round (NOT MEASURED, reason: about 70 minutes of shared lock for a merge that changed no source line of this PR); Test UI runs the affected set on this PR. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_ <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Yibo Wang · project thread
Fixes #36981
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
These Setup surfaces called their endpoints with the session cookie only, so a session held by its bearer token alone (the case the card measures) read a 401 there while the rest of the console worked. Each now goes through
createAuthenticatedFetchfrom@object-ui/auth, the path every other console request already takes.credentials: 'include'is still passed on every call, so the cookie rides along exactly as before. A 401 now reaches the console's session-ended check, as it does on every other page. Besides the bearer, the shared wrapper also stampsX-Tenant-ID(the active organization) andAccept-Language(from the htmllangattribute, never overriding a header the caller set) on these calls, and stores a rotatedset-auth-tokenfrom the response, exactly as it already does for every other console request (L1 N1). Nothing changes in what the server accepts, how sessions are minted, stored or refreshed, cookies, CORS or any policy./api/settingscalls inpages/settings/api.ts(list, read, save, action, and the judged client-address read of the Authentication and Access policy pages)PackagesPage'sapiJson(every/api/v1/packagescall the page makes); inmarketplaceApi.ts, the runtime's own/api/v1/cloud-connection/installedandorg-packagesreads and every/api/v1/marketplace/install-local*call/api/v1/data/sys_audit_logreadconnectorCredentials.tscallhelper inconnectorConnections.ts(declaration, registry, status, begin, revoke)Each module builds the wrapper per call (
createAuthenticatedFetch()(input, init), asapprovalsApi.tsdoes). A module-level instance would run at import, before a test file's hoisted@object-ui/authmock can supply it.Audit log failure state: a failed read no longer draws the "No audit entries" empty state, because the table card is not drawn under the alert. The alert shows the refusal's own sentence when the response carries the declared envelope (
readEnvelopeFailureText). Otherwise it shows the page's own "Failed to load audit log". It never shows the raw response body or a bare machine code.marketplaceApi.ts: the calls to the cloud control plane's own origin (getCloudBase()) and the marketplace browse calls (credentials: 'omit') are deliberately left alone. The cloud origin must never see this runtime's bearer.Tests
New pins, each with a cookie-only control (no token stored: no
Authorizationheader,credentials: 'include'):ui/apps/console/src/pages/settings/api.bearer.test.ts: every settings call sendsAuthorization: Bearer TOKENwhen a token is stored.ui/apps/console/src/pages/system/AuditLogPage.bearerAndFailure.test.tsx: the ledger lists against a server that answers only the bearer. A 401 (the REST seam's flat body) shows "Failed to load audit log", with noHTTP 401, no JSON and noUNAUTHENTICATED, and does not show "No audit entries". An enveloped 403 shows its sentence. An empty answer still shows the empty state.ui/packages/app-shell/src/views/setup/setupDoorsBearer.test.ts: every connector credential and connection call, and the org-packages, cloud-installed and install-ledger reads.ui/packages/app-shell/src/views/metadata-admin/PackagesPage.bearerSession.test.tsx: the Installed Apps address lists a marketplace install against a server that refuses any request without the bearer.Fixture triage: the authenticated fetch reads
response.headers(for a rotated session token, which a realResponsealways carries). TheResponsedoubles of 29 existing settings, connector and Packages test files carried onlyok,statusandjson. Each gainsheaders: new Headers(). The display-locale harness (consoleFaces.displayLocale-9909.test.tsx) mockscreateAuthenticatedFetchwith a fixed empty answer, so its mock now hands a case that stubs the wire to that stub. No assertion changed.Acceptance notes
packages-io.ts's held package-list read (GET /api/v1/packages, read by the shell's sidebar, header and Studio entries on every page) is cookie-only too. In the browser it answered 401 on every Setup page with a bearer-only session. Fixing it moves theResponsedoubles of roughly a dozen unrelated shell test files, so it was left out of this card. Many otherui/modules still callfetchwith the cookie only.actionErrorDetail(@object-ui/core) reads a bare-stringerrorbeforemessage. Against the REST seam's flat 401 body ({ error: 'UNAUTHENTICATED', code, message }, a sanctioned envelope peranonymous-deny.ts), it therefore answers the code. That is where the connector connections page's bareUNAUTHENTICATEDcame from. With the bearer attached these surfaces no longer meet that 401, and a real ended session goes to the session-ended check. The shared reader is not changed here.Verification
Reproduced on main, then fixed (real boot: showcase backend + Console dev server, signed in, session cookie removed, bearer kept)
On
main(305fe60), every surface answered 401 without the bearer:With the fix, in the same state, every request carried the bearer, answered 200, and the pages rendered their content (settings manifests and fields, the Packages list, audit rows, the connector empty states). No page showed
HTTP 401,UNAUTHENTICATEDor "Authentication is required".Pins fail on main's source, pass on the fix; ablation
Against main's source (the seven source files restored to
305fe60e6eon disk, each blob checked equal to the base blob, then restored toHEAD, withgit diff HEADempty afterwards), the four new pin files failed exactly the bearer pins and the audit failure-state pins. The cookie-only controls and the empty-state control passed:Ablations at
8d5bf768c5, throughscripts/ablation-replace.mjs. Each mutation was proven on disk (anchor 1 to 0, blob moved). Each restore was proven (blob equal toHEAD,git diff HEADempty).An earlier ablation of
connectorConnections.ts(module-level form) turned exactly its five bearer cases red:5 failed | 18 passed (23).Suites, typecheck and gates
Run at
7d8601826f(the final head): the eight edited or new test files that changed last,Test Files 8 passed (8),Tests 74 passed (74).@object-ui/app-shelltype-checkexit 0. At8d5bf768c5:@object-ui/consoletype-checkexit 0. Both typechecks ran after building the dependency closure (pnpm --filter '@object-ui/console^...' build, exit 0).Full package suites were run at
f8533fabdd. Only test files changed after it.@object-ui/console:Test Files 1 failed | 331 passed (332),Tests 7 failed | 3560 passed (3567). All seven failures were inconsoleFaces.displayLocale-9909.test.tsx, whose auth mock answered{}for the audit ledger. Its mock was fixed atfc22fa2f7d. The file then passed alone: 15 of 15.@object-ui/app-shell:Test Files 1 failed | 2416 passed | 1 skipped (2418),Tests 1 failed | 22867 passed | 9 skipped (22877). The one failure (RecordDetailView.recordPageTiers-26678) is outside this diff's reach and passed alone, 10 of 10, atfc22fa2f7d. The full run took 6054 s on a shared box.Derived gate families (
node scripts/pm/dispatch-gates.mjs --commands): all 39 ran at8d5bf768c5, each exit 0. That includespnpm check:type-check-debtunder the lock andpnpm --dir ui exec vitest run scripts/(Test Files 172 passed | 2 skipped).--ranprinted: "39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)". At that headcheck:test-source-aliaswas red on four edited test files. The fix (module-top side-effect imports) landed as7d8601826f. At7d8601826f,check:test-source-alias,check:undeclared-dep-importsandcheck:nul-byteseach exited 0.node scripts/pm/overlap-check.mjsran before each push from the third one on:VERDICT clean exit 0, and #36973 (which sharesPackagesPage.tsx) merges cleanly.Read first:
ui/apps/console/src/pages/system/AuditLogPage.tsx: the failure and empty-state hunk. The table card is now conditional.ui/packages/app-shell/src/console/marketplace/marketplaceApi.ts: confirm only same-server calls moved toserverFetch, and that nogetCloudBase()call did.ui/apps/console/src/pages/settings/api.ts: the five call sites.Two-minute check: sign in on the Console, delete the
better-auth.session_tokencookie in devtools, and open Setup, then All Settings. The settings cards load. Onmainthe page reads "Authentication is required to access this endpoint."Generated by Claude Code