From 3a17d2ab098daa084559a4caf8ab4dd6755a7ee4 Mon Sep 17 00:00:00 2001 From: Peter Szabo Date: Sun, 1 Oct 2023 13:22:25 +0700 Subject: [PATCH] Use proxy-agent instead of superagent-proxy --- packages/@ionic/cli/package.json | 3 +-- packages/@ionic/cli/src/lib/utils/http.ts | 13 ++----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/@ionic/cli/package.json b/packages/@ionic/cli/package.json index 381d7d630b..63c223d22e 100644 --- a/packages/@ionic/cli/package.json +++ b/packages/@ionic/cli/package.json @@ -58,12 +58,12 @@ "lodash": "^4.17.5", "open": "^7.0.4", "os-name": "^4.0.0", + "proxy-agent": "^6.3.0", "semver": "^7.1.1", "split2": "^3.0.0", "ssh-config": "^1.1.1", "stream-combiner2": "^1.1.1", "superagent": "^8.0.9", - "superagent-proxy": "^3.0.0", "tar": "^6.0.1", "tslib": "^2.0.1" }, @@ -77,7 +77,6 @@ "@types/semver": "^7.1.0", "@types/split2": "^2.1.6", "@types/superagent": "4.1.3", - "@types/superagent-proxy": "^3.0.0", "@types/tar": "^6.1.2", "jest": "^26.4.2", "jest-cli": "^26.0.1", diff --git a/packages/@ionic/cli/src/lib/utils/http.ts b/packages/@ionic/cli/src/lib/utils/http.ts index 74ca72ed3c..145708b7d1 100644 --- a/packages/@ionic/cli/src/lib/utils/http.ts +++ b/packages/@ionic/cli/src/lib/utils/http.ts @@ -1,13 +1,11 @@ import { conform } from '@ionic/utils-array'; import { readFile } from '@ionic/utils-fs'; -import * as Debug from 'debug'; +import { ProxyAgent } from 'proxy-agent'; import { CreateRequestOptions, HttpMethod } from '../../definitions'; export type SuperAgentRequest = import('superagent').SuperAgentRequest; -const debug = Debug('ionic:lib:utils:http'); - export const PROXY_ENVIRONMENT_VARIABLES: readonly string[] = ['IONIC_HTTP_PROXY', 'HTTPS_PROXY', 'HTTP_PROXY', 'PROXY', 'https_proxy', 'http_proxy', 'proxy']; function getGlobalProxy(): { envvar: string; envval: string; } | undefined { @@ -38,14 +36,7 @@ export async function createRequest(method: HttpMethod, url: string, { userAgent .redirects(25); if (proxy) { - const superagentProxy = await import('superagent-proxy'); - superagentProxy(superagent); - - if (req.proxy) { - req.proxy(proxy); - } else { - debug(`Cannot install proxy--req.proxy not defined`); - } + req.agent(new ProxyAgent({ getProxyForUrl: () => proxy as string })) } if (ssl) {