import { type WebFetchProvider, type WebFetchRequest, type WebFetchResult } from './types.js'; export interface GuardedFetchConfig { /** Injected so a test needs no socket. Defaults to the global `fetch`. */ readonly fetch?: typeof globalThis.fetch; readonly maxRedirects?: number; readonly maxBytes?: number; readonly timeoutMs?: number; /** * Hostnames this must refuse regardless of where they resolve. * * A host's own belt on top of the address check: an internal name that * resolves publicly is not caught by an IP-range rule, and only the host * knows its own names. */ readonly blockedHosts?: readonly string[]; /** * Allow addresses the private-range check would refuse. * * `false`, and the default is the whole point. A test fixture on * `127.0.0.1` is the one legitimate case, and it is a decision a host * makes explicitly rather than one it inherits. */ readonly allowPrivateAddresses?: boolean; /** * How a hostname becomes addresses. Defaults to `node:dns`. * * Injected for the reason `fetch` is: a test that has to reach a real * resolver is a test that depends on somebody's DNS. It is also the seam * a host uses to pin resolution — see `assertAllowed` for the rebinding * gap this cannot close on its own. */ readonly resolve?: (hostname: string, signal?: AbortSignal) => Promise; } /** * Is this address inside the host's own network? * * Written out rather than pulled from a dependency, because the list is * short, stable, and the thing being protected is worth reading in full. * IPv6 included: `::1` is loopback and `fc00::/7` is unique-local, and a * guard that checked only IPv4 would be bypassed by a name with a AAAA * record. */ export declare function isPrivateAddress(address: string): boolean; export declare class GuardedFetchProvider implements WebFetchProvider { private readonly config; private readonly timeoutMs; private readonly maxBytes; private readonly maxRedirects; constructor(config?: GuardedFetchConfig); /** * Refuse a URL before anything is sent. * * Called for the original URL AND for every redirect target. That * repetition is the point: checking once and then following redirects is * the classic version of this bug — a permitted public URL answers * `302 -> http://169.254.169.254/`, and a fetch that validated only what * the caller typed follows it happily. */ private assertAllowed; fetch(request: WebFetchRequest): Promise; } //# sourceMappingURL=guarded-fetch.d.ts.map