diff --git a/src/e2ee/matrixKeyProvider.ts b/src/e2ee/matrixKeyProvider.ts index d7aebc4b..63a96755 100644 --- a/src/e2ee/matrixKeyProvider.ts +++ b/src/e2ee/matrixKeyProvider.ts @@ -61,12 +61,12 @@ export class MatrixKeyProvider extends BaseKeyProvider { ); logger.debug( - `Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${rtcBackendIdentity} (before hash: ${membershipParts.userId}) encryptionKeyIndex=${encryptionKeyIndex}`, + `Sent new key to livekit room=${this.rtcSession?.room.roomId} participantId=${rtcBackendIdentity} (before hash: ${membershipParts.userId}:${membershipParts.deviceId}) encryptionKeyIndex=${encryptionKeyIndex}`, ); }, (e) => { logger.error( - `Failed to create key material from buffer for livekit room=${this.rtcSession?.room.roomId} participantId before hash=${membershipParts.userId} encryptionKeyIndex=${encryptionKeyIndex}`, + `Failed to create key material from buffer for livekit room=${this.rtcSession?.room.roomId} participantId before hash=${membershipParts.userId}:${membershipParts.deviceId} encryptionKeyIndex=${encryptionKeyIndex}`, e, ); }, diff --git a/src/livekit/openIDSFU.ts b/src/livekit/openIDSFU.ts index 7d6dfc24..6728a243 100644 --- a/src/livekit/openIDSFU.ts +++ b/src/livekit/openIDSFU.ts @@ -20,6 +20,7 @@ export interface SFUConfig { url: string; jwt: string; livekitAlias: string; + // NOTE: Currently unused. livekitIdentity: string; } @@ -68,7 +69,7 @@ export type OpenIDClientParts = Pick< * @param client The Matrix client * @param membership * @param serviceUrl The URL of the livekit SFU service - * @param forceOldEndpoint This will use the old jwt endpoint which will create the rtc backend identity based on string concatination + * @param forceOldJwtEndpoint This will use the old jwt endpoint which will create the rtc backend identity based on string concatination * instead of a hash. * This function by default uses whatever is possible with the current jwt service installed next to the SFU. * For remote connections this does not matter, since we will not publish there we can rely on the newest option. @@ -103,12 +104,6 @@ export async function getSFUConfigWithOpenID( logger?.debug("Got openID token", openIdToken); logger?.info(`Trying to get JWT for focus ${serviceUrl}...`); - const args: [CallMembershipIdentityParts, string, string, IOpenIDToken] = [ - membership, - serviceUrl, - roomId, - openIdToken, - ]; let sfuConfig: { url: string; jwt: string }; try { @@ -118,7 +113,10 @@ export async function getSFUConfigWithOpenID( throw new Error("No delayId, Won't try matrix 2.0 jwt endpoint."); sfuConfig = await getLiveKitJWTWithDelayDelegation( - ...args, + membership, + serviceUrl, + roomId, + openIdToken, delayEndpointBaseUrl, delayId, ); @@ -128,23 +126,30 @@ export async function getSFUConfigWithOpenID( `Failed fetching jwt with matrix 2.0 endpoint (retry with legacy)`, e, ); - sfuConfig = await getLiveKitJWT(...args); + sfuConfig = await getLiveKitJWT( + membership.deviceId, + serviceUrl, + roomId, + openIdToken, + ); logger?.info(`Got JWT from call's active focus URL.`); } // Pull the details from the JWT const [, payloadStr] = sfuConfig.jwt.split("."); - + // TODO: Prefer Uint8Array.fromBase64 when widely available const payload = JSON.parse(global.atob(payloadStr)) as SFUJWTPayload; return { jwt: sfuConfig.jwt, url: sfuConfig.url, livekitAlias: payload.video.room, // NOTE: Currently unused. + // Probably also not helpful since we now compute the backendIdentity on joining the call so we can use it for the encryption manager. + // The only reason for us to know it locally is to connect the right users with the lk world. (and to set our own keys) livekitIdentity: payload.sub, }; } async function getLiveKitJWT( - membership: CallMembershipIdentityParts, + deviceId: string, livekitServiceURL: string, matrixRoomId: string, openIDToken: IOpenIDToken, @@ -159,7 +164,7 @@ async function getLiveKitJWT( // This is the actual livekit room alias. For the legacy jwt endpoint simply the room id was used. room: matrixRoomId, openid_token: openIDToken, - device_id: membership.deviceId, + device_id: deviceId, }), }); if (!res.ok) { diff --git a/src/room/InCallView.test.tsx b/src/room/InCallView.test.tsx index 8ac4bccb..a137074b 100644 --- a/src/room/InCallView.test.tsx +++ b/src/room/InCallView.test.tsx @@ -22,6 +22,7 @@ import { BrowserRouter } from "react-router-dom"; import { TooltipProvider } from "@vector-im/compound-web"; import { RoomContext, useLocalParticipant } from "@livekit/components-react"; +import { InCallView } from "./InCallView"; import { mockLivekitRoom, mockLocalParticipant, @@ -33,7 +34,6 @@ import { mockRtcMembership, type MockRTCSession, } from "../utils/test"; -import { InCallView } from "./InCallView"; import { E2eeType } from "../e2ee/e2eeType"; import { getBasicCallViewModelEnvironment } from "../utils/test-viewmodel"; import { alice, local } from "../utils/test-fixtures"; diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index a21c3302..fdbd4461 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -795,7 +795,6 @@ export const InCallView: FC = ({ onTouchEnd={onControlsTouchEnd} /> )} - {!showControls &&
}
); diff --git a/src/state/CallViewModel/CallViewModel.ts b/src/state/CallViewModel/CallViewModel.ts index 9c2fbc3d..093abfad 100644 --- a/src/state/CallViewModel/CallViewModel.ts +++ b/src/state/CallViewModel/CallViewModel.ts @@ -423,7 +423,8 @@ export function createCallViewModel$( const ownMembershipIdentity: CallMembershipIdentityParts = { userId, deviceId, - // TODO look into this!!! + // This will eventually become the salt for the hash endpoint. + // For now we keep it as the user+device string since it is expected by non matrix matrixRTCMode === Legacy. memberId: `${userId}:${deviceId}`, };