Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update npm-registry-fetch (and pacote and npm-profile) #4326

Merged
merged 4 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/logout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const getAuth = require('npm-registry-fetch/auth.js')
const getAuth = require('npm-registry-fetch/lib/auth.js')
const npmFetch = require('npm-registry-fetch')
const log = require('../utils/log-shim')
const BaseCommand = require('../base-command.js')
Expand Down
5 changes: 5 additions & 0 deletions node_modules/negotiator/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.6.3 / 2022-01-22
==================

* Revert "Lazy-load modules from main entry point"

0.6.2 / 2019-04-29
==================

Expand Down
50 changes: 4 additions & 46 deletions node_modules/negotiator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

'use strict';

/**
* Cached loaded submodules.
* @private
*/

var modules = Object.create(null);
var preferredCharsets = require('./lib/charset')
var preferredEncodings = require('./lib/encoding')
var preferredLanguages = require('./lib/language')
var preferredMediaTypes = require('./lib/mediaType')

/**
* Module exports.
Expand Down Expand Up @@ -43,7 +41,6 @@ Negotiator.prototype.charset = function charset(available) {
};

Negotiator.prototype.charsets = function charsets(available) {
var preferredCharsets = loadModule('charset').preferredCharsets;
return preferredCharsets(this.request.headers['accept-charset'], available);
};

Expand All @@ -53,7 +50,6 @@ Negotiator.prototype.encoding = function encoding(available) {
};

Negotiator.prototype.encodings = function encodings(available) {
var preferredEncodings = loadModule('encoding').preferredEncodings;
return preferredEncodings(this.request.headers['accept-encoding'], available);
};

Expand All @@ -63,7 +59,6 @@ Negotiator.prototype.language = function language(available) {
};

Negotiator.prototype.languages = function languages(available) {
var preferredLanguages = loadModule('language').preferredLanguages;
return preferredLanguages(this.request.headers['accept-language'], available);
};

Expand All @@ -73,7 +68,6 @@ Negotiator.prototype.mediaType = function mediaType(available) {
};

Negotiator.prototype.mediaTypes = function mediaTypes(available) {
var preferredMediaTypes = loadModule('mediaType').preferredMediaTypes;
return preferredMediaTypes(this.request.headers.accept, available);
};

Expand All @@ -86,39 +80,3 @@ Negotiator.prototype.preferredLanguage = Negotiator.prototype.language;
Negotiator.prototype.preferredLanguages = Negotiator.prototype.languages;
Negotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType;
Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes;

/**
* Load the given module.
* @private
*/

