@webex/webex-core 3.12.0-webex-services-ready.3 → 3.12.0-webex-services-ready.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -1
- 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/domains.js +90 -0
- package/dist/lib/domains.js.map +1 -0
- package/dist/lib/services/service-catalog.js +6 -10
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +27 -25
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/service-catalog.js +6 -12
- package/dist/lib/services-v2/service-catalog.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +34 -27
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/package.json +13 -13
- package/src/config.js +17 -0
- package/src/lib/domains.ts +94 -0
- package/src/lib/services/service-catalog.js +6 -10
- package/src/lib/services/services.js +42 -40
- package/src/lib/services-v2/service-catalog.ts +6 -11
- package/src/lib/services-v2/services-v2.ts +46 -40
- package/test/fixtures/activation-email.ts +22 -0
- package/test/integration/spec/services/service-catalog.js +7 -6
- package/test/integration/spec/services/services.js +11 -8
- package/test/integration/spec/services-v2/services-v2.js +11 -8
- package/test/unit/spec/interceptors/auth.js +56 -0
- package/test/unit/spec/services/service-catalog.js +93 -11
- package/test/unit/spec/services/services.js +4 -8
- package/test/unit/spec/services-v2/service-catalog.ts +93 -11
- package/test/unit/spec/services-v2/services-v2.ts +20 -8
- package/test/unit/spec/webex-core.js +0 -2
- package/test/unit/spec/webex-internal-core.js +0 -2
package/README.md
CHANGED
|
@@ -78,8 +78,11 @@ const webex = new WebexCore({
|
|
|
78
78
|
// Validate domains against the allowed domains
|
|
79
79
|
validateDomains: true,
|
|
80
80
|
|
|
81
|
-
// The allowed domains to validate domains against
|
|
82
|
-
|
|
81
|
+
// The allowed domains to validate domains against. Each entry is a
|
|
82
|
+
// hostname, matched on label boundaries: an entry allows that host and
|
|
83
|
+
// its subdomains, so 'example.com' covers 'api.example.com' but not
|
|
84
|
+
// 'notexample.com'.
|
|
85
|
+
allowedDomains: ['example.com']
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
});
|
package/dist/config.js
CHANGED
|
@@ -31,6 +31,21 @@ var _default = exports.default = {
|
|
|
31
31
|
* @type {boolean}
|
|
32
32
|
*/
|
|
33
33
|
useUserOnboardingServiceForActivations: false,
|
|
34
|
+
/**
|
|
35
|
+
* When true, requests the U2C catalog override.
|
|
36
|
+
*
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
useCatalogOverride: false,
|
|
40
|
+
/**
|
|
41
|
+
* Maximum time (in milliseconds) to wait for the initial service catalog
|
|
42
|
+
* collection when `waitForCatalogInit` is enabled, before letting
|
|
43
|
+
* `services.ready` (and therefore `webex.ready`) fire anyway. Prevents a
|
|
44
|
+
* hung catalog request from leaving the app on a permanent spinner.
|
|
45
|
+
*
|
|
46
|
+
* @type {number}
|
|
47
|
+
*/
|
|
48
|
+
catalogInitTimeout: 15000,
|
|
34
49
|
/**
|
|
35
50
|
* A list of services that are available prior to catalog collection.
|
|
36
51
|
*
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_storage","require","_credentialsConfig","_interopRequireDefault","_default","exports","default","maxAppLevelRedirects","maxLocusRedirects","maxAuthenticationReplays","maxReconnectAttempts","onBeforeLogout","trackingIdPrefix","trackingIdSuffix","AlternateLogger","undefined","credentials","CredentialsConfig","fedramp","process","env","ENABLE_FEDRAMP","services","useUserOnboardingServiceForActivations","discovery","hydra","HYDRA_SERVICE_URL","sqdiscovery","SQDISCOVERY_SERVICE_URL","u2c","U2C_SERVICE_URL","validateDomains","servicesNotNeedValidation","allowedDomains","device","preDiscoveryServices","hydraServiceUrl","metrics","type","calling","cacheU2C","payloadTransformer","predicates","transforms","storage","boundedAdapter","MemoryStoreAdapter","unboundedAdapter"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint camelcase: [0] */\n\nimport {MemoryStoreAdapter} from './lib/storage';\nimport CredentialsConfig from './credentials-config';\n\nexport default {\n maxAppLevelRedirects: 10,\n maxLocusRedirects: 5,\n maxAuthenticationReplays: 1,\n maxReconnectAttempts: 1,\n onBeforeLogout: [],\n trackingIdPrefix: 'webex-js-sdk',\n trackingIdSuffix: '',\n AlternateLogger: undefined,\n credentials: new CredentialsConfig(),\n fedramp: process.env.ENABLE_FEDRAMP || false,\n services: {\n /**\n * When true, uses the user-onboarding service for user activation.\n * When false (default), uses the license service.\n *\n * @type {boolean}\n */\n useUserOnboardingServiceForActivations: false,\n\n /**\n * A list of services that are available prior to catalog collection.\n *\n * @type {Object}\n */\n discovery: {\n /**\n * The hydra discovery url.\n *\n * @type {string}\n */\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n\n /**\n * load balanced region info url\n */\n sqdiscovery: process.env.SQDISCOVERY_SERVICE_URL || 'https://ds.ciscospark.com/v1/region',\n\n /**\n * The u2c discovery url\n *\n * @type {string}\n */\n u2c: process.env.U2C_SERVICE_URL || 'https://u2c.wbx2.com/u2c/api/v1',\n },\n\n /**\n * When true, considers all urls in `allowedDomains` as safe for auth tokens\n *\n * @type {boolean}\n */\n validateDomains: true,\n\n /**\n * services that don't need auth validation\n */\n\n servicesNotNeedValidation: ['webex-appapi-service'],\n\n /**\n * Contains a list of allowed domain host addresses.\n *\n * @type {Array<string>}\n */\n allowedDomains: [],\n },\n device: {\n preDiscoveryServices: {\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n hydraServiceUrl: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n },\n validateDomains: true,\n },\n metrics: {\n type: ['behavioral', 'operational'],\n },\n calling: {\n /**\n * Controls whether U2C service catalogs should be cached and warmed from cache.\n * When false, the services layer will skip reading and writing the U2C cache.\n */\n cacheU2C: false,\n },\n payloadTransformer: {\n predicates: [],\n transforms: [],\n },\n storage: {\n boundedAdapter: MemoryStoreAdapter,\n unboundedAdapter: MemoryStoreAdapter,\n },\n};\n"],"mappings":";;;;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAPA;AACA;AACA;AAEA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACbC,oBAAoB,EAAE,EAAE;EACxBC,iBAAiB,EAAE,CAAC;EACpBC,wBAAwB,EAAE,CAAC;EAC3BC,oBAAoB,EAAE,CAAC;EACvBC,cAAc,EAAE,EAAE;EAClBC,gBAAgB,EAAE,cAAc;EAChCC,gBAAgB,EAAE,EAAE;EACpBC,eAAe,EAAEC,SAAS;EAC1BC,WAAW,EAAE,IAAIC,0BAAiB,CAAC,CAAC;EACpCC,OAAO,EAAEC,OAAO,CAACC,GAAG,CAACC,cAAc,IAAI,KAAK;EAC5CC,QAAQ,EAAE;IACR;AACJ;AACA;AACA;AACA;AACA;IACIC,sCAAsC,EAAE,KAAK;IAE7C;AACJ;AACA;AACA;AACA;IACIC,SAAS,EAAE;MACT;AACN;AACA;AACA;AACA;MACMC,KAAK,
|
|
1
|
+
{"version":3,"names":["_storage","require","_credentialsConfig","_interopRequireDefault","_default","exports","default","maxAppLevelRedirects","maxLocusRedirects","maxAuthenticationReplays","maxReconnectAttempts","onBeforeLogout","trackingIdPrefix","trackingIdSuffix","AlternateLogger","undefined","credentials","CredentialsConfig","fedramp","process","env","ENABLE_FEDRAMP","services","useUserOnboardingServiceForActivations","useCatalogOverride","catalogInitTimeout","discovery","hydra","HYDRA_SERVICE_URL","sqdiscovery","SQDISCOVERY_SERVICE_URL","u2c","U2C_SERVICE_URL","validateDomains","servicesNotNeedValidation","allowedDomains","device","preDiscoveryServices","hydraServiceUrl","metrics","type","calling","cacheU2C","payloadTransformer","predicates","transforms","storage","boundedAdapter","MemoryStoreAdapter","unboundedAdapter"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint camelcase: [0] */\n\nimport {MemoryStoreAdapter} from './lib/storage';\nimport CredentialsConfig from './credentials-config';\n\nexport default {\n maxAppLevelRedirects: 10,\n maxLocusRedirects: 5,\n maxAuthenticationReplays: 1,\n maxReconnectAttempts: 1,\n onBeforeLogout: [],\n trackingIdPrefix: 'webex-js-sdk',\n trackingIdSuffix: '',\n AlternateLogger: undefined,\n credentials: new CredentialsConfig(),\n fedramp: process.env.ENABLE_FEDRAMP || false,\n services: {\n /**\n * When true, uses the user-onboarding service for user activation.\n * When false (default), uses the license service.\n *\n * @type {boolean}\n */\n useUserOnboardingServiceForActivations: false,\n\n /**\n * When true, requests the U2C catalog override.\n *\n * @type {boolean}\n */\n useCatalogOverride: false,\n\n /**\n * Maximum time (in milliseconds) to wait for the initial service catalog\n * collection when `waitForCatalogInit` is enabled, before letting\n * `services.ready` (and therefore `webex.ready`) fire anyway. Prevents a\n * hung catalog request from leaving the app on a permanent spinner.\n *\n * @type {number}\n */\n catalogInitTimeout: 15000,\n\n /**\n * A list of services that are available prior to catalog collection.\n *\n * @type {Object}\n */\n discovery: {\n /**\n * The hydra discovery url.\n *\n * @type {string}\n */\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n\n /**\n * load balanced region info url\n */\n sqdiscovery: process.env.SQDISCOVERY_SERVICE_URL || 'https://ds.ciscospark.com/v1/region',\n\n /**\n * The u2c discovery url\n *\n * @type {string}\n */\n u2c: process.env.U2C_SERVICE_URL || 'https://u2c.wbx2.com/u2c/api/v1',\n },\n\n /**\n * When true, considers all urls in `allowedDomains` as safe for auth tokens\n *\n * @type {boolean}\n */\n validateDomains: true,\n\n /**\n * services that don't need auth validation\n */\n\n servicesNotNeedValidation: ['webex-appapi-service'],\n\n /**\n * Contains a list of allowed domain host addresses.\n *\n * @type {Array<string>}\n */\n allowedDomains: [],\n },\n device: {\n preDiscoveryServices: {\n hydra: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n hydraServiceUrl: process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1',\n },\n validateDomains: true,\n },\n metrics: {\n type: ['behavioral', 'operational'],\n },\n calling: {\n /**\n * Controls whether U2C service catalogs should be cached and warmed from cache.\n * When false, the services layer will skip reading and writing the U2C cache.\n */\n cacheU2C: false,\n },\n payloadTransformer: {\n predicates: [],\n transforms: [],\n },\n storage: {\n boundedAdapter: MemoryStoreAdapter,\n unboundedAdapter: MemoryStoreAdapter,\n },\n};\n"],"mappings":";;;;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAPA;AACA;AACA;AAEA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACbC,oBAAoB,EAAE,EAAE;EACxBC,iBAAiB,EAAE,CAAC;EACpBC,wBAAwB,EAAE,CAAC;EAC3BC,oBAAoB,EAAE,CAAC;EACvBC,cAAc,EAAE,EAAE;EAClBC,gBAAgB,EAAE,cAAc;EAChCC,gBAAgB,EAAE,EAAE;EACpBC,eAAe,EAAEC,SAAS;EAC1BC,WAAW,EAAE,IAAIC,0BAAiB,CAAC,CAAC;EACpCC,OAAO,EAAEC,OAAO,CAACC,GAAG,CAACC,cAAc,IAAI,KAAK;EAC5CC,QAAQ,EAAE;IACR;AACJ;AACA;AACA;AACA;AACA;IACIC,sCAAsC,EAAE,KAAK;IAE7C;AACJ;AACA;AACA;AACA;IACIC,kBAAkB,EAAE,KAAK;IAEzB;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACIC,kBAAkB,EAAE,KAAK;IAEzB;AACJ;AACA;AACA;AACA;IACIC,SAAS,EAAE;MACT;AACN;AACA;AACA;AACA;MACMC,KAAK,EAAER,OAAO,CAACC,GAAG,CAACQ,iBAAiB,IAAI,+BAA+B;MAEvE;AACN;AACA;MACMC,WAAW,EAAEV,OAAO,CAACC,GAAG,CAACU,uBAAuB,IAAI,qCAAqC;MAEzF;AACN;AACA;AACA;AACA;MACMC,GAAG,EAAEZ,OAAO,CAACC,GAAG,CAACY,eAAe,IAAI;IACtC,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIC,eAAe,EAAE,IAAI;IAErB;AACJ;AACA;;IAEIC,yBAAyB,EAAE,CAAC,sBAAsB,CAAC;IAEnD;AACJ;AACA;AACA;AACA;IACIC,cAAc,EAAE;EAClB,CAAC;EACDC,MAAM,EAAE;IACNC,oBAAoB,EAAE;MACpBV,KAAK,EAAER,OAAO,CAACC,GAAG,CAACQ,iBAAiB,IAAI,+BAA+B;MACvEU,eAAe,EAAEnB,OAAO,CAACC,GAAG,CAACQ,iBAAiB,IAAI;IACpD,CAAC;IACDK,eAAe,EAAE;EACnB,CAAC;EACDM,OAAO,EAAE;IACPC,IAAI,EAAE,CAAC,YAAY,EAAE,aAAa;EACpC,CAAC;EACDC,OAAO,EAAE;IACP;AACJ;AACA;AACA;IACIC,QAAQ,EAAE;EACZ,CAAC;EACDC,kBAAkB,EAAE;IAClBC,UAAU,EAAE,EAAE;IACdC,UAAU,EAAE;EACd,CAAC;EACDC,OAAO,EAAE;IACPC,cAAc,EAAEC,2BAAkB;IAClCC,gBAAgB,EAAED;EACpB;AACF,CAAC","ignoreList":[]}
|
package/dist/lib/batcher.js
CHANGED
|
@@ -302,7 +302,7 @@ var Batcher = _webexPlugin.default.extend({
|
|
|
302
302
|
fingerprintResponse: function fingerprintResponse(item) {
|
|
303
303
|
throw new Error('fingerprintResponse() must be implemented');
|
|
304
304
|
},
|
|
305
|
-
version: "3.12.0-webex-services-ready.
|
|
305
|
+
version: "3.12.0-webex-services-ready.4"
|
|
306
306
|
});
|
|
307
307
|
var _default2 = exports.default = Batcher;
|
|
308
308
|
//# sourceMappingURL=batcher.js.map
|
|
@@ -600,7 +600,7 @@ var Credentials = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
600
600
|
this.refresh();
|
|
601
601
|
}
|
|
602
602
|
},
|
|
603
|
-
version: "3.12.0-webex-services-ready.
|
|
603
|
+
version: "3.12.0-webex-services-ready.4"
|
|
604
604
|
}, (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));
|
|
605
605
|
var _default = exports.default = Credentials;
|
|
606
606
|
//# sourceMappingURL=credentials.js.map
|
|
@@ -532,7 +532,7 @@ var Token = _webexPlugin.default.extend((_dec = (0, _common.oneFlight)({
|
|
|
532
532
|
return res.body;
|
|
533
533
|
});
|
|
534
534
|
},
|
|
535
|
-
version: "3.12.0-webex-services-ready.
|
|
535
|
+
version: "3.12.0-webex-services-ready.4"
|
|
536
536
|
}, (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));
|
|
537
537
|
var _default = exports.default = Token;
|
|
538
538
|
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
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.normalizeAllowedDomains = exports.matchAllowedDomain = exports.default = void 0;
|
|
9
|
+
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
10
|
+
var _url = _interopRequireDefault(require("url"));
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
// Canonicalise a hostname for comparison: lowercase, drop the brackets around
|
|
13
|
+
// an IPv6 literal, and drop leading/trailing dots. DNS treats `Example.com`,
|
|
14
|
+
// `example.com.` and `example.com` as the same name.
|
|
15
|
+
//
|
|
16
|
+
// Node's `url.domainToASCII` looks like the standard way to do this, but the
|
|
17
|
+
// `url` polyfill this package bundles for the browser does not implement it,
|
|
18
|
+
// so it cannot be used here. It also leaves trailing dots in place.
|
|
19
|
+
var normalizeHostname = function normalizeHostname(value) {
|
|
20
|
+
return typeof value === 'string' ? value.toLowerCase().replace(/^\[|\]$/g, '').replace(/^\.+/, '').replace(/\.+$/, '') : '';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Canonicalise a list of configured allowed domains, discarding any entry that
|
|
25
|
+
* is not a usable hostname. Callers normalise on the way in so the stored list
|
|
26
|
+
* is already canonical, rather than re-deriving it on every request.
|
|
27
|
+
*
|
|
28
|
+
* @param {Array<string>} allowedDomains - The configured allowed domains.
|
|
29
|
+
* @returns {Array<string>} - Normalized, de-duplicated, non-empty entries.
|
|
30
|
+
*/
|
|
31
|
+
var normalizeAllowedDomains = exports.normalizeAllowedDomains = function normalizeAllowedDomains(allowedDomains) {
|
|
32
|
+
return (0, _lodash.uniq)(((0, _isArray.default)(allowedDomains) ? allowedDomains : []).map(normalizeHostname).filter(Boolean));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Determine if a hostname is covered by an allowed domain, matching only on DNS
|
|
37
|
+
* label boundaries, so that a hostname is allowed only when it is the domain
|
|
38
|
+
* itself or a subdomain of it. Matching on a substring instead would treat
|
|
39
|
+
* unrelated hostnames that merely contain the domain as allowed.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} hostname - Hostname to test. Must not include a port.
|
|
42
|
+
* @param {string} allowedDomain - The configured allowed domain.
|
|
43
|
+
* @returns {boolean} - True when the hostname is the domain or a subdomain of it.
|
|
44
|
+
*/
|
|
45
|
+
var hostnameMatchesDomain = function hostnameMatchesDomain(hostname, allowedDomain) {
|
|
46
|
+
// The stored list is normalized on write, but `allowedDomains` is a public
|
|
47
|
+
// property, so normalize again here rather than trust it.
|
|
48
|
+
var host = normalizeHostname(hostname);
|
|
49
|
+
var domain = normalizeHostname(allowedDomain);
|
|
50
|
+
return !!host && !!domain && (host === domain || host.endsWith(".".concat(domain)));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Find the allowed domain covering a url, or `undefined` if there is none.
|
|
55
|
+
*
|
|
56
|
+
* Parsing lives here rather than in the callers, and deliberately uses both url
|
|
57
|
+
* parsers, because this check gates an `Authorization` header. The two
|
|
58
|
+
* transports behind `@webex/http-core` do not use the same url parser: the
|
|
59
|
+
* browser transport parses per WHATWG, the node transport uses Node's legacy
|
|
60
|
+
* `Url.parse`, and for some inputs the two resolve different hosts.
|
|
61
|
+
*
|
|
62
|
+
* Rather than picking one, require both to agree and fail closed when they do
|
|
63
|
+
* not, so this check can never authorize a host that differs from the one a
|
|
64
|
+
* transport would actually connect to. Do not narrow this to a single parser.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} url - The url to match the allowed domains against.
|
|
67
|
+
* @param {Array<string>} allowedDomains - The configured allowed domains.
|
|
68
|
+
* @returns {string} - The matching allowed domain, or undefined if there is none.
|
|
69
|
+
*/
|
|
70
|
+
var matchAllowedDomain = exports.matchAllowedDomain = function matchAllowedDomain(url, allowedDomains) {
|
|
71
|
+
var hostname;
|
|
72
|
+
var legacyHostname;
|
|
73
|
+
try {
|
|
74
|
+
var _URL = new URL(url);
|
|
75
|
+
hostname = _URL.hostname;
|
|
76
|
+
var _Url$parse = _url.default.parse(url);
|
|
77
|
+
legacyHostname = _Url$parse.hostname;
|
|
78
|
+
} catch (_unused) {
|
|
79
|
+
// Not a parsable absolute url, so it cannot belong to an allowed domain.
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (normalizeHostname(hostname) !== normalizeHostname(legacyHostname)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return (allowedDomains || []).find(function (allowedDomain) {
|
|
86
|
+
return hostnameMatchesDomain(hostname, allowedDomain);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
var _default = exports.default = matchAllowedDomain;
|
|
90
|
+
//# sourceMappingURL=domains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_url","_interopRequireDefault","require","_lodash","normalizeHostname","value","toLowerCase","replace","normalizeAllowedDomains","exports","allowedDomains","uniq","_isArray","default","map","filter","Boolean","hostnameMatchesDomain","hostname","allowedDomain","host","domain","endsWith","concat","matchAllowedDomain","url","legacyHostname","_URL","URL","_Url$parse","Url","parse","_unused","undefined","find","_default"],"sources":["domains.ts"],"sourcesContent":["import Url from 'url';\n\nimport {uniq} from 'lodash';\n\n// Canonicalise a hostname for comparison: lowercase, drop the brackets around\n// an IPv6 literal, and drop leading/trailing dots. DNS treats `Example.com`,\n// `example.com.` and `example.com` as the same name.\n//\n// Node's `url.domainToASCII` looks like the standard way to do this, but the\n// `url` polyfill this package bundles for the browser does not implement it,\n// so it cannot be used here. It also leaves trailing dots in place.\nconst normalizeHostname = (value: string): string =>\n typeof value === 'string'\n ? value\n .toLowerCase()\n .replace(/^\\[|\\]$/g, '')\n .replace(/^\\.+/, '')\n .replace(/\\.+$/, '')\n : '';\n\n/**\n * Canonicalise a list of configured allowed domains, discarding any entry that\n * is not a usable hostname. Callers normalise on the way in so the stored list\n * is already canonical, rather than re-deriving it on every request.\n *\n * @param {Array<string>} allowedDomains - The configured allowed domains.\n * @returns {Array<string>} - Normalized, de-duplicated, non-empty entries.\n */\nexport const normalizeAllowedDomains = (allowedDomains: Array<string>): Array<string> =>\n uniq(\n (Array.isArray(allowedDomains) ? allowedDomains : []).map(normalizeHostname).filter(Boolean)\n );\n\n/**\n * Determine if a hostname is covered by an allowed domain, matching only on DNS\n * label boundaries, so that a hostname is allowed only when it is the domain\n * itself or a subdomain of it. Matching on a substring instead would treat\n * unrelated hostnames that merely contain the domain as allowed.\n *\n * @param {string} hostname - Hostname to test. Must not include a port.\n * @param {string} allowedDomain - The configured allowed domain.\n * @returns {boolean} - True when the hostname is the domain or a subdomain of it.\n */\nconst hostnameMatchesDomain = (hostname: string, allowedDomain: string): boolean => {\n // The stored list is normalized on write, but `allowedDomains` is a public\n // property, so normalize again here rather than trust it.\n const host = normalizeHostname(hostname);\n const domain = normalizeHostname(allowedDomain);\n\n return !!host && !!domain && (host === domain || host.endsWith(`.${domain}`));\n};\n\n/**\n * Find the allowed domain covering a url, or `undefined` if there is none.\n *\n * Parsing lives here rather than in the callers, and deliberately uses both url\n * parsers, because this check gates an `Authorization` header. The two\n * transports behind `@webex/http-core` do not use the same url parser: the\n * browser transport parses per WHATWG, the node transport uses Node's legacy\n * `Url.parse`, and for some inputs the two resolve different hosts.\n *\n * Rather than picking one, require both to agree and fail closed when they do\n * not, so this check can never authorize a host that differs from the one a\n * transport would actually connect to. Do not narrow this to a single parser.\n *\n * @param {string} url - The url to match the allowed domains against.\n * @param {Array<string>} allowedDomains - The configured allowed domains.\n * @returns {string} - The matching allowed domain, or undefined if there is none.\n */\nexport const matchAllowedDomain = (\n url: string,\n allowedDomains: Array<string>\n): string | undefined => {\n let hostname: string;\n let legacyHostname: string;\n\n try {\n ({hostname} = new URL(url));\n ({hostname: legacyHostname} = Url.parse(url));\n } catch {\n // Not a parsable absolute url, so it cannot belong to an allowed domain.\n return undefined;\n }\n\n if (normalizeHostname(hostname) !== normalizeHostname(legacyHostname)) {\n return undefined;\n }\n\n return (allowedDomains || []).find((allowedDomain) =>\n hostnameMatchesDomain(hostname, allowedDomain)\n );\n};\n\nexport default matchAllowedDomain;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAME,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,KAAa;EAAA,OACtC,OAAOA,KAAK,KAAK,QAAQ,GACrBA,KAAK,CACFC,WAAW,CAAC,CAAC,CACbC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CACvBA,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACnBA,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GACtB,EAAE;AAAA;;AAER;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMC,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,SAA1BA,uBAAuBA,CAAIE,cAA6B;EAAA,OACnE,IAAAC,YAAI,EACF,CAAC,IAAAC,QAAA,CAAAC,OAAA,EAAcH,cAAc,CAAC,GAAGA,cAAc,GAAG,EAAE,EAAEI,GAAG,CAACV,iBAAiB,CAAC,CAACW,MAAM,CAACC,OAAO,CAC7F,CAAC;AAAA;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAIC,QAAgB,EAAEC,aAAqB,EAAc;EAClF;EACA;EACA,IAAMC,IAAI,GAAGhB,iBAAiB,CAACc,QAAQ,CAAC;EACxC,IAAMG,MAAM,GAAGjB,iBAAiB,CAACe,aAAa,CAAC;EAE/C,OAAO,CAAC,CAACC,IAAI,IAAI,CAAC,CAACC,MAAM,KAAKD,IAAI,KAAKC,MAAM,IAAID,IAAI,CAACE,QAAQ,KAAAC,MAAA,CAAKF,MAAM,CAAE,CAAC,CAAC;AAC/E,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMG,kBAAkB,GAAAf,OAAA,CAAAe,kBAAA,GAAG,SAArBA,kBAAkBA,CAC7BC,GAAW,EACXf,cAA6B,EACN;EACvB,IAAIQ,QAAgB;EACpB,IAAIQ,cAAsB;EAE1B,IAAI;IAAA,IAAAC,IAAA,GACY,IAAIC,GAAG,CAACH,GAAG,CAAC;IAAxBP,QAAQ,GAAAS,IAAA,CAART,QAAQ;IAAA,IAAAW,UAAA,GACoBC,YAAG,CAACC,KAAK,CAACN,GAAG,CAAC;IAAhCC,cAAc,GAAAG,UAAA,CAAxBX,QAAQ;EACZ,CAAC,CAAC,OAAAc,OAAA,EAAM;IACN;IACA,OAAOC,SAAS;EAClB;EAEA,IAAI7B,iBAAiB,CAACc,QAAQ,CAAC,KAAKd,iBAAiB,CAACsB,cAAc,CAAC,EAAE;IACrE,OAAOO,SAAS;EAClB;EAEA,OAAO,CAACvB,cAAc,IAAI,EAAE,EAAEwB,IAAI,CAAC,UAACf,aAAa;IAAA,OAC/CF,qBAAqB,CAACC,QAAQ,EAAEC,aAAa,CAAC;EAAA,CAChD,CAAC;AACH,CAAC;AAAC,IAAAgB,QAAA,GAAA1B,OAAA,CAAAI,OAAA,GAEaW,kBAAkB","ignoreList":[]}
|
|
@@ -23,6 +23,7 @@ var _url = _interopRequireDefault(require("url"));
|
|
|
23
23
|
var _ampersandState = _interopRequireDefault(require("ampersand-state"));
|
|
24
24
|
var _lodash = require("lodash");
|
|
25
25
|
var _serviceUrl = _interopRequireDefault(require("./service-url"));
|
|
26
|
+
var _domains = require("../domains");
|
|
26
27
|
function ownKeys(e, r) { var t = _Object$keys3(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
27
28
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
29
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
@@ -283,19 +284,14 @@ var ServiceCatalog = _ampersandState.default.extend({
|
|
|
283
284
|
});
|
|
284
285
|
},
|
|
285
286
|
/**
|
|
286
|
-
* Finds an allowed domain that matches a specific url.
|
|
287
|
+
* Finds an allowed domain that matches a specific url. The url's hostname
|
|
288
|
+
* must be the allowed domain itself or a subdomain of it.
|
|
287
289
|
*
|
|
288
290
|
* @param {string} url - The url to match the allowed domains against.
|
|
289
291
|
* @returns {string} - The matching allowed domain.
|
|
290
292
|
*/
|
|
291
293
|
findAllowedDomain: function findAllowedDomain(url) {
|
|
292
|
-
|
|
293
|
-
if (!urlObj.host) {
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
|
-
return this.allowedDomains.find(function (allowedDomain) {
|
|
297
|
-
return urlObj.host.includes(allowedDomain);
|
|
298
|
-
});
|
|
294
|
+
return (0, _domains.matchAllowedDomain)(url, this.allowedDomains);
|
|
299
295
|
},
|
|
300
296
|
/**
|
|
301
297
|
* Get a service url from the current services list by name.
|
|
@@ -363,7 +359,7 @@ var ServiceCatalog = _ampersandState.default.extend({
|
|
|
363
359
|
* @returns {void}
|
|
364
360
|
*/
|
|
365
361
|
setAllowedDomains: function setAllowedDomains(allowedDomains) {
|
|
366
|
-
this.allowedDomains = (0,
|
|
362
|
+
this.allowedDomains = (0, _domains.normalizeAllowedDomains)(allowedDomains);
|
|
367
363
|
},
|
|
368
364
|
/**
|
|
369
365
|
*
|
|
@@ -371,7 +367,7 @@ var ServiceCatalog = _ampersandState.default.extend({
|
|
|
371
367
|
* @returns {void}
|
|
372
368
|
*/
|
|
373
369
|
addAllowedDomains: function addAllowedDomains(newAllowedDomains) {
|
|
374
|
-
this.allowedDomains = (0, _lodash.union)(this.allowedDomains, newAllowedDomains);
|
|
370
|
+
this.allowedDomains = (0, _lodash.union)(this.allowedDomains, (0, _domains.normalizeAllowedDomains)(newAllowedDomains));
|
|
375
371
|
},
|
|
376
372
|
/**
|
|
377
373
|
* Update the current list of `ServiceUrl`s against a provided
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_url","_interopRequireDefault","require","_ampersandState","_lodash","_serviceUrl","ownKeys","e","r","t","_Object$keys3","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_createForOfIteratorHelper","_Symbol","_Symbol$iterator","_Array$isArray","_unsupportedIterableToArray","_n","F","s","n","done","value","f","TypeError","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","_Array$from","test","Array","ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","serviceGroup","serviceUrls","concat","_toConsumableArray2","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","_this","existingService","service","_unloadServiceUrls","_this2","splice","indexOf","clean","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","_i","_Object$keys","_keys","key","_iterator","_step","defaultUrl","_iterator2","hosts","_step2","host","hostname","id","err","_iterator3","_step3","homeCluster","undefined","findServiceFromClusterId","_ref","clusterId","_ref$priorityHost","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","startsWith","_iterator4","_step4","alternateUrl","URL","findAllowedDomain","urlObj","allowedDomain","includes","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","_this3","failHost","setAllowedDomains","addAllowedDomains","newAllowedDomains","union","updateServiceUrls","serviceHostmap","_this4","currentServiceUrls","unusedUrls","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","_this5","_promise","resolve","reject","validatedTimeout","timeoutTimer","setTimeout","Error","once","clearTimeout","_default","exports"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport {union} from 'lodash';\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 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 // Check to see if the URL we are checking starts with the default URL\n if (url.startsWith(serviceUrl.defaultUrl)) {\n return true;\n }\n\n // If not, we check to see if the alternate URLs match\n // These are made by swapping the host of the default URL\n // with that of an alternate host\n for (const host of serviceUrl.hosts) {\n const alternateUrl = new URL(serviceUrl.defaultUrl);\n alternateUrl.host = host.host;\n\n if (url.startsWith(alternateUrl.toString())) {\n return true;\n }\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 *\n * @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains\n * @returns {void}\n */\n addAllowedDomains(newAllowedDomains) {\n this.allowedDomains = union(this.allowedDomains, newAllowedDomains);\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,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAuC,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,aAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAA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names":["_url","_interopRequireDefault","require","_ampersandState","_lodash","_serviceUrl","_domains","ownKeys","e","r","t","_Object$keys3","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_createForOfIteratorHelper","_Symbol","_Symbol$iterator","_Array$isArray","_unsupportedIterableToArray","_n","F","s","n","done","value","f","TypeError","a","u","call","next","return","_arrayLikeToArray","toString","slice","constructor","name","_Array$from","test","Array","ServiceCatalog","AmpState","extend","namespace","props","serviceGroups","discovery","override","preauth","postauth","signin","status","ready","collecting","isReady","allowedDomains","_getUrl","serviceGroup","serviceUrls","concat","_toConsumableArray2","find","serviceUrl","_listServiceUrls","_loadServiceUrls","services","_this","existingService","service","_unloadServiceUrls","_this2","splice","indexOf","clean","findClusterId","url","incomingUrlObj","Url","parse","serviceUrlObj","_i","_Object$keys","_keys","key","_iterator","_step","defaultUrl","_iterator2","hosts","_step2","host","hostname","id","err","_iterator3","_step3","homeCluster","undefined","findServiceFromClusterId","_ref","clusterId","_ref$priorityHost","priorityHost","identifiedServiceUrl","get","findServiceUrlFromUrl","startsWith","_iterator4","_step4","alternateUrl","URL","findAllowedDomain","matchAllowedDomain","getAllowedDomains","list","output","markFailedUrl","noPriorityHosts","_this3","failHost","setAllowedDomains","normalizeAllowedDomains","addAllowedDomains","newAllowedDomains","union","updateServiceUrls","serviceHostmap","_this4","currentServiceUrls","unusedUrls","every","item","serviceObj","ServiceUrl","trigger","waitForCatalog","timeout","_this5","_promise","resolve","reject","validatedTimeout","timeoutTimer","setTimeout","Error","once","clearTimeout","_default","exports"],"sources":["service-catalog.js"],"sourcesContent":["import Url from 'url';\n\nimport AmpState from 'ampersand-state';\n\nimport {union} from 'lodash';\nimport ServiceUrl from './service-url';\nimport {matchAllowedDomain, normalizeAllowedDomains} from '../domains';\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 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 // Check to see if the URL we are checking starts with the default URL\n if (url.startsWith(serviceUrl.defaultUrl)) {\n return true;\n }\n\n // If not, we check to see if the alternate URLs match\n // These are made by swapping the host of the default URL\n // with that of an alternate host\n for (const host of serviceUrl.hosts) {\n const alternateUrl = new URL(serviceUrl.defaultUrl);\n alternateUrl.host = host.host;\n\n if (url.startsWith(alternateUrl.toString())) {\n return true;\n }\n }\n\n return false;\n });\n },\n\n /**\n * Finds an allowed domain that matches a specific url. The url's hostname\n * must be the allowed domain itself or a subdomain of it.\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 return matchAllowedDomain(url, this.allowedDomains);\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 = normalizeAllowedDomains(allowedDomains);\n },\n\n /**\n *\n * @param {Array<string>} newAllowedDomains - new allowed domains to add to existing set of allowed domains\n * @returns {void}\n */\n addAllowedDomains(newAllowedDomains) {\n this.allowedDomains = union(this.allowedDomains, normalizeAllowedDomains(newAllowedDomains));\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,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA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AACF;AAAA,IAAAQ,QAAA,GAAAC,OAAA,CAAA1I,OAAA,GAEe8B,cAAc","ignoreList":[]}
|
|
@@ -43,12 +43,6 @@ var DEFAULT_CLUSTER_IDENTIFIER = process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER
|
|
|
43
43
|
var CATALOG_CACHE_KEY_V1 = 'services.v1.u2cHostMap';
|
|
44
44
|
var CATALOG_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
45
45
|
|
|
46
|
-
// Maximum time we will wait for the initial catalog collection before letting
|
|
47
|
-
// `services.ready` (and therefore `webex.ready`) fire anyway. A hung request
|
|
48
|
-
// must never leave the app on a permanent spinner - past this point downstream
|
|
49
|
-
// consumers must fall through to their normal error/login paths.
|
|
50
|
-
var SERVICES_INIT_TIMEOUT_MS = 15000;
|
|
51
|
-
|
|
52
46
|
/* eslint-disable no-underscore-dangle */
|
|
53
47
|
/**
|
|
54
48
|
* @class
|
|
@@ -1371,6 +1365,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1371
1365
|
|
|
1372
1366
|
// Destructure the credentials plugin.
|
|
1373
1367
|
var credentials = this.webex.credentials;
|
|
1368
|
+
var catalog = this._getCatalog();
|
|
1374
1369
|
|
|
1375
1370
|
// Init a promise chain. Must be done as a Promise.resolve() to allow
|
|
1376
1371
|
// credentials#getOrgId() to properly throw.
|
|
@@ -1387,9 +1382,13 @@ var Services = _webexPlugin.default.extend({
|
|
|
1387
1382
|
}).then(function () {
|
|
1388
1383
|
// Validate if the token is authorized.
|
|
1389
1384
|
if (credentials.canAuthorize) {
|
|
1390
|
-
// Attempt to collect the postauth catalog
|
|
1391
|
-
|
|
1392
|
-
|
|
1385
|
+
// Attempt to collect the postauth catalog, then mark the catalog
|
|
1386
|
+
// ready. Setting `isReady` here - rather than only in the init
|
|
1387
|
+
// callers - means a slow postauth fetch that loses the gated-init
|
|
1388
|
+
// timeout race still marks the catalog ready once it completes.
|
|
1389
|
+
return _this0.updateServices().then(function () {
|
|
1390
|
+
catalog.isReady = true;
|
|
1391
|
+
}).catch(function () {
|
|
1393
1392
|
_this0.initFailed = true;
|
|
1394
1393
|
_this0.logger.warn('services: cannot retrieve postauth catalog');
|
|
1395
1394
|
});
|
|
@@ -1506,9 +1505,9 @@ var Services = _webexPlugin.default.extend({
|
|
|
1506
1505
|
case 2:
|
|
1507
1506
|
supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1508
1507
|
if (supertoken && supertoken.access_token) {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1508
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1509
|
+
// postauth catalog is collected.
|
|
1510
|
+
_this11.initServiceCatalogs().catch(function (error) {
|
|
1512
1511
|
_this11.initFailed = true;
|
|
1513
1512
|
_this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1514
1513
|
});
|
|
@@ -1544,7 +1543,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
1544
1543
|
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1545
1544
|
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1546
1545
|
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1547
|
-
var
|
|
1546
|
+
var _this12$webex$config, _this12$webex$config$;
|
|
1547
|
+
var cachedCatalog, supertoken, initTimeoutMs, initServiceCatalogsTimeout, email;
|
|
1548
1548
|
return _regenerator.default.wrap(function (_context6) {
|
|
1549
1549
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1550
1550
|
case 0:
|
|
@@ -1564,16 +1564,19 @@ var Services = _webexPlugin.default.extend({
|
|
|
1564
1564
|
case 3:
|
|
1565
1565
|
supertoken = _this12.webex.credentials.supertoken; // Race init against a hard timeout so a hung request never leaves
|
|
1566
1566
|
// `services.ready` false forever - that would stall `webex.ready` and
|
|
1567
|
-
// leave
|
|
1568
|
-
|
|
1567
|
+
// leave consumers waiting on it indefinitely. Timeout is configurable via
|
|
1568
|
+
// `config.services.catalogInitTimeout` (defaults to 15s in config).
|
|
1569
|
+
initTimeoutMs = (_this12$webex$config = _this12.webex.config) === null || _this12$webex$config === void 0 ? void 0 : (_this12$webex$config$ = _this12$webex$config.services) === null || _this12$webex$config$ === void 0 ? void 0 : _this12$webex$config$.catalogInitTimeout;
|
|
1570
|
+
initServiceCatalogsTimeout = new _promise.default(function (_, reject) {
|
|
1569
1571
|
setTimeout(function () {
|
|
1570
|
-
return reject(new Error("services: init timed out after ".concat(
|
|
1571
|
-
},
|
|
1572
|
+
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1573
|
+
}, initTimeoutMs);
|
|
1572
1574
|
}); // Validate if the supertoken exists.
|
|
1573
1575
|
if (supertoken && supertoken.access_token) {
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1576
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1577
|
+
// postauth catalog is collected - even if it loses the timeout race
|
|
1578
|
+
// above, so a slow fetch still eventually flips `catalog.isReady`.
|
|
1579
|
+
_promise.default.race([_this12.initServiceCatalogs(), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1577
1580
|
_this12.initFailed = true;
|
|
1578
1581
|
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1579
1582
|
}).finally(function () {
|
|
@@ -1583,7 +1586,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1583
1586
|
email = _this12.webex.config.email;
|
|
1584
1587
|
_promise.default.race([_this12.collectPreauthCatalog(email ? {
|
|
1585
1588
|
email: email
|
|
1586
|
-
} : undefined),
|
|
1589
|
+
} : undefined), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1587
1590
|
_this12.initFailed = true;
|
|
1588
1591
|
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1589
1592
|
}).finally(function () {
|
|
@@ -1594,9 +1597,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
1594
1597
|
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1595
1598
|
_this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
|
|
1596
1599
|
if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
}).catch(function (error) {
|
|
1600
|
+
// `initServiceCatalogs` marks the catalog ready internally.
|
|
1601
|
+
_this12.initServiceCatalogs().catch(function (error) {
|
|
1600
1602
|
_this12.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1601
1603
|
});
|
|
1602
1604
|
}
|
|
@@ -1609,7 +1611,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1609
1611
|
}, _callee6);
|
|
1610
1612
|
})));
|
|
1611
1613
|
},
|
|
1612
|
-
version: "3.12.0-webex-services-ready.
|
|
1614
|
+
version: "3.12.0-webex-services-ready.4"
|
|
1613
1615
|
});
|
|
1614
1616
|
/* eslint-enable no-underscore-dangle */
|
|
1615
1617
|
var _default = exports.default = Services;
|