@pulzar/core
Version:
Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support
57 lines • 1.85 kB
TypeScript
import { EventEmitter } from "events";
import { AuthEvent, AuthAuditLog } from "../types";
export interface AuthEventContext {
traceId?: string;
requestId?: string;
userAgent?: string;
ipAddress?: string;
}
export declare class AuthEventEmitter extends EventEmitter {
private auditLog;
private maxLogSize;
constructor(maxLogSize?: number);
/**
* Setup default event listeners for logging
*/
private setupDefaultListeners;
/**
* Emit auth event with automatic audit logging
*/
emitAuthEvent(type: AuthEvent["type"], data: Omit<AuthEvent, "type" | "timestamp">, context?: AuthEventContext): void;
/**
* Add event to audit log with size management
*/
private addToAuditLog;
/**
* Get audit log entries
*/
getAuditLog(filters?: {
userId?: string;
type?: AuthEvent["type"];
success?: boolean;
since?: Date;
limit?: number;
}): AuthAuditLog[];
/**
* Get auth statistics
*/
getStats(): {
totalEvents: number;
eventsByType: Record<string, number>;
successRate: number;
recentFailures: number;
};
/**
* Clear audit log
*/
clearAuditLog(): void;
/**
* Export audit log as JSON
*/
exportAuditLog(): string;
}
export declare const authEvents: AuthEventEmitter;
export declare function emitLoginEvent(userId: string, success: boolean, context?: AuthEventContext, error?: string, metadata?: Record<string, unknown>): void;
export declare function emitLogoutEvent(userId: string, sessionId?: string, context?: AuthEventContext): void;
export declare function emitSecurityViolation(userId: string, violationType: string, context?: AuthEventContext, metadata?: Record<string, unknown>): void;
//# sourceMappingURL=auth-events.d.ts.map