From e9629c78882f01a55c1f5c4de55c1e68a2e9e0f6 Mon Sep 17 00:00:00 2001 From: savindi7 Date: Wed, 13 Mar 2024 11:36:53 +0530 Subject: [PATCH 1/2] Support additional params in trySignInSilently URL and bump auth-spa --- lib/package.json | 2 +- lib/src/api.ts | 5 +++-- lib/src/authenticate.tsx | 6 +++++- lib/src/models.ts | 2 +- yarn.lock | 8 ++++---- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/package.json b/lib/package.json index 872c1d18..cbc4b640 100755 --- a/lib/package.json +++ b/lib/package.json @@ -37,7 +37,7 @@ "author": "WSO2", "license": "Apache-2.0", "dependencies": { - "@asgardeo/auth-spa": "^0.4.14" + "@asgardeo/auth-spa": "^0.4.15" }, "devDependencies": { "@babel/cli": "^7.10.5", diff --git a/lib/src/api.ts b/lib/src/api.ts index c0cd7fde..61ba82ce 100644 --- a/lib/src/api.ts +++ b/lib/src/api.ts @@ -401,10 +401,11 @@ class AuthAPI { */ public async trySignInSilently( state: AuthStateInterface, - dispatch: (state: AuthStateInterface) => void + dispatch: (state: AuthStateInterface) => void, + additionalParams?: Record ): Promise { return this._client - .trySignInSilently() + .trySignInSilently(additionalParams) .then(async (response: BasicUserInfo | boolean) => { if (!response) { this.updateState({ ...this.getState(), isLoading: false }); diff --git a/lib/src/authenticate.tsx b/lib/src/authenticate.tsx index 0535cc6d..c4c673e5 100644 --- a/lib/src/authenticate.tsx +++ b/lib/src/authenticate.tsx @@ -130,7 +130,9 @@ const AuthProvider: FunctionComponent AuthClient.trySignInSilently(state, dispatch); + const trySignInSilently = ( + additionalParams?: Record + ) => AuthClient.trySignInSilently(state, dispatch, additionalParams); const [ error, setError ] = useState(); const reRenderCheckRef: MutableRefObject = useRef(false); @@ -224,6 +226,8 @@ const AuthProvider: FunctionComponent { + console.log("authenticate-react", "hi" ) + // TODO: Add logs when a logger is available. // Tracked here https://github.com/asgardeo/asgardeo-auth-js-sdk/issues/151. setError(null); diff --git a/lib/src/models.ts b/lib/src/models.ts index 36566592..fc2cc9e2 100644 --- a/lib/src/models.ts +++ b/lib/src/models.ts @@ -112,7 +112,7 @@ export interface AuthContextInterface { enableHttpHandler(): Promise; disableHttpHandler(): Promise; updateConfig(config: Partial>): Promise; - trySignInSilently: () => Promise; + trySignInSilently: (additionalParams?: Record) => Promise; on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): void; on( hook: Exclude, diff --git a/yarn.lock b/yarn.lock index 0c9c195f..0cc6854f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14,10 +14,10 @@ resolved "https://registry.yarnpkg.com/@asgardeo/auth-js/-/auth-js-2.0.15.tgz#1fae42052b5a4bc15bc55e193793ca33f164597e" integrity sha512-ciMLhrm/M//CvyMpCvaoA82S3tKvB529L+MwKKBbRZFe+d0HRPuDfruDhclWl7i07XO1+AVp9Dy1MdUDkhzR4Q== -"@asgardeo/auth-spa@^0.4.14": - version "0.4.14" - resolved "https://registry.yarnpkg.com/@asgardeo/auth-spa/-/auth-spa-0.4.14.tgz#4f67591b059c31b3db107d371be27fb274daa467" - integrity sha512-Eh1eBflbOftdeS42uy5yLYHW+G12dPQkdQRbQ52MMXYN212RXatqTzjtzS3f8xJs6i3qZGGI6LXdrav7ksJFXQ== +"@asgardeo/auth-spa@^0.4.15": + version "0.4.15" + resolved "https://registry.yarnpkg.com/@asgardeo/auth-spa/-/auth-spa-0.4.15.tgz#d0f1d0564b95adca90f529443a663251ff2a54cf" + integrity sha512-LPET7MTF5LMMoB9M73X1+HWQEbOleib3GG2GR8QnHCOQSe/omWpgnV1W9O7977vStrNwn7iMxrG9bN/PhfhNiA== dependencies: "@asgardeo/auth-js" "^2.0.15" await-semaphore "^0.1.3" From 8e45f91a1b3620c3494284f18d5bd50e01b78e81 Mon Sep 17 00:00:00 2001 From: savindi7 Date: Wed, 13 Mar 2024 11:42:54 +0530 Subject: [PATCH 2/2] minor fix --- lib/src/authenticate.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/src/authenticate.tsx b/lib/src/authenticate.tsx index c4c673e5..61327745 100644 --- a/lib/src/authenticate.tsx +++ b/lib/src/authenticate.tsx @@ -226,8 +226,6 @@ const AuthProvider: FunctionComponent { - console.log("authenticate-react", "hi" ) - // TODO: Add logs when a logger is available. // Tracked here https://github.com/asgardeo/asgardeo-auth-js-sdk/issues/151. setError(null);