Browse Source

external_api: add command to set E2EE key

j8
Saúl Ibarra Corretgé 5 years ago
parent
commit
33ebd241a9
2 changed files with 18 additions and 2 deletions
  1. 5
    0
      modules/API/API.js
  2. 13
    2
      modules/API/external/external_api.js

+ 5
- 0
modules/API/API.js View File

@@ -11,6 +11,7 @@ import {
11 11
     setSubject
12 12
 } from '../../react/features/base/conference';
13 13
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
14
+import { setE2EEKey } from '../../react/features/e2ee';
14 15
 import { invite } from '../../react/features/invite';
15 16
 import { toggleTileView } from '../../react/features/video-layout';
16 17
 import { getJitsiMeetTransport } from '../transport';
@@ -166,6 +167,10 @@ function initCommands() {
166 167
             } catch (err) {
167 168
                 logger.error('Failed sending endpoint text message', err);
168 169
             }
170
+        },
171
+        'e2ee-key': key => {
172
+            logger.debug('Set E2EE key command received');
173
+            APP.store.dispatch(setE2EEKey(key));
169 174
         }
170 175
     };
171 176
     transport.on('event', ({ data, name }) => {

+ 13
- 2
modules/API/external/external_api.js View File

@@ -29,6 +29,7 @@ const ALWAYS_ON_TOP_FILENAMES = [
29 29
 const commands = {
30 30
     avatarUrl: 'avatar-url',
31 31
     displayName: 'display-name',
32
+    e2eeKey: 'e2ee-key',
32 33
     email: 'email',
33 34
     hangup: 'video-hangup',
34 35
     password: 'password',
@@ -236,6 +237,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
236 237
      * information about the initial devices that will be used in the call.
237 238
      * @param {Object} [options.userInfo] - Object containing information about
238 239
      * the participant opening the meeting.
240
+     * @param {string}  [options.e2eeKey] - The key used for End-to-End encryption.
241
+     * THIS IS EXPERIMENTAL.
239 242
      */
240 243
     constructor(domain, ...args) {
241 244
         super();
@@ -251,7 +254,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
251 254
             onload = undefined,
252 255
             invitees,
253 256
             devices,
254
-            userInfo
257
+            userInfo,
258
+            e2eeKey
255 259
         } = parseArguments(args);
256 260
 
257 261
         this._parentNode = parentNode;
@@ -276,6 +280,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
276 280
         if (Array.isArray(invitees) && invitees.length > 0) {
277 281
             this.invite(invitees);
278 282
         }
283
+        this._tmpE2EEKey = e2eeKey;
279 284
         this._isLargeVideoVisible = true;
280 285
         this._numberOfParticipants = 0;
281 286
         this._participants = {};
@@ -429,11 +434,17 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
429 434
             const userID = data.id;
430 435
 
431 436
             switch (name) {
432
-            case 'video-conference-joined':
437
+            case 'video-conference-joined': {
438
+                if (typeof this._tmpE2EEKey !== 'undefined') {
439
+                    this.executeCommand(commands.e2eeKey, this._tmpE2EEKey);
440
+                    this._tmpE2EEKey = undefined;
441
+                }
442
+
433 443
                 this._myUserID = userID;
434 444
                 this._participants[userID] = {
435 445
                     avatarURL: data.avatarURL
436 446
                 };
447
+            }
437 448
 
438 449
             // eslint-disable-next-line no-fallthrough
439 450
             case 'participant-joined': {

Loading…
Cancel
Save