import type { ServerWebSocket } from 'bun'; import type { User, WebSocketData } from './types'; // ==================== Authentication ==================== export declare interface AuthConfig { enabled?: boolean required?: boolean cookie?: { name?: string secure?: boolean } jwt?: { secret?: string algorithm?: 'HS256' | 'HS384' | 'HS512' } session?: { key?: string } } // ==================== Rate Limiting ==================== export declare interface RateLimitConfig { max: number window: number perChannel?: boolean perUser?: boolean } // ==================== Monitoring and Metrics ==================== export declare interface MetricEvent { type: 'connection' | 'disconnection' | 'message' | 'subscribe' | 'unsubscribe' | 'error' | 'broadcast' timestamp: number socketId: string channel?: string data?: unknown } // ==================== Security ==================== export declare interface SecurityConfig { cors?: { enabled?: boolean origins?: string[] credentials?: boolean } maxPayloadSize?: number sanitizeMessages?: boolean } export type AuthCallback = (_req: Request) => Promise | User | null; // ==================== Message Validation ==================== export type MessageValidator = (_message: unknown) => boolean | string; export type MetricCallback = (_event: MetricEvent) => void; export declare class AuthenticationManager { constructor(config?: AuthConfig); authenticate(callback: AuthCallback): void; isRequired(): boolean; authenticateRequest(req: Request): Promise; } export declare class RateLimiter { constructor(config: RateLimitConfig); check(ws: ServerWebSocket, channel?: string): boolean; getRemaining(ws: ServerWebSocket, channel?: string): number; getResetAt(ws: ServerWebSocket, channel?: string): number; clear(): void; stop(): void; } export declare class MessageValidationManager { addValidator(validator: MessageValidator): void; removeValidator(validator: MessageValidator): void; validate(message: unknown): { valid: boolean, error?: string }; } export declare class MonitoringManager { on(event: MetricEvent['type'] | 'all', callback: MetricCallback): void; off(event: MetricEvent['type'] | 'all', callback: MetricCallback): void; emit(event: MetricEvent): void; incrementMetric(metric: string, amount?: number): void; getMetric(metric: string): number; getMetrics(): Record; resetMetrics(): void; } export declare class SecurityManager { constructor(config?: SecurityConfig); checkOrigin(origin: string): boolean; sanitize(data: unknown): unknown; checkSize(message: string): boolean; }