@webex/webex-core 3.8.1 → 3.9.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 (85) hide show
  1. package/README.md +87 -27
  2. package/dist/index.js +9 -33
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/batcher.js +1 -1
  5. package/dist/lib/constants.js +10 -1
  6. package/dist/lib/constants.js.map +1 -1
  7. package/dist/lib/credentials/credentials.js +1 -1
  8. package/dist/lib/credentials/token.js +1 -1
  9. package/dist/lib/{services-v2/interceptors → interceptors}/server-error.js +1 -1
  10. package/dist/lib/interceptors/server-error.js.map +1 -0
  11. package/dist/lib/services/index.js +2 -29
  12. package/dist/lib/services/index.js.map +1 -1
  13. package/dist/lib/services/service-host.js +1 -1
  14. package/dist/lib/services/service-host.js.map +1 -1
  15. package/dist/lib/services/service-registry.js +1 -1
  16. package/dist/lib/services/service-registry.js.map +1 -1
  17. package/dist/lib/services/service-state.js +1 -1
  18. package/dist/lib/services/service-state.js.map +1 -1
  19. package/dist/lib/services/services.js +3 -3
  20. package/dist/lib/services/services.js.map +1 -1
  21. package/dist/lib/services-v2/index.js +0 -29
  22. package/dist/lib/services-v2/index.js.map +1 -1
  23. package/dist/lib/services-v2/metrics.js.map +1 -1
  24. package/dist/lib/services-v2/service-catalog.js +11 -10
  25. package/dist/lib/services-v2/service-catalog.js.map +1 -1
  26. package/dist/lib/services-v2/services-v2.js +56 -67
  27. package/dist/lib/services-v2/services-v2.js.map +1 -1
  28. package/dist/lib/services-v2/types.js.map +1 -1
  29. package/dist/plugins/logger.js +1 -1
  30. package/dist/webex-core.js +3 -3
  31. package/dist/webex-core.js.map +1 -1
  32. package/package.json +13 -13
  33. package/src/index.js +5 -14
  34. package/src/lib/constants.js +29 -1
  35. package/src/lib/{services/interceptors → interceptors}/server-error.js +1 -1
  36. package/src/lib/services/index.js +2 -7
  37. package/src/lib/services/service-host.js +1 -1
  38. package/src/lib/services/service-registry.js +1 -1
  39. package/src/lib/services/service-state.js +1 -1
  40. package/src/lib/services/services.js +2 -2
  41. package/src/lib/services-v2/index.ts +0 -16
  42. package/src/lib/services-v2/service-catalog.ts +20 -19
  43. package/src/lib/services-v2/{services-v2.js → services-v2.ts} +116 -94
  44. package/src/lib/services-v2/types.ts +62 -2
  45. package/src/webex-core.js +1 -1
  46. package/test/fixtures/host-catalog-v2.ts +30 -122
  47. package/test/integration/spec/services/services.js +11 -0
  48. package/test/integration/spec/services-v2/service-catalog.js +664 -0
  49. package/test/integration/spec/services-v2/services-v2.js +1061 -0
  50. package/test/unit/spec/services-v2/service-detail.ts +1 -1
  51. package/test/unit/spec/services-v2/services-v2.ts +390 -436
  52. package/dist/lib/services/constants.js +0 -17
  53. package/dist/lib/services/constants.js.map +0 -1
  54. package/dist/lib/services/interceptors/hostmap.js +0 -64
  55. package/dist/lib/services/interceptors/hostmap.js.map +0 -1
  56. package/dist/lib/services/interceptors/server-error.js +0 -77
  57. package/dist/lib/services/interceptors/server-error.js.map +0 -1
  58. package/dist/lib/services/interceptors/service.js +0 -137
  59. package/dist/lib/services/interceptors/service.js.map +0 -1
  60. package/dist/lib/services-v2/constants.js +0 -17
  61. package/dist/lib/services-v2/constants.js.map +0 -1
  62. package/dist/lib/services-v2/interceptors/server-error.js.map +0 -1
  63. package/dist/lib/services-v2/service-host.js +0 -300
  64. package/dist/lib/services-v2/service-host.js.map +0 -1
  65. package/dist/lib/services-v2/service-registry.js +0 -534
  66. package/dist/lib/services-v2/service-registry.js.map +0 -1
  67. package/dist/lib/services-v2/service-state.js +0 -97
  68. package/dist/lib/services-v2/service-state.js.map +0 -1
  69. package/dist/lib/services-v2/service-url.js +0 -119
  70. package/dist/lib/services-v2/service-url.js.map +0 -1
  71. package/src/lib/services/constants.js +0 -21
  72. package/src/lib/services/interceptors/hostmap.js +0 -36
  73. package/src/lib/services/interceptors/service.js +0 -101
  74. package/src/lib/services-v2/constants.ts +0 -21
  75. package/src/lib/services-v2/interceptors/server-error.js +0 -48
  76. /package/dist/lib/{services-v2/interceptors → interceptors}/hostmap.js +0 -0
  77. /package/dist/lib/{services-v2/interceptors → interceptors}/hostmap.js.map +0 -0
  78. /package/dist/lib/{services-v2/interceptors → interceptors}/service.js +0 -0
  79. /package/dist/lib/{services-v2/interceptors → interceptors}/service.js.map +0 -0
  80. /package/dist/lib/{services/metrics.js → metrics.js} +0 -0
  81. /package/dist/lib/{services/metrics.js.map → metrics.js.map} +0 -0
  82. /package/src/lib/{services-v2/interceptors → interceptors}/hostmap.js +0 -0
  83. /package/src/lib/{services-v2/interceptors → interceptors}/service.js +0 -0
  84. /package/src/lib/{services-v2/metrics.js → metrics.js} +0 -0
  85. /package/src/lib/{services/metrics.js → services-v2/metrics.ts} +0 -0
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
11
- var _constants = require("./constants");
12
- /**
13
- * The state of a specific catalog to be used by {@link ServiceState}.
14
- *
15
- * @typedef {Record<string, boolean>} CatalogState
16
- * @property {boolean} CatalogState.collecting - If the catalog is collecting.
17
- * @property {boolean} CatalogState.ready - If the catalog is ready.
18
- */
19
- /**
20
- * @class
21
- * @classdesc - Manages the state of the service catalogs for a webex instance.
22
- */
23
- var ServiceState = exports.default = /*#__PURE__*/function () {
24
- /**
25
- * Generate a new {@link ServiceState}.
26
- *
27
- * @public
28
- * @constructor
29
- * @memberof ServiceState
30
- */
31
- function ServiceState() {
32
- var _this = this;
33
- (0, _classCallCheck2.default)(this, ServiceState);
34
- // Iterate over the possible catalog names and generate their states.
35
- _constants.SERVICE_CATALOGS.forEach(function (catalog) {
36
- _this[catalog] = ServiceState.generateCatalogState();
37
- });
38
- }
39
-
40
- /**
41
- * Set a catalog to be collecting or not.
42
- *
43
- * @public
44
- * @memberof ServiceState
45
- * @param {string} catalog - Catalog to target.
46
- * @param {boolean} collecting - If the target is collecting or not.
47
- * @returns {undefined}
48
- */
49
- (0, _createClass2.default)(ServiceState, [{
50
- key: "setCollecting",
51
- value: function setCollecting(catalog, collecting) {
52
- // Validate that the catalog state exists.
53
- if (this[catalog]) {
54
- // Set the 'collecting' status of the catalog state.
55
- this[catalog].collecting = collecting;
56
- }
57
- }
58
-
59
- /**
60
- * Set a catalog to be ready or not.
61
- *
62
- * @public
63
- * @memberof ServiceState
64
- * @param {string} catalog - Catalog to target.
65
- * @param {boolean} ready - If the target is ready or not.
66
- * @returns {undefined}
67
- */
68
- }, {
69
- key: "setReady",
70
- value: function setReady(catalog, ready) {
71
- // Validate that the catalog state exists.
72
- if (this[catalog]) {
73
- // Set the 'ready' status of the catalog state.
74
- this[catalog].ready = ready;
75
- }
76
- }
77
-
78
- /**
79
- * Generate a {@link CatalogState}.
80
- *
81
- * @public
82
- * @static
83
- * @memberof ServiceState
84
- * @returns {CatalogState} - The generated {@link CatalogState}.
85
- */
86
- }], [{
87
- key: "generateCatalogState",
88
- value: function generateCatalogState() {
89
- return {
90
- collecting: false,
91
- ready: false
92
- };
93
- }
94
- }]);
95
- return ServiceState;
96
- }();
97
- //# sourceMappingURL=service-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_constants","require","ServiceState","exports","default","_this","_classCallCheck2","SERVICE_CATALOGS","forEach","catalog","generateCatalogState","_createClass2","key","value","setCollecting","collecting","setReady","ready"],"sources":["service-state.js"],"sourcesContent":["import {SERVICE_CATALOGS} from './constants';\n\n/**\n * The state of a specific catalog to be used by {@link ServiceState}.\n *\n * @typedef {Record<string, boolean>} CatalogState\n * @property {boolean} CatalogState.collecting - If the catalog is collecting.\n * @property {boolean} CatalogState.ready - If the catalog is ready.\n */\n\n/**\n * @class\n * @classdesc - Manages the state of the service catalogs for a webex instance.\n */\nexport default class ServiceState {\n /**\n * Generate a new {@link ServiceState}.\n *\n * @public\n * @constructor\n * @memberof ServiceState\n */\n constructor() {\n // Iterate over the possible catalog names and generate their states.\n SERVICE_CATALOGS.forEach((catalog) => {\n this[catalog] = ServiceState.generateCatalogState();\n });\n }\n\n /**\n * Set a catalog to be collecting or not.\n *\n * @public\n * @memberof ServiceState\n * @param {string} catalog - Catalog to target.\n * @param {boolean} collecting - If the target is collecting or not.\n * @returns {undefined}\n */\n setCollecting(catalog, collecting) {\n // Validate that the catalog state exists.\n if (this[catalog]) {\n // Set the 'collecting' status of the catalog state.\n this[catalog].collecting = collecting;\n }\n }\n\n /**\n * Set a catalog to be ready or not.\n *\n * @public\n * @memberof ServiceState\n * @param {string} catalog - Catalog to target.\n * @param {boolean} ready - If the target is ready or not.\n * @returns {undefined}\n */\n setReady(catalog, ready) {\n // Validate that the catalog state exists.\n if (this[catalog]) {\n // Set the 'ready' status of the catalog state.\n this[catalog].ready = ready;\n }\n }\n\n /**\n * Generate a {@link CatalogState}.\n *\n * @public\n * @static\n * @memberof ServiceState\n * @returns {CatalogState} - The generated {@link CatalogState}.\n */\n static generateCatalogState() {\n return {\n collecting: false,\n ready: false,\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAHA,IAIqBC,YAAY,GAAAC,OAAA,CAAAC,OAAA;EAC/B;AACF;AACA;AACA;AACA;AACA;AACA;EACE,SAAAF,aAAA,EAAc;IAAA,IAAAG,KAAA;IAAA,IAAAC,gBAAA,CAAAF,OAAA,QAAAF,YAAA;IACZ;IACAK,2BAAgB,CAACC,OAAO,CAAC,UAACC,OAAO,EAAK;MACpCJ,KAAI,CAACI,OAAO,CAAC,GAAGP,YAAY,CAACQ,oBAAoB,CAAC,CAAC;IACrD,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EARE,IAAAC,aAAA,CAAAP,OAAA,EAAAF,YAAA;IAAAU,GAAA;IAAAC,KAAA,EASA,SAAAC,cAAcL,OAAO,EAAEM,UAAU,EAAE;MACjC;MACA,IAAI,IAAI,CAACN,OAAO,CAAC,EAAE;QACjB;QACA,IAAI,CAACA,OAAO,CAAC,CAACM,UAAU,GAAGA,UAAU;MACvC;IACF;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EARE;IAAAH,GAAA;IAAAC,KAAA,EASA,SAAAG,SAASP,OAAO,EAAEQ,KAAK,EAAE;MACvB;MACA,IAAI,IAAI,CAACR,OAAO,CAAC,EAAE;QACjB;QACA,IAAI,CAACA,OAAO,CAAC,CAACQ,KAAK,GAAGA,KAAK;MAC7B;IACF;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EAPE;IAAAL,GAAA;IAAAC,KAAA,EAQA,SAAAH,qBAAA,EAA8B;MAC5B,OAAO;QACLK,UAAU,EAAE,KAAK;QACjBE,KAAK,EAAE;MACT,CAAC;IACH;EAAC;EAAA,OAAAf,YAAA;AAAA"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _url = _interopRequireDefault(require("url"));
10
- var _ampersandState = _interopRequireDefault(require("ampersand-state"));
11
- /* eslint-disable no-underscore-dangle */
12
- /**
13
- * @class
14
- */
15
- var ServiceUrl = _ampersandState.default.extend({
16
- namespace: 'ServiceUrl',
17
- props: {
18
- defaultUrl: ['string', true, undefined],
19
- hosts: ['array', false, function () {
20
- return [];
21
- }],
22
- name: ['string', true, undefined]
23
- },
24
- /**
25
- * Generate a host url based on the host
26
- * uri provided.
27
- * @param {string} hostUri
28
- * @returns {string}
29
- */
30
- _generateHostUrl: function _generateHostUrl(hostUri) {
31
- var url = _url.default.parse(this.defaultUrl);
32
-
33
- // setting url.hostname will not apply during Url.format(), set host via
34
- // a string literal instead.
35
- url.host = "".concat(hostUri).concat(url.port ? ":".concat(url.port) : '');
36
- return _url.default.format(url);
37
- },
38
- /**
39
- * Generate a list of urls based on this
40
- * `ServiceUrl`'s known hosts.
41
- * @returns {string[]}
42
- */
43
- _getHostUrls: function _getHostUrls() {
44
- var _this = this;
45
- return this.hosts.map(function (host) {
46
- return {
47
- url: _this._generateHostUrl(host.host),
48
- priority: host.priority
49
- };
50
- });
51
- },
52
- /**
53
- * Get the current host url with the highest priority. If a clusterId is not
54
- * provided, this will only return a URL with a filtered host that has the
55
- * `homeCluster` value set to `true`.
56
- *
57
- * @param {string} [clusterId] - The clusterId to filter for a priority host.
58
- * @returns {string} - The priority host url.
59
- */
60
- _getPriorityHostUrl: function _getPriorityHostUrl(clusterId) {
61
- if (this.hosts.length === 0) {
62
- return this.defaultUrl;
63
- }
64
- var filteredHosts = clusterId ? this.hosts.filter(function (host) {
65
- return host.id === clusterId;
66
- }) : this.hosts.filter(function (host) {
67
- return host.homeCluster;
68
- });
69
- var aliveHosts = filteredHosts.filter(function (host) {
70
- return !host.failed;
71
- });
72
- filteredHosts = aliveHosts.length === 0 ? filteredHosts.map(function (host) {
73
- /* eslint-disable-next-line no-param-reassign */
74
- host.failed = false;
75
- return host;
76
- }) : aliveHosts;
77
- return this._generateHostUrl(filteredHosts.reduce(function (previous, current) {
78
- return previous.priority > current.priority || !previous.homeCluster ? current : previous;
79
- }, {}).host);
80
- },
81
- /**
82
- * Attempt to mark a host from this `ServiceUrl` as failed and return true
83
- * if the provided url has a host that could be successfully marked as failed.
84
- *
85
- * @param {string} url
86
- * @returns {boolean}
87
- */
88
- failHost: function failHost(url) {
89
- if (url === this.defaultUrl) {
90
- return true;
91
- }
92
- var _Url$parse = _url.default.parse(url),
93
- hostname = _Url$parse.hostname;
94
- var foundHost = this.hosts.find(function (hostObj) {
95
- return hostObj.host === hostname;
96
- });
97
- if (foundHost) {
98
- foundHost.failed = true;
99
- }
100
- return foundHost !== undefined;
101
- },
102
- /**
103
- * Get the current `defaultUrl` or generate a url using the host with the
104
- * highest priority via host rendering.
105
- *
106
- * @param {boolean} [priorityHost] - Retrieve the priority host.
107
- * @param {string} [clusterId] - Cluster to match a host against.
108
- * @returns {string} - The full service url.
109
- */
110
- get: function get(priorityHost, clusterId) {
111
- if (!priorityHost) {
112
- return this.defaultUrl;
113
- }
114
- return this._getPriorityHostUrl(clusterId);
115
- }
116
- });
117
- /* eslint-enable no-underscore-dangle */
118
- var _default = exports.default = ServiceUrl;
119
- //# sourceMappingURL=service-url.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","ServiceUrl","AmpState","extend","namespace","props","defaultUrl","undefined","hosts","name","_generateHostUrl","hostUri","url","Url","parse","host","concat","port","format","_getHostUrls","_this","map","priority","_getPriorityHostUrl","clusterId","length","filteredHosts","filter","id","homeCluster","aliveHosts","failed","reduce","previous","current","failHost","_Url$parse","hostname","foundHost","find","hostObj","get","priorityHost","_default","exports","default"],"sources":["service-url.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceUrl = AmpState.extend({\n namespace: 'ServiceUrl',\n\n props: {\n defaultUrl: ['string', true, undefined],\n hosts: ['array', false, () => []],\n name: ['string', true, undefined],\n },\n\n /**\n * Generate a host url based on the host\n * uri provided.\n * @param {string} hostUri\n * @returns {string}\n */\n _generateHostUrl(hostUri) {\n const url = Url.parse(this.defaultUrl);\n\n // setting url.hostname will not apply during Url.format(), set host via\n // a string literal instead.\n url.host = `${hostUri}${url.port ? `:${url.port}` : ''}`;\n\n return Url.format(url);\n },\n\n /**\n * Generate a list of urls based on this\n * `ServiceUrl`'s known hosts.\n * @returns {string[]}\n */\n _getHostUrls() {\n return this.hosts.map((host) => ({\n url: this._generateHostUrl(host.host),\n priority: host.priority,\n }));\n },\n\n /**\n * Get the current host url with the highest priority. If a clusterId is not\n * provided, this will only return a URL with a filtered host that has the\n * `homeCluster` value set to `true`.\n *\n * @param {string} [clusterId] - The clusterId to filter for a priority host.\n * @returns {string} - The priority host url.\n */\n _getPriorityHostUrl(clusterId) {\n if (this.hosts.length === 0) {\n return this.defaultUrl;\n }\n\n let filteredHosts = clusterId\n ? this.hosts.filter((host) => host.id === clusterId)\n : this.hosts.filter((host) => host.homeCluster);\n\n const aliveHosts = filteredHosts.filter((host) => !host.failed);\n\n filteredHosts =\n aliveHosts.length === 0\n ? filteredHosts.map((host) => {\n /* eslint-disable-next-line no-param-reassign */\n host.failed = false;\n\n return host;\n })\n : aliveHosts;\n\n return this._generateHostUrl(\n filteredHosts.reduce(\n (previous, current) =>\n previous.priority > current.priority || !previous.homeCluster ? current : previous,\n {}\n ).host\n );\n },\n\n /**\n * Attempt to mark a host from this `ServiceUrl` as failed and return true\n * if the provided url has a host that could be successfully marked as failed.\n *\n * @param {string} url\n * @returns {boolean}\n */\n failHost(url) {\n if (url === this.defaultUrl) {\n return true;\n }\n\n const {hostname} = Url.parse(url);\n const foundHost = this.hosts.find((hostObj) => hostObj.host === hostname);\n\n if (foundHost) {\n foundHost.failed = true;\n }\n\n return foundHost !== undefined;\n },\n\n /**\n * Get the current `defaultUrl` or generate a url using the host with the\n * highest priority via host rendering.\n *\n * @param {boolean} [priorityHost] - Retrieve the priority host.\n * @param {string} [clusterId] - Cluster to match a host against.\n * @returns {string} - The full service url.\n */\n get(priorityHost, clusterId) {\n if (!priorityHost) {\n return this.defaultUrl;\n }\n\n return this._getPriorityHostUrl(clusterId);\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceUrl;\n"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IA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AE;MACbA,SAAS,CAACP,MAAM,GAAG,IAAI;IACzB;IAEA,OAAOO,SAAS,KAAK/B,SAAS;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEkC,GAAG,WAAAA,IAACC,YAAY,EAAElB,SAAS,EAAE;IAC3B,IAAI,CAACkB,YAAY,EAAE;MACjB,OAAO,IAAI,CAACpC,UAAU;IACxB;IAEA,OAAO,IAAI,CAACiB,mBAAmB,CAACC,SAAS,CAAC;EAC5C;AACF,CAAC,CAAC;AACF;AAAA,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEe5C,UAAU"}
@@ -1,21 +0,0 @@
1
- const NAMESPACE = 'services';
2
- const SERVICE_CATALOGS = ['discovery', 'limited', 'signin', 'postauth', 'custom'];
3
-
4
- const SERVICE_CATALOGS_ENUM_TYPES = {
5
- STRING: 'SERVICE_CATALOGS_ENUM_TYPES_STRING',
6
- NUMBER: 'SERVICE_CATALOGS_ENUM_TYPES_NUMBER',
7
- };
8
-
9
- // The default allowed domains that SDK can make requests to outside of service catalog
10
- const COMMERCIAL_ALLOWED_DOMAINS = [
11
- 'wbx2.com',
12
- 'ciscospark.com',
13
- 'webex.com',
14
- 'webexapis.com',
15
- 'broadcloudpbx.com',
16
- 'broadcloud.eu',
17
- 'broadcloud.com.au',
18
- 'broadcloudpbx.net',
19
- ];
20
-
21
- export {SERVICE_CATALOGS_ENUM_TYPES, NAMESPACE, SERVICE_CATALOGS, COMMERCIAL_ALLOWED_DOMAINS};
@@ -1,36 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015-2024 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import {Interceptor} from '@webex/http-core';
6
-
7
- /**
8
- * This interceptor replaces the host in the request uri with the host from the hostmap
9
- * It will attempt to do this for every request, but not all URIs will be in the hostmap
10
- * URIs with hosts that are not in the hostmap will be left unchanged
11
- */
12
- export default class HostMapInterceptor extends Interceptor {
13
- /**
14
- * @returns {HostMapInterceptor}
15
- */
16
- static create() {
17
- return new HostMapInterceptor({webex: this});
18
- }
19
-
20
- /**
21
- * @see Interceptor#onRequest
22
- * @param {Object} options
23
- * @returns {Object}
24
- */
25
- onRequest(options) {
26
- if (options.uri) {
27
- try {
28
- options.uri = this.webex.internal.services.replaceHostFromHostmap(options.uri);
29
- } catch (error) {
30
- /* empty */
31
- }
32
- }
33
-
34
- return options;
35
- }
36
- }
@@ -1,101 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import {Interceptor} from '@webex/http-core';
6
-
7
- const trailingSlashes = /(?:^\/)|(?:\/$)/;
8
-
9
- /**
10
- * @class
11
- */
12
- export default class ServiceInterceptor extends Interceptor {
13
- /**
14
- * @returns {ServiceInterceptor}
15
- */
16
- static create() {
17
- /* eslint no-invalid-this: [0] */
18
- return new ServiceInterceptor({webex: this});
19
- }
20
-
21
- /* eslint-disable no-param-reassign */
22
- /**
23
- * @see Interceptor#onRequest
24
- * @param {Object} options - The request PTO.
25
- * @returns {Object} - The mutated request PTO.
26
- */
27
- onRequest(options) {
28
- // Validate that the PTO includes a uri property.
29
- if (options.uri) {
30
- return options;
31
- }
32
-
33
- // Normalize and validate the PTO.
34
- this.normalizeOptions(options);
35
- this.validateOptions(options);
36
-
37
- // Destructure commonly referenced namespaces.
38
- const {services} = this.webex.internal;
39
- const {service, resource, waitForServiceTimeout} = options;
40
-
41
- // Attempt to collect the service url.
42
- return services
43
- .waitForService({name: service, timeout: waitForServiceTimeout})
44
- .then((serviceUrl) => {
45
- // Generate the combined service url and resource.
46
- options.uri = this.generateUri(serviceUrl, resource);
47
-
48
- return options;
49
- })
50
- .catch(() =>
51
- Promise.reject(new Error(`service-interceptor: '${service}' is not a known service`))
52
- );
53
- }
54
-
55
- /* eslint-disable class-methods-use-this */
56
- /**
57
- * Generate a usable request uri string from a service url and a resouce.
58
- *
59
- * @param {string} serviceUrl - The service url.
60
- * @param {string} [resource] - The resouce to be appended to the service url.
61
- * @returns {string} - The combined service url and resource.
62
- */
63
- generateUri(serviceUrl, resource = '') {
64
- const formattedService = serviceUrl.replace(trailingSlashes, '');
65
- const formattedResource = resource.replace(trailingSlashes, '');
66
-
67
- return `${formattedService}/${formattedResource}`;
68
- }
69
-
70
- /**
71
- * Normalizes request options relative to service identification.
72
- *
73
- * @param {Object} options - The request PTO.
74
- * @returns {Object} - The mutated request PTO.
75
- */
76
- normalizeOptions(options) {
77
- // Validate if the api property is used.
78
- if (options.api) {
79
- // Assign the service property the value of the api property if necessary.
80
- options.service = options.service || options.api;
81
- delete options.api;
82
- }
83
- }
84
-
85
- /**
86
- * Validates that the appropriate options for this interceptor are present.
87
- *
88
- * @param {Object} options - The request PTO.
89
- * @returns {Object} - The mutated request PTO.
90
- */
91
- validateOptions(options) {
92
- if (!options.resource) {
93
- throw new Error('a `resource` parameter is required');
94
- }
95
-
96
- if (!options.service) {
97
- throw new Error("a valid 'service' parameter is required");
98
- }
99
- }
100
- /* eslint-enable class-methods-use-this, no-param-reassign */
101
- }
@@ -1,21 +0,0 @@
1
- const NAMESPACE = 'services';
2
- const SERVICE_CATALOGS = ['discovery', 'limited', 'signin', 'postauth', 'custom'];
3
-
4
- const SERVICE_CATALOGS_ENUM_TYPES = {
5
- STRING: 'SERVICE_CATALOGS_ENUM_TYPES_STRING',
6
- NUMBER: 'SERVICE_CATALOGS_ENUM_TYPES_NUMBER',
7
- };
8
-
9
- // The default allowed domains that SDK can make requests to outside of service catalog
10
- const COMMERCIAL_ALLOWED_DOMAINS = [
11
- 'wbx2.com',
12
- 'ciscospark.com',
13
- 'webex.com',
14
- 'webexapis.com',
15
- 'broadcloudpbx.com',
16
- 'broadcloud.eu',
17
- 'broadcloud.com.au',
18
- 'broadcloudpbx.net',
19
- ];
20
-
21
- export {SERVICE_CATALOGS_ENUM_TYPES, NAMESPACE, SERVICE_CATALOGS, COMMERCIAL_ALLOWED_DOMAINS};
@@ -1,48 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import {Interceptor} from '@webex/http-core';
6
- import WebexHttpError from '../../webex-http-error';
7
- /**
8
- * Changes server url when it fails
9
- */
10
- export default class ServerErrorInterceptor extends Interceptor {
11
- /**
12
- * @returns {HAMessagingInterceptor}
13
- */
14
- static create() {
15
- // eslint-disable-next-line no-invalid-this
16
- return new ServerErrorInterceptor({webex: this});
17
- }
18
-
19
- /**
20
- * @see Interceptor#onResponseError
21
- * @param {Object} options
22
- * @param {Object} reason
23
- * @returns {Object}
24
- */
25
- onResponseError(options, reason) {
26
- if (
27
- (reason instanceof WebexHttpError.InternalServerError ||
28
- reason instanceof WebexHttpError.BadGateway ||
29
- reason instanceof WebexHttpError.ServiceUnavailable) &&
30
- options.uri
31
- ) {
32
- const feature = this.webex.internal.device.features.developer.get('web-high-availability');
33
-
34
- if (feature && feature.value) {
35
- this.webex.internal.metrics.submitClientMetrics('web-ha', {
36
- fields: {success: false},
37
- tags: {action: 'failed', error: reason.message, url: options.uri},
38
- });
39
-
40
- return Promise.resolve(this.webex.internal.services.markFailedUrl(options.uri)).then(() =>
41
- Promise.reject(reason)
42
- );
43
- }
44
- }
45
-
46
- return Promise.reject(reason);
47
- }
48
- }
File without changes
File without changes