UNPKG

@thomkjel/logger

Version:

Security-focused event logging library for Next.js applications (Work in Progress)

109 lines (108 loc) 2.94 kB
export type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'CRITICAL'; export type Environment = 'development' | 'staging' | 'production'; export type EventCategory = 'AUTHN' | 'AUTHZ' | 'SESSION' | 'UPLOAD' | 'INPUT' | 'MALICIOUS' | 'PRIVILEGE' | 'DATA' | 'SEQUENCE' | 'SYS' | 'USER' | 'EXCESS' | 'GENERAL'; export interface LogMetadata { userid?: string; tokenid?: string; appid?: string; newuserid?: string; onuserid?: string; resource?: string; reason?: string; retries?: number; maxlimit?: number; entitlement?: string; attributes?: string; region1?: string; region2?: string; from?: string; to?: string; event?: string; [key: string]: any; } export interface LogData { dt: string; level: string; event: string; category: EventCategory; message: string; context: { environment: Environment; [key: string]: any; }; } export interface LoggerConfig { environment?: Environment; sourceToken?: string; betterStackEndpoint?: string; apiKey?: string; rateLimitPerMinute?: number; enableMetrics?: boolean; } export interface UsageMetrics { totalLogs: number; logsByLevel: Record<LogLevel, number>; logsByCategory: Record<EventCategory, number>; lastLogTimestamp: string; apiKeyUsage?: Record<string, number>; } export interface ComplianceConfig { owaspAlertsEnabled?: boolean; iso27001Mode?: boolean; vantaIntegration?: boolean; auditReportsEnabled?: boolean; alertWebhooks?: string[]; } export interface UserInsightConfig { aiAnalysisEnabled?: boolean; journeyTrackingEnabled?: boolean; behaviorAnalysisEnabled?: boolean; mcpServerEnabled?: boolean; } export interface AIQueryConfig { naturalLanguageEnabled?: boolean; mcpServerUrl?: string; aiProvider?: 'claude' | 'openai' | 'custom'; maxQueryHistory?: number; } export interface ComplianceAlert { id: string; timestamp: string; type: 'OWASP' | 'ISO27001' | 'CUSTOM'; severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; rule: string; description: string; evidenceLogIds: string[]; status: 'ACTIVE' | 'RESOLVED' | 'INVESTIGATING'; } export interface UserJourney { userId: string; sessionId: string; startTime: string; endTime?: string; events: SecurityEvent[]; riskScore: number; anomalies: string[]; } export interface AIInsight { id: string; timestamp: string; query: string; response: string; confidence: number; dataPoints: number; category: 'SECURITY' | 'COMPLIANCE' | 'USER_BEHAVIOR' | 'THREAT_ANALYSIS'; } export interface SecurityEvent { id: string; timestamp: string; type: string; level: LogLevel; message: string; data: LogMetadata; appName?: string; environment?: string; complianceFlags?: string[]; owaspCategory?: string; riskScore?: number; }