@passkeyme/auth 2.0.13 → 2.2.0
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 +50 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +50 -4
- 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("/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
|
*/
|
|
@@ -1018,10 +1041,7 @@ class PasskeymeAuth {
|
|
|
1018
1041
|
redirectToOAuth(provider, redirectUri) {
|
|
1019
1042
|
const finalRedirectUri = redirectUri || this.config.redirectUri;
|
|
1020
1043
|
// Build direct OAuth initiation URL - use apiUrl for backend API endpoints
|
|
1021
|
-
const apiBaseUrl = this.config.apiUrl ||
|
|
1022
|
-
(typeof window !== "undefined" && window.location.hostname !== "localhost"
|
|
1023
|
-
? "https://api.passkeyme.com"
|
|
1024
|
-
: "http://localhost:8000");
|
|
1044
|
+
const apiBaseUrl = this.config.apiUrl || "https://api.passkeyme.com";
|
|
1025
1045
|
const params = new URLSearchParams({
|
|
1026
1046
|
redirect_uri: finalRedirectUri,
|
|
1027
1047
|
});
|
|
@@ -1692,6 +1712,32 @@ class PasskeymeAuth {
|
|
|
1692
1712
|
});
|
|
1693
1713
|
return this._appConfigPromise;
|
|
1694
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
|
+
}
|
|
1695
1741
|
}
|
|
1696
1742
|
// Test comment
|
|
1697
1743
|
|