From a8e085d9abe738982fe8f71ec82de7924517d448 Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Tue, 30 Nov 2021 13:24:40 +0100 Subject: [PATCH 1/2] Make RedirectLoginOptions and RedirectLoginResult accept generic AppState --- src/global.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/global.ts b/src/global.ts index a85692537..af57fc996 100644 --- a/src/global.ts +++ b/src/global.ts @@ -240,7 +240,8 @@ export interface AuthorizeOptions extends BaseLoginOptions { code_challenge_method: string; } -export interface RedirectLoginOptions extends BaseLoginOptions { +export interface RedirectLoginOptions + extends BaseLoginOptions { /** * The URL where Auth0 will redirect your browser to with * the authentication result. It must be whitelisted in @@ -251,7 +252,7 @@ export interface RedirectLoginOptions extends BaseLoginOptions { /** * Used to store state before doing the redirect */ - appState?: any; + appState?: TAppState; /** * Used to add to the URL fragment before redirecting */ @@ -262,11 +263,11 @@ export interface RedirectLoginOptions extends BaseLoginOptions { redirectMethod?: 'replace' | 'assign'; } -export interface RedirectLoginResult { +export interface RedirectLoginResult { /** * State stored when the redirect request was made */ - appState?: any; + appState?: TAppState; } export interface PopupLoginOptions extends BaseLoginOptions {} From 4e3d0745e09202d399a08e54ce06a0d7b1688333 Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Tue, 30 Nov 2021 13:46:03 +0100 Subject: [PATCH 2/2] Add TAppState to loginWithRedirect and handleRedirectCallback --- src/Auth0Client.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Auth0Client.ts b/src/Auth0Client.ts index ddb40a381..ac5eb7758 100644 --- a/src/Auth0Client.ts +++ b/src/Auth0Client.ts @@ -615,7 +615,9 @@ export default class Auth0Client { * * @param options */ - public async loginWithRedirect(options: RedirectLoginOptions = {}) { + public async loginWithRedirect( + options: RedirectLoginOptions = {} + ) { const { redirectMethod, ...urlOptions } = options; const url = await this.buildAuthorizeUrl(urlOptions); window.location[redirectMethod || 'assign'](url); @@ -627,9 +629,9 @@ export default class Auth0Client { * responses from Auth0. If the response is successful, results * will be valid according to their expiration times. */ - public async handleRedirectCallback( + public async handleRedirectCallback( url: string = window.location.href - ): Promise { + ): Promise> { const queryStringFragments = url.split('?').slice(1); if (queryStringFragments.length === 0) {