mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-28 06:50:26 +00:00
Actually validate lk-jwt-service response
This commit is contained in:
@@ -122,7 +122,23 @@ async function getLiveKitJWT(
|
||||
}
|
||||
|
||||
try {
|
||||
return await res.json();
|
||||
const json = await res.json();
|
||||
if (typeof json.jwt !== "string") {
|
||||
// We don't need to check that the JWT is valid, because we pass it through to
|
||||
// the SFU opaquely.
|
||||
throw new Error("Invalid jwt field in server response: not string");
|
||||
}
|
||||
if (typeof json.url !== "string") {
|
||||
throw new Error("Invalid url field in server response: not string");
|
||||
}
|
||||
if (!json.url.startsWith("wss://")) {
|
||||
throw new Error("Invalid url field in server response: not a wss:// URL");
|
||||
}
|
||||
|
||||
return {
|
||||
jwt: json.jwt,
|
||||
url: json.url,
|
||||
};
|
||||
} catch (e) {
|
||||
throw new InvalidServerResponseError(url, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user