antaeus.keycloak.react 2.2.0 → 2.2.2
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 +23 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1351,7 +1351,6 @@ var DeviceLogin = ({
|
|
|
1351
1351
|
const [loading, setLoading] = useState(true);
|
|
1352
1352
|
const [timeRemaining, setTimeRemaining] = useState(null);
|
|
1353
1353
|
const pollTimerRef = useRef(null);
|
|
1354
|
-
const userManagerRef = useRef(null);
|
|
1355
1354
|
useEffect(() => {
|
|
1356
1355
|
const initDeviceFlow = async () => {
|
|
1357
1356
|
setLoading(true);
|
|
@@ -1386,7 +1385,6 @@ var DeviceLogin = ({
|
|
|
1386
1385
|
}, [deviceData, timeRemaining]);
|
|
1387
1386
|
useEffect(() => {
|
|
1388
1387
|
if (!deviceData) return;
|
|
1389
|
-
userManagerRef.current = auth.userManager;
|
|
1390
1388
|
const poll = async () => {
|
|
1391
1389
|
try {
|
|
1392
1390
|
const tokenResponse = await pollForToken(apiBaseUrl, deviceData.device_code);
|
|
@@ -1398,19 +1396,34 @@ var DeviceLogin = ({
|
|
|
1398
1396
|
const user = new User({
|
|
1399
1397
|
id_token: tokenResponse.id_token || "",
|
|
1400
1398
|
access_token: tokenResponse.access_token,
|
|
1401
|
-
token_type: tokenResponse.token_type,
|
|
1399
|
+
token_type: tokenResponse.token_type || "Bearer",
|
|
1402
1400
|
profile: userInfo,
|
|
1403
1401
|
expires_at: Math.floor(Date.now() / 1e3) + tokenResponse.expires_in,
|
|
1404
1402
|
scope: tokenResponse.scope,
|
|
1405
|
-
refresh_token: tokenResponse.refresh_token
|
|
1403
|
+
refresh_token: tokenResponse.refresh_token,
|
|
1404
|
+
session_state: null
|
|
1405
|
+
// Device flow doesn't have session_state
|
|
1406
1406
|
});
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1407
|
+
console.log("[DeviceLogin] Device flow authentication successful", {
|
|
1408
|
+
hasAccessToken: !!user.access_token,
|
|
1409
|
+
hasRefreshToken: !!user.refresh_token,
|
|
1410
|
+
expiresAt: user.expires_at,
|
|
1411
|
+
profile: userInfo.preferred_username
|
|
1412
|
+
});
|
|
1413
|
+
const storageKey = `oidc.user:${auth.settings.authority}:${auth.settings.client_id}`;
|
|
1414
|
+
const userJson = user.toStorageString();
|
|
1415
|
+
const storage = auth.settings.userStore?.store || window.sessionStorage;
|
|
1416
|
+
console.log("[DeviceLogin] Storing user in storage...", {
|
|
1417
|
+
storageKey,
|
|
1418
|
+
storageType: storage === window.localStorage ? "localStorage" : "sessionStorage"
|
|
1419
|
+
});
|
|
1420
|
+
storage.setItem(storageKey, userJson);
|
|
1421
|
+
const stored = storage.getItem(storageKey);
|
|
1422
|
+
if (!stored) {
|
|
1423
|
+
console.error("[DeviceLogin] Failed to store user in storage!");
|
|
1424
|
+
throw new Error("Failed to store user session. Please try again.");
|
|
1413
1425
|
}
|
|
1426
|
+
console.log("[DeviceLogin] User stored successfully in", storage === window.localStorage ? "localStorage" : "sessionStorage");
|
|
1414
1427
|
if (onSuccess) {
|
|
1415
1428
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1416
1429
|
onSuccess(user);
|