@passkeyme/auth 2.1.0 → 2.2.1
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 +49 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +49 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/src/api-client.d.ts +6 -0
- package/dist/src/api-client.d.ts.map +1 -1
- package/dist/src/passkeyme-auth.d.ts +7 -0
- package/dist/src/passkeyme-auth.d.ts.map +1 -1
- package/dist/src/types.d.ts +14 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -423,6 +423,29 @@ class PasskeymeApiClient {
|
|
|
423
423
|
lastLoginAt: new Date().toISOString(),
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Get detailed user information from /userinfo endpoint
|
|
428
|
+
* Returns rich user data including name, picture, etc.
|
|
429
|
+
* Requires a valid access token.
|
|
430
|
+
*/
|
|
431
|
+
async getUserInfo(accessToken) {
|
|
432
|
+
const response = (await this.request("/api/userinfo", {
|
|
433
|
+
method: "GET",
|
|
434
|
+
headers: {
|
|
435
|
+
Authorization: `Bearer ${accessToken}`,
|
|
436
|
+
},
|
|
437
|
+
}));
|
|
438
|
+
// Convert userinfo response to User object
|
|
439
|
+
return {
|
|
440
|
+
id: response.sub,
|
|
441
|
+
email: response.email,
|
|
442
|
+
name: response.name || response.email,
|
|
443
|
+
givenName: response.given_name,
|
|
444
|
+
familyName: response.family_name,
|
|
445
|
+
picture: response.picture,
|
|
446
|
+
emailVerified: response.email_verified,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
426
449
|
/**
|
|
427
450
|
* Refresh access token
|
|
428
451
|
*/
|
|
@@ -1689,6 +1712,32 @@ class PasskeymeAuth {
|
|
|
1689
1712
|
});
|
|
1690
1713
|
return this._appConfigPromise;
|
|
1691
1714
|
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Get detailed user information including name, picture, etc.
|
|
1717
|
+
* Requires the user to be authenticated.
|
|
1718
|
+
* This calls the /userinfo endpoint which returns richer user data
|
|
1719
|
+
* than what's available from the JWT token alone.
|
|
1720
|
+
*/
|
|
1721
|
+
async getUserInfo() {
|
|
1722
|
+
const accessToken = await this.getAccessToken();
|
|
1723
|
+
if (!accessToken) {
|
|
1724
|
+
throw new PasskeymeError({
|
|
1725
|
+
code: exports.PasskeymeErrorCode.SESSION_EXPIRED,
|
|
1726
|
+
message: "No access token available",
|
|
1727
|
+
userMessage: "Please sign in to view user information.",
|
|
1728
|
+
recoverable: true,
|
|
1729
|
+
retryable: false,
|
|
1730
|
+
suggestedAction: "Sign in again",
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
const userInfo = await this.apiClient.getUserInfo(accessToken);
|
|
1734
|
+
// Update state with enriched user data
|
|
1735
|
+
this.setState({
|
|
1736
|
+
user: { ...this._state.user, ...userInfo },
|
|
1737
|
+
});
|
|
1738
|
+
logger.debug("User info retrieved:", userInfo);
|
|
1739
|
+
return userInfo;
|
|
1740
|
+
}
|
|
1692
1741
|
}
|
|
1693
1742
|
// Test comment
|
|
1694
1743
|
|