@webex/internal-plugin-device 3.0.0-beta.4 → 3.0.0-beta.400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +10 -6
  2. package/dist/config.js +9 -9
  3. package/dist/config.js.map +1 -1
  4. package/dist/constants.js +2 -3
  5. package/dist/constants.js.map +1 -1
  6. package/dist/device.js +114 -172
  7. package/dist/device.js.map +1 -1
  8. package/dist/features/feature-collection.js +1 -8
  9. package/dist/features/feature-collection.js.map +1 -1
  10. package/dist/features/feature-model.js +15 -42
  11. package/dist/features/feature-model.js.map +1 -1
  12. package/dist/features/features-model.js +9 -21
  13. package/dist/features/features-model.js.map +1 -1
  14. package/dist/features/index.js +0 -8
  15. package/dist/features/index.js.map +1 -1
  16. package/dist/index.js +2 -24
  17. package/dist/index.js.map +1 -1
  18. package/dist/interceptors/device-url.js +12 -33
  19. package/dist/interceptors/device-url.js.map +1 -1
  20. package/dist/ipNetworkDetector.js +200 -0
  21. package/dist/ipNetworkDetector.js.map +1 -0
  22. package/dist/metrics.js +0 -2
  23. package/dist/metrics.js.map +1 -1
  24. package/package.json +10 -10
  25. package/src/config.js +17 -9
  26. package/src/constants.js +3 -5
  27. package/src/device.js +164 -146
  28. package/src/features/feature-collection.js +1 -1
  29. package/src/features/feature-model.js +5 -11
  30. package/src/features/features-model.js +3 -9
  31. package/src/features/index.js +1 -5
  32. package/src/index.js +3 -11
  33. package/src/interceptors/device-url.js +5 -7
  34. package/src/ipNetworkDetector.ts +176 -0
  35. package/src/metrics.js +1 -2
  36. package/test/integration/spec/device.js +210 -239
  37. package/test/integration/spec/webex.js +9 -9
  38. package/test/unit/spec/device.js +110 -53
  39. package/test/unit/spec/features/feature-collection.js +2 -2
  40. package/test/unit/spec/features/feature-model.js +23 -39
  41. package/test/unit/spec/features/features-model.js +4 -12
  42. package/test/unit/spec/interceptors/device-url.js +69 -109
  43. package/test/unit/spec/ipNetworkDetector.js +410 -0
  44. package/test/unit/spec/wdm-dto.json +5 -13
package/dist/device.js CHANGED
@@ -1,55 +1,32 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
-
5
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
-
7
5
  var _Object$getOwnPropertyDescriptor2 = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
-
9
6
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
10
-
11
7
  var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
12
-
13
8
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
14
-
15
9
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
16
-
17
10
  _Object$defineProperty(exports, "__esModule", {
18
11
  value: true
19
12
  });
20
-
21
13
  exports.default = void 0;
22
-
23
14
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
24
-
25
15
  var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
26
-
27
16
  var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
28
-
29
17
  var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
30
-
31
18
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
32
-
33
19
  var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
34
-
35
20
  var _common = require("@webex/common");
36
-
37
21
  var _webexCore = require("@webex/webex-core");
38
-
39
22
  var _commonTimers = require("@webex/common-timers");
40
-
41
23
  var _metrics = _interopRequireDefault(require("./metrics"));
42
-
43
24
  var _constants = require("./constants");
44
-
45
25
  var _featuresModel = _interopRequireDefault(require("./features/features-model"));
46
-
26
+ var _ipNetworkDetector = _interopRequireDefault(require("./ipNetworkDetector"));
47
27
  var _dec, _dec2, _dec3, _dec4, _dec5, _obj;
48
-
49
28
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor2(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
50
-
51
29
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor2(source, key)); }); } return target; }
52
-
53
30
  /**
54
31
  * Determine if the plugin should be initialized based on cached storage.
55
32
  *
@@ -58,9 +35,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
58
35
  function decider() {
59
36
  return !this.config.ephemeral;
60
37
  }
61
-
62
38
  var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)('@'), _dec2 = (0, _webexCore.waitForValue)('@'), _dec3 = (0, _webexCore.waitForValue)('@'), _dec4 = (0, _common.deprecated)('device#markUrlFailedAndGetNew(): Use services#markFailedUrl()'), _dec5 = (0, _webexCore.persist)('@', decider), (_obj = {
63
39
  // Ampersand property members.
40
+
64
41
  namespace: 'Device',
65
42
  // Allow for extra properties to prevent the plugin from failing due to
66
43
  // **WDM** service DTO changes.
@@ -72,9 +49,14 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
72
49
  *
73
50
  * @type {FeaturesModel}
74
51
  */
