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