/** * Open the consent URL in the install host's OWN Chromium over the Chrome * DevTools Protocol. * * 1799's loopback listener binds this host, so the redirect only completes when * the consenting browser is also on this host. When the operator opens the URL * in a browser on some other machine (their laptop), that browser cannot reach * the listener's port and the success path never fires. So when a CDP-reachable * on-host Chromium exists, register opens the consent URL in it directly and the * same-host listener finishes with nobody opening a link. * * Where no browser is reachable — a browserless brand, or a native install with * no running Chromium — this reports `reachable:false` and register falls back * to returning the URL for the paste path. That is a first-class fallback state, * not an error (Task 1862). * * The URL is transmitted as a `Page.navigate` JSON string, so Chrome receives it * byte-for-byte. A normalised redirect port would fail Google's exact-match * token exchange, which is why this never routes the URL through WHATWG parsing. * * The device Chromium is launched by platform/scripts/vnc.sh with * `--remote-debugging-port=${CDP_PORT}`; this attaches to it and never launches * its own. `fetch`/`WebSocket` are injected so the whole surface is unit-tested * against fakes with no real browser. */ /** The browser-style WebSocket shape this module needs. The Node 22 global and * the test fake both satisfy it. */ export interface MinimalWs { send(data: string): void; close(): void; addEventListener(type: "open", listener: () => void): void; addEventListener(type: "message", listener: (ev: { data: unknown; }) => void): void; addEventListener(type: "error", listener: (ev: unknown) => void): void; addEventListener(type: "close", listener: () => void): void; } export type WebSocketCtor = new (url: string) => MinimalWs; /** `reachable` divides the two non-open outcomes the caller logs differently: * `false` means no browser answered (surface=url fallback), `true` means one * answered but the navigation itself failed (surface=cdp outcome=error). */ export type ConsentOpenResult = { opened: true; } | { opened: false; reachable: boolean; detail: string; }; export interface ConsentOpenDeps { fetchImpl?: typeof fetch; WebSocketImpl?: WebSocketCtor; /** Cap on each network step. Kept short: register must not block. */ timeoutMs?: number; } /** * Open `url` in the on-host Chromium. Never throws; always returns a structured * outcome. On success the tab is LEFT OPEN — the user must sign in and approve * there — and only our websocket handle is closed. */ export declare function openConsentUrl(url: string, cdpHost: string, cdpPort: number, deps?: ConsentOpenDeps): Promise; //# sourceMappingURL=consent-open.d.ts.map