Skip to content

Commit 8bdf6f3

Browse files
authored
Feat: adds proxy agent for NVDA installation request (#32)
* feat: adds http and https proxy support for download nvda request * docs: adds instructions for proxy usage
1 parent 899e118 commit 8bdf6f3

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ If you want to specify the directory that NVDA is installed to you can pass a `-
8181
npx @guidepup/setup --nvda-install-dir <NVDA_INSTALLATION_DIRECTORY>
8282
```
8383

84+
##### Using HTTP / HTTPS Proxy for Installation
85+
86+
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:
87+
88+
- `HTTPS_PROXY`
89+
- `https_proxy`
90+
- `HTTP_PROXY`
91+
- `http_proxy`
92+
8493
#### Foreground Timeout Lock
8594

8695
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.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"@guidepup/guidepup": "^0.22.0",
5353
"chalk": "^4.0.0",
5454
"decompress": "^4.2.1",
55+
"https-proxy-agent": "^7.0.5",
5556
"regedit": "5.0.1",
5657
"semver": "^7.5.4"
5758
},

src/windows/installNvda.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { join } from "path";
55
import { tmpdir } from "os";
66
import { ERR_WINDOWS_FAILED_TO_INSTALL_NVDA } from "../errors";
77
import { GUIDEPUP_NVDA_VERSION } from "./constants";
8+
import { HttpsProxyAgent } from 'https-proxy-agent';
89

910
const appName = "guidepup_nvda";
1011
const sourceUrl = `https://codeload.github.com/guidepup/nvda/zip/refs/tags/${GUIDEPUP_NVDA_VERSION}`;
@@ -39,6 +40,19 @@ export async function installNvda({
3940
}
4041
}
4142

43+
let agent: HttpsProxyAgent<string> | undefined
44+
45+
const proxyUrl = (
46+
process.env.HTTPS_PROXY ||
47+
process.env.https_proxy ||
48+
process.env.HTTP_PROXY ||
49+
process.env.http_proxy
50+
)
51+
52+
if (proxyUrl) {
53+
agent = new HttpsProxyAgent(proxyUrl)
54+
}
55+
4256
try {
4357
await new Promise<void>((resolve, reject) => {
4458
function onSuccess() {
@@ -51,7 +65,7 @@ export async function installNvda({
5165
});
5266
}
5367

54-
const request = get(sourceUrl, (response) => response.pipe(fileZip));
68+
const request = get(sourceUrl, { agent }, (response) => response.pipe(fileZip));
5569
request.on("error", reject);
5670
fileZip.on("finish", onSuccess);
5771
fileZip.on("error", reject);

yarn.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ agent-base@6:
296296
dependencies:
297297
debug "4"
298298

299+
agent-base@^7.0.2:
300+
version "7.1.1"
301+
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317"
302+
integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==
303+
dependencies:
304+
debug "^4.3.4"
305+
299306
ajv@^6.12.4:
300307
version "6.12.6"
301308
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
@@ -925,6 +932,14 @@ https-proxy-agent@^5.0.0:
925932
agent-base "6"
926933
debug "4"
927934

935+
https-proxy-agent@^7.0.5:
936+
version "7.0.5"
937+
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz#9e8b5013873299e11fab6fd548405da2d6c602b2"
938+
integrity sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==
939+
dependencies:
940+
agent-base "^7.0.2"
941+
debug "4"
942+
928943
ieee754@^1.1.13:
929944
version "1.2.1"
930945
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"

0 commit comments

Comments
 (0)