@webex/webex-core 3.12.0-webex-services-ready.1 → 3.12.0-webex-services-ready.2
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/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/services.js +121 -37
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +118 -36
- 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/package.json +3 -3
- package/src/lib/services/services.js +92 -19
- package/src/lib/services-v2/services-v2.ts +90 -18
- package/test/integration/spec/services/services.js +39 -17
- package/test/integration/spec/services-v2/services-v2.js +39 -17
- package/test/unit/spec/services/services.js +402 -322
- package/test/unit/spec/services-v2/services-v2.ts +331 -214
package/dist/lib/batcher.js
CHANGED
|
@@ -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-webex-services-ready.
|
|
305
|
+
version: "3.12.0-webex-services-ready.2"
|
|
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-webex-services-ready.
|
|
603
|
+
version: "3.12.0-webex-services-ready.2"
|
|
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-webex-services-ready.
|
|
535
|
+
version: "3.12.0-webex-services-ready.2"
|
|
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
|
|
@@ -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)
|
|
@@ -81,8 +81,10 @@ var Services = _webexPlugin.default.extend({
|
|
|
81
81
|
},
|
|
82
82
|
session: {
|
|
83
83
|
/**
|
|
84
|
-
* Becomes `true` once
|
|
85
|
-
*
|
|
84
|
+
* Becomes `true` once the initial catalog collection has completed
|
|
85
|
+
* (successfully or otherwise) and any in-flight credentials refresh has
|
|
86
|
+
* settled. Blocks `webex.ready` so consumers can rely on `webex.ready`
|
|
87
|
+
* implying "catalogs populated AND credential state stable".
|
|
86
88
|
* @instance
|
|
87
89
|
* @memberof Services
|
|
88
90
|
* @type {boolean}
|
|
@@ -1426,7 +1428,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
1426
1428
|
});
|
|
1427
1429
|
case 1:
|
|
1428
1430
|
_this1.ready = true;
|
|
1429
|
-
_this1.trigger('services:initialized');
|
|
1430
1431
|
case 2:
|
|
1431
1432
|
case "end":
|
|
1432
1433
|
return _context4.stop();
|
|
@@ -1450,34 +1451,118 @@ var Services = _webexPlugin.default.extend({
|
|
|
1450
1451
|
this.registries.set(this.webex, registry);
|
|
1451
1452
|
this.states.set(this.webex, state);
|
|
1452
1453
|
|
|
1453
|
-
// Listen for configuration changes once.
|
|
1454
|
+
// Listen for configuration changes once. The config is not populated on the
|
|
1455
|
+
// webex instance until the `change:config` event fires, so any decision that
|
|
1456
|
+
// depends on config values (such as the gated-vs-ungated init below) must be
|
|
1457
|
+
// made from within this handler rather than synchronously in `initialize()`.
|
|
1454
1458
|
this.listenToOnce(this.webex, 'change:config', function () {
|
|
1459
|
+
var _this10$webex$config, _this10$webex$config$;
|
|
1455
1460
|
_this10.initConfig();
|
|
1456
|
-
});
|
|
1457
1461
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1462
|
+
// Feature flag: when enabled, `webex.ready` is blocked until the initial
|
|
1463
|
+
// catalog collection has settled AND any in-flight credentials refresh has
|
|
1464
|
+
// completed. When disabled (the default), preserves the pre-existing
|
|
1465
|
+
// behavior where `webex.ready` fires as soon as `webex.loaded` does and
|
|
1466
|
+
// the catalog is collected out-of-band.
|
|
1467
|
+
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;
|
|
1468
|
+
if (waitForCatalogInit) {
|
|
1469
|
+
_this10._initializeCatalogsGated(catalog);
|
|
1470
|
+
} else {
|
|
1471
|
+
// Not gating - immediately mark ready so we do not block webex.ready.
|
|
1472
|
+
_this10.ready = true;
|
|
1473
|
+
_this10._initializeCatalogsUngated(catalog);
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
},
|
|
1477
|
+
/**
|
|
1478
|
+
* Original (pre-verified-ready) initialization path. Runs on `webex.ready`
|
|
1479
|
+
* and collects catalogs opportunistically without blocking anything.
|
|
1480
|
+
*
|
|
1481
|
+
* @private
|
|
1482
|
+
* @param {ServiceCatalog} catalog
|
|
1483
|
+
* @returns {void}
|
|
1484
|
+
*/
|
|
1485
|
+
_initializeCatalogsUngated: function _initializeCatalogsUngated(catalog) {
|
|
1486
|
+
var _this11 = this;
|
|
1487
|
+
// wait for webex instance to be ready before attempting
|
|
1488
|
+
// to update the service catalogs
|
|
1489
|
+
// this can cause a race condition because credentials may
|
|
1490
|
+
// not be valid when services is initialized
|
|
1491
|
+
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
1492
|
+
var cachedCatalog, supertoken, email;
|
|
1463
1493
|
return _regenerator.default.wrap(function (_context5) {
|
|
1464
1494
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1465
1495
|
case 0:
|
|
1466
1496
|
_context5.next = 1;
|
|
1467
|
-
return
|
|
1497
|
+
return _this11._loadCatalogFromCache();
|
|
1468
1498
|
case 1:
|
|
1469
1499
|
cachedCatalog = _context5.sent;
|
|
1470
1500
|
if (!cachedCatalog) {
|
|
1471
|
-
_context5.next =
|
|
1501
|
+
_context5.next = 2;
|
|
1472
1502
|
break;
|
|
1473
1503
|
}
|
|
1474
1504
|
catalog.isReady = true;
|
|
1475
|
-
_context5.next = 2;
|
|
1476
|
-
return _this10._finalizeReady();
|
|
1477
|
-
case 2:
|
|
1478
1505
|
return _context5.abrupt("return");
|
|
1506
|
+
case 2:
|
|
1507
|
+
supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1508
|
+
if (supertoken && supertoken.access_token) {
|
|
1509
|
+
_this11.initServiceCatalogs().then(function () {
|
|
1510
|
+
catalog.isReady = true;
|
|
1511
|
+
}).catch(function (error) {
|
|
1512
|
+
_this11.initFailed = true;
|
|
1513
|
+
_this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1514
|
+
});
|
|
1515
|
+
} else {
|
|
1516
|
+
email = _this11.webex.config.email;
|
|
1517
|
+
_this11.collectPreauthCatalog(email ? {
|
|
1518
|
+
email: email
|
|
1519
|
+
} : undefined).catch(function (error) {
|
|
1520
|
+
_this11.initFailed = true;
|
|
1521
|
+
_this11.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1479
1524
|
case 3:
|
|
1480
|
-
|
|
1525
|
+
case "end":
|
|
1526
|
+
return _context5.stop();
|
|
1527
|
+
}
|
|
1528
|
+
}, _callee5);
|
|
1529
|
+
})));
|
|
1530
|
+
},
|
|
1531
|
+
/**
|
|
1532
|
+
* Verified-ready initialization path. Blocks `webex.ready` until the initial
|
|
1533
|
+
* catalog fetch has settled (or timed out) AND any in-flight credentials
|
|
1534
|
+
* refresh has completed. Also handles the fresh-login case where OAuth
|
|
1535
|
+
* completes after `loaded` fires.
|
|
1536
|
+
*
|
|
1537
|
+
* @private
|
|
1538
|
+
* @param {ServiceCatalog} catalog
|
|
1539
|
+
* @returns {void}
|
|
1540
|
+
*/
|
|
1541
|
+
_initializeCatalogsGated: function _initializeCatalogsGated(catalog) {
|
|
1542
|
+
var _this12 = this;
|
|
1543
|
+
// Wait for storage to be loaded before attempting to update the service
|
|
1544
|
+
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1545
|
+
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1546
|
+
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1547
|
+
var cachedCatalog, supertoken, timeout, 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
|
|
1481
1566
|
// `services.ready` false forever - that would stall `webex.ready` and
|
|
1482
1567
|
// leave the app on a permanent spinner.
|
|
1483
1568
|
timeout = new _promise.default(function (_, reject) {
|
|
@@ -1486,44 +1571,43 @@ var Services = _webexPlugin.default.extend({
|
|
|
1486
1571
|
}, SERVICES_INIT_TIMEOUT_MS);
|
|
1487
1572
|
}); // Validate if the supertoken exists.
|
|
1488
1573
|
if (supertoken && supertoken.access_token) {
|
|
1489
|
-
_promise.default.race([
|
|
1574
|
+
_promise.default.race([_this12.initServiceCatalogs(), timeout]).then(function () {
|
|
1490
1575
|
catalog.isReady = true;
|
|
1491
1576
|
}).catch(function (error) {
|
|
1492
|
-
|
|
1493
|
-
|
|
1577
|
+
_this12.initFailed = true;
|
|
1578
|
+
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1494
1579
|
}).finally(function () {
|
|
1495
|
-
return
|
|
1580
|
+
return _this12._finalizeReady();
|
|
1496
1581
|
});
|
|
1497
1582
|
} else {
|
|
1498
|
-
email =
|
|
1499
|
-
_promise.default.race([
|
|
1583
|
+
email = _this12.webex.config.email;
|
|
1584
|
+
_promise.default.race([_this12.collectPreauthCatalog(email ? {
|
|
1500
1585
|
email: email
|
|
1501
1586
|
} : undefined), timeout]).catch(function (error) {
|
|
1502
|
-
|
|
1503
|
-
|
|
1587
|
+
_this12.initFailed = true;
|
|
1588
|
+
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1504
1589
|
}).finally(function () {
|
|
1505
|
-
return
|
|
1590
|
+
return _this12._finalizeReady();
|
|
1506
1591
|
});
|
|
1507
|
-
|
|
1508
|
-
//
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
_this10.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1592
|
+
|
|
1593
|
+
// Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1594
|
+
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1595
|
+
_this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
|
|
1596
|
+
if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
1597
|
+
_this12.initServiceCatalogs().catch(function (error) {
|
|
1598
|
+
_this12.logger.error("services: failed to init service catalogs after auth, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1515
1599
|
});
|
|
1516
1600
|
}
|
|
1517
1601
|
});
|
|
1518
1602
|
}
|
|
1519
1603
|
case 4:
|
|
1520
1604
|
case "end":
|
|
1521
|
-
return
|
|
1605
|
+
return _context6.stop();
|
|
1522
1606
|
}
|
|
1523
|
-
},
|
|
1607
|
+
}, _callee6);
|
|
1524
1608
|
})));
|
|
1525
1609
|
},
|
|
1526
|
-
version: "3.12.0-webex-services-ready.
|
|
1610
|
+
version: "3.12.0-webex-services-ready.2"
|
|
1527
1611
|
});
|
|
1528
1612
|
/* eslint-enable no-underscore-dangle */
|
|
1529
1613
|
var _default = exports.default = Services;
|