const SENSITIVE_HEADERS = new Set([ "authorization", "cookie", "set-cookie", "proxy-authorization", "x-api-key", "x-auth-token", "x-fetcha-key", ]); export function redactHeaders(headers: Record | undefined | null): Record { const out: Record = {}; if (!headers) return out; for (const [k, v] of Object.entries(headers)) { out[k] = SENSITIVE_HEADERS.has(k.toLowerCase()) ? "[redacted]" : v; } return out; } /** Strip anything that could identify an upstream provider from an error string. */ export function scrubProviderText(text: string): string { return text .replace(/oxylabs/gi, "upstream") .replace(/decodo/gi, "upstream") .replace(/smartproxy/gi, "upstream") .replace(/soax/gi, "upstream") .replace(/pr\.oxylabs\.io|gate\.decodo\.com|proxy\.soax\.com/gi, "upstream-gateway"); } export function extractDomain(url: string): string { try { const u = new URL(url); return u.hostname.toLowerCase().replace(/^www\./, ""); } catch { return ""; } }