@webex/internal-plugin-device 3.7.0-wxcc.1 → 3.8.0-next.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/device.js CHANGED
@@ -21,6 +21,7 @@ var _common = require("@webex/common");
21
21
  var _webexCore = require("@webex/webex-core");
22
22
  var _commonTimers = require("@webex/common-timers");
23
23
  var _lodash = require("lodash");
24
+ var _uuid = _interopRequireDefault(require("uuid"));
24
25
  var _metrics = _interopRequireDefault(require("./metrics"));
25
26
  var _constants = require("./constants");
26
27
  var _featuresModel = _interopRequireDefault(require("./features/features-model"));
@@ -374,6 +375,8 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
374
375
  } : {});
375
376
  var _deviceRegistrationOp = deviceRegistrationOptions.includeDetails,
376
377
  includeDetails = _deviceRegistrationOp === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp;
378
+ var requestId = _uuid.default.v4();
379
+ _this.set('refresh-request-id', requestId);
377
380
  return _this.request({
378
381
  method: 'PUT',
379
382
  uri: _this.url,
@@ -383,6 +386,11 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
383
386
  includeUpstreamServices: "".concat(includeDetails).concat(_this.config.energyForecast && _this.energyForecastConfig ? ',energyforecast' : '')
384
387
  }
385
388
  }).then(function (response) {
389
+ // If we've signed out in the mean time, the request ID will have changed
390
+ if (_this.get('refresh-request-id') !== requestId) {
391
+ _this.logger.info('device: refresh request ID mismatch, ignoring response');
392
+ return _promise.default.resolve();
393
+ }
386
394
  return _this.processRegistrationSuccess(response);
387
395
  }).catch(function (reason) {
388
396
  // Handle a 404 error, which indicates that the device is no longer
@@ -488,6 +496,8 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
488
496
  });
489
497
  var _deviceRegistrationOp2 = deviceRegistrationOptions.includeDetails,
490
498
  includeDetails = _deviceRegistrationOp2 === void 0 ? _types.CatalogDetails.all : _deviceRegistrationOp2;
499
+ var requestId = _uuid.default.v4();
500
+ this.set('register-request-id', requestId);
491
501
 
492
502
  // This will be replaced by a `create()` method.
493
503
  return this.request({
@@ -505,6 +515,12 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
505
515
  });
506
516
  throw error;
507
517
  }).then(function (response) {
518
+ // If we've signed out in the mean time, the request ID will have changed
519
+ if (_this4.get('register-request-id') !== requestId) {
520
+ _this4.logger.info('device: register request ID mismatch, ignoring response');
521
+ return _promise.default.resolve();
522
+ }
523
+
508
524
  // Do not add any processing of response above this as that will affect timestamp
509
525
  _this4.webex.internal.newMetrics.submitInternalEvent({
510
526
  name: 'internal.register.device.response'
@@ -833,7 +849,7 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
833
849
  _this11.resetLogoutTimer();
834
850
  });
835
851
  } /* eslint-enable require-jsdoc */,
836
- version: "3.7.0-wxcc.1"
852
+ version: "3.8.0-next.1"
837
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)));
838
854
  var _default = exports.default = Device;
