@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
@@ -55,7 +55,7 @@ const Token = WebexPlugin.extend({
55
55
  deps: ['access_token', 'isExpired'],
56
56
  fn() {
57
57
  return !!this.access_token && !this.isExpired;
58
- }
58
+ },
59
59
  },
60
60
 
61
61
  /**
@@ -76,7 +76,7 @@ const Token = WebexPlugin.extend({
76
76
  deps: ['canAuthorize'],
77
77
  fn() {
78
78
  return this.canAuthorize && !!this.config.client_id;
79
- }
79
+ },
80
80
  },
81
81
 
82
82
  /**
@@ -101,7 +101,7 @@ const Token = WebexPlugin.extend({
101
101
  }
102
102
 
103
103
  return !!this.refresh_token && !!this.config.client_secret;
104
- }
104
+ },
105
105
  },
106
106
 
107
107
  /**
@@ -118,7 +118,7 @@ const Token = WebexPlugin.extend({
118
118
  // in order to avoid setting `cache:false`, we'll use a private property
119
119
  // and a timer rather than comparing to `Date.now()`;
120
120
  return !!this.expires && this._isExpired;
121
- }
121
+ },
122
122
  },
123
123
 
124
124
  /**
@@ -137,8 +137,8 @@ const Token = WebexPlugin.extend({
137
137
  }
138
138
 
139
139
  return `${this.token_type} ${this.access_token}`;
140
- }
141
- }
140
+ },
141
+ },
142
142
  },
143
143
 
144
144
  namespace: 'Credentials',
@@ -196,8 +196,8 @@ const Token = WebexPlugin.extend({
196
196
  */
197
197
  token_type: {
198
198
  default: 'Bearer',
199
- type: 'string'
200
- }
199
+ type: 'string',
200
+ },
201
201
  },
202
202
 
203
203
  session: {
@@ -210,7 +210,7 @@ const Token = WebexPlugin.extend({
210
210
  */
211
211
  _isExpired: {
212
212
  default: false,
213
- type: 'boolean'
213
+ type: 'boolean',
214
214
  },
215
215
  /**
216
216
  * Handle to the previous token that we'll revoke when we refresh this
@@ -224,14 +224,14 @@ const Token = WebexPlugin.extend({
224
224
  * @type {Object}
225
225
  */
226
226
  previousToken: {
227
- type: 'state'
228
- }
227
+ type: 'state',
228
+ },
229
229
  },
230
230
 
231
231
  @oneFlight({
232
232
  keyFactory(scope) {
233
233
  return scope;
234
- }
234
+ },
235
235
  })
