@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.
Files changed (184) hide show
  1. package/dist/config.js +1 -11
  2. package/dist/config.js.map +1 -1
  3. package/dist/credentials-config.js +44 -64
  4. package/dist/credentials-config.js.map +1 -1
  5. package/dist/index.js +0 -76
  6. package/dist/index.js.map +1 -1
  7. package/dist/interceptors/auth.js +22 -55
  8. package/dist/interceptors/auth.js.map +1 -1
  9. package/dist/interceptors/default-options.js +0 -20
  10. package/dist/interceptors/default-options.js.map +1 -1
  11. package/dist/interceptors/embargo.js +0 -21
  12. package/dist/interceptors/embargo.js.map +1 -1
  13. package/dist/interceptors/network-timing.js +2 -21
  14. package/dist/interceptors/network-timing.js.map +1 -1
  15. package/dist/interceptors/payload-transformer.js +2 -22
  16. package/dist/interceptors/payload-transformer.js.map +1 -1
  17. package/dist/interceptors/rate-limit.js +25 -57
  18. package/dist/interceptors/rate-limit.js.map +1 -1
  19. package/dist/interceptors/redirect.js +4 -33
  20. package/dist/interceptors/redirect.js.map +1 -1
  21. package/dist/interceptors/request-event.js +3 -30
  22. package/dist/interceptors/request-event.js.map +1 -1
  23. package/dist/interceptors/request-logger.js +1 -30
  24. package/dist/interceptors/request-logger.js.map +1 -1
  25. package/dist/interceptors/request-timing.js +3 -22
  26. package/dist/interceptors/request-timing.js.map +1 -1
  27. package/dist/interceptors/response-logger.js +2 -31
  28. package/dist/interceptors/response-logger.js.map +1 -1
  29. package/dist/interceptors/user-agent.js +2 -29
  30. package/dist/interceptors/user-agent.js.map +1 -1
  31. package/dist/interceptors/webex-tracking-id.js +5 -28
  32. package/dist/interceptors/webex-tracking-id.js.map +1 -1
  33. package/dist/interceptors/webex-user-agent.js +5 -38
  34. package/dist/interceptors/webex-user-agent.js.map +1 -1
  35. package/dist/lib/batcher.js +3 -51
  36. package/dist/lib/batcher.js.map +1 -1
  37. package/dist/lib/credentials/credentials.js +39 -119
  38. package/dist/lib/credentials/credentials.js.map +1 -1
  39. package/dist/lib/credentials/grant-errors.js +0 -49
  40. package/dist/lib/credentials/grant-errors.js.map +1 -1
  41. package/dist/lib/credentials/index.js +1 -13
  42. package/dist/lib/credentials/index.js.map +1 -1
  43. package/dist/lib/credentials/scope.js +1 -7
  44. package/dist/lib/credentials/scope.js.map +1 -1
  45. package/dist/lib/credentials/token-collection.js +1 -7
  46. package/dist/lib/credentials/token-collection.js.map +1 -1
  47. package/dist/lib/credentials/token.js +39 -118
  48. package/dist/lib/credentials/token.js.map +1 -1
  49. package/dist/lib/page.js +13 -26
  50. package/dist/lib/page.js.map +1 -1
  51. package/dist/lib/services/constants.js +0 -2
  52. package/dist/lib/services/constants.js.map +1 -1
  53. package/dist/lib/services/index.js +1 -28
  54. package/dist/lib/services/index.js.map +1 -1
  55. package/dist/lib/services/interceptors/server-error.js +2 -23
  56. package/dist/lib/services/interceptors/server-error.js.map +1 -1
  57. package/dist/lib/services/interceptors/service.js +12 -34
  58. package/dist/lib/services/interceptors/service.js.map +1 -1
  59. package/dist/lib/services/metrics.js +0 -2
  60. package/dist/lib/services/metrics.js.map +1 -1
  61. package/dist/lib/services/service-catalog.js +10 -90
  62. package/dist/lib/services/service-catalog.js.map +1 -1
  63. package/dist/lib/services/service-fed-ramp.js +0 -2
  64. package/dist/lib/services/service-fed-ramp.js.map +1 -1
  65. package/dist/lib/services/service-host.js +47 -62
  66. package/dist/lib/services/service-host.js.map +1 -1
  67. package/dist/lib/services/service-registry.js +78 -90
  68. package/dist/lib/services/service-registry.js.map +1 -1
  69. package/dist/lib/services/service-state.js +3 -15
  70. package/dist/lib/services/service-state.js.map +1 -1
  71. package/dist/lib/services/service-url.js +4 -25
  72. package/dist/lib/services/service-url.js.map +1 -1
  73. package/dist/lib/services/services.js +122 -238
  74. package/dist/lib/services/services.js.map +1 -1
  75. package/dist/lib/stateless-webex-plugin.js +5 -28
  76. package/dist/lib/stateless-webex-plugin.js.map +1 -1
  77. package/dist/lib/storage/decorators.js +19 -62
  78. package/dist/lib/storage/decorators.js.map +1 -1
  79. package/dist/lib/storage/errors.js +0 -23
  80. package/dist/lib/storage/errors.js.map +1 -1
  81. package/dist/lib/storage/index.js +2 -16
  82. package/dist/lib/storage/index.js.map +1 -1
  83. package/dist/lib/storage/make-webex-plugin-store.js +11 -41
  84. package/dist/lib/storage/make-webex-plugin-store.js.map +1 -1
  85. package/dist/lib/storage/make-webex-store.js +8 -30
  86. package/dist/lib/storage/make-webex-store.js.map +1 -1
  87. package/dist/lib/storage/memory-store-adapter.js +1 -19
  88. package/dist/lib/storage/memory-store-adapter.js.map +1 -1
  89. package/dist/lib/webex-core-plugin-mixin.js +9 -29
  90. package/dist/lib/webex-core-plugin-mixin.js.map +1 -1
  91. package/dist/lib/webex-http-error.js +1 -31
  92. package/dist/lib/webex-http-error.js.map +1 -1
  93. package/dist/lib/webex-internal-core-plugin-mixin.js +9 -29
  94. package/dist/lib/webex-internal-core-plugin-mixin.js.map +1 -1
  95. package/dist/lib/webex-plugin.js +6 -40
  96. package/dist/lib/webex-plugin.js.map +1 -1
  97. package/dist/plugins/logger.js +3 -17
  98. package/dist/plugins/logger.js.map +1 -1
  99. package/dist/webex-core.js +79 -203
  100. package/dist/webex-core.js.map +1 -1
  101. package/dist/webex-internal-core.js +0 -10
  102. package/dist/webex-internal-core.js.map +1 -1
  103. package/package.json +14 -14
  104. package/src/config.js +9 -11
  105. package/src/credentials-config.js +110 -72
  106. package/src/index.js +4 -14
  107. package/src/interceptors/auth.js +36 -37
  108. package/src/interceptors/default-options.js +0 -1
  109. package/src/interceptors/embargo.js +1 -1
  110. package/src/interceptors/payload-transformer.js +1 -2
  111. package/src/interceptors/rate-limit.js +8 -5
  112. package/src/interceptors/redirect.js +14 -8
  113. package/src/interceptors/request-event.js +4 -8
  114. package/src/interceptors/request-logger.js +8 -5
  115. package/src/interceptors/response-logger.js +11 -8
  116. package/src/interceptors/user-agent.js +1 -2
  117. package/src/interceptors/webex-user-agent.js +3 -9
  118. package/src/lib/batcher.js +70 -69
  119. package/src/lib/credentials/credentials.js +112 -122
  120. package/src/lib/credentials/grant-errors.js +6 -7
  121. package/src/lib/credentials/index.js +1 -4
  122. package/src/lib/credentials/scope.js +1 -4
  123. package/src/lib/credentials/token-collection.js +1 -1
  124. package/src/lib/credentials/token.js +86 -80
  125. package/src/lib/page.js +10 -11
  126. package/src/lib/services/constants.js +3 -13
  127. package/src/lib/services/index.js +2 -2
  128. package/src/lib/services/interceptors/server-error.js +12 -7
  129. package/src/lib/services/interceptors/service.js +6 -5
  130. package/src/lib/services/metrics.js +1 -1
  131. package/src/lib/services/service-catalog.js +110 -100
  132. package/src/lib/services/service-fed-ramp.js +1 -2
  133. package/src/lib/services/service-host.js +10 -17
  134. package/src/lib/services/service-registry.js +69 -96
  135. package/src/lib/services/service-state.js +4 -6
  136. package/src/lib/services/service-url.js +24 -23
  137. package/src/lib/services/services.js +260 -251
  138. package/src/lib/stateless-webex-plugin.js +4 -2
  139. package/src/lib/storage/decorators.js +68 -66
  140. package/src/lib/storage/index.js +4 -6
  141. package/src/lib/storage/make-webex-plugin-store.js +34 -21
  142. package/src/lib/storage/make-webex-store.js +6 -7
  143. package/src/lib/storage/memory-store-adapter.js +3 -3
  144. package/src/lib/webex-core-plugin-mixin.js +10 -7
  145. package/src/lib/webex-http-error.js +7 -8
  146. package/src/lib/webex-internal-core-plugin-mixin.js +9 -6
  147. package/src/lib/webex-plugin.js +41 -34
  148. package/src/plugins/logger.js +8 -3
  149. package/src/webex-core.js +185 -116
  150. package/src/webex-internal-core.js +15 -9
  151. package/test/integration/spec/credentials/credentials.js +26 -30
  152. package/test/integration/spec/credentials/token.js +36 -33
  153. package/test/integration/spec/services/service-catalog.js +177 -156
  154. package/test/integration/spec/services/services.js +313 -304
  155. package/test/integration/spec/webex-core.js +98 -86
  156. package/test/unit/spec/_setup.js +26 -18
  157. package/test/unit/spec/credentials/credentials.js +189 -154
  158. package/test/unit/spec/credentials/token.js +94 -76
  159. package/test/unit/spec/interceptors/auth.js +291 -243
  160. package/test/unit/spec/interceptors/default-options.js +36 -24
  161. package/test/unit/spec/interceptors/embargo.js +32 -27
  162. package/test/unit/spec/interceptors/network-timing.js +2 -2
  163. package/test/unit/spec/interceptors/payload-transformer.js +61 -52
  164. package/test/unit/spec/interceptors/rate-limit.js +104 -75
  165. package/test/unit/spec/interceptors/redirect.js +22 -20
  166. package/test/unit/spec/interceptors/request-timing.js +18 -22
  167. package/test/unit/spec/interceptors/user-agent.js +28 -16
  168. package/test/unit/spec/interceptors/webex-tracking-id.js +14 -8
  169. package/test/unit/spec/interceptors/webex-user-agent.js +83 -37
  170. package/test/unit/spec/lib/batcher.js +36 -32
  171. package/test/unit/spec/lib/page.js +36 -32
  172. package/test/unit/spec/lib/webex-plugin.js +1 -1
  173. package/test/unit/spec/services/interceptors/server-error.js +67 -90
  174. package/test/unit/spec/services/interceptors/service.js +17 -28
  175. package/test/unit/spec/services/service-catalog.js +19 -27
  176. package/test/unit/spec/services/service-host.js +29 -26
  177. package/test/unit/spec/services/service-registry.js +128 -170
  178. package/test/unit/spec/services/service-state.js +13 -22
  179. package/test/unit/spec/services/service-url.js +24 -43
  180. package/test/unit/spec/services/services.js +85 -41
  181. package/test/unit/spec/storage/persist.js +6 -9
  182. package/test/unit/spec/storage/wait-for-value.js +22 -21
  183. package/test/unit/spec/webex-core.js +78 -57
  184. 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