839
855
  //# sourceMappingURL=device.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","_webexCore","_commonTimers","_lodash","_metrics","_interopRequireDefault","_constants","_featuresModel","_ipNetworkDetector","_types","_dec","_dec2","_dec3","_dec4","_dec5","_dec6","_obj","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor2","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","decider","config","ephemeral","Device","WebexPlugin","extend","waitForValue","deprecated","persist","namespace","extraProperties","idAttribute","children","features","FeaturesModel","ipNetworkDetector","IpNetworkDetector","props","clientMessagingGiphy","customerCompanyName","customerLogoUrl","deviceType","helpUrl","intranetInactivityDuration","intranetInactivityCheckUrl","inNetworkInactivityDuration","ecmEnabledForAllUsers","ecmSupportedStorageProviders","modificationTime","navigationBarColor","partnerCompanyName","partnerLogoUrl","peopleInsightsEnabled","reportingSiteDesc","reportingSiteUrl","searchEncryptionKeyUrl","showSupportText","supportProviderCompanyName","supportProviderLogoUrl","url","userId","webFileShareControl","webSocketUrl","whiteboardFileShareControl","derived","registered","deps","fn","session","logoutTimer","lastUserActivityDate","isReachabilityChecked","energyForecastConfig","isInMeeting","isInNetwork","meetingStarted","webex","trigger","meetingEnded","setEnergyForecastConfig","undefined","refresh","_this","deviceRegistrationOptions","logger","info","canRegister","then","register","body","serialize","mediaCluster","etag","ttl","ephemeralDeviceTTL","headers","defaults","_deviceRegistrationOp","includeDetails","CatalogDetails","all","request","method","uri","qs","includeUpstreamServices","concat","energyForecast","response","processRegistrationSuccess","catch","reason","statusCode","clear","_promise","reject","deleteDevices","_this2","service","resource","devices","_this2$_getBody","_getBody","webDevices","item","sortedDevices","orderBy","Date","totalItems","countToDelete","Math","ceil","urlsToDelete","slice","map","race","resolve","error","_this3","internal","newMetrics","callDiagnosticMetrics","setDeviceInfo","_registerInternal","_error$body","message","_this4","submitInternalEvent","name","_deviceRegistrationOp2","metrics","submitClientMetrics","METRICS","JS_SDK_WDM_REGISTRATION_SUCCESSFUL","JS_SDK_WDM_REGISTRATION_FAILED","fields","unregister","_this5","warn","services","waitForCatalog","canRegisterWaitDuration","get","Error","join","checkNetworkReachability","_this6","resetLogoutTimer","trackingid","_len","args","Array","_key","_apply","prototype","getWebSocketUrl","_this7","wait","waitForRegistration","convertUrlToPriorityHostUrl","wsUrl","_this8","serviceHostMap","_ref","user","reset","entitlement","set","delay","refreshTimer","safeSetTimeout","DEVICE_EVENT_REGISTRATION_SUCCESS","clearTimeout","off","unset","enableInactivityEnforcement","setLogoutTimer","duration","_this9","on","logout","_this10","timeout","timeoutTimer","once","markUrlFailedAndGetNew","markFailedUrl","initialize","_this11","_len2","_key2","FEATURE_COLLECTION_NAMES","collectionName","model","value","options","listenTo","_now","version","_applyDecoratedDescriptor2","oneFlight","_getOwnPropertyDescriptor","_default","exports"],"sources":["device.js"],"sourcesContent":["// Internal Dependencies\nimport {deprecated, oneFlight} from '@webex/common';\nimport {persist, waitForValue, WebexPlugin} from '@webex/webex-core';\nimport {safeSetTimeout} from '@webex/common-timers';\nimport {orderBy} from 'lodash';\n\nimport METRICS from './metrics';\nimport {FEATURE_COLLECTION_NAMES, DEVICE_EVENT_REGISTRATION_SUCCESS} from './constants';\nimport FeaturesModel from './features/features-model';\nimport IpNetworkDetector from './ipNetworkDetector';\nimport {CatalogDetails} from './types';\n\n/**\n * Determine if the plugin should be initialized based on cached storage.\n *\n * @returns {boolean} - If the device is ephemeral.\n */\nfunction decider() {\n return !this.config.ephemeral;\n}\n\nconst Device = WebexPlugin.extend({\n // Ampersand property members.\n\n namespace: 'Device',\n\n // Allow for extra properties to prevent the plugin from failing due to\n // **WDM** service DTO changes.\n extraProperties: 'allow',\n\n idAttribute: 'url',\n\n children: {\n /**\n * The class object that contains all of the feature collections.\n *\n * @type {FeaturesModel}\n */\n features: FeaturesModel,\n /**\n * Helper class for detecting what IP network version (ipv4, ipv6) we're on.\n *\n * @type {IpNetworkDetector}\n */\n ipNetworkDetector: IpNetworkDetector,\n },\n\n /**\n * A collection of device properties mostly assigned by the retrieved DTO from\n * the **WDM** service that are mapped against the ampersand properties.\n *\n * @type {Object}\n */\n props: {\n /**\n * This property determines whether or not giphy support is enabled.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n clientMessagingGiphy: 'string',\n\n /**\n * This property should store the company name.\n *\n * @type {string}\n */\n customerCompanyName: 'string',\n\n /**\n * This property should store the logo url.\n *\n * @type {string}\n */\n customerLogoUrl: 'string',\n\n /**\n * This property doesn't have any real values, but is sent during device\n * refresh to prevent the **wdm** service from falling back to an iOS device\n * type.\n *\n * @type {string}\n */\n deviceType: 'string',\n\n /**\n * This property should store the help url.\n *\n * @type {string}\n */\n helpUrl: 'string',\n\n /**\n * This property should store the intranet inactivity timer duration.\n *\n * @type {number}\n */\n intranetInactivityDuration: 'number',\n\n /**\n * This property stores the url required to validate if the device is able\n * to actively reach the intranet network.\n *\n * @type {string}\n */\n intranetInactivityCheckUrl: 'string',\n\n /**\n * This property stores the inactivity timer duration, and could possibly\n * deprecate the `intranetInactivityDuration` property.\n *\n * @type {number}\n */\n inNetworkInactivityDuration: 'number',\n\n /**\n * This property stores the ECM (external content management) enabled value\n * for the whole organization.\n *\n * @type {boolean}\n */\n ecmEnabledForAllUsers: ['boolean', false, false],\n\n /**\n * This property stores an array of ECM (external content management)\n * providers that are currently available.\n *\n * @returns {Array<string>}\n */\n ecmSupportedStorageProviders: ['array', false, () => []],\n\n /**\n * This property stores the modification time value retrieved from the\n * **WDM** endpoint formatted as ISO 8601.\n *\n * @type {string}\n */\n modificationTime: 'string',\n\n /**\n * This property stores the navigation bar color.\n *\n * @type {string}\n */\n navigationBarColor: 'string',\n\n /**\n * This property stores the partner company's name when available.\n *\n * @type {string}\n */\n partnerCompanyName: 'string',\n\n /**\n * This property stores the partner company's logo when available.\n *\n * @type {string}\n */\n partnerLogoUrl: 'string',\n\n /**\n * This property stores the availability of people data from the **WDM**\n * service.\n *\n * @type {boolean}\n */\n peopleInsightsEnabled: 'boolean',\n\n /**\n * This property stores the reporting site's description when available.\n *\n * @type {string}\n */\n reportingSiteDesc: 'string',\n\n /**\n * This property stores the reporting site's access url when available.\n *\n * @type {string}\n */\n reportingSiteUrl: 'string',\n\n /**\n * This property stores the encryption key url when available.\n *\n * @type {string}\n */\n searchEncryptionKeyUrl: 'string',\n\n /**\n * This property stores the availability of support-provided text from the\n * **WDM** service.\n *\n * @type {boolean}\n */\n showSupportText: 'boolean',\n\n /**\n * This property stores the support provider's company name when available.\n *\n * @type {string}\n */\n supportProviderCompanyName: 'string',\n\n /**\n * This property stores the support provider's logo url when available.\n *\n * @type {string}\n */\n supportProviderLogoUrl: 'string',\n\n /**\n * This property stores the device's url retrieved from a registration\n * request. This property gets set via the initial registration process by a\n * `this.set()` method.\n *\n * @type {string}\n */\n url: 'string',\n\n /**\n * This property stores the device's userId uuid value, which can also be\n * derived from the device's registerd user's userId retrieved from\n * the **Hydra** service.\n *\n * @type {string}\n */\n userId: 'string',\n\n /**\n * This property stores whether or not file sharing is enabled\n *\n * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}\n */\n webFileShareControl: 'string',\n\n /**\n * This property stores the current web socket url used by the registered\n * device.\n *\n * @type {string}\n */\n webSocketUrl: 'string',\n\n /**\n * This property stores the value indicating whether or not white board file\n * sharing is enabled for the current device.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n whiteboardFileShareControl: 'string',\n },\n\n /**\n * A list of derived properties that populate based when their parent data\n * available via the device's properties.\n *\n * @type {Object}\n */\n derived: {\n /**\n * This property determines if the current device is registered.\n *\n * @type {boolean}\n */\n registered: {\n deps: ['url'],\n\n /**\n * Checks if the device is registered by validating that the url exists.\n * Amperstand does not allow this to method to be written as an arrow\n * function.\n *\n * @returns {boolean}\n */\n fn() {\n return !!this.url;\n },\n },\n },\n\n /**\n * Stores timer data as well as other state details.\n *\n * @type {Object}\n */\n session: {\n /**\n * This property stores the logout timer object\n *\n * @type {any}\n */\n logoutTimer: 'any',\n\n /**\n * This property stores the date for the last activity the user made\n * with the current device.\n *\n * @type {number}\n */\n lastUserActivityDate: 'number',\n\n /**\n * This property stores whether or not the reachability check has been\n * performed to prevent the reachability check from performing its\n * operation more than once after a successful check.\n *\n * @returns {boolean}\n */\n isReachabilityChecked: ['boolean', false, false],\n\n /**\n * This property stores whether or not the next refresh or register request should request energy forecast data\n * in order to prevent over fetching energy forecasts\n *\n * @type {boolean}\n */\n energyForecastConfig: 'boolean',\n\n /**\n * This property stores whether or not the current device is in a meeting\n * to prevent an unneeded timeout of a meeting due to inactivity.\n *\n * @type {boolean}\n */\n isInMeeting: 'boolean',\n\n /**\n * This property identifies if the device is currently in network to prevent\n * the `resetLogoutTimer()` method from being called repeatedly once its\n * known client is connected to the organization's internal network.\n *\n * @type {boolean}\n */\n isInNetwork: 'boolean',\n },\n\n // Event method members.\n\n /**\n * Trigger meeting started event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingStarted() {\n this.webex.trigger('meeting started');\n },\n\n /**\n * Trigger meeting ended event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingEnded() {\n this.webex.trigger('meeting ended');\n },\n\n /**\n * Set the value of energy forecast config for the current registered device.\n * @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register\n * @returns {void}\n */\n setEnergyForecastConfig(energyForecastConfig = false) {\n this.energyForecastConfig = energyForecastConfig;\n },\n\n // Registration method members\n\n /**\n * Refresh the current registered device if able.\n *\n * @param {DeviceRegistrationOptions} options - The options for refresh.\n * @param {CatalogDetails} options.includeDetails - The details to include in the refresh/register request.\n * @returns {Promise<void, Error>}\n */\n @oneFlight\n @waitForValue('@')\n refresh(deviceRegistrationOptions = {}) {\n this.logger.info('device: refreshing');\n\n // Validate that the device can be registered.\n return this.canRegister().then(() => {\n // Validate if the device is not registered and register instead.\n if (!this.registered) {\n this.logger.info('device: device not registered, registering');\n\n return this.register(deviceRegistrationOptions);\n }\n\n // Merge body configurations, overriding defaults.\n const body = {\n ...this.serialize(),\n ...(this.config.body ? this.config.body : {}),\n };\n\n // Remove unneeded properties from the body object.\n delete body.features;\n delete body.mediaCluster;\n delete body.etag;\n\n // Append a ttl value if the device is marked as ephemeral.\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n\n // Merge header configurations, overriding defaults.\n const headers = {\n ...(this.config.defaults.headers ? this.config.defaults.headers : {}),\n ...(this.config.headers ? this.config.headers : {}),\n // If etag is sent, WDM will not send developer feature toggles unless they have changed\n ...(this.etag ? {'If-None-Match': this.etag} : {}),\n };\n\n const {includeDetails = CatalogDetails.all} = deviceRegistrationOptions;\n\n return this.request({\n method: 'PUT',\n uri: this.url,\n body,\n headers,\n qs: {\n includeUpstreamServices: `${includeDetails}${\n this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : ''\n }`,\n },\n })\n .then((response) => this.processRegistrationSuccess(response))\n .catch((reason) => {\n // Handle a 404 error, which indicates that the device is no longer\n // valid and needs to be registered as a new device.\n if (reason.statusCode === 404) {\n this.logger.info('device: refresh failed, device is not valid');\n this.logger.info('device: attempting to register a new device');\n\n this.clear();\n\n return this.register(deviceRegistrationOptions);\n }\n\n return Promise.reject(reason);\n });\n });\n },\n /**\n * Fetches the web devices and deletes the third of them which are not recent devices in use\n * @returns {Promise<void, Error>}\n */\n deleteDevices() {\n // Fetch devices with a GET request\n return this.request({\n method: 'GET',\n service: 'wdm',\n resource: 'devices',\n })\n .then((response) => {\n const {devices} = response.body;\n\n const {deviceType} = this._getBody();\n\n // Filter devices of type deviceType\n const webDevices = devices.filter((item) => item.deviceType === deviceType);\n\n const sortedDevices = orderBy(webDevices, [(item) => new Date(item.modificationTime)]);\n\n // If there are more than two devices, delete the last third\n if (sortedDevices.length > 2) {\n const totalItems = sortedDevices.length;\n const countToDelete = Math.ceil(totalItems / 3);\n const urlsToDelete = sortedDevices.slice(0, countToDelete).map((item) => item.url);\n\n return Promise.race(\n urlsToDelete.map((url) => {\n return this.request({\n uri: url,\n method: 'DELETE',\n });\n })\n );\n }\n\n return Promise.resolve();\n })\n .catch((error) => {\n this.logger.error('Failed to retrieve devices:', error);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Registers and when fails deletes devices\n */\n @waitForValue('@')\n register(deviceRegistrationOptions = {}) {\n this.logger.info('device: registering');\n\n this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);\n\n // Validate that the device can be registered.\n return this.canRegister().then(() => {\n // Validate if the device is already registered and refresh instead.\n if (this.registered) {\n this.logger.info('device: device already registered, refreshing');\n\n return this.refresh(deviceRegistrationOptions);\n }\n\n return this._registerInternal(deviceRegistrationOptions).catch((error) => {\n if (error?.body?.message === 'User has excessive device registrations') {\n return this.deleteDevices().then(() => {\n return this._registerInternal(deviceRegistrationOptions);\n });\n }\n throw error;\n });\n });\n },\n\n _getBody() {\n return {\n ...(this.config.defaults.body ? this.config.defaults.body : {}),\n ...(this.config.body ? this.config.body : {}),\n };\n },\n\n /**\n * Register or refresh a device depending on the current device state. Device\n * registration utilizes the services plugin to send the request to the\n * **WDM** service.\n *\n * @param {Object} options - The options for registration.\n * @param {CatalogDetails} options.includeDetails - The details to include in the refresh/register request.\n * @returns {Promise<void, Error>}\n */\n @oneFlight\n @waitForValue('@')\n _registerInternal(deviceRegistrationOptions = {}) {\n this.logger.info('device: making registration request');\n\n // Merge body configurations, overriding defaults.\n const body = this._getBody();\n\n // Merge header configurations, overriding defaults.\n const headers = {\n ...(this.config.defaults.headers ? this.config.defaults.headers : {}),\n ...(this.config.headers ? this.config.headers : {}),\n };\n\n // Append a ttl value if the device is marked as ephemeral\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.request',\n });\n\n const {includeDetails = CatalogDetails.all} = deviceRegistrationOptions;\n\n // This will be replaced by a `create()` method.\n return this.request({\n method: 'POST',\n service: 'wdm',\n resource: 'devices',\n body,\n headers,\n qs: {\n includeUpstreamServices: `${includeDetails}${\n this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : ''\n }`,\n },\n })\n .catch((error) => {\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response',\n });\n\n throw error;\n })\n .then((response) => {\n // Do not add any processing of response above this as that will affect timestamp\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response',\n });\n\n this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);\n\n return this.processRegistrationSuccess(response);\n })\n .catch((error) => {\n this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_WDM_REGISTRATION_FAILED, {\n fields: {error},\n });\n throw error;\n });\n },\n /**\n * Unregister the current registered device if available. Unregistering a\n * device utilizes the services plugin to send the request to the **WDM**\n * service.\n *\n * @returns {Promise<void, Error>}\n */\n @oneFlight\n @waitForValue('@')\n unregister() {\n this.logger.info('device: unregistering');\n\n if (!this.registered) {\n this.logger.warn('device: not registered');\n\n return Promise.resolve();\n }\n\n return this.request({\n uri: this.url,\n method: 'DELETE',\n })\n .then(() => this.clear())\n .catch((reason) => {\n if (reason.statusCode === 404) {\n this.logger.info(\n 'device: 404 when deleting device, device is already deleted, clearing device'\n );\n\n this.clear();\n }\n throw reason;\n });\n },\n /* eslint-enable require-jsdoc */\n\n // Helper method members\n\n /**\n * Determine if registration methods can be performed. This method utilizes\n * the `services` plugin to confirm if the appropriate service urls are\n * available for device registration.\n *\n * @returns {Promise<void, Error>}\n */\n canRegister() {\n this.logger.info('device: validating if registration can occur');\n\n // Destructure the services plugin for ease of reference.\n const {services} = this.webex.internal;\n\n // Wait for the postauth catalog to populate.\n return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(() =>\n // Validate that the service exists after waiting for the catalog.\n services.get('wdm')\n ? Promise.resolve()\n : Promise.reject(\n new Error(\n [\n 'device: cannot register,',\n \"'wdm' service is not available from the postauth catalog\",\n ].join(' ')\n )\n )\n );\n },\n\n /**\n * Check if the device can currently reach the inactivity check url.\n *\n * @returns {Promise<void, Error>}\n */\n checkNetworkReachability() {\n this.logger.info('device: checking network reachability');\n\n // Validate if the device has been checked and reset the logout timer.\n if (this.isReachabilityChecked) {\n return Promise.resolve(this.resetLogoutTimer());\n }\n\n this.isReachabilityChecked = true;\n\n // Validate if the device has a intranet checking url.\n if (!this.intranetInactivityCheckUrl) {\n this.isInNetwork = false;\n\n return Promise.resolve(this.resetLogoutTimer());\n }\n\n // Clear unnecessary headers for reachability request.\n const headers = {\n 'cisco-no-http-redirect': null,\n 'spark-user-agent': null,\n trackingid: null,\n };\n\n // Send the network reachability request.\n return this.request({\n headers,\n method: 'GET',\n uri: this.intranetInactivityCheckUrl,\n })\n .then(() => {\n this.isInNetwork = true;\n\n return Promise.resolve(this.resetLogoutTimer());\n })\n .catch(() => {\n this.logger.info('device: did not reach ping endpoint');\n this.logger.info('device: triggering off-network timer');\n\n this.isInNetwork = false;\n\n return Promise.resolve(this.resetLogoutTimer());\n });\n },\n\n /**\n * Clears the registration ttl value if available.\n *\n * @param {Object} options - Values to be cleared.\n * @returns {void}\n */\n clear(...args) {\n this.logger.info('device: clearing registered device');\n\n // Prototype the extended class in order to preserve the parent member.\n Reflect.apply(WebexPlugin.prototype.clear, this, args);\n },\n\n /**\n * Get the current websocket url with the appropriate priority host.\n *\n * @param {boolean} [wait=false] - Willing to wait on a valid url.\n * @returns {Promise<string, Error>} - The priority-mapped web socket url.\n */\n getWebSocketUrl(wait = false) {\n this.logger.info('device: getting the current websocket url');\n\n // Destructure the services plugin for ease of reference.\n const {services} = this.webex.internal;\n\n // Validate if the method should wait for registration.\n if (wait) {\n return this.waitForRegistration()\n .then(() => services.convertUrlToPriorityHostUrl(this.webSocketUrl))\n .catch((error) => {\n this.logger.warn(error.message);\n\n return Promise.reject(new Error('device: failed to get the current websocket url'));\n });\n }\n\n // Validate if the device is registered.\n if (!this.registered) {\n return Promise.reject(\n new Error('device: cannot get websocket url, device is not registered')\n );\n }\n\n // Attempt to collect the priority-host-mapped web socket URL.\n const wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);\n\n // Validate that the url was collected.\n if (wsUrl) {\n return Promise.resolve(wsUrl);\n }\n\n return Promise.reject(new Error('device: failed to get the current websocket url'));\n },\n\n /**\n * Process a successful device registration.\n *\n * @param {Object} response - response object from registration success.\n * @returns {void}\n */\n processRegistrationSuccess(response) {\n this.logger.info('device: received registration payload');\n\n // Clone the response body for service cleaning.\n const body = {...response.body};\n\n // Clean service data.\n delete body.services;\n delete body.serviceHostMap;\n\n const {etag} = response.headers || {};\n\n if (this.etag && etag && this.etag === etag) {\n // If current etag matches the previous one and we have sent\n // If-None-Match header the developer and entitlement feature\n // toggles will not be returned\n const {features} = body;\n\n delete body.features;\n // When using the etag feature cache, user and entitlement features are still returned\n this.features.user.reset(features.user);\n this.features.entitlement.reset(features.entitlement);\n }\n\n // Assign the recieved DTO from **WDM** to this device.\n this.set(body);\n\n // Assign the new etag to this device.\n this.set({etag});\n\n // Validate if device is ephemeral and setup refresh timer.\n if (this.config.ephemeral) {\n this.logger.info('device: enqueuing device refresh');\n\n const delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;\n\n this.refreshTimer = safeSetTimeout(() => this.refresh(), delay);\n }\n\n // Emit the registration:success event.\n this.trigger(DEVICE_EVENT_REGISTRATION_SUCCESS, this);\n },\n\n /**\n * Reset the current local logout timer for the registered device if\n * registered.\n *\n * @returns {void}\n */\n resetLogoutTimer() {\n this.logger.info('device: resetting logout timer');\n\n // Clear current logout timer.\n clearTimeout(this.logoutTimer);\n\n // Remove last activity date event listener.\n this.off('change:lastUserActivityDate');\n\n // Remove the logout timer.\n this.unset('logoutTimer');\n\n // Validate if the device is currently in a meeting and is configured to\n // required inactivity enforcement.\n if (\n !this.isInMeeting &&\n this.config.enableInactivityEnforcement &&\n this.isReachabilityChecked\n ) {\n if (this.isInNetwork) {\n this.setLogoutTimer(this.inNetworkInactivityDuration);\n } else {\n this.setLogoutTimer(this.intranetInactivityDuration);\n }\n }\n },\n\n /**\n * Set the value of the logout timer for the current registered device.\n *\n * @param {number} duration - Value in seconds of the new logout timer.\n * @returns {void}\n */\n setLogoutTimer(duration) {\n this.logger.info('device: setting logout timer');\n\n if (!duration || duration <= 0) {\n return;\n }\n\n // Setup user activity date event listener.\n this.on('change:lastUserActivityDate', () => {\n this.resetLogoutTimer();\n });\n\n // Initialize a new timer.\n this.logoutTimer = safeSetTimeout(() => {\n this.webex.logout();\n }, duration * 1000);\n },\n\n /**\n * Wait for the device to be registered.\n *\n * @param {number} [timeout=10] - The maximum duration to wait, in seconds.\n * @returns {Promise<void, Error>}\n */\n waitForRegistration(timeout = 10) {\n this.logger.info('device: waiting for registration');\n\n return new Promise((resolve, reject) => {\n if (this.registered) {\n resolve();\n }\n\n const timeoutTimer = safeSetTimeout(\n () => reject(new Error('device: timeout occured while waiting for registration')),\n timeout * 1000\n );\n\n this.once(DEVICE_EVENT_REGISTRATION_SUCCESS, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n\n // Deprecated methods.\n\n /**\n * Mark a url as failed and get the next priority host url.\n *\n * @param {string} url - The url to mark as failed.\n * @returns {Promise<string>} - The next priority url.\n */\n @deprecated('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()')\n markUrlFailedAndGetNew(url) {\n return Promise.resolve(this.webex.internal.services.markFailedUrl(url));\n },\n\n // Ampersand method members\n\n /* eslint-disable require-jsdoc */\n /**\n * Initializer method for the device plugin.\n *\n * @override\n * @param {Array<any>} args - An array of items to be mapped as properties.\n * @returns {void}\n */\n @persist('@', decider)\n initialize(...args) {\n // Prototype the extended class in order to preserve the parent member.\n Reflect.apply(WebexPlugin.prototype.initialize, this, args);\n\n // Initialize feature events and listeners.\n FEATURE_COLLECTION_NAMES.forEach((collectionName) => {\n this.features.on(`change:${collectionName}`, (model, value, options) => {\n this.trigger('change', this, options);\n this.trigger('change:features', this, this.features, options);\n });\n });\n\n // Initialize network reachability checking event for url change.\n this.on('change:intranetInactivityCheckUrl', () => {\n this.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:intranetInactivityDuration', () => {\n this.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:inNetworkInactivityDuration', () => {\n this.checkNetworkReachability();\n });\n\n // Initialize listener for activity checking.\n this.listenTo(this.webex, 'user-activity', () => {\n this.lastUserActivityDate = Date.now();\n });\n\n // Initialize listener for meeting started event.\n this.listenTo(this.webex, 'meeting started', () => {\n this.isInMeeting = true;\n this.resetLogoutTimer();\n });\n\n // Initialize listener for meeting ended event.\n this.listenTo(this.webex, 'meeting ended', () => {\n this.isInMeeting = false;\n this.resetLogoutTimer();\n });\n },\n /* eslint-enable require-jsdoc */\n});\n\nexport default Device;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,kBAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAuC,IAAAU,IAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,IAAA,EAVvC;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,M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O,yBAAA,CAAA7M,OAAA,EAAAnB,IAAA,cAAAA,IAAA,OAAA8N,0BAAA,CAAA3M,OAAA,EAAAnB,IAAA,eAAAL,KAAA,OAAAqO,yBAAA,CAAA7M,OAAA,EAAAnB,IAAA,eAAAA,IAAA,OAAA8N,0BAAA,CAAA3M,OAAA,EAAAnB,IAAA,wBA+JT+N,iBAAS,EAAAnO,KAAA,OAAAoO,yBAAA,CAAA7M,OAAA,EAAAnB,IAAA,wBAAAA,IAAA,OAAA8N,0BAAA,CAAA3M,OAAA,EAAAnB,IAAA,iBAoET+N,iBAAS,EAAAlO,KAAA,OAAAmO,yBAAA,CAAA7M,OAAA,EAAAnB,IAAA,iBAAAA,IAAA,OAAA8N,0BAAA,CAAA3M,OAAA,EAAAnB,IAAA,6BAAAF,KAAA,OAAAkO,yBAAA,CAAA7M,OAAA,EAAAnB,IAAA,6BAAAA,IAAA,OAAA8N,0BAAA,CAAA3M,OAAA,EAAAnB,IAAA,iBAAAD,KAAA,OAAAiO,yBAAA,CAAA7M,OAAA,EAAAnB,IAAA,iBAAAA,IAAA,IAAAA,IAAA,EA6WX,CAAC;AAAC,IAAAiO,QAAA,GAAAC,OAAA,CAAA/M,OAAA,GAEYO,MAAM"}
