Commit ·
690837a
1
Parent(s): b01564f
random user agent
Browse files7 unmodified lines89101112111213166 unmodified lines1801811821851831841851865 unmodified lines19219319419719519619719845 unmodified lines24424524624724924824925025129 unmodified lines28128228328528428528628768 unmodified lines35635735835936036036136236336429 unmodified lines3943953963963973983994007 unmodified lines DuckAIRequest,} from "./types";
const userAgent = new UserAgent();
// Rate limiting tracking with sliding windowinterface RateLimitInfo { requestTimestamps: number[]; // Array of request timestamps for sliding window166 unmodified lines } }
private async getVQD(): Promise<VQDResponse> { private async getVQD(userAgent: string): Promise<VQDResponse> { const response = await fetch("https://duckduckgo.com/duckchat/v1/status", { headers: { accept: "*/*",5 unmodified lines "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "x-vqd-accept": "1", "User-Agent": userAgent.toString(), "User-Agent": userAgent, }, referrer: "https://duckduckgo.com/", referrerPolicy: "origin",45 unmodified lines // Wait if rate limiting is needed await this.waitIfNeeded();
const userAgent = new UserAgent().toString(); const vqd = await this.getVQD(); const vqd = await this.getVQD(userAgent);
const { window } = new JSDOM( `<html><body><script>window.hash = ${vqd.hash}</script></body></html>`,29 unmodified lines "sec-fetch-site": "same-origin", "x-fe-version": "serp_20250401_100419_ET-19d438eb199b2bf7c300", "x-vqd-4": vqd.vqd, "User-Agent": userAgent.toString(), "User-Agent": userAgent, "x-vqd-hash-1": btoa( JSON.stringify({ server_hashes: hash.server_hashes,68 unmodified lines // Wait if rate limiting is needed await this.waitIfNeeded();
const userAgent = new UserAgent().toString();
const vqd = await this.getVQD(); const vqd = await this.getVQD(userAgent);
const { window } = new JSDOM( `<html><body><script>window.hash = ${vqd.hash}</script></body></html>`,29 unmodified lines "sec-fetch-site": "same-origin", "x-fe-version": "serp_20250401_100419_ET-19d438eb199b2bf7c300", "x-vqd-4": vqd.vqd, "User-Agent": userAgent.toString(), "User-Agent": userAgent, "x-vqd-hash-1": btoa( JSON.stringify({ server_hashes: hash.server_hashes,src/duckai.ts+9-8