sip-connector 7.0.5 → 7.0.7

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.
@@ -1,173 +1,174 @@
1
1
  var At = Object.defineProperty;
2
2
  var Rt = (r, e, t) => e in r ? At(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => (Rt(r, typeof e != "symbol" ? e + "" : e, t), t);
3
+ var i = (r, e, t) => Rt(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { CancelableRequest as N, isCanceledError as It } from "@krivega/cancelable-promise";
5
5
  import Oe from "events-constructor";
6
- import F from "debug";
7
- const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code", Ot = "Internal Error", Pt = "Busy", Le = "Rejected", Mt = "Redirected", pt = "Unavailable", Dt = "Not Found", vt = "Address Incomplete", wt = "Incompatible SDP", yt = "Missing SDP", bt = "Authentication Error", He = "Terminated", Ut = "WebRTC Error", ke = "Canceled", Lt = "No Answer", Ht = "Expires", kt = "No ACK", qt = "Dialog Error", Wt = "User Denied Media Access", Ft = "Bad Media Description", Bt = "RTP Timeout", Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6
+ import { repeatedCallsAsync as mt } from "repeated-calls";
7
+ import B from "debug";
8
+ const ft = "Connection Error", Ue = "Request Timeout", pt = "SIP Failure Code", Ot = "Internal Error", Pt = "Busy", Le = "Rejected", Dt = "Redirected", Mt = "Unavailable", vt = "Not Found", yt = "Address Incomplete", bt = "Incompatible SDP", wt = "Missing SDP", Ut = "Authentication Error", He = "Terminated", Lt = "WebRTC Error", We = "Canceled", Ht = "No Answer", Wt = "Expires", kt = "No ACK", qt = "Dialog Error", Ft = "User Denied Media Access", Bt = "Bad Media Description", Vt = "RTP Timeout", tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8
9
  __proto__: null,
9
- ADDRESS_INCOMPLETE: vt,
10
- AUTHENTICATION_ERROR: bt,
11
- BAD_MEDIA_DESCRIPTION: Ft,
10
+ ADDRESS_INCOMPLETE: yt,
11
+ AUTHENTICATION_ERROR: Ut,
12
+ BAD_MEDIA_DESCRIPTION: Bt,
12
13
  BUSY: Pt,
13
14
  BYE: He,
14
- CANCELED: ke,
15
- CONNECTION_ERROR: mt,
15
+ CANCELED: We,
16
+ CONNECTION_ERROR: ft,
16
17
  DIALOG_ERROR: qt,
17
- EXPIRES: Ht,
18
- INCOMPATIBLE_SDP: wt,
18
+ EXPIRES: Wt,
19
+ INCOMPATIBLE_SDP: bt,
19
20
  INTERNAL_ERROR: Ot,
20
- MISSING_SDP: yt,
21
- NOT_FOUND: Dt,
21
+ MISSING_SDP: wt,
22
+ NOT_FOUND: vt,
22
23
  NO_ACK: kt,
23
- NO_ANSWER: Lt,
24
- REDIRECTED: Mt,
24
+ NO_ANSWER: Ht,
25
+ REDIRECTED: Dt,
25
26
  REJECTED: Le,
26
27
  REQUEST_TIMEOUT: Ue,
27
- RTP_TIMEOUT: Bt,
28
- SIP_FAILURE_CODE: ft,
29
- UNAVAILABLE: pt,
30
- USER_DENIED_MEDIA_ACCESS: Wt,
31
- WEBRTC_ERROR: Ut
32
- }, Symbol.toStringTag, { value: "Module" })), B = "incomingCall", V = "declinedIncomingCall", Y = "failedIncomingCall", x = "terminatedIncomingCall", L = "connecting", m = "connected", u = "disconnected", p = "newRTCSession", f = "registered", $ = "unregistered", O = "registrationFailed", qe = "newMessage", G = "sipEvent", X = "availableSecondRemoteStream", J = "notAvailableSecondRemoteStream", z = "mustStopPresentation", D = "shareState", Q = "enterRoom", K = "useLicense", j = "peerconnection:confirmed", Z = "peerconnection:ontrack", v = "channels", ee = "channels:notify", te = "ended:fromserver", se = "main-cam-control", ne = "admin-stop-main-cam", ie = "admin-start-main-cam", re = "admin-stop-mic", oe = "admin-start-mic", w = "admin-force-sync-media-state", ae = "participant:added-to-list-moderators", ce = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", _e = "participant:move-request-to-spectators", he = "participation:accepting-word-request", de = "participation:cancelling-word-request", Te = "webcast:started", le = "webcast:stopped", ue = "account:changed", Se = "account:deleted", Ne = "conference:participant-token-issued", P = "ended", We = "sending", Fe = "reinvite", Be = "replaces", Ve = "refer", Ye = "progress", xe = "accepted", y = "confirmed", b = "peerconnection", C = "failed", $e = "muted", Ge = "unmuted", ge = "newDTMF", Ce = "newInfo", Xe = "hold", Je = "unhold", ze = "update", Qe = "sdp", Ke = "icecandidate", je = "getusermediafailed", Ze = "peerconnection:createofferfailed", et = "peerconnection:createanswerfailed", tt = "peerconnection:setlocaldescriptionfailed", st = "peerconnection:setremotedescriptionfailed", nt = "presentation:start", it = "presentation:started", rt = "presentation:end", Ae = "presentation:ended", U = "presentation:failed", ot = "SPECTATOR", zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
28
+ RTP_TIMEOUT: Vt,
29
+ SIP_FAILURE_CODE: pt,
30
+ UNAVAILABLE: Mt,
31
+ USER_DENIED_MEDIA_ACCESS: Ft,
32
+ WEBRTC_ERROR: Lt
33
+ }, Symbol.toStringTag, { value: "Module" })), V = "incomingCall", Y = "declinedIncomingCall", x = "failedIncomingCall", G = "terminatedIncomingCall", H = "connecting", f = "connected", u = "disconnected", M = "newRTCSession", p = "registered", $ = "unregistered", O = "registrationFailed", ke = "newMessage", X = "sipEvent", J = "availableSecondRemoteStream", z = "notAvailableSecondRemoteStream", Q = "mustStopPresentation", v = "shareState", j = "enterRoom", K = "useLicense", Z = "peerconnection:confirmed", ee = "peerconnection:ontrack", y = "channels", te = "channels:notify", se = "ended:fromserver", ne = "main-cam-control", ie = "admin-stop-main-cam", re = "admin-start-main-cam", oe = "admin-stop-mic", ae = "admin-start-mic", b = "admin-force-sync-media-state", ce = "participant:added-to-list-moderators", Ee = "participant:removed-from-list-moderators", _e = "participant:move-request-to-stream", he = "participant:move-request-to-spectators", de = "participation:accepting-word-request", le = "participation:cancelling-word-request", Te = "webcast:started", Se = "webcast:stopped", ue = "account:changed", Ne = "account:deleted", Ce = "conference:participant-token-issued", P = "ended", qe = "sending", Fe = "reinvite", Be = "replaces", Ve = "refer", Ye = "progress", xe = "accepted", w = "confirmed", U = "peerconnection", g = "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", st = "peerconnection:setremotedescriptionfailed", nt = "presentation:start", it = "presentation:started", rt = "presentation:end", Re = "presentation:ended", L = "presentation:failed", ot = "SPECTATOR", sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
33
34
  __proto__: null,
34
35
  ACCEPTED: xe,
35
36
  ACCOUNT_CHANGED: ue,
36
- ACCOUNT_DELETED: Se,
37
- ADMIN_FORCE_SYNC_MEDIA_STATE: w,
38
- ADMIN_START_MAIN_CAM: ie,
39
- ADMIN_START_MIC: oe,
40
- ADMIN_STOP_MAIN_CAM: ne,
41
- ADMIN_STOP_MIC: re,
42
- AVAILABLE_SECOND_REMOTE_STREAM_EVENT: X,
43
- CHANNELS: v,
44
- CHANNELS_NOTIFY: ee,
45
- CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Ne,
46
- CONFIRMED: y,
47
- CONNECTED: m,
48
- CONNECTING: L,
49
- DECLINED_INCOMING_CALL: V,
37
+ ACCOUNT_DELETED: Ne,
38
+ ADMIN_FORCE_SYNC_MEDIA_STATE: b,
39
+ ADMIN_START_MAIN_CAM: re,
40
+ ADMIN_START_MIC: ae,
41
+ ADMIN_STOP_MAIN_CAM: ie,
42
+ ADMIN_STOP_MIC: oe,
43
+ AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
44
+ CHANNELS: y,
45
+ CHANNELS_NOTIFY: te,
46
+ CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Ce,
47
+ CONFIRMED: w,
48
+ CONNECTED: f,
49
+ CONNECTING: H,
50
+ DECLINED_INCOMING_CALL: Y,
50
51
  DISCONNECTED: u,