1
+ {"version":3,"names":["_common","require","_webexCore","_commonTimers","_lodash","_uuid","_interopRequireDefault","_metrics","_constants","_featuresModel","_ipNetworkDetector","_types","_dec","_dec2","_dec3","_dec4","_dec5","_dec6","_obj","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor2","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","decider","config","ephemeral","Device","WebexPlugin","extend","waitForValue","deprecated","persist","namespace","extraProperties","idAttribute","children","features","FeaturesModel","ipNetworkDetector","IpNetworkDetector","props","clientMessagingGiphy","customerCompanyName","customerLogoUrl","deviceType","helpUrl","intranetInactivityDuration","intranetInactivityCheckUrl","inNetworkInactivityDuration","ecmEnabledForAllUsers","ecmSupportedStorageProviders","modificationTime","navigationBarColor","partnerCompanyName","partnerLogoUrl","peopleInsightsEnabled","reportingSiteDesc","reportingSiteUrl","searchEncryptionKeyUrl","showSupportText","supportProviderCompanyName","supportProviderLogoUrl","url","userId","webFileShareControl","webSocketUrl","whiteboardFileShareControl","derived","registered","deps","fn","session","logoutTimer","lastUserActivityDate","isReachabilityChecked","energyForecastConfig","isInMeeting","isInNetwork","meetingStarted","webex","trigger","meetingEnded","setEnergyForecastConfig","undefined","refresh","_this","deviceRegistrationOptions","logger","info","canRegister","then","register","body","serialize","mediaCluster","etag","ttl","ephemeralDeviceTTL","headers","defaults","_deviceRegistrationOp","includeDetails","CatalogDetails","all","requestId","uuid","v4","set","request","method","uri","qs","includeUpstreamServices","concat","energyForecast","response","get","_promise","resolve","processRegistrationSuccess","catch","reason","statusCode","clear","reject","deleteDevices","_this2","service","resource","devices","_this2$_getBody","_getBody","webDevices","item","sortedDevices","orderBy","Date","totalItems","countToDelete","Math","ceil","urlsToDelete","slice","map","race","error","_this3","internal","newMetrics","callDiagnosticMetrics","setDeviceInfo","_registerInternal","_error$body","message","_this4","submitInternalEvent","name","_deviceRegistrationOp2","metrics","submitClientMetrics","METRICS","JS_SDK_WDM_REGISTRATION_SUCCESSFUL","JS_SDK_WDM_REGISTRATION_FAILED","fields","unregister","_this5","warn","services","waitForCatalog","canRegisterWaitDuration","Error","join","checkNetworkReachability","_this6","resetLogoutTimer","trackingid","_len","args","Array","_key","_apply","prototype","getWebSocketUrl","_this7","wait","waitForRegistration","convertUrlToPriorityHostUrl","wsUrl","_this8","serviceHostMap","_ref","user","reset","entitlement","delay","refreshTimer","safeSetTimeout","DEVICE_EVENT_REGISTRATION_SUCCESS","clearTimeout","off","unset","enableInactivityEnforcement","setLogoutTimer","duration","_this9","on","logout","_this10","timeout","timeoutTimer","once","markUrlFailedAndGetNew","markFailedUrl","initialize","_this11","_len2","_key2","FEATURE_COLLECTION_NAMES","collectionName","model","value","options","listenTo","_now","version","_applyDecoratedDescriptor2","oneFlight","_getOwnPropertyDescriptor","_default","exports"],"sources":["device.js"],"sourcesContent":["// Internal Dependencies\nimport {deprecated, oneFlight} from '@webex/common';\nimport {persist, waitForValue, WebexPlugin} from '@webex/webex-core';\nimport {safeSetTimeout} from '@webex/common-timers';\nimport {orderBy} from 'lodash';\nimport uuid from 'uuid';\n\nimport METRICS from './metrics';\nimport {FEATURE_COLLECTION_NAMES, DEVICE_EVENT_REGISTRATION_SUCCESS} from './constants';\nimport FeaturesModel from './features/features-model';\nimport IpNetworkDetector from './ipNetworkDetector';\nimport {CatalogDetails} from './types';\n\n/**\n * Determine if the plugin should be initialized based on cached storage.\n *\n * @returns {boolean} - If the device is ephemeral.\n */\nfunction decider() {\n return !this.config.ephemeral;\n}\n\nconst Device = WebexPlugin.extend({\n // Ampersand property members.\n\n namespace: 'Device',\n\n // Allow for extra properties to prevent the plugin from failing due to\n // **WDM** service DTO changes.\n extraProperties: 'allow',\n\n idAttribute: 'url',\n\n children: {\n /**\n * The class object that contains all of the feature collections.\n *\n * @type {FeaturesModel}\n */\n features: FeaturesModel,\n /**\n * Helper class for detecting what IP network version (ipv4, ipv6) we're on.\n *\n * @type {IpNetworkDetector}\n */\n ipNetworkDetector: IpNetworkDetector,\n },\n\n /**\n * A collection of device properties mostly assigned by the retrieved DTO from\n * the **WDM** service that are mapped against the ampersand properties.\n *\n * @type {Object}\n */\n props: {\n /**\n * This property determines whether or not giphy support is enabled.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n clientMessagingGiphy: 'string',\n\n /**\n * This property should store the company name.\n *\n * @type {string}\n */\n customerCompanyName: 'string',\n\n /**\n * This property should store the logo url.\n *\n * @type {string}\n */\n customerLogoUrl: 'string',\n\n /**\n * This property doesn't have any real values, but is sent during device\n * refresh to prevent the **wdm** service from falling back to an iOS device\n * type.\n *\n * @type {string}\n */\n deviceType: 'string',\n\n /**\n * This property should store the help url.\n *\n * @type {string}\n */\n helpUrl: 'string',\n\n /**\n * This property should store the intranet inactivity timer duration.\n *\n * @type {number}\n */\n intranetInactivityDuration: 'number',\n\n /**\n * This property stores the url required to validate if the device is able\n * to actively reach the intranet network.\n *\n * @type {string}\n */\n intranetInactivityCheckUrl: 'string',\n\n /**\n * This property stores the inactivity timer duration, and could possibly\n * deprecate the `intranetInactivityDuration` property.\n *\n * @type {number}\n */\n inNetworkInactivityDuration: 'number',\n\n /**\n * This property stores the ECM (external content management) enabled value\n * for the whole organization.\n *\n * @type {boolean}\n */\n ecmEnabledForAllUsers: ['boolean', false, false],\n\n /**\n * This property stores an array of ECM (external content management)\n * providers that are currently available.\n *\n * @returns {Array<string>}\n */\n ecmSupportedStorageProviders: ['array', false, () => []],\n\n /**\n * This property stores the modification time value retrieved from the\n * **WDM** endpoint formatted as ISO 8601.\n *\n * @type {string}\n */\n modificationTime: 'string',\n\n /**\n * This property stores the navigation bar color.\n *\n * @type {string}\n */\n navigationBarColor: 'string',\n\n /**\n * This property stores the partner company's name when available.\n *\n * @type {string}\n */\n partnerCompanyName: 'string',\n\n /**\n * This property stores the partner company's logo when available.\n *\n * @type {string}\n */\n partnerLogoUrl: 'string',\n\n /**\n * This property stores the availability of people data from the **WDM**\n * service.\n *\n * @type {boolean}\n */\n peopleInsightsEnabled: 'boolean',\n\n /**\n * This property stores the reporting site's description when available.\n *\n * @type {string}\n */\n reportingSiteDesc: 'string',\n\n /**\n * This property stores the reporting site's access url when available.\n *\n * @type {string}\n */\n reportingSiteUrl: 'string',\n\n /**\n * This property stores the encryption key url when available.\n *\n * @type {string}\n */\n searchEncryptionKeyUrl: 'string',\n\n /**\n * This property stores the availability of support-provided text from the\n * **WDM** service.\n *\n * @type {boolean}\n */\n showSupportText: 'boolean',\n\n /**\n * This property stores the support provider's company name when available.\n *\n * @type {string}\n */\n supportProviderCompanyName: 'string',\n\n /**\n * This property stores the support provider's logo url when available.\n *\n * @type {string}\n */\n supportProviderLogoUrl: 'string',\n\n /**\n * This property stores the device's url retrieved from a registration\n * request. This property gets set via the initial registration process by a\n * `this.set()` method.\n *\n * @type {string}\n */\n url: 'string',\n\n /**\n * This property stores the device's userId uuid value, which can also be\n * derived from the device's registerd user's userId retrieved from\n * the **Hydra** service.\n *\n * @type {string}\n */\n userId: 'string',\n\n /**\n * This property stores whether or not file sharing is enabled\n *\n * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}\n */\n webFileShareControl: 'string',\n\n /**\n * This property stores the current web socket url used by the registered\n * device.\n *\n * @type {string}\n */\n webSocketUrl: 'string',\n\n /**\n * This property stores the value indicating whether or not white board file\n * sharing is enabled for the current device.\n *\n * @type {'ALLOW' | 'BLOCK'}\n */\n whiteboardFileShareControl: 'string',\n },\n\n /**\n * A list of derived properties that populate based when their parent data\n * available via the device's properties.\n *\n * @type {Object}\n */\n derived: {\n /**\n * This property determines if the current device is registered.\n *\n * @type {boolean}\n */\n registered: {\n deps: ['url'],\n\n /**\n * Checks if the device is registered by validating that the url exists.\n * Amperstand does not allow this to method to be written as an arrow\n * function.\n *\n * @returns {boolean}\n */\n fn() {\n return !!this.url;\n },\n },\n },\n\n /**\n * Stores timer data as well as other state details.\n *\n * @type {Object}\n */\n session: {\n /**\n * This property stores the logout timer object\n *\n * @type {any}\n */\n logoutTimer: 'any',\n\n /**\n * This property stores the date for the last activity the user made\n * with the current device.\n *\n * @type {number}\n */\n lastUserActivityDate: 'number',\n\n /**\n * This property stores whether or not the reachability check has been\n * performed to prevent the reachability check from performing its\n * operation more than once after a successful check.\n *\n * @returns {boolean}\n */\n isReachabilityChecked: ['boolean', false, false],\n\n /**\n * This property stores whether or not the next refresh or register request should request energy forecast data\n * in order to prevent over fetching energy forecasts\n *\n * @type {boolean}\n */\n energyForecastConfig: 'boolean',\n\n /**\n * This property stores whether or not the current device is in a meeting\n * to prevent an unneeded timeout of a meeting due to inactivity.\n *\n * @type {boolean}\n */\n isInMeeting: 'boolean',\n\n /**\n * This property identifies if the device is currently in network to prevent\n * the `resetLogoutTimer()` method from being called repeatedly once its\n * known client is connected to the organization's internal network.\n *\n * @type {boolean}\n */\n isInNetwork: 'boolean',\n },\n\n // Event method members.\n\n /**\n * Trigger meeting started event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingStarted() {\n this.webex.trigger('meeting started');\n },\n\n /**\n * Trigger meeting ended event for webex instance. Used by web-client team.\n *\n * @returns {void}\n */\n meetingEnded() {\n this.webex.trigger('meeting ended');\n },\n\n /**\n * Set the value of energy forecast config for the current registered device.\n * @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register\n * @returns {void}\n */\n setEnergyForecastConfig(energyForecastConfig = false) {\n this.energyForecastConfig = energyForecastConfig;\n },\n\n // Registration method members\n\n /**\n * Refresh the current registered device if able.\n *\n * @param {DeviceRegistrationOptions} options - The options for refresh.\n * @param {CatalogDetails} options.includeDetails - The details to include in the refresh/register request.\n * @returns {Promise<void, Error>}\n */\n @oneFlight\n @waitForValue('@')\n refresh(deviceRegistrationOptions = {}) {\n this.logger.info('device: refreshing');\n\n // Validate that the device can be registered.\n return this.canRegister().then(() => {\n // Validate if the device is not registered and register instead.\n if (!this.registered) {\n this.logger.info('device: device not registered, registering');\n\n return this.register(deviceRegistrationOptions);\n }\n\n // Merge body configurations, overriding defaults.\n const body = {\n ...this.serialize(),\n ...(this.config.body ? this.config.body : {}),\n };\n\n // Remove unneeded properties from the body object.\n delete body.features;\n delete body.mediaCluster;\n delete body.etag;\n\n // Append a ttl value if the device is marked as ephemeral.\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n\n // Merge header configurations, overriding defaults.\n const headers = {\n ...(this.config.defaults.headers ? this.config.defaults.headers : {}),\n ...(this.config.headers ? this.config.headers : {}),\n // If etag is sent, WDM will not send developer feature toggles unless they have changed\n ...(this.etag ? {'If-None-Match': this.etag} : {}),\n };\n\n const {includeDetails = CatalogDetails.all} = deviceRegistrationOptions;\n\n const requestId = uuid.v4();\n this.set('refresh-request-id', requestId);\n\n return this.request({\n method: 'PUT',\n uri: this.url,\n body,\n headers,\n qs: {\n includeUpstreamServices: `${includeDetails}${\n this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : ''\n }`,\n },\n })\n .then((response) => {\n // If we've signed out in the mean time, the request ID will have changed\n if (this.get('refresh-request-id') !== requestId) {\n this.logger.info('device: refresh request ID mismatch, ignoring response');\n\n return Promise.resolve();\n }\n\n return this.processRegistrationSuccess(response);\n })\n .catch((reason) => {\n // Handle a 404 error, which indicates that the device is no longer\n // valid and needs to be registered as a new device.\n if (reason.statusCode === 404) {\n this.logger.info('device: refresh failed, device is not valid');\n this.logger.info('device: attempting to register a new device');\n\n this.clear();\n\n return this.register(deviceRegistrationOptions);\n }\n\n return Promise.reject(reason);\n });\n });\n },\n /**\n * Fetches the web devices and deletes the third of them which are not recent devices in use\n * @returns {Promise<void, Error>}\n */\n deleteDevices() {\n // Fetch devices with a GET request\n return this.request({\n method: 'GET',\n service: 'wdm',\n resource: 'devices',\n })\n .then((response) => {\n const {devices} = response.body;\n\n const {deviceType} = this._getBody();\n\n // Filter devices of type deviceType\n const webDevices = devices.filter((item) => item.deviceType === deviceType);\n\n const sortedDevices = orderBy(webDevices, [(item) => new Date(item.modificationTime)]);\n\n // If there are more than two devices, delete the last third\n if (sortedDevices.length > 2) {\n const totalItems = sortedDevices.length;\n const countToDelete = Math.ceil(totalItems / 3);\n const urlsToDelete = sortedDevices.slice(0, countToDelete).map((item) => item.url);\n\n return Promise.race(\n urlsToDelete.map((url) => {\n return this.request({\n uri: url,\n method: 'DELETE',\n });\n })\n );\n }\n\n return Promise.resolve();\n })\n .catch((error) => {\n this.logger.error('Failed to retrieve devices:', error);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Registers and when fails deletes devices\n */\n @waitForValue('@')\n register(deviceRegistrationOptions = {}) {\n this.logger.info('device: registering');\n\n this.webex.internal.newMetrics.callDiagnosticMetrics.setDeviceInfo(this);\n\n // Validate that the device can be registered.\n return this.canRegister().then(() => {\n // Validate if the device is already registered and refresh instead.\n if (this.registered) {\n this.logger.info('device: device already registered, refreshing');\n\n return this.refresh(deviceRegistrationOptions);\n }\n\n return this._registerInternal(deviceRegistrationOptions).catch((error) => {\n if (error?.body?.message === 'User has excessive device registrations') {\n return this.deleteDevices().then(() => {\n return this._registerInternal(deviceRegistrationOptions);\n });\n }\n throw error;\n });\n });\n },\n\n _getBody() {\n return {\n ...(this.config.defaults.body ? this.config.defaults.body : {}),\n ...(this.config.body ? this.config.body : {}),\n };\n },\n\n /**\n * Register or refresh a device depending on the current device state. Device\n * registration utilizes the services plugin to send the request to the\n * **WDM** service.\n *\n * @param {Object} options - The options for registration.\n * @param {CatalogDetails} options.includeDetails - The details to include in the refresh/register request.\n * @returns {Promise<void, Error>}\n */\n @oneFlight\n @waitForValue('@')\n _registerInternal(deviceRegistrationOptions = {}) {\n this.logger.info('device: making registration request');\n\n // Merge body configurations, overriding defaults.\n const body = this._getBody();\n\n // Merge header configurations, overriding defaults.\n const headers = {\n ...(this.config.defaults.headers ? this.config.defaults.headers : {}),\n ...(this.config.headers ? this.config.headers : {}),\n };\n\n // Append a ttl value if the device is marked as ephemeral\n if (this.config.ephemeral) {\n body.ttl = this.config.ephemeralDeviceTTL;\n }\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.request',\n });\n\n const {includeDetails = CatalogDetails.all} = deviceRegistrationOptions;\n\n const requestId = uuid.v4();\n this.set('register-request-id', requestId);\n\n // This will be replaced by a `create()` method.\n return this.request({\n method: 'POST',\n service: 'wdm',\n resource: 'devices',\n body,\n headers,\n qs: {\n includeUpstreamServices: `${includeDetails}${\n this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : ''\n }`,\n },\n })\n .catch((error) => {\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response',\n });\n\n throw error;\n })\n .then((response) => {\n // If we've signed out in the mean time, the request ID will have changed\n if (this.get('register-request-id') !== requestId) {\n this.logger.info('device: register request ID mismatch, ignoring response');\n\n return Promise.resolve();\n }\n\n // Do not add any processing of response above this as that will affect timestamp\n this.webex.internal.newMetrics.submitInternalEvent({\n name: 'internal.register.device.response',\n });\n\n this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);\n\n return this.processRegistrationSuccess(response);\n })\n .catch((error) => {\n this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_WDM_REGISTRATION_FAILED, {\n fields: {error},\n });\n throw error;\n });\n },\n /**\n * Unregister the current registered device if available. Unregistering a\n * device utilizes the services plugin to send the request to the **WDM**\n * service.\n *\n * @returns {Promise<void, Error>}\n */\n @oneFlight\n @waitForValue('@')\n unregister() {\n this.logger.info('device: unregistering');\n\n if (!this.registered) {\n this.logger.warn('device: not registered');\n\n return Promise.resolve();\n }\n\n return this.request({\n uri: this.url,\n method: 'DELETE',\n })\n .then(() => this.clear())\n .catch((reason) => {\n if (reason.statusCode === 404) {\n this.logger.info(\n 'device: 404 when deleting device, device is already deleted, clearing device'\n );\n\n this.clear();\n }\n throw reason;\n });\n },\n /* eslint-enable require-jsdoc */\n\n // Helper method members\n\n /**\n * Determine if registration methods can be performed. This method utilizes\n * the `services` plugin to confirm if the appropriate service urls are\n * available for device registration.\n *\n * @returns {Promise<void, Error>}\n */\n canRegister() {\n this.logger.info('device: validating if registration can occur');\n\n // Destructure the services plugin for ease of reference.\n const {services} = this.webex.internal;\n\n // Wait for the postauth catalog to populate.\n return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(() =>\n // Validate that the service exists after waiting for the catalog.\n services.get('wdm')\n ? Promise.resolve()\n : Promise.reject(\n new Error(\n [\n 'device: cannot register,',\n \"'wdm' service is not available from the postauth catalog\",\n ].join(' ')\n )\n )\n );\n },\n\n /**\n * Check if the device can currently reach the inactivity check url.\n *\n * @returns {Promise<void, Error>}\n */\n checkNetworkReachability() {\n this.logger.info('device: checking network reachability');\n\n // Validate if the device has been checked and reset the logout timer.\n if (this.isReachabilityChecked) {\n return Promise.resolve(this.resetLogoutTimer());\n }\n\n this.isReachabilityChecked = true;\n\n // Validate if the device has a intranet checking url.\n if (!this.intranetInactivityCheckUrl) {\n this.isInNetwork = false;\n\n return Promise.resolve(this.resetLogoutTimer());\n }\n\n // Clear unnecessary headers for reachability request.\n const headers = {\n 'cisco-no-http-redirect': null,\n 'spark-user-agent': null,\n trackingid: null,\n };\n\n // Send the network reachability request.\n return this.request({\n headers,\n method: 'GET',\n uri: this.intranetInactivityCheckUrl,\n })\n .then(() => {\n this.isInNetwork = true;\n\n return Promise.resolve(this.resetLogoutTimer());\n })\n .catch(() => {\n this.logger.info('device: did not reach ping endpoint');\n this.logger.info('device: triggering off-network timer');\n\n this.isInNetwork = false;\n\n return Promise.resolve(this.resetLogoutTimer());\n });\n },\n\n /**\n * Clears the registration ttl value if available.\n *\n * @param {Object} options - Values to be cleared.\n * @returns {void}\n */\n clear(...args) {\n this.logger.info('device: clearing registered device');\n\n // Prototype the extended class in order to preserve the parent member.\n Reflect.apply(WebexPlugin.prototype.clear, this, args);\n },\n\n /**\n * Get the current websocket url with the appropriate priority host.\n *\n * @param {boolean} [wait=false] - Willing to wait on a valid url.\n * @returns {Promise<string, Error>} - The priority-mapped web socket url.\n */\n getWebSocketUrl(wait = false) {\n this.logger.info('device: getting the current websocket url');\n\n // Destructure the services plugin for ease of reference.\n const {services} = this.webex.internal;\n\n // Validate if the method should wait for registration.\n if (wait) {\n return this.waitForRegistration()\n .then(() => services.convertUrlToPriorityHostUrl(this.webSocketUrl))\n .catch((error) => {\n this.logger.warn(error.message);\n\n return Promise.reject(new Error('device: failed to get the current websocket url'));\n });\n }\n\n // Validate if the device is registered.\n if (!this.registered) {\n return Promise.reject(\n new Error('device: cannot get websocket url, device is not registered')\n );\n }\n\n // Attempt to collect the priority-host-mapped web socket URL.\n const wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);\n\n // Validate that the url was collected.\n if (wsUrl) {\n return Promise.resolve(wsUrl);\n }\n\n return Promise.reject(new Error('device: failed to get the current websocket url'));\n },\n\n /**\n * Process a successful device registration.\n *\n * @param {Object} response - response object from registration success.\n * @returns {void}\n */\n processRegistrationSuccess(response) {\n this.logger.info('device: received registration payload');\n\n // Clone the response body for service cleaning.\n const body = {...response.body};\n\n // Clean service data.\n delete body.services;\n delete body.serviceHostMap;\n\n const {etag} = response.headers || {};\n\n if (this.etag && etag && this.etag === etag) {\n // If current etag matches the previous one and we have sent\n // If-None-Match header the developer and entitlement feature\n // toggles will not be returned\n const {features} = body;\n\n delete body.features;\n // When using the etag feature cache, user and entitlement features are still returned\n this.features.user.reset(features.user);\n this.features.entitlement.reset(features.entitlement);\n }\n\n // Assign the recieved DTO from **WDM** to this device.\n this.set(body);\n\n // Assign the new etag to this device.\n this.set({etag});\n\n // Validate if device is ephemeral and setup refresh timer.\n if (this.config.ephemeral) {\n this.logger.info('device: enqueuing device refresh');\n\n const delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;\n\n this.refreshTimer = safeSetTimeout(() => this.refresh(), delay);\n }\n\n // Emit the registration:success event.\n this.trigger(DEVICE_EVENT_REGISTRATION_SUCCESS, this);\n },\n\n /**\n * Reset the current local logout timer for the registered device if\n * registered.\n *\n * @returns {void}\n */\n resetLogoutTimer() {\n this.logger.info('device: resetting logout timer');\n\n // Clear current logout timer.\n clearTimeout(this.logoutTimer);\n\n // Remove last activity date event listener.\n this.off('change:lastUserActivityDate');\n\n // Remove the logout timer.\n this.unset('logoutTimer');\n\n // Validate if the device is currently in a meeting and is configured to\n // required inactivity enforcement.\n if (\n !this.isInMeeting &&\n this.config.enableInactivityEnforcement &&\n this.isReachabilityChecked\n ) {\n if (this.isInNetwork) {\n this.setLogoutTimer(this.inNetworkInactivityDuration);\n } else {\n this.setLogoutTimer(this.intranetInactivityDuration);\n }\n }\n },\n\n /**\n * Set the value of the logout timer for the current registered device.\n *\n * @param {number} duration - Value in seconds of the new logout timer.\n * @returns {void}\n */\n setLogoutTimer(duration) {\n this.logger.info('device: setting logout timer');\n\n if (!duration || duration <= 0) {\n return;\n }\n\n // Setup user activity date event listener.\n this.on('change:lastUserActivityDate', () => {\n this.resetLogoutTimer();\n });\n\n // Initialize a new timer.\n this.logoutTimer = safeSetTimeout(() => {\n this.webex.logout();\n }, duration * 1000);\n },\n\n /**\n * Wait for the device to be registered.\n *\n * @param {number} [timeout=10] - The maximum duration to wait, in seconds.\n * @returns {Promise<void, Error>}\n */\n waitForRegistration(timeout = 10) {\n this.logger.info('device: waiting for registration');\n\n return new Promise((resolve, reject) => {\n if (this.registered) {\n resolve();\n }\n\n const timeoutTimer = safeSetTimeout(\n () => reject(new Error('device: timeout occured while waiting for registration')),\n timeout * 1000\n );\n\n this.once(DEVICE_EVENT_REGISTRATION_SUCCESS, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n\n // Deprecated methods.\n\n /**\n * Mark a url as failed and get the next priority host url.\n *\n * @param {string} url - The url to mark as failed.\n * @returns {Promise<string>} - The next priority url.\n */\n @deprecated('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()')\n markUrlFailedAndGetNew(url) {\n return Promise.resolve(this.webex.internal.services.markFailedUrl(url));\n },\n\n // Ampersand method members\n\n /* eslint-disable require-jsdoc */\n /**\n * Initializer method for the device plugin.\n *\n * @override\n * @param {Array<any>} args - An array of items to be mapped as properties.\n * @returns {void}\n */\n @persist('@', decider)\n initialize(...args) {\n // Prototype the extended class in order to preserve the parent member.\n Reflect.apply(WebexPlugin.prototype.initialize, this, args);\n\n // Initialize feature events and listeners.\n FEATURE_COLLECTION_NAMES.forEach((collectionName) => {\n this.features.on(`change:${collectionName}`, (model, value, options) => {\n this.trigger('change', this, options);\n this.trigger('change:features', this, this.features, options);\n });\n });\n\n // Initialize network reachability checking event for url change.\n this.on('change:intranetInactivityCheckUrl', () => {\n this.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:intranetInactivityDuration', () => {\n this.checkNetworkReachability();\n });\n\n // Initialize network reachability checking event for duration change.\n this.on('change:inNetworkInactivityDuration', () => {\n this.checkNetworkReachability();\n });\n\n // Initialize listener for activity checking.\n this.listenTo(this.webex, 'user-activity', () => {\n this.lastUserActivityDate = Date.now();\n });\n\n // Initialize listener for meeting started event.\n this.listenTo(this.webex, 'meeting started', () => {\n this.isInMeeting = true;\n this.resetLogoutTimer();\n });\n\n // Initialize listener for meeting ended event.\n this.listenTo(this.webex, 'meeting ended', () => {\n this.isInMeeting = false;\n this.resetLogoutTimer();\n });\n },\n /* eslint-enable require-jsdoc */\n});\n\nexport default Device;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,cAAA,GAAAH,sBAAA,CAAAL,OAAA;AACA,IAAAS,kBAAA,GAAAJ,sBAAA,CAAAL,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAAuC,IAAAW,IAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC,IAAA,EAXvC;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,iCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAA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A;AACA;IACIC,sBAAsB,EAAE,QAAQ;IAEhC;AACJ;AACA;AACA;AACA;AACA;IACIC,eAAe,EAAE,SAAS;IAE1B;AACJ;AACA;AACA;AACA;IACIC,0BAA0B,EAAE,QAAQ;IAEpC;AACJ;AACA;AACA;AACA;IACIC,sBAAsB,EAAE,QAAQ;IAEhC;AACJ;AACA;AACA;AACA;AACA;AACA;IACIC,GAAG,EAAE,QAAQ;IAEb;AACJ;AACA;AACA;AACA;AACA;AACA;IACIC,MAAM,EAAE,QAAQ;IAEhB;AACJ;AACA;AACA;AACA;IACIC,mBAAmB,EAAE,QAAQ;IAE7B;AACJ;AACA;AACA;AACA;AACA;IACIC,YAAY,EAAE,QAAQ;IAEtB;AACJ;AACA;AACA;AACA;AACA;IACIC,0BAA0B,EAAE;EAC9B,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,OAAO,EAAE;IACP;AACJ;AACA;AACA;AACA;IACIC,UAAU,EAAE;MACVC,IAAI,EAAE,CAAC,KAAK,CAAC;MAEb;AACN;AACA;AACA;AACA;AACA;AACA;MACMC,EAAE,WAAAA,GAAA,EAAG;QACH,OAAO,CAAC,CAAC,IAAI,CAACR,GAAG;MACnB;IACF;EACF,CAAC;EAED;AACF;AACA;AACA;AACA;EACES,OAAO,EAAE;IACP;AACJ;AACA;AACA;AACA;IACIC,WAAW,EAAE,KAAK;IAElB;AACJ;AACA;AACA;AACA;AACA;IACIC,oBAAoB,EAAE,QAAQ;IAE9B;AACJ;AACA;AACA;AACA;AACA;AACA;IACIC,qBAAqB,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC;IAEhD;AACJ;AACA;AACA;AACA;AACA;IACIC,oBAAoB,EAAE,SAAS;IAE/B;AACJ;AACA;AACA;AACA;AACA;IACIC,WAAW,EAAE,SAAS;IAEtB;AACJ;AACA;AACA;AACA;AACA;AACA;IACIC,WAAW,EAAE;EACf,CAAC;EAED;EAEA;AACF;AACA;AACA;AACA;EACEC,cAAc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AA,GAAAC,OAAA,CAAAlN,OAAA,GAEYO,MAAM"}
@@ -225,7 +225,7 @@ var IpNetworkDetector = _webexCore.WebexPlugin.extend({
225
225
  }, _callee2, null, [[6,, 12, 16]]);
226
226
  }))();
