Skip to content

Commit

Permalink
Feat: adds proxy agent for NVDA installation request (#32)
Browse files Browse the repository at this point in the history
* feat: adds http and https proxy support for download nvda request

* docs: adds instructions for proxy usage
  • Loading branch information
bruno-sch authored Sep 4, 2024
1 parent 899e118 commit 8bdf6f3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NVDA_INSTALLATION_DIRECTORY>
```

##### 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.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
16 changes: 15 additions & 1 deletion src/windows/installNvda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -39,6 +40,19 @@ export async function installNvda({
}
}

let agent: HttpsProxyAgent<string> | 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<void>((resolve, reject) => {
function onSuccess() {
Expand All @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8bdf6f3

Please sign in to comment.