/** * XMLHttpRequest monkey-patch — captures URL/method/headers/body for * request and response WITHOUT replacing the XMLHttpRequest constructor. * * The previous implementation wrapped `window.XMLHttpRequest` with a new * constructor, which broke `xhr instanceof XMLHttpRequest` checks in * business code. This patch attaches per-instance metadata via a * non-enumerable Symbol key and overrides only prototype methods, leaving * the constructor and prototype chain native. * * Capture rules mirror fetchPatch.ts: * - 256 KB body cap with content-type routing (json / text / binary) * - Sensitive header redaction (Authorization / Cookie / x-api-key / x-auth-*) * - Two events per request keyed by a shared `id` (`phase: 'req' | 'res'`) * - Errors inside capture are swallowed via `safeEmit` * - `__hfeInternal` opt-out via a magic header `x-hfe-internal: 1` * (XHR has no init-style options bag like fetch) * - Idempotent install + dispose() restores original prototype methods */ import type { NetworkEntry } from '@harnessa-fe/protocol'; export interface XhrPatchOptions { onEntry: (entry: NetworkEntry) => void; bodyCap?: number; denylist?: RegExp[]; } export declare function installXhrPatch(opts: XhrPatchOptions): () => void;