1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.initializeProxy = void 0;
|
4 | const debug = require("debug");
|
5 | const utils_1 = require("./utils");
|
6 | const d = debug('@electron/get:proxy');
|
7 | /**
|
8 | * Initializes a third-party proxy module for HTTP(S) requests. Call this function before
|
9 | * using the {@link download} and {@link downloadArtifact} APIs if you need proxy support.
|
10 | *
|
11 | * If the `ELECTRON_GET_USE_PROXY` environment variable is set to `true`, this function will be
|
12 | * called automatically for `@electron/get` requests.
|
13 | *
|
14 | * @category Utility
|
15 | * @see {@link https://github.com/gajus/global-agent?tab=readme-ov-file#environment-variables | `global-agent`}
|
16 | * documentation for available environment variables.
|
17 | *
|
18 | * @example
|
19 | * ```sh
|
20 | * export GLOBAL_AGENT_HTTPS_PROXY="$HTTPS_PROXY"
|
21 | * ```
|
22 | */
|
23 | function initializeProxy() {
|
24 | try {
|
25 | // See: https://github.com/electron/get/pull/214#discussion_r798845713
|
26 | const env = (0, utils_1.getEnv)('GLOBAL_AGENT_');
|
27 | (0, utils_1.setEnv)('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
|
28 | (0, utils_1.setEnv)('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
|
29 | (0, utils_1.setEnv)('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));
|
30 | /**
|
31 | * TODO: replace global-agent with a hpagent. @BlackHole1
|
32 | * https://github.com/sindresorhus/got/blob/HEAD/documentation/tips.md#proxying
|
33 | */
|
34 | require('global-agent').bootstrap();
|
35 | }
|
36 | catch (e) {
|
37 | d('Could not load either proxy modules, built-in proxy support not available:', e);
|
38 | }
|
39 | }
|
40 | exports.initializeProxy = initializeProxy;
|
41 | //# sourceMappingURL=proxy.js.map |
\ | No newline at end of file |