@webex/plugin-meetings 3.13.0-next.1 → 3.13.0-next.11

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 (56) hide show
  1. package/babel.config.js +17 -1
  2. package/dist/aiEnableRequest/index.js +1 -1
  3. package/dist/breakouts/breakout.js +1 -1
  4. package/dist/breakouts/index.js +1 -1
  5. package/dist/common/wasm-loader.js +174 -0
  6. package/dist/common/wasm-loader.js.map +1 -0
  7. package/dist/config.js +2 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/constants.js +1 -1
  10. package/dist/constants.js.map +1 -1
  11. package/dist/e2ee/E2eeManager.js +91 -0
  12. package/dist/e2ee/E2eeManager.js.map +1 -0
  13. package/dist/e2ee/E2eeSignaling.js +200 -0
  14. package/dist/e2ee/E2eeSignaling.js.map +1 -0
  15. package/dist/e2ee/MediaEncryptionService.js +75 -0
  16. package/dist/e2ee/MediaEncryptionService.js.map +1 -0
  17. package/dist/e2ee/mls.js +558 -0
  18. package/dist/e2ee/mls.js.map +1 -0
  19. package/dist/e2ee/types.js +59 -0
  20. package/dist/e2ee/types.js.map +1 -0
  21. package/dist/e2ee/wasm.d.js +7 -0
  22. package/dist/e2ee/wasm.d.js.map +1 -0
  23. package/dist/interpretation/index.js +1 -1
  24. package/dist/interpretation/siLanguage.js +1 -1
  25. package/dist/meetings/index.js +20 -0
  26. package/dist/meetings/index.js.map +1 -1
  27. package/dist/types/common/wasm-loader.d.ts +55 -0
  28. package/dist/types/config.d.ts +1 -0
  29. package/dist/types/constants.d.ts +1 -1
  30. package/dist/types/e2ee/E2eeManager.d.ts +23 -0
  31. package/dist/types/e2ee/E2eeSignaling.d.ts +94 -0
  32. package/dist/types/e2ee/MediaEncryptionService.d.ts +27 -0
  33. package/dist/types/e2ee/mls.d.ts +191 -0
  34. package/dist/types/e2ee/types.d.ts +104 -0
  35. package/dist/types/meetings/index.d.ts +4 -0
  36. package/dist/webinar/index.js +1 -1
  37. package/package.json +21 -21
  38. package/src/common/wasm-loader.ts +124 -0
  39. package/src/config.ts +1 -0
  40. package/src/constants.ts +1 -1
  41. package/src/e2ee/E2eeManager.ts +58 -0
  42. package/src/e2ee/E2eeSignaling.ts +215 -0
  43. package/src/e2ee/MediaEncryptionService.ts +41 -0
  44. package/src/e2ee/mls.ts +548 -0
  45. package/src/e2ee/types.ts +114 -0
  46. package/src/e2ee/wasm.d.ts +153 -0
  47. package/src/meetings/ai-docs/meetings-spec.md +2 -0
  48. package/src/meetings/index.ts +18 -0
  49. package/test/integration/spec/transcription.js +1 -1
  50. package/test/unit/spec/common/wasm-loader.ts +171 -0
  51. package/test/unit/spec/e2ee/E2eeManager.ts +82 -0
  52. package/test/unit/spec/e2ee/E2eeSignaling.ts +172 -0
  53. package/test/unit/spec/e2ee/MediaEncryptionService.ts +43 -0
  54. package/test/unit/spec/e2ee/mls.ts +765 -0
  55. package/test/unit/spec/meeting-info/index.js +2 -3
  56. package/test/unit/spec/meetings/index.js +20 -0
