@webex/calling 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.3

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.
Files changed (39) hide show
  1. package/dist/CallingClient/constants.js +4 -2
  2. package/dist/CallingClient/constants.js.map +1 -1
  3. package/dist/CallingClient/line/index.js +4 -0
  4. package/dist/CallingClient/line/index.js.map +1 -1
  5. package/dist/CallingClient/line/line.test.js +47 -10
  6. package/dist/CallingClient/line/line.test.js.map +1 -1
  7. package/dist/CallingClient/registration/register.js +466 -390
  8. package/dist/CallingClient/registration/register.js.map +1 -1
  9. package/dist/CallingClient/registration/register.test.js +349 -80
  10. package/dist/CallingClient/registration/register.test.js.map +1 -1
  11. package/dist/CallingClient/registration/types.js +26 -0
  12. package/dist/CallingClient/registration/types.js.map +1 -1
  13. package/dist/Errors/types.js +2 -0
  14. package/dist/Errors/types.js.map +1 -1
  15. package/dist/Events/types.js.map +1 -1
  16. package/dist/common/Utils.js +85 -50
  17. package/dist/common/Utils.js.map +1 -1
  18. package/dist/common/Utils.test.js +270 -195
  19. package/dist/common/Utils.test.js.map +1 -1
  20. package/dist/module/CallingClient/constants.js +2 -0
  21. package/dist/module/CallingClient/line/index.js +2 -0
  22. package/dist/module/CallingClient/registration/register.js +36 -10
  23. package/dist/module/CallingClient/registration/types.js +5 -1
  24. package/dist/module/Errors/types.js +2 -0
  25. package/dist/module/common/Utils.js +26 -8
  26. package/dist/types/CallingClient/constants.d.ts +2 -0
  27. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  28. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  29. package/dist/types/CallingClient/registration/register.d.ts +2 -1
  30. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  31. package/dist/types/CallingClient/registration/types.d.ts +23 -0
  32. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  33. package/dist/types/Errors/types.d.ts +2 -0
  34. package/dist/types/Errors/types.d.ts.map +1 -1
  35. package/dist/types/Events/types.d.ts +1 -1
  36. package/dist/types/Events/types.d.ts.map +1 -1
  37. package/dist/types/common/Utils.d.ts +2 -5
  38. package/dist/types/common/Utils.d.ts.map +1 -1
  39. package/package.json +10 -10
@@ -32,10 +32,11 @@ var _types = require("../../Metrics/types");
32
32
  var _Metrics = require("../../Metrics");
33
33
  var _calling = require("../calling");
34
34
  var _Logger = _interopRequireDefault(require("../../Logger"));
35
+ var _types2 = require("./types");
35
36
  var _SDKConnector = _interopRequireDefault(require("../../SDKConnector"));
36
- var _types2 = require("../../common/types");
37
+ var _types3 = require("../../common/types");
37
38
  var _constants2 = require("../constants");
38
- var _types3 = require("../line/types");
39
+ var _types4 = require("../line/types");
39
40
  var _request = require("../utils/request");
40
41
  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; } } }; }
41
42
  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; } }
@@ -79,13 +80,13 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
79
80
  this.jwe = jwe;
80
81
  this.sdkConnector = _SDKConnector.default;
81
82
  this.serviceData = serviceData;
82
- this.isCCFlow = serviceData.indicator === _types2.ServiceIndicator.CONTACT_CENTER;
83
+ this.isCCFlow = serviceData.indicator === _types3.ServiceIndicator.CONTACT_CENTER;
83
84
  if (!this.sdkConnector.getWebex()) {
84
85
  _SDKConnector.default.setWebex(webex);
85
86
  }
86
87
  this.webex = this.sdkConnector.getWebex();
87
88
  this.userId = this.webex.internal.device.userId;
88
- this.registrationStatus = _types2.RegistrationStatus.IDLE;
89
+ this.registrationStatus = _types3.RegistrationStatus.IDLE;
89
90
  this.failback429RetryAttempts = 0;
90
91
  _Logger.default.setLogger(logLevel, _constants2.REGISTRATION_FILE);
91
92
  this.rehomingIntervalMin = _constants2.DEFAULT_REHOMING_INTERVAL_MIN;
@@ -235,9 +236,9 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
235
236
  case 0:
236
237
  requestObj = {
237
238
  uri: "".concat(url).concat(_constants2.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId),
238
- method: _types2.HTTP_METHODS.DELETE,
239
+ method: _types3.HTTP_METHODS.DELETE,
239
240
  headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
240
- service: _types2.ALLOWED_SERVICES.MOBIUS
241
+ service: _types3.ALLOWED_SERVICES.MOBIUS
241
242
  };
242
243
  if (this.apiRequest.isSocketEnabled()) {
243
244
  // @ts-ignore - body is added for mobius wss support, it is not used for mobius http
@@ -262,8 +263,8 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
262
263
  _context2.next = 4;
263
264
  return (0, _common.uploadLogs)();
264
265
  case 4:
265
- this.setStatus(_types2.RegistrationStatus.INACTIVE);
266
- this.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
266
+ this.setStatus(_types3.RegistrationStatus.INACTIVE);
267
+ this.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
267
268
  return _context2.abrupt("return", response);
268
269
  case 5:
269
270
  case "end":
@@ -298,10 +299,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
298
299
  };
299
300
  return _context3.abrupt("return", this.apiRequest.makeRequest({
300
301
  uri: "".concat(url, "device"),
301
- method: _types2.HTTP_METHODS.POST,
302
+ method: _types3.HTTP_METHODS.POST,
302
303
  headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceInfo.clientDeviceUri), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
303
304
  body: deviceInfo,
304
- service: _types2.ALLOWED_SERVICES.MOBIUS
305
+ service: _types3.ALLOWED_SERVICES.MOBIUS
305
306
  }));
306
307
  case 1:
307
308
  case "end":
@@ -459,6 +460,60 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
459
460
  }
460
461
  return handle404KeepaliveFailure;
461
462
  }()
463
+ /**
464
+ * Hard stops a calling session that Mobius reported as superseded, in response to a
465
+ * `409 Conflict` on a keepalive (device_status) message.
466
+ *
467
+ * Mobius returns 409 when this deviceId is gone but the same user still has an active
468
+ * registration elsewhere (typically calling opened in another browser tab, which
469
+ * superseded this device). Re-registering here would unregister the other device and
470
+ * restart the registration ping-pong between the two, so no registration is attempted:
471
+ * the keepalive worker is terminated, the Mobius WebSocket is closed and the consumer
472
+ * receives `LINE_EVENTS.UNREGISTERED` carrying `lineError` as the reason.
473
+ *
474
+ * @param lineError - Superseded-session error built by `handleRegistrationErrors`.
475
+ * @param error - The keepalive failure payload forwarded by the keepalive worker.
476
+ * @param serverType - Mobius server type the keepalive was sent to, for metrics.
477
+ * @param keepaliveRetryCount - Consecutive keepalive failures reported by the worker.
478
+ */
479
+ )
480
+ }, {
481
+ key: "handle409KeepaliveFailure",
482
+ value: (function () {
483
+ var _handle409KeepaliveFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(lineError, error, serverType, keepaliveRetryCount) {
484
+ var _error$headers$tracki, _error$headers;
485
+ var loggerContext;
486
+ return _regenerator.default.wrap(function (_context7) {
487
+ while (1) switch (_context7.prev = _context7.next) {
488
+ case 0:
489
+ loggerContext = {
490
+ file: _constants2.REGISTRATION_FILE,
491
+ method: _constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE
492
+ };
493
+ _Logger.default.warn("Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ".concat(keepaliveRetryCount), loggerContext);
494
+
495
+ /* Stop the keepalive worker up front so no further keepalive is sent while cleanup waits on the mutex. */
496
+ this.clearKeepaliveTimer();
497
+ this.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.KEEPALIVE_ERROR, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, _constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE, 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 : '', keepaliveRetryCount, lineError);
498
+ _context7.next = 1;
499
+ return this.registrationCleanup(_constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE, {
500
+ reason: _types2.HARD_STOP_REASON.SESSION_SUPERSEDED,
501
+ error: lineError
502
+ });
503
+ case 1:
504
+ _context7.next = 2;
505
+ return (0, _common.uploadLogs)();
506
+ case 2:
507
+ case "end":
508
+ return _context7.stop();
509
+ }
510
+ }, _callee7, this);
511
+ }));
512
+ function handle409KeepaliveFailure(_x7, _x8, _x9, _x0) {
513
+ return _handle409KeepaliveFailure.apply(this, arguments);
514
+ }
515
+ return handle409KeepaliveFailure;
516
+ }()
462
517
  /**
463
518
  * Callback for handling 429 retry response from the server
464
519
  */
