Audit | Node.js SDK
The audit API is designed for recording a trail of application-based user activity in a scalable, tamper-proof log.
Audit
constructor(token: string, config: PangeaConfig, tenantID: string, configID: string): AuditServiceCreates a new AuditService
with the given Pangea API token and
configuration.
const config = new PangeaConfig({ domain: "pangea_domain" });
const audit = new AuditService("pangea_token", config);
Download search results
downloadResults(request: DownloadRequest): Promise<PangeaResponse<DownloadResult>>Get all search results as a compressed (gzip) CSV file.
const response = await audit.downloadResults({
result_id: "pas_[...]",
format: Audit.DownloadFormat.CSV,
});
Log an entry
log(event: Event, options: LogOptions): Promise<PangeaResponse<LogResponse>>Create a log entry in the Secure Audit Log.
const auditData = {
action: "add_employee",
actor: user,
target: data.email,
status: "error",
message: `Resume denied - sanctioned country from ${clientIp}`,
source: "web",
};
const options = { verbose: true };
const response = await audit.log(auditData, options);
Log multiple entries
logBulk(events: Event[], options: LogOptions): Promise<PangeaResponse<LogBulkResponse>>Create multiple log entries in the Secure Audit Log.
const events = [
{ message: "hello world" },
];
const options = { verbose: true };
const response = await audit.logBulk(events, options);
Log multiple entries asynchronously
logBulkAsync(events: Event[], options: LogOptions): Promise<PangeaResponse<LogBulkResponse>>Asynchronously create multiple log entries in the Secure Audit Log.
const events = [
{ message: "hello world" },
];
const options = { verbose: true };
const response = await audit.logBulkAsync(events, options);
post(endpoint: string, data: object, options: PostOptions): Promise<PangeaResponse<R>>
POST
request.
Results of a search
results(id: string, limit: number, offset: number, options: SearchOptions): Promise<PangeaResponse<ResultResponse>>Fetch paginated results of a previously executed search.
const response = await audit.results(
"pas_sqilrhruwu54uggihqj3aie24wrctakr",
50,
100
);
Tamperproof verification
root(size: number): Promise<PangeaResponse<RootResult>>Returns current root hash and consistency proof.
const response = audit.root(7);
Search the log
search(query: string, queryOptions: SearchParamsOptions, options: SearchOptions): Promise<PangeaResponse<SearchResponse>>Search for events that match the provided search criteria.
const response = await audit.search(
"add_employee:Gumby"
);
Enum DownloadFormat
DownloadFormatCSV
= "csv"
JSON
= "json"