function loadModule(moduleName) {
var module = modules[moduleName];

if (module !== undefined) {
return module;
}

// This uses a switch for static require analysis
switch (moduleName) {
case 'charset':
module = require('./lib/charset');
break;
case 'encoding':
module = require('./lib/encoding');
break;
case 'language':
module = require('./lib/language');
break;
case 'mediaType':
module = require('./lib/mediaType');
break;
default:
throw new Error('Cannot find module \'' + moduleName + '\'');
}

// Store to prevent invoking require()
modules[moduleName] = module;

return module;
}
6 changes: 3 additions & 3 deletions node_modules/negotiator/lib/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function parseLanguage(str, i) {
var match = simpleLanguageRegExp.exec(str);
if (!match) return null;

var prefix = match[1],
suffix = match[2],
full = prefix;
var prefix = match[1]
var suffix = match[2]
var full = prefix

if (suffix) full += "-" + suffix;

Expand Down
16 changes: 8 additions & 8 deletions node_modules/negotiator/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "negotiator",
"description": "HTTP content negotiation",
"version": "0.6.2",
"version": "0.6.3",
"contributors": [
"Douglas Christopher Wilson <doug@somethingdoug.com>",
"Federico Romero <federico.romero@outboxlabs.com>",
Expand All @@ -18,10 +18,10 @@
],
"repository": "jshttp/negotiator",
"devDependencies": {
"eslint": "5.16.0",
"eslint-plugin-markdown": "1.0.0",
"mocha": "6.1.4",
"nyc": "14.0.0"
"eslint": "7.32.0",
"eslint-plugin-markdown": "2.2.1",
"mocha": "9.1.3",
"nyc": "15.1.0"
},
"files": [
"lib/",
Expand All @@ -34,9 +34,9 @@
"node": ">= 0.6"
},
"scripts": {
"lint": "eslint --plugin markdown --ext js,md .",
"lint": "eslint .",
"test": "mocha --reporter spec --check-leaks --bail test/",
"test-cov": "nyc --reporter=html --reporter=text npm test",
"test-travis": "nyc --reporter=text npm test"
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}
15 changes: 0 additions & 15 deletions node_modules/npm-profile/LICENSE

This file was deleted.

20 changes: 20 additions & 0 deletions node_modules/npm-profile/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->

ISC License

Copyright npm, Inc.

Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby
granted, provided that the above copyright notice and this
permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const fetch = require('npm-registry-fetch')
const { HttpErrorBase } = require('npm-registry-fetch/errors.js')
const { HttpErrorBase } = require('npm-registry-fetch/lib/errors')
const os = require('os')
const { URL } = require('url')

Expand Down Expand Up @@ -57,7 +57,7 @@ const webAuth = (opener, opts, body) => {
return fetch(target, {
...opts,
method: 'POST',
body
body,
}).then(res => {
return Promise.all([res, res.json()])
}).then(([res, content]) => {
Expand All @@ -76,7 +76,7 @@ const webAuth = (opener, opts, body) => {
if ((er.statusCode >= 400 && er.statusCode <= 499) || er.statusCode === 500) {
throw new WebLoginNotSupported('POST', {
status: er.statusCode,
headers: { raw: () => er.headers }
headers: { raw: () => er.headers },
}, er.body)
} else {
throw er
Expand Down Expand Up @@ -115,19 +115,19 @@ const adduserCouch = (username, email, password, opts = {}) => {
email: email,
type: 'user',
roles: [],
date: new Date().toISOString()
date: new Date().toISOString(),
}
const logObj = {
...body,
password: 'XXXXX'
password: 'XXXXX',
}
process.emit('log', 'verbose', 'adduser', 'before first PUT', logObj)

const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username)
return fetch.json(target, {
...opts,
method: 'PUT',
body
body,
}).then(result => {
result.username = username
return result
Expand All @@ -141,28 +141,30 @@ const loginCouch = (username, password, opts = {}) => {
password: password,
type: 'user',
roles: [],
date: new Date().toISOString()
date: new Date().toISOString(),
}
const logObj = {
...body,
password: 'XXXXX'
password: 'XXXXX',
}
process.emit('log', 'verbose', 'login', 'before first PUT', logObj)

const target = '-/user/org.couchdb.user:' + encodeURIComponent(username)
return fetch.json(target, {
...opts,
method: 'PUT',
body
body,
}).catch(err => {
if (err.code === 'E400') {
err.message = `There is no user with the username "${username}".`
throw err
}
if (err.code !== 'E409') throw err
if (err.code !== 'E409') {
throw err
}
return fetch.json(target, {
...opts,
query: { write: true }
query: { write: true },
}).then(result => {
Object.keys(result).forEach(k => {
if (!body[k] || k === 'roles') {
Expand All @@ -177,8 +179,8 @@ const loginCouch = (username, password, opts = {}) => {
forceAuth: {
username,
password: Buffer.from(password, 'utf8').toString('base64'),
otp
}
otp,
},
})
})
}).then(result => {
Expand All @@ -192,12 +194,14 @@ const get = (opts = {}) => fetch.json('/-/npm/v1/user', opts)
const set = (profile, opts = {}) => {
Object.keys(profile).forEach(key => {
// profile keys can't be empty strings, but they CAN be null
if (profile[key] === '') profile[key] = null
if (profile[key] === '') {
profile[key] = null
}
})
return fetch.json('/-/npm/v1/user', {
...opts,
method: 'POST',
body: profile
body: profile,
})
}

Expand All @@ -220,7 +224,7 @@ const removeToken = (tokenKey, opts = {}) => {
return fetch(target, {
...opts,
method: 'DELETE',
ignoreBody: true
ignoreBody: true,
}).then(() => null)
}

Expand All @@ -231,8 +235,8 @@ const createToken = (password, readonly, cidrs, opts = {}) => {
body: {
password: password,
readonly: readonly,
cidr_whitelist: cidrs
}
cidr_whitelist: cidrs,
},
})
}

Expand Down Expand Up @@ -267,5 +271,5 @@ module.exports = {
set,
listTokens,
removeToken,
createToken
createToken,
}
30 changes: 18 additions & 12 deletions node_modules/npm-profile/package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
{
"name": "npm-profile",
"version": "5.0.4",
"version": "6.0.0",
"description": "Library for updating an npmjs.com profile",
"keywords": [],
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org/)",
"author": "GitHub Inc.",
"license": "ISC",
"dependencies": {
"npm-registry-fetch": "^11.0.0"
"npm-registry-fetch": "^12.0.0"
},
"main": "index.js",
"main": "./lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/npm-profile.git"
},
"files": [
"index.js"
"bin",
"lib"
],
"devDependencies": {
"nock": "^12.0.1",
"require-inject": "^1.4.4",
"standard": "^14.3.1",
"tap": "^14.10.6"
"@npmcli/template-oss": "^2.5.1",
"nock": "^13.2.1",
"tap": "^15.1.5"
},
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"posttest": "standard index.js",
"posttest": "npm run lint",
"test": "tap",
"snap": "tap"
"snap": "tap",
"lint": "eslint '**/*.js'",
"postlint": "npm-template-check",
"lintfix": "npm run lint -- --fix"
},
"tap": {
"check-coverage": true
},
"engines": {
"node": ">=10"
"node": "^12.13.0 || ^14.15.0 || >=16"
},
"templateOSS": {
"version": "2.5.1"
}
}
Loading