/** * Stealth Fetch Module * * Provides TLS fingerprint impersonation for bypassing bot detection. * Uses CycleTLS when available for browser-like TLS fingerprints. * * This is inspired by yt-dlp's use of curl_cffi for TLS fingerprinting, * adapted for the Node.js ecosystem using CycleTLS. * * @see https://github.com/Danny-Dasilva/CycleTLS * @see https://github.com/lexiforest/curl_cffi */ /** * Browser fingerprint profiles * Based on real browser JA3/JA4 fingerprints */ export declare const BROWSER_PROFILES: { readonly chrome_120: { readonly ja3: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-21,29-23-24,0"; readonly userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"; readonly headers: { readonly 'sec-ch-ua': "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\""; readonly 'sec-ch-ua-mobile': "?0"; readonly 'sec-ch-ua-platform': "\"Windows\""; readonly 'sec-fetch-dest': "document"; readonly 'sec-fetch-mode': "navigate"; readonly 'sec-fetch-site': "none"; readonly 'sec-fetch-user': "?1"; readonly 'upgrade-insecure-requests': "1"; }; }; readonly firefox_121: { readonly ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0"; readonly userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0"; readonly headers: { readonly 'upgrade-insecure-requests': "1"; }; }; readonly safari_17: { readonly ja3: "771,4865-4866-4867-49196-49195-52393-49200-49199-52392-49188-49187-49192-49191-49162-49161-49172-49171-157-156-53-47-255,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0"; readonly userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15"; readonly headers: {}; }; readonly chrome_android: { readonly ja3: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-21,29-23-24,0"; readonly userAgent: "Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.144 Mobile Safari/537.36"; readonly headers: { readonly 'sec-ch-ua': "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\""; readonly 'sec-ch-ua-mobile': "?1"; readonly 'sec-ch-ua-platform': "\"Android\""; }; }; readonly chrome_ios: { readonly ja3: "771,4865-4866-4867-49196-49195-52393-49200-49199-52392-49188-49187-49192-49191-49162-49161-49172-49171-157-156-53-47-255,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0"; readonly userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.6099.119 Mobile/15E148 Safari/604.1"; readonly headers: {}; }; }; export type BrowserProfile = keyof typeof BROWSER_PROFILES; /** * Stealth fetch options */ export interface StealthFetchOptions { /** Browser profile to impersonate */ profile?: BrowserProfile; /** Custom JA3 fingerprint */ ja3?: string; /** Custom user agent */ userAgent?: string; /** Additional headers */ headers?: Record; /** Request timeout in ms */ timeout?: number; /** Proxy URL */ proxy?: string; /** Follow redirects */ followRedirects?: boolean; /** Maximum redirects to follow */ maxRedirects?: number; } /** * Stealth fetch response */ export interface StealthFetchResponse { status: number; statusText: string; headers: Record; body: string; url: string; redirected: boolean; } /** * Check if CycleTLS is available */ export declare function isCycleTLSAvailable(): Promise; /** * Cleanup CycleTLS instance * Call this when shutting down to clean up resources */ export declare function cleanupCycleTLS(): Promise; /** * Fetch with TLS fingerprint impersonation * * Falls back to standard fetch if CycleTLS is not available. */ export declare function stealthFetch(url: string, options?: StealthFetchOptions): Promise; /** * Fetch with random browser profile * Useful for avoiding fingerprint-based blocking */ export declare function stealthFetchRandom(url: string, options?: Omit): Promise; /** * Fetch with retry on fingerprint detection * Switches browser profiles on 403/429 responses */ export declare function stealthFetchWithRetry(url: string, options?: StealthFetchOptions, maxRetries?: number): Promise; /** * Check if a site likely requires stealth fetching * Based on common bot detection patterns */ export declare function likelyNeedsStealth(url: string): boolean; export default stealthFetch; //# sourceMappingURL=stealth-fetch.d.ts.map