@shenyin/embedded-call-widget 2.6.2 → 2.6.4
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 +21 -19
- package/embedded-call-widget-runtime.js +623 -395
- package/manifest.json +11 -11
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Ct = "0.21.1";
|
|
2
2
|
class le extends Error {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
super(e), Object.setPrototypeOf(this, new.target.prototype);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class Be extends le {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super(e || "Unsupported content type.");
|
|
10
10
|
}
|
|
@@ -30,7 +30,7 @@ class pe extends le {
|
|
|
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 Ct {
|
|
|
40
40
|
return this.incomingAckRequest.message;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class Rt {
|
|
44
44
|
/** @internal */
|
|
45
45
|
constructor(e) {
|
|
46
46
|
this.incomingByeRequest = e;
|
|
@@ -58,7 +58,7 @@ class xt {
|
|
|
58
58
|
return this.incomingByeRequest.reject(e), Promise.resolve();
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
class
|
|
61
|
+
class It {
|
|
62
62
|
/** @internal */
|
|
63
63
|
constructor(e) {
|
|
64
64
|
this.incomingCancelRequest = e;
|
|
@@ -130,7 +130,7 @@ class be {
|
|
|
130
130
|
return this.addListener(e, { once: !0 });
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
class
|
|
133
|
+
class _t {
|
|
134
134
|
/** @internal */
|
|
135
135
|
constructor(e) {
|
|
136
136
|
this.incomingInfoRequest = e;
|
|
@@ -148,7 +148,7 @@ class It {
|
|
|
148
148
|
return this.incomingInfoRequest.reject(e), Promise.resolve();
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
class
|
|
151
|
+
class nt {
|
|
152
152
|
constructor(e) {
|
|
153
153
|
this.parameters = {};
|
|
154
154
|
for (const t in e)
|
|
@@ -174,7 +174,7 @@ class rt {
|
|
|
174
174
|
this.parameters = {};
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
class F extends
|
|
177
|
+
class F extends nt {
|
|
178
178
|
/**
|
|
179
179
|
* Constructor
|
|
180
180
|
* @param uri -
|
|
@@ -204,7 +204,7 @@ class F extends rt {
|
|
|
204
204
|
return e;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
class Y extends
|
|
207
|
+
class Y extends nt {
|
|
208
208
|
/**
|
|
209
209
|
* Constructor
|
|
210
210
|
* @param scheme -
|
|
@@ -333,7 +333,7 @@ class Y extends rt {
|
|
|
333
333
|
return t[r] && (r = t[r]), r;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function Je(a, e) {
|
|
337
337
|
if (a.scheme !== e.scheme || a.user !== e.user || a.host !== e.host || a.port !== e.port)
|
|
338
338
|
return !1;
|
|
339
339
|
function t(r, n) {
|
|
@@ -440,21 +440,21 @@ function At(a, e) {
|
|
|
440
440
|
f(`\r
|
|
441
441
|
`, !1),
|
|
442
442
|
/^[0-9]/,
|
|
443
|
-
|
|
443
|
+
A([["0", "9"]], !1, !1),
|
|
444
444
|
/^[a-zA-Z]/,
|
|
445
|
-
|
|
445
|
+
A([["a", "z"], ["A", "Z"]], !1, !1),
|
|
446
446
|
/^[0-9a-fA-F]/,
|
|
447
|
-
|
|
447
|
+
A([["0", "9"], ["a", "f"], ["A", "F"]], !1, !1),
|
|
448
448
|
/^[\0-\xFF]/,
|
|
449
|
-
|
|
449
|
+
A([["\0", "ÿ"]], !1, !1),
|
|
450
450
|
/^["]/,
|
|
451
|
-
|
|
451
|
+
A(['"'], !1, !1),
|
|
452
452
|
" ",
|
|
453
453
|
f(" ", !1),
|
|
454
454
|
" ",
|
|
455
455
|
f(" ", !1),
|
|
456
456
|
/^[a-zA-Z0-9]/,
|
|
457
|
-
|
|
457
|
+
A([["a", "z"], ["A", "Z"], ["0", "9"]], !1, !1),
|
|
458
458
|
";",
|
|
459
459
|
f(";", !1),
|
|
460
460
|
"/",
|
|
@@ -502,13 +502,13 @@ function At(a, e) {
|
|
|
502
502
|
return ":";
|
|
503
503
|
},
|
|
504
504
|
/^[!-~]/,
|
|
505
|
-
|
|
505
|
+
A([["!", "~"]], !1, !1),
|
|
506
506
|
/^[\x80-\uFFFF]/,
|
|
507
|
-
|
|
507
|
+
A([["", ""]], !1, !1),
|
|
508
508
|
/^[\x80-\xBF]/,
|
|
509
|
-
|
|
509
|
+
A([["", "¿"]], !1, !1),
|
|
510
510
|
/^[a-f]/,
|
|
511
|
-
|
|
511
|
+
A([["a", "f"]], !1, !1),
|
|
512
512
|
"`",
|
|
513
513
|
f("`", !1),
|
|
514
514
|
"<",
|
|
@@ -559,22 +559,22 @@ function At(a, e) {
|
|
|
559
559
|
return '"';
|
|
560
560
|
},
|
|
561
561
|
/^[!-']/,
|
|
562
|
-
|
|
562
|
+
A([["!", "'"]], !1, !1),
|
|
563
563
|
/^[*-[]/,
|
|
564
|
-
|
|
564
|
+
A([["*", "["]], !1, !1),
|
|
565
565
|
/^[\]-~]/,
|
|
566
|
-
|
|
566
|
+
A([["]", "~"]], !1, !1),
|
|
567
567
|
function(l) {
|
|
568
568
|
return l;
|
|
569
569
|
},
|
|
570
570
|
/^[#-[]/,
|
|
571
|
-
|
|
571
|
+
A([["#", "["]], !1, !1),
|
|
572
572
|
/^[\0-\t]/,
|
|
573
|
-
|
|
573
|
+
A([["\0", " "]], !1, !1),
|
|
574
574
|
/^[\v-\f]/,
|
|
575
|
-
|
|
575
|
+
A([["\v", "\f"]], !1, !1),
|
|
576
576
|
/^[\x0E-\x7F]/,
|
|
577
|
-
|
|
577
|
+
A([["", ""]], !1, !1),
|
|
578
578
|
function() {
|
|
579
579
|
e = e || { data: {} }, e.data.uri = new Y(e.data.scheme, e.data.user, e.data.host, e.data.port), delete e.data.scheme, delete e.data.user, delete e.data.host, delete e.data.host_type, delete e.data.port;
|
|
580
580
|
},
|
|
@@ -589,44 +589,44 @@ function At(a, e) {
|
|
|
589
589
|
e = e || { data: {} }, e.data.scheme = l;
|
|
590
590
|
},
|
|
591
591
|
function() {
|
|
592
|
-
e = e || { data: {} }, e.data.user = decodeURIComponent(
|
|
592
|
+
e = e || { data: {} }, e.data.user = decodeURIComponent(E().slice(0, -1));
|
|
593
593
|
},
|
|
594
594
|
function() {
|
|
595
|
-
e = e || { data: {} }, e.data.password =
|
|
595
|
+
e = e || { data: {} }, e.data.password = E();
|
|
596
596
|
},
|
|
597
597
|
function() {
|
|
598
|
-
return e = e || { data: {} }, e.data.host =
|
|
598
|
+
return e = e || { data: {} }, e.data.host = E(), e.data.host;
|
|
599
599
|
},
|
|
600
600
|
function() {
|
|
601
|
-
return e = e || { data: {} }, e.data.host_type = "domain",
|
|
601
|
+
return e = e || { data: {} }, e.data.host_type = "domain", E();
|
|
602
602
|
},
|
|
603
603
|
/^[a-zA-Z0-9_\-]/,
|
|
604
|
-
|
|
604
|
+
A([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], !1, !1),
|
|
605
605
|
/^[a-zA-Z0-9\-]/,
|
|
606
|
-
|
|
606
|
+
A([["a", "z"], ["A", "Z"], ["0", "9"], "-"], !1, !1),
|
|
607
607
|
function() {
|
|
608
|
-
return e = e || { data: {} }, e.data.host_type = "IPv6",
|
|
608
|
+
return e = e || { data: {} }, e.data.host_type = "IPv6", E();
|
|
609
609
|
},
|
|
610
610
|
"::",
|
|
611
611
|
f("::", !1),
|
|
612
612
|
function() {
|
|
613
|
-
return e = e || { data: {} }, e.data.host_type = "IPv6",
|
|
613
|
+
return e = e || { data: {} }, e.data.host_type = "IPv6", E();
|
|
614
614
|
},
|
|
615
615
|
function() {
|
|
616
|
-
return e = e || { data: {} }, e.data.host_type = "IPv4",
|
|
616
|
+
return e = e || { data: {} }, e.data.host_type = "IPv4", E();
|
|
617
617
|
},
|
|
618
618
|
"25",
|
|
619
619
|
f("25", !1),
|
|
620
620
|
/^[0-5]/,
|
|
621
|
-
|
|
621
|
+
A([["0", "5"]], !1, !1),
|
|
622
622
|
"2",
|
|
623
623
|
f("2", !1),
|
|
624
624
|
/^[0-4]/,
|
|
625
|
-
|
|
625
|
+
A([["0", "4"]], !1, !1),
|
|
626
626
|
"1",
|
|
627
627
|
f("1", !1),
|
|
628
628
|
/^[1-9]/,
|
|
629
|
-
|
|
629
|
+
A([["1", "9"]], !1, !1),
|
|
630
630
|
function(l) {
|
|
631
631
|
return e = e || { data: {} }, l = parseInt(l.join("")), e.data.port = l, l;
|
|
632
632
|
},
|
|
@@ -684,11 +684,11 @@ function At(a, e) {
|
|
|
684
684
|
"//",
|
|
685
685
|
f("//", !1),
|
|
686
686
|
function() {
|
|
687
|
-
e = e || { data: {} }, e.data.scheme =
|
|
687
|
+
e = e || { data: {} }, e.data.scheme = E();
|
|
688
688
|
},
|
|
689
689
|
f("SIP", !0),
|
|
690
690
|
function() {
|
|
691
|
-
e = e || { data: {} }, e.data.sip_version =
|
|
691
|
+
e = e || { data: {} }, e.data.sip_version = E();
|
|
692
692
|
},
|
|
693
693
|
"INVITE",
|
|
694
694
|
f("INVITE", !1),
|
|
@@ -713,16 +713,16 @@ function At(a, e) {
|
|
|
713
713
|
"PUBLISH",
|
|
714
714
|
f("PUBLISH", !1),
|
|
715
715
|
function() {
|
|
716
|
-
return e = e || { data: {} }, e.data.method =
|
|
716
|
+
return e = e || { data: {} }, e.data.method = E(), e.data.method;
|
|
717
717
|
},
|
|
718
718
|
function(l) {
|
|
719
719
|
e = e || { data: {} }, e.data.status_code = parseInt(l.join(""));
|
|
720
720
|
},
|
|
721
721
|
function() {
|
|
722
|
-
e = e || { data: {} }, e.data.reason_phrase =
|
|
722
|
+
e = e || { data: {} }, e.data.reason_phrase = E();
|
|
723
723
|
},
|
|
724
724
|
function() {
|
|
725
|
-
e = e || { data: {} }, e.data =
|
|
725
|
+
e = e || { data: {} }, e.data = E();
|
|
726
726
|
},
|
|
727
727
|
function() {
|
|
728
728
|
var l, y;
|
|
@@ -748,7 +748,7 @@ function At(a, e) {
|
|
|
748
748
|
});
|
|
749
749
|
},
|
|
750
750
|
function(l) {
|
|
751
|
-
l =
|
|
751
|
+
l = E().trim(), l[0] === '"' && (l = l.substring(1, l.length - 1)), e = e || { data: {} }, e.data.displayName = l;
|
|
752
752
|
},
|
|
753
753
|
"q",
|
|
754
754
|
f("q", !0),
|
|
@@ -766,7 +766,7 @@ function At(a, e) {
|
|
|
766
766
|
"0",
|
|
767
767
|
f("0", !1),
|
|
768
768
|
function() {
|
|
769
|
-
return parseFloat(
|
|
769
|
+
return parseFloat(E());
|
|
770
770
|
},
|
|
771
771
|
function(l, y) {
|
|
772
772
|
e = e || { data: {} }, e.data.params || (e.data.params = {}), y === null ? y = void 0 : y = y[1], e.data.params[l.toLowerCase()] = y;
|
|
@@ -780,7 +780,7 @@ function At(a, e) {
|
|
|
780
780
|
"alert",
|
|
781
781
|
f("alert", !0),
|
|
782
782
|
function() {
|
|
783
|
-
e = e || { data: {} }, e.startRule === "Content_Disposition" && (e.data.type =
|
|
783
|
+
e = e || { data: {} }, e.startRule === "Content_Disposition" && (e.data.type = E().toLowerCase());
|
|
784
784
|
},
|
|
785
785
|
"handling",
|
|
786
786
|
f("handling", !0),
|
|
@@ -792,7 +792,7 @@ function At(a, e) {
|
|
|
792
792
|
e = e || { data: {} }, e.data = parseInt(l.join(""));
|
|
793
793
|
},
|
|
794
794
|
function() {
|
|
795
|
-
e = e || { data: {} }, e.data =
|
|
795
|
+
e = e || { data: {} }, e.data = E();
|
|
796
796
|
},
|
|
797
797
|
"text",
|
|
798
798
|
f("text", !0),
|
|
@@ -943,7 +943,7 @@ function At(a, e) {
|
|
|
943
943
|
return y;
|
|
944
944
|
},
|
|
945
945
|
function(l, y) {
|
|
946
|
-
return
|
|
946
|
+
return St(l, y);
|
|
947
947
|
},
|
|
948
948
|
function(l) {
|
|
949
949
|
e = e || { data: {} }, e.startRule === "Require" && (e.data = l || []);
|
|
@@ -958,7 +958,7 @@ function At(a, e) {
|
|
|
958
958
|
"terminated",
|
|
959
959
|
f("terminated", !0),
|
|
960
960
|
function() {
|
|
961
|
-
e = e || { data: {} }, e.data.state =
|
|
961
|
+
e = e || { data: {} }, e.data.state = E();
|
|
962
962
|
},
|
|
963
963
|
"reason",
|
|
964
964
|
f("reason", !0),
|
|
@@ -1031,7 +1031,7 @@ function At(a, e) {
|
|
|
1031
1031
|
e = e || { data: {} }, e.data.transport = l;
|
|
1032
1032
|
},
|
|
1033
1033
|
function() {
|
|
1034
|
-
e = e || { data: {} }, e.data.host =
|
|
1034
|
+
e = e || { data: {} }, e.data.host = E();
|
|
1035
1035
|
},
|
|
1036
1036
|
function(l) {
|
|
1037
1037
|
e = e || { data: {} }, e.data.port = parseInt(l.join(""));
|
|
@@ -1074,7 +1074,7 @@ function At(a, e) {
|
|
|
1074
1074
|
e = e || { data: {} }, e.data.transport = l;
|
|
1075
1075
|
},
|
|
1076
1076
|
function() {
|
|
1077
|
-
e = e || { data: {} }, e.data =
|
|
1077
|
+
e = e || { data: {} }, e.data = E();
|
|
1078
1078
|
},
|
|
1079
1079
|
"Referred-By",
|
|
1080
1080
|
f("Referred-By", !1),
|
|
@@ -1321,13 +1321,13 @@ function At(a, e) {
|
|
|
1321
1321
|
];
|
|
1322
1322
|
let d = 0, p = 0;
|
|
1323
1323
|
const u = [{ line: 1, column: 1 }];
|
|
1324
|
-
let w = 0, S = [], I = 0,
|
|
1324
|
+
let w = 0, S = [], I = 0, _;
|
|
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
|
-
function
|
|
1330
|
+
function E() {
|
|
1331
1331
|
return a.substring(p, d);
|
|
1332
1332
|
}
|
|
1333
1333
|
function ae() {
|
|
@@ -1336,13 +1336,13 @@ function At(a, e) {
|
|
|
1336
1336
|
function f(l, y) {
|
|
1337
1337
|
return { type: "literal", text: l, ignoreCase: y };
|
|
1338
1338
|
}
|
|
1339
|
-
function
|
|
1339
|
+
function A(l, y, h) {
|
|
1340
1340
|
return { type: "class", parts: l, inverted: y, ignoreCase: h };
|
|
1341
1341
|
}
|
|
1342
1342
|
function ke() {
|
|
1343
1343
|
return { type: "end" };
|
|
1344
1344
|
}
|
|
1345
|
-
function
|
|
1345
|
+
function We(l) {
|
|
1346
1346
|
let y = u[l], h;
|
|
1347
1347
|
if (y)
|
|
1348
1348
|
return y;
|
|
@@ -1356,7 +1356,7 @@ function At(a, e) {
|
|
|
1356
1356
|
return u[l] = y, y;
|
|
1357
1357
|
}
|
|
1358
1358
|
function Pe(l, y) {
|
|
1359
|
-
const h =
|
|
1359
|
+
const h = We(l), B = We(y);
|
|
1360
1360
|
return {
|
|
1361
1361
|
source: i,
|
|
1362
1362
|
start: {
|
|
@@ -1374,107 +1374,107 @@ function At(a, e) {
|
|
|
1374
1374
|
function Ke(l) {
|
|
1375
1375
|
d < w || (d > w && (w = d, S = []), S.push(l));
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1377
|
+
function vt(l, y, h) {
|
|
1378
1378
|
return new he(he.buildMessage(l, y), l, y, h);
|
|
1379
1379
|
}
|
|
1380
1380
|
function c(l) {
|
|
1381
1381
|
return l.split("").map((y) => y.charCodeAt(0) - 32);
|
|
1382
1382
|
}
|
|
1383
|
-
function
|
|
1383
|
+
function ze(l) {
|
|
1384
1384
|
const y = o[l];
|
|
1385
1385
|
let h = 0;
|
|
1386
1386
|
const B = [];
|
|
1387
1387
|
let $ = y.length;
|
|
1388
|
-
const
|
|
1389
|
-
let
|
|
1388
|
+
const W = [], C = [];
|
|
1389
|
+
let Ye;
|
|
1390
1390
|
for (; ; ) {
|
|
1391
1391
|
for (; h < $; )
|
|
1392
1392
|
switch (y[h]) {
|
|
1393
1393
|
case 0:
|
|
1394
|
-
|
|
1394
|
+
C.push(n[y[h + 1]]), h += 2;
|
|
1395
1395
|
break;
|
|
1396
1396
|
case 1:
|
|
1397
|
-
|
|
1397
|
+
C.push(void 0), h++;
|
|
1398
1398
|
break;
|
|
1399
1399
|
case 2:
|
|
1400
|
-
|
|
1400
|
+
C.push(null), h++;
|
|
1401
1401
|
break;
|
|
1402
1402
|
case 3:
|
|
1403
|
-
|
|
1403
|
+
C.push(t), h++;
|
|
1404
1404
|
break;
|
|
1405
1405
|
case 4:
|
|
1406
|
-
|
|
1406
|
+
C.push([]), h++;
|
|
1407
1407
|
break;
|
|
1408
1408
|
case 5:
|
|
1409
|
-
|
|
1409
|
+
C.push(d), h++;
|
|
1410
1410
|
break;
|
|
1411
1411
|
case 6:
|
|
1412
|
-
|
|
1412
|
+
C.pop(), h++;
|
|
1413
1413
|
break;
|
|
1414
1414
|
case 7:
|
|
1415
|
-
d =
|
|
1415
|
+
d = C.pop(), h++;
|
|
1416
1416
|
break;
|
|
1417
1417
|
case 8:
|
|
1418
|
-
|
|
1418
|
+
C.length -= y[h + 1], h += 2;
|
|
1419
1419
|
break;
|
|
1420
1420
|
case 9:
|
|
1421
|
-
|
|
1421
|
+
C.splice(-2, 1), h++;
|
|
1422
1422
|
break;
|
|
1423
1423
|
case 10:
|
|
1424
|
-
|
|
1424
|
+
C[C.length - 2].push(C.pop()), h++;
|
|
1425
1425
|
break;
|
|
1426
1426
|
case 11:
|
|
1427
|
-
|
|
1427
|
+
C.push(C.splice(C.length - y[h + 1], y[h + 1])), h += 2;
|
|
1428
1428
|
break;
|
|
1429
1429
|
case 12:
|
|
1430
|
-
|
|
1430
|
+
C.push(a.substring(C.pop(), d)), h++;
|
|
1431
1431
|
break;
|
|
1432
1432
|
case 13:
|
|
1433
|
-
|
|
1433
|
+
W.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), C[C.length - 1] ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1434
1434
|
break;
|
|
1435
1435
|
case 14:
|
|
1436
|
-
|
|
1436
|
+
W.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), C[C.length - 1] === t ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1437
1437
|
break;
|
|
1438
1438
|
case 15:
|
|
1439
|
-
|
|
1439
|
+
W.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), C[C.length - 1] !== t ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1440
1440
|
break;
|
|
1441
1441
|
case 16:
|
|
1442
|
-
|
|
1442
|
+
C[C.length - 1] !== t ? (W.push($), B.push(h), $ = h + 2 + y[h + 1], h += 2) : h += 2 + y[h + 1];
|
|
1443
1443
|
break;
|
|
1444
1444
|
case 17:
|
|
1445
|
-
|
|
1445
|
+
W.push($), B.push(h + 3 + y[h + 1] + y[h + 2]), a.length > d ? ($ = h + 3 + y[h + 1], h += 3) : ($ = h + 3 + y[h + 1] + y[h + 2], h += 3 + y[h + 1]);
|
|
1446
1446
|
break;
|
|
1447
1447
|
case 18:
|
|
1448
|
-
|
|
1448
|
+
W.push($), B.push(h + 4 + y[h + 2] + y[h + 3]), a.substr(d, n[y[h + 1]].length) === n[y[h + 1]] ? ($ = h + 4 + y[h + 2], h += 4) : ($ = h + 4 + y[h + 2] + y[h + 3], h += 4 + y[h + 2]);
|
|
1449
1449
|
break;
|
|
1450
1450
|
case 19:
|
|
1451
|
-
|
|
1451
|
+
W.push($), B.push(h + 4 + y[h + 2] + y[h + 3]), a.substr(d, n[y[h + 1]].length).toLowerCase() === n[y[h + 1]] ? ($ = h + 4 + y[h + 2], h += 4) : ($ = h + 4 + y[h + 2] + y[h + 3], h += 4 + y[h + 2]);
|
|
1452
1452
|
break;
|
|
1453
1453
|
case 20:
|
|
1454
|
-
|
|
1454
|
+
W.push($), B.push(h + 4 + y[h + 2] + y[h + 3]), n[y[h + 1]].test(a.charAt(d)) ? ($ = h + 4 + y[h + 2], h += 4) : ($ = h + 4 + y[h + 2] + y[h + 3], h += 4 + y[h + 2]);
|
|
1455
1455
|
break;
|
|
1456
1456
|
case 21:
|
|
1457
|
-
|
|
1457
|
+
C.push(a.substr(d, y[h + 1])), d += y[h + 1], h += 2;
|
|
1458
1458
|
break;
|
|
1459
1459
|
case 22:
|
|
1460
|
-
|
|
1460
|
+
C.push(n[y[h + 1]]), d += n[y[h + 1]].length, h += 2;
|
|
1461
1461
|
break;
|
|
1462
1462
|
case 23:
|
|
1463
|
-
|
|
1463
|
+
C.push(t), I === 0 && Ke(n[y[h + 1]]), h += 2;
|
|
1464
1464
|
break;
|
|
1465
1465
|
case 24:
|
|
1466
|
-
p =
|
|
1466
|
+
p = C[C.length - 1 - y[h + 1]], h += 2;
|
|
1467
1467
|
break;
|
|
1468
1468
|
case 25:
|
|
1469
1469
|
p = d, h++;
|
|
1470
1470
|
break;
|
|
1471
1471
|
case 26:
|
|
1472
|
-
|
|
1473
|
-
return
|
|
1474
|
-
}),
|
|
1472
|
+
Ye = y.slice(h + 4, h + 4 + y[h + 3]).map(function(Tt) {
|
|
1473
|
+
return C[C.length - 1 - Tt];
|
|
1474
|
+
}), C.splice(C.length - y[h + 2], y[h + 2], n[y[h + 1]].apply(null, Ye)), h += 4 + y[h + 3];
|
|
1475
1475
|
break;
|
|
1476
1476
|
case 27:
|
|
1477
|
-
|
|
1477
|
+
C.push(ze(y[h + 1])), h += 2;
|
|
1478
1478
|
break;
|
|
1479
1479
|
case 28:
|
|
1480
1480
|
I++, h++;
|
|
@@ -1485,28 +1485,28 @@ function At(a, e) {
|
|
|
1485
1485
|
default:
|
|
1486
1486
|
throw new Error("Invalid opcode: " + y[h] + ".");
|
|
1487
1487
|
}
|
|
1488
|
-
if (
|
|
1489
|
-
$ =
|
|
1488
|
+
if (W.length > 0)
|
|
1489
|
+
$ = W.pop(), h = B.pop();
|
|
1490
1490
|
else
|
|
1491
1491
|
break;
|
|
1492
1492
|
}
|
|
1493
|
-
return
|
|
1493
|
+
return C[0];
|
|
1494
1494
|
}
|
|
1495
1495
|
e.data = {};
|
|
1496
|
-
function
|
|
1496
|
+
function St(l, y) {
|
|
1497
1497
|
return [l].concat(y);
|
|
1498
1498
|
}
|
|
1499
|
-
if (
|
|
1500
|
-
return
|
|
1501
|
-
throw
|
|
1499
|
+
if (_ = ze(r), _ !== t && d === a.length)
|
|
1500
|
+
return _;
|
|
1501
|
+
throw _ !== t && d < a.length && Ke(ke()), vt(S, w < a.length ? a.charAt(w) : null, w < a.length ? Pe(w, w + 1) : Pe(w, w));
|
|
1502
1502
|
}
|
|
1503
|
-
const
|
|
1503
|
+
const $t = At;
|
|
1504
1504
|
var k;
|
|
1505
1505
|
(function(a) {
|
|
1506
1506
|
function e(s, r) {
|
|
1507
1507
|
const n = { startRule: r };
|
|
1508
1508
|
try {
|
|
1509
|
-
|
|
1509
|
+
$t(s, n);
|
|
1510
1510
|
} catch {
|
|
1511
1511
|
n.data = -1;
|
|
1512
1512
|
}
|
|
@@ -1524,7 +1524,7 @@ var k;
|
|
|
1524
1524
|
}
|
|
1525
1525
|
a.URIParse = i;
|
|
1526
1526
|
})(k = k || (k = {}));
|
|
1527
|
-
const
|
|
1527
|
+
const Dt = {
|
|
1528
1528
|
100: "Trying",
|
|
1529
1529
|
180: "Ringing",
|
|
1530
1530
|
181: "Call Is Being Forwarded",
|
|
@@ -1605,13 +1605,13 @@ function oe(a, e = 32) {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
return t;
|
|
1607
1607
|
}
|
|
1608
|
-
function
|
|
1609
|
-
return
|
|
1608
|
+
function _e(a) {
|
|
1609
|
+
return Dt[a] || "";
|
|
1610
1610
|
}
|
|
1611
|
-
function
|
|
1611
|
+
function Ae() {
|
|
1612
1612
|
return oe(10);
|
|
1613
1613
|
}
|
|
1614
|
-
function
|
|
1614
|
+
function K(a) {
|
|
1615
1615
|
const e = {
|
|
1616
1616
|
"Call-Id": "Call-ID",
|
|
1617
1617
|
Cseq: "CSeq",
|
|
@@ -1628,7 +1628,7 @@ function W(a) {
|
|
|
1628
1628
|
function ve(a) {
|
|
1629
1629
|
return encodeURIComponent(a).replace(/%[A-F\d]{2}/g, "U").length;
|
|
1630
1630
|
}
|
|
1631
|
-
class
|
|
1631
|
+
class at {
|
|
1632
1632
|
constructor() {
|
|
1633
1633
|
this.headers = {};
|
|
1634
1634
|
}
|
|
@@ -1640,7 +1640,7 @@ class nt {
|
|
|
1640
1640
|
*/
|
|
1641
1641
|
addHeader(e, t) {
|
|
1642
1642
|
const i = { raw: t };
|
|
1643
|
-
e =
|
|
1643
|
+
e = K(e), this.headers[e] ? this.headers[e].push(i) : this.headers[e] = [i];
|
|
1644
1644
|
}
|
|
1645
1645
|
/**
|
|
1646
1646
|
* Get the value of the given header name at the given position.
|
|
@@ -1648,7 +1648,7 @@ class nt {
|
|
|
1648
1648
|
* @returns Returns the specified header, undefined if header doesn't exist.
|
|
1649
1649
|
*/
|
|
1650
1650
|
getHeader(e) {
|
|
1651
|
-
const t = this.headers[
|
|
1651
|
+
const t = this.headers[K(e)];
|
|
1652
1652
|
if (t) {
|
|
1653
1653
|
if (t[0])
|
|
1654
1654
|
return t[0].raw;
|
|
@@ -1661,7 +1661,7 @@ class nt {
|
|
|
1661
1661
|
* @returns Array - with all the headers of the specified name.
|
|
1662
1662
|
*/
|
|
1663
1663
|
getHeaders(e) {
|
|
1664
|
-
const t = this.headers[
|
|
1664
|
+
const t = this.headers[K(e)], i = [];
|
|
1665
1665
|
if (!t)
|
|
1666
1666
|
return [];
|
|
1667
1667
|
for (const s of t)
|
|
@@ -1674,7 +1674,7 @@ class nt {
|
|
|
1674
1674
|
* @returns true if header with given name exists, false otherwise
|
|
1675
1675
|
*/
|
|
1676
1676
|
hasHeader(e) {
|
|
1677
|
-
return !!this.headers[
|
|
1677
|
+
return !!this.headers[K(e)];
|
|
1678
1678
|
}
|
|
1679
1679
|
/**
|
|
1680
1680
|
* Parse the given header on the given index.
|
|
@@ -1685,7 +1685,7 @@ class nt {
|
|
|
1685
1685
|
*/
|
|
1686
1686
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1687
1687
|
parseHeader(e, t = 0) {
|
|
1688
|
-
if (e =
|
|
1688
|
+
if (e = K(e), this.headers[e]) {
|
|
1689
1689
|
if (t >= this.headers[e].length)
|
|
1690
1690
|
return;
|
|
1691
1691
|
} else return;
|
|
@@ -1719,18 +1719,18 @@ class nt {
|
|
|
1719
1719
|
* @param value - header value
|
|
1720
1720
|
*/
|
|
1721
1721
|
setHeader(e, t) {
|
|
1722
|
-
this.headers[
|
|
1722
|
+
this.headers[K(e)] = [{ raw: t }];
|
|
1723
1723
|
}
|
|
1724
1724
|
toString() {
|
|
1725
1725
|
return this.data;
|
|
1726
1726
|
}
|
|
1727
1727
|
}
|
|
1728
|
-
class ue extends
|
|
1728
|
+
class ue extends at {
|
|
1729
1729
|
constructor() {
|
|
1730
1730
|
super();
|
|
1731
1731
|
}
|
|
1732
1732
|
}
|
|
1733
|
-
class ne extends
|
|
1733
|
+
class ne extends at {
|
|
1734
1734
|
constructor() {
|
|
1735
1735
|
super();
|
|
1736
1736
|
}
|
|
@@ -1740,7 +1740,7 @@ class de {
|
|
|
1740
1740
|
this.headers = {}, this.extraHeaders = [], this.options = de.getDefaultOptions(), r && (this.options = Object.assign(Object.assign({}, this.options), r), this.options.optionTags && this.options.optionTags.length && (this.options.optionTags = this.options.optionTags.slice()), this.options.routeSet && this.options.routeSet.length && (this.options.routeSet = this.options.routeSet.slice())), n && n.length && (this.extraHeaders = n.slice()), o && (this.body = {
|
|
1741
1741
|
body: o.content,
|
|
1742
1742
|
contentType: o.contentType
|
|
1743
|
-
}), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag :
|
|
1743
|
+
}), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag : Ae(), this.from = de.makeNameAddrHeader(this.fromURI, this.options.fromDisplayName, this.fromTag), this.toURI = s.clone(), this.toTag = this.options.toTag, this.to = de.makeNameAddrHeader(this.toURI, this.options.toDisplayName, this.toTag), this.callId = this.options.callId ? this.options.callId : this.options.callIdPrefix + oe(15), this.cseq = this.options.cseq, this.setHeader("route", this.options.routeSet), this.setHeader("via", ""), this.setHeader("to", this.to.toString()), this.setHeader("from", this.from.toString()), this.setHeader("cseq", this.cseq + " " + this.method), this.setHeader("call-id", this.callId), this.setHeader("max-forwards", "70");
|
|
1744
1744
|
}
|
|
1745
1745
|
/** Get a copy of the default options. */
|
|
1746
1746
|
static getDefaultOptions() {
|
|
@@ -1770,7 +1770,7 @@ class de {
|
|
|
1770
1770
|
* @returns Returns the specified header, undefined if header doesn't exist.
|
|
1771
1771
|
*/
|
|
1772
1772
|
getHeader(e) {
|
|
1773
|
-
const t = this.headers[
|
|
1773
|
+
const t = this.headers[K(e)];
|
|
1774
1774
|
if (t) {
|
|
1775
1775
|
if (t[0])
|
|
1776
1776
|
return t[0];
|
|
@@ -1787,7 +1787,7 @@ class de {
|
|
|
1787
1787
|
* @returns Array with all the headers of the specified name.
|
|
1788
1788
|
*/
|
|
1789
1789
|
getHeaders(e) {
|
|
1790
|
-
const t = [], i = this.headers[
|
|
1790
|
+
const t = [], i = this.headers[K(e)];
|
|
1791
1791
|
if (i)
|
|
1792
1792
|
for (const s of i)
|
|
1793
1793
|
t.push(s);
|
|
@@ -1804,7 +1804,7 @@ class de {
|
|
|
1804
1804
|
* @returns true if header with given name exists, false otherwise
|
|
1805
1805
|
*/
|
|
1806
1806
|
hasHeader(e) {
|
|
1807
|
-
if (this.headers[
|
|
1807
|
+
if (this.headers[K(e)])
|
|
1808
1808
|
return !0;
|
|
1809
1809
|
{
|
|
1810
1810
|
const t = new RegExp("^\\s*" + e + "\\s*:", "i");
|
|
@@ -1820,7 +1820,7 @@ class de {
|
|
|
1820
1820
|
* @param value - header value
|
|
1821
1821
|
*/
|
|
1822
1822
|
setHeader(e, t) {
|
|
1823
|
-
this.headers[
|
|
1823
|
+
this.headers[K(e)] = t instanceof Array ? t : [t];
|
|
1824
1824
|
}
|
|
1825
1825
|
/**
|
|
1826
1826
|
* The Via header field indicates the transport used for the transaction
|
|
@@ -1870,14 +1870,14 @@ class de {
|
|
|
1870
1870
|
`, e;
|
|
1871
1871
|
}
|
|
1872
1872
|
}
|
|
1873
|
-
function
|
|
1873
|
+
function ot(a) {
|
|
1874
1874
|
return a === "application/sdp" ? "session" : "render";
|
|
1875
1875
|
}
|
|
1876
1876
|
function xe(a) {
|
|
1877
1877
|
const e = typeof a == "string" ? a : a.body, t = typeof a == "string" ? "application/sdp" : a.contentType;
|
|
1878
|
-
return { contentDisposition:
|
|
1878
|
+
return { contentDisposition: ot(t), contentType: t, content: e };
|
|
1879
1879
|
}
|
|
1880
|
-
function
|
|
1880
|
+
function ct(a) {
|
|
1881
1881
|
return a && typeof a.content == "string" && typeof a.contentType == "string" && a.contentDisposition === void 0 ? !0 : typeof a.contentDisposition == "string";
|
|
1882
1882
|
}
|
|
1883
1883
|
function we(a) {
|
|
@@ -1900,8 +1900,8 @@ function we(a) {
|
|
|
1900
1900
|
throw new Error("Header content type header does not equal body content type.");
|
|
1901
1901
|
t = a.body.contentType, i = a.body.body;
|
|
1902
1902
|
}
|
|
1903
|
-
if (
|
|
1904
|
-
if (t && !e && (e =
|
|
1903
|
+
if (ct(a) && (e = a.contentDisposition, t = a.contentType, i = a.content), !!i) {
|
|
1904
|
+
if (t && !e && (e = ot(t)), !e)
|
|
1905
1905
|
throw new Error("Content disposition undefined.");
|
|
1906
1906
|
if (!t)
|
|
1907
1907
|
throw new Error("Content type undefined.");
|
|
@@ -1920,16 +1920,16 @@ var b;
|
|
|
1920
1920
|
(function(a) {
|
|
1921
1921
|
a.Initial = "Initial", a.HaveLocalOffer = "HaveLocalOffer", a.HaveRemoteOffer = "HaveRemoteOffer", a.Stable = "Stable", a.Closed = "Closed";
|
|
1922
1922
|
})(b = b || (b = {}));
|
|
1923
|
-
const Z = 500,
|
|
1923
|
+
const Z = 500, kt = 4e3, Ze = 5e3, M = {
|
|
1924
1924
|
T1: Z,
|
|
1925
|
-
T2:
|
|
1925
|
+
T2: kt,
|
|
1926
1926
|
TIMER_B: 64 * Z,
|
|
1927
1927
|
TIMER_D: 0 * Z,
|
|
1928
1928
|
TIMER_F: 64 * Z,
|
|
1929
1929
|
TIMER_H: 64 * Z,
|
|
1930
|
-
TIMER_I: 0 *
|
|
1930
|
+
TIMER_I: 0 * Ze,
|
|
1931
1931
|
TIMER_J: 0 * Z,
|
|
1932
|
-
TIMER_K: 0 *
|
|
1932
|
+
TIMER_K: 0 * Ze,
|
|
1933
1933
|
TIMER_L: 64 * Z,
|
|
1934
1934
|
TIMER_M: 64 * Z,
|
|
1935
1935
|
TIMER_N: 64 * Z,
|
|
@@ -1959,7 +1959,7 @@ const se = [
|
|
|
1959
1959
|
v.REGISTER,
|
|
1960
1960
|
v.SUBSCRIBE
|
|
1961
1961
|
];
|
|
1962
|
-
class
|
|
1962
|
+
class dt {
|
|
1963
1963
|
/** @internal */
|
|
1964
1964
|
constructor(e) {
|
|
1965
1965
|
this.incomingMessageRequest = e;
|
|
@@ -1977,7 +1977,7 @@ class ct {
|
|
|
1977
1977
|
return this.incomingMessageRequest.reject(e), Promise.resolve();
|
|
1978
1978
|
}
|
|
1979
1979
|
}
|
|
1980
|
-
class
|
|
1980
|
+
class je {
|
|
1981
1981
|
/** @internal */
|
|
1982
1982
|
constructor(e) {
|
|
1983
1983
|
this.incomingNotifyRequest = e;
|
|
@@ -1995,7 +1995,7 @@ class Be {
|
|
|
1995
1995
|
return this.incomingNotifyRequest.reject(e), Promise.resolve();
|
|
1996
1996
|
}
|
|
1997
1997
|
}
|
|
1998
|
-
class
|
|
1998
|
+
class Pt {
|
|
1999
1999
|
/** @internal */
|
|
2000
2000
|
constructor(e, t) {
|
|
2001
2001
|
this.incomingReferRequest = e, this.session = t;
|
|
@@ -2454,7 +2454,7 @@ class ge {
|
|
|
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 ge {
|
|
|
2497
2497
|
return;
|
|
2498
2498
|
}
|
|
2499
2499
|
if (this.delegate && this.delegate.onBye) {
|
|
2500
|
-
const t = new
|
|
2500
|
+
const t = new Rt(e);
|
|
2501
2501
|
this.delegate.onBye(t);
|
|
2502
2502
|
} else
|
|
2503
2503
|
e.accept();
|
|
@@ -2513,7 +2513,7 @@ class ge {
|
|
|
2513
2513
|
return;
|
|
2514
2514
|
}
|
|
2515
2515
|
if (this.delegate && this.delegate.onInfo) {
|
|
2516
|
-
const t = new
|
|
2516
|
+
const t = new _t(e);
|
|
2517
2517
|
this.delegate.onInfo(t);
|
|
2518
2518
|
} else
|
|
2519
2519
|
e.accept();
|
|
@@ -2576,7 +2576,7 @@ class ge {
|
|
|
2576
2576
|
return;
|
|
2577
2577
|
}
|
|
2578
2578
|
if (this.delegate && this.delegate.onMessage) {
|
|
2579
|
-
const t = new
|
|
2579
|
+
const t = new dt(e);
|
|
2580
2580
|
this.delegate.onMessage(t);
|
|
2581
2581
|
} else
|
|
2582
2582
|
e.accept();
|
|
@@ -2591,12 +2591,12 @@ class ge {
|
|
|
2591
2591
|
return;
|
|
2592
2592
|
}
|
|
2593
2593
|
if (this.onNotify) {
|
|
2594
|
-
const t = new
|
|
2594
|
+
const t = new je(e);
|
|
2595
2595
|
this.onNotify(t);
|
|
2596
2596
|
return;
|
|
2597
2597
|
}
|
|
2598
2598
|
if (this.delegate && this.delegate.onNotify) {
|
|
2599
|
-
const t = new
|
|
2599
|
+
const t = new je(e);
|
|
2600
2600
|
this.delegate.onNotify(t);
|
|
2601
2601
|
} else
|
|
2602
2602
|
e.accept();
|
|
@@ -2626,7 +2626,7 @@ class ge {
|
|
|
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 Pt(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
|
}));
|
|
@@ -2716,7 +2716,7 @@ class ge {
|
|
|
2716
2716
|
const i = this.setupSessionDescriptionHandler(), s = t.sessionDescriptionHandlerOptions, r = t.sessionDescriptionHandlerModifiers;
|
|
2717
2717
|
try {
|
|
2718
2718
|
if (!i.hasDescription(e.contentType))
|
|
2719
|
-
return Promise.reject(new
|
|
2719
|
+
return Promise.reject(new Be());
|
|
2720
2720
|
} catch (n) {
|
|
2721
2721
|
this.logger.error("Session.setAnswer: SDH hasDescription threw...");
|
|
2722
2722
|
const o = n instanceof Error ? n : new Error(n);
|
|
@@ -2742,7 +2742,7 @@ class ge {
|
|
|
2742
2742
|
const i = this.setupSessionDescriptionHandler(), s = t.sessionDescriptionHandlerOptions, r = t.sessionDescriptionHandlerModifiers;
|
|
2743
2743
|
try {
|
|
2744
2744
|
if (!i.hasDescription(e.contentType))
|
|
2745
|
-
return Promise.reject(new
|
|
2745
|
+
return Promise.reject(new Be());
|
|
2746
2746
|
} catch (n) {
|
|
2747
2747
|
this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");
|
|
2748
2748
|
const o = n instanceof Error ? n : new Error(n);
|
|
@@ -2819,7 +2819,7 @@ class ge {
|
|
|
2819
2819
|
}
|
|
2820
2820
|
getReasonHeaderValue(e, t) {
|
|
2821
2821
|
const i = e;
|
|
2822
|
-
let s =
|
|
2822
|
+
let s = _e(e);
|
|
2823
2823
|
return !s && t && (s = t), "SIP;cause=" + i + ';text="' + s + '"';
|
|
2824
2824
|
}
|
|
2825
2825
|
referExtraHeaders(e) {
|
|
@@ -2843,7 +2843,7 @@ var G;
|
|
|
2843
2843
|
(function(a) {
|
|
2844
2844
|
a.Required = "Required", a.Supported = "Supported", a.Unsupported = "Unsupported";
|
|
2845
2845
|
})(G = G || (G = {}));
|
|
2846
|
-
const
|
|
2846
|
+
const Ht = {
|
|
2847
2847
|
"100rel": !0,
|
|
2848
2848
|
199: !0,
|
|
2849
2849
|
answermode: !0,
|
|
@@ -3030,7 +3030,7 @@ class ce extends ge {
|
|
|
3030
3030
|
const n = new Error(`Invalid session state ${this.state}`);
|
|
3031
3031
|
return this.logger.error(n.message), Promise.reject(n);
|
|
3032
3032
|
}
|
|
3033
|
-
const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase :
|
|
3033
|
+
const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase : _e(t), s = e.extraHeaders || [];
|
|
3034
3034
|
if (t < 300 || t > 699)
|
|
3035
3035
|
throw new TypeError("Invalid statusCode: " + t);
|
|
3036
3036
|
const r = e.body ? xe(e.body) : void 0;
|
|
@@ -3049,7 +3049,7 @@ class ce extends ge {
|
|
|
3049
3049
|
return;
|
|
3050
3050
|
}
|
|
3051
3051
|
if (this.delegate && this.delegate.onCancel) {
|
|
3052
|
-
const t = new
|
|
3052
|
+
const t = new It(e);
|
|
3053
3053
|
this.delegate.onCancel(t);
|
|
3054
3054
|
}
|
|
3055
3055
|
this.isCanceled = !0, this.incomingInviteRequest.reject({ statusCode: 487 }), this.stateTransition(m.Terminated);
|
|
@@ -3092,7 +3092,7 @@ class ce extends ge {
|
|
|
3092
3092
|
*/
|
|
3093
3093
|
handleResponseError(e) {
|
|
3094
3094
|
let t = 480;
|
|
3095
|
-
if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof
|
|
3095
|
+
if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof Be ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof Et ? this.logger.error("A session description handler occurred while sending response") : e instanceof He ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof ie && this.logger.error("Session changed state before response could be formulated and sent"), this.state === m.Initial || this.state === m.Establishing)
|
|
3096
3096
|
try {
|
|
3097
3097
|
this.incomingInviteRequest.reject({ statusCode: t }), this.stateTransition(m.Terminated);
|
|
3098
3098
|
} catch (i) {
|
|
@@ -3174,27 +3174,27 @@ class ce extends ge {
|
|
|
3174
3174
|
let u, w;
|
|
3175
3175
|
p.session.delegate = {
|
|
3176
3176
|
onPrack: (f) => {
|
|
3177
|
-
u = f, clearTimeout(I), clearTimeout(ae), this.waitingForPrack && (this.waitingForPrack = !1, this.handlePrackOfferAnswer(u).then((
|
|
3177
|
+
u = f, clearTimeout(I), clearTimeout(ae), this.waitingForPrack && (this.waitingForPrack = !1, this.handlePrackOfferAnswer(u).then((A) => {
|
|
3178
3178
|
try {
|
|
3179
|
-
w = u.accept({ statusCode: 200, body:
|
|
3179
|
+
w = u.accept({ statusCode: 200, body: A }), this.prackArrived(), o({ prackRequest: u, prackResponse: w, progressResponse: p });
|
|
3180
3180
|
} catch (ke) {
|
|
3181
3181
|
d(ke);
|
|
3182
3182
|
}
|
|
3183
|
-
}).catch((
|
|
3183
|
+
}).catch((A) => d(A)));
|
|
3184
3184
|
}
|
|
3185
3185
|
};
|
|
3186
3186
|
const I = setTimeout(() => {
|
|
3187
3187
|
this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(ae), this.reject({ statusCode: 504 }).then(() => d(new He())).catch((f) => d(f)));
|
|
3188
|
-
}, M.T1 * 64),
|
|
3188
|
+
}, M.T1 * 64), _ = () => {
|
|
3189
3189
|
try {
|
|
3190
3190
|
this.incomingInviteRequest.progress({ statusCode: i, reasonPhrase: s, extraHeaders: r, body: n });
|
|
3191
3191
|
} catch (f) {
|
|
3192
3192
|
this.waitingForPrack = !1, d(f);
|
|
3193
3193
|
return;
|
|
3194
3194
|
}
|
|
3195
|
-
ae = setTimeout(
|
|
3195
|
+
ae = setTimeout(_, E *= 2);
|
|
3196
3196
|
};
|
|
3197
|
-
let
|
|
3197
|
+
let E = M.T1, ae = setTimeout(_, E);
|
|
3198
3198
|
}).catch((p) => {
|
|
3199
3199
|
this.waitingForPrack = !1, d(p);
|
|
3200
3200
|
});
|
|
@@ -3239,7 +3239,7 @@ class ce extends ge {
|
|
|
3239
3239
|
this.waitingForPrackReject && this.waitingForPrackReject(new He()), this.waitingForPrackPromise = void 0, this.waitingForPrackResolve = void 0, this.waitingForPrackReject = void 0;
|
|
3240
3240
|
}
|
|
3241
3241
|
}
|
|
3242
|
-
class
|
|
3242
|
+
class Ce extends ge {
|
|
3243
3243
|
/**
|
|
3244
3244
|
* Constructs a new instance of the `Inviter` class.
|
|
3245
3245
|
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
@@ -3247,7 +3247,7 @@ class Ee extends ge {
|
|
|
3247
3247
|
* @param options - Options bucket. See {@link InviterOptions} for details.
|
|
3248
3248
|
*/
|
|
3249
3249
|
constructor(e, t, i = {}) {
|
|
3250
|
-
super(e, i), this.disposed = !1, this.earlyMedia = !1, this.earlyMediaSessionDescriptionHandlers = /* @__PURE__ */ new Map(), this.isCanceled = !1, this.inviteWithoutSdp = !1, this.logger = e.getLogger("sip.Inviter"), this.earlyMedia = i.earlyMedia !== void 0 ? i.earlyMedia : this.earlyMedia, this.fromTag =
|
|
3250
|
+
super(e, i), this.disposed = !1, this.earlyMedia = !1, this.earlyMediaSessionDescriptionHandlers = /* @__PURE__ */ new Map(), this.isCanceled = !1, this.inviteWithoutSdp = !1, this.logger = e.getLogger("sip.Inviter"), this.earlyMedia = i.earlyMedia !== void 0 ? i.earlyMedia : this.earlyMedia, this.fromTag = Ae(), this.inviteWithoutSdp = i.inviteWithoutSdp !== void 0 ? i.inviteWithoutSdp : this.inviteWithoutSdp;
|
|
3251
3251
|
const s = Object.assign({}, i);
|
|
3252
3252
|
s.params = Object.assign({}, i.params);
|
|
3253
3253
|
const r = i.anonymous || !1, n = e.contact.toString({
|
|
@@ -3339,7 +3339,7 @@ class Ee extends ge {
|
|
|
3339
3339
|
if (i && i < 200 || i > 699)
|
|
3340
3340
|
throw new TypeError("Invalid statusCode: " + i);
|
|
3341
3341
|
if (i) {
|
|
3342
|
-
const r = i, n =
|
|
3342
|
+
const r = i, n = _e(i) || s;
|
|
3343
3343
|
return "SIP;cause=" + r + ';text="' + n + '"';
|
|
3344
3344
|
}
|
|
3345
3345
|
}
|
|
@@ -3716,7 +3716,7 @@ class Ee extends ge {
|
|
|
3716
3716
|
}
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
|
-
class
|
|
3719
|
+
class Mt {
|
|
3720
3720
|
/**
|
|
3721
3721
|
* Constructs a new instance of the `Messager` class.
|
|
3722
3722
|
* @param userAgent - User agent. See {@link UserAgent} for details.
|
|
@@ -3896,7 +3896,7 @@ class z {
|
|
|
3896
3896
|
for (; n--; ) {
|
|
3897
3897
|
if (o = s.message.parseHeader("contact", n), !o)
|
|
3898
3898
|
throw new Error("Contact undefined");
|
|
3899
|
-
if (this.userAgent.contact.pubGruu &&
|
|
3899
|
+
if (this.userAgent.contact.pubGruu && Je(o.uri, this.userAgent.contact.pubGruu)) {
|
|
3900
3900
|
r = Number(o.getParam("expires"));
|
|
3901
3901
|
break;
|
|
3902
3902
|
}
|
|
@@ -3905,7 +3905,7 @@ class z {
|
|
|
3905
3905
|
r = Number(o.getParam("expires"));
|
|
3906
3906
|
break;
|
|
3907
3907
|
}
|
|
3908
|
-
} else if (
|
|
3908
|
+
} else if (Je(o.uri, this.userAgent.contact.uri)) {
|
|
3909
3909
|
r = Number(o.getParam("expires"));
|
|
3910
3910
|
break;
|
|
3911
3911
|
}
|
|
@@ -4208,7 +4208,7 @@ P.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592" && console.error("Md5
|
|
|
4208
4208
|
function ee(a) {
|
|
4209
4209
|
return P.hashStr(a);
|
|
4210
4210
|
}
|
|
4211
|
-
class
|
|
4211
|
+
class qt {
|
|
4212
4212
|
/**
|
|
4213
4213
|
* Constructor.
|
|
4214
4214
|
* @param loggerFactory - LoggerFactory.
|
|
@@ -4275,7 +4275,7 @@ var H;
|
|
|
4275
4275
|
(function(a) {
|
|
4276
4276
|
a[a.error = 0] = "error", a[a.warn = 1] = "warn", a[a.log = 2] = "log", a[a.debug = 3] = "debug";
|
|
4277
4277
|
})(H = H || (H = {}));
|
|
4278
|
-
class
|
|
4278
|
+
class Xe {
|
|
4279
4279
|
constructor(e, t, i) {
|
|
4280
4280
|
this.logger = e, this.category = t, this.label = i;
|
|
4281
4281
|
}
|
|
@@ -4301,7 +4301,7 @@ class Ze {
|
|
|
4301
4301
|
this.logger.level = e;
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
4304
|
-
class
|
|
4304
|
+
class Ot {
|
|
4305
4305
|
constructor() {
|
|
4306
4306
|
this.builtinEnabled = !0, this._level = H.log, this.loggers = {}, this.logger = this.getLogger("sip:loggerfactory");
|
|
4307
4307
|
}
|
|
@@ -4320,11 +4320,11 @@ class qt {
|
|
|
4320
4320
|
}
|
|
4321
4321
|
getLogger(e, t) {
|
|
4322
4322
|
if (t && this.level === 3)
|
|
4323
|
-
return new
|
|
4323
|
+
return new Xe(this, e, t);
|
|
4324
4324
|
if (this.loggers[e])
|
|
4325
4325
|
return this.loggers[e];
|
|
4326
4326
|
{
|
|
4327
|
-
const i = new
|
|
4327
|
+
const i = new Xe(this, e);
|
|
4328
4328
|
return this.loggers[e] = i, i;
|
|
4329
4329
|
}
|
|
4330
4330
|
}
|
|
@@ -4354,7 +4354,7 @@ class qt {
|
|
|
4354
4354
|
}
|
|
4355
4355
|
}
|
|
4356
4356
|
}
|
|
4357
|
-
var
|
|
4357
|
+
var Ee;
|
|
4358
4358
|
(function(a) {
|
|
4359
4359
|
function e(s, r) {
|
|
4360
4360
|
let n = r, o = 0, d = 0;
|
|
@@ -4481,23 +4481,23 @@ var Ce;
|
|
|
4481
4481
|
return u.hasHeader("content-length") ? u.body = s.substr(w, Number(u.getHeader("content-length"))) : u.body = s.substring(w), u;
|
|
4482
4482
|
}
|
|
4483
4483
|
a.parseMessage = i;
|
|
4484
|
-
})(
|
|
4485
|
-
function
|
|
4484
|
+
})(Ee = Ee || (Ee = {}));
|
|
4485
|
+
function lt(a, e) {
|
|
4486
4486
|
if (e.statusCode < 100 || e.statusCode > 699)
|
|
4487
4487
|
throw new TypeError("Invalid statusCode: " + e.statusCode);
|
|
4488
|
-
const i = e.reasonPhrase ? e.reasonPhrase :
|
|
4488
|
+
const i = e.reasonPhrase ? e.reasonPhrase : _e(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
4492
|
const r = "From: " + a.getHeader("From") + `\r
|
|
4493
4493
|
`, n = "Call-ID: " + a.callId + `\r
|
|
4494
4494
|
`, o = "CSeq: " + a.cseq + " " + a.method + `\r
|
|
4495
|
-
`, d = a.getHeaders("via").reduce((I,
|
|
4495
|
+
`, d = a.getHeaders("via").reduce((I, _) => I + "Via: " + _ + `\r
|
|
4496
4496
|
`, "");
|
|
4497
4497
|
let p = "To: " + a.getHeader("to");
|
|
4498
4498
|
if (e.statusCode > 100 && !a.parseHeader("to").hasParam("tag")) {
|
|
4499
4499
|
let I = e.toTag;
|
|
4500
|
-
I || (I =
|
|
4500
|
+
I || (I = Ae()), p += ";tag=" + I;
|
|
4501
4501
|
}
|
|
4502
4502
|
p += `\r
|
|
4503
4503
|
`;
|
|
@@ -4508,7 +4508,7 @@ function dt(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((I,
|
|
4511
|
+
return e.extraHeaders && (S = e.extraHeaders.reduce((I, _) => I + _.trim() + `\r
|
|
4512
4512
|
`, "")), s += d, s += r, s += p, s += o, s += n, s += u, s += w, s += S, e.body ? (s += "Content-Type: " + e.body.contentType + `\r
|
|
4513
4513
|
`, s += "Content-Length: " + ve(e.body.content) + `\r
|
|
4514
4514
|
\r
|
|
@@ -4521,7 +4521,7 @@ class qe extends le {
|
|
|
4521
4521
|
super(e || "Unspecified transport error.");
|
|
4522
4522
|
}
|
|
4523
4523
|
}
|
|
4524
|
-
class
|
|
4524
|
+
class ht {
|
|
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 lt {
|
|
|
4605
4605
|
return "UnknownType";
|
|
4606
4606
|
}
|
|
4607
4607
|
}
|
|
4608
|
-
class
|
|
4608
|
+
class ut extends ht {
|
|
4609
4609
|
constructor(e, t, i, s, r) {
|
|
4610
4610
|
super(t, i, e.viaBranch, s, r), this._request = e, this.user = i;
|
|
4611
4611
|
}
|
|
@@ -4618,7 +4618,7 @@ var g;
|
|
|
4618
4618
|
(function(a) {
|
|
4619
4619
|
a.Accepted = "Accepted", a.Calling = "Calling", a.Completed = "Completed", a.Confirmed = "Confirmed", a.Proceeding = "Proceeding", a.Terminated = "Terminated", a.Trying = "Trying";
|
|
4620
4620
|
})(g = g || (g = {}));
|
|
4621
|
-
class
|
|
4621
|
+
class N extends ut {
|
|
4622
4622
|
/**
|
|
4623
4623
|
* Constructor.
|
|
4624
4624
|
* Upon construction, a "100 Trying" reply will be immediately sent.
|
|
@@ -4848,7 +4848,7 @@ class U extends ht {
|
|
|
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 $e extends
|
|
4851
|
+
class $e extends ht {
|
|
4852
4852
|
constructor(e, t, i, s, r) {
|
|
4853
4853
|
super(t, i, $e.makeId(e), s, r), this._request = e, this.user = i, e.setViaHeader(this.id, t.protocol);
|
|
4854
4854
|
}
|
|
@@ -5047,10 +5047,10 @@ class fe {
|
|
|
5047
5047
|
const S = e.from.uri, I = e.to.uri;
|
|
5048
5048
|
if (!t.statusCode)
|
|
5049
5049
|
throw new Error("Incoming response status code undefined.");
|
|
5050
|
-
const
|
|
5050
|
+
const _ = t.statusCode < 200;
|
|
5051
5051
|
return {
|
|
5052
5052
|
id: p + u + w,
|
|
5053
|
-
early:
|
|
5053
|
+
early: _,
|
|
5054
5054
|
callId: p,
|
|
5055
5055
|
localTag: u,
|
|
5056
5056
|
remoteTag: w,
|
|
@@ -5076,7 +5076,7 @@ class fe {
|
|
|
5076
5076
|
throw new Error("Contact undefined.");
|
|
5077
5077
|
if (!(n instanceof F))
|
|
5078
5078
|
throw new Error("Contact not instance of NameAddrHeader.");
|
|
5079
|
-
const o = n.uri, d = e.cseq, p = void 0, u = e.callId, w = t, S = e.fromTag, I = e.from.uri,
|
|
5079
|
+
const o = n.uri, d = e.cseq, p = void 0, u = e.callId, w = t, S = e.fromTag, I = e.from.uri, _ = e.to.uri;
|
|
5080
5080
|
return {
|
|
5081
5081
|
id: u + w + S,
|
|
5082
5082
|
early: i,
|
|
@@ -5085,7 +5085,7 @@ class fe {
|
|
|
5085
5085
|
remoteTag: S,
|
|
5086
5086
|
localSequenceNumber: p,
|
|
5087
5087
|
remoteSequenceNumber: d,
|
|
5088
|
-
localURI:
|
|
5088
|
+
localURI: _,
|
|
5089
5089
|
remoteURI: I,
|
|
5090
5090
|
remoteTarget: o,
|
|
5091
5091
|
routeSet: r,
|
|
@@ -5653,13 +5653,13 @@ class q {
|
|
|
5653
5653
|
this.core.userAgentClients.set(i, this);
|
|
5654
5654
|
}
|
|
5655
5655
|
}
|
|
5656
|
-
class
|
|
5656
|
+
class Ft extends q {
|
|
5657
5657
|
constructor(e, t, i) {
|
|
5658
5658
|
const s = e.createOutgoingRequestMessage(v.BYE, i);
|
|
5659
5659
|
super(L, e.userAgentCore, s, t), e.dispose();
|
|
5660
5660
|
}
|
|
5661
5661
|
}
|
|
5662
|
-
class
|
|
5662
|
+
class U extends ut {
|
|
5663
5663
|
/**
|
|
5664
5664
|
* Constructor.
|
|
5665
5665
|
* After construction the transaction will be in the "trying": state and the transaction
|
|
@@ -5800,7 +5800,7 @@ class N extends ht {
|
|
|
5800
5800
|
}
|
|
5801
5801
|
class J {
|
|
5802
5802
|
constructor(e, t, i, s) {
|
|
5803
|
-
this.transactionConstructor = e, this.core = t, this.message = i, this.delegate = s, this.logger = this.loggerFactory.getLogger("sip.user-agent-server"), this.toTag = i.toTag ? i.toTag :
|
|
5803
|
+
this.transactionConstructor = e, this.core = t, this.message = i, this.delegate = s, this.logger = this.loggerFactory.getLogger("sip.user-agent-server"), this.toTag = i.toTag ? i.toTag : Ae(), this.init();
|
|
5804
5804
|
}
|
|
5805
5805
|
dispose() {
|
|
5806
5806
|
this.transaction.dispose();
|
|
@@ -5875,37 +5875,37 @@ class J {
|
|
|
5875
5875
|
this.delegate && this.delegate.onCancel && this.delegate.onCancel(e);
|
|
5876
5876
|
}
|
|
5877
5877
|
get acceptable() {
|
|
5878
|
-
if (this.transaction instanceof U)
|
|
5879
|
-
return this.transaction.state === g.Proceeding || this.transaction.state === g.Accepted;
|
|
5880
5878
|
if (this.transaction instanceof N)
|
|
5879
|
+
return this.transaction.state === g.Proceeding || this.transaction.state === g.Accepted;
|
|
5880
|
+
if (this.transaction instanceof U)
|
|
5881
5881
|
return this.transaction.state === g.Trying || this.transaction.state === g.Proceeding;
|
|
5882
5882
|
throw new Error("Unknown transaction type.");
|
|
5883
5883
|
}
|
|
5884
5884
|
get progressable() {
|
|
5885
|
-
if (this.transaction instanceof U)
|
|
5886
|
-
return this.transaction.state === g.Proceeding;
|
|
5887
5885
|
if (this.transaction instanceof N)
|
|
5886
|
+
return this.transaction.state === g.Proceeding;
|
|
5887
|
+
if (this.transaction instanceof U)
|
|
5888
5888
|
return !1;
|
|
5889
5889
|
throw new Error("Unknown transaction type.");
|
|
5890
5890
|
}
|
|
5891
5891
|
get redirectable() {
|
|
5892
|
-
if (this.transaction instanceof U)
|
|
5893
|
-
return this.transaction.state === g.Proceeding;
|
|
5894
5892
|
if (this.transaction instanceof N)
|
|
5893
|
+
return this.transaction.state === g.Proceeding;
|
|
5894
|
+
if (this.transaction instanceof U)
|
|
5895
5895
|
return this.transaction.state === g.Trying || this.transaction.state === g.Proceeding;
|
|
5896
5896
|
throw new Error("Unknown transaction type.");
|
|
5897
5897
|
}
|
|
5898
5898
|
get rejectable() {
|
|
5899
|
-
if (this.transaction instanceof U)
|
|
5900
|
-
return this.transaction.state === g.Proceeding;
|
|
5901
5899
|
if (this.transaction instanceof N)
|
|
5900
|
+
return this.transaction.state === g.Proceeding;
|
|
5901
|
+
if (this.transaction instanceof U)
|
|
5902
5902
|
return this.transaction.state === g.Trying || this.transaction.state === g.Proceeding;
|
|
5903
5903
|
throw new Error("Unknown transaction type.");
|
|
5904
5904
|
}
|
|
5905
5905
|
get tryingable() {
|
|
5906
|
-
if (this.transaction instanceof U)
|
|
5907
|
-
return this.transaction.state === g.Proceeding;
|
|
5908
5906
|
if (this.transaction instanceof N)
|
|
5907
|
+
return this.transaction.state === g.Proceeding;
|
|
5908
|
+
if (this.transaction instanceof U)
|
|
5909
5909
|
return this.transaction.state === g.Trying;
|
|
5910
5910
|
throw new Error("Unknown transaction type.");
|
|
5911
5911
|
}
|
|
@@ -5924,7 +5924,7 @@ class J {
|
|
|
5924
5924
|
*/
|
|
5925
5925
|
reply(e) {
|
|
5926
5926
|
!e.toTag && e.statusCode !== 100 && (e.toTag = this.toTag), e.userAgent = e.userAgent || this.core.configuration.userAgentHeaderFieldValue, e.supported = e.supported || this.core.configuration.supportedOptionTagsResponse;
|
|
5927
|
-
const t =
|
|
5927
|
+
const t = lt(this.message, e);
|
|
5928
5928
|
return this.transaction.receiveResponse(e.statusCode, t.message), t;
|
|
5929
5929
|
}
|
|
5930
5930
|
init() {
|
|
@@ -5942,9 +5942,9 @@ class J {
|
|
|
5942
5942
|
this.core.userAgentServers.set(t.id, this);
|
|
5943
5943
|
}
|
|
5944
5944
|
}
|
|
5945
|
-
class
|
|
5945
|
+
class Nt extends J {
|
|
5946
5946
|
constructor(e, t, i) {
|
|
5947
|
-
super(
|
|
5947
|
+
super(U, e.userAgentCore, t, i);
|
|
5948
5948
|
}
|
|
5949
5949
|
}
|
|
5950
5950
|
class Ut extends q {
|
|
@@ -5953,28 +5953,28 @@ class Ut extends q {
|
|
|
5953
5953
|
super(L, e.userAgentCore, s, t);
|
|
5954
5954
|
}
|
|
5955
5955
|
}
|
|
5956
|
-
class
|
|
5956
|
+
class Lt extends J {
|
|
5957
5957
|
constructor(e, t, i) {
|
|
5958
|
-
super(
|
|
5958
|
+
super(U, e.userAgentCore, t, i);
|
|
5959
5959
|
}
|
|
5960
5960
|
}
|
|
5961
|
-
class
|
|
5961
|
+
class gt extends q {
|
|
5962
5962
|
constructor(e, t, i) {
|
|
5963
5963
|
super(L, e, t, i);
|
|
5964
5964
|
}
|
|
5965
5965
|
}
|
|
5966
|
-
class
|
|
5966
|
+
class ft extends J {
|
|
5967
5967
|
constructor(e, t, i) {
|
|
5968
|
-
super(
|
|
5968
|
+
super(U, e, t, i);
|
|
5969
5969
|
}
|
|
5970
5970
|
}
|
|
5971
|
-
class
|
|
5971
|
+
class Bt extends q {
|
|
5972
5972
|
constructor(e, t, i) {
|
|
5973
5973
|
const s = e.createOutgoingRequestMessage(v.NOTIFY, i);
|
|
5974
5974
|
super(L, e.userAgentCore, s, t);
|
|
5975
5975
|
}
|
|
5976
5976
|
}
|
|
5977
|
-
function
|
|
5977
|
+
function jt(a) {
|
|
5978
5978
|
return a.userAgentCore !== void 0;
|
|
5979
5979
|
}
|
|
5980
5980
|
class Re extends J {
|
|
@@ -5984,19 +5984,19 @@ class Re extends J {
|
|
|
5984
5984
|
* @param message - Incoming NOTIFY request message.
|
|
5985
5985
|
*/
|
|
5986
5986
|
constructor(e, t, i) {
|
|
5987
|
-
const s =
|
|
5988
|
-
super(
|
|
5987
|
+
const s = jt(e) ? e.userAgentCore : e;
|
|
5988
|
+
super(U, s, t, i);
|
|
5989
5989
|
}
|
|
5990
5990
|
}
|
|
5991
|
-
class
|
|
5991
|
+
class Vt extends q {
|
|
5992
5992
|
constructor(e, t, i) {
|
|
5993
5993
|
const s = e.createOutgoingRequestMessage(v.PRACK, i);
|
|
5994
5994
|
super(L, e.userAgentCore, s, t), e.signalingStateTransition(s);
|
|
5995
5995
|
}
|
|
5996
5996
|
}
|
|
5997
|
-
class
|
|
5997
|
+
class Gt extends J {
|
|
5998
5998
|
constructor(e, t, i) {
|
|
5999
|
-
super(
|
|
5999
|
+
super(U, e.userAgentCore, t, i), e.signalingStateTransition(t), this.dialog = e;
|
|
6000
6000
|
}
|
|
6001
6001
|
/**
|
|
6002
6002
|
* Update the dialog signaling state on a 2xx response.
|
|
@@ -6006,7 +6006,7 @@ class Vt extends J {
|
|
|
6006
6006
|
return e.body && this.dialog.signalingStateTransition(e.body), super.accept(e);
|
|
6007
6007
|
}
|
|
6008
6008
|
}
|
|
6009
|
-
class
|
|
6009
|
+
class Wt extends q {
|
|
6010
6010
|
constructor(e, t, i) {
|
|
6011
6011
|
const s = e.createOutgoingRequestMessage(v.INVITE, i);
|
|
6012
6012
|
super(re, e.userAgentCore, s, t), this.delegate = t, e.signalingStateTransition(s), e.reinviteUserAgentClient = this, this.dialog = e;
|
|
@@ -6051,7 +6051,7 @@ class Gt extends q {
|
|
|
6051
6051
|
}
|
|
6052
6052
|
class Kt extends J {
|
|
6053
6053
|
constructor(e, t, i) {
|
|
6054
|
-
super(
|
|
6054
|
+
super(N, e.userAgentCore, t, i), e.reinviteUserAgentServer = this, this.dialog = e;
|
|
6055
6055
|
}
|
|
6056
6056
|
/**
|
|
6057
6057
|
* Update the dialog signaling state on a 2xx response.
|
|
@@ -6091,29 +6091,29 @@ class Kt extends J {
|
|
|
6091
6091
|
return this.dialog.signalingStateRollback(), this.dialog.reinviteUserAgentServer = void 0, super.reject(e);
|
|
6092
6092
|
}
|
|
6093
6093
|
}
|
|
6094
|
-
class
|
|
6094
|
+
class zt extends q {
|
|
6095
6095
|
constructor(e, t, i) {
|
|
6096
6096
|
const s = e.createOutgoingRequestMessage(v.REFER, i);
|
|
6097
6097
|
super(L, e.userAgentCore, s, t);
|
|
6098
6098
|
}
|
|
6099
6099
|
}
|
|
6100
|
-
function
|
|
6100
|
+
function Yt(a) {
|
|
6101
6101
|
return a.userAgentCore !== void 0;
|
|
6102
6102
|
}
|
|
6103
|
-
class
|
|
6103
|
+
class pt extends J {
|
|
6104
6104
|
/**
|
|
6105
6105
|
* REFER UAS constructor.
|
|
6106
6106
|
* @param dialogOrCore - Dialog for in dialog REFER, UserAgentCore for out of dialog REFER.
|
|
6107
6107
|
* @param message - Incoming REFER request message.
|
|
6108
6108
|
*/
|
|
6109
6109
|
constructor(e, t, i) {
|
|
6110
|
-
const s =
|
|
6111
|
-
super(
|
|
6110
|
+
const s = Yt(e) ? e.userAgentCore : e;
|
|
6111
|
+
super(U, s, t, i);
|
|
6112
6112
|
}
|
|
6113
6113
|
}
|
|
6114
6114
|
class Ie extends fe {
|
|
6115
6115
|
constructor(e, t, i, s) {
|
|
6116
|
-
super(t, i), this.initialTransaction = e, this._signalingState = b.Initial, this.ackWait = !1, this.ackProcessing = !1, this.delegate = s, e instanceof
|
|
6116
|
+
super(t, i), this.initialTransaction = e, this._signalingState = b.Initial, this.ackWait = !1, this.ackProcessing = !1, this.delegate = s, e instanceof N && (this.ackWait = !0), this.early || this.start2xxRetransmissionTimer(), this.signalingStateTransition(e.request), this.logger = t.loggerFactory.getLogger("sip.invite-dialog"), this.logger.log(`INVITE dialog ${this.id} constructed`);
|
|
6117
6117
|
}
|
|
6118
6118
|
dispose() {
|
|
6119
6119
|
super.dispose(), this._signalingState = b.Closed, this._offer = void 0, this._answer = void 0, this.invite2xxTimer && (clearTimeout(this.invite2xxTimer), this.invite2xxTimer = void 0), this.logger.log(`INVITE dialog ${this.id} destroyed`);
|
|
@@ -6214,13 +6214,13 @@ class Ie extends fe {
|
|
|
6214
6214
|
* while it's waiting on the ACK for its 2xx response.
|
|
6215
6215
|
*/
|
|
6216
6216
|
bye(e, t) {
|
|
6217
|
-
if (this.logger.log(`INVITE dialog ${this.id} sending BYE request`), this.initialTransaction instanceof
|
|
6217
|
+
if (this.logger.log(`INVITE dialog ${this.id} sending BYE request`), this.initialTransaction instanceof N) {
|
|
6218
6218
|
if (this.early)
|
|
6219
6219
|
throw new Error("UAS MUST NOT send a BYE on early dialogs.");
|
|
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 Ft(this, e, t);
|
|
6224
6224
|
}
|
|
6225
6225
|
/**
|
|
6226
6226
|
* An INFO request can be associated with an Info Package (see
|
|
@@ -6265,7 +6265,7 @@ class Ie extends fe {
|
|
|
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 Wt(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 Ie extends fe {
|
|
|
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 gt(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 Ie extends fe {
|
|
|
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 Bt(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 Ie extends fe {
|
|
|
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 Vt(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 Ie extends fe {
|
|
|
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 zt(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 Ie extends fe {
|
|
|
6391
6391
|
switch (e.method) {
|
|
6392
6392
|
case v.BYE:
|
|
6393
6393
|
{
|
|
6394
|
-
const t = new
|
|
6394
|
+
const t = new Nt(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 Lt(this, e);
|
|
6401
6401
|
this.delegate && this.delegate.onInfo ? this.delegate.onInfo(t) : t.reject({
|
|
6402
6402
|
statusCode: 469,
|
|
6403
6403
|
extraHeaders: ["Recv-Info:"]
|
|
@@ -6412,7 +6412,7 @@ class Ie extends fe {
|
|
|
6412
6412
|
break;
|
|
6413
6413
|
case v.MESSAGE:
|
|
6414
6414
|
{
|
|
6415
|
-
const t = new
|
|
6415
|
+
const t = new ft(this.core, e);
|
|
6416
6416
|
this.delegate && this.delegate.onMessage ? this.delegate.onMessage(t) : t.accept();
|
|
6417
6417
|
}
|
|
6418
6418
|
break;
|
|
@@ -6424,13 +6424,13 @@ class Ie extends fe {
|
|
|
6424
6424
|
break;
|
|
6425
6425
|
case v.PRACK:
|
|
6426
6426
|
{
|
|
6427
|
-
const t = new
|
|
6427
|
+
const t = new Gt(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 pt(this, e);
|
|
6434
6434
|
this.delegate && this.delegate.onRefer ? this.delegate.onRefer(t) : t.reject();
|
|
6435
6435
|
}
|
|
6436
6436
|
break;
|
|
@@ -6519,7 +6519,7 @@ class Ie extends fe {
|
|
|
6519
6519
|
default:
|
|
6520
6520
|
throw new Error("Unexpected signaling state.");
|
|
6521
6521
|
}
|
|
6522
|
-
if (
|
|
6522
|
+
if (ct(e))
|
|
6523
6523
|
switch (this._signalingState) {
|
|
6524
6524
|
case b.Initial:
|
|
6525
6525
|
case b.Stable:
|
|
@@ -6538,7 +6538,7 @@ class Ie extends fe {
|
|
|
6538
6538
|
}
|
|
6539
6539
|
}
|
|
6540
6540
|
start2xxRetransmissionTimer() {
|
|
6541
|
-
if (this.initialTransaction instanceof
|
|
6541
|
+
if (this.initialTransaction instanceof N) {
|
|
6542
6542
|
const e = this.initialTransaction;
|
|
6543
6543
|
let t = M.T1;
|
|
6544
6544
|
const i = () => {
|
|
@@ -6557,7 +6557,7 @@ class Ie extends fe {
|
|
|
6557
6557
|
}
|
|
6558
6558
|
// FIXME: Refactor
|
|
6559
6559
|
startReInvite2xxRetransmissionTimer() {
|
|
6560
|
-
if (this.reinviteUserAgentServer && this.reinviteUserAgentServer.transaction instanceof
|
|
6560
|
+
if (this.reinviteUserAgentServer && this.reinviteUserAgentServer.transaction instanceof N) {
|
|
6561
6561
|
const e = this.reinviteUserAgentServer.transaction;
|
|
6562
6562
|
let t = M.T1;
|
|
6563
6563
|
const i = () => {
|
|
@@ -6575,7 +6575,7 @@ class Ie extends fe {
|
|
|
6575
6575
|
}
|
|
6576
6576
|
}
|
|
6577
6577
|
}
|
|
6578
|
-
class
|
|
6578
|
+
class Jt extends q {
|
|
6579
6579
|
constructor(e, t, i) {
|
|
6580
6580
|
super(re, e, t, i), this.confirmedDialogAcks = /* @__PURE__ */ new Map(), this.confirmedDialogs = /* @__PURE__ */ new Map(), this.earlyDialogs = /* @__PURE__ */ new Map(), this.delegate = i;
|
|
6581
6581
|
}
|
|
@@ -6698,7 +6698,7 @@ class Yt extends q {
|
|
|
6698
6698
|
}
|
|
6699
6699
|
class Oe extends J {
|
|
6700
6700
|
constructor(e, t, i) {
|
|
6701
|
-
super(
|
|
6701
|
+
super(N, e, t, i), this.core = e;
|
|
6702
6702
|
}
|
|
6703
6703
|
dispose() {
|
|
6704
6704
|
this.earlyDialog && this.earlyDialog.dispose(), super.dispose();
|
|
@@ -6719,7 +6719,7 @@ class Oe extends J {
|
|
|
6719
6719
|
this.earlyDialog.confirm(), this.confirmedDialog = this.earlyDialog, this.earlyDialog = void 0;
|
|
6720
6720
|
else {
|
|
6721
6721
|
const d = this.transaction;
|
|
6722
|
-
if (!(d instanceof
|
|
6722
|
+
if (!(d instanceof N))
|
|
6723
6723
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6724
6724
|
const p = fe.initialDialogStateForUserAgentServer(this.message, this.toTag);
|
|
6725
6725
|
this.confirmedDialog = new Ie(d, this.core, p);
|
|
@@ -6762,7 +6762,7 @@ class Oe extends J {
|
|
|
6762
6762
|
throw new ie(`${this.message.method} not progressable in state ${this.transaction.state}.`);
|
|
6763
6763
|
if (!this.earlyDialog) {
|
|
6764
6764
|
const o = this.transaction;
|
|
6765
|
-
if (!(o instanceof
|
|
6765
|
+
if (!(o instanceof N))
|
|
6766
6766
|
throw new Error("Transaction not instance of InviteClientTransaction.");
|
|
6767
6767
|
const d = fe.initialDialogStateForUserAgentServer(this.message, this.toTag, !0);
|
|
6768
6768
|
this.earlyDialog = new Ie(o, this.core, d);
|
|
@@ -6799,22 +6799,22 @@ class Oe extends J {
|
|
|
6799
6799
|
return super.reject(e);
|
|
6800
6800
|
}
|
|
6801
6801
|
}
|
|
6802
|
-
class
|
|
6802
|
+
class Zt extends q {
|
|
6803
6803
|
constructor(e, t, i) {
|
|
6804
6804
|
super(L, e, t, i);
|
|
6805
6805
|
}
|
|
6806
6806
|
}
|
|
6807
|
-
class
|
|
6807
|
+
class Xt extends q {
|
|
6808
6808
|
constructor(e, t, i) {
|
|
6809
6809
|
super(L, e, t, i);
|
|
6810
6810
|
}
|
|
6811
6811
|
}
|
|
6812
|
-
class
|
|
6812
|
+
class Qt extends J {
|
|
6813
6813
|
constructor(e, t, i) {
|
|
6814
|
-
super(
|
|
6814
|
+
super(U, e, t, i), this.core = e;
|
|
6815
6815
|
}
|
|
6816
6816
|
}
|
|
6817
|
-
class
|
|
6817
|
+
class ei extends q {
|
|
6818
6818
|
constructor(e, t, i) {
|
|
6819
6819
|
const s = e.createOutgoingRequestMessage(v.SUBSCRIBE, i);
|
|
6820
6820
|
super(L, e.userAgentCore, s, t), this.dialog = e;
|
|
@@ -6838,7 +6838,7 @@ class Qt extends q {
|
|
|
6838
6838
|
e.statusCode && e.statusCode >= 400 && e.statusCode < 700 && [404, 405, 410, 416, 480, 481, 482, 483, 484, 485, 489, 501, 604].includes(e.statusCode) && this.dialog.terminate(), super.receiveResponse(e);
|
|
6839
6839
|
}
|
|
6840
6840
|
}
|
|
6841
|
-
class
|
|
6841
|
+
class Qe extends fe {
|
|
6842
6842
|
constructor(e, t, i, s, r, n) {
|
|
6843
6843
|
super(s, r), this.delegate = n, this._autoRefresh = !1, this._subscriptionEvent = e, this._subscriptionExpires = t, this._subscriptionExpiresInitial = t, this._subscriptionExpiresLastSet = Math.floor(Date.now() / 1e3), this._subscriptionRefresh = void 0, this._subscriptionRefreshLastSet = void 0, this._subscriptionState = i, this.logger = s.loggerFactory.getLogger("sip.subscribe-dialog"), this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`);
|
|
6844
6844
|
}
|
|
@@ -6951,7 +6951,7 @@ class Xe extends fe {
|
|
|
6951
6951
|
if (this.subscriptionState !== R.Pending && this.subscriptionState !== R.Active)
|
|
6952
6952
|
throw new Error(`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`);
|
|
6953
6953
|
this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);
|
|
6954
|
-
const s = new
|
|
6954
|
+
const s = new ei(this, e, t);
|
|
6955
6955
|
return this.N && (clearTimeout(this.N), this.N = void 0), !((i = t.extraHeaders) === null || i === void 0) && i.includes("Expires: 0") || (this.N = setTimeout(() => this.timerN(), M.TIMER_N)), s;
|
|
6956
6956
|
}
|
|
6957
6957
|
/**
|
|
@@ -7074,7 +7074,7 @@ class Xe extends fe {
|
|
|
7074
7074
|
this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."), this.subscriptionState !== R.Terminated && (this.stateTransition(R.Terminated), this.onTerminated());
|
|
7075
7075
|
}
|
|
7076
7076
|
}
|
|
7077
|
-
class
|
|
7077
|
+
class ti extends q {
|
|
7078
7078
|
constructor(e, t, i) {
|
|
7079
7079
|
const s = t.getHeader("Event");
|
|
7080
7080
|
if (!s)
|
|
@@ -7144,8 +7144,8 @@ class ei extends q {
|
|
|
7144
7144
|
throw new Error(`Unrecognized state ${s}.`);
|
|
7145
7145
|
}
|
|
7146
7146
|
if (this.subscriptionState !== R.Terminated) {
|
|
7147
|
-
const r =
|
|
7148
|
-
this.dialog = new
|
|
7147
|
+
const r = Qe.initialDialogStateForSubscription(this.message, e.message);
|
|
7148
|
+
this.dialog = new Qe(this.subscriptionEvent, this.subscriptionExpires, this.subscriptionState, this.core, r);
|
|
7149
7149
|
}
|
|
7150
7150
|
if (this.delegate && this.delegate.onNotify) {
|
|
7151
7151
|
const r = e, n = this.dialog;
|
|
@@ -7191,13 +7191,13 @@ class ei extends q {
|
|
|
7191
7191
|
this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."), this.waitNotifyStop(), this.delegate && this.delegate.onNotifyTimeout && this.delegate.onNotifyTimeout();
|
|
7192
7192
|
}
|
|
7193
7193
|
}
|
|
7194
|
-
class
|
|
7194
|
+
class ii extends J {
|
|
7195
7195
|
constructor(e, t, i) {
|
|
7196
|
-
super(
|
|
7196
|
+
super(U, e, t, i), this.core = e;
|
|
7197
7197
|
}
|
|
7198
7198
|
}
|
|
7199
|
-
const
|
|
7200
|
-
class
|
|
7199
|
+
const et = ["application/sdp", "application/dtmf-relay"];
|
|
7200
|
+
class si {
|
|
7201
7201
|
/**
|
|
7202
7202
|
* Constructor.
|
|
7203
7203
|
* @param configuration - Configuration.
|
|
@@ -7231,7 +7231,7 @@ class ii {
|
|
|
7231
7231
|
* @param delegate - Request delegate.
|
|
7232
7232
|
*/
|
|
7233
7233
|
invite(e, t) {
|
|
7234
|
-
return new
|
|
7234
|
+
return new Jt(this, e, t);
|
|
7235
7235
|
}
|
|
7236
7236
|
/**
|
|
7237
7237
|
* Send MESSAGE.
|
|
@@ -7239,7 +7239,7 @@ class ii {
|
|
|
7239
7239
|
* @param delegate - Request delegate.
|
|
7240
7240
|
*/
|
|
7241
7241
|
message(e, t) {
|
|
7242
|
-
return new
|
|
7242
|
+
return new gt(this, e, t);
|
|
7243
7243
|
}
|
|
7244
7244
|
/**
|
|
7245
7245
|
* Send PUBLISH.
|
|
@@ -7247,7 +7247,7 @@ class ii {
|
|
|
7247
7247
|
* @param delegate - Request delegate.
|
|
7248
7248
|
*/
|
|
7249
7249
|
publish(e, t) {
|
|
7250
|
-
return new
|
|
7250
|
+
return new Zt(this, e, t);
|
|
7251
7251
|
}
|
|
7252
7252
|
/**
|
|
7253
7253
|
* Send REGISTER.
|
|
@@ -7255,7 +7255,7 @@ class ii {
|
|
|
7255
7255
|
* @param delegate - Request delegate.
|
|
7256
7256
|
*/
|
|
7257
7257
|
register(e, t) {
|
|
7258
|
-
return new
|
|
7258
|
+
return new Xt(this, e, t);
|
|
7259
7259
|
}
|
|
7260
7260
|
/**
|
|
7261
7261
|
* Send SUBSCRIBE.
|
|
@@ -7263,7 +7263,7 @@ class ii {
|
|
|
7263
7263
|
* @param delegate - Request delegate.
|
|
7264
7264
|
*/
|
|
7265
7265
|
subscribe(e, t) {
|
|
7266
|
-
return new
|
|
7266
|
+
return new ti(this, e, t);
|
|
7267
7267
|
}
|
|
7268
7268
|
/**
|
|
7269
7269
|
* Send a request.
|
|
@@ -7286,15 +7286,15 @@ class ii {
|
|
|
7286
7286
|
makeOutgoingRequestMessage(e, t, i, s, r, n, o) {
|
|
7287
7287
|
const d = this.configuration.sipjsId, p = this.configuration.displayName, u = 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 I = this.configuration.routeSet,
|
|
7289
|
+
const I = this.configuration.routeSet, _ = this.configuration.userAgentHeaderFieldValue, E = this.configuration.viaHost, f = Object.assign(Object.assign({}, {
|
|
7290
7290
|
callIdPrefix: d,
|
|
7291
7291
|
forceRport: u,
|
|
7292
7292
|
fromDisplayName: p,
|
|
7293
7293
|
hackViaTcp: w,
|
|
7294
7294
|
optionTags: S,
|
|
7295
7295
|
routeSet: I,
|
|
7296
|
-
userAgentString:
|
|
7297
|
-
viaHost:
|
|
7296
|
+
userAgentString: _,
|
|
7297
|
+
viaHost: E
|
|
7298
7298
|
}), r);
|
|
7299
7299
|
return new de(e, t, i, s, f, n, o);
|
|
7300
7300
|
}
|
|
@@ -7331,7 +7331,7 @@ class ii {
|
|
|
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 = lt(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;
|
|
@@ -7355,7 +7355,7 @@ class ii {
|
|
|
7355
7355
|
return;
|
|
7356
7356
|
}
|
|
7357
7357
|
if (e.method === v.CANCEL) {
|
|
7358
|
-
i ? (this.replyStateless(e, { statusCode: 200 }), i.transaction instanceof
|
|
7358
|
+
i ? (this.replyStateless(e, { statusCode: 200 }), i.transaction instanceof N && i.transaction.state === g.Proceeding && i instanceof Oe && i.receiveCancel(e)) : this.replyStateless(e, { statusCode: 481 });
|
|
7359
7359
|
return;
|
|
7360
7360
|
}
|
|
7361
7361
|
if (i) {
|
|
@@ -7436,7 +7436,7 @@ class ii {
|
|
|
7436
7436
|
const t = e.callId + e.toTag + e.fromTag, i = this.dialogs.get(t);
|
|
7437
7437
|
if (i) {
|
|
7438
7438
|
if (e.method === v.OPTIONS) {
|
|
7439
|
-
const s = "Allow: " + se.toString(), r = "Accept: " +
|
|
7439
|
+
const s = "Allow: " + se.toString(), r = "Accept: " + et.toString();
|
|
7440
7440
|
this.replyStateless(e, {
|
|
7441
7441
|
statusCode: 200,
|
|
7442
7442
|
extraHeaders: [s, r]
|
|
@@ -7474,7 +7474,7 @@ class ii {
|
|
|
7474
7474
|
break;
|
|
7475
7475
|
case v.MESSAGE:
|
|
7476
7476
|
{
|
|
7477
|
-
const t = new
|
|
7477
|
+
const t = new ft(this, e);
|
|
7478
7478
|
this.delegate.onMessage ? this.delegate.onMessage(t) : t.accept();
|
|
7479
7479
|
}
|
|
7480
7480
|
break;
|
|
@@ -7486,7 +7486,7 @@ class ii {
|
|
|
7486
7486
|
break;
|
|
7487
7487
|
case v.OPTIONS:
|
|
7488
7488
|
{
|
|
7489
|
-
const t = "Allow: " + se.toString(), i = "Accept: " +
|
|
7489
|
+
const t = "Allow: " + se.toString(), i = "Accept: " + et.toString();
|
|
7490
7490
|
this.replyStateless(e, {
|
|
7491
7491
|
statusCode: 200,
|
|
7492
7492
|
extraHeaders: [t, i]
|
|
@@ -7495,19 +7495,19 @@ class ii {
|
|
|
7495
7495
|
break;
|
|
7496
7496
|
case v.REFER:
|
|
7497
7497
|
{
|
|
7498
|
-
const t = new
|
|
7498
|
+
const t = new pt(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 Qt(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 ii(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 ii {
|
|
|
7533
7533
|
i ? i.transaction.receiveResponse(e) : this.logger.warn(`Discarding unmatched ${e.statusCode} response to ${e.method} ${t}.`);
|
|
7534
7534
|
}
|
|
7535
7535
|
}
|
|
7536
|
-
function
|
|
7536
|
+
function ri() {
|
|
7537
7537
|
return (a) => !a.audio && !a.video ? Promise.resolve(new MediaStream()) : navigator.mediaDevices === void 0 ? Promise.reject(new Error("Media devices not available in insecure contexts.")) : navigator.mediaDevices.getUserMedia.call(navigator.mediaDevices, a);
|
|
7538
7538
|
}
|
|
7539
|
-
function
|
|
7539
|
+
function ni() {
|
|
7540
7540
|
return {
|
|
7541
7541
|
bundlePolicy: "balanced",
|
|
7542
7542
|
certificates: void 0,
|
|
@@ -8078,12 +8078,12 @@ class O {
|
|
|
8078
8078
|
};
|
|
8079
8079
|
}
|
|
8080
8080
|
}
|
|
8081
|
-
function
|
|
8081
|
+
function ai(a) {
|
|
8082
8082
|
return (e, t) => {
|
|
8083
|
-
a === void 0 && (a =
|
|
8083
|
+
a === void 0 && (a = ri());
|
|
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({}, ni()), t?.peerConnectionConfiguration)
|
|
8087
8087
|
}, r = e.userAgent.getLogger("sip.SessionDescriptionHandler");
|
|
8088
8088
|
return new O(r, a, s);
|
|
8089
8089
|
};
|
|
@@ -8501,7 +8501,7 @@ class V {
|
|
|
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 Ot(), this.logger = this.loggerFactory.getLogger("sip.UserAgent"), this.loggerFactory.builtinEnabled = this.options.logBuiltinEnabled, this.loggerFactory.connector = this.options.logConnector, this.options.logLevel) {
|
|
8505
8505
|
case "error":
|
|
8506
8506
|
this.loggerFactory.level = H.error;
|
|
8507
8507
|
break;
|
|
@@ -8585,7 +8585,7 @@ class V {
|
|
|
8585
8585
|
reconnectionAttempts: 0,
|
|
8586
8586
|
reconnectionDelay: 4,
|
|
8587
8587
|
sendInitialProvisionalResponse: !0,
|
|
8588
|
-
sessionDescriptionHandlerFactory:
|
|
8588
|
+
sessionDescriptionHandlerFactory: ai(),
|
|
8589
8589
|
sessionDescriptionHandlerFactoryOptions: {},
|
|
8590
8590
|
sipExtension100rel: G.Unsupported,
|
|
8591
8591
|
sipExtensionReplaces: G.Unsupported,
|
|
@@ -8594,7 +8594,7 @@ class V {
|
|
|
8594
8594
|
transportConstructor: Se,
|
|
8595
8595
|
transportOptions: {},
|
|
8596
8596
|
uri: new Y("sip", "anonymous", "anonymous.invalid"),
|
|
8597
|
-
userAgentString: "SIP.js/" +
|
|
8597
|
+
userAgentString: "SIP.js/" + Ct,
|
|
8598
8598
|
viaHost: ""
|
|
8599
8599
|
};
|
|
8600
8600
|
}
|
|
@@ -8769,7 +8769,7 @@ class V {
|
|
|
8769
8769
|
* @internal
|
|
8770
8770
|
*/
|
|
8771
8771
|
_makeInviter(e, t) {
|
|
8772
|
-
return new
|
|
8772
|
+
return new Ce(this, e, t);
|
|
8773
8773
|
}
|
|
8774
8774
|
/**
|
|
8775
8775
|
* Attempt reconnection up to `maxReconnectionAttempts` times.
|
|
@@ -8810,7 +8810,7 @@ class V {
|
|
|
8810
8810
|
*/
|
|
8811
8811
|
initCore() {
|
|
8812
8812
|
let e = [];
|
|
8813
|
-
e.push("outbound"), this.options.sipExtension100rel === G.Supported && e.push("100rel"), this.options.sipExtensionReplaces === G.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) =>
|
|
8813
|
+
e.push("outbound"), this.options.sipExtension100rel === G.Supported && e.push("100rel"), this.options.sipExtensionReplaces === G.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Ht[r])), e = Array.from(new Set(e));
|
|
8814
8814
|
const t = e.slice();
|
|
8815
8815
|
(this.contact.pubGruu || this.contact.tempGruu) && t.push("gruu");
|
|
8816
8816
|
const i = {
|
|
@@ -8828,7 +8828,7 @@ class V {
|
|
|
8828
8828
|
viaHost: this.options.viaHost,
|
|
8829
8829
|
authenticationFactory: () => {
|
|
8830
8830
|
const r = this.options.authorizationUsername ? this.options.authorizationUsername : this.options.uri.user, n = this.options.authorizationPassword ? this.options.authorizationPassword : void 0, o = this.options.authorizationHa1 ? this.options.authorizationHa1 : void 0;
|
|
8831
|
-
return new
|
|
8831
|
+
return new qt(this.getLoggerFactory(), o, r, n);
|
|
8832
8832
|
},
|
|
8833
8833
|
transportAccessor: () => this.transport
|
|
8834
8834
|
}, s = {
|
|
@@ -8855,19 +8855,19 @@ class V {
|
|
|
8855
8855
|
const S = p.replaces_from_tag;
|
|
8856
8856
|
if (typeof S != "string")
|
|
8857
8857
|
throw new Error("type of from tag is not string");
|
|
8858
|
-
const I = u + w + S,
|
|
8859
|
-
if (!
|
|
8858
|
+
const I = u + w + S, _ = this.userAgentCore.dialogs.get(I);
|
|
8859
|
+
if (!_) {
|
|
8860
8860
|
o.reject({ statusCode: 481 });
|
|
8861
8861
|
return;
|
|
8862
8862
|
}
|
|
8863
|
-
if (!
|
|
8863
|
+
if (!_.early && p.early_only === !0) {
|
|
8864
8864
|
o.reject({ statusCode: 486 });
|
|
8865
8865
|
return;
|
|
8866
8866
|
}
|
|
8867
|
-
const
|
|
8868
|
-
if (!
|
|
8867
|
+
const E = this._sessions[u + S] || this._sessions[u + w] || void 0;
|
|
8868
|
+
if (!E)
|
|
8869
8869
|
throw new Error("Session does not exist.");
|
|
8870
|
-
o._replacee =
|
|
8870
|
+
o._replacee = E;
|
|
8871
8871
|
}
|
|
8872
8872
|
}
|
|
8873
8873
|
if (!((n = this.delegate) === null || n === void 0) && n.onInvite) {
|
|
@@ -8887,14 +8887,14 @@ class V {
|
|
|
8887
8887
|
},
|
|
8888
8888
|
onMessage: (r) => {
|
|
8889
8889
|
if (this.delegate && this.delegate.onMessage) {
|
|
8890
|
-
const n = new
|
|
8890
|
+
const n = new dt(r);
|
|
8891
8891
|
this.delegate.onMessage(n);
|
|
8892
8892
|
} else
|
|
8893
8893
|
r.accept();
|
|
8894
8894
|
},
|
|
8895
8895
|
onNotify: (r) => {
|
|
8896
8896
|
if (this.delegate && this.delegate.onNotify) {
|
|
8897
|
-
const n = new
|
|
8897
|
+
const n = new je(r);
|
|
8898
8898
|
this.delegate.onNotify(n);
|
|
8899
8899
|
} else
|
|
8900
8900
|
this.options.allowLegacyNotifications ? r.accept() : r.reject({ statusCode: 481 });
|
|
@@ -8909,7 +8909,7 @@ class V {
|
|
|
8909
8909
|
this.logger.warn("Received an out of dialog SUBSCRIBE request"), this.delegate && this.delegate.onSubscribeRequest ? this.delegate.onSubscribeRequest(r) : r.reject({ statusCode: 405 });
|
|
8910
8910
|
}
|
|
8911
8911
|
};
|
|
8912
|
-
return new
|
|
8912
|
+
return new si(i, s);
|
|
8913
8913
|
}
|
|
8914
8914
|
initTransportCallbacks() {
|
|
8915
8915
|
this.transport.onConnect = () => this.onTransportConnect(), this.transport.onDisconnect = (e) => this.onTransportDisconnect(e), this.transport.onMessage = (e) => this.onTransportMessage(e);
|
|
@@ -8921,7 +8921,7 @@ class V {
|
|
|
8921
8921
|
this.state !== D.Stopped && (this.delegate && this.delegate.onDisconnect && this.delegate.onDisconnect(e), e && this.options.reconnectionAttempts > 0 && this.attemptReconnection());
|
|
8922
8922
|
}
|
|
8923
8923
|
onTransportMessage(e) {
|
|
8924
|
-
const t =
|
|
8924
|
+
const t = Ee.parseMessage(e, this.getLogger("sip.Parser"));
|
|
8925
8925
|
if (!t) {
|
|
8926
8926
|
this.logger.warn("Failed to parse incoming message. Dropping.");
|
|
8927
8927
|
return;
|
|
@@ -9002,10 +9002,10 @@ class V {
|
|
|
9002
9002
|
this.logger.log(`Transitioned from ${this._state} to ${e}`), this._state = e, this._stateEventEmitter.emit(this._state);
|
|
9003
9003
|
}
|
|
9004
9004
|
}
|
|
9005
|
-
function
|
|
9005
|
+
function oi() {
|
|
9006
9006
|
return (a, e) => ({ session: e, held: !1, muted: !1 });
|
|
9007
9007
|
}
|
|
9008
|
-
class
|
|
9008
|
+
class Ge {
|
|
9009
9009
|
/**
|
|
9010
9010
|
* Constructs a new instance of the `SessionManager` class.
|
|
9011
9011
|
* @param server - SIP WebSocket Server URL.
|
|
@@ -9017,7 +9017,7 @@ class Ve {
|
|
|
9017
9017
|
autoStop: !0,
|
|
9018
9018
|
delegate: {},
|
|
9019
9019
|
iceStopWaitingOnServerReflexive: !1,
|
|
9020
|
-
managedSessionFactory:
|
|
9020
|
+
managedSessionFactory: oi(),
|
|
9021
9021
|
maxSimultaneousSessions: 2,
|
|
9022
9022
|
media: {},
|
|
9023
9023
|
optionsPingInterval: -1,
|
|
@@ -9031,7 +9031,7 @@ class Ve {
|
|
|
9031
9031
|
registererRegisterOptions: {},
|
|
9032
9032
|
sendDTMFUsingSessionDescriptionHandler: !1,
|
|
9033
9033
|
userAgentOptions: {}
|
|
9034
|
-
},
|
|
9034
|
+
}, Ge.stripUndefinedProperties(t));
|
|
9035
9035
|
const i = Object.assign({}, t.userAgentOptions);
|
|
9036
9036
|
if (i.transportConstructor || (i.transportConstructor = Se), i.transportOptions || (i.transportOptions = {
|
|
9037
9037
|
server: e
|
|
@@ -9267,7 +9267,7 @@ class Ve {
|
|
|
9267
9267
|
}
|
|
9268
9268
|
};
|
|
9269
9269
|
});
|
|
9270
|
-
const n = new
|
|
9270
|
+
const n = new Ce(this.userAgent, r, t);
|
|
9271
9271
|
return this.sendInvite(n, t, i).then(() => n);
|
|
9272
9272
|
}
|
|
9273
9273
|
/**
|
|
@@ -9419,7 +9419,7 @@ Duration=` + 2e3
|
|
|
9419
9419
|
async message(e, t) {
|
|
9420
9420
|
this.logger.log("Sending message...");
|
|
9421
9421
|
const i = V.makeURI(e);
|
|
9422
|
-
return i ? new
|
|
9422
|
+
return i ? new Mt(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() {
|
|
@@ -9749,7 +9749,7 @@ Duration=` + 2e3
|
|
|
9749
9749
|
async terminate(e) {
|
|
9750
9750
|
switch (this.logger.log(`[${e.id}] Terminating...`), e.state) {
|
|
9751
9751
|
case m.Initial:
|
|
9752
|
-
if (e instanceof
|
|
9752
|
+
if (e instanceof Ce)
|
|
9753
9753
|
return e.cancel().then(() => {
|
|
9754
9754
|
this.logger.log(`[${e.id}] Inviter never sent INVITE (canceled)`);
|
|
9755
9755
|
});
|
|
@@ -9759,7 +9759,7 @@ Duration=` + 2e3
|
|
|
9759
9759
|
});
|
|
9760
9760
|
throw new Error("Unknown session type.");
|
|
9761
9761
|
case m.Establishing:
|
|
9762
|
-
if (e instanceof
|
|
9762
|
+
if (e instanceof Ce)
|
|
9763
9763
|
return e.cancel().then(() => {
|
|
9764
9764
|
this.logger.log(`[${e.id}] Inviter canceled (sent CANCEL)`);
|
|
9765
9765
|
});
|
|
@@ -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 ci {
|
|
9786
9786
|
/**
|
|
9787
9787
|
* Constructs a new instance of the `SimpleUser` class.
|
|
9788
9788
|
* @param server - SIP WebSocket Server URL.
|
|
@@ -9846,7 +9846,7 @@ class oi {
|
|
|
9846
9846
|
sendDTMFUsingSessionDescriptionHandler: this.options.sendDTMFUsingSessionDescriptionHandler,
|
|
9847
9847
|
userAgentOptions: this.options.userAgentOptions
|
|
9848
9848
|
};
|
|
9849
|
-
this.sessionManager = new
|
|
9849
|
+
this.sessionManager = new Ge(e, i), this.logger = this.sessionManager.userAgent.getLogger("sip.SimpleUser");
|
|
9850
9850
|
}
|
|
9851
9851
|
/**
|
|
9852
9852
|
* Instance identifier.
|
|
@@ -10051,13 +10051,13 @@ class oi {
|
|
|
10051
10051
|
return this.logger.log(`[${this.id}] sending message...`), this.sessionManager.message(e, t);
|
|
10052
10052
|
}
|
|
10053
10053
|
}
|
|
10054
|
-
const Fe = (a, e, t) => {
|
|
10054
|
+
const di = 15e3, li = 15e3, Fe = (a, e, t) => {
|
|
10055
10055
|
const i = String(a?.name || a?.code || "").trim(), s = new Error(e);
|
|
10056
10056
|
return s.name = i || "MediaAccessError", s.code = t, s.cause = a, s;
|
|
10057
|
-
},
|
|
10057
|
+
}, Ne = (a) => {
|
|
10058
10058
|
const e = new Error(a);
|
|
10059
10059
|
return e.name = "SipClientLifecycleCancelledError", e.code = "sip_client_replaced", e;
|
|
10060
|
-
},
|
|
10060
|
+
}, Ve = async (a, e = "call") => {
|
|
10061
10061
|
const t = String(a?.name || a?.code || "").trim(), i = String(a?.message || "").trim(), s = `${t} ${i}`.toLowerCase();
|
|
10062
10062
|
let r = "";
|
|
10063
10063
|
try {
|
|
@@ -10081,17 +10081,17 @@ const Fe = (a, e, t) => {
|
|
|
10081
10081
|
"麦克风当前被系统或其他应用占用,无法建立语音通话。请关闭占用麦克风的程序后重试。",
|
|
10082
10082
|
"media_device_unavailable"
|
|
10083
10083
|
) : a;
|
|
10084
|
-
},
|
|
10084
|
+
}, hi = async (a = "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
|
|
10091
|
+
throw await Ve(t, a);
|
|
10092
10092
|
}
|
|
10093
10093
|
};
|
|
10094
|
-
class
|
|
10094
|
+
class ui {
|
|
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 li {
|
|
|
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.peerConnectionDebug = {
|
|
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) : di, this.registrationConfirmTimeoutMs = Number.isFinite(Number(t.registrationConfirmTimeoutMs)) ? Number(t.registrationConfirmTimeoutMs) : li, this.peerConnectionDebug = {
|
|
10103
10103
|
attached: !1,
|
|
10104
10104
|
events: [],
|
|
10105
10105
|
iceCandidates: [],
|
|
@@ -10323,19 +10323,19 @@ class li {
|
|
|
10323
10323
|
registererOptions: {
|
|
10324
10324
|
expires: 1800
|
|
10325
10325
|
}
|
|
10326
|
-
}, w = new
|
|
10326
|
+
}, w = new ci(d, u);
|
|
10327
10327
|
return w.delegate = {
|
|
10328
10328
|
onServerConnect: () => {
|
|
10329
|
-
this.connected = !0, this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
|
|
10329
|
+
this.connected = !0, this._resolveConnectionWaiters(), this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
|
|
10330
10330
|
},
|
|
10331
10331
|
onServerDisconnect: (S) => {
|
|
10332
|
-
this.connected = !1, this.registered = !1, this.active = !1, this.onError && this.onError(S || new Error("呼叫服务器已断开")), this.onStateChange && this.onStateChange("disconnected", this.getConnectionSnapshot()), this._stopRingback(), this._stopIncomingTone();
|
|
10332
|
+
this.connected = !1, this.registered = !1, this.active = !1, this._rejectConnectionWaiters(S || new Error("呼叫服务器已断开")), this._rejectRegistrationWaiters(S || new Error("呼叫服务器已断开")), this.onError && this.onError(S || new Error("呼叫服务器已断开")), this.onStateChange && this.onStateChange("disconnected", this.getConnectionSnapshot()), this._stopRingback(), this._stopIncomingTone();
|
|
10333
10333
|
},
|
|
10334
10334
|
onRegistered: () => {
|
|
10335
|
-
this.registered = !0, this.onStateChange && this.onStateChange("registered", this.getConnectionSnapshot());
|
|
10335
|
+
this.registered = !0, this._resolveRegistrationWaiters(), this.onStateChange && this.onStateChange("registered", this.getConnectionSnapshot());
|
|
10336
10336
|
},
|
|
10337
10337
|
onUnregistered: () => {
|
|
10338
|
-
this.registered = !1, this.onStateChange && this.onStateChange("unregistered", this.getConnectionSnapshot());
|
|
10338
|
+
this.registered = !1, this._rejectRegistrationWaiters(new Error("SIP 注册已被取消或失效。")), this.onStateChange && this.onStateChange("unregistered", this.getConnectionSnapshot());
|
|
10339
10339
|
},
|
|
10340
10340
|
onCallCreated: () => {
|
|
10341
10341
|
const S = this._isIncomingSession();
|
|
@@ -10352,8 +10352,8 @@ class li {
|
|
|
10352
10352
|
if (this.active = !1, this.onStateChange) {
|
|
10353
10353
|
const I = this.lastFailureMeta ? { ...this.lastFailureMeta } : {};
|
|
10354
10354
|
I.hangupSource = this.hangupInitiatedByLocal ? "local" : S ? "remote" : "unknown";
|
|
10355
|
-
const
|
|
10356
|
-
|
|
10355
|
+
const _ = this.lastSessionMeta || this._buildIncomingCallMeta();
|
|
10356
|
+
_ && Object.keys(_).length > 0 && (I.callMeta = _), this.onStateChange("terminated", I);
|
|
10357
10357
|
}
|
|
10358
10358
|
this.hangupInitiatedByLocal = !1, this._stopAllAudioMonitors(), this._reportAudioSilence(), this._stopRingback(), this._stopIncomingTone(), this.lastFailureMeta = null, this.lastSessionMeta = null;
|
|
10359
10359
|
}
|
|
@@ -10402,16 +10402,149 @@ class li {
|
|
|
10402
10402
|
}
|
|
10403
10403
|
_assertSimpleUserIsCurrent(e, t = "当前操作") {
|
|
10404
10404
|
if (!(e && this.simpleUser === e && this.account))
|
|
10405
|
-
throw
|
|
10405
|
+
throw Ne(`SIP 客户端已重置,已取消${t}。`);
|
|
10406
10406
|
}
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10407
|
+
_resolveRegistrationWaiters() {
|
|
10408
|
+
if (!this.registrationWaiters.size)
|
|
10409
|
+
return;
|
|
10410
|
+
const e = Array.from(this.registrationWaiters);
|
|
10411
|
+
this.registrationWaiters.clear(), e.forEach((t) => {
|
|
10410
10412
|
try {
|
|
10411
|
-
|
|
10412
|
-
} catch
|
|
10413
|
-
throw this.onError && this.onError(t), t;
|
|
10413
|
+
t.resolve();
|
|
10414
|
+
} catch {
|
|
10414
10415
|
}
|
|
10416
|
+
});
|
|
10417
|
+
}
|
|
10418
|
+
_rejectRegistrationWaiters(e) {
|
|
10419
|
+
if (!this.registrationWaiters.size)
|
|
10420
|
+
return;
|
|
10421
|
+
const t = Array.from(this.registrationWaiters);
|
|
10422
|
+
this.registrationWaiters.clear();
|
|
10423
|
+
const i = e instanceof Error ? e : new Error("SIP 注册未完成即已中断。");
|
|
10424
|
+
t.forEach((s) => {
|
|
10425
|
+
try {
|
|
10426
|
+
s.reject(i);
|
|
10427
|
+
} catch {
|
|
10428
|
+
}
|
|
10429
|
+
});
|
|
10430
|
+
}
|
|
10431
|
+
_resolveConnectionWaiters() {
|
|
10432
|
+
if (!this.connectionWaiters.size)
|
|
10433
|
+
return;
|
|
10434
|
+
const e = Array.from(this.connectionWaiters);
|
|
10435
|
+
this.connectionWaiters.clear(), e.forEach((t) => {
|
|
10436
|
+
try {
|
|
10437
|
+
t.resolve();
|
|
10438
|
+
} catch {
|
|
10439
|
+
}
|
|
10440
|
+
});
|
|
10441
|
+
}
|
|
10442
|
+
_rejectConnectionWaiters(e) {
|
|
10443
|
+
if (!this.connectionWaiters.size)
|
|
10444
|
+
return;
|
|
10445
|
+
const t = Array.from(this.connectionWaiters);
|
|
10446
|
+
this.connectionWaiters.clear();
|
|
10447
|
+
const i = e instanceof Error ? e : new Error("SIP 连接未完成即已中断。");
|
|
10448
|
+
t.forEach((s) => {
|
|
10449
|
+
try {
|
|
10450
|
+
s.reject(i);
|
|
10451
|
+
} catch {
|
|
10452
|
+
}
|
|
10453
|
+
});
|
|
10454
|
+
}
|
|
10455
|
+
_waitForConnectionConfirmation(e = this.connectionConfirmTimeoutMs) {
|
|
10456
|
+
return this.connected ? Promise.resolve() : new Promise((t, i) => {
|
|
10457
|
+
const s = {
|
|
10458
|
+
resolve: () => {
|
|
10459
|
+
clearTimeout(r), t();
|
|
10460
|
+
},
|
|
10461
|
+
reject: (n) => {
|
|
10462
|
+
clearTimeout(r), i(n);
|
|
10463
|
+
}
|
|
10464
|
+
}, r = setTimeout(() => {
|
|
10465
|
+
this.connectionWaiters.delete(s);
|
|
10466
|
+
const n = this.account?.internal_number || this.account?.account_key || this.account?.sip_username || "当前账号";
|
|
10467
|
+
i(new Error(`${n} 浏览器连接超时,未收到 SIP 服务器连接确认。`));
|
|
10468
|
+
}, e);
|
|
10469
|
+
this.connectionWaiters.add(s);
|
|
10470
|
+
});
|
|
10471
|
+
}
|
|
10472
|
+
_waitForRegistrationConfirmation(e = this.registrationConfirmTimeoutMs) {
|
|
10473
|
+
return this.registered ? Promise.resolve() : new Promise((t, i) => {
|
|
10474
|
+
const s = {
|
|
10475
|
+
resolve: () => {
|
|
10476
|
+
clearTimeout(r), t();
|
|
10477
|
+
},
|
|
10478
|
+
reject: (n) => {
|
|
10479
|
+
clearTimeout(r), i(n);
|
|
10480
|
+
}
|
|
10481
|
+
}, r = setTimeout(() => {
|
|
10482
|
+
this.registrationWaiters.delete(s);
|
|
10483
|
+
const n = this.account?.internal_number || this.account?.account_key || this.account?.sip_username || "当前账号";
|
|
10484
|
+
i(new Error(`${n} 浏览器注册超时,信令已连接但未收到注册确认。`));
|
|
10485
|
+
}, e);
|
|
10486
|
+
this.registrationWaiters.add(s);
|
|
10487
|
+
});
|
|
10488
|
+
}
|
|
10489
|
+
_captureRegistrationDiagnostics() {
|
|
10490
|
+
return {
|
|
10491
|
+
snapshot: this.getConnectionSnapshot(),
|
|
10492
|
+
shouldBeRegistered: !!this.simpleUser?.sessionManager?.shouldBeRegistered,
|
|
10493
|
+
hasRegisterer: !!this.simpleUser?.sessionManager?.registerer
|
|
10494
|
+
};
|
|
10495
|
+
}
|
|
10496
|
+
_shouldRecoverFromConnectedWithoutRegistration(e) {
|
|
10497
|
+
return !!(e?.snapshot?.connected && !e?.snapshot?.registered && !e?.shouldBeRegistered && !e?.hasRegisterer);
|
|
10498
|
+
}
|
|
10499
|
+
async _ensureRegistration(e) {
|
|
10500
|
+
try {
|
|
10501
|
+
this._assertSimpleUserIsCurrent(e, "注册流程"), await e.register(), this._assertSimpleUserIsCurrent(e, "注册流程"), this.registered || (await this._waitForRegistrationConfirmation(), this._assertSimpleUserIsCurrent(e, "注册确认"));
|
|
10502
|
+
} catch (t) {
|
|
10503
|
+
throw this.onError && this.onError(t), t;
|
|
10504
|
+
}
|
|
10505
|
+
}
|
|
10506
|
+
async ensureReady() {
|
|
10507
|
+
if (this.ensureReadyPromise)
|
|
10508
|
+
return this.ensureReadyPromise;
|
|
10509
|
+
const e = (async () => {
|
|
10510
|
+
let t = this.simpleUser;
|
|
10511
|
+
if (t || (t = this._createSimpleUser(), this.simpleUser = t), !this.connected) {
|
|
10512
|
+
let i = null;
|
|
10513
|
+
const s = t.connect().catch((r) => (i = r, null));
|
|
10514
|
+
if (this.connected || await Promise.race([
|
|
10515
|
+
s,
|
|
10516
|
+
this._waitForConnectionConfirmation()
|
|
10517
|
+
]), this.connected || await s, i)
|
|
10518
|
+
throw i;
|
|
10519
|
+
this.connected || await this._waitForConnectionConfirmation(), this._assertSimpleUserIsCurrent(t, "连接流程"), this.connected = !0, this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
|
|
10520
|
+
}
|
|
10521
|
+
if (!this.registered) {
|
|
10522
|
+
let i = null;
|
|
10523
|
+
try {
|
|
10524
|
+
await this._ensureRegistration(t);
|
|
10525
|
+
} catch (r) {
|
|
10526
|
+
i = r;
|
|
10527
|
+
}
|
|
10528
|
+
let s = this._captureRegistrationDiagnostics();
|
|
10529
|
+
if (i && this._shouldRecoverFromConnectedWithoutRegistration(s)) {
|
|
10530
|
+
console.warn("SIP 客户端首次建连后未真正进入注册流程,开始立即补注册。", {
|
|
10531
|
+
accountKey: this.account?.internal_number || this.account?.account_key || this.account?.sip_username || null,
|
|
10532
|
+
snapshot: s.snapshot
|
|
10533
|
+
}), await new Promise((r) => window.setTimeout(r, 200));
|
|
10534
|
+
try {
|
|
10535
|
+
await this._ensureRegistration(t);
|
|
10536
|
+
} catch (r) {
|
|
10537
|
+
i = i || r;
|
|
10538
|
+
}
|
|
10539
|
+
s = this._captureRegistrationDiagnostics();
|
|
10540
|
+
}
|
|
10541
|
+
if (i && !(s?.snapshot?.connected && s?.snapshot?.registered))
|
|
10542
|
+
throw i;
|
|
10543
|
+
}
|
|
10544
|
+
})().finally(() => {
|
|
10545
|
+
this.ensureReadyPromise === e && (this.ensureReadyPromise = null);
|
|
10546
|
+
});
|
|
10547
|
+
return this.ensureReadyPromise = e, e;
|
|
10415
10548
|
}
|
|
10416
10549
|
getConnectionSnapshot() {
|
|
10417
10550
|
const e = this.simpleUser, t = typeof e?.isConnected == "function" ? e.isConnected() : !!this.connected, i = typeof e?.isRegistered == "function" ? e.isRegistered() : !!this.registered;
|
|
@@ -10466,9 +10599,9 @@ class li {
|
|
|
10466
10599
|
async _preflightAudioAccess(e = "call") {
|
|
10467
10600
|
let t = null;
|
|
10468
10601
|
try {
|
|
10469
|
-
t = await
|
|
10602
|
+
t = await hi(e);
|
|
10470
10603
|
} catch (i) {
|
|
10471
|
-
const s = await
|
|
10604
|
+
const s = await Ve(i, e);
|
|
10472
10605
|
throw this.onError && this.onError(s), this.lastFailureMeta = {
|
|
10473
10606
|
source: "media-preflight",
|
|
10474
10607
|
code: s?.code || null,
|
|
@@ -10527,7 +10660,7 @@ class li {
|
|
|
10527
10660
|
}
|
|
10528
10661
|
}
|
|
10529
10662
|
async _normalizeMediaAccessError(e, t = "call") {
|
|
10530
|
-
return
|
|
10663
|
+
return Ve(e, t);
|
|
10531
10664
|
}
|
|
10532
10665
|
_createInviteRequestDelegate(e) {
|
|
10533
10666
|
const t = (s, ...r) => {
|
|
@@ -10633,6 +10766,7 @@ class li {
|
|
|
10633
10766
|
}
|
|
10634
10767
|
}
|
|
10635
10768
|
async destroy() {
|
|
10769
|
+
this._rejectConnectionWaiters(Ne("SIP 客户端已销毁,已取消连接等待。")), this._rejectRegistrationWaiters(Ne("SIP 客户端已销毁,已取消注册等待。")), this.ensureReadyPromise = null;
|
|
10636
10770
|
const e = this.simpleUser;
|
|
10637
10771
|
if (e)
|
|
10638
10772
|
try {
|
|
@@ -10703,9 +10837,9 @@ class li {
|
|
|
10703
10837
|
s.getByteTimeDomainData(r);
|
|
10704
10838
|
let p = 0;
|
|
10705
10839
|
const u = n ? new Float32Array(r.length) : null;
|
|
10706
|
-
for (let
|
|
10707
|
-
const
|
|
10708
|
-
p +=
|
|
10840
|
+
for (let _ = 0; _ < r.length; _ += 1) {
|
|
10841
|
+
const E = (r[_] - 128) / 128;
|
|
10842
|
+
p += E * E, u && (u[_] = E);
|
|
10709
10843
|
}
|
|
10710
10844
|
const w = Math.sqrt(p / r.length), S = Math.min(1, w * 2);
|
|
10711
10845
|
if (this.onAudioLevel && this.onAudioLevel(e, S), u && this.audioContext && this.onAudioFrame)
|
|
@@ -10918,54 +11052,54 @@ class li {
|
|
|
10918
11052
|
this.audioContext = null;
|
|
10919
11053
|
}
|
|
10920
11054
|
}
|
|
10921
|
-
const
|
|
10922
|
-
function
|
|
11055
|
+
const gi = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
11056
|
+
function fi(a, e = "") {
|
|
10923
11057
|
const t = String(a || e || "").trim();
|
|
10924
11058
|
if (!t)
|
|
10925
11059
|
throw new Error("缺少统一服务基址");
|
|
10926
11060
|
return t;
|
|
10927
11061
|
}
|
|
10928
|
-
function
|
|
10929
|
-
return
|
|
11062
|
+
function mt(a, e = "https://") {
|
|
11063
|
+
return gi.test(a) ? a : `${e}${a.replace(/^\/+/, "")}`;
|
|
10930
11064
|
}
|
|
10931
|
-
function
|
|
11065
|
+
function wt(a = "/") {
|
|
10932
11066
|
return a.endsWith("/") ? a : `${a}/`;
|
|
10933
11067
|
}
|
|
10934
|
-
function
|
|
10935
|
-
const t =
|
|
11068
|
+
function yt(a = "/", e = "") {
|
|
11069
|
+
const t = wt(a || "/"), i = String(e || "").replace(/^\/+/, "");
|
|
10936
11070
|
return i ? `${t}${i}` : t;
|
|
10937
11071
|
}
|
|
10938
11072
|
function De(a, e = "") {
|
|
10939
|
-
const t =
|
|
10940
|
-
return i.search = "", i.hash = "", i.pathname =
|
|
11073
|
+
const t = mt(fi(a, e)), i = new URL(t);
|
|
11074
|
+
return i.search = "", i.hash = "", i.pathname = wt(i.pathname || "/"), i;
|
|
10941
11075
|
}
|
|
10942
|
-
function
|
|
11076
|
+
function pi(a, e = "") {
|
|
10943
11077
|
return De(a, e).pathname !== "/";
|
|
10944
11078
|
}
|
|
10945
11079
|
function X(a, e, t = "") {
|
|
10946
11080
|
const i = De(a, t);
|
|
10947
|
-
return i.pathname =
|
|
11081
|
+
return i.pathname = yt(i.pathname, e), i.href;
|
|
10948
11082
|
}
|
|
10949
11083
|
function Ue(a, e = "ws", t = "") {
|
|
10950
11084
|
const i = De(a, t);
|
|
10951
|
-
return i.protocol === "https:" ? i.protocol = "wss:" : i.protocol === "http:" ? i.protocol = "ws:" : i.protocol !== "ws:" && i.protocol !== "wss:" && (i.protocol = "wss:"), i.pathname =
|
|
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 = yt(i.pathname, e), i.href;
|
|
10952
11086
|
}
|
|
10953
|
-
function
|
|
11087
|
+
function tt(a, e = "") {
|
|
10954
11088
|
if (!String(a || "").trim())
|
|
10955
11089
|
return String(e || "").replace(/^\/+/, "");
|
|
10956
|
-
const t = new URL(
|
|
11090
|
+
const t = new URL(mt(String(a).trim())), i = String(t.pathname || "/").replace(/^\/+/, ""), s = String(t.search || "");
|
|
10957
11091
|
return `${i}${s}` || String(e || "").replace(/^\/+/, "");
|
|
10958
11092
|
}
|
|
10959
|
-
function
|
|
11093
|
+
function it({
|
|
10960
11094
|
apiBaseUrl: a,
|
|
10961
11095
|
transportBaseUrl: e = "",
|
|
10962
11096
|
transportUrl: t = "",
|
|
10963
11097
|
fallbackPath: i = "ws"
|
|
10964
11098
|
}) {
|
|
10965
11099
|
const s = String(e || "").trim();
|
|
10966
|
-
return s ? Ue(s,
|
|
11100
|
+
return s ? Ue(s, tt(t, i)) : pi(a) ? Ue(a, tt(t, i)) : String(t || "").trim() ? String(t).trim() : Ue(a, i);
|
|
10967
11101
|
}
|
|
10968
|
-
const
|
|
11102
|
+
const mi = `
|
|
10969
11103
|
:host { all: initial; }
|
|
10970
11104
|
.widget { font-family: "Noto Sans SC", "PingFang SC", sans-serif; color: #16302b; }
|
|
10971
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); }
|
|
@@ -10974,6 +11108,8 @@ const fi = `
|
|
|
10974
11108
|
.title { margin: 0; font-size: 18px; line-height: 1.3; }
|
|
10975
11109
|
.availability { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
|
|
10976
11110
|
.availability--ready { color: #0f5132; background: rgba(220, 252, 231, 0.92); }
|
|
11111
|
+
.availability--preparing { color: #0b4f71; background: rgba(225, 239, 255, 0.96); }
|
|
11112
|
+
.availability--working { color: #0b4f71; background: rgba(220, 240, 255, 0.96); }
|
|
10977
11113
|
.availability--recovering { color: #8a5a00; background: rgba(255, 244, 200, 0.96); }
|
|
10978
11114
|
.availability--offline { color: #8b1e3f; background: rgba(255, 226, 231, 0.96); }
|
|
10979
11115
|
.status { margin-top: 10px; padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,0.78); font-size: 13px; }
|
|
@@ -11011,28 +11147,30 @@ const fi = `
|
|
|
11011
11147
|
rejected: "本次来电已拒接,widget 仍保持待机。",
|
|
11012
11148
|
missed: "本次来电未接听,widget 仍保持待机。",
|
|
11013
11149
|
failed: "本次呼叫失败,请先看下方日志。"
|
|
11014
|
-
},
|
|
11150
|
+
}, wi = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", bt = 15e3, yi = 15e3, st = 2, bi = 2, me = bt * bi, vi = 1200, Si = 3e4, Ti = 4e3, Te = {
|
|
11015
11151
|
ready: "线路可用",
|
|
11152
|
+
preparing: "正在准备",
|
|
11153
|
+
working: "正在呼叫",
|
|
11016
11154
|
recovering: "正在恢复",
|
|
11017
11155
|
offline: "当前离线"
|
|
11018
11156
|
};
|
|
11019
|
-
function
|
|
11157
|
+
function Ci(a, e) {
|
|
11020
11158
|
return e ? `${a}
|
|
11021
11159
|
${JSON.stringify(e, null, 2)}` : a;
|
|
11022
11160
|
}
|
|
11023
|
-
function
|
|
11161
|
+
function Ei(a) {
|
|
11024
11162
|
return a === "outbound" ? "outbound" : "terminal";
|
|
11025
11163
|
}
|
|
11026
|
-
function
|
|
11164
|
+
function xi(a) {
|
|
11027
11165
|
return typeof a == "function";
|
|
11028
11166
|
}
|
|
11029
|
-
function
|
|
11167
|
+
function Ri() {
|
|
11030
11168
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("embeddedCallWidgetE2E") === "1";
|
|
11031
11169
|
}
|
|
11032
|
-
function
|
|
11170
|
+
function Ii() {
|
|
11033
11171
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `widget-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
11034
11172
|
}
|
|
11035
|
-
function
|
|
11173
|
+
function Le(a) {
|
|
11036
11174
|
const e = String(a?.message || a || "");
|
|
11037
11175
|
return /Failed to fetch|NetworkError|Load failed|network/i.test(e);
|
|
11038
11176
|
}
|
|
@@ -11043,26 +11181,26 @@ function te(a = {}, e = null) {
|
|
|
11043
11181
|
const s = String(a?.businessKey ?? "").trim();
|
|
11044
11182
|
return s || String(e?.default_business_key ?? "").trim();
|
|
11045
11183
|
}
|
|
11046
|
-
function
|
|
11184
|
+
function _i(a) {
|
|
11047
11185
|
const e = new Error(a);
|
|
11048
11186
|
return e.name = "EmbeddedCallWidgetLifecycleCancelledError", e.code = "widget_runtime_run_stale", e;
|
|
11049
11187
|
}
|
|
11050
|
-
function
|
|
11188
|
+
function rt(a) {
|
|
11051
11189
|
return a?.code === "sip_client_replaced" || a?.code === "widget_runtime_run_stale";
|
|
11052
11190
|
}
|
|
11053
|
-
class
|
|
11191
|
+
class Ai {
|
|
11054
11192
|
constructor({ mount: e, shadowRoot: t, options: i }) {
|
|
11055
|
-
this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode =
|
|
11193
|
+
this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = Ei(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = De(i.apiBaseUrl || window.location.origin).href, this.client = null, this.issuedSession = null, this.bootstrap = null, this.turnIceServers = [], this.state = "idle", this.finalizing = !1, this.isMobileViewport = !1, this.pendingIncomingCall = null, this.visibilityHandler = null, this.sessionTouchTimer = null, this.sessionRecoveryInFlight = null, this.transportDisconnectTimer = null, this.transportDisconnectContext = null, this.e2eBridgeEnabled = Ri(), 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.refs = {};
|
|
11056
11194
|
}
|
|
11057
11195
|
async mount() {
|
|
11058
11196
|
this.isMobileViewport = typeof window < "u" && window.matchMedia("(max-width: 480px)").matches, this.shadowRoot.innerHTML = `
|
|
11059
|
-
<style>${
|
|
11197
|
+
<style>${mi}</style>
|
|
11060
11198
|
<section class="widget">
|
|
11061
11199
|
<div class="panel">
|
|
11062
11200
|
<div class="hero">
|
|
11063
11201
|
<p class="eyebrow">Embedded Call Button</p>
|
|
11064
11202
|
<h2 class="title">${this.options.text || "联系管理员"}</h2>
|
|
11065
|
-
<div class="availability availability--
|
|
11203
|
+
<div class="availability availability--preparing" data-role="availability">正在准备</div>
|
|
11066
11204
|
<div class="status" data-role="status">${Q.idle}</div>
|
|
11067
11205
|
<div class="hint" data-role="hint"></div>
|
|
11068
11206
|
</div>
|
|
@@ -11092,7 +11230,15 @@ class Ci {
|
|
|
11092
11230
|
}), this.isMobileViewport && ["requesting", "registering", "calling", "connected"].includes(this.state) && (this.refs.status.textContent = "页面已切到后台;手机网页回到前台后请确认通话仍在继续。");
|
|
11093
11231
|
return;
|
|
11094
11232
|
}
|
|
11095
|
-
this.isMobileViewport && (this.appendLog("页面已回到前台", { state: this.state }), ["requesting", "registering", "calling", "connected"].includes(this.state) && (this.refs.status.textContent = Q[this.state] || Q.idle)), this.touchWidgetPresence("visibility-visible"), !this.legacyOutboundOnly && ["standby", "registering", "standbyRequesting", "failed", "idle", "missed", "rejected", "ended"].includes(this.state)
|
|
11233
|
+
if (this.isMobileViewport && (this.appendLog("页面已回到前台", { state: this.state }), ["requesting", "registering", "calling", "connected"].includes(this.state) && (this.refs.status.textContent = Q[this.state] || Q.idle)), this.touchWidgetPresence("visibility-visible"), !this.legacyOutboundOnly && ["standby", "registering", "standbyRequesting", "failed", "idle", "missed", "rejected", "ended"].includes(this.state)) {
|
|
11234
|
+
const e = this.client?.getConnectionSnapshot?.() || null, t = !!(e?.connected && (this.state !== "standby" || e?.registered));
|
|
11235
|
+
this.issuedSession?.session_id && t ? this.touchIssuedSession(this.state, { trigger: "visibility-visible" }) : (this.appendLog("页面回到前台后检测到待机链路未处于健康状态,准备自动重建。", {
|
|
11236
|
+
state: this.state,
|
|
11237
|
+
has_session: !!this.issuedSession?.session_id,
|
|
11238
|
+
client_snapshot: e
|
|
11239
|
+
}), this.client || this.issuedSession?.session_id ? this.disconnectAndCleanup("visibility-visible-unhealthy-client") : this.startStandby({ force: !0 }));
|
|
11240
|
+
}
|
|
11241
|
+
this.reportIssuedSessionEvent("visibility-visible", {
|
|
11096
11242
|
visible: !0
|
|
11097
11243
|
}), this.render();
|
|
11098
11244
|
}, document.addEventListener("visibilitychange", this.visibilityHandler), typeof window < "u" && (this.onlineHandler = () => {
|
|
@@ -11109,11 +11255,11 @@ class Ci {
|
|
|
11109
11255
|
}
|
|
11110
11256
|
assertLifecycleRunCurrent(e) {
|
|
11111
11257
|
if (e !== this.lifecycleRunId)
|
|
11112
|
-
throw
|
|
11258
|
+
throw _i("网页电话已切换到新的连接流程,旧流程不再继续。");
|
|
11113
11259
|
}
|
|
11114
11260
|
emitHostCallback(e, t) {
|
|
11115
11261
|
const i = this.options?.[e];
|
|
11116
|
-
if (
|
|
11262
|
+
if (xi(i))
|
|
11117
11263
|
try {
|
|
11118
11264
|
i(t);
|
|
11119
11265
|
} catch (s) {
|
|
@@ -11211,11 +11357,13 @@ class Ci {
|
|
|
11211
11357
|
return;
|
|
11212
11358
|
const e = this.beginLifecycleRun();
|
|
11213
11359
|
try {
|
|
11214
|
-
this.terminalFailureOverride = "", this.setAvailabilityState("
|
|
11360
|
+
this.terminalFailureOverride = "", this.clearAutoStandbyRecovery(), this.pendingLifecycleMode = "outbound", this.setAvailabilityState("working", "正在建立呼叫链路。"), !this.legacyOutboundOnly && this.issuedSession?.session_mode === "widget_standby" && (this.appendLog("访客主动呼叫前,先释放当前待机会话并切换到呼叫链路。", {
|
|
11215
11361
|
widget_anchor_number: this.issuedSession?.widget_anchor_number || null,
|
|
11216
11362
|
resolved_business_key: this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || null
|
|
11217
11363
|
}), await this.disconnectAndCleanup("switch-to-outbound-call", {
|
|
11218
|
-
preserveLifecycleRun: !0
|
|
11364
|
+
preserveLifecycleRun: !0,
|
|
11365
|
+
suppressStateReset: !0,
|
|
11366
|
+
suppressClientTeardownState: "switch-to-outbound-call"
|
|
11219
11367
|
}), this.assertLifecycleRunCurrent(e)), this.setState("requesting"), await this.loadBootstrap(), this.assertLifecycleRunCurrent(e), this.turnIceServers = await this.fetchTurnIceServers(), this.assertLifecycleRunCurrent(e);
|
|
11220
11368
|
const t = await this.fetchIssuedSession();
|
|
11221
11369
|
this.assertLifecycleRunCurrent(e), await this.ensureClient(t), this.assertLifecycleRunCurrent(e), this.setState("registering"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(e), this.setState("calling"), this.syncAvailabilityState(), await this.client.call(t.target), this.assertLifecycleRunCurrent(e), this.appendLog("已发起呼叫", {
|
|
@@ -11223,14 +11371,14 @@ class Ci {
|
|
|
11223
11371
|
route_note: t.routeNote || null
|
|
11224
11372
|
});
|
|
11225
11373
|
} catch (t) {
|
|
11226
|
-
if (
|
|
11374
|
+
if (this.pendingLifecycleMode = null, rt(t)) {
|
|
11227
11375
|
this.appendLog("已忽略过期的网页电话呼叫流程", {
|
|
11228
11376
|
message: t?.message || String(t)
|
|
11229
11377
|
});
|
|
11230
11378
|
return;
|
|
11231
11379
|
}
|
|
11232
11380
|
const i = t?.message || String(t);
|
|
11233
|
-
if (this.terminalFailureOverride = i, this.setState("failed", i),
|
|
11381
|
+
if (this.terminalFailureOverride = i, this.setState("failed", i), Le(t) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "呼叫失败,正在准备恢复网页电话待机。"), this.appendLog("连接并呼叫失败", { message: i }), await this.releaseIssuedSession("failed", "connect-and-call-failed"), !this.legacyOutboundOnly) {
|
|
11234
11382
|
this.appendLog("呼叫失败后,网页电话将恢复待机。", { message: i }), await this.startStandby({ force: !0 });
|
|
11235
11383
|
return;
|
|
11236
11384
|
}
|
|
@@ -11245,9 +11393,9 @@ class Ci {
|
|
|
11245
11393
|
return;
|
|
11246
11394
|
const i = this.beginLifecycleRun();
|
|
11247
11395
|
try {
|
|
11248
|
-
this.terminalFailureOverride = "", this.setState("standbyRequesting"), this.setAvailabilityState("
|
|
11396
|
+
this.clearAutoStandbyRecovery(), this.pendingLifecycleMode = "standby", this.terminalFailureOverride = "", this.setState("standbyRequesting"), this.setAvailabilityState("preparing", "正在申请新的待机会话。"), await this.loadBootstrap(), this.assertLifecycleRunCurrent(i), this.turnIceServers = await this.fetchTurnIceServers(), this.assertLifecycleRunCurrent(i);
|
|
11249
11397
|
const s = await this.fetchStandbySession();
|
|
11250
|
-
this.assertLifecycleRunCurrent(i), await this.ensureClient(s), this.assertLifecycleRunCurrent(i), this.setState("registering", "待机会话已拿到,正在连接并执行 REGISTER。"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(i), this.setState("standby"), this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。"), this.appendLog("widget 已进入待机", {
|
|
11398
|
+
this.assertLifecycleRunCurrent(i), await this.ensureClient(s), this.assertLifecycleRunCurrent(i), this.setState("registering", "待机会话已拿到,正在连接并执行 REGISTER。"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(i), this.pendingLifecycleMode = null, this.setState("standby"), this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。"), this.appendLog("widget 已进入待机", {
|
|
11251
11399
|
session_id: this.issuedSession?.session_id || null,
|
|
11252
11400
|
route_business_key: this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || null,
|
|
11253
11401
|
standby_mode: this.issuedSession?.standby_mode || null,
|
|
@@ -11255,14 +11403,15 @@ class Ci {
|
|
|
11255
11403
|
browser_sip_username: this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username || null
|
|
11256
11404
|
}), this.emitHostCallback("onStandbyReady", this.getSnapshot());
|
|
11257
11405
|
} catch (s) {
|
|
11258
|
-
if (
|
|
11406
|
+
if (rt(s)) {
|
|
11259
11407
|
this.appendLog("已忽略过期的网页电话待机流程", {
|
|
11260
11408
|
message: s?.message || String(s)
|
|
11261
11409
|
});
|
|
11262
11410
|
return;
|
|
11263
11411
|
}
|
|
11412
|
+
this.pendingLifecycleMode = null;
|
|
11264
11413
|
const r = s?.message || String(s);
|
|
11265
|
-
this.terminalFailureOverride = r, this.setState("failed", r),
|
|
11414
|
+
this.terminalFailureOverride = r, this.setState("failed", r), Le(s) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "当前未能完成待机注册,系统会继续自动恢复。"), this.appendLog("进入待机失败", { message: r }), await this.releaseIssuedSession("failed", "standby-start-failed"), this.setState("failed", r), !this.legacyOutboundOnly && this.networkOnline !== !1 && this.scheduleAutoStandbyRecovery("standby-start-failed");
|
|
11266
11415
|
}
|
|
11267
11416
|
}
|
|
11268
11417
|
async ensureClient(e) {
|
|
@@ -11273,7 +11422,7 @@ class Ci {
|
|
|
11273
11422
|
webrtc_url: e.transport,
|
|
11274
11423
|
ice_servers: this.turnIceServers
|
|
11275
11424
|
};
|
|
11276
|
-
this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new
|
|
11425
|
+
this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new ui(t, {
|
|
11277
11426
|
remoteAudioElement: this.refs.audio,
|
|
11278
11427
|
onStateChange: (i, s) => {
|
|
11279
11428
|
this.handleClientState(i, s);
|
|
@@ -11283,11 +11432,11 @@ class Ci {
|
|
|
11283
11432
|
}
|
|
11284
11433
|
async handleClientState(e, t = {}) {
|
|
11285
11434
|
if (this.syncSessionTouch(e), this.reportIssuedSessionEvent(e, t, e), (e === "connected" || e === "registered" || e === "ringing" || e === "dialing" || e === "answered") && await this.clearTransportDisconnectGrace(!0), e === "registered") {
|
|
11286
|
-
this.issuedSession?.session_mode === "widget_standby" ? (this.setState("standby"), this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。")) : this.setState("registering", "REGISTER 已完成,正在准备发起呼叫。");
|
|
11435
|
+
this.pendingLifecycleMode = null, this.issuedSession?.session_mode === "widget_standby" ? (this.setState("standby"), this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。")) : this.setState("registering", "REGISTER 已完成,正在准备发起呼叫。");
|
|
11287
11436
|
return;
|
|
11288
11437
|
}
|
|
11289
11438
|
if (e === "incoming") {
|
|
11290
|
-
this.pendingIncomingCall = t && typeof t == "object" ? { ...t } : null, this.setState("incoming"), this.setAvailabilityState("ready", "已有新来电,请直接接听或拒接。"), this.appendLog("收到新的来电", this.pendingIncomingCall), this.emitHostCallback("onIncomingCall", this.pendingIncomingCall);
|
|
11439
|
+
this.pendingLifecycleMode = null, this.pendingIncomingCall = t && typeof t == "object" ? { ...t } : null, this.setState("incoming"), this.setAvailabilityState("ready", "已有新来电,请直接接听或拒接。"), this.appendLog("收到新的来电", this.pendingIncomingCall), this.emitHostCallback("onIncomingCall", this.pendingIncomingCall);
|
|
11291
11440
|
return;
|
|
11292
11441
|
}
|
|
11293
11442
|
if (e === "ringing" || e === "dialing") {
|
|
@@ -11295,7 +11444,7 @@ class Ci {
|
|
|
11295
11444
|
return;
|
|
11296
11445
|
}
|
|
11297
11446
|
if (e === "answered") {
|
|
11298
|
-
this.terminalFailureOverride = "";
|
|
11447
|
+
this.pendingLifecycleMode = null, this.terminalFailureOverride = "";
|
|
11299
11448
|
const i = this.pendingIncomingCall || t || null;
|
|
11300
11449
|
this.setState("connected"), this.setAvailabilityState("ready", "当前通话已接通。"), this.emitHostCallback("onCallAnswered", i);
|
|
11301
11450
|
return;
|
|
@@ -11309,10 +11458,14 @@ class Ci {
|
|
|
11309
11458
|
return;
|
|
11310
11459
|
}
|
|
11311
11460
|
if (e === "failed") {
|
|
11312
|
-
|
|
11461
|
+
if (this.isExpectedClientTeardown())
|
|
11462
|
+
return;
|
|
11463
|
+
this.pendingLifecycleMode = null, await this.clearTransportDisconnectGrace(!1), this.stopSessionTouch(), this.terminalFailureOverride = t?.message || Q.failed, this.setState("failed", this.terminalFailureOverride), this.setAvailabilityState("recovering", "通话链路异常断开,系统会继续自动恢复。"), await this.releaseIssuedSession("failed", "sip-client-failed");
|
|
11313
11464
|
return;
|
|
11314
11465
|
}
|
|
11315
11466
|
if (e === "disconnected" || e === "unregistered") {
|
|
11467
|
+
if (this.isExpectedClientTeardown() || this.isExpectedTermination() || !this.issuedSession?.session_id && this.pendingLifecycleMode === "standby")
|
|
11468
|
+
return;
|
|
11316
11469
|
if (this.stopSessionTouch(), ["calling", "connected"].includes(this.state)) {
|
|
11317
11470
|
this.setState("connected", "SIP 信令短暂中断,正在等待恢复。"), this.setAvailabilityState("recovering", "通话信令短暂中断,正在等待恢复。"), this.scheduleTransportDisconnectGrace(e);
|
|
11318
11471
|
return;
|
|
@@ -11324,7 +11477,7 @@ class Ci {
|
|
|
11324
11477
|
}
|
|
11325
11478
|
if (this.state === "failed")
|
|
11326
11479
|
return;
|
|
11327
|
-
this.state !== "idle" && this.state !== "ended" && (this.setState("ended"), this.setAvailabilityState("recovering", "通话已结束,正在恢复网页电话待机。"));
|
|
11480
|
+
this.state !== "idle" && this.state !== "ended" && (this.pendingLifecycleMode = null, this.setState("ended"), this.setAvailabilityState("recovering", "通话已结束,正在恢复网页电话待机。"), this.scheduleAutoStandbyRecovery(`client-${e}`));
|
|
11328
11481
|
}
|
|
11329
11482
|
}
|
|
11330
11483
|
stopTransportDisconnectGrace() {
|
|
@@ -11367,8 +11520,8 @@ class Ci {
|
|
|
11367
11520
|
if (!this.finalizing) {
|
|
11368
11521
|
this.beginLifecycleRun(), this.finalizing = !0;
|
|
11369
11522
|
try {
|
|
11370
|
-
if (this.stopSessionTouch(), this.stopTransportDisconnectGrace(), await this.releaseIssuedSession("released", e), this.client && (await this.client.destroy(), this.client = null), !this.legacyOutboundOnly) {
|
|
11371
|
-
this.setState("
|
|
11523
|
+
if (this.pendingLifecycleMode = null, this.stopSessionTouch(), this.stopTransportDisconnectGrace(), await this.releaseIssuedSession("released", e), this.client && (await this.client.destroy(), this.client = null), !this.legacyOutboundOnly) {
|
|
11524
|
+
this.pendingLifecycleMode = "standby", this.setState("standbyRequesting", "上一通通话已结束,正在自动回到待机。"), this.setAvailabilityState("preparing", "页面仍在线,正在自动回到待机。"), this.appendLog("通话已结束,网页电话正在自动回到待机。", { reason: e }), await this.startStandby({ force: !0 });
|
|
11372
11525
|
return;
|
|
11373
11526
|
}
|
|
11374
11527
|
const t = this.terminalFailureOverride || (this.state === "failed" ? this.refs.status?.textContent?.trim() || Q.failed : "");
|
|
@@ -11425,13 +11578,17 @@ class Ci {
|
|
|
11425
11578
|
this.legacyOutboundOnly ? this.setState("ended") : this.setState("standby", "测试桥已模拟挂断,网页电话已恢复待机。"), this.pendingIncomingCall = null;
|
|
11426
11579
|
return;
|
|
11427
11580
|
}
|
|
11428
|
-
this.client && await this.client.hangup();
|
|
11581
|
+
this.client && (this.expectTermination("hangup-call"), this.suppressExpectedClientTeardown("hangup-call"), await this.client.hangup());
|
|
11429
11582
|
}
|
|
11430
11583
|
async disconnectAndCleanup(e, t = {}) {
|
|
11431
|
-
const {
|
|
11432
|
-
|
|
11584
|
+
const {
|
|
11585
|
+
preserveLifecycleRun: i = !1,
|
|
11586
|
+
suppressStateReset: s = !1,
|
|
11587
|
+
suppressClientTeardownState: r = null
|
|
11588
|
+
} = t;
|
|
11589
|
+
i || this.beginLifecycleRun(), r && this.suppressExpectedClientTeardown(r), this.stopSessionTouch(), this.stopTransportDisconnectGrace(), this.reportIssuedSessionEvent("manual-disconnect", {
|
|
11433
11590
|
reason: e
|
|
11434
|
-
}, this.state), this.pendingIncomingCall = null, this.terminalFailureOverride = "", this.client && (await this.client.destroy(), this.client = null), await this.releaseIssuedSession("released", e), this.setState("idle"), this.setAvailabilityState("recovering", "
|
|
11591
|
+
}, this.state), this.pendingIncomingCall = null, this.terminalFailureOverride = "", this.client && (await this.client.destroy(), this.client = null), await this.releaseIssuedSession("released", e), s || (this.pendingLifecycleMode = null, this.setState("idle"), this.setAvailabilityState("recovering", "网页电话已断开,系统正在自动恢复待机。"), this.appendLog("连接已断开", { reason: e }), !this.legacyOutboundOnly && this.networkOnline !== !1 && this.scheduleAutoStandbyRecovery(e));
|
|
11435
11592
|
}
|
|
11436
11593
|
async loadBootstrap() {
|
|
11437
11594
|
if (this.bootstrap)
|
|
@@ -11499,7 +11656,7 @@ class Ci {
|
|
|
11499
11656
|
sipUsername: r.sip_username,
|
|
11500
11657
|
sipDomain: r.sip_domain,
|
|
11501
11658
|
password: r.sip_password,
|
|
11502
|
-
transport:
|
|
11659
|
+
transport: it({
|
|
11503
11660
|
apiBaseUrl: this.apiBaseUrl,
|
|
11504
11661
|
transportBaseUrl: this.options.transportBaseUrl || "",
|
|
11505
11662
|
transportUrl: r.ws_server
|
|
@@ -11551,7 +11708,7 @@ class Ci {
|
|
|
11551
11708
|
sipUsername: r.sip_username,
|
|
11552
11709
|
sipDomain: r.sip_domain,
|
|
11553
11710
|
password: r.sip_password,
|
|
11554
|
-
transport:
|
|
11711
|
+
transport: it({
|
|
11555
11712
|
apiBaseUrl: this.apiBaseUrl,
|
|
11556
11713
|
transportBaseUrl: this.options.transportBaseUrl || "",
|
|
11557
11714
|
transportUrl: r.ws_server
|
|
@@ -11564,7 +11721,7 @@ class Ci {
|
|
|
11564
11721
|
if (!this.issuedSession?.session_id)
|
|
11565
11722
|
return;
|
|
11566
11723
|
const i = this.issuedSession.session_id;
|
|
11567
|
-
this.issuedSession = null, await fetch(X(this.apiBaseUrl, "api/sip/release-call-session"), {
|
|
11724
|
+
this.markRecentlyReleasedSession(i, t), this.issuedSession = null, await fetch(X(this.apiBaseUrl, "api/sip/release-call-session"), {
|
|
11568
11725
|
method: "POST",
|
|
11569
11726
|
credentials: "include",
|
|
11570
11727
|
cache: "no-store",
|
|
@@ -11604,17 +11761,66 @@ class Ci {
|
|
|
11604
11761
|
setAvailabilityState(e, t = "") {
|
|
11605
11762
|
this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${Te[e] || Te.recovering} · ${t}` : Te[e] || Te.recovering, this.refs.availability.className = `availability availability--${e}`), this.render();
|
|
11606
11763
|
}
|
|
11764
|
+
suppressExpectedClientTeardown(e, t = Ti) {
|
|
11765
|
+
this.expectedClientTeardown = {
|
|
11766
|
+
reason: e,
|
|
11767
|
+
expiresAt: Date.now() + t
|
|
11768
|
+
};
|
|
11769
|
+
}
|
|
11770
|
+
expectTermination(e, t = 1e4) {
|
|
11771
|
+
this.expectedTermination = {
|
|
11772
|
+
reason: e,
|
|
11773
|
+
expiresAt: Date.now() + t
|
|
11774
|
+
};
|
|
11775
|
+
}
|
|
11776
|
+
clearExpectedTermination() {
|
|
11777
|
+
this.expectedTermination = null;
|
|
11778
|
+
}
|
|
11779
|
+
isExpectedTermination() {
|
|
11780
|
+
const e = this.expectedTermination;
|
|
11781
|
+
return e ? e.expiresAt <= Date.now() ? (this.expectedTermination = null, !1) : !0 : !1;
|
|
11782
|
+
}
|
|
11783
|
+
isExpectedClientTeardown() {
|
|
11784
|
+
const e = this.expectedClientTeardown;
|
|
11785
|
+
return e ? e.expiresAt <= Date.now() ? (this.expectedClientTeardown = null, !1) : !0 : !1;
|
|
11786
|
+
}
|
|
11787
|
+
clearAutoStandbyRecovery() {
|
|
11788
|
+
this.autoStandbyRecoveryTimer && (window.clearTimeout(this.autoStandbyRecoveryTimer), this.autoStandbyRecoveryTimer = null);
|
|
11789
|
+
}
|
|
11790
|
+
scheduleAutoStandbyRecovery(e, t = vi) {
|
|
11791
|
+
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(() => {
|
|
11792
|
+
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 })));
|
|
11793
|
+
}, t));
|
|
11794
|
+
}
|
|
11795
|
+
pruneRecentlyReleasedSessions() {
|
|
11796
|
+
const e = Date.now();
|
|
11797
|
+
for (const [t, i] of this.recentlyReleasedSessions.entries())
|
|
11798
|
+
(i?.expiresAt || 0) <= e && this.recentlyReleasedSessions.delete(t);
|
|
11799
|
+
}
|
|
11800
|
+
markRecentlyReleasedSession(e, t) {
|
|
11801
|
+
e && (this.pruneRecentlyReleasedSessions(), this.recentlyReleasedSessions.set(e, {
|
|
11802
|
+
reason: t,
|
|
11803
|
+
expiresAt: Date.now() + Si
|
|
11804
|
+
}));
|
|
11805
|
+
}
|
|
11806
|
+
wasSessionRecentlyReleased(e) {
|
|
11807
|
+
return e ? (this.pruneRecentlyReleasedSessions(), this.recentlyReleasedSessions.has(e)) : !1;
|
|
11808
|
+
}
|
|
11607
11809
|
syncAvailabilityState() {
|
|
11608
11810
|
if (this.networkOnline === !1) {
|
|
11609
11811
|
this.setAvailabilityState("offline", "当前网络连接已断开,正在等待恢复。");
|
|
11610
11812
|
return;
|
|
11611
11813
|
}
|
|
11612
|
-
if (
|
|
11613
|
-
this.setAvailabilityState("
|
|
11814
|
+
if (this.pendingLifecycleMode === "outbound" && ["requesting", "registering", "calling"].includes(this.state)) {
|
|
11815
|
+
this.setAvailabilityState("working", this.state === "calling" ? "正在等待对端振铃或接听。" : "正在建立呼叫链路。");
|
|
11614
11816
|
return;
|
|
11615
11817
|
}
|
|
11616
11818
|
if (["requesting", "standbyRequesting", "registering"].includes(this.state)) {
|
|
11617
|
-
this.setAvailabilityState("
|
|
11819
|
+
this.setAvailabilityState("preparing", "页面仍在线,正在建立网页电话连接。");
|
|
11820
|
+
return;
|
|
11821
|
+
}
|
|
11822
|
+
if (!this.legacyOutboundOnly && !this.issuedSession?.session_id && !this.pendingLifecycleMode && !["calling", "connected", "incoming"].includes(this.state)) {
|
|
11823
|
+
this.setAvailabilityState("recovering", "页面仍在线,正在自动恢复待机。"), this.scheduleAutoStandbyRecovery("missing-issued-session");
|
|
11618
11824
|
return;
|
|
11619
11825
|
}
|
|
11620
11826
|
this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。");
|
|
@@ -11638,6 +11844,23 @@ class Ci {
|
|
|
11638
11844
|
}
|
|
11639
11845
|
}
|
|
11640
11846
|
}
|
|
11847
|
+
async handleServerSessionAction(e, t = {}) {
|
|
11848
|
+
return this.legacyOutboundOnly || String(t?.session_action || "").trim().toLowerCase() !== "restart_standby" || this.sessionRecoveryInFlight || this.connectivityRecoveryInFlight ? !1 : ["requesting", "standbyRequesting", "calling", "incoming", "connected"].includes(this.state) ? (this.appendLog("服务端已要求重建待机,但当前阶段暂不主动打断。", {
|
|
11849
|
+
source: e,
|
|
11850
|
+
state: this.state,
|
|
11851
|
+
session_action_reason: t?.session_action_reason || null,
|
|
11852
|
+
session_action_detail: t?.session_action_detail || null
|
|
11853
|
+
}), !1) : (this.appendLog("服务端要求当前页面放弃旧锚点并重新进入待机。", {
|
|
11854
|
+
source: e,
|
|
11855
|
+
session_action_reason: t?.session_action_reason || null,
|
|
11856
|
+
session_action_detail: t?.session_action_detail || null,
|
|
11857
|
+
resolved_session_id: t?.resolved_session_id || null,
|
|
11858
|
+
resolved_widget_anchor_number: t?.resolved_widget_anchor_number || null,
|
|
11859
|
+
resolved_browser_sip_username: t?.resolved_browser_sip_username || null
|
|
11860
|
+
}), this.setAvailabilityState("recovering", t?.session_action_detail || "当前锚点已失效,正在自动切换到新的待机线路。"), await this.disconnectAndCleanup(`server-session-action-${t?.session_action_reason || e}`, {
|
|
11861
|
+
preserveLifecycleRun: !0
|
|
11862
|
+
}), await this.startStandby({ force: !0 }), !0);
|
|
11863
|
+
}
|
|
11641
11864
|
async touchWidgetPresence(e = "interval") {
|
|
11642
11865
|
if (this.legacyOutboundOnly)
|
|
11643
11866
|
return;
|
|
@@ -11674,14 +11897,15 @@ class Ci {
|
|
|
11674
11897
|
});
|
|
11675
11898
|
if (!i.ok)
|
|
11676
11899
|
throw new Error(`运行态心跳失败:${i.status}`);
|
|
11677
|
-
|
|
11900
|
+
const s = await i.json().catch(() => ({}));
|
|
11901
|
+
this.presenceFailureCount = 0, await this.handleServerSessionAction("touch-widget-presence", s) || this.syncAvailabilityState(), t && await this.restartStandbyAfterConnectivity(`presence-${e}`);
|
|
11678
11902
|
} catch (i) {
|
|
11679
|
-
if (this.presenceFailureCount += 1, this.networkOnline === !1 ||
|
|
11903
|
+
if (this.presenceFailureCount += 1, this.networkOnline === !1 || Le(i) || this.presenceFailureCount >= st) {
|
|
11680
11904
|
const r = this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。";
|
|
11681
11905
|
this.setAvailabilityState("offline", r);
|
|
11682
11906
|
} else
|
|
11683
11907
|
this.setAvailabilityState("recovering", "正在确认后台连接状态。");
|
|
11684
|
-
this.presenceFailureCount <=
|
|
11908
|
+
this.presenceFailureCount <= st && this.appendLog("widget 运行态心跳失败", {
|
|
11685
11909
|
trigger: e,
|
|
11686
11910
|
failure_count: this.presenceFailureCount,
|
|
11687
11911
|
message: i?.message || String(i)
|
|
@@ -11691,7 +11915,7 @@ class Ci {
|
|
|
11691
11915
|
startPresenceTouch() {
|
|
11692
11916
|
this.legacyOutboundOnly || (this.touchWidgetPresence("mount"), this.presenceTouchTimer || (this.presenceTouchTimer = window.setInterval(() => {
|
|
11693
11917
|
this.touchWidgetPresence("interval");
|
|
11694
|
-
},
|
|
11918
|
+
}, yi)));
|
|
11695
11919
|
}
|
|
11696
11920
|
async touchIssuedSession(e, t = null) {
|
|
11697
11921
|
if (!this.issuedSession?.session_id)
|
|
@@ -11711,10 +11935,14 @@ class Ci {
|
|
|
11711
11935
|
})
|
|
11712
11936
|
});
|
|
11713
11937
|
if (!s.ok) {
|
|
11714
|
-
const
|
|
11715
|
-
throw
|
|
11938
|
+
const n = new Error(`会话心跳失败:${s.status}`);
|
|
11939
|
+
throw n.status = s.status, n;
|
|
11716
11940
|
}
|
|
11941
|
+
const r = await s.json().catch(() => ({}));
|
|
11942
|
+
await this.handleServerSessionAction("touch-call-session", r);
|
|
11717
11943
|
} catch (s) {
|
|
11944
|
+
if (s?.status === 404 && this.wasSessionRecentlyReleased(i))
|
|
11945
|
+
return;
|
|
11718
11946
|
this.appendLog("网页通话会话心跳失败", {
|
|
11719
11947
|
session_id: i,
|
|
11720
11948
|
state: e,
|
|
@@ -11800,35 +12028,35 @@ class Ci {
|
|
|
11800
12028
|
}
|
|
11801
12029
|
this.touchIssuedSession(e), this.sessionTouchTimer || (this.sessionTouchTimer = window.setInterval(() => {
|
|
11802
12030
|
this.touchIssuedSession(this.state);
|
|
11803
|
-
},
|
|
12031
|
+
}, bt));
|
|
11804
12032
|
}
|
|
11805
12033
|
setState(e, t = "") {
|
|
11806
|
-
this.state = e, this.refs.status.textContent = t || Q[e] || Q.idle, this.
|
|
12034
|
+
this.state = e, this.refs.status.textContent = t || Q[e] || Q.idle, this.syncAvailabilityState(), this.render(), this.emitHostCallback("onStateChange", this.getSnapshot());
|
|
11807
12035
|
}
|
|
11808
12036
|
appendLog(e, t) {
|
|
11809
12037
|
const i = document.createElement("div");
|
|
11810
|
-
for (i.className = "log", i.textContent =
|
|
12038
|
+
for (i.className = "log", i.textContent = Ci(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
|
|
11811
12039
|
this.refs.logs.lastElementChild?.remove();
|
|
11812
12040
|
}
|
|
11813
12041
|
render() {
|
|
11814
|
-
const e = ["requesting", "standbyRequesting", "registering", "calling"].includes(this.state), t = ["calling", "connected"].includes(this.state), i = !!(this.client || this.issuedSession);
|
|
12042
|
+
const e = ["requesting", "standbyRequesting", "registering", "calling"].includes(this.state), t = ["calling", "connected"].includes(this.state), i = !!(this.client || this.issuedSession), s = !this.legacyOutboundOnly && !i && this.availabilityState !== "offline" && ["idle", "failed", "ended"].includes(this.state);
|
|
11815
12043
|
this.refs.status && (this.refs.status.className = [
|
|
11816
12044
|
"status",
|
|
11817
12045
|
this.availabilityState === "offline" ? "status--offline" : this.availabilityState === "recovering" ? "status--recovering" : ""
|
|
11818
|
-
].filter(Boolean).join(" ")), this.legacyOutboundOnly ? (this.refs.primary.disabled = e, this.refs.primary.textContent = t ? "通话进行中" : "连接并呼叫", this.refs.secondary.disabled = !t && !i, this.refs.secondary.textContent = t ? "挂断并清理" : "断开并清理") : (this.refs.primary.disabled = e || this.state === "connected", this.state === "incoming" ? this.refs.primary.textContent = "接听来电" : e ? this.refs.primary.textContent = this.state === "calling" ? "通话进行中" : "正在恢复网页电话" : this.availabilityState === "offline" ? this.refs.primary.textContent = "网络恢复后再试" : !i || ["idle", "failed", "ended"].includes(this.state) ? this.refs.primary.textContent = "恢复网页电话待机" : this.refs.primary.textContent = "呼叫管理员", this.refs.secondary.disabled = !i, this.refs.secondary.textContent = this.state === "incoming" ? "拒接来电" : this.state === "connected" ? "挂断并恢复待机" : "断开电话");
|
|
11819
|
-
const
|
|
11820
|
-
this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${
|
|
12046
|
+
].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" ? "挂断并恢复待机" : "断开电话");
|
|
12047
|
+
const r = this.options.siteKey || this.bootstrap?.default_site_key || "等待服务端返回", n = this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || "等待服务端返回";
|
|
12048
|
+
this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${n};站点键:${r}` : this.refs.meta.textContent = `站点键:${r};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${n}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ? wi : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。";
|
|
11821
12049
|
}
|
|
11822
12050
|
async destroy() {
|
|
11823
12051
|
await this.disconnectAndCleanup("destroy-widget"), typeof document < "u" && this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.stopSessionTouch(), this.stopPresenceTouch(), this.stopTransportDisconnectGrace(), this.pendingIncomingCall = null, typeof window < "u" && (this.onlineHandler && (window.removeEventListener("online", this.onlineHandler), this.onlineHandler = null), this.offlineHandler && (window.removeEventListener("offline", this.offlineHandler), this.offlineHandler = null)), this.e2eBridgeEnabled && typeof window < "u" && window.__embeddedCallWidgetE2E__ && delete window.__embeddedCallWidgetE2E__, this.shadowRoot.innerHTML = "";
|
|
11824
12052
|
}
|
|
11825
12053
|
}
|
|
11826
|
-
function
|
|
11827
|
-
return new
|
|
12054
|
+
function $i(a) {
|
|
12055
|
+
return new Ai(a);
|
|
11828
12056
|
}
|
|
11829
12057
|
typeof window < "u" && (window.__EmbeddedCallWidgetRuntime__ = {
|
|
11830
|
-
createEmbeddedCallWidgetRuntime:
|
|
12058
|
+
createEmbeddedCallWidgetRuntime: $i
|
|
11831
12059
|
});
|
|
11832
12060
|
export {
|
|
11833
|
-
|
|
12061
|
+
$i as createEmbeddedCallWidgetRuntime
|
|
11834
12062
|
};
|