add invite staff
This commit is contained in:
29
src/common/utils/jwt.utils.ts
Normal file
29
src/common/utils/jwt.utils.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { sign, verify } from 'jsonwebtoken';
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class JwtUtils {
|
||||
signToken(payload: string, expiresIn: string) {
|
||||
return sign(payload, process.env.JWT_SECRET!, { expiresIn });
|
||||
}
|
||||
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
signTokenRS256(payload: any, expiresIn: string) {
|
||||
const privateKey = process.env.JWT_RS256_PRIVATE_KEY!;
|
||||
return sign(payload, privateKey, {
|
||||
algorithm: 'RS256',
|
||||
expiresIn,
|
||||
});
|
||||
}
|
||||
|
||||
verifyTokenRS256(token: string) {
|
||||
const publicKey = process.env.JWT_RS256_PUBLIC_KEY!;
|
||||
return verify(token, publicKey, {
|
||||
algorithms: ['RS256'],
|
||||
});
|
||||
}
|
||||
|
||||
verifyToken(token: string) {
|
||||
return verify(token, process.env.JWT_SECRET!);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user