@iblai/web-utils 1.2.6 → 1.2.7
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 +24 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2856,6 +2856,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2856
2856
|
* Skipped if enableStorageSync is false
|
|
2857
2857
|
*/
|
|
2858
2858
|
React.useEffect(() => {
|
|
2859
|
+
console.log("[AuthProvider] cookie-sync effect running", {
|
|
2860
|
+
pathname,
|
|
2861
|
+
enableStorageSync,
|
|
2862
|
+
hasStorageService: !!storageService,
|
|
2863
|
+
});
|
|
2859
2864
|
if (!storageService || !isWeb$1() || !enableStorageSync) {
|
|
2860
2865
|
// If no storage service, not web, or sync disabled, mark sync as complete immediately
|
|
2861
2866
|
setInitialSyncComplete(true);
|
|
@@ -2865,16 +2870,22 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2865
2870
|
isRedirectingRef.current = false;
|
|
2866
2871
|
// Initial sync on mount
|
|
2867
2872
|
async function initialSync() {
|
|
2873
|
+
console.log("[AuthProvider] initialSync starting");
|
|
2868
2874
|
try {
|
|
2869
2875
|
// Initialize last known logout timestamp
|
|
2870
2876
|
lastLogoutTimestampRef.current = CookieUtils.get(COOKIE_KEYS.LOGOUT_TIMESTAMP);
|
|
2871
2877
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2878
|
+
console.log("[AuthProvider] initialSync result", {
|
|
2879
|
+
needsRefresh,
|
|
2880
|
+
userDataOutOfSync,
|
|
2881
|
+
});
|
|
2872
2882
|
if (needsRefresh) {
|
|
2873
2883
|
console.log("[auth-redirect] Cookie sync detected changes, refreshing page");
|
|
2874
2884
|
// If user data is out of sync, trigger logout to force re-authentication
|
|
2875
2885
|
safeRedirectToAuthSpa(undefined, undefined, userDataOutOfSync, false);
|
|
2876
2886
|
}
|
|
2877
2887
|
else {
|
|
2888
|
+
console.log("[AuthProvider] initialSync no changes, syncing auth to cookies");
|
|
2878
2889
|
await syncAuthToCookies(storageService);
|
|
2879
2890
|
}
|
|
2880
2891
|
}
|
|
@@ -2887,8 +2898,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2887
2898
|
// Poll for cookie changes every 2 seconds to detect cross-SPA updates
|
|
2888
2899
|
cookieCheckIntervalRef.current = setInterval(async () => {
|
|
2889
2900
|
// If a redirect is already in progress, skip entirely
|
|
2890
|
-
if (isRedirectingRef.current)
|
|
2901
|
+
if (isRedirectingRef.current) {
|
|
2902
|
+
console.log("[AuthProvider] interval: redirect already in progress, skipping");
|
|
2891
2903
|
return;
|
|
2904
|
+
}
|
|
2892
2905
|
// Skip cookie sync checks if user is completing SSO at /sso-login
|
|
2893
2906
|
const completingSso = /^\/sso-login/.test(pathname);
|
|
2894
2907
|
if (completingSso) {
|
|
@@ -2909,6 +2922,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2909
2922
|
return;
|
|
2910
2923
|
}
|
|
2911
2924
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2925
|
+
console.log("[AuthProvider] interval poll result", {
|
|
2926
|
+
needsRefresh,
|
|
2927
|
+
userDataOutOfSync,
|
|
2928
|
+
pathname,
|
|
2929
|
+
});
|
|
2912
2930
|
if (needsRefresh) {
|
|
2913
2931
|
console.log("[auth-redirect] Cookie sync detected changes from another SPA, refreshing page");
|
|
2914
2932
|
let cookieTenantKey;
|
|
@@ -2917,6 +2935,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2917
2935
|
cookieTenantKey = cookieCurrentTenant.key;
|
|
2918
2936
|
}
|
|
2919
2937
|
catch (_a) { }
|
|
2938
|
+
console.log("[AuthProvider] interval redirecting to auth spa", {
|
|
2939
|
+
cookieTenantKey,
|
|
2940
|
+
userDataOutOfSync,
|
|
2941
|
+
});
|
|
2920
2942
|
// If user data is out of sync, trigger logout to force re-authentication
|
|
2921
2943
|
safeRedirectToAuthSpa(undefined, cookieTenantKey, userDataOutOfSync, false);
|
|
2922
2944
|
}
|
|
@@ -2926,6 +2948,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2926
2948
|
}, 2000);
|
|
2927
2949
|
// Cleanup interval on unmount
|
|
2928
2950
|
return () => {
|
|
2951
|
+
console.log("[AuthProvider] cookie-sync effect cleanup", { pathname });
|
|
2929
2952
|
if (cookieCheckIntervalRef.current) {
|
|
2930
2953
|
clearInterval(cookieCheckIntervalRef.current);
|
|
2931
2954
|
}
|