@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.esm.js
CHANGED
|
@@ -2836,6 +2836,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2836
2836
|
* Skipped if enableStorageSync is false
|
|
2837
2837
|
*/
|
|
2838
2838
|
useEffect(() => {
|
|
2839
|
+
console.log("[AuthProvider] cookie-sync effect running", {
|
|
2840
|
+
pathname,
|
|
2841
|
+
enableStorageSync,
|
|
2842
|
+
hasStorageService: !!storageService,
|
|
2843
|
+
});
|
|
2839
2844
|
if (!storageService || !isWeb$1() || !enableStorageSync) {
|
|
2840
2845
|
// If no storage service, not web, or sync disabled, mark sync as complete immediately
|
|
2841
2846
|
setInitialSyncComplete(true);
|
|
@@ -2845,16 +2850,22 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2845
2850
|
isRedirectingRef.current = false;
|
|
2846
2851
|
// Initial sync on mount
|
|
2847
2852
|
async function initialSync() {
|
|
2853
|
+
console.log("[AuthProvider] initialSync starting");
|
|
2848
2854
|
try {
|
|
2849
2855
|
// Initialize last known logout timestamp
|
|
2850
2856
|
lastLogoutTimestampRef.current = CookieUtils.get(COOKIE_KEYS.LOGOUT_TIMESTAMP);
|
|
2851
2857
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2858
|
+
console.log("[AuthProvider] initialSync result", {
|
|
2859
|
+
needsRefresh,
|
|
2860
|
+
userDataOutOfSync,
|
|
2861
|
+
});
|
|
2852
2862
|
if (needsRefresh) {
|
|
2853
2863
|
console.log("[auth-redirect] Cookie sync detected changes, refreshing page");
|
|
2854
2864
|
// If user data is out of sync, trigger logout to force re-authentication
|
|
2855
2865
|
safeRedirectToAuthSpa(undefined, undefined, userDataOutOfSync, false);
|
|
2856
2866
|
}
|
|
2857
2867
|
else {
|
|
2868
|
+
console.log("[AuthProvider] initialSync no changes, syncing auth to cookies");
|
|
2858
2869
|
await syncAuthToCookies(storageService);
|
|
2859
2870
|
}
|
|
2860
2871
|
}
|
|
@@ -2867,8 +2878,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2867
2878
|
// Poll for cookie changes every 2 seconds to detect cross-SPA updates
|
|
2868
2879
|
cookieCheckIntervalRef.current = setInterval(async () => {
|
|
2869
2880
|
// If a redirect is already in progress, skip entirely
|
|
2870
|
-
if (isRedirectingRef.current)
|
|
2881
|
+
if (isRedirectingRef.current) {
|
|
2882
|
+
console.log("[AuthProvider] interval: redirect already in progress, skipping");
|
|
2871
2883
|
return;
|
|
2884
|
+
}
|
|
2872
2885
|
// Skip cookie sync checks if user is completing SSO at /sso-login
|
|
2873
2886
|
const completingSso = /^\/sso-login/.test(pathname);
|
|
2874
2887
|
if (completingSso) {
|
|
@@ -2889,6 +2902,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2889
2902
|
return;
|
|
2890
2903
|
}
|
|
2891
2904
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2905
|
+
console.log("[AuthProvider] interval poll result", {
|
|
2906
|
+
needsRefresh,
|
|
2907
|
+
userDataOutOfSync,
|
|
2908
|
+
pathname,
|
|
2909
|
+
});
|
|
2892
2910
|
if (needsRefresh) {
|
|
2893
2911
|
console.log("[auth-redirect] Cookie sync detected changes from another SPA, refreshing page");
|
|
2894
2912
|
let cookieTenantKey;
|
|
@@ -2897,6 +2915,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2897
2915
|
cookieTenantKey = cookieCurrentTenant.key;
|
|
2898
2916
|
}
|
|
2899
2917
|
catch (_a) { }
|
|
2918
|
+
console.log("[AuthProvider] interval redirecting to auth spa", {
|
|
2919
|
+
cookieTenantKey,
|
|
2920
|
+
userDataOutOfSync,
|
|
2921
|
+
});
|
|
2900
2922
|
// If user data is out of sync, trigger logout to force re-authentication
|
|
2901
2923
|
safeRedirectToAuthSpa(undefined, cookieTenantKey, userDataOutOfSync, false);
|
|
2902
2924
|
}
|
|
@@ -2906,6 +2928,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2906
2928
|
}, 2000);
|
|
2907
2929
|
// Cleanup interval on unmount
|
|
2908
2930
|
return () => {
|
|
2931
|
+
console.log("[AuthProvider] cookie-sync effect cleanup", { pathname });
|
|
2909
2932
|
if (cookieCheckIntervalRef.current) {
|
|
2910
2933
|
clearInterval(cookieCheckIntervalRef.current);
|
|
2911
2934
|
}
|