@shenyin/embedded-call-widget 2.6.1 → 2.6.2
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/README.md +10 -4
- package/checksums.txt +3 -3
- package/embedded-call-widget-runtime.iife.js +22 -22
- package/embedded-call-widget-runtime.js +610 -549
- package/manifest.json +13 -11
- package/package.json +1 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const Tt = "0.21.1";
|
|
2
|
+
class le extends Error {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
super(e), Object.setPrototypeOf(this, new.target.prototype);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class Le extends le {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super(e || "Unsupported content type.");
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class ye extends le {
|
|
13
13
|
/** @internal */
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super(e || "Request pending.");
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class Et extends le {
|
|
19
19
|
constructor(e) {
|
|
20
20
|
super(e || "Unspecified session description handler error.");
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class He extends le {
|
|
24
24
|
constructor() {
|
|
25
25
|
super("The session has terminated.");
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class pe extends le {
|
|
29
29
|
constructor(e) {
|
|
30
30
|
super(e || "An error occurred during state transition.");
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class Ct {
|
|
34
34
|
/** @internal */
|
|
35
35
|
constructor(e) {
|
|
36
36
|
this.incomingAckRequest = e;
|
|
@@ -40,7 +40,7 @@ class Tt {
|
|
|
40
40
|
return this.incomingAckRequest.message;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class xt {
|
|
44
44
|
/** @internal */
|
|
45
45
|
constructor(e) {
|
|
46
46
|
this.incomingByeRequest = e;
|
|
@@ -58,7 +58,7 @@ class Et {
|
|
|
58
58
|
return this.incomingByeRequest.reject(e), Promise.resolve();
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
class
|
|
61
|
+
class Rt {
|
|
62
62
|
/** @internal */
|
|
63
63
|
constructor(e) {
|
|
64
64
|
this.incomingCancelRequest = e;
|
|
@@ -130,7 +130,7 @@ class be {
|
|
|
130
130
|
return this.addListener(e, { once: !0 });
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
class
|
|
133
|
+
class It {
|
|
134
134
|
/** @internal */
|
|
135
135
|
constructor(e) {
|
|
136
136
|
this.incomingInfoRequest = e;
|
|
@@ -148,7 +148,7 @@ class xt {
|
|
|
148
148
|
return this.incomingInfoRequest.reject(e), Promise.resolve();
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
class
|
|
151
|
+
class rt {
|
|
152
152
|
constructor(e) {
|
|
153
153
|
this.parameters = {};
|
|
154
154
|
for (const t in e)
|
|
@@ -174,7 +174,7 @@ class it {
|
|
|
174
174
|
this.parameters = {};
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
class
|
|
177
|
+
class F extends rt {
|
|
178
178
|
/**
|
|
179
179
|
* Constructor
|
|
180
180
|
* @param uri -
|
|
@@ -194,7 +194,7 @@ class O extends it {
|
|
|
194
194
|
this._displayName = e;
|
|
195
195
|
}
|
|
196
196
|
clone() {
|
|
197
|
-
return new
|
|
197
|
+
return new F(this.uri.clone(), this._displayName, JSON.parse(JSON.stringify(this.parameters)));
|
|
198
198
|
}
|
|
199
199
|
toString() {
|
|
200
200
|
let e = this.displayName || this.displayName === "0" ? '"' + this.displayName + '" ' : "";
|
|
@@ -204,7 +204,7 @@ class O extends it {
|
|
|
204
204
|
return e;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
class Y extends
|
|
207
|
+
class Y extends rt {
|
|
208
208
|
/**
|
|
209
209
|
* Constructor
|
|
210
210
|
* @param scheme -
|
|
@@ -333,7 +333,7 @@ class Y extends it {
|
|
|
333
333
|
return t[r] && (r = t[r]), r;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function Ye(a, e) {
|
|
337
337
|
if (a.scheme !== e.scheme || a.user !== e.user || a.host !== e.host || a.port !== e.port)
|
|
338
338
|
return !1;
|
|
339
339
|
function t(r, n) {
|
|
@@ -352,12 +352,12 @@ function ze(a, e) {
|
|
|
352
352
|
}
|
|
353
353
|
return !0;
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function Me(a, e, t) {
|
|
356
356
|
return t = t || " ", a.length > e ? a : (e -= a.length, t += t.repeat(e), a + t.slice(0, e));
|
|
357
357
|
}
|
|
358
|
-
class
|
|
358
|
+
class he extends Error {
|
|
359
359
|
constructor(e, t, i, s) {
|
|
360
|
-
super(), this.message = e, this.expected = t, this.found = i, this.location = s, this.name = "SyntaxError", typeof Object.setPrototypeOf == "function" ? Object.setPrototypeOf(this,
|
|
360
|
+
super(), this.message = e, this.expected = t, this.found = i, this.location = s, this.name = "SyntaxError", typeof Object.setPrototypeOf == "function" ? Object.setPrototypeOf(this, he.prototype) : this.__proto__ = he.prototype, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, he);
|
|
361
361
|
}
|
|
362
362
|
static buildMessage(e, t) {
|
|
363
363
|
function i(p) {
|
|
@@ -417,12 +417,12 @@ class le extends Error {
|
|
|
417
417
|
}
|
|
418
418
|
let r = this.location.start, n = this.location.source + ":" + r.line + ":" + r.column;
|
|
419
419
|
if (i) {
|
|
420
|
-
let o = this.location.end, d =
|
|
420
|
+
let o = this.location.end, d = Me("", r.line.toString().length, " "), p = i[r.line - 1], u = r.line === o.line ? o.column : p.length + 1;
|
|
421
421
|
t += `
|
|
422
422
|
--> ` + n + `
|
|
423
423
|
` + d + ` |
|
|
424
424
|
` + r.line + " | " + p + `
|
|
425
|
-
` + d + " | " +
|
|
425
|
+
` + d + " | " + Me("", r.column - 1, " ") + Me("", u - r.column, "^");
|
|
426
426
|
} else
|
|
427
427
|
t += `
|
|
428
428
|
at ` + n;
|
|
@@ -430,7 +430,7 @@ class le extends Error {
|
|
|
430
430
|
return t;
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function At(a, e) {
|
|
434
434
|
e = e !== void 0 ? e : {};
|
|
435
435
|
const t = {}, i = e.grammarSource, s = { Contact: 119, Name_Addr_Header: 156, Record_Route: 176, Request_Response: 81, SIP_URI: 45, Subscription_State: 186, Supported: 191, Require: 182, Via: 194, absoluteURI: 84, Call_ID: 118, Content_Disposition: 130, Content_Length: 135, Content_Type: 136, CSeq: 146, displayName: 122, Event: 149, From: 151, host: 52, Max_Forwards: 154, Min_SE: 213, Proxy_Authenticate: 157, quoted_string: 40, Refer_To: 178, Replaces: 179, Session_Expires: 210, stun_URI: 217, To: 192, turn_URI: 223, uuid: 226, WWW_Authenticate: 209, challenge: 158, sipfrag: 230, Referred_By: 231 };
|
|
436
436
|
let r = 119;
|
|
@@ -672,11 +672,11 @@ function Rt(a, e) {
|
|
|
672
672
|
function() {
|
|
673
673
|
e = e || { data: {} }, e.data.uri_params || (e.data.uri_params = {}), e.data.uri_params.lr = void 0;
|
|
674
674
|
},
|
|
675
|
-
function(l,
|
|
676
|
-
e = e || { data: {} }, e.data.uri_params || (e.data.uri_params = {}),
|
|
675
|
+
function(l, y) {
|
|
676
|
+
e = e || { data: {} }, e.data.uri_params || (e.data.uri_params = {}), y === null ? y = void 0 : y = y[1], e.data.uri_params[l.toLowerCase()] = y;
|
|
677
677
|
},
|
|
678
|
-
function(l,
|
|
679
|
-
l = l.join("").toLowerCase(),
|
|
678
|
+
function(l, y) {
|
|
679
|
+
l = l.join("").toLowerCase(), y = y.join(""), e = e || { data: {} }, e.data.uri_headers || (e.data.uri_headers = {}), e.data.uri_headers[l] ? e.data.uri_headers[l].push(y) : e.data.uri_headers[l] = [y];
|
|
680
680
|
},
|
|
681
681
|
function() {
|
|
682
682
|
e = e || { data: {} }, e.startRule === "Refer_To" && (e.data.uri = new Y(e.data.scheme, e.data.user, e.data.host, e.data.port, e.data.uri_params, e.data.uri_headers), delete e.data.scheme, delete e.data.user, delete e.data.host, delete e.data.host_type, delete e.data.port, delete e.data.uri_params);
|
|
@@ -725,8 +725,8 @@ function Rt(a, e) {
|
|
|
725
725
|
e = e || { data: {} }, e.data = C();
|
|
726
726
|
},
|
|
727
727
|
function() {
|
|
728
|
-
var l,
|
|
729
|
-
for (e = e || { data: {} },
|
|
728
|
+
var l, y;
|
|
729
|
+
for (e = e || { data: {} }, y = e.data.multi_header.length, l = 0; l < y; l++)
|
|
730
730
|
if (e.data.multi_header[l].parsed === null) {
|
|
731
731
|
e.data = null;
|
|
732
732
|
break;
|
|
@@ -737,13 +737,13 @@ function Rt(a, e) {
|
|
|
737
737
|
var l;
|
|
738
738
|
e = e || { data: {} }, e.data.multi_header || (e.data.multi_header = []);
|
|
739
739
|
try {
|
|
740
|
-
l = new
|
|
740
|
+
l = new F(e.data.uri, e.data.displayName, e.data.params), delete e.data.uri, delete e.data.displayName, delete e.data.params;
|
|
741
741
|
} catch {
|
|
742
742
|
l = null;
|
|
743
743
|
}
|
|
744
744
|
e.data.multi_header.push({
|
|
745
745
|
position: d,
|
|
746
|
-
offset:
|
|
746
|
+
offset: ae().start.offset,
|
|
747
747
|
parsed: l
|
|
748
748
|
});
|
|
749
749
|
},
|
|
@@ -768,8 +768,8 @@ function Rt(a, e) {
|
|
|
768
768
|
function() {
|
|
769
769
|
return parseFloat(C());
|
|
770
770
|
},
|
|
771
|
-
function(l,
|
|
772
|
-
e = e || { data: {} }, e.data.params || (e.data.params = {}),
|
|
771
|
+
function(l, y) {
|
|
772
|
+
e = e || { data: {} }, e.data.params || (e.data.params = {}), y === null ? y = void 0 : y = y[1], e.data.params[l.toLowerCase()] = y;
|
|
773
773
|
},
|
|
774
774
|
"render",
|
|
775
775
|
f("render", !0),
|
|
@@ -822,7 +822,7 @@ function Rt(a, e) {
|
|
|
822
822
|
function() {
|
|
823
823
|
e = e || { data: {} };
|
|
824
824
|
var l = e.data.tag;
|
|
825
|
-
e.data = new
|
|
825
|
+
e.data = new F(e.data.uri, e.data.displayName, e.data.params), l && e.data.setParam("tag", l);
|
|
826
826
|
},
|
|
827
827
|
"tag",
|
|
828
828
|
f("tag", !0),
|
|
@@ -836,7 +836,7 @@ function Rt(a, e) {
|
|
|
836
836
|
e = e || { data: {} }, e.data = l;
|
|
837
837
|
},
|
|
838
838
|
function() {
|
|
839
|
-
e = e || { data: {} }, e.data = new
|
|
839
|
+
e = e || { data: {} }, e.data = new F(e.data.uri, e.data.displayName, e.data.params);
|
|
840
840
|
},
|
|
841
841
|
"digest",
|
|
842
842
|
f("Digest", !0),
|
|
@@ -891,8 +891,8 @@ function Rt(a, e) {
|
|
|
891
891
|
e = e || { data: {} }, e.data.value = parseInt(l.join(""));
|
|
892
892
|
},
|
|
893
893
|
function() {
|
|
894
|
-
var l,
|
|
895
|
-
for (e = e || { data: {} },
|
|
894
|
+
var l, y;
|
|
895
|
+
for (e = e || { data: {} }, y = e.data.multi_header.length, l = 0; l < y; l++)
|
|
896
896
|
if (e.data.multi_header[l].parsed === null) {
|
|
897
897
|
e.data = null;
|
|
898
898
|
break;
|
|
@@ -903,18 +903,18 @@ function Rt(a, e) {
|
|
|
903
903
|
var l;
|
|
904
904
|
e = e || { data: {} }, e.data.multi_header || (e.data.multi_header = []);
|
|
905
905
|
try {
|
|
906
|
-
l = new
|
|
906
|
+
l = new F(e.data.uri, e.data.displayName, e.data.params), delete e.data.uri, delete e.data.displayName, delete e.data.params;
|
|
907
907
|
} catch {
|
|
908
908
|
l = null;
|
|
909
909
|
}
|
|
910
910
|
e.data.multi_header.push({
|
|
911
911
|
position: d,
|
|
912
|
-
offset:
|
|
912
|
+
offset: ae().start.offset,
|
|
913
913
|
parsed: l
|
|
914
914
|
});
|
|
915
915
|
},
|
|
916
916
|
function() {
|
|
917
|
-
e = e || { data: {} }, e.data = new
|
|
917
|
+
e = e || { data: {} }, e.data = new F(e.data.uri, e.data.displayName, e.data.params);
|
|
918
918
|
},
|
|
919
919
|
function() {
|
|
920
920
|
e = e || { data: {} }, e.data.replaces_from_tag && e.data.replaces_to_tag || (e.data = -1);
|
|
@@ -939,11 +939,11 @@ function Rt(a, e) {
|
|
|
939
939
|
function() {
|
|
940
940
|
e = e || { data: {} }, e.data.early_only = !0;
|
|
941
941
|
},
|
|
942
|
-
function(l,
|
|
943
|
-
return
|
|
942
|
+
function(l, y) {
|
|
943
|
+
return y;
|
|
944
944
|
},
|
|
945
|
-
function(l,
|
|
946
|
-
return
|
|
945
|
+
function(l, y) {
|
|
946
|
+
return vt(l, y);
|
|
947
947
|
},
|
|
948
948
|
function(l) {
|
|
949
949
|
e = e || { data: {} }, e.startRule === "Require" && (e.data = l || []);
|
|
@@ -993,7 +993,7 @@ function Rt(a, e) {
|
|
|
993
993
|
function() {
|
|
994
994
|
e = e || { data: {} };
|
|
995
995
|
var l = e.data.tag;
|
|
996
|
-
e.data = new
|
|
996
|
+
e.data = new F(e.data.uri, e.data.displayName, e.data.params), l && e.data.setParam("tag", l);
|
|
997
997
|
},
|
|
998
998
|
"ttl",
|
|
999
999
|
f("ttl", !0),
|
|
@@ -1330,33 +1330,33 @@ function Rt(a, e) {
|
|
|
1330
1330
|
function C() {
|
|
1331
1331
|
return a.substring(p, d);
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1333
|
+
function ae() {
|
|
1334
|
+
return Pe(p, d);
|
|
1335
1335
|
}
|
|
1336
|
-
function f(l,
|
|
1337
|
-
return { type: "literal", text: l, ignoreCase:
|
|
1336
|
+
function f(l, y) {
|
|
1337
|
+
return { type: "literal", text: l, ignoreCase: y };
|
|
1338
1338
|
}
|
|
1339
|
-
function _(l,
|
|
1340
|
-
return { type: "class", parts: l, inverted:
|
|
1339
|
+
function _(l, y, h) {
|
|
1340
|
+
return { type: "class", parts: l, inverted: y, ignoreCase: h };
|
|
1341
1341
|
}
|
|
1342
|
-
function
|
|
1342
|
+
function ke() {
|
|
1343
1343
|
return { type: "end" };
|
|
1344
1344
|
}
|
|
1345
|
-
function
|
|
1346
|
-
let
|
|
1347
|
-
if (
|
|
1348
|
-
return
|
|
1345
|
+
function Ge(l) {
|
|
1346
|
+
let y = u[l], h;
|
|
1347
|
+
if (y)
|
|
1348
|
+
return y;
|
|
1349
1349
|
for (h = l - 1; !u[h]; )
|
|
1350
1350
|
h--;
|
|
1351
|
-
for (
|
|
1352
|
-
line:
|
|
1353
|
-
column:
|
|
1351
|
+
for (y = u[h], y = {
|
|
1352
|
+
line: y.line,
|
|
1353
|
+
column: y.column
|
|
1354
1354
|
}; h < l; )
|
|
1355
|
-
a.charCodeAt(h) === 10 ? (
|
|
1356
|
-
return u[l] =
|
|
1355
|
+
a.charCodeAt(h) === 10 ? (y.line++, y.column = 1) : y.column++, h++;
|
|
1356
|
+
return u[l] = y, y;
|
|
1357
1357
|
}
|
|
1358
|
-
function
|
|
1359
|
-
const h =
|
|
1358
|
+
function Pe(l, y) {
|
|
1359
|
+
const h = Ge(l), B = Ge(y);
|
|
1360
1360
|
return {
|
|
1361
1361
|
source: i,
|
|
1362
1362
|
start: {
|
|
@@ -1365,33 +1365,33 @@ function Rt(a, e) {
|
|
|
1365
1365
|
column: h.column
|
|
1366
1366
|
},
|
|
1367
1367
|
end: {
|
|
1368
|
-
offset:
|
|
1368
|
+
offset: y,
|
|
1369
1369
|
line: B.line,
|
|
1370
1370
|
column: B.column
|
|
1371
1371
|
}
|
|
1372
1372
|
};
|
|
1373
1373
|
}
|
|
1374
|
-
function
|
|
1374
|
+
function Ke(l) {
|
|
1375
1375
|
d < w || (d > w && (w = d, S = []), S.push(l));
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1378
|
-
return new
|
|
1377
|
+
function bt(l, y, h) {
|
|
1378
|
+
return new he(he.buildMessage(l, y), l, y, h);
|
|
1379
1379
|
}
|
|
1380
1380
|
function c(l) {
|
|
1381
|
-
return l.split("").map((
|
|
1381
|
+
return l.split("").map((y) => y.charCodeAt(0) - 32);
|
|
1382
1382
|
}
|
|
1383
|
-
function
|
|
1384
|
-
const
|
|
1383
|
+
function We(l) {
|
|
1384
|
+
const y = o[l];
|
|
1385
1385
|
let h = 0;
|
|
1386
1386
|
const B = [];
|
|
1387
|
-
let $ =
|
|
1387
|
+
let $ = y.length;
|
|
1388
1388
|
const K = [], E = [];
|
|
1389
|
-
let
|
|
1389
|
+
let ze;
|
|
1390
1390
|
for (; ; ) {
|
|
1391
1391
|
for (; h < $; )
|
|
1392
|
-
switch (
|
|
1392
|
+
switch (y[h]) {
|
|
1393
1393
|
case 0:
|
|
1394
|
-
E.push(n[
|
|
1394
|
+
E.push(n[y[h + 1]]), h += 2;
|
|
1395
1395
|
break;
|
|
1396
1396
|
case 1:
|
|
1397
1397
|
E.push(void 0), h++;
|
|
@@ -1415,7 +1415,7 @@ function Rt(a, e) {
|
|
|
1415
1415
|
d = E.pop(), h++;
|
|
1416
1416
|
break;
|
|
1417
1417
|
case 8:
|
|
1418
|
-
E.length -=
|
|
1418
|
+
E.length -= y[h + 1], h += 2;
|
|
1419
1419
|
break;
|
|
1420
1420
|
case 9:
|
|
1421
1421
|
E.splice(-2, 1), h++;
|
|
@@ -1424,57 +1424,57 @@ function Rt(a, e) {
|
|
|
1424
1424
|
E[E.length - 2].push(E.pop()), h++;
|
|
1425
1425
|
break;
|
|
1426
1426
|
case 11:
|
|
1427
|
-
E.push(E.splice(E.length -
|
|
1427
|
+
E.push(E.splice(E.length - y[h + 1], y[h + 1])), h += 2;
|
|
1428
1428
|
break;
|
|
1429
1429
|
case 12:
|
|
1430
1430
|
E.push(a.substring(E.pop(), d)), h++;
|
|
1431
1431
|
break;
|
|
1432
1432
|
case 13:
|
|
1433
|
-
K.push($), B.push(h + 3 +
|
|
1433
|
+
K.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), E[E.length - 1] ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1434
1434
|
break;
|
|
1435
1435
|
case 14:
|
|
1436
|
-
K.push($), B.push(h + 3 +
|
|
1436
|
+
K.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), E[E.length - 1] === t ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1437
1437
|
break;
|
|
1438
1438
|
case 15:
|
|
1439
|
-
K.push($), B.push(h + 3 +
|
|
1439
|
+
K.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), E[E.length - 1] !== t ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1440
1440
|
break;
|
|
1441
1441
|
case 16:
|
|
1442
|
-
E[E.length - 1] !== t ? (K.push($), B.push(h), $ = h + 2 +
|
|
1442
|
+
E[E.length - 1] !== t ? (K.push($), B.push(h), $ = h + 2 + y[h + 1], h += 2) : h += 2 + y[h + 1];
|
|
1443
1443
|
break;
|
|
1444
1444
|
case 17:
|
|
1445
|
-
K.push($), B.push(h + 3 +
|
|
1445
|
+
K.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), a.length > d ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1446
1446
|
break;
|
|
1447
1447
|
case 18:
|
|
1448
|
-
K.push($), B.push(h + 4 +
|
|
1448
|
+
K.push($), B.push(h + 4 + y[h + 2] + y[h + 3]), a.substr(d, n[y[h + 1]].length) === n[y[h + 1]] ? ($ = h + 4 + y[h + 2], h += 4) : ($ = h + 4 + y[h + 2] + y[h + 3], h += 4 + y[h + 2]);
|
|
1449
1449
|
break;
|
|
1450
1450
|
case 19:
|
|
1451
|
-
K.push($), B.push(h + 4 +
|
|
1451
|
+
K.push($), B.push(h + 4 + y[h + 2] + y[h + 3]), a.substr(d, n[y[h + 1]].length).toLowerCase() === n[y[h + 1]] ? ($ = h + 4 + y[h + 2], h += 4) : ($ = h + 4 + y[h + 2] + y[h + 3], h += 4 + y[h + 2]);
|
|
1452
1452
|
break;
|
|
1453
1453
|
case 20:
|
|
1454
|
-
K.push($), B.push(h + 4 +
|
|
1454
|
+
K.push($), B.push(h + 4 + y[h + 2] + y[h + 3]), n[y[h + 1]].test(a.charAt(d)) ? ($ = h + 4 + y[h + 2], h += 4) : ($ = h + 4 + y[h + 2] + y[h + 3], h += 4 + y[h + 2]);
|
|
1455
1455
|
break;
|
|
1456
1456
|
case 21:
|
|
1457
|
-
E.push(a.substr(d,
|
|
1457
|
+
E.push(a.substr(d, y[h + 1])), d += y[h + 1], h += 2;
|
|
1458
1458
|
break;
|
|
1459
1459
|
case 22:
|
|
1460
|
-
E.push(n[
|
|
1460
|
+
E.push(n[y[h + 1]]), d += n[y[h + 1]].length, h += 2;
|
|
1461
1461
|
break;
|
|
1462
1462
|
case 23:
|
|
1463
|
-
E.push(t), I === 0 &&
|
|
1463
|
+
E.push(t), I === 0 && Ke(n[y[h + 1]]), h += 2;
|
|
1464
1464
|
break;
|
|
1465
1465
|
case 24:
|
|
1466
|
-
p = E[E.length - 1 -
|
|
1466
|
+
p = E[E.length - 1 - y[h + 1]], h += 2;
|
|
1467
1467
|
break;
|
|
1468
1468
|
case 25:
|
|
1469
1469
|
p = d, h++;
|
|
1470
1470
|
break;
|
|
1471
1471
|
case 26:
|
|
1472
|
-
|
|
1473
|
-
return E[E.length - 1 -
|
|
1474
|
-
}), E.splice(E.length -
|
|
1472
|
+
ze = y.slice(h + 4, h + 4 + y[h + 3]).map(function(St) {
|
|
1473
|
+
return E[E.length - 1 - St];
|
|
1474
|
+
}), E.splice(E.length - y[h + 2], y[h + 2], n[y[h + 1]].apply(null, ze)), h += 4 + y[h + 3];
|
|
1475
1475
|
break;
|
|
1476
1476
|
case 27:
|
|
1477
|
-
E.push(
|
|
1477
|
+
E.push(We(y[h + 1])), h += 2;
|
|
1478
1478
|
break;
|
|
1479
1479
|
case 28:
|
|
1480
1480
|
I++, h++;
|
|
@@ -1483,7 +1483,7 @@ function Rt(a, e) {
|
|
|
1483
1483
|
I--, h++;
|
|
1484
1484
|
break;
|
|
1485
1485
|
default:
|
|
1486
|
-
throw new Error("Invalid opcode: " +
|
|
1486
|
+
throw new Error("Invalid opcode: " + y[h] + ".");
|
|
1487
1487
|
}
|
|
1488
1488
|
if (K.length > 0)
|
|
1489
1489
|
$ = K.pop(), h = B.pop();
|
|
@@ -1493,20 +1493,20 @@ function Rt(a, e) {
|
|
|
1493
1493
|
return E[0];
|
|
1494
1494
|
}
|
|
1495
1495
|
e.data = {};
|
|
1496
|
-
function
|
|
1497
|
-
return [l].concat(
|
|
1496
|
+
function vt(l, y) {
|
|
1497
|
+
return [l].concat(y);
|
|
1498
1498
|
}
|
|
1499
|
-
if (A =
|
|
1499
|
+
if (A = We(r), A !== t && d === a.length)
|
|
1500
1500
|
return A;
|
|
1501
|
-
throw A !== t && d < a.length &&
|
|
1501
|
+
throw A !== t && d < a.length && Ke(ke()), bt(S, w < a.length ? a.charAt(w) : null, w < a.length ? Pe(w, w + 1) : Pe(w, w));
|
|
1502
1502
|
}
|
|
1503
|
-
const
|
|
1503
|
+
const _t = At;
|
|
1504
1504
|
var k;
|
|
1505
1505
|
(function(a) {
|
|
1506
1506
|
function e(s, r) {
|
|
1507
1507
|
const n = { startRule: r };
|
|
1508
1508
|
try {
|
|
1509
|
-
|
|
1509
|
+
_t(s, n);
|
|
1510
1510
|
} catch {
|
|
1511
1511
|
n.data = -1;
|
|
1512
1512
|
}
|
|
@@ -1524,7 +1524,7 @@ var k;
|
|
|
1524
1524
|
}
|
|
1525
1525
|
a.URIParse = i;
|
|
1526
1526
|
})(k = k || (k = {}));
|
|
1527
|
-
const
|
|
1527
|
+
const $t = {
|
|
1528
1528
|
100: "Trying",
|
|
1529
1529
|
180: "Ringing",
|
|
1530
1530
|
181: "Call Is Being Forwarded",
|
|
@@ -1597,7 +1597,7 @@ const At = {
|
|
|
1597
1597
|
604: "Does Not Exist Anywhere",
|
|
1598
1598
|
606: "Not Acceptable"
|
|
1599
1599
|
};
|
|
1600
|
-
function
|
|
1600
|
+
function oe(a, e = 32) {
|
|
1601
1601
|
let t = "";
|
|
1602
1602
|
for (let i = 0; i < a; i++) {
|
|
1603
1603
|
const s = Math.floor(Math.random() * e);
|
|
@@ -1605,11 +1605,11 @@ function ae(a, e = 32) {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
return t;
|
|
1607
1607
|
}
|
|
1608
|
-
function
|
|
1609
|
-
return
|
|
1608
|
+
function Ae(a) {
|
|
1609
|
+
return $t[a] || "";
|
|
1610
1610
|
}
|
|
1611
|
-
function
|
|
1612
|
-
return
|
|
1611
|
+
function _e() {
|
|
1612
|
+
return oe(10);
|
|
1613
1613
|
}
|
|
1614
1614
|
function W(a) {
|
|
1615
1615
|
const e = {
|
|
@@ -1625,10 +1625,10 @@ function W(a) {
|
|
|
1625
1625
|
r !== 0 && (s += "-"), s += t[r].charAt(0).toUpperCase() + t[r].substring(1);
|
|
1626
1626
|
return e[s] && (s = e[s]), s;
|
|
1627
1627
|
}
|
|
1628
|
-
function
|
|
1628
|
+
function ve(a) {
|
|
1629
1629
|
return encodeURIComponent(a).replace(/%[A-F\d]{2}/g, "U").length;
|
|
1630
1630
|
}
|
|
1631
|
-
class
|
|
1631
|
+
class nt {
|
|
1632
1632
|
constructor() {
|
|
1633
1633
|
this.headers = {};
|
|
1634
1634
|
}
|
|
@@ -1725,22 +1725,22 @@ class st {
|
|
|
1725
1725
|
return this.data;
|
|
1726
1726
|
}
|
|
1727
1727
|
}
|
|
1728
|
-
class
|
|
1728
|
+
class ue extends nt {
|
|
1729
1729
|
constructor() {
|
|
1730
1730
|
super();
|
|
1731
1731
|
}
|
|
1732
1732
|
}
|
|
1733
|
-
class
|
|
1733
|
+
class ne extends nt {
|
|
1734
1734
|
constructor() {
|
|
1735
1735
|
super();
|
|
1736
1736
|
}
|
|
1737
1737
|
}
|
|
1738
|
-
class
|
|
1738
|
+
class de {
|
|
1739
1739
|
constructor(e, t, i, s, r, n, o) {
|
|
1740
|
-
this.headers = {}, this.extraHeaders = [], this.options =
|
|
1740
|
+
this.headers = {}, this.extraHeaders = [], this.options = de.getDefaultOptions(), r && (this.options = Object.assign(Object.assign({}, this.options), r), this.options.optionTags && this.options.optionTags.length && (this.options.optionTags = this.options.optionTags.slice()), this.options.routeSet && this.options.routeSet.length && (this.options.routeSet = this.options.routeSet.slice())), n && n.length && (this.extraHeaders = n.slice()), o && (this.body = {
|
|
1741
1741
|
body: o.content,
|
|
1742
1742
|
contentType: o.contentType
|
|
1743
|
-
}), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag :
|
|
1743
|
+
}), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag : _e(), this.from = de.makeNameAddrHeader(this.fromURI, this.options.fromDisplayName, this.fromTag), this.toURI = s.clone(), this.toTag = this.options.toTag, this.to = de.makeNameAddrHeader(this.toURI, this.options.toDisplayName, this.toTag), this.callId = this.options.callId ? this.options.callId : this.options.callIdPrefix + oe(15), this.cseq = this.options.cseq, this.setHeader("route", this.options.routeSet), this.setHeader("via", ""), this.setHeader("to", this.to.toString()), this.setHeader("from", this.from.toString()), this.setHeader("cseq", this.cseq + " " + this.method), this.setHeader("call-id", this.callId), this.setHeader("max-forwards", "70");
|
|
1744
1744
|
}
|
|
1745
1745
|
/** Get a copy of the default options. */
|
|
1746
1746
|
static getDefaultOptions() {
|
|
@@ -1762,7 +1762,7 @@ class ce {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
static makeNameAddrHeader(e, t, i) {
|
|
1764
1764
|
const s = {};
|
|
1765
|
-
return i && (s.tag = i), new
|
|
1765
|
+
return i && (s.tag = i), new F(e, t, s);
|
|
1766
1766
|
}
|
|
1767
1767
|
/**
|
|
1768
1768
|
* Get the value of the given header name at the given position.
|
|
@@ -1858,10 +1858,10 @@ class ce {
|
|
|
1858
1858
|
`;
|
|
1859
1859
|
return e += "Supported: " + this.options.optionTags.join(", ") + `\r
|
|
1860
1860
|
`, e += "User-Agent: " + this.options.userAgentString + `\r
|
|
1861
|
-
`, this.body ? typeof this.body == "string" ? (e += "Content-Length: " +
|
|
1861
|
+
`, this.body ? typeof this.body == "string" ? (e += "Content-Length: " + ve(this.body) + `\r
|
|
1862
1862
|
\r
|
|
1863
1863
|
`, e += this.body) : this.body.body && this.body.contentType ? (e += "Content-Type: " + this.body.contentType + `\r
|
|
1864
|
-
`, e += "Content-Length: " +
|
|
1864
|
+
`, e += "Content-Length: " + ve(this.body.body) + `\r
|
|
1865
1865
|
\r
|
|
1866
1866
|
`, e += this.body.body) : e += `Content-Length: 0\r
|
|
1867
1867
|
\r
|
|
@@ -1870,27 +1870,27 @@ class ce {
|
|
|
1870
1870
|
`, e;
|
|
1871
1871
|
}
|
|
1872
1872
|
}
|
|
1873
|
-
function
|
|
1873
|
+
function at(a) {
|
|
1874
1874
|
return a === "application/sdp" ? "session" : "render";
|
|
1875
1875
|
}
|
|
1876
|
-
function
|
|
1876
|
+
function xe(a) {
|
|
1877
1877
|
const e = typeof a == "string" ? a : a.body, t = typeof a == "string" ? "application/sdp" : a.contentType;
|
|
1878
|
-
return { contentDisposition:
|
|
1878
|
+
return { contentDisposition: at(t), contentType: t, content: e };
|
|
1879
1879
|
}
|
|
1880
|
-
function
|
|
1880
|
+
function ot(a) {
|
|
1881
1881
|
return a && typeof a.content == "string" && typeof a.contentType == "string" && a.contentDisposition === void 0 ? !0 : typeof a.contentDisposition == "string";
|
|
1882
1882
|
}
|
|
1883
|
-
function
|
|
1883
|
+
function we(a) {
|
|
1884
1884
|
let e, t, i;
|
|
1885
|
-
if (a instanceof
|
|
1885
|
+
if (a instanceof ue && a.body) {
|
|
1886
1886
|
const s = a.parseHeader("Content-Disposition");
|
|
1887
1887
|
e = s ? s.type : void 0, t = a.parseHeader("Content-Type"), i = a.body;
|
|
1888
1888
|
}
|
|
1889
|
-
if (a instanceof
|
|
1889
|
+
if (a instanceof ne && a.body) {
|
|
1890
1890
|
const s = a.parseHeader("Content-Disposition");
|
|
1891
1891
|
e = s ? s.type : void 0, t = a.parseHeader("Content-Type"), i = a.body;
|
|
1892
1892
|
}
|
|
1893
|
-
if (a instanceof
|
|
1893
|
+
if (a instanceof de && a.body)
|
|
1894
1894
|
if (e = a.getHeader("Content-Disposition"), t = a.getHeader("Content-Type"), typeof a.body == "string") {
|
|
1895
1895
|
if (!t)
|
|
1896
1896
|
throw new Error("Header content type header does not equal body content type.");
|
|
@@ -1900,8 +1900,8 @@ function me(a) {
|
|
|
1900
1900
|
throw new Error("Header content type header does not equal body content type.");
|
|
1901
1901
|
t = a.body.contentType, i = a.body.body;
|
|
1902
1902
|
}
|
|
1903
|
-
if (
|
|
1904
|
-
if (t && !e && (e =
|
|
1903
|
+
if (ot(a) && (e = a.contentDisposition, t = a.contentType, i = a.content), !!i) {
|
|
1904
|
+
if (t && !e && (e = at(t)), !e)
|
|
1905
1905
|
throw new Error("Content disposition undefined.");
|
|
1906
1906
|
if (!t)
|
|
1907
1907
|
throw new Error("Content type undefined.");
|
|
@@ -1916,27 +1916,27 @@ var j;
|
|
|
1916
1916
|
(function(a) {
|
|
1917
1917
|
a.Initial = "Initial", a.Early = "Early", a.AckWait = "AckWait", a.Confirmed = "Confirmed", a.Terminated = "Terminated";
|
|
1918
1918
|
})(j = j || (j = {}));
|
|
1919
|
-
var
|
|
1919
|
+
var b;
|
|
1920
1920
|
(function(a) {
|
|
1921
1921
|
a.Initial = "Initial", a.HaveLocalOffer = "HaveLocalOffer", a.HaveRemoteOffer = "HaveRemoteOffer", a.Stable = "Stable", a.Closed = "Closed";
|
|
1922
|
-
})(
|
|
1923
|
-
const Z = 500,
|
|
1922
|
+
})(b = b || (b = {}));
|
|
1923
|
+
const Z = 500, Dt = 4e3, Je = 5e3, M = {
|
|
1924
1924
|
T1: Z,
|
|
1925
|
-
T2:
|
|
1925
|
+
T2: Dt,
|
|
1926
1926
|
TIMER_B: 64 * Z,
|
|
1927
1927
|
TIMER_D: 0 * Z,
|
|
1928
1928
|
TIMER_F: 64 * Z,
|
|
1929
1929
|
TIMER_H: 64 * Z,
|
|
1930
|
-
TIMER_I: 0 *
|
|
1930
|
+
TIMER_I: 0 * Je,
|
|
1931
1931
|
TIMER_J: 0 * Z,
|
|
1932
|
-
TIMER_K: 0 *
|
|
1932
|
+
TIMER_K: 0 * Je,
|
|
1933
1933
|
TIMER_L: 64 * Z,
|
|
1934
1934
|
TIMER_M: 64 * Z,
|
|
1935
1935
|
TIMER_N: 64 * Z,
|
|
1936
1936
|
PROVISIONAL_RESPONSE_INTERVAL: 6e4
|
|
1937
1937
|
// See RFC 3261 Section 13.3.1.1
|
|
1938
1938
|
};
|
|
1939
|
-
class
|
|
1939
|
+
class ie extends le {
|
|
1940
1940
|
constructor(e) {
|
|
1941
1941
|
super(e || "Transaction state error.");
|
|
1942
1942
|
}
|
|
@@ -1945,7 +1945,7 @@ var v;
|
|
|
1945
1945
|
(function(a) {
|
|
1946
1946
|
a.ACK = "ACK", a.BYE = "BYE", a.CANCEL = "CANCEL", a.INFO = "INFO", a.INVITE = "INVITE", a.MESSAGE = "MESSAGE", a.NOTIFY = "NOTIFY", a.OPTIONS = "OPTIONS", a.REGISTER = "REGISTER", a.UPDATE = "UPDATE", a.SUBSCRIBE = "SUBSCRIBE", a.PUBLISH = "PUBLISH", a.REFER = "REFER", a.PRACK = "PRACK";
|
|
1947
1947
|
})(v = v || (v = {}));
|
|
1948
|
-
const
|
|
1948
|
+
const se = [
|
|
1949
1949
|
v.ACK,
|
|
1950
1950
|
v.BYE,
|
|
1951
1951
|
v.CANCEL,
|
|
@@ -1959,7 +1959,7 @@ const ie = [
|
|
|
1959
1959
|
v.REGISTER,
|
|
1960
1960
|
v.SUBSCRIBE
|
|
1961
1961
|
];
|
|
1962
|
-
class
|
|
1962
|
+
class ct {
|
|
1963
1963
|
/** @internal */
|
|
1964
1964
|
constructor(e) {
|
|
1965
1965
|
this.incomingMessageRequest = e;
|
|
@@ -1977,7 +1977,7 @@ class at {
|
|
|
1977
1977
|
return this.incomingMessageRequest.reject(e), Promise.resolve();
|
|
1978
1978
|
}
|
|
1979
1979
|
}
|
|
1980
|
-
class
|
|
1980
|
+
class Be {
|
|
1981
1981
|
/** @internal */
|
|
1982
1982
|
constructor(e) {
|
|
1983
1983
|
this.incomingNotifyRequest = e;
|
|
@@ -1995,14 +1995,14 @@ class Le {
|
|
|
1995
1995
|
return this.incomingNotifyRequest.reject(e), Promise.resolve();
|
|
1996
1996
|
}
|
|
1997
1997
|
}
|
|
1998
|
-
class
|
|
1998
|
+
class kt {
|
|
1999
1999
|
/** @internal */
|
|
2000
2000
|
constructor(e, t) {
|
|
2001
2001
|
this.incomingReferRequest = e, this.session = t;
|
|
2002
2002
|
}
|
|
2003
2003
|
get referTo() {
|
|
2004
2004
|
const e = this.incomingReferRequest.message.parseHeader("refer-to");
|
|
2005
|
-
if (!(e instanceof
|
|
2005
|
+
if (!(e instanceof F))
|
|
2006
2006
|
throw new Error("Failed to parse Refer-To header.");
|
|
2007
2007
|
return e;
|
|
2008
2008
|
}
|
|
@@ -2053,7 +2053,7 @@ var m;
|
|
|
2053
2053
|
(function(a) {
|
|
2054
2054
|
a.Initial = "Initial", a.Establishing = "Establishing", a.Established = "Established", a.Terminating = "Terminating", a.Terminated = "Terminated";
|
|
2055
2055
|
})(m = m || (m = {}));
|
|
2056
|
-
class
|
|
2056
|
+
class ge {
|
|
2057
2057
|
/**
|
|
2058
2058
|
* Constructor.
|
|
2059
2059
|
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
@@ -2257,11 +2257,11 @@ class ue {
|
|
|
2257
2257
|
if (this.logger.log("Session.invite"), this.state !== m.Established)
|
|
2258
2258
|
return Promise.reject(new Error(`Invalid session state ${this.state}`));
|
|
2259
2259
|
if (this.pendingReinvite)
|
|
2260
|
-
return Promise.reject(new
|
|
2260
|
+
return Promise.reject(new ye("Reinvite in progress. Please wait until complete, then try again."));
|
|
2261
2261
|
this.pendingReinvite = !0, e.sessionDescriptionHandlerModifiers && (this.sessionDescriptionHandlerModifiersReInvite = e.sessionDescriptionHandlerModifiers), e.sessionDescriptionHandlerOptions && (this.sessionDescriptionHandlerOptionsReInvite = e.sessionDescriptionHandlerOptions);
|
|
2262
2262
|
const t = {
|
|
2263
2263
|
onAccept: (r) => {
|
|
2264
|
-
const n =
|
|
2264
|
+
const n = we(r.message);
|
|
2265
2265
|
if (!n) {
|
|
2266
2266
|
this.logger.error("Received 2xx response to re-INVITE without a session description"), this.ackAndBye(r, 400, "Missing session description"), this.stateTransition(m.Terminated), this.pendingReinvite = !1;
|
|
2267
2267
|
return;
|
|
@@ -2314,7 +2314,7 @@ class ue {
|
|
|
2314
2314
|
onTrying: (r) => {
|
|
2315
2315
|
}
|
|
2316
2316
|
}, i = e.requestOptions || {};
|
|
2317
|
-
if (i.extraHeaders = (i.extraHeaders || []).slice(), i.extraHeaders.push("Allow: " +
|
|
2317
|
+
if (i.extraHeaders = (i.extraHeaders || []).slice(), i.extraHeaders.push("Allow: " + se.toString()), i.extraHeaders.push("Contact: " + this._contact), e.withoutSdp) {
|
|
2318
2318
|
if (!this.dialog)
|
|
2319
2319
|
throw this.pendingReinvite = !1, new Error("Dialog undefined.");
|
|
2320
2320
|
return Promise.resolve(this.dialog.invite(t, i));
|
|
@@ -2349,7 +2349,7 @@ class ue {
|
|
|
2349
2349
|
refer(e, t = {}) {
|
|
2350
2350
|
if (this.state !== m.Established)
|
|
2351
2351
|
return this.logger.error("Session.refer() may only be called if established session."), Promise.reject(new Error(`Invalid session state ${this.state}`));
|
|
2352
|
-
if (e instanceof
|
|
2352
|
+
if (e instanceof ge && !e.dialog)
|
|
2353
2353
|
return this.logger.error("Session.refer() may only be called with session which is established. You are perhaps attempting to attended transfer to a target for which there is not dialog yet established. Perhaps you are attempting a 'semi-attended' tansfer? Regardless, this is not supported. The recommended approached is to check to see if the target Session is in the Established state before calling refer(); if the state is not Established you may proceed by falling back using a URI as the target (blind transfer)."), Promise.reject(new Error(`Invalid session state ${this.state}`));
|
|
2354
2354
|
const i = t.requestDelegate, s = this.copyRequestOptions(t.requestOptions);
|
|
2355
2355
|
return s.extraHeaders = s.extraHeaders ? s.extraHeaders.concat(this.referExtraHeaders(this.referToString(e))) : this.referExtraHeaders(this.referToString(e)), this._refer(t.onNotify, i, s);
|
|
@@ -2454,34 +2454,34 @@ class ue {
|
|
|
2454
2454
|
sessionDescriptionHandlerModifiers: this.pendingReinviteAck ? this._sessionDescriptionHandlerModifiersReInvite : this._sessionDescriptionHandlerModifiers
|
|
2455
2455
|
};
|
|
2456
2456
|
if (this.delegate && this.delegate.onAck) {
|
|
2457
|
-
const s = new
|
|
2457
|
+
const s = new Ct(e);
|
|
2458
2458
|
this.delegate.onAck(s);
|
|
2459
2459
|
}
|
|
2460
2460
|
switch (this.pendingReinviteAck = !1, t.signalingState) {
|
|
2461
|
-
case
|
|
2461
|
+
case b.Initial: {
|
|
2462
2462
|
this.logger.error(`Invalid signaling state ${t.signalingState}.`);
|
|
2463
2463
|
const s = ["Reason: " + this.getReasonHeaderValue(488, "Bad Media Description")];
|
|
2464
2464
|
return t.bye(void 0, { extraHeaders: s }), this.stateTransition(m.Terminated), Promise.resolve();
|
|
2465
2465
|
}
|
|
2466
|
-
case
|
|
2467
|
-
const s =
|
|
2466
|
+
case b.Stable: {
|
|
2467
|
+
const s = we(e.message);
|
|
2468
2468
|
return s ? s.contentDisposition === "render" ? (this._renderbody = s.content, this._rendertype = s.contentType, Promise.resolve()) : s.contentDisposition !== "session" ? Promise.resolve() : this.setAnswer(s, i).catch((r) => {
|
|
2469
2469
|
this.logger.error(r.message);
|
|
2470
2470
|
const n = ["Reason: " + this.getReasonHeaderValue(488, "Bad Media Description")];
|
|
2471
2471
|
t.bye(void 0, { extraHeaders: n }), this.stateTransition(m.Terminated);
|
|
2472
2472
|
}) : Promise.resolve();
|
|
2473
2473
|
}
|
|
2474
|
-
case
|
|
2474
|
+
case b.HaveLocalOffer: {
|
|
2475
2475
|
this.logger.error(`Invalid signaling state ${t.signalingState}.`);
|
|
2476
2476
|
const s = ["Reason: " + this.getReasonHeaderValue(488, "Bad Media Description")];
|
|
2477
2477
|
return t.bye(void 0, { extraHeaders: s }), this.stateTransition(m.Terminated), Promise.resolve();
|
|
2478
2478
|
}
|
|
2479
|
-
case
|
|
2479
|
+
case b.HaveRemoteOffer: {
|
|
2480
2480
|
this.logger.error(`Invalid signaling state ${t.signalingState}.`);
|
|
2481
2481
|
const s = ["Reason: " + this.getReasonHeaderValue(488, "Bad Media Description")];
|
|
2482
2482
|
return t.bye(void 0, { extraHeaders: s }), this.stateTransition(m.Terminated), Promise.resolve();
|
|
2483
2483
|
}
|
|
2484
|
-
case
|
|
2484
|
+
case b.Closed:
|
|
2485
2485
|
throw new Error(`Invalid signaling state ${t.signalingState}.`);
|
|
2486
2486
|
default:
|
|
2487
2487
|
throw new Error(`Invalid signaling state ${t.signalingState}.`);
|
|
@@ -2497,7 +2497,7 @@ class ue {
|
|
|
2497
2497
|
return;
|
|
2498
2498
|
}
|
|
2499
2499
|
if (this.delegate && this.delegate.onBye) {
|
|
2500
|
-
const t = new
|
|
2500
|
+
const t = new xt(e);
|
|
2501
2501
|
this.delegate.onBye(t);
|
|
2502
2502
|
} else
|
|
2503
2503
|
e.accept();
|
|
@@ -2513,7 +2513,7 @@ class ue {
|
|
|
2513
2513
|
return;
|
|
2514
2514
|
}
|
|
2515
2515
|
if (this.delegate && this.delegate.onInfo) {
|
|
2516
|
-
const t = new
|
|
2516
|
+
const t = new It(e);
|
|
2517
2517
|
this.delegate.onInfo(t);
|
|
2518
2518
|
} else
|
|
2519
2519
|
e.accept();
|
|
@@ -2545,7 +2545,7 @@ class ue {
|
|
|
2545
2545
|
}).catch((s) => {
|
|
2546
2546
|
if (this.logger.error(s.message), this.logger.error("Failed to handle to re-INVITE request"), !this.dialog)
|
|
2547
2547
|
throw new Error("Dialog undefined.");
|
|
2548
|
-
if (this.logger.error(this.dialog.signalingState), this.dialog.signalingState ===
|
|
2548
|
+
if (this.logger.error(this.dialog.signalingState), this.dialog.signalingState === b.Stable) {
|
|
2549
2549
|
const r = e.reject({ statusCode: 488 });
|
|
2550
2550
|
this.delegate && this.delegate.onInvite && this.delegate.onInvite(e.message, r.message, 488);
|
|
2551
2551
|
return;
|
|
@@ -2576,7 +2576,7 @@ class ue {
|
|
|
2576
2576
|
return;
|
|
2577
2577
|
}
|
|
2578
2578
|
if (this.delegate && this.delegate.onMessage) {
|
|
2579
|
-
const t = new
|
|
2579
|
+
const t = new ct(e);
|
|
2580
2580
|
this.delegate.onMessage(t);
|
|
2581
2581
|
} else
|
|
2582
2582
|
e.accept();
|
|
@@ -2591,12 +2591,12 @@ class ue {
|
|
|
2591
2591
|
return;
|
|
2592
2592
|
}
|
|
2593
2593
|
if (this.onNotify) {
|
|
2594
|
-
const t = new
|
|
2594
|
+
const t = new Be(e);
|
|
2595
2595
|
this.onNotify(t);
|
|
2596
2596
|
return;
|
|
2597
2597
|
}
|
|
2598
2598
|
if (this.delegate && this.delegate.onNotify) {
|
|
2599
|
-
const t = new
|
|
2599
|
+
const t = new Be(e);
|
|
2600
2600
|
this.delegate.onNotify(t);
|
|
2601
2601
|
} else
|
|
2602
2602
|
e.accept();
|
|
@@ -2626,7 +2626,7 @@ class ue {
|
|
|
2626
2626
|
this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."), e.reject();
|
|
2627
2627
|
return;
|
|
2628
2628
|
}
|
|
2629
|
-
const t = new
|
|
2629
|
+
const t = new kt(e, this);
|
|
2630
2630
|
this.delegate && this.delegate.onRefer ? this.delegate.onRefer(t) : (this.logger.log("No delegate available to handle REFER, automatically accepting and following."), t.accept().then(() => t.makeInviter(this._referralInviterOptions).invite()).catch((i) => {
|
|
2631
2631
|
this.logger.error(i.message);
|
|
2632
2632
|
}));
|
|
@@ -2641,7 +2641,7 @@ class ue {
|
|
|
2641
2641
|
generateResponseOfferAnswer(e, t) {
|
|
2642
2642
|
if (this.dialog)
|
|
2643
2643
|
return this.generateResponseOfferAnswerInDialog(t);
|
|
2644
|
-
const i =
|
|
2644
|
+
const i = we(e.message);
|
|
2645
2645
|
return !i || i.contentDisposition !== "session" ? this.getOffer(t) : this.setOfferAndGetAnswer(i, t);
|
|
2646
2646
|
}
|
|
2647
2647
|
/**
|
|
@@ -2654,17 +2654,17 @@ class ue {
|
|
|
2654
2654
|
if (!this.dialog)
|
|
2655
2655
|
throw new Error("Dialog undefined.");
|
|
2656
2656
|
switch (this.dialog.signalingState) {
|
|
2657
|
-
case
|
|
2657
|
+
case b.Initial:
|
|
2658
2658
|
return this.getOffer(e);
|
|
2659
|
-
case
|
|
2659
|
+
case b.HaveLocalOffer:
|
|
2660
2660
|
return Promise.resolve(void 0);
|
|
2661
|
-
case
|
|
2661
|
+
case b.HaveRemoteOffer:
|
|
2662
2662
|
if (!this.dialog.offer)
|
|
2663
2663
|
throw new Error(`Session offer undefined in signaling state ${this.dialog.signalingState}.`);
|
|
2664
2664
|
return this.setOfferAndGetAnswer(this.dialog.offer, e);
|
|
2665
|
-
case
|
|
2665
|
+
case b.Stable:
|
|
2666
2666
|
return this.state !== m.Established ? Promise.resolve(void 0) : this.getOffer(e);
|
|
2667
|
-
case
|
|
2667
|
+
case b.Closed:
|
|
2668
2668
|
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
2669
2669
|
default:
|
|
2670
2670
|
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
@@ -2677,7 +2677,7 @@ class ue {
|
|
|
2677
2677
|
getOffer(e) {
|
|
2678
2678
|
const t = this.setupSessionDescriptionHandler(), i = e.sessionDescriptionHandlerOptions, s = e.sessionDescriptionHandlerModifiers;
|
|
2679
2679
|
try {
|
|
2680
|
-
return t.getDescription(i, s).then((r) =>
|
|
2680
|
+
return t.getDescription(i, s).then((r) => xe(r)).catch((r) => {
|
|
2681
2681
|
this.logger.error("Session.getOffer: SDH getDescription rejected...");
|
|
2682
2682
|
const n = r instanceof Error ? r : new Error("Session.getOffer unknown error.");
|
|
2683
2683
|
throw this.logger.error(n.message), n;
|
|
@@ -2716,7 +2716,7 @@ class ue {
|
|
|
2716
2716
|
const i = this.setupSessionDescriptionHandler(), s = t.sessionDescriptionHandlerOptions, r = t.sessionDescriptionHandlerModifiers;
|
|
2717
2717
|
try {
|
|
2718
2718
|
if (!i.hasDescription(e.contentType))
|
|
2719
|
-
return Promise.reject(new
|
|
2719
|
+
return Promise.reject(new Le());
|
|
2720
2720
|
} catch (n) {
|
|
2721
2721
|
this.logger.error("Session.setAnswer: SDH hasDescription threw...");
|
|
2722
2722
|
const o = n instanceof Error ? n : new Error(n);
|
|
@@ -2742,14 +2742,14 @@ class ue {
|
|
|
2742
2742
|
const i = this.setupSessionDescriptionHandler(), s = t.sessionDescriptionHandlerOptions, r = t.sessionDescriptionHandlerModifiers;
|
|
2743
2743
|
try {
|
|
2744
2744
|
if (!i.hasDescription(e.contentType))
|
|
2745
|
-
return Promise.reject(new
|
|
2745
|
+
return Promise.reject(new Le());
|
|
2746
2746
|
} catch (n) {
|
|
2747
2747
|
this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");
|
|
2748
2748
|
const o = n instanceof Error ? n : new Error(n);
|
|
2749
2749
|
return this.logger.error(o.message), Promise.reject(o);
|
|
2750
2750
|
}
|
|
2751
2751
|
try {
|
|
2752
|
-
return i.setDescription(e.content, s, r).then(() => i.getDescription(s, r)).then((n) =>
|
|
2752
|
+
return i.setDescription(e.content, s, r).then(() => i.getDescription(s, r)).then((n) => xe(n)).catch((n) => {
|
|
2753
2753
|
this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription rejected...");
|
|
2754
2754
|
const o = n instanceof Error ? n : new Error("Session.setOfferAndGetAnswer unknown error.");
|
|
2755
2755
|
throw this.logger.error(o.message), o;
|
|
@@ -2819,7 +2819,7 @@ class ue {
|
|
|
2819
2819
|
}
|
|
2820
2820
|
getReasonHeaderValue(e, t) {
|
|
2821
2821
|
const i = e;
|
|
2822
|
-
let s =
|
|
2822
|
+
let s = Ae(e);
|
|
2823
2823
|
return !s && t && (s = t), "SIP;cause=" + i + ';text="' + s + '"';
|
|
2824
2824
|
}
|
|
2825
2825
|
referExtraHeaders(e) {
|
|
@@ -2843,7 +2843,7 @@ var G;
|
|
|
2843
2843
|
(function(a) {
|
|
2844
2844
|
a.Required = "Required", a.Supported = "Supported", a.Unsupported = "Unsupported";
|
|
2845
2845
|
})(G = G || (G = {}));
|
|
2846
|
-
const
|
|
2846
|
+
const Pt = {
|
|
2847
2847
|
"100rel": !0,
|
|
2848
2848
|
199: !0,
|
|
2849
2849
|
answermode: !0,
|
|
@@ -2879,7 +2879,7 @@ const Dt = {
|
|
|
2879
2879
|
uui: !0
|
|
2880
2880
|
// RFC 7433
|
|
2881
2881
|
};
|
|
2882
|
-
class
|
|
2882
|
+
class ce extends ge {
|
|
2883
2883
|
/** @internal */
|
|
2884
2884
|
constructor(e, t) {
|
|
2885
2885
|
super(e), this.incomingInviteRequest = t, this.disposed = !1, this.expiresTimer = void 0, this.isCanceled = !1, this.rel100 = "none", this.rseq = Math.floor(Math.random() * 1e4), this.userNoAnswerTimer = void 0, this.waitingForPrack = !1, this.logger = e.getLogger("sip.Invitation");
|
|
@@ -3030,10 +3030,10 @@ class oe extends ue {
|
|
|
3030
3030
|
const n = new Error(`Invalid session state ${this.state}`);
|
|
3031
3031
|
return this.logger.error(n.message), Promise.reject(n);
|
|
3032
3032
|
}
|
|
3033
|
-
const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase :
|
|
3033
|
+
const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase : Ae(t), s = e.extraHeaders || [];
|
|
3034
3034
|
if (t < 300 || t > 699)
|
|
3035
3035
|
throw new TypeError("Invalid statusCode: " + t);
|
|
3036
|
-
const r = e.body ?
|
|
3036
|
+
const r = e.body ? xe(e.body) : void 0;
|
|
3037
3037
|
return t < 400 ? this.incomingInviteRequest.redirect([], { statusCode: t, reasonPhrase: i, extraHeaders: s, body: r }) : this.incomingInviteRequest.reject({ statusCode: t, reasonPhrase: i, extraHeaders: s, body: r }), this.stateTransition(m.Terminated), Promise.resolve();
|
|
3038
3038
|
}
|
|
3039
3039
|
/**
|
|
@@ -3049,7 +3049,7 @@ class oe extends ue {
|
|
|
3049
3049
|
return;
|
|
3050
3050
|
}
|
|
3051
3051
|
if (this.delegate && this.delegate.onCancel) {
|
|
3052
|
-
const t = new
|
|
3052
|
+
const t = new Rt(e);
|
|
3053
3053
|
this.delegate.onCancel(t);
|
|
3054
3054
|
}
|
|
3055
3055
|
this.isCanceled = !0, this.incomingInviteRequest.reject({ statusCode: 487 }), this.stateTransition(m.Terminated);
|
|
@@ -3060,7 +3060,7 @@ class oe extends ue {
|
|
|
3060
3060
|
handlePrackOfferAnswer(e) {
|
|
3061
3061
|
if (!this.dialog)
|
|
3062
3062
|
throw new Error("Dialog undefined.");
|
|
3063
|
-
const t =
|
|
3063
|
+
const t = we(e.message);
|
|
3064
3064
|
if (!t || t.contentDisposition !== "session")
|
|
3065
3065
|
return Promise.resolve(void 0);
|
|
3066
3066
|
const i = {
|
|
@@ -3068,16 +3068,16 @@ class oe extends ue {
|
|
|
3068
3068
|
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers
|
|
3069
3069
|
};
|
|
3070
3070
|
switch (this.dialog.signalingState) {
|
|
3071
|
-
case
|
|
3071
|
+
case b.Initial:
|
|
3072
3072
|
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
3073
|
-
case
|
|
3073
|
+
case b.Stable:
|
|
3074
3074
|
return this.setAnswer(t, i).then(() => {
|
|
3075
3075
|
});
|
|
3076
|
-
case
|
|
3076
|
+
case b.HaveLocalOffer:
|
|
3077
3077
|
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
3078
|
-
case
|
|
3078
|
+
case b.HaveRemoteOffer:
|
|
3079
3079
|
return this.setOfferAndGetAnswer(t, i);
|
|
3080
|
-
case
|
|
3080
|
+
case b.Closed:
|
|
3081
3081
|
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
3082
3082
|
default:
|
|
3083
3083
|
throw new Error(`Invalid signaling state ${this.dialog.signalingState}.`);
|
|
@@ -3092,7 +3092,7 @@ class oe extends ue {
|
|
|
3092
3092
|
*/
|
|
3093
3093
|
handleResponseError(e) {
|
|
3094
3094
|
let t = 480;
|
|
3095
|
-
if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof
|
|
3095
|
+
if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof Le ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof Et ? this.logger.error("A session description handler occurred while sending response") : e instanceof He ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof ie && this.logger.error("Session changed state before response could be formulated and sent"), this.state === m.Initial || this.state === m.Establishing)
|
|
3096
3096
|
try {
|
|
3097
3097
|
this.incomingInviteRequest.reject({ statusCode: t }), this.stateTransition(m.Terminated);
|
|
3098
3098
|
} catch (i) {
|
|
@@ -3129,7 +3129,7 @@ class oe extends ue {
|
|
|
3129
3129
|
* @param options - Options bucket.
|
|
3130
3130
|
*/
|
|
3131
3131
|
sendProgress(e = {}) {
|
|
3132
|
-
const t = e.statusCode || 180, i = e.reasonPhrase, s = (e.extraHeaders || []).slice(), r = e.body ?
|
|
3132
|
+
const t = e.statusCode || 180, i = e.reasonPhrase, s = (e.extraHeaders || []).slice(), r = e.body ? xe(e.body) : void 0;
|
|
3133
3133
|
if (t === 183 && !r)
|
|
3134
3134
|
return this.sendProgressWithSDP(e);
|
|
3135
3135
|
try {
|
|
@@ -3174,17 +3174,17 @@ class oe extends ue {
|
|
|
3174
3174
|
let u, w;
|
|
3175
3175
|
p.session.delegate = {
|
|
3176
3176
|
onPrack: (f) => {
|
|
3177
|
-
u = f, clearTimeout(I), clearTimeout(
|
|
3177
|
+
u = f, clearTimeout(I), clearTimeout(ae), this.waitingForPrack && (this.waitingForPrack = !1, this.handlePrackOfferAnswer(u).then((_) => {
|
|
3178
3178
|
try {
|
|
3179
3179
|
w = u.accept({ statusCode: 200, body: _ }), this.prackArrived(), o({ prackRequest: u, prackResponse: w, progressResponse: p });
|
|
3180
|
-
} catch (
|
|
3181
|
-
d(
|
|
3180
|
+
} catch (ke) {
|
|
3181
|
+
d(ke);
|
|
3182
3182
|
}
|
|
3183
3183
|
}).catch((_) => d(_)));
|
|
3184
3184
|
}
|
|
3185
3185
|
};
|
|
3186
3186
|
const I = setTimeout(() => {
|
|
3187
|
-
this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(
|
|
3187
|
+
this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(ae), this.reject({ statusCode: 504 }).then(() => d(new He())).catch((f) => d(f)));
|
|
3188
3188
|
}, M.T1 * 64), A = () => {
|
|
3189
3189
|
try {
|
|
3190
3190
|
this.incomingInviteRequest.progress({ statusCode: i, reasonPhrase: s, extraHeaders: r, body: n });
|
|
@@ -3192,9 +3192,9 @@ class oe extends ue {
|
|
|
3192
3192
|
this.waitingForPrack = !1, d(f);
|
|
3193
3193
|
return;
|
|
3194
3194
|
}
|
|
3195
|
-
|
|
3195
|
+
ae = setTimeout(A, C *= 2);
|
|
3196
3196
|
};
|
|
3197
|
-
let C = M.T1,
|
|
3197
|
+
let C = M.T1, ae = setTimeout(A, C);
|
|
3198
3198
|
}).catch((p) => {
|
|
3199
3199
|
this.waitingForPrack = !1, d(p);
|
|
3200
3200
|
});
|
|
@@ -3236,10 +3236,10 @@ class oe extends ue {
|
|
|
3236
3236
|
* the accept to fail and the session to transition to "terminated".
|
|
3237
3237
|
*/
|
|
3238
3238
|
prackNeverArrived() {
|
|
3239
|
-
this.waitingForPrackReject && this.waitingForPrackReject(new
|
|
3239
|
+
this.waitingForPrackReject && this.waitingForPrackReject(new He()), this.waitingForPrackPromise = void 0, this.waitingForPrackResolve = void 0, this.waitingForPrackReject = void 0;
|
|
3240
3240
|
}
|
|
3241
3241
|
}
|
|
3242
|
-
class
|
|
3242
|
+
class Ee extends ge {
|
|
3243
3243
|
/**
|
|
3244
3244
|
* Constructs a new instance of the `Inviter` class.
|
|
3245
3245
|
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
@@ -3247,7 +3247,7 @@ class Te extends ue {
|
|
|
3247
3247
|
* @param options - Options bucket. See {@link InviterOptions} for details.
|
|
3248
3248
|
*/
|
|
3249
3249
|
constructor(e, t, i = {}) {
|
|
3250
|
-
super(e, i), this.disposed = !1, this.earlyMedia = !1, this.earlyMediaSessionDescriptionHandlers = /* @__PURE__ */ new Map(), this.isCanceled = !1, this.inviteWithoutSdp = !1, this.logger = e.getLogger("sip.Inviter"), this.earlyMedia = i.earlyMedia !== void 0 ? i.earlyMedia : this.earlyMedia, this.fromTag =
|
|
3250
|
+
super(e, i), this.disposed = !1, this.earlyMedia = !1, this.earlyMediaSessionDescriptionHandlers = /* @__PURE__ */ new Map(), this.isCanceled = !1, this.inviteWithoutSdp = !1, this.logger = e.getLogger("sip.Inviter"), this.earlyMedia = i.earlyMedia !== void 0 ? i.earlyMedia : this.earlyMedia, this.fromTag = _e(), this.inviteWithoutSdp = i.inviteWithoutSdp !== void 0 ? i.inviteWithoutSdp : this.inviteWithoutSdp;
|
|
3251
3251
|
const s = Object.assign({}, i);
|
|
3252
3252
|
s.params = Object.assign({}, i.params);
|
|
3253
3253
|
const r = i.anonymous || !1, n = e.contact.toString({
|
|
@@ -3339,7 +3339,7 @@ class Te extends ue {
|
|
|
3339
3339
|
if (i && i < 200 || i > 699)
|
|
3340
3340
|
throw new TypeError("Invalid statusCode: " + i);
|
|
3341
3341
|
if (i) {
|
|
3342
|
-
const r = i, n =
|
|
3342
|
+
const r = i, n = Ae(i) || s;
|
|
3343
3343
|
return "SIP;cause=" + r + ';text="' + n + '"';
|
|
3344
3344
|
}
|
|
3345
3345
|
}
|
|
@@ -3531,7 +3531,7 @@ class Te extends ue {
|
|
|
3531
3531
|
notifyReferer(e) {
|
|
3532
3532
|
if (!this._referred)
|
|
3533
3533
|
return;
|
|
3534
|
-
if (!(this._referred instanceof
|
|
3534
|
+
if (!(this._referred instanceof ge))
|
|
3535
3535
|
throw new Error("Referred session not instance of session");
|
|
3536
3536
|
if (!this._referred.dialog)
|
|
3537
3537
|
return;
|
|
@@ -3571,11 +3571,11 @@ class Te extends ue {
|
|
|
3571
3571
|
onPrack: (s) => this.onPrackRequest(s),
|
|
3572
3572
|
onRefer: (s) => this.onReferRequest(s)
|
|
3573
3573
|
}, this._dialog = i, i.signalingState) {
|
|
3574
|
-
case
|
|
3574
|
+
case b.Initial:
|
|
3575
3575
|
return this.logger.error("Received 2xx response to INVITE without a session description"), this.ackAndBye(e, 400, "Missing session description"), this.stateTransition(m.Terminated), Promise.reject(new Error("Bad Media Description"));
|
|
3576
|
-
case
|
|
3576
|
+
case b.HaveLocalOffer:
|
|
3577
3577
|
return this.logger.error("Received 2xx response to INVITE without a session description"), this.ackAndBye(e, 400, "Missing session description"), this.stateTransition(m.Terminated), Promise.reject(new Error("Bad Media Description"));
|
|
3578
|
-
case
|
|
3578
|
+
case b.HaveRemoteOffer: {
|
|
3579
3579
|
if (!this._dialog.offer)
|
|
3580
3580
|
throw new Error(`Session offer undefined in signaling state ${this._dialog.signalingState}.`);
|
|
3581
3581
|
const s = {
|
|
@@ -3588,7 +3588,7 @@ class Te extends ue {
|
|
|
3588
3588
|
throw this.ackAndBye(e, 488, "Invalid session description"), this.stateTransition(m.Terminated), r;
|
|
3589
3589
|
});
|
|
3590
3590
|
}
|
|
3591
|
-
case
|
|
3591
|
+
case b.Stable: {
|
|
3592
3592
|
if (this.earlyMediaSessionDescriptionHandlers.size > 0) {
|
|
3593
3593
|
const n = this.earlyMediaSessionDescriptionHandlers.get(i.id);
|
|
3594
3594
|
if (!n)
|
|
@@ -3619,7 +3619,7 @@ class Te extends ue {
|
|
|
3619
3619
|
throw this.logger.error(n.message), this.ackAndBye(e, 488, "Not Acceptable Here"), this.stateTransition(m.Terminated), n;
|
|
3620
3620
|
});
|
|
3621
3621
|
}
|
|
3622
|
-
case
|
|
3622
|
+
case b.Closed:
|
|
3623
3623
|
return Promise.reject(new Error("Terminated."));
|
|
3624
3624
|
default:
|
|
3625
3625
|
throw new Error("Unknown session signaling state.");
|
|
@@ -3639,11 +3639,11 @@ class Te extends ue {
|
|
|
3639
3639
|
i.hasHeader("P-Asserted-Identity") && (this._assertedIdentity = k.nameAddrHeaderParse(i.getHeader("P-Asserted-Identity")));
|
|
3640
3640
|
const r = i.getHeader("require"), n = i.getHeader("rseq"), d = !!(r && r.includes("100rel") && n ? Number(n) : void 0), p = [];
|
|
3641
3641
|
switch (d && p.push("RAck: " + i.getHeader("rseq") + " " + i.getHeader("cseq")), s.signalingState) {
|
|
3642
|
-
case
|
|
3642
|
+
case b.Initial:
|
|
3643
3643
|
return d && (this.logger.warn("First reliable provisional response received MUST contain an offer when INVITE does not contain an offer."), e.prack({ extraHeaders: p })), Promise.resolve();
|
|
3644
|
-
case
|
|
3644
|
+
case b.HaveLocalOffer:
|
|
3645
3645
|
return d && e.prack({ extraHeaders: p }), Promise.resolve();
|
|
3646
|
-
case
|
|
3646
|
+
case b.HaveRemoteOffer:
|
|
3647
3647
|
if (!d)
|
|
3648
3648
|
return this.logger.warn("Non-reliable provisional response MUST NOT contain an initial offer, discarding response."), Promise.resolve();
|
|
3649
3649
|
{
|
|
@@ -3659,7 +3659,7 @@ class Te extends ue {
|
|
|
3659
3659
|
throw this.stateTransition(m.Terminated), w;
|
|
3660
3660
|
});
|
|
3661
3661
|
}
|
|
3662
|
-
case
|
|
3662
|
+
case b.Stable:
|
|
3663
3663
|
if (d && e.prack({ extraHeaders: p }), this.earlyMedia && !this.earlyMediaDialog) {
|
|
3664
3664
|
this.earlyMediaDialog = s;
|
|
3665
3665
|
const u = s.answer;
|
|
@@ -3674,7 +3674,7 @@ class Te extends ue {
|
|
|
3674
3674
|
});
|
|
3675
3675
|
}
|
|
3676
3676
|
return Promise.resolve();
|
|
3677
|
-
case
|
|
3677
|
+
case b.Closed:
|
|
3678
3678
|
return Promise.reject(new Error("Terminated."));
|
|
3679
3679
|
default:
|
|
3680
3680
|
throw new Error("Unknown session signaling state.");
|
|
@@ -3716,7 +3716,7 @@ class Te extends ue {
|
|
|
3716
3716
|
}
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
|
-
class
|
|
3719
|
+
class Ht {
|
|
3720
3720
|
/**
|
|
3721
3721
|
* Constructs a new instance of the `Messager` class.
|
|
3722
3722
|
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
@@ -3877,7 +3877,7 @@ class z {
|
|
|
3877
3877
|
throw this.stateError(), new Error("Registerer disposed. Unable to register.");
|
|
3878
3878
|
if (this.waiting) {
|
|
3879
3879
|
this.waitingWarning();
|
|
3880
|
-
const s = new
|
|
3880
|
+
const s = new ye("REGISTER request already in progress, waiting for final response");
|
|
3881
3881
|
return Promise.reject(s);
|
|
3882
3882
|
}
|
|
3883
3883
|
e.requestOptions && (this.options = Object.assign(Object.assign({}, this.options), e.requestOptions));
|
|
@@ -3896,7 +3896,7 @@ class z {
|
|
|
3896
3896
|
for (; n--; ) {
|
|
3897
3897
|
if (o = s.message.parseHeader("contact", n), !o)
|
|
3898
3898
|
throw new Error("Contact undefined");
|
|
3899
|
-
if (this.userAgent.contact.pubGruu &&
|
|
3899
|
+
if (this.userAgent.contact.pubGruu && Ye(o.uri, this.userAgent.contact.pubGruu)) {
|
|
3900
3900
|
r = Number(o.getParam("expires"));
|
|
3901
3901
|
break;
|
|
3902
3902
|
}
|
|
@@ -3905,7 +3905,7 @@ class z {
|
|
|
3905
3905
|
r = Number(o.getParam("expires"));
|
|
3906
3906
|
break;
|
|
3907
3907
|
}
|
|
3908
|
-
} else if (
|
|
3908
|
+
} else if (Ye(o.uri, this.userAgent.contact.uri)) {
|
|
3909
3909
|
r = Number(o.getParam("expires"));
|
|
3910
3910
|
break;
|
|
3911
3911
|
}
|
|
@@ -3970,7 +3970,7 @@ class z {
|
|
|
3970
3970
|
throw this.stateError(), new Error("Registerer disposed. Unable to register.");
|
|
3971
3971
|
if (this.waiting) {
|
|
3972
3972
|
this.waitingWarning();
|
|
3973
|
-
const s = new
|
|
3973
|
+
const s = new ye("REGISTER request already in progress, waiting for final response");
|
|
3974
3974
|
return Promise.reject(s);
|
|
3975
3975
|
}
|
|
3976
3976
|
this._state !== x.Registered && !e.all && this.logger.warn("Not currently registered, but sending an unregister anyway.");
|
|
@@ -4208,7 +4208,7 @@ P.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592" && console.error("Md5
|
|
|
4208
4208
|
function ee(a) {
|
|
4209
4209
|
return P.hashStr(a);
|
|
4210
4210
|
}
|
|
4211
|
-
class
|
|
4211
|
+
class Mt {
|
|
4212
4212
|
/**
|
|
4213
4213
|
* Constructor.
|
|
4214
4214
|
* @param loggerFactory - LoggerFactory.
|
|
@@ -4245,7 +4245,7 @@ class Pt {
|
|
|
4245
4245
|
return this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted"), !1;
|
|
4246
4246
|
else
|
|
4247
4247
|
this.qop = void 0;
|
|
4248
|
-
return this.method = e.method, this.uri = e.ruri, this.cnonce =
|
|
4248
|
+
return this.method = e.method, this.uri = e.ruri, this.cnonce = oe(12), this.nc += 1, this.updateNcHex(), this.nc === 4294967296 && (this.nc = 1, this.ncHex = "00000001"), this.calculateResponse(i), !0;
|
|
4249
4249
|
}
|
|
4250
4250
|
/**
|
|
4251
4251
|
* Return the Proxy-Authorization or WWW-Authorization header value.
|
|
@@ -4275,7 +4275,7 @@ var H;
|
|
|
4275
4275
|
(function(a) {
|
|
4276
4276
|
a[a.error = 0] = "error", a[a.warn = 1] = "warn", a[a.log = 2] = "log", a[a.debug = 3] = "debug";
|
|
4277
4277
|
})(H = H || (H = {}));
|
|
4278
|
-
class
|
|
4278
|
+
class Ze {
|
|
4279
4279
|
constructor(e, t, i) {
|
|
4280
4280
|
this.logger = e, this.category = t, this.label = i;
|
|
4281
4281
|
}
|
|
@@ -4301,7 +4301,7 @@ class Je {
|
|
|
4301
4301
|
this.logger.level = e;
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
4304
|
-
class
|
|
4304
|
+
class qt {
|
|
4305
4305
|
constructor() {
|
|
4306
4306
|
this.builtinEnabled = !0, this._level = H.log, this.loggers = {}, this.logger = this.getLogger("sip:loggerfactory");
|
|
4307
4307
|
}
|
|
@@ -4320,11 +4320,11 @@ class Ht {
|
|
|
4320
4320
|
}
|
|
4321
4321
|
getLogger(e, t) {
|
|
4322
4322
|
if (t && this.level === 3)
|
|
4323
|
-
return new
|
|
4323
|
+
return new Ze(this, e, t);
|
|
4324
4324
|
if (this.loggers[e])
|
|
4325
4325
|
return this.loggers[e];
|
|
4326
4326
|
{
|
|
4327
|
-
const i = new
|
|
4327
|
+
const i = new Ze(this, e);
|
|
4328
4328
|
return this.loggers[e] = i, i;
|
|
4329
4329
|
}
|
|
4330
4330
|
}
|
|
@@ -4354,7 +4354,7 @@ class Ht {
|
|
|
4354
4354
|
}
|
|
4355
4355
|
}
|
|
4356
4356
|
}
|
|
4357
|
-
var
|
|
4357
|
+
var Ce;
|
|
4358
4358
|
(function(a) {
|
|
4359
4359
|
function e(s, r) {
|
|
4360
4360
|
let n = r, o = 0, d = 0;
|
|
@@ -4425,7 +4425,7 @@ var Ee;
|
|
|
4425
4425
|
s.setHeader("content-type", u), w = s.parseHeader("content-type");
|
|
4426
4426
|
break;
|
|
4427
4427
|
case "cseq":
|
|
4428
|
-
s.setHeader("cseq", u), w = s.parseHeader("cseq"), w && (s.cseq = w.value), s instanceof
|
|
4428
|
+
s.setHeader("cseq", u), w = s.parseHeader("cseq"), w && (s.cseq = w.value), s instanceof ne && (s.method = w.method);
|
|
4429
4429
|
break;
|
|
4430
4430
|
case "max-forwards":
|
|
4431
4431
|
s.setHeader("max-forwards", u), w = s.parseHeader("max-forwards");
|
|
@@ -4460,7 +4460,7 @@ var Ee;
|
|
|
4460
4460
|
if (p === -1) {
|
|
4461
4461
|
r.warn('error parsing first line of SIP message: "' + d + '"');
|
|
4462
4462
|
return;
|
|
4463
|
-
} else p.status_code ? (u = new
|
|
4463
|
+
} else p.status_code ? (u = new ne(), u.statusCode = p.status_code, u.reasonPhrase = p.reason_phrase) : (u = new ue(), u.method = p.method, u.ruri = p.uri);
|
|
4464
4464
|
u.data = s, n = o + 2;
|
|
4465
4465
|
let w;
|
|
4466
4466
|
for (; ; ) {
|
|
@@ -4481,11 +4481,11 @@ var Ee;
|
|
|
4481
4481
|
return u.hasHeader("content-length") ? u.body = s.substr(w, Number(u.getHeader("content-length"))) : u.body = s.substring(w), u;
|
|
4482
4482
|
}
|
|
4483
4483
|
a.parseMessage = i;
|
|
4484
|
-
})(
|
|
4485
|
-
function
|
|
4484
|
+
})(Ce = Ce || (Ce = {}));
|
|
4485
|
+
function dt(a, e) {
|
|
4486
4486
|
if (e.statusCode < 100 || e.statusCode > 699)
|
|
4487
4487
|
throw new TypeError("Invalid statusCode: " + e.statusCode);
|
|
4488
|
-
const i = e.reasonPhrase ? e.reasonPhrase :
|
|
4488
|
+
const i = e.reasonPhrase ? e.reasonPhrase : Ae(e.statusCode);
|
|
4489
4489
|
let s = "SIP/2.0 " + e.statusCode + " " + i + `\r
|
|
4490
4490
|
`;
|
|
4491
4491
|
e.statusCode >= 100 && e.statusCode < 200, e.statusCode;
|
|
@@ -4497,7 +4497,7 @@ function ot(a, e) {
|
|
|
4497
4497
|
let p = "To: " + a.getHeader("to");
|
|
4498
4498
|
if (e.statusCode > 100 && !a.parseHeader("to").hasParam("tag")) {
|
|
4499
4499
|
let I = e.toTag;
|
|
4500
|
-
I || (I =
|
|
4500
|
+
I || (I = _e()), p += ";tag=" + I;
|
|
4501
4501
|
}
|
|
4502
4502
|
p += `\r
|
|
4503
4503
|
`;
|
|
@@ -4510,18 +4510,18 @@ function ot(a, e) {
|
|
|
4510
4510
|
let S = "";
|
|
4511
4511
|
return e.extraHeaders && (S = e.extraHeaders.reduce((I, A) => I + A.trim() + `\r
|
|
4512
4512
|
`, "")), s += d, s += r, s += p, s += o, s += n, s += u, s += w, s += S, e.body ? (s += "Content-Type: " + e.body.contentType + `\r
|
|
4513
|
-
`, s += "Content-Length: " +
|
|
4513
|
+
`, s += "Content-Length: " + ve(e.body.content) + `\r
|
|
4514
4514
|
\r
|
|
4515
4515
|
`, s += e.body.content) : s += `Content-Length: 0\r
|
|
4516
4516
|
\r
|
|
4517
4517
|
`, { message: s };
|
|
4518
4518
|
}
|
|
4519
|
-
class
|
|
4519
|
+
class qe extends le {
|
|
4520
4520
|
constructor(e) {
|
|
4521
4521
|
super(e || "Unspecified transport error.");
|
|
4522
4522
|
}
|
|
4523
4523
|
}
|
|
4524
|
-
class
|
|
4524
|
+
class lt {
|
|
4525
4525
|
constructor(e, t, i, s, r) {
|
|
4526
4526
|
this._transport = e, this._user = t, this._id = i, this._state = s, this.listeners = new Array(), this.logger = t.loggerFactory.getLogger(r, i), this.logger.debug(`Constructing ${this.typeToString()} with id ${this.id}.`);
|
|
4527
4527
|
}
|
|
@@ -4592,10 +4592,10 @@ class ct {
|
|
|
4592
4592
|
*/
|
|
4593
4593
|
send(e) {
|
|
4594
4594
|
return this.transport.send(e).catch((t) => {
|
|
4595
|
-
if (t instanceof
|
|
4595
|
+
if (t instanceof qe)
|
|
4596
4596
|
throw this.onTransportError(t), t;
|
|
4597
4597
|
let i;
|
|
4598
|
-
throw t && typeof t.message == "string" ? i = new
|
|
4598
|
+
throw t && typeof t.message == "string" ? i = new qe(t.message) : i = new qe(), this.onTransportError(i), i;
|
|
4599
4599
|
});
|
|
4600
4600
|
}
|
|
4601
4601
|
setState(e) {
|
|
@@ -4605,7 +4605,7 @@ class ct {
|
|
|
4605
4605
|
return "UnknownType";
|
|
4606
4606
|
}
|
|
4607
4607
|
}
|
|
4608
|
-
class
|
|
4608
|
+
class ht extends lt {
|
|
4609
4609
|
constructor(e, t, i, s, r) {
|
|
4610
4610
|
super(t, i, e.viaBranch, s, r), this._request = e, this.user = i;
|
|
4611
4611
|
}
|
|
@@ -4618,7 +4618,7 @@ var g;
|
|
|
4618
4618
|
(function(a) {
|
|
4619
4619
|
a.Accepted = "Accepted", a.Calling = "Calling", a.Completed = "Completed", a.Confirmed = "Confirmed", a.Proceeding = "Proceeding", a.Terminated = "Terminated", a.Trying = "Trying";
|
|
4620
4620
|
})(g = g || (g = {}));
|
|
4621
|
-
class U extends
|
|
4621
|
+
class U extends ht {
|
|
4622
4622
|
/**
|
|
4623
4623
|
* Constructor.
|
|
4624
4624
|
* Upon construction, a "100 Trying" reply will be immediately sent.
|
|
@@ -4848,9 +4848,9 @@ class U extends dt {
|
|
|
4848
4848
|
this.logger.debug(`Timer L expired for INVITE server transaction ${this.id}.`), this.state === g.Accepted && this.stateTransition(g.Terminated);
|
|
4849
4849
|
}
|
|
4850
4850
|
}
|
|
4851
|
-
class
|
|
4851
|
+
class $e extends lt {
|
|
4852
4852
|
constructor(e, t, i, s, r) {
|
|
4853
|
-
super(t, i,
|
|
4853
|
+
super(t, i, $e.makeId(e), s, r), this._request = e, this.user = i, e.setViaHeader(this.id, t.protocol);
|
|
4854
4854
|
}
|
|
4855
4855
|
static makeId(e) {
|
|
4856
4856
|
if (e.method === "CANCEL") {
|
|
@@ -4878,7 +4878,7 @@ class _e extends ct {
|
|
|
4878
4878
|
this.user.onRequestTimeout && this.user.onRequestTimeout();
|
|
4879
4879
|
}
|
|
4880
4880
|
}
|
|
4881
|
-
class L extends
|
|
4881
|
+
class L extends $e {
|
|
4882
4882
|
/**
|
|
4883
4883
|
* Constructor
|
|
4884
4884
|
* Upon construction, the outgoing request's Via header is updated by calling `setViaHeader`.
|
|
@@ -5010,7 +5010,7 @@ class L extends _e {
|
|
|
5010
5010
|
this.state === g.Completed && this.stateTransition(g.Terminated);
|
|
5011
5011
|
}
|
|
5012
5012
|
}
|
|
5013
|
-
class
|
|
5013
|
+
class fe {
|
|
5014
5014
|
/**
|
|
5015
5015
|
* Dialog constructor.
|
|
5016
5016
|
* @param core - User agent core.
|
|
@@ -5031,7 +5031,7 @@ class ge {
|
|
|
5031
5031
|
const s = t.getHeaders("record-route").reverse(), r = t.parseHeader("contact");
|
|
5032
5032
|
if (!r)
|
|
5033
5033
|
throw new Error("Contact undefined.");
|
|
5034
|
-
if (!(r instanceof
|
|
5034
|
+
if (!(r instanceof F))
|
|
5035
5035
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
5036
5036
|
const n = r.uri, o = e.cseq, d = void 0, p = e.callId, u = e.fromTag, w = t.toTag;
|
|
5037
5037
|
if (!p)
|
|
@@ -5074,7 +5074,7 @@ class ge {
|
|
|
5074
5074
|
const r = e.getHeaders("record-route"), n = e.parseHeader("contact");
|
|
5075
5075
|
if (!n)
|
|
5076
5076
|
throw new Error("Contact undefined.");
|
|
5077
|
-
if (!(n instanceof
|
|
5077
|
+
if (!(n instanceof F))
|
|
5078
5078
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
5079
5079
|
const o = n.uri, d = e.cseq, p = void 0, u = e.callId, w = t, S = e.fromTag, I = e.from.uri, A = e.to.uri;
|
|
5080
5080
|
return {
|
|
@@ -5267,7 +5267,7 @@ class ge {
|
|
|
5267
5267
|
return e.method === v.ACK ? !0 : this.remoteSequenceNumber && e.cseq <= this.remoteSequenceNumber ? (this.core.replyStateless(e, { statusCode: 500 }), !1) : !0;
|
|
5268
5268
|
}
|
|
5269
5269
|
}
|
|
5270
|
-
class
|
|
5270
|
+
class re extends $e {
|
|
5271
5271
|
/**
|
|
5272
5272
|
* Constructor.
|
|
5273
5273
|
* Upon construction, the outgoing request's Via header is updated by calling `setViaHeader`.
|
|
@@ -5587,7 +5587,7 @@ class q {
|
|
|
5587
5587
|
*/
|
|
5588
5588
|
onRequestTimeout() {
|
|
5589
5589
|
this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");
|
|
5590
|
-
const e = new
|
|
5590
|
+
const e = new ne();
|
|
5591
5591
|
e.statusCode = 408, e.reasonPhrase = "Request Timeout", this.receiveResponse(e);
|
|
5592
5592
|
}
|
|
5593
5593
|
/**
|
|
@@ -5605,7 +5605,7 @@ class q {
|
|
|
5605
5605
|
*/
|
|
5606
5606
|
onTransportError(e) {
|
|
5607
5607
|
this.logger.error(e.message), this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");
|
|
5608
|
-
const t = new
|
|
5608
|
+
const t = new ne();
|
|
5609
5609
|
t.statusCode = 503, t.reasonPhrase = "Service Unavailable", this.receiveResponse(t);
|
|
5610
5610
|
}
|
|
5611
5611
|
/**
|
|
@@ -5653,13 +5653,13 @@ class q {
|
|
|
5653
5653
|
this.core.userAgentClients.set(i, this);
|
|
5654
5654
|
}
|
|
5655
5655
|
}
|
|
5656
|
-
class
|
|
5656
|
+
class Ot extends q {
|
|
5657
5657
|
constructor(e, t, i) {
|
|
5658
5658
|
const s = e.createOutgoingRequestMessage(v.BYE, i);
|
|
5659
5659
|
super(L, e.userAgentCore, s, t), e.dispose();
|
|
5660
5660
|
}
|
|
5661
5661
|
}
|
|
5662
|
-
class N extends
|
|
5662
|
+
class N extends ht {
|
|
5663
5663
|
/**
|
|
5664
5664
|
* Constructor.
|
|
5665
5665
|
* After construction the transaction will be in the "trying": state and the transaction
|
|
@@ -5800,7 +5800,7 @@ class N extends dt {
|
|
|
5800
5800
|
}
|
|
5801
5801
|
class J {
|
|
5802
5802
|
constructor(e, t, i, s) {
|
|
5803
|
-
this.transactionConstructor = e, this.core = t, this.message = i, this.delegate = s, this.logger = this.loggerFactory.getLogger("sip.user-agent-server"), this.toTag = i.toTag ? i.toTag :
|
|
5803
|
+
this.transactionConstructor = e, this.core = t, this.message = i, this.delegate = s, this.logger = this.loggerFactory.getLogger("sip.user-agent-server"), this.toTag = i.toTag ? i.toTag : _e(), this.init();
|
|
5804
5804
|
}
|
|
5805
5805
|
dispose() {
|
|
5806
5806
|
this.transaction.dispose();
|
|
@@ -5816,7 +5816,7 @@ class J {
|
|
|
5816
5816
|
}
|
|
5817
5817
|
accept(e = { statusCode: 200 }) {
|
|
5818
5818
|
if (!this.acceptable)
|
|
5819
|
-
throw new
|
|
5819
|
+
throw new ie(`${this.message.method} not acceptable in state ${this.transaction.state}.`);
|
|
5820
5820
|
const t = e.statusCode;
|
|
5821
5821
|
if (t < 200 || t > 299)
|
|
5822
5822
|
throw new TypeError(`Invalid statusCode: ${t}`);
|
|
@@ -5824,7 +5824,7 @@ class J {
|
|
|
5824
5824
|
}
|
|
5825
5825
|
progress(e = { statusCode: 180 }) {
|
|
5826
5826
|
if (!this.progressable)
|
|
5827
|
-
throw new
|
|
5827
|
+
throw new ie(`${this.message.method} not progressable in state ${this.transaction.state}.`);
|
|
5828
5828
|
const t = e.statusCode;
|
|
5829
5829
|
if (t < 101 || t > 199)
|
|
5830
5830
|
throw new TypeError(`Invalid statusCode: ${t}`);
|
|
@@ -5832,7 +5832,7 @@ class J {
|
|
|
5832
5832
|
}
|
|
5833
5833
|
redirect(e, t = { statusCode: 302 }) {
|
|
5834
5834
|
if (!this.redirectable)
|
|
5835
|
-
throw new
|
|
5835
|
+
throw new ie(`${this.message.method} not redirectable in state ${this.transaction.state}.`);
|
|
5836
5836
|
const i = t.statusCode;
|
|
5837
5837
|
if (i < 300 || i > 399)
|
|
5838
5838
|
throw new TypeError(`Invalid statusCode: ${i}`);
|
|
@@ -5841,7 +5841,7 @@ class J {
|
|
|
5841
5841
|
}
|
|
5842
5842
|
reject(e = { statusCode: 480 }) {
|
|
5843
5843
|
if (!this.rejectable)
|
|
5844
|
-
throw new
|
|
5844
|
+
throw new ie(`${this.message.method} not rejectable in state ${this.transaction.state}.`);
|
|
5845
5845
|
const t = e.statusCode;
|
|
5846
5846
|
if (t < 400 || t > 699)
|
|
5847
5847
|
throw new TypeError(`Invalid statusCode: ${t}`);
|
|
@@ -5850,7 +5850,7 @@ class J {
|
|
|
5850
5850
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5851
5851
|
trying(e) {
|
|
5852
5852
|
if (!this.tryingable)
|
|
5853
|
-
throw new
|
|
5853
|
+
throw new ie(`${this.message.method} not tryingable in state ${this.transaction.state}.`);
|
|
5854
5854
|
return this.reply({ statusCode: 100 });
|
|
5855
5855
|
}
|
|
5856
5856
|
/**
|
|
@@ -5924,7 +5924,7 @@ class J {
|
|
|
5924
5924
|
*/
|
|
5925
5925
|
reply(e) {
|
|
5926
5926
|
!e.toTag && e.statusCode !== 100 && (e.toTag = this.toTag), e.userAgent = e.userAgent || this.core.configuration.userAgentHeaderFieldValue, e.supported = e.supported || this.core.configuration.supportedOptionTagsResponse;
|
|
5927
|
-
const t =
|
|
5927
|
+
const t = dt(this.message, e);
|
|
5928
5928
|
return this.transaction.receiveResponse(e.statusCode, t.message), t;
|
|
5929
5929
|
}
|
|
5930
5930
|
init() {
|
|
@@ -5942,59 +5942,59 @@ class J {
|
|
|
5942
5942
|
this.core.userAgentServers.set(t.id, this);
|
|
5943
5943
|
}
|
|
5944
5944
|
}
|
|
5945
|
-
class
|
|
5945
|
+
class Ft extends J {
|
|
5946
5946
|
constructor(e, t, i) {
|
|
5947
5947
|
super(N, e.userAgentCore, t, i);
|
|
5948
5948
|
}
|
|
5949
5949
|
}
|
|
5950
|
-
class
|
|
5950
|
+
class Ut extends q {
|
|
5951
5951
|
constructor(e, t, i) {
|
|
5952
5952
|
const s = e.createOutgoingRequestMessage(v.INFO, i);
|
|
5953
5953
|
super(L, e.userAgentCore, s, t);
|
|
5954
5954
|
}
|
|
5955
5955
|
}
|
|
5956
|
-
class
|
|
5956
|
+
class Nt extends J {
|
|
5957
5957
|
constructor(e, t, i) {
|
|
5958
5958
|
super(N, e.userAgentCore, t, i);
|
|
5959
5959
|
}
|
|
5960
5960
|
}
|
|
5961
|
-
class
|
|
5961
|
+
class ut extends q {
|
|
5962
5962
|
constructor(e, t, i) {
|
|
5963
5963
|
super(L, e, t, i);
|
|
5964
5964
|
}
|
|
5965
5965
|
}
|
|
5966
|
-
class
|
|
5966
|
+
class gt extends J {
|
|
5967
5967
|
constructor(e, t, i) {
|
|
5968
5968
|
super(N, e, t, i);
|
|
5969
5969
|
}
|
|
5970
5970
|
}
|
|
5971
|
-
class
|
|
5971
|
+
class Lt extends q {
|
|
5972
5972
|
constructor(e, t, i) {
|
|
5973
5973
|
const s = e.createOutgoingRequestMessage(v.NOTIFY, i);
|
|
5974
5974
|
super(L, e.userAgentCore, s, t);
|
|
5975
5975
|
}
|
|
5976
5976
|
}
|
|
5977
|
-
function
|
|
5977
|
+
function Bt(a) {
|
|
5978
5978
|
return a.userAgentCore !== void 0;
|
|
5979
5979
|
}
|
|
5980
|
-
class
|
|
5980
|
+
class Re extends J {
|
|
5981
5981
|
/**
|
|
5982
5982
|
* NOTIFY UAS constructor.
|
|
5983
5983
|
* @param dialogOrCore - Dialog for in dialog NOTIFY, UserAgentCore for out of dialog NOTIFY (deprecated).
|
|
5984
5984
|
* @param message - Incoming NOTIFY request message.
|
|
5985
5985
|
*/
|
|
5986
5986
|
constructor(e, t, i) {
|
|
5987
|
-
const s =
|
|
5987
|
+
const s = Bt(e) ? e.userAgentCore : e;
|
|
5988
5988
|
super(N, s, t, i);
|
|
5989
5989
|
}
|
|
5990
5990
|
}
|
|
5991
|
-
class
|
|
5991
|
+
class jt extends q {
|
|
5992
5992
|
constructor(e, t, i) {
|
|
5993
5993
|
const s = e.createOutgoingRequestMessage(v.PRACK, i);
|
|
5994
5994
|
super(L, e.userAgentCore, s, t), e.signalingStateTransition(s);
|
|
5995
5995
|
}
|
|
5996
5996
|
}
|
|
5997
|
-
class
|
|
5997
|
+
class Vt extends J {
|
|
5998
5998
|
constructor(e, t, i) {
|
|
5999
5999
|
super(N, e.userAgentCore, t, i), e.signalingStateTransition(t), this.dialog = e;
|
|
6000
6000
|
}
|
|
@@ -6006,10 +6006,10 @@ class Bt extends J {
|
|
|
6006
6006
|
return e.body && this.dialog.signalingStateTransition(e.body), super.accept(e);
|
|
6007
6007
|
}
|
|
6008
6008
|
}
|
|
6009
|
-
class
|
|
6009
|
+
class Gt extends q {
|
|
6010
6010
|
constructor(e, t, i) {
|
|
6011
6011
|
const s = e.createOutgoingRequestMessage(v.INVITE, i);
|
|
6012
|
-
super(
|
|
6012
|
+
super(re, e.userAgentCore, s, t), this.delegate = t, e.signalingStateTransition(s), e.reinviteUserAgentClient = this, this.dialog = e;
|
|
6013
6013
|
}
|
|
6014
6014
|
receiveResponse(e) {
|
|
6015
6015
|
if (!this.authenticationGuard(e, this.dialog))
|
|
@@ -6049,7 +6049,7 @@ class jt extends q {
|
|
|
6049
6049
|
}
|
|
6050
6050
|
}
|
|
6051
6051
|
}
|
|
6052
|
-
class
|
|
6052
|
+
class Kt extends J {
|
|
6053
6053
|
constructor(e, t, i) {
|
|
6054
6054
|
super(U, e.userAgentCore, t, i), e.reinviteUserAgentServer = this, this.dialog = e;
|
|
6055
6055
|
}
|
|
@@ -6091,36 +6091,36 @@ class Vt extends J {
|
|
|
6091
6091
|
return this.dialog.signalingStateRollback(), this.dialog.reinviteUserAgentServer = void 0, super.reject(e);
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
|
-
class
|
|
6094
|
+
class Wt extends q {
|
|
6095
6095
|
constructor(e, t, i) {
|
|
6096
6096
|
const s = e.createOutgoingRequestMessage(v.REFER, i);
|
|
6097
6097
|
super(L, e.userAgentCore, s, t);
|
|
6098
6098
|
}
|
|
6099
6099
|
}
|
|
6100
|
-
function
|
|
6100
|
+
function zt(a) {
|
|
6101
6101
|
return a.userAgentCore !== void 0;
|
|
6102
6102
|
}
|
|
6103
|
-
class
|
|
6103
|
+
class ft extends J {
|
|
6104
6104
|
/**
|
|
6105
6105
|
* REFER UAS constructor.
|
|
6106
6106
|
* @param dialogOrCore - Dialog for in dialog REFER, UserAgentCore for out of dialog REFER.
|
|
6107
6107
|
* @param message - Incoming REFER request message.
|
|
6108
6108
|
*/
|
|
6109
6109
|
constructor(e, t, i) {
|
|
6110
|
-
const s =
|
|
6110
|
+
const s = zt(e) ? e.userAgentCore : e;
|
|
6111
6111
|
super(N, s, t, i);
|
|
6112
6112
|
}
|
|
6113
6113
|
}
|
|
6114
|
-
class
|
|
6114
|
+
class Ie extends fe {
|
|
6115
6115
|
constructor(e, t, i, s) {
|
|
6116
|
-
super(t, i), this.initialTransaction = e, this._signalingState =
|
|
6116
|
+
super(t, i), this.initialTransaction = e, this._signalingState = b.Initial, this.ackWait = !1, this.ackProcessing = !1, this.delegate = s, e instanceof U && (this.ackWait = !0), this.early || this.start2xxRetransmissionTimer(), this.signalingStateTransition(e.request), this.logger = t.loggerFactory.getLogger("sip.invite-dialog"), this.logger.log(`INVITE dialog ${this.id} constructed`);
|
|
6117
6117
|
}
|
|
6118
6118
|
dispose() {
|
|
6119
|
-
super.dispose(), this._signalingState =
|
|
6119
|
+
super.dispose(), this._signalingState = b.Closed, this._offer = void 0, this._answer = void 0, this.invite2xxTimer && (clearTimeout(this.invite2xxTimer), this.invite2xxTimer = void 0), this.logger.log(`INVITE dialog ${this.id} destroyed`);
|
|
6120
6120
|
}
|
|
6121
6121
|
// FIXME: Need real state machine
|
|
6122
6122
|
get sessionState() {
|
|
6123
|
-
return this.early ? j.Early : this.ackWait ? j.AckWait : this._signalingState ===
|
|
6123
|
+
return this.early ? j.Early : this.ackWait ? j.AckWait : this._signalingState === b.Closed ? j.Terminated : j.Confirmed;
|
|
6124
6124
|
}
|
|
6125
6125
|
/** The state of the offer/answer exchange. */
|
|
6126
6126
|
get signalingState() {
|
|
@@ -6161,11 +6161,11 @@ class Re extends ge {
|
|
|
6161
6161
|
this.logger.log(`INVITE dialog ${this.id} sending ACK request`);
|
|
6162
6162
|
let t;
|
|
6163
6163
|
if (this.reinviteUserAgentClient) {
|
|
6164
|
-
if (!(this.reinviteUserAgentClient.transaction instanceof
|
|
6164
|
+
if (!(this.reinviteUserAgentClient.transaction instanceof re))
|
|
6165
6165
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6166
6166
|
t = this.reinviteUserAgentClient.transaction, this.reinviteUserAgentClient = void 0;
|
|
6167
6167
|
} else {
|
|
6168
|
-
if (!(this.initialTransaction instanceof
|
|
6168
|
+
if (!(this.initialTransaction instanceof re))
|
|
6169
6169
|
throw new Error("Initial transaction not instance of InviteClientTransaction.");
|
|
6170
6170
|
t = this.initialTransaction;
|
|
6171
6171
|
}
|
|
@@ -6220,7 +6220,7 @@ class Re extends ge {
|
|
|
6220
6220
|
if (this.ackWait && this.initialTransaction.state !== g.Terminated)
|
|
6221
6221
|
throw new Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.");
|
|
6222
6222
|
}
|
|
6223
|
-
return new
|
|
6223
|
+
return new Ot(this, e, t);
|
|
6224
6224
|
}
|
|
6225
6225
|
/**
|
|
6226
6226
|
* An INFO request can be associated with an Info Package (see
|
|
@@ -6235,7 +6235,7 @@ class Re extends ge {
|
|
|
6235
6235
|
info(e, t) {
|
|
6236
6236
|
if (this.logger.log(`INVITE dialog ${this.id} sending INFO request`), this.early)
|
|
6237
6237
|
throw new Error("Dialog not confirmed.");
|
|
6238
|
-
return new
|
|
6238
|
+
return new Ut(this, e, t);
|
|
6239
6239
|
}
|
|
6240
6240
|
/**
|
|
6241
6241
|
* Modifying an Existing Session
|
|
@@ -6265,7 +6265,7 @@ class Re extends ge {
|
|
|
6265
6265
|
throw new Error("There is an ongoing re-INVITE client transaction.");
|
|
6266
6266
|
if (this.reinviteUserAgentServer)
|
|
6267
6267
|
throw new Error("There is an ongoing re-INVITE server transaction.");
|
|
6268
|
-
return new
|
|
6268
|
+
return new Gt(this, e, t);
|
|
6269
6269
|
}
|
|
6270
6270
|
/**
|
|
6271
6271
|
* A UAC MAY associate a MESSAGE request with an existing dialog. If a
|
|
@@ -6278,7 +6278,7 @@ class Re extends ge {
|
|
|
6278
6278
|
if (this.logger.log(`INVITE dialog ${this.id} sending MESSAGE request`), this.early)
|
|
6279
6279
|
throw new Error("Dialog not confirmed.");
|
|
6280
6280
|
const i = this.createOutgoingRequestMessage(v.MESSAGE, t);
|
|
6281
|
-
return new
|
|
6281
|
+
return new ut(this.core, i, e);
|
|
6282
6282
|
}
|
|
6283
6283
|
/**
|
|
6284
6284
|
* The NOTIFY mechanism defined in [2] MUST be used to inform the agent
|
|
@@ -6289,7 +6289,7 @@ class Re extends ge {
|
|
|
6289
6289
|
notify(e, t) {
|
|
6290
6290
|
if (this.logger.log(`INVITE dialog ${this.id} sending NOTIFY request`), this.early)
|
|
6291
6291
|
throw new Error("Dialog not confirmed.");
|
|
6292
|
-
return new
|
|
6292
|
+
return new Lt(this, e, t);
|
|
6293
6293
|
}
|
|
6294
6294
|
/**
|
|
6295
6295
|
* Assuming the response is to be transmitted reliably, the UAC MUST
|
|
@@ -6302,7 +6302,7 @@ class Re extends ge {
|
|
|
6302
6302
|
* @param options - Options bucket.
|
|
6303
6303
|
*/
|
|
6304
6304
|
prack(e, t) {
|
|
6305
|
-
return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`), new
|
|
6305
|
+
return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`), new jt(this, e, t);
|
|
6306
6306
|
}
|
|
6307
6307
|
/**
|
|
6308
6308
|
* REFER is a SIP request and is constructed as defined in [1]. A REFER
|
|
@@ -6313,7 +6313,7 @@ class Re extends ge {
|
|
|
6313
6313
|
refer(e, t) {
|
|
6314
6314
|
if (this.logger.log(`INVITE dialog ${this.id} sending REFER request`), this.early)
|
|
6315
6315
|
throw new Error("Dialog not confirmed.");
|
|
6316
|
-
return new
|
|
6316
|
+
return new Wt(this, e, t);
|
|
6317
6317
|
}
|
|
6318
6318
|
/**
|
|
6319
6319
|
* Requests sent within a dialog, as any other requests, are atomic. If
|
|
@@ -6326,7 +6326,7 @@ class Re extends ge {
|
|
|
6326
6326
|
receiveRequest(e) {
|
|
6327
6327
|
if (this.logger.log(`INVITE dialog ${this.id} received ${e.method} request`), e.method === v.ACK) {
|
|
6328
6328
|
if (this.ackWait) {
|
|
6329
|
-
if (this.initialTransaction instanceof
|
|
6329
|
+
if (this.initialTransaction instanceof re) {
|
|
6330
6330
|
this.logger.warn(`INVITE dialog ${this.id} received unexpected ${e.method} request, dropping.`);
|
|
6331
6331
|
return;
|
|
6332
6332
|
}
|
|
@@ -6367,7 +6367,7 @@ class Re extends ge {
|
|
|
6367
6367
|
this.core.replyStateless(e, { statusCode: 500, extraHeaders: s }), t();
|
|
6368
6368
|
return;
|
|
6369
6369
|
}
|
|
6370
|
-
if (this.ackWait && this.signalingState !==
|
|
6370
|
+
if (this.ackWait && this.signalingState !== b.Stable) {
|
|
6371
6371
|
this.core.replyStateless(e, { statusCode: 500, extraHeaders: s }), t();
|
|
6372
6372
|
return;
|
|
6373
6373
|
}
|
|
@@ -6384,20 +6384,20 @@ class Re extends ge {
|
|
|
6384
6384
|
const t = e.parseHeader("contact");
|
|
6385
6385
|
if (!t)
|
|
6386
6386
|
throw new Error("Contact undefined.");
|
|
6387
|
-
if (!(t instanceof
|
|
6387
|
+
if (!(t instanceof F))
|
|
6388
6388
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
6389
6389
|
this.dialogState.remoteTarget = t.uri;
|
|
6390
6390
|
}
|
|
6391
6391
|
switch (e.method) {
|
|
6392
6392
|
case v.BYE:
|
|
6393
6393
|
{
|
|
6394
|
-
const t = new
|
|
6394
|
+
const t = new Ft(this, e);
|
|
6395
6395
|
this.delegate && this.delegate.onBye ? this.delegate.onBye(t) : t.accept(), this.dispose();
|
|
6396
6396
|
}
|
|
6397
6397
|
break;
|
|
6398
6398
|
case v.INFO:
|
|
6399
6399
|
{
|
|
6400
|
-
const t = new
|
|
6400
|
+
const t = new Nt(this, e);
|
|
6401
6401
|
this.delegate && this.delegate.onInfo ? this.delegate.onInfo(t) : t.reject({
|
|
6402
6402
|
statusCode: 469,
|
|
6403
6403
|
extraHeaders: ["Recv-Info:"]
|
|
@@ -6406,31 +6406,31 @@ class Re extends ge {
|
|
|
6406
6406
|
break;
|
|
6407
6407
|
case v.INVITE:
|
|
6408
6408
|
{
|
|
6409
|
-
const t = new
|
|
6409
|
+
const t = new Kt(this, e);
|
|
6410
6410
|
this.signalingStateTransition(e), this.delegate && this.delegate.onInvite ? this.delegate.onInvite(t) : t.reject({ statusCode: 488 });
|
|
6411
6411
|
}
|
|
6412
6412
|
break;
|
|
6413
6413
|
case v.MESSAGE:
|
|
6414
6414
|
{
|
|
6415
|
-
const t = new
|
|
6415
|
+
const t = new gt(this.core, e);
|
|
6416
6416
|
this.delegate && this.delegate.onMessage ? this.delegate.onMessage(t) : t.accept();
|
|
6417
6417
|
}
|
|
6418
6418
|
break;
|
|
6419
6419
|
case v.NOTIFY:
|
|
6420
6420
|
{
|
|
6421
|
-
const t = new
|
|
6421
|
+
const t = new Re(this, e);
|
|
6422
6422
|
this.delegate && this.delegate.onNotify ? this.delegate.onNotify(t) : t.accept();
|
|
6423
6423
|
}
|
|
6424
6424
|
break;
|
|
6425
6425
|
case v.PRACK:
|
|
6426
6426
|
{
|
|
6427
|
-
const t = new
|
|
6427
|
+
const t = new Vt(this, e);
|
|
6428
6428
|
this.delegate && this.delegate.onPrack ? this.delegate.onPrack(t) : t.accept();
|
|
6429
6429
|
}
|
|
6430
6430
|
break;
|
|
6431
6431
|
case v.REFER:
|
|
6432
6432
|
{
|
|
6433
|
-
const t = new
|
|
6433
|
+
const t = new ft(this, e);
|
|
6434
6434
|
this.delegate && this.delegate.onRefer ? this.delegate.onRefer(t) : t.reject();
|
|
6435
6435
|
}
|
|
6436
6436
|
break;
|
|
@@ -6462,75 +6462,75 @@ class Re extends ge {
|
|
|
6462
6462
|
* If not in a stable signaling state, rollback to prior stable signaling state.
|
|
6463
6463
|
*/
|
|
6464
6464
|
signalingStateRollback() {
|
|
6465
|
-
(this._signalingState ===
|
|
6465
|
+
(this._signalingState === b.HaveLocalOffer || this.signalingState === b.HaveRemoteOffer) && this._rollbackOffer && this._rollbackAnswer && (this._signalingState = b.Stable, this._offer = this._rollbackOffer, this._answer = this._rollbackAnswer);
|
|
6466
6466
|
}
|
|
6467
6467
|
/**
|
|
6468
6468
|
* Update the signaling state of the dialog.
|
|
6469
6469
|
* @param message - The message to base the update off of.
|
|
6470
6470
|
*/
|
|
6471
6471
|
signalingStateTransition(e) {
|
|
6472
|
-
const t =
|
|
6472
|
+
const t = we(e);
|
|
6473
6473
|
if (!(!t || t.contentDisposition !== "session")) {
|
|
6474
|
-
if (this._signalingState ===
|
|
6474
|
+
if (this._signalingState === b.Stable && (this._rollbackOffer = this._offer, this._rollbackAnswer = this._answer), e instanceof ue)
|
|
6475
6475
|
switch (this._signalingState) {
|
|
6476
|
-
case
|
|
6477
|
-
case
|
|
6478
|
-
this._signalingState =
|
|
6476
|
+
case b.Initial:
|
|
6477
|
+
case b.Stable:
|
|
6478
|
+
this._signalingState = b.HaveRemoteOffer, this._offer = t, this._answer = void 0;
|
|
6479
6479
|
break;
|
|
6480
|
-
case
|
|
6481
|
-
this._signalingState =
|
|
6480
|
+
case b.HaveLocalOffer:
|
|
6481
|
+
this._signalingState = b.Stable, this._answer = t;
|
|
6482
6482
|
break;
|
|
6483
|
-
case
|
|
6483
|
+
case b.HaveRemoteOffer:
|
|
6484
6484
|
break;
|
|
6485
|
-
case
|
|
6485
|
+
case b.Closed:
|
|
6486
6486
|
break;
|
|
6487
6487
|
default:
|
|
6488
6488
|
throw new Error("Unexpected signaling state.");
|
|
6489
6489
|
}
|
|
6490
|
-
if (e instanceof
|
|
6490
|
+
if (e instanceof ne)
|
|
6491
6491
|
switch (this._signalingState) {
|
|
6492
|
-
case
|
|
6493
|
-
case
|
|
6494
|
-
this._signalingState =
|
|
6492
|
+
case b.Initial:
|
|
6493
|
+
case b.Stable:
|
|
6494
|
+
this._signalingState = b.HaveRemoteOffer, this._offer = t, this._answer = void 0;
|
|
6495
6495
|
break;
|
|
6496
|
-
case
|
|
6497
|
-
this._signalingState =
|
|
6496
|
+
case b.HaveLocalOffer:
|
|
6497
|
+
this._signalingState = b.Stable, this._answer = t;
|
|
6498
6498
|
break;
|
|
6499
|
-
case
|
|
6499
|
+
case b.HaveRemoteOffer:
|
|
6500
6500
|
break;
|
|
6501
|
-
case
|
|
6501
|
+
case b.Closed:
|
|
6502
6502
|
break;
|
|
6503
6503
|
default:
|
|
6504
6504
|
throw new Error("Unexpected signaling state.");
|
|
6505
6505
|
}
|
|
6506
|
-
if (e instanceof
|
|
6506
|
+
if (e instanceof de)
|
|
6507
6507
|
switch (this._signalingState) {
|
|
6508
|
-
case
|
|
6509
|
-
case
|
|
6510
|
-
this._signalingState =
|
|
6508
|
+
case b.Initial:
|
|
6509
|
+
case b.Stable:
|
|
6510
|
+
this._signalingState = b.HaveLocalOffer, this._offer = t, this._answer = void 0;
|
|
6511
6511
|
break;
|
|
6512
|
-
case
|
|
6512
|
+
case b.HaveLocalOffer:
|
|
6513
6513
|
break;
|
|
6514
|
-
case
|
|
6515
|
-
this._signalingState =
|
|
6514
|
+
case b.HaveRemoteOffer:
|
|
6515
|
+
this._signalingState = b.Stable, this._answer = t;
|
|
6516
6516
|
break;
|
|
6517
|
-
case
|
|
6517
|
+
case b.Closed:
|
|
6518
6518
|
break;
|
|
6519
6519
|
default:
|
|
6520
6520
|
throw new Error("Unexpected signaling state.");
|
|
6521
6521
|
}
|
|
6522
|
-
if (
|
|
6522
|
+
if (ot(e))
|
|
6523
6523
|
switch (this._signalingState) {
|
|
6524
|
-
case
|
|
6525
|
-
case
|
|
6526
|
-
this._signalingState =
|
|
6524
|
+
case b.Initial:
|
|
6525
|
+
case b.Stable:
|
|
6526
|
+
this._signalingState = b.HaveLocalOffer, this._offer = t, this._answer = void 0;
|
|
6527
6527
|
break;
|
|
6528
|
-
case
|
|
6528
|
+
case b.HaveLocalOffer:
|
|
6529
6529
|
break;
|
|
6530
|
-
case
|
|
6531
|
-
this._signalingState =
|
|
6530
|
+
case b.HaveRemoteOffer:
|
|
6531
|
+
this._signalingState = b.Stable, this._answer = t;
|
|
6532
6532
|
break;
|
|
6533
|
-
case
|
|
6533
|
+
case b.Closed:
|
|
6534
6534
|
break;
|
|
6535
6535
|
default:
|
|
6536
6536
|
throw new Error("Unexpected signaling state.");
|
|
@@ -6575,9 +6575,9 @@ class Re extends ge {
|
|
|
6575
6575
|
}
|
|
6576
6576
|
}
|
|
6577
6577
|
}
|
|
6578
|
-
class
|
|
6578
|
+
class Yt extends q {
|
|
6579
6579
|
constructor(e, t, i) {
|
|
6580
|
-
super(
|
|
6580
|
+
super(re, e, t, i), this.confirmedDialogAcks = /* @__PURE__ */ new Map(), this.confirmedDialogs = /* @__PURE__ */ new Map(), this.earlyDialogs = /* @__PURE__ */ new Map(), this.delegate = i;
|
|
6581
6581
|
}
|
|
6582
6582
|
dispose() {
|
|
6583
6583
|
this.earlyDialogs.forEach((e) => e.dispose()), this.earlyDialogs.clear(), super.dispose();
|
|
@@ -6617,19 +6617,19 @@ class Wt extends q {
|
|
|
6617
6617
|
this.logger.error("Non-100 1xx INVITE response received without a Contact header field, dropping.");
|
|
6618
6618
|
return;
|
|
6619
6619
|
}
|
|
6620
|
-
const s =
|
|
6620
|
+
const s = fe.initialDialogStateForUserAgentClient(this.message, e);
|
|
6621
6621
|
let r = this.earlyDialogs.get(s.id);
|
|
6622
6622
|
if (!r) {
|
|
6623
6623
|
const o = this.transaction;
|
|
6624
|
-
if (!(o instanceof
|
|
6624
|
+
if (!(o instanceof re))
|
|
6625
6625
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6626
|
-
r = new
|
|
6626
|
+
r = new Ie(o, this.core, s), this.earlyDialogs.set(r.id, r);
|
|
6627
6627
|
}
|
|
6628
6628
|
if (!r.reliableSequenceGuard(e)) {
|
|
6629
6629
|
this.logger.warn("1xx INVITE reliable response received out of order or is a retransmission, dropping.");
|
|
6630
6630
|
return;
|
|
6631
6631
|
}
|
|
6632
|
-
(r.signalingState ===
|
|
6632
|
+
(r.signalingState === b.Initial || r.signalingState === b.HaveLocalOffer) && r.signalingStateTransition(e);
|
|
6633
6633
|
const n = r;
|
|
6634
6634
|
this.delegate && this.delegate.onProgress && this.delegate.onProgress({
|
|
6635
6635
|
message: e,
|
|
@@ -6648,13 +6648,13 @@ class Wt extends q {
|
|
|
6648
6648
|
this.logger.error("2xx INVITE response received without a Contact header field, dropping.");
|
|
6649
6649
|
return;
|
|
6650
6650
|
}
|
|
6651
|
-
const s =
|
|
6651
|
+
const s = fe.initialDialogStateForUserAgentClient(this.message, e);
|
|
6652
6652
|
let r = this.confirmedDialogs.get(s.id);
|
|
6653
6653
|
if (r) {
|
|
6654
6654
|
const o = this.confirmedDialogAcks.get(s.id);
|
|
6655
6655
|
if (o) {
|
|
6656
6656
|
const d = this.transaction;
|
|
6657
|
-
if (!(d instanceof
|
|
6657
|
+
if (!(d instanceof re))
|
|
6658
6658
|
throw new Error("Client transaction not instance of InviteClientTransaction.");
|
|
6659
6659
|
d.ackResponse(o.message);
|
|
6660
6660
|
}
|
|
@@ -6664,11 +6664,11 @@ class Wt extends q {
|
|
|
6664
6664
|
r.confirm(), r.recomputeRouteSet(e), this.earlyDialogs.delete(r.id), this.confirmedDialogs.set(r.id, r);
|
|
6665
6665
|
else {
|
|
6666
6666
|
const o = this.transaction;
|
|
6667
|
-
if (!(o instanceof
|
|
6667
|
+
if (!(o instanceof re))
|
|
6668
6668
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6669
|
-
r = new
|
|
6669
|
+
r = new Ie(o, this.core, s), this.confirmedDialogs.set(r.id, r);
|
|
6670
6670
|
}
|
|
6671
|
-
(r.signalingState ===
|
|
6671
|
+
(r.signalingState === b.Initial || r.signalingState === b.HaveLocalOffer) && r.signalingStateTransition(e);
|
|
6672
6672
|
const n = r;
|
|
6673
6673
|
if (this.delegate && this.delegate.onAccept)
|
|
6674
6674
|
this.delegate.onAccept({
|
|
@@ -6696,7 +6696,7 @@ class Wt extends q {
|
|
|
6696
6696
|
}
|
|
6697
6697
|
}
|
|
6698
6698
|
}
|
|
6699
|
-
class
|
|
6699
|
+
class Oe extends J {
|
|
6700
6700
|
constructor(e, t, i) {
|
|
6701
6701
|
super(U, e, t, i), this.core = e;
|
|
6702
6702
|
}
|
|
@@ -6713,7 +6713,7 @@ class qe extends J {
|
|
|
6713
6713
|
*/
|
|
6714
6714
|
accept(e = { statusCode: 200 }) {
|
|
6715
6715
|
if (!this.acceptable)
|
|
6716
|
-
throw new
|
|
6716
|
+
throw new ie(`${this.message.method} not acceptable in state ${this.transaction.state}.`);
|
|
6717
6717
|
if (!this.confirmedDialog)
|
|
6718
6718
|
if (this.earlyDialog)
|
|
6719
6719
|
this.earlyDialog.confirm(), this.confirmedDialog = this.earlyDialog, this.earlyDialog = void 0;
|
|
@@ -6721,19 +6721,19 @@ class qe extends J {
|
|
|
6721
6721
|
const d = this.transaction;
|
|
6722
6722
|
if (!(d instanceof U))
|
|
6723
6723
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6724
|
-
const p =
|
|
6725
|
-
this.confirmedDialog = new
|
|
6724
|
+
const p = fe.initialDialogStateForUserAgentServer(this.message, this.toTag);
|
|
6725
|
+
this.confirmedDialog = new Ie(d, this.core, p);
|
|
6726
6726
|
}
|
|
6727
|
-
const t = this.message.getHeaders("record-route").map((d) => `Record-Route: ${d}`), i = `Contact: ${this.core.configuration.contact.toString()}`, s = "Allow: " +
|
|
6727
|
+
const t = this.message.getHeaders("record-route").map((d) => `Record-Route: ${d}`), i = `Contact: ${this.core.configuration.contact.toString()}`, s = "Allow: " + se.toString();
|
|
6728
6728
|
if (!e.body) {
|
|
6729
|
-
if (this.confirmedDialog.signalingState ===
|
|
6729
|
+
if (this.confirmedDialog.signalingState === b.Stable)
|
|
6730
6730
|
e.body = this.confirmedDialog.answer;
|
|
6731
|
-
else if (this.confirmedDialog.signalingState ===
|
|
6731
|
+
else if (this.confirmedDialog.signalingState === b.Initial || this.confirmedDialog.signalingState === b.HaveRemoteOffer)
|
|
6732
6732
|
throw new Error("Response must have a body.");
|
|
6733
6733
|
}
|
|
6734
6734
|
e.statusCode = e.statusCode || 200, e.extraHeaders = e.extraHeaders || [], e.extraHeaders = e.extraHeaders.concat(t), e.extraHeaders.push(s), e.extraHeaders.push(i);
|
|
6735
6735
|
const r = super.accept(e), n = this.confirmedDialog, o = Object.assign(Object.assign({}, r), { session: n });
|
|
6736
|
-
return e.body && this.confirmedDialog.signalingState !==
|
|
6736
|
+
return e.body && this.confirmedDialog.signalingState !== b.Stable && this.confirmedDialog.signalingStateTransition(e.body), o;
|
|
6737
6737
|
}
|
|
6738
6738
|
/**
|
|
6739
6739
|
* 13.3.1.1 Progress
|
|
@@ -6759,18 +6759,18 @@ class qe extends J {
|
|
|
6759
6759
|
*/
|
|
6760
6760
|
progress(e = { statusCode: 180 }) {
|
|
6761
6761
|
if (!this.progressable)
|
|
6762
|
-
throw new
|
|
6762
|
+
throw new ie(`${this.message.method} not progressable in state ${this.transaction.state}.`);
|
|
6763
6763
|
if (!this.earlyDialog) {
|
|
6764
6764
|
const o = this.transaction;
|
|
6765
6765
|
if (!(o instanceof U))
|
|
6766
6766
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6767
|
-
const d =
|
|
6768
|
-
this.earlyDialog = new
|
|
6767
|
+
const d = fe.initialDialogStateForUserAgentServer(this.message, this.toTag, !0);
|
|
6768
|
+
this.earlyDialog = new Ie(o, this.core, d);
|
|
6769
6769
|
}
|
|
6770
6770
|
const t = this.message.getHeaders("record-route").map((o) => `Record-Route: ${o}`), i = `Contact: ${this.core.configuration.contact}`;
|
|
6771
6771
|
e.extraHeaders = e.extraHeaders || [], e.extraHeaders = e.extraHeaders.concat(t), e.extraHeaders.push(i);
|
|
6772
6772
|
const s = super.progress(e), r = this.earlyDialog, n = Object.assign(Object.assign({}, s), { session: r });
|
|
6773
|
-
return e.body && this.earlyDialog.signalingState !==
|
|
6773
|
+
return e.body && this.earlyDialog.signalingState !== b.Stable && this.earlyDialog.signalingStateTransition(e.body), n;
|
|
6774
6774
|
}
|
|
6775
6775
|
/**
|
|
6776
6776
|
* 13.3.1.2 The INVITE is Redirected
|
|
@@ -6799,22 +6799,22 @@ class qe extends J {
|
|
|
6799
6799
|
return super.reject(e);
|
|
6800
6800
|
}
|
|
6801
6801
|
}
|
|
6802
|
-
class
|
|
6802
|
+
class Jt extends q {
|
|
6803
6803
|
constructor(e, t, i) {
|
|
6804
6804
|
super(L, e, t, i);
|
|
6805
6805
|
}
|
|
6806
6806
|
}
|
|
6807
|
-
class
|
|
6807
|
+
class Zt extends q {
|
|
6808
6808
|
constructor(e, t, i) {
|
|
6809
6809
|
super(L, e, t, i);
|
|
6810
6810
|
}
|
|
6811
6811
|
}
|
|
6812
|
-
class
|
|
6812
|
+
class Xt extends J {
|
|
6813
6813
|
constructor(e, t, i) {
|
|
6814
6814
|
super(N, e, t, i), this.core = e;
|
|
6815
6815
|
}
|
|
6816
6816
|
}
|
|
6817
|
-
class
|
|
6817
|
+
class Qt extends q {
|
|
6818
6818
|
constructor(e, t, i) {
|
|
6819
6819
|
const s = e.createOutgoingRequestMessage(v.SUBSCRIBE, i);
|
|
6820
6820
|
super(L, e.userAgentCore, s, t), this.dialog = e;
|
|
@@ -6838,7 +6838,7 @@ class Zt extends q {
|
|
|
6838
6838
|
e.statusCode && e.statusCode >= 400 && e.statusCode < 700 && [404, 405, 410, 416, 480, 481, 482, 483, 484, 485, 489, 501, 604].includes(e.statusCode) && this.dialog.terminate(), super.receiveResponse(e);
|
|
6839
6839
|
}
|
|
6840
6840
|
}
|
|
6841
|
-
class
|
|
6841
|
+
class Xe extends fe {
|
|
6842
6842
|
constructor(e, t, i, s, r, n) {
|
|
6843
6843
|
super(s, r), this.delegate = n, this._autoRefresh = !1, this._subscriptionEvent = e, this._subscriptionExpires = t, this._subscriptionExpiresInitial = t, this._subscriptionExpiresLastSet = Math.floor(Date.now() / 1e3), this._subscriptionRefresh = void 0, this._subscriptionRefreshLastSet = void 0, this._subscriptionState = i, this.logger = s.loggerFactory.getLogger("sip.subscribe-dialog"), this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`);
|
|
6844
6844
|
}
|
|
@@ -6854,7 +6854,7 @@ class Ze extends ge {
|
|
|
6854
6854
|
const s = t.getHeaders("record-route"), r = t.parseHeader("contact");
|
|
6855
6855
|
if (!r)
|
|
6856
6856
|
throw new Error("Contact undefined.");
|
|
6857
|
-
if (!(r instanceof
|
|
6857
|
+
if (!(r instanceof F))
|
|
6858
6858
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
6859
6859
|
const n = r.uri, o = e.cseq, d = void 0, p = e.callId, u = e.fromTag, w = t.fromTag;
|
|
6860
6860
|
if (!p)
|
|
@@ -6937,7 +6937,7 @@ class Ze extends ge {
|
|
|
6937
6937
|
* https://tools.ietf.org/html/rfc6665#section-4.1.2.2
|
|
6938
6938
|
*/
|
|
6939
6939
|
refresh() {
|
|
6940
|
-
const e = "Allow: " +
|
|
6940
|
+
const e = "Allow: " + se.toString(), t = {};
|
|
6941
6941
|
return t.extraHeaders = (t.extraHeaders || []).slice(), t.extraHeaders.push(e), t.extraHeaders.push("Event: " + this.subscriptionEvent), t.extraHeaders.push("Expires: " + this.subscriptionExpiresInitial), t.extraHeaders.push("Contact: " + this.core.configuration.contact.toString()), this.subscribe(void 0, t);
|
|
6942
6942
|
}
|
|
6943
6943
|
/**
|
|
@@ -6951,7 +6951,7 @@ class Ze extends ge {
|
|
|
6951
6951
|
if (this.subscriptionState !== R.Pending && this.subscriptionState !== R.Active)
|
|
6952
6952
|
throw new Error(`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`);
|
|
6953
6953
|
this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);
|
|
6954
|
-
const s = new
|
|
6954
|
+
const s = new Qt(this, e, t);
|
|
6955
6955
|
return this.N && (clearTimeout(this.N), this.N = void 0), !((i = t.extraHeaders) === null || i === void 0) && i.includes("Expires: 0") || (this.N = setTimeout(() => this.timerN(), M.TIMER_N)), s;
|
|
6956
6956
|
}
|
|
6957
6957
|
/**
|
|
@@ -6969,7 +6969,7 @@ class Ze extends ge {
|
|
|
6969
6969
|
* https://tools.ietf.org/html/rfc6665#section-4.1.2.3
|
|
6970
6970
|
*/
|
|
6971
6971
|
unsubscribe() {
|
|
6972
|
-
const e = "Allow: " +
|
|
6972
|
+
const e = "Allow: " + se.toString(), t = {};
|
|
6973
6973
|
return t.extraHeaders = (t.extraHeaders || []).slice(), t.extraHeaders.push(e), t.extraHeaders.push("Event: " + this.subscriptionEvent), t.extraHeaders.push("Expires: 0"), t.extraHeaders.push("Contact: " + this.core.configuration.contact.toString()), this.subscribe(void 0, t);
|
|
6974
6974
|
}
|
|
6975
6975
|
/**
|
|
@@ -7004,7 +7004,7 @@ class Ze extends ge {
|
|
|
7004
7004
|
this.logger.warn("Unrecognized subscription state.");
|
|
7005
7005
|
break;
|
|
7006
7006
|
}
|
|
7007
|
-
const n = new
|
|
7007
|
+
const n = new Re(this, e);
|
|
7008
7008
|
this.delegate && this.delegate.onNotify ? this.delegate.onNotify(n) : n.accept();
|
|
7009
7009
|
}
|
|
7010
7010
|
onRefresh(e) {
|
|
@@ -7074,7 +7074,7 @@ class Ze extends ge {
|
|
|
7074
7074
|
this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."), this.subscriptionState !== R.Terminated && (this.stateTransition(R.Terminated), this.onTerminated());
|
|
7075
7075
|
}
|
|
7076
7076
|
}
|
|
7077
|
-
class
|
|
7077
|
+
class ei extends q {
|
|
7078
7078
|
constructor(e, t, i) {
|
|
7079
7079
|
const s = t.getHeader("Event");
|
|
7080
7080
|
if (!s)
|
|
@@ -7144,8 +7144,8 @@ class Xt extends q {
|
|
|
7144
7144
|
throw new Error(`Unrecognized state ${s}.`);
|
|
7145
7145
|
}
|
|
7146
7146
|
if (this.subscriptionState !== R.Terminated) {
|
|
7147
|
-
const r =
|
|
7148
|
-
this.dialog = new
|
|
7147
|
+
const r = Xe.initialDialogStateForSubscription(this.message, e.message);
|
|
7148
|
+
this.dialog = new Xe(this.subscriptionEvent, this.subscriptionExpires, this.subscriptionState, this.core, r);
|
|
7149
7149
|
}
|
|
7150
7150
|
if (this.delegate && this.delegate.onNotify) {
|
|
7151
7151
|
const r = e, n = this.dialog;
|
|
@@ -7191,13 +7191,13 @@ class Xt extends q {
|
|
|
7191
7191
|
this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."), this.waitNotifyStop(), this.delegate && this.delegate.onNotifyTimeout && this.delegate.onNotifyTimeout();
|
|
7192
7192
|
}
|
|
7193
7193
|
}
|
|
7194
|
-
class
|
|
7194
|
+
class ti extends J {
|
|
7195
7195
|
constructor(e, t, i) {
|
|
7196
7196
|
super(N, e, t, i), this.core = e;
|
|
7197
7197
|
}
|
|
7198
7198
|
}
|
|
7199
|
-
const
|
|
7200
|
-
class
|
|
7199
|
+
const Qe = ["application/sdp", "application/dtmf-relay"];
|
|
7200
|
+
class ii {
|
|
7201
7201
|
/**
|
|
7202
7202
|
* Constructor.
|
|
7203
7203
|
* @param configuration - Configuration.
|
|
@@ -7231,7 +7231,7 @@ class ei {
|
|
|
7231
7231
|
* @param delegate - Request delegate.
|
|
7232
7232
|
*/
|
|
7233
7233
|
invite(e, t) {
|
|
7234
|
-
return new
|
|
7234
|
+
return new Yt(this, e, t);
|
|
7235
7235
|
}
|
|
7236
7236
|
/**
|
|
7237
7237
|
* Send MESSAGE.
|
|
@@ -7239,7 +7239,7 @@ class ei {
|
|
|
7239
7239
|
* @param delegate - Request delegate.
|
|
7240
7240
|
*/
|
|
7241
7241
|
message(e, t) {
|
|
7242
|
-
return new
|
|
7242
|
+
return new ut(this, e, t);
|
|
7243
7243
|
}
|
|
7244
7244
|
/**
|
|
7245
7245
|
* Send PUBLISH.
|
|
@@ -7247,7 +7247,7 @@ class ei {
|
|
|
7247
7247
|
* @param delegate - Request delegate.
|
|
7248
7248
|
*/
|
|
7249
7249
|
publish(e, t) {
|
|
7250
|
-
return new
|
|
7250
|
+
return new Jt(this, e, t);
|
|
7251
7251
|
}
|
|
7252
7252
|
/**
|
|
7253
7253
|
* Send REGISTER.
|
|
@@ -7255,7 +7255,7 @@ class ei {
|
|
|
7255
7255
|
* @param delegate - Request delegate.
|
|
7256
7256
|
*/
|
|
7257
7257
|
register(e, t) {
|
|
7258
|
-
return new
|
|
7258
|
+
return new Zt(this, e, t);
|
|
7259
7259
|
}
|
|
7260
7260
|
/**
|
|
7261
7261
|
* Send SUBSCRIBE.
|
|
@@ -7263,7 +7263,7 @@ class ei {
|
|
|
7263
7263
|
* @param delegate - Request delegate.
|
|
7264
7264
|
*/
|
|
7265
7265
|
subscribe(e, t) {
|
|
7266
|
-
return new
|
|
7266
|
+
return new ei(this, e, t);
|
|
7267
7267
|
}
|
|
7268
7268
|
/**
|
|
7269
7269
|
* Send a request.
|
|
@@ -7296,7 +7296,7 @@ class ei {
|
|
|
7296
7296
|
userAgentString: A,
|
|
7297
7297
|
viaHost: C
|
|
7298
7298
|
}), r);
|
|
7299
|
-
return new
|
|
7299
|
+
return new de(e, t, i, s, f, n, o);
|
|
7300
7300
|
}
|
|
7301
7301
|
/**
|
|
7302
7302
|
* Handle an incoming request message from the transport.
|
|
@@ -7331,7 +7331,7 @@ class ei {
|
|
|
7331
7331
|
replyStateless(e, t) {
|
|
7332
7332
|
const i = this.configuration.userAgentHeaderFieldValue, s = this.configuration.supportedOptionTagsResponse;
|
|
7333
7333
|
t = Object.assign(Object.assign({}, t), { userAgent: i, supported: s });
|
|
7334
|
-
const r =
|
|
7334
|
+
const r = dt(e, t);
|
|
7335
7335
|
return this.transport.send(r.message).catch((n) => {
|
|
7336
7336
|
n instanceof Error && this.logger.error(n.message), this.logger.error(`Transport error occurred sending stateless reply to ${e.method} request.`);
|
|
7337
7337
|
}), r;
|
|
@@ -7350,12 +7350,12 @@ class ei {
|
|
|
7350
7350
|
*/
|
|
7351
7351
|
receiveRequestFromTransport(e) {
|
|
7352
7352
|
const t = e.viaBranch, i = this.userAgentServers.get(t);
|
|
7353
|
-
if (e.method === v.ACK && i && i.transaction.state === g.Accepted && i instanceof
|
|
7353
|
+
if (e.method === v.ACK && i && i.transaction.state === g.Accepted && i instanceof Oe) {
|
|
7354
7354
|
this.logger.warn(`Discarding out of dialog ACK after 2xx response sent on transaction ${t}.`);
|
|
7355
7355
|
return;
|
|
7356
7356
|
}
|
|
7357
7357
|
if (e.method === v.CANCEL) {
|
|
7358
|
-
i ? (this.replyStateless(e, { statusCode: 200 }), i.transaction instanceof U && i.transaction.state === g.Proceeding && i instanceof
|
|
7358
|
+
i ? (this.replyStateless(e, { statusCode: 200 }), i.transaction instanceof U && i.transaction.state === g.Proceeding && i instanceof Oe && i.receiveCancel(e)) : this.replyStateless(e, { statusCode: 481 });
|
|
7359
7359
|
return;
|
|
7360
7360
|
}
|
|
7361
7361
|
if (i) {
|
|
@@ -7374,8 +7374,8 @@ class ei {
|
|
|
7374
7374
|
* @param message - Incoming request message.
|
|
7375
7375
|
*/
|
|
7376
7376
|
receiveRequest(e) {
|
|
7377
|
-
if (!
|
|
7378
|
-
const s = "Allow: " +
|
|
7377
|
+
if (!se.includes(e.method)) {
|
|
7378
|
+
const s = "Allow: " + se.toString();
|
|
7379
7379
|
this.replyStateless(e, {
|
|
7380
7380
|
statusCode: 405,
|
|
7381
7381
|
extraHeaders: [s]
|
|
@@ -7428,7 +7428,7 @@ class ei {
|
|
|
7428
7428
|
}
|
|
7429
7429
|
const r = e.callId + e.toTag + s.event, n = this.subscribers.get(r);
|
|
7430
7430
|
if (n) {
|
|
7431
|
-
const o = new
|
|
7431
|
+
const o = new Re(this, e);
|
|
7432
7432
|
n.onNotify(o);
|
|
7433
7433
|
return;
|
|
7434
7434
|
}
|
|
@@ -7436,7 +7436,7 @@ class ei {
|
|
|
7436
7436
|
const t = e.callId + e.toTag + e.fromTag, i = this.dialogs.get(t);
|
|
7437
7437
|
if (i) {
|
|
7438
7438
|
if (e.method === v.OPTIONS) {
|
|
7439
|
-
const s = "Allow: " +
|
|
7439
|
+
const s = "Allow: " + se.toString(), r = "Accept: " + Qe.toString();
|
|
7440
7440
|
this.replyStateless(e, {
|
|
7441
7441
|
statusCode: 200,
|
|
7442
7442
|
extraHeaders: [s, r]
|
|
@@ -7468,25 +7468,25 @@ class ei {
|
|
|
7468
7468
|
break;
|
|
7469
7469
|
case v.INVITE:
|
|
7470
7470
|
{
|
|
7471
|
-
const t = new
|
|
7471
|
+
const t = new Oe(this, e);
|
|
7472
7472
|
this.delegate.onInvite ? this.delegate.onInvite(t) : t.reject();
|
|
7473
7473
|
}
|
|
7474
7474
|
break;
|
|
7475
7475
|
case v.MESSAGE:
|
|
7476
7476
|
{
|
|
7477
|
-
const t = new
|
|
7477
|
+
const t = new gt(this, e);
|
|
7478
7478
|
this.delegate.onMessage ? this.delegate.onMessage(t) : t.accept();
|
|
7479
7479
|
}
|
|
7480
7480
|
break;
|
|
7481
7481
|
case v.NOTIFY:
|
|
7482
7482
|
{
|
|
7483
|
-
const t = new
|
|
7483
|
+
const t = new Re(this, e);
|
|
7484
7484
|
this.delegate.onNotify ? this.delegate.onNotify(t) : t.reject({ statusCode: 405 });
|
|
7485
7485
|
}
|
|
7486
7486
|
break;
|
|
7487
7487
|
case v.OPTIONS:
|
|
7488
7488
|
{
|
|
7489
|
-
const t = "Allow: " +
|
|
7489
|
+
const t = "Allow: " + se.toString(), i = "Accept: " + Qe.toString();
|
|
7490
7490
|
this.replyStateless(e, {
|
|
7491
7491
|
statusCode: 200,
|
|
7492
7492
|
extraHeaders: [t, i]
|
|
@@ -7495,19 +7495,19 @@ class ei {
|
|
|
7495
7495
|
break;
|
|
7496
7496
|
case v.REFER:
|
|
7497
7497
|
{
|
|
7498
|
-
const t = new
|
|
7498
|
+
const t = new ft(this, e);
|
|
7499
7499
|
this.delegate.onRefer ? this.delegate.onRefer(t) : t.reject({ statusCode: 405 });
|
|
7500
7500
|
}
|
|
7501
7501
|
break;
|
|
7502
7502
|
case v.REGISTER:
|
|
7503
7503
|
{
|
|
7504
|
-
const t = new
|
|
7504
|
+
const t = new Xt(this, e);
|
|
7505
7505
|
this.delegate.onRegister ? this.delegate.onRegister(t) : t.reject({ statusCode: 405 });
|
|
7506
7506
|
}
|
|
7507
7507
|
break;
|
|
7508
7508
|
case v.SUBSCRIBE:
|
|
7509
7509
|
{
|
|
7510
|
-
const t = new
|
|
7510
|
+
const t = new ti(this, e);
|
|
7511
7511
|
this.delegate.onSubscribe ? this.delegate.onSubscribe(t) : t.reject({ statusCode: 480 });
|
|
7512
7512
|
}
|
|
7513
7513
|
break;
|
|
@@ -7533,10 +7533,10 @@ class ei {
|
|
|
7533
7533
|
i ? i.transaction.receiveResponse(e) : this.logger.warn(`Discarding unmatched ${e.statusCode} response to ${e.method} ${t}.`);
|
|
7534
7534
|
}
|
|
7535
7535
|
}
|
|
7536
|
-
function
|
|
7536
|
+
function si() {
|
|
7537
7537
|
return (a) => !a.audio && !a.video ? Promise.resolve(new MediaStream()) : navigator.mediaDevices === void 0 ? Promise.reject(new Error("Media devices not available in insecure contexts.")) : navigator.mediaDevices.getUserMedia.call(navigator.mediaDevices, a);
|
|
7538
7538
|
}
|
|
7539
|
-
function
|
|
7539
|
+
function ri() {
|
|
7540
7540
|
return {
|
|
7541
7541
|
bundlePolicy: "balanced",
|
|
7542
7542
|
certificates: void 0,
|
|
@@ -7546,7 +7546,7 @@ function ii() {
|
|
|
7546
7546
|
rtcpMuxPolicy: "require"
|
|
7547
7547
|
};
|
|
7548
7548
|
}
|
|
7549
|
-
class
|
|
7549
|
+
class O {
|
|
7550
7550
|
/**
|
|
7551
7551
|
* Constructor
|
|
7552
7552
|
* @param logger - A logger
|
|
@@ -7867,7 +7867,7 @@ class F {
|
|
|
7867
7867
|
this.logger.debug(`SessionDescriptionHandler.setLocalMediaStream - replacing sender ${p} track`), w();
|
|
7868
7868
|
}).then(() => u.replaceTrack(d).then(() => {
|
|
7869
7869
|
const w = i.getTracks().find((S) => S.kind === p);
|
|
7870
|
-
w && (w.stop(), i.removeTrack(w),
|
|
7870
|
+
w && (w.stop(), i.removeTrack(w), O.dispatchRemoveTrackEvent(i, w)), i.addTrack(d), O.dispatchAddTrackEvent(i, d);
|
|
7871
7871
|
}).catch((w) => {
|
|
7872
7872
|
throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to replace sender ${p} track`), w;
|
|
7873
7873
|
}))) : s.push(new Promise((w) => {
|
|
@@ -7878,7 +7878,7 @@ class F {
|
|
|
7878
7878
|
} catch (w) {
|
|
7879
7879
|
throw this.logger.error(`SessionDescriptionHandler.setLocalMediaStream - failed to add sender ${p} track`), w;
|
|
7880
7880
|
}
|
|
7881
|
-
i.addTrack(d),
|
|
7881
|
+
i.addTrack(d), O.dispatchAddTrackEvent(i, d);
|
|
7882
7882
|
}));
|
|
7883
7883
|
}, n = e.getAudioTracks();
|
|
7884
7884
|
n.length && r(n[0]);
|
|
@@ -7934,10 +7934,10 @@ class F {
|
|
|
7934
7934
|
this.logger.debug("SessionDescriptionHandler.setRemoteTrack");
|
|
7935
7935
|
const t = this._remoteMediaStream;
|
|
7936
7936
|
t.getTrackById(e.id) ? this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - have remote ${e.kind} track`) : e.kind === "audio" ? (this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`), t.getAudioTracks().forEach((i) => {
|
|
7937
|
-
i.stop(), t.removeTrack(i),
|
|
7938
|
-
}), t.addTrack(e),
|
|
7939
|
-
i.stop(), t.removeTrack(i),
|
|
7940
|
-
}), t.addTrack(e),
|
|
7937
|
+
i.stop(), t.removeTrack(i), O.dispatchRemoveTrackEvent(t, i);
|
|
7938
|
+
}), t.addTrack(e), O.dispatchAddTrackEvent(t, e)) : e.kind === "video" && (this.logger.debug(`SessionDescriptionHandler.setRemoteTrack - adding remote ${e.kind} track`), t.getVideoTracks().forEach((i) => {
|
|
7939
|
+
i.stop(), t.removeTrack(i), O.dispatchRemoveTrackEvent(t, i);
|
|
7940
|
+
}), t.addTrack(e), O.dispatchAddTrackEvent(t, e));
|
|
7941
7941
|
}
|
|
7942
7942
|
/**
|
|
7943
7943
|
* Depending on the current signaling state and the session hold state, update transceiver direction.
|
|
@@ -8078,23 +8078,23 @@ class F {
|
|
|
8078
8078
|
};
|
|
8079
8079
|
}
|
|
8080
8080
|
}
|
|
8081
|
-
function
|
|
8081
|
+
function ni(a) {
|
|
8082
8082
|
return (e, t) => {
|
|
8083
|
-
a === void 0 && (a =
|
|
8083
|
+
a === void 0 && (a = si());
|
|
8084
8084
|
const s = {
|
|
8085
8085
|
iceGatheringTimeout: t?.iceGatheringTimeout !== void 0 ? t?.iceGatheringTimeout : 5e3,
|
|
8086
|
-
peerConnectionConfiguration: Object.assign(Object.assign({},
|
|
8086
|
+
peerConnectionConfiguration: Object.assign(Object.assign({}, ri()), t?.peerConnectionConfiguration)
|
|
8087
8087
|
}, r = e.userAgent.getLogger("sip.SessionDescriptionHandler");
|
|
8088
|
-
return new
|
|
8088
|
+
return new O(r, a, s);
|
|
8089
8089
|
};
|
|
8090
8090
|
}
|
|
8091
|
-
class
|
|
8091
|
+
class Se {
|
|
8092
8092
|
constructor(e, t) {
|
|
8093
8093
|
if (this._state = T.Disconnected, this.transitioningState = !1, this._stateEventEmitter = new be(), this.logger = e, t) {
|
|
8094
8094
|
const r = t, n = r?.wsServers, o = r?.maxReconnectionAttempts;
|
|
8095
8095
|
n !== void 0 && this.logger.warn('The transport option "wsServers" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'), o !== void 0 && this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'), n && !t.server && (typeof n == "string" && (t.server = n), n instanceof Array && (t.server = n[0]));
|
|
8096
8096
|
}
|
|
8097
|
-
this.configuration = Object.assign(Object.assign({},
|
|
8097
|
+
this.configuration = Object.assign(Object.assign({}, Se.defaultOptions), t);
|
|
8098
8098
|
const i = this.configuration.server, s = k.parse(i, "absoluteURI");
|
|
8099
8099
|
if (s === -1)
|
|
8100
8100
|
throw this.logger.error(`Invalid WebSocket Server URL "${i}"`), new Error("Invalid WebSocket Server URL");
|
|
@@ -8191,7 +8191,7 @@ class ve {
|
|
|
8191
8191
|
try {
|
|
8192
8192
|
this.transitionState(T.Connecting);
|
|
8193
8193
|
} catch (t) {
|
|
8194
|
-
if (t instanceof
|
|
8194
|
+
if (t instanceof pe)
|
|
8195
8195
|
return Promise.reject(t);
|
|
8196
8196
|
throw t;
|
|
8197
8197
|
}
|
|
@@ -8202,7 +8202,7 @@ class ve {
|
|
|
8202
8202
|
try {
|
|
8203
8203
|
this.transitionState(T.Connecting);
|
|
8204
8204
|
} catch (t) {
|
|
8205
|
-
if (t instanceof
|
|
8205
|
+
if (t instanceof pe)
|
|
8206
8206
|
return Promise.reject(t);
|
|
8207
8207
|
throw t;
|
|
8208
8208
|
}
|
|
@@ -8232,7 +8232,7 @@ class ve {
|
|
|
8232
8232
|
try {
|
|
8233
8233
|
this.transitionState(T.Disconnecting);
|
|
8234
8234
|
} catch (t) {
|
|
8235
|
-
if (t instanceof
|
|
8235
|
+
if (t instanceof pe)
|
|
8236
8236
|
return Promise.reject(t);
|
|
8237
8237
|
throw t;
|
|
8238
8238
|
}
|
|
@@ -8243,7 +8243,7 @@ class ve {
|
|
|
8243
8243
|
try {
|
|
8244
8244
|
this.transitionState(T.Disconnecting);
|
|
8245
8245
|
} catch (t) {
|
|
8246
|
-
if (t instanceof
|
|
8246
|
+
if (t instanceof pe)
|
|
8247
8247
|
return Promise.reject(t);
|
|
8248
8248
|
throw t;
|
|
8249
8249
|
}
|
|
@@ -8366,7 +8366,7 @@ class ve {
|
|
|
8366
8366
|
*/
|
|
8367
8367
|
transitionLoopDetectedError(e) {
|
|
8368
8368
|
let t = "A state transition loop has been detected.";
|
|
8369
|
-
return t += ` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`, t += " Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?", this.logger.error(t), new
|
|
8369
|
+
return t += ` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`, t += " Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?", this.logger.error(t), new pe("Loop detected.");
|
|
8370
8370
|
}
|
|
8371
8371
|
/**
|
|
8372
8372
|
* Transition transport state.
|
|
@@ -8483,7 +8483,7 @@ class ve {
|
|
|
8483
8483
|
this.keepAliveInterval && clearInterval(this.keepAliveInterval), this.keepAliveDebounceTimeout && clearTimeout(this.keepAliveDebounceTimeout), this.keepAliveInterval = void 0, this.keepAliveDebounceTimeout = void 0;
|
|
8484
8484
|
}
|
|
8485
8485
|
}
|
|
8486
|
-
|
|
8486
|
+
Se.defaultOptions = {
|
|
8487
8487
|
server: "",
|
|
8488
8488
|
connectionTimeout: 5,
|
|
8489
8489
|
keepAliveInterval: 0,
|
|
@@ -8496,12 +8496,12 @@ class V {
|
|
|
8496
8496
|
* @param options - Options bucket. See {@link UserAgentOptions} for details.
|
|
8497
8497
|
*/
|
|
8498
8498
|
constructor(e = {}) {
|
|
8499
|
-
if (this._publishers = {}, this._registerers = {}, this._sessions = {}, this._subscriptions = {}, this._state = D.Stopped, this._stateEventEmitter = new be(), this.delegate = e.delegate, this.options = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, V.defaultOptions()), { sipjsId:
|
|
8499
|
+
if (this._publishers = {}, this._registerers = {}, this._sessions = {}, this._subscriptions = {}, this._state = D.Stopped, this._stateEventEmitter = new be(), this.delegate = e.delegate, this.options = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, V.defaultOptions()), { sipjsId: oe(5) }), { uri: new Y("sip", "anonymous." + oe(6), "anonymous.invalid") }), { viaHost: oe(12) + ".invalid" }), V.stripUndefinedProperties(e)), this.options.hackIpInContact)
|
|
8500
8500
|
if (typeof this.options.hackIpInContact == "boolean" && this.options.hackIpInContact) {
|
|
8501
8501
|
const s = Math.floor(Math.random() * 254 + 1);
|
|
8502
8502
|
this.options.viaHost = "192.0.2." + s;
|
|
8503
8503
|
} else this.options.hackIpInContact && (this.options.viaHost = this.options.hackIpInContact);
|
|
8504
|
-
switch (this.loggerFactory = new
|
|
8504
|
+
switch (this.loggerFactory = new qt(), this.logger = this.loggerFactory.getLogger("sip.UserAgent"), this.loggerFactory.builtinEnabled = this.options.logBuiltinEnabled, this.loggerFactory.connector = this.options.logConnector, this.options.logLevel) {
|
|
8505
8505
|
case "error":
|
|
8506
8506
|
this.loggerFactory.level = H.error;
|
|
8507
8507
|
break;
|
|
@@ -8585,16 +8585,16 @@ class V {
|
|
|
8585
8585
|
reconnectionAttempts: 0,
|
|
8586
8586
|
reconnectionDelay: 4,
|
|
8587
8587
|
sendInitialProvisionalResponse: !0,
|
|
8588
|
-
sessionDescriptionHandlerFactory:
|
|
8588
|
+
sessionDescriptionHandlerFactory: ni(),
|
|
8589
8589
|
sessionDescriptionHandlerFactoryOptions: {},
|
|
8590
8590
|
sipExtension100rel: G.Unsupported,
|
|
8591
8591
|
sipExtensionReplaces: G.Unsupported,
|
|
8592
8592
|
sipExtensionExtraSupported: [],
|
|
8593
8593
|
sipjsId: "",
|
|
8594
|
-
transportConstructor:
|
|
8594
|
+
transportConstructor: Se,
|
|
8595
8595
|
transportOptions: {},
|
|
8596
8596
|
uri: new Y("sip", "anonymous", "anonymous.invalid"),
|
|
8597
|
-
userAgentString: "SIP.js/" +
|
|
8597
|
+
userAgentString: "SIP.js/" + Tt,
|
|
8598
8598
|
viaHost: ""
|
|
8599
8599
|
};
|
|
8600
8600
|
}
|
|
@@ -8769,7 +8769,7 @@ class V {
|
|
|
8769
8769
|
* @internal
|
|
8770
8770
|
*/
|
|
8771
8771
|
_makeInviter(e, t) {
|
|
8772
|
-
return new
|
|
8772
|
+
return new Ee(this, e, t);
|
|
8773
8773
|
}
|
|
8774
8774
|
/**
|
|
8775
8775
|
* Attempt reconnection up to `maxReconnectionAttempts` times.
|
|
@@ -8793,7 +8793,7 @@ class V {
|
|
|
8793
8793
|
* Initialize contact.
|
|
8794
8794
|
*/
|
|
8795
8795
|
initContact() {
|
|
8796
|
-
const e = this.options.contactName !== "" ? this.options.contactName :
|
|
8796
|
+
const e = this.options.contactName !== "" ? this.options.contactName : oe(8), t = this.options.contactParams;
|
|
8797
8797
|
return {
|
|
8798
8798
|
pubGruu: void 0,
|
|
8799
8799
|
tempGruu: void 0,
|
|
@@ -8810,7 +8810,7 @@ class V {
|
|
|
8810
8810
|
*/
|
|
8811
8811
|
initCore() {
|
|
8812
8812
|
let e = [];
|
|
8813
|
-
e.push("outbound"), this.options.sipExtension100rel === G.Supported && e.push("100rel"), this.options.sipExtensionReplaces === G.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) =>
|
|
8813
|
+
e.push("outbound"), this.options.sipExtension100rel === G.Supported && e.push("100rel"), this.options.sipExtensionReplaces === G.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Pt[r])), e = Array.from(new Set(e));
|
|
8814
8814
|
const t = e.slice();
|
|
8815
8815
|
(this.contact.pubGruu || this.contact.tempGruu) && t.push("gruu");
|
|
8816
8816
|
const i = {
|
|
@@ -8828,13 +8828,13 @@ class V {
|
|
|
8828
8828
|
viaHost: this.options.viaHost,
|
|
8829
8829
|
authenticationFactory: () => {
|
|
8830
8830
|
const r = this.options.authorizationUsername ? this.options.authorizationUsername : this.options.uri.user, n = this.options.authorizationPassword ? this.options.authorizationPassword : void 0, o = this.options.authorizationHa1 ? this.options.authorizationHa1 : void 0;
|
|
8831
|
-
return new
|
|
8831
|
+
return new Mt(this.getLoggerFactory(), o, r, n);
|
|
8832
8832
|
},
|
|
8833
8833
|
transportAccessor: () => this.transport
|
|
8834
8834
|
}, s = {
|
|
8835
8835
|
onInvite: (r) => {
|
|
8836
8836
|
var n;
|
|
8837
|
-
const o = new
|
|
8837
|
+
const o = new ce(this, r);
|
|
8838
8838
|
if (r.delegate = {
|
|
8839
8839
|
onCancel: (d) => {
|
|
8840
8840
|
o._onCancel(d);
|
|
@@ -8887,14 +8887,14 @@ class V {
|
|
|
8887
8887
|
},
|
|
8888
8888
|
onMessage: (r) => {
|
|
8889
8889
|
if (this.delegate && this.delegate.onMessage) {
|
|
8890
|
-
const n = new
|
|
8890
|
+
const n = new ct(r);
|
|
8891
8891
|
this.delegate.onMessage(n);
|
|
8892
8892
|
} else
|
|
8893
8893
|
r.accept();
|
|
8894
8894
|
},
|
|
8895
8895
|
onNotify: (r) => {
|
|
8896
8896
|
if (this.delegate && this.delegate.onNotify) {
|
|
8897
|
-
const n = new
|
|
8897
|
+
const n = new Be(r);
|
|
8898
8898
|
this.delegate.onNotify(n);
|
|
8899
8899
|
} else
|
|
8900
8900
|
this.options.allowLegacyNotifications ? r.accept() : r.reject({ statusCode: 481 });
|
|
@@ -8909,7 +8909,7 @@ class V {
|
|
|
8909
8909
|
this.logger.warn("Received an out of dialog SUBSCRIBE request"), this.delegate && this.delegate.onSubscribeRequest ? this.delegate.onSubscribeRequest(r) : r.reject({ statusCode: 405 });
|
|
8910
8910
|
}
|
|
8911
8911
|
};
|
|
8912
|
-
return new
|
|
8912
|
+
return new ii(i, s);
|
|
8913
8913
|
}
|
|
8914
8914
|
initTransportCallbacks() {
|
|
8915
8915
|
this.transport.onConnect = () => this.onTransportConnect(), this.transport.onDisconnect = (e) => this.onTransportDisconnect(e), this.transport.onMessage = (e) => this.onTransportMessage(e);
|
|
@@ -8921,12 +8921,12 @@ class V {
|
|
|
8921
8921
|
this.state !== D.Stopped && (this.delegate && this.delegate.onDisconnect && this.delegate.onDisconnect(e), e && this.options.reconnectionAttempts > 0 && this.attemptReconnection());
|
|
8922
8922
|
}
|
|
8923
8923
|
onTransportMessage(e) {
|
|
8924
|
-
const t =
|
|
8924
|
+
const t = Ce.parseMessage(e, this.getLogger("sip.Parser"));
|
|
8925
8925
|
if (!t) {
|
|
8926
8926
|
this.logger.warn("Failed to parse incoming message. Dropping.");
|
|
8927
8927
|
return;
|
|
8928
8928
|
}
|
|
8929
|
-
if (this.state === D.Stopped && t instanceof
|
|
8929
|
+
if (this.state === D.Stopped && t instanceof ue) {
|
|
8930
8930
|
this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);
|
|
8931
8931
|
return;
|
|
8932
8932
|
}
|
|
@@ -8937,7 +8937,7 @@ class V {
|
|
|
8937
8937
|
return this.logger.warn(`Missing mandatory header field : ${r}.`), !1;
|
|
8938
8938
|
return !0;
|
|
8939
8939
|
};
|
|
8940
|
-
if (t instanceof
|
|
8940
|
+
if (t instanceof ue) {
|
|
8941
8941
|
if (!i()) {
|
|
8942
8942
|
this.logger.warn("Request missing mandatory header field. Dropping.");
|
|
8943
8943
|
return;
|
|
@@ -8946,13 +8946,13 @@ class V {
|
|
|
8946
8946
|
this.userAgentCore.replyStateless(t, { statusCode: 482 });
|
|
8947
8947
|
return;
|
|
8948
8948
|
}
|
|
8949
|
-
const s =
|
|
8949
|
+
const s = ve(t.body), r = t.getHeader("content-length");
|
|
8950
8950
|
if (r && s < Number(r)) {
|
|
8951
8951
|
this.userAgentCore.replyStateless(t, { statusCode: 400 });
|
|
8952
8952
|
return;
|
|
8953
8953
|
}
|
|
8954
8954
|
}
|
|
8955
|
-
if (t instanceof
|
|
8955
|
+
if (t instanceof ne) {
|
|
8956
8956
|
if (!i()) {
|
|
8957
8957
|
this.logger.warn("Response missing mandatory header field. Dropping.");
|
|
8958
8958
|
return;
|
|
@@ -8965,17 +8965,17 @@ class V {
|
|
|
8965
8965
|
this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");
|
|
8966
8966
|
return;
|
|
8967
8967
|
}
|
|
8968
|
-
const s =
|
|
8968
|
+
const s = ve(t.body), r = t.getHeader("content-length");
|
|
8969
8969
|
if (r && s < Number(r)) {
|
|
8970
8970
|
this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.");
|
|
8971
8971
|
return;
|
|
8972
8972
|
}
|
|
8973
8973
|
}
|
|
8974
|
-
if (t instanceof
|
|
8974
|
+
if (t instanceof ue) {
|
|
8975
8975
|
this.userAgentCore.receiveIncomingRequestFromTransport(t);
|
|
8976
8976
|
return;
|
|
8977
8977
|
}
|
|
8978
|
-
if (t instanceof
|
|
8978
|
+
if (t instanceof ne) {
|
|
8979
8979
|
this.userAgentCore.receiveIncomingResponseFromTransport(t);
|
|
8980
8980
|
return;
|
|
8981
8981
|
}
|
|
@@ -9002,10 +9002,10 @@ class V {
|
|
|
9002
9002
|
this.logger.log(`Transitioned from ${this._state} to ${e}`), this._state = e, this._stateEventEmitter.emit(this._state);
|
|
9003
9003
|
}
|
|
9004
9004
|
}
|
|
9005
|
-
function
|
|
9005
|
+
function ai() {
|
|
9006
9006
|
return (a, e) => ({ session: e, held: !1, muted: !1 });
|
|
9007
9007
|
}
|
|
9008
|
-
class
|
|
9008
|
+
class Ve {
|
|
9009
9009
|
/**
|
|
9010
9010
|
* Constructs a new instance of the `SessionManager` class.
|
|
9011
9011
|
* @param server - SIP WebSocket Server URL.
|
|
@@ -9017,7 +9017,7 @@ class je {
|
|
|
9017
9017
|
autoStop: !0,
|
|
9018
9018
|
delegate: {},
|
|
9019
9019
|
iceStopWaitingOnServerReflexive: !1,
|
|
9020
|
-
managedSessionFactory:
|
|
9020
|
+
managedSessionFactory: ai(),
|
|
9021
9021
|
maxSimultaneousSessions: 2,
|
|
9022
9022
|
media: {},
|
|
9023
9023
|
optionsPingInterval: -1,
|
|
@@ -9031,9 +9031,9 @@ class je {
|
|
|
9031
9031
|
registererRegisterOptions: {},
|
|
9032
9032
|
sendDTMFUsingSessionDescriptionHandler: !1,
|
|
9033
9033
|
userAgentOptions: {}
|
|
9034
|
-
},
|
|
9034
|
+
}, Ve.stripUndefinedProperties(t));
|
|
9035
9035
|
const i = Object.assign({}, t.userAgentOptions);
|
|
9036
|
-
if (i.transportConstructor || (i.transportConstructor =
|
|
9036
|
+
if (i.transportConstructor || (i.transportConstructor = Se), i.transportOptions || (i.transportOptions = {
|
|
9037
9037
|
server: e
|
|
9038
9038
|
}), !i.uri && t.aor) {
|
|
9039
9039
|
const s = V.makeURI(t.aor);
|
|
@@ -9120,7 +9120,7 @@ class je {
|
|
|
9120
9120
|
getLocalMediaStream(e) {
|
|
9121
9121
|
const t = e.sessionDescriptionHandler;
|
|
9122
9122
|
if (t) {
|
|
9123
|
-
if (!(t instanceof
|
|
9123
|
+
if (!(t instanceof O))
|
|
9124
9124
|
throw new Error("Session description handler not instance of web SessionDescriptionHandler");
|
|
9125
9125
|
return t.localMediaStream;
|
|
9126
9126
|
}
|
|
@@ -9132,7 +9132,7 @@ class je {
|
|
|
9132
9132
|
getRemoteMediaStream(e) {
|
|
9133
9133
|
const t = e.sessionDescriptionHandler;
|
|
9134
9134
|
if (t) {
|
|
9135
|
-
if (!(t instanceof
|
|
9135
|
+
if (!(t instanceof O))
|
|
9136
9136
|
throw new Error("Session description handler not instance of web SessionDescriptionHandler");
|
|
9137
9137
|
return t.remoteMediaStream;
|
|
9138
9138
|
}
|
|
@@ -9258,7 +9258,7 @@ class je {
|
|
|
9258
9258
|
};
|
|
9259
9259
|
}
|
|
9260
9260
|
this.options.iceStopWaitingOnServerReflexive && (t.delegate = t.delegate || {}, t.delegate.onSessionDescriptionHandler = (o) => {
|
|
9261
|
-
if (!(o instanceof
|
|
9261
|
+
if (!(o instanceof O))
|
|
9262
9262
|
throw new Error("Session description handler not instance of SessionDescriptionHandler");
|
|
9263
9263
|
o.peerConnectionDelegate = {
|
|
9264
9264
|
onicecandidate: (d) => {
|
|
@@ -9267,7 +9267,7 @@ class je {
|
|
|
9267
9267
|
}
|
|
9268
9268
|
};
|
|
9269
9269
|
});
|
|
9270
|
-
const n = new
|
|
9270
|
+
const n = new Ee(this.userAgent, r, t);
|
|
9271
9271
|
return this.sendInvite(n, t, i).then(() => n);
|
|
9272
9272
|
}
|
|
9273
9273
|
/**
|
|
@@ -9291,7 +9291,7 @@ class je {
|
|
|
9291
9291
|
* @param invitationAcceptOptions - Optional options for Inviter.accept().
|
|
9292
9292
|
*/
|
|
9293
9293
|
async answer(e, t) {
|
|
9294
|
-
return this.logger.log(`[${e.id}] Accepting Invitation...`), this.sessionExists(e) ? e instanceof
|
|
9294
|
+
return this.logger.log(`[${e.id}] Accepting Invitation...`), this.sessionExists(e) ? e instanceof ce ? (t || (t = {}), t.sessionDescriptionHandlerOptions || (t.sessionDescriptionHandlerOptions = {}), t.sessionDescriptionHandlerOptions.constraints || (t.sessionDescriptionHandlerOptions.constraints = this.constraints), e.accept(t)) : Promise.reject(new Error("Session not instance of Invitation.")) : Promise.reject(new Error("Session does not exist."));
|
|
9295
9295
|
}
|
|
9296
9296
|
/**
|
|
9297
9297
|
* Decline an incoming call.
|
|
@@ -9302,7 +9302,7 @@ class je {
|
|
|
9302
9302
|
* Use `onCallHangup` delegate method to determine if and when call is ended.
|
|
9303
9303
|
*/
|
|
9304
9304
|
async decline(e) {
|
|
9305
|
-
return this.logger.log(`[${e.id}] Rejecting Invitation...`), this.sessionExists(e) ? e instanceof
|
|
9305
|
+
return this.logger.log(`[${e.id}] Rejecting Invitation...`), this.sessionExists(e) ? e instanceof ce ? e.reject() : Promise.reject(new Error("Session not instance of Invitation.")) : Promise.reject(new Error("Session does not exist."));
|
|
9306
9306
|
}
|
|
9307
9307
|
/**
|
|
9308
9308
|
* Hold call
|
|
@@ -9403,7 +9403,7 @@ Duration=` + 2e3
|
|
|
9403
9403
|
* and execute a blind transfer to the target.
|
|
9404
9404
|
*/
|
|
9405
9405
|
async transfer(e, t, i) {
|
|
9406
|
-
if (this.logger.log(`[${e.id}] Referring session...`), t instanceof
|
|
9406
|
+
if (this.logger.log(`[${e.id}] Referring session...`), t instanceof ge)
|
|
9407
9407
|
return e.refer(t, i).then(() => {
|
|
9408
9408
|
});
|
|
9409
9409
|
const s = V.makeURI(t);
|
|
@@ -9419,7 +9419,7 @@ Duration=` + 2e3
|
|
|
9419
9419
|
async message(e, t) {
|
|
9420
9420
|
this.logger.log("Sending message...");
|
|
9421
9421
|
const i = V.makeURI(e);
|
|
9422
|
-
return i ? new
|
|
9422
|
+
return i ? new Ht(this.userAgent, i, t).message() : Promise.reject(new Error(`Failed to create a valid URI from "${e}"`));
|
|
9423
9423
|
}
|
|
9424
9424
|
/** Media constraints. */
|
|
9425
9425
|
get constraints() {
|
|
@@ -9474,7 +9474,7 @@ Duration=` + 2e3
|
|
|
9474
9474
|
t().then(() => {
|
|
9475
9475
|
this.registrationAttemptTimeout = void 0, s();
|
|
9476
9476
|
}).catch((n) => {
|
|
9477
|
-
this.registrationAttemptTimeout = void 0, n instanceof
|
|
9477
|
+
this.registrationAttemptTimeout = void 0, n instanceof ye ? s() : r(n);
|
|
9478
9478
|
});
|
|
9479
9479
|
}, e ? 0 : i(this.options.registrationRetryInterval));
|
|
9480
9480
|
});
|
|
@@ -9491,7 +9491,7 @@ Duration=` + 2e3
|
|
|
9491
9491
|
if (!this.sessionExists(e))
|
|
9492
9492
|
throw new Error("Session does not exist.");
|
|
9493
9493
|
const i = e.sessionDescriptionHandler;
|
|
9494
|
-
if (!(i instanceof
|
|
9494
|
+
if (!(i instanceof O))
|
|
9495
9495
|
throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");
|
|
9496
9496
|
i.enableReceiverTracks(t);
|
|
9497
9497
|
}
|
|
@@ -9500,7 +9500,7 @@ Duration=` + 2e3
|
|
|
9500
9500
|
if (!this.sessionExists(e))
|
|
9501
9501
|
throw new Error("Session does not exist.");
|
|
9502
9502
|
const i = e.sessionDescriptionHandler;
|
|
9503
|
-
if (!(i instanceof
|
|
9503
|
+
if (!(i instanceof O))
|
|
9504
9504
|
throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");
|
|
9505
9505
|
i.enableSenderTracks(t);
|
|
9506
9506
|
}
|
|
@@ -9657,7 +9657,7 @@ Duration=` + 2e3
|
|
|
9657
9657
|
return Promise.reject(new Error("Session does not exist."));
|
|
9658
9658
|
if (this.isHeld(e) === t)
|
|
9659
9659
|
return Promise.resolve();
|
|
9660
|
-
if (!(e.sessionDescriptionHandler instanceof
|
|
9660
|
+
if (!(e.sessionDescriptionHandler instanceof O))
|
|
9661
9661
|
throw new Error("Session's session description handler not instance of SessionDescriptionHandler.");
|
|
9662
9662
|
const s = {
|
|
9663
9663
|
requestDelegate: {
|
|
@@ -9680,7 +9680,7 @@ Duration=` + 2e3
|
|
|
9680
9680
|
const o = this.sessionManaged(e);
|
|
9681
9681
|
o !== void 0 && (this.enableReceiverTracks(e, !o.held), this.enableSenderTracks(e, !o.held && !o.muted));
|
|
9682
9682
|
}).catch((o) => {
|
|
9683
|
-
throw n.held = !t, o instanceof
|
|
9683
|
+
throw n.held = !t, o instanceof ye && this.logger.error(`[${e.id}] A hold request is already in progress.`), o;
|
|
9684
9684
|
});
|
|
9685
9685
|
}
|
|
9686
9686
|
/**
|
|
@@ -9749,21 +9749,21 @@ Duration=` + 2e3
|
|
|
9749
9749
|
async terminate(e) {
|
|
9750
9750
|
switch (this.logger.log(`[${e.id}] Terminating...`), e.state) {
|
|
9751
9751
|
case m.Initial:
|
|
9752
|
-
if (e instanceof
|
|
9752
|
+
if (e instanceof Ee)
|
|
9753
9753
|
return e.cancel().then(() => {
|
|
9754
9754
|
this.logger.log(`[${e.id}] Inviter never sent INVITE (canceled)`);
|
|
9755
9755
|
});
|
|
9756
|
-
if (e instanceof
|
|
9756
|
+
if (e instanceof ce)
|
|
9757
9757
|
return e.reject().then(() => {
|
|
9758
9758
|
this.logger.log(`[${e.id}] Invitation rejected (sent 480)`);
|
|
9759
9759
|
});
|
|
9760
9760
|
throw new Error("Unknown session type.");
|
|
9761
9761
|
case m.Establishing:
|
|
9762
|
-
if (e instanceof
|
|
9762
|
+
if (e instanceof Ee)
|
|
9763
9763
|
return e.cancel().then(() => {
|
|
9764
9764
|
this.logger.log(`[${e.id}] Inviter canceled (sent CANCEL)`);
|
|
9765
9765
|
});
|
|
9766
|
-
if (e instanceof
|
|
9766
|
+
if (e instanceof ce)
|
|
9767
9767
|
return e.reject().then(() => {
|
|
9768
9768
|
this.logger.log(`[${e.id}] Invitation rejected (sent 480)`);
|
|
9769
9769
|
});
|
|
@@ -9782,7 +9782,7 @@ Duration=` + 2e3
|
|
|
9782
9782
|
return this.logger.log(`[${e.id}] Terminating in state ${e.state}, no action taken`), Promise.resolve();
|
|
9783
9783
|
}
|
|
9784
9784
|
}
|
|
9785
|
-
class
|
|
9785
|
+
class oi {
|
|
9786
9786
|
/**
|
|
9787
9787
|
* Constructs a new instance of the `SimpleUser` class.
|
|
9788
9788
|
* @param server - SIP WebSocket Server URL.
|
|
@@ -9846,7 +9846,7 @@ class ni {
|
|
|
9846
9846
|
sendDTMFUsingSessionDescriptionHandler: this.options.sendDTMFUsingSessionDescriptionHandler,
|
|
9847
9847
|
userAgentOptions: this.options.userAgentOptions
|
|
9848
9848
|
};
|
|
9849
|
-
this.sessionManager = new
|
|
9849
|
+
this.sessionManager = new Ve(e, i), this.logger = this.sessionManager.userAgent.getLogger("sip.SimpleUser");
|
|
9850
9850
|
}
|
|
9851
9851
|
/**
|
|
9852
9852
|
* Instance identifier.
|
|
@@ -10054,7 +10054,10 @@ class ni {
|
|
|
10054
10054
|
const Fe = (a, e, t) => {
|
|
10055
10055
|
const i = String(a?.name || a?.code || "").trim(), s = new Error(e);
|
|
10056
10056
|
return s.name = i || "MediaAccessError", s.code = t, s.cause = a, s;
|
|
10057
|
-
},
|
|
10057
|
+
}, ci = (a) => {
|
|
10058
|
+
const e = new Error(a);
|
|
10059
|
+
return e.name = "SipClientLifecycleCancelledError", e.code = "sip_client_replaced", e;
|
|
10060
|
+
}, je = async (a, e = "call") => {
|
|
10058
10061
|
const t = String(a?.name || a?.code || "").trim(), i = String(a?.message || "").trim(), s = `${t} ${i}`.toLowerCase();
|
|
10059
10062
|
let r = "";
|
|
10060
10063
|
try {
|
|
@@ -10078,17 +10081,17 @@ const Fe = (a, e, t) => {
|
|
|
10078
10081
|
"麦克风当前被系统或其他应用占用,无法建立语音通话。请关闭占用麦克风的程序后重试。",
|
|
10079
10082
|
"media_device_unavailable"
|
|
10080
10083
|
) : a;
|
|
10081
|
-
},
|
|
10084
|
+
}, di = async (a = "call") => {
|
|
10082
10085
|
if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia)
|
|
10083
10086
|
return null;
|
|
10084
10087
|
let e = null;
|
|
10085
10088
|
try {
|
|
10086
10089
|
return e = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 }), e;
|
|
10087
10090
|
} catch (t) {
|
|
10088
|
-
throw await
|
|
10091
|
+
throw await je(t, a);
|
|
10089
10092
|
}
|
|
10090
10093
|
};
|
|
10091
|
-
class
|
|
10094
|
+
class li {
|
|
10092
10095
|
constructor(e, t = {}) {
|
|
10093
10096
|
this.account = { ...e }, this.remoteAudioElementId = t.remoteAudioElementId || "sipRemoteAudio", this.remoteAudioElement = t.remoteAudioElement || null, this.onStateChange = t.onStateChange, this.onError = t.onError, this.onAudioLevel = t.onAudioLevel, this.onAudioFrame = t.onAudioFrame, this.simpleUser = null, this.connected = !1, this.registered = !1, this.active = !1, this.lastFailureMeta = null, this.audioContext = null, this.audioMonitors = {
|
|
10094
10097
|
local: null,
|
|
@@ -10320,7 +10323,7 @@ class oi {
|
|
|
10320
10323
|
registererOptions: {
|
|
10321
10324
|
expires: 1800
|
|
10322
10325
|
}
|
|
10323
|
-
}, w = new
|
|
10326
|
+
}, w = new oi(d, u);
|
|
10324
10327
|
return w.delegate = {
|
|
10325
10328
|
onServerConnect: () => {
|
|
10326
10329
|
this.connected = !0, this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
|
|
@@ -10379,7 +10382,7 @@ class oi {
|
|
|
10379
10382
|
}
|
|
10380
10383
|
_isIncomingSession() {
|
|
10381
10384
|
if (!this.simpleUser || !this.simpleUser.session) return !1;
|
|
10382
|
-
if (typeof
|
|
10385
|
+
if (typeof ce < "u" && this.simpleUser.session instanceof ce)
|
|
10383
10386
|
return !0;
|
|
10384
10387
|
const e = this.simpleUser.session;
|
|
10385
10388
|
return !!(e && e.incomingInviteRequest);
|
|
@@ -10397,12 +10400,17 @@ class oi {
|
|
|
10397
10400
|
direction: this._isIncomingSession() ? "inbound" : "outbound"
|
|
10398
10401
|
};
|
|
10399
10402
|
}
|
|
10403
|
+
_assertSimpleUserIsCurrent(e, t = "当前操作") {
|
|
10404
|
+
if (!(e && this.simpleUser === e && this.account))
|
|
10405
|
+
throw ci(`SIP 客户端已重置,已取消${t}。`);
|
|
10406
|
+
}
|
|
10400
10407
|
async ensureReady() {
|
|
10401
|
-
|
|
10408
|
+
let e = this.simpleUser;
|
|
10409
|
+
if (e || (e = this._createSimpleUser(), this.simpleUser = e), this.connected || (await e.connect(), this._assertSimpleUserIsCurrent(e, "连接流程"), this.connected = !0, this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot())), !this.registered)
|
|
10402
10410
|
try {
|
|
10403
|
-
await
|
|
10404
|
-
} catch (
|
|
10405
|
-
throw this.onError && this.onError(
|
|
10411
|
+
this._assertSimpleUserIsCurrent(e, "注册流程"), await e.register(), this._assertSimpleUserIsCurrent(e, "注册流程"), this.registered = !0, this.onStateChange && this.onStateChange("registered", this.getConnectionSnapshot());
|
|
10412
|
+
} catch (t) {
|
|
10413
|
+
throw this.onError && this.onError(t), t;
|
|
10406
10414
|
}
|
|
10407
10415
|
}
|
|
10408
10416
|
getConnectionSnapshot() {
|
|
@@ -10458,9 +10466,9 @@ class oi {
|
|
|
10458
10466
|
async _preflightAudioAccess(e = "call") {
|
|
10459
10467
|
let t = null;
|
|
10460
10468
|
try {
|
|
10461
|
-
t = await
|
|
10469
|
+
t = await di(e);
|
|
10462
10470
|
} catch (i) {
|
|
10463
|
-
const s = await
|
|
10471
|
+
const s = await je(i, e);
|
|
10464
10472
|
throw this.onError && this.onError(s), this.lastFailureMeta = {
|
|
10465
10473
|
source: "media-preflight",
|
|
10466
10474
|
code: s?.code || null,
|
|
@@ -10519,7 +10527,7 @@ class oi {
|
|
|
10519
10527
|
}
|
|
10520
10528
|
}
|
|
10521
10529
|
async _normalizeMediaAccessError(e, t = "call") {
|
|
10522
|
-
return
|
|
10530
|
+
return je(e, t);
|
|
10523
10531
|
}
|
|
10524
10532
|
_createInviteRequestDelegate(e) {
|
|
10525
10533
|
const t = (s, ...r) => {
|
|
@@ -10910,54 +10918,54 @@ class oi {
|
|
|
10910
10918
|
this.audioContext = null;
|
|
10911
10919
|
}
|
|
10912
10920
|
}
|
|
10913
|
-
const
|
|
10914
|
-
function
|
|
10921
|
+
const hi = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
10922
|
+
function ui(a, e = "") {
|
|
10915
10923
|
const t = String(a || e || "").trim();
|
|
10916
10924
|
if (!t)
|
|
10917
10925
|
throw new Error("缺少统一服务基址");
|
|
10918
10926
|
return t;
|
|
10919
10927
|
}
|
|
10920
|
-
function
|
|
10921
|
-
return
|
|
10928
|
+
function pt(a, e = "https://") {
|
|
10929
|
+
return hi.test(a) ? a : `${e}${a.replace(/^\/+/, "")}`;
|
|
10922
10930
|
}
|
|
10923
|
-
function
|
|
10931
|
+
function mt(a = "/") {
|
|
10924
10932
|
return a.endsWith("/") ? a : `${a}/`;
|
|
10925
10933
|
}
|
|
10926
|
-
function
|
|
10927
|
-
const t =
|
|
10934
|
+
function wt(a = "/", e = "") {
|
|
10935
|
+
const t = mt(a || "/"), i = String(e || "").replace(/^\/+/, "");
|
|
10928
10936
|
return i ? `${t}${i}` : t;
|
|
10929
10937
|
}
|
|
10930
|
-
function
|
|
10931
|
-
const t =
|
|
10932
|
-
return i.search = "", i.hash = "", i.pathname =
|
|
10938
|
+
function De(a, e = "") {
|
|
10939
|
+
const t = pt(ui(a, e)), i = new URL(t);
|
|
10940
|
+
return i.search = "", i.hash = "", i.pathname = mt(i.pathname || "/"), i;
|
|
10933
10941
|
}
|
|
10934
|
-
function
|
|
10935
|
-
return
|
|
10942
|
+
function gi(a, e = "") {
|
|
10943
|
+
return De(a, e).pathname !== "/";
|
|
10936
10944
|
}
|
|
10937
10945
|
function X(a, e, t = "") {
|
|
10938
|
-
const i =
|
|
10939
|
-
return i.pathname =
|
|
10946
|
+
const i = De(a, t);
|
|
10947
|
+
return i.pathname = wt(i.pathname, e), i.href;
|
|
10940
10948
|
}
|
|
10941
|
-
function
|
|
10942
|
-
const i =
|
|
10943
|
-
return i.protocol === "https:" ? i.protocol = "wss:" : i.protocol === "http:" ? i.protocol = "ws:" : i.protocol !== "ws:" && i.protocol !== "wss:" && (i.protocol = "wss:"), i.pathname =
|
|
10949
|
+
function Ue(a, e = "ws", t = "") {
|
|
10950
|
+
const i = De(a, t);
|
|
10951
|
+
return i.protocol === "https:" ? i.protocol = "wss:" : i.protocol === "http:" ? i.protocol = "ws:" : i.protocol !== "ws:" && i.protocol !== "wss:" && (i.protocol = "wss:"), i.pathname = wt(i.pathname, e), i.href;
|
|
10944
10952
|
}
|
|
10945
|
-
function
|
|
10953
|
+
function et(a, e = "") {
|
|
10946
10954
|
if (!String(a || "").trim())
|
|
10947
10955
|
return String(e || "").replace(/^\/+/, "");
|
|
10948
|
-
const t = new URL(
|
|
10956
|
+
const t = new URL(pt(String(a).trim())), i = String(t.pathname || "/").replace(/^\/+/, ""), s = String(t.search || "");
|
|
10949
10957
|
return `${i}${s}` || String(e || "").replace(/^\/+/, "");
|
|
10950
10958
|
}
|
|
10951
|
-
function
|
|
10959
|
+
function tt({
|
|
10952
10960
|
apiBaseUrl: a,
|
|
10953
10961
|
transportBaseUrl: e = "",
|
|
10954
10962
|
transportUrl: t = "",
|
|
10955
10963
|
fallbackPath: i = "ws"
|
|
10956
10964
|
}) {
|
|
10957
10965
|
const s = String(e || "").trim();
|
|
10958
|
-
return s ?
|
|
10966
|
+
return s ? Ue(s, et(t, i)) : gi(a) ? Ue(a, et(t, i)) : String(t || "").trim() ? String(t).trim() : Ue(a, i);
|
|
10959
10967
|
}
|
|
10960
|
-
const
|
|
10968
|
+
const fi = `
|
|
10961
10969
|
:host { all: initial; }
|
|
10962
10970
|
.widget { font-family: "Noto Sans SC", "PingFang SC", sans-serif; color: #16302b; }
|
|
10963
10971
|
.panel { width: min(360px, 92vw); border-radius: 24px; overflow: hidden; background: linear-gradient(180deg, #fffdf6, #f4efe4); box-shadow: 0 22px 54px rgba(17, 30, 28, 0.22); border: 1px solid rgba(28, 78, 67, 0.12); }
|
|
@@ -11003,38 +11011,52 @@ const hi = `
|
|
|
11003
11011
|
rejected: "本次来电已拒接,widget 仍保持待机。",
|
|
11004
11012
|
missed: "本次来电未接听,widget 仍保持待机。",
|
|
11005
11013
|
failed: "本次呼叫失败,请先看下方日志。"
|
|
11006
|
-
},
|
|
11014
|
+
}, pi = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", yt = 15e3, mi = 15e3, it = 2, wi = 2, me = yt * wi, Te = {
|
|
11007
11015
|
ready: "线路可用",
|
|
11008
11016
|
recovering: "正在恢复",
|
|
11009
11017
|
offline: "当前离线"
|
|
11010
11018
|
};
|
|
11011
|
-
function
|
|
11019
|
+
function yi(a, e) {
|
|
11012
11020
|
return e ? `${a}
|
|
11013
11021
|
${JSON.stringify(e, null, 2)}` : a;
|
|
11014
11022
|
}
|
|
11015
|
-
function
|
|
11023
|
+
function bi(a) {
|
|
11016
11024
|
return a === "outbound" ? "outbound" : "terminal";
|
|
11017
11025
|
}
|
|
11018
|
-
function
|
|
11026
|
+
function vi(a) {
|
|
11019
11027
|
return typeof a == "function";
|
|
11020
11028
|
}
|
|
11021
|
-
function
|
|
11029
|
+
function Si() {
|
|
11022
11030
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("embeddedCallWidgetE2E") === "1";
|
|
11023
11031
|
}
|
|
11024
|
-
function
|
|
11032
|
+
function Ti() {
|
|
11025
11033
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `widget-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
11026
11034
|
}
|
|
11027
|
-
function
|
|
11035
|
+
function Ne(a) {
|
|
11028
11036
|
const e = String(a?.message || a || "");
|
|
11029
11037
|
return /Failed to fetch|NetworkError|Load failed|network/i.test(e);
|
|
11030
11038
|
}
|
|
11031
|
-
|
|
11039
|
+
function te(a = {}, e = null) {
|
|
11040
|
+
const t = a?.advanced && typeof a.advanced == "object" ? a.advanced : {}, i = String(t.visitorBusinessKey ?? "").trim();
|
|
11041
|
+
if (i)
|
|
11042
|
+
return i;
|
|
11043
|
+
const s = String(a?.businessKey ?? "").trim();
|
|
11044
|
+
return s || String(e?.default_business_key ?? "").trim();
|
|
11045
|
+
}
|
|
11046
|
+
function Ei(a) {
|
|
11047
|
+
const e = new Error(a);
|
|
11048
|
+
return e.name = "EmbeddedCallWidgetLifecycleCancelledError", e.code = "widget_runtime_run_stale", e;
|
|
11049
|
+
}
|
|
11050
|
+
function st(a) {
|
|
11051
|
+
return a?.code === "sip_client_replaced" || a?.code === "widget_runtime_run_stale";
|
|
11052
|
+
}
|
|
11053
|
+
class Ci {
|
|
11032
11054
|
constructor({ mount: e, shadowRoot: t, options: i }) {
|
|
11033
|
-
this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode =
|
|
11055
|
+
this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = bi(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = De(i.apiBaseUrl || window.location.origin).href, this.client = null, this.issuedSession = null, this.bootstrap = null, this.turnIceServers = [], this.state = "idle", this.finalizing = !1, this.isMobileViewport = !1, this.pendingIncomingCall = null, this.visibilityHandler = null, this.sessionTouchTimer = null, this.sessionRecoveryInFlight = null, this.transportDisconnectTimer = null, this.transportDisconnectContext = null, this.e2eBridgeEnabled = Si(), this.terminalFailureOverride = "", this.presenceId = Ti(), this.presenceTouchTimer = null, this.presenceFailureCount = 0, this.availabilityState = "recovering", this.availabilityDetail = "正在连接后台并准备网页电话待机。", this.connectivityRecoveryInFlight = null, this.lifecycleRunId = 0, this.networkOnline = typeof navigator > "u" ? !0 : navigator.onLine !== !1, this.pageVisible = typeof document > "u" ? !0 : document.visibilityState === "visible", this.onlineHandler = null, this.offlineHandler = null, this.refs = {};
|
|
11034
11056
|
}
|
|
11035
11057
|
async mount() {
|
|
11036
11058
|
this.isMobileViewport = typeof window < "u" && window.matchMedia("(max-width: 480px)").matches, this.shadowRoot.innerHTML = `
|
|
11037
|
-
<style>${
|
|
11059
|
+
<style>${fi}</style>
|
|
11038
11060
|
<section class="widget">
|
|
11039
11061
|
<div class="panel">
|
|
11040
11062
|
<div class="hero">
|
|
@@ -11044,7 +11066,7 @@ class vi {
|
|
|
11044
11066
|
<div class="status" data-role="status">${Q.idle}</div>
|
|
11045
11067
|
<div class="hint" data-role="hint"></div>
|
|
11046
11068
|
</div>
|
|
11047
|
-
<div class="meta" data-role="meta">站点键:${this.options.siteKey || "自动读取默认值"};访客主动呼叫默认规则:${this.options
|
|
11069
|
+
<div class="meta" data-role="meta">站点键:${this.options.siteKey || "自动读取默认值"};访客主动呼叫默认规则:${te(this.options) || "自动读取默认值"}</div>
|
|
11048
11070
|
<div class="actions">
|
|
11049
11071
|
<button class="btn btn-primary" data-role="primary" type="button">恢复网页电话待机</button>
|
|
11050
11072
|
<button class="btn btn-secondary" data-role="secondary" type="button" disabled>断开并清理</button>
|
|
@@ -11082,9 +11104,16 @@ class vi {
|
|
|
11082
11104
|
open() {
|
|
11083
11105
|
this.mountNode.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
11084
11106
|
}
|
|
11107
|
+
beginLifecycleRun() {
|
|
11108
|
+
return this.lifecycleRunId += 1, this.lifecycleRunId;
|
|
11109
|
+
}
|
|
11110
|
+
assertLifecycleRunCurrent(e) {
|
|
11111
|
+
if (e !== this.lifecycleRunId)
|
|
11112
|
+
throw Ei("网页电话已切换到新的连接流程,旧流程不再继续。");
|
|
11113
|
+
}
|
|
11085
11114
|
emitHostCallback(e, t) {
|
|
11086
11115
|
const i = this.options?.[e];
|
|
11087
|
-
if (
|
|
11116
|
+
if (vi(i))
|
|
11088
11117
|
try {
|
|
11089
11118
|
i(t);
|
|
11090
11119
|
} catch (s) {
|
|
@@ -11101,7 +11130,7 @@ class vi {
|
|
|
11101
11130
|
sessionMode: this.issuedSession?.session_mode || null,
|
|
11102
11131
|
sessionId: this.issuedSession?.session_id || null,
|
|
11103
11132
|
siteKey: this.options.siteKey || this.bootstrap?.default_site_key || null,
|
|
11104
|
-
businessKey: this.issuedSession?.resolved_business_key || this.options
|
|
11133
|
+
businessKey: this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || null,
|
|
11105
11134
|
standbyMode: this.issuedSession?.standby_mode || null,
|
|
11106
11135
|
standbyState: this.issuedSession?.standby_state || this.options.standbyState || null,
|
|
11107
11136
|
widgetSipNumber: this.issuedSession?.widget_anchor_number || null,
|
|
@@ -11133,7 +11162,8 @@ class vi {
|
|
|
11133
11162
|
user: s,
|
|
11134
11163
|
host: i,
|
|
11135
11164
|
direction: "inbound",
|
|
11136
|
-
uri: t.uri || `sip:${s}@${i}
|
|
11165
|
+
uri: t.uri || `sip:${s}@${i}`,
|
|
11166
|
+
e2eSimulated: !0
|
|
11137
11167
|
}, this.setState("incoming"), this.emitHostCallback("onIncomingCall", this.pendingIncomingCall), this.getSnapshot();
|
|
11138
11168
|
},
|
|
11139
11169
|
answerIncomingCall: async () => (await this.answerIncomingCall(), this.getSnapshot()),
|
|
@@ -11177,45 +11207,63 @@ class vi {
|
|
|
11177
11207
|
await this.disconnectAndCleanup("manual-disconnect");
|
|
11178
11208
|
}
|
|
11179
11209
|
async connectAndCall() {
|
|
11180
|
-
if (
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11210
|
+
if (["requesting", "registering", "calling", "connected"].includes(this.state))
|
|
11211
|
+
return;
|
|
11212
|
+
const e = this.beginLifecycleRun();
|
|
11213
|
+
try {
|
|
11214
|
+
this.terminalFailureOverride = "", this.setAvailabilityState("recovering", "正在建立呼叫链路。"), !this.legacyOutboundOnly && this.issuedSession?.session_mode === "widget_standby" && (this.appendLog("访客主动呼叫前,先释放当前待机会话并切换到呼叫链路。", {
|
|
11215
|
+
widget_anchor_number: this.issuedSession?.widget_anchor_number || null,
|
|
11216
|
+
resolved_business_key: this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || null
|
|
11217
|
+
}), await this.disconnectAndCleanup("switch-to-outbound-call", {
|
|
11218
|
+
preserveLifecycleRun: !0
|
|
11219
|
+
}), this.assertLifecycleRunCurrent(e)), this.setState("requesting"), await this.loadBootstrap(), this.assertLifecycleRunCurrent(e), this.turnIceServers = await this.fetchTurnIceServers(), this.assertLifecycleRunCurrent(e);
|
|
11220
|
+
const t = await this.fetchIssuedSession();
|
|
11221
|
+
this.assertLifecycleRunCurrent(e), await this.ensureClient(t), this.assertLifecycleRunCurrent(e), this.setState("registering"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(e), this.setState("calling"), this.syncAvailabilityState(), await this.client.call(t.target), this.assertLifecycleRunCurrent(e), this.appendLog("已发起呼叫", {
|
|
11222
|
+
target: t.target,
|
|
11223
|
+
route_note: t.routeNote || null
|
|
11224
|
+
});
|
|
11225
|
+
} catch (t) {
|
|
11226
|
+
if (st(t)) {
|
|
11227
|
+
this.appendLog("已忽略过期的网页电话呼叫流程", {
|
|
11228
|
+
message: t?.message || String(t)
|
|
11190
11229
|
});
|
|
11191
|
-
|
|
11192
|
-
const t = e?.message || String(e);
|
|
11193
|
-
if (this.terminalFailureOverride = t, this.setState("failed", t), Ue(e) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "呼叫失败,正在准备恢复网页电话待机。"), this.appendLog("连接并呼叫失败", { message: t }), await this.releaseIssuedSession("failed", "connect-and-call-failed"), !this.legacyOutboundOnly) {
|
|
11194
|
-
this.appendLog("呼叫失败后,网页电话将恢复待机。", { message: t }), await this.startStandby({ force: !0 });
|
|
11195
|
-
return;
|
|
11196
|
-
}
|
|
11197
|
-
this.setState("failed", t);
|
|
11230
|
+
return;
|
|
11198
11231
|
}
|
|
11232
|
+
const i = t?.message || String(t);
|
|
11233
|
+
if (this.terminalFailureOverride = i, this.setState("failed", i), Ne(t) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "呼叫失败,正在准备恢复网页电话待机。"), this.appendLog("连接并呼叫失败", { message: i }), await this.releaseIssuedSession("failed", "connect-and-call-failed"), !this.legacyOutboundOnly) {
|
|
11234
|
+
this.appendLog("呼叫失败后,网页电话将恢复待机。", { message: i }), await this.startStandby({ force: !0 });
|
|
11235
|
+
return;
|
|
11236
|
+
}
|
|
11237
|
+
this.setState("failed", i);
|
|
11238
|
+
}
|
|
11199
11239
|
}
|
|
11200
11240
|
async startStandby(e = {}) {
|
|
11201
11241
|
if (this.legacyOutboundOnly)
|
|
11202
11242
|
throw new Error("当前 widget 仍处于 legacy outbound 兼容模式");
|
|
11203
11243
|
const { force: t = !1 } = e;
|
|
11204
|
-
if (!
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11244
|
+
if (!t && ["standbyRequesting", "registering", "incoming", "connected"].includes(this.state))
|
|
11245
|
+
return;
|
|
11246
|
+
const i = this.beginLifecycleRun();
|
|
11247
|
+
try {
|
|
11248
|
+
this.terminalFailureOverride = "", this.setState("standbyRequesting"), this.setAvailabilityState("recovering", "正在申请新的待机会话。"), await this.loadBootstrap(), this.assertLifecycleRunCurrent(i), this.turnIceServers = await this.fetchTurnIceServers(), this.assertLifecycleRunCurrent(i);
|
|
11249
|
+
const s = await this.fetchStandbySession();
|
|
11250
|
+
this.assertLifecycleRunCurrent(i), await this.ensureClient(s), this.assertLifecycleRunCurrent(i), this.setState("registering", "待机会话已拿到,正在连接并执行 REGISTER。"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(i), this.setState("standby"), this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。"), this.appendLog("widget 已进入待机", {
|
|
11251
|
+
session_id: this.issuedSession?.session_id || null,
|
|
11252
|
+
route_business_key: this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || null,
|
|
11253
|
+
standby_mode: this.issuedSession?.standby_mode || null,
|
|
11254
|
+
widget_anchor_number: this.issuedSession?.widget_anchor_number || null,
|
|
11255
|
+
browser_sip_username: this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username || null
|
|
11256
|
+
}), this.emitHostCallback("onStandbyReady", this.getSnapshot());
|
|
11257
|
+
} catch (s) {
|
|
11258
|
+
if (st(s)) {
|
|
11259
|
+
this.appendLog("已忽略过期的网页电话待机流程", {
|
|
11260
|
+
message: s?.message || String(s)
|
|
11261
|
+
});
|
|
11262
|
+
return;
|
|
11218
11263
|
}
|
|
11264
|
+
const r = s?.message || String(s);
|
|
11265
|
+
this.terminalFailureOverride = r, this.setState("failed", r), Ne(s) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "当前未能完成待机注册,系统会继续自动恢复。"), this.appendLog("进入待机失败", { message: r }), await this.releaseIssuedSession("failed", "standby-start-failed"), this.setState("failed", r);
|
|
11266
|
+
}
|
|
11219
11267
|
}
|
|
11220
11268
|
async ensureClient(e) {
|
|
11221
11269
|
const t = {
|
|
@@ -11225,7 +11273,7 @@ class vi {
|
|
|
11225
11273
|
webrtc_url: e.transport,
|
|
11226
11274
|
ice_servers: this.turnIceServers
|
|
11227
11275
|
};
|
|
11228
|
-
this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new
|
|
11276
|
+
this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new li(t, {
|
|
11229
11277
|
remoteAudioElement: this.refs.audio,
|
|
11230
11278
|
onStateChange: (i, s) => {
|
|
11231
11279
|
this.handleClientState(i, s);
|
|
@@ -11289,10 +11337,10 @@ class vi {
|
|
|
11289
11337
|
const t = this.transportDisconnectContext, i = !!(e && t?.reported && this.sameTransportDisconnectContext(t));
|
|
11290
11338
|
this.stopTransportDisconnectGrace(), i && (await this.reportIssuedSessionEvent("transport-restored", {
|
|
11291
11339
|
disconnectDurationMs: Date.now() - (t.startedAt || Date.now()),
|
|
11292
|
-
graceMs:
|
|
11340
|
+
graceMs: me
|
|
11293
11341
|
}, this.state), this.appendLog("网页通话信令已恢复", {
|
|
11294
11342
|
disconnectDurationMs: Date.now() - (t.startedAt || Date.now()),
|
|
11295
|
-
graceMs:
|
|
11343
|
+
graceMs: me
|
|
11296
11344
|
}));
|
|
11297
11345
|
}
|
|
11298
11346
|
scheduleTransportDisconnectGrace(e) {
|
|
@@ -11308,16 +11356,16 @@ class vi {
|
|
|
11308
11356
|
this.transportDisconnectContext = t, this.transportDisconnectTimer = window.setTimeout(() => {
|
|
11309
11357
|
this.transportDisconnectTimer = null, this.sameTransportDisconnectContext(t) && (t.reported = !0, this.reportIssuedSessionEvent("transport-disconnected", {
|
|
11310
11358
|
state: e,
|
|
11311
|
-
graceMs:
|
|
11359
|
+
graceMs: me
|
|
11312
11360
|
}, this.state), this.appendLog("网页通话信令断开超过宽限窗口", {
|
|
11313
|
-
graceMs:
|
|
11361
|
+
graceMs: me,
|
|
11314
11362
|
state: e
|
|
11315
11363
|
}));
|
|
11316
|
-
},
|
|
11364
|
+
}, me);
|
|
11317
11365
|
}
|
|
11318
11366
|
async finalizeAfterTermination(e) {
|
|
11319
11367
|
if (!this.finalizing) {
|
|
11320
|
-
this.finalizing = !0;
|
|
11368
|
+
this.beginLifecycleRun(), this.finalizing = !0;
|
|
11321
11369
|
try {
|
|
11322
11370
|
if (this.stopSessionTouch(), this.stopTransportDisconnectGrace(), await this.releaseIssuedSession("released", e), this.client && (await this.client.destroy(), this.client = null), !this.legacyOutboundOnly) {
|
|
11323
11371
|
this.setState("idle", "上一通通话已结束,正在恢复网页电话待机。"), this.setAvailabilityState("recovering", "上一通通话已结束,正在恢复网页电话待机。"), this.appendLog("通话已结束,网页电话正在恢复待机。", { reason: e }), await this.startStandby({ force: !0 });
|
|
@@ -11340,6 +11388,10 @@ class vi {
|
|
|
11340
11388
|
}
|
|
11341
11389
|
async answerIncomingCall() {
|
|
11342
11390
|
if (this.state === "incoming") {
|
|
11391
|
+
if (this.e2eBridgeEnabled && this.pendingIncomingCall?.e2eSimulated) {
|
|
11392
|
+
this.setState("connected", "测试桥已模拟接听当前来电。"), this.emitHostCallback("onCallAnswered", this.pendingIncomingCall);
|
|
11393
|
+
return;
|
|
11394
|
+
}
|
|
11343
11395
|
if (!this.client && this.e2eBridgeEnabled) {
|
|
11344
11396
|
this.setState("connected", "测试桥已模拟接听当前来电。"), this.emitHostCallback("onCallAnswered", this.pendingIncomingCall);
|
|
11345
11397
|
return;
|
|
@@ -11351,6 +11403,10 @@ class vi {
|
|
|
11351
11403
|
}
|
|
11352
11404
|
async declineIncomingCall() {
|
|
11353
11405
|
if (this.state === "incoming") {
|
|
11406
|
+
if (this.e2eBridgeEnabled && this.pendingIncomingCall?.e2eSimulated) {
|
|
11407
|
+
this.setState("rejected"), this.emitHostCallback("onCallRejected", this.pendingIncomingCall), this.pendingIncomingCall = null;
|
|
11408
|
+
return;
|
|
11409
|
+
}
|
|
11354
11410
|
if (!this.client && this.e2eBridgeEnabled) {
|
|
11355
11411
|
this.setState("rejected"), this.emitHostCallback("onCallRejected", this.pendingIncomingCall), this.pendingIncomingCall = null;
|
|
11356
11412
|
return;
|
|
@@ -11361,14 +11417,19 @@ class vi {
|
|
|
11361
11417
|
}
|
|
11362
11418
|
}
|
|
11363
11419
|
async hangupCall() {
|
|
11420
|
+
if (this.e2eBridgeEnabled && this.pendingIncomingCall?.e2eSimulated) {
|
|
11421
|
+
this.legacyOutboundOnly ? this.setState("ended") : this.setState("standby", "测试桥已模拟挂断,网页电话已恢复待机。"), this.pendingIncomingCall = null;
|
|
11422
|
+
return;
|
|
11423
|
+
}
|
|
11364
11424
|
if (!this.client && this.e2eBridgeEnabled) {
|
|
11365
11425
|
this.legacyOutboundOnly ? this.setState("ended") : this.setState("standby", "测试桥已模拟挂断,网页电话已恢复待机。"), this.pendingIncomingCall = null;
|
|
11366
11426
|
return;
|
|
11367
11427
|
}
|
|
11368
11428
|
this.client && await this.client.hangup();
|
|
11369
11429
|
}
|
|
11370
|
-
async disconnectAndCleanup(e) {
|
|
11371
|
-
|
|
11430
|
+
async disconnectAndCleanup(e, t = {}) {
|
|
11431
|
+
const { preserveLifecycleRun: i = !1 } = t;
|
|
11432
|
+
i || this.beginLifecycleRun(), this.stopSessionTouch(), this.stopTransportDisconnectGrace(), this.reportIssuedSessionEvent("manual-disconnect", {
|
|
11372
11433
|
reason: e
|
|
11373
11434
|
}, this.state), this.pendingIncomingCall = null, this.terminalFailureOverride = "", this.client && (await this.client.destroy(), this.client = null), await this.releaseIssuedSession("released", e), this.setState("idle"), this.setAvailabilityState("recovering", "网页电话已断开,可按需重新恢复待机。"), this.appendLog("连接已断开", { reason: e });
|
|
11374
11435
|
}
|
|
@@ -11394,7 +11455,7 @@ class vi {
|
|
|
11394
11455
|
return Array.isArray(t?.ice_servers) ? t.ice_servers : [];
|
|
11395
11456
|
}
|
|
11396
11457
|
async fetchIssuedSession() {
|
|
11397
|
-
const e = this.options.siteKey || this.bootstrap?.default_site_key || "", t =
|
|
11458
|
+
const e = this.options.siteKey || this.bootstrap?.default_site_key || "", t = te(this.options, this.bootstrap);
|
|
11398
11459
|
if (!e)
|
|
11399
11460
|
throw new Error("当前 SDK 模式必须明确提供 siteKey,或让服务端下发默认站点键");
|
|
11400
11461
|
const i = {
|
|
@@ -11438,7 +11499,7 @@ class vi {
|
|
|
11438
11499
|
sipUsername: r.sip_username,
|
|
11439
11500
|
sipDomain: r.sip_domain,
|
|
11440
11501
|
password: r.sip_password,
|
|
11441
|
-
transport:
|
|
11502
|
+
transport: tt({
|
|
11442
11503
|
apiBaseUrl: this.apiBaseUrl,
|
|
11443
11504
|
transportBaseUrl: this.options.transportBaseUrl || "",
|
|
11444
11505
|
transportUrl: r.ws_server
|
|
@@ -11448,7 +11509,7 @@ class vi {
|
|
|
11448
11509
|
};
|
|
11449
11510
|
}
|
|
11450
11511
|
async fetchStandbySession() {
|
|
11451
|
-
const e = this.options.siteKey || this.bootstrap?.default_site_key || "", t =
|
|
11512
|
+
const e = this.options.siteKey || this.bootstrap?.default_site_key || "", t = te(this.options) || null;
|
|
11452
11513
|
if (!e)
|
|
11453
11514
|
throw new Error("当前 SDK 待机模式必须明确提供 siteKey,或让服务端下发默认站点键");
|
|
11454
11515
|
const i = {
|
|
@@ -11490,7 +11551,7 @@ class vi {
|
|
|
11490
11551
|
sipUsername: r.sip_username,
|
|
11491
11552
|
sipDomain: r.sip_domain,
|
|
11492
11553
|
password: r.sip_password,
|
|
11493
|
-
transport:
|
|
11554
|
+
transport: tt({
|
|
11494
11555
|
apiBaseUrl: this.apiBaseUrl,
|
|
11495
11556
|
transportBaseUrl: this.options.transportBaseUrl || "",
|
|
11496
11557
|
transportUrl: r.ws_server
|
|
@@ -11541,7 +11602,7 @@ class vi {
|
|
|
11541
11602
|
};
|
|
11542
11603
|
}
|
|
11543
11604
|
setAvailabilityState(e, t = "") {
|
|
11544
|
-
this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${
|
|
11605
|
+
this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${Te[e] || Te.recovering} · ${t}` : Te[e] || Te.recovering, this.refs.availability.className = `availability availability--${e}`), this.render();
|
|
11545
11606
|
}
|
|
11546
11607
|
syncAvailabilityState() {
|
|
11547
11608
|
if (this.networkOnline === !1) {
|
|
@@ -11593,7 +11654,7 @@ class vi {
|
|
|
11593
11654
|
presence_id: this.presenceId,
|
|
11594
11655
|
state: this.state,
|
|
11595
11656
|
site_key: this.options.siteKey || this.bootstrap?.default_site_key || void 0,
|
|
11596
|
-
requested_business_key: this.options
|
|
11657
|
+
requested_business_key: te(this.options, this.bootstrap) || void 0,
|
|
11597
11658
|
resolved_business_key: this.issuedSession?.resolved_business_key || void 0,
|
|
11598
11659
|
display_name: this.options.displayName || void 0,
|
|
11599
11660
|
page_url: typeof window > "u" ? void 0 : window.location.href,
|
|
@@ -11615,12 +11676,12 @@ class vi {
|
|
|
11615
11676
|
throw new Error(`运行态心跳失败:${i.status}`);
|
|
11616
11677
|
this.presenceFailureCount = 0, this.syncAvailabilityState(), t && await this.restartStandbyAfterConnectivity(`presence-${e}`);
|
|
11617
11678
|
} catch (i) {
|
|
11618
|
-
if (this.presenceFailureCount += 1, this.networkOnline === !1 ||
|
|
11679
|
+
if (this.presenceFailureCount += 1, this.networkOnline === !1 || Ne(i) || this.presenceFailureCount >= it) {
|
|
11619
11680
|
const r = this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。";
|
|
11620
11681
|
this.setAvailabilityState("offline", r);
|
|
11621
11682
|
} else
|
|
11622
11683
|
this.setAvailabilityState("recovering", "正在确认后台连接状态。");
|
|
11623
|
-
this.presenceFailureCount <=
|
|
11684
|
+
this.presenceFailureCount <= it && this.appendLog("widget 运行态心跳失败", {
|
|
11624
11685
|
trigger: e,
|
|
11625
11686
|
failure_count: this.presenceFailureCount,
|
|
11626
11687
|
message: i?.message || String(i)
|
|
@@ -11630,7 +11691,7 @@ class vi {
|
|
|
11630
11691
|
startPresenceTouch() {
|
|
11631
11692
|
this.legacyOutboundOnly || (this.touchWidgetPresence("mount"), this.presenceTouchTimer || (this.presenceTouchTimer = window.setInterval(() => {
|
|
11632
11693
|
this.touchWidgetPresence("interval");
|
|
11633
|
-
},
|
|
11694
|
+
}, mi)));
|
|
11634
11695
|
}
|
|
11635
11696
|
async touchIssuedSession(e, t = null) {
|
|
11636
11697
|
if (!this.issuedSession?.session_id)
|
|
@@ -11739,14 +11800,14 @@ class vi {
|
|
|
11739
11800
|
}
|
|
11740
11801
|
this.touchIssuedSession(e), this.sessionTouchTimer || (this.sessionTouchTimer = window.setInterval(() => {
|
|
11741
11802
|
this.touchIssuedSession(this.state);
|
|
11742
|
-
},
|
|
11803
|
+
}, yt));
|
|
11743
11804
|
}
|
|
11744
11805
|
setState(e, t = "") {
|
|
11745
11806
|
this.state = e, this.refs.status.textContent = t || Q[e] || Q.idle, this.emitHostCallback("onStateChange", this.getSnapshot()), this.syncAvailabilityState(), this.render();
|
|
11746
11807
|
}
|
|
11747
11808
|
appendLog(e, t) {
|
|
11748
11809
|
const i = document.createElement("div");
|
|
11749
|
-
for (i.className = "log", i.textContent =
|
|
11810
|
+
for (i.className = "log", i.textContent = yi(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
|
|
11750
11811
|
this.refs.logs.lastElementChild?.remove();
|
|
11751
11812
|
}
|
|
11752
11813
|
render() {
|
|
@@ -11755,19 +11816,19 @@ class vi {
|
|
|
11755
11816
|
"status",
|
|
11756
11817
|
this.availabilityState === "offline" ? "status--offline" : this.availabilityState === "recovering" ? "status--recovering" : ""
|
|
11757
11818
|
].filter(Boolean).join(" ")), this.legacyOutboundOnly ? (this.refs.primary.disabled = e, this.refs.primary.textContent = t ? "通话进行中" : "连接并呼叫", this.refs.secondary.disabled = !t && !i, this.refs.secondary.textContent = t ? "挂断并清理" : "断开并清理") : (this.refs.primary.disabled = e || this.state === "connected", this.state === "incoming" ? this.refs.primary.textContent = "接听来电" : e ? this.refs.primary.textContent = this.state === "calling" ? "通话进行中" : "正在恢复网页电话" : this.availabilityState === "offline" ? this.refs.primary.textContent = "网络恢复后再试" : !i || ["idle", "failed", "ended"].includes(this.state) ? this.refs.primary.textContent = "恢复网页电话待机" : this.refs.primary.textContent = "呼叫管理员", this.refs.secondary.disabled = !i, this.refs.secondary.textContent = this.state === "incoming" ? "拒接来电" : this.state === "connected" ? "挂断并恢复待机" : "断开电话");
|
|
11758
|
-
const s = this.options.siteKey || this.bootstrap?.default_site_key || "等待服务端返回", r = this.issuedSession?.resolved_business_key || this.options
|
|
11759
|
-
this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${r};站点键:${s}` : this.refs.meta.textContent = `站点键:${s};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${r}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ?
|
|
11819
|
+
const s = this.options.siteKey || this.bootstrap?.default_site_key || "等待服务端返回", r = this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || "等待服务端返回";
|
|
11820
|
+
this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${r};站点键:${s}` : this.refs.meta.textContent = `站点键:${s};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${r}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ? pi : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。";
|
|
11760
11821
|
}
|
|
11761
11822
|
async destroy() {
|
|
11762
11823
|
await this.disconnectAndCleanup("destroy-widget"), typeof document < "u" && this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.stopSessionTouch(), this.stopPresenceTouch(), this.stopTransportDisconnectGrace(), this.pendingIncomingCall = null, typeof window < "u" && (this.onlineHandler && (window.removeEventListener("online", this.onlineHandler), this.onlineHandler = null), this.offlineHandler && (window.removeEventListener("offline", this.offlineHandler), this.offlineHandler = null)), this.e2eBridgeEnabled && typeof window < "u" && window.__embeddedCallWidgetE2E__ && delete window.__embeddedCallWidgetE2E__, this.shadowRoot.innerHTML = "";
|
|
11763
11824
|
}
|
|
11764
11825
|
}
|
|
11765
|
-
function
|
|
11766
|
-
return new
|
|
11826
|
+
function xi(a) {
|
|
11827
|
+
return new Ci(a);
|
|
11767
11828
|
}
|
|
11768
11829
|
typeof window < "u" && (window.__EmbeddedCallWidgetRuntime__ = {
|
|
11769
|
-
createEmbeddedCallWidgetRuntime:
|
|
11830
|
+
createEmbeddedCallWidgetRuntime: xi
|
|
11770
11831
|
});
|
|
11771
11832
|
export {
|
|
11772
|
-
|
|
11833
|
+
xi as createEmbeddedCallWidgetRuntime
|
|
11773
11834
|
};
|