@webex/internal-plugin-device 3.0.0-beta.3 → 3.0.0-beta.30
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/README.md +10 -6
- package/dist/config.js +0 -8
- package/dist/config.js.map +1 -1
- package/dist/constants.js +2 -3
- package/dist/constants.js.map +1 -1
- package/dist/device.js +91 -169
- package/dist/device.js.map +1 -1
- package/dist/features/feature-collection.js +1 -8
- package/dist/features/feature-collection.js.map +1 -1
- package/dist/features/feature-model.js +15 -42
- package/dist/features/feature-model.js.map +1 -1
- package/dist/features/features-model.js +9 -21
- package/dist/features/features-model.js.map +1 -1
- package/dist/features/index.js +0 -8
- package/dist/features/index.js.map +1 -1
- package/dist/index.js +2 -24
- package/dist/index.js.map +1 -1
- package/dist/interceptors/device-url.js +12 -33
- package/dist/interceptors/device-url.js.map +1 -1
- package/dist/metrics.js +0 -2
- package/dist/metrics.js.map +1 -1
- package/package.json +10 -10
- package/src/config.js +8 -9
- package/src/constants.js +3 -5
- package/src/device.js +140 -144
- package/src/features/feature-collection.js +1 -1
- package/src/features/feature-model.js +5 -11
- package/src/features/features-model.js +3 -9
- package/src/features/index.js +1 -5
- package/src/index.js +3 -11
- package/src/interceptors/device-url.js +5 -7
- package/src/metrics.js +1 -2
- package/test/integration/spec/device.js +210 -239
- package/test/integration/spec/webex.js +9 -9
- package/test/unit/spec/device.js +44 -53
- package/test/unit/spec/features/feature-collection.js +2 -2
- package/test/unit/spec/features/feature-model.js +23 -39
- package/test/unit/spec/features/features-model.js +4 -12
- package/test/unit/spec/interceptors/device-url.js +69 -109
- package/test/unit/spec/wdm-dto.json +5 -13
package/src/device.js
CHANGED
|
@@ -4,10 +4,7 @@ import {persist, waitForValue, WebexPlugin} from '@webex/webex-core';
|
|
|
4
4
|
import {safeSetTimeout} from '@webex/common-timers';
|
|
5
5
|
|
|
6
6
|
import METRICS from './metrics';
|
|
7
|
-
import {
|
|
8
|
-
FEATURE_COLLECTION_NAMES,
|
|
9
|
-
DEVICE_EVENT_REGISTRATION_SUCCESS
|
|
10
|
-
} from './constants';
|
|
7
|
+
import {FEATURE_COLLECTION_NAMES, DEVICE_EVENT_REGISTRATION_SUCCESS} from './constants';
|
|
11
8
|
import FeaturesModel from './features/features-model';
|
|
12
9
|
|
|
13
10
|
/**
|
|
@@ -20,7 +17,6 @@ function decider() {
|
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
const Device = WebexPlugin.extend({
|
|
23
|
-
|
|
24
20
|
// Ampersand property members.
|
|
25
21
|
|
|
26
22
|
namespace: 'Device',
|
|
@@ -37,7 +33,7 @@ const Device = WebexPlugin.extend({
|
|
|
37
33
|
*
|
|
38
34
|
* @type {FeaturesModel}
|
|
39
35
|
*/
|
|
40
|
-
features: FeaturesModel
|
|
36
|
+
features: FeaturesModel,
|
|
41
37
|
},
|
|
42
38
|
|
|
43
39
|
/**
|
|
@@ -121,7 +117,7 @@ const Device = WebexPlugin.extend({
|
|
|
121
117
|
*
|
|
122
118
|
* @returns {Array<string>}
|
|
123
119
|
*/
|
|
124
|
-
ecmSupportedStorageProviders: ['array', false, (
|
|
120
|
+
ecmSupportedStorageProviders: ['array', false, () => []],
|
|
125
121
|
|
|
126
122
|
/**
|
|
127
123
|
* This property stores the modification time value retrieved from the
|
|
@@ -242,7 +238,7 @@ const Device = WebexPlugin.extend({
|
|
|
242
238
|
*
|
|
243
239
|
* @type {'ALLOW' | 'BLOCK'}
|
|
244
240
|
*/
|
|
245
|
-
whiteboardFileShareControl: 'string'
|
|
241
|
+
whiteboardFileShareControl: 'string',
|
|
246
242
|
},
|
|
247
243
|
|
|
248
244
|
/**
|
|
@@ -268,9 +264,9 @@ const Device = WebexPlugin.extend({
|
|
|
268
264
|
* @returns {boolean}
|
|
269
265
|
*/
|
|
270
266
|
fn() {
|
|
271
|
-
return !!
|
|
272
|
-
}
|
|
273
|
-
}
|
|
267
|
+
return !!this.url;
|
|
268
|
+
},
|
|
269
|
+
},
|
|
274
270
|
},
|
|
275
271
|
|
|
276
272
|
/**
|
|
@@ -318,7 +314,7 @@ const Device = WebexPlugin.extend({
|
|
|
318
314
|
*
|
|
319
315
|
* @type {boolean}
|
|
320
316
|
*/
|
|
321
|
-
isInNetwork: 'boolean'
|
|
317
|
+
isInNetwork: 'boolean',
|
|
322
318
|
},
|
|
323
319
|
|
|
324
320
|
// Event method members.
|
|
@@ -355,61 +351,60 @@ const Device = WebexPlugin.extend({
|
|
|
355
351
|
this.logger.info('device: refreshing');
|
|
356
352
|
|
|
357
353
|
// Validate that the device can be registered.
|
|
358
|
-
return this.canRegister()
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
this.logger.info('device: device not registered, registering');
|
|
363
|
-
|
|
364
|
-
return this.register();
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// Merge body configurations, overriding defaults.
|
|
368
|
-
const body = {
|
|
369
|
-
...(this.serialize()),
|
|
370
|
-
...(this.config.body ? this.config.body : {})
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
// Remove unneeded properties from the body object.
|
|
374
|
-
delete body.features;
|
|
375
|
-
delete body.mediaCluster;
|
|
376
|
-
delete body.etag;
|
|
377
|
-
|
|
378
|
-
// Append a ttl value if the device is marked as ephemeral.
|
|
379
|
-
if (this.config.ephemeral) {
|
|
380
|
-
body.ttl = this.config.ephemeralDeviceTTL;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// Merge header configurations, overriding defaults.
|
|
384
|
-
const headers = {
|
|
385
|
-
...(this.config.defaults.headers ? this.config.defaults.headers : {}),
|
|
386
|
-
...(this.config.headers ? this.config.headers : {}),
|
|
387
|
-
// If etag is sent, WDM will not send developer feature toggles unless they have changed
|
|
388
|
-
...(this.etag ? {'If-None-Match': this.etag} : {})
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
return this.request({
|
|
392
|
-
method: 'PUT',
|
|
393
|
-
uri: this.url,
|
|
394
|
-
body,
|
|
395
|
-
headers
|
|
396
|
-
})
|
|
397
|
-
.then((response) => this.processRegistrationSuccess(response))
|
|
398
|
-
.catch((reason) => {
|
|
399
|
-
// Handle a 404 error, which indicates that the device is no longer
|
|
400
|
-
// valid and needs to be registered as a new device.
|
|
401
|
-
if (reason.statusCode === 404) {
|
|
402
|
-
this.logger.info('device: refresh failed, device is not valid');
|
|
403
|
-
this.logger.info('device: attempting to register a new device');
|
|
354
|
+
return this.canRegister().then(() => {
|
|
355
|
+
// Validate if the device is not registered and register instead.
|
|
356
|
+
if (!this.registered) {
|
|
357
|
+
this.logger.info('device: device not registered, registering');
|
|
404
358
|
|
|
405
|
-
|
|
359
|
+
return this.register();
|
|
360
|
+
}
|
|
406
361
|
|
|
407
|
-
|
|
408
|
-
|
|
362
|
+
// Merge body configurations, overriding defaults.
|
|
363
|
+
const body = {
|
|
364
|
+
...this.serialize(),
|
|
365
|
+
...(this.config.body ? this.config.body : {}),
|
|
366
|
+
};
|
|
409
367
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
368
|
+
// Remove unneeded properties from the body object.
|
|
369
|
+
delete body.features;
|
|
370
|
+
delete body.mediaCluster;
|
|
371
|
+
delete body.etag;
|
|
372
|
+
|
|
373
|
+
// Append a ttl value if the device is marked as ephemeral.
|
|
374
|
+
if (this.config.ephemeral) {
|
|
375
|
+
body.ttl = this.config.ephemeralDeviceTTL;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Merge header configurations, overriding defaults.
|
|
379
|
+
const headers = {
|
|
380
|
+
...(this.config.defaults.headers ? this.config.defaults.headers : {}),
|
|
381
|
+
...(this.config.headers ? this.config.headers : {}),
|
|
382
|
+
// If etag is sent, WDM will not send developer feature toggles unless they have changed
|
|
383
|
+
...(this.etag ? {'If-None-Match': this.etag} : {}),
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
return this.request({
|
|
387
|
+
method: 'PUT',
|
|
388
|
+
uri: this.url,
|
|
389
|
+
body,
|
|
390
|
+
headers,
|
|
391
|
+
})
|
|
392
|
+
.then((response) => this.processRegistrationSuccess(response))
|
|
393
|
+
.catch((reason) => {
|
|
394
|
+
// Handle a 404 error, which indicates that the device is no longer
|
|
395
|
+
// valid and needs to be registered as a new device.
|
|
396
|
+
if (reason.statusCode === 404) {
|
|
397
|
+
this.logger.info('device: refresh failed, device is not valid');
|
|
398
|
+
this.logger.info('device: attempting to register a new device');
|
|
399
|
+
|
|
400
|
+
this.clear();
|
|
401
|
+
|
|
402
|
+
return this.register();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return Promise.reject(reason);
|
|
406
|
+
});
|
|
407
|
+
});
|
|
413
408
|
},
|
|
414
409
|
|
|
415
410
|
/**
|
|
@@ -425,52 +420,53 @@ const Device = WebexPlugin.extend({
|
|
|
425
420
|
this.logger.info('device: registering');
|
|
426
421
|
|
|
427
422
|
// Validate that the device can be registered.
|
|
428
|
-
return this.canRegister()
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
423
|
+
return this.canRegister().then(() => {
|
|
424
|
+
// Validate if the device is already registered and refresh instead.
|
|
425
|
+
if (this.registered) {
|
|
426
|
+
this.logger.info('device: device already registered, refreshing');
|
|
427
|
+
|
|
428
|
+
return this.refresh();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Merge body configurations, overriding defaults.
|
|
432
|
+
const body = {
|
|
433
|
+
...(this.config.defaults.body ? this.config.defaults.body : {}),
|
|
434
|
+
...(this.config.body ? this.config.body : {}),
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// Merge header configurations, overriding defaults.
|
|
438
|
+
const headers = {
|
|
439
|
+
...(this.config.defaults.headers ? this.config.defaults.headers : {}),
|
|
440
|
+
...(this.config.headers ? this.config.headers : {}),
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// Append a ttl value if the device is marked as ephemeral
|
|
444
|
+
if (this.config.ephemeral) {
|
|
445
|
+
body.ttl = this.config.ephemeralDeviceTTL;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// This will be replaced by a `create()` method.
|
|
449
|
+
return this.request({
|
|
450
|
+
method: 'POST',
|
|
451
|
+
service: 'wdm',
|
|
452
|
+
resource: 'devices',
|
|
453
|
+
body,
|
|
454
|
+
headers,
|
|
455
|
+
})
|
|
456
|
+
.then((response) => {
|
|
457
|
+
this.webex.internal.metrics.submitClientMetrics(
|
|
458
|
+
METRICS.JS_SDK_WDM_REGISTRATION_SUCCESSFUL
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
return this.processRegistrationSuccess(response);
|
|
461
462
|
})
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return this.processRegistrationSuccess(response);
|
|
466
|
-
})
|
|
467
|
-
.catch((error) => {
|
|
468
|
-
this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_WDM_REGISTRATION_FAILED, {
|
|
469
|
-
fields: {error}
|
|
470
|
-
});
|
|
471
|
-
throw error;
|
|
463
|
+
.catch((error) => {
|
|
464
|
+
this.webex.internal.metrics.submitClientMetrics(METRICS.JS_SDK_WDM_REGISTRATION_FAILED, {
|
|
465
|
+
fields: {error},
|
|
472
466
|
});
|
|
473
|
-
|
|
467
|
+
throw error;
|
|
468
|
+
});
|
|
469
|
+
});
|
|
474
470
|
},
|
|
475
471
|
|
|
476
472
|
/**
|
|
@@ -493,9 +489,8 @@ const Device = WebexPlugin.extend({
|
|
|
493
489
|
|
|
494
490
|
return this.request({
|
|
495
491
|
uri: this.url,
|
|
496
|
-
method: 'DELETE'
|
|
497
|
-
})
|
|
498
|
-
.then(() => this.clear());
|
|
492
|
+
method: 'DELETE',
|
|
493
|
+
}).then(() => this.clear());
|
|
499
494
|
},
|
|
500
495
|
/* eslint-enable require-jsdoc */
|
|
501
496
|
|
|
@@ -515,19 +510,19 @@ const Device = WebexPlugin.extend({
|
|
|
515
510
|
const {services} = this.webex.internal;
|
|
516
511
|
|
|
517
512
|
// Wait for the postauth catalog to populate.
|
|
518
|
-
return services.waitForCatalog(
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
513
|
+
return services.waitForCatalog('postauth', this.config.canRegisterWaitDuration).then(() =>
|
|
514
|
+
// Validate that the service exists after waiting for the catalog.
|
|
515
|
+
services.get('wdm')
|
|
516
|
+
? Promise.resolve()
|
|
517
|
+
: Promise.reject(
|
|
518
|
+
new Error(
|
|
519
|
+
[
|
|
520
|
+
'device: cannot register,',
|
|
521
|
+
"'wdm' service is not available from the postauth catalog",
|
|
522
|
+
].join(' ')
|
|
523
|
+
)
|
|
524
|
+
)
|
|
525
|
+
);
|
|
531
526
|
},
|
|
532
527
|
|
|
533
528
|
/**
|
|
@@ -556,14 +551,14 @@ const Device = WebexPlugin.extend({
|
|
|
556
551
|
const headers = {
|
|
557
552
|
'cisco-no-http-redirect': null,
|
|
558
553
|
'spark-user-agent': null,
|
|
559
|
-
trackingid: null
|
|
554
|
+
trackingid: null,
|
|
560
555
|
};
|
|
561
556
|
|
|
562
557
|
// Send the network reachability request.
|
|
563
558
|
return this.request({
|
|
564
559
|
headers,
|
|
565
560
|
method: 'GET',
|
|
566
|
-
uri: this.intranetInactivityCheckUrl
|
|
561
|
+
uri: this.intranetInactivityCheckUrl,
|
|
567
562
|
})
|
|
568
563
|
.then(() => {
|
|
569
564
|
this.isInNetwork = true;
|
|
@@ -612,17 +607,15 @@ const Device = WebexPlugin.extend({
|
|
|
612
607
|
.catch((error) => {
|
|
613
608
|
this.logger.warn(error.message);
|
|
614
609
|
|
|
615
|
-
return Promise.reject(new Error(
|
|
616
|
-
'device: failed to get the current websocket url'
|
|
617
|
-
));
|
|
610
|
+
return Promise.reject(new Error('device: failed to get the current websocket url'));
|
|
618
611
|
});
|
|
619
612
|
}
|
|
620
613
|
|
|
621
614
|
// Validate if the device is registered.
|
|
622
615
|
if (!this.registered) {
|
|
623
|
-
return Promise.reject(
|
|
624
|
-
'device: cannot get websocket url, device is not registered'
|
|
625
|
-
)
|
|
616
|
+
return Promise.reject(
|
|
617
|
+
new Error('device: cannot get websocket url, device is not registered')
|
|
618
|
+
);
|
|
626
619
|
}
|
|
627
620
|
|
|
628
621
|
// Attempt to collect the priority-host-mapped web socket URL.
|
|
@@ -633,9 +626,7 @@ const Device = WebexPlugin.extend({
|
|
|
633
626
|
return Promise.resolve(wsUrl);
|
|
634
627
|
}
|
|
635
628
|
|
|
636
|
-
return Promise.reject(new Error(
|
|
637
|
-
'device: failed to get the current websocket url'
|
|
638
|
-
));
|
|
629
|
+
return Promise.reject(new Error('device: failed to get the current websocket url'));
|
|
639
630
|
},
|
|
640
631
|
|
|
641
632
|
/**
|
|
@@ -707,12 +698,14 @@ const Device = WebexPlugin.extend({
|
|
|
707
698
|
|
|
708
699
|
// Validate if the device is currently in a meeting and is configured to
|
|
709
700
|
// required inactivity enforcement.
|
|
710
|
-
if (
|
|
711
|
-
this.
|
|
701
|
+
if (
|
|
702
|
+
!this.isInMeeting &&
|
|
703
|
+
this.config.enableInactivityEnforcement &&
|
|
704
|
+
this.isReachabilityChecked
|
|
705
|
+
) {
|
|
712
706
|
if (this.isInNetwork) {
|
|
713
707
|
this.setLogoutTimer(this.inNetworkInactivityDuration);
|
|
714
|
-
}
|
|
715
|
-
else {
|
|
708
|
+
} else {
|
|
716
709
|
this.setLogoutTimer(this.intranetInactivityDuration);
|
|
717
710
|
}
|
|
718
711
|
}
|
|
@@ -732,7 +725,9 @@ const Device = WebexPlugin.extend({
|
|
|
732
725
|
}
|
|
733
726
|
|
|
734
727
|
// Setup user activity date event listener.
|
|
735
|
-
this.on('change:lastUserActivityDate', () => {
|
|
728
|
+
this.on('change:lastUserActivityDate', () => {
|
|
729
|
+
this.resetLogoutTimer();
|
|
730
|
+
});
|
|
736
731
|
|
|
737
732
|
// Initialize a new timer.
|
|
738
733
|
this.logoutTimer = safeSetTimeout(() => {
|
|
@@ -754,9 +749,10 @@ const Device = WebexPlugin.extend({
|
|
|
754
749
|
resolve();
|
|
755
750
|
}
|
|
756
751
|
|
|
757
|
-
const timeoutTimer = safeSetTimeout(
|
|
758
|
-
new Error('device: timeout occured while waiting for registration')
|
|
759
|
-
|
|
752
|
+
const timeoutTimer = safeSetTimeout(
|
|
753
|
+
() => reject(new Error('device: timeout occured while waiting for registration')),
|
|
754
|
+
timeout * 1000
|
|
755
|
+
);
|
|
760
756
|
|
|
761
757
|
this.once(DEVICE_EVENT_REGISTRATION_SUCCESS, () => {
|
|
762
758
|
clearTimeout(timeoutTimer);
|
|
@@ -832,7 +828,7 @@ const Device = WebexPlugin.extend({
|
|
|
832
828
|
this.isInMeeting = false;
|
|
833
829
|
this.resetLogoutTimer();
|
|
834
830
|
});
|
|
835
|
-
}
|
|
831
|
+
},
|
|
836
832
|
/* eslint-enable require-jsdoc */
|
|
837
833
|
});
|
|
838
834
|
|
|
@@ -20,7 +20,6 @@ import {FEATURE_TYPES} from '../constants';
|
|
|
20
20
|
* **WDM** service upon registration.
|
|
21
21
|
*/
|
|
22
22
|
const FeatureModel = AmpState.extend({
|
|
23
|
-
|
|
24
23
|
idAttribute: 'key', // needed by Ampersand to determine unique item
|
|
25
24
|
|
|
26
25
|
// Ampersand property members.
|
|
@@ -67,7 +66,7 @@ const FeatureModel = AmpState.extend({
|
|
|
67
66
|
*
|
|
68
67
|
* @type {any}
|
|
69
68
|
*/
|
|
70
|
-
value: 'any'
|
|
69
|
+
value: 'any',
|
|
71
70
|
},
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -82,11 +81,7 @@ const FeatureModel = AmpState.extend({
|
|
|
82
81
|
constructor(attrs, options = {}) {
|
|
83
82
|
defaults(options, {parse: true});
|
|
84
83
|
|
|
85
|
-
return Reflect.apply(
|
|
86
|
-
AmpState.prototype.constructor,
|
|
87
|
-
this,
|
|
88
|
-
[attrs, options]
|
|
89
|
-
);
|
|
84
|
+
return Reflect.apply(AmpState.prototype.constructor, this, [attrs, options]);
|
|
90
85
|
},
|
|
91
86
|
|
|
92
87
|
// Ampsersand method members.
|
|
@@ -150,7 +145,7 @@ const FeatureModel = AmpState.extend({
|
|
|
150
145
|
// Validate that the overloaded class member returned an object with the
|
|
151
146
|
// `lastModified` key-value pair and instance it as an ISO string.
|
|
152
147
|
if (attrs.lastModified) {
|
|
153
|
-
attrs.lastModified =
|
|
148
|
+
attrs.lastModified = new Date(attrs.lastModified).toISOString();
|
|
154
149
|
}
|
|
155
150
|
|
|
156
151
|
return attrs;
|
|
@@ -179,8 +174,7 @@ const FeatureModel = AmpState.extend({
|
|
|
179
174
|
if (isObject(key) || key === null) {
|
|
180
175
|
attrs = key;
|
|
181
176
|
optns = value;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
177
|
+
} else {
|
|
184
178
|
attrs = {};
|
|
185
179
|
attrs[key] = value;
|
|
186
180
|
optns = options;
|
|
@@ -189,7 +183,7 @@ const FeatureModel = AmpState.extend({
|
|
|
189
183
|
attrs = this.parse(attrs, optns);
|
|
190
184
|
|
|
191
185
|
return Reflect.apply(AmpState.prototype.set, this, [attrs, optns]);
|
|
192
|
-
}
|
|
186
|
+
},
|
|
193
187
|
});
|
|
194
188
|
|
|
195
189
|
export default FeatureModel;
|
|
@@ -14,7 +14,6 @@ import FeatureCollection from './feature-collection';
|
|
|
14
14
|
* organize the data retrieved from the **wdm** service on device registration.
|
|
15
15
|
*/
|
|
16
16
|
const FeaturesModel = AmpState.extend({
|
|
17
|
-
|
|
18
17
|
// Ampersand property members.
|
|
19
18
|
|
|
20
19
|
collections: {
|
|
@@ -37,7 +36,7 @@ const FeaturesModel = AmpState.extend({
|
|
|
37
36
|
*
|
|
38
37
|
* @type {FeatureCollection}
|
|
39
38
|
*/
|
|
40
|
-
user: FeatureCollection
|
|
39
|
+
user: FeatureCollection,
|
|
41
40
|
},
|
|
42
41
|
|
|
43
42
|
// Helper method members.
|
|
@@ -87,16 +86,11 @@ const FeaturesModel = AmpState.extend({
|
|
|
87
86
|
eventNames.forEach((eventName) => {
|
|
88
87
|
FEATURE_COLLECTION_NAMES.forEach((collectionName) => {
|
|
89
88
|
this[collectionName].on(eventName, (model, options) => {
|
|
90
|
-
this.trigger(
|
|
91
|
-
`change:${collectionName}`,
|
|
92
|
-
this,
|
|
93
|
-
this[collectionName],
|
|
94
|
-
options
|
|
95
|
-
);
|
|
89
|
+
this.trigger(`change:${collectionName}`, this, this[collectionName], options);
|
|
96
90
|
});
|
|
97
91
|
});
|
|
98
92
|
});
|
|
99
|
-
}
|
|
93
|
+
},
|
|
100
94
|
});
|
|
101
95
|
|
|
102
96
|
export default FeaturesModel;
|
package/src/features/index.js
CHANGED
|
@@ -2,8 +2,4 @@ import FeatureCollection from './feature-collection';
|
|
|
2
2
|
import FeatureModel from './feature-model';
|
|
3
3
|
import FeaturesModel from './features-model';
|
|
4
4
|
|
|
5
|
-
export {
|
|
6
|
-
FeatureCollection,
|
|
7
|
-
FeatureModel,
|
|
8
|
-
FeaturesModel
|
|
9
|
-
};
|
|
5
|
+
export {FeatureCollection, FeatureModel, FeaturesModel};
|
package/src/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import config from './config';
|
|
|
13
13
|
registerInternalPlugin('device', Device, {
|
|
14
14
|
config,
|
|
15
15
|
interceptors: {
|
|
16
|
-
DeviceUrlInterceptor: DeviceUrlInterceptor.create
|
|
16
|
+
DeviceUrlInterceptor: DeviceUrlInterceptor.create,
|
|
17
17
|
},
|
|
18
18
|
/**
|
|
19
19
|
* Unregister the device in the case that the webex instance has logged out.
|
|
@@ -22,16 +22,8 @@ registerInternalPlugin('device', Device, {
|
|
|
22
22
|
*/
|
|
23
23
|
onBeforeLogout() {
|
|
24
24
|
return this.unregister();
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
export {default} from './device';
|
|
29
|
-
export {
|
|
30
|
-
config,
|
|
31
|
-
constants,
|
|
32
|
-
DeviceUrlInterceptor,
|
|
33
|
-
FeatureCollection,
|
|
34
|
-
FeatureModel,
|
|
35
|
-
FeaturesModel
|
|
36
|
-
};
|
|
37
|
-
|
|
29
|
+
export {config, constants, DeviceUrlInterceptor, FeatureCollection, FeatureModel, FeaturesModel};
|
|
@@ -8,8 +8,8 @@ import {set} from 'lodash';
|
|
|
8
8
|
import {CISCO_DEVICE_URL} from '../constants';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Adds 'cisco-device-url' header, as appropriate, to requests
|
|
12
|
+
*/
|
|
13
13
|
export default class DeviceUrlInterceptor extends Interceptor {
|
|
14
14
|
/**
|
|
15
15
|
* @returns {DeviceUrlInterceptor}
|
|
@@ -29,15 +29,13 @@ export default class DeviceUrlInterceptor extends Interceptor {
|
|
|
29
29
|
const {device, services} = this.webex.internal;
|
|
30
30
|
|
|
31
31
|
// Check if header is already set before moving forward
|
|
32
|
-
if (
|
|
33
|
-
!device.url ||
|
|
34
|
-
(headers && CISCO_DEVICE_URL in headers && !!headers[CISCO_DEVICE_URL])
|
|
35
|
-
) {
|
|
32
|
+
if (!device.url || (headers && CISCO_DEVICE_URL in headers && !!headers[CISCO_DEVICE_URL])) {
|
|
36
33
|
return Promise.resolve(options);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
// Wait for catalog and service to be defined.
|
|
40
|
-
return services
|
|
37
|
+
return services
|
|
38
|
+
.waitForService({service, url: uri})
|
|
41
39
|
.then((url) => {
|
|
42
40
|
// Grab the service name with the url returned from waitForService
|
|
43
41
|
const {name: serviceName} = services.getServiceFromUrl(url) || {};
|
package/src/metrics.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Metric to do with WDM registration
|
|
2
2
|
export default {
|
|
3
3
|
JS_SDK_WDM_REGISTRATION_SUCCESSFUL: 'JS_SDK_WDM_REGISTRATION_SUCCESSFUL',
|
|
4
|
-
JS_SDK_WDM_REGISTRATION_FAILED: 'JS_SDK_WDM_REGISTRATION_FAILED'
|
|
4
|
+
JS_SDK_WDM_REGISTRATION_FAILED: 'JS_SDK_WDM_REGISTRATION_FAILED',
|
|
5
5
|
};
|
|
6
|
-
|