sip-connector 6.22.2 → 6.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/doMock.js CHANGED
@@ -1,34 +1,71 @@
1
- var R = Object.defineProperty;
2
- var S = (o, t, e) => t in o ? R(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var r = (o, t, e) => (S(o, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { j as C, R as y, U as I, S as A } from "./SipConnector-Hg44qtgr.js";
5
- import O from "@krivega/jssip/lib/NameAddrHeader";
6
- import k from "@krivega/jssip/lib/URI";
7
- import { EventEmitter as N } from "node:events";
8
- import { IncomingRequest as D } from "@krivega/jssip/lib/SIPMessage";
9
- import { createAudioMediaStreamTrackMock as L, createVideoMediaStreamTrackMock as W } from "webrtc-mock";
10
- import E from "events-constructor";
1
+ var I = Object.defineProperty;
2
+ var A = (i, e, t) => e in i ? I(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var n = (i, e, t) => (A(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { j as O, R as k, U as N, S as L } from "./SipConnector-m1cOb6M0.js";
5
+ import D from "@krivega/jssip/lib/NameAddrHeader";
6
+ import W from "@krivega/jssip/lib/URI";
7
+ import { EventEmitter as P } from "node:events";
8
+ import { IncomingRequest as x } from "@krivega/jssip/lib/SIPMessage";
9
+ import w from "events-constructor";
11
10
  import "@krivega/cancelable-promise";
12
11
  import "debug";
13
- class f extends D {
14
- constructor(e) {
12
+ class y extends x {
13
+ constructor(t) {
15
14
  super();
16
- r(this, "headers");
17
- this.headers = new Headers(e);
15
+ n(this, "headers");
16
+ this.headers = new Headers(t);
18
17
  }
19
- getHeader(e) {
20
- return this.headers.get(e) || "";
18
+ getHeader(t) {
19
+ return this.headers.get(t) || "";
21
20
  }
22
21
  }
23
- class b {
22
+ var V = Object.defineProperty, F = (i, e, t) => e in i ? V(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, s = (i, e, t) => (F(i, typeof e != "symbol" ? e + "" : e, t), t);
23
+ const c = "ended", H = "mute", U = "isolationchange", j = "overconstrained", z = "unmute", $ = [c, H, z, U, j];
24
+ class R {
25
+ constructor(e, { id: t = "identifier", constraints: r = {} } = {}) {
26
+ s(this, "events"), s(this, "id"), s(this, "kind"), s(this, "constraints"), s(this, "enabled"), s(this, "contentHint", ""), s(this, "readyState", "live"), s(this, "isolated", !1), s(this, "label", ""), s(this, "muted", !1), s(this, "onended", null), s(this, "onisolationchange", null), s(this, "onmute", null), s(this, "onunmute", null), s(this, "getConstraints", () => this.constraints), s(this, "stop", () => {
27
+ const o = { ...new Event(c) };
28
+ this.events.trigger(c, o), this.readyState = c, this.onended && this.onended(o);
29
+ }), s(this, "addEventListener", (o, a) => {
30
+ this.events.on(o, a);
31
+ }), s(this, "removeEventListener", (o, a) => {
32
+ this.events.off(o, a);
33
+ }), this.id = `${t}-${e}-track`, this.kind = e, this.enabled = !0, this.constraints = { ...r }, this.events = new w($);
34
+ }
35
+ clone() {
36
+ return { ...this };
37
+ }
38
+ getCapabilities() {
39
+ return {
40
+ width: { min: 352, max: 4096 },
41
+ height: { min: 288, max: 2160 }
42
+ };
43
+ }
44
+ getSettings() {
45
+ let e = 0, t = 0;
46
+ return typeof this.constraints.width == "object" && this.constraints.width.ideal !== void 0 ? e = this.constraints.width.ideal : typeof this.constraints.width == "object" && this.constraints.width.exact !== void 0 ? e = this.constraints.width.exact : typeof this.constraints.width == "number" && this.constraints.width && (e = this.constraints.width), typeof this.constraints.height == "object" && this.constraints.height.ideal !== void 0 ? t = this.constraints.height.ideal : typeof this.constraints.height == "object" && this.constraints.height.exact !== void 0 ? t = this.constraints.height.exact : typeof this.constraints.height == "number" && this.constraints.height && (t = this.constraints.height), {
47
+ width: e,
48
+ height: t
49
+ };
50
+ }
51
+ async applyConstraints(e) {
52
+ this.constraints = { ...e };
53
+ }
54
+ dispatchEvent(e) {
55
+ const t = e.type;
56
+ return this.events.trigger(t, e), !0;
57
+ }
58
+ }
59
+ const q = (i) => new R("audio", i), B = (i) => new R("video", i);
60
+ class K {
24
61
  // @ts-expect-error
25
- constructor({ originator: t = "local", eventHandlers: e }) {
26
- r(this, "originator");
27
- r(this, "_connection");
28
- r(this, "_events");
29
- r(this, "_remote_identity");
30
- r(this, "_mutedOptions", { audio: !1, video: !1 });
31
- this.originator = t, this._events = new E(C), this.initEvents(e);
62
+ constructor({ originator: e = "local", eventHandlers: t }) {
63
+ n(this, "originator");
64
+ n(this, "_connection");
65
+ n(this, "_events");
66
+ n(this, "_remote_identity");
67
+ n(this, "_mutedOptions", { audio: !1, video: !1 });
68
+ this.originator = e, this._events = new w(O), this.initEvents(t);
32
69
  }
33
70
  // @ts-expect-error
34
71
  get C() {
@@ -41,7 +78,7 @@ class b {
41
78
  get id() {
42
79
  throw new Error("Method not implemented.");
43
80
  }
44
- set data(t) {
81
+ set data(e) {
45
82
  throw new Error("Method not implemented.");
46
83
  }
47
84
  get data() {
@@ -80,82 +117,82 @@ class b {
80
117
  isReadyToReOffer() {
81
118
  throw new Error("Method not implemented.");
82
119
  }
83
- answer(t) {
120
+ answer(e) {
84
121
  throw new Error("Method not implemented.");
85
122
  }
86
- terminate(t) {
123
+ terminate(e) {
87
124
  throw new Error("Method not implemented.");
88
125
  }
89
- async sendInfo(t, e, n) {
126
+ async sendInfo(e, t, r) {
90
127
  throw new Error("Method not implemented.");
91
128
  }
92
- hold(t, e) {
129
+ hold(e, t) {
93
130
  throw new Error("Method not implemented.");
94
131
  }
95
- unhold(t, e) {
132
+ unhold(e, t) {
96
133
  throw new Error("Method not implemented.");
97
134
  }
98
- async renegotiate(t, e) {
135
+ async renegotiate(e, t) {
99
136
  throw new Error("Method not implemented.");
100
137
  }
101
138
  isOnHold() {
102
139
  throw new Error("Method not implemented.");
103
140
  }
104
- mute(t) {
141
+ mute(e) {
105
142
  throw new Error("Method not implemented.");
106
143
  }
107
- unmute(t) {
144
+ unmute(e) {
108
145
  throw new Error("Method not implemented.");
109
146
  }
110
147
  isMuted() {
111
148
  throw new Error("Method not implemented.");
112
149
  }
113
- refer(t, e) {
150
+ refer(e, t) {
114
151
  throw new Error("Method not implemented.");
115
152
  }
116
153
  resetLocalMedia() {
117
154
  throw new Error("Method not implemented.");
118
155
  }
119
- async replaceMediaStream(t, e) {
156
+ async replaceMediaStream(e, t) {
120
157
  throw new Error("Method not implemented.");
121
158
  }
122
- addListener(t, e) {
159
+ addListener(e, t) {
123
160
  throw new Error("Method not implemented.");
124
161
  }
125
- once(t, e) {
162
+ once(e, t) {
126
163
  throw new Error("Method not implemented.");
127
164
  }
128
- removeListener(t, e) {
165
+ removeListener(e, t) {
129
166
  throw new Error("Method not implemented.");
130
167
  }
131
- off(t, e) {
168
+ off(e, t) {
132
169
  throw new Error("Method not implemented.");
133
170
  }
134
- removeAllListeners(t) {
171
+ removeAllListeners(e) {
135
172
  throw new Error("Method not implemented.");
136
173
  }
137
- setMaxListeners(t) {
174
+ setMaxListeners(e) {
138
175
  throw new Error("Method not implemented.");
139
176
  }
140
177
  getMaxListeners() {
141
178
  throw new Error("Method not implemented.");
142
179
  }
143
- listeners(t) {
180
+ listeners(e) {
144
181
  throw new Error("Method not implemented.");
145
182
  }
146
- rawListeners(t) {
183
+ rawListeners(e) {
147
184
  throw new Error("Method not implemented.");
148
185
  }
149
- emit(t, ...e) {
186
+ emit(e, ...t) {
150
187
  throw new Error("Method not implemented.");
151
188
  }
152
- listenerCount(t) {
189
+ listenerCount(e) {
153
190
  throw new Error("Method not implemented.");
154
191
  }
155
- prependListener(t, e) {
192
+ prependListener(e, t) {
156
193
  throw new Error("Method not implemented.");
157
194
  }
158
- prependOnceListener(t, e) {
195
+ prependOnceListener(e, t) {
159
196
  throw new Error("Method not implemented.");
160
197
  }
161
198
  eventNames() {
@@ -168,15 +205,15 @@ class b {
168
205
  *
169
206
  * @returns {undefined}
170
207
  */
171
- initEvents(t = []) {
172
- Object.entries(t).forEach(([e, n]) => this.on(e, n));
208
+ initEvents(e = []) {
209
+ Object.entries(e).forEach(([t, r]) => this.on(t, r));
173
210
  }
174
211
  // @ts-expect-error
175
- on(t, e) {
176
- return this._events.on(t, e), this;
212
+ on(e, t) {
213
+ return this._events.on(e, t), this;
177
214
  }
178
- trigger(t, e) {
179
- this._events.trigger(t, e);
215
+ trigger(e, t) {
216
+ this._events.trigger(e, t);
180
217
  }
181
218
  /**
182
219
  * sendDTMF
@@ -188,62 +225,62 @@ class b {
188
225
  sendDTMF() {
189
226
  this.trigger("newDTMF", { originator: this.originator });
190
227
  }
191
- async startPresentation(t) {
192
- return t;
228
+ async startPresentation(e) {
229
+ return e;
193
230
  }
194
- async updatePresentation(t) {
195
- return t;
231
+ async updatePresentation(e) {
232
+ return e;
196
233
  }
197
- async stopPresentation(t) {
198
- return t;
234
+ async stopPresentation(e) {
235
+ return e;
199
236
  }
200
237
  isEstablished() {
201
238
  return !0;
202
239
  }
203
240
  }
204
- class P {
205
- constructor(t, e) {
206
- r(this, "_senders", []);
207
- r(this, "_receivers", []);
208
- r(this, "canTrickleIceCandidates");
209
- r(this, "connectionState");
210
- r(this, "currentLocalDescription");
211
- r(this, "currentRemoteDescription");
212
- r(this, "iceConnectionState");
213
- r(this, "iceGatheringState");
214
- r(this, "idpErrorInfo");
215
- r(this, "idpLoginUrl");
216
- r(this, "localDescription");
217
- r(this, "onconnectionstatechange");
218
- r(this, "ondatachannel");
219
- r(this, "onicecandidate");
220
- r(this, "onicecandidateerror", null);
221
- r(this, "oniceconnectionstatechange");
222
- r(this, "onicegatheringstatechange");
223
- r(this, "onnegotiationneeded");
224
- r(this, "onsignalingstatechange");
225
- r(this, "ontrack");
226
- r(this, "peerIdentity");
227
- r(this, "pendingLocalDescription");
228
- r(this, "pendingRemoteDescription");
229
- r(this, "remoteDescription");
230
- r(this, "sctp", null);
231
- r(this, "signalingState");
232
- r(this, "getReceivers", () => this._receivers);
233
- r(this, "getSenders", () => this._senders);
234
- r(this, "addTrack", (t) => {
235
- const e = { track: t };
236
- return this._senders.push(e), e;
241
+ class Y {
242
+ constructor(e, t) {
243
+ n(this, "_senders", []);
244
+ n(this, "_receivers", []);
245
+ n(this, "canTrickleIceCandidates");
246
+ n(this, "connectionState");
247
+ n(this, "currentLocalDescription");
248
+ n(this, "currentRemoteDescription");
249
+ n(this, "iceConnectionState");
250
+ n(this, "iceGatheringState");
251
+ n(this, "idpErrorInfo");
252
+ n(this, "idpLoginUrl");
253
+ n(this, "localDescription");
254
+ n(this, "onconnectionstatechange");
255
+ n(this, "ondatachannel");
256
+ n(this, "onicecandidate");
257
+ n(this, "onicecandidateerror", null);
258
+ n(this, "oniceconnectionstatechange");
259
+ n(this, "onicegatheringstatechange");
260
+ n(this, "onnegotiationneeded");
261
+ n(this, "onsignalingstatechange");
262
+ n(this, "ontrack");
263
+ n(this, "peerIdentity");
264
+ n(this, "pendingLocalDescription");
265
+ n(this, "pendingRemoteDescription");
266
+ n(this, "remoteDescription");
267
+ n(this, "sctp", null);
268
+ n(this, "signalingState");
269
+ n(this, "getReceivers", () => this._receivers);
270
+ n(this, "getSenders", () => this._senders);
271
+ n(this, "addTrack", (e) => {
272
+ const t = { track: e };
273
+ return this._senders.push(t), t;
237
274
  });
238
- this._receivers = e.map((n) => ({ track: n }));
275
+ this._receivers = t.map((r) => ({ track: r }));
239
276
  }
240
277
  getRemoteStreams() {
241
278
  throw new Error("Method not implemented.");
242
279
  }
243
- async addIceCandidate(t) {
280
+ async addIceCandidate(e) {
244
281
  throw new Error("Method not implemented.");
245
282
  }
246
- addTransceiver(t, e) {
283
+ addTransceiver(e, t) {
247
284
  throw new Error("Method not implemented.");
248
285
  }
249
286
  close() {
@@ -252,13 +289,13 @@ class P {
252
289
  restartIce() {
253
290
  throw new Error("Method not implemented.");
254
291
  }
255
- async createAnswer(t, e) {
292
+ async createAnswer(e, t) {
256
293
  throw new Error("Method not implemented.");
257
294
  }
258
- createDataChannel(t, e) {
295
+ createDataChannel(e, t) {
259
296
  throw new Error("Method not implemented.");
260
297
  }
261
- async createOffer(t, e, n) {
298
+ async createOffer(e, t, r) {
262
299
  throw new Error("Method not implemented.");
263
300
  }
264
301
  getConfiguration() {
@@ -267,52 +304,52 @@ class P {
267
304
  async getIdentityAssertion() {
268
305
  throw new Error("Method not implemented.");
269
306
  }
270
- async getStats(t) {
307
+ async getStats(e) {
271
308
  throw new Error("Method not implemented.");
272
309
  }
273
310
  getTransceivers() {
274
311
  throw new Error("Method not implemented.");
275
312
  }
276
- removeTrack(t) {
313
+ removeTrack(e) {
277
314
  throw new Error("Method not implemented.");
278
315
  }
279
- setConfiguration(t) {
316
+ setConfiguration(e) {
280
317
  throw new Error("Method not implemented.");
281
318
  }
282
- async setLocalDescription(t) {
319
+ async setLocalDescription(e) {
283
320
  throw new Error("Method not implemented.");
284
321
  }
285
- async setRemoteDescription(t) {
322
+ async setRemoteDescription(e) {
286
323
  throw new Error("Method not implemented.");
287
324
  }
288
- addEventListener(t, e, n) {
325
+ addEventListener(e, t, r) {
289
326
  throw new Error("Method not implemented.");
290
327
  }
291
- removeEventListener(t, e, n) {
328
+ removeEventListener(e, t, r) {
292
329
  throw new Error("Method not implemented.");
293
330
  }
294
- dispatchEvent(t) {
331
+ dispatchEvent(e) {
295
332
  throw new Error("Method not implemented.");
296
333
  }
297
334
  }
298
- function V(o) {
299
- const t = o.match(/[\d.]+/g);
300
- if (!t)
335
+ function J(i) {
336
+ const e = i.match(/[\d.]+/g);
337
+ if (!e)
301
338
  throw new Error("wrong sip url");
302
- return t[0];
339
+ return e[0];
303
340
  }
304
- const m = 400, U = "777", x = (o) => o.getVideoTracks().length > 0;
305
- class M extends b {
341
+ const g = 400, G = "777", X = (i) => i.getVideoTracks().length > 0;
342
+ class S extends K {
306
343
  constructor({
307
- url: e = "",
308
- mediaStream: n,
309
- eventHandlers: i,
310
- originator: d
344
+ url: t = "",
345
+ mediaStream: r,
346
+ eventHandlers: o,
347
+ originator: a
311
348
  }) {
312
- super({ originator: d, eventHandlers: i });
313
- r(this, "url");
314
- r(this, "status_code");
315
- r(this, "_isEnded", !1);
349
+ super({ originator: a, eventHandlers: o });
350
+ n(this, "url");
351
+ n(this, "status_code");
352
+ n(this, "_isEnded", !1);
316
353
  /**
317
354
  * answer
318
355
  *
@@ -322,94 +359,94 @@ class M extends b {
322
359
 
323
360
  * @returns {undefined}
324
361
  */
325
- r(this, "answer", jest.fn(({ mediaStream: e }) => {
362
+ n(this, "answer", jest.fn(({ mediaStream: t }) => {
326
363
  if (this.originator !== "remote")
327
364
  throw new Error("answer available only for remote sessions");
328
- this.initPeerconnection(e), setTimeout(() => {
365
+ this.initPeerconnection(t), setTimeout(() => {
329
366
  this.trigger("connecting"), setTimeout(() => {
330
367
  this.trigger("accepted");
331
368
  }, 100), setTimeout(() => {
332
369
  this.trigger("confirmed");
333
370
  }, 200);
334
- }, m);
371
+ }, g);
335
372
  }));
336
- this.url = e, this.initPeerconnection(n);
337
- }
338
- initPeerconnection(e) {
339
- return e ? (this.createPeerconnection(e), !0) : !1;
340
- }
341
- createPeerconnection(e) {
342
- const n = L();
343
- n.id = "mainaudio1";
344
- const i = [n];
345
- if (x(e)) {
346
- const p = W();
347
- p.id = "mainvideo1", i.push(p);
373
+ this.url = t, this.initPeerconnection(r);
374
+ }
375
+ initPeerconnection(t) {
376
+ return t ? (this.createPeerconnection(t), !0) : !1;
377
+ }
378
+ createPeerconnection(t) {
379
+ const r = q();
380
+ r.id = "mainaudio1";
381
+ const o = [r];
382
+ if (X(t)) {
383
+ const M = B();
384
+ M.id = "mainvideo1", o.push(M);
348
385
  }
349
- this._connection = new P(void 0, i), this._addStream(e), setTimeout(() => {
386
+ this._connection = new Y(void 0, o), this._addStream(t), setTimeout(() => {
350
387
  this.trigger("peerconnection", { peerconnection: this.connection });
351
- }, m);
388
+ }, g);
352
389
  }
353
- connect(e) {
354
- const n = V(e);
390
+ connect(t) {
391
+ const r = J(t);
355
392
  setTimeout(() => {
356
- this.url.includes(U) ? this.trigger("failed", {
393
+ this.url.includes(G) ? this.trigger("failed", {
357
394
  originator: "remote",
358
395
  message: "IncomingResponse",
359
- cause: y
396
+ cause: k
360
397
  }) : (this.trigger("connecting"), setTimeout(() => {
361
- this.trigger("enterRoom", n);
398
+ this.trigger("enterRoom", r);
362
399
  }, 100), setTimeout(() => {
363
400
  this.trigger("accepted");
364
401
  }, 200), setTimeout(() => {
365
402
  this.trigger("confirmed");
366
403
  }, 300));
367
- }, m);
404
+ }, g);
368
405
  }
369
- terminate({ status_code: e } = {}) {
370
- return this.status_code = e, this.trigger("ended", { status_code: e }), this._isEnded = !1, this;
406
+ terminate({ status_code: t } = {}) {
407
+ return this.status_code = t, this.trigger("ended", { status_code: t }), this._isEnded = !1, this;
371
408
  }
372
- terminateRemote({ status_code: e } = {}) {
373
- return this.status_code = e, this.trigger("ended", { status_code: e, originator: "remote" }), this;
409
+ terminateRemote({ status_code: t } = {}) {
410
+ return this.status_code = t, this.trigger("ended", { status_code: t, originator: "remote" }), this;
374
411
  }
375
- _addStream(e, n = "getTracks") {
376
- e[n]().forEach((i) => this.connection.addTrack(i));
412
+ _addStream(t, r = "getTracks") {
413
+ t[r]().forEach((o) => this.connection.addTrack(o));
377
414
  }
378
- _forEachSenders(e) {
379
- const n = this.connection.getSenders();
380
- for (const i of n)
381
- e(i);
382
- return n;
415
+ _forEachSenders(t) {
416
+ const r = this.connection.getSenders();
417
+ for (const o of r)
418
+ t(o);
419
+ return r;
383
420
  }
384
421
  /* eslint-disable no-param-reassign */
385
- _toggleMuteAudio(e) {
386
- this._forEachSenders(({ track: n }) => {
387
- n && n.kind === "audio" && (n.enabled = !e);
422
+ _toggleMuteAudio(t) {
423
+ this._forEachSenders(({ track: r }) => {
424
+ r && r.kind === "audio" && (r.enabled = !t);
388
425
  });
389
426
  }
390
427
  /* eslint-enable no-param-reassign */
391
428
  /* eslint-disable no-param-reassign */
392
- _toggleMuteVideo(e) {
393
- this._forEachSenders(({ track: n }) => {
394
- n && n.kind === "video" && (n.enabled = !e);
429
+ _toggleMuteVideo(t) {
430
+ this._forEachSenders(({ track: r }) => {
431
+ r && r.kind === "video" && (r.enabled = !t);
395
432
  });
396
433
  }
397
- mute(e) {
398
- 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);
434
+ mute(t) {
435
+ t.audio && (this._mutedOptions.audio = !0, this._toggleMuteAudio(this._mutedOptions.audio)), t.video && (this._mutedOptions.video = !0, this._toggleMuteVideo(this._mutedOptions.video)), this._onmute(t);
399
436
  }
400
- unmute(e) {
401
- e.audio && (this._mutedOptions.audio = !1), e.video && (this._mutedOptions.video = !1), this.trigger("unmuted", e);
437
+ unmute(t) {
438
+ t.audio && (this._mutedOptions.audio = !1), t.video && (this._mutedOptions.video = !1), this.trigger("unmuted", t);
402
439
  }
403
440
  isMuted() {
404
441
  return this._mutedOptions;
405
442
  }
406
- async replaceMediaStream(e) {
407
- return e;
443
+ async replaceMediaStream(t) {
444
+ return t;
408
445
  }
409
- _onmute({ audio: e, video: n }) {
446
+ _onmute({ audio: t, video: r }) {
410
447
  this.trigger("muted", {
411
- audio: e,
412
- video: n
448
+ audio: t,
449
+ video: r
413
450
  });
414
451
  }
415
452
  async sendInfo() {
@@ -417,38 +454,43 @@ class M extends b {
417
454
  isEnded() {
418
455
  return this._isEnded;
419
456
  }
420
- newInfo(e) {
421
- this.trigger("newInfo", e);
457
+ newInfo(t) {
458
+ this.trigger("newInfo", t);
422
459
  }
423
460
  /* eslint-enable no-param-reassign */
424
461
  }
425
- class F {
462
+ class Q {
426
463
  constructor() {
427
- r(this, "extraHeaders");
464
+ n(this, "extraHeaders");
428
465
  }
429
- setExtraHeaders(t) {
430
- this.extraHeaders = t;
466
+ setExtraHeaders(e) {
467
+ this.extraHeaders = e;
431
468
  }
432
469
  setExtraContactParams() {
433
470
  }
434
471
  }
435
- const s = "PASSWORD_CORRECT", w = "PASSWORD_CORRECT_2", H = "NAME_INCORRECT", a = 400;
436
- class z {
437
- constructor(t) {
438
- r(this, "_events");
439
- r(this, "_startedTimeout");
440
- r(this, "_stopedTimeout");
441
- r(this, "session");
442
- r(this, "_isRegistered");
443
- r(this, "_isConnected");
444
- r(this, "configuration");
445
- r(this, "_registrator");
472
+ const d = "PASSWORD_CORRECT", T = "PASSWORD_CORRECT_2", Z = "NAME_INCORRECT", h = 400, m = class m {
473
+ constructor(e) {
474
+ n(this, "_events");
475
+ n(this, "_startedTimeout");
476
+ n(this, "_stopedTimeout");
477
+ n(this, "session");
478
+ n(this, "_isRegistered");
479
+ n(this, "_isConnected");
480
+ n(this, "configuration");
481
+ n(this, "_registrator");
446
482
  // @ts-expect-error
447
- r(this, "call", jest.fn((t, e) => {
448
- const { mediaStream: n, eventHandlers: i } = e;
449
- return this.session = new M({ url: t, mediaStream: n, eventHandlers: i, originator: "local" }), this.session.connect(t), this.session;
483
+ n(this, "call", jest.fn((e, t) => {
484
+ const { mediaStream: r, eventHandlers: o } = t;
485
+ return this.session = new S({ url: e, mediaStream: r, eventHandlers: o, originator: "local" }), this.session.connect(e), this.session;
450
486
  }));
451
- this._events = new E(I), this.configuration = t, this._registrator = new F();
487
+ this._events = new w(N), this.configuration = e, this._registrator = new Q();
488
+ }
489
+ static setAvailableTelephony() {
490
+ this.isAvailableTelephony = !0;
491
+ }
492
+ static setNotAvailableTelephony() {
493
+ this.isAvailableTelephony = !1;
452
494
  }
453
495
  /**
454
496
  * start
@@ -466,14 +508,25 @@ class z {
466
508
  stop() {
467
509
  this._startedTimeout && clearTimeout(this._startedTimeout), this._stopedTimeout && clearTimeout(this._stopedTimeout), this.unregister(), this.isStarted() ? this._stopedTimeout = setTimeout(() => {
468
510
  this.trigger("disconnected", { error: new Error("stoped") });
469
- }, a) : this.trigger("disconnected", { error: new Error("stoped") });
511
+ }, h) : this.trigger("disconnected", { error: new Error("stoped") });
512
+ }
513
+ // @ts-expect-error
514
+ on(e, t) {
515
+ return this._events.on(e, t), this;
516
+ }
517
+ // @ts-expect-error
518
+ once(e, t) {
519
+ return this._events.once(e, t), this;
470
520
  }
471
521
  // @ts-expect-error
472
- on(t, e) {
473
- return this._events.on(t, e), this;
522
+ off(e, t) {
523
+ return this._events.off(e, t), this;
524
+ }
525
+ removeAllListeners() {
526
+ return this._events.removeEventHandlers(), this;
474
527
  }
475
- trigger(t, e) {
476
- this._events.trigger(t, e);
528
+ trigger(e, t) {
529
+ this._events.trigger(e, t);
477
530
  }
478
531
  /**
479
532
  * terminateSessions
@@ -491,8 +544,8 @@ class z {
491
544
  *
492
545
  * @returns {boolean} true
493
546
  */
494
- set(t, e) {
495
- return this.configuration[t] = e, !0;
547
+ set(e, t) {
548
+ return this.configuration[e] = t, !0;
496
549
  }
497
550
  /**
498
551
  * register
@@ -501,14 +554,14 @@ class z {
501
554
  */
502
555
  register() {
503
556
  this._startedTimeout && clearTimeout(this._startedTimeout);
504
- const { password: t, register: e, uri: n } = this.configuration;
505
- e && n.includes(H) ? (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
557
+ const { password: e, register: t, uri: r } = this.configuration;
558
+ t && r.includes(Z) ? (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
506
559
  this.trigger("registrationFailed", { response: null, cause: "Request Timeout" });
507
- }, a)) : !this._isRegistered && e && (t === s || t === w) ? (this._isRegistered = !0, this._startedTimeout = setTimeout(() => {
560
+ }, h)) : !this._isRegistered && t && (e === d || e === T) ? (this._isRegistered = !0, this._startedTimeout = setTimeout(() => {
508
561
  this.trigger("registered");
509
- }, a)) : e && t !== s && t !== w && (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
562
+ }, h)) : t && e !== d && e !== T && (this._isRegistered = !1, this._isConnected = !1, this._startedTimeout = setTimeout(() => {
510
563
  this.trigger("registrationFailed", { response: null, cause: "Wrong credentials" });
511
- }, a)), this.trigger("connected"), this._isConnected = !0;
564
+ }, h)), m.isAvailableTelephony ? (this.trigger("connected"), this._isConnected = !0) : this.stop();
512
565
  }
513
566
  /**
514
567
  * unregister
@@ -537,120 +590,122 @@ class z {
537
590
  registrator() {
538
591
  return this._registrator;
539
592
  }
540
- newSipEvent(t) {
541
- this.trigger("sipEvent", t);
593
+ newSipEvent(e) {
594
+ this.trigger("sipEvent", e);
542
595
  }
543
- }
544
- class q {
545
- constructor(t) {
546
- r(this, "url");
547
- this.url = t;
596
+ };
597
+ n(m, "isAvailableTelephony", !0);
598
+ let p = m;
599
+ class ee {
600
+ constructor(e) {
601
+ n(this, "url");
602
+ this.url = e;
548
603
  }
549
604
  }
550
- class $ extends N {
551
- constructor(e, n) {
605
+ class te extends P {
606
+ constructor(t, r) {
552
607
  super();
553
- r(this, "contentType");
554
- r(this, "body");
555
- this.contentType = e, this.body = n;
608
+ n(this, "contentType");
609
+ n(this, "body");
610
+ this.contentType = t, this.body = r;
556
611
  }
557
612
  }
558
- const u = "remote", j = (o, t) => {
559
- const e = new f(t), n = {
560
- originator: u,
561
- request: e,
562
- info: new $("", "")
613
+ const _ = "remote", ne = (i, e) => {
614
+ const t = new y(e), r = {
615
+ originator: _,
616
+ request: t,
617
+ info: new te("", "")
563
618
  };
564
- o.newInfo(n);
565
- }, B = (o, t) => {
566
- const n = { request: new f(t) };
567
- o.newSipEvent(n);
568
- }, K = (o, {
569
- incomingNumber: t = "1234",
570
- displayName: e,
571
- host: n
619
+ i.newInfo(r);
620
+ }, re = (i, e) => {
621
+ const r = { request: new y(e) };
622
+ i.newSipEvent(r);
623
+ }, ie = (i, {
624
+ incomingNumber: e = "1234",
625
+ displayName: t,
626
+ host: r
572
627
  }) => {
573
- const i = new M({ originator: u }), d = new k("sip", t, n);
574
- i._remote_identity = new O(d, e), o.trigger("newRTCSession", { originator: u, session: i });
575
- }, J = (o, t) => {
576
- t ? o.trigger("failed", t) : o.trigger("failed", o);
577
- }, T = {
578
- triggerNewInfo: j,
579
- triggerNewSipEvent: B,
580
- triggerIncomingSession: K,
581
- triggerFailIncomingSession: J,
582
- WebSocketInterface: q,
583
- UA: z,
628
+ const o = new S({ originator: _ }), a = new W("sip", e, r);
629
+ o._remote_identity = new D(a, t), i.trigger("newRTCSession", { originator: _, session: o });
630
+ }, oe = (i, e) => {
631
+ e ? i.trigger("failed", e) : i.trigger("failed", i);
632
+ }, C = {
633
+ triggerNewInfo: ne,
634
+ triggerNewSipEvent: re,
635
+ triggerIncomingSession: ie,
636
+ triggerFailIncomingSession: oe,
637
+ WebSocketInterface: ee,
638
+ UA: p,
584
639
  C: {
585
640
  INVITE: "INVITE"
586
641
  }
587
- }, l = "user", c = "displayName", g = "SIP_SERVER_URL", v = "SIP_WEB_SOCKET_SERVER_URL", Y = new T.WebSocketInterface(v), _ = {
642
+ }, E = "user", l = "displayName", f = "SIP_SERVER_URL", b = "SIP_WEB_SOCKET_SERVER_URL", se = new C.WebSocketInterface(b), v = {
588
643
  userAgent: "Chrome",
589
- sipServerUrl: g,
590
- sipWebSocketServerURL: v
644
+ sipServerUrl: f,
645
+ sipWebSocketServerURL: b
646
+ }, Ee = {
647
+ ...v
591
648
  }, ae = {
592
- ..._
593
- }, G = {
594
- ..._,
595
- user: l,
596
- password: s,
649
+ ...v,
650
+ user: E,
651
+ password: d,
597
652
  register: !0
598
- }, ce = {
599
- ...G,
600
- displayName: c
601
- }, he = {
602
- ..._,
603
- displayName: c,
653
+ }, fe = {
654
+ ...ae,
655
+ displayName: l
656
+ }, ve = {
657
+ ...v,
658
+ displayName: l,
604
659
  register: !1
605
- }, h = {
660
+ }, u = {
606
661
  session_timers: !1,
607
- sockets: [Y],
662
+ sockets: [se],
608
663
  user_agent: "Chrome",
609
664
  sdp_semantics: "plan-b",
610
665
  register_expires: 300,
611
666
  connection_recovery_max_interval: 6,
612
667
  connection_recovery_min_interval: 2
613
- }, me = {
614
- ...h,
615
- password: s,
616
- uri: `sip:${l}@${g}`,
668
+ }, Me = {
669
+ ...u,
670
+ password: d,
671
+ uri: `sip:${E}@${f}`,
617
672
  display_name: "",
618
673
  register: !0
619
- }, ue = {
620
- ...h,
621
- password: s,
622
- uri: `sip:${l}@${g}`,
623
- display_name: c,
674
+ }, Te = {
675
+ ...u,
676
+ password: d,
677
+ uri: `sip:${E}@${f}`,
678
+ display_name: l,
624
679
  register: !0
625
- }, le = {
626
- ...h,
627
- display_name: c,
680
+ }, ye = {
681
+ ...u,
682
+ display_name: l,
628
683
  register: !1
629
- }, ge = {
630
- ...h,
684
+ }, Re = {
685
+ ...u,
631
686
  display_name: "",
632
687
  register: !1
633
- }, X = "10.10.10.10", _e = [`X-Vinteo-Remote: ${X}`], pe = () => new A({
634
- JsSIP: T
688
+ }, de = "10.10.10.10", Se = [`X-Vinteo-Remote: ${de}`], Ce = () => new L({
689
+ JsSIP: C
635
690
  });
636
691
  export {
637
- U as FAILED_CONFERENCE_NUMBER,
638
- H as NAME_INCORRECT,
639
- s as PASSWORD_CORRECT,
640
- w as PASSWORD_CORRECT_2,
641
- g as SIP_SERVER_URL,
642
- v as SIP_WEB_SOCKET_SERVER_URL,
643
- G as dataForConnectionWithAuthorization,
644
- ce as dataForConnectionWithAuthorizationWithDisplayName,
645
- he as dataForConnectionWithoutAuthorization,
646
- ae as dataForConnectionWithoutAuthorizationWithoutDisplayName,
647
- pe as default,
648
- c as displayName,
649
- _e as extraHeadersRemoteAddress,
650
- X as remoteAddress,
651
- me as uaConfigurationWithAuthorization,
652
- ue as uaConfigurationWithAuthorizationWithDisplayName,
653
- le as uaConfigurationWithoutAuthorization,
654
- ge as uaConfigurationWithoutAuthorizationWithoutDisplayName,
655
- l as user
692
+ G as FAILED_CONFERENCE_NUMBER,
693
+ Z as NAME_INCORRECT,
694
+ d as PASSWORD_CORRECT,
695
+ T as PASSWORD_CORRECT_2,
696
+ f as SIP_SERVER_URL,
697
+ b as SIP_WEB_SOCKET_SERVER_URL,
698
+ ae as dataForConnectionWithAuthorization,
699
+ fe as dataForConnectionWithAuthorizationWithDisplayName,
700
+ ve as dataForConnectionWithoutAuthorization,
701
+ Ee as dataForConnectionWithoutAuthorizationWithoutDisplayName,
702
+ Ce as default,
703
+ l as displayName,
704
+ Se as extraHeadersRemoteAddress,
705
+ de as remoteAddress,
706
+ Me as uaConfigurationWithAuthorization,
707
+ Te as uaConfigurationWithAuthorizationWithDisplayName,
708
+ ye as uaConfigurationWithoutAuthorization,
709
+ Re as uaConfigurationWithoutAuthorizationWithoutDisplayName,
710
+ E as user
656
711
  };