@livekit/rtc-node 0.12.1 → 0.13.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/dist/audio_frame.cjs +2 -2
- package/dist/audio_frame.cjs.map +1 -1
- package/dist/audio_frame.d.cts +31 -0
- package/dist/audio_frame.d.ts +11 -5
- package/dist/audio_frame.d.ts.map +1 -1
- package/dist/audio_frame.js +3 -3
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_resampler.cjs +10 -7
- package/dist/audio_resampler.cjs.map +1 -1
- package/dist/audio_resampler.d.cts +59 -0
- package/dist/audio_resampler.d.ts +11 -3
- package/dist/audio_resampler.d.ts.map +1 -1
- package/dist/audio_resampler.js +13 -10
- package/dist/audio_resampler.js.map +1 -1
- package/dist/audio_source.cjs +6 -4
- package/dist/audio_source.cjs.map +1 -1
- package/dist/audio_source.d.cts +37 -0
- package/dist/audio_source.d.ts +13 -5
- package/dist/audio_source.d.ts.map +1 -1
- package/dist/audio_source.js +9 -7
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.cjs +1 -2
- package/dist/audio_stream.cjs.map +1 -1
- package/dist/audio_stream.d.cts +37 -0
- package/dist/audio_stream.d.ts +16 -5
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/audio_stream.js +2 -3
- package/dist/audio_stream.js.map +1 -1
- package/dist/e2ee.cjs +19 -20
- package/dist/e2ee.cjs.map +1 -1
- package/dist/e2ee.d.cts +47 -0
- package/dist/e2ee.d.ts +11 -8
- package/dist/e2ee.d.ts.map +1 -1
- package/dist/e2ee.js +29 -30
- package/dist/e2ee.js.map +1 -1
- package/dist/ffi_client.cjs +6 -5
- package/dist/ffi_client.cjs.map +1 -1
- package/dist/ffi_client.d.cts +35 -0
- package/dist/ffi_client.d.ts +23 -11
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +6 -10
- package/dist/ffi_client.js.map +1 -1
- package/dist/index.cjs +16 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +20 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -46
- package/dist/index.js.map +1 -1
- package/dist/napi/native.d.cjs.map +1 -1
- package/dist/napi/native.d.d.cts +21 -0
- package/dist/napi/native.d.d.ts +21 -0
- package/dist/napi/native.d.ts +5 -5
- package/dist/native.d.ts +5 -5
- package/dist/participant.cjs +57 -34
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +126 -0
- package/dist/participant.d.ts +34 -20
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +75 -50
- package/dist/participant.js.map +1 -1
- package/dist/proto/audio_frame_pb.cjs +977 -125
- package/dist/proto/audio_frame_pb.cjs.map +1 -1
- package/dist/proto/audio_frame_pb.d.cts +898 -0
- package/dist/proto/audio_frame_pb.d.ts +506 -417
- package/dist/proto/audio_frame_pb.d.ts.map +1 -1
- package/dist/proto/audio_frame_pb.js +943 -85
- package/dist/proto/audio_frame_pb.js.map +1 -1
- package/dist/proto/e2ee_pb.cjs +700 -85
- package/dist/proto/e2ee_pb.cjs.map +1 -1
- package/dist/proto/e2ee_pb.d.cts +653 -0
- package/dist/proto/e2ee_pb.d.ts +333 -263
- package/dist/proto/e2ee_pb.d.ts.map +1 -1
- package/dist/proto/e2ee_pb.js +675 -57
- package/dist/proto/e2ee_pb.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +369 -36
- package/dist/proto/ffi_pb.cjs.map +1 -1
- package/dist/proto/ffi_pb.d.cts +898 -0
- package/dist/proto/ffi_pb.d.ts +164 -112
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +364 -29
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/handle_pb.cjs +27 -7
- package/dist/proto/handle_pb.cjs.map +1 -1
- package/dist/proto/handle_pb.d.cts +31 -0
- package/dist/proto/handle_pb.d.ts +15 -15
- package/dist/proto/handle_pb.d.ts.map +1 -1
- package/dist/proto/handle_pb.js +26 -5
- package/dist/proto/handle_pb.js.map +1 -1
- package/dist/proto/participant_pb.cjs +112 -15
- package/dist/proto/participant_pb.cjs.map +1 -1
- package/dist/proto/participant_pb.d.cts +181 -0
- package/dist/proto/participant_pb.d.ts +143 -53
- package/dist/proto/participant_pb.d.ts.map +1 -1
- package/dist/proto/participant_pb.js +109 -11
- package/dist/proto/participant_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +2693 -302
- package/dist/proto/room_pb.cjs.map +1 -1
- package/dist/proto/room_pb.d.cts +2475 -0
- package/dist/proto/room_pb.d.ts +1269 -864
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +2603 -210
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/proto/rpc_pb.cjs +302 -37
- package/dist/proto/rpc_pb.cjs.map +1 -1
- package/dist/proto/rpc_pb.d.cts +267 -0
- package/dist/proto/rpc_pb.d.ts +140 -108
- package/dist/proto/rpc_pb.d.ts.map +1 -1
- package/dist/proto/rpc_pb.js +291 -25
- package/dist/proto/rpc_pb.js.map +1 -1
- package/dist/proto/stats_pb.cjs +1253 -139
- package/dist/proto/stats_pb.cjs.map +1 -1
- package/dist/proto/stats_pb.d.cts +1764 -0
- package/dist/proto/stats_pb.d.ts +806 -693
- package/dist/proto/stats_pb.d.ts.map +1 -1
- package/dist/proto/stats_pb.js +1216 -93
- package/dist/proto/stats_pb.js.map +1 -1
- package/dist/proto/track_pb.cjs +462 -64
- package/dist/proto/track_pb.cjs.map +1 -1
- package/dist/proto/track_pb.d.cts +434 -0
- package/dist/proto/track_pb.d.ts +254 -220
- package/dist/proto/track_pb.d.ts.map +1 -1
- package/dist/proto/track_pb.js +447 -45
- package/dist/proto/track_pb.js.map +1 -1
- package/dist/proto/track_publication_pb.cjs +130 -0
- package/dist/proto/track_publication_pb.cjs.map +1 -0
- package/dist/proto/track_publication_pb.d.cts +80 -0
- package/dist/proto/track_publication_pb.d.ts +80 -0
- package/dist/proto/track_publication_pb.d.ts.map +1 -0
- package/dist/proto/track_publication_pb.js +103 -0
- package/dist/proto/track_publication_pb.js.map +1 -0
- package/dist/proto/video_frame_pb.cjs +648 -88
- package/dist/proto/video_frame_pb.cjs.map +1 -1
- package/dist/proto/video_frame_pb.d.cts +660 -0
- package/dist/proto/video_frame_pb.d.ts +375 -328
- package/dist/proto/video_frame_pb.d.ts.map +1 -1
- package/dist/proto/video_frame_pb.js +626 -60
- package/dist/proto/video_frame_pb.js.map +1 -1
- package/dist/room.cjs +93 -125
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +123 -0
- package/dist/room.d.ts +37 -34
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +92 -122
- package/dist/room.js.map +1 -1
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +81 -0
- package/dist/rpc.d.ts +10 -7
- package/dist/rpc.js.map +1 -1
- package/dist/track.cjs +12 -8
- package/dist/track.cjs.map +1 -1
- package/dist/track.d.cts +45 -0
- package/dist/track.d.ts +30 -20
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +13 -9
- package/dist/track.js.map +1 -1
- package/dist/track_publication.cjs +21 -12
- package/dist/track_publication.cjs.map +1 -1
- package/dist/track_publication.d.cts +47 -0
- package/dist/track_publication.d.ts +30 -19
- package/dist/track_publication.d.ts.map +1 -1
- package/dist/track_publication.js +22 -13
- package/dist/track_publication.js.map +1 -1
- package/dist/transcription.d.cts +15 -0
- package/dist/transcription.d.ts +4 -3
- package/dist/types.d.cts +9 -0
- package/dist/types.d.ts +3 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -0
- package/dist/version.d.ts +3 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/video_frame.cjs +26 -45
- package/dist/video_frame.cjs.map +1 -1
- package/dist/video_frame.d.cts +24 -0
- package/dist/video_frame.d.ts +10 -4
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +29 -48
- package/dist/video_frame.js.map +1 -1
- package/dist/video_source.cjs +7 -4
- package/dist/video_source.cjs.map +1 -1
- package/dist/video_source.d.cts +22 -0
- package/dist/video_source.d.ts +14 -7
- package/dist/video_source.d.ts.map +1 -1
- package/dist/video_source.js +9 -6
- package/dist/video_source.js.map +1 -1
- package/dist/video_stream.cjs +16 -5
- package/dist/video_stream.cjs.map +1 -1
- package/dist/video_stream.d.cts +40 -0
- package/dist/video_stream.d.ts +18 -7
- package/dist/video_stream.d.ts.map +1 -1
- package/dist/video_stream.js +17 -6
- package/dist/video_stream.js.map +1 -1
- package/package.json +17 -12
- package/src/audio_frame.ts +10 -10
- package/src/audio_resampler.ts +15 -13
- package/src/audio_source.ts +11 -8
- package/src/audio_stream.ts +3 -4
- package/src/e2ee.ts +36 -37
- package/src/ffi_client.ts +8 -16
- package/src/index.ts +5 -68
- package/src/napi/native.d.ts +5 -5
- package/src/participant.ts +100 -72
- package/src/proto/audio_frame_pb.ts +1220 -496
- package/src/proto/e2ee_pb.ts +858 -337
- package/src/proto/ffi_pb.ts +442 -135
- package/src/proto/handle_pb.ts +33 -19
- package/src/proto/participant_pb.ts +225 -60
- package/src/proto/room_pb.ts +3149 -1013
- package/src/proto/rpc_pb.ts +358 -129
- package/src/proto/stats_pb.ts +1891 -877
- package/src/proto/track_pb.ts +587 -253
- package/src/proto/track_publication_pb.ts +180 -0
- package/src/proto/video_frame_pb.ts +861 -394
- package/src/room.ts +143 -188
- package/src/rpc.ts +1 -1
- package/src/track.ts +16 -17
- package/src/track_publication.ts +25 -26
- package/src/version.ts +1 -1
- package/src/video_frame.ts +48 -72
- package/src/video_source.ts +11 -8
- package/src/video_stream.ts +18 -8
package/dist/e2ee.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { create } from "@bufbuild/protobuf";
|
|
2
1
|
import { FfiClient } from "./ffi_client.js";
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
E2eeManagerSetEnabledRequest,
|
|
4
|
+
E2eeRequest,
|
|
6
5
|
EncryptionType,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
FrameCryptorSetEnabledRequest,
|
|
7
|
+
FrameCryptorSetKeyIndexRequest,
|
|
8
|
+
GetKeyRequest,
|
|
9
|
+
GetSharedKeyRequest,
|
|
10
|
+
RatchetKeyRequest,
|
|
11
|
+
RatchetSharedKeyRequest,
|
|
12
|
+
SetKeyRequest,
|
|
13
|
+
SetSharedKeyRequest
|
|
15
14
|
} from "./proto/e2ee_pb.js";
|
|
16
15
|
const DEFAULT_RATCHET_SALT = new TextEncoder().encode("LKFrameEncryptionKey");
|
|
17
16
|
const DEFAULT_RATCHET_WINDOW_SIZE = 16;
|
|
@@ -32,11 +31,11 @@ class KeyProvider {
|
|
|
32
31
|
this.options = opts;
|
|
33
32
|
}
|
|
34
33
|
setSharedKey(sharedKey, keyIndex) {
|
|
35
|
-
const req =
|
|
34
|
+
const req = new E2eeRequest({
|
|
36
35
|
roomHandle: this.roomHandle,
|
|
37
36
|
message: {
|
|
38
37
|
case: "setSharedKey",
|
|
39
|
-
value:
|
|
38
|
+
value: new SetSharedKeyRequest({
|
|
40
39
|
keyIndex,
|
|
41
40
|
sharedKey
|
|
42
41
|
})
|
|
@@ -50,11 +49,11 @@ class KeyProvider {
|
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
exportSharedKey(keyIndex) {
|
|
53
|
-
const req =
|
|
52
|
+
const req = new E2eeRequest({
|
|
54
53
|
roomHandle: this.roomHandle,
|
|
55
54
|
message: {
|
|
56
55
|
case: "getSharedKey",
|
|
57
|
-
value:
|
|
56
|
+
value: new GetSharedKeyRequest({
|
|
58
57
|
keyIndex
|
|
59
58
|
})
|
|
60
59
|
}
|
|
@@ -68,11 +67,11 @@ class KeyProvider {
|
|
|
68
67
|
return res.message.value.key;
|
|
69
68
|
}
|
|
70
69
|
ratchetSharedKey(keyIndex) {
|
|
71
|
-
const req =
|
|
70
|
+
const req = new E2eeRequest({
|
|
72
71
|
roomHandle: this.roomHandle,
|
|
73
72
|
message: {
|
|
74
73
|
case: "ratchetSharedKey",
|
|
75
|
-
value:
|
|
74
|
+
value: new RatchetSharedKeyRequest({
|
|
76
75
|
keyIndex
|
|
77
76
|
})
|
|
78
77
|
}
|
|
@@ -86,11 +85,11 @@ class KeyProvider {
|
|
|
86
85
|
return res.message.value.newKey;
|
|
87
86
|
}
|
|
88
87
|
setKey(participantIdentity, keyIndex) {
|
|
89
|
-
const req =
|
|
88
|
+
const req = new E2eeRequest({
|
|
90
89
|
roomHandle: this.roomHandle,
|
|
91
90
|
message: {
|
|
92
91
|
case: "setKey",
|
|
93
|
-
value:
|
|
92
|
+
value: new SetKeyRequest({
|
|
94
93
|
keyIndex,
|
|
95
94
|
participantIdentity
|
|
96
95
|
})
|
|
@@ -104,11 +103,11 @@ class KeyProvider {
|
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
105
|
exportKey(participantIdentity, keyIndex) {
|
|
107
|
-
const req =
|
|
106
|
+
const req = new E2eeRequest({
|
|
108
107
|
roomHandle: this.roomHandle,
|
|
109
108
|
message: {
|
|
110
109
|
case: "getKey",
|
|
111
|
-
value:
|
|
110
|
+
value: new GetKeyRequest({
|
|
112
111
|
keyIndex,
|
|
113
112
|
participantIdentity
|
|
114
113
|
})
|
|
@@ -123,11 +122,11 @@ class KeyProvider {
|
|
|
123
122
|
return res.message.value.key;
|
|
124
123
|
}
|
|
125
124
|
ratchetKey(participantIdentity, keyIndex) {
|
|
126
|
-
const req =
|
|
125
|
+
const req = new E2eeRequest({
|
|
127
126
|
roomHandle: this.roomHandle,
|
|
128
127
|
message: {
|
|
129
128
|
case: "ratchetKey",
|
|
130
|
-
value:
|
|
129
|
+
value: new RatchetKeyRequest({
|
|
131
130
|
keyIndex,
|
|
132
131
|
participantIdentity
|
|
133
132
|
})
|
|
@@ -152,11 +151,11 @@ class FrameCryptor {
|
|
|
152
151
|
}
|
|
153
152
|
setEnabled(enabled) {
|
|
154
153
|
this.enabled = enabled;
|
|
155
|
-
const req =
|
|
154
|
+
const req = new E2eeRequest({
|
|
156
155
|
roomHandle: this.roomHandle,
|
|
157
156
|
message: {
|
|
158
157
|
case: "cryptorSetEnabled",
|
|
159
|
-
value:
|
|
158
|
+
value: new FrameCryptorSetEnabledRequest({
|
|
160
159
|
participantIdentity: this.participantIdentity,
|
|
161
160
|
enabled: this.enabled
|
|
162
161
|
})
|
|
@@ -171,11 +170,11 @@ class FrameCryptor {
|
|
|
171
170
|
}
|
|
172
171
|
setKeyIndex(keyIndex) {
|
|
173
172
|
this.keyIndex = keyIndex;
|
|
174
|
-
const req =
|
|
173
|
+
const req = new E2eeRequest({
|
|
175
174
|
roomHandle: this.roomHandle,
|
|
176
175
|
message: {
|
|
177
176
|
case: "cryptorSetKeyIndex",
|
|
178
|
-
value:
|
|
177
|
+
value: new FrameCryptorSetKeyIndexRequest({
|
|
179
178
|
participantIdentity: this.participantIdentity,
|
|
180
179
|
keyIndex: this.keyIndex
|
|
181
180
|
})
|
|
@@ -201,11 +200,11 @@ class E2EEManager {
|
|
|
201
200
|
}
|
|
202
201
|
setEnabled(enabled) {
|
|
203
202
|
this.enabled = enabled;
|
|
204
|
-
const req =
|
|
203
|
+
const req = new E2eeRequest({
|
|
205
204
|
roomHandle: this.roomHandle,
|
|
206
205
|
message: {
|
|
207
206
|
case: "managerSetEnabled",
|
|
208
|
-
value:
|
|
207
|
+
value: new E2eeManagerSetEnabledRequest({
|
|
209
208
|
enabled: this.enabled
|
|
210
209
|
})
|
|
211
210
|
}
|
|
@@ -218,7 +217,7 @@ class E2EEManager {
|
|
|
218
217
|
});
|
|
219
218
|
}
|
|
220
219
|
frameCryptors() {
|
|
221
|
-
const req =
|
|
220
|
+
const req = new E2eeRequest({
|
|
222
221
|
roomHandle: this.roomHandle,
|
|
223
222
|
message: {
|
|
224
223
|
case: "managerGetFrameCryptors",
|
package/dist/e2ee.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/e2ee.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { create } from '@bufbuild/protobuf';\nimport { FfiClient } from './ffi_client.js';\nimport type {\n E2eeManagerGetFrameCryptorsResponse,\n E2eeResponse,\n GetKeyResponse,\n GetSharedKeyResponse,\n RatchetKeyResponse,\n RatchetSharedKeyResponse,\n} from './proto/e2ee_pb.js';\nimport {\n E2eeManagerSetEnabledRequestSchema,\n E2eeRequestSchema,\n EncryptionType,\n FrameCryptorSetEnabledRequestSchema,\n FrameCryptorSetKeyIndexRequestSchema,\n GetKeyRequestSchema,\n GetSharedKeyRequestSchema,\n RatchetKeyRequestSchema,\n RatchetSharedKeyRequestSchema,\n SetKeyRequestSchema,\n SetSharedKeyRequestSchema,\n} from './proto/e2ee_pb.js';\n\nconst DEFAULT_RATCHET_SALT = new TextEncoder().encode('LKFrameEncryptionKey');\nconst DEFAULT_RATCHET_WINDOW_SIZE = 16;\nconst DEFAULT_FAILURE_TOLERANCE = -1;\n\nexport interface KeyProviderOptions {\n sharedKey?: Uint8Array;\n ratchetSalt: Uint8Array;\n ratchetWindowSize: number;\n failureTolerance: number;\n}\n\nexport const defaultKeyProviderOptions: KeyProviderOptions = {\n ratchetSalt: DEFAULT_RATCHET_SALT,\n ratchetWindowSize: DEFAULT_RATCHET_WINDOW_SIZE,\n failureTolerance: DEFAULT_FAILURE_TOLERANCE,\n};\n\nexport interface E2EEOptions {\n keyProviderOptions: KeyProviderOptions;\n encryptionType: EncryptionType;\n}\n\nexport const defaultE2EEOptions: E2EEOptions = {\n keyProviderOptions: defaultKeyProviderOptions,\n encryptionType: EncryptionType.GCM,\n};\n\nexport class KeyProvider {\n private roomHandle: bigint;\n options: KeyProviderOptions;\n\n /** internal */\n constructor(roomHandle: bigint, opts: KeyProviderOptions) {\n this.roomHandle = roomHandle;\n this.options = opts;\n }\n\n setSharedKey(sharedKey: Uint8Array, keyIndex: number) {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'setSharedKey',\n value: create(SetSharedKeyRequestSchema, {\n keyIndex: keyIndex,\n sharedKey: sharedKey,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n exportSharedKey(keyIndex: number): Uint8Array {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'getSharedKey',\n value: create(GetSharedKeyRequestSchema, {\n keyIndex: keyIndex,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as GetSharedKeyResponse).key;\n }\n\n ratchetSharedKey(keyIndex: number): Uint8Array {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'ratchetSharedKey',\n value: create(RatchetSharedKeyRequestSchema, {\n keyIndex: keyIndex,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as RatchetSharedKeyResponse).newKey;\n }\n\n setKey(participantIdentity: string, keyIndex: number) {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'setKey',\n value: create(SetKeyRequestSchema, {\n keyIndex: keyIndex,\n participantIdentity: participantIdentity,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n exportKey(participantIdentity: string, keyIndex: number): Uint8Array {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'getKey',\n value: create(GetKeyRequestSchema, {\n keyIndex: keyIndex,\n participantIdentity: participantIdentity,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as GetKeyResponse).key;\n }\n\n ratchetKey(participantIdentity: string, keyIndex: number): Uint8Array {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'ratchetKey',\n value: create(RatchetKeyRequestSchema, {\n keyIndex: keyIndex,\n participantIdentity: participantIdentity,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as RatchetKeyResponse).newKey;\n }\n}\n\nexport class FrameCryptor {\n private roomHandle = BigInt(0);\n participantIdentity: string;\n keyIndex: number;\n enabled: boolean;\n\n constructor(roomHandle: bigint, participantIdentity: string, keyIndex: number, enabled: boolean) {\n this.roomHandle = roomHandle;\n this.participantIdentity = participantIdentity;\n this.keyIndex = keyIndex;\n this.enabled = enabled;\n }\n\n setEnabled(enabled: boolean) {\n this.enabled = enabled;\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'cryptorSetEnabled',\n value: create(FrameCryptorSetEnabledRequestSchema, {\n participantIdentity: this.participantIdentity,\n enabled: this.enabled,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n setKeyIndex(keyIndex: number) {\n this.keyIndex = keyIndex;\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'cryptorSetKeyIndex',\n value: create(FrameCryptorSetKeyIndexRequestSchema, {\n participantIdentity: this.participantIdentity,\n keyIndex: this.keyIndex,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n}\n\nexport class E2EEManager {\n private roomHandle = BigInt(0);\n private options: E2EEOptions;\n private keyProvider?: KeyProvider;\n\n enabled: boolean;\n\n constructor(roomHandle: bigint, opts?: E2EEOptions) {\n this.roomHandle = roomHandle;\n this.enabled = opts !== undefined;\n\n opts ??= defaultE2EEOptions;\n const options = { ...defaultE2EEOptions, ...opts };\n\n this.options = options;\n this.keyProvider = new KeyProvider(roomHandle, options.keyProviderOptions);\n }\n\n setEnabled(enabled: boolean) {\n this.enabled = enabled;\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'managerSetEnabled',\n value: create(E2eeManagerSetEnabledRequestSchema, {\n enabled: this.enabled,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n frameCryptors(): FrameCryptor[] {\n const req = create(E2eeRequestSchema, {\n roomHandle: this.roomHandle,\n message: {\n case: 'managerGetFrameCryptors',\n value: {},\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n const frameCryptors = (\n res.message.value as E2eeManagerGetFrameCryptorsResponse\n ).frameCryptors.map(\n (cryptor) =>\n new FrameCryptor(\n this.roomHandle,\n cryptor.participantIdentity,\n cryptor.keyIndex,\n cryptor.enabled,\n ),\n );\n\n return frameCryptors;\n }\n}\n"],"mappings":"AAGA,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAS1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,uBAAuB,IAAI,YAAY,EAAE,OAAO,sBAAsB;AAC5E,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;AAS3B,MAAM,4BAAgD;AAAA,EAC3D,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,kBAAkB;AACpB;AAOO,MAAM,qBAAkC;AAAA,EAC7C,oBAAoB;AAAA,EACpB,gBAAgB,eAAe;AACjC;AAEO,MAAM,YAAY;AAAA;AAAA,EAKvB,YAAY,YAAoB,MAA0B;AACxD,SAAK,aAAa;AAClB,SAAK,UAAU;AAAA,EACjB;AAAA,EA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A,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,gBAAgC;AAC9B,UAAM,MAAM,OAAO,mBAAmB;AAAA,MACpC,YAAY,KAAK;AAAA,MACjB,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO,CAAC;AAAA,MACV;AAAA,IACF,CAAC;AAED,UAAM,MAAM,UAAU,SAAS,QAAsB;AAAA,MACnD,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,UAAM,gBACJ,IAAI,QAAQ,MACZ,cAAc;AAAA,MACd,CAAC,YACC,IAAI;AAAA,QACF,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,IACJ;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/e2ee.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { FfiClient } from './ffi_client.js';\nimport type {\n E2eeManagerGetFrameCryptorsResponse,\n E2eeResponse,\n GetKeyResponse,\n GetSharedKeyResponse,\n RatchetKeyResponse,\n RatchetSharedKeyResponse,\n} from './proto/e2ee_pb.js';\nimport {\n E2eeManagerSetEnabledRequest,\n E2eeRequest,\n EncryptionType,\n FrameCryptorSetEnabledRequest,\n FrameCryptorSetKeyIndexRequest,\n GetKeyRequest,\n GetSharedKeyRequest,\n RatchetKeyRequest,\n RatchetSharedKeyRequest,\n SetKeyRequest,\n SetSharedKeyRequest,\n} from './proto/e2ee_pb.js';\n\nconst DEFAULT_RATCHET_SALT = new TextEncoder().encode('LKFrameEncryptionKey');\nconst DEFAULT_RATCHET_WINDOW_SIZE = 16;\nconst DEFAULT_FAILURE_TOLERANCE = -1;\n\nexport interface KeyProviderOptions {\n sharedKey?: Uint8Array;\n ratchetSalt: Uint8Array;\n ratchetWindowSize: number;\n failureTolerance: number;\n}\n\nexport const defaultKeyProviderOptions: KeyProviderOptions = {\n ratchetSalt: DEFAULT_RATCHET_SALT,\n ratchetWindowSize: DEFAULT_RATCHET_WINDOW_SIZE,\n failureTolerance: DEFAULT_FAILURE_TOLERANCE,\n};\n\nexport interface E2EEOptions {\n keyProviderOptions: KeyProviderOptions;\n encryptionType: EncryptionType;\n}\n\nexport const defaultE2EEOptions: E2EEOptions = {\n keyProviderOptions: defaultKeyProviderOptions,\n encryptionType: EncryptionType.GCM,\n};\n\nexport class KeyProvider {\n private roomHandle: bigint;\n options: KeyProviderOptions;\n\n /** internal */\n constructor(roomHandle: bigint, opts: KeyProviderOptions) {\n this.roomHandle = roomHandle;\n this.options = opts;\n }\n\n setSharedKey(sharedKey: Uint8Array, keyIndex: number) {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'setSharedKey',\n value: new SetSharedKeyRequest({\n keyIndex: keyIndex,\n sharedKey: sharedKey,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n exportSharedKey(keyIndex: number): Uint8Array {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'getSharedKey',\n value: new GetSharedKeyRequest({\n keyIndex: keyIndex,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as GetSharedKeyResponse).key!;\n }\n\n ratchetSharedKey(keyIndex: number): Uint8Array {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'ratchetSharedKey',\n value: new RatchetSharedKeyRequest({\n keyIndex: keyIndex,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as RatchetSharedKeyResponse).newKey!;\n }\n\n setKey(participantIdentity: string, keyIndex: number) {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'setKey',\n value: new SetKeyRequest({\n keyIndex: keyIndex,\n participantIdentity: participantIdentity,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n exportKey(participantIdentity: string, keyIndex: number): Uint8Array {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'getKey',\n value: new GetKeyRequest({\n keyIndex: keyIndex,\n participantIdentity: participantIdentity,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as GetKeyResponse).key!;\n }\n\n ratchetKey(participantIdentity: string, keyIndex: number): Uint8Array {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'ratchetKey',\n value: new RatchetKeyRequest({\n keyIndex: keyIndex,\n participantIdentity: participantIdentity,\n }),\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n return (res.message.value as RatchetKeyResponse).newKey!;\n }\n}\n\nexport class FrameCryptor {\n private roomHandle = BigInt(0);\n participantIdentity: string;\n keyIndex: number;\n enabled: boolean;\n\n constructor(roomHandle: bigint, participantIdentity: string, keyIndex: number, enabled: boolean) {\n this.roomHandle = roomHandle;\n this.participantIdentity = participantIdentity;\n this.keyIndex = keyIndex;\n this.enabled = enabled;\n }\n\n setEnabled(enabled: boolean) {\n this.enabled = enabled;\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'cryptorSetEnabled',\n value: new FrameCryptorSetEnabledRequest({\n participantIdentity: this.participantIdentity,\n enabled: this.enabled,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n setKeyIndex(keyIndex: number) {\n this.keyIndex = keyIndex;\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'cryptorSetKeyIndex',\n value: new FrameCryptorSetKeyIndexRequest({\n participantIdentity: this.participantIdentity,\n keyIndex: this.keyIndex,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n}\n\nexport class E2EEManager {\n private roomHandle = BigInt(0);\n private options: E2EEOptions;\n private keyProvider?: KeyProvider;\n\n enabled: boolean;\n\n constructor(roomHandle: bigint, opts?: E2EEOptions) {\n this.roomHandle = roomHandle;\n this.enabled = opts !== undefined;\n\n opts ??= defaultE2EEOptions;\n const options = { ...defaultE2EEOptions, ...opts };\n\n this.options = options;\n this.keyProvider = new KeyProvider(roomHandle, options.keyProviderOptions);\n }\n\n setEnabled(enabled: boolean) {\n this.enabled = enabled;\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'managerSetEnabled',\n value: new E2eeManagerSetEnabledRequest({\n enabled: this.enabled,\n }),\n },\n });\n\n FfiClient.instance.request({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n }\n\n frameCryptors(): FrameCryptor[] {\n const req = new E2eeRequest({\n roomHandle: this.roomHandle,\n message: {\n case: 'managerGetFrameCryptors',\n value: {},\n },\n });\n\n const res = FfiClient.instance.request<E2eeResponse>({\n message: {\n case: 'e2ee',\n value: req,\n },\n });\n\n const frameCryptors = (\n res.message.value as E2eeManagerGetFrameCryptorsResponse\n ).frameCryptors.map(\n (cryptor) =>\n new FrameCryptor(\n this.roomHandle,\n cryptor.participantIdentity!,\n cryptor.keyIndex!,\n cryptor.enabled!,\n ),\n );\n\n return frameCryptors;\n }\n}\n"],"mappings":"AAGA,SAAS,iBAAiB;AAS1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,uBAAuB,IAAI,YAAY,EAAE,OAAO,sBAAsB;AAC5E,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;AAS3B,MAA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ACf,UAAM,MAAM,IAAI,YAAY;AAAA,MAC1B,YAAY,KAAK;AAAA,MACjB,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO,IAAI,6BAA6B;AAAA,UACtC,SAAS,KAAK;AAAA,QAChB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,cAAU,SAAS,QAAQ;AAAA,MACzB,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,gBAAgC;AAC9B,UAAM,MAAM,IAAI,YAAY;AAAA,MAC1B,YAAY,KAAK;AAAA,MACjB,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO,CAAC;AAAA,MACV;AAAA,IACF,CAAC;AAED,UAAM,MAAM,UAAU,SAAS,QAAsB;AAAA,MACnD,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,UAAM,gBACJ,IAAI,QAAQ,MACZ,cAAc;AAAA,MACd,CAAC,YACC,IAAI;AAAA,QACF,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,IACJ;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/ffi_client.cjs
CHANGED
|
@@ -31,10 +31,10 @@ __export(ffi_client_exports, {
|
|
|
31
31
|
FfiClient: () => FfiClient,
|
|
32
32
|
FfiClientEvent: () => FfiClientEvent,
|
|
33
33
|
FfiHandle: () => import_native.FfiHandle,
|
|
34
|
+
FfiRequest: () => import_ffi_pb.FfiRequest,
|
|
34
35
|
dispose: () => import_native.livekitDispose
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(ffi_client_exports);
|
|
37
|
-
var import_protobuf = require("@bufbuild/protobuf");
|
|
38
38
|
var import_events = __toESM(require("events"), 1);
|
|
39
39
|
var import_native = require("./napi/native.cjs");
|
|
40
40
|
var import_ffi_pb = require("./proto/ffi_pb.cjs");
|
|
@@ -54,7 +54,7 @@ class FfiClient extends import_events.default {
|
|
|
54
54
|
this.setMaxListeners(0);
|
|
55
55
|
(0, import_native.livekitInitialize)(
|
|
56
56
|
(event_data) => {
|
|
57
|
-
const event =
|
|
57
|
+
const event = import_ffi_pb.FfiEvent.fromBinary(event_data);
|
|
58
58
|
this.emit("ffi_event" /* FfiEvent */, event);
|
|
59
59
|
},
|
|
60
60
|
true,
|
|
@@ -62,10 +62,10 @@ class FfiClient extends import_events.default {
|
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
request(req) {
|
|
65
|
-
const request =
|
|
66
|
-
const req_data =
|
|
65
|
+
const request = new import_ffi_pb.FfiRequest(req);
|
|
66
|
+
const req_data = request.toBinary();
|
|
67
67
|
const res_data = (0, import_native.livekitFfiRequest)(req_data);
|
|
68
|
-
return
|
|
68
|
+
return import_ffi_pb.FfiResponse.fromBinary(res_data).message.value;
|
|
69
69
|
}
|
|
70
70
|
copyBuffer(ptr, len) {
|
|
71
71
|
return (0, import_native.livekitCopyBuffer)(ptr, len);
|
|
@@ -90,6 +90,7 @@ class FfiClient extends import_events.default {
|
|
|
90
90
|
FfiClient,
|
|
91
91
|
FfiClientEvent,
|
|
92
92
|
FfiHandle,
|
|
93
|
+
FfiRequest,
|
|
93
94
|
dispose
|
|
94
95
|
});
|
|
95
96
|
//# sourceMappingURL=ffi_client.cjs.map
|
package/dist/ffi_client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ffi_client.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/ffi_client.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { PartialMessage } from '@bufbuild/protobuf';\nimport type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';\nimport EventEmitter from 'events';\nimport {\n FfiHandle,\n livekitCopyBuffer,\n livekitDispose,\n livekitFfiRequest,\n livekitInitialize,\n livekitRetrievePtr,\n} from './napi/native.js';\nimport { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';\nimport { SDK_VERSION } from './version.js';\n\nexport { FfiHandle, type FfiEvent, type FfiResponse, FfiRequest, livekitDispose as dispose };\n\nexport type FfiClientCallbacks = {\n ffi_event: (event: FfiEvent) => void;\n};\n\nexport enum FfiClientEvent {\n FfiEvent = 'ffi_event',\n}\n\nexport class FfiClient extends (EventEmitter as new () => TypedEmitter<FfiClientCallbacks>) {\n static _client?: FfiClient;\n\n /** @internal */\n static get instance(): FfiClient {\n if (!FfiClient._client) FfiClient._client = new FfiClient();\n\n return FfiClient._client;\n }\n\n constructor() {\n super();\n this.setMaxListeners(0);\n\n livekitInitialize(\n (event_data: Uint8Array) => {\n const event = FfiEvent.fromBinary(event_data);\n this.emit(FfiClientEvent.FfiEvent, event);\n },\n true,\n SDK_VERSION,\n );\n }\n\n request<T>(req: PartialMessage<FfiRequest>): T {\n const request = new FfiRequest(req);\n const req_data = request.toBinary();\n const res_data = livekitFfiRequest(req_data);\n return FfiResponse.fromBinary(res_data).message.value as T;\n }\n\n copyBuffer(ptr: bigint, len: number): Uint8Array {\n return livekitCopyBuffer(ptr, len);\n }\n\n retrievePtr(data: Uint8Array): bigint {\n return livekitRetrievePtr(data);\n }\n\n async waitFor<T>(predicate: (ev: FfiEvent) => boolean): Promise<T> {\n return new Promise<T>((resolve) => {\n const listener = (ev: FfiEvent) => {\n if (predicate(ev)) {\n this.off(FfiClientEvent.FfiEvent, listener);\n resolve(ev.message.value as T);\n }\n };\n this.on(FfiClientEvent.FfiEvent, listener);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAyB;AACzB,oBAOO;AACP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itter';
|
|
3
|
+
export { FfiHandle, livekitDispose as dispose } from './napi/native.d.cjs';
|
|
4
|
+
import { FfiEvent, FfiRequest } from './proto/ffi_pb.cjs';
|
|
5
|
+
export { FfiResponse } from './proto/ffi_pb.cjs';
|
|
6
|
+
import './proto/room_pb.cjs';
|
|
7
|
+
import './proto/participant_pb.cjs';
|
|
8
|
+
import './proto/handle_pb.cjs';
|
|
9
|
+
import './proto/track_pb.cjs';
|
|
10
|
+
import './proto/stats_pb.cjs';
|
|
11
|
+
import './proto/e2ee_pb.cjs';
|
|
12
|
+
import './proto/video_frame_pb.cjs';
|
|
13
|
+
import './proto/audio_frame_pb.cjs';
|
|
14
|
+
import './proto/rpc_pb.cjs';
|
|
15
|
+
import './proto/track_publication_pb.cjs';
|
|
16
|
+
|
|
17
|
+
type FfiClientCallbacks = {
|
|
18
|
+
ffi_event: (event: FfiEvent) => void;
|
|
19
|
+
};
|
|
20
|
+
declare enum FfiClientEvent {
|
|
21
|
+
FfiEvent = "ffi_event"
|
|
22
|
+
}
|
|
23
|
+
declare const FfiClient_base: new () => TypedEventEmitter<FfiClientCallbacks>;
|
|
24
|
+
declare class FfiClient extends FfiClient_base {
|
|
25
|
+
static _client?: FfiClient;
|
|
26
|
+
/** @internal */
|
|
27
|
+
static get instance(): FfiClient;
|
|
28
|
+
constructor();
|
|
29
|
+
request<T>(req: PartialMessage<FfiRequest>): T;
|
|
30
|
+
copyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
31
|
+
retrievePtr(data: Uint8Array): bigint;
|
|
32
|
+
waitFor<T>(predicate: (ev: FfiEvent) => boolean): Promise<T>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { FfiClient, type FfiClientCallbacks, FfiClientEvent, FfiEvent, FfiRequest };
|
package/dist/ffi_client.d.ts
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
|
|
1
|
+
import { PartialMessage } from '@bufbuild/protobuf';
|
|
2
|
+
import { TypedEventEmitter } from '@livekit/typed-emitter';
|
|
3
|
+
export { FfiHandle, livekitDispose as dispose } from './napi/native.d.js';
|
|
4
|
+
import { FfiEvent, FfiRequest } from './proto/ffi_pb.js';
|
|
5
|
+
export { FfiResponse } from './proto/ffi_pb.js';
|
|
6
|
+
import './proto/room_pb.js';
|
|
7
|
+
import './proto/participant_pb.js';
|
|
8
|
+
import './proto/handle_pb.js';
|
|
9
|
+
import './proto/track_pb.js';
|
|
10
|
+
import './proto/stats_pb.js';
|
|
11
|
+
import './proto/e2ee_pb.js';
|
|
12
|
+
import './proto/video_frame_pb.js';
|
|
13
|
+
import './proto/audio_frame_pb.js';
|
|
14
|
+
import './proto/rpc_pb.js';
|
|
15
|
+
import './proto/track_publication_pb.js';
|
|
16
|
+
|
|
17
|
+
type FfiClientCallbacks = {
|
|
7
18
|
ffi_event: (event: FfiEvent) => void;
|
|
8
19
|
};
|
|
9
|
-
|
|
20
|
+
declare enum FfiClientEvent {
|
|
10
21
|
FfiEvent = "ffi_event"
|
|
11
22
|
}
|
|
12
|
-
declare const FfiClient_base: new () =>
|
|
13
|
-
|
|
23
|
+
declare const FfiClient_base: new () => TypedEventEmitter<FfiClientCallbacks>;
|
|
24
|
+
declare class FfiClient extends FfiClient_base {
|
|
14
25
|
static _client?: FfiClient;
|
|
15
26
|
/** @internal */
|
|
16
27
|
static get instance(): FfiClient;
|
|
17
28
|
constructor();
|
|
18
|
-
request<T>(req:
|
|
29
|
+
request<T>(req: PartialMessage<FfiRequest>): T;
|
|
19
30
|
copyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
20
31
|
retrievePtr(data: Uint8Array): bigint;
|
|
21
32
|
waitFor<T>(predicate: (ev: FfiEvent) => boolean): Promise<T>;
|
|
22
33
|
}
|
|
23
|
-
|
|
34
|
+
|
|
35
|
+
export { FfiClient, type FfiClientCallbacks, FfiClientEvent, FfiEvent, FfiRequest };
|
package/dist/ffi_client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ffi_client.d.ts","sourceRoot":"","sources":["../src/ffi_client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ffi_client.d.ts","sourceRoot":"","sources":["../src/ffi_client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EACL,SAAS,EAET,cAAc,EAIf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGtE,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,cAAc,IAAI,OAAO,EAAE,CAAC;AAE7F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,oBAAY,cAAc;IACxB,QAAQ,cAAc;CACvB;8BAE+C,UAAU,YAAY,CAAC,kBAAkB,CAAC;AAA1F,qBAAa,SAAU,SAAQ,cAA4D;IACzF,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAE3B,gBAAgB;IAChB,MAAM,KAAK,QAAQ,IAAI,SAAS,CAI/B;;IAgBD,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC;IAO9C,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAIhD,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IAI/B,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;CAWnE"}
|
package/dist/ffi_client.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
2
1
|
import EventEmitter from "events";
|
|
3
2
|
import {
|
|
4
3
|
FfiHandle,
|
|
@@ -8,11 +7,7 @@ import {
|
|
|
8
7
|
livekitInitialize,
|
|
9
8
|
livekitRetrievePtr
|
|
10
9
|
} from "./napi/native.js";
|
|
11
|
-
import {
|
|
12
|
-
FfiEventSchema,
|
|
13
|
-
FfiRequestSchema,
|
|
14
|
-
FfiResponseSchema
|
|
15
|
-
} from "./proto/ffi_pb.js";
|
|
10
|
+
import { FfiEvent, FfiRequest, FfiResponse } from "./proto/ffi_pb.js";
|
|
16
11
|
import { SDK_VERSION } from "./version.js";
|
|
17
12
|
var FfiClientEvent = /* @__PURE__ */ ((FfiClientEvent2) => {
|
|
18
13
|
FfiClientEvent2["FfiEvent"] = "ffi_event";
|
|
@@ -29,7 +24,7 @@ class FfiClient extends EventEmitter {
|
|
|
29
24
|
this.setMaxListeners(0);
|
|
30
25
|
livekitInitialize(
|
|
31
26
|
(event_data) => {
|
|
32
|
-
const event = fromBinary(
|
|
27
|
+
const event = FfiEvent.fromBinary(event_data);
|
|
33
28
|
this.emit("ffi_event" /* FfiEvent */, event);
|
|
34
29
|
},
|
|
35
30
|
true,
|
|
@@ -37,10 +32,10 @@ class FfiClient extends EventEmitter {
|
|
|
37
32
|
);
|
|
38
33
|
}
|
|
39
34
|
request(req) {
|
|
40
|
-
const request =
|
|
41
|
-
const req_data = toBinary(
|
|
35
|
+
const request = new FfiRequest(req);
|
|
36
|
+
const req_data = request.toBinary();
|
|
42
37
|
const res_data = livekitFfiRequest(req_data);
|
|
43
|
-
return fromBinary(
|
|
38
|
+
return FfiResponse.fromBinary(res_data).message.value;
|
|
44
39
|
}
|
|
45
40
|
copyBuffer(ptr, len) {
|
|
46
41
|
return livekitCopyBuffer(ptr, len);
|
|
@@ -64,6 +59,7 @@ export {
|
|
|
64
59
|
FfiClient,
|
|
65
60
|
FfiClientEvent,
|
|
66
61
|
FfiHandle,
|
|
62
|
+
FfiRequest,
|
|
67
63
|
livekitDispose as dispose
|
|
68
64
|
};
|
|
69
65
|
//# sourceMappingURL=ffi_client.js.map
|
package/dist/ffi_client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ffi_client.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/ffi_client.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { PartialMessage } from '@bufbuild/protobuf';\nimport type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';\nimport EventEmitter from 'events';\nimport {\n FfiHandle,\n livekitCopyBuffer,\n livekitDispose,\n livekitFfiRequest,\n livekitInitialize,\n livekitRetrievePtr,\n} from './napi/native.js';\nimport { FfiEvent, FfiRequest, FfiResponse } from './proto/ffi_pb.js';\nimport { SDK_VERSION } from './version.js';\n\nexport { FfiHandle, type FfiEvent, type FfiResponse, FfiRequest, livekitDispose as dispose };\n\nexport type FfiClientCallbacks = {\n ffi_event: (event: FfiEvent) => void;\n};\n\nexport enum FfiClientEvent {\n FfiEvent = 'ffi_event',\n}\n\nexport class FfiClient extends (EventEmitter as new () => TypedEmitter<FfiClientCallbacks>) {\n static _client?: FfiClient;\n\n /** @internal */\n static get instance(): FfiClient {\n if (!FfiClient._client) FfiClient._client = new FfiClient();\n\n return FfiClient._client;\n }\n\n constructor() {\n super();\n this.setMaxListeners(0);\n\n livekitInitialize(\n (event_data: Uint8Array) => {\n const event = FfiEvent.fromBinary(event_data);\n this.emit(FfiClientEvent.FfiEvent, event);\n },\n true,\n SDK_VERSION,\n );\n }\n\n request<T>(req: PartialMessage<FfiRequest>): T {\n const request = new FfiRequest(req);\n const req_data = request.toBinary();\n const res_data = livekitFfiRequest(req_data);\n return FfiResponse.fromBinary(res_data).message.value as T;\n }\n\n copyBuffer(ptr: bigint, len: number): Uint8Array {\n return livekitCopyBuffer(ptr, len);\n }\n\n retrievePtr(data: Uint8Array): bigint {\n return livekitRetrievePtr(data);\n }\n\n async waitFor<T>(predicate: (ev: FfiEvent) => boolean): Promise<T> {\n return new Promise<T>((resolve) => {\n const listener = (ev: FfiEvent) => {\n if (predicate(ev)) {\n this.off(FfiClientEvent.FfiEvent, listener);\n resolve(ev.message.value as T);\n }\n };\n this.on(FfiClientEvent.FfiEvent, listener);\n });\n }\n}\n"],"mappings":"AAKA,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,YAAY,mBAAmB;AAClD,SAAS,mBAAmB;AAQrB,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,cAAW;AADD,SAAAA;AAAA,GAAA;AAIL,MAAM,kBAAmB,aAA4D;AAAA;AAAA,EAI1F,WAAW,WAAsB;AAC/B,QAAI,CAAC,UAAU,QAAS,WAAU,UAAU,IAAI,UAAU;AAE1D,WAAO,UAAU;AAAA,EACnB;AAAA,EAEA,cAAc;AACZ,UAAM;AACN,SAAK,gBAAgB,CAAC;AAEtB;AAAA,MACE,CAAC,eAA2B;AAC1B,cAAM,QAAQ,SAAS,WAAW,UAAU;AAC5C,aAAK,KAAK,4BAAyB,KAAK;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,QAAW,KAAoC;AAC7C,UAAM,UAAU,IAAI,WAAW,GAAG;AAClC,UAAM,WAAW,QAAQ,SAAS;AAClC,UAAM,WAAW,kBAAkB,QAAQ;AAC3C,WAAO,YAAY,WAAW,QAAQ,EAAE,QAAQ;AAAA,EAClD;AAAA,EAEA,WAAW,KAAa,KAAyB;AAC/C,WAAO,kBAAkB,KAAK,GAAG;AAAA,EACnC;AAAA,EAEA,YAAY,MAA0B;AACpC,WAAO,mBAAmB,IAAI;AAAA,EAChC;AAAA,EAEA,MAAM,QAAW,WAAkD;AACjE,WAAO,IAAI,QAAW,CAAC,YAAY;AACjC,YAAM,WAAW,CAAC,OAAiB;AACjC,YAAI,UAAU,EAAE,GAAG;AACjB,eAAK,IAAI,4BAAyB,QAAQ;AAC1C,kBAAQ,GAAG,QAAQ,KAAU;AAAA,QAC/B;AAAA,MACF;AACA,WAAK,GAAG,4BAAyB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;","names":["FfiClientEvent"]}
|
package/dist/index.cjs
CHANGED
|
@@ -24,16 +24,16 @@ __export(src_exports, {
|
|
|
24
24
|
AudioSource: () => import_audio_source.AudioSource,
|
|
25
25
|
AudioStream: () => import_audio_stream.AudioStream,
|
|
26
26
|
ConnectError: () => import_room.ConnectError,
|
|
27
|
-
ConnectionQuality: () =>
|
|
28
|
-
ConnectionState: () =>
|
|
29
|
-
ContinualGatheringPolicy: () =>
|
|
30
|
-
DataPacketKind: () =>
|
|
27
|
+
ConnectionQuality: () => import_room_pb.ConnectionQuality,
|
|
28
|
+
ConnectionState: () => import_room_pb.ConnectionState,
|
|
29
|
+
ContinualGatheringPolicy: () => import_room_pb.ContinualGatheringPolicy,
|
|
30
|
+
DataPacketKind: () => import_room_pb.DataPacketKind,
|
|
31
31
|
E2EEManager: () => import_e2ee.E2EEManager,
|
|
32
32
|
EncryptionState: () => import_e2ee_pb.EncryptionState,
|
|
33
33
|
EncryptionType: () => import_e2ee_pb.EncryptionType,
|
|
34
34
|
FrameCryptor: () => import_e2ee.FrameCryptor,
|
|
35
|
-
IceServer: () => IceServer,
|
|
36
|
-
IceTransportType: () =>
|
|
35
|
+
IceServer: () => import_room_pb.IceServer,
|
|
36
|
+
IceTransportType: () => import_room_pb.IceTransportType,
|
|
37
37
|
KeyProvider: () => import_e2ee.KeyProvider,
|
|
38
38
|
LocalAudioTrack: () => import_track.LocalAudioTrack,
|
|
39
39
|
LocalParticipant: () => import_participant.LocalParticipant,
|
|
@@ -48,26 +48,22 @@ __export(src_exports, {
|
|
|
48
48
|
Room: () => import_room.Room,
|
|
49
49
|
RoomEvent: () => import_room.RoomEvent,
|
|
50
50
|
RpcError: () => import_rpc.RpcError,
|
|
51
|
-
StreamState: () =>
|
|
51
|
+
StreamState: () => import_track_pb.StreamState,
|
|
52
52
|
Track: () => import_track.Track,
|
|
53
|
-
TrackKind: () =>
|
|
53
|
+
TrackKind: () => import_track_pb.TrackKind,
|
|
54
54
|
TrackPublication: () => import_track_publication.TrackPublication,
|
|
55
|
-
TrackPublishOptions: () => TrackPublishOptions,
|
|
56
|
-
TrackSource: () =>
|
|
57
|
-
VideoBufferType: () =>
|
|
58
|
-
VideoCodec: () =>
|
|
55
|
+
TrackPublishOptions: () => import_room_pb.TrackPublishOptions,
|
|
56
|
+
TrackSource: () => import_track_pb.TrackSource,
|
|
57
|
+
VideoBufferType: () => import_video_frame_pb.VideoBufferType,
|
|
58
|
+
VideoCodec: () => import_video_frame_pb.VideoCodec,
|
|
59
59
|
VideoFrame: () => import_video_frame.VideoFrame,
|
|
60
|
-
VideoRotation: () =>
|
|
60
|
+
VideoRotation: () => import_video_frame_pb.VideoRotation,
|
|
61
61
|
VideoSource: () => import_video_source.VideoSource,
|
|
62
62
|
VideoStream: () => import_video_stream.VideoStream,
|
|
63
63
|
combineAudioFrames: () => import_audio_frame.combineAudioFrames,
|
|
64
64
|
dispose: () => import_ffi_client.dispose
|
|
65
65
|
});
|
|
66
66
|
module.exports = __toCommonJS(src_exports);
|
|
67
|
-
var import_protobuf = require("@bufbuild/protobuf");
|
|
68
|
-
var import_room_pb = require("./proto/room_pb.cjs");
|
|
69
|
-
var import_track_pb = require("./proto/track_pb.cjs");
|
|
70
|
-
var import_video_frame_pb = require("./proto/video_frame_pb.cjs");
|
|
71
67
|
var import_room = require("./room.cjs");
|
|
72
68
|
var import_participant = require("./participant.cjs");
|
|
73
69
|
var import_track = require("./track.cjs");
|
|
@@ -79,43 +75,14 @@ var import_video_stream = require("./video_stream.cjs");
|
|
|
79
75
|
var import_audio_source = require("./audio_source.cjs");
|
|
80
76
|
var import_video_source = require("./video_source.cjs");
|
|
81
77
|
var import_track_publication = require("./track_publication.cjs");
|
|
82
|
-
var import_transcription = require("./transcription.cjs");
|
|
83
78
|
var import_e2ee = require("./e2ee.cjs");
|
|
84
|
-
var
|
|
79
|
+
var import_room_pb = require("./proto/room_pb.cjs");
|
|
85
80
|
var import_rpc = require("./rpc.cjs");
|
|
86
81
|
var import_e2ee_pb = require("./proto/e2ee_pb.cjs");
|
|
87
|
-
var
|
|
88
|
-
var
|
|
82
|
+
var import_track_pb = require("./proto/track_pb.cjs");
|
|
83
|
+
var import_video_frame_pb = require("./proto/video_frame_pb.cjs");
|
|
89
84
|
var import_participant_pb = require("./proto/participant_pb.cjs");
|
|
90
85
|
var import_ffi_client = require("./ffi_client.cjs");
|
|
91
|
-
class IceServer {
|
|
92
|
-
constructor(init) {
|
|
93
|
-
this.$typeName = "livekit.proto.IceServer";
|
|
94
|
-
const { urls, username, password } = init;
|
|
95
|
-
this.urls = urls;
|
|
96
|
-
this.username = username ?? "";
|
|
97
|
-
this.password = password ?? "";
|
|
98
|
-
(0, import_protobuf.create)(import_room_pb.IceServerSchema, init);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
class TrackPublishOptions {
|
|
102
|
-
constructor(init = {}) {
|
|
103
|
-
this.$typeName = "livekit.proto.TrackPublishOptions";
|
|
104
|
-
const { videoCodec, videoEncoding, audioEncoding, dtx, simulcast, source, stream, red } = init;
|
|
105
|
-
this.videoCodec = videoCodec ?? import_video_frame_pb.VideoCodec.VP8;
|
|
106
|
-
if (videoEncoding) {
|
|
107
|
-
this.videoEncoding = (0, import_protobuf.create)(import_room_pb.VideoEncodingSchema, videoEncoding);
|
|
108
|
-
}
|
|
109
|
-
if (audioEncoding) {
|
|
110
|
-
this.audioEncoding = (0, import_protobuf.create)(import_room_pb.AudioEncodingSchema, audioEncoding);
|
|
111
|
-
}
|
|
112
|
-
this.dtx = dtx ?? false;
|
|
113
|
-
this.simulcast = simulcast ?? false;
|
|
114
|
-
this.source = source ?? import_track_pb.TrackSource.SOURCE_UNKNOWN;
|
|
115
|
-
this.stream = stream ?? "";
|
|
116
|
-
this.red = red ?? false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
120
87
|
0 && (module.exports = {
|
|
121
88
|
AudioFrame,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { Participant, RemoteParticipant, LocalParticipant } from './participant.js';\nexport {\n Track,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n type AudioTrack,\n} from './track.js';\nexport { VideoFrame } from './video_frame.js';\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioStream } from './audio_stream.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport { AudioSource } from './audio_source.js';\nexport { VideoSource } from './video_source.js';\nexport {\n TrackPublication,\n RemoteTrackPublication,\n LocalTrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport {\n ConnectionQuality,\n IceServer,\n IceTransportType,\n DataPacketKind,\n ContinualGatheringPolicy,\n TrackPublishOptions,\n ConnectionState,\n} from './proto/room_pb.js';\nexport { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';\nexport { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_pb.js';\nexport { ParticipantKind } from './proto/participant_pb.js';\nexport { dispose } from './ffi_client.js';\nexport type { ChatMessage } from './types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAuF;AACvF,yBAAiE;AACjE,mBAUO;AACP,yBAA2B;AAC3B,yBAA+C;AAC/C,0BAA4B;AAC5B,6BAAsD;AACtD,0BAAkD;AAClD,0BAA4B;AAC5B,0BAA4B;AAC5B,+BAIO;AAEP,kBAAuD;AAEvD,qBAQO;AACP,iBAAwE;AACxE,qBAAgD;AAChD,sBAAoD;AACpD,4BAA2D;AAC3D,4BAAgC;AAChC,wBAAwB;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { ConnectError, Room, RoomEvent, RoomOptions, RtcConfiguration } from './room.cjs';
|
|
2
|
+
export { LocalParticipant, Participant, RemoteParticipant } from './participant.cjs';
|
|
3
|
+
export { AudioTrack, LocalAudioTrack, LocalTrack, LocalVideoTrack, RemoteAudioTrack, RemoteTrack, RemoteVideoTrack, Track, VideoTrack } from './track.cjs';
|
|
4
|
+
export { VideoFrame } from './video_frame.cjs';
|
|
5
|
+
export { AudioFrame, combineAudioFrames } from './audio_frame.cjs';
|
|
6
|
+
export { AudioStream } from './audio_stream.cjs';
|
|
7
|
+
export { AudioResampler, AudioResamplerQuality } from './audio_resampler.cjs';
|
|
8
|
+
export { VideoFrameEvent, VideoStream } from './video_stream.cjs';
|
|
9
|
+
export { AudioSource } from './audio_source.cjs';
|
|
10
|
+
export { VideoSource } from './video_source.cjs';
|
|
11
|
+
export { LocalTrackPublication, RemoteTrackPublication, TrackPublication } from './track_publication.cjs';
|
|
12
|
+
export { Transcription, TranscriptionSegment } from './transcription.cjs';
|
|
13
|
+
export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.cjs';
|
|
14
|
+
export { ConnectionQuality, ConnectionState, ContinualGatheringPolicy, DataPacketKind, IceServer, IceTransportType, TrackPublishOptions } from './proto/room_pb.cjs';
|
|
15
|
+
export { PerformRpcParams, RpcError, RpcInvocationData } from './rpc.cjs';
|
|
16
|
+
export { EncryptionState, EncryptionType } from './proto/e2ee_pb.cjs';
|
|
17
|
+
export { StreamState, TrackKind, TrackSource } from './proto/track_pb.cjs';
|
|
18
|
+
export { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.cjs';
|
|
19
|
+
export { ParticipantKind } from './proto/participant_pb.cjs';
|
|
20
|
+
export { livekitDispose as dispose } from './napi/native.d.cjs';
|
|
21
|
+
export { ChatMessage } from './types.cjs';
|
|
22
|
+
import '@livekit/typed-emitter';
|
|
23
|
+
import './proto/audio_frame_pb.cjs';
|
|
24
|
+
import '@bufbuild/protobuf';
|
|
25
|
+
import './proto/handle_pb.cjs';
|
|
26
|
+
import '@livekit/mutex';
|
|
27
|
+
import './proto/stats_pb.cjs';
|
|
28
|
+
import './proto/rpc_pb.cjs';
|