@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.
Files changed (89) hide show
  1. package/dist/aiEnableRequest/index.js +1 -1
  2. package/dist/breakouts/breakout.js +1 -1
  3. package/dist/breakouts/index.js +1 -1
  4. package/dist/common/events/typed-events-scope.js +135 -0
  5. package/dist/common/events/typed-events-scope.js.map +1 -0
  6. package/dist/common/types.js +7 -0
  7. package/dist/common/types.js.map +1 -0
  8. package/dist/config.js +1 -1
  9. package/dist/constants.js +5 -0
  10. package/dist/constants.js.map +1 -1
  11. package/dist/e2ee/E2eeController.js +581 -0
  12. package/dist/e2ee/E2eeController.js.map +1 -0
  13. package/dist/e2ee/E2eeManager.js +50 -31
  14. package/dist/e2ee/E2eeManager.js.map +1 -1
  15. package/dist/e2ee/E2eeSignaling.js +18 -21
  16. package/dist/e2ee/E2eeSignaling.js.map +1 -1
  17. package/dist/e2ee/MediaEncryptionService.js +2 -5
  18. package/dist/e2ee/MediaEncryptionService.js.map +1 -1
  19. package/dist/e2ee/constants.js +28 -0
  20. package/dist/e2ee/constants.js.map +1 -0
  21. package/dist/e2ee/mls.js +85 -67
  22. package/dist/e2ee/mls.js.map +1 -1
  23. package/dist/e2ee/types.js +52 -13
  24. package/dist/e2ee/types.js.map +1 -1
  25. package/dist/e2ee/wasm.d.js.map +1 -1
  26. package/dist/hashTree/hashTreeParser.js.map +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/interpretation/index.js +1 -1
  29. package/dist/interpretation/siLanguage.js +1 -1
  30. package/dist/meeting/index.js +394 -249
  31. package/dist/meeting/index.js.map +1 -1
  32. package/dist/meeting/request.js +69 -58
  33. package/dist/meeting/request.js.map +1 -1
  34. package/dist/meeting/util.js +4 -2
  35. package/dist/meeting/util.js.map +1 -1
  36. package/dist/meetings/index.js +87 -61
  37. package/dist/meetings/index.js.map +1 -1
  38. package/dist/meetings/util.js +10 -0
  39. package/dist/meetings/util.js.map +1 -1
  40. package/dist/metrics/constants.js +2 -1
  41. package/dist/metrics/constants.js.map +1 -1
  42. package/dist/types/common/events/typed-events-scope.d.ts +73 -0
  43. package/dist/types/common/types.d.ts +9 -0
  44. package/dist/types/constants.d.ts +5 -0
  45. package/dist/types/e2ee/E2eeController.d.ts +130 -0
  46. package/dist/types/e2ee/E2eeManager.d.ts +26 -6
  47. package/dist/types/e2ee/E2eeSignaling.d.ts +1 -7
  48. package/dist/types/e2ee/MediaEncryptionService.d.ts +1 -3
  49. package/dist/types/e2ee/constants.d.ts +12 -0
  50. package/dist/types/e2ee/mls.d.ts +16 -10
  51. package/dist/types/e2ee/types.d.ts +92 -35
  52. package/dist/types/hashTree/hashTreeParser.d.ts +1 -1
  53. package/dist/types/index.d.ts +1 -0
  54. package/dist/types/meeting/index.d.ts +34 -0
  55. package/dist/types/meeting/util.d.ts +1 -1
  56. package/dist/types/metrics/constants.d.ts +1 -0
  57. package/dist/webinar/index.js +1 -1
  58. package/package.json +22 -22
  59. package/src/common/events/typed-events-scope.ts +110 -0
  60. package/src/common/types.ts +10 -0
  61. package/src/constants.ts +6 -0
  62. package/src/e2ee/DESIGN.md +363 -0
  63. package/src/e2ee/E2eeController.ts +487 -0
  64. package/src/e2ee/E2eeManager.ts +48 -27
  65. package/src/e2ee/E2eeSignaling.ts +13 -28
  66. package/src/e2ee/MediaEncryptionService.ts +2 -4
  67. package/src/e2ee/constants.ts +34 -0
  68. package/src/e2ee/mls.ts +62 -32
  69. package/src/e2ee/types.ts +99 -34
  70. package/src/e2ee/wasm.d.ts +18 -14
  71. package/src/hashTree/hashTreeParser.ts +1 -1
  72. package/src/index.ts +1 -0
  73. package/src/meeting/index.ts +155 -0
  74. package/src/meeting/request.ts +16 -0
  75. package/src/meeting/util.ts +2 -1
  76. package/src/meetings/index.ts +30 -5
  77. package/src/meetings/util.ts +8 -0
  78. package/src/metrics/constants.ts +1 -0
  79. package/test/unit/spec/common/events/typed-events-scope.ts +88 -0
  80. package/test/unit/spec/e2ee/E2eeController.ts +662 -0
  81. package/test/unit/spec/e2ee/E2eeManager.ts +53 -29
  82. package/test/unit/spec/e2ee/E2eeSignaling.ts +19 -10
  83. package/test/unit/spec/e2ee/mls.ts +84 -32
  84. package/test/unit/spec/meeting/index.js +662 -0
  85. package/test/unit/spec/meeting/request.js +35 -0
  86. package/test/unit/spec/meeting/utils.js +4 -0
  87. package/test/unit/spec/meetings/index.js +36 -1
  88. package/test/unit/spec/meetings/utils.js +15 -0
  89. package/test/utils/webex-config.js +1 -0
