/** * Which pages may talk to the daemon when auth is off (crew#1048). * * The daemon binds loopback, but a browser on the same machine runs pages from anywhere: another * local dev server, an agent-built app, or a remote site using DNS rebinding. With auth off (the * local default) no token stands between such a page and the API, and WebSockets (`/ws`, * `/ws/terminals/:id`, which writes to a PTY) are not covered by CORS at all. So, in local mode: * * - **Host** must be a loopback name on every request. A rebinding page reaches us under its own * name (`evil.example:7701`), and a plain-http page sends no `Origin` or `Sec-Fetch-*` on a read, * so the Host is the only thing that tells it apart. The worker MCP routes are exempt: the seat * gateway reaches them under a host alias, and the engine checks their unit token in every mode. * - **A write or WebSocket upgrade** must come from the daemon's own origin or an allowed one * (studio's dev server, `WICKED_CREW_ALLOWED_ORIGINS`). A write that names a foreign site in * `Sec-Fetch-Site` without an `Origin` is refused too. * - **CORS** is reflected only for allowed origins. * * Required mode is unchanged: a bearer token carries no ambient credential, so a foreign page * without one holds nothing (docs/auth.md "CORS pairing"). */ import type { AuthMode } from './auth.js'; /** Studio's Vite dev server (`wicked-studio/vite.config.ts`, `server.port`), which calls the daemon cross-origin. */ export declare const STUDIO_DEV_ORIGINS: readonly string[]; export interface OriginPolicy { mode: AuthMode; /** `null` = no allowlist (required mode then reflects any origin). */ allowedOrigins: readonly string[] | null; } export interface GuardedRequest { method: string; /** The request path, without the query string. */ path: string; host: string | undefined; origin: string | undefined; secFetchSite: string | undefined; upgrade: string | undefined; } /** May this origin read our responses (CORS reflection)? */ export declare function corsAllowed(origin: string, policy: OriginPolicy): boolean; /** `null` = let it through; otherwise the reason it is refused (403 `origin_refused`). */ export declare function refuseRequest(req: GuardedRequest, policy: OriginPolicy): string | null; //# sourceMappingURL=origin-guard.d.ts.map