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