@webex/plugin-meetings 3.13.0-next.16 → 3.13.0-next.18

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 (112) 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 +609 -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/MemberMLSReconciler.js +194 -0
  20. package/dist/e2ee/MemberMLSReconciler.js.map +1 -0
  21. package/dist/e2ee/constants.js +28 -0
  22. package/dist/e2ee/constants.js.map +1 -0
  23. package/dist/e2ee/mls.js +86 -68
  24. package/dist/e2ee/mls.js.map +1 -1
  25. package/dist/e2ee/types.js +66 -11
  26. package/dist/e2ee/types.js.map +1 -1
  27. package/dist/e2ee/wasm.d.js.map +1 -1
  28. package/dist/hashTree/hashTreeParser.js.map +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/interpretation/index.js +1 -1
  31. package/dist/interpretation/siLanguage.js +1 -1
  32. package/dist/meeting/index.js +394 -249
  33. package/dist/meeting/index.js.map +1 -1
  34. package/dist/meeting/request.js +69 -58
  35. package/dist/meeting/request.js.map +1 -1
  36. package/dist/meeting/util.js +4 -2
  37. package/dist/meeting/util.js.map +1 -1
  38. package/dist/meetings/index.js +87 -61
  39. package/dist/meetings/index.js.map +1 -1
  40. package/dist/meetings/util.js +10 -0
  41. package/dist/meetings/util.js.map +1 -1
  42. package/dist/member/index.js +159 -0
  43. package/dist/member/index.js.map +1 -1
  44. package/dist/member/types.js.map +1 -1
  45. package/dist/members/collection.js +84 -1
  46. package/dist/members/collection.js.map +1 -1
  47. package/dist/members/index.js +58 -1
  48. package/dist/members/index.js.map +1 -1
  49. package/dist/metrics/constants.js +2 -1
  50. package/dist/metrics/constants.js.map +1 -1
  51. package/dist/types/common/events/typed-events-scope.d.ts +73 -0
  52. package/dist/types/common/types.d.ts +9 -0
  53. package/dist/types/constants.d.ts +5 -0
  54. package/dist/types/e2ee/E2eeController.d.ts +131 -0
  55. package/dist/types/e2ee/E2eeManager.d.ts +26 -6
  56. package/dist/types/e2ee/E2eeSignaling.d.ts +1 -7
  57. package/dist/types/e2ee/MediaEncryptionService.d.ts +1 -3
  58. package/dist/types/e2ee/MemberMLSReconciler.d.ts +76 -0
  59. package/dist/types/e2ee/constants.d.ts +12 -0
  60. package/dist/types/e2ee/mls.d.ts +16 -10
  61. package/dist/types/e2ee/types.d.ts +117 -36
  62. package/dist/types/hashTree/hashTreeParser.d.ts +1 -1
  63. package/dist/types/index.d.ts +1 -0
  64. package/dist/types/meeting/index.d.ts +34 -0
  65. package/dist/types/meeting/util.d.ts +1 -1
  66. package/dist/types/member/index.d.ts +62 -0
  67. package/dist/types/member/types.d.ts +1 -0
  68. package/dist/types/members/collection.d.ts +30 -0
  69. package/dist/types/members/index.d.ts +73 -0
  70. package/dist/types/metrics/constants.d.ts +1 -0
  71. package/dist/webinar/index.js +1 -1
  72. package/package.json +21 -21
  73. package/src/common/events/typed-events-scope.ts +110 -0
  74. package/src/common/types.ts +10 -0
  75. package/src/constants.ts +6 -0
  76. package/src/e2ee/DESIGN.md +363 -0
  77. package/src/e2ee/E2eeController.ts +513 -0
  78. package/src/e2ee/E2eeManager.ts +48 -27
  79. package/src/e2ee/E2eeSignaling.ts +13 -28
  80. package/src/e2ee/MediaEncryptionService.ts +2 -4
  81. package/src/e2ee/MemberMLSReconciler.ts +175 -0
  82. package/src/e2ee/constants.ts +34 -0
  83. package/src/e2ee/mls.ts +63 -33
  84. package/src/e2ee/types.ts +129 -35
  85. package/src/e2ee/wasm.d.ts +18 -14
  86. package/src/hashTree/hashTreeParser.ts +1 -1
  87. package/src/index.ts +1 -0
  88. package/src/meeting/index.ts +155 -0
  89. package/src/meeting/request.ts +16 -0
  90. package/src/meeting/util.ts +2 -1
  91. package/src/meetings/index.ts +30 -5
  92. package/src/meetings/util.ts +8 -0
  93. package/src/member/index.ts +169 -0
  94. package/src/member/types.ts +1 -0
  95. package/src/members/collection.ts +67 -1
  96. package/src/members/index.ts +59 -1
  97. package/src/metrics/constants.ts +1 -0
  98. package/test/unit/spec/common/events/typed-events-scope.ts +88 -0
  99. package/test/unit/spec/e2ee/E2eeController.ts +753 -0
  100. package/test/unit/spec/e2ee/E2eeManager.ts +53 -29
  101. package/test/unit/spec/e2ee/E2eeSignaling.ts +19 -10
  102. package/test/unit/spec/e2ee/MemberMLSReconciler.ts +353 -0
  103. package/test/unit/spec/e2ee/mls.ts +86 -34
  104. package/test/unit/spec/meeting/index.js +662 -0
  105. package/test/unit/spec/meeting/request.js +35 -0
  106. package/test/unit/spec/meeting/utils.js +4 -0
  107. package/test/unit/spec/meetings/index.js +36 -1
  108. package/test/unit/spec/meetings/utils.js +15 -0
  109. package/test/unit/spec/member/index.js +292 -0
  110. package/test/unit/spec/members/collection.js +50 -0
  111. package/test/unit/spec/members/index.js +71 -0
  112. package/test/utils/webex-config.js +1 -0