51
52
  ENDED: P,
52
- ENDED_FROM_SERVER: te,
53
- ENTER_ROOM: Q,
54
- FAILED: C,
55
- FAILED_INCOMING_CALL: Y,
56
- GET_USER_MEDIA_FAILED: je,
53
+ ENDED_FROM_SERVER: se,
54
+ ENTER_ROOM: j,
55
+ FAILED: g,
56
+ FAILED_INCOMING_CALL: x,
57
+ GET_USER_MEDIA_FAILED: Ke,
57
58
  HOLD: Xe,
58
- ICE_CANDIDATE: Ke,
59
- INCOMING_CALL: B,
60
- MAIN_CAM_CONTROL: se,
61
- MUST_STOP_PRESENTATION_EVENT: z,
62
- MUTED: $e,
59
+ ICE_CANDIDATE: je,
60
+ INCOMING_CALL: V,
61
+ MAIN_CAM_CONTROL: ne,
62
+ MUST_STOP_PRESENTATION_EVENT: Q,
63
+ MUTED: Ge,
63
64
  NEW_DTMF: ge,
64
- NEW_INFO: Ce,
65
- NEW_MESSAGE: qe,
66
- NEW_RTC_SESSION: p,
67
- NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
68
- PARTICIPANT_ADDED_TO_LIST_MODERATORS: ae,
69
- PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: _e,
70
- PARTICIPANT_MOVE_REQUEST_TO_STREAM: Ee,
71
- PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: ce,
72
- PARTICIPATION_ACCEPTING_WORD_REQUEST: he,
73
- PARTICIPATION_CANCELLING_WORD_REQUEST: de,
74
- PEER_CONNECTION: b,
75
- PEER_CONNECTION_CONFIRMED: j,
65
+ NEW_INFO: Ae,
66
+ NEW_MESSAGE: ke,
67
+ NEW_RTC_SESSION: M,
68
+ NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: z,
69
+ PARTICIPANT_ADDED_TO_LIST_MODERATORS: ce,
70
+ PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: he,
71
+ PARTICIPANT_MOVE_REQUEST_TO_STREAM: _e,
72
+ PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: Ee,
73
+ PARTICIPATION_ACCEPTING_WORD_REQUEST: de,
74
+ PARTICIPATION_CANCELLING_WORD_REQUEST: le,
75
+ PEER_CONNECTION: U,
76
+ PEER_CONNECTION_CONFIRMED: Z,
76
77
  PEER_CONNECTION_CREATE_ANSWER_FAILED: et,
77
78
  PEER_CONNECTION_CREATE_OFFER_FAILED: Ze,
78
- PEER_CONNECTION_ONTRACK: Z,
79
+ PEER_CONNECTION_ONTRACK: ee,
79
80
  PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: tt,
80
81
  PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: st,
81
82
  PRESENTATION_END: rt,
82
- PRESENTATION_ENDED: Ae,
83
- PRESENTATION_FAILED: U,
83
+ PRESENTATION_ENDED: Re,
84
+ PRESENTATION_FAILED: L,
84
85
  PRESENTATION_START: nt,
85
86
  PRESENTATION_STARTED: it,
86
87
  PROGRESS: Ye,
87
88
  REFER: Ve,
88
- REGISTERED: f,
89
+ REGISTERED: p,
89
90
  REGISTRATION_FAILED: O,
90
91
  REINVITE: Fe,
91
92
  REPLACES: Be,
92
93
  SDP: Qe,
93
- SENDING: We,
94
- SHARE_STATE: D,
95
- SIP_EVENT: G,
94
+ SENDING: qe,
95
+ SHARE_STATE: v,
96
+ SIP_EVENT: X,
96
97
  SPECTATOR: ot,
97
- TERMINATED_INCOMING_CALL: x,
98
+ TERMINATED_INCOMING_CALL: G,
98
99
  UNHOLD: Je,
99
- UNMUTED: Ge,
100
+ UNMUTED: $e,
100
101
  UNREGISTERED: $,
101
102
  UPDATE: ze,
102
103
  USE_LICENSE: K,
103
104
  WEBCAST_STARTED: Te,
104
- WEBCAST_STOPPED: le
105
+ WEBCAST_STOPPED: Se
105
106
  }, Symbol.toStringTag, { value: "Module" })), at = [
106
- B,
107
107
  V,
108
- x,
109
108
  Y,
110
- he,
109
+ G,
110
+ x,
111
111
  de,
112
- Ee,
113
- ee,
114
- Ne,
112
+ le,
113
+ _e,
114
+ te,
115
+ Ce,
115
116
  ue,
116
- Se,
117
+ Ne,
117
118
  Te,
118
- le,
119
- ae,
120
- ce
121
- ], Re = [
122
- L,
123
- m,
119
+ Se,
120
+ ce,
121
+ Ee
122
+ ], Ie = [
123
+ H,
124
+ f,
124
125
  u,
126
+ M,
125
127
  p,
126
- f,
127
128
  $,
128
129
  O,
129
- qe,
130
- G
130
+ ke,
131
+ X
131
132
  ], ct = [
132
- X,
133
133
  J,
134
134
  z,
135
- D,
136
135
  Q,
137
- K,
136
+ v,
138
137
  j,
138
+ K,
139
139
  Z,
140
- v,
141
- te,
140
+ ee,
141
+ y,
142
142
  se,
143
- ie,
144
143
  ne,
145
144
  re,
145
+ ie,
146
146
  oe,
147
- w,
148
- _e
149
- ], Ie = [
147
+ ae,
148
+ b,
149
+ he
150
+ ], me = [
150
151
  P,
151
- L,
152
- We,
152
+ H,
153
+ qe,
153
154
  Fe,
154
155
  Be,
155
156
  Ve,
156
157
  Ye,
157
158
  xe,
158
- y,
159
- b,
160
- C,
161
- $e,
159
+ w,
160
+ U,
161
+ g,
162
162
  Ge,
163
+ $e,
163
164
  ge,
164
- Ce,
165
+ Ae,
165
166
  Xe,
166
167
  Je,
167
168
  ze,
168
169
  Qe,
169
- Ke,
170
170
  je,
171
+ Ke,
171
172
  Ze,
172
173
  et,
173
174
  tt,
@@ -175,32 +176,32 @@ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code",
175
176
  nt,
176
177
  it,
177
178
  rt,
178
- Ae,
179
- U
180
- ], Et = [...Re, ...at], _t = [
181
- ...Ie,
179
+ Re,
180
+ L
181
+ ], Et = [...Ie, ...at], _t = [
182
+ ...me,
182
183
  ...ct
183
- ], Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
184
+ ], nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
184
185
  __proto__: null,
185
186
  SESSION_EVENT_NAMES: _t,
186
- SESSION_JSSIP_EVENT_NAMES: Ie,
187
+ SESSION_JSSIP_EVENT_NAMES: me,
187
188
  SESSION_SYNTHETICS_EVENT_NAMES: ct,
188
189
  UA_EVENT_NAMES: Et,
189
- UA_JSSIP_EVENT_NAMES: Re,
190
+ UA_JSSIP_EVENT_NAMES: Ie,
190
191
  UA_SYNTHETICS_EVENT_NAMES: at
