livekit-client 2.11.4 → 2.12.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.
Files changed (54) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +25 -14
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +100 -15
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/api/SignalClient.d.ts +2 -1
  10. package/dist/src/api/SignalClient.d.ts.map +1 -1
  11. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  12. package/dist/src/e2ee/KeyProvider.d.ts +8 -5
  13. package/dist/src/e2ee/KeyProvider.d.ts.map +1 -1
  14. package/dist/src/e2ee/events.d.ts +8 -3
  15. package/dist/src/e2ee/events.d.ts.map +1 -1
  16. package/dist/src/e2ee/types.d.ts +5 -1
  17. package/dist/src/e2ee/types.d.ts.map +1 -1
  18. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  19. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +4 -4
  20. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
  21. package/dist/src/room/RTCEngine.d.ts +2 -1
  22. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  23. package/dist/src/room/Room.d.ts +1 -0
  24. package/dist/src/room/Room.d.ts.map +1 -1
  25. package/dist/src/room/events.d.ts +11 -1
  26. package/dist/src/room/events.d.ts.map +1 -1
  27. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  28. package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
  29. package/dist/src/version.d.ts +1 -1
  30. package/dist/ts4.2/src/api/SignalClient.d.ts +2 -1
  31. package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +8 -5
  32. package/dist/ts4.2/src/e2ee/events.d.ts +8 -3
  33. package/dist/ts4.2/src/e2ee/types.d.ts +5 -1
  34. package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +4 -4
  35. package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -1
  36. package/dist/ts4.2/src/room/Room.d.ts +1 -0
  37. package/dist/ts4.2/src/room/events.d.ts +11 -1
  38. package/dist/ts4.2/src/version.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/src/api/SignalClient.ts +10 -0
  41. package/src/e2ee/E2eeManager.ts +6 -1
  42. package/src/e2ee/KeyProvider.ts +13 -6
  43. package/src/e2ee/events.ts +12 -3
  44. package/src/e2ee/types.ts +8 -1
  45. package/src/e2ee/worker/FrameCryptor.ts +8 -4
  46. package/src/e2ee/worker/ParticipantKeyHandler.test.ts +104 -4
  47. package/src/e2ee/worker/ParticipantKeyHandler.ts +22 -23
  48. package/src/e2ee/worker/e2ee.worker.ts +7 -2
  49. package/src/room/RTCEngine.ts +7 -0
  50. package/src/room/Room.ts +20 -0
  51. package/src/room/events.ts +11 -0
  52. package/src/room/participant/LocalParticipant.ts +0 -5
  53. package/src/room/track/RemoteAudioTrack.ts +3 -2
  54. package/src/version.ts +1 -1
@@ -3884,6 +3884,9 @@ const DisconnectReason = /* @__PURE__ */proto3.makeEnum("livekit.DisconnectReaso
3884
3884
  }, {
3885
3885
  no: 13,
3886
3886
  name: "SIP_TRUNK_FAILURE"
3887
+ }, {
3888
+ no: 14,
3889
+ name: "CONNECTION_TIMEOUT"
3887
3890
  }]);
