/**
 * Digital Samba MCP Server - Rate Limiting Module
 *
 * This module provides rate limiting functionality for the Digital Samba MCP Server.
 * It implements a token bucket algorithm for limiting the number of requests that can
 * be made in a given time period, helping to protect the Digital Samba API from abuse
 * and ensuring fair usage across clients.
 *
 * Features include:
 * - Configurable rate limits (requests per minute, per hour)
 * - Memory-based storage for rate limiting data
 * - Optional Redis-based storage for distributed deployments
 * - Detailed logging of rate limiting events
 * - Configurable response behavior for rate limited requests
 *
 * @module rate-limiter
 * @author Digital Samba Team
 * @version 0.1.0
 */
import { Request, Response, NextFunction } from 'express';
/**
 * Rate limiter options interface
 */
export interface RateLimiterOptions {
    /** Maximum number of requests allowed per window */
    maxRequests: number;
    /** Time window in milliseconds */
    windowMs: number;
    /** Whether to include headers in response */
    headers: boolean;
    /** Message to send when rate limit is exceeded */
    message?: string;
    /** Key function to identify requesters */
    keyGenerator: (req: Request) => string;
    /** Skip function to bypass rate limiting for certain requests */
    skip?: (req: Request) => boolean;
    /** Handler for when rate limit is exceeded */
    handler?: (req: Request, res: Response) => void;
    /** Whether to trust the X-Forwarded-For header */
    trustProxy?: boolean;
}
/**
 * Default options for the rate limiter
 */
export declare const defaultOptions: Partial<RateLimiterOptions>;
/**
 * TokenBucket rate limiter implementation
 *
 * This class implements a token bucket algorithm for rate limiting.
 * Each client has a bucket that's refilled at a constant rate.
 * When a request is made, a token is consumed from the bucket.
 * If there are no tokens left, the request is rate limited.
 */
export declare class TokenBucketRateLimiter {
    private options;
    private store;
    private tokensPerMs;
    /**
     * Creates a new TokenBucketRateLimiter
     * @param options Rate limiter options
     */
    constructor(options?: Partial<RateLimiterOptions>);
    /**
     * Gets the current status for a client
     * @param key Client identifier
     * @returns Rate limit status
     */
    private getClientStatus;
    /**
     * Consumes a token for a client
     * @param key Client identifier
     * @returns Whether the token was successfully consumed
     */
    consumeToken(key: string): boolean;
    /**
     * Gets remaining tokens for a client
     * @param key Client identifier
     * @returns Number of tokens remaining
     */
    getRemainingTokens(key: string): number;
    /**
     * Gets reset time for a client's rate limit
     * @param key Client identifier
     * @returns Timestamp when rate limit will reset
     */
    getResetTime(key: string): number;
    /**
     * Middleware function for Express
     * @returns Express middleware
     */
    middleware(): (req: Request, res: Response, next: NextFunction) => void;
    /**
     * Gets rate limit status for a client
     * @param key Client identifier
     * @returns Client rate limit status
     */
    getStatus(key: string): {
        remaining: number;
        limit: number;
        reset: number;
    };
    /**
     * Clears the rate limiter store
     */
    reset(): void;
}
/**
 * Redis-backed token bucket rate limiter
 * This implementation uses Redis for storage, making it suitable for distributed deployments.
 * Note: This is a placeholder for the Redis implementation.
 * The actual implementation would use a Redis client library.
 */
export declare class RedisRateLimiter {
    constructor(options?: Partial<RateLimiterOptions>);
}
/**
 * Creates a rate limiter middleware for express
 * @param options Rate limiter options
 * @returns Express middleware
 */
export declare function createRateLimiter(options?: Partial<RateLimiterOptions>): (req: Request, res: Response, next: NextFunction) => void;
/**
 * Creates an API key based rate limiter that limits requests per API key
 * @param options Rate limiter options
 * @returns Express middleware
 */
export declare function createApiKeyRateLimiter(options?: Partial<RateLimiterOptions>): (req: Request, res: Response, next: NextFunction) => void;
/**
 * Creates an IP based rate limiter that limits requests per IP address
 * @param options Rate limiter options
 * @returns Express middleware
 */
export declare function createIpRateLimiter(options?: Partial<RateLimiterOptions>): (req: Request, res: Response, next: NextFunction) => void;
/**
 * Exports the default rate limiter
 */
declare const _default: {
    TokenBucketRateLimiter: typeof TokenBucketRateLimiter;
    RedisRateLimiter: typeof RedisRateLimiter;
    createRateLimiter: typeof createRateLimiter;
    createApiKeyRateLimiter: typeof createApiKeyRateLimiter;
    createIpRateLimiter: typeof createIpRateLimiter;
};
export default _default;
//# sourceMappingURL=rate-limiter.d.ts.map