227
227
  },
228
- version: "3.7.0-wxcc.1"
228
+ version: "3.8.0-next.1"
229
229
  });
230
230
  var _default = exports.default = IpNetworkDetector;
231
231
  //# sourceMappingURL=ipNetworkDetector.js.map
package/package.json CHANGED
@@ -25,10 +25,10 @@
25
25
  "@webex/eslint-config-legacy": "0.0.0",
26
26
  "@webex/jest-config-legacy": "0.0.0",
27
27
  "@webex/legacy-tools": "0.0.0",
28
- "@webex/test-helper-chai": "3.7.0-wxcc.1",
29
- "@webex/test-helper-mocha": "3.7.0-wxcc.1",
30
- "@webex/test-helper-mock-webex": "3.7.0-wxcc.1",
31
- "@webex/test-helper-test-users": "3.7.0-wxcc.1",
28
+ "@webex/test-helper-chai": "3.8.0-next.1",
29
+ "@webex/test-helper-mocha": "3.8.0-next.1",
30
+ "@webex/test-helper-mock-webex": "3.8.0-next.1",
31
+ "@webex/test-helper-test-users": "3.8.0-next.1",
32
32
  "chai": "^4.3.4",
33
33
  "chai-as-promised": "^7.1.1",
34
34
  "eslint": "^8.24.0",
