@iblai/web-utils 1.4.1 → 1.5.0
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 +4 -3
- package/dist/index.esm.js +32 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/providers/tenant-provider.d.ts +2 -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, skipAuthCheck, 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> |
|
|
1560
|
+
declare function AuthProvider({ children, fallback, middleware, onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, skipAuthCheck, storageService, token, enableStorageSync, skip, }: Props$2): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | 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> | 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 | 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> |
|
|
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 | react_jsx_runtime.JSX.Element | 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> | null | undefined;
|
|
1594
1594
|
|
|
1595
1595
|
/**
|
|
1596
1596
|
* Type definition for the tenant context
|
|
@@ -1642,6 +1642,7 @@ type Props = {
|
|
|
1642
1642
|
skip?: boolean;
|
|
1643
1643
|
onLoadPlatformPermissions?: (rbacPermissions: Record<string, unknown> | undefined) => void;
|
|
1644
1644
|
skipCustomDomainCheck?: boolean;
|
|
1645
|
+
onTenantMismatch?: () => void;
|
|
1645
1646
|
};
|
|
1646
1647
|
/**
|
|
1647
1648
|
* TenantProvider Component
|
|
@@ -1653,7 +1654,7 @@ type Props = {
|
|
|
1653
1654
|
* 4. Handles tenant-specific domain redirects
|
|
1654
1655
|
* 5. Maintains tenant access state
|
|
1655
1656
|
*/
|
|
1656
|
-
declare function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed, setUseMentorProvider, skip, onLoadPlatformPermissions, skipCustomDomainCheck, }: 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> |
|
|
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 | react_jsx_runtime.JSX.Element | 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> | null | undefined;
|
|
1657
1658
|
|
|
1658
1659
|
/**
|
|
1659
1660
|
* Chat area size constants
|
package/dist/index.esm.js
CHANGED
|
@@ -2832,6 +2832,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2832
2832
|
console.log("[AuthProvider] Redirect already in progress, skipping");
|
|
2833
2833
|
return;
|
|
2834
2834
|
}
|
|
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
|
+
}
|
|
2835
2840
|
isRedirectingRef.current = true;
|
|
2836
2841
|
// NOTE: we intentionally do NOT clear the interval here.
|
|
2837
2842
|
// The isRedirectingRef guard prevents redundant redirects while navigation
|
|
@@ -2927,6 +2932,8 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2927
2932
|
needsRefresh,
|
|
2928
2933
|
userDataOutOfSync,
|
|
2929
2934
|
pathname,
|
|
2935
|
+
currentLogoutTimestamp,
|
|
2936
|
+
lastLogoutTimestampRef: lastLogoutTimestampRef.current,
|
|
2930
2937
|
});
|
|
2931
2938
|
if (needsRefresh) {
|
|
2932
2939
|
console.log("[auth-redirect] Cookie sync detected changes from another SPA, refreshing page");
|
|
@@ -3203,7 +3210,7 @@ const useTenantContext = () => useContext(TenantContext);
|
|
|
3203
3210
|
* 4. Handles tenant-specific domain redirects
|
|
3204
3211
|
* 5. Maintains tenant access state
|
|
3205
3212
|
*/
|
|
3206
|
-
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed = false, setUseMentorProvider, skip = false, onLoadPlatformPermissions, skipCustomDomainCheck = false, }) {
|
|
3213
|
+
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed = false, setUseMentorProvider, skip = false, onLoadPlatformPermissions, skipCustomDomainCheck = false, onTenantMismatch = () => { }, }) {
|
|
3207
3214
|
// If skip is true, just return children without any provider logic
|
|
3208
3215
|
if (skip) {
|
|
3209
3216
|
return jsx(Fragment, { children: children });
|
|
@@ -3634,6 +3641,30 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
3634
3641
|
isLoadingCustomDomain,
|
|
3635
3642
|
isCustomDomainError,
|
|
3636
3643
|
]);
|
|
3644
|
+
// Poll every 2s: if requestedTenant exists, differs from currentTenant,
|
|
3645
|
+
// and user is not on a public route, invoke the onTenantMismatch callback.
|
|
3646
|
+
React__default.useEffect(() => {
|
|
3647
|
+
if (!onTenantMismatch)
|
|
3648
|
+
return;
|
|
3649
|
+
const interval = setInterval(() => {
|
|
3650
|
+
if (requestedTenant &&
|
|
3651
|
+
currentTenant &&
|
|
3652
|
+
requestedTenant !== currentTenant &&
|
|
3653
|
+
!userIsAccessingPublicRoute) {
|
|
3654
|
+
console.log("[TenantProvider] Tenant mismatch detected", {
|
|
3655
|
+
requestedTenant,
|
|
3656
|
+
currentTenant,
|
|
3657
|
+
});
|
|
3658
|
+
onTenantMismatch();
|
|
3659
|
+
}
|
|
3660
|
+
}, 2000);
|
|
3661
|
+
return () => clearInterval(interval);
|
|
3662
|
+
}, [
|
|
3663
|
+
requestedTenant,
|
|
3664
|
+
currentTenant,
|
|
3665
|
+
userIsAccessingPublicRoute,
|
|
3666
|
+
onTenantMismatch,
|
|
3667
|
+
]);
|
|
3637
3668
|
// Show fallback component during tenant determination
|
|
3638
3669
|
if (isLoading) {
|
|
3639
3670
|
return fallback;
|