import{u5 as P}from"./cli-0.5.4-hwjx0gja.mjs";import{Lma as p,Mma as w}from"./cli-0.5.4-f2v2k9ae.mjs";import"./cli-0.5.4-jpahwy23.mjs";import{Zma as u,_ma as a}from"./cli-0.5.4-aacw1src.mjs";var d,t,f,E,_,v=(r,e,s)=>{if(e.Version!==1)throw Error(`Profile ${r} credential_process did not return Version 1.`);if(e.AccessKeyId===void 0||e.SecretAccessKey===void 0)throw Error(`Profile ${r} credential_process returned invalid credentials.`);if(e.Expiration){let i=new Date;if(new Date(e.Expiration)<i)throw Error(`Profile ${r} credential_process returned expired credentials.`)}let o=e.AccountId;if(!o&&s?.[r]?.aws_account_id)o=s[r].aws_account_id;let n={accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,...e.SessionToken&&{sessionToken:e.SessionToken},...e.Expiration&&{expiration:new Date(e.Expiration)},...e.CredentialScope&&{credentialScope:e.CredentialScope},...o&&{accountId:o}};return _.setCredentialFeature(n,"CREDENTIALS_PROCESS","w"),n},x=async(r,e,s)=>{let o=e[r];if(e[r]){let n=o.credential_process;if(n!==void 0){let i=E.promisify(d.externalDataInterceptor?.getTokenRecord?.().exec??f.exec);try{let{stdout:c}=await i(n),l;try{l=JSON.parse(c.trim())}catch{throw Error(`Profile ${r} credential_process returned invalid JSON.`)}return v(r,l,e)}catch(c){throw new t.CredentialsProviderError(c.message,{logger:s})}}else throw new t.CredentialsProviderError(`Profile ${r} did not contain credential_process.`,{logger:s})}else throw new t.CredentialsProviderError(`Profile ${r} could not be found in shared credentials file.`,{logger:s})},h=(r={})=>async({callerClientConfig:e}={})=>{r.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let s=await d.parseKnownFiles(r);return x(d.getProfileName({profile:r.profile??e?.profile}),s,r.logger)},y;var S=u(()=>{d=P(),t=w(),f=a("node:child_process"),E=a("node:util"),_=p();y=h});S();export{y as fromProcess};export default {get fromProcess(){return y}};