@@ -466,21 +521,21 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
466
521
  }, {
467
522
  key: "handle429Retry",
468
523
  value: (function () {
469
- var _handle429Retry = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8(retryAfter, caller) {
524
+ var _handle429Retry = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(retryAfter, caller) {
470
525
  var _this2 = this;
471
526
  var interval, abort;
472
- return _regenerator.default.wrap(function (_context8) {
473
- while (1) switch (_context8.prev = _context8.next) {
527
+ return _regenerator.default.wrap(function (_context9) {
528
+ while (1) switch (_context9.prev = _context9.next) {
474
529
  case 0:
475
530
  if (!(caller === _constants2.FAILBACK_UTIL)) {
476
- _context8.next = 4;
531
+ _context9.next = 4;
477
532
  break;
478
533
  }
479
534
  if (!(this.failback429RetryAttempts >= _constants2.REG_FAILBACK_429_MAX_RETRIES)) {
480
- _context8.next = 1;
535
+ _context9.next = 1;
481
536
  break;
482
537
  }
483
- return _context8.abrupt("return");
538
+ return _context9.abrupt("return");
484
539
  case 1:
485
540
  this.clearFailbackTimer();
486
541
  this.failback429RetryAttempts += 1;
@@ -491,26 +546,26 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
491
546
  interval = this.getRegRetryInterval(this.failback429RetryAttempts);
492
547
  this.startFailbackTimer(interval);
493
548
  this.scheduled429Retry = true;
494
- _context8.next = 2;
549
+ _context9.next = 2;
495
550
  return this.restorePreviousRegistration(_constants2.REG_429_RETRY_UTIL);
496
551
  case 2:
497
- abort = _context8.sent;
552
+ abort = _context9.sent;
498
553
  if (!(!abort && !this.isDeviceRegistered())) {
499
- _context8.next = 3;
554
+ _context9.next = 3;
500
555
  break;
501
556
  }
502
- _context8.next = 3;
557
+ _context9.next = 3;
503
558
  return this.restartRegistration(_constants2.REG_429_RETRY_UTIL);
504
559
  case 3:
505
- _context8.next = 5;
560
+ _context9.next = 5;
506
561
  break;
507
562
  case 4:
508
563
  if (caller === _constants2.KEEPALIVE_UTIL) {
509
564
  this.clearKeepaliveTimer();
510
- setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
565
+ setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
511
566
  var _this2$deviceInfo$dev;
512
- return _regenerator.default.wrap(function (_context7) {
513
- while (1) switch (_context7.prev = _context7.next) {
567
+ return _regenerator.default.wrap(function (_context8) {
568
+ while (1) switch (_context8.prev = _context8.next) {
514
569
  case 0:
515
570
  _Logger.default.log("Resuming keepalive after ".concat(retryAfter, " seconds"), {
516
571
  file: _constants2.REGISTRATION_FILE,
@@ -518,24 +573,24 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
518
573
  });
519
574
 
520
575
  // Resume the keepalive after waiting for the retry after period
521
- _context7.next = 1;
576
+ _context8.next = 1;
522
577
  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');
523
578
  case 1:
524
579
  case "end":
525
- return _context7.stop();
580
+ return _context8.stop();
526
581
  }
527
- }, _callee7);
582
+ }, _callee8);
528
583
  })), (retryAfter - Number(this.deviceInfo.keepaliveInterval || 0)) * 1000);
529
584
  } else {
530
585
  this.retryAfter = retryAfter;
531
586
  }
532
587
  case 5:
533
588
  case "end":
534
- return _context8.stop();
589
+ return _context9.stop();
535
590
  }
536
- }, _callee8, this);
591
+ }, _callee9, this);
537
592
  }));
538
- function handle429Retry(_x7, _x8) {
593
+ function handle429Retry(_x1, _x10) {
539
594
  return _handle429Retry.apply(this, arguments);
540
595
  }
541
596
  return handle429Retry;
@@ -564,7 +619,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
564
619
  }, {
565
620
  key: "startFailoverTimer",
566
621
  value: (function () {
567
- var _startFailoverTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
622
+ var _startFailoverTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
568
623
  var _this3 = this;
569
624
  var attempt,
570
625
  timeElapsed,
@@ -574,12 +629,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
574
629
  excessVal,
575
630
  abort,
576
631
  scheduledTime,
577
- _args11 = arguments;
578
- return _regenerator.default.wrap(function (_context11) {
579
- while (1) switch (_context11.prev = _context11.next) {
632
+ _args12 = arguments;
633
+ return _regenerator.default.wrap(function (_context12) {
634
+ while (1) switch (_context12.prev = _context12.next) {
580
635
  case 0:
581
- attempt = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : 1;
582
- timeElapsed = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : 0;
636
+ attempt = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : 1;
637
+ timeElapsed = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : 0;
583
638
  loggerContext = {
584
639
  file: _constants2.REGISTRATION_FILE,
585
640
  method: _constants2.FAILOVER_UTIL
@@ -594,7 +649,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
594
649
  this.failoverImmediately = this.retryAfter + timeElapsed > TIMER_THRESHOLD;
595
650
  }
596
651
  if (!(interval > _constants2.BASE_REG_RETRY_TIMER_VAL_IN_SEC && !this.failoverImmediately)) {
597
- _context11.next = 1;
652
+ _context12.next = 1;
598
653
  break;
599
654
  }
600
655
  scheduledTime = Math.floor((0, _now.default)() / 1000);
@@ -607,53 +662,53 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
607
662
  retryScheduledTime: scheduledTime,
608
663
  serverType: 'primary'
609
664
  });
610
- setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
611
- return _regenerator.default.wrap(function (_context0) {
612
- while (1) switch (_context0.prev = _context0.next) {
665
+ setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
666
+ return _regenerator.default.wrap(function (_context1) {
667
+ while (1) switch (_context1.prev = _context1.next) {
613
668
  case 0:
614
- _context0.next = 1;
615
- return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
669
+ _context1.next = 1;
670
+ return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
616
671
  var currentTime;
617
- return _regenerator.default.wrap(function (_context9) {
618
- while (1) switch (_context9.prev = _context9.next) {
672
+ return _regenerator.default.wrap(function (_context0) {
673
+ while (1) switch (_context0.prev = _context0.next) {
619
674
  case 0:
620
- _context9.next = 1;
675
+ _context0.next = 1;
621
676
  return _this3.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL);
622
677
  case 1:
623
- abort = _context9.sent;
678
+ abort = _context0.sent;
624
679
  currentTime = Math.floor((0, _now.default)() / 1000);
625
680
  if (!(!abort && !_this3.isDeviceRegistered())) {
626
- _context9.next = 2;
681
+ _context0.next = 2;
627
682
  break;
628
683
  }
629
- _context9.next = 2;
684
+ _context0.next = 2;
630
685
  return _this3.startFailoverTimer(attempt + 1, timeElapsed + (currentTime - scheduledTime));
631
686
  case 2:
632
687
  case "end":
633
- return _context9.stop();
688
+ return _context0.stop();
634
689
  }
635
- }, _callee9);
690
+ }, _callee0);
636
691
  })));
637
692
  case 1:
638
693
  case "end":
639
- return _context0.stop();
694
+ return _context1.stop();
640
695
  }
641
- }, _callee0);
696
+ }, _callee1);
642
697
  })), interval * _constants2.SEC_TO_MSEC_MFACTOR);
643
698
  _Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
644
- _context11.next = 7;
699
+ _context12.next = 7;
645
700
  break;
646
701
  case 1:
647
702
  if (!this.backupMobiusUris.length) {
648
- _context11.next = 5;
703
+ _context12.next = 5;
649
704
  break;
650
705
  }
651
706
  if (!this.apiRequest.isSocketEnabled()) {
652
- _context11.next = 3;
707
+ _context12.next = 3;
653
708
  break;
654
709
  }
655
710
  _Logger.default.info('Disconnecting from primary Mobius socket for failover to backup servers', loggerContext);
656
- _context11.next = 2;
711
+ _context12.next = 2;
657
712
  return this.apiRequest.disconnectFromMobiusSocket({
658
713
  code: 3050,
659
714
  reason: 'done (permanent)'
@@ -669,66 +724,66 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
669
724
  });
670
725
  _Logger.default.info('Failing over to backup servers.', loggerContext);
671
726
  this.failoverImmediately = false;
672
- _context11.next = 4;
727
+ _context12.next = 4;
673
728
  return this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, this.backupMobiusUris);
674
729
  case 4:
675
- abort = _context11.sent;
730
+ abort = _context12.sent;
676
731
  if (!abort && !this.isDeviceRegistered()) {
677
732
  interval = this.getRegRetryInterval();
678
733
  if (this.retryAfter != null && this.retryAfter < _constants2.RETRY_TIMER_UPPER_LIMIT) {
679
734
  interval = interval < this.retryAfter ? this.retryAfter : interval;
680
735
  }
681
- setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
682
- return _regenerator.default.wrap(function (_context10) {
683
- while (1) switch (_context10.prev = _context10.next) {
736
+ setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
737
+ return _regenerator.default.wrap(function (_context11) {
738
+ while (1) switch (_context11.prev = _context11.next) {
684
739
  case 0:
685
- _context10.next = 1;
686
- return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
687
- return _regenerator.default.wrap(function (_context1) {
688
- while (1) switch (_context1.prev = _context1.next) {
740
+ _context11.next = 1;
741
+ return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
742
+ return _regenerator.default.wrap(function (_context10) {
743
+ while (1) switch (_context10.prev = _context10.next) {
689
744
  case 0:
690
- _context1.next = 1;
745
+ _context10.next = 1;
691
746
  return _this3.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, _this3.backupMobiusUris);
692
747
  case 1:
693
- abort = _context1.sent;
748
+ abort = _context10.sent;
694
749
  if (!(!abort && !_this3.isDeviceRegistered())) {
695
- _context1.next = 3;
750
+ _context10.next = 3;
696
751
  break;
697
752
  }
698
- _context1.next = 2;
753
+ _context10.next = 2;
699
754
  return (0, _common.uploadLogs)();
700
755
  case 2:
701
756
  (0, _common.emitFinalFailure)(function (clientError) {
702
- _this3.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
757
+ _this3.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
703
758
  }, loggerContext);
704
759
  case 3:
705
760
  case "end":
706
- return _context1.stop();
761
+ return _context10.stop();
707
762
  }
708
- }, _callee1);
763
+ }, _callee10);
709
764
  })));
710
765
  case 1:
711
766
  case "end":
712
- return _context10.stop();
767
+ return _context11.stop();
713
768
  }
714
- }, _callee10);
769
+ }, _callee11);
715
770
  })), interval * _constants2.SEC_TO_MSEC_MFACTOR);
716
771
  _Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
717
772
  }
718
- _context11.next = 7;
773
+ _context12.next = 7;
719
774
  break;
720
775
  case 5:
721
- _context11.next = 6;
776
+ _context12.next = 6;
722
777
  return (0, _common.uploadLogs)();
723
778
  case 6:
724
779
  (0, _common.emitFinalFailure)(function (clientError) {
725
- _this3.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
780
+ _this3.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
726
781
  }, loggerContext, interval < 0 ? 'Timer threshold exceeded during failover' : undefined);
727
782
  case 7:
728
783
  case "end":
729
- return _context11.stop();
784
+ return _context12.stop();
730
785
  }
731
- }, _callee11, this);
786
+ }, _callee12, this);
732
787
  }));
