From 74d09664fbb17da498b5929791597921d8735761 Mon Sep 17 00:00:00 2001 From: James Easter Date: Wed, 9 Oct 2024 18:23:39 -0600 Subject: [PATCH] Update compareTime arguments. --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index c3eb183f..08c98de3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -648,7 +648,7 @@ 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.'); } } @@ -656,7 +656,7 @@ export function _checkCredential({ // 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}).`); @@ -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}).`); @@ -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}).`);