self review
This commit is contained in:
@@ -61,12 +61,12 @@ export class MatrixKeyProvider extends BaseKeyProvider {
|
|||||||
);
|
);
|
||||||
|
|
||||||
logger.debug(
|
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) => {
|
(e) => {
|
||||||
logger.error(
|
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,
|
e,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export interface SFUConfig {
|
|||||||
url: string;
|
url: string;
|
||||||
jwt: string;
|
jwt: string;
|
||||||
livekitAlias: string;
|
livekitAlias: string;
|
||||||
|
// NOTE: Currently unused.
|
||||||
livekitIdentity: string;
|
livekitIdentity: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ export type OpenIDClientParts = Pick<
|
|||||||
* @param client The Matrix client
|
* @param client The Matrix client
|
||||||
* @param membership
|
* @param membership
|
||||||
* @param serviceUrl The URL of the livekit SFU service
|
* @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.
|
* instead of a hash.
|
||||||
* This function by default uses whatever is possible with the current jwt service installed next to the SFU.
|
* 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.
|
* 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?.debug("Got openID token", openIdToken);
|
||||||
|
|
||||||
logger?.info(`Trying to get JWT for focus ${serviceUrl}...`);
|
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 };
|
let sfuConfig: { url: string; jwt: string };
|
||||||
try {
|
try {
|
||||||
@@ -118,7 +113,10 @@ export async function getSFUConfigWithOpenID(
|
|||||||
throw new Error("No delayId, Won't try matrix 2.0 jwt endpoint.");
|
throw new Error("No delayId, Won't try matrix 2.0 jwt endpoint.");
|
||||||
|
|
||||||
sfuConfig = await getLiveKitJWTWithDelayDelegation(
|
sfuConfig = await getLiveKitJWTWithDelayDelegation(
|
||||||
...args,
|
membership,
|
||||||
|
serviceUrl,
|
||||||
|
roomId,
|
||||||
|
openIdToken,
|
||||||
delayEndpointBaseUrl,
|
delayEndpointBaseUrl,
|
||||||
delayId,
|
delayId,
|
||||||
);
|
);
|
||||||
@@ -128,23 +126,30 @@ export async function getSFUConfigWithOpenID(
|
|||||||
`Failed fetching jwt with matrix 2.0 endpoint (retry with legacy)`,
|
`Failed fetching jwt with matrix 2.0 endpoint (retry with legacy)`,
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
sfuConfig = await getLiveKitJWT(...args);
|
sfuConfig = await getLiveKitJWT(
|
||||||
|
membership.deviceId,
|
||||||
|
serviceUrl,
|
||||||
|
roomId,
|
||||||
|
openIdToken,
|
||||||
|
);
|
||||||
logger?.info(`Got JWT from call's active focus URL.`);
|
logger?.info(`Got JWT from call's active focus URL.`);
|
||||||
} // Pull the details from the JWT
|
} // Pull the details from the JWT
|
||||||
const [, payloadStr] = sfuConfig.jwt.split(".");
|
const [, payloadStr] = sfuConfig.jwt.split(".");
|
||||||
|
// TODO: Prefer Uint8Array.fromBase64 when widely available
|
||||||
const payload = JSON.parse(global.atob(payloadStr)) as SFUJWTPayload;
|
const payload = JSON.parse(global.atob(payloadStr)) as SFUJWTPayload;
|
||||||
return {
|
return {
|
||||||
jwt: sfuConfig.jwt,
|
jwt: sfuConfig.jwt,
|
||||||
url: sfuConfig.url,
|
url: sfuConfig.url,
|
||||||
livekitAlias: payload.video.room,
|
livekitAlias: payload.video.room,
|
||||||
// NOTE: Currently unused.
|
// 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,
|
livekitIdentity: payload.sub,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLiveKitJWT(
|
async function getLiveKitJWT(
|
||||||
membership: CallMembershipIdentityParts,
|
deviceId: string,
|
||||||
livekitServiceURL: string,
|
livekitServiceURL: string,
|
||||||
matrixRoomId: string,
|
matrixRoomId: string,
|
||||||
openIDToken: IOpenIDToken,
|
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.
|
// This is the actual livekit room alias. For the legacy jwt endpoint simply the room id was used.
|
||||||
room: matrixRoomId,
|
room: matrixRoomId,
|
||||||
openid_token: openIDToken,
|
openid_token: openIDToken,
|
||||||
device_id: membership.deviceId,
|
device_id: deviceId,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { BrowserRouter } from "react-router-dom";
|
|||||||
import { TooltipProvider } from "@vector-im/compound-web";
|
import { TooltipProvider } from "@vector-im/compound-web";
|
||||||
import { RoomContext, useLocalParticipant } from "@livekit/components-react";
|
import { RoomContext, useLocalParticipant } from "@livekit/components-react";
|
||||||
|
|
||||||
|
import { InCallView } from "./InCallView";
|
||||||
import {
|
import {
|
||||||
mockLivekitRoom,
|
mockLivekitRoom,
|
||||||
mockLocalParticipant,
|
mockLocalParticipant,
|
||||||
@@ -33,7 +34,6 @@ import {
|
|||||||
mockRtcMembership,
|
mockRtcMembership,
|
||||||
type MockRTCSession,
|
type MockRTCSession,
|
||||||
} from "../utils/test";
|
} from "../utils/test";
|
||||||
import { InCallView } from "./InCallView";
|
|
||||||
import { E2eeType } from "../e2ee/e2eeType";
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
import { getBasicCallViewModelEnvironment } from "../utils/test-viewmodel";
|
import { getBasicCallViewModelEnvironment } from "../utils/test-viewmodel";
|
||||||
import { alice, local } from "../utils/test-fixtures";
|
import { alice, local } from "../utils/test-fixtures";
|
||||||
|
|||||||
@@ -795,7 +795,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
onTouchEnd={onControlsTouchEnd}
|
onTouchEnd={onControlsTouchEnd}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!showControls && <div className={styles.layout} />}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -423,7 +423,8 @@ export function createCallViewModel$(
|
|||||||
const ownMembershipIdentity: CallMembershipIdentityParts = {
|
const ownMembershipIdentity: CallMembershipIdentityParts = {
|
||||||
userId,
|
userId,
|
||||||
deviceId,
|
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}`,
|
memberId: `${userId}:${deviceId}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user