( params: JWTDecodeParams, )
| 19 | export const maxDuration = 120; |
| 20 | |
| 21 | export 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 | |
| 46 | export const authOptions = (): NextAuthOptions => { |
| 47 | let _adapter: Adapter | undefined; |
no test coverage detected