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

Function createCSRFToken

packages/auth-server/src/server/csrf.ts:18–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 */
17
18export function createCSRFToken() {
19 // New CSRF token
20 const csrfToken = randomBytes(32).toString('hex');
21 const csrfTokenHash = createHash('sha256')
22 .update(`${csrfToken}${process.env.NEXTAUTH_SECRET}`)
23 .digest('hex');
24 const token = `${csrfToken}|${csrfTokenHash}`;
25
26 return token;
27}
28
29export function verifyCSRFToken(token: string) {
30 const [csrfToken, csrfTokenHash] = token.split('|');

Callers 6

CreateRouterFunction · 0.90
getServerSidePropsFunction · 0.90
getServerSidePropsFunction · 0.90
step2_signUpFunction · 0.90
auth.test.tsFile · 0.90
loginFunction · 0.90

Calls 1

updateMethod · 0.45

Tested by 2

step2_signUpFunction · 0.72
loginFunction · 0.72