236
236
  /**
237
237
  * Uses this token to request a new Token with a subset of this Token's scopes
@@ -252,8 +252,7 @@ const Token = WebexPlugin.extend({
252
252
  if (!this.canDownscope) {
253
253
  if (this.config.client_id) {
254
254
  this.logger.info('token: request received to downscope invalid access_token');
255
- }
256
- else {
255
+ } else {
257
256
  this.logger.trace('token: cannot downscope without client_id');
258
257
  }
259
258
 
@@ -273,18 +272,19 @@ const Token = WebexPlugin.extend({
273
272
  return Promise.reject(new Error('token: scope reduction requires a reduced scope'));
274
273
  }
275
274
 
276
- return this.webex.request({
277
- method: 'POST',
278
- uri: this.config.tokenUrl,
279
- addAuthHeader: false,
280
- form: {
281
- grant_type: 'urn:cisco:oauth:grant-type:scope-reduction',
282
- token: this.access_token,
283
- scope,
284
- client_id: this.config.client_id,
285
- self_contained_token: true
286
- }
287
- })
275
+ return this.webex
276
+ .request({
277
+ method: 'POST',
278
+ uri: this.config.tokenUrl,
279
+ addAuthHeader: false,
280
+ form: {
281
+ grant_type: 'urn:cisco:oauth:grant-type:scope-reduction',
282
+ token: this.access_token,
283
+ scope,
284
+ client_id: this.config.client_id,
285
+ self_contained_token: true,
286
+ },
287
+ })
288
288
  .then((res) => {
289
289
  this.logger.info(`token: downscoped token to ${scope}`);
290
290
 
@@ -317,8 +317,7 @@ const Token = WebexPlugin.extend({
317
317
  if (this.expires) {
318
318
  if (this.expires < Date.now()) {
319
319
  this._isExpired = true;
320
- }
321
- else {
320
+ } else {
322
321
  safeSetTimeout(() => {
323
322
  this._isExpired = true;
324
323
  }, this.expires - Date.now());
@@ -349,22 +348,26 @@ const Token = WebexPlugin.extend({
349
348
  promise = Promise.resolve(this.config.refreshCallback(this.webex, this));
350
349
  }
351
350
 
352
- return (promise || this.webex.request({
353
- method: 'POST',
354
- uri: this.config.tokenUrl,
355
- form: {
356
- grant_type: 'refresh_token',
357
- redirect_uri: this.config.redirect_uri,
358
- refresh_token: this.refresh_token
359
- },
360
- auth: {
361
- user: this.config.client_id,
362
- pass: this.config.client_secret,
363
- sendImmediately: true
364
- },
365
- shouldRefreshAccessToken: false
366
- })
367
- .then((res) => res.body))
351
+ return (
352
+ promise ||
353
+ this.webex
354
+ .request({
355
+ method: 'POST',
356
+ uri: this.config.tokenUrl,
357
+ form: {
358
+ grant_type: 'refresh_token',
359
+ redirect_uri: this.config.redirect_uri,
360
+ refresh_token: this.refresh_token,
361
+ },
362
+ auth: {
363
+ user: this.config.client_id,
364
+ pass: this.config.client_secret,
365
+ sendImmediately: true,
366
+ },
367
+ shouldRefreshAccessToken: false,
368
+ })
369
+ .then((res) => res.body)
370
+ )
368
371
  .then((obj) => {
369
372
  if (!obj) {
370
373
  throw new Error('token: refreshCallback() did not produce an object');
@@ -373,7 +376,10 @@ const Token = WebexPlugin.extend({
373
376
  // the current refresh token and related values to the response (note:
374
377
  // at time of implementation, CI never sends a new refresh token)
375
378
  if (!obj.refresh_token) {
376
- Object.assign(obj, pick(this, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in'));
379
+ Object.assign(
380
+ obj,
381
+ pick(this, 'refresh_token', 'refresh_token_expires', 'refresh_token_expires_in')
382
+ );
377
383
  }
378
384
 
379
385
  // If the new token is the same as the previous token, then we may have
@@ -436,27 +442,23 @@ const Token = WebexPlugin.extend({
436
442
 
437
443
  this.logger.info('token: revoking access token');
438
444
 
439
- return this.webex.request({
440
- method: 'POST',
441
- uri: this.config.revokeUrl,
442
- form: {
443
- token: this.access_token,
444
- token_type_hint: 'access_token'
445
- },
446
- auth: {
447
- user: this.config.client_id,
448
- pass: this.config.client_secret,
449
- sendImmediately: true
450
- },
451
- shouldRefreshAccessToken: false
452
- })
445
+ return this.webex
446
+ .request({
447
+ method: 'POST',
448
+ uri: this.config.revokeUrl,
449
+ form: {
450
+ token: this.access_token,
451
+ token_type_hint: 'access_token',
452
+ },
453
+ auth: {
454
+ user: this.config.client_id,
455
+ pass: this.config.client_secret,
456
+ sendImmediately: true,
457
+ },
458
+ shouldRefreshAccessToken: false,
459
+ })
453
460
  .then(() => {
454
- this.unset([
455
- 'access_token',
456
- 'expires',
457
- 'expires_in',
458
- 'token_type'
459
- ]);
461
+ this.unset(['access_token', 'expires', 'expires_in', 'token_type']);
460
462
  this.logger.info('token: access token revoked');
461
463
  })
462
464
  .catch(processGrantError);
@@ -469,7 +471,7 @@ const Token = WebexPlugin.extend({
469
471
  if (!attrs.token_type && attrs.access_token && attrs.access_token.includes(' ')) {
470
472
  const [token_type, access_token] = attrs.access_token.split(' ');
471
473
 
472
- attrs = Object.assign({}, attrs, {access_token, token_type});
474
+ attrs = {...attrs, access_token, token_type};
473
475
  }
474
476
  const now = Date.now();
475
477
 
@@ -516,38 +518,42 @@ const Token = WebexPlugin.extend({
516
518
  throw new Error('Token#validate() must not be used in production');
517
519
  }
518
520
 
519
- return this.webex.request({
520
- method: 'POST',
521
- service: 'conversation',
522
- resource: 'users/validateAuthToken',
523
- body: {
524
- token: this.access_token
525
- }
526
- })
521
+ return this.webex
522
+ .request({
523
+ method: 'POST',
524
+ service: 'conversation',
525
+ resource: 'users/validateAuthToken',
526
+ body: {
527
+ token: this.access_token,
528
+ },
529
+ })
527
530
  .catch((reason) => {
528
531
  if ('statusCode' in reason) {
529
532
  return Promise.reject(reason);
530
533
  }
531
- this.logger.info('REMINDER: If you\'re investigating a network error here, it\'s normal');
534
+ this.logger.info("REMINDER: If you're investigating a network error here, it's normal");
532
535
 
533
536
  // If we got an error that isn't a WebexHttpError, assume the problem is
534
537
  // that we don't have the wdm plugin loaded and service/resource isn't
535
538
  // a valid means of identifying a request.
536
- const convApi = process.env.CONVERSATION_SERVICE || process.env.CONVERSATION_SERVICE_URL || 'https://conv-a.wbx2.com/conversation/api/v1';
539
+ const convApi =
540
+ process.env.CONVERSATION_SERVICE ||
541
+ process.env.CONVERSATION_SERVICE_URL ||
542
+ 'https://conv-a.wbx2.com/conversation/api/v1';
537
543
 
538
544
  return this.webex.request({
539
545
  method: 'POST',
540
546
  uri: `${convApi}/users/validateAuthToken`,
541
547
  body: {
542
- token: this.access_token
548
+ token: this.access_token,
543
549
  },
544
550
  headers: {
545
- authorization: `Bearer ${this.access_token}`
546
- }
551
+ authorization: `Bearer ${this.access_token}`,
552
+ },
547
553
  });
548
554
  })
549
555
  .then((res) => res.body);
550
- }
556
+ },
551
557
  });
552
558
 
553
559
  export default Token;
package/src/lib/page.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-constructor-return */
2
+
1
3
  /*!
2
4
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
5
  */
