@@ -184,6 +184,13 @@ export interface IAuthOptions {
184184 * Defaults to 120 seconds.
185185 */
186186 minSecondsBeforeRefresh ?: number
187+
188+ /**
189+ * If true, disables the token refresh when the tab regains focus.
190+ *
191+ * Default false
192+ */
193+ disableRefreshOnFocus ?: boolean
187194}
188195
189196interface AccessTokenActiveOrgMap {
@@ -603,6 +610,10 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
603610 clientState . observers = [ ]
604611 clientState . accessTokenObservers = [ ]
605612 window . removeEventListener ( "storage" , onStorageChange )
613+ window . removeEventListener ( "online" , onOnlineOrFocus )
614+ if ( ! authOptions . disableRefreshOnFocus ) {
615+ window . removeEventListener ( "focus" , onOnlineOrFocus )
616+ }
606617 if ( clientState . refreshInterval ) {
607618 clearInterval ( clientState . refreshInterval )
608619 }
@@ -649,7 +660,10 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
649660 if ( hasWindow ( ) ) {
650661 window . addEventListener ( "storage" , onStorageChange )
651662 window . addEventListener ( "online" , onOnlineOrFocus )
652- window . addEventListener ( "focus" , onOnlineOrFocus )
663+
664+ if ( ! authOptions . disableRefreshOnFocus ) {
665+ window . addEventListener ( "focus" , onOnlineOrFocus )
666+ }
653667
654668 if ( authOptions . enableBackgroundTokenRefresh ) {
655669 client . getAuthenticationInfoOrNull ( )
0 commit comments