@webex/webex-core 3.0.0-beta.2 → 3.0.0-beta.21
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 +1 -11
- package/dist/config.js.map +1 -1
- package/dist/credentials-config.js +44 -64
- package/dist/credentials-config.js.map +1 -1
- package/dist/index.js +0 -76
- package/dist/index.js.map +1 -1
- package/dist/interceptors/auth.js +22 -55
- package/dist/interceptors/auth.js.map +1 -1
- package/dist/interceptors/default-options.js +0 -20
- package/dist/interceptors/default-options.js.map +1 -1
- package/dist/interceptors/embargo.js +0 -21
- package/dist/interceptors/embargo.js.map +1 -1
- package/dist/interceptors/network-timing.js +2 -21
- package/dist/interceptors/network-timing.js.map +1 -1
- package/dist/interceptors/payload-transformer.js +2 -22
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/interceptors/rate-limit.js +25 -57
- package/dist/interceptors/rate-limit.js.map +1 -1
- package/dist/interceptors/redirect.js +4 -33
- package/dist/interceptors/redirect.js.map +1 -1
- package/dist/interceptors/request-event.js +3 -30
- package/dist/interceptors/request-event.js.map +1 -1
- package/dist/interceptors/request-logger.js +1 -30
- package/dist/interceptors/request-logger.js.map +1 -1
- package/dist/interceptors/request-timing.js +3 -22
- package/dist/interceptors/request-timing.js.map +1 -1
- package/dist/interceptors/response-logger.js +2 -31
- package/dist/interceptors/response-logger.js.map +1 -1
- package/dist/interceptors/user-agent.js +2 -29
- package/dist/interceptors/user-agent.js.map +1 -1
- package/dist/interceptors/webex-tracking-id.js +5 -28
- package/dist/interceptors/webex-tracking-id.js.map +1 -1
- package/dist/interceptors/webex-user-agent.js +5 -38
- package/dist/interceptors/webex-user-agent.js.map +1 -1
- package/dist/lib/batcher.js +3 -51
- package/dist/lib/batcher.js.map +1 -1
- package/dist/lib/credentials/credentials.js +39 -119
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/grant-errors.js +0 -49
- package/dist/lib/credentials/grant-errors.js.map +1 -1
- package/dist/lib/credentials/index.js +1 -13
- package/dist/lib/credentials/index.js.map +1 -1
- package/dist/lib/credentials/scope.js +1 -7
- package/dist/lib/credentials/scope.js.map +1 -1
- package/dist/lib/credentials/token-collection.js +1 -7
- package/dist/lib/credentials/token-collection.js.map +1 -1
- package/dist/lib/credentials/token.js +39 -118
- package/dist/lib/credentials/token.js.map +1 -1
- package/dist/lib/page.js +13 -26
- package/dist/lib/page.js.map +1 -1
- package/dist/lib/services/constants.js +0 -2
- package/dist/lib/services/constants.js.map +1 -1
- package/dist/lib/services/index.js +1 -28
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/interceptors/server-error.js +2 -23
- package/dist/lib/services/interceptors/server-error.js.map +1 -1
- package/dist/lib/services/interceptors/service.js +12 -34
- package/dist/lib/services/interceptors/service.js.map +1 -1
- package/dist/lib/services/metrics.js +0 -2
- package/dist/lib/services/metrics.js.map +1 -1
- package/dist/lib/services/service-catalog.js +10 -90
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/service-fed-ramp.js +0 -2
- package/dist/lib/services/service-fed-ramp.js.map +1 -1
- package/dist/lib/services/service-host.js +47 -62
- package/dist/lib/services/service-host.js.map +1 -1
- package/dist/lib/services/service-registry.js +78 -90
- package/dist/lib/services/service-registry.js.map +1 -1
- package/dist/lib/services/service-state.js +3 -15
- package/dist/lib/services/service-state.js.map +1 -1
- package/dist/lib/services/service-url.js +4 -25
- package/dist/lib/services/service-url.js.map +1 -1
- package/dist/lib/services/services.js +122 -238
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/stateless-webex-plugin.js +5 -28
- package/dist/lib/stateless-webex-plugin.js.map +1 -1
- package/dist/lib/storage/decorators.js +19 -62
- package/dist/lib/storage/decorators.js.map +1 -1
- package/dist/lib/storage/errors.js +0 -23
- package/dist/lib/storage/errors.js.map +1 -1
- package/dist/lib/storage/index.js +2 -16
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/make-webex-plugin-store.js +11 -41
- package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
- package/dist/lib/storage/make-webex-store.js +8 -30
- package/dist/lib/storage/make-webex-store.js.map +1 -1
- package/dist/lib/storage/memory-store-adapter.js +1 -19
- package/dist/lib/storage/memory-store-adapter.js.map +1 -1
- package/dist/lib/webex-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-http-error.js +1 -31
- package/dist/lib/webex-http-error.js.map +1 -1
- package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
- package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
- package/dist/lib/webex-plugin.js +6 -40
- package/dist/lib/webex-plugin.js.map +1 -1
- package/dist/plugins/logger.js +3 -17
- package/dist/plugins/logger.js.map +1 -1
- package/dist/webex-core.js +79 -203
- package/dist/webex-core.js.map +1 -1
- package/dist/webex-internal-core.js +0 -10
- package/dist/webex-internal-core.js.map +1 -1
- package/package.json +14 -14
- package/src/config.js +9 -11
- package/src/credentials-config.js +110 -72
- package/src/index.js +4 -14
- package/src/interceptors/auth.js +36 -37
- package/src/interceptors/default-options.js +0 -1
- package/src/interceptors/embargo.js +1 -1
- package/src/interceptors/payload-transformer.js +1 -2
- package/src/interceptors/rate-limit.js +8 -5
- package/src/interceptors/redirect.js +14 -8
- package/src/interceptors/request-event.js +4 -8
- package/src/interceptors/request-logger.js +8 -5
- package/src/interceptors/response-logger.js +11 -8
- package/src/interceptors/user-agent.js +1 -2
- package/src/interceptors/webex-user-agent.js +3 -9
- package/src/lib/batcher.js +70 -69
- package/src/lib/credentials/credentials.js +112 -122
- package/src/lib/credentials/grant-errors.js +6 -7
- package/src/lib/credentials/index.js +1 -4
- package/src/lib/credentials/scope.js +1 -4
- package/src/lib/credentials/token-collection.js +1 -1
- package/src/lib/credentials/token.js +86 -80
- package/src/lib/page.js +10 -11
- package/src/lib/services/constants.js +3 -13
- package/src/lib/services/index.js +2 -2
- package/src/lib/services/interceptors/server-error.js +12 -7
- package/src/lib/services/interceptors/service.js +6 -5
- package/src/lib/services/metrics.js +1 -1
- package/src/lib/services/service-catalog.js +110 -100
- package/src/lib/services/service-fed-ramp.js +1 -2
- package/src/lib/services/service-host.js +10 -17
- package/src/lib/services/service-registry.js +69 -96
- package/src/lib/services/service-state.js +4 -6
- package/src/lib/services/service-url.js +24 -23
- package/src/lib/services/services.js +260 -251
- package/src/lib/stateless-webex-plugin.js +4 -2
- package/src/lib/storage/decorators.js +68 -66
- package/src/lib/storage/index.js +4 -6
- package/src/lib/storage/make-webex-plugin-store.js +34 -21
- package/src/lib/storage/make-webex-store.js +6 -7
- package/src/lib/storage/memory-store-adapter.js +3 -3
- package/src/lib/webex-core-plugin-mixin.js +10 -7
- package/src/lib/webex-http-error.js +7 -8
- package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
- package/src/lib/webex-plugin.js +41 -34
- package/src/plugins/logger.js +8 -3
- package/src/webex-core.js +185 -116
- package/src/webex-internal-core.js +15 -9
- package/test/integration/spec/credentials/credentials.js +26 -30
- package/test/integration/spec/credentials/token.js +36 -33
- package/test/integration/spec/services/service-catalog.js +177 -156
- package/test/integration/spec/services/services.js +313 -304
- package/test/integration/spec/webex-core.js +98 -86
- package/test/unit/spec/_setup.js +26 -18
- package/test/unit/spec/credentials/credentials.js +189 -154
- package/test/unit/spec/credentials/token.js +94 -76
- package/test/unit/spec/interceptors/auth.js +291 -243
- package/test/unit/spec/interceptors/default-options.js +36 -24
- package/test/unit/spec/interceptors/embargo.js +32 -27
- package/test/unit/spec/interceptors/network-timing.js +2 -2
- package/test/unit/spec/interceptors/payload-transformer.js +61 -52
- package/test/unit/spec/interceptors/rate-limit.js +104 -75
- package/test/unit/spec/interceptors/redirect.js +22 -20
- package/test/unit/spec/interceptors/request-timing.js +18 -22
- package/test/unit/spec/interceptors/user-agent.js +28 -16
- package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
- package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
- package/test/unit/spec/lib/batcher.js +36 -32
- package/test/unit/spec/lib/page.js +36 -32
- package/test/unit/spec/lib/webex-plugin.js +1 -1
- package/test/unit/spec/services/interceptors/server-error.js +67 -90
- package/test/unit/spec/services/interceptors/service.js +17 -28
- package/test/unit/spec/services/service-catalog.js +19 -27
- package/test/unit/spec/services/service-host.js +29 -26
- package/test/unit/spec/services/service-registry.js +128 -170
- package/test/unit/spec/services/service-state.js +13 -22
- package/test/unit/spec/services/service-url.js +24 -43
- package/test/unit/spec/services/services.js +85 -41
- package/test/unit/spec/storage/persist.js +6 -9
- package/test/unit/spec/storage/wait-for-value.js +22 -21
- package/test/unit/spec/webex-core.js +78 -57
- package/test/unit/spec/webex-internal-core.js +56 -31
|
@@ -1,67 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
4
|
-
|
|
5
4
|
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
-
|
|
7
5
|
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
8
|
-
|
|
9
6
|
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
10
|
-
|
|
11
7
|
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
12
|
-
|
|
13
8
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
14
|
-
|
|
15
9
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
16
|
-
|
|
17
10
|
_Object$defineProperty(exports, "__esModule", {
|
|
18
11
|
value: true
|
|
19
12
|
});
|
|
20
|
-
|
|
21
13
|
exports.default = void 0;
|
|
22
|
-
|
|
23
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
24
|
-
|
|
25
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
26
|
-
|
|
27
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
28
|
-
|
|
29
17
|
var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
|
|
30
|
-
|
|
31
18
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
32
|
-
|
|
33
19
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
34
|
-
|
|
35
20
|
var _url = _interopRequireDefault(require("url"));
|
|
36
|
-
|
|
37
21
|
var _sha = _interopRequireDefault(require("crypto-js/sha256"));
|
|
38
|
-
|
|
39
22
|
var _webexPlugin = _interopRequireDefault(require("../webex-plugin"));
|
|
40
|
-
|
|
41
23
|
var _metrics = _interopRequireDefault(require("./metrics"));
|
|
42
|
-
|
|
43
24
|
var _serviceCatalog = _interopRequireDefault(require("./service-catalog"));
|
|
44
|
-
|
|
45
25
|
var _serviceRegistry = _interopRequireDefault(require("./service-registry"));
|
|
46
|
-
|
|
47
26
|
var _serviceState = _interopRequireDefault(require("./service-state"));
|
|
48
|
-
|
|
49
27
|
var _serviceFedRamp = _interopRequireDefault(require("./service-fed-ramp"));
|
|
50
|
-
|
|
51
28
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys2(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
52
|
-
|
|
53
29
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
54
|
-
|
|
55
30
|
var trailingSlashes = /(?:^\/)|(?:\/$)/;
|
|
56
|
-
/* eslint-disable no-underscore-dangle */
|
|
57
31
|
|
|
32
|
+
/* eslint-disable no-underscore-dangle */
|
|
58
33
|
/**
|
|
59
34
|
* @class
|
|
60
35
|
*/
|
|
61
|
-
|
|
62
36
|
var Services = _webexPlugin.default.extend({
|
|
63
37
|
namespace: 'Services',
|
|
64
|
-
|
|
65
38
|
/**
|
|
66
39
|
* The {@link WeakMap} of {@link ServiceRegistry} class instances that are
|
|
67
40
|
* keyed with WebexCore instances.
|
|
@@ -72,7 +45,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
72
45
|
* @memberof Services
|
|
73
46
|
*/
|
|
74
47
|
registries: new _weakMap.default(),
|
|
75
|
-
|
|
76
48
|
/**
|
|
77
49
|
* The {@link WeakMap} of {@link ServiceState} class instances that are
|
|
78
50
|
* keyed with WebexCore instances.
|
|
@@ -88,7 +60,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
88
60
|
},
|
|
89
61
|
_catalogs: new _weakMap.default(),
|
|
90
62
|
_serviceUrls: null,
|
|
91
|
-
|
|
92
63
|
/**
|
|
93
64
|
* Get the registry associated with this webex instance.
|
|
94
65
|
*
|
|
@@ -99,7 +70,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
99
70
|
getRegistry: function getRegistry() {
|
|
100
71
|
return this.registries.get(this.webex);
|
|
101
72
|
},
|
|
102
|
-
|
|
103
73
|
/**
|
|
104
74
|
* Get the state associated with this webex instance.
|
|
105
75
|
*
|
|
@@ -110,7 +80,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
110
80
|
getState: function getState() {
|
|
111
81
|
return this.states.get(this.webex);
|
|
112
82
|
},
|
|
113
|
-
|
|
114
83
|
/**
|
|
115
84
|
* @private
|
|
116
85
|
* Get the current catalog based on the assocaited
|
|
@@ -120,7 +89,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
120
89
|
_getCatalog: function _getCatalog() {
|
|
121
90
|
return this._catalogs.get(this.webex);
|
|
122
91
|
},
|
|
123
|
-
|
|
124
92
|
/**
|
|
125
93
|
* Get a service url from the current services list by name
|
|
126
94
|
* from the associated instance catalog.
|
|
@@ -131,10 +99,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
131
99
|
*/
|
|
132
100
|
get: function get(name, priorityHost, serviceGroup) {
|
|
133
101
|
var catalog = this._getCatalog();
|
|
134
|
-
|
|
135
102
|
return catalog.get(name, priorityHost, serviceGroup);
|
|
136
103
|
},
|
|
137
|
-
|
|
138
104
|
/**
|
|
139
105
|
* Determine if the catalog contains a specific service
|
|
140
106
|
*
|
|
@@ -144,7 +110,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
144
110
|
hasService: function hasService(serviceName) {
|
|
145
111
|
return !!this.get(serviceName);
|
|
146
112
|
},
|
|
147
|
-
|
|
148
113
|
/**
|
|
149
114
|
* Determine if a whilelist exists in the service catalog.
|
|
150
115
|
*
|
|
@@ -152,10 +117,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
152
117
|
*/
|
|
153
118
|
hasAllowedDomains: function hasAllowedDomains() {
|
|
154
119
|
var catalog = this._getCatalog();
|
|
155
|
-
|
|
156
120
|
return catalog.getAllowedDomains().length > 0;
|
|
157
121
|
},
|
|
158
|
-
|
|
159
122
|
/**
|
|
160
123
|
* Generate a service catalog as an object from
|
|
161
124
|
* the associated instance catalog.
|
|
@@ -165,10 +128,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
165
128
|
*/
|
|
166
129
|
list: function list(priorityHost, serviceGroup) {
|
|
167
130
|
var catalog = this._getCatalog();
|
|
168
|
-
|
|
169
131
|
return catalog.list(priorityHost, serviceGroup);
|
|
170
132
|
},
|
|
171
|
-
|
|
172
133
|
/**
|
|
173
134
|
* Mark a priority host service url as failed.
|
|
174
135
|
* This will mark the host associated with the
|
|
@@ -184,19 +145,16 @@ var Services = _webexPlugin.default.extend({
|
|
|
184
145
|
*/
|
|
185
146
|
markFailedUrl: function markFailedUrl(url, noPriorityHosts) {
|
|
186
147
|
var catalog = this._getCatalog();
|
|
187
|
-
|
|
188
148
|
return catalog.markFailedUrl(url, noPriorityHosts);
|
|
189
149
|
},
|
|
190
|
-
|
|
191
150
|
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
151
|
+
* saves all the services from the pre and post catalog service
|
|
152
|
+
* @param {Object} serviceUrls
|
|
153
|
+
* @returns {void}
|
|
154
|
+
*/
|
|
196
155
|
_updateServiceUrls: function _updateServiceUrls(serviceUrls) {
|
|
197
156
|
this._serviceUrls = _objectSpread(_objectSpread({}, this._serviceUrls), serviceUrls);
|
|
198
157
|
},
|
|
199
|
-
|
|
200
158
|
/**
|
|
201
159
|
* Update a list of `serviceUrls` to the most current
|
|
202
160
|
* catalog via the defined `discoveryUrl` then returns the current
|
|
@@ -212,58 +170,49 @@ var Services = _webexPlugin.default.extend({
|
|
|
212
170
|
*/
|
|
213
171
|
updateServices: function updateServices() {
|
|
214
172
|
var _this = this;
|
|
215
|
-
|
|
216
173
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
174
|
+
from = _ref.from,
|
|
175
|
+
query = _ref.query,
|
|
176
|
+
token = _ref.token,
|
|
177
|
+
forceRefresh = _ref.forceRefresh;
|
|
222
178
|
var catalog = this._getCatalog();
|
|
179
|
+
var formattedQuery;
|
|
180
|
+
var serviceGroup;
|
|
223
181
|
|
|
224
|
-
|
|
225
|
-
|
|
182
|
+
// map catalog name to service group name.
|
|
226
183
|
switch (from) {
|
|
227
184
|
case 'limited':
|
|
228
185
|
serviceGroup = 'preauth';
|
|
229
186
|
break;
|
|
230
|
-
|
|
231
187
|
case 'signin':
|
|
232
188
|
serviceGroup = 'signin';
|
|
233
189
|
break;
|
|
234
|
-
|
|
235
190
|
default:
|
|
236
191
|
serviceGroup = 'postauth';
|
|
237
192
|
break;
|
|
238
|
-
}
|
|
239
|
-
|
|
193
|
+
}
|
|
240
194
|
|
|
195
|
+
// confirm catalog update for group is not in progress.
|
|
241
196
|
if (catalog.status[serviceGroup].collecting) {
|
|
242
197
|
return this.waitForCatalog(serviceGroup);
|
|
243
198
|
}
|
|
244
|
-
|
|
245
199
|
catalog.status[serviceGroup].collecting = true;
|
|
246
|
-
|
|
247
200
|
if (serviceGroup === 'preauth') {
|
|
248
201
|
var queryKey = query && (0, _keys.default)(query)[0];
|
|
249
|
-
|
|
250
202
|
if (!['email', 'emailhash', 'userId', 'orgId', 'mode'].includes(queryKey)) {
|
|
251
203
|
return _promise.default.reject(new Error('a query param of email, emailhash, userId, orgId, or mode is required'));
|
|
252
204
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
205
|
+
}
|
|
206
|
+
// encode email when query key is email
|
|
256
207
|
if (serviceGroup === 'preauth' || serviceGroup === 'signin') {
|
|
257
208
|
var _queryKey = (0, _keys.default)(query)[0];
|
|
258
209
|
formattedQuery = {};
|
|
259
|
-
|
|
260
210
|
if (_queryKey === 'email' && query.email) {
|
|
261
211
|
formattedQuery.emailhash = (0, _sha.default)(query.email.toLowerCase()).toString();
|
|
262
212
|
} else {
|
|
263
213
|
formattedQuery[_queryKey] = query[_queryKey];
|
|
264
214
|
}
|
|
265
215
|
}
|
|
266
|
-
|
|
267
216
|
return this._fetchNewServiceHostmap({
|
|
268
217
|
from: from,
|
|
269
218
|
token: token,
|
|
@@ -271,16 +220,13 @@ var Services = _webexPlugin.default.extend({
|
|
|
271
220
|
forceRefresh: forceRefresh
|
|
272
221
|
}).then(function (serviceHostMap) {
|
|
273
222
|
catalog.updateServiceUrls(serviceGroup, serviceHostMap);
|
|
274
|
-
|
|
275
223
|
_this.updateCredentialsConfig();
|
|
276
|
-
|
|
277
224
|
catalog.status[serviceGroup].collecting = false;
|
|
278
225
|
}).catch(function (error) {
|
|
279
226
|
catalog.status[serviceGroup].collecting = false;
|
|
280
227
|
return _promise.default.reject(error);
|
|
281
228
|
});
|
|
282
229
|
},
|
|
283
|
-
|
|
284
230
|
/**
|
|
285
231
|
* User validation parameter transfer object for {@link validateUser}.
|
|
286
232
|
* @param {object} ValidateUserPTO
|
|
@@ -289,7 +235,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
289
235
|
* @property {object} [ValidateUserPTO.activationOptions] - Extra options to pass when sending the activation
|
|
290
236
|
* @property {object} [ValidateUserPTO.preloginUserId] - The prelogin user id to set when sending the activation.
|
|
291
237
|
*/
|
|
292
|
-
|
|
293
238
|
/**
|
|
294
239
|
* User validation return transfer object for {@link validateUser}.
|
|
295
240
|
* @param {object} ValidateUserRTO
|
|
@@ -298,7 +243,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
298
243
|
* @property {string} ValidateUserRTO.details - A descriptive status message.
|
|
299
244
|
* @property {object} ValidateUserRTO.user - **License** service user object.
|
|
300
245
|
*/
|
|
301
|
-
|
|
302
246
|
/**
|
|
303
247
|
* Validate if a user is activated and update the service catalogs as needed
|
|
304
248
|
* based on the user's activation status.
|
|
@@ -308,24 +252,25 @@ var Services = _webexPlugin.default.extend({
|
|
|
308
252
|
*/
|
|
309
253
|
validateUser: function validateUser(_ref2) {
|
|
310
254
|
var _this2 = this;
|
|
311
|
-
|
|
312
255
|
var email = _ref2.email,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
this.logger.info('services: validating a user');
|
|
321
|
-
|
|
256
|
+
_ref2$reqId = _ref2.reqId,
|
|
257
|
+
reqId = _ref2$reqId === void 0 ? 'WEBCLIENT' : _ref2$reqId,
|
|
258
|
+
_ref2$forceRefresh = _ref2.forceRefresh,
|
|
259
|
+
forceRefresh = _ref2$forceRefresh === void 0 ? false : _ref2$forceRefresh,
|
|
260
|
+
_ref2$activationOptio = _ref2.activationOptions,
|
|
261
|
+
activationOptions = _ref2$activationOptio === void 0 ? {} : _ref2$activationOptio,
|
|
262
|
+
preloginUserId = _ref2.preloginUserId;
|
|
263
|
+
this.logger.info('services: validating a user');
|
|
264
|
+
|
|
265
|
+
// Validate that an email parameter key was provided.
|
|
322
266
|
if (!email) {
|
|
323
267
|
return _promise.default.reject(new Error('`email` is required'));
|
|
324
|
-
}
|
|
325
|
-
|
|
268
|
+
}
|
|
326
269
|
|
|
327
|
-
|
|
270
|
+
// Destructure the credentials object.
|
|
271
|
+
var canAuthorize = this.webex.credentials.canAuthorize;
|
|
328
272
|
|
|
273
|
+
// Validate that the user is already authorized.
|
|
329
274
|
if (canAuthorize) {
|
|
330
275
|
return this.updateServices({
|
|
331
276
|
forceRefresh: forceRefresh
|
|
@@ -347,47 +292,49 @@ var Services = _webexPlugin.default.extend({
|
|
|
347
292
|
user: userObj
|
|
348
293
|
};
|
|
349
294
|
});
|
|
350
|
-
}
|
|
295
|
+
}
|
|
351
296
|
|
|
297
|
+
// Destructure the client authorization details.
|
|
352
298
|
/* eslint-disable camelcase */
|
|
353
|
-
|
|
354
|
-
|
|
355
299
|
var _this$webex$credentia = this.webex.credentials.config,
|
|
356
|
-
|
|
357
|
-
|
|
300
|
+
client_id = _this$webex$credentia.client_id,
|
|
301
|
+
client_secret = _this$webex$credentia.client_secret;
|
|
358
302
|
|
|
303
|
+
// Validate that client authentication details exist.
|
|
359
304
|
if (!client_id || !client_secret) {
|
|
360
305
|
return _promise.default.reject(new Error('client authentication details are not available'));
|
|
361
306
|
}
|
|
362
307
|
/* eslint-enable camelcase */
|
|
363
|
-
// Declare a class-memeber-scoped token for usage within the promise chain.
|
|
364
|
-
|
|
365
308
|
|
|
366
|
-
|
|
309
|
+
// Declare a class-memeber-scoped token for usage within the promise chain.
|
|
310
|
+
var token;
|
|
367
311
|
|
|
312
|
+
// Begin client authentication user validation.
|
|
368
313
|
return this.collectPreauthCatalog({
|
|
369
314
|
email: email
|
|
370
315
|
}).then(function () {
|
|
371
316
|
// Retrieve the service url from the updated catalog. This is required
|
|
372
317
|
// since `WebexCore` is usually not fully initialized at the time this
|
|
373
318
|
// request completes.
|
|
374
|
-
var idbrokerService = _this2.get('idbroker', true);
|
|
375
|
-
|
|
319
|
+
var idbrokerService = _this2.get('idbroker', true);
|
|
376
320
|
|
|
321
|
+
// Collect the client auth token.
|
|
377
322
|
return _this2.webex.credentials.getClientToken({
|
|
378
323
|
uri: "".concat(idbrokerService, "idb/oauth2/v1/access_token"),
|
|
379
324
|
scope: 'webexsquare:admin webexsquare:get_conversation Identity:SCIM'
|
|
380
325
|
});
|
|
381
326
|
}).then(function (tokenObj) {
|
|
382
327
|
// Generate the token string.
|
|
383
|
-
token = tokenObj.toString();
|
|
328
|
+
token = tokenObj.toString();
|
|
384
329
|
|
|
330
|
+
// Collect the signin catalog using the client auth information.
|
|
385
331
|
return _this2.collectSigninCatalog({
|
|
386
332
|
email: email,
|
|
387
333
|
token: token,
|
|
388
334
|
forceRefresh: forceRefresh
|
|
389
335
|
});
|
|
390
|
-
})
|
|
336
|
+
})
|
|
337
|
+
// Validate if collecting the signin catalog failed and populate the RTO
|
|
391
338
|
// with the appropriate content.
|
|
392
339
|
.catch(function (error) {
|
|
393
340
|
return {
|
|
@@ -395,7 +342,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
395
342
|
activated: false,
|
|
396
343
|
details: error.name !== 'NotFound' ? 'user exists but is not activated' : 'user does not exist and is not activated'
|
|
397
344
|
};
|
|
398
|
-
})
|
|
345
|
+
})
|
|
346
|
+
// Validate if the previous promise resolved with an RTO and populate the
|
|
399
347
|
// new RTO accordingly.
|
|
400
348
|
.then(function (rto) {
|
|
401
349
|
return _promise.default.all([rto || {
|
|
@@ -411,9 +359,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
411
359
|
})]);
|
|
412
360
|
}).then(function (_ref3) {
|
|
413
361
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
362
|
+
rto = _ref4[0],
|
|
363
|
+
user = _ref4[1];
|
|
417
364
|
return _objectSpread(_objectSpread({}, rto), {}, {
|
|
418
365
|
user: user
|
|
419
366
|
});
|
|
@@ -426,7 +373,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
426
373
|
return _promise.default.reject(response);
|
|
427
374
|
});
|
|
428
375
|
},
|
|
429
|
-
|
|
430
376
|
/**
|
|
431
377
|
* Get user meeting preferences (preferred webex site).
|
|
432
378
|
*
|
|
@@ -434,21 +380,18 @@ var Services = _webexPlugin.default.extend({
|
|
|
434
380
|
*/
|
|
435
381
|
getMeetingPreferences: function getMeetingPreferences() {
|
|
436
382
|
var _this3 = this;
|
|
437
|
-
|
|
438
383
|
return this.request({
|
|
439
384
|
method: 'GET',
|
|
440
385
|
service: 'hydra',
|
|
441
386
|
resource: 'meetingPreferences'
|
|
442
387
|
}).then(function (res) {
|
|
443
388
|
_this3.logger.info('services: received user region info');
|
|
444
|
-
|
|
445
389
|
return res.body;
|
|
446
390
|
}).catch(function (err) {
|
|
447
|
-
_this3.logger.info('services: was not able to fetch user login information', err);
|
|
448
|
-
|
|
391
|
+
_this3.logger.info('services: was not able to fetch user login information', err);
|
|
392
|
+
// resolve successfully even if request failed
|
|
449
393
|
});
|
|
450
394
|
},
|
|
451
|
-
|
|
452
395
|
/**
|
|
453
396
|
* Fetches client region info such as countryCode and timezone.
|
|
454
397
|
*
|
|
@@ -456,7 +399,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
456
399
|
*/
|
|
457
400
|
fetchClientRegionInfo: function fetchClientRegionInfo() {
|
|
458
401
|
var _this4 = this;
|
|
459
|
-
|
|
460
402
|
return this.request({
|
|
461
403
|
uri: 'https://ds.ciscospark.com/v1/region',
|
|
462
404
|
addAuthHeader: false,
|
|
@@ -466,14 +408,12 @@ var Services = _webexPlugin.default.extend({
|
|
|
466
408
|
timeout: 5000
|
|
467
409
|
}).then(function (res) {
|
|
468
410
|
_this4.logger.info('services: received user region info');
|
|
469
|
-
|
|
470
411
|
return res.body;
|
|
471
412
|
}).catch(function (err) {
|
|
472
|
-
_this4.logger.info('services: was not able to get user region info', err);
|
|
473
|
-
|
|
413
|
+
_this4.logger.info('services: was not able to get user region info', err);
|
|
414
|
+
// resolve successfully even if request failed
|
|
474
415
|
});
|
|
475
416
|
},
|
|
476
|
-
|
|
477
417
|
/**
|
|
478
418
|
* User activation parameter transfer object for {@link sendUserActivation}.
|
|
479
419
|
* @typedef {object} SendUserActivationPTO
|
|
@@ -483,7 +423,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
483
423
|
* @property {object} SendUserActivationPTO.activationOptions - Extra options to pass when sending the activation.
|
|
484
424
|
* @property {object} SendUserActivationPTO.preloginUserId - The prelogin user id to set when sending the activation.
|
|
485
425
|
*/
|
|
486
|
-
|
|
487
426
|
/**
|
|
488
427
|
* Send a request to activate a user using a client token.
|
|
489
428
|
*
|
|
@@ -492,22 +431,23 @@ var Services = _webexPlugin.default.extend({
|
|
|
492
431
|
*/
|
|
493
432
|
sendUserActivation: function sendUserActivation(_ref5) {
|
|
494
433
|
var _this5 = this;
|
|
495
|
-
|
|
496
434
|
var email = _ref5.email,
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
435
|
+
reqId = _ref5.reqId,
|
|
436
|
+
token = _ref5.token,
|
|
437
|
+
activationOptions = _ref5.activationOptions,
|
|
438
|
+
preloginUserId = _ref5.preloginUserId;
|
|
501
439
|
this.logger.info('services: sending user activation request');
|
|
502
|
-
var countryCode
|
|
440
|
+
var countryCode;
|
|
441
|
+
var timezone;
|
|
503
442
|
|
|
443
|
+
// try to fetch client region info first
|
|
504
444
|
return this.fetchClientRegionInfo().then(function (clientRegionInfo) {
|
|
505
445
|
if (clientRegionInfo) {
|
|
506
446
|
countryCode = clientRegionInfo.countryCode;
|
|
507
447
|
timezone = clientRegionInfo.timezone;
|
|
508
|
-
}
|
|
509
|
-
|
|
448
|
+
}
|
|
510
449
|
|
|
450
|
+
// Send the user activation request to the **License** service.
|
|
511
451
|
return _this5.request({
|
|
512
452
|
service: 'license',
|
|
513
453
|
resource: 'users/activations',
|
|
@@ -525,16 +465,17 @@ var Services = _webexPlugin.default.extend({
|
|
|
525
465
|
}, activationOptions),
|
|
526
466
|
shouldRefreshAccessToken: false
|
|
527
467
|
});
|
|
528
|
-
})
|
|
468
|
+
})
|
|
469
|
+
// On success, return the **License** user object.
|
|
529
470
|
.then(function (_ref6) {
|
|
530
471
|
var body = _ref6.body;
|
|
531
472
|
return body;
|
|
532
|
-
})
|
|
473
|
+
})
|
|
474
|
+
// On failure, reject with error from **License**.
|
|
533
475
|
.catch(function (error) {
|
|
534
476
|
return _promise.default.reject(error);
|
|
535
477
|
});
|
|
536
478
|
},
|
|
537
|
-
|
|
538
479
|
/**
|
|
539
480
|
* simplified method to update the preauth catalog via email
|
|
540
481
|
*
|
|
@@ -546,7 +487,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
546
487
|
*/
|
|
547
488
|
collectPreauthCatalog: function collectPreauthCatalog(query) {
|
|
548
489
|
var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
549
|
-
|
|
550
490
|
if (!query) {
|
|
551
491
|
return this.updateServices({
|
|
552
492
|
from: 'limited',
|
|
@@ -556,14 +496,12 @@ var Services = _webexPlugin.default.extend({
|
|
|
556
496
|
forceRefresh: forceRefresh
|
|
557
497
|
});
|
|
558
498
|
}
|
|
559
|
-
|
|
560
499
|
return this.updateServices({
|
|
561
500
|
from: 'limited',
|
|
562
501
|
query: query,
|
|
563
502
|
forceRefresh: forceRefresh
|
|
564
503
|
});
|
|
565
504
|
},
|
|
566
|
-
|
|
567
505
|
/**
|
|
568
506
|
* simplified method to update the signin catalog via email and token
|
|
569
507
|
* @param {object} param
|
|
@@ -573,18 +511,15 @@ var Services = _webexPlugin.default.extend({
|
|
|
573
511
|
*/
|
|
574
512
|
collectSigninCatalog: function collectSigninCatalog() {
|
|
575
513
|
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
514
|
+
email = _ref7.email,
|
|
515
|
+
token = _ref7.token,
|
|
516
|
+
forceRefresh = _ref7.forceRefresh;
|
|
580
517
|
if (!email) {
|
|
581
518
|
return _promise.default.reject(new Error('`email` is required'));
|
|
582
519
|
}
|
|
583
|
-
|
|
584
520
|
if (!token) {
|
|
585
521
|
return _promise.default.reject(new Error('`token` is required'));
|
|
586
522
|
}
|
|
587
|
-
|
|
588
523
|
return this.updateServices({
|
|
589
524
|
from: 'signin',
|
|
590
525
|
query: {
|
|
@@ -594,7 +529,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
594
529
|
forceRefresh: forceRefresh
|
|
595
530
|
});
|
|
596
531
|
},
|
|
597
|
-
|
|
598
532
|
/**
|
|
599
533
|
* Updates credentials config to utilize u2c catalog
|
|
600
534
|
* urls.
|
|
@@ -602,31 +536,29 @@ var Services = _webexPlugin.default.extend({
|
|
|
602
536
|
*/
|
|
603
537
|
updateCredentialsConfig: function updateCredentialsConfig() {
|
|
604
538
|
var _this$list = this.list(true),
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
539
|
+
idbroker = _this$list.idbroker,
|
|
540
|
+
identity = _this$list.identity;
|
|
608
541
|
if (idbroker && identity) {
|
|
609
542
|
var _this$webex$config$cr = this.webex.config.credentials,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
// idbroker and identity url values.
|
|
543
|
+
authorizationString = _this$webex$config$cr.authorizationString,
|
|
544
|
+
authorizeUrl = _this$webex$config$cr.authorizeUrl;
|
|
613
545
|
|
|
546
|
+
// This must be set outside of the setConfig method used to assign the
|
|
547
|
+
// idbroker and identity url values.
|
|
614
548
|
this.webex.config.credentials.authorizeUrl = authorizationString ? authorizeUrl : "".concat(idbroker.replace(trailingSlashes, ''), "/idb/oauth2/v1/authorize");
|
|
615
549
|
this.webex.setConfig({
|
|
616
550
|
credentials: {
|
|
617
551
|
idbroker: {
|
|
618
552
|
url: idbroker.replace(trailingSlashes, '') // remove trailing slash
|
|
619
|
-
|
|
620
553
|
},
|
|
554
|
+
|
|
621
555
|
identity: {
|
|
622
556
|
url: identity.replace(trailingSlashes, '') // remove trailing slash
|
|
623
|
-
|
|
624
557
|
}
|
|
625
558
|
}
|
|
626
559
|
});
|
|
627
560
|
}
|
|
628
561
|
},
|
|
629
|
-
|
|
630
562
|
/**
|
|
631
563
|
* Wait until the service catalog is available,
|
|
632
564
|
* or reject afte ra timeout of 60 seconds.
|
|
@@ -636,20 +568,15 @@ var Services = _webexPlugin.default.extend({
|
|
|
636
568
|
*/
|
|
637
569
|
waitForCatalog: function waitForCatalog(serviceGroup, timeout) {
|
|
638
570
|
var catalog = this._getCatalog();
|
|
639
|
-
|
|
640
571
|
var supertoken = this.webex.credentials.supertoken;
|
|
641
|
-
|
|
642
572
|
if (serviceGroup === 'postauth' && supertoken && supertoken.access_token && !catalog.status.postauth.collecting && !catalog.status.postauth.ready) {
|
|
643
573
|
if (!catalog.status.preauth.ready) {
|
|
644
574
|
return this.initServiceCatalogs();
|
|
645
575
|
}
|
|
646
|
-
|
|
647
576
|
return this.updateServices();
|
|
648
577
|
}
|
|
649
|
-
|
|
650
578
|
return catalog.waitForCatalog(serviceGroup, timeout);
|
|
651
579
|
},
|
|
652
|
-
|
|
653
580
|
/**
|
|
654
581
|
* Service waiting parameter transfer object for {@link waitForService}.
|
|
655
582
|
*
|
|
@@ -658,7 +585,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
658
585
|
* @property {string} [WaitForServicePTO.url] - The service url.
|
|
659
586
|
* @property {string} [WaitForServicePTO.timeout] - wait duration in seconds.
|
|
660
587
|
*/
|
|
661
|
-
|
|
662
588
|
/**
|
|
663
589
|
* Wait until the service has been ammended to any service catalog. This
|
|
664
590
|
* method prioritizes the service name over the service url when searching.
|
|
@@ -668,35 +594,29 @@ var Services = _webexPlugin.default.extend({
|
|
|
668
594
|
*/
|
|
669
595
|
waitForService: function waitForService(_ref8) {
|
|
670
596
|
var _this6 = this;
|
|
671
|
-
|
|
672
597
|
var name = _ref8.name,
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
var services = this.webex.config.services;
|
|
598
|
+
_ref8$timeout = _ref8.timeout,
|
|
599
|
+
timeout = _ref8$timeout === void 0 ? 5 : _ref8$timeout,
|
|
600
|
+
url = _ref8.url;
|
|
601
|
+
var services = this.webex.config.services;
|
|
677
602
|
|
|
603
|
+
// Save memory by grabbing the catalog after there isn't a priortyURL
|
|
678
604
|
var catalog = this._getCatalog();
|
|
679
|
-
|
|
680
605
|
var fetchFromServiceUrl = services.servicesNotNeedValidation.find(function (service) {
|
|
681
606
|
return service === name;
|
|
682
607
|
});
|
|
683
|
-
|
|
684
608
|
if (fetchFromServiceUrl) {
|
|
685
609
|
return _promise.default.resolve(this._serviceUrls[name]);
|
|
686
610
|
}
|
|
687
|
-
|
|
688
611
|
var priorityUrl = this.get(name, true);
|
|
689
612
|
var priorityUrlObj = this.getServiceFromUrl(url);
|
|
690
|
-
|
|
691
613
|
if (priorityUrl || priorityUrlObj) {
|
|
692
614
|
return _promise.default.resolve(priorityUrl || priorityUrlObj.priorityUrl);
|
|
693
615
|
}
|
|
694
|
-
|
|
695
616
|
if (catalog.isReady) {
|
|
696
617
|
if (url) {
|
|
697
618
|
return _promise.default.resolve(url);
|
|
698
619
|
}
|
|
699
|
-
|
|
700
620
|
this.webex.internal.metrics.submitClientMetrics(_metrics.default.JS_SDK_SERVICE_NOT_FOUND, {
|
|
701
621
|
fields: {
|
|
702
622
|
service_name: name
|
|
@@ -704,16 +624,12 @@ var Services = _webexPlugin.default.extend({
|
|
|
704
624
|
});
|
|
705
625
|
return _promise.default.reject(new Error("services: service '".concat(name, "' was not found in any of the catalogs")));
|
|
706
626
|
}
|
|
707
|
-
|
|
708
627
|
return new _promise.default(function (resolve, reject) {
|
|
709
628
|
var groupsToCheck = ['preauth', 'signin', 'postauth'];
|
|
710
|
-
|
|
711
629
|
var checkCatalog = function checkCatalog(catalogGroup) {
|
|
712
630
|
return catalog.waitForCatalog(catalogGroup, timeout).then(function () {
|
|
713
631
|
var scopedPriorityUrl = _this6.get(name, true);
|
|
714
|
-
|
|
715
632
|
var scopedPrioriryUrlObj = _this6.getServiceFromUrl(url);
|
|
716
|
-
|
|
717
633
|
if (scopedPriorityUrl || scopedPrioriryUrlObj) {
|
|
718
634
|
resolve(scopedPriorityUrl || scopedPrioriryUrlObj.priorityUrl);
|
|
719
635
|
}
|
|
@@ -721,7 +637,6 @@ var Services = _webexPlugin.default.extend({
|
|
|
721
637
|
return undefined;
|
|
722
638
|
});
|
|
723
639
|
};
|
|
724
|
-
|
|
725
640
|
_promise.default.all(groupsToCheck.map(function (group) {
|
|
726
641
|
return checkCatalog(group);
|
|
727
642
|
})).then(function () {
|
|
@@ -730,12 +645,10 @@ var Services = _webexPlugin.default.extend({
|
|
|
730
645
|
service_name: name
|
|
731
646
|
}
|
|
732
647
|
});
|
|
733
|
-
|
|
734
648
|
reject(new Error("services: service '".concat(name, "' was not found after waiting")));
|
|
735
649
|
});
|
|
736
650
|
});
|
|
737
651
|
},
|
|
738
|
-
|
|
739
652
|
/**
|
|
740
653
|
* @private
|
|
741
654
|
* Organize a received hostmap from a service
|
|
@@ -747,17 +660,14 @@ var Services = _webexPlugin.default.extend({
|
|
|
747
660
|
// map the host catalog items to a formatted hostmap
|
|
748
661
|
var formattedHostmap = (0, _keys.default)(serviceHostmap.hostCatalog).reduce(function (accumulator, key) {
|
|
749
662
|
var _serviceItem$hosts;
|
|
750
|
-
|
|
751
663
|
if (serviceHostmap.hostCatalog[key].length === 0) {
|
|
752
664
|
return accumulator;
|
|
753
665
|
}
|
|
754
|
-
|
|
755
666
|
var serviceName = serviceHostmap.hostCatalog[key][0].id.split(':')[3];
|
|
756
667
|
var defaultUrl = serviceHostmap.serviceLinks[serviceName];
|
|
757
668
|
var serviceItem = accumulator.find(function (item) {
|
|
758
669
|
return item.name === serviceName;
|
|
759
670
|
});
|
|
760
|
-
|
|
761
671
|
if (!serviceItem) {
|
|
762
672
|
serviceItem = {
|
|
763
673
|
name: serviceName,
|
|
@@ -767,8 +677,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
767
677
|
};
|
|
768
678
|
accumulator.push(serviceItem);
|
|
769
679
|
}
|
|
770
|
-
|
|
771
|
-
|
|
680
|
+
(_serviceItem$hosts = serviceItem.hosts).push.apply(_serviceItem$hosts, [
|
|
681
|
+
// map the default key as a low priority default for cluster matching
|
|
772
682
|
{
|
|
773
683
|
host: key,
|
|
774
684
|
ttl: -1,
|
|
@@ -780,15 +690,14 @@ var Services = _webexPlugin.default.extend({
|
|
|
780
690
|
homeCluster: serviceItem.defaultHost === key
|
|
781
691
|
});
|
|
782
692
|
}))));
|
|
783
|
-
|
|
784
693
|
return accumulator;
|
|
785
|
-
}, []);
|
|
694
|
+
}, []);
|
|
786
695
|
|
|
696
|
+
// append service links that do not exist in the host catalog
|
|
787
697
|
(0, _keys.default)(serviceHostmap.serviceLinks).forEach(function (key) {
|
|
788
698
|
var service = formattedHostmap.find(function (item) {
|
|
789
699
|
return item.name === key;
|
|
790
700
|
});
|
|
791
|
-
|
|
792
701
|
if (!service) {
|
|
793
702
|
formattedHostmap.push({
|
|
794
703
|
name: key,
|
|
@@ -797,13 +706,13 @@ var Services = _webexPlugin.default.extend({
|
|
|
797
706
|
hosts: []
|
|
798
707
|
});
|
|
799
708
|
}
|
|
800
|
-
});
|
|
709
|
+
});
|
|
801
710
|
|
|
802
|
-
|
|
711
|
+
// update all the service urls in the host catalog
|
|
803
712
|
|
|
713
|
+
this._updateServiceUrls(serviceHostmap.serviceLinks);
|
|
804
714
|
return formattedHostmap;
|
|
805
715
|
},
|
|
806
|
-
|
|
807
716
|
/**
|
|
808
717
|
* Get the clusterId associated with a URL string.
|
|
809
718
|
* @param {string} url
|
|
@@ -811,10 +720,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
811
720
|
*/
|
|
812
721
|
getClusterId: function getClusterId(url) {
|
|
813
722
|
var catalog = this._getCatalog();
|
|
814
|
-
|
|
815
723
|
return catalog.findClusterId(url);
|
|
816
724
|
},
|
|
817
|
-
|
|
818
725
|
/**
|
|
819
726
|
* Get a service value from a provided clusterId. This method will
|
|
820
727
|
* return an object containing both the name and url of a found service.
|
|
@@ -828,10 +735,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
828
735
|
*/
|
|
829
736
|
getServiceFromClusterId: function getServiceFromClusterId(params) {
|
|
830
737
|
var catalog = this._getCatalog();
|
|
831
|
-
|
|
832
738
|
return catalog.findServiceFromClusterId(params);
|
|
833
739
|
},
|
|
834
|
-
|
|
835
740
|
/**
|
|
836
741
|
* Get a service object from a service url if the service url exists in the
|
|
837
742
|
* catalog.
|
|
@@ -844,20 +749,16 @@ var Services = _webexPlugin.default.extend({
|
|
|
844
749
|
*/
|
|
845
750
|
getServiceFromUrl: function getServiceFromUrl() {
|
|
846
751
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
847
|
-
|
|
848
752
|
var service = this._getCatalog().findServiceUrlFromUrl(url);
|
|
849
|
-
|
|
850
753
|
if (!service) {
|
|
851
754
|
return undefined;
|
|
852
755
|
}
|
|
853
|
-
|
|
854
756
|
return {
|
|
855
757
|
name: service.name,
|
|
856
758
|
priorityUrl: service.get(true),
|
|
857
759
|
defaultUrl: service.get()
|
|
858
760
|
};
|
|
859
761
|
},
|
|
860
|
-
|
|
861
762
|
/**
|
|
862
763
|
* Verify that a provided url exists in the service
|
|
863
764
|
* catalog.
|
|
@@ -866,10 +767,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
866
767
|
*/
|
|
867
768
|
isServiceUrl: function isServiceUrl(url) {
|
|
868
769
|
var catalog = this._getCatalog();
|
|
869
|
-
|
|
870
770
|
return !!catalog.findServiceUrlFromUrl(url);
|
|
871
771
|
},
|
|
872
|
-
|
|
873
772
|
/**
|
|
874
773
|
* Determine if a provided url is in the catalog's allowed domains.
|
|
875
774
|
*
|
|
@@ -878,10 +777,8 @@ var Services = _webexPlugin.default.extend({
|
|
|
878
777
|
*/
|
|
879
778
|
isAllowedDomainUrl: function isAllowedDomainUrl(url) {
|
|
880
779
|
var catalog = this._getCatalog();
|
|
881
|
-
|
|
882
780
|
return !!catalog.findAllowedDomain(url);
|
|
883
781
|
},
|
|
884
|
-
|
|
885
782
|
/**
|
|
886
783
|
* Converts the host portion of the url from default host
|
|
887
784
|
* to a priority host
|
|
@@ -893,14 +790,11 @@ var Services = _webexPlugin.default.extend({
|
|
|
893
790
|
convertUrlToPriorityHostUrl: function convertUrlToPriorityHostUrl() {
|
|
894
791
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
895
792
|
var data = this.getServiceFromUrl(url);
|
|
896
|
-
|
|
897
793
|
if (!data) {
|
|
898
794
|
throw Error("No service associated with url: [".concat(url, "]"));
|
|
899
795
|
}
|
|
900
|
-
|
|
901
796
|
return url.replace(data.defaultUrl, data.priorityUrl);
|
|
902
797
|
},
|
|
903
|
-
|
|
904
798
|
/**
|
|
905
799
|
* @private
|
|
906
800
|
* Simplified method wrapper for sending a request to get
|
|
@@ -916,43 +810,35 @@ var Services = _webexPlugin.default.extend({
|
|
|
916
810
|
*/
|
|
917
811
|
_fetchNewServiceHostmap: function _fetchNewServiceHostmap() {
|
|
918
812
|
var _this7 = this;
|
|
919
|
-
|
|
920
813
|
var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
814
|
+
from = _ref9.from,
|
|
815
|
+
query = _ref9.query,
|
|
816
|
+
token = _ref9.token,
|
|
817
|
+
forceRefresh = _ref9.forceRefresh;
|
|
926
818
|
var service = 'u2c';
|
|
927
819
|
var resource = from ? "/".concat(from, "/catalog") : '/catalog';
|
|
928
|
-
|
|
929
820
|
var qs = _objectSpread(_objectSpread({}, query), {}, {
|
|
930
821
|
format: 'hostmap'
|
|
931
822
|
});
|
|
932
|
-
|
|
933
823
|
if (forceRefresh) {
|
|
934
824
|
qs.timestamp = new Date().getTime();
|
|
935
825
|
}
|
|
936
|
-
|
|
937
826
|
var requestObject = {
|
|
938
827
|
method: 'GET',
|
|
939
828
|
service: service,
|
|
940
829
|
resource: resource,
|
|
941
830
|
qs: qs
|
|
942
831
|
};
|
|
943
|
-
|
|
944
832
|
if (token) {
|
|
945
833
|
requestObject.headers = {
|
|
946
834
|
authorization: token
|
|
947
835
|
};
|
|
948
836
|
}
|
|
949
|
-
|
|
950
837
|
return this.request(requestObject).then(function (_ref10) {
|
|
951
838
|
var body = _ref10.body;
|
|
952
839
|
return _this7._formatReceivedHostmap(body);
|
|
953
840
|
});
|
|
954
841
|
},
|
|
955
|
-
|
|
956
842
|
/**
|
|
957
843
|
* Initialize the discovery services and the whitelisted services.
|
|
958
844
|
*
|
|
@@ -961,17 +847,16 @@ var Services = _webexPlugin.default.extend({
|
|
|
961
847
|
initConfig: function initConfig() {
|
|
962
848
|
// Get the catalog and destructure the services config.
|
|
963
849
|
var catalog = this._getCatalog();
|
|
964
|
-
|
|
965
850
|
var _this$webex$config = this.webex.config,
|
|
966
|
-
|
|
967
|
-
|
|
851
|
+
services = _this$webex$config.services,
|
|
852
|
+
fedramp = _this$webex$config.fedramp;
|
|
968
853
|
|
|
854
|
+
// Validate that the services configuration exists.
|
|
969
855
|
if (services) {
|
|
970
856
|
if (fedramp) {
|
|
971
857
|
services.discovery = _serviceFedRamp.default;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
|
|
858
|
+
}
|
|
859
|
+
// Check for discovery services.
|
|
975
860
|
if (services.discovery) {
|
|
976
861
|
// Format the discovery configuration into an injectable array.
|
|
977
862
|
var formattedDiscoveryServices = (0, _keys.default)(services.discovery).map(function (key) {
|
|
@@ -979,11 +864,11 @@ var Services = _webexPlugin.default.extend({
|
|
|
979
864
|
name: key,
|
|
980
865
|
defaultUrl: services.discovery[key]
|
|
981
866
|
};
|
|
982
|
-
});
|
|
867
|
+
});
|
|
983
868
|
|
|
869
|
+
// Inject formatted discovery services into services catalog.
|
|
984
870
|
catalog.updateServiceUrls('discovery', formattedDiscoveryServices);
|
|
985
871
|
}
|
|
986
|
-
|
|
987
872
|
if (services.override) {
|
|
988
873
|
// Format the override configuration into an injectable array.
|
|
989
874
|
var formattedOverrideServices = (0, _keys.default)(services.override).map(function (key) {
|
|
@@ -991,22 +876,22 @@ var Services = _webexPlugin.default.extend({
|
|
|
991
876
|
name: key,
|
|
992
877
|
defaultUrl: services.override[key]
|
|
993
878
|
};
|
|
994
|
-
});
|
|
879
|
+
});
|
|
995
880
|
|
|
881
|
+
// Inject formatted override services into services catalog.
|
|
996
882
|
catalog.updateServiceUrls('override', formattedOverrideServices);
|
|
997
|
-
}
|
|
998
|
-
|
|
883
|
+
}
|
|
999
884
|
|
|
885
|
+
// Check for allowed host domains.
|
|
1000
886
|
if (services.allowedDomains) {
|
|
1001
887
|
// Store the allowed domains as a property of the catalog.
|
|
1002
888
|
catalog.setAllowedDomains(services.allowedDomains);
|
|
1003
|
-
}
|
|
1004
|
-
|
|
889
|
+
}
|
|
1005
890
|
|
|
891
|
+
// Set `validateDomains` property to match configuration
|
|
1006
892
|
this.validateDomains = services.validateDomains;
|
|
1007
893
|
}
|
|
1008
894
|
},
|
|
1009
|
-
|
|
1010
895
|
/**
|
|
1011
896
|
* Make the initial requests to collect the root catalogs.
|
|
1012
897
|
*
|
|
@@ -1014,16 +899,19 @@ var Services = _webexPlugin.default.extend({
|
|
|
1014
899
|
*/
|
|
1015
900
|
initServiceCatalogs: function initServiceCatalogs() {
|
|
1016
901
|
var _this8 = this;
|
|
902
|
+
this.logger.info('services: initializing initial service catalogs');
|
|
1017
903
|
|
|
1018
|
-
|
|
904
|
+
// Destructure the credentials plugin.
|
|
905
|
+
var credentials = this.webex.credentials;
|
|
1019
906
|
|
|
1020
|
-
|
|
907
|
+
// Init a promise chain. Must be done as a Promise.resolve() to allow
|
|
1021
908
|
// credentials#getOrgId() to properly throw.
|
|
1022
|
-
|
|
1023
|
-
|
|
909
|
+
return _promise.default.resolve()
|
|
910
|
+
// Get the user's OrgId.
|
|
1024
911
|
.then(function () {
|
|
1025
912
|
return credentials.getOrgId();
|
|
1026
|
-
})
|
|
913
|
+
})
|
|
914
|
+
// Begin collecting the preauth/limited catalog.
|
|
1027
915
|
.then(function (orgId) {
|
|
1028
916
|
return _this8.collectPreauthCatalog({
|
|
1029
917
|
orgId: orgId
|
|
@@ -1035,13 +923,12 @@ var Services = _webexPlugin.default.extend({
|
|
|
1035
923
|
return _this8.updateServices().catch(function () {
|
|
1036
924
|
return _this8.logger.warn('services: cannot retrieve postauth catalog');
|
|
1037
925
|
});
|
|
1038
|
-
}
|
|
1039
|
-
|
|
926
|
+
}
|
|
1040
927
|
|
|
928
|
+
// Return a resolved promise for consistent return value.
|
|
1041
929
|
return _promise.default.resolve();
|
|
1042
930
|
});
|
|
1043
931
|
},
|
|
1044
|
-
|
|
1045
932
|
/**
|
|
1046
933
|
* Initializer
|
|
1047
934
|
*
|
|
@@ -1051,24 +938,24 @@ var Services = _webexPlugin.default.extend({
|
|
|
1051
938
|
*/
|
|
1052
939
|
initialize: function initialize() {
|
|
1053
940
|
var _this9 = this;
|
|
1054
|
-
|
|
1055
941
|
var catalog = new _serviceCatalog.default();
|
|
1056
942
|
var registry = new _serviceRegistry.default();
|
|
1057
943
|
var state = new _serviceState.default();
|
|
1058
|
-
|
|
1059
944
|
this._catalogs.set(this.webex, catalog);
|
|
1060
|
-
|
|
1061
945
|
this.registries.set(this.webex, registry);
|
|
1062
|
-
this.states.set(this.webex, state);
|
|
946
|
+
this.states.set(this.webex, state);
|
|
1063
947
|
|
|
948
|
+
// Listen for configuration changes once.
|
|
1064
949
|
this.listenToOnce(this.webex, 'change:config', function () {
|
|
1065
950
|
_this9.initConfig();
|
|
1066
|
-
});
|
|
1067
|
-
// to update the service catalogs
|
|
951
|
+
});
|
|
1068
952
|
|
|
953
|
+
// wait for webex instance to be ready before attempting
|
|
954
|
+
// to update the service catalogs
|
|
1069
955
|
this.listenToOnce(this.webex, 'ready', function () {
|
|
1070
|
-
var supertoken = _this9.webex.credentials.supertoken;
|
|
956
|
+
var supertoken = _this9.webex.credentials.supertoken;
|
|
1071
957
|
|
|
958
|
+
// Validate if the supertoken exists.
|
|
1072
959
|
if (supertoken && supertoken.access_token) {
|
|
1073
960
|
_this9.initServiceCatalogs().then(function () {
|
|
1074
961
|
catalog.isReady = true;
|
|
@@ -1077,18 +964,15 @@ var Services = _webexPlugin.default.extend({
|
|
|
1077
964
|
});
|
|
1078
965
|
} else {
|
|
1079
966
|
var email = _this9.webex.config.email;
|
|
1080
|
-
|
|
1081
967
|
_this9.collectPreauthCatalog(email ? {
|
|
1082
968
|
email: email
|
|
1083
969
|
} : undefined);
|
|
1084
970
|
}
|
|
1085
971
|
});
|
|
1086
972
|
},
|
|
1087
|
-
version: "3.0.0-beta.
|
|
973
|
+
version: "3.0.0-beta.21"
|
|
1088
974
|
});
|
|
1089
975
|
/* eslint-enable no-underscore-dangle */
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
976
|
var _default = Services;
|
|
1093
977
|
exports.default = _default;
|
|
1094
978
|
//# sourceMappingURL=services.js.map
|