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