/** * Audit Service * * Manages audit logging for ABAC engine access decisions. * Maintains a history of access requests and their outcomes for compliance and security monitoring. */ import { ABACAccessLog, ABACDecision, ABACRequest, Decision } from '../types'; /** * Configuration options for the audit service */ export interface AuditServiceConfig { /** * Enable audit logging * @default true */ enabled?: boolean; /** * Maximum number of audit logs to keep in memory * @default 10000 */ maxLogs?: number; /** * Optional callback for custom audit log handling */ onLog?: (log: ABACAccessLog) => void | Promise; } /** * Service for managing audit logs */ export declare class AuditService { private logs; private enabled; private maxLogs; private onLog; constructor(config?: AuditServiceConfig); /** * Log an access decision * * @param requestId - Unique request identifier * @param request - The access request * @param decision - The decision result * @param evaluationTime - Time taken to evaluate (in milliseconds) * @param errors - Any errors that occurred during evaluation */ log(requestId: string, request: ABACRequest, decision: ABACDecision, evaluationTime: number, errors?: string[]): Promise; /** * Get audit logs * * @param limit - Maximum number of logs to return (most recent first) * @returns Array of audit logs */ getLogs(limit?: number): ABACAccessLog[]; /** * Clear all audit logs */ clear(): void; /** * Get the total number of audit logs * * @returns Number of logs stored */ getCount(): number; /** * Enable audit logging */ enable(): void; /** * Disable audit logging */ disable(): void; /** * Check if audit logging is enabled * * @returns true if enabled, false otherwise */ isEnabled(): boolean; /** * Get logs for a specific subject * * @param subjectId - Subject identifier * @returns Array of audit logs for the subject */ getLogsBySubject(subjectId: string): ABACAccessLog[]; /** * Get logs for a specific resource * * @param resourceId - Resource identifier * @returns Array of audit logs for the resource */ getLogsByResource(resourceId: string): ABACAccessLog[]; /** * Get logs by decision type * * @param decision - Decision type to filter by * @returns Array of audit logs with the specified decision */ getLogsByDecision(decision: Decision): ABACAccessLog[]; /** * Get logs within a time range * * @param startTime - Start of time range * @param endTime - End of time range * @returns Array of audit logs within the time range */ getLogsByTimeRange(startTime: Date, endTime: Date): ABACAccessLog[]; /** * Get logs that resulted in errors * * @returns Array of audit logs with errors */ getErrorLogs(): ABACAccessLog[]; /** * Get statistics about audit logs * * @returns Statistics object */ getStatistics(): { total: number; byDecision: Record; withErrors: number; averageEvaluationTime: number; }; /** * Export logs as JSON * * @returns JSON string of all logs */ exportLogs(): string; /** * Import logs from JSON * * @param json - JSON string of logs */ importLogs(json: string): void; } //# sourceMappingURL=AuditService.d.ts.map