MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / encode

Function encode

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

Issues a JWT. By default, the JWT is encrypted using "A256GCM".

(user: any)

Source from the content-addressed store, hash-verified

9
10/** Issues a JWT. By default, the JWT is encrypted using "A256GCM". */
11async function encode(user: any) {
12 const encryptionSecret = await getDerivedEncryptionKey(
13 process.env.NEXTAUTH_SECRET!
14 );
15 return await new jose.EncryptJWT({ data: user })
16 .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
17 .setIssuedAt()
18 .setExpirationTime(now() + DEFAULT_MAX_AGE)
19 .setJti(uuid())
20 .encrypt(encryptionSecret);
21}
22
23/** Decodes a NextAuth.js issued JWT. */
24async function decode(token: string): Promise<JwtPayload | null> {

Callers 3

signTokenFunction · 0.85
getServerSidePropsFunction · 0.85
getServerSidePropsFunction · 0.85

Calls 2

getDerivedEncryptionKeyFunction · 0.85
nowFunction · 0.70

Tested by

no test coverage detected