From 9db9b53c812fd681ab63b65b2ac4c8ca28b41cac Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Wed, 30 Jun 2021 14:12:20 +0100 Subject: [PATCH] Fix package.json Also back out auth changes --- package.json | 2 +- .../@node-red/nodes/core/network/21-httprequest.js | 14 ++++++++++---- packages/node_modules/@node-red/nodes/package.json | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index cfe7660e0..ede777340 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "fs.notify": "0.0.4", "got": "11.8.2", "hash-sum": "2.0.0", - "hpagent": "0.1.2", + "hpagent": "^0.1.2", "https-proxy-agent": "5.0.0", "i18next": "20.3.2", "iconv-lite": "0.6.3", diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js index fd840bdea..a498d4ac7 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js @@ -207,17 +207,23 @@ module.exports = function(RED) { } if (this.credentials) { if (this.authType === "basic") { + // Workaround for https://github.com/sindresorhus/got/issues/1169 + var cred = "" var parsedURL = new URL(url) if (this.credentials.user) { - opts.username = this.credentials.user; + // opts.username = this.credentials.user; + cred = this.credentials.user } else if (parsedURL.username) { - opts.username = parsedURL.username + cred = parsedURL.username } if (this.credentials.password) { - opts.password = this.credentials.password; + // opts.password = this.credentials.password; + cred += ":" + this.credentials.password } else if (parsedURL.password) { - opts.password = parsedURL.password + cred += ":" + parsedURL.password } + // build own basic auth header + opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64"); } else if (this.authType === "digest") { let digestCreds = this.credentials; let sentCreds = false; diff --git a/packages/node_modules/@node-red/nodes/package.json b/packages/node_modules/@node-red/nodes/package.json index 72a908165..5be62780f 100644 --- a/packages/node_modules/@node-red/nodes/package.json +++ b/packages/node_modules/@node-red/nodes/package.json @@ -31,7 +31,7 @@ "fs.notify": "0.0.4", "got": "11.8.2", "hash-sum": "2.0.0", - "hpagent": "0.1.1", + "hpagent": "^0.1.2", "https-proxy-agent": "5.0.0", "is-utf8": "0.2.1", "js-yaml": "3.14.0",