sip-connector 14.0.1-0 → 14.1.0-alpha.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 (127) hide show
  1. package/dist/ApiManager/@ApiManager.d.ts +58 -0
  2. package/dist/ApiManager/constants.d.ts +71 -0
  3. package/dist/ApiManager/eventNames.d.ts +33 -0
  4. package/dist/ApiManager/index.d.ts +2 -0
  5. package/dist/ApiManager/types.d.ts +99 -0
  6. package/dist/CallManager/@CallManager.d.ts +26 -0
  7. package/dist/CallManager/AbstractCallStrategy.d.ts +47 -0
  8. package/dist/CallManager/MCUCallStrategy.d.ts +30 -0
  9. package/dist/CallManager/RemoteStreamsManager.d.ts +8 -0
  10. package/dist/CallManager/causes.d.ts +12 -0
  11. package/dist/CallManager/eventNames.d.ts +45 -0
  12. package/dist/CallManager/hasCanceledCallError.d.ts +2 -0
  13. package/dist/CallManager/index.d.ts +5 -0
  14. package/dist/CallManager/types.d.ts +59 -0
  15. package/dist/ConnectionManager/@ConnectionManager.d.ts +47 -0
  16. package/dist/ConnectionManager/ConfigurationManager.d.ts +60 -0
  17. package/dist/ConnectionManager/ConnectionFlow.d.ts +83 -0
  18. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +61 -0
  19. package/dist/ConnectionManager/RegistrationManager.d.ts +17 -0
  20. package/dist/ConnectionManager/SipOperations.d.ts +32 -0
  21. package/dist/ConnectionManager/UAFactory.d.ts +50 -0
  22. package/dist/ConnectionManager/eventNames.d.ts +16 -0
  23. package/dist/ConnectionManager/index.d.ts +3 -0
  24. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +36 -0
  25. package/dist/IncomingCallManager/eventNames.d.ts +13 -0
  26. package/dist/IncomingCallManager/index.d.ts +2 -0
  27. package/dist/PresentationManager/@PresentationManager.d.ts +47 -0
  28. package/dist/PresentationManager/constants.d.ts +1 -0
  29. package/dist/PresentationManager/eventNames.d.ts +11 -0
  30. package/dist/PresentationManager/index.d.ts +1 -0
  31. package/dist/PresentationManager/types.d.ts +2 -0
  32. package/dist/SipConnector-CK3GgjXE.js +2492 -0
  33. package/dist/SipConnector-CwI8aFEA.cjs +1 -0
  34. package/dist/SipConnector.d.ts +107 -0
  35. package/dist/{src/SipConnectorFacade → SipConnectorFacade}/SipConnectorFacade.d.ts +34 -25
  36. package/dist/{src/__fixtures__ → __fixtures__}/BaseSession.mock.d.ts +9 -9
  37. package/dist/{src/__fixtures__ → __fixtures__}/RTCSessionMock.d.ts +25 -20
  38. package/dist/{src/__fixtures__ → __fixtures__}/UA.mock.d.ts +23 -25
  39. package/dist/{src/__fixtures__ → __fixtures__}/index.d.ts +4 -4
  40. package/dist/{src/__fixtures__ → __fixtures__}/jssip.mock.d.ts +3 -3
  41. package/dist/doMock.cjs +1 -1
  42. package/dist/{src/doMock.d.ts → doMock.d.ts} +1 -0
  43. package/dist/doMock.js +248 -217
  44. package/dist/index.cjs +1 -1
  45. package/dist/{src/index.d.ts → index.d.ts} +3 -1
  46. package/dist/index.js +529 -436
  47. package/dist/{src/tools → tools}/__fixtures__/connectToServer.d.ts +2 -2
  48. package/dist/{src/tools → tools}/index.d.ts +2 -2
  49. package/dist/{src/tools/sendDTMFAccumulated.d.ts → tools/sendDtmfFAccumulated.d.ts} +2 -2
  50. package/package.json +27 -33
  51. package/dist/SipConnector-CJN8qKAC.js +0 -1316
  52. package/dist/SipConnector-DO0YvSq6.cjs +0 -1
  53. package/dist/src/SipConnector.d.ts +0 -301
  54. package/dist/{src/SipConnectorFacade → SipConnectorFacade}/index.d.ts +0 -0
  55. package/dist/{src/__fixtures__ → __fixtures__}/RTCPeerConnectionMock.d.ts +1 -1
  56. /package/dist/{src/__fixtures__ → __fixtures__}/RTCRtpSenderMock.d.ts +0 -0
  57. /package/dist/{src/__fixtures__ → __fixtures__}/Registrator.mock.d.ts +0 -0
  58. /package/dist/{src/__fixtures__ → __fixtures__}/Request.mock.d.ts +0 -0
  59. /package/dist/{src/__fixtures__ → __fixtures__}/WebSocketInterface.mock.d.ts +0 -0
  60. /package/dist/{src/__fixtures__ → __fixtures__}/accountNotify.d.ts +0 -0
  61. /package/dist/{src/__fixtures__ → __fixtures__}/channels.d.ts +0 -0
  62. /package/dist/{src/__fixtures__ → __fixtures__}/channelsNotify.d.ts +0 -0
  63. /package/dist/{src/__fixtures__ → __fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
  64. /package/dist/{src/__fixtures__ → __fixtures__}/delayPromise.d.ts +0 -0
  65. /package/dist/{src/__fixtures__ → __fixtures__}/enterRoom.d.ts +0 -0
  66. /package/dist/{src/__fixtures__ → __fixtures__}/mediaState.d.ts +0 -0
  67. /package/dist/{src/__fixtures__ → __fixtures__}/participantMoveRequests.d.ts +0 -0
  68. /package/dist/{src/__fixtures__ → __fixtures__}/participantNotify.d.ts +0 -0
  69. /package/dist/{src/__fixtures__ → __fixtures__}/remoteCallerData.d.ts +0 -0
  70. /package/dist/{src/__fixtures__ → __fixtures__}/utils.d.ts +0 -0
  71. /package/dist/{src/__fixtures__ → __fixtures__}/webcastNotify.d.ts +0 -0
  72. /package/dist/{src/causes.d.ts → causes.d.ts} +0 -0
  73. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  74. /package/dist/{src/eventNames.d.ts → eventNames.d.ts} +0 -0
  75. /package/dist/{src/getExtraHeadersRemoteAddress.d.ts → getExtraHeadersRemoteAddress.d.ts} +0 -0
  76. /package/dist/{src/headers.d.ts → headers.d.ts} +0 -0
  77. /package/dist/{src/logger.d.ts → logger.d.ts} +0 -0
  78. /package/dist/{src/setParametersToSender → setParametersToSender}/configureDegradationPreference.d.ts +0 -0
  79. /package/dist/{src/setParametersToSender → setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
  80. /package/dist/{src/setParametersToSender → setParametersToSender}/configureEncodings.d.ts +0 -0
  81. /package/dist/{src/setParametersToSender → setParametersToSender}/configureMaxBitrate.d.ts +0 -0
  82. /package/dist/{src/setParametersToSender → setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
  83. /package/dist/{src/setParametersToSender → setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
  84. /package/dist/{src/setParametersToSender → setParametersToSender}/index.d.ts +0 -0
  85. /package/dist/{src/setParametersToSender → setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
  86. /package/dist/{src/setParametersToSender → setParametersToSender}/setParametersToSender.d.ts +0 -0
  87. /package/dist/{src/tools → tools}/__fixtures__/call.d.ts +0 -0
  88. /package/dist/{src/tools → tools}/__fixtures__/hasValidUri.d.ts +0 -0
  89. /package/dist/{src/tools → tools}/__fixtures__/permissions.d.ts +0 -0
  90. /package/dist/{src/tools → tools}/__fixtures__/processRequest.d.ts +0 -0
  91. /package/dist/{src/tools → tools}/__tests-utils__/parseObject.d.ts +0 -0
  92. /package/dist/{src/tools → tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
  93. /package/dist/{src/tools → tools}/error/getLinkError.d.ts +0 -0
  94. /package/dist/{src/tools → tools}/error/getTypeFromError.d.ts +0 -0
  95. /package/dist/{src/tools → tools}/error/getValuesFromError.d.ts +0 -0
  96. /package/dist/{src/tools → tools}/error/index.d.ts +0 -0
  97. /package/dist/{src/tools → tools}/error/stringifyMessage.d.ts +0 -0
  98. /package/dist/{src/tools → tools}/generateSimulcastEncodings.d.ts +0 -0
  99. /package/dist/{src/tools → tools}/getExtraHeaders.d.ts +0 -0
  100. /package/dist/{src/tools → tools}/getUserAgent.d.ts +0 -0
  101. /package/dist/{src/tools → tools}/hasPurgatory.d.ts +0 -0
  102. /package/dist/{src/tools → tools}/prepareMediaStream.d.ts +0 -0
  103. /package/dist/{src/tools → tools}/resolveUpdateTransceiver.d.ts +0 -0
  104. /package/dist/{src/tools → tools}/setVideoTrackContentHints.d.ts +0 -0
  105. /package/dist/{src/tools → tools}/syncMediaState/index.d.ts +0 -0
  106. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
  107. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
  108. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
  109. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
  110. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
  111. /package/dist/{src/utils → utils}/errors.d.ts +0 -0
  112. /package/dist/{src/utils → utils}/findSenderByStream.d.ts +0 -0
  113. /package/dist/{src/utils → utils}/findVideoSender.d.ts +0 -0
  114. /package/dist/{src/utils → utils}/findVideoTrack.d.ts +0 -0
  115. /package/dist/{src/utils → utils}/getCodecFromSender.d.ts +0 -0
  116. /package/dist/{src/utils → utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
  117. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/balance.d.ts +0 -0
  118. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
  119. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
  120. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
  121. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/hasIncludesString.d.ts +0 -0
  122. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/index.d.ts +0 -0
  123. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/processSender.d.ts +0 -0
  124. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleBitrate.d.ts +0 -0
  125. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
  126. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
  127. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
package/dist/doMock.js CHANGED
@@ -1,12 +1,12 @@
1
- import { n as N, R as P, U as O, S as k } from "./SipConnector-CJN8qKAC.js";
1
+ import { f as P, R as N, g as O, U as b, S as k } from "./SipConnector-CK3GgjXE.js";
2
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";
3
+ import D from "@krivega/jssip/lib/URI";
4
+ import { EventEmitter as L } from "node:events";
5
+ import { IncomingRequest as W } from "@krivega/jssip/lib/SIPMessage";
6
+ import { NameAddrHeader as V, URI as h, C as _ } from "@krivega/jssip";
7
+ import { createAudioMediaStreamTrackMock as F, createVideoMediaStreamTrackMock as x } from "webrtc-mock";
7
8
  import R from "events-constructor";
8
- import { URI as w, C as I } from "@krivega/jssip";
9
- class E extends L {
9
+ class w extends W {
10
10
  headers;
11
11
  constructor(e) {
12
12
  super(), this.headers = new Headers(e);
@@ -15,7 +15,7 @@ class E extends L {
15
15
  return this.headers.get(e) ?? "";
16
16
  }
17
17
  }
18
- class F {
18
+ class H {
19
19
  originator;
20
20
  connection;
21
21
  events;
@@ -23,43 +23,44 @@ class F {
23
23
  mutedOptions = { audio: !1, video: !1 };
24
24
  constructor({
25
25
  originator: e = "local",
26
- eventHandlers: t
26
+ eventHandlers: t,
27
+ remoteIdentity: r
27
28
  }) {
28
- this.originator = e, this.events = new R(N), this.initEvents(t);
29
+ this.originator = e, this.events = new R(P), this.initEvents(t), this.remote_identity = r;
29
30
  }
30
- // @ts-expect-error
31
- get C() {
31
+ get contact() {
32
32
  throw new Error("Method not implemented.");
33
33
  }
34
- // @ts-expect-error
35
- get causes() {
34
+ get direction() {
36
35
  throw new Error("Method not implemented.");
37
36
  }
38
- get id() {
37
+ get local_identity() {
39
38
  throw new Error("Method not implemented.");
40
39
  }
41
- set data(e) {
40
+ get start_time() {
42
41
  throw new Error("Method not implemented.");
43
42
  }
44
- get data() {
43
+ get end_time() {
45
44
  throw new Error("Method not implemented.");
46
45
  }
47
- get contact() {
46
+ get status() {
48
47
  throw new Error("Method not implemented.");
49
48
  }
50
- get direction() {
49
+ // @ts-expect-error
50
+ get C() {
51
51
  throw new Error("Method not implemented.");
52
52
  }
53
- get local_identity() {
53
+ // @ts-expect-error
54
+ get causes() {
54
55
  throw new Error("Method not implemented.");
55
56
  }
56
- get start_time() {
57
+ get id() {
57
58
  throw new Error("Method not implemented.");
58
59
  }
59
- get end_time() {
60
+ get data() {
60
61
  throw new Error("Method not implemented.");
61
62
  }
62
- get status() {
63
+ set data(e) {
63
64
  throw new Error("Method not implemented.");
64
65
  }
65
66
  isInProgress() {
@@ -120,10 +121,10 @@ class F {
120
121
  throw new Error("Method not implemented.");
121
122
  }
122
123
  off(e, t) {
123
- throw new Error("Method not implemented.");
124
+ return this.events.off(e, t), this;
124
125
  }
125
126
  removeAllListeners(e) {
126
- throw new Error("Method not implemented.");
127
+ return console.warn("Method not implemented. Event:", e), this;
127
128
  }
128
129
  setMaxListeners(e) {
129
130
  throw new Error("Method not implemented.");
@@ -153,7 +154,7 @@ class F {
153
154
  throw new Error("Method not implemented.");
154
155
  }
155
156
  initEvents(e) {
156
- Object.entries(e).forEach(([t, r]) => this.on(t, r));
157
+ e && Object.entries(e).forEach(([t, r]) => this.on(t, r));
157
158
  }
158
159
  // @ts-expect-error
159
160
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
@@ -174,19 +175,16 @@ class F {
174
175
  this.trigger("newDTMF", { originator: this.originator });
175
176
  }
176
177
  async startPresentation(e) {
177
- return e;
178
- }
179
- async updatePresentation(e) {
180
- return e;
178
+ return this.trigger("presentation:start", e), this.trigger("presentation:started", e), e;
181
179
  }
182
180
  async stopPresentation(e) {
183
- return e;
181
+ return this.trigger("presentation:end", e), this.trigger("presentation:ended", e), e;
184
182
  }
185
183
  isEstablished() {
186
184
  return !0;
187
185
  }
188
186
  }
189
- class x {
187
+ class j {
190
188
  dtmf = null;
191
189
  track = null;
192
190
  transport = null;
@@ -202,6 +200,7 @@ class x {
202
200
  constructor({ track: e } = {}) {
203
201
  this.track = e ?? null;
204
202
  }
203
+ // eslint-disable-next-line class-methods-use-this
205
204
  async getStats() {
206
205
  throw new Error("Method not implemented.");
207
206
  }
@@ -223,16 +222,14 @@ class x {
223
222
  getParameters() {
224
223
  return this.parametersGets = { ...this.parameters }, this.parametersGets;
225
224
  }
225
+ // eslint-disable-next-line class-methods-use-this
226
226
  setStreams() {
227
227
  throw new Error("Method not implemented.");
228
228
  }
229
229
  }
230
- class U {
230
+ class z {
231
231
  senders = [];
232
232
  receivers = [];
233
- constructor(e, t) {
234
- this.receivers = t.map((r) => ({ track: r }));
235
- }
236
233
  canTrickleIceCandidates;
237
234
  connectionState;
238
235
  currentLocalDescription;
@@ -245,6 +242,7 @@ class U {
245
242
  onconnectionstatechange;
246
243
  ondatachannel;
247
244
  onicecandidate;
245
+ // eslint-disable-next-line unicorn/no-null
248
246
  onicecandidateerror = null;
249
247
  oniceconnectionstatechange;
250
248
  onicegatheringstatechange;
@@ -255,8 +253,12 @@ class U {
255
253
  pendingLocalDescription;
256
254
  pendingRemoteDescription;
257
255
  remoteDescription;
256
+ // eslint-disable-next-line unicorn/no-null
258
257
  sctp = null;
259
258
  signalingState;
259
+ constructor(e, t) {
260
+ this.receivers = t.map((r) => ({ track: r }));
261
+ }
260
262
  getRemoteStreams() {
261
263
  throw new Error("Method not implemented.");
262
264
  }
@@ -306,10 +308,10 @@ class U {
306
308
  throw new Error("Method not implemented.");
307
309
  }
308
310
  addEventListener(e, t, r) {
309
- throw new Error("Method not implemented.");
311
+ console.warn("Method not implemented. Type:", e);
310
312
  }
311
313
  removeEventListener(e, t, r) {
312
- throw new Error("Method not implemented.");
314
+ console.warn("Method not implemented. Type:", e);
313
315
  }
314
316
  dispatchEvent(e) {
315
317
  throw new Error("Method not implemented.");
@@ -317,31 +319,65 @@ class U {
317
319
  getReceivers = () => this.receivers;
318
320
  getSenders = () => this.senders;
319
321
  addTrack = (e) => {
320
- const t = new x({ track: e });
322
+ const t = new j({ track: e });
321
323
  return this.senders.push(t), t;
322
324
  };
323
325
  }
324
- function H(n) {
326
+ function Y(n) {
325
327
  const e = n.match(/(purgatory)|[\d.]+/g);
326
328
  if (!e)
327
329
  throw new Error("wrong sip url");
328
330
  return e[0];
329
331
  }
330
- const l = 400, z = "777", Y = (n) => n.getVideoTracks().length > 0;
331
- class s extends F {
332
- url;
333
- status_code;
334
- isEndedInner = !1;
332
+ const p = 400, q = "777", J = (n) => n.getVideoTracks().length > 0;
333
+ class i extends H {
334
+ static presentationError;
335
335
  static startPresentationError;
336
336
  static countStartPresentationError = Number.POSITIVE_INFINITY;
337
337
  static countStartsPresentation = 0;
338
+ url;
339
+ status_code;
340
+ /**
341
+ * answer
342
+ *
343
+ * @param {Object} arg1 - The argument 1
344
+ * @param {Object} arg1.mediaStream - The media stream
345
+ * @param {Array} arg1.eventHandlers - The event handlers
346
+
347
+ * @returns {undefined}
348
+ */
349
+ answer = jest.fn(({ mediaStream: e }) => {
350
+ if (this.originator !== "remote")
351
+ throw new Error("answer available only for remote sessions");
352
+ this.initPeerconnection(e), setTimeout(() => {
353
+ this.trigger("connecting"), setTimeout(() => {
354
+ this.trigger("accepted");
355
+ }, 100), setTimeout(() => {
356
+ this.trigger("confirmed");
357
+ }, 200);
358
+ }, p);
359
+ });
360
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
361
+ replaceMediaStream = jest.fn(async (e) => {
362
+ });
363
+ isEndedInner = !1;
338
364
  constructor({
339
365
  url: e = "",
340
366
  mediaStream: t,
341
367
  eventHandlers: r,
342
- originator: o
368
+ originator: s,
369
+ remoteIdentity: a = new V(
370
+ new h("sip", "caller1", "test1.com", 5060),
371
+ "Test Caller 1"
372
+ )
343
373
  }) {
344
- super({ originator: o, eventHandlers: r }), this.url = e, this.initPeerconnection(t);
374
+ super({ originator: s, eventHandlers: r, remoteIdentity: a }), this.url = e, this.initPeerconnection(t);
375
+ }
376
+ static setPresentationError(e) {
377
+ this.presentationError = e;
378
+ }
379
+ static resetPresentationError() {
380
+ this.presentationError = void 0;
345
381
  }
346
382
  static setStartPresentationError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
347
383
  this.startPresentationError = e, this.countStartPresentationError = t;
@@ -349,66 +385,62 @@ class s extends F {
349
385
  static resetStartPresentationError() {
350
386
  this.startPresentationError = void 0, this.countStartPresentationError = Number.POSITIVE_INFINITY, this.countStartsPresentation = 0;
351
387
  }
352
- async startPresentation(e) {
353
- if (s.countStartsPresentation += 1, s.startPresentationError && s.countStartsPresentation < s.countStartPresentationError)
354
- throw s.startPresentationError;
388
+ startPresentation = async (e) => {
389
+ if (i.countStartsPresentation += 1, i.presentationError)
390
+ throw this.trigger("presentation:start", e), this.trigger("presentation:failed", e), i.presentationError;
391
+ if (i.startPresentationError && i.countStartsPresentation < i.countStartPresentationError)
392
+ throw this.trigger("presentation:start", e), this.trigger("presentation:failed", e), i.startPresentationError;
355
393
  return super.startPresentation(e);
356
- }
394
+ };
395
+ stopPresentation = async (e) => {
396
+ if (i.presentationError)
397
+ throw this.trigger("presentation:end", e), this.trigger("presentation:failed", e), i.presentationError;
398
+ return super.stopPresentation(e);
399
+ };
357
400
  initPeerconnection(e) {
358
401
  return e ? (this.createPeerconnection(e), !0) : !1;
359
402
  }
360
403
  createPeerconnection(e) {
361
- const t = W();
404
+ const t = F();
362
405
  t.id = "mainaudio1";
363
406
  const r = [t];
364
- if (Y(e)) {
365
- const a = V();
407
+ if (J(e)) {
408
+ const a = x();
366
409
  a.id = "mainvideo1", r.push(a);
367
410
  }
368
- this.connection = new U(void 0, r), this.addStream(e), setTimeout(() => {
411
+ this.connection = new z(void 0, r), this.addStream(e), setTimeout(() => {
369
412
  this.trigger("peerconnection", { peerconnection: this.connection });
370
- }, l);
413
+ }, p);
371
414
  }
372
415
  connect(e) {
373
- const t = H(e);
416
+ const t = Y(e);
374
417
  setTimeout(() => {
375
- this.url.includes(z) ? this.trigger("failed", {
418
+ this.url.includes(q) ? this.trigger("failed", {
376
419
  originator: "remote",
377
420
  message: "IncomingResponse",
378
- cause: P
421
+ cause: N
379
422
  }) : (this.trigger("connecting"), setTimeout(() => {
380
- this.trigger("enterRoom", { room: t });
423
+ this.newInfo({
424
+ originator: O.REMOTE,
425
+ // @ts-expect-error
426
+ request: {
427
+ getHeader: (r) => r === "content-type" ? "application/vinteo.webrtc.roomname" : r === "x-webrtc-enter-room" ? t : r === "x-webrtc-participant-name" ? "Test Caller 1" : ""
428
+ }
429
+ });
381
430
  }, 100), setTimeout(() => {
382
431
  this.trigger("accepted");
383
432
  }, 200), setTimeout(() => {
384
433
  this.trigger("confirmed");
385
434
  }, 300));
386
- }, l);
435
+ }, p);
387
436
  }
388
- /**
389
- * answer
390
- *
391
- * @param {Object} arg1 - The argument 1
392
- * @param {Object} arg1.mediaStream - The media stream
393
- * @param {Array} arg1.eventHandlers - The event handlers
394
-
395
- * @returns {undefined}
396
- */
397
- answer = jest.fn(({ mediaStream: e }) => {
398
- if (this.originator !== "remote")
399
- throw new Error("answer available only for remote sessions");
400
- this.initPeerconnection(e), setTimeout(() => {
401
- this.trigger("connecting"), setTimeout(() => {
402
- this.trigger("accepted");
403
- }, 100), setTimeout(() => {
404
- this.trigger("confirmed");
405
- }, 200);
406
- }, l);
407
- });
408
437
  terminate({ status_code: e, cause: t } = {}) {
409
438
  return this.status_code = e, this.trigger("ended", { status_code: e, cause: t, originator: "local" }), this.isEndedInner = !1, this;
410
439
  }
411
- async terminateAsync({ status_code: e, cause: t } = {}) {
440
+ async terminateAsync({
441
+ status_code: e,
442
+ cause: t
443
+ } = {}) {
412
444
  this.terminate({ status_code: e, cause: t });
413
445
  }
414
446
  terminateRemote({ status_code: e } = {}) {
@@ -445,16 +477,13 @@ class s extends F {
445
477
  isMuted() {
446
478
  return this.mutedOptions;
447
479
  }
448
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
449
- async replaceMediaStream(e) {
450
- }
451
480
  onmute({ audio: e, video: t }) {
452
481
  this.trigger("muted", {
453
482
  audio: e,
454
483
  video: t
455
484
  });
456
485
  }
457
- // eslint-disable-next-line @typescript-eslint/no-empty-function
486
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, class-methods-use-this
458
487
  async sendInfo() {
459
488
  }
460
489
  isEnded() {
@@ -465,99 +494,100 @@ class s extends F {
465
494
  }
466
495
  /* eslint-enable no-param-reassign */
467
496
  }
468
- class q {
497
+ class $ {
469
498
  extraHeaders = [];
470
499
  setExtraHeaders(e) {
471
500
  this.extraHeaders = e;
472
501
  }
502
+ // eslint-disable-next-line class-methods-use-this
473
503
  setExtraContactParams() {
474
504
  }
475
505
  }
476
- const d = "PASSWORD_CORRECT", M = "PASSWORD_CORRECT_2", G = "NAME_INCORRECT", c = 400, p = {
506
+ const d = "PASSWORD_CORRECT", v = "PASSWORD_CORRECT_2", G = "NAME_INCORRECT", c = 400, g = {
477
507
  url: "wss://sipServerUrl/webrtc/wss/",
478
508
  sip_uri: "sip:sipServerUrl;transport=ws",
479
509
  via_transport: "WSS"
480
- }, v = {
510
+ }, M = {
481
511
  status_code: 200,
482
512
  reason_phrase: "OK"
483
513
  }, T = {
484
514
  status_code: 401,
485
515
  reason_phrase: "Unauthorized"
486
516
  };
487
- class i {
517
+ class o {
488
518
  static isAvailableTelephony = !0;
489
519
  static startError;
490
520
  static countStartError = Number.POSITIVE_INFINITY;
491
521
  static countStarts = 0;
492
- static setStartError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
493
- this.startError = e, this.countStartError = t;
494
- }
495
- static resetStartError() {
496
- this.startError = void 0, this.countStartError = Number.POSITIVE_INFINITY, this.countStarts = 0;
497
- }
498
- static setAvailableTelephony() {
499
- this.isAvailableTelephony = !0;
500
- }
501
- static setNotAvailableTelephony() {
502
- this.isAvailableTelephony = !1;
503
- }
504
522
  events;
523
+ registratorInner;
524
+ // @ts-expect-error – Jest создаёт функцию-замок.
525
+ call = jest.fn(
526
+ (e, t) => {
527
+ const { mediaStream: r, eventHandlers: s } = t;
528
+ return this.session = new i({ url: e, mediaStream: r, eventHandlers: s, originator: "local" }), this.session.connect(e), this.session;
529
+ }
530
+ );
531
+ sendOptions = jest.fn(
532
+ (e, t, r) => {
533
+ console.log("sendOptions", e, t, r);
534
+ }
535
+ );
536
+ /**
537
+ * start – имитирует запуск UA.
538
+ */
539
+ start = jest.fn(() => {
540
+ if (o.countStarts += 1, o.startError && o.countStarts < o.countStartError) {
541
+ this.trigger("disconnected", o.startError);
542
+ return;
543
+ }
544
+ this.register();
545
+ });
546
+ /**
547
+ * stop – имитирует остановку UA.
548
+ */
549
+ stop = jest.fn(() => {
550
+ this.startedTimeout && clearTimeout(this.startedTimeout), this.stopedTimeout && clearTimeout(this.stopedTimeout), this.unregister(), this.isStarted() ? this.stopedTimeout = setTimeout(() => {
551
+ this.trigger("disconnected", { error: !0, socket: g });
552
+ }, c) : this.trigger("disconnected", { error: !0, socket: g });
553
+ });
554
+ removeAllListeners = jest.fn(() => (this.events.removeEventHandlers(), this));
555
+ once = jest.fn((e, t) => (this.events.once(e, t), this));
505
556
  startedTimeout;
506
557
  stopedTimeout;
507
558
  session;
508
559
  isRegisteredInner;
509
560
  isConnectedInner;
510
561
  configuration;
511
- registratorInner;
512
562
  constructor(e) {
513
- this.events = new R(O);
514
- const [t, r] = e.uri.split(":"), [o, a] = r.split("@"), u = {
563
+ this.events = new R(b);
564
+ const [t, r] = e.uri.split(":"), [s, a] = r.split("@"), l = {
515
565
  ...e,
516
- uri: new w(t, o, a)
566
+ uri: new h(t, s, a)
517
567
  };
518
- this.configuration = u, this.registratorInner = new q();
568
+ this.configuration = l, this.registratorInner = new $();
519
569
  }
520
- /**
521
- * start
522
- *
523
- * @returns {undefined}
524
- */
525
- start() {
526
- if (i.countStarts += 1, i.startError && i.countStarts < i.countStartError) {
527
- this.trigger("disconnected", i.startError);
528
- return;
529
- }
530
- this.register();
570
+ static setStartError(e, { count: t = Number.POSITIVE_INFINITY } = {}) {
571
+ o.startError = e, o.countStartError = t;
531
572
  }
532
- /**
533
- * stop
534
- *
535
- * @returns {undefined}
536
- */
537
- stop() {
538
- this.startedTimeout && clearTimeout(this.startedTimeout), this.stopedTimeout && clearTimeout(this.stopedTimeout), this.unregister(), this.isStarted() ? this.stopedTimeout = setTimeout(() => {
539
- this.trigger("disconnected", { error: !0, socket: p });
540
- }, c) : this.trigger("disconnected", { error: !0, socket: p });
573
+ static resetStartError() {
574
+ o.startError = void 0, o.countStartError = Number.POSITIVE_INFINITY, o.countStarts = 0;
575
+ }
576
+ static setAvailableTelephony() {
577
+ o.isAvailableTelephony = !0;
578
+ }
579
+ static setNotAvailableTelephony() {
580
+ o.isAvailableTelephony = !1;
581
+ }
582
+ static reset() {
583
+ o.resetStartError(), o.setAvailableTelephony();
541
584
  }
542
- // @ts-expect-error
543
- call = jest.fn(
544
- (e, t) => {
545
- const { mediaStream: r, eventHandlers: o } = t;
546
- return this.session = new s({ url: e, mediaStream: r, eventHandlers: o, originator: "local" }), this.session.connect(e), this.session;
547
- }
548
- );
549
585
  on(e, t) {
550
586
  return this.events.on(e, t), this;
551
587
  }
552
- once(e, t) {
553
- return this.events.once(e, t), this;
554
- }
555
588
  off(e, t) {
556
589
  return this.events.off(e, t), this;
557
590
  }
558
- removeAllListeners() {
559
- return this.events.removeEventHandlers(), this;
560
- }
561
591
  trigger(e, t) {
562
592
  this.events.trigger(e, t);
563
593
  }
@@ -567,7 +597,7 @@ class i {
567
597
  * @returns {undefined}
568
598
  */
569
599
  terminateSessions() {
570
- this.session.terminate();
600
+ this.session?.terminate();
571
601
  }
572
602
  set(e, t) {
573
603
  return this.configuration[e] = t, !0;
@@ -580,13 +610,13 @@ class i {
580
610
  register() {
581
611
  this.startedTimeout && clearTimeout(this.startedTimeout);
582
612
  const { password: e, register: t, uri: r } = this.configuration;
583
- t && r.user.includes(G) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
584
- this.trigger("registrationFailed", { response: T, cause: I.causes.REJECTED });
585
- }, c)) : !this.isRegistered() && t && (e === d || e === M) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
586
- this.trigger("registered", { response: v });
587
- }, c)) : t && e !== d && e !== M && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
588
- this.trigger("registrationFailed", { response: T, cause: I.causes.REJECTED });
589
- }, c)), i.isAvailableTelephony ? (this.trigger("connected", { socket: p }), this.isConnectedInner = !0) : this.stop();
613
+ t === !0 && r.user.includes(G) ? (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
614
+ this.trigger("registrationFailed", { response: T, cause: _.causes.REJECTED });
615
+ }, c)) : !this.isRegistered() && t === !0 && (e === d || e === v) ? (this.isRegisteredInner = !0, this.startedTimeout = setTimeout(() => {
616
+ this.trigger("registered", { response: M });
617
+ }, c)) : t === !0 && e !== d && e !== v && (this.isRegisteredInner = !1, this.isConnectedInner = !1, this.startedTimeout = setTimeout(() => {
618
+ this.trigger("registrationFailed", { response: T, cause: _.causes.REJECTED });
619
+ }, c)), o.isAvailableTelephony ? (this.trigger("connected", { socket: g }), this.isConnectedInner = !0) : this.stop();
590
620
  }
591
621
  /**
592
622
  * unregister
@@ -594,13 +624,13 @@ class i {
594
624
  * @returns {undefined}
595
625
  */
596
626
  unregister() {
597
- this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: v });
627
+ this.isRegisteredInner = !1, this.isConnectedInner = !1, this.trigger("unregistered", { response: M });
598
628
  }
599
629
  isRegistered() {
600
- return !!this.isRegisteredInner;
630
+ return this.isRegisteredInner === !0;
601
631
  }
602
632
  isConnected() {
603
- return !!this.isConnectedInner;
633
+ return this.isConnectedInner === !0;
604
634
  }
605
635
  /**
606
636
  * isStarted
@@ -608,7 +638,7 @@ class i {
608
638
  * @returns {boolean} isStarted
609
639
  */
610
640
  isStarted() {
611
- return this.configuration && ((this.configuration.register && !!this.isRegisteredInner) ?? (!this.configuration.register && !!this.isConnectedInner));
641
+ return this.configuration.register === !0 && this.isRegisteredInner === !0 || this.configuration.register !== !0 && this.isConnectedInner === !0;
612
642
  }
613
643
  newSipEvent(e) {
614
644
  this.trigger("sipEvent", e);
@@ -617,121 +647,122 @@ class i {
617
647
  return this.registratorInner;
618
648
  }
619
649
  }
620
- class J {
650
+ class U {
621
651
  url;
622
652
  constructor(e) {
623
653
  this.url = e;
624
654
  }
625
655
  }
626
- class $ extends D {
656
+ class B extends L {
627
657
  contentType;
628
658
  body;
629
659
  constructor(e, t) {
630
660
  super(), this.contentType = e, this.body = t;
631
661
  }
632
662
  }
633
- const g = "remote", j = (n, e) => {
634
- const t = new E(e), r = {
635
- originator: g,
663
+ const E = "remote", K = (n, e) => {
664
+ const t = new w(e), r = {
665
+ originator: E,
636
666
  request: t,
637
- info: new $("", "")
667
+ info: new B("", "")
638
668
  };
639
669
  n.newInfo(r);
640
- }, B = (n, e) => {
641
- const r = { event: "sipEvent", request: new E(e) };
670
+ }, X = (n, e) => {
671
+ const r = { event: "sipEvent", request: new w(e) };
642
672
  n.newSipEvent(r);
643
- }, K = (n, {
673
+ }, Q = (n, {
644
674
  incomingNumber: e = "1234",
645
675
  displayName: t,
646
676
  host: r
647
677
  }) => {
648
- const o = new s({ originator: g, eventHandlers: {} }), a = new b("sip", e, r);
649
- o.remote_identity = new A(a, t);
650
- const u = new E([]);
678
+ const s = new i({ originator: E, eventHandlers: {} }), a = new D("sip", e, r);
679
+ s.remote_identity = new A(a, t);
680
+ const l = new w([]);
651
681
  n.trigger("newRTCSession", {
652
- originator: g,
653
- session: o,
654
- request: u
682
+ originator: E,
683
+ session: s,
684
+ request: l
655
685
  });
656
- }, X = (n, e) => {
686
+ }, Z = (n, e) => {
657
687
  e ? n.trigger("failed", e) : n.trigger("failed", n);
658
688
  }, C = {
659
- triggerNewInfo: j,
660
- triggerNewSipEvent: B,
661
- triggerIncomingSession: K,
662
- triggerFailIncomingSession: X,
663
- WebSocketInterface: J,
664
- UA: i,
689
+ triggerNewInfo: K,
690
+ triggerNewSipEvent: X,
691
+ triggerIncomingSession: Q,
692
+ triggerFailIncomingSession: Z,
693
+ WebSocketInterface: U,
694
+ UA: o,
665
695
  C: {
666
696
  INVITE: "INVITE"
667
697
  }
668
- }, f = "user", h = "displayName", _ = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", Q = new C.WebSocketInterface(y), S = {
698
+ }, f = "user", m = "displayName", S = "SIP_SERVER_URL", y = "SIP_WEB_SOCKET_SERVER_URL", ee = new C.WebSocketInterface(y), I = {
669
699
  userAgent: "Chrome",
670
- sipServerUrl: _,
700
+ sipServerUrl: S,
671
701
  sipWebSocketServerURL: y
672
- }, ce = {
673
- ...S
674
- }, Z = {
675
- ...S,
702
+ }, me = {
703
+ ...I
704
+ }, te = {
705
+ ...I,
676
706
  user: f,
677
707
  password: d,
678
708
  register: !0
679
- }, he = {
680
- ...Z,
681
- displayName: h
682
- }, me = {
683
- ...S,
684
- displayName: h,
709
+ }, ue = {
710
+ ...te,
711
+ displayName: m
712
+ }, le = {
713
+ ...I,
714
+ displayName: m,
685
715
  register: !1
686
- }, m = {
716
+ }, u = {
687
717
  session_timers: !1,
688
- sockets: [Q],
718
+ sockets: [ee],
689
719
  user_agent: "Chrome",
690
- sdp_semantics: "unified-plan",
720
+ sdpSemantics: "unified-plan",
691
721
  register_expires: 300,
692
722
  connection_recovery_max_interval: 6,
693
723
  connection_recovery_min_interval: 2
694
- }, ue = {
695
- ...m,
724
+ }, pe = {
725
+ ...u,
696
726
  password: d,
697
- uri: new w("sip", f, _),
727
+ uri: new h("sip", f, S),
698
728
  display_name: "",
699
729
  register: !0
700
- }, le = {
701
- ...m,
730
+ }, ge = {
731
+ ...u,
702
732
  password: d,
703
- uri: new w("sip", f, _),
704
- display_name: h,
733
+ uri: new h("sip", f, S),
734
+ display_name: m,
705
735
  register: !0
706
- }, pe = {
707
- ...m,
708
- display_name: h,
736
+ }, Ee = {
737
+ ...u,
738
+ display_name: m,
709
739
  register: !1
710
- }, ge = {
711
- ...m,
740
+ }, we = {
741
+ ...u,
712
742
  display_name: "",
713
743
  register: !1
714
- }, ee = "10.10.10.10", we = [`X-Vinteo-Remote: ${ee}`], Ee = () => new k({
744
+ }, re = "10.10.10.10", fe = [`X-Vinteo-Remote: ${re}`], Se = () => new k({
715
745
  JsSIP: C
716
746
  });
717
747
  export {
718
- z as FAILED_CONFERENCE_NUMBER,
748
+ q as FAILED_CONFERENCE_NUMBER,
749
+ C as JsSIP,
719
750
  G as NAME_INCORRECT,
720
751
  d as PASSWORD_CORRECT,
721
- M as PASSWORD_CORRECT_2,
722
- _ as SIP_SERVER_URL,
752
+ v as PASSWORD_CORRECT_2,
753
+ S as SIP_SERVER_URL,
723
754
  y as SIP_WEB_SOCKET_SERVER_URL,
724
- Z as dataForConnectionWithAuthorization,
725
- he as dataForConnectionWithAuthorizationWithDisplayName,
726
- me as dataForConnectionWithoutAuthorization,
727
- ce as dataForConnectionWithoutAuthorizationWithoutDisplayName,
728
- h as displayName,
729
- Ee as doMockSipConnector,
730
- we as extraHeadersRemoteAddress,
731
- ee as remoteAddress,
732
- ue as uaConfigurationWithAuthorization,
733
- le as uaConfigurationWithAuthorizationWithDisplayName,
734
- pe as uaConfigurationWithoutAuthorization,
735
- ge as uaConfigurationWithoutAuthorizationWithoutDisplayName,
755
+ te as dataForConnectionWithAuthorization,
756
+ ue as dataForConnectionWithAuthorizationWithDisplayName,
757
+ le as dataForConnectionWithoutAuthorization,
758
+ me as dataForConnectionWithoutAuthorizationWithoutDisplayName,
759
+ m as displayName,
760
+ Se as doMockSipConnector,
761
+ fe as extraHeadersRemoteAddress,
762
+ re as remoteAddress,
763
+ pe as uaConfigurationWithAuthorization,
764
+ ge as uaConfigurationWithAuthorizationWithDisplayName,
765
+ Ee as uaConfigurationWithoutAuthorization,
766
+ we as uaConfigurationWithoutAuthorizationWithoutDisplayName,
736
767
  f as user
737
768
  };