@@ -0,0 +1,153 @@
1
+ /*!
2
+ * Copyright (c) 2015-2026 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import type {E2eeIdentityType, E2eeValidationResult} from './types';
6
+
7
+ /**
8
+ * Raw WebAssembly (WebE2EE) boundary types. These mirror the emscripten-generated MLS engine API
9
+ * exactly (including its snake_case fields); the SDK-facing camelCase shapes live in types.ts.
10
+ */
11
+
12
+ export interface Transaction {
13
+ id: string;
14
+ type: 'join' | 'update';
15
+ }
16
+
17
+ export interface JoinSuccessResult {
18
+ status: 'join_success';
19
+ epoch: number;
20
+ base_key: Uint8Array;
21
+ index: number;
22
+ index_bits: number;
23
+ sec_code: string;
24
+ sframe_cipher_suite: number;
25
+ sframe_epoch_bits: number;
26
+ }
27
+
28
+ export interface UpdateSuccessResult {
29
+ status: 'update_success';
30
+ }
31
+
32
+ export interface TransactionFailureResult {
33
+ status: 'failure';
34
+ reason:
35
+ | 'timeout'
36
+ | 'join_failure'
37
+ | 'tree_fetch_failure'
38
+ | 'commit_fetch_failure'
39
+ | 'update_override';
40
+ }
41
+
42
+ export type TransactionResult = JoinSuccessResult | UpdateSuccessResult | TransactionFailureResult;
43
+
44
+ export interface HTTPRequest {
45
+ url: string;
46
+ /** A view into WASM memory (`typed_memory_view`); only valid during the callback — copy before async use. */
47
+ body: Uint8Array;
48
+ handlerId: number;
49
+ }
50
+
51
+ export interface EpochInfo {
52
+ epoch: number;
53
+ base_key: Uint8Array;
54
+ index: number;
55
+ index_bits: number;
56
+ sec_code: string;
57
+ }
58
+
59
+ export interface CertificateInfo {
60
+ primary_name: string;
61
+ common_name: string;
62
+ organization_name: string;
63
+ email_addresses: string[];
64
+ domain_names: string[];
65
+ not_before: number;
66
+ not_after: number;
67
+ signature_algorithm: string;
68
+ public_key_algorithm: string;
69
+ identity_type?: E2eeIdentityType;
70
+ der: Uint8Array;
71
+ }
72
+
73
+ export interface CertificateResult {
74
+ result: E2eeValidationResult;
75
+ member_certs: CertificateInfo[];
76
+ failed_cert_index?: number;
77
+ }
78
+
79
+ export interface RosterMember {
80
+ url: string;
81
+ display_name: string;
82
+ device_type: string;
83
+ validation_result: E2eeValidationResult;
84
+ x509?: CertificateResult[];
85
+ }
86
+
87
+ export interface WebE2EEInstance {
88
+ initialize(
89
+ participantId: string,
90
+ deviceUrl: string,
91
+ deviceType: string,
92
+ correlationId: string,
93
+ displayName: string,
94
+ serviceUrl: string
95
+ ): void;
96
+
97
+ addX509Credential(privateKey: Uint8Array, certChain: Uint8Array[]): void;
98
+ setTrustAnchors(
99
+ webexCaRoots: string,
100
+ domainNameRoots: string,
101
+ userIdentityRoots: string,
102
+ domainNameRootsP7b: Uint8Array
103
+ ): void;
104
+
105
+ join(): void;
106
+ leave(): void;
107
+ joined(): boolean;
108
+ securityCode(): string;
109
+ sessionSecret(): Uint8Array | null;
110
+ contentKey(): Uint8Array | null;
111
+ contentKeyId(): string;
112
+ roster(): RosterMember[];
113
+ handle(event: Uint8Array): void;
114
+ isLeader(): boolean;
115
+ /**
116
+ * Used by backend services such as Homer; client SDKs do not need to call this.
117
+ */
118
+ keepAlive(): void;
119
+ llmConnected(): void;
120
+ setLlmConnectedBeforeJoin(connected: boolean): void;
121
+ setGzipThreshold(threshold: number): void;
122
+ setCoalesceWindow(milliseconds: number): void;
123
+ setJoinTimeout(milliseconds: number): void;
124
+ setPurgeKeysTimeout(milliseconds: number): void;
125
+
126
+ setOnNewTransaction(callback: (transaction: Transaction) => void): void;
127
+ setOnCompleteTransaction(callback: (id: string, result: TransactionResult) => void): void;
128
+ setOnHttpRequest(callback: (request: HTTPRequest) => void): void;
129
+ setOnWait(callback: (milliseconds: number, handlerId: number) => void): void;
130
+ setOnGotKey(callback: (epoch: EpochInfo) => void): void;
131
+ setOnUseKey(callback: (epoch: number) => void): void;
132
+ setOnLeader(callback: () => void): void;
133
+ setOnPurgeBefore(callback: (epoch: number) => void): void;
134
+ setOnEvicted(callback: () => void): void;
135
+ setOnAddRoster(callback: (added: RosterMember[]) => void): void;
136
+ setOnRemoveRoster(callback: (removed: string[]) => void): void;
137
+ setOnE2eeVersion(callback: (version: number) => void): void;
138
+ setOnMissingCommit(callback: (mlsEpoch: number, useKeyEpoch: number) => void): void;
139
+ setOnLog(callback: (level: number, message: string) => void): void;
140
+
141
+ completeHttpRequest(
142
+ handlerId: number,
143
+ success: boolean,
144
+ body: Uint8Array,
145
+ errorCode: number,
146
+ errorMessage: string
147
+ ): void;
148
+ completeWait(handlerId: number): void;
149
+ }
150
+
151
+ export interface ModuleInstance {
152
+ WebE2EE: new () => WebE2EEInstance;
153
+ }
@@ -115,6 +115,7 @@ Webex core host, device and Mercury plugins, meeting-info services, Meeting cons
115
115
  | `MEETINGS-R-003` | `executeRegistrationStep()` marks a step `true` whenever its supplied promise resolves and rethrows a rejection without resetting other flags. `fetchUserPreferredWebexSite()` catches its own failures and resolves, while the `startReachability` registration callback catches that gather rejection and resolves; those two steps are therefore marked successful even when their underlying work failed. `unregister()` removes Locus, ROAP, and `ONLINE` Mercury listeners plus device state, but leaves the `OFFLINE` listener installed. | Registration status records wrapper settlement, not necessarily underlying site/reachability success; other rejected steps preserve partial progress until the next `register()` reset, and the residual `OFFLINE` listener must stay visible as a teardown gap. | `src/meetings/index.ts` | `test/unit/spec/meetings/index.js` | characterize absorbed site/reachability failures, partial status after a non-absorbed rejection, and the surviving `OFFLINE` callback | PRESENT |
