@webex/calling 3.8.1-next.8 → 3.8.1-web-workers-keepalive.1

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.
@@ -54,7 +54,6 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
54
54
  (0, _defineProperty2.default)(this, "registrationStatus", void 0);
55
55
  (0, _defineProperty2.default)(this, "failbackTimer", void 0);
56
56
  (0, _defineProperty2.default)(this, "activeMobiusUrl", void 0);
57
- (0, _defineProperty2.default)(this, "keepaliveTimer", void 0);
58
57
  (0, _defineProperty2.default)(this, "rehomingIntervalMin", void 0);
59
58
  (0, _defineProperty2.default)(this, "rehomingIntervalMax", void 0);
60
59
  (0, _defineProperty2.default)(this, "mutex", void 0);
@@ -69,6 +68,7 @@ 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, "webWorker", void 0);
72
72
  (0, _defineProperty2.default)(this, "retryAfter", void 0);
73
73
  (0, _defineProperty2.default)(this, "scheduled429Retry", false);
74
74
  this.jwe = jwe;
@@ -118,94 +118,65 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
118
118
  this.backupMobiusUris = backupMobiusUris;
119
119
  }
120
120
 
121
- /**
122
- * Implementation of sending keepalive.
123
- *
124
- */
125
- }, {
126
- key: "postKeepAlive",
127
- value: (function () {
128
- var _postKeepAlive = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
129
- return _regenerator.default.wrap(function _callee$(_context) {
130
- while (1) switch (_context.prev = _context.next) {
131
- case 0:
132
- return _context.abrupt("return", this.webex.request({
133
- uri: "".concat(url, "/status"),
134
- method: _types2.HTTP_METHODS.POST,
135
- headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, this.webex.internal.device.url), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
136
- service: _types2.ALLOWED_SERVICES.MOBIUS
137
- }));
138
- case 1:
139
- case "end":
140
- return _context.stop();
141
- }
142
- }, _callee, this);
143
- }));
144
- function postKeepAlive(_x) {
145
- return _postKeepAlive.apply(this, arguments);
146
- }
147
- return postKeepAlive;
148
- }()
149
121
  /**
150
122
  * Implementation of delete device.
151
123
  *
152
124
  */
