MCPcopy Create free account
hub / github.com/LevelUpWeb3/app / getUserFromToken

Function getUserFromToken

src/app/api/utils/auth.ts:8–21  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

6);
7
8async function getUserFromToken(req) {
9 try {
10 const authToken = req.cookies.get("privy-token")?.value;
11 if (!authToken) {
12 throw new Error("No ID token found in cookies");
13 }
14 const verifiedClaims = await privy.verifyAuthToken(authToken);
15 const user = await privy.getUserById(verifiedClaims.userId);
16 return user;
17 } catch (error) {
18 console.error("Error validating ID token:", error);
19 throw new Error("Invalid or expired token");
20 }
21}
22
23export { getUserFromToken, privy };

Callers 3

POSTFunction · 0.90
POSTFunction · 0.90
POSTFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected