Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libnpmpublish

Package Overview
Dependencies
Maintainers
6
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libnpmpublish - npm Package Compare versions

Comparing version 7.1.4 to 7.2.0

53

lib/publish.js

@@ -45,6 +45,12 @@ const { fixer } = require('normalize-package-data')

const metadata = await buildMetadata(reg, pubManifest, tarballData, spec, opts)
const { metadata, transparencyLogUrl } = await buildMetadata(
reg,
pubManifest,
tarballData,
spec,
opts
)
try {
return await npmFetch(spec.escapedName, {
const res = await npmFetch(spec.escapedName, {
...opts,

@@ -55,2 +61,6 @@ method: 'PUT',

})
if (transparencyLogUrl) {
res.transparencyLogUrl = transparencyLogUrl
}
return res
} catch (err) {

@@ -69,3 +79,3 @@ if (err.code !== 'E409') {

const newMetadata = patchMetadata(current, metadata)
return npmFetch(spec.escapedName, {
const res = await npmFetch(spec.escapedName, {
...opts,

@@ -76,2 +86,7 @@ method: 'PUT',

})
/* istanbul ignore next */
if (transparencyLogUrl) {
res.transparencyLogUrl = transparencyLogUrl
}
return res
}

@@ -145,2 +160,3 @@ }

// Handle case where --provenance flag was set to true
let transparencyLogUrl
if (provenance === true) {

@@ -169,4 +185,19 @@ const subject = {

const visibility =
await npmFetch.json(`${registry}/-/package/${spec.escapedName}/visibility`, opts)
// Some registries (e.g. GH packages) require auth to check visibility,
// and always return 404 when no auth is supplied. In this case we assume
// the package is always private and require `--access public` to publish
// with provenance.
let visibility = { public: false }
if (opts.provenance === true && opts.access !== 'public') {
try {
const res = await npmFetch
.json(`${registry}/-/package/${spec.escapedName}/visibility`, opts)
visibility = res
} catch (err) {
if (err.code !== 'E404') {
throw err
}
}
}
if (!visibility.public && opts.provenance === true && opts.access !== 'public') {

@@ -187,4 +218,7 @@ throw Object.assign(

if (tlogEntry) {
const logUrl = `${TLOG_BASE_URL}?logIndex=${tlogEntry.logIndex}`
log.notice('publish', `Provenance statement published to transparency log: ${logUrl}`)
transparencyLogUrl = `${TLOG_BASE_URL}?logIndex=${tlogEntry.logIndex}`
log.notice(
'publish',
`Provenance statement published to transparency log: ${transparencyLogUrl}`
)
}

@@ -200,3 +234,6 @@

return root
return {
metadata: root,
transparencyLogUrl,
}
}

@@ -203,0 +240,0 @@

2

package.json
{
"name": "libnpmpublish",
"version": "7.1.4",
"version": "7.2.0",
"description": "Programmatic API for the bits behind npm publish and unpublish",

@@ -5,0 +5,0 @@ "author": "GitHub Inc.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc