Skip to main content

AuditHistoryResponse

Package: @nauth-toolkit/client Type: Interface

Paginated response containing authentication and security audit events.

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

Properties

PropertyTypeRequiredDescription
dataAuthAuditEvent[]YesArray of audit event records
totalnumberYesTotal number of records matching query
pagenumberYesCurrent page number (1-indexed)
limitnumberYesNumber of records per page
totalPagesnumberYesTotal number of pages

Example

Fetching Audit History:

const history = await client.getAuditHistory({
page: 1,
limit: 20,
eventType: 'LOGIN_SUCCESS',
});

console.log(`Page ${history.page} of ${history.totalPages}`);
console.log(`Showing ${history.data.length} of ${history.total} events`);

history.data.forEach((event) => {
console.log(`${event.eventType} - ${event.eventStatus}`);
console.log(`IP: ${event.ipAddress}, Location: ${event.ipCity}, ${event.ipCountry}`);
console.log(`Device: ${event.deviceType} - ${event.browser}`);
});

Angular with Pagination:

this.authService
.getClient()
.getAuditHistory({
page: this.currentPage,
limit: 20,
})
.then((response) => {
this.events = response.data;
this.totalPages = response.totalPages;
this.totalRecords = response.total;
});

Filtering by Event Type:

// Get all failed login attempts
const failedLogins = await client.getAuditHistory({
eventType: 'LOGIN_FAILED',
page: 1,
limit: 50,
});

// Get suspicious activity
const suspicious = await client.getAuditHistory({
eventStatus: 'SUSPICIOUS',
page: 1,
limit: 100,
});