/** * URL helpers shared across packages. * * @module */ /** * Returns true when the hostname is a loopback, private, link-local, or * otherwise non-routable literal that should not be fetched from untrusted * input. */ export declare function isPrivateHostname(hostname: string): boolean; /** * Thrown by {@link assertPublicUrl} (and surfaced by {@link fetchPublicUrl}) when a URL — or a * redirect target — fails public-URL validation. Distinct from generic `Error` so callers can * map validation failures to a specific error code (e.g. `invalidGatewayUri`) without * accidentally also mapping unrelated network failures. */ export declare class PublicUrlValidationError extends Error { constructor(message: string); } /** * Parses and validates that a URL targets a routable public host over an allowed network scheme. * * Rejects: * - URLs whose protocol is not in `allowedProtocols` (defaults to `http:` / `https:`), so callers * cannot smuggle `file:`, `javascript:`, `data:`, `ws:`, etc. past a downstream `fetch()`. * - URLs without a hostname. * - URLs whose hostname is a loopback, private, link-local, or otherwise non-routable literal per * {@link isPrivateHostname}, unless `allowPrivateHosts` explicitly permits trusted local targets. * * This intentionally does not perform DNS resolution, so callers handling high-risk server-side * fetches should still consider DNS rebinding defenses (and use {@link fetchPublicUrl} to also * validate every redirect target). */ export declare function assertPublicUrl(url: string | URL, description?: string, options?: { allowedProtocols?: readonly string[]; allowPrivateHosts?: boolean; }): URL; /** * Performs a `fetch()` whose target — and every subsequent redirect target — is validated by * {@link assertPublicUrl}. Defends against SSRF via redirect-based bypasses where a public * gateway returns `Location: http://127.0.0.1/...` after the initial validation succeeded. * * Manually drives the redirect loop so each `Location` is re-validated. A 3xx response without a * `Location` header (e.g. `304 Not Modified`) is returned to the caller unchanged. */ export declare function fetchPublicUrl(url: string | URL, init?: RequestInit, options?: { description?: string; allowedProtocols?: readonly string[]; /** Allow trusted local targets without bypassing scheme validation or redirect limits. */ allowPrivateHosts?: boolean; maxRedirects?: number; /** Wrap each validated hop's fetch independently of URL and redirect handling. */ fetchFn?: (url: string, init: RequestInit) => Promise; }): Promise; /** * Concatenates a base URL and a path ensuring that there is exactly one slash between them. * * The `path` argument must be a pure URL pathname — raw `?` (query) and `#` (fragment) delimiters * are rejected because they are silently percent-encoded by the WHATWG URL parser when assigned * to `pathname`, which would otherwise change the endpoint a caller meant to reach. Callers that * need to attach a query string or fragment should construct the URL explicitly. Percent-encoded * `%3F` / `%23` are preserved so genuine path segments containing those characters work. */ export declare function concatenateUrl(baseUrl: string, path: string): string; //# sourceMappingURL=url.d.ts.map