Skip to content

Commit

Permalink
Update compareTime arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameseaster committed Oct 10, 2024
1 parent 2d4bd57 commit 74d0966
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@ export function _checkCredential({
if(mode === 'verify') {
// check if `now` is after `expirationDate`
const expirationDate = new Date(credential.expirationDate);
if(compareTime({t1: expirationDate, t2: now, maxClockSkew}) > 0) {
if(compareTime({t1: now, t2: expirationDate, maxClockSkew}) > 0) {
throw new Error('Credential has expired.');
}
}
}
// check if `now` is before `issuanceDate` on verification
if(mode === 'verify') {
const issuanceDate = new Date(credential.issuanceDate);
if(compareTime({t1: now, t2: issuanceDate, maxClockSkew}) > 0) {
if(compareTime({t1: issuanceDate, t2: now, maxClockSkew}) > 0) {
throw new Error(
`The current date time (${now.toISOString()}) is before the ` +
`"issuanceDate" (${credential.issuanceDate}).`);
Expand All @@ -670,7 +670,7 @@ export function _checkCredential({
assertDateString({credential, prop: 'validUntil'});
if(mode === 'verify') {
validUntil = new Date(credential.validUntil);
if(compareTime({t1: validUntil, t2: now, maxClockSkew}) > 0) {
if(compareTime({t1: now, t2: validUntil, maxClockSkew}) > 0) {
throw new Error(
`The current date time (${now.toISOString()}) is after ` +
`"validUntil" (${credential.validUntil}).`);
Expand All @@ -682,7 +682,7 @@ export function _checkCredential({
if(mode === 'verify') {
// check if `now` is before `validFrom`
validFrom = new Date(credential.validFrom);
if(compareTime({t1: now, t2: validFrom, maxClockSkew}) > 0) {
if(compareTime({t1: validFrom, t2: now, maxClockSkew}) > 0) {
throw new Error(
`The current date time (${now.toISOString()}) is before ` +
`"validFrom" (${credential.validFrom}).`);
Expand Down

0 comments on commit 74d0966

Please sign in to comment.