@webex/internal-plugin-device 3.0.0-beta.9 → 3.0.0-bnr.0

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 (52) hide show
  1. package/README.md +10 -6
  2. package/dist/config.js +0 -8
  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 +94 -171
  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/internal-plugin-device.d.ts +91 -0
  21. package/dist/metrics.js +0 -2
  22. package/dist/metrics.js.map +1 -1
  23. package/dist/tsdoc-metadata.json +11 -0
  24. package/dist/types/config.d.ts +10 -0
  25. package/dist/types/constants.d.ts +12 -0
  26. package/dist/types/device.d.ts +2 -0
  27. package/dist/types/features/feature-collection.d.ts +9 -0
  28. package/dist/types/features/feature-model.d.ts +29 -0
  29. package/dist/types/features/features-model.d.ts +9 -0
  30. package/dist/types/features/index.d.ts +4 -0
  31. package/dist/types/index.d.ts +8 -0
  32. package/dist/types/interceptors/device-url.d.ts +15 -0
  33. package/dist/types/metrics.d.ts +5 -0
  34. package/package.json +10 -10
  35. package/src/config.js +8 -9
  36. package/src/constants.js +3 -5
  37. package/src/device.js +142 -146
  38. package/src/features/feature-collection.js +1 -1
  39. package/src/features/feature-model.js +5 -11
  40. package/src/features/features-model.js +3 -9
  41. package/src/features/index.js +1 -5
  42. package/src/index.js +3 -11
  43. package/src/interceptors/device-url.js +5 -7
  44. package/src/metrics.js +1 -2
  45. package/test/integration/spec/device.js +210 -239
  46. package/test/integration/spec/webex.js +9 -9
  47. package/test/unit/spec/device.js +44 -53
  48. package/test/unit/spec/features/feature-collection.js +2 -2
  49. package/test/unit/spec/features/feature-model.js +23 -39
  50. package/test/unit/spec/features/features-model.js +4 -12
  51. package/test/unit/spec/interceptors/device-url.js +69 -109
  52. package/test/unit/spec/wdm-dto.json +5 -13
@@ -1,37 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  _Object$defineProperty(exports, "FeatureCollection", {
12
9
  enumerable: true,
13
10
  get: function get() {
14
11
  return _featureCollection.default;
15
12
  }
16
13
  });
17
-
18
14
  _Object$defineProperty(exports, "FeatureModel", {
19
15
  enumerable: true,
20
16
  get: function get() {
21
17
  return _featureModel.default;
22
18
  }
23
19
  });
24
-
25
20
  _Object$defineProperty(exports, "FeaturesModel", {
26
21
  enumerable: true,
27
22
  get: function get() {
28
23
  return _featuresModel.default;
29
24
  }
30
25
  });
31
-
32
26
  var _featureCollection = _interopRequireDefault(require("./feature-collection"));
33
-
34
27
  var _featureModel = _interopRequireDefault(require("./feature-model"));
35
-
36
28
  var _featuresModel = _interopRequireDefault(require("./features-model"));