153
- )
154
125
  }, {
155
126
  key: "deleteRegistration",
156
127
  value: (function () {
157
- var _deleteRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url, deviceId, deviceUrl) {
128
+ var _deleteRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url, deviceId, deviceUrl) {
158
129
  var _response;
159
130
  var response;
160
- return _regenerator.default.wrap(function _callee2$(_context2) {
161
- while (1) switch (_context2.prev = _context2.next) {
131
+ return _regenerator.default.wrap(function _callee$(_context) {
132
+ while (1) switch (_context.prev = _context.next) {
162
133
  case 0:
163
- _context2.prev = 0;
164
- _context2.t0 = fetch;
165
- _context2.t1 = "".concat(url).concat(_constants2.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId);
166
- _context2.t2 = _types2.HTTP_METHODS.DELETE;
167
- _context2.t3 = _defineProperty2.default;
168
- _context2.t4 = _defineProperty2.default;
169
- _context2.t5 = _defineProperty2.default;
170
- _context2.t6 = (0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl);
171
- _context2.next = 10;
134
+ _context.prev = 0;
135
+ _context.t0 = fetch;
136
+ _context.t1 = "".concat(url).concat(_constants2.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId);
137
+ _context.t2 = _types2.HTTP_METHODS.DELETE;
138
+ _context.t3 = _defineProperty2.default;
139
+ _context.t4 = _defineProperty2.default;
140
+ _context.t5 = _defineProperty2.default;
141
+ _context.t6 = (0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl);
142
+ _context.next = 10;
172
143
  return this.webex.credentials.getUserToken();
173
144
  case 10:
174
- _context2.t7 = _context2.sent;
175
- _context2.t8 = (0, _context2.t5)(_context2.t6, "Authorization", _context2.t7);
176
- _context2.t9 = "".concat(_constants2.WEBEX_WEB_CLIENT, "_").concat((0, _uuid.v4)());
177
- _context2.t10 = (0, _context2.t4)(_context2.t8, "trackingId", _context2.t9);
178
- _context2.t11 = _constants2.SPARK_USER_AGENT;
179
- _context2.t12 = _constants2.CALLING_USER_AGENT;
180
- _context2.t13 = (0, _context2.t3)(_context2.t10, _context2.t11, _context2.t12);
181
- _context2.t14 = {
182
- method: _context2.t2,
183
- headers: _context2.t13
145
+ _context.t7 = _context.sent;
146
+ _context.t8 = (0, _context.t5)(_context.t6, "Authorization", _context.t7);
147
+ _context.t9 = "".concat(_constants2.WEBEX_WEB_CLIENT, "_").concat((0, _uuid.v4)());
148
+ _context.t10 = (0, _context.t4)(_context.t8, "trackingId", _context.t9);
149
+ _context.t11 = _constants2.SPARK_USER_AGENT;
150
+ _context.t12 = _constants2.CALLING_USER_AGENT;
151
+ _context.t13 = (0, _context.t3)(_context.t10, _context.t11, _context.t12);
152
+ _context.t14 = {
153
+ method: _context.t2,
154
+ headers: _context.t13
184
155
  };
185
- _context2.next = 20;
186
- return (0, _context2.t0)(_context2.t1, _context2.t14);
156
+ _context.next = 20;
157
+ return (0, _context.t0)(_context.t1, _context.t14);
187
158
  case 20:
188
- response = _context2.sent;
189
- _context2.next = 26;
159
+ response = _context.sent;
160
+ _context.next = 26;
190
161
  break;
191
162
  case 23:
192
- _context2.prev = 23;
193
- _context2.t15 = _context2["catch"](0);
194
- _Logger.default.warn("Delete failed with Mobius ".concat(_context2.t15), {
163
+ _context.prev = 23;
164
+ _context.t15 = _context["catch"](0);
165
+ _Logger.default.warn("Delete failed with Mobius ".concat(_context.t15), {
195
166
  file: _constants2.REGISTRATION_FILE,
196
167
  method: _constants2.METHODS.DEREGISTER
197
168
  });
198
169
  case 26:
199
170
  this.setStatus(_types2.RegistrationStatus.INACTIVE);
200
171
  this.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
201
- return _context2.abrupt("return", (_response = response) === null || _response === void 0 ? void 0 : _response.json());
172
+ return _context.abrupt("return", (_response = response) === null || _response === void 0 ? void 0 : _response.json());
202
173
  case 29:
203
174
  case "end":
204
- return _context2.stop();
175
+ return _context.stop();
205
176
  }
206
- }, _callee2, this, [[0, 23]]);
177
+ }, _callee, this, [[0, 23]]);
207
178
  }));
208
- function deleteRegistration(_x2, _x3, _x4) {
179
+ function deleteRegistration(_x, _x2, _x3) {
209
180
  return _deleteRegistration.apply(this, arguments);
210
181
  }
211
182
  return deleteRegistration;
@@ -218,10 +189,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
218
189
  }, {
219
190
  key: "postRegistration",
220
191
  value: (function () {
221
- var _postRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
192
+ var _postRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url) {
222
193
  var deviceInfo;
223
- return _regenerator.default.wrap(function _callee3$(_context3) {
224
- while (1) switch (_context3.prev = _context3.next) {
194
+ return _regenerator.default.wrap(function _callee2$(_context2) {
195
+ while (1) switch (_context2.prev = _context2.next) {
225
196
  case 0:
226
197
  deviceInfo = {
227
198
  userId: this.userId,
@@ -230,7 +201,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
230
201
  jwe: this.jwe
231
202
  }) : this.serviceData
232
203
  };
233
- return _context3.abrupt("return", this.webex.request({
204
+ return _context2.abrupt("return", this.webex.request({
234
205
  uri: "".concat(url, "device"),
235
206
  method: _types2.HTTP_METHODS.POST,
236
207
  headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceInfo.clientDeviceUri), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
@@ -239,11 +210,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
239
210
  }));
240
211
  case 2:
241
212
  case "end":
242
- return _context3.stop();
213
+ return _context2.stop();
243
214
  }
244
- }, _callee3, this);
215
+ }, _callee2, this);
245
216
  }));
246
- function postRegistration(_x5) {
217
+ function postRegistration(_x4) {
247
218
  return _postRegistration.apply(this, arguments);
248
219
  }
249
220
  return postRegistration;
@@ -256,29 +227,29 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
256
227
  }, {
257
228
  key: "restorePreviousRegistration",
258
229
  value: (function () {
259
- var _restorePreviousRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(caller) {
230
+ var _restorePreviousRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(caller) {
260
231
  var abort;
261
- return _regenerator.default.wrap(function _callee4$(_context4) {
262
- while (1) switch (_context4.prev = _context4.next) {
232
+ return _regenerator.default.wrap(function _callee3$(_context3) {
233
+ while (1) switch (_context3.prev = _context3.next) {
263
234
  case 0:
264
235
  abort = false;
265
236
  if (!this.activeMobiusUrl) {
266
- _context4.next = 5;
237
+ _context3.next = 5;
267
238
  break;
268
239
  }
269
- _context4.next = 4;
240
+ _context3.next = 4;
270
241
  return this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
271
242
  case 4:
272
- abort = _context4.sent;
243
+ abort = _context3.sent;
273
244
  case 5:
274
- return _context4.abrupt("return", abort);
245
+ return _context3.abrupt("return", abort);
275
246
  case 6:
276
247
  case "end":
277
- return _context4.stop();
248
+ return _context3.stop();
278
249
  }
279
- }, _callee4, this);
250
+ }, _callee3, this);
280
251
  }));
281
- function restorePreviousRegistration(_x6) {
252
+ function restorePreviousRegistration(_x5) {
282
253
  return _restorePreviousRegistration.apply(this, arguments);
283
254
  }
284
255
  return restorePreviousRegistration;
@@ -290,20 +261,20 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
290
261
  }, {
291
262
  key: "handle429Retry",
292
263
  value: (function () {
293
- var _handle429Retry = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(retryAfter, caller) {
264
+ var _handle429Retry = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(retryAfter, caller) {
294
265
  var interval, abort;
295
- return _regenerator.default.wrap(function _callee5$(_context5) {
296
- while (1) switch (_context5.prev = _context5.next) {
266
+ return _regenerator.default.wrap(function _callee4$(_context4) {
267
+ while (1) switch (_context4.prev = _context4.next) {
297
268
  case 0:
298
269
  if (!(caller === _constants2.FAILBACK_UTIL)) {
299
- _context5.next = 17;
270
+ _context4.next = 17;
300
271
  break;
301
272
  }
302
273
  if (!(this.failback429RetryAttempts >= _constants2.REG_FAILBACK_429_MAX_RETRIES)) {
303
- _context5.next = 3;
274
+ _context4.next = 3;
304
275
  break;
305
276
  }
306
- return _context5.abrupt("return");
277
+ return _context4.abrupt("return");
307
278
  case 3:
308
279
  this.clearFailbackTimer();
309
280
  this.failback429RetryAttempts += 1;
@@ -314,28 +285,28 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
314
285
  interval = this.getRegRetryInterval(this.failback429RetryAttempts);
315
286
  this.startFailbackTimer(interval);
316
287
  this.scheduled429Retry = true;
317
- _context5.next = 11;
288
+ _context4.next = 11;
318
289
  return this.restorePreviousRegistration(_constants2.REG_429_RETRY_UTIL);
319
290
  case 11:
320
- abort = _context5.sent;
291
+ abort = _context4.sent;
321
292
  if (!(!abort && !this.isDeviceRegistered())) {
322
- _context5.next = 15;
293
+ _context4.next = 15;
323
294
  break;
324
295
  }
325
- _context5.next = 15;
296
+ _context4.next = 15;
326
297
  return this.restartRegistration(_constants2.REG_429_RETRY_UTIL);
327
298
  case 15:
328
- _context5.next = 18;
299
+ _context4.next = 18;
329
300
  break;
330
301
  case 17:
331
302
  this.retryAfter = retryAfter;
332
303
  case 18:
333
304
  case "end":
334
- return _context5.stop();
305
+ return _context4.stop();
335
306
  }
336
- }, _callee5, this);
307
+ }, _callee4, this);
337
308
  }));
338
- function handle429Retry(_x7, _x8) {
309
+ function handle429Retry(_x6, _x7) {
339
310
  return _handle429Retry.apply(this, arguments);
340
311
  }
341
312
  return handle429Retry;
@@ -364,7 +335,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
364
335
  }, {
365
336
  key: "startFailoverTimer",
366
337
  value: (function () {
367
- var _startFailoverTimer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
338
+ var _startFailoverTimer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
368
339
  var _this = this;
369
340
  var attempt,
370
341
  timeElapsed,
@@ -374,12 +345,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
374
345
  excessVal,
375
346
  abort,
376
347
  scheduledTime,
377
- _args10 = arguments;
378
- return _regenerator.default.wrap(function _callee10$(_context10) {
379
- while (1) switch (_context10.prev = _context10.next) {
348
+ _args9 = arguments;
349
+ return _regenerator.default.wrap(function _callee9$(_context9) {
350
+ while (1) switch (_context9.prev = _context9.next) {
380
351
  case 0:
381
- attempt = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : 1;
382
- timeElapsed = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 0;
352
+ attempt = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : 1;
353
+ timeElapsed = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 0;
383
354
  loggerContext = {
384
355
  file: _constants2.REGISTRATION_FILE,
385
356
  method: _constants2.FAILOVER_UTIL
@@ -394,83 +365,83 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
394
365
  this.failoverImmediately = this.retryAfter + timeElapsed > TIMER_THRESHOLD;
395
366
  }
396
367
  if (!(interval > _constants2.BASE_REG_RETRY_TIMER_VAL_IN_SEC && !this.failoverImmediately)) {
397
- _context10.next = 14;
368
+ _context9.next = 14;
398
369
  break;
399
370
  }
400
371
  scheduledTime = Math.floor((0, _now.default)() / 1000);
401
372
  if (this.retryAfter != null) {
402
373
  interval = Math.max(interval, this.retryAfter);
403
374
  }
404
- setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
405
- return _regenerator.default.wrap(function _callee7$(_context7) {
406
- while (1) switch (_context7.prev = _context7.next) {
375
+ setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
376
+ return _regenerator.default.wrap(function _callee6$(_context6) {
377
+ while (1) switch (_context6.prev = _context6.next) {
407
378
  case 0:
408
- _context7.next = 2;
409
- return _this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
379
+ _context6.next = 2;
380
+ return _this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
410
381
  var currentTime;
411
- return _regenerator.default.wrap(function _callee6$(_context6) {
412
- while (1) switch (_context6.prev = _context6.next) {
382
+ return _regenerator.default.wrap(function _callee5$(_context5) {
383
+ while (1) switch (_context5.prev = _context5.next) {
413
384
  case 0:
414
- _context6.next = 2;
385
+ _context5.next = 2;
415
386
  return _this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL);
416
387
  case 2:
417
- abort = _context6.sent;
388
+ abort = _context5.sent;
418
389
  currentTime = Math.floor((0, _now.default)() / 1000);
419
390
  if (!(!abort && !_this.isDeviceRegistered())) {
420
- _context6.next = 7;
391
+ _context5.next = 7;
421
392
  break;
422
393
  }
423
- _context6.next = 7;
394
+ _context5.next = 7;
424
395
  return _this.startFailoverTimer(attempt + 1, timeElapsed + (currentTime - scheduledTime));
425
396
  case 7:
426
397
  case "end":
427
- return _context6.stop();
398
+ return _context5.stop();
428
399
  }
429
- }, _callee6);
400
+ }, _callee5);
430
401
  })));
431
402
  case 2:
432
403
  case "end":
433
- return _context7.stop();
404
+ return _context6.stop();
434
405
  }
435
- }, _callee7);
406
+ }, _callee6);
436
407
  })), interval * _constants2.SEC_TO_MSEC_MFACTOR);
437
408
  _Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
438
- _context10.next = 26;
409
+ _context9.next = 26;
439
410
  break;
440
411
  case 14:
441
412
  if (!this.backupMobiusUris.length) {
442
- _context10.next = 23;
413
+ _context9.next = 23;
443
414
  break;
444
415
  }
445
416
  _Logger.default.info('Failing over to backup servers.', loggerContext);
446
417
  this.failoverImmediately = false;
447
- _context10.next = 19;
418
+ _context9.next = 19;
448
419
  return this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, this.backupMobiusUris);
449
420
  case 19:
450
- abort = _context10.sent;
421
+ abort = _context9.sent;
451
422
  if (!abort && !this.isDeviceRegistered()) {
452
423
  interval = this.getRegRetryInterval();
453
424
  if (this.retryAfter != null && this.retryAfter < _constants2.RETRY_TIMER_UPPER_LIMIT) {
454
425
  interval = interval < this.retryAfter ? this.retryAfter : interval;
455
426
  }
456
- setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
457
- return _regenerator.default.wrap(function _callee9$(_context9) {
458
- while (1) switch (_context9.prev = _context9.next) {
427
+ setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
428
+ return _regenerator.default.wrap(function _callee8$(_context8) {
429
+ while (1) switch (_context8.prev = _context8.next) {
459
430
  case 0:
460
- _context9.next = 2;
461
- return _this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
462
- return _regenerator.default.wrap(function _callee8$(_context8) {
463
- while (1) switch (_context8.prev = _context8.next) {
431
+ _context8.next = 2;
432
+ return _this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
433
+ return _regenerator.default.wrap(function _callee7$(_context7) {
434
+ while (1) switch (_context7.prev = _context7.next) {
464
435
  case 0:
465
- _context8.next = 2;
436
+ _context7.next = 2;
466
437
  return _this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, _this.backupMobiusUris);
467
438
  case 2:
468
- abort = _context8.sent;
439
+ abort = _context7.sent;
469
440
  if (!(!abort && !_this.isDeviceRegistered())) {
470
- _context8.next = 7;
441
+ _context7.next = 7;
471
442
  break;
472
443
  }
473
- _context8.next = 6;
444
+ _context7.next = 6;
474
445
  return (0, _common.uploadLogs)();
475
446
  case 6:
476
447
  (0, _common.emitFinalFailure)(function (clientError) {
@@ -478,22 +449,22 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
478
449
  }, loggerContext);
479
450
  case 7:
480
451
  case "end":
481
- return _context8.stop();
452
+ return _context7.stop();
482
453
  }
483
- }, _callee8);
454
+ }, _callee7);
484
455
  })));
485
456
  case 2:
486
457
  case "end":
487
- return _context9.stop();
458
+ return _context8.stop();
488
459
  }
489
- }, _callee9);
460
+ }, _callee8);
490
461
  })), interval * _constants2.SEC_TO_MSEC_MFACTOR);
491
462
  _Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
492
463
  }
493
- _context10.next = 26;
464
+ _context9.next = 26;
494
465
  break;
495
466
  case 23:
496
- _context10.next = 25;
467
+ _context9.next = 25;
497
468
  return (0, _common.uploadLogs)();
498
469
  case 25:
499
470
  (0, _common.emitFinalFailure)(function (clientError) {
@@ -501,9 +472,9 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
501
472
  }, loggerContext);
502
473
  case 26:
503
474
  case "end":
504
- return _context10.stop();
475
+ return _context9.stop();
505
476
  }
506
- }, _callee10, this);
477
+ }, _callee9, this);
507
478
  }));