116
116
  | `MEETINGS-R-004` | `register()` starts site, geo, reachability, device-registration, and H.264 work together through `Promise.all`; Mercury connect is chained after device registration. Each wrapper-resolved step updates its own status, including the failure-absorbing site and reachability wrappers. `syncMeetings()` runs later from the Mercury `ONLINE` handler installed by `listenForEvents()`. | Registration readiness and active-meeting synchronization are distinct phases, and preserving wrapper-level settlement and actual concurrency prevents callers from depending on a nonexistent success definition or serial order. | `src/meetings/index.ts`, `src/meetings/meetings.types.ts` | `test/unit/spec/meetings/index.js` | none | PRESENT |
117
117
  | `MEETINGS-R-007` | `emitWasmRuntimePerformance(correlationId)` is a `once()`-wrapped private probe that runs `WasmRuntimeProbe.check()` and reports `WASM_RUNTIME_PERFORMANCE` (`js_sdk_wasm_runtime_performance`) with `status`, `capability`, `reason`, the destructured measurements `divRatio`, `sqrtRatio`, `addNsPerOp`, `addMedianMs`, `divMedianMs`, `sqrtMedianMs`, and `correlation_id`. Each measurement defaults to `null` when `result.measurements` is absent or omits it. Both a probe rejection and a metric-submission rejection are caught and logged only. | The probe is diagnostic: it exists to find browsers where real-time WASM effects run poorly, so it must never be able to fail meeting creation. Explicit `null` defaults keep the metric schema fixed-width so the fields stay comparable across browsers that report partial measurements, and `once()` keeps one sample per plugin instance rather than one per meeting. | `src/meetings/index.ts`, `src/metrics/constants.ts` | `test/unit/spec/meetings/index.js` | none | PRESENT |
118
+ | `MEETINGS-R-008` | Meetings owns one shared `WasmLoader`; after successful registration it starts E2EE WASM preloading when `meetings.enableE2ee` is true and WebAssembly is supported. Preload is fire-and-forget, so a preload rejection is logged and does not change registration success. | Keep module initialization off the meeting join path while preserving registration behavior when the optional asset is unavailable. | `src/meetings/index.ts`, `src/common/wasm-loader.ts`, `src/e2ee/E2eeManager.ts` | `test/unit/spec/meetings/index.js`, `test/unit/spec/common/wasm-loader.ts`, `test/unit/spec/e2ee/E2eeManager.ts` | Actual E2EE assets are supplied separately. | PRESENT |
118
119
  | `MEETINGS-R-005` | Mercury/Locus events resolve an existing meeting by supported keys before creating or routing a new object. | Stable meeting identity prevents duplicate Meeting objects and misrouted realtime updates. | `src/meetings/index.ts`, `src/meetings/collection.ts` | `test/unit/spec/meetings/index.js`, `test/unit/spec/meetings/collection.js` | none | PRESENT |
