@@ -20,14 +20,19 @@ export class CredentialsClient {
20
20
private readonly requestHandler ?: NodeHttpHandler ;
21
21
22
22
constructor ( props : CredentialsClientProps ) {
23
- this . region = props . region ;
23
+ if ( props . region !== undefined ) {
24
+ this . region = props . region ;
25
+ }
24
26
if ( props . proxyServer ) {
25
27
info ( 'Configuring proxy handler for STS client' ) ;
26
- const getProxyForUrl = new ProxyResolver ( {
28
+ const proxyOptions : { httpProxy : string ; httpsProxy : string ; noProxy ?: string } = {
27
29
httpProxy : props . proxyServer ,
28
30
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 ;
31
36
const handler = new ProxyAgent ( { getProxyForUrl } ) ;
32
37
this . requestHandler = new NodeHttpHandler ( {
33
38
httpsAgent : handler ,
@@ -38,11 +43,14 @@ export class CredentialsClient {
38
43
39
44
public get stsClient ( ) : STSClient {
40
45
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 ) ;
46
54
}
47
55
return this . _stsClient ;
48
56
}
@@ -88,9 +96,9 @@ export class CredentialsClient {
88
96
}
89
97
90
98
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 ) ;
94
102
return client . config . credentials ( ) ;
95
103
}
96
104
}
0 commit comments