508
479
  function startFailoverTimer() {
509
480
  return _startFailoverTimer.apply(this, arguments);
@@ -569,16 +540,16 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
569
540
  key: "startFailbackTimer",
570
541
  value: function startFailbackTimer(intervalInSeconds) {
571
542
  var _this2 = this;
572
- this.failbackTimer = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
573
- return _regenerator.default.wrap(function _callee11$(_context11) {
574
- while (1) switch (_context11.prev = _context11.next) {
543
+ this.failbackTimer = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
544
+ return _regenerator.default.wrap(function _callee10$(_context10) {
545
+ while (1) switch (_context10.prev = _context10.next) {
575
546
  case 0:
576
- return _context11.abrupt("return", _this2.executeFailback());
547
+ return _context10.abrupt("return", _this2.executeFailback());
577
548
  case 1:
578
549
  case "end":
579
- return _context11.stop();
550
+ return _context10.stop();
580
551
  }
581
- }, _callee11);
552
+ }, _callee10);
582
553
  })), intervalInSeconds * _constants2.SEC_TO_MSEC_MFACTOR);
583
554
  _Logger.default.log("Failback scheduled after ".concat(intervalInSeconds, " seconds."), {
584
555
  file: _constants2.REGISTRATION_FILE,
@@ -593,67 +564,67 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
593
564
  }, {
594
565
  key: "executeFailback",
595
566
  value: (function () {
596
- var _executeFailback = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
567
+ var _executeFailback = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
597
568
  var _this3 = this;
598
- return _regenerator.default.wrap(function _callee13$(_context13) {
599
- while (1) switch (_context13.prev = _context13.next) {
569
+ return _regenerator.default.wrap(function _callee12$(_context12) {
570
+ while (1) switch (_context12.prev = _context12.next) {
600
571
  case 0:
601
- _context13.next = 2;
602
- return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
572
+ _context12.next = 2;
573
+ return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
603
574
  var abort, abortNew;
604
- return _regenerator.default.wrap(function _callee12$(_context12) {
605
- while (1) switch (_context12.prev = _context12.next) {
575
+ return _regenerator.default.wrap(function _callee11$(_context11) {
576
+ while (1) switch (_context11.prev = _context11.next) {
606
577
  case 0:
607
578
  if (!_this3.isFailbackRequired()) {
608
- _context12.next = 28;
579
+ _context11.next = 28;
609
580
  break;
610
581
  }
611
582
  if (!((0, _keys.default)(_this3.callManager.getActiveCalls()).length === 0)) {
612
- _context12.next = 25;
583
+ _context11.next = 25;
613
584
  break;
614
585
  }
615
586
  _Logger.default.info("Attempting failback to primary.", {
616
587
  file: _constants2.REGISTRATION_FILE,
617
588
  method: _this3.executeFailback.name
618
589
  });
619
- _context12.next = 5;
590
+ _context11.next = 5;
620
591
  return _this3.deregister();
621
592
  case 5:
622
- _context12.next = 7;
593
+ _context11.next = 7;
623
594
  return _this3.attemptRegistrationWithServers(_constants2.FAILBACK_UTIL);
624
595
  case 7:
625
- abort = _context12.sent;
596
+ abort = _context11.sent;
626
597
  if (!(_this3.scheduled429Retry || abort || _this3.isDeviceRegistered())) {
627
- _context12.next = 10;
598
+ _context11.next = 10;
628
599
  break;
629
600
  }
630
- return _context12.abrupt("return");
601
+ return _context11.abrupt("return");
631
602
  case 10:
632
- _context12.next = 12;
603
+ _context11.next = 12;
633
604
  return _this3.restorePreviousRegistration(_constants2.FAILBACK_UTIL);
634
605
  case 12:
635
- abortNew = _context12.sent;
606
+ abortNew = _context11.sent;
636
607
  if (!abortNew) {
637
- _context12.next = 16;
608
+ _context11.next = 16;
638
609
  break;
639
610
  }
640
611
  _this3.clearFailbackTimer();
641
- return _context12.abrupt("return");
612
+ return _context11.abrupt("return");
642
613
  case 16:
643
614
  if (_this3.isDeviceRegistered()) {
644
- _context12.next = 21;
615
+ _context11.next = 21;
645
616
  break;
646
617
  }
647
- _context12.next = 19;
618
+ _context11.next = 19;
648
619
  return _this3.restartRegistration(_this3.executeFailback.name);
649
620
  case 19:
650
- _context12.next = 23;
621
+ _context11.next = 23;
651
622
  break;
652
623
  case 21:
653
624
  _this3.failbackTimer = undefined;
654
625
  _this3.initiateFailback();
655
626
  case 23:
656
- _context12.next = 28;
627
+ _context11.next = 28;
657
628
  break;
658
629
  case 25:
659
630
  _Logger.default.info('Active calls present, deferring failback to next cycle.', {
@@ -664,15 +635,15 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
664
635
  _this3.initiateFailback();
665
636
  case 28:
666
637
  case "end":
667
- return _context12.stop();
638
+ return _context11.stop();
668
639
  }
669
- }, _callee12);
640
+ }, _callee11);
670
641
  })));
671
642
  case 2:
672
643
  case "end":
673
- return _context13.stop();
644
+ return _context12.stop();
674
645
  }
675
- }, _callee13, this);
646
+ }, _callee12, this);
676
647
  }));
677
648
  function executeFailback() {
678
649
  return _executeFailback.apply(this, arguments);
@@ -735,10 +706,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
735
706
  }, {
736
707
  key: "restartRegistration",
737
708
  value: (function () {
738
- var _restartRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(caller) {
709
+ var _restartRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(caller) {
739
710
  var abort;
740
- return _regenerator.default.wrap(function _callee14$(_context14) {
741
- while (1) switch (_context14.prev = _context14.next) {
711
+ return _regenerator.default.wrap(function _callee13$(_context13) {
712
+ while (1) switch (_context13.prev = _context13.next) {
742
713
  case 0:
743
714
  /*
744
715
  * Cancel any failback timer running
@@ -746,23 +717,23 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
746
717
  */
747
718
  this.clearFailbackTimer();
748
719
  this.failback429RetryAttempts = 0;
749
- _context14.next = 4;
720
+ _context13.next = 4;
750
721
  return this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
751
722
  case 4:
752
- abort = _context14.sent;
723
+ abort = _context13.sent;
753
724
  if (!(!abort && !this.isDeviceRegistered())) {
754
- _context14.next = 8;
725
+ _context13.next = 8;
755
726
  break;
756
727
  }
757
- _context14.next = 8;
728
+ _context13.next = 8;
758
729
  return this.startFailoverTimer();
759
730
  case 8:
760
731
  case "end":
761
- return _context14.stop();
732
+ return _context13.stop();
762
733
  }
763
- }, _callee14, this);
734
+ }, _callee13, this);
764
735
  }));
765
- function restartRegistration(_x9) {
736
+ function restartRegistration(_x8) {
766
737
  return _restartRegistration.apply(this, arguments);
767
738
  }
768
739
  return restartRegistration;
@@ -776,23 +747,23 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
776
747
  }, {
777
748
  key: "handleConnectionRestoration",
778
749
  value: (function () {
779
- var _handleConnectionRestoration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(retry) {
750
+ var _handleConnectionRestoration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(retry) {
780
751
  var _this4 = this;
781
- return _regenerator.default.wrap(function _callee16$(_context16) {
782
- while (1) switch (_context16.prev = _context16.next) {
752
+ return _regenerator.default.wrap(function _callee15$(_context15) {
753
+ while (1) switch (_context15.prev = _context15.next) {
783
754
  case 0:
784
755
  _Logger.default.info(_constants.METHOD_START_MESSAGE, {
785
756
  method: _constants2.METHODS.HANDLE_CONNECTION_RESTORATION,
786
757
  file: _constants2.REGISTRATION_FILE
787
758
  });
788
- _context16.next = 3;
789
- return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
759
+ _context15.next = 3;
760
+ return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
790
761
  var abort;
791
- return _regenerator.default.wrap(function _callee15$(_context15) {
792
- while (1) switch (_context15.prev = _context15.next) {
762
+ return _regenerator.default.wrap(function _callee14$(_context14) {
763
+ while (1) switch (_context14.prev = _context14.next) {
793
764
  case 0:
794
765
  if (!retry) {
795
- _context15.next = 14;
766
+ _context14.next = 14;
796
767
  break;
797
768
  }
798
769
  _Logger.default.log('Mercury connection is up again, re-registering with Webex Calling if needed', {
@@ -801,43 +772,43 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
801
772
  });
802
773
  _this4.clearKeepaliveTimer();
803
774
  if (!_this4.isDeviceRegistered()) {
804
- _context15.next = 6;
775
+ _context14.next = 6;
805
776
  break;
806
777
  }
807
- _context15.next = 6;
778
+ _context14.next = 6;
808
779
  return _this4.deregister();
809
780
  case 6:
810
781
  if (!_this4.activeMobiusUrl) {
811
- _context15.next = 13;
782
+ _context14.next = 13;
812
783
  break;
813
784
  }
814
- _context15.next = 9;
785
+ _context14.next = 9;
815
786
  return _this4.restorePreviousRegistration(_this4.handleConnectionRestoration.name);
816
787
  case 9:
817
- abort = _context15.sent;
788
+ abort = _context14.sent;
818
789
  if (!(!abort && !_this4.isDeviceRegistered())) {
819
- _context15.next = 13;
790
+ _context14.next = 13;
820
791
  break;
821
792
  }
822
- _context15.next = 13;
793
+ _context14.next = 13;
823
794
  return _this4.restartRegistration(_this4.handleConnectionRestoration.name);
824
795
  case 13:
825
796
  retry = false;
826
797
  case 14:
827
798
  case "end":
828
- return _context15.stop();
799
+ return _context14.stop();
829
800
  }
830
- }, _callee15);
801
+ }, _callee14);
831
802
  })));
832
803
  case 3:
833
- return _context16.abrupt("return", retry);
804
+ return _context15.abrupt("return", retry);
834
805
  case 4:
835
806
  case "end":
836
- return _context16.stop();
807
+ return _context15.stop();
837
808
  }
838
- }, _callee16, this);
809
+ }, _callee15, this);
839
810
  }));
840
- function handleConnectionRestoration(_x10) {
811
+ function handleConnectionRestoration(_x9) {
841
812
  return _handleConnectionRestoration.apply(this, arguments);
842
813
  }
843
814
  return handleConnectionRestoration;
@@ -853,53 +824,53 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
853
824
  value: function restoreRegistrationCallBack() {
854
825
  var _this5 = this;
855
826
  return /*#__PURE__*/function () {
856
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(restoreData, caller) {
827
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(restoreData, caller) {
857
828
  var logContext, restore, finalError;
858
- return _regenerator.default.wrap(function _callee17$(_context17) {
859
- while (1) switch (_context17.prev = _context17.next) {
829
+ return _regenerator.default.wrap(function _callee16$(_context16) {
830
+ while (1) switch (_context16.prev = _context16.next) {
860
831
  case 0:
861
832
  logContext = {
862
833
  file: _constants2.REGISTRATION_FILE,
863
834
  method: caller
864
835
  };
865
836
  if (_this5.isRegRetry()) {
866
- _context17.next = 17;
837
+ _context16.next = 17;
867
838
  break;
868
839
  }
869
840
  _Logger.default.info('Registration restoration in progress.', logContext);
870
841
  restore = _this5.getExistingDevice(restoreData);
871
842
  if (!restore) {
872
- _context17.next = 14;
843
+ _context16.next = 14;
873
844
  break;
874
845
  }
875
846
  _this5.setRegRetry(true);
876
- _context17.next = 8;
847
+ _context16.next = 8;
877
848
  return _this5.deregister();
878
849
  case 8:
879
- _context17.next = 10;
850
+ _context16.next = 10;
880
851
  return _this5.restorePreviousRegistration(caller);
881
852
  case 10:
882
- finalError = _context17.sent;
853
+ finalError = _context16.sent;
883
854
  _this5.setRegRetry(false);
884
855
  if (_this5.isDeviceRegistered()) {
885
856
  _Logger.default.info('Registration restored successfully.', logContext);
886
857
  }
887
- return _context17.abrupt("return", finalError);
858
+ return _context16.abrupt("return", finalError);
888
859
  case 14:
889
860
  _this5.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
890
- _context17.next = 18;
861
+ _context16.next = 18;
891
862
  break;
892
863
  case 17:
893
864
  _this5.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
894
865
  case 18:
895
- return _context17.abrupt("return", false);
866
+ return _context16.abrupt("return", false);
896
867
  case 19:
897
868
  case "end":
898
- return _context17.stop();
869
+ return _context16.stop();
899
870
  }
900
- }, _callee17);
871
+ }, _callee16);
901
872
  }));
902
- return function (_x11, _x12) {
873
+ return function (_x10, _x11) {
903
874
  return _ref8.apply(this, arguments);
904
875
  };
905
876
  }();
@@ -912,30 +883,30 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
912
883
  }, {
913
884
  key: "triggerRegistration",
914
885
  value: (function () {
915
- var _triggerRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
886
+ var _triggerRegistration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
916
887
  var abort;
917
- return _regenerator.default.wrap(function _callee18$(_context18) {
918
- while (1) switch (_context18.prev = _context18.next) {
888
+ return _regenerator.default.wrap(function _callee17$(_context17) {
889
+ while (1) switch (_context17.prev = _context17.next) {
919
890
  case 0:
920
891
  if (!(this.primaryMobiusUris.length > 0)) {
921
- _context18.next = 7;
892
+ _context17.next = 7;
922
893
  break;
923
894
  }
924
- _context18.next = 3;
895
+ _context17.next = 3;
925
896
  return this.attemptRegistrationWithServers(_constants2.REGISTRATION_UTIL, this.primaryMobiusUris);
926
897
  case 3:
927
- abort = _context18.sent;
898
+ abort = _context17.sent;
928
899
  if (!(!this.isDeviceRegistered() && !abort)) {
929
- _context18.next = 7;
900
+ _context17.next = 7;
930
901
  break;
931
902
  }
932
- _context18.next = 7;
903
+ _context17.next = 7;
933
904
  return this.startFailoverTimer();
934
905
  case 7:
935
906
  case "end":
936
- return _context18.stop();
907
+ return _context17.stop();
937
908
  }
938
- }, _callee18, this);
909
+ }, _callee17, this);
939
910
  }));
940
911
  function triggerRegistration() {
941
912
  return _triggerRegistration.apply(this, arguments);
@@ -954,7 +925,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
954
925
  }, {
955
926
  key: "attemptRegistrationWithServers",
956
927
  value: (function () {
957
- var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(caller) {
928
+ var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(caller) {
958
929
  var _this6 = this;
959
930
  var servers,
960
931
  abort,
@@ -962,40 +933,40 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
962
933
  _step,
963
934
  _loop,
964
935
  _ret,
965
- _args20 = arguments;
966
- return _regenerator.default.wrap(function _callee19$(_context20) {
967
- while (1) switch (_context20.prev = _context20.next) {
936
+ _args19 = arguments;
937
+ return _regenerator.default.wrap(function _callee18$(_context19) {
938
+ while (1) switch (_context19.prev = _context19.next) {
968
939
  case 0:
969
- servers = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : this.primaryMobiusUris;
940
+ servers = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : this.primaryMobiusUris;
970
941
  abort = false;
971
942
  this.retryAfter = undefined;
972
943
  if (!this.failoverImmediately) {
973
- _context20.next = 5;
944
+ _context19.next = 5;
974
945
  break;
975
946
  }
976
- return _context20.abrupt("return", abort);
947
+ return _context19.abrupt("return", abort);
977
948
  case 5:
978
949
  if (!this.isDeviceRegistered()) {
979
- _context20.next = 8;
950
+ _context19.next = 8;
980
951
  break;
981
952
  }
982
953
  _Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), {
983
954
  file: _constants2.REGISTRATION_FILE,
984
955
  method: _constants2.REGISTER_UTIL
985
956
  });
986
- return _context20.abrupt("return", abort);
957
+ return _context19.abrupt("return", abort);
987
958
  case 8:
988
959
  _iterator = _createForOfIteratorHelper(servers);
989
- _context20.prev = 9;
960
+ _context19.prev = 9;
990
961
  _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
991
962
  var _this6$backupMobiusUr;
992
963
  var url, serverType, _this6$deviceInfo$dev, _resp$headers$trackin, _resp$headers, _this6$deviceInfo$dev2, resp, body;
993
- return _regenerator.default.wrap(function _loop$(_context19) {
994
- while (1) switch (_context19.prev = _context19.next) {
964
+ return _regenerator.default.wrap(function _loop$(_context18) {
965
+ while (1) switch (_context18.prev = _context18.next) {
995
966
  case 0:
996
967
  url = _step.value;
997
968
  serverType = _this6.primaryMobiusUris.includes(url) && 'PRIMARY' || ((_this6$backupMobiusUr = _this6.backupMobiusUris) === null || _this6$backupMobiusUr === void 0 ? void 0 : _this6$backupMobiusUr.includes(url)) && 'BACKUP' || 'UNKNOWN';
998
- _context19.prev = 2;
969
+ _context18.prev = 2;
999
970
  abort = false;
1000
971
  _this6.registrationStatus = _types2.RegistrationStatus.INACTIVE;
1001
972
  _this6.lineEmitter(_types3.LINE_EVENTS.CONNECTING);
@@ -1004,10 +975,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1004
975
  method: _constants2.REGISTER_UTIL
1005
976
  });
1006
977
  // eslint-disable-next-line no-await-in-loop
1007
- _context19.next = 9;
978
+ _context18.next = 9;
1008
979
  return _this6.postRegistration(url);
1009
980
  case 9:
1010
- resp = _context19.sent;
981
+ resp = _context18.sent;
1011
982
  _this6.deviceInfo = resp.body;
1012
983
  _this6.registrationStatus = _types2.RegistrationStatus.ACTIVE;
1013
984
  _this6.lineEmitter(_types3.LINE_EVENTS.REGISTERED, resp.body);
@@ -1021,12 +992,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1021
992
  _this6.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, caller, serverType, (_resp$headers$trackin = (_resp$headers = resp.headers) === null || _resp$headers === void 0 ? void 0 : _resp$headers.trackingid) !== null && _resp$headers$trackin !== void 0 ? _resp$headers$trackin : '', undefined, undefined);
1022
993
  _this6.startKeepaliveTimer((_this6$deviceInfo$dev2 = _this6.deviceInfo.device) === null || _this6$deviceInfo$dev2 === void 0 ? void 0 : _this6$deviceInfo$dev2.uri, _this6.deviceInfo.keepaliveInterval, serverType);
1023
994
  _this6.initiateFailback();
1024
- return _context19.abrupt("return", 0);
995
+ return _context18.abrupt("return", 0);
1025
996
  case 23:
1026
- _context19.prev = 23;
1027
- _context19.t0 = _context19["catch"](2);
1028
- body = _context19.t0; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
1029
- _context19.next = 28;
997
+ _context18.prev = 23;
998
+ _context18.t0 = _context18["catch"](2);
999
+ body = _context18.t0; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
1000
+ _context18.next = 28;
1030
1001
  return (0, _common.handleRegistrationErrors)(body, function (clientError, finalError) {
1031
1002
  var _body$headers$trackin, _body$headers;
1032
1003
  if (finalError) {
@@ -1042,66 +1013,66 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1042
1013
  return _this6.handle429Retry(retryAfter, retryCaller);
1043
1014
  }, _this6.restoreRegistrationCallBack());
1044
1015
  case 28:
1045
- abort = _context19.sent;
1016
+ abort = _context18.sent;
1046
1017
  if (!(_this6.registrationStatus === _types2.RegistrationStatus.ACTIVE)) {
1047
- _context19.next = 32;
1018
+ _context18.next = 32;
1048
1019
  break;
1049
1020
  }
1050
1021
  _Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(_this6.activeMobiusUrl), {
1051
1022
  file: _constants2.REGISTRATION_FILE,
1052
1023
  method: _this6.attemptRegistrationWithServers.name
1053
1024
  });
1054
- return _context19.abrupt("return", 0);
1025
+ return _context18.abrupt("return", 0);
1055
1026
  case 32:
1056
1027
  if (!abort) {
1057
- _context19.next = 35;
1028
+ _context18.next = 35;
1058
1029
  break;
1059
1030
  }
1060
1031
  _this6.setStatus(_types2.RegistrationStatus.INACTIVE);
1061
- return _context19.abrupt("return", 0);
1032
+ return _context18.abrupt("return", 0);
1062
1033
  case 35:
1063
1034
  case "end":
1064
- return _context19.stop();
1035
+ return _context18.stop();
1065
1036
  }
1066
1037
  }, _loop, null, [[2, 23]]);
1067
1038
  });
1068
1039
  _iterator.s();
1069
1040
  case 12:
1070
1041
  if ((_step = _iterator.n()).done) {
1071
- _context20.next = 19;
1042
+ _context19.next = 19;
1072
1043
  break;
1073
1044
  }
1074
- return _context20.delegateYield(_loop(), "t0", 14);
1045
+ return _context19.delegateYield(_loop(), "t0", 14);
1075
1046
  case 14:
1076
- _ret = _context20.t0;
1047
+ _ret = _context19.t0;
1077
1048
  if (!(_ret === 0)) {
1078
- _context20.next = 17;
1049
+ _context19.next = 17;
1079
1050
  break;
1080
1051
  }
1081
- return _context20.abrupt("break", 19);
1052
+ return _context19.abrupt("break", 19);
1082
1053
  case 17:
1083
- _context20.next = 12;
1054
+ _context19.next = 12;
1084
1055
  break;
1085
1056
  case 19:
1086
- _context20.next = 24;
1057
+ _context19.next = 24;
1087
1058
  break;
1088
1059
  case 21:
1089
- _context20.prev = 21;
1090
- _context20.t1 = _context20["catch"](9);
1091
- _iterator.e(_context20.t1);
1060
+ _context19.prev = 21;
1061
+ _context19.t1 = _context19["catch"](9);
1062
+ _iterator.e(_context19.t1);
1092
1063
  case 24:
1093
- _context20.prev = 24;
1064
+ _context19.prev = 24;
1094
1065
  _iterator.f();
1095
- return _context20.finish(24);
1066
+ return _context19.finish(24);
1096
1067
  case 27:
1097
- return _context20.abrupt("return", abort);
1068
+ return _context19.abrupt("return", abort);
1098
1069
  case 28:
1099
1070
  case "end":
1100
- return _context20.stop();
1071
+ return _context19.stop();
1101
1072
  }
1102
- }, _callee19, this, [[9, 21, 24, 27]]);
1073
+ }, _callee18, this, [[9, 21, 24, 27]]);
1103
1074
  }));
1104
- function attemptRegistrationWithServers(_x13) {
1075
+ function attemptRegistrationWithServers(_x12) {
1105
1076
  return _attemptRegistrationWithServers.apply(this, arguments);
1106
1077
  }
1107
1078
  return attemptRegistrationWithServers;
@@ -1113,104 +1084,133 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1113
1084
  )
1114
1085
  }, {
1115
1086
  key: "startKeepaliveTimer",
1116
- value: function startKeepaliveTimer(url, interval, serverType) {
1117
- var _this7 = this;
1118
- var keepAliveRetryCount = 0;
1119
- this.clearKeepaliveTimer();
1120
- var RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
1121
- this.keepaliveTimer = setInterval( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
1122
- var logContext;
1087
+ value: (function () {
1088
+ var _startKeepaliveTimer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(url, interval, serverType) {
1089
+ var _this7 = this;
1090
+ var RETRY_COUNT_THRESHOLD;
1123
1091
  return _regenerator.default.wrap(function _callee21$(_context22) {
1124
1092
  while (1) switch (_context22.prev = _context22.next) {
1125
1093
  case 0:
1126
- logContext = {
1127
- file: _constants2.REGISTRATION_FILE,
1128
- method: _constants2.KEEPALIVE_UTIL
1129
- };
1130
- _context22.next = 3;
1131
- return _this7.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
1132
- var res, error, abort;
1094
+ this.clearKeepaliveTimer();
1095
+ RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
1096
+ _context22.next = 4;
1097
+ return this.mutex.runExclusive( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
1098
+ var accessToken;
1133
1099
  return _regenerator.default.wrap(function _callee20$(_context21) {
1134
1100
  while (1) switch (_context21.prev = _context21.next) {
1135
1101
  case 0:
1136
- if (!(_this7.isDeviceRegistered() && keepAliveRetryCount < RETRY_COUNT_THRESHOLD)) {
1137
- _context21.next = 30;
1102
+ if (!_this7.isDeviceRegistered()) {
1103
+ _context21.next = 5;
1138
1104
  break;
1139
1105
  }
1140
- _context21.prev = 1;
1141
- _context21.next = 4;
1142
- return _this7.postKeepAlive(url);
1143
- case 4:
1144
- res = _context21.sent;
1145
- _Logger.default.log("Sent Keepalive, status: ".concat(res.statusCode), logContext);
1146
- if (keepAliveRetryCount > 0) {
1147
- _this7.lineEmitter(_types3.LINE_EVENTS.RECONNECTED);
1148
- }
1149
- keepAliveRetryCount = 0;
1150
- _context21.next = 30;
1151
- break;
1152
- case 10:
1153
- _context21.prev = 10;
1154
- _context21.t0 = _context21["catch"](1);
1155
- keepAliveRetryCount += 1;
1156
- error = _context21.t0;
1157
- _Logger.default.warn("Keep-alive missed ".concat(keepAliveRetryCount, " times. Status -> ").concat(error.statusCode, " "), logContext);
1158
- _context21.next = 17;
1159
- return (0, _common.handleRegistrationErrors)(error, function (clientError, finalError) {
1160
- var _error$headers$tracki, _error$headers;
1161
- if (finalError) {
1162
- _this7.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
1163
- }
1164
- _this7.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _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 : '', keepAliveRetryCount, clientError);
1165
- }, {
1166
- method: _constants2.KEEPALIVE_UTIL,
1167
- file: _constants2.REGISTRATION_FILE
1168
- });
1169
- case 17:
1170
- abort = _context21.sent;
1171
- if (!(abort || keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
1172
- _context21.next = 29;
1173
- break;
1174
- }
1175
- _this7.failoverImmediately = _this7.isCCFlow;
1176
- _this7.setStatus(_types2.RegistrationStatus.INACTIVE);
1177
- _this7.clearKeepaliveTimer();
1178
- _this7.clearFailbackTimer();
1179
- _this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
1180
- if (abort) {
1181
- _context21.next = 27;
1182
- break;
1106
+ _context21.next = 3;
1107
+ return _this7.webex.credentials.getUserToken();
1108
+ case 3:
1109
+ accessToken = _context21.sent;
1110
+ if (!_this7.webWorker) {
1111
+ _this7.webWorker = new Worker(new URL('./webWorker.js', import.meta.url));
1112
+ _this7.webWorker.postMessage({
1113
+ type: _types2.WorkerMessageType.START_KEEPALIVE,
1114
+ accessToken: String(accessToken),
1115
+ deviceUrl: String(_this7.webex.internal.device.url),
1116
+ interval: interval,
1117
+ retryCountThreshold: RETRY_COUNT_THRESHOLD,
1118
+ url: url
1119
+ });
1120
+ _this7.webWorker.onmessage = /*#__PURE__*/function () {
1121
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(event) {
1122
+ var logContext, error, abort;
1123
+ return _regenerator.default.wrap(function _callee19$(_context20) {
1124
+ while (1) switch (_context20.prev = _context20.next) {
1125
+ case 0:
1126
+ logContext = {
1127
+ file: _constants2.REGISTRATION_FILE,
1128
+ method: _this7.startKeepaliveTimer.name
1129
+ };
1130
+ if (event.data.type === _types2.WorkerMessageType.KEEPALIVE_SUCCESS) {
1131
+ _Logger.default.info("Sent Keepalive, status: ".concat(event.data.statusCode), logContext);
1132
+ _this7.lineEmitter(_types3.LINE_EVENTS.RECONNECTED);
1133
+ }
1134
+ if (!(event.data.type === _types2.WorkerMessageType.KEEPALIVE_FAILURE)) {
1135
+ _context20.next = 20;
1136
+ break;
1137
+ }
1138
+ error = event.data.err;
1139
+ _Logger.default.warn("Keep-alive missed ".concat(event.data.keepAliveRetryCount, " times. Status -> ").concat(error.statusCode, " "), logContext);
1140
+ _context20.next = 7;
1141
+ return (0, _common.handleRegistrationErrors)(error, function (clientError, finalError) {
1142
+ var _error$headers$tracki, _error$headers;
1143
+ if (finalError) {
1144
+ _this7.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
1145
+ }
1146
+ _this7.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _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);
1147
+ }, {
1148
+ method: _constants2.KEEPALIVE_UTIL,
1149
+ file: _constants2.REGISTRATION_FILE
1150
+ });
1151
+ case 7:
1152
+ abort = _context20.sent;
1153
+ if (!(abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
1154
+ _context20.next = 19;
1155
+ break;
1156
+ }
1157
+ _this7.failoverImmediately = _this7.isCCFlow;
1158
+ _this7.setStatus(_types2.RegistrationStatus.INACTIVE);
1159
+ _this7.clearKeepaliveTimer();
1160
+ _this7.clearFailbackTimer();
1161
+ _this7.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
1162
+ if (abort) {
1163
+ _context20.next = 17;
1164
+ break;
1165
+ }
1166
+ _context20.next = 17;
1167
+ return _this7.reconnectOnFailure(_constants2.KEEPALIVE_UTIL);
1168
+ case 17:
1169
+ _context20.next = 20;
1170
+ break;
1171
+ case 19:
1172
+ _this7.lineEmitter(_types3.LINE_EVENTS.RECONNECTING);
1173
+ case 20:
1174
+ case "end":
1175
+ return _context20.stop();
1176
+ }
1177
+ }, _callee19);
1178
+ }));
1179
+ return function (_x16) {
1180
+ return _ref10.apply(this, arguments);
1181
+ };
1182
+ }();
1183
1183
  }
1184
- _context21.next = 27;
1185
- return _this7.reconnectOnFailure(_constants2.KEEPALIVE_UTIL);
1186
- case 27:
1187
- _context21.next = 30;
1188
- break;
1189
- case 29:
1190
- _this7.lineEmitter(_types3.LINE_EVENTS.RECONNECTING);
1191
- case 30:
1184
+ case 5:
1192
1185
  case "end":
1193
1186
  return _context21.stop();
1194
1187
  }
1195
- }, _callee20, null, [[1, 10]]);
1188
+ }, _callee20);
1196
1189
  })));
1197
- case 3:
1190
+ case 4:
1198
1191
  case "end":
1199
1192
  return _context22.stop();
1200
1193
  }
1201
- }, _callee21);
1202
- })), interval * 1000);
1203
- }
1204
-
1194
+ }, _callee21, this);
1195
+ }));
1196
+ function startKeepaliveTimer(_x13, _x14, _x15) {
1197
+ return _startKeepaliveTimer.apply(this, arguments);
1198
+ }
1199
+ return startKeepaliveTimer;
1200
+ }()
1205
1201
  /**
1206
1202
  * Clears the keepalive timer if running.
1207
1203
  */
1204
+ )
1208
1205
  }, {
1209
1206
  key: "clearKeepaliveTimer",
1210
1207
  value: function clearKeepaliveTimer() {
1211
- if (this.keepaliveTimer) {
1212
- clearInterval(this.keepaliveTimer);
1213
- this.keepaliveTimer = undefined;
1208
+ if (this.webWorker) {
1209
+ this.webWorker.postMessage({
1210
+ type: _types2.WorkerMessageType.CLEAR_KEEPALIVE
1211
+ });
1212
+ this.webWorker.terminate();
1213
+ this.webWorker = undefined;
1214
1214
  }
1215
1215
  }
1216
1216
  }, {
@@ -1357,7 +1357,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
1357
1357
  }
1358
1358
  }, _callee23, this);
1359
1359
  }));
1360
- function reconnectOnFailure(_x14) {
1360
+ function reconnectOnFailure(_x17) {
1361
1361
  return _reconnectOnFailure.apply(this, arguments);
1362
1362
  }
1363
1363
  return reconnectOnFailure;