@webex/webex-core 3.12.0-next.7 → 3.12.0-next.70

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.
Files changed (75) hide show
  1. package/.repo-context.json +653 -0
  2. package/.sdd/manifest.json +605 -0
  3. package/AGENTS.md +209 -0
  4. package/README.md +5 -2
  5. package/dist/config.js +45 -0
  6. package/dist/config.js.map +1 -1
  7. package/dist/credentials-config.js +12 -0
  8. package/dist/credentials-config.js.map +1 -1
  9. package/dist/index.js +14 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/interceptors/catalog-url.js +87 -0
  12. package/dist/interceptors/catalog-url.js.map +1 -0
  13. package/dist/interceptors/payload-transformer.js +25 -4
  14. package/dist/interceptors/payload-transformer.js.map +1 -1
  15. package/dist/lib/batcher.js +23 -7
  16. package/dist/lib/batcher.js.map +1 -1
  17. package/dist/lib/credentials/credentials.js +103 -4
  18. package/dist/lib/credentials/credentials.js.map +1 -1
  19. package/dist/lib/credentials/token.js +1 -1
  20. package/dist/lib/domains.js +90 -0
  21. package/dist/lib/domains.js.map +1 -0
  22. package/dist/lib/services/service-catalog.js +108 -18
  23. package/dist/lib/services/service-catalog.js.map +1 -1
  24. package/dist/lib/services/services.js +242 -38
  25. package/dist/lib/services/services.js.map +1 -1
  26. package/dist/lib/services-v2/service-catalog.js +14 -13
  27. package/dist/lib/services-v2/service-catalog.js.map +1 -1
  28. package/dist/lib/services-v2/services-v2.js +255 -42
  29. package/dist/lib/services-v2/services-v2.js.map +1 -1
  30. package/dist/lib/static-asset-loader.js +153 -0
  31. package/dist/lib/static-asset-loader.js.map +1 -0
  32. package/dist/plugins/logger.js +1 -1
  33. package/dist/webex-core.js +11 -3
  34. package/dist/webex-core.js.map +1 -1
  35. package/docs/adr/index.md +32 -0
  36. package/docs/architecture.md +298 -0
  37. package/docs/getting-started.md +96 -0
  38. package/docs/index.md +55 -0
  39. package/docs/specs/README.md +76 -0
  40. package/package.json +13 -13
  41. package/schemas/repo-context.schema.json +796 -0
  42. package/src/config.js +49 -0
  43. package/src/credentials-config.js +13 -0
  44. package/src/docs/README.md +732 -0
  45. package/src/index.js +2 -0
  46. package/src/interceptors/catalog-url.js +66 -0
  47. package/src/interceptors/docs/README.md +658 -0
  48. package/src/interceptors/payload-transformer.js +23 -1
  49. package/src/lib/batcher.js +25 -10
  50. package/src/lib/credentials/credentials.js +93 -3
  51. package/src/lib/credentials/docs/README.md +846 -0
  52. package/src/lib/domains.ts +94 -0
  53. package/src/lib/services/docs/README.md +737 -0
  54. package/src/lib/services/service-catalog.js +112 -16
  55. package/src/lib/services/services.js +220 -22
  56. package/src/lib/services-v2/docs/README.md +751 -0
  57. package/src/lib/services-v2/service-catalog.ts +16 -12
  58. package/src/lib/services-v2/services-v2.ts +234 -24
  59. package/src/lib/static-asset-loader.ts +128 -0
  60. package/src/lib/storage/docs/README.md +646 -0
  61. package/src/webex-core.js +8 -0
  62. package/test/fixtures/activation-email.ts +22 -0
  63. package/test/integration/spec/services/services.js +183 -112
  64. package/test/integration/spec/services-v2/services-v2.js +169 -98
  65. package/test/unit/spec/credentials/credentials.js +247 -3
  66. package/test/unit/spec/interceptors/auth.js +56 -0
  67. package/test/unit/spec/interceptors/catalog-url.js +224 -0
  68. package/test/unit/spec/interceptors/payload-transformer.js +119 -1
  69. package/test/unit/spec/lib/batcher.js +56 -0
  70. package/test/unit/spec/services/service-catalog.js +368 -11
  71. package/test/unit/spec/services/services.js +466 -2
  72. package/test/unit/spec/services-v2/service-catalog.ts +134 -11
  73. package/test/unit/spec/services-v2/services-v2.ts +588 -0
  74. package/test/unit/spec/static-asset-loader.ts +224 -0
  75. package/test/unit/spec/webex-core.js +77 -1
