Use a newly generated access_token while joining Jitsi (#24646)
Fixes: #24687 Signed-off-by: Emrah Eryilmaz emrah.com@gmail.compull/24895/head
parent
b9b0b096a4
commit
2575322360
|
@ -52,7 +52,6 @@ let avatarUrl: string;
|
||||||
let userId: string;
|
let userId: string;
|
||||||
let jitsiAuth: string;
|
let jitsiAuth: string;
|
||||||
let roomId: string;
|
let roomId: string;
|
||||||
let openIdToken: IOpenIDCredentials;
|
|
||||||
let roomName: string;
|
let roomName: string;
|
||||||
let startAudioOnly: boolean;
|
let startAudioOnly: boolean;
|
||||||
let startWithAudioMuted: boolean | undefined;
|
let startWithAudioMuted: boolean | undefined;
|
||||||
|
@ -223,13 +222,6 @@ const setupCompleted = (async (): Promise<string | void> => {
|
||||||
|
|
||||||
if (widgetApi) {
|
if (widgetApi) {
|
||||||
await widgetApiReady;
|
await widgetApiReady;
|
||||||
|
|
||||||
// See https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
|
|
||||||
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
|
||||||
// Request credentials, give callback to continue when received
|
|
||||||
openIdToken = await widgetApi.requestOpenIDConnectToken();
|
|
||||||
logger.log("Got OpenID Connect token");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that everything should be set up, skip to the Jitsi splash screen if needed
|
// Now that everything should be set up, skip to the Jitsi splash screen if needed
|
||||||
|
@ -245,7 +237,7 @@ const setupCompleted = (async (): Promise<string | void> => {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function enableJoinButton(): void {
|
function enableJoinButton(): void {
|
||||||
document.getElementById("joinButton").onclick = (): void => joinConference();
|
document.getElementById("joinButton").onclick = (): Promise<void> => joinConference();
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchVisibleContainers(): void {
|
function switchVisibleContainers(): void {
|
||||||
|
@ -271,11 +263,11 @@ function skipToJitsiSplashScreen(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a JWT token fot jitsi openidtoken-jwt auth
|
* Create a JWT token for jitsi openidtoken-jwt auth
|
||||||
*
|
*
|
||||||
* See https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
|
* See https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
|
||||||
*/
|
*/
|
||||||
function createJWTToken(): string {
|
function createJWTToken(openIdToken: IOpenIDCredentials): string {
|
||||||
// Header
|
// Header
|
||||||
const header = { alg: "HS256", typ: "JWT" };
|
const header = { alg: "HS256", typ: "JWT" };
|
||||||
// Payload
|
// Payload
|
||||||
|
@ -356,17 +348,21 @@ function mapLanguage(language: string): string {
|
||||||
// audio input it can find, while an input of null instructs it to start muted,
|
// audio input it can find, while an input of null instructs it to start muted,
|
||||||
// and a non-nullish input specifies the label of a specific device to use.
|
// and a non-nullish input specifies the label of a specific device to use.
|
||||||
// Same for video inputs.
|
// Same for video inputs.
|
||||||
function joinConference(audioInput?: string | null, videoInput?: string | null): void {
|
async function joinConference(audioInput?: string | null, videoInput?: string | null): Promise<void> {
|
||||||
let jwt;
|
let jwt;
|
||||||
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
||||||
if (!openIdToken?.access_token) {
|
// See https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
|
||||||
|
const openIdToken: IOpenIDCredentials = await widgetApi.requestOpenIDConnectToken();
|
||||||
|
logger.log("Got OpenID Connect token");
|
||||||
|
|
||||||
|
if (!openIdToken.access_token) {
|
||||||
// eslint-disable-line camelcase
|
// eslint-disable-line camelcase
|
||||||
// We've failing to get a token, don't try to init conference
|
// We've failing to get a token, don't try to init conference
|
||||||
logger.warn("Expected to have an OpenID credential, cannot initialize widget.");
|
logger.warn("Expected to have an OpenID credential, cannot initialize widget.");
|
||||||
document.getElementById("widgetActionContainer").innerText = "Failed to load Jitsi widget";
|
document.getElementById("widgetActionContainer").innerText = "Failed to load Jitsi widget";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jwt = createJWTToken();
|
jwt = createJWTToken(openIdToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
switchVisibleContainers();
|
switchVisibleContainers();
|
||||||
|
|
Loading…
Reference in New Issue