37
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.js"],"sourcesContent":["import FeatureCollection from './feature-collection';\nimport FeatureModel from './feature-model';\nimport FeaturesModel from './features-model';\n\nexport {\n FeatureCollection,\n FeatureModel,\n FeaturesModel\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA"}
1
+ {"version":3,"names":[],"sources":["index.js"],"sourcesContent":["import FeatureCollection from './feature-collection';\nimport FeatureModel from './feature-model';\nimport FeaturesModel from './features-model';\n\nexport {FeatureCollection, FeatureModel, FeaturesModel};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA"}
package/dist/index.js CHANGED
@@ -1,92 +1,70 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
-
5
4
  var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
6
-
7
5
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
-
9
6
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
10
-
11
7
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
-
13
8
  _Object$defineProperty(exports, "__esModule", {
14
9
  value: true
15
10
  });
16
-
17
11
  _Object$defineProperty(exports, "DeviceUrlInterceptor", {
18
12
  enumerable: true,
19
13
  get: function get() {
20
14
  return _deviceUrl.default;
21
15
  }
22
16
  });
23
-
24
17
  _Object$defineProperty(exports, "FeatureCollection", {
25
18
  enumerable: true,
26
19
  get: function get() {
27
20
  return _index.FeatureCollection;
28
21
  }
29
22
  });
30
-
31
23
  _Object$defineProperty(exports, "FeatureModel", {
32
24
  enumerable: true,
33
25
  get: function get() {
34
26
  return _index.FeatureModel;
35
27
  }
36
28
  });
37
-
38
29
  _Object$defineProperty(exports, "FeaturesModel", {
39
30
  enumerable: true,
40
31
  get: function get() {
41
32
  return _index.FeaturesModel;
42
33
  }
43
34
  });
44
-
45
35
  _Object$defineProperty(exports, "config", {
46
36
  enumerable: true,
47
37
  get: function get() {
48
38
  return _config.default;
49
39
  }
50
40
  });
51
-
52
41
  exports.constants = void 0;
53
-
54
42
  _Object$defineProperty(exports, "default", {
55
43
  enumerable: true,
56
44
  get: function get() {
57
45
  return _device.default;
58
46
  }
59
47
  });
60
-
61
48
  require("@webex/internal-plugin-metrics");
62
-
63
49
  var _webexCore = require("@webex/webex-core");
64
-
65
50
  var _device = _interopRequireDefault(require("./device"));
66
-
67
51
  var _index = require("./features/index");
68
-
69
52
  var _deviceUrl = _interopRequireDefault(require("./interceptors/device-url"));
70
-
71
53
  var constants = _interopRequireWildcard(require("./constants"));
72
-
73
54
  exports.constants = constants;
74
-
75
55
  var _config = _interopRequireDefault(require("./config"));
76
-
77
56
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
78
-
79
57
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
80
-
81
58
  // Internal dependencies.
82
59
  // Need to import metrics plugin for the devices to send metrics on succes/failure registration
60
+
83
61
  // Plugin dependencies.
62
+
84
63
  (0, _webexCore.registerInternalPlugin)('device', _device.default, {
85
64
  config: _config.default,
86
65
  interceptors: {
87
66
  DeviceUrlInterceptor: _deviceUrl.default.create
88
67
  },
89
-
90
68
  /**
91
69
  * Unregister the device in the case that the webex instance has logged out.
92
70
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["registerInternalPlugin","Device","config","interceptors","DeviceUrlInterceptor","create","onBeforeLogout","unregister"],"sources":["index.js"],"sourcesContent":["// Internal dependencies.\n// Need to import metrics plugin for the devices to send metrics on succes/failure registration\nimport '@webex/internal-plugin-metrics';\nimport {registerInternalPlugin} from '@webex/webex-core';\n\n// Plugin dependencies.\nimport Device from './device';\nimport {FeatureCollection, FeatureModel, FeaturesModel} from './features/index';\nimport DeviceUrlInterceptor from './interceptors/device-url';\nimport * as constants from './constants';\nimport config from './config';\n\nregisterInternalPlugin('device', Device, {\n config,\n interceptors: {\n DeviceUrlInterceptor: DeviceUrlInterceptor.create\n },\n /**\n * Unregister the device in the case that the webex instance has logged out.\n *\n * @returns {Promise<undefined>}\n */\n onBeforeLogout() {\n return this.unregister();\n }\n});\n\nexport {default} from './device';\nexport {\n config,\n constants,\n DeviceUrlInterceptor,\n FeatureCollection,\n FeatureModel,\n FeaturesModel\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;AACA;;;;;;AAVA;AACA;AAIA;AAOA,IAAAA,iCAAA,EAAuB,QAAvB,EAAiCC,eAAjC,EAAyC;EACvCC,MAAM,EAANA,eADuC;EAEvCC,YAAY,EAAE;IACZC,oBAAoB,EAAEA,kBAAA,CAAqBC;EAD/B,CAFyB;;EAKvC;AACF;AACA;AACA;AACA;EACEC,cAVuC,4BAUtB;IACf,OAAO,KAAKC,UAAL,EAAP;EACD;AAZsC,CAAzC"}
1
+ {"version":3,"names":["registerInternalPlugin","Device","config","interceptors","DeviceUrlInterceptor","create","onBeforeLogout","unregister"],"sources":["index.js"],"sourcesContent":["// Internal dependencies.\n// Need to import metrics plugin for the devices to send metrics on succes/failure registration\nimport '@webex/internal-plugin-metrics';\nimport {registerInternalPlugin} from '@webex/webex-core';\n\n// Plugin dependencies.\nimport Device from './device';\nimport {FeatureCollection, FeatureModel, FeaturesModel} from './features/index';\nimport DeviceUrlInterceptor from './interceptors/device-url';\nimport * as constants from './constants';\nimport config from './config';\n\nregisterInternalPlugin('device', Device, {\n config,\n interceptors: {\n DeviceUrlInterceptor: DeviceUrlInterceptor.create,\n },\n /**\n * Unregister the device in the case that the webex instance has logged out.\n *\n * @returns {Promise<undefined>}\n */\n onBeforeLogout() {\n return this.unregister();\n },\n});\n\nexport {default} from './device';\nexport {config, constants, DeviceUrlInterceptor, FeatureCollection, FeatureModel, FeaturesModel};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA;AAGA;AACA;AACA;AACA;AAAyC;AACzC;AAA8B;AAAA;AAV9B;AACA;;AAIA;;AAOA,IAAAA,iCAAsB,EAAC,QAAQ,EAAEC,eAAM,EAAE;EACvCC,MAAM,EAANA,eAAM;EACNC,YAAY,EAAE;IACZC,oBAAoB,EAAEA,kBAAoB,CAACC;EAC7C,CAAC;EACD;AACF;AACA;AACA;AACA;EACEC,cAAc,4BAAG;IACf,OAAO,IAAI,CAACC,UAAU,EAAE;EAC1B;AACF,CAAC,CAAC"}
@@ -1,52 +1,33 @@
1
1
  "use strict";
2
2
 
3
3
  var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
4
-
5
4
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
6
-
7
5
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
8
-
9
6
  _Object$defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
-
13
9
  exports.default = void 0;
14
-
15
10
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
16
-
17
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
18
-
19
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
20
-
21
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
22
-
23
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
24
-
25
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
26
-
27
16
  var _set2 = _interopRequireDefault(require("lodash/set"));
28
-
29
17
  var _httpCore = require("@webex/http-core");
30
-
31
18
  var _constants = require("../constants");
32
-
33
19
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
34
-
35
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
36
-
37
21
  /**
38
- * Adds 'cisco-device-url' header, as appropriate, to requests
39
- */
22
+ * Adds 'cisco-device-url' header, as appropriate, to requests
23
+ */
40
24
  var DeviceUrlInterceptor = /*#__PURE__*/function (_Interceptor) {
41
25
  (0, _inherits2.default)(DeviceUrlInterceptor, _Interceptor);
42
-
43
26
  var _super = _createSuper(DeviceUrlInterceptor);
44
-
45
27
  function DeviceUrlInterceptor() {
46
28
  (0, _classCallCheck2.default)(this, DeviceUrlInterceptor);
47
29
  return _super.apply(this, arguments);
48
30
  }
49
-
50
31
  (0, _createClass2.default)(DeviceUrlInterceptor, [{
51
32
  key: "onRequest",
52
33
  value:
@@ -57,39 +38,38 @@ var DeviceUrlInterceptor = /*#__PURE__*/function (_Interceptor) {
57
38
  */
58
39
  function onRequest(options) {
59
40
  var headers = options.headers,
60
- service = options.service,
61
- uri = options.uri;
41
+ service = options.service,
42
+ uri = options.uri;
62
43
  var _this$webex$internal = this.webex.internal,
63
- device = _this$webex$internal.device,
64
- services = _this$webex$internal.services; // Check if header is already set before moving forward
44
+ device = _this$webex$internal.device,
45
+ services = _this$webex$internal.services;
65
46
 
47
+ // Check if header is already set before moving forward
66
48
  if (!device.url || headers && _constants.CISCO_DEVICE_URL in headers && !!headers[_constants.CISCO_DEVICE_URL]) {
67
49
  return _promise.default.resolve(options);
68
- } // Wait for catalog and service to be defined.
69
-
50
+ }
70
51
 
52
+ // Wait for catalog and service to be defined.
71
53
  return services.waitForService({
72
54
  service: service,
73
55
  url: uri
74
56
  }).then(function (url) {
75
57
  // Grab the service name with the url returned from waitForService
76
58
  var _ref = services.getServiceFromUrl(url) || {},
77
- serviceName = _ref.name;
59
+ serviceName = _ref.name;
60
+ var invalidServices = ['idbroker', 'oauth', 'saml'];
78
61
 
79
- var invalidServices = ['idbroker', 'oauth', 'saml']; // Check if service is not one of the invalid services
62
+ // Check if service is not one of the invalid services
80
63
  // Assign the url to the device header
81
-
82
64
  if (serviceName && !invalidServices.includes(serviceName)) {
83
65
  (0, _set2.default)(options, "headers['".concat(_constants.CISCO_DEVICE_URL, "']"), device.url);
84
66
  }
85
-
86
67
  return options;
87
68
  }).catch(function (error) {
88
69
  // Validate that the error came from getServiceFromUrl
89
70
  if (error.message.match(/was not found after waiting/)) {
90
71
  return options;
91
72
  }
92
-
93
73
  return _promise.default.reject(error);
94
74
  });
95
75
  }
@@ -108,6 +88,5 @@ var DeviceUrlInterceptor = /*#__PURE__*/function (_Interceptor) {
108
88
  }]);
109
89
  return DeviceUrlInterceptor;
110
90
  }(_httpCore.Interceptor);
111
-
112
91
  exports.default = DeviceUrlInterceptor;
113
92
  //# sourceMappingURL=device-url.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DeviceUrlInterceptor","options","headers","service","uri","webex","internal","device","services","url","CISCO_DEVICE_URL","resolve","waitForService","then","getServiceFromUrl","serviceName","name","invalidServices","includes","catch","error","message","match","reject","Interceptor"],"sources":["device-url.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\nimport {set} from 'lodash';\n\nimport {CISCO_DEVICE_URL} from '../constants';\n\n/**\n * Adds 'cisco-device-url' header, as appropriate, to requests\n */\nexport default class DeviceUrlInterceptor extends Interceptor {\n /**\n * @returns {DeviceUrlInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new DeviceUrlInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const {headers, service, uri} = options;\n const {device, services} = this.webex.internal;\n\n // Check if header is already set before moving forward\n if (\n !device.url ||\n (headers && CISCO_DEVICE_URL in headers && !!headers[CISCO_DEVICE_URL])\n ) {\n return Promise.resolve(options);\n }\n\n // Wait for catalog and service to be defined.\n return services.waitForService({service, url: uri})\n .then((url) => {\n // Grab the service name with the url returned from waitForService\n const {name: serviceName} = services.getServiceFromUrl(url) || {};\n const invalidServices = ['idbroker', 'oauth', 'saml'];\n\n // Check if service is not one of the invalid services\n // Assign the url to the device header\n if (serviceName && !invalidServices.includes(serviceName)) {\n set(options, `headers['${CISCO_DEVICE_URL}']`, device.url);\n }\n\n return options;\n })\n .catch((error) => {\n // Validate that the error came from getServiceFromUrl\n if (error.message.match(/was not found after waiting/)) {\n return options;\n }\n\n return Promise.reject(error);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAGA;;;;;;AAEA;AACA;AACA;IACqBA,oB;;;;;;;;;;;;;IASnB;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAV,EAAmB;MACjB,IAAOC,OAAP,GAAgCD,OAAhC,CAAOC,OAAP;MAAA,IAAgBC,OAAhB,GAAgCF,OAAhC,CAAgBE,OAAhB;MAAA,IAAyBC,GAAzB,GAAgCH,OAAhC,CAAyBG,GAAzB;MACA,2BAA2B,KAAKC,KAAL,CAAWC,QAAtC;MAAA,IAAOC,MAAP,wBAAOA,MAAP;MAAA,IAAeC,QAAf,wBAAeA,QAAf,CAFiB,CAIjB;;MACA,IACE,CAACD,MAAM,CAACE,GAAR,IACCP,OAAO,IAAIQ,2BAAA,IAAoBR,OAA/B,IAA0C,CAAC,CAACA,OAAO,CAACQ,2BAAD,CAFtD,EAGE;QACA,OAAO,iBAAQC,OAAR,CAAgBV,OAAhB,CAAP;MACD,CAVgB,CAYjB;;;MACA,OAAOO,QAAQ,CAACI,cAAT,CAAwB;QAACT,OAAO,EAAPA,OAAD;QAAUM,GAAG,EAAEL;MAAf,CAAxB,EACJS,IADI,CACC,UAACJ,GAAD,EAAS;QACb;QACA,WAA4BD,QAAQ,CAACM,iBAAT,CAA2BL,GAA3B,KAAmC,EAA/D;QAAA,IAAaM,WAAb,QAAOC,IAAP;;QACA,IAAMC,eAAe,GAAG,CAAC,UAAD,EAAa,OAAb,EAAsB,MAAtB,CAAxB,CAHa,CAKb;QACA;;QACA,IAAIF,WAAW,IAAI,CAACE,eAAe,CAACC,QAAhB,CAAyBH,WAAzB,CAApB,EAA2D;UACzD,mBAAId,OAAJ,qBAAyBS,2BAAzB,SAA+CH,MAAM,CAACE,GAAtD;QACD;;QAED,OAAOR,OAAP;MACD,CAbI,EAcJkB,KAdI,CAcE,UAACC,KAAD,EAAW;QAChB;QACA,IAAIA,KAAK,CAACC,OAAN,CAAcC,KAAd,CAAoB,6BAApB,CAAJ,EAAwD;UACtD,OAAOrB,OAAP;QACD;;QAED,OAAO,iBAAQsB,MAAR,CAAeH,KAAf,CAAP;MACD,CArBI,CAAP;IAsBD;;;;IAhDD;AACF;AACA;IACE,kBAAgB;MACd;MACA,OAAO,IAAIpB,oBAAJ,CAAyB;QAACK,KAAK,EAAE;MAAR,CAAzB,CAAP;IACD;;;EAP+CmB,qB"}
1
+ {"version":3,"names":["DeviceUrlInterceptor","options","headers","service","uri","webex","internal","device","services","url","CISCO_DEVICE_URL","resolve","waitForService","then","getServiceFromUrl","serviceName","name","invalidServices","includes","catch","error","message","match","reject","Interceptor"],"sources":["device-url.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\nimport {set} from 'lodash';\n\nimport {CISCO_DEVICE_URL} from '../constants';\n\n/**\n * Adds 'cisco-device-url' header, as appropriate, to requests\n */\nexport default class DeviceUrlInterceptor extends Interceptor {\n /**\n * @returns {DeviceUrlInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new DeviceUrlInterceptor({webex: this});\n }\n\n /**\n * @see Interceptor#onRequest\n * @param {Object} options\n * @returns {Object}\n */\n onRequest(options) {\n const {headers, service, uri} = options;\n const {device, services} = this.webex.internal;\n\n // Check if header is already set before moving forward\n if (!device.url || (headers && CISCO_DEVICE_URL in headers && !!headers[CISCO_DEVICE_URL])) {\n return Promise.resolve(options);\n }\n\n // Wait for catalog and service to be defined.\n return services\n .waitForService({service, url: uri})\n .then((url) => {\n // Grab the service name with the url returned from waitForService\n const {name: serviceName} = services.getServiceFromUrl(url) || {};\n const invalidServices = ['idbroker', 'oauth', 'saml'];\n\n // Check if service is not one of the invalid services\n // Assign the url to the device header\n if (serviceName && !invalidServices.includes(serviceName)) {\n set(options, `headers['${CISCO_DEVICE_URL}']`, device.url);\n }\n\n return options;\n })\n .catch((error) => {\n // Validate that the error came from getServiceFromUrl\n if (error.message.match(/was not found after waiting/)) {\n return options;\n }\n\n return Promise.reject(error);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIA;AAGA;AAA8C;AAAA;AAE9C;AACA;AACA;AAFA,IAGqBA,oBAAoB;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IASvC;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAO,EAAE;MACjB,IAAOC,OAAO,GAAkBD,OAAO,CAAhCC,OAAO;QAAEC,OAAO,GAASF,OAAO,CAAvBE,OAAO;QAAEC,GAAG,GAAIH,OAAO,CAAdG,GAAG;MAC5B,2BAA2B,IAAI,CAACC,KAAK,CAACC,QAAQ;QAAvCC,MAAM,wBAANA,MAAM;QAAEC,QAAQ,wBAARA,QAAQ;;MAEvB;MACA,IAAI,CAACD,MAAM,CAACE,GAAG,IAAKP,OAAO,IAAIQ,2BAAgB,IAAIR,OAAO,IAAI,CAAC,CAACA,OAAO,CAACQ,2BAAgB,CAAE,EAAE;QAC1F,OAAO,iBAAQC,OAAO,CAACV,OAAO,CAAC;MACjC;;MAEA;MACA,OAAOO,QAAQ,CACZI,cAAc,CAAC;QAACT,OAAO,EAAPA,OAAO;QAAEM,GAAG,EAAEL;MAAG,CAAC,CAAC,CACnCS,IAAI,CAAC,UAACJ,GAAG,EAAK;QACb;QACA,WAA4BD,QAAQ,CAACM,iBAAiB,CAACL,GAAG,CAAC,IAAI,CAAC,CAAC;UAApDM,WAAW,QAAjBC,IAAI;QACX,IAAMC,eAAe,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC;;QAErD;QACA;QACA,IAAIF,WAAW,IAAI,CAACE,eAAe,CAACC,QAAQ,CAACH,WAAW,CAAC,EAAE;UACzD,mBAAId,OAAO,qBAAcS,2BAAgB,SAAMH,MAAM,CAACE,GAAG,CAAC;QAC5D;QAEA,OAAOR,OAAO;MAChB,CAAC,CAAC,CACDkB,KAAK,CAAC,UAACC,KAAK,EAAK;QAChB;QACA,IAAIA,KAAK,CAACC,OAAO,CAACC,KAAK,CAAC,6BAA6B,CAAC,EAAE;UACtD,OAAOrB,OAAO;QAChB;QAEA,OAAO,iBAAQsB,MAAM,CAACH,KAAK,CAAC;MAC9B,CAAC,CAAC;IACN;EAAC;IAAA;IAAA;IA9CD;AACF;AACA;IACE,kBAAgB;MACd;MACA,OAAO,IAAIpB,oBAAoB,CAAC;QAACK,KAAK,EAAE;MAAI,CAAC,CAAC;IAChD;EAAC;EAAA;AAAA,EAP+CmB,qBAAW;AAAA"}
@@ -0,0 +1,91 @@
1
+ declare const CISCO_DEVICE_URL: "cisco-device-url";
2
+
3
+ export declare namespace config {
4
+ export namespace device {
5
+ const canRegisterWaitDuration: number;
6
+ const defaults: any;
7
+ const enableInactivityEnforcement: boolean;
8
+ const ephemeral: boolean;
9
+ const ephemeralDeviceTTL: boolean;
10
+ }
11
+ }
12
+
13
+ declare namespace constants {
14
+ export {
15
+ FEATURE_COLLECTION_DEVELOPER,
16
+ FEATURE_COLLECTION_ENTITLEMENT,
17
+ FEATURE_COLLECTION_USER,
18
+ CISCO_DEVICE_URL,
19
+ FEATURE_COLLECTION_NAMES,
20
+ FEATURE_TYPES,
21
+ DEVICE_EVENT_REGISTRATION_SUCCESS,
22
+ DEVICE_EVENTS
23
+ }
24
+ }
25
+ export { constants }
26
+
27
+ declare const Device: any;
28
+ export default Device;
29
+
30
+ declare const DEVICE_EVENT_REGISTRATION_SUCCESS: "registration:success";
31
+
32
+ declare const DEVICE_EVENTS: string[];
33
+
34
+ /**
35
+ * Adds 'cisco-device-url' header, as appropriate, to requests
36
+ */
37
+ export declare class DeviceUrlInterceptor {
38
+ /**
39
+ * @returns {DeviceUrlInterceptor}
40
+ */
41
+ static create(): DeviceUrlInterceptor;
42
+ /**
43
+ * @see Interceptor#onRequest
44
+ * @param {Object} options
45
+ * @returns {Object}
46
+ */
47
+ onRequest(options: any): any;
48
+ }
49
+
50
+ declare const FEATURE_COLLECTION_DEVELOPER: "developer";
51
+
52
+ declare const FEATURE_COLLECTION_ENTITLEMENT: "entitlement";
53
+
54
+ declare const FEATURE_COLLECTION_NAMES: string[];
55
+
56
+ declare const FEATURE_COLLECTION_USER: "user";
57
+
58
+ declare namespace FEATURE_TYPES {
59
+ const BOOLEAN: string;
60
+ const NUMBER: string;
61
+ const STRING: string;
62
+ }
63
+
64
+ /**
65
+ * Feature collection model.
66
+ *
67
+ * @description
68
+ * This model contains a collection of features under a specific collection
69
+ * group.
70
+ */
71
+ export declare const FeatureCollection: any;
72
+
73
+ /**
74
+ * Feature model.
75
+ *
76
+ * @description
77
+ * This model contains details on a single feature and is received from the
78
+ * **WDM** service upon registration.
79
+ */
80
+ export declare const FeatureModel: any;
81
+
82
+ /**
83
+ * Feature collection parent container.
84
+ *
85
+ * @description
86
+ * This class contains all of the feature collection class objects to help
87
+ * organize the data retrieved from the **wdm** service on device registration.
88
+ */
89
+ export declare const FeaturesModel: any;
90
+
91
+ export { }
package/dist/metrics.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
8
  // Metric to do with WDM registration
11
9
  var _default = {
@@ -1 +1 @@
1
- {"version":3,"names":["JS_SDK_WDM_REGISTRATION_SUCCESSFUL","JS_SDK_WDM_REGISTRATION_FAILED"],"sources":["metrics.js"],"sourcesContent":["// Metric to do with WDM registration\nexport default {\n JS_SDK_WDM_REGISTRATION_SUCCESSFUL: 'JS_SDK_WDM_REGISTRATION_SUCCESSFUL',\n JS_SDK_WDM_REGISTRATION_FAILED: 'JS_SDK_WDM_REGISTRATION_FAILED'\n};\n\n"],"mappings":";;;;;;;;;AAAA;eACe;EACbA,kCAAkC,EAAE,oCADvB;EAEbC,8BAA8B,EAAE;AAFnB,C"}
1
+ {"version":3,"names":["JS_SDK_WDM_REGISTRATION_SUCCESSFUL","JS_SDK_WDM_REGISTRATION_FAILED"],"sources":["metrics.js"],"sourcesContent":["// Metric to do with WDM registration\nexport default {\n JS_SDK_WDM_REGISTRATION_SUCCESSFUL: 'JS_SDK_WDM_REGISTRATION_SUCCESSFUL',\n JS_SDK_WDM_REGISTRATION_FAILED: 'JS_SDK_WDM_REGISTRATION_FAILED',\n};\n"],"mappings":";;;;;;;AAAA;AAAA,eACe;EACbA,kCAAkC,EAAE,oCAAoC;EACxEC,8BAA8B,EAAE;AAClC,CAAC;AAAA"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.4"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,10 @@
1
+ declare namespace _default {
2
+ namespace device {
3
+ const canRegisterWaitDuration: number;
4
+ const defaults: any;
5
+ const enableInactivityEnforcement: boolean;
6
+ const ephemeral: boolean;
7
+ const ephemeralDeviceTTL: boolean;
8
+ }
9
+ }
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ export const FEATURE_COLLECTION_DEVELOPER: "developer";
2
+ export const FEATURE_COLLECTION_ENTITLEMENT: "entitlement";
3
+ export const FEATURE_COLLECTION_USER: "user";
4
+ export const CISCO_DEVICE_URL: "cisco-device-url";
5
+ export const FEATURE_COLLECTION_NAMES: string[];
6
+ export namespace FEATURE_TYPES {
7
+ const BOOLEAN: string;
8
+ const NUMBER: string;
9
+ const STRING: string;
10
+ }
11
+ export const DEVICE_EVENT_REGISTRATION_SUCCESS: "registration:success";
12
+ export const DEVICE_EVENTS: string[];
@@ -0,0 +1,2 @@
1
+ export default Device;
2
+ declare const Device: any;
@@ -0,0 +1,9 @@
1
+ export default FeatureCollection;
2
+ /**
3
+ * Feature collection model.
4
+ *
5
+ * @description
6
+ * This model contains a collection of features under a specific collection
7
+ * group.
8
+ */
9
+ declare const FeatureCollection: any;
@@ -0,0 +1,29 @@
1
+ export default FeatureModel;
2
+ /**
3
+ * The model returned from the {@link FeatureModelparse } method.
4
+ */
5
+ export type ParsedFeatureModel = {
6
+ /**
7
+ * - The parsed val.
8
+ */
9
+ value: boolean | number | string;
10
+ /**
11
+ * - The type of the parsed val.
12
+ */
13
+ type: string;
14
+ };
15
+ /**
16
+ * The model returned from the {@link FeatureModel#parse} method.
17
+ *
18
+ * @typedef {Object} ParsedFeatureModel
19
+ * @property {boolean|number|string} ParsedFeatureModel.value - The parsed val.
20
+ * @property {string} ParsedFeatureModel.type - The type of the parsed val.
21
+ */
22
+ /**
23
+ * Feature model.
24
+ *
25
+ * @description
26
+ * This model contains details on a single feature and is received from the
27
+ * **WDM** service upon registration.
28
+ */
29
+ declare const FeatureModel: any;
@@ -0,0 +1,9 @@
1
+ export default FeaturesModel;
2
+ /**
3
+ * Feature collection parent container.
4
+ *
5
+ * @description
6
+ * This class contains all of the feature collection class objects to help
7
+ * organize the data retrieved from the **wdm** service on device registration.
8
+ */
9
+ declare const FeaturesModel: any;
@@ -0,0 +1,4 @@
1
+ import FeatureCollection from "./feature-collection";
2
+ import FeatureModel from "./feature-model";
3
+ import FeaturesModel from "./features-model";
4
+ export { FeatureCollection, FeatureModel, FeaturesModel };
@@ -0,0 +1,8 @@
1
+ export { default } from "./device";
2
+ import config from "./config";
3
+ import * as constants from "./constants";
4
+ import DeviceUrlInterceptor from "./interceptors/device-url";
5
+ import { FeatureCollection } from "./features/index";
6
+ import { FeatureModel } from "./features/index";
7
+ import { FeaturesModel } from "./features/index";
8
+ export { config, constants, DeviceUrlInterceptor, FeatureCollection, FeatureModel, FeaturesModel };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Adds 'cisco-device-url' header, as appropriate, to requests
3
+ */
4
+ export default class DeviceUrlInterceptor {
5
+ /**
6
+ * @returns {DeviceUrlInterceptor}
7
+ */
8
+ static create(): DeviceUrlInterceptor;
9
+ /**
10
+ * @see Interceptor#onRequest
11
+ * @param {Object} options
12
+ * @returns {Object}
13
+ */
14
+ onRequest(options: any): any;
15
+ }
@@ -0,0 +1,5 @@
1
+ declare namespace _default {
2
+ const JS_SDK_WDM_REGISTRATION_SUCCESSFUL: string;
3
+ const JS_SDK_WDM_REGISTRATION_FAILED: string;
4
+ }
5
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-device",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-bnr.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Timothy Scheuering <timsch@cisco.com>",
@@ -21,20 +21,20 @@
21
21
  ]
22
22
  },
23
23
  "devDependencies": {
24
- "@webex/test-helper-chai": "3.0.0-beta.9",
25
- "@webex/test-helper-mock-webex": "3.0.0-beta.9",
26
- "@webex/test-helper-test-users": "3.0.0-beta.9",
24
+ "@webex/test-helper-chai": "3.0.0-bnr.0",
25
+ "@webex/test-helper-mock-webex": "3.0.0-bnr.0",
26
+ "@webex/test-helper-test-users": "3.0.0-bnr.0",
27
27
  "chai": "^4.3.4",
28
28
  "chai-as-promised": "^7.1.1",
29
29
  "sinon": "^9.2.4"
30
30
  },
31
31
  "dependencies": {
32
- "@webex/common": "3.0.0-beta.9",
33
- "@webex/common-timers": "3.0.0-beta.9",
34
- "@webex/http-core": "3.0.0-beta.9",
35
- "@webex/internal-plugin-device": "3.0.0-beta.9",
36
- "@webex/internal-plugin-metrics": "3.0.0-beta.9",
37
- "@webex/webex-core": "3.0.0-beta.9",
32
+ "@webex/common": "3.0.0-bnr.0",
33
+ "@webex/common-timers": "3.0.0-bnr.0",
34
+ "@webex/http-core": "3.0.0-bnr.0",
35
+ "@webex/internal-plugin-device": "3.0.0-bnr.0",
36
+ "@webex/internal-plugin-metrics": "3.0.0-bnr.0",
37
+ "@webex/webex-core": "3.0.0-bnr.0",
38
38
  "ampersand-collection": "^2.0.2",
39
39
  "ampersand-state": "^5.0.3",
40
40
  "lodash": "^4.17.21"
package/src/config.js CHANGED
@@ -2,7 +2,6 @@ import {inBrowser, deviceType} from '@webex/common';
2
2
 
3
3
  export default {
4
4
  device: {
5
-
6
5
  /**
7
6
  * The duration to wait for the catalog to populate in seconds.
8
7
  *
@@ -16,22 +15,22 @@ export default {
16
15
  * @type {Object}
17
16
  */
18
17
  defaults: {
19
-
20
18
  /**
21
19
  * The default body configuration of registration requests.
22
20
  *
23
21
  * @type {Object}
24
22
  */
25
23
  body: {
26
- name: (typeof process.title === 'string' ?
27
- process.title.trim() : undefined) ||
28
- inBrowser && 'browser' || 'javascript',
24
+ name:
25
+ (typeof process.title === 'string' ? process.title.trim() : undefined) ||
26
+ (inBrowser && 'browser') ||
27
+ 'javascript',
29
28
  deviceType: deviceType.WEB,
30
29
  model: 'web-js-sdk',
31
30
  localizedModel: 'webex-js-sdk',
32
31
  systemName: 'WEBEX_JS_SDK',
33
- systemVersion: '1.0.0'
34
- }
32
+ systemVersion: '1.0.0',
33
+ },
35
34
  },
36
35
 
37
36
  /**
@@ -56,6 +55,6 @@ export default {
56
55
  *
57
56
  * @type {boolean}
58
57
  */
59
- ephemeralDeviceTTL: 30 * 60
60
- }
58
+ ephemeralDeviceTTL: 30 * 60,
59
+ },
61
60
  };
package/src/constants.js CHANGED
@@ -8,18 +8,16 @@ export const CISCO_DEVICE_URL = 'cisco-device-url';
8
8
  export const FEATURE_COLLECTION_NAMES = [
9
9
  FEATURE_COLLECTION_DEVELOPER,
10
10
  FEATURE_COLLECTION_ENTITLEMENT,
11
- FEATURE_COLLECTION_USER
11
+ FEATURE_COLLECTION_USER,
12
12
  ];
13
13
 
14
14
  export const FEATURE_TYPES = {
15
15
  BOOLEAN: 'boolean',
16
16
  NUMBER: 'number',
17
- STRING: 'string'
17
+ STRING: 'string',
18
18
  };
19
19
 
20
20
  // Device constants.
21
21
  export const DEVICE_EVENT_REGISTRATION_SUCCESS = 'registration:success';
22
22
 
23
- export const DEVICE_EVENTS = [
24
- DEVICE_EVENT_REGISTRATION_SUCCESS
25
- ];
23
+ export const DEVICE_EVENTS = [DEVICE_EVENT_REGISTRATION_SUCCESS];