diff options
Diffstat (limited to 'desktop/node_modules/global-agent')
125 files changed, 5954 insertions, 0 deletions
diff --git a/desktop/node_modules/global-agent/.flowconfig b/desktop/node_modules/global-agent/.flowconfig new file mode 100644 index 0000000..029d8c2 --- /dev/null +++ b/desktop/node_modules/global-agent/.flowconfig @@ -0,0 +1,3 @@ +[ignore] +.*/node_modules/.*/test/.* +<PROJECT_ROOT>/dist/.* diff --git a/desktop/node_modules/global-agent/LICENSE b/desktop/node_modules/global-agent/LICENSE new file mode 100644 index 0000000..5065086 --- /dev/null +++ b/desktop/node_modules/global-agent/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2019, Gajus Kuizinas (http://gajus.com/) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/desktop/node_modules/global-agent/README.md b/desktop/node_modules/global-agent/README.md new file mode 100644 index 0000000..8a8b525 --- /dev/null +++ b/desktop/node_modules/global-agent/README.md @@ -0,0 +1,239 @@ +# global-agent + +[![GitSpo Mentions](https://gitspo.com/badges/mentions/gajus/global-agent?style=flat-square)](https://gitspo.com/mentions/gajus/global-agent) +[![Travis build status](http://img.shields.io/travis/gajus/global-agent/master.svg?style=flat-square)](https://travis-ci.org/gajus/global-agent) +[![Coveralls](https://img.shields.io/coveralls/gajus/global-agent.svg?style=flat-square)](https://coveralls.io/github/gajus/global-agent) +[![NPM version](http://img.shields.io/npm/v/global-agent.svg?style=flat-square)](https://www.npmjs.org/package/global-agent) +[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical) +[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas) + +Global HTTP/HTTPS proxy configurable using environment variables. + +* [Usage](#usage) + * [Setup proxy using `global-agent/bootstrap`](#setup-proxy-using-global-agentbootstrap) + * [Setup proxy using `bootstrap` routine](#setup-proxy-using-bootstrap-routine) + * [Runtime configuration](#runtime-configuration) + * [Exclude URLs](#exclude-urls) + * [Enable logging](#enable-logging) +* [API](#api) + * [`createGlobalProxyAgent`](#createglobalproxyagent) + * [Environment variables](#environment-variables) + * [`global.GLOBAL_AGENT`](#globalglobal_agent) +* [Supported libraries](#supported-libraries) +* [FAQ](#faq) + * [What is the reason `global-agent` overrides explicitly configured HTTP(S) agent?](#what-is-the-reason-global-agent-overrides-explicitly-configured-https-agent) + * [What is the reason `global-agent/bootstrap` does not use `HTTP_PROXY`?](#what-is-the-reason-global-agentbootstrap-does-not-use-http_proxy) + * [What is the difference from `global-tunnel` and `tunnel`?](#what-is-the-difference-from-global-tunnel-and-tunnel) + +## Usage + +### Setup proxy using `global-agent/bootstrap` + +To configure HTTP proxy: + +1. Import `global-agent/bootstrap`. +1. Export HTTP proxy address as `GLOBAL_AGENT_HTTP_PROXY` environment variable. + +Code: + +```js +import 'global-agent/bootstrap'; + +// or: +// import {bootstrap} from 'global-agent'; +// bootstrap(); + +``` + +Bash: + +```bash +$ export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080 + +``` + +Alternatively, you can preload module using Node.js `--require, -r` configuration, e.g. + +```bash +$ export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080 +$ node -r 'global-agent/bootstrap' your-script.js + +``` + +### Setup proxy using `bootstrap` routine + +Instead of importing a self-initialising script with side-effects as demonstrated in the [setup proxy using `global-agent/bootstrap`](#setup-proxy-using-global-agentbootstrap) documentation, you can import `bootstrap` routine and explicitly evaluate the bootstrap logic, e.g. + +```js +import { + bootstrap +} from 'global-agent'; + +bootstrap(); + +``` + +This is useful if you need to conditionally bootstrap `global-agent`, e.g. + +```js +import { + bootstrap +} from 'global-agent'; +import globalTunnel from 'global-tunnel-ng'; + +const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10); + +if (MAJOR_NODEJS_VERSION >= 10) { + // `global-agent` works with Node.js v10 and above. + bootstrap(); +} else { + // `global-tunnel-ng` works only with Node.js v10 and below. + globalTunnel.initialize(); +} + +``` + +### Setup proxy using `createGlobalProxyAgent` + +If you do not want to use `global.GLOBAL_AGENT` variable, then you can use `createGlobalProxyAgent` to instantiate a controlled instance of `global-agent`, e.g. + +```js +import { + createGlobalProxyAgent +} from 'global-agent'; + +const globalProxyAgent = createGlobalProxyAgent(); + +``` + +Unlike `bootstrap` routine, `createGlobalProxyAgent` factory does not create `global.GLOBAL_AGENT` variable and does not guard against multiple initializations of `global-agent`. The result object of `createGlobalProxyAgent` is equivalent to `global.GLOBAL_AGENT`. + +### Runtime configuration + +`global-agent/bootstrap` script copies `process.env.GLOBAL_AGENT_HTTP_PROXY` value to `global.GLOBAL_AGENT.HTTP_PROXY` and continues to use the latter variable. + +You can override the `global.GLOBAL_AGENT.HTTP_PROXY` value at runtime to change proxy behaviour, e.g. + +```js +http.get('http://127.0.0.1:8000'); + +global.GLOBAL_AGENT.HTTP_PROXY = 'http://127.0.0.1:8001'; + +http.get('http://127.0.0.1:8000'); + +global.GLOBAL_AGENT.HTTP_PROXY = 'http://127.0.0.1:8002'; + +``` + +The first HTTP request is going to use http://127.0.0.1:8001 proxy and the secord request is going to use http://127.0.0.1:8002. + +All `global-agent` configuration is available under `global.GLOBAL_AGENT` namespace. + +### Exclude URLs + +The `GLOBAL_AGENT_NO_PROXY` environment variable specifies a pattern of URLs that should be excluded from proxying. `GLOBAL_AGENT_NO_PROXY` value is a comma-separated list of domain names. Asterisks can be used as wildcards, e.g. + +```bash +export GLOBAL_AGENT_NO_PROXY='*.foo.com,baz.com' + +``` + +says to contact all machines with the 'foo.com' TLD and 'baz.com' domains directly. + +### Separate proxy for HTTPS + +The environment variable `GLOBAL_AGENT_HTTPS_PROXY` can be set to specify a separate proxy for HTTPS requests. When this variable is not set `GLOBAL_AGENT_HTTP_PROXY` is used for both HTTP and HTTPS requests. + +### Enable logging + +`global-agent` is using [`roarr`](https://www.npmjs.com/package/roarr) logger to log HTTP requests and response (HTTP status code and headers), e.g. + +```json +{"context":{"program":"global-agent","namespace":"Agent","logLevel":10,"destination":"http://gajus.com","proxy":"http://127.0.0.1:8076"},"message":"proxying request","sequence":1,"time":1556269669663,"version":"1.0.0"} +{"context":{"program":"global-agent","namespace":"Agent","logLevel":10,"headers":{"content-type":"text/plain","content-length":"2","date":"Fri, 26 Apr 2019 12:07:50 GMT","connection":"close"},"requestId":6,"statusCode":200},"message":"proxying response","sequence":2,"time":1557133856955,"version":"1.0.0"} + +``` + +Export `ROARR_LOG=true` environment variable to enable log printing to stdout. + +Use [`roarr-cli`](https://github.com/gajus/roarr-cli) program to pretty-print the logs. + +## API + +### `createGlobalProxyAgent` + +```js +/** + * @property environmentVariableNamespace Defines namespace of `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables. (Default: `GLOBAL_AGENT_`) + * @property forceGlobalAgent Forces to use `global-agent` HTTP(S) agent even when request was explicitly constructed with another agent. (Default: `true`) + * @property socketConnectionTimeout Destroys socket if connection is not established within the timeout. (Default: `60000`) + */ +type ProxyAgentConfigurationInputType = {| + +environmentVariableNamespace?: string, + +forceGlobalAgent?: boolean, + +socketConnectionTimeout?: number, +|}; + +(configurationInput: ProxyAgentConfigurationInputType) => ProxyAgentConfigurationType; + +``` + +### Environment variables + +|Name|Description|Default| +|---|---|---| +|`GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE`|Defines namespace of `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables.|`GLOBAL_AGENT_`| +|`GLOBAL_AGENT_FORCE_GLOBAL_AGENT`|Forces to use `global-agent` HTTP(S) agent even when request was explicitly constructed with another agent.|`true`| +|`GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT`|Destroys socket if connection is not established within the timeout.|`60000`| +|`${NAMESPACE}_HTTP_PROXY`|Sets the initial proxy controller HTTP_PROXY value.|N/A| +|`${NAMESPACE}_HTTPS_PROXY`|Sets the initial proxy controller HTTPS_PROXY value.|N/A| +|`${NAMESPACE}_NO_PROXY`|Sets the initial proxy controller NO_PROXY value.|N/A| + +### `global.GLOBAL_AGENT` + +`global.GLOBAL_AGENT` is initialized by `bootstrap` routine. + +`global.GLOBAL_AGENT` has the following properties: + +|Name|Description|Configurable| +|---|---|---| +|`HTTP_PROXY`|Yes|Sets HTTP proxy to use.| +|`HTTPS_PROXY`|Yes|Sets a distinct proxy to use for HTTPS requests.| +|`NO_PROXY`|Yes|Specifies a pattern of URLs that should be excluded from proxying. See [Exclude URLs](#exclude-urls).| + +## Supported libraries + +`global-agent` works with all libraries that internally use [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback). + +`global-agent` has been tested to work with: + +* [`got`](https://www.npmjs.com/package/got) +* [`axios`](https://www.npmjs.com/package/axios) +* [`request`](https://www.npmjs.com/package/axios) + +## FAQ + +### What is the reason `global-agent` overrides explicitly configured HTTP(S) agent? + +By default, `global-agent` overrides [`agent` property](https://nodejs.org/api/http.html#http_http_request_options_callback) of any HTTP request, even if `agent` property was explicitly set when constructing a HTTP request. This behaviour allows to intercept requests of libraries that use a custom instance of an agent per default (e.g. Stripe SDK [uses an `http(s).globalAgent` instance pre-configured with `keepAlive: true`](https://github.com/stripe/stripe-node/blob/e542902dd8fbe591fe3c3ce07a7e89d1d60e4cf7/lib/StripeResource.js#L11-L12)). + +This behaviour can be disabled with `GLOBAL_AGENT_FORCE_GLOBAL_AGENT=false` environment variable. When disabled, then `global-agent` will only set `agent` property when it is not already defined or if `agent` is an instance of `http(s).globalAgent`. + +### What is the reason `global-agent/bootstrap` does not use `HTTP_PROXY`? + +Some libraries (e.g. [`request`](https://npmjs.org/package/request)) change their behaviour when `HTTP_PROXY` environment variable is present. Using a namespaced environment variable prevents conflicting library behaviour. + +You can override this behaviour by configuring `GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE` variable, e.g. + +```bash +$ export GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE= + +``` + +Now script initialized using `global-agent/bootstrap` will use `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables. + +### What is the difference from `global-tunnel` and `tunnel`? + +[`global-tunnel`](https://github.com/salesforce/global-tunnel) (including [`global-tunnel-ng`](https://github.com/np-maintain/global-tunnel) and [`tunnel`](https://npmjs.com/package/tunnel)) are designed to support legacy Node.js versions. They use various [workarounds](https://github.com/koichik/node-tunnel/blob/5fb2fb424788597146b7be6729006cad1cf9e9a8/lib/tunnel.js#L134-L144) and rely on [monkey-patching `http.request`, `http.get`, `https.request` and `https.get` methods](https://github.com/np-maintain/global-tunnel/blob/51413dcf0534252b5049ec213105c7063ccc6367/index.js#L302-L338). + +In contrast, `global-agent` supports Node.js v10 and above, and does not implements workarounds for the older Node.js versions. diff --git a/desktop/node_modules/global-agent/bootstrap.js b/desktop/node_modules/global-agent/bootstrap.js new file mode 100644 index 0000000..0204420 --- /dev/null +++ b/desktop/node_modules/global-agent/bootstrap.js @@ -0,0 +1 @@ +require('./dist/index').bootstrap(); diff --git a/desktop/node_modules/global-agent/dist/Logger.js b/desktop/node_modules/global-agent/dist/Logger.js new file mode 100644 index 0000000..a72a177 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/Logger.js @@ -0,0 +1,18 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _roarr = _interopRequireDefault(require("roarr")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const Logger = _roarr.default.child({ + package: 'global-agent' +}); + +var _default = Logger; +exports.default = _default; +//# sourceMappingURL=Logger.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/Logger.js.flow b/desktop/node_modules/global-agent/dist/Logger.js.flow new file mode 100644 index 0000000..166f1e4 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/Logger.js.flow @@ -0,0 +1,10 @@ +// @flow + +import Roarr from 'roarr'; + +const Logger = Roarr + .child({ + package: 'global-agent', + }); + +export default Logger; diff --git a/desktop/node_modules/global-agent/dist/Logger.js.map b/desktop/node_modules/global-agent/dist/Logger.js.map new file mode 100644 index 0000000..e31661f --- /dev/null +++ b/desktop/node_modules/global-agent/dist/Logger.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/Logger.js"],"names":["Logger","Roarr","child","package"],"mappings":";;;;;;;AAEA;;;;AAEA,MAAMA,MAAM,GAAGC,eACZC,KADY,CACN;AACLC,EAAAA,OAAO,EAAE;AADJ,CADM,CAAf;;eAKeH,M","sourcesContent":["// @flow\n\nimport Roarr from 'roarr';\n\nconst Logger = Roarr\n .child({\n package: 'global-agent',\n });\n\nexport default Logger;\n"],"file":"Logger.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/Agent.js b/desktop/node_modules/global-agent/dist/classes/Agent.js new file mode 100644 index 0000000..ba8cc1a --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/Agent.js @@ -0,0 +1,174 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _serializeError = require("serialize-error"); + +var _boolean = require("boolean"); + +var _Logger = _interopRequireDefault(require("../Logger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const log = _Logger.default.child({ + namespace: 'Agent' +}); + +let requestId = 0; + +class Agent { + constructor(isProxyConfigured, mustUrlUseProxy, getUrlProxy, fallbackAgent, socketConnectionTimeout) { + this.fallbackAgent = fallbackAgent; + this.isProxyConfigured = isProxyConfigured; + this.mustUrlUseProxy = mustUrlUseProxy; + this.getUrlProxy = getUrlProxy; + this.socketConnectionTimeout = socketConnectionTimeout; + } + + addRequest(request, configuration) { + let requestUrl; // It is possible that addRequest was constructed for a proxied request already, e.g. + // "request" package does this when it detects that a proxy should be used + // https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402 + // https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218 + + if (request.path.startsWith('http://') || request.path.startsWith('https://')) { + requestUrl = request.path; + } else { + requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path; + } + + if (!this.isProxyConfigured()) { + log.trace({ + destination: requestUrl + }, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured'); // $FlowFixMe It appears that Flow is missing the method description. + + this.fallbackAgent.addRequest(request, configuration); + return; + } + + if (!this.mustUrlUseProxy(requestUrl)) { + log.trace({ + destination: requestUrl + }, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY'); // $FlowFixMe It appears that Flow is missing the method description. + + this.fallbackAgent.addRequest(request, configuration); + return; + } + + const currentRequestId = requestId++; + const proxy = this.getUrlProxy(requestUrl); + + if (this.protocol === 'http:') { + request.path = requestUrl; + + if (proxy.authorization) { + request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64')); + } + } + + log.trace({ + destination: requestUrl, + proxy: 'http://' + proxy.hostname + ':' + proxy.port, + requestId: currentRequestId + }, 'proxying request'); + request.on('error', error => { + log.error({ + error: (0, _serializeError.serializeError)(error) + }, 'request error'); + }); + request.once('response', response => { + log.trace({ + headers: response.headers, + requestId: currentRequestId, + statusCode: response.statusCode + }, 'proxying response'); + }); + request.shouldKeepAlive = false; + const connectionConfiguration = { + host: configuration.hostname || configuration.host, + port: configuration.port || 80, + proxy, + tls: {} + }; // add optional tls options for https requests. + // @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback : + // > The following additional options from tls.connect() + // > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback - + // > are also accepted: + // > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder, + // > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext. + + if (this.protocol === 'https:') { + connectionConfiguration.tls = { + ca: configuration.ca, + cert: configuration.cert, + ciphers: configuration.ciphers, + clientCertEngine: configuration.clientCertEngine, + crl: configuration.crl, + dhparam: configuration.dhparam, + ecdhCurve: configuration.ecdhCurve, + honorCipherOrder: configuration.honorCipherOrder, + key: configuration.key, + passphrase: configuration.passphrase, + pfx: configuration.pfx, + rejectUnauthorized: configuration.rejectUnauthorized, + secureOptions: configuration.secureOptions, + secureProtocol: configuration.secureProtocol, + servername: configuration.servername || connectionConfiguration.host, + sessionIdContext: configuration.sessionIdContext + }; // This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`. + // However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`, + // which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only. + // + // eslint-disable-next-line no-process-env + + if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && (0, _boolean.boolean)(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) { + connectionConfiguration.tls.rejectUnauthorized = false; + } + } // $FlowFixMe It appears that Flow is missing the method description. + + + this.createConnection(connectionConfiguration, (error, socket) => { + log.trace({ + target: connectionConfiguration + }, 'connecting'); // @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057 + + if (socket) { + socket.setTimeout(this.socketConnectionTimeout, () => { + socket.destroy(); + }); + socket.once('connect', () => { + log.trace({ + target: connectionConfiguration + }, 'connected'); + socket.setTimeout(0); + }); + socket.once('secureConnect', () => { + log.trace({ + target: connectionConfiguration + }, 'connected (secure)'); + socket.setTimeout(0); + }); + } + + if (error) { + request.emit('error', error); + } else { + log.debug('created socket'); + socket.on('error', socketError => { + log.error({ + error: (0, _serializeError.serializeError)(socketError) + }, 'socket error'); + }); + request.onSocket(socket); + } + }); + } + +} + +var _default = Agent; +exports.default = _default; +//# sourceMappingURL=Agent.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/Agent.js.flow b/desktop/node_modules/global-agent/dist/classes/Agent.js.flow new file mode 100644 index 0000000..801dd1f --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/Agent.js.flow @@ -0,0 +1,212 @@ +// @flow + +import { + serializeError, +} from 'serialize-error'; +import { + boolean, +} from 'boolean'; +import Logger from '../Logger'; +import type { + AgentType, + GetUrlProxyMethodType, + IsProxyConfiguredMethodType, + MustUrlUseProxyMethodType, + ProtocolType, +} from '../types'; + +const log = Logger.child({ + namespace: 'Agent', +}); + +let requestId = 0; + +class Agent { + defaultPort: number; + + protocol: ProtocolType; + + fallbackAgent: AgentType; + + isProxyConfigured: IsProxyConfiguredMethodType; + + mustUrlUseProxy: MustUrlUseProxyMethodType; + + getUrlProxy: GetUrlProxyMethodType; + + socketConnectionTimeout: number; + + constructor ( + isProxyConfigured: IsProxyConfiguredMethodType, + mustUrlUseProxy: MustUrlUseProxyMethodType, + getUrlProxy: GetUrlProxyMethodType, + fallbackAgent: AgentType, + socketConnectionTimeout: number, + ) { + this.fallbackAgent = fallbackAgent; + this.isProxyConfigured = isProxyConfigured; + this.mustUrlUseProxy = mustUrlUseProxy; + this.getUrlProxy = getUrlProxy; + this.socketConnectionTimeout = socketConnectionTimeout; + } + + addRequest (request: *, configuration: *) { + let requestUrl; + + // It is possible that addRequest was constructed for a proxied request already, e.g. + // "request" package does this when it detects that a proxy should be used + // https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402 + // https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218 + if (request.path.startsWith('http://') || request.path.startsWith('https://')) { + requestUrl = request.path; + } else { + requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path; + } + + if (!this.isProxyConfigured()) { + log.trace({ + destination: requestUrl, + }, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured'); + + // $FlowFixMe It appears that Flow is missing the method description. + this.fallbackAgent.addRequest(request, configuration); + + return; + } + + if (!this.mustUrlUseProxy(requestUrl)) { + log.trace({ + destination: requestUrl, + }, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY'); + + // $FlowFixMe It appears that Flow is missing the method description. + this.fallbackAgent.addRequest(request, configuration); + + return; + } + + const currentRequestId = requestId++; + + const proxy = this.getUrlProxy(requestUrl); + + if (this.protocol === 'http:') { + request.path = requestUrl; + + if (proxy.authorization) { + request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64')); + } + } + + log.trace({ + destination: requestUrl, + proxy: 'http://' + proxy.hostname + ':' + proxy.port, + requestId: currentRequestId, + }, 'proxying request'); + + request.on('error', (error) => { + log.error({ + error: serializeError(error), + }, 'request error'); + }); + + request.once('response', (response) => { + log.trace({ + headers: response.headers, + requestId: currentRequestId, + statusCode: response.statusCode, + }, 'proxying response'); + }); + + request.shouldKeepAlive = false; + + const connectionConfiguration = { + host: configuration.hostname || configuration.host, + port: configuration.port || 80, + proxy, + tls: {}, + }; + + // add optional tls options for https requests. + // @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback : + // > The following additional options from tls.connect() + // > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback - + // > are also accepted: + // > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder, + // > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext. + if (this.protocol === 'https:') { + connectionConfiguration.tls = { + ca: configuration.ca, + cert: configuration.cert, + ciphers: configuration.ciphers, + clientCertEngine: configuration.clientCertEngine, + crl: configuration.crl, + dhparam: configuration.dhparam, + ecdhCurve: configuration.ecdhCurve, + honorCipherOrder: configuration.honorCipherOrder, + key: configuration.key, + passphrase: configuration.passphrase, + pfx: configuration.pfx, + rejectUnauthorized: configuration.rejectUnauthorized, + secureOptions: configuration.secureOptions, + secureProtocol: configuration.secureProtocol, + servername: configuration.servername || connectionConfiguration.host, + sessionIdContext: configuration.sessionIdContext, + }; + + // This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`. + // However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`, + // which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only. + // + // eslint-disable-next-line no-process-env + if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && boolean(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) { + connectionConfiguration.tls.rejectUnauthorized = false; + } + } + + // $FlowFixMe It appears that Flow is missing the method description. + this.createConnection(connectionConfiguration, (error, socket) => { + log.trace({ + target: connectionConfiguration, + }, 'connecting'); + + // @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057 + if (socket) { + socket.setTimeout(this.socketConnectionTimeout, () => { + socket.destroy(); + }); + + socket.once('connect', () => { + log.trace({ + target: connectionConfiguration, + }, 'connected'); + + socket.setTimeout(0); + }); + + socket.once('secureConnect', () => { + log.trace({ + target: connectionConfiguration, + }, 'connected (secure)'); + + socket.setTimeout(0); + }); + } + + if (error) { + request.emit('error', error); + } else { + log.debug('created socket'); + + socket.on('error', (socketError) => { + log.error({ + error: serializeError(socketError), + }, 'socket error'); + }); + + request.onSocket(socket); + } + }); + } +} + +export default Agent; diff --git a/desktop/node_modules/global-agent/dist/classes/Agent.js.map b/desktop/node_modules/global-agent/dist/classes/Agent.js.map new file mode 100644 index 0000000..af6283e --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/Agent.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/classes/Agent.js"],"names":["log","Logger","child","namespace","requestId","Agent","constructor","isProxyConfigured","mustUrlUseProxy","getUrlProxy","fallbackAgent","socketConnectionTimeout","addRequest","request","configuration","requestUrl","path","startsWith","protocol","hostname","host","port","trace","destination","currentRequestId","proxy","authorization","setHeader","Buffer","from","toString","on","error","once","response","headers","statusCode","shouldKeepAlive","connectionConfiguration","tls","ca","cert","ciphers","clientCertEngine","crl","dhparam","ecdhCurve","honorCipherOrder","key","passphrase","pfx","rejectUnauthorized","secureOptions","secureProtocol","servername","sessionIdContext","process","env","NODE_TLS_REJECT_UNAUTHORIZED","createConnection","socket","target","setTimeout","destroy","emit","debug","socketError","onSocket"],"mappings":";;;;;;;AAEA;;AAGA;;AAGA;;;;AASA,MAAMA,GAAG,GAAGC,gBAAOC,KAAP,CAAa;AACvBC,EAAAA,SAAS,EAAE;AADY,CAAb,CAAZ;;AAIA,IAAIC,SAAS,GAAG,CAAhB;;AAEA,MAAMC,KAAN,CAAY;AAeVC,EAAAA,WAAW,CACTC,iBADS,EAETC,eAFS,EAGTC,WAHS,EAITC,aAJS,EAKTC,uBALS,EAMT;AACA,SAAKD,aAAL,GAAqBA,aAArB;AACA,SAAKH,iBAAL,GAAyBA,iBAAzB;AACA,SAAKC,eAAL,GAAuBA,eAAvB;AACA,SAAKC,WAAL,GAAmBA,WAAnB;AACA,SAAKE,uBAAL,GAA+BA,uBAA/B;AACD;;AAEDC,EAAAA,UAAU,CAAEC,OAAF,EAAcC,aAAd,EAAgC;AACxC,QAAIC,UAAJ,CADwC,CAGxC;AACA;AACA;AACA;;AACA,QAAIF,OAAO,CAACG,IAAR,CAAaC,UAAb,CAAwB,SAAxB,KAAsCJ,OAAO,CAACG,IAAR,CAAaC,UAAb,CAAwB,UAAxB,CAA1C,EAA+E;AAC7EF,MAAAA,UAAU,GAAGF,OAAO,CAACG,IAArB;AACD,KAFD,MAEO;AACLD,MAAAA,UAAU,GAAG,KAAKG,QAAL,GAAgB,IAAhB,IAAwBJ,aAAa,CAACK,QAAd,IAA0BL,aAAa,CAACM,IAAhE,KAAyEN,aAAa,CAACO,IAAd,KAAuB,EAAvB,IAA6BP,aAAa,CAACO,IAAd,KAAuB,GAApD,GAA0D,EAA1D,GAA+D,MAAMP,aAAa,CAACO,IAA5J,IAAoKR,OAAO,CAACG,IAAzL;AACD;;AAED,QAAI,CAAC,KAAKT,iBAAL,EAAL,EAA+B;AAC7BP,MAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRC,QAAAA,WAAW,EAAER;AADL,OAAV,EAEG,iEAFH,EAD6B,CAK7B;;AACA,WAAKL,aAAL,CAAmBE,UAAnB,CAA8BC,OAA9B,EAAuCC,aAAvC;AAEA;AACD;;AAED,QAAI,CAAC,KAAKN,eAAL,CAAqBO,UAArB,CAAL,EAAuC;AACrCf,MAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRC,QAAAA,WAAW,EAAER;AADL,OAAV,EAEG,yDAFH,EADqC,CAKrC;;AACA,WAAKL,aAAL,CAAmBE,UAAnB,CAA8BC,OAA9B,EAAuCC,aAAvC;AAEA;AACD;;AAED,UAAMU,gBAAgB,GAAGpB,SAAS,EAAlC;AAEA,UAAMqB,KAAK,GAAG,KAAKhB,WAAL,CAAiBM,UAAjB,CAAd;;AAEA,QAAI,KAAKG,QAAL,KAAkB,OAAtB,EAA+B;AAC7BL,MAAAA,OAAO,CAACG,IAAR,GAAeD,UAAf;;AAEA,UAAIU,KAAK,CAACC,aAAV,EAAyB;AACvBb,QAAAA,OAAO,CAACc,SAAR,CAAkB,qBAAlB,EAAyC,WAAWC,MAAM,CAACC,IAAP,CAAYJ,KAAK,CAACC,aAAlB,EAAiCI,QAAjC,CAA0C,QAA1C,CAApD;AACD;AACF;;AAED9B,IAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRC,MAAAA,WAAW,EAAER,UADL;AAERU,MAAAA,KAAK,EAAE,YAAYA,KAAK,CAACN,QAAlB,GAA6B,GAA7B,GAAmCM,KAAK,CAACJ,IAFxC;AAGRjB,MAAAA,SAAS,EAAEoB;AAHH,KAAV,EAIG,kBAJH;AAMAX,IAAAA,OAAO,CAACkB,EAAR,CAAW,OAAX,EAAqBC,KAAD,IAAW;AAC7BhC,MAAAA,GAAG,CAACgC,KAAJ,CAAU;AACRA,QAAAA,KAAK,EAAE,oCAAeA,KAAf;AADC,OAAV,EAEG,eAFH;AAGD,KAJD;AAMAnB,IAAAA,OAAO,CAACoB,IAAR,CAAa,UAAb,EAA0BC,QAAD,IAAc;AACrClC,MAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRa,QAAAA,OAAO,EAAED,QAAQ,CAACC,OADV;AAER/B,QAAAA,SAAS,EAAEoB,gBAFH;AAGRY,QAAAA,UAAU,EAAEF,QAAQ,CAACE;AAHb,OAAV,EAIG,mBAJH;AAKD,KAND;AAQAvB,IAAAA,OAAO,CAACwB,eAAR,GAA0B,KAA1B;AAEA,UAAMC,uBAAuB,GAAG;AAC9BlB,MAAAA,IAAI,EAAEN,aAAa,CAACK,QAAd,IAA0BL,aAAa,CAACM,IADhB;AAE9BC,MAAAA,IAAI,EAAEP,aAAa,CAACO,IAAd,IAAsB,EAFE;AAG9BI,MAAAA,KAH8B;AAI9Bc,MAAAA,GAAG,EAAE;AAJyB,KAAhC,CArEwC,CA4ExC;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAI,KAAKrB,QAAL,KAAkB,QAAtB,EAAgC;AAC9BoB,MAAAA,uBAAuB,CAACC,GAAxB,GAA8B;AAC5BC,QAAAA,EAAE,EAAE1B,aAAa,CAAC0B,EADU;AAE5BC,QAAAA,IAAI,EAAE3B,aAAa,CAAC2B,IAFQ;AAG5BC,QAAAA,OAAO,EAAE5B,aAAa,CAAC4B,OAHK;AAI5BC,QAAAA,gBAAgB,EAAE7B,aAAa,CAAC6B,gBAJJ;AAK5BC,QAAAA,GAAG,EAAE9B,aAAa,CAAC8B,GALS;AAM5BC,QAAAA,OAAO,EAAE/B,aAAa,CAAC+B,OANK;AAO5BC,QAAAA,SAAS,EAAEhC,aAAa,CAACgC,SAPG;AAQ5BC,QAAAA,gBAAgB,EAAEjC,aAAa,CAACiC,gBARJ;AAS5BC,QAAAA,GAAG,EAAElC,aAAa,CAACkC,GATS;AAU5BC,QAAAA,UAAU,EAAEnC,aAAa,CAACmC,UAVE;AAW5BC,QAAAA,GAAG,EAAEpC,aAAa,CAACoC,GAXS;AAY5BC,QAAAA,kBAAkB,EAAErC,aAAa,CAACqC,kBAZN;AAa5BC,QAAAA,aAAa,EAAEtC,aAAa,CAACsC,aAbD;AAc5BC,QAAAA,cAAc,EAAEvC,aAAa,CAACuC,cAdF;AAe5BC,QAAAA,UAAU,EAAExC,aAAa,CAACwC,UAAd,IAA4BhB,uBAAuB,CAAClB,IAfpC;AAgB5BmC,QAAAA,gBAAgB,EAAEzC,aAAa,CAACyC;AAhBJ,OAA9B,CAD8B,CAoB9B;AACA;AACA;AACA;AACA;;AACA,UAAI,OAAOC,OAAO,CAACC,GAAR,CAAYC,4BAAnB,KAAoD,QAApD,IAAgE,sBAAQF,OAAO,CAACC,GAAR,CAAYC,4BAApB,MAAsD,KAA1H,EAAiI;AAC/HpB,QAAAA,uBAAuB,CAACC,GAAxB,CAA4BY,kBAA5B,GAAiD,KAAjD;AACD;AACF,KA/GuC,CAiHxC;;;AACA,SAAKQ,gBAAL,CAAsBrB,uBAAtB,EAA+C,CAACN,KAAD,EAAQ4B,MAAR,KAAmB;AAChE5D,MAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRuC,QAAAA,MAAM,EAAEvB;AADA,OAAV,EAEG,YAFH,EADgE,CAKhE;;AACA,UAAIsB,MAAJ,EAAY;AACVA,QAAAA,MAAM,CAACE,UAAP,CAAkB,KAAKnD,uBAAvB,EAAgD,MAAM;AACpDiD,UAAAA,MAAM,CAACG,OAAP;AACD,SAFD;AAIAH,QAAAA,MAAM,CAAC3B,IAAP,CAAY,SAAZ,EAAuB,MAAM;AAC3BjC,UAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRuC,YAAAA,MAAM,EAAEvB;AADA,WAAV,EAEG,WAFH;AAIAsB,UAAAA,MAAM,CAACE,UAAP,CAAkB,CAAlB;AACD,SAND;AAQAF,QAAAA,MAAM,CAAC3B,IAAP,CAAY,eAAZ,EAA6B,MAAM;AACjCjC,UAAAA,GAAG,CAACsB,KAAJ,CAAU;AACRuC,YAAAA,MAAM,EAAEvB;AADA,WAAV,EAEG,oBAFH;AAIAsB,UAAAA,MAAM,CAACE,UAAP,CAAkB,CAAlB;AACD,SAND;AAOD;;AAED,UAAI9B,KAAJ,EAAW;AACTnB,QAAAA,OAAO,CAACmD,IAAR,CAAa,OAAb,EAAsBhC,KAAtB;AACD,OAFD,MAEO;AACLhC,QAAAA,GAAG,CAACiE,KAAJ,CAAU,gBAAV;AAEAL,QAAAA,MAAM,CAAC7B,EAAP,CAAU,OAAV,EAAoBmC,WAAD,IAAiB;AAClClE,UAAAA,GAAG,CAACgC,KAAJ,CAAU;AACRA,YAAAA,KAAK,EAAE,oCAAekC,WAAf;AADC,WAAV,EAEG,cAFH;AAGD,SAJD;AAMArD,QAAAA,OAAO,CAACsD,QAAR,CAAiBP,MAAjB;AACD;AACF,KAzCD;AA0CD;;AAzLS;;eA4LGvD,K","sourcesContent":["// @flow\n\nimport {\n serializeError,\n} from 'serialize-error';\nimport {\n boolean,\n} from 'boolean';\nimport Logger from '../Logger';\nimport type {\n AgentType,\n GetUrlProxyMethodType,\n IsProxyConfiguredMethodType,\n MustUrlUseProxyMethodType,\n ProtocolType,\n} from '../types';\n\nconst log = Logger.child({\n namespace: 'Agent',\n});\n\nlet requestId = 0;\n\nclass Agent {\n defaultPort: number;\n\n protocol: ProtocolType;\n\n fallbackAgent: AgentType;\n\n isProxyConfigured: IsProxyConfiguredMethodType;\n\n mustUrlUseProxy: MustUrlUseProxyMethodType;\n\n getUrlProxy: GetUrlProxyMethodType;\n\n socketConnectionTimeout: number;\n\n constructor (\n isProxyConfigured: IsProxyConfiguredMethodType,\n mustUrlUseProxy: MustUrlUseProxyMethodType,\n getUrlProxy: GetUrlProxyMethodType,\n fallbackAgent: AgentType,\n socketConnectionTimeout: number,\n ) {\n this.fallbackAgent = fallbackAgent;\n this.isProxyConfigured = isProxyConfigured;\n this.mustUrlUseProxy = mustUrlUseProxy;\n this.getUrlProxy = getUrlProxy;\n this.socketConnectionTimeout = socketConnectionTimeout;\n }\n\n addRequest (request: *, configuration: *) {\n let requestUrl;\n\n // It is possible that addRequest was constructed for a proxied request already, e.g.\n // \"request\" package does this when it detects that a proxy should be used\n // https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402\n // https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218\n if (request.path.startsWith('http://') || request.path.startsWith('https://')) {\n requestUrl = request.path;\n } else {\n requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path;\n }\n\n if (!this.isProxyConfigured()) {\n log.trace({\n destination: requestUrl,\n }, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured');\n\n // $FlowFixMe It appears that Flow is missing the method description.\n this.fallbackAgent.addRequest(request, configuration);\n\n return;\n }\n\n if (!this.mustUrlUseProxy(requestUrl)) {\n log.trace({\n destination: requestUrl,\n }, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY');\n\n // $FlowFixMe It appears that Flow is missing the method description.\n this.fallbackAgent.addRequest(request, configuration);\n\n return;\n }\n\n const currentRequestId = requestId++;\n\n const proxy = this.getUrlProxy(requestUrl);\n\n if (this.protocol === 'http:') {\n request.path = requestUrl;\n\n if (proxy.authorization) {\n request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64'));\n }\n }\n\n log.trace({\n destination: requestUrl,\n proxy: 'http://' + proxy.hostname + ':' + proxy.port,\n requestId: currentRequestId,\n }, 'proxying request');\n\n request.on('error', (error) => {\n log.error({\n error: serializeError(error),\n }, 'request error');\n });\n\n request.once('response', (response) => {\n log.trace({\n headers: response.headers,\n requestId: currentRequestId,\n statusCode: response.statusCode,\n }, 'proxying response');\n });\n\n request.shouldKeepAlive = false;\n\n const connectionConfiguration = {\n host: configuration.hostname || configuration.host,\n port: configuration.port || 80,\n proxy,\n tls: {},\n };\n\n // add optional tls options for https requests.\n // @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback :\n // > The following additional options from tls.connect()\n // > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback -\n // > are also accepted:\n // > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder,\n // > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext.\n if (this.protocol === 'https:') {\n connectionConfiguration.tls = {\n ca: configuration.ca,\n cert: configuration.cert,\n ciphers: configuration.ciphers,\n clientCertEngine: configuration.clientCertEngine,\n crl: configuration.crl,\n dhparam: configuration.dhparam,\n ecdhCurve: configuration.ecdhCurve,\n honorCipherOrder: configuration.honorCipherOrder,\n key: configuration.key,\n passphrase: configuration.passphrase,\n pfx: configuration.pfx,\n rejectUnauthorized: configuration.rejectUnauthorized,\n secureOptions: configuration.secureOptions,\n secureProtocol: configuration.secureProtocol,\n servername: configuration.servername || connectionConfiguration.host,\n sessionIdContext: configuration.sessionIdContext,\n };\n\n // This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`.\n // However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`,\n // which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only.\n //\n // eslint-disable-next-line no-process-env\n if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && boolean(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) {\n connectionConfiguration.tls.rejectUnauthorized = false;\n }\n }\n\n // $FlowFixMe It appears that Flow is missing the method description.\n this.createConnection(connectionConfiguration, (error, socket) => {\n log.trace({\n target: connectionConfiguration,\n }, 'connecting');\n\n // @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057\n if (socket) {\n socket.setTimeout(this.socketConnectionTimeout, () => {\n socket.destroy();\n });\n\n socket.once('connect', () => {\n log.trace({\n target: connectionConfiguration,\n }, 'connected');\n\n socket.setTimeout(0);\n });\n\n socket.once('secureConnect', () => {\n log.trace({\n target: connectionConfiguration,\n }, 'connected (secure)');\n\n socket.setTimeout(0);\n });\n }\n\n if (error) {\n request.emit('error', error);\n } else {\n log.debug('created socket');\n\n socket.on('error', (socketError) => {\n log.error({\n error: serializeError(socketError),\n }, 'socket error');\n });\n\n request.onSocket(socket);\n }\n });\n }\n}\n\nexport default Agent;\n"],"file":"Agent.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js b/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js new file mode 100644 index 0000000..6d1c831 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js @@ -0,0 +1,33 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _net = _interopRequireDefault(require("net")); + +var _Agent = _interopRequireDefault(require("./Agent")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +class HttpProxyAgent extends _Agent.default { + // @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290 + // eslint-disable-next-line unicorn/prevent-abbreviations + constructor(...args) { + super(...args); + this.protocol = 'http:'; + this.defaultPort = 80; + } + + createConnection(configuration, callback) { + const socket = _net.default.connect(configuration.proxy.port, configuration.proxy.hostname); + + callback(null, socket); + } + +} + +var _default = HttpProxyAgent; +exports.default = _default; +//# sourceMappingURL=HttpProxyAgent.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js.flow b/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js.flow new file mode 100644 index 0000000..8b9b471 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js.flow @@ -0,0 +1,30 @@ +// @flow + +import net from 'net'; +import type { + ConnectionCallbackType, + ConnectionConfigurationType, +} from '../types'; +import Agent from './Agent'; + +class HttpProxyAgent extends Agent { + // @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290 + // eslint-disable-next-line unicorn/prevent-abbreviations + constructor (...args: *) { + super(...args); + + this.protocol = 'http:'; + this.defaultPort = 80; + } + + createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) { + const socket = net.connect( + configuration.proxy.port, + configuration.proxy.hostname, + ); + + callback(null, socket); + } +} + +export default HttpProxyAgent; diff --git a/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js.map b/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js.map new file mode 100644 index 0000000..f2586b9 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/HttpProxyAgent.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/classes/HttpProxyAgent.js"],"names":["HttpProxyAgent","Agent","constructor","args","protocol","defaultPort","createConnection","configuration","callback","socket","net","connect","proxy","port","hostname"],"mappings":";;;;;;;AAEA;;AAKA;;;;AAEA,MAAMA,cAAN,SAA6BC,cAA7B,CAAmC;AACjC;AACA;AACAC,EAAAA,WAAW,CAAE,GAAGC,IAAL,EAAc;AACvB,UAAM,GAAGA,IAAT;AAEA,SAAKC,QAAL,GAAgB,OAAhB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACD;;AAEDC,EAAAA,gBAAgB,CAAEC,aAAF,EAA8CC,QAA9C,EAAgF;AAC9F,UAAMC,MAAM,GAAGC,aAAIC,OAAJ,CACbJ,aAAa,CAACK,KAAd,CAAoBC,IADP,EAEbN,aAAa,CAACK,KAAd,CAAoBE,QAFP,CAAf;;AAKAN,IAAAA,QAAQ,CAAC,IAAD,EAAOC,MAAP,CAAR;AACD;;AAjBgC;;eAoBpBT,c","sourcesContent":["// @flow\n\nimport net from 'net';\nimport type {\n ConnectionCallbackType,\n ConnectionConfigurationType,\n} from '../types';\nimport Agent from './Agent';\n\nclass HttpProxyAgent extends Agent {\n // @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290\n // eslint-disable-next-line unicorn/prevent-abbreviations\n constructor (...args: *) {\n super(...args);\n\n this.protocol = 'http:';\n this.defaultPort = 80;\n }\n\n createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {\n const socket = net.connect(\n configuration.proxy.port,\n configuration.proxy.hostname,\n );\n\n callback(null, socket);\n }\n}\n\nexport default HttpProxyAgent;\n"],"file":"HttpProxyAgent.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js b/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js new file mode 100644 index 0000000..1206ffa --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js @@ -0,0 +1,53 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _net = _interopRequireDefault(require("net")); + +var _tls = _interopRequireDefault(require("tls")); + +var _Agent = _interopRequireDefault(require("./Agent")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +class HttpsProxyAgent extends _Agent.default { + // eslint-disable-next-line unicorn/prevent-abbreviations + constructor(...args) { + super(...args); + this.protocol = 'https:'; + this.defaultPort = 443; + } + + createConnection(configuration, callback) { + const socket = _net.default.connect(configuration.proxy.port, configuration.proxy.hostname); + + socket.on('error', error => { + callback(error); + }); + socket.once('data', () => { + const secureSocket = _tls.default.connect({ ...configuration.tls, + socket + }); + + callback(null, secureSocket); + }); + let connectMessage = ''; + connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\r\n'; + connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\r\n'; + + if (configuration.proxy.authorization) { + connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\r\n'; + } + + connectMessage += '\r\n'; + socket.write(connectMessage); + } + +} + +var _default = HttpsProxyAgent; +exports.default = _default; +//# sourceMappingURL=HttpsProxyAgent.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.flow b/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.flow new file mode 100644 index 0000000..24d724f --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.flow @@ -0,0 +1,54 @@ +// @flow + +import net from 'net'; +import tls from 'tls'; +import type { + ConnectionCallbackType, + ConnectionConfigurationType, +} from '../types'; +import Agent from './Agent'; + +class HttpsProxyAgent extends Agent { + // eslint-disable-next-line unicorn/prevent-abbreviations + constructor (...args: *) { + super(...args); + + this.protocol = 'https:'; + this.defaultPort = 443; + } + + createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) { + const socket = net.connect( + configuration.proxy.port, + configuration.proxy.hostname, + ); + + socket.on('error', (error) => { + callback(error); + }); + + socket.once('data', () => { + const secureSocket = tls.connect({ + ...configuration.tls, + socket, + }); + + callback(null, secureSocket); + }); + + let connectMessage = ''; + + connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\r\n'; + connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\r\n'; + + if (configuration.proxy.authorization) { + connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\r\n'; + } + + connectMessage += '\r\n'; + + socket.write(connectMessage); + } +} + +export default HttpsProxyAgent; diff --git a/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.map b/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.map new file mode 100644 index 0000000..0bad4a9 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/HttpsProxyAgent.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/classes/HttpsProxyAgent.js"],"names":["HttpsProxyAgent","Agent","constructor","args","protocol","defaultPort","createConnection","configuration","callback","socket","net","connect","proxy","port","hostname","on","error","once","secureSocket","tls","connectMessage","host","authorization","Buffer","from","toString","write"],"mappings":";;;;;;;AAEA;;AACA;;AAKA;;;;AAEA,MAAMA,eAAN,SAA8BC,cAA9B,CAAoC;AAClC;AACAC,EAAAA,WAAW,CAAE,GAAGC,IAAL,EAAc;AACvB,UAAM,GAAGA,IAAT;AAEA,SAAKC,QAAL,GAAgB,QAAhB;AACA,SAAKC,WAAL,GAAmB,GAAnB;AACD;;AAEDC,EAAAA,gBAAgB,CAAEC,aAAF,EAA8CC,QAA9C,EAAgF;AAC9F,UAAMC,MAAM,GAAGC,aAAIC,OAAJ,CACbJ,aAAa,CAACK,KAAd,CAAoBC,IADP,EAEbN,aAAa,CAACK,KAAd,CAAoBE,QAFP,CAAf;;AAKAL,IAAAA,MAAM,CAACM,EAAP,CAAU,OAAV,EAAoBC,KAAD,IAAW;AAC5BR,MAAAA,QAAQ,CAACQ,KAAD,CAAR;AACD,KAFD;AAIAP,IAAAA,MAAM,CAACQ,IAAP,CAAY,MAAZ,EAAoB,MAAM;AACxB,YAAMC,YAAY,GAAGC,aAAIR,OAAJ,CAAY,EAC/B,GAAGJ,aAAa,CAACY,GADc;AAE/BV,QAAAA;AAF+B,OAAZ,CAArB;;AAKAD,MAAAA,QAAQ,CAAC,IAAD,EAAOU,YAAP,CAAR;AACD,KAPD;AASA,QAAIE,cAAc,GAAG,EAArB;AAEAA,IAAAA,cAAc,IAAI,aAAab,aAAa,CAACc,IAA3B,GAAkC,GAAlC,GAAwCd,aAAa,CAACM,IAAtD,GAA6D,eAA/E;AACAO,IAAAA,cAAc,IAAI,WAAWb,aAAa,CAACc,IAAzB,GAAgC,GAAhC,GAAsCd,aAAa,CAACM,IAApD,GAA2D,MAA7E;;AAEA,QAAIN,aAAa,CAACK,KAAd,CAAoBU,aAAxB,EAAuC;AACrCF,MAAAA,cAAc,IAAI,gCAAgCG,MAAM,CAACC,IAAP,CAAYjB,aAAa,CAACK,KAAd,CAAoBU,aAAhC,EAA+CG,QAA/C,CAAwD,QAAxD,CAAhC,GAAoG,MAAtH;AACD;;AAEDL,IAAAA,cAAc,IAAI,MAAlB;AAEAX,IAAAA,MAAM,CAACiB,KAAP,CAAaN,cAAb;AACD;;AAxCiC;;eA2CrBpB,e","sourcesContent":["// @flow\n\nimport net from 'net';\nimport tls from 'tls';\nimport type {\n ConnectionCallbackType,\n ConnectionConfigurationType,\n} from '../types';\nimport Agent from './Agent';\n\nclass HttpsProxyAgent extends Agent {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n constructor (...args: *) {\n super(...args);\n\n this.protocol = 'https:';\n this.defaultPort = 443;\n }\n\n createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) {\n const socket = net.connect(\n configuration.proxy.port,\n configuration.proxy.hostname,\n );\n\n socket.on('error', (error) => {\n callback(error);\n });\n\n socket.once('data', () => {\n const secureSocket = tls.connect({\n ...configuration.tls,\n socket,\n });\n\n callback(null, secureSocket);\n });\n\n let connectMessage = '';\n\n connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\\r\\n';\n connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\\r\\n';\n\n if (configuration.proxy.authorization) {\n connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\\r\\n';\n }\n\n connectMessage += '\\r\\n';\n\n socket.write(connectMessage);\n }\n}\n\nexport default HttpsProxyAgent;\n"],"file":"HttpsProxyAgent.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/index.js b/desktop/node_modules/global-agent/dist/classes/index.js new file mode 100644 index 0000000..b3889d2 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/index.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "Agent", { + enumerable: true, + get: function () { + return _Agent.default; + } +}); +Object.defineProperty(exports, "HttpProxyAgent", { + enumerable: true, + get: function () { + return _HttpProxyAgent.default; + } +}); +Object.defineProperty(exports, "HttpsProxyAgent", { + enumerable: true, + get: function () { + return _HttpsProxyAgent.default; + } +}); + +var _Agent = _interopRequireDefault(require("./Agent")); + +var _HttpProxyAgent = _interopRequireDefault(require("./HttpProxyAgent")); + +var _HttpsProxyAgent = _interopRequireDefault(require("./HttpsProxyAgent")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/classes/index.js.flow b/desktop/node_modules/global-agent/dist/classes/index.js.flow new file mode 100644 index 0000000..9e8418a --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/index.js.flow @@ -0,0 +1,5 @@ +// @flow + +export {default as Agent} from './Agent'; +export {default as HttpProxyAgent} from './HttpProxyAgent'; +export {default as HttpsProxyAgent} from './HttpsProxyAgent'; diff --git a/desktop/node_modules/global-agent/dist/classes/index.js.map b/desktop/node_modules/global-agent/dist/classes/index.js.map new file mode 100644 index 0000000..59a05bb --- /dev/null +++ b/desktop/node_modules/global-agent/dist/classes/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/classes/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA","sourcesContent":["// @flow\n\nexport {default as Agent} from './Agent';\nexport {default as HttpProxyAgent} from './HttpProxyAgent';\nexport {default as HttpsProxyAgent} from './HttpsProxyAgent';\n"],"file":"index.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/errors.js b/desktop/node_modules/global-agent/dist/errors.js new file mode 100644 index 0000000..578d19e --- /dev/null +++ b/desktop/node_modules/global-agent/dist/errors.js @@ -0,0 +1,22 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.UnexpectedStateError = void 0; + +var _es6Error = _interopRequireDefault(require("es6-error")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/* eslint-disable fp/no-class, fp/no-this */ +class UnexpectedStateError extends _es6Error.default { + constructor(message, code = 'UNEXPECTED_STATE_ERROR') { + super(message); + this.code = code; + } + +} + +exports.UnexpectedStateError = UnexpectedStateError; +//# sourceMappingURL=errors.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/errors.js.flow b/desktop/node_modules/global-agent/dist/errors.js.flow new file mode 100644 index 0000000..d93ba6f --- /dev/null +++ b/desktop/node_modules/global-agent/dist/errors.js.flow @@ -0,0 +1,15 @@ +// @flow + +/* eslint-disable fp/no-class, fp/no-this */ + +import ExtendableError from 'es6-error'; + +export class UnexpectedStateError extends ExtendableError { + code: string; + + constructor (message: string, code: string = 'UNEXPECTED_STATE_ERROR') { + super(message); + + this.code = code; + } +} diff --git a/desktop/node_modules/global-agent/dist/errors.js.map b/desktop/node_modules/global-agent/dist/errors.js.map new file mode 100644 index 0000000..7388bd1 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/errors.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/errors.js"],"names":["UnexpectedStateError","ExtendableError","constructor","message","code"],"mappings":";;;;;;;AAIA;;;;AAFA;AAIO,MAAMA,oBAAN,SAAmCC,iBAAnC,CAAmD;AAGxDC,EAAAA,WAAW,CAAEC,OAAF,EAAmBC,IAAY,GAAG,wBAAlC,EAA4D;AACrE,UAAMD,OAAN;AAEA,SAAKC,IAAL,GAAYA,IAAZ;AACD;;AAPuD","sourcesContent":["// @flow\n\n/* eslint-disable fp/no-class, fp/no-this */\n\nimport ExtendableError from 'es6-error';\n\nexport class UnexpectedStateError extends ExtendableError {\n code: string;\n\n constructor (message: string, code: string = 'UNEXPECTED_STATE_ERROR') {\n super(message);\n\n this.code = code;\n }\n}\n"],"file":"errors.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js b/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js new file mode 100644 index 0000000..c87b9ed --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js @@ -0,0 +1,175 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _http = _interopRequireDefault(require("http")); + +var _https = _interopRequireDefault(require("https")); + +var _boolean = require("boolean"); + +var _semver = _interopRequireDefault(require("semver")); + +var _Logger = _interopRequireDefault(require("../Logger")); + +var _classes = require("../classes"); + +var _errors = require("../errors"); + +var _utilities = require("../utilities"); + +var _createProxyController = _interopRequireDefault(require("./createProxyController")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const httpGet = _http.default.get; +const httpRequest = _http.default.request; +const httpsGet = _https.default.get; +const httpsRequest = _https.default.request; + +const log = _Logger.default.child({ + namespace: 'createGlobalProxyAgent' +}); + +const defaultConfigurationInput = { + environmentVariableNamespace: undefined, + forceGlobalAgent: undefined, + socketConnectionTimeout: 60000 +}; + +const omitUndefined = subject => { + const keys = Object.keys(subject); + const result = {}; + + for (const key of keys) { + const value = subject[key]; + + if (value !== undefined) { + result[key] = value; + } + } + + return result; +}; + +const createConfiguration = configurationInput => { + // eslint-disable-next-line no-process-env + const environment = process.env; + const defaultConfiguration = { + environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_', + forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? (0, _boolean.boolean)(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true, + socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? Number.parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout + }; // $FlowFixMe + + return { ...defaultConfiguration, + ...omitUndefined(configurationInput) + }; +}; + +const createGlobalProxyAgent = (configurationInput = defaultConfigurationInput) => { + const configuration = createConfiguration(configurationInput); + const proxyController = (0, _createProxyController.default)(); // eslint-disable-next-line no-process-env + + proxyController.HTTP_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTP_PROXY'] || null; // eslint-disable-next-line no-process-env + + proxyController.HTTPS_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTPS_PROXY'] || null; // eslint-disable-next-line no-process-env + + proxyController.NO_PROXY = process.env[configuration.environmentVariableNamespace + 'NO_PROXY'] || null; + log.info({ + configuration, + state: proxyController + }, 'global agent has been initialized'); + + const mustUrlUseProxy = getProxy => { + return url => { + if (!getProxy()) { + return false; + } + + if (!proxyController.NO_PROXY) { + return true; + } + + return !(0, _utilities.isUrlMatchingNoProxy)(url, proxyController.NO_PROXY); + }; + }; + + const getUrlProxy = getProxy => { + return () => { + const proxy = getProxy(); + + if (!proxy) { + throw new _errors.UnexpectedStateError('HTTP(S) proxy must be configured.'); + } + + return (0, _utilities.parseProxyUrl)(proxy); + }; + }; + + const getHttpProxy = () => { + return proxyController.HTTP_PROXY; + }; + + const BoundHttpProxyAgent = class extends _classes.HttpProxyAgent { + constructor() { + super(() => { + return getHttpProxy(); + }, mustUrlUseProxy(getHttpProxy), getUrlProxy(getHttpProxy), _http.default.globalAgent, configuration.socketConnectionTimeout); + } + + }; + const httpAgent = new BoundHttpProxyAgent(); + + const getHttpsProxy = () => { + return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY; + }; + + const BoundHttpsProxyAgent = class extends _classes.HttpsProxyAgent { + constructor() { + super(() => { + return getHttpsProxy(); + }, mustUrlUseProxy(getHttpsProxy), getUrlProxy(getHttpsProxy), _https.default.globalAgent, configuration.socketConnectionTimeout); + } + + }; + const httpsAgent = new BoundHttpsProxyAgent(); // Overriding globalAgent was added in v11.7. + // @see https://nodejs.org/uk/blog/release/v11.7.0/ + + if (_semver.default.gte(process.version, 'v11.7.0')) { + // @see https://github.com/facebook/flow/issues/7670 + // $FlowFixMe + _http.default.globalAgent = httpAgent; // $FlowFixMe + + _https.default.globalAgent = httpsAgent; + } // The reason this logic is used in addition to overriding http(s).globalAgent + // is because there is no guarantee that we set http(s).globalAgent variable + // before an instance of http(s).Agent has been already constructed by someone, + // e.g. Stripe SDK creates instances of http(s).Agent at the top-level. + // @see https://github.com/gajus/global-agent/pull/13 + // + // We still want to override http(s).globalAgent when possible to enable logic + // in `bindHttpMethod`. + + + if (_semver.default.gte(process.version, 'v10.0.0')) { + // $FlowFixMe + _http.default.get = (0, _utilities.bindHttpMethod)(httpGet, httpAgent, configuration.forceGlobalAgent); // $FlowFixMe + + _http.default.request = (0, _utilities.bindHttpMethod)(httpRequest, httpAgent, configuration.forceGlobalAgent); // $FlowFixMe + + _https.default.get = (0, _utilities.bindHttpMethod)(httpsGet, httpsAgent, configuration.forceGlobalAgent); // $FlowFixMe + + _https.default.request = (0, _utilities.bindHttpMethod)(httpsRequest, httpsAgent, configuration.forceGlobalAgent); + } else { + log.warn('attempt to initialize global-agent in unsupported Node.js version was ignored'); + } + + return proxyController; +}; + +var _default = createGlobalProxyAgent; +exports.default = _default; +//# sourceMappingURL=createGlobalProxyAgent.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js.flow b/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js.flow new file mode 100644 index 0000000..d515a9d --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js.flow @@ -0,0 +1,197 @@ +// @flow + +import http from 'http'; +import https from 'https'; +import { + boolean as parseBoolean, +} from 'boolean'; +import semver from 'semver'; +import Logger from '../Logger'; +import { + HttpProxyAgent, + HttpsProxyAgent, +} from '../classes'; +import { + UnexpectedStateError, +} from '../errors'; +import { + bindHttpMethod, + isUrlMatchingNoProxy, + parseProxyUrl, +} from '../utilities'; +import type { + ProxyAgentConfigurationInputType, + ProxyAgentConfigurationType, +} from '../types'; +import createProxyController from './createProxyController'; + +const httpGet = http.get; +const httpRequest = http.request; +const httpsGet = https.get; +const httpsRequest = https.request; + +const log = Logger.child({ + namespace: 'createGlobalProxyAgent', +}); + +const defaultConfigurationInput = { + environmentVariableNamespace: undefined, + forceGlobalAgent: undefined, + socketConnectionTimeout: 60000, +}; + +const omitUndefined = (subject) => { + const keys = Object.keys(subject); + + const result = {}; + + for (const key of keys) { + const value = subject[key]; + + if (value !== undefined) { + result[key] = value; + } + } + + return result; +}; + +const createConfiguration = (configurationInput: ProxyAgentConfigurationInputType): ProxyAgentConfigurationType => { + // eslint-disable-next-line no-process-env + const environment = process.env; + + const defaultConfiguration = { + environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_', + forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? parseBoolean(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true, + socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? Number.parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout, + }; + + // $FlowFixMe + return { + ...defaultConfiguration, + ...omitUndefined(configurationInput), + }; +}; + +export default (configurationInput: ProxyAgentConfigurationInputType = defaultConfigurationInput) => { + const configuration = createConfiguration(configurationInput); + + const proxyController = createProxyController(); + + // eslint-disable-next-line no-process-env + proxyController.HTTP_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTP_PROXY'] || null; + + // eslint-disable-next-line no-process-env + proxyController.HTTPS_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTPS_PROXY'] || null; + + // eslint-disable-next-line no-process-env + proxyController.NO_PROXY = process.env[configuration.environmentVariableNamespace + 'NO_PROXY'] || null; + + log.info({ + configuration, + state: proxyController, + }, 'global agent has been initialized'); + + const mustUrlUseProxy = (getProxy) => { + return (url) => { + if (!getProxy()) { + return false; + } + + if (!proxyController.NO_PROXY) { + return true; + } + + return !isUrlMatchingNoProxy(url, proxyController.NO_PROXY); + }; + }; + + const getUrlProxy = (getProxy) => { + return () => { + const proxy = getProxy(); + + if (!proxy) { + throw new UnexpectedStateError('HTTP(S) proxy must be configured.'); + } + + return parseProxyUrl(proxy); + }; + }; + + const getHttpProxy = () => { + return proxyController.HTTP_PROXY; + }; + + const BoundHttpProxyAgent = class extends HttpProxyAgent { + constructor () { + super( + () => { + return getHttpProxy(); + }, + mustUrlUseProxy(getHttpProxy), + getUrlProxy(getHttpProxy), + http.globalAgent, + configuration.socketConnectionTimeout, + ); + } + }; + + const httpAgent = new BoundHttpProxyAgent(); + + const getHttpsProxy = () => { + return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY; + }; + + const BoundHttpsProxyAgent = class extends HttpsProxyAgent { + constructor () { + super( + () => { + return getHttpsProxy(); + }, + mustUrlUseProxy(getHttpsProxy), + getUrlProxy(getHttpsProxy), + https.globalAgent, + configuration.socketConnectionTimeout, + ); + } + }; + + const httpsAgent = new BoundHttpsProxyAgent(); + + // Overriding globalAgent was added in v11.7. + // @see https://nodejs.org/uk/blog/release/v11.7.0/ + if (semver.gte(process.version, 'v11.7.0')) { + // @see https://github.com/facebook/flow/issues/7670 + // $FlowFixMe + http.globalAgent = httpAgent; + + // $FlowFixMe + https.globalAgent = httpsAgent; + } + + // The reason this logic is used in addition to overriding http(s).globalAgent + // is because there is no guarantee that we set http(s).globalAgent variable + // before an instance of http(s).Agent has been already constructed by someone, + // e.g. Stripe SDK creates instances of http(s).Agent at the top-level. + // @see https://github.com/gajus/global-agent/pull/13 + // + // We still want to override http(s).globalAgent when possible to enable logic + // in `bindHttpMethod`. + if (semver.gte(process.version, 'v10.0.0')) { + // $FlowFixMe + http.get = bindHttpMethod(httpGet, httpAgent, configuration.forceGlobalAgent); + + // $FlowFixMe + http.request = bindHttpMethod(httpRequest, httpAgent, configuration.forceGlobalAgent); + + // $FlowFixMe + https.get = bindHttpMethod(httpsGet, httpsAgent, configuration.forceGlobalAgent); + + // $FlowFixMe + https.request = bindHttpMethod(httpsRequest, httpsAgent, configuration.forceGlobalAgent); + } else { + log.warn('attempt to initialize global-agent in unsupported Node.js version was ignored'); + } + + return proxyController; +}; diff --git a/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js.map b/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js.map new file mode 100644 index 0000000..00b69f9 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/createGlobalProxyAgent.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/factories/createGlobalProxyAgent.js"],"names":["httpGet","http","get","httpRequest","request","httpsGet","https","httpsRequest","log","Logger","child","namespace","defaultConfigurationInput","environmentVariableNamespace","undefined","forceGlobalAgent","socketConnectionTimeout","omitUndefined","subject","keys","Object","result","key","value","createConfiguration","configurationInput","environment","process","env","defaultConfiguration","GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE","GLOBAL_AGENT_FORCE_GLOBAL_AGENT","GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT","Number","parseInt","configuration","proxyController","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","info","state","mustUrlUseProxy","getProxy","url","getUrlProxy","proxy","UnexpectedStateError","getHttpProxy","BoundHttpProxyAgent","HttpProxyAgent","constructor","globalAgent","httpAgent","getHttpsProxy","BoundHttpsProxyAgent","HttpsProxyAgent","httpsAgent","semver","gte","version","warn"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AAIA;;AAGA;;AASA;;;;AAEA,MAAMA,OAAO,GAAGC,cAAKC,GAArB;AACA,MAAMC,WAAW,GAAGF,cAAKG,OAAzB;AACA,MAAMC,QAAQ,GAAGC,eAAMJ,GAAvB;AACA,MAAMK,YAAY,GAAGD,eAAMF,OAA3B;;AAEA,MAAMI,GAAG,GAAGC,gBAAOC,KAAP,CAAa;AACvBC,EAAAA,SAAS,EAAE;AADY,CAAb,CAAZ;;AAIA,MAAMC,yBAAyB,GAAG;AAChCC,EAAAA,4BAA4B,EAAEC,SADE;AAEhCC,EAAAA,gBAAgB,EAAED,SAFc;AAGhCE,EAAAA,uBAAuB,EAAE;AAHO,CAAlC;;AAMA,MAAMC,aAAa,GAAIC,OAAD,IAAa;AACjC,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYD,OAAZ,CAAb;AAEA,QAAMG,MAAM,GAAG,EAAf;;AAEA,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACtB,UAAMI,KAAK,GAAGL,OAAO,CAACI,GAAD,CAArB;;AAEA,QAAIC,KAAK,KAAKT,SAAd,EAAyB;AACvBO,MAAAA,MAAM,CAACC,GAAD,CAAN,GAAcC,KAAd;AACD;AACF;;AAED,SAAOF,MAAP;AACD,CAdD;;AAgBA,MAAMG,mBAAmB,GAAIC,kBAAD,IAAuF;AACjH;AACA,QAAMC,WAAW,GAAGC,OAAO,CAACC,GAA5B;AAEA,QAAMC,oBAAoB,GAAG;AAC3BhB,IAAAA,4BAA4B,EAAE,OAAOa,WAAW,CAACI,2CAAnB,KAAmE,QAAnE,GAA8EJ,WAAW,CAACI,2CAA1F,GAAwI,eAD3I;AAE3Bf,IAAAA,gBAAgB,EAAE,OAAOW,WAAW,CAACK,+BAAnB,KAAuD,QAAvD,GAAkE,sBAAaL,WAAW,CAACK,+BAAzB,CAAlE,GAA8H,IAFrH;AAG3Bf,IAAAA,uBAAuB,EAAE,OAAOU,WAAW,CAACM,sCAAnB,KAA8D,QAA9D,GAAyEC,MAAM,CAACC,QAAP,CAAgBR,WAAW,CAACM,sCAA5B,EAAoE,EAApE,CAAzE,GAAmJpB,yBAAyB,CAACI;AAH3K,GAA7B,CAJiH,CAUjH;;AACA,SAAO,EACL,GAAGa,oBADE;AAEL,OAAGZ,aAAa,CAACQ,kBAAD;AAFX,GAAP;AAID,CAfD;;gCAiBgBA,kBAAoD,GAAGb,yB,KAA8B;AACnG,QAAMuB,aAAa,GAAGX,mBAAmB,CAACC,kBAAD,CAAzC;AAEA,QAAMW,eAAe,GAAG,qCAAxB,CAHmG,CAKnG;;AACAA,EAAAA,eAAe,CAACC,UAAhB,GAA6BV,OAAO,CAACC,GAAR,CAAYO,aAAa,CAACtB,4BAAd,GAA6C,YAAzD,KAA0E,IAAvG,CANmG,CAQnG;;AACAuB,EAAAA,eAAe,CAACE,WAAhB,GAA8BX,OAAO,CAACC,GAAR,CAAYO,aAAa,CAACtB,4BAAd,GAA6C,aAAzD,KAA2E,IAAzG,CATmG,CAWnG;;AACAuB,EAAAA,eAAe,CAACG,QAAhB,GAA2BZ,OAAO,CAACC,GAAR,CAAYO,aAAa,CAACtB,4BAAd,GAA6C,UAAzD,KAAwE,IAAnG;AAEAL,EAAAA,GAAG,CAACgC,IAAJ,CAAS;AACPL,IAAAA,aADO;AAEPM,IAAAA,KAAK,EAAEL;AAFA,GAAT,EAGG,mCAHH;;AAKA,QAAMM,eAAe,GAAIC,QAAD,IAAc;AACpC,WAAQC,GAAD,IAAS;AACd,UAAI,CAACD,QAAQ,EAAb,EAAiB;AACf,eAAO,KAAP;AACD;;AAED,UAAI,CAACP,eAAe,CAACG,QAArB,EAA+B;AAC7B,eAAO,IAAP;AACD;;AAED,aAAO,CAAC,qCAAqBK,GAArB,EAA0BR,eAAe,CAACG,QAA1C,CAAR;AACD,KAVD;AAWD,GAZD;;AAcA,QAAMM,WAAW,GAAIF,QAAD,IAAc;AAChC,WAAO,MAAM;AACX,YAAMG,KAAK,GAAGH,QAAQ,EAAtB;;AAEA,UAAI,CAACG,KAAL,EAAY;AACV,cAAM,IAAIC,4BAAJ,CAAyB,mCAAzB,CAAN;AACD;;AAED,aAAO,8BAAcD,KAAd,CAAP;AACD,KARD;AASD,GAVD;;AAYA,QAAME,YAAY,GAAG,MAAM;AACzB,WAAOZ,eAAe,CAACC,UAAvB;AACD,GAFD;;AAIA,QAAMY,mBAAmB,GAAG,cAAcC,uBAAd,CAA6B;AACvDC,IAAAA,WAAW,GAAI;AACb,YACE,MAAM;AACJ,eAAOH,YAAY,EAAnB;AACD,OAHH,EAIEN,eAAe,CAACM,YAAD,CAJjB,EAKEH,WAAW,CAACG,YAAD,CALb,EAME/C,cAAKmD,WANP,EAOEjB,aAAa,CAACnB,uBAPhB;AASD;;AAXsD,GAAzD;AAcA,QAAMqC,SAAS,GAAG,IAAIJ,mBAAJ,EAAlB;;AAEA,QAAMK,aAAa,GAAG,MAAM;AAC1B,WAAOlB,eAAe,CAACE,WAAhB,IAA+BF,eAAe,CAACC,UAAtD;AACD,GAFD;;AAIA,QAAMkB,oBAAoB,GAAG,cAAcC,wBAAd,CAA8B;AACzDL,IAAAA,WAAW,GAAI;AACb,YACE,MAAM;AACJ,eAAOG,aAAa,EAApB;AACD,OAHH,EAIEZ,eAAe,CAACY,aAAD,CAJjB,EAKET,WAAW,CAACS,aAAD,CALb,EAMEhD,eAAM8C,WANR,EAOEjB,aAAa,CAACnB,uBAPhB;AASD;;AAXwD,GAA3D;AAcA,QAAMyC,UAAU,GAAG,IAAIF,oBAAJ,EAAnB,CAnFmG,CAqFnG;AACA;;AACA,MAAIG,gBAAOC,GAAP,CAAWhC,OAAO,CAACiC,OAAnB,EAA4B,SAA5B,CAAJ,EAA4C;AAC1C;AACA;AACA3D,kBAAKmD,WAAL,GAAmBC,SAAnB,CAH0C,CAK1C;;AACA/C,mBAAM8C,WAAN,GAAoBK,UAApB;AACD,GA9FkG,CAgGnG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAIC,gBAAOC,GAAP,CAAWhC,OAAO,CAACiC,OAAnB,EAA4B,SAA5B,CAAJ,EAA4C;AAC1C;AACA3D,kBAAKC,GAAL,GAAW,+BAAeF,OAAf,EAAwBqD,SAAxB,EAAmClB,aAAa,CAACpB,gBAAjD,CAAX,CAF0C,CAI1C;;AACAd,kBAAKG,OAAL,GAAe,+BAAeD,WAAf,EAA4BkD,SAA5B,EAAuClB,aAAa,CAACpB,gBAArD,CAAf,CAL0C,CAO1C;;AACAT,mBAAMJ,GAAN,GAAY,+BAAeG,QAAf,EAAyBoD,UAAzB,EAAqCtB,aAAa,CAACpB,gBAAnD,CAAZ,CAR0C,CAU1C;;AACAT,mBAAMF,OAAN,GAAgB,+BAAeG,YAAf,EAA6BkD,UAA7B,EAAyCtB,aAAa,CAACpB,gBAAvD,CAAhB;AACD,GAZD,MAYO;AACLP,IAAAA,GAAG,CAACqD,IAAJ,CAAS,+EAAT;AACD;;AAED,SAAOzB,eAAP;AACD,C","sourcesContent":["// @flow\n\nimport http from 'http';\nimport https from 'https';\nimport {\n boolean as parseBoolean,\n} from 'boolean';\nimport semver from 'semver';\nimport Logger from '../Logger';\nimport {\n HttpProxyAgent,\n HttpsProxyAgent,\n} from '../classes';\nimport {\n UnexpectedStateError,\n} from '../errors';\nimport {\n bindHttpMethod,\n isUrlMatchingNoProxy,\n parseProxyUrl,\n} from '../utilities';\nimport type {\n ProxyAgentConfigurationInputType,\n ProxyAgentConfigurationType,\n} from '../types';\nimport createProxyController from './createProxyController';\n\nconst httpGet = http.get;\nconst httpRequest = http.request;\nconst httpsGet = https.get;\nconst httpsRequest = https.request;\n\nconst log = Logger.child({\n namespace: 'createGlobalProxyAgent',\n});\n\nconst defaultConfigurationInput = {\n environmentVariableNamespace: undefined,\n forceGlobalAgent: undefined,\n socketConnectionTimeout: 60000,\n};\n\nconst omitUndefined = (subject) => {\n const keys = Object.keys(subject);\n\n const result = {};\n\n for (const key of keys) {\n const value = subject[key];\n\n if (value !== undefined) {\n result[key] = value;\n }\n }\n\n return result;\n};\n\nconst createConfiguration = (configurationInput: ProxyAgentConfigurationInputType): ProxyAgentConfigurationType => {\n // eslint-disable-next-line no-process-env\n const environment = process.env;\n\n const defaultConfiguration = {\n environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_',\n forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? parseBoolean(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true,\n socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? Number.parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout,\n };\n\n // $FlowFixMe\n return {\n ...defaultConfiguration,\n ...omitUndefined(configurationInput),\n };\n};\n\nexport default (configurationInput: ProxyAgentConfigurationInputType = defaultConfigurationInput) => {\n const configuration = createConfiguration(configurationInput);\n\n const proxyController = createProxyController();\n\n // eslint-disable-next-line no-process-env\n proxyController.HTTP_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTP_PROXY'] || null;\n\n // eslint-disable-next-line no-process-env\n proxyController.HTTPS_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTPS_PROXY'] || null;\n\n // eslint-disable-next-line no-process-env\n proxyController.NO_PROXY = process.env[configuration.environmentVariableNamespace + 'NO_PROXY'] || null;\n\n log.info({\n configuration,\n state: proxyController,\n }, 'global agent has been initialized');\n\n const mustUrlUseProxy = (getProxy) => {\n return (url) => {\n if (!getProxy()) {\n return false;\n }\n\n if (!proxyController.NO_PROXY) {\n return true;\n }\n\n return !isUrlMatchingNoProxy(url, proxyController.NO_PROXY);\n };\n };\n\n const getUrlProxy = (getProxy) => {\n return () => {\n const proxy = getProxy();\n\n if (!proxy) {\n throw new UnexpectedStateError('HTTP(S) proxy must be configured.');\n }\n\n return parseProxyUrl(proxy);\n };\n };\n\n const getHttpProxy = () => {\n return proxyController.HTTP_PROXY;\n };\n\n const BoundHttpProxyAgent = class extends HttpProxyAgent {\n constructor () {\n super(\n () => {\n return getHttpProxy();\n },\n mustUrlUseProxy(getHttpProxy),\n getUrlProxy(getHttpProxy),\n http.globalAgent,\n configuration.socketConnectionTimeout,\n );\n }\n };\n\n const httpAgent = new BoundHttpProxyAgent();\n\n const getHttpsProxy = () => {\n return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY;\n };\n\n const BoundHttpsProxyAgent = class extends HttpsProxyAgent {\n constructor () {\n super(\n () => {\n return getHttpsProxy();\n },\n mustUrlUseProxy(getHttpsProxy),\n getUrlProxy(getHttpsProxy),\n https.globalAgent,\n configuration.socketConnectionTimeout,\n );\n }\n };\n\n const httpsAgent = new BoundHttpsProxyAgent();\n\n // Overriding globalAgent was added in v11.7.\n // @see https://nodejs.org/uk/blog/release/v11.7.0/\n if (semver.gte(process.version, 'v11.7.0')) {\n // @see https://github.com/facebook/flow/issues/7670\n // $FlowFixMe\n http.globalAgent = httpAgent;\n\n // $FlowFixMe\n https.globalAgent = httpsAgent;\n }\n\n // The reason this logic is used in addition to overriding http(s).globalAgent\n // is because there is no guarantee that we set http(s).globalAgent variable\n // before an instance of http(s).Agent has been already constructed by someone,\n // e.g. Stripe SDK creates instances of http(s).Agent at the top-level.\n // @see https://github.com/gajus/global-agent/pull/13\n //\n // We still want to override http(s).globalAgent when possible to enable logic\n // in `bindHttpMethod`.\n if (semver.gte(process.version, 'v10.0.0')) {\n // $FlowFixMe\n http.get = bindHttpMethod(httpGet, httpAgent, configuration.forceGlobalAgent);\n\n // $FlowFixMe\n http.request = bindHttpMethod(httpRequest, httpAgent, configuration.forceGlobalAgent);\n\n // $FlowFixMe\n https.get = bindHttpMethod(httpsGet, httpsAgent, configuration.forceGlobalAgent);\n\n // $FlowFixMe\n https.request = bindHttpMethod(httpsRequest, httpsAgent, configuration.forceGlobalAgent);\n } else {\n log.warn('attempt to initialize global-agent in unsupported Node.js version was ignored');\n }\n\n return proxyController;\n};\n"],"file":"createGlobalProxyAgent.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/factories/createProxyController.js b/desktop/node_modules/global-agent/dist/factories/createProxyController.js new file mode 100644 index 0000000..7746081 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/createProxyController.js @@ -0,0 +1,45 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _Logger = _interopRequireDefault(require("../Logger")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const log = _Logger.default.child({ + namespace: 'createProxyController' +}); + +const KNOWN_PROPERTY_NAMES = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY']; + +const createProxyController = () => { + // eslint-disable-next-line fp/no-proxy + return new Proxy({ + HTTP_PROXY: null, + HTTPS_PROXY: null, + NO_PROXY: null + }, { + set: (subject, name, value) => { + if (!KNOWN_PROPERTY_NAMES.includes(name)) { + throw new Error('Cannot set an unmapped property "' + name + '".'); + } + + subject[name] = value; + log.info({ + change: { + name, + value + }, + newConfiguration: subject + }, 'configuration changed'); + return true; + } + }); +}; + +var _default = createProxyController; +exports.default = _default; +//# sourceMappingURL=createProxyController.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/factories/createProxyController.js.flow b/desktop/node_modules/global-agent/dist/factories/createProxyController.js.flow new file mode 100644 index 0000000..5805ec8 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/createProxyController.js.flow @@ -0,0 +1,46 @@ +// @flow + +import Logger from '../Logger'; + +type ProxyControllerType = {| + HTTP_PROXY: string | null, + HTTPS_PROXY: string | null, + NO_PROXY: string | null, +|}; + +const log = Logger.child({ + namespace: 'createProxyController', +}); + +const KNOWN_PROPERTY_NAMES = [ + 'HTTP_PROXY', + 'HTTPS_PROXY', + 'NO_PROXY', +]; + +export default (): ProxyControllerType => { + // eslint-disable-next-line fp/no-proxy + return new Proxy({ + HTTP_PROXY: null, + HTTPS_PROXY: null, + NO_PROXY: null, + }, { + set: (subject, name, value) => { + if (!KNOWN_PROPERTY_NAMES.includes(name)) { + throw new Error('Cannot set an unmapped property "' + name + '".'); + } + + subject[name] = value; + + log.info({ + change: { + name, + value, + }, + newConfiguration: subject, + }, 'configuration changed'); + + return true; + }, + }); +}; diff --git a/desktop/node_modules/global-agent/dist/factories/createProxyController.js.map b/desktop/node_modules/global-agent/dist/factories/createProxyController.js.map new file mode 100644 index 0000000..da7b0e7 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/createProxyController.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/factories/createProxyController.js"],"names":["log","Logger","child","namespace","KNOWN_PROPERTY_NAMES","Proxy","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","set","subject","name","value","includes","Error","info","change","newConfiguration"],"mappings":";;;;;;;AAEA;;;;AAQA,MAAMA,GAAG,GAAGC,gBAAOC,KAAP,CAAa;AACvBC,EAAAA,SAAS,EAAE;AADY,CAAb,CAAZ;;AAIA,MAAMC,oBAAoB,GAAG,CAC3B,YAD2B,EAE3B,aAF2B,EAG3B,UAH2B,CAA7B;;oCAM0C;AACxC;AACA,SAAO,IAAIC,KAAJ,CAAU;AACfC,IAAAA,UAAU,EAAE,IADG;AAEfC,IAAAA,WAAW,EAAE,IAFE;AAGfC,IAAAA,QAAQ,EAAE;AAHK,GAAV,EAIJ;AACDC,IAAAA,GAAG,EAAE,CAACC,OAAD,EAAUC,IAAV,EAAgBC,KAAhB,KAA0B;AAC7B,UAAI,CAACR,oBAAoB,CAACS,QAArB,CAA8BF,IAA9B,CAAL,EAA0C;AACxC,cAAM,IAAIG,KAAJ,CAAU,sCAAsCH,IAAtC,GAA6C,IAAvD,CAAN;AACD;;AAEDD,MAAAA,OAAO,CAACC,IAAD,CAAP,GAAgBC,KAAhB;AAEAZ,MAAAA,GAAG,CAACe,IAAJ,CAAS;AACPC,QAAAA,MAAM,EAAE;AACNL,UAAAA,IADM;AAENC,UAAAA;AAFM,SADD;AAKPK,QAAAA,gBAAgB,EAAEP;AALX,OAAT,EAMG,uBANH;AAQA,aAAO,IAAP;AACD;AAjBA,GAJI,CAAP;AAuBD,C","sourcesContent":["// @flow\n\nimport Logger from '../Logger';\n\ntype ProxyControllerType = {|\n HTTP_PROXY: string | null,\n HTTPS_PROXY: string | null,\n NO_PROXY: string | null,\n|};\n\nconst log = Logger.child({\n namespace: 'createProxyController',\n});\n\nconst KNOWN_PROPERTY_NAMES = [\n 'HTTP_PROXY',\n 'HTTPS_PROXY',\n 'NO_PROXY',\n];\n\nexport default (): ProxyControllerType => {\n // eslint-disable-next-line fp/no-proxy\n return new Proxy({\n HTTP_PROXY: null,\n HTTPS_PROXY: null,\n NO_PROXY: null,\n }, {\n set: (subject, name, value) => {\n if (!KNOWN_PROPERTY_NAMES.includes(name)) {\n throw new Error('Cannot set an unmapped property \"' + name + '\".');\n }\n\n subject[name] = value;\n\n log.info({\n change: {\n name,\n value,\n },\n newConfiguration: subject,\n }, 'configuration changed');\n\n return true;\n },\n });\n};\n"],"file":"createProxyController.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/factories/index.js b/desktop/node_modules/global-agent/dist/factories/index.js new file mode 100644 index 0000000..3193022 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/index.js @@ -0,0 +1,24 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "createGlobalProxyAgent", { + enumerable: true, + get: function () { + return _createGlobalProxyAgent.default; + } +}); +Object.defineProperty(exports, "createProxyController", { + enumerable: true, + get: function () { + return _createProxyController.default; + } +}); + +var _createGlobalProxyAgent = _interopRequireDefault(require("./createGlobalProxyAgent")); + +var _createProxyController = _interopRequireDefault(require("./createProxyController")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/factories/index.js.flow b/desktop/node_modules/global-agent/dist/factories/index.js.flow new file mode 100644 index 0000000..c16eca6 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/index.js.flow @@ -0,0 +1,4 @@ +// @flow + +export {default as createGlobalProxyAgent} from './createGlobalProxyAgent'; +export {default as createProxyController} from './createProxyController'; diff --git a/desktop/node_modules/global-agent/dist/factories/index.js.map b/desktop/node_modules/global-agent/dist/factories/index.js.map new file mode 100644 index 0000000..2e61240 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/factories/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/factories/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;AACA","sourcesContent":["// @flow\n\nexport {default as createGlobalProxyAgent} from './createGlobalProxyAgent';\nexport {default as createProxyController} from './createProxyController';\n"],"file":"index.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/index.js b/desktop/node_modules/global-agent/dist/index.js new file mode 100644 index 0000000..242a88a --- /dev/null +++ b/desktop/node_modules/global-agent/dist/index.js @@ -0,0 +1,22 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "bootstrap", { + enumerable: true, + get: function () { + return _routines.bootstrap; + } +}); +Object.defineProperty(exports, "createGlobalProxyAgent", { + enumerable: true, + get: function () { + return _factories.createGlobalProxyAgent; + } +}); + +var _routines = require("./routines"); + +var _factories = require("./factories"); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/index.js.flow b/desktop/node_modules/global-agent/dist/index.js.flow new file mode 100644 index 0000000..14da1ba --- /dev/null +++ b/desktop/node_modules/global-agent/dist/index.js.flow @@ -0,0 +1,4 @@ +// @flow + +export {bootstrap} from './routines'; +export {createGlobalProxyAgent} from './factories'; diff --git a/desktop/node_modules/global-agent/dist/index.js.map b/desktop/node_modules/global-agent/dist/index.js.map new file mode 100644 index 0000000..42901df --- /dev/null +++ b/desktop/node_modules/global-agent/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;AACA","sourcesContent":["// @flow\n\nexport {bootstrap} from './routines';\nexport {createGlobalProxyAgent} from './factories';\n"],"file":"index.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/routines/bootstrap.js b/desktop/node_modules/global-agent/dist/routines/bootstrap.js new file mode 100644 index 0000000..444df53 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/routines/bootstrap.js @@ -0,0 +1,30 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _Logger = _interopRequireDefault(require("../Logger")); + +var _factories = require("../factories"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const log = _Logger.default.child({ + namespace: 'bootstrap' +}); + +const bootstrap = configurationInput => { + if (global.GLOBAL_AGENT) { + log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored'); + return false; + } + + global.GLOBAL_AGENT = (0, _factories.createGlobalProxyAgent)(configurationInput); + return true; +}; + +var _default = bootstrap; +exports.default = _default; +//# sourceMappingURL=bootstrap.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/routines/bootstrap.js.flow b/desktop/node_modules/global-agent/dist/routines/bootstrap.js.flow new file mode 100644 index 0000000..038feb3 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/routines/bootstrap.js.flow @@ -0,0 +1,25 @@ +// @flow + +import Logger from '../Logger'; +import { + createGlobalProxyAgent, +} from '../factories'; +import type { + ProxyAgentConfigurationInputType, +} from '../types'; + +const log = Logger.child({ + namespace: 'bootstrap', +}); + +export default (configurationInput?: ProxyAgentConfigurationInputType): boolean => { + if (global.GLOBAL_AGENT) { + log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored'); + + return false; + } + + global.GLOBAL_AGENT = createGlobalProxyAgent(configurationInput); + + return true; +}; diff --git a/desktop/node_modules/global-agent/dist/routines/bootstrap.js.map b/desktop/node_modules/global-agent/dist/routines/bootstrap.js.map new file mode 100644 index 0000000..84bbf79 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/routines/bootstrap.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/routines/bootstrap.js"],"names":["log","Logger","child","namespace","configurationInput","global","GLOBAL_AGENT","warn"],"mappings":";;;;;;;AAEA;;AACA;;;;AAOA,MAAMA,GAAG,GAAGC,gBAAOC,KAAP,CAAa;AACvBC,EAAAA,SAAS,EAAE;AADY,CAAb,CAAZ;;kBAIgBC,kB,IAAmE;AACjF,MAAIC,MAAM,CAACC,YAAX,EAAyB;AACvBN,IAAAA,GAAG,CAACO,IAAJ,CAAS,iFAAT;AAEA,WAAO,KAAP;AACD;;AAEDF,EAAAA,MAAM,CAACC,YAAP,GAAsB,uCAAuBF,kBAAvB,CAAtB;AAEA,SAAO,IAAP;AACD,C","sourcesContent":["// @flow\n\nimport Logger from '../Logger';\nimport {\n createGlobalProxyAgent,\n} from '../factories';\nimport type {\n ProxyAgentConfigurationInputType,\n} from '../types';\n\nconst log = Logger.child({\n namespace: 'bootstrap',\n});\n\nexport default (configurationInput?: ProxyAgentConfigurationInputType): boolean => {\n if (global.GLOBAL_AGENT) {\n log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored');\n\n return false;\n }\n\n global.GLOBAL_AGENT = createGlobalProxyAgent(configurationInput);\n\n return true;\n};\n"],"file":"bootstrap.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/routines/index.js b/desktop/node_modules/global-agent/dist/routines/index.js new file mode 100644 index 0000000..2ae1be2 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/routines/index.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "bootstrap", { + enumerable: true, + get: function () { + return _bootstrap.default; + } +}); + +var _bootstrap = _interopRequireDefault(require("./bootstrap")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/routines/index.js.flow b/desktop/node_modules/global-agent/dist/routines/index.js.flow new file mode 100644 index 0000000..e47a8a0 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/routines/index.js.flow @@ -0,0 +1,3 @@ +// @flow + +export {default as bootstrap} from './bootstrap'; diff --git a/desktop/node_modules/global-agent/dist/routines/index.js.map b/desktop/node_modules/global-agent/dist/routines/index.js.map new file mode 100644 index 0000000..97295d9 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/routines/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/routines/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAEA","sourcesContent":["// @flow\n\nexport {default as bootstrap} from './bootstrap';\n"],"file":"index.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/types.js b/desktop/node_modules/global-agent/dist/types.js new file mode 100644 index 0000000..fb07a95 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/types.js @@ -0,0 +1,10 @@ +"use strict"; + +var _net = require("net"); + +var _tls = require("tls"); + +var _http = require("http"); + +var _https = require("https"); +//# sourceMappingURL=types.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/types.js.flow b/desktop/node_modules/global-agent/dist/types.js.flow new file mode 100644 index 0000000..e2f1a99 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/types.js.flow @@ -0,0 +1,66 @@ +// @flow + +import { + Socket, +} from 'net'; +import { + TLSSocket, +} from 'tls'; +import { + Agent as HttpAgent, +} from 'http'; +import { + Agent as HttpsAgent, +} from 'https'; + +export type ProxyConfigurationType = {| + +authorization: string, + +hostname: string, + +port: number, +|}; + +export type TlsConfigurationType = {| + +ca?: string, + +cert?: string, + +ciphers?: string, + +clientCertEngine?: string, + +crl?: string, + +dhparam?: string, + +ecdhCurve?: string, + +honorCipherOrder?: boolean, + +key?: string, + +passphrase?: string, + +pfx?: string, + +rejectUnauthorized?: boolean, + +secureOptions?: number, + +secureProtocol?: string, + +servername?: string, + +sessionIdContext?: string, +|}; + +export type ConnectionConfigurationType = {| + +host: string, + +port: number, + +tls?: TlsConfigurationType, + +proxy: ProxyConfigurationType, +|}; + +export type ConnectionCallbackType = (error: Error | null, socket?: Socket | TLSSocket) => void; + +export type AgentType = HttpAgent | HttpsAgent; +export type IsProxyConfiguredMethodType = () => boolean; +export type MustUrlUseProxyMethodType = (url: string) => boolean; +export type GetUrlProxyMethodType = (url: string) => ProxyConfigurationType; +export type ProtocolType = 'http:' | 'https:'; + +export type ProxyAgentConfigurationInputType = {| + +environmentVariableNamespace?: string, + +forceGlobalAgent?: boolean, + +socketConnectionTimeout?: number, +|}; + +export type ProxyAgentConfigurationType = {| + +environmentVariableNamespace: string, + +forceGlobalAgent: boolean, + +socketConnectionTimeout: number, +|}; diff --git a/desktop/node_modules/global-agent/dist/types.js.map b/desktop/node_modules/global-agent/dist/types.js.map new file mode 100644 index 0000000..46e65bc --- /dev/null +++ b/desktop/node_modules/global-agent/dist/types.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/types.js"],"names":[],"mappings":";;AAEA;;AAGA;;AAGA;;AAGA","sourcesContent":["// @flow\n\nimport {\n Socket,\n} from 'net';\nimport {\n TLSSocket,\n} from 'tls';\nimport {\n Agent as HttpAgent,\n} from 'http';\nimport {\n Agent as HttpsAgent,\n} from 'https';\n\nexport type ProxyConfigurationType = {|\n +authorization: string,\n +hostname: string,\n +port: number,\n|};\n\nexport type TlsConfigurationType = {|\n +ca?: string,\n +cert?: string,\n +ciphers?: string,\n +clientCertEngine?: string,\n +crl?: string,\n +dhparam?: string,\n +ecdhCurve?: string,\n +honorCipherOrder?: boolean,\n +key?: string,\n +passphrase?: string,\n +pfx?: string,\n +rejectUnauthorized?: boolean,\n +secureOptions?: number,\n +secureProtocol?: string,\n +servername?: string,\n +sessionIdContext?: string,\n|};\n\nexport type ConnectionConfigurationType = {|\n +host: string,\n +port: number,\n +tls?: TlsConfigurationType,\n +proxy: ProxyConfigurationType,\n|};\n\nexport type ConnectionCallbackType = (error: Error | null, socket?: Socket | TLSSocket) => void;\n\nexport type AgentType = HttpAgent | HttpsAgent;\nexport type IsProxyConfiguredMethodType = () => boolean;\nexport type MustUrlUseProxyMethodType = (url: string) => boolean;\nexport type GetUrlProxyMethodType = (url: string) => ProxyConfigurationType;\nexport type ProtocolType = 'http:' | 'https:';\n\nexport type ProxyAgentConfigurationInputType = {|\n +environmentVariableNamespace?: string,\n +forceGlobalAgent?: boolean,\n +socketConnectionTimeout?: number,\n|};\n\nexport type ProxyAgentConfigurationType = {|\n +environmentVariableNamespace: string,\n +forceGlobalAgent: boolean,\n +socketConnectionTimeout: number,\n|};\n"],"file":"types.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js b/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js new file mode 100644 index 0000000..4ce571a --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _http = _interopRequireDefault(require("http")); + +var _https = _interopRequireDefault(require("https")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// eslint-disable-next-line flowtype/no-weak-types +const bindHttpMethod = (originalMethod, agent, forceGlobalAgent) => { + // eslint-disable-next-line unicorn/prevent-abbreviations + return (...args) => { + let url; + let options; + let callback; + + if (typeof args[0] === 'string' || args[0] instanceof URL) { + url = args[0]; + + if (typeof args[1] === 'function') { + options = {}; + callback = args[1]; + } else { + options = { ...args[1] + }; + callback = args[2]; + } + } else { + options = { ...args[0] + }; + callback = args[1]; + } + + if (forceGlobalAgent) { + options.agent = agent; + } else { + if (!options.agent) { + options.agent = agent; + } + + if (options.agent === _http.default.globalAgent || options.agent === _https.default.globalAgent) { + options.agent = agent; + } + } + + if (url) { + // $FlowFixMe + return originalMethod(url, options, callback); + } else { + return originalMethod(options, callback); + } + }; +}; + +var _default = bindHttpMethod; +exports.default = _default; +//# sourceMappingURL=bindHttpMethod.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js.flow b/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js.flow new file mode 100644 index 0000000..f8859b5 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js.flow @@ -0,0 +1,54 @@ +// @flow + +import http from 'http'; +import https from 'https'; + +type AgentType = http.Agent | https.Agent; + +// eslint-disable-next-line flowtype/no-weak-types +export default (originalMethod: Function, agent: AgentType, forceGlobalAgent: boolean) => { + // eslint-disable-next-line unicorn/prevent-abbreviations + return (...args: *) => { + let url; + let options; + let callback; + + if (typeof args[0] === 'string' || args[0] instanceof URL) { + url = args[0]; + + if (typeof args[1] === 'function') { + options = {}; + callback = args[1]; + } else { + options = { + ...args[1], + }; + callback = args[2]; + } + } else { + options = { + ...args[0], + }; + callback = args[1]; + } + + if (forceGlobalAgent) { + options.agent = agent; + } else { + if (!options.agent) { + options.agent = agent; + } + + if (options.agent === http.globalAgent || options.agent === https.globalAgent) { + options.agent = agent; + } + } + + if (url) { + // $FlowFixMe + return originalMethod(url, options, callback); + } else { + return originalMethod(options, callback); + } + }; +}; diff --git a/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js.map b/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js.map new file mode 100644 index 0000000..0d49171 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/bindHttpMethod.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/utilities/bindHttpMethod.js"],"names":["originalMethod","agent","forceGlobalAgent","args","url","options","callback","URL","http","globalAgent","https"],"mappings":";;;;;;;AAEA;;AACA;;;;AAIA;wBACgBA,c,EAA0BC,K,EAAkBC,gB,KAA8B;AACxF;AACA,SAAO,CAAC,GAAGC,IAAJ,KAAgB;AACrB,QAAIC,GAAJ;AACA,QAAIC,OAAJ;AACA,QAAIC,QAAJ;;AAEA,QAAI,OAAOH,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+BA,IAAI,CAAC,CAAD,CAAJ,YAAmBI,GAAtD,EAA2D;AACzDH,MAAAA,GAAG,GAAGD,IAAI,CAAC,CAAD,CAAV;;AAEA,UAAI,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,UAAvB,EAAmC;AACjCE,QAAAA,OAAO,GAAG,EAAV;AACAC,QAAAA,QAAQ,GAAGH,IAAI,CAAC,CAAD,CAAf;AACD,OAHD,MAGO;AACLE,QAAAA,OAAO,GAAG,EACR,GAAGF,IAAI,CAAC,CAAD;AADC,SAAV;AAGAG,QAAAA,QAAQ,GAAGH,IAAI,CAAC,CAAD,CAAf;AACD;AACF,KAZD,MAYO;AACLE,MAAAA,OAAO,GAAG,EACR,GAAGF,IAAI,CAAC,CAAD;AADC,OAAV;AAGAG,MAAAA,QAAQ,GAAGH,IAAI,CAAC,CAAD,CAAf;AACD;;AAED,QAAID,gBAAJ,EAAsB;AACpBG,MAAAA,OAAO,CAACJ,KAAR,GAAgBA,KAAhB;AACD,KAFD,MAEO;AACL,UAAI,CAACI,OAAO,CAACJ,KAAb,EAAoB;AAClBI,QAAAA,OAAO,CAACJ,KAAR,GAAgBA,KAAhB;AACD;;AAED,UAAII,OAAO,CAACJ,KAAR,KAAkBO,cAAKC,WAAvB,IAAsCJ,OAAO,CAACJ,KAAR,KAAkBS,eAAMD,WAAlE,EAA+E;AAC7EJ,QAAAA,OAAO,CAACJ,KAAR,GAAgBA,KAAhB;AACD;AACF;;AAED,QAAIG,GAAJ,EAAS;AACP;AACA,aAAOJ,cAAc,CAACI,GAAD,EAAMC,OAAN,EAAeC,QAAf,CAArB;AACD,KAHD,MAGO;AACL,aAAON,cAAc,CAACK,OAAD,EAAUC,QAAV,CAArB;AACD;AACF,GA1CD;AA2CD,C","sourcesContent":["// @flow\n\nimport http from 'http';\nimport https from 'https';\n\ntype AgentType = http.Agent | https.Agent;\n\n// eslint-disable-next-line flowtype/no-weak-types\nexport default (originalMethod: Function, agent: AgentType, forceGlobalAgent: boolean) => {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n return (...args: *) => {\n let url;\n let options;\n let callback;\n\n if (typeof args[0] === 'string' || args[0] instanceof URL) {\n url = args[0];\n\n if (typeof args[1] === 'function') {\n options = {};\n callback = args[1];\n } else {\n options = {\n ...args[1],\n };\n callback = args[2];\n }\n } else {\n options = {\n ...args[0],\n };\n callback = args[1];\n }\n\n if (forceGlobalAgent) {\n options.agent = agent;\n } else {\n if (!options.agent) {\n options.agent = agent;\n }\n\n if (options.agent === http.globalAgent || options.agent === https.globalAgent) {\n options.agent = agent;\n }\n }\n\n if (url) {\n // $FlowFixMe\n return originalMethod(url, options, callback);\n } else {\n return originalMethod(options, callback);\n }\n };\n};\n"],"file":"bindHttpMethod.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/index.js b/desktop/node_modules/global-agent/dist/utilities/index.js new file mode 100644 index 0000000..5b9ff43 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/index.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "bindHttpMethod", { + enumerable: true, + get: function () { + return _bindHttpMethod.default; + } +}); +Object.defineProperty(exports, "isUrlMatchingNoProxy", { + enumerable: true, + get: function () { + return _isUrlMatchingNoProxy.default; + } +}); +Object.defineProperty(exports, "parseProxyUrl", { + enumerable: true, + get: function () { + return _parseProxyUrl.default; + } +}); + +var _bindHttpMethod = _interopRequireDefault(require("./bindHttpMethod")); + +var _isUrlMatchingNoProxy = _interopRequireDefault(require("./isUrlMatchingNoProxy")); + +var _parseProxyUrl = _interopRequireDefault(require("./parseProxyUrl")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/index.js.flow b/desktop/node_modules/global-agent/dist/utilities/index.js.flow new file mode 100644 index 0000000..3412387 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/index.js.flow @@ -0,0 +1,5 @@ +// @flow + +export {default as bindHttpMethod} from './bindHttpMethod'; +export {default as isUrlMatchingNoProxy} from './isUrlMatchingNoProxy'; +export {default as parseProxyUrl} from './parseProxyUrl'; diff --git a/desktop/node_modules/global-agent/dist/utilities/index.js.map b/desktop/node_modules/global-agent/dist/utilities/index.js.map new file mode 100644 index 0000000..6861a5a --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/utilities/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA","sourcesContent":["// @flow\n\nexport {default as bindHttpMethod} from './bindHttpMethod';\nexport {default as isUrlMatchingNoProxy} from './isUrlMatchingNoProxy';\nexport {default as parseProxyUrl} from './parseProxyUrl';\n"],"file":"index.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js b/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js new file mode 100644 index 0000000..92a3436 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js @@ -0,0 +1,43 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _url = require("url"); + +var _matcher = _interopRequireDefault(require("matcher")); + +var _errors = require("../errors"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const isUrlMatchingNoProxy = (subjectUrl, noProxy) => { + const subjectUrlTokens = (0, _url.parse)(subjectUrl); + const rules = noProxy.split(/[\s,]+/); + + for (const rule of rules) { + const ruleMatch = rule.replace(/^(?<leadingDot>\.)/, '*').match(/^(?<hostname>.+?)(?::(?<port>\d+))?$/); + + if (!ruleMatch || !ruleMatch.groups) { + throw new _errors.UnexpectedStateError('Invalid NO_PROXY pattern.'); + } + + if (!ruleMatch.groups.hostname) { + throw new _errors.UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.'); + } + + const hostnameIsMatch = _matcher.default.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname); + + if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) { + return true; + } + } + + return false; +}; + +var _default = isUrlMatchingNoProxy; +exports.default = _default; +//# sourceMappingURL=isUrlMatchingNoProxy.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js.flow b/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js.flow new file mode 100644 index 0000000..f2de584 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js.flow @@ -0,0 +1,37 @@ +// @flow + +import { + parse as parseUrl, +} from 'url'; +import matcher from 'matcher'; +import { + UnexpectedStateError, +} from '../errors'; + +export default (subjectUrl: string, noProxy: string) => { + const subjectUrlTokens = parseUrl(subjectUrl); + + const rules = noProxy.split(/[\s,]+/); + + for (const rule of rules) { + const ruleMatch = rule + .replace(/^(?<leadingDot>\.)/, '*') + .match(/^(?<hostname>.+?)(?::(?<port>\d+))?$/); + + if (!ruleMatch || !ruleMatch.groups) { + throw new UnexpectedStateError('Invalid NO_PROXY pattern.'); + } + + if (!ruleMatch.groups.hostname) { + throw new UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.'); + } + + const hostnameIsMatch = matcher.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname); + + if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) { + return true; + } + } + + return false; +}; diff --git a/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js.map b/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js.map new file mode 100644 index 0000000..9f60970 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/isUrlMatchingNoProxy.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/utilities/isUrlMatchingNoProxy.js"],"names":["subjectUrl","noProxy","subjectUrlTokens","rules","split","rule","ruleMatch","replace","match","groups","UnexpectedStateError","hostname","hostnameIsMatch","matcher","isMatch","port"],"mappings":";;;;;;;AAEA;;AAGA;;AACA;;;;8BAIgBA,U,EAAoBC,O,KAAoB;AACtD,QAAMC,gBAAgB,GAAG,gBAASF,UAAT,CAAzB;AAEA,QAAMG,KAAK,GAAGF,OAAO,CAACG,KAAR,CAAc,QAAd,CAAd;;AAEA,OAAK,MAAMC,IAAX,IAAmBF,KAAnB,EAA0B;AACxB,UAAMG,SAAS,GAAGD,IAAI,CACnBE,OADe,CACP,oBADO,EACe,GADf,EAEfC,KAFe,CAET,sCAFS,CAAlB;;AAIA,QAAI,CAACF,SAAD,IAAc,CAACA,SAAS,CAACG,MAA7B,EAAqC;AACnC,YAAM,IAAIC,4BAAJ,CAAyB,2BAAzB,CAAN;AACD;;AAED,QAAI,CAACJ,SAAS,CAACG,MAAV,CAAiBE,QAAtB,EAAgC;AAC9B,YAAM,IAAID,4BAAJ,CAAyB,4EAAzB,CAAN;AACD;;AAED,UAAME,eAAe,GAAGC,iBAAQC,OAAR,CAAgBZ,gBAAgB,CAACS,QAAjC,EAA2CL,SAAS,CAACG,MAAV,CAAiBE,QAA5D,CAAxB;;AAEA,QAAIC,eAAe,KAAK,CAACN,SAAS,CAACG,MAAX,IAAqB,CAACH,SAAS,CAACG,MAAV,CAAiBM,IAAvC,IAA+Cb,gBAAgB,CAACa,IAAjB,IAAyBb,gBAAgB,CAACa,IAAjB,KAA0BT,SAAS,CAACG,MAAV,CAAiBM,IAAxH,CAAnB,EAAkJ;AAChJ,aAAO,IAAP;AACD;AACF;;AAED,SAAO,KAAP;AACD,C","sourcesContent":["// @flow\n\nimport {\n parse as parseUrl,\n} from 'url';\nimport matcher from 'matcher';\nimport {\n UnexpectedStateError,\n} from '../errors';\n\nexport default (subjectUrl: string, noProxy: string) => {\n const subjectUrlTokens = parseUrl(subjectUrl);\n\n const rules = noProxy.split(/[\\s,]+/);\n\n for (const rule of rules) {\n const ruleMatch = rule\n .replace(/^(?<leadingDot>\\.)/, '*')\n .match(/^(?<hostname>.+?)(?::(?<port>\\d+))?$/);\n\n if (!ruleMatch || !ruleMatch.groups) {\n throw new UnexpectedStateError('Invalid NO_PROXY pattern.');\n }\n\n if (!ruleMatch.groups.hostname) {\n throw new UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.');\n }\n\n const hostnameIsMatch = matcher.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname);\n\n if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) {\n return true;\n }\n }\n\n return false;\n};\n"],"file":"isUrlMatchingNoProxy.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js b/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js new file mode 100644 index 0000000..e4f1185 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js @@ -0,0 +1,42 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _url = require("url"); + +var _errors = require("../errors"); + +const parseProxyUrl = url => { + const urlTokens = (0, _url.parse)(url); + + if (urlTokens.query !== null) { + throw new _errors.UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.'); + } + + if (urlTokens.hash !== null) { + throw new _errors.UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.'); + } + + if (urlTokens.protocol !== 'http:') { + throw new _errors.UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".'); + } + + let port = 80; + + if (urlTokens.port) { + port = Number.parseInt(urlTokens.port, 10); + } + + return { + authorization: urlTokens.auth || null, + hostname: urlTokens.hostname, + port + }; +}; + +var _default = parseProxyUrl; +exports.default = _default; +//# sourceMappingURL=parseProxyUrl.js.map
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js.flow b/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js.flow new file mode 100644 index 0000000..e2e9a6b --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js.flow @@ -0,0 +1,36 @@ +// @flow + +import { + parse as parseUrl, +} from 'url'; +import { + UnexpectedStateError, +} from '../errors'; + +export default (url: string) => { + const urlTokens = parseUrl(url); + + if (urlTokens.query !== null) { + throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.'); + } + + if (urlTokens.hash !== null) { + throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.'); + } + + if (urlTokens.protocol !== 'http:') { + throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".'); + } + + let port = 80; + + if (urlTokens.port) { + port = Number.parseInt(urlTokens.port, 10); + } + + return { + authorization: urlTokens.auth || null, + hostname: urlTokens.hostname, + port, + }; +}; diff --git a/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js.map b/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js.map new file mode 100644 index 0000000..4457f10 --- /dev/null +++ b/desktop/node_modules/global-agent/dist/utilities/parseProxyUrl.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/utilities/parseProxyUrl.js"],"names":["url","urlTokens","query","UnexpectedStateError","hash","protocol","port","Number","parseInt","authorization","auth","hostname"],"mappings":";;;;;;;AAEA;;AAGA;;sBAIgBA,G,IAAgB;AAC9B,QAAMC,SAAS,GAAG,gBAASD,GAAT,CAAlB;;AAEA,MAAIC,SAAS,CAACC,KAAV,KAAoB,IAAxB,EAA8B;AAC5B,UAAM,IAAIC,4BAAJ,CAAyB,qFAAzB,CAAN;AACD;;AAED,MAAIF,SAAS,CAACG,IAAV,KAAmB,IAAvB,EAA6B;AAC3B,UAAM,IAAID,4BAAJ,CAAyB,oFAAzB,CAAN;AACD;;AAED,MAAIF,SAAS,CAACI,QAAV,KAAuB,OAA3B,EAAoC;AAClC,UAAM,IAAIF,4BAAJ,CAAyB,0FAAzB,CAAN;AACD;;AAED,MAAIG,IAAI,GAAG,EAAX;;AAEA,MAAIL,SAAS,CAACK,IAAd,EAAoB;AAClBA,IAAAA,IAAI,GAAGC,MAAM,CAACC,QAAP,CAAgBP,SAAS,CAACK,IAA1B,EAAgC,EAAhC,CAAP;AACD;;AAED,SAAO;AACLG,IAAAA,aAAa,EAAER,SAAS,CAACS,IAAV,IAAkB,IAD5B;AAELC,IAAAA,QAAQ,EAAEV,SAAS,CAACU,QAFf;AAGLL,IAAAA;AAHK,GAAP;AAKD,C","sourcesContent":["// @flow\n\nimport {\n parse as parseUrl,\n} from 'url';\nimport {\n UnexpectedStateError,\n} from '../errors';\n\nexport default (url: string) => {\n const urlTokens = parseUrl(url);\n\n if (urlTokens.query !== null) {\n throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.');\n }\n\n if (urlTokens.hash !== null) {\n throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.');\n }\n\n if (urlTokens.protocol !== 'http:') {\n throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be \"http:\".');\n }\n\n let port = 80;\n\n if (urlTokens.port) {\n port = Number.parseInt(urlTokens.port, 10);\n }\n\n return {\n authorization: urlTokens.auth || null,\n hostname: urlTokens.hostname,\n port,\n };\n};\n"],"file":"parseProxyUrl.js"}
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/node_modules/.bin/semver b/desktop/node_modules/global-agent/node_modules/.bin/semver new file mode 120000 index 0000000..5aaadf4 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/.bin/semver @@ -0,0 +1 @@ +../semver/bin/semver.js
\ No newline at end of file diff --git a/desktop/node_modules/global-agent/node_modules/semver/LICENSE b/desktop/node_modules/global-agent/node_modules/semver/LICENSE new file mode 100644 index 0000000..19129e3 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/desktop/node_modules/global-agent/node_modules/semver/README.md b/desktop/node_modules/global-agent/node_modules/semver/README.md new file mode 100644 index 0000000..53ea9b5 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/README.md @@ -0,0 +1,637 @@ +semver(1) -- The semantic versioner for npm +=========================================== + +## Install + +```bash +npm install semver +```` + +## Usage + +As a node module: + +```js +const semver = require('semver') + +semver.valid('1.2.3') // '1.2.3' +semver.valid('a.b.c') // null +semver.clean(' =v1.2.3 ') // '1.2.3' +semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true +semver.gt('1.2.3', '9.8.7') // false +semver.lt('1.2.3', '9.8.7') // true +semver.minVersion('>=1.0.0') // '1.0.0' +semver.valid(semver.coerce('v2')) // '2.0.0' +semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7' +``` + +You can also just load the module for the function that you care about, if +you'd like to minimize your footprint. + +```js +// load the whole API at once in a single object +const semver = require('semver') + +// or just load the bits you need +// all of them listed here, just pick and choose what you want + +// classes +const SemVer = require('semver/classes/semver') +const Comparator = require('semver/classes/comparator') +const Range = require('semver/classes/range') + +// functions for working with versions +const semverParse = require('semver/functions/parse') +const semverValid = require('semver/functions/valid') +const semverClean = require('semver/functions/clean') +const semverInc = require('semver/functions/inc') +const semverDiff = require('semver/functions/diff') +const semverMajor = require('semver/functions/major') +const semverMinor = require('semver/functions/minor') +const semverPatch = require('semver/functions/patch') +const semverPrerelease = require('semver/functions/prerelease') +const semverCompare = require('semver/functions/compare') +const semverRcompare = require('semver/functions/rcompare') +const semverCompareLoose = require('semver/functions/compare-loose') +const semverCompareBuild = require('semver/functions/compare-build') +const semverSort = require('semver/functions/sort') +const semverRsort = require('semver/functions/rsort') + +// low-level comparators between versions +const semverGt = require('semver/functions/gt') +const semverLt = require('semver/functions/lt') +const semverEq = require('semver/functions/eq') +const semverNeq = require('semver/functions/neq') +const semverGte = require('semver/functions/gte') +const semverLte = require('semver/functions/lte') +const semverCmp = require('semver/functions/cmp') +const semverCoerce = require('semver/functions/coerce') + +// working with ranges +const semverSatisfies = require('semver/functions/satisfies') +const semverMaxSatisfying = require('semver/ranges/max-satisfying') +const semverMinSatisfying = require('semver/ranges/min-satisfying') +const semverToComparators = require('semver/ranges/to-comparators') +const semverMinVersion = require('semver/ranges/min-version') +const semverValidRange = require('semver/ranges/valid') +const semverOutside = require('semver/ranges/outside') +const semverGtr = require('semver/ranges/gtr') +const semverLtr = require('semver/ranges/ltr') +const semverIntersects = require('semver/ranges/intersects') +const simplifyRange = require('semver/ranges/simplify') +const rangeSubset = require('semver/ranges/subset') +``` + +As a command-line utility: + +``` +$ semver -h + +A JavaScript implementation of the https://semver.org/ specification +Copyright Isaac Z. Schlueter + +Usage: semver [options] <version> [<version> [...]] +Prints valid versions sorted by SemVer precedence + +Options: +-r --range <range> + Print versions that match the specified range. + +-i --increment [<level>] + Increment a version by the specified level. Level can + be one of: major, minor, patch, premajor, preminor, + prepatch, or prerelease. Default level is 'patch'. + Only one version may be specified. + +--preid <identifier> + Identifier to be used to prefix premajor, preminor, + prepatch or prerelease version increments. + +-l --loose + Interpret versions and ranges loosely + +-n <0|1> + This is the base to be used for the prerelease identifier. + +-p --include-prerelease + Always include prerelease versions in range matching + +-c --coerce + Coerce a string into SemVer if possible + (does not imply --loose) + +--rtl + Coerce version strings right to left + +--ltr + Coerce version strings left to right (default) + +Program exits successfully if any valid version satisfies +all supplied ranges, and prints all satisfying versions. + +If no satisfying versions are found, then exits failure. + +Versions are printed in ascending order, so supplying +multiple versions to the utility will just sort them. +``` + +## Versions + +A "version" is described by the `v2.0.0` specification found at +<https://semver.org/>. + +A leading `"="` or `"v"` character is stripped off and ignored. + +## Ranges + +A `version range` is a set of `comparators` which specify versions +that satisfy the range. + +A `comparator` is composed of an `operator` and a `version`. The set +of primitive `operators` is: + +* `<` Less than +* `<=` Less than or equal to +* `>` Greater than +* `>=` Greater than or equal to +* `=` Equal. If no operator is specified, then equality is assumed, + so this operator is optional, but MAY be included. + +For example, the comparator `>=1.2.7` would match the versions +`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6` +or `1.1.0`. The comparator `>1` is equivalent to `>=2.0.0` and +would match the versions `2.0.0` and `3.1.0`, but not the versions +`1.0.1` or `1.1.0`. + +Comparators can be joined by whitespace to form a `comparator set`, +which is satisfied by the **intersection** of all of the comparators +it includes. + +A range is composed of one or more comparator sets, joined by `||`. A +version matches a range if and only if every comparator in at least +one of the `||`-separated comparator sets is satisfied by the version. + +For example, the range `>=1.2.7 <1.3.0` would match the versions +`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`, +or `1.1.0`. + +The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`, +`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`. + +### Prerelease Tags + +If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then +it will only be allowed to satisfy comparator sets if at least one +comparator with the same `[major, minor, patch]` tuple also has a +prerelease tag. + +For example, the range `>1.2.3-alpha.3` would be allowed to match the +version `1.2.3-alpha.7`, but it would *not* be satisfied by +`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater +than" `1.2.3-alpha.3` according to the SemVer sort rules. The version +range only accepts prerelease tags on the `1.2.3` version. The +version `3.4.5` *would* satisfy the range, because it does not have a +prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`. + +The purpose for this behavior is twofold. First, prerelease versions +frequently are updated very quickly, and contain many breaking changes +that are (by the author's design) not yet fit for public consumption. +Therefore, by default, they are excluded from range matching +semantics. + +Second, a user who has opted into using a prerelease version has +clearly indicated the intent to use *that specific* set of +alpha/beta/rc versions. By including a prerelease tag in the range, +the user is indicating that they are aware of the risk. However, it +is still not appropriate to assume that they have opted into taking a +similar risk on the *next* set of prerelease versions. + +Note that this behavior can be suppressed (treating all prerelease +versions as if they were normal versions, for the purpose of range +matching) by setting the `includePrerelease` flag on the options +object to any +[functions](https://github.com/npm/node-semver#functions) that do +range matching. + +#### Prerelease Identifiers + +The method `.inc` takes an additional `identifier` string argument that +will append the value of the string as a prerelease identifier: + +```javascript +semver.inc('1.2.3', 'prerelease', 'beta') +// '1.2.4-beta.0' +``` + +command-line example: + +```bash +$ semver 1.2.3 -i prerelease --preid beta +1.2.4-beta.0 +``` + +Which then can be used to increment further: + +```bash +$ semver 1.2.4-beta.0 -i prerelease +1.2.4-beta.1 +``` + +#### Prerelease Identifier Base + +The method `.inc` takes an optional parameter 'identifierBase' string +that will let you let your prerelease number as zero-based or one-based. +Set to `false` to omit the prerelease number altogether. +If you do not specify this parameter, it will default to zero-based. + +```javascript +semver.inc('1.2.3', 'prerelease', 'beta', '1') +// '1.2.4-beta.1' +``` + +```javascript +semver.inc('1.2.3', 'prerelease', 'beta', false) +// '1.2.4-beta' +``` + +command-line example: + +```bash +$ semver 1.2.3 -i prerelease --preid beta -n 1 +1.2.4-beta.1 +``` + +```bash +$ semver 1.2.3 -i prerelease --preid beta -n false +1.2.4-beta +``` + +### Advanced Range Syntax + +Advanced range syntax desugars to primitive comparators in +deterministic ways. + +Advanced ranges may be combined in the same way as primitive +comparators using white space or `||`. + +#### Hyphen Ranges `X.Y.Z - A.B.C` + +Specifies an inclusive set. + +* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` + +If a partial version is provided as the first version in the inclusive +range, then the missing pieces are replaced with zeroes. + +* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4` + +If a partial version is provided as the second version in the +inclusive range, then all versions that start with the supplied parts +of the tuple are accepted, but nothing that would be greater than the +provided tuple parts. + +* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0` +* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0` + +#### X-Ranges `1.2.x` `1.X` `1.2.*` `*` + +Any of `X`, `x`, or `*` may be used to "stand in" for one of the +numeric values in the `[major, minor, patch]` tuple. + +* `*` := `>=0.0.0` (Any non-prerelease version satisfies, unless + `includePrerelease` is specified, in which case any version at all + satisfies) +* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version) +* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions) + +A partial version range is treated as an X-Range, so the special +character is in fact optional. + +* `""` (empty string) := `*` := `>=0.0.0` +* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0` +* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0` + +#### Tilde Ranges `~1.2.3` `~1.2` `~1` + +Allows patch-level changes if a minor version is specified on the +comparator. Allows minor-level changes if not. + +* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0` +* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`) +* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`) +* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0` +* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`) +* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`) +* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in + the `1.2.3` version will be allowed, if they are greater than or + equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but + `1.2.4-beta.2` would not, because it is a prerelease of a + different `[major, minor, patch]` tuple. + +#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4` + +Allows changes that do not modify the left-most non-zero element in the +`[major, minor, patch]` tuple. In other words, this allows patch and +minor updates for versions `1.0.0` and above, patch updates for +versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`. + +Many authors treat a `0.x` version as if the `x` were the major +"breaking-change" indicator. + +Caret ranges are ideal when an author may make breaking changes +between `0.2.4` and `0.3.0` releases, which is a common practice. +However, it presumes that there will *not* be breaking changes between +`0.2.4` and `0.2.5`. It allows for changes that are presumed to be +additive (but non-breaking), according to commonly observed practices. + +* `^1.2.3` := `>=1.2.3 <2.0.0-0` +* `^0.2.3` := `>=0.2.3 <0.3.0-0` +* `^0.0.3` := `>=0.0.3 <0.0.4-0` +* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in + the `1.2.3` version will be allowed, if they are greater than or + equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but + `1.2.4-beta.2` would not, because it is a prerelease of a + different `[major, minor, patch]` tuple. +* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the + `0.0.3` version *only* will be allowed, if they are greater than or + equal to `beta`. So, `0.0.3-pr.2` would be allowed. + +When parsing caret ranges, a missing `patch` value desugars to the +number `0`, but will allow flexibility within that value, even if the +major and minor versions are both `0`. + +* `^1.2.x` := `>=1.2.0 <2.0.0-0` +* `^0.0.x` := `>=0.0.0 <0.1.0-0` +* `^0.0` := `>=0.0.0 <0.1.0-0` + +A missing `minor` and `patch` values will desugar to zero, but also +allow flexibility within those values, even if the major version is +zero. + +* `^1.x` := `>=1.0.0 <2.0.0-0` +* `^0.x` := `>=0.0.0 <1.0.0-0` + +### Range Grammar + +Putting all this together, here is a Backus-Naur grammar for ranges, +for the benefit of parser authors: + +```bnf +range-set ::= range ( logical-or range ) * +logical-or ::= ( ' ' ) * '||' ( ' ' ) * +range ::= hyphen | simple ( ' ' simple ) * | '' +hyphen ::= partial ' - ' partial +simple ::= primitive | partial | tilde | caret +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial +partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? +xr ::= 'x' | 'X' | '*' | nr +nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * +tilde ::= '~' partial +caret ::= '^' partial +qualifier ::= ( '-' pre )? ( '+' build )? +pre ::= parts +build ::= parts +parts ::= part ( '.' part ) * +part ::= nr | [-0-9A-Za-z]+ +``` + +## Functions + +All methods and classes take a final `options` object argument. All +options in this object are `false` by default. The options supported +are: + +- `loose` Be more forgiving about not-quite-valid semver strings. + (Any resulting output will always be 100% strict compliant, of + course.) For backwards compatibility reasons, if the `options` + argument is a boolean value instead of an object, it is interpreted + to be the `loose` param. +- `includePrerelease` Set to suppress the [default + behavior](https://github.com/npm/node-semver#prerelease-tags) of + excluding prerelease tagged versions from ranges unless they are + explicitly opted into. + +Strict-mode Comparators and Ranges will be strict about the SemVer +strings that they parse. + +* `valid(v)`: Return the parsed version, or null if it's not valid. +* `inc(v, release)`: Return the version incremented by the release + type (`major`, `premajor`, `minor`, `preminor`, `patch`, + `prepatch`, or `prerelease`), or null if it's not valid + * `premajor` in one call will bump the version up to the next major + version and down to a prerelease of that major version. + `preminor`, and `prepatch` work the same way. + * If called from a non-prerelease version, the `prerelease` will work the + same as `prepatch`. It increments the patch version, then makes a + prerelease. If the input version is already a prerelease it simply + increments it. +* `prerelease(v)`: Returns an array of prerelease components, or null + if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]` +* `major(v)`: Return the major version number. +* `minor(v)`: Return the minor version number. +* `patch(v)`: Return the patch version number. +* `intersects(r1, r2, loose)`: Return true if the two supplied ranges + or comparators intersect. +* `parse(v)`: Attempt to parse a string as a semantic version, returning either + a `SemVer` object or `null`. + +### Comparison + +* `gt(v1, v2)`: `v1 > v2` +* `gte(v1, v2)`: `v1 >= v2` +* `lt(v1, v2)`: `v1 < v2` +* `lte(v1, v2)`: `v1 <= v2` +* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent, + even if they're not the exact same string. You already know how to + compare strings. +* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`. +* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call + the corresponding function above. `"==="` and `"!=="` do simple + string comparison, but are included for completeness. Throws if an + invalid comparison string is provided. +* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if + `v2` is greater. Sorts in ascending order if passed to `Array.sort()`. +* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions + in descending order when passed to `Array.sort()`. +* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions + are equal. Sorts in ascending order if passed to `Array.sort()`. + `v2` is greater. Sorts in ascending order if passed to `Array.sort()`. +* `diff(v1, v2)`: Returns difference between two versions by the release type + (`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`), + or null if the versions are the same. + +### Comparators + +* `intersects(comparator)`: Return true if the comparators intersect + +### Ranges + +* `validRange(range)`: Return the valid range or null if it's not valid +* `satisfies(version, range)`: Return true if the version satisfies the + range. +* `maxSatisfying(versions, range)`: Return the highest version in the list + that satisfies the range, or `null` if none of them do. +* `minSatisfying(versions, range)`: Return the lowest version in the list + that satisfies the range, or `null` if none of them do. +* `minVersion(range)`: Return the lowest version that can possibly match + the given range. +* `gtr(version, range)`: Return `true` if version is greater than all the + versions possible in the range. +* `ltr(version, range)`: Return `true` if version is less than all the + versions possible in the range. +* `outside(version, range, hilo)`: Return true if the version is outside + the bounds of the range in either the high or low direction. The + `hilo` argument must be either the string `'>'` or `'<'`. (This is + the function called by `gtr` and `ltr`.) +* `intersects(range)`: Return true if any of the ranges comparators intersect +* `simplifyRange(versions, range)`: Return a "simplified" range that + matches the same items in `versions` list as the range specified. Note + that it does *not* guarantee that it would match the same versions in all + cases, only for the set of versions provided. This is useful when + generating ranges by joining together multiple versions with `||` + programmatically, to provide the user with something a bit more + ergonomic. If the provided range is shorter in string-length than the + generated range, then that is returned. +* `subset(subRange, superRange)`: Return `true` if the `subRange` range is + entirely contained by the `superRange` range. + +Note that, since ranges may be non-contiguous, a version might not be +greater than a range, less than a range, *or* satisfy a range! For +example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9` +until `2.0.0`, so the version `1.2.10` would not be greater than the +range (because `2.0.1` satisfies, which is higher), nor less than the +range (since `1.2.8` satisfies, which is lower), and it also does not +satisfy the range. + +If you want to know if a version satisfies or does not satisfy a +range, use the `satisfies(version, range)` function. + +### Coercion + +* `coerce(version, options)`: Coerces a string to semver if possible + +This aims to provide a very forgiving translation of a non-semver string to +semver. It looks for the first digit in a string, and consumes all +remaining characters which satisfy at least a partial semver (e.g., `1`, +`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer +versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All +surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes +`3.4.0`). Only text which lacks digits will fail coercion (`version one` +is not valid). The maximum length for any semver component considered for +coercion is 16 characters; longer components will be ignored +(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any +semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value +components are invalid (`9999999999999999.4.7.4` is likely invalid). + +If the `options.rtl` flag is set, then `coerce` will return the right-most +coercible tuple that does not share an ending index with a longer coercible +tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not +`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of +any other overlapping SemVer tuple. + +### Clean + +* `clean(version)`: Clean a string to be a valid semver if possible + +This will return a cleaned and trimmed semver version. If the provided +version is not valid a null will be returned. This does not work for +ranges. + +ex. +* `s.clean(' = v 2.1.5foo')`: `null` +* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'` +* `s.clean(' = v 2.1.5-foo')`: `null` +* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'` +* `s.clean('=v2.1.5')`: `'2.1.5'` +* `s.clean(' =v2.1.5')`: `2.1.5` +* `s.clean(' 2.1.5 ')`: `'2.1.5'` +* `s.clean('~1.0.0')`: `null` + +## Constants + +As a convenience, helper constants are exported to provide information about what `node-semver` supports: + +### `RELEASE_TYPES` + +- major +- premajor +- minor +- preminor +- patch +- prepatch +- prerelease + +``` +const semver = require('semver'); + +if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) { + console.log('This is a valid release type!'); +} else { + console.warn('This is NOT a valid release type!'); +} +``` + +### `SEMVER_SPEC_VERSION` + +2.0.0 + +``` +const semver = require('semver'); + +console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION); +``` + +## Exported Modules + +<!-- +TODO: Make sure that all of these items are documented (classes aren't, +eg), and then pull the module name into the documentation for that specific +thing. +--> + +You may pull in just the part of this semver utility that you need, if you +are sensitive to packing and tree-shaking concerns. The main +`require('semver')` export uses getter functions to lazily load the parts +of the API that are used. + +The following modules are available: + +* `require('semver')` +* `require('semver/classes')` +* `require('semver/classes/comparator')` +* `require('semver/classes/range')` +* `require('semver/classes/semver')` +* `require('semver/functions/clean')` +* `require('semver/functions/cmp')` +* `require('semver/functions/coerce')` +* `require('semver/functions/compare')` +* `require('semver/functions/compare-build')` +* `require('semver/functions/compare-loose')` +* `require('semver/functions/diff')` +* `require('semver/functions/eq')` +* `require('semver/functions/gt')` +* `require('semver/functions/gte')` +* `require('semver/functions/inc')` +* `require('semver/functions/lt')` +* `require('semver/functions/lte')` +* `require('semver/functions/major')` +* `require('semver/functions/minor')` +* `require('semver/functions/neq')` +* `require('semver/functions/parse')` +* `require('semver/functions/patch')` +* `require('semver/functions/prerelease')` +* `require('semver/functions/rcompare')` +* `require('semver/functions/rsort')` +* `require('semver/functions/satisfies')` +* `require('semver/functions/sort')` +* `require('semver/functions/valid')` +* `require('semver/ranges/gtr')` +* `require('semver/ranges/intersects')` +* `require('semver/ranges/ltr')` +* `require('semver/ranges/max-satisfying')` +* `require('semver/ranges/min-satisfying')` +* `require('semver/ranges/min-version')` +* `require('semver/ranges/outside')` +* `require('semver/ranges/to-comparators')` +* `require('semver/ranges/valid')` + diff --git a/desktop/node_modules/global-agent/node_modules/semver/bin/semver.js b/desktop/node_modules/global-agent/node_modules/semver/bin/semver.js new file mode 100755 index 0000000..242b7ad --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/bin/semver.js @@ -0,0 +1,197 @@ +#!/usr/bin/env node +// Standalone semver comparison program. +// Exits successfully and prints matching version(s) if +// any supplied version is valid and passes all tests. + +const argv = process.argv.slice(2) + +let versions = [] + +const range = [] + +let inc = null + +const version = require('../package.json').version + +let loose = false + +let includePrerelease = false + +let coerce = false + +let rtl = false + +let identifier + +let identifierBase + +const semver = require('../') +const parseOptions = require('../internal/parse-options') + +let reverse = false + +let options = {} + +const main = () => { + if (!argv.length) { + return help() + } + while (argv.length) { + let a = argv.shift() + const indexOfEqualSign = a.indexOf('=') + if (indexOfEqualSign !== -1) { + const value = a.slice(indexOfEqualSign + 1) + a = a.slice(0, indexOfEqualSign) + argv.unshift(value) + } + switch (a) { + case '-rv': case '-rev': case '--rev': case '--reverse': + reverse = true + break + case '-l': case '--loose': + loose = true + break + case '-p': case '--include-prerelease': + includePrerelease = true + break + case '-v': case '--version': + versions.push(argv.shift()) + break + case '-i': case '--inc': case '--increment': + switch (argv[0]) { + case 'major': case 'minor': case 'patch': case 'prerelease': + case 'premajor': case 'preminor': case 'prepatch': + inc = argv.shift() + break + default: + inc = 'patch' + break + } + break + case '--preid': + identifier = argv.shift() + break + case '-r': case '--range': + range.push(argv.shift()) + break + case '-n': + identifierBase = argv.shift() + if (identifierBase === 'false') { + identifierBase = false + } + break + case '-c': case '--coerce': + coerce = true + break + case '--rtl': + rtl = true + break + case '--ltr': + rtl = false + break + case '-h': case '--help': case '-?': + return help() + default: + versions.push(a) + break + } + } + + options = parseOptions({ loose, includePrerelease, rtl }) + + versions = versions.map((v) => { + return coerce ? (semver.coerce(v, options) || { version: v }).version : v + }).filter((v) => { + return semver.valid(v) + }) + if (!versions.length) { + return fail() + } + if (inc && (versions.length !== 1 || range.length)) { + return failInc() + } + + for (let i = 0, l = range.length; i < l; i++) { + versions = versions.filter((v) => { + return semver.satisfies(v, range[i], options) + }) + if (!versions.length) { + return fail() + } + } + return success(versions) +} + +const failInc = () => { + console.error('--inc can only be used on a single version with no range') + fail() +} + +const fail = () => process.exit(1) + +const success = () => { + const compare = reverse ? 'rcompare' : 'compare' + versions.sort((a, b) => { + return semver[compare](a, b, options) + }).map((v) => { + return semver.clean(v, options) + }).map((v) => { + return inc ? semver.inc(v, inc, options, identifier, identifierBase) : v + }).forEach((v, i, _) => { + console.log(v) + }) +} + +const help = () => console.log( +`SemVer ${version} + +A JavaScript implementation of the https://semver.org/ specification +Copyright Isaac Z. Schlueter + +Usage: semver [options] <version> [<version> [...]] +Prints valid versions sorted by SemVer precedence + +Options: +-r --range <range> + Print versions that match the specified range. + +-i --increment [<level>] + Increment a version by the specified level. Level can + be one of: major, minor, patch, premajor, preminor, + prepatch, or prerelease. Default level is 'patch'. + Only one version may be specified. + +--preid <identifier> + Identifier to be used to prefix premajor, preminor, + prepatch or prerelease version increments. + +-l --loose + Interpret versions and ranges loosely + +-p --include-prerelease + Always include prerelease versions in range matching + +-c --coerce + Coerce a string into SemVer if possible + (does not imply --loose) + +--rtl + Coerce version strings right to left + +--ltr + Coerce version strings left to right (default) + +-n <base> + Base number to be used for the prerelease identifier. + Can be either 0 or 1, or false to omit the number altogether. + Defaults to 0. + +Program exits successfully if any valid version satisfies +all supplied ranges, and prints all satisfying versions. + +If no satisfying versions are found, then exits failure. + +Versions are printed in ascending order, so supplying +multiple versions to the utility will just sort them.`) + +main() diff --git a/desktop/node_modules/global-agent/node_modules/semver/classes/comparator.js b/desktop/node_modules/global-agent/node_modules/semver/classes/comparator.js new file mode 100644 index 0000000..3d39c0e --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/classes/comparator.js @@ -0,0 +1,141 @@ +const ANY = Symbol('SemVer ANY') +// hoisted class for cyclic dependency +class Comparator { + static get ANY () { + return ANY + } + + constructor (comp, options) { + options = parseOptions(options) + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + comp = comp.trim().split(/\s+/).join(' ') + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) + } + + parse (comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const m = comp.match(r) + + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } + + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } + } + + toString () { + return this.value + } + + test (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY || version === ANY) { + return true + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) + } + + intersects (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (this.operator === '') { + if (this.value === '') { + return true + } + return new Range(comp.value, options).test(this.value) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + return new Range(this.value, options).test(comp.semver) + } + + options = parseOptions(options) + + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + if (!options.includePrerelease && + (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) { + return false + } + + // Same direction increasing (> or >=) + if (this.operator.startsWith('>') && comp.operator.startsWith('>')) { + return true + } + // Same direction decreasing (< or <=) + if (this.operator.startsWith('<') && comp.operator.startsWith('<')) { + return true + } + // same SemVer and both sides are inclusive (<= or >=) + if ( + (this.semver.version === comp.semver.version) && + this.operator.includes('=') && comp.operator.includes('=')) { + return true + } + // opposite directions less than + if (cmp(this.semver, '<', comp.semver, options) && + this.operator.startsWith('>') && comp.operator.startsWith('<')) { + return true + } + // opposite directions greater than + if (cmp(this.semver, '>', comp.semver, options) && + this.operator.startsWith('<') && comp.operator.startsWith('>')) { + return true + } + return false + } +} + +module.exports = Comparator + +const parseOptions = require('../internal/parse-options') +const { safeRe: re, t } = require('../internal/re') +const cmp = require('../functions/cmp') +const debug = require('../internal/debug') +const SemVer = require('./semver') +const Range = require('./range') diff --git a/desktop/node_modules/global-agent/node_modules/semver/classes/index.js b/desktop/node_modules/global-agent/node_modules/semver/classes/index.js new file mode 100644 index 0000000..5e3f5c9 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/classes/index.js @@ -0,0 +1,5 @@ +module.exports = { + SemVer: require('./semver.js'), + Range: require('./range.js'), + Comparator: require('./comparator.js'), +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/classes/range.js b/desktop/node_modules/global-agent/node_modules/semver/classes/range.js new file mode 100644 index 0000000..7e7c414 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/classes/range.js @@ -0,0 +1,539 @@ +// hoisted class for cyclic dependency +class Range { + constructor (range, options) { + options = parseOptions(options) + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range(range.raw, options) + } + } + + if (range instanceof Comparator) { + // just put it in the set and return + this.raw = range.value + this.set = [[range]] + this.format() + return this + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First reduce all whitespace as much as possible so we do not have to rely + // on potentially slow regexes like \s*. This is then stored and used for + // future error messages as well. + this.raw = range + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') + // map the range to a 2d array of comparators + .map(r => this.parseRange(r.trim())) + // throw out any comparator lists that are empty + // this generally means that it was not a valid range, which is allowed + // in loose mode, but will still throw if the WHOLE range is invalid. + .filter(c => c.length) + + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${this.raw}`) + } + + // if we have any that are not the null set, throw out null sets. + if (this.set.length > 1) { + // keep the first one, in case they're all null sets + const first = this.set[0] + this.set = this.set.filter(c => !isNullSet(c[0])) + if (this.set.length === 0) { + this.set = [first] + } else if (this.set.length > 1) { + // if we have any that are *, then the range is just * + for (const c of this.set) { + if (c.length === 1 && isAny(c[0])) { + this.set = [c] + break + } + } + } + } + + this.format() + } + + format () { + this.range = this.set + .map((comps) => comps.join(' ').trim()) + .join('||') + .trim() + return this.range + } + + toString () { + return this.range + } + + parseRange (range) { + // memoize range parsing for performance. + // this is a very hot path, and fully deterministic. + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range + const cached = cache.get(memoKey) + if (cached) { + return cached + } + + const loose = this.options.loose + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) + debug('hyphen replace', range) + + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range) + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + debug('tilde trim', range) + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) + debug('caret trim', range) + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + let rangeList = range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + // >=0.0.0 is equivalent to * + .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { + // in loose mode, throw out any that are not valid comparators + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) + + // if any comparators are the null set, then replace with JUST null set + // if more than one comparator, remove any * comparators + // also, don't include the same comparator more than once + const rangeMap = new Map() + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { + return [comp] + } + rangeMap.set(comp.value, comp) + } + if (rangeMap.size > 1 && rangeMap.has('')) { + rangeMap.delete('') + } + + const result = [...rangeMap.values()] + cache.set(memoKey, result) + return result + } + + intersects (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + return this.set.some((thisComparators) => { + return ( + isSatisfiable(thisComparators, options) && + range.set.some((rangeComparators) => { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every((thisComparator) => { + return rangeComparators.every((rangeComparator) => { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) + } + + // if ANY of the sets match ALL of its comparators, then pass + test (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false + } +} + +module.exports = Range + +const LRU = require('lru-cache') +const cache = new LRU({ max: 1000 }) + +const parseOptions = require('../internal/parse-options') +const Comparator = require('./comparator') +const debug = require('../internal/debug') +const SemVer = require('./semver') +const { + safeRe: re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace, +} = require('../internal/re') +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants') + +const isNullSet = c => c.value === '<0.0.0-0' +const isAny = c => c.value === '' + +// take a set of comparators and determine whether there +// exists a version which can satisfy it +const isSatisfiable = (comparators, options) => { + let result = true + const remainingComparators = comparators.slice() + let testComparator = remainingComparators.pop() + + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +const parseComparator = (comp, options) => { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} + +const isX = id => !id || id.toLowerCase() === 'x' || id === '*' + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} + +const replaceTilde = (comp, options) => { + const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, (_, M, m, p, pr) => { + debug('tilde', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0 <${+M + 1}.0.0-0` + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0-0 + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` + } else if (pr) { + debug('replaceTilde pr', pr) + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } else { + // ~1.2.3 == >=1.2.3 <1.3.0-0 + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0-0` + } + + debug('tilde return', ret) + return ret + }) +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 +// ^1.2.3 --> >=1.2.3 <2.0.0-0 +// ^1.2.0 --> >=1.2.0 <2.0.0-0 +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} + +const replaceCaret = (comp, options) => { + debug('caret', comp, options) + const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + const z = options.includePrerelease ? '-0' : '' + return comp.replace(r, (_, M, m, p, pr) => { + debug('caret', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` + } else if (isX(p)) { + if (M === '0') { + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` + } else { + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${+M + 1}.0.0-0` + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p + }${z} <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p + }${z} <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p + } <${+M + 1}.0.0-0` + } + } + + debug('caret return', ret) + return ret + }) +} + +const replaceXRanges = (comp, options) => { + debug('replaceXRanges', comp, options) + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') +} + +const replaceXRange = (comp, options) => { + comp = comp.trim() + const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + const xM = isX(M) + const xm = xM || isX(m) + const xp = xm || isX(p) + const anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + if (gtlt === '<') { + pr = '-0' + } + + ret = `${gtlt + M}.${m}.${p}${pr}` + } else if (xm) { + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` + } else if (xp) { + ret = `>=${M}.${m}.0${pr + } <${M}.${+m + 1}.0-0` + } + + debug('xRange return', ret) + + return ret + }) +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +const replaceStars = (comp, options) => { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp + .trim() + .replace(re[t.STAR], '') +} + +const replaceGTE0 = (comp, options) => { + debug('replaceGTE0', comp, options) + return comp + .trim() + .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') +} + +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 +const hyphenReplace = incPr => ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) => { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = `>=${fM}.0.0${incPr ? '-0' : ''}` + } else if (isX(fp)) { + from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` + } else if (fpr) { + from = `>=${from}` + } else { + from = `>=${from}${incPr ? '-0' : ''}` + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = `<${+tM + 1}.0.0-0` + } else if (isX(tp)) { + to = `<${tM}.${+tm + 1}.0-0` + } else if (tpr) { + to = `<=${tM}.${tm}.${tp}-${tpr}` + } else if (incPr) { + to = `<${tM}.${tm}.${+tp + 1}-0` + } else { + to = `<=${to}` + } + + return `${from} ${to}`.trim() +} + +const testSet = (set, version, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (let i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === Comparator.ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/classes/semver.js b/desktop/node_modules/global-agent/node_modules/semver/classes/semver.js new file mode 100644 index 0000000..84e8459 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/classes/semver.js @@ -0,0 +1,302 @@ +const debug = require('../internal/debug') +const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants') +const { safeRe: re, t } = require('../internal/re') + +const parseOptions = require('../internal/parse-options') +const { compareIdentifiers } = require('../internal/identifiers') +class SemVer { + constructor (version, options) { + options = parseOptions(options) + + if (version instanceof SemVer) { + if (version.loose === !!options.loose && + version.includePrerelease === !!options.includePrerelease) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${MAX_LENGTH} characters` + ) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + // this isn't actually relevant for versions, but keep it so that we + // don't run into trouble passing this.options around. + this.includePrerelease = !!options.includePrerelease + + const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + + if (!m) { + throw new TypeError(`Invalid Version: ${version}`) + } + + this.raw = version + + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() + } + + format () { + this.version = `${this.major}.${this.minor}.${this.patch}` + if (this.prerelease.length) { + this.version += `-${this.prerelease.join('.')}` + } + return this.version + } + + toString () { + return this.version + } + + compare (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + if (typeof other === 'string' && other === this.version) { + return 0 + } + other = new SemVer(other, this.options) + } + + if (other.version === this.version) { + return 0 + } + + return this.compareMain(other) || this.comparePre(other) + } + + compareMain (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ) + } + + comparePre (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } + + let i = 0 + do { + const a = this.prerelease[i] + const b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + compareBuild (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + let i = 0 + do { + const a = this.build[i] + const b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc (release, identifier, identifierBase) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier, identifierBase) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier, identifierBase) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier, identifierBase) + } + this.inc('pre', identifier, identifierBase) + break + + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. + case 'pre': { + const base = Number(identifierBase) ? 1 : 0 + + if (!identifier && identifierBase === false) { + throw new Error('invalid increment argument: identifier is empty') + } + + if (this.prerelease.length === 0) { + this.prerelease = [base] + } else { + let i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + if (identifier === this.prerelease.join('.') && identifierBase === false) { + throw new Error('invalid increment argument: identifier already exists') + } + this.prerelease.push(base) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { + if (isNaN(this.prerelease[1])) { + this.prerelease = prerelease + } + } else { + this.prerelease = prerelease + } + } + break + } + default: + throw new Error(`invalid increment argument: ${release}`) + } + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } + return this + } +} + +module.exports = SemVer diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/clean.js b/desktop/node_modules/global-agent/node_modules/semver/functions/clean.js new file mode 100644 index 0000000..811fe6b --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/clean.js @@ -0,0 +1,6 @@ +const parse = require('./parse') +const clean = (version, options) => { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} +module.exports = clean diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/cmp.js b/desktop/node_modules/global-agent/node_modules/semver/functions/cmp.js new file mode 100644 index 0000000..4011909 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/cmp.js @@ -0,0 +1,52 @@ +const eq = require('./eq') +const neq = require('./neq') +const gt = require('./gt') +const gte = require('./gte') +const lt = require('./lt') +const lte = require('./lte') + +const cmp = (a, op, b, loose) => { + switch (op) { + case '===': + if (typeof a === 'object') { + a = a.version + } + if (typeof b === 'object') { + b = b.version + } + return a === b + + case '!==': + if (typeof a === 'object') { + a = a.version + } + if (typeof b === 'object') { + b = b.version + } + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError(`Invalid operator: ${op}`) + } +} +module.exports = cmp diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/coerce.js b/desktop/node_modules/global-agent/node_modules/semver/functions/coerce.js new file mode 100644 index 0000000..febbff9 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/coerce.js @@ -0,0 +1,52 @@ +const SemVer = require('../classes/semver') +const parse = require('./parse') +const { safeRe: re, t } = require('../internal/re') + +const coerce = (version, options) => { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + let match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) { + return null + } + + return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +} +module.exports = coerce diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/compare-build.js b/desktop/node_modules/global-agent/node_modules/semver/functions/compare-build.js new file mode 100644 index 0000000..9eb881b --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/compare-build.js @@ -0,0 +1,7 @@ +const SemVer = require('../classes/semver') +const compareBuild = (a, b, loose) => { + const versionA = new SemVer(a, loose) + const versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} +module.exports = compareBuild diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/compare-loose.js b/desktop/node_modules/global-agent/node_modules/semver/functions/compare-loose.js new file mode 100644 index 0000000..4881fbe --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/compare-loose.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/compare.js b/desktop/node_modules/global-agent/node_modules/semver/functions/compare.js new file mode 100644 index 0000000..748b7af --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/compare.js @@ -0,0 +1,5 @@ +const SemVer = require('../classes/semver') +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) + +module.exports = compare diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/diff.js b/desktop/node_modules/global-agent/node_modules/semver/functions/diff.js new file mode 100644 index 0000000..fc224e3 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/diff.js @@ -0,0 +1,65 @@ +const parse = require('./parse.js') + +const diff = (version1, version2) => { + const v1 = parse(version1, null, true) + const v2 = parse(version2, null, true) + const comparison = v1.compare(v2) + + if (comparison === 0) { + return null + } + + const v1Higher = comparison > 0 + const highVersion = v1Higher ? v1 : v2 + const lowVersion = v1Higher ? v2 : v1 + const highHasPre = !!highVersion.prerelease.length + const lowHasPre = !!lowVersion.prerelease.length + + if (lowHasPre && !highHasPre) { + // Going from prerelease -> no prerelease requires some special casing + + // If the low version has only a major, then it will always be a major + // Some examples: + // 1.0.0-1 -> 1.0.0 + // 1.0.0-1 -> 1.1.1 + // 1.0.0-1 -> 2.0.0 + if (!lowVersion.patch && !lowVersion.minor) { + return 'major' + } + + // Otherwise it can be determined by checking the high version + + if (highVersion.patch) { + // anything higher than a patch bump would result in the wrong version + return 'patch' + } + + if (highVersion.minor) { + // anything higher than a minor bump would result in the wrong version + return 'minor' + } + + // bumping major/minor/patch all have same result + return 'major' + } + + // add the `pre` prefix if we are going to a prerelease version + const prefix = highHasPre ? 'pre' : '' + + if (v1.major !== v2.major) { + return prefix + 'major' + } + + if (v1.minor !== v2.minor) { + return prefix + 'minor' + } + + if (v1.patch !== v2.patch) { + return prefix + 'patch' + } + + // high and low are preleases + return 'prerelease' +} + +module.exports = diff diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/eq.js b/desktop/node_modules/global-agent/node_modules/semver/functions/eq.js new file mode 100644 index 0000000..271fed9 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/eq.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/gt.js b/desktop/node_modules/global-agent/node_modules/semver/functions/gt.js new file mode 100644 index 0000000..d9b2156 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/gt.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/gte.js b/desktop/node_modules/global-agent/node_modules/semver/functions/gte.js new file mode 100644 index 0000000..5aeaa63 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/gte.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/inc.js b/desktop/node_modules/global-agent/node_modules/semver/functions/inc.js new file mode 100644 index 0000000..7670b1b --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/inc.js @@ -0,0 +1,19 @@ +const SemVer = require('../classes/semver') + +const inc = (version, release, options, identifier, identifierBase) => { + if (typeof (options) === 'string') { + identifierBase = identifier + identifier = options + options = undefined + } + + try { + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version + } catch (er) { + return null + } +} +module.exports = inc diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/lt.js b/desktop/node_modules/global-agent/node_modules/semver/functions/lt.js new file mode 100644 index 0000000..b440ab7 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/lt.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/lte.js b/desktop/node_modules/global-agent/node_modules/semver/functions/lte.js new file mode 100644 index 0000000..6dcc956 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/lte.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/major.js b/desktop/node_modules/global-agent/node_modules/semver/functions/major.js new file mode 100644 index 0000000..4283165 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/major.js @@ -0,0 +1,3 @@ +const SemVer = require('../classes/semver') +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/minor.js b/desktop/node_modules/global-agent/node_modules/semver/functions/minor.js new file mode 100644 index 0000000..57b3455 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/minor.js @@ -0,0 +1,3 @@ +const SemVer = require('../classes/semver') +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/neq.js b/desktop/node_modules/global-agent/node_modules/semver/functions/neq.js new file mode 100644 index 0000000..f944c01 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/neq.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/parse.js b/desktop/node_modules/global-agent/node_modules/semver/functions/parse.js new file mode 100644 index 0000000..459b3b1 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/parse.js @@ -0,0 +1,16 @@ +const SemVer = require('../classes/semver') +const parse = (version, options, throwErrors = false) => { + if (version instanceof SemVer) { + return version + } + try { + return new SemVer(version, options) + } catch (er) { + if (!throwErrors) { + return null + } + throw er + } +} + +module.exports = parse diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/patch.js b/desktop/node_modules/global-agent/node_modules/semver/functions/patch.js new file mode 100644 index 0000000..63afca2 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/patch.js @@ -0,0 +1,3 @@ +const SemVer = require('../classes/semver') +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/prerelease.js b/desktop/node_modules/global-agent/node_modules/semver/functions/prerelease.js new file mode 100644 index 0000000..06aa132 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/prerelease.js @@ -0,0 +1,6 @@ +const parse = require('./parse') +const prerelease = (version, options) => { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} +module.exports = prerelease diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/rcompare.js b/desktop/node_modules/global-agent/node_modules/semver/functions/rcompare.js new file mode 100644 index 0000000..0ac509e --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/rcompare.js @@ -0,0 +1,3 @@ +const compare = require('./compare') +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/rsort.js b/desktop/node_modules/global-agent/node_modules/semver/functions/rsort.js new file mode 100644 index 0000000..82404c5 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/rsort.js @@ -0,0 +1,3 @@ +const compareBuild = require('./compare-build') +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/satisfies.js b/desktop/node_modules/global-agent/node_modules/semver/functions/satisfies.js new file mode 100644 index 0000000..50af1c1 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/satisfies.js @@ -0,0 +1,10 @@ +const Range = require('../classes/range') +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} +module.exports = satisfies diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/sort.js b/desktop/node_modules/global-agent/node_modules/semver/functions/sort.js new file mode 100644 index 0000000..4d10917 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/sort.js @@ -0,0 +1,3 @@ +const compareBuild = require('./compare-build') +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort diff --git a/desktop/node_modules/global-agent/node_modules/semver/functions/valid.js b/desktop/node_modules/global-agent/node_modules/semver/functions/valid.js new file mode 100644 index 0000000..f27bae1 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/functions/valid.js @@ -0,0 +1,6 @@ +const parse = require('./parse') +const valid = (version, options) => { + const v = parse(version, options) + return v ? v.version : null +} +module.exports = valid diff --git a/desktop/node_modules/global-agent/node_modules/semver/index.js b/desktop/node_modules/global-agent/node_modules/semver/index.js new file mode 100644 index 0000000..86d42ac --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/index.js @@ -0,0 +1,89 @@ +// just pre-load all the stuff that index.js lazily exports +const internalRe = require('./internal/re') +const constants = require('./internal/constants') +const SemVer = require('./classes/semver') +const identifiers = require('./internal/identifiers') +const parse = require('./functions/parse') +const valid = require('./functions/valid') +const clean = require('./functions/clean') +const inc = require('./functions/inc') +const diff = require('./functions/diff') +const major = require('./functions/major') +const minor = require('./functions/minor') +const patch = require('./functions/patch') +const prerelease = require('./functions/prerelease') +const compare = require('./functions/compare') +const rcompare = require('./functions/rcompare') +const compareLoose = require('./functions/compare-loose') +const compareBuild = require('./functions/compare-build') +const sort = require('./functions/sort') +const rsort = require('./functions/rsort') +const gt = require('./functions/gt') +const lt = require('./functions/lt') +const eq = require('./functions/eq') +const neq = require('./functions/neq') +const gte = require('./functions/gte') +const lte = require('./functions/lte') +const cmp = require('./functions/cmp') +const coerce = require('./functions/coerce') +const Comparator = require('./classes/comparator') +const Range = require('./classes/range') +const satisfies = require('./functions/satisfies') +const toComparators = require('./ranges/to-comparators') +const maxSatisfying = require('./ranges/max-satisfying') +const minSatisfying = require('./ranges/min-satisfying') +const minVersion = require('./ranges/min-version') +const validRange = require('./ranges/valid') +const outside = require('./ranges/outside') +const gtr = require('./ranges/gtr') +const ltr = require('./ranges/ltr') +const intersects = require('./ranges/intersects') +const simplifyRange = require('./ranges/simplify') +const subset = require('./ranges/subset') +module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/internal/constants.js b/desktop/node_modules/global-agent/node_modules/semver/internal/constants.js new file mode 100644 index 0000000..94be1c5 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/internal/constants.js @@ -0,0 +1,35 @@ +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0' + +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || +/* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16 + +// Max safe length for a build identifier. The max length minus 6 characters for +// the shortest version with a build 0.0.0+BUILD. +const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6 + +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + +module.exports = { + MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_SAFE_INTEGER, + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/internal/debug.js b/desktop/node_modules/global-agent/node_modules/semver/internal/debug.js new file mode 100644 index 0000000..1c00e13 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/internal/debug.js @@ -0,0 +1,9 @@ +const debug = ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) +) ? (...args) => console.error('SEMVER', ...args) + : () => {} + +module.exports = debug diff --git a/desktop/node_modules/global-agent/node_modules/semver/internal/identifiers.js b/desktop/node_modules/global-agent/node_modules/semver/internal/identifiers.js new file mode 100644 index 0000000..e612d0a --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/internal/identifiers.js @@ -0,0 +1,23 @@ +const numeric = /^[0-9]+$/ +const compareIdentifiers = (a, b) => { + const anum = numeric.test(a) + const bnum = numeric.test(b) + + if (anum && bnum) { + a = +a + b = +b + } + + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} + +const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) + +module.exports = { + compareIdentifiers, + rcompareIdentifiers, +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/internal/parse-options.js b/desktop/node_modules/global-agent/node_modules/semver/internal/parse-options.js new file mode 100644 index 0000000..10d64ce --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/internal/parse-options.js @@ -0,0 +1,15 @@ +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} +module.exports = parseOptions diff --git a/desktop/node_modules/global-agent/node_modules/semver/internal/re.js b/desktop/node_modules/global-agent/node_modules/semver/internal/re.js new file mode 100644 index 0000000..21150b3 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/internal/re.js @@ -0,0 +1,212 @@ +const { + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_LENGTH, +} = require('./constants') +const debug = require('./debug') +exports = module.exports = {} + +// The actual regexps go on exports.re +const re = exports.re = [] +const safeRe = exports.safeRe = [] +const src = exports.src = [] +const t = exports.t = {} +let R = 0 + +const LETTERDASHNUMBER = '[a-zA-Z0-9-]' + +// Replace some greedy regex tokens to prevent regex dos issues. These regex are +// used internally via the safeRe object since all inputs in this library get +// normalized first to trim and collapse all extra whitespace. The original +// regexes are exported for userland consumption and lower level usage. A +// future breaking change could export the safer regex only with a note that +// all input should have extra whitespace removed. +const safeRegexReplacements = [ + ['\\s', 1], + ['\\d', MAX_LENGTH], + [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH], +] + +const makeSafeRegex = (value) => { + for (const [token, max] of safeRegexReplacements) { + value = value + .split(`${token}*`).join(`${token}{0,${max}}`) + .split(`${token}+`).join(`${token}{1,${max}}`) + } + return value +} + +const createToken = (name, value, isGlobal) => { + const safe = makeSafeRegex(value) + const index = R++ + debug(name, index, value) + t[name] = index + src[index] = value + re[index] = new RegExp(value, isGlobal ? 'g' : undefined) + safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined) +} + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') +createToken('NUMERICIDENTIFIERLOOSE', '\\d+') + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`) + +// ## Main Version +// Three dot-separated numeric identifiers. + +createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})`) + +createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})`) + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] +}|${src[t.NONNUMERICIDENTIFIER]})`) + +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] +}|${src[t.NONNUMERICIDENTIFIER]})`) + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] +}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) + +createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] +}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`) + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`) + +createToken('FULL', `^${src[t.FULLPLAIN]}$`) + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] +}${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`) + +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) + +createToken('GTLT', '((?:<|>)?=?)') + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) + +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`) + +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`) + +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +createToken('COERCE', `${'(^|[^\\d])' + + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:$|[^\\d])`) +createToken('COERCERTL', src[t.COERCE], true) + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +createToken('LONETILDE', '(?:~>?)') + +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) +exports.tildeTrimReplace = '$1~' + +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)') + +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) +exports.caretTrimReplace = '$1^' + +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] +}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) +exports.comparatorTrimReplace = '$1$2$3' + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAIN]})` + + `\\s*$`) + +createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAINLOOSE]})` + + `\\s*$`) + +// Star ranges basically just allow anything at all. +createToken('STAR', '(<|>)?=?\\s*\\*') +// >=0.0.0 is like a star +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') diff --git a/desktop/node_modules/global-agent/node_modules/semver/package.json b/desktop/node_modules/global-agent/node_modules/semver/package.json new file mode 100644 index 0000000..c145eca --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/package.json @@ -0,0 +1,87 @@ +{ + "name": "semver", + "version": "7.5.4", + "description": "The semantic version parser used by npm.", + "main": "index.js", + "scripts": { + "test": "tap", + "snap": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", + "template-oss-apply": "template-oss-apply --force" + }, + "devDependencies": { + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.17.0", + "tap": "^16.0.0" + }, + "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/npm/node-semver.git" + }, + "bin": { + "semver": "bin/semver.js" + }, + "files": [ + "bin/", + "lib/", + "classes/", + "functions/", + "internal/", + "ranges/", + "index.js", + "preload.js", + "range.bnf" + ], + "tap": { + "timeout": 30, + "coverage-map": "map.js", + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] + }, + "engines": { + "node": ">=10" + }, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "author": "GitHub Inc.", + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.17.0", + "engines": ">=10", + "ciVersions": [ + "10.0.0", + "10.x", + "12.x", + "14.x", + "16.x", + "18.x" + ], + "npmSpec": "8", + "distPaths": [ + "classes/", + "functions/", + "internal/", + "ranges/", + "index.js", + "preload.js", + "range.bnf" + ], + "allowPaths": [ + "/classes/", + "/functions/", + "/internal/", + "/ranges/", + "/index.js", + "/preload.js", + "/range.bnf" + ], + "publish": "true" + } +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/preload.js b/desktop/node_modules/global-agent/node_modules/semver/preload.js new file mode 100644 index 0000000..947cd4f --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/preload.js @@ -0,0 +1,2 @@ +// XXX remove in v8 or beyond +module.exports = require('./index.js') diff --git a/desktop/node_modules/global-agent/node_modules/semver/range.bnf b/desktop/node_modules/global-agent/node_modules/semver/range.bnf new file mode 100644 index 0000000..d4c6ae0 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/range.bnf @@ -0,0 +1,16 @@ +range-set ::= range ( logical-or range ) * +logical-or ::= ( ' ' ) * '||' ( ' ' ) * +range ::= hyphen | simple ( ' ' simple ) * | '' +hyphen ::= partial ' - ' partial +simple ::= primitive | partial | tilde | caret +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial +partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? +xr ::= 'x' | 'X' | '*' | nr +nr ::= '0' | [1-9] ( [0-9] ) * +tilde ::= '~' partial +caret ::= '^' partial +qualifier ::= ( '-' pre )? ( '+' build )? +pre ::= parts +build ::= parts +parts ::= part ( '.' part ) * +part ::= nr | [-0-9A-Za-z]+ diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/gtr.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/gtr.js new file mode 100644 index 0000000..db7e355 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/gtr.js @@ -0,0 +1,4 @@ +// Determine if version is greater than all the versions possible in the range. +const outside = require('./outside') +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/intersects.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/intersects.js new file mode 100644 index 0000000..e0e9b7c --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/intersects.js @@ -0,0 +1,7 @@ +const Range = require('../classes/range') +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2, options) +} +module.exports = intersects diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/ltr.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/ltr.js new file mode 100644 index 0000000..528a885 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/ltr.js @@ -0,0 +1,4 @@ +const outside = require('./outside') +// Determine if version is less than all the versions possible in the range +const ltr = (version, range, options) => outside(version, range, '<', options) +module.exports = ltr diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/max-satisfying.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/max-satisfying.js new file mode 100644 index 0000000..6e3d993 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/max-satisfying.js @@ -0,0 +1,25 @@ +const SemVer = require('../classes/semver') +const Range = require('../classes/range') + +const maxSatisfying = (versions, range, options) => { + let max = null + let maxSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max +} +module.exports = maxSatisfying diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/min-satisfying.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/min-satisfying.js new file mode 100644 index 0000000..9b60974 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/min-satisfying.js @@ -0,0 +1,24 @@ +const SemVer = require('../classes/semver') +const Range = require('../classes/range') +const minSatisfying = (versions, range, options) => { + let min = null + let minSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min +} +module.exports = minSatisfying diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/min-version.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/min-version.js new file mode 100644 index 0000000..350e1f7 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/min-version.js @@ -0,0 +1,61 @@ +const SemVer = require('../classes/semver') +const Range = require('../classes/range') +const gt = require('../functions/gt') + +const minVersion = (range, loose) => { + range = new Range(range, loose) + + let minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + let setMin = null + comparators.forEach((comparator) => { + // Clone to avoid manipulating the comparator's semver object. + const compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!setMin || gt(compver, setMin)) { + setMin = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }) + if (setMin && (!minver || gt(minver, setMin))) { + minver = setMin + } + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} +module.exports = minVersion diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/outside.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/outside.js new file mode 100644 index 0000000..ae99b10 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/outside.js @@ -0,0 +1,80 @@ +const SemVer = require('../classes/semver') +const Comparator = require('../classes/comparator') +const { ANY } = Comparator +const Range = require('../classes/range') +const satisfies = require('../functions/satisfies') +const gt = require('../functions/gt') +const lt = require('../functions/lt') +const lte = require('../functions/lte') +const gte = require('../functions/gte') + +const outside = (version, range, hilo, options) => { + version = new SemVer(version, options) + range = new Range(range, options) + + let gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisfies the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + let high = null + let low = null + + comparators.forEach((comparator) => { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +} + +module.exports = outside diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/simplify.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/simplify.js new file mode 100644 index 0000000..618d5b6 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/simplify.js @@ -0,0 +1,47 @@ +// given a set of versions and a range, create a "simplified" range +// that includes the same versions that the original range does +// If the original range is shorter than the simplified one, return that. +const satisfies = require('../functions/satisfies.js') +const compare = require('../functions/compare.js') +module.exports = (versions, range, options) => { + const set = [] + let first = null + let prev = null + const v = versions.sort((a, b) => compare(a, b, options)) + for (const version of v) { + const included = satisfies(version, range, options) + if (included) { + prev = version + if (!first) { + first = version + } + } else { + if (prev) { + set.push([first, prev]) + } + prev = null + first = null + } + } + if (first) { + set.push([first, null]) + } + + const ranges = [] + for (const [min, max] of set) { + if (min === max) { + ranges.push(min) + } else if (!max && min === v[0]) { + ranges.push('*') + } else if (!max) { + ranges.push(`>=${min}`) + } else if (min === v[0]) { + ranges.push(`<=${max}`) + } else { + ranges.push(`${min} - ${max}`) + } + } + const simplified = ranges.join(' || ') + const original = typeof range.raw === 'string' ? range.raw : String(range) + return simplified.length < original.length ? simplified : range +} diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/subset.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/subset.js new file mode 100644 index 0000000..1e5c268 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/subset.js @@ -0,0 +1,247 @@ +const Range = require('../classes/range.js') +const Comparator = require('../classes/comparator.js') +const { ANY } = Comparator +const satisfies = require('../functions/satisfies.js') +const compare = require('../functions/compare.js') + +// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: +// - Every simple range `r1, r2, ...` is a null set, OR +// - Every simple range `r1, r2, ...` which is not a null set is a subset of +// some `R1, R2, ...` +// +// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: +// - If c is only the ANY comparator +// - If C is only the ANY comparator, return true +// - Else if in prerelease mode, return false +// - else replace c with `[>=0.0.0]` +// - If C is only the ANY comparator +// - if in prerelease mode, return true +// - else replace C with `[>=0.0.0]` +// - Let EQ be the set of = comparators in c +// - If EQ is more than one, return true (null set) +// - Let GT be the highest > or >= comparator in c +// - Let LT be the lowest < or <= comparator in c +// - If GT and LT, and GT.semver > LT.semver, return true (null set) +// - If any C is a = range, and GT or LT are set, return false +// - If EQ +// - If GT, and EQ does not satisfy GT, return true (null set) +// - If LT, and EQ does not satisfy LT, return true (null set) +// - If EQ satisfies every C, return true +// - Else return false +// - If GT +// - If GT.semver is lower than any > or >= comp in C, return false +// - If GT is >=, and GT.semver does not satisfy every C, return false +// - If GT.semver has a prerelease, and not in prerelease mode +// - If no C has a prerelease and the GT.semver tuple, return false +// - If LT +// - If LT.semver is greater than any < or <= comp in C, return false +// - If LT is <=, and LT.semver does not satisfy every C, return false +// - If GT.semver has a prerelease, and not in prerelease mode +// - If no C has a prerelease and the LT.semver tuple, return false +// - Else return true + +const subset = (sub, dom, options = {}) => { + if (sub === dom) { + return true + } + + sub = new Range(sub, options) + dom = new Range(dom, options) + let sawNonNull = false + + OUTER: for (const simpleSub of sub.set) { + for (const simpleDom of dom.set) { + const isSub = simpleSubset(simpleSub, simpleDom, options) + sawNonNull = sawNonNull || isSub !== null + if (isSub) { + continue OUTER + } + } + // the null set is a subset of everything, but null simple ranges in + // a complex range should be ignored. so if we saw a non-null range, + // then we know this isn't a subset, but if EVERY simple range was null, + // then it is a subset. + if (sawNonNull) { + return false + } + } + return true +} + +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + +const simpleSubset = (sub, dom, options) => { + if (sub === dom) { + return true + } + + if (sub.length === 1 && sub[0].semver === ANY) { + if (dom.length === 1 && dom[0].semver === ANY) { + return true + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } + } + + if (dom.length === 1 && dom[0].semver === ANY) { + if (options.includePrerelease) { + return true + } else { + dom = minimumVersion + } + } + + const eqSet = new Set() + let gt, lt + for (const c of sub) { + if (c.operator === '>' || c.operator === '>=') { + gt = higherGT(gt, c, options) + } else if (c.operator === '<' || c.operator === '<=') { + lt = lowerLT(lt, c, options) + } else { + eqSet.add(c.semver) + } + } + + if (eqSet.size > 1) { + return null + } + + let gtltComp + if (gt && lt) { + gtltComp = compare(gt.semver, lt.semver, options) + if (gtltComp > 0) { + return null + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { + return null + } + } + + // will iterate one or zero times + for (const eq of eqSet) { + if (gt && !satisfies(eq, String(gt), options)) { + return null + } + + if (lt && !satisfies(eq, String(lt), options)) { + return null + } + + for (const c of dom) { + if (!satisfies(eq, String(c), options)) { + return false + } + } + + return true + } + + let higher, lower + let hasDomLT, hasDomGT + // if the subset has a prerelease, we need a comparator in the superset + // with the same tuple and a prerelease, or it's not a subset + let needDomLTPre = lt && + !options.includePrerelease && + lt.semver.prerelease.length ? lt.semver : false + let needDomGTPre = gt && + !options.includePrerelease && + gt.semver.prerelease.length ? gt.semver : false + // exception: <1.2.3-0 is the same as <1.2.3 + if (needDomLTPre && needDomLTPre.prerelease.length === 1 && + lt.operator === '<' && needDomLTPre.prerelease[0] === 0) { + needDomLTPre = false + } + + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' + hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' + if (gt) { + if (needDomGTPre) { + if (c.semver.prerelease && c.semver.prerelease.length && + c.semver.major === needDomGTPre.major && + c.semver.minor === needDomGTPre.minor && + c.semver.patch === needDomGTPre.patch) { + needDomGTPre = false + } + } + if (c.operator === '>' || c.operator === '>=') { + higher = higherGT(gt, c, options) + if (higher === c && higher !== gt) { + return false + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { + return false + } + } + if (lt) { + if (needDomLTPre) { + if (c.semver.prerelease && c.semver.prerelease.length && + c.semver.major === needDomLTPre.major && + c.semver.minor === needDomLTPre.minor && + c.semver.patch === needDomLTPre.patch) { + needDomLTPre = false + } + } + if (c.operator === '<' || c.operator === '<=') { + lower = lowerLT(lt, c, options) + if (lower === c && lower !== lt) { + return false + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { + return false + } + } + if (!c.operator && (lt || gt) && gtltComp !== 0) { + return false + } + } + + // if there was a < or >, and nothing in the dom, then must be false + // UNLESS it was limited by another range in the other direction. + // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 + if (gt && hasDomLT && !lt && gtltComp !== 0) { + return false + } + + if (lt && hasDomGT && !gt && gtltComp !== 0) { + return false + } + + // we needed a prerelease range in a specific tuple, but didn't get one + // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, + // because it includes prereleases in the 1.2.3 tuple + if (needDomGTPre || needDomLTPre) { + return false + } + + return true +} + +// >=1.2.3 is lower than >1.2.3 +const higherGT = (a, b, options) => { + if (!a) { + return b + } + const comp = compare(a.semver, b.semver, options) + return comp > 0 ? a + : comp < 0 ? b + : b.operator === '>' && a.operator === '>=' ? b + : a +} + +// <=1.2.3 is higher than <1.2.3 +const lowerLT = (a, b, options) => { + if (!a) { + return b + } + const comp = compare(a.semver, b.semver, options) + return comp < 0 ? a + : comp > 0 ? b + : b.operator === '<' && a.operator === '<=' ? b + : a +} + +module.exports = subset diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/to-comparators.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/to-comparators.js new file mode 100644 index 0000000..6c8bc7e --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/to-comparators.js @@ -0,0 +1,8 @@ +const Range = require('../classes/range') + +// Mostly just for testing and legacy API reasons +const toComparators = (range, options) => + new Range(range, options).set + .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) + +module.exports = toComparators diff --git a/desktop/node_modules/global-agent/node_modules/semver/ranges/valid.js b/desktop/node_modules/global-agent/node_modules/semver/ranges/valid.js new file mode 100644 index 0000000..365f356 --- /dev/null +++ b/desktop/node_modules/global-agent/node_modules/semver/ranges/valid.js @@ -0,0 +1,11 @@ +const Range = require('../classes/range') +const validRange = (range, options) => { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} +module.exports = validRange diff --git a/desktop/node_modules/global-agent/package.json b/desktop/node_modules/global-agent/package.json new file mode 100644 index 0000000..85f31af --- /dev/null +++ b/desktop/node_modules/global-agent/package.json @@ -0,0 +1,105 @@ +{ + "author": { + "email": "gajus@gajus.com", + "name": "Gajus Kuizinas", + "url": "http://gajus.com" + }, + "ava": { + "babel": { + "compileAsTests": [ + "test/helpers/**/*" + ] + }, + "files": [ + "test/global-agent/**/*" + ], + "require": [ + "@babel/register" + ] + }, + "dependencies": { + "boolean": "^3.0.1", + "es6-error": "^4.1.1", + "matcher": "^3.0.0", + "roarr": "^2.15.3", + "semver": "^7.3.2", + "serialize-error": "^7.0.1" + }, + "description": "Global HTTP/HTTPS proxy configurable using environment variables.", + "devDependencies": { + "@ava/babel": "^1.0.1", + "@babel/cli": "^7.10.1", + "@babel/core": "^7.10.2", + "@babel/node": "^7.10.1", + "@babel/plugin-transform-flow-strip-types": "^7.10.1", + "@babel/preset-env": "^7.10.2", + "@babel/register": "^7.10.1", + "anyproxy": "^4.1.2", + "ava": "^3.8.2", + "axios": "^0.19.2", + "babel-plugin-istanbul": "^6.0.0", + "babel-plugin-transform-export-default-name": "^2.0.4", + "coveralls": "^3.1.0", + "eslint": "^7.1.0", + "eslint-config-canonical": "^20.0.5", + "flow-bin": "^0.125.1", + "flow-copy-source": "^2.0.9", + "get-port": "^5.1.1", + "got": "^11.1.4", + "husky": "^4.2.5", + "nyc": "^15.1.0", + "pem": "^1.14.4", + "request": "^2.88.2", + "semantic-release": "^17.0.8", + "sinon": "^9.0.2" + }, + "engines": { + "node": ">=10.0" + }, + "husky": { + "hooks": { + "pre-commit": "npm run lint && npm run test && npm run build" + } + }, + "keywords": [ + "http", + "global", + "proxy", + "agent" + ], + "license": "BSD-3-Clause", + "main": "./dist/index.js", + "name": "global-agent", + "nyc": { + "all": true, + "exclude": [ + "src/bin", + "src/queries/*.js" + ], + "include": [ + "src/**/*.js" + ], + "instrument": false, + "reporter": [ + "html", + "text-summary" + ], + "require": [ + "@babel/register" + ], + "silent": true, + "sourceMap": false + }, + "repository": { + "type": "git", + "url": "https://github.com/gajus/global-agent" + }, + "scripts": { + "build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps && flow-copy-source src dist", + "create-readme": "gitdown ./.README/README.md --output-file ./README.md", + "dev": "NODE_ENV=development babel ./src --out-dir ./dist --copy-files --source-maps --watch", + "lint": "eslint ./src ./test && flow", + "test": "NODE_TLS_REJECT_UNAUTHORIZED=false NODE_ENV=test nyc ava --verbose --serial" + }, + "version": "3.0.0" +} diff --git a/desktop/node_modules/global-agent/src/Logger.js b/desktop/node_modules/global-agent/src/Logger.js new file mode 100644 index 0000000..166f1e4 --- /dev/null +++ b/desktop/node_modules/global-agent/src/Logger.js @@ -0,0 +1,10 @@ +// @flow + +import Roarr from 'roarr'; + +const Logger = Roarr + .child({ + package: 'global-agent', + }); + +export default Logger; diff --git a/desktop/node_modules/global-agent/src/classes/Agent.js b/desktop/node_modules/global-agent/src/classes/Agent.js new file mode 100644 index 0000000..801dd1f --- /dev/null +++ b/desktop/node_modules/global-agent/src/classes/Agent.js @@ -0,0 +1,212 @@ +// @flow + +import { + serializeError, +} from 'serialize-error'; +import { + boolean, +} from 'boolean'; +import Logger from '../Logger'; +import type { + AgentType, + GetUrlProxyMethodType, + IsProxyConfiguredMethodType, + MustUrlUseProxyMethodType, + ProtocolType, +} from '../types'; + +const log = Logger.child({ + namespace: 'Agent', +}); + +let requestId = 0; + +class Agent { + defaultPort: number; + + protocol: ProtocolType; + + fallbackAgent: AgentType; + + isProxyConfigured: IsProxyConfiguredMethodType; + + mustUrlUseProxy: MustUrlUseProxyMethodType; + + getUrlProxy: GetUrlProxyMethodType; + + socketConnectionTimeout: number; + + constructor ( + isProxyConfigured: IsProxyConfiguredMethodType, + mustUrlUseProxy: MustUrlUseProxyMethodType, + getUrlProxy: GetUrlProxyMethodType, + fallbackAgent: AgentType, + socketConnectionTimeout: number, + ) { + this.fallbackAgent = fallbackAgent; + this.isProxyConfigured = isProxyConfigured; + this.mustUrlUseProxy = mustUrlUseProxy; + this.getUrlProxy = getUrlProxy; + this.socketConnectionTimeout = socketConnectionTimeout; + } + + addRequest (request: *, configuration: *) { + let requestUrl; + + // It is possible that addRequest was constructed for a proxied request already, e.g. + // "request" package does this when it detects that a proxy should be used + // https://github.com/request/request/blob/212570b6971a732b8dd9f3c73354bcdda158a737/request.js#L402 + // https://gist.github.com/gajus/e2074cd3b747864ffeaabbd530d30218 + if (request.path.startsWith('http://') || request.path.startsWith('https://')) { + requestUrl = request.path; + } else { + requestUrl = this.protocol + '//' + (configuration.hostname || configuration.host) + (configuration.port === 80 || configuration.port === 443 ? '' : ':' + configuration.port) + request.path; + } + + if (!this.isProxyConfigured()) { + log.trace({ + destination: requestUrl, + }, 'not proxying request; GLOBAL_AGENT.HTTP_PROXY is not configured'); + + // $FlowFixMe It appears that Flow is missing the method description. + this.fallbackAgent.addRequest(request, configuration); + + return; + } + + if (!this.mustUrlUseProxy(requestUrl)) { + log.trace({ + destination: requestUrl, + }, 'not proxying request; url matches GLOBAL_AGENT.NO_PROXY'); + + // $FlowFixMe It appears that Flow is missing the method description. + this.fallbackAgent.addRequest(request, configuration); + + return; + } + + const currentRequestId = requestId++; + + const proxy = this.getUrlProxy(requestUrl); + + if (this.protocol === 'http:') { + request.path = requestUrl; + + if (proxy.authorization) { + request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64')); + } + } + + log.trace({ + destination: requestUrl, + proxy: 'http://' + proxy.hostname + ':' + proxy.port, + requestId: currentRequestId, + }, 'proxying request'); + + request.on('error', (error) => { + log.error({ + error: serializeError(error), + }, 'request error'); + }); + + request.once('response', (response) => { + log.trace({ + headers: response.headers, + requestId: currentRequestId, + statusCode: response.statusCode, + }, 'proxying response'); + }); + + request.shouldKeepAlive = false; + + const connectionConfiguration = { + host: configuration.hostname || configuration.host, + port: configuration.port || 80, + proxy, + tls: {}, + }; + + // add optional tls options for https requests. + // @see https://nodejs.org/docs/latest-v12.x/api/https.html#https_https_request_url_options_callback : + // > The following additional options from tls.connect() + // > - https://nodejs.org/docs/latest-v12.x/api/tls.html#tls_tls_connect_options_callback - + // > are also accepted: + // > ca, cert, ciphers, clientCertEngine, crl, dhparam, ecdhCurve, honorCipherOrder, + // > key, passphrase, pfx, rejectUnauthorized, secureOptions, secureProtocol, servername, sessionIdContext. + if (this.protocol === 'https:') { + connectionConfiguration.tls = { + ca: configuration.ca, + cert: configuration.cert, + ciphers: configuration.ciphers, + clientCertEngine: configuration.clientCertEngine, + crl: configuration.crl, + dhparam: configuration.dhparam, + ecdhCurve: configuration.ecdhCurve, + honorCipherOrder: configuration.honorCipherOrder, + key: configuration.key, + passphrase: configuration.passphrase, + pfx: configuration.pfx, + rejectUnauthorized: configuration.rejectUnauthorized, + secureOptions: configuration.secureOptions, + secureProtocol: configuration.secureProtocol, + servername: configuration.servername || connectionConfiguration.host, + sessionIdContext: configuration.sessionIdContext, + }; + + // This is not ideal because there is no way to override this setting using `tls` configuration if `NODE_TLS_REJECT_UNAUTHORIZED=0`. + // However, popular HTTP clients (such as https://github.com/sindresorhus/got) come with pre-configured value for `rejectUnauthorized`, + // which makes it impossible to override that value globally and respect `rejectUnauthorized` for specific requests only. + // + // eslint-disable-next-line no-process-env + if (typeof process.env.NODE_TLS_REJECT_UNAUTHORIZED === 'string' && boolean(process.env.NODE_TLS_REJECT_UNAUTHORIZED) === false) { + connectionConfiguration.tls.rejectUnauthorized = false; + } + } + + // $FlowFixMe It appears that Flow is missing the method description. + this.createConnection(connectionConfiguration, (error, socket) => { + log.trace({ + target: connectionConfiguration, + }, 'connecting'); + + // @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057 + if (socket) { + socket.setTimeout(this.socketConnectionTimeout, () => { + socket.destroy(); + }); + + socket.once('connect', () => { + log.trace({ + target: connectionConfiguration, + }, 'connected'); + + socket.setTimeout(0); + }); + + socket.once('secureConnect', () => { + log.trace({ + target: connectionConfiguration, + }, 'connected (secure)'); + + socket.setTimeout(0); + }); + } + + if (error) { + request.emit('error', error); + } else { + log.debug('created socket'); + + socket.on('error', (socketError) => { + log.error({ + error: serializeError(socketError), + }, 'socket error'); + }); + + request.onSocket(socket); + } + }); + } +} + +export default Agent; diff --git a/desktop/node_modules/global-agent/src/classes/HttpProxyAgent.js b/desktop/node_modules/global-agent/src/classes/HttpProxyAgent.js new file mode 100644 index 0000000..8b9b471 --- /dev/null +++ b/desktop/node_modules/global-agent/src/classes/HttpProxyAgent.js @@ -0,0 +1,30 @@ +// @flow + +import net from 'net'; +import type { + ConnectionCallbackType, + ConnectionConfigurationType, +} from '../types'; +import Agent from './Agent'; + +class HttpProxyAgent extends Agent { + // @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/169#issuecomment-486980290 + // eslint-disable-next-line unicorn/prevent-abbreviations + constructor (...args: *) { + super(...args); + + this.protocol = 'http:'; + this.defaultPort = 80; + } + + createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) { + const socket = net.connect( + configuration.proxy.port, + configuration.proxy.hostname, + ); + + callback(null, socket); + } +} + +export default HttpProxyAgent; diff --git a/desktop/node_modules/global-agent/src/classes/HttpsProxyAgent.js b/desktop/node_modules/global-agent/src/classes/HttpsProxyAgent.js new file mode 100644 index 0000000..24d724f --- /dev/null +++ b/desktop/node_modules/global-agent/src/classes/HttpsProxyAgent.js @@ -0,0 +1,54 @@ +// @flow + +import net from 'net'; +import tls from 'tls'; +import type { + ConnectionCallbackType, + ConnectionConfigurationType, +} from '../types'; +import Agent from './Agent'; + +class HttpsProxyAgent extends Agent { + // eslint-disable-next-line unicorn/prevent-abbreviations + constructor (...args: *) { + super(...args); + + this.protocol = 'https:'; + this.defaultPort = 443; + } + + createConnection (configuration: ConnectionConfigurationType, callback: ConnectionCallbackType) { + const socket = net.connect( + configuration.proxy.port, + configuration.proxy.hostname, + ); + + socket.on('error', (error) => { + callback(error); + }); + + socket.once('data', () => { + const secureSocket = tls.connect({ + ...configuration.tls, + socket, + }); + + callback(null, secureSocket); + }); + + let connectMessage = ''; + + connectMessage += 'CONNECT ' + configuration.host + ':' + configuration.port + ' HTTP/1.1\r\n'; + connectMessage += 'Host: ' + configuration.host + ':' + configuration.port + '\r\n'; + + if (configuration.proxy.authorization) { + connectMessage += 'Proxy-Authorization: Basic ' + Buffer.from(configuration.proxy.authorization).toString('base64') + '\r\n'; + } + + connectMessage += '\r\n'; + + socket.write(connectMessage); + } +} + +export default HttpsProxyAgent; diff --git a/desktop/node_modules/global-agent/src/classes/index.js b/desktop/node_modules/global-agent/src/classes/index.js new file mode 100644 index 0000000..9e8418a --- /dev/null +++ b/desktop/node_modules/global-agent/src/classes/index.js @@ -0,0 +1,5 @@ +// @flow + +export {default as Agent} from './Agent'; +export {default as HttpProxyAgent} from './HttpProxyAgent'; +export {default as HttpsProxyAgent} from './HttpsProxyAgent'; diff --git a/desktop/node_modules/global-agent/src/errors.js b/desktop/node_modules/global-agent/src/errors.js new file mode 100644 index 0000000..d93ba6f --- /dev/null +++ b/desktop/node_modules/global-agent/src/errors.js @@ -0,0 +1,15 @@ +// @flow + +/* eslint-disable fp/no-class, fp/no-this */ + +import ExtendableError from 'es6-error'; + +export class UnexpectedStateError extends ExtendableError { + code: string; + + constructor (message: string, code: string = 'UNEXPECTED_STATE_ERROR') { + super(message); + + this.code = code; + } +} diff --git a/desktop/node_modules/global-agent/src/factories/createGlobalProxyAgent.js b/desktop/node_modules/global-agent/src/factories/createGlobalProxyAgent.js new file mode 100644 index 0000000..d515a9d --- /dev/null +++ b/desktop/node_modules/global-agent/src/factories/createGlobalProxyAgent.js @@ -0,0 +1,197 @@ +// @flow + +import http from 'http'; +import https from 'https'; +import { + boolean as parseBoolean, +} from 'boolean'; +import semver from 'semver'; +import Logger from '../Logger'; +import { + HttpProxyAgent, + HttpsProxyAgent, +} from '../classes'; +import { + UnexpectedStateError, +} from '../errors'; +import { + bindHttpMethod, + isUrlMatchingNoProxy, + parseProxyUrl, +} from '../utilities'; +import type { + ProxyAgentConfigurationInputType, + ProxyAgentConfigurationType, +} from '../types'; +import createProxyController from './createProxyController'; + +const httpGet = http.get; +const httpRequest = http.request; +const httpsGet = https.get; +const httpsRequest = https.request; + +const log = Logger.child({ + namespace: 'createGlobalProxyAgent', +}); + +const defaultConfigurationInput = { + environmentVariableNamespace: undefined, + forceGlobalAgent: undefined, + socketConnectionTimeout: 60000, +}; + +const omitUndefined = (subject) => { + const keys = Object.keys(subject); + + const result = {}; + + for (const key of keys) { + const value = subject[key]; + + if (value !== undefined) { + result[key] = value; + } + } + + return result; +}; + +const createConfiguration = (configurationInput: ProxyAgentConfigurationInputType): ProxyAgentConfigurationType => { + // eslint-disable-next-line no-process-env + const environment = process.env; + + const defaultConfiguration = { + environmentVariableNamespace: typeof environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE === 'string' ? environment.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE : 'GLOBAL_AGENT_', + forceGlobalAgent: typeof environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT === 'string' ? parseBoolean(environment.GLOBAL_AGENT_FORCE_GLOBAL_AGENT) : true, + socketConnectionTimeout: typeof environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT === 'string' ? Number.parseInt(environment.GLOBAL_AGENT_SOCKET_CONNECTION_TIMEOUT, 10) : defaultConfigurationInput.socketConnectionTimeout, + }; + + // $FlowFixMe + return { + ...defaultConfiguration, + ...omitUndefined(configurationInput), + }; +}; + +export default (configurationInput: ProxyAgentConfigurationInputType = defaultConfigurationInput) => { + const configuration = createConfiguration(configurationInput); + + const proxyController = createProxyController(); + + // eslint-disable-next-line no-process-env + proxyController.HTTP_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTP_PROXY'] || null; + + // eslint-disable-next-line no-process-env + proxyController.HTTPS_PROXY = process.env[configuration.environmentVariableNamespace + 'HTTPS_PROXY'] || null; + + // eslint-disable-next-line no-process-env + proxyController.NO_PROXY = process.env[configuration.environmentVariableNamespace + 'NO_PROXY'] || null; + + log.info({ + configuration, + state: proxyController, + }, 'global agent has been initialized'); + + const mustUrlUseProxy = (getProxy) => { + return (url) => { + if (!getProxy()) { + return false; + } + + if (!proxyController.NO_PROXY) { + return true; + } + + return !isUrlMatchingNoProxy(url, proxyController.NO_PROXY); + }; + }; + + const getUrlProxy = (getProxy) => { + return () => { + const proxy = getProxy(); + + if (!proxy) { + throw new UnexpectedStateError('HTTP(S) proxy must be configured.'); + } + + return parseProxyUrl(proxy); + }; + }; + + const getHttpProxy = () => { + return proxyController.HTTP_PROXY; + }; + + const BoundHttpProxyAgent = class extends HttpProxyAgent { + constructor () { + super( + () => { + return getHttpProxy(); + }, + mustUrlUseProxy(getHttpProxy), + getUrlProxy(getHttpProxy), + http.globalAgent, + configuration.socketConnectionTimeout, + ); + } + }; + + const httpAgent = new BoundHttpProxyAgent(); + + const getHttpsProxy = () => { + return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY; + }; + + const BoundHttpsProxyAgent = class extends HttpsProxyAgent { + constructor () { + super( + () => { + return getHttpsProxy(); + }, + mustUrlUseProxy(getHttpsProxy), + getUrlProxy(getHttpsProxy), + https.globalAgent, + configuration.socketConnectionTimeout, + ); + } + }; + + const httpsAgent = new BoundHttpsProxyAgent(); + + // Overriding globalAgent was added in v11.7. + // @see https://nodejs.org/uk/blog/release/v11.7.0/ + if (semver.gte(process.version, 'v11.7.0')) { + // @see https://github.com/facebook/flow/issues/7670 + // $FlowFixMe + http.globalAgent = httpAgent; + + // $FlowFixMe + https.globalAgent = httpsAgent; + } + + // The reason this logic is used in addition to overriding http(s).globalAgent + // is because there is no guarantee that we set http(s).globalAgent variable + // before an instance of http(s).Agent has been already constructed by someone, + // e.g. Stripe SDK creates instances of http(s).Agent at the top-level. + // @see https://github.com/gajus/global-agent/pull/13 + // + // We still want to override http(s).globalAgent when possible to enable logic + // in `bindHttpMethod`. + if (semver.gte(process.version, 'v10.0.0')) { + // $FlowFixMe + http.get = bindHttpMethod(httpGet, httpAgent, configuration.forceGlobalAgent); + + // $FlowFixMe + http.request = bindHttpMethod(httpRequest, httpAgent, configuration.forceGlobalAgent); + + // $FlowFixMe + https.get = bindHttpMethod(httpsGet, httpsAgent, configuration.forceGlobalAgent); + + // $FlowFixMe + https.request = bindHttpMethod(httpsRequest, httpsAgent, configuration.forceGlobalAgent); + } else { + log.warn('attempt to initialize global-agent in unsupported Node.js version was ignored'); + } + + return proxyController; +}; diff --git a/desktop/node_modules/global-agent/src/factories/createProxyController.js b/desktop/node_modules/global-agent/src/factories/createProxyController.js new file mode 100644 index 0000000..5805ec8 --- /dev/null +++ b/desktop/node_modules/global-agent/src/factories/createProxyController.js @@ -0,0 +1,46 @@ +// @flow + +import Logger from '../Logger'; + +type ProxyControllerType = {| + HTTP_PROXY: string | null, + HTTPS_PROXY: string | null, + NO_PROXY: string | null, +|}; + +const log = Logger.child({ + namespace: 'createProxyController', +}); + +const KNOWN_PROPERTY_NAMES = [ + 'HTTP_PROXY', + 'HTTPS_PROXY', + 'NO_PROXY', +]; + +export default (): ProxyControllerType => { + // eslint-disable-next-line fp/no-proxy + return new Proxy({ + HTTP_PROXY: null, + HTTPS_PROXY: null, + NO_PROXY: null, + }, { + set: (subject, name, value) => { + if (!KNOWN_PROPERTY_NAMES.includes(name)) { + throw new Error('Cannot set an unmapped property "' + name + '".'); + } + + subject[name] = value; + + log.info({ + change: { + name, + value, + }, + newConfiguration: subject, + }, 'configuration changed'); + + return true; + }, + }); +}; diff --git a/desktop/node_modules/global-agent/src/factories/index.js b/desktop/node_modules/global-agent/src/factories/index.js new file mode 100644 index 0000000..c16eca6 --- /dev/null +++ b/desktop/node_modules/global-agent/src/factories/index.js @@ -0,0 +1,4 @@ +// @flow + +export {default as createGlobalProxyAgent} from './createGlobalProxyAgent'; +export {default as createProxyController} from './createProxyController'; diff --git a/desktop/node_modules/global-agent/src/index.js b/desktop/node_modules/global-agent/src/index.js new file mode 100644 index 0000000..14da1ba --- /dev/null +++ b/desktop/node_modules/global-agent/src/index.js @@ -0,0 +1,4 @@ +// @flow + +export {bootstrap} from './routines'; +export {createGlobalProxyAgent} from './factories'; diff --git a/desktop/node_modules/global-agent/src/routines/bootstrap.js b/desktop/node_modules/global-agent/src/routines/bootstrap.js new file mode 100644 index 0000000..038feb3 --- /dev/null +++ b/desktop/node_modules/global-agent/src/routines/bootstrap.js @@ -0,0 +1,25 @@ +// @flow + +import Logger from '../Logger'; +import { + createGlobalProxyAgent, +} from '../factories'; +import type { + ProxyAgentConfigurationInputType, +} from '../types'; + +const log = Logger.child({ + namespace: 'bootstrap', +}); + +export default (configurationInput?: ProxyAgentConfigurationInputType): boolean => { + if (global.GLOBAL_AGENT) { + log.warn('found global.GLOBAL_AGENT; second attempt to bootstrap global-agent was ignored'); + + return false; + } + + global.GLOBAL_AGENT = createGlobalProxyAgent(configurationInput); + + return true; +}; diff --git a/desktop/node_modules/global-agent/src/routines/index.js b/desktop/node_modules/global-agent/src/routines/index.js new file mode 100644 index 0000000..e47a8a0 --- /dev/null +++ b/desktop/node_modules/global-agent/src/routines/index.js @@ -0,0 +1,3 @@ +// @flow + +export {default as bootstrap} from './bootstrap'; diff --git a/desktop/node_modules/global-agent/src/types.js b/desktop/node_modules/global-agent/src/types.js new file mode 100644 index 0000000..e2f1a99 --- /dev/null +++ b/desktop/node_modules/global-agent/src/types.js @@ -0,0 +1,66 @@ +// @flow + +import { + Socket, +} from 'net'; +import { + TLSSocket, +} from 'tls'; +import { + Agent as HttpAgent, +} from 'http'; +import { + Agent as HttpsAgent, +} from 'https'; + +export type ProxyConfigurationType = {| + +authorization: string, + +hostname: string, + +port: number, +|}; + +export type TlsConfigurationType = {| + +ca?: string, + +cert?: string, + +ciphers?: string, + +clientCertEngine?: string, + +crl?: string, + +dhparam?: string, + +ecdhCurve?: string, + +honorCipherOrder?: boolean, + +key?: string, + +passphrase?: string, + +pfx?: string, + +rejectUnauthorized?: boolean, + +secureOptions?: number, + +secureProtocol?: string, + +servername?: string, + +sessionIdContext?: string, +|}; + +export type ConnectionConfigurationType = {| + +host: string, + +port: number, + +tls?: TlsConfigurationType, + +proxy: ProxyConfigurationType, +|}; + +export type ConnectionCallbackType = (error: Error | null, socket?: Socket | TLSSocket) => void; + +export type AgentType = HttpAgent | HttpsAgent; +export type IsProxyConfiguredMethodType = () => boolean; +export type MustUrlUseProxyMethodType = (url: string) => boolean; +export type GetUrlProxyMethodType = (url: string) => ProxyConfigurationType; +export type ProtocolType = 'http:' | 'https:'; + +export type ProxyAgentConfigurationInputType = {| + +environmentVariableNamespace?: string, + +forceGlobalAgent?: boolean, + +socketConnectionTimeout?: number, +|}; + +export type ProxyAgentConfigurationType = {| + +environmentVariableNamespace: string, + +forceGlobalAgent: boolean, + +socketConnectionTimeout: number, +|}; diff --git a/desktop/node_modules/global-agent/src/utilities/bindHttpMethod.js b/desktop/node_modules/global-agent/src/utilities/bindHttpMethod.js new file mode 100644 index 0000000..f8859b5 --- /dev/null +++ b/desktop/node_modules/global-agent/src/utilities/bindHttpMethod.js @@ -0,0 +1,54 @@ +// @flow + +import http from 'http'; +import https from 'https'; + +type AgentType = http.Agent | https.Agent; + +// eslint-disable-next-line flowtype/no-weak-types +export default (originalMethod: Function, agent: AgentType, forceGlobalAgent: boolean) => { + // eslint-disable-next-line unicorn/prevent-abbreviations + return (...args: *) => { + let url; + let options; + let callback; + + if (typeof args[0] === 'string' || args[0] instanceof URL) { + url = args[0]; + + if (typeof args[1] === 'function') { + options = {}; + callback = args[1]; + } else { + options = { + ...args[1], + }; + callback = args[2]; + } + } else { + options = { + ...args[0], + }; + callback = args[1]; + } + + if (forceGlobalAgent) { + options.agent = agent; + } else { + if (!options.agent) { + options.agent = agent; + } + + if (options.agent === http.globalAgent || options.agent === https.globalAgent) { + options.agent = agent; + } + } + + if (url) { + // $FlowFixMe + return originalMethod(url, options, callback); + } else { + return originalMethod(options, callback); + } + }; +}; diff --git a/desktop/node_modules/global-agent/src/utilities/index.js b/desktop/node_modules/global-agent/src/utilities/index.js new file mode 100644 index 0000000..3412387 --- /dev/null +++ b/desktop/node_modules/global-agent/src/utilities/index.js @@ -0,0 +1,5 @@ +// @flow + +export {default as bindHttpMethod} from './bindHttpMethod'; +export {default as isUrlMatchingNoProxy} from './isUrlMatchingNoProxy'; +export {default as parseProxyUrl} from './parseProxyUrl'; diff --git a/desktop/node_modules/global-agent/src/utilities/isUrlMatchingNoProxy.js b/desktop/node_modules/global-agent/src/utilities/isUrlMatchingNoProxy.js new file mode 100644 index 0000000..f2de584 --- /dev/null +++ b/desktop/node_modules/global-agent/src/utilities/isUrlMatchingNoProxy.js @@ -0,0 +1,37 @@ +// @flow + +import { + parse as parseUrl, +} from 'url'; +import matcher from 'matcher'; +import { + UnexpectedStateError, +} from '../errors'; + +export default (subjectUrl: string, noProxy: string) => { + const subjectUrlTokens = parseUrl(subjectUrl); + + const rules = noProxy.split(/[\s,]+/); + + for (const rule of rules) { + const ruleMatch = rule + .replace(/^(?<leadingDot>\.)/, '*') + .match(/^(?<hostname>.+?)(?::(?<port>\d+))?$/); + + if (!ruleMatch || !ruleMatch.groups) { + throw new UnexpectedStateError('Invalid NO_PROXY pattern.'); + } + + if (!ruleMatch.groups.hostname) { + throw new UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.'); + } + + const hostnameIsMatch = matcher.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname); + + if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) { + return true; + } + } + + return false; +}; diff --git a/desktop/node_modules/global-agent/src/utilities/parseProxyUrl.js b/desktop/node_modules/global-agent/src/utilities/parseProxyUrl.js new file mode 100644 index 0000000..e2e9a6b --- /dev/null +++ b/desktop/node_modules/global-agent/src/utilities/parseProxyUrl.js @@ -0,0 +1,36 @@ +// @flow + +import { + parse as parseUrl, +} from 'url'; +import { + UnexpectedStateError, +} from '../errors'; + +export default (url: string) => { + const urlTokens = parseUrl(url); + + if (urlTokens.query !== null) { + throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.'); + } + + if (urlTokens.hash !== null) { + throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.'); + } + + if (urlTokens.protocol !== 'http:') { + throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".'); + } + + let port = 80; + + if (urlTokens.port) { + port = Number.parseInt(urlTokens.port, 10); + } + + return { + authorization: urlTokens.auth || null, + hostname: urlTokens.hostname, + port, + }; +}; |