/** * URL validation and content-type classification for the local HTTP(S) fetch * provider — the pure, network-free half. The provider's `fetch()` composes * these with transport (redirect following, byte caps, decoding). * * @module @unieai/uad-web-fetch-http/policy */ /** The body kinds this provider decodes. */ export type FetchableKind = 'html' | 'text'; /** * Validate a request URL against the basic transport hygiene the provider * enforces before any network access: http(s) only, no embedded credentials, * bounded length. Returns the parsed `URL`. Throws {@link WebError} otherwise. * (SSRF / private-network blocking is deferred — see the package Agent Note.) * * @param input - the raw URL string from the fetch request. * @param maxUrlLength - inclusive upper bound on `input`'s length. * @returns the parsed `URL`. */ export declare function validateFetchUrl(input: string, maxUrlLength: number): URL; /** * Two URLs are same-origin when scheme, hostname, and port match. A redirect * that crosses origins is refused so each new origin requires a fresh tool call * (and thus a fresh provider/permission decision). * * @param a - one of the two URLs to compare. * @param b - the other URL to compare. * @returns true when `a` and `b` share scheme, hostname, and port. */ export declare function isSameOrigin(a: URL, b: URL): boolean; /** * Classify a response `Content-Type` into a decodable body kind, or `undefined` * for an unsupported (e.g. binary) type. `text/html` and `application/xhtml+xml` * are `html`; other `text/*` plus a few structured text types are `text`. * * @param contentType - the raw `Content-Type` header, or `null` when the * response carries none (unsupported). * @returns the decodable kind, or `undefined` for an unsupported type. */ export declare function classifyContentType(contentType: string | null): FetchableKind | undefined; /** * Extract the `charset` parameter from a response `Content-Type`, lower-cased, * or `undefined` when absent. The provider feeds this label to `TextDecoder` * so a non-UTF-8 response is decoded with its declared encoding rather than * silently mangled into replacement characters. * * @param contentType - the raw `Content-Type` header, or `null` when the * response carries none. * @returns the lower-cased charset label, or `undefined` when none is declared. */ export declare function parseCharset(contentType: string | null): string | undefined; /** * Build a `TextDecoder` for the declared charset, falling back to UTF-8 when * none is declared. Throws {@link WebError} `WEB_UNSUPPORTED_CONTENT_TYPE` when * the label is present but not a charset `TextDecoder` recognizes — better to * fail loudly than return mojibake. * * @param charset - the declared charset label (from {@link parseCharset}), or * `undefined` to default to UTF-8. * @returns a decoder for the declared (or defaulted) encoding. */ export declare function decoderForCharset(charset: string | undefined): TextDecoder; //# sourceMappingURL=policy.d.ts.map