@webex/webex-core 3.12.0-next.32 → 3.12.0-next.34
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/config.js +9 -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/services/services.js +196 -28
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +195 -26
- 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 +3 -3
- package/src/config.js +10 -0
- package/src/lib/services/services.js +170 -17
- package/src/lib/services-v2/services-v2.ts +169 -16
- package/test/fixtures/activation-email.ts +22 -0
- package/test/integration/spec/services/services.js +44 -8
- package/test/integration/spec/services-v2/services-v2.js +44 -8
- package/test/unit/spec/services/services.js +307 -2
- package/test/unit/spec/services-v2/services-v2.ts +295 -0
package/dist/config.js
CHANGED
|
@@ -31,6 +31,15 @@ var _default = exports.default = {
|
|
|
31
31
|
* @type {boolean}
|
|
32
32
|
*/
|
|
33
33
|
useUserOnboardingServiceForActivations: false,
|
|
34
|
+
/**
|
|
35
|
+
* Maximum time (in milliseconds) to wait for the initial service catalog
|
|
36
|
+
* collection when `waitForCatalogInit` is enabled, before letting
|
|
37
|
+
* `services.ready` (and therefore `webex.ready`) fire anyway. Prevents a
|
|
38
|
+
* hung catalog request from leaving the app on a permanent spinner.
|
|
39
|
+
*
|
|
40
|
+
* @type {number}
|
|
41
|
+
*/
|
|
42
|
+
catalogInitTimeout: 15000,
|
|
34
43
|
/**
|
|
35
44
|
* A list of services that are available prior to catalog collection.
|
|
36
45
|
*
|
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","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 * 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;AACA;AACA;AACA;IACIC,kBAAkB,EAAE,KAAK;IAEzB;AACJ;AACA;AACA;AACA;IACIC,SAAS,EAAE;MACT;AACN;AACA;AACA;AACA;MACMC,KAAK,EAAEP,OAAO,CAACC,GAAG,CAACO,iBAAiB,IAAI,+BAA+B;MAEvE;AACN;AACA;MACMC,WAAW,EAAET,OAAO,CAACC,GAAG,CAACS,uBAAuB,IAAI,qCAAqC;MAEzF;AACN;AACA;AACA;AACA;MACMC,GAAG,EAAEX,OAAO,CAACC,GAAG,CAACW,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,EAAEP,OAAO,CAACC,GAAG,CAACO,iBAAiB,IAAI,+BAA+B;MACvEU,eAAe,EAAElB,OAAO,CAACC,GAAG,CAACO,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-next.
|
|
305
|
+
version: "3.12.0-next.34"
|
|
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-next.
|
|
603
|
+
version: "3.12.0-next.34"
|
|
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-next.
|
|
535
|
+
version: "3.12.0-next.34"
|
|
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
|
|
@@ -73,6 +73,21 @@ var Services = _webexPlugin.default.extend({
|
|
|
73
73
|
validateDomains: ['boolean', false, true],
|
|
74
74
|
initFailed: ['boolean', false, false]
|
|
75
75
|
},
|
|
76
|
+
session: {
|
|
77
|
+
/**
|
|
78
|
+
* Becomes `true` once the initial catalog collection has completed
|
|
79
|
+
* (successfully or otherwise) and any in-flight credentials refresh has
|
|
80
|
+
* settled. Blocks `webex.ready` so consumers can rely on `webex.ready`
|
|
81
|
+
* implying "catalogs populated AND credential state stable".
|
|
82
|
+
* @instance
|
|
83
|
+
* @memberof Services
|
|
84
|
+
* @type {boolean}
|
|
85
|
+
*/
|
|
86
|
+
ready: {
|
|
87
|
+
default: false,
|
|
88
|
+
type: 'boolean'
|
|
89
|
+
}
|
|
90
|
+
},
|
|
76
91
|
_catalogs: new _weakMap.default(),
|
|
77
92
|
_serviceUrls: null,
|
|
78
93
|
_hostCatalog: null,
|
|
@@ -1350,6 +1365,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1350
1365
|
|
|
1351
1366
|
// Destructure the credentials plugin.
|
|
1352
1367
|
var credentials = this.webex.credentials;
|
|
1368
|
+
var catalog = this._getCatalog();
|
|
1353
1369
|
|
|
1354
1370
|
// Init a promise chain. Must be done as a Promise.resolve() to allow
|
|
1355
1371
|
// credentials#getOrgId() to properly throw.
|
|
@@ -1366,9 +1382,13 @@ var Services = _webexPlugin.default.extend({
|
|
|
1366
1382
|
}).then(function () {
|
|
1367
1383
|
// Validate if the token is authorized.
|
|
1368
1384
|
if (credentials.canAuthorize) {
|
|
1369
|
-
// Attempt to collect the postauth catalog
|
|
1370
|
-
|
|
1371
|
-
|
|
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 () {
|
|
1372
1392
|
_this0.initFailed = true;
|
|
1373
1393
|
_this0.logger.warn('services: cannot retrieve postauth catalog');
|
|
1374
1394
|
});
|
|
@@ -1378,6 +1398,42 @@ var Services = _webexPlugin.default.extend({
|
|
|
1378
1398
|
return _promise.default.resolve();
|
|
1379
1399
|
});
|
|
1380
1400
|
},
|
|
1401
|
+
/**
|
|
1402
|
+
* Await any in-flight credentials refresh, then flip `services.ready` so
|
|
1403
|
+
* `webex.ready` can fire. Closes the parallel-refresh window: if a credential
|
|
1404
|
+
* refresh is in flight when initial catalog collection settles, we must not
|
|
1405
|
+
* signal ready until the refresh has resolved - otherwise downstream
|
|
1406
|
+
* consumers may observe `canAuthorize`/token state that is about to change
|
|
1407
|
+
* under them.
|
|
1408
|
+
*
|
|
1409
|
+
* @private
|
|
1410
|
+
* @returns {Promise<void>}
|
|
1411
|
+
*/
|
|
1412
|
+
_finalizeReady: function _finalizeReady() {
|
|
1413
|
+
var _this1 = this;
|
|
1414
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
1415
|
+
var credentials;
|
|
1416
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
1417
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1418
|
+
case 0:
|
|
1419
|
+
credentials = _this1.webex.credentials;
|
|
1420
|
+
if (!(credentials && credentials.isRefreshing)) {
|
|
1421
|
+
_context4.next = 1;
|
|
1422
|
+
break;
|
|
1423
|
+
}
|
|
1424
|
+
_context4.next = 1;
|
|
1425
|
+
return new _promise.default(function (resolve) {
|
|
1426
|
+
credentials.once('change:isRefreshing', resolve);
|
|
1427
|
+
});
|
|
1428
|
+
case 1:
|
|
1429
|
+
_this1.ready = true;
|
|
1430
|
+
case 2:
|
|
1431
|
+
case "end":
|
|
1432
|
+
return _context4.stop();
|
|
1433
|
+
}
|
|
1434
|
+
}, _callee4);
|
|
1435
|
+
}))();
|
|
1436
|
+
},
|
|
1381
1437
|
/**
|
|
1382
1438
|
* Initializer
|
|
1383
1439
|
*
|
|
@@ -1386,7 +1442,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1386
1442
|
* @returns {Services}
|
|
1387
1443
|
*/
|
|
1388
1444
|
initialize: function initialize() {
|
|
1389
|
-
var
|
|
1445
|
+
var _this10 = this;
|
|
1390
1446
|
var catalog = new _serviceCatalog.default();
|
|
1391
1447
|
var registry = new _serviceRegistry.default();
|
|
1392
1448
|
var state = new _serviceState.default();
|
|
@@ -1394,56 +1450,168 @@ var Services = _webexPlugin.default.extend({
|
|
|
1394
1450
|
this.registries.set(this.webex, registry);
|
|
1395
1451
|
this.states.set(this.webex, state);
|
|
1396
1452
|
|
|
1397
|
-
// Listen for configuration changes once.
|
|
1453
|
+
// Listen for configuration changes once. The config is not populated on the
|
|
1454
|
+
// webex instance until the `change:config` event fires, so any decision that
|
|
1455
|
+
// depends on config values (such as the gated-vs-ungated init below) must be
|
|
1456
|
+
// made from within this handler rather than synchronously in `initialize()`.
|
|
1398
1457
|
this.listenToOnce(this.webex, 'change:config', function () {
|
|
1399
|
-
|
|
1400
|
-
|
|
1458
|
+
var _this10$webex$config, _this10$webex$config$;
|
|
1459
|
+
_this10.initConfig();
|
|
1401
1460
|
|
|
1461
|
+
// Feature flag: when enabled, `webex.ready` is blocked until the initial
|
|
1462
|
+
// catalog collection has settled AND any in-flight credentials refresh has
|
|
1463
|
+
// completed. When disabled (the default), preserves the pre-existing
|
|
1464
|
+
// behavior where `webex.ready` fires as soon as `webex.loaded` does and
|
|
1465
|
+
// the catalog is collected out-of-band.
|
|
1466
|
+
var waitForCatalogInit = ((_this10$webex$config = _this10.webex.config) === null || _this10$webex$config === void 0 ? void 0 : (_this10$webex$config$ = _this10$webex$config.services) === null || _this10$webex$config$ === void 0 ? void 0 : _this10$webex$config$.waitForCatalogInit) === true;
|
|
1467
|
+
if (waitForCatalogInit) {
|
|
1468
|
+
_this10._initializeCatalogsGated(catalog);
|
|
1469
|
+
} else {
|
|
1470
|
+
// Not gating - immediately mark ready so we do not block webex.ready.
|
|
1471
|
+
_this10.ready = true;
|
|
1472
|
+
_this10._initializeCatalogsUngated(catalog);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
},
|
|
1476
|
+
/**
|
|
1477
|
+
* Original (pre-verified-ready) initialization path. Runs on `webex.ready`
|
|
1478
|
+
* and collects catalogs opportunistically without blocking anything.
|
|
1479
|
+
*
|
|
1480
|
+
* @private
|
|
1481
|
+
* @param {ServiceCatalog} catalog
|
|
1482
|
+
* @returns {void}
|
|
1483
|
+
*/
|
|
1484
|
+
_initializeCatalogsUngated: function _initializeCatalogsUngated(catalog) {
|
|
1485
|
+
var _this11 = this;
|
|
1402
1486
|
// wait for webex instance to be ready before attempting
|
|
1403
1487
|
// to update the service catalogs
|
|
1404
1488
|
// this can cause a race condition because credentials may
|
|
1405
1489
|
// not be valid when services is initialized
|
|
1406
|
-
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1490
|
+
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
1407
1491
|
var cachedCatalog, supertoken, email;
|
|
1408
|
-
return _regenerator.default.wrap(function (
|
|
1409
|
-
while (1) switch (
|
|
1492
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
1493
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1410
1494
|
case 0:
|
|
1411
|
-
|
|
1412
|
-
return
|
|
1495
|
+
_context5.next = 1;
|
|
1496
|
+
return _this11._loadCatalogFromCache();
|
|
1413
1497
|
case 1:
|
|
1414
|
-
cachedCatalog =
|
|
1498
|
+
cachedCatalog = _context5.sent;
|
|
1415
1499
|
if (!cachedCatalog) {
|
|
1416
|
-
|
|
1500
|
+
_context5.next = 2;
|
|
1417
1501
|
break;
|
|
1418
1502
|
}
|
|
1419
1503
|
catalog.isReady = true;
|
|
1420
|
-
return
|
|
1504
|
+
return _context5.abrupt("return");
|
|
1421
1505
|
case 2:
|
|
1422
|
-
supertoken =
|
|
1506
|
+
supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1423
1507
|
if (supertoken && supertoken.access_token) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1508
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1509
|
+
// postauth catalog is collected.
|
|
1510
|
+
_this11.initServiceCatalogs().catch(function (error) {
|
|
1511
|
+
_this11.initFailed = true;
|
|
1512
|
+
_this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1429
1513
|
});
|
|
1430
1514
|
} else {
|
|
1431
|
-
email =
|
|
1432
|
-
|
|
1515
|
+
email = _this11.webex.config.email;
|
|
1516
|
+
_this11.collectPreauthCatalog(email ? {
|
|
1433
1517
|
email: email
|
|
1434
1518
|
} : undefined).catch(function (error) {
|
|
1435
|
-
|
|
1436
|
-
|
|
1519
|
+
_this11.initFailed = true;
|
|
1520
|
+
_this11.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1437
1521
|
});
|
|
1438
1522
|
}
|
|
1439
1523
|
case 3:
|
|
1440
1524
|
case "end":
|
|
1441
|
-
return
|
|
1525
|
+
return _context5.stop();
|
|
1442
1526
|
}
|
|
1443
|
-
},
|
|
1527
|
+
}, _callee5);
|
|
1528
|
+
})));
|
|
1529
|
+
},
|
|
1530
|
+
/**
|
|
1531
|
+
* Verified-ready initialization path. Blocks `webex.ready` until the initial
|
|
1532
|
+
* catalog fetch has settled (or timed out) AND any in-flight credentials
|
|
1533
|
+
* refresh has completed. Also handles the fresh-login case where OAuth
|
|
1534
|
+
* completes after `loaded` fires.
|
|
1535
|
+
*
|
|
1536
|
+
* @private
|
|
1537
|
+
* @param {ServiceCatalog} catalog
|
|
1538
|
+
* @returns {void}
|
|
1539
|
+
*/
|
|
1540
|
+
_initializeCatalogsGated: function _initializeCatalogsGated(catalog) {
|
|
1541
|
+
var _this12 = this;
|
|
1542
|
+
// Wait for storage to be loaded before attempting to update the service
|
|
1543
|
+
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1544
|
+
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1545
|
+
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1546
|
+
var _this12$webex$config, _this12$webex$config$;
|
|
1547
|
+
var cachedCatalog, supertoken, initTimeoutMs, initServiceCatalogsTimeout, email;
|
|
1548
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
1549
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1550
|
+
case 0:
|
|
1551
|
+
_context6.next = 1;
|
|
1552
|
+
return _this12._loadCatalogFromCache();
|
|
1553
|
+
case 1:
|
|
1554
|
+
cachedCatalog = _context6.sent;
|
|
1555
|
+
if (!cachedCatalog) {
|
|
1556
|
+
_context6.next = 3;
|
|
1557
|
+
break;
|
|
1558
|
+
}
|
|
1559
|
+
catalog.isReady = true;
|
|
1560
|
+
_context6.next = 2;
|
|
1561
|
+
return _this12._finalizeReady();
|
|
1562
|
+
case 2:
|
|
1563
|
+
return _context6.abrupt("return");
|
|
1564
|
+
case 3:
|
|
1565
|
+
supertoken = _this12.webex.credentials.supertoken; // Race init against a hard timeout so a hung request never leaves
|
|
1566
|
+
// `services.ready` false forever - that would stall `webex.ready` and
|
|
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) {
|
|
1571
|
+
setTimeout(function () {
|
|
1572
|
+
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1573
|
+
}, initTimeoutMs);
|
|
1574
|
+
}); // Validate if the supertoken exists.
|
|
1575
|
+
if (supertoken && supertoken.access_token) {
|
|
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) {
|
|
1580
|
+
_this12.initFailed = true;
|
|
1581
|
+
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1582
|
+
}).finally(function () {
|
|
1583
|
+
return _this12._finalizeReady();
|
|
1584
|
+
});
|
|
1585
|
+
} else {
|
|
1586
|
+
email = _this12.webex.config.email;
|
|
1587
|
+
_promise.default.race([_this12.collectPreauthCatalog(email ? {
|
|
1588
|
+
email: email
|
|
1589
|
+
} : undefined), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1590
|
+
_this12.initFailed = true;
|
|
1591
|
+
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1592
|
+
}).finally(function () {
|
|
1593
|
+
return _this12._finalizeReady();
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
// Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1597
|
+
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1598
|
+
_this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
|
|
1599
|
+
if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
1600
|
+
// `initServiceCatalogs` marks the catalog ready internally.
|
|
1601
|
+
_this12.initServiceCatalogs().catch(function (error) {
|
|
1602
|
+
_this12.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
case 4:
|
|
1608
|
+
case "end":
|
|
1609
|
+
return _context6.stop();
|
|
1610
|
+
}
|
|
1611
|
+
}, _callee6);
|
|
1444
1612
|
})));
|
|
1445
1613
|
},
|
|
1446
|
-
version: "3.12.0-next.
|
|
1614
|
+
version: "3.12.0-next.34"
|
|
1447
1615
|
});
|
|
1448
1616
|
/* eslint-enable no-underscore-dangle */
|
|
1449
1617
|
var _default = exports.default = Services;
|