191
- }, Symbol.toStringTag, { value: "Module" })), Vt = (r) => {
192
+ }, Symbol.toStringTag, { value: "Module" })), Yt = (r) => {
192
193
  const e = [];
193
194
  return r && e.push(`X-Vinteo-Remote: ${r}`), e;
194
- }, Yt = "content-type", xt = "x-webrtc-enter-room", M = "application/vinteo.webrtc.sharedesktop", $t = "application/vinteo.webrtc.roomname", Gt = "application/vinteo.webrtc.channels", Xt = "application/vinteo.webrtc.mediastate", Jt = "application/vinteo.webrtc.refusal", Pe = "application/vinteo.webrtc.maincam", zt = "application/vinteo.webrtc.mic", Qt = "application/vinteo.webrtc.uselic", Kt = "X-WEBRTC-USE-LICENSE", jt = "X-WEBRTC-PARTICIPANT-NAME", Me = "X-WEBRTC-INPUT-CHANNELS", pe = "X-WEBRTC-OUTPUT-CHANNELS", Zt = "X-WEBRTC-MAINCAM", es = "X-WEBRTC-MIC", De = "X-WEBRTC-SYNC", ts = "X-WEBRTC-MAINCAM-RESOLUTION", ss = "X-WEBRTC-MEDIA-STATE", ns = "X-Vinteo-Media-Type", is = "X-Vinteo-MainCam-State", rs = "X-Vinteo-Mic-State", os = "application/vinteo.webrtc.partstate", as = "X-WEBRTC-PARTSTATE", cs = "application/vinteo.webrtc.notify", Es = "X-VINTEO-NOTIFY", A = "x-webrtc-share-state", _s = `${A}: LETMESTARTPRESENTATION`, hs = `${A}: STOPPRESENTATION`, ht = "YOUCANRECEIVECONTENT", dt = "CONTENTEND", Tt = "YOUMUSTSTOPSENDCONTENT", ds = `${A}: ${Tt}`, Ts = `${A}: ${ht}`, ls = `${A}: ${dt}`, us = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Ss = `${us}: LETMESTARTMAINCAM`, me = "sip-connector", ve = F(me), Ks = () => {
195
- F.enable(me);
196
- }, js = () => {
197
- F.enable(`-${me}`);
195
+ }, xt = "content-type", Gt = "x-webrtc-enter-room", D = "application/vinteo.webrtc.sharedesktop", $t = "application/vinteo.webrtc.roomname", Xt = "application/vinteo.webrtc.channels", Jt = "application/vinteo.webrtc.mediastate", zt = "application/vinteo.webrtc.refusal", Pe = "application/vinteo.webrtc.maincam", Qt = "application/vinteo.webrtc.mic", jt = "application/vinteo.webrtc.uselic", Kt = "X-WEBRTC-USE-LICENSE", Zt = "X-WEBRTC-PARTICIPANT-NAME", De = "X-WEBRTC-INPUT-CHANNELS", Me = "X-WEBRTC-OUTPUT-CHANNELS", es = "X-WEBRTC-MAINCAM", ts = "X-WEBRTC-MIC", ve = "X-WEBRTC-SYNC", ss = "X-WEBRTC-MAINCAM-RESOLUTION", ns = "X-WEBRTC-MEDIA-STATE", is = "X-Vinteo-Media-Type", rs = "X-Vinteo-MainCam-State", os = "X-Vinteo-Mic-State", as = "application/vinteo.webrtc.partstate", cs = "X-WEBRTC-PARTSTATE", Es = "application/vinteo.webrtc.notify", _s = "X-VINTEO-NOTIFY", A = "x-webrtc-share-state", hs = `${A}: LETMESTARTPRESENTATION`, ds = `${A}: STOPPRESENTATION`, ht = "YOUCANRECEIVECONTENT", dt = "CONTENTEND", lt = "YOUMUSTSTOPSENDCONTENT", ls = `${A}: ${lt}`, Ts = `${A}: ${ht}`, Ss = `${A}: ${dt}`, us = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Ns = `${us}: LETMESTARTMAINCAM`, fe = "sip-connector", ye = B(fe), rn = () => {
196
+ B.enable(fe);
197
+ }, on = () => {
198
+ B.enable(`-${fe}`);
198
199
  };
