export interface RateLimitRule { readonly count: number; readonly windowSeconds: number; } export interface LockoutRule { readonly failures: number; readonly windowSeconds: number; readonly lockSeconds: number; } /** * `/`, the one definition of a rate rule in this package. The * principals file validates a rule by parsing it through `parseRule` rather * than restating this pattern, so there is no second copy to drift from it. */ export declare const RATE_RULE_PATTERN: RegExp; /** * Sliding windows keyed by principal id, plus one key for requests that * never became a principal. Memory is bounded by the registry: a key holds * at most its rule's count of timestamps, and there is no key a caller can * invent. A lockout engages when a principal's authentication failures reach * the rule inside its window, and ends only when the lock expires or the * process restarts. */ export declare class RateLimiter { private readonly clock; private readonly hits; private readonly failures; private readonly locks; constructor(clock?: () => number); /** `/`; a refusal names the variable. */ static parseRule(text: string, key: string): RateLimitRule; /** `//`; zero failures disables the lockout. */ static parseLockout(text: string, key: string): LockoutRule | null; /** Whether the key has room under the rule right now, without taking any. */ exhausted(key: string, rule: RateLimitRule): boolean; /** Takes one request from the key's window; false when the window is full. */ allow(key: string, rule: RateLimitRule): boolean; /** Records an authentication failure; true when this one engaged the lock. */ recordFailure(key: string, rule: LockoutRule | null): boolean; locked(key: string): boolean; private recent; } //# sourceMappingURL=RateLimiter.d.ts.map