@webex/internal-plugin-device 3.12.0-next.8 → 3.12.0-task-refactor.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.
- package/dist/config.js +10 -16
- package/dist/config.js.map +1 -1
- package/dist/constants.js +1 -6
- package/dist/constants.js.map +1 -1
- package/dist/device.js +79 -181
- package/dist/device.js.map +1 -1
- package/dist/ipNetworkDetector.js +3 -3
- package/dist/ipNetworkDetector.js.map +1 -1
- package/package.json +10 -10
- package/src/config.js +9 -16
- package/src/constants.js +0 -5
- package/src/device.js +26 -150
- package/src/ipNetworkDetector.ts +1 -1
- package/test/unit/spec/device.js +46 -641
package/dist/config.js
CHANGED
|
@@ -59,21 +59,15 @@ var _default = exports.default = {
|
|
|
59
59
|
* energyForcast
|
|
60
60
|
* @type {boolean}
|
|
61
61
|
*/
|
|
62
|
-
energyForecast: false
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* @alias device.machineId
|
|
74
|
-
* @type {string}
|
|
75
|
-
*/
|
|
76
|
-
installationId: undefined
|
|
77
|
-
}
|
|
62
|
+
energyForecast: false
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* installationId is used exclusively as web client for fraud prevention,
|
|
66
|
+
* and is aliased to as machineId by CA.
|
|
67
|
+
*
|
|
68
|
+
* @alias device.machineId
|
|
69
|
+
* @type {string}
|
|
70
|
+
*/
|
|
71
|
+
installationId: undefined
|
|
78
72
|
};
|
|
79
73
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_common","require","_default","exports","default","device","canRegisterWaitDuration","defaults","body","name","process","title","trim","undefined","inBrowser","deviceType","WEB","model","localizedModel","systemName","systemVersion","enableInactivityEnforcement","ephemeral","ephemeralDeviceTTL","energyForecast","
|
|
1
|
+
{"version":3,"names":["_common","require","_default","exports","default","device","canRegisterWaitDuration","defaults","body","name","process","title","trim","undefined","inBrowser","deviceType","WEB","model","localizedModel","systemName","systemVersion","enableInactivityEnforcement","ephemeral","ephemeralDeviceTTL","energyForecast","installationId"],"sources":["config.js"],"sourcesContent":["import {inBrowser, deviceType} from '@webex/common';\n\nexport default {\n device: {\n /**\n * The duration to wait for the catalog to populate in seconds.\n *\n * @type {number}\n */\n canRegisterWaitDuration: 10,\n\n /**\n * The default configuration group when sending registration requests.\n *\n * @type {Object}\n */\n defaults: {\n /**\n * The default body configuration of registration requests.\n *\n * @type {Object}\n */\n body: {\n name:\n (typeof process.title === 'string' ? process.title.trim() : undefined) ||\n (inBrowser && 'browser') ||\n 'javascript',\n deviceType: deviceType.WEB,\n model: 'web-js-sdk',\n localizedModel: 'webex-js-sdk',\n systemName: 'WEBEX_JS_SDK',\n systemVersion: '1.0.0',\n },\n },\n\n /**\n * When true, the **wdm** service will enforce an inactivity duration.\n *\n * @type {boolean}\n */\n enableInactivityEnforcement: false,\n\n /**\n * When true, the device registration will include a ttl value of\n * {@link config.device.ephemeralDeviceTTL} and refresh on an interval of\n * {@link config.device.ephemeralDeviceTTL} / 2 + 60 seconds.\n *\n * @type {boolean}\n */\n ephemeral: false,\n\n /**\n * The ttl value to include in device registration if\n * {@link config.device.ephemeral} is true. Measured in seconds.\n *\n * @type {boolean}\n */\n ephemeralDeviceTTL: 30 * 60,\n\n /**\n * energyForcast\n * @type {boolean}\n */\n energyForecast: false,\n },\n\n /**\n * installationId is used exclusively as web client for fraud prevention,\n * and is aliased to as machineId by CA.\n *\n * @alias device.machineId\n * @type {string}\n */\n installationId: undefined,\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAoD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAErC;EACbC,MAAM,EAAE;IACN;AACJ;AACA;AACA;AACA;IACIC,uBAAuB,EAAE,EAAE;IAE3B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,EAAE;MACR;AACN;AACA;AACA;AACA;MACMC,IAAI,EAAE;QACJC,IAAI,EACF,CAAC,OAAOC,OAAO,CAACC,KAAK,KAAK,QAAQ,GAAGD,OAAO,CAACC,KAAK,CAACC,IAAI,CAAC,CAAC,GAAGC,SAAS,KACpEC,iBAAS,IAAI,SAAU,IACxB,YAAY;QACdC,UAAU,EAAEA,kBAAU,CAACC,GAAG;QAC1BC,KAAK,EAAE,YAAY;QACnBC,cAAc,EAAE,cAAc;QAC9BC,UAAU,EAAE,cAAc;QAC1BC,aAAa,EAAE;MACjB;IACF,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIC,2BAA2B,EAAE,KAAK;IAElC;AACJ;AACA;AACA;AACA;AACA;AACA;IACIC,SAAS,EAAE,KAAK;IAEhB;AACJ;AACA;AACA;AACA;AACA;IACIC,kBAAkB,EAAE,EAAE,GAAG,EAAE;IAE3B;AACJ;AACA;AACA;IACIC,cAAc,EAAE;EAClB,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,cAAc,EAAEZ;AAClB,CAAC","ignoreList":[]}
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.FEATURE_TYPES = exports.FEATURE_COLLECTION_USER = exports.FEATURE_COLLECTION_NAMES = exports.FEATURE_COLLECTION_ENTITLEMENT = exports.FEATURE_COLLECTION_DEVELOPER = exports.DEVICE_EVENT_REGISTRATION_SUCCESS = exports.DEVICE_EVENTS = exports.CISCO_DEVICE_URL = void 0;
|
|
8
8
|
// Feature constants.
|
|
9
9
|
var FEATURE_COLLECTION_DEVELOPER = exports.FEATURE_COLLECTION_DEVELOPER = 'developer';
|
|
10
10
|
var FEATURE_COLLECTION_ENTITLEMENT = exports.FEATURE_COLLECTION_ENTITLEMENT = 'entitlement';
|
|
@@ -20,9 +20,4 @@ var FEATURE_TYPES = exports.FEATURE_TYPES = {
|
|
|
20
20
|
// Device constants.
|
|
21
21
|
var DEVICE_EVENT_REGISTRATION_SUCCESS = exports.DEVICE_EVENT_REGISTRATION_SUCCESS = 'registration:success';
|
|
22
22
|
var DEVICE_EVENTS = exports.DEVICE_EVENTS = [DEVICE_EVENT_REGISTRATION_SUCCESS];
|
|
23
|
-
|
|
24
|
-
// Device deletion constants.
|
|
25
|
-
var MIN_DEVICES_FOR_CLEANUP = exports.MIN_DEVICES_FOR_CLEANUP = 5;
|
|
26
|
-
var MAX_DELETION_CONFIRMATION_ATTEMPTS = exports.MAX_DELETION_CONFIRMATION_ATTEMPTS = 5;
|
|
27
|
-
var DELETION_CONFIRMATION_DELAY_MS = exports.DELETION_CONFIRMATION_DELAY_MS = 3000;
|
|
28
23
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FEATURE_COLLECTION_DEVELOPER","exports","FEATURE_COLLECTION_ENTITLEMENT","FEATURE_COLLECTION_USER","CISCO_DEVICE_URL","FEATURE_COLLECTION_NAMES","FEATURE_TYPES","BOOLEAN","NUMBER","STRING","DEVICE_EVENT_REGISTRATION_SUCCESS","DEVICE_EVENTS"
|
|
1
|
+
{"version":3,"names":["FEATURE_COLLECTION_DEVELOPER","exports","FEATURE_COLLECTION_ENTITLEMENT","FEATURE_COLLECTION_USER","CISCO_DEVICE_URL","FEATURE_COLLECTION_NAMES","FEATURE_TYPES","BOOLEAN","NUMBER","STRING","DEVICE_EVENT_REGISTRATION_SUCCESS","DEVICE_EVENTS"],"sources":["constants.js"],"sourcesContent":["// Feature constants.\nexport const FEATURE_COLLECTION_DEVELOPER = 'developer';\nexport const FEATURE_COLLECTION_ENTITLEMENT = 'entitlement';\nexport const FEATURE_COLLECTION_USER = 'user';\n\nexport const CISCO_DEVICE_URL = 'cisco-device-url';\n\nexport const FEATURE_COLLECTION_NAMES = [\n FEATURE_COLLECTION_DEVELOPER,\n FEATURE_COLLECTION_ENTITLEMENT,\n FEATURE_COLLECTION_USER,\n];\n\nexport const FEATURE_TYPES = {\n BOOLEAN: 'boolean',\n NUMBER: 'number',\n STRING: 'string',\n};\n\n// Device constants.\nexport const DEVICE_EVENT_REGISTRATION_SUCCESS = 'registration:success';\n\nexport const DEVICE_EVENTS = [DEVICE_EVENT_REGISTRATION_SUCCESS];\n"],"mappings":";;;;;;;AAAA;AACO,IAAMA,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,GAAG,WAAW;AAChD,IAAME,8BAA8B,GAAAD,OAAA,CAAAC,8BAAA,GAAG,aAAa;AACpD,IAAMC,uBAAuB,GAAAF,OAAA,CAAAE,uBAAA,GAAG,MAAM;AAEtC,IAAMC,gBAAgB,GAAAH,OAAA,CAAAG,gBAAA,GAAG,kBAAkB;AAE3C,IAAMC,wBAAwB,GAAAJ,OAAA,CAAAI,wBAAA,GAAG,CACtCL,4BAA4B,EAC5BE,8BAA8B,EAC9BC,uBAAuB,CACxB;AAEM,IAAMG,aAAa,GAAAL,OAAA,CAAAK,aAAA,GAAG;EAC3BC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE;AACV,CAAC;;AAED;AACO,IAAMC,iCAAiC,GAAAT,OAAA,CAAAS,iCAAA,GAAG,sBAAsB;AAEhE,IAAMC,aAAa,GAAAV,OAAA,CAAAU,aAAA,GAAG,CAACD,iCAAiC,CAAC","ignoreList":[]}
|
package/dist/device.js
CHANGED
|
@@ -13,11 +13,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
13
13
|
exports.default = void 0;
|
|
14
14
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
15
15
|
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
16
|
-
var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
|
|
17
16
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
18
17
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
|
|
19
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
20
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
21
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
22
19
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
23
20
|
var _common = require("@webex/common");
|
|
@@ -409,105 +406,51 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
409
406
|
});
|
|
410
407
|
},
|
|
411
408
|
/**
|
|
412
|
-
* Fetches devices
|
|
413
|
-
* @returns {Promise<
|
|
409
|
+
* Fetches the web devices and deletes the third of them which are not recent devices in use
|
|
410
|
+
* @returns {Promise<void, Error>}
|
|
414
411
|
*/
|
|
415
|
-
|
|
416
|
-
var
|
|
417
|
-
|
|
412
|
+
deleteDevices: function deleteDevices() {
|
|
413
|
+
var _this2 = this;
|
|
414
|
+
// Fetch devices with a GET request
|
|
418
415
|
return this.request({
|
|
419
416
|
method: 'GET',
|
|
420
417
|
service: 'wdm',
|
|
421
418
|
resource: 'devices'
|
|
422
419
|
}).then(function (response) {
|
|
423
|
-
|
|
420
|
+
var devices = response.body.devices;
|
|
421
|
+
var _this2$_getBody = _this2._getBody(),
|
|
422
|
+
deviceType = _this2$_getBody.deviceType;
|
|
423
|
+
|
|
424
|
+
// Filter devices of type deviceType
|
|
425
|
+
var webDevices = devices.filter(function (item) {
|
|
424
426
|
return item.deviceType === deviceType;
|
|
425
427
|
});
|
|
426
|
-
});
|
|
427
|
-
},
|
|
428
|
-
/**
|
|
429
|
-
* Waits until the server-side device count drops to or below targetCount,
|
|
430
|
-
* polling up to maxAttempts times with a delay between each check.
|
|
431
|
-
* @param {number} targetCount - resolve when device count drops to this value or below
|
|
432
|
-
* @param {number} [attempt=0]
|
|
433
|
-
* @returns {Promise<void>}
|
|
434
|
-
*/
|
|
435
|
-
_waitForDeviceCountBelowLimit: function _waitForDeviceCountBelowLimit(targetCount) {
|
|
436
|
-
var _this2 = this;
|
|
437
|
-
var attempt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
438
|
-
if (attempt >= _constants.MAX_DELETION_CONFIRMATION_ATTEMPTS) {
|
|
439
|
-
this.logger.warn('device: max confirmation attempts reached, proceeding anyway');
|
|
440
|
-
return _promise.default.resolve();
|
|
441
|
-
}
|
|
442
|
-
return new _promise.default(function (resolve) {
|
|
443
|
-
return setTimeout(resolve, _constants.DELETION_CONFIRMATION_DELAY_MS);
|
|
444
|
-
}).then(function () {
|
|
445
|
-
return _this2._getDevicesOfCurrentType();
|
|
446
|
-
}).then(function (devices) {
|
|
447
|
-
_this2.logger.info("device: confirmation check ".concat(attempt + 1, "/").concat(_constants.MAX_DELETION_CONFIRMATION_ATTEMPTS, ", ") + "".concat(devices.length, " devices remaining (target: \u2264 ").concat(targetCount, ")"));
|
|
448
|
-
if (devices.length <= targetCount) {
|
|
449
|
-
_this2.logger.info('device: device count is now safely below limit');
|
|
450
|
-
return _promise.default.resolve();
|
|
451
|
-
}
|
|
452
|
-
return _this2._waitForDeviceCountBelowLimit(targetCount, attempt + 1);
|
|
453
|
-
}).catch(function (error) {
|
|
454
|
-
_this2.logger.warn("device: confirmation check ".concat(attempt + 1, " failed, proceeding anyway:"), error);
|
|
455
|
-
return _promise.default.resolve();
|
|
456
|
-
});
|
|
457
|
-
},
|
|
458
|
-
/**
|
|
459
|
-
* Fetches the web devices and deletes the oldest third, then waits
|
|
460
|
-
* for the server to confirm the count is below the limit.
|
|
461
|
-
* @returns {Promise<void>}
|
|
462
|
-
*/
|
|
463
|
-
deleteDevices: function deleteDevices() {
|
|
464
|
-
var _this3 = this;
|
|
465
|
-
var targetCount;
|
|
466
|
-
return this._getDevicesOfCurrentType().then(function (webDevices) {
|
|
467
428
|
var sortedDevices = (0, _lodash.orderBy)(webDevices, [function (item) {
|
|
468
429
|
return new Date(item.modificationTime);
|
|
469
430
|
}]);
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return _promise.default.all(devicesToDelete.map(function (device) {
|
|
478
|
-
return _this3.request({
|
|
479
|
-
uri: device.url,
|
|
480
|
-
method: 'DELETE'
|
|
481
|
-
}).then(function () {
|
|
482
|
-
return {
|
|
483
|
-
status: 'fulfilled'
|
|
484
|
-
};
|
|
485
|
-
}).catch(function (reason) {
|
|
486
|
-
return {
|
|
487
|
-
status: 'rejected',
|
|
488
|
-
reason: reason
|
|
489
|
-
};
|
|
490
|
-
});
|
|
491
|
-
})).then(function (results) {
|
|
492
|
-
var failed = results.filter(function (r) {
|
|
493
|
-
return r.status === 'rejected';
|
|
431
|
+
|
|
432
|
+
// If there are more than two devices, delete the last third
|
|
433
|
+
if (sortedDevices.length > 2) {
|
|
434
|
+
var totalItems = sortedDevices.length;
|
|
435
|
+
var countToDelete = Math.ceil(totalItems / 3);
|
|
436
|
+
var urlsToDelete = sortedDevices.slice(0, countToDelete).map(function (item) {
|
|
437
|
+
return item.url;
|
|
494
438
|
});
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
_this3.logger.info('device: device count confirmed below limit, cleanup successful');
|
|
439
|
+
return _promise.default.race(urlsToDelete.map(function (url) {
|
|
440
|
+
return _this2.request({
|
|
441
|
+
uri: url,
|
|
442
|
+
method: 'DELETE'
|
|
443
|
+
});
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
446
|
+
return _promise.default.resolve();
|
|
504
447
|
}).catch(function (error) {
|
|
505
|
-
|
|
448
|
+
_this2.logger.error('Failed to retrieve devices:', error);
|
|
506
449
|
return _promise.default.reject(error);
|
|
507
450
|
});
|
|
508
451
|
},
|
|
509
452
|
register: function register() {
|
|
510
|
-
var
|
|
453
|
+
var _this3 = this;
|
|
511
454
|
var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
512
455
|
this.logger.info('device: registering');
|
|
513
456
|
this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);
|
|
@@ -515,17 +458,15 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
515
458
|
// Validate that the device can be registered.
|
|
516
459
|
return this.canRegister().then(function () {
|
|
517
460
|
// Validate if the device is already registered and refresh instead.
|
|
518
|
-
if (
|
|
519
|
-
|
|
520
|
-
return
|
|
461
|
+
if (_this3.registered) {
|
|
462
|
+
_this3.logger.info('device: device already registered, refreshing');
|
|
463
|
+
return _this3.refresh(deviceRegistrationOptions);
|
|
521
464
|
}
|
|
522
|
-
return
|
|
465
|
+
return _this3._registerInternal(deviceRegistrationOptions).catch(function (error) {
|
|
523
466
|
var _error$body;
|
|
524
467
|
if ((error === null || error === void 0 ? void 0 : (_error$body = error.body) === null || _error$body === void 0 ? void 0 : _error$body.message) === 'User has excessive device registrations') {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
_this4.logger.info('device: device cleanup complete, retrying registration');
|
|
528
|
-
return _this4._registerInternal(deviceRegistrationOptions);
|
|
468
|
+
return _this3.deleteDevices().then(function () {
|
|
469
|
+
return _this3._registerInternal(deviceRegistrationOptions);
|
|
529
470
|
});
|
|
530
471
|
}
|
|
531
472
|
throw error;
|
|
@@ -536,7 +477,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
536
477
|
return _objectSpread(_objectSpread({}, this.config.defaults.body ? this.config.defaults.body : {}), this.config.body ? this.config.body : {});
|
|
537
478
|
},
|
|
538
479
|
_registerInternal: function _registerInternal() {
|
|
539
|
-
var
|
|
480
|
+
var _this4 = this;
|
|
540
481
|
var deviceRegistrationOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
541
482
|
this.logger.info('device: making registration request');
|
|
542
483
|
|
|
@@ -569,25 +510,25 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
569
510
|
includeUpstreamServices: "".concat(includeDetails).concat(this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : '')
|
|
570
511
|
}
|
|
571
512
|
}).catch(function (error) {
|
|
572
|
-
|
|
513
|
+
_this4.webex.internal.newMetrics.submitInternalEvent({
|
|
573
514
|
name: 'internal.register.device.response'
|
|
574
515
|
});
|
|
575
516
|
throw error;
|
|
576
517
|
}).then(function (response) {
|
|
577
518
|
// If we've signed out in the mean time, the request ID will have changed
|
|
578
|
-
if (
|
|
579
|
-
|
|
519
|
+
if (_this4.get('register-request-id') !== requestId) {
|
|
520
|
+
_this4.logger.info('device: register request ID mismatch, ignoring response');
|
|
580
521
|
return _promise.default.resolve();
|
|
581
522
|
}
|
|
582
523
|
|
|
583
524
|
// Do not add any processing of response above this as that will affect timestamp
|
|
584
|
-
|
|
525
|
+
_this4.webex.internal.newMetrics.submitInternalEvent({
|
|
585
526
|
name: 'internal.register.device.response'
|
|
586
527
|
});
|
|
587
|
-
|
|
588
|
-
return
|
|
528
|
+
_this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);
|
|
529
|
+
return _this4.processRegistrationSuccess(response);
|
|
589
530
|
}).catch(function (error) {
|
|
590
|
-
|
|
531
|
+
_this4.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_FAILED, {
|
|
591
532
|
fields: {
|
|
592
533
|
error: error
|
|
593
534
|
}
|
|
@@ -596,7 +537,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
596
537
|
});
|
|
597
538
|
},
|
|
598
539
|
unregister: function unregister() {
|
|
599
|
-
var
|
|
540
|
+
var _this5 = this;
|
|
600
541
|
this.logger.info('device: unregistering');
|
|
601
542
|
if (!this.registered) {
|
|
602
543
|
this.logger.warn('device: not registered');
|
|
@@ -606,11 +547,11 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
606
547
|
uri: this.url,
|
|
607
548
|
method: 'DELETE'
|
|
608
549
|
}).then(function () {
|
|
609
|
-
return
|
|
550
|
+
return _this5.clear();
|
|
610
551
|
}).catch(function (reason) {
|
|
611
552
|
if (reason.statusCode === 404) {
|
|
612
|
-
|
|
613
|
-
|
|
553
|
+
_this5.logger.info('device: 404 when deleting device, device is already deleted, clearing device');
|
|
554
|
+
_this5.clear();
|
|
614
555
|
}
|
|
615
556
|
throw reason;
|
|
616
557
|
});
|
|
@@ -644,7 +585,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
644
585
|
* @returns {Promise<void, Error>}
|
|
645
586
|
*/
|
|
646
587
|
checkNetworkReachability: function checkNetworkReachability() {
|
|
647
|
-
var
|
|
588
|
+
var _this6 = this;
|
|
648
589
|
this.logger.info('device: checking network reachability');
|
|
649
590
|
|
|
650
591
|
// Validate if the device has been checked and reset the logout timer.
|
|
@@ -672,13 +613,13 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
672
613
|
method: 'GET',
|
|
673
614
|
uri: this.intranetInactivityCheckUrl
|
|
674
615
|
}).then(function () {
|
|
675
|
-
|
|
676
|
-
return _promise.default.resolve(
|
|
616
|
+
_this6.isInNetwork = true;
|
|
617
|
+
return _promise.default.resolve(_this6.resetLogoutTimer());
|
|
677
618
|
}).catch(function () {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return _promise.default.resolve(
|
|
619
|
+
_this6.logger.info('device: did not reach ping endpoint');
|
|
620
|
+
_this6.logger.info('device: triggering off-network timer');
|
|
621
|
+
_this6.isInNetwork = false;
|
|
622
|
+
return _promise.default.resolve(_this6.resetLogoutTimer());
|
|
682
623
|
});
|
|
683
624
|
},
|
|
684
625
|
/**
|
|
@@ -703,7 +644,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
703
644
|
* @returns {Promise<string, Error>} - The priority-mapped web socket url.
|
|
704
645
|
*/
|
|
705
646
|
getWebSocketUrl: function getWebSocketUrl() {
|
|
706
|
-
var
|
|
647
|
+
var _this7 = this;
|
|
707
648
|
var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
708
649
|
this.logger.info('device: getting the current websocket url');
|
|
709
650
|
|
|
@@ -713,9 +654,9 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
713
654
|
// Validate if the method should wait for registration.
|
|
714
655
|
if (wait) {
|
|
715
656
|
return this.waitForRegistration().then(function () {
|
|
716
|
-
return services.convertUrlToPriorityHostUrl(
|
|
657
|
+
return services.convertUrlToPriorityHostUrl(_this7.webSocketUrl);
|
|
717
658
|
}).catch(function (error) {
|
|
718
|
-
|
|
659
|
+
_this7.logger.warn(error.message);
|
|
719
660
|
return _promise.default.reject(new Error('device: failed to get the current websocket url'));
|
|
720
661
|
});
|
|
721
662
|
}
|
|
@@ -734,33 +675,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
734
675
|
}
|
|
735
676
|
return _promise.default.reject(new Error('device: failed to get the current websocket url'));
|
|
736
677
|
},
|
|
737
|
-
/**
|
|
738
|
-
* Get sanitized processed debug features from session storage
|
|
739
|
-
* these should be JSON encoded and in the form {feature1: true, feature2: false}
|
|
740
|
-
*
|
|
741
|
-
* @returns {Array<Object>} - Array of sanitized debug feature toggles
|
|
742
|
-
*/
|
|
743
|
-
getDebugFeatures: function getDebugFeatures() {
|
|
744
|
-
var sanitizedDebugFeatures = [];
|
|
745
|
-
if (this.config.debugFeatureTogglesKey) {
|
|
746
|
-
var debugFeaturesString = this.webex.getWindow().sessionStorage.getItem(this.config.debugFeatureTogglesKey);
|
|
747
|
-
if (debugFeaturesString) {
|
|
748
|
-
var debugFeatures = JSON.parse(debugFeaturesString);
|
|
749
|
-
(0, _entries.default)(debugFeatures).forEach(function (_ref) {
|
|
750
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
751
|
-
key = _ref2[0],
|
|
752
|
-
value = _ref2[1];
|
|
753
|
-
sanitizedDebugFeatures.push({
|
|
754
|
-
key: key,
|
|
755
|
-
val: value ? 'true' : 'false',
|
|
756
|
-
mutable: true,
|
|
757
|
-
lastModified: new Date().toISOString()
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
return sanitizedDebugFeatures;
|
|
763
|
-
},
|
|
764
678
|
/**
|
|
765
679
|
* Process a successful device registration.
|
|
766
680
|
*
|
|
@@ -768,8 +682,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
768
682
|
* @returns {void}
|
|
769
683
|
*/
|
|
770
684
|
processRegistrationSuccess: function processRegistrationSuccess(response) {
|
|
771
|
-
var
|
|
772
|
-
_this9 = this;
|
|
685
|
+
var _this8 = this;
|
|
773
686
|
this.logger.info('device: received registration payload');
|
|
774
687
|
|
|
775
688
|
// Clone the response body for service cleaning.
|
|
@@ -778,8 +691,8 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
778
691
|
// Clean service data.
|
|
779
692
|
delete body.services;
|
|
780
693
|
delete body.serviceHostMap;
|
|
781
|
-
var
|
|
782
|
-
etag =
|
|
694
|
+
var _ref = response.headers || {},
|
|
695
|
+
etag = _ref.etag;
|
|
783
696
|
if (this.etag && etag && this.etag === etag) {
|
|
784
697
|
// If current etag matches the previous one and we have sent
|
|
785
698
|
// If-None-Match header the developer and entitlement feature
|
|
@@ -789,15 +702,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
789
702
|
// When using the etag feature cache, user and entitlement features are still returned
|
|
790
703
|
this.features.user.reset(features.user);
|
|
791
704
|
this.features.entitlement.reset(features.entitlement);
|
|
792
|
-
} else if (this.config.debugFeatureTogglesKey && body !== null && body !== void 0 && (_body$features = body.features) !== null && _body$features !== void 0 && _body$features.developer) {
|
|
793
|
-
// Add the debug feature toggles from session storage if available
|
|
794
|
-
try {
|
|
795
|
-
var _body$features$develo;
|
|
796
|
-
var debugFeatures = this.getDebugFeatures();
|
|
797
|
-
(_body$features$develo = body.features.developer).push.apply(_body$features$develo, (0, _toConsumableArray2.default)(debugFeatures));
|
|
798
|
-
} catch (error) {
|
|
799
|
-
this.logger.error('Failed to parse debug feature toggles from session storage:', error);
|
|
800
|
-
}
|
|
801
705
|
}
|
|
802
706
|
|
|
803
707
|
// Assign the recieved DTO from **WDM** to this device.
|
|
@@ -813,7 +717,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
813
717
|
this.logger.info('device: enqueuing device refresh');
|
|
814
718
|
var delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;
|
|
815
719
|
this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {
|
|
816
|
-
return
|
|
720
|
+
return _this8.refresh();
|
|
817
721
|
}, delay);
|
|
818
722
|
}
|
|
819
723
|
|
|
@@ -855,7 +759,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
855
759
|
* @returns {void}
|
|
856
760
|
*/
|
|
857
761
|
setLogoutTimer: function setLogoutTimer(duration) {
|
|
858
|
-
var
|
|
762
|
+
var _this9 = this;
|
|
859
763
|
this.logger.info('device: setting logout timer');
|
|
860
764
|
if (!duration || duration <= 0) {
|
|
861
765
|
return;
|
|
@@ -863,12 +767,12 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
863
767
|
|
|
864
768
|
// Setup user activity date event listener.
|
|
865
769
|
this.on('change:lastUserActivityDate', function () {
|
|
866
|
-
|
|
770
|
+
_this9.resetLogoutTimer();
|
|
867
771
|
});
|
|
868
772
|
|
|
869
773
|
// Initialize a new timer.
|
|
870
774
|
this.logoutTimer = (0, _commonTimers.safeSetTimeout)(function () {
|
|
871
|
-
|
|
775
|
+
_this9.webex.logout();
|
|
872
776
|
}, duration * 1000);
|
|
873
777
|
},
|
|
874
778
|
/**
|
|
@@ -878,17 +782,17 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
878
782
|
* @returns {Promise<void, Error>}
|
|
879
783
|
*/
|
|
880
784
|
waitForRegistration: function waitForRegistration() {
|
|
881
|
-
var
|
|
785
|
+
var _this0 = this;
|
|
882
786
|
var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
883
787
|
this.logger.info('device: waiting for registration');
|
|
884
788
|
return new _promise.default(function (resolve, reject) {
|
|
885
|
-
if (
|
|
789
|
+
if (_this0.registered) {
|
|
886
790
|
resolve();
|
|
887
791
|
}
|
|
888
792
|
var timeoutTimer = (0, _commonTimers.safeSetTimeout)(function () {
|
|
889
793
|
return reject(new Error('device: timeout occured while waiting for registration'));
|
|
890
794
|
}, timeout * 1000);
|
|
891
|
-
|
|
795
|
+
_this0.once(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, function () {
|
|
892
796
|
clearTimeout(timeoutTimer);
|
|
893
797
|
resolve();
|
|
894
798
|
});
|
|
@@ -898,60 +802,54 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
|
|
|
898
802
|
return _promise.default.resolve(this.webex.internal.services.markFailedUrl(url));
|
|
899
803
|
},
|
|
900
804
|
initialize: function initialize() {
|
|
901
|
-
var
|
|
805
|
+
var _this1 = this;
|
|
902
806
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
903
807
|
args[_key2] = arguments[_key2];
|
|
904
808
|
}
|
|
905
809
|
// Prototype the extended class in order to preserve the parent member.
|
|
906
810
|
(0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);
|
|
907
|
-
this.listenToOnce(this.webex, 'change:config', function () {
|
|
908
|
-
// If debug feature toggles exist, clear the etag to ensure developer feature toggles are fetched
|
|
909
|
-
if (_this10.getDebugFeatures(_this10.config.debugFeatureTogglesKey).length > 0) {
|
|
910
|
-
_this10.set('etag', undefined);
|
|
911
|
-
}
|
|
912
|
-
});
|
|
913
811
|
|
|
914
812
|
// Initialize feature events and listeners.
|
|
915
813
|
_constants.FEATURE_COLLECTION_NAMES.forEach(function (collectionName) {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
814
|
+
_this1.features.on("change:".concat(collectionName), function (model, value, options) {
|
|
815
|
+
_this1.trigger('change', _this1, options);
|
|
816
|
+
_this1.trigger('change:features', _this1, _this1.features, options);
|
|
919
817
|
});
|
|
920
818
|
});
|
|
921
819
|
|
|
922
820
|
// Initialize network reachability checking event for url change.
|
|
923
821
|
this.on('change:intranetInactivityCheckUrl', function () {
|
|
924
|
-
|
|
822
|
+
_this1.checkNetworkReachability();
|
|
925
823
|
});
|
|
926
824
|
|
|
927
825
|
// Initialize network reachability checking event for duration change.
|
|
928
826
|
this.on('change:intranetInactivityDuration', function () {
|
|
929
|
-
|
|
827
|
+
_this1.checkNetworkReachability();
|
|
930
828
|
});
|
|
931
829
|
|
|
932
830
|
// Initialize network reachability checking event for duration change.
|
|
933
831
|
this.on('change:inNetworkInactivityDuration', function () {
|
|
934
|
-
|
|
832
|
+
_this1.checkNetworkReachability();
|
|
935
833
|
});
|
|
936
834
|
|
|
937
835
|
// Initialize listener for activity checking.
|
|
938
836
|
this.listenTo(this.webex, 'user-activity', function () {
|
|
939
|
-
|
|
837
|
+
_this1.lastUserActivityDate = (0, _now.default)();
|
|
940
838
|
});
|
|
941
839
|
|
|
942
840
|
// Initialize listener for meeting started event.
|
|
943
841
|
this.listenTo(this.webex, 'meeting started', function () {
|
|
944
|
-
|
|
945
|
-
|
|
842
|
+
_this1.isInMeeting = true;
|
|
843
|
+
_this1.resetLogoutTimer();
|
|
946
844
|
});
|
|
947
845
|
|
|
948
846
|
// Initialize listener for meeting ended event.
|
|
949
847
|
this.listenTo(this.webex, 'meeting ended', function () {
|
|
950
|
-
|
|
951
|
-
|
|
848
|
+
_this1.isInMeeting = false;
|
|
849
|
+
_this1.resetLogoutTimer();
|
|
952
850
|
});
|
|
953
851
|
} /* eslint-enable require-jsdoc */,
|
|
954
|
-
version: "3.12.0-
|
|
852
|
+
version: "3.12.0-task-refactor.1"
|
|
955
853
|
}, (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight, _dec], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "register", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "register"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "_registerInternal", [_common.oneFlight, _dec3], (0, _getOwnPropertyDescriptor.default)(_obj, "_registerInternal"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "unregister", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, "unregister"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "markUrlFailedAndGetNew", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, "markUrlFailedAndGetNew"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "initialize", [_dec6], (0, _getOwnPropertyDescriptor.default)(_obj, "initialize"), _obj), _obj));
|
|
956
854
|
var _default = exports.default = Device;
|
|
957
855
|
//# sourceMappingURL=device.js.map
|