Part of the API reference for the Consent Ledger LiveKit reference integration.
Functions exported from consent-ledger-livekit. Every function validates its input and throws on bad input instead of guessing. The consent client's methods are asynchronous, except subscribe().
Functions
Function | Returns | Use it to |
|
| Create the consent client your backend calls |
|
| Talk to Consent Ledger's HTTP API |
|
| Connect the consent client to Consent Ledger, with read-back |
|
| Turn a decision into a Consent Ledger record |
|
| Read the decision a receipt describes, wherever the mapping stores it |
|
| The identifier written into every new record |
|
| Keep current decisions in memory (the default; tests and trials only) |
|
| Check one current decision without a store read |
|
| Get why one current decision blocks recording |
createConsentClient(options)
const consent = createConsentClient({
ledger, // required: a ConsentLedgerAdapter
store, // optional: a ConsentStateStore; in memory if omitted
confirmationTimeoutMs: 5_000, // optional: how long submitDecision waits for Consent Ledger (1 to 60,000 ms)
});The ConsentClient it returns:
Method | Returns | What it does |
|
| Saves the decision as current, sends it to Consent Ledger once, and waits up to |
|
| The participant's current decision for this meeting and purpose, with its receipt status. |
|
| Reads a |
|
| Whether every participant in the supplied |
|
| Ends a meeting: deletes its current decisions. The PostgreSQL store keeps the receipt references. |
|
| Calls |
scope is { sessionId, participantId, purposeId }. request is { sessionId, purposeId, participantIds } with 1 to 10,000 IDs. See Types and errors for ConsentDecision, ConsentSubmission and ConsentPermission.
createHttpLedgerClient(options)
const ledgerClient = createHttpLedgerClient({
baseUrl: 'https://api.enzuzo.com', // the Consent Ledger API base URL
ledgerId, // the ledger's UUID
readToken, // a token with ledger:read; used only for reads
timeoutMs: 2_000, // per request
fetchImpl, // optional: a fetch function, for tests or proxies
});
await ledgerClient.readRecord(recordId); // { status: 'found', record } or { status: 'not-found' }
await ledgerClient.writeRecord(payload); // { status: 'accepted', recordId } | 'rejected' | 'unknown'baseUrl is the API base URL from the Consent Ledger Quickstart Guide. It must use HTTPS (HTTP only for localhost) and have no credentials, query, or fragment.
You rarely call it directly: pass it to createLedgerConsentAdapter. It throws LedgerHttpError with a code (unauthorized, forbidden, timeout, network, rate-limited, and others) for reads that fail.
createLedgerConsentAdapter(options)
const ledger = createLedgerConsentAdapter({
client: ledgerClient, // required
mapping: proposedLedgerMapping(), // required: decision to Consent Ledger record
readBackIntervalMs: 100, // optional: first read-back delay, doubling up to 1 s
});Writes each decision once and reads it back until the stored record matches exactly. The outcome becomes the receipt status: confirmed, pending (accepted but not readable yet, with its record ID), failed (rejected, or a different record stored), or unknown (the write's outcome is uncertain). A write Consent Ledger accepted (HTTP 202) is not a confirmed receipt and never permits recording by itself.
proposedLedgerMapping(options?)
Turns a decision into a Consent Ledger record. Acceptances are stored with the analytics category; declines and withdrawals with no categories. The original choice, purpose, session, revision, notice version, and participant are kept in the record. The field names and locations are provisional, so read them with readReceiptFields rather than from fixed paths. See the LiveKit receipt reference for an example record.
readReceiptFields(record)
const read = await ledgerClient.readRecord(recordId);
if (read.status === 'found') {
const fields = readReceiptFields(read.record);
// { integrationId, submissionId, sessionId, participantId, purposeId, choice, revision, noticeVersion },
// or undefined if the record was not written by this mapping or a field is missing
}It describes the record only. Recording permission comes from the participant's current decision in your database, never from a receipt.
