/**
 * Rate Limiting Middleware
 *
 * Implements sliding window rate limiting with support for:
 * - Global rate limits
 * - Per-key rate limits
 * - Per-endpoint rate limits
 * - Route-based configuration
 */
import type { Request, Response, NextFunction } from 'express';
import type { ServerConfig } from '../types.js';
interface RateLimitEntry {
    count: number;
    resetAt: number;
    requests: number[];
}
/**
 * Configuration for route-based rate limiting
 */
export interface RateLimitOptions {
    /** Maximum requests allowed in the window */
    maxRequests: number;
    /** Time window in milliseconds */
    windowMs: number;
    /** Optional key prefix for store isolation */
    keyPrefix?: string;
    /** Skip rate limiting for certain conditions */
    skip?: (req: Request) => boolean;
    /** Custom key generator */
    keyGenerator?: (req: Request) => string;
    /** Custom handler for rate limit exceeded */
    handler?: (req: Request, res: Response, next: NextFunction, retryAfter: number) => void;
}
/**
 * Default rate limit configurations by route prefix
 */
export declare const DEFAULT_ROUTE_LIMITS: Record<string, RateLimitOptions>;
/**
 * Create rate limiting middleware with route-based configuration
 */
export declare function createRateLimitMiddleware(config: ServerConfig): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
/**
 * Create endpoint-specific rate limit middleware
 */
export declare function endpointRateLimit(maxRequests: number, windowMs: number): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
/**
 * Create a rate limiter for a specific route prefix
 * Useful for applying different limits to different route groups
 *
 * @example
 * // 10 requests per minute for auth routes
 * app.use('/auth', createRouteRateLimiter({ maxRequests: 10, windowMs: 60000 }));
 *
 * // 100 requests per minute for API routes
 * app.use('/api', createRouteRateLimiter({ maxRequests: 100, windowMs: 60000 }));
 */
export declare function createRouteRateLimiter(options: RateLimitOptions): (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
/**
 * Predefined rate limiters for common use cases
 */
export declare const rateLimiters: {
    /** Strict limiter for auth endpoints: 10 req/min */
    auth: (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
    /** Standard API limiter: 100 req/min */
    api: (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
    /** Relaxed limiter for read-only endpoints: 200 req/min */
    readonly: (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
    /** Very strict limiter for sensitive operations: 5 req/min */
    sensitive: (req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>;
};
/**
 * Get current rate limit stats for a key
 */
export declare function getRateLimitStats(keyId: string): {
    used: number;
    remaining: number;
    resetAt: number;
} | null;
/**
 * Reset rate limit for a key (admin function)
 */
export declare function resetRateLimit(keyId: string): boolean;
/**
 * Get all rate limit entries (admin function)
 */
export declare function getAllRateLimits(): Map<string, RateLimitEntry>;
export {};