@@ -4,6 +4,100 @@ import AmpState from 'ampersand-state';
4
4
 
5
5
  import {union} from 'lodash';
6
6
  import ServiceUrl from './service-url';
7
+ import {matchAllowedDomain, normalizeAllowedDomains} from '../domains';
8
+
9
+ // Catalog base URLs are a small, stable set, so their parsed origin/path is
10
+ // memoized to avoid repeated `new URL()` work when scanning the catalog on the
11
+ // request hot path.
12
+ const catalogUrlCache = new Map();
13
+
14
+ /**
15
+ * Parse a catalog URL into the origin and normalized path used for matching,
16
+ * memoizing the result. Returns null when the URL is unparsable.
17
+ *
18
+ * @param {string} catalogUrlString - The catalog URL to parse
19
+ * @returns {{origin: string, path: string} | null} - Parsed catalog URL, or null
20
+ */
21
+ export function parseCatalogUrl(catalogUrlString) {
22
+ if (catalogUrlCache.has(catalogUrlString)) {
23
+ return catalogUrlCache.get(catalogUrlString);
24
+ }
25
+
26
+ let parsed = null;
27
+
28
+ try {
29
+ const catalogUrl = new URL(catalogUrlString);
30
+
31
+ // Normalize paths by removing trailing slashes (except root "/")
32
+ parsed = {origin: catalogUrl.origin, path: catalogUrl.pathname.replace(/\/$/, '') || '/'};
33
+ } catch {
34
+ parsed = null;
35
+ }
36
+
37
+ catalogUrlCache.set(catalogUrlString, parsed);
38
+
39
+ return parsed;
40
+ }
41
+
42
+ /**
43
+ * Check if an already-parsed candidate URL matches a parsed catalog URL with
44
+ * proper origin validation. Allocates nothing, so it is safe to call in a tight
45
+ * loop over the whole catalog.
46
+ *
47
+ * @param {URL} candidateUrl - The parsed candidate URL to validate
48
+ * @param {{origin: string, path: string} | null} parsedCatalogUrl - The parsed catalog URL
49
+ * @returns {boolean} - True if the candidate URL is under the catalog URL's origin and path
50
+ */
51
+ export function matchesParsedCatalogUrl(candidateUrl, parsedCatalogUrl) {
52
+ if (!candidateUrl || !parsedCatalogUrl) {
53
+ return false;
54
+ }
55
+
56
+ // Origins must match exactly (scheme + host + port)
57
+ if (candidateUrl.origin !== parsedCatalogUrl.origin) {
58
+ return false;
59
+ }
60
+
61
+ const catalogPath = parsedCatalogUrl.path;
62
+
63
+ if (catalogPath === '/') {
64
+ // Root path matches everything under this origin
65
+ return true;
66
+ }
67
+
68
+ const candidatePath = candidateUrl.pathname;
69
+
70
+ if (candidatePath.startsWith(catalogPath)) {
71
+ // Ensure we're at a path boundary, not mid-segment
72
+ // e.g., /api/v1 should match /api/v1/foo but not /api/v1extra
73
+ // nextChar is undefined for exact match, '/' for valid extension
74
+ const nextChar = candidatePath[catalogPath.length];
75
+
76
+ return nextChar === '/' || nextChar === undefined;
77
+ }
78
+
79
+ return false;
80
+ }
81
+
82
+ /**
83
+ * Check if a candidate URL matches a catalog URL with proper origin validation.
84
+ * This prevents bypasses like https://trusted.example.attacker.com matching https://trusted.example
85
+ *
86
+ * @param {string} candidateUrlString - The URL to validate
87
+ * @param {string} catalogUrlString - The catalog URL to compare against
88
+ * @returns {boolean} - True if the candidate URL is under the catalog URL's origin and path
89
+ */
90
+ export function matchesCatalogUrl(candidateUrlString, catalogUrlString) {
91
+ let candidateUrl;
92
+
93
+ try {
94
+ candidateUrl = new URL(candidateUrlString);
95
+ } catch {
96
+ return false;
97
+ }
98
+
99
+ return matchesParsedCatalogUrl(candidateUrl, parseCatalogUrl(catalogUrlString));
100
+ }
7
101
 
