@webex/webex-core 3.12.0-next.40 → 3.12.0-next.42

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 CHANGED
@@ -37,6 +37,15 @@ var _default = exports.default = {
37
37
  * @type {boolean}
38
38
  */
39
39
  useCatalogOverride: false,
40
+ /**
41
+ * When true, skips fetching the preauth catalog during initialization
42
+ * while the user is unauthenticated (no existing token). The catalog is
43
+ * expected to be collected manually later instead. When false (default),
44
+ * the preauth catalog is collected automatically during init.
45
+ *
46
+ * @type {boolean}
47
+ */
48
+ skipPreauthCatalogOnUnauthenticated: false,
40
49
  /**
41
50
  * Maximum time (in milliseconds) to wait for the initial service catalog
42
51
  * collection when `waitForCatalogInit` is enabled, before letting
@@ -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","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":[]}
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","skipPreauthCatalogOnUnauthenticated","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 * When true, skips fetching the preauth catalog during initialization\n * while the user is unauthenticated (no existing token). The catalog is\n * expected to be collected manually later instead. When false (default),\n * the preauth catalog is collected automatically during init.\n *\n * @type {boolean}\n */\n skipPreauthCatalogOnUnauthenticated: 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,mCAAmC,EAAE,KAAK;IAE1C;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,EAAET,OAAO,CAACC,GAAG,CAACS,iBAAiB,IAAI,+BAA+B;MAEvE;AACN;AACA;MACMC,WAAW,EAAEX,OAAO,CAACC,GAAG,CAACW,uBAAuB,IAAI,qCAAqC;MAEzF;AACN;AACA;AACA;AACA;MACMC,GAAG,EAAEb,OAAO,CAACC,GAAG,CAACa,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,EAAET,OAAO,CAACC,GAAG,CAACS,iBAAiB,IAAI,+BAA+B;MACvEU,eAAe,EAAEpB,OAAO,CAACC,GAAG,CAACS,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":[]}
@@ -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.40"
305
+ version: "3.12.0-next.42"
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.40"
603
+ version: "3.12.0-next.42"
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.40"
535
+ version: "3.12.0-next.42"
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
@@ -1434,6 +1434,26 @@ var Services = _webexPlugin.default.extend({
1434
1434
  }, _callee4);
1435
1435
  }))();
1436
1436
  },
