1+ "use strict" ;
2+ exports . id = 163 ;
3+ exports . ids = [ 163 ] ;
4+ exports . modules = {
5+
6+ /***/ 26163 :
7+ /***/ ( ( __unused_webpack_module , exports , __webpack_require__ ) => {
8+
9+
10+
11+ var sharedIniFileLoader = __webpack_require__ ( 93438 ) ;
12+ var propertyProvider = __webpack_require__ ( 1104 ) ;
13+ var client = __webpack_require__ ( 17582 ) ;
14+
15+ const resolveCredentialSource = ( credentialSource , profileName , logger ) => {
16+ const sourceProvidersMap = {
17+ EcsContainer : async ( options ) => {
18+ const { fromHttp } = await __webpack_require__ . e ( /* import() */ 795 ) . then ( __webpack_require__ . bind ( __webpack_require__ , 60795 ) ) ;
19+ const { fromContainerMetadata } = await Promise . resolve ( /* import() */ ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 40566 , 19 ) ) ;
20+ logger ?. debug ( "@aws-sdk/credential-provider-ini - credential_source is EcsContainer" ) ;
21+ return async ( ) => propertyProvider . chain ( fromHttp ( options ?? { } ) , fromContainerMetadata ( options ) ) ( ) . then ( setNamedProvider ) ;
22+ } ,
23+ Ec2InstanceMetadata : async ( options ) => {
24+ logger ?. debug ( "@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata" ) ;
25+ const { fromInstanceMetadata } = await Promise . resolve ( /* import() */ ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 40566 , 19 ) ) ;
26+ return async ( ) => fromInstanceMetadata ( options ) ( ) . then ( setNamedProvider ) ;
27+ } ,
28+ Environment : async ( options ) => {
29+ logger ?. debug ( "@aws-sdk/credential-provider-ini - credential_source is Environment" ) ;
30+ const { fromEnv } = await Promise . resolve ( /* import() */ ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 56104 , 19 ) ) ;
31+ return async ( ) => fromEnv ( options ) ( ) . then ( setNamedProvider ) ;
32+ } ,
33+ } ;
34+ if ( credentialSource in sourceProvidersMap ) {
35+ return sourceProvidersMap [ credentialSource ] ;
36+ }
37+ else {
38+ throw new propertyProvider . CredentialsProviderError ( `Unsupported credential source in profile ${ profileName } . Got ${ credentialSource } , ` +
39+ `expected EcsContainer or Ec2InstanceMetadata or Environment.` , { logger } ) ;
40+ }
41+ } ;
42+ const setNamedProvider = ( creds ) => client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_NAMED_PROVIDER" , "p" ) ;
43+
44+ const isAssumeRoleProfile = ( arg , { profile = "default" , logger } = { } ) => {
45+ return ( Boolean ( arg ) &&
46+ typeof arg === "object" &&
47+ typeof arg . role_arn === "string" &&
48+ [ "undefined" , "string" ] . indexOf ( typeof arg . role_session_name ) > - 1 &&
49+ [ "undefined" , "string" ] . indexOf ( typeof arg . external_id ) > - 1 &&
50+ [ "undefined" , "string" ] . indexOf ( typeof arg . mfa_serial ) > - 1 &&
51+ ( isAssumeRoleWithSourceProfile ( arg , { profile, logger } ) || isCredentialSourceProfile ( arg , { profile, logger } ) ) ) ;
52+ } ;
53+ const isAssumeRoleWithSourceProfile = ( arg , { profile, logger } ) => {
54+ const withSourceProfile = typeof arg . source_profile === "string" && typeof arg . credential_source === "undefined" ;
55+ if ( withSourceProfile ) {
56+ logger ?. debug ?. ( ` ${ profile } isAssumeRoleWithSourceProfile source_profile=${ arg . source_profile } ` ) ;
57+ }
58+ return withSourceProfile ;
59+ } ;
60+ const isCredentialSourceProfile = ( arg , { profile, logger } ) => {
61+ const withProviderProfile = typeof arg . credential_source === "string" && typeof arg . source_profile === "undefined" ;
62+ if ( withProviderProfile ) {
63+ logger ?. debug ?. ( ` ${ profile } isCredentialSourceProfile credential_source=${ arg . credential_source } ` ) ;
64+ }
65+ return withProviderProfile ;
66+ } ;
67+ const resolveAssumeRoleCredentials = async ( profileName , profiles , options , visitedProfiles = { } ) => {
68+ options . logger ?. debug ( "@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)" ) ;
69+ const profileData = profiles [ profileName ] ;
70+ const { source_profile, region } = profileData ;
71+ if ( ! options . roleAssumer ) {
72+ const { getDefaultRoleAssumer } = await __webpack_require__ . e ( /* import() */ 58 ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 31058 , 23 ) ) ;
73+ options . roleAssumer = getDefaultRoleAssumer ( {
74+ ...options . clientConfig ,
75+ credentialProviderLogger : options . logger ,
76+ parentClientConfig : {
77+ ...options ?. parentClientConfig ,
78+ region : region ?? options ?. parentClientConfig ?. region ,
79+ } ,
80+ } , options . clientPlugins ) ;
81+ }
82+ if ( source_profile && source_profile in visitedProfiles ) {
83+ throw new propertyProvider . CredentialsProviderError ( `Detected a cycle attempting to resolve credentials for profile` +
84+ ` ${ sharedIniFileLoader . getProfileName ( options ) } . Profiles visited: ` +
85+ Object . keys ( visitedProfiles ) . join ( ", " ) , { logger : options . logger } ) ;
86+ }
87+ options . logger ?. debug ( `@aws-sdk/credential-provider-ini - finding credential resolver using ${ source_profile ? `source_profile=[${ source_profile } ]` : `profile=[${ profileName } ]` } ` ) ;
88+ const sourceCredsProvider = source_profile
89+ ? resolveProfileData ( source_profile , profiles , options , {
90+ ...visitedProfiles ,
91+ [ source_profile ] : true ,
92+ } , isCredentialSourceWithoutRoleArn ( profiles [ source_profile ] ?? { } ) )
93+ : ( await resolveCredentialSource ( profileData . credential_source , profileName , options . logger ) ( options ) ) ( ) ;
94+ if ( isCredentialSourceWithoutRoleArn ( profileData ) ) {
95+ return sourceCredsProvider . then ( ( creds ) => client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_SOURCE_PROFILE" , "o" ) ) ;
96+ }
97+ else {
98+ const params = {
99+ RoleArn : profileData . role_arn ,
100+ RoleSessionName : profileData . role_session_name || `aws-sdk-js-${ Date . now ( ) } ` ,
101+ ExternalId : profileData . external_id ,
102+ DurationSeconds : parseInt ( profileData . duration_seconds || "3600" , 10 ) ,
103+ } ;
104+ const { mfa_serial } = profileData ;
105+ if ( mfa_serial ) {
106+ if ( ! options . mfaCodeProvider ) {
107+ throw new propertyProvider . CredentialsProviderError ( `Profile ${ profileName } requires multi-factor authentication, but no MFA code callback was provided.` , { logger : options . logger , tryNextLink : false } ) ;
108+ }
109+ params . SerialNumber = mfa_serial ;
110+ params . TokenCode = await options . mfaCodeProvider ( mfa_serial ) ;
111+ }
112+ const sourceCreds = await sourceCredsProvider ;
113+ return options . roleAssumer ( sourceCreds , params ) . then ( ( creds ) => client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_SOURCE_PROFILE" , "o" ) ) ;
114+ }
115+ } ;
116+ const isCredentialSourceWithoutRoleArn = ( section ) => {
117+ return ! section . role_arn && ! ! section . credential_source ;
118+ } ;
119+
120+ const isProcessProfile = ( arg ) => Boolean ( arg ) && typeof arg === "object" && typeof arg . credential_process === "string" ;
121+ const resolveProcessCredentials = async ( options , profile ) => __webpack_require__ . e ( /* import() */ 630 ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 15630 , 19 ) ) . then ( ( { fromProcess } ) => fromProcess ( {
122+ ...options ,
123+ profile,
124+ } ) ( ) . then ( ( creds ) => client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_PROCESS" , "v" ) ) ) ;
125+
126+ const resolveSsoCredentials = async ( profile , profileData , options = { } ) => {
127+ const { fromSSO } = await __webpack_require__ . e ( /* import() */ 212 ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 8212 , 19 ) ) ;
128+ return fromSSO ( {
129+ profile,
130+ logger : options . logger ,
131+ parentClientConfig : options . parentClientConfig ,
132+ clientConfig : options . clientConfig ,
133+ } ) ( ) . then ( ( creds ) => {
134+ if ( profileData . sso_session ) {
135+ return client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_SSO" , "r" ) ;
136+ }
137+ else {
138+ return client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_SSO_LEGACY" , "t" ) ;
139+ }
140+ } ) ;
141+ } ;
142+ const isSsoProfile = ( arg ) => arg &&
143+ ( typeof arg . sso_start_url === "string" ||
144+ typeof arg . sso_account_id === "string" ||
145+ typeof arg . sso_session === "string" ||
146+ typeof arg . sso_region === "string" ||
147+ typeof arg . sso_role_name === "string" ) ;
148+
149+ const isStaticCredsProfile = ( arg ) => Boolean ( arg ) &&
150+ typeof arg === "object" &&
151+ typeof arg . aws_access_key_id === "string" &&
152+ typeof arg . aws_secret_access_key === "string" &&
153+ [ "undefined" , "string" ] . indexOf ( typeof arg . aws_session_token ) > - 1 &&
154+ [ "undefined" , "string" ] . indexOf ( typeof arg . aws_account_id ) > - 1 ;
155+ const resolveStaticCredentials = async ( profile , options ) => {
156+ options ?. logger ?. debug ( "@aws-sdk/credential-provider-ini - resolveStaticCredentials" ) ;
157+ const credentials = {
158+ accessKeyId : profile . aws_access_key_id ,
159+ secretAccessKey : profile . aws_secret_access_key ,
160+ sessionToken : profile . aws_session_token ,
161+ ...( profile . aws_credential_scope && { credentialScope : profile . aws_credential_scope } ) ,
162+ ...( profile . aws_account_id && { accountId : profile . aws_account_id } ) ,
163+ } ;
164+ return client . setCredentialFeature ( credentials , "CREDENTIALS_PROFILE" , "n" ) ;
165+ } ;
166+
167+ const isWebIdentityProfile = ( arg ) => Boolean ( arg ) &&
168+ typeof arg === "object" &&
169+ typeof arg . web_identity_token_file === "string" &&
170+ typeof arg . role_arn === "string" &&
171+ [ "undefined" , "string" ] . indexOf ( typeof arg . role_session_name ) > - 1 ;
172+ const resolveWebIdentityCredentials = async ( profile , options ) => Promise . all ( /* import() */ [ __webpack_require__ . e ( 58 ) , __webpack_require__ . e ( 654 ) ] ) . then ( __webpack_require__ . t . bind ( __webpack_require__ , 47654 , 23 ) ) . then ( ( { fromTokenFile } ) => fromTokenFile ( {
173+ webIdentityTokenFile : profile . web_identity_token_file ,
174+ roleArn : profile . role_arn ,
175+ roleSessionName : profile . role_session_name ,
176+ roleAssumerWithWebIdentity : options . roleAssumerWithWebIdentity ,
177+ logger : options . logger ,
178+ parentClientConfig : options . parentClientConfig ,
179+ } ) ( ) . then ( ( creds ) => client . setCredentialFeature ( creds , "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN" , "q" ) ) ) ;
180+
181+ const resolveProfileData = async ( profileName , profiles , options , visitedProfiles = { } , isAssumeRoleRecursiveCall = false ) => {
182+ const data = profiles [ profileName ] ;
183+ if ( Object . keys ( visitedProfiles ) . length > 0 && isStaticCredsProfile ( data ) ) {
184+ return resolveStaticCredentials ( data , options ) ;
185+ }
186+ if ( isAssumeRoleRecursiveCall || isAssumeRoleProfile ( data , { profile : profileName , logger : options . logger } ) ) {
187+ return resolveAssumeRoleCredentials ( profileName , profiles , options , visitedProfiles ) ;
188+ }
189+ if ( isStaticCredsProfile ( data ) ) {
190+ return resolveStaticCredentials ( data , options ) ;
191+ }
192+ if ( isWebIdentityProfile ( data ) ) {
193+ return resolveWebIdentityCredentials ( data , options ) ;
194+ }
195+ if ( isProcessProfile ( data ) ) {
196+ return resolveProcessCredentials ( options , profileName ) ;
197+ }
198+ if ( isSsoProfile ( data ) ) {
199+ return await resolveSsoCredentials ( profileName , data , options ) ;
200+ }
201+ throw new propertyProvider . CredentialsProviderError ( `Could not resolve credentials using profile: [${ profileName } ] in configuration/credentials file(s).` , { logger : options . logger } ) ;
202+ } ;
203+
204+ const fromIni = ( _init = { } ) => async ( { callerClientConfig } = { } ) => {
205+ const init = {
206+ ..._init ,
207+ parentClientConfig : {
208+ ...callerClientConfig ,
209+ ..._init . parentClientConfig ,
210+ } ,
211+ } ;
212+ init . logger ?. debug ( "@aws-sdk/credential-provider-ini - fromIni" ) ;
213+ const profiles = await sharedIniFileLoader . parseKnownFiles ( init ) ;
214+ return resolveProfileData ( sharedIniFileLoader . getProfileName ( {
215+ profile : _init . profile ?? callerClientConfig ?. profile ,
216+ } ) , profiles , init ) ;
217+ } ;
218+
219+ exports . fromIni = fromIni ;
220+
221+
222+ /***/ } )
223+
224+ } ;
225+ ;
0 commit comments