- * saves all the services from the pre and post catalog service
193
- * @param {Object} serviceUrls
194
- * @returns {void}
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
- from = _ref.from,
218
- query = _ref.query,
219
- token = _ref.token,
220
- forceRefresh = _ref.forceRefresh;
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
- var formattedQuery, serviceGroup; // map catalog name to service group name.
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
- } // confirm catalog update for group is not in progress.
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
- } // encode email when query key is email
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
- _ref2$reqId = _ref2.reqId,
314
- reqId = _ref2$reqId === void 0 ? 'WEBCLIENT' : _ref2$reqId,
315
- _ref2$forceRefresh = _ref2.forceRefresh,
316
- forceRefresh = _ref2$forceRefresh === void 0 ? false : _ref2$forceRefresh,
317
- _ref2$activationOptio = _ref2.activationOptions,
318
- activationOptions = _ref2$activationOptio === void 0 ? {} : _ref2$activationOptio,
319
- preloginUserId = _ref2.preloginUserId;
320
- this.logger.info('services: validating a user'); // Validate that an email parameter key was provided.
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
- } // Destructure the credentials object.
325
-
268
+ }
326
269
 
327
- var canAuthorize = this.webex.credentials.canAuthorize; // Validate that the user is already authorized.
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
- } // Destructure the client authorization details.
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
- client_id = _this$webex$credentia.client_id,
357
- client_secret = _this$webex$credentia.client_secret; // Validate that client authentication details exist.
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
- var token; // Begin client authentication user validation.
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); // Collect the client auth token.
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(); // Collect the signin catalog using the client auth information.
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
- }) // Validate if collecting the signin catalog failed and populate the RTO
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
- }) // Validate if the previous promise resolved with an RTO and populate the
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
- rto = _ref4[0],
415
- user = _ref4[1];
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); // resolve successfully even if request failed
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); // resolve successfully even if request failed
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
- reqId = _ref5.reqId,
498
- token = _ref5.token,
499
- activationOptions = _ref5.activationOptions,
500
- preloginUserId = _ref5.preloginUserId;
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, timezone; // try to fetch client region info first
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
- } // Send the user activation request to the **License** service.
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
- }) // On success, return the **License** user object.
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
- }) // On failure, reject with error from **License**.
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
- email = _ref7.email,
577
- token = _ref7.token,
578
- forceRefresh = _ref7.forceRefresh;
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
- idbroker = _this$list.idbroker,
606
- identity = _this$list.identity;
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
- authorizationString = _this$webex$config$cr.authorizationString,
611
- authorizeUrl = _this$webex$config$cr.authorizeUrl; // This must be set outside of the setConfig method used to assign the
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
- _ref8$timeout = _ref8.timeout,
674
- timeout = _ref8$timeout === void 0 ? 5 : _ref8$timeout,
675
- url = _ref8.url;
676
- var services = this.webex.config.services; // Save memory by grabbing the catalog after there isn't a priortyURL
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
- (_serviceItem$hosts = serviceItem.hosts).push.apply(_serviceItem$hosts, [// map the default key as a low priority default for cluster matching
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
- }, []); // append service links that do not exist in the host catalog
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
- }); // update all the service urls in the host catalog
709
+ });
801
710
 
