summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/lib
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib')
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/access.js168
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/adduser.js128
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/attempt.js20
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/authify.js26
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/deprecate.js42
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/dist-tags/add.js43
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/dist-tags/fetch.js37
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/dist-tags/rm.js38
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/dist-tags/set.js39
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/dist-tags/update.js39
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/fetch.js85
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/get.js22
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/initialize.js91
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/logout.js23
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/org.js62
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/ping.js21
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/publish.js194
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/request.js336
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js19
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/star.js51
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/stars.js18
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/tag.js23
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/team.js105
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/unpublish.js120
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/whoami.js21
25 files changed, 0 insertions, 1771 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/access.js b/deps/npm/node_modules/npm-registry-client/lib/access.js
deleted file mode 100644
index caa80b1219..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/access.js
+++ /dev/null
@@ -1,168 +0,0 @@
-module.exports = access
-
-var assert = require('assert')
-var url = require('url')
-var npa = require('npm-package-arg')
-var subcommands = {}
-
-function access (sub, uri, params, cb) {
- accessAssertions(sub, uri, params, cb)
- return subcommands[sub].call(this, uri, params, cb)
-}
-
-subcommands.public = function (uri, params, cb) {
- return setAccess.call(this, 'public', uri, params, cb)
-}
-subcommands.restricted = function (uri, params, cb) {
- return setAccess.call(this, 'restricted', uri, params, cb)
-}
-subcommands['2fa-required'] = function (uri, params, cb) {
- return setRequires2fa.call(this, true, uri, params, cb)
-}
-subcommands['2fa-not-required'] = function (uri, params, cb) {
- return setRequires2fa.call(this, false, uri, params, cb)
-}
-
-function setAccess (access, uri, params, cb) {
- return this.request(apiUri(uri, 'package', params.package, 'access'), {
- method: 'POST',
- auth: params.auth,
- body: JSON.stringify({ access: access })
- }, cb)
-}
-
-function setRequires2fa (requires2fa, uri, params, cb) {
- return this.request(apiUri(uri, 'package', params.package, 'access'), {
- method: 'POST',
- auth: params.auth,
- body: JSON.stringify({ publish_requires_tfa: requires2fa })
- }, cb)
-}
-
-subcommands.grant = function (uri, params, cb) {
- var reqUri = apiUri(uri, 'team', params.scope, params.team, 'package')
- return this.request(reqUri, {
- method: 'PUT',
- auth: params.auth,
- body: JSON.stringify({
- permissions: params.permissions,
- package: params.package
- })
- }, cb)
-}
-
-subcommands.revoke = function (uri, params, cb) {
- var reqUri = apiUri(uri, 'team', params.scope, params.team, 'package')
- return this.request(reqUri, {
- method: 'DELETE',
- auth: params.auth,
- body: JSON.stringify({
- package: params.package
- })
- }, cb)
-}
-
-subcommands['ls-packages'] = function (uri, params, cb, type) {
- type = type || (params.team ? 'team' : 'org')
- var client = this
- var uriParams = '?format=cli'
- var reqUri = apiUri(uri, type, params.scope, params.team, 'package')
- return client.request(reqUri + uriParams, {
- method: 'GET',
- auth: params.auth
- }, function (err, perms) {
- if (err && err.statusCode === 404 && type === 'org') {
- subcommands['ls-packages'].call(client, uri, params, cb, 'user')
- } else {
- cb(err, perms && translatePermissions(perms))
- }
- })
-}
-
-subcommands['ls-collaborators'] = function (uri, params, cb) {
- var uriParams = '?format=cli'
- if (params.user) {
- uriParams += ('&user=' + encodeURIComponent(params.user))
- }
- var reqUri = apiUri(uri, 'package', params.package, 'collaborators')
- return this.request(reqUri + uriParams, {
- method: 'GET',
- auth: params.auth
- }, function (err, perms) {
- cb(err, perms && translatePermissions(perms))
- })
-}
-
-subcommands.edit = function () {
- throw new Error('edit subcommand is not implemented yet')
-}
-
-function apiUri (registryUri) {
- var path = Array.prototype.slice.call(arguments, 1)
- .filter(function (x) { return x })
- .map(encodeURIComponent)
- .join('/')
- return url.resolve(registryUri, '-/' + path)
-}
-
-function accessAssertions (subcommand, uri, params, cb) {
- assert(subcommands.hasOwnProperty(subcommand),
- 'access subcommand must be one of ' +
- Object.keys(subcommands).join(', '))
- typeChecks({
- 'uri': [uri, 'string'],
- 'params': [params, 'object'],
- 'auth': [params.auth, 'object'],
- 'callback': [cb, 'function']
- })
- if (contains([
- 'public', 'restricted'
- ], subcommand)) {
- typeChecks({ 'package': [params.package, 'string'] })
- assert(!!npa(params.package).scope,
- 'access commands are only accessible for scoped packages')
- }
- if (contains(['grant', 'revoke', 'ls-packages'], subcommand)) {
- typeChecks({ 'scope': [params.scope, 'string'] })
- }
- if (contains(['grant', 'revoke'], subcommand)) {
- typeChecks({ 'team': [params.team, 'string'] })
- }
- if (subcommand === 'grant') {
- typeChecks({ 'permissions': [params.permissions, 'string'] })
- assert(params.permissions === 'read-only' ||
- params.permissions === 'read-write',
- 'permissions must be either read-only or read-write')
- }
-}
-
-function typeChecks (specs) {
- Object.keys(specs).forEach(function (key) {
- var checks = specs[key]
- /* eslint valid-typeof:0 */
- assert(typeof checks[0] === checks[1],
- key + ' is required and must be of type ' + checks[1])
- })
-}
-
-function contains (arr, item) {
- return arr.indexOf(item) !== -1
-}
-
-function translatePermissions (perms) {
- var newPerms = {}
- for (var key in perms) {
- if (perms.hasOwnProperty(key)) {
- if (perms[key] === 'read') {
- newPerms[key] = 'read-only'
- } else if (perms[key] === 'write') {
- newPerms[key] = 'read-write'
- } else {
- // This shouldn't happen, but let's not break things
- // if the API starts returning different things.
- newPerms[key] = perms[key]
- }
- }
- }
- return newPerms
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/adduser.js b/deps/npm/node_modules/npm-registry-client/lib/adduser.js
deleted file mode 100644
index a31d5b0333..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/adduser.js
+++ /dev/null
@@ -1,128 +0,0 @@
-module.exports = adduser
-
-var url = require('url')
-var assert = require('assert')
-
-function adduser (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to adduser')
- assert(
- params && typeof params === 'object',
- 'must pass params to adduser'
- )
- assert(typeof cb === 'function', 'must pass callback to adduser')
-
- assert(params.auth && typeof params.auth, 'must pass auth to adduser')
- var auth = params.auth
- assert(typeof auth.username === 'string', 'must include username in auth')
- assert(typeof auth.password === 'string', 'must include password in auth')
- assert(typeof auth.email === 'string', 'must include email in auth')
-
- // normalize registry URL
- if (uri.slice(-1) !== '/') uri += '/'
-
- var username = auth.username.trim()
- var password = auth.password.trim()
- var email = auth.email.trim()
-
- // validation
- if (!username) return cb(new Error('No username supplied.'))
- if (!password) return cb(new Error('No password supplied.'))
- if (!email) return cb(new Error('No email address supplied.'))
- if (!email.match(/^[^@]+@[^.]+\.[^.]+/)) {
- return cb(new Error('Please use a real email address.'))
- }
-
- var userobj = {
- _id: 'org.couchdb.user:' + username,
- name: username,
- password: password,
- email: email,
- type: 'user',
- roles: [],
- date: new Date().toISOString()
- }
-
- var token = this.config.couchToken
- if (this.couchLogin) this.couchLogin.token = null
-
- cb = done.call(this, token, cb)
-
- var logObj = Object.keys(userobj).map(function (k) {
- if (k === 'password') return [k, 'XXXXX']
- return [k, userobj[k]]
- }).reduce(function (s, kv) {
- s[kv[0]] = kv[1]
- return s
- }, {})
-
- this.log.verbose('adduser', 'before first PUT', logObj)
-
- var client = this
-
- uri = url.resolve(uri, '-/user/org.couchdb.user:' + encodeURIComponent(username))
- var options = {
- method: 'PUT',
- body: userobj,
- auth: auth
- }
- this.request(
- uri,
- Object.assign({}, options),
- function (error, data, json, response) {
- if (!error || !response || response.statusCode !== 409) {
- return cb(error, data, json, response)
- }
-
- client.log.verbose('adduser', 'update existing user')
- return client.request(
- uri + '?write=true',
- { auth: auth },
- function (er, data, json, response) {
- if (er || data.error) {
- return cb(er, data, json, response)
- }
- Object.keys(data).forEach(function (k) {
- if (!userobj[k] || k === 'roles') {
- userobj[k] = data[k]
- }
- })
- client.log.verbose('adduser', 'userobj', logObj)
- client.request(uri + '/-rev/' + userobj._rev, options, cb)
- }
- )
- }
- )
-
- function done (token, cb) {
- return function (error, data, json, response) {
- if (!error && (!response || response.statusCode === 201)) {
- return cb(error, data, json, response)
- }
-
- // there was some kind of error, reinstate previous auth/token/etc.
- if (client.couchLogin) {
- client.couchLogin.token = token
- if (client.couchLogin.tokenSet) {
- client.couchLogin.tokenSet(token)
- }
- }
-
- client.log.verbose('adduser', 'back', [error, data, json])
- if (!error) {
- error = new Error(
- ((response && response.statusCode) || '') + ' ' +
- 'Could not create user\n' + JSON.stringify(data)
- )
- }
-
- if (response && (response.statusCode === 401 || response.statusCode === 403)) {
- client.log.warn('adduser', 'Incorrect username or password\n' +
- 'You can reset your account by visiting:\n' +
- '\n' +
- ' https://npmjs.org/forgot\n')
- }
-
- return cb(error)
- }
- }
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/attempt.js b/deps/npm/node_modules/npm-registry-client/lib/attempt.js
deleted file mode 100644
index d41bbc4fae..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/attempt.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var retry = require('retry')
-
-module.exports = attempt
-
-function attempt (cb) {
- // Tuned to spread 3 attempts over about a minute.
- // See formula at <https://github.com/tim-kos/node-retry>.
- var operation = retry.operation(this.config.retry)
-
- var client = this
- operation.attempt(function (currentAttempt) {
- client.log.info(
- 'attempt',
- 'registry request try #' + currentAttempt +
- ' at ' + (new Date()).toLocaleTimeString()
- )
-
- cb(operation)
- })
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/authify.js b/deps/npm/node_modules/npm-registry-client/lib/authify.js
deleted file mode 100644
index 9b38a30a92..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/authify.js
+++ /dev/null
@@ -1,26 +0,0 @@
-module.exports = authify
-
-function authify (authed, parsed, headers, credentials) {
- if (credentials && credentials.otp) {
- this.log.verbose('request', 'passing along npm otp')
- headers['npm-otp'] = credentials.otp
- }
- if (credentials && credentials.token) {
- this.log.verbose('request', 'using bearer token for auth')
- headers.authorization = 'Bearer ' + credentials.token
-
- return null
- }
-
- if (authed) {
- if (credentials && credentials.username && credentials.password) {
- var username = encodeURIComponent(credentials.username)
- var password = encodeURIComponent(credentials.password)
- parsed.auth = username + ':' + password
- } else {
- return new Error(
- 'This request requires auth credentials. Run `npm login` and repeat the request.'
- )
- }
- }
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/deprecate.js b/deps/npm/node_modules/npm-registry-client/lib/deprecate.js
deleted file mode 100644
index 5ff3a8891f..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/deprecate.js
+++ /dev/null
@@ -1,42 +0,0 @@
-module.exports = deprecate
-
-var assert = require('assert')
-var semver = require('semver')
-
-function deprecate (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to deprecate')
- assert(params && typeof params === 'object', 'must pass params to deprecate')
- assert(typeof cb === 'function', 'must pass callback to deprecate')
-
- assert(typeof params.version === 'string', 'must pass version to deprecate')
- assert(typeof params.message === 'string', 'must pass message to deprecate')
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to deprecate'
- )
-
- var version = params.version
- var message = params.message
- var auth = params.auth
-
- if (semver.validRange(version) === null) {
- return cb(new Error('invalid version range: ' + version))
- }
-
- this.get(uri + '?write=true', { auth: auth }, function (er, data) {
- if (er) return cb(er)
- // filter all the versions that match
- Object.keys(data.versions).filter(function (v) {
- return semver.satisfies(v, version)
- }).forEach(function (v) {
- data.versions[v].deprecated = message
- })
- // now update the doc on the registry
- var options = {
- method: 'PUT',
- body: data,
- auth: auth
- }
- this.request(uri, options, cb)
- }.bind(this))
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/add.js b/deps/npm/node_modules/npm-registry-client/lib/dist-tags/add.js
deleted file mode 100644
index 924199ad1e..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/add.js
+++ /dev/null
@@ -1,43 +0,0 @@
-module.exports = add
-
-var assert = require('assert')
-var url = require('url')
-
-var npa = require('npm-package-arg')
-
-function add (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to distTags.add')
- assert(
- params && typeof params === 'object',
- 'must pass params to distTags.add'
- )
- assert(typeof cb === 'function', 'muss pass callback to distTags.add')
-
- assert(
- typeof params.package === 'string',
- 'must pass package name to distTags.add'
- )
- assert(
- typeof params.distTag === 'string',
- 'must pass package distTag name to distTags.add'
- )
- assert(
- typeof params.version === 'string',
- 'must pass version to be mapped to distTag to distTags.add'
- )
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to distTags.add'
- )
-
- var p = npa(params.package)
- var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
- var rest = '-/package/' + pkg + '/dist-tags/' + params.distTag
-
- var options = {
- method: 'PUT',
- body: JSON.stringify(params.version),
- auth: params.auth
- }
- this.request(url.resolve(uri, rest), options, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/fetch.js b/deps/npm/node_modules/npm-registry-client/lib/dist-tags/fetch.js
deleted file mode 100644
index 69a126d1f4..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/fetch.js
+++ /dev/null
@@ -1,37 +0,0 @@
-module.exports = fetch
-
-var assert = require('assert')
-var url = require('url')
-
-var npa = require('npm-package-arg')
-
-function fetch (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to distTags.fetch')
- assert(
- params && typeof params === 'object',
- 'must pass params to distTags.fetch'
- )
- assert(typeof cb === 'function', 'must pass callback to distTags.fetch')
-
- assert(
- typeof params.package === 'string',
- 'must pass package name to distTags.fetch'
- )
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to distTags.fetch'
- )
-
- var p = npa(params.package)
- var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
- var rest = '-/package/' + pkg + '/dist-tags'
-
- var options = {
- method: 'GET',
- auth: params.auth
- }
- this.request(url.resolve(uri, rest), options, function (er, data) {
- if (data && typeof data === 'object') delete data._etag
- cb(er, data)
- })
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/rm.js b/deps/npm/node_modules/npm-registry-client/lib/dist-tags/rm.js
deleted file mode 100644
index d2bdda05da..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/rm.js
+++ /dev/null
@@ -1,38 +0,0 @@
-module.exports = rm
-
-var assert = require('assert')
-var url = require('url')
-
-var npa = require('npm-package-arg')
-
-function rm (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to distTags.rm')
- assert(
- params && typeof params === 'object',
- 'must pass params to distTags.rm'
- )
- assert(typeof cb === 'function', 'muss pass callback to distTags.rm')
-
- assert(
- typeof params.package === 'string',
- 'must pass package name to distTags.rm'
- )
- assert(
- typeof params.distTag === 'string',
- 'must pass package distTag name to distTags.rm'
- )
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to distTags.rm'
- )
-
- var p = npa(params.package)
- var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
- var rest = '-/package/' + pkg + '/dist-tags/' + params.distTag
-
- var options = {
- method: 'DELETE',
- auth: params.auth
- }
- this.request(url.resolve(uri, rest), options, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/set.js b/deps/npm/node_modules/npm-registry-client/lib/dist-tags/set.js
deleted file mode 100644
index 7af351d635..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/set.js
+++ /dev/null
@@ -1,39 +0,0 @@
-module.exports = set
-
-var assert = require('assert')
-var url = require('url')
-
-var npa = require('npm-package-arg')
-
-function set (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to distTags.set')
- assert(
- params && typeof params === 'object',
- 'must pass params to distTags.set'
- )
- assert(typeof cb === 'function', 'muss pass callback to distTags.set')
-
- assert(
- typeof params.package === 'string',
- 'must pass package name to distTags.set'
- )
- assert(
- params.distTags && typeof params.distTags === 'object',
- 'must pass distTags map to distTags.set'
- )
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to distTags.set'
- )
-
- var p = npa(params.package)
- var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
- var rest = '-/package/' + pkg + '/dist-tags'
-
- var options = {
- method: 'PUT',
- body: JSON.stringify(params.distTags),
- auth: params.auth
- }
- this.request(url.resolve(uri, rest), options, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/update.js b/deps/npm/node_modules/npm-registry-client/lib/dist-tags/update.js
deleted file mode 100644
index 07ec3e5e75..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/dist-tags/update.js
+++ /dev/null
@@ -1,39 +0,0 @@
-module.exports = update
-
-var assert = require('assert')
-var url = require('url')
-
-var npa = require('npm-package-arg')
-
-function update (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to distTags.update')
- assert(
- params && typeof params === 'object',
- 'must pass params to distTags.update'
- )
- assert(typeof cb === 'function', 'muss pass callback to distTags.update')
-
- assert(
- typeof params.package === 'string',
- 'must pass package name to distTags.update'
- )
- assert(
- params.distTags && typeof params.distTags === 'object',
- 'must pass distTags map to distTags.update'
- )
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to distTags.update'
- )
-
- var p = npa(params.package)
- var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
- var rest = '-/package/' + pkg + '/dist-tags'
-
- var options = {
- method: 'POST',
- body: JSON.stringify(params.distTags),
- auth: params.auth
- }
- this.request(url.resolve(uri, rest), options, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/fetch.js b/deps/npm/node_modules/npm-registry-client/lib/fetch.js
deleted file mode 100644
index 5ab8587780..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/fetch.js
+++ /dev/null
@@ -1,85 +0,0 @@
-var assert = require('assert')
-var url = require('url')
-
-var request = require('request')
-var once = require('once')
-
-module.exports = fetch
-
-function fetch (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass uri to request')
- assert(params && typeof params === 'object', 'must pass params to request')
- assert(typeof cb === 'function', 'must pass callback to request')
-
- cb = once(cb)
-
- var client = this
- this.attempt(function (operation) {
- makeRequest.call(client, uri, params, function (er, req) {
- if (er) return cb(er)
-
- req.once('error', retryOnError)
-
- function retryOnError (er) {
- if (operation.retry(er)) {
- client.log.info('retry', 'will retry, error on last attempt: ' + er)
- } else {
- cb(er)
- }
- }
-
- req.on('response', function (res) {
- client.log.http('fetch', '' + res.statusCode, uri)
- req.removeListener('error', retryOnError)
-
- var er
- var statusCode = res && res.statusCode
- if (statusCode === 200) {
- res.resume()
-
- req.once('error', function (er) {
- res.emit('error', er)
- })
-
- return cb(null, res)
- // Only retry on 408, 5xx or no `response`.
- } else if (statusCode === 408) {
- er = new Error('request timed out')
- } else if (statusCode >= 500) {
- er = new Error('server error ' + statusCode)
- }
-
- if (er && operation.retry(er)) {
- client.log.info('retry', 'will retry, error on last attempt: ' + er)
- } else {
- cb(new Error('fetch failed with status code ' + statusCode))
- }
- })
- })
- })
-}
-
-function makeRequest (remote, params, cb) {
- var parsed = url.parse(remote)
- this.log.http('fetch', 'GET', parsed.href)
-
- var headers = params.headers || {}
- var er = this.authify(
- params.auth && params.auth.alwaysAuth,
- parsed,
- headers,
- params.auth
- )
- if (er) return cb(er)
-
- var opts = this.initialize(
- parsed,
- 'GET',
- 'application/x-tar, application/vnd.github+json; q=0.1',
- headers
- )
- // always want to follow redirects for fetch
- opts.followRedirect = true
-
- cb(null, request(opts))
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/get.js b/deps/npm/node_modules/npm-registry-client/lib/get.js
deleted file mode 100644
index ab0eae10f0..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/get.js
+++ /dev/null
@@ -1,22 +0,0 @@
-module.exports = get
-
-var assert = require('assert')
-var url = require('url')
-
-/*
- * This is meant to be overridden in specific implementations if you
- * want specialized behavior for metadata (i.e. caching).
- */
-function get (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to get')
- assert(params && typeof params === 'object', 'must pass params to get')
- assert(typeof cb === 'function', 'must pass callback to get')
-
- var parsed = url.parse(uri)
- assert(
- parsed.protocol === 'http:' || parsed.protocol === 'https:',
- 'must have a URL that starts with http: or https:'
- )
-
- this.request(uri, params, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/initialize.js b/deps/npm/node_modules/npm-registry-client/lib/initialize.js
deleted file mode 100644
index a25077eae5..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/initialize.js
+++ /dev/null
@@ -1,91 +0,0 @@
-var crypto = require('crypto')
-var HttpAgent = require('http').Agent
-var HttpsAgent = require('https').Agent
-
-var pkg = require('../package.json')
-
-module.exports = initialize
-
-function initialize (uri, method, accept, headers) {
- if (!this.config.sessionToken) {
- this.config.sessionToken = crypto.randomBytes(8).toString('hex')
- this.log.verbose('request id', this.config.sessionToken)
- }
- if (this.config.isFromCI == null) {
- this.config.isFromCI = Boolean(
- process.env['CI'] === 'true' || process.env['TDDIUM'] ||
- process.env['JENKINS_URL'] || process.env['bamboo.buildKey'] ||
- process.env['GO_PIPELINE_NAME'])
- }
-
- var opts = {
- url: uri,
- method: method,
- headers: headers,
- localAddress: this.config.proxy.localAddress,
- strictSSL: this.config.ssl.strict,
- cert: this.config.ssl.certificate,
- key: this.config.ssl.key,
- ca: this.config.ssl.ca,
- agent: getAgent.call(this, uri.protocol)
- }
-
- // allow explicit disabling of proxy in environment via CLI
- //
- // how false gets here is the CLI's problem (it's gross)
- if (this.config.proxy.http === false) {
- opts.proxy = null
- } else {
- // request will not pay attention to the NOPROXY environment variable if a
- // config value named proxy is passed in, even if it's set to null.
- var proxy
- if (uri.protocol === 'https:') {
- proxy = this.config.proxy.https
- } else {
- proxy = this.config.proxy.http
- }
- if (typeof proxy === 'string') opts.proxy = proxy
- }
-
- headers.version = this.version || pkg.version
- headers.accept = accept
-
- if (this.refer) headers.referer = this.refer
-
- headers['npm-session'] = this.config.sessionToken
- headers['npm-in-ci'] = String(this.config.isFromCI)
- headers['user-agent'] = this.config.userAgent
- if (this.config.scope) {
- headers['npm-scope'] = this.config.scope
- }
-
- return opts
-}
-
-function getAgent (protocol) {
- if (protocol === 'https:') {
- if (!this.httpsAgent) {
- this.httpsAgent = new HttpsAgent({
- keepAlive: true,
- maxSockets: this.config.maxSockets,
- localAddress: this.config.proxy.localAddress,
- rejectUnauthorized: this.config.ssl.strict,
- ca: this.config.ssl.ca,
- cert: this.config.ssl.certificate,
- key: this.config.ssl.key
- })
- }
-
- return this.httpsAgent
- } else {
- if (!this.httpAgent) {
- this.httpAgent = new HttpAgent({
- keepAlive: true,
- maxSockets: this.config.maxSockets,
- localAddress: this.config.proxy.localAddress
- })
- }
-
- return this.httpAgent
- }
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/logout.js b/deps/npm/node_modules/npm-registry-client/lib/logout.js
deleted file mode 100644
index e66e9b78ac..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/logout.js
+++ /dev/null
@@ -1,23 +0,0 @@
-module.exports = logout
-
-var assert = require('assert')
-var url = require('url')
-
-function logout (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to logout')
- assert(params && typeof params === 'object', 'must pass params to logout')
- assert(typeof cb === 'function', 'must pass callback to star')
-
- var auth = params.auth
- assert(auth && typeof auth === 'object', 'must pass auth to logout')
- assert(typeof auth.token === 'string', 'can only log out for token auth')
-
- uri = url.resolve(uri, '-/user/token/' + auth.token)
- var options = {
- method: 'DELETE',
- auth: auth
- }
-
- this.log.verbose('logout', 'invalidating session token for user')
- this.request(uri, options, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/org.js b/deps/npm/node_modules/npm-registry-client/lib/org.js
deleted file mode 100644
index 3072b3817a..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/org.js
+++ /dev/null
@@ -1,62 +0,0 @@
-'use strict'
-
-module.exports = org
-
-var assert = require('assert')
-var url = require('url')
-
-var subcommands = {}
-
-function org (subcommand, uri, params, cb) {
- orgAssertions(subcommand, uri, params, cb)
- return subcommands[subcommand].call(this, uri, params, cb)
-}
-
-subcommands.set = subcommands.add = function (uri, params, cb) {
- return this.request(apiUri(uri, 'org', params.org, 'user'), {
- method: 'PUT',
- auth: params.auth,
- body: JSON.stringify({
- user: params.user,
- role: params.role
- })
- }, cb)
-}
-
-subcommands.rm = function (uri, params, cb) {
- return this.request(apiUri(uri, 'org', params.org, 'user'), {
- method: 'DELETE',
- auth: params.auth,
- body: JSON.stringify({
- user: params.user
- })
- }, cb)
-}
-
-subcommands.ls = function (uri, params, cb) {
- return this.request(apiUri(uri, 'org', params.org, 'user'), {
- method: 'GET',
- auth: params.auth
- }, cb)
-}
-
-function apiUri (registryUri) {
- var path = Array.prototype.slice.call(arguments, 1)
- .map(encodeURIComponent)
- .join('/')
- return url.resolve(registryUri, '-/' + path)
-}
-
-function orgAssertions (subcommand, uri, params, cb) {
- assert(subcommand, 'subcommand is required')
- assert(subcommands.hasOwnProperty(subcommand),
- 'org subcommand must be one of ' + Object.keys(subcommands))
- assert(typeof uri === 'string', 'registry URI is required')
- assert(typeof params === 'object', 'params are required')
- assert(typeof params.auth === 'object', 'auth is required')
- assert(!cb || typeof cb === 'function', 'callback must be a function')
- assert(typeof params.org === 'string', 'org name is required')
- if (subcommand === 'rm' || subcommand === 'add' || subcommand === 'set') {
- assert(typeof params.user === 'string', 'user is required')
- }
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/ping.js b/deps/npm/node_modules/npm-registry-client/lib/ping.js
deleted file mode 100644
index 5ab98c52d2..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/ping.js
+++ /dev/null
@@ -1,21 +0,0 @@
-module.exports = ping
-
-var url = require('url')
-var assert = require('assert')
-
-function ping (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to ping')
- assert(params && typeof params === 'object', 'must pass params to ping')
- assert(typeof cb === 'function', 'must pass callback to ping')
-
- var auth = params.auth
- assert(auth && typeof auth === 'object', 'must pass auth to ping')
-
- this.request(url.resolve(uri, '-/ping?write=true'), { auth: auth }, function (er, fullData, data, response) {
- if (er || fullData) {
- cb(er, fullData, data, response)
- } else {
- cb(new Error('No data received'))
- }
- })
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/publish.js b/deps/npm/node_modules/npm-registry-client/lib/publish.js
deleted file mode 100644
index fd3adce126..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/publish.js
+++ /dev/null
@@ -1,194 +0,0 @@
-module.exports = publish
-
-var url = require('url')
-var semver = require('semver')
-var Stream = require('stream').Stream
-var assert = require('assert')
-var fixer = require('normalize-package-data').fixer
-var concat = require('concat-stream')
-var ssri = require('ssri')
-
-function escaped (name) {
- return name.replace('/', '%2f')
-}
-
-function publish (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to publish')
- assert(params && typeof params === 'object', 'must pass params to publish')
- assert(typeof cb === 'function', 'must pass callback to publish')
-
- var access = params.access
- assert(
- (!access) || ['public', 'restricted'].indexOf(access) !== -1,
- "if present, access level must be either 'public' or 'restricted'"
- )
-
- var auth = params.auth
- assert(auth && typeof auth === 'object', 'must pass auth to publish')
- if (!(auth.token ||
- (auth.password && auth.username && auth.email))) {
- var er = new Error('auth required for publishing')
- er.code = 'ENEEDAUTH'
- return cb(er)
- }
-
- var metadata = params.metadata
- assert(
- metadata && typeof metadata === 'object',
- 'must pass package metadata to publish'
- )
- try {
- fixer.fixNameField(metadata, {strict: true, allowLegacyCase: true})
- } catch (er) {
- return cb(er)
- }
- var version = semver.clean(metadata.version)
- if (!version) return cb(new Error('invalid semver: ' + metadata.version))
- metadata.version = version
-
- var body = params.body
- assert(body, 'must pass package body to publish')
- assert(body instanceof Stream, 'package body passed to publish must be a stream')
- var client = this
- var sink = concat(function (tarbuffer) {
- putFirst.call(client, uri, metadata, tarbuffer, access, auth, cb)
- })
- sink.on('error', cb)
- body.pipe(sink)
-}
-
-function putFirst (registry, data, tarbuffer, access, auth, cb) {
- // optimistically try to PUT all in one single atomic thing.
- // If 409, then GET and merge, try again.
- // If other error, then fail.
-
- var root = {
- _id: data.name,
- name: data.name,
- description: data.description,
- 'dist-tags': {},
- versions: {},
- readme: data.readme || ''
- }
-
- if (access) root.access = access
-
- if (!auth.token) {
- root.maintainers = [{ name: auth.username, email: auth.email }]
- data.maintainers = JSON.parse(JSON.stringify(root.maintainers))
- }
-
- root.versions[ data.version ] = data
- var tag = data.tag || this.config.defaultTag
- root['dist-tags'][tag] = data.version
-
- var tbName = data.name + '-' + data.version + '.tgz'
- var tbURI = data.name + '/-/' + tbName
- var integrity = ssri.fromData(tarbuffer, {
- algorithms: ['sha1', 'sha512']
- })
-
- data._id = data.name + '@' + data.version
- data.dist = data.dist || {}
- // Don't bother having sha1 in the actual integrity field
- data.dist.integrity = integrity['sha512'][0].toString()
- // Legacy shasum support
- data.dist.shasum = integrity['sha1'][0].hexDigest()
- data.dist.tarball = url.resolve(registry, tbURI)
- .replace(/^https:\/\//, 'http://')
-
- root._attachments = {}
- root._attachments[ tbName ] = {
- 'content_type': 'application/octet-stream',
- 'data': tarbuffer.toString('base64'),
- 'length': tarbuffer.length
- }
-
- var fixed = url.resolve(registry, escaped(data.name))
- var client = this
- var options = {
- method: 'PUT',
- body: root,
- auth: auth
- }
- this.request(fixed, options, function (er, parsed, json, res) {
- var r409 = 'must supply latest _rev to update existing package'
- var r409b = 'Document update conflict.'
- var conflict = res && res.statusCode === 409
- if (parsed && (parsed.reason === r409 || parsed.reason === r409b)) {
- conflict = true
- }
-
- // a 409 is typical here. GET the data and merge in.
- if (er && !conflict) {
- client.log.error('publish', 'Failed PUT ' + (res && res.statusCode))
- return cb(er)
- }
-
- if (!er && !conflict) return cb(er, parsed, json, res)
-
- // let's see what versions are already published.
- client.request(fixed + '?write=true', { auth: auth }, function (er, current) {
- if (er) return cb(er)
-
- putNext.call(client, registry, data.version, root, current, auth, cb)
- })
- })
-}
-
-function putNext (registry, newVersion, root, current, auth, cb) {
- // already have the tardata on the root object
- // just merge in existing stuff
- var curVers = Object.keys(current.versions || {}).map(function (v) {
- return semver.clean(v, true)
- }).concat(Object.keys(current.time || {}).map(function (v) {
- if (semver.valid(v, true)) return semver.clean(v, true)
- }).filter(function (v) {
- return v
- }))
-
- if (curVers.indexOf(newVersion) !== -1) {
- return cb(conflictError(root.name, newVersion))
- }
-
- current.versions[newVersion] = root.versions[newVersion]
- current._attachments = current._attachments || {}
- for (var i in root) {
- switch (i) {
- // objects that copy over the new stuffs
- case 'dist-tags':
- case 'versions':
- case '_attachments':
- for (var j in root[i]) {
- current[i][j] = root[i][j]
- }
- break
-
- // ignore these
- case 'maintainers':
- break
-
- // copy
- default:
- current[i] = root[i]
- }
- }
- var maint = JSON.parse(JSON.stringify(root.maintainers))
- root.versions[newVersion].maintainers = maint
-
- var uri = url.resolve(registry, escaped(root.name))
- var options = {
- method: 'PUT',
- body: current,
- auth: auth
- }
- this.request(uri, options, cb)
-}
-
-function conflictError (pkgid, version) {
- var e = new Error('cannot modify pre-existing version')
- e.code = 'EPUBLISHCONFLICT'
- e.pkgid = pkgid
- e.version = version
- return e
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/request.js b/deps/npm/node_modules/npm-registry-client/lib/request.js
deleted file mode 100644
index 5987bfa6fb..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/request.js
+++ /dev/null
@@ -1,336 +0,0 @@
-module.exports = regRequest
-
-// npm: means
-// 1. https
-// 2. send authorization
-// 3. content-type is 'application/json' -- metadata
-//
-var assert = require('assert')
-var url = require('url')
-var zlib = require('zlib')
-var Stream = require('stream').Stream
-var STATUS_CODES = require('http').STATUS_CODES
-
-var request = require('request')
-var once = require('once')
-
-function regRequest (uri, params, cb_) {
- assert(typeof uri === 'string', 'must pass uri to request')
- assert(params && typeof params === 'object', 'must pass params to request')
- assert(typeof cb_ === 'function', 'must pass callback to request')
-
- params.method = params.method || 'GET'
- this.log.verbose('request', 'uri', uri)
-
- // Since there are multiple places where an error could occur,
- // don't let the cb be called more than once.
- var cb = once(cb_)
-
- if (uri.match(/^\/?favicon.ico/)) {
- return cb(new Error("favicon.ico isn't a package, it's a picture."))
- }
-
- var adduserChange = /\/?-\/user\/org\.couchdb\.user:([^/]+)\/-rev/
- var isUserChange = uri.match(adduserChange)
- var adduserNew = /\/?-\/user\/org\.couchdb\.user:([^/?]+)$/
- var isNewUser = uri.match(adduserNew)
- var alwaysAuth = params.auth && params.auth.alwaysAuth
- var isDelete = params.method === 'DELETE'
- var isWrite = params.body || isDelete
-
- if (isUserChange && !isWrite) {
- return cb(new Error('trying to change user document without writing(?!)'))
- }
-
- if (params.authed == null) {
- // new users can *not* use auth, because they don't *have* auth yet
- if (isUserChange) {
- this.log.verbose('request', 'updating existing user; sending authorization')
- params.authed = true
- } else if (isNewUser) {
- this.log.verbose('request', "new user, so can't send auth")
- params.authed = false
- } else if (alwaysAuth) {
- this.log.verbose('request', 'always-auth set; sending authorization')
- params.authed = true
- } else if (isWrite) {
- this.log.verbose('request', 'sending authorization for write operation')
- params.authed = true
- } else {
- // most of the time we don't want to auth
- this.log.verbose('request', 'no auth needed')
- params.authed = false
- }
- }
-
- var self = this
- this.attempt(function (operation) {
- makeRequest.call(self, uri, params, function (er, parsed, raw, response) {
- if (response) {
- self.log.verbose('headers', response.headers)
- if (response.headers['npm-notice']) {
- self.log.warn('notice', response.headers['npm-notice'])
- }
- }
-
- if (!er || (er.message && er.message.match(/^SSL Error/))) {
- if (er) er.code = 'ESSL'
- return cb(er, parsed, raw, response)
- }
-
- // Only retry on 408, 5xx or no `response`.
- var statusCode = response && response.statusCode
-
- var timeout = statusCode === 408
- var serverError = statusCode >= 500
- var statusRetry = !statusCode || timeout || serverError
- if (er && statusRetry && operation.retry(er)) {
- self.log.info('retry', 'will retry, error on last attempt: ' + er)
- return undefined
- }
- cb.apply(null, arguments)
- })
- })
-}
-
-function makeRequest (uri, params, cb_) {
- var socket
- var cb = once(function (er, parsed, raw, response) {
- if (socket) {
- // The socket might be returned to a pool for re-use, so don’t keep
- // the 'error' listener from here attached.
- socket.removeListener('error', cb)
- }
-
- return cb_(er, parsed, raw, response)
- })
-
- var parsed = url.parse(uri)
- var headers = {}
-
- // metadata should be compressed
- headers['accept-encoding'] = 'gzip'
-
- // metadata should be minified, if the registry supports it
-
- var er = this.authify(params.authed, parsed, headers, params.auth)
- if (er) return cb_(er)
-
- var useCorgi = params.fullMetadata == null ? false : !params.fullMetadata
-
- var opts = this.initialize(
- parsed,
- params.method,
- useCorgi ? 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' : 'application/json',
- headers
- )
-
- opts.followRedirect = (typeof params.follow === 'boolean' ? params.follow : true)
- opts.encoding = null // tell request let body be Buffer instance
-
- if (params.etag) {
- this.log.verbose('etag', params.etag)
- headers[params.method === 'GET' ? 'if-none-match' : 'if-match'] = params.etag
- }
-
- if (params.lastModified && params.method === 'GET') {
- this.log.verbose('lastModified', params.lastModified)
- headers['if-modified-since'] = params.lastModified
- }
-
- // figure out wth body is
- if (params.body) {
- if (Buffer.isBuffer(params.body)) {
- opts.body = params.body
- headers['content-type'] = 'application/json'
- headers['content-length'] = params.body.length
- } else if (typeof params.body === 'string') {
- opts.body = params.body
- headers['content-type'] = 'application/json'
- headers['content-length'] = Buffer.byteLength(params.body)
- } else if (params.body instanceof Stream) {
- headers['content-type'] = 'application/octet-stream'
- if (params.body.size) headers['content-length'] = params.body.size
- } else {
- delete params.body._etag
- delete params.body._lastModified
- opts.json = params.body
- }
- }
-
- this.log.http('request', params.method, parsed.href || '/')
-
- var done = requestDone.call(this, params.method, uri, cb)
- var req = request(opts, params.streaming ? undefined : decodeResponseBody(done))
-
- req.on('error', cb)
-
- // This should not be necessary, as the HTTP implementation in Node
- // passes errors occurring on the socket to the request itself. Being overly
- // cautious comes at a low cost, though.
- req.on('socket', function (s) {
- socket = s
- socket.on('error', cb)
- })
-
- if (params.streaming) {
- req.on('response', function (response) {
- if (response.statusCode >= 400) {
- var parts = []
- response.on('data', function (data) {
- parts.push(data)
- })
- response.on('end', function () {
- decodeResponseBody(done)(null, response, Buffer.concat(parts))
- })
- } else {
- response.on('end', function () {
- // don't ever re-use connections that had server errors.
- // those sockets connect to the Bad Place!
- if (response.socket && response.statusCode > 500) {
- response.socket.destroy()
- }
- })
-
- return cb(null, response)
- }
- })
- }
-
- if (params.body && (params.body instanceof Stream)) {
- params.body.pipe(req)
- }
-}
-
-function decodeResponseBody (cb) {
- return function (er, response, data) {
- if (er) return cb(er, response, data)
-
- // don't ever re-use connections that had server errors.
- // those sockets connect to the Bad Place!
- if (response.socket && response.statusCode > 500) {
- response.socket.destroy()
- }
-
- if (response.headers['content-encoding'] !== 'gzip') {
- return cb(er, response, data)
- }
-
- zlib.gunzip(data, function (er, buf) {
- if (er) return cb(er, response, data)
-
- cb(null, response, buf)
- })
- }
-}
-
-// cb(er, parsed, raw, response)
-function requestDone (method, where, cb) {
- return function (er, response, data) {
- if (er) return cb(er)
-
- var urlObj = url.parse(where)
- if (urlObj.auth) urlObj.auth = '***'
- this.log.http(response.statusCode, url.format(urlObj))
-
- if (Buffer.isBuffer(data)) {
- data = data.toString()
- }
-
- var parsed
- if (data && typeof data === 'string' && response.statusCode !== 304) {
- try {
- parsed = JSON.parse(data)
- } catch (ex) {
- ex.message += '\n' + data
- this.log.verbose('bad json', data)
- this.log.error('registry', 'error parsing json')
- return cb(ex, null, data, response)
- }
- } else if (data) {
- parsed = data
- data = JSON.stringify(parsed)
- }
-
- // expect data with any error codes
- if (!data && response.statusCode >= 400) {
- var code = response.statusCode
- return cb(
- makeError(code + ' ' + STATUS_CODES[code], null, code),
- null,
- data,
- response
- )
- }
-
- er = null
- if (parsed && response.headers.etag) {
- parsed._etag = response.headers.etag
- }
-
- if (parsed && response.headers['last-modified']) {
- parsed._lastModified = response.headers['last-modified']
- }
-
- // for the search endpoint, the 'error' property can be an object
- if ((parsed && parsed.error && typeof parsed.error !== 'object') ||
- response.statusCode >= 400) {
- var w = url.parse(where).pathname.substr(1)
- var name
- if (!w.match(/^-/)) {
- w = w.split('/')
- var index = w.indexOf('_rewrite')
- if (index === -1) {
- index = w.length - 1
- } else {
- index++
- }
- name = decodeURIComponent(w[index])
- }
-
- if (!parsed.error) {
- if (response.statusCode === 401 && response.headers['www-authenticate']) {
- const auth = response.headers['www-authenticate'].split(/,\s*/).map(s => s.toLowerCase())
- if (auth.indexOf('ipaddress') !== -1) {
- er = makeError('Login is not allowed from your IP address', name, response.statusCode, 'EAUTHIP')
- } else if (auth.indexOf('otp') !== -1) {
- er = makeError('OTP required for this operation', name, response.statusCode, 'EOTP')
- } else {
- er = makeError('Unable to authenticate, need: ' + response.headers['www-authenticate'], name, response.statusCode, 'EAUTHUNKNOWN')
- }
- } else {
- const msg = parsed.message ? ': ' + parsed.message : ''
- er = makeError(
- 'Registry returned ' + response.statusCode +
- ' for ' + method +
- ' on ' + where +
- msg,
- name,
- response.statusCode
- )
- }
- } else if (name && parsed.error === 'not_found') {
- er = makeError('404 Not Found: ' + name, name, response.statusCode)
- } else if (name && parsed.error === 'User not found') {
- er = makeError('User not found. Check `npm whoami` and make sure you have a NPM account.', name, response.statusCode)
- } else {
- er = makeError(
- parsed.error + ' ' + (parsed.reason || '') + ': ' + (name || w),
- name,
- response.statusCode
- )
- }
- }
- return cb(er, parsed, data, response)
- }.bind(this)
-}
-
-function makeError (message, name, statusCode, code) {
- var er = new Error(message)
- if (name) er.pkgid = name
- if (statusCode) {
- er.statusCode = statusCode
- er.code = code || 'E' + statusCode
- }
- return er
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js b/deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js
deleted file mode 100644
index b5b7a1dca1..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js
+++ /dev/null
@@ -1,19 +0,0 @@
-module.exports = send
-
-var assert = require('assert')
-var url = require('url')
-
-function send (registryUrl, params, cb) {
- assert(typeof registryUrl === 'string', 'must pass registry URI')
- assert(params && typeof params === 'object', 'must pass params')
- assert(typeof cb === 'function', 'must pass callback')
-
- var uri = url.resolve(registryUrl, '-/npm/anon-metrics/v1/' +
- encodeURIComponent(params.metricId))
-
- this.request(uri, {
- method: 'PUT',
- body: JSON.stringify(params.metrics),
- authed: false
- }, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/star.js b/deps/npm/node_modules/npm-registry-client/lib/star.js
deleted file mode 100644
index 5c9224eaa2..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/star.js
+++ /dev/null
@@ -1,51 +0,0 @@
-module.exports = star
-
-var assert = require('assert')
-
-function star (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to star')
- assert(params && typeof params === 'object', 'must pass params to star')
- assert(typeof cb === 'function', 'must pass callback to star')
-
- var starred = !!params.starred
-
- var auth = params.auth
- assert(auth && typeof auth === 'object', 'must pass auth to star')
- if (!(auth.token || (auth.password && auth.username && auth.email))) {
- var er = new Error('Must be logged in to star/unstar packages')
- er.code = 'ENEEDAUTH'
- return cb(er)
- }
-
- var client = this
- this.request(uri + '?write=true', { auth: auth }, function (er, fullData) {
- if (er) return cb(er)
-
- client.whoami(uri, params, function (er, username) {
- if (er) return cb(er)
-
- var data = {
- _id: fullData._id,
- _rev: fullData._rev,
- users: fullData.users || {}
- }
-
- if (starred) {
- client.log.info('starring', data._id)
- data.users[username] = true
- client.log.verbose('starring', data)
- } else {
- delete data.users[username]
- client.log.info('unstarring', data._id)
- client.log.verbose('unstarring', data)
- }
-
- var options = {
- method: 'PUT',
- body: data,
- auth: auth
- }
- return client.request(uri, options, cb)
- })
- })
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/stars.js b/deps/npm/node_modules/npm-registry-client/lib/stars.js
deleted file mode 100644
index ba47f2c1ef..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/stars.js
+++ /dev/null
@@ -1,18 +0,0 @@
-module.exports = stars
-
-var assert = require('assert')
-var url = require('url')
-
-function stars (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to stars')
- assert(params && typeof params === 'object', 'must pass params to stars')
- assert(typeof cb === 'function', 'must pass callback to stars')
-
- var auth = params.auth
- var name = params.username || (auth && auth.username)
- if (!name) return cb(new Error('must pass either username or auth to stars'))
- var encoded = encodeURIComponent(name)
- var path = '-/_view/starredByUser?key="' + encoded + '"'
-
- this.request(url.resolve(uri, path), { auth: auth }, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/tag.js b/deps/npm/node_modules/npm-registry-client/lib/tag.js
deleted file mode 100644
index 3b6dad1df2..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/tag.js
+++ /dev/null
@@ -1,23 +0,0 @@
-module.exports = tag
-
-var assert = require('assert')
-
-function tag (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to tag')
- assert(params && typeof params === 'object', 'must pass params to tag')
- assert(typeof cb === 'function', 'must pass callback to tag')
-
- assert(typeof params.version === 'string', 'must pass version to tag')
- assert(typeof params.tag === 'string', 'must pass tag name to tag')
- assert(
- params.auth && typeof params.auth === 'object',
- 'must pass auth to tag'
- )
-
- var options = {
- method: 'PUT',
- body: JSON.stringify(params.version),
- auth: params.auth
- }
- this.request(uri + '/' + params.tag, options, cb)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/team.js b/deps/npm/node_modules/npm-registry-client/lib/team.js
deleted file mode 100644
index 327fa9cd5a..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/team.js
+++ /dev/null
@@ -1,105 +0,0 @@
-module.exports = team
-
-var assert = require('assert')
-var url = require('url')
-
-var subcommands = {}
-
-function team (sub, uri, params, cb) {
- teamAssertions(sub, uri, params, cb)
- return subcommands[sub].call(this, uri, params, cb)
-}
-
-subcommands.create = function (uri, params, cb) {
- return this.request(apiUri(uri, 'org', params.scope, 'team'), {
- method: 'PUT',
- auth: params.auth,
- body: JSON.stringify({
- name: params.team
- })
- }, cb)
-}
-
-subcommands.destroy = function (uri, params, cb) {
- return this.request(apiUri(uri, 'team', params.scope, params.team), {
- method: 'DELETE',
- auth: params.auth
- }, cb)
-}
-
-subcommands.add = function (uri, params, cb) {
- return this.request(apiUri(uri, 'team', params.scope, params.team, 'user'), {
- method: 'PUT',
- auth: params.auth,
- body: JSON.stringify({
- user: params.user
- })
- }, cb)
-}
-
-subcommands.rm = function (uri, params, cb) {
- return this.request(apiUri(uri, 'team', params.scope, params.team, 'user'), {
- method: 'DELETE',
- auth: params.auth,
- body: JSON.stringify({
- user: params.user
- })
- }, cb)
-}
-
-subcommands.ls = function (uri, params, cb) {
- var uriParams = '?format=cli'
- if (params.team) {
- var reqUri = apiUri(
- uri, 'team', params.scope, params.team, 'user') + uriParams
- return this.request(reqUri, {
- method: 'GET',
- auth: params.auth
- }, cb)
- } else {
- return this.request(apiUri(uri, 'org', params.scope, 'team') + uriParams, {
- method: 'GET',
- auth: params.auth
- }, cb)
- }
-}
-
-// TODO - we punted this to v2
-// subcommands.edit = function (uri, params, cb) {
-// return this.request(apiUri(uri, 'team', params.scope, params.team, 'user'), {
-// method: 'POST',
-// auth: params.auth,
-// body: JSON.stringify({
-// users: params.users
-// })
-// }, cb)
-// }
-
-function apiUri (registryUri) {
- var path = Array.prototype.slice.call(arguments, 1)
- .map(encodeURIComponent)
- .join('/')
- return url.resolve(registryUri, '-/' + path)
-}
-
-function teamAssertions (subcommand, uri, params, cb) {
- assert(subcommand, 'subcommand is required')
- assert(subcommands.hasOwnProperty(subcommand),
- 'team subcommand must be one of ' + Object.keys(subcommands))
- assert(typeof uri === 'string', 'registry URI is required')
- assert(typeof params === 'object', 'params are required')
- assert(typeof params.auth === 'object', 'auth is required')
- assert(typeof params.scope === 'string', 'scope is required')
- assert(!cb || typeof cb === 'function', 'callback must be a function')
- if (subcommand !== 'ls') {
- assert(typeof params.team === 'string', 'team name is required')
- }
- if (subcommand === 'rm' || subcommand === 'add') {
- assert(typeof params.user === 'string', 'user is required')
- }
- if (subcommand === 'edit') {
- assert(typeof params.users === 'object' &&
- params.users.length != null,
- 'users is required')
- }
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/unpublish.js b/deps/npm/node_modules/npm-registry-client/lib/unpublish.js
deleted file mode 100644
index 05c5a4b611..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/unpublish.js
+++ /dev/null
@@ -1,120 +0,0 @@
-module.exports = unpublish
-
-// fetch the data
-// modify to remove the version in question
-// If no versions remaining, then DELETE
-// else, PUT the modified data
-// delete the tarball
-
-var semver = require('semver')
-var url = require('url')
-var chain = require('slide').chain
-var assert = require('assert')
-
-function unpublish (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to unpublish')
- assert(params && typeof params === 'object', 'must pass params to unpublish')
- assert(typeof cb === 'function', 'must pass callback to unpublish')
-
- var ver = params.version
- var auth = params.auth
- assert(auth && typeof auth === 'object', 'must pass auth to unpublish')
-
- var options = {
- timeout: -1,
- follow: false,
- auth: auth
- }
- this.get(uri + '?write=true', options, function (er, data) {
- if (er) {
- this.log.info('unpublish', uri + ' not published')
- return cb()
- }
- // remove all if no version specified
- if (!ver) {
- this.log.info('unpublish', 'No version specified, removing all')
- return this.request(uri + '/-rev/' + data._rev, { method: 'DELETE', auth: auth }, cb)
- }
-
- var versions = data.versions || {}
- var versionPublic = versions.hasOwnProperty(ver)
-
- var dist
- if (!versionPublic) {
- this.log.info('unpublish', uri + '@' + ver + ' not published')
- } else {
- dist = versions[ver].dist
- this.log.verbose('unpublish', 'removing attachments', dist)
- }
-
- delete versions[ver]
- // if it was the only version, then delete the whole package.
- if (!Object.keys(versions).length) {
- this.log.info('unpublish', 'No versions remain, removing entire package')
- return this.request(uri + '/-rev/' + data._rev, { method: 'DELETE', auth: auth }, cb)
- }
-
- if (!versionPublic) return cb()
-
- var latestVer = data['dist-tags'].latest
- for (var tag in data['dist-tags']) {
- if (data['dist-tags'][tag] === ver) delete data['dist-tags'][tag]
- }
-
- if (latestVer === ver) {
- data['dist-tags'].latest =
- Object.getOwnPropertyNames(versions).sort(semver.compareLoose).pop()
- }
-
- var rev = data._rev
- delete data._revisions
- delete data._attachments
- var cb_ = detacher.call(this, uri, data, dist, auth, cb)
-
- this.request(uri + '/-rev/' + rev, { method: 'PUT', body: data, auth: auth }, function (er) {
- if (er) {
- this.log.error('unpublish', 'Failed to update data')
- }
- cb_(er)
- }.bind(this))
- }.bind(this))
-}
-
-function detacher (uri, data, dist, credentials, cb) {
- return function (er) {
- if (er) return cb(er)
- this.get(escape(uri, data.name), { auth: credentials }, function (er, data) {
- if (er) return cb(er)
-
- var tb = url.parse(dist.tarball)
-
- detach.call(this, uri, data, tb.pathname, data._rev, credentials, function (er) {
- if (er || !dist.bin) return cb(er)
- chain(Object.keys(dist.bin).map(function (bt) {
- return function (cb) {
- var d = dist.bin[bt]
- detach.call(this, uri, data, url.parse(d.tarball).pathname, null, credentials, cb)
- }.bind(this)
- }, this), cb)
- }.bind(this))
- }.bind(this))
- }.bind(this)
-}
-
-function detach (uri, data, path, rev, credentials, cb) {
- if (rev) {
- path += '/-rev/' + rev
- this.log.info('detach', path)
- return this.request(url.resolve(uri, path), { method: 'DELETE', auth: credentials }, cb)
- }
- this.get(escape(uri, data.name), { auth: credentials }, function (er, data) {
- rev = data._rev
- if (!rev) return cb(new Error('No _rev found in ' + data._id))
- detach.call(this, data, path, rev, cb)
- }.bind(this))
-}
-
-function escape (base, name) {
- var escaped = name.replace(/\//, '%2f')
- return url.resolve(base, escaped)
-}
diff --git a/deps/npm/node_modules/npm-registry-client/lib/whoami.js b/deps/npm/node_modules/npm-registry-client/lib/whoami.js
deleted file mode 100644
index 68db49e59a..0000000000
--- a/deps/npm/node_modules/npm-registry-client/lib/whoami.js
+++ /dev/null
@@ -1,21 +0,0 @@
-module.exports = whoami
-
-var url = require('url')
-var assert = require('assert')
-
-function whoami (uri, params, cb) {
- assert(typeof uri === 'string', 'must pass registry URI to whoami')
- assert(params && typeof params === 'object', 'must pass params to whoami')
- assert(typeof cb === 'function', 'must pass callback to whoami')
-
- var auth = params.auth
- assert(auth && typeof auth === 'object', 'must pass auth to whoami')
-
- if (auth.username) return process.nextTick(cb.bind(this, null, auth.username))
-
- this.request(url.resolve(uri, '-/whoami'), { auth: auth }, function (er, userdata) {
- if (er) return cb(er)
-
- cb(null, userdata.username)
- })
-}