@@ -213,7 +213,7 @@ describe('transformPackument', () => {
213213 expect ( detectPublishSecurityDowngradeForVersion ( infos , '1.0.1' ) ?. trustedVersion ) . toBe ( '1.0.0' )
214214 } )
215215
216- it ( 'prefers provenance trust level when both trustedPublisher and attestations exist' , ( ) => {
216+ it ( 'prefers trustedPublisher trust level when both trustedPublisher and attestations exist' , ( ) => {
217217 const packument = createPackument (
218218 {
219219 '1.0.0' : createTrustedPublisherWithAttestationsVersion ( '1.0.0' ) ,
@@ -230,7 +230,34 @@ describe('transformPackument', () => {
230230
231231 const transformed = transformPackument ( packument , '1.0.1' )
232232
233- expect ( transformed . versions [ '1.0.0' ] ?. trustLevel ) . toBe ( 'provenance' )
233+ expect ( transformed . versions [ '1.0.0' ] ?. trustLevel ) . toBe ( 'trustedPublisher' )
234+ } )
235+
236+ // https://github.com/npmx-dev/npmx.dev/issues/1292
237+ it ( 'does not flag false downgrade when trusted publisher version also has attestations' , ( ) => {
238+ // Trusted publishing automatically generates provenance attestations,
239+ // so a version with both should be classified as trustedPublisher, not provenance.
240+ const packument = createPackument (
241+ {
242+ '7.0.0' : createTrustedPublisherWithAttestationsVersion ( '7.0.0' ) ,
243+ '7.0.1' : createTrustedPublisherWithAttestationsVersion ( '7.0.1' ) ,
244+ } ,
245+ {
246+ 'created' : '2026-01-01T00:00:00.000Z' ,
247+ 'modified' : '2026-01-02T00:00:00.000Z' ,
248+ '7.0.0' : '2026-01-01T00:00:00.000Z' ,
249+ '7.0.1' : '2026-01-02T00:00:00.000Z' ,
250+ } ,
251+ '7.0.1' ,
252+ )
253+
254+ const transformed = transformPackument ( packument , '7.0.1' )
255+ const infos = toVersionInfos ( transformed )
256+
257+ // Both versions should be trustedPublisher — no downgrade
258+ expect ( infos . find ( v => v . version === '7.0.0' ) ?. trustLevel ) . toBe ( 'trustedPublisher' )
259+ expect ( infos . find ( v => v . version === '7.0.1' ) ?. trustLevel ) . toBe ( 'trustedPublisher' )
260+ expect ( detectPublishSecurityDowngradeForVersion ( infos , '7.0.1' ) ) . toBeNull ( )
234261 } )
235262
236263 it ( 'flags non-direct downgrade chain until trust is restored' , ( ) => {
0 commit comments