import * as jwt from "jsonwebtoken" ; export const TOKEN_SECRET = process . env . TOKEN_SECRET || "nicetrynsa" ; export const TOKEN_ALGORITHM = "HS512" ; export async function generateToken ( payload , expires ) { return jwt . sign ( { ... payload , exp : expires . getTime ( ) / 1000 } , TOKEN_SECRET , { algorithm : TOKEN_ALGORITHM } ) ; } export async function verifyToken ( token ) { return jwt . verify ( token , TOKEN_SECRET , { algorithms : [ TOKEN_ALGORITHM ] } ) ; }