3888
3891
  const ReconnectReason = /* @__PURE__ */proto3.makeEnum("livekit.ReconnectReason", [{
3889
3892
  no: 0,
@@ -3929,6 +3932,9 @@ const AudioTrackFeature = /* @__PURE__ */proto3.makeEnum("livekit.AudioTrackFeat
3929
3932
  }, {
3930
3933
  no: 5,
3931
3934
  name: "TF_ENHANCED_NOISE_CANCELLATION"
3935
+ }, {
3936
+ no: 6,
3937
+ name: "TF_PRECONNECT_BUFFER"
3932
3938
  }]);
3933
3939
  const Room$1 = /* @__PURE__ */proto3.makeMessageType("livekit.Room", () => [{
3934
3940
  no: 1,
@@ -4929,6 +4935,9 @@ const ClientInfo_SDK = /* @__PURE__ */proto3.makeEnum("livekit.ClientInfo.SDK",
4929
4935
  }, {
4930
4936
  no: 12,
4931
4937
  name: "NODE"
4938
+ }, {
4939
+ no: 13,
4940
+ name: "UNREAL"
4932
4941
  }]);
4933
4942
  const ClientConfiguration = /* @__PURE__ */proto3.makeMessageType("livekit.ClientConfiguration", () => [{
4934
4943
  no: 1,
@@ -5419,6 +5428,12 @@ const SignalResponse = /* @__PURE__ */proto3.makeMessageType("livekit.SignalResp
5419
5428
  kind: "message",
5420
5429
  T: TrackSubscribed,
5421
5430
  oneof: "message"
5431
+ }, {
5432
+ no: 24,
5433
+ name: "room_moved",
5434
+ kind: "message",
5435
+ T: RoomMovedResponse,
5436
+ oneof: "message"
5422
5437
  }]);
5423
5438
  const SimulcastCodec = /* @__PURE__ */proto3.makeMessageType("livekit.SimulcastCodec", () => [{
5424
5439
  no: 1,
@@ -5525,6 +5540,12 @@ const AddTrackRequest = /* @__PURE__ */proto3.makeMessageType("livekit.AddTrackR
5525
5540
  name: "backup_codec_policy",
5526
5541
  kind: "enum",
5527
5542
  T: proto3.getEnumType(BackupCodecPolicy$1)
5543
+ }, {
5544
+ no: 17,
5545
+ name: "audio_features",
5546
+ kind: "enum",
5547
+ T: proto3.getEnumType(AudioTrackFeature),
5548
+ repeated: true
5528
5549
  }]);
5529
5550
  const TrickleRequest = /* @__PURE__ */proto3.makeMessageType("livekit.TrickleRequest", () => [{
5530
5551
  no: 1,
@@ -6045,6 +6066,29 @@ const SubscriptionPermissionUpdate = /* @__PURE__ */proto3.makeMessageType("live
6045
6066
  T: 8
6046
6067
  /* ScalarType.BOOL */
6047
6068
  }]);
6069
+ const RoomMovedResponse = /* @__PURE__ */proto3.makeMessageType("livekit.RoomMovedResponse", () => [{
6070
+ no: 1,
6071
+ name: "room",
6072
+ kind: "message",
6073
+ T: Room$1
6074
+ }, {
6075
+ no: 2,
6076
+ name: "token",
6077
+ kind: "scalar",
6078
+ T: 9
6079
+ /* ScalarType.STRING */
6080
+ }, {
6081
+ no: 3,
6082
+ name: "participant",
6083
+ kind: "message",
6084
+ T: ParticipantInfo
6085
+ }, {
6086
+ no: 4,
6087
+ name: "other_participants",
6088
+ kind: "message",
6089
+ T: ParticipantInfo,
6090
+ repeated: true
6091
+ }]);
6048
6092
  const SyncState = /* @__PURE__ */proto3.makeMessageType("livekit.SyncState", () => [{
6049
6093
  no: 1,
6050
6094
  name: "answer",
@@ -10162,11 +10206,16 @@ const KEY_PROVIDER_DEFAULTS = {
10162
10206
  var KeyProviderEvent;
10163
10207
  (function (KeyProviderEvent) {
10164
10208
  KeyProviderEvent["SetKey"] = "setKey";
10209
+ /** Event for requesting to ratchet the key used to encrypt the stream */
10165
10210
  KeyProviderEvent["RatchetRequest"] = "ratchetRequest";
10211
+ /** Emitted when a key is ratcheted. Could be after auto-ratcheting on decryption failure or
10212
+ * following a `RatchetRequest`, will contain the ratcheted key material */
10166
10213
  KeyProviderEvent["KeyRatcheted"] = "keyRatcheted";
10167
10214
  })(KeyProviderEvent || (KeyProviderEvent = {}));
10168
10215
  var KeyHandlerEvent;
10169
10216
  (function (KeyHandlerEvent) {
10217
+ /** Emitted when a key has been ratcheted. Is emitted when any key has been ratcheted
10218
+ * i.e. when the FrameCryptor tried to ratchet when decryption is failing */
10170
10219
  KeyHandlerEvent["KeyRatcheted"] = "keyRatcheted";
10171
10220
  })(KeyHandlerEvent || (KeyHandlerEvent = {}));
10172
10221
  var EncryptionEvent;
@@ -10335,14 +10384,18 @@ class BaseKeyProvider extends eventsExports.EventEmitter {
10335
10384
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10336
10385
  super();
10337
10386
  /**
10338
- * callback being invoked after a ratchet request has been performed on a participant
10339
- * that surfaces the new key material.
10340
- * @param material
10387
+ * Callback being invoked after a key has been ratcheted.
10388
+ * Can happen when:
10389
+ * - A decryption failure occurs and the key is auto-ratcheted
10390
+ * - A ratchet request is sent (see {@link ratchetKey()})
10391
+ * @param ratchetResult Contains the ratcheted chain key (exportable to other participants) and the derived new key material.
10392
+ * @param participantId
10341
10393
  * @param keyIndex
10342
10394
  */
10343
- this.onKeyRatcheted = (material, keyIndex) => {
10395
+ this.onKeyRatcheted = (ratchetResult, participantId, keyIndex) => {
10344
10396
  livekitLogger.debug('key ratcheted event received', {
10345
- material,
10397
+ ratchetResult,
10398
+ participantId,
10346
10399
  keyIndex
10347
10400
  });
10348
10401
  };
@@ -10577,6 +10630,15 @@ var RoomEvent;
10577
10630
  * args: ([[ConnectionState]])
10578
10631
  */
10579
10632
  RoomEvent["ConnectionStateChanged"] = "connectionStateChanged";
10633
+ /**
10634
+ * When participant has been moved to a different room by the service request.
10635
+ * The behavior looks like the participant has been disconnected and reconnected to a different room
10636
+ * seamlessly without connection state transition.
10637
+ * A new token will be provided for reconnecting to the new room if needed.
10638
+ *
10639
+ * args: ([[room: string, token: string]])
10640
+ */
10641
+ RoomEvent["Moved"] = "moved";
10580
10642
  /**
10581
10643
  * When input or output devices on the machine have changed.
10582
10644
  */
@@ -11028,6 +11090,7 @@ var EngineEvent;
11028
11090
  EngineEvent["Offline"] = "offline";
11029
11091
  EngineEvent["SignalRequestResponse"] = "signalRequestResponse";
11030
11092
  EngineEvent["SignalConnected"] = "signalConnected";
11093
+ EngineEvent["RoomMoved"] = "roomMoved";
11031
11094
  })(EngineEvent || (EngineEvent = {}));
11032
11095
  var TrackEvent;
11033
11096
  (function (TrackEvent) {
@@ -11186,10 +11249,10 @@ function getOSVersion(ua) {
11186
11249
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11187
11250
  }
11188
11251
 
11189
- var version$1 = "2.11.4";
11252
+ var version$1 = "2.12.0";
11190
11253
 
11191
11254
  const version = version$1;
11192
- const protocolVersion = 15;
11255
+ const protocolVersion = 16;
11193
11256
 
11194
11257
  /**
11195
11258
  * Timers that can be overridden with platform specific implementations
@@ -12547,7 +12610,7 @@ class E2EEManager extends eventsExports.EventEmitter {
12547
12610
  }
12548
12611
  break;
12549
12612
  case 'ratchetKey':
12550
- this.keyProvider.emit(KeyProviderEvent.KeyRatcheted, data.material, data.keyIndex);
12613
+ this.keyProvider.emit(KeyProviderEvent.KeyRatcheted, data.ratchetResult, data.participantIdentity, data.keyIndex);
12551
12614
  break;
12552
12615
  }
12553
12616
  };
@@ -13540,6 +13603,13 @@ class SignalClient {
13540
13603
  if (this.onLocalTrackSubscribed) {
13541
13604
  this.onLocalTrackSubscribed(msg.value.trackSid);
13542
13605
  }
13606
+ } else if (msg.case === 'roomMoved') {
13607
+ if (this.onTokenRefresh) {
13608
+ this.onTokenRefresh(msg.value.token);
13609
+ }
13610
+ if (this.onRoomMoved) {
13611
+ this.onRoomMoved(msg.value);
13612
+ }
13543
13613
  } else {
13544
13614
  this.log.debug('unsupported message', Object.assign(Object.assign({}, this.logContext), {
13545
13615
  msgCase: msg.case
@@ -17644,6 +17714,11 @@ class RTCEngine extends eventsExports.EventEmitter {
17644
17714
  this.client.onSubscribedQualityUpdate = update => {
17645
17715
  this.emit(EngineEvent.SubscribedQualityUpdate, update);
17646
17716
  };
17717
+ this.client.onRoomMoved = res => {
17718
+ var _a;
17719
+ this.participantSid = (_a = res.participant) === null || _a === void 0 ? void 0 : _a.sid;
17720
+ this.emit(EngineEvent.RoomMoved, res);
17721
+ };
17647
17722
  this.client.onClose = () => {
17648
17723
  this.handleDisconnect('signal', ReconnectReason.RR_SIGNAL_DISCONNECTED);
17649
17724
  };
@@ -18797,8 +18872,9 @@ class RemoteAudioTrack extends RemoteTrack {
18797
18872
  super.attach(element);
18798
18873
  }
18799
18874
  if (this.sinkId && supportsSetSinkId(element)) {
18800
- /* @ts-ignore */
18801
- element.setSinkId(this.sinkId);
18875
+ element.setSinkId(this.sinkId).catch(e => {
18876
+ this.log.error('Failed to set sink id on remote audio track', e, this.logContext);
18877
+ });
18802
18878
  }
18803
18879
  if (this.audioContext && needsNewWebAudioConnection) {
18804
18880
  this.log.debug('using audio context mapping', this.logContext);
@@ -21600,11 +21676,6 @@ class LocalParticipant extends Participant {
21600
21676
  }
21601
21677
  /** @internal */
21602
21678
  updateInfo(info) {
21603
- if (info.sid !== this.sid) {
21604
- // drop updates that specify a wrong sid.
21605
- // the sid for local participant is only explicitly set on join and full reconnect
21606
- return false;
21607
- }
21608
21679
  if (!super.updateInfo(info)) {
21609
21680
  return false;
21610
21681
  }
@@ -23228,6 +23299,20 @@ class Room extends eventsExports.EventEmitter {
23228
23299
  }
23229
23300
  this.localParticipant.emit(ParticipantEvent.LocalTrackSubscribed, trackPublication);
23230
23301
  this.emitWhenConnected(RoomEvent.LocalTrackSubscribed, trackPublication, this.localParticipant);
23302
+ }).on(EngineEvent.RoomMoved, roomMoved => {
23303
+ this.log.debug('room moved', roomMoved);
23304
+ if (roomMoved.room) {
23305
+ this.handleRoomUpdate(roomMoved.room);
23306
+ }
23307
+ this.remoteParticipants.forEach((participant, identity) => {
23308
+ this.handleParticipantDisconnected(identity, participant);
23309
+ });
23310
+ this.emit(RoomEvent.Moved, roomMoved.room.name, roomMoved.token);
23311
+ if (roomMoved.participant) {
23312
+ this.handleParticipantUpdates([roomMoved.participant, ...roomMoved.otherParticipants]);
23313
+ } else {
23314
+ this.handleParticipantUpdates(roomMoved.otherParticipants);
23315
+ }
23231
23316
  });
23232
23317
  if (this.localParticipant) {
23233
23318
  this.localParticipant.setupEngine(this.engine);