diff options
Diffstat (limited to 'includes/external/addressbook/node_modules/http2-wrapper/source/proxies')
7 files changed, 0 insertions, 259 deletions
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/get-auth-headers.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/get-auth-headers.js deleted file mode 100644 index 364a858..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/get-auth-headers.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = self => { - const {username, password} = self.proxyOptions.url; - - if (username || password) { - const data = `${username}:${password}`; - const authorization = `Basic ${Buffer.from(data).toString('base64')}`; - - return { - 'proxy-authorization': authorization, - authorization - }; - } - - return {}; -}; diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h1-over-h2.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h1-over-h2.js deleted file mode 100644 index 15a4f78..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h1-over-h2.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict'; -const tls = require('tls'); -const http = require('http'); -const https = require('https'); -const JSStreamSocket = require('../utils/js-stream-socket.js'); -const {globalAgent} = require('../agent.js'); -const UnexpectedStatusCodeError = require('./unexpected-status-code-error.js'); -const initialize = require('./initialize.js'); -const getAuthorizationHeaders = require('./get-auth-headers.js'); - -const createConnection = (self, options, callback) => { - (async () => { - try { - const {proxyOptions} = self; - const {url, headers, raw} = proxyOptions; - - const stream = await globalAgent.request(url, proxyOptions, { - ...getAuthorizationHeaders(self), - ...headers, - ':method': 'CONNECT', - ':authority': `${options.host}:${options.port}` - }); - - stream.once('error', callback); - stream.once('response', headers => { - const statusCode = headers[':status']; - - if (statusCode !== 200) { - callback(new UnexpectedStatusCodeError(statusCode, '')); - return; - } - - const encrypted = self instanceof https.Agent; - - if (raw && encrypted) { - options.socket = stream; - const secureStream = tls.connect(options); - - secureStream.once('close', () => { - stream.destroy(); - }); - - callback(null, secureStream); - return; - } - - const socket = new JSStreamSocket(stream); - socket.encrypted = false; - socket._handle.getpeername = out => { - out.family = undefined; - out.address = undefined; - out.port = undefined; - }; - - callback(null, socket); - }); - } catch (error) { - callback(error); - } - })(); -}; - -class HttpOverHttp2 extends http.Agent { - constructor(options) { - super(options); - - initialize(this, options.proxyOptions); - } - - createConnection(options, callback) { - createConnection(this, options, callback); - } -} - -class HttpsOverHttp2 extends https.Agent { - constructor(options) { - super(options); - - initialize(this, options.proxyOptions); - } - - createConnection(options, callback) { - createConnection(this, options, callback); - } -} - -module.exports = { - HttpOverHttp2, - HttpsOverHttp2 -}; diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h1.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h1.js deleted file mode 100644 index 8764f07..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h1.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; -const http = require('http'); -const https = require('https'); -const Http2OverHttpX = require('./h2-over-hx.js'); -const getAuthorizationHeaders = require('./get-auth-headers.js'); - -const getStream = request => new Promise((resolve, reject) => { - const onConnect = (response, socket, head) => { - socket.unshift(head); - - request.off('error', reject); - resolve([socket, response.statusCode, response.statusMessage]); - }; - - request.once('error', reject); - request.once('connect', onConnect); -}); - -class Http2OverHttp extends Http2OverHttpX { - async _getProxyStream(authority) { - const {proxyOptions} = this; - const {url, headers} = this.proxyOptions; - - const network = url.protocol === 'https:' ? https : http; - - // `new URL('https://localhost/httpbin.org:443')` results in - // a `/httpbin.org:443` path, which has an invalid leading slash. - const request = network.request({ - ...proxyOptions, - hostname: url.hostname, - port: url.port, - path: authority, - headers: { - ...getAuthorizationHeaders(this), - ...headers, - host: authority - }, - method: 'CONNECT' - }).end(); - - return getStream(request); - } -} - -module.exports = { - Http2OverHttp, - Http2OverHttps: Http2OverHttp -}; diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js deleted file mode 100644 index 414c5e9..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-h2.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -const {globalAgent} = require('../agent.js'); -const Http2OverHttpX = require('./h2-over-hx.js'); -const getAuthorizationHeaders = require('./get-auth-headers.js'); - -const getStatusCode = stream => new Promise((resolve, reject) => { - stream.once('error', reject); - stream.once('response', headers => { - stream.off('error', reject); - resolve(headers[':status']); - }); -}); - -class Http2OverHttp2 extends Http2OverHttpX { - async _getProxyStream(authority) { - const {proxyOptions} = this; - - const headers = { - ...getAuthorizationHeaders(this), - ...proxyOptions.headers, - ':method': 'CONNECT', - ':authority': authority - }; - - const stream = await globalAgent.request(proxyOptions.url, proxyOptions, headers); - const statusCode = await getStatusCode(stream); - - return [stream, statusCode, '']; - } -} - -module.exports = Http2OverHttp2; diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-hx.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-hx.js deleted file mode 100644 index 0f5a104..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/h2-over-hx.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; -const {Agent} = require('../agent.js'); -const JSStreamSocket = require('../utils/js-stream-socket.js'); -const UnexpectedStatusCodeError = require('./unexpected-status-code-error.js'); -const initialize = require('./initialize.js'); - -class Http2OverHttpX extends Agent { - constructor(options) { - super(options); - - initialize(this, options.proxyOptions); - } - - async createConnection(origin, options) { - const authority = `${origin.hostname}:${origin.port || 443}`; - - const [stream, statusCode, statusMessage] = await this._getProxyStream(authority); - if (statusCode !== 200) { - throw new UnexpectedStatusCodeError(statusCode, statusMessage); - } - - if (this.proxyOptions.raw) { - options.socket = stream; - } else { - const socket = new JSStreamSocket(stream); - socket.encrypted = false; - socket._handle.getpeername = out => { - out.family = undefined; - out.address = undefined; - out.port = undefined; - }; - - return socket; - } - - return super.createConnection(origin, options); - } -} - -module.exports = Http2OverHttpX; diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/initialize.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/initialize.js deleted file mode 100644 index e4c5889..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/initialize.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -// See https://github.com/facebook/jest/issues/2549 -// eslint-disable-next-line node/prefer-global/url -const {URL} = require('url'); -const checkType = require('../utils/check-type.js'); - -module.exports = (self, proxyOptions) => { - checkType('proxyOptions', proxyOptions, ['object']); - checkType('proxyOptions.headers', proxyOptions.headers, ['object', 'undefined']); - checkType('proxyOptions.raw', proxyOptions.raw, ['boolean', 'undefined']); - checkType('proxyOptions.url', proxyOptions.url, [URL, 'string']); - - const url = new URL(proxyOptions.url); - - self.proxyOptions = { - raw: true, - ...proxyOptions, - headers: {...proxyOptions.headers}, - url - }; -}; diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/unexpected-status-code-error.js b/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/unexpected-status-code-error.js deleted file mode 100644 index c7f0216..0000000 --- a/includes/external/addressbook/node_modules/http2-wrapper/source/proxies/unexpected-status-code-error.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -class UnexpectedStatusCodeError extends Error { - constructor(statusCode, statusMessage = '') { - super(`The proxy server rejected the request with status code ${statusCode} (${statusMessage || 'empty status message'})`); - this.statusCode = statusCode; - this.statusMessage = statusMessage; - } -} - -module.exports = UnexpectedStatusCodeError; |