1437
+ /**
1438
+ * Build a promise that rejects once the catalog init timeout elapses. Race
1439
+ * this against catalog collection so a hung request never leaves
1440
+ * `services.ready` false forever - that would stall `webex.ready` and leave
1441
+ * consumers waiting on it indefinitely. Timeout is configurable via
1442
+ * `config.services.catalogInitTimeout` (defaults to 15s in config). Created
1443
+ * lazily so paths that skip catalog collection never schedule a stray timer.
1444
+ *
1445
+ * @private
1446
+ * @returns {Promise<never>}
1447
+ */
1448
+ _makeInitTimeout: function _makeInitTimeout() {
1449
+ var _this$webex$config3, _this$webex$config3$s;
1450
+ var initTimeoutMs = (_this$webex$config3 = this.webex.config) === null || _this$webex$config3 === void 0 ? void 0 : (_this$webex$config3$s = _this$webex$config3.services) === null || _this$webex$config3$s === void 0 ? void 0 : _this$webex$config3$s.catalogInitTimeout;
1451
+ return new _promise.default(function (_, reject) {
1452
+ setTimeout(function () {
1453
+ return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
1454
+ }, initTimeoutMs);
1455
+ });
1456
+ },
1437
1457
  /**
1438
1458
  * Initializer
1439
1459
  *
@@ -1488,7 +1508,7 @@ var Services = _webexPlugin.default.extend({
1488
1508
  // this can cause a race condition because credentials may
1489
1509
  // not be valid when services is initialized
1490
1510
  this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
1491
- var cachedCatalog, supertoken, email;
1511
+ var cachedCatalog, supertoken, _this11$webex$config, _this11$webex$config$, email;
1492
1512
  return _regenerator.default.wrap(function (_context5) {
1493
1513
  while (1) switch (_context5.prev = _context5.next) {
1494
1514
  case 0:
@@ -1504,23 +1524,34 @@ var Services = _webexPlugin.default.extend({
1504
1524
  return _context5.abrupt("return");
1505
1525
  case 2:
1506
1526
  supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
1507
- if (supertoken && supertoken.access_token) {
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));
1513
- });
1514
- } else {
1515
- email = _this11.webex.config.email;
1516
- _this11.collectPreauthCatalog(email ? {
1517
- email: email
1518
- } : undefined).catch(function (error) {
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));
1521
- });
1527
+ if (!(supertoken && supertoken.access_token)) {
1528
+ _context5.next = 3;
1529
+ break;
1522
1530
  }
1531
+ // `initServiceCatalogs` marks the catalog ready internally once the
1532
+ // postauth catalog is collected.
1533
+ _this11.initServiceCatalogs().catch(function (error) {
1534
+ _this11.initFailed = true;
1535
+ _this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1536
+ });
1537
+ _context5.next = 5;
1538
+ break;
1523
1539
  case 3:
1540
+ email = _this11.webex.config.email;
1541
+ if (!(((_this11$webex$config = _this11.webex.config) === null || _this11$webex$config === void 0 ? void 0 : (_this11$webex$config$ = _this11$webex$config.services) === null || _this11$webex$config$ === void 0 ? void 0 : _this11$webex$config$.skipPreauthCatalogOnUnauthenticated) === true)) {
1542
+ _context5.next = 4;
1543
+ break;
1544
+ }
1545
+ _this11.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
1546
+ return _context5.abrupt("return");
1547
+ case 4:
1548
+ _this11.collectPreauthCatalog(email ? {
1549
+ email: email
1550
+ } : undefined).catch(function (error) {
1551
+ _this11.initFailed = true;
1552
+ _this11.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1553
+ });
1554
+ case 5:
1524
1555
  case "end":
1525
1556
  return _context5.stop();
1526
1557
  }
@@ -1543,8 +1574,7 @@ var Services = _webexPlugin.default.extend({
1543
1574
  // catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
1544
1575
  // now blocks `webex.ready` - listening to 'ready' would deadlock.
1545
1576
  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;
1577
+ var cachedCatalog, supertoken, _this12$webex$config, _this12$webex$config$, email;
1548
1578
  return _regenerator.default.wrap(function (_context6) {
1549
1579
  while (1) switch (_context6.prev = _context6.next) {
1550
1580
  case 0:
@@ -1562,38 +1592,19 @@ var Services = _webexPlugin.default.extend({
1562
1592
  case 2:
1563
1593
  return _context6.abrupt("return");
1564
1594
  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.
1595
+ supertoken = _this12.webex.credentials.supertoken; // Validate if the supertoken exists.
1575
1596
  if (supertoken && supertoken.access_token) {
1576
1597
  // `initServiceCatalogs` marks the catalog ready internally once the
1577
1598
  // 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) {
1599
+ // below, so a slow fetch still eventually flips `catalog.isReady`.
1600
+ _promise.default.race([_this12.initServiceCatalogs(), _this12._makeInitTimeout()]).catch(function (error) {
1580
1601
  _this12.initFailed = true;
1581
1602
  _this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1582
1603
  }).finally(function () {
1583
1604
  return _this12._finalizeReady();
1584
1605
  });
1585
1606
  } 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
1607
+ email = _this12.webex.config.email; // Handle fresh login: 'loaded' fires before OAuth completes, so listen
1597
1608
  // for `canAuthorize` flipping true and then collect the postauth catalog.
1598
1609
  _this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
1599
1610
  if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
@@ -1603,6 +1614,23 @@ var Services = _webexPlugin.default.extend({
1603
1614
  });
1604
1615
  }
1605
1616
  });
1617
+ if (((_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$.skipPreauthCatalogOnUnauthenticated) === true) {
1618
+ // Skip the preauth catalog fetch (it will be collected manually
1619
+ // later), but still finalize `services.ready` so `webex.ready` is not
1620
+ // stalled while unauthenticated. No timeout is created here so there
1621
+ // is no stray timer or unhandled rejection.
1622
+ _this12.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
1623
+ _this12._finalizeReady();
1624
+ } else {
1625
+ _promise.default.race([_this12.collectPreauthCatalog(email ? {
1626
+ email: email
1627
+ } : undefined), _this12._makeInitTimeout()]).catch(function (error) {
1628
+ _this12.initFailed = true;
1629
+ _this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1630
+ }).finally(function () {
1631
+ return _this12._finalizeReady();
1632
+ });
1633
+ }
1606
1634
  }
1607
1635
  case 4:
1608
1636
  case "end":
@@ -1611,7 +1639,7 @@ var Services = _webexPlugin.default.extend({
1611
1639
  }, _callee6);
1612
1640
  })));
1613
1641
  },
1614
- version: "3.12.0-next.40"
1642
+ version: "3.12.0-next.42"
1615
1643
  });
1616
1644
  /* eslint-enable no-underscore-dangle */
1617
1645
  var _default = exports.default = Services;