Issues a JWT. By default, the JWT is encrypted using "A256GCM".
(user: any)
| 9 | |
| 10 | /** Issues a JWT. By default, the JWT is encrypted using "A256GCM". */ |
| 11 | async 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. */ |
| 24 | async function decode(token: string): Promise<JwtPayload | null> { |
no test coverage detected