From 33ebd241a993a4869912f90ff1d71123d277ee62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 16 Apr 2020 15:26:45 +0200 Subject: [PATCH] external_api: add command to set E2EE key --- modules/API/API.js | 5 +++++ modules/API/external/external_api.js | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/API/API.js b/modules/API/API.js index cd7b87f9e..a37199b3c 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -11,6 +11,7 @@ import { setSubject } from '../../react/features/base/conference'; import { parseJWTFromURLParams } from '../../react/features/base/jwt'; +import { setE2EEKey } from '../../react/features/e2ee'; import { invite } from '../../react/features/invite'; import { toggleTileView } from '../../react/features/video-layout'; import { getJitsiMeetTransport } from '../transport'; @@ -166,6 +167,10 @@ function initCommands() { } catch (err) { logger.error('Failed sending endpoint text message', err); } + }, + 'e2ee-key': key => { + logger.debug('Set E2EE key command received'); + APP.store.dispatch(setE2EEKey(key)); } }; transport.on('event', ({ data, name }) => { diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index c0c956627..c0d3a8cdb 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -29,6 +29,7 @@ const ALWAYS_ON_TOP_FILENAMES = [ const commands = { avatarUrl: 'avatar-url', displayName: 'display-name', + e2eeKey: 'e2ee-key', email: 'email', hangup: 'video-hangup', password: 'password', @@ -236,6 +237,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter { * information about the initial devices that will be used in the call. * @param {Object} [options.userInfo] - Object containing information about * the participant opening the meeting. + * @param {string} [options.e2eeKey] - The key used for End-to-End encryption. + * THIS IS EXPERIMENTAL. */ constructor(domain, ...args) { super(); @@ -251,7 +254,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter { onload = undefined, invitees, devices, - userInfo + userInfo, + e2eeKey } = parseArguments(args); this._parentNode = parentNode; @@ -276,6 +280,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter { if (Array.isArray(invitees) && invitees.length > 0) { this.invite(invitees); } + this._tmpE2EEKey = e2eeKey; this._isLargeVideoVisible = true; this._numberOfParticipants = 0; this._participants = {}; @@ -429,11 +434,17 @@ export default class JitsiMeetExternalAPI extends EventEmitter { const userID = data.id; switch (name) { - case 'video-conference-joined': + case 'video-conference-joined': { + if (typeof this._tmpE2EEKey !== 'undefined') { + this.executeCommand(commands.e2eeKey, this._tmpE2EEKey); + this._tmpE2EEKey = undefined; + } + this._myUserID = userID; this._participants[userID] = { avatarURL: data.avatarURL }; + } // eslint-disable-next-line no-fallthrough case 'participant-joined': {