import { Tool as BaseTool, UserAuthInfo as BaseUserAuthInfo, SecurityConfig as BaseSecurityConfig, ToolCallEvent as BaseToolCallEvent, RateLimit as BaseRateLimit, DangerousArgumentsConfig as BaseDangerousArgumentsConfig, UserAuthConfig as BaseUserAuthConfig, ToolAccessConfig as BaseToolAccessConfig, RoleConfig as BaseRoleConfig } from '../types'; export interface ExtendedRateLimit extends BaseRateLimit { interval?: string | number; } export type ExtendedUserAuthInfo = BaseUserAuthInfo & { username?: string; roles?: string[]; permissions?: string[]; metadata?: Record; }; export type ExtendedDangerousArgumentsConfig = BaseDangerousArgumentsConfig & { extendablePatterns?: Array; auditOnlyMode?: boolean; specificKeyRules?: Record; }; export type UserAuthConfig = BaseUserAuthConfig; export type ToolAccessConfig = BaseToolAccessConfig; export type RoleConfig = BaseRoleConfig; export type ExtendedSecurityConfig = BaseSecurityConfig & { debug: boolean; allowUnauthenticatedAccess?: boolean; dangerousArguments?: ExtendedDangerousArgumentsConfig; toolConfig?: Record; }>; }; export interface SecurityContext { config: ExtendedSecurityConfig; debug: boolean; userId?: string; toolName?: string; } export interface ISecurityManager { getConfig(): ExtendedSecurityConfig; updateConfig(config: Partial): void; authenticateUser(accessToken?: string): Promise; createAccessToken(userInfo: Omit, expiresIn?: string | number): string; checkToolAccessAndArgs(tool: BaseTool, userInfo: ExtendedUserAuthInfo | null, args?: any): Promise; logToolCall(event: ExtendedToolCallEvent): void; isDebugEnabled(): boolean; setDebugMode(debug: boolean): void; on(event: string, handler: (event: any) => void): ISecurityManager; off(event: string, handler: (event: any) => void): ISecurityManager; clearTokenCache(): void; clearRateLimitCounters(userId?: string): void; destroy?(): void; } export interface SecurityCheckParams { tool: BaseTool; userInfo: ExtendedUserAuthInfo | null; args?: any; context: SecurityContext; securityManager?: ISecurityManager; } export interface TokenValidationResult { isValid: boolean; userInfo?: ExtendedUserAuthInfo; error?: Error; } export interface TokenConfig { payload: Omit; expiresIn?: string | number; } export interface RateLimitParams { userId: string; toolName: string; rateLimit: ExtendedRateLimit; source?: string; } export interface RateLimitResult { allowed: boolean; currentCount: number; limit: number; resetTime: Date; timeLeft?: number; } export interface IAuthManager { authenticateUser(accessToken?: string): Promise; createAccessToken(config: TokenConfig): string; validateToken(token: string): Promise; clearTokenCache(): void; setDebugMode(debug: boolean): void; updateSecret?(newSecret: string | undefined): void; destroy?(): void; } export interface IAccessControlManager { checkAccess(params: SecurityCheckParams): Promise; setDebugMode(debug: boolean): void; destroy?(): void; } export interface IRateLimitManager { checkRateLimit(params: RateLimitParams): RateLimitResult; clearLimits(userId?: string): void; setDebugMode(debug: boolean): void; destroy?(): void; } export interface IArgumentSanitizer { validateArguments(tool: BaseTool, args: any, context: SecurityContext): Promise; setDebugMode(debug: boolean): void; destroy?(): void; } export interface ExtendedToolCallEvent extends BaseToolCallEvent { duration?: number; }