@webex/plugin-device-manager 3.0.0-beta.8 → 3.0.0-beta.81

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.
@@ -24,50 +24,48 @@ const DeviceManager = WebexPlugin.extend({
24
24
  },
25
25
 
26
26
  /**
27
- * Gets a list of all recent devices associated with the user
28
- * the device list gets populated from Redis
29
- * @returns {Promise<Device>}
30
- */
27
+ * Gets a list of all recent devices associated with the user
28
+ * the device list gets populated from Redis
29
+ * @returns {Promise<Device>}
30
+ */
31
31
  getAll() {
32
32
  return DeviceCollection.getAll();
33
33
  },
34
34
 
35
35
  /**
36
- * Gets a list of all recent devices associated with the user
37
- * the device list gets populated from Redis
38
- * @returns {Promise<Device>}
39
- */
36
+ * Gets a list of all recent devices associated with the user
37
+ * the device list gets populated from Redis
38
+ * @returns {Promise<Device>}
39
+ */
40
40
  refresh() {
41
41
  DeviceCollection.reset();
42
42
 
43
- return this.webex.request({
44
- api: 'wdm',
45
- resource: 'devices/auxiliary'
46
- })
43
+ return this.webex
44
+ .request({
45
+ api: 'wdm',
46
+ resource: 'devices/auxiliary',
47
+ })
47
48
  .then((res) => {
48
49
  if (!res.body) {
49
50
  return Promise.reject();
50
51
  }
51
52
 
52
- return this._updateDeviceMetadata(res.body.items)
53
- .then((devices) => {
54
- /* eslint-disable consistent-return */
55
- devices.forEach((device) => {
56
- if (device.deviceInfo &&
57
- device.deviceInfo.machineType === LYRA_SPACE) {
58
- return this.webex.internal.lyra.space.get(device.deviceInfo)
59
- .catch((err) => {
60
- this.logger.error('DeviceManager#refresh: failed to receive device info', err);
61
- });
62
- }
63
- });
64
- /* eslint-enable consistent-return */
65
- res.body.items.forEach((device) => {
66
- DeviceCollection.set(device);
67
- });
68
-
69
- return this.getAll();
53
+ return this._updateDeviceMetadata(res.body.items).then((devices) => {
54
+ /* eslint-disable consistent-return */
55
+ devices.forEach((device) => {
56
+ if (device.deviceInfo && device.deviceInfo.machineType === LYRA_SPACE) {
57
+ return this.webex.internal.lyra.space.get(device.deviceInfo).catch((err) => {
58
+ this.logger.error('DeviceManager#refresh: failed to receive device info', err);
59
+ });
60
+ }
70
61
  });
62
+ /* eslint-enable consistent-return */
63
+ res.body.items.forEach((device) => {
64
+ DeviceCollection.set(device);
65
+ });
66
+
67
+ return this.getAll();
68
+ });
71
69
  })
72
70
  .catch((err) => {
73
71
  this.logger.error('DeviceManager#refresh: failed to fetch recent devices', err);
@@ -75,11 +73,11 @@ const DeviceManager = WebexPlugin.extend({
75
73
  },
76
74
 
77
75
  /**
78
- * Search for a device by name
79
- * @param {Object} options
80
- * @param {string} options.searchQuery
81
- * @returns {Promise<Device>}
82
- */
76
+ * Search for a device by name
77
+ * @param {Object} options
78
+ * @param {string} options.searchQuery
79
+ * @returns {Promise<Device>}
80
+ */
83
81
  search(options) {
84
82
  if (!options || !options.searchQuery) {
85
83
  this.logger.error('DeviceManager#search: options.searchQuery is required');
@@ -87,14 +85,15 @@ const DeviceManager = WebexPlugin.extend({
87
85
  return Promise.reject(new Error('DeviceManager#search: options.searchQuery is required'));
88
86
  }
89
87
 
90
- return this.webex.internal.search.people({
91
- searchId: uuid.v4(),
92
- searchType: 'DEVICE_SEARCH',
93
- searchEntity: 'device',
94
- includePeople: false,
95
- includeRooms: true,
96
- queryString: options.searchQuery
97
- })
88
+ return this.webex.internal.search
89
+ .people({
90
+ searchId: uuid.v4(),
91
+ searchType: 'DEVICE_SEARCH',
92
+ searchEntity: 'device',
93
+ includePeople: false,
94
+ includeRooms: true,
95
+ queryString: options.searchQuery,
96
+ })
98
97
  .catch((err) => {
99
98
  this.logger.error('DeviceManager#search: failed to search a device', err);
100
99
 
@@ -103,13 +102,13 @@ const DeviceManager = WebexPlugin.extend({
103
102
  },
104
103
 
105
104
  /**
106
- * Caches the device info and also registers to Redis for subsequent fetches
107
- * @param {Object} device
108
- * @param {string} device.id
109
- * @returns {deviceInfo}
110
- */
105
+ * Caches the device info and also registers to Redis for subsequent fetches
106
+ * @param {Object} device
107
+ * @param {string} device.id
108
+ * @returns {deviceInfo}
109
+ */
111
110
  upsert(device) {
112
- const deviceId = device.id || device.identity && device.identity.id;
111
+ const deviceId = device.id || (device.identity && device.identity.id);
113
112
 
114
113
  if (!deviceId) {
115
114
  this.logger.error('DeviceManager#upsert: device.id is required');
@@ -128,33 +127,37 @@ const DeviceManager = WebexPlugin.extend({
128
127
  }
129
128
 
130
129
  // new device requested, add to wdm for subsequent retreivals
131
- return this.webex.request({
132
- api: 'wdm',
133
- method: 'PUT',
134
- resource: `devices/auxiliary/Room/${deviceId}`
135
- })
136
- .then((res) => {
137
- const auxDevice = res.body;
130
+ return (
131
+ this.webex
132
+ .request({
133
+ api: 'wdm',
134
+ method: 'PUT',
135
+ resource: `devices/auxiliary/Room/${deviceId}`,
136
+ })
137
+ .then((res) => {
138
+ const auxDevice = res.body;
138
139
 
139
- return this._decryptDeviceName(auxDevice);
140
- })
141
- .then((device) => {
142
- DeviceCollection.set(device);
140
+ return this._decryptDeviceName(auxDevice);
141
+ })
142
+ // eslint-disable-next-line no-shadow
143
+ .then((device) => {
144
+ DeviceCollection.set(device);
143
145
 
144
- return Promise.resolve(DeviceCollection.get(deviceId));
145
- })
146
- .catch((err) => {
147
- this.logger.error('DeviceManager#upsert: failed to add/update a device', err);
146
+ return Promise.resolve(DeviceCollection.get(deviceId));
147
+ })
148
+ .catch((err) => {
149
+ this.logger.error('DeviceManager#upsert: failed to add/update a device', err);
148
150
 
149
- return Promise.reject(err);
150
- });
151
+ return Promise.reject(err);
152
+ })
153
+ );
151
154
  },
152
155
 
153
156
  /**
154
- * Retreives device info of a particular device
155
- * @param {string} token
156
- * @returns {Promise<deviceInfo>}
157
- */
157
+ * Retreives device info of a particular device
158
+ * @param {string} token
159
+ * @returns {Promise<deviceInfo>}
160
+ */
158
161
  get(token) {
159
162
  if (!token) {
160
163
  this.logger.error('DeviceManager#get: token is required');
@@ -163,7 +166,8 @@ const DeviceManager = WebexPlugin.extend({
163
166
  }
164
167
  let deviceInfo;
165
168
 
166
- return this.webex.internal.lyra.getAdvertisedEndpoint(token)
169
+ return this.webex.internal.lyra
170
+ .getAdvertisedEndpoint(token)
167
171
  .then((res) => {
168
172
  deviceInfo = res;
169
173
 
@@ -186,11 +190,11 @@ const DeviceManager = WebexPlugin.extend({
186
190
  },
187
191
 
188
192
  /**
189
- * Unregisters the device from Redis, will not fetch in subsequent loads,
190
- * similar to space.deleteBinding()
191
- * @param {string} deviceId
192
- * @returns {Promise<deviceInfo>}
193
- */
193
+ * Unregisters the device from Redis, will not fetch in subsequent loads,
194
+ * similar to space.deleteBinding()
195
+ * @param {string} deviceId
196
+ * @returns {Promise<deviceInfo>}
197
+ */
194
198
  remove(deviceId) {
195
199
  if (!deviceId) {
196
200
  this.logger.error('DeviceManager#remove: deviceId is required');
@@ -198,11 +202,12 @@ const DeviceManager = WebexPlugin.extend({
198
202
  return Promise.reject(new Error('DeviceManager#remove: deviceId is required'));
199
203
  }
200
204
 
201
- return this.webex.request({
202
- method: 'delete',
203
- api: 'wdm',
204
- resource: `devices/auxiliary/${deviceId}`
205
- })
205
+ return this.webex
206
+ .request({
207
+ method: 'delete',
208
+ api: 'wdm',
209
+ resource: `devices/auxiliary/${deviceId}`,
210
+ })
206
211
  .catch((error) => {
207
212
  this.logger.error('DeviceManager#remove: failed to remove the device', error);
208
213
 
@@ -211,14 +216,14 @@ const DeviceManager = WebexPlugin.extend({
211
216
  },
212
217
 
213
218
  /**
214
- * Requests to display PIN on the device
215
- * @param {object} device
216
- * @param {object} options
217
- * @param {object} options.data
218
- * @returns {Promise<deviceInfo>}
219
- */
219
+ * Requests to display PIN on the device
220
+ * @param {object} device
221
+ * @param {object} options
222
+ * @param {object} options.data
223
+ * @returns {Promise<deviceInfo>}
224
+ */
220
225
  requestPin(device, options = {}) {
221
- const deviceId = device.id || device.identity && device.identity.id;
226
+ const deviceId = device.id || (device.identity && device.identity.id);
222
227
 
223
228
  if (!deviceId) {
224
229
  this.logger.error('DeviceManager#requestPin: device.id is required');
@@ -227,16 +232,19 @@ const DeviceManager = WebexPlugin.extend({
227
232
  }
228
233
  const space = {id: deviceId, url: `/spaces/${deviceId}`};
229
234
 
230
- return this.webex.internal.lyra.space.get(space)
231
- .then((dev) => { // check if the space is pinChallenge capable
235
+ return this.webex.internal.lyra.space
236
+ .get(space)
237
+ .then((dev) => {
238
+ // check if the space is pinChallenge capable
232
239
  if (dev && dev.occupants && dev.occupants.pinChallenge) {
233
240
  this.logger.info('DeviceManager#requestPin: space is PIN challenge capable');
234
241
 
235
- return this.webex.internal.lyra.space.join(space, {
236
- passType: 'MANUAL',
237
- verificationInitiation: 'PIN',
238
- data: options.data
239
- })
242
+ return this.webex.internal.lyra.space
243
+ .join(space, {
244
+ passType: 'MANUAL',
245
+ verificationInitiation: 'PIN',
246
+ data: options.data,
247
+ })
240
248
  .then(() => {
241
249
  this._devicePendingPinChallenge = dev;
242
250
 
@@ -246,10 +254,11 @@ const DeviceManager = WebexPlugin.extend({
246
254
  });
247
255
  }
248
256
  // pairs with the space if it's not PIN challenge capable
249
- this.logger.info('DeviceManager#requestPin: space is not PIN challenge capable, probably already occupied, will still return device info');
257
+ this.logger.info(
258
+ 'DeviceManager#requestPin: space is not PIN challenge capable, probably already occupied, will still return device info'
259
+ );
250
260
 
251
- return this.webex.internal.lyra.space.get(space)
252
- .then(() => Promise.resolve(dev));
261
+ return this.webex.internal.lyra.space.get(space).then(() => Promise.resolve(dev));
253
262
  })
254
263
  .catch((err) => {
255
264
  this.logger.error('DeviceManager#requestPin: device failed PIN challenge request', err);
@@ -259,13 +268,13 @@ const DeviceManager = WebexPlugin.extend({
259
268
  },
260
269
 
261
270
  /**
262
- * pairs the device with the user (manual pairing), also adds it to
263
- * user's recents list for subsequent fetches.
264
- * similar to space.join()
265
- * @param {object} options
266
- * @param {number} options.pin
267
- * @returns {Promise<deviceInfo>}
268
- */
271
+ * pairs the device with the user (manual pairing), also adds it to
272
+ * user's recents list for subsequent fetches.
273
+ * similar to space.join()
274
+ * @param {object} options
275
+ * @param {number} options.pin
276
+ * @returns {Promise<deviceInfo>}
277
+ */
269
278
  pair(options = {}) {
270
279
  if (!options.pin) {
271
280
  this.logger.error('DeviceManager#pair: options.pin is required');
@@ -273,12 +282,16 @@ const DeviceManager = WebexPlugin.extend({
273
282
  return Promise.reject(new Error('DeviceManager#pair: options.pin is required'));
274
283
  }
275
284
  if (this._devicePendingPinChallenge) {
276
- const space = {id: this._devicePendingPinChallenge.identity.id, url: `/spaces/${this._devicePendingPinChallenge.identity.id}`};
277
-
278
- return this.webex.internal.lyra.space.join(space, {
279
- passType: 'PIN_ANSWER',
280
- data: options.pin
281
- })
285
+ const space = {
286
+ id: this._devicePendingPinChallenge.identity.id,
287
+ url: `/spaces/${this._devicePendingPinChallenge.identity.id}`,
288
+ };
289
+
290
+ return this.webex.internal.lyra.space
291
+ .join(space, {
292
+ passType: 'PIN_ANSWER',
293
+ data: options.pin,
294
+ })
282
295
  .catch((err) => {
283
296
  this.logger.error('DeviceManager#pair: incorrect PIN, unable to pair ', err);
284
297
 
@@ -292,14 +305,14 @@ const DeviceManager = WebexPlugin.extend({
292
305
  },
293
306
 
294
307
  /**
295
- * unpairs the device with the user (manual/ultrasonic pairing), but still
296
- * keeps in the recents list/does not remove from Redis
297
- * options.removeAllDevices will remove all associated devices to user
298
- * similar to space.leave()
299
- * @param {object} options
300
- * @param {boolean} options.removeAllDevices
301
- * @returns {Promise<deviceInfo>}
302
- */
308
+ * unpairs the device with the user (manual/ultrasonic pairing), but still
309
+ * keeps in the recents list/does not remove from Redis
310
+ * options.removeAllDevices will remove all associated devices to user
311
+ * similar to space.leave()
312
+ * @param {object} options
313
+ * @param {boolean} options.removeAllDevices
314
+ * @returns {Promise<deviceInfo>}
315
+ */
303
316
  unpair(options = {}) {
304
317
  if (!this._pairedDevice) {
305
318
  this.logger.error('DeviceManager#unpair: no device to unpair');
@@ -308,22 +321,21 @@ const DeviceManager = WebexPlugin.extend({
308
321
  }
309
322
  const space = {url: `/spaces/${this._pairedDevice.identity.id}`};
310
323
 
311
- return this.webex.internal.lyra.space.leave(space, options)
312
- .catch((err) => {
313
- this.logger.error('DeviceManager#unpair: failed to remove device from Lyra', err);
324
+ return this.webex.internal.lyra.space.leave(space, options).catch((err) => {
325
+ this.logger.error('DeviceManager#unpair: failed to remove device from Lyra', err);
314
326
 
315
- return Promise.reject(err);
316
- });
327
+ return Promise.reject(err);
328
+ });
317
329
  },
318
330
 
319
331
  /**
320
- * binds the space to the paired device (if supported)
321
- * similar to space.bindConversation()
322
- * @param {object} options
323
- * @param {boolean} options.url, conversation url
324
- * @param {boolean} options.kmsResourceObjectUrl of the convo
325
- * @returns {Promise<deviceInfo>}
326
- */
332
+ * binds the space to the paired device (if supported)
333
+ * similar to space.bindConversation()
334
+ * @param {object} options
335
+ * @param {boolean} options.url, conversation url
336
+ * @param {boolean} options.kmsResourceObjectUrl of the convo
337
+ * @returns {Promise<deviceInfo>}
338
+ */
327
339
  bindSpace(options = {}) {
328
340
  if (!options.url) {
329
341
  this.logger.error('DeviceManager#pair: options.url is required');
@@ -333,42 +345,52 @@ const DeviceManager = WebexPlugin.extend({
333
345
  if (!options.kmsResourceObjectUrl) {
334
346
  this.logger.error('DeviceManager#bindSpace: options.kmsResourceObjectUrl is required');
335
347
 
336
- return Promise.reject(new Error('DeviceManager#bindSpace: options.kmsResourceObjectUrl is required'));
348
+ return Promise.reject(
349
+ new Error('DeviceManager#bindSpace: options.kmsResourceObjectUrl is required')
350
+ );
337
351
  }
338
352
  if (!this._pairedDevice) {
339
353
  this.logger.error('DeviceManager#bindSpace: No device paired currently');
340
354
 
341
355
  return Promise.reject(new Error('DeviceManager#bindSpace: No device paired currently'));
342
356
  }
343
- const space = {url: `/spaces/${this._pairedDevice.identity.id}`, id: this._pairedDevice.identity.id};
357
+ const space = {
358
+ url: `/spaces/${this._pairedDevice.identity.id}`,
359
+ id: this._pairedDevice.identity.id,
360
+ };
344
361
 
345
362
  this._boundSpace = {
346
363
  kmsResourceObjectUrl: options.kmsResourceObjectUrl,
347
- url: options.url
364
+ url: options.url,
348
365
  };
349
366
 
350
- return this.webex.internal.lyra.space.bindConversation(space, this._boundSpace)
351
- .catch((err) => {
352
- this.logger.error('DeviceManager#bindSpace: failed to bind device to Space');
367
+ return this.webex.internal.lyra.space.bindConversation(space, this._boundSpace).catch((err) => {
368
+ this.logger.error('DeviceManager#bindSpace: failed to bind device to Space');
353
369
 
354
- return Promise.reject(err);
355
- });
370
+ return Promise.reject(err);
371
+ });
356
372
  },
357
373
 
358
374
  /**
359
- * unbinds the space to the paired device (if supported)
360
- * similar to space.unbindConversation()
361
- * @returns {Promise<deviceInfo>}
362
- */
375
+ * unbinds the space to the paired device (if supported)
376
+ * similar to space.unbindConversation()
377
+ * @returns {Promise<deviceInfo>}
378
+ */
363
379
  unbindSpace() {
364
380
  if (!this._pairedDevice || !this._boundSpace) {
365
381
  this.logger.error('DeviceManager#unbindSpace: No space currently bound to the device');
366
382
 
367
- return Promise.reject(new Error('DeviceManager#unbindSpace: No space currently bound to the device'));
383
+ return Promise.reject(
384
+ new Error('DeviceManager#unbindSpace: No space currently bound to the device')
385
+ );
368
386
  }
369
- const space = {url: `/spaces/${this._pairedDevice.identity.id}`, id: this._pairedDevice.identity.id};
387
+ const space = {
388
+ url: `/spaces/${this._pairedDevice.identity.id}`,
389
+ id: this._pairedDevice.identity.id,
390
+ };
370
391
 
371
- return this.webex.internal.lyra.space.unbindConversation(space, this._boundSpace)
392
+ return this.webex.internal.lyra.space
393
+ .unbindConversation(space, this._boundSpace)
372
394
  .then((res) => {
373
395
  this._boundSpace = null;
374
396
 
@@ -382,37 +404,39 @@ const DeviceManager = WebexPlugin.extend({
382
404
  },
383
405
 
384
406
  /**
385
- * Gets the audio state of the paired device
386
- * similar to device.getAudioState()
387
- * @returns {Promise<audioState>}
388
- */
407
+ * Gets the audio state of the paired device
408
+ * similar to device.getAudioState()
409
+ * @returns {Promise<audioState>}
410
+ */
389
411
  getAudioState() {
390
412
  if (!this._pairedDevice) {
391
413
  this.logger.error('DeviceManager#getAudioState: Currently no device is paired');
392
414
 
393
- return Promise.reject(new Error('DeviceManager#getAudioState: Currently no device is paired'));
415
+ return Promise.reject(
416
+ new Error('DeviceManager#getAudioState: Currently no device is paired')
417
+ );
394
418
  }
395
419
 
396
420
  return this.webex.internal.lyra.device.getAudioState(this._pairedDevice);
397
421
  },
398
422
 
399
423
  /**
400
- * Updates audio state of the paired device, should be called every 10 minutes
401
- * or when mic or volume state is changed
402
- * similar to device.putAudioState()
403
- * @param {object} space
404
- * @param {object} audioState
405
- * @returns {Promise<audioState>}
406
- */
424
+ * Updates audio state of the paired device, should be called every 10 minutes
425
+ * or when mic or volume state is changed
426
+ * similar to device.putAudioState()
427
+ * @param {object} space
428
+ * @param {object} audioState
429
+ * @returns {Promise<audioState>}
430
+ */
407
431
  putAudioState(space, audioState = {}) {
408
432
  return this.webex.internal.lyra.device.putAudioState(space, audioState);
409
433
  },
410
434
 
411
435
  /**
412
- * Mutes paired device
413
- * similar to device.mute()
414
- * @returns {Promise<audioState>}
415
- */
436
+ * Mutes paired device
437
+ * similar to device.mute()
438
+ * @returns {Promise<audioState>}
439
+ */
416
440
  mute() {
417
441
  if (!this._pairedDevice) {
418
442
  this.logger.error('DeviceManager#mute: Currently no device is paired');
@@ -424,10 +448,10 @@ const DeviceManager = WebexPlugin.extend({
424
448
  },
425
449
 
426
450
  /**
427
- * Unmutes paired device
428
- * similar to device.unmute()
429
- * @returns {Promise<audioState>}
430
- */
451
+ * Unmutes paired device
452
+ * similar to device.unmute()
453
+ * @returns {Promise<audioState>}
454
+ */
431
455
  unmute() {
432
456
  if (!this._pairedDevice) {
433
457
  this.logger.error('DeviceManager#unmute: Currently no device is paired');
@@ -439,41 +463,45 @@ const DeviceManager = WebexPlugin.extend({
439
463
  },
440
464
 
441
465
  /**
442
- * Increases paired device's volume
443
- * similar to device.increaseVolume()
444
- * @returns {Promise<audioState>}
445
- */
466
+ * Increases paired device's volume
467
+ * similar to device.increaseVolume()
468
+ * @returns {Promise<audioState>}
469
+ */
446
470
  increaseVolume() {
447
471
  if (!this._pairedDevice) {
448
472
  this.logger.error('DeviceManager#increaseVolume: Currently no device is paired');
449
473
 
450
- return Promise.reject(new Error('DeviceManager#increaseVolume: Currently no device is paired'));
474
+ return Promise.reject(
475
+ new Error('DeviceManager#increaseVolume: Currently no device is paired')
476
+ );
451
477
  }
452
478
 
453
479
  return this.webex.internal.lyra.device.increaseVolume(this._pairedDevice);
454
480
  },
455
481
 
456
482
  /**
457
- * Decreases paired device's volume
458
- * similar to device.decreaseVolume()
459
- * @returns {Promise<audioState>}
460
- */
483
+ * Decreases paired device's volume
484
+ * similar to device.decreaseVolume()
485
+ * @returns {Promise<audioState>}
486
+ */
461
487
  decreaseVolume() {
462
488
  if (!this._pairedDevice) {
463
489
  this.logger.error('DeviceManager#decreaseVolume: Currently no device is paired');
464
490
 
465
- return Promise.reject(new Error('DeviceManager#decreaseVolume: Currently no device is paired'));
491
+ return Promise.reject(
492
+ new Error('DeviceManager#decreaseVolume: Currently no device is paired')
493
+ );
466
494
  }
467
495
 
468
496
  return this.webex.internal.lyra.device.decreaseVolume(this._pairedDevice);
469
497
  },
470
498
 
471
499
  /**
472
- * Sets paired device's volume but should use increase and decrease api instead
473
- * similar to device.setVolume()
474
- * @param {number} level
475
- * @returns {Promise<audioState>}
476
- */
500
+ * Sets paired device's volume but should use increase and decrease api instead
501
+ * similar to device.setVolume()
502
+ * @param {number} level
503
+ * @returns {Promise<audioState>}
504
+ */
477
505
  setVolume(level = 0) {
478
506
  if (!this._pairedDevice) {
479
507
  this.logger.error('DeviceManager#setVolume: Currently no device is paired');
@@ -485,48 +513,51 @@ const DeviceManager = WebexPlugin.extend({
485
513
  },
486
514
 
487
515
  /**
488
- * Utility function to update decrypted device name on device object
489
- * @param {Array} deviceArray
490
- * @returns {device}
491
- */
516
+ * Utility function to update decrypted device name on device object
517
+ * @param {Array} deviceArray
518
+ * @returns {device}
519
+ */
492
520
  _updateDeviceMetadata(deviceArray = []) {
493
521
  if (!deviceArray.length) {
494
522
  return Promise.resolve(deviceArray);
495
523
  }
496
524
  const devices = cloneDeep(deviceArray);
497
525
 
498
- return Promise.all(devices.map(
499
- (device, index) => this.webex.internal.services.waitForCatalog('postauth')
500
- .then(() => {
501
- if (device.deviceClass === UC_CLOUD) {
502
- device.id = `${this.webex.internal.services.get('wdm')}/${device.id}`;
503
- }
526
+ return Promise.all(
527
+ devices.map((device, index) =>
528
+ this.webex.internal.services
529
+ .waitForCatalog('postauth')
530
+ .then(() => {
531
+ if (device.deviceClass === UC_CLOUD) {
532
+ device.id = `${this.webex.internal.services.get('wdm')}/${device.id}`;
533
+ }
504
534
 
505
- return this._decryptDeviceName(device);
506
- })
507
- .then((updatedDevice) => {
508
- devices[index] = updatedDevice;
535
+ return this._decryptDeviceName(device);
536
+ })
537
+ .then((updatedDevice) => {
538
+ devices[index] = updatedDevice;
509
539
 
510
- return Promise.resolve();
511
- })
512
- ))
513
- .then(() => Promise.resolve(devices));
540
+ return Promise.resolve();
541
+ })
542
+ )
543
+ ).then(() => Promise.resolve(devices));
514
544
  },
515
545
 
516
546
  /**
517
- * Utility function to update decrypted device name on device object
518
- * @param {object} inDevice
519
- * @returns {device}
520
- */
547
+ * Utility function to update decrypted device name on device object
548
+ * @param {object} inDevice
549
+ * @returns {device}
550
+ */
521
551
  _decryptDeviceName(inDevice = {}) {
522
552
  const device = cloneDeep(inDevice);
523
553
 
524
- if (device.metadata &&
554
+ if (
555
+ device.metadata &&
525
556
  device.metadata.encryptedUserAssignedName &&
526
- device.metadata.encryptionKeyUrl) {
527
- return this.webex.internal.encryption.decryptText(
528
- device.metadata.encryptionKeyUrl, device.metadata.encryptedUserAssignedName
529
- )
557
+ device.metadata.encryptionKeyUrl
558
+ ) {
559
+ return this.webex.internal.encryption
560
+ .decryptText(device.metadata.encryptionKeyUrl, device.metadata.encryptedUserAssignedName)
530
561
  .then((decryptedDeviceName) => {
531
562
  // set userAssignedName as the decypted value, unset encryptedUserAssignedName since it's not needed
532
563
  device.metadata.encryptedUserAssignedName = undefined;
@@ -537,7 +568,10 @@ const DeviceManager = WebexPlugin.extend({
537
568
  .catch((err) => {
538
569
  // unset encryptedUserAssignedName if failed to decrypt
539
570
  device.metadata.encryptedUserAssignedName = undefined;
540
- this.logger.error('DeviceCollection#_decryptDeviceName: failed to decrypt device name', err);
571
+ this.logger.error(
572
+ 'DeviceCollection#_decryptDeviceName: failed to decrypt device name',
573
+ err
574
+ );
541
575
  });
542
576
  }
543
577
 
@@ -545,10 +579,10 @@ const DeviceManager = WebexPlugin.extend({
545
579
  },
546
580
 
547
581
  /**
548
- * Utility function to update device info on mercury updates
549
- * @param {object} device
550
- * @returns {device}
551
- */
582
+ * Utility function to update device info on mercury updates
583
+ * @param {object} device
584
+ * @returns {device}
585
+ */
552
586
  _receiveDeviceUpdates(device) {
553
587
  // we care only the updates are for the registered devices
554
588
  if (device && device.spaceUrl) {
@@ -556,22 +590,30 @@ const DeviceManager = WebexPlugin.extend({
556
590
  const existingDevice = DeviceCollection.get(deviceId);
557
591
 
558
592
  if (existingDevice) {
559
- return this.webex.internal.lyra.space.get({id: deviceId})
593
+ return this.webex.internal.lyra.space
594
+ .get({id: deviceId})
560
595
  .then((space) => {
596
+ // eslint-disable-next-line no-shadow
561
597
  const device = DeviceCollection.get(deviceId);
562
598
 
563
- if (device &&
599
+ if (
600
+ device &&
564
601
  space.occupants &&
565
- (!space.occupants.self || !space.occupants.self.verified)) {
566
- device.productName = space.devices && space.devices[0] && space.devices[0].productName ||
567
- DEFAULT_PRODUCT_NAME;
602
+ (!space.occupants.self || !space.occupants.self.verified)
603
+ ) {
604
+ device.productName =
605
+ (space.devices && space.devices[0] && space.devices[0].productName) ||
606
+ DEFAULT_PRODUCT_NAME;
568
607
  // pin challenge is not verified reset _pairedDevice if ids
569
608
  // match
570
- const pairedDeviceId = this._pairedDevice && (this._pairedDevice.id || this._pairedDevice.identity.id);
609
+ const pairedDeviceId =
610
+ this._pairedDevice && (this._pairedDevice.id || this._pairedDevice.identity.id);
571
611
 
572
612
  if (pairedDeviceId === deviceId) {
573
613
  this._pairedDevice = null;
574
- this.logger.info(`DeviceManager#_receiveDeviceUpdates: device ${deviceId} lost pairing`);
614
+ this.logger.info(
615
+ `DeviceManager#_receiveDeviceUpdates: device ${deviceId} lost pairing`
616
+ );
575
617
 
576
618
  return Promise.resolve();
577
619
  }
@@ -586,15 +628,16 @@ const DeviceManager = WebexPlugin.extend({
586
628
  return Promise.resolve();
587
629
  })
588
630
  .catch((err) => {
589
- this.logger.error('DeviceManager#_receiveDeviceUpdates: failed to receive updates for Lyra space', err);
631
+ this.logger.error(
632
+ 'DeviceManager#_receiveDeviceUpdates: failed to receive updates for Lyra space',
633
+ err
634
+ );
590
635
  });
591
636
  }
592
637
  }
593
638
 
594
639
  return Promise.resolve();
595
- }
596
-
597
-
640
+ },
598
641
  });
599
642
 
600
643
  export default DeviceManager;