@@ -36,11 +36,11 @@
36
36
  "sinon": "^9.2.4"
37
37
  },
38
38
  "dependencies": {
39
- "@webex/common": "3.7.0-wxcc.1",
40
- "@webex/common-timers": "3.7.0-wxcc.1",
41
- "@webex/http-core": "3.7.0-wxcc.1",
42
- "@webex/internal-plugin-metrics": "3.7.0-wxcc.1",
43
- "@webex/webex-core": "3.7.0-wxcc.1",
39
+ "@webex/common": "3.8.0-next.1",
40
+ "@webex/common-timers": "3.8.0-next.1",
41
+ "@webex/http-core": "3.8.0-next.1",
42
+ "@webex/internal-plugin-metrics": "3.8.0-next.1",
43
+ "@webex/webex-core": "3.8.0-next.1",
44
44
  "ampersand-collection": "^2.0.2",
45
45
  "ampersand-state": "^5.0.3",
46
46
  "lodash": "^4.17.21"
@@ -54,5 +54,5 @@
54
54
  "test:style": "eslint ./src/**/*.*",
55
55
  "test:unit": "webex-legacy-tools test --unit --runner jest"
56
56
  },
57
- "version": "3.7.0-wxcc.1"
57
+ "version": "3.8.0-next.1"
58
58
  }
