@webex/webex-core 3.11.0-webex-services-ready.1 → 3.12.0-auth-prejoin-fetch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/config.js +24 -0
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +12 -0
- package/dist/credentials-config.js.map +1 -1
- package/dist/interceptors/redirect.js +1 -1
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/lib/batcher.js +23 -7
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +48 -4
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/domains.js +90 -0
- package/dist/lib/domains.js.map +1 -0
- package/dist/lib/services/service-catalog.js +6 -10
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +244 -57
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/service-catalog.js +6 -12
- package/dist/lib/services-v2/service-catalog.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +243 -52
- 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/dist/webex-core.js.map +1 -1
- package/package.json +13 -13
- package/src/config.js +27 -0
- package/src/credentials-config.js +13 -0
- package/src/interceptors/redirect.js +4 -1
- package/src/lib/batcher.js +25 -10
- package/src/lib/credentials/credentials.js +50 -3
- package/src/lib/domains.ts +94 -0
- package/src/lib/services/service-catalog.js +6 -10
- package/src/lib/services/services.js +218 -46
- package/src/lib/services-v2/service-catalog.ts +6 -11
- package/src/lib/services-v2/services-v2.ts +218 -42
- package/test/fixtures/activation-email.ts +22 -0
- package/test/integration/spec/services/service-catalog.js +7 -6
- package/test/integration/spec/services/services.js +188 -128
- package/test/integration/spec/services-v2/services-v2.js +174 -114
- package/test/unit/spec/credentials/credentials.js +133 -2
- package/test/unit/spec/interceptors/auth.js +56 -0
- package/test/unit/spec/lib/batcher.js +56 -0
- package/test/unit/spec/services/service-catalog.js +93 -11
- package/test/unit/spec/services/services.js +591 -322
- package/test/unit/spec/services-v2/service-catalog.ts +93 -11
- package/test/unit/spec/services-v2/services-v2.ts +539 -214
- package/test/unit/spec/webex-core.js +0 -2
- package/test/unit/spec/webex-internal-core.js +0 -2
|
@@ -31,7 +31,7 @@ var _serviceState = _interopRequireDefault(require("./service-state"));
|
|
|
31
31
|
var _serviceFedRamp = _interopRequireDefault(require("./service-fed-ramp"));
|
|
32
32
|
var _constants = require("../constants");
|
|
33
33
|
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
34
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
34
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
35
35
|
var trailingSlashes = /(?:^\/)|(?:\/$)/;
|
|
36
36
|
|
|
37
37
|
// The default cluster when one is not provided (usually as 'US' from hydra)
|
|
@@ -75,8 +75,10 @@ var Services = _webexPlugin.default.extend({
|
|
|
75
75
|
},
|
|
76
76
|
session: {
|
|
77
77
|
/**
|
|
78
|
-
* Becomes `true` once
|
|
79
|
-
*
|
|
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".
|
|
80
82
|
* @instance
|
|
81
83
|
* @memberof Services
|
|
82
84
|
* @type {boolean}
|
|
@@ -256,6 +258,24 @@ var Services = _webexPlugin.default.extend({
|
|
|
256
258
|
var hostCatalog = this._hostCatalog || {};
|
|
257
259
|
return !!((_hostCatalog$host = hostCatalog[host]) !== null && _hostCatalog$host !== void 0 && _hostCatalog$host.length);
|
|
258
260
|
},
|
|
261
|
+
/**
|
|
262
|
+
* Checks if the current environment is an integration (INT) environment
|
|
263
|
+
* by examining the u2c discovery URL from webex config.
|
|
264
|
+
* INT environments use discovery URLs containing 'intb' (e.g., u2c-intb.ciscospark.com).
|
|
265
|
+
* @returns {boolean} True if INT environment, false otherwise
|
|
266
|
+
*/
|
|
267
|
+
isIntegrationEnvironment: function isIntegrationEnvironment() {
|
|
268
|
+
try {
|
|
269
|
+
var _this$webex, _this$webex$config, _this$webex$config$se, _this$webex$config$se2;
|
|
270
|
+
var u2cUrl = ((_this$webex = this.webex) === null || _this$webex === void 0 ? void 0 : (_this$webex$config = _this$webex.config) === null || _this$webex$config === void 0 ? void 0 : (_this$webex$config$se = _this$webex$config.services) === null || _this$webex$config$se === void 0 ? void 0 : (_this$webex$config$se2 = _this$webex$config$se.discovery) === null || _this$webex$config$se2 === void 0 ? void 0 : _this$webex$config$se2.u2c) || '';
|
|
271
|
+
var isInt = u2cUrl.includes('intb');
|
|
272
|
+
this.logger.info("services: isIntegrationEnvironment: ".concat(isInt));
|
|
273
|
+
return isInt;
|
|
274
|
+
} catch (error) {
|
|
275
|
+
this.logger.error('services: failed to determine integration environment', error);
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
},
|
|
259
279
|
/**
|
|
260
280
|
* Merge provided active cluster mappings into current state.
|
|
261
281
|
* @param {Record<string,string>} activeServices
|
|
@@ -1055,9 +1075,11 @@ var Services = _webexPlugin.default.extend({
|
|
|
1055
1075
|
authorization: token
|
|
1056
1076
|
};
|
|
1057
1077
|
}
|
|
1058
|
-
|
|
1078
|
+
var sendRequest = function sendRequest() {
|
|
1059
1079
|
return _this7.request(requestObject);
|
|
1060
|
-
}
|
|
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) {
|
|
1061
1083
|
var body = _ref12.body;
|
|
1062
1084
|
return body;
|
|
1063
1085
|
});
|
|
@@ -1284,9 +1306,9 @@ var Services = _webexPlugin.default.extend({
|
|
|
1284
1306
|
initConfig: function initConfig() {
|
|
1285
1307
|
// Get the catalog and destructure the services config.
|
|
1286
1308
|
var catalog = this._getCatalog();
|
|
1287
|
-
var _this$webex$
|
|
1288
|
-
services = _this$webex$
|
|
1289
|
-
fedramp = _this$webex$
|
|
1309
|
+
var _this$webex$config2 = this.webex.config,
|
|
1310
|
+
services = _this$webex$config2.services,
|
|
1311
|
+
fedramp = _this$webex$config2.fedramp;
|
|
1290
1312
|
|
|
1291
1313
|
// Validate that the services configuration exists.
|
|
1292
1314
|
if (services) {
|
|
@@ -1345,6 +1367,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1345
1367
|
|
|
1346
1368
|
// Destructure the credentials plugin.
|
|
1347
1369
|
var credentials = this.webex.credentials;
|
|
1370
|
+
var catalog = this._getCatalog();
|
|
1348
1371
|
|
|
1349
1372
|
// Init a promise chain. Must be done as a Promise.resolve() to allow
|
|
1350
1373
|
// credentials#getOrgId() to properly throw.
|
|
@@ -1361,9 +1384,13 @@ var Services = _webexPlugin.default.extend({
|
|
|
1361
1384
|
}).then(function () {
|
|
1362
1385
|
// Validate if the token is authorized.
|
|
1363
1386
|
if (credentials.canAuthorize) {
|
|
1364
|
-
// Attempt to collect the postauth catalog
|
|
1365
|
-
|
|
1366
|
-
|
|
1387
|
+
// Attempt to collect the postauth catalog, then mark the catalog
|
|
1388
|
+
// ready. Setting `isReady` here - rather than only in the init
|
|
1389
|
+
// callers - means a slow postauth fetch that loses the gated-init
|
|
1390
|
+
// timeout race still marks the catalog ready once it completes.
|
|
1391
|
+
return _this0.updateServices().then(function () {
|
|
1392
|
+
catalog.isReady = true;
|
|
1393
|
+
}).catch(function () {
|
|
1367
1394
|
_this0.initFailed = true;
|
|
1368
1395
|
_this0.logger.warn('services: cannot retrieve postauth catalog');
|
|
1369
1396
|
});
|
|
@@ -1373,6 +1400,62 @@ var Services = _webexPlugin.default.extend({
|
|
|
1373
1400
|
return _promise.default.resolve();
|
|
1374
1401
|
});
|
|
1375
1402
|
},
|
|
1403
|
+
/**
|
|
1404
|
+
* Await any in-flight credentials refresh, then flip `services.ready` so
|
|
1405
|
+
* `webex.ready` can fire. Closes the parallel-refresh window: if a credential
|
|
1406
|
+
* refresh is in flight when initial catalog collection settles, we must not
|
|
1407
|
+
* signal ready until the refresh has resolved - otherwise downstream
|
|
1408
|
+
* consumers may observe `canAuthorize`/token state that is about to change
|
|
1409
|
+
* under them.
|
|
1410
|
+
*
|
|
1411
|
+
* @private
|
|
1412
|
+
* @returns {Promise<void>}
|
|
1413
|
+
*/
|
|
1414
|
+
_finalizeReady: function _finalizeReady() {
|
|
1415
|
+
var _this1 = this;
|
|
1416
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
1417
|
+
var credentials;
|
|
1418
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
1419
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1420
|
+
case 0:
|
|
1421
|
+
credentials = _this1.webex.credentials;
|
|
1422
|
+
if (!(credentials && credentials.isRefreshing)) {
|
|
1423
|
+
_context4.next = 1;
|
|
1424
|
+
break;
|
|
1425
|
+
}
|
|
1426
|
+
_context4.next = 1;
|
|
1427
|
+
return new _promise.default(function (resolve) {
|
|
1428
|
+
credentials.once('change:isRefreshing', resolve);
|
|
1429
|
+
});
|
|
1430
|
+
case 1:
|
|
1431
|
+
_this1.ready = true;
|
|
1432
|
+
case 2:
|
|
1433
|
+
case "end":
|
|
1434
|
+
return _context4.stop();
|
|
1435
|
+
}
|
|
1436
|
+
}, _callee4);
|
|
1437
|
+
}))();
|
|
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
|
+
},
|
|
1376
1459
|
/**
|
|
1377
1460
|
* Initializer
|
|
1378
1461
|
*
|
|
@@ -1381,7 +1464,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1381
1464
|
* @returns {Services}
|
|
1382
1465
|
*/
|
|
1383
1466
|
initialize: function initialize() {
|
|
1384
|
-
var
|
|
1467
|
+
var _this10 = this;
|
|
1385
1468
|
var catalog = new _serviceCatalog.default();
|
|
1386
1469
|
var registry = new _serviceRegistry.default();
|
|
1387
1470
|
var state = new _serviceState.default();
|
|
@@ -1389,72 +1472,176 @@ var Services = _webexPlugin.default.extend({
|
|
|
1389
1472
|
this.registries.set(this.webex, registry);
|
|
1390
1473
|
this.states.set(this.webex, state);
|
|
1391
1474
|
|
|
1392
|
-
// Listen for configuration changes once.
|
|
1475
|
+
// Listen for configuration changes once. The config is not populated on the
|
|
1476
|
+
// webex instance until the `change:config` event fires, so any decision that
|
|
1477
|
+
// depends on config values (such as the gated-vs-ungated init below) must be
|
|
1478
|
+
// made from within this handler rather than synchronously in `initialize()`.
|
|
1393
1479
|
this.listenToOnce(this.webex, 'change:config', function () {
|
|
1394
|
-
|
|
1395
|
-
|
|
1480
|
+
var _this10$webex$config, _this10$webex$config$;
|
|
1481
|
+
_this10.initConfig();
|
|
1396
1482
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
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
|
+
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;
|
|
1489
|
+
if (waitForCatalogInit) {
|
|
1490
|
+
_this10._initializeCatalogsGated(catalog);
|
|
1491
|
+
} else {
|
|
1492
|
+
// Not gating - immediately mark ready so we do not block webex.ready.
|
|
1493
|
+
_this10.ready = true;
|
|
1494
|
+
_this10._initializeCatalogsUngated(catalog);
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
},
|
|
1498
|
+
/**
|
|
1499
|
+
* Original (pre-verified-ready) initialization path. Runs on `webex.ready`
|
|
1500
|
+
* and collects catalogs opportunistically without blocking anything.
|
|
1501
|
+
*
|
|
1502
|
+
* @private
|
|
1503
|
+
* @param {ServiceCatalog} catalog
|
|
1504
|
+
* @returns {void}
|
|
1505
|
+
*/
|
|
1506
|
+
_initializeCatalogsUngated: function _initializeCatalogsUngated(catalog) {
|
|
1507
|
+
var _this11 = this;
|
|
1508
|
+
// wait for webex instance to be ready before attempting
|
|
1509
|
+
// to update the service catalogs
|
|
1510
|
+
// this can cause a race condition because credentials may
|
|
1511
|
+
// not be valid when services is initialized
|
|
1512
|
+
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
1513
|
+
var cachedCatalog, supertoken, _this11$webex$config, _this11$webex$config$, email;
|
|
1514
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
1515
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1404
1516
|
case 0:
|
|
1405
|
-
|
|
1406
|
-
return
|
|
1517
|
+
_context5.next = 1;
|
|
1518
|
+
return _this11._loadCatalogFromCache();
|
|
1519
|
+
case 1:
|
|
1520
|
+
cachedCatalog = _context5.sent;
|
|
1521
|
+
if (!cachedCatalog) {
|
|
1522
|
+
_context5.next = 2;
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
catalog.isReady = true;
|
|
1526
|
+
return _context5.abrupt("return");
|
|
1527
|
+
case 2:
|
|
1528
|
+
supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1529
|
+
if (!(supertoken && supertoken.access_token)) {
|
|
1530
|
+
_context5.next = 3;
|
|
1531
|
+
break;
|
|
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;
|
|
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:
|
|
1557
|
+
case "end":
|
|
1558
|
+
return _context5.stop();
|
|
1559
|
+
}
|
|
1560
|
+
}, _callee5);
|
|
1561
|
+
})));
|
|
1562
|
+
},
|
|
1563
|
+
/**
|
|
1564
|
+
* Verified-ready initialization path. Blocks `webex.ready` until the initial
|
|
1565
|
+
* catalog fetch has settled (or timed out) AND any in-flight credentials
|
|
1566
|
+
* refresh has completed. Also handles the fresh-login case where OAuth
|
|
1567
|
+
* completes after `loaded` fires.
|
|
1568
|
+
*
|
|
1569
|
+
* @private
|
|
1570
|
+
* @param {ServiceCatalog} catalog
|
|
1571
|
+
* @returns {void}
|
|
1572
|
+
*/
|
|
1573
|
+
_initializeCatalogsGated: function _initializeCatalogsGated(catalog) {
|
|
1574
|
+
var _this12 = this;
|
|
1575
|
+
// Wait for storage to be loaded before attempting to update the service
|
|
1576
|
+
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1577
|
+
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1578
|
+
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1579
|
+
var cachedCatalog, supertoken, _this12$webex$config, _this12$webex$config$, email;
|
|
1580
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
1581
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1582
|
+
case 0:
|
|
1583
|
+
_context6.next = 1;
|
|
1584
|
+
return _this12._loadCatalogFromCache();
|
|
1407
1585
|
case 1:
|
|
1408
|
-
cachedCatalog =
|
|
1586
|
+
cachedCatalog = _context6.sent;
|
|
1409
1587
|
if (!cachedCatalog) {
|
|
1410
|
-
|
|
1588
|
+
_context6.next = 3;
|
|
1411
1589
|
break;
|
|
1412
1590
|
}
|
|
1413
1591
|
catalog.isReady = true;
|
|
1414
|
-
|
|
1592
|
+
_context6.next = 2;
|
|
1593
|
+
return _this12._finalizeReady();
|
|
1415
1594
|
case 2:
|
|
1416
|
-
|
|
1595
|
+
return _context6.abrupt("return");
|
|
1596
|
+
case 3:
|
|
1597
|
+
supertoken = _this12.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1417
1598
|
if (supertoken && supertoken.access_token) {
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1599
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1600
|
+
// postauth catalog is collected - even if it loses the timeout race
|
|
1601
|
+
// below, so a slow fetch still eventually flips `catalog.isReady`.
|
|
1602
|
+
_promise.default.race([_this12.initServiceCatalogs(), _this12._makeInitTimeout()]).catch(function (error) {
|
|
1603
|
+
_this12.initFailed = true;
|
|
1604
|
+
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1423
1605
|
}).finally(function () {
|
|
1424
|
-
|
|
1425
|
-
_this1.trigger('services:initialized');
|
|
1606
|
+
return _this12._finalizeReady();
|
|
1426
1607
|
});
|
|
1427
1608
|
} else {
|
|
1428
|
-
email =
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
_this1.ready = true;
|
|
1436
|
-
_this1.trigger('services:initialized');
|
|
1437
|
-
});
|
|
1438
|
-
// Listen for when credentials become available to fetch the full catalog.
|
|
1439
|
-
// This handles fresh login where 'loaded' fires before OAuth completes.
|
|
1440
|
-
_this1.listenToOnce(_this1.webex, 'change:canAuthorize', function () {
|
|
1441
|
-
if (_this1.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
1442
|
-
_this1.initServiceCatalogs().then(function () {
|
|
1443
|
-
catalog.isReady = true;
|
|
1444
|
-
}).catch(function (error) {
|
|
1445
|
-
_this1.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1609
|
+
email = _this12.webex.config.email; // Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1610
|
+
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1611
|
+
_this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
|
|
1612
|
+
if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
1613
|
+
// `initServiceCatalogs` marks the catalog ready internally.
|
|
1614
|
+
_this12.initServiceCatalogs().catch(function (error) {
|
|
1615
|
+
_this12.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1446
1616
|
});
|
|
1447
1617
|
}
|
|
1448
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
|
+
}
|
|
1449
1636
|
}
|
|
1450
|
-
case
|
|
1637
|
+
case 4:
|
|
1451
1638
|
case "end":
|
|
1452
|
-
return
|
|
1639
|
+
return _context6.stop();
|
|
1453
1640
|
}
|
|
1454
|
-
},
|
|
1641
|
+
}, _callee6);
|
|
1455
1642
|
})));
|
|
1456
1643
|
},
|
|
1457
|
-
version: "3.
|
|
1644
|
+
version: "3.12.0-auth-prejoin-fetch.1"
|
|
1458
1645
|
});
|
|
1459
1646
|
/* eslint-enable no-underscore-dangle */
|
|
1460
1647
|
var _default = exports.default = Services;
|