refactor source code

This commit is contained in:
2024-10-29 17:42:54 +07:00
parent 3b23d9e0b7
commit 152bb50da8
83 changed files with 8473 additions and 7577 deletions

View File

@@ -1,29 +1,29 @@
import { sign, verify } from 'jsonwebtoken';
import { sign, verify } from 'jsonwebtoken'
import { Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common'
@Injectable()
export class JwtUtils {
signToken(payload: string, expiresIn: string) {
return sign(payload, process.env.JWT_SECRET!, { expiresIn });
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!;
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!;
const publicKey = process.env.JWT_RS256_PUBLIC_KEY!
return verify(token, publicKey, {
algorithms: ['RS256'],
});
})
}
verifyToken(token: string) {
return verify(token, process.env.JWT_SECRET!);
return verify(token, process.env.JWT_SECRET!)
}
}