Skip to content

Commit 3db1cd6

Browse files
committed
feat: enhance AsgardeoBrowserConfig and AsgardeoContextProps with storage options
1 parent fb8c164 commit 3db1cd6

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/browser/src/models/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
import {Config} from '@asgardeo/javascript';
2020

21-
export type AsgardeoBrowserConfig = Config;
21+
export type AsgardeoBrowserConfig = Config<'sessionStorage' | 'localStorage' | 'browserMemory' | 'webWorker'>;

packages/javascript/src/models/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
197197
* @see {@link https://openid.net/specs/openid-connect-session-management-1_0.html#IframeBasedSessionManagement}
198198
*/
199199
syncSession?: boolean;
200+
201+
/**
202+
* Storage mechanism to use for storing tokens and session data.
203+
* The values should be defined at the framework layer.
204+
*/
205+
storage?: T;
200206
}
201207

202208
export interface WithPreferences {

packages/react/src/contexts/Asgardeo/AsgardeoContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
TokenResponse,
2828
} from '@asgardeo/browser';
2929
import AsgardeoReactClient from '../../AsgardeoReactClient';
30+
import {AsgardeoReactConfig} from '../../models/config';
3031

3132
/**
3233
* Props interface of {@link AsgardeoContext}
@@ -120,7 +121,7 @@ export type AsgardeoContextProps = {
120121
* @returns A promise that resolves to the token response or the raw response.
121122
*/
122123
exchangeToken?: (config: TokenExchangeRequestConfig) => Promise<TokenResponse | Response>;
123-
};
124+
} & Pick<AsgardeoReactConfig, 'storage'>;
124125

125126
/**
126127
* Context object for managing the Authentication flow builder core context.
@@ -149,6 +150,7 @@ const AsgardeoContext: Context<AsgardeoContextProps | null> = createContext<null
149150
getDecodedIdToken: null,
150151
getAccessToken: null,
151152
exchangeToken: null,
153+
storage: 'sessionStorage',
152154
});
153155

154156
AsgardeoContext.displayName = 'AsgardeoContext';

0 commit comments

Comments
 (0)