@webex/webex-core 3.0.0-beta.283 → 3.0.0-beta.285
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/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/interceptors/service.js +4 -2
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/service-catalog.js +2 -1
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/package.json +14 -14
- package/src/lib/services/interceptors/service.js +2 -2
- package/src/lib/services/service-catalog.js +3 -1
- package/test/unit/spec/services/interceptors/service.js +9 -3
package/dist/lib/batcher.js
CHANGED
|
@@ -282,7 +282,7 @@ var Batcher = _webexPlugin.default.extend({
|
|
|
282
282
|
fingerprintResponse: function fingerprintResponse(item) {
|
|
283
283
|
throw new Error('fingerprintResponse() must be implemented');
|
|
284
284
|
},
|
|
285
|
-
version: "3.0.0-beta.
|
|
285
|
+
version: "3.0.0-beta.285"
|
|
286
286
|
});
|
|
287
287
|
var _default2 = Batcher;
|
|
288
288
|
exports.default = _default2;
|
|
@@ -558,7 +558,7 @@ var Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
558
558
|
this.refresh();
|
|
559
559
|
}
|
|
560
560
|
},
|
|
561
|
-
version: "3.0.0-beta.
|
|
561
|
+
version: "3.0.0-beta.285"
|
|
562
562
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "getUserToken", [_dec, _dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "getUserToken"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "initialize", [_dec3], (0, _getOwnPropertyDescriptor.default)(_obj, "initialize"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "invalidate", [_common.oneFlight, _dec4], (0, _getOwnPropertyDescriptor.default)(_obj, "invalidate"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight, _dec5, _dec6], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj)), _obj)));
|
|
563
563
|
var _default = Credentials;
|
|
564
564
|
exports.default = _default;
|
|
@@ -527,7 +527,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
527
527
|
return res.body;
|
|
528
528
|
});
|
|
529
529
|
},
|
|
530
|
-
version: "3.0.0-beta.
|
|
530
|
+
version: "3.0.0-beta.285"
|
|
531
531
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "downscope", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "downscope"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "refresh", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "refresh"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "revoke", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "revoke"), _obj)), _obj)));
|
|
532
532
|
var _default = Token;
|
|
533
533
|
exports.default = _default;
|
|
@@ -50,11 +50,13 @@ var ServiceInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
|
50
50
|
// Destructure commonly referenced namespaces.
|
|
51
51
|
var services = this.webex.internal.services;
|
|
52
52
|
var service = options.service,
|
|
53
|
-
resource = options.resource
|
|
53
|
+
resource = options.resource,
|
|
54
|
+
waitForServiceTimeout = options.waitForServiceTimeout;
|
|
54
55
|
|
|
55
56
|
// Attempt to collect the service url.
|
|
56
57
|
return services.waitForService({
|
|
57
|
-
name: service
|
|
58
|
+
name: service,
|
|
59
|
+
timeout: waitForServiceTimeout
|
|
58
60
|
}).then(function (serviceUrl) {
|
|
59
61
|
// Generate the combined service url and resource.
|
|
60
62
|
options.uri = _this.generateUri(serviceUrl, resource);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["trailingSlashes","ServiceInterceptor","options","uri","normalizeOptions","validateOptions","services","webex","internal","service","resource","waitForService","name","then","serviceUrl","generateUri","catch","reject","Error","formattedService","replace","formattedResource","api","Interceptor"],"sources":["service.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nconst trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n/**\n * @class\n */\nexport default class ServiceInterceptor extends Interceptor {\n /**\n * @returns {ServiceInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new ServiceInterceptor({webex: this});\n }\n\n /* eslint-disable no-param-reassign */\n /**\n * @see Interceptor#onRequest\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n onRequest(options) {\n // Validate that the PTO includes a uri property.\n if (options.uri) {\n return options;\n }\n\n // Normalize and validate the PTO.\n this.normalizeOptions(options);\n this.validateOptions(options);\n\n // Destructure commonly referenced namespaces.\n const {services} = this.webex.internal;\n const {service, resource} = options;\n\n // Attempt to collect the service url.\n return services\n .waitForService({name: service})\n .then((serviceUrl) => {\n // Generate the combined service url and resource.\n options.uri = this.generateUri(serviceUrl, resource);\n\n return options;\n })\n .catch(() =>\n Promise.reject(new Error(`service-interceptor: '${service}' is not a known service`))\n );\n }\n\n /* eslint-disable class-methods-use-this */\n /**\n * Generate a usable request uri string from a service url and a resouce.\n *\n * @param {string} serviceUrl - The service url.\n * @param {string} [resource] - The resouce to be appended to the service url.\n * @returns {string} - The combined service url and resource.\n */\n generateUri(serviceUrl, resource = '') {\n const formattedService = serviceUrl.replace(trailingSlashes, '');\n const formattedResource = resource.replace(trailingSlashes, '');\n\n return `${formattedService}/${formattedResource}`;\n }\n\n /**\n * Normalizes request options relative to service identification.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n normalizeOptions(options) {\n // Validate if the api property is used.\n if (options.api) {\n // Assign the service property the value of the api property if necessary.\n options.service = options.service || options.api;\n delete options.api;\n }\n }\n\n /**\n * Validates that the appropriate options for this interceptor are present.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n validateOptions(options) {\n if (!options.resource) {\n throw new Error('a `resource` parameter is required');\n }\n\n if (!options.service) {\n throw new Error(\"a valid 'service' parameter is required\");\n }\n }\n /* eslint-enable class-methods-use-this, no-param-reassign */\n}\n"],"mappings":";;;;;;;;;;;;;;;AAIA;AAA6C;AAAA;AAE7C,IAAMA,eAAe,GAAG,iBAAiB;;AAEzC;AACA;AACA;AAFA,IAGqBC,kBAAkB;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA,OASrC;IACA;AACF;AACA;AACA;AACA;IACE,mBAAUC,OAAO,EAAE;MAAA;MACjB;MACA,IAAIA,OAAO,CAACC,GAAG,EAAE;QACf,OAAOD,OAAO;MAChB;;MAEA;MACA,IAAI,CAACE,gBAAgB,CAACF,OAAO,CAAC;MAC9B,IAAI,CAACG,eAAe,CAACH,OAAO,CAAC;;MAE7B;MACA,IAAOI,QAAQ,GAAI,IAAI,CAACC,KAAK,CAACC,QAAQ,CAA/BF,QAAQ;MACf,IAAOG,OAAO,
|
|
1
|
+
{"version":3,"names":["trailingSlashes","ServiceInterceptor","options","uri","normalizeOptions","validateOptions","services","webex","internal","service","resource","waitForServiceTimeout","waitForService","name","timeout","then","serviceUrl","generateUri","catch","reject","Error","formattedService","replace","formattedResource","api","Interceptor"],"sources":["service.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nconst trailingSlashes = /(?:^\\/)|(?:\\/$)/;\n\n/**\n * @class\n */\nexport default class ServiceInterceptor extends Interceptor {\n /**\n * @returns {ServiceInterceptor}\n */\n static create() {\n /* eslint no-invalid-this: [0] */\n return new ServiceInterceptor({webex: this});\n }\n\n /* eslint-disable no-param-reassign */\n /**\n * @see Interceptor#onRequest\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n onRequest(options) {\n // Validate that the PTO includes a uri property.\n if (options.uri) {\n return options;\n }\n\n // Normalize and validate the PTO.\n this.normalizeOptions(options);\n this.validateOptions(options);\n\n // Destructure commonly referenced namespaces.\n const {services} = this.webex.internal;\n const {service, resource, waitForServiceTimeout} = options;\n\n // Attempt to collect the service url.\n return services\n .waitForService({name: service, timeout: waitForServiceTimeout})\n .then((serviceUrl) => {\n // Generate the combined service url and resource.\n options.uri = this.generateUri(serviceUrl, resource);\n\n return options;\n })\n .catch(() =>\n Promise.reject(new Error(`service-interceptor: '${service}' is not a known service`))\n );\n }\n\n /* eslint-disable class-methods-use-this */\n /**\n * Generate a usable request uri string from a service url and a resouce.\n *\n * @param {string} serviceUrl - The service url.\n * @param {string} [resource] - The resouce to be appended to the service url.\n * @returns {string} - The combined service url and resource.\n */\n generateUri(serviceUrl, resource = '') {\n const formattedService = serviceUrl.replace(trailingSlashes, '');\n const formattedResource = resource.replace(trailingSlashes, '');\n\n return `${formattedService}/${formattedResource}`;\n }\n\n /**\n * Normalizes request options relative to service identification.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n normalizeOptions(options) {\n // Validate if the api property is used.\n if (options.api) {\n // Assign the service property the value of the api property if necessary.\n options.service = options.service || options.api;\n delete options.api;\n }\n }\n\n /**\n * Validates that the appropriate options for this interceptor are present.\n *\n * @param {Object} options - The request PTO.\n * @returns {Object} - The mutated request PTO.\n */\n validateOptions(options) {\n if (!options.resource) {\n throw new Error('a `resource` parameter is required');\n }\n\n if (!options.service) {\n throw new Error(\"a valid 'service' parameter is required\");\n }\n }\n /* eslint-enable class-methods-use-this, no-param-reassign */\n}\n"],"mappings":";;;;;;;;;;;;;;;AAIA;AAA6C;AAAA;AAE7C,IAAMA,eAAe,GAAG,iBAAiB;;AAEzC;AACA;AACA;AAFA,IAGqBC,kBAAkB;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;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E;MACxB;MACA,IAAIA,OAAO,CAACsB,GAAG,EAAE;QACf;QACAtB,OAAO,CAACO,OAAO,GAAGP,OAAO,CAACO,OAAO,IAAIP,OAAO,CAACsB,GAAG;QAChD,OAAOtB,OAAO,CAACsB,GAAG;MACpB;IACF;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,yBAAgBtB,OAAO,EAAE;MACvB,IAAI,CAACA,OAAO,CAACQ,QAAQ,EAAE;QACrB,MAAM,IAAIU,KAAK,CAAC,oCAAoC,CAAC;MACvD;MAEA,IAAI,CAAClB,OAAO,CAACO,OAAO,EAAE;QACpB,MAAM,IAAIW,KAAK,CAAC,yCAAyC,CAAC;MAC5D;IACF;IACA;EAAA;IAAA;IAAA;IAvFA;AACF;AACA;IACE,kBAAgB;MACd;MACA,OAAO,IAAInB,kBAAkB,CAAC;QAACM,KAAK,EAAE;MAAI,CAAC,CAAC;IAC9C;EAAC;EAAA;AAAA,EAP6CkB,qBAAW;AAAA"}
|
|
@@ -393,9 +393,10 @@ var ServiceCatalog = _ampersandState.default.extend({
|
|
|
393
393
|
if (_this5.status[serviceGroup].ready) {
|
|
394
394
|
resolve();
|
|
395
395
|
}
|
|
396
|
+
var validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;
|
|
396
397
|
var timeoutTimer = setTimeout(function () {
|
|
397
398
|
return reject(new Error("services: timeout occured while waiting for '".concat(serviceGroup, "' catalog to populate")));
|
|
398
|
-
},
|
|
399
|
+
}, validatedTimeout * 1000);
|
|
399
400
|
_this5.once(serviceGroup, function () {
|
|
400
401
|
clearTimeout(timeoutTimer);
|
|
401
402
|
resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","name","serviceGroup","serviceUrls","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","existingService","forEach","service","push","_unloadServiceUrls","splice","indexOf","clean","length","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","key","defaultUrl","hosts","host","hostname","id","homeCluster","undefined","findServiceFromClusterId","clusterId","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","failHost","setAllowedDomains","updateServiceUrls","serviceHostmap","currentServiceUrls","unusedUrls","filter","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","resolve","reject","timeoutTimer","setTimeout","Error","once","clearTimeout"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport ServiceUrl from './service-url';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceCatalog = AmpState.extend({\n namespace: 'ServiceCatalog',\n\n props: {\n serviceGroups: [\n 'object',\n true,\n () => ({\n discovery: [],\n override: [],\n preauth: [],\n postauth: [],\n signin: [],\n }),\n ],\n status: [\n 'object',\n true,\n () => ({\n discovery: {\n ready: false,\n collecting: false,\n },\n override: {\n ready: false,\n collecting: false,\n },\n preauth: {\n ready: false,\n collecting: false,\n },\n postauth: {\n ready: false,\n collecting: false,\n },\n signin: {\n ready: false,\n collecting: false,\n },\n }),\n ],\n isReady: ['boolean', false, false],\n allowedDomains: ['array', false, () => []],\n },\n\n /**\n * @private\n * Search the service url array to locate a `ServiceUrl`\n * class object based on its name.\n * @param {string} name\n * @param {string} [serviceGroup]\n * @returns {ServiceUrl}\n */\n _getUrl(name, serviceGroup) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n return serviceUrls.find((serviceUrl) => serviceUrl.name === name);\n },\n\n /**\n * @private\n * Generate an array of `ServiceUrl`s that is organized from highest auth\n * level to lowest auth level.\n * @returns {Array<ServiceUrl>} - array of `ServiceUrl`s\n */\n _listServiceUrls() {\n return [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n },\n\n /**\n * @private\n * Safely load one or more `ServiceUrl`s into this `Services` instance.\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _loadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (!existingService) {\n this.serviceGroups[serviceGroup].push(service);\n }\n });\n\n return this;\n },\n\n /**\n * @private\n * Safely unload one or more `ServiceUrl`s into this `Services` instance\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _unloadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (existingService) {\n this.serviceGroups[serviceGroup].splice(\n this.serviceGroups[serviceGroup].indexOf(existingService),\n 1\n );\n }\n });\n\n return this;\n },\n\n /**\n * Clear all collected catalog data and reset catalog status.\n *\n * @returns {void}\n */\n clean() {\n this.serviceGroups.preauth.length = 0;\n this.serviceGroups.signin.length = 0;\n this.serviceGroups.postauth.length = 0;\n this.status.preauth = {ready: false};\n this.status.signin = {ready: false};\n this.status.postauth = {ready: false};\n },\n\n /**\n * Search over all service groups to find a cluster id based\n * on a given url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {string} - ClusterId of a given url\n */\n findClusterId(url) {\n const incomingUrlObj = Url.parse(url);\n let serviceUrlObj;\n\n for (const key of Object.keys(this.serviceGroups)) {\n for (const service of this.serviceGroups[key]) {\n serviceUrlObj = Url.parse(service.defaultUrl);\n\n for (const host of service.hosts) {\n if (incomingUrlObj.hostname === host.host && host.id) {\n return host.id;\n }\n }\n\n if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {\n // no exact match, so try to grab the first home cluster\n for (const host of service.hosts) {\n if (host.homeCluster) {\n return host.id;\n }\n }\n\n // no match found still, so return the first entry\n return service.hosts[0].id;\n }\n }\n }\n\n return undefined;\n },\n\n /**\n * Search over all service groups and return a service value from a provided\n * clusterId. Currently, this method will return either a service name, or a\n * service url depending on the `value` parameter. If the `value` parameter\n * is set to `name`, it will return a service name to be utilized within the\n * Services plugin methods.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost = true] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n const identifiedServiceUrl = serviceUrls.find((serviceUrl) =>\n serviceUrl.hosts.find((host) => host.id === clusterId)\n );\n\n if (identifiedServiceUrl) {\n return {\n name: identifiedServiceUrl.name,\n url: identifiedServiceUrl.get(priorityHost, clusterId),\n };\n }\n\n return undefined;\n },\n\n /**\n * Find a service based on the provided url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {serviceUrl} - ServiceUrl assocated with provided url\n */\n findServiceUrlFromUrl(url) {\n const incomingUrlObj = Url.parse(url);\n const serviceUrls = [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n return serviceUrls.find((serviceUrl) => {\n if (incomingUrlObj.hostname === Url.parse(serviceUrl.defaultUrl).hostname) {\n return true;\n }\n\n if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.hostname)) {\n return true;\n }\n\n return false;\n });\n },\n\n /**\n * Finds an allowed domain that matches a specific url.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @returns {string} - The matching allowed domain.\n */\n findAllowedDomain(url) {\n const urlObj = Url.parse(url);\n\n if (!urlObj.host) {\n return undefined;\n }\n\n return this.allowedDomains.find((allowedDomain) => urlObj.host.includes(allowedDomain));\n },\n\n /**\n * Get a service url from the current services list by name.\n * @param {string} name\n * @param {boolean} priorityHost\n * @param {string} serviceGroup\n * @returns {string}\n */\n get(name, priorityHost, serviceGroup) {\n const serviceUrl = this._getUrl(name, serviceGroup);\n\n return serviceUrl ? serviceUrl.get(priorityHost) : undefined;\n },\n\n /**\n * Get the current allowed domains list.\n *\n * @returns {Array<string>} - the current allowed domains list.\n */\n getAllowedDomains() {\n return [...this.allowedDomains];\n },\n\n /**\n * Creates an object where the keys are the service names\n * and the values are the service urls.\n * @param {boolean} priorityHost - use the highest priority if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list(priorityHost, serviceGroup) {\n const output = {};\n\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n if (serviceUrls) {\n serviceUrls.forEach((serviceUrl) => {\n output[serviceUrl.name] = serviceUrl.get(priorityHost);\n });\n }\n\n return output;\n },\n\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl(url, noPriorityHosts) {\n const serviceUrl = this._getUrl(\n Object.keys(this.list()).find((key) => this._getUrl(key).failHost(url))\n );\n\n if (!serviceUrl) {\n return undefined;\n }\n\n return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);\n },\n\n /**\n * Set the allowed domains for the catalog.\n *\n * @param {Array<string>} allowedDomains - allowed domains to be assigned.\n * @returns {void}\n */\n setAllowedDomains(allowedDomains) {\n this.allowedDomains = [...allowedDomains];\n },\n\n /**\n * Update the current list of `ServiceUrl`s against a provided\n * service hostmap.\n * @emits ServiceCatalog#preauthorized\n * @emits ServiceCatalog#postauthorized\n * @param {string} serviceGroup\n * @param {object} serviceHostmap\n * @returns {Services}\n */\n updateServiceUrls(serviceGroup, serviceHostmap) {\n const currentServiceUrls = this.serviceGroups[serviceGroup];\n\n const unusedUrls = currentServiceUrls.filter((serviceUrl) =>\n serviceHostmap.every((item) => item.name !== serviceUrl.name)\n );\n\n this._unloadServiceUrls(serviceGroup, unusedUrls);\n\n serviceHostmap.forEach((serviceObj) => {\n const service = this._getUrl(serviceObj.name, serviceGroup);\n\n if (service) {\n service.defaultUrl = serviceObj.defaultUrl;\n service.hosts = serviceObj.hosts || [];\n } else {\n this._loadServiceUrls(serviceGroup, [\n new ServiceUrl({\n ...serviceObj,\n }),\n ]);\n }\n });\n\n this.status[serviceGroup].ready = true;\n this.trigger(serviceGroup);\n\n return this;\n },\n\n /**\n * Wait until the service catalog is available,\n * or reject after a timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog(serviceGroup, timeout) {\n return new Promise((resolve, reject) => {\n if (this.status[serviceGroup].ready) {\n resolve();\n }\n\n const timeoutTimer = setTimeout(\n () =>\n reject(\n new Error(\n `services: timeout occured while waiting for '${serviceGroup}' catalog to populate`\n )\n ),\n timeout ? timeout * 1000 : 60000\n );\n\n this.once(serviceGroup, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceCatalog;\n"],"mappings":";;;;;;;;;;;;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E,CAClC,IAAIuD,mBAAU,mBACTD,UAAU,EACb,CACH,CAAC;MACJ;IACF,CAAC,CAAC;IAEF,IAAI,CAAC7D,MAAM,CAACO,YAAY,CAAC,CAACN,KAAK,GAAG,IAAI;IACtC,IAAI,CAAC8D,OAAO,CAACxD,YAAY,CAAC;IAE1B,OAAO,IAAI;EACb,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEyD,cAAc,0BAACzD,YAAY,EAAE0D,OAAO,EAAE;IAAA;IACpC,OAAO,qBAAY,UAACC,OAAO,EAAEC,MAAM,EAAK;MACtC,IAAI,MAAI,CAACnE,MAAM,CAACO,YAAY,CAAC,CAACN,KAAK,EAAE;QACnCiE,OAAO,EAAE;MACX;MAEA,IAAME,YAAY,GAAGC,UAAU,CAC7B;QAAA,OACEF,MAAM,CACJ,IAAIG,KAAK,wDACyC/D,YAAY,2BAC7D,CACF;MAAA,GACH0D,OAAO,GAAGA,OAAO,GAAG,IAAI,GAAG,KAAK,CACjC;MAED,MAAI,CAACM,IAAI,CAAChE,YAAY,EAAE,YAAM;QAC5BiE,YAAY,CAACJ,YAAY,CAAC;QAC1BF,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF,CAAC,CAAC;AACF;AAAA,eAEe7E,cAAc;AAAA"}
|
|
1
|
+
{"version":3,"names":["ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","name","serviceGroup","serviceUrls","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","existingService","forEach","service","push","_unloadServiceUrls","splice","indexOf","clean","length","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","key","defaultUrl","hosts","host","hostname","id","homeCluster","undefined","findServiceFromClusterId","clusterId","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","failHost","setAllowedDomains","updateServiceUrls","serviceHostmap","currentServiceUrls","unusedUrls","filter","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","resolve","reject","validatedTimeout","timeoutTimer","setTimeout","Error","once","clearTimeout"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport ServiceUrl from './service-url';\n\n/* eslint-disable no-underscore-dangle */\n/**\n * @class\n */\nconst ServiceCatalog = AmpState.extend({\n namespace: 'ServiceCatalog',\n\n props: {\n serviceGroups: [\n 'object',\n true,\n () => ({\n discovery: [],\n override: [],\n preauth: [],\n postauth: [],\n signin: [],\n }),\n ],\n status: [\n 'object',\n true,\n () => ({\n discovery: {\n ready: false,\n collecting: false,\n },\n override: {\n ready: false,\n collecting: false,\n },\n preauth: {\n ready: false,\n collecting: false,\n },\n postauth: {\n ready: false,\n collecting: false,\n },\n signin: {\n ready: false,\n collecting: false,\n },\n }),\n ],\n isReady: ['boolean', false, false],\n allowedDomains: ['array', false, () => []],\n },\n\n /**\n * @private\n * Search the service url array to locate a `ServiceUrl`\n * class object based on its name.\n * @param {string} name\n * @param {string} [serviceGroup]\n * @returns {ServiceUrl}\n */\n _getUrl(name, serviceGroup) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n return serviceUrls.find((serviceUrl) => serviceUrl.name === name);\n },\n\n /**\n * @private\n * Generate an array of `ServiceUrl`s that is organized from highest auth\n * level to lowest auth level.\n * @returns {Array<ServiceUrl>} - array of `ServiceUrl`s\n */\n _listServiceUrls() {\n return [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n },\n\n /**\n * @private\n * Safely load one or more `ServiceUrl`s into this `Services` instance.\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _loadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (!existingService) {\n this.serviceGroups[serviceGroup].push(service);\n }\n });\n\n return this;\n },\n\n /**\n * @private\n * Safely unload one or more `ServiceUrl`s into this `Services` instance\n * @param {string} serviceGroup\n * @param {Array<ServiceUrl>} services\n * @returns {Services}\n */\n _unloadServiceUrls(serviceGroup, services) {\n // declare namespaces outside of loop\n let existingService;\n\n services.forEach((service) => {\n existingService = this._getUrl(service.name, serviceGroup);\n\n if (existingService) {\n this.serviceGroups[serviceGroup].splice(\n this.serviceGroups[serviceGroup].indexOf(existingService),\n 1\n );\n }\n });\n\n return this;\n },\n\n /**\n * Clear all collected catalog data and reset catalog status.\n *\n * @returns {void}\n */\n clean() {\n this.serviceGroups.preauth.length = 0;\n this.serviceGroups.signin.length = 0;\n this.serviceGroups.postauth.length = 0;\n this.status.preauth = {ready: false};\n this.status.signin = {ready: false};\n this.status.postauth = {ready: false};\n },\n\n /**\n * Search over all service groups to find a cluster id based\n * on a given url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {string} - ClusterId of a given url\n */\n findClusterId(url) {\n const incomingUrlObj = Url.parse(url);\n let serviceUrlObj;\n\n for (const key of Object.keys(this.serviceGroups)) {\n for (const service of this.serviceGroups[key]) {\n serviceUrlObj = Url.parse(service.defaultUrl);\n\n for (const host of service.hosts) {\n if (incomingUrlObj.hostname === host.host && host.id) {\n return host.id;\n }\n }\n\n if (serviceUrlObj.hostname === incomingUrlObj.hostname && service.hosts.length > 0) {\n // no exact match, so try to grab the first home cluster\n for (const host of service.hosts) {\n if (host.homeCluster) {\n return host.id;\n }\n }\n\n // no match found still, so return the first entry\n return service.hosts[0].id;\n }\n }\n }\n\n return undefined;\n },\n\n /**\n * Search over all service groups and return a service value from a provided\n * clusterId. Currently, this method will return either a service name, or a\n * service url depending on the `value` parameter. If the `value` parameter\n * is set to `name`, it will return a service name to be utilized within the\n * Services plugin methods.\n * @param {object} params\n * @param {string} params.clusterId - clusterId of found service\n * @param {boolean} [params.priorityHost = true] - returns priority host url if true\n * @param {string} [params.serviceGroup] - specify service group\n * @returns {object} service\n * @returns {string} service.name\n * @returns {string} service.url\n */\n findServiceFromClusterId({clusterId, priorityHost = true, serviceGroup} = {}) {\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.override,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.discovery,\n ];\n\n const identifiedServiceUrl = serviceUrls.find((serviceUrl) =>\n serviceUrl.hosts.find((host) => host.id === clusterId)\n );\n\n if (identifiedServiceUrl) {\n return {\n name: identifiedServiceUrl.name,\n url: identifiedServiceUrl.get(priorityHost, clusterId),\n };\n }\n\n return undefined;\n },\n\n /**\n * Find a service based on the provided url.\n * @param {string} url - Must be parsable by `Url`\n * @returns {serviceUrl} - ServiceUrl assocated with provided url\n */\n findServiceUrlFromUrl(url) {\n const incomingUrlObj = Url.parse(url);\n const serviceUrls = [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n return serviceUrls.find((serviceUrl) => {\n if (incomingUrlObj.hostname === Url.parse(serviceUrl.defaultUrl).hostname) {\n return true;\n }\n\n if (serviceUrl.hosts.find((host) => host.host === incomingUrlObj.hostname)) {\n return true;\n }\n\n return false;\n });\n },\n\n /**\n * Finds an allowed domain that matches a specific url.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @returns {string} - The matching allowed domain.\n */\n findAllowedDomain(url) {\n const urlObj = Url.parse(url);\n\n if (!urlObj.host) {\n return undefined;\n }\n\n return this.allowedDomains.find((allowedDomain) => urlObj.host.includes(allowedDomain));\n },\n\n /**\n * Get a service url from the current services list by name.\n * @param {string} name\n * @param {boolean} priorityHost\n * @param {string} serviceGroup\n * @returns {string}\n */\n get(name, priorityHost, serviceGroup) {\n const serviceUrl = this._getUrl(name, serviceGroup);\n\n return serviceUrl ? serviceUrl.get(priorityHost) : undefined;\n },\n\n /**\n * Get the current allowed domains list.\n *\n * @returns {Array<string>} - the current allowed domains list.\n */\n getAllowedDomains() {\n return [...this.allowedDomains];\n },\n\n /**\n * Creates an object where the keys are the service names\n * and the values are the service urls.\n * @param {boolean} priorityHost - use the highest priority if set to `true`\n * @param {string} [serviceGroup]\n * @returns {Record<string, string>}\n */\n list(priorityHost, serviceGroup) {\n const output = {};\n\n const serviceUrls =\n typeof serviceGroup === 'string'\n ? this.serviceGroups[serviceGroup] || []\n : [\n ...this.serviceGroups.discovery,\n ...this.serviceGroups.preauth,\n ...this.serviceGroups.signin,\n ...this.serviceGroups.postauth,\n ...this.serviceGroups.override,\n ];\n\n if (serviceUrls) {\n serviceUrls.forEach((serviceUrl) => {\n output[serviceUrl.name] = serviceUrl.get(priorityHost);\n });\n }\n\n return output;\n },\n\n /**\n * Mark a priority host service url as failed.\n * This will mark the host associated with the\n * `ServiceUrl` to be removed from the its\n * respective host array, and then return the next\n * viable host from the `ServiceUrls` host array,\n * or the `ServiceUrls` default url if no other priority\n * hosts are available, or if `noPriorityHosts` is set to\n * `true`.\n * @param {string} url\n * @param {boolean} noPriorityHosts\n * @returns {string}\n */\n markFailedUrl(url, noPriorityHosts) {\n const serviceUrl = this._getUrl(\n Object.keys(this.list()).find((key) => this._getUrl(key).failHost(url))\n );\n\n if (!serviceUrl) {\n return undefined;\n }\n\n return noPriorityHosts ? serviceUrl.get(false) : serviceUrl.get(true);\n },\n\n /**\n * Set the allowed domains for the catalog.\n *\n * @param {Array<string>} allowedDomains - allowed domains to be assigned.\n * @returns {void}\n */\n setAllowedDomains(allowedDomains) {\n this.allowedDomains = [...allowedDomains];\n },\n\n /**\n * Update the current list of `ServiceUrl`s against a provided\n * service hostmap.\n * @emits ServiceCatalog#preauthorized\n * @emits ServiceCatalog#postauthorized\n * @param {string} serviceGroup\n * @param {object} serviceHostmap\n * @returns {Services}\n */\n updateServiceUrls(serviceGroup, serviceHostmap) {\n const currentServiceUrls = this.serviceGroups[serviceGroup];\n\n const unusedUrls = currentServiceUrls.filter((serviceUrl) =>\n serviceHostmap.every((item) => item.name !== serviceUrl.name)\n );\n\n this._unloadServiceUrls(serviceGroup, unusedUrls);\n\n serviceHostmap.forEach((serviceObj) => {\n const service = this._getUrl(serviceObj.name, serviceGroup);\n\n if (service) {\n service.defaultUrl = serviceObj.defaultUrl;\n service.hosts = serviceObj.hosts || [];\n } else {\n this._loadServiceUrls(serviceGroup, [\n new ServiceUrl({\n ...serviceObj,\n }),\n ]);\n }\n });\n\n this.status[serviceGroup].ready = true;\n this.trigger(serviceGroup);\n\n return this;\n },\n\n /**\n * Wait until the service catalog is available,\n * or reject after a timeout of 60 seconds.\n * @param {string} serviceGroup\n * @param {number} [timeout] - in seconds\n * @returns {Promise<void>}\n */\n waitForCatalog(serviceGroup, timeout) {\n return new Promise((resolve, reject) => {\n if (this.status[serviceGroup].ready) {\n resolve();\n }\n\n const validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;\n\n const timeoutTimer = setTimeout(\n () =>\n reject(\n new Error(\n `services: timeout occured while waiting for '${serviceGroup}' catalog to populate`\n )\n ),\n validatedTimeout * 1000\n );\n\n this.once(serviceGroup, () => {\n clearTimeout(timeoutTimer);\n resolve();\n });\n });\n },\n});\n/* eslint-enable no-underscore-dangle */\n\nexport default ServiceCatalog;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAEA;AAEA;AAAuC;AAAA;AAAA;AAAA;AAAA;AAEvC;AACA;AACA;AACA;AACA,IAAMA,cAAc,GAAGC,uBAAQ,CAACC,MAAM,CAAC;EACrCC,SAAS,EAAE,gBAAgB;EAE3BC,KAAK,EAAE;IACL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AAC;IAE1B,OAAO,IAAI;EACb,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEyD,cAAc,0BAACzD,YAAY,EAAE0D,OAAO,EAAE;IAAA;IACpC,OAAO,qBAAY,UAACC,OAAO,EAAEC,MAAM,EAAK;MACtC,IAAI,MAAI,CAACnE,MAAM,CAACO,YAAY,CAAC,CAACN,KAAK,EAAE;QACnCiE,OAAO,EAAE;MACX;MAEA,IAAME,gBAAgB,GAAG,OAAOH,OAAO,KAAK,QAAQ,IAAIA,OAAO,IAAI,CAAC,GAAGA,OAAO,GAAG,EAAE;MAEnF,IAAMI,YAAY,GAAGC,UAAU,CAC7B;QAAA,OACEH,MAAM,CACJ,IAAII,KAAK,wDACyChE,YAAY,2BAC7D,CACF;MAAA,GACH6D,gBAAgB,GAAG,IAAI,CACxB;MAED,MAAI,CAACI,IAAI,CAACjE,YAAY,EAAE,YAAM;QAC5BkE,YAAY,CAACJ,YAAY,CAAC;QAC1BH,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF,CAAC,CAAC;AACF;AAAA,eAEe7E,cAAc;AAAA"}
|
package/dist/plugins/logger.js
CHANGED
|
@@ -57,7 +57,7 @@ var Logger = _webexPlugin.default.extend({
|
|
|
57
57
|
info: wrapConsoleMethod('info'),
|
|
58
58
|
debug: wrapConsoleMethod('debug'),
|
|
59
59
|
trace: wrapConsoleMethod('trace'),
|
|
60
|
-
version: "3.0.0-beta.
|
|
60
|
+
version: "3.0.0-beta.285"
|
|
61
61
|
});
|
|
62
62
|
(0, _webexCore.registerPlugin)('logger', Logger);
|
|
63
63
|
var _default = Logger;
|
package/dist/webex-core.js
CHANGED
|
@@ -99,7 +99,7 @@ var MAX_FILE_SIZE_IN_MB = 2048;
|
|
|
99
99
|
* @class
|
|
100
100
|
*/
|
|
101
101
|
var WebexCore = _ampersandState.default.extend((_obj = {
|
|
102
|
-
version: "3.0.0-beta.
|
|
102
|
+
version: "3.0.0-beta.285",
|
|
103
103
|
children: {
|
|
104
104
|
internal: _webexInternalCore.default
|
|
105
105
|
},
|
|
@@ -641,7 +641,7 @@ var WebexCore = _ampersandState.default.extend((_obj = {
|
|
|
641
641
|
});
|
|
642
642
|
}
|
|
643
643
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "_uploadPhaseUpload", [_common.retry], (0, _getOwnPropertyDescriptor.default)(_obj, "_uploadPhaseUpload"), _obj)), _obj));
|
|
644
|
-
WebexCore.version = "3.0.0-beta.
|
|
644
|
+
WebexCore.version = "3.0.0-beta.285";
|
|
645
645
|
(0, _webexInternalCorePluginMixin.default)(_webexInternalCore.default, _config.default, interceptors);
|
|
646
646
|
(0, _webexCorePluginMixin.default)(WebexCore, _config.default, interceptors);
|
|
647
647
|
var _default = WebexCore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/webex-core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.285",
|
|
4
4
|
"description": "Plugin handling for Cisco Webex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"contributors": [
|
|
@@ -31,24 +31,24 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@sinonjs/fake-timers": "^6.0.1",
|
|
34
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
35
|
-
"@webex/test-helper-make-local-url": "3.0.0-beta.
|
|
36
|
-
"@webex/test-helper-mocha": "3.0.0-beta.
|
|
37
|
-
"@webex/test-helper-mock-webex": "3.0.0-beta.
|
|
38
|
-
"@webex/test-helper-refresh-callback": "3.0.0-beta.
|
|
39
|
-
"@webex/test-helper-test-users": "3.0.0-beta.
|
|
34
|
+
"@webex/test-helper-chai": "3.0.0-beta.285",
|
|
35
|
+
"@webex/test-helper-make-local-url": "3.0.0-beta.285",
|
|
36
|
+
"@webex/test-helper-mocha": "3.0.0-beta.285",
|
|
37
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.285",
|
|
38
|
+
"@webex/test-helper-refresh-callback": "3.0.0-beta.285",
|
|
39
|
+
"@webex/test-helper-test-users": "3.0.0-beta.285",
|
|
40
40
|
"chai": "^4.3.4",
|
|
41
41
|
"chai-as-promised": "^7.1.1",
|
|
42
42
|
"sinon": "^9.2.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@webex/common": "3.0.0-beta.
|
|
46
|
-
"@webex/common-timers": "3.0.0-beta.
|
|
47
|
-
"@webex/http-core": "3.0.0-beta.
|
|
48
|
-
"@webex/internal-plugin-device": "3.0.0-beta.
|
|
49
|
-
"@webex/plugin-logger": "3.0.0-beta.
|
|
50
|
-
"@webex/storage-adapter-spec": "3.0.0-beta.
|
|
51
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
45
|
+
"@webex/common": "3.0.0-beta.285",
|
|
46
|
+
"@webex/common-timers": "3.0.0-beta.285",
|
|
47
|
+
"@webex/http-core": "3.0.0-beta.285",
|
|
48
|
+
"@webex/internal-plugin-device": "3.0.0-beta.285",
|
|
49
|
+
"@webex/plugin-logger": "3.0.0-beta.285",
|
|
50
|
+
"@webex/storage-adapter-spec": "3.0.0-beta.285",
|
|
51
|
+
"@webex/webex-core": "3.0.0-beta.285",
|
|
52
52
|
"ampersand-collection": "^2.0.2",
|
|
53
53
|
"ampersand-events": "^2.0.2",
|
|
54
54
|
"ampersand-state": "^5.0.3",
|
|
@@ -36,11 +36,11 @@ export default class ServiceInterceptor extends Interceptor {
|
|
|
36
36
|
|
|
37
37
|
// Destructure commonly referenced namespaces.
|
|
38
38
|
const {services} = this.webex.internal;
|
|
39
|
-
const {service, resource} = options;
|
|
39
|
+
const {service, resource, waitForServiceTimeout} = options;
|
|
40
40
|
|
|
41
41
|
// Attempt to collect the service url.
|
|
42
42
|
return services
|
|
43
|
-
.waitForService({name: service})
|
|
43
|
+
.waitForService({name: service, timeout: waitForServiceTimeout})
|
|
44
44
|
.then((serviceUrl) => {
|
|
45
45
|
// Generate the combined service url and resource.
|
|
46
46
|
options.uri = this.generateUri(serviceUrl, resource);
|
|
@@ -413,6 +413,8 @@ const ServiceCatalog = AmpState.extend({
|
|
|
413
413
|
resolve();
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
const validatedTimeout = typeof timeout === 'number' && timeout >= 0 ? timeout : 60;
|
|
417
|
+
|
|
416
418
|
const timeoutTimer = setTimeout(
|
|
417
419
|
() =>
|
|
418
420
|
reject(
|
|
@@ -420,7 +422,7 @@ const ServiceCatalog = AmpState.extend({
|
|
|
420
422
|
`services: timeout occured while waiting for '${serviceGroup}' catalog to populate`
|
|
421
423
|
)
|
|
422
424
|
),
|
|
423
|
-
|
|
425
|
+
validatedTimeout * 1000
|
|
424
426
|
);
|
|
425
427
|
|
|
426
428
|
this.once(serviceGroup, () => {
|
|
@@ -5,6 +5,7 @@ import chai from 'chai';
|
|
|
5
5
|
import chaiAsPromised from 'chai-as-promised';
|
|
6
6
|
import sinon from 'sinon';
|
|
7
7
|
import {ServiceInterceptor} from '@webex/webex-core';
|
|
8
|
+
import CONFIG from '../../../../../src/config';
|
|
8
9
|
|
|
9
10
|
const {assert} = chai;
|
|
10
11
|
|
|
@@ -26,6 +27,7 @@ describe('webex-core', () => {
|
|
|
26
27
|
service: 'example',
|
|
27
28
|
serviceUrl: 'https://www.example-service.com/',
|
|
28
29
|
uri: 'https://www.example-uri.com/',
|
|
30
|
+
waitForServiceTimeout: 11,
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
options = {};
|
|
@@ -107,6 +109,7 @@ describe('webex-core', () => {
|
|
|
107
109
|
|
|
108
110
|
options.service = fixture.service;
|
|
109
111
|
options.resource = fixture.resource;
|
|
112
|
+
options.timeout = fixture.waitForServiceTimeout;
|
|
110
113
|
});
|
|
111
114
|
|
|
112
115
|
it('should normalize the options', () =>
|
|
@@ -116,9 +119,12 @@ describe('webex-core', () => {
|
|
|
116
119
|
interceptor.onRequest(options).then(() => assert.called(interceptor.validateOptions)));
|
|
117
120
|
|
|
118
121
|
it('should attempt to collect the service url', () =>
|
|
119
|
-
interceptor
|
|
120
|
-
.
|
|
121
|
-
|
|
122
|
+
interceptor.onRequest(options).then(
|
|
123
|
+
assert.calledWith(waitForService, {
|
|
124
|
+
name: options.service,
|
|
125
|
+
timeout: options.waitForServiceTimeout,
|
|
126
|
+
})
|
|
127
|
+
));
|
|
122
128
|
|
|
123
129
|
describe('when the service url was collected successfully', () => {
|
|
124
130
|
beforeEach('generate additional mocks', () => {});
|