Skip to content

createWebhookAuditLog

function createWebhookAuditLog(options: CreateWebhookAuditLogOptions): MftAuditLog;

Defined in: src/mft/webhooks.ts:191

Wraps a webhook target as an MftAuditLog.

Entries whose type is not in target.types are silently dropped. list() always returns an empty array because webhook deliveries are not buffered. Payloads are HMAC-signed with target.secret (when provided) so receivers can verify authenticity before acting on them.

ParameterTypeDescription
optionsCreateWebhookAuditLogOptionsWebhook target plus optional retry/observer hooks.

MftAuditLog

An audit log that delivers each record call to the webhook.

import {
InMemoryAuditLog,
composeAuditLogs,
createWebhookAuditLog,
} from "@zero-transfer/sdk";
const memory = new InMemoryAuditLog();
const webhook = createWebhookAuditLog({
target: {
url: "https://hooks.example.com/zt",
secret: { env: "ZT_WEBHOOK_SECRET" },
types: ["transfer.success", "transfer.failure"],
},
onDelivery: ({ result }) => console.log("delivered", result.statusCode),
});
const audit = composeAuditLogs(memory, webhook);
await audit.record({ type: "transfer.success", receipt });