@webex/webex-core 3.11.0 → 3.12.0-llmrefactor.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 +15 -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 +217 -31
- 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 +221 -30
- 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 +17 -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 +192 -17
- package/src/lib/services-v2/service-catalog.ts +6 -11
- package/src/lib/services-v2/services-v2.ts +195 -17
- package/test/fixtures/activation-email.ts +22 -0
- package/test/integration/spec/services/services.js +44 -8
- package/test/integration/spec/services-v2/services-v2.js +44 -8
- package/test/unit/spec/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 +358 -2
- package/test/unit/spec/services-v2/service-catalog.ts +93 -11
- package/test/unit/spec/services-v2/services-v2.ts +362 -0
|
@@ -73,6 +73,21 @@ var Services = _webexPlugin.default.extend({
|
|
|
73
73
|
validateDomains: ['boolean', false, true],
|
|
74
74
|
initFailed: ['boolean', false, false]
|
|
75
75
|
},
|
|
76
|
+
session: {
|
|
77
|
+
/**
|
|
78
|
+
* Becomes `true` once the initial catalog collection has completed
|
|
79
|
+
* (successfully or otherwise) and any in-flight credentials refresh has
|
|
80
|
+
* settled. Blocks `webex.ready` so consumers can rely on `webex.ready`
|
|
81
|
+
* implying "catalogs populated AND credential state stable".
|
|
82
|
+
* @instance
|
|
83
|
+
* @memberof Services
|
|
84
|
+
* @type {boolean}
|
|
85
|
+
*/
|
|
86
|
+
ready: {
|
|
87
|
+
default: false,
|
|
88
|
+
type: 'boolean'
|
|
89
|
+
}
|
|
90
|
+
},
|
|
76
91
|
_catalogs: new _weakMap.default(),
|
|
77
92
|
_serviceUrls: null,
|
|
78
93
|
_hostCatalog: null,
|
|
@@ -243,6 +258,24 @@ var Services = _webexPlugin.default.extend({
|
|
|
243
258
|
var hostCatalog = this._hostCatalog || {};
|
|
244
259
|
return !!((_hostCatalog$host = hostCatalog[host]) !== null && _hostCatalog$host !== void 0 && _hostCatalog$host.length);
|
|
245
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
|
+
},
|
|
246
279
|
/**
|
|
247
280
|
* Merge provided active cluster mappings into current state.
|
|
248
281
|
* @param {Record<string,string>} activeServices
|
|
@@ -1271,9 +1304,9 @@ var Services = _webexPlugin.default.extend({
|
|
|
1271
1304
|
initConfig: function initConfig() {
|
|
1272
1305
|
// Get the catalog and destructure the services config.
|
|
1273
1306
|
var catalog = this._getCatalog();
|
|
1274
|
-
var _this$webex$
|
|
1275
|
-
services = _this$webex$
|
|
1276
|
-
fedramp = _this$webex$
|
|
1307
|
+
var _this$webex$config2 = this.webex.config,
|
|
1308
|
+
services = _this$webex$config2.services,
|
|
1309
|
+
fedramp = _this$webex$config2.fedramp;
|
|
1277
1310
|
|
|
1278
1311
|
// Validate that the services configuration exists.
|
|
1279
1312
|
if (services) {
|
|
@@ -1332,6 +1365,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1332
1365
|
|
|
1333
1366
|
// Destructure the credentials plugin.
|
|
1334
1367
|
var credentials = this.webex.credentials;
|
|
1368
|
+
var catalog = this._getCatalog();
|
|
1335
1369
|
|
|
1336
1370
|
// Init a promise chain. Must be done as a Promise.resolve() to allow
|
|
1337
1371
|
// credentials#getOrgId() to properly throw.
|
|
@@ -1348,9 +1382,13 @@ var Services = _webexPlugin.default.extend({
|
|
|
1348
1382
|
}).then(function () {
|
|
1349
1383
|
// Validate if the token is authorized.
|
|
1350
1384
|
if (credentials.canAuthorize) {
|
|
1351
|
-
// Attempt to collect the postauth catalog
|
|
1352
|
-
|
|
1353
|
-
|
|
1385
|
+
// Attempt to collect the postauth catalog, then mark the catalog
|
|
1386
|
+
// ready. Setting `isReady` here - rather than only in the init
|
|
1387
|
+
// callers - means a slow postauth fetch that loses the gated-init
|
|
1388
|
+
// timeout race still marks the catalog ready once it completes.
|
|
1389
|
+
return _this0.updateServices().then(function () {
|
|
1390
|
+
catalog.isReady = true;
|
|
1391
|
+
}).catch(function () {
|
|
1354
1392
|
_this0.initFailed = true;
|
|
1355
1393
|
_this0.logger.warn('services: cannot retrieve postauth catalog');
|
|
1356
1394
|
});
|
|
@@ -1360,6 +1398,42 @@ var Services = _webexPlugin.default.extend({
|
|
|
1360
1398
|
return _promise.default.resolve();
|
|
1361
1399
|
});
|
|
1362
1400
|
},
|
|
1401
|
+
/**
|
|
1402
|
+
* Await any in-flight credentials refresh, then flip `services.ready` so
|
|
1403
|
+
* `webex.ready` can fire. Closes the parallel-refresh window: if a credential
|
|
1404
|
+
* refresh is in flight when initial catalog collection settles, we must not
|
|
1405
|
+
* signal ready until the refresh has resolved - otherwise downstream
|
|
1406
|
+
* consumers may observe `canAuthorize`/token state that is about to change
|
|
1407
|
+
* under them.
|
|
1408
|
+
*
|
|
1409
|
+
* @private
|
|
1410
|
+
* @returns {Promise<void>}
|
|
1411
|
+
*/
|
|
1412
|
+
_finalizeReady: function _finalizeReady() {
|
|
1413
|
+
var _this1 = this;
|
|
1414
|
+
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
1415
|
+
var credentials;
|
|
1416
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
1417
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1418
|
+
case 0:
|
|
1419
|
+
credentials = _this1.webex.credentials;
|
|
1420
|
+
if (!(credentials && credentials.isRefreshing)) {
|
|
1421
|
+
_context4.next = 1;
|
|
1422
|
+
break;
|
|
1423
|
+
}
|
|
1424
|
+
_context4.next = 1;
|
|
1425
|
+
return new _promise.default(function (resolve) {
|
|
1426
|
+
credentials.once('change:isRefreshing', resolve);
|
|
1427
|
+
});
|
|
1428
|
+
case 1:
|
|
1429
|
+
_this1.ready = true;
|
|
1430
|
+
case 2:
|
|
1431
|
+
case "end":
|
|
1432
|
+
return _context4.stop();
|
|
1433
|
+
}
|
|
1434
|
+
}, _callee4);
|
|
1435
|
+
}))();
|
|
1436
|
+
},
|
|
1363
1437
|
/**
|
|
1364
1438
|
* Initializer
|
|
1365
1439
|
*
|
|
@@ -1368,7 +1442,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1368
1442
|
* @returns {Services}
|
|
1369
1443
|
*/
|
|
1370
1444
|
initialize: function initialize() {
|
|
1371
|
-
var
|
|
1445
|
+
var _this10 = this;
|
|
1372
1446
|
var catalog = new _serviceCatalog.default();
|
|
1373
1447
|
var registry = new _serviceRegistry.default();
|
|
1374
1448
|
var state = new _serviceState.default();
|
|
@@ -1376,56 +1450,168 @@ var Services = _webexPlugin.default.extend({
|
|
|
1376
1450
|
this.registries.set(this.webex, registry);
|
|
1377
1451
|
this.states.set(this.webex, state);
|
|
1378
1452
|
|
|
1379
|
-
// Listen for configuration changes once.
|
|
1453
|
+
// Listen for configuration changes once. The config is not populated on the
|
|
1454
|
+
// webex instance until the `change:config` event fires, so any decision that
|
|
1455
|
+
// depends on config values (such as the gated-vs-ungated init below) must be
|
|
1456
|
+
// made from within this handler rather than synchronously in `initialize()`.
|
|
1380
1457
|
this.listenToOnce(this.webex, 'change:config', function () {
|
|
1381
|
-
|
|
1382
|
-
|
|
1458
|
+
var _this10$webex$config, _this10$webex$config$;
|
|
1459
|
+
_this10.initConfig();
|
|
1383
1460
|
|
|
1461
|
+
// Feature flag: when enabled, `webex.ready` is blocked until the initial
|
|
1462
|
+
// catalog collection has settled AND any in-flight credentials refresh has
|
|
1463
|
+
// completed. When disabled (the default), preserves the pre-existing
|
|
1464
|
+
// behavior where `webex.ready` fires as soon as `webex.loaded` does and
|
|
1465
|
+
// the catalog is collected out-of-band.
|
|
1466
|
+
var waitForCatalogInit = ((_this10$webex$config = _this10.webex.config) === null || _this10$webex$config === void 0 ? void 0 : (_this10$webex$config$ = _this10$webex$config.services) === null || _this10$webex$config$ === void 0 ? void 0 : _this10$webex$config$.waitForCatalogInit) === true;
|
|
1467
|
+
if (waitForCatalogInit) {
|
|
1468
|
+
_this10._initializeCatalogsGated(catalog);
|
|
1469
|
+
} else {
|
|
1470
|
+
// Not gating - immediately mark ready so we do not block webex.ready.
|
|
1471
|
+
_this10.ready = true;
|
|
1472
|
+
_this10._initializeCatalogsUngated(catalog);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
},
|
|
1476
|
+
/**
|
|
1477
|
+
* Original (pre-verified-ready) initialization path. Runs on `webex.ready`
|
|
1478
|
+
* and collects catalogs opportunistically without blocking anything.
|
|
1479
|
+
*
|
|
1480
|
+
* @private
|
|
1481
|
+
* @param {ServiceCatalog} catalog
|
|
1482
|
+
* @returns {void}
|
|
1483
|
+
*/
|
|
1484
|
+
_initializeCatalogsUngated: function _initializeCatalogsUngated(catalog) {
|
|
1485
|
+
var _this11 = this;
|
|
1384
1486
|
// wait for webex instance to be ready before attempting
|
|
1385
1487
|
// to update the service catalogs
|
|
1386
1488
|
// this can cause a race condition because credentials may
|
|
1387
1489
|
// not be valid when services is initialized
|
|
1388
|
-
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1490
|
+
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
1389
1491
|
var cachedCatalog, supertoken, email;
|
|
1390
|
-
return _regenerator.default.wrap(function (
|
|
1391
|
-
while (1) switch (
|
|
1492
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
1493
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1392
1494
|
case 0:
|
|
1393
|
-
|
|
1394
|
-
return
|
|
1495
|
+
_context5.next = 1;
|
|
1496
|
+
return _this11._loadCatalogFromCache();
|
|
1395
1497
|
case 1:
|
|
1396
|
-
cachedCatalog =
|
|
1498
|
+
cachedCatalog = _context5.sent;
|
|
1397
1499
|
if (!cachedCatalog) {
|
|
1398
|
-
|
|
1500
|
+
_context5.next = 2;
|
|
1399
1501
|
break;
|
|
1400
1502
|
}
|
|
1401
1503
|
catalog.isReady = true;
|
|
1402
|
-
return
|
|
1504
|
+
return _context5.abrupt("return");
|
|
1403
1505
|
case 2:
|
|
1404
|
-
supertoken =
|
|
1506
|
+
supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1405
1507
|
if (supertoken && supertoken.access_token) {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
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));
|
|
1411
1513
|
});
|
|
1412
1514
|
} else {
|
|
1413
|
-
email =
|
|
1414
|
-
|
|
1515
|
+
email = _this11.webex.config.email;
|
|
1516
|
+
_this11.collectPreauthCatalog(email ? {
|
|
1415
1517
|
email: email
|
|
1416
1518
|
} : undefined).catch(function (error) {
|
|
1417
|
-
|
|
1418
|
-
|
|
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));
|
|
1419
1521
|
});
|
|
1420
1522
|
}
|
|
1421
1523
|
case 3:
|
|
1422
1524
|
case "end":
|
|
1423
|
-
return
|
|
1525
|
+
return _context5.stop();
|
|
1424
1526
|
}
|
|
1425
|
-
},
|
|
1527
|
+
}, _callee5);
|
|
1528
|
+
})));
|
|
1529
|
+
},
|
|
1530
|
+
/**
|
|
1531
|
+
* Verified-ready initialization path. Blocks `webex.ready` until the initial
|
|
1532
|
+
* catalog fetch has settled (or timed out) AND any in-flight credentials
|
|
1533
|
+
* refresh has completed. Also handles the fresh-login case where OAuth
|
|
1534
|
+
* completes after `loaded` fires.
|
|
1535
|
+
*
|
|
1536
|
+
* @private
|
|
1537
|
+
* @param {ServiceCatalog} catalog
|
|
1538
|
+
* @returns {void}
|
|
1539
|
+
*/
|
|
1540
|
+
_initializeCatalogsGated: function _initializeCatalogsGated(catalog) {
|
|
1541
|
+
var _this12 = this;
|
|
1542
|
+
// Wait for storage to be loaded before attempting to update the service
|
|
1543
|
+
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1544
|
+
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1545
|
+
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1546
|
+
var _this12$webex$config, _this12$webex$config$;
|
|
1547
|
+
var cachedCatalog, supertoken, initTimeoutMs, initServiceCatalogsTimeout, email;
|
|
1548
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
1549
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1550
|
+
case 0:
|
|
1551
|
+
_context6.next = 1;
|
|
1552
|
+
return _this12._loadCatalogFromCache();
|
|
1553
|
+
case 1:
|
|
1554
|
+
cachedCatalog = _context6.sent;
|
|
1555
|
+
if (!cachedCatalog) {
|
|
1556
|
+
_context6.next = 3;
|
|
1557
|
+
break;
|
|
1558
|
+
}
|
|
1559
|
+
catalog.isReady = true;
|
|
1560
|
+
_context6.next = 2;
|
|
1561
|
+
return _this12._finalizeReady();
|
|
1562
|
+
case 2:
|
|
1563
|
+
return _context6.abrupt("return");
|
|
1564
|
+
case 3:
|
|
1565
|
+
supertoken = _this12.webex.credentials.supertoken; // Race init against a hard timeout so a hung request never leaves
|
|
1566
|
+
// `services.ready` false forever - that would stall `webex.ready` and
|
|
1567
|
+
// leave consumers waiting on it indefinitely. Timeout is configurable via
|
|
1568
|
+
// `config.services.catalogInitTimeout` (defaults to 15s in config).
|
|
1569
|
+
initTimeoutMs = (_this12$webex$config = _this12.webex.config) === null || _this12$webex$config === void 0 ? void 0 : (_this12$webex$config$ = _this12$webex$config.services) === null || _this12$webex$config$ === void 0 ? void 0 : _this12$webex$config$.catalogInitTimeout;
|
|
1570
|
+
initServiceCatalogsTimeout = new _promise.default(function (_, reject) {
|
|
1571
|
+
setTimeout(function () {
|
|
1572
|
+
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1573
|
+
}, initTimeoutMs);
|
|
1574
|
+
}); // Validate if the supertoken exists.
|
|
1575
|
+
if (supertoken && supertoken.access_token) {
|
|
1576
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1577
|
+
// postauth catalog is collected - even if it loses the timeout race
|
|
1578
|
+
// above, so a slow fetch still eventually flips `catalog.isReady`.
|
|
1579
|
+
_promise.default.race([_this12.initServiceCatalogs(), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1580
|
+
_this12.initFailed = true;
|
|
1581
|
+
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1582
|
+
}).finally(function () {
|
|
1583
|
+
return _this12._finalizeReady();
|
|
1584
|
+
});
|
|
1585
|
+
} else {
|
|
1586
|
+
email = _this12.webex.config.email;
|
|
1587
|
+
_promise.default.race([_this12.collectPreauthCatalog(email ? {
|
|
1588
|
+
email: email
|
|
1589
|
+
} : undefined), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1590
|
+
_this12.initFailed = true;
|
|
1591
|
+
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1592
|
+
}).finally(function () {
|
|
1593
|
+
return _this12._finalizeReady();
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
// Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1597
|
+
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1598
|
+
_this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
|
|
1599
|
+
if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
1600
|
+
// `initServiceCatalogs` marks the catalog ready internally.
|
|
1601
|
+
_this12.initServiceCatalogs().catch(function (error) {
|
|
1602
|
+
_this12.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
case 4:
|
|
1608
|
+
case "end":
|
|
1609
|
+
return _context6.stop();
|
|
1610
|
+
}
|
|
1611
|
+
}, _callee6);
|
|
1426
1612
|
})));
|
|
1427
1613
|
},
|
|
1428
|
-
version: "
|
|
1614
|
+
version: "3.12.0-llmrefactor.1"
|
|
1429
1615
|
});
|
|
1430
1616
|
/* eslint-enable no-underscore-dangle */
|
|
1431
1617
|
var _default = exports.default = Services;
|