import type { WebFetchError } from "./types.js"; import { RequestLoopContext, networkError } from "./issue-hop.js"; export { timeoutError } from "./issue-hop.js"; export { networkError }; export type { DnsLookupFn, HttpRequestFn, HttpsRequestFn, NormalisedArgs } from "./issue-hop.js"; export declare function schemeOf(raw: string): string; type RequestLoopResult = { ok: true; lastUrl: string; contentType: string | undefined; body: string; bytesReceived: number; truncated: boolean; truncatedAt?: number; } | { ok: false; lastUrl: string; error: WebFetchError; }; /** * Run up to {@link MAX_REDIRECT_HOPS} request hops. Each hop: * * - parses the current URL * - re-applies the SSRF pre-check on the hostname literal * - resolves the hostname via {@link DnsLookupFn}, captures `dnsMs` * and the resolved IP * - re-applies the SSRF check on the resolved IP * - builds a pinned-IP `https/http.request` with a custom `lookup` * callback that returns the resolved IP synchronously * - on a 3xx with `Location`, appends a redirect hop and loops * - on a binary content type, returns `binary-content` * - on a 4xx/5xx terminal, reads up to * {@link HTTP_ERROR_BODY_PREVIEW_BYTES} bytes for the preview and * returns `http-error` * - on a 2xx terminal, reads the body up to `maxBytes` and returns * success */ export declare function runRequestLoop(ctx: RequestLoopContext): Promise;