Skip to main content

AuthAuditEvent

Package: @nauth-toolkit/client Type: Interface

Individual authentication or security audit event record.

import { AuthAuditEvent } from '@nauth-toolkit/client';

Properties

PropertyTypeRequiredDescription
idnumberYesUnique event identifier
userIdnumberYesUser ID associated with event
eventTypeAuthAuditEventTypeYesType of event
eventStatusAuthAuditEventStatusYesEvent status
riskFactornumber | nullNoRisk score (0-100)
riskFactorsstring[] | nullNoArray of risk factor identifiers
adaptiveMfaTriggeredboolean | nullNoWhether adaptive MFA was triggered
ipAddressstring | nullNoIP address of request
ipCountrystring | nullNoCountry from IP geolocation
ipCitystring | nullNoCity from IP geolocation
userAgentstring | nullNoFull user agent string
platformstring | nullNoPlatform (Windows, macOS, Linux, etc.)
browserstring | nullNoBrowser name and version
deviceIdstring | nullNoDevice identifier
deviceNamestring | nullNoDevice name
deviceTypestring | nullNoDevice type (desktop, mobile, tablet)
sessionIdnumber | nullNoAssociated session ID
challengeSessionIdnumber | nullNoAssociated challenge session ID
authMethodstring | nullNoAuthentication method used
performedBystring | nullNoWho performed the action
reasonstring | nullNoReason for the action
descriptionstring | nullNoAdditional description
metadataRecord<string, unknown> | nullNoAdditional metadata
createdAtstring | DateYesEvent timestamp

Example

Displaying Event Details:

function displayAuditEvent(event: AuthAuditEvent) {
console.log(`Event #${event.id}`);
console.log(`Type: ${event.eventType}`);
console.log(`Status: ${event.eventStatus}`);
console.log(`Time: ${new Date(event.createdAt).toLocaleString()}`);

if (event.ipAddress) {
console.log(`Location: ${event.ipCity}, ${event.ipCountry} (${event.ipAddress})`);
}

if (event.deviceType) {
console.log(`Device: ${event.deviceType} - ${event.browser} on ${event.platform}`);
}

if (event.riskFactor) {
console.log(`Risk Score: ${event.riskFactor}/100`);
if (event.riskFactors) {
console.log(`Risk Factors: ${event.riskFactors.join(', ')}`);
}
}

if (event.adaptiveMfaTriggered) {
console.log('Adaptive MFA was triggered for this event');
}
}

Angular (20+) Example:

// audit-log.component.ts
import { Component, computed, input } from '@angular/core';
import { AuthAuditEvent } from './auth-audit-event';

@Component({
selector: 'app-audit-log',
templateUrl: './audit-log.component.html',
})
export class AuditLogComponent {
// New input API (Angular 16+) - works great with signals-based templates.
readonly auditEvents = input.required<AuthAuditEvent[]>();

// Signals-friendly derived state
readonly hasEvents = computed(() => (this.auditEvents()?.length ?? 0) > 0);
}
<!-- audit-log.component.html -->
@if (!hasEvents()) {
<p>No audit events.</p>
} @else {
@for (event of auditEvents(); track event.id) {
<div class="audit-event">
<div class="event-header">
<span class="event-type">{{ event.eventType }}</span>
<span [class]="'event-status-' + event.eventStatus">
{{ event.eventStatus }}
</span>
</div>

<div class="event-details">
<p>{{ event.createdAt | date:'medium' }}</p>

@if (event.ipAddress) {
<p>
Location: {{ event.ipCity }}, {{ event.ipCountry }} ({{ event.ipAddress }})
</p>
}

@if (event.deviceType) {
<p>Device: {{ event.browser }} on {{ event.platform }}</p>
}

@if (event.riskFactor) {
<p class="risk-indicator">Risk Score: {{ event.riskFactor }}/100</p>
}
</div>
</div>
}
}

Used By