diff --git a/lib/src/client.ts b/lib/src/client.ts index 8a60a584..a074c45c 100755 --- a/lib/src/client.ts +++ b/lib/src/client.ts @@ -54,6 +54,7 @@ const DefaultConfig: Partial> = { checkSessionInterval: 3, clientHost: origin, enableOIDCSessionManagement: false, + periodicTokenRefresh: false, sessionRefreshInterval: 300, storage: Storage.SessionStorage }; diff --git a/lib/src/helpers/spa-helper.ts b/lib/src/helpers/spa-helper.ts index 6199e334..72b5de54 100644 --- a/lib/src/helpers/spa-helper.ts +++ b/lib/src/helpers/spa-helper.ts @@ -33,6 +33,13 @@ export class SPAHelper MainThreadClientConfig | WebWorkerClientConfig > ): Promise { + 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 diff --git a/lib/src/models/client-config.ts b/lib/src/models/client-config.ts index 1278307e..2047e373 100644 --- a/lib/src/models/client-config.ts +++ b/lib/src/models/client-config.ts @@ -31,6 +31,7 @@ export interface SPAConfig { sessionRefreshInterval?: number; resourceServerURLs?: string[]; authParams?: Record + periodicTokenRefresh?: boolean; } /**