(token: string)
| 27 | } |
| 28 | |
| 29 | export function verifyCSRFToken(token: string) { |
| 30 | const [csrfToken, csrfTokenHash] = token.split('|'); |
| 31 | const expectedCsrfTokenHash = createHash('sha256') |
| 32 | .update(`${csrfToken}${process.env.NEXTAUTH_SECRET}`) |
| 33 | .digest('hex'); |
| 34 | |
| 35 | return csrfTokenHash === expectedCsrfTokenHash; |
| 36 | } |
no test coverage detected