Part of the API reference for the Consent Ledger LiveKit reference integration.
Functions exported from consent-ledger-livekit/livekit. They create join tokens and start and stop recordings according to consent.
Functions
Function | Returns | Use it to |
|
| Give an authenticated participant a join token |
|
| Start and stop recordings according to consent |
|
| Get the bucket key of a finished recording |
|
| Keep recording jobs in memory (tests and trials only) |
createRoomToken(config, identity, options?)
const token = await createRoomToken(
{ apiKey, apiSecret, room }, // room = the consent sessionId
participantId, // identity = the consent participantId
{ name: 'Zoë Ng' }, // optional display name, up to 100 characters
);The token lasts 5 minutes, joins only that room, and may publish only microphone and camera. It grants no data messages, room admin, or recording rights. Authenticate the person and check they belong in the room before you call it.
createRecordingController(options)
Option | Required | Meaning |
| Yes | The |
| Yes | LiveKit's |
| Yes | The consent purpose this controller records for. Use one purpose per room. |
| Yes |
|
| Production | A |
| Production | A |
| No | Called with the result of each sync a consent change starts, for logging or metrics |
| No |
|
| No | Passed to LiveKit's |
| No | How long an uncertain start may take to show up in LiveKit (default 120,000 ms). Shorten only in tests. |
The controller it returns:
Method | Returns | What it does |
|
| Checks one participant: stops their recording if not permitted, starts one if permitted and nothing records them. |
|
| Handles a LiveKit webhook whose signature |
|
| Finishes work a restart or missed event left behind. Run at startup and every minute. Returns |
|
| Stops listening to consent changes. Call on shutdown. |
Recording results
A RecordingSyncResult has room, participantId, permitted, and an action:
| Meaning |
| LiveKit accepted the start and reports a starting or active recording ( |
| LiveKit's answer was lost; it may be recording ( |
| LiveKit accepted the stop and is still finishing the file ( |
| Every affected recording has finished ( |
| Nothing to do ( |
| Could not start or stop ( |
recordingFile(job)
Returns the bucket key of a complete recording (the file LiveKit reported, else the requested path), or undefined for one that did not finish. It does not check who may see the file.