8
102
  /* eslint-disable no-underscore-dangle */
9
103
  /**
@@ -245,20 +339,27 @@ const ServiceCatalog = AmpState.extend({
245
339
  ...this.serviceGroups.override,
246
340
  ];
247
341
 
342
+ // Invalid URLs cannot match any service
343
+ let candidateUrl;
344
+
345
+ try {
346
+ candidateUrl = new URL(url);
347
+ } catch {
348
+ return undefined;
349
+ }
350
+
248
351
  return serviceUrls.find((serviceUrl) => {
249
- // Check to see if the URL we are checking starts with the default URL
250
- if (url.startsWith(serviceUrl.defaultUrl)) {
352
+ // Check if the URL matches the default URL with proper origin validation
353
+ if (matchesParsedCatalogUrl(candidateUrl, parseCatalogUrl(serviceUrl.defaultUrl))) {
251
354
  return true;
252
355
  }
253
356
 
254
- // If not, we check to see if the alternate URLs match
255
- // These are made by swapping the host of the default URL
256
- // with that of an alternate host
357
+ // Check alternate URLs (built by swapping host with alternate hosts)
257
358
  for (const host of serviceUrl.hosts) {
258
359
  const alternateUrl = new URL(serviceUrl.defaultUrl);
259
360
  alternateUrl.host = host.host;
260
361
 
261
- if (url.startsWith(alternateUrl.toString())) {
362
+ if (matchesParsedCatalogUrl(candidateUrl, parseCatalogUrl(alternateUrl.toString()))) {
262
363
  return true;
263
364
  }
264
365
  }
@@ -268,19 +369,14 @@ const ServiceCatalog = AmpState.extend({
268
369
  },
269
370
 
270
371
  /**
271
- * Finds an allowed domain that matches a specific url.
372
+ * Finds an allowed domain that matches a specific url. The url's hostname
373
+ * must be the allowed domain itself or a subdomain of it.
272
374
  *
273
375
  * @param {string} url - The url to match the allowed domains against.
274
376
  * @returns {string} - The matching allowed domain.
275
377
  */
276
378
  findAllowedDomain(url) {
277
- const urlObj = Url.parse(url);
278
-
279
- if (!urlObj.host) {
280
- return undefined;
281
- }
282
-
283
- return this.allowedDomains.find((allowedDomain) => urlObj.host.includes(allowedDomain));
379
+ return matchAllowedDomain(url, this.allowedDomains);
284
380
  },
285
381
 
286
382
  /**
@@ -367,7 +463,7 @@ const ServiceCatalog = AmpState.extend({
367
463
  * @returns {void}
368
464
  */
369
465
  setAllowedDomains(allowedDomains) {
370
- this.allowedDomains = [...allowedDomains];
466
+ this.allowedDomains = normalizeAllowedDomains(allowedDomains);
371
467
  },
372
468
 
373
469
  /**
@@ -376,7 +472,7 @@ const ServiceCatalog = AmpState.extend({
376
472
  * @returns {void}
377
473
  */
378
474
  addAllowedDomains(newAllowedDomains) {
379
- this.allowedDomains = union(this.allowedDomains, newAllowedDomains);
475
+ this.allowedDomains = union(this.allowedDomains, normalizeAllowedDomains(newAllowedDomains));
380
476
  },
381
477
 
382
478
  /**
@@ -57,6 +57,22 @@ const Services = WebexPlugin.extend({
57
57
  initFailed: ['boolean', false, false],
58
58
  },
59
59
 
60
+ session: {
61
+ /**
62
+ * Becomes `true` once the initial catalog collection has completed
63
+ * (successfully or otherwise) and any in-flight credentials refresh has
64
+ * settled. Blocks `webex.ready` so consumers can rely on `webex.ready`
65
+ * implying "catalogs populated AND credential state stable".
66
+ * @instance
67
+ * @memberof Services
68
+ * @type {boolean}
69
+ */
70
+ ready: {
71
+ default: false,
72
+ type: 'boolean',
73
+ },
74
+ },
75
+
60
76
  _catalogs: new WeakMap(),
61
77
 
62
78
  _serviceUrls: null,
