@webex/internal-plugin-lyra 3.0.0-beta.14 → 3.0.0-beta.15
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/README.md +1 -3
- package/dist/config.js.map +1 -1
- package/dist/device.js +1 -1
- package/dist/device.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lyra.js +1 -1
- package/dist/lyra.js.map +1 -1
- package/dist/space.js +17 -7
- package/dist/space.js.map +1 -1
- package/package.json +13 -13
- package/src/config.js +1 -2
- package/src/device.js +18 -17
- package/src/index.js +1 -1
- package/src/lyra.js +11 -11
- package/src/space.js +68 -64
- package/test/integration/spec/device.js +69 -48
- package/test/integration/spec/space.js +127 -82
- package/test/unit/spec/device.js +22 -15
- package/test/unit/spec/lyra.js +16 -11
- package/test/unit/spec/space.js +132 -71
package/src/space.js
CHANGED
|
@@ -21,11 +21,12 @@ const Space = WebexPlugin.extend({
|
|
|
21
21
|
* @returns {Promise<Array>} spaces
|
|
22
22
|
*/
|
|
23
23
|
list() {
|
|
24
|
-
return this.webex
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return this.webex
|
|
25
|
+
.request({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
api: 'lyra',
|
|
28
|
+
resource: '/spaces',
|
|
29
|
+
})
|
|
29
30
|
.then((res) => res.body.items);
|
|
30
31
|
},
|
|
31
32
|
|
|
@@ -37,17 +38,18 @@ const Space = WebexPlugin.extend({
|
|
|
37
38
|
* @returns {Promise<LyraSpace>} response body
|
|
38
39
|
*/
|
|
39
40
|
get(space = {}) {
|
|
40
|
-
const spaceId = space.id || space.identity && space.identity.id;
|
|
41
|
+
const spaceId = space.id || (space.identity && space.identity.id);
|
|
41
42
|
|
|
42
43
|
if (!spaceId) {
|
|
43
44
|
return Promise.reject(new Error('space.id is required'));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
return this.webex
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
return this.webex
|
|
48
|
+
.request({
|
|
49
|
+
method: 'GET',
|
|
50
|
+
api: 'lyra',
|
|
51
|
+
resource: `/spaces/${spaceId}`,
|
|
52
|
+
})
|
|
51
53
|
.then((res) => res.body);
|
|
52
54
|
},
|
|
53
55
|
|
|
@@ -62,15 +64,16 @@ const Space = WebexPlugin.extend({
|
|
|
62
64
|
* @returns {Promise}
|
|
63
65
|
*/
|
|
64
66
|
join(space, options) {
|
|
65
|
-
options =
|
|
66
|
-
passType: 'MANUAL'
|
|
67
|
-
|
|
67
|
+
options = {
|
|
68
|
+
passType: 'MANUAL',
|
|
69
|
+
...options,
|
|
70
|
+
};
|
|
68
71
|
|
|
69
72
|
const body = {
|
|
70
73
|
pass: {
|
|
71
|
-
type: options.passType
|
|
74
|
+
type: options.passType,
|
|
72
75
|
},
|
|
73
|
-
deviceUrl: this.webex.internal.device.url
|
|
76
|
+
deviceUrl: this.webex.internal.device.url,
|
|
74
77
|
};
|
|
75
78
|
|
|
76
79
|
if (options.data) {
|
|
@@ -87,7 +90,7 @@ const Space = WebexPlugin.extend({
|
|
|
87
90
|
return this.webex.request({
|
|
88
91
|
method: 'PUT',
|
|
89
92
|
uri: options.uri,
|
|
90
|
-
body
|
|
93
|
+
body,
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -95,7 +98,7 @@ const Space = WebexPlugin.extend({
|
|
|
95
98
|
method: 'PUT',
|
|
96
99
|
api: 'lyra',
|
|
97
100
|
resource: `${space.url}/occupants/@me`,
|
|
98
|
-
body
|
|
101
|
+
body,
|
|
99
102
|
});
|
|
100
103
|
},
|
|
101
104
|
|
|
@@ -113,7 +116,7 @@ const Space = WebexPlugin.extend({
|
|
|
113
116
|
|
|
114
117
|
if (!options.removeAllDevices) {
|
|
115
118
|
const params = {
|
|
116
|
-
deviceUrl: base64.toBase64Url(this.webex.internal.device.url)
|
|
119
|
+
deviceUrl: base64.toBase64Url(this.webex.internal.device.url),
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
uri += `?${querystring.stringify(params)}`;
|
|
@@ -122,7 +125,7 @@ const Space = WebexPlugin.extend({
|
|
|
122
125
|
return this.webex.request({
|
|
123
126
|
method: 'DELETE',
|
|
124
127
|
api: 'lyra',
|
|
125
|
-
resource: uri
|
|
128
|
+
resource: uri,
|
|
126
129
|
});
|
|
127
130
|
},
|
|
128
131
|
|
|
@@ -136,18 +139,17 @@ const Space = WebexPlugin.extend({
|
|
|
136
139
|
verifyOccupant(space, occupantId) {
|
|
137
140
|
const body = {
|
|
138
141
|
pass: {
|
|
139
|
-
type: 'VERIFICATION'
|
|
140
|
-
}
|
|
142
|
+
type: 'VERIFICATION',
|
|
143
|
+
},
|
|
141
144
|
};
|
|
142
145
|
|
|
143
146
|
return this.webex.request({
|
|
144
147
|
method: 'PUT',
|
|
145
148
|
uri: `${space.url}/occupants/${occupantId}`,
|
|
146
|
-
body
|
|
149
|
+
body,
|
|
147
150
|
});
|
|
148
151
|
},
|
|
149
152
|
|
|
150
|
-
|
|
151
153
|
/**
|
|
152
154
|
* Gets the state of bindings in this Lyra space
|
|
153
155
|
* @param {Types~LyraSpace} space
|
|
@@ -155,10 +157,11 @@ const Space = WebexPlugin.extend({
|
|
|
155
157
|
* @returns {Promise<LyraBindings>} bindings response body
|
|
156
158
|
*/
|
|
157
159
|
getCurrentBindings(space) {
|
|
158
|
-
return this.webex
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
return this.webex
|
|
161
|
+
.request({
|
|
162
|
+
method: 'GET',
|
|
163
|
+
uri: `${space.url}/bindings`,
|
|
164
|
+
})
|
|
162
165
|
.then((res) => res.body);
|
|
163
166
|
},
|
|
164
167
|
|
|
@@ -176,7 +179,7 @@ const Space = WebexPlugin.extend({
|
|
|
176
179
|
* @returns {Promise<LyraBindings>} bindings response body
|
|
177
180
|
*/
|
|
178
181
|
bindConversation(space = {}, conversation = {}, options = {}) {
|
|
179
|
-
const spaceId = space.id || space.identity && space.identity.id;
|
|
182
|
+
const spaceId = space.id || (space.identity && space.identity.id);
|
|
180
183
|
|
|
181
184
|
if (!space.url) {
|
|
182
185
|
return Promise.reject(new Error('space.url is required'));
|
|
@@ -199,22 +202,21 @@ const Space = WebexPlugin.extend({
|
|
|
199
202
|
method: 'create',
|
|
200
203
|
uri: '/authorizations',
|
|
201
204
|
resourceUri: `${conversation.kmsResourceObjectUrl}`,
|
|
202
|
-
userIds: [spaceId]
|
|
205
|
+
userIds: [spaceId],
|
|
203
206
|
},
|
|
204
|
-
conversationUrl: conversation.url
|
|
207
|
+
conversationUrl: conversation.url,
|
|
205
208
|
};
|
|
206
209
|
|
|
207
210
|
const request = {
|
|
208
211
|
method: 'POST',
|
|
209
|
-
body
|
|
212
|
+
body,
|
|
210
213
|
};
|
|
211
214
|
|
|
212
215
|
// if options.uri is available use it, since that would have the
|
|
213
216
|
// complete lyra service URL
|
|
214
217
|
if (options.uri) {
|
|
215
218
|
request.uri = options.uri;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
219
|
+
} else {
|
|
218
220
|
request.api = 'lyra';
|
|
219
221
|
request.resource = `${space.url}/bindings`;
|
|
220
222
|
}
|
|
@@ -246,8 +248,8 @@ const Space = WebexPlugin.extend({
|
|
|
246
248
|
api: 'lyra',
|
|
247
249
|
resource,
|
|
248
250
|
body: {
|
|
249
|
-
bindingCleanupAfterCall: true
|
|
250
|
-
}
|
|
251
|
+
bindingCleanupAfterCall: true,
|
|
252
|
+
},
|
|
251
253
|
});
|
|
252
254
|
},
|
|
253
255
|
|
|
@@ -266,7 +268,7 @@ const Space = WebexPlugin.extend({
|
|
|
266
268
|
* @returns {Promise<LyraBindings>} bindings response body
|
|
267
269
|
*/
|
|
268
270
|
unbindConversation(space = {}, conversation = {}, options = {}) {
|
|
269
|
-
const spaceId = space.id || space.identity && space.identity.id;
|
|
271
|
+
const spaceId = space.id || (space.identity && space.identity.id);
|
|
270
272
|
|
|
271
273
|
if (!space.url) {
|
|
272
274
|
return Promise.reject(new Error('space.url is required'));
|
|
@@ -287,29 +289,30 @@ const Space = WebexPlugin.extend({
|
|
|
287
289
|
const parameters = {
|
|
288
290
|
kmsMessage: {
|
|
289
291
|
method: 'delete',
|
|
290
|
-
uri: `${conversation.kmsResourceObjectUrl}/authorizations?${querystring.stringify({
|
|
292
|
+
uri: `${conversation.kmsResourceObjectUrl}/authorizations?${querystring.stringify({
|
|
293
|
+
authId: spaceId,
|
|
294
|
+
})}`,
|
|
291
295
|
},
|
|
292
|
-
conversationUrl: base64.toBase64Url(conversation.url)
|
|
296
|
+
conversationUrl: base64.toBase64Url(conversation.url),
|
|
293
297
|
};
|
|
294
298
|
|
|
295
|
-
return this.webex.internal.encryption.kms.prepareRequest(parameters.kmsMessage)
|
|
296
|
-
.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (options.uri) {
|
|
301
|
-
return this.webex.request({
|
|
302
|
-
method: 'DELETE',
|
|
303
|
-
uri: `${options.uri}?${querystring.stringify(parameters)}`
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
|
|
299
|
+
return this.webex.internal.encryption.kms.prepareRequest(parameters.kmsMessage).then((req) => {
|
|
300
|
+
parameters.kmsMessage = req.wrapped;
|
|
301
|
+
// if options.uri is available use it, since that would have the
|
|
302
|
+
// complete lyra service URL
|
|
303
|
+
if (options.uri) {
|
|
307
304
|
return this.webex.request({
|
|
308
305
|
method: 'DELETE',
|
|
309
|
-
|
|
310
|
-
resource: `${space.url}/bindings?${querystring.stringify(parameters)}`
|
|
306
|
+
uri: `${options.uri}?${querystring.stringify(parameters)}`,
|
|
311
307
|
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return this.webex.request({
|
|
311
|
+
method: 'DELETE',
|
|
312
|
+
api: 'lyra',
|
|
313
|
+
resource: `${space.url}/bindings?${querystring.stringify(parameters)}`,
|
|
312
314
|
});
|
|
315
|
+
});
|
|
313
316
|
},
|
|
314
317
|
|
|
315
318
|
/**
|
|
@@ -323,7 +326,7 @@ const Space = WebexPlugin.extend({
|
|
|
323
326
|
* @returns {Promise<LyraBindings>} bindings response body
|
|
324
327
|
*/
|
|
325
328
|
deleteBinding(space = {}, options = {}) {
|
|
326
|
-
const spaceId = space.id || space.identity && space.identity.id;
|
|
329
|
+
const spaceId = space.id || (space.identity && space.identity.id);
|
|
327
330
|
|
|
328
331
|
if (!space.url) {
|
|
329
332
|
return Promise.reject(new Error('space.url is required'));
|
|
@@ -344,20 +347,21 @@ const Space = WebexPlugin.extend({
|
|
|
344
347
|
const parameters = {
|
|
345
348
|
kmsMessage: {
|
|
346
349
|
method: 'delete',
|
|
347
|
-
uri: `${options.kmsResourceObjectUrl}/authorizations?${querystring.stringify({
|
|
348
|
-
|
|
350
|
+
uri: `${options.kmsResourceObjectUrl}/authorizations?${querystring.stringify({
|
|
351
|
+
authId: spaceId,
|
|
352
|
+
})}`,
|
|
353
|
+
},
|
|
349
354
|
};
|
|
350
355
|
|
|
351
|
-
return this.webex.internal.encryption.kms.prepareRequest(parameters.kmsMessage)
|
|
352
|
-
.
|
|
353
|
-
parameters.kmsMessage = req.wrapped;
|
|
356
|
+
return this.webex.internal.encryption.kms.prepareRequest(parameters.kmsMessage).then((req) => {
|
|
357
|
+
parameters.kmsMessage = req.wrapped;
|
|
354
358
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
});
|
|
359
|
+
return this.webex.request({
|
|
360
|
+
method: 'DELETE',
|
|
361
|
+
uri: `${space.url}/bindings/${options.bindingId}?${querystring.stringify(parameters)}`,
|
|
359
362
|
});
|
|
360
|
-
|
|
363
|
+
});
|
|
364
|
+
},
|
|
361
365
|
});
|
|
362
366
|
|
|
363
367
|
export default Space;
|
|
@@ -24,20 +24,22 @@ describe('plugin-lyra', () => {
|
|
|
24
24
|
before('create lyra machine', function () {
|
|
25
25
|
this.timeout(retry.timeout(20000));
|
|
26
26
|
|
|
27
|
-
return retry(() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
return retry(() =>
|
|
28
|
+
testUsers.create({
|
|
29
|
+
count: 1,
|
|
30
|
+
config: {
|
|
31
|
+
machineType: 'LYRA_SPACE',
|
|
32
|
+
type: 'MACHINE',
|
|
33
|
+
password: `${generateRandomString(32)}d_wA*`,
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
)
|
|
35
37
|
.then((machines) => {
|
|
36
38
|
lyraMachine = machines[0];
|
|
37
39
|
lyraMachine.webex = new WebexCore({
|
|
38
40
|
credentials: {
|
|
39
|
-
authorization: lyraMachine.token
|
|
40
|
-
}
|
|
41
|
+
authorization: lyraMachine.token,
|
|
42
|
+
},
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
// binding to conversation only works with webex board device
|
|
@@ -56,31 +58,37 @@ describe('plugin-lyra', () => {
|
|
|
56
58
|
});
|
|
57
59
|
});
|
|
58
60
|
|
|
59
|
-
before('create users', () =>
|
|
60
|
-
.then((users) => {
|
|
61
|
+
before('create users', () =>
|
|
62
|
+
testUsers.create({count: 2}).then((users) => {
|
|
61
63
|
participants = users;
|
|
62
64
|
spock = participants[0];
|
|
63
65
|
|
|
64
|
-
return Promise.all(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
return Promise.all(
|
|
67
|
+
Array.map(participants, (participant) => {
|
|
68
|
+
participant.webex = new WebexCore({
|
|
69
|
+
credentials: {
|
|
70
|
+
authorization: participant.token,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return participant.webex.internal.mercury.connect();
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
before('create conversation', () =>
|
|
81
|
+
retry(() =>
|
|
82
|
+
participants[0].webex.internal.conversation.create({
|
|
83
|
+
displayName: 'Test Lyra Conversation',
|
|
84
|
+
participants,
|
|
85
|
+
})
|
|
86
|
+
).then((c) => {
|
|
80
87
|
conversation = c;
|
|
81
88
|
|
|
82
89
|
return conversation;
|
|
83
|
-
})
|
|
90
|
+
})
|
|
91
|
+
);
|
|
84
92
|
|
|
85
93
|
describe('#getAudioState', () => {
|
|
86
94
|
let audioState;
|
|
@@ -88,19 +96,19 @@ describe('plugin-lyra', () => {
|
|
|
88
96
|
before('put audio state', () => {
|
|
89
97
|
audioState = {
|
|
90
98
|
volume: {
|
|
91
|
-
level: 2
|
|
99
|
+
level: 2,
|
|
92
100
|
},
|
|
93
101
|
microphones: {
|
|
94
|
-
muted: false
|
|
102
|
+
muted: false,
|
|
95
103
|
},
|
|
96
|
-
deviceUrl: lyraMachine.webex.internal.device.url
|
|
104
|
+
deviceUrl: lyraMachine.webex.internal.device.url,
|
|
97
105
|
};
|
|
98
106
|
|
|
99
107
|
return lyraMachine.webex.internal.lyra.device.putAudioState(lyraMachine.space, audioState);
|
|
100
108
|
});
|
|
101
109
|
|
|
102
|
-
it('returns audio state', () =>
|
|
103
|
-
.then((res) => {
|
|
110
|
+
it('returns audio state', () =>
|
|
111
|
+
lyraMachine.webex.internal.lyra.device.getAudioState(lyraMachine.space).then((res) => {
|
|
104
112
|
assert.equal(res.microphones.muted, audioState.microphones.muted);
|
|
105
113
|
assert.equal(res.volume.level, audioState.volume.level);
|
|
106
114
|
}));
|
|
@@ -108,14 +116,19 @@ describe('plugin-lyra', () => {
|
|
|
108
116
|
|
|
109
117
|
// Skip until we can bind a conversation to lyra space by posting capabilities to Lyra.
|
|
110
118
|
describe.skip('when a call is in progress', () => {
|
|
111
|
-
before('ensure participant joined space', () =>
|
|
112
|
-
.
|
|
113
|
-
|
|
119
|
+
before('ensure participant joined space', () =>
|
|
120
|
+
spock.webex.internal.lyra.space
|
|
121
|
+
.join(lyraSpace)
|
|
122
|
+
.then(() =>
|
|
123
|
+
lyraMachine.webex.internal.lyra.space.verifyOccupant(lyraMachine.space, spock.id)
|
|
124
|
+
)
|
|
125
|
+
.then(() => spock.webex.internal.lyra.space.bindConversation(lyraSpace, conversation))
|
|
126
|
+
);
|
|
114
127
|
|
|
115
128
|
before('make a call', () => {
|
|
116
129
|
const locus = {
|
|
117
130
|
url: conversation.locusUrl,
|
|
118
|
-
correlationId: uuid.v4()
|
|
131
|
+
correlationId: uuid.v4(),
|
|
119
132
|
};
|
|
120
133
|
|
|
121
134
|
return spock.webex.request({
|
|
@@ -124,19 +137,23 @@ describe('plugin-lyra', () => {
|
|
|
124
137
|
body: {
|
|
125
138
|
correlationId: locus.correlationId,
|
|
126
139
|
deviceUrl: spock.webex.internal.device.url,
|
|
127
|
-
localMedias: []
|
|
128
|
-
}
|
|
140
|
+
localMedias: [],
|
|
141
|
+
},
|
|
129
142
|
});
|
|
130
143
|
});
|
|
131
144
|
|
|
132
|
-
after('remove binding', () =>
|
|
133
|
-
|
|
134
|
-
|
|
145
|
+
after('remove binding', () =>
|
|
146
|
+
spock.webex.internal.lyra.space
|
|
147
|
+
.unbindConversation(lyraMachine.space, conversation)
|
|
148
|
+
// After hooks shouldn't be able to break tests
|
|
149
|
+
.catch((err) => console.error(err))
|
|
150
|
+
);
|
|
135
151
|
|
|
136
152
|
it('mutes', () => {
|
|
137
153
|
spock.webex.internal.lyra.device.mute(lyraMachine.space);
|
|
138
154
|
|
|
139
|
-
return lyraMachine.webex.internal.mercury
|
|
155
|
+
return lyraMachine.webex.internal.mercury
|
|
156
|
+
.when('event:lyra.space_audio_microphones_mute_action')
|
|
140
157
|
.then(([event]) => {
|
|
141
158
|
assert.equal(event.data.action, 'mute');
|
|
142
159
|
});
|
|
@@ -145,7 +162,8 @@ describe('plugin-lyra', () => {
|
|
|
145
162
|
it('unmutes', () => {
|
|
146
163
|
spock.webex.internal.lyra.device.unmute(lyraMachine.space);
|
|
147
164
|
|
|
148
|
-
return lyraMachine.webex.internal.mercury
|
|
165
|
+
return lyraMachine.webex.internal.mercury
|
|
166
|
+
.when('event:lyra.space_audio_microphones_mute_action')
|
|
149
167
|
.then(([event]) => {
|
|
150
168
|
assert.equal(event.data.action, 'unMute');
|
|
151
169
|
});
|
|
@@ -154,7 +172,8 @@ describe('plugin-lyra', () => {
|
|
|
154
172
|
it('increases volume', () => {
|
|
155
173
|
spock.webex.internal.lyra.device.increaseVolume(lyraMachine.space);
|
|
156
174
|
|
|
157
|
-
return lyraMachine.webex.internal.mercury
|
|
175
|
+
return lyraMachine.webex.internal.mercury
|
|
176
|
+
.when('event:lyra.space_audio_volume_change_action')
|
|
158
177
|
.then(([event]) => {
|
|
159
178
|
assert.equal(event.data.action, 'increase');
|
|
160
179
|
});
|
|
@@ -163,7 +182,8 @@ describe('plugin-lyra', () => {
|
|
|
163
182
|
it('decreases volume', () => {
|
|
164
183
|
spock.webex.internal.lyra.device.decreaseVolume(lyraMachine.space);
|
|
165
184
|
|
|
166
|
-
return lyraMachine.webex.internal.mercury
|
|
185
|
+
return lyraMachine.webex.internal.mercury
|
|
186
|
+
.when('event:lyra.space_audio_volume_change_action')
|
|
167
187
|
.then(([event]) => {
|
|
168
188
|
assert.equal(event.data.action, 'decrease');
|
|
169
189
|
});
|
|
@@ -172,7 +192,8 @@ describe('plugin-lyra', () => {
|
|
|
172
192
|
it('sets volume', () => {
|
|
173
193
|
spock.webex.internal.lyra.device.setVolume(lyraMachine.space, 2);
|
|
174
194
|
|
|
175
|
-
return lyraMachine.webex.internal.mercury
|
|
195
|
+
return lyraMachine.webex.internal.mercury
|
|
196
|
+
.when('event:lyra.space_audio_volume_set_action')
|
|
176
197
|
.then(([event]) => {
|
|
177
198
|
assert.equal(event.data.level, 2);
|
|
178
199
|
});
|