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 @@ -612,14 +612,13 @@ export function _checkCredential({
612
612
}
613
613
// check if `now` is before `issuanceDate` on verification
614
614
if ( mode === 'verify' ) {
615
- let { issuanceDate} = credential ;
616
615
assertDateString ( { credential, prop : 'issuanceDate' } ) ;
617
616
// check if `now` is before `issuanceDate`
618
- issuanceDate = new Date ( issuanceDate ) ;
617
+ const issuanceDate = new Date ( credential . issuanceDate ) ;
619
618
if ( now < issuanceDate ) {
620
619
throw new Error (
621
620
`The current date time (${ now . toISOString ( ) } ) is before the ` +
622
- `"issuanceDate" (${ issuanceDate . toISOString ( ) } ).` ) ;
621
+ `"issuanceDate" (${ credential . issuanceDate } ).` ) ;
623
622
}
624
623
}
625
624
}
@@ -633,7 +632,7 @@ export function _checkCredential({
633
632
if ( now > validUntil ) {
634
633
throw new Error (
635
634
`The current date time (${ now . toISOString ( ) } ) is after ` +
636
- `"validUntil" (${ validUntil . toISOString ( ) } ).` ) ;
635
+ `"validUntil" (${ credential . validUntil } ).` ) ;
637
636
}
638
637
}
639
638
if ( validFrom ) {
@@ -643,7 +642,7 @@ export function _checkCredential({
643
642
if ( now < validFrom ) {
644
643
throw new Error (
645
644
`The current date time (${ now . toISOString ( ) } ) is before ` +
646
- `"validFrom" (${ validFrom . toISOString ( ) } ).` ) ;
645
+ `"validFrom" (${ credential . validFrom } ).` ) ;
647
646
}
648
647
}
649
648
}
Original file line number Diff line number Diff line change @@ -851,7 +851,7 @@ for(const [version, mockCredential] of versionedCredentials) {
851
851
const credential = mockCredential ( ) ;
852
852
credential . issuer = 'did:example:12345' ;
853
853
credential . issuanceDate = createSkewedTimeStamp ( { skewYear : 1 } ) ;
854
- const now = createSkewedTimeStamp ( { skewYear : 0 } ) ;
854
+ const now = new Date ( ) ;
855
855
let error ;
856
856
try {
857
857
vc . _checkCredential ( { credential, now} ) ;
@@ -861,7 +861,7 @@ for(const [version, mockCredential] of versionedCredentials) {
861
861
should . exist ( error ,
862
862
'Should throw error when "now" is before "issuanceDate"' ) ;
863
863
error . message . should . contain (
864
- `The current date time (${ now } ) is before the ` +
864
+ `The current date time (${ now . toISOString ( ) } ) is before the ` +
865
865
`"issuanceDate" (${ credential . issuanceDate } ).` ) ;
866
866
} ) ;
867
867
}
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