@iblai/web-utils 1.10.2 → 1.10.4

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.js CHANGED
@@ -9389,10 +9389,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
9389
9389
  var _a;
9390
9390
  try {
9391
9391
  setIsAuthenticating(true);
9392
- if ((storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN)) && !hasNonExpiredAuthToken()) {
9392
+ const authToken = await (storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN));
9393
+ if (authToken && !hasNonExpiredAuthToken()) {
9393
9394
  const reason = "Auth token expired";
9394
9395
  onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(reason);
9395
- console.log("[auth-redirect] Auth token has expired", storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN));
9396
+ console.log("[auth-redirect] Auth token has expired");
9396
9397
  safeRedirectToAuthSpa(undefined, undefined, true);
9397
9398
  return;
9398
9399
  }
@@ -9800,28 +9801,28 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
9800
9801
  return;
9801
9802
  }
9802
9803
  }
9803
- // If there is a customDomainPlatformKey and user doesn't belong to that tenant,
9804
+ // If there is a effectiveRequestedTenant and user doesn't belong to that tenant,
9804
9805
  // redirect to auth to re-authenticate. Use a sessionStorage guard to prevent
9805
9806
  // an infinite loop: if we already tried once this session and the user still
9806
9807
  // doesn't belong after re-auth, surface the failure instead of looping.
9807
- if (customDomainPlatformKey) {
9808
- if (!(enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((tenant) => tenant.key === customDomainPlatformKey))) {
9809
- const guardKey = `tenant_access_attempt_${customDomainPlatformKey}`;
9808
+ if (effectiveRequestedTenant) {
9809
+ if (!(enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((tenant) => tenant.key === effectiveRequestedTenant))) {
9810
+ const guardKey = `tenant_access_attempt_${effectiveRequestedTenant}`;
9810
9811
  if (isWeb() && sessionStorage.getItem(guardKey)) {
9811
9812
  sessionStorage.removeItem(guardKey);
9812
- console.warn(`[TenantProvider] User still does not belong to custom domain tenant after re-auth: ${customDomainPlatformKey}`);
9813
- onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
9813
+ console.warn(`[TenantProvider] User still does not belong to tenant after re-auth: ${effectiveRequestedTenant}`);
9814
+ onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${effectiveRequestedTenant}). Please contact your administrator.`);
9814
9815
  return;
9815
9816
  }
9816
9817
  let joined = false;
9817
- joined = await joinAndActivateTenant(customDomainPlatformKey, {
9818
- platform_key: customDomainPlatformKey,
9819
- platform_name: customDomainPlatformKey,
9818
+ joined = await joinAndActivateTenant(effectiveRequestedTenant, {
9819
+ platform_key: effectiveRequestedTenant,
9820
+ platform_name: effectiveRequestedTenant,
9820
9821
  }, {
9821
- key: customDomainPlatformKey,
9822
+ key: effectiveRequestedTenant,
9822
9823
  is_admin: false,
9823
- org: customDomainPlatformKey,
9824
- platform_name: customDomainPlatformKey,
9824
+ org: effectiveRequestedTenant,
9825
+ platform_name: effectiveRequestedTenant,
9825
9826
  }, { handleVisitingTenant: false });
9826
9827
  if (isWeb()) {
9827
9828
  if (!joined) {