"use strict";exports.id=714,exports.ids=[714],exports.modules={19714:(e,r,t)=>{t.r(r),t.d(r,{fromProcess:()=>j});var s=t(70857),o=t(16928);const i={},n=()=>{const{HOME:e,USERPROFILE:r,HOMEPATH:t,HOMEDRIVE:n=`C:${o.sep}`}=process.env;if(e)return e;if(r)return r;if(t)return`${n}${t}`;const c=process&&process.geteuid?`${process.geteuid()}`:"DEFAULT";return i[c]||(i[c]=(0,s.homedir)()),i[c]};t(76982);var c=t(79896);const{readFile:a}=c.promises;var l,d,f,u,p,E,h,g;!function(e){e.HEADER="header",e.QUERY="query"}(l||(l={})),function(e){e.HEADER="header",e.QUERY="query"}(d||(d={})),function(e){e.HTTP="http",e.HTTPS="https"}(f||(f={})),function(e){e.MD5="md5",e.CRC32="crc32",e.CRC32C="crc32c",e.SHA1="sha1",e.SHA256="sha256"}(u||(u={})),function(e){e[e.HEADER=0]="HEADER",e[e.TRAILER=1]="TRAILER"}(p||(p={})),(g=E||(E={})).PROFILE="profile",g.SSO_SESSION="sso-session",g.SERVICES="services",function(e){e.HTTP_0_9="http/0.9",e.HTTP_1_0="http/1.0",e.TDS_8_0="tds/8.0"}(h||(h={}));const _=e=>Object.entries(e).filter((([e])=>{const r=e.indexOf(C);return-1!==r&&Object.values(E).includes(e.substring(0,r))})).reduce(((e,[r,t])=>{const s=r.indexOf(C);return e[r.substring(0,s)===E.PROFILE?r.substring(s+1):r]=t,e}),{...e.default&&{default:e.default}}),S=()=>process.env.AWS_CONFIG_FILE||(0,o.join)(n(),".aws","config"),w=()=>process.env.AWS_SHARED_CREDENTIALS_FILE||(0,o.join)(n(),".aws","credentials"),v=/^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/,O=["__proto__","profile __proto__"],y=e=>{const r={};let t,s;for(const o of e.split(/\r?\n/)){const e=o.split(/(^|\s)[;#]/)[0].trim();if("["===e[0]&&"]"===e[e.length-1]){t=void 0,s=void 0;const r=e.substring(1,e.length-1),o=v.exec(r);if(o){const[,e,,r]=o;Object.values(E).includes(e)&&(t=[e,r].join(C))}else t=r;if(O.includes(r))throw new Error(`Found invalid profile name "${r}"`)}else if(t){const i=e.indexOf("=");if(![0,-1].includes(i)){const[n,c]=[e.substring(0,i).trim(),e.substring(i+1).trim()];if(""===c)s=n;else{s&&o.trimStart()===o&&(s=void 0),r[t]=r[t]||{};const e=s?[s,n].join(C):n;r[t][e]=c}}}}return r},{readFile:P}=c.promises,R={},A=(e,r)=>(R[e]&&!r?.ignoreCache||(R[e]=P(e,"utf8")),R[e]),m=()=>({}),C=".";class b extends Error{constructor(e,r=!0){let t,s=!0;"boolean"==typeof r?(t=void 0,s=r):null!=r&&"object"==typeof r&&(t=r.logger,s=r.tryNextLink??!0),super(e),this.name="ProviderError",this.tryNextLink=s,Object.setPrototypeOf(this,b.prototype),t?.debug?.(`@smithy/property-provider ${s?"->":"(!)"} ${e}`)}static from(e,r=!0){return Object.assign(new this(e.message,r),e)}}class I extends b{constructor(e,r=!0){super(e,r),this.name="CredentialsProviderError",Object.setPrototypeOf(this,I.prototype)}}var x=t(35317),T=t(39023),F=t(82729);const j=(e={})=>async({callerClientConfig:r}={})=>{e.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");const t=await(async e=>{const r=await(async(e={})=>{const{filepath:r=w(),configFilepath:t=S()}=e,s=n();let i=r;r.startsWith("~/")&&(i=(0,o.join)(s,r.slice(2)));let c=t;t.startsWith("~/")&&(c=(0,o.join)(s,t.slice(2)));const a=await Promise.all([A(c,{ignoreCache:e.ignoreCache}).then(y).then(_).catch(m),A(i,{ignoreCache:e.ignoreCache}).then(y).catch(m)]);return{configFile:a[0],credentialsFile:a[1]}})(e);return((...e)=>{const r={};for(const t of e)for(const[e,s]of Object.entries(t))void 0!==r[e]?Object.assign(r[e],s):r[e]=s;return r})(r.configFile,r.credentialsFile)})(e);return(async(e,r,t)=>{const s=r[e];if(!r[e])throw new I(`Profile ${e} could not be found in shared credentials file.`,{logger:t});{const o=s.credential_process;if(void 0===o)throw new I(`Profile ${e} did not contain credential_process.`,{logger:t});{const s=(0,T.promisify)(x.exec);try{const{stdout:t}=await s(o);let i;try{i=JSON.parse(t.trim())}catch{throw Error(`Profile ${e} credential_process returned invalid JSON.`)}return((e,r,t)=>{if(1!==r.Version)throw Error(`Profile ${e} credential_process did not return Version 1.`);if(void 0===r.AccessKeyId||void 0===r.SecretAccessKey)throw Error(`Profile ${e} credential_process returned invalid credentials.`);if(r.Expiration){const t=new Date;if(new Date(r.Expiration)<t)throw Error(`Profile ${e} credential_process returned expired credentials.`)}let s=r.AccountId;!s&&t?.[e]?.aws_account_id&&(s=t[e].aws_account_id);const o={accessKeyId:r.AccessKeyId,secretAccessKey:r.SecretAccessKey,...r.SessionToken&&{sessionToken:r.SessionToken},...r.Expiration&&{expiration:new Date(r.Expiration)},...r.CredentialScope&&{credentialScope:r.CredentialScope},...s&&{accountId:s}};return(0,F.g)(o,"CREDENTIALS_PROCESS","w"),o})(e,i,r)}catch(e){throw new I(e.message,{logger:t})}}}})((e=>e.profile||process.env.AWS_PROFILE||"default")({profile:e.profile??r?.profile}),t,e.logger)}}};
//# sourceMappingURL=714-bundle.js.map