File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -613,14 +613,13 @@ export function _checkCredential({
613
613
}
614
614
// check if `now` is before `issuanceDate` on verification
615
615
if ( mode === 'verify' ) {
616
- let { issuanceDate} = credential ;
617
616
assertDateString ( { credential, prop : 'issuanceDate' } ) ;
618
617
// check if `now` is before `issuanceDate`
619
- issuanceDate = new Date ( issuanceDate ) ;
618
+ const issuanceDate = new Date ( credential . issuanceDate ) ;
620
619
if ( now < issuanceDate ) {
621
620
throw new Error (
622
621
`The current date time (${ now . toISOString ( ) } ) is before the ` +
623
- `"issuanceDate" (${ issuanceDate . toISOString ( ) } ).` ) ;
622
+ `"issuanceDate" (${ credential . issuanceDate } ).` ) ;
624
623
}
625
624
}
626
625
}
@@ -634,7 +633,7 @@ export function _checkCredential({
634
633
if ( now > validUntil ) {
635
634
throw new Error (
636
635
`The current date time (${ now . toISOString ( ) } ) is after ` +
637
- `"validUntil" (${ validUntil . toISOString ( ) } ).` ) ;
636
+ `"validUntil" (${ credential . validUntil } ).` ) ;
638
637
}
639
638
}
640
639
if ( validFrom ) {
@@ -644,7 +643,7 @@ export function _checkCredential({
644
643
if ( now < validFrom ) {
645
644
throw new Error (
646
645
`The current date time (${ now . toISOString ( ) } ) is before ` +
647
- `"validFrom" (${ validFrom . toISOString ( ) } ).` ) ;
646
+ `"validFrom" (${ credential . validFrom } ).` ) ;
648
647
}
649
648
}
650
649
}
Original file line number Diff line number Diff line change @@ -784,7 +784,7 @@ for(const [version, mockCredential] of versionedCredentials) {
784
784
const credential = jsonld . clone ( mockCredential ) ;
785
785
credential . issuer = 'did:example:12345' ;
786
786
credential . issuanceDate = createSkewedTimeStamp ( { skewYear : 1 } ) ;
787
- const now = createSkewedTimeStamp ( { skewYear : 0 } ) ;
787
+ const now = new Date ( ) ;
788
788
let error ;
789
789
try {
790
790
vc . _checkCredential ( { credential, now} ) ;
@@ -794,7 +794,7 @@ for(const [version, mockCredential] of versionedCredentials) {
794
794
should . exist ( error ,
795
795
'Should throw error when "now" is before "issuanceDate"' ) ;
796
796
error . message . should . contain (
797
- `The current date time (${ now } ) is before the ` +
797
+ `The current date time (${ now . toISOString ( ) } ) is before the ` +
798
798
`"issuanceDate" (${ credential . issuanceDate } ).` ) ;
799
799
} ) ;
800
800
}
Original file line number Diff line number Diff line change 9
9
*/
10
10
export function createSkewedTimeStamp ( { date = new Date ( ) , skewYear} ) {
11
11
date . setFullYear ( date . getFullYear ( ) + skewYear ) ;
12
- return date . toISOString ( ) ;
12
+ const isoString = date . toISOString ( ) ;
13
+ return isoString . substr ( 0 , isoString . length - 5 ) + 'Z' ;
13
14
}
You can’t perform that action at this time.
0 commit comments