119
120
  | `MEETINGS-R-006` | Reachability, geo hints, site preferences, PMR, and active-meeting queries delegate to their current request/controller boundaries. | Central plugin access must preserve host credentials, service discovery, and established response/error behavior. | `src/meetings/index.ts`, `src/meetings/request.ts` | `test/unit/spec/meetings/request.js` | none | PRESENT |
120
121
 
@@ -289,6 +290,7 @@ Use the current mirrored suites: `test/unit/spec/meetings/collection.js`, `test/
289
290
  | `MEETINGS-R-005` | `test/unit/spec/meetings/index.js`, `test/unit/spec/meetings/collection.js` | verify alternate-key collision cases |
290
291
  | `MEETINGS-R-006` | `test/unit/spec/meetings/request.js` | none |
291
292
  | `MEETINGS-R-007` | `test/unit/spec/meetings/index.js` | covered for the full-measurements payload, the `null` defaults when measurements are absent, and the swallowed probe rejection |
293
+ | `MEETINGS-R-008` | `test/unit/spec/meetings/index.js`, `test/unit/spec/common/wasm-loader.ts`, `test/unit/spec/e2ee/E2eeManager.ts` | cover configured asset URL, config/capability gating, module caching/retry, and registration resilience |
292
294
 
293
295
  ## Traceability
294
296
 
@@ -21,6 +21,8 @@ import LoggerRequest from '../common/logs/request';
21
21
  import Trigger from '../common/events/trigger-proxy';
22
22
  import Media from '../media';
23
23
  import MeetingUtil from '../meeting/util';
24
+ import WasmLoader from '../common/wasm-loader';
25
+ import E2eeManager from '../e2ee/E2eeManager';
24
26
  import {
25
27
  MEETINGS,
26
28
  EVENTS,
@@ -210,6 +212,8 @@ export default class Meetings extends WebexPlugin {
210
212
  breakoutLocusForHandleLater: any;
211
213
  namespace = MEETINGS;
212
214
  registrationStatus: MeetingRegistrationStatus;
215
+ wasmLoader?: WasmLoader;
216
+ e2eeManager?: E2eeManager;
213
217
 
214
218
  /**
215
219
  * Emits a metric describing how well this browser runs WebAssembly, used to spot browsers
@@ -348,6 +352,9 @@ export default class Meetings extends WebexPlugin {
348
352
  getUserMedia: Media.getUserMedia,
349
353
  };
350
354
 
355
+ // Shared runtime cache for WASM modules used by meetings.
356
+ this.wasmLoader = new WasmLoader();
357
+
351
358
  this.onReady();
352
359
  }
353
360
 
@@ -808,6 +815,10 @@ export default class Meetings extends WebexPlugin {
808
815
  mediaLogger = new MediaLogger();
809
816
  setLogger(mediaLogger);
810
817
 
818
+ // Construct after READY because the manager uses the initialized webex client and config.
819
+ // @ts-ignore
820
+ this.e2eeManager = new E2eeManager({webex: this.webex, wasmLoader: this.wasmLoader});
821
+
811
822
  /**
812
823
  * The MeetingInfo object to interact with server
813
824
  * @instance
@@ -1125,6 +1136,13 @@ export default class Meetings extends WebexPlugin {
1125
1136
  );
1126
1137
  this.registered = true;
1127
1138
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MEETINGS_REGISTRATION_SUCCESS);
1139
+
1140
+ // Preload is best-effort and must not delay or fail Meetings registration.
1141
+ this.e2eeManager?.preload().catch((error) => {
1142
+ LoggerProxy.logger.warn(
1143
+ `Meetings:index#register --> E2EE preload failed: ${error?.message || error}`
1144
+ );
1145
+ });
1128
1146
  })
