@proveanything/smartlinks-auth-ui 0.1.18 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -11225,9 +11225,8 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11225
11225
  const [accountInfo, setAccountInfo] = useState(null);
11226
11226
  const [isLoading, setIsLoading] = useState(true);
11227
11227
  const callbacksRef = useRef(new Set());
11228
- // Initialization guards to prevent race conditions on hot reload
11228
+ // Initialization guard to prevent concurrent runs (NOT persisted across remounts)
11229
11229
  const initializingRef = useRef(false);
11230
- const initializedRef = useRef(false);
11231
11230
  // Notify all subscribers of auth state changes
11232
11231
  const notifyAuthStateChange = useCallback((type, currentUser, currentToken, currentAccountData, currentAccountInfo) => {
11233
11232
  callbacksRef.current.forEach(callback => {
@@ -11247,9 +11246,9 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11247
11246
  }, []);
11248
11247
  // Initialize auth state - different behavior for proxy mode vs standalone mode
11249
11248
  useEffect(() => {
11250
- // Prevent concurrent initialization (race condition fix)
11251
- if (initializingRef.current || initializedRef.current) {
11252
- console.log('[AuthContext] Skipping initialization - already in progress or completed');
11249
+ // Prevent concurrent initialization only
11250
+ if (initializingRef.current) {
11251
+ console.log('[AuthContext] Skipping initialization - already in progress');
11253
11252
  return;
11254
11253
  }
11255
11254
  let isMounted = true;
@@ -11288,7 +11287,6 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11288
11287
  }
11289
11288
  if (isMounted) {
11290
11289
  setIsLoading(false);
11291
- initializedRef.current = true;
11292
11290
  initializingRef.current = false;
11293
11291
  }
11294
11292
  return;
@@ -11308,6 +11306,8 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11308
11306
  setUser(storedUser);
11309
11307
  setAccountData(storedAccountData);
11310
11308
  console.log('[AuthContext] Session restored successfully');
11309
+ // Notify subscribers that session was restored (critical for app to know we're logged in)
11310
+ notifyAuthStateChange('LOGIN', storedUser, storedToken.token, storedAccountData || null);
11311
11311
  }
11312
11312
  }
11313
11313
  catch (err) {
@@ -11330,7 +11330,6 @@ const AuthProvider = ({ children, proxyMode = false, accountCacheTTL = 5 * 60 *
11330
11330
  finally {
11331
11331
  if (isMounted) {
11332
11332
  setIsLoading(false);
11333
- initializedRef.current = true;
11334
11333
  initializingRef.current = false;
11335
11334
  }
11336
11335
  }