@@ -14,10 +14,9 @@ const sigstore = require('sigstore')
1414const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*'
1515const fullDoc = 'application/json'
1616
17- // Some really old packages have no time field in their packument so we need to
18- // fallback to a time that is before we could have a registry rotate keys. This
19- // is snapped to just before we shipped `npm audit signatures` in 8.14.0.
20- const NO_TIME_CUTOFF_TIME = '2022-07-12T00:00:00.000Z'
17+ // Some really old packages have no time field in their packument so we need a
18+ // cutoff date.
19+ const MISSING_TIME_CUTOFF = '2015-01-01T00:00:00.000Z'
2120
2221const fetch = require ( 'npm-registry-fetch' )
2322
@@ -120,6 +119,13 @@ class RegistryFetcher extends Fetcher {
120119 return this . package
121120 }
122121
122+ // When verifying signatures, we need to fetch the full/uncompressed
123+ // packument to get publish time as this is not included in the
124+ // corgi/compressed packument.
125+ if ( this . opts . verifySignatures ) {
126+ this . fullMetadata = true
127+ }
128+
123129 const packument = await this . packument ( )
124130 let mani = await pickManifest ( packument , this . spec . fetchSpec , {
125131 ...this . opts ,
@@ -184,7 +190,7 @@ class RegistryFetcher extends Fetcher {
184190 ) , { code : 'EMISSINGSIGNATUREKEY' } )
185191 }
186192
187- const publishedTime = Date . parse ( mani . _time || NO_TIME_CUTOFF_TIME )
193+ const publishedTime = Date . parse ( mani . _time || MISSING_TIME_CUTOFF )
188194 const validPublicKey = ! publicKey . expires ||
189195 publishedTime < Date . parse ( publicKey . expires )
190196 if ( ! validPublicKey ) {
0 commit comments