From d1c6bbce2926aabe7a0097f6e2eddb3546b45a35 Mon Sep 17 00:00:00 2001 From: PSanetra Date: Fri, 6 Apr 2018 17:38:31 +0200 Subject: [PATCH] fix(npm): use parsed body in case response.body is gzip encoded --- src/lib/npm.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/npm.js b/src/lib/npm.js index 91fb98d..1044395 100644 --- a/src/lib/npm.js +++ b/src/lib/npm.js @@ -42,7 +42,7 @@ async function getNpmToken({npm, options}) { } else if (err) { resolve({err}); } else { - resolve(response.body); + resolve(parsed); } }); }); @@ -72,11 +72,11 @@ async function validateToken(otp, uri, body, npm) { } return new Promise(resolve => { - client.request(uri, {method: 'PUT', auth: {otp}, body}, (err, parsed, raw, response) => { - if (err || !response.body.ok) { + client.request(uri, {method: 'PUT', auth: {otp}, body}, (err, parsed) => { + if (err || !parsed || !parsed.ok) { resolve('Invalid authentication code'); } else { - npm.token = response.body.token; + npm.token = parsed.token; resolve(true); } });