Skip to main content

Class: AuditLogUtils

Defined in: auth/src/auth/AuditLogUtils.ts:64

Records durable audit-log entries for a curated set of security-relevant actions (see AuthEventType in ./events.js) - a separate mechanism from, and NOT a replacement for, @rapidrest/core's EventUtils.record(). EventUtils is lossy, best-effort telemetry: with no telemetry_services:url configured and no EventUtils.on() listener registered, every event it records is silently discarded end to end - fine for telemetry, unacceptable for an audit log. This class exists because an audit log needs the opposite guarantee - durable, queryable, attributable - which a generic library class can't provide on its own without knowing the consuming app's actual persistence layer.

This base implementation only logs (via @Logger), which is still a real improvement over EventUtils's silent no-op today - visible in server logs with zero extra configuration. A consuming app that wants a real, durable, queryable audit trail (strongly recommended for production) registers a database-backed subclass under this exact class name (AuditLogUtils), so ObjectFactory resolves every @Inject(AuditLogUtils) in this library to that richer implementation instead - precisely how MessagingUtils is swapped for a database-backed implementation elsewhere in this library (see e.g. BaseSecretRoute's @Inject(MessagingUtils)), with zero code changes needed in this repo beyond declaring this class and calling record().

Constructors​

Constructor​

new AuditLogUtils(): AuditLogUtils

Returns​

AuditLogUtils

Properties​

logger​

protected logger: any

Defined in: auth/src/auth/AuditLogUtils.ts:66

Methods​

record()​

record(entry): Promise<void>

Defined in: auth/src/auth/AuditLogUtils.ts:74

Records one audit-log entry. Never throws - a logging failure here must never be allowed to propagate and fail the caller's real operation - so this wraps its own body in try/catch as a belt-and-suspenders measure, even though every call site in this library already independently guards its own call to this method too.

Parameters​

entry​

AuditLogEntry

Returns​

Promise<void>