75
- features: _featuresModel.default
52
+ features: _featuresModel.default,
53
+ /**
54
+ * Helper class for detecting what IP network version (ipv4, ipv6) we're on.
55
+ *
56
+ * @type {IpNetworkDetector}
57
+ */
58
+ ipNetworkDetector: _ipNetworkDetector.default
76
59
  },
77
-
78
60
  /**
79
61
  * A collection of device properties mostly assigned by the retrieved DTO from
80
62
  * the **WDM** service that are mapped against the ampersand properties.
@@ -88,21 +70,18 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
88
70
  * @type {'ALLOW' | 'BLOCK'}
89
71
  */
90
72
  clientMessagingGiphy: 'string',
91
-
92
73
  /**
93
74
  * This property should store the company name.
94
75
  *
95
76
  * @type {string}
96
77
  */
97
78
  customerCompanyName: 'string',
98
-
99
79
  /**
100
80
  * This property should store the logo url.
101
81
  *
102
82
  * @type {string}
103
83
  */
104
84
  customerLogoUrl: 'string',
105
-
106
85
  /**
107
86
  * This property doesn't have any real values, but is sent during device
108
87
  * refresh to prevent the **wdm** service from falling back to an iOS device
@@ -111,21 +90,18 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
111
90
  * @type {string}
112
91
  */
113
92
  deviceType: 'string',
114
-
115
93
  /**
116
94
  * This property should store the help url.
117
95
  *
118
96
  * @type {string}
119
97
  */
120
98
  helpUrl: 'string',
121
-
122
99
  /**
123
100
  * This property should store the intranet inactivity timer duration.
124
101
  *
125
102
  * @type {number}
126
103
  */
127
104
  intranetInactivityDuration: 'number',
128
-
129
105
  /**
130
106
  * This property stores the url required to validate if the device is able
131
107
  * to actively reach the intranet network.
@@ -133,7 +109,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
133
109
  * @type {string}
134
110
  */
135
111
  intranetInactivityCheckUrl: 'string',
136
-
137
112
  /**
138
113
  * This property stores the inactivity timer duration, and could possibly
139
114
  * deprecate the `intranetInactivityDuration` property.
@@ -141,7 +116,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
141
116
  * @type {number}
142
117
  */
143
118
  inNetworkInactivityDuration: 'number',
144
-
145
119
  /**
146
120
  * This property stores the ECM (external content management) enabled value
147
121
  * for the whole organization.
@@ -149,7 +123,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
149
123
  * @type {boolean}
150
124
  */
151
125
  ecmEnabledForAllUsers: ['boolean', false, false],
152
-
153
126
  /**
154
127
  * This property stores an array of ECM (external content management)
155
128
  * providers that are currently available.
@@ -159,7 +132,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
159
132
  ecmSupportedStorageProviders: ['array', false, function () {
160
133
  return [];
161
134
  }],
162
-
163
135
  /**
164
136
  * This property stores the modification time value retrieved from the
165
137
  * **WDM** endpoint formatted as ISO 8601.
@@ -167,28 +139,24 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
167
139
  * @type {string}
168
140
  */
169
141
  modificationTime: 'string',
170
-
171
142
  /**
172
143
  * This property stores the navigation bar color.
173
144
  *
174
145
  * @type {string}
175
146
  */
176
147
  navigationBarColor: 'string',
177
-
178
148
  /**
179
149
  * This property stores the partner company's name when available.
180
150
  *
181
151
  * @type {string}
182
152
  */
183
153
  partnerCompanyName: 'string',
184
-
185
154
  /**
186
155
  * This property stores the partner company's logo when available.
187
156
  *
188
157
  * @type {string}
189
158
  */
190
159
  partnerLogoUrl: 'string',
191
-
192
160
  /**
193
161
  * This property stores the availability of people data from the **WDM**
194
162
  * service.
@@ -196,28 +164,24 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
196
164
  * @type {boolean}
197
165
  */
198
166
  peopleInsightsEnabled: 'boolean',
