@webex/webex-core 3.12.0-next.8 → 3.12.0-task-refactor.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/dist/config.js +0 -7
- package/dist/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 +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/service-url.js +1 -11
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +93 -418
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +40 -342
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/lib/services-v2/types.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 +0 -7
- package/src/interceptors/redirect.js +1 -4
- package/src/lib/services/service-url.js +1 -9
- package/src/lib/services/services.js +5 -285
- package/src/lib/services-v2/services-v2.ts +1 -269
- package/src/lib/services-v2/types.ts +0 -5
- package/test/integration/spec/services/service-catalog.js +4 -10
- package/test/integration/spec/services/services.js +9 -25
- package/test/integration/spec/services-v2/services-v2.js +6 -16
- package/test/unit/spec/services/service-url.js +0 -110
- package/test/unit/spec/services/services.js +12 -392
- package/test/unit/spec/services-v2/services-v2.ts +0 -249
|
@@ -11,8 +11,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
11
11
|
value: true
|
|
12
12
|
});
|
|
13
13
|
exports.default = exports.DEFAULT_CLUSTER_SERVICE = exports.DEFAULT_CLUSTER = void 0;
|
|
14
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
15
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
16
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
17
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
18
16
|
var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
|
|
@@ -20,8 +18,6 @@ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/ar
|
|
|
20
18
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
21
19
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
22
20
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
23
|
-
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
24
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
25
21
|
var _sha = _interopRequireDefault(require("crypto-js/sha256"));
|
|
26
22
|
var _lodash = require("lodash");
|
|
27
23
|
var _webexPlugin = _interopRequireDefault(require("../webex-plugin"));
|
|
@@ -39,8 +35,6 @@ var DEFAULT_CLUSTER = exports.DEFAULT_CLUSTER = 'urn:TEAM:us-east-2_a';
|
|
|
39
35
|
var DEFAULT_CLUSTER_SERVICE = exports.DEFAULT_CLUSTER_SERVICE = 'identityLookup';
|
|
40
36
|
var CLUSTER_SERVICE = process.env.WEBEX_CONVERSATION_CLUSTER_SERVICE || DEFAULT_CLUSTER_SERVICE;
|
|
41
37
|
var DEFAULT_CLUSTER_IDENTIFIER = process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER || "".concat(DEFAULT_CLUSTER, ":").concat(CLUSTER_SERVICE);
|
|
42
|
-
var CATALOG_CACHE_KEY_V2 = 'services.v2.u2cHostMap';
|
|
43
|
-
var CATALOG_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
44
38
|
|
|
45
39
|
/* eslint-disable no-underscore-dangle */
|
|
46
40
|
/**
|
|
@@ -64,45 +58,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
64
58
|
_getCatalog: function _getCatalog() {
|
|
65
59
|
return this._catalogs.get(this.webex);
|
|
66
60
|
},
|
|
67
|
-
/**
|
|
68
|
-
* Safely access localStorage if available; returns the Storage or null.
|
|
69
|
-
* @returns {Storage | null}
|
|
70
|
-
*/
|
|
71
|
-
_getLocalStorageSafe: function _getLocalStorageSafe() {
|
|
72
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
73
|
-
return window.localStorage;
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* Determine the intended preauth selection based on the current context.
|
|
79
|
-
* @param {string} [currentOrgId]
|
|
80
|
-
* @returns {{selectionType: string, selectionValue: string}}
|
|
81
|
-
*/
|
|
82
|
-
getIntendedPreauthSelection: function getIntendedPreauthSelection(currentOrgId) {
|
|
83
|
-
var _this$webex$credentia;
|
|
84
|
-
if ((_this$webex$credentia = this.webex.credentials) !== null && _this$webex$credentia !== void 0 && _this$webex$credentia.canAuthorize) {
|
|
85
|
-
if (currentOrgId) {
|
|
86
|
-
return {
|
|
87
|
-
selectionType: 'orgId',
|
|
88
|
-
selectionValue: currentOrgId
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
var emailConfig = this.webex.config && this.webex.config.email;
|
|
93
|
-
if (typeof emailConfig === 'string' && emailConfig.trim()) {
|
|
94
|
-
return {
|
|
95
|
-
selectionType: 'emailhash',
|
|
96
|
-
selectionValue: (0, _sha.default)(emailConfig.toLowerCase()).toString()
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// fall back to proximity mode when no orgId or email available
|
|
101
|
-
return {
|
|
102
|
-
selectionType: 'mode',
|
|
103
|
-
selectionValue: 'DEFAULT_BY_PROXIMITY'
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
61
|
/**
|
|
107
62
|
* Get a service url from the current services list by name
|
|
108
63
|
* from the associated instance catalog.
|
|
@@ -149,7 +104,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
149
104
|
* @returns {Array<ServiceHost>} - An array of `ServiceHost` objects.
|
|
150
105
|
*/
|
|
151
106
|
getMobiusClusters: function getMobiusClusters() {
|
|
152
|
-
this.logger.info('services: fetching mobius clusters');
|
|
153
107
|
var clusters = [];
|
|
154
108
|
var services = this._services || [];
|
|
155
109
|
services.filter(function (service) {
|
|
@@ -186,24 +140,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
186
140
|
});
|
|
187
141
|
});
|
|
188
142
|
},
|
|
189
|
-
/**
|
|
190
|
-
* Checks if the current environment is an integration (INT) environment
|
|
191
|
-
* by examining the u2c discovery URL from webex config.
|
|
192
|
-
* INT environments use discovery URLs containing 'intb' (e.g., u2c-intb.ciscospark.com).
|
|
193
|
-
* @returns {boolean} True if INT environment, false otherwise
|
|
194
|
-
*/
|
|
195
|
-
isIntegrationEnvironment: function isIntegrationEnvironment() {
|
|
196
|
-
try {
|
|
197
|
-
var _this$webex, _this$webex$config, _this$webex$config$se, _this$webex$config$se2;
|
|
198
|
-
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) || '';
|
|
199
|
-
var isInt = u2cUrl.includes('intb');
|
|
200
|
-
this.logger.info("services: isIntegrationEnvironment: ".concat(isInt));
|
|
201
|
-
return isInt;
|
|
202
|
-
} catch (error) {
|
|
203
|
-
this.logger.error('services: failed to determine integration environment', error);
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
143
|
/**
|
|
208
144
|
* saves all the services from the pre and post catalog service
|
|
209
145
|
* @param {ActiveServices} activeServices
|
|
@@ -286,18 +222,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
286
222
|
forceRefresh: forceRefresh
|
|
287
223
|
}).then(function (serviceHostMap) {
|
|
288
224
|
catalog.updateServiceGroups(serviceGroup, serviceHostMap === null || serviceHostMap === void 0 ? void 0 : serviceHostMap.services, serviceHostMap === null || serviceHostMap === void 0 ? void 0 : serviceHostMap.timestamp);
|
|
289
|
-
// Build selection metadata for caching discrimination (preauth/signin)
|
|
290
|
-
var selectionMeta;
|
|
291
|
-
if (serviceGroup === 'preauth' || serviceGroup === 'signin') {
|
|
292
|
-
var key = formattedQuery && (0, _keys.default)(formattedQuery || {})[0];
|
|
293
|
-
if (key) {
|
|
294
|
-
selectionMeta = {
|
|
295
|
-
selectionType: key,
|
|
296
|
-
selectionValue: formattedQuery[key]
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
_this._cacheCatalog(serviceGroup, serviceHostMap, selectionMeta);
|
|
301
225
|
_this.updateCredentialsConfig();
|
|
302
226
|
catalog.status[serviceGroup].collecting = false;
|
|
303
227
|
}).catch(function (error) {
|
|
@@ -374,9 +298,9 @@ var Services = _webexPlugin.default.extend({
|
|
|
374
298
|
|
|
375
299
|
// Destructure the client authorization details.
|
|
376
300
|
/* eslint-disable camelcase */
|
|
377
|
-
var _this$webex$
|
|
378
|
-
client_id = _this$webex$
|
|
379
|
-
client_secret = _this$webex$
|
|
301
|
+
var _this$webex$credentia = this.webex.credentials.config,
|
|
302
|
+
client_id = _this$webex$credentia.client_id,
|
|
303
|
+
client_secret = _this$webex$credentia.client_secret;
|
|
380
304
|
|
|
381
305
|
// Validate that client authentication details exist.
|
|
382
306
|
if (!client_id || !client_secret) {
|
|
@@ -952,213 +876,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
952
876
|
}
|
|
953
877
|
return url.replace(data.defaultUrl, data.priorityUrl);
|
|
954
878
|
},
|
|
955
|
-
/**
|
|
956
|
-
* @private
|
|
957
|
-
* Cache the catalog in the bounded storage.
|
|
958
|
-
* @param {ServiceGroup} serviceGroup - preauth, signin, postauth
|
|
959
|
-
* @param {ServiceHostmap} hostMap - The hostmap to cache
|
|
960
|
-
* @param {object} [meta] - Optional selection metadata for cache discrimination
|
|
961
|
-
* @returns {Promise<void>}
|
|
962
|
-
*/
|
|
963
|
-
_cacheCatalog: function _cacheCatalog(serviceGroup, hostMap, meta) {
|
|
964
|
-
var _this9 = this;
|
|
965
|
-
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
966
|
-
var current, orgId, _this9$webex$config, _this9$webex$config$c, _this9$webex, _this9$webex$config2, _this9$webex2, _this9$webex2$config, _this9$webex2$config$, _this9$webex2$config$2, _ls, cachedJson, credentials, _current, env, fedramp, u2cDiscoveryUrl, updated, ls, _t;
|
|
967
|
-
return _regenerator.default.wrap(function (_context) {
|
|
968
|
-
while (1) switch (_context.prev = _context.next) {
|
|
969
|
-
case 0:
|
|
970
|
-
current = {};
|
|
971
|
-
_context.prev = 1;
|
|
972
|
-
if ((_this9$webex$config = _this9.webex.config) !== null && _this9$webex$config !== void 0 && (_this9$webex$config$c = _this9$webex$config.calling) !== null && _this9$webex$config$c !== void 0 && _this9$webex$config$c.cacheU2C) {
|
|
973
|
-
_context.next = 2;
|
|
974
|
-
break;
|
|
975
|
-
}
|
|
976
|
-
_this9.logger.info("services: skipping cache write for ".concat(serviceGroup, " as per the config"));
|
|
977
|
-
return _context.abrupt("return");
|
|
978
|
-
case 2:
|
|
979
|
-
try {
|
|
980
|
-
_ls = _this9._getLocalStorageSafe();
|
|
981
|
-
cachedJson = _ls ? _ls.getItem(CATALOG_CACHE_KEY_V2) : null;
|
|
982
|
-
current = cachedJson ? JSON.parse(cachedJson) : {};
|
|
983
|
-
} catch (_unused2) {
|
|
984
|
-
current = {};
|
|
985
|
-
}
|
|
986
|
-
try {
|
|
987
|
-
credentials = _this9.webex.credentials;
|
|
988
|
-
orgId = credentials.getOrgId();
|
|
989
|
-
} catch (_unused3) {
|
|
990
|
-
orgId = current.orgId;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
// Capture environment fingerprint to invalidate cache across env changes
|
|
994
|
-
_current = current, env = _current.env;
|
|
995
|
-
fedramp = !!((_this9$webex = _this9.webex) !== null && _this9$webex !== void 0 && (_this9$webex$config2 = _this9$webex.config) !== null && _this9$webex$config2 !== void 0 && _this9$webex$config2.fedramp);
|
|
996
|
-
u2cDiscoveryUrl = (_this9$webex2 = _this9.webex) === null || _this9$webex2 === void 0 ? void 0 : (_this9$webex2$config = _this9$webex2.config) === null || _this9$webex2$config === void 0 ? void 0 : (_this9$webex2$config$ = _this9$webex2$config.services) === null || _this9$webex2$config$ === void 0 ? void 0 : (_this9$webex2$config$2 = _this9$webex2$config$.discovery) === null || _this9$webex2$config$2 === void 0 ? void 0 : _this9$webex2$config$2.u2c;
|
|
997
|
-
env = {
|
|
998
|
-
fedramp: fedramp,
|
|
999
|
-
u2cDiscoveryUrl: u2cDiscoveryUrl
|
|
1000
|
-
};
|
|
1001
|
-
updated = _objectSpread(_objectSpread({}, current), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
1002
|
-
orgId: orgId || current.orgId,
|
|
1003
|
-
env: env || current.env
|
|
1004
|
-
}, serviceGroup, meta ? {
|
|
1005
|
-
hostMap: hostMap,
|
|
1006
|
-
meta: meta
|
|
1007
|
-
} : hostMap), "cachedAt", (0, _now.default)()));
|
|
1008
|
-
ls = _this9._getLocalStorageSafe();
|
|
1009
|
-
if (ls) {
|
|
1010
|
-
ls.setItem(CATALOG_CACHE_KEY_V2, (0, _stringify.default)(updated));
|
|
1011
|
-
}
|
|
1012
|
-
_context.next = 4;
|
|
1013
|
-
break;
|
|
1014
|
-
case 3:
|
|
1015
|
-
_context.prev = 3;
|
|
1016
|
-
_t = _context["catch"](1);
|
|
1017
|
-
_this9.logger.warn('services: error caching catalog', _t);
|
|
1018
|
-
case 4:
|
|
1019
|
-
case "end":
|
|
1020
|
-
return _context.stop();
|
|
1021
|
-
}
|
|
1022
|
-
}, _callee, null, [[1, 3]]);
|
|
1023
|
-
}))();
|
|
1024
|
-
},
|
|
1025
|
-
/**
|
|
1026
|
-
* @private
|
|
1027
|
-
* Load the catalog from cache and hydrate the in-memory ServiceCatalog.
|
|
1028
|
-
* @returns {Promise<boolean>} true if cache was loaded, false otherwise
|
|
1029
|
-
*/
|
|
1030
|
-
_loadCatalogFromCache: function _loadCatalogFromCache() {
|
|
1031
|
-
var _this0 = this;
|
|
1032
|
-
return (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
1033
|
-
var currentOrgId, _this0$webex$config, _this0$webex$config$c, _this0$webex$config2, _this0$webex$config3, _this0$webex$config3$, _this0$webex$config3$2, ls, cachedJson, cached, cachedAt, _this0$webex$credenti, credentials, fedramp, u2cDiscoveryUrl, currentEnv, sameEnv, catalog, groups, _t2, _t3;
|
|
1034
|
-
return _regenerator.default.wrap(function (_context2) {
|
|
1035
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1036
|
-
case 0:
|
|
1037
|
-
_context2.prev = 0;
|
|
1038
|
-
if ((_this0$webex$config = _this0.webex.config) !== null && _this0$webex$config !== void 0 && (_this0$webex$config$c = _this0$webex$config.calling) !== null && _this0$webex$config$c !== void 0 && _this0$webex$config$c.cacheU2C) {
|
|
1039
|
-
_context2.next = 1;
|
|
1040
|
-
break;
|
|
1041
|
-
}
|
|
1042
|
-
_this0.logger.info('services: skipping cache warm-up as per the cache config');
|
|
1043
|
-
return _context2.abrupt("return", false);
|
|
1044
|
-
case 1:
|
|
1045
|
-
ls = _this0._getLocalStorageSafe();
|
|
1046
|
-
if (ls) {
|
|
1047
|
-
_context2.next = 2;
|
|
1048
|
-
break;
|
|
1049
|
-
}
|
|
1050
|
-
_this0.logger.info('services: skipping cache warm-up as no localStorage is available');
|
|
1051
|
-
return _context2.abrupt("return", false);
|
|
1052
|
-
case 2:
|
|
1053
|
-
cachedJson = ls.getItem(CATALOG_CACHE_KEY_V2);
|
|
1054
|
-
cached = cachedJson ? JSON.parse(cachedJson) : undefined;
|
|
1055
|
-
if (cached) {
|
|
1056
|
-
_context2.next = 3;
|
|
1057
|
-
break;
|
|
1058
|
-
}
|
|
1059
|
-
return _context2.abrupt("return", false);
|
|
1060
|
-
case 3:
|
|
1061
|
-
// TTL enforcement
|
|
1062
|
-
cachedAt = Number(cached.cachedAt) || 0;
|
|
1063
|
-
if (!(!cachedAt || (0, _now.default)() - cachedAt > CATALOG_TTL_MS)) {
|
|
1064
|
-
_context2.next = 4;
|
|
1065
|
-
break;
|
|
1066
|
-
}
|
|
1067
|
-
_this0.clearCatalogCache();
|
|
1068
|
-
return _context2.abrupt("return", false);
|
|
1069
|
-
case 4:
|
|
1070
|
-
_context2.prev = 4;
|
|
1071
|
-
if (!((_this0$webex$credenti = _this0.webex.credentials) !== null && _this0$webex$credenti !== void 0 && _this0$webex$credenti.canAuthorize)) {
|
|
1072
|
-
_context2.next = 5;
|
|
1073
|
-
break;
|
|
1074
|
-
}
|
|
1075
|
-
credentials = _this0.webex.credentials;
|
|
1076
|
-
currentOrgId = credentials.getOrgId();
|
|
1077
|
-
if (!(cached.orgId && cached.orgId !== currentOrgId)) {
|
|
1078
|
-
_context2.next = 5;
|
|
1079
|
-
break;
|
|
1080
|
-
}
|
|
1081
|
-
return _context2.abrupt("return", false);
|
|
1082
|
-
case 5:
|
|
1083
|
-
_context2.next = 7;
|
|
1084
|
-
break;
|
|
1085
|
-
case 6:
|
|
1086
|
-
_context2.prev = 6;
|
|
1087
|
-
_t2 = _context2["catch"](4);
|
|
1088
|
-
_this0.logger.warn('services: error checking orgId', _t2);
|
|
1089
|
-
case 7:
|
|
1090
|
-
// Ensure cached environment matches current environment
|
|
1091
|
-
fedramp = !!((_this0$webex$config2 = _this0.webex.config) !== null && _this0$webex$config2 !== void 0 && _this0$webex$config2.fedramp);
|
|
1092
|
-
u2cDiscoveryUrl = (_this0$webex$config3 = _this0.webex.config) === null || _this0$webex$config3 === void 0 ? void 0 : (_this0$webex$config3$ = _this0$webex$config3.services) === null || _this0$webex$config3$ === void 0 ? void 0 : (_this0$webex$config3$2 = _this0$webex$config3$.discovery) === null || _this0$webex$config3$2 === void 0 ? void 0 : _this0$webex$config3$2.u2c;
|
|
1093
|
-
currentEnv = {
|
|
1094
|
-
fedramp: fedramp,
|
|
1095
|
-
u2cDiscoveryUrl: u2cDiscoveryUrl
|
|
1096
|
-
};
|
|
1097
|
-
if (!cached.env) {
|
|
1098
|
-
_context2.next = 8;
|
|
1099
|
-
break;
|
|
1100
|
-
}
|
|
1101
|
-
sameEnv = cached.env.fedramp === currentEnv.fedramp && cached.env.u2cDiscoveryUrl === currentEnv.u2cDiscoveryUrl;
|
|
1102
|
-
if (sameEnv) {
|
|
1103
|
-
_context2.next = 8;
|
|
1104
|
-
break;
|
|
1105
|
-
}
|
|
1106
|
-
return _context2.abrupt("return", false);
|
|
1107
|
-
case 8:
|
|
1108
|
-
catalog = _this0._getCatalog();
|
|
1109
|
-
groups = ['preauth', 'signin', 'postauth'];
|
|
1110
|
-
groups.forEach(function (serviceGroup) {
|
|
1111
|
-
var cachedGroup = cached[serviceGroup];
|
|
1112
|
-
if (!cachedGroup) {
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
// Support legacy (hostMap) and new ({hostMap, meta}) shapes
|
|
1117
|
-
var hostMap = cachedGroup && cachedGroup.hostMap ? cachedGroup.hostMap : cachedGroup;
|
|
1118
|
-
var meta = cachedGroup === null || cachedGroup === void 0 ? void 0 : cachedGroup.meta;
|
|
1119
|
-
if (serviceGroup === 'preauth' && meta) {
|
|
1120
|
-
// For proximity-based selection, always fetch fresh to respect IP/region changes
|
|
1121
|
-
if (meta.selectionType === 'mode') {
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
var intended = _this0.getIntendedPreauthSelection(currentOrgId);
|
|
1125
|
-
var matches = intended && intended.selectionType === meta.selectionType && intended.selectionValue === meta.selectionValue;
|
|
1126
|
-
if (!matches) {
|
|
1127
|
-
return;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
if (hostMap) {
|
|
1131
|
-
catalog.updateServiceGroups(serviceGroup, hostMap === null || hostMap === void 0 ? void 0 : hostMap.services, hostMap === null || hostMap === void 0 ? void 0 : hostMap.timestamp);
|
|
1132
|
-
}
|
|
1133
|
-
});
|
|
1134
|
-
_this0.updateCredentialsConfig();
|
|
1135
|
-
return _context2.abrupt("return", true);
|
|
1136
|
-
case 9:
|
|
1137
|
-
_context2.prev = 9;
|
|
1138
|
-
_t3 = _context2["catch"](0);
|
|
1139
|
-
return _context2.abrupt("return", false);
|
|
1140
|
-
case 10:
|
|
1141
|
-
case "end":
|
|
1142
|
-
return _context2.stop();
|
|
1143
|
-
}
|
|
1144
|
-
}, _callee2, null, [[0, 9], [4, 6]]);
|
|
1145
|
-
}))();
|
|
1146
|
-
},
|
|
1147
|
-
/**
|
|
1148
|
-
* Clear the catalog cache from the bounded storage (v2).
|
|
1149
|
-
* @returns {Promise<void>}
|
|
1150
|
-
*/
|
|
1151
|
-
clearCatalogCache: function clearCatalogCache() {
|
|
1152
|
-
try {
|
|
1153
|
-
var ls = this._getLocalStorageSafe();
|
|
1154
|
-
if (ls) {
|
|
1155
|
-
ls.removeItem(CATALOG_CACHE_KEY_V2);
|
|
1156
|
-
}
|
|
1157
|
-
} catch (e) {
|
|
1158
|
-
this.logger.warn('services: error clearing catalog cache', e);
|
|
1159
|
-
}
|
|
1160
|
-
return _promise.default.resolve();
|
|
1161
|
-
},
|
|
1162
879
|
/**
|
|
1163
880
|
* @private
|
|
1164
881
|
* Simplified method wrapper for sending a request to get
|
|
@@ -1173,7 +890,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1173
890
|
* @returns {Promise<object>}
|
|
1174
891
|
*/
|
|
1175
892
|
_fetchNewServiceHostmap: function _fetchNewServiceHostmap() {
|
|
1176
|
-
var
|
|
893
|
+
var _this9 = this;
|
|
1177
894
|
var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1178
895
|
from = _ref11.from,
|
|
1179
896
|
query = _ref11.query,
|
|
@@ -1200,10 +917,10 @@ var Services = _webexPlugin.default.extend({
|
|
|
1200
917
|
};
|
|
1201
918
|
}
|
|
1202
919
|
return this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(function () {
|
|
1203
|
-
return
|
|
920
|
+
return _this9.request(requestObject);
|
|
1204
921
|
}, 'internal.get.u2c.time').then(function (_ref12) {
|
|
1205
922
|
var body = _ref12.body;
|
|
1206
|
-
return
|
|
923
|
+
return _this9._formatReceivedHostmap(body || {});
|
|
1207
924
|
});
|
|
1208
925
|
},
|
|
1209
926
|
/**
|
|
@@ -1212,12 +929,12 @@ var Services = _webexPlugin.default.extend({
|
|
|
1212
929
|
* @returns {void}
|
|
1213
930
|
*/
|
|
1214
931
|
initConfig: function initConfig() {
|
|
1215
|
-
var
|
|
932
|
+
var _this0 = this;
|
|
1216
933
|
// Get the catalog and destructure the services config.
|
|
1217
934
|
var catalog = this._getCatalog();
|
|
1218
|
-
var _this$webex$
|
|
1219
|
-
services = _this$webex$
|
|
1220
|
-
fedramp = _this$webex$
|
|
935
|
+
var _this$webex$config = this.webex.config,
|
|
936
|
+
services = _this$webex$config.services,
|
|
937
|
+
fedramp = _this$webex$config.fedramp;
|
|
1221
938
|
|
|
1222
939
|
// Validate that the services configuration exists.
|
|
1223
940
|
if (services) {
|
|
@@ -1228,7 +945,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1228
945
|
if (services.discovery) {
|
|
1229
946
|
// Format the discovery configuration into an injectable array.
|
|
1230
947
|
var formattedDiscoveryServices = (0, _keys.default)(services.discovery).map(function (key) {
|
|
1231
|
-
return
|
|
948
|
+
return _this0._formatHostMapEntry({
|
|
1232
949
|
id: key,
|
|
1233
950
|
serviceName: key,
|
|
1234
951
|
serviceUrls: [{
|
|
@@ -1244,7 +961,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1244
961
|
if (services.override) {
|
|
1245
962
|
// Format the override configuration into an injectable array.
|
|
1246
963
|
var formattedOverrideServices = (0, _keys.default)(services.override).map(function (key) {
|
|
1247
|
-
return
|
|
964
|
+
return _this0._formatHostMapEntry({
|
|
1248
965
|
id: key,
|
|
1249
966
|
serviceName: key,
|
|
1250
967
|
serviceUrls: [{
|
|
@@ -1279,7 +996,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1279
996
|
* @returns {Promise<void, Error>} - Errors if the token is unavailable.
|
|
1280
997
|
*/
|
|
1281
998
|
initServiceCatalogs: function initServiceCatalogs() {
|
|
1282
|
-
var
|
|
999
|
+
var _this1 = this;
|
|
1283
1000
|
var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1284
1001
|
this.logger.info('services: initializing initial service catalogs');
|
|
1285
1002
|
|
|
@@ -1295,18 +1012,18 @@ var Services = _webexPlugin.default.extend({
|
|
|
1295
1012
|
})
|
|
1296
1013
|
// Begin collecting the preauth/limited catalog.
|
|
1297
1014
|
.then(function (orgId) {
|
|
1298
|
-
return
|
|
1015
|
+
return _this1.collectPreauthCatalog({
|
|
1299
1016
|
orgId: orgId
|
|
1300
1017
|
}, refresh);
|
|
1301
1018
|
}).then(function () {
|
|
1302
1019
|
// Validate if the token is authorized.
|
|
1303
1020
|
if (credentials.canAuthorize) {
|
|
1304
1021
|
// Attempt to collect the postauth catalog.
|
|
1305
|
-
return
|
|
1022
|
+
return _this1.updateServices({
|
|
1306
1023
|
forceRefresh: refresh
|
|
1307
1024
|
}).catch(function () {
|
|
1308
|
-
|
|
1309
|
-
|
|
1025
|
+
_this1.initFailed = true;
|
|
1026
|
+
_this1.logger.warn('services: cannot retrieve postauth catalog');
|
|
1310
1027
|
});
|
|
1311
1028
|
}
|
|
1312
1029
|
|
|
@@ -1322,58 +1039,39 @@ var Services = _webexPlugin.default.extend({
|
|
|
1322
1039
|
* @returns {Services}
|
|
1323
1040
|
*/
|
|
1324
1041
|
initialize: function initialize() {
|
|
1325
|
-
var
|
|
1042
|
+
var _this10 = this;
|
|
1326
1043
|
var catalog = new _serviceCatalog.default();
|
|
1327
1044
|
this._catalogs.set(this.webex, catalog);
|
|
1328
1045
|
|
|
1329
1046
|
// Listen for configuration changes once.
|
|
1330
1047
|
this.listenToOnce(this.webex, 'change:config', function () {
|
|
1331
|
-
|
|
1048
|
+
_this10.initConfig();
|
|
1332
1049
|
});
|
|
1333
1050
|
|
|
1334
1051
|
// wait for webex instance to be ready before attempting
|
|
1335
1052
|
// to update the service catalogs
|
|
1336
|
-
this.listenToOnce(this.webex, 'ready',
|
|
1337
|
-
var
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
}).catch(function (error) {
|
|
1357
|
-
_this12.initFailed = true;
|
|
1358
|
-
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1359
|
-
});
|
|
1360
|
-
} else {
|
|
1361
|
-
email = _this12.webex.config.email;
|
|
1362
|
-
_this12.collectPreauthCatalog(email ? {
|
|
1363
|
-
email: email
|
|
1364
|
-
} : undefined).catch(function (error) {
|
|
1365
|
-
_this12.initFailed = true;
|
|
1366
|
-
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1367
|
-
});
|
|
1368
|
-
}
|
|
1369
|
-
case 3:
|
|
1370
|
-
case "end":
|
|
1371
|
-
return _context3.stop();
|
|
1372
|
-
}
|
|
1373
|
-
}, _callee3);
|
|
1374
|
-
})));
|
|
1053
|
+
this.listenToOnce(this.webex, 'ready', function () {
|
|
1054
|
+
var supertoken = _this10.webex.credentials.supertoken;
|
|
1055
|
+
// Validate if the supertoken exists.
|
|
1056
|
+
if (supertoken && supertoken.access_token) {
|
|
1057
|
+
_this10.initServiceCatalogs().then(function () {
|
|
1058
|
+
catalog.isReady = true;
|
|
1059
|
+
}).catch(function (error) {
|
|
1060
|
+
_this10.initFailed = true;
|
|
1061
|
+
_this10.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1062
|
+
});
|
|
1063
|
+
} else {
|
|
1064
|
+
var email = _this10.webex.config.email;
|
|
1065
|
+
_this10.collectPreauthCatalog(email ? {
|
|
1066
|
+
email: email
|
|
1067
|
+
} : undefined).catch(function (error) {
|
|
1068
|
+
_this10.initFailed = true;
|
|
1069
|
+
_this10.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1375
1073
|
},
|
|
1376
|
-
version: "3.12.0-
|
|
1074
|
+
version: "3.12.0-task-refactor.1"
|
|
1377
1075
|
});
|
|
1378
1076
|
/* eslint-enable no-underscore-dangle */
|
|
1379
1077
|
var _default = exports.default = Services;
|