Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions JitsiConference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import P2PDominantSpeakerDetection from './modules/detection/P2PDominantSpeakerD
import VADAudioAnalyser, { IVADProcessor } from './modules/detection/VADAudioAnalyser';
import VADNoiseDetection from './modules/detection/VADNoiseDetection';
import VADTalkMutedDetection from './modules/detection/VADTalkMutedDetection';
import { E2EEncryption } from './modules/e2ee/E2EEncryption';
import { E2EEncryption, IMediaEncryptionKeyInfo } from './modules/e2ee/E2EEncryption';
import E2ePing from './modules/e2eping/e2eping';
import FeatureFlags from './modules/flags/FeatureFlags';
import { LiteModeContext } from './modules/litemode/LiteModeContext';
Expand Down Expand Up @@ -100,9 +100,14 @@ export interface IConferenceOptions {
disableAudioLevels?: boolean;
disableLocalStats?: boolean;
disableLocalStatsBroadcast?: boolean;
e2ee?: {
disabled?: boolean;
externallyManagedKey?: boolean;
};
e2eping?: {
enabled?: boolean;
};
enableEncodedTransformSupport?: boolean;
enableNoAudioDetection?: boolean;
enableNoisyMicDetection?: boolean;
enableTalkWhileMuted?: boolean;
Expand All @@ -126,6 +131,7 @@ export interface IConferenceOptions {
statisticsId?: string;
testing?: {
allowMultipleTracks?: boolean;
disableE2EE?: boolean;
enableAV1ForFF?: boolean;
enableFirefoxP2p?: boolean;
forceInitiator?: boolean;
Expand Down Expand Up @@ -4333,7 +4339,7 @@ export default class JitsiConference extends Listenable {
* @param {Number} [keyInfo.index] - the index of the encryption key.
* @returns {void}
*/
public setMediaEncryptionKey(keyInfo: CryptoKey): void {
public setMediaEncryptionKey(keyInfo: IMediaEncryptionKeyInfo): void {
this._e2eEncryption.setEncryptionKey(keyInfo);
}

Expand Down
35 changes: 22 additions & 13 deletions modules/e2ee/E2EEncryption.js → modules/e2ee/E2EEncryption.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import JitsiConference, { IConferenceOptions } from '../../JitsiConference';
import JitsiParticipant from '../../JitsiParticipant';
import browser from '../browser';

import { ExternallyManagedKeyHandler } from './ExternallyManagedKeyHandler';
import { ManagedKeyHandler } from './ManagedKeyHandler';
import { OlmAdapter } from './OlmAdapter';


export interface IMediaEncryptionKeyInfo {
encryptionKey?: CryptoKey;
index?: number;
}

/**
* This module integrates {@link KeyHandler} with {@link JitsiConference} in order to enable E2E encryption.
*/
export class E2EEncryption {
private _externallyManaged: boolean;
private _keyHandler: ExternallyManagedKeyHandler | ManagedKeyHandler;

/**
* A constructor.
* @param {JitsiConference} conference - The conference instance for which E2E encryption is to be enabled.
*/
constructor(conference) {
constructor(conference: JitsiConference) {
const { e2ee = {} } = conference.options.config;

this._externallyManaged = e2ee.externallyManagedKey;
Expand All @@ -30,7 +41,7 @@ export class E2EEncryption {
* @param {object} config - Global configuration.
* @returns {boolean}
*/
static isSupported(config) {
static isSupported(config: IConferenceOptions['config']): boolean {
const { e2ee = {} } = config;

if (!e2ee.externallyManagedKey && !OlmAdapter.isSupported()) {
Expand All @@ -50,7 +61,7 @@ export class E2EEncryption {
*
* @returns {boolean}
*/
isEnabled() {
isEnabled(): boolean {
return this._keyHandler.isEnabled();
}

Expand All @@ -60,19 +71,17 @@ export class E2EEncryption {
* @param {boolean} enabled - whether E2EE should be enabled or not.
* @returns {void}
*/
async setEnabled(enabled) {
async setEnabled(enabled: boolean): Promise<void> {
await this._keyHandler.setEnabled(enabled);
}

/**
* Sets the key and index for End-to-End encryption.
*
* @param {CryptoKey} [keyInfo.encryptionKey] - encryption key.
* @param {Number} [keyInfo.index] - the index of the encryption key.
* @param {IMediaEncryptionKeyInfo} [keyInfo]
* @returns {void}
*/
setEncryptionKey(keyInfo) {
this._keyHandler.setKey(keyInfo);
setEncryptionKey(keyInfo: IMediaEncryptionKeyInfo): void {
(this._keyHandler as ExternallyManagedKeyHandler).setKey(keyInfo);
}

/**
Expand All @@ -81,8 +90,8 @@ export class E2EEncryption {
* @param {Participant} - participant to be verified.
* @returns {void}
*/
startVerification(participant) {
this._keyHandler.sasVerification?.startVerification(participant);
startVerification(participant: JitsiParticipant): void {
(this._keyHandler as ManagedKeyHandler).sasVerification?.startVerification(participant);
}

/**
Expand All @@ -92,7 +101,7 @@ export class E2EEncryption {
* @param {boolean} isVerified - whether the verification was succesfull.
* @returns {void}
*/
markParticipantVerified(participant, isVerified) {
this._keyHandler.sasVerification?.markParticipantVerified(participant, isVerified);
markParticipantVerified(participant: JitsiParticipant, isVerified: boolean): void {
(this._keyHandler as ManagedKeyHandler).sasVerification?.markParticipantVerified(participant, isVerified);
}
}
2 changes: 1 addition & 1 deletion modules/e2ee/OlmAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class OlmAdapter extends Listenable {
*
* @param {JitsiParticipant} participant - The target participant.
* @returns {Promise<void>}
* @private
* @internal
*/
startVerification(participant) {
const pId = participant.getId();
Expand Down