@@ -46,28 +46,33 @@ class Verifier {
4646 }
4747 // Checks that all of the timestamps in the entity are valid and returns them
4848 verifyTimestamps ( entity ) {
49- let timestampCount = 0 ;
50- const timestamps = entity . timestamps . map ( ( timestamp ) => {
49+ const timestamps = [ ] ;
50+ for ( const timestamp of entity . timestamps ) {
5151 switch ( timestamp . $case ) {
5252 case 'timestamp-authority' :
53- timestampCount ++ ;
54- return ( 0 , timestamp_1 . getTSATimestamp ) ( timestamp . timestamp , entity . signature . signature , this . trustMaterial . timestampAuthorities ) ;
55- case 'transparency-log' :
56- timestampCount ++ ;
57- return ( 0 , timestamp_1 . getTLogTimestamp ) ( timestamp . tlogEntry ) ;
53+ timestamps . push ( ( 0 , timestamp_1 . getTSATimestamp ) ( timestamp . timestamp , entity . signature . signature , this . trustMaterial . timestampAuthorities ) ) ;
54+ break ;
55+ case 'transparency-log' : {
56+ const result = ( 0 , timestamp_1 . getTLogTimestamp ) ( timestamp . tlogEntry ) ;
57+ /* istanbul ignore else */
58+ if ( result ) {
59+ timestamps . push ( result ) ;
60+ }
61+ break ;
62+ }
5863 }
59- } ) ;
64+ }
6065 // Check for duplicate timestamps
6166 if ( containsDupes ( timestamps ) ) {
6267 throw new error_1 . VerificationError ( {
6368 code : 'TIMESTAMP_ERROR' ,
6469 message : 'duplicate timestamp' ,
6570 } ) ;
6671 }
67- if ( timestampCount < this . options . timestampThreshold ) {
72+ if ( timestamps . length < this . options . timestampThreshold ) {
6873 throw new error_1 . VerificationError ( {
6974 code : 'TIMESTAMP_ERROR' ,
70- message : `expected ${ this . options . timestampThreshold } timestamps, got ${ timestampCount } ` ,
75+ message : `expected ${ this . options . timestampThreshold } timestamps, got ${ timestamps . length } ` ,
7176 } ) ;
7277 }
7378 return timestamps . map ( ( t ) => t . timestamp ) ;
@@ -133,6 +138,11 @@ class Verifier {
133138 if ( policy . extensions ) {
134139 ( 0 , policy_1 . verifyExtensions ) ( policy . extensions , identity . extensions ) ;
135140 }
141+ // Check that the OIDs of the signer match the policy
142+ /* istanbul ignore if */
143+ if ( policy . oids ) {
144+ ( 0 , policy_1 . verifyOIDs ) ( policy . oids , identity . oids ) ;
145+ }
136146 }
137147}
138148exports . Verifier = Verifier ;
0 commit comments