/** * Sliding window rate limiter — in-memory, resets on Gate restart. * * Tracks request timestamps per credential and enforces configurable * rate limits like "100/min", "1000/hour", "10/sec". * * This is intentionally simple for v0.2. A persistent rate limiter * backed by Redis or SQLite is planned for later phases. */ export interface RateLimit { /** Maximum number of requests in the window */ maxRequests: number; /** Window size in milliseconds */ windowMs: number; } export interface RateLimitResult { allowed: boolean; /** Seconds until the client should retry (only set when blocked) */ retryAfterSeconds?: number; /** How many requests remain in the current window */ remaining: number; /** Total limit for the window */ limit: number; } /** * Parse a rate limit string like "100/min" into a structured RateLimit. * * Supported formats: * - "100/min" or "100/minute" * - "1000/hour" or "1000/hr" * - "10/sec" or "10/second" * - "5000/day" */ export declare function parseRateLimit(input: string): RateLimit; /** * Format a RateLimit back to a human-readable string. */ export declare function formatRateLimit(limit: RateLimit): string; export declare class RateLimiter { /** * Map from credential ID → array of request timestamps (epoch ms). * Timestamps outside the window are pruned on each check. */ private windows; /** * Check if a request for the given credential is allowed under its rate limit. * Records the request timestamp if allowed. */ check(credentialId: string, limit: RateLimit): RateLimitResult; /** * Reset rate limit state for a specific credential (e.g. after rotation). */ reset(credentialId: string): void; /** * Clear all rate limit state. */ clear(): void; } //# sourceMappingURL=rate-limiter.d.ts.map