802
- this._updateServiceUrls(serviceHostmap.serviceLinks);
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
- from = _ref9.from,
922
- query = _ref9.query,
923
- token = _ref9.token,
924
- forceRefresh = _ref9.forceRefresh;
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
- services = _this$webex$config.services,
967
- fedramp = _this$webex$config.fedramp; // Validate that the services configuration exists.
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
- } // Check for discovery services.
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
- }); // Inject formatted discovery services into services catalog.
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
- }); // Inject formatted override services into services catalog.
879
+ });
995
880
 
881
+ // Inject formatted override services into services catalog.
996
882
  catalog.updateServiceUrls('override', formattedOverrideServices);
997
- } // Check for allowed host domains.
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
- } // Set `validateDomains` property to match configuration
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
- this.logger.info('services: initializing initial service catalogs'); // Destructure the credentials plugin.
904
+ // Destructure the credentials plugin.
905
+ var credentials = this.webex.credentials;
1019
906
 
1020
- var credentials = this.webex.credentials; // Init a promise chain. Must be done as a Promise.resolve() to allow
907
+ // Init a promise chain. Must be done as a Promise.resolve() to allow
1021
908
  // credentials#getOrgId() to properly throw.
1022
-
1023
- return _promise.default.resolve() // Get the user's OrgId.
909
+ return _promise.default.resolve()
910
+ // Get the user's OrgId.
1024
911
  .then(function () {
1025
912
  return credentials.getOrgId();
1026
- }) // Begin collecting the preauth/limited catalog.
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
- } // Return a resolved promise for consistent return value.
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); // Listen for configuration changes once.
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
- }); // wait for webex instance to be ready before attempting
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; // Validate if the supertoken exists.
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.2"
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