livekit-client 2.15.6 → 2.15.8

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 (173) 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 +253 -118
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +1892 -153
  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/connectionHelper/checks/publishVideo.d.ts.map +1 -1
  10. package/dist/src/e2ee/E2eeManager.d.ts +16 -2
  11. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  12. package/dist/src/e2ee/types.d.ts +35 -1
  13. package/dist/src/e2ee/types.d.ts.map +1 -1
  14. package/dist/src/e2ee/utils.d.ts +2 -0
  15. package/dist/src/e2ee/utils.d.ts.map +1 -1
  16. package/dist/src/e2ee/worker/DataCryptor.d.ts +15 -0
  17. package/dist/src/e2ee/worker/DataCryptor.d.ts.map +1 -0
  18. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +3 -2
  19. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
  20. package/dist/src/e2ee/worker/sifPayload.d.ts +6 -6
  21. package/dist/src/e2ee/worker/sifPayload.d.ts.map +1 -1
  22. package/dist/src/index.d.ts +5 -3
  23. package/dist/src/index.d.ts.map +1 -1
  24. package/dist/src/logger.d.ts +1 -0
  25. package/dist/src/logger.d.ts.map +1 -1
  26. package/dist/src/options.d.ts +4 -2
  27. package/dist/src/options.d.ts.map +1 -1
  28. package/dist/src/room/PCTransport.d.ts.map +1 -1
  29. package/dist/src/room/RTCEngine.d.ts +5 -2
  30. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  31. package/dist/src/room/Room.d.ts +3 -2
  32. package/dist/src/room/Room.d.ts.map +1 -1
  33. package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts +2 -2
  34. package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts.map +1 -1
  35. package/dist/src/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts.map +1 -1
  36. package/dist/src/room/errors.d.ts +2 -1
  37. package/dist/src/room/errors.d.ts.map +1 -1
  38. package/dist/src/room/participant/LocalParticipant.d.ts +1 -3
  39. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  40. package/dist/src/room/participant/Participant.d.ts +2 -2
  41. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  42. package/dist/src/room/token-source/TokenSource.d.ts +70 -0
  43. package/dist/src/room/token-source/TokenSource.d.ts.map +1 -0
  44. package/dist/src/room/token-source/types.d.ts +68 -0
  45. package/dist/src/room/token-source/types.d.ts.map +1 -0
  46. package/dist/src/room/token-source/utils.d.ts +5 -0
  47. package/dist/src/room/token-source/utils.d.ts.map +1 -0
  48. package/dist/src/room/track/LocalTrack.d.ts +1 -1
  49. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  50. package/dist/src/room/track/options.d.ts +7 -3
  51. package/dist/src/room/track/options.d.ts.map +1 -1
  52. package/dist/src/room/track/utils.d.ts.map +1 -1
  53. package/dist/src/room/types.d.ts +1 -0
  54. package/dist/src/room/types.d.ts.map +1 -1
  55. package/dist/src/room/utils.d.ts +2 -1
  56. package/dist/src/room/utils.d.ts.map +1 -1
  57. package/dist/src/utils/camelToSnakeCase.d.ts +8 -0
  58. package/dist/src/utils/camelToSnakeCase.d.ts.map +1 -0
  59. package/dist/ts4.2/{src/e2ee → e2ee}/E2eeManager.d.ts +16 -2
  60. package/dist/ts4.2/{src/e2ee → e2ee}/types.d.ts +35 -1
  61. package/dist/ts4.2/{src/e2ee → e2ee}/utils.d.ts +3 -0
  62. package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +15 -0
  63. package/dist/ts4.2/{src/e2ee → e2ee}/worker/ParticipantKeyHandler.d.ts +3 -2
  64. package/dist/ts4.2/{src/e2ee → e2ee}/worker/sifPayload.d.ts +6 -6
  65. package/dist/ts4.2/{src/index.d.ts → index.d.ts} +5 -3
  66. package/dist/ts4.2/{src/logger.d.ts → logger.d.ts} +1 -0
  67. package/dist/ts4.2/{src/options.d.ts → options.d.ts} +4 -2
  68. package/dist/ts4.2/{src/room → room}/RTCEngine.d.ts +5 -2
  69. package/dist/ts4.2/{src/room → room}/Room.d.ts +3 -2
  70. package/dist/ts4.2/{src/room → room}/data-stream/incoming/IncomingDataStreamManager.d.ts +2 -1
  71. package/dist/ts4.2/{src/room → room}/errors.d.ts +2 -1
  72. package/dist/ts4.2/{src/room → room}/participant/LocalParticipant.d.ts +1 -3
  73. package/dist/ts4.2/{src/room → room}/participant/Participant.d.ts +2 -2
  74. package/dist/ts4.2/room/token-source/TokenSource.d.ts +71 -0
  75. package/dist/ts4.2/room/token-source/types.d.ts +68 -0
  76. package/dist/ts4.2/room/token-source/utils.d.ts +5 -0
  77. package/dist/ts4.2/{src/room → room}/track/LocalTrack.d.ts +1 -1
  78. package/dist/ts4.2/{src/room → room}/track/options.d.ts +10 -3
  79. package/dist/ts4.2/{src/room → room}/types.d.ts +1 -0
  80. package/dist/ts4.2/{src/room → room}/utils.d.ts +2 -1
  81. package/dist/ts4.2/utils/camelToSnakeCase.d.ts +8 -0
  82. package/package.json +14 -12
  83. package/src/connectionHelper/checks/publishVideo.ts +5 -0
  84. package/src/e2ee/E2eeManager.ts +94 -2
  85. package/src/e2ee/types.ts +44 -1
  86. package/src/e2ee/utils.ts +16 -0
  87. package/src/e2ee/worker/DataCryptor.test.ts +271 -0
  88. package/src/e2ee/worker/DataCryptor.ts +147 -0
  89. package/src/e2ee/worker/ParticipantKeyHandler.ts +4 -3
  90. package/src/e2ee/worker/e2ee.worker.ts +47 -0
  91. package/src/e2ee/worker/sifPayload.ts +10 -6
  92. package/src/index.ts +14 -1
  93. package/src/logger.ts +1 -0
  94. package/src/options.ts +8 -2
  95. package/src/room/PCTransport.ts +14 -5
  96. package/src/room/RTCEngine.ts +55 -6
  97. package/src/room/Room.ts +39 -17
  98. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +64 -17
  99. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +7 -0
  100. package/src/room/errors.ts +3 -0
  101. package/src/room/participant/LocalParticipant.ts +17 -29
  102. package/src/room/participant/Participant.ts +6 -1
  103. package/src/room/token-source/TokenSource.ts +285 -0
  104. package/src/room/token-source/types.ts +84 -0
  105. package/src/room/token-source/utils.ts +35 -0
  106. package/src/room/track/LocalAudioTrack.ts +1 -1
  107. package/src/room/track/LocalTrack.ts +1 -1
  108. package/src/room/track/options.ts +12 -4
  109. package/src/room/track/utils.ts +10 -2
  110. package/src/room/types.ts +1 -0
  111. package/src/room/utils.ts +8 -4
  112. package/src/utils/camelToSnakeCase.ts +16 -0
  113. /package/dist/ts4.2/{src/api → api}/SignalClient.d.ts +0 -0
  114. /package/dist/ts4.2/{src/api → api}/utils.d.ts +0 -0
  115. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/ConnectionCheck.d.ts +0 -0
  116. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/Checker.d.ts +0 -0
  117. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/cloudRegion.d.ts +0 -0
  118. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/connectionProtocol.d.ts +0 -0
  119. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/publishAudio.d.ts +0 -0
  120. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/publishVideo.d.ts +0 -0
  121. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/reconnect.d.ts +0 -0
  122. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/turn.d.ts +0 -0
  123. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/webrtc.d.ts +0 -0
  124. /package/dist/ts4.2/{src/connectionHelper → connectionHelper}/checks/websocket.d.ts +0 -0
  125. /package/dist/ts4.2/{src/e2ee → e2ee}/KeyProvider.d.ts +0 -0
  126. /package/dist/ts4.2/{src/e2ee → e2ee}/constants.d.ts +0 -0
  127. /package/dist/ts4.2/{src/e2ee → e2ee}/errors.d.ts +0 -0
  128. /package/dist/ts4.2/{src/e2ee → e2ee}/events.d.ts +0 -0
  129. /package/dist/ts4.2/{src/e2ee → e2ee}/index.d.ts +0 -0
  130. /package/dist/ts4.2/{src/e2ee → e2ee}/worker/FrameCryptor.d.ts +0 -0
  131. /package/dist/ts4.2/{src/e2ee → e2ee}/worker/e2ee.worker.d.ts +0 -0
  132. /package/dist/ts4.2/{src/e2ee → e2ee}/worker/naluUtils.d.ts +0 -0
  133. /package/dist/ts4.2/{src/room → room}/DefaultReconnectPolicy.d.ts +0 -0
  134. /package/dist/ts4.2/{src/room → room}/DeviceManager.d.ts +0 -0
  135. /package/dist/ts4.2/{src/room → room}/PCTransport.d.ts +0 -0
  136. /package/dist/ts4.2/{src/room → room}/PCTransportManager.d.ts +0 -0
  137. /package/dist/ts4.2/{src/room → room}/ReconnectPolicy.d.ts +0 -0
  138. /package/dist/ts4.2/{src/room → room}/RegionUrlProvider.d.ts +0 -0
  139. /package/dist/ts4.2/{src/room → room}/attribute-typings.d.ts +0 -0
  140. /package/dist/ts4.2/{src/room → room}/data-stream/incoming/StreamReader.d.ts +0 -0
  141. /package/dist/ts4.2/{src/room → room}/data-stream/outgoing/OutgoingDataStreamManager.d.ts +0 -0
  142. /package/dist/ts4.2/{src/room → room}/data-stream/outgoing/StreamWriter.d.ts +0 -0
  143. /package/dist/ts4.2/{src/room → room}/defaults.d.ts +0 -0
  144. /package/dist/ts4.2/{src/room → room}/events.d.ts +0 -0
  145. /package/dist/ts4.2/{src/room → room}/participant/ParticipantTrackPermission.d.ts +0 -0
  146. /package/dist/ts4.2/{src/room → room}/participant/RemoteParticipant.d.ts +0 -0
  147. /package/dist/ts4.2/{src/room → room}/participant/publishUtils.d.ts +0 -0
  148. /package/dist/ts4.2/{src/room → room}/rpc.d.ts +0 -0
  149. /package/dist/ts4.2/{src/room → room}/stats.d.ts +0 -0
  150. /package/dist/ts4.2/{src/room → room}/timers.d.ts +0 -0
  151. /package/dist/ts4.2/{src/room → room}/track/LocalAudioTrack.d.ts +0 -0
  152. /package/dist/ts4.2/{src/room → room}/track/LocalTrackPublication.d.ts +0 -0
  153. /package/dist/ts4.2/{src/room → room}/track/LocalVideoTrack.d.ts +0 -0
  154. /package/dist/ts4.2/{src/room → room}/track/RemoteAudioTrack.d.ts +0 -0
  155. /package/dist/ts4.2/{src/room → room}/track/RemoteTrack.d.ts +0 -0
  156. /package/dist/ts4.2/{src/room → room}/track/RemoteTrackPublication.d.ts +0 -0
  157. /package/dist/ts4.2/{src/room → room}/track/RemoteVideoTrack.d.ts +0 -0
  158. /package/dist/ts4.2/{src/room → room}/track/Track.d.ts +0 -0
  159. /package/dist/ts4.2/{src/room → room}/track/TrackPublication.d.ts +0 -0
  160. /package/dist/ts4.2/{src/room → room}/track/create.d.ts +0 -0
  161. /package/dist/ts4.2/{src/room → room}/track/facingMode.d.ts +0 -0
  162. /package/dist/ts4.2/{src/room → room}/track/processor/types.d.ts +0 -0
  163. /package/dist/ts4.2/{src/room → room}/track/record.d.ts +0 -0
  164. /package/dist/ts4.2/{src/room → room}/track/types.d.ts +0 -0
  165. /package/dist/ts4.2/{src/room → room}/track/utils.d.ts +0 -0
  166. /package/dist/ts4.2/{src/test → test}/MockMediaStreamTrack.d.ts +0 -0
  167. /package/dist/ts4.2/{src/test → test}/mocks.d.ts +0 -0
  168. /package/dist/ts4.2/{src/utils → utils}/AsyncQueue.d.ts +0 -0
  169. /package/dist/ts4.2/{src/utils → utils}/browserParser.d.ts +0 -0
  170. /package/dist/ts4.2/{src/utils → utils}/cloneDeep.d.ts +0 -0
  171. /package/dist/ts4.2/{src/utils → utils}/dataPacketBuffer.d.ts +0 -0
  172. /package/dist/ts4.2/{src/utils → utils}/ttlmap.d.ts +0 -0
  173. /package/dist/ts4.2/{src/version.d.ts → version.d.ts} +0 -0
@@ -3780,6 +3780,42 @@ const EventMetric = /* @__PURE__ */proto3.makeMessageType("livekit.EventMetric",
3780
3780
  T: 13
3781
3781
  /* ScalarType.UINT32 */
3782
3782
  }]);
