import { ApiKey } from './AuthManager.js'; /** * Security Middleware * Integrates all security features into a single middleware */ export interface SecurityConfig { auth: { enabled: boolean; requireApiKey: boolean; allowedOrigins?: string[]; defaultRateLimit?: { requestsPerMinute: number; requestsPerHour: number; }; }; rateLimit: { enabled: boolean; requestsPerMinute: number; requestsPerHour: number; blockDuration?: number; }; sanitization: { enabled: boolean; maxStringLength?: number; maxArrayLength?: number; maxObjectDepth?: number; }; } export interface SecurityCheckResult { allowed: boolean; reason?: string; apiKey?: ApiKey; rateLimit?: { remaining: { perMinute: number; perHour: number; }; resetAt?: number; }; sanitizedMessage?: any; } export declare class SecurityMiddleware { private authManager; private rateLimiter; private sanitizer; private config; constructor(config: SecurityConfig); /** * Check if a request is allowed * @param isConnectionCheck - true when called for the initial TCP/WS connection * (before any protocol message arrives). Skips message structure validation. */ checkRequest(apiKey: string | undefined, origin: string | undefined, message: any, identifier: string, isConnectionCheck?: boolean): SecurityCheckResult; /** * Generate a new API key */ generateApiKey(agentId: string, name: string, options?: { expiresIn?: number; permissions?: string[]; rateLimit?: { requestsPerMinute: number; requestsPerHour: number; }; }): string; /** * Revoke an API key */ revokeApiKey(key: string): boolean; /** * List API keys */ listApiKeys(agentId?: string): ApiKey[]; /** * Get rate limit usage */ getRateLimitUsage(identifier: string): { minuteRequests: number; hourRequests: number; blockedUntil?: number; }; /** * Reset rate limit for an identifier */ resetRateLimit(identifier: string): void; /** * Destroy security middleware */ destroy(): void; } //# sourceMappingURL=SecurityMiddleware.d.ts.map