@webex/internal-plugin-mercury 2.60.0-next.8 → 2.60.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"names":["_ws","_interopRequireDefault","require","_socketBase","Socket","getWebSocketConstructor","WS","_default","exports","default"],"sources":["socket.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport WS from 'ws';\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n return WS;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAIA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMAE,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE,OAAOC,WAAE;AACX,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaL,mBAAM"}
1
+ {"version":3,"names":["_ws","_interopRequireDefault","require","_socketBase","Socket","getWebSocketConstructor","WS","_default","exports","default"],"sources":["socket.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport WS from 'ws';\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n return WS;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAIA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMAE,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE,OAAOC,WAAE;AACX,CAAC;AAAC,IAAAC,QAAA,GAEaH,mBAAM;AAAAI,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -32,5 +32,6 @@ _socketBase.default.getWebSocketConstructor = function getWebSocketConstructor()
32
32
  }
33
33
  return ws;
34
34
  };
35
- var _default = exports.default = _socketBase.default;
35
+ var _default = _socketBase.default;
36
+ exports.default = _default;
36
37
  //# sourceMappingURL=socket.shim.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_socketBase","_interopRequireDefault","require","Socket","getWebSocketConstructor","ws","WebSocket","MozWebSocket","global","window","self","_default","exports","default"],"sources":["socket.shim.js"],"sourcesContent":["/* eslint-disable no-restricted-globals */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n // Grabed from https://github.com/heineiuo/isomorphic-ws/blob/9b977394ac875638c045fd9cf774ed418484b394/browser.js\n let ws;\n\n if (typeof WebSocket !== 'undefined') {\n ws = WebSocket;\n } else if (typeof MozWebSocket !== 'undefined') {\n // eslint-disable-next-line no-undef\n ws = MozWebSocket;\n } else if (typeof global !== 'undefined') {\n ws = global.WebSocket || global.MozWebSocket;\n } else if (typeof window !== 'undefined') {\n ws = window.WebSocket || window.MozWebSocket;\n } else if (typeof self !== 'undefined') {\n ws = self.WebSocket || self.MozWebSocket;\n }\n\n return ws;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAQA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AARA;;AAEA;AACA;AACA;;AAEA;;AAIAC,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE;EACA,IAAIC,EAAE;EAEN,IAAI,OAAOC,SAAS,KAAK,WAAW,EAAE;IACpCD,EAAE,GAAGC,SAAS;EAChB,CAAC,MAAM,IAAI,OAAOC,YAAY,KAAK,WAAW,EAAE;IAC9C;IACAF,EAAE,GAAGE,YAAY;EACnB,CAAC,MAAM,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACxCH,EAAE,GAAGG,MAAM,CAACF,SAAS,IAAIE,MAAM,CAACD,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOE,MAAM,KAAK,WAAW,EAAE;IACxCJ,EAAE,GAAGI,MAAM,CAACH,SAAS,IAAIG,MAAM,CAACF,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOG,IAAI,KAAK,WAAW,EAAE;IACtCL,EAAE,GAAGK,IAAI,CAACJ,SAAS,IAAII,IAAI,CAACH,YAAY;EAC1C;EAEA,OAAOF,EAAE;AACX,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,mBAAM"}
