@shenyin/embedded-call-widget 2.6.9 → 2.6.10
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 +1 -1
- package/checksums.txt +3 -3
- package/embedded-call-widget-runtime.iife.js +26 -26
- package/embedded-call-widget-runtime.js +660 -604
- package/manifest.json +11 -11
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Et = "0.21.1";
|
|
2
2
|
class he extends Error {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
super(e), Object.setPrototypeOf(this, new.target.prototype);
|
|
@@ -15,7 +15,7 @@ class be extends he {
|
|
|
15
15
|
super(e || "Request pending.");
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class Rt extends he {
|
|
19
19
|
constructor(e) {
|
|
20
20
|
super(e || "Unspecified session description handler error.");
|
|
21
21
|
}
|
|
@@ -30,7 +30,7 @@ class me extends he {
|
|
|
30
30
|
super(e || "An error occurred during state transition.");
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class xt {
|
|
34
34
|
/** @internal */
|
|
35
35
|
constructor(e) {
|
|
36
36
|
this.incomingAckRequest = e;
|
|
@@ -40,7 +40,7 @@ class Rt {
|
|
|
40
40
|
return this.incomingAckRequest.message;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class _t {
|
|
44
44
|
/** @internal */
|
|
45
45
|
constructor(e) {
|
|
46
46
|
this.incomingByeRequest = e;
|
|
@@ -130,7 +130,7 @@ class ve {
|
|
|
130
130
|
return this.addListener(e, { once: !0 });
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
class
|
|
133
|
+
class At {
|
|
134
134
|
/** @internal */
|
|
135
135
|
constructor(e) {
|
|
136
136
|
this.incomingInfoRequest = e;
|
|
@@ -217,8 +217,8 @@ class Z extends at {
|
|
|
217
217
|
constructor(e = "sip", t, i, s, r, n) {
|
|
218
218
|
if (super(r || {}), this.headers = {}, !i)
|
|
219
219
|
throw new TypeError('missing or invalid "host" parameter');
|
|
220
|
-
for (const
|
|
221
|
-
n.hasOwnProperty(
|
|
220
|
+
for (const a in n)
|
|
221
|
+
n.hasOwnProperty(a) && this.setHeader(a, n[a]);
|
|
222
222
|
this.raw = {
|
|
223
223
|
scheme: e,
|
|
224
224
|
user: t,
|
|
@@ -333,27 +333,27 @@ class Z extends at {
|
|
|
333
333
|
return t[r] && (r = t[r]), r;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function Ze(
|
|
337
|
-
if (
|
|
336
|
+
function Ze(o, e) {
|
|
337
|
+
if (o.scheme !== e.scheme || o.user !== e.user || o.host !== e.host || o.port !== e.port)
|
|
338
338
|
return !1;
|
|
339
339
|
function t(r, n) {
|
|
340
|
-
const
|
|
341
|
-
return !(!
|
|
340
|
+
const a = Object.keys(r.parameters), d = Object.keys(n.parameters);
|
|
341
|
+
return !(!a.filter((h) => d.includes(h)).every((h) => r.parameters[h] === n.parameters[h]) || !["user", "ttl", "method", "transport"].every((h) => r.hasParam(h) && n.hasParam(h) || !r.hasParam(h) && !n.hasParam(h)) || !["maddr"].every((h) => r.hasParam(h) && n.hasParam(h) || !r.hasParam(h) && !n.hasParam(h)));
|
|
342
342
|
}
|
|
343
|
-
if (!t(
|
|
343
|
+
if (!t(o, e))
|
|
344
344
|
return !1;
|
|
345
|
-
const i = Object.keys(
|
|
345
|
+
const i = Object.keys(o.headers), s = Object.keys(e.headers);
|
|
346
346
|
if (i.length !== 0 || s.length !== 0) {
|
|
347
347
|
if (i.length !== s.length)
|
|
348
348
|
return !1;
|
|
349
349
|
const r = i.filter((n) => s.includes(n));
|
|
350
|
-
if (r.length !== s.length || !r.every((n) =>
|
|
350
|
+
if (r.length !== s.length || !r.every((n) => o.headers[n].length && e.headers[n].length && o.headers[n][0] === e.headers[n][0]))
|
|
351
351
|
return !1;
|
|
352
352
|
}
|
|
353
353
|
return !0;
|
|
354
354
|
}
|
|
355
|
-
function qe(
|
|
356
|
-
return t = t || " ",
|
|
355
|
+
function qe(o, e, t) {
|
|
356
|
+
return t = t || " ", o.length > e ? o : (e -= o.length, t += t.repeat(e), o + t.slice(0, e));
|
|
357
357
|
}
|
|
358
358
|
class ue extends Error {
|
|
359
359
|
constructor(e, t, i, s) {
|
|
@@ -384,7 +384,7 @@ class ue extends Error {
|
|
|
384
384
|
return f.description;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function a(f) {
|
|
388
388
|
const h = f.map(n);
|
|
389
389
|
let w, S;
|
|
390
390
|
if (h.sort(), h.length > 0) {
|
|
@@ -404,7 +404,7 @@ class ue extends Error {
|
|
|
404
404
|
function d(f) {
|
|
405
405
|
return f ? '"' + s(f) + '"' : "end of input";
|
|
406
406
|
}
|
|
407
|
-
return "Expected " +
|
|
407
|
+
return "Expected " + a(e) + " but " + d(t) + " found.";
|
|
408
408
|
}
|
|
409
409
|
format(e) {
|
|
410
410
|
let t = "Error: " + this.message;
|
|
@@ -417,7 +417,7 @@ class ue 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
|
|
420
|
+
let a = this.location.end, d = qe("", r.line.toString().length, " "), f = i[r.line - 1], h = r.line === a.line ? a.column : f.length + 1;
|
|
421
421
|
t += `
|
|
422
422
|
--> ` + n + `
|
|
423
423
|
` + d + ` |
|
|
@@ -430,7 +430,7 @@ class ue extends Error {
|
|
|
430
430
|
return t;
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function $t(o, 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;
|
|
@@ -743,7 +743,7 @@ function At(a, e) {
|
|
|
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
|
},
|
|
@@ -909,7 +909,7 @@ function At(a, e) {
|
|
|
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
|
},
|
|
@@ -943,7 +943,7 @@ function At(a, e) {
|
|
|
943
943
|
return y;
|
|
944
944
|
},
|
|
945
945
|
function(l, y) {
|
|
946
|
-
return
|
|
946
|
+
return Tt(l, y);
|
|
947
947
|
},
|
|
948
948
|
function(l) {
|
|
949
949
|
e = e || { data: {} }, e.startRule === "Require" && (e.data = l || []);
|
|
@@ -1082,7 +1082,7 @@ function At(a, e) {
|
|
|
1082
1082
|
p("b", !1),
|
|
1083
1083
|
"cid",
|
|
1084
1084
|
p("cid", !1)
|
|
1085
|
-
],
|
|
1085
|
+
], a = [
|
|
1086
1086
|
c('2 ""6 7!'),
|
|
1087
1087
|
c('4"""5!7#'),
|
|
1088
1088
|
c('4$""5!7%'),
|
|
@@ -1321,16 +1321,16 @@ function At(a, e) {
|
|
|
1321
1321
|
];
|
|
1322
1322
|
let d = 0, f = 0;
|
|
1323
1323
|
const h = [{ line: 1, column: 1 }];
|
|
1324
|
-
let w = 0, S = [],
|
|
1324
|
+
let w = 0, S = [], _ = 0, I;
|
|
1325
1325
|
if (e.startRule !== void 0) {
|
|
1326
1326
|
if (!(e.startRule in s))
|
|
1327
1327
|
throw new Error(`Can't start parsing from rule "` + e.startRule + '".');
|
|
1328
1328
|
r = s[e.startRule];
|
|
1329
1329
|
}
|
|
1330
1330
|
function E() {
|
|
1331
|
-
return
|
|
1331
|
+
return o.substring(f, d);
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1333
|
+
function ae() {
|
|
1334
1334
|
return He(f, d);
|
|
1335
1335
|
}
|
|
1336
1336
|
function p(l, y) {
|
|
@@ -1352,7 +1352,7 @@ function At(a, e) {
|
|
|
1352
1352
|
line: y.line,
|
|
1353
1353
|
column: y.column
|
|
1354
1354
|
}; u < l; )
|
|
1355
|
-
|
|
1355
|
+
o.charCodeAt(u) === 10 ? (y.line++, y.column = 1) : y.column++, u++;
|
|
1356
1356
|
return h[l] = y, y;
|
|
1357
1357
|
}
|
|
1358
1358
|
function He(l, y) {
|
|
@@ -1374,21 +1374,21 @@ function At(a, e) {
|
|
|
1374
1374
|
function ze(l) {
|
|
1375
1375
|
d < w || (d > w && (w = d, S = []), S.push(l));
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1377
|
+
function St(l, y, u) {
|
|
1378
1378
|
return new ue(ue.buildMessage(l, y), l, y, u);
|
|
1379
1379
|
}
|
|
1380
1380
|
function c(l) {
|
|
1381
1381
|
return l.split("").map((y) => y.charCodeAt(0) - 32);
|
|
1382
1382
|
}
|
|
1383
1383
|
function Ye(l) {
|
|
1384
|
-
const y =
|
|
1384
|
+
const y = a[l];
|
|
1385
1385
|
let u = 0;
|
|
1386
1386
|
const j = [];
|
|
1387
|
-
let
|
|
1387
|
+
let D = y.length;
|
|
1388
1388
|
const K = [], C = [];
|
|
1389
1389
|
let Je;
|
|
1390
1390
|
for (; ; ) {
|
|
1391
|
-
for (; u <
|
|
1391
|
+
for (; u < D; )
|
|
1392
1392
|
switch (y[u]) {
|
|
1393
1393
|
case 0:
|
|
1394
1394
|
C.push(n[y[u + 1]]), u += 2;
|
|
@@ -1427,40 +1427,40 @@ function At(a, e) {
|
|
|
1427
1427
|
C.push(C.splice(C.length - y[u + 1], y[u + 1])), u += 2;
|
|
1428
1428
|
break;
|
|
1429
1429
|
case 12:
|
|
1430
|
-
C.push(
|
|
1430
|
+
C.push(o.substring(C.pop(), d)), u++;
|
|
1431
1431
|
break;
|
|
1432
1432
|
case 13:
|
|
1433
|
-
K.push(
|
|
1433
|
+
K.push(D), j.push(u + 3 + y[u + 1] + y[u + 2]), C[C.length - 1] ? (D = u + 3 + y[u + 1], u += 3) : (D = u + 3 + y[u + 1] + y[u + 2], u += 3 + y[u + 1]);
|
|
1434
1434
|
break;
|
|
1435
1435
|
case 14:
|
|
1436
|
-
K.push(
|
|
1436
|
+
K.push(D), j.push(u + 3 + y[u + 1] + y[u + 2]), C[C.length - 1] === t ? (D = u + 3 + y[u + 1], u += 3) : (D = u + 3 + y[u + 1] + y[u + 2], u += 3 + y[u + 1]);
|
|
1437
1437
|
break;
|
|
1438
1438
|
case 15:
|
|
1439
|
-
K.push(
|
|
1439
|
+
K.push(D), j.push(u + 3 + y[u + 1] + y[u + 2]), C[C.length - 1] !== t ? (D = u + 3 + y[u + 1], u += 3) : (D = u + 3 + y[u + 1] + y[u + 2], u += 3 + y[u + 1]);
|
|
1440
1440
|
break;
|
|
1441
1441
|
case 16:
|
|
1442
|
-
C[C.length - 1] !== t ? (K.push(
|
|
1442
|
+
C[C.length - 1] !== t ? (K.push(D), j.push(u), D = u + 2 + y[u + 1], u += 2) : u += 2 + y[u + 1];
|
|
1443
1443
|
break;
|
|
1444
1444
|
case 17:
|
|
1445
|
-
K.push(
|
|
1445
|
+
K.push(D), j.push(u + 3 + y[u + 1] + y[u + 2]), o.length > d ? (D = u + 3 + y[u + 1], u += 3) : (D = u + 3 + y[u + 1] + y[u + 2], u += 3 + y[u + 1]);
|
|
1446
1446
|
break;
|
|
1447
1447
|
case 18:
|
|
1448
|
-
K.push(
|
|
1448
|
+
K.push(D), j.push(u + 4 + y[u + 2] + y[u + 3]), o.substr(d, n[y[u + 1]].length) === n[y[u + 1]] ? (D = u + 4 + y[u + 2], u += 4) : (D = u + 4 + y[u + 2] + y[u + 3], u += 4 + y[u + 2]);
|
|
1449
1449
|
break;
|
|
1450
1450
|
case 19:
|
|
1451
|
-
K.push(
|
|
1451
|
+
K.push(D), j.push(u + 4 + y[u + 2] + y[u + 3]), o.substr(d, n[y[u + 1]].length).toLowerCase() === n[y[u + 1]] ? (D = u + 4 + y[u + 2], u += 4) : (D = u + 4 + y[u + 2] + y[u + 3], u += 4 + y[u + 2]);
|
|
1452
1452
|
break;
|
|
1453
1453
|
case 20:
|
|
1454
|
-
K.push(
|
|
1454
|
+
K.push(D), j.push(u + 4 + y[u + 2] + y[u + 3]), n[y[u + 1]].test(o.charAt(d)) ? (D = u + 4 + y[u + 2], u += 4) : (D = u + 4 + y[u + 2] + y[u + 3], u += 4 + y[u + 2]);
|
|
1455
1455
|
break;
|
|
1456
1456
|
case 21:
|
|
1457
|
-
C.push(
|
|
1457
|
+
C.push(o.substr(d, y[u + 1])), d += y[u + 1], u += 2;
|
|
1458
1458
|
break;
|
|
1459
1459
|
case 22:
|
|
1460
1460
|
C.push(n[y[u + 1]]), d += n[y[u + 1]].length, u += 2;
|
|
1461
1461
|
break;
|
|
1462
1462
|
case 23:
|
|
1463
|
-
C.push(t),
|
|
1463
|
+
C.push(t), _ === 0 && ze(n[y[u + 1]]), u += 2;
|
|
1464
1464
|
break;
|
|
1465
1465
|
case 24:
|
|
1466
1466
|
f = C[C.length - 1 - y[u + 1]], u += 2;
|
|
@@ -1469,62 +1469,62 @@ function At(a, e) {
|
|
|
1469
1469
|
f = d, u++;
|
|
1470
1470
|
break;
|
|
1471
1471
|
case 26:
|
|
1472
|
-
Je = y.slice(u + 4, u + 4 + y[u + 3]).map(function(
|
|
1473
|
-
return C[C.length - 1 -
|
|
1472
|
+
Je = y.slice(u + 4, u + 4 + y[u + 3]).map(function(Ct) {
|
|
1473
|
+
return C[C.length - 1 - Ct];
|
|
1474
1474
|
}), C.splice(C.length - y[u + 2], y[u + 2], n[y[u + 1]].apply(null, Je)), u += 4 + y[u + 3];
|
|
1475
1475
|
break;
|
|
1476
1476
|
case 27:
|
|
1477
1477
|
C.push(Ye(y[u + 1])), u += 2;
|
|
1478
1478
|
break;
|
|
1479
1479
|
case 28:
|
|
1480
|
-
|
|
1480
|
+
_++, u++;
|
|
1481
1481
|
break;
|
|
1482
1482
|
case 29:
|
|
1483
|
-
|
|
1483
|
+
_--, u++;
|
|
1484
1484
|
break;
|
|
1485
1485
|
default:
|
|
1486
1486
|
throw new Error("Invalid opcode: " + y[u] + ".");
|
|
1487
1487
|
}
|
|
1488
1488
|
if (K.length > 0)
|
|
1489
|
-
|
|
1489
|
+
D = K.pop(), u = j.pop();
|
|
1490
1490
|
else
|
|
1491
1491
|
break;
|
|
1492
1492
|
}
|
|
1493
1493
|
return C[0];
|
|
1494
1494
|
}
|
|
1495
1495
|
e.data = {};
|
|
1496
|
-
function
|
|
1496
|
+
function Tt(l, y) {
|
|
1497
1497
|
return [l].concat(y);
|
|
1498
1498
|
}
|
|
1499
|
-
if (
|
|
1500
|
-
return
|
|
1501
|
-
throw
|
|
1499
|
+
if (I = Ye(r), I !== t && d === o.length)
|
|
1500
|
+
return I;
|
|
1501
|
+
throw I !== t && d < o.length && ze(Pe()), St(S, w < o.length ? o.charAt(w) : null, w < o.length ? He(w, w + 1) : He(w, w));
|
|
1502
1502
|
}
|
|
1503
|
-
const
|
|
1503
|
+
const Dt = $t;
|
|
1504
1504
|
var P;
|
|
1505
|
-
(function(
|
|
1505
|
+
(function(o) {
|
|
1506
1506
|
function e(s, r) {
|
|
1507
1507
|
const n = { startRule: r };
|
|
1508
1508
|
try {
|
|
1509
|
-
|
|
1509
|
+
Dt(s, n);
|
|
1510
1510
|
} catch {
|
|
1511
1511
|
n.data = -1;
|
|
1512
1512
|
}
|
|
1513
1513
|
return n.data;
|
|
1514
1514
|
}
|
|
1515
|
-
|
|
1515
|
+
o.parse = e;
|
|
1516
1516
|
function t(s) {
|
|
1517
|
-
const r =
|
|
1517
|
+
const r = o.parse(s, "Name_Addr_Header");
|
|
1518
1518
|
return r !== -1 ? r : void 0;
|
|
1519
1519
|
}
|
|
1520
|
-
|
|
1520
|
+
o.nameAddrHeaderParse = t;
|
|
1521
1521
|
function i(s) {
|
|
1522
|
-
const r =
|
|
1522
|
+
const r = o.parse(s, "SIP_URI");
|
|
1523
1523
|
return r !== -1 ? r : void 0;
|
|
1524
1524
|
}
|
|
1525
|
-
|
|
1525
|
+
o.URIParse = i;
|
|
1526
1526
|
})(P = P || (P = {}));
|
|
1527
|
-
const
|
|
1527
|
+
const kt = {
|
|
1528
1528
|
100: "Trying",
|
|
1529
1529
|
180: "Ringing",
|
|
1530
1530
|
181: "Call Is Being Forwarded",
|
|
@@ -1597,21 +1597,21 @@ const Dt = {
|
|
|
1597
1597
|
604: "Does Not Exist Anywhere",
|
|
1598
1598
|
606: "Not Acceptable"
|
|
1599
1599
|
};
|
|
1600
|
-
function ce(
|
|
1600
|
+
function ce(o, e = 32) {
|
|
1601
1601
|
let t = "";
|
|
1602
|
-
for (let i = 0; i <
|
|
1602
|
+
for (let i = 0; i < o; i++) {
|
|
1603
1603
|
const s = Math.floor(Math.random() * e);
|
|
1604
1604
|
t += s.toString(e);
|
|
1605
1605
|
}
|
|
1606
1606
|
return t;
|
|
1607
1607
|
}
|
|
1608
|
-
function Ae(
|
|
1609
|
-
return
|
|
1608
|
+
function Ae(o) {
|
|
1609
|
+
return kt[o] || "";
|
|
1610
1610
|
}
|
|
1611
1611
|
function $e() {
|
|
1612
1612
|
return ce(10);
|
|
1613
1613
|
}
|
|
1614
|
-
function Y(
|
|
1614
|
+
function Y(o) {
|
|
1615
1615
|
const e = {
|
|
1616
1616
|
"Call-Id": "Call-ID",
|
|
1617
1617
|
Cseq: "CSeq",
|
|
@@ -1619,16 +1619,16 @@ function Y(a) {
|
|
|
1619
1619
|
Rack: "RAck",
|
|
1620
1620
|
Rseq: "RSeq",
|
|
1621
1621
|
"Www-Authenticate": "WWW-Authenticate"
|
|
1622
|
-
}, t =
|
|
1622
|
+
}, t = o.toLowerCase().replace(/_/g, "-").split("-"), i = t.length;
|
|
1623
1623
|
let s = "";
|
|
1624
1624
|
for (let r = 0; r < i; r++)
|
|
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 Se(
|
|
1629
|
-
return encodeURIComponent(
|
|
1628
|
+
function Se(o) {
|
|
1629
|
+
return encodeURIComponent(o).replace(/%[A-F\d]{2}/g, "U").length;
|
|
1630
1630
|
}
|
|
1631
|
-
class
|
|
1631
|
+
class ct {
|
|
1632
1632
|
constructor() {
|
|
1633
1633
|
this.headers = {};
|
|
1634
1634
|
}
|
|
@@ -1725,21 +1725,21 @@ class ot {
|
|
|
1725
1725
|
return this.data;
|
|
1726
1726
|
}
|
|
1727
1727
|
}
|
|
1728
|
-
class ge extends
|
|
1728
|
+
class ge extends ct {
|
|
1729
1729
|
constructor() {
|
|
1730
1730
|
super();
|
|
1731
1731
|
}
|
|
1732
1732
|
}
|
|
1733
|
-
class
|
|
1733
|
+
class oe extends ct {
|
|
1734
1734
|
constructor() {
|
|
1735
1735
|
super();
|
|
1736
1736
|
}
|
|
1737
1737
|
}
|
|
1738
1738
|
class le {
|
|
1739
|
-
constructor(e, t, i, s, r, n,
|
|
1740
|
-
this.headers = {}, this.extraHeaders = [], this.options = le.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()),
|
|
1741
|
-
body:
|
|
1742
|
-
contentType:
|
|
1739
|
+
constructor(e, t, i, s, r, n, a) {
|
|
1740
|
+
this.headers = {}, this.extraHeaders = [], this.options = le.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()), a && (this.body = {
|
|
1741
|
+
body: a.content,
|
|
1742
|
+
contentType: a.contentType
|
|
1743
1743
|
}), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag : $e(), this.from = le.makeNameAddrHeader(this.fromURI, this.options.fromDisplayName, this.fromTag), this.toURI = s.clone(), this.toTag = this.options.toTag, this.to = le.makeNameAddrHeader(this.toURI, this.options.toDisplayName, this.toTag), this.callId = this.options.callId ? this.options.callId : this.options.callIdPrefix + ce(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. */
|
|
@@ -1870,38 +1870,38 @@ class le {
|
|
|
1870
1870
|
`, e;
|
|
1871
1871
|
}
|
|
1872
1872
|
}
|
|
1873
|
-
function
|
|
1874
|
-
return
|
|
1873
|
+
function dt(o) {
|
|
1874
|
+
return o === "application/sdp" ? "session" : "render";
|
|
1875
1875
|
}
|
|
1876
|
-
function xe(
|
|
1877
|
-
const e = typeof
|
|
1878
|
-
return { contentDisposition:
|
|
1876
|
+
function xe(o) {
|
|
1877
|
+
const e = typeof o == "string" ? o : o.body, t = typeof o == "string" ? "application/sdp" : o.contentType;
|
|
1878
|
+
return { contentDisposition: dt(t), contentType: t, content: e };
|
|
1879
1879
|
}
|
|
1880
|
-
function
|
|
1881
|
-
return
|
|
1880
|
+
function lt(o) {
|
|
1881
|
+
return o && typeof o.content == "string" && typeof o.contentType == "string" && o.contentDisposition === void 0 ? !0 : typeof o.contentDisposition == "string";
|
|
1882
1882
|
}
|
|
1883
|
-
function ye(
|
|
1883
|
+
function ye(o) {
|
|
1884
1884
|
let e, t, i;
|
|
1885
|
-
if (
|
|
1886
|
-
const s =
|
|
1887
|
-
e = s ? s.type : void 0, t =
|
|
1885
|
+
if (o instanceof ge && o.body) {
|
|
1886
|
+
const s = o.parseHeader("Content-Disposition");
|
|
1887
|
+
e = s ? s.type : void 0, t = o.parseHeader("Content-Type"), i = o.body;
|
|
1888
1888
|
}
|
|
1889
|
-
if (
|
|
1890
|
-
const s =
|
|
1891
|
-
e = s ? s.type : void 0, t =
|
|
1889
|
+
if (o instanceof oe && o.body) {
|
|
1890
|
+
const s = o.parseHeader("Content-Disposition");
|
|
1891
|
+
e = s ? s.type : void 0, t = o.parseHeader("Content-Type"), i = o.body;
|
|
1892
1892
|
}
|
|
1893
|
-
if (
|
|
1894
|
-
if (e =
|
|
1893
|
+
if (o instanceof le && o.body)
|
|
1894
|
+
if (e = o.getHeader("Content-Disposition"), t = o.getHeader("Content-Type"), typeof o.body == "string") {
|
|
1895
1895
|
if (!t)
|
|
1896
1896
|
throw new Error("Header content type header does not equal body content type.");
|
|
1897
|
-
i =
|
|
1897
|
+
i = o.body;
|
|
1898
1898
|
} else {
|
|
1899
|
-
if (t && t !==
|
|
1899
|
+
if (t && t !== o.body.contentType)
|
|
1900
1900
|
throw new Error("Header content type header does not equal body content type.");
|
|
1901
|
-
t =
|
|
1901
|
+
t = o.body.contentType, i = o.body.body;
|
|
1902
1902
|
}
|
|
1903
|
-
if (
|
|
1904
|
-
if (t && !e && (e =
|
|
1903
|
+
if (lt(o) && (e = o.contentDisposition, t = o.contentType, i = o.content), !!i) {
|
|
1904
|
+
if (t && !e && (e = dt(t)), !e)
|
|
1905
1905
|
throw new Error("Content disposition undefined.");
|
|
1906
1906
|
if (!t)
|
|
1907
1907
|
throw new Error("Content type undefined.");
|
|
@@ -1913,16 +1913,16 @@ function ye(a) {
|
|
|
1913
1913
|
}
|
|
1914
1914
|
}
|
|
1915
1915
|
var V;
|
|
1916
|
-
(function(
|
|
1917
|
-
|
|
1916
|
+
(function(o) {
|
|
1917
|
+
o.Initial = "Initial", o.Early = "Early", o.AckWait = "AckWait", o.Confirmed = "Confirmed", o.Terminated = "Terminated";
|
|
1918
1918
|
})(V = V || (V = {}));
|
|
1919
1919
|
var b;
|
|
1920
|
-
(function(
|
|
1921
|
-
|
|
1920
|
+
(function(o) {
|
|
1921
|
+
o.Initial = "Initial", o.HaveLocalOffer = "HaveLocalOffer", o.HaveRemoteOffer = "HaveRemoteOffer", o.Stable = "Stable", o.Closed = "Closed";
|
|
1922
1922
|
})(b = b || (b = {}));
|
|
1923
|
-
const Q = 500,
|
|
1923
|
+
const Q = 500, Pt = 4e3, Xe = 5e3, q = {
|
|
1924
1924
|
T1: Q,
|
|
1925
|
-
T2:
|
|
1925
|
+
T2: Pt,
|
|
1926
1926
|
TIMER_B: 64 * Q,
|
|
1927
1927
|
TIMER_D: 0 * Q,
|
|
1928
1928
|
TIMER_F: 64 * Q,
|
|
@@ -1942,8 +1942,8 @@ class se extends he {
|
|
|
1942
1942
|
}
|
|
1943
1943
|
}
|
|
1944
1944
|
var v;
|
|
1945
|
-
(function(
|
|
1946
|
-
|
|
1945
|
+
(function(o) {
|
|
1946
|
+
o.ACK = "ACK", o.BYE = "BYE", o.CANCEL = "CANCEL", o.INFO = "INFO", o.INVITE = "INVITE", o.MESSAGE = "MESSAGE", o.NOTIFY = "NOTIFY", o.OPTIONS = "OPTIONS", o.REGISTER = "REGISTER", o.UPDATE = "UPDATE", o.SUBSCRIBE = "SUBSCRIBE", o.PUBLISH = "PUBLISH", o.REFER = "REFER", o.PRACK = "PRACK";
|
|
1947
1947
|
})(v = v || (v = {}));
|
|
1948
1948
|
const re = [
|
|
1949
1949
|
v.ACK,
|
|
@@ -1959,7 +1959,7 @@ const re = [
|
|
|
1959
1959
|
v.REGISTER,
|
|
1960
1960
|
v.SUBSCRIBE
|
|
1961
1961
|
];
|
|
1962
|
-
class
|
|
1962
|
+
class ht {
|
|
1963
1963
|
/** @internal */
|
|
1964
1964
|
constructor(e) {
|
|
1965
1965
|
this.incomingMessageRequest = e;
|
|
@@ -1995,7 +1995,7 @@ class Ve {
|
|
|
1995
1995
|
return this.incomingNotifyRequest.reject(e), Promise.resolve();
|
|
1996
1996
|
}
|
|
1997
1997
|
}
|
|
1998
|
-
class
|
|
1998
|
+
class Ht {
|
|
1999
1999
|
/** @internal */
|
|
2000
2000
|
constructor(e, t) {
|
|
2001
2001
|
this.incomingReferRequest = e, this.session = t;
|
|
@@ -2050,8 +2050,8 @@ class Pt {
|
|
|
2050
2050
|
}
|
|
2051
2051
|
}
|
|
2052
2052
|
var m;
|
|
2053
|
-
(function(
|
|
2054
|
-
|
|
2053
|
+
(function(o) {
|
|
2054
|
+
o.Initial = "Initial", o.Establishing = "Establishing", o.Established = "Established", o.Terminating = "Terminating", o.Terminated = "Terminated";
|
|
2055
2055
|
})(m = m || (m = {}));
|
|
2056
2056
|
class fe {
|
|
2057
2057
|
/**
|
|
@@ -2267,11 +2267,11 @@ class fe {
|
|
|
2267
2267
|
return;
|
|
2268
2268
|
}
|
|
2269
2269
|
if (e.withoutSdp) {
|
|
2270
|
-
const
|
|
2270
|
+
const a = {
|
|
2271
2271
|
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptionsReInvite,
|
|
2272
2272
|
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiersReInvite
|
|
2273
2273
|
};
|
|
2274
|
-
this.setOfferAndGetAnswer(n,
|
|
2274
|
+
this.setOfferAndGetAnswer(n, a).then((d) => {
|
|
2275
2275
|
r.ack({ body: d });
|
|
2276
2276
|
}).catch((d) => {
|
|
2277
2277
|
this.logger.error("Failed to handle offer in 2xx response to re-INVITE"), this.logger.error(d.message), this.state === m.Terminated ? r.ack() : (this.ackAndBye(r, 488, "Bad Media Description"), this.stateTransition(m.Terminated));
|
|
@@ -2279,11 +2279,11 @@ class fe {
|
|
|
2279
2279
|
this.pendingReinvite = !1, e.requestDelegate && e.requestDelegate.onAccept && e.requestDelegate.onAccept(r);
|
|
2280
2280
|
});
|
|
2281
2281
|
} else {
|
|
2282
|
-
const
|
|
2282
|
+
const a = {
|
|
2283
2283
|
sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptionsReInvite,
|
|
2284
2284
|
sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiersReInvite
|
|
2285
2285
|
};
|
|
2286
|
-
this.setAnswer(n,
|
|
2286
|
+
this.setAnswer(n, a).then(() => {
|
|
2287
2287
|
r.ack();
|
|
2288
2288
|
}).catch((d) => {
|
|
2289
2289
|
this.logger.error("Failed to handle answer in 2xx response to re-INVITE"), this.logger.error(d.message), this.state !== m.Terminated ? (this.ackAndBye(r, 488, "Bad Media Description"), this.stateTransition(m.Terminated)) : r.ack();
|
|
@@ -2303,8 +2303,8 @@ class fe {
|
|
|
2303
2303
|
if (this.logger.error("Failed to rollback offer on non-2xx response to re-INVITE"), this.logger.error(n.message), this.state !== m.Terminated) {
|
|
2304
2304
|
if (!this.dialog)
|
|
2305
2305
|
throw new Error("Dialog undefined.");
|
|
2306
|
-
const
|
|
2307
|
-
|
|
2306
|
+
const a = [];
|
|
2307
|
+
a.push("Reason: " + this.getReasonHeaderValue(500, "Internal Server Error")), this.dialog.bye(void 0, { extraHeaders: a }), this.stateTransition(m.Terminated);
|
|
2308
2308
|
}
|
|
2309
2309
|
}).then(() => {
|
|
2310
2310
|
e.requestDelegate && e.requestDelegate.onReject && e.requestDelegate.onReject(r);
|
|
@@ -2454,7 +2454,7 @@ class fe {
|
|
|
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 xt(e);
|
|
2458
2458
|
this.delegate.onAck(s);
|
|
2459
2459
|
}
|
|
2460
2460
|
switch (this.pendingReinviteAck = !1, t.signalingState) {
|
|
@@ -2497,7 +2497,7 @@ class fe {
|
|
|
2497
2497
|
return;
|
|
2498
2498
|
}
|
|
2499
2499
|
if (this.delegate && this.delegate.onBye) {
|
|
2500
|
-
const t = new
|
|
2500
|
+
const t = new _t(e);
|
|
2501
2501
|
this.delegate.onBye(t);
|
|
2502
2502
|
} else
|
|
2503
2503
|
e.accept();
|
|
@@ -2513,7 +2513,7 @@ class fe {
|
|
|
2513
2513
|
return;
|
|
2514
2514
|
}
|
|
2515
2515
|
if (this.delegate && this.delegate.onInfo) {
|
|
2516
|
-
const t = new
|
|
2516
|
+
const t = new At(e);
|
|
2517
2517
|
this.delegate.onInfo(t);
|
|
2518
2518
|
} else
|
|
2519
2519
|
e.accept();
|
|
@@ -2559,8 +2559,8 @@ class fe {
|
|
|
2559
2559
|
if (this.state !== m.Terminated) {
|
|
2560
2560
|
if (!this.dialog)
|
|
2561
2561
|
throw new Error("Dialog undefined.");
|
|
2562
|
-
const
|
|
2563
|
-
|
|
2562
|
+
const a = [];
|
|
2563
|
+
a.push("Reason: " + this.getReasonHeaderValue(500, "Internal Server Error")), this.dialog.bye(void 0, { extraHeaders: a }), this.stateTransition(m.Terminated);
|
|
2564
2564
|
}
|
|
2565
2565
|
this.delegate && this.delegate.onInvite && this.delegate.onInvite(e.message, n.message, 488);
|
|
2566
2566
|
});
|
|
@@ -2576,7 +2576,7 @@ class fe {
|
|
|
2576
2576
|
return;
|
|
2577
2577
|
}
|
|
2578
2578
|
if (this.delegate && this.delegate.onMessage) {
|
|
2579
|
-
const t = new
|
|
2579
|
+
const t = new ht(e);
|
|
2580
2580
|
this.delegate.onMessage(t);
|
|
2581
2581
|
} else
|
|
2582
2582
|
e.accept();
|
|
@@ -2626,7 +2626,7 @@ class fe {
|
|
|
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 Ht(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
|
}));
|
|
@@ -2719,19 +2719,19 @@ class fe {
|
|
|
2719
2719
|
return Promise.reject(new je());
|
|
2720
2720
|
} catch (n) {
|
|
2721
2721
|
this.logger.error("Session.setAnswer: SDH hasDescription threw...");
|
|
2722
|
-
const
|
|
2723
|
-
return this.logger.error(
|
|
2722
|
+
const a = n instanceof Error ? n : new Error(n);
|
|
2723
|
+
return this.logger.error(a.message), Promise.reject(a);
|
|
2724
2724
|
}
|
|
2725
2725
|
try {
|
|
2726
2726
|
return i.setDescription(e.content, s, r).catch((n) => {
|
|
2727
2727
|
this.logger.error("Session.setAnswer: SDH setDescription rejected...");
|
|
2728
|
-
const
|
|
2729
|
-
throw this.logger.error(
|
|
2728
|
+
const a = n instanceof Error ? n : new Error("Session.setAnswer unknown error.");
|
|
2729
|
+
throw this.logger.error(a.message), a;
|
|
2730
2730
|
});
|
|
2731
2731
|
} catch (n) {
|
|
2732
2732
|
this.logger.error("Session.setAnswer: SDH setDescription threw...");
|
|
2733
|
-
const
|
|
2734
|
-
return this.logger.error(
|
|
2733
|
+
const a = n instanceof Error ? n : new Error(n);
|
|
2734
|
+
return this.logger.error(a.message), Promise.reject(a);
|
|
2735
2735
|
}
|
|
2736
2736
|
}
|
|
2737
2737
|
/**
|
|
@@ -2745,19 +2745,19 @@ class fe {
|
|
|
2745
2745
|
return Promise.reject(new je());
|
|
2746
2746
|
} catch (n) {
|
|
2747
2747
|
this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");
|
|
2748
|
-
const
|
|
2749
|
-
return this.logger.error(
|
|
2748
|
+
const a = n instanceof Error ? n : new Error(n);
|
|
2749
|
+
return this.logger.error(a.message), Promise.reject(a);
|
|
2750
2750
|
}
|
|
2751
2751
|
try {
|
|
2752
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
|
-
const
|
|
2755
|
-
throw this.logger.error(
|
|
2754
|
+
const a = n instanceof Error ? n : new Error("Session.setOfferAndGetAnswer unknown error.");
|
|
2755
|
+
throw this.logger.error(a.message), a;
|
|
2756
2756
|
});
|
|
2757
2757
|
} catch (n) {
|
|
2758
2758
|
this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription threw...");
|
|
2759
|
-
const
|
|
2760
|
-
return this.logger.error(
|
|
2759
|
+
const a = n instanceof Error ? n : new Error(n);
|
|
2760
|
+
return this.logger.error(a.message), Promise.reject(a);
|
|
2761
2761
|
}
|
|
2762
2762
|
}
|
|
2763
2763
|
/**
|
|
@@ -2833,17 +2833,17 @@ class fe {
|
|
|
2833
2833
|
else {
|
|
2834
2834
|
if (!e.dialog)
|
|
2835
2835
|
throw new Error("Dialog undefined.");
|
|
2836
|
-
const i = e.remoteIdentity.friendlyName, s = e.dialog.remoteTarget.toString(), r = e.dialog.callId, n = e.dialog.remoteTag,
|
|
2836
|
+
const i = e.remoteIdentity.friendlyName, s = e.dialog.remoteTarget.toString(), r = e.dialog.callId, n = e.dialog.remoteTag, a = e.dialog.localTag, d = encodeURIComponent(`${r};to-tag=${n};from-tag=${a}`);
|
|
2837
2837
|
t = `"${i}" <${s}?Replaces=${d}>`;
|
|
2838
2838
|
}
|
|
2839
2839
|
return t;
|
|
2840
2840
|
}
|
|
2841
2841
|
}
|
|
2842
2842
|
var W;
|
|
2843
|
-
(function(
|
|
2844
|
-
|
|
2843
|
+
(function(o) {
|
|
2844
|
+
o.Required = "Required", o.Supported = "Supported", o.Unsupported = "Unsupported";
|
|
2845
2845
|
})(W = W || (W = {}));
|
|
2846
|
-
const
|
|
2846
|
+
const Mt = {
|
|
2847
2847
|
"100rel": !0,
|
|
2848
2848
|
199: !0,
|
|
2849
2849
|
answermode: !0,
|
|
@@ -2898,8 +2898,8 @@ class de extends fe {
|
|
|
2898
2898
|
}
|
|
2899
2899
|
const n = this.request.getHeader("P-Asserted-Identity");
|
|
2900
2900
|
n && (this._assertedIdentity = P.nameAddrHeaderParse(n)), this._contact = this.userAgent.contact.toString();
|
|
2901
|
-
const
|
|
2902
|
-
|
|
2901
|
+
const a = i.parseHeader("Content-Disposition");
|
|
2902
|
+
a && a.type === "render" && (this._renderbody = i.body, this._rendertype = i.getHeader("Content-Type")), this._id = i.callId + i.fromTag, this.userAgent._sessions[this._id] = this;
|
|
2903
2903
|
}
|
|
2904
2904
|
/**
|
|
2905
2905
|
* Destructor.
|
|
@@ -3092,7 +3092,7 @@ class de extends fe {
|
|
|
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 je ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof
|
|
3095
|
+
if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof je ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof Rt ? this.logger.error("A session description handler occurred while sending response") : e instanceof Me ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof se && 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) {
|
|
@@ -3168,33 +3168,33 @@ class de extends fe {
|
|
|
3168
3168
|
}, i = e.statusCode || 183, s = e.reasonPhrase, r = (e.extraHeaders || []).slice();
|
|
3169
3169
|
r.push("Require: 100rel"), r.push("RSeq: " + this.rseq++);
|
|
3170
3170
|
let n;
|
|
3171
|
-
return new Promise((
|
|
3171
|
+
return new Promise((a, d) => {
|
|
3172
3172
|
this.waitingForPrack = !0, this.generateResponseOfferAnswer(this.incomingInviteRequest, t).then((f) => (n = f, this.incomingInviteRequest.progress({ statusCode: i, reasonPhrase: s, extraHeaders: r, body: n }))).then((f) => {
|
|
3173
3173
|
this._dialog = f.session;
|
|
3174
3174
|
let h, w;
|
|
3175
3175
|
f.session.delegate = {
|
|
3176
3176
|
onPrack: (p) => {
|
|
3177
|
-
h = p, clearTimeout(
|
|
3177
|
+
h = p, clearTimeout(_), clearTimeout(ae), this.waitingForPrack && (this.waitingForPrack = !1, this.handlePrackOfferAnswer(h).then((A) => {
|
|
3178
3178
|
try {
|
|
3179
|
-
w = h.accept({ statusCode: 200, body: A }), this.prackArrived(),
|
|
3179
|
+
w = h.accept({ statusCode: 200, body: A }), this.prackArrived(), a({ prackRequest: h, prackResponse: w, progressResponse: f });
|
|
3180
3180
|
} catch (Pe) {
|
|
3181
3181
|
d(Pe);
|
|
3182
3182
|
}
|
|
3183
3183
|
}).catch((A) => d(A)));
|
|
3184
3184
|
}
|
|
3185
3185
|
};
|
|
3186
|
-
const
|
|
3187
|
-
this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(
|
|
3188
|
-
}, q.T1 * 64),
|
|
3186
|
+
const _ = setTimeout(() => {
|
|
3187
|
+
this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(ae), this.reject({ statusCode: 504 }).then(() => d(new Me())).catch((p) => d(p)));
|
|
3188
|
+
}, q.T1 * 64), I = () => {
|
|
3189
3189
|
try {
|
|
3190
3190
|
this.incomingInviteRequest.progress({ statusCode: i, reasonPhrase: s, extraHeaders: r, body: n });
|
|
3191
3191
|
} catch (p) {
|
|
3192
3192
|
this.waitingForPrack = !1, d(p);
|
|
3193
3193
|
return;
|
|
3194
3194
|
}
|
|
3195
|
-
|
|
3195
|
+
ae = setTimeout(I, E *= 2);
|
|
3196
3196
|
};
|
|
3197
|
-
let E = q.T1,
|
|
3197
|
+
let E = q.T1, ae = setTimeout(I, E);
|
|
3198
3198
|
}).catch((f) => {
|
|
3199
3199
|
this.waitingForPrack = !1, d(f);
|
|
3200
3200
|
});
|
|
@@ -3257,8 +3257,8 @@ class Ee extends fe {
|
|
|
3257
3257
|
outbound: r ? !e.contact.tempGruu : !e.contact.pubGruu
|
|
3258
3258
|
});
|
|
3259
3259
|
r && e.configuration.uri && (s.params.fromDisplayName = "Anonymous", s.params.fromUri = "sip:anonymous@anonymous.invalid");
|
|
3260
|
-
let
|
|
3261
|
-
if (s.params.fromUri && (
|
|
3260
|
+
let a = e.userAgentCore.configuration.aor;
|
|
3261
|
+
if (s.params.fromUri && (a = typeof s.params.fromUri == "string" ? P.URIParse(s.params.fromUri) : s.params.fromUri), !a)
|
|
3262
3262
|
throw new TypeError("Invalid from URI: " + s.params.fromUri);
|
|
3263
3263
|
let d = t;
|
|
3264
3264
|
if (s.params.toUri && (d = typeof s.params.toUri == "string" ? P.URIParse(s.params.toUri) : s.params.toUri), !d)
|
|
@@ -3268,7 +3268,7 @@ class Ee extends fe {
|
|
|
3268
3268
|
const h = (s.extraHeaders || []).slice();
|
|
3269
3269
|
r && e.configuration.uri && (h.push("P-Preferred-Identity: " + e.configuration.uri.toString()), h.push("Privacy: id")), h.push("Contact: " + n), h.push("Allow: " + ["ACK", "CANCEL", "INVITE", "MESSAGE", "BYE", "OPTIONS", "INFO", "NOTIFY", "REFER"].toString()), e.configuration.sipExtension100rel === W.Required && h.push("Require: 100rel"), e.configuration.sipExtensionReplaces === W.Required && h.push("Require: replaces"), s.extraHeaders = h;
|
|
3270
3270
|
const w = void 0;
|
|
3271
|
-
this.outgoingRequestMessage = e.userAgentCore.makeOutgoingRequestMessage(v.INVITE, t,
|
|
3271
|
+
this.outgoingRequestMessage = e.userAgentCore.makeOutgoingRequestMessage(v.INVITE, t, a, d, f, h, w), this._contact = n, this._referralInviterOptions = s, this._renderbody = i.renderbody, this._rendertype = i.rendertype, i.sessionDescriptionHandlerModifiers && (this.sessionDescriptionHandlerModifiers = i.sessionDescriptionHandlerModifiers), i.sessionDescriptionHandlerOptions && (this.sessionDescriptionHandlerOptions = i.sessionDescriptionHandlerOptions), i.sessionDescriptionHandlerModifiersReInvite && (this.sessionDescriptionHandlerModifiersReInvite = i.sessionDescriptionHandlerModifiersReInvite), i.sessionDescriptionHandlerOptionsReInvite && (this.sessionDescriptionHandlerOptionsReInvite = i.sessionDescriptionHandlerOptionsReInvite), this._id = this.outgoingRequestMessage.callId + this.fromTag, this.userAgent._sessions[this._id] = this;
|
|
3272
3272
|
}
|
|
3273
3273
|
/**
|
|
3274
3274
|
* Destructor.
|
|
@@ -3716,7 +3716,7 @@ class Ee extends fe {
|
|
|
3716
3716
|
}
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
|
-
class
|
|
3719
|
+
class qt {
|
|
3720
3720
|
/**
|
|
3721
3721
|
* Constructs a new instance of the `Messager` class.
|
|
3722
3722
|
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
@@ -3730,15 +3730,15 @@ class Mt {
|
|
|
3730
3730
|
let n = e.userAgentCore.configuration.aor;
|
|
3731
3731
|
if (r.params.fromUri && (n = typeof r.params.fromUri == "string" ? P.URIParse(r.params.fromUri) : r.params.fromUri), !n)
|
|
3732
3732
|
throw new TypeError("Invalid from URI: " + r.params.fromUri);
|
|
3733
|
-
let
|
|
3734
|
-
if (r.params.toUri && (
|
|
3733
|
+
let a = t;
|
|
3734
|
+
if (r.params.toUri && (a = typeof r.params.toUri == "string" ? P.URIParse(r.params.toUri) : r.params.toUri), !a)
|
|
3735
3735
|
throw new TypeError("Invalid to URI: " + r.params.toUri);
|
|
3736
3736
|
const d = r.params ? Object.assign({}, r.params) : {}, f = (r.extraHeaders || []).slice(), w = {
|
|
3737
3737
|
contentDisposition: "render",
|
|
3738
3738
|
contentType: s,
|
|
3739
3739
|
content: i
|
|
3740
3740
|
};
|
|
3741
|
-
this.request = e.userAgentCore.makeOutgoingRequestMessage(v.MESSAGE, t, n,
|
|
3741
|
+
this.request = e.userAgentCore.makeOutgoingRequestMessage(v.MESSAGE, t, n, a, d, f, w), this.userAgent = e;
|
|
3742
3742
|
}
|
|
3743
3743
|
/**
|
|
3744
3744
|
* Send the message.
|
|
@@ -3748,8 +3748,8 @@ class Mt {
|
|
|
3748
3748
|
}
|
|
3749
3749
|
}
|
|
3750
3750
|
var R;
|
|
3751
|
-
(function(
|
|
3752
|
-
|
|
3751
|
+
(function(o) {
|
|
3752
|
+
o.Initial = "Initial", o.Registered = "Registered", o.Unregistered = "Unregistered", o.Terminated = "Terminated";
|
|
3753
3753
|
})(R = R || (R = {}));
|
|
3754
3754
|
class J {
|
|
3755
3755
|
/**
|
|
@@ -3766,8 +3766,8 @@ class J {
|
|
|
3766
3766
|
throw new Error("Invalid instanceId.");
|
|
3767
3767
|
if (this.options.regId && this.options.regId < 0)
|
|
3768
3768
|
throw new Error("Invalid regId.");
|
|
3769
|
-
const s = this.options.registrar, r = this.options.params && this.options.params.fromUri || e.userAgentCore.configuration.aor, n = this.options.params && this.options.params.toUri || e.configuration.uri,
|
|
3770
|
-
if (this.request = e.userAgentCore.makeOutgoingRequestMessage(v.REGISTER, s, r, n,
|
|
3769
|
+
const s = this.options.registrar, r = this.options.params && this.options.params.fromUri || e.userAgentCore.configuration.aor, n = this.options.params && this.options.params.toUri || e.configuration.uri, a = this.options.params || {}, d = (t.extraHeaders || []).slice();
|
|
3770
|
+
if (this.request = e.userAgentCore.makeOutgoingRequestMessage(v.REGISTER, s, r, n, a, d, void 0), this.expires = this.options.expires || J.defaultExpires, this.expires < 0)
|
|
3771
3771
|
throw new Error("Invalid expires.");
|
|
3772
3772
|
if (this.refreshFrequency = this.options.refreshFrequency || J.defaultRefreshFrequency, this.refreshFrequency < 50 || this.refreshFrequency > 99)
|
|
3773
3773
|
throw new Error("Invalid refresh frequency. The value represents a percentage of the expiration time and should be between 50 and 99.");
|
|
@@ -3892,26 +3892,26 @@ class J {
|
|
|
3892
3892
|
this.logger.error("No Contact header in response to REGISTER, dropping response."), this.unregistered();
|
|
3893
3893
|
return;
|
|
3894
3894
|
}
|
|
3895
|
-
let
|
|
3895
|
+
let a;
|
|
3896
3896
|
for (; n--; ) {
|
|
3897
|
-
if (
|
|
3897
|
+
if (a = s.message.parseHeader("contact", n), !a)
|
|
3898
3898
|
throw new Error("Contact undefined");
|
|
3899
|
-
if (this.userAgent.contact.pubGruu && Ze(
|
|
3900
|
-
r = Number(
|
|
3899
|
+
if (this.userAgent.contact.pubGruu && Ze(a.uri, this.userAgent.contact.pubGruu)) {
|
|
3900
|
+
r = Number(a.getParam("expires"));
|
|
3901
3901
|
break;
|
|
3902
3902
|
}
|
|
3903
3903
|
if (this.userAgent.configuration.contactName === "") {
|
|
3904
|
-
if (
|
|
3905
|
-
r = Number(
|
|
3904
|
+
if (a.uri.user === this.userAgent.contact.uri.user) {
|
|
3905
|
+
r = Number(a.getParam("expires"));
|
|
3906
3906
|
break;
|
|
3907
3907
|
}
|
|
3908
|
-
} else if (Ze(
|
|
3909
|
-
r = Number(
|
|
3908
|
+
} else if (Ze(a.uri, this.userAgent.contact.uri)) {
|
|
3909
|
+
r = Number(a.getParam("expires"));
|
|
3910
3910
|
break;
|
|
3911
3911
|
}
|
|
3912
|
-
|
|
3912
|
+
a = void 0;
|
|
3913
3913
|
}
|
|
3914
|
-
if (
|
|
3914
|
+
if (a === void 0) {
|
|
3915
3915
|
this.logger.error("No Contact header pointing to us, dropping response"), this.unregistered(), this.waitingToggle(!1);
|
|
3916
3916
|
return;
|
|
3917
3917
|
}
|
|
@@ -3919,12 +3919,12 @@ class J {
|
|
|
3919
3919
|
this.logger.error("Contact pointing to us is missing expires parameter, dropping response"), this.unregistered(), this.waitingToggle(!1);
|
|
3920
3920
|
return;
|
|
3921
3921
|
}
|
|
3922
|
-
if (
|
|
3923
|
-
const d =
|
|
3922
|
+
if (a.hasParam("temp-gruu")) {
|
|
3923
|
+
const d = a.getParam("temp-gruu");
|
|
3924
3924
|
d && (this.userAgent.contact.tempGruu = P.URIParse(d.replace(/"/g, "")));
|
|
3925
3925
|
}
|
|
3926
|
-
if (
|
|
3927
|
-
const d =
|
|
3926
|
+
if (a.hasParam("pub-gruu")) {
|
|
3927
|
+
const d = a.getParam("pub-gruu");
|
|
3928
3928
|
d && (this.userAgent.contact.pubGruu = P.URIParse(d.replace(/"/g, "")));
|
|
3929
3929
|
}
|
|
3930
3930
|
this.registered(r), e.requestDelegate && e.requestDelegate.onAccept && e.requestDelegate.onAccept(s), this.waitingToggle(!1);
|
|
@@ -4087,16 +4087,16 @@ class J {
|
|
|
4087
4087
|
J.defaultExpires = 600;
|
|
4088
4088
|
J.defaultRefreshFrequency = 99;
|
|
4089
4089
|
var x;
|
|
4090
|
-
(function(
|
|
4091
|
-
|
|
4090
|
+
(function(o) {
|
|
4091
|
+
o.Initial = "Initial", o.NotifyWait = "NotifyWait", o.Pending = "Pending", o.Active = "Active", o.Terminated = "Terminated";
|
|
4092
4092
|
})(x = x || (x = {}));
|
|
4093
4093
|
var T;
|
|
4094
|
-
(function(
|
|
4095
|
-
|
|
4094
|
+
(function(o) {
|
|
4095
|
+
o.Connecting = "Connecting", o.Connected = "Connected", o.Disconnecting = "Disconnecting", o.Disconnected = "Disconnected";
|
|
4096
4096
|
})(T = T || (T = {}));
|
|
4097
4097
|
var k;
|
|
4098
|
-
(function(
|
|
4099
|
-
|
|
4098
|
+
(function(o) {
|
|
4099
|
+
o.Started = "Started", o.Stopped = "Stopped";
|
|
4100
4100
|
})(k = k || (k = {}));
|
|
4101
4101
|
class H {
|
|
4102
4102
|
constructor() {
|
|
@@ -4110,9 +4110,9 @@ class H {
|
|
|
4110
4110
|
}
|
|
4111
4111
|
static _hex(e) {
|
|
4112
4112
|
const t = H.hexChars, i = H.hexOut;
|
|
4113
|
-
let s, r, n,
|
|
4114
|
-
for (
|
|
4115
|
-
for (r =
|
|
4113
|
+
let s, r, n, a;
|
|
4114
|
+
for (a = 0; a < 4; a += 1)
|
|
4115
|
+
for (r = a * 8, s = e[a], n = 0; n < 8; n += 2)
|
|
4116
4116
|
i[r + 1 + n] = t.charAt(s & 15), s >>>= 4, i[r + 0 + n] = t.charAt(s & 15), s >>>= 4;
|
|
4117
4117
|
return i.join("");
|
|
4118
4118
|
}
|
|
@@ -4190,10 +4190,10 @@ class H {
|
|
|
4190
4190
|
if (this._dataLength += t, i[t] = 128, i[t + 1] = i[t + 2] = i[t + 3] = 0, s.set(H.buffer32Identity.subarray(r), r), t > 55 && (H._md5cycle(this._state, s), s.set(H.buffer32Identity)), n = this._dataLength * 8, n <= 4294967295)
|
|
4191
4191
|
s[14] = n;
|
|
4192
4192
|
else {
|
|
4193
|
-
const
|
|
4194
|
-
if (
|
|
4193
|
+
const a = n.toString(16).match(/(.*?)(.{0,8})$/);
|
|
4194
|
+
if (a === null)
|
|
4195
4195
|
return;
|
|
4196
|
-
const d = parseInt(
|
|
4196
|
+
const d = parseInt(a[2], 16), f = parseInt(a[1], 16) || 0;
|
|
4197
4197
|
s[14] = d, s[15] = f;
|
|
4198
4198
|
}
|
|
4199
4199
|
return H._md5cycle(this._state, s), e ? this._state : H._hex(this._state);
|
|
@@ -4205,10 +4205,10 @@ H.hexChars = "0123456789abcdef";
|
|
|
4205
4205
|
H.hexOut = [];
|
|
4206
4206
|
H.onePassHasher = new H();
|
|
4207
4207
|
H.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592" && console.error("Md5 self test failed.");
|
|
4208
|
-
function te(
|
|
4209
|
-
return H.hashStr(
|
|
4208
|
+
function te(o) {
|
|
4209
|
+
return H.hashStr(o);
|
|
4210
4210
|
}
|
|
4211
|
-
class
|
|
4211
|
+
class Ot {
|
|
4212
4212
|
/**
|
|
4213
4213
|
* Constructor.
|
|
4214
4214
|
* @param loggerFactory - LoggerFactory.
|
|
@@ -4272,8 +4272,8 @@ class qt {
|
|
|
4272
4272
|
}
|
|
4273
4273
|
}
|
|
4274
4274
|
var M;
|
|
4275
|
-
(function(
|
|
4276
|
-
|
|
4275
|
+
(function(o) {
|
|
4276
|
+
o[o.error = 0] = "error", o[o.warn = 1] = "warn", o[o.log = 2] = "log", o[o.debug = 3] = "debug";
|
|
4277
4277
|
})(M = M || (M = {}));
|
|
4278
4278
|
class Qe {
|
|
4279
4279
|
constructor(e, t, i) {
|
|
@@ -4301,7 +4301,7 @@ class Qe {
|
|
|
4301
4301
|
this.logger.level = e;
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
4304
|
-
class
|
|
4304
|
+
class Ft {
|
|
4305
4305
|
constructor() {
|
|
4306
4306
|
this.builtinEnabled = !0, this._level = M.log, this.loggers = {}, this.logger = this.getLogger("sip:loggerfactory");
|
|
4307
4307
|
}
|
|
@@ -4355,22 +4355,22 @@ class Ot {
|
|
|
4355
4355
|
}
|
|
4356
4356
|
}
|
|
4357
4357
|
var Re;
|
|
4358
|
-
(function(
|
|
4358
|
+
(function(o) {
|
|
4359
4359
|
function e(s, r) {
|
|
4360
|
-
let n = r,
|
|
4360
|
+
let n = r, a = 0, d = 0;
|
|
4361
4361
|
if (s.substring(n, n + 2).match(/(^\r\n)/))
|
|
4362
4362
|
return -2;
|
|
4363
|
-
for (;
|
|
4363
|
+
for (; a === 0; ) {
|
|
4364
4364
|
if (d = s.indexOf(`\r
|
|
4365
4365
|
`, n), d === -1)
|
|
4366
4366
|
return d;
|
|
4367
|
-
!s.substring(d + 2, d + 4).match(/(^\r\n)/) && s.charAt(d + 2).match(/(^\s+)/) ? n = d + 2 :
|
|
4367
|
+
!s.substring(d + 2, d + 4).match(/(^\r\n)/) && s.charAt(d + 2).match(/(^\s+)/) ? n = d + 2 : a = d;
|
|
4368
4368
|
}
|
|
4369
|
-
return
|
|
4369
|
+
return a;
|
|
4370
4370
|
}
|
|
4371
|
-
|
|
4372
|
-
function t(s, r, n,
|
|
4373
|
-
const d = r.indexOf(":", n), f = r.substring(n, d).trim(), h = r.substring(d + 1,
|
|
4371
|
+
o.getHeader = e;
|
|
4372
|
+
function t(s, r, n, a) {
|
|
4373
|
+
const d = r.indexOf(":", n), f = r.substring(n, d).trim(), h = r.substring(d + 1, a).trim();
|
|
4374
4374
|
let w;
|
|
4375
4375
|
switch (f.toLowerCase()) {
|
|
4376
4376
|
case "via":
|
|
@@ -4425,7 +4425,7 @@ var Re;
|
|
|
4425
4425
|
s.setHeader("content-type", h), w = s.parseHeader("content-type");
|
|
4426
4426
|
break;
|
|
4427
4427
|
case "cseq":
|
|
4428
|
-
s.setHeader("cseq", h), w = s.parseHeader("cseq"), w && (s.cseq = w.value), s instanceof
|
|
4428
|
+
s.setHeader("cseq", h), w = s.parseHeader("cseq"), w && (s.cseq = w.value), s instanceof oe && (s.method = w.method);
|
|
4429
4429
|
break;
|
|
4430
4430
|
case "max-forwards":
|
|
4431
4431
|
s.setHeader("max-forwards", h), w = s.parseHeader("max-forwards");
|
|
@@ -4447,57 +4447,57 @@ var Re;
|
|
|
4447
4447
|
error: "error parsing header '" + f + "'"
|
|
4448
4448
|
} : !0;
|
|
4449
4449
|
}
|
|
4450
|
-
|
|
4450
|
+
o.parseHeader = t;
|
|
4451
4451
|
function i(s, r) {
|
|
4452
|
-
let n = 0,
|
|
4452
|
+
let n = 0, a = s.indexOf(`\r
|
|
4453
4453
|
`);
|
|
4454
|
-
if (
|
|
4454
|
+
if (a === -1) {
|
|
4455
4455
|
r.warn("no CRLF found, not a SIP message, discarded");
|
|
4456
4456
|
return;
|
|
4457
4457
|
}
|
|
4458
|
-
const d = s.substring(0,
|
|
4458
|
+
const d = s.substring(0, a), f = P.parse(d, "Request_Response");
|
|
4459
4459
|
let h;
|
|
4460
4460
|
if (f === -1) {
|
|
4461
4461
|
r.warn('error parsing first line of SIP message: "' + d + '"');
|
|
4462
4462
|
return;
|
|
4463
|
-
} else f.status_code ? (h = new
|
|
4464
|
-
h.data = s, n =
|
|
4463
|
+
} else f.status_code ? (h = new oe(), h.statusCode = f.status_code, h.reasonPhrase = f.reason_phrase) : (h = new ge(), h.method = f.method, h.ruri = f.uri);
|
|
4464
|
+
h.data = s, n = a + 2;
|
|
4465
4465
|
let w;
|
|
4466
4466
|
for (; ; ) {
|
|
4467
|
-
if (
|
|
4467
|
+
if (a = e(s, n), a === -2) {
|
|
4468
4468
|
w = n + 2;
|
|
4469
4469
|
break;
|
|
4470
|
-
} else if (
|
|
4470
|
+
} else if (a === -1) {
|
|
4471
4471
|
r.error("malformed message");
|
|
4472
4472
|
return;
|
|
4473
4473
|
}
|
|
4474
|
-
const S = t(h, s, n,
|
|
4474
|
+
const S = t(h, s, n, a);
|
|
4475
4475
|
if (S && S !== !0) {
|
|
4476
4476
|
r.error(S.error);
|
|
4477
4477
|
return;
|
|
4478
4478
|
}
|
|
4479
|
-
n =
|
|
4479
|
+
n = a + 2;
|
|
4480
4480
|
}
|
|
4481
4481
|
return h.hasHeader("content-length") ? h.body = s.substr(w, Number(h.getHeader("content-length"))) : h.body = s.substring(w), h;
|
|
4482
4482
|
}
|
|
4483
|
-
|
|
4483
|
+
o.parseMessage = i;
|
|
4484
4484
|
})(Re = Re || (Re = {}));
|
|
4485
|
-
function
|
|
4485
|
+
function ut(o, e) {
|
|
4486
4486
|
if (e.statusCode < 100 || e.statusCode > 699)
|
|
4487
4487
|
throw new TypeError("Invalid statusCode: " + e.statusCode);
|
|
4488
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;
|
|
4492
|
-
const r = "From: " +
|
|
4493
|
-
`, n = "Call-ID: " +
|
|
4494
|
-
`,
|
|
4495
|
-
`, d =
|
|
4492
|
+
const r = "From: " + o.getHeader("From") + `\r
|
|
4493
|
+
`, n = "Call-ID: " + o.callId + `\r
|
|
4494
|
+
`, a = "CSeq: " + o.cseq + " " + o.method + `\r
|
|
4495
|
+
`, d = o.getHeaders("via").reduce((_, I) => _ + "Via: " + I + `\r
|
|
4496
4496
|
`, "");
|
|
4497
|
-
let f = "To: " +
|
|
4498
|
-
if (e.statusCode > 100 && !
|
|
4499
|
-
let
|
|
4500
|
-
|
|
4497
|
+
let f = "To: " + o.getHeader("to");
|
|
4498
|
+
if (e.statusCode > 100 && !o.parseHeader("to").hasParam("tag")) {
|
|
4499
|
+
let _ = e.toTag;
|
|
4500
|
+
_ || (_ = $e()), f += ";tag=" + _;
|
|
4501
4501
|
}
|
|
4502
4502
|
f += `\r
|
|
4503
4503
|
`;
|
|
@@ -4508,8 +4508,8 @@ function ht(a, e) {
|
|
|
4508
4508
|
e.userAgent && (w = "User-Agent: " + e.userAgent + `\r
|
|
4509
4509
|
`);
|
|
4510
4510
|
let S = "";
|
|
4511
|
-
return e.extraHeaders && (S = e.extraHeaders.reduce((
|
|
4512
|
-
`, "")), s += d, s += r, s += f, s +=
|
|
4511
|
+
return e.extraHeaders && (S = e.extraHeaders.reduce((_, I) => _ + I.trim() + `\r
|
|
4512
|
+
`, "")), s += d, s += r, s += f, s += a, s += n, s += h, s += w, s += S, e.body ? (s += "Content-Type: " + e.body.contentType + `\r
|
|
4513
4513
|
`, s += "Content-Length: " + Se(e.body.content) + `\r
|
|
4514
4514
|
\r
|
|
4515
4515
|
`, s += e.body.content) : s += `Content-Length: 0\r
|
|
@@ -4521,7 +4521,7 @@ class Oe extends he {
|
|
|
4521
4521
|
super(e || "Unspecified transport error.");
|
|
4522
4522
|
}
|
|
4523
4523
|
}
|
|
4524
|
-
class
|
|
4524
|
+
class gt {
|
|
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
|
}
|
|
@@ -4605,7 +4605,7 @@ class ut {
|
|
|
4605
4605
|
return "UnknownType";
|
|
4606
4606
|
}
|
|
4607
4607
|
}
|
|
4608
|
-
class
|
|
4608
|
+
class ft extends gt {
|
|
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
|
}
|
|
@@ -4615,10 +4615,10 @@ class gt extends ut {
|
|
|
4615
4615
|
}
|
|
4616
4616
|
}
|
|
4617
4617
|
var g;
|
|
4618
|
-
(function(
|
|
4619
|
-
|
|
4618
|
+
(function(o) {
|
|
4619
|
+
o.Accepted = "Accepted", o.Calling = "Calling", o.Completed = "Completed", o.Confirmed = "Confirmed", o.Proceeding = "Proceeding", o.Terminated = "Terminated", o.Trying = "Trying";
|
|
4620
4620
|
})(g = g || (g = {}));
|
|
4621
|
-
class U extends
|
|
4621
|
+
class U extends ft {
|
|
4622
4622
|
/**
|
|
4623
4623
|
* Constructor.
|
|
4624
4624
|
* Upon construction, a "100 Trying" reply will be immediately sent.
|
|
@@ -4848,7 +4848,7 @@ class U extends gt {
|
|
|
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 De extends
|
|
4851
|
+
class De extends gt {
|
|
4852
4852
|
constructor(e, t, i, s, r) {
|
|
4853
4853
|
super(t, i, De.makeId(e), s, r), this._request = e, this.user = i, e.setViaHeader(this.id, t.protocol);
|
|
4854
4854
|
}
|
|
@@ -5033,7 +5033,7 @@ class pe {
|
|
|
5033
5033
|
throw new Error("Contact undefined.");
|
|
5034
5034
|
if (!(r instanceof N))
|
|
5035
5035
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
5036
|
-
const n = r.uri,
|
|
5036
|
+
const n = r.uri, a = e.cseq, d = void 0, f = e.callId, h = e.fromTag, w = t.toTag;
|
|
5037
5037
|
if (!f)
|
|
5038
5038
|
throw new Error("Call id undefined.");
|
|
5039
5039
|
if (!h)
|
|
@@ -5044,20 +5044,20 @@ class pe {
|
|
|
5044
5044
|
throw new Error("From undefined.");
|
|
5045
5045
|
if (!e.to)
|
|
5046
5046
|
throw new Error("To undefined.");
|
|
5047
|
-
const S = e.from.uri,
|
|
5047
|
+
const S = e.from.uri, _ = e.to.uri;
|
|
5048
5048
|
if (!t.statusCode)
|
|
5049
5049
|
throw new Error("Incoming response status code undefined.");
|
|
5050
|
-
const
|
|
5050
|
+
const I = t.statusCode < 200;
|
|
5051
5051
|
return {
|
|
5052
5052
|
id: f + h + w,
|
|
5053
|
-
early:
|
|
5053
|
+
early: I,
|
|
5054
5054
|
callId: f,
|
|
5055
5055
|
localTag: h,
|
|
5056
5056
|
remoteTag: w,
|
|
5057
|
-
localSequenceNumber:
|
|
5057
|
+
localSequenceNumber: a,
|
|
5058
5058
|
remoteSequenceNumber: d,
|
|
5059
5059
|
localURI: S,
|
|
5060
|
-
remoteURI:
|
|
5060
|
+
remoteURI: _,
|
|
5061
5061
|
remoteTarget: n,
|
|
5062
5062
|
routeSet: s,
|
|
5063
5063
|
secure: !1
|
|
@@ -5076,7 +5076,7 @@ class pe {
|
|
|
5076
5076
|
throw new Error("Contact undefined.");
|
|
5077
5077
|
if (!(n instanceof N))
|
|
5078
5078
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
5079
|
-
const
|
|
5079
|
+
const a = n.uri, d = e.cseq, f = void 0, h = e.callId, w = t, S = e.fromTag, _ = e.from.uri, I = e.to.uri;
|
|
5080
5080
|
return {
|
|
5081
5081
|
id: h + w + S,
|
|
5082
5082
|
early: i,
|
|
@@ -5085,9 +5085,9 @@ class pe {
|
|
|
5085
5085
|
remoteTag: S,
|
|
5086
5086
|
localSequenceNumber: f,
|
|
5087
5087
|
remoteSequenceNumber: d,
|
|
5088
|
-
localURI:
|
|
5089
|
-
remoteURI:
|
|
5090
|
-
remoteTarget:
|
|
5088
|
+
localURI: I,
|
|
5089
|
+
remoteURI: _,
|
|
5090
|
+
remoteTarget: a,
|
|
5091
5091
|
routeSet: r,
|
|
5092
5092
|
secure: !1
|
|
5093
5093
|
};
|
|
@@ -5230,12 +5230,12 @@ class pe {
|
|
|
5230
5230
|
* @param method - Outgoing request method.
|
|
5231
5231
|
*/
|
|
5232
5232
|
createOutgoingRequestMessage(e, t) {
|
|
5233
|
-
const i = this.remoteURI, s = this.remoteTag, r = this.localURI, n = this.localTag,
|
|
5233
|
+
const i = this.remoteURI, s = this.remoteTag, r = this.localURI, n = this.localTag, a = this.callId;
|
|
5234
5234
|
let d;
|
|
5235
5235
|
t && t.cseq ? d = t.cseq : this.dialogState.localSequenceNumber ? d = this.dialogState.localSequenceNumber += 1 : d = this.dialogState.localSequenceNumber = 1;
|
|
5236
5236
|
const f = this.remoteTarget, h = this.routeSet, w = t && t.extraHeaders, S = t && t.body;
|
|
5237
5237
|
return this.userAgentCore.makeOutgoingRequestMessage(e, f, r, i, {
|
|
5238
|
-
callId:
|
|
5238
|
+
callId: a,
|
|
5239
5239
|
cseq: d,
|
|
5240
5240
|
fromTag: n,
|
|
5241
5241
|
toTag: s,
|
|
@@ -5403,17 +5403,17 @@ class ne extends De {
|
|
|
5403
5403
|
return "INVITE client transaction";
|
|
5404
5404
|
}
|
|
5405
5405
|
ack(e) {
|
|
5406
|
-
const t = this.request.ruri, i = this.request.callId, s = this.request.cseq, r = this.request.getHeader("from"), n = e.getHeader("to"),
|
|
5406
|
+
const t = this.request.ruri, i = this.request.callId, s = this.request.cseq, r = this.request.getHeader("from"), n = e.getHeader("to"), a = this.request.getHeader("via"), d = this.request.getHeader("route");
|
|
5407
5407
|
if (!r)
|
|
5408
5408
|
throw new Error("From undefined.");
|
|
5409
5409
|
if (!n)
|
|
5410
5410
|
throw new Error("To undefined.");
|
|
5411
|
-
if (!
|
|
5411
|
+
if (!a)
|
|
5412
5412
|
throw new Error("Via undefined.");
|
|
5413
5413
|
let f = `ACK ${t} SIP/2.0\r
|
|
5414
5414
|
`;
|
|
5415
5415
|
d && (f += `Route: ${d}\r
|
|
5416
|
-
`), f += `Via: ${
|
|
5416
|
+
`), f += `Via: ${a}\r
|
|
5417
5417
|
`, f += `To: ${n}\r
|
|
5418
5418
|
`, f += `From: ${r}\r
|
|
5419
5419
|
`, f += `Call-ID: ${i}\r
|
|
@@ -5587,7 +5587,7 @@ class O {
|
|
|
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 oe();
|
|
5591
5591
|
e.statusCode = 408, e.reasonPhrase = "Request Timeout", this.receiveResponse(e);
|
|
5592
5592
|
}
|
|
5593
5593
|
/**
|
|
@@ -5605,7 +5605,7 @@ class O {
|
|
|
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 oe();
|
|
5609
5609
|
t.statusCode = 503, t.reasonPhrase = "Service Unavailable", this.receiveResponse(t);
|
|
5610
5610
|
}
|
|
5611
5611
|
/**
|
|
@@ -5653,13 +5653,13 @@ class O {
|
|
|
5653
5653
|
this.core.userAgentClients.set(i, this);
|
|
5654
5654
|
}
|
|
5655
5655
|
}
|
|
5656
|
-
class
|
|
5656
|
+
class Nt extends O {
|
|
5657
5657
|
constructor(e, t, i) {
|
|
5658
5658
|
const s = e.createOutgoingRequestMessage(v.BYE, i);
|
|
5659
5659
|
super(B, e.userAgentCore, s, t), e.dispose();
|
|
5660
5660
|
}
|
|
5661
5661
|
}
|
|
5662
|
-
class L extends
|
|
5662
|
+
class L extends ft {
|
|
5663
5663
|
/**
|
|
5664
5664
|
* Constructor.
|
|
5665
5665
|
* After construction the transaction will be in the "trying": state and the transaction
|
|
@@ -5924,7 +5924,7 @@ class X {
|
|
|
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 = ut(this.message, e);
|
|
5928
5928
|
return this.transaction.receiveResponse(e.statusCode, t.message), t;
|
|
5929
5929
|
}
|
|
5930
5930
|
init() {
|
|
@@ -5942,59 +5942,59 @@ class X {
|
|
|
5942
5942
|
this.core.userAgentServers.set(t.id, this);
|
|
5943
5943
|
}
|
|
5944
5944
|
}
|
|
5945
|
-
class
|
|
5945
|
+
class Ut extends X {
|
|
5946
5946
|
constructor(e, t, i) {
|
|
5947
5947
|
super(L, e.userAgentCore, t, i);
|
|
5948
5948
|
}
|
|
5949
5949
|
}
|
|
5950
|
-
class
|
|
5950
|
+
class Lt extends O {
|
|
5951
5951
|
constructor(e, t, i) {
|
|
5952
5952
|
const s = e.createOutgoingRequestMessage(v.INFO, i);
|
|
5953
5953
|
super(B, e.userAgentCore, s, t);
|
|
5954
5954
|
}
|
|
5955
5955
|
}
|
|
5956
|
-
class
|
|
5956
|
+
class Bt extends X {
|
|
5957
5957
|
constructor(e, t, i) {
|
|
5958
5958
|
super(L, e.userAgentCore, t, i);
|
|
5959
5959
|
}
|
|
5960
5960
|
}
|
|
5961
|
-
class
|
|
5961
|
+
class pt extends O {
|
|
5962
5962
|
constructor(e, t, i) {
|
|
5963
5963
|
super(B, e, t, i);
|
|
5964
5964
|
}
|
|
5965
5965
|
}
|
|
5966
|
-
class
|
|
5966
|
+
class mt extends X {
|
|
5967
5967
|
constructor(e, t, i) {
|
|
5968
5968
|
super(L, e, t, i);
|
|
5969
5969
|
}
|
|
5970
5970
|
}
|
|
5971
|
-
class
|
|
5971
|
+
class jt extends O {
|
|
5972
5972
|
constructor(e, t, i) {
|
|
5973
5973
|
const s = e.createOutgoingRequestMessage(v.NOTIFY, i);
|
|
5974
5974
|
super(B, e.userAgentCore, s, t);
|
|
5975
5975
|
}
|
|
5976
5976
|
}
|
|
5977
|
-
function
|
|
5978
|
-
return
|
|
5977
|
+
function Vt(o) {
|
|
5978
|
+
return o.userAgentCore !== void 0;
|
|
5979
5979
|
}
|
|
5980
|
-
class
|
|
5980
|
+
class _e extends X {
|
|
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 = Vt(e) ? e.userAgentCore : e;
|
|
5988
5988
|
super(L, s, t, i);
|
|
5989
5989
|
}
|
|
5990
5990
|
}
|
|
5991
|
-
class
|
|
5991
|
+
class Gt extends O {
|
|
5992
5992
|
constructor(e, t, i) {
|
|
5993
5993
|
const s = e.createOutgoingRequestMessage(v.PRACK, i);
|
|
5994
5994
|
super(B, e.userAgentCore, s, t), e.signalingStateTransition(s);
|
|
5995
5995
|
}
|
|
5996
5996
|
}
|
|
5997
|
-
class
|
|
5997
|
+
class Wt extends X {
|
|
5998
5998
|
constructor(e, t, i) {
|
|
5999
5999
|
super(L, e.userAgentCore, t, i), e.signalingStateTransition(t), this.dialog = e;
|
|
6000
6000
|
}
|
|
@@ -6006,7 +6006,7 @@ class Gt extends X {
|
|
|
6006
6006
|
return e.body && this.dialog.signalingStateTransition(e.body), super.accept(e);
|
|
6007
6007
|
}
|
|
6008
6008
|
}
|
|
6009
|
-
class
|
|
6009
|
+
class Kt extends O {
|
|
6010
6010
|
constructor(e, t, i) {
|
|
6011
6011
|
const s = e.createOutgoingRequestMessage(v.INVITE, i);
|
|
6012
6012
|
super(ne, e.userAgentCore, s, t), this.delegate = t, e.signalingStateTransition(s), e.reinviteUserAgentClient = this, this.dialog = e;
|
|
@@ -6049,7 +6049,7 @@ class Wt extends O {
|
|
|
6049
6049
|
}
|
|
6050
6050
|
}
|
|
6051
6051
|
}
|
|
6052
|
-
class
|
|
6052
|
+
class zt extends X {
|
|
6053
6053
|
constructor(e, t, i) {
|
|
6054
6054
|
super(U, e.userAgentCore, t, i), e.reinviteUserAgentServer = this, this.dialog = e;
|
|
6055
6055
|
}
|
|
@@ -6091,27 +6091,27 @@ class Kt extends X {
|
|
|
6091
6091
|
return this.dialog.signalingStateRollback(), this.dialog.reinviteUserAgentServer = void 0, super.reject(e);
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
|
-
class
|
|
6094
|
+
class Yt extends O {
|
|
6095
6095
|
constructor(e, t, i) {
|
|
6096
6096
|
const s = e.createOutgoingRequestMessage(v.REFER, i);
|
|
6097
6097
|
super(B, e.userAgentCore, s, t);
|
|
6098
6098
|
}
|
|
6099
6099
|
}
|
|
6100
|
-
function
|
|
6101
|
-
return
|
|
6100
|
+
function Jt(o) {
|
|
6101
|
+
return o.userAgentCore !== void 0;
|
|
6102
6102
|
}
|
|
6103
|
-
class
|
|
6103
|
+
class wt extends X {
|
|
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 = Jt(e) ? e.userAgentCore : e;
|
|
6111
6111
|
super(L, s, t, i);
|
|
6112
6112
|
}
|
|
6113
6113
|
}
|
|
6114
|
-
class
|
|
6114
|
+
class Ie extends pe {
|
|
6115
6115
|
constructor(e, t, i, s) {
|
|
6116
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
|
}
|
|
@@ -6220,7 +6220,7 @@ class _e extends pe {
|
|
|
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 Nt(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 _e extends pe {
|
|
|
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 Lt(this, e, t);
|
|
6239
6239
|
}
|
|
6240
6240
|
/**
|
|
6241
6241
|
* Modifying an Existing Session
|
|
@@ -6265,7 +6265,7 @@ class _e extends pe {
|
|
|
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 Kt(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 _e extends pe {
|
|
|
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 pt(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 _e extends pe {
|
|
|
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 jt(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 _e extends pe {
|
|
|
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 Gt(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 _e extends pe {
|
|
|
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 Yt(this, e, t);
|
|
6317
6317
|
}
|
|
6318
6318
|
/**
|
|
6319
6319
|
* Requests sent within a dialog, as any other requests, are atomic. If
|
|
@@ -6391,13 +6391,13 @@ class _e extends pe {
|
|
|
6391
6391
|
switch (e.method) {
|
|
6392
6392
|
case v.BYE:
|
|
6393
6393
|
{
|
|
6394
|
-
const t = new
|
|
6394
|
+
const t = new Ut(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 Bt(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 _e extends pe {
|
|
|
6406
6406
|
break;
|
|
6407
6407
|
case v.INVITE:
|
|
6408
6408
|
{
|
|
6409
|
-
const t = new
|
|
6409
|
+
const t = new zt(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 mt(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 _e(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 Wt(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 wt(this, e);
|
|
6434
6434
|
this.delegate && this.delegate.onRefer ? this.delegate.onRefer(t) : t.reject();
|
|
6435
6435
|
}
|
|
6436
6436
|
break;
|
|
@@ -6487,7 +6487,7 @@ class _e extends pe {
|
|
|
6487
6487
|
default:
|
|
6488
6488
|
throw new Error("Unexpected signaling state.");
|
|
6489
6489
|
}
|
|
6490
|
-
if (e instanceof
|
|
6490
|
+
if (e instanceof oe)
|
|
6491
6491
|
switch (this._signalingState) {
|
|
6492
6492
|
case b.Initial:
|
|
6493
6493
|
case b.Stable:
|
|
@@ -6519,7 +6519,7 @@ class _e extends pe {
|
|
|
6519
6519
|
default:
|
|
6520
6520
|
throw new Error("Unexpected signaling state.");
|
|
6521
6521
|
}
|
|
6522
|
-
if (
|
|
6522
|
+
if (lt(e))
|
|
6523
6523
|
switch (this._signalingState) {
|
|
6524
6524
|
case b.Initial:
|
|
6525
6525
|
case b.Stable:
|
|
@@ -6575,7 +6575,7 @@ class _e extends pe {
|
|
|
6575
6575
|
}
|
|
6576
6576
|
}
|
|
6577
6577
|
}
|
|
6578
|
-
class
|
|
6578
|
+
class Zt extends O {
|
|
6579
6579
|
constructor(e, t, i) {
|
|
6580
6580
|
super(ne, e, t, i), this.confirmedDialogAcks = /* @__PURE__ */ new Map(), this.confirmedDialogs = /* @__PURE__ */ new Map(), this.earlyDialogs = /* @__PURE__ */ new Map(), this.delegate = i;
|
|
6581
6581
|
}
|
|
@@ -6620,10 +6620,10 @@ class Jt extends O {
|
|
|
6620
6620
|
const s = pe.initialDialogStateForUserAgentClient(this.message, e);
|
|
6621
6621
|
let r = this.earlyDialogs.get(s.id);
|
|
6622
6622
|
if (!r) {
|
|
6623
|
-
const
|
|
6624
|
-
if (!(
|
|
6623
|
+
const a = this.transaction;
|
|
6624
|
+
if (!(a instanceof ne))
|
|
6625
6625
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6626
|
-
r = new
|
|
6626
|
+
r = new Ie(a, 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.");
|
|
@@ -6634,7 +6634,7 @@ class Jt extends O {
|
|
|
6634
6634
|
this.delegate && this.delegate.onProgress && this.delegate.onProgress({
|
|
6635
6635
|
message: e,
|
|
6636
6636
|
session: n,
|
|
6637
|
-
prack: (
|
|
6637
|
+
prack: (a) => n.prack(void 0, a)
|
|
6638
6638
|
});
|
|
6639
6639
|
}
|
|
6640
6640
|
return;
|
|
@@ -6651,22 +6651,22 @@ class Jt extends O {
|
|
|
6651
6651
|
const s = pe.initialDialogStateForUserAgentClient(this.message, e);
|
|
6652
6652
|
let r = this.confirmedDialogs.get(s.id);
|
|
6653
6653
|
if (r) {
|
|
6654
|
-
const
|
|
6655
|
-
if (
|
|
6654
|
+
const a = this.confirmedDialogAcks.get(s.id);
|
|
6655
|
+
if (a) {
|
|
6656
6656
|
const d = this.transaction;
|
|
6657
6657
|
if (!(d instanceof ne))
|
|
6658
6658
|
throw new Error("Client transaction not instance of InviteClientTransaction.");
|
|
6659
|
-
d.ackResponse(
|
|
6659
|
+
d.ackResponse(a.message);
|
|
6660
6660
|
}
|
|
6661
6661
|
return;
|
|
6662
6662
|
}
|
|
6663
6663
|
if (r = this.earlyDialogs.get(s.id), r)
|
|
6664
6664
|
r.confirm(), r.recomputeRouteSet(e), this.earlyDialogs.delete(r.id), this.confirmedDialogs.set(r.id, r);
|
|
6665
6665
|
else {
|
|
6666
|
-
const
|
|
6667
|
-
if (!(
|
|
6666
|
+
const a = this.transaction;
|
|
6667
|
+
if (!(a instanceof ne))
|
|
6668
6668
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6669
|
-
r = new
|
|
6669
|
+
r = new Ie(a, this.core, s), this.confirmedDialogs.set(r.id, r);
|
|
6670
6670
|
}
|
|
6671
6671
|
(r.signalingState === b.Initial || r.signalingState === b.HaveLocalOffer) && r.signalingStateTransition(e);
|
|
6672
6672
|
const n = r;
|
|
@@ -6674,14 +6674,14 @@ class Jt extends O {
|
|
|
6674
6674
|
this.delegate.onAccept({
|
|
6675
6675
|
message: e,
|
|
6676
6676
|
session: n,
|
|
6677
|
-
ack: (
|
|
6678
|
-
const d = n.ack(
|
|
6677
|
+
ack: (a) => {
|
|
6678
|
+
const d = n.ack(a);
|
|
6679
6679
|
return this.confirmedDialogAcks.set(n.id, d), d;
|
|
6680
6680
|
}
|
|
6681
6681
|
});
|
|
6682
6682
|
else {
|
|
6683
|
-
const
|
|
6684
|
-
this.confirmedDialogAcks.set(n.id,
|
|
6683
|
+
const a = n.ack();
|
|
6684
|
+
this.confirmedDialogAcks.set(n.id, a);
|
|
6685
6685
|
}
|
|
6686
6686
|
}
|
|
6687
6687
|
return;
|
|
@@ -6722,7 +6722,7 @@ class Fe extends X {
|
|
|
6722
6722
|
if (!(d instanceof U))
|
|
6723
6723
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6724
6724
|
const f = pe.initialDialogStateForUserAgentServer(this.message, this.toTag);
|
|
6725
|
-
this.confirmedDialog = new
|
|
6725
|
+
this.confirmedDialog = new Ie(d, this.core, f);
|
|
6726
6726
|
}
|
|
6727
6727
|
const t = this.message.getHeaders("record-route").map((d) => `Record-Route: ${d}`), i = `Contact: ${this.core.configuration.contact.toString()}`, s = "Allow: " + re.toString();
|
|
6728
6728
|
if (!e.body) {
|
|
@@ -6732,8 +6732,8 @@ class Fe extends X {
|
|
|
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
|
-
const r = super.accept(e), n = this.confirmedDialog,
|
|
6736
|
-
return e.body && this.confirmedDialog.signalingState !== b.Stable && this.confirmedDialog.signalingStateTransition(e.body),
|
|
6735
|
+
const r = super.accept(e), n = this.confirmedDialog, a = Object.assign(Object.assign({}, r), { session: n });
|
|
6736
|
+
return e.body && this.confirmedDialog.signalingState !== b.Stable && this.confirmedDialog.signalingStateTransition(e.body), a;
|
|
6737
6737
|
}
|
|
6738
6738
|
/**
|
|
6739
6739
|
* 13.3.1.1 Progress
|
|
@@ -6761,13 +6761,13 @@ class Fe extends X {
|
|
|
6761
6761
|
if (!this.progressable)
|
|
6762
6762
|
throw new se(`${this.message.method} not progressable in state ${this.transaction.state}.`);
|
|
6763
6763
|
if (!this.earlyDialog) {
|
|
6764
|
-
const
|
|
6765
|
-
if (!(
|
|
6764
|
+
const a = this.transaction;
|
|
6765
|
+
if (!(a instanceof U))
|
|
6766
6766
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6767
6767
|
const d = pe.initialDialogStateForUserAgentServer(this.message, this.toTag, !0);
|
|
6768
|
-
this.earlyDialog = new
|
|
6768
|
+
this.earlyDialog = new Ie(a, this.core, d);
|
|
6769
6769
|
}
|
|
6770
|
-
const t = this.message.getHeaders("record-route").map((
|
|
6770
|
+
const t = this.message.getHeaders("record-route").map((a) => `Record-Route: ${a}`), 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
6773
|
return e.body && this.earlyDialog.signalingState !== b.Stable && this.earlyDialog.signalingStateTransition(e.body), n;
|
|
@@ -6799,22 +6799,22 @@ class Fe extends X {
|
|
|
6799
6799
|
return super.reject(e);
|
|
6800
6800
|
}
|
|
6801
6801
|
}
|
|
6802
|
-
class
|
|
6802
|
+
class Xt extends O {
|
|
6803
6803
|
constructor(e, t, i) {
|
|
6804
6804
|
super(B, e, t, i);
|
|
6805
6805
|
}
|
|
6806
6806
|
}
|
|
6807
|
-
class
|
|
6807
|
+
class Qt extends O {
|
|
6808
6808
|
constructor(e, t, i) {
|
|
6809
6809
|
super(B, e, t, i);
|
|
6810
6810
|
}
|
|
6811
6811
|
}
|
|
6812
|
-
class
|
|
6812
|
+
class ei extends X {
|
|
6813
6813
|
constructor(e, t, i) {
|
|
6814
6814
|
super(L, e, t, i), this.core = e;
|
|
6815
6815
|
}
|
|
6816
6816
|
}
|
|
6817
|
-
class
|
|
6817
|
+
class ti extends O {
|
|
6818
6818
|
constructor(e, t, i) {
|
|
6819
6819
|
const s = e.createOutgoingRequestMessage(v.SUBSCRIBE, i);
|
|
6820
6820
|
super(B, e.userAgentCore, s, t), this.dialog = e;
|
|
@@ -6856,7 +6856,7 @@ class et extends pe {
|
|
|
6856
6856
|
throw new Error("Contact undefined.");
|
|
6857
6857
|
if (!(r instanceof N))
|
|
6858
6858
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
6859
|
-
const n = r.uri,
|
|
6859
|
+
const n = r.uri, a = e.cseq, d = void 0, f = e.callId, h = e.fromTag, w = t.fromTag;
|
|
6860
6860
|
if (!f)
|
|
6861
6861
|
throw new Error("Call id undefined.");
|
|
6862
6862
|
if (!h)
|
|
@@ -6867,17 +6867,17 @@ class et extends pe {
|
|
|
6867
6867
|
throw new Error("From undefined.");
|
|
6868
6868
|
if (!e.to)
|
|
6869
6869
|
throw new Error("To undefined.");
|
|
6870
|
-
const S = e.from.uri,
|
|
6870
|
+
const S = e.from.uri, _ = e.to.uri;
|
|
6871
6871
|
return {
|
|
6872
6872
|
id: f + h + w,
|
|
6873
6873
|
early: !1,
|
|
6874
6874
|
callId: f,
|
|
6875
6875
|
localTag: h,
|
|
6876
6876
|
remoteTag: w,
|
|
6877
|
-
localSequenceNumber:
|
|
6877
|
+
localSequenceNumber: a,
|
|
6878
6878
|
remoteSequenceNumber: d,
|
|
6879
6879
|
localURI: S,
|
|
6880
|
-
remoteURI:
|
|
6880
|
+
remoteURI: _,
|
|
6881
6881
|
remoteTarget: n,
|
|
6882
6882
|
routeSet: s,
|
|
6883
6883
|
secure: !1
|
|
@@ -6951,7 +6951,7 @@ class et extends pe {
|
|
|
6951
6951
|
if (this.subscriptionState !== x.Pending && this.subscriptionState !== x.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 ti(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(), q.TIMER_N)), s;
|
|
6956
6956
|
}
|
|
6957
6957
|
/**
|
|
@@ -7004,7 +7004,7 @@ class et extends pe {
|
|
|
7004
7004
|
this.logger.warn("Unrecognized subscription state.");
|
|
7005
7005
|
break;
|
|
7006
7006
|
}
|
|
7007
|
-
const n = new
|
|
7007
|
+
const n = new _e(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 et extends pe {
|
|
|
7074
7074
|
this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."), this.subscriptionState !== x.Terminated && (this.stateTransition(x.Terminated), this.onTerminated());
|
|
7075
7075
|
}
|
|
7076
7076
|
}
|
|
7077
|
-
class
|
|
7077
|
+
class ii extends O {
|
|
7078
7078
|
constructor(e, t, i) {
|
|
7079
7079
|
const s = t.getHeader("Event");
|
|
7080
7080
|
if (!s)
|
|
@@ -7191,13 +7191,13 @@ class ti extends O {
|
|
|
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 si extends X {
|
|
7195
7195
|
constructor(e, t, i) {
|
|
7196
7196
|
super(L, e, t, i), this.core = e;
|
|
7197
7197
|
}
|
|
7198
7198
|
}
|
|
7199
7199
|
const tt = ["application/sdp", "application/dtmf-relay"];
|
|
7200
|
-
class
|
|
7200
|
+
class ri {
|
|
7201
7201
|
/**
|
|
7202
7202
|
* Constructor.
|
|
7203
7203
|
* @param configuration - Configuration.
|
|
@@ -7231,7 +7231,7 @@ class si {
|
|
|
7231
7231
|
* @param delegate - Request delegate.
|
|
7232
7232
|
*/
|
|
7233
7233
|
invite(e, t) {
|
|
7234
|
-
return new
|
|
7234
|
+
return new Zt(this, e, t);
|
|
7235
7235
|
}
|
|
7236
7236
|
/**
|
|
7237
7237
|
* Send MESSAGE.
|
|
@@ -7239,7 +7239,7 @@ class si {
|
|
|
7239
7239
|
* @param delegate - Request delegate.
|
|
7240
7240
|
*/
|
|
7241
7241
|
message(e, t) {
|
|
7242
|
-
return new
|
|
7242
|
+
return new pt(this, e, t);
|
|
7243
7243
|
}
|
|
7244
7244
|
/**
|
|
7245
7245
|
* Send PUBLISH.
|
|
@@ -7247,7 +7247,7 @@ class si {
|
|
|
7247
7247
|
* @param delegate - Request delegate.
|
|
7248
7248
|
*/
|
|
7249
7249
|
publish(e, t) {
|
|
7250
|
-
return new
|
|
7250
|
+
return new Xt(this, e, t);
|
|
7251
7251
|
}
|
|
7252
7252
|
/**
|
|
7253
7253
|
* Send REGISTER.
|
|
@@ -7255,7 +7255,7 @@ class si {
|
|
|
7255
7255
|
* @param delegate - Request delegate.
|
|
7256
7256
|
*/
|
|
7257
7257
|
register(e, t) {
|
|
7258
|
-
return new
|
|
7258
|
+
return new Qt(this, e, t);
|
|
7259
7259
|
}
|
|
7260
7260
|
/**
|
|
7261
7261
|
* Send SUBSCRIBE.
|
|
@@ -7263,7 +7263,7 @@ class si {
|
|
|
7263
7263
|
* @param delegate - Request delegate.
|
|
7264
7264
|
*/
|
|
7265
7265
|
subscribe(e, t) {
|
|
7266
|
-
return new
|
|
7266
|
+
return new ii(this, e, t);
|
|
7267
7267
|
}
|
|
7268
7268
|
/**
|
|
7269
7269
|
* Send a request.
|
|
@@ -7283,20 +7283,20 @@ class si {
|
|
|
7283
7283
|
* @param extraHeaders - Extra headers to add.
|
|
7284
7284
|
* @param body - Message body.
|
|
7285
7285
|
*/
|
|
7286
|
-
makeOutgoingRequestMessage(e, t, i, s, r, n,
|
|
7286
|
+
makeOutgoingRequestMessage(e, t, i, s, r, n, a) {
|
|
7287
7287
|
const d = this.configuration.sipjsId, f = this.configuration.displayName, h = this.configuration.viaForceRport, w = this.configuration.hackViaTcp, S = this.configuration.supportedOptionTags.slice();
|
|
7288
7288
|
e === v.REGISTER && S.push("path", "gruu"), e === v.INVITE && (this.configuration.contact.pubGruu || this.configuration.contact.tempGruu) && S.push("gruu");
|
|
7289
|
-
const
|
|
7289
|
+
const _ = this.configuration.routeSet, I = this.configuration.userAgentHeaderFieldValue, E = this.configuration.viaHost, p = Object.assign(Object.assign({}, {
|
|
7290
7290
|
callIdPrefix: d,
|
|
7291
7291
|
forceRport: h,
|
|
7292
7292
|
fromDisplayName: f,
|
|
7293
7293
|
hackViaTcp: w,
|
|
7294
7294
|
optionTags: S,
|
|
7295
|
-
routeSet:
|
|
7296
|
-
userAgentString:
|
|
7295
|
+
routeSet: _,
|
|
7296
|
+
userAgentString: I,
|
|
7297
7297
|
viaHost: E
|
|
7298
7298
|
}), r);
|
|
7299
|
-
return new le(e, t, i, s, p, n,
|
|
7299
|
+
return new le(e, t, i, s, p, n, a);
|
|
7300
7300
|
}
|
|
7301
7301
|
/**
|
|
7302
7302
|
* Handle an incoming request message from the transport.
|
|
@@ -7331,7 +7331,7 @@ class si {
|
|
|
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 = ut(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;
|
|
@@ -7428,8 +7428,8 @@ class si {
|
|
|
7428
7428
|
}
|
|
7429
7429
|
const r = e.callId + e.toTag + s.event, n = this.subscribers.get(r);
|
|
7430
7430
|
if (n) {
|
|
7431
|
-
const
|
|
7432
|
-
n.onNotify(
|
|
7431
|
+
const a = new _e(this, e);
|
|
7432
|
+
n.onNotify(a);
|
|
7433
7433
|
return;
|
|
7434
7434
|
}
|
|
7435
7435
|
}
|
|
@@ -7474,13 +7474,13 @@ class si {
|
|
|
7474
7474
|
break;
|
|
7475
7475
|
case v.MESSAGE:
|
|
7476
7476
|
{
|
|
7477
|
-
const t = new
|
|
7477
|
+
const t = new mt(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 _e(this, e);
|
|
7484
7484
|
this.delegate.onNotify ? this.delegate.onNotify(t) : t.reject({ statusCode: 405 });
|
|
7485
7485
|
}
|
|
7486
7486
|
break;
|
|
@@ -7495,19 +7495,19 @@ class si {
|
|
|
7495
7495
|
break;
|
|
7496
7496
|
case v.REFER:
|
|
7497
7497
|
{
|
|
7498
|
-
const t = new
|
|
7498
|
+
const t = new wt(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 ei(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 si(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 si {
|
|
|
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 ri() {
|
|
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
|
-
}
|
|
7539
7536
|
function ni() {
|
|
7537
|
+
return (o) => !o.audio && !o.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, o);
|
|
7538
|
+
}
|
|
7539
|
+
function oi() {
|
|
7540
7540
|
return {
|
|
7541
7541
|
bundlePolicy: "balanced",
|
|
7542
7542
|
certificates: void 0,
|
|
@@ -7713,11 +7713,11 @@ class F {
|
|
|
7713
7713
|
return Promise.reject(new Error("Peer connection closed."));
|
|
7714
7714
|
this.onDataChannel = e?.onDataChannel;
|
|
7715
7715
|
const r = (i = e?.offerOptions) === null || i === void 0 ? void 0 : i.iceRestart, n = e?.iceGatheringTimeout === void 0 ? (s = this.sessionDescriptionHandlerConfiguration) === null || s === void 0 ? void 0 : s.iceGatheringTimeout : e?.iceGatheringTimeout;
|
|
7716
|
-
return this.getLocalMediaStream(e).then(() => this.updateDirection(e)).then(() => this.createDataChannel(e)).then(() => this.createLocalOfferOrAnswer(e)).then((
|
|
7717
|
-
body:
|
|
7716
|
+
return this.getLocalMediaStream(e).then(() => this.updateDirection(e)).then(() => this.createDataChannel(e)).then(() => this.createLocalOfferOrAnswer(e)).then((a) => this.applyModifiers(a, t)).then((a) => this.setLocalSessionDescription(a)).then(() => this.waitForIceGatheringComplete(r, n)).then(() => this.getLocalSessionDescription()).then((a) => ({
|
|
7717
|
+
body: a.sdp,
|
|
7718
7718
|
contentType: "application/sdp"
|
|
7719
|
-
})).catch((
|
|
7720
|
-
throw this.logger.error("SessionDescriptionHandler.getDescription failed - " +
|
|
7719
|
+
})).catch((a) => {
|
|
7720
|
+
throw this.logger.error("SessionDescriptionHandler.getDescription failed - " + a), a;
|
|
7721
7721
|
});
|
|
7722
7722
|
}
|
|
7723
7723
|
/**
|
|
@@ -7756,8 +7756,8 @@ class F {
|
|
|
7756
7756
|
const r = t?.duration, n = t?.interToneGap;
|
|
7757
7757
|
try {
|
|
7758
7758
|
s.insertDTMF(e, r, n);
|
|
7759
|
-
} catch (
|
|
7760
|
-
return this.logger.error(
|
|
7759
|
+
} catch (a) {
|
|
7760
|
+
return this.logger.error(a.toString()), !1;
|
|
7761
7761
|
}
|
|
7762
7762
|
return this.logger.log("SessionDescriptionHandler.sendDtmf sent via RTP: " + e.toString()), !0;
|
|
7763
7763
|
}
|
|
@@ -7882,8 +7882,8 @@ class F {
|
|
|
7882
7882
|
}));
|
|
7883
7883
|
}, n = e.getAudioTracks();
|
|
7884
7884
|
n.length && r(n[0]);
|
|
7885
|
-
const
|
|
7886
|
-
return
|
|
7885
|
+
const a = e.getVideoTracks();
|
|
7886
|
+
return a.length && r(a[0]), s.reduce((d, f) => d.then(() => f), Promise.resolve());
|
|
7887
7887
|
}
|
|
7888
7888
|
/**
|
|
7889
7889
|
* Gets the peer connection's local session description.
|
|
@@ -8078,21 +8078,21 @@ class F {
|
|
|
8078
8078
|
};
|
|
8079
8079
|
}
|
|
8080
8080
|
}
|
|
8081
|
-
function ai(
|
|
8081
|
+
function ai(o) {
|
|
8082
8082
|
return (e, t) => {
|
|
8083
|
-
|
|
8083
|
+
o === void 0 && (o = ni());
|
|
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({}, oi()), t?.peerConnectionConfiguration)
|
|
8087
8087
|
}, r = e.userAgent.getLogger("sip.SessionDescriptionHandler");
|
|
8088
|
-
return new F(r,
|
|
8088
|
+
return new F(r, o, s);
|
|
8089
8089
|
};
|
|
8090
8090
|
}
|
|
8091
8091
|
class Te {
|
|
8092
8092
|
constructor(e, t) {
|
|
8093
8093
|
if (this._state = T.Disconnected, this.transitioningState = !1, this._stateEventEmitter = new ve(), this.logger = e, t) {
|
|
8094
|
-
const r = t, n = r?.wsServers,
|
|
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.'),
|
|
8094
|
+
const r = t, n = r?.wsServers, a = r?.maxReconnectionAttempts;
|
|
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.'), a !== 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
8097
|
this.configuration = Object.assign(Object.assign({}, Te.defaultOptions), t);
|
|
8098
8098
|
const i = this.configuration.server, s = P.parse(i, "absoluteURI");
|
|
@@ -8398,7 +8398,7 @@ class Te {
|
|
|
8398
8398
|
this._state = e;
|
|
8399
8399
|
const r = this.connectResolve, n = this.connectReject;
|
|
8400
8400
|
s === T.Connecting && (this.connectPromise = void 0, this.connectResolve = void 0, this.connectReject = void 0);
|
|
8401
|
-
const
|
|
8401
|
+
const a = this.disconnectResolve, d = this.disconnectReject;
|
|
8402
8402
|
if (s === T.Disconnecting && (this.disconnectPromise = void 0, this.disconnectResolve = void 0, this.disconnectReject = void 0), this.connectTimeout && (clearTimeout(this.connectTimeout), this.connectTimeout = void 0), this.logger.log(`Transitioned from ${s} to ${this._state}`), this._stateEventEmitter.emit(this._state), e === T.Connected && (this.startSendingKeepAlives(), this.onConnect))
|
|
8403
8403
|
try {
|
|
8404
8404
|
this.onConnect();
|
|
@@ -8419,11 +8419,11 @@ class Te {
|
|
|
8419
8419
|
e === T.Connected ? r() : n(t || new Error("Connect aborted."));
|
|
8420
8420
|
}
|
|
8421
8421
|
if (s === T.Disconnecting) {
|
|
8422
|
-
if (!
|
|
8422
|
+
if (!a)
|
|
8423
8423
|
throw new Error("Disconnect resolve undefined.");
|
|
8424
8424
|
if (!d)
|
|
8425
8425
|
throw new Error("Disconnect reject undefined.");
|
|
8426
|
-
e === T.Disconnected ?
|
|
8426
|
+
e === T.Disconnected ? a() : d(t || new Error("Disconnect aborted."));
|
|
8427
8427
|
}
|
|
8428
8428
|
this.transitioningState = !1;
|
|
8429
8429
|
}
|
|
@@ -8501,7 +8501,7 @@ class G {
|
|
|
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 Ft(), 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 = M.error;
|
|
8507
8507
|
break;
|
|
@@ -8594,7 +8594,7 @@ class G {
|
|
|
8594
8594
|
transportConstructor: Te,
|
|
8595
8595
|
transportOptions: {},
|
|
8596
8596
|
uri: new Z("sip", "anonymous", "anonymous.invalid"),
|
|
8597
|
-
userAgentString: "SIP.js/" +
|
|
8597
|
+
userAgentString: "SIP.js/" + Et,
|
|
8598
8598
|
viaHost: ""
|
|
8599
8599
|
};
|
|
8600
8600
|
}
|
|
@@ -8736,32 +8736,32 @@ class G {
|
|
|
8736
8736
|
if (this.state === k.Stopped)
|
|
8737
8737
|
return this.logger.warn("User agent already stopped"), Promise.resolve();
|
|
8738
8738
|
if (this.logger.log(`Stopping ${this.configuration.uri}`), !this.options.gracefulShutdown)
|
|
8739
|
-
return this.logger.log("Dispose of transport"), this.transport.dispose().catch((
|
|
8740
|
-
throw this.logger.error(
|
|
8739
|
+
return this.logger.log("Dispose of transport"), this.transport.dispose().catch((a) => {
|
|
8740
|
+
throw this.logger.error(a.message), a;
|
|
8741
8741
|
}), this.logger.log("Dispose of core"), this.userAgentCore.dispose(), this._publishers = {}, this._registerers = {}, this._sessions = {}, this._subscriptions = {}, this.transitionState(k.Stopped), Promise.resolve();
|
|
8742
8742
|
const e = Object.assign({}, this._publishers), t = Object.assign({}, this._registerers), i = Object.assign({}, this._sessions), s = Object.assign({}, this._subscriptions), r = this.transport, n = this.userAgentCore;
|
|
8743
8743
|
this.logger.log("Dispose of registerers");
|
|
8744
|
-
for (const
|
|
8745
|
-
t[
|
|
8746
|
-
throw this.logger.error(d.message), delete this._registerers[
|
|
8744
|
+
for (const a in t)
|
|
8745
|
+
t[a] && await t[a].dispose().catch((d) => {
|
|
8746
|
+
throw this.logger.error(d.message), delete this._registerers[a], d;
|
|
8747
8747
|
});
|
|
8748
8748
|
this.logger.log("Dispose of sessions");
|
|
8749
|
-
for (const
|
|
8750
|
-
i[
|
|
8751
|
-
throw this.logger.error(d.message), delete this._sessions[
|
|
8749
|
+
for (const a in i)
|
|
8750
|
+
i[a] && await i[a].dispose().catch((d) => {
|
|
8751
|
+
throw this.logger.error(d.message), delete this._sessions[a], d;
|
|
8752
8752
|
});
|
|
8753
8753
|
this.logger.log("Dispose of subscriptions");
|
|
8754
|
-
for (const
|
|
8755
|
-
s[
|
|
8756
|
-
throw this.logger.error(d.message), delete this._subscriptions[
|
|
8754
|
+
for (const a in s)
|
|
8755
|
+
s[a] && await s[a].dispose().catch((d) => {
|
|
8756
|
+
throw this.logger.error(d.message), delete this._subscriptions[a], d;
|
|
8757
8757
|
});
|
|
8758
8758
|
this.logger.log("Dispose of publishers");
|
|
8759
|
-
for (const
|
|
8760
|
-
e[
|
|
8761
|
-
throw this.logger.error(d.message), delete this._publishers[
|
|
8759
|
+
for (const a in e)
|
|
8760
|
+
e[a] && await e[a].dispose().catch((d) => {
|
|
8761
|
+
throw this.logger.error(d.message), delete this._publishers[a], d;
|
|
8762
8762
|
});
|
|
8763
|
-
this.logger.log("Dispose of transport"), await r.dispose().catch((
|
|
8764
|
-
throw this.logger.error(
|
|
8763
|
+
this.logger.log("Dispose of transport"), await r.dispose().catch((a) => {
|
|
8764
|
+
throw this.logger.error(a.message), a;
|
|
8765
8765
|
}), this.logger.log("Dispose of core"), n.dispose(), this.transitionState(k.Stopped);
|
|
8766
8766
|
}
|
|
8767
8767
|
/**
|
|
@@ -8799,9 +8799,9 @@ class G {
|
|
|
8799
8799
|
tempGruu: void 0,
|
|
8800
8800
|
uri: new Z("sip", e, this.options.viaHost, void 0, t),
|
|
8801
8801
|
toString: (s = {}) => {
|
|
8802
|
-
const r = s.anonymous || !1, n = s.outbound || !1,
|
|
8802
|
+
const r = s.anonymous || !1, n = s.outbound || !1, a = s.register || !1;
|
|
8803
8803
|
let d = "<";
|
|
8804
|
-
return r ? d += this.contact.tempGruu || `sip:anonymous@anonymous.invalid;transport=${t.transport ? t.transport : "ws"}` :
|
|
8804
|
+
return r ? d += this.contact.tempGruu || `sip:anonymous@anonymous.invalid;transport=${t.transport ? t.transport : "ws"}` : a ? d += this.contact.uri : d += this.contact.pubGruu || this.contact.uri, n && (d += ";ob"), d += ">", this.options.instanceIdAlwaysAdded && (d += ';+sip.instance="<urn:uuid:' + this._instanceId + '>"'), d;
|
|
8805
8805
|
}
|
|
8806
8806
|
};
|
|
8807
8807
|
}
|
|
@@ -8810,7 +8810,7 @@ class G {
|
|
|
8810
8810
|
*/
|
|
8811
8811
|
initCore() {
|
|
8812
8812
|
let e = [];
|
|
8813
|
-
e.push("outbound"), this.options.sipExtension100rel === W.Supported && e.push("100rel"), this.options.sipExtensionReplaces === W.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 === W.Supported && e.push("100rel"), this.options.sipExtensionReplaces === W.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Mt[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 = {
|
|
@@ -8827,17 +8827,17 @@ class G {
|
|
|
8827
8827
|
viaForceRport: this.options.forceRport,
|
|
8828
8828
|
viaHost: this.options.viaHost,
|
|
8829
8829
|
authenticationFactory: () => {
|
|
8830
|
-
const r = this.options.authorizationUsername ? this.options.authorizationUsername : this.options.uri.user, n = this.options.authorizationPassword ? this.options.authorizationPassword : void 0,
|
|
8831
|
-
return new
|
|
8830
|
+
const r = this.options.authorizationUsername ? this.options.authorizationUsername : this.options.uri.user, n = this.options.authorizationPassword ? this.options.authorizationPassword : void 0, a = this.options.authorizationHa1 ? this.options.authorizationHa1 : void 0;
|
|
8831
|
+
return new Ot(this.getLoggerFactory(), a, r, n);
|
|
8832
8832
|
},
|
|
8833
8833
|
transportAccessor: () => this.transport
|
|
8834
8834
|
}, s = {
|
|
8835
8835
|
onInvite: (r) => {
|
|
8836
8836
|
var n;
|
|
8837
|
-
const
|
|
8837
|
+
const a = new de(this, r);
|
|
8838
8838
|
if (r.delegate = {
|
|
8839
8839
|
onCancel: (d) => {
|
|
8840
|
-
|
|
8840
|
+
a._onCancel(d);
|
|
8841
8841
|
},
|
|
8842
8842
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8843
8843
|
onTransportError: (d) => {
|
|
@@ -8855,39 +8855,39 @@ class G {
|
|
|
8855
8855
|
const S = f.replaces_from_tag;
|
|
8856
8856
|
if (typeof S != "string")
|
|
8857
8857
|
throw new Error("type of from tag is not string");
|
|
8858
|
-
const
|
|
8859
|
-
if (!
|
|
8860
|
-
|
|
8858
|
+
const _ = h + w + S, I = this.userAgentCore.dialogs.get(_);
|
|
8859
|
+
if (!I) {
|
|
8860
|
+
a.reject({ statusCode: 481 });
|
|
8861
8861
|
return;
|
|
8862
8862
|
}
|
|
8863
|
-
if (!
|
|
8864
|
-
|
|
8863
|
+
if (!I.early && f.early_only === !0) {
|
|
8864
|
+
a.reject({ statusCode: 486 });
|
|
8865
8865
|
return;
|
|
8866
8866
|
}
|
|
8867
8867
|
const E = this._sessions[h + S] || this._sessions[h + w] || void 0;
|
|
8868
8868
|
if (!E)
|
|
8869
8869
|
throw new Error("Session does not exist.");
|
|
8870
|
-
|
|
8870
|
+
a._replacee = E;
|
|
8871
8871
|
}
|
|
8872
8872
|
}
|
|
8873
8873
|
if (!((n = this.delegate) === null || n === void 0) && n.onInvite) {
|
|
8874
|
-
if (
|
|
8875
|
-
|
|
8874
|
+
if (a.autoSendAnInitialProvisionalResponse) {
|
|
8875
|
+
a.progress().then(() => {
|
|
8876
8876
|
var d;
|
|
8877
8877
|
if (((d = this.delegate) === null || d === void 0 ? void 0 : d.onInvite) === void 0)
|
|
8878
8878
|
throw new Error("onInvite undefined.");
|
|
8879
|
-
this.delegate.onInvite(
|
|
8879
|
+
this.delegate.onInvite(a);
|
|
8880
8880
|
});
|
|
8881
8881
|
return;
|
|
8882
8882
|
}
|
|
8883
|
-
this.delegate.onInvite(
|
|
8883
|
+
this.delegate.onInvite(a);
|
|
8884
8884
|
return;
|
|
8885
8885
|
}
|
|
8886
|
-
|
|
8886
|
+
a.reject({ statusCode: 486 });
|
|
8887
8887
|
},
|
|
8888
8888
|
onMessage: (r) => {
|
|
8889
8889
|
if (this.delegate && this.delegate.onMessage) {
|
|
8890
|
-
const n = new
|
|
8890
|
+
const n = new ht(r);
|
|
8891
8891
|
this.delegate.onMessage(n);
|
|
8892
8892
|
} else
|
|
8893
8893
|
r.accept();
|
|
@@ -8909,7 +8909,7 @@ class G {
|
|
|
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 ri(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);
|
|
@@ -8952,7 +8952,7 @@ class G {
|
|
|
8952
8952
|
return;
|
|
8953
8953
|
}
|
|
8954
8954
|
}
|
|
8955
|
-
if (t instanceof
|
|
8955
|
+
if (t instanceof oe) {
|
|
8956
8956
|
if (!i()) {
|
|
8957
8957
|
this.logger.warn("Response missing mandatory header field. Dropping.");
|
|
8958
8958
|
return;
|
|
@@ -8975,7 +8975,7 @@ class G {
|
|
|
8975
8975
|
this.userAgentCore.receiveIncomingRequestFromTransport(t);
|
|
8976
8976
|
return;
|
|
8977
8977
|
}
|
|
8978
|
-
if (t instanceof
|
|
8978
|
+
if (t instanceof oe) {
|
|
8979
8979
|
this.userAgentCore.receiveIncomingResponseFromTransport(t);
|
|
8980
8980
|
return;
|
|
8981
8981
|
}
|
|
@@ -9002,8 +9002,8 @@ class G {
|
|
|
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
|
|
9006
|
-
return (
|
|
9005
|
+
function ci() {
|
|
9006
|
+
return (o, e) => ({ session: e, held: !1, muted: !1 });
|
|
9007
9007
|
}
|
|
9008
9008
|
class We {
|
|
9009
9009
|
/**
|
|
@@ -9017,7 +9017,7 @@ class We {
|
|
|
9017
9017
|
autoStop: !0,
|
|
9018
9018
|
delegate: {},
|
|
9019
9019
|
iceStopWaitingOnServerReflexive: !1,
|
|
9020
|
-
managedSessionFactory:
|
|
9020
|
+
managedSessionFactory: ci(),
|
|
9021
9021
|
maxSimultaneousSessions: 2,
|
|
9022
9022
|
media: {},
|
|
9023
9023
|
optionsPingInterval: -1,
|
|
@@ -9053,8 +9053,8 @@ class We {
|
|
|
9053
9053
|
this.options.optionsPingInterval > 0 && (r = this.optionsPingFailure, this.optionsPingFailure = !1, this.optionsPingStop()), this.delegate && this.delegate.onServerDisconnect && this.delegate.onServerDisconnect(s), (s || r) && (this.registerer && (this.logger.log("Disposing of registerer..."), this.registerer.dispose().catch((n) => {
|
|
9054
9054
|
this.logger.debug("Error occurred disposing of registerer after connection with server was lost."), this.logger.debug(n.toString());
|
|
9055
9055
|
}), this.registerer = void 0), this.managedSessions.slice().map((n) => n.session).forEach(async (n) => {
|
|
9056
|
-
this.logger.log("Disposing of session..."), n.dispose().catch((
|
|
9057
|
-
this.logger.debug("Error occurred disposing of a session after connection with server was lost."), this.logger.debug(
|
|
9056
|
+
this.logger.log("Disposing of session..."), n.dispose().catch((a) => {
|
|
9057
|
+
this.logger.debug("Error occurred disposing of a session after connection with server was lost."), this.logger.debug(a.toString());
|
|
9058
9058
|
});
|
|
9059
9059
|
}), this.shouldBeConnected && this.attemptReconnection());
|
|
9060
9060
|
},
|
|
@@ -9065,8 +9065,8 @@ class We {
|
|
|
9065
9065
|
if (r !== 0 && this.managedSessions.length > r) {
|
|
9066
9066
|
this.logger.warn(`[${s.id}] Session already in progress, rejecting INVITE...`), s.reject().then(() => {
|
|
9067
9067
|
this.logger.log(`[${s.id}] Rejected INVITE`);
|
|
9068
|
-
}).catch((
|
|
9069
|
-
this.logger.error(`[${s.id}] Failed to reject INVITE`), this.logger.error(
|
|
9068
|
+
}).catch((a) => {
|
|
9069
|
+
this.logger.error(`[${s.id}] Failed to reject INVITE`), this.logger.error(a.toString());
|
|
9070
9070
|
});
|
|
9071
9071
|
return;
|
|
9072
9072
|
}
|
|
@@ -9075,8 +9075,8 @@ class We {
|
|
|
9075
9075
|
};
|
|
9076
9076
|
this.initSession(s, n), this.delegate && this.delegate.onCallReceived ? this.delegate.onCallReceived(s) : (this.logger.warn(`[${s.id}] No handler available, rejecting INVITE...`), s.reject().then(() => {
|
|
9077
9077
|
this.logger.log(`[${s.id}] Rejected INVITE`);
|
|
9078
|
-
}).catch((
|
|
9079
|
-
this.logger.error(`[${s.id}] Failed to reject INVITE`), this.logger.error(
|
|
9078
|
+
}).catch((a) => {
|
|
9079
|
+
this.logger.error(`[${s.id}] Failed to reject INVITE`), this.logger.error(a.toString());
|
|
9080
9080
|
}));
|
|
9081
9081
|
},
|
|
9082
9082
|
// Handle incoming messages
|
|
@@ -9252,18 +9252,18 @@ class We {
|
|
|
9252
9252
|
return Promise.reject(new Error(`Failed to create a valid URI from "${e}"`));
|
|
9253
9253
|
if (t || (t = {}), t.sessionDescriptionHandlerOptions || (t.sessionDescriptionHandlerOptions = {}), t.sessionDescriptionHandlerOptions.constraints || (t.sessionDescriptionHandlerOptions.constraints = this.constraints), t.earlyMedia) {
|
|
9254
9254
|
i = i || {}, i.requestDelegate = i.requestDelegate || {};
|
|
9255
|
-
const
|
|
9255
|
+
const a = i.requestDelegate.onProgress;
|
|
9256
9256
|
i.requestDelegate.onProgress = (d) => {
|
|
9257
|
-
d.message.statusCode === 183 && this.setupRemoteMedia(n),
|
|
9257
|
+
d.message.statusCode === 183 && this.setupRemoteMedia(n), a && a(d);
|
|
9258
9258
|
};
|
|
9259
9259
|
}
|
|
9260
|
-
this.options.iceStopWaitingOnServerReflexive && (t.delegate = t.delegate || {}, t.delegate.onSessionDescriptionHandler = (
|
|
9261
|
-
if (!(
|
|
9260
|
+
this.options.iceStopWaitingOnServerReflexive && (t.delegate = t.delegate || {}, t.delegate.onSessionDescriptionHandler = (a) => {
|
|
9261
|
+
if (!(a instanceof F))
|
|
9262
9262
|
throw new Error("Session description handler not instance of SessionDescriptionHandler");
|
|
9263
|
-
|
|
9263
|
+
a.peerConnectionDelegate = {
|
|
9264
9264
|
onicecandidate: (d) => {
|
|
9265
9265
|
var f;
|
|
9266
|
-
((f = d.candidate) === null || f === void 0 ? void 0 : f.type) === "srflx" && (this.logger.log(`[${n.id}] Found srflx ICE candidate, stop waiting...`),
|
|
9266
|
+
((f = d.candidate) === null || f === void 0 ? void 0 : f.type) === "srflx" && (this.logger.log(`[${n.id}] Found srflx ICE candidate, stop waiting...`), a.iceGatheringComplete());
|
|
9267
9267
|
}
|
|
9268
9268
|
};
|
|
9269
9269
|
});
|
|
@@ -9419,7 +9419,7 @@ Duration=` + 2e3
|
|
|
9419
9419
|
async message(e, t) {
|
|
9420
9420
|
this.logger.log("Sending message...");
|
|
9421
9421
|
const i = G.makeURI(e);
|
|
9422
|
-
return i ? new
|
|
9422
|
+
return i ? new qt(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() {
|
|
@@ -9544,9 +9544,9 @@ Duration=` + 2e3
|
|
|
9544
9544
|
i.reject();
|
|
9545
9545
|
return;
|
|
9546
9546
|
}
|
|
9547
|
-
let
|
|
9547
|
+
let a;
|
|
9548
9548
|
const d = /^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/;
|
|
9549
|
-
if (n[0] !== void 0 && d.test(n[0]) && (
|
|
9549
|
+
if (n[0] !== void 0 && d.test(n[0]) && (a = n[0].replace(d, "$2")), !a) {
|
|
9550
9550
|
i.reject();
|
|
9551
9551
|
return;
|
|
9552
9552
|
}
|
|
@@ -9558,9 +9558,9 @@ Duration=` + 2e3
|
|
|
9558
9558
|
}
|
|
9559
9559
|
i.accept().then(() => {
|
|
9560
9560
|
if (this.delegate && this.delegate.onCallDTMFReceived) {
|
|
9561
|
-
if (!
|
|
9561
|
+
if (!a || !f)
|
|
9562
9562
|
throw new Error("Tone or duration undefined.");
|
|
9563
|
-
this.delegate.onCallDTMFReceived(e,
|
|
9563
|
+
this.delegate.onCallDTMFReceived(e, a, f);
|
|
9564
9564
|
}
|
|
9565
9565
|
}).catch((w) => {
|
|
9566
9566
|
this.logger.error(w.message);
|
|
@@ -9586,8 +9586,8 @@ Duration=` + 2e3
|
|
|
9586
9586
|
this.optionsPingFailure = !1, this.optionsPingRunning && (this.optionsPingRunning = !1, this.optionsPingRun(e, t, i));
|
|
9587
9587
|
}, r = () => {
|
|
9588
9588
|
this.logger.error("OPTIONS ping failed"), this.optionsPingFailure = !0, this.optionsPingRunning = !1, this.userAgent.transport.disconnect().catch((d) => this.logger.error(d));
|
|
9589
|
-
}, n = this.userAgent.userAgentCore,
|
|
9590
|
-
this.optionsPingRequest = n.request(
|
|
9589
|
+
}, n = this.userAgent.userAgentCore, a = n.makeOutgoingRequestMessage("OPTIONS", e, t, i, {});
|
|
9590
|
+
this.optionsPingRequest = n.request(a, {
|
|
9591
9591
|
onAccept: () => {
|
|
9592
9592
|
this.optionsPingRequest = void 0, s();
|
|
9593
9593
|
},
|
|
@@ -9662,13 +9662,13 @@ Duration=` + 2e3
|
|
|
9662
9662
|
const s = {
|
|
9663
9663
|
requestDelegate: {
|
|
9664
9664
|
onAccept: () => {
|
|
9665
|
-
const
|
|
9666
|
-
|
|
9665
|
+
const a = this.sessionManaged(e);
|
|
9666
|
+
a !== void 0 && (a.held = t, this.enableReceiverTracks(e, !a.held), this.enableSenderTracks(e, !a.held && !a.muted), this.delegate && this.delegate.onCallHold && this.delegate.onCallHold(e, a.held));
|
|
9667
9667
|
},
|
|
9668
9668
|
onReject: () => {
|
|
9669
9669
|
this.logger.warn(`[${e.id}] Re-invite request was rejected`);
|
|
9670
|
-
const
|
|
9671
|
-
|
|
9670
|
+
const a = this.sessionManaged(e);
|
|
9671
|
+
a !== void 0 && (a.held = !t, this.enableReceiverTracks(e, !a.held), this.enableSenderTracks(e, !a.held && !a.muted), this.delegate && this.delegate.onCallHold && this.delegate.onCallHold(e, a.held));
|
|
9672
9672
|
}
|
|
9673
9673
|
}
|
|
9674
9674
|
}, r = e.sessionDescriptionHandlerOptionsReInvite;
|
|
@@ -9677,10 +9677,10 @@ Duration=` + 2e3
|
|
|
9677
9677
|
if (!n)
|
|
9678
9678
|
throw new Error("Managed session is undefiend.");
|
|
9679
9679
|
return n.held = t, e.invite(s).then(() => {
|
|
9680
|
-
const
|
|
9681
|
-
|
|
9682
|
-
}).catch((
|
|
9683
|
-
throw n.held = !t,
|
|
9680
|
+
const a = this.sessionManaged(e);
|
|
9681
|
+
a !== void 0 && (this.enableReceiverTracks(e, !a.held), this.enableSenderTracks(e, !a.held && !a.muted));
|
|
9682
|
+
}).catch((a) => {
|
|
9683
|
+
throw n.held = !t, a instanceof be && this.logger.error(`[${e.id}] A hold request is already in progress.`), a;
|
|
9684
9684
|
});
|
|
9685
9685
|
}
|
|
9686
9686
|
/**
|
|
@@ -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 di {
|
|
9786
9786
|
/**
|
|
9787
9787
|
* Constructs a new instance of the `SimpleUser` class.
|
|
9788
9788
|
* @param server - SIP WebSocket Server URL.
|
|
@@ -9810,12 +9810,12 @@ class ci {
|
|
|
9810
9810
|
this.session = void 0, !((s = this.delegate) === null || s === void 0) && s.onCallHangup && ((r = this.delegate) === null || r === void 0 || r.onCallHangup());
|
|
9811
9811
|
},
|
|
9812
9812
|
onCallHold: (s, r) => {
|
|
9813
|
-
var n,
|
|
9814
|
-
return (
|
|
9813
|
+
var n, a;
|
|
9814
|
+
return (a = (n = this.delegate) === null || n === void 0 ? void 0 : n.onCallHold) === null || a === void 0 ? void 0 : a.call(n, r);
|
|
9815
9815
|
},
|
|
9816
9816
|
onCallDTMFReceived: (s, r, n) => {
|
|
9817
|
-
var
|
|
9818
|
-
return (d = (
|
|
9817
|
+
var a, d;
|
|
9818
|
+
return (d = (a = this.delegate) === null || a === void 0 ? void 0 : a.onCallDTMFReceived) === null || d === void 0 ? void 0 : d.call(a, r, n);
|
|
9819
9819
|
},
|
|
9820
9820
|
onMessageReceived: (s) => {
|
|
9821
9821
|
var r, n;
|
|
@@ -10051,14 +10051,14 @@ class ci {
|
|
|
10051
10051
|
return this.logger.log(`[${this.id}] sending message...`), this.sessionManager.message(e, t);
|
|
10052
10052
|
}
|
|
10053
10053
|
}
|
|
10054
|
-
const
|
|
10055
|
-
const i = String(
|
|
10056
|
-
return s.name = i || "MediaAccessError", s.code = t, s.cause =
|
|
10057
|
-
}, Ue = (
|
|
10058
|
-
const e = new Error(
|
|
10054
|
+
const li = 15e3, hi = 15e3, Ne = (o, e, t) => {
|
|
10055
|
+
const i = String(o?.name || o?.code || "").trim(), s = new Error(e);
|
|
10056
|
+
return s.name = i || "MediaAccessError", s.code = t, s.cause = o, s;
|
|
10057
|
+
}, Ue = (o) => {
|
|
10058
|
+
const e = new Error(o);
|
|
10059
10059
|
return e.name = "SipClientLifecycleCancelledError", e.code = "sip_client_replaced", e;
|
|
10060
|
-
}, Ge = async (
|
|
10061
|
-
const t = String(
|
|
10060
|
+
}, Ge = async (o, e = "call") => {
|
|
10061
|
+
const t = String(o?.name || o?.code || "").trim(), i = String(o?.message || "").trim(), s = `${t} ${i}`.toLowerCase();
|
|
10062
10062
|
let r = "";
|
|
10063
10063
|
try {
|
|
10064
10064
|
if (typeof navigator < "u" && navigator.permissions?.query) {
|
|
@@ -10069,29 +10069,29 @@ const di = 15e3, li = 15e3, Ne = (a, e, t) => {
|
|
|
10069
10069
|
r = "";
|
|
10070
10070
|
}
|
|
10071
10071
|
return r === "denied" || t === "NotAllowedError" || t === "SecurityError" || s.includes("notallowederror") || s.includes("permission denied") || s.includes("permission dismissed") || s.includes("microphone permission") || s.includes("getusermedia() no permission") ? Ne(
|
|
10072
|
-
|
|
10072
|
+
o,
|
|
10073
10073
|
`浏览器未授予麦克风权限,无法${e === "answer" ? "接听来电" : "发起通话"}。请点击地址栏的麦克风权限并选择“允许”,然后刷新页面重试。`,
|
|
10074
10074
|
"media_permission_denied"
|
|
10075
10075
|
) : t === "NotFoundError" || t === "DevicesNotFoundError" || s.includes("notfounderror") || s.includes("requested device not found") || s.includes("no audio input device") ? Ne(
|
|
10076
|
-
|
|
10076
|
+
o,
|
|
10077
10077
|
"未检测到可用的麦克风设备,无法建立语音通话。请连接耳麦或启用系统麦克风后重试。",
|
|
10078
10078
|
"media_device_not_found"
|
|
10079
10079
|
) : t === "NotReadableError" || t === "TrackStartError" || s.includes("notreadableerror") || s.includes("could not start audio source") ? Ne(
|
|
10080
|
-
|
|
10080
|
+
o,
|
|
10081
10081
|
"麦克风当前被系统或其他应用占用,无法建立语音通话。请关闭占用麦克风的程序后重试。",
|
|
10082
10082
|
"media_device_unavailable"
|
|
10083
|
-
) :
|
|
10084
|
-
},
|
|
10083
|
+
) : o;
|
|
10084
|
+
}, ui = async (o = "call") => {
|
|
10085
10085
|
if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia)
|
|
10086
10086
|
return null;
|
|
10087
10087
|
let e = null;
|
|
10088
10088
|
try {
|
|
10089
10089
|
return e = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 }), e;
|
|
10090
10090
|
} catch (t) {
|
|
10091
|
-
throw await Ge(t,
|
|
10091
|
+
throw await Ge(t, o);
|
|
10092
10092
|
}
|
|
10093
10093
|
};
|
|
10094
|
-
class
|
|
10094
|
+
class gi {
|
|
10095
10095
|
constructor(e, t = {}) {
|
|
10096
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 = {
|
|
10097
10097
|
local: null,
|
|
@@ -10099,7 +10099,7 @@ class ui {
|
|
|
10099
10099
|
}, this.audioTrackMeta = {
|
|
10100
10100
|
local: null,
|
|
10101
10101
|
remote: null
|
|
10102
|
-
}, this.ringbackAudio = null, this.ringbackPlaying = !1, this.incomingAudio = null, this.incomingPlaying = !1, this.hangupInitiatedByLocal = !1, this.ringbackToneUrl = this._resolveToneUrl(t.ringbackTone || "ringback1.wav"), this.incomingToneUrl = this._resolveToneUrl(t.incomingTone || "ring1.wav"), this.pendingPlaybackTasks = /* @__PURE__ */ new Map(), this.audioUnlockHandler = null, this.lastSessionMeta = null, this.ensureReadyPromise = null, this.connectionWaiters = /* @__PURE__ */ new Set(), this.registrationWaiters = /* @__PURE__ */ new Set(), this.connectionConfirmTimeoutMs = Number.isFinite(Number(t.connectionConfirmTimeoutMs)) ? Number(t.connectionConfirmTimeoutMs) :
|
|
10102
|
+
}, this.ringbackAudio = null, this.ringbackPlaying = !1, this.incomingAudio = null, this.incomingPlaying = !1, this.hangupInitiatedByLocal = !1, this.ringbackToneUrl = this._resolveToneUrl(t.ringbackTone || "ringback1.wav"), this.incomingToneUrl = this._resolveToneUrl(t.incomingTone || "ring1.wav"), this.pendingPlaybackTasks = /* @__PURE__ */ new Map(), this.audioUnlockHandler = null, this.lastSessionMeta = null, this.ensureReadyPromise = null, this.connectionWaiters = /* @__PURE__ */ new Set(), this.registrationWaiters = /* @__PURE__ */ new Set(), this.connectionConfirmTimeoutMs = Number.isFinite(Number(t.connectionConfirmTimeoutMs)) ? Number(t.connectionConfirmTimeoutMs) : li, this.registrationConfirmTimeoutMs = Number.isFinite(Number(t.registrationConfirmTimeoutMs)) ? Number(t.registrationConfirmTimeoutMs) : hi, this.peerConnectionDebug = {
|
|
10103
10103
|
attached: !1,
|
|
10104
10104
|
events: [],
|
|
10105
10105
|
iceCandidates: [],
|
|
@@ -10191,15 +10191,15 @@ class ui {
|
|
|
10191
10191
|
codecId: n.codecId || "",
|
|
10192
10192
|
transportId: n.transportId || ""
|
|
10193
10193
|
}), n.type === "transport" && n.selectedCandidatePairId && !r.selectedCandidatePair) {
|
|
10194
|
-
const
|
|
10195
|
-
|
|
10196
|
-
state:
|
|
10197
|
-
localCandidateId:
|
|
10198
|
-
remoteCandidateId:
|
|
10199
|
-
bytesSent:
|
|
10200
|
-
bytesReceived:
|
|
10201
|
-
currentRoundTripTime:
|
|
10202
|
-
}, r.localCandidate = s.get(
|
|
10194
|
+
const a = s.get(n.selectedCandidatePairId);
|
|
10195
|
+
a && (r.selectedCandidatePair = {
|
|
10196
|
+
state: a.state || "",
|
|
10197
|
+
localCandidateId: a.localCandidateId || "",
|
|
10198
|
+
remoteCandidateId: a.remoteCandidateId || "",
|
|
10199
|
+
bytesSent: a.bytesSent || 0,
|
|
10200
|
+
bytesReceived: a.bytesReceived || 0,
|
|
10201
|
+
currentRoundTripTime: a.currentRoundTripTime || 0
|
|
10202
|
+
}, r.localCandidate = s.get(a.localCandidateId) || null, r.remoteCandidate = s.get(a.remoteCandidateId) || null);
|
|
10203
10203
|
}
|
|
10204
10204
|
n.type === "local-candidate" && r.localCandidates.push({
|
|
10205
10205
|
id: n.id || "",
|
|
@@ -10305,7 +10305,7 @@ class ui {
|
|
|
10305
10305
|
});
|
|
10306
10306
|
}
|
|
10307
10307
|
_createSimpleUser() {
|
|
10308
|
-
const { sip_username: e, sip_password: t, sip_domain: i, port: s, webrtc_url: r, ice_servers: n } = this.account,
|
|
10308
|
+
const { sip_username: e, sip_password: t, sip_domain: i, port: s, webrtc_url: r, ice_servers: n } = this.account, a = s || "443", d = r || (/^wss?:\/\//.test(i) ? i : `wss://${i}:${a}`), h = {
|
|
10309
10309
|
aor: `sip:${e}@${i}`,
|
|
10310
10310
|
media: {
|
|
10311
10311
|
constraints: { audio: { echoCancellation: !0, noiseSuppression: !0, autoGainControl: !0 }, video: !1 },
|
|
@@ -10323,7 +10323,7 @@ class ui {
|
|
|
10323
10323
|
registererOptions: {
|
|
10324
10324
|
expires: 1800
|
|
10325
10325
|
}
|
|
10326
|
-
}, w = new
|
|
10326
|
+
}, w = new di(d, h);
|
|
10327
10327
|
return w.delegate = {
|
|
10328
10328
|
onServerConnect: () => {
|
|
10329
10329
|
this.connected = !0, this._resolveConnectionWaiters(), this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
|
|
@@ -10350,10 +10350,10 @@ class ui {
|
|
|
10350
10350
|
onCallHangup: () => {
|
|
10351
10351
|
const S = this.active;
|
|
10352
10352
|
if (this.active = !1, this.onStateChange) {
|
|
10353
|
-
const
|
|
10354
|
-
|
|
10355
|
-
const
|
|
10356
|
-
|
|
10353
|
+
const _ = this.lastFailureMeta ? { ...this.lastFailureMeta } : {};
|
|
10354
|
+
_.hangupSource = this.hangupInitiatedByLocal ? "local" : S ? "remote" : "unknown";
|
|
10355
|
+
const I = this.lastSessionMeta || this._buildIncomingCallMeta();
|
|
10356
|
+
I && Object.keys(I).length > 0 && (_.callMeta = I), this.onStateChange("terminated", _);
|
|
10357
10357
|
}
|
|
10358
10358
|
this.hangupInitiatedByLocal = !1, this._stopAllAudioMonitors(), this._reportAudioSilence(), this._stopRingback(), this._stopIncomingTone(), this.lastFailureMeta = null, this.lastSessionMeta = null;
|
|
10359
10359
|
}
|
|
@@ -10377,7 +10377,7 @@ class ui {
|
|
|
10377
10377
|
const i = t.match(/^(sips?:)/i), s = i ? i[1].toLowerCase() : "sip:", r = i ? t.slice(i[1].length) : t, n = r.indexOf("@");
|
|
10378
10378
|
if (n === -1)
|
|
10379
10379
|
return `${s}${this._encodeSipUserPart(r)}`;
|
|
10380
|
-
const
|
|
10380
|
+
const a = r.slice(0, n), d = r.slice(n + 1), f = this._encodeSipUserPart(a);
|
|
10381
10381
|
return `${s}${f}@${d}`;
|
|
10382
10382
|
}
|
|
10383
10383
|
_isIncomingSession() {
|
|
@@ -10586,8 +10586,8 @@ class ui {
|
|
|
10586
10586
|
const r = this._createInviteRequestDelegate(t), n = this._mergeInviteOptions(t, r);
|
|
10587
10587
|
try {
|
|
10588
10588
|
await this._preflightAudioAccess("call"), await this.simpleUser.call(s, void 0, n), this._scheduleLocalMonitor(), this._stopIncomingTone();
|
|
10589
|
-
} catch (
|
|
10590
|
-
const d = await this._normalizeMediaAccessError(
|
|
10589
|
+
} catch (a) {
|
|
10590
|
+
const d = await this._normalizeMediaAccessError(a, "call");
|
|
10591
10591
|
throw this.onError && this.onError(d), this.lastFailureMeta = {
|
|
10592
10592
|
source: "invite-exception",
|
|
10593
10593
|
code: d?.code || null,
|
|
@@ -10599,7 +10599,7 @@ class ui {
|
|
|
10599
10599
|
async _preflightAudioAccess(e = "call") {
|
|
10600
10600
|
let t = null;
|
|
10601
10601
|
try {
|
|
10602
|
-
t = await
|
|
10602
|
+
t = await ui(e);
|
|
10603
10603
|
} catch (i) {
|
|
10604
10604
|
const s = await Ge(i, e);
|
|
10605
10605
|
throw this.onError && this.onError(s), this.lastFailureMeta = {
|
|
@@ -10635,14 +10635,14 @@ class ui {
|
|
|
10635
10635
|
this.lastFailureMeta = i, console.warn("[CALL] 呼叫失败", i), this._stopRingback(), this._stopIncomingTone(), this._stopAllAudioMonitors(), this._reportAudioSilence(), this.onStateChange && this.onStateChange("failed", { ...i }), this.onError && i.message && this.onError(new Error(i.message));
|
|
10636
10636
|
}
|
|
10637
10637
|
_extractResponseMeta(e, t) {
|
|
10638
|
-
const i = t?.message, s = i?.statusCode || null, r = (i?.reasonPhrase || "").trim(), n = this._getHeaderValue(i, "Warning"),
|
|
10638
|
+
const i = t?.message, s = i?.statusCode || null, r = (i?.reasonPhrase || "").trim(), n = this._getHeaderValue(i, "Warning"), a = this._getHeaderValue(i, "Reason"), d = this._getHeaderValue(i, "Retry-After"), f = typeof i?.body == "string" ? i.body.trim() : "", w = [s, r].filter(Boolean).join(" ").trim() || n || a || f || "呼叫未建立";
|
|
10639
10639
|
return {
|
|
10640
10640
|
source: "invite-response",
|
|
10641
10641
|
stage: e,
|
|
10642
10642
|
status: s,
|
|
10643
10643
|
reason: r,
|
|
10644
10644
|
warning: n,
|
|
10645
|
-
cause:
|
|
10645
|
+
cause: a,
|
|
10646
10646
|
retryAfter: d,
|
|
10647
10647
|
body: f,
|
|
10648
10648
|
message: w,
|
|
@@ -10833,13 +10833,13 @@ class ui {
|
|
|
10833
10833
|
s.fftSize = 2048;
|
|
10834
10834
|
const r = new Uint8Array(s.fftSize);
|
|
10835
10835
|
i.connect(s);
|
|
10836
|
-
const n = typeof this.onAudioFrame == "function",
|
|
10836
|
+
const n = typeof this.onAudioFrame == "function", a = () => {
|
|
10837
10837
|
s.getByteTimeDomainData(r);
|
|
10838
10838
|
let f = 0;
|
|
10839
10839
|
const h = n ? new Float32Array(r.length) : null;
|
|
10840
|
-
for (let
|
|
10841
|
-
const E = (r[
|
|
10842
|
-
f += E * E, h && (h[
|
|
10840
|
+
for (let I = 0; I < r.length; I += 1) {
|
|
10841
|
+
const E = (r[I] - 128) / 128;
|
|
10842
|
+
f += E * E, h && (h[I] = E);
|
|
10843
10843
|
}
|
|
10844
10844
|
const w = Math.sqrt(f / r.length), S = Math.min(1, w * 2);
|
|
10845
10845
|
if (this.onAudioLevel && this.onAudioLevel(e, S), h && this.audioContext && this.onAudioFrame)
|
|
@@ -10851,13 +10851,13 @@ class ui {
|
|
|
10851
10851
|
});
|
|
10852
10852
|
} catch {
|
|
10853
10853
|
}
|
|
10854
|
-
const
|
|
10855
|
-
|
|
10854
|
+
const _ = this.audioMonitors[e];
|
|
10855
|
+
_ && (_.rafId = window.requestAnimationFrame(a));
|
|
10856
10856
|
}, d = {
|
|
10857
10857
|
source: i,
|
|
10858
10858
|
analyser: s,
|
|
10859
10859
|
dataArray: r,
|
|
10860
|
-
rafId: window.requestAnimationFrame(
|
|
10860
|
+
rafId: window.requestAnimationFrame(a)
|
|
10861
10861
|
};
|
|
10862
10862
|
this.audioMonitors[e] = d;
|
|
10863
10863
|
} catch (i) {
|
|
@@ -10930,20 +10930,20 @@ class ui {
|
|
|
10930
10930
|
this._ensureAudioContext();
|
|
10931
10931
|
const r = () => {
|
|
10932
10932
|
typeof t == "function" && t(), s && this._removePendingPlaybackTask(s);
|
|
10933
|
-
}, n = (
|
|
10934
|
-
if (this._shouldUnlock(
|
|
10933
|
+
}, n = (a) => {
|
|
10934
|
+
if (this._shouldUnlock(a) && s) {
|
|
10935
10935
|
this._requestAutoplayUnlock(s, () => {
|
|
10936
10936
|
this._attemptPlayAudio(e, { onSuccess: t, onError: i, unlockKey: s });
|
|
10937
10937
|
});
|
|
10938
10938
|
return;
|
|
10939
10939
|
}
|
|
10940
|
-
typeof i == "function" && i(
|
|
10940
|
+
typeof i == "function" && i(a);
|
|
10941
10941
|
};
|
|
10942
10942
|
try {
|
|
10943
|
-
const
|
|
10944
|
-
|
|
10945
|
-
} catch (
|
|
10946
|
-
n(
|
|
10943
|
+
const a = e.play();
|
|
10944
|
+
a && typeof a.then == "function" ? a.then(() => r()).catch((d) => n(d)) : r();
|
|
10945
|
+
} catch (a) {
|
|
10946
|
+
n(a);
|
|
10947
10947
|
}
|
|
10948
10948
|
return !0;
|
|
10949
10949
|
}
|
|
@@ -11052,54 +11052,54 @@ class ui {
|
|
|
11052
11052
|
this.audioContext = null;
|
|
11053
11053
|
}
|
|
11054
11054
|
}
|
|
11055
|
-
const
|
|
11056
|
-
function
|
|
11057
|
-
const t = String(
|
|
11055
|
+
const fi = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
11056
|
+
function pi(o, e = "") {
|
|
11057
|
+
const t = String(o || e || "").trim();
|
|
11058
11058
|
if (!t)
|
|
11059
11059
|
throw new Error("缺少统一服务基址");
|
|
11060
11060
|
return t;
|
|
11061
11061
|
}
|
|
11062
|
-
function
|
|
11063
|
-
return
|
|
11062
|
+
function yt(o, e = "https://") {
|
|
11063
|
+
return fi.test(o) ? o : `${e}${o.replace(/^\/+/, "")}`;
|
|
11064
11064
|
}
|
|
11065
|
-
function
|
|
11066
|
-
return
|
|
11065
|
+
function bt(o = "/") {
|
|
11066
|
+
return o.endsWith("/") ? o : `${o}/`;
|
|
11067
11067
|
}
|
|
11068
|
-
function
|
|
11069
|
-
const t =
|
|
11068
|
+
function vt(o = "/", e = "") {
|
|
11069
|
+
const t = bt(o || "/"), i = String(e || "").replace(/^\/+/, "");
|
|
11070
11070
|
return i ? `${t}${i}` : t;
|
|
11071
11071
|
}
|
|
11072
|
-
function ke(
|
|
11073
|
-
const t =
|
|
11074
|
-
return i.search = "", i.hash = "", i.pathname =
|
|
11072
|
+
function ke(o, e = "") {
|
|
11073
|
+
const t = yt(pi(o, e)), i = new URL(t);
|
|
11074
|
+
return i.search = "", i.hash = "", i.pathname = bt(i.pathname || "/"), i;
|
|
11075
11075
|
}
|
|
11076
|
-
function
|
|
11077
|
-
return ke(
|
|
11076
|
+
function mi(o, e = "") {
|
|
11077
|
+
return ke(o, e).pathname !== "/";
|
|
11078
11078
|
}
|
|
11079
|
-
function z(
|
|
11080
|
-
const i = ke(
|
|
11081
|
-
return i.pathname =
|
|
11079
|
+
function z(o, e, t = "") {
|
|
11080
|
+
const i = ke(o, t);
|
|
11081
|
+
return i.pathname = vt(i.pathname, e), i.href;
|
|
11082
11082
|
}
|
|
11083
|
-
function Le(
|
|
11084
|
-
const i = ke(
|
|
11085
|
-
return i.protocol === "https:" ? i.protocol = "wss:" : i.protocol === "http:" ? i.protocol = "ws:" : i.protocol !== "ws:" && i.protocol !== "wss:" && (i.protocol = "wss:"), i.pathname =
|
|
11083
|
+
function Le(o, e = "ws", t = "") {
|
|
11084
|
+
const i = ke(o, t);
|
|
11085
|
+
return i.protocol === "https:" ? i.protocol = "wss:" : i.protocol === "http:" ? i.protocol = "ws:" : i.protocol !== "ws:" && i.protocol !== "wss:" && (i.protocol = "wss:"), i.pathname = vt(i.pathname, e), i.href;
|
|
11086
11086
|
}
|
|
11087
|
-
function it(
|
|
11088
|
-
if (!String(
|
|
11087
|
+
function it(o, e = "") {
|
|
11088
|
+
if (!String(o || "").trim())
|
|
11089
11089
|
return String(e || "").replace(/^\/+/, "");
|
|
11090
|
-
const t = new URL(
|
|
11090
|
+
const t = new URL(yt(String(o).trim())), i = String(t.pathname || "/").replace(/^\/+/, ""), s = String(t.search || "");
|
|
11091
11091
|
return `${i}${s}` || String(e || "").replace(/^\/+/, "");
|
|
11092
11092
|
}
|
|
11093
11093
|
function st({
|
|
11094
|
-
apiBaseUrl:
|
|
11094
|
+
apiBaseUrl: o,
|
|
11095
11095
|
transportBaseUrl: e = "",
|
|
11096
11096
|
transportUrl: t = "",
|
|
11097
11097
|
fallbackPath: i = "ws"
|
|
11098
11098
|
}) {
|
|
11099
11099
|
const s = String(e || "").trim();
|
|
11100
|
-
return s ? Le(s, it(t, i)) :
|
|
11100
|
+
return s ? Le(s, it(t, i)) : mi(o) ? Le(o, it(t, i)) : String(t || "").trim() ? String(t).trim() : Le(o, i);
|
|
11101
11101
|
}
|
|
11102
|
-
const
|
|
11102
|
+
const wi = `
|
|
11103
11103
|
:host { all: initial; }
|
|
11104
11104
|
.widget { font-family: "Noto Sans SC", "PingFang SC", sans-serif; color: #16302b; }
|
|
11105
11105
|
.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); }
|
|
@@ -11147,57 +11147,64 @@ const mi = `
|
|
|
11147
11147
|
rejected: "本次来电已拒接,widget 仍保持待机。",
|
|
11148
11148
|
missed: "本次来电未接听,widget 仍保持待机。",
|
|
11149
11149
|
failed: "本次呼叫失败,请先看下方日志。"
|
|
11150
|
-
},
|
|
11150
|
+
}, yi = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", bi = 5e3, vi = 15e3, rt = 2, we = 3e4, Si = 1200, Ti = 3e4, Ci = 4e3, Ce = {
|
|
11151
11151
|
ready: "线路可用",
|
|
11152
11152
|
preparing: "正在准备",
|
|
11153
11153
|
working: "通话处理中",
|
|
11154
11154
|
recovering: "正在恢复",
|
|
11155
11155
|
offline: "当前离线"
|
|
11156
11156
|
};
|
|
11157
|
-
function
|
|
11158
|
-
return e ? `${
|
|
11159
|
-
${JSON.stringify(e, null, 2)}` :
|
|
11157
|
+
function Ei(o, e) {
|
|
11158
|
+
return e ? `${o}
|
|
11159
|
+
${JSON.stringify(e, null, 2)}` : o;
|
|
11160
11160
|
}
|
|
11161
|
-
function
|
|
11162
|
-
t != null && (typeof t == "string" && t.trim() === "" || (
|
|
11161
|
+
function $(o, e, t) {
|
|
11162
|
+
t != null && (typeof t == "string" && t.trim() === "" || (o[e] = t));
|
|
11163
11163
|
}
|
|
11164
|
-
function
|
|
11165
|
-
return
|
|
11164
|
+
function Ri(o) {
|
|
11165
|
+
return o === "outbound" ? "outbound" : "terminal";
|
|
11166
11166
|
}
|
|
11167
|
-
function
|
|
11168
|
-
return typeof
|
|
11167
|
+
function xi(o) {
|
|
11168
|
+
return typeof o == "function";
|
|
11169
11169
|
}
|
|
11170
|
-
function
|
|
11170
|
+
function _i() {
|
|
11171
11171
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("embeddedCallWidgetE2E") === "1";
|
|
11172
11172
|
}
|
|
11173
11173
|
function Ii() {
|
|
11174
11174
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `widget-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
11175
11175
|
}
|
|
11176
|
-
function Be(
|
|
11177
|
-
const e = String(
|
|
11176
|
+
function Be(o) {
|
|
11177
|
+
const e = String(o?.message || o || "");
|
|
11178
11178
|
return /Failed to fetch|NetworkError|Load failed|network/i.test(e);
|
|
11179
11179
|
}
|
|
11180
|
-
function ie(
|
|
11181
|
-
const t =
|
|
11180
|
+
function ie(o = {}, e = null) {
|
|
11181
|
+
const t = o?.advanced && typeof o.advanced == "object" ? o.advanced : {}, i = String(t.visitorBusinessKey ?? "").trim();
|
|
11182
11182
|
if (i)
|
|
11183
11183
|
return i;
|
|
11184
|
-
const s = String(
|
|
11184
|
+
const s = String(o?.businessKey ?? "").trim();
|
|
11185
11185
|
return s || "";
|
|
11186
11186
|
}
|
|
11187
|
-
function
|
|
11188
|
-
const e = new Error(
|
|
11187
|
+
function Ai(o) {
|
|
11188
|
+
const e = new Error(o);
|
|
11189
11189
|
return e.name = "EmbeddedCallWidgetLifecycleCancelledError", e.code = "widget_runtime_run_stale", e;
|
|
11190
11190
|
}
|
|
11191
|
-
function nt(
|
|
11192
|
-
return
|
|
11191
|
+
function nt(o) {
|
|
11192
|
+
return o?.code === "sip_client_replaced" || o?.code === "widget_runtime_run_stale";
|
|
11193
11193
|
}
|
|
11194
|
-
|
|
11194
|
+
function $i(o, e = {}) {
|
|
11195
|
+
const t = new Error(o);
|
|
11196
|
+
return t.name = "EmbeddedCallWidgetProtocolViolationError", t.code = "widget_protocol_violation", t.detail = e, t;
|
|
11197
|
+
}
|
|
11198
|
+
function ot(o) {
|
|
11199
|
+
return o?.code === "widget_protocol_violation";
|
|
11200
|
+
}
|
|
11201
|
+
class Di {
|
|
11195
11202
|
constructor({ mount: e, shadowRoot: t, options: i }) {
|
|
11196
|
-
this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode =
|
|
11203
|
+
this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = Ri(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = ke(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 = _i(), this.terminalFailureOverride = "", this.presenceId = Ii(), this.presenceTouchTimer = null, this.presenceFailureCount = 0, this.availabilityState = "preparing", this.availabilityDetail = "正在连接后台并准备网页电话待机。", this.connectivityRecoveryInFlight = null, this.lifecycleRunId = 0, this.pendingLifecycleMode = null, this.expectedClientTeardown = null, this.expectedTermination = null, this.autoStandbyRecoveryTimer = null, this.recentlyReleasedSessions = /* @__PURE__ */ new Map(), 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.beforeUnloadHandler = null, this.pageHideHandler = null, this.unloadCleanupStarted = !1, this.refs = {};
|
|
11197
11204
|
}
|
|
11198
11205
|
async mount() {
|
|
11199
11206
|
this.isMobileViewport = typeof window < "u" && window.matchMedia("(max-width: 480px)").matches, this.shadowRoot.innerHTML = `
|
|
11200
|
-
<style>${
|
|
11207
|
+
<style>${wi}</style>
|
|
11201
11208
|
<section class="widget">
|
|
11202
11209
|
<div class="panel">
|
|
11203
11210
|
<div class="hero">
|
|
@@ -11262,11 +11269,11 @@ class Ai {
|
|
|
11262
11269
|
}
|
|
11263
11270
|
assertLifecycleRunCurrent(e) {
|
|
11264
11271
|
if (e !== this.lifecycleRunId)
|
|
11265
|
-
throw
|
|
11272
|
+
throw Ai("网页电话已切换到新的连接流程,旧流程不再继续。");
|
|
11266
11273
|
}
|
|
11267
11274
|
emitHostCallback(e, t) {
|
|
11268
11275
|
const i = this.options?.[e];
|
|
11269
|
-
if (
|
|
11276
|
+
if (xi(i))
|
|
11270
11277
|
try {
|
|
11271
11278
|
i(t);
|
|
11272
11279
|
} catch (s) {
|
|
@@ -11365,7 +11372,9 @@ class Ai {
|
|
|
11365
11372
|
return;
|
|
11366
11373
|
const e = this.beginLifecycleRun();
|
|
11367
11374
|
try {
|
|
11368
|
-
this.terminalFailureOverride = "", this.clearAutoStandbyRecovery(), this.pendingLifecycleMode = "outbound", this.setAvailabilityState("working", "正在建立呼叫链路。")
|
|
11375
|
+
this.terminalFailureOverride = "", this.clearAutoStandbyRecovery(), this.pendingLifecycleMode = "outbound", this.setAvailabilityState("working", "正在建立呼叫链路。");
|
|
11376
|
+
const t = this.issuedSession?.session_mode === "widget_standby" && (this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username) || null;
|
|
11377
|
+
!this.legacyOutboundOnly && this.issuedSession?.session_mode === "widget_standby" && (this.appendLog("访客主动呼叫前,先释放当前待机会话并切换到呼叫链路。", {
|
|
11369
11378
|
widget_anchor_number: this.issuedSession?.widget_anchor_number || null,
|
|
11370
11379
|
resolved_business_key: this.issuedSession?.resolved_business_key || ie(this.options) || null
|
|
11371
11380
|
}), await this.disconnectAndCleanup("switch-to-outbound-call", {
|
|
@@ -11373,10 +11382,12 @@ class Ai {
|
|
|
11373
11382
|
suppressStateReset: !0,
|
|
11374
11383
|
suppressClientTeardownState: "switch-to-outbound-call"
|
|
11375
11384
|
}), this.assertLifecycleRunCurrent(e)), this.setState("requesting"), await this.loadBootstrap(), this.assertLifecycleRunCurrent(e), this.turnIceServers = await this.fetchTurnIceServers(), this.assertLifecycleRunCurrent(e);
|
|
11376
|
-
const
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11385
|
+
const i = await this.fetchIssuedSession({
|
|
11386
|
+
preferredBrowserSipUsername: t
|
|
11387
|
+
});
|
|
11388
|
+
this.assertLifecycleRunCurrent(e), await this.ensureClient(i), this.assertLifecycleRunCurrent(e), this.setState("registering"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(e), this.setState("calling"), this.syncAvailabilityState(), await this.client.call(i.target), this.assertLifecycleRunCurrent(e), this.appendLog("已发起呼叫", {
|
|
11389
|
+
target: i.target,
|
|
11390
|
+
route_note: i.routeNote || null
|
|
11380
11391
|
});
|
|
11381
11392
|
} catch (t) {
|
|
11382
11393
|
if (this.pendingLifecycleMode = null, nt(t)) {
|
|
@@ -11430,7 +11441,7 @@ class Ai {
|
|
|
11430
11441
|
webrtc_url: e.transport,
|
|
11431
11442
|
ice_servers: this.turnIceServers
|
|
11432
11443
|
};
|
|
11433
|
-
this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new
|
|
11444
|
+
this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new gi(t, {
|
|
11434
11445
|
remoteAudioElement: this.refs.audio,
|
|
11435
11446
|
onStateChange: (i, s) => {
|
|
11436
11447
|
this.handleClientState(i, s);
|
|
@@ -11619,56 +11630,58 @@ class Ai {
|
|
|
11619
11630
|
const t = await e.json();
|
|
11620
11631
|
return Array.isArray(t?.ice_servers) ? t.ice_servers : [];
|
|
11621
11632
|
}
|
|
11622
|
-
async fetchIssuedSession() {
|
|
11623
|
-
const
|
|
11633
|
+
async fetchIssuedSession(e = {}) {
|
|
11634
|
+
const {
|
|
11635
|
+
preferredBrowserSipUsername: t = null
|
|
11636
|
+
} = e, i = ie(this.options), s = {
|
|
11624
11637
|
page_url: window.location.href
|
|
11625
11638
|
};
|
|
11626
|
-
|
|
11627
|
-
const
|
|
11639
|
+
$(s, "site_key", this.options.siteKey), $(s, "standby_state", this.options.standbyState), $(s, "selected_primary_account", this.options.selectedPrimaryAccount), $(s, "selected_middle_layer_account", this.options.selectedMiddleLayerAccount), $(s, "preferred_browser_sip_username", t), $(s, "display_name", this.options.displayName), $(s, "access_token", this.options.accessToken), i && (s.business_key = i);
|
|
11640
|
+
const r = await fetch(z(this.apiBaseUrl, "api/sip/issue-call-session"), {
|
|
11628
11641
|
method: "POST",
|
|
11629
11642
|
credentials: "include",
|
|
11630
11643
|
cache: "no-store",
|
|
11631
11644
|
headers: { "Content-Type": "application/json" },
|
|
11632
|
-
body: JSON.stringify(
|
|
11645
|
+
body: JSON.stringify(s)
|
|
11633
11646
|
});
|
|
11634
|
-
if (!
|
|
11635
|
-
const
|
|
11636
|
-
throw new Error(
|
|
11637
|
-
}
|
|
11638
|
-
const
|
|
11639
|
-
return this.issuedSession =
|
|
11640
|
-
sessionId:
|
|
11641
|
-
targetExtension:
|
|
11642
|
-
dialTargetExtension:
|
|
11643
|
-
resolvedTargetInternalNumbers:
|
|
11644
|
-
resolvedBusinessKey:
|
|
11647
|
+
if (!r.ok) {
|
|
11648
|
+
const a = await r.json().catch(() => ({}));
|
|
11649
|
+
throw new Error(a?.detail || `会话签发失败:${r.status}`);
|
|
11650
|
+
}
|
|
11651
|
+
const n = await r.json();
|
|
11652
|
+
return this.issuedSession = n, this.reportIssuedSessionEvent("issued-session-fetched", {
|
|
11653
|
+
sessionId: n.session_id,
|
|
11654
|
+
targetExtension: n.target_extension,
|
|
11655
|
+
dialTargetExtension: n.dial_target_extension || n.target_extension,
|
|
11656
|
+
resolvedTargetInternalNumbers: n.resolved_target_internal_numbers || [],
|
|
11657
|
+
resolvedBusinessKey: n.resolved_business_key || null
|
|
11645
11658
|
}, "requesting"), this.appendLog("已获取服务端签发会话", {
|
|
11646
|
-
session_id:
|
|
11647
|
-
target_extension:
|
|
11648
|
-
dial_target_extension:
|
|
11649
|
-
resolved_target_internal_numbers:
|
|
11650
|
-
resolved_business_key:
|
|
11651
|
-
resolved_route_mode:
|
|
11652
|
-
route_note:
|
|
11659
|
+
session_id: n.session_id,
|
|
11660
|
+
target_extension: n.target_extension,
|
|
11661
|
+
dial_target_extension: n.dial_target_extension || n.target_extension || null,
|
|
11662
|
+
resolved_target_internal_numbers: n.resolved_target_internal_numbers || [],
|
|
11663
|
+
resolved_business_key: n.resolved_business_key || null,
|
|
11664
|
+
resolved_route_mode: n.resolved_route_mode || null,
|
|
11665
|
+
route_note: n.route_note || null
|
|
11653
11666
|
}), {
|
|
11654
|
-
sessionMode:
|
|
11655
|
-
sipUsername:
|
|
11656
|
-
sipDomain:
|
|
11657
|
-
password:
|
|
11667
|
+
sessionMode: n.session_mode || "outbound",
|
|
11668
|
+
sipUsername: n.sip_username,
|
|
11669
|
+
sipDomain: n.sip_domain,
|
|
11670
|
+
password: n.sip_password,
|
|
11658
11671
|
transport: st({
|
|
11659
11672
|
apiBaseUrl: this.apiBaseUrl,
|
|
11660
11673
|
transportBaseUrl: this.options.transportBaseUrl || "",
|
|
11661
|
-
transportUrl:
|
|
11674
|
+
transportUrl: n.ws_server
|
|
11662
11675
|
}),
|
|
11663
|
-
target:
|
|
11664
|
-
routeNote:
|
|
11676
|
+
target: n.dial_target_extension || n.target_extension,
|
|
11677
|
+
routeNote: n.route_note || ""
|
|
11665
11678
|
};
|
|
11666
11679
|
}
|
|
11667
11680
|
async fetchStandbySession() {
|
|
11668
11681
|
const e = ie(this.options) || null, t = {
|
|
11669
11682
|
page_url: window.location.href
|
|
11670
11683
|
};
|
|
11671
|
-
|
|
11684
|
+
$(t, "site_key", this.options.siteKey), $(t, "standby_state", this.options.standbyState), $(t, "selected_primary_account", this.options.selectedPrimaryAccount), $(t, "selected_middle_layer_account", this.options.selectedMiddleLayerAccount), $(t, "display_name", this.options.displayName), $(t, "access_token", this.options.accessToken), e && (t.business_key = e);
|
|
11672
11685
|
const i = await fetch(z(this.apiBaseUrl, "api/sip/issue-widget-standby-session"), {
|
|
11673
11686
|
method: "POST",
|
|
11674
11687
|
credentials: "include",
|
|
@@ -11781,7 +11794,7 @@ class Ai {
|
|
|
11781
11794
|
setAvailabilityState(e, t = "") {
|
|
11782
11795
|
this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${Ce[e] || Ce.recovering} · ${t}` : Ce[e] || Ce.recovering, this.refs.availability.className = `availability availability--${e}`), this.render();
|
|
11783
11796
|
}
|
|
11784
|
-
suppressExpectedClientTeardown(e, t =
|
|
11797
|
+
suppressExpectedClientTeardown(e, t = Ci) {
|
|
11785
11798
|
this.expectedClientTeardown = {
|
|
11786
11799
|
reason: e,
|
|
11787
11800
|
expiresAt: Date.now() + t
|
|
@@ -11807,7 +11820,7 @@ class Ai {
|
|
|
11807
11820
|
clearAutoStandbyRecovery() {
|
|
11808
11821
|
this.autoStandbyRecoveryTimer && (window.clearTimeout(this.autoStandbyRecoveryTimer), this.autoStandbyRecoveryTimer = null);
|
|
11809
11822
|
}
|
|
11810
|
-
scheduleAutoStandbyRecovery(e, t =
|
|
11823
|
+
scheduleAutoStandbyRecovery(e, t = Si) {
|
|
11811
11824
|
this.legacyOutboundOnly || this.networkOnline === !1 || this.autoStandbyRecoveryTimer || this.client || this.issuedSession?.session_id || this.finalizing || this.pendingLifecycleMode === "outbound" || this.sessionRecoveryInFlight || this.connectivityRecoveryInFlight || ["requesting", "standbyRequesting", "registering", "calling", "incoming", "connected"].includes(this.state) || (this.autoStandbyRecoveryTimer = window.setTimeout(() => {
|
|
11812
11825
|
this.autoStandbyRecoveryTimer = null, !(this.legacyOutboundOnly || this.networkOnline === !1) && (this.client || this.issuedSession?.session_id || this.finalizing || this.pendingLifecycleMode === "outbound" || (this.appendLog("检测到页面当前不在通话中,开始自动进入待机。", { reason: e }), this.startStandby({ force: !0 })));
|
|
11813
11826
|
}, t));
|
|
@@ -11820,7 +11833,7 @@ class Ai {
|
|
|
11820
11833
|
markRecentlyReleasedSession(e, t) {
|
|
11821
11834
|
e && (this.pruneRecentlyReleasedSessions(), this.recentlyReleasedSessions.set(e, {
|
|
11822
11835
|
reason: t,
|
|
11823
|
-
expiresAt: Date.now() +
|
|
11836
|
+
expiresAt: Date.now() + Ti
|
|
11824
11837
|
}));
|
|
11825
11838
|
}
|
|
11826
11839
|
wasSessionRecentlyReleased(e) {
|
|
@@ -11881,21 +11894,56 @@ class Ai {
|
|
|
11881
11894
|
}
|
|
11882
11895
|
}
|
|
11883
11896
|
async handleServerSessionAction(e, t = {}) {
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11897
|
+
if (this.legacyOutboundOnly)
|
|
11898
|
+
return !1;
|
|
11899
|
+
const i = String(t?.session_action || "").trim().toLowerCase();
|
|
11900
|
+
if (i !== "restart_standby" || this.sessionRecoveryInFlight || this.connectivityRecoveryInFlight)
|
|
11901
|
+
return !1;
|
|
11902
|
+
const s = String(this.issuedSession?.session_mode || "").trim(), r = String(this.pendingLifecycleMode || "").trim();
|
|
11903
|
+
if (s === "outbound" || r === "outbound")
|
|
11904
|
+
throw $i("非待机会话收到了非法的 restart_standby 指令。", {
|
|
11905
|
+
source: e,
|
|
11906
|
+
state: this.state,
|
|
11907
|
+
local_session_mode: s || null,
|
|
11908
|
+
local_lifecycle_mode: r || null,
|
|
11909
|
+
session_action: i,
|
|
11910
|
+
session_action_reason: t?.session_action_reason || null,
|
|
11911
|
+
session_action_detail: t?.session_action_detail || null,
|
|
11912
|
+
resolved_session_id: t?.resolved_session_id || null,
|
|
11913
|
+
resolved_widget_anchor_number: t?.resolved_widget_anchor_number || null,
|
|
11914
|
+
resolved_browser_sip_username: t?.resolved_browser_sip_username || null
|
|
11915
|
+
});
|
|
11916
|
+
this.sessionRecoveryInFlight = (async () => {
|
|
11917
|
+
this.appendLog("服务端要求当前页面立即放弃旧锚点并重建待机。", {
|
|
11918
|
+
source: e,
|
|
11919
|
+
state: this.state,
|
|
11920
|
+
local_session_mode: s || null,
|
|
11921
|
+
local_lifecycle_mode: r || null,
|
|
11922
|
+
session_action_reason: t?.session_action_reason || null,
|
|
11923
|
+
session_action_detail: t?.session_action_detail || null,
|
|
11924
|
+
resolved_session_id: t?.resolved_session_id || null,
|
|
11925
|
+
resolved_widget_anchor_number: t?.resolved_widget_anchor_number || null,
|
|
11926
|
+
resolved_browser_sip_username: t?.resolved_browser_sip_username || null
|
|
11927
|
+
}), this.setAvailabilityState("recovering", t?.session_action_detail || "当前锚点已失效,正在自动切换到新的待机线路。"), (this.client || this.issuedSession?.session_id) && await this.disconnectAndCleanup(`server-session-action-${t?.session_action_reason || e}`, {
|
|
11928
|
+
preserveLifecycleRun: !0,
|
|
11929
|
+
suppressStateReset: !0
|
|
11930
|
+
}), await this.startStandby({ force: !0 });
|
|
11931
|
+
})();
|
|
11932
|
+
try {
|
|
11933
|
+
await this.sessionRecoveryInFlight;
|
|
11934
|
+
} finally {
|
|
11935
|
+
this.sessionRecoveryInFlight = null;
|
|
11936
|
+
}
|
|
11937
|
+
return !0;
|
|
11938
|
+
}
|
|
11939
|
+
async handleProtocolViolation(e) {
|
|
11940
|
+
const t = e?.detail && typeof e.detail == "object" ? e.detail : {}, i = {
|
|
11941
|
+
violation_code: e?.code || "widget_protocol_violation",
|
|
11942
|
+
violation_name: e?.name || "EmbeddedCallWidgetProtocolViolationError",
|
|
11943
|
+
violation_message: e?.message || String(e),
|
|
11944
|
+
...t
|
|
11945
|
+
};
|
|
11946
|
+
this.appendLog("协议错误:当前页面收到了非法的运行态指令,已拒绝执行并保留现有通话状态。", i), typeof console < "u" && typeof console.error == "function" && console.error("[embedded-call-widget] protocol violation", i), await this.reportIssuedSessionEvent("protocol-violation", i);
|
|
11899
11947
|
}
|
|
11900
11948
|
async touchWidgetPresence(e = "interval") {
|
|
11901
11949
|
if (this.legacyOutboundOnly)
|
|
@@ -11918,15 +11966,15 @@ class Ai {
|
|
|
11918
11966
|
network_online: this.networkOnline,
|
|
11919
11967
|
client_summary: this.buildPresenceEvidenceSummary(this.state, { trigger: e })
|
|
11920
11968
|
};
|
|
11921
|
-
return
|
|
11969
|
+
return $(n, "site_key", this.options.siteKey), $(n, "requested_business_key", ie(this.options)), $(n, "resolved_business_key", this.issuedSession?.resolved_business_key), $(n, "display_name", this.options.displayName), $(n, "session_id", this.issuedSession?.session_id), $(n, "session_mode", this.issuedSession?.session_mode), $(n, "widget_anchor_number", this.issuedSession?.widget_anchor_number), $(
|
|
11922
11970
|
n,
|
|
11923
11971
|
"browser_sip_username",
|
|
11924
11972
|
this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username
|
|
11925
|
-
),
|
|
11973
|
+
), $(n, "standby_mode", this.issuedSession?.standby_mode), $(
|
|
11926
11974
|
n,
|
|
11927
11975
|
"standby_state",
|
|
11928
11976
|
this.issuedSession?.standby_state || this.options.standbyState
|
|
11929
|
-
),
|
|
11977
|
+
), $(n, "selected_primary_account", this.options.selectedPrimaryAccount), $(n, "selected_middle_layer_account", this.options.selectedMiddleLayerAccount), $(n, "route_note", this.issuedSession?.route_note), n;
|
|
11930
11978
|
})())
|
|
11931
11979
|
});
|
|
11932
11980
|
if (!i.ok)
|
|
@@ -11934,6 +11982,10 @@ class Ai {
|
|
|
11934
11982
|
const s = await i.json().catch(() => ({}));
|
|
11935
11983
|
this.presenceFailureCount = 0, await this.handleServerSessionAction("touch-widget-presence", s) || this.syncAvailabilityState(), t && await this.restartStandbyAfterConnectivity(`presence-${e}`);
|
|
11936
11984
|
} catch (i) {
|
|
11985
|
+
if (ot(i)) {
|
|
11986
|
+
await this.handleProtocolViolation(i), this.syncAvailabilityState();
|
|
11987
|
+
return;
|
|
11988
|
+
}
|
|
11937
11989
|
if (this.presenceFailureCount += 1, this.networkOnline === !1 || Be(i) || this.presenceFailureCount >= rt) {
|
|
11938
11990
|
const r = this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。";
|
|
11939
11991
|
this.setAvailabilityState("offline", r);
|
|
@@ -11949,7 +12001,7 @@ class Ai {
|
|
|
11949
12001
|
startPresenceTouch() {
|
|
11950
12002
|
this.legacyOutboundOnly || (this.touchWidgetPresence("mount"), this.presenceTouchTimer || (this.presenceTouchTimer = window.setInterval(() => {
|
|
11951
12003
|
this.touchWidgetPresence("interval");
|
|
11952
|
-
},
|
|
12004
|
+
}, vi)));
|
|
11953
12005
|
}
|
|
11954
12006
|
async touchIssuedSession(e, t = null) {
|
|
11955
12007
|
if (!this.issuedSession?.session_id)
|
|
@@ -11975,6 +12027,10 @@ class Ai {
|
|
|
11975
12027
|
const r = await s.json().catch(() => ({}));
|
|
11976
12028
|
await this.handleServerSessionAction("touch-call-session", r);
|
|
11977
12029
|
} catch (s) {
|
|
12030
|
+
if (ot(s)) {
|
|
12031
|
+
await this.handleProtocolViolation(s);
|
|
12032
|
+
return;
|
|
12033
|
+
}
|
|
11978
12034
|
if (s?.status === 404 && this.wasSessionRecentlyReleased(i))
|
|
11979
12035
|
return;
|
|
11980
12036
|
this.appendLog("网页通话会话心跳失败", {
|
|
@@ -12003,7 +12059,7 @@ class Ai {
|
|
|
12003
12059
|
if (!this.issuedSession?.session_id)
|
|
12004
12060
|
return;
|
|
12005
12061
|
const s = this.issuedSession.session_id, r = i || this.state;
|
|
12006
|
-
let n = null,
|
|
12062
|
+
let n = null, a = "";
|
|
12007
12063
|
try {
|
|
12008
12064
|
const d = await fetch(z(this.apiBaseUrl, "api/sip/report-call-session-event"), {
|
|
12009
12065
|
method: "POST",
|
|
@@ -12022,7 +12078,7 @@ class Ai {
|
|
|
12022
12078
|
if (!d.ok) {
|
|
12023
12079
|
n = d.status;
|
|
12024
12080
|
const f = await d.json().catch(() => ({}));
|
|
12025
|
-
throw
|
|
12081
|
+
throw a = f?.detail ? String(f.detail) : "", new Error(a || `事件留证失败:${d.status}`);
|
|
12026
12082
|
}
|
|
12027
12083
|
} catch (d) {
|
|
12028
12084
|
await fetch(z(this.apiBaseUrl, "api/sip/report-call-session-event-delivery-failure"), {
|
|
@@ -12039,7 +12095,7 @@ class Ai {
|
|
|
12039
12095
|
detail: this.buildClientEvidenceSummary(r, t),
|
|
12040
12096
|
delivery_error: {
|
|
12041
12097
|
status: typeof n == "number" ? n : null,
|
|
12042
|
-
detail:
|
|
12098
|
+
detail: a || "",
|
|
12043
12099
|
message: d?.message || String(d)
|
|
12044
12100
|
}
|
|
12045
12101
|
})
|
|
@@ -12062,14 +12118,14 @@ class Ai {
|
|
|
12062
12118
|
}
|
|
12063
12119
|
this.touchIssuedSession(e), this.sessionTouchTimer || (this.sessionTouchTimer = window.setInterval(() => {
|
|
12064
12120
|
this.touchIssuedSession(this.state);
|
|
12065
|
-
},
|
|
12121
|
+
}, bi));
|
|
12066
12122
|
}
|
|
12067
12123
|
setState(e, t = "") {
|
|
12068
12124
|
this.state = e, this.refs.status.textContent = t || ee[e] || ee.idle, this.syncAvailabilityState(), this.render(), this.emitHostCallback("onStateChange", this.getSnapshot());
|
|
12069
12125
|
}
|
|
12070
12126
|
appendLog(e, t) {
|
|
12071
12127
|
const i = document.createElement("div");
|
|
12072
|
-
for (i.className = "log", i.textContent =
|
|
12128
|
+
for (i.className = "log", i.textContent = Ei(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
|
|
12073
12129
|
this.refs.logs.lastElementChild?.remove();
|
|
12074
12130
|
}
|
|
12075
12131
|
render() {
|
|
@@ -12078,19 +12134,19 @@ class Ai {
|
|
|
12078
12134
|
"status",
|
|
12079
12135
|
this.availabilityState === "offline" ? "status--offline" : this.availabilityState === "recovering" ? "status--recovering" : ""
|
|
12080
12136
|
].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 || s || this.state === "connected", this.state === "incoming" ? this.refs.primary.textContent = "接听来电" : this.state === "connected" ? this.refs.primary.textContent = "通话进行中" : e || s ? this.availabilityState === "working" ? this.refs.primary.textContent = "正在建立呼叫" : this.availabilityState === "preparing" ? this.refs.primary.textContent = "正在准备网页电话" : 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" ? "挂断通话" : "断开电话");
|
|
12081
|
-
const r = String(this.options.siteKey || "").trim(), n = String(this.bootstrap?.default_site_key || "").trim(),
|
|
12082
|
-
this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${h};站点键:${f}` : this.refs.meta.textContent = `站点键:${f};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${h}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.state === "incoming" ? this.refs.hint.textContent = "当前已有来电,直接接听或拒接即可;处理完成后会自动回到待机。" : this.state === "connected" ? this.refs.hint.textContent = "当前通话已接通,挂断后会自动回到待机,不需要额外刷新页面。" : this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ?
|
|
12137
|
+
const r = String(this.options.siteKey || "").trim(), n = String(this.bootstrap?.default_site_key || "").trim(), a = String(ie(this.options) || "").trim(), d = String(this.bootstrap?.default_business_key || "").trim(), f = r || (n ? `${n}(服务端默认站点)` : "等待服务端解析"), h = this.issuedSession?.resolved_business_key || a || (d ? `${d}(服务端默认规则)` : "等待服务端解析");
|
|
12138
|
+
this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${h};站点键:${f}` : this.refs.meta.textContent = `站点键:${f};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${h}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.state === "incoming" ? this.refs.hint.textContent = "当前已有来电,直接接听或拒接即可;处理完成后会自动回到待机。" : this.state === "connected" ? this.refs.hint.textContent = "当前通话已接通,挂断后会自动回到待机,不需要额外刷新页面。" : this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ? yi : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。";
|
|
12083
12139
|
}
|
|
12084
12140
|
async destroy() {
|
|
12085
12141
|
this.clearAutoStandbyRecovery(), await this.disconnectAndCleanup("destroy-widget", { suppressStateReset: !0 }), typeof document < "u" && this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.stopSessionTouch(), this.stopPresenceTouch(), this.stopTransportDisconnectGrace(), this.pendingLifecycleMode = null, 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.beforeUnloadHandler && (window.removeEventListener("beforeunload", this.beforeUnloadHandler), this.beforeUnloadHandler = null), this.pageHideHandler && (window.removeEventListener("pagehide", this.pageHideHandler), this.pageHideHandler = null)), this.e2eBridgeEnabled && typeof window < "u" && window.__embeddedCallWidgetE2E__ && delete window.__embeddedCallWidgetE2E__, this.shadowRoot.innerHTML = "";
|
|
12086
12142
|
}
|
|
12087
12143
|
}
|
|
12088
|
-
function
|
|
12089
|
-
return new
|
|
12144
|
+
function ki(o) {
|
|
12145
|
+
return new Di(o);
|
|
12090
12146
|
}
|
|
12091
12147
|
typeof window < "u" && (window.__EmbeddedCallWidgetRuntime__ = {
|
|
12092
|
-
createEmbeddedCallWidgetRuntime:
|
|
12148
|
+
createEmbeddedCallWidgetRuntime: ki
|
|
12093
12149
|
});
|
|
12094
12150
|
export {
|
|
12095
|
-
|
|
12151
|
+
ki as createEmbeddedCallWidgetRuntime
|
|
12096
12152
|
};
|