Skip to content

Commit

Permalink
OV-5: * fix Wrong amount of left-padding spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-lacorazza committed Aug 20, 2024
1 parent add55d7 commit 68aba69
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions backend/src/common/services/token/token.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { type JWTPayload as TokenPayload } from 'jose';
import { jwtVerify, SignJWT } from 'jose';

class TokenService {
private SECRET_KEY: Uint8Array;
private EXPIRATION_TIME: string;
private SECRET_KEY: Uint8Array;
private EXPIRATION_TIME: string;

public constructor(secretKey: string, expirationTime: string) {
this.SECRET_KEY = new TextEncoder().encode(secretKey);
this.EXPIRATION_TIME = expirationTime;
}
public constructor(secretKey: string, expirationTime: string) {
this.SECRET_KEY = new TextEncoder().encode(secretKey);
this.EXPIRATION_TIME = expirationTime;
}

public async createToken(userId: number): Promise<string> {
return await new SignJWT({ userId })
.setProtectedHeader({ alg: 'HS256' })
.setExpirationTime(this.EXPIRATION_TIME)
.sign(this.SECRET_KEY);
}
return await new SignJWT({ userId })
.setProtectedHeader({ alg: 'HS256' })
.setExpirationTime(this.EXPIRATION_TIME)
.sign(this.SECRET_KEY);
}

public async verifyToken(token: string): Promise<TokenPayload | null> {
try {
Expand Down

0 comments on commit 68aba69

Please sign in to comment.