Reorganizing
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-05-03 11:12:59 -04:00
parent 27a78dd471
commit dc72cefece
23 changed files with 163 additions and 87 deletions

View File

@@ -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);