diff --git a/README.md b/README.md index a98d8e8..fc1d8ad 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,15 @@ If you want to specify the directory that NVDA is installed to you can pass a `- npx @guidepup/setup --nvda-install-dir ``` +##### Using HTTP / HTTPS Proxy for Installation + +If you are using a proxy connection, you must define the proxy URL in an env variable. You can use any of the following variables: + +- `HTTPS_PROXY` +- `https_proxy` +- `HTTP_PROXY` +- `http_proxy` + #### Foreground Timeout Lock Modern versions of Windows have a setting which prevents new application instances launching in front of other applications in quick succession, requiring over 3 minutes between activations before it will actually show the window - in the interim it launches the window minimized. diff --git a/package.json b/package.json index 1d566f5..4c32021 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "@guidepup/guidepup": "^0.22.0", "chalk": "^4.0.0", "decompress": "^4.2.1", + "https-proxy-agent": "^7.0.5", "regedit": "5.0.1", "semver": "^7.5.4" }, diff --git a/src/windows/installNvda.ts b/src/windows/installNvda.ts index e46e751..1407aa3 100644 --- a/src/windows/installNvda.ts +++ b/src/windows/installNvda.ts @@ -5,6 +5,7 @@ import { join } from "path"; import { tmpdir } from "os"; import { ERR_WINDOWS_FAILED_TO_INSTALL_NVDA } from "../errors"; import { GUIDEPUP_NVDA_VERSION } from "./constants"; +import { HttpsProxyAgent } from 'https-proxy-agent'; const appName = "guidepup_nvda"; const sourceUrl = `https://codeload.github.com/guidepup/nvda/zip/refs/tags/${GUIDEPUP_NVDA_VERSION}`; @@ -39,6 +40,19 @@ export async function installNvda({ } } + let agent: HttpsProxyAgent | undefined + + const proxyUrl = ( + process.env.HTTPS_PROXY || + process.env.https_proxy || + process.env.HTTP_PROXY || + process.env.http_proxy + ) + + if (proxyUrl) { + agent = new HttpsProxyAgent(proxyUrl) + } + try { await new Promise((resolve, reject) => { function onSuccess() { @@ -51,7 +65,7 @@ export async function installNvda({ }); } - const request = get(sourceUrl, (response) => response.pipe(fileZip)); + const request = get(sourceUrl, { agent }, (response) => response.pipe(fileZip)); request.on("error", reject); fileZip.on("finish", onSuccess); fileZip.on("error", reject); diff --git a/yarn.lock b/yarn.lock index c9fef0d..b4b36de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -296,6 +296,13 @@ agent-base@6: dependencies: debug "4" +agent-base@^7.0.2: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -925,6 +932,14 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" +https-proxy-agent@^7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz#9e8b5013873299e11fab6fd548405da2d6c602b2" + integrity sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw== + dependencies: + agent-base "^7.0.2" + debug "4" + ieee754@^1.1.13: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"