55 * or at https://opensource.org/licenses/MIT.
66 */
77
8+ import { NodeHttpHandler , NodeHttpHandlerOptions } from '@smithy/node-http-handler' ;
9+ import { HttpProxyAgent } from 'http-proxy-agent' ;
10+ import { HttpsProxyAgent } from 'https-proxy-agent' ;
811import { Config } from '../provider' ;
912import { DEFAULT_CONFIG_S3_ACCESS_KEY_ID , DEFAUTLT_CONFIG_S3_SECRET_ACCESS_KEY } from './default' ;
1013
@@ -19,6 +22,22 @@ const CONFIG_S3_ACCESS_KEY_ID = process.env['CONFIG_S3_ACCESS_KEY_ID'];
1922const CONFIG_S3_SECRET_ACCESS_KEY = process . env [ 'CONFIG_S3_SECRET_ACCESS_KEY' ] ;
2023/** S3 unique service identifier */
2124const CONFIG_S3_SERVICE_ID = process . env [ 'CONFIG_S3_SERVICE_ID' ] ;
25+ /** HTTP Proxy URI */
26+ const CONFIG_S3_PROXY_HTTP = process . env [ 'CONFIG_S3_PROXY_HTTP' ] ;
27+ /** HTTPS Proxy URI */
28+ const CONFIG_S3_PROXY_HTTPS = process . env [ 'CONFIG_S3_PROXY_HTTPS' ] ;
29+
30+ const requestHandlerConfig : NodeHttpHandlerOptions = { } ;
31+ if ( CONFIG_S3_PROXY_HTTP ) {
32+ requestHandlerConfig . httpAgent = new HttpProxyAgent ( CONFIG_S3_PROXY_HTTP ) ;
33+ }
34+ if ( CONFIG_S3_PROXY_HTTPS ) {
35+ requestHandlerConfig . httpsAgent = new HttpsProxyAgent ( CONFIG_S3_PROXY_HTTPS ) ;
36+ }
37+ let requestHandler : NodeHttpHandler | undefined = undefined ;
38+ if ( requestHandlerConfig . httpAgent || requestHandlerConfig . httpsAgent ) {
39+ requestHandler = new NodeHttpHandler ( requestHandlerConfig ) ;
40+ }
2241
2342export const envBasedConfig : Config = {
2443 region : CONFIG_S3_REGION ,
@@ -27,5 +46,6 @@ export const envBasedConfig: Config = {
2746 secretAccessKey : CONFIG_S3_SECRET_ACCESS_KEY ?? DEFAUTLT_CONFIG_S3_SECRET_ACCESS_KEY ,
2847 } ,
2948 serviceId : CONFIG_S3_SERVICE_ID ,
49+ requestHandler,
3050} ;
3151// #endregion
0 commit comments