import { lookup as dnsLookup, type LookupAddress } from "node:dns"; import { type Dispatcher } from "undici"; export declare class SsrfBlockedError extends Error { readonly hostname: string; readonly address: string; constructor(hostname: string, address: string); } /** * True if `ip` is a private, loopback, link-local, CGNAT, multicast, or * otherwise-reserved address that outbound fetches must never reach. Anything * that is not a parseable IP literal is treated as unsafe (returns true) — the * caller is expected to pass a resolved address, not a hostname. */ export declare function isPrivateOrReservedAddress(ip: string): boolean; type LookupCallback = (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void; /** * Wrap a dns.lookup-shaped function so a resolution to any private/reserved * address fails the lookup. Exported for direct unit testing; production code * uses {@link ssrfGuardedDispatcher}. */ export declare function makeGuardedLookup(baseLookup?: typeof dnsLookup): (hostname: string, options: Parameters[1], callback: LookupCallback) => void; /** * Shared undici dispatcher for all outbound fetches to caller-influenced or * discovered URLs. Its connect-time lookup rejects private/reserved * resolutions (see module header). Reused across requests — undici pools * connections per origin behind it. */ export declare const ssrfGuardedDispatcher: Dispatcher; /** * Resolve a URL's hostname and throw if any resolved address is * private/reserved. Use this before handing a URL to an **external fetcher** * (Firecrawl/Crawl4AI) that resolves and connects on our behalf and therefore * can't be covered by {@link ssrfGuardedDispatcher} (which only guards our own * connections). Unlike the connect-time guard this has a TOCTOU window — the * external service re-resolves later and could get a different answer — but it * closes the common DNS-rebinding case (a hostname that stably resolves to an * internal address) that the string-level `assertPublicUrl` misses. A * resolution failure is not treated as a block: let the downstream fetch * surface its own DNS error rather than masking it here. */ export declare function assertResolvedPublic(url: string): Promise; export {};