199
-
200
167
  /**
201
168
  * This property stores the reporting site's description when available.
202
169
  *
203
170
  * @type {string}
204
171
  */
205
172
  reportingSiteDesc: 'string',
206
-
207
173
  /**
208
174
  * This property stores the reporting site's access url when available.
209
175
  *
210
176
  * @type {string}
211
177
  */
212
178
  reportingSiteUrl: 'string',
213
-
214
179
  /**
215
180
  * This property stores the encryption key url when available.
216
181
  *
217
182
  * @type {string}
218
183
  */
219
184
  searchEncryptionKeyUrl: 'string',
220
-
221
185
  /**
222
186
  * This property stores the availability of support-provided text from the
223
187
  * **WDM** service.
@@ -225,21 +189,18 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
225
189
  * @type {boolean}
226
190
  */
227
191
  showSupportText: 'boolean',
228
-
229
192
  /**
230
193
  * This property stores the support provider's company name when available.
231
194
  *
232
195
  * @type {string}
233
196
  */
234
197
  supportProviderCompanyName: 'string',
235
-
236
198
  /**
237
199
  * This property stores the support provider's logo url when available.
238
200
  *
239
201
  * @type {string}
240
202
  */
241
203
  supportProviderLogoUrl: 'string',
242
-
243
204
  /**
244
205
  * This property stores the device's url retrieved from a registration
245
206
  * request. This property gets set via the initial registration process by a
@@ -248,7 +209,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
248
209
  * @type {string}
249
210
  */
250
211
  url: 'string',
251
-
252
212
  /**
253
213
  * This property stores the device's userId uuid value, which can also be
254
214
  * derived from the device's registerd user's userId retrieved from
@@ -257,14 +217,12 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
257
217
  * @type {string}
258
218
  */
259
219
  userId: 'string',
260
-
261
220
  /**
262
221
  * This property stores whether or not file sharing is enabled
263
222
  *
264
223
  * @type {'BLOCK_BOTH' | 'BLOCK_UPLOAD'}
265
224
  */
266
225
  webFileShareControl: 'string',
267
-
268
226
  /**
269
227
  * This property stores the current web socket url used by the registered
270
228
  * device.
@@ -272,7 +230,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
272
230
  * @type {string}
273
231
  */
274
232
  webSocketUrl: 'string',
275
-
276
233
  /**
277
234
  * This property stores the value indicating whether or not white board file
278
235
  * sharing is enabled for the current device.
@@ -281,7 +238,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
281
238
  */
282
239
  whiteboardFileShareControl: 'string'
283
240
  },
284
-
285
241
  /**
286
242
  * A list of derived properties that populate based when their parent data
287
243
  * available via the device's properties.
@@ -296,7 +252,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
296
252
  */