@@ -0,0 +1,487 @@
1
+ /*!
2
+ * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import type {IdentityProvider} from '@webex/internal-plugin-identity';
6
+
7
+ import TypedEventsScope from '../common/events/typed-events-scope';
8
+ import LoggerProxy from '../common/logs/logger-proxy';
9
+ import Metrics from '../metrics';
10
+ import BEHAVIORAL_METRICS from '../metrics/constants';
11
+ import {EVENT_TRIGGERS} from '../constants';
12
+ import MLS, {type MLSEvent, type MLSEventMap} from './mls';
13
+ import MediaEncryptionService from './MediaEncryptionService';
14
+ import E2eeSignaling from './E2eeSignaling';
15
+ import {MEDIA_SERVICE_DEVICE_TYPE} from './constants';
16
+ import MeetingsUtil from '../meetings/util';
17
+ import type WasmLoader from '../common/wasm-loader';
18
+ import {E2eeState} from './types';
19
+ import type {
20
+ E2eeControllerEvent,
21
+ E2eeControllerEventMap,
22
+ E2eeMeetingContext,
23
+ E2eeRosterMember,
24
+ } from './types';
25
+ import type {ModuleInstance} from './wasm';
26
+
27
+ const TRIGGER_SCOPE = {file: 'e2ee/E2eeController', function: 'e2ee'};
28
+
29
+ type FatalE2eeState = typeof E2eeState.Failed | typeof E2eeState.Evicted;
30
+
31
+ /**
32
+ * Per-meeting E2EE controller (owned by Meeting as `this.e2ee`). It orchestrates the MLS engine, the
33
+ * signaling adapter and the HTTP transport for one meeting, exposes the security code, media-service
34
+ * presence and lifecycle state, and re-emits E2EE events on the meeting. Its start() is a no-op
35
+ * unless the meeting requires E2EE (a V2/zero-trust meeting) and E2EE is enabled and supported.
36
+ */
37
+ export default class E2eeController extends TypedEventsScope<E2eeControllerEventMap> {
38
+ private readonly context: E2eeMeetingContext;
39
+
40
+ private readonly webex: any;
41
+
42
+ private readonly wasmLoader: WasmLoader;
43
+
44
+ private readonly wasmUrl: string;
45
+
46
+ private readonly identityProvider: IdentityProvider;
47
+
48
+ private mlsSession?: MLS;
49
+
50
+ private signaling?: E2eeSignaling;
51
+
52
+ private sessionUnsubscribers: Array<() => void> = [];
53
+
54
+ private currentState: E2eeState = E2eeState.Disabled;
55
+
56
+ private securityCode?: string;
57
+
58
+ private readonly mediaServiceUrls = new Set<string>(); // todo: remove this as part of SPARK-876976 work
59
+
60
+ // Incremented by every start() and cleanupSession(); an in-flight start() whose attempt is no
61
+ // longer the latest was cancelled during teardown and must not continue.
62
+ private startAttempt = 0;
63
+
64
+ /**
65
+ * @param {Object} deps
66
+ * @param {E2eeMeetingContext} deps.context - The meeting data and operations used by E2EE.
67
+ * @param {Object} deps.webex - The parent webex instance.
68
+ * @param {WasmLoader} deps.wasmLoader - Shared (pre-warmed) WASM loader.
69
+ * @param {string} deps.wasmUrl - URL of the E2EE WASM module.
70
+ * @param {IdentityProvider} deps.identityProvider - Shared identity/credential provider.
71
+ */
72
+ constructor({
73
+ context,
74
+ webex,
75
+ wasmLoader,
76
+ wasmUrl,
77
+ identityProvider,
78
+ }: {
79
+ context: E2eeMeetingContext;
80
+ webex: any;
81
+ wasmLoader: WasmLoader;
82
+ wasmUrl: string;
83
+ identityProvider: IdentityProvider;
84
+ }) {
85
+ super();
86
+ this.context = context;
87
+ this.webex = webex;
88
+ this.wasmLoader = wasmLoader;
89
+ this.wasmUrl = wasmUrl;
90
+ this.identityProvider = identityProvider;
91
+ }
92
+
93
+ /**
94
+ * @returns {E2eeState} the current E2EE lifecycle state.
95
+ */
96
+ get state(): E2eeState {
97
+ return this.currentState;
98
+ }
99
+
100
+ /**
101
+ * @returns {boolean} whether the MLS roster contains a media service currently considered untrusted.
102
+ */
103
+ get hasUntrustedMediaServices(): boolean {
104
+ // For now, assume every media service is untrusted. Determining which services are trusted is
105
+ // tracked by SPARK-863974.
106
+ return this.mediaServiceUrls.size > 0;
107
+ }
108
+
109
+ /**
110
+ * @returns {string|undefined} the meeting security code, once available.
111
+ */
112
+ getSecurityCode(): string | undefined {
113
+ return this.securityCode;
114
+ }
115
+
116
+ /**
117
+ * Refreshes the LLM channel used for MLS signaling after Meeting changes its channel.
118
+ * @returns {void}
119
+ */
120
+ llmChannelChanged(): void {
121
+ this.signaling?.setLlmChannel(this.context.getLlmChannel());
122
+ }
123
+
124
+ /**
125
+ * @returns {boolean} whether this meeting requires an MLS join (V2/zero-trust) and E2EE is enabled.
126
+ */
127
+ private required(): boolean {
128
+ const locusInfo = this.context.getLocusInfo();
129
+
130
+ return (
131
+ MeetingsUtil.isE2eeEnabledAndSupported(this.webex?.config) &&
132
+ !!locusInfo?.info?.isV2E2EEncrypted &&
133
+ !!locusInfo?.info?.mediaEncryptionGroupUrl
134
+ );
135
+ }
136
+
137
+ /**
138
+ * Starts the MLS session for this meeting. Idempotent and self-guarded: a no-op unless the
139
+ * meeting requires E2EE, and while a session is already starting or running. Never rejects —
140
+ * failures transition to the `failed` state and emit an E2EE failure event. Calling it again
141
+ * from `failed` or `evicted` retries with a fresh MLS session.
142
+ * @returns {Promise<void>}
143
+ */
144
+ async start(): Promise<void> {
145
+ if (
146
+ this.currentState === E2eeState.Initializing ||
147
+ this.currentState === E2eeState.Joining ||
148
+ this.currentState === E2eeState.Joined
149
+ ) {
150
+ LoggerProxy.logger.info(
151
+ `e2ee: E2eeController#start --> ignoring, already in state: ${this.currentState}`
152
+ );
153
+
154
+ return;
155
+ }
156
+ if (!this.required()) {
157
+ LoggerProxy.logger.info(
158
+ 'e2ee: E2eeController#start --> not required for this meeting, skipping'
159
+ );
160
+
161
+ return;
162
+ }
163
+
164
+ LoggerProxy.logger.info('e2ee: E2eeController#start --> starting E2EE session');
165
+ this.startAttempt += 1;
166
+ const attempt = this.startAttempt;
167
+ const isCancelled = () => attempt !== this.startAttempt;
168
+ // Awaits a startup step, then aborts start() (via the catch below) if stop() ran meanwhile.
169
+ const step = async <T>(promise: Promise<T>): Promise<T> => {
170
+ const result = await promise;
171
+
172
+ if (isCancelled()) {
173
+ throw new Error('E2EE start cancelled');
174
+ }
175
+
176
+ return result;
177
+ };
178
+
179
+ this.setState(E2eeState.Initializing);
180
+
181
+ try {
182
+ const {device} = this.webex.internal;
183
+ const [module, credentials] = await step(
184
+ Promise.all([
185
+ this.wasmLoader.get<ModuleInstance>(this.wasmUrl),
186
+ this.identityProvider.getCredentials(device.userId),
187
+ ])
188
+ );
189
+
190
+ const httpClient = new MediaEncryptionService({
191
+ webexRequest: this.webex.request.bind(this.webex),
192
+ });
193
+ const session = new MLS({
194
+ httpClient,
195
+ module,
196
+ });
197
+ const mediaEncryptionGroupUrl = this.context.getLocusInfo()?.info?.mediaEncryptionGroupUrl;
198
+
199
+ if (!mediaEncryptionGroupUrl) {
200
+ throw new Error('Meeting locus has no media encryption group URL');
201
+ }
202
+
203
+ this.mlsSession = session;
204
+ this.setupMlsSessionListeners(session);
205
+
206
+ session.initialize({
207
+ participantId: device.userId,
208
+ deviceUrl: device.url,
209
+ deviceType: this.webex.config.meetings.deviceType,
210
+ correlationId: this.context.getCorrelationId(),
211
+ displayName: this.getSelfDisplayName(),
212
+ serviceUrl: mediaEncryptionGroupUrl,
213
+ credentials,
214
+ trustAnchors: this.identityProvider.getTrustAnchors(),
215
+ });
216
+
217
+ this.signaling = new E2eeSignaling({
218
+ llm: this.context.getLlmChannel(),
219
+ mercury: this.webex.internal.mercury,
220
+ getLocusUrl: () => this.context.getLocusInfo()?.url,
221
+ session,
222
+ });
223
+ this.signaling.start();
224
+
225
+ this.setState(E2eeState.Joining);
226
+ session.join();
227
+ } catch (error) {
228
+ if (isCancelled()) {
229
+ LoggerProxy.logger.info(
230
+ 'e2ee: E2eeController#start --> cancelled by stop() during startup'
231
+ );
232
+
233
+ return;
234
+ }
235
+
236
+ LoggerProxy.logger.error(`e2ee: E2eeController#start --> failed to start E2EE: ${error}`);
237
+ this.handleFatal(E2eeState.Failed, 'startFailed', {
238
+ errorMessage: error?.message ?? String(error),
239
+ });
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Tears down the MLS session and resets state, cancelling a start() that is still in progress.
245
+ * Idempotent.
246
+ * @returns {Promise<void>}
247
+ */
248
+ async stop(): Promise<void> {
249
+ if (this.currentState === E2eeState.Disabled) {
250
+ // E2EE was never started (not required for this meeting, or still pre-join). Nothing to tear
251
+ // down, and we stay silent so callers can invoke stop() unconditionally without log noise.
252
+ return;
253
+ }
254
+
255
+ LoggerProxy.logger.info('e2ee: E2eeController#stop --> stopping E2EE session');
256
+ this.cleanupSession();
257
+ this.setState(E2eeState.Left);
258
+ }
259
+
260
+ /**
261
+ * @param {MLS} session
262
+ * @returns {void}
263
+ */
264
+ private setupMlsSessionListeners(session: MLS): void {
265
+ const subscribe = <K extends MLSEvent>(
266
+ event: K,
267
+ listener: (payload: MLSEventMap[K]) => void
268
+ ) => {
269
+ session.on(event, listener);
270
+ this.sessionUnsubscribers.push(() => session.off(event, listener));
271
+ };
272
+
273
+ subscribe('joinSuccess', ({securityCode}) => {
274
+ this.securityCode = securityCode;
275
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_SECURITY_CODE_UPDATED, {securityCode});
276
+ });
277
+
278
+ subscribe('securityCodeChanged', ({code}) => {
279
+ this.securityCode = code;
280
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_SECURITY_CODE_UPDATED, {securityCode: code});
281
+ });
282
+
283
+ subscribe('rosterAdded', (added) => {
284
+ this.updateFromRoster({added, removed: []});
285
+ });
286
+ subscribe('rosterRemoved', ({urls}) => {
287
+ this.updateFromRoster({added: [], removed: urls});
288
+ });
289
+
290
+ subscribe('joinFailure', ({reason}) => this.deferFatal(session, E2eeState.Failed, reason));
291
+ subscribe('mediaEncryptionServiceFailure', ({errorCode, message}) =>
292
+ this.deferFatal(session, E2eeState.Failed, 'mediaEncryptionServiceFailure', {
293
+ errorCode,
294
+ errorMessage: message,
295
+ })
296
+ );
297
+ subscribe('evicted', () => this.deferFatal(session, E2eeState.Evicted, 'evicted'));
298
+ }
299
+
300
+ /**
301
+ * Defers teardown until the WASM callback that emitted the event has returned.
302
+ * @param {MLS} session
303
+ * @param {E2eeState.Failed|E2eeState.Evicted} state
304
+ * @param {string} reason
305
+ * @param {Object} [details]
306
+ * @returns {void}
307
+ */
308
+ private deferFatal(
309
+ session: MLS,
310
+ state: FatalE2eeState,
311
+ reason: string,
312
+ details: {errorCode?: number; errorMessage?: string} = {}
313
+ ): void {
314
+ Promise.resolve().then(() => {
315
+ if (this.mlsSession !== session) {
316
+ return;
317
+ }
318
+
319
+ this.handleFatal(state, reason, details);
320
+ });
321
+ }
322
+
323
+ /**
324
+ * Updates media-service presence and MLS-join completion from roster changes. MLS join is
325
+ * complete only once our own device URL appears in the roster.
326
+ * @param {Object} rosterChanges
327
+ * @param {E2eeRosterMember[]} rosterChanges.added
328
+ * @param {string[]} rosterChanges.removed
329
+ * @returns {void}
330
+ */
331
+ private updateFromRoster({added, removed}: {added: E2eeRosterMember[]; removed: string[]}): void {
332
+ const hadMediaServices = this.mediaServiceUrls.size > 0;
333
+ let ownDeviceAdded = false;
334
+
335
+ for (const member of added) {
336
+ if (member.deviceType === MEDIA_SERVICE_DEVICE_TYPE) {
337
+ this.mediaServiceUrls.add(member.url);
338
+ }
339
+
340
+ if (member.url === this.webex.internal.device.url) {
341
+ ownDeviceAdded = true;
342
+ }
343
+ }
344
+
345
+ for (const url of removed) {
346
+ this.mediaServiceUrls.delete(url);
347
+ }
348
+
349
+ const hasMediaServices = this.mediaServiceUrls.size > 0;
350
+
351
+ if (hasMediaServices !== hadMediaServices) {
352
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_MEDIA_SERVICES_CHANGED, {hasMediaServices});
353
+ }
354
+
355
+ if (this.currentState === E2eeState.Joining && ownDeviceAdded) {
356
+ this.setState(E2eeState.Joined);
357
+ }
358
+ }
359
+
360
+ /**
361
+ * @param {E2eeState.Failed|E2eeState.Evicted} state
362
+ * @param {string} reason
363
+ * @param {Object} [details] - Extra diagnostics included only in the behavioral metric.
364
+ * @param {number} [details.errorCode] - Media-encryption service error code.
365
+ * @param {string} [details.error] - Error message.
366
+ * @returns {void}
367
+ */
368
+ private handleFatal(
369
+ state: FatalE2eeState,
370
+ reason: string,
371
+ details: {errorCode?: number; errorMessage?: string} = {}
372
+ ): void {
373
+ LoggerProxy.logger.error(
374
+ `e2ee: E2eeController --> fatal E2EE error: state=${state} reason=${reason} details=`,
375
+ details
376
+ );
377
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.E2EE_FAILURE, {
378
+ correlation_id: this.context.getCorrelationId(),
379
+ state,
380
+ reason,
381
+ ...details,
382
+ });
383
+ this.cleanupSession();
384
+ this.setState(state);
385
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_FAILURE, {reason, ...details});
386
+ }
387
+
388
+ /**
389
+ * Stops signaling, detaches session listeners, leaves the MLS group, and resets roster state.
390
+ * @returns {void}
391
+ */
392
+ private cleanupSession(): void {
393
+ this.startAttempt += 1;
394
+
395
+ try {
396
+ this.signaling?.stop();
397
+ } catch (error) {
398
+ LoggerProxy.logger.warn(`e2ee: E2eeController --> error stopping signaling: ${error}`);
399
+ }
400
+ this.signaling = undefined;
401
+
402
+ this.sessionUnsubscribers.forEach((unsubscribe) => {
403
+ try {
404
+ unsubscribe();
405
+ } catch (error) {
406
+ LoggerProxy.logger.warn(`e2ee: E2eeController --> error removing MLS listener: ${error}`);
407
+ }
408
+ });
409
+ this.sessionUnsubscribers = [];
410
+
411
+ const hadMediaServices = this.mediaServiceUrls.size > 0;
412
+
413
+ this.mediaServiceUrls.clear();
414
+
415
+ const {mlsSession} = this;
416
+
417
+ this.mlsSession = undefined;
418
+
419
+ try {
420
+ mlsSession?.leave();
421
+ } catch (error) {
422
+ LoggerProxy.logger.warn(`e2ee: E2eeController --> error leaving MLS session: ${error}`);
423
+ }
424
+
425
+ try {
426
+ mlsSession?.cleanUp();
427
+ } catch (error) {
428
+ LoggerProxy.logger.warn(`e2ee: E2eeController --> error cleaning up MLS session: ${error}`);
429
+ }
430
+
431
+ if (hadMediaServices) {
432
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_MEDIA_SERVICES_CHANGED, {
433
+ hasMediaServices: false,
434
+ });
435
+ }
436
+ }
437
+
438
+ /**
439
+ * Clears a security code that is no longer valid for the current MLS session.
440
+ * @returns {void}
441
+ */
442
+ private clearSecurityCode(): void {
443
+ if (this.securityCode === undefined) {
444
+ return;
445
+ }
446
+
447
+ this.securityCode = undefined;
448
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_SECURITY_CODE_UPDATED, {
449
+ securityCode: undefined,
450
+ });
451
+ }
452
+
453
+ /**
454
+ * @returns {string} the self participant's display name, or '' if unavailable.
455
+ */
456
+ private getSelfDisplayName(): string {
457
+ return this.context.members.membersCollection.get(this.context.members.selfId)?.name ?? '';
458
+ }
459
+
460
+ /**
461
+ * @param {E2eeState} state
462
+ * @returns {void}
463
+ */
464
+ private setState(state: E2eeState): void {
465
+ if (this.currentState === state) {
466
+ return;
467
+ }
468
+
469
+ if (state === E2eeState.Failed || state === E2eeState.Evicted || state === E2eeState.Left) {
470
+ this.clearSecurityCode();
471
+ }
472
+
473
+ LoggerProxy.logger.info(
474
+ `e2ee: E2eeController --> state changed: ${this.currentState} -> ${state}`
475
+ );
476
+ this.currentState = state;
477
+ this.emitE2eeEvent(EVENT_TRIGGERS.MEETING_E2EE_STATE_CHANGED, {state});
478
+ }
479
+
480
+ private emitE2eeEvent<K extends E2eeControllerEvent>(
481
+ event: K,
482
+ payload: E2eeControllerEventMap[K]
483
+ ): void {
484
+ LoggerProxy.logger.info(`e2ee: E2eeController --> emitting event: ${event}`);
485
+ this.emit(TRIGGER_SCOPE, event, payload);
486
+ }
487
+ }
@@ -2,57 +2,78 @@
2
2
  * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
 
