@@ -4848,7 +4848,7 @@ let oe = class extends qt {
48484848 constructor ( ) {
48494849 super ( ) , this . hankoUrlAttr = "" , this . basePath = "" , this . authPath = "/api/auth/osm" , this . osmRequired = ! 1 , this . osmScopes = "read_prefs" , this . showProfile = ! 1 , this . redirectAfterLogin = "" , this . autoConnect = ! 1 , this . verifySession = ! 1 , this . redirectAfterLogout = "" , this . displayNameAttr = "" , this . mappingCheckUrl = "" , this . appId = "" , this . loginUrl = "" , this . lang = "en" , this . buttonVariant = "plain" , this . buttonColor = "primary" , this . display = "default" , this . user = null , this . osmConnected = ! 1 , this . osmData = null , this . osmLoading = ! 1 , this . loading = ! 0 , this . error = null , this . hankoReady = ! 1 , this . profileDisplayName = "" , this . profilePictureUrl = "" , this . hasAppMapping = ! 1 , this . userProfileLanguage = null , this . isOpen = ! 1 , this . handleOutsideClick = ( n ) => {
48504850 this . contains ( n . target ) || this . closeDropdown ( ) ;
4851- } , this . _debugMode = ! 1 , this . _lastSessionId = null , this . _hanko = null , this . _isPrimary = ! 1 , this . _hankoObserver = null , this . _signUpHeadlines = /* @__PURE__ */ new Set ( [
4851+ } , this . _debugMode = ! 1 , this . _lastSessionId = null , this . _hanko = null , this . _isPrimary = ! 1 , this . _sessionCheckFailures = 0 , this . _sessionCheckBackoffTimer = null , this . _hankoObserver = null , this . _signUpHeadlines = /* @__PURE__ */ new Set ( [
48524852 "Create an account" ,
48534853 // en (our override)
48544854 "Crear cuenta" ,
@@ -4875,9 +4875,9 @@ let oe = class extends qt {
48754875 "Entrar"
48764876 // pt loginEmailNoSignup
48774877 ] ) , this . _handleVisibilityChange = ( ) => {
4878- this . _isPrimary && ! document . hidden && ! this . showProfile && ! this . user && ( this . log ( "Page visible, re-checking session..." ) , this . checkSession ( ) ) ;
4878+ this . _isPrimary && ( this . _sessionCheckBackoffTimer || ! document . hidden && ! this . showProfile && ! this . user && ( this . log ( "Page visible, re-checking session..." ) , this . checkSession ( ) ) ) ;
48794879 } , this . _handleWindowFocus = ( ) => {
4880- this . _isPrimary && ! this . showProfile && ! this . user && ( this . log ( "Window focused, re-checking session..." ) , this . checkSession ( ) ) ;
4880+ this . _isPrimary && ( this . _sessionCheckBackoffTimer || ! this . showProfile && ! this . user && ( this . log ( "Window focused, re-checking session..." ) , this . checkSession ( ) ) ) ;
48814881 } , this . _handleExternalLogin = ( n ) => {
48824882 var e ;
48834883 if ( ! this . _isPrimary ) return ;
@@ -5040,6 +5040,13 @@ let oe = class extends qt {
50405040 this . logError ( "Failed to initialize hanko-auth:" , n ) , this . error = n . message , this . loading = ! 1 , this . _broadcastState ( ) ;
50415041 }
50425042 }
5043+ _scheduleSessionRetry ( ) {
5044+ if ( this . _sessionCheckBackoffTimer ) return ;
5045+ const n = Math . min ( 1e3 * 2 ** this . _sessionCheckFailures , 6e4 ) ;
5046+ this . log ( `Session check failed, retrying in ${ n / 1e3 } s (attempt ${ this . _sessionCheckFailures } )` ) , this . _sessionCheckBackoffTimer = setTimeout ( ( ) => {
5047+ this . _sessionCheckBackoffTimer = null , this . checkSession ( ) ;
5048+ } , n ) ;
5049+ }
50435050 async checkSession ( ) {
50445051 var n , t , e , o , i ;
50455052 if ( this . log ( "Checking for existing Hanko session..." ) , ! this . _hanko ) {
@@ -5070,7 +5077,7 @@ let oe = class extends qt {
50705077 ) ) ;
50715078 return ;
50725079 }
5073- this . log ( "Valid Hanko session found via cookie" ) , this . log ( "Session data:" , s ) ;
5080+ this . _sessionCheckFailures = 0 , this . log ( "Valid Hanko session found via cookie" ) , this . log ( "Session data:" , s ) ;
50745081 try {
50755082 const d = await fetch ( `${ this . hankoUrl } /me` , {
50765083 method : "GET" ,
@@ -5134,10 +5141,12 @@ let oe = class extends qt {
51345141 } else
51355142 this . log ( "No valid session cookie found - user needs to login" ) ;
51365143 } catch ( r ) {
5137- this . log ( "Session validation failed:" , r ) , this . log ( "No valid session - user needs to login" ) ;
5144+ this . _sessionCheckFailures ++ , this . log ( "Session validation failed:" , r ) , this . _scheduleSessionRetry ( ) ;
5145+ return ;
51385146 }
51395147 } catch ( r ) {
5140- this . log ( "Session check error:" , r ) , this . log ( "No existing session - user needs to login" ) ;
5148+ this . _sessionCheckFailures ++ , this . log ( "Session check error:" , r ) , this . _scheduleSessionRetry ( ) ;
5149+ return ;
51415150 } finally {
51425151 this . _isPrimary && this . _broadcastState ( ) ;
51435152 }
0 commit comments