update websocket

This commit is contained in:
2024-11-06 17:16:10 +07:00
parent ef5c753ce4
commit 57037a59ec
18 changed files with 129 additions and 71 deletions

View File

@@ -134,4 +134,8 @@ export class DateTimeUtils {
second: second as SecondNumbers,
}
}
static getTimeFromDateTime(dateTime: DateTime): TimeType {
return this.toTime(`${dateTime.hour}:${dateTime.minute}:${dateTime.second}`)
}
}

View File

@@ -7,9 +7,11 @@ 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!
signTokenRS256(payload: string, expiresIn: string) {
const privateKey = process.env.JWT_RS256_PRIVATE_KEY
if (!privateKey) {
throw new Error('JWT_RS256_PRIVATE_KEY is not defined')
}
return sign(payload, privateKey, {
algorithm: 'RS256',
expiresIn,
@@ -17,7 +19,10 @@ export class JwtUtils {
}
verifyTokenRS256(token: string) {
const publicKey = process.env.JWT_RS256_PUBLIC_KEY!
const publicKey = process.env.JWT_RS256_PUBLIC_KEY
if (!publicKey) {
throw new Error('JWT_RS256_PUBLIC_KEY is not defined')
}
return verify(token, publicKey, {
algorithms: ['RS256'],
})