From 25828960bce78dd5559c86f4fc40134a7a54e976 Mon Sep 17 00:00:00 2001 From: Christoph Witzko Date: Wed, 27 May 2015 18:55:58 +0200 Subject: [PATCH] fix(npm-info): support basic auth --- lib/npm-info.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/npm-info.js b/lib/npm-info.js index b861796d..24a10734 100644 --- a/lib/npm-info.js +++ b/lib/npm-info.js @@ -10,12 +10,16 @@ module.exports = function (pkgName, cb) { npmconf.load, function (conf, callback) { var cred = conf.getCredentialsByURI(registry) - callback(null, { + var reqopts = { url: registry + pkgName.replace(/\//g, '%2F'), - headers: { - 'Authorization': cred.token ? 'Bearer ' + cred.token : null - } - }) + headers: {} + } + if (cred.token) { + reqopts.headers.Authorization = 'Bearer ' + cred.token + } else if (cred.auth) { + reqopts.headers.Authorization = 'Basic ' + cred.auth + } + callback(null, reqopts) }, request, function (response, body, callback) {