external_api: add command to set E2EE key

This commit is contained in:
Saúl Ibarra Corretgé 2020-04-16 15:26:45 +02:00 committed by Saúl Ibarra Corretgé
parent cb6fbb0f03
commit 33ebd241a9
2 changed files with 18 additions and 2 deletions

View File

@ -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 }) => {

View File

@ -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': {