@@ -245,13 +261,23 @@ const Services = WebexPlugin.extend({
245
261
  },
246
262
 
247
263
  /**
248
- * Checks if the current environment is an integration (INT) environment
249
- * by examining the u2c discovery URL from webex config.
264
+ * Checks if the current environment is an integration (INT) environment.
265
+ * Uses the explicit environment config when set, otherwise examines the u2c discovery URL.
250
266
  * INT environments use discovery URLs containing 'intb' (e.g., u2c-intb.ciscospark.com).
251
267
  * @returns {boolean} True if INT environment, false otherwise
252
268
  */
253
269
  isIntegrationEnvironment() {
254
270
  try {
271
+ const configuredEnvironment = this.webex?.config?.environment;
272
+
273
+ if (configuredEnvironment !== undefined) {
274
+ const isIntFromConfig = configuredEnvironment === 'integration';
275
+
276
+ this.logger.info(`services: isIntegrationEnvironment: ${isIntFromConfig} (config)`);
277
+
278
+ return isIntFromConfig;
279
+ }
280
+
255
281
  const u2cUrl = this.webex?.config?.services?.discovery?.u2c || '';
256
282
  const isInt = u2cUrl.includes('intb');
257
283
 
@@ -1087,9 +1113,16 @@ const Services = WebexPlugin.extend({
1087
1113
  requestObject.headers = {authorization: token};
1088
1114
  }
1089
1115
 
1090
- return this.webex.internal.newMetrics.callDiagnosticLatencies
1091
- .measureLatency(() => this.request(requestObject), 'internal.get.u2c.time')
1092
- .then(({body}) => body);
1116
+ const sendRequest = () => this.request(requestObject);
1117
+
1118
+ const responsePromise = this.webex.internal.newMetrics
1119
+ ? this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(
1120
+ sendRequest,
1121
+ 'internal.get.u2c.time'
1122
+ )
1123
+ : sendRequest();
1124
+
1125
+ return responsePromise.then(({body}) => body);
1093
1126
  },
1094
1127
 
1095
1128
  /**
@@ -1346,6 +1379,7 @@ const Services = WebexPlugin.extend({
1346
1379
 
1347
1380
  // Destructure the credentials plugin.
1348
1381
  const {credentials} = this.webex;
1382
+ const catalog = this._getCatalog();
1349
1383
 
1350
1384
  // Init a promise chain. Must be done as a Promise.resolve() to allow
1351
1385
  // credentials#getOrgId() to properly throw.
@@ -1358,12 +1392,18 @@ const Services = WebexPlugin.extend({
1358
1392
  .then(() => {
1359
1393
  // Validate if the token is authorized.
1360
1394
  if (credentials.canAuthorize) {
1361
- // Attempt to collect the postauth catalog.
1362
-
1363
- return this.updateServices().catch(() => {
1364
- this.initFailed = true;
1365
- this.logger.warn('services: cannot retrieve postauth catalog');
1366
- });
1395
+ // Attempt to collect the postauth catalog, then mark the catalog
1396
+ // ready. Setting `isReady` here - rather than only in the init
1397
+ // callers - means a slow postauth fetch that loses the gated-init
1398
+ // timeout race still marks the catalog ready once it completes.
1399
+ return this.updateServices()
1400
+ .then(() => {
1401
+ catalog.isReady = true;
1402
+ })
1403
+ .catch(() => {
1404
+ this.initFailed = true;
1405
+ this.logger.warn('services: cannot retrieve postauth catalog');
1406
+ });
1367
1407
  }
1368
1408
 
1369
1409
  // Return a resolved promise for consistent return value.
@@ -1372,6 +1412,51 @@ const Services = WebexPlugin.extend({
1372
1412
  );
1373
1413
  },
1374
1414
 
1415
+ /**
1416
+ * Await any in-flight credentials refresh, then flip `services.ready` so
1417
+ * `webex.ready` can fire. Closes the parallel-refresh window: if a credential
1418
+ * refresh is in flight when initial catalog collection settles, we must not
1419
+ * signal ready until the refresh has resolved - otherwise downstream
1420
+ * consumers may observe `canAuthorize`/token state that is about to change
1421
+ * under them.
1422
+ *
1423
+ * @private
1424
+ * @returns {Promise<void>}
1425
+ */
1426
+ async _finalizeReady() {
1427
+ const {credentials} = this.webex;
1428
+
1429
+ if (credentials && credentials.isRefreshing) {
1430
+ await new Promise((resolve) => {
1431
+ credentials.once('change:isRefreshing', resolve);
1432
+ });
1433
+ }
1434
+
1435
+ this.ready = true;
1436
+ },
1437
+
1438
+ /**
1439
+ * Build a promise that rejects once the catalog init timeout elapses. Race
1440
+ * this against catalog collection so a hung request never leaves
1441
+ * `services.ready` false forever - that would stall `webex.ready` and leave
1442
+ * consumers waiting on it indefinitely. Timeout is configurable via
1443
+ * `config.services.catalogInitTimeout` (defaults to 15s in config). Created
1444
+ * lazily so paths that skip catalog collection never schedule a stray timer.
1445
+ *
1446
+ * @private
1447
+ * @returns {Promise<never>}
1448
+ */
1449
+ _makeInitTimeout() {
1450
+ const initTimeoutMs = this.webex.config?.services?.catalogInitTimeout;
1451
+
1452
+ return new Promise((_, reject) => {
1453
+ setTimeout(
1454
+ () => reject(new Error(`services: init timed out after ${initTimeoutMs}ms`)),
1455
+ initTimeoutMs
1456
+ );
1457
+ });
1458
+ },
1459
+
1375
1460
  /**
1376
1461
  * Initializer
1377
1462
  *
@@ -1388,11 +1473,39 @@ const Services = WebexPlugin.extend({
1388
1473
  this.registries.set(this.webex, registry);
1389
1474
  this.states.set(this.webex, state);
1390
1475
 
1391
- // Listen for configuration changes once.
1476
+ // Listen for configuration changes once. The config is not populated on the
1477
+ // webex instance until the `change:config` event fires, so any decision that
1478
+ // depends on config values (such as the gated-vs-ungated init below) must be
1479
+ // made from within this handler rather than synchronously in `initialize()`.
1392
1480
  this.listenToOnce(this.webex, 'change:config', () => {
1393
1481
  this.initConfig();
1482
+
1483
+ // Feature flag: when enabled, `webex.ready` is blocked until the initial
1484
+ // catalog collection has settled AND any in-flight credentials refresh has
1485
+ // completed. When disabled (the default), preserves the pre-existing
1486
+ // behavior where `webex.ready` fires as soon as `webex.loaded` does and
1487
+ // the catalog is collected out-of-band.
1488
+ const waitForCatalogInit = this.webex.config?.services?.waitForCatalogInit === true;
1489
+
1490
+ if (waitForCatalogInit) {
1491
+ this._initializeCatalogsGated(catalog);
1492
+ } else {
1493
+ // Not gating - immediately mark ready so we do not block webex.ready.
1494
+ this.ready = true;
1495
+ this._initializeCatalogsUngated(catalog);
1496
+ }
1394
1497
  });
1498
+ },
1395
1499
 
1500
+ /**
1501
+ * Original (pre-verified-ready) initialization path. Runs on `webex.ready`
1502
+ * and collects catalogs opportunistically without blocking anything.
1503
+ *
1504
+ * @private
1505
+ * @param {ServiceCatalog} catalog
1506
+ * @returns {void}
1507
+ */
1508
+ _initializeCatalogsUngated(catalog) {
1396
1509
  // wait for webex instance to be ready before attempting
1397
1510
  // to update the service catalogs
1398
1511
  // this can cause a race condition because credentials may
@@ -1407,19 +1520,25 @@ const Services = WebexPlugin.extend({
1407
1520
  const {supertoken} = this.webex.credentials;
1408
1521
  // Validate if the supertoken exists.
1409
1522
  if (supertoken && supertoken.access_token) {
1410
- this.initServiceCatalogs()
1411
- .then(() => {
1412
- catalog.isReady = true;
1413
- })
1414
- .catch((error) => {
1415
- this.initFailed = true;
1416
- this.logger.error(
1417
- `services: failed to init initial services when credentials available, ${error?.message}`
1418
- );
1419
- });
1523
+ // `initServiceCatalogs` marks the catalog ready internally once the
1524
+ // postauth catalog is collected.
1525
+ this.initServiceCatalogs().catch((error) => {
1526
+ this.initFailed = true;
1527
+ this.logger.error(
1528
+ `services: failed to init initial services when credentials available, ${error?.message}`
1529
+ );
1530
+ });
1420
1531
  } else {
1421
1532
  const {email} = this.webex.config;
1422
1533
 
1534
+ if (this.webex.config?.services?.skipPreauthCatalogOnUnauthenticated === true) {
1535
+ this.logger.info(
1536
+ 'services: skipping preauth catalog collection while unauthenticated as per the config'
1537
+ );
1538
+
1539
+ return;
1540
+ }
1541
+
1423
1542
  this.collectPreauthCatalog(email ? {email} : undefined).catch((error) => {
1424
1543
  this.initFailed = true;
1425
1544
  this.logger.error(
@@ -1429,6 +1548,85 @@ const Services = WebexPlugin.extend({
1429
1548
  }
1430
1549
  });
1431
1550
  },
1551
+
1552
+ /**
1553
+ * Verified-ready initialization path. Blocks `webex.ready` until the initial
1554
+ * catalog fetch has settled (or timed out) AND any in-flight credentials
1555
+ * refresh has completed. Also handles the fresh-login case where OAuth
1556
+ * completes after `loaded` fires.
1557
+ *
1558
+ * @private
1559
+ * @param {ServiceCatalog} catalog
1560
+ * @returns {void}
1561
+ */
1562
+ _initializeCatalogsGated(catalog) {
1563
+ // Wait for storage to be loaded before attempting to update the service
1564
+ // catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
1565
+ // now blocks `webex.ready` - listening to 'ready' would deadlock.
1566
+ this.listenToOnce(this.webex, 'loaded', async () => {
1567
+ const cachedCatalog = await this._loadCatalogFromCache();
1568
+ if (cachedCatalog) {
1569
+ catalog.isReady = true;
1570
+ await this._finalizeReady();
1571
+
1572
+ return; // skip initServiceCatalogs() on reload when cache exists
1573
+ }
1574
+ const {supertoken} = this.webex.credentials;
1575
+
1576
+ // Validate if the supertoken exists.
1577
+ if (supertoken && supertoken.access_token) {
1578
+ // `initServiceCatalogs` marks the catalog ready internally once the
1579
+ // postauth catalog is collected - even if it loses the timeout race
1580
+ // below, so a slow fetch still eventually flips `catalog.isReady`.
1581
+ Promise.race([this.initServiceCatalogs(), this._makeInitTimeout()])
1582
+ .catch((error) => {
1583
+ this.initFailed = true;
1584
+ this.logger.error(
1585
+ `services: failed to init initial services when credentials available, ${error?.message}`
1586
+ );
1587
+ })
1588
+ .finally(() => this._finalizeReady());
1589
+ } else {
1590
+ const {email} = this.webex.config;
1591
+
1592
+ // Handle fresh login: 'loaded' fires before OAuth completes, so listen
1593
+ // for `canAuthorize` flipping true and then collect the postauth catalog.
1594
+ this.listenToOnce(this.webex, 'change:canAuthorize', () => {
1595
+ if (this.webex.canAuthorize && !catalog.status.postauth.ready) {
1596
+ // `initServiceCatalogs` marks the catalog ready internally.
1597
+ this.initServiceCatalogs().catch((error) => {
1598
+ this.logger.error(
1599
+ `services: failed to init service catalogs after auth, ${error?.message}`
1600
+ );
1601
+ });
1602
+ }
1603
+ });
1604
+
1605
+ if (this.webex.config?.services?.skipPreauthCatalogOnUnauthenticated === true) {
1606
+ // Skip the preauth catalog fetch (it will be collected manually
1607
+ // later), but still finalize `services.ready` so `webex.ready` is not
1608
+ // stalled while unauthenticated. No timeout is created here so there
1609
+ // is no stray timer or unhandled rejection.
1610
+ this.logger.info(
1611
+ 'services: skipping preauth catalog collection while unauthenticated as per the config'
1612
+ );
1613
+ this._finalizeReady();
1614
+ } else {
1615
+ Promise.race([
1616
+ this.collectPreauthCatalog(email ? {email} : undefined),
1617
+ this._makeInitTimeout(),
1618
+ ])
1619
+ .catch((error) => {
1620
+ this.initFailed = true;
1621
+ this.logger.error(
1622
+ `services: failed to init initial services when no credentials available, ${error?.message}`
1623
+ );
1624
+ })
1625
+ .finally(() => this._finalizeReady());
1626
+ }
1627
+ }
1628
+ });
1629
+ },
1432
1630
  });
1433
1631
  /* eslint-enable no-underscore-dangle */
1434
1632