MCPcopy Index your code
hub / github.com/CapSoftware/Cap / decodeSessionToken

Function decodeSessionToken

packages/database/auth/auth-options.ts:21–44  ·  view source on GitHub ↗
(
	params: JWTDecodeParams,
)

Source from the content-addressed store, hash-verified

19export const maxDuration = 120;
20
21export async function decodeSessionToken(
22 params: JWTDecodeParams,
23): Promise<JWT | null> {
24 const token = await decode(params);
25 if (!token) return null;
26
27 const userId = typeof token.id === "string" ? token.id : null;
28 if (!userId) return token;
29
30 const [user] = await db()
31 .select({ authSessionVersion: users.authSessionVersion })
32 .from(users)
33 .where(eq(users.id, User.UserId.make(userId)))
34 .limit(1);
35
36 if (!user) return null;
37
38 const sessionVersion =
39 typeof token.sessionVersion === "number" ? token.sessionVersion : 0;
40
41 if (sessionVersion !== user.authSessionVersion) return null;
42
43 return token;
44}
45
46export const authOptions = (): NextAuthOptions => {
47 let _adapter: Adapter | undefined;

Callers 1

session.tsFile · 0.90

Calls 2

dbFunction · 0.90
decodeFunction · 0.85

Tested by

no test coverage detected