MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / decode

Function decode

packages/auth-server/src/server/tokens.ts:24–33  ·  view source on GitHub ↗

Decodes a NextAuth.js issued JWT.

(token: string)

Source from the content-addressed store, hash-verified

22
23/** Decodes a NextAuth.js issued JWT. */
24async function decode(token: string): Promise<JwtPayload | null> {
25 if (!token) return null;
26 const encryptionSecret = await getDerivedEncryptionKey(
27 process.env.NEXTAUTH_SECRET!
28 );
29 const { payload } = await jose.jwtDecrypt(token, encryptionSecret, {
30 clockTolerance: 15,
31 });
32 return payload as JwtPayload;
33}
34
35async function getDerivedEncryptionKey(secret: string | Buffer) {
36 return await hkdf('sha256', secret, '', 'Linen Generated Encryption Key', 32);

Callers 2

decodeHTMLFunction · 0.85
verifyTokenFunction · 0.85

Calls 1

getDerivedEncryptionKeyFunction · 0.85

Tested by

no test coverage detected