Skip to main content

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): AuditService

Creates a new AuditService with the given Pangea API token and configuration.

required parameters

string

Pangea API token.

Configuration.

string
string

Response Object

AuditService
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.

required parameters

DownloadRequest

Request parameters.

Response Object

Promise<PangeaResponse<DownloadResult>>
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.

required parameters

Event

A structured event describing an auditable activity. Supported fields are:

  • actor (string): Record who performed the auditable activity.
  • action (string): The auditable action that occurred.
  • status (string): Record whether or not the activity was successful.
  • source (string): Used to record the location from where an activity occurred.
  • target (string): Used to record the specific record that was targeted by the auditable activity.
  • message (string|object): A message describing a detailed account of what happened. This can be recorded as free-form text or as a JSON-formatted string.
  • new (string|object): The value of a record after it was changed.
  • old (string|object): The value of a record before it was changed.
  • tenant_id (string): Used to record the tenant associated with this activity.
LogOptions

Log options. The following log options are supported:

  • verbose (bool): Return a verbose response, including the canonical event hash and received_at time.

Response Object

Promise<PangeaResponse<LogResponse>>
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.

required parameters

Array<Event>
LogOptions

Response Object

Promise<PangeaResponse<LogBulkResponse>>
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.

required parameters

Array<Event>
LogOptions

Response Object

Promise<PangeaResponse<LogBulkResponse>>
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.

required parameters

string

Endpoint path.

object

Request body.

Additional options.

Response Object

Promise<PangeaResponse<R>>
results(id: string, limit: number, offset: number, options: SearchOptions): Promise<PangeaResponse<ResultResponse>>

Fetch paginated results of a previously executed search.

required parameters

string

The id of a successful search

number

(default 20) - The number of results returned

number

(default 0) - The starting position of the first returned result

Response Object

Promise<PangeaResponse<ResultResponse>>
const response = await audit.results(
  "pas_sqilrhruwu54uggihqj3aie24wrctakr",
  50,
  100
);

Tamperproof verification

root(size: number): Promise<PangeaResponse<RootResult>>

Returns current root hash and consistency proof.

required parameters

number

The size of the tree (the number of records)

Response Object

Promise<PangeaResponse<RootResult>>
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.

required parameters

string

Natural search string; list of keywords with optional <option>:<value> qualifiers. The following optional qualifiers are supported:

  • action:
  • actor:
  • message:
  • new:
  • old:
  • status:
  • target:

Search options. The following search options are supported:

  • limit (number): Maximum number of records to return per page.
  • start (string): The start of the time range to perform the search on.
  • end (string): The end of the time range to perform the search on. All records up to the latest if left out.
  • sources (array): A list of sources that the search can apply to. If empty or not provided, matches only the default source.

Response Object

Promise<PangeaResponse<SearchResponse>>
const response = await audit.search(
  "add_employee:Gumby"
);

Enum DownloadFormat

DownloadFormat

CSV = "csv"

JSON = "json"

Interface AuditRecord

AuditRecord

required parameters

EventEnvelope
string

optional parameters

string
string
string
string
boolean
string

Interface DownloadRequest

DownloadRequest

required parameters

string

ID returned by the search API.

optional parameters

Format for the records.

Interface DownloadResult

DownloadResult

required parameters

string

URL where search results can be downloaded.

Interface Event

Event

Interface EventEnvelope

EventEnvelope

required parameters

Event
string

optional parameters

string
string

Interface LogBulkRequest

LogBulkRequest

required parameters

Array<LogEvent>

optional parameters

boolean

Interface LogBulkResponse

LogBulkResponse

required parameters

Array<LogResponse>

Interface LogData

LogData

required parameters

Event

optional parameters

string
string
string
boolean

Interface LogEvent

LogEvent

required parameters

Event

optional parameters

string
string

Interface LogOptions

LogOptions

optional parameters

Object
Signer
boolean
boolean
boolean

Interface LogRequestCommon

LogRequestCommon

optional parameters

boolean

Interface LogResponse

LogResponse

required parameters

EventEnvelope
string

optional parameters

Array<string>
string
string
string
string
string

Interface ResultResponse

ResultResponse

required parameters

number

optional parameters

Root

Interface Root

Root

required parameters

Array<string>
string
number
string

optional parameters

string
string

Interface RootParams

RootParams

optional parameters

number

Interface RootRequest

RootRequest

optional parameters

number

Interface RootResult

RootResult

required parameters

Array<string>
Root
string
number
string

optional parameters

string
string

Interface SearchOptions

SearchOptions

optional parameters

boolean
boolean

Interface SearchParams

SearchParams

required parameters

string

optional parameters

string
number
number
string
string
SearchRestriction
string
boolean

Interface SearchParamsOptions

SearchParamsOptions

optional parameters

string
number
number
string
string
SearchRestriction
string
boolean

Interface SearchResponse

SearchResponse

required parameters

number
string
string

optional parameters

Root
Root

Interface SearchRestriction

SearchRestriction

optional parameters

Array<string>
Array<string>
Array<string>
Array<string>
Array<string>