@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.esm.js CHANGED
@@ -9369,10 +9369,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
9369
9369
  var _a;
9370
9370
  try {
9371
9371
  setIsAuthenticating(true);
9372
- if ((storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN)) && !hasNonExpiredAuthToken()) {
9372
+ const authToken = await (storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN));
9373
+ if (authToken && !hasNonExpiredAuthToken()) {
9373
9374
  const reason = "Auth token expired";
9374
9375
  onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(reason);
9375
- console.log("[auth-redirect] Auth token has expired", storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN));
9376
+ console.log("[auth-redirect] Auth token has expired");
9376
9377
  safeRedirectToAuthSpa(undefined, undefined, true);
9377
9378
  return;
9378
9379
  }
@@ -9780,28 +9781,28 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
9780
9781
  return;
9781
9782
  }
9782
9783
  }
9783
- // If there is a customDomainPlatformKey and user doesn't belong to that tenant,
9784
+ // If there is a effectiveRequestedTenant and user doesn't belong to that tenant,
9784
9785
  // redirect to auth to re-authenticate. Use a sessionStorage guard to prevent
9785
9786
  // an infinite loop: if we already tried once this session and the user still
9786
9787
  // doesn't belong after re-auth, surface the failure instead of looping.
9787
- if (customDomainPlatformKey) {
9788
- if (!(enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((tenant) => tenant.key === customDomainPlatformKey))) {
9789
- const guardKey = `tenant_access_attempt_${customDomainPlatformKey}`;
9788
+ if (effectiveRequestedTenant) {
9789
+ if (!(enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((tenant) => tenant.key === effectiveRequestedTenant))) {
9790
+ const guardKey = `tenant_access_attempt_${effectiveRequestedTenant}`;
9790
9791
  if (isWeb() && sessionStorage.getItem(guardKey)) {
9791
9792
  sessionStorage.removeItem(guardKey);
9792
- console.warn(`[TenantProvider] User still does not belong to custom domain tenant after re-auth: ${customDomainPlatformKey}`);
9793
- onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
9793
+ console.warn(`[TenantProvider] User still does not belong to tenant after re-auth: ${effectiveRequestedTenant}`);
9794
+ onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${effectiveRequestedTenant}). Please contact your administrator.`);
9794
9795
  return;
9795
9796
  }
9796
9797
  let joined = false;
9797
- joined = await joinAndActivateTenant(customDomainPlatformKey, {
9798
- platform_key: customDomainPlatformKey,
9799
- platform_name: customDomainPlatformKey,
9798
+ joined = await joinAndActivateTenant(effectiveRequestedTenant, {
9799
+ platform_key: effectiveRequestedTenant,
9800
+ platform_name: effectiveRequestedTenant,
9800
9801
  }, {
9801
- key: customDomainPlatformKey,
9802
+ key: effectiveRequestedTenant,
9802
9803
  is_admin: false,
9803
- org: customDomainPlatformKey,
9804
- platform_name: customDomainPlatformKey,
9804
+ org: effectiveRequestedTenant,
9805
+ platform_name: effectiveRequestedTenant,
9805
9806
  }, { handleVisitingTenant: false });
9806
9807
  if (isWeb()) {
9807
9808
  if (!joined) {