@iblai/web-utils 1.5.0 → 1.6.1
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.d.ts +3 -3
- package/dist/index.esm.js +16 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -9
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/providers/auth-provider.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1557,7 +1557,7 @@ type Props$2 = {
|
|
|
1557
1557
|
* 4. Handles redirects to auth SPA when needed
|
|
1558
1558
|
* 5. Manages public route access state
|
|
1559
1559
|
*/
|
|
1560
|
-
declare function AuthProvider({ children, fallback, middleware, onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname,
|
|
1560
|
+
declare function AuthProvider({ children, fallback, middleware, onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, storageService, token, enableStorageSync, skip, }: Props$2): string | number | bigint | boolean | Iterable<React__default.ReactNode> | Promise<string | number | bigint | boolean | React__default.ReactPortal | React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>> | Iterable<React__default.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
1561
1561
|
|
|
1562
1562
|
/**
|
|
1563
1563
|
* Props for the MentorProvider component
|
|
@@ -1590,7 +1590,7 @@ type Props$1 = {
|
|
|
1590
1590
|
* 3. Manages redirection based on mentor availability
|
|
1591
1591
|
* 4. Integrates with tenant context for access control
|
|
1592
1592
|
*/
|
|
1593
|
-
declare function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, onLoadMentorsPermissions, redirectToNoMentorsPage, redirectToCreateMentor, username, isAdmin, mainTenantKey, requestedMentorId, handleMentorNotFound, forceDetermineMentor, onComplete, skip, }: Props$1): string | number | bigint | boolean |
|
|
1593
|
+
declare function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, onLoadMentorsPermissions, redirectToNoMentorsPage, redirectToCreateMentor, username, isAdmin, mainTenantKey, requestedMentorId, handleMentorNotFound, forceDetermineMentor, onComplete, skip, }: Props$1): string | number | bigint | boolean | Iterable<React__default.ReactNode> | Promise<string | number | bigint | boolean | React__default.ReactPortal | React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>> | Iterable<React__default.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
1594
1594
|
|
|
1595
1595
|
/**
|
|
1596
1596
|
* Type definition for the tenant context
|
|
@@ -1654,7 +1654,7 @@ type Props = {
|
|
|
1654
1654
|
* 4. Handles tenant-specific domain redirects
|
|
1655
1655
|
* 5. Maintains tenant access state
|
|
1656
1656
|
*/
|
|
1657
|
-
declare function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed, setUseMentorProvider, skip, onLoadPlatformPermissions, skipCustomDomainCheck, onTenantMismatch, }: Props): string | number | bigint | boolean |
|
|
1657
|
+
declare function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed, setUseMentorProvider, skip, onLoadPlatformPermissions, skipCustomDomainCheck, onTenantMismatch, }: Props): string | number | bigint | boolean | Iterable<React__default.ReactNode> | Promise<string | number | bigint | boolean | React__default.ReactPortal | React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>> | Iterable<React__default.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
1658
1658
|
|
|
1659
1659
|
/**
|
|
1660
1660
|
* Chat area size constants
|
package/dist/index.esm.js
CHANGED
|
@@ -2507,6 +2507,7 @@ const COOKIE_KEYS = {
|
|
|
2507
2507
|
USER_DATA: "ibl_user_data",
|
|
2508
2508
|
TENANT: "ibl_tenant",
|
|
2509
2509
|
LOGOUT_TIMESTAMP: "ibl_logout_timestamp",
|
|
2510
|
+
LOGIN_TIMESTAMP: "ibl_login_timestamp",
|
|
2510
2511
|
};
|
|
2511
2512
|
/**
|
|
2512
2513
|
* Get the base domain for cookie sharing
|
|
@@ -2818,6 +2819,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2818
2819
|
const [initialSyncComplete, setInitialSyncComplete] = useState(false);
|
|
2819
2820
|
const cookieCheckIntervalRef = useRef(null);
|
|
2820
2821
|
const lastLogoutTimestampRef = useRef(null);
|
|
2822
|
+
const lastLoginTimestampRef = useRef(null);
|
|
2821
2823
|
// Guard to prevent poll from firing after a redirect has been initiated.
|
|
2822
2824
|
// Once set, no further redirects or cookie syncs will happen.
|
|
2823
2825
|
const isRedirectingRef = useRef(false);
|
|
@@ -2832,11 +2834,6 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2832
2834
|
console.log("[AuthProvider] Redirect already in progress, skipping");
|
|
2833
2835
|
return;
|
|
2834
2836
|
}
|
|
2835
|
-
// Skip if a tenant switch is already in progress
|
|
2836
|
-
if (isWeb$1() && document.cookie.includes("ibl_tenant_switching")) {
|
|
2837
|
-
console.log("[AuthProvider] Tenant switch in progress, skipping redirect");
|
|
2838
|
-
return;
|
|
2839
|
-
}
|
|
2840
2837
|
isRedirectingRef.current = true;
|
|
2841
2838
|
// NOTE: we intentionally do NOT clear the interval here.
|
|
2842
2839
|
// The isRedirectingRef guard prevents redundant redirects while navigation
|
|
@@ -2862,6 +2859,10 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2862
2859
|
* Skipped if enableStorageSync is false
|
|
2863
2860
|
*/
|
|
2864
2861
|
useEffect(() => {
|
|
2862
|
+
if (skipAuthCheck) {
|
|
2863
|
+
setInitialSyncComplete(true);
|
|
2864
|
+
return;
|
|
2865
|
+
}
|
|
2865
2866
|
console.log("[AuthProvider] cookie-sync effect running", {
|
|
2866
2867
|
pathname,
|
|
2867
2868
|
enableStorageSync,
|
|
@@ -2878,8 +2879,9 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2878
2879
|
async function initialSync() {
|
|
2879
2880
|
console.log("[AuthProvider] initialSync starting");
|
|
2880
2881
|
try {
|
|
2881
|
-
// Initialize last known logout
|
|
2882
|
+
// Initialize last known logout and login timestamps
|
|
2882
2883
|
lastLogoutTimestampRef.current = CookieUtils.get(COOKIE_KEYS.LOGOUT_TIMESTAMP);
|
|
2884
|
+
lastLoginTimestampRef.current = CookieUtils.get(COOKIE_KEYS.LOGIN_TIMESTAMP);
|
|
2883
2885
|
const { needsRefresh, userDataOutOfSync } = await syncCookiesToLocalStorage(storageService);
|
|
2884
2886
|
console.log("[AuthProvider] initialSync result", {
|
|
2885
2887
|
needsRefresh,
|
|
@@ -2969,7 +2971,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2969
2971
|
* Skipped if enableStorageSync is false
|
|
2970
2972
|
*/
|
|
2971
2973
|
useEffect(() => {
|
|
2972
|
-
if (!storageService || !isWeb$1() || !enableStorageSync)
|
|
2974
|
+
if (!storageService || !isWeb$1() || !enableStorageSync || skipAuthCheck)
|
|
2973
2975
|
return;
|
|
2974
2976
|
const handleStorageChange = async (event) => {
|
|
2975
2977
|
// Only handle changes to our auth-related keys
|
|
@@ -3069,6 +3071,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
3069
3071
|
}
|
|
3070
3072
|
}
|
|
3071
3073
|
useEffect(() => {
|
|
3074
|
+
if (skipAuthCheck) {
|
|
3075
|
+
setIsAuthenticating(false);
|
|
3076
|
+
setUserIsAccessingPublicRoute(true);
|
|
3077
|
+
return;
|
|
3078
|
+
}
|
|
3072
3079
|
// Wait for initial sync to complete before performing auth check
|
|
3073
3080
|
if (!initialSyncComplete) {
|
|
3074
3081
|
console.log("[useAuthProvider] Waiting for initial sync to complete...");
|
|
@@ -3146,7 +3153,7 @@ async function determineAuthRequired(middleware, pathname) {
|
|
|
3146
3153
|
* 4. Handles redirects to auth SPA when needed
|
|
3147
3154
|
* 5. Manages public route access state
|
|
3148
3155
|
*/
|
|
3149
|
-
function AuthProvider({ children, fallback, middleware = new Map(), onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname,
|
|
3156
|
+
function AuthProvider({ children, fallback, middleware = new Map(), onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, storageService, token, enableStorageSync = true, skip = false, }) {
|
|
3150
3157
|
const { isAuthenticating, userIsAccessingPublicRoute, setUserIsAccessingPublicRoute, } = useAuthProvider({
|
|
3151
3158
|
middleware,
|
|
3152
3159
|
onAuthSuccess,
|
|
@@ -3156,7 +3163,7 @@ function AuthProvider({ children, fallback, middleware = new Map(), onAuthSucces
|
|
|
3156
3163
|
username,
|
|
3157
3164
|
pathname,
|
|
3158
3165
|
storageService,
|
|
3159
|
-
|
|
3166
|
+
skip,
|
|
3160
3167
|
token,
|
|
3161
3168
|
enableStorageSync,
|
|
3162
3169
|
});
|