/** * Replay a drafted provider's AUTHENTICATED request FROM INSIDE the live * attached browser tab, over CDP `Runtime.evaluate` — so cookies/session are * always the real browser's, for every browser source the MCP can attach to * (local Chrome, remote Popcorn, or a caller-supplied custom CDP endpoint all * funnel through one `AuthoringBackend.sendCdp`). Ports the pattern already * proven in the cloud/Popcorn authoring backend * (`packages/app/src/author/backend.ts` `pageFetch`/`authenticatedFetch`), * adapted to the MCP's single-page `sendCdp(method, params)` (no separate * `pageSession` argument). The ANONYMOUS auth-bound check does NOT go through * the page — see `replayProviderInPage`'s doc comment below for why. */ import type { ReclaimProvider } from '../provider/schema.ts'; import { type ReplayResult } from './replay.ts'; /** Everything this module needs from an `AuthoringBackend` — just the raw CDP * seam, so callers can pass a minimal object instead of a full backend. */ export interface PageReplayTarget { sendCdp(method: string, params?: Record): Promise; } /** * Replay `provider` and judge the response. Without `withoutSecrets`, replays * as the logged-in session — run FROM INSIDE the live tab * (`authenticatedPageFetch`) so cookies are the real browser's, which a * detached call could never reproduce without manually re-deriving them. * WITH `withoutSecrets` (the auth-bound check — "does this still work with * no credentials, that is, is it actually public"), replay instead through the * detached Node-side `replayProvider`: the whole point of that check is to * prove NO secret rides along, and the live page's own global `fetch` can't * give that guarantee — a site (or a script installed via test_user_script) * can wrap `fetch` and re-attach a token from localStorage/a service worker * even under `credentials:'omit'`. A fresh, page-uninvolved fetch has no * such surface. */ export declare function replayProviderInPage(backend: PageReplayTarget, provider: ReclaimProvider, secrets: Record, opts?: { withoutSecrets?: boolean; }): Promise;