@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.esm.js
CHANGED
|
@@ -419,6 +419,29 @@ class PasskeymeApiClient {
|
|
|
419
419
|
lastLoginAt: new Date().toISOString(),
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Get detailed user information from /userinfo endpoint
|
|
424
|
+
* Returns rich user data including name, picture, etc.
|
|
425
|
+
* Requires a valid access token.
|
|
426
|
+
*/
|
|
427
|
+
async getUserInfo(accessToken) {
|
|
428
|
+
const response = (await this.request("/userinfo", {
|
|
429
|
+
method: "GET",
|
|
430
|
+
headers: {
|
|
431
|
+
Authorization: `Bearer ${accessToken}`,
|
|
432
|
+
},
|
|
433
|
+
}));
|
|
434
|
+
// Convert userinfo response to User object
|
|
435
|
+
return {
|
|
436
|
+
id: response.sub,
|
|
437
|
+
email: response.email,
|
|
438
|
+
name: response.name || response.email,
|
|
439
|
+
givenName: response.given_name,
|
|
440
|
+
familyName: response.family_name,
|
|
441
|
+
picture: response.picture,
|
|
442
|
+
emailVerified: response.email_verified,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
422
445
|
/**
|
|
423
446
|
* Refresh access token
|
|
424
447
|
*/
|
|
@@ -1014,10 +1037,7 @@ class PasskeymeAuth {
|
|
|
1014
1037
|
redirectToOAuth(provider, redirectUri) {
|
|
1015
1038
|
const finalRedirectUri = redirectUri || this.config.redirectUri;
|
|
1016
1039
|
// Build direct OAuth initiation URL - use apiUrl for backend API endpoints
|
|
1017
|
-
const apiBaseUrl = this.config.apiUrl ||
|
|
1018
|
-
(typeof window !== "undefined" && window.location.hostname !== "localhost"
|
|
1019
|
-
? "https://api.passkeyme.com"
|
|
1020
|
-
: "http://localhost:8000");
|
|
1040
|
+
const apiBaseUrl = this.config.apiUrl || "https://api.passkeyme.com";
|
|
1021
1041
|
const params = new URLSearchParams({
|
|
1022
1042
|
redirect_uri: finalRedirectUri,
|
|
1023
1043
|
});
|
|
@@ -1688,6 +1708,32 @@ class PasskeymeAuth {
|
|
|
1688
1708
|
});
|
|
1689
1709
|
return this._appConfigPromise;
|
|
1690
1710
|
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Get detailed user information including name, picture, etc.
|
|
1713
|
+
* Requires the user to be authenticated.
|
|
1714
|
+
* This calls the /userinfo endpoint which returns richer user data
|
|
1715
|
+
* than what's available from the JWT token alone.
|
|
1716
|
+
*/
|
|
1717
|
+
async getUserInfo() {
|
|
1718
|
+
const accessToken = await this.getAccessToken();
|
|
1719
|
+
if (!accessToken) {
|
|
1720
|
+
throw new PasskeymeError({
|
|
1721
|
+
code: PasskeymeErrorCode.SESSION_EXPIRED,
|
|
1722
|
+
message: "No access token available",
|
|
1723
|
+
userMessage: "Please sign in to view user information.",
|
|
1724
|
+
recoverable: true,
|
|
1725
|
+
retryable: false,
|
|
1726
|
+
suggestedAction: "Sign in again",
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
const userInfo = await this.apiClient.getUserInfo(accessToken);
|
|
1730
|
+
// Update state with enriched user data
|
|
1731
|
+
this.setState({
|
|
1732
|
+
user: { ...this._state.user, ...userInfo },
|
|
1733
|
+
});
|
|
1734
|
+
logger.debug("User info retrieved:", userInfo);
|
|
1735
|
+
return userInfo;
|
|
1736
|
+
}
|
|
1691
1737
|
}
|
|
1692
1738
|
// Test comment
|
|
1693
1739
|
|