UNPKG

@ai-capabilities-suite/mcp-debugger-core

Version:

Core debugging engine for Node.js and TypeScript applications. Provides Inspector Protocol integration, breakpoint management, variable inspection, execution control, profiling, hang detection, and source map support.

142 lines (141 loc) 3.79 kB
/** * Authentication token */ export interface AuthToken { token: string; createdAt: Date; expiresAt: Date; metadata?: Record<string, any>; } /** * API key definition */ export interface ApiKey { key: string; hashedKey: string; name: string; createdAt: Date; enabled: boolean; metadata?: Record<string, any>; } /** * Authentication result */ export interface AuthResult { authenticated: boolean; error?: string; } /** * Authentication configuration */ export interface AuthConfig { enabled: boolean; tokenExpirationMs?: number; requireApiKey?: boolean; tokens?: string[]; } /** * Manages authentication for MCP connections * Provides token-based authentication and API key validation */ export declare class AuthManager { private tokens; private apiKeys; private config; private validTokens; constructor(config?: AuthConfig); /** * Generate a new authentication token * @param metadata Optional metadata to associate with the token * @returns The generated token */ generateToken(metadata?: Record<string, any>): AuthToken; /** * Authenticate a token and return detailed result * @param token The token to authenticate * @returns Authentication result with status and error message */ authenticate(token: string | null | undefined): AuthResult; /** * Constant-time comparison to prevent timing attacks * @param token The token to check * @returns True if the token is valid */ private constantTimeCompare; /** * Validate an authentication token * @param token The token to validate * @returns True if the token is valid and not expired */ validateToken(token: string): boolean; /** * Revoke an authentication token * @param token The token to revoke * @returns True if the token was found and revoked */ revokeToken(token: string): boolean; /** * Clean up expired tokens */ cleanupExpiredTokens(): void; /** * Create an API key * @param name Name for the API key * @param metadata Optional metadata to associate with the key * @returns The created API key (with the unhashed key) */ createApiKey(name: string, metadata?: Record<string, any>): ApiKey; /** * Validate an API key * @param key The API key to validate * @returns True if the key is valid and enabled */ validateApiKey(key: string): boolean; /** * Revoke an API key * @param key The API key to revoke * @returns True if the key was found and revoked */ revokeApiKey(key: string): boolean; /** * Delete an API key * @param key The API key to delete * @returns True if the key was found and deleted */ deleteApiKey(key: string): boolean; /** * Get all API keys (without the actual key values) * @returns Array of API keys with hashed keys */ getAllApiKeys(): Omit<ApiKey, 'key'>[]; /** * Hash an API key for secure storage * @param key The API key to hash * @returns The hashed key */ private hashApiKey; /** * Check if authentication is enabled * @returns True if authentication is enabled */ isEnabled(): boolean; /** * Check if API key validation is required * @returns True if API key validation is required */ requiresApiKey(): boolean; /** * Get the number of active tokens * @returns The number of active tokens */ getActiveTokenCount(): number; /** * Get the number of API keys * @returns The number of API keys */ getApiKeyCount(): number; /** * Clear all tokens and API keys */ clear(): void; }