@webex/calling 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CallHistory/CallHistory.js +596 -0
- package/dist/CallHistory/CallHistory.js.map +1 -0
- package/dist/CallHistory/CallHistory.test.js +916 -0
- package/dist/CallHistory/CallHistory.test.js.map +1 -0
- package/dist/CallHistory/callHistoryFixtures.js +650 -0
- package/dist/CallHistory/callHistoryFixtures.js.map +1 -0
- package/dist/CallHistory/constants.js +38 -0
- package/dist/CallHistory/constants.js.map +1 -0
- package/dist/CallHistory/types.js +7 -0
- package/dist/CallHistory/types.js.map +1 -0
- package/dist/CallSettings/CallSettings.js +311 -0
- package/dist/CallSettings/CallSettings.js.map +1 -0
- package/dist/CallSettings/CallSettings.test.js +122 -0
- package/dist/CallSettings/CallSettings.test.js.map +1 -0
- package/dist/CallSettings/UcmBackendConnector.js +308 -0
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -0
- package/dist/CallSettings/UcmBackendConnector.test.js +411 -0
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -0
- package/dist/CallSettings/WxCallBackendConnector.js +597 -0
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -0
- package/dist/CallSettings/WxCallBackendConnector.test.js +904 -0
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -0
- package/dist/CallSettings/constants.js +31 -0
- package/dist/CallSettings/constants.js.map +1 -0
- package/dist/CallSettings/testFixtures.js +68 -0
- package/dist/CallSettings/testFixtures.js.map +1 -0
- package/dist/CallSettings/types.js +7 -0
- package/dist/CallSettings/types.js.map +1 -0
- package/dist/CallingClient/CallingClient.js +1119 -0
- package/dist/CallingClient/CallingClient.js.map +1 -0
- package/dist/CallingClient/CallingClient.test.js +1266 -0
- package/dist/CallingClient/CallingClient.test.js.map +1 -0
- package/dist/CallingClient/callRecordFixtures.js +101 -0
- package/dist/CallingClient/callRecordFixtures.js.map +1 -0
- package/dist/CallingClient/calling/CallerId/index.js +275 -0
- package/dist/CallingClient/calling/CallerId/index.js.map +1 -0
- package/dist/CallingClient/calling/CallerId/index.test.js +275 -0
- package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -0
- package/dist/CallingClient/calling/CallerId/types.js +7 -0
- package/dist/CallingClient/calling/CallerId/types.js.map +1 -0
- package/dist/CallingClient/calling/call.js +3486 -0
- package/dist/CallingClient/calling/call.js.map +1 -0
- package/dist/CallingClient/calling/call.test.js +3612 -0
- package/dist/CallingClient/calling/call.test.js.map +1 -0
- package/dist/CallingClient/calling/callManager.js +460 -0
- package/dist/CallingClient/calling/callManager.js.map +1 -0
- package/dist/CallingClient/calling/callManager.test.js +741 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -0
- package/dist/CallingClient/calling/index.js +30 -0
- package/dist/CallingClient/calling/index.js.map +1 -0
- package/dist/CallingClient/calling/types.js +74 -0
- package/dist/CallingClient/calling/types.js.map +1 -0
- package/dist/CallingClient/callingClientFixtures.js +143 -0
- package/dist/CallingClient/callingClientFixtures.js.map +1 -0
- package/dist/CallingClient/constants.js +243 -0
- package/dist/CallingClient/constants.js.map +1 -0
- package/dist/CallingClient/line/index.js +332 -0
- package/dist/CallingClient/line/index.js.map +1 -0
- package/dist/CallingClient/line/line.test.js +327 -0
- package/dist/CallingClient/line/line.test.js.map +1 -0
- package/dist/CallingClient/line/types.js +21 -0
- package/dist/CallingClient/line/types.js.map +1 -0
- package/dist/CallingClient/registration/index.js +19 -0
- package/dist/CallingClient/registration/index.js.map +1 -0
- package/dist/CallingClient/registration/register.js +1686 -0
- package/dist/CallingClient/registration/register.js.map +1 -0
- package/dist/CallingClient/registration/register.test.js +1885 -0
- package/dist/CallingClient/registration/register.test.js.map +1 -0
- package/dist/CallingClient/registration/registerFixtures.js +36 -0
- package/dist/CallingClient/registration/registerFixtures.js.map +1 -0
- package/dist/CallingClient/registration/types.js +7 -0
- package/dist/CallingClient/registration/types.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.js +130 -0
- package/dist/CallingClient/registration/webWorker.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.test.js +303 -0
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -0
- package/dist/CallingClient/registration/webWorkerStr.js +15 -0
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -0
- package/dist/CallingClient/types.js +7 -0
- package/dist/CallingClient/types.js.map +1 -0
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +142 -0
- package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +1206 -0
- package/dist/Contacts/ContactsClient.js.map +1 -0
- package/dist/Contacts/ContactsClient.test.js +1004 -0
- package/dist/Contacts/ContactsClient.test.js.map +1 -0
- package/dist/Contacts/constants.js +40 -0
- package/dist/Contacts/constants.js.map +1 -0
- package/dist/Contacts/contactFixtures.js +430 -0
- package/dist/Contacts/contactFixtures.js.map +1 -0
- package/dist/Contacts/types.js +43 -0
- package/dist/Contacts/types.js.map +1 -0
- package/dist/Errors/catalog/CallError.js +89 -0
- package/dist/Errors/catalog/CallError.js.map +1 -0
- package/dist/Errors/catalog/CallingDeviceError.js +83 -0
- package/dist/Errors/catalog/CallingDeviceError.js.map +1 -0
- package/dist/Errors/catalog/ExtendedError.js +42 -0
- package/dist/Errors/catalog/ExtendedError.js.map +1 -0
- package/dist/Errors/catalog/LineError.js +85 -0
- package/dist/Errors/catalog/LineError.js.map +1 -0
- package/dist/Errors/index.js +28 -0
- package/dist/Errors/index.js.map +1 -0
- package/dist/Errors/types.js +59 -0
- package/dist/Errors/types.js.map +1 -0
- package/dist/Events/impl/index.js +79 -0
- package/dist/Events/impl/index.js.map +1 -0
- package/dist/Events/types.js +107 -0
- package/dist/Events/types.js.map +1 -0
- package/dist/Logger/index.js +228 -0
- package/dist/Logger/index.js.map +1 -0
- package/dist/Logger/index.test.js +87 -0
- package/dist/Logger/index.test.js.map +1 -0
- package/dist/Logger/types.js +34 -0
- package/dist/Logger/types.js.map +1 -0
- package/dist/Metrics/index.js +534 -0
- package/dist/Metrics/index.js.map +1 -0
- package/dist/Metrics/index.test.js +463 -0
- package/dist/Metrics/index.test.js.map +1 -0
- package/dist/Metrics/types.js +64 -0
- package/dist/Metrics/types.js.map +1 -0
- package/dist/SDKConnector/index.js +102 -0
- package/dist/SDKConnector/index.js.map +1 -0
- package/dist/SDKConnector/index.test.js +9 -0
- package/dist/SDKConnector/index.test.js.map +1 -0
- package/dist/SDKConnector/types.js +7 -0
- package/dist/SDKConnector/types.js.map +1 -0
- package/dist/SDKConnector/utils.js +39 -0
- package/dist/SDKConnector/utils.js.map +1 -0
- package/dist/SDKConnector/utils.test.js +9 -0
- package/dist/SDKConnector/utils.test.js.map +1 -0
- package/dist/Voicemail/BroadworksBackendConnector.js +699 -0
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -0
- package/dist/Voicemail/BroadworksBackendConnector.test.js +820 -0
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -0
- package/dist/Voicemail/UcmBackendConnector.js +628 -0
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -0
- package/dist/Voicemail/UcmBackendConnector.test.js +738 -0
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -0
- package/dist/Voicemail/Voicemail.js +472 -0
- package/dist/Voicemail/Voicemail.js.map +1 -0
- package/dist/Voicemail/Voicemail.test.js +391 -0
- package/dist/Voicemail/Voicemail.test.js.map +1 -0
- package/dist/Voicemail/WxCallBackendConnector.js +657 -0
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -0
- package/dist/Voicemail/WxCallBackendConnector.test.js +1225 -0
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -0
- package/dist/Voicemail/constants.js +61 -0
- package/dist/Voicemail/constants.js.map +1 -0
- package/dist/Voicemail/types.js +7 -0
- package/dist/Voicemail/types.js.map +1 -0
- package/dist/Voicemail/voicemailFixture.js +524 -0
- package/dist/Voicemail/voicemailFixture.js.map +1 -0
- package/dist/api.js +157 -0
- package/dist/api.js.map +1 -0
- package/dist/common/Utils.js +1483 -0
- package/dist/common/Utils.js.map +1 -0
- package/dist/common/Utils.test.js +1989 -0
- package/dist/common/Utils.test.js.map +1 -0
- package/dist/common/constants.js +62 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/index.js +19 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/testUtil.js +983 -0
- package/dist/common/testUtil.js.map +1 -0
- package/dist/common/types.js +75 -0
- package/dist/common/types.js.map +1 -0
- package/dist/index.js +321 -0
- package/dist/index.js.map +1 -0
- package/dist/module/CallHistory/CallHistory.js +28 -17
- package/dist/module/CallingClient/CallingClient.js +43 -1
- package/dist/module/CallingClient/calling/call.js +3 -2
- package/dist/module/CallingClient/constants.js +2 -0
- package/dist/module/CallingClient/registration/register.js +8 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +2 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +2 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +2 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +2 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/types.d.ts +2 -1
- package/dist/types/CallingClient/types.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +4 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,1686 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
5
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
6
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
7
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
8
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
9
|
+
var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
|
|
10
|
+
var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
|
|
11
|
+
var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
|
|
12
|
+
var _Array$isArray = require("@babel/runtime-corejs2/core-js/array/is-array");
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
14
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
exports.createRegistration = exports.Registration = void 0;
|
|
18
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
19
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
20
|
+
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
21
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
22
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
23
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
24
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
25
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
27
|
+
var _uuid = require("uuid");
|
|
28
|
+
var _constants = require("../../common/constants");
|
|
29
|
+
var _common = require("../../common");
|
|
30
|
+
var _webWorkerStr = _interopRequireDefault(require("./webWorkerStr"));
|
|
31
|
+
var _types = require("../../Metrics/types");
|
|
32
|
+
var _Metrics = require("../../Metrics");
|
|
33
|
+
var _calling = require("../calling");
|
|
34
|
+
var _Logger = _interopRequireDefault(require("../../Logger"));
|
|
35
|
+
var _SDKConnector = _interopRequireDefault(require("../../SDKConnector"));
|
|
36
|
+
var _types2 = require("../../common/types");
|
|
37
|
+
var _constants2 = require("../constants");
|
|
38
|
+
var _types3 = require("../line/types");
|
|
39
|
+
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; } } }; }
|
|
40
|
+
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; } }
|
|
41
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
42
|
+
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
43
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
48
|
+
/**
|
|
49
|
+
*/
|
|
50
|
+
function Registration(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
|
|
51
|
+
(0, _classCallCheck2.default)(this, Registration);
|
|
52
|
+
(0, _defineProperty2.default)(this, "sdkConnector", void 0);
|
|
53
|
+
(0, _defineProperty2.default)(this, "webex", void 0);
|
|
54
|
+
(0, _defineProperty2.default)(this, "userId", '');
|
|
55
|
+
(0, _defineProperty2.default)(this, "serviceData", void 0);
|
|
56
|
+
(0, _defineProperty2.default)(this, "failback429RetryAttempts", void 0);
|
|
57
|
+
(0, _defineProperty2.default)(this, "registrationStatus", void 0);
|
|
58
|
+
(0, _defineProperty2.default)(this, "failbackTimer", void 0);
|
|
59
|
+
(0, _defineProperty2.default)(this, "activeMobiusUrl", void 0);
|
|
60
|
+
(0, _defineProperty2.default)(this, "rehomingIntervalMin", void 0);
|
|
61
|
+
(0, _defineProperty2.default)(this, "rehomingIntervalMax", void 0);
|
|
62
|
+
(0, _defineProperty2.default)(this, "mutex", void 0);
|
|
63
|
+
(0, _defineProperty2.default)(this, "metricManager", void 0);
|
|
64
|
+
(0, _defineProperty2.default)(this, "lineEmitter", void 0);
|
|
65
|
+
(0, _defineProperty2.default)(this, "callManager", void 0);
|
|
66
|
+
(0, _defineProperty2.default)(this, "deviceInfo", {});
|
|
67
|
+
(0, _defineProperty2.default)(this, "primaryMobiusUris", void 0);
|
|
68
|
+
(0, _defineProperty2.default)(this, "backupMobiusUris", void 0);
|
|
69
|
+
(0, _defineProperty2.default)(this, "registerRetry", false);
|
|
70
|
+
(0, _defineProperty2.default)(this, "reconnectPending", false);
|
|
71
|
+
(0, _defineProperty2.default)(this, "jwe", void 0);
|
|
72
|
+
(0, _defineProperty2.default)(this, "isCCFlow", false);
|
|
73
|
+
(0, _defineProperty2.default)(this, "failoverImmediately", false);
|
|
74
|
+
(0, _defineProperty2.default)(this, "retryAfter", void 0);
|
|
75
|
+
(0, _defineProperty2.default)(this, "scheduled429Retry", false);
|
|
76
|
+
(0, _defineProperty2.default)(this, "webWorker", void 0);
|
|
77
|
+
this.jwe = jwe;
|
|
78
|
+
this.sdkConnector = _SDKConnector.default;
|
|
79
|
+
this.serviceData = serviceData;
|
|
80
|
+
this.isCCFlow = serviceData.indicator === _types2.ServiceIndicator.CONTACT_CENTER;
|
|
81
|
+
if (!this.sdkConnector.getWebex()) {
|
|
82
|
+
_SDKConnector.default.setWebex(webex);
|
|
83
|
+
}
|
|
84
|
+
this.webex = this.sdkConnector.getWebex();
|
|
85
|
+
this.userId = this.webex.internal.device.userId;
|
|
86
|
+
this.registrationStatus = _types2.RegistrationStatus.IDLE;
|
|
87
|
+
this.failback429RetryAttempts = 0;
|
|
88
|
+
_Logger.default.setLogger(logLevel, _constants2.REGISTRATION_FILE);
|
|
89
|
+
this.rehomingIntervalMin = _constants2.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
90
|
+
this.rehomingIntervalMax = _constants2.DEFAULT_REHOMING_INTERVAL_MAX;
|
|
91
|
+
this.mutex = mutex;
|
|
92
|
+
this.callManager = (0, _calling.getCallManager)(this.webex, serviceData.indicator);
|
|
93
|
+
this.metricManager = (0, _Metrics.getMetricManager)(this.webex, serviceData.indicator);
|
|
94
|
+
this.lineEmitter = lineEmitter;
|
|
95
|
+
this.primaryMobiusUris = [];
|
|
96
|
+
this.backupMobiusUris = [];
|
|
97
|
+
}
|
|
98
|
+
return (0, _createClass2.default)(Registration, [{
|
|
99
|
+
key: "getFailoverCacheKey",
|
|
100
|
+
value: function getFailoverCacheKey() {
|
|
101
|
+
return "".concat(_constants2.FAILOVER_CACHE_PREFIX, ".").concat(this.userId || 'unknown');
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "saveFailoverState",
|
|
105
|
+
value: function saveFailoverState(failoverState) {
|
|
106
|
+
try {
|
|
107
|
+
localStorage.setItem(this.getFailoverCacheKey(), (0, _stringify.default)(failoverState));
|
|
108
|
+
} catch (error) {
|
|
109
|
+
_Logger.default.warn("Storing failover state in cache failed with error: ".concat(String(error)), {
|
|
110
|
+
file: _constants2.REGISTRATION_FILE,
|
|
111
|
+
method: 'saveFailoverState'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "clearFailoverState",
|
|
117
|
+
value: function clearFailoverState() {
|
|
118
|
+
try {
|
|
119
|
+
localStorage.removeItem(this.getFailoverCacheKey());
|
|
120
|
+
} catch (_unused) {
|
|
121
|
+
_Logger.default.warn('Clearing failover state from localStorage failed', {
|
|
122
|
+
file: _constants2.REGISTRATION_FILE,
|
|
123
|
+
method: 'clearFailoverState'
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "resumeFailover",
|
|
129
|
+
value: function () {
|
|
130
|
+
var _resumeFailover = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
131
|
+
var cachedState, failoverState, currentTime, newElapsed, _t;
|
|
132
|
+
return _regenerator.default.wrap(function (_context) {
|
|
133
|
+
while (1) switch (_context.prev = _context.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
_context.prev = 0;
|
|
136
|
+
cachedState = localStorage.getItem(this.getFailoverCacheKey());
|
|
137
|
+
failoverState = cachedState ? JSON.parse(cachedState) : undefined;
|
|
138
|
+
if (!(failoverState && !this.isDeviceRegistered())) {
|
|
139
|
+
_context.next = 2;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
currentTime = Math.floor((0, _now.default)() / 1000);
|
|
143
|
+
newElapsed = failoverState.timeElapsed + (currentTime - failoverState.retryScheduledTime);
|
|
144
|
+
this.clearFailoverState();
|
|
145
|
+
_context.next = 1;
|
|
146
|
+
return this.startFailoverTimer(failoverState.attempt, newElapsed);
|
|
147
|
+
case 1:
|
|
148
|
+
return _context.abrupt("return", true);
|
|
149
|
+
case 2:
|
|
150
|
+
_context.next = 4;
|
|
151
|
+
break;
|
|
152
|
+
case 3:
|
|
153
|
+
_context.prev = 3;
|
|
154
|
+
_t = _context["catch"](0);
|
|
155
|
+
_Logger.default.warn("No failover state found in cache", {
|
|
156
|
+
file: _constants2.REGISTRATION_FILE,
|
|
157
|
+
method: 'triggerRegistration'
|
|
158
|
+
});
|
|
159
|
+
case 4:
|
|
160
|
+
return _context.abrupt("return", false);
|
|
161
|
+
case 5:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context.stop();
|
|
164
|
+
}
|
|
165
|
+
}, _callee, this, [[0, 3]]);
|
|
166
|
+
}));
|
|
167
|
+
function resumeFailover() {
|
|
168
|
+
return _resumeFailover.apply(this, arguments);
|
|
169
|
+
}
|
|
170
|
+
return resumeFailover;
|
|
171
|
+
}()
|
|
172
|
+
}, {
|
|
173
|
+
key: "getActiveMobiusUrl",
|
|
174
|
+
value: function getActiveMobiusUrl() {
|
|
175
|
+
return this.activeMobiusUrl;
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "setActiveMobiusUrl",
|
|
179
|
+
value: function setActiveMobiusUrl(url) {
|
|
180
|
+
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " with ").concat(url), {
|
|
181
|
+
method: _constants2.METHODS.UPDATE_ACTIVE_MOBIUS,
|
|
182
|
+
file: _constants2.REGISTRATION_FILE
|
|
183
|
+
});
|
|
184
|
+
this.activeMobiusUrl = url;
|
|
185
|
+
this.callManager.updateActiveMobius(url);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Populate deviceInfo using a devices response body.
|
|
190
|
+
*/
|
|
191
|
+
}, {
|
|
192
|
+
key: "setDeviceInfo",
|
|
193
|
+
value: function setDeviceInfo(devicesInfo) {
|
|
194
|
+
var _devicesInfo$devices = (0, _slicedToArray2.default)(devicesInfo.devices, 1),
|
|
195
|
+
device = _devicesInfo$devices[0];
|
|
196
|
+
this.deviceInfo = {
|
|
197
|
+
userId: devicesInfo.userId,
|
|
198
|
+
device: device,
|
|
199
|
+
devices: devicesInfo.devices
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: "setMobiusServers",
|
|
204
|
+
value: function setMobiusServers(primaryMobiusUris, backupMobiusUris) {
|
|
205
|
+
_Logger.default.log(_constants.METHOD_START_MESSAGE, {
|
|
206
|
+
method: _constants2.METHODS.SET_MOBIUS_SERVERS,
|
|
207
|
+
file: _constants2.REGISTRATION_FILE
|
|
208
|
+
});
|
|
209
|
+
this.primaryMobiusUris = primaryMobiusUris;
|
|
210
|
+
this.backupMobiusUris = backupMobiusUris;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Implementation of delete device.
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
}, {
|
|
218
|
+
key: "deleteRegistration",
|
|
219
|
+
value: (function () {
|
|
220
|
+
var _deleteRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(url, deviceId, deviceUrl) {
|
|
221
|
+
var _response;
|
|
222
|
+
var response, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
223
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
224
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
_context2.prev = 0;
|
|
227
|
+
_t2 = fetch;
|
|
228
|
+
_t3 = "".concat(url).concat(_constants2.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId);
|
|
229
|
+
_t4 = _types2.HTTP_METHODS.DELETE;
|
|
230
|
+
_t5 = _defineProperty2.default;
|
|
231
|
+
_t6 = _defineProperty2.default;
|
|
232
|
+
_t7 = _defineProperty2.default;
|
|
233
|
+
_t8 = (0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl);
|
|
234
|
+
_context2.next = 1;
|
|
235
|
+
return this.webex.credentials.getUserToken();
|
|
236
|
+
case 1:
|
|
237
|
+
_t9 = _t5(_t6(_t7(_t8, "Authorization", _context2.sent), "trackingId", "".concat(_constants2.WEBEX_WEB_CLIENT, "_").concat((0, _uuid.v4)())), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT);
|
|
238
|
+
_context2.next = 2;
|
|
239
|
+
return _t2(_t3, {
|
|
240
|
+
method: _t4,
|
|
241
|
+
headers: _t9
|
|
242
|
+
});
|
|
243
|
+
case 2:
|
|
244
|
+
response = _context2.sent;
|
|
245
|
+
_context2.next = 4;
|
|
246
|
+
break;
|
|
247
|
+
case 3:
|
|
248
|
+
_context2.prev = 3;
|
|
249
|
+
_t0 = _context2["catch"](0);
|
|
250
|
+
_Logger.default.warn("Delete failed with Mobius: ".concat((0, _stringify.default)(_t0)), {
|
|
251
|
+
file: _constants2.REGISTRATION_FILE,
|
|
252
|
+
method: _constants2.METHODS.DELETE_REGISTRATION
|
|
253
|
+
});
|
|
254
|
+
_context2.next = 4;
|
|
255
|
+
return (0, _common.uploadLogs)();
|
|
256
|
+
case 4:
|
|
257
|
+
this.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
258
|
+
this.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
259
|
+
return _context2.abrupt("return", (_response = response) === null || _response === void 0 ? void 0 : _response.json());
|
|
260
|
+
case 5:
|
|
261
|
+
case "end":
|
|
262
|
+
return _context2.stop();
|
|
263
|
+
}
|
|
264
|
+
}, _callee2, this, [[0, 3]]);
|
|
265
|
+
}));
|
|
266
|
+
function deleteRegistration(_x, _x2, _x3) {
|
|
267
|
+
return _deleteRegistration.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
return deleteRegistration;
|
|
270
|
+
}()
|
|
271
|
+
/**
|
|
272
|
+
* Implementation of POST request for device registration.
|
|
273
|
+
*
|
|
274
|
+
*/
|
|
275
|
+
)
|
|
276
|
+
}, {
|
|
277
|
+
key: "postRegistration",
|
|
278
|
+
value: (function () {
|
|
279
|
+
var _postRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
|
|
280
|
+
var deviceInfo;
|
|
281
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
282
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
283
|
+
case 0:
|
|
284
|
+
deviceInfo = {
|
|
285
|
+
userId: this.userId,
|
|
286
|
+
clientDeviceUri: this.webex.internal.device.url,
|
|
287
|
+
serviceData: this.jwe ? _objectSpread(_objectSpread({}, this.serviceData), {}, {
|
|
288
|
+
jwe: this.jwe
|
|
289
|
+
}) : this.serviceData
|
|
290
|
+
};
|
|
291
|
+
return _context3.abrupt("return", this.webex.request({
|
|
292
|
+
uri: "".concat(url, "device"),
|
|
293
|
+
method: _types2.HTTP_METHODS.POST,
|
|
294
|
+
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceInfo.clientDeviceUri), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
|
|
295
|
+
body: deviceInfo,
|
|
296
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS
|
|
297
|
+
}));
|
|
298
|
+
case 1:
|
|
299
|
+
case "end":
|
|
300
|
+
return _context3.stop();
|
|
301
|
+
}
|
|
302
|
+
}, _callee3, this);
|
|
303
|
+
}));
|
|
304
|
+
function postRegistration(_x4) {
|
|
305
|
+
return _postRegistration.apply(this, arguments);
|
|
306
|
+
}
|
|
307
|
+
return postRegistration;
|
|
308
|
+
}()
|
|
309
|
+
/**
|
|
310
|
+
* Re-attempts registration with the mobius url it was last registered
|
|
311
|
+
* to, that mobius url is expected to be updated already in this.activeMobiusUrl.
|
|
312
|
+
*/
|
|
313
|
+
)
|
|
314
|
+
}, {
|
|
315
|
+
key: "restorePreviousRegistration",
|
|
316
|
+
value: (function () {
|
|
317
|
+
var _restorePreviousRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(caller) {
|
|
318
|
+
var _this = this;
|
|
319
|
+
var abort;
|
|
320
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
321
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
322
|
+
case 0:
|
|
323
|
+
abort = false;
|
|
324
|
+
if (!this.activeMobiusUrl) {
|
|
325
|
+
_context5.next = 6;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
_context5.next = 1;
|
|
329
|
+
return this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
|
|
330
|
+
case 1:
|
|
331
|
+
abort = _context5.sent;
|
|
332
|
+
if (!this.retryAfter) {
|
|
333
|
+
_context5.next = 6;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
if (!(this.retryAfter < _constants2.RETRY_TIMER_UPPER_LIMIT)) {
|
|
337
|
+
_context5.next = 2;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
// If retry-after is less than threshold, honor it and schedule retry
|
|
341
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
342
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
343
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
344
|
+
case 0:
|
|
345
|
+
_context4.next = 1;
|
|
346
|
+
return _this.restartRegistration(caller);
|
|
347
|
+
case 1:
|
|
348
|
+
case "end":
|
|
349
|
+
return _context4.stop();
|
|
350
|
+
}
|
|
351
|
+
}, _callee4);
|
|
352
|
+
})), this.retryAfter * 1000);
|
|
353
|
+
_context5.next = 5;
|
|
354
|
+
break;
|
|
355
|
+
case 2:
|
|
356
|
+
if (!(this.primaryMobiusUris.includes(this.activeMobiusUrl) && this.backupMobiusUris.length > 0)) {
|
|
357
|
+
_context5.next = 4;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
_context5.next = 3;
|
|
361
|
+
return this.attemptRegistrationWithServers(caller, this.backupMobiusUris);
|
|
362
|
+
case 3:
|
|
363
|
+
abort = _context5.sent;
|
|
364
|
+
_context5.next = 5;
|
|
365
|
+
break;
|
|
366
|
+
case 4:
|
|
367
|
+
// If we are using backup and got 429, restart registration
|
|
368
|
+
this.restartRegistration(caller);
|
|
369
|
+
case 5:
|
|
370
|
+
this.retryAfter = undefined;
|
|
371
|
+
return _context5.abrupt("return", true);
|
|
372
|
+
case 6:
|
|
373
|
+
return _context5.abrupt("return", abort);
|
|
374
|
+
case 7:
|
|
375
|
+
case "end":
|
|
376
|
+
return _context5.stop();
|
|
377
|
+
}
|
|
378
|
+
}, _callee5, this);
|
|
379
|
+
}));
|
|
380
|
+
function restorePreviousRegistration(_x5) {
|
|
381
|
+
return _restorePreviousRegistration.apply(this, arguments);
|
|
382
|
+
}
|
|
383
|
+
return restorePreviousRegistration;
|
|
384
|
+
}()
|
|
385
|
+
/**
|
|
386
|
+
* Callback for handling 404 response from the server for register keepalive
|
|
387
|
+
*/
|
|
388
|
+
)
|
|
389
|
+
}, {
|
|
390
|
+
key: "handle404KeepaliveFailure",
|
|
391
|
+
value: (function () {
|
|
392
|
+
var _handle404KeepaliveFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(caller) {
|
|
393
|
+
var abort;
|
|
394
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
395
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
396
|
+
case 0:
|
|
397
|
+
if (!(caller === _constants2.KEEPALIVE_UTIL)) {
|
|
398
|
+
_context6.next = 2;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
_context6.next = 1;
|
|
402
|
+
return this.attemptRegistrationWithServers(caller);
|
|
403
|
+
case 1:
|
|
404
|
+
abort = _context6.sent;
|
|
405
|
+
if (!(!abort && !this.isDeviceRegistered())) {
|
|
406
|
+
_context6.next = 2;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
_context6.next = 2;
|
|
410
|
+
return this.startFailoverTimer();
|
|
411
|
+
case 2:
|
|
412
|
+
case "end":
|
|
413
|
+
return _context6.stop();
|
|
414
|
+
}
|
|
415
|
+
}, _callee6, this);
|
|
416
|
+
}));
|
|
417
|
+
function handle404KeepaliveFailure(_x6) {
|
|
418
|
+
return _handle404KeepaliveFailure.apply(this, arguments);
|
|
419
|
+
}
|
|
420
|
+
return handle404KeepaliveFailure;
|
|
421
|
+
}()
|
|
422
|
+
/**
|
|
423
|
+
* Callback for handling 429 retry response from the server
|
|
424
|
+
*/
|
|
425
|
+
)
|
|
426
|
+
}, {
|
|
427
|
+
key: "handle429Retry",
|
|
428
|
+
value: (function () {
|
|
429
|
+
var _handle429Retry = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8(retryAfter, caller) {
|
|
430
|
+
var _this2 = this;
|
|
431
|
+
var interval, abort;
|
|
432
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
433
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
434
|
+
case 0:
|
|
435
|
+
if (!(caller === _constants2.FAILBACK_UTIL)) {
|
|
436
|
+
_context8.next = 4;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
if (!(this.failback429RetryAttempts >= _constants2.REG_FAILBACK_429_MAX_RETRIES)) {
|
|
440
|
+
_context8.next = 1;
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
return _context8.abrupt("return");
|
|
444
|
+
case 1:
|
|
445
|
+
this.clearFailbackTimer();
|
|
446
|
+
this.failback429RetryAttempts += 1;
|
|
447
|
+
_Logger.default.log("Received 429 while rehoming, 429 retry count : ".concat(this.failback429RetryAttempts), {
|
|
448
|
+
file: _constants2.REGISTRATION_FILE,
|
|
449
|
+
method: _constants2.REG_429_RETRY_UTIL
|
|
450
|
+
});
|
|
451
|
+
interval = this.getRegRetryInterval(this.failback429RetryAttempts);
|
|
452
|
+
this.startFailbackTimer(interval);
|
|
453
|
+
this.scheduled429Retry = true;
|
|
454
|
+
_context8.next = 2;
|
|
455
|
+
return this.restorePreviousRegistration(_constants2.REG_429_RETRY_UTIL);
|
|
456
|
+
case 2:
|
|
457
|
+
abort = _context8.sent;
|
|
458
|
+
if (!(!abort && !this.isDeviceRegistered())) {
|
|
459
|
+
_context8.next = 3;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
_context8.next = 3;
|
|
463
|
+
return this.restartRegistration(_constants2.REG_429_RETRY_UTIL);
|
|
464
|
+
case 3:
|
|
465
|
+
_context8.next = 5;
|
|
466
|
+
break;
|
|
467
|
+
case 4:
|
|
468
|
+
if (caller === _constants2.KEEPALIVE_UTIL) {
|
|
469
|
+
this.clearKeepaliveTimer();
|
|
470
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
471
|
+
var _this2$deviceInfo$dev;
|
|
472
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
473
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
474
|
+
case 0:
|
|
475
|
+
_Logger.default.log("Resuming keepalive after ".concat(retryAfter, " seconds"), {
|
|
476
|
+
file: _constants2.REGISTRATION_FILE,
|
|
477
|
+
method: _constants2.REG_429_RETRY_UTIL
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// Resume the keepalive after waiting for the retry after period
|
|
481
|
+
_context7.next = 1;
|
|
482
|
+
return _this2.startKeepaliveTimer((_this2$deviceInfo$dev = _this2.deviceInfo.device) === null || _this2$deviceInfo$dev === void 0 ? void 0 : _this2$deviceInfo$dev.uri, _this2.deviceInfo.keepaliveInterval, 'UNKNOWN');
|
|
483
|
+
case 1:
|
|
484
|
+
case "end":
|
|
485
|
+
return _context7.stop();
|
|
486
|
+
}
|
|
487
|
+
}, _callee7);
|
|
488
|
+
})), retryAfter * 1000);
|
|
489
|
+
} else {
|
|
490
|
+
this.retryAfter = retryAfter;
|
|
491
|
+
}
|
|
492
|
+
case 5:
|
|
493
|
+
case "end":
|
|
494
|
+
return _context8.stop();
|
|
495
|
+
}
|
|
496
|
+
}, _callee8, this);
|
|
497
|
+
}));
|
|
498
|
+
function handle429Retry(_x7, _x8) {
|
|
499
|
+
return _handle429Retry.apply(this, arguments);
|
|
500
|
+
}
|
|
501
|
+
return handle429Retry;
|
|
502
|
+
}()
|
|
503
|
+
/**
|
|
504
|
+
* Calculates and returns a random interval value using input argument
|
|
505
|
+
* attempt as the variable factor.
|
|
506
|
+
*
|
|
507
|
+
* attempted already.
|
|
508
|
+
*/
|
|
509
|
+
)
|
|
510
|
+
}, {
|
|
511
|
+
key: "getRegRetryInterval",
|
|
512
|
+
value: function getRegRetryInterval() {
|
|
513
|
+
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
514
|
+
return _constants2.BASE_REG_RETRY_TIMER_VAL_IN_SEC + Math.pow(_constants2.BASE_REG_TIMER_MFACTOR, attempt) + Math.floor((Math.random() * (_constants2.REG_RANDOM_T_FACTOR_UPPER_LIMIT - _constants2.SEC_TO_MSEC_MFACTOR + 1) + _constants2.SEC_TO_MSEC_MFACTOR) / _constants2.SEC_TO_MSEC_MFACTOR);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Schedules registration retry with primary mobius servers at a random
|
|
519
|
+
* interval calculated based on the number of times registration retry is already done
|
|
520
|
+
* Once the time taken since the beginning of retry attempt exceeds the
|
|
521
|
+
* retry threshold, it switches over to backup mobius servers.
|
|
522
|
+
*
|
|
523
|
+
*/
|
|
524
|
+
}, {
|
|
525
|
+
key: "startFailoverTimer",
|
|
526
|
+
value: (function () {
|
|
527
|
+
var _startFailoverTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
528
|
+
var _this3 = this;
|
|
529
|
+
var attempt,
|
|
530
|
+
timeElapsed,
|
|
531
|
+
loggerContext,
|
|
532
|
+
interval,
|
|
533
|
+
TIMER_THRESHOLD,
|
|
534
|
+
excessVal,
|
|
535
|
+
abort,
|
|
536
|
+
scheduledTime,
|
|
537
|
+
_args11 = arguments;
|
|
538
|
+
return _regenerator.default.wrap(function (_context11) {
|
|
539
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
540
|
+
case 0:
|
|
541
|
+
attempt = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : 1;
|
|
542
|
+
timeElapsed = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 0;
|
|
543
|
+
loggerContext = {
|
|
544
|
+
file: _constants2.REGISTRATION_FILE,
|
|
545
|
+
method: _constants2.FAILOVER_UTIL
|
|
546
|
+
};
|
|
547
|
+
interval = this.getRegRetryInterval(attempt);
|
|
548
|
+
TIMER_THRESHOLD = _constants2.REG_TRY_BACKUP_TIMER_VAL_IN_SEC;
|
|
549
|
+
if (timeElapsed + interval > TIMER_THRESHOLD) {
|
|
550
|
+
excessVal = timeElapsed + interval - TIMER_THRESHOLD;
|
|
551
|
+
interval -= excessVal;
|
|
552
|
+
}
|
|
553
|
+
if (this.retryAfter != null && interval < this.retryAfter) {
|
|
554
|
+
this.failoverImmediately = this.retryAfter + timeElapsed > TIMER_THRESHOLD;
|
|
555
|
+
}
|
|
556
|
+
if (!(interval > _constants2.BASE_REG_RETRY_TIMER_VAL_IN_SEC && !this.failoverImmediately)) {
|
|
557
|
+
_context11.next = 1;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
scheduledTime = Math.floor((0, _now.default)() / 1000);
|
|
561
|
+
if (this.retryAfter != null) {
|
|
562
|
+
interval = Math.max(interval, this.retryAfter);
|
|
563
|
+
}
|
|
564
|
+
this.saveFailoverState({
|
|
565
|
+
attempt: attempt,
|
|
566
|
+
timeElapsed: timeElapsed,
|
|
567
|
+
retryScheduledTime: scheduledTime,
|
|
568
|
+
serverType: 'primary'
|
|
569
|
+
});
|
|
570
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
571
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
572
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
573
|
+
case 0:
|
|
574
|
+
_context0.next = 1;
|
|
575
|
+
return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
576
|
+
var currentTime;
|
|
577
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
578
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
579
|
+
case 0:
|
|
580
|
+
_context9.next = 1;
|
|
581
|
+
return _this3.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL);
|
|
582
|
+
case 1:
|
|
583
|
+
abort = _context9.sent;
|
|
584
|
+
currentTime = Math.floor((0, _now.default)() / 1000);
|
|
585
|
+
if (!(!abort && !_this3.isDeviceRegistered())) {
|
|
586
|
+
_context9.next = 2;
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
589
|
+
_context9.next = 2;
|
|
590
|
+
return _this3.startFailoverTimer(attempt + 1, timeElapsed + (currentTime - scheduledTime));
|
|
591
|
+
case 2:
|
|
592
|
+
case "end":
|
|
593
|
+
return _context9.stop();
|
|
594
|
+
}
|
|
595
|
+
}, _callee9);
|
|
596
|
+
})));
|
|
597
|
+
case 1:
|
|
598
|
+
case "end":
|
|
599
|
+
return _context0.stop();
|
|
600
|
+
}
|
|
601
|
+
}, _callee0);
|
|
602
|
+
})), interval * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
603
|
+
_Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
|
|
604
|
+
_context11.next = 5;
|
|
605
|
+
break;
|
|
606
|
+
case 1:
|
|
607
|
+
if (!this.backupMobiusUris.length) {
|
|
608
|
+
_context11.next = 3;
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
this.saveFailoverState({
|
|
612
|
+
attempt: attempt,
|
|
613
|
+
timeElapsed: timeElapsed,
|
|
614
|
+
retryScheduledTime: Math.floor((0, _now.default)() / 1000),
|
|
615
|
+
serverType: 'backup'
|
|
616
|
+
});
|
|
617
|
+
_Logger.default.info('Failing over to backup servers.', loggerContext);
|
|
618
|
+
this.failoverImmediately = false;
|
|
619
|
+
_context11.next = 2;
|
|
620
|
+
return this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, this.backupMobiusUris);
|
|
621
|
+
case 2:
|
|
622
|
+
abort = _context11.sent;
|
|
623
|
+
if (!abort && !this.isDeviceRegistered()) {
|
|
624
|
+
interval = this.getRegRetryInterval();
|
|
625
|
+
if (this.retryAfter != null && this.retryAfter < _constants2.RETRY_TIMER_UPPER_LIMIT) {
|
|
626
|
+
interval = interval < this.retryAfter ? this.retryAfter : interval;
|
|
627
|
+
}
|
|
628
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
629
|
+
return _regenerator.default.wrap(function (_context10) {
|
|
630
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
631
|
+
case 0:
|
|
632
|
+
_context10.next = 1;
|
|
633
|
+
return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
634
|
+
return _regenerator.default.wrap(function (_context1) {
|
|
635
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
636
|
+
case 0:
|
|
637
|
+
_context1.next = 1;
|
|
638
|
+
return _this3.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, _this3.backupMobiusUris);
|
|
639
|
+
case 1:
|
|
640
|
+
abort = _context1.sent;
|
|
641
|
+
if (!(!abort && !_this3.isDeviceRegistered())) {
|
|
642
|
+
_context1.next = 3;
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
_context1.next = 2;
|
|
646
|
+
return (0, _common.uploadLogs)();
|
|
647
|
+
case 2:
|
|
648
|
+
(0, _common.emitFinalFailure)(function (clientError) {
|
|
649
|
+
_this3.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
650
|
+
}, loggerContext);
|
|
651
|
+
case 3:
|
|
652
|
+
case "end":
|
|
653
|
+
return _context1.stop();
|
|
654
|
+
}
|
|
655
|
+
}, _callee1);
|
|
656
|
+
})));
|
|
657
|
+
case 1:
|
|
658
|
+
case "end":
|
|
659
|
+
return _context10.stop();
|
|
660
|
+
}
|
|
661
|
+
}, _callee10);
|
|
662
|
+
})), interval * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
663
|
+
_Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
|
|
664
|
+
}
|
|
665
|
+
_context11.next = 5;
|
|
666
|
+
break;
|
|
667
|
+
case 3:
|
|
668
|
+
_context11.next = 4;
|
|
669
|
+
return (0, _common.uploadLogs)();
|
|
670
|
+
case 4:
|
|
671
|
+
(0, _common.emitFinalFailure)(function (clientError) {
|
|
672
|
+
_this3.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
673
|
+
}, loggerContext);
|
|
674
|
+
case 5:
|
|
675
|
+
case "end":
|
|
676
|
+
return _context11.stop();
|
|
677
|
+
}
|
|
678
|
+
}, _callee11, this);
|
|
679
|
+
}));
|
|
680
|
+
function startFailoverTimer() {
|
|
681
|
+
return _startFailoverTimer.apply(this, arguments);
|
|
682
|
+
}
|
|
683
|
+
return startFailoverTimer;
|
|
684
|
+
}()
|
|
685
|
+
/**
|
|
686
|
+
* Clears the failback timer if running.
|
|
687
|
+
*/
|
|
688
|
+
)
|
|
689
|
+
}, {
|
|
690
|
+
key: "clearFailbackTimer",
|
|
691
|
+
value: function clearFailbackTimer() {
|
|
692
|
+
if (this.failbackTimer) {
|
|
693
|
+
clearTimeout(this.failbackTimer);
|
|
694
|
+
this.failbackTimer = undefined;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}, {
|
|
698
|
+
key: "isPrimaryActive",
|
|
699
|
+
value: function () {
|
|
700
|
+
var _isPrimaryActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
701
|
+
var status, _iterator, _step, mobiusUrl, baseUri, response, _ref7, statusCode, _t1, _t10;
|
|
702
|
+
return _regenerator.default.wrap(function (_context12) {
|
|
703
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
704
|
+
case 0:
|
|
705
|
+
_iterator = _createForOfIteratorHelper(this.primaryMobiusUris);
|
|
706
|
+
_context12.prev = 1;
|
|
707
|
+
_iterator.s();
|
|
708
|
+
case 2:
|
|
709
|
+
if ((_step = _iterator.n()).done) {
|
|
710
|
+
_context12.next = 8;
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
mobiusUrl = _step.value;
|
|
714
|
+
_context12.prev = 3;
|
|
715
|
+
baseUri = mobiusUrl.replace(_constants2.URL_ENDPOINT, '/'); // eslint-disable-next-line no-await-in-loop
|
|
716
|
+
_context12.next = 4;
|
|
717
|
+
return this.webex.request({
|
|
718
|
+
uri: "".concat(baseUri, "ping"),
|
|
719
|
+
method: _types2.HTTP_METHODS.GET,
|
|
720
|
+
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, this.webex.internal.device.url), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
|
|
721
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS
|
|
722
|
+
});
|
|
723
|
+
case 4:
|
|
724
|
+
response = _context12.sent;
|
|
725
|
+
_ref7 = response, statusCode = _ref7.statusCode;
|
|
726
|
+
if (!(statusCode === 200)) {
|
|
727
|
+
_context12.next = 5;
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
_Logger.default.info("Ping successful for primary Mobius: ".concat(mobiusUrl), {
|
|
731
|
+
file: _constants2.REGISTRATION_FILE,
|
|
732
|
+
method: _constants2.FAILBACK_UTIL
|
|
733
|
+
});
|
|
734
|
+
status = 'up';
|
|
735
|
+
return _context12.abrupt("continue", 8);
|
|
736
|
+
case 5:
|
|
737
|
+
_context12.next = 7;
|
|
738
|
+
break;
|
|
739
|
+
case 6:
|
|
740
|
+
_context12.prev = 6;
|
|
741
|
+
_t1 = _context12["catch"](3);
|
|
742
|
+
_Logger.default.warn("Ping failed for primary Mobius: ".concat(mobiusUrl, " with error: ").concat((0, _stringify.default)(_t1)), {
|
|
743
|
+
file: _constants2.REGISTRATION_FILE,
|
|
744
|
+
method: _constants2.FAILBACK_UTIL
|
|
745
|
+
});
|
|
746
|
+
status = 'down';
|
|
747
|
+
case 7:
|
|
748
|
+
_context12.next = 2;
|
|
749
|
+
break;
|
|
750
|
+
case 8:
|
|
751
|
+
_context12.next = 10;
|
|
752
|
+
break;
|
|
753
|
+
case 9:
|
|
754
|
+
_context12.prev = 9;
|
|
755
|
+
_t10 = _context12["catch"](1);
|
|
756
|
+
_iterator.e(_t10);
|
|
757
|
+
case 10:
|
|
758
|
+
_context12.prev = 10;
|
|
759
|
+
_iterator.f();
|
|
760
|
+
return _context12.finish(10);
|
|
761
|
+
case 11:
|
|
762
|
+
return _context12.abrupt("return", status === 'up');
|
|
763
|
+
case 12:
|
|
764
|
+
case "end":
|
|
765
|
+
return _context12.stop();
|
|
766
|
+
}
|
|
767
|
+
}, _callee12, this, [[1, 9, 10, 11], [3, 6]]);
|
|
768
|
+
}));
|
|
769
|
+
function isPrimaryActive() {
|
|
770
|
+
return _isPrimaryActive.apply(this, arguments);
|
|
771
|
+
}
|
|
772
|
+
return isPrimaryActive;
|
|
773
|
+
}()
|
|
774
|
+
/**
|
|
775
|
+
* Returns true if device is registered with a backup mobius.
|
|
776
|
+
*/
|
|
777
|
+
}, {
|
|
778
|
+
key: "isFailbackRequired",
|
|
779
|
+
value: function isFailbackRequired() {
|
|
780
|
+
return this.isDeviceRegistered() && this.primaryMobiusUris.indexOf(this.activeMobiusUrl) === -1;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Calculates and returns a random value between rehomingIntervalMin and
|
|
785
|
+
* rehomingIntervalMax.
|
|
786
|
+
*/
|
|
787
|
+
}, {
|
|
788
|
+
key: "getFailbackInterval",
|
|
789
|
+
value: function getFailbackInterval() {
|
|
790
|
+
return Math.floor(Math.random() * (this.rehomingIntervalMax - this.rehomingIntervalMin + 1) + this.rehomingIntervalMin);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Starts failback timer to move to primary mobius if device
|
|
795
|
+
* is registered with a backup mobius.
|
|
796
|
+
*/
|
|
797
|
+
}, {
|
|
798
|
+
key: "initiateFailback",
|
|
799
|
+
value: function initiateFailback() {
|
|
800
|
+
if (this.isFailbackRequired()) {
|
|
801
|
+
if (!this.failbackTimer) {
|
|
802
|
+
this.failback429RetryAttempts = 0;
|
|
803
|
+
var intervalInMinutes = this.getFailbackInterval();
|
|
804
|
+
this.startFailbackTimer(intervalInMinutes * _constants2.MINUTES_TO_SEC_MFACTOR);
|
|
805
|
+
}
|
|
806
|
+
} else {
|
|
807
|
+
this.failback429RetryAttempts = 0;
|
|
808
|
+
this.clearFailbackTimer();
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Starts failback timer with the interval value received.
|
|
814
|
+
*
|
|
815
|
+
*/
|
|
816
|
+
}, {
|
|
817
|
+
key: "startFailbackTimer",
|
|
818
|
+
value: function startFailbackTimer(intervalInSeconds) {
|
|
819
|
+
var _this4 = this;
|
|
820
|
+
this.failbackTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
821
|
+
return _regenerator.default.wrap(function (_context13) {
|
|
822
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
823
|
+
case 0:
|
|
824
|
+
return _context13.abrupt("return", _this4.executeFailback());
|
|
825
|
+
case 1:
|
|
826
|
+
case "end":
|
|
827
|
+
return _context13.stop();
|
|
828
|
+
}
|
|
829
|
+
}, _callee13);
|
|
830
|
+
})), intervalInSeconds * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
831
|
+
_Logger.default.log("Failback scheduled after ".concat(intervalInSeconds, " seconds."), {
|
|
832
|
+
file: _constants2.REGISTRATION_FILE,
|
|
833
|
+
method: this.startFailbackTimer.name
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Core logic for the failback processing, scheduled and executed
|
|
839
|
+
* at failback timer expiry.
|
|
840
|
+
*/
|
|
841
|
+
}, {
|
|
842
|
+
key: "executeFailback",
|
|
843
|
+
value: (function () {
|
|
844
|
+
var _executeFailback = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
845
|
+
var _this5 = this;
|
|
846
|
+
return _regenerator.default.wrap(function (_context15) {
|
|
847
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
848
|
+
case 0:
|
|
849
|
+
_context15.next = 1;
|
|
850
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
851
|
+
var primaryServerStatus, abort, abortNew;
|
|
852
|
+
return _regenerator.default.wrap(function (_context14) {
|
|
853
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
854
|
+
case 0:
|
|
855
|
+
if (!_this5.isFailbackRequired()) {
|
|
856
|
+
_context14.next = 11;
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
_context14.next = 1;
|
|
860
|
+
return _this5.isPrimaryActive();
|
|
861
|
+
case 1:
|
|
862
|
+
primaryServerStatus = _context14.sent;
|
|
863
|
+
if (!((0, _keys.default)(_this5.callManager.getActiveCalls()).length === 0 && primaryServerStatus)) {
|
|
864
|
+
_context14.next = 10;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
_Logger.default.info("Attempting failback to primary.", {
|
|
868
|
+
file: _constants2.REGISTRATION_FILE,
|
|
869
|
+
method: _this5.executeFailback.name
|
|
870
|
+
});
|
|
871
|
+
_context14.next = 2;
|
|
872
|
+
return _this5.deregister();
|
|
873
|
+
case 2:
|
|
874
|
+
_context14.next = 3;
|
|
875
|
+
return _this5.attemptRegistrationWithServers(_constants2.FAILBACK_UTIL);
|
|
876
|
+
case 3:
|
|
877
|
+
abort = _context14.sent;
|
|
878
|
+
if (!(_this5.scheduled429Retry || abort || _this5.isDeviceRegistered())) {
|
|
879
|
+
_context14.next = 4;
|
|
880
|
+
break;
|
|
881
|
+
}
|
|
882
|
+
return _context14.abrupt("return");
|
|
883
|
+
case 4:
|
|
884
|
+
_context14.next = 5;
|
|
885
|
+
return _this5.restorePreviousRegistration(_constants2.FAILBACK_UTIL);
|
|
886
|
+
case 5:
|
|
887
|
+
abortNew = _context14.sent;
|
|
888
|
+
if (!abortNew) {
|
|
889
|
+
_context14.next = 6;
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
_this5.clearFailbackTimer();
|
|
893
|
+
return _context14.abrupt("return");
|
|
894
|
+
case 6:
|
|
895
|
+
if (_this5.isDeviceRegistered()) {
|
|
896
|
+
_context14.next = 8;
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
_context14.next = 7;
|
|
900
|
+
return _this5.restartRegistration(_this5.executeFailback.name);
|
|
901
|
+
case 7:
|
|
902
|
+
_context14.next = 9;
|
|
903
|
+
break;
|
|
904
|
+
case 8:
|
|
905
|
+
_this5.failbackTimer = undefined;
|
|
906
|
+
_this5.initiateFailback();
|
|
907
|
+
case 9:
|
|
908
|
+
_context14.next = 11;
|
|
909
|
+
break;
|
|
910
|
+
case 10:
|
|
911
|
+
_Logger.default.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', {
|
|
912
|
+
file: _constants2.REGISTRATION_FILE,
|
|
913
|
+
method: _this5.executeFailback.name
|
|
914
|
+
});
|
|
915
|
+
_this5.failbackTimer = undefined;
|
|
916
|
+
_this5.initiateFailback();
|
|
917
|
+
case 11:
|
|
918
|
+
case "end":
|
|
919
|
+
return _context14.stop();
|
|
920
|
+
}
|
|
921
|
+
}, _callee14);
|
|
922
|
+
})));
|
|
923
|
+
case 1:
|
|
924
|
+
case "end":
|
|
925
|
+
return _context15.stop();
|
|
926
|
+
}
|
|
927
|
+
}, _callee15, this);
|
|
928
|
+
}));
|
|
929
|
+
function executeFailback() {
|
|
930
|
+
return _executeFailback.apply(this, arguments);
|
|
931
|
+
}
|
|
932
|
+
return executeFailback;
|
|
933
|
+
}()
|
|
934
|
+
/**
|
|
935
|
+
* Updates rehomingIntervalMin and rehomingIntervalMax values
|
|
936
|
+
* if received in registration response from a primary mobius
|
|
937
|
+
* server.
|
|
938
|
+
*
|
|
939
|
+
*/
|
|
940
|
+
)
|
|
941
|
+
}, {
|
|
942
|
+
key: "setIntervalValues",
|
|
943
|
+
value: function setIntervalValues(deviceInfo) {
|
|
944
|
+
if (this.primaryMobiusUris.indexOf(this.activeMobiusUrl) !== -1) {
|
|
945
|
+
this.rehomingIntervalMin = deviceInfo !== null && deviceInfo !== void 0 && deviceInfo.rehomingIntervalMin ? deviceInfo.rehomingIntervalMin : _constants2.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
946
|
+
this.rehomingIntervalMax = deviceInfo !== null && deviceInfo !== void 0 && deviceInfo.rehomingIntervalMax ? deviceInfo.rehomingIntervalMax : _constants2.DEFAULT_REHOMING_INTERVAL_MAX;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Retrieves information about the device as {@link IDeviceInfo}.
|
|
952
|
+
*
|
|
953
|
+
*/
|
|
954
|
+
}, {
|
|
955
|
+
key: "getDeviceInfo",
|
|
956
|
+
value: function getDeviceInfo() {
|
|
957
|
+
return this.deviceInfo;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Checks if the device is currently registered.
|
|
962
|
+
*
|
|
963
|
+
* by checking if isRegistered state is set to
|
|
964
|
+
* ACTIVE, else false.
|
|
965
|
+
*/
|
|
966
|
+
}, {
|
|
967
|
+
key: "isDeviceRegistered",
|
|
968
|
+
value: function isDeviceRegistered() {
|
|
969
|
+
return this.registrationStatus === _types2.RegistrationStatus.ACTIVE;
|
|
970
|
+
}
|
|
971
|
+
}, {
|
|
972
|
+
key: "getStatus",
|
|
973
|
+
value: function getStatus() {
|
|
974
|
+
return this.registrationStatus;
|
|
975
|
+
}
|
|
976
|
+
}, {
|
|
977
|
+
key: "setStatus",
|
|
978
|
+
value: function setStatus(value) {
|
|
979
|
+
this.registrationStatus = value;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Start fresh registration cycle with the mobius
|
|
984
|
+
* server list already present.
|
|
985
|
+
*
|
|
986
|
+
*/
|
|
987
|
+
}, {
|
|
988
|
+
key: "restartRegistration",
|
|
989
|
+
value: (function () {
|
|
990
|
+
var _restartRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16(caller) {
|
|
991
|
+
var abort;
|
|
992
|
+
return _regenerator.default.wrap(function (_context16) {
|
|
993
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
994
|
+
case 0:
|
|
995
|
+
/*
|
|
996
|
+
* Cancel any failback timer running
|
|
997
|
+
* and start fresh registration attempt with retry as true.
|
|
998
|
+
*/
|
|
999
|
+
this.clearFailbackTimer();
|
|
1000
|
+
this.failback429RetryAttempts = 0;
|
|
1001
|
+
_context16.next = 1;
|
|
1002
|
+
return this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
|
|
1003
|
+
case 1:
|
|
1004
|
+
abort = _context16.sent;
|
|
1005
|
+
if (!(!abort && !this.isDeviceRegistered())) {
|
|
1006
|
+
_context16.next = 2;
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
_context16.next = 2;
|
|
1010
|
+
return this.startFailoverTimer();
|
|
1011
|
+
case 2:
|
|
1012
|
+
case "end":
|
|
1013
|
+
return _context16.stop();
|
|
1014
|
+
}
|
|
1015
|
+
}, _callee16, this);
|
|
1016
|
+
}));
|
|
1017
|
+
function restartRegistration(_x9) {
|
|
1018
|
+
return _restartRegistration.apply(this, arguments);
|
|
1019
|
+
}
|
|
1020
|
+
return restartRegistration;
|
|
1021
|
+
}()
|
|
1022
|
+
/**
|
|
1023
|
+
* Restores the connection and attempts refreshing existing registration with server.
|
|
1024
|
+
* Allows retry if not restored in the first attempt.
|
|
1025
|
+
*
|
|
1026
|
+
*/
|
|
1027
|
+
)
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "handleConnectionRestoration",
|
|
1030
|
+
value: (function () {
|
|
1031
|
+
var _handleConnectionRestoration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18(retry) {
|
|
1032
|
+
var _this6 = this;
|
|
1033
|
+
return _regenerator.default.wrap(function (_context18) {
|
|
1034
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1035
|
+
case 0:
|
|
1036
|
+
_Logger.default.info(_constants.METHOD_START_MESSAGE, {
|
|
1037
|
+
method: _constants2.METHODS.HANDLE_CONNECTION_RESTORATION,
|
|
1038
|
+
file: _constants2.REGISTRATION_FILE
|
|
1039
|
+
});
|
|
1040
|
+
_context18.next = 1;
|
|
1041
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
1042
|
+
var abort;
|
|
1043
|
+
return _regenerator.default.wrap(function (_context17) {
|
|
1044
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1045
|
+
case 0:
|
|
1046
|
+
if (!retry) {
|
|
1047
|
+
_context17.next = 4;
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
_Logger.default.log('Network is up again, re-registering with Webex Calling if needed', {
|
|
1051
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1052
|
+
method: _constants2.METHODS.HANDLE_CONNECTION_RESTORATION
|
|
1053
|
+
});
|
|
1054
|
+
_this6.clearKeepaliveTimer();
|
|
1055
|
+
if (!_this6.isDeviceRegistered()) {
|
|
1056
|
+
_context17.next = 1;
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
_context17.next = 1;
|
|
1060
|
+
return _this6.deregister();
|
|
1061
|
+
case 1:
|
|
1062
|
+
if (!_this6.activeMobiusUrl) {
|
|
1063
|
+
_context17.next = 3;
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
_context17.next = 2;
|
|
1067
|
+
return _this6.restorePreviousRegistration(_constants2.METHODS.HANDLE_CONNECTION_RESTORATION);
|
|
1068
|
+
case 2:
|
|
1069
|
+
abort = _context17.sent;
|
|
1070
|
+
if (!(!abort && !_this6.isDeviceRegistered())) {
|
|
1071
|
+
_context17.next = 3;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
_context17.next = 3;
|
|
1075
|
+
return _this6.restartRegistration(_constants2.METHODS.HANDLE_CONNECTION_RESTORATION);
|
|
1076
|
+
case 3:
|
|
1077
|
+
retry = false;
|
|
1078
|
+
case 4:
|
|
1079
|
+
case "end":
|
|
1080
|
+
return _context17.stop();
|
|
1081
|
+
}
|
|
1082
|
+
}, _callee17);
|
|
1083
|
+
})));
|
|
1084
|
+
case 1:
|
|
1085
|
+
return _context18.abrupt("return", retry);
|
|
1086
|
+
case 2:
|
|
1087
|
+
case "end":
|
|
1088
|
+
return _context18.stop();
|
|
1089
|
+
}
|
|
1090
|
+
}, _callee18, this);
|
|
1091
|
+
}));
|
|
1092
|
+
function handleConnectionRestoration(_x0) {
|
|
1093
|
+
return _handleConnectionRestoration.apply(this, arguments);
|
|
1094
|
+
}
|
|
1095
|
+
return handleConnectionRestoration;
|
|
1096
|
+
}()
|
|
1097
|
+
/**
|
|
1098
|
+
* Callback function for restoring registration in case of failure during initial registration
|
|
1099
|
+
* due to device registration already exists.
|
|
1100
|
+
*
|
|
1101
|
+
*/
|
|
1102
|
+
)
|
|
1103
|
+
}, {
|
|
1104
|
+
key: "restoreRegistrationCallBack",
|
|
1105
|
+
value: function restoreRegistrationCallBack() {
|
|
1106
|
+
var _this7 = this;
|
|
1107
|
+
return /*#__PURE__*/function () {
|
|
1108
|
+
var _ref1 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19(restoreData, caller) {
|
|
1109
|
+
var logContext, restore, finalError;
|
|
1110
|
+
return _regenerator.default.wrap(function (_context19) {
|
|
1111
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1112
|
+
case 0:
|
|
1113
|
+
logContext = {
|
|
1114
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1115
|
+
method: caller
|
|
1116
|
+
};
|
|
1117
|
+
if (_this7.isRegRetry()) {
|
|
1118
|
+
_context19.next = 4;
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
_Logger.default.info('Registration restoration in progress.', logContext);
|
|
1122
|
+
restore = _this7.getExistingDevice(restoreData);
|
|
1123
|
+
if (!restore) {
|
|
1124
|
+
_context19.next = 3;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
_this7.setRegRetry(true);
|
|
1128
|
+
_context19.next = 1;
|
|
1129
|
+
return _this7.deregister();
|
|
1130
|
+
case 1:
|
|
1131
|
+
_context19.next = 2;
|
|
1132
|
+
return _this7.restorePreviousRegistration(caller);
|
|
1133
|
+
case 2:
|
|
1134
|
+
finalError = _context19.sent;
|
|
1135
|
+
_this7.setRegRetry(false);
|
|
1136
|
+
if (_this7.isDeviceRegistered()) {
|
|
1137
|
+
_Logger.default.info('Registration restored successfully.', logContext);
|
|
1138
|
+
}
|
|
1139
|
+
return _context19.abrupt("return", finalError);
|
|
1140
|
+
case 3:
|
|
1141
|
+
_this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
1142
|
+
_context19.next = 5;
|
|
1143
|
+
break;
|
|
1144
|
+
case 4:
|
|
1145
|
+
_this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
1146
|
+
case 5:
|
|
1147
|
+
return _context19.abrupt("return", false);
|
|
1148
|
+
case 6:
|
|
1149
|
+
case "end":
|
|
1150
|
+
return _context19.stop();
|
|
1151
|
+
}
|
|
1152
|
+
}, _callee19);
|
|
1153
|
+
}));
|
|
1154
|
+
return function (_x1, _x10) {
|
|
1155
|
+
return _ref1.apply(this, arguments);
|
|
1156
|
+
};
|
|
1157
|
+
}();
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Triggers the registration with the given list of Mobius servers
|
|
1162
|
+
* Registration is attempted with primary and backup until it succeeds or the list is exhausted
|
|
1163
|
+
*/
|
|
1164
|
+
}, {
|
|
1165
|
+
key: "triggerRegistration",
|
|
1166
|
+
value: (function () {
|
|
1167
|
+
var _triggerRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
1168
|
+
var abort;
|
|
1169
|
+
return _regenerator.default.wrap(function (_context20) {
|
|
1170
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1171
|
+
case 0:
|
|
1172
|
+
_context20.next = 1;
|
|
1173
|
+
return this.resumeFailover();
|
|
1174
|
+
case 1:
|
|
1175
|
+
if (!_context20.sent) {
|
|
1176
|
+
_context20.next = 2;
|
|
1177
|
+
break;
|
|
1178
|
+
}
|
|
1179
|
+
return _context20.abrupt("return");
|
|
1180
|
+
case 2:
|
|
1181
|
+
if (!(this.primaryMobiusUris.length > 0)) {
|
|
1182
|
+
_context20.next = 4;
|
|
1183
|
+
break;
|
|
1184
|
+
}
|
|
1185
|
+
_context20.next = 3;
|
|
1186
|
+
return this.attemptRegistrationWithServers(_constants2.REGISTRATION_UTIL, this.primaryMobiusUris);
|
|
1187
|
+
case 3:
|
|
1188
|
+
abort = _context20.sent;
|
|
1189
|
+
if (!(!this.isDeviceRegistered() && !abort)) {
|
|
1190
|
+
_context20.next = 4;
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
_context20.next = 4;
|
|
1194
|
+
return this.startFailoverTimer();
|
|
1195
|
+
case 4:
|
|
1196
|
+
case "end":
|
|
1197
|
+
return _context20.stop();
|
|
1198
|
+
}
|
|
1199
|
+
}, _callee20, this);
|
|
1200
|
+
}));
|
|
1201
|
+
function triggerRegistration() {
|
|
1202
|
+
return _triggerRegistration.apply(this, arguments);
|
|
1203
|
+
}
|
|
1204
|
+
return triggerRegistration;
|
|
1205
|
+
}()
|
|
1206
|
+
/**
|
|
1207
|
+
* Attempts registration with the server list received in
|
|
1208
|
+
* argument one by one until registration either succeeds with
|
|
1209
|
+
* one or all of them are tried.
|
|
1210
|
+
*
|
|
1211
|
+
* attempt has hit a final error and a retry should not be scheduled
|
|
1212
|
+
* else false.
|
|
1213
|
+
*/
|
|
1214
|
+
)
|
|
1215
|
+
}, {
|
|
1216
|
+
key: "attemptRegistrationWithServers",
|
|
1217
|
+
value: (function () {
|
|
1218
|
+
var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21(caller) {
|
|
1219
|
+
var _this8 = this;
|
|
1220
|
+
var servers,
|
|
1221
|
+
abort,
|
|
1222
|
+
_iterator2,
|
|
1223
|
+
_step2,
|
|
1224
|
+
_loop,
|
|
1225
|
+
_ret,
|
|
1226
|
+
_args22 = arguments,
|
|
1227
|
+
_t12;
|
|
1228
|
+
return _regenerator.default.wrap(function (_context22) {
|
|
1229
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1230
|
+
case 0:
|
|
1231
|
+
servers = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : this.primaryMobiusUris;
|
|
1232
|
+
abort = false;
|
|
1233
|
+
this.retryAfter = undefined;
|
|
1234
|
+
if (!this.failoverImmediately) {
|
|
1235
|
+
_context22.next = 1;
|
|
1236
|
+
break;
|
|
1237
|
+
}
|
|
1238
|
+
return _context22.abrupt("return", abort);
|
|
1239
|
+
case 1:
|
|
1240
|
+
if (!this.isDeviceRegistered()) {
|
|
1241
|
+
_context22.next = 2;
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
_Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), {
|
|
1245
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1246
|
+
method: _constants2.REGISTER_UTIL
|
|
1247
|
+
});
|
|
1248
|
+
return _context22.abrupt("return", abort);
|
|
1249
|
+
case 2:
|
|
1250
|
+
_iterator2 = _createForOfIteratorHelper(servers);
|
|
1251
|
+
_context22.prev = 3;
|
|
1252
|
+
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1253
|
+
var _this8$backupMobiusUr;
|
|
1254
|
+
var url, serverType, _this8$deviceInfo$dev, _resp$headers, _resp$headers$trackin, _resp$headers2, _this8$deviceInfo$dev2, resp, body, _t11;
|
|
1255
|
+
return _regenerator.default.wrap(function (_context21) {
|
|
1256
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1257
|
+
case 0:
|
|
1258
|
+
url = _step2.value;
|
|
1259
|
+
serverType = _this8.primaryMobiusUris.includes(url) && 'PRIMARY' || ((_this8$backupMobiusUr = _this8.backupMobiusUris) === null || _this8$backupMobiusUr === void 0 ? void 0 : _this8$backupMobiusUr.includes(url)) && 'BACKUP' || 'UNKNOWN';
|
|
1260
|
+
_context21.prev = 1;
|
|
1261
|
+
abort = false;
|
|
1262
|
+
_this8.registrationStatus = _types2.RegistrationStatus.INACTIVE;
|
|
1263
|
+
_this8.lineEmitter(_types3.LINE_EVENTS.CONNECTING);
|
|
1264
|
+
_Logger.default.info("[".concat(caller, "] : Mobius url to contact: ").concat(url), {
|
|
1265
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1266
|
+
method: _constants2.REGISTER_UTIL
|
|
1267
|
+
});
|
|
1268
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1269
|
+
_context21.next = 2;
|
|
1270
|
+
return _this8.postRegistration(url);
|
|
1271
|
+
case 2:
|
|
1272
|
+
resp = _context21.sent;
|
|
1273
|
+
_this8.clearFailoverState();
|
|
1274
|
+
_this8.deviceInfo = resp.body;
|
|
1275
|
+
_this8.registrationStatus = _types2.RegistrationStatus.ACTIVE;
|
|
1276
|
+
_this8.setActiveMobiusUrl(url);
|
|
1277
|
+
_this8.lineEmitter(_types3.LINE_EVENTS.REGISTERED, resp.body);
|
|
1278
|
+
_Logger.default.log("Registration successful for deviceId: ".concat((_this8$deviceInfo$dev = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev === void 0 ? void 0 : _this8$deviceInfo$dev.deviceId, " userId: ").concat(_this8.userId, " responseTrackingId: ").concat((_resp$headers = resp.headers) === null || _resp$headers === void 0 ? void 0 : _resp$headers.trackingid), {
|
|
1279
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1280
|
+
method: _constants2.METHODS.REGISTER
|
|
1281
|
+
});
|
|
1282
|
+
_this8.setIntervalValues(_this8.deviceInfo);
|
|
1283
|
+
_this8.metricManager.setDeviceInfo(_this8.deviceInfo);
|
|
1284
|
+
_this8.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, caller, serverType, (_resp$headers$trackin = (_resp$headers2 = resp.headers) === null || _resp$headers2 === void 0 ? void 0 : _resp$headers2.trackingid) !== null && _resp$headers$trackin !== void 0 ? _resp$headers$trackin : '', undefined, undefined);
|
|
1285
|
+
_this8.startKeepaliveTimer((_this8$deviceInfo$dev2 = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev2 === void 0 ? void 0 : _this8$deviceInfo$dev2.uri, _this8.deviceInfo.keepaliveInterval, serverType);
|
|
1286
|
+
_this8.initiateFailback();
|
|
1287
|
+
return _context21.abrupt("return", 0);
|
|
1288
|
+
case 3:
|
|
1289
|
+
_context21.prev = 3;
|
|
1290
|
+
_t11 = _context21["catch"](1);
|
|
1291
|
+
body = _t11; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
|
|
1292
|
+
_context21.next = 4;
|
|
1293
|
+
return (0, _common.handleRegistrationErrors)(body, function (clientError, finalError) {
|
|
1294
|
+
var _body$headers$trackin, _body$headers;
|
|
1295
|
+
if (finalError) {
|
|
1296
|
+
_this8.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
1297
|
+
} else {
|
|
1298
|
+
_this8.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
1299
|
+
}
|
|
1300
|
+
_this8.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION_ERROR, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, caller, serverType, (_body$headers$trackin = (_body$headers = body.headers) === null || _body$headers === void 0 ? void 0 : _body$headers.trackingid) !== null && _body$headers$trackin !== void 0 ? _body$headers$trackin : '', undefined, clientError);
|
|
1301
|
+
}, {
|
|
1302
|
+
method: caller,
|
|
1303
|
+
file: _constants2.REGISTRATION_FILE
|
|
1304
|
+
}, function (retryAfter, retryCaller) {
|
|
1305
|
+
return _this8.handle429Retry(retryAfter, retryCaller);
|
|
1306
|
+
}, _this8.restoreRegistrationCallBack());
|
|
1307
|
+
case 4:
|
|
1308
|
+
abort = _context21.sent;
|
|
1309
|
+
if (!(_this8.registrationStatus === _types2.RegistrationStatus.ACTIVE)) {
|
|
1310
|
+
_context21.next = 5;
|
|
1311
|
+
break;
|
|
1312
|
+
}
|
|
1313
|
+
_Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(_this8.activeMobiusUrl), {
|
|
1314
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1315
|
+
method: _this8.attemptRegistrationWithServers.name
|
|
1316
|
+
});
|
|
1317
|
+
return _context21.abrupt("return", 0);
|
|
1318
|
+
case 5:
|
|
1319
|
+
if (!abort) {
|
|
1320
|
+
_context21.next = 7;
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
_this8.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1324
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1325
|
+
_context21.next = 6;
|
|
1326
|
+
return (0, _common.uploadLogs)();
|
|
1327
|
+
case 6:
|
|
1328
|
+
return _context21.abrupt("return", 0);
|
|
1329
|
+
case 7:
|
|
1330
|
+
case "end":
|
|
1331
|
+
return _context21.stop();
|
|
1332
|
+
}
|
|
1333
|
+
}, _loop, null, [[1, 3]]);
|
|
1334
|
+
});
|
|
1335
|
+
_iterator2.s();
|
|
1336
|
+
case 4:
|
|
1337
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
1338
|
+
_context22.next = 7;
|
|
1339
|
+
break;
|
|
1340
|
+
}
|
|
1341
|
+
return _context22.delegateYield(_loop(), "t0", 5);
|
|
1342
|
+
case 5:
|
|
1343
|
+
_ret = _context22.t0;
|
|
1344
|
+
if (!(_ret === 0)) {
|
|
1345
|
+
_context22.next = 6;
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
return _context22.abrupt("continue", 7);
|
|
1349
|
+
case 6:
|
|
1350
|
+
_context22.next = 4;
|
|
1351
|
+
break;
|
|
1352
|
+
case 7:
|
|
1353
|
+
_context22.next = 9;
|
|
1354
|
+
break;
|
|
1355
|
+
case 8:
|
|
1356
|
+
_context22.prev = 8;
|
|
1357
|
+
_t12 = _context22["catch"](3);
|
|
1358
|
+
_iterator2.e(_t12);
|
|
1359
|
+
case 9:
|
|
1360
|
+
_context22.prev = 9;
|
|
1361
|
+
_iterator2.f();
|
|
1362
|
+
return _context22.finish(9);
|
|
1363
|
+
case 10:
|
|
1364
|
+
return _context22.abrupt("return", abort);
|
|
1365
|
+
case 11:
|
|
1366
|
+
case "end":
|
|
1367
|
+
return _context22.stop();
|
|
1368
|
+
}
|
|
1369
|
+
}, _callee21, this, [[3, 8, 9, 10]]);
|
|
1370
|
+
}));
|
|
1371
|
+
function attemptRegistrationWithServers(_x11) {
|
|
1372
|
+
return _attemptRegistrationWithServers.apply(this, arguments);
|
|
1373
|
+
}
|
|
1374
|
+
return attemptRegistrationWithServers;
|
|
1375
|
+
}()
|
|
1376
|
+
/**
|
|
1377
|
+
* This method sets up a timer to periodically send keep-alive requests to maintain a connection.
|
|
1378
|
+
* It handles retries, error handling, and re-registration attempts based on the response, ensuring continuous connectivity with the server.
|
|
1379
|
+
*/
|
|
1380
|
+
)
|
|
1381
|
+
}, {
|
|
1382
|
+
key: "startKeepaliveTimer",
|
|
1383
|
+
value: (function () {
|
|
1384
|
+
var _startKeepaliveTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24(url, interval, serverType) {
|
|
1385
|
+
var _this9 = this;
|
|
1386
|
+
var RETRY_COUNT_THRESHOLD;
|
|
1387
|
+
return _regenerator.default.wrap(function (_context25) {
|
|
1388
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1389
|
+
case 0:
|
|
1390
|
+
this.clearKeepaliveTimer();
|
|
1391
|
+
RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
1392
|
+
_context25.next = 1;
|
|
1393
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
|
|
1394
|
+
var accessToken, blob, blobUrl;
|
|
1395
|
+
return _regenerator.default.wrap(function (_context24) {
|
|
1396
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1397
|
+
case 0:
|
|
1398
|
+
if (!_this9.isDeviceRegistered()) {
|
|
1399
|
+
_context24.next = 2;
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
_context24.next = 1;
|
|
1403
|
+
return _this9.webex.credentials.getUserToken();
|
|
1404
|
+
case 1:
|
|
1405
|
+
accessToken = _context24.sent;
|
|
1406
|
+
if (!_this9.webWorker) {
|
|
1407
|
+
blob = new Blob([_webWorkerStr.default], {
|
|
1408
|
+
type: 'application/javascript'
|
|
1409
|
+
});
|
|
1410
|
+
blobUrl = URL.createObjectURL(blob);
|
|
1411
|
+
_this9.webWorker = new Worker(blobUrl);
|
|
1412
|
+
URL.revokeObjectURL(blobUrl);
|
|
1413
|
+
_this9.webWorker.postMessage({
|
|
1414
|
+
type: _types2.WorkerMessageType.START_KEEPALIVE,
|
|
1415
|
+
accessToken: String(accessToken),
|
|
1416
|
+
deviceUrl: String(_this9.webex.internal.device.url),
|
|
1417
|
+
interval: interval,
|
|
1418
|
+
retryCountThreshold: RETRY_COUNT_THRESHOLD,
|
|
1419
|
+
url: url
|
|
1420
|
+
});
|
|
1421
|
+
_this9.webWorker.onmessage = /*#__PURE__*/function () {
|
|
1422
|
+
var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22(event) {
|
|
1423
|
+
var logContext, error, abort;
|
|
1424
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
1425
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1426
|
+
case 0:
|
|
1427
|
+
logContext = {
|
|
1428
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1429
|
+
method: _constants2.KEEPALIVE_UTIL
|
|
1430
|
+
};
|
|
1431
|
+
if (event.data.type === _types2.WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
1432
|
+
_Logger.default.info("Sent Keepalive, status: ".concat(event.data.statusCode), logContext);
|
|
1433
|
+
_this9.lineEmitter(_types3.LINE_EVENTS.RECONNECTED);
|
|
1434
|
+
}
|
|
1435
|
+
if (!(event.data.type === _types2.WorkerMessageType.KEEPALIVE_FAILURE)) {
|
|
1436
|
+
_context23.next = 7;
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
error = event.data.err;
|
|
1440
|
+
_Logger.default.warn("Keep-alive missed ".concat(event.data.keepAliveRetryCount, " times. Status -> ").concat(error.statusCode, " "), logContext);
|
|
1441
|
+
_context23.next = 1;
|
|
1442
|
+
return (0, _common.handleRegistrationErrors)(error, function (clientError, finalError) {
|
|
1443
|
+
var _error$headers$tracki, _error$headers;
|
|
1444
|
+
if (finalError) {
|
|
1445
|
+
_this9.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
1446
|
+
}
|
|
1447
|
+
_this9.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.KEEPALIVE_ERROR, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, _constants2.KEEPALIVE_UTIL, serverType, (_error$headers$tracki = (_error$headers = error.headers) === null || _error$headers === void 0 ? void 0 : _error$headers.trackingid) !== null && _error$headers$tracki !== void 0 ? _error$headers$tracki : '', event.data.keepAliveRetryCount, clientError);
|
|
1448
|
+
}, {
|
|
1449
|
+
method: _constants2.KEEPALIVE_UTIL,
|
|
1450
|
+
file: _constants2.REGISTRATION_FILE
|
|
1451
|
+
}, function (retryAfter, retryCaller) {
|
|
1452
|
+
return _this9.handle429Retry(retryAfter, retryCaller);
|
|
1453
|
+
});
|
|
1454
|
+
case 1:
|
|
1455
|
+
abort = _context23.sent;
|
|
1456
|
+
if (!(abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
|
|
1457
|
+
_context23.next = 6;
|
|
1458
|
+
break;
|
|
1459
|
+
}
|
|
1460
|
+
_this9.failoverImmediately = _this9.isCCFlow;
|
|
1461
|
+
_this9.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1462
|
+
_this9.clearKeepaliveTimer();
|
|
1463
|
+
_this9.clearFailbackTimer();
|
|
1464
|
+
_this9.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
1465
|
+
_context23.next = 2;
|
|
1466
|
+
return (0, _common.uploadLogs)();
|
|
1467
|
+
case 2:
|
|
1468
|
+
if (abort) {
|
|
1469
|
+
_context23.next = 4;
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
_context23.next = 3;
|
|
1473
|
+
return _this9.reconnectOnFailure(_constants2.RECONNECT_ON_FAILURE_UTIL);
|
|
1474
|
+
case 3:
|
|
1475
|
+
_context23.next = 5;
|
|
1476
|
+
break;
|
|
1477
|
+
case 4:
|
|
1478
|
+
if (error.statusCode === 404) {
|
|
1479
|
+
_this9.handle404KeepaliveFailure(_constants2.KEEPALIVE_UTIL);
|
|
1480
|
+
}
|
|
1481
|
+
case 5:
|
|
1482
|
+
_context23.next = 7;
|
|
1483
|
+
break;
|
|
1484
|
+
case 6:
|
|
1485
|
+
_this9.lineEmitter(_types3.LINE_EVENTS.RECONNECTING);
|
|
1486
|
+
case 7:
|
|
1487
|
+
case "end":
|
|
1488
|
+
return _context23.stop();
|
|
1489
|
+
}
|
|
1490
|
+
}, _callee22);
|
|
1491
|
+
}));
|
|
1492
|
+
return function (_x15) {
|
|
1493
|
+
return _ref11.apply(this, arguments);
|
|
1494
|
+
};
|
|
1495
|
+
}();
|
|
1496
|
+
}
|
|
1497
|
+
case 2:
|
|
1498
|
+
case "end":
|
|
1499
|
+
return _context24.stop();
|
|
1500
|
+
}
|
|
1501
|
+
}, _callee23);
|
|
1502
|
+
})));
|
|
1503
|
+
case 1:
|
|
1504
|
+
case "end":
|
|
1505
|
+
return _context25.stop();
|
|
1506
|
+
}
|
|
1507
|
+
}, _callee24, this);
|
|
1508
|
+
}));
|
|
1509
|
+
function startKeepaliveTimer(_x12, _x13, _x14) {
|
|
1510
|
+
return _startKeepaliveTimer.apply(this, arguments);
|
|
1511
|
+
}
|
|
1512
|
+
return startKeepaliveTimer;
|
|
1513
|
+
}()
|
|
1514
|
+
/**
|
|
1515
|
+
* Clears the keepalive timer if running.
|
|
1516
|
+
*/
|
|
1517
|
+
)
|
|
1518
|
+
}, {
|
|
1519
|
+
key: "clearKeepaliveTimer",
|
|
1520
|
+
value: function clearKeepaliveTimer() {
|
|
1521
|
+
if (this.webWorker) {
|
|
1522
|
+
this.webWorker.postMessage({
|
|
1523
|
+
type: _types2.WorkerMessageType.CLEAR_KEEPALIVE
|
|
1524
|
+
});
|
|
1525
|
+
this.webWorker.terminate();
|
|
1526
|
+
this.webWorker = undefined;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
}, {
|
|
1530
|
+
key: "isReconnectPending",
|
|
1531
|
+
value: function isReconnectPending() {
|
|
1532
|
+
return this.reconnectPending;
|
|
1533
|
+
}
|
|
1534
|
+
}, {
|
|
1535
|
+
key: "deregister",
|
|
1536
|
+
value: function () {
|
|
1537
|
+
var _deregister = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1538
|
+
var _this$deviceInfo$devi, _this$deviceInfo$devi2, _t13;
|
|
1539
|
+
return _regenerator.default.wrap(function (_context26) {
|
|
1540
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1541
|
+
case 0:
|
|
1542
|
+
_context26.prev = 0;
|
|
1543
|
+
_context26.next = 1;
|
|
1544
|
+
return this.deleteRegistration(this.activeMobiusUrl, (_this$deviceInfo$devi = this.deviceInfo.device) === null || _this$deviceInfo$devi === void 0 ? void 0 : _this$deviceInfo$devi.deviceId, (_this$deviceInfo$devi2 = this.deviceInfo.device) === null || _this$deviceInfo$devi2 === void 0 ? void 0 : _this$deviceInfo$devi2.clientDeviceUri);
|
|
1545
|
+
case 1:
|
|
1546
|
+
_Logger.default.log('Registration successfully deregistered', {
|
|
1547
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1548
|
+
method: _constants2.METHODS.DEREGISTER
|
|
1549
|
+
});
|
|
1550
|
+
_context26.next = 3;
|
|
1551
|
+
break;
|
|
1552
|
+
case 2:
|
|
1553
|
+
_context26.prev = 2;
|
|
1554
|
+
_t13 = _context26["catch"](0);
|
|
1555
|
+
_Logger.default.warn("Delete failed with Mobius: ".concat((0, _stringify.default)(_t13)), {
|
|
1556
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1557
|
+
method: _constants2.METHODS.DEREGISTER
|
|
1558
|
+
});
|
|
1559
|
+
case 3:
|
|
1560
|
+
this.clearKeepaliveTimer();
|
|
1561
|
+
this.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1562
|
+
this.clearFailoverState();
|
|
1563
|
+
case 4:
|
|
1564
|
+
case "end":
|
|
1565
|
+
return _context26.stop();
|
|
1566
|
+
}
|
|
1567
|
+
}, _callee25, this, [[0, 2]]);
|
|
1568
|
+
}));
|
|
1569
|
+
function deregister() {
|
|
1570
|
+
return _deregister.apply(this, arguments);
|
|
1571
|
+
}
|
|
1572
|
+
return deregister;
|
|
1573
|
+
}()
|
|
1574
|
+
/**
|
|
1575
|
+
* Indicates whether the calling client is in a mode
|
|
1576
|
+
* to retry registration.
|
|
1577
|
+
*/
|
|
1578
|
+
}, {
|
|
1579
|
+
key: "isRegRetry",
|
|
1580
|
+
value: function isRegRetry() {
|
|
1581
|
+
return this.registerRetry;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Sets the received value in instance variable
|
|
1586
|
+
* registerRetry for registration retry cases.
|
|
1587
|
+
*
|
|
1588
|
+
*/
|
|
1589
|
+
}, {
|
|
1590
|
+
key: "setRegRetry",
|
|
1591
|
+
value: function setRegRetry(value) {
|
|
1592
|
+
this.registerRetry = value;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Restores the deviceInfo object in callingClient when receiving a 403 with error code 101.
|
|
1597
|
+
*
|
|
1598
|
+
*/
|
|
1599
|
+
}, {
|
|
1600
|
+
key: "getExistingDevice",
|
|
1601
|
+
value: function getExistingDevice(restoreData) {
|
|
1602
|
+
if (restoreData.devices && restoreData.devices.length > 0) {
|
|
1603
|
+
this.deviceInfo = {
|
|
1604
|
+
userId: restoreData.userId,
|
|
1605
|
+
device: restoreData.devices[0],
|
|
1606
|
+
keepaliveInterval: _constants2.DEFAULT_KEEPALIVE_INTERVAL,
|
|
1607
|
+
rehomingIntervalMax: _constants2.DEFAULT_REHOMING_INTERVAL_MAX,
|
|
1608
|
+
rehomingIntervalMin: _constants2.DEFAULT_REHOMING_INTERVAL_MIN
|
|
1609
|
+
};
|
|
1610
|
+
var stringToReplace = "".concat(_constants2.DEVICES_ENDPOINT_RESOURCE, "/").concat(restoreData.devices[0].deviceId);
|
|
1611
|
+
var uri = restoreData.devices[0].uri.replace(stringToReplace, '');
|
|
1612
|
+
this.setActiveMobiusUrl(uri);
|
|
1613
|
+
this.registrationStatus = _types2.RegistrationStatus.ACTIVE;
|
|
1614
|
+
return true;
|
|
1615
|
+
}
|
|
1616
|
+
return false;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* Invoked to re-register in cases when the registration
|
|
1621
|
+
* is lost due to some failure.
|
|
1622
|
+
* If there are active calls, it will only mark reconnectPending
|
|
1623
|
+
* as true and then retry will happen when this method gets
|
|
1624
|
+
* invoked again on receiving all calls cleared event from
|
|
1625
|
+
* callManager.
|
|
1626
|
+
*
|
|
1627
|
+
*/
|
|
1628
|
+
}, {
|
|
1629
|
+
key: "reconnectOnFailure",
|
|
1630
|
+
value: (function () {
|
|
1631
|
+
var _reconnectOnFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26(caller) {
|
|
1632
|
+
var abort;
|
|
1633
|
+
return _regenerator.default.wrap(function (_context27) {
|
|
1634
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1635
|
+
case 0:
|
|
1636
|
+
_Logger.default.info(_constants.METHOD_START_MESSAGE, {
|
|
1637
|
+
method: _constants2.METHODS.RECONNECT_ON_FAILURE,
|
|
1638
|
+
file: _constants2.REGISTRATION_FILE
|
|
1639
|
+
});
|
|
1640
|
+
this.reconnectPending = false;
|
|
1641
|
+
if (this.isDeviceRegistered()) {
|
|
1642
|
+
_context27.next = 4;
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
if (!((0, _keys.default)(this.callManager.getActiveCalls()).length === 0)) {
|
|
1646
|
+
_context27.next = 3;
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
_context27.next = 1;
|
|
1650
|
+
return this.restorePreviousRegistration(caller);
|
|
1651
|
+
case 1:
|
|
1652
|
+
abort = _context27.sent;
|
|
1653
|
+
if (!(!abort && !this.isDeviceRegistered())) {
|
|
1654
|
+
_context27.next = 2;
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
_context27.next = 2;
|
|
1658
|
+
return this.restartRegistration(caller);
|
|
1659
|
+
case 2:
|
|
1660
|
+
_context27.next = 4;
|
|
1661
|
+
break;
|
|
1662
|
+
case 3:
|
|
1663
|
+
this.reconnectPending = true;
|
|
1664
|
+
_Logger.default.info('Active call(s) present, deferred reconnect till call cleanup.', {
|
|
1665
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1666
|
+
method: _constants2.METHODS.RECONNECT_ON_FAILURE
|
|
1667
|
+
});
|
|
1668
|
+
case 4:
|
|
1669
|
+
case "end":
|
|
1670
|
+
return _context27.stop();
|
|
1671
|
+
}
|
|
1672
|
+
}, _callee26, this);
|
|
1673
|
+
}));
|
|
1674
|
+
function reconnectOnFailure(_x16) {
|
|
1675
|
+
return _reconnectOnFailure.apply(this, arguments);
|
|
1676
|
+
}
|
|
1677
|
+
return reconnectOnFailure;
|
|
1678
|
+
}())
|
|
1679
|
+
}]);
|
|
1680
|
+
}();
|
|
1681
|
+
/*
|
|
1682
|
+
*/
|
|
1683
|
+
var createRegistration = exports.createRegistration = function createRegistration(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
|
|
1684
|
+
return new Registration(webex, serviceData, mutex, lineEmitter, logLevel, jwe);
|
|
1685
|
+
};
|
|
1686
|
+
//# sourceMappingURL=register.js.map
|