livekit-client 1.13.0 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +122 -105
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +172 -109
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +4 -3
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/KeyProvider.d.ts +7 -6
- package/dist/src/e2ee/KeyProvider.d.ts.map +1 -1
- package/dist/src/e2ee/events.d.ts +34 -0
- package/dist/src/e2ee/events.d.ts.map +1 -0
- package/dist/src/e2ee/index.d.ts +1 -0
- package/dist/src/e2ee/index.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +17 -33
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +15 -12
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +6 -8
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +1 -0
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/processor/types.d.ts +2 -1
- package/dist/src/room/track/processor/types.d.ts.map +1 -1
- package/dist/ts4.2/src/e2ee/E2eeManager.d.ts +4 -3
- package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +7 -6
- package/dist/ts4.2/src/e2ee/events.d.ts +34 -0
- package/dist/ts4.2/src/e2ee/index.d.ts +1 -0
- package/dist/ts4.2/src/e2ee/types.d.ts +17 -33
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +15 -12
- package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +6 -8
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -0
- package/dist/ts4.2/src/room/track/processor/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/e2ee/E2eeManager.ts +105 -77
- package/src/e2ee/KeyProvider.ts +23 -13
- package/src/e2ee/events.ts +48 -0
- package/src/e2ee/index.ts +1 -0
- package/src/e2ee/types.ts +19 -41
- package/src/e2ee/worker/FrameCryptor.ts +51 -43
- package/src/e2ee/worker/ParticipantKeyHandler.ts +25 -27
- package/src/e2ee/worker/e2ee.worker.ts +61 -68
- package/src/room/PCTransport.ts +12 -2
- package/src/room/RTCEngine.ts +0 -1
- package/src/room/Room.ts +20 -15
- package/src/room/participant/LocalParticipant.ts +5 -1
- package/src/room/track/LocalTrack.ts +18 -10
- package/src/room/track/facingMode.ts +1 -1
- package/src/room/track/processor/types.ts +2 -1
package/src/room/Room.ts
CHANGED
@@ -209,10 +209,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
209
209
|
*/
|
210
210
|
async setE2EEEnabled(enabled: boolean) {
|
211
211
|
if (this.e2eeManager) {
|
212
|
-
await Promise.all([
|
213
|
-
|
214
|
-
this.e2eeManager.setParticipantCryptorEnabled(enabled)
|
215
|
-
|
212
|
+
await Promise.all([this.localParticipant.setE2EEEnabled(enabled)]);
|
213
|
+
if (this.localParticipant.identity !== '') {
|
214
|
+
this.e2eeManager.setParticipantCryptorEnabled(enabled, this.localParticipant.identity);
|
215
|
+
}
|
216
216
|
} else {
|
217
217
|
throw Error('e2ee not configured, please set e2ee settings within the room options');
|
218
218
|
}
|
@@ -230,7 +230,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
230
230
|
this.emit(RoomEvent.ParticipantEncryptionStatusChanged, enabled, participant);
|
231
231
|
},
|
232
232
|
);
|
233
|
-
this.e2eeManager.on(EncryptionEvent.
|
233
|
+
this.e2eeManager.on(EncryptionEvent.EncryptionError, (error) =>
|
234
234
|
this.emit(RoomEvent.EncryptionError, error),
|
235
235
|
);
|
236
236
|
this.e2eeManager?.setup(this);
|
@@ -1025,7 +1025,15 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
1025
1025
|
log.warn('tried to create RemoteParticipant for local participant');
|
1026
1026
|
return;
|
1027
1027
|
}
|
1028
|
-
|
1028
|
+
|
1029
|
+
const participant = this.participants.get(participantId) as RemoteParticipant | undefined;
|
1030
|
+
|
1031
|
+
if (!participant) {
|
1032
|
+
log.error(
|
1033
|
+
`Tried to add a track for a participant, that's not present. Sid: ${participantId}`,
|
1034
|
+
);
|
1035
|
+
return;
|
1036
|
+
}
|
1029
1037
|
|
1030
1038
|
let adaptiveStreamSettings: AdaptiveStreamSettings | undefined;
|
1031
1039
|
if (this.options.adaptiveStream) {
|
@@ -1445,20 +1453,17 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
1445
1453
|
return participant;
|
1446
1454
|
}
|
1447
1455
|
|
1448
|
-
private getOrCreateParticipant(id: string, info
|
1456
|
+
private getOrCreateParticipant(id: string, info: ParticipantInfo): RemoteParticipant {
|
1449
1457
|
if (this.participants.has(id)) {
|
1450
1458
|
return this.participants.get(id) as RemoteParticipant;
|
1451
1459
|
}
|
1452
|
-
// it's possible for the RTC track to arrive before signaling data
|
1453
|
-
// when this happens, we'll create the participant and make the track work
|
1454
1460
|
const participant = this.createParticipant(id, info);
|
1455
1461
|
this.participants.set(id, participant);
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
}
|
1462
|
+
|
1463
|
+
this.identityToSid.set(info.identity, info.sid);
|
1464
|
+
// if we have valid info and the participant wasn't in the map before, we can assume the participant is new
|
1465
|
+
// firing here to make sure that `ParticipantConnected` fires before the initial track events
|
1466
|
+
this.emitWhenConnected(RoomEvent.ParticipantConnected, participant);
|
1462
1467
|
|
1463
1468
|
// also forward events
|
1464
1469
|
// trackPublished is only fired for tracks added after both local participant
|
@@ -104,6 +104,10 @@ export default class LocalParticipant extends Participant {
|
|
104
104
|
return this.microphoneError;
|
105
105
|
}
|
106
106
|
|
107
|
+
get isE2EEEnabled(): boolean {
|
108
|
+
return this.encryptionType !== Encryption_Type.NONE;
|
109
|
+
}
|
110
|
+
|
107
111
|
getTrack(source: Track.Source): LocalTrackPublication | undefined {
|
108
112
|
const track = super.getTrack(source);
|
109
113
|
if (track) {
|
@@ -645,7 +649,7 @@ export default class LocalParticipant extends Participant {
|
|
645
649
|
disableDtx: !(opts.dtx ?? true),
|
646
650
|
encryption: this.encryptionType,
|
647
651
|
stereo: isStereo,
|
648
|
-
|
652
|
+
disableRed: !(opts.red ?? true),
|
649
653
|
});
|
650
654
|
|
651
655
|
// compute encodings and layers for video
|
@@ -128,8 +128,23 @@ export default abstract class LocalTrack extends Track {
|
|
128
128
|
newTrack.addEventListener('unmute', this.handleTrackUnmuteEvent);
|
129
129
|
this._constraints = newTrack.getConstraints();
|
130
130
|
}
|
131
|
+
let processedTrack: MediaStreamTrack | undefined;
|
132
|
+
if (this.processor && newTrack && this.processorElement) {
|
133
|
+
log.debug('restarting processor');
|
134
|
+
if (this.kind === 'unknown') {
|
135
|
+
throw TypeError('cannot set processor on track of unknown kind');
|
136
|
+
}
|
137
|
+
|
138
|
+
attachToElement(newTrack, this.processorElement);
|
139
|
+
await this.processor.restart({
|
140
|
+
track: newTrack,
|
141
|
+
kind: this.kind,
|
142
|
+
element: this.processorElement,
|
143
|
+
});
|
144
|
+
processedTrack = this.processor.processedTrack;
|
145
|
+
}
|
131
146
|
if (this.sender) {
|
132
|
-
await this.sender.replaceTrack(newTrack);
|
147
|
+
await this.sender.replaceTrack(processedTrack ?? newTrack);
|
133
148
|
}
|
134
149
|
this._mediaStreamTrack = newTrack;
|
135
150
|
if (newTrack) {
|
@@ -138,7 +153,7 @@ export default abstract class LocalTrack extends Track {
|
|
138
153
|
// when a valid track is replace, we'd want to start producing
|
139
154
|
await this.resumeUpstream();
|
140
155
|
this.attachedElements.forEach((el) => {
|
141
|
-
attachToElement(newTrack, el);
|
156
|
+
attachToElement(processedTrack ?? newTrack, el);
|
142
157
|
});
|
143
158
|
}
|
144
159
|
}
|
@@ -236,14 +251,7 @@ export default abstract class LocalTrack extends Track {
|
|
236
251
|
|
237
252
|
await this.setMediaStreamTrack(newTrack);
|
238
253
|
this._constraints = constraints;
|
239
|
-
|
240
|
-
const processor = this.processor;
|
241
|
-
await this.setProcessor(processor);
|
242
|
-
} else {
|
243
|
-
this.attachedElements.forEach((el) => {
|
244
|
-
attachToElement(this._mediaStreamTrack, el);
|
245
|
-
});
|
246
|
-
}
|
254
|
+
|
247
255
|
this.emit(TrackEvent.Restarted, this);
|
248
256
|
return this;
|
249
257
|
}
|
@@ -29,7 +29,8 @@ export interface TrackProcessor<
|
|
29
29
|
U extends ProcessorOptions<T> = ProcessorOptions<T>,
|
30
30
|
> {
|
31
31
|
name: string;
|
32
|
-
init: (opts: U) => void
|
32
|
+
init: (opts: U) => Promise<void>;
|
33
|
+
restart: (opts: U) => Promise<void>;
|
33
34
|
destroy: () => Promise<void>;
|
34
35
|
processedTrack?: MediaStreamTrack;
|
35
36
|
}
|