proxy-chain
Advanced tools
Comparing version 2.0.5 to 2.0.6-beta.0
@@ -321,3 +321,6 @@ "use strict"; | ||
} | ||
if (auth.type !== 'Basic') { | ||
// https://datatracker.ietf.org/doc/html/rfc7617#page-3 | ||
// Note that both scheme and parameter names are matched case- | ||
// insensitively. | ||
if (auth.type.toLowerCase() !== 'basic') { | ||
throw new request_error_1.RequestError('The "Proxy-Authorization" header must have the "Basic" type.', 400); | ||
@@ -324,0 +327,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseAuthorizationHeader = void 0; | ||
const node_buffer_1 = require("node:buffer"); | ||
const splitAt = (string, index) => { | ||
@@ -18,7 +19,28 @@ return [ | ||
const [type, data] = splitAt(header, header.indexOf(' ')); | ||
// https://datatracker.ietf.org/doc/html/rfc7617#page-3 | ||
// Note that both scheme and parameter names are matched case- | ||
// insensitively. | ||
if (type.toLowerCase() !== 'basic') { | ||
return { type, data }; | ||
} | ||
const auth = Buffer.from(data, 'base64').toString(); | ||
const [username, password] = splitAt(auth, auth.indexOf(':')); | ||
const auth = node_buffer_1.Buffer.from(data, 'base64').toString(); | ||
// https://datatracker.ietf.org/doc/html/rfc7617#page-5 | ||
// To receive authorization, the client | ||
// | ||
// 1. obtains the user-id and password from the user, | ||
// | ||
// 2. constructs the user-pass by concatenating the user-id, a single | ||
// colon (":") character, and the password, | ||
// | ||
// 3. encodes the user-pass into an octet sequence (see below for a | ||
// discussion of character encoding schemes), | ||
// | ||
// 4. and obtains the basic-credentials by encoding this octet sequence | ||
// using Base64 ([RFC4648], Section 4) into a sequence of US-ASCII | ||
// characters ([RFC0020]). | ||
// Note: | ||
// If there's a colon : missing, we imply that the user-pass string is just a username. | ||
// This is a non-spec behavior. At Apify there are clients that rely on this. | ||
// If you want this behavior changed, please open an issue. | ||
const [username, password] = auth.includes(':') ? splitAt(auth, auth.indexOf(':')) : [auth, '']; | ||
return { | ||
@@ -25,0 +47,0 @@ type, |
{ | ||
"name": "proxy-chain", | ||
"version": "2.0.5", | ||
"version": "2.0.6-beta.0", | ||
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.", | ||
@@ -65,3 +65,3 @@ "main": "dist/index.js", | ||
"nyc": "^15.1.0", | ||
"phantomjs-prebuilt": "^2.1.16", | ||
"puppeteer": "^16.0.0", | ||
"portastic": "^1.0.1", | ||
@@ -68,0 +68,0 @@ "proxy": "^1.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
166865
1710
1