/** * Rate Limiter - Per-domain request throttling * * Prevents overwhelming government websites and getting blocked */ interface DomainConfig { requestsPerMinute: number; minDelayMs: number; } export declare class RateLimiter { private requestHistory; private domainLocks; /** * Get domain from URL */ private getDomain; /** * Get rate limit config for a domain */ private getConfig; /** * Clean up old request records (older than 1 minute) */ private cleanupHistory; /** * Calculate delay needed before next request */ private calculateDelay; /** * Record a request */ private recordRequest; /** * Wait for rate limit delay and record request. * * Note: This method only handles rate limiting (delay calculation and request recording). * For serialized access (ensuring one request at a time per domain), use throttle() instead. * The lock mechanism is intentionally NOT checked here to avoid deadlock when called from throttle(). */ acquire(url: string): Promise; /** * Wrap an async function with rate limiting */ throttle(url: string, fn: () => Promise): Promise; /** * Get current rate limit status for a domain */ getStatus(url: string): { domain: string; requestsInLastMinute: number; limit: number; canRequest: boolean; }; /** * Add or update rate limit config for a domain */ setDomainConfig(domain: string, config: DomainConfig): void; } export declare const rateLimiter: RateLimiter; export {}; //# sourceMappingURL=rate-limiter.d.ts.map