@webex/plugin-meetings 3.13.0-next.15 → 3.13.0-next.17
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/aiEnableRequest/index.js +1 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/common/events/typed-events-scope.js +135 -0
- package/dist/common/events/typed-events-scope.js.map +1 -0
- package/dist/common/types.js +7 -0
- package/dist/common/types.js.map +1 -0
- package/dist/config.js +1 -1
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -1
- package/dist/e2ee/E2eeController.js +581 -0
- package/dist/e2ee/E2eeController.js.map +1 -0
- package/dist/e2ee/E2eeManager.js +50 -31
- package/dist/e2ee/E2eeManager.js.map +1 -1
- package/dist/e2ee/E2eeSignaling.js +18 -21
- package/dist/e2ee/E2eeSignaling.js.map +1 -1
- package/dist/e2ee/MediaEncryptionService.js +2 -5
- package/dist/e2ee/MediaEncryptionService.js.map +1 -1
- package/dist/e2ee/constants.js +28 -0
- package/dist/e2ee/constants.js.map +1 -0
- package/dist/e2ee/mls.js +85 -67
- package/dist/e2ee/mls.js.map +1 -1
- package/dist/e2ee/types.js +52 -13
- package/dist/e2ee/types.js.map +1 -1
- package/dist/e2ee/wasm.d.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/meeting/index.js +394 -249
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/request.js +69 -58
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/util.js +4 -2
- package/dist/meeting/util.js.map +1 -1
- package/dist/meetings/index.js +87 -61
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/util.js +10 -0
- package/dist/meetings/util.js.map +1 -1
- package/dist/metrics/constants.js +2 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/types/common/events/typed-events-scope.d.ts +73 -0
- package/dist/types/common/types.d.ts +9 -0
- package/dist/types/constants.d.ts +5 -0
- package/dist/types/e2ee/E2eeController.d.ts +130 -0
- package/dist/types/e2ee/E2eeManager.d.ts +26 -6
- package/dist/types/e2ee/E2eeSignaling.d.ts +1 -7
- package/dist/types/e2ee/MediaEncryptionService.d.ts +1 -3
- package/dist/types/e2ee/constants.d.ts +12 -0
- package/dist/types/e2ee/mls.d.ts +16 -10
- package/dist/types/e2ee/types.d.ts +92 -35
- package/dist/types/hashTree/hashTreeParser.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/meeting/index.d.ts +34 -0
- package/dist/types/meeting/util.d.ts +1 -1
- package/dist/types/metrics/constants.d.ts +1 -0
- package/dist/webinar/index.js +1 -1
- package/package.json +22 -22
- package/src/common/events/typed-events-scope.ts +110 -0
- package/src/common/types.ts +10 -0
- package/src/constants.ts +6 -0
- package/src/e2ee/DESIGN.md +363 -0
- package/src/e2ee/E2eeController.ts +487 -0
- package/src/e2ee/E2eeManager.ts +48 -27
- package/src/e2ee/E2eeSignaling.ts +13 -28
- package/src/e2ee/MediaEncryptionService.ts +2 -4
- package/src/e2ee/constants.ts +34 -0
- package/src/e2ee/mls.ts +62 -32
- package/src/e2ee/types.ts +99 -34
- package/src/e2ee/wasm.d.ts +18 -14
- package/src/hashTree/hashTreeParser.ts +1 -1
- package/src/index.ts +1 -0
- package/src/meeting/index.ts +155 -0
- package/src/meeting/request.ts +16 -0
- package/src/meeting/util.ts +2 -1
- package/src/meetings/index.ts +30 -5
- package/src/meetings/util.ts +8 -0
- package/src/metrics/constants.ts +1 -0
- package/test/unit/spec/common/events/typed-events-scope.ts +88 -0
- package/test/unit/spec/e2ee/E2eeController.ts +662 -0
- package/test/unit/spec/e2ee/E2eeManager.ts +53 -29
- package/test/unit/spec/e2ee/E2eeSignaling.ts +19 -10
- package/test/unit/spec/e2ee/mls.ts +84 -32
- package/test/unit/spec/meeting/index.js +662 -0
- package/test/unit/spec/meeting/request.js +35 -0
- package/test/unit/spec/meeting/utils.js +4 -0
- package/test/unit/spec/meetings/index.js +36 -1
- package/test/unit/spec/meetings/utils.js +15 -0
- package/test/utils/webex-config.js +1 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
import 'jsdom-global/register';
|
|
5
|
+
import {assert} from '@webex/test-helper-chai';
|
|
6
|
+
import sinon from 'sinon';
|
|
7
|
+
import E2eeController from '@webex/plugin-meetings/src/e2ee/E2eeController';
|
|
8
|
+
import MLS from '@webex/plugin-meetings/src/e2ee/mls';
|
|
9
|
+
import * as MLSModule from '@webex/plugin-meetings/src/e2ee/mls';
|
|
10
|
+
import E2eeSignaling from '@webex/plugin-meetings/src/e2ee/E2eeSignaling';
|
|
11
|
+
import MeetingsUtil from '@webex/plugin-meetings/src/meetings/util';
|
|
12
|
+
import WasmLoader from '@webex/plugin-meetings/src/common/wasm-loader';
|
|
13
|
+
import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
|
|
14
|
+
import {EVENT_TRIGGERS} from '@webex/plugin-meetings/src/constants';
|
|
15
|
+
import Metrics from '@webex/plugin-meetings/src/metrics';
|
|
16
|
+
import {E2eeState, E2eeValidationResult} from '@webex/plugin-meetings/src/e2ee/types';
|
|
17
|
+
|
|
18
|
+
describe('plugin-meetings', () => {
|
|
19
|
+
describe('E2eeController', () => {
|
|
20
|
+
let webex;
|
|
21
|
+
let meeting;
|
|
22
|
+
let wasmLoader;
|
|
23
|
+
let identityProvider;
|
|
24
|
+
let getLlmChannel;
|
|
25
|
+
let createController;
|
|
26
|
+
let e2ee;
|
|
27
|
+
let events;
|
|
28
|
+
let sessionHandlers;
|
|
29
|
+
let rosterStub;
|
|
30
|
+
let initializeStub;
|
|
31
|
+
let onStub;
|
|
32
|
+
let offStub;
|
|
33
|
+
let joinStub;
|
|
34
|
+
let leaveStub;
|
|
35
|
+
let cleanUpStub;
|
|
36
|
+
let signalingStartStub;
|
|
37
|
+
let signalingStopStub;
|
|
38
|
+
let sendBehavioralMetricStub;
|
|
39
|
+
|
|
40
|
+
const OWN_DEVICE_URL = 'https://wdm.webex.com/device-1';
|
|
41
|
+
const WASM_URL = '/assets/plugin-meetings/e2ee.wasm';
|
|
42
|
+
const GROUP_URL = 'https://mes.webex.com/group-1';
|
|
43
|
+
const LOCUS_URL = 'https://locus.webex.com/locus-1';
|
|
44
|
+
const CREDENTIALS = {privateKey: new Uint8Array([1]), certChain: [new ArrayBuffer(1)]};
|
|
45
|
+
const TRUST_ANCHORS = {webexCaRoots: 'ca', domainNameRoots: '', userIdentityRoots: ''};
|
|
46
|
+
|
|
47
|
+
const emitSession = (event, payload?) => sessionHandlers[event]?.(payload);
|
|
48
|
+
|
|
49
|
+
const makeRosterEntry = ({url, deviceType = 'WEB'}) => ({
|
|
50
|
+
url,
|
|
51
|
+
deviceType,
|
|
52
|
+
displayName: '',
|
|
53
|
+
validationResult: E2eeValidationResult.Success,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const MEDIA_SERVICE = makeRosterEntry({
|
|
57
|
+
url: 'https://ms.webex.com/1',
|
|
58
|
+
deviceType: 'MEDIA_SERVICE',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const addMediaServiceToRoster = () => {
|
|
62
|
+
rosterStub.returns([MEDIA_SERVICE]);
|
|
63
|
+
emitSession('rosterAdded', [MEDIA_SERVICE]);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const resetEventSpies = () => Object.values(events).forEach((spy: any) => spy.resetHistory());
|
|
67
|
+
|
|
68
|
+
const assertSessionTornDown = () => {
|
|
69
|
+
assert.calledOnce(signalingStopStub);
|
|
70
|
+
assert.calledOnce(leaveStub);
|
|
71
|
+
assert.calledOnce(cleanUpStub);
|
|
72
|
+
assert.deepEqual(sessionHandlers, {});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const createDeferred = () => {
|
|
76
|
+
let resolve;
|
|
77
|
+
let reject;
|
|
78
|
+
const promise = new Promise((res, rej) => {
|
|
79
|
+
resolve = res;
|
|
80
|
+
reject = rej;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return {promise, resolve, reject};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
sessionHandlers = {};
|
|
88
|
+
initializeStub = sinon.stub(MLS.prototype, 'initialize');
|
|
89
|
+
joinStub = sinon.stub(MLS.prototype, 'join');
|
|
90
|
+
leaveStub = sinon.stub(MLS.prototype, 'leave');
|
|
91
|
+
cleanUpStub = sinon.stub(MLS.prototype, 'cleanUp');
|
|
92
|
+
rosterStub = sinon.stub(MLS.prototype, 'getRoster').returns([]);
|
|
93
|
+
onStub = sinon.stub(MLS.prototype, 'on').callsFake((event, handler) => {
|
|
94
|
+
sessionHandlers[event] = handler;
|
|
95
|
+
});
|
|
96
|
+
offStub = sinon.stub(MLS.prototype, 'off').callsFake((event) => {
|
|
97
|
+
delete sessionHandlers[event];
|
|
98
|
+
});
|
|
99
|
+
signalingStartStub = sinon.stub(E2eeSignaling.prototype, 'start');
|
|
100
|
+
signalingStopStub = sinon.stub(E2eeSignaling.prototype, 'stop');
|
|
101
|
+
sendBehavioralMetricStub = sinon.stub(Metrics, 'sendBehavioralMetric');
|
|
102
|
+
|
|
103
|
+
wasmLoader = sinon.createStubInstance(WasmLoader);
|
|
104
|
+
wasmLoader.get.resolves({});
|
|
105
|
+
identityProvider = {
|
|
106
|
+
getCredentials: sinon.stub().resolves(CREDENTIALS),
|
|
107
|
+
getTrustAnchors: sinon.stub().returns(TRUST_ANCHORS),
|
|
108
|
+
};
|
|
109
|
+
getLlmChannel = sinon.stub().returns(undefined);
|
|
110
|
+
webex = {
|
|
111
|
+
config: {meetings: {enableE2ee: true, deviceType: 'WEB'}},
|
|
112
|
+
internal: {
|
|
113
|
+
device: {userId: 'user-1', url: OWN_DEVICE_URL},
|
|
114
|
+
mercury: {on: sinon.stub(), off: sinon.stub()},
|
|
115
|
+
},
|
|
116
|
+
request: sinon.stub().resolves({body: ''}),
|
|
117
|
+
};
|
|
118
|
+
meeting = {
|
|
119
|
+
correlationId: 'corr-1',
|
|
120
|
+
locusInfo: {
|
|
121
|
+
url: LOCUS_URL,
|
|
122
|
+
info: {isV2E2EEncrypted: true, mediaEncryptionGroupUrl: GROUP_URL},
|
|
123
|
+
},
|
|
124
|
+
members: {
|
|
125
|
+
selfId: 's1',
|
|
126
|
+
membersCollection: {
|
|
127
|
+
get: (id) => (id === 's1' ? {name: 'Alice'} : undefined),
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
createController = () =>
|
|
132
|
+
new E2eeController({
|
|
133
|
+
context: {
|
|
134
|
+
getCorrelationId: () => meeting.correlationId,
|
|
135
|
+
getLocusInfo: () => meeting.locusInfo,
|
|
136
|
+
getLlmChannel,
|
|
137
|
+
members: meeting.members,
|
|
138
|
+
} as any,
|
|
139
|
+
webex,
|
|
140
|
+
wasmLoader,
|
|
141
|
+
wasmUrl: WASM_URL,
|
|
142
|
+
identityProvider,
|
|
143
|
+
});
|
|
144
|
+
e2ee = createController();
|
|
145
|
+
|
|
146
|
+
events = {
|
|
147
|
+
securityCode: sinon.spy(),
|
|
148
|
+
state: sinon.spy(),
|
|
149
|
+
mediaServices: sinon.spy(),
|
|
150
|
+
failure: sinon.spy(),
|
|
151
|
+
};
|
|
152
|
+
e2ee.on(EVENT_TRIGGERS.MEETING_E2EE_SECURITY_CODE_UPDATED, events.securityCode);
|
|
153
|
+
e2ee.on(EVENT_TRIGGERS.MEETING_E2EE_STATE_CHANGED, events.state);
|
|
154
|
+
e2ee.on(EVENT_TRIGGERS.MEETING_E2EE_MEDIA_SERVICES_CHANGED, events.mediaServices);
|
|
155
|
+
e2ee.on(EVENT_TRIGGERS.MEETING_E2EE_FAILURE, events.failure);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
afterEach(() => {
|
|
159
|
+
sinon.restore();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe('start', () => {
|
|
163
|
+
[
|
|
164
|
+
{
|
|
165
|
+
when: 'WebAssembly is unsupported or disabled',
|
|
166
|
+
setup: () => sinon.stub(MeetingsUtil, 'isE2eeEnabledAndSupported').returns(false),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
when: 'the meeting is not V2 E2E encrypted',
|
|
170
|
+
setup: () => (meeting.locusInfo.info.isV2E2EEncrypted = false),
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
when: 'there is no media-encryption group url',
|
|
174
|
+
setup: () => (meeting.locusInfo.info.mediaEncryptionGroupUrl = undefined),
|
|
175
|
+
},
|
|
176
|
+
{when: 'there is no locus info', setup: () => (meeting.locusInfo = undefined)},
|
|
177
|
+
].forEach(({when, setup}) => {
|
|
178
|
+
it(`is a no-op when ${when}`, async () => {
|
|
179
|
+
setup();
|
|
180
|
+
|
|
181
|
+
await e2ee.start();
|
|
182
|
+
|
|
183
|
+
assert.equal(e2ee.state, E2eeState.Disabled);
|
|
184
|
+
assert.notCalled(identityProvider.getCredentials);
|
|
185
|
+
assert.notCalled(initializeStub);
|
|
186
|
+
assert.notCalled(events.state);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('initializes the session, then starts signaling, then joins', async () => {
|
|
191
|
+
await e2ee.start();
|
|
192
|
+
|
|
193
|
+
assert.calledOnceWithExactly(wasmLoader.get, WASM_URL);
|
|
194
|
+
assert.calledOnceWithExactly(identityProvider.getCredentials, 'user-1');
|
|
195
|
+
assert.calledOnceWithExactly(initializeStub, {
|
|
196
|
+
participantId: 'user-1',
|
|
197
|
+
deviceUrl: OWN_DEVICE_URL,
|
|
198
|
+
deviceType: 'WEB',
|
|
199
|
+
correlationId: 'corr-1',
|
|
200
|
+
displayName: 'Alice',
|
|
201
|
+
serviceUrl: GROUP_URL,
|
|
202
|
+
credentials: CREDENTIALS,
|
|
203
|
+
trustAnchors: TRUST_ANCHORS,
|
|
204
|
+
});
|
|
205
|
+
sinon.assert.callOrder(initializeStub, signalingStartStub, joinStub);
|
|
206
|
+
assert.deepEqual(events.state.args, [[{state: E2eeState.Initializing}], [{state: E2eeState.Joining}]]);
|
|
207
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('uses an empty display name when the self member is unknown', async () => {
|
|
211
|
+
meeting.members.selfId = 'unknown';
|
|
212
|
+
|
|
213
|
+
await e2ee.start();
|
|
214
|
+
|
|
215
|
+
assert.equal(initializeStub.firstCall.args[0].displayName, '');
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('gives MLS the loaded WASM module and a media-encryption service bound to webex.request', async () => {
|
|
219
|
+
const module = {WebE2EE: sinon.stub()};
|
|
220
|
+
|
|
221
|
+
wasmLoader.get.resolves(module);
|
|
222
|
+
const mlsCtorSpy = sinon.spy(MLSModule, 'default');
|
|
223
|
+
|
|
224
|
+
await e2ee.start();
|
|
225
|
+
|
|
226
|
+
assert.calledOnceWithExactly(mlsCtorSpy, {
|
|
227
|
+
httpClient: sinon.match.object,
|
|
228
|
+
module,
|
|
229
|
+
});
|
|
230
|
+
assert.isTrue(mlsCtorSpy.calledWithNew());
|
|
231
|
+
const [{httpClient}] = mlsCtorSpy.firstCall.args;
|
|
232
|
+
|
|
233
|
+
assert.calledOnceWithExactly(wasmLoader.get, WASM_URL);
|
|
234
|
+
|
|
235
|
+
webex.request.resolves({body: {ok: true}});
|
|
236
|
+
const response = await httpClient.request(`${GROUP_URL}/commit`, {a: 1});
|
|
237
|
+
|
|
238
|
+
assert.deepEqual(response, {ok: true});
|
|
239
|
+
assert.calledOnceWithExactly(webex.request, {
|
|
240
|
+
method: 'POST',
|
|
241
|
+
service: 'media-encryption',
|
|
242
|
+
url: `${GROUP_URL}/commit`,
|
|
243
|
+
body: {a: 1},
|
|
244
|
+
});
|
|
245
|
+
assert.equal(webex.request.firstCall.thisValue, webex);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('connects signaling to mercury, the LLM channel of this locus and the MLS session', async () => {
|
|
249
|
+
signalingStartStub.restore();
|
|
250
|
+
const handleEventStub = sinon.stub(MLS.prototype, 'handleEvent');
|
|
251
|
+
const setLlmConnectedBeforeJoinStub = sinon.stub(
|
|
252
|
+
MLS.prototype,
|
|
253
|
+
'setLlmConnectedBeforeJoin'
|
|
254
|
+
);
|
|
255
|
+
const llm = {
|
|
256
|
+
on: sinon.stub(),
|
|
257
|
+
off: sinon.stub(),
|
|
258
|
+
isConnected: sinon.stub().returns(true),
|
|
259
|
+
getLocusUrl: sinon.stub().returns(LOCUS_URL),
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
getLlmChannel.returns(llm);
|
|
263
|
+
|
|
264
|
+
await e2ee.start();
|
|
265
|
+
|
|
266
|
+
assert.calledOnceWithExactly(setLlmConnectedBeforeJoinStub, true);
|
|
267
|
+
|
|
268
|
+
const [event, onMercuryEvent] = webex.internal.mercury.on.firstCall.args;
|
|
269
|
+
|
|
270
|
+
assert.calledWith(llm.on, event, sinon.match.func);
|
|
271
|
+
|
|
272
|
+
onMercuryEvent({data: {type: 'welcome'}});
|
|
273
|
+
|
|
274
|
+
assert.calledOnceWithExactly(
|
|
275
|
+
handleEventStub,
|
|
276
|
+
sinon.match.instanceOf(Uint8Array),
|
|
277
|
+
'mercury'
|
|
278
|
+
);
|
|
279
|
+
assert.equal(
|
|
280
|
+
new TextDecoder().decode(handleEventStub.firstCall.args[0]),
|
|
281
|
+
'{"type":"welcome"}'
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('ignores start while a session is starting or running', async () => {
|
|
286
|
+
await Promise.all([e2ee.start(), e2ee.start()]);
|
|
287
|
+
await e2ee.start();
|
|
288
|
+
|
|
289
|
+
assert.calledOnce(initializeStub);
|
|
290
|
+
assert.calledOnce(joinStub);
|
|
291
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('can start again after stop', async () => {
|
|
295
|
+
await e2ee.start();
|
|
296
|
+
await e2ee.stop();
|
|
297
|
+
|
|
298
|
+
await e2ee.start();
|
|
299
|
+
|
|
300
|
+
assert.calledTwice(initializeStub);
|
|
301
|
+
assert.calledTwice(joinStub);
|
|
302
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
describe('when stopped during startup', () => {
|
|
306
|
+
it('does not create a session if stopped while loading credentials', async () => {
|
|
307
|
+
const credentials = createDeferred();
|
|
308
|
+
|
|
309
|
+
identityProvider.getCredentials.returns(credentials.promise);
|
|
310
|
+
const starting = e2ee.start();
|
|
311
|
+
|
|
312
|
+
await e2ee.stop();
|
|
313
|
+
credentials.resolve(CREDENTIALS);
|
|
314
|
+
await starting;
|
|
315
|
+
|
|
316
|
+
assert.notCalled(initializeStub);
|
|
317
|
+
assert.notCalled(signalingStartStub);
|
|
318
|
+
assert.notCalled(joinStub);
|
|
319
|
+
assert.equal(e2ee.state, E2eeState.Left);
|
|
320
|
+
assert.deepEqual(events.state.args, [[{state: E2eeState.Initializing}], [{state: E2eeState.Left}]]);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('cleans up the initialized session when stopped', async () => {
|
|
324
|
+
await e2ee.start();
|
|
325
|
+
await e2ee.stop();
|
|
326
|
+
|
|
327
|
+
assert.calledOnce(initializeStub);
|
|
328
|
+
assert.calledOnce(leaveStub);
|
|
329
|
+
assert.calledOnce(cleanUpStub);
|
|
330
|
+
assert.deepEqual(sessionHandlers, {});
|
|
331
|
+
assert.calledOnce(signalingStartStub);
|
|
332
|
+
assert.calledOnce(joinStub);
|
|
333
|
+
assert.equal(e2ee.state, E2eeState.Left);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('lets a new start proceed while the cancelled one is still pending', async () => {
|
|
337
|
+
const firstCredentials = createDeferred();
|
|
338
|
+
|
|
339
|
+
identityProvider.getCredentials.onFirstCall().returns(firstCredentials.promise);
|
|
340
|
+
const cancelledStart = e2ee.start();
|
|
341
|
+
|
|
342
|
+
await e2ee.stop();
|
|
343
|
+
await e2ee.start();
|
|
344
|
+
firstCredentials.resolve(CREDENTIALS);
|
|
345
|
+
await cancelledStart;
|
|
346
|
+
|
|
347
|
+
assert.calledOnce(initializeStub);
|
|
348
|
+
assert.calledOnce(joinStub);
|
|
349
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('defers fatal event cleanup until an MLS callback returns during join', async () => {
|
|
354
|
+
joinStub.callsFake(() => {
|
|
355
|
+
emitSession('joinFailure', {reason: 'join_failure'});
|
|
356
|
+
assert.notCalled(leaveStub);
|
|
357
|
+
assert.notCalled(events.failure);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
await e2ee.start();
|
|
361
|
+
|
|
362
|
+
assert.calledOnce(leaveStub);
|
|
363
|
+
assert.calledOnce(joinStub);
|
|
364
|
+
assert.equal(e2ee.state, E2eeState.Failed);
|
|
365
|
+
assert.calledOnceWithExactly(events.failure, {reason: 'join_failure'});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
[
|
|
369
|
+
{
|
|
370
|
+
when: 'the credentials cannot be fetched',
|
|
371
|
+
fail: () => identityProvider.getCredentials.rejects(new Error('CA down')),
|
|
372
|
+
errorMessage: 'CA down',
|
|
373
|
+
sessionCreated: false,
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
when: 'the WASM module fails to load with a non-Error value',
|
|
377
|
+
fail: () => wasmLoader.get.callsFake(() => Promise.reject('boom')),
|
|
378
|
+
errorMessage: 'boom',
|
|
379
|
+
sessionCreated: false,
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
when: 'the locus loses its media-encryption group url during startup',
|
|
383
|
+
fail: () =>
|
|
384
|
+
identityProvider.getCredentials.callsFake(async () => {
|
|
385
|
+
meeting.locusInfo.info.mediaEncryptionGroupUrl = undefined;
|
|
386
|
+
|
|
387
|
+
return CREDENTIALS;
|
|
388
|
+
}),
|
|
389
|
+
errorMessage: 'Meeting locus has no media encryption group URL',
|
|
390
|
+
sessionCreated: false,
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
when: 'the MLS session fails to initialize',
|
|
394
|
+
fail: () => initializeStub.throws(new Error('MLS init failed')),
|
|
395
|
+
errorMessage: 'MLS init failed',
|
|
396
|
+
sessionCreated: true,
|
|
397
|
+
},
|
|
398
|
+
].forEach(({when, fail, errorMessage, sessionCreated}) => {
|
|
399
|
+
it(`fails and reports startFailed when ${when}`, async () => {
|
|
400
|
+
fail();
|
|
401
|
+
|
|
402
|
+
await e2ee.start();
|
|
403
|
+
|
|
404
|
+
assert.equal(e2ee.state, E2eeState.Failed);
|
|
405
|
+
assert.deepEqual(events.state.args, [[{state: E2eeState.Initializing}], [{state: E2eeState.Failed}]]);
|
|
406
|
+
assert.calledOnceWithExactly(events.failure, {reason: 'startFailed', errorMessage});
|
|
407
|
+
assert.calledOnceWithExactly(sendBehavioralMetricStub, 'js_sdk_e2ee_failure', {
|
|
408
|
+
correlation_id: 'corr-1',
|
|
409
|
+
state: E2eeState.Failed,
|
|
410
|
+
reason: 'startFailed',
|
|
411
|
+
errorMessage,
|
|
412
|
+
});
|
|
413
|
+
assert.notCalled(signalingStartStub);
|
|
414
|
+
assert.notCalled(joinStub);
|
|
415
|
+
assert.equal(leaveStub.callCount, sessionCreated ? 1 : 0);
|
|
416
|
+
assert.deepEqual(sessionHandlers, {});
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
describe('llmChannelChanged', () => {
|
|
422
|
+
let setLlmChannelStub;
|
|
423
|
+
|
|
424
|
+
beforeEach(() => {
|
|
425
|
+
setLlmChannelStub = sinon.stub(E2eeSignaling.prototype, 'setLlmChannel');
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it('is a no-op before start', () => {
|
|
429
|
+
e2ee.llmChannelChanged();
|
|
430
|
+
|
|
431
|
+
assert.notCalled(setLlmChannelStub);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it('passes the current LLM channel to signaling', async () => {
|
|
435
|
+
const replacementLlm = {id: 'replacement'};
|
|
436
|
+
|
|
437
|
+
await e2ee.start();
|
|
438
|
+
|
|
439
|
+
getLlmChannel.returns(replacementLlm);
|
|
440
|
+
e2ee.llmChannelChanged();
|
|
441
|
+
getLlmChannel.returns(undefined);
|
|
442
|
+
e2ee.llmChannelChanged();
|
|
443
|
+
|
|
444
|
+
assert.deepEqual(setLlmChannelStub.args, [[replacementLlm], [undefined]]);
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
describe('session events', () => {
|
|
449
|
+
beforeEach(async () => {
|
|
450
|
+
await e2ee.start();
|
|
451
|
+
resetEventSpies();
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('records the security code on joinSuccess without changing the join state', () => {
|
|
455
|
+
emitSession('joinSuccess', {securityCode: 'SEC-1'});
|
|
456
|
+
|
|
457
|
+
assert.equal(e2ee.getSecurityCode(), 'SEC-1');
|
|
458
|
+
assert.calledOnceWithExactly(events.securityCode, {securityCode: 'SEC-1'});
|
|
459
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
460
|
+
assert.notCalled(rosterStub);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it('updates the security code on securityCodeChanged', () => {
|
|
464
|
+
emitSession('securityCodeChanged', {code: 'SEC-2'});
|
|
465
|
+
|
|
466
|
+
assert.equal(e2ee.getSecurityCode(), 'SEC-2');
|
|
467
|
+
assert.calledOnceWithExactly(events.securityCode, {securityCode: 'SEC-2'});
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it('marks joined only once our own device url is in the roster', () => {
|
|
471
|
+
emitSession('rosterAdded', [makeRosterEntry({url: 'https://wdm.webex.com/other'})]);
|
|
472
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
473
|
+
|
|
474
|
+
emitSession('rosterAdded', [makeRosterEntry({url: OWN_DEVICE_URL})]);
|
|
475
|
+
assert.equal(e2ee.state, E2eeState.Joined);
|
|
476
|
+
assert.calledOnceWithExactly(events.state, {state: E2eeState.Joined});
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
it('uses roster changes without reading the full roster', async () => {
|
|
480
|
+
await e2ee.start();
|
|
481
|
+
emitSession('rosterAdded', [
|
|
482
|
+
MEDIA_SERVICE,
|
|
483
|
+
makeRosterEntry({url: OWN_DEVICE_URL}),
|
|
484
|
+
]);
|
|
485
|
+
|
|
486
|
+
assert.equal(e2ee.state, E2eeState.Joined);
|
|
487
|
+
assert.isTrue(e2ee.hasUntrustedMediaServices);
|
|
488
|
+
assert.notCalled(rosterStub);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
it('emits a media-services change only when their presence in the roster changes', () => {
|
|
492
|
+
assert.isFalse(e2ee.hasUntrustedMediaServices);
|
|
493
|
+
|
|
494
|
+
const anotherMediaService = makeRosterEntry({
|
|
495
|
+
url: 'https://ms.webex.com/2',
|
|
496
|
+
deviceType: 'MEDIA_SERVICE',
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
emitSession('rosterAdded', [MEDIA_SERVICE, anotherMediaService]);
|
|
500
|
+
assert.isTrue(e2ee.hasUntrustedMediaServices);
|
|
501
|
+
|
|
502
|
+
emitSession('rosterRemoved', {urls: [MEDIA_SERVICE.url]});
|
|
503
|
+
assert.isTrue(e2ee.hasUntrustedMediaServices);
|
|
504
|
+
|
|
505
|
+
emitSession('rosterRemoved', {urls: [anotherMediaService.url]});
|
|
506
|
+
assert.isFalse(e2ee.hasUntrustedMediaServices);
|
|
507
|
+
|
|
508
|
+
assert.deepEqual(events.mediaServices.args, [
|
|
509
|
+
[{hasMediaServices: true}],
|
|
510
|
+
[{hasMediaServices: false}],
|
|
511
|
+
]);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
[
|
|
515
|
+
{
|
|
516
|
+
event: 'joinFailure',
|
|
517
|
+
payload: {reason: 'join_failure'},
|
|
518
|
+
state: E2eeState.Failed,
|
|
519
|
+
reason: 'join_failure',
|
|
520
|
+
details: {},
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
event: 'mediaEncryptionServiceFailure',
|
|
524
|
+
payload: {errorCode: 78400011, message: 'not leader'},
|
|
525
|
+
state: E2eeState.Failed,
|
|
526
|
+
reason: 'mediaEncryptionServiceFailure',
|
|
527
|
+
details: {errorCode: 78400011, errorMessage: 'not leader'},
|
|
528
|
+
},
|
|
529
|
+
{event: 'evicted', payload: undefined, state: E2eeState.Evicted, reason: 'evicted', details: {}},
|
|
530
|
+
].forEach(({event, payload, state, reason, details}) => {
|
|
531
|
+
it(`tears down the session, moves to ${state} and reports a failure on ${event}`, async () => {
|
|
532
|
+
emitSession('joinSuccess', {securityCode: 'SEC-1'});
|
|
533
|
+
resetEventSpies();
|
|
534
|
+
|
|
535
|
+
emitSession(event, payload);
|
|
536
|
+
await Promise.resolve();
|
|
537
|
+
|
|
538
|
+
assertSessionTornDown();
|
|
539
|
+
assert.equal(e2ee.state, state);
|
|
540
|
+
assert.isUndefined(e2ee.getSecurityCode());
|
|
541
|
+
assert.calledOnceWithExactly(events.securityCode, {securityCode: undefined});
|
|
542
|
+
assert.calledOnceWithExactly(events.state, {state});
|
|
543
|
+
assert.calledOnceWithExactly(events.failure, {reason, ...details});
|
|
544
|
+
assert.calledOnceWithExactly(sendBehavioralMetricStub, 'js_sdk_e2ee_failure', {
|
|
545
|
+
correlation_id: 'corr-1',
|
|
546
|
+
state,
|
|
547
|
+
reason,
|
|
548
|
+
...details,
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
it(`creates a fresh session when started again after ${event}`, async () => {
|
|
553
|
+
const failedSession = initializeStub.firstCall.thisValue;
|
|
554
|
+
|
|
555
|
+
emitSession(event, payload);
|
|
556
|
+
await Promise.resolve();
|
|
557
|
+
resetEventSpies();
|
|
558
|
+
|
|
559
|
+
await e2ee.start();
|
|
560
|
+
|
|
561
|
+
assert.calledTwice(initializeStub);
|
|
562
|
+
assert.notStrictEqual(initializeStub.secondCall.thisValue, failedSession);
|
|
563
|
+
assert.calledTwice(joinStub);
|
|
564
|
+
assert.equal(e2ee.state, E2eeState.Joining);
|
|
565
|
+
assert.deepEqual(events.state.args, [[{state: E2eeState.Initializing}], [{state: E2eeState.Joining}]]);
|
|
566
|
+
assert.notCalled(events.failure);
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it('ignores start once joined', async () => {
|
|
571
|
+
await e2ee.start();
|
|
572
|
+
emitSession('rosterAdded', [makeRosterEntry({url: OWN_DEVICE_URL})]);
|
|
573
|
+
|
|
574
|
+
await e2ee.start();
|
|
575
|
+
|
|
576
|
+
assert.calledOnce(initializeStub);
|
|
577
|
+
assert.equal(e2ee.state, E2eeState.Joined);
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
describe('stop', () => {
|
|
582
|
+
it('is a silent no-op when E2EE was never started', async () => {
|
|
583
|
+
const loggerInfoStub = sinon.stub();
|
|
584
|
+
|
|
585
|
+
// Replace the whole logger: other specs install loggers whose methods are already sinon
|
|
586
|
+
// stubs, so stubbing LoggerProxy.logger.info directly fails depending on test order.
|
|
587
|
+
sinon.stub(LoggerProxy, 'logger').value({...LoggerProxy.logger, info: loggerInfoStub});
|
|
588
|
+
|
|
589
|
+
await e2ee.stop();
|
|
590
|
+
|
|
591
|
+
assert.equal(e2ee.state, E2eeState.Disabled);
|
|
592
|
+
assert.notCalled(signalingStopStub);
|
|
593
|
+
assert.notCalled(leaveStub);
|
|
594
|
+
assert.notCalled(events.state);
|
|
595
|
+
assert.notCalled(loggerInfoStub);
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
it('tears down the session and moves to left without reporting a failure', async () => {
|
|
599
|
+
await e2ee.start();
|
|
600
|
+
emitSession('joinSuccess', {securityCode: 'SEC-1'});
|
|
601
|
+
resetEventSpies();
|
|
602
|
+
|
|
603
|
+
await e2ee.stop();
|
|
604
|
+
|
|
605
|
+
assertSessionTornDown();
|
|
606
|
+
assert.equal(e2ee.state, E2eeState.Left);
|
|
607
|
+
assert.isUndefined(e2ee.getSecurityCode());
|
|
608
|
+
assert.calledOnceWithExactly(events.securityCode, {securityCode: undefined});
|
|
609
|
+
assert.calledOnceWithExactly(events.state, {state: E2eeState.Left});
|
|
610
|
+
assert.notCalled(events.failure);
|
|
611
|
+
assert.notCalled(sendBehavioralMetricStub);
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
it('reports media services gone when they were present', async () => {
|
|
615
|
+
await e2ee.start();
|
|
616
|
+
addMediaServiceToRoster();
|
|
617
|
+
resetEventSpies();
|
|
618
|
+
|
|
619
|
+
await e2ee.stop();
|
|
620
|
+
|
|
621
|
+
assert.isFalse(e2ee.hasUntrustedMediaServices);
|
|
622
|
+
assert.calledOnceWithExactly(events.mediaServices, {hasMediaServices: false});
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
it('does nothing when called again', async () => {
|
|
626
|
+
await e2ee.start();
|
|
627
|
+
await e2ee.stop();
|
|
628
|
+
signalingStopStub.resetHistory();
|
|
629
|
+
leaveStub.resetHistory();
|
|
630
|
+
resetEventSpies();
|
|
631
|
+
|
|
632
|
+
await e2ee.stop();
|
|
633
|
+
|
|
634
|
+
assert.equal(e2ee.state, E2eeState.Left);
|
|
635
|
+
assert.notCalled(signalingStopStub);
|
|
636
|
+
assert.notCalled(leaveStub);
|
|
637
|
+
assert.notCalled(events.state);
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
[
|
|
641
|
+
{step: 'signaling.stop', fail: () => signalingStopStub.throws(new Error('stop failed'))},
|
|
642
|
+
{step: 'session.off', fail: () => offStub.throws(new Error('off failed'))},
|
|
643
|
+
{step: 'session.leave', fail: () => leaveStub.throws(new Error('leave failed'))},
|
|
644
|
+
].forEach(({step, fail}) => {
|
|
645
|
+
it(`still completes cleanup when ${step} throws`, async () => {
|
|
646
|
+
await e2ee.start();
|
|
647
|
+
addMediaServiceToRoster();
|
|
648
|
+
resetEventSpies();
|
|
649
|
+
fail();
|
|
650
|
+
|
|
651
|
+
await e2ee.stop();
|
|
652
|
+
|
|
653
|
+
assert.calledOnce(signalingStopStub);
|
|
654
|
+
assert.calledOnce(leaveStub);
|
|
655
|
+
assert.equal(offStub.callCount, onStub.callCount);
|
|
656
|
+
assert.calledOnceWithExactly(events.mediaServices, {hasMediaServices: false});
|
|
657
|
+
assert.equal(e2ee.state, E2eeState.Left);
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
});
|