Skip to content
Closed
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
1 change: 1 addition & 0 deletions JitsiConference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,7 @@ export default class JitsiConference extends Listenable {
}

public restartMediaSessions() {
console.trace('[restartMediaSessions] caller');
this._restartMediaSessions();
}

Expand Down
27 changes: 24 additions & 3 deletions modules/e2ee-internxt/ManagedKeyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { JitsiConferenceEvents } from '../../JitsiConferenceEvents';
import JitsiParticipant from '../../JitsiParticipant';
import { RTCEvents } from '../../service/RTC/RTCEvents';
import JitsiLocalTrack from '../RTC/JitsiLocalTrack';
import JitsiRemoteTrack from '../RTC/JitsiRemoteTrack';
import JitsiTrack from '../RTC/JitsiTrack';
import TraceablePeerConnection from '../RTC/TraceablePeerConnection';
import browser from '../browser';
Expand Down Expand Up @@ -71,7 +72,7 @@ export class ManagedKeyHandler extends Listenable {
onConferenceLeft: (() => void) | undefined;
onMediaSessionStarted: ((session: JingleSessionPC) => void) | undefined;
onTrackAdded: ((track: JitsiTrack) => void) | undefined;
onRemoteTrackAdded: ((track: JitsiLocalTrack, tpc: TraceablePeerConnection) => void) | undefined;
onRemoteTrackAdded: ((track: JitsiRemoteTrack, tpc: TraceablePeerConnection) => void) | undefined;
onTrackMuteChanged: ((track: JitsiLocalTrack) => void) | undefined;
onSasUpdated: ((sasStr: string) => void) | undefined;

Expand Down Expand Up @@ -253,7 +254,7 @@ export class ManagedKeyHandler extends Listenable {
* @private
*/
private _setupReceiverE2EEForTrack(
track: JitsiLocalTrack,
track: JitsiRemoteTrack,
tpc: TraceablePeerConnection,
) {
if (!this.enabled) {
Expand Down Expand Up @@ -765,6 +766,24 @@ export class ManagedKeyHandler extends Listenable {
console[level](`E2E: User ${this.myID}: ${message}`);
}

private _setupE2EEForExistingTracks() {
for (const session of this.conference.getMediaSessions()) {
const pc = session.peerconnection;

if (!pc) {
continue;
}

for (const track of this.conference.getLocalTracks()) {
this._setupSenderE2EEForTrack(session, track);
}

for (const track of pc.getRemoteTracks()) {
this._setupReceiverE2EEForTrack(track, pc);
}
}
}

_onParticipantJoined(id: string) {
this._queueParticipantEvent('join', id);
}
Expand Down Expand Up @@ -976,15 +995,17 @@ export class ManagedKeyHandler extends Listenable {
if (enabled) {
this.log('info', 'Enabling e2ee');
await this.enableE2E();
this._setupE2EEForExistingTracks();
}

if (!enabled) {
this.log('info', 'Disabling e2ee');
await this.disableE2E();
this.conference.restartMediaSessions();
}

this.conference.setLocalParticipantProperty('e2ee.enabled', enabled.toString());
this.conference.restartMediaSessions();

}

async messageReceived(participant: JitsiParticipant, payload) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lib-meet",
"version": "1.0.3",
"version": "1.0.3-test",
"description": "JS library for accessing Jitsi server side deployments",
"repository": {
"type": "git",
Expand Down
18 changes: 14 additions & 4 deletions tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class XmppServerMock {

const pId = keyHandler.conference.myUserId();

if (!pId) {
throw new Error('Mock got undefined user ID');
}

if (!this.listeners.has(pId)) {
this.listeners.forEach((existingHandler, _id) => {
existingHandler._onParticipantJoined(pId);
Expand Down Expand Up @@ -153,10 +157,14 @@ export class XmppServerMock {
sendMessage(myId: string, pId: string, payload: any) {
this.listeners.forEach((keyHandler, id) => {
if (id === pId) {
keyHandler.messageReceived(
this.participants.get(myId),
payload,
);
const participant = this.participants.get(myId);

if (participant) {
keyHandler.messageReceived(
participant,
payload,
);
}
}
});
}
Expand All @@ -182,6 +190,8 @@ export async function createInitializedManagedKeyHandler(
const mockRTC = new RTC(conferenceMock);

when(conferenceMock.rtc).thenReturn(mockRTC);
when(conferenceMock.getMediaSessions()).thenReturn([]);
when(conferenceMock.getLocalTracks()).thenReturn([]);

const eventEmitterMock = mock<EventEmitter>();

Expand Down
Loading