297
253
  registered: {
298
254
  deps: ['url'],
299
-
300
255
  /**
301
256
  * Checks if the device is registered by validating that the url exists.
302
257
  * Amperstand does not allow this to method to be written as an arrow
@@ -309,7 +264,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
309
264
  }
310
265
  }
311
266
  },
312
-
313
267
  /**
314
268
  * Stores timer data as well as other state details.
315
269
  *
@@ -322,7 +276,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
322
276
  * @type {any}
323
277
  */
324
278
  logoutTimer: 'any',
325
-
326
279
  /**
327
280
  * This property stores the date for the last activity the user made
328
281
  * with the current device.
@@ -330,7 +283,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
330
283
  * @type {number}
331
284
  */
332
285
  lastUserActivityDate: 'number',
333
-
334
286
  /**
335
287
  * This property stores whether or not the reachability check has been
336
288
  * performed to prevent the reachability check from performing its
@@ -339,7 +291,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
339
291
  * @returns {boolean}
340
292
  */
341
293
  isReachabilityChecked: ['boolean', false, false],
342
-
343
294
  /**
344
295
  * This property stores whether or not the current device is in a meeting
345
296
  * to prevent an unneeded timeout of a meeting due to inactivity.
@@ -347,7 +298,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
347
298
  * @type {boolean}
348
299
  */
349
300
  isInMeeting: 'boolean',
350
-
351
301
  /**
352
302
  * This property identifies if the device is currently in network to prevent
353
303
  * the `resetLogoutTimer()` method from being called repeatedly once its
@@ -358,7 +308,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
358
308
  isInNetwork: 'boolean'
359
309
  },
360
310
  // Event method members.
361
-
362
311
  /**
363
312
  * Trigger meeting started event for webex instance. Used by web-client team.
364
313
  *
@@ -367,7 +316,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
367
316
  meetingStarted: function meetingStarted() {
368
317
  this.webex.trigger('meeting started');
369
318
  },
370
-
371
319
  /**
372
320
  * Trigger meeting ended event for webex instance. Used by web-client team.
373
321
  *
@@ -378,34 +326,33 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
378
326
  },
379
327
  refresh: function refresh() {
380
328
  var _this = this;
329
+ this.logger.info('device: refreshing');
381
330
 
382
- this.logger.info('device: refreshing'); // Validate that the device can be registered.
383
-
331
+ // Validate that the device can be registered.
384
332
  return this.canRegister().then(function () {
385
333
  // Validate if the device is not registered and register instead.
386
334
  if (!_this.registered) {
387
335
  _this.logger.info('device: device not registered, registering');
388
-
389
336
  return _this.register();
390
- } // Merge body configurations, overriding defaults.
391
-
392
-
393
- var body = _objectSpread(_objectSpread({}, _this.serialize()), _this.config.body ? _this.config.body : {}); // Remove unneeded properties from the body object.
337
+ }
394
338
 
339
+ // Merge body configurations, overriding defaults.
340
+ var body = _objectSpread(_objectSpread({}, _this.serialize()), _this.config.body ? _this.config.body : {});
395
341
 
342
+ // Remove unneeded properties from the body object.
396
343
  delete body.features;
397
344
  delete body.mediaCluster;
398
- delete body.etag; // Append a ttl value if the device is marked as ephemeral.
345
+ delete body.etag;
399
346
 
347
+ // Append a ttl value if the device is marked as ephemeral.
400
348
  if (_this.config.ephemeral) {
401
349
  body.ttl = _this.config.ephemeralDeviceTTL;
402
- } // Merge header configurations, overriding defaults.
403
-
350
+ }
404
351
 
352
+ // Merge header configurations, overriding defaults.
405
353
  var headers = _objectSpread(_objectSpread(_objectSpread({}, _this.config.defaults.headers ? _this.config.defaults.headers : {}), _this.config.headers ? _this.config.headers : {}), _this.etag ? {
406
354
  'If-None-Match': _this.etag
407
355
  } : {});
408
-
409
356
  return _this.request({
410
357
  method: 'PUT',
411
358
  uri: _this.url,
@@ -418,52 +365,58 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
418
365
  // valid and needs to be registered as a new device.
419
366
  if (reason.statusCode === 404) {
420
367
  _this.logger.info('device: refresh failed, device is not valid');
421
-
422
368
  _this.logger.info('device: attempting to register a new device');
423
-
424
369
  _this.clear();
425
-
426
370
  return _this.register();
427
371
  }
428
-
429
372
  return _promise.default.reject(reason);
430
373
  });
431
374
  });
432
375
  },
433
376
  register: function register() {
434
377
  var _this2 = this;
378
+ this.logger.info('device: registering');
435
379
 
436
- this.logger.info('device: registering'); // Validate that the device can be registered.
437
-
380
+ // Validate that the device can be registered.
438
381
  return this.canRegister().then(function () {
439
382
  // Validate if the device is already registered and refresh instead.
440
383
  if (_this2.registered) {
441
384
  _this2.logger.info('device: device already registered, refreshing');
442
-
443
385
  return _this2.refresh();
444
- } // Merge body configurations, overriding defaults.
445
-
446
-
447
- var body = _objectSpread(_objectSpread({}, _this2.config.defaults.body ? _this2.config.defaults.body : {}), _this2.config.body ? _this2.config.body : {}); // Merge header configurations, overriding defaults.
448
-
386
+ }
449
387
 
450
- var headers = _objectSpread(_objectSpread({}, _this2.config.defaults.headers ? _this2.config.defaults.headers : {}), _this2.config.headers ? _this2.config.headers : {}); // Append a ttl value if the device is marked as ephemeral
388
+ // Merge body configurations, overriding defaults.
389
+ var body = _objectSpread(_objectSpread({}, _this2.config.defaults.body ? _this2.config.defaults.body : {}), _this2.config.body ? _this2.config.body : {});
451
390
 
391
+ // Merge header configurations, overriding defaults.
392
+ var headers = _objectSpread(_objectSpread({}, _this2.config.defaults.headers ? _this2.config.defaults.headers : {}), _this2.config.headers ? _this2.config.headers : {});
452
393
 
394
+ // Append a ttl value if the device is marked as ephemeral
453
395
  if (_this2.config.ephemeral) {
454
396
  body.ttl = _this2.config.ephemeralDeviceTTL;
455
- } // This will be replaced by a `create()` method.
456
-
397
+ }
398
+ _this2.webex.internal.newMetrics.submitInternalEvent({
399
+ name: 'internal.register.device.request'
400
+ });
457
401
 
402
+ // This will be replaced by a `create()` method.
458
403
  return _this2.request({
459
404
  method: 'POST',
460
405
  service: 'wdm',
461
406
  resource: 'devices',
462
407
  body: body,
463
408
  headers: headers
409
+ }).catch(function (error) {
410
+ _this2.webex.internal.newMetrics.submitInternalEvent({
411
+ name: 'internal.register.device.response'
412
+ });
413
+ throw error;
464
414
  }).then(function (response) {
415
+ // Do not add any processing of response above this as that will affect timestamp
416
+ _this2.webex.internal.newMetrics.submitInternalEvent({
417
+ name: 'internal.register.device.response'
418
+ });
465
419
  _this2.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_SUCCESSFUL);
466
-
467
420
  return _this2.processRegistrationSuccess(response);
468
421
  }).catch(function (error) {
469
422
  _this2.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_WDM_REGISTRATION_FAILED, {
@@ -471,21 +424,17 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
471
424
  error: error
472
425
  }
473
426
  });
474
-
475
427
  throw error;
476
428
  });
477
429
  });
478
430
  },
479
431
  unregister: function unregister() {
480
432
  var _this3 = this;
481
-
482
433
  this.logger.info('device: unregistering');
483
-
484
434
  if (!this.registered) {
485
435
  this.logger.warn('device: not registered');
486
436
  return _promise.default.resolve();
487
437
  }
488
-
489
438
  return this.request({
490
439
  uri: this.url,
491
440
  method: 'DELETE'
@@ -493,10 +442,8 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
493
442
  return _this3.clear();
494
443
  });
495
444
  },
496
-
497
445
  /* eslint-enable require-jsdoc */
498
446
  // Helper method members
499
-
500
447
  /**
501
448
  * Determine if registration methods can be performed. This method utilizes
502
449
  * the `services` plugin to confirm if the appropriate service urls are
@@ -505,17 +452,19 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
505
452
  * @returns {Promise<void, Error>}
506
453
  */
507
454
  canRegister: function canRegister() {
508
- this.logger.info('device: validating if registration can occur'); // Destructure the services plugin for ease of reference.
455
+ this.logger.info('device: validating if registration can occur');
509
456
 
510
- var services = this.webex.internal.services; // Wait for the postauth catalog to populate.
457
+ // Destructure the services plugin for ease of reference.
458
+ var services = this.webex.internal.services;
511
459
 
460
+ // Wait for the postauth catalog to populate.
512
461
  return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(function () {
513
- return (// Validate that the service exists after waiting for the catalog.
514
- services.get('wdm') ? _promise.default.resolve() : _promise.default.reject(new Error(['device: cannot register,', '\'wdm\' service is not available from the postauth catalog'].join(' ')))
462
+ return (
463
+ // Validate that the service exists after waiting for the catalog.
464
+ services.get('wdm') ? _promise.default.resolve() : _promise.default.reject(new Error(['device: cannot register,', "'wdm' service is not available from the postauth catalog"].join(' ')))
515
465
  );
516
466
  });
517
467
  },
518
-
519
468
  /**
520
469
  * Check if the device can currently reach the inactivity check url.
521
470
  *
@@ -523,27 +472,28 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
523
472
  */
524
473
  checkNetworkReachability: function checkNetworkReachability() {
525
474
  var _this4 = this;
475
+ this.logger.info('device: checking network reachability');
526
476
 
527
- this.logger.info('device: checking network reachability'); // Validate if the device has been checked and reset the logout timer.
528
-
477
+ // Validate if the device has been checked and reset the logout timer.
529
478
  if (this.isReachabilityChecked) {
530
479
  return _promise.default.resolve(this.resetLogoutTimer());
531
480
  }
481
+ this.isReachabilityChecked = true;
532
482
 
533
- this.isReachabilityChecked = true; // Validate if the device has a intranet checking url.
534
-
483
+ // Validate if the device has a intranet checking url.
535
484
  if (!this.intranetInactivityCheckUrl) {
536
485
  this.isInNetwork = false;
537
486
  return _promise.default.resolve(this.resetLogoutTimer());
538
- } // Clear unnecessary headers for reachability request.
539
-
487
+ }
540
488
 
489
+ // Clear unnecessary headers for reachability request.
541
490
  var headers = {
542
491
  'cisco-no-http-redirect': null,
543
492
  'spark-user-agent': null,
544
493
  trackingid: null
545
- }; // Send the network reachability request.
494
+ };
546
495
 
496
+ // Send the network reachability request.
547
497
  return this.request({
548
498
  headers: headers,
549
499
  method: 'GET',
@@ -553,14 +503,11 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
553
503
  return _promise.default.resolve(_this4.resetLogoutTimer());
554
504
  }).catch(function () {
555
505
  _this4.logger.info('device: did not reach ping endpoint');
556
-
557
506
  _this4.logger.info('device: triggering off-network timer');
558
-
559
507
  _this4.isInNetwork = false;
560
508
  return _promise.default.resolve(_this4.resetLogoutTimer());
561
509
  });
562
510
  },