@@ -69,12 +71,8 @@ export default class Page {
69
71
 
70
72
  return linkHeaders.reduce((links, linkHeader) => {
71
73
  linkHeader = linkHeader.split(';');
72
- const link = linkHeader[0]
73
- .replace('<', '')
74
- .replace('>', '');
75
- const rel = linkHeader[1]
76
- .split('=')[1]
77
- .replace(/"/g, '');
74
+ const link = linkHeader[0].replace('<', '').replace('>', '');
75
+ const rel = linkHeader[1].split('=')[1].replace(/"/g, '');
78
76
 
79
77
  links[rel] = link;
80
78
 
@@ -121,9 +119,10 @@ export default class Page {
121
119
  * @returns {Promise<Page>}
122
120
  */
123
121
  getLink(link) {
124
- return this.webex.request({
125
- uri: this.links[link]
126
- })
122
+ return this.webex
123
+ .request({
124
+ uri: this.links[link],
125
+ })
127
126
  .then((res) => new Page(res, this.webex));
128
127
  }
129
128
 
@@ -149,12 +148,12 @@ export default class Page {
149
148
  i += 1;
150
149
  if (i < this.length) {
151
150
  return {
152
- value: this.items[i]
151
+ value: this.items[i],
153
152
  };
154
153
  }
155
154
 
156
155
  return {done: true};
157
- }
156
+ },
158
157
  };
159
158
  }
160
159
  }
@@ -1,19 +1,9 @@
1
1
  const NAMESPACE = 'services';
2
- const SERVICE_CATALOGS = [
3
- 'discovery',
4
- 'limited',
5
- 'signin',
6
- 'postauth',
7
- 'custom'
8
- ];
2
+ const SERVICE_CATALOGS = ['discovery', 'limited', 'signin', 'postauth', 'custom'];
9
3
 
10
4
  const SERVICE_CATALOGS_ENUM_TYPES = {
11
5
  STRING: 'SERVICE_CATALOGS_ENUM_TYPES_STRING',
12
- NUMBER: 'SERVICE_CATALOGS_ENUM_TYPES_NUMBER'
6
+ NUMBER: 'SERVICE_CATALOGS_ENUM_TYPES_NUMBER',
13
7
  };
14
8
 
15
- export {
16
- SERVICE_CATALOGS_ENUM_TYPES,
17
- NAMESPACE,
18
- SERVICE_CATALOGS
19
- };
9
+ export {SERVICE_CATALOGS_ENUM_TYPES, NAMESPACE, SERVICE_CATALOGS};
@@ -11,8 +11,8 @@ import ServiceInterceptor from './interceptors/service';
11
11
  registerInternalPlugin('services', Services, {
12
12
  interceptors: {
13
13
  ServiceInterceptor: ServiceInterceptor.create,
14
- ServerErrorInterceptor: ServerErrorInterceptor.create
15
- }
14
+ ServerErrorInterceptor: ServerErrorInterceptor.create,
15
+ },
16
16
  });
17
17
 
18
18
  export {constants};
@@ -9,14 +9,13 @@ import {WebexHttpError} from '@webex/webex-core';
9
9
  */
10
10
  export default class ServerErrorInterceptor extends Interceptor {
11
11
  /**
12
- * @returns {HAMessagingInterceptor}
13
- */
12
+ * @returns {HAMessagingInterceptor}
13
+ */
14
14
  static create() {
15
15
  // eslint-disable-next-line no-invalid-this
16
16
  return new ServerErrorInterceptor({webex: this});
17
17
  }
18
18
 
19
-
20
19
  /**
21
20
  * @see Interceptor#onResponseError
22
21
  * @param {Object} options
@@ -24,17 +23,23 @@ export default class ServerErrorInterceptor extends Interceptor {
24
23
  * @returns {Object}
25
24
  */
26
25
  onResponseError(options, reason) {
27
- if ((reason instanceof WebexHttpError.InternalServerError || reason instanceof WebexHttpError.BadGateway || reason instanceof WebexHttpError.ServiceUnavailable) && options.uri) {
26
+ if (
27
+ (reason instanceof WebexHttpError.InternalServerError ||
28
+ reason instanceof WebexHttpError.BadGateway ||
29
+ reason instanceof WebexHttpError.ServiceUnavailable) &&
30
+ options.uri
31
+ ) {
28
32
  const feature = this.webex.internal.device.features.developer.get('web-high-availability');
29
33
 
30
34
  if (feature && feature.value) {
31
35
  this.webex.internal.metrics.submitClientMetrics('web-ha', {
32
36
  fields: {success: false},
33
- tags: {action: 'failed', error: reason.message, url: options.uri}
37
+ tags: {action: 'failed', error: reason.message, url: options.uri},
34
38
  });
35
39
 
36
- return Promise.resolve(this.webex.internal.services.markFailedUrl(options.uri))
37
- .then(() => Promise.reject(reason));
40
+ return Promise.resolve(this.webex.internal.services.markFailedUrl(options.uri)).then(() =>
41
+ Promise.reject(reason)
42
+ );
38
43
  }
39
44
  }
40
45
 
@@ -39,16 +39,17 @@ export default class ServiceInterceptor extends Interceptor {
39
39
  const {service, resource} = options;
40
40
 
41
41
  // Attempt to collect the service url.
42
- return services.waitForService({name: service})
42
+ return services
43
+ .waitForService({name: service})
43
44
  .then((serviceUrl) => {
44
45
  // Generate the combined service url and resource.
45
46
  options.uri = this.generateUri(serviceUrl, resource);
46
47
 
47
48
  return options;
48
49
  })
49
- .catch(() => Promise.reject(new Error(
50
- `service-interceptor: '${service}' is not a known service`
51
- )));
50
+ .catch(() =>
51
+ Promise.reject(new Error(`service-interceptor: '${service}' is not a known service`))
52
+ );
52
53
  }
53
54
 
54
55
  /* eslint-disable class-methods-use-this */
@@ -93,7 +94,7 @@ export default class ServiceInterceptor extends Interceptor {
93
94
  }
94
95
 
95
96
  if (!options.service) {
96
- throw new Error('a valid \'service\' parameter is required');
97
+ throw new Error("a valid 'service' parameter is required");
97
98
  }
98
99
  }
99
100
  /* eslint-enable class-methods-use-this, no-param-reassign */
@@ -1,4 +1,4 @@
1
1
  // Metrics for service catalog
2
2
  export default {
3
- JS_SDK_SERVICE_NOT_FOUND: 'JS_SDK_SERVICE_NOT_FOUND'
3
+ JS_SDK_SERVICE_NOT_FOUND: 'JS_SDK_SERVICE_NOT_FOUND',
4
4
  };