This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { JWT_SECRET } from '../constants/defaults';
|
||||
|
||||
export const getJwtSecret = () => process.env.JWT_SECRET || JWT_SECRET;
|
||||
import { JWT_AUDIENCE, JWT_ISSUER, JWT_SECRET } from '../constants/constants';
|
||||
export interface TokenProps {
|
||||
aud?: string;
|
||||
exp?: number | Date;
|
||||
@@ -26,12 +24,12 @@ export const sign = (props: SignProps) => {
|
||||
{
|
||||
exp,
|
||||
sub,
|
||||
aud: rest.aud || process.env.JWT_AUDIENCE,
|
||||
aud: rest.aud || JWT_AUDIENCE,
|
||||
iat: today.getTime(),
|
||||
iss: rest.iss || process.env.JWT_ISSUER,
|
||||
iss: rest.iss || JWT_ISSUER,
|
||||
},
|
||||
getJwtSecret(),
|
||||
JWT_SECRET,
|
||||
);
|
||||
};
|
||||
|
||||
export const verify = (token: string) => jwt.verify(token, getJwtSecret());
|
||||
export const verify = (token: string) => jwt.verify(token, JWT_SECRET);
|
||||
|
||||
Reference in New Issue
Block a user