563
-
564
511
  /**
565
512
  * Clears the registration ttl value if available.
566
513
  *
@@ -568,15 +515,14 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
568
515
  * @returns {void}
569
516
  */
570
517
  clear: function clear() {
571
- this.logger.info('device: clearing registered device'); // Prototype the extended class in order to preserve the parent member.
518
+ this.logger.info('device: clearing registered device');
572
519
 
520
+ // Prototype the extended class in order to preserve the parent member.
573
521
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
574
522
  args[_key] = arguments[_key];
575
523
  }
576
-
577
524
  (0, _apply.default)(_webexCore.WebexPlugin.prototype.clear, this, args);
578
525
  },
579
-
580
526
  /**
581
527
  * Get the current websocket url with the appropriate priority host.
582
528
  *
@@ -585,37 +531,36 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
585
531
  */
586
532
  getWebSocketUrl: function getWebSocketUrl() {
587
533
  var _this5 = this;
588
-
589
534
  var wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
590
- this.logger.info('device: getting the current websocket url'); // Destructure the services plugin for ease of reference.
535
+ this.logger.info('device: getting the current websocket url');
591
536
 
592
- var services = this.webex.internal.services; // Validate if the method should wait for registration.
537
+ // Destructure the services plugin for ease of reference.
538
+ var services = this.webex.internal.services;
593
539
 
540
+ // Validate if the method should wait for registration.
594
541
  if (wait) {
595
542
  return this.waitForRegistration().then(function () {
596
543
  return services.convertUrlToPriorityHostUrl(_this5.webSocketUrl);
597
544
  }).catch(function (error) {
598
545
  _this5.logger.warn(error.message);
599
-
600
546
  return _promise.default.reject(new Error('device: failed to get the current websocket url'));
601
547
  });
602
- } // Validate if the device is registered.
603
-
548
+ }
604
549
 
