pacote 21.3.1 → 21.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -160,6 +160,7 @@ Options object is cloned, and mutated along the way to add integrity, resolved,
160
160
  Possible values and defaults are the same as `allowGit`
161
161
  * `allowDirectory` Whether or not to allow data to be fetched from directory specs.
162
162
  Possible values and defaults are the same as `allowGit`
163
+ * `allowRegistry` Whether or not to allow data to be fetched from registry specs. This includes `version`, `range`, `tag`, and `alias`.
163
164
  * `_isRoot` Whether or not the package being fetched is in a root context.
164
165
  Defaults to `false`,
165
166
  For `npm` itself this means a package that is defined in the local project or workspace package.json, or a package that is being fetched for another command like `npm view`. This informs the `allowX` options to let them know the context of the current request.
package/lib/fetcher.js CHANGED
@@ -10,7 +10,7 @@ const cacache = require('cacache')
10
10
  const fsm = require('fs-minipass')
11
11
  const getContents = require('@npmcli/installed-package-contents')
12
12
  const npa = require('npm-package-arg')
13
- const retry = require('promise-retry')
13
+ const { promiseRetry } = require('@gar/promise-retry')
14
14
  const ssri = require('ssri')
15
15
  const tar = require('tar')
16
16
  const { Minipass } = require('minipass')
@@ -319,7 +319,7 @@ class FetcherBase {
319
319
  this.spec
320
320
  }. Extracting by manifest.`)
321
321
  }
322
- return this.resolve().then(() => retry(tryAgain =>
322
+ return this.resolve().then(() => promiseRetry(tryAgain =>
323
323
  streamHandler(this.#istream(this[_.tarballFromResolved]()))
324
324
  .catch(streamErr => {
325
325
  // Most likely data integrity. A cache ENOENT error is unlikely
@@ -502,6 +502,7 @@ FetcherBase.get = (rawSpec, opts = {}) => {
502
502
  case 'range':
503
503
  case 'tag':
504
504
  case 'alias':
505
+ canUse({ allow: opts.allowRegistry, isRoot: opts._isRoot, allowType: 'registry', spec })
505
506
  return new RegistryFetcher(spec.subSpec || spec, opts)
506
507
 
507
508
  case 'file':
package/lib/registry.js CHANGED
@@ -229,7 +229,7 @@ class RegistryFetcher extends Fetcher {
229
229
  if (this.opts.verifyAttestations) {
230
230
  // Always fetch attestations from the current registry host
231
231
  const attestationsPath = new URL(dist.attestations.url).pathname
232
- const attestationsUrl = removeTrailingSlashes(this.registry) + attestationsPath
232
+ const attestationsUrl = new URL(attestationsPath, this.registry).href
233
233
  const res = await fetch(attestationsUrl, {
234
234
  ...this.opts,
235
235
  // disable integrity check for attestations json payload, we check the
@@ -256,7 +256,10 @@ class RegistryFetcher extends Fetcher {
256
256
  const attestationKeyIds = bundles.map((b) => b.keyid).filter((k) => !!k)
257
257
  const attestationRegistryKeys = (this.registryKeys || [])
258
258
  .filter(key => attestationKeyIds.includes(key.keyid))
259
- if (!attestationRegistryKeys.length) {
259
+ // Only require registry keys when there are keyed attestations.
260
+ // Keyless (Sigstore/Fulcio) attestations embed their signing
261
+ // certificate in the bundle and don't need registry keys.
262
+ if (attestationKeyIds.length > 0 && !attestationRegistryKeys.length) {
260
263
  throw Object.assign(new Error(
261
264
  `${mani._id} has attestations but no corresponding public key(s) can be found`
262
265
  ), { code: 'EMISSINGSIGNATUREKEY' })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacote",
3
- "version": "21.3.1",
3
+ "version": "21.4.0",
4
4
  "description": "JavaScript package downloader",
5
5
  "author": "GitHub Inc.",
6
6
  "bin": {
@@ -46,6 +46,7 @@
46
46
  "git"
47
47
  ],
48
48
  "dependencies": {
49
+ "@gar/promise-retry": "^1.0.0",
49
50
  "@npmcli/git": "^7.0.0",
50
51
  "@npmcli/installed-package-contents": "^4.0.0",
51
52
  "@npmcli/package-json": "^7.0.0",
@@ -59,7 +60,6 @@
59
60
  "npm-pick-manifest": "^11.0.1",
60
61
  "npm-registry-fetch": "^19.0.0",
61
62
  "proc-log": "^6.0.0",
62
- "promise-retry": "^2.0.1",
63
63
  "sigstore": "^4.0.0",
64
64
  "ssri": "^13.0.0",
65
65
  "tar": "^7.4.3"