import { IRateLimitManager, RateLimitParams, RateLimitResult } from './types'; import { Logger } from '../utils/logger'; import type { SimpleEventEmitter } from '../utils/simple-event-emitter'; /** * In-memory rate limiter. * WARNING: This implementation is NOT suitable for distributed/multi-process environments * as the state is local to each instance. Use an external store (e.g., Redis) for scaling. */ export declare class RateLimitManager implements IRateLimitManager { private limits; private eventEmitter; private logger; private debugMode; private cleanupIntervalId; private readonly DEFAULT_CLEANUP_INTERVAL_MS; constructor(eventEmitter: SimpleEventEmitter, logger: Logger); setDebugMode(debug: boolean): void; private startCleanupTimer; stopCleanupTimer(): void; /** * Parses the RateLimit configuration to get the window size in milliseconds. * @returns Window size in ms, or 0 if invalid. */ private getTimeWindowMs; /** * Checks if a request is allowed based on the defined rate limit. * Increments the counter if the request is allowed. * @param params - RateLimitParams containing identifiers and limit config. * @returns RateLimitResult indicating if allowed and current state. */ checkRateLimit(params: RateLimitParams): RateLimitResult; /** Clears rate limits, optionally for a specific user. */ clearLimits(userId?: string): void; /** Periodically removes very old/stale entries from the map to manage memory. */ private cleanupExpiredLimits; destroy(): void; }