@molecule/api-video-rooms-livekit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=browser-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-guard.d.ts","sourceRoot":"","sources":["../src/browser-guard.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Browser guard — `@molecule/api-video-rooms-livekit` is SERVER-ONLY.
3
+ *
4
+ * Generated by scripts/gen-browser-guards.mjs (workspace root) — edit THAT, not this.
5
+ * Evaluating a server package in a browser bundle is always an import-graph mistake
6
+ * (node APIs, secrets); without this guard it surfaces as a cryptic downstream crash
7
+ * ("Buffer is not defined") far from the culprit. Throwing here names the package and
8
+ * the fix at the exact moment the client bundle evaluates it. jsdom tests and SSR are
9
+ * unaffected: the throw requires browser globals AND the absence of a node runtime.
10
+ */
11
+ const g = globalThis;
12
+ if (g.window !== undefined && g.document !== undefined && !g.process?.versions?.node) {
13
+ throw new Error('@molecule/api-video-rooms-livekit is SERVER-ONLY: it was bundled into browser/client code. Import it only ' +
14
+ 'from server code (a server route/function or your API), or dynamic-import it inside ' +
15
+ 'the server handler — never from components or shared client modules, and never ' +
16
+ 'polyfill Buffer/process to silence this.');
17
+ }
18
+ export {};
@@ -0,0 +1,63 @@
1
+ /**
2
+ * LiveKit video rooms provider for molecule.dev.
3
+ *
4
+ * Implements the `@molecule/api-video-rooms` interface against the
5
+ * LiveKit Server API (Twirp transport) and the `livekit-server-sdk`
6
+ * `AccessToken` HS256 JWT signer. Self-hostable + LiveKit Cloud — the
7
+ * recommended provider for users who need to keep media on their own
8
+ * infrastructure.
9
+ *
10
+ * @remarks
11
+ * - **LiveKit rooms are always token-gated — there is no `public` mode.**
12
+ * Every join needs a token from `createMeetingToken()`, and the returned
13
+ * `Room.url` is the server's `wss://` endpoint (not a click-to-join link).
14
+ * A `private` room is therefore LiveKit's native, enforced behaviour and is
15
+ * reported truthfully. Requesting `createRoom({ privacy: 'public' })`
16
+ * **throws** — this bond will not return a room falsely labelled `public`.
17
+ * - **`recording: true` requires a configured egress output.** LiveKit
18
+ * records via Egress, which needs a storage destination (S3 / GCP / Azure /
19
+ * AliOSS file output, or a stream/segment output) — a destination the core
20
+ * `recording` flag does not carry. Supply it via `config.recordingEgress`
21
+ * (a LiveKit `RoomEgress`, or a `(roomName) => RoomEgress` factory); the
22
+ * bond attaches it to the room so LiveKit auto-starts a room-composite
23
+ * egress once the room is active. `createRoom({ recording: true })`
24
+ * **throws** when `recordingEgress` is not configured — it never returns a
25
+ * room that silently isn't recording.
26
+ * - `listRecordings()` reflects the real LiveKit Egress state (it calls
27
+ * `EgressClient.listEgress`): an empty result means no egress ran, not a
28
+ * swallowed failure.
29
+ * - `expiresAt` on `createRoom` maps to LiveKit's `emptyTimeout` (how long
30
+ * an empty room survives), not an absolute expiry.
31
+ * - All meeting tokens grant `canPublish` + `canSubscribe`; `isOwner` adds
32
+ * `roomAdmin` — there is no subscribe-only token option in this revision.
33
+ * - `createProvider()` throws at bond time when LIVEKIT_URL /
34
+ * LIVEKIT_API_KEY / LIVEKIT_API_SECRET are unset.
35
+ *
36
+ * @module
37
+ * @example
38
+ * ```typescript
39
+ * import { setProvider } from '@molecule/api-video-rooms'
40
+ * import { createProvider } from '@molecule/api-video-rooms-livekit'
41
+ *
42
+ * // Bond at startup (reads LIVEKIT_URL / LIVEKIT_API_KEY /
43
+ * // LIVEKIT_API_SECRET by default)
44
+ * setProvider(createProvider())
45
+ *
46
+ * // Explicit config. For real cloud recording, also pass `recordingEgress` — a
47
+ * // LiveKit `RoomEgress` (built with RoomCompositeEgressRequest + EncodedFileOutput
48
+ * // + your S3/GCP/Azure upload), or a `(roomName) => RoomEgress` factory; see the
49
+ * // `recordingEgress` docs in @remarks. With it, `createRoom({ recording: true })`
50
+ * // starts a real room-composite egress; WITHOUT it, that call throws rather than
51
+ * // silently not recording.
52
+ * setProvider(createProvider({
53
+ * host: 'https://livekit.example.com',
54
+ * apiKey: 'APIxxx',
55
+ * apiSecret: 'secretxxx',
56
+ * }))
57
+ * ```
58
+ */
59
+ export * from './browser-guard.js';
60
+ export * from './provider.js';
61
+ export * from './secrets.js';
62
+ export * from './types.js';
63
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * LiveKit video rooms provider for molecule.dev.
3
+ *
4
+ * Implements the `@molecule/api-video-rooms` interface against the
5
+ * LiveKit Server API (Twirp transport) and the `livekit-server-sdk`
6
+ * `AccessToken` HS256 JWT signer. Self-hostable + LiveKit Cloud — the
7
+ * recommended provider for users who need to keep media on their own
8
+ * infrastructure.
9
+ *
10
+ * @remarks
11
+ * - **LiveKit rooms are always token-gated — there is no `public` mode.**
12
+ * Every join needs a token from `createMeetingToken()`, and the returned
13
+ * `Room.url` is the server's `wss://` endpoint (not a click-to-join link).
14
+ * A `private` room is therefore LiveKit's native, enforced behaviour and is
15
+ * reported truthfully. Requesting `createRoom({ privacy: 'public' })`
16
+ * **throws** — this bond will not return a room falsely labelled `public`.
17
+ * - **`recording: true` requires a configured egress output.** LiveKit
18
+ * records via Egress, which needs a storage destination (S3 / GCP / Azure /
19
+ * AliOSS file output, or a stream/segment output) — a destination the core
20
+ * `recording` flag does not carry. Supply it via `config.recordingEgress`
21
+ * (a LiveKit `RoomEgress`, or a `(roomName) => RoomEgress` factory); the
22
+ * bond attaches it to the room so LiveKit auto-starts a room-composite
23
+ * egress once the room is active. `createRoom({ recording: true })`
24
+ * **throws** when `recordingEgress` is not configured — it never returns a
25
+ * room that silently isn't recording.
26
+ * - `listRecordings()` reflects the real LiveKit Egress state (it calls
27
+ * `EgressClient.listEgress`): an empty result means no egress ran, not a
28
+ * swallowed failure.
29
+ * - `expiresAt` on `createRoom` maps to LiveKit's `emptyTimeout` (how long
30
+ * an empty room survives), not an absolute expiry.
31
+ * - All meeting tokens grant `canPublish` + `canSubscribe`; `isOwner` adds
32
+ * `roomAdmin` — there is no subscribe-only token option in this revision.
33
+ * - `createProvider()` throws at bond time when LIVEKIT_URL /
34
+ * LIVEKIT_API_KEY / LIVEKIT_API_SECRET are unset.
35
+ *
36
+ * @module
37
+ * @example
38
+ * ```typescript
39
+ * import { setProvider } from '@molecule/api-video-rooms'
40
+ * import { createProvider } from '@molecule/api-video-rooms-livekit'
41
+ *
42
+ * // Bond at startup (reads LIVEKIT_URL / LIVEKIT_API_KEY /
43
+ * // LIVEKIT_API_SECRET by default)
44
+ * setProvider(createProvider())
45
+ *
46
+ * // Explicit config. For real cloud recording, also pass `recordingEgress` — a
47
+ * // LiveKit `RoomEgress` (built with RoomCompositeEgressRequest + EncodedFileOutput
48
+ * // + your S3/GCP/Azure upload), or a `(roomName) => RoomEgress` factory; see the
49
+ * // `recordingEgress` docs in @remarks. With it, `createRoom({ recording: true })`
50
+ * // starts a real room-composite egress; WITHOUT it, that call throws rather than
51
+ * // silently not recording.
52
+ * setProvider(createProvider({
53
+ * host: 'https://livekit.example.com',
54
+ * apiKey: 'APIxxx',
55
+ * apiSecret: 'secretxxx',
56
+ * }))
57
+ * ```
58
+ */
59
+ export * from './browser-guard.js';
60
+ export * from './provider.js';
61
+ export * from './secrets.js';
62
+ export * from './types.js';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * LiveKit implementation of the molecule {@link VideoRoomsProvider} interface.
3
+ *
4
+ * Wraps the LiveKit Server API (Twirp transport — `RoomServiceClient` and
5
+ * `EgressClient` from `livekit-server-sdk`) and the `AccessToken` JWT
6
+ * signer to provide room lifecycle, signed meeting tokens (HS256), and
7
+ * egress (cloud recording) listing conforming to
8
+ * `@molecule/api-video-rooms`.
9
+ *
10
+ * LiveKit is self-hostable (alongside LiveKit Cloud), making this the
11
+ * recommended provider whenever operators need to keep media on their
12
+ * own infrastructure.
13
+ *
14
+ * @module
15
+ */
16
+ import './secrets.js';
17
+ import type { VideoRoomsProvider } from '@molecule/api-video-rooms';
18
+ import type { LiveKitVideoRoomsConfig } from './types.js';
19
+ /**
20
+ * Creates a LiveKit-backed {@link VideoRoomsProvider}.
21
+ *
22
+ * Self-hostable: pass a `host` of e.g. `https://livekit.example.com` or
23
+ * set `LIVEKIT_URL` to the same value (or a `wss://` URL — the provider
24
+ * rewrites the protocol for the HTTP/Twirp endpoints).
25
+ *
26
+ * The API secret is **never** included in any error thrown by this
27
+ * provider — both the missing-secret error and SDK-error wrappers
28
+ * scrub it out.
29
+ *
30
+ * @param config - LiveKit provider configuration. Falls back to the
31
+ * `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET` env vars
32
+ * when the corresponding fields are omitted.
33
+ * @returns A fully initialised `VideoRoomsProvider` backed by LiveKit.
34
+ * @throws {Error} If host, API key, or API secret cannot be resolved.
35
+ */
36
+ export declare function createProvider(config?: LiveKitVideoRoomsConfig): VideoRoomsProvider;
37
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,cAAc,CAAA;AASrB,OAAO,KAAK,EAMV,kBAAkB,EACnB,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAMV,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAyKnB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,uBAA4B,GAAG,kBAAkB,CAgPvF"}
@@ -0,0 +1,418 @@
1
+ /**
2
+ * LiveKit implementation of the molecule {@link VideoRoomsProvider} interface.
3
+ *
4
+ * Wraps the LiveKit Server API (Twirp transport — `RoomServiceClient` and
5
+ * `EgressClient` from `livekit-server-sdk`) and the `AccessToken` JWT
6
+ * signer to provide room lifecycle, signed meeting tokens (HS256), and
7
+ * egress (cloud recording) listing conforming to
8
+ * `@molecule/api-video-rooms`.
9
+ *
10
+ * LiveKit is self-hostable (alongside LiveKit Cloud), making this the
11
+ * recommended provider whenever operators need to keep media on their
12
+ * own infrastructure.
13
+ *
14
+ * @module
15
+ */
16
+ // Side-effect import: registers this bond's secret definitions so the
17
+ // runtime registry is populated even when provider.js is imported directly
18
+ // (not through the package barrel).
19
+ import './secrets.js';
20
+ import { AccessToken, EgressClient, EgressStatus, RoomServiceClient, } from 'livekit-server-sdk';
21
+ const DEFAULT_TOKEN_TTL_SECONDS = 6 * 60 * 60;
22
+ /**
23
+ * Coerces a LiveKit timestamp (which may be `bigint`, `number`, or
24
+ * `undefined`) into milliseconds suitable for `new Date(ms)`.
25
+ *
26
+ * LiveKit reports unix-seconds (sometimes as `bigint` because the proto
27
+ * field is `int64`). Treats `0` as "unset" since the proto default is 0.
28
+ *
29
+ * @param value - The raw timestamp value.
30
+ * @returns The timestamp in milliseconds, or `undefined` if unset.
31
+ */
32
+ function toMillis(value) {
33
+ if (value === undefined)
34
+ return undefined;
35
+ const numeric = typeof value === 'bigint' ? Number(value) : value;
36
+ if (!Number.isFinite(numeric) || numeric === 0)
37
+ return undefined;
38
+ return numeric * 1000;
39
+ }
40
+ /**
41
+ * Coerces a LiveKit duration (`bigint` | `number` | `undefined`) into a
42
+ * plain number of seconds. The LiveKit `FileInfo.duration` field is in
43
+ * nanoseconds, but the molecule contract reports seconds — divide by
44
+ * `1e9` when present.
45
+ *
46
+ * @param value - The raw duration in nanoseconds.
47
+ * @returns Duration in seconds, or `undefined` if unset.
48
+ */
49
+ function toSeconds(value) {
50
+ if (value === undefined)
51
+ return undefined;
52
+ const numeric = typeof value === 'bigint' ? Number(value) : value;
53
+ if (!Number.isFinite(numeric) || numeric === 0)
54
+ return undefined;
55
+ return numeric / 1e9;
56
+ }
57
+ /**
58
+ * Maps a LiveKit `Room` payload onto the normalised molecule {@link Room}.
59
+ *
60
+ * @param data - LiveKit room payload (as returned by `RoomServiceClient`).
61
+ * @param wsUrl - The LiveKit websocket URL to expose as the joinable URL.
62
+ * @returns Normalised molecule room.
63
+ */
64
+ function mapRoom(data, wsUrl) {
65
+ const room = {
66
+ name: data.name,
67
+ url: wsUrl,
68
+ };
69
+ if (typeof data.maxParticipants === 'number' && data.maxParticipants > 0) {
70
+ room.maxParticipants = data.maxParticipants;
71
+ }
72
+ if (typeof data.activeRecording === 'boolean') {
73
+ room.recording = data.activeRecording;
74
+ }
75
+ return room;
76
+ }
77
+ /**
78
+ * Normalises a LiveKit `EgressStatus` enum value onto the molecule
79
+ * {@link Recording.status} enum.
80
+ *
81
+ * @param status - Numeric LiveKit `EgressStatus` value.
82
+ * @returns Normalised molecule recording status.
83
+ */
84
+ function mapRecordingStatus(status) {
85
+ switch (status) {
86
+ case EgressStatus.EGRESS_STARTING:
87
+ case EgressStatus.EGRESS_ACTIVE:
88
+ case EgressStatus.EGRESS_ENDING:
89
+ return 'processing';
90
+ case EgressStatus.EGRESS_COMPLETE:
91
+ return 'ready';
92
+ case EgressStatus.EGRESS_FAILED:
93
+ case EgressStatus.EGRESS_ABORTED:
94
+ case EgressStatus.EGRESS_LIMIT_REACHED:
95
+ return 'failed';
96
+ default:
97
+ return 'processing';
98
+ }
99
+ }
100
+ /**
101
+ * Maps a LiveKit egress payload onto the normalised molecule
102
+ * {@link Recording}. The first entry of `fileResults` is treated as the
103
+ * canonical download — egress jobs may produce multiple files but
104
+ * molecule reports the primary one.
105
+ *
106
+ * @param data - LiveKit egress info.
107
+ * @returns Normalised molecule recording.
108
+ */
109
+ function mapRecording(data) {
110
+ const recording = {
111
+ id: data.egressId,
112
+ roomName: data.roomName,
113
+ };
114
+ recording.status = mapRecordingStatus(data.status);
115
+ const startedAtMs = toMillis(data.startedAt);
116
+ if (startedAtMs !== undefined) {
117
+ recording.startedAt = new Date(startedAtMs);
118
+ }
119
+ const file = data.fileResults?.[0];
120
+ if (file?.location) {
121
+ recording.downloadUrl = file.location;
122
+ }
123
+ const duration = toSeconds(file?.duration);
124
+ if (duration !== undefined) {
125
+ recording.duration = duration;
126
+ }
127
+ return recording;
128
+ }
129
+ /**
130
+ * Normalises an explicit host or `LIVEKIT_URL` env value into the
131
+ * `https://` form required by Twirp service clients and the `wss://`
132
+ * form clients use to actually join.
133
+ *
134
+ * @param host - User-provided host (e.g. `https://...`, `wss://...`,
135
+ * `http://...`, or `ws://...`).
136
+ * @returns A pair of `{ http, ws }` URLs derived from the same origin.
137
+ */
138
+ function normaliseHost(host) {
139
+ const trimmed = host.replace(/\/$/, '');
140
+ let http;
141
+ let ws;
142
+ if (trimmed.startsWith('wss://')) {
143
+ http = `https://${trimmed.slice('wss://'.length)}`;
144
+ ws = trimmed;
145
+ }
146
+ else if (trimmed.startsWith('ws://')) {
147
+ http = `http://${trimmed.slice('ws://'.length)}`;
148
+ ws = trimmed;
149
+ }
150
+ else if (trimmed.startsWith('https://')) {
151
+ http = trimmed;
152
+ ws = `wss://${trimmed.slice('https://'.length)}`;
153
+ }
154
+ else if (trimmed.startsWith('http://')) {
155
+ http = trimmed;
156
+ ws = `ws://${trimmed.slice('http://'.length)}`;
157
+ }
158
+ else {
159
+ http = `https://${trimmed}`;
160
+ ws = `wss://${trimmed}`;
161
+ }
162
+ return { http, ws };
163
+ }
164
+ /**
165
+ * Computes the unix-seconds TTL (relative offset, in seconds) that
166
+ * `livekit-server-sdk`'s `AccessToken` expects for its `ttl` option,
167
+ * given an absolute expiry `Date`. Returns `undefined` when no expiry
168
+ * was provided, in which case the SDK's default of 6 hours applies.
169
+ *
170
+ * @param expiresAt - Optional absolute expiry.
171
+ * @returns TTL in seconds, or `undefined`.
172
+ */
173
+ function toTtlSeconds(expiresAt) {
174
+ if (expiresAt === undefined)
175
+ return undefined;
176
+ const ms = expiresAt.getTime() - Date.now();
177
+ if (!Number.isFinite(ms) || ms <= 0)
178
+ return 1;
179
+ return Math.floor(ms / 1000);
180
+ }
181
+ /**
182
+ * Creates a LiveKit-backed {@link VideoRoomsProvider}.
183
+ *
184
+ * Self-hostable: pass a `host` of e.g. `https://livekit.example.com` or
185
+ * set `LIVEKIT_URL` to the same value (or a `wss://` URL — the provider
186
+ * rewrites the protocol for the HTTP/Twirp endpoints).
187
+ *
188
+ * The API secret is **never** included in any error thrown by this
189
+ * provider — both the missing-secret error and SDK-error wrappers
190
+ * scrub it out.
191
+ *
192
+ * @param config - LiveKit provider configuration. Falls back to the
193
+ * `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET` env vars
194
+ * when the corresponding fields are omitted.
195
+ * @returns A fully initialised `VideoRoomsProvider` backed by LiveKit.
196
+ * @throws {Error} If host, API key, or API secret cannot be resolved.
197
+ */
198
+ export function createProvider(config = {}) {
199
+ const apiKey = config.apiKey ?? process.env.LIVEKIT_API_KEY;
200
+ const apiSecret = config.apiSecret ?? process.env.LIVEKIT_API_SECRET;
201
+ const rawHost = config.host ?? process.env.LIVEKIT_URL;
202
+ const defaultTokenTtl = config.defaultTokenTtl ?? DEFAULT_TOKEN_TTL_SECONDS;
203
+ if (!rawHost) {
204
+ throw new Error('LiveKit host is required. Set config.host or the LIVEKIT_URL environment variable.');
205
+ }
206
+ if (!apiKey) {
207
+ throw new Error('LiveKit apiKey is required. Set config.apiKey or the LIVEKIT_API_KEY environment variable.');
208
+ }
209
+ if (!apiSecret) {
210
+ throw new Error('LiveKit apiSecret is required. Set config.apiSecret or the LIVEKIT_API_SECRET environment variable.');
211
+ }
212
+ // Locked-in non-undefined values for closure use after the early throws above.
213
+ const resolvedApiKey = apiKey;
214
+ const resolvedApiSecret = apiSecret;
215
+ const { http: httpUrl, ws: wsUrl } = normaliseHost(rawHost);
216
+ const accessTokenCtor = config.accessTokenCtor ?? AccessToken;
217
+ const roomService = config.roomServiceClient ??
218
+ new RoomServiceClient(httpUrl, resolvedApiKey, resolvedApiSecret);
219
+ const egress = config.egressClient ??
220
+ new EgressClient(httpUrl, resolvedApiKey, resolvedApiSecret);
221
+ const recordingEgress = config.recordingEgress;
222
+ /**
223
+ * Resolves the configured auto-egress specification for a room, if any.
224
+ * Returns the fixed `RoomEgress`, the result of the factory, or
225
+ * `undefined` when no recording output has been configured on this bond.
226
+ *
227
+ * @param roomName - The room the egress would record.
228
+ * @returns The `RoomEgress` to attach, or `undefined` when unconfigured.
229
+ */
230
+ function resolveRecordingEgress(roomName) {
231
+ if (recordingEgress === undefined)
232
+ return undefined;
233
+ return typeof recordingEgress === 'function' ? recordingEgress(roomName) : recordingEgress;
234
+ }
235
+ /**
236
+ * Wraps a thrown error in a provider-prefixed `Error` whose message is
237
+ * scrubbed of the LiveKit API secret.
238
+ *
239
+ * @param operation - Short label of the failing operation.
240
+ * @param error - The underlying error.
241
+ * @returns A redacted Error with provider context.
242
+ */
243
+ function redactError(operation, error) {
244
+ const raw = error instanceof Error ? error.message : String(error);
245
+ const scrubbed = raw.split(resolvedApiSecret).join('[redacted]');
246
+ const wrapped = new Error(`LiveKit ${operation} failed: ${scrubbed}`);
247
+ if (error instanceof Error && error.stack) {
248
+ wrapped.stack = error.stack;
249
+ }
250
+ return wrapped;
251
+ }
252
+ /**
253
+ * Generates a fresh meeting token for `roomName` with the given
254
+ * options. All tokens get publish + subscribe; owners additionally get
255
+ * roomAdmin + canUpdateOwnMetadata.
256
+ *
257
+ * @param roomName - The room the token is scoped to.
258
+ * @param options - Token options.
259
+ * @returns The signed JWT.
260
+ */
261
+ async function issueToken(roomName, options = {}) {
262
+ const ttl = toTtlSeconds(options.expiresAt) ?? defaultTokenTtl;
263
+ const tokenOptions = { ttl };
264
+ if (options.userName !== undefined) {
265
+ tokenOptions.identity = options.userName;
266
+ tokenOptions.name = options.userName;
267
+ }
268
+ const token = new accessTokenCtor(resolvedApiKey, resolvedApiSecret, tokenOptions);
269
+ const isOwner = options.isOwner === true;
270
+ token.addGrant({
271
+ room: roomName,
272
+ roomJoin: true,
273
+ roomAdmin: isOwner,
274
+ canPublish: true,
275
+ canSubscribe: true,
276
+ canPublishData: true,
277
+ canUpdateOwnMetadata: isOwner,
278
+ });
279
+ return token.toJwt();
280
+ }
281
+ const provider = {
282
+ async createRoom(options) {
283
+ // Privacy: LiveKit is *always* token-gated — every join needs a token
284
+ // from createMeetingToken(), and Room.url is the server's wss://
285
+ // endpoint, not a click-to-join link. There is no URL-joinable /
286
+ // token-free mode, so a `public` room cannot be honoured. Fail loudly
287
+ // at creation rather than return a room falsely labelled `public`.
288
+ if (options.privacy === 'public') {
289
+ throw new Error('LiveKit does not support public (URL-joinable) rooms: every join ' +
290
+ 'requires a meeting token from createMeetingToken(). Use ' +
291
+ "privacy: 'private' (the default enforced by this bond) or omit it.");
292
+ }
293
+ const name = options.name ?? `room-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
294
+ const createOptions = { name };
295
+ if (options.maxParticipants !== undefined) {
296
+ createOptions.maxParticipants = options.maxParticipants;
297
+ }
298
+ const ttl = toTtlSeconds(options.expiresAt);
299
+ if (ttl !== undefined) {
300
+ createOptions.emptyTimeout = ttl;
301
+ }
302
+ // Recording: LiveKit records via Egress, which requires a storage
303
+ // output that the core `recording: boolean` flag does not carry. When
304
+ // recording is requested we attach the operator-configured auto-egress
305
+ // spec so LiveKit really starts a room-composite egress once the room
306
+ // is active; without it we throw rather than pretend recording is on.
307
+ let recordingEnabled = false;
308
+ if (options.recording === true) {
309
+ const egressSpec = resolveRecordingEgress(name);
310
+ if (egressSpec === undefined) {
311
+ throw new Error('LiveKit recording was requested (recording: true) but no egress ' +
312
+ 'output is configured. Set config.recordingEgress to a LiveKit ' +
313
+ 'RoomEgress with a storage destination (S3 / GCP / Azure / AliOSS ' +
314
+ 'file output, or a stream/segment output). LiveKit cannot record ' +
315
+ 'without a storage output.');
316
+ }
317
+ createOptions.egress = egressSpec;
318
+ recordingEnabled = true;
319
+ }
320
+ let raw;
321
+ try {
322
+ raw = await roomService.createRoom(createOptions);
323
+ }
324
+ catch (error) {
325
+ throw redactError('createRoom', error);
326
+ }
327
+ const room = mapRoom(raw, wsUrl);
328
+ // Every LiveKit room is token-gated — report the true privacy state.
329
+ room.privacy = 'private';
330
+ if (options.expiresAt !== undefined) {
331
+ room.expiresAt = options.expiresAt;
332
+ }
333
+ // Recording is enabled for the room even before the first participant
334
+ // makes the egress active, so report it as enabled once wired.
335
+ if (recordingEnabled) {
336
+ room.recording = true;
337
+ }
338
+ const result = { ...room };
339
+ try {
340
+ result.token = await issueToken(name, {
341
+ isOwner: true,
342
+ expiresAt: options.expiresAt,
343
+ });
344
+ }
345
+ catch (error) {
346
+ throw redactError('createMeetingToken', error);
347
+ }
348
+ return result;
349
+ },
350
+ async deleteRoom(name) {
351
+ try {
352
+ await roomService.deleteRoom(name);
353
+ }
354
+ catch (error) {
355
+ if (isNotFoundError(error))
356
+ return;
357
+ throw redactError('deleteRoom', error);
358
+ }
359
+ },
360
+ async getRoom(name) {
361
+ let rooms;
362
+ try {
363
+ rooms = await roomService.listRooms([name]);
364
+ }
365
+ catch (error) {
366
+ throw redactError('getRoom', error);
367
+ }
368
+ const match = rooms.find((r) => r.name === name);
369
+ return match ? mapRoom(match, wsUrl) : null;
370
+ },
371
+ async createMeetingToken(roomName, options) {
372
+ try {
373
+ return await issueToken(roomName, options);
374
+ }
375
+ catch (error) {
376
+ throw redactError('createMeetingToken', error);
377
+ }
378
+ },
379
+ async listRecordings(roomName) {
380
+ let rows;
381
+ try {
382
+ rows = await egress.listEgress({ roomName });
383
+ }
384
+ catch (error) {
385
+ throw redactError('listRecordings', error);
386
+ }
387
+ return rows.map(mapRecording);
388
+ },
389
+ };
390
+ return provider;
391
+ }
392
+ /**
393
+ * Detects whether a thrown LiveKit error represents a "room does not
394
+ * exist" (404 / not_found / NotFound) condition. Used to make
395
+ * `deleteRoom` idempotent.
396
+ *
397
+ * @param error - The thrown error.
398
+ * @returns `true` when the error indicates a missing room.
399
+ */
400
+ function isNotFoundError(error) {
401
+ if (!(error instanceof Error))
402
+ return false;
403
+ const message = error.message.toLowerCase();
404
+ if (message.includes('not_found'))
405
+ return true;
406
+ if (message.includes('not found'))
407
+ return true;
408
+ if (message.includes('does not exist'))
409
+ return true;
410
+ if (/\b404\b/.test(error.message))
411
+ return true;
412
+ // TwirpError exposes a `code` property of `'not_found'` for missing
413
+ // resources. Check it without coupling to the concrete type.
414
+ const code = error.code;
415
+ if (typeof code === 'string' && code.toLowerCase() === 'not_found')
416
+ return true;
417
+ return false;
418
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LiveKit video-rooms bond secret definitions — self-registered at import time so the
3
+ * runtime secrets registry (`@molecule/api-secrets`) can drive boot-time
4
+ * configuration reports and actionable "not configured" errors.
5
+ *
6
+ * Content is derived MECHANICALLY from this package's mlcl registry secrets
7
+ * entry (label/instructions/setupUrl/example) via the fleet formula, so
8
+ * packages sharing a key register byte-identical definitions and
9
+ * registration order never matters.
10
+ *
11
+ * @module
12
+ */
13
+ import type { SecretDefinition } from '@molecule/api-secrets';
14
+ /** Secret definitions required by the LiveKit video-rooms bond. */
15
+ export declare const videoRoomsLivekitSecretDefinitions: SecretDefinition[];
16
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,mEAAmE;AACnE,eAAO,MAAM,kCAAkC,EAAE,gBAAgB,EAoBhE,CAAA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * LiveKit video-rooms bond secret definitions — self-registered at import time so the
3
+ * runtime secrets registry (`@molecule/api-secrets`) can drive boot-time
4
+ * configuration reports and actionable "not configured" errors.
5
+ *
6
+ * Content is derived MECHANICALLY from this package's mlcl registry secrets
7
+ * entry (label/instructions/setupUrl/example) via the fleet formula, so
8
+ * packages sharing a key register byte-identical definitions and
9
+ * registration order never matters.
10
+ *
11
+ * @module
12
+ */
13
+ import { registerSecrets } from '@molecule/api-secrets';
14
+ /** Secret definitions required by the LiveKit video-rooms bond. */
15
+ export const videoRoomsLivekitSecretDefinitions = [
16
+ {
17
+ key: 'LIVEKIT_URL',
18
+ description: 'LiveKit server URL — Your LiveKit Cloud project URL (or self-hosted wss:// URL).',
19
+ helpUrl: 'https://cloud.livekit.io/',
20
+ required: true,
21
+ example: 'wss://your-app.livekit.cloud',
22
+ },
23
+ {
24
+ key: 'LIVEKIT_API_KEY',
25
+ description: 'LiveKit API key — LiveKit Cloud → project → Settings → Keys.',
26
+ helpUrl: 'https://cloud.livekit.io/',
27
+ required: true,
28
+ },
29
+ {
30
+ key: 'LIVEKIT_API_SECRET',
31
+ description: 'LiveKit API secret — Shown when creating the key in LiveKit Cloud.',
32
+ helpUrl: 'https://cloud.livekit.io/',
33
+ required: true,
34
+ },
35
+ ];
36
+ registerSecrets(videoRoomsLivekitSecretDefinitions);
@@ -0,0 +1,162 @@
1
+ /**
2
+ * LiveKit video rooms provider configuration types.
3
+ *
4
+ * @module
5
+ */
6
+ import type { AccessToken as AccessTokenClass, RoomEgress } from 'livekit-server-sdk';
7
+ /**
8
+ * Constructor for `livekit-server-sdk`'s `AccessToken` class. Exposed so
9
+ * tests can inject a fake builder without spinning up the real `jose`
10
+ * signer.
11
+ */
12
+ export type AccessTokenCtor = new (apiKey?: string, apiSecret?: string, options?: ConstructorParameters<typeof AccessTokenClass>[2]) => AccessTokenClass;
13
+ /**
14
+ * Minimal `RoomServiceClient` surface used by the provider. Tests inject
15
+ * a stub here to avoid HTTP traffic. The real
16
+ * `livekit-server-sdk.RoomServiceClient` satisfies this shape.
17
+ */
18
+ export interface LiveKitRoomServiceClient {
19
+ /** Creates a new LiveKit room. */
20
+ createRoom(options: {
21
+ name: string;
22
+ emptyTimeout?: number;
23
+ departureTimeout?: number;
24
+ maxParticipants?: number;
25
+ metadata?: string;
26
+ /**
27
+ * Auto-egress specification. When set, LiveKit automatically starts a
28
+ * room-composite (or participant/track) egress once the room becomes
29
+ * active — this is how the bond wires `CreateRoomOptions.recording`.
30
+ */
31
+ egress?: RoomEgress;
32
+ }): Promise<LiveKitRoom>;
33
+ /** Lists active rooms, optionally filtered by name. */
34
+ listRooms(names?: string[]): Promise<LiveKitRoom[]>;
35
+ /** Deletes a room by name. */
36
+ deleteRoom(room: string): Promise<void>;
37
+ }
38
+ /**
39
+ * Minimal `EgressClient` surface used by the provider for listing
40
+ * recordings.
41
+ */
42
+ export interface LiveKitEgressClient {
43
+ /** Lists egress (recording) jobs, optionally filtered by room. */
44
+ listEgress(options?: {
45
+ roomName?: string;
46
+ }): Promise<LiveKitEgressInfo[]>;
47
+ }
48
+ /**
49
+ * Minimal LiveKit `Room` shape consumed by the provider. The real
50
+ * protobuf class exposes additional fields we don't depend on.
51
+ */
52
+ export interface LiveKitRoom {
53
+ /** Room name (stable identifier). */
54
+ name: string;
55
+ /** Room sid (unique per-instance id). */
56
+ sid?: string;
57
+ /** Maximum simultaneous participants. */
58
+ maxParticipants?: number;
59
+ /** Empty-room TTL in seconds. */
60
+ emptyTimeout?: number;
61
+ /** Departure-room TTL in seconds. */
62
+ departureTimeout?: number;
63
+ /** Provider-side opaque metadata blob. */
64
+ metadata?: string;
65
+ /** Unix-seconds creation timestamp (the protobuf field is `bigint`). */
66
+ creationTime?: number | bigint;
67
+ /** Whether a recording is currently active on the room. */
68
+ activeRecording?: boolean;
69
+ }
70
+ /**
71
+ * Minimal LiveKit egress (recording job) shape. Status is the numeric
72
+ * `EgressStatus` enum value from `@livekit/protocol`.
73
+ */
74
+ export interface LiveKitEgressInfo {
75
+ /** Egress identifier. */
76
+ egressId: string;
77
+ /** Name of the room the egress belongs to. */
78
+ roomName: string;
79
+ /** Numeric `EgressStatus` enum (0=starting … 6=limit_reached). */
80
+ status?: number;
81
+ /** Unix-seconds (or bigint) start time. */
82
+ startedAt?: number | bigint;
83
+ /** Unix-seconds (or bigint) end time. */
84
+ endedAt?: number | bigint;
85
+ /** Recorded file results, when present. */
86
+ fileResults?: Array<{
87
+ location?: string;
88
+ duration?: number | bigint;
89
+ }>;
90
+ }
91
+ /**
92
+ * Configuration for the LiveKit video rooms provider.
93
+ */
94
+ export interface LiveKitVideoRoomsConfig {
95
+ /**
96
+ * LiveKit host (including protocol), e.g.
97
+ * `https://my-project.livekit.cloud` or `https://livekit.example.com`.
98
+ * Defaults to `process.env.LIVEKIT_URL` (which may use `wss://` — the
99
+ * provider rewrites it to `https://` for HTTP/Twirp calls).
100
+ */
101
+ host?: string;
102
+ /**
103
+ * LiveKit API key. Defaults to `process.env.LIVEKIT_API_KEY`.
104
+ */
105
+ apiKey?: string;
106
+ /**
107
+ * LiveKit API secret. Defaults to `process.env.LIVEKIT_API_SECRET`.
108
+ * Used to sign JWT meeting tokens via HS256.
109
+ */
110
+ apiSecret?: string;
111
+ /**
112
+ * Optional default token TTL in seconds. Used when
113
+ * `createMeetingToken()` is called without an `expiresAt`. Defaults to
114
+ * `21600` (6 hours), matching the `livekit-server-sdk` default.
115
+ */
116
+ defaultTokenTtl?: number;
117
+ /**
118
+ * Auto-egress specification used to satisfy `createRoom({ recording:
119
+ * true })`. LiveKit records via Egress, which **requires** a storage
120
+ * destination (S3 / GCP / Azure / AliOSS via `EncodedFileOutput`, or a
121
+ * stream/segment output) — a destination the core `recording: boolean`
122
+ * flag does not carry. Supply the LiveKit `RoomEgress` (with your
123
+ * storage output) here, either as a fixed object or a factory that
124
+ * receives the room name and returns a per-room `RoomEgress`. When it is
125
+ * set, `createRoom({ recording: true })` attaches it to the room so
126
+ * LiveKit auto-starts a room-composite egress once the room is active.
127
+ *
128
+ * When this is **not** configured, `createRoom({ recording: true })`
129
+ * throws rather than silently returning a room with no recording — LiveKit
130
+ * cannot record without a storage output.
131
+ */
132
+ recordingEgress?: RoomEgress | ((roomName: string) => RoomEgress);
133
+ /**
134
+ * Optional pre-built `RoomServiceClient` (or compatible stub). Tests
135
+ * inject a stub here. When omitted, the provider lazily constructs a
136
+ * real `RoomServiceClient` from the SDK on first use.
137
+ */
138
+ roomServiceClient?: LiveKitRoomServiceClient;
139
+ /**
140
+ * Optional pre-built `EgressClient` (or compatible stub). Tests inject
141
+ * a stub here. When omitted, the provider lazily constructs a real
142
+ * `EgressClient` from the SDK on first use.
143
+ */
144
+ egressClient?: LiveKitEgressClient;
145
+ /**
146
+ * Optional `AccessToken` constructor override. Tests inject a fake
147
+ * builder to avoid the real `jose` HS256 signer. Defaults to the
148
+ * `AccessToken` class exported by `livekit-server-sdk`.
149
+ */
150
+ accessTokenCtor?: AccessTokenCtor;
151
+ }
152
+ declare global {
153
+ namespace NodeJS {
154
+ /** LiveKit-specific environment variable declarations. */
155
+ interface ProcessEnv {
156
+ LIVEKIT_URL?: string;
157
+ LIVEKIT_API_KEY?: string;
158
+ LIVEKIT_API_SECRET?: string;
159
+ }
160
+ }
161
+ }
162
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * LiveKit video rooms provider configuration types.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@molecule/api-video-rooms-livekit",
3
+ "version": "1.0.0",
4
+ "description": "LiveKit video rooms provider for molecule.dev",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "video",
25
+ "video-rooms",
26
+ "livekit",
27
+ "webrtc",
28
+ "self-hosted"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "peerDependencies": {
32
+ "@molecule/api-secrets": "^1.0.0",
33
+ "@molecule/api-video-rooms": "1.0.0"
34
+ },
35
+ "dependencies": {
36
+ "livekit-server-sdk": "2.17.0"
37
+ },
38
+ "devDependencies": {
39
+ "@molecule/api-video-rooms": "1.0.0",
40
+ "@types/node": "26.1.2",
41
+ "typescript": "6.0.3",
42
+ "vitest": "4.1.10"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/molecule-dev/molecule.git",
47
+ "directory": "packages/api/bonds/video-rooms/livekit"
48
+ },
49
+ "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/bonds/video-rooms/livekit",
50
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }