/** * * IMPIT (by Apify): * ───────────────── * Impit is a Rust-based HTTP client compiled to a native addon for Node.js. * It uses BoringSSL (not OpenSSL!) and can impersonate real browser TLS * fingerprints (JA3/JA4/HTTP2 AKAMAI fingerprint). This means it should * produce a TLS handshake indistinguishable from Chrome/Firefox/Safari, * bypassing Cloudflare's bot detection without needing a real browser. * * Key difference from Node.js fetch: * - Node.js fetch → undici → OpenSSL → known bot fingerprint → BLOCKED * - Impit → Rust → BoringSSL → browser fingerprint → ✅ PASSES */ import type { RequestInit } from "impit"; import { HttpProxyAgent } from "http-proxy-agent"; import { HttpsProxyAgent } from "https-proxy-agent"; import { SocksProxyAgent } from "socks-proxy-agent"; declare module "impit" { interface RequestInit { /** Clean request with no defualt headers options attached * default headers inclue "Content-Type": "application/json" and "Accept": "application/json" * - When set to true, the fetch request will not include the default headers and will only use the headers provided in the options * - Useful for making requests that require custom headers or no headers at all, without being overridden by default values */ clean?: boolean; /** Proxy agent to use for the request */ agent?: HttpProxyAgent | HttpsProxyAgent | SocksProxyAgent; /** Custom cache key for caching responses */ customCacheKey?: string; /** Number of milliseconds to cache the response */ cacheTTL?: number; } } /** Handle HTTPS request requestResponse */ export declare function handleResponse(requestResponse: Response): Promise; /** Make an application fetch request */ export declare function appFetch(request: RequestInfo | URL, options?: RequestInit): Promise; /** Fetch with timeout * @see {@link appFetch} for fetch behavior * @default timeout 1000ms * - Aborts the request if it takes longer than the specified timeout * - Useful for preventing hanging requests and improving responsiveness * - If the request is aborted due to timeout, it throws an AbortError which can be caught and handled by the caller */ export declare function fetchWithTimeout(request: RequestInfo | URL, options: RequestTimeoutInit): Promise; export declare function fetchWithRetry(request: RequestInfo | URL, options: RequestRetryInit): Promise; /** Fetch and handle HTTPS request requestResponse * - Makes a fetch request using appFetch and processes the response with handleResponse * - Returns the parsed response if successful, or throws an error if the request fails * - Useful for making API requests and automatically handling response parsing and error handling in a consistent way across the application * @see {@link appFetch} for fetch behavior * @see {@link handleResponse} for response handling behavior */ export declare function fetchResponse(request: RequestInfo | URL, options?: RequestInit): Promise; /** Fetch with retry mechanism * @see {@link fetchResponse} for fetch behavior * @default "{maxAttempts : 1}" 1 retries * @default "{retryTimeout : 800}" 800ms between retries * - Retries the request a specified number of times with delay * - If the request fails after all retries, it throws the last encountered error * - Useful for handling transient network issues or temporary server unavailability */ export declare function fetchResponseWithRetry(request: RequestInfo | URL, options: RequestRetryInit): Promise; /** Fetch and handle HTTPS request requestResponse with timeout * @see {@link fetchWithTimeout} for timeout behavior * @see {@link handleResponse} for response handling behavior * - Executes request with timeout and handles response parsing * - Combines the functionality of fetchWithTimeout and handleResponse to provide a convenient way to make requests with timeout and automatic response handling * - If the request is successful within the timeout, it returns the parsed response * - If the request fails or times out, it throws the corresponding error which can be caught and handled by the caller */ export declare function fetchResponseWithTimeout(request: RequestInfo | URL, options: RequestTimeoutInit): Promise; export type RequestRetryInit = RequestInit & { maxAttempts?: number; retryTimeout?: number; }; export type RequestTimeoutInit = Omit & { timeout?: number; }; export type RequestInfo = globalThis.RequestInfo; export type Response = globalThis.Response; export { RequestInit };