5
- import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
6
- // @ts-ignore - StaticAssetLoader is exported from webex-core's JavaScript entry point.
7
- import {StaticAssetLoader} from '@webex/webex-core';
8
-
9
5
  import LoggerProxy from '../common/logs/logger-proxy';
10
6
  import WasmLoader from '../common/wasm-loader';
11
-
12
- /* The WASM module that contains the libe2ee + mlspp libraries with a WebE2EE wrapper around them, required for joining MLS group for E2EE meetings.
13
- * The version is in the filename as it is important that JS-SDK implementation of MLS class matches the WASM module version.
14
- */
15
- const E2EE_WASM_ASSET = 'e2ee-0.0.1.wasm';
7
+ import E2eeController from './E2eeController';
8
+ import MeetingsUtil from '../meetings/util';
9
+ import type {E2eeMeetingContext} from './types';
16
10
 
17
11
  /**
18
- * Owns E2EE resource preloading for a Meetings plugin session. The per-meeting controller is added
19
- * in the follow-up integration change; this first step keeps the slow WASM load off the join path.
12
+ * Owns E2EE resource preloading for a Meetings plugin session and creates its per-meeting
13
+ * controllers. Meetings supplies the shared WASM loader and resolved module URL.
20
14
  */
21
15
  export default class E2eeManager {
22
16
  private readonly webex: any;
23
17
 
24
18
  private readonly wasmLoader: WasmLoader;
25
19
 
26
- private readonly assetLoader: StaticAssetLoader;
20
+ private readonly wasmUrl: string;
27
21
 
28
- constructor({webex, wasmLoader}: {webex: any; wasmLoader: WasmLoader}) {
22
+ /**
23
+ * @param {Object} deps
24
+ * @param {Object} deps.webex - The parent webex instance.
25
+ * @param {WasmLoader} deps.wasmLoader - Shared WASM loader, owned by Meetings.
26
+ * @param {string} deps.wasmUrl - URL of the E2EE WASM module, resolved by Meetings.
27
+ */
28
+ constructor({webex, wasmLoader, wasmUrl}: {webex: any; wasmLoader: WasmLoader; wasmUrl: string}) {
29
29
  this.webex = webex;
30
30
  this.wasmLoader = wasmLoader;
31
- this.assetLoader = new StaticAssetLoader(
32
- {baseUrl: webex.config.meetings.assetsBaseUrl},
33
- {parent: webex}
34
- );
31
+ this.wasmUrl = wasmUrl;
32
+ }
33
+
34
+ /**
35
+ * @returns {boolean} whether E2EE is enabled via config.
36
+ */
37
+ get isEnabled(): boolean {
38
+ return MeetingsUtil.isE2eeEnabledAndSupported(this.webex?.config);
35
39
  }
36
40
 
37
41
  /**
38
- * Warms the E2EE WASM module when configured and supported. Callers should not await this from
39
- * registration; a loading failure must not prevent the client from registering for meetings.
42
+ * Warms the shared E2EE resources (WASM module) when enabled. No-op when disabled. Rejection is
43
+ * handled by the caller (register wires this fire-and-forget so it can never fail registration).
40
44
  * @returns {Promise<void>}
41
45
  */
42
46
  async preload(): Promise<void> {
43
- const enabled = !!this.webex?.config?.meetings?.enableE2ee;
44
- const supported = WebCapabilities.supportsWasm() === CapabilityState.CAPABLE;
45
-
46
- if (!enabled || !supported) {
47
- LoggerProxy.logger.info('e2ee: E2eeManager#preload --> E2EE disabled or unsupported');
47
+ if (!this.isEnabled) {
48
+ LoggerProxy.logger.info(
49
+ 'e2ee: E2eeManager#preload --> E2EE disabled or not supported, skipping WASM preload'
50
+ );
48
51
 
49
52
  return;
50
53
  }
51
54
 
52
- const wasmUrl = this.assetLoader.getUrl(E2EE_WASM_ASSET);
53
-
54
55
  LoggerProxy.logger.info('e2ee: E2eeManager#preload --> preloading WASM module');
55
- await this.wasmLoader.preload(wasmUrl);
56
+ await this.wasmLoader.preload(this.wasmUrl);
56
57
  LoggerProxy.logger.info('e2ee: E2eeManager#preload --> WASM module preloaded');
57
58
  }
59
+
60
+ /**
61
+ * Creates the per-meeting E2EE controller, injecting the shared loader, module URL, identity provider and config.
62
+ * The returned controller's start() is a no-op unless the meeting requires E2EE and E2EE is enabled.
63
+ * @param {E2eeMeetingContext} context - The meeting data and operations used by E2EE.
64
+ * @returns {E2eeController}
65
+ */
66
+ createE2eeController(context: E2eeMeetingContext): E2eeController {
67
+ LoggerProxy.logger.info(
68
+ 'e2ee: E2eeManager#createE2eeController --> creating E2EE meeting controller'
69
+ );
70
+
71
+ return new E2eeController({
72
+ context,
73
+ webex: this.webex,
74
+ wasmLoader: this.wasmLoader,
75
+ wasmUrl: this.wasmUrl,
76
+ identityProvider: this.webex.internal.identity,
77
+ });
78
+ }
58
79
  }
@@ -3,29 +3,10 @@
3
3
  */
4
4
 
5
5
  import type LLMChannel from '@webex/internal-plugin-llm';
6
-
7
- /** Source labels passed to the MLS engine for incoming signaling messages. */
8
- type E2eeSignalingSource = 'llm' | 'mercury';
9
-
10
- /** LLM event carrying the channel's connection state. */
11
- export const LLM_ONLINE_EVENT = 'online';
12
-
13
- /** Mercury events carrying MLS protocol messages. */
14
- export const MEDIA_ENCRYPTION_MERCURY_EVENTS = [
15
- 'event:media_encryption.leader_nominated',
16
- 'event:media_encryption.welcome',
17
- 'event:media_encryption.annotated_welcome',
18
- 'event:media_encryption.multi_welcome',
19
- 'event:media_encryption.group_update',
20
- 'event:media_encryption.annotated_commit',
21
- 'event:media_encryption.large_group_update',
22
- 'event:media_encryption.use_key',
23
- 'event:media_encryption.join_request',
24
- 'event:media_encryption.leave_request',
25
- 'event:media_encryption.join_failure',
26
- 'event:media_encryption.leader_changed',
27
- 'event:media_encryption.message_segment',
28
- ];
6
+ import {ONLINE} from '../constants';
7
+ import LoggerProxy from '../common/logs/logger-proxy';
8
+ import {MEDIA_ENCRYPTION_MERCURY_EVENTS} from './constants';
9
+ import type {E2eeSignalingSource} from './types';
29
10
 
30
11
  /** The subset of the MLS engine the signaling adapter drives. */
31
12
  export interface IMlsSignalingTarget {
@@ -149,10 +130,14 @@ export default class E2eeSignaling {
149
130
  * @returns {void}
150
131
  */
151
132
  private forwardEvent(envelope: any, source: E2eeSignalingSource): void {
152
- const eventData = envelope?.data ?? envelope;
153
- const bytes = new TextEncoder().encode(JSON.stringify(eventData));
133
+ try {
134
+ const eventData = envelope?.data ?? envelope;
135
+ const bytes = new TextEncoder().encode(JSON.stringify(eventData));
154
136
 
155
- this.session.handleEvent(new Uint8Array(bytes), source);
137
+ this.session.handleEvent(new Uint8Array(bytes), source);
138
+ } catch (error) {
139
+ LoggerProxy.logger.warn(`e2ee: E2eeSignaling --> error forwarding signaling event: ${error}`);
140
+ }
156
141
  }
157
142
 
158
143
  /**
@@ -190,13 +175,13 @@ export default class E2eeSignaling {
190
175
  this.llm?.on(event, this.onLlmEvent);
191
176
  });
192
177
  if (!this.isLlmOnlineForThisSession()) {
193
- this.llm.on(LLM_ONLINE_EVENT, this.onLlmOnline);
178
+ this.llm.on(ONLINE, this.onLlmOnline);
194
179
  }
195
180
  }
196
181
 
197
182
  /** @returns {void} */
198
183
  private unsubscribeFromLlmEvents(): void {
199
- this.llm?.off(LLM_ONLINE_EVENT, this.onLlmOnline);
184
+ this.llm?.off(ONLINE, this.onLlmOnline);
200
185
  MEDIA_ENCRYPTION_MERCURY_EVENTS.forEach((event) => {
201
186
  this.llm?.off(event, this.onLlmEvent);
202
187
  });
@@ -2,10 +2,8 @@
2
2
  * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
 
5
- const MEDIA_ENCRYPTION_SERVICE = 'media-encryption';
6
-
7
- /** The bound webex.request function shape consumed by this adapter. */
8
- type WebexRequestMethod = (options: Record<string, any>) => Promise<any>;
5
+ import {MEDIA_ENCRYPTION_SERVICE} from './constants';
6
+ import type {WebexRequestMethod} from '../common/types';
9
7
 
10
8
  /**
11
9
  * Routes the MLS engine's protocol HTTP requests to the media-encryption service via