sip-connector 13.3.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var se = Object.defineProperty;
2
2
  var oe = (n, e, t) => e in n ? se(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var c = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as G, N as K, l as a, E as x, s as re, a as ie, P as ce, b as ae, S as sn } from "./SipConnector-B4xLnl6L.js";
5
- import { i as mn, j as hn, m as Rn, k as gn, c as pn, d as yn, f as En, g as Tn, e as bn, h as Mn } from "./SipConnector-B4xLnl6L.js";
3
+ var a = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as G, N as K, l as c, E as x, s as re, a as ie, P as ce, b as ae } from "./SipConnector-Cc1z-VjV.js";
5
+ import { i as Cn, j as mn, m as hn, k as Rn, S as gn, c as pn, d as yn, f as En, g as Tn, e as bn, h as Mn } from "./SipConnector-Cc1z-VjV.js";
6
6
  import { sequentPromises as ue } from "sequent-promises";
7
7
  import { createStackPromises as le } from "stack-promises";
8
8
  import { isCanceledError as de } from "@krivega/cancelable-promise";
@@ -41,7 +41,7 @@ const Ce = (n = new Error()) => {
41
41
  try {
42
42
  e = JSON.stringify(n);
43
43
  } catch (t) {
44
- a("failed to stringify message", t);
44
+ c("failed to stringify message", t);
45
45
  }
46
46
  return e;
47
47
  }, he = (n = new Error()) => {
@@ -87,7 +87,7 @@ const Ce = (n = new Error()) => {
87
87
  }) => {
88
88
  const o = Me(e)(n);
89
89
  return ue(o, t);
90
- }, Ae = (n) => (t) => (a("onStartMainCam"), n.onSession("admin-start-main-cam", t)), ve = (n) => (t) => (a("onStartMic"), n.onSession("admin-start-mic", t)), Oe = (n) => (t) => (a("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), Ne = (n) => (t) => (a("onStopMic"), n.onSession("admin-stop-mic", t)), we = ({ sipConnector: n }) => {
90
+ }, Ae = (n) => (t) => (c("onStartMainCam"), n.onSession("admin-start-main-cam", t)), ve = (n) => (t) => (c("onStartMic"), n.onSession("admin-start-mic", t)), Oe = (n) => (t) => (c("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), Ne = (n) => (t) => (c("onStopMic"), n.onSession("admin-stop-mic", t)), we = ({ sipConnector: n }) => {
91
91
  const e = (m, p) => ({ isSyncForced: h = !1 }) => {
92
92
  if (h) {
93
93
  m();
@@ -135,7 +135,7 @@ const Ce = (n = new Error()) => {
135
135
  f();
136
136
  }
137
137
  };
138
- }, ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
138
+ }, un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
139
139
  __proto__: null,
140
140
  PURGATORY_CONFERENCE_NUMBER: q,
141
141
  createSyncMediaState: we,
@@ -161,7 +161,7 @@ const Ce = (n = new Error()) => {
161
161
  const s = n.getSettings(), o = s.width, r = s.height, i = o / e.width, u = r / e.height, l = Math.max(i, u, He), S = Z(e.width, t);
162
162
  return { scaleResolutionDownBy: l, maxBitrate: S };
163
163
  }, ne = le(), Xe = async () => ne().catch((n) => {
164
- a("videoSendingBalancer: error", n);
164
+ c("videoSendingBalancer: error", n);
165
165
  }), je = async (n) => (ne.add(n), Xe()), X = async ({
166
166
  sender: n,
167
167
  scaleResolutionDownBy: e,
@@ -257,7 +257,7 @@ const Ce = (n = new Error()) => {
257
257
  },
258
258
  s
259
259
  );
260
- }, dn = (n, {
260
+ }, ln = (n, {
261
261
  ignoreForCodec: e,
262
262
  onSetParameters: t
263
263
  } = {}) => {
@@ -331,11 +331,15 @@ const Ce = (n = new Error()) => {
331
331
  excludeMimeTypesVideoCodecs: t
332
332
  }) => async (s) => {
333
333
  var o;
334
- if (typeof s.setCodecPreferences == "function" && ((o = s.sender.track) == null ? void 0 : o.kind) === "video" && (e !== void 0 && (e == null ? void 0 : e.length) > 0 || t !== void 0 && (t == null ? void 0 : t.length) > 0)) {
335
- const r = ze("video"), i = Je(r, t), u = Qe(i, e);
336
- s.setCodecPreferences(u);
334
+ try {
335
+ if (typeof s.setCodecPreferences == "function" && ((o = s.sender.track) == null ? void 0 : o.kind) === "video" && (e !== void 0 && (e == null ? void 0 : e.length) > 0 || t !== void 0 && (t == null ? void 0 : t.length) > 0)) {
336
+ const r = ze("video"), i = Je(r, t), u = Qe(i, e);
337
+ s.setCodecPreferences(u);
338
+ }
339
+ Object.keys(n).length > 0 && await ie(s.sender, n);
340
+ } catch (r) {
341
+ c("updateTransceiver error", r);
337
342
  }
338
- Object.keys(n).length > 0 && await ie(s.sender, n);
339
343
  }, $ = (n) => {
340
344
  if (!de(n) && !Se(n))
341
345
  throw n;
@@ -362,55 +366,55 @@ const Ce = (n = new Error()) => {
362
366
  "isConfigured",
363
367
  "isRegistered"
364
368
  ]);
365
- class Sn {
369
+ class dn {
366
370
  constructor(e, {
367
371
  preferredMimeTypesVideoCodecs: t,
368
372
  excludeMimeTypesVideoCodecs: s
369
373
  } = {}) {
370
- c(this, "sipConnector");
371
- c(this, "preferredMimeTypesVideoCodecs");
372
- c(this, "excludeMimeTypesVideoCodecs");
374
+ a(this, "sipConnector");
375
+ a(this, "preferredMimeTypesVideoCodecs");
376
+ a(this, "excludeMimeTypesVideoCodecs");
373
377
  // @ts-expect-error: proxy method
374
- c(this, "on");
378
+ a(this, "on");
375
379
  // @ts-expect-error: proxy method
376
- c(this, "once");
380
+ a(this, "once");
377
381
  // @ts-expect-error: proxy method
378
- c(this, "onceRace");
382
+ a(this, "onceRace");
379
383
  // @ts-expect-error: proxy method
380
- c(this, "wait");
384
+ a(this, "wait");
381
385
  // @ts-expect-error: proxy method
382
- c(this, "off");
386
+ a(this, "off");
383
387
  // @ts-expect-error: proxy method
384
- c(this, "onSession");
388
+ a(this, "onSession");
385
389
  // @ts-expect-error: proxy method
386
- c(this, "onceSession");
390
+ a(this, "onceSession");
387
391
  // @ts-expect-error: proxy method
388
- c(this, "onceRaceSession");
392
+ a(this, "onceRaceSession");
389
393
  // @ts-expect-error: proxy method
390
- c(this, "waitSession");
394
+ a(this, "waitSession");
391
395
  // @ts-expect-error: proxy method
392
- c(this, "offSession");
396
+ a(this, "offSession");
393
397
  // @ts-expect-error: proxy method
394
- c(this, "sendDTMF");
398
+ a(this, "sendDTMF");
395
399
  // @ts-expect-error: proxy method
396
- c(this, "hangUp");
400
+ a(this, "hangUp");
397
401
  // @ts-expect-error: proxy method
398
- c(this, "declineToIncomingCall");
402
+ a(this, "declineToIncomingCall");
399
403
  // @ts-expect-error: proxy method
400
- c(this, "sendChannels");
404
+ a(this, "sendChannels");
401
405
  // @ts-expect-error: proxy method
402
- c(this, "checkTelephony");
406
+ a(this, "checkTelephony");
403
407
  // @ts-expect-error: proxy method
404
- c(this, "waitChannels");
408
+ a(this, "waitChannels");
405
409
  // @ts-expect-error: proxy method
406
- c(this, "ping");
410
+ a(this, "ping");
407
411
  // proxy method
408
- c(this, "connection");
412
+ a(this, "connection");
409
413
  // @ts-expect-error: proxy method
410
- c(this, "isConfigured");
414
+ a(this, "isConfigured");
411
415
  // @ts-expect-error: proxy method
412
- c(this, "isRegistered");
413
- c(this, "connectToServer", async (e) => {
416
+ a(this, "isRegistered");
417
+ a(this, "connectToServer", async (e) => {
414
418
  const {
415
419
  userAgent: t,
416
420
  sipWebSocketServerURL: s,
@@ -422,7 +426,7 @@ class Sn {
422
426
  isRegisteredUser: S,
423
427
  isDisconnectOnFail: C
424
428
  } = e;
425
- return a("connectToServer", e), this.sipConnector.connect({
429
+ return c("connectToServer", e), this.sipConnector.connect({
426
430
  userAgent: t,
427
431
  sipWebSocketServerURL: s,
428
432
  sipServerUrl: o,
@@ -431,9 +435,9 @@ class Sn {
431
435
  password: l,
432
436
  user: u,
433
437
  register: S
434
- }).then((f) => (a("connectToServer then"), { ua: f, isSuccessful: !0 })).catch(async (f) => (a("connectToServer catch: error", f), C === !0 ? this.sipConnector.disconnect().then(() => $(f)).catch(() => $(f)) : $(f)));
438
+ }).then((f) => (c("connectToServer then"), { ua: f, isSuccessful: !0 })).catch(async (f) => (c("connectToServer catch: error", f), C === !0 ? this.sipConnector.disconnect().then(() => $(f)).catch(() => $(f)) : $(f)));
435
439
  });
436
- c(this, "callToServer", async (e) => {
440
+ a(this, "callToServer", async (e) => {
437
441
  const {
438
442
  conference: t,
439
443
  mediaStream: s,
@@ -468,8 +472,8 @@ class Sn {
468
472
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
469
473
  }
470
474
  );
471
- a("callToServer", e);
472
- const N = async () => (a("startCall"), this.sipConnector.call({
475
+ c("callToServer", e);
476
+ const N = async () => (c("startCall"), this.sipConnector.call({
473
477
  mediaStream: s,
474
478
  extraHeaders: o,
475
479
  iceServers: r,
@@ -488,20 +492,20 @@ class Sn {
488
492
  ontrack: v
489
493
  }));
490
494
  let M = !1, _;
491
- const w = (a("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
492
- a("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? R && R() : y && y({ isSuccessProgressCall: M });
495
+ const w = (c("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
496
+ c("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? R && R() : y && y({ isSuccessProgressCall: M });
493
497
  }) : () => {
494
- }), k = (d) => (a("onSuccess"), M = !0, A(), h && h({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
498
+ }), k = (d) => (c("onSuccess"), M = !0, A(), h && h({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
495
499
  w(), b && b();
496
500
  }), d), U = (d) => {
497
- throw a("onFail"), E && E(), w(), d;
501
+ throw c("onFail"), E && E(), w(), d;
498
502
  }, V = () => {
499
- a("onFinish"), T && T();
503
+ c("onFinish"), T && T();
500
504
  };
501
- return a("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
505
+ return c("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
502
506
  });
503
- c(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (a("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (a("disconnectFromServer: catch", e), { isSuccessful: !1 })));
504
- c(this, "answerIncomingCall", async (e) => {
507
+ a(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (c("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (c("disconnectFromServer: catch", e), { isSuccessful: !1 })));
508
+ a(this, "answerIncomingCall", async (e) => {
505
509
  const {
506
510
  mediaStream: t,
507
511
  extraHeaders: s,
@@ -535,7 +539,7 @@ class Sn {
535
539
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
536
540
  }
537
541
  );
538
- a("answerIncomingCall", e);
542
+ c("answerIncomingCall", e);
539
543
  const O = async () => this.sipConnector.answerToIncomingCall({
540
544
  mediaStream: t,
541
545
  extraHeaders: s,
@@ -557,23 +561,23 @@ class Sn {
557
561
  return d.incomingNumber;
558
562
  };
559
563
  let M = !1, _;
560
- const w = (a("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
561
- a("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? h && h() : R && R({ isSuccessProgressCall: M });
564
+ const w = (c("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
565
+ c("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? h && h() : R && R({ isSuccessProgressCall: M });
562
566
  }) : () => {
563
- }), k = (d) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
567
+ }), k = (d) => (c("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
564
568
  w(), T && T();
565
569
  }), d), U = (d) => {
566
- throw a("onFail"), y && y(), w(), d;
570
+ throw c("onFail"), y && y(), w(), d;
567
571
  }, V = () => {
568
- a("onFinish"), E && E();
572
+ c("onFinish"), E && E();
569
573
  };
570
- if (a("onBeforeProgressCall"), m) {
574
+ if (c("onBeforeProgressCall"), m) {
571
575
  const d = N();
572
576
  m(d);
573
577
  }
574
578
  return O().then(k).catch((d) => U(d)).finally(V);
575
579
  });
576
- c(this, "updatePresentation", async ({
580
+ a(this, "updatePresentation", async ({
577
581
  mediaStream: e,
578
582
  isP2P: t,
579
583
  maxBitrate: s,
@@ -593,7 +597,7 @@ class Sn {
593
597
  excludeMimeTypesVideoCodecs: S
594
598
  }
595
599
  );
596
- return a("updatePresentation"), this.sipConnector.updatePresentation(e, {
600
+ return c("updatePresentation"), this.sipConnector.updatePresentation(e, {
597
601
  isP2P: t,
598
602
  maxBitrate: s,
599
603
  contentHint: o,
@@ -605,7 +609,7 @@ class Sn {
605
609
  onAddedTransceiver: C
606
610
  });
607
611
  });
608
- c(this, "startPresentation", async ({
612
+ a(this, "startPresentation", async ({
609
613
  mediaStream: e,
610
614
  isP2P: t,
611
615
  maxBitrate: s,
@@ -625,7 +629,7 @@ class Sn {
625
629
  excludeMimeTypesVideoCodecs: S
626
630
  }
627
631
  );
628
- return a("startPresentation"), this.sipConnector.startPresentation(
632
+ return c("startPresentation"), this.sipConnector.startPresentation(
629
633
  e,
630
634
  {
631
635
  isP2P: t,
@@ -641,31 +645,31 @@ class Sn {
641
645
  C
642
646
  );
643
647
  });
644
- c(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (a("stopShareSipConnector"), this.sipConnector.stopPresentation({
648
+ a(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (c("stopShareSipConnector"), this.sipConnector.stopPresentation({
645
649
  isP2P: e
646
650
  }).catch((t) => {
647
- a(t);
651
+ c(t);
648
652
  })));
649
- c(this, "sendRefusalToTurnOnMic", async () => {
653
+ a(this, "sendRefusalToTurnOnMic", async () => {
650
654
  if (this.sipConnector.isCallActive)
651
- return a("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
652
- a("sendRefusalToTurnOnMic: error", e);
655
+ return c("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
656
+ c("sendRefusalToTurnOnMic: error", e);
653
657
  });
654
658
  });
655
- c(this, "sendRefusalToTurnOnCam", async () => {
659
+ a(this, "sendRefusalToTurnOnCam", async () => {
656
660
  if (this.sipConnector.isCallActive)
657
- return a("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
658
- a("sendRefusalToTurnOnCam: error", e);
661
+ return c("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
662
+ c("sendRefusalToTurnOnCam: error", e);
659
663
  });
660
664
  });
661
- c(this, "sendMediaState", async ({
665
+ a(this, "sendMediaState", async ({
662
666
  isEnabledCam: e,
663
667
  isEnabledMic: t
664
668
  }) => {
665
669
  if (this.sipConnector.isCallActive)
666
- return a("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
670
+ return c("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
667
671
  });
668
- c(this, "replaceMediaStream", async (e, {
672
+ a(this, "replaceMediaStream", async (e, {
669
673
  deleteExisting: t,
670
674
  addMissing: s,
671
675
  forceRenegotiation: o,
@@ -683,7 +687,7 @@ class Sn {
683
687
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
684
688
  }
685
689
  );
686
- return a("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
690
+ return c("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
687
691
  deleteExisting: t,
688
692
  addMissing: s,
689
693
  forceRenegotiation: o,
@@ -696,26 +700,26 @@ class Sn {
696
700
  onAddedTransceiver: S
697
701
  });
698
702
  });
699
- c(this, "askPermissionToEnableCam", async () => {
703
+ a(this, "askPermissionToEnableCam", async () => {
700
704
  if (this.sipConnector.isCallActive)
701
- return a("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
705
+ return c("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
702
706
  });
703
- c(this, "resolveHandleReadyRemoteStreamsDebounced", ({
707
+ a(this, "resolveHandleReadyRemoteStreamsDebounced", ({
704
708
  onReadyRemoteStreams: e
705
709
  }) => fe(() => {
706
710
  const t = this.sipConnector.getRemoteStreams();
707
- a("remoteStreams", t), t && e(t);
711
+ c("remoteStreams", t), t && e(t);
708
712
  }, 200));
709
- c(this, "resolveHandleReadyRemoteStreams", ({
713
+ a(this, "resolveHandleReadyRemoteStreams", ({
710
714
  onReadyRemoteStreams: e
711
715
  }) => ({ track: t }) => {
712
716
  Ze(t) && e();
713
717
  });
714
- c(this, "getRemoteStreams", () => (a("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
715
- c(this, "onUseLicense", (e) => (a("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
716
- c(this, "onMustStopPresentation", (e) => (a("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
717
- c(this, "onMoveToSpectators", (e) => (a("onMoveToSpectators"), this.sipConnector.onSession(ce, e)));
718
- c(this, "onMoveToParticipants", (e) => (a("onMoveToParticipants"), this.sipConnector.onSession(ae, e)));
718
+ a(this, "getRemoteStreams", () => (c("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
719
+ a(this, "onUseLicense", (e) => (c("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
720
+ a(this, "onMustStopPresentation", (e) => (c("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
721
+ a(this, "onMoveToSpectators", (e) => (c("onMoveToSpectators"), this.sipConnector.onSession(ce, e)));
722
+ a(this, "onMoveToParticipants", (e) => (c("onMoveToParticipants"), this.sipConnector.onSession(ae, e)));
719
723
  return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, new Proxy(this, {
720
724
  get: (o, r, i) => {
721
725
  if (typeof r == "string" && en.has(r) && r in this.sipConnector) {
@@ -730,21 +734,21 @@ class Sn {
730
734
  }
731
735
  export {
732
736
  x as EEventsMainCAM,
733
- mn as EEventsMic,
734
- hn as EEventsSyncMediaState,
735
- Rn as EMimeTypesVideoCodecs,
736
- gn as EUseLicense,
737
- Sn as SipConnectorFacade,
737
+ Cn as EEventsMic,
738
+ mn as EEventsSyncMediaState,
739
+ hn as EMimeTypesVideoCodecs,
740
+ Rn as EUseLicense,
741
+ gn as SipConnector,
742
+ dn as SipConnectorFacade,
738
743
  pn as causes,
739
744
  yn as constants,
740
745
  An as debug,
741
- sn as default,
742
746
  En as disableDebug,
743
747
  Tn as enableDebug,
744
748
  bn as eventNames,
745
749
  De as getCodecFromSender,
746
750
  Mn as hasCanceledCallError,
747
- dn as resolveVideoSendingBalancer,
751
+ ln as resolveVideoSendingBalancer,
748
752
  ie as setParametersToSender,
749
- ln as tools
753
+ un as tools
750
754
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "13.3.1",
3
+ "version": "14.0.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -63,19 +63,19 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@krivega/cancelable-promise": "^1.1.3",
66
- "@krivega/jssip": "^5.1.0",
66
+ "@krivega/jssip": "^5.1.2",
67
67
  "debug": "^4.4.0",
68
68
  "events-constructor": "^1.3.0",
69
69
  "repeated-calls": "^2.3.0",
70
70
  "sequent-promises": "^2.0.1",
71
- "stack-promises": "^2.0.2",
71
+ "stack-promises": "^2.0.3",
72
72
  "ts-debounce": "^4.0.0",
73
73
  "webrtc-mock": "^1.1.6"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@babel/preset-typescript": "^7.26.0",
77
- "@commitlint/cli": "^19.6.1",
78
- "@commitlint/config-conventional": "^19.6.0",
77
+ "@commitlint/cli": "^19.7.1",
78
+ "@commitlint/config-conventional": "^19.7.1",
79
79
  "@nabla/vite-plugin-eslint": "^2.0.5",
80
80
  "@types/debug": "^4.1.12",
81
81
  "@types/dom-mediacapture-transform": "^0.1.10",
@@ -86,37 +86,37 @@
86
86
  "eslint": "^8.57.0",
87
87
  "eslint-config-airbnb-base": "^15.0.0",
88
88
  "eslint-config-airbnb-typescript": "^18.0.0",
89
- "eslint-config-prettier": "^9.1.0",
89
+ "eslint-config-prettier": "^10.0.1",
90
90
  "eslint-import-resolver-typescript": "^3.7.0",
91
91
  "eslint-plugin-flowtype": "^8.0.3",
92
92
  "eslint-plugin-import": "^2.31.0",
93
- "eslint-plugin-jest": "^28.10.0",
94
- "eslint-plugin-prettier": "^5.2.1",
93
+ "eslint-plugin-jest": "^28.11.0",
94
+ "eslint-plugin-prettier": "^5.2.3",
95
95
  "eslint-plugin-unicorn": "^56.0.1",
96
96
  "husky": "^9.1.7",
97
97
  "jest": "^29.7.0",
98
98
  "jest-environment-jsdom": "^29.7.0",
99
99
  "jest-extended": "^4.0.2",
100
100
  "jest-junit": "^16.0.0",
101
- "lint-staged": "^15.2.11",
102
- "prettier": "^3.4.2",
101
+ "lint-staged": "^15.4.3",
102
+ "prettier": "^3.5.0",
103
103
  "standard-version": "^9.5.0",
104
104
  "ts-jest": "^29.2.5",
105
105
  "ts-node": "^10.9.2",
106
106
  "tsc-files": "^1.1.4",
107
- "typescript": "^5.7.2",
108
- "vite": "^6.0.4",
109
- "vite-plugin-dts": "^4.4.0",
107
+ "typescript": "^5.7.3",
108
+ "vite": "^6.1.0",
109
+ "vite-plugin-dts": "^4.5.0",
110
110
  "vite-tsconfig-paths": "^5.1.4"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@krivega/cancelable-promise": "^1.1.3",
114
- "@krivega/jssip": "^5.1.0",
114
+ "@krivega/jssip": "^5.1.2",
115
115
  "debug": "^4.4.0",
116
116
  "events-constructor": "^1.3.0",
117
117
  "repeated-calls": "^2.2.1",
118
118
  "sequent-promises": "^2.0.1",
119
- "stack-promises": "^2.0.2",
119
+ "stack-promises": "^2.0.3",
120
120
  "ts-debounce": "^4.0.0",
121
121
  "webrtc-mock": "^1.0.4"
122
122
  },
@@ -1 +0,0 @@
1
- "use strict";var Mt=Object.defineProperty;var pt=(s,e,t)=>e in s?Mt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>pt(s,typeof e!="symbol"?e+"":e,t);const C=require("@krivega/cancelable-promise"),we=require("events-constructor"),Ue=require("repeated-calls"),J=require("debug"),vt="Connection Error",Fe="Request Timeout",yt="SIP Failure Code",bt="Internal Error",wt="Busy",X="Rejected",Ut="Redirected",Lt="Unavailable",xe="Not Found",Ht="Address Incomplete",Wt="Incompatible SDP",qt="Missing SDP",kt="Authentication Error",Ve="Terminated",Bt="WebRTC Error",Ye="Canceled",Ft="No Answer",xt="Expires",Vt="No ACK",Yt="Dialog Error",Gt="User Denied Media Access",Ge="Bad Media Description",$t="RTP Timeout",Jt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:Ht,AUTHENTICATION_ERROR:kt,BAD_MEDIA_DESCRIPTION:Ge,BUSY:wt,BYE:Ve,CANCELED:Ye,CONNECTION_ERROR:vt,DIALOG_ERROR:Yt,EXPIRES:xt,INCOMPATIBLE_SDP:Wt,INTERNAL_ERROR:bt,MISSING_SDP:qt,NOT_FOUND:xe,NO_ACK:Vt,NO_ANSWER:Ft,REDIRECTED:Ut,REJECTED:X,REQUEST_TIMEOUT:Fe,RTP_TIMEOUT:$t,SIP_FAILURE_CODE:yt,UNAVAILABLE:Lt,USER_DENIED_MEDIA_ACCESS:Gt,WEBRTC_ERROR:Bt},Symbol.toStringTag,{value:"Module"})),Q="incomingCall",z="declinedIncomingCall",j="failedIncomingCall",K="terminatedIncomingCall",F="connecting",O="connected",N="disconnected",b="newRTCSession",m="registered",Z="unregistered",D="registrationFailed",$e="newMessage",ee="sipEvent",te="availableSecondRemoteStream",ne="notAvailableSecondRemoteStream",se="mustStopPresentation",w="shareState",ie="enterRoom",oe="useLicense",re="peerconnection:confirmed",ae="peerconnection:ontrack",U="channels",ce="channels:notify",Ee="ended:fromserver",_e="main-cam-control",le="admin-stop-main-cam",de="admin-start-main-cam",he="admin-stop-mic",Te="admin-start-mic",L="admin-force-sync-media-state",ue="participant:added-to-list-moderators",Se="participant:removed-from-list-moderators",Ne="participant:move-request-to-stream",x="participant:move-request-to-spectators",V="participant:move-request-to-participants",Ce="participation:accepting-word-request",ge="participation:cancelling-word-request",Ae="webcast:started",Re="webcast:stopped",Ie="account:changed",fe="account:deleted",Pe="conference:participant-token-issued",M="ended",Je="sending",Xe="reinvite",Qe="replaces",ze="refer",je="progress",Ke="accepted",H="confirmed",W="peerconnection",R="failed",Ze="muted",et="unmuted",Oe="newDTMF",me="newInfo",tt="hold",nt="unhold",st="update",it="sdp",ot="icecandidate",rt="getusermediafailed",at="peerconnection:createofferfailed",ct="peerconnection:createanswerfailed",Et="peerconnection:setlocaldescriptionfailed",_t="peerconnection:setremotedescriptionfailed",lt="presentation:start",dt="presentation:started",ht="presentation:end",De="presentation:ended",q="presentation:failed",Tt="SPECTATOR",ut="PARTICIPANT",St=1e6,Xt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Ke,ACCOUNT_CHANGED:Ie,ACCOUNT_DELETED:fe,ADMIN_FORCE_SYNC_MEDIA_STATE:L,ADMIN_START_MAIN_CAM:de,ADMIN_START_MIC:Te,ADMIN_STOP_MAIN_CAM:le,ADMIN_STOP_MIC:he,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:te,CHANNELS:U,CHANNELS_NOTIFY:ce,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Pe,CONFIRMED:H,CONNECTED:O,CONNECTING:F,DECLINED_INCOMING_CALL:z,DISCONNECTED:N,ENDED:M,ENDED_FROM_SERVER:Ee,ENTER_ROOM:ie,FAILED:R,FAILED_INCOMING_CALL:j,GET_USER_MEDIA_FAILED:rt,HOLD:tt,ICE_CANDIDATE:ot,INCOMING_CALL:Q,MAIN_CAM_CONTROL:_e,MUST_STOP_PRESENTATION_EVENT:se,MUTED:Ze,NEW_DTMF:Oe,NEW_INFO:me,NEW_MESSAGE:$e,NEW_RTC_SESSION:b,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:ne,ONE_MEGABIT_IN_BITS:St,PARTICIPANT:ut,PARTICIPANT_ADDED_TO_LIST_MODERATORS:ue,PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS:V,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:x,PARTICIPANT_MOVE_REQUEST_TO_STREAM:Ne,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Se,PARTICIPATION_ACCEPTING_WORD_REQUEST:Ce,PARTICIPATION_CANCELLING_WORD_REQUEST:ge,PEER_CONNECTION:W,PEER_CONNECTION_CONFIRMED:re,PEER_CONNECTION_CREATE_ANSWER_FAILED:ct,PEER_CONNECTION_CREATE_OFFER_FAILED:at,PEER_CONNECTION_ONTRACK:ae,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:Et,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:_t,PRESENTATION_END:ht,PRESENTATION_ENDED:De,PRESENTATION_FAILED:q,PRESENTATION_START:lt,PRESENTATION_STARTED:dt,PROGRESS:je,REFER:ze,REGISTERED:m,REGISTRATION_FAILED:D,REINVITE:Xe,REPLACES:Qe,SDP:it,SENDING:Je,SHARE_STATE:w,SIP_EVENT:ee,SPECTATOR:Tt,TERMINATED_INCOMING_CALL:K,UNHOLD:nt,UNMUTED:et,UNREGISTERED:Z,UPDATE:st,USE_LICENSE:oe,WEBCAST_STARTED:Ae,WEBCAST_STOPPED:Re},Symbol.toStringTag,{value:"Module"})),Nt=[Q,z,K,j,Ce,ge,Ne,ce,Pe,Ie,fe,Ae,Re,ue,Se],Me=[F,O,N,b,m,Z,D,$e,ee],Ct=[te,ne,se,w,ie,oe,re,ae,U,Ee,_e,de,le,he,Te,L,x,V],pe=[M,F,Je,Xe,Qe,ze,je,Ke,H,W,R,Ze,et,Oe,me,tt,nt,st,it,ot,rt,at,ct,Et,_t,lt,dt,ht,De,q],ve=[...Me,...Nt],ye=[...pe,...Ct],Qt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:ye,SESSION_JSSIP_EVENT_NAMES:pe,SESSION_SYNTHETICS_EVENT_NAMES:Ct,UA_EVENT_NAMES:ve,UA_JSSIP_EVENT_NAMES:Me,UA_SYNTHETICS_EVENT_NAMES:Nt},Symbol.toStringTag,{value:"Module"})),zt=s=>{const e=[];return s&&e.push(`X-Vinteo-Remote: ${s}`),e},jt="content-type",Kt="x-webrtc-enter-room",p="application/vinteo.webrtc.sharedesktop",Zt="application/vinteo.webrtc.roomname",en="application/vinteo.webrtc.channels",tn="application/vinteo.webrtc.mediastate",nn="application/vinteo.webrtc.refusal",Le="application/vinteo.webrtc.maincam",sn="application/vinteo.webrtc.mic",on="application/vinteo.webrtc.uselic",rn="X-WEBRTC-USE-LICENSE",an="X-WEBRTC-PARTICIPANT-NAME",He="X-WEBRTC-INPUT-CHANNELS",We="X-WEBRTC-OUTPUT-CHANNELS",cn="X-WEBRTC-MAINCAM",En="X-WEBRTC-MIC",qe="X-WEBRTC-SYNC",_n="X-WEBRTC-MAINCAM-RESOLUTION",ln="X-WEBRTC-MEDIA-STATE",dn="X-Vinteo-Media-Type",hn="X-Vinteo-MainCam-State",Tn="X-Vinteo-Mic-State",un="application/vinteo.webrtc.partstate",Sn="X-WEBRTC-PARTSTATE",Nn="application/vinteo.webrtc.notify",Cn="X-VINTEO-NOTIFY",f="x-webrtc-share-state",gn=`${f}: LETMESTARTPRESENTATION`,An=`${f}: STOPPRESENTATION`,gt="YOUCANRECEIVECONTENT",At="CONTENTEND",Rt="YOUMUSTSTOPSENDCONTENT",Rn=`${f}: ${Rt}`,In=`${f}: ${gt}`,fn=`${f}: ${At}`,Pn="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",On=`${Pn}: LETMESTARTMAINCAM`,be="sip-connector",y=J(be),mn=()=>{J.enable(be)},Dn=()=>{J.enable(`-${be}`)},Mn=(s,e)=>{s.getVideoTracks().forEach(n=>{"contentHint"in n&&n.contentHint!==e&&(n.contentHint=e)})},v=(s,{directionVideo:e,directionAudio:t,contentHint:n}={})=>{if(!s||e==="recvonly"&&t==="recvonly")return;const i=t==="recvonly"?[]:s.getAudioTracks(),r=e==="recvonly"?[]:s.getVideoTracks(),a=[...i,...r],c=new MediaStream(a);return c.getTracks=()=>[...c.getAudioTracks(),...c.getVideoTracks()],n&&n!=="none"&&Mn(c,n),c};var I=(s=>(s.PAUSE_MAIN_CAM="PAUSEMAINCAM",s.RESUME_MAIN_CAM="RESUMEMAINCAM",s.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",s.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",s.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",s))(I||{}),k=(s=>(s.ADMIN_STOP_MIC="ADMINSTOPMIC",s.ADMIN_START_MIC="ADMINSTARTMIC",s))(k||{}),B=(s=>(s.ADMIN_SYNC_FORCED="1",s.ADMIN_SYNC_NOT_FORCED="0",s))(B||{}),It=(s=>(s.AUDIO="AUDIO",s.VIDEO="VIDEO",s.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",s))(It||{}),ft=(s=>(s.VP8="video/VP8",s.VP9="video/VP9",s.H264="video/H264",s.AV1="video/AV1",s.rtx="video/rtx",s.red="video/red",s.flexfec03="video/flexfec-03",s))(ft||{});function pn(s){return e=>`sip:${e}@${s}`}const vn=(s,e)=>()=>Math.floor(Math.random()*(e-s))+s,ke=s=>s.trim().replaceAll(" ","_"),yn=vn(1e5,99999999),bn=s=>s.some(t=>{const{kind:n}=t;return n==="video"}),wn="Error decline with 603",Un=1006,Ln=s=>typeof s=="object"&&s!==null&&"code"in s&&s.code===Un,Hn=s=>s.message===wn,Wn=(s,e)=>s.find(t=>t.track&&e.getTracks().includes(t.track)),qn=(s,e)=>(s.degradationPreference=e.degradationPreference,s),kn=(s,e)=>{s.encodings===void 0&&(s.encodings=[]);for(let t=s.encodings.length;t<e;t+=1)s.encodings.push({});return s},Pt=s=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==s,Bn=Pt(),Fn=(s,e)=>{if(Bn(s,e))return s},xn=(s,e)=>{const t=s.maxBitrate,n=Fn(e,t);return n!==void 0&&(s.maxBitrate=n),s},Ot=1,Vn=Pt(Ot),Yn=(s,e)=>{const t=s===void 0?void 0:Math.max(s,Ot);if(t!==void 0&&Vn(t,e))return t},Gn=(s,e)=>{const t=s.scaleResolutionDownBy,n=Yn(e,t);return n!==void 0&&(s.scaleResolutionDownBy=n),s},$n=(s,e)=>{var n;const t=((n=e.encodings)==null?void 0:n.length)??0;return kn(s,t),s.encodings.forEach((i,r)=>{const a=((e==null?void 0:e.encodings)??[])[r],c=a==null?void 0:a.maxBitrate,_=a==null?void 0:a.scaleResolutionDownBy;xn(i,c),Gn(i,_)}),s},Jn=(s,e)=>{var t,n,i,r,a,c,_,l;if(((t=s.codecs)==null?void 0:t.length)!==((n=e.codecs)==null?void 0:n.length))return!0;for(let E=0;E<(((i=s.codecs)==null?void 0:i.length)??0);E++)if(JSON.stringify(s.codecs[E])!==JSON.stringify(e.codecs[E]))return!0;if(((r=s.headerExtensions)==null?void 0:r.length)!==((a=e.headerExtensions)==null?void 0:a.length))return!0;for(let E=0;E<(((c=s.headerExtensions)==null?void 0:c.length)??0);E++)if(JSON.stringify(s.headerExtensions[E])!==JSON.stringify(e.headerExtensions[E]))return!0;if(((_=s.encodings)==null?void 0:_.length)!==((l=e.encodings)==null?void 0:l.length))return!0;for(let E=0;E<(s.encodings.length??0);E++)if(JSON.stringify(s.encodings[E])!==JSON.stringify(e.encodings[E]))return!0;return s.rtcp.cname!==e.rtcp.cname||s.rtcp.reducedSize!==e.rtcp.reducedSize||s.degradationPreference!==e.degradationPreference},mt=async(s,e)=>{const t=s.getParameters(),n=JSON.parse(JSON.stringify(t));$n(t,e),qn(t,e);const i=Jn(n,t);return i&&await s.setParameters(t),{parameters:t,isChanged:i}},Dt=async(s,e,t)=>{const{isChanged:n,parameters:i}=await mt(s,{encodings:[{scaleResolutionDownBy:e.scaleResolutionDownBy,maxBitrate:e.maxBitrate}]});return n&&t&&t(i),{isChanged:n,parameters:i}},Xn=async(s,e,t)=>{const n=Wn(s,e);if(n)return Dt(n,{maxBitrate:t})},Qn=486,zn=487,$="local",Be="remote",jn=3,Kn=1,Zn=(s=new Error)=>{const{originator:e,cause:t}=s;return C.isCanceledError(s)?!0:typeof t=="string"?t===Fe||t===X||e===$&&(t===Ye||t===Ve):!1},A="SipConnector",es="channels",ts="WebcastStarted",ns="WebcastStopped",ss="accountChanged",is="accountDeleted",os="addedToListModerators",rs="removedFromListModerators",as="ParticipationRequestAccepted",cs="ParticipationRequestRejected",Es="ParticipantMovedToWebcast",_s="ConferenceParticipantTokenIssued";class ls{constructor({JsSIP:e}){o(this,"_isRegisterConfig",!1);o(this,"_connectionConfiguration",{});o(this,"_remoteStreams",{});o(this,"JsSIP");o(this,"_sessionEvents");o(this,"_uaEvents");o(this,"_cancelableConnect");o(this,"_cancelableConnectWithRepeatedCalls");o(this,"_cancelableSendPresentationWithRepeatedCalls");o(this,"_cancelableInitUa");o(this,"_cancelableDisconnect");o(this,"_cancelableSet");o(this,"_cancelableCall");o(this,"_cancelableAnswer");o(this,"_cancelableSendDTMF");o(this,"getSipServerUrl",e=>e);o(this,"promisePendingStartPresentation");o(this,"promisePendingStopPresentation");o(this,"ua");o(this,"session");o(this,"incomingSession");o(this,"_streamPresentationCurrent");o(this,"socket");o(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));o(this,"initUa",async e=>this._cancelableInitUa.request(e));o(this,"set",async e=>this._cancelableSet.request(e));o(this,"call",async e=>this._cancelableCall.request(e));o(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));o(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));o(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));o(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));o(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(F,void 0);try{await this.unregister()}catch(e){y("tryRegister",e)}return this.register()});o(this,"declineToIncomingCall",async({statusCode:e=zn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const i=this.incomingSession,r=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(z,r),t(i.terminate({status_code:e}))}));o(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:Qn}));o(this,"removeIncomingSession",()=>{delete this.incomingSession});o(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=jn}={})=>{const n=async()=>this._cancelableConnect.request(e),i=r=>{var l;const c=!!((l=this.ua)!=null&&l.isConnected())&&this.hasEqualConnectionConfiguration(e),_=!!r&&!Ln(r);return c||_};return this._cancelableConnectWithRepeatedCalls=Ue.repeatedCallsAsync({targetFunction:n,isComplete:i,callLimit:t,isRejectAsValid:!0,isCheckBeforeCall:!1,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(r=>{if(r instanceof this.JsSIP.UA)return r;throw r})});o(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===Be){this.incomingSession=t;const n=this.remoteCallerData;t.on(R,i=>{this.removeIncomingSession(),i.originator===$?this._uaEvents.trigger(K,n):this._uaEvents.trigger(j,n)}),this._uaEvents.trigger(Q,n)}});o(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));o(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:l,userAgent:E,displayName:h="",register:d=!1,extraHeaders:T=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!i)throw new Error("sipWebSocketServerURL is required");if(d&&!e)throw new Error("user is required for authorized connection");if(d&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:h,register:d,user:e,password:t};const{configuration:u,helpers:S}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:i,password:t,displayName:h,register:d,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:l,userAgent:E});return this.getSipServerUrl=S.getSipServerUrl,this.socket=S.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!d,this.ua=this._createUa({...u,remoteAddress:r,extraHeaders:T}),this._uaEvents.eachTriggers((g,Y)=>{const P=Me.find(G=>G===Y);P&&this.ua&&this.ua.on(P,g)}),this.ua});o(this,"_createUa",({remoteAddress:e,extraHeaders:t=[],...n})=>{const i=new this.JsSIP.UA(n),a=[...e?zt(e):[],...t];return a.length>0&&i.registrator().setExtraHeaders(a),i});o(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const i=()=>{c(),e(n)},r=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(m,i),this.on(D,r)):this.on(O,i),this.on(N,r)},c=()=>{this.off(m,i),this.off(D,r),this.off(O,i),this.off(N,r)};a(),this.on(b,this.handleNewRTCSession),n.start()}));o(this,"_set",async({displayName:e,password:t})=>new Promise((n,i)=>{const{ua:r}=this;if(!r){i(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=r.set("display_name",ke(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=r.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(l=>{i(l)}):_?n(_):i(new Error("nothing changed"))}));o(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());o(this,"_disconnect",async()=>{this.off(b,this.handleNewRTCSession);const e=new Promise(t=>{this.once(N,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(N,void 0)):this._uaEvents.trigger(N,void 0),e});o(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:i,iceServers:r,directionVideo:a,directionAudio:c,contentHint:_,offerToReceiveAudio:l=!0,offerToReceiveVideo:E=!0,sendEncodings:h,onAddedTransceiver:d})=>new Promise((T,u)=>{const{ua:S}=this;if(!S){u(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:i}).then(T).catch(g=>{u(g)}),this.session=S.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:v(t,{directionVideo:a,directionAudio:c,contentHint:_}),eventHandlers:this._sessionEvents.triggers,directionVideo:a,directionAudio:c,pcConfig:{iceServers:r},rtcOfferConstraints:{offerToReceiveAudio:l,offerToReceiveVideo:E},sendEncodings:h,onAddedTransceiver:d})}));o(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:i,directionVideo:r,directionAudio:a,offerToReceiveAudio:c,offerToReceiveVideo:_,contentHint:l,sendEncodings:E,onAddedTransceiver:h})=>new Promise((d,T)=>{if(!this.isAvailableIncomingCall){T(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:u}=this;if(!u){T(new Error("No session established"));return}this._sessionEvents.eachTriggers((g,Y)=>{const P=pe.find(G=>G===Y);P&&u.on(P,g)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=u.remote_identity.uri.user,this._handleCall({ontrack:t}).then(d).catch(g=>{T(g)});const S=v(e,{directionVideo:r,directionAudio:a,contentHint:l});u.answer({extraHeaders:n,directionVideo:r,directionAudio:a,mediaStream:S,pcConfig:{iceServers:i},rtcOfferConstraints:{offerToReceiveAudio:c,offerToReceiveVideo:_},sendEncodings:E,onAddedTransceiver:h})}));o(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const i=()=>{this.onSession(W,E),this.onSession(H,h)},r=()=>{this.offSession(W,E),this.offSession(H,h)},a=()=>{this.onSession(R,_),this.onSession(M,_)},c=()=>{this.offSession(R,_),this.offSession(M,_)},_=d=>{r(),c(),n(d)};let l;const E=({peerconnection:d})=>{l=d,l.ontrack=T=>{this._sessionEvents.trigger(ae,l),e&&e(T)}},h=()=>{l&&this._sessionEvents.trigger(re,l),r(),c(),t(l)};i(),a()}));o(this,"_restoreSession",()=>{this._cancelRequestsAndResetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});o(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:i}=this;if(!i){n(new Error("No session established"));return}this.onceSession(Oe,({originator:r})=>{r===$&&t()}),i.sendDTMF(e,{duration:120,interToneGap:600})}));o(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent)try{await this.stopPresentation()}catch(t){y("error stop presentation: ",t)}if(this._restoreSession(),!e.isEnded())return e.terminateAsync()}});o(this,"_handleShareState",e=>{switch(e){case gt:{this._sessionEvents.trigger(te,void 0);break}case At:{this._sessionEvents.trigger(ne,void 0);break}case Rt:{this._sessionEvents.trigger(se,void 0);break}}});o(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(He),n=e.getHeader(We);if(t&&n){const i={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(U,i)}});o(this,"_handleNotify",e=>{switch(e.cmd){case es:{const t=e;this._triggerChannelsNotify(t);break}case ts:{const t=e;this._triggerWebcastStartedNotify(t);break}case ns:{const t=e;this._triggerWebcastStoppedNotify(t);break}case os:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case rs:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case as:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case cs:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Es:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case ss:{this._triggerAccountChangedNotify();break}case is:{this._triggerAccountDeletedNotify();break}case _s:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:y("unknown cmd",e.cmd)}});o(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Se,t)});o(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(ue,t)});o(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Ae,n)});o(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Re,n)});o(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ie,void 0)});o(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(fe,void 0)});o(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const i={conference:e,participant:t,jwt:n};this._uaEvents.trigger(Pe,i)});o(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,i={inputChannels:t,outputChannels:n};this._uaEvents.trigger(ce,i)});o(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Ce,t)});o(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(ge,t)});o(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Ne,t)});o(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Kt),n=e.getHeader(an);this._sessionEvents.trigger(ie,{room:t,participantName:n})});o(this,"_triggerShareState",e=>{const t=e.getHeader(f);this._sessionEvents.trigger(w,t)});o(this,"_maybeTriggerParticipantMoveRequest",e=>{const t=e.getHeader(Sn);t===Tt&&this._sessionEvents.trigger(x,void 0),t===ut&&this._sessionEvents.trigger(V,void 0)});o(this,"_triggerMainCamControl",e=>{const t=e.getHeader(cn),n=e.getHeader(qe),i=n===B.ADMIN_SYNC_FORCED;if(t===I.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(de,{isSyncForced:i});return}if(t===I.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(le,{isSyncForced:i});return}(t===I.RESUME_MAIN_CAM||t===I.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(L,{isSyncForced:i});const r=e.getHeader(_n);this._sessionEvents.trigger(_e,{mainCam:t,resolutionMainCam:r})});o(this,"_triggerMicControl",e=>{const t=e.getHeader(En),i=e.getHeader(qe)===B.ADMIN_SYNC_FORCED;t===k.ADMIN_START_MIC?this._sessionEvents.trigger(Te,{isSyncForced:i}):t===k.ADMIN_STOP_MIC&&this._sessionEvents.trigger(he,{isSyncForced:i})});o(this,"_triggerUseLicense",e=>{const t=e.getHeader(rn);this._sessionEvents.trigger(oe,t)});o(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,i=n.getHeader(jt);if(i)switch(i){case Zt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case Nn:{this._maybeHandleNotify(n);break}case p:{this._triggerShareState(n);break}case Le:{this._triggerMainCamControl(n);break}case sn:{this._triggerMicControl(n);break}case on:{this._triggerUseLicense(n);break}case un:{this._maybeTriggerParticipantMoveRequest(n);break}}});o(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});o(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Cn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});o(this,"_handleEnded",e=>{const{originator:t}=e;t===Be&&this._sessionEvents.trigger(Ee,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new we(ye),this._uaEvents=new we(ve),this._cancelableConnect=new C.CancelableRequest(this._connect,{moduleName:A,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new C.CancelableRequest(this._initUa,{moduleName:A}),this._cancelableDisconnect=new C.CancelableRequest(this._disconnect,{moduleName:A}),this._cancelableSet=new C.CancelableRequest(this._set,{moduleName:A}),this._cancelableCall=new C.CancelableRequest(this._call,{moduleName:A}),this._cancelableAnswer=new C.CancelableRequest(this._answer,{moduleName:A}),this._cancelableSendDTMF=new C.CancelableRequest(this._sendDTMF,{moduleName:A}),this.onSession(w,this._handleShareState),this.onSession(me,this._handleNewInfo),this.on(ee,this._handleSipEvent),this.onSession(R,this._handleEnded),this.onSession(M,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(m,e),this.ua.on(D,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(Z,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((i,r)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{i()},failed:r}})}catch(a){r(a)}})}async ping(e,t){var i;if(!((i=this.ua)!=null&&i.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,extraHeaders:a}){return new Promise((c,_)=>{const{configuration:l}=this.createUaConfiguration({sipWebSocketServerURL:i,displayName:t,userAgent:e,sipServerUrl:n}),E=this._createUa({...l,remoteAddress:r,extraHeaders:a}),h=()=>{const T=new Error("Telephony is not available");_(T)};E.once(N,h);const d=()=>{E.removeAllListeners(),E.once(N,c),E.stop()};E.once(O,d),E.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");const{contentHint:n}=t??{},i=v(e,{contentHint:n});return this.session.replaceMediaStream(i,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[On];return this.session.sendInfo(Le,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(Hn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentationWithDuplicatedCalls({session:e,stream:t,presentationOptions:n,options:i={callLimit:Kn}}){const r=async()=>this._sendPresentation(e,t,n),a=()=>!!this._streamPresentationCurrent;return this._cancelableSendPresentationWithRepeatedCalls=Ue.repeatedCallsAsync({targetFunction:r,isComplete:a,isRejectAsValid:!0,...i}),this._cancelableSendPresentationWithRepeatedCalls.then(c=>c)}hasEqualConnectionConfiguration(e){var i;const{configuration:t}=this.createUaConfiguration(e),n=(i=this.ua)==null?void 0:i.configuration;return(n==null?void 0:n.password)===t.password&&(n==null?void 0:n.register)===t.register&&(n==null?void 0:n.uri.toString())===t.uri&&(n==null?void 0:n.display_name)===t.display_name&&(n==null?void 0:n.user_agent)===t.user_agent&&(n==null?void 0:n.sockets)===t.sockets&&(n==null?void 0:n.session_timers)===t.session_timers&&(n==null?void 0:n.register_expires)===t.register_expires&&(n==null?void 0:n.connection_recovery_min_interval)===t.connection_recovery_min_interval&&(n==null?void 0:n.connection_recovery_max_interval)===t.connection_recovery_max_interval}createUaConfiguration({user:e,password:t,sipWebSocketServerURL:n,displayName:i="",sipServerUrl:r,register:a=!1,sessionTimers:c=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:l=2,connectionRecoveryMaxInterval:E=6,userAgent:h}){if(a&&!t)throw new Error("password is required for authorized connection");const d=a&&e?e.trim():`${yn()}`,T=pn(r),u=T(d),S=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:u,display_name:ke(i),user_agent:h,sdp_semantics:"unified-plan",sockets:[S],session_timers:c,register_expires:_,connection_recovery_min_interval:l,connection_recovery_max_interval:E},helpers:{socket:S,getSipServerUrl:T}}}async _sendPresentation(e,t,{maxBitrate:n=St,isNeedReinvite:i=!0,isP2P:r=!1,contentHint:a="detail",sendEncodings:c,onAddedTransceiver:_}){const l=v(t,{contentHint:a});this._streamPresentationCurrent=l;const E=r?[In]:[gn],h=e.sendInfo(p,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(l,i,{sendEncodings:c,onAddedTransceiver:_})).then(async()=>{const{connection:d}=this;if(!d||n===void 0)return;const T=d.getSenders();await Xn(T,t,n)}).then(()=>t).catch(d=>{throw this._removeStreamPresentationCurrent(),this._sessionEvents.trigger(q,d),d});return this.promisePendingStartPresentation=h,h.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c}={},_){const l=this.establishedSession;if(!l)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(l),this._sendPresentationWithDuplicatedCalls({session:l,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c},options:_})}async sendMustStopPresentation(e){await e.sendInfo(p,void 0,{extraHeaders:[Rn]})}async stopPresentation({isP2P:e=!1}={}){this._cancelSendPresentationWithRepeatedCalls();const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const i=e?[fn]:[An],r=this.establishedSession;return r&&t&&(n=n.then(async()=>r.sendInfo(p,void 0,{extraHeaders:i})).then(async()=>r.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(q,a),a})),!r&&t&&this._sessionEvents.trigger(De,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t,maxBitrate:n,contentHint:i,sendEncodings:r,onAddedTransceiver:a}={}){const c=this.establishedSession;if(!c)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(c,e,{isP2P:t,maxBitrate:n,contentHint:i,isNeedReinvite:!1,sendEncodings:r,onAddedTransceiver:a})}_removeStreamPresentationCurrent(){delete this._streamPresentationCurrent}_resetPresentation(){this._removeStreamPresentationCurrent(),this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}_cancelRequestsAndResetPresentation(){this._cancelSendPresentationWithRepeatedCalls(),this._resetPresentation()}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return bn(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,i,r,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(i=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:i.uri.host,incomingNumber:(a=(r=this.incomingSession)==null?void 0:r.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){var e;return(e=this.session)!=null&&e.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,i=this._remoteStreams[n]||new MediaStream;return t&&i.addTrack(t),i.addTrack(e),this._remoteStreams[n]=i,i}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,i)=>{if(n.kind==="audio")return;const r=n,a=e[i-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(r,c);t.push(_)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectWithRepeatedCalls()}_cancelConnectWithRepeatedCalls(){var e;(e=this._cancelableConnectWithRepeatedCalls)==null||e.cancel()}_cancelSendPresentationWithRepeatedCalls(){var e;(e=this._cancelableSendPresentationWithRepeatedCalls)==null||e.cancel()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(U)}async waitSyncMediaState(){return this.waitSession(L)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${He}: ${e}`,i=`${We}: ${t}`,r=[n,i];return this.session.sendInfo(en,void 0,{extraHeaders:r})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const i=`${ln}: currentstate`,r=`${hn}: ${Number(e)}`,a=`${Tn}: ${Number(t)}`,c=[i,r,a];return this.session.sendInfo(tn,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${dn}: ${e==="mic"?0:1}`];return this.session.sendInfo(nn,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Ge;exports.EEventsMainCAM=I;exports.EEventsMic=k;exports.EEventsSyncMediaState=B;exports.EMimeTypesVideoCodecs=ft;exports.EUseLicense=It;exports.NOT_FOUND=xe;exports.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS=V;exports.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS=x;exports.REJECTED=X;exports.SESSION_EVENT_NAMES=ye;exports.SipConnector=ls;exports.UA_EVENT_NAMES=ve;exports.causes=Jt;exports.constants=Xt;exports.disableDebug=Dn;exports.enableDebug=mn;exports.eventNames=Qt;exports.hasCanceledCallError=Zn;exports.logger=y;exports.setEncodingsToSender=Dt;exports.setParametersToSender=mt;