199
- 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 || {}), Ns = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(Ns || {});
200
- function we(r) {
200
+ var m = /* @__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))(m || {}), 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 || {}), Cs = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(Cs || {});
201
+ function gs(r) {
201
202
  return (e) => `sip:${e}@${r}`;
202
203
  }
203
- const gs = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, ye = (r) => r.trim().replaceAll(" ", "_"), Cs = gs(1e5, 99999999), H = (r, {
204
+ const As = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) => r.trim().replaceAll(" ", "_"), Rs = As(1e5, 99999999), W = (r, {
204
205
  videoMode: e,
205
206
  audioMode: t
206
207
  } = {}) => {
@@ -208,41 +209,41 @@ const gs = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, ye = (r) =>
208
209
  return;
209
210
  const s = t === "recvonly" ? [] : r.getAudioTracks(), n = e === "recvonly" ? [] : r.getVideoTracks(), o = [...s, ...n], a = new MediaStream(o);
210
211
  return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], a;
211
- }, As = (r) => r.some((t) => {
212
+ }, Is = (r) => r.some((t) => {
212
213
  const { kind: s } = t;
213
214
  return s === "video";
214
- }), Rs = "Error decline with 603", Is = (r) => r.message === Rs, ms = (r, e) => r.find((t) => t.track && e.getTracks().includes(t.track)), lt = 1, ut = (r) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== r, fs = ut(
215
- lt
216
- ), Os = (r, e) => {
217
- const t = r === void 0 ? void 0 : Math.max(r, lt);
218
- if (t !== void 0 && fs(
215
+ }), ms = "Error decline with 603", fs = 1006, ps = (r) => typeof r == "object" && r !== null && "code" in r && r.code === fs, Os = (r) => Array.isArray(r) && r.some((e) => ps(e)), Ps = (r) => r.message === ms, Ds = (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, Ms = St(
216
+ Tt
217
+ ), vs = (r, e) => {
218
+ const t = r === void 0 ? void 0 : Math.max(r, Tt);
219
+ if (t !== void 0 && Ms(
219
220
  t,
220
221
  e
221
222
  ))
222
223
  return t;
223
- }, Ps = ut(), Ms = (r, e) => {
224
- if (Ps(r, e))
224
+ }, ys = St(), bs = (r, e) => {
225
+ if (ys(r, e))
225
226
  return r;
226
- }, ps = async (r, e, t) => {
227
+ }, ws = async (r, e, t) => {
227
228
  const s = r.getParameters();
228
229
  (s.encodings === void 0 || s.encodings.length === 0) && (s.encodings = [{}]);
229
- const [n] = s.encodings, o = n.scaleResolutionDownBy, a = Os(
230
+ const [n] = s.encodings, o = n.scaleResolutionDownBy, a = vs(
230
231
  e.scaleResolutionDownBy,
231
232
  o
232
233
  );
233
234
  let c = !1;
234
235
  a !== void 0 && (s.encodings[0].scaleResolutionDownBy = a, c = !0);
235
- const E = n.maxBitrate, _ = Ms(e.maxBitrate, E);
236
- return _ !== void 0 && (s.encodings[0].maxBitrate = _, c = !0), c ? (t && t(s), r.setParameters(s).then(() => ({ parameters: s, isChanged: c }))) : { parameters: s, isChanged: c };
237
- }, Ds = async (r, e, t) => {
238
- const s = ms(r, e);
236
+ const _ = n.maxBitrate, E = bs(e.maxBitrate, _);
237
+ return E !== void 0 && (s.encodings[0].maxBitrate = E, c = !0), c ? (t && t(s), r.setParameters(s).then(() => ({ parameters: s, isChanged: c }))) : { parameters: s, isChanged: c };
238
+ }, Us = async (r, e, t) => {
239
+ const s = Ds(r, e);
239
240
  if (s)
240
- return ps(s, { maxBitrate: t });
241
- }, vs = 486, ws = 487, W = "local", be = "remote", Zs = (r = new Error()) => {
241
+ return ws(s, { maxBitrate: t });
242
+ }, Ls = 486, Hs = 487, F = "local", we = "remote", Ws = 3, an = (r = new Error()) => {
242
243
  const { originator: e, cause: t } = r;
243
- return It(r) ? !0 : typeof t == "string" ? t === Ue || t === Le || e === W && (t === ke || t === He) : !1;
244
- }, g = "SipConnector", ys = "channels", bs = "WebcastStarted", Us = "WebcastStopped", Ls = "accountChanged", Hs = "accountDeleted", ks = "addedToListModerators", qs = "removedFromListModerators", Ws = "ParticipationRequestAccepted", Fs = "ParticipationRequestRejected", Bs = "ParticipantMovedToWebcast", Vs = "ConferenceParticipantTokenIssued";
245
- class en {
244
+ return It(r) ? !0 : typeof t == "string" ? t === Ue || t === Le || e === F && (t === We || t === He) : !1;
245
+ }, C = "SipConnector", ks = "channels", qs = "WebcastStarted", Fs = "WebcastStopped", Bs = "accountChanged", Vs = "accountDeleted", Ys = "addedToListModerators", xs = "removedFromListModerators", Gs = "ParticipationRequestAccepted", $s = "ParticipationRequestRejected", Xs = "ParticipantMovedToWebcast", Js = "ConferenceParticipantTokenIssued";
246
+ class cn {
246
247
  constructor({ JsSIP: e }) {
247
248
  i(this, "_isRegisterConfig", !1);
248
249
  i(this, "_connectionConfiguration", {});
@@ -251,6 +252,7 @@ class en {
251
252
  i(this, "_sessionEvents");
252
253
  i(this, "_uaEvents");
253
254
  i(this, "_cancelableConnect");
255
+ i(this, "_cancelableConnectWithRepeatedCalls");
254
256
  i(this, "_cancelableInitUa");
255
257
  i(this, "_cancelableDisconnect");
256
258
  i(this, "_cancelableSet");
@@ -265,7 +267,7 @@ class en {
265
267
  i(this, "incomingSession");
266
268
  i(this, "_streamPresentationCurrent");
267
269
  i(this, "socket");
268
- i(this, "connect", async (e) => (this._cancelRequests(), this._cancelableConnect.request(e)));
270
+ i(this, "connect", async (e, t) => (this._cancelRequests(), this._connectWithDuplicatedCalls(e, t)));
269
271
  i(this, "initUa", async (e) => this._cancelableInitUa.request(e));
270
272
  i(this, "set", async (e) => this._cancelableSet.request(e));
271
273
  i(this, "call", async (e) => this._cancelableCall.request(e));
@@ -276,33 +278,54 @@ class en {
276
278
  i(this, "tryRegister", async () => {
277
279
  if (!this.isRegisterConfig)
278
280
  throw new Error("Config is not registered");
279
- this._uaEvents.trigger(L, void 0);
281
+ this._uaEvents.trigger(H, void 0);
280
282
  try {
281
283
  await this.unregister();
282
284
  } catch (e) {
283
- ve("tryRegister", e);
285
+ ye("tryRegister", e);
284
286
  }
285
287
  return this.register();
286
288
  });
287
- i(this, "declineToIncomingCall", async ({ statusCode: e = ws } = {}) => new Promise((t, s) => {
289
+ i(this, "declineToIncomingCall", async ({ statusCode: e = Hs } = {}) => new Promise((t, s) => {
288
290
  if (!this.isAvailableIncomingCall) {
289
291
  s(new Error("no incomingSession"));
290
292
  return;
291
293
  }
292
294
  const n = this.incomingSession, o = this.remoteCallerData;
293
- this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(V, o), t(n.terminate({ status_code: e }));
295
+ this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(Y, o), t(n.terminate({ status_code: e }));
294
296
  }));
295
- i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: vs }));
297
+ i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: Ls }));
296
298
  i(this, "removeIncomingSession", () => {
297
299
  delete this.incomingSession;
298
300
  });
301
+ i(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t = Ws } = {}) => {
302
+ let s = !0;
303
+ const n = async () => (s = !1, this._cancelableConnect.request(e)), o = (a) => {
304
+ var h;
305
+ const c = !!((h = this.ua) != null && h.isConnected()), _ = !s && c && this.hasEqualConnectionConfiguration(e), E = !!a && !Os(a);
306
+ return _ || E;
307
+ };
308
+ return this._cancelableConnectWithRepeatedCalls = mt({
309
+ targetFunction: n,
310
+ isComplete: o,
311
+ callLimit: t,
312
+ isRejectAsValid: !0,
313
+ onAfterCancel: () => {
314
+ this._cancelableConnect.cancelRequest();
315
+ }
316
+ }), this._cancelableConnectWithRepeatedCalls.then((a) => {
317
+ if (a instanceof this.JsSIP.UA)
318
+ return a;
319
+ throw a;
320
+ });
321
+ });
299
322
  i(this, "handleNewRTCSession", ({ originator: e, session: t }) => {
300
- if (e === be) {
323
+ if (e === we) {
301
324
  this.incomingSession = t;
302
325
  const s = this.remoteCallerData;
303
- t.on(C, (n) => {
304
- this.removeIncomingSession(), n.originator === W ? this._uaEvents.trigger(x, s) : this._uaEvents.trigger(Y, s);
305
- }), this._uaEvents.trigger(B, s);
326
+ t.on(g, (n) => {
327
+ this.removeIncomingSession(), n.originator === F ? this._uaEvents.trigger(G, s) : this._uaEvents.trigger(x, s);
328
+ }), this._uaEvents.trigger(V, s);
306
329
  }
307
330
  });
308
331
  i(this, "_connect", async (e) => this.initUa(e).then(async () => this._start()));
@@ -314,8 +337,8 @@ class en {
314
337
  remoteAddress: o,
315
338
  sdpSemantics: a,
316
339
  sessionTimers: c,
317
- registerExpires: E,
318
- connectionRecoveryMinInterval: _,
340
+ registerExpires: _,
341
+ connectionRecoveryMinInterval: E,
319
342
  connectionRecoveryMaxInterval: h,
320
343
  userAgent: l,
321
344
  displayName: d = "",
@@ -336,60 +359,29 @@ class en {
336
359
  register: T,
337
360
  user: e,
338
361
  password: t
339
- }, this.getSipServerUrl = we(s), this.socket = new this.JsSIP.WebSocketInterface(n), this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!T;
340
- const { socket: R } = this;
341
- this.ua = this._createUa({
362
+ };
363
+ const { configuration: R, helpers: I } = this.createUaConfiguration({
342
364
  user: e,
365
+ sipServerUrl: s,
366
+ sipWebSocketServerURL: n,
343
367
  password: t,
344
- socket: R,
345
368
  displayName: d,
346
369
  register: T,
347
370
  sdpSemantics: a,
348
371
  sessionTimers: c,
349
- registerExpires: E,
350
- connectionRecoveryMinInterval: _,
372
+ registerExpires: _,
373
+ connectionRecoveryMinInterval: E,
351
374
  connectionRecoveryMaxInterval: h,
352
- userAgent: l,
353
- getSipServerUrl: this.getSipServerUrl
354
- }), this._uaEvents.eachTriggers((Nt, gt) => {
355
- const fe = Re.find((Ct) => Ct === gt);
356
- fe && this.ua && this.ua.on(fe, Nt);
375
+ userAgent: l
357
376
  });
358
- const St = [...Vt(o), ...S];
359
- return this.ua.registrator().setExtraHeaders(St), this.ua;
360
- });
361
- i(this, "_createUa", ({
362
- user: e,
363
- password: t,
364
- socket: s,
365
- displayName: n,
366
- getSipServerUrl: o,
367
- register: a = !1,
368
- sdpSemantics: c = "plan-b",
369
- sessionTimers: E = !1,
370
- registerExpires: _ = 60 * 5,
371
- // 5 minutes in sec
372
- connectionRecoveryMinInterval: h = 2,
373
- connectionRecoveryMaxInterval: l = 6,
374
- userAgent: d
375
- }) => {
376
- if (a && !t)
377
- throw new Error("password is required for authorized connection");
378
- const T = a && e ? e.trim() : `${Cs()}`, S = o(T), R = {
379
- password: t,
380
- register: a,
381
- uri: S,
382
- display_name: ye(n),
383
- user_agent: d,
384
- sdp_semantics: c,
385
- sockets: [s],
386
- session_timers: E,
387
- register_expires: _,
388
- connection_recovery_min_interval: h,
389
- connection_recovery_max_interval: l
390
- };
391
- return new this.JsSIP.UA(R);
377
+ this.getSipServerUrl = I.getSipServerUrl, this.socket = I.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!T, this.ua = this._createUa(R), this._uaEvents.eachTriggers((Nt, Ct) => {
378
+ const pe = Ie.find((gt) => gt === Ct);
379
+ pe && this.ua && this.ua.on(pe, Nt);
380
+ });
381
+ const ut = [...Yt(o), ...S];
382
+ return this.ua.registrator().setExtraHeaders(ut), this.ua;
392
383
  });
384
+ i(this, "_createUa", (e) => new this.JsSIP.UA(e));
393
385
  i(this, "_start", async () => new Promise((e, t) => {
394
386
  const { ua: s } = this;
395
387
  if (!s) {
@@ -398,14 +390,14 @@ class en {
398
390
  }
399
391
  const n = () => {
400
392
  c(), e(s);
401
- }, o = (E) => {
402
- c(), t(E);
393
+ }, o = (_) => {
394
+ c(), t(_);
403
395
  }, a = () => {
404
- this.isRegisterConfig ? (this.on(f, n), this.on(O, o)) : this.on(m, n), this.on(u, o);
396
+ this.isRegisterConfig ? (this.on(p, n), this.on(O, o)) : this.on(f, n), this.on(u, o);
405
397
  }, c = () => {
406
- this.off(f, n), this.off(O, o), this.off(m, n), this.off(u, o);
398
+ this.off(p, n), this.off(O, o), this.off(f, n), this.off(u, o);
407
399
  };
408
- a(), this.on(p, this.handleNewRTCSession), s.start();
400
+ a(), this.on(M, this.handleNewRTCSession), s.start();
409
401
  }));
410
402
  i(this, "_set", async ({ displayName: e, password: t }) => new Promise((s, n) => {
411
403
  const { ua: o } = this;
@@ -414,17 +406,17 @@ class en {
414
406
  return;
415
407
  }
416
408
  let a = !1, c = !1;
417
- e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name", ye(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
418
- const E = a || c;
409
+ e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name", be(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
410
+ const _ = a || c;
419
411
  c && this.isRegisterConfig ? this.register().then(() => {
420
- s(E);
421
- }).catch((_) => {
422
- n(_);
423
- }) : E ? s(E) : n(new Error("nothing changed"));
412
+ s(_);
413
+ }).catch((E) => {
414
+ n(E);
415
+ }) : _ ? s(_) : n(new Error("nothing changed"));
424
416
  }));
425
417
  i(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
426
418
  i(this, "_disconnect", async () => {
427
- this.off(p, this.handleNewRTCSession);
419
+ this.off(M, this.handleNewRTCSession);
428
420
  const e = new Promise((t) => {
429
421
  this.once(u, () => {
430
422
  delete this.ua, t();
@@ -440,8 +432,8 @@ class en {
440
432
  iceServers: o,
441
433
  videoMode: a,
442
434
  audioMode: c,
443
- degradationPreference: E,
444
- offerToReceiveAudio: _ = !0,
435
+ degradationPreference: _,
436
+ offerToReceiveAudio: E = !0,
445
437
  offerToReceiveVideo: h = !0
446
438
  }) => new Promise((l, d) => {
447
439
  const { ua: T } = this;
@@ -453,19 +445,19 @@ class en {
453
445
  d(S);
454
446
  }), this.session = T.call(this.getSipServerUrl(e), {
455
447
  extraHeaders: s,
456
- mediaStream: H(t, {
448
+ mediaStream: W(t, {
457
449
  videoMode: a,
458
450
  audioMode: c
459
451
  }),
460
452
  eventHandlers: this._sessionEvents.triggers,
461
453
  videoMode: a,
462
454
  audioMode: c,
463
- degradationPreference: E,
455
+ degradationPreference: _,
464
456
  pcConfig: {
465
457
  iceServers: o
466
458
  },
467
459
  rtcOfferConstraints: {
468
- offerToReceiveAudio: _,
460
+ offerToReceiveAudio: E,
469
461
  offerToReceiveVideo: h
470
462
  }
471
463
  });
@@ -478,24 +470,24 @@ class en {
478
470
  videoMode: o,
479
471
  audioMode: a,
480
472
  degradationPreference: c
481
- }) => new Promise((E, _) => {
473
+ }) => new Promise((_, E) => {
482
474
  if (!this.isAvailableIncomingCall) {
483
- _(new Error("no incomingSession"));
475
+ E(new Error("no incomingSession"));
484
476
  return;
485
477
  }
486
478
  this.session = this.incomingSession, this.removeIncomingSession();
487
479
  const { session: h } = this;
488
480
  if (!h) {
489
- _(new Error("No session established"));
481
+ E(new Error("No session established"));
490
482
  return;
491
483
  }
492
484
  this._sessionEvents.eachTriggers((d, T) => {
493
- const S = Ie.find((R) => R === T);
485
+ const S = me.find((R) => R === T);
494
486
  S && h.on(S, d);
495
- }), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(E).catch((d) => {
496
- _(d);
487
+ }), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(_).catch((d) => {
488
+ E(d);
497
489
  });
498
- const l = H(e, {
490
+ const l = W(e, {
499
491
  videoMode: o,
500
492
  audioMode: a
501
493
  });
@@ -512,23 +504,23 @@ class en {
512
504
  }));
513
505
  i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, s) => {
514
506
  const n = () => {
515
- this.onSession(b, h), this.onSession(y, l);
507
+ this.onSession(U, h), this.onSession(w, l);
516
508
  }, o = () => {
517
- this.offSession(b, h), this.offSession(y, l);
509
+ this.offSession(U, h), this.offSession(w, l);
518
510
  }, a = () => {
519
- this.onSession(C, E), this.onSession(P, E);
511
+ this.onSession(g, _), this.onSession(P, _);
520
512
  }, c = () => {
521
- this.offSession(C, E), this.offSession(P, E);
522
- }, E = (d) => {
513
+ this.offSession(g, _), this.offSession(P, _);
514
+ }, _ = (d) => {
523
515
  o(), c(), s(d);
524
516
  };
525
- let _;
517
+ let E;
526
518
  const h = ({ peerconnection: d }) => {
527
- _ = d, _.ontrack = (T) => {
528
- this._sessionEvents.trigger(Z, _), e && e(T);
519
+ E = d, E.ontrack = (T) => {
520
+ this._sessionEvents.trigger(ee, E), e && e(T);
529
521
  };
530
522
  }, l = () => {
531
- _ && this._sessionEvents.trigger(j, _), o(), c(), t(_);
523
+ E && this._sessionEvents.trigger(Z, E), o(), c(), t(E);
532
524
  };
533
525
  n(), a();
534
526
  }));
@@ -542,7 +534,7 @@ class en {
542
534
  return;
543
535
  }
544
536
  this.onceSession(ge, ({ originator: o }) => {
545
- o === W && t();
537
+ o === F && t();
546
538
  }), n.sendDTMF(e, {
547
539
  duration: 120,
548
540
  interToneGap: 600
@@ -558,86 +550,86 @@ class en {
558
550
  i(this, "_handleShareState", (e) => {
559
551
  switch (e) {
560
552
  case ht: {
561
- this._sessionEvents.trigger(X, void 0);
553
+ this._sessionEvents.trigger(J, void 0);
562
554
  break;
563
555
  }
564
556
  case dt: {
565
- this._sessionEvents.trigger(J, void 0);
557
+ this._sessionEvents.trigger(z, void 0);
566
558
  break;
567
559
  }
568
- case Tt: {
569
- this._sessionEvents.trigger(z, void 0);
560
+ case lt: {
561
+ this._sessionEvents.trigger(Q, void 0);
570
562
  break;
571
563
  }
572
564
  }
573
565
  });
574
566
  i(this, "_maybeTriggerChannels", (e) => {
575
- const t = e.getHeader(Me), s = e.getHeader(pe);
567
+ const t = e.getHeader(De), s = e.getHeader(Me);
576
568
  if (t && s) {
577
569
  const n = {
578
570
  inputChannels: t,
579
571
  outputChannels: s
580
572
  };
581
- this._sessionEvents.trigger(v, n);
573
+ this._sessionEvents.trigger(y, n);
582
574
  }
583
575
  });
584
576
  i(this, "_handleNotify", (e) => {
585
577
  switch (e.cmd) {
586
- case ys: {
578
+ case ks: {
587
579
  const t = e;
588
580
  this._triggerChannelsNotify(t);
589
581
  break;
590
582
  }
591
- case bs: {
583
+ case qs: {
592
584
  const t = e;
593
585
  this._triggerWebcastStartedNotify(t);
594
586
  break;
595
587
  }
596
- case Us: {
588
+ case Fs: {
597
589
  const t = e;
598
590
  this._triggerWebcastStoppedNotify(t);
599
591
  break;
600
592
  }
601
- case ks: {
593
+ case Ys: {
602
594
  const t = e;
603
595
  this._triggerAddedToListModeratorsNotify(t);
604
596
  break;
605
597
  }
606
- case qs: {
598
+ case xs: {
607
599
  const t = e;
608
600
  this._triggerRemovedFromListModeratorsNotify(t);
609
601
  break;
610
602
  }
611
- case Ws: {
603
+ case Gs: {
612
604
  const t = e;
613
605
  this._triggerParticipationAcceptingWordRequest(t);
614
606
  break;
615
607
  }
616
- case Fs: {
608
+ case $s: {
617
609
  const t = e;
618
610
  this._triggerParticipationCancellingWordRequest(t);
619
611
  break;
620
612
  }
621
- case Bs: {
613
+ case Xs: {
622
614
  const t = e;
623
615
  this._triggerParticipantMoveRequestToStream(t);
624
616
  break;
625
617
  }
626
- case Ls: {
618
+ case Bs: {
627
619
  this._triggerAccountChangedNotify();
628
620
  break;
629
621
  }
630
- case Hs: {
622
+ case Vs: {
631
623
  this._triggerAccountDeletedNotify();
632
624
  break;
633
625
  }
634
- case Vs: {
626
+ case Js: {
635
627
  const t = e;
636
628
  this._triggerConferenceParticipantTokenIssued(t);
637
629
  break;
638
630
  }
639
631
  default:
640
- ve("unknown cmd", e.cmd);
632
+ ye("unknown cmd", e.cmd);
641
633
  }
642
634
  });
643
635
  i(this, "_triggerRemovedFromListModeratorsNotify", ({
@@ -647,7 +639,7 @@ class en {
647
639
  conference: e
648
640
  };
649
641
  this._uaEvents.trigger(
650
- ce,
642
+ Ee,
651
643
  t
652
644
  );
653
645
  });
@@ -655,7 +647,7 @@ class en {
655
647
  const t = {
656
648
  conference: e
657
649
  };
658
- this._uaEvents.trigger(ae, t);
650
+ this._uaEvents.trigger(ce, t);
659
651
  });
660
652
  i(this, "_triggerWebcastStartedNotify", ({ body: { conference: e, type: t } }) => {
661
653
  const s = {
@@ -669,13 +661,13 @@ class en {
669
661
  conference: e,
670
662
  type: t
671
663
  };
672
- this._uaEvents.trigger(le, s);
664
+ this._uaEvents.trigger(Se, s);
673
665
  });
674
666
  i(this, "_triggerAccountChangedNotify", () => {
675
667
  this._uaEvents.trigger(ue, void 0);
676
668
  });
677
669
  i(this, "_triggerAccountDeletedNotify", () => {
678
- this._uaEvents.trigger(Se, void 0);
670
+ this._uaEvents.trigger(Ne, void 0);
679
671
  });
680
672
  i(this, "_triggerConferenceParticipantTokenIssued", ({
681
673
  body: { conference: e, participant: t, jwt: s }
@@ -686,7 +678,7 @@ class en {
686
678
  jwt: s
687
679
  };
688
680
  this._uaEvents.trigger(
689
- Ne,
681
+ Ce,
690
682
  n
691
683
  );
692
684
  });
@@ -695,7 +687,7 @@ class en {
695
687
  inputChannels: t,
696
688
  outputChannels: s
697
689
  };
698
- this._uaEvents.trigger(ee, n);
690
+ this._uaEvents.trigger(te, n);
699
691
  });
700
692
  i(this, "_triggerParticipationAcceptingWordRequest", ({
701
693
  body: { conference: e }
@@ -703,7 +695,7 @@ class en {
703
695
  const t = {
704
696
  conference: e
705
697
  };
706
- this._uaEvents.trigger(he, t);
698
+ this._uaEvents.trigger(de, t);
707
699
  });
708
700
  i(this, "_triggerParticipationCancellingWordRequest", ({
709
701
  body: { conference: e }
@@ -711,7 +703,7 @@ class en {
711
703
  const t = {
712
704
  conference: e
713
705
  };
714
- this._uaEvents.trigger(de, t);
706
+ this._uaEvents.trigger(le, t);
715
707
  });
716
708
  i(this, "_triggerParticipantMoveRequestToStream", ({
717
709
  body: { conference: e }
@@ -719,39 +711,39 @@ class en {
719
711
  const t = {
720
712
  conference: e
721
713
  };
722
- this._uaEvents.trigger(Ee, t);
714
+ this._uaEvents.trigger(_e, t);
723
715
  });
724
716
  i(this, "_triggerEnterRoom", (e) => {
725
- const t = e.getHeader(xt), s = e.getHeader(jt);
726
- this._sessionEvents.trigger(Q, { room: t, participantName: s });
717
+ const t = e.getHeader(Gt), s = e.getHeader(Zt);
718
+ this._sessionEvents.trigger(j, { room: t, participantName: s });
727
719
  });
728
720
  i(this, "_triggerShareState", (e) => {
729
721
  const t = e.getHeader(A);
730
- this._sessionEvents.trigger(D, t);
722
+ this._sessionEvents.trigger(v, t);
731
723
  });
732
724
  i(this, "_maybeTriggerParticipantMoveRequestToSpectators", (e) => {
733
- e.getHeader(as) === ot && this._sessionEvents.trigger(_e, void 0);
725
+ e.getHeader(cs) === ot && this._sessionEvents.trigger(he, void 0);
734
726
  });
735
727
  i(this, "_triggerMainCamControl", (e) => {
736
- const t = e.getHeader(Zt), s = e.getHeader(De), n = s === q.ADMIN_SYNC_FORCED;
737
- if (t === I.ADMIN_START_MAIN_CAM) {
738
- this._sessionEvents.trigger(ie, { isSyncForced: n });
728
+ const t = e.getHeader(es), s = e.getHeader(ve), n = s === q.ADMIN_SYNC_FORCED;
729
+ if (t === m.ADMIN_START_MAIN_CAM) {
730
+ this._sessionEvents.trigger(re, { isSyncForced: n });
739
731
  return;
740
732
  }
741
- if (t === I.ADMIN_STOP_MAIN_CAM) {
742
- this._sessionEvents.trigger(ne, { isSyncForced: n });
733
+ if (t === m.ADMIN_STOP_MAIN_CAM) {
734
+ this._sessionEvents.trigger(ie, { isSyncForced: n });
743
735
  return;
744
736
  }
745
- (t === I.RESUME_MAIN_CAM || t === I.PAUSE_MAIN_CAM) && s && this._sessionEvents.trigger(w, { isSyncForced: n });
746
- const o = e.getHeader(ts);
747
- this._sessionEvents.trigger(se, {
737
+ (t === m.RESUME_MAIN_CAM || t === m.PAUSE_MAIN_CAM) && s && this._sessionEvents.trigger(b, { isSyncForced: n });
738
+ const o = e.getHeader(ss);
739
+ this._sessionEvents.trigger(ne, {
748
740
  mainCam: t,
749
741
  resolutionMainCam: o
750
742
  });
751
743
  });
752
744
  i(this, "_triggerMicControl", (e) => {
753
- const t = e.getHeader(es), n = e.getHeader(De) === q.ADMIN_SYNC_FORCED;
754
- t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(oe, { isSyncForced: n }) : t === k.ADMIN_STOP_MIC && this._sessionEvents.trigger(re, { isSyncForced: n });
745
+ const t = e.getHeader(ts), n = e.getHeader(ve) === q.ADMIN_SYNC_FORCED;
746
+ t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(ae, { isSyncForced: n }) : t === k.ADMIN_STOP_MIC && this._sessionEvents.trigger(oe, { isSyncForced: n });
755
747
  });
756
748
  i(this, "_triggerUseLicense", (e) => {
757
749
  const t = e.getHeader(Kt);
@@ -761,18 +753,18 @@ class en {
761
753
  const { originator: t } = e;
762
754
  if (t !== "remote")
763
755
  return;
764
- const { request: s } = e, n = s.getHeader(Yt);
756
+ const { request: s } = e, n = s.getHeader(xt);
765
757
  if (n)
766
758
  switch (n) {
767
759
  case $t: {
768
760
  this._triggerEnterRoom(s), this._maybeTriggerChannels(s);
769
761
  break;
770
762
  }
771
- case cs: {
763
+ case Es: {
772
764
  this._maybeHandleNotify(s);
773
765
  break;
774
766
  }
775
- case M: {
767
+ case D: {
776
768
  this._triggerShareState(s);
777
769
  break;
778
770
  }
@@ -780,15 +772,15 @@ class en {
780
772
  this._triggerMainCamControl(s);
781
773
  break;
782
774
  }
783
- case zt: {
775
+ case Qt: {
784
776
  this._triggerMicControl(s);
785
777
  break;
786
778
  }
787
- case Qt: {
779
+ case jt: {
788
780
  this._triggerUseLicense(s);
789
781
  break;
790
782
  }
791
- case os: {
783
+ case as: {
792
784
  this._maybeTriggerParticipantMoveRequestToSpectators(s);
793
785
  break;
794
786
  }
@@ -798,7 +790,7 @@ class en {
798
790
  this._maybeHandleNotify(e);
799
791
  });
800
792
  i(this, "_maybeHandleNotify", (e) => {
801
- const t = e.getHeader(Es);
793
+ const t = e.getHeader(_s);
802
794
  if (t) {
803
795
  const s = JSON.parse(t);
804
796
  this._handleNotify(s);
@@ -806,32 +798,32 @@ class en {
806
798
  });
807
799
  i(this, "_handleEnded", (e) => {
808
800
  const { originator: t } = e;
809
- t === be && this._sessionEvents.trigger(te, e), this._restoreSession();
801
+ t === we && this._sessionEvents.trigger(se, e), this._restoreSession();
810
802
  });
811
803
  this.JsSIP = e, this._sessionEvents = new Oe(_t), this._uaEvents = new Oe(Et), this._cancelableConnect = new N(
812
804
  this._connect,
813
805
  {
814
- moduleName: g,
806
+ moduleName: C,
815
807
  afterCancelRequest: () => {
816
808
  this._cancelableInitUa.cancelRequest(), this._cancelableDisconnect.cancelRequest();
817
809
  }
818
810
  }
819
811
  ), this._cancelableInitUa = new N(
820
812
  this._initUa,
821
- { moduleName: g }
813
+ { moduleName: C }
822
814
  ), this._cancelableDisconnect = new N(
823
815
  this._disconnect,
824
- { moduleName: g }
816
+ { moduleName: C }
825
817
  ), this._cancelableSet = new N(this._set, {
826
- moduleName: g
818
+ moduleName: C
827
819
  }), this._cancelableCall = new N(
828
820
  this._call,
829
- { moduleName: g }
830
- ), this._cancelableAnswer = new N(this._answer, { moduleName: g }), this._cancelableSendDTMF = new N(this._sendDTMF, { moduleName: g }), this.onSession(D, this._handleShareState), this.onSession(Ce, this._handleNewInfo), this.on(G, this._handleSipEvent), this.onSession(C, this._handleEnded), this.onSession(P, this._handleEnded);
821
+ { moduleName: C }
822
+ ), this._cancelableAnswer = new N(this._answer, { moduleName: C }), this._cancelableSendDTMF = new N(this._sendDTMF, { moduleName: C }), this.onSession(v, this._handleShareState), this.onSession(Ae, this._handleNewInfo), this.on(X, this._handleSipEvent), this.onSession(g, this._handleEnded), this.onSession(P, this._handleEnded);
831
823
  }
832
824
  async register() {
833
825
  return new Promise((e, t) => {
834
- this.isRegisterConfig && this.ua ? (this.ua.on(f, e), this.ua.on(O, t), this.ua.register()) : t(new Error("Config is not registered"));
826
+ this.isRegisterConfig && this.ua ? (this.ua.on(p, e), this.ua.on(O, t), this.ua.register()) : t(new Error("Config is not registered"));
835
827
  });
836
828
  }
837
829
  async unregister() {
@@ -873,21 +865,21 @@ class en {
873
865
  sdpSemantics: o
874
866
  }) {
875
867
  return new Promise((a, c) => {
876
- const E = we(s), _ = new this.JsSIP.WebSocketInterface(n), h = this._createUa({
877
- socket: _,
868
+ const { configuration: _ } = this.createUaConfiguration({
869
+ sipWebSocketServerURL: n,
878
870
  displayName: t,
879
871
  sdpSemantics: o,
880
872
  userAgent: e,
881
- getSipServerUrl: E
882
- }), l = () => {
883
- const T = new Error("Telephony is not available");
884
- c(T);
873
+ sipServerUrl: s
874
+ }), E = this._createUa(_), h = () => {
875
+ const d = new Error("Telephony is not available");
876
+ c(d);
885
877
  };
886
- h.once(u, l);
887
- const d = () => {
888
- h.removeAllListeners(), h.once(u, a), h.stop();
878
+ E.once(u, h);
879
+ const l = () => {
880
+ E.removeAllListeners(), E.once(u, a), E.stop();
889
881
  };
890
- h.once(m, d), h.start();
882
+ E.once(f, l), E.start();
891
883
  });
892
884
  }
893
885
  async replaceMediaStream(e, t) {
@@ -898,29 +890,72 @@ class en {
898
890
  async askPermissionToEnableCam(e = {}) {
899
891
  if (!this.session)
900
892
  throw new Error("No session established");
901
- const t = [Ss];
893
+ const t = [Ns];
902
894
  return this.session.sendInfo(Pe, void 0, {
903
895
  noTerminateWhenError: !0,
904
896
  ...e,
905
897
  extraHeaders: t
906
898
  }).catch((s) => {
907
- if (Is(s))
899
+ if (Ps(s))
908
900
  throw s;
909
901
  });
910
902
  }
911
903
  get isPendingPresentation() {
912
904
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
913
905
  }
906
+ hasEqualConnectionConfiguration(e) {
907
+ var n;
908
+ const { configuration: t } = this.createUaConfiguration(e), s = (n = this.ua) == null ? void 0 : n.configuration;
909
+ return (s == null ? void 0 : s.password) === t.password && (s == null ? void 0 : s.register) === t.register && (s == null ? void 0 : s.uri.toString()) === t.uri && (s == null ? void 0 : s.display_name) === t.display_name && (s == null ? void 0 : s.user_agent) === t.user_agent && (s == null ? void 0 : s.sdpSemantics) === t.sdp_semantics && (s == null ? void 0 : s.sockets) === t.sockets && (s == null ? void 0 : s.session_timers) === t.session_timers && (s == null ? void 0 : s.register_expires) === t.register_expires && (s == null ? void 0 : s.connection_recovery_min_interval) === t.connection_recovery_min_interval && (s == null ? void 0 : s.connection_recovery_max_interval) === t.connection_recovery_max_interval;
910
+ }
911
+ createUaConfiguration({
912
+ user: e,
913
+ password: t,
914
+ sipWebSocketServerURL: s,
915
+ displayName: n = "",
916
+ sipServerUrl: o,
917
+ register: a = !1,
918
+ sdpSemantics: c = "plan-b",
919
+ sessionTimers: _ = !1,
920
+ registerExpires: E = 60 * 5,
921
+ // 5 minutes in sec
922
+ connectionRecoveryMinInterval: h = 2,
923
+ connectionRecoveryMaxInterval: l = 6,
924
+ userAgent: d
925
+ }) {
926
+ if (a && !t)
927
+ throw new Error("password is required for authorized connection");
928
+ const T = a && e ? e.trim() : `${Rs()}`, S = gs(o), R = S(T), I = new this.JsSIP.WebSocketInterface(s);
929
+ return {
930
+ configuration: {
931
+ password: t,
932
+ register: a,
933
+ uri: R,
934
+ display_name: be(n),
935
+ user_agent: d,
936
+ sdp_semantics: c,
937
+ sockets: [I],
938
+ session_timers: _,
939
+ register_expires: E,
940
+ connection_recovery_min_interval: h,
941
+ connection_recovery_max_interval: l
942
+ },
943
+ helpers: {
944
+ socket: I,
945
+ getSipServerUrl: S
946
+ }
947
+ };
948
+ }
914
949
  async _sendPresentation(e, t, {
915
950
  maxBitrate: s,
916
951
  degradationPreference: n,
917
952
  isNeedReinvite: o = !0,
918
953
  isP2P: a = !1
919
954
  }) {
920
- const c = H(t);
955
+ const c = W(t);
921
956
  this._streamPresentationCurrent = c;
922
- const E = a ? [Ts] : [_s], _ = e.sendInfo(M, void 0, {
923
- extraHeaders: E
957
+ const _ = a ? [Ts] : [hs], E = e.sendInfo(D, void 0, {
958
+ extraHeaders: _
924
959
  }).then(async () => e.startPresentation(
925
960
  c,
926
961
  o,
@@ -930,11 +965,11 @@ class en {
930
965
  if (!h || s === void 0)
931
966
  return;
932
967
  const l = h.getSenders();
933
- await Ds(l, t, s);
968
+ await Us(l, t, s);
934
969
  }).then(() => t).catch((h) => {
935
- throw this._sessionEvents.trigger(U, h), h;
970
+ throw this._sessionEvents.trigger(L, h), h;
936
971
  });
937
- return this.promisePendingStartPresentation = _, _.finally(() => {
972
+ return this.promisePendingStartPresentation = E, E.finally(() => {
938
973
  this.promisePendingStartPresentation = void 0;
939
974
  });
940
975
  }
@@ -957,8 +992,8 @@ class en {
957
992
  });
958
993
  }
959
994
  async sendMustStopPresentation(e) {
960
- await e.sendInfo(M, void 0, {
961
- extraHeaders: [ds]
995
+ await e.sendInfo(D, void 0, {
996
+ extraHeaders: [ls]
962
997
  });
963
998
  }
964
999
  async stopPresentation({
@@ -966,12 +1001,12 @@ class en {
966
1001
  } = {}) {
967
1002
  const t = this._streamPresentationCurrent;
968
1003
  let s = this.promisePendingStartPresentation ?? Promise.resolve();
969
- const n = e ? [ls] : [hs], o = this.establishedSession;
970
- return o && t && (s = s.then(async () => o.sendInfo(M, void 0, {
1004
+ const n = e ? [Ss] : [ds], o = this.establishedSession;
1005
+ return o && t && (s = s.then(async () => o.sendInfo(D, void 0, {
971
1006
  extraHeaders: n
972
1007
  })).then(async () => o.stopPresentation(t)).catch((a) => {
973
- throw this._sessionEvents.trigger(U, a), a;
974
- })), !o && t && this._sessionEvents.trigger(Ae, t), this.promisePendingStopPresentation = s, s.finally(() => {
1008
+ throw this._sessionEvents.trigger(L, a), a;
1009
+ })), !o && t && this._sessionEvents.trigger(Re, t), this.promisePendingStopPresentation = s, s.finally(() => {
975
1010
  this._resetPresentation();
976
1011
  });
977
1012
  }
@@ -1035,7 +1070,7 @@ class en {
1035
1070
  if (!this.connection)
1036
1071
  return;
1037
1072
  const t = this.connection.getReceivers().map(({ track: s }) => s);
1038
- return As(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
1073
+ return Is(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
1039
1074
  }
1040
1075
  get connection() {
1041
1076
  var t;
@@ -1085,18 +1120,19 @@ class en {
1085
1120
  const o = s, a = e[n - 1];
1086
1121
  let c;
1087
1122
  a && a.kind === "audio" && (c = a);
1088
- const E = this._generateStream(o, c);
1089
- t.push(E);
1123
+ const _ = this._generateStream(o, c);
1124
+ t.push(_);
1090
1125
  }), t;
1091
1126
  }
1092
1127
  _generateAudioStreams(e) {
1093
1128
  return e.map((s) => this._generateAudioStream(s));
1094
1129
  }
1095
1130
  _cancelRequests() {
1096
- this._cancelActionsRequests(), this._cancelCallRequests(), this._cancelConnectRequests();
1131
+ this._cancelActionsRequests(), this._cancelCallRequests(), this._cancelConnectWithRepeatedCalls();
1097
1132
  }
1098
- _cancelConnectRequests() {
1099
- this._cancelableConnect.cancelRequest();
1133
+ _cancelConnectWithRepeatedCalls() {
1134
+ var e;
1135
+ (e = this._cancelableConnectWithRepeatedCalls) == null || e.cancel();
1100
1136
  }
1101
1137
  _cancelCallRequests() {
1102
1138
  this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest();
@@ -1105,29 +1141,29 @@ class en {
1105
1141
  this._cancelableAnswer.cancelRequest(), this._cancelableSendDTMF.cancelRequest();
1106
1142
  }
1107
1143
  async waitChannels() {
1108
- return this.waitSession(v);
1144
+ return this.waitSession(y);
1109
1145
  }
1110
1146
  async waitSyncMediaState() {
1111
- return this.waitSession(w);
1147
+ return this.waitSession(b);
1112
1148
  }
1113
1149
  async sendChannels({ inputChannels: e, outputChannels: t }) {
1114
1150
  if (!this.session)
1115
1151
  throw new Error("No session established");
1116
- const s = `${Me}: ${e}`, n = `${pe}: ${t}`, o = [
1152
+ const s = `${De}: ${e}`, n = `${Me}: ${t}`, o = [
1117
1153
  s,
1118
1154
  n
1119
1155
  ];
1120
- return this.session.sendInfo(Gt, void 0, { extraHeaders: o });
1156
+ return this.session.sendInfo(Xt, void 0, { extraHeaders: o });
1121
1157
  }
1122
1158
  async sendMediaState({ cam: e, mic: t }, s = {}) {
1123
1159
  if (!this.session)
1124
1160
  throw new Error("No session established");
1125
- const n = `${ss}: currentstate`, o = `${is}: ${Number(e)}`, a = `${rs}: ${Number(t)}`, c = [
1161
+ const n = `${ns}: currentstate`, o = `${rs}: ${Number(e)}`, a = `${os}: ${Number(t)}`, c = [
1126
1162
  n,
1127
1163
  o,
1128
1164
  a
1129
1165
  ];
1130
- return this.session.sendInfo(Xt, void 0, {
1166
+ return this.session.sendInfo(Jt, void 0, {
1131
1167
  noTerminateWhenError: !0,
1132
1168
  ...s,
1133
1169
  extraHeaders: c
@@ -1136,8 +1172,8 @@ class en {
1136
1172
  async _sendRefusalToTurnOn(e, t = {}) {
1137
1173
  if (!this.session)
1138
1174
  throw new Error("No session established");
1139
- const c = [`${ns}: ${e === "mic" ? 0 : 1}`];
1140
- return this.session.sendInfo(Jt, void 0, {
1175
+ const c = [`${is}: ${e === "mic" ? 0 : 1}`];
1176
+ return this.session.sendInfo(zt, void 0, {
1141
1177
  noTerminateWhenError: !0,
1142
1178
  ...t,
1143
1179
  extraHeaders: c
@@ -1155,22 +1191,22 @@ class en {
1155
1191
  }
1156
1192
  }
1157
1193
  export {
1158
- Ft as B,
1159
- I as E,
1160
- Dt as N,
1194
+ Bt as B,
1195
+ m as E,
1196
+ vt as N,
1161
1197
  Le as R,
1162
- en as S,
1198
+ cn as S,
1163
1199
  Et as U,
1164
- zs as a,
1165
- Ks as b,
1166
- Js as c,
1167
- js as d,
1168
- Qs as e,
1200
+ sn as a,
1201
+ rn as b,
1202
+ tn as c,
1203
+ on as d,
1204
+ nn as e,
1169
1205
  k as f,
1170
1206
  q as g,
1171
- Zs as h,
1172
- Ns as i,
1207
+ an as h,
1208
+ Cs as i,
1173
1209
  _t as j,
1174
- ve as l,
1175
- ps as s
1210
+ ye as l,
1211
+ ws as s
1176
1212
  };