Spaces:
Runtime error
Runtime error
File size: 1,355 Bytes
f3abb0d 4acc19f f3abb0d 4acc19f 52c09c2 f3abb0d 4acc19f f3abb0d 4acc19f f3abb0d 4acc19f | 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import { JwtVerifyOptions } from '@nestjs/jwt';
import type { StringValue } from 'ms';
export enum TOKEN_TYPE {
REFRESH = 'REFRESH',
ACCESS = 'ACCESS',
}
export enum TOKEN_USER_TYPE {
USER = 'USER',
SUPER_ADMIN = 'SUPER_ADMIN',
}
export const jwtAuthConstants = {
accessTokenSecret: process.env.JWT_ACCESS_SECRET || 'default-access-secret',
refreshTokenSecret:
process.env.JWT_REFRESH_SECRET || 'default-refresh-secret',
accessTokenExpiresIn: (process.env.JWT_ACCESS_EXPIRES_IN ||
'24h') as StringValue,
refreshTokenExpiresIn: (process.env.JWT_REFRESH_EXPIRES_IN ||
'7d') as StringValue,
};
export const refreshTokenSignSettings = {
secret: jwtAuthConstants.refreshTokenSecret,
expiresIn: jwtAuthConstants.refreshTokenExpiresIn,
};
export const accessTokenSignSettings = {
secret: jwtAuthConstants.accessTokenSecret,
expiresIn: jwtAuthConstants.accessTokenExpiresIn,
};
export const accessTokenVerifySettings: JwtVerifyOptions = {
secret: jwtAuthConstants.accessTokenSecret,
};
export const refreshTokenVerifySettings: JwtVerifyOptions = {
secret: jwtAuthConstants.refreshTokenSecret,
};
export const AuthMessages = {
ACCESS_TOKEN_VALID: 'Access token is already valid.',
REFRESH_TOKEN_INVALID: 'Refresh token is expired.',
LOGIN_SUCCESS: 'Login successful',
LOGOUT_SUCCESS: 'Logout successful',
};
|