@@ -20,14 +20,19 @@ export class CredentialsClient {
2020 private readonly requestHandler ?: NodeHttpHandler ;
2121
2222 constructor ( props : CredentialsClientProps ) {
23- this . region = props . region ;
23+ if ( props . region !== undefined ) {
24+ this . region = props . region ;
25+ }
2426 if ( props . proxyServer ) {
2527 info ( 'Configuring proxy handler for STS client' ) ;
26- const getProxyForUrl = new ProxyResolver ( {
28+ const proxyOptions : { httpProxy : string ; httpsProxy : string ; noProxy ?: string } = {
2729 httpProxy : props . proxyServer ,
2830 httpsProxy : props . proxyServer ,
29- noProxy : props . noProxy ,
30- } ) . getProxyForUrl ;
31+ } ;
32+ if ( props . noProxy !== undefined ) {
33+ proxyOptions . noProxy = props . noProxy ;
34+ }
35+ const getProxyForUrl = new ProxyResolver ( proxyOptions ) . getProxyForUrl ;
3136 const handler = new ProxyAgent ( { getProxyForUrl } ) ;
3237 this . requestHandler = new NodeHttpHandler ( {
3338 httpsAgent : handler ,
@@ -38,11 +43,14 @@ export class CredentialsClient {
3843
3944 public get stsClient ( ) : STSClient {
4045 if ( ! this . _stsClient ) {
41- this . _stsClient = new STSClient ( {
42- region : this . region ,
43- customUserAgent : USER_AGENT ,
44- requestHandler : this . requestHandler ? this . requestHandler : undefined ,
45- } ) ;
46+ const config = { customUserAgent : USER_AGENT } as {
47+ customUserAgent : string ;
48+ region ?: string ;
49+ requestHandler ?: NodeHttpHandler ;
50+ } ;
51+ if ( this . region !== undefined ) config . region = this . region ;
52+ if ( this . requestHandler !== undefined ) config . requestHandler = this . requestHandler ;
53+ this . _stsClient = new STSClient ( config ) ;
4654 }
4755 return this . _stsClient ;
4856 }
@@ -88,9 +96,9 @@ export class CredentialsClient {
8896 }
8997
9098 private async loadCredentials ( ) {
91- const client = new STSClient ( {
92- requestHandler : this . requestHandler ? this . requestHandler : undefined ,
93- } ) ;
99+ const config = { } as { requestHandler ?: NodeHttpHandler } ;
100+ if ( this . requestHandler !== undefined ) config . requestHandler = this . requestHandler ;
101+ const client = new STSClient ( config ) ;
94102 return client . config . credentials ( ) ;
95103 }
96104}
0 commit comments