@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.umd.js CHANGED
@@ -1435,6 +1435,19 @@
1435
1435
  }
1436
1436
  // Extract token and user info from response
1437
1437
  const { token, user_uuid, success, message } = completeResponse.data;
1438
+ // Decode JWT to extract email and other user info
1439
+ let tokenEmail;
1440
+ try {
1441
+ const tokenParts = token.split(".");
1442
+ if (tokenParts.length === 3) {
1443
+ const payload = JSON.parse(atob(tokenParts[1]));
1444
+ tokenEmail = payload.email;
1445
+ logger.debug("Extracted email from JWT:", tokenEmail);
1446
+ }
1447
+ }
1448
+ catch (decodeError) {
1449
+ logger.debug("Failed to decode JWT token:", decodeError);
1450
+ }
1438
1451
  // Store tokens - use the JWT token as access token
1439
1452
  const tokens = {
1440
1453
  accessToken: token,
@@ -1443,11 +1456,13 @@
1443
1456
  };
1444
1457
  await this.tokenStorage.setTokens(tokens);
1445
1458
  // Create user object with available information
1459
+ // Prefer email from JWT token, fallback to username
1460
+ const userEmail = tokenEmail || username;
1446
1461
  const user = {
1447
1462
  id: user_uuid,
1448
1463
  uuid: user_uuid,
1449
1464
  username: username,
1450
- email: username, // Assume username is email for now
1465
+ email: userEmail,
1451
1466
  authenticated: true,
1452
1467
  };
1453
1468
  // Update state