sip-connector 8.2.0 → 8.2.1

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.
@@ -5,7 +5,7 @@ import { CancelableRequest as N, isCanceledError as It } from "@krivega/cancelab
5
5
  import Pe from "events-constructor";
6
6
  import { repeatedCallsAsync as Oe } from "repeated-calls";
7
7
  import B from "debug";
8
- const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code", pt = "Internal Error", Pt = "Busy", Le = "Rejected", Ot = "Redirected", Dt = "Unavailable", Mt = "Not Found", vt = "Address Incomplete", yt = "Incompatible SDP", bt = "Missing SDP", wt = "Authentication Error", He = "Terminated", Ut = "WebRTC Error", We = "Canceled", Lt = "No Answer", Ht = "Expires", Wt = "No ACK", kt = "Dialog Error", qt = "User Denied Media Access", Ft = "Bad Media Description", Bt = "RTP Timeout", ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8
+ const mt = "Connection Error", Ue = "Request Timeout", pt = "SIP Failure Code", ft = "Internal Error", Pt = "Busy", Le = "Rejected", Ot = "Redirected", Dt = "Unavailable", Mt = "Not Found", vt = "Address Incomplete", yt = "Incompatible SDP", bt = "Missing SDP", wt = "Authentication Error", He = "Terminated", Ut = "WebRTC Error", We = "Canceled", Lt = "No Answer", Ht = "Expires", Wt = "No ACK", kt = "Dialog Error", qt = "User Denied Media Access", Ft = "Bad Media Description", Bt = "RTP Timeout", ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9
9
  __proto__: null,
10
10
  ADDRESS_INCOMPLETE: vt,
11
11
  AUTHENTICATION_ERROR: wt,
@@ -17,7 +17,7 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
17
17
  DIALOG_ERROR: kt,
18
18
  EXPIRES: Ht,
19
19
  INCOMPATIBLE_SDP: yt,
20
- INTERNAL_ERROR: pt,
20
+ INTERNAL_ERROR: ft,
21
21
  MISSING_SDP: bt,
22
22
  NOT_FOUND: Mt,
23
23
  NO_ACK: Wt,
@@ -26,14 +26,14 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
26
26
  REJECTED: Le,
27
27
  REQUEST_TIMEOUT: Ue,
28
28
  RTP_TIMEOUT: Bt,
29
- SIP_FAILURE_CODE: ft,
29
+ SIP_FAILURE_CODE: pt,
30
30
  UNAVAILABLE: Dt,
31
31
  USER_DENIED_MEDIA_ACCESS: qt,
32
32
  WEBRTC_ERROR: Ut
33
- }, Symbol.toStringTag, { value: "Module" })), V = "incomingCall", Y = "declinedIncomingCall", x = "failedIncomingCall", G = "terminatedIncomingCall", L = "connecting", m = "connected", S = "disconnected", D = "newRTCSession", f = "registered", $ = "unregistered", p = "registrationFailed", ke = "newMessage", X = "sipEvent", J = "availableSecondRemoteStream", z = "notAvailableSecondRemoteStream", Q = "mustStopPresentation", M = "shareState", j = "enterRoom", K = "useLicense", Z = "peerconnection:confirmed", ee = "peerconnection:ontrack", v = "channels", te = "channels:notify", ne = "ended:fromserver", se = "main-cam-control", ie = "admin-stop-main-cam", re = "admin-start-main-cam", oe = "admin-stop-mic", ae = "admin-start-mic", y = "admin-force-sync-media-state", ce = "participant:added-to-list-moderators", _e = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", he = "participant:move-request-to-spectators", le = "participation:accepting-word-request", de = "participation:cancelling-word-request", Te = "webcast:started", Se = "webcast:stopped", ue = "account:changed", Ce = "account:deleted", Ne = "conference:participant-token-issued", P = "ended", qe = "sending", Fe = "reinvite", Be = "replaces", Ve = "refer", Ye = "progress", xe = "accepted", b = "confirmed", w = "peerconnection", A = "failed", Ge = "muted", $e = "unmuted", ge = "newDTMF", Ae = "newInfo", Xe = "hold", Je = "unhold", ze = "update", Qe = "sdp", je = "icecandidate", Ke = "getusermediafailed", Ze = "peerconnection:createofferfailed", et = "peerconnection:createanswerfailed", tt = "peerconnection:setlocaldescriptionfailed", nt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", it = "presentation:started", rt = "presentation:end", Re = "presentation:ended", U = "presentation:failed", ot = "SPECTATOR", ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
33
+ }, Symbol.toStringTag, { value: "Module" })), V = "incomingCall", Y = "declinedIncomingCall", x = "failedIncomingCall", G = "terminatedIncomingCall", L = "connecting", m = "connected", u = "disconnected", D = "newRTCSession", p = "registered", $ = "unregistered", f = "registrationFailed", ke = "newMessage", X = "sipEvent", J = "availableSecondRemoteStream", z = "notAvailableSecondRemoteStream", Q = "mustStopPresentation", M = "shareState", j = "enterRoom", K = "useLicense", Z = "peerconnection:confirmed", ee = "peerconnection:ontrack", v = "channels", te = "channels:notify", ne = "ended:fromserver", se = "main-cam-control", ie = "admin-stop-main-cam", re = "admin-start-main-cam", oe = "admin-stop-mic", ae = "admin-start-mic", y = "admin-force-sync-media-state", ce = "participant:added-to-list-moderators", _e = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", he = "participant:move-request-to-spectators", le = "participation:accepting-word-request", de = "participation:cancelling-word-request", Te = "webcast:started", ue = "webcast:stopped", Se = "account:changed", Ce = "account:deleted", Ne = "conference:participant-token-issued", P = "ended", qe = "sending", Fe = "reinvite", Be = "replaces", Ve = "refer", Ye = "progress", xe = "accepted", b = "confirmed", w = "peerconnection", A = "failed", Ge = "muted", $e = "unmuted", ge = "newDTMF", Ae = "newInfo", Xe = "hold", Je = "unhold", ze = "update", Qe = "sdp", je = "icecandidate", Ke = "getusermediafailed", Ze = "peerconnection:createofferfailed", et = "peerconnection:createanswerfailed", tt = "peerconnection:setlocaldescriptionfailed", nt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", it = "presentation:started", rt = "presentation:end", Re = "presentation:ended", U = "presentation:failed", ot = "SPECTATOR", ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
34
34
  __proto__: null,
35
35
  ACCEPTED: xe,
36
- ACCOUNT_CHANGED: ue,
36
+ ACCOUNT_CHANGED: Se,
37
37
  ACCOUNT_DELETED: Ce,
38
38
  ADMIN_FORCE_SYNC_MEDIA_STATE: y,
39
39
  ADMIN_START_MAIN_CAM: re,
@@ -48,7 +48,7 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
48
48
  CONNECTED: m,
49
49
  CONNECTING: L,
50
50
  DECLINED_INCOMING_CALL: Y,
51
- DISCONNECTED: S,
51
+ DISCONNECTED: u,
52
52
  ENDED: P,
53
53
  ENDED_FROM_SERVER: ne,
54
54
  ENTER_ROOM: j,
@@ -86,8 +86,8 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
86
86
  PRESENTATION_STARTED: it,
87
87
  PROGRESS: Ye,
88
88
  REFER: Ve,
89
- REGISTERED: f,
90
- REGISTRATION_FAILED: p,
89
+ REGISTERED: p,
90
+ REGISTRATION_FAILED: f,
91
91
  REINVITE: Fe,
92
92
  REPLACES: Be,
93
93
  SDP: Qe,
@@ -102,7 +102,7 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
102
102
  UPDATE: ze,
103
103
  USE_LICENSE: K,
104
104
  WEBCAST_STARTED: Te,
105
- WEBCAST_STOPPED: Se
105
+ WEBCAST_STOPPED: ue
106
106
  }, Symbol.toStringTag, { value: "Module" })), at = [
107
107
  V,
108
108
  Y,
@@ -113,20 +113,20 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
113
113
  Ee,
114
114
  te,
115
115
  Ne,
116
- ue,
116
+ Se,
117
117
  Ce,
118
118
  Te,
119
- Se,
119
+ ue,
120
120
  ce,
121
121
  _e
122
122
  ], Ie = [
123
123
  L,
124
124
  m,
125
- S,
125
+ u,
126
126
  D,
127
- f,
128
- $,
129
127
  p,
128
+ $,
129
+ f,
130
130
  ke,
131
131
  X
132
132
  ], ct = [
@@ -192,10 +192,10 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
192
192
  }, Symbol.toStringTag, { value: "Module" })), Vt = (r) => {
193
193
  const e = [];
194
194
  return r && e.push(`X-Vinteo-Remote: ${r}`), e;
195
- }, Yt = "content-type", xt = "x-webrtc-enter-room", O = "application/vinteo.webrtc.sharedesktop", Gt = "application/vinteo.webrtc.roomname", $t = "application/vinteo.webrtc.channels", Xt = "application/vinteo.webrtc.mediastate", Jt = "application/vinteo.webrtc.refusal", De = "application/vinteo.webrtc.maincam", zt = "application/vinteo.webrtc.mic", Qt = "application/vinteo.webrtc.uselic", jt = "X-WEBRTC-USE-LICENSE", Kt = "X-WEBRTC-PARTICIPANT-NAME", Me = "X-WEBRTC-INPUT-CHANNELS", ve = "X-WEBRTC-OUTPUT-CHANNELS", Zt = "X-WEBRTC-MAINCAM", en = "X-WEBRTC-MIC", ye = "X-WEBRTC-SYNC", tn = "X-WEBRTC-MAINCAM-RESOLUTION", nn = "X-WEBRTC-MEDIA-STATE", sn = "X-Vinteo-Media-Type", rn = "X-Vinteo-MainCam-State", on = "X-Vinteo-Mic-State", an = "application/vinteo.webrtc.partstate", cn = "X-WEBRTC-PARTSTATE", _n = "application/vinteo.webrtc.notify", En = "X-VINTEO-NOTIFY", R = "x-webrtc-share-state", hn = `${R}: LETMESTARTPRESENTATION`, ln = `${R}: STOPPRESENTATION`, ht = "YOUCANRECEIVECONTENT", lt = "CONTENTEND", dt = "YOUMUSTSTOPSENDCONTENT", dn = `${R}: ${dt}`, Tn = `${R}: ${ht}`, Sn = `${R}: ${lt}`, un = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Cn = `${un}: LETMESTARTMAINCAM`, fe = "sip-connector", H = B(fe), is = () => {
196
- B.enable(fe);
195
+ }, Yt = "content-type", xt = "x-webrtc-enter-room", O = "application/vinteo.webrtc.sharedesktop", Gt = "application/vinteo.webrtc.roomname", $t = "application/vinteo.webrtc.channels", Xt = "application/vinteo.webrtc.mediastate", Jt = "application/vinteo.webrtc.refusal", De = "application/vinteo.webrtc.maincam", zt = "application/vinteo.webrtc.mic", Qt = "application/vinteo.webrtc.uselic", jt = "X-WEBRTC-USE-LICENSE", Kt = "X-WEBRTC-PARTICIPANT-NAME", Me = "X-WEBRTC-INPUT-CHANNELS", ve = "X-WEBRTC-OUTPUT-CHANNELS", Zt = "X-WEBRTC-MAINCAM", en = "X-WEBRTC-MIC", ye = "X-WEBRTC-SYNC", tn = "X-WEBRTC-MAINCAM-RESOLUTION", nn = "X-WEBRTC-MEDIA-STATE", sn = "X-Vinteo-Media-Type", rn = "X-Vinteo-MainCam-State", on = "X-Vinteo-Mic-State", an = "application/vinteo.webrtc.partstate", cn = "X-WEBRTC-PARTSTATE", _n = "application/vinteo.webrtc.notify", En = "X-VINTEO-NOTIFY", R = "x-webrtc-share-state", hn = `${R}: LETMESTARTPRESENTATION`, ln = `${R}: STOPPRESENTATION`, ht = "YOUCANRECEIVECONTENT", lt = "CONTENTEND", dt = "YOUMUSTSTOPSENDCONTENT", dn = `${R}: ${dt}`, Tn = `${R}: ${ht}`, un = `${R}: ${lt}`, Sn = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Cn = `${Sn}: LETMESTARTMAINCAM`, pe = "sip-connector", H = B(pe), is = () => {
196
+ B.enable(pe);
197
197
  }, rs = () => {
198
- B.enable(`-${fe}`);
198
+ B.enable(`-${pe}`);
199
199
  };
200
200
  var I = /* @__PURE__ */ ((r) => (r.PAUSE_MAIN_CAM = "PAUSEMAINCAM", r.RESUME_MAIN_CAM = "RESUMEMAINCAM", r.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", r.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", r.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", r))(I || {}), k = /* @__PURE__ */ ((r) => (r.ADMIN_STOP_MIC = "ADMINSTOPMIC", r.ADMIN_START_MIC = "ADMINSTARTMIC", r))(k || {}), q = /* @__PURE__ */ ((r) => (r.ADMIN_SYNC_FORCED = "1", r.ADMIN_SYNC_NOT_FORCED = "0", r))(q || {}), Nn = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(Nn || {});
201
201
  function gn(r) {
@@ -212,7 +212,7 @@ const An = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) =>
212
212
  }, In = (r) => r.some((t) => {
213
213
  const { kind: n } = t;
214
214
  return n === "video";
215
- }), mn = "Error decline with 603", fn = 1006, pn = (r) => typeof r == "object" && r !== null && "code" in r && r.code === fn, Pn = (r) => r.message === mn, On = (r, e) => r.find((t) => t.track && e.getTracks().includes(t.track)), Tt = 1, St = (r) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== r, Dn = St(
215
+ }), mn = "Error decline with 603", pn = 1006, fn = (r) => typeof r == "object" && r !== null && "code" in r && r.code === pn, Pn = (r) => r.message === mn, On = (r, e) => r.find((t) => t.track && e.getTracks().includes(t.track)), Tt = 1, ut = (r) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== r, Dn = ut(
216
216
  Tt
217
217
  ), Mn = (r, e) => {
218
218
  const t = r === void 0 ? void 0 : Math.max(r, Tt);
@@ -221,7 +221,7 @@ const An = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) =>
221
221
  e
