@webex/plugin-meetings 3.13.0-next.6 → 3.13.0-next.8
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/config.js +1 -1
- package/dist/e2ee/E2eeSignaling.js +200 -0
- package/dist/e2ee/E2eeSignaling.js.map +1 -0
- package/dist/e2ee/MediaEncryptionService.js +75 -0
- package/dist/e2ee/MediaEncryptionService.js.map +1 -0
- package/dist/e2ee/mls.js +558 -0
- package/dist/e2ee/mls.js.map +1 -0
- package/dist/e2ee/types.js +59 -0
- package/dist/e2ee/types.js.map +1 -0
- package/dist/e2ee/wasm.d.js +7 -0
- package/dist/e2ee/wasm.d.js.map +1 -0
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/types/e2ee/E2eeSignaling.d.ts +94 -0
- package/dist/types/e2ee/MediaEncryptionService.d.ts +27 -0
- package/dist/types/e2ee/mls.d.ts +191 -0
- package/dist/types/e2ee/types.d.ts +104 -0
- package/dist/webinar/index.js +1 -1
- package/package.json +1 -1
- package/src/e2ee/E2eeSignaling.ts +215 -0
- package/src/e2ee/MediaEncryptionService.ts +41 -0
- package/src/e2ee/mls.ts +548 -0
- package/src/e2ee/types.ts +114 -0
- package/src/e2ee/wasm.d.ts +153 -0
- package/test/unit/spec/e2ee/E2eeSignaling.ts +172 -0
- package/test/unit/spec/e2ee/MediaEncryptionService.ts +43 -0
- package/test/unit/spec/e2ee/mls.ts +769 -0
package/src/e2ee/mls.ts
ADDED
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import EventEmitter from 'events';
|
|
6
|
+
|
|
7
|
+
import LoggerProxy from '../common/logs/logger-proxy';
|
|
8
|
+
import type {
|
|
9
|
+
E2eeKey,
|
|
10
|
+
E2eeRosterMember,
|
|
11
|
+
E2eeSignalingSource,
|
|
12
|
+
IMlsHttpClient,
|
|
13
|
+
MLSConfig,
|
|
14
|
+
SframeParams,
|
|
15
|
+
} from './types';
|
|
16
|
+
import type {
|
|
17
|
+
EpochInfo,
|
|
18
|
+
HTTPRequest,
|
|
19
|
+
ModuleInstance,
|
|
20
|
+
RosterMember,
|
|
21
|
+
Transaction,
|
|
22
|
+
TransactionResult,
|
|
23
|
+
WebE2EEInstance,
|
|
24
|
+
} from './wasm';
|
|
25
|
+
|
|
26
|
+
const DEFAULT_JOIN_TIMEOUT = 180_000;
|
|
27
|
+
const DEFAULT_COALESCE_WINDOW = 500;
|
|
28
|
+
const DEFAULT_DEVICE_TYPE = 'WEB';
|
|
29
|
+
|
|
30
|
+
// WASM log levels, indexed by the numeric level the engine emits (see LogLevel in libe2ee).
|
|
31
|
+
const WASM_LOG_LEVELS = ['', 'FATAL', 'ERROR', 'WARN', 'INFO', 'DEBUG'];
|
|
32
|
+
|
|
33
|
+
/** Payloads for each event emitted by {@link MLS}. */
|
|
34
|
+
export interface MLSEventMap {
|
|
35
|
+
joinSuccess: {epoch: number; securityCode: string; sframe: SframeParams; key: E2eeKey};
|
|
36
|
+
joinFailure: {reason: string};
|
|
37
|
+
mediaEncryptionRequestFailure: {errorCode: number; message: string};
|
|
38
|
+
newKey: E2eeKey;
|
|
39
|
+
useKey: {epoch: number};
|
|
40
|
+
purgeKeys: {epoch: number};
|
|
41
|
+
rosterAdded: E2eeRosterMember[];
|
|
42
|
+
rosterRemoved: {urls: string[]};
|
|
43
|
+
leaderChanged: {isLeader: boolean};
|
|
44
|
+
evicted: void;
|
|
45
|
+
versionNegotiated: {version: number};
|
|
46
|
+
securityCodeChanged: {code: string};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type MLSEvent = keyof MLSEventMap;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Pure MLS protocol engine wrapping the WebE2EE WASM module. It has no webex/HTTP/LLM
|
|
53
|
+
* dependencies: all I/O flows through the injected {@link IMlsHttpClient}, and all outputs are
|
|
54
|
+
* emitted as typed events. This keeps it unit-testable in isolation.
|
|
55
|
+
*/
|
|
56
|
+
export default class MLS {
|
|
57
|
+
private readonly loadModule: () => Promise<ModuleInstance>;
|
|
58
|
+
|
|
59
|
+
private readonly httpClient: IMlsHttpClient;
|
|
60
|
+
|
|
61
|
+
private readonly emitter = new EventEmitter();
|
|
62
|
+
|
|
63
|
+
private readonly transactions = new Map<string, Transaction['type']>();
|
|
64
|
+
|
|
65
|
+
private e2ee: WebE2EEInstance | null = null;
|
|
66
|
+
|
|
67
|
+
private lastSecurityCode = '';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {Object} deps
|
|
71
|
+
* @param {IMlsHttpClient} deps.httpClient - Transport for the engine's protocol requests.
|
|
72
|
+
* @param {Function} deps.loadModule - Loads the WASM module instance; supplied by the integration layer.
|
|
73
|
+
*/
|
|
74
|
+
constructor({
|
|
75
|
+
httpClient,
|
|
76
|
+
loadModule,
|
|
77
|
+
}: {
|
|
78
|
+
httpClient: IMlsHttpClient;
|
|
79
|
+
loadModule: () => Promise<ModuleInstance>;
|
|
80
|
+
}) {
|
|
81
|
+
this.httpClient = httpClient;
|
|
82
|
+
this.loadModule = loadModule;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Subscribe to an engine event.
|
|
87
|
+
* @param {MLSEvent} event
|
|
88
|
+
* @param {Function} listener
|
|
89
|
+
* @returns {void}
|
|
90
|
+
*/
|
|
91
|
+
on<K extends MLSEvent>(event: K, listener: (payload: MLSEventMap[K]) => void): void {
|
|
92
|
+
this.emitter.on(event, listener as (payload: unknown) => void);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Unsubscribe from an engine event.
|
|
97
|
+
* @param {MLSEvent} event
|
|
98
|
+
* @param {Function} listener
|
|
99
|
+
* @returns {void}
|
|
100
|
+
*/
|
|
101
|
+
off<K extends MLSEvent>(event: K, listener: (payload: MLSEventMap[K]) => void): void {
|
|
102
|
+
this.emitter.off(event, listener as (payload: unknown) => void);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {MLSEvent} event
|
|
107
|
+
* @param {*} [payload]
|
|
108
|
+
* @returns {void}
|
|
109
|
+
*/
|
|
110
|
+
private emitEvent<K extends MLSEvent>(event: K, payload?: MLSEventMap[K]): void {
|
|
111
|
+
LoggerProxy.logger.info(`e2ee: MLS --> emitting event: ${event}`);
|
|
112
|
+
this.emitter.emit(event, payload);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Loads the WASM module, instantiates the engine, wires its callbacks, and applies credentials,
|
|
117
|
+
* trust anchors and timeouts. Must be called before {@link join}.
|
|
118
|
+
* @param {MLSConfig} config
|
|
119
|
+
* @returns {Promise<void>}
|
|
120
|
+
*/
|
|
121
|
+
async initialize(config: MLSConfig): Promise<void> {
|
|
122
|
+
LoggerProxy.logger.info('e2ee: MLS --> initialize: loading WASM and instantiating engine');
|
|
123
|
+
const module = await this.loadModule();
|
|
124
|
+
|
|
125
|
+
// When loadModule uses WasmLoader.get(), repeated calls share the in-flight promise or return
|
|
126
|
+
// the cached module, so this check can stay after loading.
|
|
127
|
+
if (this.e2ee) {
|
|
128
|
+
LoggerProxy.logger.info('e2ee: MLS --> initialize: already initialized');
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.e2ee = new module.WebE2EE();
|
|
134
|
+
this.setupCallbacks();
|
|
135
|
+
|
|
136
|
+
this.e2ee.initialize(
|
|
137
|
+
config.participantId,
|
|
138
|
+
config.deviceUrl,
|
|
139
|
+
config.deviceType || DEFAULT_DEVICE_TYPE,
|
|
140
|
+
config.correlationId,
|
|
141
|
+
config.displayName,
|
|
142
|
+
config.serviceUrl
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
if (config.credentials) {
|
|
146
|
+
const {privateKey, certChain} = config.credentials;
|
|
147
|
+
|
|
148
|
+
this.e2ee.addX509Credential(privateKey, certChain);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (config.trustAnchors) {
|
|
152
|
+
this.e2ee.setTrustAnchors(
|
|
153
|
+
config.trustAnchors.webexCaRoots || '',
|
|
154
|
+
config.trustAnchors.domainNameRoots || '',
|
|
155
|
+
config.trustAnchors.userIdentityRoots || '',
|
|
156
|
+
config.trustAnchors.domainNameRootsP7b || new Uint8Array()
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
this.e2ee.setJoinTimeout(config.joinTimeout ?? DEFAULT_JOIN_TIMEOUT);
|
|
161
|
+
this.e2ee.setCoalesceWindow(config.coalesceWindow ?? DEFAULT_COALESCE_WINDOW);
|
|
162
|
+
|
|
163
|
+
LoggerProxy.logger.info('e2ee: MLS --> initialize: engine initialized');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @returns {void}
|
|
168
|
+
*/
|
|
169
|
+
private setupCallbacks(): void {
|
|
170
|
+
const {e2ee} = this;
|
|
171
|
+
|
|
172
|
+
if (!e2ee) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
e2ee.setOnNewTransaction(({id, type}: Transaction) => {
|
|
177
|
+
this.transactions.set(id, type);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
e2ee.setOnCompleteTransaction((id, result: TransactionResult) => {
|
|
181
|
+
const transactionType = this.transactions.get(id);
|
|
182
|
+
|
|
183
|
+
if (!transactionType) {
|
|
184
|
+
LoggerProxy.logger.warn(`e2ee: MLS --> completion for unknown transaction (id=${id})`);
|
|
185
|
+
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
this.transactions.delete(id);
|
|
190
|
+
|
|
191
|
+
if (result.status === 'join_success') {
|
|
192
|
+
if (transactionType !== 'join') {
|
|
193
|
+
LoggerProxy.logger.warn(
|
|
194
|
+
`e2ee: MLS --> join success for non-join transaction (id=${id}, type=${transactionType})`
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
this.lastSecurityCode = result.sec_code;
|
|
201
|
+
this.emitEvent('joinSuccess', {
|
|
202
|
+
epoch: result.epoch,
|
|
203
|
+
securityCode: result.sec_code,
|
|
204
|
+
sframe: {
|
|
205
|
+
cipherSuite: result.sframe_cipher_suite,
|
|
206
|
+
epochBits: result.sframe_epoch_bits,
|
|
207
|
+
},
|
|
208
|
+
key: {
|
|
209
|
+
epoch: result.epoch,
|
|
210
|
+
baseKey: new Uint8Array(result.base_key),
|
|
211
|
+
index: result.index,
|
|
212
|
+
indexBits: result.index_bits,
|
|
213
|
+
canEncrypt: false,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
} else if (result.status === 'update_success') {
|
|
217
|
+
if (transactionType !== 'update') {
|
|
218
|
+
LoggerProxy.logger.warn(
|
|
219
|
+
`e2ee: MLS --> update success for non-update transaction (id=${id}, type=${transactionType})`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
} else if (result.status === 'failure') {
|
|
223
|
+
if (transactionType === 'join') {
|
|
224
|
+
this.emitEvent('joinFailure', {reason: result.reason});
|
|
225
|
+
} else {
|
|
226
|
+
LoggerProxy.logger.error(
|
|
227
|
+
`e2ee: MLS --> update transaction failed (id=${id}, reason=${result.reason})`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
e2ee.setOnHttpRequest((request: HTTPRequest) => {
|
|
234
|
+
const {url, handlerId} = request;
|
|
235
|
+
// The body is a view into WASM memory that is only valid during this callback, so copy it now.
|
|
236
|
+
const body = new Uint8Array(request.body);
|
|
237
|
+
|
|
238
|
+
// Complete asynchronously so the engine is never re-entered from inside its own request call.
|
|
239
|
+
Promise.resolve()
|
|
240
|
+
.then(() => this.sendHttpRequest(url, body))
|
|
241
|
+
.then((responseBytes) => {
|
|
242
|
+
this.completeHttpRequest(handlerId, true, responseBytes, 0, '');
|
|
243
|
+
})
|
|
244
|
+
.catch((error) => {
|
|
245
|
+
const errorCode = MLS.getMesErrorCode(error);
|
|
246
|
+
const message = error?.message || 'Request failed';
|
|
247
|
+
|
|
248
|
+
LoggerProxy.logger.warn(
|
|
249
|
+
`e2ee: MLS --> HTTP request failed (url=${url}, errorCode=${errorCode}): ${message}`
|
|
250
|
+
);
|
|
251
|
+
this.completeHttpRequest(handlerId, false, new Uint8Array(0), errorCode, message);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
e2ee.setOnWait((milliseconds, handlerId) => {
|
|
256
|
+
setTimeout(() => {
|
|
257
|
+
this.e2ee?.completeWait(handlerId);
|
|
258
|
+
}, milliseconds);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
e2ee.setOnGotKey((epoch: EpochInfo) => {
|
|
262
|
+
this.emitEvent('newKey', {
|
|
263
|
+
epoch: epoch.epoch,
|
|
264
|
+
baseKey: new Uint8Array(epoch.base_key),
|
|
265
|
+
index: epoch.index,
|
|
266
|
+
indexBits: epoch.index_bits,
|
|
267
|
+
canEncrypt: false,
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
e2ee.setOnUseKey((epoch: number) => {
|
|
272
|
+
this.emitEvent('useKey', {epoch});
|
|
273
|
+
this.emitSecurityCodeIfChanged();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
e2ee.setOnPurgeBefore((epoch: number) => {
|
|
277
|
+
this.emitEvent('purgeKeys', {epoch});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
e2ee.setOnLeader(() => {
|
|
281
|
+
this.emitEvent('leaderChanged', {isLeader: true});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
e2ee.setOnAddRoster((added: RosterMember[]) => {
|
|
285
|
+
this.emitEvent('rosterAdded', added.map(MLS.toRosterMember));
|
|
286
|
+
this.emitSecurityCodeIfChanged();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
e2ee.setOnRemoveRoster((removed: string[]) => {
|
|
290
|
+
this.emitEvent('rosterRemoved', {urls: removed});
|
|
291
|
+
this.emitSecurityCodeIfChanged();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
e2ee.setOnEvicted(() => {
|
|
295
|
+
this.emitEvent('evicted');
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
e2ee.setOnE2eeVersion((version: number) => {
|
|
299
|
+
this.emitEvent('versionNegotiated', {version});
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
e2ee.setOnMissingCommit((mlsEpoch, useKeyEpoch) => {
|
|
303
|
+
LoggerProxy.logger.warn(
|
|
304
|
+
`e2ee: MLS --> missing commit (mlsEpoch=${mlsEpoch}, useKeyEpoch=${useKeyEpoch})`
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
e2ee.setOnLog((level: number, message: string) => {
|
|
309
|
+
const label = WASM_LOG_LEVELS[level] ?? '';
|
|
310
|
+
|
|
311
|
+
switch (level) {
|
|
312
|
+
case 1:
|
|
313
|
+
case 2:
|
|
314
|
+
LoggerProxy.logger.error(`e2ee: [E2EE ${label}] ${message}`);
|
|
315
|
+
break;
|
|
316
|
+
case 3:
|
|
317
|
+
LoggerProxy.logger.warn(`e2ee: [E2EE ${label}] ${message}`);
|
|
318
|
+
break;
|
|
319
|
+
case 5:
|
|
320
|
+
LoggerProxy.logger.debug(`e2ee: [E2EE ${label}] ${message}`);
|
|
321
|
+
break;
|
|
322
|
+
default:
|
|
323
|
+
LoggerProxy.logger.info(`e2ee: [E2EE ${label}] ${message}`);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Sends an engine HTTP request through the injected {@link IMlsHttpClient}, converting between
|
|
330
|
+
* the engine's JSON bytes and the client's objects. Conversion failures reject so the engine's
|
|
331
|
+
* request is completed as failed.
|
|
332
|
+
* @param {string} url - The absolute request URL provided by the engine.
|
|
333
|
+
* @param {Uint8Array} body - JSON request payload as bytes (owned copy, not a WASM memory view).
|
|
334
|
+
* @returns {Promise<Uint8Array>} JSON response payload as bytes.
|
|
335
|
+
*/
|
|
336
|
+
private async sendHttpRequest(url: string, body: Uint8Array): Promise<Uint8Array> {
|
|
337
|
+
const requestBody = MLS.decodeRequestBody(url, body);
|
|
338
|
+
const response = await this.httpClient.request(url, requestBody);
|
|
339
|
+
|
|
340
|
+
return MLS.encodeResponseBody(url, response);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @param {string} url - Request URL, used only for logging.
|
|
345
|
+
* @param {Uint8Array} body - JSON request payload as bytes.
|
|
346
|
+
* @returns {unknown} the parsed request body.
|
|
347
|
+
* @throws {Error} when the bytes are not valid JSON.
|
|
348
|
+
*/
|
|
349
|
+
private static decodeRequestBody(url: string, body: Uint8Array): unknown {
|
|
350
|
+
try {
|
|
351
|
+
return JSON.parse(new TextDecoder().decode(body));
|
|
352
|
+
} catch (error) {
|
|
353
|
+
LoggerProxy.logger.error(
|
|
354
|
+
`e2ee: MLS --> failed to parse engine HTTP request body as JSON (url=${url}): ${error?.message}`
|
|
355
|
+
);
|
|
356
|
+
throw new Error(`Invalid JSON in HTTP request body: ${error?.message}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @param {string} url - Request URL, used only for logging.
|
|
362
|
+
* @param {unknown} response - Response object from the HTTP client.
|
|
363
|
+
* @returns {Uint8Array} the response serialized as JSON bytes.
|
|
364
|
+
* @throws {Error} when the response cannot be serialized to JSON.
|
|
365
|
+
*/
|
|
366
|
+
private static encodeResponseBody(url: string, response: unknown): Uint8Array {
|
|
367
|
+
try {
|
|
368
|
+
return new TextEncoder().encode(JSON.stringify(response));
|
|
369
|
+
} catch (error) {
|
|
370
|
+
LoggerProxy.logger.error(
|
|
371
|
+
`e2ee: MLS --> failed to serialize HTTP response body as JSON (url=${url}): ${error?.message}`
|
|
372
|
+
);
|
|
373
|
+
throw new Error(`Unserializable HTTP response body: ${error?.message}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Hands a media-encryption service request outcome back to the engine. libe2ee throws
|
|
379
|
+
* `e2ee_negotiation_failure` out of this call when it can't recover from the service's error code
|
|
380
|
+
* or fails to process a successful response; this surfaces in JS as an opaque value with no
|
|
381
|
+
* message. That is unrecoverable for the in-flight operation, so it is reported as
|
|
382
|
+
* `mediaEncryptionRequestFailure` instead of escaping as an unhandled rejection.
|
|
383
|
+
* @param {number} handlerId
|
|
384
|
+
* @param {boolean} success
|
|
385
|
+
* @param {Uint8Array} body
|
|
386
|
+
* @param {number} errorCode - Media-encryption service error code, or 0 when not applicable.
|
|
387
|
+
* @param {string} message
|
|
388
|
+
* @returns {void}
|
|
389
|
+
*/
|
|
390
|
+
private completeHttpRequest(
|
|
391
|
+
handlerId: number,
|
|
392
|
+
success: boolean,
|
|
393
|
+
body: Uint8Array,
|
|
394
|
+
errorCode: number,
|
|
395
|
+
message: string
|
|
396
|
+
): void {
|
|
397
|
+
try {
|
|
398
|
+
this.e2ee?.completeHttpRequest(handlerId, success, body, errorCode, message);
|
|
399
|
+
} catch (error) {
|
|
400
|
+
LoggerProxy.logger.error(
|
|
401
|
+
`e2ee: MLS --> engine threw while completing HTTP request (success=${success}, errorCode=${errorCode}): ${error}`
|
|
402
|
+
);
|
|
403
|
+
this.emitEvent('mediaEncryptionRequestFailure', {
|
|
404
|
+
errorCode,
|
|
405
|
+
message: success ? 'Engine failed to process HTTP response' : message,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* @param {*} error - Rejection from the HTTP client.
|
|
412
|
+
* @returns {number} the media-encryption service error code from the response body, or 0.
|
|
413
|
+
*/
|
|
414
|
+
private static getMesErrorCode(error: any): number {
|
|
415
|
+
const errorCode = error?.body?.errorCode;
|
|
416
|
+
|
|
417
|
+
return Number.isInteger(errorCode) ? errorCode : 0;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @returns {void}
|
|
422
|
+
*/
|
|
423
|
+
private emitSecurityCodeIfChanged(): void {
|
|
424
|
+
const code = this.getSecurityCode();
|
|
425
|
+
|
|
426
|
+
if (code && code !== this.lastSecurityCode) {
|
|
427
|
+
this.lastSecurityCode = code;
|
|
428
|
+
this.emitEvent('securityCodeChanged', {code});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Starts the MLS join.
|
|
434
|
+
* @returns {void}
|
|
435
|
+
*/
|
|
436
|
+
join(): void {
|
|
437
|
+
LoggerProxy.logger.info('e2ee: MLS --> join: starting MLS join');
|
|
438
|
+
this.assertInitialized().join();
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Leaves the MLS group.
|
|
443
|
+
* @returns {void}
|
|
444
|
+
*/
|
|
445
|
+
leave(): void {
|
|
446
|
+
LoggerProxy.logger.info('e2ee: MLS --> leave: leaving MLS group');
|
|
447
|
+
this.transactions.clear();
|
|
448
|
+
this.assertInitialized().leave();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Forwards an incoming MLS protocol event (from the signaling channel) to the engine.
|
|
453
|
+
* @param {Uint8Array} eventData
|
|
454
|
+
* @param {E2eeSignalingSource} source - Which channel the event arrived on, logged for diagnostics.
|
|
455
|
+
* @returns {void}
|
|
456
|
+
*/
|
|
457
|
+
handleEvent(eventData: Uint8Array, source: E2eeSignalingSource): void {
|
|
458
|
+
LoggerProxy.logger.info(
|
|
459
|
+
`e2ee: MLS --> handleEvent: forwarding ${eventData.length} bytes from ${source} to engine`
|
|
460
|
+
);
|
|
461
|
+
this.assertInitialized().handle(new Uint8Array(eventData));
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Tells the engine whether the signaling channel was already connected before join.
|
|
466
|
+
* @param {boolean} connected
|
|
467
|
+
* @returns {void}
|
|
468
|
+
*/
|
|
469
|
+
setLlmConnectedBeforeJoin(connected: boolean): void {
|
|
470
|
+
LoggerProxy.logger.info(`e2ee: MLS --> setLlmConnectedBeforeJoin: ${connected}`);
|
|
471
|
+
this.assertInitialized().setLlmConnectedBeforeJoin(connected);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Notifies the engine that the signaling channel is now connected.
|
|
476
|
+
* @returns {void}
|
|
477
|
+
*/
|
|
478
|
+
llmConnected(): void {
|
|
479
|
+
LoggerProxy.logger.info('e2ee: MLS --> llmConnected');
|
|
480
|
+
this.assertInitialized().llmConnected();
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @returns {string} the current security code, or '' if not initialized.
|
|
485
|
+
*/
|
|
486
|
+
getSecurityCode(): string {
|
|
487
|
+
return this.e2ee ? this.e2ee.securityCode() : '';
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* @returns {E2eeRosterMember[]} the current MLS roster, or [] if not initialized.
|
|
492
|
+
*/
|
|
493
|
+
getRoster(): E2eeRosterMember[] {
|
|
494
|
+
return this.e2ee ? this.e2ee.roster().map(MLS.toRosterMember) : [];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @returns {boolean} whether this client is the group leader.
|
|
499
|
+
*/
|
|
500
|
+
isLeader(): boolean {
|
|
501
|
+
return this.e2ee ? this.e2ee.isLeader() : false;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @returns {WebE2EEInstance}
|
|
506
|
+
*/
|
|
507
|
+
private assertInitialized(): WebE2EEInstance {
|
|
508
|
+
if (!this.e2ee) {
|
|
509
|
+
throw new Error('MLS not initialized');
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return this.e2ee;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @param {RosterMember} member - raw WASM roster member.
|
|
517
|
+
* @returns {E2eeRosterMember}
|
|
518
|
+
*/
|
|
519
|
+
private static toRosterMember(member: RosterMember): E2eeRosterMember {
|
|
520
|
+
return {
|
|
521
|
+
url: member.url,
|
|
522
|
+
displayName: member.display_name,
|
|
523
|
+
deviceType: member.device_type,
|
|
524
|
+
validationResult: member.validation_result,
|
|
525
|
+
...(member.x509 && {
|
|
526
|
+
identityResults: member.x509.map((certificateResult) => ({
|
|
527
|
+
result: certificateResult.result,
|
|
528
|
+
certificateChain: certificateResult.member_certs.map((certificate) => ({
|
|
529
|
+
primaryName: certificate.primary_name,
|
|
530
|
+
commonName: certificate.common_name,
|
|
531
|
+
organizationName: certificate.organization_name,
|
|
532
|
+
emailAddresses: certificate.email_addresses,
|
|
533
|
+
domainNames: certificate.domain_names,
|
|
534
|
+
notBefore: certificate.not_before,
|
|
535
|
+
notAfter: certificate.not_after,
|
|
536
|
+
signatureAlgorithm: certificate.signature_algorithm,
|
|
537
|
+
publicKeyAlgorithm: certificate.public_key_algorithm,
|
|
538
|
+
identityType: certificate.identity_type,
|
|
539
|
+
der: new Uint8Array(certificate.der),
|
|
540
|
+
})),
|
|
541
|
+
...(certificateResult.failed_cert_index !== undefined && {
|
|
542
|
+
failedCertIndex: certificateResult.failed_cert_index,
|
|
543
|
+
}),
|
|
544
|
+
})),
|
|
545
|
+
}),
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SDK-facing shapes used by the isolated MLS protocol engine. Integration-specific meeting,
|
|
7
|
+
* identity-plugin and signaling types are added by the later adapter phases.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Credential-validation outcome from the MLS roster. Keep ordinals in sync with libe2ee. */
|
|
11
|
+
export const E2eeValidationResult = {
|
|
12
|
+
Success: 0,
|
|
13
|
+
PartialSuccess: 1,
|
|
14
|
+
Failure: 2,
|
|
15
|
+
ParseError: 3,
|
|
16
|
+
UnknownIssuer: 4,
|
|
17
|
+
UnknownPublicKey: 5,
|
|
18
|
+
InvalidSignature: 6,
|
|
19
|
+
Expired: 7,
|
|
20
|
+
Inactive: 8,
|
|
21
|
+
Revoked: 9,
|
|
22
|
+
UnsupportedCaType: 10,
|
|
23
|
+
InvalidKeypackageSignature: 11,
|
|
24
|
+
UnsupportedCredentialType: 12,
|
|
25
|
+
MissingDisplayNameExtension: 13,
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
export type E2eeValidationResult = (typeof E2eeValidationResult)[keyof typeof E2eeValidationResult];
|
|
29
|
+
|
|
30
|
+
/** Identity type attached to the leaf certificate. Keep ordinals in sync with libe2ee. */
|
|
31
|
+
export const E2eeIdentityType = {
|
|
32
|
+
WebexAnonymousIdentity: 0,
|
|
33
|
+
WebexMachineIdentity: 1,
|
|
34
|
+
WebexUserIdentity: 2,
|
|
35
|
+
ExternalVerifiedIdentity: 3,
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export type E2eeIdentityType = (typeof E2eeIdentityType)[keyof typeof E2eeIdentityType];
|
|
39
|
+
|
|
40
|
+
/** A media-encryption (SFrame) key for an MLS epoch. */
|
|
41
|
+
export interface E2eeKey {
|
|
42
|
+
epoch: number;
|
|
43
|
+
baseKey: Uint8Array;
|
|
44
|
+
index: number;
|
|
45
|
+
indexBits: number;
|
|
46
|
+
canEncrypt: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** SFrame parameters negotiated for an MLS group. */
|
|
50
|
+
export interface SframeParams {
|
|
51
|
+
cipherSuite: number;
|
|
52
|
+
epochBits: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Parsed certificate information returned with a roster member. */
|
|
56
|
+
export interface E2eeCertificateInfo {
|
|
57
|
+
primaryName: string;
|
|
58
|
+
commonName: string;
|
|
59
|
+
organizationName: string;
|
|
60
|
+
emailAddresses: string[];
|
|
61
|
+
domainNames: string[];
|
|
62
|
+
notBefore: number;
|
|
63
|
+
notAfter: number;
|
|
64
|
+
signatureAlgorithm: string;
|
|
65
|
+
publicKeyAlgorithm: string;
|
|
66
|
+
identityType?: E2eeIdentityType;
|
|
67
|
+
der: Uint8Array;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface E2eeIdentityResult {
|
|
71
|
+
result: E2eeValidationResult;
|
|
72
|
+
certificateChain: E2eeCertificateInfo[];
|
|
73
|
+
failedCertIndex?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A member of the MLS roster and its credential-validation result. */
|
|
77
|
+
export interface E2eeRosterMember {
|
|
78
|
+
url: string;
|
|
79
|
+
displayName: string;
|
|
80
|
+
deviceType: string;
|
|
81
|
+
validationResult: E2eeValidationResult;
|
|
82
|
+
identityResults?: E2eeIdentityResult[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Credentials and trust anchors consumed by the WASM engine. */
|
|
86
|
+
export interface MLSConfig {
|
|
87
|
+
participantId: string;
|
|
88
|
+
deviceUrl: string;
|
|
89
|
+
deviceType?: string;
|
|
90
|
+
correlationId: string;
|
|
91
|
+
displayName: string;
|
|
92
|
+
serviceUrl: string;
|
|
93
|
+
credentials?: {privateKey: Uint8Array; certChain: Uint8Array[]};
|
|
94
|
+
trustAnchors?: {
|
|
95
|
+
webexCaRoots?: string;
|
|
96
|
+
domainNameRoots?: string;
|
|
97
|
+
userIdentityRoots?: string;
|
|
98
|
+
domainNameRootsP7b?: Uint8Array;
|
|
99
|
+
};
|
|
100
|
+
joinTimeout?: number;
|
|
101
|
+
coalesceWindow?: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* HTTP transport the MLS engine uses for its protocol requests. Implemented by
|
|
106
|
+
* MediaEncryptionService (which routes to webex.request); injected so the engine stays pure.
|
|
107
|
+
* Bodies are plain JS objects: MLS converts the engine's JSON bytes to/from objects at its boundary.
|
|
108
|
+
*/
|
|
109
|
+
export interface IMlsHttpClient {
|
|
110
|
+
request(url: string, body: unknown): Promise<unknown>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Signaling transport that delivered an MLS protocol message. */
|
|
114
|
+
export type E2eeSignalingSource = 'llm' | 'mercury';
|