@webex/calling 3.8.0-next.31 → 3.8.0-next.32
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/constants.js +4 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +2 -2
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +149 -143
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +495 -139
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/common/Utils.js +58 -44
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +45 -14
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/module/CallingClient/constants.js +3 -2
- package/dist/module/CallingClient/registration/register.js +54 -44
- package/dist/module/common/Utils.js +24 -8
- package/dist/types/CallingClient/constants.d.ts +3 -2
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +3 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +1 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +2 -2
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -23,16 +23,15 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/he
|
|
|
23
23
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
24
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
25
25
|
var _uuid = require("uuid");
|
|
26
|
-
var _types = require("../../Errors/types");
|
|
27
26
|
var _common = require("../../common");
|
|
28
|
-
var
|
|
27
|
+
var _types = require("../../Metrics/types");
|
|
29
28
|
var _Metrics = require("../../Metrics");
|
|
30
29
|
var _calling = require("../calling");
|
|
31
30
|
var _Logger = _interopRequireDefault(require("../../Logger"));
|
|
32
31
|
var _SDKConnector = _interopRequireDefault(require("../../SDKConnector"));
|
|
33
|
-
var
|
|
32
|
+
var _types2 = require("../../common/types");
|
|
34
33
|
var _constants = require("../constants");
|
|
35
|
-
var
|
|
34
|
+
var _types3 = require("../line/types");
|
|
36
35
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && o[_Symbol$iterator] || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
37
36
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
38
37
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -69,16 +68,18 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
69
68
|
(0, _defineProperty2.default)(this, "jwe", void 0);
|
|
70
69
|
(0, _defineProperty2.default)(this, "isCCFlow", false);
|
|
71
70
|
(0, _defineProperty2.default)(this, "failoverImmediately", false);
|
|
71
|
+
(0, _defineProperty2.default)(this, "retryAfter", void 0);
|
|
72
|
+
(0, _defineProperty2.default)(this, "scheduled429Retry", false);
|
|
72
73
|
this.jwe = jwe;
|
|
73
74
|
this.sdkConnector = _SDKConnector.default;
|
|
74
75
|
this.serviceData = serviceData;
|
|
75
|
-
this.isCCFlow = serviceData.indicator ===
|
|
76
|
+
this.isCCFlow = serviceData.indicator === _types2.ServiceIndicator.CONTACT_CENTER;
|
|
76
77
|
if (!this.sdkConnector.getWebex()) {
|
|
77
78
|
_SDKConnector.default.setWebex(webex);
|
|
78
79
|
}
|
|
79
80
|
this.webex = this.sdkConnector.getWebex();
|
|
80
81
|
this.userId = this.webex.internal.device.userId;
|
|
81
|
-
this.registrationStatus =
|
|
82
|
+
this.registrationStatus = _types2.RegistrationStatus.IDLE;
|
|
82
83
|
this.failback429RetryAttempts = 0;
|
|
83
84
|
_Logger.default.setLogger(logLevel, _constants.REGISTRATION_FILE);
|
|
84
85
|
this.rehomingIntervalMin = _constants.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
@@ -125,9 +126,9 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
125
126
|
case 0:
|
|
126
127
|
return _context.abrupt("return", this.webex.request({
|
|
127
128
|
uri: "".concat(url, "/status"),
|
|
128
|
-
method:
|
|
129
|
+
method: _types2.HTTP_METHODS.POST,
|
|
129
130
|
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, this.webex.internal.device.url), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT),
|
|
130
|
-
service:
|
|
131
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS
|
|
131
132
|
}));
|
|
132
133
|
case 1:
|
|
133
134
|
case "end":
|
|
@@ -157,7 +158,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
157
158
|
_context2.prev = 0;
|
|
158
159
|
_context2.t0 = fetch;
|
|
159
160
|
_context2.t1 = "".concat(url).concat(_constants.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId);
|
|
160
|
-
_context2.t2 =
|
|
161
|
+
_context2.t2 = _types2.HTTP_METHODS.DELETE;
|
|
161
162
|
_context2.t3 = _defineProperty2.default;
|
|
162
163
|
_context2.t4 = _defineProperty2.default;
|
|
163
164
|
_context2.t5 = _defineProperty2.default;
|
|
@@ -187,8 +188,8 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
187
188
|
_context2.t15 = _context2["catch"](0);
|
|
188
189
|
_Logger.default.warn("Delete failed with Mobius", {});
|
|
189
190
|
case 26:
|
|
190
|
-
this.setStatus(
|
|
191
|
-
this.lineEmitter(
|
|
191
|
+
this.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
192
|
+
this.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
192
193
|
return _context2.abrupt("return", (_response = response) === null || _response === void 0 ? void 0 : _response.json());
|
|
193
194
|
case 29:
|
|
194
195
|
case "end":
|
|
@@ -223,10 +224,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
223
224
|
};
|
|
224
225
|
return _context3.abrupt("return", this.webex.request({
|
|
225
226
|
uri: "".concat(url, "device"),
|
|
226
|
-
method:
|
|
227
|
+
method: _types2.HTTP_METHODS.POST,
|
|
227
228
|
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants.CISCO_DEVICE_URL, deviceInfo.clientDeviceUri), _constants.SPARK_USER_AGENT, _constants.CALLING_USER_AGENT),
|
|
228
229
|
body: deviceInfo,
|
|
229
|
-
service:
|
|
230
|
+
service: _types2.ALLOWED_SERVICES.MOBIUS
|
|
230
231
|
}));
|
|
231
232
|
case 2:
|
|
232
233
|
case "end":
|
|
@@ -275,54 +276,61 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
275
276
|
return restorePreviousRegistration;
|
|
276
277
|
}()
|
|
277
278
|
/**
|
|
278
|
-
*
|
|
279
|
-
* request did not even land on primary mobius to know if it
|
|
280
|
-
* can handle this device registration now, in such cases this
|
|
281
|
-
* method is called to retry sooner than the rehoming timer value.
|
|
279
|
+
*
|
|
282
280
|
*/
|
|
283
281
|
)
|
|
284
282
|
}, {
|
|
285
|
-
key: "
|
|
283
|
+
key: "handle429Retry",
|
|
286
284
|
value: (function () {
|
|
287
|
-
var
|
|
285
|
+
var _handle429Retry = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(retryAfter, caller) {
|
|
288
286
|
var interval, abort;
|
|
289
287
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
290
288
|
while (1) switch (_context5.prev = _context5.next) {
|
|
291
289
|
case 0:
|
|
290
|
+
if (!(caller === _constants.FAILBACK_UTIL)) {
|
|
291
|
+
_context5.next = 17;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
292
294
|
if (!(this.failback429RetryAttempts >= _constants.REG_FAILBACK_429_MAX_RETRIES)) {
|
|
293
|
-
_context5.next =
|
|
295
|
+
_context5.next = 3;
|
|
294
296
|
break;
|
|
295
297
|
}
|
|
296
298
|
return _context5.abrupt("return");
|
|
297
|
-
case
|
|
299
|
+
case 3:
|
|
298
300
|
this.clearFailbackTimer();
|
|
299
301
|
this.failback429RetryAttempts += 1;
|
|
300
302
|
_Logger.default.log("Received 429 while rehoming, 429 retry count : ".concat(this.failback429RetryAttempts), {
|
|
301
303
|
file: _constants.REGISTRATION_FILE,
|
|
302
|
-
method: _constants.
|
|
304
|
+
method: _constants.REG_429_RETRY_UTIL
|
|
303
305
|
});
|
|
304
306
|
interval = this.getRegRetryInterval(this.failback429RetryAttempts);
|
|
305
307
|
this.startFailbackTimer(interval);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
308
|
+
this.scheduled429Retry = true;
|
|
309
|
+
_context5.next = 11;
|
|
310
|
+
return this.restorePreviousRegistration(_constants.REG_429_RETRY_UTIL);
|
|
311
|
+
case 11:
|
|
309
312
|
abort = _context5.sent;
|
|
310
313
|
if (!(!abort && !this.isDeviceRegistered())) {
|
|
311
|
-
_context5.next =
|
|
314
|
+
_context5.next = 15;
|
|
312
315
|
break;
|
|
313
316
|
}
|
|
314
|
-
_context5.next =
|
|
315
|
-
return this.restartRegistration(_constants.
|
|
316
|
-
case
|
|
317
|
+
_context5.next = 15;
|
|
318
|
+
return this.restartRegistration(_constants.REG_429_RETRY_UTIL);
|
|
319
|
+
case 15:
|
|
320
|
+
_context5.next = 18;
|
|
321
|
+
break;
|
|
322
|
+
case 17:
|
|
323
|
+
this.retryAfter = retryAfter;
|
|
324
|
+
case 18:
|
|
317
325
|
case "end":
|
|
318
326
|
return _context5.stop();
|
|
319
327
|
}
|
|
320
328
|
}, _callee5, this);
|
|
321
329
|
}));
|
|
322
|
-
function
|
|
323
|
-
return
|
|
330
|
+
function handle429Retry(_x7, _x8) {
|
|
331
|
+
return _handle429Retry.apply(this, arguments);
|
|
324
332
|
}
|
|
325
|
-
return
|
|
333
|
+
return handle429Retry;
|
|
326
334
|
}()
|
|
327
335
|
/**
|
|
328
336
|
* Calculates and returns a random interval value using input argument
|
|
@@ -366,7 +374,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
366
374
|
timeElapsed = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 0;
|
|
367
375
|
loggerContext = {
|
|
368
376
|
file: _constants.REGISTRATION_FILE,
|
|
369
|
-
method:
|
|
377
|
+
method: _constants.FAILOVER_UTIL
|
|
370
378
|
};
|
|
371
379
|
interval = this.getRegRetryInterval(attempt);
|
|
372
380
|
TIMER_THRESHOLD = this.isCCFlow ? _constants.REG_TRY_BACKUP_TIMER_VAL_FOR_CC_IN_SEC : _constants.REG_TRY_BACKUP_TIMER_VAL_IN_SEC;
|
|
@@ -374,11 +382,17 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
374
382
|
excessVal = timeElapsed + interval - TIMER_THRESHOLD;
|
|
375
383
|
interval -= excessVal;
|
|
376
384
|
}
|
|
385
|
+
if (this.retryAfter != null && interval < this.retryAfter) {
|
|
386
|
+
this.failoverImmediately = this.retryAfter + timeElapsed > TIMER_THRESHOLD;
|
|
387
|
+
}
|
|
377
388
|
if (!(interval > _constants.BASE_REG_RETRY_TIMER_VAL_IN_SEC && !this.failoverImmediately)) {
|
|
378
|
-
_context10.next =
|
|
389
|
+
_context10.next = 14;
|
|
379
390
|
break;
|
|
380
391
|
}
|
|
381
392
|
scheduledTime = Math.floor((0, _now.default)() / 1000);
|
|
393
|
+
if (this.retryAfter != null) {
|
|
394
|
+
interval = Math.max(interval, this.retryAfter);
|
|
395
|
+
}
|
|
382
396
|
setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
|
383
397
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
384
398
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -390,7 +404,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
390
404
|
while (1) switch (_context6.prev = _context6.next) {
|
|
391
405
|
case 0:
|
|
392
406
|
_context6.next = 2;
|
|
393
|
-
return _this.attemptRegistrationWithServers(
|
|
407
|
+
return _this.attemptRegistrationWithServers(_constants.FAILOVER_UTIL);
|
|
394
408
|
case 2:
|
|
395
409
|
abort = _context6.sent;
|
|
396
410
|
currentTime = Math.floor((0, _now.default)() / 1000);
|
|
@@ -413,21 +427,24 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
413
427
|
}, _callee7);
|
|
414
428
|
})), interval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
415
429
|
_Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
|
|
416
|
-
_context10.next =
|
|
430
|
+
_context10.next = 24;
|
|
417
431
|
break;
|
|
418
|
-
case
|
|
432
|
+
case 14:
|
|
419
433
|
if (!this.backupMobiusUris.length) {
|
|
420
|
-
_context10.next =
|
|
434
|
+
_context10.next = 23;
|
|
421
435
|
break;
|
|
422
436
|
}
|
|
423
437
|
_Logger.default.log('Failing over to backup servers.', loggerContext);
|
|
424
438
|
this.failoverImmediately = false;
|
|
425
|
-
_context10.next =
|
|
426
|
-
return this.attemptRegistrationWithServers(
|
|
427
|
-
case
|
|
439
|
+
_context10.next = 19;
|
|
440
|
+
return this.attemptRegistrationWithServers(_constants.FAILOVER_UTIL, this.backupMobiusUris);
|
|
441
|
+
case 19:
|
|
428
442
|
abort = _context10.sent;
|
|
429
443
|
if (!abort && !this.isDeviceRegistered()) {
|
|
430
444
|
interval = this.getRegRetryInterval();
|
|
445
|
+
if (this.retryAfter != null && this.retryAfter < _constants.RETRY_TIMER_UPPER_LIMIT) {
|
|
446
|
+
interval = interval < this.retryAfter ? this.retryAfter : interval;
|
|
447
|
+
}
|
|
431
448
|
setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
432
449
|
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
433
450
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -438,12 +455,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
438
455
|
while (1) switch (_context8.prev = _context8.next) {
|
|
439
456
|
case 0:
|
|
440
457
|
_context8.next = 2;
|
|
441
|
-
return _this.attemptRegistrationWithServers(
|
|
458
|
+
return _this.attemptRegistrationWithServers(_constants.FAILOVER_UTIL, _this.backupMobiusUris);
|
|
442
459
|
case 2:
|
|
443
460
|
abort = _context8.sent;
|
|
444
461
|
if (!abort && !_this.isDeviceRegistered()) {
|
|
445
462
|
(0, _common.emitFinalFailure)(function (clientError) {
|
|
446
|
-
_this.lineEmitter(
|
|
463
|
+
_this.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
447
464
|
}, loggerContext);
|
|
448
465
|
}
|
|
449
466
|
case 4:
|
|
@@ -460,13 +477,13 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
460
477
|
})), interval * _constants.SEC_TO_MSEC_MFACTOR);
|
|
461
478
|
_Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
|
|
462
479
|
}
|
|
463
|
-
_context10.next =
|
|
480
|
+
_context10.next = 24;
|
|
464
481
|
break;
|
|
465
|
-
case
|
|
482
|
+
case 23:
|
|
466
483
|
(0, _common.emitFinalFailure)(function (clientError) {
|
|
467
|
-
_this.lineEmitter(
|
|
484
|
+
_this.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
468
485
|
}, loggerContext);
|
|
469
|
-
case
|
|
486
|
+
case 24:
|
|
470
487
|
case "end":
|
|
471
488
|
return _context10.stop();
|
|
472
489
|
}
|
|
@@ -572,11 +589,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
572
589
|
while (1) switch (_context12.prev = _context12.next) {
|
|
573
590
|
case 0:
|
|
574
591
|
if (!_this3.isFailbackRequired()) {
|
|
575
|
-
_context12.next =
|
|
592
|
+
_context12.next = 28;
|
|
576
593
|
break;
|
|
577
594
|
}
|
|
578
595
|
if (!((0, _keys.default)(_this3.callManager.getActiveCalls()).length === 0)) {
|
|
579
|
-
_context12.next =
|
|
596
|
+
_context12.next = 25;
|
|
580
597
|
break;
|
|
581
598
|
}
|
|
582
599
|
_Logger.default.info("Attempting failback to primary.", {
|
|
@@ -590,44 +607,46 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
590
607
|
return _this3.attemptRegistrationWithServers(_constants.FAILBACK_UTIL);
|
|
591
608
|
case 7:
|
|
592
609
|
abort = _context12.sent;
|
|
593
|
-
if (!(
|
|
594
|
-
_context12.next =
|
|
610
|
+
if (!(_this3.scheduled429Retry || abort || _this3.isDeviceRegistered())) {
|
|
611
|
+
_context12.next = 10;
|
|
595
612
|
break;
|
|
596
613
|
}
|
|
597
|
-
_context12.
|
|
614
|
+
return _context12.abrupt("return");
|
|
615
|
+
case 10:
|
|
616
|
+
_context12.next = 12;
|
|
598
617
|
return _this3.restorePreviousRegistration(_constants.FAILBACK_UTIL);
|
|
599
|
-
case
|
|
618
|
+
case 12:
|
|
600
619
|
abortNew = _context12.sent;
|
|
601
620
|
if (!abortNew) {
|
|
602
|
-
_context12.next =
|
|
621
|
+
_context12.next = 16;
|
|
603
622
|
break;
|
|
604
623
|
}
|
|
605
624
|
_this3.clearFailbackTimer();
|
|
606
625
|
return _context12.abrupt("return");
|
|
607
|
-
case
|
|
626
|
+
case 16:
|
|
608
627
|
if (_this3.isDeviceRegistered()) {
|
|
609
|
-
_context12.next =
|
|
628
|
+
_context12.next = 21;
|
|
610
629
|
break;
|
|
611
630
|
}
|
|
612
|
-
_context12.next =
|
|
631
|
+
_context12.next = 19;
|
|
613
632
|
return _this3.restartRegistration(_this3.executeFailback.name);
|
|
614
|
-
case
|
|
615
|
-
_context12.next =
|
|
633
|
+
case 19:
|
|
634
|
+
_context12.next = 23;
|
|
616
635
|
break;
|
|
617
|
-
case
|
|
636
|
+
case 21:
|
|
618
637
|
_this3.failbackTimer = undefined;
|
|
619
638
|
_this3.initiateFailback();
|
|
620
|
-
case
|
|
621
|
-
_context12.next =
|
|
639
|
+
case 23:
|
|
640
|
+
_context12.next = 28;
|
|
622
641
|
break;
|
|
623
|
-
case
|
|
642
|
+
case 25:
|
|
624
643
|
_Logger.default.info('Active calls present, deferring failback to next cycle.', {
|
|
625
644
|
file: _constants.REGISTRATION_FILE,
|
|
626
645
|
method: _this3.executeFailback.name
|
|
627
646
|
});
|
|
628
647
|
_this3.failbackTimer = undefined;
|
|
629
648
|
_this3.initiateFailback();
|
|
630
|
-
case
|
|
649
|
+
case 28:
|
|
631
650
|
case "end":
|
|
632
651
|
return _context12.stop();
|
|
633
652
|
}
|
|
@@ -679,7 +698,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
679
698
|
}, {
|
|
680
699
|
key: "isDeviceRegistered",
|
|
681
700
|
value: function isDeviceRegistered() {
|
|
682
|
-
return this.registrationStatus ===
|
|
701
|
+
return this.registrationStatus === _types2.RegistrationStatus.ACTIVE;
|
|
683
702
|
}
|
|
684
703
|
}, {
|
|
685
704
|
key: "getStatus",
|
|
@@ -727,7 +746,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
727
746
|
}
|
|
728
747
|
}, _callee14, this);
|
|
729
748
|
}));
|
|
730
|
-
function restartRegistration(
|
|
749
|
+
function restartRegistration(_x9) {
|
|
731
750
|
return _restartRegistration.apply(this, arguments);
|
|
732
751
|
}
|
|
733
752
|
return restartRegistration;
|
|
@@ -798,7 +817,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
798
817
|
}
|
|
799
818
|
}, _callee16, this);
|
|
800
819
|
}));
|
|
801
|
-
function handleConnectionRestoration(
|
|
820
|
+
function handleConnectionRestoration(_x10) {
|
|
802
821
|
return _handleConnectionRestoration.apply(this, arguments);
|
|
803
822
|
}
|
|
804
823
|
return handleConnectionRestoration;
|
|
@@ -847,11 +866,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
847
866
|
}
|
|
848
867
|
return _context17.abrupt("return", finalError);
|
|
849
868
|
case 14:
|
|
850
|
-
_this5.lineEmitter(
|
|
869
|
+
_this5.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
851
870
|
_context17.next = 18;
|
|
852
871
|
break;
|
|
853
872
|
case 17:
|
|
854
|
-
_this5.lineEmitter(
|
|
873
|
+
_this5.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
855
874
|
case 18:
|
|
856
875
|
return _context17.abrupt("return", false);
|
|
857
876
|
case 19:
|
|
@@ -860,7 +879,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
860
879
|
}
|
|
861
880
|
}, _callee17);
|
|
862
881
|
}));
|
|
863
|
-
return function (
|
|
882
|
+
return function (_x11, _x12) {
|
|
864
883
|
return _ref8.apply(this, arguments);
|
|
865
884
|
};
|
|
866
885
|
}();
|
|
@@ -925,133 +944,120 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
925
944
|
_this$deviceInfo$devi,
|
|
926
945
|
resp,
|
|
927
946
|
body,
|
|
928
|
-
error,
|
|
929
947
|
_args19 = arguments;
|
|
930
948
|
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
931
949
|
while (1) switch (_context19.prev = _context19.next) {
|
|
932
950
|
case 0:
|
|
933
951
|
servers = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : this.primaryMobiusUris;
|
|
934
952
|
abort = false;
|
|
953
|
+
this.retryAfter = undefined;
|
|
935
954
|
if (!this.failoverImmediately) {
|
|
936
|
-
_context19.next =
|
|
955
|
+
_context19.next = 5;
|
|
937
956
|
break;
|
|
938
957
|
}
|
|
939
958
|
return _context19.abrupt("return", abort);
|
|
940
|
-
case
|
|
959
|
+
case 5:
|
|
941
960
|
if (!this.isDeviceRegistered()) {
|
|
942
|
-
_context19.next =
|
|
961
|
+
_context19.next = 8;
|
|
943
962
|
break;
|
|
944
963
|
}
|
|
945
964
|
_Logger.default.log("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), {
|
|
946
965
|
file: _constants.REGISTRATION_FILE,
|
|
947
|
-
method:
|
|
966
|
+
method: _constants.REGISTER_UTIL
|
|
948
967
|
});
|
|
949
968
|
return _context19.abrupt("return", abort);
|
|
950
|
-
case
|
|
969
|
+
case 8:
|
|
951
970
|
_iterator = _createForOfIteratorHelper(servers);
|
|
952
|
-
_context19.prev =
|
|
971
|
+
_context19.prev = 9;
|
|
953
972
|
_iterator.s();
|
|
954
|
-
case
|
|
973
|
+
case 11:
|
|
955
974
|
if ((_step = _iterator.n()).done) {
|
|
956
|
-
_context19.next =
|
|
975
|
+
_context19.next = 47;
|
|
957
976
|
break;
|
|
958
977
|
}
|
|
959
978
|
url = _step.value;
|
|
960
|
-
_context19.prev =
|
|
979
|
+
_context19.prev = 13;
|
|
961
980
|
abort = false;
|
|
962
|
-
this.registrationStatus =
|
|
963
|
-
this.lineEmitter(
|
|
981
|
+
this.registrationStatus = _types2.RegistrationStatus.INACTIVE;
|
|
982
|
+
this.lineEmitter(_types3.LINE_EVENTS.CONNECTING);
|
|
964
983
|
_Logger.default.log("[".concat(caller, "] : Mobius url to contact: ").concat(url), {
|
|
965
984
|
file: _constants.REGISTRATION_FILE,
|
|
966
|
-
method:
|
|
985
|
+
method: _constants.REGISTER_UTIL
|
|
967
986
|
});
|
|
968
987
|
// eslint-disable-next-line no-await-in-loop
|
|
969
|
-
_context19.next =
|
|
988
|
+
_context19.next = 20;
|
|
970
989
|
return this.postRegistration(url);
|
|
971
|
-
case
|
|
990
|
+
case 20:
|
|
972
991
|
resp = _context19.sent;
|
|
973
992
|
this.deviceInfo = resp.body;
|
|
974
|
-
this.registrationStatus =
|
|
975
|
-
this.lineEmitter(
|
|
993
|
+
this.registrationStatus = _types2.RegistrationStatus.ACTIVE;
|
|
994
|
+
this.lineEmitter(_types3.LINE_EVENTS.REGISTERED, resp.body);
|
|
976
995
|
this.setActiveMobiusUrl(url);
|
|
977
996
|
this.setIntervalValues(this.deviceInfo);
|
|
978
997
|
this.metricManager.setDeviceInfo(this.deviceInfo);
|
|
979
|
-
this.metricManager.submitRegistrationMetric(
|
|
998
|
+
this.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, undefined);
|
|
980
999
|
this.startKeepaliveTimer((_this$deviceInfo$devi = this.deviceInfo.device) === null || _this$deviceInfo$devi === void 0 ? void 0 : _this$deviceInfo$devi.uri, this.deviceInfo.keepaliveInterval);
|
|
981
1000
|
this.initiateFailback();
|
|
982
|
-
return _context19.abrupt("break",
|
|
983
|
-
case
|
|
984
|
-
_context19.prev =
|
|
985
|
-
_context19.t0 = _context19["catch"](
|
|
1001
|
+
return _context19.abrupt("break", 47);
|
|
1002
|
+
case 33:
|
|
1003
|
+
_context19.prev = 33;
|
|
1004
|
+
_context19.t0 = _context19["catch"](13);
|
|
986
1005
|
body = _context19.t0; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
|
|
987
|
-
_context19.next =
|
|
1006
|
+
_context19.next = 38;
|
|
988
1007
|
return (0, _common.handleRegistrationErrors)(body, function (clientError, finalError) {
|
|
989
1008
|
if (finalError) {
|
|
990
|
-
_this6.lineEmitter(
|
|
1009
|
+
_this6.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
991
1010
|
} else {
|
|
992
|
-
_this6.lineEmitter(
|
|
1011
|
+
_this6.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
993
1012
|
}
|
|
994
|
-
_this6.metricManager.submitRegistrationMetric(
|
|
1013
|
+
_this6.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION_ERROR, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, clientError);
|
|
995
1014
|
}, {
|
|
996
|
-
method:
|
|
1015
|
+
method: caller,
|
|
997
1016
|
file: _constants.REGISTRATION_FILE
|
|
1017
|
+
}, function (retryAfter, retryCaller) {
|
|
1018
|
+
return _this6.handle429Retry(retryAfter, retryCaller);
|
|
998
1019
|
}, this.restoreRegistrationCallBack());
|
|
999
|
-
case
|
|
1020
|
+
case 38:
|
|
1000
1021
|
abort = _context19.sent;
|
|
1001
|
-
if (!(this.registrationStatus ===
|
|
1002
|
-
_context19.next =
|
|
1022
|
+
if (!(this.registrationStatus === _types2.RegistrationStatus.ACTIVE)) {
|
|
1023
|
+
_context19.next = 42;
|
|
1003
1024
|
break;
|
|
1004
1025
|
}
|
|
1005
1026
|
_Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(this.activeMobiusUrl), {
|
|
1006
1027
|
file: _constants.REGISTRATION_FILE,
|
|
1007
1028
|
method: this.attemptRegistrationWithServers.name
|
|
1008
1029
|
});
|
|
1009
|
-
return _context19.abrupt("break",
|
|
1010
|
-
case
|
|
1030
|
+
return _context19.abrupt("break", 47);
|
|
1031
|
+
case 42:
|
|
1011
1032
|
if (!abort) {
|
|
1012
|
-
_context19.next =
|
|
1013
|
-
break;
|
|
1014
|
-
}
|
|
1015
|
-
this.setStatus(_types3.RegistrationStatus.INACTIVE);
|
|
1016
|
-
return _context19.abrupt("break", 55);
|
|
1017
|
-
case 46:
|
|
1018
|
-
if (!(caller === this.executeFailback.name)) {
|
|
1019
|
-
_context19.next = 53;
|
|
1033
|
+
_context19.next = 45;
|
|
1020
1034
|
break;
|
|
1021
1035
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
_context19.next = 51;
|
|
1028
|
-
return this.scheduleFailback429Retry();
|
|
1029
|
-
case 51:
|
|
1030
|
-
abort = true;
|
|
1031
|
-
return _context19.abrupt("break", 55);
|
|
1032
|
-
case 53:
|
|
1033
|
-
_context19.next = 10;
|
|
1036
|
+
this.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1037
|
+
return _context19.abrupt("break", 47);
|
|
1038
|
+
case 45:
|
|
1039
|
+
_context19.next = 11;
|
|
1034
1040
|
break;
|
|
1035
|
-
case
|
|
1036
|
-
_context19.next =
|
|
1041
|
+
case 47:
|
|
1042
|
+
_context19.next = 52;
|
|
1037
1043
|
break;
|
|
1038
|
-
case
|
|
1039
|
-
_context19.prev =
|
|
1040
|
-
_context19.t1 = _context19["catch"](
|
|
1044
|
+
case 49:
|
|
1045
|
+
_context19.prev = 49;
|
|
1046
|
+
_context19.t1 = _context19["catch"](9);
|
|
1041
1047
|
_iterator.e(_context19.t1);
|
|
1042
|
-
case
|
|
1043
|
-
_context19.prev =
|
|
1048
|
+
case 52:
|
|
1049
|
+
_context19.prev = 52;
|
|
1044
1050
|
_iterator.f();
|
|
1045
|
-
return _context19.finish(
|
|
1046
|
-
case
|
|
1051
|
+
return _context19.finish(52);
|
|
1052
|
+
case 55:
|
|
1047
1053
|
return _context19.abrupt("return", abort);
|
|
1048
|
-
case
|
|
1054
|
+
case 56:
|
|
1049
1055
|
case "end":
|
|
1050
1056
|
return _context19.stop();
|
|
1051
1057
|
}
|
|
1052
|
-
}, _callee19, this, [[
|
|
1058
|
+
}, _callee19, this, [[9, 49, 52, 55], [13, 33]]);
|
|
1053
1059
|
}));
|
|
1054
|
-
function attemptRegistrationWithServers(
|
|
1060
|
+
function attemptRegistrationWithServers(_x13) {
|
|
1055
1061
|
return _attemptRegistrationWithServers.apply(this, arguments);
|
|
1056
1062
|
}
|
|
1057
1063
|
return attemptRegistrationWithServers;
|
|
@@ -1094,7 +1100,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1094
1100
|
res = _context20.sent;
|
|
1095
1101
|
_Logger.default.info("Sent Keepalive, status: ".concat(res.statusCode), logContext);
|
|
1096
1102
|
if (keepAliveRetryCount > 0) {
|
|
1097
|
-
_this7.lineEmitter(
|
|
1103
|
+
_this7.lineEmitter(_types3.LINE_EVENTS.RECONNECTED);
|
|
1098
1104
|
}
|
|
1099
1105
|
keepAliveRetryCount = 0;
|
|
1100
1106
|
_context20.next = 30;
|
|
@@ -1108,9 +1114,9 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1108
1114
|
_context20.next = 17;
|
|
1109
1115
|
return (0, _common.handleRegistrationErrors)(error, function (clientError, finalError) {
|
|
1110
1116
|
if (finalError) {
|
|
1111
|
-
_this7.lineEmitter(
|
|
1117
|
+
_this7.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
1112
1118
|
}
|
|
1113
|
-
_this7.metricManager.submitRegistrationMetric(
|
|
1119
|
+
_this7.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, clientError);
|
|
1114
1120
|
}, {
|
|
1115
1121
|
method: _this7.startKeepaliveTimer.name,
|
|
1116
1122
|
file: _constants.REGISTRATION_FILE
|
|
@@ -1122,10 +1128,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1122
1128
|
break;
|
|
1123
1129
|
}
|
|
1124
1130
|
_this7.failoverImmediately = _this7.isCCFlow;
|
|
1125
|
-
_this7.setStatus(
|
|
1131
|
+
_this7.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1126
1132
|
_this7.clearKeepaliveTimer();
|
|
1127
1133
|
_this7.clearFailbackTimer();
|
|
1128
|
-
_this7.lineEmitter(
|
|
1134
|
+
_this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
1129
1135
|
if (abort) {
|
|
1130
1136
|
_context20.next = 27;
|
|
1131
1137
|
break;
|
|
@@ -1136,7 +1142,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1136
1142
|
_context20.next = 30;
|
|
1137
1143
|
break;
|
|
1138
1144
|
case 29:
|
|
1139
|
-
_this7.lineEmitter(
|
|
1145
|
+
_this7.lineEmitter(_types3.LINE_EVENTS.RECONNECTING);
|
|
1140
1146
|
case 30:
|
|
1141
1147
|
case "end":
|
|
1142
1148
|
return _context20.stop();
|
|
@@ -1187,7 +1193,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1187
1193
|
_Logger.default.warn("Delete failed with Mobius", {});
|
|
1188
1194
|
case 8:
|
|
1189
1195
|
this.clearKeepaliveTimer();
|
|
1190
|
-
this.setStatus(
|
|
1196
|
+
this.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1191
1197
|
case 10:
|
|
1192
1198
|
case "end":
|
|
1193
1199
|
return _context22.stop();
|
|
@@ -1238,7 +1244,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1238
1244
|
var stringToReplace = "".concat(_constants.DEVICES_ENDPOINT_RESOURCE, "/").concat(restoreData.devices[0].deviceId);
|
|
1239
1245
|
var uri = restoreData.devices[0].uri.replace(stringToReplace, '');
|
|
1240
1246
|
this.setActiveMobiusUrl(uri);
|
|
1241
|
-
this.registrationStatus =
|
|
1247
|
+
this.registrationStatus = _types2.RegistrationStatus.ACTIVE;
|
|
1242
1248
|
return true;
|
|
1243
1249
|
}
|
|
1244
1250
|
return false;
|
|
@@ -1295,7 +1301,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1295
1301
|
}
|
|
1296
1302
|
}, _callee23, this);
|
|
1297
1303
|
}));
|
|
1298
|
-
function reconnectOnFailure(
|
|
1304
|
+
function reconnectOnFailure(_x14) {
|
|
1299
1305
|
return _reconnectOnFailure.apply(this, arguments);
|
|
1300
1306
|
}
|
|
1301
1307
|
return reconnectOnFailure;
|