/** * SSRF guard — classifies an address (or hostname literal) as * private/loopback/link-local/cloud-metadata/CGNAT. Single source of truth * for address classification: `web.fetch` (classifier branch + per-hop * resolution check), `src/safety/classifier.ts`, and the legacy * `http.fetch` check (via {@link isBlockedAddress}) all delegate here. */ /** * Categorical address class returned by {@link classify} and * {@link classifyHost} when the input belongs to a non-public range. * * Mappings: * - `loopback` — 127.0.0.0/8, IPv6 `::1`, and the * `localhost` / `ip6-localhost` hostname literals. * - `rfc1918` — 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and * IPv6 ULA `fc00::/7` (the IPv6 private-use range, * grouped here as RFC1918's IPv6 cousin). * - `ipv4-link-local` — 169.254.0.0/16 except the cloud-metadata literal. * - `ipv6-link-local` — `fe80::/10`. * - `cloud-metadata` — `169.254.169.254` (IPv4 EC2/AWS, GCP, Azure * metadata) and `fd00:ec2::254` (IPv6 EC2 metadata). * - `cgnat` — 100.64.0.0/10 (RFC 6598 carrier-grade NAT). */ export type AddressClass = "loopback" | "rfc1918" | "ipv4-link-local" | "ipv6-link-local" | "cloud-metadata" | "cgnat"; /** Result shape returned by {@link classify} and {@link classifyHost}. */ export interface AddressClassification { class: AddressClass; } /** * `true` iff `url` parses as an absolute URL with scheme `http:`/`https:`. * Single source of truth for the scheme allow-list so the safety classifier * and the fetch-core argument validator stay in sync. */ export declare function isAllowedScheme(url: string): boolean; /** * Classify a literal IP address (IPv4 or IPv6). * * Returns `{ class }` when the address falls into one of the * {@link AddressClass} buckets, or `null` when the input is a * globally-routable address (or fails to parse as either family). * * The check is fully synchronous and never performs DNS. */ export declare function classify(ip: string): AddressClassification | null; /** * Classify a hostname or IP literal without performing DNS resolution. * * - For literal IPv4/IPv6 addresses (with or without surrounding `[…]` * brackets), this delegates to {@link classify}. * - For known-bad hostname literals (`localhost`, `localhost.localdomain`, * `ip6-localhost`, `ip6-loopback`), this returns `{ class: "loopback" }`. * - For every other hostname, this returns `null` (the caller is * responsible for the DNS-resolved second pass; see * `src/tools/web/fetch-core.ts`). */ export declare function classifyHost(hostname: string): AddressClassification | null; /** * Legacy boolean shape preserved for the existing `http.fetch` SSRF check. * * Returns `true` whenever {@link classifyHost} would return a non-null * classification, plus a small additional set of historically-blocked * ranges (currently `0.0.0.0/8`, the "this network" range) that are kept * for backward compatibility with the previous `http.ts` implementation * but are not enumerated in the public {@link AddressClass} list. */ export declare function isBlockedAddress(host: string): boolean;