@iblai/iblai-js 1.6.2 → 1.8.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.
@@ -126,7 +126,7 @@ const initializeLocalStorageWithObject = async (data, localStorageKeys) => {
126
126
  * 3. Syncs critical auth data to cookies for cross-SPA synchronization
127
127
  * 4. Redirects to the appropriate path after login
128
128
  */
129
- function SsoLogin({ localStorageKeys, redirectPathKey = 'redirect-to', defaultRedirectPath = '/', onLoginSuccess, }) {
129
+ function SsoLogin({ localStorageKeys, redirectPathKey = 'redirect-to', defaultRedirectPath = '/', onLoginSuccess, resolveRedirectPath, }) {
130
130
  const searchParams = useSearchParams();
131
131
  React__default.useEffect(() => {
132
132
  const queryParamData = searchParams.get('data');
@@ -138,21 +138,19 @@ function SsoLogin({ localStorageKeys, redirectPathKey = 'redirect-to', defaultRe
138
138
  onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess(parsedData);
139
139
  // Determine redirect path
140
140
  let redirectPath = localStorage.getItem(redirectPathKey) || incomingRedirectPath || defaultRedirectPath;
141
- // Check if redirectPath contains a platform key that doesn't match the authenticated tenant
142
- const platformKeyMatch = redirectPath.match(/^\/platform\/([^/]+)/);
143
- if (platformKeyMatch) {
144
- const pathPlatformKey = platformKeyMatch[1];
145
- const authenticatedTenant = parsedData.tenant;
146
- if (authenticatedTenant && pathPlatformKey !== authenticatedTenant) {
147
- // Platform key in path doesn't match authenticated tenant, reset to default
148
- redirectPath = '/';
149
- }
141
+ // Allow the calling component to resolve/override the redirect path
142
+ if (resolveRedirectPath) {
143
+ redirectPath = resolveRedirectPath(redirectPath, parsedData);
150
144
  }
151
145
  // Clean up redirect path from storage
152
146
  localStorage.removeItem(redirectPathKey);
153
147
  // Debug: log localStorage right before redirect
154
- console.log('##################### BEFORE REDIRECT localStorage.tenant:', localStorage.getItem('tenant'));
155
- console.log('##################### BEFORE REDIRECT redirectPath:', redirectPath);
148
+ console.log('[sso-login] localStorage.tenant:', localStorage.getItem('tenant'));
149
+ console.log('[sso-login] redirectPath:', redirectPath);
150
+ // Set login timestamp so auth provider won't redirect during an active login
151
+ setCookie('ibl_login_timestamp', String(Date.now()));
152
+ // Clear tenant switching cookie before redirect
153
+ deleteCookie('ibl_tenant_switching');
156
154
  // Redirect to the target path
157
155
  window.location.href = `${window.location.origin}${redirectPath}`;
158
156
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iblai/iblai-js",
3
- "version": "1.6.2",
3
+ "version": "1.8.0",
4
4
  "description": "Unified JavaScript SDK for IBL.ai — re-exports data-layer, web-containers, and web-utils under a single package",
5
5
  "type": "module",
6
6
  "engines": {
@@ -61,10 +61,10 @@
61
61
  "axios": "1.13.6",
62
62
  "dotenv": "16.6.1",
63
63
  "winston": "3.19.0",
64
- "@iblai/web-containers": "1.4.1",
65
- "@iblai/web-utils": "1.4.1",
64
+ "@iblai/data-layer": "1.4.0",
66
65
  "@iblai/mcp": "1.4.2",
67
- "@iblai/data-layer": "1.4.0"
66
+ "@iblai/web-containers": "1.6.0",
67
+ "@iblai/web-utils": "1.6.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@iblai/iblai-api": "4.166.0-ai",