733
788
  function startFailoverTimer() {
734
789
  return _startFailoverTimer.apply(this, arguments);
@@ -750,27 +805,27 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
750
805
  }, {
751
806
  key: "postKeepAlive",
752
807
  value: function () {
753
- var _postKeepAlive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12(deviceUrl, url) {
808
+ var _postKeepAlive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13(deviceUrl, url) {
754
809
  var _this$deviceInfo$devi;
755
- return _regenerator.default.wrap(function (_context12) {
756
- while (1) switch (_context12.prev = _context12.next) {
810
+ return _regenerator.default.wrap(function (_context13) {
811
+ while (1) switch (_context13.prev = _context13.next) {
757
812
  case 0:
758
- return _context12.abrupt("return", this.apiRequest.makeRequest({
813
+ return _context13.abrupt("return", this.apiRequest.makeRequest({
759
814
  uri: "".concat(url, "/status"),
760
- method: _types2.HTTP_METHODS.POST,
815
+ method: _types3.HTTP_METHODS.POST,
761
816
  headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
762
817
  body: {
763
818
  deviceId: (_this$deviceInfo$devi = this.deviceInfo.device) === null || _this$deviceInfo$devi === void 0 ? void 0 : _this$deviceInfo$devi.deviceId
764
819
  },
765
- service: _types2.ALLOWED_SERVICES.MOBIUS
820
+ service: _types3.ALLOWED_SERVICES.MOBIUS
766
821
  }));
767
822
  case 1:
768
823
  case "end":
769
- return _context12.stop();
824
+ return _context13.stop();
770
825
  }
771
- }, _callee12, this);
826
+ }, _callee13, this);
772
827
  }));
773
- function postKeepAlive(_x9, _x0) {
828
+ function postKeepAlive(_x11, _x12) {
774
829
  return _postKeepAlive.apply(this, arguments);
775
830
  }
776
831
  return postKeepAlive;
@@ -778,34 +833,34 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
778
833
  }, {
779
834
  key: "isPrimaryActive",
780
835
  value: function () {
781
- var _isPrimaryActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
836
+ var _isPrimaryActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
782
837
  var status, _iterator, _step, mobiusUrl, baseUri, response, _ref7, statusCode, _t3, _t4;
783
- return _regenerator.default.wrap(function (_context13) {
784
- while (1) switch (_context13.prev = _context13.next) {
838
+ return _regenerator.default.wrap(function (_context14) {
839
+ while (1) switch (_context14.prev = _context14.next) {
785
840
  case 0:
786
841
  _iterator = _createForOfIteratorHelper(this.primaryMobiusUris);
787
- _context13.prev = 1;
842
+ _context14.prev = 1;
788
843
  _iterator.s();
789
844
  case 2:
790
845
  if ((_step = _iterator.n()).done) {
791
- _context13.next = 8;
846
+ _context14.next = 8;
792
847
  break;
793
848
  }
794
849
  mobiusUrl = _step.value;
795
- _context13.prev = 3;
850
+ _context14.prev = 3;
796
851
  baseUri = mobiusUrl.replace(_constants2.URL_ENDPOINT, '/').replace('wss://', 'https://'); // eslint-disable-next-line no-await-in-loop
797
- _context13.next = 4;
852
+ _context14.next = 4;
798
853
  return this.webex.request({
799
854
  uri: "".concat(baseUri, "ping"),
800
- method: _types2.HTTP_METHODS.GET,
855
+ method: _types3.HTTP_METHODS.GET,
801
856
  headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, this.webex.internal.device.url), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
802
- service: _types2.ALLOWED_SERVICES.MOBIUS
857
+ service: _types3.ALLOWED_SERVICES.MOBIUS
803
858
  });
804
859
  case 4:
805
- response = _context13.sent;
860
+ response = _context14.sent;
806
861
  _ref7 = response, statusCode = _ref7.statusCode;
807
862
  if (!(statusCode === 200)) {
808
- _context13.next = 5;
863
+ _context14.next = 5;
809
864
  break;
810
865
  }
811
866
  _Logger.default.info("Ping successful for primary Mobius: ".concat(mobiusUrl), {
@@ -813,39 +868,39 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
813
868
  method: _constants2.FAILBACK_UTIL
814
869
  });
815
870
  status = 'up';
816
- return _context13.abrupt("continue", 8);
871
+ return _context14.abrupt("continue", 8);
817
872
  case 5:
818
- _context13.next = 7;
873
+ _context14.next = 7;
819
874
  break;
820
875
  case 6:
821
- _context13.prev = 6;
822
- _t3 = _context13["catch"](3);
876
+ _context14.prev = 6;
877
+ _t3 = _context14["catch"](3);
823
878
  _Logger.default.warn("Ping failed for primary Mobius: ".concat(mobiusUrl, " with error: ").concat((0, _stringify.default)(_t3)), {
824
879
  file: _constants2.REGISTRATION_FILE,
825
880
  method: _constants2.FAILBACK_UTIL
826
881
  });
827
882
  status = 'down';
828
883
  case 7:
829
- _context13.next = 2;
884
+ _context14.next = 2;
830
885
  break;
831
886
  case 8:
832
- _context13.next = 10;
887
+ _context14.next = 10;
833
888
  break;
834
889
  case 9:
835
- _context13.prev = 9;
836
- _t4 = _context13["catch"](1);
890
+ _context14.prev = 9;
891
+ _t4 = _context14["catch"](1);
837
892
  _iterator.e(_t4);
838
893
  case 10:
839
- _context13.prev = 10;
894
+ _context14.prev = 10;
840
895
  _iterator.f();
841
- return _context13.finish(10);
896
+ return _context14.finish(10);
842
897
  case 11:
843
- return _context13.abrupt("return", status === 'up');
898
+ return _context14.abrupt("return", status === 'up');
844
899
  case 12:
845
900
  case "end":
846
- return _context13.stop();
901
+ return _context14.stop();
847
902
  }
848
- }, _callee13, this, [[1, 9, 10, 11], [3, 6]]);
903
+ }, _callee14, this, [[1, 9, 10, 11], [3, 6]]);
849
904
  }));
850
905
  function isPrimaryActive() {
851
906
  return _isPrimaryActive.apply(this, arguments);
@@ -906,16 +961,16 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
906
961
  key: "startFailbackTimer",
907
962
  value: function startFailbackTimer(intervalInSeconds) {
908
963
  var _this4 = this;
909
- this.failbackTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
910
- return _regenerator.default.wrap(function (_context14) {
911
- while (1) switch (_context14.prev = _context14.next) {
964
+ this.failbackTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
965
+ return _regenerator.default.wrap(function (_context15) {
966
+ while (1) switch (_context15.prev = _context15.next) {
912
967
  case 0:
913
- return _context14.abrupt("return", _this4.executeFailback());
968
+ return _context15.abrupt("return", _this4.executeFailback());
914
969
  case 1:
915
970
  case "end":
916
- return _context14.stop();
971
+ return _context15.stop();
917
972
  }
918
- }, _callee14);
973
+ }, _callee15);
919
974
  })), intervalInSeconds * _constants2.SEC_TO_MSEC_MFACTOR);
920
975
  _Logger.default.log("Failback scheduled after ".concat(intervalInSeconds, " seconds."), {
921
976
  file: _constants2.REGISTRATION_FILE,
@@ -930,45 +985,45 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
930
985
  }, {
931
986
  key: "executeFailback",
932
987
  value: (function () {
933
- var _executeFailback = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
988
+ var _executeFailback = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
934
989
  var _this5 = this;
935
990
  var loggerContext;
936
- return _regenerator.default.wrap(function (_context16) {
937
- while (1) switch (_context16.prev = _context16.next) {
991
+ return _regenerator.default.wrap(function (_context17) {
992
+ while (1) switch (_context17.prev = _context17.next) {
938
993
  case 0:
939
994
  loggerContext = {
940
995
  file: _constants2.REGISTRATION_FILE,
941
996
  method: _constants2.METHODS.EXECUTE_FAILBACK
942
997
  };
943
998
  _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
944
- _context16.next = 1;
945
- return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
999
+ _context17.next = 1;
1000
+ return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
946
1001
  var primaryServerStatus, abort, abortNew;
947
- return _regenerator.default.wrap(function (_context15) {
948
- while (1) switch (_context15.prev = _context15.next) {
1002
+ return _regenerator.default.wrap(function (_context16) {
1003
+ while (1) switch (_context16.prev = _context16.next) {
949
1004
  case 0:
950
1005
  if (!_this5.isFailbackRequired()) {
951
- _context15.next = 13;
1006
+ _context16.next = 13;
952
1007
  break;
953
1008
  }
954
- _context15.next = 1;
1009
+ _context16.next = 1;
955
1010
  return _this5.isPrimaryActive();
956
1011
  case 1:
957
- primaryServerStatus = _context15.sent;
1012
+ primaryServerStatus = _context16.sent;
958
1013
  if (!((0, _keys.default)(_this5.callManager.getActiveCalls()).length === 0 && primaryServerStatus)) {
959
- _context15.next = 12;
1014
+ _context16.next = 12;
960
1015
  break;
961
1016
  }
962
1017
  _Logger.default.info("Attempting failback to primary.", loggerContext);
963
- _context15.next = 2;
1018
+ _context16.next = 2;
964
1019
  return _this5.deregister();
965
1020
  case 2:
966
1021
  if (!_this5.apiRequest.isSocketEnabled()) {
967
- _context15.next = 4;
1022
+ _context16.next = 4;
968
1023
  break;
969
1024
  }
970
1025
  _Logger.default.info('Disconnecting from backup Mobius socket for failback to primary', loggerContext);
971
- _context15.next = 3;
1026
+ _context16.next = 3;
972
1027
  return _this5.apiRequest.disconnectFromMobiusSocket({
973
1028
  code: 3050,
974
1029
  reason: 'done (permanent)'
@@ -976,41 +1031,41 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
976
1031
  case 3:
977
1032
  _Logger.default.log('Mobius socket disconnect complete prior to primary failback', loggerContext);
978
1033
  case 4:
979
- _context15.next = 5;
1034
+ _context16.next = 5;
980
1035
  return _this5.attemptRegistrationWithServers(_constants2.FAILBACK_UTIL);
981
1036
  case 5:
982
- abort = _context15.sent;
1037
+ abort = _context16.sent;
983
1038
  if (!(_this5.scheduled429Retry || abort || _this5.isDeviceRegistered())) {
984
- _context15.next = 6;
1039
+ _context16.next = 6;
985
1040
  break;
986
1041
  }
987
- return _context15.abrupt("return");
1042
+ return _context16.abrupt("return");
988
1043
  case 6:
989
- _context15.next = 7;
1044
+ _context16.next = 7;
990
1045
  return _this5.restorePreviousRegistration(_constants2.FAILBACK_UTIL);
991
1046
  case 7:
992
- abortNew = _context15.sent;
1047
+ abortNew = _context16.sent;
993
1048
  if (!abortNew) {
994
- _context15.next = 8;
1049
+ _context16.next = 8;
995
1050
  break;
996
1051
  }
997
1052
  _this5.clearFailbackTimer();
998
- return _context15.abrupt("return");
1053
+ return _context16.abrupt("return");
999
1054
  case 8:
1000
1055
  if (_this5.isDeviceRegistered()) {
1001
- _context15.next = 10;
1056
+ _context16.next = 10;
1002
1057
  break;
1003
1058
  }
1004
- _context15.next = 9;
1059
+ _context16.next = 9;
1005
1060
  return _this5.restartRegistration(loggerContext.method);
1006
1061
  case 9:
1007
- _context15.next = 11;
1062
+ _context16.next = 11;
1008
1063
  break;
1009
1064
  case 10:
1010
1065
  _this5.failbackTimer = undefined;
1011
1066
  _this5.initiateFailback();
1012
1067
  case 11:
1013
- _context15.next = 13;
1068
+ _context16.next = 13;
1014
1069
  break;
1015
1070
  case 12:
1016
1071
  _Logger.default.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', loggerContext);
@@ -1018,15 +1073,15 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1018
1073
  _this5.initiateFailback();
1019
1074
  case 13:
1020
1075
  case "end":
1021
- return _context15.stop();
1076
+ return _context16.stop();
1022
1077
  }
1023
- }, _callee15);
1078
+ }, _callee16);
1024
1079
  })));
1025
1080
  case 1:
1026
1081
  case "end":
1027
- return _context16.stop();
1082
+ return _context17.stop();
1028
1083
  }
1029
- }, _callee16, this);
1084
+ }, _callee17, this);
1030
1085
  }));
1031
1086
  function executeFailback() {
1032
1087
  return _executeFailback.apply(this, arguments);
@@ -1068,7 +1123,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1068
1123
  }, {
1069
1124
  key: "isDeviceRegistered",
1070
1125
  value: function isDeviceRegistered() {
1071
- return this.registrationStatus === _types2.RegistrationStatus.ACTIVE;
1126
+ return this.registrationStatus === _types3.RegistrationStatus.ACTIVE;
1072
1127
  }
1073
1128
  }, {
1074
1129
  key: "getStatus",
@@ -1089,10 +1144,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1089
1144
  }, {
1090
1145
  key: "restartRegistration",
1091
1146
  value: (function () {
1092
- var _restartRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17(caller) {
1147
+ var _restartRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18(caller) {
1093
1148
  var loggerContext, abort;
1094
- return _regenerator.default.wrap(function (_context17) {
1095
- while (1) switch (_context17.prev = _context17.next) {
1149
+ return _regenerator.default.wrap(function (_context18) {
1150
+ while (1) switch (_context18.prev = _context18.next) {
1096
1151
  case 0:
1097
1152
  loggerContext = {
1098
1153
  file: _constants2.REGISTRATION_FILE,
@@ -1106,25 +1161,25 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1106
1161
  */
1107
1162
  this.clearFailbackTimer();
1108
1163
  this.failback429RetryAttempts = 0;
1109
- _context17.next = 1;
1164
+ _context18.next = 1;
1110
1165
  return this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
1111
1166
  case 1:
1112
- abort = _context17.sent;
1167
+ abort = _context18.sent;
1113
1168
  if (!(!abort && !this.isDeviceRegistered())) {
1114
- _context17.next = 2;
1169
+ _context18.next = 2;
1115
1170
  break;
1116
1171
  }
1117
- _context17.next = 2;
1172
+ _context18.next = 2;
1118
1173
  return this.startFailoverTimer();
1119
1174
  case 2:
1120
1175
  _Logger.default.log("restartRegistration completed - caller: ".concat(caller, ", deviceRegistered: ").concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
1121
1176
  case 3:
1122
1177
  case "end":
1123
- return _context17.stop();
1178
+ return _context18.stop();
1124
1179
  }
1125
- }, _callee17, this);
1180
+ }, _callee18, this);
1126
1181
  }));
1127
- function restartRegistration(_x1) {
1182
+ function restartRegistration(_x13) {
1128
1183
  return _restartRegistration.apply(this, arguments);
1129
1184
  }
1130
1185
  return restartRegistration;
@@ -1138,23 +1193,23 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1138
1193
  }, {
1139
1194
  key: "handleConnectionRestoration",
1140
1195
  value: (function () {
1141
- var _handleConnectionRestoration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19(retry) {
1196
+ var _handleConnectionRestoration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(retry) {
1142
1197
  var _this6 = this;
1143
- return _regenerator.default.wrap(function (_context19) {
1144
- while (1) switch (_context19.prev = _context19.next) {
1198
+ return _regenerator.default.wrap(function (_context20) {
1199
+ while (1) switch (_context20.prev = _context20.next) {
1145
1200
  case 0:
1146
1201
  _Logger.default.info(_constants.METHOD_START_MESSAGE, {
1147
1202
  method: _constants2.METHODS.HANDLE_CONNECTION_RESTORATION,
1148
1203
  file: _constants2.REGISTRATION_FILE
1149
1204
  });
1150
- _context19.next = 1;
1151
- return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1205
+ _context20.next = 1;
1206
+ return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
1152
1207
  var abort;
1153
- return _regenerator.default.wrap(function (_context18) {
1154
- while (1) switch (_context18.prev = _context18.next) {
1208
+ return _regenerator.default.wrap(function (_context19) {
1209
+ while (1) switch (_context19.prev = _context19.next) {
1155
1210
  case 0:
1156
1211
  if (!retry) {
1157
- _context18.next = 4;
1212
+ _context19.next = 4;
1158
1213
  break;
1159
1214
  }
1160
1215
  _Logger.default.log('Network is up again, re-registering with Webex Calling if needed', {
@@ -1163,43 +1218,43 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1163
1218
  });
1164
1219
  _this6.clearKeepaliveTimer();
1165
1220
  if (!_this6.isDeviceRegistered()) {
1166
- _context18.next = 1;
1221
+ _context19.next = 1;
1167
1222
  break;
1168
1223
  }
1169
- _context18.next = 1;
1224
+ _context19.next = 1;
1170
1225
  return _this6.deregister();
1171
1226
  case 1:
1172
1227
  if (!_this6.activeMobiusUrl) {
1173
- _context18.next = 3;
1228
+ _context19.next = 3;
1174
1229
  break;
1175
1230
  }
1176
- _context18.next = 2;
1231
+ _context19.next = 2;
1177
1232
  return _this6.restorePreviousRegistration(_constants2.METHODS.HANDLE_CONNECTION_RESTORATION);
1178
1233
  case 2:
1179
- abort = _context18.sent;
1234
+ abort = _context19.sent;
1180
1235
  if (!(!abort && !_this6.isDeviceRegistered())) {
1181
- _context18.next = 3;
1236
+ _context19.next = 3;
1182
1237
  break;
1183
1238
  }
1184
- _context18.next = 3;
1239
+ _context19.next = 3;
1185
1240
  return _this6.restartRegistration(_constants2.METHODS.HANDLE_CONNECTION_RESTORATION);
1186
1241
  case 3:
1187
1242
  retry = false;
1188
1243
  case 4:
1189
1244
  case "end":
1190
- return _context18.stop();
1245
+ return _context19.stop();
1191
1246
  }
1192
- }, _callee18);
1247
+ }, _callee19);
1193
1248
  })));
1194
1249
  case 1:
1195
- return _context19.abrupt("return", retry);
1250
+ return _context20.abrupt("return", retry);
1196
1251
  case 2:
1197
1252
  case "end":
1198
- return _context19.stop();
1253
+ return _context20.stop();
1199
1254
  }
1200
- }, _callee19, this);
1255
+ }, _callee20, this);
1201
1256
  }));
1202
- function handleConnectionRestoration(_x10) {
1257
+ function handleConnectionRestoration(_x14) {
1203
1258
  return _handleConnectionRestoration.apply(this, arguments);
1204
1259
  }
1205
1260
  return handleConnectionRestoration;
@@ -1215,53 +1270,53 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1215
1270
  value: function restoreRegistrationCallBack() {
1216
1271
  var _this7 = this;
1217
1272
  return /*#__PURE__*/function () {
1218
- var _ref1 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(restoreData, caller) {
1273
+ var _ref1 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21(restoreData, caller) {
1219
1274
  var logContext, restore, finalError;
1220
- return _regenerator.default.wrap(function (_context20) {
1221
- while (1) switch (_context20.prev = _context20.next) {
1275
+ return _regenerator.default.wrap(function (_context21) {
1276
+ while (1) switch (_context21.prev = _context21.next) {
1222
1277
  case 0:
1223
1278
  logContext = {
1224
1279
  file: _constants2.REGISTRATION_FILE,
1225
1280
  method: caller
1226
1281
  };
1227
1282
  if (_this7.isRegRetry()) {
1228
- _context20.next = 4;
1283
+ _context21.next = 4;
1229
1284
  break;
1230
1285
  }
1231
1286
  _Logger.default.info('Registration restoration in progress.', logContext);
1232
1287
  restore = _this7.getExistingDevice(restoreData);
1233
1288
  if (!restore) {
1234
- _context20.next = 3;
1289
+ _context21.next = 3;
1235
1290
  break;
1236
1291
  }
1237
1292
  _this7.setRegRetry(true);
1238
- _context20.next = 1;
1293
+ _context21.next = 1;
1239
1294
  return _this7.deregister();
1240
1295
  case 1:
1241
- _context20.next = 2;
1296
+ _context21.next = 2;
1242
1297
  return _this7.restorePreviousRegistration(caller);
1243
1298
  case 2:
1244
- finalError = _context20.sent;
1299
+ finalError = _context21.sent;
1245
1300
  _this7.setRegRetry(false);
1246
1301
  if (_this7.isDeviceRegistered()) {
1247
1302
  _Logger.default.info('Registration restored successfully.', logContext);
1248
1303
  }
1249
- return _context20.abrupt("return", finalError);
1304
+ return _context21.abrupt("return", finalError);
1250
1305
  case 3:
1251
- _this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
1252
- _context20.next = 5;
1306
+ _this7.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
1307
+ _context21.next = 5;
1253
1308
  break;
1254
1309
  case 4:
1255
- _this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
1310
+ _this7.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
1256
1311
  case 5:
1257
- return _context20.abrupt("return", false);
1312
+ return _context21.abrupt("return", false);
1258
1313
  case 6:
1259
1314
  case "end":
1260
- return _context20.stop();
1315
+ return _context21.stop();
1261
1316
  }
1262
- }, _callee20);
1317
+ }, _callee21);
1263
1318
  }));
1264
- return function (_x11, _x12) {
1319
+ return function (_x15, _x16) {
1265
1320
  return _ref1.apply(this, arguments);
1266
1321
  };
1267
1322
  }();
@@ -1274,51 +1329,51 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1274
1329
  }, {
1275
1330
  key: "triggerRegistration",
1276
1331
  value: (function () {
1277
- var _triggerRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1332
+ var _triggerRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1278
1333
  var loggerContext, abort;
1279
- return _regenerator.default.wrap(function (_context21) {
1280
- while (1) switch (_context21.prev = _context21.next) {
1334
+ return _regenerator.default.wrap(function (_context22) {
1335
+ while (1) switch (_context22.prev = _context22.next) {
1281
1336
  case 0:
1282
1337
  loggerContext = {
1283
1338
  file: _constants2.REGISTRATION_FILE,
1284
1339
  method: _constants2.METHODS.TRIGGER_REGISTRATION
1285
1340
  };
1286
1341
  _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
1287
- _context21.next = 1;
1342
+ _context22.next = 1;
1288
1343
  return this.resumeFailover();
1289
1344
  case 1:
1290
- if (!_context21.sent) {
1291
- _context21.next = 2;
1345
+ if (!_context22.sent) {
1346
+ _context22.next = 2;
1292
1347
  break;
1293
1348
  }
1294
1349
  _Logger.default.info('Registration trigger handled by resumeFailover path', loggerContext);
1295
- return _context21.abrupt("return");
1350
+ return _context22.abrupt("return");
1296
1351
  case 2:
1297
1352
  if (!(this.primaryMobiusUris.length > 0)) {
1298
- _context21.next = 5;
1353
+ _context22.next = 5;
1299
1354
  break;
1300
1355
  }
1301
- _context21.next = 3;
1356
+ _context22.next = 3;
1302
1357
  return this.attemptRegistrationWithServers(_constants2.REGISTRATION_UTIL, this.primaryMobiusUris);
1303
1358
  case 3:
1304
- abort = _context21.sent;
1359
+ abort = _context22.sent;
1305
1360
  if (!(!this.isDeviceRegistered() && !abort)) {
1306
- _context21.next = 4;
1361
+ _context22.next = 4;
1307
1362
  break;
1308
1363
  }
1309
- _context21.next = 4;
1364
+ _context22.next = 4;
1310
1365
  return this.startFailoverTimer();
1311
1366
  case 4:
1312
1367
  _Logger.default.log("triggerRegistration completed - deviceRegistered: ".concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
1313
- _context21.next = 6;
1368
+ _context22.next = 6;
1314
1369
  break;
1315
1370
  case 5:
1316
1371
  _Logger.default.warn('triggerRegistration skipped: no primary Mobius URIs available', loggerContext);
1317
1372
  case 6:
1318
1373
  case "end":
1319
- return _context21.stop();
1374
+ return _context22.stop();
1320
1375
  }
1321
- }, _callee21, this);
1376
+ }, _callee22, this);
1322
1377
  }));
1323
1378
  function triggerRegistration() {
1324
1379
  return _triggerRegistration.apply(this, arguments);
@@ -1337,7 +1392,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1337
1392
  }, {
1338
1393
  key: "attemptRegistrationWithServers",
1339
1394
  value: (function () {
1340
- var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22(caller) {
1395
+ var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23(caller) {
1341
1396
  var _this8 = this;
1342
1397
  var servers,
1343
1398
  loggerContext,
@@ -1347,12 +1402,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1347
1402
  _step2,
1348
1403
  _loop,
1349
1404
  _ret,
1350
- _args23 = arguments,
1405
+ _args24 = arguments,
1351
1406
  _t6;
1352
- return _regenerator.default.wrap(function (_context23) {
1353
- while (1) switch (_context23.prev = _context23.next) {
1407
+ return _regenerator.default.wrap(function (_context24) {
1408
+ while (1) switch (_context24.prev = _context24.next) {
1354
1409
  case 0:
1355
- servers = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : this.primaryMobiusUris;
1410
+ servers = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : this.primaryMobiusUris;
1356
1411
  loggerContext = {
1357
1412
  file: _constants2.REGISTRATION_FILE,
1358
1413
  method: _constants2.REGISTER_UTIL
@@ -1360,17 +1415,17 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1360
1415
  abort = false;
1361
1416
  this.retryAfter = undefined;
1362
1417
  if (!this.failoverImmediately) {
1363
- _context23.next = 1;
1418
+ _context24.next = 1;
1364
1419
  break;
1365
1420
  }
1366
- return _context23.abrupt("return", abort);
1421
+ return _context24.abrupt("return", abort);
1367
1422
  case 1:
1368
1423
  if (!this.isDeviceRegistered()) {
1369
- _context23.next = 2;
1424
+ _context24.next = 2;
1370
1425
  break;
1371
1426
  }
1372
1427
  _Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), loggerContext);
1373
- return _context23.abrupt("return", abort);
1428
+ return _context24.abrupt("return", abort);
1374
1429
  case 2:
1375
1430
  /*
1376
1431
  * Align the active transport with this server group. When the Mobius socket is enabled
@@ -1383,90 +1438,93 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1383
1438
  this.apiRequest.setSocketEnabled(servers[0].startsWith('wss://'));
1384
1439
  }
1385
1440
  _iterator2 = _createForOfIteratorHelper(servers);
1386
- _context23.prev = 3;
1441
+ _context24.prev = 3;
1387
1442
  _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
1388
1443
  var url, serverType, _this8$deviceInfo$dev, _resp$headers, _resp$headers$trackin, _resp$headers2, _this8$deviceInfo$dev2, wssNormalizedUrl, resp, body, _yield$handleRegistra, finalError, shouldDisconnect, _t5;
1389
- return _regenerator.default.wrap(function (_context22) {
1390
- while (1) switch (_context22.prev = _context22.next) {
1444
+ return _regenerator.default.wrap(function (_context23) {
1445
+ while (1) switch (_context23.prev = _context23.next) {
1391
1446
  case 0:
1392
1447
  url = _step2.value;
1393
1448
  serverType = _this8.getServerType(url);
1394
- _context22.prev = 1;
1449
+ _context23.prev = 1;
1395
1450
  abort = false;
1396
- _this8.registrationStatus = _types2.RegistrationStatus.INACTIVE;
1397
- _this8.lineEmitter(_types3.LINE_EVENTS.CONNECTING);
1451
+ _this8.registrationStatus = _types3.RegistrationStatus.INACTIVE;
1452
+ _this8.lineEmitter(_types4.LINE_EVENTS.CONNECTING);
1398
1453
  _Logger.default.info("[".concat(caller, "] : Mobius url to contact: ").concat(url), loggerContext);
1399
1454
  if (!_this8.apiRequest.isSocketEnabled()) {
1400
- _context22.next = 3;
1455
+ _context23.next = 3;
1401
1456
  break;
1402
1457
  }
1403
1458
  wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
1404
1459
  _Logger.default.info("[".concat(caller, "] : Connecting to Mobius WebSocket - serverType: ").concat(serverType, ", wssUrl: ").concat(wssNormalizedUrl), loggerContext);
1405
1460
 
1406
1461
  // eslint-disable-next-line no-await-in-loop
1407
- _context22.next = 2;
1462
+ _context23.next = 2;
1408
1463
  return _this8.apiRequest.connectToMobiusSocket(wssNormalizedUrl);
1409
1464
  case 2:
1410
- connectedWebSocketUrl = _context22.sent;
1465
+ connectedWebSocketUrl = _context23.sent;
1411
1466
  connectedWebSocketUrl = connectedWebSocketUrl ? "".concat(connectedWebSocketUrl, "/") : undefined;
1412
1467
  _Logger.default.log("[".concat(caller, "] : Mobius WebSocket connected - serverType: ").concat(serverType, ", connectedWebSocketUrl: ").concat(connectedWebSocketUrl), loggerContext);
1413
1468
  case 3:
1414
- _context22.next = 4;
1469
+ _context23.next = 4;
1415
1470
  return _this8.postRegistration(url);
1416
1471
  case 4:
1417
- resp = _context22.sent;
1472
+ resp = _context23.sent;
1418
1473
  _this8.clearFailoverState();
1419
1474
  _this8.deviceInfo = resp.body;
1420
- _this8.registrationStatus = _types2.RegistrationStatus.ACTIVE;
1475
+ _this8.registrationStatus = _types3.RegistrationStatus.ACTIVE;
1421
1476
  _this8.setActiveMobiusUrl(connectedWebSocketUrl || url);
1422
- _this8.lineEmitter(_types3.LINE_EVENTS.REGISTERED, resp.body);
1477
+ _this8.lineEmitter(_types4.LINE_EVENTS.REGISTERED, resp.body);
1423
1478
  _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), loggerContext);
1424
1479
  _this8.setIntervalValues(_this8.deviceInfo);
1425
1480
  _this8.metricManager.setDeviceInfo(_this8.deviceInfo);
1426
1481
  _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);
1427
1482
  _this8.startKeepaliveTimer((_this8$deviceInfo$dev2 = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev2 === void 0 ? void 0 : _this8$deviceInfo$dev2.uri, _this8.deviceInfo.keepaliveInterval, serverType);
1428
1483
  _this8.initiateFailback();
1429
- return _context22.abrupt("return", 0);
1484
+ return _context23.abrupt("return", 0);
1430
1485
  case 5:
1431
- _context22.prev = 5;
1432
- _t5 = _context22["catch"](1);
1486
+ _context23.prev = 5;
1487
+ _t5 = _context23["catch"](1);
1433
1488
  body = _t5; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
1434
- _context22.next = 6;
1489
+ _context23.next = 6;
1435
1490
  return (0, _common.handleRegistrationErrors)(body, function (clientError, isFinalError) {
1436
1491
  var _body$headers$trackin, _body$headers;
1437
1492
  if (isFinalError) {
1438
- _this8.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
1493
+ _this8.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
1439
1494
  } else {
1440
- _this8.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
1495
+ _this8.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
1441
1496
  }
1442
1497
  _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);
1443
1498
  }, {
1444
1499
  method: caller,
1445
1500
  file: _constants2.REGISTRATION_FILE
1446
- }, function (retryAfter, retryCaller) {
1447
- return _this8.handle429Retry(retryAfter, retryCaller);
1448
- }, _this8.restoreRegistrationCallBack(), servers.length);
1501
+ }, {
1502
+ retry429Cb: function retry429Cb(retryAfter, retryCaller) {
1503
+ return _this8.handle429Retry(retryAfter, retryCaller);
1504
+ },
1505
+ restoreRegCb: _this8.restoreRegistrationCallBack()
1506
+ }, servers.length);
1449
1507
  case 6:
1450
- _yield$handleRegistra = _context22.sent;
1508
+ _yield$handleRegistra = _context23.sent;
1451
1509
  finalError = _yield$handleRegistra.finalError;
1452
1510
  shouldDisconnect = _yield$handleRegistra.shouldDisconnect;
1453
1511
  abort = finalError;
1454
- if (!(_this8.registrationStatus === _types2.RegistrationStatus.ACTIVE)) {
1455
- _context22.next = 7;
1512
+ if (!(_this8.registrationStatus === _types3.RegistrationStatus.ACTIVE)) {
1513
+ _context23.next = 7;
1456
1514
  break;
1457
1515
  }
1458
1516
  _Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(_this8.activeMobiusUrl), loggerContext);
1459
- return _context22.abrupt("return", 0);
1517
+ return _context23.abrupt("return", 0);
1460
1518
  case 7:
1461
1519
  if (!(shouldDisconnect && _this8.apiRequest.isSocketEnabled())) {
1462
- _context22.next = 9;
1520
+ _context23.next = 9;
1463
1521
  break;
1464
1522
  }
1465
1523
  connectedWebSocketUrl = undefined;
1466
1524
  _Logger.default.info("[".concat(caller, "] : Tearing down Mobius WebSocket after registration error - serverType: ").concat(serverType), loggerContext);
1467
1525
 
1468
1526
  // eslint-disable-next-line no-await-in-loop
1469
- _context22.next = 8;
1527
+ _context23.next = 8;
1470
1528
  return _this8.apiRequest.disconnectFromMobiusSocket({
1471
1529
  code: 3050,
1472
1530
  reason: 'done (permanent)'
@@ -1475,58 +1533,58 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1475
1533
  _Logger.default.log("[".concat(caller, "] : Mobius WebSocket disconnect complete after registration error - serverType: ").concat(serverType), loggerContext);
1476
1534
  case 9:
1477
1535
  if (!abort) {
1478
- _context22.next = 11;
1536
+ _context23.next = 11;
1479
1537
  break;
1480
1538
  }
1481
- _this8.setStatus(_types2.RegistrationStatus.INACTIVE);
1539
+ _this8.setStatus(_types3.RegistrationStatus.INACTIVE);
1482
1540
  // eslint-disable-next-line no-await-in-loop
1483
- _context22.next = 10;
1541
+ _context23.next = 10;
1484
1542
  return (0, _common.uploadLogs)();
1485
1543
  case 10:
1486
- return _context22.abrupt("return", 0);
1544
+ return _context23.abrupt("return", 0);
1487
1545
  case 11:
1488
1546
  case "end":
1489
- return _context22.stop();
1547
+ return _context23.stop();
1490
1548
  }
1491
1549
  }, _loop, null, [[1, 5]]);
1492
1550
  });
1493
1551
  _iterator2.s();
1494
1552
  case 4:
1495
1553
  if ((_step2 = _iterator2.n()).done) {
1496
- _context23.next = 7;
1554
+ _context24.next = 7;
1497
1555
  break;
1498
1556
  }
1499
- return _context23.delegateYield(_loop(), "t0", 5);
1557
+ return _context24.delegateYield(_loop(), "t0", 5);
1500
1558
  case 5:
1501
- _ret = _context23.t0;
1559
+ _ret = _context24.t0;
1502
1560
  if (!(_ret === 0)) {
1503
- _context23.next = 6;
1561
+ _context24.next = 6;
1504
1562
  break;
1505
1563
  }
1506
- return _context23.abrupt("continue", 7);
1564
+ return _context24.abrupt("continue", 7);
1507
1565
  case 6:
1508
- _context23.next = 4;
1566
+ _context24.next = 4;
1509
1567
  break;
1510
1568
  case 7:
1511
- _context23.next = 9;
1569
+ _context24.next = 9;
1512
1570
  break;
1513
1571
  case 8:
1514
- _context23.prev = 8;
1515
- _t6 = _context23["catch"](3);
1572
+ _context24.prev = 8;
1573
+ _t6 = _context24["catch"](3);
1516
1574
  _iterator2.e(_t6);
1517
1575
  case 9:
1518
- _context23.prev = 9;
1576
+ _context24.prev = 9;
1519
1577
  _iterator2.f();
1520
- return _context23.finish(9);
1578
+ return _context24.finish(9);
1521
1579
  case 10:
1522
- return _context23.abrupt("return", abort);
1580
+ return _context24.abrupt("return", abort);
1523
1581
  case 11:
1524
1582
  case "end":
1525
- return _context23.stop();
1583
+ return _context24.stop();
1526
1584
  }
1527
- }, _callee22, this, [[3, 8, 9, 10]]);
1585
+ }, _callee23, this, [[3, 8, 9, 10]]);
1528
1586
  }));
1529
- function attemptRegistrationWithServers(_x13) {
1587
+ function attemptRegistrationWithServers(_x17) {
1530
1588
  return _attemptRegistrationWithServers.apply(this, arguments);
1531
1589
  }
1532
1590
  return attemptRegistrationWithServers;
@@ -1539,19 +1597,19 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1539
1597
  }, {
1540
1598
  key: "startKeepaliveTimer",
1541
1599
  value: (function () {
1542
- var _startKeepaliveTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25(url, interval, serverType) {
1600
+ var _startKeepaliveTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26(url, interval, serverType) {
1543
1601
  var _this9 = this;
1544
1602
  var RETRY_COUNT_THRESHOLD;
1545
- return _regenerator.default.wrap(function (_context26) {
1546
- while (1) switch (_context26.prev = _context26.next) {
1603
+ return _regenerator.default.wrap(function (_context27) {
1604
+ while (1) switch (_context27.prev = _context27.next) {
1547
1605
  case 0:
1548
1606
  this.clearKeepaliveTimer();
1549
1607
  RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
1550
- _context26.next = 1;
1551
- return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1608
+ _context27.next = 1;
1609
+ return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1552
1610
  var blob, blobUrl;
1553
- return _regenerator.default.wrap(function (_context25) {
1554
- while (1) switch (_context25.prev = _context25.next) {
1611
+ return _regenerator.default.wrap(function (_context26) {
1612
+ while (1) switch (_context26.prev = _context26.next) {
1555
1613
  case 0:
1556
1614
  if (_this9.isDeviceRegistered()) {
1557
1615
  if (!_this9.webWorker) {
@@ -1562,38 +1620,38 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1562
1620
  _this9.webWorker = new Worker(blobUrl);
1563
1621
  URL.revokeObjectURL(blobUrl);
1564
1622
  _this9.webWorker.postMessage({
1565
- type: _types2.WorkerMessageType.START_KEEPALIVE,
1623
+ type: _types3.WorkerMessageType.START_KEEPALIVE,
1566
1624
  interval: interval,
1567
1625
  retryCountThreshold: RETRY_COUNT_THRESHOLD
1568
1626
  });
1569
1627
  _this9.webWorker.onmessage = /*#__PURE__*/function () {
1570
- var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23(event) {
1571
- var logContext, _this9$webWorker, res, _err$headers, _this9$webWorker2, error, _error, _yield$handleRegistra2, abort, _t7;
1572
- return _regenerator.default.wrap(function (_context24) {
1573
- while (1) switch (_context24.prev = _context24.next) {
1628
+ var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24(event) {
1629
+ var logContext, _this9$webWorker, res, _err$headers, _this9$webWorker2, error, _error, _yield$handleRegistra2, abort, handledByCallback, _t7;
1630
+ return _regenerator.default.wrap(function (_context25) {
1631
+ while (1) switch (_context25.prev = _context25.next) {
1574
1632
  case 0:
1575
1633
  logContext = {
1576
1634
  file: _constants2.REGISTRATION_FILE,
1577
1635
  method: _constants2.KEEPALIVE_UTIL
1578
1636
  };
1579
- if (!(event.data.type === _types2.WorkerMessageType.SEND_KEEPALIVE)) {
1580
- _context24.next = 4;
1637
+ if (!(event.data.type === _types3.WorkerMessageType.SEND_KEEPALIVE)) {
1638
+ _context25.next = 4;
1581
1639
  break;
1582
1640
  }
1583
- _context24.prev = 1;
1584
- _context24.next = 2;
1641
+ _context25.prev = 1;
1642
+ _context25.next = 2;
1585
1643
  return _this9.postKeepAlive(String(_this9.webex.internal.device.url), url);
1586
1644
  case 2:
1587
- res = _context24.sent;
1645
+ res = _context25.sent;
1588
1646
  (_this9$webWorker = _this9.webWorker) === null || _this9$webWorker === void 0 ? void 0 : _this9$webWorker.postMessage({
1589
- type: _types2.WorkerMessageType.KEEPALIVE_RESULT,
1647
+ type: _types3.WorkerMessageType.KEEPALIVE_RESULT,
1590
1648
  statusCode: res.statusCode
1591
1649
  });
1592
- _context24.next = 4;
1650
+ _context25.next = 4;
1593
1651
  break;
1594
1652
  case 3:
1595
- _context24.prev = 3;
1596
- _t7 = _context24["catch"](1);
1653
+ _context25.prev = 3;
1654
+ _t7 = _context25["catch"](1);
1597
1655
  error = {
1598
1656
  headers: {
1599
1657
  trackingid: (_err$headers = _t7.headers) === null || _err$headers === void 0 ? void 0 : _err$headers.trackingid,
@@ -1604,73 +1662,85 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1604
1662
  type: _t7.type
1605
1663
  };
1606
1664
  (_this9$webWorker2 = _this9.webWorker) === null || _this9$webWorker2 === void 0 ? void 0 : _this9$webWorker2.postMessage({
1607
- type: _types2.WorkerMessageType.KEEPALIVE_RESULT,
1665
+ type: _types3.WorkerMessageType.KEEPALIVE_RESULT,
1608
1666
  err: error
1609
1667
  });
1610
1668
  case 4:
1611
- if (event.data.type === _types2.WorkerMessageType.KEEPALIVE_SUCCESS) {
1669
+ if (event.data.type === _types3.WorkerMessageType.KEEPALIVE_SUCCESS) {
1612
1670
  _Logger.default.info("Sent Keepalive, status: ".concat(event.data.statusCode), logContext);
1613
- _this9.lineEmitter(_types3.LINE_EVENTS.RECONNECTED);
1671
+ _this9.lineEmitter(_types4.LINE_EVENTS.RECONNECTED);
1614
1672
  }
1615
- if (!(event.data.type === _types2.WorkerMessageType.KEEPALIVE_FAILURE)) {
1616
- _context24.next = 11;
1673
+ if (!(event.data.type === _types3.WorkerMessageType.KEEPALIVE_FAILURE)) {
1674
+ _context25.next = 12;
1617
1675
  break;
1618
1676
  }
1619
1677
  _error = event.data.err;
1620
1678
  _Logger.default.warn("Keep-alive missed ".concat(event.data.keepAliveRetryCount, " times. Status -> ").concat(_error.statusCode, " "), logContext);
1621
- _context24.next = 5;
1679
+ _context25.next = 5;
1622
1680
  return (0, _common.handleRegistrationErrors)(_error, function (clientError, finalError) {
1623
- var _error$headers$tracki, _error$headers;
1681
+ var _error$headers$tracki2, _error$headers2;
1624
1682
  if (finalError) {
1625
- _this9.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
1683
+ _this9.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
1626
1684
  }
1627
- _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);
1685
+ _this9.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.KEEPALIVE_ERROR, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, _constants2.KEEPALIVE_UTIL, serverType, (_error$headers$tracki2 = (_error$headers2 = _error.headers) === null || _error$headers2 === void 0 ? void 0 : _error$headers2.trackingid) !== null && _error$headers$tracki2 !== void 0 ? _error$headers$tracki2 : '', event.data.keepAliveRetryCount, clientError);
1628
1686
  }, {
1629
1687
  method: _constants2.KEEPALIVE_UTIL,
1630
1688
  file: _constants2.REGISTRATION_FILE
1631
- }, function (retryAfter, retryCaller) {
1632
- return _this9.handle429Retry(retryAfter, retryCaller);
1689
+ }, {
1690
+ retry429Cb: function retry429Cb(retryAfter, retryCaller) {
1691
+ return _this9.handle429Retry(retryAfter, retryCaller);
1692
+ },
1693
+ sessionSupersededCb: function sessionSupersededCb(clientError) {
1694
+ return _this9.handle409KeepaliveFailure(clientError, _error, serverType, event.data.keepAliveRetryCount);
1695
+ }
1633
1696
  });
1634
1697
  case 5:
1635
- _yield$handleRegistra2 = _context24.sent;
1698
+ _yield$handleRegistra2 = _context25.sent;
1636
1699
  abort = _yield$handleRegistra2.finalError;
1700
+ handledByCallback = _yield$handleRegistra2.handledByCallback;
1701
+ if (!handledByCallback) {
1702
+ _context25.next = 6;
1703
+ break;
1704
+ }
1705
+ return _context25.abrupt("return");
1706
+ case 6:
1637
1707
  if (!(abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
1638
- _context24.next = 10;
1708
+ _context25.next = 11;
1639
1709
  break;
1640
1710
  }
1641
1711
  _this9.failoverImmediately = _this9.isCCFlow;
1642
- _this9.setStatus(_types2.RegistrationStatus.INACTIVE);
1712
+ _this9.setStatus(_types3.RegistrationStatus.INACTIVE);
1643
1713
  _this9.clearKeepaliveTimer();
1644
1714
  _this9.clearFailbackTimer();
1645
- _this9.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
1646
- _context24.next = 6;
1715
+ _this9.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
1716
+ _context25.next = 7;
1647
1717
  return (0, _common.uploadLogs)();
1648
- case 6:
1718
+ case 7:
1649
1719
  if (abort) {
1650
- _context24.next = 8;
1720
+ _context25.next = 9;
1651
1721
  break;
1652
1722
  }
1653
- _context24.next = 7;
1723
+ _context25.next = 8;
1654
1724
  return _this9.reconnectOnFailure(_constants2.RECONNECT_ON_FAILURE_UTIL);
1655
- case 7:
1656
- _context24.next = 9;
1657
- break;
1658
1725
  case 8:
1726
+ _context25.next = 10;
1727
+ break;
1728
+ case 9:
1659
1729
  if (_error.statusCode === 404) {
1660
1730
  _this9.handle404KeepaliveFailure(_constants2.KEEPALIVE_UTIL);
1661
1731
  }
1662
- case 9:
1663
- _context24.next = 11;
1664
- break;
1665
1732
  case 10:
1666
- _this9.lineEmitter(_types3.LINE_EVENTS.RECONNECTING);
1733
+ _context25.next = 12;
1734
+ break;
1667
1735
  case 11:
1736
+ _this9.lineEmitter(_types4.LINE_EVENTS.RECONNECTING);
1737
+ case 12:
1668
1738
  case "end":
1669
- return _context24.stop();
1739
+ return _context25.stop();
1670
1740
  }
1671
- }, _callee23, null, [[1, 3]]);
1741
+ }, _callee24, null, [[1, 3]]);
1672
1742
  }));
1673
- return function (_x17) {
1743
+ return function (_x21) {
1674
1744
  return _ref11.apply(this, arguments);
1675
1745
  };
1676
1746
  }();
@@ -1678,17 +1748,17 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1678
1748
  }
1679
1749
  case 1:
1680
1750
  case "end":
1681
- return _context25.stop();
1751
+ return _context26.stop();
1682
1752
  }
1683
- }, _callee24);
1753
+ }, _callee25);
1684
1754
  })));
1685
1755
  case 1:
1686
1756
  case "end":
1687
- return _context26.stop();
1757
+ return _context27.stop();
1688
1758
  }
1689
- }, _callee25, this);
1759
+ }, _callee26, this);
1690
1760
  }));
1691
- function startKeepaliveTimer(_x14, _x15, _x16) {
1761
+ function startKeepaliveTimer(_x18, _x19, _x20) {
1692
1762
  return _startKeepaliveTimer.apply(this, arguments);
1693
1763
  }
1694
1764
  return startKeepaliveTimer;
@@ -1702,7 +1772,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1702
1772
  value: function clearKeepaliveTimer() {
1703
1773
  if (this.webWorker) {
1704
1774
  this.webWorker.postMessage({
1705
- type: _types2.WorkerMessageType.CLEAR_KEEPALIVE
1775
+ type: _types3.WorkerMessageType.CLEAR_KEEPALIVE
1706
1776
  });
1707
1777
  this.webWorker.terminate();
1708
1778
  this.webWorker = undefined;
@@ -1716,39 +1786,39 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1716
1786
  }, {
1717
1787
  key: "deregister",
1718
1788
  value: function () {
1719
- var _deregister = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1789
+ var _deregister = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1720
1790
  var closeMobiusWss,
1721
1791
  loggerContext,
1722
1792
  _this$deviceInfo$devi2,
1723
1793
  _this$deviceInfo$devi3,
1724
- _args27 = arguments,
1794
+ _args28 = arguments,
1725
1795
  _t8;
1726
- return _regenerator.default.wrap(function (_context27) {
1727
- while (1) switch (_context27.prev = _context27.next) {
1796
+ return _regenerator.default.wrap(function (_context28) {
1797
+ while (1) switch (_context28.prev = _context28.next) {
1728
1798
  case 0:
1729
- closeMobiusWss = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : false;
1799
+ closeMobiusWss = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : false;
1730
1800
  loggerContext = {
1731
1801
  file: _constants2.REGISTRATION_FILE,
1732
1802
  method: _constants2.METHODS.DEREGISTER
1733
1803
  };
1734
1804
  _Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
1735
- _context27.prev = 1;
1736
- _context27.next = 2;
1805
+ _context28.prev = 1;
1806
+ _context28.next = 2;
1737
1807
  return this.deleteRegistration(this.activeMobiusUrl, (_this$deviceInfo$devi2 = this.deviceInfo.device) === null || _this$deviceInfo$devi2 === void 0 ? void 0 : _this$deviceInfo$devi2.deviceId, (_this$deviceInfo$devi3 = this.deviceInfo.device) === null || _this$deviceInfo$devi3 === void 0 ? void 0 : _this$deviceInfo$devi3.clientDeviceUri);
1738
1808
  case 2:
1739
1809
  _Logger.default.log('Registration successfully deregistered', loggerContext);
1740
- _context27.next = 4;
1810
+ _context28.next = 4;
1741
1811
  break;
1742
1812
  case 3:
1743
- _context27.prev = 3;
1744
- _t8 = _context27["catch"](1);
1813
+ _context28.prev = 3;
1814
+ _t8 = _context28["catch"](1);
1745
1815
  _Logger.default.warn("Delete failed with Mobius: ".concat((0, _stringify.default)(_t8)), loggerContext);
1746
1816
  case 4:
1747
1817
  if (!closeMobiusWss) {
1748
- _context27.next = 6;
1818
+ _context28.next = 6;
1749
1819
  break;
1750
1820
  }
1751
- _context27.next = 5;
1821
+ _context28.next = 5;
1752
1822
  return this.apiRequest.disconnectFromMobiusSocket({
1753
1823
  code: 3050,
1754
1824
  reason: 'done (permanent)'
@@ -1757,13 +1827,13 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1757
1827
  _Logger.default.log('Mobius socket disconnect complete after deregistration', loggerContext);
1758
1828
  case 6:
1759
1829
  this.clearKeepaliveTimer();
1760
- this.setStatus(_types2.RegistrationStatus.INACTIVE);
1830
+ this.setStatus(_types3.RegistrationStatus.INACTIVE);
1761
1831
  this.clearFailoverState();
1762
1832
  case 7:
1763
1833
  case "end":
1764
- return _context27.stop();
1834
+ return _context28.stop();
1765
1835
  }
1766
- }, _callee26, this, [[1, 3]]);
1836
+ }, _callee27, this, [[1, 3]]);
1767
1837
  }));
1768
1838
  function deregister() {
1769
1839
  return _deregister.apply(this, arguments);
@@ -1813,7 +1883,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1813
1883
  uri = !uri.endsWith('/') ? "".concat(uri, "/") : uri;
1814
1884
  }
1815
1885
  this.setActiveMobiusUrl(uri);
1816
- this.registrationStatus = _types2.RegistrationStatus.ACTIVE;
1886
+ this.registrationStatus = _types3.RegistrationStatus.ACTIVE;
1817
1887
  return true;
1818
1888
  }
1819
1889
  return false;
@@ -1831,10 +1901,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1831
1901
  }, {
1832
1902
  key: "reconnectOnFailure",
1833
1903
  value: (function () {
1834
- var _reconnectOnFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27(caller) {
1904
+ var _reconnectOnFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28(caller) {
1835
1905
  var abort;
1836
- return _regenerator.default.wrap(function (_context28) {
1837
- while (1) switch (_context28.prev = _context28.next) {
1906
+ return _regenerator.default.wrap(function (_context29) {
1907
+ while (1) switch (_context29.prev = _context29.next) {
1838
1908
  case 0:
1839
1909
  _Logger.default.info(_constants.METHOD_START_MESSAGE, {
1840
1910
  method: _constants2.METHODS.RECONNECT_ON_FAILURE,
@@ -1842,25 +1912,25 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1842
1912
  });
1843
1913
  this.reconnectPending = false;
1844
1914
  if (this.isDeviceRegistered()) {
1845
- _context28.next = 4;
1915
+ _context29.next = 4;
1846
1916
  break;
1847
1917
  }
1848
1918
  if (!((0, _keys.default)(this.callManager.getActiveCalls()).length === 0)) {
1849
- _context28.next = 3;
1919
+ _context29.next = 3;
1850
1920
  break;
1851
1921
  }
1852
- _context28.next = 1;
1922
+ _context29.next = 1;
1853
1923
  return this.restorePreviousRegistration(caller);
1854
1924
  case 1:
1855
- abort = _context28.sent;
1925
+ abort = _context29.sent;
1856
1926
  if (!(!abort && !this.isDeviceRegistered())) {
1857
- _context28.next = 2;
1927
+ _context29.next = 2;
1858
1928
  break;
1859
1929
  }
1860
- _context28.next = 2;
1930
+ _context29.next = 2;
1861
1931
  return this.restartRegistration(caller);
1862
1932
  case 2:
1863
- _context28.next = 4;
1933
+ _context29.next = 4;
1864
1934
  break;
1865
1935
  case 3:
1866
1936
  this.reconnectPending = true;
@@ -1870,11 +1940,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1870
1940
  });
1871
1941
  case 4:
1872
1942
  case "end":
1873
- return _context28.stop();
1943
+ return _context29.stop();
1874
1944
  }
1875
- }, _callee27, this);
1945
+ }, _callee28, this);
1876
1946
  }));
1877
- function reconnectOnFailure(_x18) {
1947
+ function reconnectOnFailure(_x22) {
1878
1948
  return _reconnectOnFailure.apply(this, arguments);
1879
1949
  }
1880
1950
  return reconnectOnFailure;
@@ -1889,11 +1959,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1889
1959
  }, {
1890
1960
  key: "handleRegistrationDownEvent",
1891
1961
  value: (function () {
1892
- var _handleRegistrationDownEvent = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28(event) {
1962
+ var _handleRegistrationDownEvent = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29(event) {
1893
1963
  var _event$trackingId, _event$eventId;
1894
1964
  var loggerContext, _Object$values, _Object$values2, activeCall;
1895
- return _regenerator.default.wrap(function (_context29) {
1896
- while (1) switch (_context29.prev = _context29.next) {
1965
+ return _regenerator.default.wrap(function (_context30) {
1966
+ while (1) switch (_context30.prev = _context30.next) {
1897
1967
  case 0:
1898
1968
  loggerContext = {
1899
1969
  file: _constants2.REGISTRATION_FILE,
@@ -1902,50 +1972,56 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1902
1972
  _Logger.default.info("Registration down received - trackingId: ".concat((_event$trackingId = event === null || event === void 0 ? void 0 : event.trackingId) !== null && _event$trackingId !== void 0 ? _event$trackingId : 'unknown', ", eventId: ").concat((_event$eventId = event === null || event === void 0 ? void 0 : event.eventId) !== null && _event$eventId !== void 0 ? _event$eventId : 'unknown'), loggerContext);
1903
1973
  _Object$values = (0, _values.default)(this.callManager.getActiveCalls()), _Object$values2 = (0, _slicedToArray2.default)(_Object$values, 1), activeCall = _Object$values2[0];
1904
1974
  activeCall === null || activeCall === void 0 ? void 0 : activeCall.end();
1905
- _context29.next = 1;
1906
- return this.performRegistrationDownCleanup(_constants2.METHODS.HANDLE_REGISTRATION_DOWN_EVENT);
1975
+ _context30.next = 1;
1976
+ return this.registrationCleanup(_constants2.METHODS.HANDLE_REGISTRATION_DOWN_EVENT, {
1977
+ reason: _types2.HARD_STOP_REASON.REGISTRATION_DOWN
1978
+ });
1907
1979
  case 1:
1908
1980
  case "end":
1909
- return _context29.stop();
1981
+ return _context30.stop();
1910
1982
  }
1911
- }, _callee28, this);
1983
+ }, _callee29, this);
1912
1984
  }));
1913
- function handleRegistrationDownEvent(_x19) {
1985
+ function handleRegistrationDownEvent(_x23) {
1914
1986
  return _handleRegistrationDownEvent.apply(this, arguments);
1915
1987
  }
1916
1988
  return handleRegistrationDownEvent;
1917
1989
  }()
1918
1990
  /**
1919
- * Cleans up registration-side state after a Mobius registration-down event.
1991
+ * Cleans up registration-side state for a hard stop, i.e. a registration that is gone
1992
+ * and must not be re-established by the SDK (Mobius registration-down event, or a
1993
+ * session superseded by another registration for the same user).
1920
1994
  *
1921
1995
  * Stops timers, resets transient flags, clears failover cache, sets status to
1922
1996
  * INACTIVE, tears down the Mobius WebSocket (when enabled), and finally emits
1923
- * `LINE_EVENTS.UNREGISTERED` so the SDK consumer is notified.
1997
+ * `LINE_EVENTS.UNREGISTERED` so the SDK consumer is notified. A superseded session
1998
+ * carries its `LineError` on that event as the reason the line will stay unregistered.
1924
1999
  *
1925
2000
  * Runs under the shared mutex to avoid racing with other registration flows.
1926
2001
  *
1927
2002
  * @param caller - Identifier of the caller, used for logs.
2003
+ * @param hardStop - Why the registration is being torn down as {@link HardStop}.
1928
2004
  */
1929
2005
  )
1930
2006
  }, {
1931
- key: "performRegistrationDownCleanup",
2007
+ key: "registrationCleanup",
1932
2008
  value: (function () {
1933
- var _performRegistrationDownCleanup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30(caller) {
2009
+ var _registrationCleanup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31(caller, hardStop) {
1934
2010
  var _this0 = this;
1935
2011
  var loggerContext;
1936
- return _regenerator.default.wrap(function (_context31) {
1937
- while (1) switch (_context31.prev = _context31.next) {
2012
+ return _regenerator.default.wrap(function (_context32) {
2013
+ while (1) switch (_context32.prev = _context32.next) {
1938
2014
  case 0:
1939
2015
  loggerContext = {
1940
2016
  file: _constants2.REGISTRATION_FILE,
1941
- method: _constants2.METHODS.HANDLE_REGISTRATION_DOWN_EVENT
2017
+ method: caller
1942
2018
  };
1943
- _Logger.default.info("[".concat(caller, "] : Running registration-down cleanup"), loggerContext);
1944
- _context31.next = 1;
1945
- return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
2019
+ _Logger.default.info("[".concat(caller, "] : Running ").concat(hardStop.reason, " cleanup"), loggerContext);
2020
+ _context32.next = 1;
2021
+ return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
1946
2022
  var _t9;
1947
- return _regenerator.default.wrap(function (_context30) {
1948
- while (1) switch (_context30.prev = _context30.next) {
2023
+ return _regenerator.default.wrap(function (_context31) {
2024
+ while (1) switch (_context31.prev = _context31.next) {
1949
2025
  case 0:
1950
2026
  _this0.clearFailbackTimer();
1951
2027
  _this0.clearKeepaliveTimer();
@@ -1955,43 +2031,43 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1955
2031
  _this0.retryAfter = undefined;
1956
2032
  _this0.registerRetry = false;
1957
2033
  _this0.clearFailoverState();
1958
- _this0.setStatus(_types2.RegistrationStatus.INACTIVE);
2034
+ _this0.setStatus(_types3.RegistrationStatus.INACTIVE);
1959
2035
  if (!_this0.apiRequest.isSocketEnabled()) {
1960
- _context30.next = 4;
2036
+ _context31.next = 4;
1961
2037
  break;
1962
2038
  }
1963
- _context30.prev = 1;
1964
- _context30.next = 2;
2039
+ _context31.prev = 1;
2040
+ _context31.next = 2;
1965
2041
  return _this0.apiRequest.disconnectFromMobiusSocket({
1966
2042
  code: 3050,
1967
2043
  reason: 'done (permanent)'
1968
2044
  });
1969
2045
  case 2:
1970
- _Logger.default.log('Mobius socket disconnect complete after registration-down', loggerContext);
1971
- _context30.next = 4;
2046
+ _Logger.default.log("Mobius socket disconnect complete after ".concat(hardStop.reason), loggerContext);
2047
+ _context31.next = 4;
1972
2048
  break;
1973
2049
  case 3:
1974
- _context30.prev = 3;
1975
- _t9 = _context30["catch"](1);
1976
- _Logger.default.warn("Mobius socket disconnect failed after registration-down: ".concat(String(_t9)), loggerContext);
2050
+ _context31.prev = 3;
2051
+ _t9 = _context31["catch"](1);
2052
+ _Logger.default.warn("Mobius socket disconnect failed after ".concat(hardStop.reason, ": ").concat(String(_t9)), loggerContext);
1977
2053
  case 4:
1978
- _this0.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
2054
+ _this0.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED, undefined, hardStop.error);
1979
2055
  case 5:
1980
2056
  case "end":
1981
- return _context30.stop();
2057
+ return _context31.stop();
1982
2058
  }
1983
- }, _callee29, null, [[1, 3]]);
2059
+ }, _callee30, null, [[1, 3]]);
1984
2060
  })));
1985
2061
  case 1:
1986
2062
  case "end":
1987
- return _context31.stop();
2063
+ return _context32.stop();
1988
2064
  }
1989
- }, _callee30, this);
2065
+ }, _callee31, this);
1990
2066
  }));
1991
- function performRegistrationDownCleanup(_x20) {
1992
- return _performRegistrationDownCleanup.apply(this, arguments);
2067
+ function registrationCleanup(_x24, _x25) {
2068
+ return _registrationCleanup.apply(this, arguments);
1993
2069
  }
1994
- return performRegistrationDownCleanup;
2070
+ return registrationCleanup;
1995
2071
  }())
1996
2072
  }]);
1997
2073
  }();