From 3b770b3ac52963ebe7f9809212a93dfcf0f7ff74 Mon Sep 17 00:00:00 2001 From: Nipun Thennakoon Date: Sun, 5 Nov 2023 23:08:24 +0530 Subject: [PATCH 1/2] Properly URL encoding the sign-out URL. --- lib/src/core/authentication-core.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/src/core/authentication-core.ts b/lib/src/core/authentication-core.ts index 8b74cca9..ac98034d 100644 --- a/lib/src/core/authentication-core.ts +++ b/lib/src/core/authentication-core.ts @@ -556,8 +556,8 @@ export class AuthenticationCore { "No sign-in redirect URL has been found either. " ); } - - let parameter: string = `client_id=${ configData.clientID }`; + const queryParams = new URLSearchParams(); + queryParams.set("post_logout_redirect_uri", callbackURL); if (configData.sendIdTokenInLogoutRequest) { const idToken: string = (await this._dataLayer.getSessionData(userID))?.id_token; @@ -569,16 +569,13 @@ export class AuthenticationCore { "No ID token could be found. Either the session information is lost or you have not signed in." ); } - parameter = `id_token_hint=${ idToken }`; + queryParams.set("id_token_hint", idToken); + } else { + queryParams.set("client_id", configData.clientID); } - const logoutCallback: string = - `${ logoutEndpoint }?` + - parameter + - `&post_logout_redirect_uri=${ callbackURL }&state=` + - SIGN_OUT_SUCCESS_PARAM; - - return logoutCallback; + queryParams.set("state", SIGN_OUT_SUCCESS_PARAM); + return `${logoutEndpoint}?${queryParams.toString()}`; } public async clearUserSessionData(userID?: string): Promise { From 5f855f2eeb6db9a727eb86197230ad6a2b46dce7 Mon Sep 17 00:00:00 2001 From: Nipun Thennakoon Date: Sun, 5 Nov 2023 23:18:45 +0530 Subject: [PATCH 2/2] Fix lint issues. --- lib/src/core/authentication-core.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/core/authentication-core.ts b/lib/src/core/authentication-core.ts index ac98034d..c5ee23de 100644 --- a/lib/src/core/authentication-core.ts +++ b/lib/src/core/authentication-core.ts @@ -556,7 +556,8 @@ export class AuthenticationCore { "No sign-in redirect URL has been found either. " ); } - const queryParams = new URLSearchParams(); + const queryParams: URLSearchParams = new URLSearchParams(); + queryParams.set("post_logout_redirect_uri", callbackURL); if (configData.sendIdTokenInLogoutRequest) { @@ -575,6 +576,7 @@ export class AuthenticationCore { } queryParams.set("state", SIGN_OUT_SUCCESS_PARAM); + return `${logoutEndpoint}?${queryParams.toString()}`; }