A tour of the features
Querying
Section titled “Querying”const page = await audit.query({ tenant: "acme", actions: ["invoice.*"], // families actorId: "user_1", targetType: "invoice", from: "2026-01-01", search: "refund", limit: 50,});// { items, pageInfo: { hasNextPage, endCursor } } — keyset pagination, stable while new events arriveconst next = await audit.query({ tenant: "acme", cursor: page.pageInfo.endCursor! });The envelope is @xtandard/lib’s Paginated<T> shape, so it plugs into createPaginator and its TanStack Query helpers unchanged. Details: docs/QUERYING.md.
Tamper evidence
Section titled “Tamper evidence”Every tenant has its own hash chain: each event commits to the previous one, and the privacy-bearing sections (actor, targets, context, metadata, description) are hashed separately — so personal data can be erased without breaking the chain, and the erasure itself is recorded. Signed checkpoints (Ed25519, public key served as a JWKS) bind the chain at points in time; streaming them to the customer makes a later rewrite detectable.
import { createAuditCore, ed25519Signer } from "@xtandard/audit";
const audit = createAuditCore({ storage, signer: await ed25519Signer(JSON.parse(process.env.AUDIT_SIGNING_KEY!)),});const report = await audit.verify("acme"); // { ok, checked, anchor, signedThrough, erased, issues }Customers verify exports offline with nothing but the bundle — xtandard-audit verify --bundle acme.jsonl or the zero-dependency @xtandard/audit/verify. Details: docs/INTEGRITY.md.
The customer portal
Section titled “The customer portal”The WorkOS-style audit-log viewer, self-hosted: your customers browse, filter, export and verify their own events inside your product, scoped by a signed token — no sessions, no proxy routes.
// Your server: mint a token after your own auth (optionally narrowed by a view filter)const token = await createPortalToken(process.env.PORTAL_SECRET!, org.id, { filter: { excludeActions: ["support.*"] },});
// Your React frontend:import { AuditPortal } from "@xtandard/audit/react";import "@xtandard/audit/react/styles.css";
<AuditPortal apiBaseUrl="/audit" token={token} />;
Details: docs/PORTAL.md.
Exports and streaming
Section titled “Exports and streaming”- Exports: CSV (formula-injection safe), JSON, JSONL, and the verifiable bundle (events + checkpoints + JWKS in one file). Every export is itself audited.
- Streams:
httpSink,webhookSink(Standard Webhooks-signed),datadogSink,splunkSink,s3Sink,fileSink,consoleSink— or bridge into@xtandard/webhooksso each customer manages its own SIEM endpoints. At-least-once, per-tenant ordered, with backoff and lag shown in the admin UI.
Details: docs/STREAMING.md.
Storage backends
Section titled “Storage backends”Point it at what you already run — a four-method KV contract plus an optional native event-log capability for indexed queries (ADR 0005):
| Backend | Subpath | Event log |
|---|---|---|
| Memory | storage/memory |
native |
| Postgres | storage/postgres |
native (indexed SQL) |
| Drizzle | storage/drizzle + drizzle/{pg,mysql,sqlite} |
native, your migrations |
| SQLite (Bun) | storage/sqlite |
native |
| libSQL / Turso | storage/libsql |
native |
| MongoDB | storage/mongodb |
native |
| Redis | storage/redis |
KV index fallback |
| File | storage/file |
KV index fallback |
| unstorage | storage/unstorage |
KV index fallback |
| Cloudflare KV | storage/cloudflare-kv |
KV index fallback |
Details: docs/STORAGE.md.