package/src/index.ts CHANGED
@@ -72,6 +72,7 @@ export type {
72
72
  SitePreferencesResponse,
73
73
  } from './meetings/meetings.types';
74
74
  export type {Interpreter, InterpreterUsingResource} from './interpretation/interpretation.types';
75
+ export type {E2eeControllerEvent, E2eeControllerEventMap} from './e2ee/types';
75
76
 
76
77
  export {
77
78
  CaptchaError,
@@ -89,6 +89,9 @@ import ReconnectionManager from '../reconnection-manager';
89
89
  import ReconnectionNotStartedError from '../common/errors/reconnection-not-started';
90
90
  import MeetingRequest from './request';
91
91
  import Members from '../members/index';
92
+ import type E2eeController from '../e2ee/E2eeController';
93
+ import {E2eeState, TrustState} from '../e2ee/types';
94
+ import type {E2eeLocusInfo, E2eeMeetingContext} from '../e2ee/types';
92
95
  import MeetingUtil from './util';
93
96
  import MeetingsUtil from '../meetings/util';
94
97
  import RecordingUtil from '../recording-controller/util';
@@ -633,6 +636,8 @@ export default class Meeting extends StatelessWebexPlugin {
633
636
  meetingInfo: any;
634
637
  meetingRequest: MeetingRequest;
635
638
  members: Members;
639
+ e2ee?: E2eeController;
640
+ private lastTrustState?: TrustState;
636
641
  options: object;
637
642
  orgId: string;
638
643
  owner: string;
@@ -1154,6 +1159,23 @@ export default class Meeting extends StatelessWebexPlugin {
1154
1159
  */
1155
1160
  // @ts-ignore - Fix type
1156
1161
  this.roap = new Roap({}, {parent: this.webex});
1162
+
1163
+ const e2eeContext: E2eeMeetingContext = {
1164
+ getCorrelationId: () => this.correlationId,
1165
+ getLocusInfo: (): E2eeLocusInfo | undefined => this.locusInfo,
1166
+ getLlmChannel: () => this.llmChannel,
1167
+ members: this.members,
1168
+ };
1169
+
1170
+ /**
1171
+ * The per-meeting E2EE controller (undefined when no E2EE manager is provided).
1172
+ * @instance
1173
+ * @type {E2eeController}
1174
+ * @private
1175
+ * @memberof Meeting
1176
+ */
1177
+ this.e2ee = attrs.e2eeManager?.createE2eeController(e2eeContext);
1178
+ this.setupE2eeEventForwarding(this.e2ee);
1157
1179
  /**
1158
1180
  * indicates if an SDP exchange is happening
1159
1181
  *
@@ -1667,6 +1689,7 @@ export default class Meeting extends StatelessWebexPlugin {
1667
1689
 
1668
1690
  this.setUpLocusInfoListeners();
1669
1691
  this.locusInfo.init(attrs.locus ? attrs.locus : {});
1692
+ this.lastTrustState = this.trustState;
1670
1693
  this.hasJoinedOnce = false;
1671
1694
 
1672
1695
  /**
@@ -2884,9 +2907,53 @@ export default class Meeting extends StatelessWebexPlugin {
2884
2907
 
2885
2908
  // If user moved to a JOINED state and there is a pending floor grant trigger it
2886
2909
  this.requestScreenShareFloorIfPending();
2910
+
2911
+ this.updateE2eeOnSelfChange(payload);
2912
+ this.updateTrustState();
2887
2913
  });
2888
2914
  }
2889
2915
 
2916
+ /**
2917
+ * Drives the E2EE MLS lifecycle from self-state changes for this WDM device:
2918
+ * join once the device is JOINED, leave when it is moved back into the lobby.
2919
+ * @param {Object} payload the LOCUS_INFO_UPDATE_SELF payload (oldSelf, newSelf)
2920
+ * @returns {undefined}
2921
+ * @private
2922
+ * @memberof Meeting
2923
+ */
2924
+ private updateE2eeOnSelfChange(payload: any) {
2925
+ // Gate on this WDM device's joinedWith state, not the aggregate self state (which can be JOINED
2926
+ // because another device for the same user joined). Lobby/pre-join selves are never JOINED.
2927
+ const wasDeviceJoined =
2928
+ payload.oldSelf?.joinedWith?.url === this.deviceUrl &&
2929
+ payload.oldSelf?.joinedWith?.state === MEETING_STATE.STATES.JOINED;
2930
+ const isDeviceJoined =
2931
+ payload.newSelf?.joinedWith?.url === this.deviceUrl &&
2932
+ payload.newSelf?.joinedWith?.state === MEETING_STATE.STATES.JOINED;
2933
+
2934
+ if (!wasDeviceJoined && isDeviceJoined) {
2935
+ this.e2ee?.start().catch((error) => {
2936
+ LoggerProxy.logger.error(
2937
+ 'Meeting:index#updateE2eeOnSelfChange --> E2EE start failed',
2938
+ error
2939
+ );
2940
+ });
2941
+ }
2942
+
2943
+ // Leave when this device stops being joined or the host moves it back into the lobby.
2944
+ const wasDeviceUnadmitted = payload.oldSelf?.isUserUnadmitted === true;
2945
+ const isDeviceUnadmitted = payload.newSelf?.isUserUnadmitted === true;
2946
+
2947
+ if ((wasDeviceJoined && !isDeviceJoined) || (!wasDeviceUnadmitted && isDeviceUnadmitted)) {
2948
+ this.e2ee?.stop().catch((error) => {
2949
+ LoggerProxy.logger.error(
2950
+ 'Meeting:index#updateE2eeOnSelfChange --> E2EE stop failed',
2951
+ error
2952
+ );
2953
+ });
2954
+ }
2955
+ }
2956
+
2890
2957
  /**
2891
2958
  * Notify any changes on the pstn devices
2892
2959
  * @param {Object} payload
@@ -3787,6 +3854,7 @@ export default class Meeting extends StatelessWebexPlugin {
3787
3854
  }
3788
3855
  });
3789
3856
  this.locusInfo.on(LOCUSINFO.EVENTS.MEETING_INFO_UPDATED, ({isInitializing}) => {
3857
+ this.updateTrustState();
3790
3858
  this.updateMeetingActions();
3791
3859
  this.recordingController.setDisplayHints(this.userDisplayHints);
3792
3860
  this.recordingController.setUserPolicy(this.selfUserPolicies);
@@ -4418,6 +4486,90 @@ export default class Meeting extends StatelessWebexPlugin {
4418
4486
  return this.members;
4419
4487
  }
4420
4488
 
4489
+ /**
4490
+ * The meeting's overall trust state, derived from the Locus E2EE flags, the MLS join state
4491
+ * and media-service presence. Undefined when the local device is not joined to the meeting.
4492
+ * @returns {TrustState | undefined}
4493
+ * @public
4494
+ * @memberof Meeting
4495
+ */
4496
+ public get trustState(): TrustState | undefined {
4497
+ if (!this.isJoined()) {
4498
+ return undefined;
4499
+ }
4500
+
4501
+ const info: any = this.locusInfo?.info;
4502
+ const adaptive = !!info?.isBestEffortE2EEncryption;
4503
+ const isEncrypted = !!info?.isV2E2EEncrypted;
4504
+
4505
+ if (isEncrypted) {
4506
+ if (this.e2ee?.state === E2eeState.Failed) {
4507
+ return TrustState.Failed;
4508
+ }
4509
+
4510
+ if (this.e2ee?.state === E2eeState.Initializing || this.e2ee?.state === E2eeState.Joining) {
4511
+ return TrustState.Calculating;
4512
+ }
4513
+ }
4514
+
4515
+ const zeroTrust =
4516
+ isEncrypted && this.e2ee?.state === E2eeState.Joined && !this.e2ee?.hasUntrustedMediaServices;
4517
+
4518
+ if (adaptive) {
4519
+ return zeroTrust ? TrustState.AdaptiveZeroTrust : TrustState.AdaptiveStrong;
4520
+ }
4521
+
4522
+ return zeroTrust ? TrustState.ZeroTrust : TrustState.Strong;
4523
+ }
4524
+
4525
+ /**
4526
+ * Emits when a Locus or MLS update changes the meeting's overall E2EE trust state.
4527
+ * @returns {void}
4528
+ * @private
4529
+ */
4530
+ private updateTrustState(): void {
4531
+ const {trustState} = this;
4532
+
4533
+ if (this.lastTrustState === trustState) {
4534
+ return;
4535
+ }
4536
+
4537
+ this.lastTrustState = trustState;
4538
+ Trigger.trigger(
4539
+ this,
4540
+ {
4541
+ file: 'meeting/index',
4542
+ function: 'updateTrustState',
4543
+ },
4544
+ EVENT_TRIGGERS.MEETING_TRUST_STATE_CHANGED,
4545
+ {trustState}
4546
+ );
4547
+ }
4548
+
4549
+ /**
4550
+ * Forwards E2EE controller events and updates the derived trust state when relevant E2EE state changes.
4551
+ * @param {E2eeController | undefined} e2ee
4552
+ * @returns {void}
4553
+ * @private
4554
+ */
4555
+ private setupE2eeEventForwarding(e2ee?: E2eeController): void {
4556
+ if (!e2ee) {
4557
+ return;
4558
+ }
4559
+
4560
+ [
4561
+ EVENT_TRIGGERS.MEETING_E2EE_SECURITY_CODE_UPDATED,
4562
+ EVENT_TRIGGERS.MEETING_E2EE_STATE_CHANGED,
4563
+ EVENT_TRIGGERS.MEETING_E2EE_MEDIA_SERVICES_CHANGED,
4564
+ EVENT_TRIGGERS.MEETING_E2EE_FAILURE,
4565
+ ].forEach((event) => this.forwardEvent(e2ee, event, event));
4566
+
4567
+ [
4568
+ EVENT_TRIGGERS.MEETING_E2EE_STATE_CHANGED,
4569
+ EVENT_TRIGGERS.MEETING_E2EE_MEDIA_SERVICES_CHANGED,
4570
+ ].forEach((event) => e2ee.on(event, () => this.updateTrustState()));
4571
+ }
4572
+
4421
4573
  /**
4422
4574
  * Sets the meeting info on the class instance
4423
4575
  * @param {Object} meetingInfo
@@ -6800,6 +6952,7 @@ export default class Meeting extends StatelessWebexPlugin {
6800
6952
  } finally {
6801
6953
  this.stopListeningForLLMEvents();
6802
6954
  this.llmChannel = undefined;
6955
+ this.e2ee?.llmChannelChanged();
6803
6956
  }
6804
6957
  };
6805
6958
 
@@ -6933,6 +7086,7 @@ export default class Meeting extends StatelessWebexPlugin {
6933
7086
  // Create a new LLM channel for this meeting
6934
7087
  // @ts-ignore - Fix type
6935
7088
  this.llmChannel = this.webex.internal.llm.createChannel();
7089
+ this.e2ee?.llmChannelChanged();
6936
7090
 
6937
7091
  // Get token from pending (saved from join response) or channel
6938
7092
  const datachannelToken = this._pendingDatachannelToken ?? this.llmChannel.getDatachannelToken();
@@ -7035,6 +7189,7 @@ export default class Meeting extends StatelessWebexPlugin {
7035
7189
 
7036
7190
  // Clean up the channel on failure
7037
7191
  this.llmChannel = undefined;
7192
+ this.e2ee?.llmChannelChanged();
7038
7193
 
7039
7194
  return Promise.reject(error);
7040
7195
  });
@@ -7,6 +7,8 @@ import {deviceType} from '@webex/common';
7
7
  import {CallDiagnosticUtils} from '@webex/internal-plugin-metrics';
8
8
 
9
9
  import LoggerProxy from '../common/logs/logger-proxy';
10
+ import {E2EE_1K_SUPPORTED} from '../e2ee/constants';
11
+ import MeetingsUtil from '../meetings/util';
10
12
  import {
11
13
  ALERT,
12
14
  ALTERNATE_REDIRECT_TRUE,
@@ -183,6 +185,11 @@ export default class MeetingRequest extends StatelessWebexPlugin {
183
185
  allowMultiDevice: true,
184
186
  ensureConversation: ensureConversation || false,
185
187
  supportsNativeLobby: 1,
188
+ // @ts-ignore - config comes from registerPlugin
189
+ supportsV2E2EEncryption: MeetingsUtil.isE2eeEnabledAndSupported(
190
+ // @ts-ignore - config comes from registerPlugin
191
+ this.webex?.config
192
+ ),
186
193
  clientMediaPreferences,
187
194
  };
188
195
 
@@ -204,6 +211,15 @@ export default class MeetingRequest extends StatelessWebexPlugin {
204
211
  INTERPRETATION.CAPABILITIES.SIGN_INTERPRETER_SUPPORTED
205
212
  );
206
213
  }
214
+ // @ts-ignore - config comes from registerPlugin
215
+ if (
216
+ MeetingsUtil.isE2eeEnabledAndSupported(
217
+ // @ts-ignore - config comes from registerPlugin
218
+ this.webex?.config
219
+ )
220
+ ) {
221
+ deviceCapabilities.push(E2EE_1K_SUPPORTED);
222
+ }
207
223
 
208
224
  // append installationId to device config if it exists
209
225
  // @ts-ignore
@@ -383,7 +383,8 @@ const MeetingUtil = {
383
383
  ? meeting.statsAnalyzer.stopAnalyzer()
384
384
  : Promise.resolve();
385
385
 
386
- return stopStatsAnalyzer
386
+ return Promise.resolve(meeting.e2ee?.stop())
387
+ .then(() => stopStatsAnalyzer)
387
388
  .then(() => meeting.closeRemoteStreams())
388
389
  .then(() => meeting.closePeerConnections())
389
390
  .then(() => {
@@ -4,8 +4,7 @@ import {WasmRuntimeProbe} from '@webex/web-capabilities';
4
4
  import '@webex/internal-plugin-mercury';
5
5
  import '@webex/internal-plugin-conversation';
6
6
  import '@webex/internal-plugin-metrics';
7
- // @ts-ignore
8
- import {WebexPlugin} from '@webex/webex-core';
7
+ import {StaticAssetLoader, WebexPlugin} from '@webex/webex-core';
9
8
  import {setLogger} from '@webex/internal-media-core';
10
9
  import {DeviceRegistrationOptions} from '@webex/internal-plugin-device';
11
10
 
@@ -23,6 +22,7 @@ import Media from '../media';
23
22
  import MeetingUtil from '../meeting/util';
24
23
  import WasmLoader from '../common/wasm-loader';
25
24
  import E2eeManager from '../e2ee/E2eeManager';
25
+ import {E2EE_WASM_ASSET} from '../e2ee/constants';
26
26
  import {
27
27
  MEETINGS,
28
28
  EVENTS,
@@ -352,7 +352,14 @@ export default class Meetings extends WebexPlugin {
352
352
  getUserMedia: Media.getUserMedia,
353
353
  };
354
354
 
355
- // Shared runtime cache for WASM modules used by meetings.
355
+ /**
356
+ * Loads and caches WASM modules (for example needed for E2EE).
357
+ * Safe to create here as it has no dependency on webex.request.
358
+ * @instance
359
+ * @type {WasmLoader}
360
+ * @private
361
+ * @memberof Meetings
362
+ */
356
363
  this.wasmLoader = new WasmLoader();
357
364
 
358
365
  this.onReady();
@@ -815,9 +822,26 @@ export default class Meetings extends WebexPlugin {
815
822
  mediaLogger = new MediaLogger();
816
823
  setLogger(mediaLogger);
817
824
 
818
- // Construct after READY because the manager uses the initialized webex client and config.
825
+ // Resolved here rather than in the constructor because WebexCore assigns webex.config in its
826
+ // initialize(), which runs after plugin children (including Meetings) are constructed.
827
+ const assetLoader = new StaticAssetLoader(
828
+ // @ts-ignore
829
+ {baseUrl: this.config.assetsBaseUrl},
830
+ // @ts-ignore
831
+ {parent: this.webex}
832
+ );
833
+
834
+ // E2eeManager is created here (not in the constructor) because webex.request isn't available
835
+ // yet at plugin-construction time, so webex.request.bind() inside E2eeManager would throw.
819
836
  // @ts-ignore
820
- this.e2eeManager = new E2eeManager({webex: this.webex, wasmLoader: this.wasmLoader});
837
+ this.e2eeManager = new E2eeManager({
838
+ // @ts-ignore - parent is provided by WebexPlugin.
839
+ webex: this.webex,
840
+ // @ts-ignore - initialized in the Meetings constructor.
841
+ wasmLoader: this.wasmLoader,
842
+ // @ts-ignore - initialized in the Meetings constructor.
843
+ wasmUrl: assetLoader.getUrl(E2EE_WASM_ASSET),
844
+ });
821
845
 
822
846
  /**
823
847
  * The MeetingInfo object to interact with server
@@ -1821,6 +1845,7 @@ export default class Meetings extends WebexPlugin {
1821
1845
  destination,
1822
1846
  destinationType: type,
1823
1847
  callStateForMetrics,
1848
+ e2eeManager: this.e2eeManager,
1824
1849
  },
1825
1850
  {
1826
1851
  // @ts-ignore
@@ -44,6 +44,14 @@ import {EndMeetingReason, LocusFullState} from '../locus-info/types';
44
44
 
45
45
  const MeetingsUtil: any = {};
46
46
 
47
+ /**
48
+ * E2EE can only be enabled when requested and WebAssembly is available in this browser.
49
+ * @param {Object} config - The Webex SDK configuration.
50
+ * @returns {boolean} whether E2EE can run in this browser.
51
+ */
52
+ MeetingsUtil.isE2eeEnabledAndSupported = (config?: {meetings?: {enableE2ee?: boolean}}): boolean =>
53
+ !!config?.meetings?.enableE2ee && WebCapabilities.supportsWasm() === CapabilityState.CAPABLE;
54
+
47
55
  MeetingsUtil.getMeetingAddedType = (type: DESTINATION_TYPE) =>
48
56
  type === DESTINATION_TYPE.LOCUS_ID ? _INCOMING_ : _CREATED_;
49
57
 
@@ -2,11 +2,19 @@
2
2
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
  import {MEETINGS, _IN_LOBBY_, _NOT_IN_MEETING_, _IN_MEETING_, _OBSERVE_} from '../constants';
5
+ import {
6
+ E2eeDeviceVerificationState,
7
+ E2eeIdentityType,
8
+ E2eeMemberVerificationState,
9
+ E2eeValidationResult,
10
+ } from '../e2ee/types';
11
+ import type {E2eeDeviceVerification} from '../e2ee/types';
5
12
  import {IExternalRoles, IMediaStatus, Participant, ParticipantUrl} from './types';
6
13
 
7
14
  import MemberUtil from './util';
8
15
 
9
16
  export type MemberId = string;
17
+
10
18
  /**
11
19
  * @class Member
12
20
  */
@@ -53,6 +61,10 @@ export default class Member {
53
61
  memberId?: MemberId;
54
62
  };
55
63
 
64
+ // Per-device E2EE verification, keyed by device URL, applied by the E2EE roster reconciler.
65
+ e2eeDeviceVerifications: Map<string, E2eeDeviceVerification>;
66
+ e2eeVerificationState: E2eeMemberVerificationState;
67
+
56
68
  /**
57
69
  * @param {Object} participant - the locus participant
58
70
  * @param {Object} [options] - constructor params
@@ -329,6 +341,8 @@ export default class Member {
329
341
  participantUrl: undefined,
330
342
  memberId: undefined,
331
343
  };
344
+ this.e2eeDeviceVerifications = new Map();
345
+ this.e2eeVerificationState = E2eeMemberVerificationState.Unknown;
332
346
  /**
333
347
  * @instance
334
348
  * @type {IMediaStatus}
@@ -504,6 +518,161 @@ export default class Member {
504
518
  this.isSelf = flag;
505
519
  }
506
520
 
521
+ /**
522
+ * Replaces this member's per-device E2EE verifications and recomputes the aggregate state.
523
+ * Called by the E2EE roster reconciler; a member with no matching MLS roster devices is reset.
524
+ * @param {E2eeDeviceVerification[]} verifications
525
+ * @returns {undefined}
526
+ * @public
527
+ * @memberof Member
528
+ */
529
+ public setE2eeDeviceVerifications(verifications: E2eeDeviceVerification[]) {
530
+ this.e2eeDeviceVerifications = new Map(
531
+ verifications.map((verification) => [verification.deviceUrl, verification])
532
+ );
533
+ this.recomputeE2eeVerificationState();
534
+ }
535
+
536
+ /**
537
+ * Upserts the verification for a single device and recomputes the aggregate state.
538
+ * @param {String} deviceUrl
539
+ * @param {E2eeDeviceVerification} verification
540
+ * @returns {boolean} whether the verification actually changed.
541
+ * @public
542
+ * @memberof Member
543
+ */
544
+ public setE2eeDeviceVerification(
545
+ deviceUrl: string,
546
+ verification: E2eeDeviceVerification
547
+ ): boolean {
548
+ const previous = this.e2eeDeviceVerifications.get(deviceUrl);
549
+
550
+ if (previous && JSON.stringify(previous) === JSON.stringify(verification)) {
551
+ return false;
552
+ }
553
+
554
+ this.e2eeDeviceVerifications.set(deviceUrl, verification);
555
+ this.recomputeE2eeVerificationState();
556
+
557
+ return true;
558
+ }
559
+
560
+ /**
561
+ * Removes the verification for a single device and recomputes the aggregate state.
562
+ * @param {String} deviceUrl
563
+ * @returns {boolean} whether a verification was actually removed.
564
+ * @public
565
+ * @memberof Member
566
+ */
567
+ public removeE2eeDeviceVerification(deviceUrl: string): boolean {
568
+ if (!this.e2eeDeviceVerifications.has(deviceUrl)) {
569
+ return false;
570
+ }
571
+
572
+ this.e2eeDeviceVerifications.delete(deviceUrl);
573
+ this.recomputeE2eeVerificationState();
574
+
575
+ return true;
576
+ }
577
+
578
+ /**
579
+ * @param {String} deviceUrl
580
+ * @returns {E2eeDeviceVerification | undefined} the verification for a single device.
581
+ * @public
582
+ * @memberof Member
583
+ */
584
+ public getE2eeDeviceVerification(deviceUrl: string): E2eeDeviceVerification | undefined {
585
+ return this.e2eeDeviceVerifications.get(deviceUrl);
586
+ }
587
+
588
+ /**
589
+ * @returns {E2eeDeviceVerification[]} all per-device verifications for this member.
590
+ * @public
591
+ * @memberof Member
592
+ */
593
+ public getE2eeDeviceVerifications(): E2eeDeviceVerification[] {
594
+ return Array.from(this.e2eeDeviceVerifications.values());
595
+ }
596
+
597
+ /**
598
+ * Recomputes the aggregate E2EE verification state from the per-device X.509 identity results.
599
+ * A successful X.509 result is classified by its leaf identity type, matching UCF's per-device
600
+ * identity display; the resulting device states are then aggregated across this Member's devices.
601
+ * @returns {undefined}
602
+ * @private
603
+ * @memberof Member
604
+ */
605
+ private recomputeE2eeVerificationState() {
606
+ const verifications = this.getE2eeDeviceVerifications();
607
+
608
+ if (verifications.length === 0) {
609
+ this.e2eeVerificationState = E2eeMemberVerificationState.Unknown;
610
+
611
+ return;
612
+ }
613
+
614
+ const deviceStates = verifications.map((verification) =>
615
+ this.getE2eeDeviceVerificationState(verification)
616
+ );
617
+ const verifiedCount = deviceStates.filter(
618
+ (state) => state === E2eeDeviceVerificationState.Verified
619
+ ).length;
620
+
621
+ if (verifiedCount === deviceStates.length) {
622
+ this.e2eeVerificationState = E2eeMemberVerificationState.Verified;
623
+ } else if (verifiedCount === 0) {
624
+ this.e2eeVerificationState = deviceStates.every(
625
+ (state) => state === E2eeDeviceVerificationState.Unknown
626
+ )
627
+ ? E2eeMemberVerificationState.Unknown
628
+ : E2eeMemberVerificationState.Unverified;
629
+ } else {
630
+ this.e2eeVerificationState = E2eeMemberVerificationState.PartiallyVerified;
631
+ }
632
+ }
633
+
634
+ /**
635
+ * Derives the identity status for one device using the same X.509 result selection and identity
636
+ * type rules as UCF. `validationResult` is the aggregate credential result, so it is not enough
637
+ * to classify MultiCredential identities on its own.
638
+ * @param {E2eeDeviceVerification} verification
639
+ * @returns {E2eeDeviceVerificationState}
640
+ * @private
641
+ * @memberof Member
642
+ */
643
+ private getE2eeDeviceVerificationState(
644
+ verification: E2eeDeviceVerification
645
+ ): E2eeDeviceVerificationState {
646
+ const identityResults = verification.identityResults ?? [];
647
+
648
+ if (identityResults.length === 0) {
649
+ return E2eeDeviceVerificationState.Unknown;
650
+ }
651
+
652
+ const identityResult =
653
+ identityResults.find((result) => result.result === E2eeValidationResult.Success) ??
654
+ identityResults[0];
655
+
656
+ if (!identityResult) {
657
+ return E2eeDeviceVerificationState.Unknown;
658
+ }
659
+
660
+ if (identityResult.result !== E2eeValidationResult.Success) {
661
+ return E2eeDeviceVerificationState.Unverified;
662
+ }
663
+
664
+ switch (identityResult.certificateChain[0]?.identityType) {
665
+ case E2eeIdentityType.WebexMachineIdentity:
666
+ case E2eeIdentityType.WebexUserIdentity:
667
+ case E2eeIdentityType.ExternalVerifiedIdentity:
668
+ return E2eeDeviceVerificationState.Verified;
669
+ case E2eeIdentityType.WebexAnonymousIdentity:
670
+ return E2eeDeviceVerificationState.Unverified;
671
+ default:
672
+ return E2eeDeviceVerificationState.Unknown;
673
+ }
674
+ }
675
+
507
676
  /**
508
677
  * determine if this member is content sharing
509
678
  * @param {Object} participant
@@ -55,6 +55,7 @@ export interface ParticipantDevice {
55
55
  mediaSessions: Array<MediaSession>;
56
56
  mediaSessionsExternal: boolean;
57
57
  state: string; // probably one of MEETING_STATE.STATES
58
+ url: string; // device (WDM) URL; present at runtime, used to match against the MLS roster
58
59
  }
59
60
 
60
61
  // this is not a complete type, Locus may send more fields
@@ -7,20 +7,41 @@ import Member from '../member';
7
7
  export default class MembersCollection {
8
8
  members: Record<string, Member>;
9
9
  namespace = MEETINGS;
10
+
11
+ // Reverse index: device URL -> owning Member, kept in sync with the collection.
12
+ private memberByDeviceUrl: Map<string, Member>;
13
+
10
14
  /**
11
15
  * @param {Object} locus
12
16
  * @memberof Members
13
17
  */
14
18
  constructor() {
15
19
  this.members = {};
20
+ this.memberByDeviceUrl = new Map();
16
21
  }
17
22
 
23
+ /**
24
+ * @param {String} id
25
+ * @param {Member} member
26
+ * @returns {void}
27
+ */
18
28
  set(id: string, member: Member) {
29
+ const existing = this.members[id];
30
+
31
+ if (existing) {
32
+ this.removeFromDeviceUrlIndex(existing);
33
+ }
19
34
  this.members[id] = member;
35
+ this.addToDeviceUrlIndex(member);
20
36
  }
21
37
 
38
+ /**
39
+ * @param {Object} members
40
+ * @returns {void}
41
+ */
22
42
  setAll(members: Record<string, Member>) {
23
43
  this.members = members;
44
+ this.rebuildDeviceUrlIndex();
24
45
  }
25
46
 
26
47
  /**
@@ -31,6 +52,15 @@ export default class MembersCollection {
31
52
  return this.members[id];
32
53
  }
33
54
 
55
+ /**
56
+ * @param {String} deviceUrl
57
+ * @returns {Member | undefined} the member that owns the given device URL, if any.
58
+ * @memberof MembersCollection
59
+ */
60
+ getMemberByDeviceUrl(deviceUrl: string): Member | undefined {
61
+ return this.memberByDeviceUrl.get(deviceUrl);
62
+ }
63
+
34
64
  /**
35
65
  * @returns {Object} returns an object map of Member instances
36
66
  * @memberof MembersCollection
@@ -45,7 +75,10 @@ export default class MembersCollection {
45
75
  * @returns {void}
46
76
  */
47
77
  remove(id: string) {
48
- if (this.members[id]) {
78
+ const existing = this.members[id];
79
+
80
+ if (existing) {
81
+ this.removeFromDeviceUrlIndex(existing);
49
82
  delete this.members[id];
50
83
  }
51
84
  }
@@ -56,5 +89,38 @@ export default class MembersCollection {
56
89
  */
57
90
  reset() {
58
91
  this.members = {};
92
+ this.memberByDeviceUrl.clear();
93
+ }
94
+
95
+ /**
96
+ * @param {Member} member
97
+ * @returns {void}
98
+ */
99
+ private addToDeviceUrlIndex(member: Member) {
100
+ member.participant?.devices?.forEach((device) => {
101
+ if (device?.url) {
102
+ this.memberByDeviceUrl.set(device.url, member);
103
+ }
104
+ });
105
+ }
106
+
107
+ /**
108
+ * @param {Member} member
109
+ * @returns {void}
110
+ */
111
+ private removeFromDeviceUrlIndex(member: Member) {
112
+ member.participant?.devices?.forEach((device) => {
113
+ if (device?.url && this.memberByDeviceUrl.get(device.url) === member) {
114
+ this.memberByDeviceUrl.delete(device.url);
115
+ }
116
+ });
117
+ }
118
+
119
+ /**
120
+ * @returns {void}
121
+ */
122
+ private rebuildDeviceUrlIndex() {
123
+ this.memberByDeviceUrl.clear();
124
+ Object.values(this.members).forEach((member) => this.addToDeviceUrlIndex(member));
59
125
  }
60
126
  }