Skip to content
Customer developer docs

TypeScript SDK guide

Monitor readiness, runs, exceptions, and receipts from Node and TypeScript services with definite-ts.

TypeScript SDK

The TypeScript SDK is the definite-ts package on npm (Node 20+, zero runtime dependencies, ESM and CommonJS). It wraps the Vault REST API: readiness, report programs, runs, exceptions, and receipts.

text
npm install definite-ts

Create a client

text
import { DefiniteClient } from "definite-ts";
 
const client = new DefiniteClient({
  vaultUrl: "https://vault.example.com",
  vaultApiKey: process.env.DEFINITE_VAULT_API_KEY,
});

createVaultConfig() builds the same configuration from the environment:

FieldTypeRequiredDescription
DEFINITE_VAULT_URLstringYesVault base URL.
DEFINITE_VAULT_API_KEYstringDirect modeTenant API key, sent as X-Vault-API-Key.
DEFINITE_VAULT_AUTH_MODEdirect | proxyNoDefault direct. Proxy mode sends X-Vault-Proxy-API-Key and prefixes paths with /proxy/client/{clientId}.
DEFINITE_VAULT_PROXY_API_KEYstringProxy modeProxy key. Requires DEFINITE_CLIENT_ID.
DEFINITE_CLIENT_IDstringProxy modeTenant identifier used in proxy paths.
DEFINITE_VAULT_TIMEOUTnumberNoRequest timeout in milliseconds. Default 30000.
DEFINITE_MAX_RETRIESnumberNoRetry budget for transient failures. Default 3.

Monitor runs and read receipts

text
import { DefiniteClient } from "definite-ts";
 
// new DefiniteClient() reads DEFINITE_VAULT_URL and DEFINITE_VAULT_API_KEY
const client = new DefiniteClient();
 
const readiness = await client.getReadiness();
console.log(readiness.verdictCounts);
 
const runs = await client.listRuns({ limit: 10 });
for (const run of runs.items) {
  console.log(run.runId, run.status);
}
 
const completed = await client.waitForRun(runs.items[0].runId);
 
const receipts = await client.listReceipts({ limit: 50 });
for (const receipt of receipts.items) {
  console.log(receipt.ruleId, receipt.verdict);
}

waitForRun polls until the run reaches completed or failed, and throws RunTimeoutError if the timeout elapses first. A completed run can still contain FAIL or CANNOT_VERIFY receipts; run state and rule verdicts are separate.

Runs usually start from the console, a schedule, or a data refresh. To start one programmatically, call POST /v1/programs/{program_id}/runs over REST — the SDK's createProgramRun and listReportPrograms in 1.0.0 still target a retired endpoint path and will be repointed in the next release.

Method reference

FieldTypeRequiredDescription
getReadiness()ReadinessVerdict counts, open exceptions, and program status. Metadata, never a verdict.
listReportPrograms() / getReportProgram(id)ProgramsConfigured programs and their bound rule versions. In 1.0.0, targets a retired path — see the note above.
createProgramRun(programId, request)RunsStart an asynchronous run. In 1.0.0, targets a retired path — use REST /v1/programs/{id}/runs until the next release.
listRuns() / getRun(id) / retryRun(id)RunsInspect runs; retry creates a new child run and leaves the original immutable.
waitForRun(id, options?)RunsPoll until completed or failed.
listExceptions() / getException(id)ExceptionsFAIL and CANNOT_VERIFY findings with their investigation state.
updateException(id, request) / reviewException(id, request, actor)ExceptionsAssign, annotate, and record a human review. Reviews never change the original verdict.
listReceipts() / getReceipt(id)ReceiptsSigned, hash-chained rule receipts.

Error types: DefiniteError, VaultApiError, VaultConnectionError, RunTimeoutError, and TrustedProxyRequiredError. Payload helpers toCamelCaseKeys and toSnakeCaseKeys are exported for interop with raw REST responses.

Do not send raw source values in SDK requests. Runs bind to immutable source snapshots that Vault already holds; receipts and evidence responses carry references and hashes, not raw sensitive values.