/** * Configuration options for the RateLimiter. */ export interface RateLimiterConfig { /** Maximum number of requests allowed within the time window */ maxRequests: number; /** Time window in milliseconds */ windowMs: number; } /** * A sliding-window rate limiter that tracks requests per client. * Uses a Map to store request timestamps for each client and * automatically cleans up expired entries. */ export declare class RateLimiter { private readonly maxRequests; private readonly windowMs; private readonly clients; /** * Creates a new RateLimiter instance. * * @param config - Configuration for request limits and time window * @throws Error if maxRequests or windowMs are not positive numbers */ constructor(config: RateLimiterConfig); /** * Checks if a request from the given client is allowed. * If allowed, records the request timestamp. * * @param clientId - Unique identifier for the client * @returns True if the request is allowed, false if rate limited */ isAllowed(clientId: string): boolean; /** * Returns the number of remaining requests for a client within the current window. * * @param clientId - Unique identifier for the client * @returns Number of remaining allowed requests */ getRemainingRequests(clientId: string): number; /** * Resets rate limiting state. * If clientId is provided, resets only that client. * Otherwise, resets all clients. * * @param clientId - Optional client identifier to reset */ reset(clientId?: string): void; /** * Removes expired timestamps from a client's entry. * Deletes the entry entirely if no valid timestamps remain. * * @param clientId - Client identifier to clean up * @param now - Current timestamp for expiration calculation */ private cleanupExpiredEntries; } //# sourceMappingURL=rate-limiter-simple.d.ts.map