import dns from 'dns'; export declare const BLOCKED_MESSAGE = "Blocked: the URL points to a private or reserved address"; /** The error of a connection refused by the guard. `code` is `EBLOCKED`. */ export declare class BlockedAddressError extends Error { code: string; constructor(); } export type LookupFunction = (hostname: string, options: dns.LookupOptions, callback: (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void) => void; export interface GuardOptions { /** * Whether private addresses may be contacted (local development, a test). * Called on every lookup, so it can follow configuration. */ allowPrivate: () => boolean; /** The DNS lookup. A test passes a fake; the default is `dns.lookup`. */ lookup?: LookupFunction; } /** * Connect-time SSRF guard. The hostname is resolved here and the connection is * refused if ANY resolved address is blocked. Checking the address we actually * connect to (not just the hostname when the URL was saved) is what defeats DNS * rebinding and a hostname that points at an internal address. Passed to an * undici `Agent` as `connect.lookup`. */ export declare function createGuardedLookup(options: GuardOptions): (hostname: string, lookupOptions: any, callback: any) => void; /** * An IP literal in the URL (`https://169.254.169.254/`) is never resolved, so * the guarded lookup does not run for it. Check it here instead. */ export declare function assertLiteralAllowed(hostname: string, allowPrivate: boolean): void;