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