@webex/internal-plugin-device 2.59.1 → 2.59.3-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/.eslintrc.js +6 -6
- package/README.md +80 -80
- package/babel.config.js +3 -3
- package/dist/config.js +27 -27
- package/dist/config.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/device.js +226 -226
- package/dist/device.js.map +1 -1
- package/dist/features/feature-collection.js +14 -14
- package/dist/features/feature-collection.js.map +1 -1
- package/dist/features/feature-model.js +73 -73
- package/dist/features/feature-model.js.map +1 -1
- package/dist/features/features-model.js +28 -28
- package/dist/features/features-model.js.map +1 -1
- package/dist/features/index.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/interceptors/device-url.js +8 -8
- package/dist/interceptors/device-url.js.map +1 -1
- package/dist/metrics.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +17 -16
- package/process +1 -1
- package/src/config.js +60 -60
- package/src/constants.js +23 -23
- package/src/device.js +835 -835
- package/src/features/feature-collection.js +30 -30
- package/src/features/feature-model.js +189 -189
- package/src/features/features-model.js +96 -96
- package/src/features/index.js +5 -5
- package/src/index.js +29 -29
- package/src/interceptors/device-url.js +61 -61
- package/src/metrics.js +5 -5
- package/test/integration/spec/device.js +904 -904
- package/test/integration/spec/webex.js +42 -42
- package/test/unit/spec/device.js +409 -409
- package/test/unit/spec/features/feature-collection.js +24 -24
- package/test/unit/spec/features/feature-model.js +255 -255
- package/test/unit/spec/features/features-model.js +97 -97
- package/test/unit/spec/interceptors/device-url.js +215 -215
- package/test/unit/spec/wdm-dto.json +104 -104
package/src/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// Internal dependencies.
|
|
2
|
-
// Need to import metrics plugin for the devices to send metrics on succes/failure registration
|
|
3
|
-
import '@webex/internal-plugin-metrics';
|
|
4
|
-
import {registerInternalPlugin} from '@webex/webex-core';
|
|
5
|
-
|
|
6
|
-
// Plugin dependencies.
|
|
7
|
-
import Device from './device';
|
|
8
|
-
import {FeatureCollection, FeatureModel, FeaturesModel} from './features/index';
|
|
9
|
-
import DeviceUrlInterceptor from './interceptors/device-url';
|
|
10
|
-
import * as constants from './constants';
|
|
11
|
-
import config from './config';
|
|
12
|
-
|
|
13
|
-
registerInternalPlugin('device', Device, {
|
|
14
|
-
config,
|
|
15
|
-
interceptors: {
|
|
16
|
-
DeviceUrlInterceptor: DeviceUrlInterceptor.create,
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* Unregister the device in the case that the webex instance has logged out.
|
|
20
|
-
*
|
|
21
|
-
* @returns {Promise<undefined>}
|
|
22
|
-
*/
|
|
23
|
-
onBeforeLogout() {
|
|
24
|
-
return this.unregister();
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export {default} from './device';
|
|
29
|
-
export {config, constants, DeviceUrlInterceptor, FeatureCollection, FeatureModel, FeaturesModel};
|
|
1
|
+
// Internal dependencies.
|
|
2
|
+
// Need to import metrics plugin for the devices to send metrics on succes/failure registration
|
|
3
|
+
import '@webex/internal-plugin-metrics';
|
|
4
|
+
import {registerInternalPlugin} from '@webex/webex-core';
|
|
5
|
+
|
|
6
|
+
// Plugin dependencies.
|
|
7
|
+
import Device from './device';
|
|
8
|
+
import {FeatureCollection, FeatureModel, FeaturesModel} from './features/index';
|
|
9
|
+
import DeviceUrlInterceptor from './interceptors/device-url';
|
|
10
|
+
import * as constants from './constants';
|
|
11
|
+
import config from './config';
|
|
12
|
+
|
|
13
|
+
registerInternalPlugin('device', Device, {
|
|
14
|
+
config,
|
|
15
|
+
interceptors: {
|
|
16
|
+
DeviceUrlInterceptor: DeviceUrlInterceptor.create,
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Unregister the device in the case that the webex instance has logged out.
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<undefined>}
|
|
22
|
+
*/
|
|
23
|
+
onBeforeLogout() {
|
|
24
|
+
return this.unregister();
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export {default} from './device';
|
|
29
|
+
export {config, constants, DeviceUrlInterceptor, FeatureCollection, FeatureModel, FeaturesModel};
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {Interceptor} from '@webex/http-core';
|
|
6
|
-
import {set} from 'lodash';
|
|
7
|
-
|
|
8
|
-
import {CISCO_DEVICE_URL} from '../constants';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Adds 'cisco-device-url' header, as appropriate, to requests
|
|
12
|
-
*/
|
|
13
|
-
export default class DeviceUrlInterceptor extends Interceptor {
|
|
14
|
-
/**
|
|
15
|
-
* @returns {DeviceUrlInterceptor}
|
|
16
|
-
*/
|
|
17
|
-
static create() {
|
|
18
|
-
/* eslint no-invalid-this: [0] */
|
|
19
|
-
return new DeviceUrlInterceptor({webex: this});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @see Interceptor#onRequest
|
|
24
|
-
* @param {Object} options
|
|
25
|
-
* @returns {Object}
|
|
26
|
-
*/
|
|
27
|
-
onRequest(options) {
|
|
28
|
-
const {headers, service, uri} = options;
|
|
29
|
-
const {device, services} = this.webex.internal;
|
|
30
|
-
|
|
31
|
-
// Check if header is already set before moving forward
|
|
32
|
-
if (!device.url || (headers && CISCO_DEVICE_URL in headers && !!headers[CISCO_DEVICE_URL])) {
|
|
33
|
-
return Promise.resolve(options);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Wait for catalog and service to be defined.
|
|
37
|
-
return services
|
|
38
|
-
.waitForService({service, url: uri})
|
|
39
|
-
.then((url) => {
|
|
40
|
-
// Grab the service name with the url returned from waitForService
|
|
41
|
-
const {name: serviceName} = services.getServiceFromUrl(url) || {};
|
|
42
|
-
const invalidServices = ['idbroker', 'oauth', 'saml'];
|
|
43
|
-
|
|
44
|
-
// Check if service is not one of the invalid services
|
|
45
|
-
// Assign the url to the device header
|
|
46
|
-
if (serviceName && !invalidServices.includes(serviceName)) {
|
|
47
|
-
set(options, `headers['${CISCO_DEVICE_URL}']`, device.url);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return options;
|
|
51
|
-
})
|
|
52
|
-
.catch((error) => {
|
|
53
|
-
// Validate that the error came from getServiceFromUrl
|
|
54
|
-
if (error.message.match(/was not found after waiting/)) {
|
|
55
|
-
return options;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return Promise.reject(error);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Interceptor} from '@webex/http-core';
|
|
6
|
+
import {set} from 'lodash';
|
|
7
|
+
|
|
8
|
+
import {CISCO_DEVICE_URL} from '../constants';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Adds 'cisco-device-url' header, as appropriate, to requests
|
|
12
|
+
*/
|
|
13
|
+
export default class DeviceUrlInterceptor extends Interceptor {
|
|
14
|
+
/**
|
|
15
|
+
* @returns {DeviceUrlInterceptor}
|
|
16
|
+
*/
|
|
17
|
+
static create() {
|
|
18
|
+
/* eslint no-invalid-this: [0] */
|
|
19
|
+
return new DeviceUrlInterceptor({webex: this});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @see Interceptor#onRequest
|
|
24
|
+
* @param {Object} options
|
|
25
|
+
* @returns {Object}
|
|
26
|
+
*/
|
|
27
|
+
onRequest(options) {
|
|
28
|
+
const {headers, service, uri} = options;
|
|
29
|
+
const {device, services} = this.webex.internal;
|
|
30
|
+
|
|
31
|
+
// Check if header is already set before moving forward
|
|
32
|
+
if (!device.url || (headers && CISCO_DEVICE_URL in headers && !!headers[CISCO_DEVICE_URL])) {
|
|
33
|
+
return Promise.resolve(options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Wait for catalog and service to be defined.
|
|
37
|
+
return services
|
|
38
|
+
.waitForService({service, url: uri})
|
|
39
|
+
.then((url) => {
|
|
40
|
+
// Grab the service name with the url returned from waitForService
|
|
41
|
+
const {name: serviceName} = services.getServiceFromUrl(url) || {};
|
|
42
|
+
const invalidServices = ['idbroker', 'oauth', 'saml'];
|
|
43
|
+
|
|
44
|
+
// Check if service is not one of the invalid services
|
|
45
|
+
// Assign the url to the device header
|
|
46
|
+
if (serviceName && !invalidServices.includes(serviceName)) {
|
|
47
|
+
set(options, `headers['${CISCO_DEVICE_URL}']`, device.url);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return options;
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
// Validate that the error came from getServiceFromUrl
|
|
54
|
+
if (error.message.match(/was not found after waiting/)) {
|
|
55
|
+
return options;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return Promise.reject(error);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/metrics.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Metric to do with WDM registration
|
|
2
|
-
export default {
|
|
3
|
-
JS_SDK_WDM_REGISTRATION_SUCCESSFUL: 'JS_SDK_WDM_REGISTRATION_SUCCESSFUL',
|
|
4
|
-
JS_SDK_WDM_REGISTRATION_FAILED: 'JS_SDK_WDM_REGISTRATION_FAILED',
|
|
5
|
-
};
|
|
1
|
+
// Metric to do with WDM registration
|
|
2
|
+
export default {
|
|
3
|
+
JS_SDK_WDM_REGISTRATION_SUCCESSFUL: 'JS_SDK_WDM_REGISTRATION_SUCCESSFUL',
|
|
4
|
+
JS_SDK_WDM_REGISTRATION_FAILED: 'JS_SDK_WDM_REGISTRATION_FAILED',
|
|
5
|
+
};
|