@@ -14,10 +14,9 @@ const sigstore = require('sigstore')
14
14
const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*'
15
15
const fullDoc = 'application/json'
16
16
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'
21
20
22
21
const fetch = require ( 'npm-registry-fetch' )
23
22
@@ -120,6 +119,13 @@ class RegistryFetcher extends Fetcher {
120
119
return this . package
121
120
}
122
121
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
+
123
129
const packument = await this . packument ( )
124
130
let mani = await pickManifest ( packument , this . spec . fetchSpec , {
125
131
...this . opts ,
@@ -184,7 +190,7 @@ class RegistryFetcher extends Fetcher {
184
190
) , { code : 'EMISSINGSIGNATUREKEY' } )
185
191
}
186
192
187
- const publishedTime = Date . parse ( mani . _time || NO_TIME_CUTOFF_TIME )
193
+ const publishedTime = Date . parse ( mani . _time || MISSING_TIME_CUTOFF )
188
194
const validPublicKey = ! publicKey . expires ||
189
195
publishedTime < Date . parse ( publicKey . expires )
190
196
if ( ! validPublicKey ) {
0 commit comments