mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
Actually validate lk-jwt-service response
This commit is contained in:
@@ -122,7 +122,23 @@ async function getLiveKitJWT(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
throw new InvalidServerResponseError(url, e);
|
throw new InvalidServerResponseError(url, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user