@iblai/iblai-js 1.8.3 → 1.8.5
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.
|
@@ -88,7 +88,6 @@ const syncSsoDataToCookiesInternal = (data, localStorageKeys) => {
|
|
|
88
88
|
* Initialize localStorage with authentication data and sync to cookies
|
|
89
89
|
*/
|
|
90
90
|
const initializeLocalStorageWithObject = async (data, localStorageKeys) => {
|
|
91
|
-
console.log('#################### local storage before ', JSON.stringify(localStorage));
|
|
92
91
|
// CRITICAL: Clear auth cookies FIRST to prevent syncCookiesToLocalStorage from
|
|
93
92
|
// syncing stale cookie data back to localStorage after we clear it.
|
|
94
93
|
// This must happen before clearing localStorage values.
|
|
@@ -110,7 +109,6 @@ const initializeLocalStorageWithObject = async (data, localStorageKeys) => {
|
|
|
110
109
|
if (data.tenant) {
|
|
111
110
|
localStorage.setItem('tenant', data.tenant);
|
|
112
111
|
}
|
|
113
|
-
console.log('#################### local storage after ', JSON.stringify(localStorage));
|
|
114
112
|
// Sync to cookies for cross-SPA synchronization
|
|
115
113
|
// This sets the NEW auth data in cookies after we've cleared the stale ones
|
|
116
114
|
syncSsoDataToCookiesInternal(data, localStorageKeys);
|
|
@@ -128,33 +126,27 @@ const initializeLocalStorageWithObject = async (data, localStorageKeys) => {
|
|
|
128
126
|
*/
|
|
129
127
|
function SsoLogin({ localStorageKeys, redirectPathKey = 'redirect-to', defaultRedirectPath = '/', onLoginSuccess, resolveRedirectPath, }) {
|
|
130
128
|
const searchParams = useSearchParams();
|
|
129
|
+
const processedRef = React__default.useRef(false);
|
|
131
130
|
React__default.useEffect(() => {
|
|
131
|
+
if (processedRef.current)
|
|
132
|
+
return;
|
|
132
133
|
const queryParamData = searchParams.get('data');
|
|
133
134
|
const incomingRedirectPath = searchParams.get('redirect-path');
|
|
134
|
-
if (queryParamData)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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');
|
|
154
|
-
// Redirect to the target path
|
|
155
|
-
window.location.href = `${window.location.origin}${redirectPath}`;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
135
|
+
if (!queryParamData)
|
|
136
|
+
return;
|
|
137
|
+
processedRef.current = true;
|
|
138
|
+
const parsedData = JSON.parse(queryParamData);
|
|
139
|
+
initializeLocalStorageWithObject(parsedData, localStorageKeys).then(() => {
|
|
140
|
+
onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess(parsedData);
|
|
141
|
+
let redirectPath = localStorage.getItem(redirectPathKey) || incomingRedirectPath || defaultRedirectPath;
|
|
142
|
+
if (resolveRedirectPath) {
|
|
143
|
+
redirectPath = resolveRedirectPath(redirectPath, parsedData);
|
|
144
|
+
}
|
|
145
|
+
localStorage.removeItem(redirectPathKey);
|
|
146
|
+
setCookie('ibl_login_timestamp', String(Date.now()));
|
|
147
|
+
deleteCookie('ibl_tenant_switching');
|
|
148
|
+
window.location.href = `${window.location.origin}${redirectPath}`;
|
|
149
|
+
});
|
|
158
150
|
}, [searchParams, localStorageKeys, redirectPathKey, defaultRedirectPath, onLoginSuccess]);
|
|
159
151
|
return null;
|
|
160
152
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iblai/iblai-js",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
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/data-layer": "1.4.0",
|
|
65
64
|
"@iblai/mcp": "1.4.5",
|
|
66
|
-
"@iblai/web-containers": "1.6.
|
|
67
|
-
"@iblai/
|
|
65
|
+
"@iblai/web-containers": "1.6.4",
|
|
66
|
+
"@iblai/data-layer": "1.4.0",
|
|
67
|
+
"@iblai/web-utils": "1.6.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@iblai/iblai-api": "4.166.0-ai",
|