diff --git a/src/pollux/models/JWTVerifiableCredential.ts b/src/pollux/models/JWTVerifiableCredential.ts index 214e6f694..4a0b3f5a1 100644 --- a/src/pollux/models/JWTVerifiableCredential.ts +++ b/src/pollux/models/JWTVerifiableCredential.ts @@ -320,14 +320,14 @@ export class JWTCredential const exp = this.isCredentialPayload(Object.fromEntries(this.properties)) ? this.properties.get(JWT_VC_PROPS.exp) : this.properties.get(JWT_VP_PROPS.exp); - return exp ? new Date(exp).toISOString() : undefined; + return exp ? new Date(exp * 1000).toISOString() : undefined; } get issuanceDate() { const nbf = this.isCredentialPayload(Object.fromEntries(this.properties)) ? this.properties.get(JWT_VC_PROPS.nbf) : this.properties.get(JWT_VP_PROPS.nbf); - return new Date(nbf).toISOString(); + return new Date(nbf * 1000).toISOString(); } get audience() { diff --git a/tests/pollux/Pollux.test.ts b/tests/pollux/Pollux.test.ts index fafe2f4f2..e2b6ce37e 100644 --- a/tests/pollux/Pollux.test.ts +++ b/tests/pollux/Pollux.test.ts @@ -393,10 +393,10 @@ describe("Pollux", () => { credential.credentialSubject ); expect(jwtCred.expirationDate).to.be.equal( - new Date(jwtPayload[JWTVerifiableCredentialProperties.exp]).toISOString() + new Date(jwtPayload[JWTVerifiableCredentialProperties.exp] * 1000).toISOString() ); expect(jwtCred.issuanceDate).to.be.equal( - new Date(jwtPayload[JWTVerifiableCredentialProperties.nbf]).toISOString() + new Date(jwtPayload[JWTVerifiableCredentialProperties.nbf] * 1000).toISOString() ); expect(jwtCred.type).to.be.deep.equal(credential.type); @@ -428,8 +428,8 @@ describe("Pollux", () => { } ) as JWTCredential; - const issuanceDate = new Date(nbf).toISOString(); - const expirationDate = new Date(exp).toISOString(); + const issuanceDate = new Date(nbf * 1000).toISOString(); + const expirationDate = new Date(exp * 1000).toISOString(); expect(result.issuanceDate).to.equal(issuanceDate); expect(result.expirationDate).to.equal(expirationDate);