550
+ // Validate if the device is registered.
605
551
  if (!this.registered) {
606
552
  return _promise.default.reject(new Error('device: cannot get websocket url, device is not registered'));
607
- } // Attempt to collect the priority-host-mapped web socket URL.
608
-
553
+ }
609
554
 
610
- var wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl); // Validate that the url was collected.
555
+ // Attempt to collect the priority-host-mapped web socket URL.
556
+ var wsUrl = services.convertUrlToPriorityHostUrl(this.webSocketUrl);
611
557
 
558
+ // Validate that the url was collected.
612
559
  if (wsUrl) {
613
560
  return _promise.default.resolve(wsUrl);
614
561
  }
615
-
616
562
  return _promise.default.reject(new Error('device: failed to get the current websocket url'));
617
563
  },
618
-
619
564
  /**
620
565
  * Process a successful device registration.
621
566
  *
@@ -624,46 +569,47 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
624
569
  */
625
570
  processRegistrationSuccess: function processRegistrationSuccess(response) {
626
571
  var _this6 = this;
572
+ this.logger.info('device: received registration payload');
627
573
 
628
- this.logger.info('device: received registration payload'); // Clone the response body for service cleaning.
629
-
630
- var body = _objectSpread({}, response.body); // Clean service data.
631
-
574
+ // Clone the response body for service cleaning.
575
+ var body = _objectSpread({}, response.body);
632
576
 
577
+ // Clean service data.
633
578
  delete body.services;
634
579
  delete body.serviceHostMap;
635
- var etag = response.headers.etag;
636
-
637
- if (this.etag && this.etag === etag) {
580
+ var _ref = response.headers || {},
581
+ etag = _ref.etag;
582
+ if (this.etag && etag && this.etag === etag) {
638
583
  // If current etag matches the previous one and we have sent
639
584
  // If-None-Match header the developer and entitlement feature
640
585
  // toggles will not be returned
641
586
  var features = body.features;
642
- delete body.features; // When using the etag feature cache, user and entitlement features are still returned
643
-
587
+ delete body.features;
588
+ // When using the etag feature cache, user and entitlement features are still returned
644
589
  this.features.user.reset(features.user);
645
590
  this.features.entitlement.reset(features.entitlement);
646
- } // Assign the recieved DTO from **WDM** to this device.
647
-
591
+ }
648
592
 
649
- this.set(body); // Assign the new etag to this device.
593
+ // Assign the recieved DTO from **WDM** to this device.
594
+ this.set(body);
650
595
 
596
+ // Assign the new etag to this device.
651
597
  this.set({
652
598
  etag: etag
653
- }); // Validate if device is ephemeral and setup refresh timer.
599
+ });
654
600
 
