@@ -223,38 +223,57 @@ export class UmbAuthFlow {
223
223
return ! ! this . #accessTokenResponse && this . #accessTokenResponse. isValid ( ) ;
224
224
}
225
225
226
+ /**
227
+ * Forget all cached token state
228
+ */
229
+ async clearTokenStorage ( ) {
230
+ await this . #storageBackend. removeItem ( TOKEN_RESPONSE_NAME ) ;
231
+
232
+ // clear the internal state
233
+ this . #accessTokenResponse = undefined ;
234
+ this . #refreshToken = undefined ;
235
+ }
236
+
226
237
/**
227
238
* This method will sign the user out of the application.
228
239
*/
229
240
async signOut ( ) {
230
- // forget all cached token state
231
- await this . #storageBackend. removeItem ( TOKEN_RESPONSE_NAME ) ;
241
+ const signOutPromises : Promise < unknown > [ ] = [ ] ;
232
242
243
+ // revoke the access token if it exists
233
244
if ( this . #accessTokenResponse) {
234
- // TODO: Enable this when the server supports it
235
- // const tokenRevokeRequest = new RevokeTokenRequest({
236
- // token: this.#accessTokenResponse.accessToken,
237
- // client_id: this.#clientId,
238
- // token_type_hint: 'access_token',
239
- // });
240
-
241
- // await this.#tokenHandler.performRevokeTokenRequest(this.#configuration, tokenRevokeRequest);
245
+ const tokenRevokeRequest = new RevokeTokenRequest ( {
246
+ token : this . #accessTokenResponse. accessToken ,
247
+ client_id : this . #clientId,
248
+ token_type_hint : 'access_token' ,
249
+ } ) ;
242
250
243
- this . #accessTokenResponse = undefined ;
251
+ signOutPromises . push ( this . #tokenHandler . performRevokeTokenRequest ( this . #configuration , tokenRevokeRequest ) ) ;
244
252
}
245
253
254
+ // revoke the refresh token if it exists
246
255
if ( this . #refreshToken) {
247
- // TODO: Enable this when the server supports it
248
- // const tokenRevokeRequest = new RevokeTokenRequest({
249
- // token: this.#refreshToken,
250
- // client_id: this.#clientId,
251
- // token_type_hint: 'refresh_token',
252
- // });
253
-
254
- // await this.#tokenHandler.performRevokeTokenRequest(this.#configuration, tokenRevokeRequest);
256
+ const tokenRevokeRequest = new RevokeTokenRequest ( {
257
+ token : this . #refreshToken,
258
+ client_id : this . #clientId,
259
+ token_type_hint : 'refresh_token' ,
260
+ } ) ;
255
261
256
- this . #refreshToken = undefined ;
262
+ signOutPromises . push ( this . #tokenHandler . performRevokeTokenRequest ( this . #configuration , tokenRevokeRequest ) ) ;
257
263
}
264
+
265
+ // clear the internal token state
266
+ signOutPromises . push ( this . clearTokenStorage ( ) ) ;
267
+
268
+ // wait for all promises to settle before continuing
269
+ await Promise . allSettled ( signOutPromises ) ;
270
+
271
+ // clear the session on the server as well
272
+ // this will redirect the user to the end session endpoint of the server
273
+ // which will redirect the user back to the client
274
+ // and the client will then try and log in again (if the user is not logged in)
275
+ // which will redirect the user to the login page
276
+ location . href = `${ this . #configuration. endSessionEndpoint } ?post_logout_redirect_uri=${ this . #redirectUri} ` ;
258
277
}
259
278
260
279
/**
0 commit comments