Skip to content

@xtandard/audit/verify

The zero-dependency verifier for auditors and customers: re-derive every hash of an exported log, check its links, and verify the signed checkpoints, with nothing but Web Crypto (ADR 0004).

import { verifyBundle } from "@xtandard/audit/verify";
const report = await verifyBundle(await Bun.file("acme.audit.jsonl").text());
console.log(report.ok ? `verified ${report.checked} events` : report.issues);
import { … } from "@xtandard/audit/verify";

Also re-exports symbols of @xtandard/audit/schema, documented on those pages.

Name Summary
canonicalStringify Serialize a JSON value with object keys sorted lexicographically at every depth. Arrays keep their order; undefined inside objects is dropped exactly as JSON.stringify would. Throws on non-finite numbers.
ed25519VerificationKey A verification key from an Ed25519 public JWK.
hmacVerificationKey A verification key for hmacSigner checkpoints (needs the secret).
keysFromJwks Verification keys from a JWKS document (GET {basePath}/api/integrity/keys).
parseBundle Parse a bundle (JSONL text). Throws on a malformed bundle.
sha256 "sha256:" + hex(SHA-256(utf8(text))).
verifyBundle Verify a bundle offline. Keys default to the bundle’s own JWKS — pass keys (from a JWKS you obtained independently, e.g. the vendor’s published keys) to not trust the file for them.
verifyChain Verify a tenant’s events (and optionally checkpoints). Pure: it trusts nothing but the data passed in and the keys.
verifyCheckpointSignature Verify one checkpoint’s signature with a key.
verifyEvent Re-derive one event’s digests and hash; returns the issues found.
Name Summary
AuditVerificationKey A key able to verify checkpoint signatures.
BundleHeader The first line of a bundle.
ParsedBundle A parsed bundle.
VerifyChainOptions Options for verifyChain.
VerifyIssue One verification failure.
VerifyReport Result of verifyChain.
Name Summary
VerifyIssueKind Why verification failed at a given point.
Name Summary
GENESIS_HASH prevHash of the first event of every chain.