Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 7x 14x 7x 7x 7x 7x 7x 7x 16x 7x 7x 16x 7x 7x 7x 7x | import appConfig from '@/config/app.config';
import jwt from 'jsonwebtoken';
import { v4 as uuidv4 } from 'uuid';
export const generateAccessToken = (userId: string) => {
return jwt.sign(
{
userId,
timestamp: Date.now(),
},
appConfig.jwt.secret,
{ expiresIn: appConfig.jwt.expiresIn }
);
};
export const generateRefreshToken = () => {
return uuidv4();
};
export const verifyAccessToken = (token: string) => {
return jwt.verify(token, appConfig.jwt.secret);
};
export const verifyRefreshToken = (token: string) => {
return jwt.verify(token, appConfig.jwt.refreshSecretKey);
};
|