Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upgrade proxy-agent to ^6.3.0 to remove vm2 deps #13012

Merged
merged 4 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/amplify-category-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"lodash": "^4.17.21",
"ora": "^4.0.3",
"promise-sequential": "^1.1.1",
"proxy-agent": "^5.0.0"
"proxy-agent": "^6.3.0"
},
"jest": {
"testEnvironmentOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
resolveRegion,
loadConfigurationForEnv,
} from '@aws-amplify/amplify-provider-awscloudformation';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
const spinner = ora('');
const defaultPinpointRegion = 'us-east-1';

Expand Down Expand Up @@ -544,10 +544,11 @@ export const getPinpointClient = async (
customUserAgent: formUserAgentParam(context, userAgentAction),
};

// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
if (httpProxy) {
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy),
agent: new ProxyAgent(),
awsluja marked this conversation as resolved.
Show resolved Hide resolved
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"node-fetch": "^2.6.7",
"open": "^8.4.0",
"ora": "^4.0.3",
"proxy-agent": "^5.0.0",
"proxy-agent": "^6.3.0",
"semver": "^7.5.4",
"typescript-json-schema": "~0.52.0",
"which": "^2.0.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/amplify-cli-core/src/banner-message/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from 'node-fetch';
import semver from 'semver';
import ProxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import { getLogger } from '../logger';

export type Message = {
Expand Down Expand Up @@ -43,7 +43,8 @@ export class BannerMessage {
try {
logger.info(`fetch banner messages from ${url}`);
const proxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const fetchOptions = proxy ? { agent: new ProxyAgent(proxy) } : {};
// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
const fetchOptions = proxy ? { agent: new ProxyAgent() } : {};
const result = await fetch(url, fetchOptions);
const body = await result.json();
if (!semver.satisfies(body.version, MAX_SUPPORTED_MESSAGE_CONFIG_VERSION)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-provider-awscloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"node-fetch": "^2.6.7",
"ora": "^4.0.3",
"promise-sequential": "^1.1.1",
"proxy-agent": "^5.0.0",
"proxy-agent": "^6.3.0",
"rimraf": "^3.0.0",
"xstate": "^4.14.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const aws = require('aws-sdk');
const proxyAgent = require('proxy-agent');
const { ProxyAgent } = require('proxy-agent');
const configurationManager = require('../configuration-manager');
const { regions: amplifyServiceRegions } = require('../aws-regions');

Expand All @@ -24,7 +24,7 @@ async function getConfiguredAmplifyClient(context, options = {}) {
if (httpProxy) {
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy),
agent: new ProxyAgent(),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ try {
aws = require('aws-sdk');
}

const proxyAgent = require('proxy-agent');
const { ProxyAgent } = require('proxy-agent');
const configurationManager = require('../configuration-manager');

aws.configureWithCreds = async (context) => {
Expand All @@ -35,7 +35,7 @@ aws.configureWithCreds = async (context) => {
if (httpProxy) {
aws.config.update({
httpOptions: {
agent: proxyAgent(httpProxy),
agent: new ProxyAgent(httpProxy),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import chalk from 'chalk';
import { prompt } from 'inquirer';
import _ from 'lodash';
import path from 'path';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import { STS } from 'aws-sdk';
import awsRegions from './aws-regions';
import constants from './constants';
Expand Down Expand Up @@ -838,10 +838,11 @@ export async function getAwsConfig(context: $TSContext): Promise<AwsSdkConfig> {
}
}

// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
if (httpProxy) {
resultAWSConfigInfo = {
...resultAWSConfigInfo,
httpOptions: { agent: proxyAgent(httpProxy) },
httpOptions: { agent: new ProxyAgent() },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fs from 'fs-extra';
import * as path from 'path';
import * as ini from 'ini';
import * as inquirer from 'inquirer';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import * as constants from './constants';
import { fileLogger } from './utils/aws-logger';
import { AwsSdkConfig } from './utils/auth-types';
Expand Down Expand Up @@ -123,10 +123,11 @@ export const getProfiledAwsConfig = async (
});
}

// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
if (httpProxy) {
awsConfigInfo = {
...awsConfigInfo,
httpOptions: { agent: proxyAgent(httpProxy) },
httpOptions: { agent: new ProxyAgent() },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stateManager, $TSContext, AmplifyError, AmplifyFault } from '@aws-ampli
import aws from 'aws-sdk';
import _ from 'lodash';
import fetch from 'node-fetch';
import proxyAgent from 'proxy-agent';
import { ProxyAgent } from 'proxy-agent';
import { adminLoginFlow } from '../admin-login';
import { AdminAuthConfig, AwsSdkConfig, CognitoAccessToken, CognitoIdToken } from './auth-types';
import { printer, prompter } from '@aws-amplify/amplify-prompts';
Expand Down Expand Up @@ -89,8 +89,9 @@ type AppStateResponse = {
async function getAdminAppState(appId: string, region: string): Promise<AppStateResponse> {
// environment variable AMPLIFY_CLI_APPSTATE_BASE_URL useful for development against beta/gamma appstate endpoints
const appStateBaseUrl = process.env.AMPLIFY_CLI_APPSTATE_BASE_URL ?? adminBackendMap[region].appStateUrl;
// HTTP_PROXY & HTTPS_PROXY env vars are read automatically by ProxyAgent, but we check to see if they are set before using the proxy
const httpProxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const fetchOptions = httpProxy ? { agent: proxyAgent(httpProxy) } : {};
const fetchOptions = httpProxy ? { agent: new ProxyAgent() } : {};
const res = await fetch(`${appStateBaseUrl}/AppState/?appId=${appId}`, fetchOptions);
if (res.status >= 500) {
throw new AmplifyFault('ServiceCallFault', {
Expand Down
1 change: 1 addition & 0 deletions shared-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function _verifyAPIExtract {
# download [repo, .cache from s3]
loadCache repo $CODEBUILD_SRC_DIR
loadCache .cache $HOME/.cache
unset IS_AMPLIFY_CI
jhockett marked this conversation as resolved.
Show resolved Hide resolved
yarn verify-api-extract
}
function _verifyYarnLock {
Expand Down
Loading