3783
+ const AudioCodec = /* @__PURE__ */proto3.makeEnum("livekit.AudioCodec", [{
3784
+ no: 0,
3785
+ name: "DEFAULT_AC"
3786
+ }, {
3787
+ no: 1,
3788
+ name: "OPUS"
3789
+ }, {
3790
+ no: 2,
3791
+ name: "AAC"
3792
+ }, {
3793
+ no: 3,
3794
+ name: "AC_MP3"
3795
+ }]);
3796
+ const VideoCodec = /* @__PURE__ */proto3.makeEnum("livekit.VideoCodec", [{
3797
+ no: 0,
3798
+ name: "DEFAULT_VC"
3799
+ }, {
3800
+ no: 1,
3801
+ name: "H264_BASELINE"
3802
+ }, {
3803
+ no: 2,
3804
+ name: "H264_MAIN"
3805
+ }, {
3806
+ no: 3,
3807
+ name: "H264_HIGH"
3808
+ }, {
3809
+ no: 4,
3810
+ name: "VP8"
3811
+ }]);
3812
+ const ImageCodec = /* @__PURE__ */proto3.makeEnum("livekit.ImageCodec", [{
3813
+ no: 0,
3814
+ name: "IC_DEFAULT"
3815
+ }, {
3816
+ no: 1,
3817
+ name: "IC_JPEG"
3818
+ }]);
3783
3819
  const BackupCodecPolicy$1 = /* @__PURE__ */proto3.makeEnum("livekit.BackupCodecPolicy", [{
3784
3820
  no: 0,
3785
3821
  name: "PREFER_REGRESSION"
@@ -4268,6 +4304,17 @@ const SimulcastCodecInfo = /* @__PURE__ */proto3.makeMessageType("livekit.Simulc
4268
4304
  kind: "message",
4269
4305
  T: VideoLayer,
4270
4306
  repeated: true
4307
+ }, {
4308
+ no: 5,
4309
+ name: "video_layer_mode",
4310
+ kind: "enum",
4311
+ T: proto3.getEnumType(VideoLayer_Mode)
4312
+ }, {
4313
+ no: 6,
4314
+ name: "sdp_cid",
4315
+ kind: "scalar",
4316
+ T: 9
4317
+ /* ScalarType.STRING */
4271
4318
  }]);
4272
4319
  const TrackInfo = /* @__PURE__ */proto3.makeMessageType("livekit.TrackInfo", () => [{
4273
4320
  no: 1,
@@ -4427,6 +4474,19 @@ const VideoLayer = /* @__PURE__ */proto3.makeMessageType("livekit.VideoLayer", (
4427
4474
  T: 9
4428
4475
  /* ScalarType.STRING */
4429
4476
  }]);
4477
+ const VideoLayer_Mode = /* @__PURE__ */proto3.makeEnum("livekit.VideoLayer.Mode", [{
4478
+ no: 0,
4479
+ name: "MODE_UNUSED"
4480
+ }, {
4481
+ no: 1,
4482
+ name: "ONE_SPATIAL_LAYER_PER_STREAM"
4483
+ }, {
4484
+ no: 2,
4485
+ name: "MULTIPLE_SPATIAL_LAYERS_PER_STREAM"
4486
+ }, {
4487
+ no: 3,
4488
+ name: "ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"
4489
+ }]);
4430
4490
  const DataPacket = /* @__PURE__ */proto3.makeMessageType("livekit.DataPacket", () => [{
4431
4491
  no: 1,
4432
4492
  name: "kind",
@@ -4516,6 +4576,12 @@ const DataPacket = /* @__PURE__ */proto3.makeMessageType("livekit.DataPacket", (
4516
4576
  kind: "message",
4517
4577
  T: DataStream_Trailer,
4518
4578
  oneof: "value"
4579
+ }, {
4580
+ no: 18,
4581
+ name: "encrypted_packet",
4582
+ kind: "message",
4583
+ T: EncryptedPacket,
4584
+ oneof: "value"
4519
4585
  }, {
4520
4586
  no: 16,
4521
4587
  name: "sequence",
@@ -4536,6 +4602,79 @@ const DataPacket_Kind = /* @__PURE__ */proto3.makeEnum("livekit.DataPacket.Kind"
4536
4602
  no: 1,
4537
4603
  name: "LOSSY"
4538
4604
  }]);
4605
+ const EncryptedPacket = /* @__PURE__ */proto3.makeMessageType("livekit.EncryptedPacket", () => [{
4606
+ no: 1,
4607
+ name: "encryption_type",
4608
+ kind: "enum",
4609
+ T: proto3.getEnumType(Encryption_Type)
4610
+ }, {
4611
+ no: 2,
4612
+ name: "iv",
4613
+ kind: "scalar",
4614
+ T: 12
4615
+ /* ScalarType.BYTES */
4616
+ }, {
4617
+ no: 3,
4618
+ name: "key_index",
4619
+ kind: "scalar",
4620
+ T: 13
4621
+ /* ScalarType.UINT32 */
4622
+ }, {
4623
+ no: 4,
4624
+ name: "encrypted_value",
4625
+ kind: "scalar",
4626
+ T: 12
4627
+ /* ScalarType.BYTES */
4628
+ }]);
4629
+ const EncryptedPacketPayload = /* @__PURE__ */proto3.makeMessageType("livekit.EncryptedPacketPayload", () => [{
4630
+ no: 1,
4631
+ name: "user",
4632
+ kind: "message",
4633
+ T: UserPacket,
4634
+ oneof: "value"
4635
+ }, {
4636
+ no: 3,
4637
+ name: "chat_message",
4638
+ kind: "message",
4639
+ T: ChatMessage,
4640
+ oneof: "value"
4641
+ }, {
4642
+ no: 4,
4643
+ name: "rpc_request",
4644
+ kind: "message",
4645
+ T: RpcRequest,
4646
+ oneof: "value"
4647
+ }, {
4648
+ no: 5,
4649
+ name: "rpc_ack",
4650
+ kind: "message",
4651
+ T: RpcAck,
4652
+ oneof: "value"
4653
+ }, {
4654
+ no: 6,
4655
+ name: "rpc_response",
4656
+ kind: "message",
4657
+ T: RpcResponse,
4658
+ oneof: "value"
4659
+ }, {
4660
+ no: 7,
4661
+ name: "stream_header",
4662
+ kind: "message",
4663
+ T: DataStream_Header,
4664
+ oneof: "value"
4665
+ }, {
4666
+ no: 8,
4667
+ name: "stream_chunk",
4668
+ kind: "message",
4669
+ T: DataStream_Chunk,
4670
+ oneof: "value"
4671
+ }, {
4672
+ no: 9,
4673
+ name: "stream_trailer",
4674
+ kind: "message",
4675
+ T: DataStream_Trailer,
4676
+ oneof: "value"
4677
+ }]);
4539
4678
  const ActiveSpeakerUpdate = /* @__PURE__ */proto3.makeMessageType("livekit.ActiveSpeakerUpdate", () => [{
4540
4679
  no: 1,
4541
4680
  name: "speakers",
@@ -5111,104 +5250,883 @@ const DataStream_Header = /* @__PURE__ */proto3.makeMessageType("livekit.DataStr
5111
5250
  /* ScalarType.STRING */
5112
5251
  }, {
5113
5252
  no: 4,
5114
- name: "mime_type",
5253
+ name: "mime_type",
5254
+ kind: "scalar",
5255
+ T: 9
5256
+ /* ScalarType.STRING */
5257
+ }, {
5258
+ no: 5,
5259
+ name: "total_length",
5260
+ kind: "scalar",
5261
+ T: 4,
5262
+ opt: true
5263
+ }, {
5264
+ no: 7,
5265
+ name: "encryption_type",
5266
+ kind: "enum",
5267
+ T: proto3.getEnumType(Encryption_Type)
5268
+ }, {
5269
+ no: 8,
5270
+ name: "attributes",
5271
+ kind: "map",
5272
+ K: 9,
5273
+ V: {
5274
+ kind: "scalar",
5275
+ T: 9
5276
+ /* ScalarType.STRING */
5277
+ }
5278
+ }, {
5279
+ no: 9,
5280
+ name: "text_header",
5281
+ kind: "message",
5282
+ T: DataStream_TextHeader,
5283
+ oneof: "content_header"
5284
+ }, {
5285
+ no: 10,
5286
+ name: "byte_header",
5287
+ kind: "message",
5288
+ T: DataStream_ByteHeader,
5289
+ oneof: "content_header"
5290
+ }], {
5291
+ localName: "DataStream_Header"
5292
+ });
5293
+ const DataStream_Chunk = /* @__PURE__ */proto3.makeMessageType("livekit.DataStream.Chunk", () => [{
5294
+ no: 1,
5295
+ name: "stream_id",
5296
+ kind: "scalar",
5297
+ T: 9
5298
+ /* ScalarType.STRING */
5299
+ }, {
5300
+ no: 2,
5301
+ name: "chunk_index",
5302
+ kind: "scalar",
5303
+ T: 4
5304
+ /* ScalarType.UINT64 */
5305
+ }, {
5306
+ no: 3,
5307
+ name: "content",
5308
+ kind: "scalar",
5309
+ T: 12
5310
+ /* ScalarType.BYTES */
5311
+ }, {
5312
+ no: 4,
5313
+ name: "version",
5314
+ kind: "scalar",
5315
+ T: 5
5316
+ /* ScalarType.INT32 */
5317
+ }, {
5318
+ no: 5,
5319
+ name: "iv",
5320
+ kind: "scalar",
5321
+ T: 12,
5322
+ opt: true
5323
+ }], {
5324
+ localName: "DataStream_Chunk"
5325
+ });
5326
+ const DataStream_Trailer = /* @__PURE__ */proto3.makeMessageType("livekit.DataStream.Trailer", () => [{
5327
+ no: 1,
5328
+ name: "stream_id",
5329
+ kind: "scalar",
5330
+ T: 9
5331
+ /* ScalarType.STRING */
5332
+ }, {
5333
+ no: 2,
5334
+ name: "reason",
5335
+ kind: "scalar",
5336
+ T: 9
5337
+ /* ScalarType.STRING */
5338
+ }, {
5339
+ no: 3,
5340
+ name: "attributes",
5341
+ kind: "map",
5342
+ K: 9,
5343
+ V: {
5344
+ kind: "scalar",
5345
+ T: 9
5346
+ /* ScalarType.STRING */
5347
+ }
5348
+ }], {
5349
+ localName: "DataStream_Trailer"
5350
+ });
5351
+ const WebhookConfig = /* @__PURE__ */proto3.makeMessageType("livekit.WebhookConfig", () => [{
5352
+ no: 1,
5353
+ name: "url",
5354
+ kind: "scalar",
5355
+ T: 9
5356
+ /* ScalarType.STRING */
5357
+ }, {
5358
+ no: 2,
5359
+ name: "signing_key",
5360
+ kind: "scalar",
5361
+ T: 9
5362
+ /* ScalarType.STRING */
5363
+ }]);
5364
+ const SubscribedAudioCodec = /* @__PURE__ */proto3.makeMessageType("livekit.SubscribedAudioCodec", () => [{
5365
+ no: 1,
5366
+ name: "codec",
5367
+ kind: "scalar",
5368
+ T: 9
5369
+ /* ScalarType.STRING */
5370
+ }, {
5371
+ no: 2,
5372
+ name: "enabled",
5373
+ kind: "scalar",
5374
+ T: 8
5375
+ /* ScalarType.BOOL */
5376
+ }]);
5377
+ const RoomAgentDispatch = /* @__PURE__ */proto3.makeMessageType("livekit.RoomAgentDispatch", () => [{
5378
+ no: 1,
5379
+ name: "agent_name",
5380
+ kind: "scalar",
5381
+ T: 9
5382
+ /* ScalarType.STRING */
5383
+ }, {
5384
+ no: 2,
5385
+ name: "metadata",
5386
+ kind: "scalar",
5387
+ T: 9
5388
+ /* ScalarType.STRING */
5389
+ }]);
5390
+ const EncodedFileType = /* @__PURE__ */proto3.makeEnum("livekit.EncodedFileType", [{
5391
+ no: 0,
5392
+ name: "DEFAULT_FILETYPE"
5393
+ }, {
5394
+ no: 1,
5395
+ name: "MP4"
5396
+ }, {
5397
+ no: 2,
5398
+ name: "OGG"
5399
+ }, {
5400
+ no: 3,
5401
+ name: "MP3"
5402
+ }]);
5403
+ const SegmentedFileProtocol = /* @__PURE__ */proto3.makeEnum("livekit.SegmentedFileProtocol", [{
5404
+ no: 0,
5405
+ name: "DEFAULT_SEGMENTED_FILE_PROTOCOL"
5406
+ }, {
5407
+ no: 1,
5408
+ name: "HLS_PROTOCOL"
5409
+ }]);
5410
+ const SegmentedFileSuffix = /* @__PURE__ */proto3.makeEnum("livekit.SegmentedFileSuffix", [{
5411
+ no: 0,
5412
+ name: "INDEX"
5413
+ }, {
5414
+ no: 1,
5415
+ name: "TIMESTAMP"
5416
+ }]);
5417
+ const ImageFileSuffix = /* @__PURE__ */proto3.makeEnum("livekit.ImageFileSuffix", [{
5418
+ no: 0,
5419
+ name: "IMAGE_SUFFIX_INDEX"
5420
+ }, {
5421
+ no: 1,
5422
+ name: "IMAGE_SUFFIX_TIMESTAMP"
5423
+ }, {
5424
+ no: 2,
5425
+ name: "IMAGE_SUFFIX_NONE_OVERWRITE"
5426
+ }]);
5427
+ const StreamProtocol = /* @__PURE__ */proto3.makeEnum("livekit.StreamProtocol", [{
5428
+ no: 0,
5429
+ name: "DEFAULT_PROTOCOL"
5430
+ }, {
5431
+ no: 1,
5432
+ name: "RTMP"
5433
+ }, {
5434
+ no: 2,
5435
+ name: "SRT"
5436
+ }]);
5437
+ const AudioMixing = /* @__PURE__ */proto3.makeEnum("livekit.AudioMixing", [{
5438
+ no: 0,
5439
+ name: "DEFAULT_MIXING"
5440
+ }, {
5441
+ no: 1,
5442
+ name: "DUAL_CHANNEL_AGENT"
5443
+ }, {
5444
+ no: 2,
5445
+ name: "DUAL_CHANNEL_ALTERNATE"
5446
+ }]);
5447
+ const EncodingOptionsPreset = /* @__PURE__ */proto3.makeEnum("livekit.EncodingOptionsPreset", [{
5448
+ no: 0,
5449
+ name: "H264_720P_30"
5450
+ }, {
5451
+ no: 1,
5452
+ name: "H264_720P_60"
5453
+ }, {
5454
+ no: 2,
5455
+ name: "H264_1080P_30"
5456
+ }, {
5457
+ no: 3,
5458
+ name: "H264_1080P_60"
5459
+ }, {
5460
+ no: 4,
5461
+ name: "PORTRAIT_H264_720P_30"
5462
+ }, {
5463
+ no: 5,
5464
+ name: "PORTRAIT_H264_720P_60"
5465
+ }, {
5466
+ no: 6,
5467
+ name: "PORTRAIT_H264_1080P_30"
5468
+ }, {
5469
+ no: 7,
5470
+ name: "PORTRAIT_H264_1080P_60"
5471
+ }]);
5472
+ const RoomCompositeEgressRequest = /* @__PURE__ */proto3.makeMessageType("livekit.RoomCompositeEgressRequest", () => [{
5473
+ no: 1,
5474
+ name: "room_name",
5475
+ kind: "scalar",
5476
+ T: 9
5477
+ /* ScalarType.STRING */
5478
+ }, {
5479
+ no: 2,
5480
+ name: "layout",
5481
+ kind: "scalar",
5482
+ T: 9
5483
+ /* ScalarType.STRING */
5484
+ }, {
5485
+ no: 3,
5486
+ name: "audio_only",
5487
+ kind: "scalar",
5488
+ T: 8
5489
+ /* ScalarType.BOOL */
5490
+ }, {
5491
+ no: 15,
5492
+ name: "audio_mixing",
5493
+ kind: "enum",
5494
+ T: proto3.getEnumType(AudioMixing)
5495
+ }, {
5496
+ no: 4,
5497
+ name: "video_only",
5498
+ kind: "scalar",
5499
+ T: 8
5500
+ /* ScalarType.BOOL */
5501
+ }, {
5502
+ no: 5,
5503
+ name: "custom_base_url",
5504
+ kind: "scalar",
5505
+ T: 9
5506
+ /* ScalarType.STRING */
5507
+ }, {
5508
+ no: 6,
5509
+ name: "file",
5510
+ kind: "message",
5511
+ T: EncodedFileOutput,
5512
+ oneof: "output"
5513
+ }, {
5514
+ no: 7,
5515
+ name: "stream",
5516
+ kind: "message",
5517
+ T: StreamOutput,
5518
+ oneof: "output"
5519
+ }, {
5520
+ no: 10,
5521
+ name: "segments",
5522
+ kind: "message",
5523
+ T: SegmentedFileOutput,
5524
+ oneof: "output"
5525
+ }, {
5526
+ no: 8,
5527
+ name: "preset",
5528
+ kind: "enum",
5529
+ T: proto3.getEnumType(EncodingOptionsPreset),
5530
+ oneof: "options"
5531
+ }, {
5532
+ no: 9,
5533
+ name: "advanced",
5534
+ kind: "message",
5535
+ T: EncodingOptions,
5536
+ oneof: "options"
5537
+ }, {
5538
+ no: 11,
5539
+ name: "file_outputs",
5540
+ kind: "message",
5541
+ T: EncodedFileOutput,
5542
+ repeated: true
5543
+ }, {
5544
+ no: 12,
5545
+ name: "stream_outputs",
5546
+ kind: "message",
5547
+ T: StreamOutput,
5548
+ repeated: true
5549
+ }, {
5550
+ no: 13,
5551
+ name: "segment_outputs",
5552
+ kind: "message",
5553
+ T: SegmentedFileOutput,
5554
+ repeated: true
5555
+ }, {
5556
+ no: 14,
5557
+ name: "image_outputs",
5558
+ kind: "message",
5559
+ T: ImageOutput,
5560
+ repeated: true
5561
+ }, {
5562
+ no: 16,
5563
+ name: "webhooks",
5564
+ kind: "message",
5565
+ T: WebhookConfig,
5566
+ repeated: true
5567
+ }]);
5568
+ const EncodedFileOutput = /* @__PURE__ */proto3.makeMessageType("livekit.EncodedFileOutput", () => [{
5569
+ no: 1,
5570
+ name: "file_type",
5571
+ kind: "enum",
5572
+ T: proto3.getEnumType(EncodedFileType)
5573
+ }, {
5574
+ no: 2,
5575
+ name: "filepath",
5576
+ kind: "scalar",
5577
+ T: 9
5578
+ /* ScalarType.STRING */
5579
+ }, {
5580
+ no: 6,
5581
+ name: "disable_manifest",
5582
+ kind: "scalar",
5583
+ T: 8
5584
+ /* ScalarType.BOOL */
5585
+ }, {
5586
+ no: 3,
5587
+ name: "s3",
5588
+ kind: "message",
5589
+ T: S3Upload,
5590
+ oneof: "output"
5591
+ }, {
5592
+ no: 4,
5593
+ name: "gcp",
5594
+ kind: "message",
5595
+ T: GCPUpload,
5596
+ oneof: "output"
5597
+ }, {
5598
+ no: 5,
5599
+ name: "azure",
5600
+ kind: "message",
5601
+ T: AzureBlobUpload,
5602
+ oneof: "output"
5603
+ }, {
5604
+ no: 7,
5605
+ name: "aliOSS",
5606
+ kind: "message",
5607
+ T: AliOSSUpload,
5608
+ oneof: "output"
5609
+ }]);
5610
+ const SegmentedFileOutput = /* @__PURE__ */proto3.makeMessageType("livekit.SegmentedFileOutput", () => [{
5611
+ no: 1,
5612
+ name: "protocol",
5613
+ kind: "enum",
5614
+ T: proto3.getEnumType(SegmentedFileProtocol)
5615
+ }, {
5616
+ no: 2,
5617
+ name: "filename_prefix",
5618
+ kind: "scalar",
5619
+ T: 9
5620
+ /* ScalarType.STRING */
5621
+ }, {
5622
+ no: 3,
5623
+ name: "playlist_name",
5624
+ kind: "scalar",
5625
+ T: 9
5626
+ /* ScalarType.STRING */
5627
+ }, {
5628
+ no: 11,
5629
+ name: "live_playlist_name",
5630
+ kind: "scalar",
5631
+ T: 9
5632
+ /* ScalarType.STRING */
5633
+ }, {
5634
+ no: 4,
5635
+ name: "segment_duration",
5636
+ kind: "scalar",
5637
+ T: 13
5638
+ /* ScalarType.UINT32 */
5639
+ }, {
5640
+ no: 10,
5641
+ name: "filename_suffix",
5642
+ kind: "enum",
5643
+ T: proto3.getEnumType(SegmentedFileSuffix)
5644
+ }, {
5645
+ no: 8,
5646
+ name: "disable_manifest",
5647
+ kind: "scalar",
5648
+ T: 8
5649
+ /* ScalarType.BOOL */
5650
+ }, {
5651
+ no: 5,
5652
+ name: "s3",
5653
+ kind: "message",
5654
+ T: S3Upload,
5655
+ oneof: "output"
5656
+ }, {
5657
+ no: 6,
5658
+ name: "gcp",
5659
+ kind: "message",
5660
+ T: GCPUpload,
5661
+ oneof: "output"
5662
+ }, {
5663
+ no: 7,
5664
+ name: "azure",
5665
+ kind: "message",
5666
+ T: AzureBlobUpload,
5667
+ oneof: "output"
5668
+ }, {
5669
+ no: 9,
5670
+ name: "aliOSS",
5671
+ kind: "message",
5672
+ T: AliOSSUpload,
5673
+ oneof: "output"
5674
+ }]);
5675
+ const ImageOutput = /* @__PURE__ */proto3.makeMessageType("livekit.ImageOutput", () => [{
5676
+ no: 1,
5677
+ name: "capture_interval",
5678
+ kind: "scalar",
5679
+ T: 13
5680
+ /* ScalarType.UINT32 */
5681
+ }, {
5682
+ no: 2,
5683
+ name: "width",
5684
+ kind: "scalar",
5685
+ T: 5
5686
+ /* ScalarType.INT32 */
5687
+ }, {
5688
+ no: 3,
5689
+ name: "height",
5690
+ kind: "scalar",
5691
+ T: 5
5692
+ /* ScalarType.INT32 */
5693
+ }, {
5694
+ no: 4,
5695
+ name: "filename_prefix",
5696
+ kind: "scalar",
5697
+ T: 9
5698
+ /* ScalarType.STRING */
5699
+ }, {
5700
+ no: 5,
5701
+ name: "filename_suffix",
5702
+ kind: "enum",
5703
+ T: proto3.getEnumType(ImageFileSuffix)
5704
+ }, {
5705
+ no: 6,
5706
+ name: "image_codec",
5707
+ kind: "enum",
5708
+ T: proto3.getEnumType(ImageCodec)
5709
+ }, {
5710
+ no: 7,
5711
+ name: "disable_manifest",
5712
+ kind: "scalar",
5713
+ T: 8
5714
+ /* ScalarType.BOOL */
5715
+ }, {
5716
+ no: 8,
5717
+ name: "s3",
5718
+ kind: "message",
5719
+ T: S3Upload,
5720
+ oneof: "output"
5721
+ }, {
5722
+ no: 9,
5723
+ name: "gcp",
5724
+ kind: "message",
5725
+ T: GCPUpload,
5726
+ oneof: "output"
5727
+ }, {
5728
+ no: 10,
5729
+ name: "azure",
5730
+ kind: "message",
5731
+ T: AzureBlobUpload,
5732
+ oneof: "output"
5733
+ }, {
5734
+ no: 11,
5735
+ name: "aliOSS",
5736
+ kind: "message",
5737
+ T: AliOSSUpload,
5738
+ oneof: "output"
5739
+ }]);
5740
+ const S3Upload = /* @__PURE__ */proto3.makeMessageType("livekit.S3Upload", () => [{
5741
+ no: 1,
5742
+ name: "access_key",
5743
+ kind: "scalar",
5744
+ T: 9
5745
+ /* ScalarType.STRING */
5746
+ }, {
5747
+ no: 2,
5748
+ name: "secret",
5749
+ kind: "scalar",
5750
+ T: 9
5751
+ /* ScalarType.STRING */
5752
+ }, {
5753
+ no: 11,
5754
+ name: "session_token",
5755
+ kind: "scalar",
5756
+ T: 9
5757
+ /* ScalarType.STRING */
5758
+ }, {
5759
+ no: 12,
5760
+ name: "assume_role_arn",
5761
+ kind: "scalar",
5762
+ T: 9
5763
+ /* ScalarType.STRING */
5764
+ }, {
5765
+ no: 13,
5766
+ name: "assume_role_external_id",
5767
+ kind: "scalar",
5768
+ T: 9
5769
+ /* ScalarType.STRING */
5770
+ }, {
5771
+ no: 3,
5772
+ name: "region",
5773
+ kind: "scalar",
5774
+ T: 9
5775
+ /* ScalarType.STRING */
5776
+ }, {
5777
+ no: 4,
5778
+ name: "endpoint",
5779
+ kind: "scalar",
5780
+ T: 9
5781
+ /* ScalarType.STRING */
5782
+ }, {
5783
+ no: 5,
5784
+ name: "bucket",
5785
+ kind: "scalar",
5786
+ T: 9
5787
+ /* ScalarType.STRING */
5788
+ }, {
5789
+ no: 6,
5790
+ name: "force_path_style",
5791
+ kind: "scalar",
5792
+ T: 8
5793
+ /* ScalarType.BOOL */
5794
+ }, {
5795
+ no: 7,
5796
+ name: "metadata",
5797
+ kind: "map",
5798
+ K: 9,
5799
+ V: {
5800
+ kind: "scalar",
5801
+ T: 9
5802
+ /* ScalarType.STRING */
5803
+ }
5804
+ }, {
5805
+ no: 8,
5806
+ name: "tagging",
5807
+ kind: "scalar",
5808
+ T: 9
5809
+ /* ScalarType.STRING */
5810
+ }, {
5811
+ no: 9,
5812
+ name: "content_disposition",
5813
+ kind: "scalar",
5814
+ T: 9
5815
+ /* ScalarType.STRING */
5816
+ }, {
5817
+ no: 10,
5818
+ name: "proxy",
5819
+ kind: "message",
5820
+ T: ProxyConfig
5821
+ }]);
5822
+ const GCPUpload = /* @__PURE__ */proto3.makeMessageType("livekit.GCPUpload", () => [{
5823
+ no: 1,
5824
+ name: "credentials",
5825
+ kind: "scalar",
5826
+ T: 9
5827
+ /* ScalarType.STRING */
5828
+ }, {
5829
+ no: 2,
5830
+ name: "bucket",
5831
+ kind: "scalar",
5832
+ T: 9
5833
+ /* ScalarType.STRING */
5834
+ }, {
5835
+ no: 3,
5836
+ name: "proxy",
5837
+ kind: "message",
5838
+ T: ProxyConfig
5839
+ }]);
5840
+ const AzureBlobUpload = /* @__PURE__ */proto3.makeMessageType("livekit.AzureBlobUpload", () => [{
5841
+ no: 1,
5842
+ name: "account_name",
5843
+ kind: "scalar",
5844
+ T: 9
5845
+ /* ScalarType.STRING */
5846
+ }, {
5847
+ no: 2,
5848
+ name: "account_key",
5849
+ kind: "scalar",
5850
+ T: 9
5851
+ /* ScalarType.STRING */
5852
+ }, {
5853
+ no: 3,
5854
+ name: "container_name",
5855
+ kind: "scalar",
5856
+ T: 9
5857
+ /* ScalarType.STRING */
5858
+ }]);
5859
+ const AliOSSUpload = /* @__PURE__ */proto3.makeMessageType("livekit.AliOSSUpload", () => [{
5860
+ no: 1,
5861
+ name: "access_key",
5862
+ kind: "scalar",
5863
+ T: 9
5864
+ /* ScalarType.STRING */
5865
+ }, {
5866
+ no: 2,
5867
+ name: "secret",
5868
+ kind: "scalar",
5869
+ T: 9
5870
+ /* ScalarType.STRING */
5871
+ }, {
5872
+ no: 3,
5873
+ name: "region",
5874
+ kind: "scalar",
5875
+ T: 9
5876
+ /* ScalarType.STRING */
5877
+ }, {
5878
+ no: 4,
5879
+ name: "endpoint",
5880
+ kind: "scalar",
5881
+ T: 9
5882
+ /* ScalarType.STRING */
5883
+ }, {
5884
+ no: 5,
5885
+ name: "bucket",
5886
+ kind: "scalar",
5887
+ T: 9
5888
+ /* ScalarType.STRING */
5889
+ }]);
5890
+ const ProxyConfig = /* @__PURE__ */proto3.makeMessageType("livekit.ProxyConfig", () => [{
5891
+ no: 1,
5892
+ name: "url",
5893
+ kind: "scalar",
5894
+ T: 9
5895
+ /* ScalarType.STRING */
5896
+ }, {
5897
+ no: 2,
5898
+ name: "username",
5899
+ kind: "scalar",
5900
+ T: 9
5901
+ /* ScalarType.STRING */
5902
+ }, {
5903
+ no: 3,
5904
+ name: "password",
5905
+ kind: "scalar",
5906
+ T: 9
5907
+ /* ScalarType.STRING */
5908
+ }]);
5909
+ const StreamOutput = /* @__PURE__ */proto3.makeMessageType("livekit.StreamOutput", () => [{
5910
+ no: 1,
5911
+ name: "protocol",
5912
+ kind: "enum",
5913
+ T: proto3.getEnumType(StreamProtocol)
5914
+ }, {
5915
+ no: 2,
5916
+ name: "urls",
5917
+ kind: "scalar",
5918
+ T: 9,
5919
+ repeated: true
5920
+ }]);
5921
+ const EncodingOptions = /* @__PURE__ */proto3.makeMessageType("livekit.EncodingOptions", () => [{
5922
+ no: 1,
5923
+ name: "width",
5924
+ kind: "scalar",
5925
+ T: 5
5926
+ /* ScalarType.INT32 */
5927
+ }, {
5928
+ no: 2,
5929
+ name: "height",
5930
+ kind: "scalar",
5931
+ T: 5
5932
+ /* ScalarType.INT32 */
5933
+ }, {
5934
+ no: 3,
5935
+ name: "depth",
5936
+ kind: "scalar",
5937
+ T: 5
5938
+ /* ScalarType.INT32 */
5939
+ }, {
5940
+ no: 4,
5941
+ name: "framerate",
5942
+ kind: "scalar",
5943
+ T: 5
5944
+ /* ScalarType.INT32 */
5945
+ }, {
5946
+ no: 5,
5947
+ name: "audio_codec",
5948
+ kind: "enum",
5949
+ T: proto3.getEnumType(AudioCodec)
5950
+ }, {
5951
+ no: 6,
5952
+ name: "audio_bitrate",
5953
+ kind: "scalar",
5954
+ T: 5
5955
+ /* ScalarType.INT32 */
5956
+ }, {
5957
+ no: 11,
5958
+ name: "audio_quality",
5959
+ kind: "scalar",
5960
+ T: 5
5961
+ /* ScalarType.INT32 */
5962
+ }, {
5963
+ no: 7,
5964
+ name: "audio_frequency",
5965
+ kind: "scalar",
5966
+ T: 5
5967
+ /* ScalarType.INT32 */
5968
+ }, {
5969
+ no: 8,
5970
+ name: "video_codec",
5971
+ kind: "enum",
5972
+ T: proto3.getEnumType(VideoCodec)
5973
+ }, {
5974
+ no: 9,
5975
+ name: "video_bitrate",
5976
+ kind: "scalar",
5977
+ T: 5
5978
+ /* ScalarType.INT32 */
5979
+ }, {
5980
+ no: 12,
5981
+ name: "video_quality",
5982
+ kind: "scalar",
5983
+ T: 5
5984
+ /* ScalarType.INT32 */
5985
+ }, {
5986
+ no: 10,
5987
+ name: "key_frame_interval",
5988
+ kind: "scalar",
5989
+ T: 1
5990
+ /* ScalarType.DOUBLE */
5991
+ }]);
5992
+ const AutoParticipantEgress = /* @__PURE__ */proto3.makeMessageType("livekit.AutoParticipantEgress", () => [{
5993
+ no: 1,
5994
+ name: "preset",
5995
+ kind: "enum",
5996
+ T: proto3.getEnumType(EncodingOptionsPreset),
5997
+ oneof: "options"
5998
+ }, {
5999
+ no: 2,
6000
+ name: "advanced",
6001
+ kind: "message",
6002
+ T: EncodingOptions,
6003
+ oneof: "options"
6004
+ }, {
6005
+ no: 3,
6006
+ name: "file_outputs",
6007
+ kind: "message",
6008
+ T: EncodedFileOutput,
6009
+ repeated: true
6010
+ }, {
6011
+ no: 4,
6012
+ name: "segment_outputs",
6013
+ kind: "message",
6014
+ T: SegmentedFileOutput,
6015
+ repeated: true
6016
+ }]);
6017
+ const AutoTrackEgress = /* @__PURE__ */proto3.makeMessageType("livekit.AutoTrackEgress", () => [{
6018
+ no: 1,
6019
+ name: "filepath",
5115
6020
  kind: "scalar",
5116
6021
  T: 9
5117
6022
  /* ScalarType.STRING */
5118
6023
  }, {
5119
6024
  no: 5,
5120
- name: "total_length",
6025
+ name: "disable_manifest",
5121
6026
  kind: "scalar",
5122
- T: 4,
5123
- opt: true
6027
+ T: 8
6028
+ /* ScalarType.BOOL */
5124
6029
  }, {
5125
- no: 7,
5126
- name: "encryption_type",
5127
- kind: "enum",
5128
- T: proto3.getEnumType(Encryption_Type)
6030
+ no: 2,
6031
+ name: "s3",
6032
+ kind: "message",
6033
+ T: S3Upload,
6034
+ oneof: "output"
5129
6035
  }, {
5130
- no: 8,
5131
- name: "attributes",
5132
- kind: "map",
5133
- K: 9,
5134
- V: {
5135
- kind: "scalar",
5136
- T: 9
5137
- /* ScalarType.STRING */
5138
- }
6036
+ no: 3,
6037
+ name: "gcp",
6038
+ kind: "message",
6039
+ T: GCPUpload,
6040
+ oneof: "output"
5139
6041
  }, {
5140
- no: 9,
5141
- name: "text_header",
6042
+ no: 4,
6043
+ name: "azure",
5142
6044
  kind: "message",
5143
- T: DataStream_TextHeader,
5144
- oneof: "content_header"
6045
+ T: AzureBlobUpload,
6046
+ oneof: "output"
5145
6047
  }, {
5146
- no: 10,
5147
- name: "byte_header",
6048
+ no: 6,
6049
+ name: "aliOSS",
5148
6050
  kind: "message",
5149
- T: DataStream_ByteHeader,
5150
- oneof: "content_header"
5151
- }], {
5152
- localName: "DataStream_Header"
5153
- });
5154
- const DataStream_Chunk = /* @__PURE__ */proto3.makeMessageType("livekit.DataStream.Chunk", () => [{
6051
+ T: AliOSSUpload,
6052
+ oneof: "output"
6053
+ }]);
6054
+ const RoomEgress = /* @__PURE__ */proto3.makeMessageType("livekit.RoomEgress", () => [{
5155
6055
  no: 1,
5156
- name: "stream_id",
6056
+ name: "room",
6057
+ kind: "message",
6058
+ T: RoomCompositeEgressRequest
6059
+ }, {
6060
+ no: 3,
6061
+ name: "participant",
6062
+ kind: "message",
6063
+ T: AutoParticipantEgress
6064
+ }, {
6065
+ no: 2,
6066
+ name: "tracks",
6067
+ kind: "message",
6068
+ T: AutoTrackEgress
6069
+ }]);
6070
+ const RoomConfiguration = /* @__PURE__ */proto3.makeMessageType("livekit.RoomConfiguration", () => [{
6071
+ no: 1,
6072
+ name: "name",
5157
6073
  kind: "scalar",
5158
6074
  T: 9
5159
6075
  /* ScalarType.STRING */
5160
6076
  }, {
5161
6077
  no: 2,
5162
- name: "chunk_index",
6078
+ name: "empty_timeout",
5163
6079
  kind: "scalar",
5164
- T: 4
5165
- /* ScalarType.UINT64 */
6080
+ T: 13
6081
+ /* ScalarType.UINT32 */
5166
6082
  }, {
5167
6083
  no: 3,
5168
- name: "content",
6084
+ name: "departure_timeout",
5169
6085
  kind: "scalar",
5170
- T: 12
5171
- /* ScalarType.BYTES */
6086
+ T: 13
6087
+ /* ScalarType.UINT32 */
5172
6088
  }, {
5173
6089
  no: 4,
5174
- name: "version",
6090
+ name: "max_participants",
5175
6091
  kind: "scalar",
5176
- T: 5
5177
- /* ScalarType.INT32 */
6092
+ T: 13
6093
+ /* ScalarType.UINT32 */
5178
6094
  }, {
5179
- no: 5,
5180
- name: "iv",
5181
- kind: "scalar",
5182
- T: 12,
5183
- opt: true
5184
- }], {
5185
- localName: "DataStream_Chunk"
5186
- });
5187
- const DataStream_Trailer = /* @__PURE__ */proto3.makeMessageType("livekit.DataStream.Trailer", () => [{
5188
- no: 1,
5189
- name: "stream_id",
6095
+ no: 11,
6096
+ name: "metadata",
5190
6097
  kind: "scalar",
5191
6098
  T: 9
5192
6099
  /* ScalarType.STRING */
5193
6100
  }, {
5194
- no: 2,
5195
- name: "reason",
6101
+ no: 5,
6102
+ name: "egress",
6103
+ kind: "message",
6104
+ T: RoomEgress
6105
+ }, {
6106
+ no: 7,
6107
+ name: "min_playout_delay",
5196
6108
  kind: "scalar",
5197
- T: 9
5198
- /* ScalarType.STRING */
6109
+ T: 13
6110
+ /* ScalarType.UINT32 */
5199
6111
  }, {
5200
- no: 3,
5201
- name: "attributes",
5202
- kind: "map",
5203
- K: 9,
5204
- V: {
5205
- kind: "scalar",
5206
- T: 9
5207
- /* ScalarType.STRING */
5208
- }
5209
- }], {
5210
- localName: "DataStream_Trailer"
5211
- });
6112
+ no: 8,
6113
+ name: "max_playout_delay",
6114
+ kind: "scalar",
6115
+ T: 13
6116
+ /* ScalarType.UINT32 */
6117
+ }, {
6118
+ no: 9,
6119
+ name: "sync_streams",
6120
+ kind: "scalar",
6121
+ T: 8
6122
+ /* ScalarType.BOOL */
6123
+ }, {
6124
+ no: 10,
6125
+ name: "agents",
6126
+ kind: "message",
6127
+ T: RoomAgentDispatch,
6128
+ repeated: true
6129
+ }]);
5212
6130
  const SignalTarget = /* @__PURE__ */proto3.makeEnum("livekit.SignalTarget", [{
5213
6131
  no: 0,
5214
6132
  name: "PUBLISHER"
@@ -5474,6 +6392,18 @@ const SignalResponse = /* @__PURE__ */proto3.makeMessageType("livekit.SignalResp
5474
6392
  kind: "message",
5475
6393
  T: RoomMovedResponse,
5476
6394
  oneof: "message"
6395
+ }, {
6396
+ no: 25,
6397
+ name: "media_sections_requirement",
6398
+ kind: "message",
6399
+ T: MediaSectionsRequirement,
6400
+ oneof: "message"
6401
+ }, {
6402
+ no: 26,
6403
+ name: "subscribed_audio_codec_update",
6404
+ kind: "message",
6405
+ T: SubscribedAudioCodecUpdate,
6406
+ oneof: "message"
5477
6407
  }]);
5478
6408
  const SimulcastCodec = /* @__PURE__ */proto3.makeMessageType("livekit.SimulcastCodec", () => [{
5479
6409
  no: 1,
@@ -5487,6 +6417,17 @@ const SimulcastCodec = /* @__PURE__ */proto3.makeMessageType("livekit.SimulcastC
5487
6417
  kind: "scalar",
5488
6418
  T: 9
5489
6419
  /* ScalarType.STRING */
6420
+ }, {
6421
+ no: 4,
6422
+ name: "layers",
6423
+ kind: "message",
6424
+ T: VideoLayer,
6425
+ repeated: true
6426
+ }, {
6427
+ no: 5,
6428
+ name: "video_layer_mode",
6429
+ kind: "enum",
6430
+ T: proto3.getEnumType(VideoLayer_Mode)
5490
6431
  }]);
5491
6432
  const AddTrackRequest = /* @__PURE__ */proto3.makeMessageType("livekit.AddTrackRequest", () => [{
5492
6433
  no: 1,
@@ -6066,6 +7007,19 @@ const SubscribedQualityUpdate = /* @__PURE__ */proto3.makeMessageType("livekit.S
6066
7007
  T: SubscribedCodec,
6067
7008
  repeated: true
6068
7009
  }]);
7010
+ const SubscribedAudioCodecUpdate = /* @__PURE__ */proto3.makeMessageType("livekit.SubscribedAudioCodecUpdate", () => [{
7011
+ no: 1,
7012
+ name: "track_sid",
7013
+ kind: "scalar",
7014
+ T: 9
7015
+ /* ScalarType.STRING */
7016
+ }, {
7017
+ no: 2,
7018
+ name: "subscribed_audio_codecs",
7019
+ kind: "message",
7020
+ T: SubscribedAudioCodec,
7021
+ repeated: true
7022
+ }]);
6069
7023
  const TrackPermission = /* @__PURE__ */proto3.makeMessageType("livekit.TrackPermission", () => [{
6070
7024
  no: 1,
6071
7025
  name: "participant_sid",
@@ -6353,6 +7307,42 @@ const RequestResponse = /* @__PURE__ */proto3.makeMessageType("livekit.RequestRe
6353
7307
  kind: "scalar",
6354
7308
  T: 9
6355
7309
  /* ScalarType.STRING */
7310
+ }, {
7311
+ no: 4,
7312
+ name: "trickle",
7313
+ kind: "message",
7314
+ T: TrickleRequest,
7315
+ oneof: "request"
7316
+ }, {
7317
+ no: 5,
7318
+ name: "add_track",
7319
+ kind: "message",
7320
+ T: AddTrackRequest,
7321
+ oneof: "request"
7322
+ }, {
7323
+ no: 6,
7324
+ name: "mute",
7325
+ kind: "message",
7326
+ T: MuteTrackRequest,
7327
+ oneof: "request"
7328
+ }, {
7329
+ no: 7,
7330
+ name: "update_metadata",
7331
+ kind: "message",
7332
+ T: UpdateParticipantMetadata,
7333
+ oneof: "request"
7334
+ }, {
7335
+ no: 8,
7336
+ name: "update_audio_track",
7337
+ kind: "message",
7338
+ T: UpdateLocalAudioTrack,
7339
+ oneof: "request"
7340
+ }, {
7341
+ no: 9,
7342
+ name: "update_video_track",
7343
+ kind: "message",
7344
+ T: UpdateLocalVideoTrack,
7345
+ oneof: "request"
6356
7346
  }]);
6357
7347
  const RequestResponse_Reason = /* @__PURE__ */proto3.makeEnum("livekit.RequestResponse.Reason", [{
6358
7348
  no: 0,
@@ -6366,6 +7356,15 @@ const RequestResponse_Reason = /* @__PURE__ */proto3.makeEnum("livekit.RequestRe
6366
7356
  }, {
6367
7357
  no: 3,
6368
7358
  name: "LIMIT_EXCEEDED"
7359
+ }, {
7360
+ no: 4,
7361
+ name: "QUEUED"
7362
+ }, {
7363
+ no: 5,
7364
+ name: "UNSUPPORTED_TYPE"
7365
+ }, {
7366
+ no: 6,
7367
+ name: "UNCLASSIFIED_ERROR"
6369
7368
  }]);
6370
7369
  const TrackSubscribed = /* @__PURE__ */proto3.makeMessageType("livekit.TrackSubscribed", () => [{
6371
7370
  no: 1,
@@ -6374,6 +7373,73 @@ const TrackSubscribed = /* @__PURE__ */proto3.makeMessageType("livekit.TrackSubs
6374
7373
  T: 9
6375
7374
  /* ScalarType.STRING */
6376
7375
  }]);
7376
+ const MediaSectionsRequirement = /* @__PURE__ */proto3.makeMessageType("livekit.MediaSectionsRequirement", () => [{
7377
+ no: 1,
7378
+ name: "num_audios",
7379
+ kind: "scalar",
7380
+ T: 13
7381
+ /* ScalarType.UINT32 */
7382
+ }, {
7383
+ no: 2,
7384
+ name: "num_videos",
7385
+ kind: "scalar",
7386
+ T: 13
7387
+ /* ScalarType.UINT32 */
7388
+ }]);
7389
+ const TokenSourceRequest = /* @__PURE__ */proto3.makeMessageType("livekit.TokenSourceRequest", () => [{
7390
+ no: 1,
7391
+ name: "room_name",
7392
+ kind: "scalar",
7393
+ T: 9,
7394
+ opt: true
7395
+ }, {
7396
+ no: 2,
7397
+ name: "participant_name",
7398
+ kind: "scalar",
7399
+ T: 9,
7400
+ opt: true
7401
+ }, {
7402
+ no: 3,
7403
+ name: "participant_identity",
7404
+ kind: "scalar",
7405
+ T: 9,
7406
+ opt: true
7407
+ }, {
7408
+ no: 4,
7409
+ name: "participant_metadata",
7410
+ kind: "scalar",
7411
+ T: 9,
7412
+ opt: true
7413
+ }, {
7414
+ no: 5,
7415
+ name: "participant_attributes",
7416
+ kind: "map",
7417
+ K: 9,
7418
+ V: {
7419
+ kind: "scalar",
7420
+ T: 9
7421
+ /* ScalarType.STRING */
7422
+ }
7423
+ }, {
7424
+ no: 6,
7425
+ name: "room_config",
7426
+ kind: "message",
7427
+ T: RoomConfiguration,
7428
+ opt: true
7429
+ }]);
7430
+ const TokenSourceResponse = /* @__PURE__ */proto3.makeMessageType("livekit.TokenSourceResponse", () => [{
7431
+ no: 1,
7432
+ name: "server_url",
7433
+ kind: "scalar",
7434
+ T: 9
7435
+ /* ScalarType.STRING */
7436
+ }, {
7437
+ no: 2,
7438
+ name: "participant_token",
7439
+ kind: "scalar",
7440
+ T: 9
7441
+ /* ScalarType.STRING */
7442
+ }]);
6377
7443
 
6378
7444
  function getDefaultExportFromCjs (x) {
6379
7445
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -6718,6 +7784,7 @@ var LoggerNames;
6718
7784
  (function (LoggerNames) {
6719
7785
  LoggerNames["Default"] = "livekit";
6720
7786
  LoggerNames["Room"] = "livekit-room";
7787
+ LoggerNames["TokenSource"] = "livekit-token-source";
6721
7788
  LoggerNames["Participant"] = "livekit-participant";
6722
7789
  LoggerNames["Track"] = "livekit-track";
6723
7790
  LoggerNames["Publication"] = "livekit-track-publication";
@@ -7432,7 +8499,7 @@ function detectBrowser(window) {
7432
8499
  * @param {*} val The something you want to check.
7433
8500
  * @return true if val is an object, false otherwise.
7434
8501
  */
7435
- function isObject(val) {
8502
+ function isObject$1(val) {
7436
8503
  return Object.prototype.toString.call(val) === '[object Object]';
7437
8504
  }
7438
8505
 
@@ -7442,11 +8509,11 @@ function isObject(val) {
7442
8509
  * of Lodash's `compact`.
7443
8510
  */
7444
8511
  function compactObject(data) {
7445
- if (!isObject(data)) {
8512
+ if (!isObject$1(data)) {
7446
8513
  return data;
7447
8514
  }
7448
8515
  return Object.keys(data).reduce(function (accumulator, key) {
7449
- const isObj = isObject(data[key]);
8516
+ const isObj = isObject$1(data[key]);
7450
8517
  const value = isObj ? compactObject(data[key]) : data[key];
7451
8518
  const isEmptyObject = isObj && !Object.keys(value).length;
7452
8519
  if (value === undefined || isEmptyObject) {
@@ -10453,6 +11520,15 @@ function writeRbsp(data_in) {
10453
11520
  }
10454
11521
  return new Uint8Array(dataOut);
10455
11522
  }
11523
+ function asEncryptablePacket(packet) {
11524
+ var _a, _b, _c, _d, _e;
11525
+ if (((_a = packet.value) === null || _a === void 0 ? void 0 : _a.case) !== 'sipDtmf' && ((_b = packet.value) === null || _b === void 0 ? void 0 : _b.case) !== 'metrics' && ((_c = packet.value) === null || _c === void 0 ? void 0 : _c.case) !== 'speaker' && ((_d = packet.value) === null || _d === void 0 ? void 0 : _d.case) !== 'transcription' && ((_e = packet.value) === null || _e === void 0 ? void 0 : _e.case) !== 'encryptedPacket') {
11526
+ return new EncryptedPacketPayload({
11527
+ value: packet.value
11528
+ });
11529
+ }
11530
+ return undefined;
11531
+ }
10456
11532
 
10457
11533
  /**
10458
11534
  * @experimental
@@ -10632,6 +11708,8 @@ var DataStreamErrorReason;
10632
11708
  DataStreamErrorReason[DataStreamErrorReason["Incomplete"] = 4] = "Incomplete";
10633
11709
  // Unable to register a stream handler more than once.
10634
11710
  DataStreamErrorReason[DataStreamErrorReason["HandlerAlreadyRegistered"] = 7] = "HandlerAlreadyRegistered";
11711
+ // Encryption type mismatch.
11712
+ DataStreamErrorReason[DataStreamErrorReason["EncryptionTypeMismatch"] = 8] = "EncryptionTypeMismatch";
10635
11713
  })(DataStreamErrorReason || (DataStreamErrorReason = {}));
10636
11714
  class DataStreamError extends LivekitError {
10637
11715
  constructor(message, reason) {
@@ -11388,7 +12466,7 @@ function getOSVersion(ua) {
11388
12466
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11389
12467
  }
11390
12468
 
11391
- var version$1 = "2.15.6";
12469
+ var version$1 = "2.15.8";
11392
12470
 
11393
12471
  const version = version$1;
11394
12472
  const protocolVersion = 16;
@@ -11828,11 +12906,15 @@ class VideoPreset {
11828
12906
  };
11829
12907
  }
11830
12908
  }
11831
- const backupCodecs = ['vp8', 'h264'];
12909
+ // `red` is not technically a codec, but treated as one in signalling protocol
12910
+ const audioCodecs = ['opus', 'red'];
12911
+ const backupVideoCodecs = ['vp8', 'h264'];
11832
12912
  const videoCodecs = ['vp8', 'h264', 'vp9', 'av1', 'h265'];
11833
- function isBackupCodec(codec) {
11834
- return !!backupCodecs.find(backup => backup === codec);
12913
+ function isBackupVideoCodec(codec) {
12914
+ return !!backupVideoCodecs.find(backup => backup === codec);
11835
12915
  }
12916
+ /** @deprecated Use {@link isBackupVideoCodec} instead */
12917
+ const isBackupCodec = isBackupVideoCodec;
11836
12918
  var BackupCodecPolicy;
11837
12919
  (function (BackupCodecPolicy) {
11838
12920
  // codec regression is preferred, the sfu will try to regress codec if possible but not guaranteed
@@ -11944,7 +13026,7 @@ function supportsAV1() {
11944
13026
  let hasAV1 = false;
11945
13027
  if (capabilities) {
11946
13028
  for (const codec of capabilities.codecs) {
11947
- if (codec.mimeType === 'video/AV1') {
13029
+ if (codec.mimeType.toLowerCase() === 'video/av1') {
11948
13030
  hasAV1 = true;
11949
13031
  break;
11950
13032
  }
@@ -11976,7 +13058,7 @@ function supportsVP9() {
11976
13058
  let hasVP9 = false;
11977
13059
  if (capabilities) {
11978
13060
  for (const codec of capabilities.codecs) {
11979
- if (codec.mimeType === 'video/VP9') {
13061
+ if (codec.mimeType.toLowerCase() === 'video/vp9') {
11980
13062
  hasVP9 = true;
11981
13063
  break;
11982
13064
  }
@@ -12276,6 +13358,9 @@ function createAudioAnalyser(track, options) {
12276
13358
  cleanup
12277
13359
  };
12278
13360
  }
13361
+ function isAudioCodec(maybeCodec) {
13362
+ return audioCodecs.includes(maybeCodec);
13363
+ }
12279
13364
  function isVideoCodec(maybeCodec) {
12280
13365
  return videoCodecs.includes(maybeCodec);
12281
13366
  }
@@ -12570,8 +13655,16 @@ function getNewAudioContext() {
12570
13655
  }
12571
13656
  } catch (e) {
12572
13657
  console.warn('Error trying to auto-resume audio context', e);
13658
+ } finally {
13659
+ (_a = window.document.body) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleResume);
13660
+ }
13661
+ });
13662
+ // https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/statechange_event
13663
+ audioContext.addEventListener('statechange', () => {
13664
+ var _a;
13665
+ if (audioContext.state === 'closed') {
13666
+ (_a = window.document.body) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleResume);
12573
13667
  }
12574
- (_a = window.document.body) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleResume);
12575
13668
  });
12576
13669
  window.document.body.addEventListener('click', handleResume);
12577
13670
  }
@@ -12754,8 +13847,10 @@ function layerDimensionsFor(trackInfo, quality) {
12754
13847
  * @experimental
12755
13848
  */
12756
13849
  class E2EEManager extends eventsExports.EventEmitter {
12757
- constructor(options) {
13850
+ constructor(options, dcEncryptionEnabled) {
12758
13851
  super();
13852
+ this.decryptDataRequests = new Map();
13853
+ this.encryptDataRequests = new Map();
12759
13854
  this.onWorkerMessage = ev => {
12760
13855
  var _a, _b;
12761
13856
  const {
@@ -12794,6 +13889,18 @@ class E2EEManager extends eventsExports.EventEmitter {
12794
13889
  case 'ratchetKey':
12795
13890
  this.keyProvider.emit(KeyProviderEvent.KeyRatcheted, data.ratchetResult, data.participantIdentity, data.keyIndex);
12796
13891
  break;
13892
+ case 'decryptDataResponse':
13893
+ const decryptFuture = this.decryptDataRequests.get(data.uuid);
13894
+ if (decryptFuture === null || decryptFuture === void 0 ? void 0 : decryptFuture.resolve) {
13895
+ decryptFuture.resolve(data);
13896
+ }
13897
+ break;
13898
+ case 'encryptDataResponse':
13899
+ const encryptFuture = this.encryptDataRequests.get(data.uuid);
13900
+ if (encryptFuture === null || encryptFuture === void 0 ? void 0 : encryptFuture.resolve) {
13901
+ encryptFuture.resolve(data);
13902
+ }
13903
+ break;
12797
13904
  }
12798
13905
  };
12799
13906
  this.onWorkerError = ev => {
@@ -12805,6 +13912,13 @@ class E2EEManager extends eventsExports.EventEmitter {
12805
13912
  this.keyProvider = options.keyProvider;
12806
13913
  this.worker = options.worker;
12807
13914
  this.encryptionEnabled = false;
13915
+ this.dataChannelEncryptionEnabled = dcEncryptionEnabled;
13916
+ }
13917
+ get isEnabled() {
13918
+ return this.encryptionEnabled;
13919
+ }
13920
+ get isDataChannelEncryptionEnabled() {
13921
+ return this.isEnabled && this.dataChannelEncryptionEnabled;
12808
13922
  }
12809
13923
  /**
12810
13924
  * @internal
@@ -12908,6 +14022,52 @@ class E2EEManager extends eventsExports.EventEmitter {
12908
14022
  });
12909
14023
  keyProvider.on(KeyProviderEvent.SetKey, keyInfo => this.postKey(keyInfo)).on(KeyProviderEvent.RatchetRequest, (participantId, keyIndex) => this.postRatchetRequest(participantId, keyIndex));
12910
14024
  }
14025
+ encryptData(data) {
14026
+ return __awaiter(this, void 0, void 0, function* () {
14027
+ if (!this.worker) {
14028
+ throw Error('could not encrypt data, worker is missing');
14029
+ }
14030
+ const uuid = crypto.randomUUID();
14031
+ const msg = {
14032
+ kind: 'encryptDataRequest',
14033
+ data: {
14034
+ uuid,
14035
+ payload: data,
14036
+ participantIdentity: this.room.localParticipant.identity
14037
+ }
14038
+ };
14039
+ const future = new Future();
14040
+ future.onFinally = () => {
14041
+ this.encryptDataRequests.delete(uuid);
14042
+ };
14043
+ this.encryptDataRequests.set(uuid, future);
14044
+ this.worker.postMessage(msg);
14045
+ return future.promise;
14046
+ });
14047
+ }
14048
+ handleEncryptedData(payload, iv, participantIdentity, keyIndex) {
14049
+ if (!this.worker) {
14050
+ throw Error('could not handle encrypted data, worker is missing');
14051
+ }
14052
+ const uuid = crypto.randomUUID();
14053
+ const msg = {
14054
+ kind: 'decryptDataRequest',
14055
+ data: {
14056
+ uuid,
14057
+ payload,
14058
+ iv,
14059
+ participantIdentity,
14060
+ keyIndex
14061
+ }
14062
+ };
14063
+ const future = new Future();
14064
+ future.onFinally = () => {
14065
+ this.decryptDataRequests.delete(uuid);
14066
+ };
14067
+ this.decryptDataRequests.set(uuid, future);
14068
+ this.worker.postMessage(msg);
14069
+ return future.promise;
14070
+ }
12911
14071
  postRatchetRequest(participantIdentity, keyIndex) {
12912
14072
  if (!this.worker) {
12913
14073
  throw Error('could not ratchet key, worker is missing');
@@ -14970,10 +16130,11 @@ class PCTransport extends eventsExports.EventEmitter {
14970
16130
  } else if (sd.type === 'answer') {
14971
16131
  const sdpParsed = libExports.parse((_a = sd.sdp) !== null && _a !== void 0 ? _a : '');
14972
16132
  sdpParsed.media.forEach(media => {
16133
+ const mid = getMidString(media.mid);
14973
16134
  if (media.type === 'audio') {
14974
16135
  // mung sdp for opus bitrate settings
14975
16136
  this.trackBitrates.some(trackbr => {
14976
- if (!trackbr.transceiver || media.mid != trackbr.transceiver.mid) {
16137
+ if (!trackbr.transceiver || mid != trackbr.transceiver.mid) {
14977
16138
  return false;
14978
16139
  }
14979
16140
  let codecPayload = 0;
@@ -15324,6 +16485,8 @@ class PCTransport extends eventsExports.EventEmitter {
15324
16485
  }
15325
16486
  }
15326
16487
  function ensureAudioNackAndStereo(media, stereoMids, nackMids) {
16488
+ // sdp-transform types don't include number however the parser outputs mids as numbers in some cases
16489
+ const mid = getMidString(media.mid);
15327
16490
  // found opus codec to add nack fb
15328
16491
  let opusPayload = 0;
15329
16492
  media.rtp.some(rtp => {
@@ -15338,13 +16501,13 @@ function ensureAudioNackAndStereo(media, stereoMids, nackMids) {
15338
16501
  if (!media.rtcpFb) {
15339
16502
  media.rtcpFb = [];
15340
16503
  }
15341
- if (nackMids.includes(media.mid) && !media.rtcpFb.some(fb => fb.payload === opusPayload && fb.type === 'nack')) {
16504
+ if (nackMids.includes(mid) && !media.rtcpFb.some(fb => fb.payload === opusPayload && fb.type === 'nack')) {
15342
16505
  media.rtcpFb.push({
15343
16506
  payload: opusPayload,
15344
16507
  type: 'nack'
15345
16508
  });
15346
16509
  }
15347
- if (stereoMids.includes(media.mid)) {
16510
+ if (stereoMids.includes(mid)) {
15348
16511
  media.fmtp.some(fmtp => {
15349
16512
  if (fmtp.payload === opusPayload) {
15350
16513
  if (!fmtp.config.includes('stereo=1')) {
@@ -15365,6 +16528,7 @@ function extractStereoAndNackAudioFromOffer(offer) {
15365
16528
  let opusPayload = 0;
15366
16529
  sdpParsed.media.forEach(media => {
15367
16530
  var _a;
16531
+ const mid = getMidString(media.mid);
15368
16532
  if (media.type === 'audio') {
15369
16533
  media.rtp.some(rtp => {
15370
16534
  if (rtp.codec === 'opus') {
@@ -15374,12 +16538,12 @@ function extractStereoAndNackAudioFromOffer(offer) {
15374
16538
  return false;
15375
16539
  });
15376
16540
  if ((_a = media.rtcpFb) === null || _a === void 0 ? void 0 : _a.some(fb => fb.payload === opusPayload && fb.type === 'nack')) {
15377
- nackMids.push(media.mid);
16541
+ nackMids.push(mid);
15378
16542
  }
15379
16543
  media.fmtp.some(fmtp => {
15380
16544
  if (fmtp.payload === opusPayload) {
15381
16545
  if (fmtp.config.includes('sprop-stereo=1')) {
15382
- stereoMids.push(media.mid);
16546
+ stereoMids.push(mid);
15383
16547
  }
15384
16548
  return true;
15385
16549
  }
@@ -15405,6 +16569,9 @@ function ensureIPAddrMatchVersion(media) {
15405
16569
  }
15406
16570
  }
15407
16571
  }
16572
+ function getMidString(mid) {
16573
+ return typeof mid === 'number' ? mid.toFixed(0) : mid;
16574
+ }
15408
16575
 
15409
16576
  const defaultVideoCodec = 'vp8';
15410
16577
  const publishDefaults = {
@@ -16761,7 +17928,7 @@ class LocalAudioTrack extends LocalTrack {
16761
17928
  const trackIsSilent = yield detectSilence(this);
16762
17929
  if (trackIsSilent) {
16763
17930
  if (!this.isMuted) {
16764
- this.log.warn('silence detected on local audio track', this.logContext);
17931
+ this.log.debug('silence detected on local audio track', this.logContext);
16765
17932
  }
16766
17933
  this.emit(TrackEvent.AudioSilenceDetected);
16767
17934
  }
@@ -17849,7 +19016,7 @@ class RTCEngine extends eventsExports.EventEmitter {
17849
19016
  }();
17850
19017
  });
17851
19018
  this.handleDataMessage = message => __awaiter(this, void 0, void 0, function* () {
17852
- var _a, _b;
19019
+ var _a, _b, _c, _d, _e;
17853
19020
  // make sure to respect incoming data message order by processing message events one after the other
17854
19021
  const unlock = yield this.dataProcessLock.lock();
17855
19022
  try {
@@ -17877,12 +19044,27 @@ class RTCEngine extends eventsExports.EventEmitter {
17877
19044
  if (((_a = dp.value) === null || _a === void 0 ? void 0 : _a.case) === 'speaker') {
17878
19045
  // dispatch speaker updates
17879
19046
  this.emit(EngineEvent.ActiveSpeakersUpdate, dp.value.value.speakers);
19047
+ } else if (((_b = dp.value) === null || _b === void 0 ? void 0 : _b.case) === 'encryptedPacket') {
19048
+ if (!this.e2eeManager) {
19049
+ this.log.error('Received encrypted packet but E2EE not set up', this.logContext);
19050
+ return;
19051
+ }
19052
+ const decryptedData = yield (_c = this.e2eeManager) === null || _c === void 0 ? void 0 : _c.handleEncryptedData(dp.value.value.encryptedValue, dp.value.value.iv, dp.participantIdentity, dp.value.value.keyIndex);
19053
+ const decryptedPacket = EncryptedPacketPayload.fromBinary(decryptedData.payload);
19054
+ const newDp = new DataPacket({
19055
+ value: decryptedPacket.value
19056
+ });
19057
+ if (((_d = newDp.value) === null || _d === void 0 ? void 0 : _d.case) === 'user') {
19058
+ // compatibility
19059
+ applyUserDataCompat(newDp, newDp.value.value);
19060
+ }
19061
+ this.emit(EngineEvent.DataPacketReceived, newDp, dp.value.value.encryptionType);
17880
19062
  } else {
17881
- if (((_b = dp.value) === null || _b === void 0 ? void 0 : _b.case) === 'user') {
19063
+ if (((_e = dp.value) === null || _e === void 0 ? void 0 : _e.case) === 'user') {
17882
19064
  // compatibility
17883
19065
  applyUserDataCompat(dp, dp.value.value);
17884
19066
  }
17885
- this.emit(EngineEvent.DataPacketReceived, dp);
19067
+ this.emit(EngineEvent.DataPacketReceived, dp, Encryption_Type.NONE);
17886
19068
  }
17887
19069
  } finally {
17888
19070
  unlock();
@@ -17995,7 +19177,6 @@ class RTCEngine extends eventsExports.EventEmitter {
17995
19177
  this.client = new SignalClient(undefined, this.loggerOptions);
17996
19178
  this.client.signalLatency = this.options.expSignalLatency;
17997
19179
  this.reconnectPolicy = this.options.reconnectPolicy;
17998
- this.registerOnLineListener();
17999
19180
  this.closingLock = new _();
18000
19181
  this.dataProcessLock = new _();
18001
19182
  this.dcBufferStatus = new Map([[DataPacket_Kind.LOSSY, true], [DataPacket_Kind.RELIABLE, true]]);
@@ -18036,8 +19217,11 @@ class RTCEngine extends eventsExports.EventEmitter {
18036
19217
  }
18037
19218
  // create offer
18038
19219
  if (!this.subscriberPrimary || joinResponse.fastPublish) {
18039
- this.negotiate();
19220
+ this.negotiate().catch(err => {
19221
+ livekitLogger.error(err, this.logContext);
19222
+ });
18040
19223
  }
19224
+ this.registerOnLineListener();
18041
19225
  this.clientConfiguration = joinResponse.clientConfiguration;
18042
19226
  this.emit(EngineEvent.SignalConnected, joinResponse);
18043
19227
  return joinResponse;
@@ -18206,7 +19390,7 @@ class RTCEngine extends eventsExports.EventEmitter {
18206
19390
  }
18207
19391
  } else if (connectionState === PCTransportState.FAILED) {
18208
19392
  // on Safari, PeerConnection will switch to 'disconnected' during renegotiation
18209
- if (this.pcState === PCState.Connected) {
19393
+ if (this.pcState === PCState.Connected || this.pcState === PCState.Reconnecting) {
18210
19394
  this.pcState = PCState.Disconnected;
18211
19395
  this.handleDisconnect('peerconnection failed', subscriberState === 'failed' ? ReconnectReason.RR_SUBSCRIBER_FAILED : ReconnectReason.RR_PUBLISHER_FAILED);
18212
19396
  }
@@ -18727,6 +19911,20 @@ class RTCEngine extends eventsExports.EventEmitter {
18727
19911
  return __awaiter(this, void 0, void 0, function* () {
18728
19912
  // make sure we do have a data connection
18729
19913
  yield this.ensurePublisherConnected(kind);
19914
+ if (this.e2eeManager && this.e2eeManager.isDataChannelEncryptionEnabled) {
19915
+ const encryptablePacket = asEncryptablePacket(packet);
19916
+ if (encryptablePacket) {
19917
+ const encryptedData = yield this.e2eeManager.encryptData(encryptablePacket.toBinary());
19918
+ packet.value = {
19919
+ case: 'encryptedPacket',
19920
+ value: new EncryptedPacket({
19921
+ encryptedValue: encryptedData.payload,
19922
+ iv: encryptedData.iv,
19923
+ keyIndex: encryptedData.keyIndex
19924
+ })
19925
+ };
19926
+ }
19927
+ }
18730
19928
  if (kind === DataPacket_Kind.RELIABLE) {
18731
19929
  packet.sequence = this.reliableDataSequence;
18732
19930
  this.reliableDataSequence += 1;
@@ -18803,7 +20001,9 @@ class RTCEngine extends eventsExports.EventEmitter {
18803
20001
  }
18804
20002
  if (needNegotiation) {
18805
20003
  // start negotiation
18806
- _this2.negotiate();
20004
+ _this2.negotiate().catch(err => {
20005
+ livekitLogger.error(err, _this2.logContext);
20006
+ });
18807
20007
  }
18808
20008
  const targetChannel = _this2.dataChannelForKind(kind, subscriber);
18809
20009
  if ((targetChannel === null || targetChannel === void 0 ? void 0 : targetChannel.readyState) === 'open') {
@@ -19420,21 +20620,21 @@ class IncomingDataStreamManager {
19420
20620
  }
19421
20621
  }
19422
20622
  }
19423
- handleDataStreamPacket(packet) {
20623
+ handleDataStreamPacket(packet, encryptionType) {
19424
20624
  return __awaiter(this, void 0, void 0, function* () {
19425
20625
  switch (packet.value.case) {
19426
20626
  case 'streamHeader':
19427
- return this.handleStreamHeader(packet.value.value, packet.participantIdentity);
20627
+ return this.handleStreamHeader(packet.value.value, packet.participantIdentity, encryptionType);
19428
20628
  case 'streamChunk':
19429
- return this.handleStreamChunk(packet.value.value);
20629
+ return this.handleStreamChunk(packet.value.value, encryptionType);
19430
20630
  case 'streamTrailer':
19431
- return this.handleStreamTrailer(packet.value.value);
20631
+ return this.handleStreamTrailer(packet.value.value, encryptionType);
19432
20632
  default:
19433
20633
  throw new Error("DataPacket of value \"".concat(packet.value.case, "\" is not data stream related!"));
19434
20634
  }
19435
20635
  });
19436
20636
  }
19437
- handleStreamHeader(streamHeader, participantIdentity) {
20637
+ handleStreamHeader(streamHeader, participantIdentity, encryptionType) {
19438
20638
  return __awaiter(this, void 0, void 0, function* () {
19439
20639
  var _a;
19440
20640
  if (streamHeader.contentHeader.case === 'byteHeader') {
@@ -19445,6 +20645,9 @@ class IncomingDataStreamManager {
19445
20645
  }
19446
20646
  let streamController;
19447
20647
  const outOfBandFailureRejectingFuture = new Future();
20648
+ outOfBandFailureRejectingFuture.promise.catch(err => {
20649
+ this.log.error(err);
20650
+ });
19448
20651
  const info = {
19449
20652
  id: streamHeader.streamId,
19450
20653
  name: (_a = streamHeader.contentHeader.value.name) !== null && _a !== void 0 ? _a : 'unknown',
@@ -19452,7 +20655,8 @@ class IncomingDataStreamManager {
19452
20655
  size: streamHeader.totalLength ? Number(streamHeader.totalLength) : undefined,
19453
20656
  topic: streamHeader.topic,
19454
20657
  timestamp: bigIntToNumber(streamHeader.timestamp),
19455
- attributes: streamHeader.attributes
20658
+ attributes: streamHeader.attributes,
20659
+ encryptionType
19456
20660
  };
19457
20661
  const stream = new ReadableStream({
19458
20662
  start: controller => {
@@ -19480,13 +20684,17 @@ class IncomingDataStreamManager {
19480
20684
  }
19481
20685
  let streamController;
19482
20686
  const outOfBandFailureRejectingFuture = new Future();
20687
+ outOfBandFailureRejectingFuture.promise.catch(err => {
20688
+ this.log.error(err);
20689
+ });
19483
20690
  const info = {
19484
20691
  id: streamHeader.streamId,
19485
20692
  mimeType: streamHeader.mimeType,
19486
20693
  size: streamHeader.totalLength ? Number(streamHeader.totalLength) : undefined,
19487
20694
  topic: streamHeader.topic,
19488
20695
  timestamp: Number(streamHeader.timestamp),
19489
- attributes: streamHeader.attributes
20696
+ attributes: streamHeader.attributes,
20697
+ encryptionType
19490
20698
  };
19491
20699
  const stream = new ReadableStream({
19492
20700
  start: controller => {
@@ -19509,34 +20717,46 @@ class IncomingDataStreamManager {
19509
20717
  }
19510
20718
  });
19511
20719
  }
19512
- handleStreamChunk(chunk) {
20720
+ handleStreamChunk(chunk, encryptionType) {
19513
20721
  const fileBuffer = this.byteStreamControllers.get(chunk.streamId);
19514
20722
  if (fileBuffer) {
19515
- if (chunk.content.length > 0) {
20723
+ if (fileBuffer.info.encryptionType !== encryptionType) {
20724
+ fileBuffer.controller.error(new DataStreamError("Encryption type mismatch for stream ".concat(chunk.streamId, ". Expected ").concat(encryptionType, ", got ").concat(fileBuffer.info.encryptionType), DataStreamErrorReason.EncryptionTypeMismatch));
20725
+ this.byteStreamControllers.delete(chunk.streamId);
20726
+ } else if (chunk.content.length > 0) {
19516
20727
  fileBuffer.controller.enqueue(chunk);
19517
20728
  }
19518
20729
  }
19519
20730
  const textBuffer = this.textStreamControllers.get(chunk.streamId);
19520
20731
  if (textBuffer) {
19521
- if (chunk.content.length > 0) {
20732
+ if (textBuffer.info.encryptionType !== encryptionType) {
20733
+ textBuffer.controller.error(new DataStreamError("Encryption type mismatch for stream ".concat(chunk.streamId, ". Expected ").concat(encryptionType, ", got ").concat(textBuffer.info.encryptionType), DataStreamErrorReason.EncryptionTypeMismatch));
20734
+ this.textStreamControllers.delete(chunk.streamId);
20735
+ } else if (chunk.content.length > 0) {
19522
20736
  textBuffer.controller.enqueue(chunk);
19523
20737
  }
19524
20738
  }
19525
20739
  }
19526
- handleStreamTrailer(trailer) {
20740
+ handleStreamTrailer(trailer, encryptionType) {
19527
20741
  const textBuffer = this.textStreamControllers.get(trailer.streamId);
19528
20742
  if (textBuffer) {
19529
- textBuffer.info.attributes = Object.assign(Object.assign({}, textBuffer.info.attributes), trailer.attributes);
19530
- textBuffer.controller.close();
19531
- this.textStreamControllers.delete(trailer.streamId);
20743
+ if (textBuffer.info.encryptionType !== encryptionType) {
20744
+ textBuffer.controller.error(new DataStreamError("Encryption type mismatch for stream ".concat(trailer.streamId, ". Expected ").concat(encryptionType, ", got ").concat(textBuffer.info.encryptionType), DataStreamErrorReason.EncryptionTypeMismatch));
20745
+ } else {
20746
+ textBuffer.info.attributes = Object.assign(Object.assign({}, textBuffer.info.attributes), trailer.attributes);
20747
+ textBuffer.controller.close();
20748
+ this.textStreamControllers.delete(trailer.streamId);
20749
+ }
19532
20750
  }
19533
20751
  const fileBuffer = this.byteStreamControllers.get(trailer.streamId);
19534
20752
  if (fileBuffer) {
19535
- {
20753
+ if (fileBuffer.info.encryptionType !== encryptionType) {
20754
+ fileBuffer.controller.error(new DataStreamError("Encryption type mismatch for stream ".concat(trailer.streamId, ". Expected ").concat(encryptionType, ", got ").concat(fileBuffer.info.encryptionType), DataStreamErrorReason.EncryptionTypeMismatch));
20755
+ } else {
19536
20756
  fileBuffer.info.attributes = Object.assign(Object.assign({}, fileBuffer.info.attributes), trailer.attributes);
19537
20757
  fileBuffer.controller.close();
19538
- this.byteStreamControllers.delete(trailer.streamId);
19539
20758
  }
20759
+ this.byteStreamControllers.delete(trailer.streamId);
19540
20760
  }
19541
20761
  }
19542
20762
  }
@@ -19623,7 +20843,7 @@ class OutgoingDataStreamManager {
19623
20843
  */
19624
20844
  streamText(options) {
19625
20845
  return __awaiter(this, void 0, void 0, function* () {
19626
- var _a, _b;
20846
+ var _a, _b, _c;
19627
20847
  const streamId = (_a = options === null || options === void 0 ? void 0 : options.streamId) !== null && _a !== void 0 ? _a : crypto.randomUUID();
19628
20848
  const info = {
19629
20849
  id: streamId,
@@ -19631,7 +20851,8 @@ class OutgoingDataStreamManager {
19631
20851
  timestamp: Date.now(),
19632
20852
  topic: (_b = options === null || options === void 0 ? void 0 : options.topic) !== null && _b !== void 0 ? _b : '',
19633
20853
  size: options === null || options === void 0 ? void 0 : options.totalSize,
19634
- attributes: options === null || options === void 0 ? void 0 : options.attributes
20854
+ attributes: options === null || options === void 0 ? void 0 : options.attributes,
20855
+ encryptionType: ((_c = this.engine.e2eeManager) === null || _c === void 0 ? void 0 : _c.isDataChannelEncryptionEnabled) ? Encryption_Type.GCM : Encryption_Type.NONE
19635
20856
  };
19636
20857
  const header = new DataStream_Header({
19637
20858
  streamId,
@@ -19749,7 +20970,7 @@ class OutgoingDataStreamManager {
19749
20970
  }
19750
20971
  streamBytes(options) {
19751
20972
  return __awaiter(this, void 0, void 0, function* () {
19752
- var _a, _b, _c, _d, _e;
20973
+ var _a, _b, _c, _d, _e, _f;
19753
20974
  const streamId = (_a = options === null || options === void 0 ? void 0 : options.streamId) !== null && _a !== void 0 ? _a : crypto.randomUUID();
19754
20975
  const destinationIdentities = options === null || options === void 0 ? void 0 : options.destinationIdentities;
19755
20976
  const info = {
@@ -19759,10 +20980,11 @@ class OutgoingDataStreamManager {
19759
20980
  timestamp: Date.now(),
19760
20981
  attributes: options === null || options === void 0 ? void 0 : options.attributes,
19761
20982
  size: options === null || options === void 0 ? void 0 : options.totalSize,
19762
- name: (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : 'unknown'
20983
+ name: (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : 'unknown',
20984
+ encryptionType: ((_e = this.engine.e2eeManager) === null || _e === void 0 ? void 0 : _e.isDataChannelEncryptionEnabled) ? Encryption_Type.GCM : Encryption_Type.NONE
19763
20985
  };
19764
20986
  const header = new DataStream_Header({
19765
- totalLength: numberToBigInt((_e = info.size) !== null && _e !== void 0 ? _e : 0),
20987
+ totalLength: numberToBigInt((_f = info.size) !== null && _f !== void 0 ? _f : 0),
19766
20988
  mimeType: info.mimeType,
19767
20989
  streamId,
19768
20990
  topic: info.topic,
@@ -21569,15 +22791,6 @@ class LocalParticipant extends Participant {
21569
22791
  return this.setTrackEnabled(Track.Source.ScreenShare, enabled, options, publishOptions);
21570
22792
  }
21571
22793
  /** @internal */
21572
- setPermissions(permissions) {
21573
- const prevPermissions = this.permissions;
21574
- const changed = super.setPermissions(permissions);
21575
- if (changed && prevPermissions) {
21576
- this.emit(ParticipantEvent.ParticipantPermissionsChanged, prevPermissions);
21577
- }
21578
- return changed;
21579
- }
21580
- /** @internal */
21581
22794
  setE2EEEnabled(enabled) {
21582
22795
  return __awaiter(this, void 0, void 0, function* () {
21583
22796
  this.encryptionType = enabled ? Encryption_Type.GCM : Encryption_Type.NONE;
@@ -21888,25 +23101,22 @@ class LocalParticipant extends Participant {
21888
23101
  _this2.log.warn('track has already been published, skipping', Object.assign(Object.assign({}, _this2.logContext), getLogContextFromTrack(existingPublication)));
21889
23102
  return existingPublication;
21890
23103
  }
23104
+ const opts = Object.assign(Object.assign({}, _this2.roomOptions.publishDefaults), options);
21891
23105
  const isStereoInput = 'channelCount' in track.mediaStreamTrack.getSettings() &&
21892
23106
  // @ts-ignore `channelCount` on getSettings() is currently only available for Safari, but is generally the best way to determine a stereo track https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/channelCount
21893
23107
  track.mediaStreamTrack.getSettings().channelCount === 2 || track.mediaStreamTrack.getConstraints().channelCount === 2;
21894
- const isStereo = (_b = options === null || options === void 0 ? void 0 : options.forceStereo) !== null && _b !== void 0 ? _b : isStereoInput;
23108
+ const isStereo = (_b = opts.forceStereo) !== null && _b !== void 0 ? _b : isStereoInput;
21895
23109
  // disable dtx for stereo track if not enabled explicitly
21896
23110
  if (isStereo) {
21897
- if (!options) {
21898
- options = {};
21899
- }
21900
- if (options.dtx === undefined) {
23111
+ if (opts.dtx === undefined) {
21901
23112
  _this2.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.", Object.assign(Object.assign({}, _this2.logContext), getLogContextFromTrack(track)));
21902
23113
  }
21903
- if (options.red === undefined) {
23114
+ if (opts.red === undefined) {
21904
23115
  _this2.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work.");
21905
23116
  }
21906
- (_c = options.dtx) !== null && _c !== void 0 ? _c : options.dtx = false;
21907
- (_d = options.red) !== null && _d !== void 0 ? _d : options.red = false;
23117
+ (_c = opts.dtx) !== null && _c !== void 0 ? _c : opts.dtx = false;
23118
+ (_d = opts.red) !== null && _d !== void 0 ? _d : opts.red = false;
21908
23119
  }
21909
- const opts = Object.assign(Object.assign({}, _this2.roomOptions.publishDefaults), options);
21910
23120
  if (!isE2EESimulcastSupported() && _this2.roomOptions.e2ee) {
21911
23121
  _this2.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2", Object.assign({}, _this2.logContext));
21912
23122
  opts.simulcast = false;
@@ -22528,16 +23738,17 @@ class LocalParticipant extends Participant {
22528
23738
  const kind = options.reliable ? DataPacket_Kind.RELIABLE : DataPacket_Kind.LOSSY;
22529
23739
  const destinationIdentities = options.destinationIdentities;
22530
23740
  const topic = options.topic;
23741
+ let userPacket = new UserPacket({
23742
+ participantIdentity: _this4.identity,
23743
+ payload: data,
23744
+ destinationIdentities,
23745
+ topic
23746
+ });
22531
23747
  const packet = new DataPacket({
22532
23748
  kind: kind,
22533
23749
  value: {
22534
23750
  case: 'user',
22535
- value: new UserPacket({
22536
- participantIdentity: _this4.identity,
22537
- payload: data,
22538
- destinationIdentities,
22539
- topic
22540
- })
23751
+ value: userPacket
22541
23752
  }
22542
23753
  });
22543
23754
  yield _this4.engine.sendDataPacket(packet, kind);
@@ -23462,6 +24673,9 @@ const connectionReconcileFrequency = 4 * 1000;
23462
24673
  * @noInheritDoc
23463
24674
  */
23464
24675
  class Room extends eventsExports.EventEmitter {
24676
+ get hasE2EESetup() {
24677
+ return this.e2eeManager !== undefined;
24678
+ }
23465
24679
  /**
23466
24680
  * Creates a new Room, the primary construct for a LiveKit session.
23467
24681
  * @param options
@@ -23622,7 +24836,7 @@ class Room extends eventsExports.EventEmitter {
23622
24836
  this.localParticipant.sid = pi.sid;
23623
24837
  this.localParticipant.identity = pi.identity;
23624
24838
  this.localParticipant.setEnabledPublishCodecs(joinResponse.enabledPublishCodecs);
23625
- if (this.options.e2ee && this.e2eeManager) {
24839
+ if (this.e2eeManager) {
23626
24840
  try {
23627
24841
  this.e2eeManager.setSifTrailer(joinResponse.sifTrailer);
23628
24842
  } catch (e) {
@@ -24010,11 +25224,11 @@ class Room extends eventsExports.EventEmitter {
24010
25224
  }
24011
25225
  pub.setSubscriptionError(update.err);
24012
25226
  };
24013
- this.handleDataPacket = packet => {
25227
+ this.handleDataPacket = (packet, encryptionType) => {
24014
25228
  // find the participant
24015
25229
  const participant = this.remoteParticipants.get(packet.participantIdentity);
24016
25230
  if (packet.value.case === 'user') {
24017
- this.handleUserPacket(participant, packet.value.value, packet.kind);
25231
+ this.handleUserPacket(participant, packet.value.value, packet.kind, encryptionType);
24018
25232
  } else if (packet.value.case === 'transcription') {
24019
25233
  this.handleTranscription(participant, packet.value.value);
24020
25234
  } else if (packet.value.case === 'sipDtmf') {
@@ -24024,16 +25238,16 @@ class Room extends eventsExports.EventEmitter {
24024
25238
  } else if (packet.value.case === 'metrics') {
24025
25239
  this.handleMetrics(packet.value.value, participant);
24026
25240
  } else if (packet.value.case === 'streamHeader' || packet.value.case === 'streamChunk' || packet.value.case === 'streamTrailer') {
24027
- this.handleDataStream(packet);
25241
+ this.handleDataStream(packet, encryptionType);
24028
25242
  } else if (packet.value.case === 'rpcRequest') {
24029
25243
  const rpc = packet.value.value;
24030
25244
  this.handleIncomingRpcRequest(packet.participantIdentity, rpc.id, rpc.method, rpc.payload, rpc.responseTimeoutMs, rpc.version);
24031
25245
  }
24032
25246
  };
24033
- this.handleUserPacket = (participant, userPacket, kind) => {
24034
- this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind, userPacket.topic);
25247
+ this.handleUserPacket = (participant, userPacket, kind, encryptionType) => {
25248
+ this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind, userPacket.topic, encryptionType);
24035
25249
  // also emit on the participant
24036
- participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
25250
+ participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind, encryptionType);
24037
25251
  };
24038
25252
  this.handleSipDtmf = (participant, dtmf) => {
24039
25253
  this.emit(RoomEvent.SipDTMFReceived, dtmf, participant);
@@ -24056,8 +25270,8 @@ class Room extends eventsExports.EventEmitter {
24056
25270
  this.handleMetrics = (metrics, participant) => {
24057
25271
  this.emit(RoomEvent.MetricsReceived, metrics, participant);
24058
25272
  };
24059
- this.handleDataStream = packet => {
24060
- this.incomingDataStreamManager.handleDataStreamPacket(packet);
25273
+ this.handleDataStream = (packet, encryptionType) => {
25274
+ this.incomingDataStreamManager.handleDataStreamPacket(packet, encryptionType);
24061
25275
  };
24062
25276
  this.bufferedSegments = new Map();
24063
25277
  this.handleAudioPlaybackStarted = () => {
@@ -24198,6 +25412,10 @@ class Room extends eventsExports.EventEmitter {
24198
25412
  this.outgoingDataStreamManager = new OutgoingDataStreamManager(this.engine, this.log);
24199
25413
  this.disconnectLock = new _();
24200
25414
  this.localParticipant = new LocalParticipant('', '', this.engine, this.options, this.rpcHandlers, this.outgoingDataStreamManager);
25415
+ if (this.options.e2ee || this.options.encryption) {
25416
+ this.setupE2EE();
25417
+ }
25418
+ this.engine.e2eeManager = this.e2eeManager;
24201
25419
  if (this.options.videoCaptureDefaults.deviceId) {
24202
25420
  this.localParticipant.activeDeviceMap.set('videoinput', unwrapConstraint(this.options.videoCaptureDefaults.deviceId));
24203
25421
  }
@@ -24207,9 +25425,6 @@ class Room extends eventsExports.EventEmitter {
24207
25425
  if ((_b = this.options.audioOutput) === null || _b === void 0 ? void 0 : _b.deviceId) {
24208
25426
  this.switchActiveDevice('audiooutput', unwrapConstraint(this.options.audioOutput.deviceId)).catch(e => this.log.warn("Could not set audio output: ".concat(e.message), this.logContext));
24209
25427
  }
24210
- if (this.options.e2ee) {
24211
- this.setupE2EE();
24212
- }
24213
25428
  if (isWeb()) {
24214
25429
  const abortController = new AbortController();
24215
25430
  // in order to catch device changes prior to room connection we need to register the event in the constructor
@@ -24291,12 +25506,15 @@ class Room extends eventsExports.EventEmitter {
24291
25506
  });
24292
25507
  }
24293
25508
  setupE2EE() {
25509
+ // when encryption is enabled via `options.encryption`, we enable data channel encryption
24294
25510
  var _a;
24295
- if (this.options.e2ee) {
24296
- if ('e2eeManager' in this.options.e2ee) {
24297
- this.e2eeManager = this.options.e2ee.e2eeManager;
25511
+ const dcEncryptionEnabled = !!this.options.encryption;
25512
+ const e2eeOptions = this.options.encryption || this.options.e2ee;
25513
+ if (e2eeOptions) {
25514
+ if ('e2eeManager' in e2eeOptions) {
25515
+ this.e2eeManager = e2eeOptions.e2eeManager;
24298
25516
  } else {
24299
- this.e2eeManager = new E2EEManager(this.options.e2ee);
25517
+ this.e2eeManager = new E2EEManager(e2eeOptions, dcEncryptionEnabled);
24300
25518
  }
24301
25519
  this.e2eeManager.on(EncryptionEvent.ParticipantEncryptionStatusChanged, (enabled, participant) => {
24302
25520
  if (isLocalParticipant(participant)) {
@@ -24374,6 +25592,7 @@ class Room extends eventsExports.EventEmitter {
24374
25592
  return;
24375
25593
  }
24376
25594
  this.engine = new RTCEngine(this.options);
25595
+ this.engine.e2eeManager = this.e2eeManager;
24377
25596
  this.engine.on(EngineEvent.ParticipantUpdate, this.handleParticipantUpdates).on(EngineEvent.RoomUpdate, this.handleRoomUpdate).on(EngineEvent.SpeakersChanged, this.handleSpeakersChanged).on(EngineEvent.StreamStateChanged, this.handleStreamStateUpdate).on(EngineEvent.ConnectionQualityUpdate, this.handleConnectionQualityUpdate).on(EngineEvent.SubscriptionError, this.handleSubscriptionError).on(EngineEvent.SubscriptionPermissionUpdate, this.handleSubscriptionPermissionUpdate).on(EngineEvent.MediaTrackAdded, (mediaTrack, stream, receiver) => {
24378
25597
  this.onTrackAdded(mediaTrack, stream, receiver);
24379
25598
  }).on(EngineEvent.Disconnected, reason => {
@@ -24513,7 +25732,7 @@ class Room extends eventsExports.EventEmitter {
24513
25732
  */
24514
25733
  simulateScenario(scenario, arg) {
24515
25734
  return __awaiter(this, void 0, void 0, function* () {
24516
- let postAction = () => {};
25735
+ let postAction = () => __awaiter(this, void 0, void 0, function* () {});
24517
25736
  let req;
24518
25737
  switch (scenario) {
24519
25738
  case 'signal-reconnect':
@@ -25774,6 +26993,11 @@ class PublishVideoCheck extends Checker {
25774
26993
  const video = document.createElement('video');
25775
26994
  video.srcObject = stream;
25776
26995
  video.muted = true;
26996
+ video.autoplay = true;
26997
+ video.playsInline = true;
26998
+ // For iOS Safari
26999
+ video.setAttribute('playsinline', 'true');
27000
+ document.body.appendChild(video);
25777
27001
  yield new Promise(resolve => {
25778
27002
  video.onplay = () => {
25779
27003
  setTimeout(() => {
@@ -26093,6 +27317,521 @@ class ConnectionCheck extends eventsExports.EventEmitter {
26093
27317
  }
26094
27318
  }
26095
27319
 
27320
+ /** A Fixed TokenSource is a token source that takes no parameters and returns a completely
27321
+ * independently derived value on each fetch() call.
27322
+ *
27323
+ * The most common downstream implementer is {@link TokenSourceLiteral}.
27324
+ */
27325
+ class TokenSourceFixed {}
27326
+ /** A Configurable TokenSource is a token source that takes a
27327
+ * {@link TokenSourceFetchOptions} object as input and returns a deterministic
27328
+ * {@link TokenSourceResponseObject} output based on the options specified.
27329
+ *
27330
+ * For example, if options.participantName is set, it should be expected that
27331
+ * all tokens that are generated will have participant name field set to the
27332
+ * provided value.
27333
+ *
27334
+ * A few common downstream implementers are {@link TokenSourceEndpoint}
27335
+ * and {@link TokenSourceCustom}.
27336
+ */
27337
+ class TokenSourceConfigurable {}
27338
+
27339
+ function _defineProperty(e, r, t) {
27340
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
27341
+ value: t,
27342
+ enumerable: true,
27343
+ configurable: true,
27344
+ writable: true
27345
+ }) : e[r] = t, e;
27346
+ }
27347
+ function _toPrimitive(t, r) {
27348
+ if ("object" != typeof t || !t) return t;
27349
+ var e = t[Symbol.toPrimitive];
27350
+ if (void 0 !== e) {
27351
+ var i = e.call(t, r);
27352
+ if ("object" != typeof i) return i;
27353
+ throw new TypeError("@@toPrimitive must return a primitive value.");
27354
+ }
27355
+ return ("string" === r ? String : Number)(t);
27356
+ }
27357
+ function _toPropertyKey(t) {
27358
+ var i = _toPrimitive(t, "string");
27359
+ return "symbol" == typeof i ? i : i + "";
27360
+ }
27361
+
27362
+ new TextEncoder();
27363
+ const decoder = new TextDecoder();
27364
+
27365
+ function decodeBase64(encoded) {
27366
+ if (Uint8Array.fromBase64) {
27367
+ return Uint8Array.fromBase64(encoded);
27368
+ }
27369
+ const binary = atob(encoded);
27370
+ const bytes = new Uint8Array(binary.length);
27371
+ for (let i = 0; i < binary.length; i++) {
27372
+ bytes[i] = binary.charCodeAt(i);
27373
+ }
27374
+ return bytes;
27375
+ }
27376
+
27377
+ function decode(input) {
27378
+ if (Uint8Array.fromBase64) {
27379
+ return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {
27380
+ alphabet: 'base64url'
27381
+ });
27382
+ }
27383
+ let encoded = input;
27384
+ if (encoded instanceof Uint8Array) {
27385
+ encoded = decoder.decode(encoded);
27386
+ }
27387
+ encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\s/g, '');
27388
+ try {
27389
+ return decodeBase64(encoded);
27390
+ } catch (_unused) {
27391
+ throw new TypeError('The input to be decoded is not correctly encoded.');
27392
+ }
27393
+ }
27394
+
27395
+ class JOSEError extends Error {
27396
+ constructor(message, options) {
27397
+ var _Error$captureStackTr;
27398
+ super(message, options);
27399
+ _defineProperty(this, "code", 'ERR_JOSE_GENERIC');
27400
+ this.name = this.constructor.name;
27401
+ (_Error$captureStackTr = Error.captureStackTrace) === null || _Error$captureStackTr === void 0 || _Error$captureStackTr.call(Error, this, this.constructor);
27402
+ }
27403
+ }
27404
+ _defineProperty(JOSEError, "code", 'ERR_JOSE_GENERIC');
27405
+ class JWTClaimValidationFailed extends JOSEError {
27406
+ constructor(message, payload) {
27407
+ let claim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unspecified';
27408
+ let reason = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'unspecified';
27409
+ super(message, {
27410
+ cause: {
27411
+ claim,
27412
+ reason,
27413
+ payload
27414
+ }
27415
+ });
27416
+ _defineProperty(this, "code", 'ERR_JWT_CLAIM_VALIDATION_FAILED');
27417
+ _defineProperty(this, "claim", void 0);
27418
+ _defineProperty(this, "reason", void 0);
27419
+ _defineProperty(this, "payload", void 0);
27420
+ this.claim = claim;
27421
+ this.reason = reason;
27422
+ this.payload = payload;
27423
+ }
27424
+ }
27425
+ _defineProperty(JWTClaimValidationFailed, "code", 'ERR_JWT_CLAIM_VALIDATION_FAILED');
27426
+ class JWTExpired extends JOSEError {
27427
+ constructor(message, payload) {
27428
+ let claim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unspecified';
27429
+ let reason = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'unspecified';
27430
+ super(message, {
27431
+ cause: {
27432
+ claim,
27433
+ reason,
27434
+ payload
27435
+ }
27436
+ });
27437
+ _defineProperty(this, "code", 'ERR_JWT_EXPIRED');
27438
+ _defineProperty(this, "claim", void 0);
27439
+ _defineProperty(this, "reason", void 0);
27440
+ _defineProperty(this, "payload", void 0);
27441
+ this.claim = claim;
27442
+ this.reason = reason;
27443
+ this.payload = payload;
27444
+ }
27445
+ }
27446
+ _defineProperty(JWTExpired, "code", 'ERR_JWT_EXPIRED');
27447
+ class JOSEAlgNotAllowed extends JOSEError {
27448
+ constructor() {
27449
+ super(...arguments);
27450
+ _defineProperty(this, "code", 'ERR_JOSE_ALG_NOT_ALLOWED');
27451
+ }
27452
+ }
27453
+ _defineProperty(JOSEAlgNotAllowed, "code", 'ERR_JOSE_ALG_NOT_ALLOWED');
27454
+ class JOSENotSupported extends JOSEError {
27455
+ constructor() {
27456
+ super(...arguments);
27457
+ _defineProperty(this, "code", 'ERR_JOSE_NOT_SUPPORTED');
27458
+ }
27459
+ }
27460
+ _defineProperty(JOSENotSupported, "code", 'ERR_JOSE_NOT_SUPPORTED');
27461
+ class JWEDecryptionFailed extends JOSEError {
27462
+ constructor() {
27463
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'decryption operation failed';
27464
+ let options = arguments.length > 1 ? arguments[1] : undefined;
27465
+ super(message, options);
27466
+ _defineProperty(this, "code", 'ERR_JWE_DECRYPTION_FAILED');
27467
+ }
27468
+ }
27469
+ _defineProperty(JWEDecryptionFailed, "code", 'ERR_JWE_DECRYPTION_FAILED');
27470
+ class JWEInvalid extends JOSEError {
27471
+ constructor() {
27472
+ super(...arguments);
27473
+ _defineProperty(this, "code", 'ERR_JWE_INVALID');
27474
+ }
27475
+ }
27476
+ _defineProperty(JWEInvalid, "code", 'ERR_JWE_INVALID');
27477
+ class JWSInvalid extends JOSEError {
27478
+ constructor() {
27479
+ super(...arguments);
27480
+ _defineProperty(this, "code", 'ERR_JWS_INVALID');
27481
+ }
27482
+ }
27483
+ _defineProperty(JWSInvalid, "code", 'ERR_JWS_INVALID');
27484
+ class JWTInvalid extends JOSEError {
27485
+ constructor() {
27486
+ super(...arguments);
27487
+ _defineProperty(this, "code", 'ERR_JWT_INVALID');
27488
+ }
27489
+ }
27490
+ _defineProperty(JWTInvalid, "code", 'ERR_JWT_INVALID');
27491
+ class JWKInvalid extends JOSEError {
27492
+ constructor() {
27493
+ super(...arguments);
27494
+ _defineProperty(this, "code", 'ERR_JWK_INVALID');
27495
+ }
27496
+ }
27497
+ _defineProperty(JWKInvalid, "code", 'ERR_JWK_INVALID');
27498
+ class JWKSInvalid extends JOSEError {
27499
+ constructor() {
27500
+ super(...arguments);
27501
+ _defineProperty(this, "code", 'ERR_JWKS_INVALID');
27502
+ }
27503
+ }
27504
+ _defineProperty(JWKSInvalid, "code", 'ERR_JWKS_INVALID');
27505
+ class JWKSNoMatchingKey extends JOSEError {
27506
+ constructor() {
27507
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'no applicable key found in the JSON Web Key Set';
27508
+ let options = arguments.length > 1 ? arguments[1] : undefined;
27509
+ super(message, options);
27510
+ _defineProperty(this, "code", 'ERR_JWKS_NO_MATCHING_KEY');
27511
+ }
27512
+ }
27513
+ _defineProperty(JWKSNoMatchingKey, "code", 'ERR_JWKS_NO_MATCHING_KEY');
27514
+ class JWKSMultipleMatchingKeys extends JOSEError {
27515
+ constructor() {
27516
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'multiple matching keys found in the JSON Web Key Set';
27517
+ let options = arguments.length > 1 ? arguments[1] : undefined;
27518
+ super(message, options);
27519
+ _defineProperty(this, Symbol.asyncIterator, void 0);
27520
+ _defineProperty(this, "code", 'ERR_JWKS_MULTIPLE_MATCHING_KEYS');
27521
+ }
27522
+ }
27523
+ _defineProperty(JWKSMultipleMatchingKeys, "code", 'ERR_JWKS_MULTIPLE_MATCHING_KEYS');
27524
+ class JWKSTimeout extends JOSEError {
27525
+ constructor() {
27526
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'request timed out';
27527
+ let options = arguments.length > 1 ? arguments[1] : undefined;
27528
+ super(message, options);
27529
+ _defineProperty(this, "code", 'ERR_JWKS_TIMEOUT');
27530
+ }
27531
+ }
27532
+ _defineProperty(JWKSTimeout, "code", 'ERR_JWKS_TIMEOUT');
27533
+ class JWSSignatureVerificationFailed extends JOSEError {
27534
+ constructor() {
27535
+ let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'signature verification failed';
27536
+ let options = arguments.length > 1 ? arguments[1] : undefined;
27537
+ super(message, options);
27538
+ _defineProperty(this, "code", 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED');
27539
+ }
27540
+ }
27541
+ _defineProperty(JWSSignatureVerificationFailed, "code", 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED');
27542
+
27543
+ function isObjectLike(value) {
27544
+ return typeof value === 'object' && value !== null;
27545
+ }
27546
+ var isObject = input => {
27547
+ if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {
27548
+ return false;
27549
+ }
27550
+ if (Object.getPrototypeOf(input) === null) {
27551
+ return true;
27552
+ }
27553
+ let proto = input;
27554
+ while (Object.getPrototypeOf(proto) !== null) {
27555
+ proto = Object.getPrototypeOf(proto);
27556
+ }
27557
+ return Object.getPrototypeOf(input) === proto;
27558
+ };
27559
+
27560
+ function decodeJwt(jwt) {
27561
+ if (typeof jwt !== 'string') throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');
27562
+ const {
27563
+ 1: payload,
27564
+ length
27565
+ } = jwt.split('.');
27566
+ if (length === 5) throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');
27567
+ if (length !== 3) throw new JWTInvalid('Invalid JWT');
27568
+ if (!payload) throw new JWTInvalid('JWTs must contain a payload');
27569
+ let decoded;
27570
+ try {
27571
+ decoded = decode(payload);
27572
+ } catch (_unused) {
27573
+ throw new JWTInvalid('Failed to base64url decode the payload');
27574
+ }
27575
+ let result;
27576
+ try {
27577
+ result = JSON.parse(decoder.decode(decoded));
27578
+ } catch (_unused2) {
27579
+ throw new JWTInvalid('Failed to parse the decoded payload as JSON');
27580
+ }
27581
+ if (!isObject(result)) throw new JWTInvalid('Invalid JWT Claims Set');
27582
+ return result;
27583
+ }
27584
+
27585
+ const ONE_SECOND_IN_MILLISECONDS = 1000;
27586
+ const ONE_MINUTE_IN_MILLISECONDS = 60 * ONE_SECOND_IN_MILLISECONDS;
27587
+ function isResponseExpired(response) {
27588
+ const jwtPayload = decodeTokenPayload(response.participantToken);
27589
+ if (!(jwtPayload === null || jwtPayload === void 0 ? void 0 : jwtPayload.exp)) {
27590
+ return true;
27591
+ }
27592
+ const expInMilliseconds = jwtPayload.exp * ONE_SECOND_IN_MILLISECONDS;
27593
+ const expiresAt = new Date(expInMilliseconds - ONE_MINUTE_IN_MILLISECONDS);
27594
+ const now = new Date();
27595
+ return expiresAt >= now;
27596
+ }
27597
+ function decodeTokenPayload(token) {
27598
+ const payload = decodeJwt(token);
27599
+ const {
27600
+ roomConfig
27601
+ } = payload,
27602
+ rest = __rest(payload, ["roomConfig"]);
27603
+ const mappedPayload = Object.assign(Object.assign({}, rest), {
27604
+ roomConfig: payload.roomConfig ? RoomConfiguration.fromJson(payload.roomConfig) : undefined
27605
+ });
27606
+ return mappedPayload;
27607
+ }
27608
+
27609
+ /** A TokenSourceCached is a TokenSource which caches the last {@link TokenSourceResponseObject} value and returns it
27610
+ * until a) it expires or b) the {@link TokenSourceFetchOptions} provided to .fetch(...) change. */
27611
+ class TokenSourceCached extends TokenSourceConfigurable {
27612
+ constructor() {
27613
+ super(...arguments);
27614
+ this.cachedFetchOptions = null;
27615
+ this.cachedResponse = null;
27616
+ this.fetchMutex = new _();
27617
+ }
27618
+ isSameAsCachedFetchOptions(options) {
27619
+ if (!this.cachedFetchOptions) {
27620
+ return false;
27621
+ }
27622
+ for (const key of Object.keys(this.cachedFetchOptions)) {
27623
+ switch (key) {
27624
+ case 'roomName':
27625
+ case 'participantName':
27626
+ case 'participantIdentity':
27627
+ case 'participantMetadata':
27628
+ case 'participantAttributes':
27629
+ case 'agentName':
27630
+ case 'agentMetadata':
27631
+ if (this.cachedFetchOptions[key] !== options[key]) {
27632
+ return false;
27633
+ }
27634
+ break;
27635
+ default:
27636
+ // ref: https://stackoverflow.com/a/58009992
27637
+ const exhaustiveCheckedKey = key;
27638
+ throw new Error("Options key ".concat(exhaustiveCheckedKey, " not being checked for equality!"));
27639
+ }
27640
+ }
27641
+ return true;
27642
+ }
27643
+ shouldReturnCachedValueFromFetch(fetchOptions) {
27644
+ if (!this.cachedResponse) {
27645
+ return false;
27646
+ }
27647
+ if (isResponseExpired(this.cachedResponse)) {
27648
+ return false;
27649
+ }
27650
+ if (this.isSameAsCachedFetchOptions(fetchOptions)) {
27651
+ return false;
27652
+ }
27653
+ return true;
27654
+ }
27655
+ getCachedResponseJwtPayload() {
27656
+ if (!this.cachedResponse) {
27657
+ return null;
27658
+ }
27659
+ return decodeTokenPayload(this.cachedResponse.participantToken);
27660
+ }
27661
+ fetch(options) {
27662
+ return __awaiter(this, void 0, void 0, function* () {
27663
+ const unlock = yield this.fetchMutex.lock();
27664
+ try {
27665
+ if (this.shouldReturnCachedValueFromFetch(options)) {
27666
+ return this.cachedResponse.toJson();
27667
+ }
27668
+ this.cachedFetchOptions = options;
27669
+ const tokenResponse = yield this.update(options);
27670
+ this.cachedResponse = tokenResponse;
27671
+ return tokenResponse.toJson();
27672
+ } finally {
27673
+ unlock();
27674
+ }
27675
+ });
27676
+ }
27677
+ }
27678
+ class TokenSourceLiteral extends TokenSourceFixed {
27679
+ constructor(literalOrFn) {
27680
+ super();
27681
+ this.literalOrFn = literalOrFn;
27682
+ }
27683
+ fetch() {
27684
+ return __awaiter(this, void 0, void 0, function* () {
27685
+ if (typeof this.literalOrFn === 'function') {
27686
+ return this.literalOrFn();
27687
+ } else {
27688
+ return this.literalOrFn;
27689
+ }
27690
+ });
27691
+ }
27692
+ }
27693
+ class TokenSourceCustom extends TokenSourceCached {
27694
+ constructor(customFn) {
27695
+ super();
27696
+ this.customFn = customFn;
27697
+ }
27698
+ update(options) {
27699
+ return __awaiter(this, void 0, void 0, function* () {
27700
+ const resultMaybePromise = this.customFn(options);
27701
+ let result;
27702
+ if (resultMaybePromise instanceof Promise) {
27703
+ result = yield resultMaybePromise;
27704
+ } else {
27705
+ result = resultMaybePromise;
27706
+ }
27707
+ return TokenSourceResponse.fromJson(result, {
27708
+ // NOTE: it could be possible that the response body could contain more fields than just
27709
+ // what's in TokenSourceResponse depending on the implementation
27710
+ ignoreUnknownFields: true
27711
+ });
27712
+ });
27713
+ }
27714
+ }
27715
+ class TokenSourceEndpoint extends TokenSourceCached {
27716
+ constructor(url) {
27717
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27718
+ super();
27719
+ this.url = url;
27720
+ this.endpointOptions = options;
27721
+ }
27722
+ createRequestFromOptions(options) {
27723
+ var _a, _b, _c;
27724
+ const request = new TokenSourceRequest();
27725
+ for (const key of Object.keys(options)) {
27726
+ switch (key) {
27727
+ case 'roomName':
27728
+ case 'participantName':
27729
+ case 'participantIdentity':
27730
+ case 'participantMetadata':
27731
+ request[key] = options[key];
27732
+ break;
27733
+ case 'participantAttributes':
27734
+ request.participantAttributes = (_a = options.participantAttributes) !== null && _a !== void 0 ? _a : {};
27735
+ break;
27736
+ case 'agentName':
27737
+ request.roomConfig = (_b = request.roomConfig) !== null && _b !== void 0 ? _b : new RoomConfiguration();
27738
+ if (request.roomConfig.agents.length === 0) {
27739
+ request.roomConfig.agents.push(new RoomAgentDispatch());
27740
+ }
27741
+ request.roomConfig.agents[0].agentName = options.agentName;
27742
+ break;
27743
+ case 'agentMetadata':
27744
+ request.roomConfig = (_c = request.roomConfig) !== null && _c !== void 0 ? _c : new RoomConfiguration();
27745
+ if (request.roomConfig.agents.length === 0) {
27746
+ request.roomConfig.agents.push(new RoomAgentDispatch());
27747
+ }
27748
+ request.roomConfig.agents[0].metadata = options.agentMetadata;
27749
+ break;
27750
+ default:
27751
+ // ref: https://stackoverflow.com/a/58009992
27752
+ const exhaustiveCheckedKey = key;
27753
+ throw new Error("Options key ".concat(exhaustiveCheckedKey, " not being included in forming request!"));
27754
+ }
27755
+ }
27756
+ return request;
27757
+ }
27758
+ update(options) {
27759
+ return __awaiter(this, void 0, void 0, function* () {
27760
+ var _a;
27761
+ const request = this.createRequestFromOptions(options);
27762
+ const response = yield fetch(this.url, Object.assign(Object.assign({}, this.endpointOptions), {
27763
+ method: (_a = this.endpointOptions.method) !== null && _a !== void 0 ? _a : 'POST',
27764
+ headers: Object.assign({
27765
+ 'Content-Type': 'application/json'
27766
+ }, this.endpointOptions.headers),
27767
+ body: request.toJsonString({
27768
+ useProtoFieldName: true
27769
+ })
27770
+ }));
27771
+ if (!response.ok) {
27772
+ throw new Error("Error generating token from endpoint ".concat(this.url, ": received ").concat(response.status, " / ").concat(yield response.text()));
27773
+ }
27774
+ const body = yield response.json();
27775
+ return TokenSourceResponse.fromJson(body, {
27776
+ // NOTE: it could be possible that the response body could contain more fields than just
27777
+ // what's in TokenSourceResponse depending on the implementation (ie, SandboxTokenServer)
27778
+ ignoreUnknownFields: true
27779
+ });
27780
+ });
27781
+ }
27782
+ }
27783
+ class TokenSourceSandboxTokenServer extends TokenSourceEndpoint {
27784
+ constructor(sandboxId, options) {
27785
+ const {
27786
+ baseUrl = 'https://cloud-api.livekit.io'
27787
+ } = options,
27788
+ rest = __rest(options, ["baseUrl"]);
27789
+ super("".concat(baseUrl, "/api/v2/sandbox/connection-details"), Object.assign(Object.assign({}, rest), {
27790
+ headers: {
27791
+ 'X-Sandbox-ID': sandboxId
27792
+ }
27793
+ }));
27794
+ }
27795
+ }
27796
+ const TokenSource = {
27797
+ /** TokenSource.literal contains a single, literal set of {@link TokenSourceResponseObject}
27798
+ * credentials, either provided directly or returned from a provided function. */
27799
+ literal(literalOrFn) {
27800
+ return new TokenSourceLiteral(literalOrFn);
27801
+ },
27802
+ /**
27803
+ * TokenSource.custom allows a user to define a manual function which generates new
27804
+ * {@link TokenSourceResponseObject} values on demand.
27805
+ *
27806
+ * Use this to get credentials from custom backends / etc.
27807
+ */
27808
+ custom(customFn) {
27809
+ return new TokenSourceCustom(customFn);
27810
+ },
27811
+ /**
27812
+ * TokenSource.endpoint creates a token source that fetches credentials from a given URL using
27813
+ * the standard endpoint format:
27814
+ * FIXME: add docs link here in the future!
27815
+ */
27816
+ endpoint(url) {
27817
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27818
+ return new TokenSourceEndpoint(url, options);
27819
+ },
27820
+ /**
27821
+ * TokenSource.sandboxTokenServer queries a sandbox token server for credentials,
27822
+ * which supports quick prototyping / getting started types of use cases.
27823
+ *
27824
+ * This token provider is INSECURE and should NOT be used in production.
27825
+ *
27826
+ * For more info:
27827
+ * @see https://cloud.livekit.io/projects/p_/sandbox/templates/token-server
27828
+ */
27829
+ sandboxTokenServer(sandboxId) {
27830
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27831
+ return new TokenSourceSandboxTokenServer(sandboxId, options);
27832
+ }
27833
+ };
27834
+
26096
27835
  /**
26097
27836
  * Try to analyze the local track to determine the facing mode of a track.
26098
27837
  *
@@ -26174,5 +27913,5 @@ function isFacingModeValue(item) {
26174
27913
  return item === undefined || allowedValues.includes(item);
26175
27914
  }
26176
27915
 
26177
- export { AudioPresets, BackupCodecPolicy, BaseKeyProvider, CheckStatus, Checker, ConnectionCheck, ConnectionError, ConnectionErrorReason, ConnectionQuality, ConnectionState, CriticalTimers, CryptorError, CryptorErrorReason, CryptorEvent, DataPacket_Kind, DataStreamError, DataStreamErrorReason, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalTrackRecorder, LocalVideoTrack, LogLevel, LoggerNames, MediaDeviceFailure, _ as Mutex, NegotiationError, Participant, ParticipantEvent, ParticipantInfo_Kind as ParticipantKind, PublishDataError, PublishTrackError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RpcError, ScreenSharePresets, SignalRequestError, SubscriptionError, Track, TrackEvent, TrackInvalidError, TrackPublication, TrackType, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, attributeTypings as attributes, compareVersions, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, importKey, isAudioTrack, isBackupCodec, isBrowserSupported, isE2EESupported, isInsertableStreamSupported, isLocalParticipant, isLocalTrack, isRemoteParticipant, isRemoteTrack, isScriptTransformSupported, isVideoFrame, isVideoTrack, needsRbspUnescaping, parseRbsp, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs, writeRbsp };
27916
+ export { AudioPresets, BackupCodecPolicy, BaseKeyProvider, CheckStatus, Checker, ConnectionCheck, ConnectionError, ConnectionErrorReason, ConnectionQuality, ConnectionState, CriticalTimers, CryptorError, CryptorErrorReason, CryptorEvent, DataPacket_Kind, DataStreamError, DataStreamErrorReason, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, Encryption_Type, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalTrackRecorder, LocalVideoTrack, LogLevel, LoggerNames, MediaDeviceFailure, _ as Mutex, NegotiationError, Participant, ParticipantEvent, ParticipantInfo_Kind as ParticipantKind, PublishDataError, PublishTrackError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RpcError, ScreenSharePresets, SignalRequestError, SubscriptionError, TokenSource, TokenSourceConfigurable, TokenSourceCustom, TokenSourceEndpoint, TokenSourceFixed, TokenSourceLiteral, TokenSourceSandboxTokenServer, Track, TrackEvent, TrackInvalidError, TrackPublication, TrackType, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, asEncryptablePacket, attachToElement, attributeTypings as attributes, audioCodecs, compareVersions, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, importKey, isAudioCodec, isAudioTrack, isBackupCodec, isBackupVideoCodec, isBrowserSupported, isE2EESupported, isInsertableStreamSupported, isLocalParticipant, isLocalTrack, isRemoteParticipant, isRemoteTrack, isScriptTransformSupported, isVideoCodec, isVideoFrame, isVideoTrack, needsRbspUnescaping, parseRbsp, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs, writeRbsp };
26178
27917
  //# sourceMappingURL=livekit-client.esm.mjs.map