Skip to content

Commit

Permalink
Add config to disable token refresh logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DonOmalVindula committed Apr 9, 2024
1 parent 06563c3 commit 0223d6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const DefaultConfig: Partial<AuthClientConfig<Config>> = {
checkSessionInterval: 3,
clientHost: origin,
enableOIDCSessionManagement: false,
periodicTokenRefresh: false,
sessionRefreshInterval: 300,
storage: Storage.SessionStorage
};
Expand Down
7 changes: 7 additions & 0 deletions lib/src/helpers/spa-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export class SPAHelper<T extends MainThreadClientConfig | WebWorkerClientConfig>
MainThreadClientConfig | WebWorkerClientConfig
>
): Promise<void> {
const shouldRefreshAutomatically: boolean = (await this._dataLayer.getConfigData())?.periodicTokenRefresh ??
false;

if (!shouldRefreshAutomatically) {
return;
}

const sessionData = await this._dataLayer.getSessionData();
if (sessionData.refresh_token) {
// Refresh 10 seconds before the expiry time
Expand Down
1 change: 1 addition & 0 deletions lib/src/models/client-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface SPAConfig {
sessionRefreshInterval?: number;
resourceServerURLs?: string[];
authParams?: Record<string, string>
periodicTokenRefresh?: boolean;
}

/**
Expand Down

0 comments on commit 0223d6a

Please sign in to comment.