Storage Backends
Choose where to store audit records: memory, file, or remote API.
Sentinel supports three storage backends. Pass one to AuditConfig.storage when configuring wrapWithSentinel or AuditLogger.
MemoryStorage
In-memory storage with configurable capacity and FIFO eviction. Best for development or short-lived processes.
import { MemoryStorage } from "@valeo/x402";
const storage = new MemoryStorage(10_000); // max 10k recordsFileStorage
JSONL file-based storage — appends one record per line. Buffers writes and flushes periodically. Best for local persistence.
import { FileStorage } from "@valeo/x402";
const storage = new FileStorage(".valeo/audit.jsonl", 10);
// filePath, flushThreshold (records before flush)| Param | Type | Default | Description |
|---|---|---|---|
filePath | string | ".valeo/audit.jsonl" | Path to JSONL file |
flushThreshold | number | 100 | Records before flush to disk |
ApiStorage
Remote API storage. Batches records and POSTs to api.valeo.money. Falls back to in-memory if unreachable.
import { ApiStorage } from "@valeo/x402";
const storage = new ApiStorage({
apiKey: process.env.VALEO_API_KEY!,
baseUrl: "https://api.valeo.money",
batchSize: 50,
flushIntervalMs: 5000,
});| Param | Type | Description |
|---|---|---|
apiKey | string | Bearer token (val_xxx) |
baseUrl | string | API base URL (default: https://api.valeo.money) |
batchSize | number | Records per batch POST |
flushIntervalMs | number | Max ms before flushing buffer |