1/** 2 * Local type declarations for `@xmldom/xmldom` (TASK-0131 SAML SP). 3 * 4 * Why this file exists: `@xmldom/xmldom` ships its own `index.d.ts` whose 5 * first line is a triple-slash `reference` directive pulling in 6 * `lib="dom"`. The API's TS program (`lib: ["ES2022"]`, no DOM) must NOT 7 * pull in `lib.dom.d.ts` — doing so injects the DOM's global 8 * `ReadableStreamReadDoneResult<T>` (where `value` is OPTIONAL) into scope, 9 * which collides with `@factory/ai`'s local `ReadResult<T>` (where `value` 10 * is required) when the API compiles `packages/ai` from source. 11 * 12 * The API `tsconfig.json` maps `@xmldom/xmldom` → this file via `paths`, so 13 * BOTH this package's imports and samlify's own type imports (which also 14 * import `@xmldom/xmldom`) resolve here, and the package's bundled d.ts 15 * never enters the program. The runtime still loads the genuine 16 * `@xmldom/xmldom` CJS module — only the compile-time types are local. 17 * 18 * The declarations below are a STRUCTURAL subset of the real @xmldom API — 19 * the surface `saml.ts` uses plus `Options` (imported by samlify's types). 20 * Keep this in sync with `saml.ts`'s usage. If you need more of the DOM 21 * API, extend these interfaces rather than importing the package's types. 22 */ 23 24export interface XmlDomNode { 25 textContent: string | null; 26 getAttribute(name: string): string; 27 getElementsByTagName(localName: string): XmlDomNode[]; 28 getElementsByTagNameNS(namespaceURI: string, localName: string): XmlDomNode[]; 29} 30 31export interface XmlDomElement extends XmlDomNode { 32 localName: string; 33 namespaceURI: string; 34} 35 36export interface XmlDomDocument { 37 documentElement: XmlDomElement | null; 38 getElementsByTagName(localName: string): XmlDomNode[]; 39 getElementsByTagNameNS(namespaceURI: string, localName: string): XmlDomNode[]; 40} 41 42/** SAML parser options consumed by samlify's `setDOMParserOptions`. */ 43export interface Options { 44 [option: string]: unknown; 45} 46 47export class DOMParser { 48 parseFromString(source: string, mimeType: string): XmlDomDocument; 49} 50 51export class XMLSerializer { 52 serializeToString(node: XmlDomNode): string; 53} 54