Socket
Socket
Sign inDemoInstall

npm-registry-fetch

Package Overview
Dependencies
Maintainers
9
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-registry-fetch - npm Package Compare versions

Comparing version 4.0.2 to 5.0.0

2

auth.js

@@ -10,3 +10,3 @@ 'use strict'

opts = config(opts)
let AUTH = {}
const AUTH = {}
const regKey = registry && registryKey(registry)

@@ -13,0 +13,0 @@ if (opts.forceAuth) {

@@ -5,2 +5,25 @@ # Change Log

<a name="5.0.0"></a>
# [5.0.0](https://github.com/npm/registry-fetch/compare/v4.0.2...v5.0.0) (2019-10-04)
### Bug Fixes
* prefer const in getAuth function ([90ac7b1](https://github.com/npm/registry-fetch/commit/90ac7b1))
* use minizlib instead of core zlib ([e64702e](https://github.com/npm/registry-fetch/commit/e64702e))
### Features
* refactor to use Minipass streams ([bb37f20](https://github.com/npm/registry-fetch/commit/bb37f20))
### BREAKING CHANGES
* this replaces all core streams (except for some
PassThrough streams in a few tests) with Minipass streams, and updates
all deps to the latest and greatest Minipass versions of things.
<a name="4.0.2"></a>

@@ -7,0 +30,0 @@ ## [4.0.2](https://github.com/npm/registry-fetch/compare/v4.0.0...v4.0.2) (2019-10-04)

@@ -6,3 +6,3 @@ 'use strict'

const LRU = require('lru-cache')
const {Response} = require('minipass-fetch')
module.exports = checkResponse

@@ -22,3 +22,3 @@ function checkResponse (method, res, registry, startTime, opts) {

res.body.resume()
res.body = null
return new Response(null, res)
}

@@ -46,13 +46,18 @@ return res

const warnings = {}
res.headers.raw()['warning'].forEach(w => {
const match = w.match(WARNING_REGEXP)
if (match) {
warnings[match[1]] = {
code: match[1],
host: match[2],
message: match[3],
date: new Date(match[4])
// note: headers.raw() will preserve case, so we might have a
// key on the object like 'WaRnInG' if that was used first
for (const [key, value] of Object.entries(res.headers.raw())) {
if (key.toLowerCase() !== 'warning') { continue }
value.forEach(w => {
const match = w.match(WARNING_REGEXP)
if (match) {
warnings[match[1]] = {
code: match[1],
host: match[2],
message: match[3],
date: new Date(match[4])
}
}
}
})
})
}
BAD_HOSTS.set(registry, true)

@@ -59,0 +64,0 @@ if (warnings['199']) {

@@ -66,3 +66,2 @@ 'use strict'

'project-scope': 'projectScope',
'Promise': {default: () => Promise},
'proxy': {},

@@ -69,0 +68,0 @@ 'query': {},

@@ -9,8 +9,8 @@ 'use strict'

const fetch = require('make-fetch-happen')
const JSONStream = require('JSONStream')
const JSONStream = require('minipass-json-stream')
const npa = require('npm-package-arg')
const {PassThrough} = require('stream')
const qs = require('querystring')
const url = require('url')
const zlib = require('zlib')
const zlib = require('minizlib')
const Minipass = require('minipass')

@@ -23,4 +23,6 @@ module.exports = regFetch

opts.registry ||
/* istanbul ignore next: default set in figgy pudding config */
'https://registry.npmjs.org/'
)
uri = url.parse(uri).protocol

@@ -33,2 +35,7 @@ ? uri

}`
const method = opts.method ||
/* istanbul ignore next: default set in figgy pudding config */
'GET'
// through that takes into account the scope, the prefix of `uri`, etc

@@ -38,6 +45,8 @@ const startTime = Date.now()

let body = opts.body
const bodyIsStream = body &&
const bodyIsStream = Minipass.isStream(body)
const bodyIsPromise = body &&
typeof body === 'object' &&
typeof body.pipe === 'function'
if (body && !bodyIsStream && typeof body !== 'string' && !Buffer.isBuffer(body)) {
typeof body.then === 'function'
if (body && !bodyIsStream && !bodyIsPromise && typeof body !== 'string' && !Buffer.isBuffer(body)) {
headers['content-type'] = headers['content-type'] || 'application/json'

@@ -48,14 +57,15 @@ body = JSON.stringify(body)

}
if (opts.gzip) {
headers['content-encoding'] = 'gzip'
if (bodyIsStream) {
const gz = zlib.createGzip()
body.on('error', err => gz.emit('error', err))
const gz = new zlib.Gzip()
body.on('error', /* istanbul ignore next: unlikely and hard to test */
err => gz.emit('error', err))
body = body.pipe(gz)
} else {
body = new opts.Promise((resolve, reject) => {
zlib.gzip(body, (err, gz) => err ? reject(err) : resolve(gz))
})
} else if (!bodyIsPromise) {
body = new zlib.Gzip().end(body).concat()
}
}
if (opts.query) {

@@ -81,3 +91,4 @@ let q = opts.query

}
return opts.Promise.resolve(body).then(body => fetch(uri, {
const doFetch = (body) => fetch(uri, {
agent: opts.agent,

@@ -96,5 +107,4 @@ algorithms: opts.algorithms,

memoize: opts.memoize,
method: opts.method || 'GET',
method: method,
noProxy: opts['no-proxy'] || opts.noproxy,
Promise: opts.Promise,
proxy: opts['https-proxy'] || opts.proxy,

@@ -111,4 +121,6 @@ referer: opts.refer,

}).then(res => checkResponse(
opts.method || 'GET', res, registry, startTime, opts
)))
method, res, registry, startTime, opts
))
return Promise.resolve(body).then(doFetch)
}

@@ -125,9 +137,8 @@

const parser = JSONStream.parse(jsonPath, opts.mapJson)
const pt = parser.pipe(new PassThrough({objectMode: true}))
parser.on('error', err => pt.emit('error', err))
regFetch(uri, opts).then(res => {
res.body.on('error', err => parser.emit('error', err))
res.body.pipe(parser)
}, err => pt.emit('error', err))
return pt
regFetch(uri, opts).then(res =>
res.body.on('error',
/* istanbul ignore next: unlikely and difficult to test */
er => parser.emit('error', er)).pipe(parser)
).catch(er => parser.emit('error', er))
return parser
}

@@ -147,3 +158,5 @@

if (!registry) {
registry = opts.registry || 'https://registry.npmjs.org/'
registry = opts.registry ||
/* istanbul ignore next: default set by figgy pudding config */
'https://registry.npmjs.org/'
}

@@ -150,0 +163,0 @@

{
"name": "npm-registry-fetch",
"version": "4.0.2",
"version": "5.0.0",
"description": "Fetch-based http client for use with npm registry APIs",

@@ -32,7 +32,10 @@ "main": "index.js",

"dependencies": {
"JSONStream": "^1.3.4",
"bluebird": "^3.5.1",
"figgy-pudding": "^3.4.1",
"lru-cache": "^5.1.1",
"make-fetch-happen": "^5.0.0",
"make-fetch-happen": "^6.0.0",
"minipass": "^3.0.0",
"minipass-fetch": "^1.1.2",
"minipass-json-stream": "^1.0.1",
"minizlib": "^2.0.0",
"npm-package-arg": "^6.1.0",

@@ -42,4 +45,3 @@ "safe-buffer": "^5.2.0"

"devDependencies": {
"cacache": "^12.0.0",
"get-stream": "^4.0.0",
"cacache": "^13.0.1",
"mkdirp": "^0.5.1",

@@ -52,3 +54,3 @@ "nock": "^9.4.3",

"standard-version": "^4.4.0",
"tap": "^12.0.1",
"tap": "^14.6.9",
"weallbehave": "^1.2.0",

@@ -55,0 +57,0 @@ "weallcontribute": "^1.0.8"

@@ -1,2 +0,2 @@

# npm-registry-fetch [![npm version](https://img.shields.io/npm/v/npm-registry-fetch.svg)](https://npm.im/npm-registry-fetch) [![license](https://img.shields.io/npm/l/npm-registry-fetch.svg)](https://npm.im/npm-registry-fetch) [![Travis](https://img.shields.io/travis/npm/npm-registry-fetch/latest.svg)](https://travis-ci.org/npm/npm-registry-fetch) [![AppVeyor](https://img.shields.io/appveyor/ci/zkat/npm-registry-fetch/latest.svg)](https://ci.appveyor.com/project/npm/npm-registry-fetch) [![Coverage Status](https://coveralls.io/repos/github/npm/npm-registry-fetch/badge.svg?branch=latest)](https://coveralls.io/github/npm/npm-registry-fetch?branch=latest)
# npm-registry-fetch [![npm version](https://img.shields.io/npm/v/npm-registry-fetch.svg)](https://npm.im/npm-registry-fetch) [![license](https://img.shields.io/npm/l/npm-registry-fetch.svg)](https://npm.im/npm-registry-fetch) [![Travis](https://img.shields.io/travis/npm/npm-registry-fetch/latest.svg)](https://travis-ci.org/npm/npm-registry-fetch) [![AppVeyor](https://img.shields.io/appveyor/ci/npm/npm-registry-fetch/latest.svg)](https://ci.appveyor.com/project/npm/npm-registry-fetch) [![Coverage Status](https://coveralls.io/repos/github/npm/npm-registry-fetch/badge.svg?branch=latest)](https://coveralls.io/github/npm/npm-registry-fetch?branch=latest)

@@ -3,0 +3,0 @@ [`npm-registry-fetch`](https://github.com/npm/npm-registry-fetch) is a Node.js

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