mirror of https://github.com/vector-im/riot-web
Add Jitsi auth check
Checks for auth needed by looking up a well-known file from the preferred Jitsi domain. No file existing will assume no auth.pull/21833/head
parent
0d290c9bd2
commit
5d8a082eb1
|
@ -34,6 +34,30 @@ export class Jitsi {
|
||||||
return this.domain || 'jitsi.riot.im';
|
return this.domain || 'jitsi.riot.im';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for auth needed by looking up a well-known file
|
||||||
|
*
|
||||||
|
* If the file does not exist, we assume no auth.
|
||||||
|
*
|
||||||
|
* See TODO add link
|
||||||
|
*/
|
||||||
|
public async getJitsiAuth(): Promise<string|null> {
|
||||||
|
if (!this.preferredDomain) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
const response = await fetch(`https://${this.preferredDomain}/.well-known/element/jitsi`);
|
||||||
|
data = await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (data.auth) {
|
||||||
|
return data.auth;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public start() {
|
public start() {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
cli.on("WellKnown.client", this.update);
|
cli.on("WellKnown.client", this.update);
|
||||||
|
|
Loading…
Reference in New Issue