@@ -1,3 +1,4 @@
|
|||||||
|
// TODO not used anymore - remove
|
||||||
/*
|
/*
|
||||||
Copyright 2023, 2024 New Vector Ltd.
|
Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import { observeParticipantEvents } from "@livekit/components-core";
|
import { observeParticipantEvents } from "@livekit/components-core";
|
||||||
import {
|
import {
|
||||||
ConnectionState,
|
ConnectionState,
|
||||||
type E2EEOptions,
|
type BaseKeyProvider,
|
||||||
ExternalE2EEKeyProvider,
|
ExternalE2EEKeyProvider,
|
||||||
type Room as LivekitRoom,
|
type Room as LivekitRoom,
|
||||||
type LocalParticipant,
|
type LocalParticipant,
|
||||||
@@ -433,7 +433,7 @@ function getRoomMemberFromRtcMember(
|
|||||||
export class CallViewModel extends ViewModel {
|
export class CallViewModel extends ViewModel {
|
||||||
private readonly livekitAlias = getLivekitAlias(this.matrixRTCSession);
|
private readonly livekitAlias = getLivekitAlias(this.matrixRTCSession);
|
||||||
|
|
||||||
private readonly livekitE2EERoomOptions = getE2eeOptions(
|
private readonly livekitE2EEKeyProvider = getE2eeKeyProvider(
|
||||||
this.options.encryptionSystem,
|
this.options.encryptionSystem,
|
||||||
this.matrixRTCSession,
|
this.matrixRTCSession,
|
||||||
);
|
);
|
||||||
@@ -450,10 +450,25 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.membershipsAndFocusMap$,
|
this.membershipsAndFocusMap$,
|
||||||
this.mediaDevices,
|
this.mediaDevices,
|
||||||
this.muteStates,
|
this.muteStates,
|
||||||
this.livekitE2EERoomOptions,
|
this.livekitE2EEKeyProvider
|
||||||
|
? {
|
||||||
|
keyProvider: this.livekitE2EEKeyProvider,
|
||||||
|
worker: new E2EEWorker(),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private readonly memberships$ = this.scope.behavior(
|
||||||
|
fromEvent(
|
||||||
|
this.matrixRTCSession,
|
||||||
|
MatrixRTCSessionEvent.MembershipsChanged,
|
||||||
|
).pipe(
|
||||||
|
startWith(null),
|
||||||
|
map(() => this.matrixRTCSession.memberships),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
private readonly membershipsAndFocusMap$ = this.scope.behavior(
|
private readonly membershipsAndFocusMap$ = this.scope.behavior(
|
||||||
this.memberships$.pipe(
|
this.memberships$.pipe(
|
||||||
map((memberships) =>
|
map((memberships) =>
|
||||||
@@ -496,7 +511,12 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.matrixRTCSession.room.client,
|
this.matrixRTCSession.room.client,
|
||||||
this.scope,
|
this.scope,
|
||||||
this.membershipsAndFocusMap$,
|
this.membershipsAndFocusMap$,
|
||||||
this.livekitE2EERoomOptions,
|
this.livekitE2EEKeyProvider
|
||||||
|
? {
|
||||||
|
keyProvider: this.livekitE2EEKeyProvider,
|
||||||
|
worker: new E2EEWorker(),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.log(
|
||||||
@@ -623,16 +643,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
// in a split-brained state.
|
// in a split-brained state.
|
||||||
private readonly pretendToBeDisconnected$ = this.reconnecting$;
|
private readonly pretendToBeDisconnected$ = this.reconnecting$;
|
||||||
|
|
||||||
private readonly memberships$ = this.scope.behavior(
|
|
||||||
fromEvent(
|
|
||||||
this.matrixRTCSession,
|
|
||||||
MatrixRTCSessionEvent.MembershipsChanged,
|
|
||||||
).pipe(
|
|
||||||
startWith(null),
|
|
||||||
pauseWhen(this.pretendToBeDisconnected$),
|
|
||||||
map(() => this.matrixRTCSession.memberships),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
private readonly participants$ = this.scope.behavior<
|
private readonly participants$ = this.scope.behavior<
|
||||||
{
|
{
|
||||||
@@ -1875,28 +1885,21 @@ export class CallViewModel extends ViewModel {
|
|||||||
// TODO-MULTI-SFU // Setup and update the keyProvider which was create by `createRoom` was a thing before. Now we never update if the E2EEsystem changes
|
// TODO-MULTI-SFU // Setup and update the keyProvider which was create by `createRoom` was a thing before. Now we never update if the E2EEsystem changes
|
||||||
// do we need this?
|
// do we need this?
|
||||||
|
|
||||||
function getE2eeOptions(
|
function getE2eeKeyProvider(
|
||||||
e2eeSystem: EncryptionSystem,
|
e2eeSystem: EncryptionSystem,
|
||||||
rtcSession: MatrixRTCSession,
|
rtcSession: MatrixRTCSession,
|
||||||
): E2EEOptions | undefined {
|
): BaseKeyProvider | undefined {
|
||||||
return undefined;
|
|
||||||
if (e2eeSystem.kind === E2eeType.NONE) return undefined;
|
if (e2eeSystem.kind === E2eeType.NONE) return undefined;
|
||||||
|
|
||||||
if (e2eeSystem.kind === E2eeType.PER_PARTICIPANT) {
|
if (e2eeSystem.kind === E2eeType.PER_PARTICIPANT) {
|
||||||
const keyProvider = new MatrixKeyProvider();
|
const keyProvider = new MatrixKeyProvider();
|
||||||
keyProvider.setRTCSession(rtcSession);
|
keyProvider.setRTCSession(rtcSession);
|
||||||
return {
|
return keyProvider;
|
||||||
keyProvider,
|
|
||||||
worker: new E2EEWorker(),
|
|
||||||
};
|
|
||||||
} else if (e2eeSystem.kind === E2eeType.SHARED_KEY && e2eeSystem.secret) {
|
} else if (e2eeSystem.kind === E2eeType.SHARED_KEY && e2eeSystem.secret) {
|
||||||
const keyProvider = new ExternalE2EEKeyProvider();
|
const keyProvider = new ExternalE2EEKeyProvider();
|
||||||
keyProvider
|
keyProvider
|
||||||
.setKey(e2eeSystem.secret)
|
.setKey(e2eeSystem.secret)
|
||||||
.catch((e) => logger.error("Failed to set shared key for E2EE", e));
|
.catch((e) => logger.error("Failed to set shared key for E2EE", e));
|
||||||
return {
|
return keyProvider;
|
||||||
keyProvider,
|
|
||||||
worker: new E2EEWorker(),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user