1129
1147
  .catch((error) => {
1130
1148
  LoggerProxy.logger.error(
@@ -6,7 +6,7 @@ describe('transcription index', () => {
6
6
  let webSocketUrl, members, sessionId, token, transcription;
7
7
 
8
8
  beforeEach(() => {
9
- webSocketUrl = 'ws://webSocketUrl';
9
+ webSocketUrl = 'wss://webSocketUrl';
10
10
  members = {
11
11
  membersCollection: {
12
12
  members: {
@@ -0,0 +1,171 @@
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 WasmLoader from '@webex/plugin-meetings/src/common/wasm-loader';
8
+
9
+ describe('plugin-meetings', () => {
10
+ describe('WasmLoader', () => {
11
+ const WASM_URL = '/assets/e2ee.wasm';
12
+ const OTHER_WASM_URL = '/assets/other.wasm';
13
+
14
+ let factory;
15
+ let importModule;
16
+ let moduleInstance;
17
+
18
+ beforeEach(() => {
19
+ moduleInstance = {name: 'e2ee-module'};
20
+ factory = sinon.stub().resolves(moduleInstance);
21
+ importModule = sinon.stub().resolves({default: factory});
22
+ });
23
+
24
+ afterEach(() => {
25
+ sinon.restore();
26
+ });
27
+
28
+ describe('get', () => {
29
+ it('derives the .js loader url from the .wasm url and points locateFile at the .wasm binary', async () => {
30
+ const loader = new WasmLoader({importModule});
31
+
32
+ const result = await loader.get(WASM_URL);
33
+
34
+ assert.calledOnceWithExactly(importModule, '/assets/e2ee.js');
35
+ assert.calledOnce(factory);
36
+ const {locateFile} = factory.firstCall.args[0];
37
+ assert.equal(locateFile('e2ee.wasm'), WASM_URL);
38
+ assert.equal(locateFile('e2ee.worker.js'), 'e2ee.worker.js');
39
+ assert.strictEqual(result, moduleInstance);
40
+ });
41
+
42
+ [
43
+ {
44
+ wasmUrl: 'https://cdn.example.com/x.wasm-assets/e2ee-0.0.1.wasm',
45
+ jsUrl: 'https://cdn.example.com/x.wasm-assets/e2ee-0.0.1.js',
46
+ },
47
+ {wasmUrl: '/assets/e2ee.wasm?v=1', jsUrl: '/assets/e2ee.js?v=1'},
48
+ {wasmUrl: '/assets/e2ee.wasm#hash', jsUrl: '/assets/e2ee.js#hash'},
49
+ ].forEach(({wasmUrl, jsUrl}) => {
50
+ it(`imports ${jsUrl} for ${wasmUrl}, replacing only the .wasm suffix`, async () => {
51
+ const loader = new WasmLoader({importModule});
52
+
53
+ await loader.get(wasmUrl);
54
+
55
+ assert.calledOnceWithExactly(importModule, jsUrl);
56
+ assert.equal(factory.firstCall.args[0].locateFile('e2ee.wasm'), wasmUrl);
57
+ });
58
+ });
59
+
60
+ it('loads each url only once and returns the cached instance on subsequent calls', async () => {
61
+ const loader = new WasmLoader({importModule});
62
+
63
+ const first = await loader.get(WASM_URL);
64
+ const second = await loader.get(WASM_URL);
65
+
66
+ assert.calledOnce(importModule);
67
+ assert.calledOnce(factory);
68
+ assert.strictEqual(first, second);
69
+ });
70
+
71
+ it('shares a single load across concurrent calls for the same url', async () => {
72
+ const loader = new WasmLoader({importModule});
73
+
74
+ const [first, second] = await Promise.all([loader.get(WASM_URL), loader.get(WASM_URL)]);
75
+
76
+ assert.calledOnce(importModule);
77
+ assert.strictEqual(first, second);
78
+ });
79
+
80
+ it('loads distinct urls independently', async () => {
81
+ const otherInstance = {name: 'other-module'};
82
+ importModule
83
+ .withArgs('/assets/e2ee.js')
84
+ .resolves({default: factory})
85
+ .withArgs('/assets/other.js')
86
+ .resolves({default: sinon.stub().resolves(otherInstance)});
87
+ const loader = new WasmLoader({importModule});
88
+
89
+ const e2ee = await loader.get(WASM_URL);
90
+ const other = await loader.get(OTHER_WASM_URL);
91
+
92
+ assert.calledTwice(importModule);
93
+ assert.calledWith(importModule, '/assets/e2ee.js');
94
+ assert.calledWith(importModule, '/assets/other.js');
95
+ assert.strictEqual(e2ee, moduleInstance);
96
+ assert.strictEqual(other, otherInstance);
97
+ });
98
+
99
+ it('resets so a failed load can be retried, then rejects', async () => {
100
+ const error = new Error('network down');
101
+ importModule.onFirstCall().rejects(error).onSecondCall().resolves({default: factory});
102
+ const loader = new WasmLoader({importModule});
103
+
104
+ await assert.isRejected(
105
+ loader.get(WASM_URL),
106
+ /Failed to load WASM module \/assets\/e2ee\.wasm/
107
+ );
108
+ assert.isFalse(loader.isLoaded(WASM_URL));
109
+
110
+ const result = await loader.get(WASM_URL);
111
+
112
+ assert.calledTwice(importModule);
113
+ assert.strictEqual(result, moduleInstance);
114
+ });
115
+
116
+ it('preserves the underlying error as the cause when the factory fails', async () => {
117
+ const error = new Error('instantiate failed');
118
+ factory.rejects(error);
119
+ const loader = new WasmLoader({importModule});
120
+
121
+ const rejection = await loader.get(WASM_URL).catch((e) => e);
122
+
123
+ assert.equal(
124
+ rejection.message,
125
+ 'Failed to load WASM module /assets/e2ee.wasm: Error: instantiate failed'
126
+ );
127
+ assert.strictEqual(rejection.cause, error);
128
+ });
129
+ });
130
+
131
+ describe('preload', () => {
132
+ it('warms the cache for the given url', async () => {
133
+ const loader = new WasmLoader({importModule});
134
+
135
+ await loader.preload(WASM_URL);
136
+
137
+ assert.calledOnceWithExactly(importModule, '/assets/e2ee.js');
138
+ assert.isTrue(loader.isLoaded(WASM_URL));
139
+ });
140
+ });
141
+
142
+ describe('isLoaded', () => {
143
+ it('is false for an unknown url', () => {
144
+ const loader = new WasmLoader({importModule});
145
+
146
+ assert.isFalse(loader.isLoaded(WASM_URL));
147
+ });
148
+
149
+ it('is false while loading is in flight and true once resolved', async () => {
150
+ const loader = new WasmLoader({importModule});
151
+
152
+ const pending = loader.get(WASM_URL);
153
+
154
+ assert.isFalse(loader.isLoaded(WASM_URL));
155
+
156
+ await pending;
157
+
158
+ assert.isTrue(loader.isLoaded(WASM_URL));
159
+ });
160
+
161
+ it('tracks each url independently', async () => {
162
+ const loader = new WasmLoader({importModule});
163
+
164
+ await loader.get(WASM_URL);
165
+
166
+ assert.isTrue(loader.isLoaded(WASM_URL));
167
+ assert.isFalse(loader.isLoaded(OTHER_WASM_URL));
168
+ });
169
+ });
170
+ });
171
+ });
@@ -0,0 +1,82 @@
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 E2eeManager from '@webex/plugin-meetings/src/e2ee/E2eeManager';
8
+ import WasmLoader from '@webex/plugin-meetings/src/common/wasm-loader';
9
+ import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
10
+
11
+ describe('plugin-meetings', () => {
12
+ describe('E2eeManager', () => {
13
+ let supportsWasmStub;
14
+
15
+ const makeWebex = (enableE2ee?: boolean, assetsBaseUrl = '/assets/plugin-meetings/') => ({
16
+ config: {meetings: {enableE2ee, assetsBaseUrl}},
17
+ });
18
+
19
+ const makeWasmLoader = () => {
20
+ const wasmLoader = sinon.createStubInstance(WasmLoader);
21
+ wasmLoader.preload.resolves();
22
+
23
+ return wasmLoader;
24
+ };
25
+
26
+ beforeEach(() => {
27
+ supportsWasmStub = sinon
28
+ .stub(WebCapabilities, 'supportsWasm')
29
+ .returns(CapabilityState.CAPABLE);
30
+ });
31
+
32
+ afterEach(() => {
33
+ sinon.restore();
34
+ });
35
+
36
+ describe('preload', () => {
37
+ it('preloads the module from the configured assets directory when enabled and supported', async () => {
38
+ const wasmLoader = makeWasmLoader();
39
+ const manager = new E2eeManager({
40
+ webex: makeWebex(true, 'https://cdn.example.com/sdk/meetings/'),
41
+ wasmLoader,
42
+ });
43
+
44
+ await manager.preload();
45
+
46
+ assert.calledOnceWithExactly(
47
+ wasmLoader.preload,
48
+ 'https://cdn.example.com/sdk/meetings/e2ee-0.0.1.wasm'
49
+ );
50
+ });
51
+
52
+ it('does not preload when the feature is disabled', async () => {
53
+ const wasmLoader = makeWasmLoader();
54
+ const manager = new E2eeManager({webex: makeWebex(false), wasmLoader});
55
+
56
+ await manager.preload();
57
+
58
+ assert.notCalled(wasmLoader.preload);
59
+ assert.calledOnce(supportsWasmStub);
60
+ });
61
+
62
+ it('does not preload when WebAssembly is unsupported', async () => {
63
+ supportsWasmStub.returns(CapabilityState.NOT_CAPABLE);
64
+ const wasmLoader = makeWasmLoader();
65
+ const manager = new E2eeManager({webex: makeWebex(true), wasmLoader});
66
+
67
+ await manager.preload();
68
+
69
+ assert.notCalled(wasmLoader.preload);
70
+ });
71
+
72
+ it('propagates preload errors for the registration caller to handle', async () => {
73
+ const error = new Error('asset load failed');
74
+ const wasmLoader = makeWasmLoader();
75
+ wasmLoader.preload.rejects(error);
76
+ const manager = new E2eeManager({webex: makeWebex(true), wasmLoader});
77
+
78
+ await assert.isRejected(manager.preload(), /asset load failed/);
79
+ });
80
+ });
81
+ });
82
+ });
@@ -0,0 +1,172 @@
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 E2eeSignaling, {
8
+ LLM_ONLINE_EVENT,
9
+ MEDIA_ENCRYPTION_MERCURY_EVENTS,
10
+ } from '../../../../src/e2ee/E2eeSignaling';
11
+
12
+ describe('plugin-meetings', () => {
13
+ describe('E2eeSignaling', () => {
14
+ let session;
15
+ let llm;
16
+ let mercury;
17
+ let signaling;
18
+
19
+ beforeEach(() => {
20
+ llm = {
21
+ on: sinon.stub(),
22
+ off: sinon.stub(),
23
+ isConnected: sinon.stub().returns(false),
24
+ getLocusUrl: sinon.stub().returns('locus-1'),
25
+ };
26
+ mercury = {
27
+ on: sinon.stub(),
28
+ off: sinon.stub(),
29
+ };
30
+ session = {
31
+ handleEvent: sinon.stub(),
32
+ setLlmConnectedBeforeJoin: sinon.stub(),
33
+ llmConnected: sinon.stub(),
34
+ };
35
+ signaling = new E2eeSignaling({llm, mercury, getLocusUrl: () => 'locus-1', session});
36
+ });
37
+
38
+ afterEach(() => {
39
+ sinon.restore();
40
+ });
41
+
42
+ it('subscribes to every mercury event on start', () => {
43
+ signaling.start();
44
+
45
+ MEDIA_ENCRYPTION_MERCURY_EVENTS.forEach((event) => {
46
+ assert.calledWith(llm.on, event, sinon.match.func);
47
+ assert.calledWith(mercury.on, event, sinon.match.func);
48
+ });
49
+ });
50
+
51
+ it('forwards mercury event data to the session as JSON bytes, tagged with the llm source', () => {
52
+ signaling.start();
53
+
54
+ const handler = llm.on.getCall(0).args[1];
55
+
56
+ handler({data: {foo: 'bar'}});
57
+
58
+ assert.calledOnce(session.handleEvent);
59
+ const [bytes, source] = session.handleEvent.firstCall.args;
60
+
61
+ assert.instanceOf(bytes, Uint8Array);
62
+ assert.deepEqual(JSON.parse(new TextDecoder().decode(bytes)), {foo: 'bar'});
63
+ assert.equal(source, 'llm');
64
+ });
65
+
66
+ it('forwards events coming from the mercury channel to the session, tagged with the mercury source', () => {
67
+ signaling.start();
68
+
69
+ const handler = mercury.on.getCall(0).args[1];
70
+
71
+ handler({data: {foo: 'baz'}});
72
+
73
+ assert.calledOnce(session.handleEvent);
74
+ const [bytes, source] = session.handleEvent.firstCall.args;
75
+
76
+ assert.instanceOf(bytes, Uint8Array);
77
+ assert.deepEqual(JSON.parse(new TextDecoder().decode(bytes)), {foo: 'baz'});
78
+ assert.equal(source, 'mercury');
79
+ });
80
+
81
+ it('tells the engine the channel is already connected when online for this meeting', () => {
82
+ llm.isConnected.returns(true);
83
+ llm.getLocusUrl.returns('locus-1');
84
+
85
+ signaling.start();
86
+
87
+ assert.calledOnceWithExactly(session.setLlmConnectedBeforeJoin, true);
88
+ assert.neverCalledWith(llm.on, LLM_ONLINE_EVENT, sinon.match.func);
89
+ });
90
+
91
+ it('waits for online and notifies only when it is for this meeting', () => {
92
+ signaling.start();
93
+
94
+ const onlineCall = llm.on.getCalls().find((call) => call.args[0] === LLM_ONLINE_EVENT);
95
+
96
+ assert.isDefined(onlineCall);
97
+ const onOnline = onlineCall.args[1];
98
+
99
+ // Online for a different meeting -> no notify.
100
+ llm.isConnected.returns(true);
101
+ llm.getLocusUrl.returns('other-locus');
102
+ onOnline();
103
+ assert.notCalled(session.llmConnected);
104
+
105
+ // Online for our meeting -> notify.
106
+ llm.getLocusUrl.returns('locus-1');
107
+ onOnline();
108
+ assert.calledOnce(session.llmConnected);
109
+ });
110
+
111
+ it('moves subscriptions when the meeting replaces or clears its LLM channel', () => {
112
+ signaling.start();
113
+
114
+ const replacementLlm = {
115
+ on: sinon.stub(),
116
+ off: sinon.stub(),
117
+ isConnected: sinon.stub().returns(false),
118
+ getLocusUrl: sinon.stub().returns('locus-1'),
119
+ };
120
+
121
+ signaling.setLlmChannel(replacementLlm);
122
+
123
+ MEDIA_ENCRYPTION_MERCURY_EVENTS.forEach((event) => {
124
+ assert.calledWith(llm.off, event, sinon.match.func);
125
+ assert.calledWith(replacementLlm.on, event, sinon.match.func);
126
+ });
127
+ assert.calledWith(llm.off, LLM_ONLINE_EVENT, sinon.match.func);
128
+ assert.calledWith(replacementLlm.on, LLM_ONLINE_EVENT, sinon.match.func);
129
+
130
+ const replacementHandler = replacementLlm.on.getCall(0).args[1];
131
+
132
+ replacementHandler({data: {foo: 'replacement'}});
133
+
134
+ const [bytes, source] = session.handleEvent.firstCall.args;
135
+
136
+ assert.deepEqual(JSON.parse(new TextDecoder().decode(bytes)), {foo: 'replacement'});
137
+ assert.equal(source, 'llm');
138
+
139
+ signaling.setLlmChannel(undefined);
140
+
141
+ MEDIA_ENCRYPTION_MERCURY_EVENTS.forEach((event) => {
142
+ assert.calledWith(replacementLlm.off, event, sinon.match.func);
143
+ });
144
+ assert.calledWith(replacementLlm.off, LLM_ONLINE_EVENT, sinon.match.func);
145
+ });
146
+
147
+ it('removes all subscriptions on stop', () => {
148
+ signaling.start();
149
+ signaling.stop();
150
+
151
+ MEDIA_ENCRYPTION_MERCURY_EVENTS.forEach((event) => {
152
+ assert.calledWith(llm.off, event, sinon.match.func);
153
+ assert.calledWith(mercury.off, event, sinon.match.func);
154
+ });
155
+ assert.calledWith(llm.off, LLM_ONLINE_EVENT, sinon.match.func);
156
+ });
157
+
158
+ it('is idempotent across repeated start/stop calls', () => {
159
+ signaling.start();
160
+ const onCountAfterStart = llm.on.callCount;
161
+
162
+ signaling.start();
163
+ assert.equal(llm.on.callCount, onCountAfterStart);
164
+
165
+ signaling.stop();
166
+ const offCountAfterStop = llm.off.callCount;
167
+
168
+ signaling.stop();
169
+ assert.equal(llm.off.callCount, offCountAfterStop);
170
+ });
171
+ });
172
+ });