1
+ {"version":3,"names":["_socketBase","_interopRequireDefault","require","Socket","getWebSocketConstructor","ws","WebSocket","MozWebSocket","global","window","self","_default","exports","default"],"sources":["socket.shim.js"],"sourcesContent":["/* eslint-disable no-restricted-globals */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n // Grabed from https://github.com/heineiuo/isomorphic-ws/blob/9b977394ac875638c045fd9cf774ed418484b394/browser.js\n let ws;\n\n if (typeof WebSocket !== 'undefined') {\n ws = WebSocket;\n } else if (typeof MozWebSocket !== 'undefined') {\n // eslint-disable-next-line no-undef\n ws = MozWebSocket;\n } else if (typeof global !== 'undefined') {\n ws = global.WebSocket || global.MozWebSocket;\n } else if (typeof window !== 'undefined') {\n ws = window.WebSocket || window.MozWebSocket;\n } else if (typeof self !== 'undefined') {\n ws = self.WebSocket || self.MozWebSocket;\n }\n\n return ws;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAQA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AARA;;AAEA;AACA;AACA;;AAEA;;AAIAC,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE;EACA,IAAIC,EAAE;EAEN,IAAI,OAAOC,SAAS,KAAK,WAAW,EAAE;IACpCD,EAAE,GAAGC,SAAS;EAChB,CAAC,MAAM,IAAI,OAAOC,YAAY,KAAK,WAAW,EAAE;IAC9C;IACAF,EAAE,GAAGE,YAAY;EACnB,CAAC,MAAM,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACxCH,EAAE,GAAGG,MAAM,CAACF,SAAS,IAAIE,MAAM,CAACD,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOE,MAAM,KAAK,WAAW,EAAE;IACxCJ,EAAE,GAAGI,MAAM,CAACH,SAAS,IAAIG,MAAM,CAACF,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOG,IAAI,KAAK,WAAW,EAAE;IACtCL,EAAE,GAAGK,IAAI,CAACJ,SAAS,IAAII,IAAI,CAACH,YAAY;EAC1C;EAEA,OAAOF,EAAE;AACX,CAAC;AAAC,IAAAM,QAAA,GAEaR,mBAAM;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-mercury",
3
+ "version": "2.60.1",
3
4
  "description": "",
4
5
  "license": "MIT",
5
6
  "main": "dist/index.js",
@@ -10,7 +11,7 @@
10
11
  "directory": "packages/@webex/internal-plugin-mercury"
11
12
  },
12
13
  "engines": {
13
- "node": ">=16"
14
+ "node": ">=14"
14
15
  },
15
16
  "browser": {
16
17
  "./dist/socket/socket.js": "./dist/socket/socket.shim.js",
@@ -25,31 +26,31 @@
25
26
  "devDependencies": {
26
27
  "@babel/core": "^7.17.10",
27
28
  "@sinonjs/fake-timers": "^6.0.1",
28
- "@webex/babel-config-legacy": "0.0.0",
29
- "@webex/eslint-config-legacy": "0.0.0",
30
- "@webex/jest-config-legacy": "0.0.0",
31
- "@webex/legacy-tools": "0.0.0",
32
- "@webex/test-helper-chai": "2.60.0-next.8",
33
- "@webex/test-helper-mocha": "2.60.0-next.8",
34
- "@webex/test-helper-mock-webex": "2.60.0-next.8",
35
- "@webex/test-helper-test-users": "2.60.0-next.8",
29
+ "@webex/babel-config-legacy": "2.60.1",
30
+ "@webex/eslint-config-legacy": "2.60.1",
31
+ "@webex/jest-config-legacy": "2.60.1",
32
+ "@webex/legacy-tools": "2.60.1",
33
+ "@webex/test-helper-chai": "2.60.1",
34
+ "@webex/test-helper-mocha": "2.60.1",
35
+ "@webex/test-helper-mock-webex": "2.60.1",
36
+ "@webex/test-helper-test-users": "2.60.1",
36
37
  "eslint": "^8.24.0",
37
38
  "prettier": "^2.7.1",
38
39
  "sinon": "^9.2.4"
39
40
  },
40
41
  "dependencies": {
41
- "@webex/common": "2.60.0-next.8",
42
- "@webex/common-timers": "2.60.0-next.8",
43
- "@webex/internal-plugin-device": "2.60.0-next.8",
44
- "@webex/internal-plugin-feature": "2.60.0-next.8",
45
- "@webex/internal-plugin-metrics": "2.60.0-next.8",
46
- "@webex/test-helper-chai": "2.60.0-next.8",
47
- "@webex/test-helper-mocha": "2.60.0-next.8",
48
- "@webex/test-helper-mock-web-socket": "2.60.0-next.8",
49
- "@webex/test-helper-mock-webex": "2.60.0-next.8",
50
- "@webex/test-helper-refresh-callback": "2.60.0-next.8",
51
- "@webex/test-helper-test-users": "2.60.0-next.8",
52
- "@webex/webex-core": "2.60.0-next.8",
42
+ "@webex/common": "2.60.1",
43
+ "@webex/common-timers": "2.60.1",
44
+ "@webex/internal-plugin-device": "2.60.1",
45
+ "@webex/internal-plugin-feature": "2.60.1",
46
+ "@webex/internal-plugin-metrics": "2.60.1",
47
+ "@webex/test-helper-chai": "2.60.1",
48
+ "@webex/test-helper-mocha": "2.60.1",
49
+ "@webex/test-helper-mock-web-socket": "2.60.1",
50
+ "@webex/test-helper-mock-webex": "2.60.1",
51
+ "@webex/test-helper-refresh-callback": "2.60.1",
52
+ "@webex/test-helper-test-users": "2.60.1",
53
+ "@webex/webex-core": "2.60.1",
53
54
  "backoff": "^2.5.0",
54
55
  "lodash": "^4.17.21",
55
56
  "uuid": "^3.3.2",
@@ -58,12 +59,10 @@
58
59
  "scripts": {
59
60
  "build": "yarn build:src",
60
61
  "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
61
- "deploy:npm": "yarn npm publish",
62
62
  "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
63
63
  "test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
64
64
  "test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
65
65
  "test:style": "eslint ./src/**/*.*",
66
66
  "test:unit": "webex-legacy-tools test --unit --runner jest"
67
- },
68
- "version": "2.60.0-next.8"
69
- }
67
+ }
68
+ }
package/src/mercury.js CHANGED
@@ -49,7 +49,7 @@ const Mercury = WebexPlugin.extend({
49
49
  @oneFlight
50
50
  connect(webSocketUrl) {
51
51
  if (this.connected) {
52
- this.logger.info(`${this.namespace}: already connected, will not connect again`);
52
+ this.logger.info('mercury: already connected, will not connect again');
53
53
 
54
54
  return Promise.resolve();
55
55
  }
@@ -59,7 +59,7 @@ const Mercury = WebexPlugin.extend({
59
59
  return Promise.resolve(
60
60
  this.webex.internal.device.registered || this.webex.internal.device.register()
61
61
  ).then(() => {
62
- this.logger.info(`${this.namespace}: connecting`);
62
+ this.logger.info('mercury: connecting');
63
63
 
64
64
  return this._connectWithBackoff(webSocketUrl);
65
65
  });
@@ -69,14 +69,16 @@ const Mercury = WebexPlugin.extend({
69
69
  disconnect() {
70
70
  return new Promise((resolve) => {
71
71
  if (this.backoffCall) {
72
- this.logger.info(`${this.namespace}: aborting connection`);
72
+ this.logger.info('mercury: aborting connection');
73
73
  this.backoffCall.abort();
74
74
  }
75
75
 
76
76
  if (this.socket) {
77
77
  this.socket.removeAllListeners('message');
78
78
  this.once('offline', resolve);
79
- resolve(this.socket.close());
79
+ this.socket.close();
80
+
81
+ return;
80
82
  }
81
83
 
82
84
  resolve();
@@ -163,7 +165,7 @@ const Mercury = WebexPlugin.extend({
163
165
  Promise.all([this._prepareUrl(socketUrl), this.webex.credentials.getUserToken()])
164
166
  .then(([webSocketUrl, token]) => {
165
167
  if (!this.backoffCall) {
166
- const msg = `${this.namespace}: prevent socket open when backoffCall no longer defined`;
168
+ const msg = 'mercury: prevent socket open when backoffCall no longer defined';
167
169
 
168
170
  this.logger.info(msg);
169
171
 
@@ -183,7 +185,7 @@ const Mercury = WebexPlugin.extend({
183
185
 
184
186
  // if the consumer has supplied request options use them
185
187
  if (this.webex.config.defaultMercuryOptions) {
186
- this.logger.info(`${this.namespace}: setting custom options`);
188
+ this.logger.info('mercury: setting custom options');
187
189
  options = {...options, ...this.webex.config.defaultMercuryOptions};
188
190
  }
189
191
 
@@ -191,8 +193,6 @@ const Mercury = WebexPlugin.extend({
191
193
  // the socket if it is in the process of being opened.
192
194
  this.socket = socket;
193
195
 
194
- this.logger.info(`${this.namespace} connection url: ${webSocketUrl}`);
195
-
196
196
  return socket.open(webSocketUrl, options);
197
197
  })
198
198
  .then(() => {
@@ -201,7 +201,6 @@ const Mercury = WebexPlugin.extend({
201
201
  success: true,
202
202
  },
203
203
  tags: {
204
- namespace: this.namespace,
205
204
  action: 'connected',
206
205
  url: attemptWSUrl,
207
206
  },
@@ -226,19 +225,19 @@ const Mercury = WebexPlugin.extend({
226
225
  if (reason.code !== 1006 && this.backoffCall && this.backoffCall.getNumRetries() > 0) {
227
226
  this._emit('connection_failed', reason, {retries: this.backoffCall.getNumRetries()});
228
227
  }
229
- this.logger.info(`${this.namespace}: connection attempt failed`, reason);
228
+ this.logger.info('mercury: connection attempt failed', reason);
230
229
  // UnknownResponse is produced by IE for any 4XXX; treated it like a bad
231
230
  // web socket url and let WDM handle the token checking
232
231
  if (reason instanceof UnknownResponse) {
233
232
  this.logger.info(
234
- `${this.namespace}: received unknown response code, refreshing device registration`
233
+ 'mercury: received unknown response code, refreshing device registration'
235
234
  );
236
235
 
237
236
  return this.webex.internal.device.refresh().then(() => callback(reason));
238
237
  }
239
238
  // NotAuthorized implies expired token
240
239
  if (reason instanceof NotAuthorized) {
241
- this.logger.info(`${this.namespace}: received authorization error, reauthorizing`);
240
+ this.logger.info('mercury: received authorization error, reauthorizing');
242
241
 
243
242
  return this.webex.credentials.refresh({force: true}).then(() => callback(reason));
244
243
  }
@@ -251,7 +250,7 @@ const Mercury = WebexPlugin.extend({
251
250
  // BadRequest implies current credentials are for a Service Account
252
251
  // Forbidden implies current user is not entitle for Webex
253
252
  if (reason instanceof BadRequest || reason instanceof Forbidden) {
254
- this.logger.warn(`${this.namespace}: received unrecoverable response from mercury`);
253
+ this.logger.warn('mercury: received unrecoverable response from mercury');
255
254
  this.backoffCall.abort();
256
255
 
257
256
  return callback(reason);
@@ -262,14 +261,13 @@ const Mercury = WebexPlugin.extend({
262
261
  .then((haMessagingEnabled) => {
263
262
  if (haMessagingEnabled) {
264
263
  this.logger.info(
265
- `${this.namespace}: received a generic connection error, will try to connect to another datacenter`
264
+ 'mercury: received a generic connection error, will try to connect to another datacenter'
266
265
  );
267
266
  this.webex.internal.metrics.submitClientMetrics('web-ha-mercury', {
268
267
  fields: {
269
268
  success: false,
270
269
  },
271
270
  tags: {
272
- namespace: this.namespace,
273
271
  action: 'failed',
274
272
  error: reason.message,
275
273
  url: attemptWSUrl,
@@ -287,7 +285,7 @@ const Mercury = WebexPlugin.extend({
287
285
  return callback(reason);
288
286
  })
289
287
  .catch((reason) => {
290
- this.logger.error(`${this.namespace}: failed to handle connection failure`, reason);
288
+ this.logger.error('mercury: failed to handle connection failure', reason);
291
289
  callback(reason);
292
290
  });
293
291
  },
@@ -303,9 +301,7 @@ const Mercury = WebexPlugin.extend({
303
301
  this.backoffCall = undefined;
304
302
  if (err) {
305
303
  this.logger.info(
306
- `${
307
- this.namespace
308
- }: failed to connect after ${call.getNumRetries()} retries; log statement about next retry was inaccurate; ${err}`
304
+ `mercury: failed to connect after ${call.getNumRetries()} retries; log statement about next retry was inaccurate; ${err}`
309
305
  );
310
306
 
311
307
  return reject(err);
@@ -318,7 +314,7 @@ const Mercury = WebexPlugin.extend({
318
314
 
319
315
  // eslint-disable-next-line prefer-reflect
320
316
  call = backoff.call((callback) => {
321
- this.logger.info(`${this.namespace}: executing connection attempt ${call.getNumRetries()}`);
317
+ this.logger.info(`mercury: executing connection attempt ${call.getNumRetries()}`);
322
318
  this._attemptConnection(webSocketUrl, callback);
323
319
  }, onComplete);
324
320
 
@@ -334,7 +330,7 @@ const Mercury = WebexPlugin.extend({
334
330
  }
335
331
 
336
332
  call.on('abort', () => {
337
- this.logger.info(`${this.namespace}: connection aborted`);
333
+ this.logger.info('mercury: connection aborted');
338
334
  reject(new Error('Mercury Connection Aborted'));
339
335
  });
340
336
 
@@ -344,16 +340,16 @@ const Mercury = WebexPlugin.extend({
344
340
  const delay = Math.min(call.strategy_.nextBackoffDelay_, this.config.backoffTimeMax);
345
341
 
346
342
  this.logger.info(
347
- `${this.namespace}: failed to connect; attempting retry ${number + 1} in ${delay} ms`
343
+ `mercury: failed to connect; attempting retry ${number + 1} in ${delay} ms`
348
344
  );
349
345
  /* istanbul ignore if */
350
346
  if (process.env.NODE_ENV === 'development') {
351
- this.logger.debug(`${this.namespace}: `, err, err.stack);
347
+ this.logger.debug('mercury: ', err, err.stack);
352
348
  }
353
349
 
354
350
  return;
355
351
  }
356
- this.logger.info(`${this.namespace}: connected`);
352
+ this.logger.info('mercury: connected');
357
353
  });
358
354
 
359
355
  call.start();
@@ -366,10 +362,7 @@ const Mercury = WebexPlugin.extend({
366
362
  try {
367
363
  this.trigger(...args);
368
364
  } catch (error) {
369
- this.logger.error(`${this.namespace}: error occurred in event handler`, {
370
- error,
371
- arguments: args,
372
- });
365
+ this.logger.error('mercury: error occurred in event handler', error);
373
366
  }
374
367
  },
375
368
 
@@ -410,20 +403,20 @@ const Mercury = WebexPlugin.extend({
410
403
  case 1003:
411
404
  // metric: disconnect
412
405
  this.logger.info(
413
- `${this.namespace}: Mercury service rejected last message; will not reconnect: ${event.reason}`
406
+ `mercury: Mercury service rejected last message; will not reconnect: ${event.reason}`
414
407
  );
415
408
  this._emit('offline.permanent', event);
416
409
  break;
417
410
  case 4000:
418
411
  // metric: disconnect
419
- this.logger.info(`${this.namespace}: socket replaced; will not reconnect`);
412
+ this.logger.info('mercury: socket replaced; will not reconnect');
420
413
  this._emit('offline.replaced', event);
421
414
  break;
422
415
  case 1001:
423
416
  case 1005:
424
417
  case 1006:
425
418
  case 1011:
426
- this.logger.info(`${this.namespace}: socket disconnected; reconnecting`);
419
+ this.logger.info('mercury: socket disconnected; reconnecting');
427
420
  this._emit('offline.transient', event);
428
421
  this._reconnect(socketUrl);
429
422
  // metric: disconnect
@@ -431,25 +424,23 @@ const Mercury = WebexPlugin.extend({
431
424
  break;
432
425
  case 1000:
433
426
  if (normalReconnectReasons.includes(reason)) {
434
- this.logger.info(`${this.namespace}: socket disconnected; reconnecting`);
427
+ this.logger.info('mercury: socket disconnected; reconnecting');
435
428
  this._emit('offline.transient', event);
436
429
  this._reconnect(socketUrl);
437
430
  // metric: disconnect
438
431
  // if (reason === done forced) metric: force closure
439
432
  } else {
440
- this.logger.info(`${this.namespace}: socket disconnected; will not reconnect`);
433
+ this.logger.info('mercury: socket disconnected; will not reconnect');
441
434
  this._emit('offline.permanent', event);
442
435
  }
443
436
  break;
444
437
  default:
445
- this.logger.info(
446
- `${this.namespace}: socket disconnected unexpectedly; will not reconnect`
447
- );
438
+ this.logger.info('mercury: socket disconnected unexpectedly; will not reconnect');
448
439
  // unexpected disconnect
449
440
  this._emit('offline.permanent', event);
450
441
  }
451
442
  } catch (error) {
452
- this.logger.error(`${this.namespace}: error occurred in close handler`, error);
443
+ this.logger.error('mercury: error occurred in close handler', error);
453
444
  }
454
445
  },
455
446
 
@@ -457,7 +448,7 @@ const Mercury = WebexPlugin.extend({
457
448
  const envelope = event.data;
458
449
 
459
450
  if (process.env.ENABLE_MERCURY_LOGGING) {
460
- this.logger.debug(`${this.namespace}: message envelope: `, envelope);
451
+ this.logger.debug('mercury: message envelope: ', envelope);
461
452
  }
462
453
 
463
454
  const {data} = envelope;
@@ -474,7 +465,7 @@ const Mercury = WebexPlugin.extend({
474
465
  resolve((this.webex[namespace] || this.webex.internal[namespace])[name](data))
475
466
  ).catch((reason) =>
476
467
  this.logger.error(
477
- `${this.namespace}: error occurred in autowired event handler for ${data.eventType}`,
468
+ `mercury: error occurred in autowired event handler for ${data.eventType}`,
478
469
  reason
479
470
  )
480
471
  );
@@ -493,12 +484,12 @@ const Mercury = WebexPlugin.extend({
493
484
  }
494
485
  })
495
486
  .catch((reason) => {
496
- this.logger.error(`${this.namespace}: error occurred processing socket message`, reason);
487
+ this.logger.error('mercury: error occurred processing socket message', reason);
497
488
  });
498
489
  },
499
490
 
500
491
  _reconnect(webSocketUrl) {
501
- this.logger.info(`${this.namespace}: reconnecting`);
492
+ this.logger.info('mercury: reconnecting');
502
493
 
503
494
  return this.connect(webSocketUrl);
504
495
  },
@@ -30,7 +30,6 @@ export default class Socket extends EventEmitter {
30
30
  */
31
31
  constructor() {
32
32
  super();
33
- this._domain = 'unknown-domain';
34
33
  this.onmessage = this.onmessage.bind(this);
35
34
  this.onclose = this.onclose.bind(this);
36
35
  }
@@ -112,10 +111,10 @@ export default class Socket extends EventEmitter {
112
111
  return;
113
112
  }
114
113
  // logger is defined once open is called
115
- this.logger.info(`socket,${this._domain}: closing`);
114
+ this.logger.info('socket: closing');
116
115
 
117
116
  if (socket.readyState === 2 || socket.readyState === 3) {
118
- this.logger.info(`socket,${this._domain}: already closed`);
117
+ this.logger.info('socket: already closed');
119
118
  resolve();
120
119
 
121
120
  return;
@@ -135,7 +134,7 @@ export default class Socket extends EventEmitter {
135
134
 
136
135
  const closeTimer = safeSetTimeout(() => {
137
136
  try {
138
- this.logger.info(`socket,${this._domain}: no close event received, forcing closure`);
137
+ this.logger.info('socket: no close event received, forcing closure');
139
138
  resolve(
140
139
  this.onclose({
141
140
  code: 1000,
@@ -143,12 +142,12 @@ export default class Socket extends EventEmitter {
143
142
  })
144
143
  );
145
144
  } catch (error) {
146
- this.logger.warn(`socket,${this._domain}: force-close failed`, error);
145
+ this.logger.warn('socket: force-close failed', error);
147
146
  }
148
147
  }, this.forceCloseDelay);
149
148
 
150
149
  socket.onclose = (event) => {
151
- this.logger.info(`socket,${this._domain}: close event fired`, event.code, event.reason);
150
+ this.logger.info('socket: close event fired', event.code, event.reason);
152
151
  clearTimeout(closeTimer);
153
152
  this.onclose(event);
154
153
  resolve(event);
@@ -172,12 +171,6 @@ export default class Socket extends EventEmitter {
172
171
  * @returns {Promise}
173
172
  */
174
173
  open(url, options) {
175
- try {
176
- this._domain = new URL(url).hostname;
177
- } catch {
178
- this._domain = url;
179
- }
180
-
181
174
  return new Promise((resolve, reject) => {
182
175
  /* eslint complexity: [0] */
183
176
  if (!url) {
@@ -208,7 +201,7 @@ export default class Socket extends EventEmitter {
208
201
 
209
202
  const WebSocket = Socket.getWebSocketConstructor();
210
203
 
211
- this.logger.info(`socket,${this._domain}: creating WebSocket`);
204
+ this.logger.info('socket: creating WebSocket');
212
205
  const socket = new WebSocket(url, [], options);
213
206
 
214
207
  socket.binaryType = 'arraybuffer';
@@ -216,7 +209,7 @@ export default class Socket extends EventEmitter {
216
209
 
217
210
  socket.onclose = (event) => {
218
211
  event = this._fixCloseCode(event);
219
- this.logger.info(`socket,${this._domain}: closed before open`, event.code, event.reason);
212
+ this.logger.info('socket: closed before open', event.code, event.reason);
220
213
  switch (event.code) {
221
214
  case 1005:
222
215
  // IE 11 doesn't seem to allow 4XXX codes, so if we get a 1005, assume
@@ -238,10 +231,10 @@ export default class Socket extends EventEmitter {
238
231
  };
239
232
 
240
233
  socket.onopen = () => {
241
- this.logger.info(`socket,${this._domain}: connected`);
234
+ this.logger.info('socket: connected');
242
235
  this._authorize()
243
236
  .then(() => {
244
- this.logger.info(`socket,${this._domain}: authorized`);
237
+ this.logger.info('socket: authorized');
245
238
  socket.onclose = this.onclose;
246
239
  resolve();
247
240
  })
@@ -249,11 +242,11 @@ export default class Socket extends EventEmitter {
249
242
  };
250
243
 
251
244
  socket.onerror = (event) => {
252
- this.logger.warn(`socket,${this._domain}: error event fired`, event);
245
+ this.logger.warn('socket: error event fired', event);
253
246
  };
254
247
 
255
248
  sockets.set(this, socket);
256
- this.logger.info(`socket,${this._domain}: waiting for server`);
249
+ this.logger.info('socket: waiting for server');
257
250
  });
258
251
  }
259
252
 
@@ -263,7 +256,7 @@ export default class Socket extends EventEmitter {
263
256
  * @returns {undefined}
264
257
  */
265
258
  onclose(event) {
266
- this.logger.info(`socket,${this._domain}: closed`, event.code, event.reason);
259
+ this.logger.info('socket: closed', event.code, event.reason);
267
260
  clearTimeout(this.pongTimer);
268
261
  clearTimeout(this.pingTimer);
269
262
 
@@ -285,10 +278,10 @@ export default class Socket extends EventEmitter {
285
278
  const data = JSON.parse(event.data);
286
279
  const sequenceNumber = parseInt(data.sequenceNumber, 10);
287
280
 
288
- this.logger.debug(`socket,${this._domain}: sequence number: `, sequenceNumber);
281
+ this.logger.debug('socket: sequence number: ', sequenceNumber);
289
282
  if (this.expectedSequenceNumber && sequenceNumber !== this.expectedSequenceNumber) {
290
283
  this.logger.debug(
291
- `socket,${this._domain}: sequence number mismatch indicates lost mercury message. expected: ${this.expectedSequenceNumber}, actual: ${sequenceNumber}`
284
+ `socket: sequence number mismatch indicates lost mercury message. expected: ${this.expectedSequenceNumber}, actual: ${sequenceNumber}`
292
285
  );
293
286
  this.emit('sequence-mismatch', sequenceNumber, this.expectedSequenceNumber);
294
287
  }
@@ -310,7 +303,7 @@ export default class Socket extends EventEmitter {
310
303
  // message from Mercury. At this time, the only action we have is to
311
304
  // ignore it and move on.
312
305
  /* istanbul ignore next */
313
- this.logger.warn(`socket,${this._domain}: error while receiving WebSocket message`, error);
306
+ this.logger.warn('socket: error while receiving WebSocket message', error);
314
307
  }
315
308
  }
316
309
 
@@ -364,7 +357,7 @@ export default class Socket extends EventEmitter {
364
357
  */
365
358
  _authorize() {
366
359
  return new Promise((resolve) => {
367
- this.logger.info(`socket,${this._domain}: authorizing`);
360
+ this.logger.info('socket: authorizing');
368
361
  this.send({
369
362
  id: uuid.v4(),
370
363
  type: 'authorization',
@@ -402,18 +395,12 @@ export default class Socket extends EventEmitter {
402
395
  if (event.code === 1005 && event.reason) {
403
396
  switch (event.reason.toLowerCase()) {
404
397
  case 'replaced':
405
- this.logger.info(
406
- `socket,${this._domain}: fixing CloseEvent code for reason: `,
407
- event.reason
408
- );
398
+ this.logger.info('socket: fixing CloseEvent code for reason: ', event.reason);
409
399
  event.code = 4000;
410
400
  break;
411
401
  case 'authentication failed':
412
402
  case 'authentication did not happen within the timeout window of 30000 seconds.':
413
- this.logger.info(
414
- `socket,${this._domain}: fixing CloseEvent code for reason: `,
415
- event.reason
416
- );
403
+ this.logger.info('socket: fixing CloseEvent code for reason: ', event.reason);
417
404
  event.code = 1008;
418
405
  break;
419
406
  default:
@@ -433,12 +420,10 @@ export default class Socket extends EventEmitter {
433
420
  _ping(id) {
434
421
  const confirmPongId = (event) => {
435
422
  try {
436
- this.logger.debug(`socket,${this._domain}: pong`, event.data.id);
423
+ this.logger.debug('socket: pong', event.data.id);
437
424
  if (event.data && event.data.id !== id) {
438
- this.logger.info(
439
- `socket,${this._domain}: received pong for wrong ping id, closing socket`
440
- );
441
- this.logger.debug(`socket,${this._domain}: expected`, id, 'received', event.data.id);
425
+ this.logger.info('socket: received pong for wrong ping id, closing socket');
426
+ this.logger.debug('socket: expected', id, 'received', event.data.id);
442
427
  this.close({
443
428
  code: 1000,
444
429
  reason: 'Pong mismatch',
@@ -448,29 +433,24 @@ export default class Socket extends EventEmitter {
448
433
  // This try/catch block was added as a debugging step; to the best of my
449
434
  // knowledge, the above can never throw.
450
435
  /* istanbul ignore next */
451
- this.logger.error(`socket,${this._domain}: error occurred in confirmPongId`, error);
436
+ this.logger.error('socket: error occurred in confirmPongId', error);
452
437
  }
453
438
  };
454
439
 
455
440
  const onPongNotReceived = () => {
456
441
  try {
457
- this.logger.info(
458
- `socket,${this._domain}: pong not receive in expected period, closing socket`
459
- );
442
+ this.logger.info('socket: pong not receive in expected period, closing socket');
460
443
  this.close({
461
444
  code: 1000,
462
445
  reason: 'Pong not received',
463
446
  }).catch((reason) => {
464
- this.logger.warn(
465
- `socket,${this._domain}: failed to close socket after missed pong`,
466
- reason
467
- );
447
+ this.logger.warn('socket: failed to close socket after missed pong', reason);
468
448
  });
469
449
  } catch (error) {
470
450
  // This try/catch block was added as a debugging step; to the best of my
471
451
  // knowledge, the above can never throw.
472
452
  /* istanbul ignore next */
473
- this.logger.error(`socket,${this._domain}: error occurred in onPongNotReceived`, error);
453
+ this.logger.error('socket: error occurred in onPongNotReceived', error);
474
454
  }
475
455
  };
476
456
 
@@ -482,10 +462,7 @@ export default class Socket extends EventEmitter {
482
462
  // This try/catch block was added as a debugging step; to the best of my
483
463
  // knowledge, the above can never throw.
484
464
  /* istanbul ignore next */
485
- this.logger.error(
486
- `socket,${this._domain}: error occurred in scheduleNextPingAndCancelPongTimer`,
487
- error
488
- );
465
+ this.logger.error('socket: error occurred in scheduleNextPingAndCancelPongTimer', error);
489
466
  }
490
467
  };
491
468
 
@@ -494,7 +471,7 @@ export default class Socket extends EventEmitter {
494
471
  this.once('pong', scheduleNextPingAndCancelPongTimer);
495
472
  this.once('pong', confirmPongId);
496
473
 
497
- this.logger.debug(`socket,${this._domain}: ping ${id}`);
474
+ this.logger.debug(`socket: ping ${id}`);
498
475
 
499
476
  return this.send({
500
477
  id,
@@ -32,13 +32,12 @@ describe('plugin-mercury', function () {
32
32
  );
33
33
 
34
34
  describe('onBeforeLogout()', () => {
35
- it('disconnects the web socket', () => {
35
+ it('disconnects the web socket', () =>
36
36
  webex.logout({noRedirect: true}).then(() => {
37
37
  assert.called(webex.internal.mercury.disconnect);
38
38
  assert.isFalse(webex.internal.mercury.connected);
39
39
  assert.called(webex.internal.device.unregister);
40
40
  assert.isFalse(webex.internal.device.registered);
41
- });
42
- });
41
+ }));
43
42
  });
44
43
  });
@@ -558,7 +558,7 @@ describe('plugin-mercury', () => {
558
558
  return promiseTick(webex.internal.mercury.config.backoffTimeReset).then(() => {
559
559
  assert.equal(
560
560
  reason.message,
561
- 'Mercury: prevent socket open when backoffCall no longer defined'
561
+ 'mercury: prevent socket open when backoffCall no longer defined'
562
562
  );
563
563
  });
564
564
  });
@@ -566,21 +566,12 @@ describe('plugin-mercury', () => {
566
566
  });
567
567
 
568
568
  describe('#_emit()', () => {
569
- it('emits Error-safe events and log the error with the call parameters', () => {
570
- const error = 'error';
571
- const event = {data: 'some data'};
569
+ it('emits Error-safe events', () => {
572
570
  mercury.on('break', () => {
573
- throw error;
571
+ throw new Error();
574
572
  });
575
- sinon.stub(mercury.logger, 'error');
576
573
 
577
- return Promise.resolve(mercury._emit('break', event)).then((res) => {
578
- assert.calledWith(mercury.logger.error, 'Mercury: error occurred in event handler', {
579
- error,
580
- arguments: ['break', event],
581
- });
582
- return res;
583
- });
574
+ return Promise.resolve(mercury._emit('break'));
584
575
  });
585
576
  });
586
577