"use strict";exports.id=56,exports.ids=[56],exports.modules={26056:(e,t,r)=>{r.d(t,{fromHttp:()=>d});var o=r(44616),n=r(18112),s=r(91943),a=r.n(s),i=r(77425),c=r(37628),l=r(18669);const d=(e={})=>{let t;e.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");const r=e.awsContainerCredentialsRelativeUri??process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,s=e.awsContainerCredentialsFullUri??process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI,d=e.awsContainerAuthorizationToken??process.env.AWS_CONTAINER_AUTHORIZATION_TOKEN,h=e.awsContainerAuthorizationTokenFile??process.env.AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE,p="NoOpLogger"!==e.logger?.constructor?.name&&e.logger?e.logger.warn:console.warn;if(r&&s&&(p("@aws-sdk/credential-provider-http: you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri."),p("awsContainerCredentialsFullUri will take precedence.")),d&&h&&(p("@aws-sdk/credential-provider-http: you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile."),p("awsContainerAuthorizationToken will take precedence.")),s)t=s;else{if(!r)throw new n.C1("No HTTP credential provider host provided.\nSet AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.",{logger:e.logger});t=`http://169.254.170.2${r}`}const u=new URL(t);((e,t)=>{if("https:"!==e.protocol&&"169.254.170.2"!==e.hostname&&"169.254.170.23"!==e.hostname&&"[fd00:ec2::23]"!==e.hostname){if(e.hostname.includes("[")){if("[::1]"===e.hostname||"[0000:0000:0000:0000:0000:0000:0000:0001]"===e.hostname)return}else{if("localhost"===e.hostname)return;const t=e.hostname.split("."),r=e=>{const t=parseInt(e,10);return 0<=t&&t<=255};if("127"===t[0]&&r(t[1])&&r(t[2])&&r(t[3])&&4===t.length)return}throw new n.C1("URL not accepted. It must either be HTTPS or match one of the following:\n  - loopback CIDR 127.0.0.0/8 or [::1/128]\n  - ECS container host 169.254.170.2\n  - EKS container host 169.254.170.23 or [fd00:ec2::23]",{logger:t})}})(u,e.logger);const g=new o.$c({requestTimeout:e.timeout??1e3,connectionTimeout:e.timeout??1e3});return w=async()=>{const t=function(e){return new i.Kd({protocol:e.protocol,hostname:e.hostname,port:Number(e.port),path:e.pathname,query:Array.from(e.searchParams.entries()).reduce(((e,[t,r])=>(e[t]=r,e)),{}),fragment:e.hash})}(u);d?t.headers.Authorization=d:h&&(t.headers.Authorization=(await a().readFile(h)).toString());try{return async function(e,t){const r=(0,l.c9)(e.body),o=await r.transformToString();if(200===e.statusCode){const e=JSON.parse(o);if("string"!=typeof e.AccessKeyId||"string"!=typeof e.SecretAccessKey||"string"!=typeof e.Token||"string"!=typeof e.Expiration)throw new n.C1("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }",{logger:t});return{accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:(0,c.EI)(e.Expiration)}}if(e.statusCode>=400&&e.statusCode<500){let r={};try{r=JSON.parse(o)}catch(e){}throw Object.assign(new n.C1(`Server responded with status: ${e.statusCode}`,{logger:t}),{Code:r.Code,Message:r.Message})}throw new n.C1(`Server responded with status: ${e.statusCode}`,{logger:t})}((await g.handle(t)).response)}catch(t){throw new n.C1(String(t),{logger:e.logger})}},C=e.maxRetries??3,A=e.timeout??1e3,async()=>{for(let e=0;e<C;++e)try{return await w()}catch(e){await new Promise((e=>setTimeout(e,A)))}return await w()};var w,C,A}}};
//# sourceMappingURL=56-bundle.js.map