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