601
+ // Validate if device is ephemeral and setup refresh timer.
655
602
  if (this.config.ephemeral) {
656
603
  this.logger.info('device: enqueuing device refresh');
657
604
  var delay = (this.config.ephemeralDeviceTTL / 2 + 60) * 1000;
658
605
  this.refreshTimer = (0, _commonTimers.safeSetTimeout)(function () {
659
606
  return _this6.refresh();
660
607
  }, delay);
661
- } // Emit the registration:success event.
662
-
608
+ }
663
609
 
610
+ // Emit the registration:success event.
664
611
  this.trigger(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, this);
665
612
  },
666
-
667
613
  /**
668
614
  * Reset the current local logout timer for the registered device if
669
615
  * registered.
@@ -671,15 +617,19 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
671
617
  * @returns {void}
672
618
  */
673
619
  resetLogoutTimer: function resetLogoutTimer() {
674
- this.logger.info('device: resetting logout timer'); // Clear current logout timer.
620
+ this.logger.info('device: resetting logout timer');
675
621
 
676
- clearTimeout(this.logoutTimer); // Remove last activity date event listener.
622
+ // Clear current logout timer.
623
+ clearTimeout(this.logoutTimer);
677
624
 
678
- this.off('change:lastUserActivityDate'); // Remove the logout timer.
625
+ // Remove last activity date event listener.
626
+ this.off('change:lastUserActivityDate');
679
627
 
680
- this.unset('logoutTimer'); // Validate if the device is currently in a meeting and is configured to
681
- // required inactivity enforcement.
628
+ // Remove the logout timer.
629
+ this.unset('logoutTimer');
682
630
 
631
+ // Validate if the device is currently in a meeting and is configured to
632
+ // required inactivity enforcement.
683
633
  if (!this.isInMeeting && this.config.enableInactivityEnforcement && this.isReachabilityChecked) {
684
634
  if (this.isInNetwork) {
685
635
  this.setLogoutTimer(this.inNetworkInactivityDuration);
@@ -688,7 +638,6 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
688
638
  }
689
639
  }
690
640
  },
691
-
692
641
  /**
693
642
  * Set the value of the logout timer for the current registered device.
694
643
  *
@@ -697,23 +646,21 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
697
646
  */
698
647
  setLogoutTimer: function setLogoutTimer(duration) {
699
648
  var _this7 = this;
700
-
701
649
  this.logger.info('device: setting logout timer');
702
-
703
650
  if (!duration || duration <= 0) {
704
651
  return;
705
- } // Setup user activity date event listener.
706
-
652
+ }
707
653
 
654
+ // Setup user activity date event listener.
708
655
  this.on('change:lastUserActivityDate', function () {
709
656
  _this7.resetLogoutTimer();
710
- }); // Initialize a new timer.
657
+ });
711
658
 