package/src/device.js CHANGED
@@ -3,6 +3,7 @@ import {deprecated, oneFlight} from '@webex/common';
3
3
  import {persist, waitForValue, WebexPlugin} from '@webex/webex-core';
4
4
  import {safeSetTimeout} from '@webex/common-timers';
5
5
  import {orderBy} from 'lodash';
6
+ import uuid from 'uuid';
6
7
 
7
8
  import METRICS from './metrics';
8
9
  import {FEATURE_COLLECTION_NAMES, DEVICE_EVENT_REGISTRATION_SUCCESS} from './constants';
@@ -412,6 +413,9 @@ const Device = WebexPlugin.extend({
412
413
 
413
414
  const {includeDetails = CatalogDetails.all} = deviceRegistrationOptions;
414
415
 
416
+ const requestId = uuid.v4();
417
+ this.set('refresh-request-id', requestId);
418
+
415
419
  return this.request({
416
420
  method: 'PUT',
417
421
  uri: this.url,
@@ -423,7 +427,16 @@ const Device = WebexPlugin.extend({
423
427
  }`,
424
428
  },
425
429
  })
426
- .then((response) => this.processRegistrationSuccess(response))
430
+ .then((response) => {
431
+ // If we've signed out in the mean time, the request ID will have changed
432
+ if (this.get('refresh-request-id') !== requestId) {
433
+ this.logger.info('device: refresh request ID mismatch, ignoring response');
434
+
435
+ return Promise.resolve();
436
+ }
437
+
438
+ return this.processRegistrationSuccess(response);
439
+ })
427
440
  .catch((reason) => {
428
441
  // Handle a 404 error, which indicates that the device is no longer
429
442
  // valid and needs to be registered as a new device.
@@ -555,6 +568,9 @@ const Device = WebexPlugin.extend({
555
568
 
556
569
  const {includeDetails = CatalogDetails.all} = deviceRegistrationOptions;
557
570
 
571
+ const requestId = uuid.v4();
572
+ this.set('register-request-id', requestId);
573
+
558
574
  // This will be replaced by a `create()` method.
559
575
  return this.request({
560
576
  method: 'POST',
@@ -576,6 +592,13 @@ const Device = WebexPlugin.extend({
576
592
  throw error;
577
593
  })
578
594
  .then((response) => {
595
+ // If we've signed out in the mean time, the request ID will have changed
596
+ if (this.get('register-request-id') !== requestId) {
597
+ this.logger.info('device: register request ID mismatch, ignoring response');
598
+
599
+ return Promise.resolve();
600
+ }
601
+
579
602
  // Do not add any processing of response above this as that will affect timestamp
580
603
  this.webex.internal.newMetrics.submitInternalEvent({
581
604
  name: 'internal.register.device.response',
@@ -7,6 +7,13 @@ import {CatalogDetails} from '@webex/internal-plugin-device';
7
7
 
8
8
  import dto from './wdm-dto';
9
9
 
10
+ const waitForAsync = () =>
11
+ new Promise((resolve) =>
12
+ setImmediate(() => {
13
+ return resolve();
14
+ })
15
+ );
16
+
10
17
  describe('plugin-device', () => {
11
18
  describe('Device', () => {
12
19
  let webex;
@@ -355,6 +362,69 @@ describe('plugin-device', () => {
355
362
 
356
363
  assert.calledWith(registerSpy, {includeDetails: CatalogDetails.websocket});
357
364
  });
365
+
366
+ it('does not process refresh if log out between start and end of request', async () => {
367
+ setup();
368
+
369
+ let resolve;
370
+
371
+ const requestFn = () => {
372
+ return new Promise((r) => {
373
+ resolve = r;
374
+ });
375
+ };
376
+
377
+ device.request.restore();
378
+
379
+ sinon.stub(device, 'request').callsFake(requestFn);
380
+
381
+ const resultPromise = device.refresh();
382
+
383
+ await waitForAsync();
384
+
385
+ device.clear();
386
+
387
+ resolve({
388
+ body: {
389
+ exampleKey: 'example response value',
390
+ },
391
+ });
392
+
393
+ await resultPromise;
394
+
395
+ assert.notCalled(device.processRegistrationSuccess);
396
+ });
397
+
398
+ it('processes refresh if refresh id does not change', async () => {
399
+ setup();
400
+
401
+ let resolve;
402
+
403
+ const requestFn = () => {
404
+ return new Promise((r) => {
405
+ resolve = r;
406
+ });
407
+ };
408
+
409
+ device.request.restore();
410
+
411
+ sinon.stub(device, 'request').callsFake(requestFn);
412
+
413
+ const resultPromise = device.refresh();
414
+
415
+ await waitForAsync();
416
+
417
+ resolve({
418
+ body: {
419
+ exampleKey: 'example response value',
420
+ },
421
+ });
422
+
423
+ await resultPromise;
424
+
425
+ assert.calledOnce(device.processRegistrationSuccess);
426
+ });
427
+
358
428
  });
359
429
 
360
430
  describe('deleteDevices()', () => {
@@ -540,6 +610,67 @@ describe('plugin-device', () => {
540
610
  });
541
611
  });
542
612
 
613
+ it('does not process registration if log out between start and end of request', async () => {
614
+ setup();
615
+ sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
616
+
617
+ let resolve;
618
+
619
+ const requestFn = () => {
620
+ return new Promise((r) => {
621
+ resolve = r;
622
+ });
623
+ };
624
+
625
+ sinon.stub(device, 'request').callsFake(requestFn);
626
+
627
+ const resultPromise = device.register();
628
+
629
+ await waitForAsync();
630
+
631
+ device.clear();
632
+
633
+ resolve({
634
+ body: {
635
+ exampleKey: 'example response value',
636
+ }
637
+ });
638
+
639
+ await resultPromise;
640
+
641
+ assert.notCalled(device.processRegistrationSuccess);
642
+ });
643
+
644
+ it('calls process registration if request id matches', async () => {
645
+ setup();
646
+ sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
647
+
648
+ let resolve;
649
+
650
+ const requestFn = () => {
651
+ return new Promise((r) => {
652
+ resolve = r;
653
+ });
654
+ };
655
+
656
+ sinon.stub(device, 'request').callsFake(requestFn);
657
+
658
+ const resultPromise = device.register();
659
+
660
+ await waitForAsync();
661
+
662
+ resolve({
663
+ body: {
664
+ exampleKey: 'example response value',
665
+ },
666
+ });
667
+
668
+ await resultPromise;
669
+
670
+ assert.calledOnce(device.processRegistrationSuccess);
671
+ });
672
+
673
+
543
674
  it('checks that submitInternalEvent gets called with internal.register.device.response on success', async () => {
544
675
  setup();
545
676
  sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());