mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-11 12:37:22 +01:00
commit
b1737c5ad2
@ -481,25 +481,37 @@ export class Client {
|
|||||||
throw new Error(`Could not find session for id ${this._sessionId}`);
|
throw new Error(`Could not find session for id ${this._sessionId}`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const hsApi = new HomeServerApi({
|
if (sessionInfo.oidcIssuer) {
|
||||||
homeserver: sessionInfo.homeServer,
|
const oidcApi = new OidcApi({
|
||||||
accessToken: sessionInfo.accessToken,
|
issuer: sessionInfo.oidcIssuer,
|
||||||
request: this._platform.request
|
clientConfigs: this._platform.config.oidc.clientConfigs,
|
||||||
});
|
clientId: sessionInfo.oidcClientId,
|
||||||
await hsApi.logout({log}).response();
|
request: this._platform.request,
|
||||||
const oidcApi = new OidcApi({
|
encoding: this._platform.encoding,
|
||||||
issuer: sessionInfo.oidcIssuer,
|
crypto: this._platform.crypto,
|
||||||
clientConfigs: this._platform.config.oidc.clientConfigs,
|
});
|
||||||
clientId: sessionInfo.oidcClientId,
|
|
||||||
request: this._platform.request,
|
// if access token revocation fails then we still want to try and revoke the refresh token
|
||||||
encoding: this._platform.encoding,
|
try {
|
||||||
crypto: this._platform.crypto,
|
await oidcApi.revokeToken({ token: sessionInfo.accessToken, type: "access_token" });
|
||||||
});
|
} catch (err) {
|
||||||
await oidcApi.revokeToken({ token: sessionInfo.accessToken, type: "access" });
|
console.error(err);
|
||||||
if (sessionInfo.refreshToken) {
|
}
|
||||||
await oidcApi.revokeToken({ token: sessionInfo.refreshToken, type: "refresh" });
|
|
||||||
|
if (sessionInfo.refreshToken) {
|
||||||
|
await oidcApi.revokeToken({ token: sessionInfo.refreshToken, type: "refresh_token" });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const hsApi = new HomeServerApi({
|
||||||
|
homeserver: sessionInfo.homeServer,
|
||||||
|
accessToken: sessionInfo.accessToken,
|
||||||
|
request: this._platform.request
|
||||||
|
});
|
||||||
|
await hsApi.logout({log}).response();
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
await this.deleteSession(log);
|
await this.deleteSession(log);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -307,14 +307,14 @@ export class OidcApi<N extends object = SegmentType> {
|
|||||||
async revokeToken({
|
async revokeToken({
|
||||||
token,
|
token,
|
||||||
type,
|
type,
|
||||||
}: { token: string, type: "refresh" | "access" }): Promise<void> {
|
}: { token: string, type: "refresh_token" | "access_token" }): Promise<void> {
|
||||||
const revocationEndpoint = await this.revocationEndpoint();
|
const revocationEndpoint = await this.revocationEndpoint();
|
||||||
if (!revocationEndpoint) {
|
if (!revocationEndpoint) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
params.append("token_type", type);
|
params.append("token_type_hint", type);
|
||||||
params.append("token", token);
|
params.append("token", token);
|
||||||
params.append("client_id", await this.clientId());
|
params.append("client_id", await this.clientId());
|
||||||
const body = params.toString();
|
const body = params.toString();
|
||||||
@ -325,7 +325,6 @@ export class OidcApi<N extends object = SegmentType> {
|
|||||||
const req = this._requestFn(revocationEndpoint, {
|
const req = this._requestFn(revocationEndpoint, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers,
|
headers,
|
||||||
format: "json",
|
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user