based authentication for my app and the problem is that jose generates token from the past, when I check it on https://www.unixtimestamp.com/ it says that ths four days in the past.
class Jwt {
public async encode(id: string) {
const accessToken = await this.signJWT(id, this.ACCESS_TOKEN_LIFE, this.ACCESS_TOKEN_SECRET);
const refreshToken = await this.signJWT(id, this.REFRESH_TOKEN_LIFE, this.REFRESH_TOKEN_SECRET);
return { accessToken, refreshToken };
}
private async signJWT(id: string, expiresAt: string, secret?: string) {
if (!secret) throw new Error('Auth secret missing');
return await new SignJWT({ id })
.setProtectedHeader({ alg: this.ALG })
.setIssuedAt()
.setExpirationTime(expiresAt)
.sign(new TextEncoder().encode(secret));
}
}
Has anyone encountered this problem before and has a solution?
Many thanks