@passkeyme/auth 2.0.11 → 2.0.12
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 +16 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +16 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/passkeyme-auth.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1429,6 +1429,19 @@ class PasskeymeAuth {
|
|
|
1429
1429
|
}
|
|
1430
1430
|
// Extract token and user info from response
|
|
1431
1431
|
const { token, user_uuid, success, message } = completeResponse.data;
|
|
1432
|
+
// Decode JWT to extract email and other user info
|
|
1433
|
+
let tokenEmail;
|
|
1434
|
+
try {
|
|
1435
|
+
const tokenParts = token.split(".");
|
|
1436
|
+
if (tokenParts.length === 3) {
|
|
1437
|
+
const payload = JSON.parse(atob(tokenParts[1]));
|
|
1438
|
+
tokenEmail = payload.email;
|
|
1439
|
+
logger.debug("Extracted email from JWT:", tokenEmail);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
catch (decodeError) {
|
|
1443
|
+
logger.debug("Failed to decode JWT token:", decodeError);
|
|
1444
|
+
}
|
|
1432
1445
|
// Store tokens - use the JWT token as access token
|
|
1433
1446
|
const tokens = {
|
|
1434
1447
|
accessToken: token,
|
|
@@ -1437,11 +1450,13 @@ class PasskeymeAuth {
|
|
|
1437
1450
|
};
|
|
1438
1451
|
await this.tokenStorage.setTokens(tokens);
|
|
1439
1452
|
// Create user object with available information
|
|
1453
|
+
// Prefer email from JWT token, fallback to username
|
|
1454
|
+
const userEmail = tokenEmail || username;
|
|
1440
1455
|
const user = {
|
|
1441
1456
|
id: user_uuid,
|
|
1442
1457
|
uuid: user_uuid,
|
|
1443
1458
|
username: username,
|
|
1444
|
-
email:
|
|
1459
|
+
email: userEmail,
|
|
1445
1460
|
authenticated: true,
|
|
1446
1461
|
};
|
|
1447
1462
|
// Update state
|