Skip to content

Commit

Permalink
fix: add compliant dates not in ms, but in seconds. (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
elribonazo committed May 7, 2024
1 parent 74ee7a1 commit a3fc2aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/pollux/models/JWTVerifiableCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions tests/pollux/Pollux.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a3fc2aa

Please sign in to comment.