222
222
  ))
223
223
  return t;
224
- }, vn = St(), yn = (r, e) => {
224
+ }, vn = ut(), yn = (r, e) => {
225
225
  if (vn(r, e))
226
226
  return r;
227
227
  }, bn = async (r, e, t) => {
@@ -303,7 +303,7 @@ class as {
303
303
  let n = !0;
304
304
  const s = async () => (n = !1, this._cancelableConnect.request(e)), o = (a) => {
305
305
  var h;
306
- const c = !!((h = this.ua) != null && h.isConnected()), _ = !n && c && this.hasEqualConnectionConfiguration(e), E = !!a && !pn(a);
306
+ const c = !!((h = this.ua) != null && h.isConnected()), _ = !n && c && this.hasEqualConnectionConfiguration(e), E = !!a && !fn(a);
307
307
  return _ || E;
308
308
  };
309
309
  return this._cancelableConnectWithRepeatedCalls = Oe({
@@ -360,7 +360,7 @@ class as {
360
360
  user: e,
361
361
  password: t
362
362
  };
363
- const { configuration: u, helpers: C } = this.createUaConfiguration({
363
+ const { configuration: S, helpers: C } = this.createUaConfiguration({
364
364
  user: e,
365
365
  sipServerUrl: n,
366
366
  sipWebSocketServerURL: s,
@@ -373,12 +373,12 @@ class as {
373
373
  connectionRecoveryMaxInterval: E,
374
374
  userAgent: h
375
375
  });
376
- this.getSipServerUrl = C.getSipServerUrl, this.socket = C.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!l, this.ua = this._createUa(u), this._uaEvents.eachTriggers((Ct, Nt) => {
377
- const pe = Ie.find((gt) => gt === Nt);
378
- pe && this.ua && this.ua.on(pe, Ct);
376
+ this.getSipServerUrl = C.getSipServerUrl, this.socket = C.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!l, this.ua = this._createUa(S), this._uaEvents.eachTriggers((Ct, Nt) => {
377
+ const fe = Ie.find((gt) => gt === Nt);
378
+ fe && this.ua && this.ua.on(fe, Ct);
379
379
  });
380
- const ut = [...Vt(o), ...T];
381
- return this.ua.registrator().setExtraHeaders(ut), this.ua;
380
+ const St = [...Vt(o), ...T];
381
+ return this.ua.registrator().setExtraHeaders(St), this.ua;
382
382
  });
383
383
  i(this, "_createUa", (e) => new this.JsSIP.UA(e));
384
384
  i(this, "_start", async () => new Promise((e, t) => {
@@ -392,9 +392,9 @@ class as {
392
392
  }, o = (_) => {
393
393
  c(), t(_);
394
394
  }, a = () => {
395
- this.isRegisterConfig ? (this.on(f, s), this.on(p, o)) : this.on(m, s), this.on(S, o);
395
+ this.isRegisterConfig ? (this.on(p, s), this.on(f, o)) : this.on(m, s), this.on(u, o);
396
396
  }, c = () => {
397
- this.off(f, s), this.off(p, o), this.off(m, s), this.off(S, o);
397
+ this.off(p, s), this.off(f, o), this.off(m, s), this.off(u, o);
398
398
  };
399
399
  a(), this.on(D, this.handleNewRTCSession), n.start();
400
400
  }));
@@ -417,11 +417,11 @@ class as {
417
417
  i(this, "_disconnect", async () => {
418
418
  this.off(D, this.handleNewRTCSession);
419
419
  const e = new Promise((t) => {
420
- this.once(S, () => {
420
+ this.once(u, () => {
421
421
  delete this.ua, t();
422
422
  });
423
423
  });
424
- return this.ua ? (await this._hangUpWithoutCancelRequests(), this.ua ? this.ua.stop() : this._uaEvents.trigger(S, void 0)) : this._uaEvents.trigger(S, void 0), e;
424
+ return this.ua ? (await this._hangUpWithoutCancelRequests(), this.ua ? this.ua.stop() : this._uaEvents.trigger(u, void 0)) : this._uaEvents.trigger(u, void 0), e;
425
425
  });
426
426
  i(this, "_call", async ({
427
427
  number: e,
@@ -440,8 +440,8 @@ class as {
440
440
  l(new Error("this.ua is not initialized"));
441
441
  return;
442
442
  }
443
- this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: s }).then(d).catch((u) => {
444
- l(u);
443
+ this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: s }).then(d).catch((S) => {
444
+ l(S);
445
445
  }), this.session = T.call(this.getSipServerUrl(e), {
446
446
  extraHeaders: n,
447
447
  mediaStream: W(t, {
@@ -481,8 +481,8 @@ class as {
481
481
  return;
482
482
  }
483
483
  this._sessionEvents.eachTriggers((l, T) => {
484
- const u = me.find((C) => C === T);
485
- u && h.on(u, l);
484
+ const S = me.find((C) => C === T);
485
+ S && h.on(S, l);
486
486
  }), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(_).catch((l) => {
487
487
  E(l);
488
488
  });
@@ -666,10 +666,10 @@ class as {
666
666
  conference: e,
667
667
  type: t
668
668
  };
669
- this._uaEvents.trigger(Se, n);
669
+ this._uaEvents.trigger(ue, n);
670
670
  });
671
671
  i(this, "_triggerAccountChangedNotify", () => {
672
- this._uaEvents.trigger(ue, void 0);
672
+ this._uaEvents.trigger(Se, void 0);
673
673
  });
674
674
  i(this, "_triggerAccountDeletedNotify", () => {
675
675
  this._uaEvents.trigger(Ce, void 0);
@@ -828,7 +828,7 @@ class as {
828
828
  }
829
829
  async register() {
830
830
  return new Promise((e, t) => {
831
- this.isRegisterConfig && this.ua ? (this.ua.on(f, e), this.ua.on(p, t), this.ua.register()) : t(new Error("Config is not registered"));
831
+ this.isRegisterConfig && this.ua ? (this.ua.on(p, e), this.ua.on(f, t), this.ua.register()) : t(new Error("Config is not registered"));
832
832
  });
833
833
  }
834
834
  async unregister() {
@@ -878,9 +878,9 @@ class as {
878
878
  const d = new Error("Telephony is not available");
879
879
  a(d);
880
880
  };
881
- _.once(S, E);
881
+ _.once(u, E);
882
882
  const h = () => {
883
- _.removeAllListeners(), _.once(S, o), _.stop();
883
+ _.removeAllListeners(), _.once(u, o), _.stop();
884
884
  };
885
885
  _.once(m, h), _.start();
886
886
  });
@@ -920,11 +920,7 @@ class as {
920
920
  isComplete: a,
921
921
  isRejectAsValid: !0,
922
922
  ...s
923
- }), this._cancelableSendPresentationWithRepeatedCalls.then((c) => {
924
- if (c instanceof MediaStream)
925
- return c;
926
- throw c;
927
- });
923
+ }), this._cancelableSendPresentationWithRepeatedCalls.then((c) => c);
928
924
  }
929
925
  hasEqualConnectionConfiguration(e) {
930
926
  var s;
@@ -947,12 +943,12 @@ class as {
947
943
  }) {
948
944
  if (a && !t)
949
945
  throw new Error("password is required for authorized connection");
950
- const l = a && e ? e.trim() : `${Rn()}`, T = gn(o), u = T(l), C = new this.JsSIP.WebSocketInterface(n);
946
+ const l = a && e ? e.trim() : `${Rn()}`, T = gn(o), S = T(l), C = new this.JsSIP.WebSocketInterface(n);
951
947
  return {
952
948
  configuration: {
953
949
  password: t,
954
950
  register: a,
955
- uri: u,
951
+ uri: S,
956
952
  display_name: be(s),
957
953
  user_agent: d,
958
954
  sdp_semantics: "unified-plan",
@@ -1029,7 +1025,7 @@ class as {
1029
1025
  this._cancelSendPresentationWithRepeatedCalls();
1030
1026
  const t = this._streamPresentationCurrent;
1031
1027
  let n = this.promisePendingStartPresentation ?? Promise.resolve();
1032
- const s = e ? [Sn] : [ln], o = this.establishedSession;
1028
+ const s = e ? [un] : [ln], o = this.establishedSession;
1033
1029
  return o && t && (n = n.then(async () => o.sendInfo(O, void 0, {
1034
1030
  extraHeaders: s
1035
1031
  })).then(async () => o.stopPresentation(t)).catch((a) => {
@@ -1 +1 @@
1
- "use strict";var pt=Object.defineProperty;var Pt=(r,e,t)=>e in r?pt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>Pt(r,typeof e!="symbol"?e+"":e,t);const C=require("@krivega/cancelable-promise"),Me=require("events-constructor"),ve=require("repeated-calls"),B=require("debug"),ft="Connection Error",We="Request Timeout",Ot="SIP Failure Code",Dt="Internal Error",Mt="Busy",V="Rejected",vt="Redirected",bt="Unavailable",qe="Not Found",yt="Address Incomplete",wt="Incompatible SDP",Ut="Missing SDP",Lt="Authentication Error",ke="Terminated",Ht="WebRTC Error",Fe="Canceled",Wt="No Answer",qt="Expires",kt="No ACK",Ft="Dialog Error",Bt="User Denied Media Access",Be="Bad Media Description",Vt="RTP Timeout",Yt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:yt,AUTHENTICATION_ERROR:Lt,BAD_MEDIA_DESCRIPTION:Be,BUSY:Mt,BYE:ke,CANCELED:Fe,CONNECTION_ERROR:ft,DIALOG_ERROR:Ft,EXPIRES:qt,INCOMPATIBLE_SDP:wt,INTERNAL_ERROR:Dt,MISSING_SDP:Ut,NOT_FOUND:qe,NO_ACK:kt,NO_ANSWER:Wt,REDIRECTED:vt,REJECTED:V,REQUEST_TIMEOUT:We,RTP_TIMEOUT:Vt,SIP_FAILURE_CODE:Ot,UNAVAILABLE:bt,USER_DENIED_MEDIA_ACCESS:Bt,WEBRTC_ERROR:Ht},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",G="failedIncomingCall",$="terminatedIncomingCall",q="connecting",m="connected",u="disconnected",M="newRTCSession",p="registered",X="unregistered",P="registrationFailed",Ve="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",j="mustStopPresentation",v="shareState",K="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",b="channels",ne="channels:notify",se="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",y="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Ee="participant:removed-from-list-moderators",le="participant:move-request-to-stream",he="participant:move-request-to-spectators",de="participation:accepting-word-request",Te="participation:cancelling-word-request",ue="webcast:started",Se="webcast:stopped",Ce="account:changed",Ne="account:deleted",ge="conference:participant-token-issued",f="ended",Ye="sending",xe="reinvite",Ge="replaces",$e="refer",Xe="progress",Je="accepted",w="confirmed",U="peerconnection",A="failed",ze="muted",Qe="unmuted",Ae="newDTMF",Re="newInfo",je="hold",Ke="unhold",Ze="update",et="sdp",tt="icecandidate",nt="getusermediafailed",st="peerconnection:createofferfailed",it="peerconnection:createanswerfailed",rt="peerconnection:setlocaldescriptionfailed",ot="peerconnection:setremotedescriptionfailed",at="presentation:start",ct="presentation:started",_t="presentation:end",Ie="presentation:ended",L="presentation:failed",Et="SPECTATOR",xt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Je,ACCOUNT_CHANGED:Ce,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:y,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:b,CHANNELS_NOTIFY:ne,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:ge,CONFIRMED:w,CONNECTED:m,CONNECTING:q,DECLINED_INCOMING_CALL:x,DISCONNECTED:u,ENDED:f,ENDED_FROM_SERVER:se,ENTER_ROOM:K,FAILED:A,FAILED_INCOMING_CALL:G,GET_USER_MEDIA_FAILED:nt,HOLD:je,ICE_CANDIDATE:tt,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:j,MUTED:ze,NEW_DTMF:Ae,NEW_INFO:Re,NEW_MESSAGE:Ve,NEW_RTC_SESSION:M,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:_e,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:he,PARTICIPANT_MOVE_REQUEST_TO_STREAM:le,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Ee,PARTICIPATION_ACCEPTING_WORD_REQUEST:de,PARTICIPATION_CANCELLING_WORD_REQUEST:Te,PEER_CONNECTION:U,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:it,PEER_CONNECTION_CREATE_OFFER_FAILED:st,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:rt,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:ot,PRESENTATION_END:_t,PRESENTATION_ENDED:Ie,PRESENTATION_FAILED:L,PRESENTATION_START:at,PRESENTATION_STARTED:ct,PROGRESS:Xe,REFER:$e,REGISTERED:p,REGISTRATION_FAILED:P,REINVITE:xe,REPLACES:Ge,SDP:et,SENDING:Ye,SHARE_STATE:v,SIP_EVENT:J,SPECTATOR:Et,TERMINATED_INCOMING_CALL:$,UNHOLD:Ke,UNMUTED:Qe,UNREGISTERED:X,UPDATE:Ze,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Se},Symbol.toStringTag,{value:"Module"})),lt=[Y,x,$,G,de,Te,le,ne,ge,Ce,Ne,ue,Se,_e,Ee],me=[q,m,u,M,p,X,P,Ve,J],ht=[z,Q,j,v,K,Z,ee,te,b,se,ie,oe,re,ae,ce,y,he],pe=[f,q,Ye,xe,Ge,$e,Xe,Je,w,U,A,ze,Qe,Ae,Re,je,Ke,Ze,et,tt,nt,st,it,rt,ot,at,ct,_t,Ie,L],Pe=[...me,...lt],fe=[...pe,...ht],Gt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:fe,SESSION_JSSIP_EVENT_NAMES:pe,SESSION_SYNTHETICS_EVENT_NAMES:ht,UA_EVENT_NAMES:Pe,UA_JSSIP_EVENT_NAMES:me,UA_SYNTHETICS_EVENT_NAMES:lt},Symbol.toStringTag,{value:"Module"})),$t=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},Xt="content-type",Jt="x-webrtc-enter-room",O="application/vinteo.webrtc.sharedesktop",zt="application/vinteo.webrtc.roomname",Qt="application/vinteo.webrtc.channels",jt="application/vinteo.webrtc.mediastate",Kt="application/vinteo.webrtc.refusal",be="application/vinteo.webrtc.maincam",Zt="application/vinteo.webrtc.mic",en="application/vinteo.webrtc.uselic",tn="X-WEBRTC-USE-LICENSE",nn="X-WEBRTC-PARTICIPANT-NAME",ye="X-WEBRTC-INPUT-CHANNELS",we="X-WEBRTC-OUTPUT-CHANNELS",sn="X-WEBRTC-MAINCAM",rn="X-WEBRTC-MIC",Ue="X-WEBRTC-SYNC",on="X-WEBRTC-MAINCAM-RESOLUTION",an="X-WEBRTC-MEDIA-STATE",cn="X-Vinteo-Media-Type",_n="X-Vinteo-MainCam-State",En="X-Vinteo-Mic-State",ln="application/vinteo.webrtc.partstate",hn="X-WEBRTC-PARTSTATE",dn="application/vinteo.webrtc.notify",Tn="X-VINTEO-NOTIFY",I="x-webrtc-share-state",un=`${I}: LETMESTARTPRESENTATION`,Sn=`${I}: STOPPRESENTATION`,dt="YOUCANRECEIVECONTENT",Tt="CONTENTEND",ut="YOUMUSTSTOPSENDCONTENT",Cn=`${I}: ${ut}`,Nn=`${I}: ${dt}`,gn=`${I}: ${Tt}`,An="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Rn=`${An}: LETMESTARTMAINCAM`,Oe="sip-connector",D=B(Oe),In=()=>{B.enable(Oe)},mn=()=>{B.enable(`-${Oe}`)};var R=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(R||{}),H=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(H||{}),W=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(W||{}),St=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(St||{});function pn(r){return e=>`sip:${e}@${r}`}const Pn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Le=r=>r.trim().replaceAll(" ","_"),fn=Pn(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const n=t==="recvonly"?[]:r.getAudioTracks(),s=e==="recvonly"?[]:r.getVideoTracks(),o=[...n,...s],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},On=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),Dn="Error decline with 603",Mn=1006,vn=r=>typeof r=="object"&&r!==null&&"code"in r&&r.code===Mn,bn=r=>r.message===Dn,yn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),Ct=1,Nt=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,wn=Nt(Ct),Un=(r,e)=>{const t=r===void 0?void 0:Math.max(r,Ct);if(t!==void 0&&wn(t,e))return t},Ln=Nt(),Hn=(r,e)=>{if(Ln(r,e))return r},gt=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=Un(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const _=s.maxBitrate,E=Hn(e.maxBitrate,_);return E!==void 0&&(n.encodings[0].maxBitrate=E,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},Wn=async(r,e,t)=>{const n=yn(r,e);if(n)return gt(n,{maxBitrate:t})},qn=486,kn=487,F="local",He="remote",Fn=3,Bn=1,Vn=(r=new Error)=>{const{originator:e,cause:t}=r;return C.isCanceledError(r)?!0:typeof t=="string"?t===We||t===V||e===F&&(t===Fe||t===ke):!1},g="SipConnector",Yn="channels",xn="WebcastStarted",Gn="WebcastStopped",$n="accountChanged",Xn="accountDeleted",Jn="addedToListModerators",zn="removedFromListModerators",Qn="ParticipationRequestAccepted",jn="ParticipationRequestRejected",Kn="ParticipantMovedToWebcast",Zn="ConferenceParticipantTokenIssued";class es{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableConnectWithRepeatedCalls");i(this,"_cancelableSendPresentationWithRepeatedCalls");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(q,void 0);try{await this.unregister()}catch(e){D("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=kn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:qn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=Fn}={})=>{let n=!0;const s=async()=>(n=!1,this._cancelableConnect.request(e)),o=a=>{var l;const c=!!((l=this.ua)!=null&&l.isConnected()),_=!n&&c&&this.hasEqualConnectionConfiguration(e),E=!!a&&!vn(a);return _||E};return this._cancelableConnectWithRepeatedCalls=ve.repeatedCallsAsync({targetFunction:s,isComplete:o,callLimit:t,isRejectAsValid:!0,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(a=>{if(a instanceof this.JsSIP.UA)return a;throw a})});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===He){this.incomingSession=t;const n=this.remoteCallerData;t.on(A,s=>{this.removeIncomingSession(),s.originator===F?this._uaEvents.trigger($,n):this._uaEvents.trigger(G,n)}),this._uaEvents.trigger(Y,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:E,userAgent:l,displayName:d="",register:h=!1,extraHeaders:T=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(h&&!e)throw new Error("user is required for authorized connection");if(h&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:d,register:h,user:e,password:t};const{configuration:S,helpers:N}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:s,password:t,displayName:d,register:h,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:E,userAgent:l});this.getSipServerUrl=N.getSipServerUrl,this.socket=N.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!h,this.ua=this._createUa(S),this._uaEvents.eachTriggers((Rt,It)=>{const De=me.find(mt=>mt===It);De&&this.ua&&this.ua.on(De,Rt)});const At=[...$t(o),...T];return this.ua.registrator().setExtraHeaders(At),this.ua});i(this,"_createUa",e=>new this.JsSIP.UA(e));i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(p,s),this.on(P,o)):this.on(m,s),this.on(u,o)},c=()=>{this.off(p,s),this.off(P,o),this.off(m,s),this.off(u,o)};a(),this.on(M,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",Le(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(E=>{s(E)}):_?n(_):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(M,this.handleNewRTCSession);const e=new Promise(t=>{this.once(u,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(u,void 0)):this._uaEvents.trigger(u,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:_,offerToReceiveAudio:E=!0,offerToReceiveVideo:l=!0})=>new Promise((d,h)=>{const{ua:T}=this;if(!T){h(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(d).catch(S=>{h(S)}),this.session=T.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:_,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:E,offerToReceiveVideo:l}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((_,E)=>{if(!this.isAvailableIncomingCall){E(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:l}=this;if(!l){E(new Error("No session established"));return}this._sessionEvents.eachTriggers((h,T)=>{const S=pe.find(N=>N===T);S&&l.on(S,h)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=l.remote_identity.uri.user,this._handleCall({ontrack:t}).then(_).catch(h=>{E(h)});const d=k(e,{videoMode:o,audioMode:a});l.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:d,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(U,l),this.onSession(w,d)},o=()=>{this.offSession(U,l),this.offSession(w,d)},a=()=>{this.onSession(A,_),this.onSession(f,_)},c=()=>{this.offSession(A,_),this.offSession(f,_)},_=h=>{o(),c(),n(h)};let E;const l=({peerconnection:h})=>{E=h,E.ontrack=T=>{this._sessionEvents.trigger(te,E),e&&e(T)}},d=()=>{E&&this._sessionEvents.trigger(ee,E),o(),c(),t(E)};s(),a()}));i(this,"_restoreSession",()=>{this._cancelRequestsAndResetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Ae,({originator:o})=>{o===F&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent)try{await this.stopPresentation()}catch(t){D("error stop presentation: ",t)}if(this._restoreSession(),!e.isEnded())return e.terminateAsync()}});i(this,"_handleShareState",e=>{switch(e){case dt:{this._sessionEvents.trigger(z,void 0);break}case Tt:{this._sessionEvents.trigger(Q,void 0);break}case ut:{this._sessionEvents.trigger(j,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(ye),n=e.getHeader(we);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(b,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case Yn:{const t=e;this._triggerChannelsNotify(t);break}case xn:{const t=e;this._triggerWebcastStartedNotify(t);break}case Gn:{const t=e;this._triggerWebcastStoppedNotify(t);break}case Jn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case zn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Qn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case jn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Kn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case $n:{this._triggerAccountChangedNotify();break}case Xn:{this._triggerAccountDeletedNotify();break}case Zn:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:D("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ue,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Se,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ce,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(ge,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(ne,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Te,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Jt),n=e.getHeader(nn);this._sessionEvents.trigger(K,{room:t,participantName:n})});i(this,"_triggerShareState",e=>{const t=e.getHeader(I);this._sessionEvents.trigger(v,t)});i(this,"_maybeTriggerParticipantMoveRequestToSpectators",e=>{e.getHeader(hn)===Et&&this._sessionEvents.trigger(he,void 0)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(sn),n=e.getHeader(Ue),s=n===W.ADMIN_SYNC_FORCED;if(t===R.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(oe,{isSyncForced:s});return}if(t===R.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(re,{isSyncForced:s});return}(t===R.RESUME_MAIN_CAM||t===R.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(y,{isSyncForced:s});const o=e.getHeader(on);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})});i(this,"_triggerMicControl",e=>{const t=e.getHeader(rn),s=e.getHeader(Ue)===W.ADMIN_SYNC_FORCED;t===H.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:s}):t===H.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(tn);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader(Xt);if(s)switch(s){case zt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case dn:{this._maybeHandleNotify(n);break}case O:{this._triggerShareState(n);break}case be:{this._triggerMainCamControl(n);break}case Zt:{this._triggerMicControl(n);break}case en:{this._triggerUseLicense(n);break}case ln:{this._maybeTriggerParticipantMoveRequestToSpectators(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Tn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===He&&this._sessionEvents.trigger(se,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new Me(fe),this._uaEvents=new Me(Pe),this._cancelableConnect=new C.CancelableRequest(this._connect,{moduleName:g,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new C.CancelableRequest(this._initUa,{moduleName:g}),this._cancelableDisconnect=new C.CancelableRequest(this._disconnect,{moduleName:g}),this._cancelableSet=new C.CancelableRequest(this._set,{moduleName:g}),this._cancelableCall=new C.CancelableRequest(this._call,{moduleName:g}),this._cancelableAnswer=new C.CancelableRequest(this._answer,{moduleName:g}),this._cancelableSendDTMF=new C.CancelableRequest(this._sendDTMF,{moduleName:g}),this.onSession(v,this._handleShareState),this.onSession(Re,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(A,this._handleEnded),this.onSession(f,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(p,e),this.ua.on(P,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(X,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((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.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:s}){return new Promise((o,a)=>{const{configuration:c}=this.createUaConfiguration({sipWebSocketServerURL:s,displayName:t,userAgent:e,sipServerUrl:n}),_=this._createUa(c),E=()=>{const d=new Error("Telephony is not available");a(d)};_.once(u,E);const l=()=>{_.removeAllListeners(),_.once(u,o),_.stop()};_.once(m,l),_.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Rn];return this.session.sendInfo(be,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(bn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentationWithDuplicatedCalls({session:e,stream:t,presentationOptions:n,options:s={callLimit:Bn}}){const o=async()=>this._sendPresentation(e,t,n),a=()=>!!this._streamPresentationCurrent;return this._cancelableSendPresentationWithRepeatedCalls=ve.repeatedCallsAsync({targetFunction:o,isComplete:a,isRejectAsValid:!0,...s}),this._cancelableSendPresentationWithRepeatedCalls.then(c=>{if(c instanceof MediaStream)return c;throw c})}hasEqualConnectionConfiguration(e){var s;const{configuration:t}=this.createUaConfiguration(e),n=(s=this.ua)==null?void 0:s.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:s="",sipServerUrl:o,register:a=!1,sessionTimers:c=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:E=2,connectionRecoveryMaxInterval:l=6,userAgent:d}){if(a&&!t)throw new Error("password is required for authorized connection");const h=a&&e?e.trim():`${fn()}`,T=pn(o),S=T(h),N=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:S,display_name:Le(s),user_agent:d,sdp_semantics:"unified-plan",sockets:[N],session_timers:c,register_expires:_,connection_recovery_min_interval:E,connection_recovery_max_interval:l},helpers:{socket:N,getSipServerUrl:T}}}async _sendPresentation(e,t,{maxBitrate:n,degradationPreference:s,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const _=a?[Nn]:[un],E=e.sendInfo(O,void 0,{extraHeaders:_}).then(async()=>e.startPresentation(c,o,s)).then(async()=>{const{connection:l}=this;if(!l||n===void 0)return;const d=l.getSenders();await Wn(d,t,n)}).then(()=>t).catch(l=>{throw this._removeStreamPresentationCurrent(),this._sessionEvents.trigger(L,l),l});return this.promisePendingStartPresentation=E,E.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:n=!1,maxBitrate:s,degradationPreference:o}={},a){const c=this.establishedSession;if(!c)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(c),this._sendPresentationWithDuplicatedCalls({session:c,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o},options:a})}async sendMustStopPresentation(e){await e.sendInfo(O,void 0,{extraHeaders:[Cn]})}async stopPresentation({isP2P:e=!1}={}){this._cancelSendPresentationWithRepeatedCalls();const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[gn]:[Sn],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(O,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(L,a),a})),!o&&t&&this._sessionEvents.trigger(Ie,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:n,degradationPreference:s}={}){const o=this.establishedSession;if(!o)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(o,e,{isP2P:t,maxBitrate:n,degradationPreference:s,isNeedReinvite:!1})}_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 On(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,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.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,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_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,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(o,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(b)}async waitSyncMediaState(){return this.waitSession(y)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${ye}: ${e}`,s=`${we}: ${t}`,o=[n,s];return this.session.sendInfo(Qt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${an}: currentstate`,o=`${_n}: ${Number(e)}`,a=`${En}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(jt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${cn}: ${e==="mic"?0:1}`];return this.session.sendInfo(Kt,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=Be;exports.EEventsMainCAM=R;exports.EEventsMic=H;exports.EEventsSyncMediaState=W;exports.EUseLicense=St;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=fe;exports.SipConnector=es;exports.UA_EVENT_NAMES=Pe;exports.causes=Yt;exports.constants=xt;exports.disableDebug=mn;exports.enableDebug=In;exports.eventNames=Gt;exports.hasCanceledCallError=Vn;exports.logger=D;exports.setEncodingsToSender=gt;
1
+ "use strict";var pt=Object.defineProperty;var Pt=(r,e,t)=>e in r?pt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>Pt(r,typeof e!="symbol"?e+"":e,t);const C=require("@krivega/cancelable-promise"),Me=require("events-constructor"),ve=require("repeated-calls"),B=require("debug"),Ot="Connection Error",We="Request Timeout",ft="SIP Failure Code",Dt="Internal Error",Mt="Busy",V="Rejected",vt="Redirected",bt="Unavailable",qe="Not Found",yt="Address Incomplete",wt="Incompatible SDP",Ut="Missing SDP",Lt="Authentication Error",ke="Terminated",Ht="WebRTC Error",Fe="Canceled",Wt="No Answer",qt="Expires",kt="No ACK",Ft="Dialog Error",Bt="User Denied Media Access",Be="Bad Media Description",Vt="RTP Timeout",Yt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:yt,AUTHENTICATION_ERROR:Lt,BAD_MEDIA_DESCRIPTION:Be,BUSY:Mt,BYE:ke,CANCELED:Fe,CONNECTION_ERROR:Ot,DIALOG_ERROR:Ft,EXPIRES:qt,INCOMPATIBLE_SDP:wt,INTERNAL_ERROR:Dt,MISSING_SDP:Ut,NOT_FOUND:qe,NO_ACK:kt,NO_ANSWER:Wt,REDIRECTED:vt,REJECTED:V,REQUEST_TIMEOUT:We,RTP_TIMEOUT:Vt,SIP_FAILURE_CODE:ft,UNAVAILABLE:bt,USER_DENIED_MEDIA_ACCESS:Bt,WEBRTC_ERROR:Ht},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",G="failedIncomingCall",$="terminatedIncomingCall",q="connecting",m="connected",u="disconnected",M="newRTCSession",p="registered",X="unregistered",P="registrationFailed",Ve="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",j="mustStopPresentation",v="shareState",K="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",b="channels",ne="channels:notify",se="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",y="admin-force-sync-media-state",_e="participant:added-to-list-moderators",Ee="participant:removed-from-list-moderators",le="participant:move-request-to-stream",he="participant:move-request-to-spectators",de="participation:accepting-word-request",Te="participation:cancelling-word-request",ue="webcast:started",Se="webcast:stopped",Ce="account:changed",Ne="account:deleted",ge="conference:participant-token-issued",O="ended",Ye="sending",xe="reinvite",Ge="replaces",$e="refer",Xe="progress",Je="accepted",w="confirmed",U="peerconnection",A="failed",ze="muted",Qe="unmuted",Ae="newDTMF",Re="newInfo",je="hold",Ke="unhold",Ze="update",et="sdp",tt="icecandidate",nt="getusermediafailed",st="peerconnection:createofferfailed",it="peerconnection:createanswerfailed",rt="peerconnection:setlocaldescriptionfailed",ot="peerconnection:setremotedescriptionfailed",at="presentation:start",ct="presentation:started",_t="presentation:end",Ie="presentation:ended",L="presentation:failed",Et="SPECTATOR",xt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Je,ACCOUNT_CHANGED:Ce,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:y,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:b,CHANNELS_NOTIFY:ne,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:ge,CONFIRMED:w,CONNECTED:m,CONNECTING:q,DECLINED_INCOMING_CALL:x,DISCONNECTED:u,ENDED:O,ENDED_FROM_SERVER:se,ENTER_ROOM:K,FAILED:A,FAILED_INCOMING_CALL:G,GET_USER_MEDIA_FAILED:nt,HOLD:je,ICE_CANDIDATE:tt,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:j,MUTED:ze,NEW_DTMF:Ae,NEW_INFO:Re,NEW_MESSAGE:Ve,NEW_RTC_SESSION:M,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:_e,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:he,PARTICIPANT_MOVE_REQUEST_TO_STREAM:le,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Ee,PARTICIPATION_ACCEPTING_WORD_REQUEST:de,PARTICIPATION_CANCELLING_WORD_REQUEST:Te,PEER_CONNECTION:U,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:it,PEER_CONNECTION_CREATE_OFFER_FAILED:st,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:rt,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:ot,PRESENTATION_END:_t,PRESENTATION_ENDED:Ie,PRESENTATION_FAILED:L,PRESENTATION_START:at,PRESENTATION_STARTED:ct,PROGRESS:Xe,REFER:$e,REGISTERED:p,REGISTRATION_FAILED:P,REINVITE:xe,REPLACES:Ge,SDP:et,SENDING:Ye,SHARE_STATE:v,SIP_EVENT:J,SPECTATOR:Et,TERMINATED_INCOMING_CALL:$,UNHOLD:Ke,UNMUTED:Qe,UNREGISTERED:X,UPDATE:Ze,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Se},Symbol.toStringTag,{value:"Module"})),lt=[Y,x,$,G,de,Te,le,ne,ge,Ce,Ne,ue,Se,_e,Ee],me=[q,m,u,M,p,X,P,Ve,J],ht=[z,Q,j,v,K,Z,ee,te,b,se,ie,oe,re,ae,ce,y,he],pe=[O,q,Ye,xe,Ge,$e,Xe,Je,w,U,A,ze,Qe,Ae,Re,je,Ke,Ze,et,tt,nt,st,it,rt,ot,at,ct,_t,Ie,L],Pe=[...me,...lt],Oe=[...pe,...ht],Gt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:pe,SESSION_SYNTHETICS_EVENT_NAMES:ht,UA_EVENT_NAMES:Pe,UA_JSSIP_EVENT_NAMES:me,UA_SYNTHETICS_EVENT_NAMES:lt},Symbol.toStringTag,{value:"Module"})),$t=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},Xt="content-type",Jt="x-webrtc-enter-room",f="application/vinteo.webrtc.sharedesktop",zt="application/vinteo.webrtc.roomname",Qt="application/vinteo.webrtc.channels",jt="application/vinteo.webrtc.mediastate",Kt="application/vinteo.webrtc.refusal",be="application/vinteo.webrtc.maincam",Zt="application/vinteo.webrtc.mic",en="application/vinteo.webrtc.uselic",tn="X-WEBRTC-USE-LICENSE",nn="X-WEBRTC-PARTICIPANT-NAME",ye="X-WEBRTC-INPUT-CHANNELS",we="X-WEBRTC-OUTPUT-CHANNELS",sn="X-WEBRTC-MAINCAM",rn="X-WEBRTC-MIC",Ue="X-WEBRTC-SYNC",on="X-WEBRTC-MAINCAM-RESOLUTION",an="X-WEBRTC-MEDIA-STATE",cn="X-Vinteo-Media-Type",_n="X-Vinteo-MainCam-State",En="X-Vinteo-Mic-State",ln="application/vinteo.webrtc.partstate",hn="X-WEBRTC-PARTSTATE",dn="application/vinteo.webrtc.notify",Tn="X-VINTEO-NOTIFY",I="x-webrtc-share-state",un=`${I}: LETMESTARTPRESENTATION`,Sn=`${I}: STOPPRESENTATION`,dt="YOUCANRECEIVECONTENT",Tt="CONTENTEND",ut="YOUMUSTSTOPSENDCONTENT",Cn=`${I}: ${ut}`,Nn=`${I}: ${dt}`,gn=`${I}: ${Tt}`,An="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Rn=`${An}: LETMESTARTMAINCAM`,fe="sip-connector",D=B(fe),In=()=>{B.enable(fe)},mn=()=>{B.enable(`-${fe}`)};var R=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(R||{}),H=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(H||{}),W=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(W||{}),St=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(St||{});function pn(r){return e=>`sip:${e}@${r}`}const Pn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Le=r=>r.trim().replaceAll(" ","_"),On=Pn(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const n=t==="recvonly"?[]:r.getAudioTracks(),s=e==="recvonly"?[]:r.getVideoTracks(),o=[...n,...s],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},fn=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),Dn="Error decline with 603",Mn=1006,vn=r=>typeof r=="object"&&r!==null&&"code"in r&&r.code===Mn,bn=r=>r.message===Dn,yn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),Ct=1,Nt=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,wn=Nt(Ct),Un=(r,e)=>{const t=r===void 0?void 0:Math.max(r,Ct);if(t!==void 0&&wn(t,e))return t},Ln=Nt(),Hn=(r,e)=>{if(Ln(r,e))return r},gt=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=Un(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const _=s.maxBitrate,E=Hn(e.maxBitrate,_);return E!==void 0&&(n.encodings[0].maxBitrate=E,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},Wn=async(r,e,t)=>{const n=yn(r,e);if(n)return gt(n,{maxBitrate:t})},qn=486,kn=487,F="local",He="remote",Fn=3,Bn=1,Vn=(r=new Error)=>{const{originator:e,cause:t}=r;return C.isCanceledError(r)?!0:typeof t=="string"?t===We||t===V||e===F&&(t===Fe||t===ke):!1},g="SipConnector",Yn="channels",xn="WebcastStarted",Gn="WebcastStopped",$n="accountChanged",Xn="accountDeleted",Jn="addedToListModerators",zn="removedFromListModerators",Qn="ParticipationRequestAccepted",jn="ParticipationRequestRejected",Kn="ParticipantMovedToWebcast",Zn="ConferenceParticipantTokenIssued";class es{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableConnectWithRepeatedCalls");i(this,"_cancelableSendPresentationWithRepeatedCalls");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(q,void 0);try{await this.unregister()}catch(e){D("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=kn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:qn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=Fn}={})=>{let n=!0;const s=async()=>(n=!1,this._cancelableConnect.request(e)),o=a=>{var l;const c=!!((l=this.ua)!=null&&l.isConnected()),_=!n&&c&&this.hasEqualConnectionConfiguration(e),E=!!a&&!vn(a);return _||E};return this._cancelableConnectWithRepeatedCalls=ve.repeatedCallsAsync({targetFunction:s,isComplete:o,callLimit:t,isRejectAsValid:!0,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(a=>{if(a instanceof this.JsSIP.UA)return a;throw a})});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===He){this.incomingSession=t;const n=this.remoteCallerData;t.on(A,s=>{this.removeIncomingSession(),s.originator===F?this._uaEvents.trigger($,n):this._uaEvents.trigger(G,n)}),this._uaEvents.trigger(Y,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:E,userAgent:l,displayName:d="",register:h=!1,extraHeaders:T=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(h&&!e)throw new Error("user is required for authorized connection");if(h&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:d,register:h,user:e,password:t};const{configuration:S,helpers:N}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:s,password:t,displayName:d,register:h,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:E,userAgent:l});this.getSipServerUrl=N.getSipServerUrl,this.socket=N.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!h,this.ua=this._createUa(S),this._uaEvents.eachTriggers((Rt,It)=>{const De=me.find(mt=>mt===It);De&&this.ua&&this.ua.on(De,Rt)});const At=[...$t(o),...T];return this.ua.registrator().setExtraHeaders(At),this.ua});i(this,"_createUa",e=>new this.JsSIP.UA(e));i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(p,s),this.on(P,o)):this.on(m,s),this.on(u,o)},c=()=>{this.off(p,s),this.off(P,o),this.off(m,s),this.off(u,o)};a(),this.on(M,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",Le(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(E=>{s(E)}):_?n(_):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(M,this.handleNewRTCSession);const e=new Promise(t=>{this.once(u,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(u,void 0)):this._uaEvents.trigger(u,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:_,offerToReceiveAudio:E=!0,offerToReceiveVideo:l=!0})=>new Promise((d,h)=>{const{ua:T}=this;if(!T){h(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(d).catch(S=>{h(S)}),this.session=T.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:_,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:E,offerToReceiveVideo:l}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((_,E)=>{if(!this.isAvailableIncomingCall){E(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:l}=this;if(!l){E(new Error("No session established"));return}this._sessionEvents.eachTriggers((h,T)=>{const S=pe.find(N=>N===T);S&&l.on(S,h)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=l.remote_identity.uri.user,this._handleCall({ontrack:t}).then(_).catch(h=>{E(h)});const d=k(e,{videoMode:o,audioMode:a});l.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:d,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(U,l),this.onSession(w,d)},o=()=>{this.offSession(U,l),this.offSession(w,d)},a=()=>{this.onSession(A,_),this.onSession(O,_)},c=()=>{this.offSession(A,_),this.offSession(O,_)},_=h=>{o(),c(),n(h)};let E;const l=({peerconnection:h})=>{E=h,E.ontrack=T=>{this._sessionEvents.trigger(te,E),e&&e(T)}},d=()=>{E&&this._sessionEvents.trigger(ee,E),o(),c(),t(E)};s(),a()}));i(this,"_restoreSession",()=>{this._cancelRequestsAndResetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Ae,({originator:o})=>{o===F&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent)try{await this.stopPresentation()}catch(t){D("error stop presentation: ",t)}if(this._restoreSession(),!e.isEnded())return e.terminateAsync()}});i(this,"_handleShareState",e=>{switch(e){case dt:{this._sessionEvents.trigger(z,void 0);break}case Tt:{this._sessionEvents.trigger(Q,void 0);break}case ut:{this._sessionEvents.trigger(j,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(ye),n=e.getHeader(we);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(b,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case Yn:{const t=e;this._triggerChannelsNotify(t);break}case xn:{const t=e;this._triggerWebcastStartedNotify(t);break}case Gn:{const t=e;this._triggerWebcastStoppedNotify(t);break}case Jn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case zn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Qn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case jn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Kn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case $n:{this._triggerAccountChangedNotify();break}case Xn:{this._triggerAccountDeletedNotify();break}case Zn:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:D("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ue,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Se,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ce,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(ge,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(ne,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Te,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Jt),n=e.getHeader(nn);this._sessionEvents.trigger(K,{room:t,participantName:n})});i(this,"_triggerShareState",e=>{const t=e.getHeader(I);this._sessionEvents.trigger(v,t)});i(this,"_maybeTriggerParticipantMoveRequestToSpectators",e=>{e.getHeader(hn)===Et&&this._sessionEvents.trigger(he,void 0)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(sn),n=e.getHeader(Ue),s=n===W.ADMIN_SYNC_FORCED;if(t===R.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(oe,{isSyncForced:s});return}if(t===R.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(re,{isSyncForced:s});return}(t===R.RESUME_MAIN_CAM||t===R.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(y,{isSyncForced:s});const o=e.getHeader(on);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})});i(this,"_triggerMicControl",e=>{const t=e.getHeader(rn),s=e.getHeader(Ue)===W.ADMIN_SYNC_FORCED;t===H.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:s}):t===H.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(tn);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader(Xt);if(s)switch(s){case zt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case dn:{this._maybeHandleNotify(n);break}case f:{this._triggerShareState(n);break}case be:{this._triggerMainCamControl(n);break}case Zt:{this._triggerMicControl(n);break}case en:{this._triggerUseLicense(n);break}case ln:{this._maybeTriggerParticipantMoveRequestToSpectators(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Tn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===He&&this._sessionEvents.trigger(se,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new Me(Oe),this._uaEvents=new Me(Pe),this._cancelableConnect=new C.CancelableRequest(this._connect,{moduleName:g,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new C.CancelableRequest(this._initUa,{moduleName:g}),this._cancelableDisconnect=new C.CancelableRequest(this._disconnect,{moduleName:g}),this._cancelableSet=new C.CancelableRequest(this._set,{moduleName:g}),this._cancelableCall=new C.CancelableRequest(this._call,{moduleName:g}),this._cancelableAnswer=new C.CancelableRequest(this._answer,{moduleName:g}),this._cancelableSendDTMF=new C.CancelableRequest(this._sendDTMF,{moduleName:g}),this.onSession(v,this._handleShareState),this.onSession(Re,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(A,this._handleEnded),this.onSession(O,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(p,e),this.ua.on(P,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(X,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((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.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:s}){return new Promise((o,a)=>{const{configuration:c}=this.createUaConfiguration({sipWebSocketServerURL:s,displayName:t,userAgent:e,sipServerUrl:n}),_=this._createUa(c),E=()=>{const d=new Error("Telephony is not available");a(d)};_.once(u,E);const l=()=>{_.removeAllListeners(),_.once(u,o),_.stop()};_.once(m,l),_.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Rn];return this.session.sendInfo(be,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(bn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentationWithDuplicatedCalls({session:e,stream:t,presentationOptions:n,options:s={callLimit:Bn}}){const o=async()=>this._sendPresentation(e,t,n),a=()=>!!this._streamPresentationCurrent;return this._cancelableSendPresentationWithRepeatedCalls=ve.repeatedCallsAsync({targetFunction:o,isComplete:a,isRejectAsValid:!0,...s}),this._cancelableSendPresentationWithRepeatedCalls.then(c=>c)}hasEqualConnectionConfiguration(e){var s;const{configuration:t}=this.createUaConfiguration(e),n=(s=this.ua)==null?void 0:s.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:s="",sipServerUrl:o,register:a=!1,sessionTimers:c=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:E=2,connectionRecoveryMaxInterval:l=6,userAgent:d}){if(a&&!t)throw new Error("password is required for authorized connection");const h=a&&e?e.trim():`${On()}`,T=pn(o),S=T(h),N=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:S,display_name:Le(s),user_agent:d,sdp_semantics:"unified-plan",sockets:[N],session_timers:c,register_expires:_,connection_recovery_min_interval:E,connection_recovery_max_interval:l},helpers:{socket:N,getSipServerUrl:T}}}async _sendPresentation(e,t,{maxBitrate:n,degradationPreference:s,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const _=a?[Nn]:[un],E=e.sendInfo(f,void 0,{extraHeaders:_}).then(async()=>e.startPresentation(c,o,s)).then(async()=>{const{connection:l}=this;if(!l||n===void 0)return;const d=l.getSenders();await Wn(d,t,n)}).then(()=>t).catch(l=>{throw this._removeStreamPresentationCurrent(),this._sessionEvents.trigger(L,l),l});return this.promisePendingStartPresentation=E,E.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:n=!1,maxBitrate:s,degradationPreference:o}={},a){const c=this.establishedSession;if(!c)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(c),this._sendPresentationWithDuplicatedCalls({session:c,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o},options:a})}async sendMustStopPresentation(e){await e.sendInfo(f,void 0,{extraHeaders:[Cn]})}async stopPresentation({isP2P:e=!1}={}){this._cancelSendPresentationWithRepeatedCalls();const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[gn]:[Sn],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(f,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(L,a),a})),!o&&t&&this._sessionEvents.trigger(Ie,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:n,degradationPreference:s}={}){const o=this.establishedSession;if(!o)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(o,e,{isP2P:t,maxBitrate:n,degradationPreference:s,isNeedReinvite:!1})}_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 fn(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,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.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,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_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,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(o,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(b)}async waitSyncMediaState(){return this.waitSession(y)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${ye}: ${e}`,s=`${we}: ${t}`,o=[n,s];return this.session.sendInfo(Qt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${an}: currentstate`,o=`${_n}: ${Number(e)}`,a=`${En}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(jt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${cn}: ${e==="mic"?0:1}`];return this.session.sendInfo(Kt,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=Be;exports.EEventsMainCAM=R;exports.EEventsMic=H;exports.EEventsSyncMediaState=W;exports.EUseLicense=St;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=es;exports.UA_EVENT_NAMES=Pe;exports.causes=Yt;exports.constants=xt;exports.disableDebug=mn;exports.enableDebug=In;exports.eventNames=Gt;exports.hasCanceledCallError=Vn;exports.logger=D;exports.setEncodingsToSender=gt;
package/dist/doMock.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var k=(o,t,e)=>t in o?b(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>k(o,typeof t!="symbol"?t+"":t,e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./SipConnector-BA8w-WR5.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),L=require("@krivega/jssip/lib/URI"),F=require("node:events"),V=require("@krivega/jssip/lib/SIPMessage"),C=require("webrtc-mock"),I=require("events-constructor"),T=require("@krivega/jssip");class y extends V.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class z{constructor({originator:t="local",eventHandlers:e}){r(this,"originator");r(this,"_connection");r(this,"_events");r(this,"_remote_identity");r(this,"_mutedOptions",{audio:!1,video:!1});this.originator=t,this._events=new I(g.SESSION_EVENT_NAMES),this.initEvents(e)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(t){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(t){throw new Error("Method not implemented.")}terminate(t){throw new Error("Method not implemented.")}async sendInfo(t,e,n){throw new Error("Method not implemented.")}hold(t,e){throw new Error("Method not implemented.")}unhold(t,e){throw new Error("Method not implemented.")}async renegotiate(t,e){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(t){throw new Error("Method not implemented.")}unmute(t){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(t,e){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(t,e){throw new Error("Method not implemented.")}addListener(t,e){throw new Error("Method not implemented.")}once(t,e){throw new Error("Method not implemented.")}removeListener(t,e){throw new Error("Method not implemented.")}off(t,e){throw new Error("Method not implemented.")}removeAllListeners(t){throw new Error("Method not implemented.")}setMaxListeners(t){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(t){throw new Error("Method not implemented.")}rawListeners(t){throw new Error("Method not implemented.")}emit(t,...e){throw new Error("Method not implemented.")}listenerCount(t){throw new Error("Method not implemented.")}prependListener(t,e){throw new Error("Method not implemented.")}prependOnceListener(t,e){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(t=[]){Object.entries(t).forEach(([e,n])=>this.on(e,n))}on(t,e){return this._events.on(t,e),this}trigger(t,e){this._events.trigger(t,e)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(t){return t}async updatePresentation(t){return t}async stopPresentation(t){return t}isEstablished(){return!0}}class U{constructor(t,e){r(this,"_senders",[]);r(this,"_receivers",[]);r(this,"canTrickleIceCandidates");r(this,"connectionState");r(this,"currentLocalDescription");r(this,"currentRemoteDescription");r(this,"iceConnectionState");r(this,"iceGatheringState");r(this,"idpErrorInfo");r(this,"idpLoginUrl");r(this,"localDescription");r(this,"onconnectionstatechange");r(this,"ondatachannel");r(this,"onicecandidate");r(this,"onicecandidateerror",null);r(this,"oniceconnectionstatechange");r(this,"onicegatheringstatechange");r(this,"onnegotiationneeded");r(this,"onsignalingstatechange");r(this,"ontrack");r(this,"peerIdentity");r(this,"pendingLocalDescription");r(this,"pendingRemoteDescription");r(this,"remoteDescription");r(this,"sctp",null);r(this,"signalingState");r(this,"getReceivers",()=>this._receivers);r(this,"getSenders",()=>this._senders);r(this,"addTrack",t=>{const e={track:t};return this._senders.push(e),e});this._receivers=e.map(n=>({track:n}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(t){throw new Error("Method not implemented.")}addTransceiver(t,e){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(t,e){throw new Error("Method not implemented.")}createDataChannel(t,e){throw new Error("Method not implemented.")}async createOffer(t,e,n){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(t){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(t){throw new Error("Method not implemented.")}setConfiguration(t){throw new Error("Method not implemented.")}async setLocalDescription(t){throw new Error("Method not implemented.")}async setRemoteDescription(t){throw new Error("Method not implemented.")}addEventListener(t,e,n){throw new Error("Method not implemented.")}removeEventListener(t,e,n){throw new Error("Method not implemented.")}dispatchEvent(t){throw new Error("Method not implemented.")}}function q(o){const t=o.match(/(purgatory)|[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const w=400,N="777",x=o=>o.getVideoTracks().length>0,a=class a extends z{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:d}){super({originator:d,eventHandlers:i});r(this,"url");r(this,"status_code");r(this,"_isEnded",!1);r(this,"answer",jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},w)}));this.url=e,this.initPeerconnection(n)}static setStartPresentationError(e,{count:n=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=n}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}async startPresentation(e){if(a.countStartsPresentation+=1,a.startPresentationError&&a.countStartsPresentation<a.countStartPresentationError)throw a.startPresentationError;return super.startPresentation(e)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=C.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(x(e)){const u=C.createVideoMediaStreamTrackMock();u.id="mainvideo1",i.push(u)}this._connection=new U(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},w)}connect(e){const n=q(e);setTimeout(()=>{this.url.includes(N)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:g.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",{room:n})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},w)}terminate({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e}),this._isEnded=!1,this}async terminateAsync({status_code:e}={}){this.terminate({status_code:e})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}_addStream(e,n="getTracks"){e[n]().forEach(i=>this.connection.addTrack(i))}_forEachSenders(e){const n=this.connection.getSenders();for(const i of n)e(i);return n}_toggleMuteAudio(e){this._forEachSenders(({track:n})=>{n&&n.kind==="audio"&&(n.enabled=!e)})}_toggleMuteVideo(e){this._forEachSenders(({track:n})=>{n&&n.kind==="video"&&(n.enabled=!e)})}mute(e){e.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),e.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(e)}unmute(e){e.audio&&(this._mutedOptions.audio=!1),e.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this._mutedOptions}async replaceMediaStream(e){return e}_onmute({audio:e,video:n}){this.trigger("muted",{audio:e,video:n})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(e){this.trigger("newInfo",e)}};r(a,"startPresentationError"),r(a,"countStartPresentationError",Number.POSITIVE_INFINITY),r(a,"countStartsPresentation",0);let l=a;class H{constructor(){r(this,"extraHeaders")}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const c="PASSWORD_CORRECT",f="PASSWORD_CORRECT_2",P="NAME_INCORRECT",m=400,s=class s{constructor(t){r(this,"_events");r(this,"_startedTimeout");r(this,"_stopedTimeout");r(this,"session");r(this,"_isRegistered");r(this,"_isConnected");r(this,"configuration");r(this,"_registrator");r(this,"call",jest.fn((t,e)=>{const{mediaStream:n,eventHandlers:i}=e;return this.session=new l({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new I(g.UA_EVENT_NAMES);const[e,n]=t.uri.split(":"),[i,d]=n.split("@"),u={...t,uri:new T.URI(e,i,d)};this.configuration=u,this._registrator=new H}static setStartError(t,{count:e=Number.POSITIVE_INFINITY}={}){this.startError=t,this.countStartError=e}static resetStartError(){this.startError=void 0,this.countStartError=Number.POSITIVE_INFINITY,this.countStarts=0}static setAvailableTelephony(){this.isAvailableTelephony=!0}static setNotAvailableTelephony(){this.isAvailableTelephony=!1}isConnected(){return!!this._isConnected}start(){if(s.countStarts+=1,s.startError&&s.countStarts<s.countStartError){this.trigger("disconnected",s.startError);return}this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},m):this.trigger("disconnected",{error:new Error("stoped")})}on(t,e){return this._events.on(t,e),this}once(t,e){return this._events.once(t,e),this}off(t,e){return this._events.off(t,e),this}removeAllListeners(){return this._events.removeEventHandlers(),this}trigger(t,e){this._events.trigger(t,e)}terminateSessions(){this.session.terminate()}set(t,e){return this.configuration[t]=e,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:t,register:e,uri:n}=this.configuration;e&&n.user.includes(P)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},m)):!this._isRegistered&&e&&(t===c||t===f)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},m)):e&&t!==c&&t!==f&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},m)),s.isAvailableTelephony?(this.trigger("connected"),this._isConnected=!0):this.stop()}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(t){this.trigger("sipEvent",t)}};r(s,"isAvailableTelephony",!0),r(s,"startError"),r(s,"countStartError",Number.POSITIVE_INFINITY),r(s,"countStarts",0);let M=s;class Y{constructor(t){r(this,"url");this.url=t}}class j extends F.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const S="remote",B=(o,t)=>{const e=new y(t),n={originator:S,request:e,info:new j("","")};o.newInfo(n)},K=(o,t)=>{const n={request:new y(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new l({originator:S}),d=new L("sip",t,n);i._remote_identity=new D(d,e),o.trigger("newRTCSession",{originator:S,session:i})},J=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},A={triggerNewInfo:B,triggerNewSipEvent:K,triggerIncomingSession:$,triggerFailIncomingSession:J,WebSocketInterface:Y,UA:M,C:{INVITE:"INVITE"}},_="user",h="displayName",E="SIP_SERVER_URL",R="SIP_WEB_SOCKET_SERVER_URL",G=new A.WebSocketInterface(R),v={userAgent:"Chrome",sipServerUrl:E,sipWebSocketServerURL:R},X={...v},O={...v,user:_,password:c,register:!0},Q={...O,displayName:h},Z={...v,displayName:h,register:!1},p={session_timers:!1,sockets:[G],user_agent:"Chrome",sdp_semantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},ee={...p,password:c,uri:new T.URI("sip",_,E),display_name:"",register:!0},te={...p,password:c,uri:new T.URI("sip",_,E),display_name:h,register:!0},re={...p,display_name:h,register:!1},ne={...p,display_name:"",register:!1},W="10.10.10.10",oe=[`X-Vinteo-Remote: ${W}`],ie=()=>new g.SipConnector({JsSIP:A});exports.FAILED_CONFERENCE_NUMBER=N;exports.NAME_INCORRECT=P;exports.PASSWORD_CORRECT=c;exports.PASSWORD_CORRECT_2=f;exports.SIP_SERVER_URL=E;exports.SIP_WEB_SOCKET_SERVER_URL=R;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=Q;exports.dataForConnectionWithoutAuthorization=Z;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=X;exports.default=ie;exports.displayName=h;exports.extraHeadersRemoteAddress=oe;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=ee;exports.uaConfigurationWithAuthorizationWithDisplayName=te;exports.uaConfigurationWithoutAuthorization=re;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ne;exports.user=_;
1
+ "use strict";var b=Object.defineProperty;var k=(o,t,e)=>t in o?b(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>k(o,typeof t!="symbol"?t+"":t,e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./SipConnector-Dg0Vq0lq.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),L=require("@krivega/jssip/lib/URI"),F=require("node:events"),V=require("@krivega/jssip/lib/SIPMessage"),C=require("webrtc-mock"),I=require("events-constructor"),T=require("@krivega/jssip");class y extends V.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class z{constructor({originator:t="local",eventHandlers:e}){r(this,"originator");r(this,"_connection");r(this,"_events");r(this,"_remote_identity");r(this,"_mutedOptions",{audio:!1,video:!1});this.originator=t,this._events=new I(g.SESSION_EVENT_NAMES),this.initEvents(e)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(t){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(t){throw new Error("Method not implemented.")}terminate(t){throw new Error("Method not implemented.")}async sendInfo(t,e,n){throw new Error("Method not implemented.")}hold(t,e){throw new Error("Method not implemented.")}unhold(t,e){throw new Error("Method not implemented.")}async renegotiate(t,e){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(t){throw new Error("Method not implemented.")}unmute(t){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(t,e){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(t,e){throw new Error("Method not implemented.")}addListener(t,e){throw new Error("Method not implemented.")}once(t,e){throw new Error("Method not implemented.")}removeListener(t,e){throw new Error("Method not implemented.")}off(t,e){throw new Error("Method not implemented.")}removeAllListeners(t){throw new Error("Method not implemented.")}setMaxListeners(t){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(t){throw new Error("Method not implemented.")}rawListeners(t){throw new Error("Method not implemented.")}emit(t,...e){throw new Error("Method not implemented.")}listenerCount(t){throw new Error("Method not implemented.")}prependListener(t,e){throw new Error("Method not implemented.")}prependOnceListener(t,e){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(t=[]){Object.entries(t).forEach(([e,n])=>this.on(e,n))}on(t,e){return this._events.on(t,e),this}trigger(t,e){this._events.trigger(t,e)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(t){return t}async updatePresentation(t){return t}async stopPresentation(t){return t}isEstablished(){return!0}}class U{constructor(t,e){r(this,"_senders",[]);r(this,"_receivers",[]);r(this,"canTrickleIceCandidates");r(this,"connectionState");r(this,"currentLocalDescription");r(this,"currentRemoteDescription");r(this,"iceConnectionState");r(this,"iceGatheringState");r(this,"idpErrorInfo");r(this,"idpLoginUrl");r(this,"localDescription");r(this,"onconnectionstatechange");r(this,"ondatachannel");r(this,"onicecandidate");r(this,"onicecandidateerror",null);r(this,"oniceconnectionstatechange");r(this,"onicegatheringstatechange");r(this,"onnegotiationneeded");r(this,"onsignalingstatechange");r(this,"ontrack");r(this,"peerIdentity");r(this,"pendingLocalDescription");r(this,"pendingRemoteDescription");r(this,"remoteDescription");r(this,"sctp",null);r(this,"signalingState");r(this,"getReceivers",()=>this._receivers);r(this,"getSenders",()=>this._senders);r(this,"addTrack",t=>{const e={track:t};return this._senders.push(e),e});this._receivers=e.map(n=>({track:n}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(t){throw new Error("Method not implemented.")}addTransceiver(t,e){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(t,e){throw new Error("Method not implemented.")}createDataChannel(t,e){throw new Error("Method not implemented.")}async createOffer(t,e,n){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(t){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(t){throw new Error("Method not implemented.")}setConfiguration(t){throw new Error("Method not implemented.")}async setLocalDescription(t){throw new Error("Method not implemented.")}async setRemoteDescription(t){throw new Error("Method not implemented.")}addEventListener(t,e,n){throw new Error("Method not implemented.")}removeEventListener(t,e,n){throw new Error("Method not implemented.")}dispatchEvent(t){throw new Error("Method not implemented.")}}function q(o){const t=o.match(/(purgatory)|[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const w=400,N="777",x=o=>o.getVideoTracks().length>0,a=class a extends z{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:d}){super({originator:d,eventHandlers:i});r(this,"url");r(this,"status_code");r(this,"_isEnded",!1);r(this,"answer",jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},w)}));this.url=e,this.initPeerconnection(n)}static setStartPresentationError(e,{count:n=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=n}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}async startPresentation(e){if(a.countStartsPresentation+=1,a.startPresentationError&&a.countStartsPresentation<a.countStartPresentationError)throw a.startPresentationError;return super.startPresentation(e)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=C.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(x(e)){const u=C.createVideoMediaStreamTrackMock();u.id="mainvideo1",i.push(u)}this._connection=new U(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},w)}connect(e){const n=q(e);setTimeout(()=>{this.url.includes(N)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:g.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",{room:n})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},w)}terminate({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e}),this._isEnded=!1,this}async terminateAsync({status_code:e}={}){this.terminate({status_code:e})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}_addStream(e,n="getTracks"){e[n]().forEach(i=>this.connection.addTrack(i))}_forEachSenders(e){const n=this.connection.getSenders();for(const i of n)e(i);return n}_toggleMuteAudio(e){this._forEachSenders(({track:n})=>{n&&n.kind==="audio"&&(n.enabled=!e)})}_toggleMuteVideo(e){this._forEachSenders(({track:n})=>{n&&n.kind==="video"&&(n.enabled=!e)})}mute(e){e.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),e.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(e)}unmute(e){e.audio&&(this._mutedOptions.audio=!1),e.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this._mutedOptions}async replaceMediaStream(e){return e}_onmute({audio:e,video:n}){this.trigger("muted",{audio:e,video:n})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(e){this.trigger("newInfo",e)}};r(a,"startPresentationError"),r(a,"countStartPresentationError",Number.POSITIVE_INFINITY),r(a,"countStartsPresentation",0);let l=a;class H{constructor(){r(this,"extraHeaders")}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const c="PASSWORD_CORRECT",f="PASSWORD_CORRECT_2",P="NAME_INCORRECT",m=400,s=class s{constructor(t){r(this,"_events");r(this,"_startedTimeout");r(this,"_stopedTimeout");r(this,"session");r(this,"_isRegistered");r(this,"_isConnected");r(this,"configuration");r(this,"_registrator");r(this,"call",jest.fn((t,e)=>{const{mediaStream:n,eventHandlers:i}=e;return this.session=new l({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new I(g.UA_EVENT_NAMES);const[e,n]=t.uri.split(":"),[i,d]=n.split("@"),u={...t,uri:new T.URI(e,i,d)};this.configuration=u,this._registrator=new H}static setStartError(t,{count:e=Number.POSITIVE_INFINITY}={}){this.startError=t,this.countStartError=e}static resetStartError(){this.startError=void 0,this.countStartError=Number.POSITIVE_INFINITY,this.countStarts=0}static setAvailableTelephony(){this.isAvailableTelephony=!0}static setNotAvailableTelephony(){this.isAvailableTelephony=!1}isConnected(){return!!this._isConnected}start(){if(s.countStarts+=1,s.startError&&s.countStarts<s.countStartError){this.trigger("disconnected",s.startError);return}this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},m):this.trigger("disconnected",{error:new Error("stoped")})}on(t,e){return this._events.on(t,e),this}once(t,e){return this._events.once(t,e),this}off(t,e){return this._events.off(t,e),this}removeAllListeners(){return this._events.removeEventHandlers(),this}trigger(t,e){this._events.trigger(t,e)}terminateSessions(){this.session.terminate()}set(t,e){return this.configuration[t]=e,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:t,register:e,uri:n}=this.configuration;e&&n.user.includes(P)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},m)):!this._isRegistered&&e&&(t===c||t===f)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},m)):e&&t!==c&&t!==f&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},m)),s.isAvailableTelephony?(this.trigger("connected"),this._isConnected=!0):this.stop()}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(t){this.trigger("sipEvent",t)}};r(s,"isAvailableTelephony",!0),r(s,"startError"),r(s,"countStartError",Number.POSITIVE_INFINITY),r(s,"countStarts",0);let M=s;class Y{constructor(t){r(this,"url");this.url=t}}class j extends F.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const S="remote",B=(o,t)=>{const e=new y(t),n={originator:S,request:e,info:new j("","")};o.newInfo(n)},K=(o,t)=>{const n={request:new y(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new l({originator:S}),d=new L("sip",t,n);i._remote_identity=new D(d,e),o.trigger("newRTCSession",{originator:S,session:i})},J=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},A={triggerNewInfo:B,triggerNewSipEvent:K,triggerIncomingSession:$,triggerFailIncomingSession:J,WebSocketInterface:Y,UA:M,C:{INVITE:"INVITE"}},_="user",h="displayName",E="SIP_SERVER_URL",R="SIP_WEB_SOCKET_SERVER_URL",G=new A.WebSocketInterface(R),v={userAgent:"Chrome",sipServerUrl:E,sipWebSocketServerURL:R},X={...v},O={...v,user:_,password:c,register:!0},Q={...O,displayName:h},Z={...v,displayName:h,register:!1},p={session_timers:!1,sockets:[G],user_agent:"Chrome",sdp_semantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},ee={...p,password:c,uri:new T.URI("sip",_,E),display_name:"",register:!0},te={...p,password:c,uri:new T.URI("sip",_,E),display_name:h,register:!0},re={...p,display_name:h,register:!1},ne={...p,display_name:"",register:!1},W="10.10.10.10",oe=[`X-Vinteo-Remote: ${W}`],ie=()=>new g.SipConnector({JsSIP:A});exports.FAILED_CONFERENCE_NUMBER=N;exports.NAME_INCORRECT=P;exports.PASSWORD_CORRECT=c;exports.PASSWORD_CORRECT_2=f;exports.SIP_SERVER_URL=E;exports.SIP_WEB_SOCKET_SERVER_URL=R;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=Q;exports.dataForConnectionWithoutAuthorization=Z;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=X;exports.default=ie;exports.displayName=h;exports.extraHeadersRemoteAddress=oe;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=ee;exports.uaConfigurationWithAuthorizationWithDisplayName=te;exports.uaConfigurationWithoutAuthorization=re;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=ne;exports.user=_;
package/dist/doMock.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var y = Object.defineProperty;
2
2
  var N = (o, t, e) => t in o ? y(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
3
  var r = (o, t, e) => N(o, typeof t != "symbol" ? t + "" : t, e);
4
- import { j as P, R as O, U as A, S as b } from "./SipConnector-C5s0hhzA.js";
4
+ import { j as P, R as O, U as A, S as b } from "./SipConnector-CpJaoOHN.js";
5
5
  import k from "@krivega/jssip/lib/NameAddrHeader";
6
6
  import D from "@krivega/jssip/lib/URI";
7
7
  import { EventEmitter as L } from "node:events";
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./SipConnector-BA8w-WR5.cjs"),K=require("ts-debounce"),H=require("@krivega/cancelable-promise"),Y=require("repeated-calls"),z=require("sequent-promises"),J=require("stack-promises"),Q=require("debug"),L="purgatory",p=e=>e===L,I=e=>()=>(r.logger("getRemoteStreams"),e.getRemoteStreams()),Z=({kind:e,readyState:t})=>e==="video"&&t==="live",V=e=>({track:t})=>{Z(t)&&e()},D=({getRemoteStreams:e,setRemoteStreams:t})=>K.debounce(()=>{const n=e();r.logger("remoteStreams",n),n&&t(n)},200),ee=e=>async n=>{const{mediaStream:s,extraHeaders:o,iceServers:c,degradationPreference:a,setRemoteStreams:u,onBeforeProgressCall:l,onSuccessProgressCall:d,onEnterPurgatory:m,onEnterConference:g,onFailProgressCall:S,onFinishProgressCall:T,onEndedCall:f}=n,E=D({setRemoteStreams:u,getRemoteStreams:I(e)}),y=V(E);r.logger("answerIncomingCall",n);const _=async()=>e.answerToIncomingCall({mediaStream:s,extraHeaders:o,iceServers:c,degradationPreference:a,ontrack:y}),h=()=>{const{remoteCallerData:i}=e;return i.incomingNumber};let M=!1,R;const b=(r.logger("subscribeEnterConference: onEnterConference",g),m??g?e.onSession("enterRoom",i=>{r.logger("enterRoom",{_room:i,isSuccessProgressCall:M}),R=i,p(R)?m&&m():g&&g({isSuccessProgressCall:M})}):()=>{}),v=i=>(r.logger("onSuccess"),M=!0,E(),d&&d({isPurgatory:p(R)}),e.onceRaceSession(["ended","failed"],()=>{b(),f&&f()}),i),O=i=>{throw r.logger("onFail"),S&&S(),b(),i},A=()=>{r.logger("onFinish"),T&&T()};if(r.logger("onBeforeProgressCall"),l){const i=h();l(i)}return _().then(v).catch(i=>O(i)).finally(A)},ne=e=>async n=>{const{conference:s,mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,setRemoteStreams:l,onBeforeProgressCall:d,onSuccessProgressCall:m,onEnterPurgatory:g,onEnterConference:S,onFailProgressCall:T,onFinishProgressCall:f,onEndedCall:E}=n,y=D({setRemoteStreams:l,getRemoteStreams:I(e)}),_=V(y);r.logger("callToServer",n);const h=async()=>(r.logger("startCall"),e.call({mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,number:s,ontrack:_}));let M=!1,R;const b=(r.logger("subscribeEnterConference: onEnterConference",S),g??S?e.onSession("enterRoom",({room:i})=>{r.logger("enterRoom",{_room:i,isSuccessProgressCall:M}),R=i,p(R)?g&&g():S&&S({isSuccessProgressCall:M})}):()=>{}),v=i=>(r.logger("onSuccess"),M=!0,y(),m&&m({isPurgatory:p(R)}),e.onceRaceSession(["ended","failed"],()=>{b(),E&&E()}),i),O=i=>{throw r.logger("onFail"),T&&T(),b(),i},A=()=>{r.logger("onFinish"),f&&f()};return r.logger("onBeforeProgressCall"),d&&d(s),h().then(v).catch(i=>O(i)).finally(A)},P=e=>{if(!H.isCanceledError(e)&&!Y.hasCanceledError(e))throw e;return{isSuccessful:!1}},te=e=>async n=>{const{userAgent:s,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,name:l,password:d,isRegisteredUser:m,isDisconnectOnFail:g}=n;return r.logger("connectToServer",n),e.connect({userAgent:s,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,password:d,user:l,register:m}).then(S=>(r.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(r.logger("connectToServer catch: error",S),g===!0?e.disconnect().then(()=>P(S)).catch(()=>P(S)):P(S)))},re=e=>async()=>(r.logger("disconnectFromServer"),e.disconnect().then(()=>(r.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(t=>(r.logger("disconnectFromServer: catch",t),{isSuccessful:!1}))),w=e=>{const{url:t,cause:n}=e;let s=t;return(n===r.BAD_MEDIA_DESCRIPTION||n===r.NOT_FOUND)&&(s=`${e.message.to.uri.user}@${e.message.to.uri.host}`),s};var $=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))($||{});const se=(e=new Error)=>{var o;const{cause:t,socket:n}=e;let s="CONNECT_SERVER_FAILED";switch(t){case"Forbidden":{s="WRONG_USER_OR_PASSWORD";break}case r.BAD_MEDIA_DESCRIPTION:{s="BAD_MEDIA_ERROR";break}case r.NOT_FOUND:{s="NOT_FOUND_ERROR";break}default:n&&((o=n==null?void 0:n._ws)==null?void 0:o.readyState)===3?s="WS_CONNECTION_FAILED":w(e)&&(s="CONNECT_SERVER_FAILED_BY_LINK")}return s},oe=e=>{let t="";try{t=JSON.stringify(e)}catch(n){r.logger("failed to stringify message",n)}return t},ce=(e=new Error)=>{const{code:t,cause:n,message:s}=e,o=w(e),c={code:"",cause:"",message:""};return typeof s=="object"&&s!==null?c.message=oe(s):s&&(c.message=String(s)),o&&(c.link=o),t&&(c.code=t),n&&(c.cause=n),c},ae=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:$,getLinkError:w,getTypeFromError:se,getValuesFromError:ce},Symbol.toStringTag,{value:"Module"})),ie=({sessionId:e,remoteAddress:t,isMutedAudio:n,isMutedVideo:s,isRegistered:o,isPresentationCall:c})=>{const a=[],u=n?"0":"1",l=s?"0":"1";return a.push(`X-Vinteo-Mic-State: ${u}`,`X-Vinteo-MainCam-State: ${l}`),o||a.push("X-Vinteo-Purgatory-Call: yes"),e&&a.push(`X-Vinteo-Session: ${e}`),c&&a.push("X-Vinteo-Presentation-Call: yes"),t&&a.push(`X-Vinteo-Remote: ${t}`),a},ue="[@*!|]",le="_",ge=e=>{let t=e;return t=t.replaceAll(new RegExp(ue,"g"),le),t},Se=({appName:e,appVersion:t,browserName:n,browserVersion:s})=>{const c=`${ge(e)} ${t}`;return`ChromeNew - ${n?`${n} ${s}, ${c}`:c}`},de=({isUnifiedSdpSemantic:e,appVersion:t,browserName:n,browserVersion:s,appName:o})=>e?Se({appVersion:t,browserName:n,browserVersion:s,appName:o}):"Chrome",me=e=>async()=>{if(e.isCallActive)return r.logger("askPermissionToEnableCam"),e.askPermissionToEnableCam()},fe=e=>n=>(r.logger("onMustStopPresentation"),e.onSession("mustStopPresentation",n)),Ce=e=>n=>(r.logger("onMoveToSpectators"),e.onSession("participant:move-request-to-spectators",n)),Ee=e=>n=>(r.logger("onUseLicense"),e.onSession("useLicense",n)),Me=e=>async({isEnabledCam:n,isEnabledMic:s})=>{if(e.isCallActive)return r.logger("sendMediaState"),e.sendMediaState({cam:n,mic:s})},Re=e=>async()=>{if(e.isCallActive)return r.logger("sendRefusalToTurnOnCam"),e.sendRefusalToTurnOnCam().catch(n=>{r.logger("sendRefusalToTurnOnCam: error",n)})},Te=e=>async()=>{if(e.isCallActive)return r.logger("sendRefusalToTurnOnMic"),e.sendRefusalToTurnOnMic().catch(n=>{r.logger("sendRefusalToTurnOnMic: error",n)})},ye=1e6,be=({maxBitrate:e=ye,sipConnector:t})=>async({mediaStream:s,isP2P:o=!1},c)=>(r.logger("startPresentation"),t.startPresentation(s,{isP2P:o,maxBitrate:e},c)),_e=({sipConnector:e})=>async({isP2P:n=!1}={})=>(r.logger("stopShareSipConnector"),e.stopPresentation({isP2P:n}).catch(s=>{r.logger(s)})),he=1e6,ve=({sipConnector:e,maxBitrate:t=he})=>async({mediaStream:s,isP2P:o=!1})=>(r.logger("updatePresentation"),e.updatePresentation(s,{isP2P:o,maxBitrate:t})),Oe=e=>t=>[...t].map(s=>async()=>e(s)),Ae=async({accumulatedKeys:e,sendKey:t,canRunTask:n})=>{const o=Oe(t)(e);return z.sequentPromises(o,n)},pe=e=>n=>(r.logger("onStartMainCam"),e.onSession("admin-start-main-cam",n)),Ne=e=>n=>(r.logger("onStartMic"),e.onSession("admin-start-mic",n)),Pe=e=>n=>(r.logger("onStopMainCam"),e.onSession("admin-stop-main-cam",n)),Be=e=>n=>(r.logger("onStopMic"),e.onSession("admin-stop-mic",n)),Ie=({sipConnector:e})=>{const t=(f,E)=>({isSyncForced:y=!1})=>{if(y){f();return}E()},n=pe(e),s=Pe(e),o=Ne(e),c=Be(e);let a=()=>{},u=()=>{},l=()=>{},d=()=>{};const m=({onStartMainCamForced:f,onStartMainCamNotForced:E,onStopMainCamForced:y,onStopMainCamNotForced:_,onStartMicForced:h,onStartMicNotForced:M,onStopMicForced:R,onStopMicNotForced:N})=>{const b=t(f,E);a=n(b);const v=t(y,_);u=s(v);const O=t(h,M);l=o(O);const A=t(R,N);d=c(A)},g=()=>{a(),u(),l(),d()};return{start:f=>{m(f)},stop:()=>{g()}}},De=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:L,createSyncMediaState:Ie,error:ae,getExtraHeaders:ie,getUserAgent:de,hasPurgatory:p,resolveAnswerIncomingCall:ee,resolveAskPermissionToEnableCam:me,resolveCallToServer:ne,resolveConnectToServer:te,resolveDisconnectFromServer:re,resolveGetRemoteStreams:I,resolveOnMoveToSpectators:Ce,resolveOnMustStopPresentation:fe,resolveOnUseLicense:Ee,resolveSendMediaState:Me,resolveSendRefusalToTurnOnCam:Re,resolveSendRefusalToTurnOnMic:Te,resolveStartPresentation:be,resolveStopShareSipConnector:_e,resolveUpdatePresentation:ve,resolveUpdateRemoteStreams:D,sendDTMFAccumulated:Ae},Symbol.toStringTag,{value:"Module"})),we=e=>[...e.keys()].map(t=>e.get(t)),Fe=(e,t)=>we(e).find(n=>n.type===t),x=async e=>e.getStats().then(t=>{const n=Fe(t,"codec");return n==null?void 0:n.mimeType}),ke=e=>e.find(t=>{var n;return((n=t==null?void 0:t.track)==null?void 0:n.kind)==="video"}),q=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase().includes(t.toLowerCase()),Ue=1e6,C=e=>e*Ue,G=C(.06),Le=C(4),Ve=e=>e<=64?G:e<=128?C(.12):e<=256?C(.25):e<=384?C(.32):e<=426?C(.38):e<=640?C(.5):e<=848?C(.7):e<=1280?C(1):e<=1920?C(2):Le,$e="av1",xe=e=>q(e,$e),qe=.6,X=(e,t)=>xe(t)?e*qe:e,Ge=e=>X(G,e),W=(e,t)=>{const n=Ve(e);return X(n,t)},j=J.createStackPromises(),Xe=async()=>j().catch(e=>{r.logger("videoSendingBalancer: error",e)}),We=async e=>(j.add(e),Xe()),F=async({sender:e,scaleResolutionDownBy:t,maxBitrate:n,onSetParameters:s})=>We(async()=>r.setEncodingsToSender(e,{scaleResolutionDownBy:t,maxBitrate:n},s)),je=async({sender:e,codec:t},n)=>{const o=Ge(t);return F({sender:e,maxBitrate:o,onSetParameters:n,scaleResolutionDownBy:200})},B=async({sender:e,track:t,codec:n},s)=>{const a=t.getSettings().width,u=W(a,n);return F({sender:e,maxBitrate:u,onSetParameters:s,scaleResolutionDownBy:1})},Ke=async({sender:e,track:t,resolution:n,codec:s},o)=>{const c=t.getSettings(),a=c.width,u=c.height,[l,d]=n.split("x"),m=a/Number(l),g=u/Number(d),T=Math.max(m,g,1),f=W(Number(l),s);return F({sender:e,maxBitrate:f,onSetParameters:o,scaleResolutionDownBy:T})},He=async({mainCam:e,resolutionMainCam:t,sender:n,track:s,codec:o},c)=>{switch(e){case r.EEventsMainCAM.PAUSE_MAIN_CAM:return je({sender:n,codec:o},c);case r.EEventsMainCAM.RESUME_MAIN_CAM:return B({sender:n,track:s,codec:o},c);case r.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return t!==void 0?Ke({sender:n,track:s,codec:o,resolution:t},c):B({sender:n,track:s,codec:o},c);default:return B({sender:n,track:s,codec:o},c)}},k={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},U=async({mainCam:e,resolutionMainCam:t,connection:n,onSetParameters:s,ignoreForCodec:o})=>{const c=n.getSenders(),a=ke(c);if(!(a!=null&&a.track))return k;const u=await x(a);return q(u,o)?k:He({mainCam:e,resolutionMainCam:t,sender:a,codec:u,track:a.track},s)},Ye=(e,{ignoreForCodec:t,onSetParameters:n}={})=>{const s=async()=>{const{connection:l}=e;if(!l)throw new Error("connection is not exist");return U({connection:l,onSetParameters:n,ignoreForCodec:t})};let o=s;const c=async l=>(o=async()=>{const{mainCam:d,resolutionMainCam:m}=l,{connection:g}=e;if(!g)throw new Error("connection is not exist");return U({mainCam:d,resolutionMainCam:m,connection:g,onSetParameters:n,ignoreForCodec:t})},o());return{subscribe:()=>{e.onSession("main-cam-control",c)},unsubscribe:()=>{e.offSession("main-cam-control",c)},balanceByTrack:s,resetMainCamControl(){o=s},async reBalance(){return o()}}};exports.EEventsMainCAM=r.EEventsMainCAM;exports.EEventsMic=r.EEventsMic;exports.EEventsSyncMediaState=r.EEventsSyncMediaState;exports.EUseLicense=r.EUseLicense;exports.causes=r.causes;exports.constants=r.constants;exports.default=r.SipConnector;exports.disableDebug=r.disableDebug;exports.enableDebug=r.enableDebug;exports.eventNames=r.eventNames;exports.hasCanceledCallError=r.hasCanceledCallError;exports.debug=Q;exports.getCodecFromSender=x;exports.resolveVideoSendingBalancer=Ye;exports.tools=De;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./SipConnector-Dg0Vq0lq.cjs"),K=require("ts-debounce"),H=require("@krivega/cancelable-promise"),Y=require("repeated-calls"),z=require("sequent-promises"),J=require("stack-promises"),Q=require("debug"),L="purgatory",p=e=>e===L,I=e=>()=>(r.logger("getRemoteStreams"),e.getRemoteStreams()),Z=({kind:e,readyState:t})=>e==="video"&&t==="live",V=e=>({track:t})=>{Z(t)&&e()},D=({getRemoteStreams:e,setRemoteStreams:t})=>K.debounce(()=>{const n=e();r.logger("remoteStreams",n),n&&t(n)},200),ee=e=>async n=>{const{mediaStream:s,extraHeaders:o,iceServers:c,degradationPreference:a,setRemoteStreams:u,onBeforeProgressCall:l,onSuccessProgressCall:d,onEnterPurgatory:m,onEnterConference:g,onFailProgressCall:S,onFinishProgressCall:T,onEndedCall:f}=n,E=D({setRemoteStreams:u,getRemoteStreams:I(e)}),y=V(E);r.logger("answerIncomingCall",n);const _=async()=>e.answerToIncomingCall({mediaStream:s,extraHeaders:o,iceServers:c,degradationPreference:a,ontrack:y}),h=()=>{const{remoteCallerData:i}=e;return i.incomingNumber};let M=!1,R;const b=(r.logger("subscribeEnterConference: onEnterConference",g),m??g?e.onSession("enterRoom",i=>{r.logger("enterRoom",{_room:i,isSuccessProgressCall:M}),R=i,p(R)?m&&m():g&&g({isSuccessProgressCall:M})}):()=>{}),v=i=>(r.logger("onSuccess"),M=!0,E(),d&&d({isPurgatory:p(R)}),e.onceRaceSession(["ended","failed"],()=>{b(),f&&f()}),i),O=i=>{throw r.logger("onFail"),S&&S(),b(),i},A=()=>{r.logger("onFinish"),T&&T()};if(r.logger("onBeforeProgressCall"),l){const i=h();l(i)}return _().then(v).catch(i=>O(i)).finally(A)},ne=e=>async n=>{const{conference:s,mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,setRemoteStreams:l,onBeforeProgressCall:d,onSuccessProgressCall:m,onEnterPurgatory:g,onEnterConference:S,onFailProgressCall:T,onFinishProgressCall:f,onEndedCall:E}=n,y=D({setRemoteStreams:l,getRemoteStreams:I(e)}),_=V(y);r.logger("callToServer",n);const h=async()=>(r.logger("startCall"),e.call({mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,number:s,ontrack:_}));let M=!1,R;const b=(r.logger("subscribeEnterConference: onEnterConference",S),g??S?e.onSession("enterRoom",({room:i})=>{r.logger("enterRoom",{_room:i,isSuccessProgressCall:M}),R=i,p(R)?g&&g():S&&S({isSuccessProgressCall:M})}):()=>{}),v=i=>(r.logger("onSuccess"),M=!0,y(),m&&m({isPurgatory:p(R)}),e.onceRaceSession(["ended","failed"],()=>{b(),E&&E()}),i),O=i=>{throw r.logger("onFail"),T&&T(),b(),i},A=()=>{r.logger("onFinish"),f&&f()};return r.logger("onBeforeProgressCall"),d&&d(s),h().then(v).catch(i=>O(i)).finally(A)},P=e=>{if(!H.isCanceledError(e)&&!Y.hasCanceledError(e))throw e;return{isSuccessful:!1}},te=e=>async n=>{const{userAgent:s,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,name:l,password:d,isRegisteredUser:m,isDisconnectOnFail:g}=n;return r.logger("connectToServer",n),e.connect({userAgent:s,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,password:d,user:l,register:m}).then(S=>(r.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(r.logger("connectToServer catch: error",S),g===!0?e.disconnect().then(()=>P(S)).catch(()=>P(S)):P(S)))},re=e=>async()=>(r.logger("disconnectFromServer"),e.disconnect().then(()=>(r.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(t=>(r.logger("disconnectFromServer: catch",t),{isSuccessful:!1}))),w=e=>{const{url:t,cause:n}=e;let s=t;return(n===r.BAD_MEDIA_DESCRIPTION||n===r.NOT_FOUND)&&(s=`${e.message.to.uri.user}@${e.message.to.uri.host}`),s};var $=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))($||{});const se=(e=new Error)=>{var o;const{cause:t,socket:n}=e;let s="CONNECT_SERVER_FAILED";switch(t){case"Forbidden":{s="WRONG_USER_OR_PASSWORD";break}case r.BAD_MEDIA_DESCRIPTION:{s="BAD_MEDIA_ERROR";break}case r.NOT_FOUND:{s="NOT_FOUND_ERROR";break}default:n&&((o=n==null?void 0:n._ws)==null?void 0:o.readyState)===3?s="WS_CONNECTION_FAILED":w(e)&&(s="CONNECT_SERVER_FAILED_BY_LINK")}return s},oe=e=>{let t="";try{t=JSON.stringify(e)}catch(n){r.logger("failed to stringify message",n)}return t},ce=(e=new Error)=>{const{code:t,cause:n,message:s}=e,o=w(e),c={code:"",cause:"",message:""};return typeof s=="object"&&s!==null?c.message=oe(s):s&&(c.message=String(s)),o&&(c.link=o),t&&(c.code=t),n&&(c.cause=n),c},ae=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:$,getLinkError:w,getTypeFromError:se,getValuesFromError:ce},Symbol.toStringTag,{value:"Module"})),ie=({sessionId:e,remoteAddress:t,isMutedAudio:n,isMutedVideo:s,isRegistered:o,isPresentationCall:c})=>{const a=[],u=n?"0":"1",l=s?"0":"1";return a.push(`X-Vinteo-Mic-State: ${u}`,`X-Vinteo-MainCam-State: ${l}`),o||a.push("X-Vinteo-Purgatory-Call: yes"),e&&a.push(`X-Vinteo-Session: ${e}`),c&&a.push("X-Vinteo-Presentation-Call: yes"),t&&a.push(`X-Vinteo-Remote: ${t}`),a},ue="[@*!|]",le="_",ge=e=>{let t=e;return t=t.replaceAll(new RegExp(ue,"g"),le),t},Se=({appName:e,appVersion:t,browserName:n,browserVersion:s})=>{const c=`${ge(e)} ${t}`;return`ChromeNew - ${n?`${n} ${s}, ${c}`:c}`},de=({isUnifiedSdpSemantic:e,appVersion:t,browserName:n,browserVersion:s,appName:o})=>e?Se({appVersion:t,browserName:n,browserVersion:s,appName:o}):"Chrome",me=e=>async()=>{if(e.isCallActive)return r.logger("askPermissionToEnableCam"),e.askPermissionToEnableCam()},fe=e=>n=>(r.logger("onMustStopPresentation"),e.onSession("mustStopPresentation",n)),Ce=e=>n=>(r.logger("onMoveToSpectators"),e.onSession("participant:move-request-to-spectators",n)),Ee=e=>n=>(r.logger("onUseLicense"),e.onSession("useLicense",n)),Me=e=>async({isEnabledCam:n,isEnabledMic:s})=>{if(e.isCallActive)return r.logger("sendMediaState"),e.sendMediaState({cam:n,mic:s})},Re=e=>async()=>{if(e.isCallActive)return r.logger("sendRefusalToTurnOnCam"),e.sendRefusalToTurnOnCam().catch(n=>{r.logger("sendRefusalToTurnOnCam: error",n)})},Te=e=>async()=>{if(e.isCallActive)return r.logger("sendRefusalToTurnOnMic"),e.sendRefusalToTurnOnMic().catch(n=>{r.logger("sendRefusalToTurnOnMic: error",n)})},ye=1e6,be=({maxBitrate:e=ye,sipConnector:t})=>async({mediaStream:s,isP2P:o=!1},c)=>(r.logger("startPresentation"),t.startPresentation(s,{isP2P:o,maxBitrate:e},c)),_e=({sipConnector:e})=>async({isP2P:n=!1}={})=>(r.logger("stopShareSipConnector"),e.stopPresentation({isP2P:n}).catch(s=>{r.logger(s)})),he=1e6,ve=({sipConnector:e,maxBitrate:t=he})=>async({mediaStream:s,isP2P:o=!1})=>(r.logger("updatePresentation"),e.updatePresentation(s,{isP2P:o,maxBitrate:t})),Oe=e=>t=>[...t].map(s=>async()=>e(s)),Ae=async({accumulatedKeys:e,sendKey:t,canRunTask:n})=>{const o=Oe(t)(e);return z.sequentPromises(o,n)},pe=e=>n=>(r.logger("onStartMainCam"),e.onSession("admin-start-main-cam",n)),Ne=e=>n=>(r.logger("onStartMic"),e.onSession("admin-start-mic",n)),Pe=e=>n=>(r.logger("onStopMainCam"),e.onSession("admin-stop-main-cam",n)),Be=e=>n=>(r.logger("onStopMic"),e.onSession("admin-stop-mic",n)),Ie=({sipConnector:e})=>{const t=(f,E)=>({isSyncForced:y=!1})=>{if(y){f();return}E()},n=pe(e),s=Pe(e),o=Ne(e),c=Be(e);let a=()=>{},u=()=>{},l=()=>{},d=()=>{};const m=({onStartMainCamForced:f,onStartMainCamNotForced:E,onStopMainCamForced:y,onStopMainCamNotForced:_,onStartMicForced:h,onStartMicNotForced:M,onStopMicForced:R,onStopMicNotForced:N})=>{const b=t(f,E);a=n(b);const v=t(y,_);u=s(v);const O=t(h,M);l=o(O);const A=t(R,N);d=c(A)},g=()=>{a(),u(),l(),d()};return{start:f=>{m(f)},stop:()=>{g()}}},De=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:L,createSyncMediaState:Ie,error:ae,getExtraHeaders:ie,getUserAgent:de,hasPurgatory:p,resolveAnswerIncomingCall:ee,resolveAskPermissionToEnableCam:me,resolveCallToServer:ne,resolveConnectToServer:te,resolveDisconnectFromServer:re,resolveGetRemoteStreams:I,resolveOnMoveToSpectators:Ce,resolveOnMustStopPresentation:fe,resolveOnUseLicense:Ee,resolveSendMediaState:Me,resolveSendRefusalToTurnOnCam:Re,resolveSendRefusalToTurnOnMic:Te,resolveStartPresentation:be,resolveStopShareSipConnector:_e,resolveUpdatePresentation:ve,resolveUpdateRemoteStreams:D,sendDTMFAccumulated:Ae},Symbol.toStringTag,{value:"Module"})),we=e=>[...e.keys()].map(t=>e.get(t)),Fe=(e,t)=>we(e).find(n=>n.type===t),x=async e=>e.getStats().then(t=>{const n=Fe(t,"codec");return n==null?void 0:n.mimeType}),ke=e=>e.find(t=>{var n;return((n=t==null?void 0:t.track)==null?void 0:n.kind)==="video"}),q=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase().includes(t.toLowerCase()),Ue=1e6,C=e=>e*Ue,G=C(.06),Le=C(4),Ve=e=>e<=64?G:e<=128?C(.12):e<=256?C(.25):e<=384?C(.32):e<=426?C(.38):e<=640?C(.5):e<=848?C(.7):e<=1280?C(1):e<=1920?C(2):Le,$e="av1",xe=e=>q(e,$e),qe=.6,X=(e,t)=>xe(t)?e*qe:e,Ge=e=>X(G,e),W=(e,t)=>{const n=Ve(e);return X(n,t)},j=J.createStackPromises(),Xe=async()=>j().catch(e=>{r.logger("videoSendingBalancer: error",e)}),We=async e=>(j.add(e),Xe()),F=async({sender:e,scaleResolutionDownBy:t,maxBitrate:n,onSetParameters:s})=>We(async()=>r.setEncodingsToSender(e,{scaleResolutionDownBy:t,maxBitrate:n},s)),je=async({sender:e,codec:t},n)=>{const o=Ge(t);return F({sender:e,maxBitrate:o,onSetParameters:n,scaleResolutionDownBy:200})},B=async({sender:e,track:t,codec:n},s)=>{const a=t.getSettings().width,u=W(a,n);return F({sender:e,maxBitrate:u,onSetParameters:s,scaleResolutionDownBy:1})},Ke=async({sender:e,track:t,resolution:n,codec:s},o)=>{const c=t.getSettings(),a=c.width,u=c.height,[l,d]=n.split("x"),m=a/Number(l),g=u/Number(d),T=Math.max(m,g,1),f=W(Number(l),s);return F({sender:e,maxBitrate:f,onSetParameters:o,scaleResolutionDownBy:T})},He=async({mainCam:e,resolutionMainCam:t,sender:n,track:s,codec:o},c)=>{switch(e){case r.EEventsMainCAM.PAUSE_MAIN_CAM:return je({sender:n,codec:o},c);case r.EEventsMainCAM.RESUME_MAIN_CAM:return B({sender:n,track:s,codec:o},c);case r.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return t!==void 0?Ke({sender:n,track:s,codec:o,resolution:t},c):B({sender:n,track:s,codec:o},c);default:return B({sender:n,track:s,codec:o},c)}},k={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},U=async({mainCam:e,resolutionMainCam:t,connection:n,onSetParameters:s,ignoreForCodec:o})=>{const c=n.getSenders(),a=ke(c);if(!(a!=null&&a.track))return k;const u=await x(a);return q(u,o)?k:He({mainCam:e,resolutionMainCam:t,sender:a,codec:u,track:a.track},s)},Ye=(e,{ignoreForCodec:t,onSetParameters:n}={})=>{const s=async()=>{const{connection:l}=e;if(!l)throw new Error("connection is not exist");return U({connection:l,onSetParameters:n,ignoreForCodec:t})};let o=s;const c=async l=>(o=async()=>{const{mainCam:d,resolutionMainCam:m}=l,{connection:g}=e;if(!g)throw new Error("connection is not exist");return U({mainCam:d,resolutionMainCam:m,connection:g,onSetParameters:n,ignoreForCodec:t})},o());return{subscribe:()=>{e.onSession("main-cam-control",c)},unsubscribe:()=>{e.offSession("main-cam-control",c)},balanceByTrack:s,resetMainCamControl(){o=s},async reBalance(){return o()}}};exports.EEventsMainCAM=r.EEventsMainCAM;exports.EEventsMic=r.EEventsMic;exports.EEventsSyncMediaState=r.EEventsSyncMediaState;exports.EUseLicense=r.EUseLicense;exports.causes=r.causes;exports.constants=r.constants;exports.default=r.SipConnector;exports.disableDebug=r.disableDebug;exports.enableDebug=r.enableDebug;exports.eventNames=r.eventNames;exports.hasCanceledCallError=r.hasCanceledCallError;exports.debug=Q;exports.getCodecFromSender=x;exports.resolveVideoSendingBalancer=Ye;exports.tools=De;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { l as o, B as V, N as x, E as B, s as q, S as Qe } from "./SipConnector-C5s0hhzA.js";
2
- import { f as un, g as ln, i as Sn, c as mn, a as dn, d as fn, b as Cn, e as gn, h as Rn } from "./SipConnector-C5s0hhzA.js";
1
+ import { l as o, B as V, N as x, E as B, s as q, S as Qe } from "./SipConnector-CpJaoOHN.js";
2
+ import { f as un, g as ln, i as Sn, c as mn, a as dn, d as fn, b as Cn, e as gn, h as Rn } from "./SipConnector-CpJaoOHN.js";
3
3
  import { debounce as z } from "ts-debounce";
4
4
  import { isCanceledError as J } from "@krivega/cancelable-promise";
5
5
  import { hasCanceledError as Q } from "repeated-calls";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "8.2.0",
3
+ "version": "8.2.1",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",