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 Apr 30, 2024
1 parent 277d9c3 commit 0af6e30
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

2 comments on commit 0af6e30

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 72%
72.77% (2072/2847) 61.53% (947/1539) 79.05% (570/721)

JUnit

Tests Skipped Failures Errors Time
434 6 💤 0 ❌ 0 🔥 1m 5s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 72%
72.77% (2072/2847) 61.53% (947/1539) 79.05% (570/721)

JUnit

Tests Skipped Failures Errors Time
434 6 💤 0 ❌ 0 🔥 1m 5s ⏱️

Please sign in to comment.