/** * Configuration options for the RateLimiter. */ export interface RateLimiterConfig { maxRequests: number; windowMs: number; } export declare class RateLimiter { private static readonly configSchema; private static readonly clientIdSchema; private readonly maxRequests; private readonly windowMs; private readonly requests; /** * Creates a new RateLimiter instance. * * @param config - Configuration for request limits and window size * @returns A configured RateLimiter instance * @throws AppError when config is invalid */ constructor(config: RateLimiterConfig); /** * Checks if a request from the given client is allowed and records it if so. * * @param clientId - Identifier for the calling client * @returns True if the request is allowed; otherwise false * @throws AppError when clientId is invalid */ isAllowed(clientId: string): boolean; /** * Returns the remaining number of requests for a client in the current window. * * @param clientId - Identifier for the calling client * @returns Remaining number of requests in the window * @throws AppError when clientId is invalid */ getRemainingRequests(clientId: string): number; /** * Resets rate limiting for a single client or all clients. * * @param clientId - Optional client identifier to reset; omit to reset all * @returns Nothing */ reset(clientId?: string): void; /** * Removes expired timestamps and deletes empty client entries. * * @param now - Current timestamp used as reference * @param clientId - Optional client identifier to scope cleanup * @returns Nothing */ private cleanupExpiredEntries; /** * Ensures the client identifier is valid. * * @param clientId - Identifier to validate * @returns Nothing * @throws AppError when clientId is invalid */ private ensureValidClientId; } //# sourceMappingURL=rate-limiter.d.ts.map