659
+ // Initialize a new timer.
712
660
  this.logoutTimer = (0, _commonTimers.safeSetTimeout)(function () {
713
661
  _this7.webex.logout();
714
662
  }, duration * 1000);
715
663
  },
716
-
717
664
  /**
718
665
  * Wait for the device to be registered.
719
666
  *
@@ -722,18 +669,15 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
722
669
  */
723
670
  waitForRegistration: function waitForRegistration() {
724
671
  var _this8 = this;
725
-
726
672
  var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
727
673
  this.logger.info('device: waiting for registration');
728
674
  return new _promise.default(function (resolve, reject) {
729
675
  if (_this8.registered) {
730
676
  resolve();
731
677
  }
732
-
733
678
  var timeoutTimer = (0, _commonTimers.safeSetTimeout)(function () {
734
679
  return reject(new Error('device: timeout occured while waiting for registration'));
735
680
  }, timeout * 1000);
736
-
737
681
  _this8.once(_constants.DEVICE_EVENT_REGISTRATION_SUCCESS, function () {
738
682
  clearTimeout(timeoutTimer);
739
683
  resolve();
@@ -745,56 +689,54 @@ var Device = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)(
745
689
  },
746
690
  initialize: function initialize() {
747
691
  var _this9 = this;
748
-
749
692
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
750
693
  args[_key2] = arguments[_key2];
751
694
  }
752
-
753
695
  // Prototype the extended class in order to preserve the parent member.
754
- (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args); // Initialize feature events and listeners.
696
+ (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);
755
697
 
698
+ // Initialize feature events and listeners.
756
699
  _constants.FEATURE_COLLECTION_NAMES.forEach(function (collectionName) {
757
700
  _this9.features.on("change:".concat(collectionName), function (model, value, options) {
758
701
  _this9.trigger('change', _this9, options);
759
-
760
702
  _this9.trigger('change:features', _this9, _this9.features, options);
761
703
  });
762
- }); // Initialize network reachability checking event for url change.
763
-
704
+ });
764
705
 
706
+ // Initialize network reachability checking event for url change.
765
707
  this.on('change:intranetInactivityCheckUrl', function () {
766
708
  _this9.checkNetworkReachability();
767
- }); // Initialize network reachability checking event for duration change.
709
+ });
768
710
 
711
+ // Initialize network reachability checking event for duration change.
769
712
  this.on('change:intranetInactivityDuration', function () {
770
713
  _this9.checkNetworkReachability();
771
- }); // Initialize network reachability checking event for duration change.
714
+ });
772
715
 
716
+ // Initialize network reachability checking event for duration change.
773
717
  this.on('change:inNetworkInactivityDuration', function () {
774
718
  _this9.checkNetworkReachability();
775
- }); // Initialize listener for activity checking.
719
+ });
776
720
 
721
+ // Initialize listener for activity checking.
777
722
  this.listenTo(this.webex, 'user-activity', function () {
778
723
  _this9.lastUserActivityDate = (0, _now.default)();
779
- }); // Initialize listener for meeting started event.
724
+ });
780
725
 
726
+ // Initialize listener for meeting started event.
781
727
  this.listenTo(this.webex, 'meeting started', function () {
782
728
  _this9.isInMeeting = true;
783
-
784
729
  _this9.resetLogoutTimer();
785
- }); // Initialize listener for meeting ended event.
730
+ });
786
731
 
732
+ // Initialize listener for meeting ended event.
787
733
  this.listenTo(this.webex, 'meeting ended', function () {
788
734
  _this9.isInMeeting = false;
789
-
790
735
  _this9.resetLogoutTimer();
791
736
  });
792
- }
793
- /* eslint-enable require-jsdoc */
794
- ,
795
- version: "3.0.0-beta.4"
737
+ } /* eslint-enable require-jsdoc */,
738
+ version: "3.0.0-beta.400"
796
739
  }, ((0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight, _dec], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "register", [_common.oneFlight, _dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "register"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "unregister", [_common.oneFlight, _dec3], (0, _getOwnPropertyDescriptor.default)(_obj, "unregister"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "markUrlFailedAndGetNew", [_dec4], (0, _getOwnPropertyDescriptor.default)(_obj, "markUrlFailedAndGetNew"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "initialize", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, "initialize"), _obj)), _obj)));
797
-
798
740
  var _default = Device;
799
741
  exports.default = _default;
800
742
  //# sourceMappingURL=device.js.map