From bd5b289168f60359beec4d1e3ae6f0391f59afb3 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 19 Jul 2022 21:59:06 +0800 Subject: [PATCH] add verification token generation --- packages/api/src/utils/auth.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/api/src/utils/auth.ts b/packages/api/src/utils/auth.ts index 12b34cce3..38ce9e345 100644 --- a/packages/api/src/utils/auth.ts +++ b/packages/api/src/utils/auth.ts @@ -79,3 +79,12 @@ export const getClaimsByToken = async ( return claims } + +export const generateVerificationToken = (userId: string) => { + const iat = Math.floor(Date.now() / 1000) + const exp = Math.floor( + new Date(Date.now() + 1000 * 60 * 60 * 24).getTime() / 1000 + ) + + return jwt.sign({ uid: userId, iat, exp }, env.server.jwtSecret) +}