sip-connector 14.1.0-alpha.9 → 14.1.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.
Files changed (132) hide show
  1. package/dist/SipConnector-DRjfFGAZ.js +1339 -0
  2. package/dist/SipConnector-EXAO9Z-2.cjs +1 -0
  3. package/dist/doMock.cjs +1 -1
  4. package/dist/doMock.js +162 -267
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +526 -577
  7. package/dist/src/SipConnector.d.ts +235 -0
  8. package/dist/{SipConnectorFacade → src/SipConnectorFacade}/SipConnectorFacade.d.ts +16 -7
  9. package/dist/{__fixtures__ → src/__fixtures__}/BaseSession.mock.d.ts +5 -5
  10. package/dist/{__fixtures__ → src/__fixtures__}/RTCSessionMock.d.ts +4 -9
  11. package/dist/{__fixtures__ → src/__fixtures__}/UA.mock.d.ts +14 -12
  12. package/dist/{__fixtures__ → src/__fixtures__}/index.d.ts +4 -4
  13. package/dist/{__fixtures__ → src/__fixtures__}/jssip.mock.d.ts +3 -3
  14. package/dist/src/causes.d.ts +23 -0
  15. package/dist/{doMock.d.ts → src/doMock.d.ts} +1 -2
  16. package/dist/{__fixtures__ → src}/eventNames.d.ts +1 -1
  17. package/dist/src/headers.d.ts +37 -0
  18. package/dist/src/index.d.ts +11 -0
  19. package/dist/{tools → src/tools}/__fixtures__/connectToServer.d.ts +2 -2
  20. package/dist/{tools → src/tools}/__fixtures__/processRequest.d.ts +1 -1
  21. package/dist/{tools → src/tools}/error/getLinkError.d.ts +1 -1
  22. package/dist/{tools → src/tools}/error/getTypeFromError.d.ts +1 -1
  23. package/dist/{tools → src/tools}/error/getValuesFromError.d.ts +1 -1
  24. package/dist/{tools → src/tools}/index.d.ts +1 -1
  25. package/dist/{tools → src/tools}/prepareMediaStream.d.ts +1 -1
  26. package/dist/{tools → src/tools}/setVideoTrackContentHints.d.ts +1 -1
  27. package/dist/{tools → src/tools}/syncMediaState/index.d.ts +1 -1
  28. package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMainCam.d.ts +1 -1
  29. package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMic.d.ts +1 -1
  30. package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMainCam.d.ts +1 -1
  31. package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMic.d.ts +1 -1
  32. package/dist/src/types.d.ts +69 -0
  33. package/dist/{videoSendingBalancer → src/videoSendingBalancer}/balance.d.ts +1 -1
  34. package/dist/{videoSendingBalancer → src/videoSendingBalancer}/index.d.ts +1 -1
  35. package/dist/{videoSendingBalancer → src/videoSendingBalancer}/processSender.d.ts +1 -1
  36. package/dist/src/videoSendingBalancer/scaleBitrate.d.ts +2 -0
  37. package/package.json +32 -26
  38. package/dist/@SipConnector-BOHJ000Z.cjs +0 -1
  39. package/dist/@SipConnector-BxitfweK.js +0 -2267
  40. package/dist/ApiManager/@ApiManager.d.ts +0 -58
  41. package/dist/ApiManager/constants.d.ts +0 -71
  42. package/dist/ApiManager/eventNames.d.ts +0 -33
  43. package/dist/ApiManager/index.d.ts +0 -3
  44. package/dist/ApiManager/types.d.ts +0 -99
  45. package/dist/CallManager/@CallManager.d.ts +0 -26
  46. package/dist/CallManager/AbstractCallStrategy.d.ts +0 -47
  47. package/dist/CallManager/MCUCallStrategy.d.ts +0 -30
  48. package/dist/CallManager/RemoteStreamsManager.d.ts +0 -8
  49. package/dist/CallManager/causes.d.ts +0 -13
  50. package/dist/CallManager/eventNames.d.ts +0 -45
  51. package/dist/CallManager/hasCanceledCallError.d.ts +0 -2
  52. package/dist/CallManager/index.d.ts +0 -7
  53. package/dist/CallManager/types.d.ts +0 -59
  54. package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -48
  55. package/dist/ConnectionManager/ConfigurationManager.d.ts +0 -60
  56. package/dist/ConnectionManager/ConnectionFlow.d.ts +0 -84
  57. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +0 -61
  58. package/dist/ConnectionManager/RegistrationManager.d.ts +0 -17
  59. package/dist/ConnectionManager/SipOperations.d.ts +0 -32
  60. package/dist/ConnectionManager/UAFactory.d.ts +0 -50
  61. package/dist/ConnectionManager/eventNames.d.ts +0 -16
  62. package/dist/ConnectionManager/index.d.ts +0 -3
  63. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -37
  64. package/dist/IncomingCallManager/eventNames.d.ts +0 -13
  65. package/dist/IncomingCallManager/index.d.ts +0 -2
  66. package/dist/PresentationManager/@PresentationManager.d.ts +0 -47
  67. package/dist/PresentationManager/constants.d.ts +0 -1
  68. package/dist/PresentationManager/eventNames.d.ts +0 -11
  69. package/dist/PresentationManager/index.d.ts +0 -2
  70. package/dist/PresentationManager/types.d.ts +0 -2
  71. package/dist/SipConnector/@SipConnector.d.ts +0 -96
  72. package/dist/SipConnector/eventNames.d.ts +0 -4
  73. package/dist/SipConnector/index.d.ts +0 -2
  74. package/dist/index.d.ts +0 -14
  75. package/dist/types.d.ts +0 -23
  76. package/dist/videoSendingBalancer/scaleBitrate.d.ts +0 -2
  77. /package/dist/{SipConnectorFacade → src/SipConnectorFacade}/index.d.ts +0 -0
  78. /package/dist/{__fixtures__ → src/__fixtures__}/RTCPeerConnectionMock.d.ts +0 -0
  79. /package/dist/{__fixtures__ → src/__fixtures__}/RTCRtpSenderMock.d.ts +0 -0
  80. /package/dist/{__fixtures__ → src/__fixtures__}/Registrator.mock.d.ts +0 -0
  81. /package/dist/{__fixtures__ → src/__fixtures__}/Request.mock.d.ts +0 -0
  82. /package/dist/{__fixtures__ → src/__fixtures__}/WebSocketInterface.mock.d.ts +0 -0
  83. /package/dist/{__fixtures__ → src/__fixtures__}/accountNotify.d.ts +0 -0
  84. /package/dist/{__fixtures__ → src/__fixtures__}/channels.d.ts +0 -0
  85. /package/dist/{__fixtures__ → src/__fixtures__}/channelsNotify.d.ts +0 -0
  86. /package/dist/{__fixtures__ → src/__fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
  87. /package/dist/{__fixtures__ → src/__fixtures__}/delayPromise.d.ts +0 -0
  88. /package/dist/{__fixtures__ → src/__fixtures__}/enterRoom.d.ts +0 -0
  89. /package/dist/{__fixtures__ → src/__fixtures__}/mediaState.d.ts +0 -0
  90. /package/dist/{__fixtures__ → src/__fixtures__}/participantMoveRequests.d.ts +0 -0
  91. /package/dist/{__fixtures__ → src/__fixtures__}/participantNotify.d.ts +0 -0
  92. /package/dist/{__fixtures__ → src/__fixtures__}/remoteCallerData.d.ts +0 -0
  93. /package/dist/{__fixtures__ → src/__fixtures__}/utils.d.ts +0 -0
  94. /package/dist/{__fixtures__ → src/__fixtures__}/webcastNotify.d.ts +0 -0
  95. /package/dist/{__fixtures__ → src}/constants.d.ts +0 -0
  96. /package/dist/{ConnectionManager → src}/getExtraHeadersRemoteAddress.d.ts +0 -0
  97. /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
  98. /package/dist/{setParametersToSender → src/setParametersToSender}/configureDegradationPreference.d.ts +0 -0
  99. /package/dist/{setParametersToSender → src/setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
  100. /package/dist/{setParametersToSender → src/setParametersToSender}/configureEncodings.d.ts +0 -0
  101. /package/dist/{setParametersToSender → src/setParametersToSender}/configureMaxBitrate.d.ts +0 -0
  102. /package/dist/{setParametersToSender → src/setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
  103. /package/dist/{setParametersToSender → src/setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
  104. /package/dist/{setParametersToSender → src/setParametersToSender}/index.d.ts +0 -0
  105. /package/dist/{setParametersToSender → src/setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
  106. /package/dist/{setParametersToSender → src/setParametersToSender}/setParametersToSender.d.ts +0 -0
  107. /package/dist/{tools → src/tools}/__fixtures__/call.d.ts +0 -0
  108. /package/dist/{tools → src/tools}/__fixtures__/hasValidUri.d.ts +0 -0
  109. /package/dist/{tools → src/tools}/__fixtures__/permissions.d.ts +0 -0
  110. /package/dist/{tools → src/tools}/__tests-utils__/parseObject.d.ts +0 -0
  111. /package/dist/{tools → src/tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
  112. /package/dist/{tools → src/tools}/error/index.d.ts +0 -0
  113. /package/dist/{tools → src/tools}/error/stringifyMessage.d.ts +0 -0
  114. /package/dist/{tools → src/tools}/generateSimulcastEncodings.d.ts +0 -0
  115. /package/dist/{tools → src/tools}/getExtraHeaders.d.ts +0 -0
  116. /package/dist/{tools → src/tools}/getUserAgent.d.ts +0 -0
  117. /package/dist/{tools → src/tools}/hasPurgatory.d.ts +0 -0
  118. /package/dist/{tools → src/tools}/resolveUpdateTransceiver.d.ts +0 -0
  119. /package/dist/{tools/sendDtmfFAccumulated.d.ts → src/tools/sendDTMFAccumulated.d.ts} +0 -0
  120. /package/dist/{utils → src/utils}/errors.d.ts +0 -0
  121. /package/dist/{utils → src/utils}/findSenderByStream.d.ts +0 -0
  122. /package/dist/{utils → src/utils}/findVideoSender.d.ts +0 -0
  123. /package/dist/{utils → src/utils}/findVideoTrack.d.ts +0 -0
  124. /package/dist/{utils → src/utils}/getCodecFromSender.d.ts +0 -0
  125. /package/dist/{utils → src/utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
  126. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
  127. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
  128. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
  129. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasIncludesString.d.ts +0 -0
  130. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
  131. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
  132. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
package/dist/doMock.js CHANGED
@@ -1,12 +1,12 @@
1
- import { O as v, S as D } from "./@SipConnector-BxitfweK.js";
2
- import y from "@krivega/jssip/lib/NameAddrHeader";
3
- import L from "@krivega/jssip/lib/URI";
4
- import { EventEmitter as F } from "node:events";
5
- import { IncomingRequest as b } from "@krivega/jssip/lib/SIPMessage";
6
- import { NameAddrHeader as V, URI as E, C as S } from "@krivega/jssip";
7
- import { createAudioMediaStreamTrackMock as k, createVideoMediaStreamTrackMock as W } from "webrtc-mock";
1
+ import { o as N, R as P, U as O, S as k } from "./SipConnector-DRjfFGAZ.js";
2
+ import A from "@krivega/jssip/lib/NameAddrHeader";
3
+ import b from "@krivega/jssip/lib/URI";
4
+ import { EventEmitter as D } from "node:events";
5
+ import { IncomingRequest as L } from "@krivega/jssip/lib/SIPMessage";
6
+ import { createAudioMediaStreamTrackMock as W, createVideoMediaStreamTrackMock as V } from "webrtc-mock";
8
7
  import R from "events-constructor";
9
- class _ extends b {
8
+ import { URI as w, C as I } from "@krivega/jssip";
9
+ class E extends L {
10
10
  headers;
11
11
  constructor(e) {
12
12
  super(), this.headers = new Headers(e);
@@ -15,89 +15,7 @@ class _ extends b {
15
15
  return this.headers.get(e) ?? "";
16
16
  }
17
17
  }
18
- const U = "incomingCall", G = "declinedIncomingCall", H = "failedIncomingCall", x = "terminatedIncomingCall", M = "connecting", q = "connected", Y = "disconnected", j = "newRTCSession", z = "registered", B = "unregistered", J = "registrationFailed", K = "newMessage", $ = "sipEvent", Q = "availableSecondRemoteStream", X = "notAvailableSecondRemoteStream", Z = "mustStopPresentation", ee = "shareState", te = "enterRoom", re = "useLicense", ne = "peerconnection:confirmed", oe = "peerconnection:ontrack", se = "channels", ie = "channels:notify", ae = "ended:fromserver", ce = "main-cam-control", de = "admin-stop-main-cam", Ee = "admin-start-main-cam", he = "admin-stop-mic", me = "admin-start-mic", le = "admin-force-sync-media-state", ue = "participant:added-to-list-moderators", pe = "participant:removed-from-list-moderators", ge = "participant:move-request-to-stream", _e = "participant:move-request-to-spectators", Te = "participant:move-request-to-participants", Ie = "participation:accepting-word-request", we = "participation:cancelling-word-request", Se = "webcast:started", Ne = "webcast:stopped", fe = "account:changed", Ce = "account:deleted", Re = "conference:participant-token-issued", Me = "ended", Ae = "sending", Oe = "reinvite", Pe = "replaces", ve = "refer", De = "progress", ye = "accepted", Le = "confirmed", Fe = "peerconnection", be = "failed", Ve = "muted", ke = "unmuted", We = "newDTMF", Ue = "newInfo", Ge = "hold", He = "unhold", xe = "update", qe = "sdp", Ye = "icecandidate", je = "getusermediafailed", ze = "peerconnection:createofferfailed", Be = "peerconnection:createanswerfailed", Je = "peerconnection:setlocaldescriptionfailed", Ke = "peerconnection:setremotedescriptionfailed", $e = "presentation:start", Qe = "presentation:started", Xe = "presentation:end", Ze = "presentation:ended", et = "presentation:failed", tt = [
19
- U,
20
- G,
21
- x,
22
- H,
23
- Ie,
24
- we,
25
- ge,
26
- ie,
27
- Re,
28
- fe,
29
- Ce,
30
- Se,
31
- Ne,
32
- ue,
33
- pe
34
- ], A = [
35
- M,
36
- q,
37
- Y,
38
- j,
39
- z,
40
- B,
41
- J,
42
- K,
43
- $
44
- ], rt = [
45
- Q,
46
- X,
47
- Z,
48
- ee,
49
- te,
50
- re,
51
- ne,
52
- oe,
53
- se,
54
- ae,
55
- ce,
56
- Ee,
57
- de,
58
- he,
59
- me,
60
- le,
61
- _e,
62
- Te
63
- ], nt = [
64
- Me,
65
- M,
66
- Ae,
67
- Oe,
68
- Pe,
69
- ve,
70
- De,
71
- ye,
72
- Le,
73
- Fe,
74
- be,
75
- Ve,
76
- ke,
77
- We,
78
- Ue,
79
- Ge,
80
- He,
81
- xe,
82
- qe,
83
- Ye,
84
- je,
85
- ze,
86
- Be,
87
- Je,
88
- Ke,
89
- $e,
90
- Qe,
91
- Xe,
92
- Ze,
93
- et
94
- ];
95
- [...A, ...tt];
96
- const ot = [
97
- ...nt,
98
- ...rt
99
- ];
100
- class st {
18
+ class F {
101
19
  originator;
102
20
  connection;
103
21
  events;
@@ -105,10 +23,9 @@ class st {
105
23
  mutedOptions = { audio: !1, video: !1 };
106
24
  constructor({
107
25
  originator: e = "local",
108
- eventHandlers: t,
109
- remoteIdentity: r
26
+ eventHandlers: t
110
27
  }) {
111
- this.originator = e, this.events = new R(ot), this.initEvents(t), this.remote_identity = r;
28
+ this.originator = e, this.events = new R(N), this.initEvents(t);
112
29
  }
113
30
  get contact() {
114
31
  throw new Error("Method not implemented.");
@@ -203,10 +120,10 @@ class st {
203
120
  throw new Error("Method not implemented.");
204
121
  }
205
122
  off(e, t) {
206
- return this.events.off(e, t), this;
123
+ throw new Error("Method not implemented.");
207
124
  }
208
125
  removeAllListeners(e) {
209
- return console.warn("Method not implemented. Event:", e), this;
126
+ throw new Error("Method not implemented.");
210
127
  }
211
128
  setMaxListeners(e) {
212
129
  throw new Error("Method not implemented.");
@@ -236,7 +153,7 @@ class st {
236
153
  throw new Error("Method not implemented.");
237
154
  }
238
155
  initEvents(e) {
239
- e && Object.entries(e).forEach(([t, r]) => this.on(t, r));
156
+ Object.entries(e).forEach(([t, r]) => this.on(t, r));
240
157
  }
241
158
  // @ts-expect-error
242
159
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
@@ -257,16 +174,19 @@ class st {
257
174
  this.trigger("newDTMF", { originator: this.originator });
258
175
  }
259
176
  async startPresentation(e) {
260
- return this.trigger("presentation:start", e), this.trigger("presentation:started", e), e;
177
+ return e;
178
+ }
179
+ async updatePresentation(e) {
180
+ return e;
261
181
  }
262
182
  async stopPresentation(e) {
263
- return this.trigger("presentation:end", e), this.trigger("presentation:ended", e), e;
183
+ return e;
264
184
  }
265
185
  isEstablished() {
266
186
  return !0;
267
187
  }
268
188
  }
269
- class it {
189
+ class x {
270
190
  dtmf = null;
271
191
  track = null;
272
192
  transport = null;
@@ -309,7 +229,7 @@ class it {
309
229
  throw new Error("Method not implemented.");
310
230
  }
311
231
  }
312
- class at {
232
+ class U {
313
233
  senders = [];
314
234
  receivers = [];
315
235
  canTrickleIceCandidates;
@@ -390,10 +310,10 @@ class at {
390
310
  throw new Error("Method not implemented.");
391
311
  }
392
312
  addEventListener(e, t, r) {
393
- console.warn("Method not implemented. Type:", e);
313
+ throw new Error("Method not implemented.");
394
314
  }
395
315
  removeEventListener(e, t, r) {
396
- console.warn("Method not implemented. Type:", e);
316
+ throw new Error("Method not implemented.");
397
317
  }
398
318
  dispatchEvent(e) {
399
319
  throw new Error("Method not implemented.");
@@ -401,19 +321,18 @@ class at {
401
321
  getReceivers = () => this.receivers;
402
322
  getSenders = () => this.senders;
403
323
  addTrack = (e) => {
404
- const t = new it({ track: e });
324
+ const t = new x({ track: e });
405
325
  return this.senders.push(t), t;
406
326
  };
407
327
  }
408
- function ct(n) {
328
+ function H(n) {
409
329
  const e = n.match(/(purgatory)|[\d.]+/g);
410
330
  if (!e)
411
331
  throw new Error("wrong sip url");
412
332
  return e[0];
413
333
  }
414
- const u = 400, dt = "777", Et = (n) => n.getVideoTracks().length > 0;
415
- class s extends st {
416
- static presentationError;
334
+ const l = 400, z = "777", Y = (n) => n.getVideoTracks().length > 0;
335
+ class s extends F {
417
336
  static startPresentationError;
418
337
  static countStartPresentationError = Number.POSITIVE_INFINITY;
419
338
  static countStartsPresentation = 0;
@@ -437,29 +356,16 @@ class s extends st {
437
356
  }, 100), setTimeout(() => {
438
357
  this.trigger("confirmed");
439
358
  }, 200);
440
- }, u);
441
- });
442
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
443
- replaceMediaStream = jest.fn(async (e) => {
359
+ }, l);
444
360
  });
445
361
  isEndedInner = !1;
446
362
  constructor({
447
363
  url: e = "",
448
364
  mediaStream: t,
449
365
  eventHandlers: r,
450
- originator: i,
451
- remoteIdentity: a = new V(
452
- new E("sip", "caller1", "test1.com", 5060),
453
- "Test Caller 1"
454
- )
366
+ originator: o
455
367
  }) {
456
- super({ originator: i, eventHandlers: r, remoteIdentity: a }), this.url = e, this.initPeerconnection(t);
457
- }
458
- static setPresentationError(e) {
459
- this.presentationError = e;
460
- }
461
- static resetPresentationError() {
462
- this.presentationError = void 0;
368
+ super({ originator: o, eventHandlers: r }), this.url = e, this.initPeerconnection(t);
463
369
  }
464
370
  static setStartPresentationError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
465
371
  this.startPresentationError = e, this.countStartPresentationError = t;
@@ -467,54 +373,41 @@ class s extends st {
467
373
  static resetStartPresentationError() {
468
374
  this.startPresentationError = void 0, this.countStartPresentationError = Number.POSITIVE_INFINITY, this.countStartsPresentation = 0;
469
375
  }
470
- startPresentation = async (e) => {
471
- if (s.countStartsPresentation += 1, s.presentationError)
472
- throw this.trigger("presentation:start", e), this.trigger("presentation:failed", e), s.presentationError;
473
- if (s.startPresentationError && s.countStartsPresentation < s.countStartPresentationError)
474
- throw this.trigger("presentation:start", e), this.trigger("presentation:failed", e), s.startPresentationError;
376
+ async startPresentation(e) {
377
+ if (s.countStartsPresentation += 1, s.startPresentationError && s.countStartsPresentation < s.countStartPresentationError)
378
+ throw s.startPresentationError;
475
379
  return super.startPresentation(e);
476
- };
477
- stopPresentation = async (e) => {
478
- if (s.presentationError)
479
- throw this.trigger("presentation:end", e), this.trigger("presentation:failed", e), s.presentationError;
480
- return super.stopPresentation(e);
481
- };
380
+ }
482
381
  initPeerconnection(e) {
483
382
  return e ? (this.createPeerconnection(e), !0) : !1;
484
383
  }
485
384
  createPeerconnection(e) {
486
- const t = k();
385
+ const t = W();
487
386
  t.id = "mainaudio1";
488
387
  const r = [t];
489
- if (Et(e)) {
490
- const a = W();
388
+ if (Y(e)) {
389
+ const a = V();
491
390
  a.id = "mainvideo1", r.push(a);
492
391
  }
493
- this.connection = new at(void 0, r), this.addStream(e), setTimeout(() => {
392
+ this.connection = new U(void 0, r), this.addStream(e), setTimeout(() => {
494
393
  this.trigger("peerconnection", { peerconnection: this.connection });
495
- }, u);
394
+ }, l);
496
395
  }
497
396
  connect(e) {
498
- const t = ct(e);
397
+ const t = H(e);
499
398
  setTimeout(() => {
500
- this.url.includes(dt) ? this.trigger("failed", {
399
+ this.url.includes(z) ? this.trigger("failed", {
501
400
  originator: "remote",
502
401
  message: "IncomingResponse",
503
- cause: "Rejected"
402
+ cause: P
504
403
  }) : (this.trigger("connecting"), setTimeout(() => {
505
- this.newInfo({
506
- originator: v.REMOTE,
507
- // @ts-expect-error
508
- request: {
509
- getHeader: (r) => r === "content-type" ? "application/vinteo.webrtc.roomname" : r === "x-webrtc-enter-room" ? t : r === "x-webrtc-participant-name" ? "Test Caller 1" : ""
510
- }
511
- });
404
+ this.trigger("enterRoom", { room: t });
512
405
  }, 100), setTimeout(() => {
513
406
  this.trigger("accepted");
514
407
  }, 200), setTimeout(() => {
515
408
  this.trigger("confirmed");
516
409
  }, 300));
517
- }, u);
410
+ }, l);
518
411
  }
519
412
  terminate({ status_code: e, cause: t } = {}) {
520
413
  return this.status_code = e, this.trigger("ended", { status_code: e, cause: t, originator: "local" }), this.isEndedInner = !1, this;
@@ -559,6 +452,9 @@ class s extends st {
559
452
  isMuted() {
560
453
  return this.mutedOptions;
561
454
  }
455
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, class-methods-use-this
456
+ async replaceMediaStream(e) {
457
+ }
562
458
  onmute({ audio: e, video: t }) {
563
459
  this.trigger("muted", {
564
460
  audio: e,
@@ -576,7 +472,7 @@ class s extends st {
576
472
  }
577
473
  /* eslint-enable no-param-reassign */
578
474
  }
579
- class ht {
475
+ class q {
580
476
  extraHeaders = [];
581
477
  setExtraHeaders(e) {
582
478
  this.extraHeaders = e;
@@ -585,56 +481,31 @@ class ht {
585
481
  setExtraContactParams() {
586
482
  }
587
483
  }
588
- const c = "PASSWORD_CORRECT", N = "PASSWORD_CORRECT_2", mt = "NAME_INCORRECT", d = 400, p = {
484
+ const d = "PASSWORD_CORRECT", M = "PASSWORD_CORRECT_2", G = "NAME_INCORRECT", c = 400, p = {
589
485
  url: "wss://sipServerUrl/webrtc/wss/",
590
486
  sip_uri: "sip:sipServerUrl;transport=ws",
591
487
  via_transport: "WSS"
592
- }, f = {
488
+ }, v = {
593
489
  status_code: 200,
594
490
  reason_phrase: "OK"
595
- }, C = {
491
+ }, T = {
596
492
  status_code: 401,
597
493
  reason_phrase: "Unauthorized"
598
494
  };
599
- class o {
495
+ class i {
600
496
  static isAvailableTelephony = !0;
601
497
  static startError;
602
498
  static countStartError = Number.POSITIVE_INFINITY;
603
499
  static countStarts = 0;
604
500
  events;
605
501
  registratorInner;
606
- // @ts-expect-error – Jest создаёт функцию-замок.
502
+ // @ts-expect-error
607
503
  call = jest.fn(
608
504
  (e, t) => {
609
- const { mediaStream: r, eventHandlers: i } = t;
610
- return this.session = new s({ url: e, mediaStream: r, eventHandlers: i, originator: "local" }), this.session.connect(e), this.session;
611
- }
612
- );
613
- sendOptions = jest.fn(
614
- (e, t, r) => {
615
- console.log("sendOptions", e, t, r);
505
+ const { mediaStream: r, eventHandlers: o } = t;
506
+ return this.session = new s({ url: e, mediaStream: r, eventHandlers: o, originator: "local" }), this.session.connect(e), this.session;
616
507
  }
617
508
  );
618
- /**
619
- * start – имитирует запуск UA.
620
- */
621
- start = jest.fn(() => {
622
- if (o.countStarts += 1, o.startError && o.countStarts < o.countStartError) {
623
- this.trigger("disconnected", o.startError);
624
- return;
625
- }
626
- this.register();
627
- });
628
- /**
629
- * stop – имитирует остановку UA.
630
- */
631
- stop = jest.fn(() => {
632
- this.startedTimeout && clearTimeout(this.startedTimeout), this.stopedTimeout && clearTimeout(this.stopedTimeout), this.unregister(), this.isStarted() ? this.stopedTimeout = setTimeout(() => {
633
- this.trigger("disconnected", { error: !0, socket: p });
634
- }, d) : this.trigger("disconnected", { error: !0, socket: p });
635
- });
636
- removeAllListeners = jest.fn(() => (this.events.removeEventHandlers(), this));
637
- once = jest.fn((e, t) => (this.events.once(e, t), this));
638
509
  startedTimeout;
639
510
  stopedTimeout;
640
511
  session;
@@ -642,34 +513,59 @@ class o {
642
513
  isConnectedInner;
643
514
  configuration;
644
515
  constructor(e) {
645
- this.events = new R(A);
646
- const [t, r] = e.uri.split(":"), [i, a] = r.split("@"), l = {
516
+ this.events = new R(O);
517
+ const [t, r] = e.uri.split(":"), [o, a] = r.split("@"), u = {
647
518
  ...e,
648
- uri: new E(t, i, a)
519
+ uri: new w(t, o, a)
649
520
  };
650
- this.configuration = l, this.registratorInner = new ht();
521
+ this.configuration = u, this.registratorInner = new q();
651
522
  }
652
523
  static setStartError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
653
- o.startError = e, o.countStartError = t;
524
+ this.startError = e, this.countStartError = t;
654
525
  }
655
526
  static resetStartError() {
656
- o.startError = void 0, o.countStartError = Number.POSITIVE_INFINITY, o.countStarts = 0;
527
+ this.startError = void 0, this.countStartError = Number.POSITIVE_INFINITY, this.countStarts = 0;
657
528
  }
658
529
  static setAvailableTelephony() {
659
- o.isAvailableTelephony = !0;
530
+ this.isAvailableTelephony = !0;
660
531
  }
661
532
  static setNotAvailableTelephony() {
662
- o.isAvailableTelephony = !1;
533
+ this.isAvailableTelephony = !1;
663
534
  }
664
- static reset() {
665
- o.resetStartError(), o.setAvailableTelephony();
535
+ /**
536
+ * start
537
+ *
538
+ * @returns {undefined}
539
+ */
540
+ start() {
541
+ if (i.countStarts += 1, i.startError && i.countStarts < i.countStartError) {
542
+ this.trigger("disconnected", i.startError);
543
+ return;
544
+ }
545
+ this.register();
546
+ }
547
+ /**
548
+ * stop
549
+ *
550
+ * @returns {undefined}
551
+ */
552
+ stop() {
553
+ this.startedTimeout && clearTimeout(this.startedTimeout), this.stopedTimeout && clearTimeout(this.stopedTimeout), this.unregister(), this.isStarted() ? this.stopedTimeout = setTimeout(() => {
554
+ this.trigger("disconnected", { error: !0, socket: p });
555
+ }, c) : this.trigger("disconnected", { error: !0, socket: p });
666
556
  }
667
557
  on(e, t) {
668
558
  return this.events.on(e, t), this;
669
559
  }
560
+ once(e, t) {
561
+ return this.events.once(e, t), this;
562
+ }
670
563
  off(e, t) {
671
564
  return this.events.off(e, t), this;
672
565
  }
566
+ removeAllListeners() {
567
+ return this.events.removeEventHandlers(), this;
568
+ }
673
569
  trigger(e, t) {
674
570
  this.events.trigger(e, t);
675
571
  }
@@ -692,13 +588,13 @@ class o {
692
588
  register() {
693
589
  this.startedTimeout && clearTimeout(this.startedTimeout);
694
590
  const { password: e, register: t, uri: r } = this.configuration;
695
- t === !0 && r.user.includes(mt) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
696
- this.trigger("registrationFailed", { response: C, cause: S.causes.REJECTED });
697
- }, d)) : !this.isRegistered() && t === !0 && (e === c || e === N) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
698
- this.trigger("registered", { response: f });
699
- }, d)) : t === !0 && e !== c && e !== N && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
700
- this.trigger("registrationFailed", { response: C, cause: S.causes.REJECTED });
701
- }, d)), o.isAvailableTelephony ? (this.trigger("connected", { socket: p }), this.isConnectedInner = !0) : this.stop();
591
+ t === !0 && r.user.includes(G) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
592
+ this.trigger("registrationFailed", { response: T, cause: I.causes.REJECTED });
593
+ }, c)) : !this.isRegistered() && t === !0 && (e === d || e === M) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
594
+ this.trigger("registered", { response: v });
595
+ }, c)) : t === !0 && e !== d && e !== M && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
596
+ this.trigger("registrationFailed", { response: T, cause: I.causes.REJECTED });
597
+ }, c)), i.isAvailableTelephony ? (this.trigger("connected", { socket: p }), this.isConnectedInner = !0) : this.stop();
702
598
  }
703
599
  /**
704
600
  * unregister
@@ -706,7 +602,7 @@ class o {
706
602
  * @returns {undefined}
707
603
  */
708
604
  unregister() {
709
- this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: f });
605
+ this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: v });
710
606
  }
711
607
  isRegistered() {
712
608
  return this.isRegisteredInner === !0;
@@ -729,122 +625,121 @@ class o {
729
625
  return this.registratorInner;
730
626
  }
731
627
  }
732
- class lt {
628
+ class J {
733
629
  url;
734
630
  constructor(e) {
735
631
  this.url = e;
736
632
  }
737
633
  }
738
- class ut extends F {
634
+ class $ extends D {
739
635
  contentType;
740
636
  body;
741
637
  constructor(e, t) {
742
638
  super(), this.contentType = e, this.body = t;
743
639
  }
744
640
  }
745
- const g = "remote", pt = (n, e) => {
746
- const t = new _(e), r = {
641
+ const g = "remote", j = (n, e) => {
642
+ const t = new E(e), r = {
747
643
  originator: g,
748
644
  request: t,
749
- info: new ut("", "")
645
+ info: new $("", "")
750
646
  };
751
647
  n.newInfo(r);
752
- }, gt = (n, e) => {
753
- const r = { event: "sipEvent", request: new _(e) };
648
+ }, B = (n, e) => {
649
+ const r = { event: "sipEvent", request: new E(e) };
754
650
  n.newSipEvent(r);
755
- }, _t = (n, {
651
+ }, K = (n, {
756
652
  incomingNumber: e = "1234",
757
653
  displayName: t,
758
654
  host: r
759
655
  }) => {
760
- const i = new s({ originator: g, eventHandlers: {} }), a = new L("sip", e, r);
761
- i.remote_identity = new y(a, t);
762
- const l = new _([]);
656
+ const o = new s({ originator: g, eventHandlers: {} }), a = new b("sip", e, r);
657
+ o.remote_identity = new A(a, t);
658
+ const u = new E([]);
763
659
  n.trigger("newRTCSession", {
764
660
  originator: g,
765
- session: i,
766
- request: l
661
+ session: o,
662
+ request: u
767
663
  });
768
- }, Tt = (n, e) => {
664
+ }, X = (n, e) => {
769
665
  e ? n.trigger("failed", e) : n.trigger("failed", n);
770
- }, O = {
771
- triggerNewInfo: pt,
772
- triggerNewSipEvent: gt,
773
- triggerIncomingSession: _t,
774
- triggerFailIncomingSession: Tt,
775
- WebSocketInterface: lt,
776
- UA: o,
666
+ }, C = {
667
+ triggerNewInfo: j,
668
+ triggerNewSipEvent: B,
669
+ triggerIncomingSession: K,
670
+ triggerFailIncomingSession: X,
671
+ WebSocketInterface: J,
672
+ UA: i,
777
673
  C: {
778
674
  INVITE: "INVITE"
779
675
  }
780
- }, T = "user", h = "displayName", I = "SIP_SERVER_URL", P = "SIP_WEB_SOCKET_SERVER_URL", It = new O.WebSocketInterface(P), w = {
676
+ }, f = "user", h = "displayName", _ = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", Q = new C.WebSocketInterface(y), S = {
781
677
  userAgent: "Chrome",
782
- sipServerUrl: I,
783
- sipWebSocketServerURL: P
784
- }, vt = {
785
- ...w
786
- }, wt = {
787
- ...w,
788
- user: T,
789
- password: c,
678
+ sipServerUrl: _,
679
+ sipWebSocketServerURL: y
680
+ }, ce = {
681
+ ...S
682
+ }, Z = {
683
+ ...S,
684
+ user: f,
685
+ password: d,
790
686
  register: !0
791
- }, Dt = {
792
- ...wt,
687
+ }, he = {
688
+ ...Z,
793
689
  displayName: h
794
- }, yt = {
795
- ...w,
690
+ }, me = {
691
+ ...S,
796
692
  displayName: h,
797
693
  register: !1
798
694
  }, m = {
799
695
  session_timers: !1,
800
- sockets: [It],
696
+ sockets: [Q],
801
697
  user_agent: "Chrome",
802
- sdpSemantics: "unified-plan",
698
+ sdp_semantics: "unified-plan",
803
699
  register_expires: 300,
804
700
  connection_recovery_max_interval: 6,
805
701
  connection_recovery_min_interval: 2
806
- }, Lt = {
702
+ }, ue = {
807
703
  ...m,
808
- password: c,
809
- uri: new E("sip", T, I),
704
+ password: d,
705
+ uri: new w("sip", f, _),
810
706
  display_name: "",
811
707
  register: !0
812
- }, Ft = {
708
+ }, le = {
813
709
  ...m,
814
- password: c,
815
- uri: new E("sip", T, I),
710
+ password: d,
711
+ uri: new w("sip", f, _),
816
712
  display_name: h,
817
713
  register: !0
818
- }, bt = {
714
+ }, pe = {
819
715
  ...m,
820
716
  display_name: h,
821
717
  register: !1
822
- }, Vt = {
718
+ }, ge = {
823
719
  ...m,
824
720
  display_name: "",
825
721
  register: !1
826
- }, St = "10.10.10.10", kt = [`X-Vinteo-Remote: ${St}`], Wt = () => new D({
827
- JsSIP: O
722
+ }, ee = "10.10.10.10", we = [`X-Vinteo-Remote: ${ee}`], Ee = () => new k({
723
+ JsSIP: C
828
724
  });
829
725
  export {
830
- dt as FAILED_CONFERENCE_NUMBER,
831
- O as JsSIP,
832
- mt as NAME_INCORRECT,
833
- c as PASSWORD_CORRECT,
834
- N as PASSWORD_CORRECT_2,
835
- I as SIP_SERVER_URL,
836
- P as SIP_WEB_SOCKET_SERVER_URL,
837
- wt as dataForConnectionWithAuthorization,
838
- Dt as dataForConnectionWithAuthorizationWithDisplayName,
839
- yt as dataForConnectionWithoutAuthorization,
840
- vt as dataForConnectionWithoutAuthorizationWithoutDisplayName,
726
+ z as FAILED_CONFERENCE_NUMBER,
727
+ G as NAME_INCORRECT,
728
+ d as PASSWORD_CORRECT,
729
+ M as PASSWORD_CORRECT_2,
730
+ _ as SIP_SERVER_URL,
731
+ y as SIP_WEB_SOCKET_SERVER_URL,
732
+ Z as dataForConnectionWithAuthorization,
733
+ he as dataForConnectionWithAuthorizationWithDisplayName,
734
+ me as dataForConnectionWithoutAuthorization,
735
+ ce as dataForConnectionWithoutAuthorizationWithoutDisplayName,
841
736
  h as displayName,
842
- Wt as doMockSipConnector,
843
- kt as extraHeadersRemoteAddress,
844
- St as remoteAddress,
845
- Lt as uaConfigurationWithAuthorization,
846
- Ft as uaConfigurationWithAuthorizationWithDisplayName,
847
- bt as uaConfigurationWithoutAuthorization,
848
- Vt as uaConfigurationWithoutAuthorizationWithoutDisplayName,
849
- T as user
737
+ Ee as doMockSipConnector,
738
+ we as extraHeadersRemoteAddress,
739
+ ee as remoteAddress,
740
+ ue as uaConfigurationWithAuthorization,
741
+ le as uaConfigurationWithAuthorizationWithDisplayName,
742
+ pe as uaConfigurationWithoutAuthorization,
743
+ ge as uaConfigurationWithoutAuthorizationWithoutDisplayName,
744
+ f as user
850
745
  };