@webex/webex-core 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.3

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-llmrefactor.1"
305
+ version: "3.12.0-llmrefactor.3"
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-llmrefactor.1"
603
+ version: "3.12.0-llmrefactor.3"
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-llmrefactor.1"
535
+ version: "3.12.0-llmrefactor.3"
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
@@ -1075,9 +1075,11 @@ var Services = _webexPlugin.default.extend({
1075
1075
  authorization: token
1076
1076
  };
1077
1077
  }
1078
- return this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(function () {
1078
+ var sendRequest = function sendRequest() {
1079
1079
  return _this7.request(requestObject);
1080
- }, 'internal.get.u2c.time').then(function (_ref12) {
1080
+ };
1081
+ var responsePromise = this.webex.internal.newMetrics ? this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(sendRequest, 'internal.get.u2c.time') : sendRequest();
1082
+ return responsePromise.then(function (_ref12) {
1081
1083
  var body = _ref12.body;
1082
1084
  return body;
1083
1085
  });
@@ -1434,6 +1436,26 @@ var Services = _webexPlugin.default.extend({
1434
1436
  }, _callee4);
1435
1437
  }))();
1436
1438
  },
1439
+ /**
1440
+ * Build a promise that rejects once the catalog init timeout elapses. Race
1441
+ * this against catalog collection so a hung request never leaves
1442
+ * `services.ready` false forever - that would stall `webex.ready` and leave
1443
+ * consumers waiting on it indefinitely. Timeout is configurable via
1444
+ * `config.services.catalogInitTimeout` (defaults to 15s in config). Created
1445
+ * lazily so paths that skip catalog collection never schedule a stray timer.
1446
+ *
1447
+ * @private
1448
+ * @returns {Promise<never>}
1449
+ */
1450
+ _makeInitTimeout: function _makeInitTimeout() {
1451
+ var _this$webex$config3, _this$webex$config3$s;
1452
+ 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;
1453
+ return new _promise.default(function (_, reject) {
1454
+ setTimeout(function () {
1455
+ return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
1456
+ }, initTimeoutMs);
1457
+ });
1458
+ },
1437
1459
  /**
1438
1460
  * Initializer
1439
1461
  *
@@ -1488,7 +1510,7 @@ var Services = _webexPlugin.default.extend({
1488
1510
  // this can cause a race condition because credentials may
1489
1511
  // not be valid when services is initialized
1490
1512
  this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
1491
- var cachedCatalog, supertoken, email;
1513
+ var cachedCatalog, supertoken, _this11$webex$config, _this11$webex$config$, email;
1492
1514
  return _regenerator.default.wrap(function (_context5) {
1493
1515
  while (1) switch (_context5.prev = _context5.next) {
1494
1516
  case 0:
@@ -1504,23 +1526,34 @@ var Services = _webexPlugin.default.extend({
1504
1526
  return _context5.abrupt("return");
1505
1527
  case 2:
1506
1528
  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
- });
1529
+ if (!(supertoken && supertoken.access_token)) {
1530
+ _context5.next = 3;
1531
+ break;
1522
1532
  }
1533
+ // `initServiceCatalogs` marks the catalog ready internally once the
1534
+ // postauth catalog is collected.
1535
+ _this11.initServiceCatalogs().catch(function (error) {
1536
+ _this11.initFailed = true;
1537
+ _this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1538
+ });
1539
+ _context5.next = 5;
1540
+ break;
1523
1541
  case 3:
1542
+ email = _this11.webex.config.email;
1543
+ 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)) {
1544
+ _context5.next = 4;
1545
+ break;
1546
+ }
1547
+ _this11.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
1548
+ return _context5.abrupt("return");
1549
+ case 4:
1550
+ _this11.collectPreauthCatalog(email ? {
1551
+ email: email
1552
+ } : undefined).catch(function (error) {
1553
+ _this11.initFailed = true;
1554
+ _this11.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1555
+ });
1556
+ case 5:
1524
1557
  case "end":
1525
1558
  return _context5.stop();
1526
1559
  }
@@ -1543,8 +1576,7 @@ var Services = _webexPlugin.default.extend({
1543
1576
  // catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
1544
1577
  // now blocks `webex.ready` - listening to 'ready' would deadlock.
1545
1578
  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;
1579
+ var cachedCatalog, supertoken, _this12$webex$config, _this12$webex$config$, email;
1548
1580
  return _regenerator.default.wrap(function (_context6) {
1549
1581
  while (1) switch (_context6.prev = _context6.next) {
1550
1582
  case 0:
@@ -1562,38 +1594,19 @@ var Services = _webexPlugin.default.extend({
1562
1594
  case 2:
1563
1595
  return _context6.abrupt("return");
1564
1596
  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.
1597
+ supertoken = _this12.webex.credentials.supertoken; // Validate if the supertoken exists.
1575
1598
  if (supertoken && supertoken.access_token) {
1576
1599
  // `initServiceCatalogs` marks the catalog ready internally once the
1577
1600
  // 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) {
1601
+ // below, so a slow fetch still eventually flips `catalog.isReady`.
1602
+ _promise.default.race([_this12.initServiceCatalogs(), _this12._makeInitTimeout()]).catch(function (error) {
1580
1603
  _this12.initFailed = true;
1581
1604
  _this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1582
1605
  }).finally(function () {
1583
1606
  return _this12._finalizeReady();
1584
1607
  });
1585
1608
  } 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
1609
+ email = _this12.webex.config.email; // Handle fresh login: 'loaded' fires before OAuth completes, so listen
1597
1610
  // for `canAuthorize` flipping true and then collect the postauth catalog.
1598
1611
  _this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
1599
1612
  if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
@@ -1603,6 +1616,23 @@ var Services = _webexPlugin.default.extend({
1603
1616
  });
1604
1617
  }
1605
1618
  });
1619
+ 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) {
1620
+ // Skip the preauth catalog fetch (it will be collected manually
1621
+ // later), but still finalize `services.ready` so `webex.ready` is not
1622
+ // stalled while unauthenticated. No timeout is created here so there
1623
+ // is no stray timer or unhandled rejection.
1624
+ _this12.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
1625
+ _this12._finalizeReady();
1626
+ } else {
1627
+ _promise.default.race([_this12.collectPreauthCatalog(email ? {
1628
+ email: email
1629
+ } : undefined), _this12._makeInitTimeout()]).catch(function (error) {
1630
+ _this12.initFailed = true;
1631
+ _this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
1632
+ }).finally(function () {
1633
+ return _this12._finalizeReady();
1634
+ });
1635
+ }
1606
1636
  }
1607
1637
  case 4:
1608
1638
  case "end":
@@ -1611,7 +1641,7 @@ var Services = _webexPlugin.default.extend({
1611
1641
  }, _callee6);
1612
1642
  })));
1613
1643
  },
1614
- version: "3.12.0-llmrefactor.1"
1644
+ version: "3.12.0-llmrefactor.3"
1615
1645
  });
1616
1646
  /* eslint-enable no-underscore-dangle */
1617
1647
  var _default = exports.default = Services;