@webex/calling 3.12.0-next.92 → 3.12.0-next.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CallingClient/registration/register.js +128 -58
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +362 -76
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/common/Utils.js +7 -18
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +3 -6
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/module/CallingClient/registration/register.js +32 -7
- package/dist/module/common/Utils.js +7 -12
- package/dist/types/CallingClient/registration/register.d.ts +1 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +0 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -37,6 +37,7 @@ var _SDKConnector = _interopRequireDefault(require("../../SDKConnector"));
|
|
|
37
37
|
var _types3 = require("../../common/types");
|
|
38
38
|
var _constants2 = require("../constants");
|
|
39
39
|
var _types4 = require("../line/types");
|
|
40
|
+
var _types5 = require("../../Errors/types");
|
|
40
41
|
var _request = require("../utils/request");
|
|
41
42
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
42
43
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -76,6 +77,13 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
76
77
|
(0, _defineProperty2.default)(this, "retryAfter", void 0);
|
|
77
78
|
(0, _defineProperty2.default)(this, "scheduled429Retry", false);
|
|
78
79
|
(0, _defineProperty2.default)(this, "webWorker", void 0);
|
|
80
|
+
/**
|
|
81
|
+
* Set once Mobius reports this session as superseded by another registration for the
|
|
82
|
+
* same user. It survives cleanup so that no automatic recovery path re-registers this
|
|
83
|
+
* device, which would restart the registration ping-pong between the two sessions.
|
|
84
|
+
* Only an explicit `triggerRegistration()` from the consumer clears it.
|
|
85
|
+
*/
|
|
86
|
+
(0, _defineProperty2.default)(this, "sessionSuperseded", false);
|
|
79
87
|
(0, _defineProperty2.default)(this, "apiRequest", void 0);
|
|
80
88
|
this.jwe = jwe;
|
|
81
89
|
this.sdkConnector = _SDKConnector.default;
|
|
@@ -490,6 +498,13 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
490
498
|
file: _constants2.REGISTRATION_FILE,
|
|
491
499
|
method: _constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE
|
|
492
500
|
};
|
|
501
|
+
/*
|
|
502
|
+
* Latch the terminal state before anything that can yield. Cleanup runs under the
|
|
503
|
+
* shared mutex, so it can be queued behind a recovery that is already registering;
|
|
504
|
+
* latching here means every registration path that has not started yet sees the
|
|
505
|
+
* superseded state rather than racing this cleanup.
|
|
506
|
+
*/
|
|
507
|
+
this.sessionSuperseded = true;
|
|
493
508
|
_Logger.default.warn("Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ".concat(keepaliveRetryCount), loggerContext);
|
|
494
509
|
|
|
495
510
|
/* Stop the keepalive worker up front so no further keepalive is sent while cleanup waits on the mutex. */
|
|
@@ -1339,6 +1354,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1339
1354
|
method: _constants2.METHODS.TRIGGER_REGISTRATION
|
|
1340
1355
|
};
|
|
1341
1356
|
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
1357
|
+
|
|
1358
|
+
/* An explicit registration from the consumer is the only way out of a superseded
|
|
1359
|
+
* session, so the terminal state is lifted here. */
|
|
1360
|
+
this.sessionSuperseded = false;
|
|
1342
1361
|
_context22.next = 1;
|
|
1343
1362
|
return this.resumeFailover();
|
|
1344
1363
|
case 1:
|
|
@@ -1412,21 +1431,40 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1412
1431
|
file: _constants2.REGISTRATION_FILE,
|
|
1413
1432
|
method: _constants2.REGISTER_UTIL
|
|
1414
1433
|
};
|
|
1434
|
+
/*
|
|
1435
|
+
* Single choke point for every registration attempt - initial registration, restore,
|
|
1436
|
+
* restart, the scheduled failover retries and failback all reach Mobius through here.
|
|
1437
|
+
* Guarding it once means a superseded session cannot be re-registered by any
|
|
1438
|
+
* automatic path, including one whose timer was already scheduled when the 409
|
|
1439
|
+
* arrived. `true` is returned so callers treat it as a final error and schedule no
|
|
1440
|
+
* further retries. `triggerRegistration()` clears the latch before calling in, so an
|
|
1441
|
+
* explicit registration by the consumer is unaffected.
|
|
1442
|
+
*/
|
|
1443
|
+
if (!this.sessionSuperseded) {
|
|
1444
|
+
_context24.next = 1;
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
_Logger.default.warn("Session superseded, skipping registration attempt - caller: ".concat(caller), {
|
|
1448
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1449
|
+
method: caller
|
|
1450
|
+
});
|
|
1451
|
+
return _context24.abrupt("return", true);
|
|
1452
|
+
case 1:
|
|
1415
1453
|
abort = false;
|
|
1416
1454
|
this.retryAfter = undefined;
|
|
1417
1455
|
if (!this.failoverImmediately) {
|
|
1418
|
-
_context24.next =
|
|
1456
|
+
_context24.next = 2;
|
|
1419
1457
|
break;
|
|
1420
1458
|
}
|
|
1421
1459
|
return _context24.abrupt("return", abort);
|
|
1422
|
-
case
|
|
1460
|
+
case 2:
|
|
1423
1461
|
if (!this.isDeviceRegistered()) {
|
|
1424
|
-
_context24.next =
|
|
1462
|
+
_context24.next = 3;
|
|
1425
1463
|
break;
|
|
1426
1464
|
}
|
|
1427
1465
|
_Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), loggerContext);
|
|
1428
1466
|
return _context24.abrupt("return", abort);
|
|
1429
|
-
case
|
|
1467
|
+
case 3:
|
|
1430
1468
|
/*
|
|
1431
1469
|
* Align the active transport with this server group. When the Mobius socket is enabled
|
|
1432
1470
|
* but a group has no WSS URL, CallingClient hands us its HTTP URIs instead; routing those
|
|
@@ -1438,7 +1476,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1438
1476
|
this.apiRequest.setSocketEnabled(servers[0].startsWith('wss://'));
|
|
1439
1477
|
}
|
|
1440
1478
|
_iterator2 = _createForOfIteratorHelper(servers);
|
|
1441
|
-
_context24.prev =
|
|
1479
|
+
_context24.prev = 4;
|
|
1442
1480
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1443
1481
|
var url, serverType, _this8$deviceInfo$dev, _resp$headers, _resp$headers$trackin, _resp$headers2, _this8$deviceInfo$dev2, wssNormalizedUrl, resp, body, _yield$handleRegistra, finalError, shouldDisconnect, _t5;
|
|
1444
1482
|
return _regenerator.default.wrap(function (_context23) {
|
|
@@ -1549,40 +1587,40 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1549
1587
|
}, _loop, null, [[1, 5]]);
|
|
1550
1588
|
});
|
|
1551
1589
|
_iterator2.s();
|
|
1552
|
-
case
|
|
1590
|
+
case 5:
|
|
1553
1591
|
if ((_step2 = _iterator2.n()).done) {
|
|
1554
|
-
_context24.next =
|
|
1592
|
+
_context24.next = 8;
|
|
1555
1593
|
break;
|
|
1556
1594
|
}
|
|
1557
|
-
return _context24.delegateYield(_loop(), "t0",
|
|
1558
|
-
case
|
|
1595
|
+
return _context24.delegateYield(_loop(), "t0", 6);
|
|
1596
|
+
case 6:
|
|
1559
1597
|
_ret = _context24.t0;
|
|
1560
1598
|
if (!(_ret === 0)) {
|
|
1561
|
-
_context24.next =
|
|
1599
|
+
_context24.next = 7;
|
|
1562
1600
|
break;
|
|
1563
1601
|
}
|
|
1564
|
-
return _context24.abrupt("continue",
|
|
1565
|
-
case 6:
|
|
1566
|
-
_context24.next = 4;
|
|
1567
|
-
break;
|
|
1602
|
+
return _context24.abrupt("continue", 8);
|
|
1568
1603
|
case 7:
|
|
1569
|
-
_context24.next =
|
|
1604
|
+
_context24.next = 5;
|
|
1570
1605
|
break;
|
|
1571
1606
|
case 8:
|
|
1572
|
-
_context24.
|
|
1573
|
-
|
|
1574
|
-
_iterator2.e(_t6);
|
|
1607
|
+
_context24.next = 10;
|
|
1608
|
+
break;
|
|
1575
1609
|
case 9:
|
|
1576
1610
|
_context24.prev = 9;
|
|
1577
|
-
|
|
1578
|
-
|
|
1611
|
+
_t6 = _context24["catch"](4);
|
|
1612
|
+
_iterator2.e(_t6);
|
|
1579
1613
|
case 10:
|
|
1580
|
-
|
|
1614
|
+
_context24.prev = 10;
|
|
1615
|
+
_iterator2.f();
|
|
1616
|
+
return _context24.finish(10);
|
|
1581
1617
|
case 11:
|
|
1618
|
+
return _context24.abrupt("return", abort);
|
|
1619
|
+
case 12:
|
|
1582
1620
|
case "end":
|
|
1583
1621
|
return _context24.stop();
|
|
1584
1622
|
}
|
|
1585
|
-
}, _callee23, this, [[
|
|
1623
|
+
}, _callee23, this, [[4, 9, 10, 11]]);
|
|
1586
1624
|
}));
|
|
1587
1625
|
function attemptRegistrationWithServers(_x17) {
|
|
1588
1626
|
return _attemptRegistrationWithServers.apply(this, arguments);
|
|
@@ -1607,7 +1645,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1607
1645
|
RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
1608
1646
|
_context27.next = 1;
|
|
1609
1647
|
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1610
|
-
var blob, blobUrl;
|
|
1648
|
+
var blob, blobUrl, worker, isCurrentWorker;
|
|
1611
1649
|
return _regenerator.default.wrap(function (_context26) {
|
|
1612
1650
|
while (1) switch (_context26.prev = _context26.next) {
|
|
1613
1651
|
case 0:
|
|
@@ -1617,16 +1655,28 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1617
1655
|
type: 'application/javascript'
|
|
1618
1656
|
});
|
|
1619
1657
|
blobUrl = URL.createObjectURL(blob);
|
|
1620
|
-
|
|
1658
|
+
worker = new Worker(blobUrl);
|
|
1659
|
+
_this9.webWorker = worker;
|
|
1621
1660
|
URL.revokeObjectURL(blobUrl);
|
|
1622
|
-
|
|
1661
|
+
worker.postMessage({
|
|
1623
1662
|
type: _types3.WorkerMessageType.START_KEEPALIVE,
|
|
1624
1663
|
interval: interval,
|
|
1625
1664
|
retryCountThreshold: RETRY_COUNT_THRESHOLD
|
|
1626
1665
|
});
|
|
1627
|
-
|
|
1666
|
+
|
|
1667
|
+
/*
|
|
1668
|
+
* A keepalive is in flight across an `await`, so this worker can be replaced
|
|
1669
|
+
* meanwhile - on failback, connection restoration or any re-registration. Its
|
|
1670
|
+
* result then belongs to a device that is no longer the registered one and must
|
|
1671
|
+
* not reach the current worker, whose retry count and failure handling (including
|
|
1672
|
+
* the 409 hard stop) would otherwise act on a stale registration.
|
|
1673
|
+
*/
|
|
1674
|
+
isCurrentWorker = function isCurrentWorker() {
|
|
1675
|
+
return _this9.webWorker === worker;
|
|
1676
|
+
};
|
|
1677
|
+
worker.onmessage = /*#__PURE__*/function () {
|
|
1628
1678
|
var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24(event) {
|
|
1629
|
-
var logContext,
|
|
1679
|
+
var logContext, res, _err$headers, error, _error, _yield$handleRegistra2, abort, _t7;
|
|
1630
1680
|
return _regenerator.default.wrap(function (_context25) {
|
|
1631
1681
|
while (1) switch (_context25.prev = _context25.next) {
|
|
1632
1682
|
case 0:
|
|
@@ -1634,24 +1684,38 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1634
1684
|
file: _constants2.REGISTRATION_FILE,
|
|
1635
1685
|
method: _constants2.KEEPALIVE_UTIL
|
|
1636
1686
|
};
|
|
1687
|
+
if (isCurrentWorker()) {
|
|
1688
|
+
_context25.next = 1;
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
_Logger.default.info('Ignoring message from a replaced keepalive worker', logContext);
|
|
1692
|
+
return _context25.abrupt("return");
|
|
1693
|
+
case 1:
|
|
1637
1694
|
if (!(event.data.type === _types3.WorkerMessageType.SEND_KEEPALIVE)) {
|
|
1638
|
-
_context25.next =
|
|
1695
|
+
_context25.next = 7;
|
|
1639
1696
|
break;
|
|
1640
1697
|
}
|
|
1641
|
-
_context25.prev =
|
|
1642
|
-
_context25.next =
|
|
1698
|
+
_context25.prev = 2;
|
|
1699
|
+
_context25.next = 3;
|
|
1643
1700
|
return _this9.postKeepAlive(String(_this9.webex.internal.device.url), url);
|
|
1644
|
-
case
|
|
1701
|
+
case 3:
|
|
1645
1702
|
res = _context25.sent;
|
|
1646
|
-
(
|
|
1703
|
+
if (isCurrentWorker()) {
|
|
1704
|
+
_context25.next = 4;
|
|
1705
|
+
break;
|
|
1706
|
+
}
|
|
1707
|
+
_Logger.default.info('Discarding keepalive result of a replaced worker', logContext);
|
|
1708
|
+
return _context25.abrupt("return");
|
|
1709
|
+
case 4:
|
|
1710
|
+
worker.postMessage({
|
|
1647
1711
|
type: _types3.WorkerMessageType.KEEPALIVE_RESULT,
|
|
1648
1712
|
statusCode: res.statusCode
|
|
1649
1713
|
});
|
|
1650
|
-
_context25.next =
|
|
1714
|
+
_context25.next = 7;
|
|
1651
1715
|
break;
|
|
1652
|
-
case
|
|
1653
|
-
_context25.prev =
|
|
1654
|
-
_t7 = _context25["catch"](
|
|
1716
|
+
case 5:
|
|
1717
|
+
_context25.prev = 5;
|
|
1718
|
+
_t7 = _context25["catch"](2);
|
|
1655
1719
|
error = {
|
|
1656
1720
|
headers: {
|
|
1657
1721
|
trackingid: (_err$headers = _t7.headers) === null || _err$headers === void 0 ? void 0 : _err$headers.trackingid,
|
|
@@ -1661,22 +1725,29 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1661
1725
|
statusText: _t7.statusText,
|
|
1662
1726
|
type: _t7.type
|
|
1663
1727
|
};
|
|
1664
|
-
(
|
|
1728
|
+
if (isCurrentWorker()) {
|
|
1729
|
+
_context25.next = 6;
|
|
1730
|
+
break;
|
|
1731
|
+
}
|
|
1732
|
+
_Logger.default.info("Discarding keepalive failure of a replaced worker, status -> ".concat(error.statusCode), logContext);
|
|
1733
|
+
return _context25.abrupt("return");
|
|
1734
|
+
case 6:
|
|
1735
|
+
worker.postMessage({
|
|
1665
1736
|
type: _types3.WorkerMessageType.KEEPALIVE_RESULT,
|
|
1666
1737
|
err: error
|
|
1667
1738
|
});
|
|
1668
|
-
case
|
|
1739
|
+
case 7:
|
|
1669
1740
|
if (event.data.type === _types3.WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
1670
1741
|
_Logger.default.info("Sent Keepalive, status: ".concat(event.data.statusCode), logContext);
|
|
1671
1742
|
_this9.lineEmitter(_types4.LINE_EVENTS.RECONNECTED);
|
|
1672
1743
|
}
|
|
1673
1744
|
if (!(event.data.type === _types3.WorkerMessageType.KEEPALIVE_FAILURE)) {
|
|
1674
|
-
_context25.next =
|
|
1745
|
+
_context25.next = 15;
|
|
1675
1746
|
break;
|
|
1676
1747
|
}
|
|
1677
1748
|
_error = event.data.err;
|
|
1678
1749
|
_Logger.default.warn("Keep-alive missed ".concat(event.data.keepAliveRetryCount, " times. Status -> ").concat(_error.statusCode, " "), logContext);
|
|
1679
|
-
_context25.next =
|
|
1750
|
+
_context25.next = 8;
|
|
1680
1751
|
return (0, _common.handleRegistrationErrors)(_error, function (clientError, finalError) {
|
|
1681
1752
|
var _error$headers$tracki2, _error$headers2;
|
|
1682
1753
|
if (finalError) {
|
|
@@ -1694,18 +1765,17 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1694
1765
|
return _this9.handle409KeepaliveFailure(clientError, _error, serverType, event.data.keepAliveRetryCount);
|
|
1695
1766
|
}
|
|
1696
1767
|
});
|
|
1697
|
-
case
|
|
1768
|
+
case 8:
|
|
1698
1769
|
_yield$handleRegistra2 = _context25.sent;
|
|
1699
1770
|
abort = _yield$handleRegistra2.finalError;
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
_context25.next = 6;
|
|
1771
|
+
if (!(abort && Number(_error.statusCode) === _types5.ERROR_CODE.CONFLICT)) {
|
|
1772
|
+
_context25.next = 9;
|
|
1703
1773
|
break;
|
|
1704
1774
|
}
|
|
1705
1775
|
return _context25.abrupt("return");
|
|
1706
|
-
case
|
|
1776
|
+
case 9:
|
|
1707
1777
|
if (!(abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
|
|
1708
|
-
_context25.next =
|
|
1778
|
+
_context25.next = 14;
|
|
1709
1779
|
break;
|
|
1710
1780
|
}
|
|
1711
1781
|
_this9.failoverImmediately = _this9.isCCFlow;
|
|
@@ -1713,32 +1783,32 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1713
1783
|
_this9.clearKeepaliveTimer();
|
|
1714
1784
|
_this9.clearFailbackTimer();
|
|
1715
1785
|
_this9.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1716
|
-
_context25.next =
|
|
1786
|
+
_context25.next = 10;
|
|
1717
1787
|
return (0, _common.uploadLogs)();
|
|
1718
|
-
case
|
|
1788
|
+
case 10:
|
|
1719
1789
|
if (abort) {
|
|
1720
|
-
_context25.next =
|
|
1790
|
+
_context25.next = 12;
|
|
1721
1791
|
break;
|
|
1722
1792
|
}
|
|
1723
|
-
_context25.next =
|
|
1793
|
+
_context25.next = 11;
|
|
1724
1794
|
return _this9.reconnectOnFailure(_constants2.RECONNECT_ON_FAILURE_UTIL);
|
|
1725
|
-
case
|
|
1726
|
-
_context25.next =
|
|
1795
|
+
case 11:
|
|
1796
|
+
_context25.next = 13;
|
|
1727
1797
|
break;
|
|
1728
|
-
case
|
|
1798
|
+
case 12:
|
|
1729
1799
|
if (_error.statusCode === 404) {
|
|
1730
1800
|
_this9.handle404KeepaliveFailure(_constants2.KEEPALIVE_UTIL);
|
|
1731
1801
|
}
|
|
1732
|
-
case
|
|
1733
|
-
_context25.next =
|
|
1802
|
+
case 13:
|
|
1803
|
+
_context25.next = 15;
|
|
1734
1804
|
break;
|
|
1735
|
-
case
|
|
1805
|
+
case 14:
|
|
1736
1806
|
_this9.lineEmitter(_types4.LINE_EVENTS.RECONNECTING);
|
|
1737
|
-
case
|
|
1807
|
+
case 15:
|
|
1738
1808
|
case "end":
|
|
1739
1809
|
return _context25.stop();
|
|
1740
1810
|
}
|
|
1741
|
-
}, _callee24, null, [[
|
|
1811
|
+
}, _callee24, null, [[2, 5]]);
|
|
1742
1812
|
}));
|
|
1743
1813
|
return function (_x21) {
|
|
1744
1814
|
return _ref11.apply(this, arguments);
|