// @bun
import{zb as a}from"./chunk-ppkzf21q.js";import{Bb as c}from"./chunk-3wpw5xgd.js";import{Gb as E}from"./chunk-0m218zhk.js";var N=E(a(),1);import{readFileSync as p}from"fs";var i=(e)=>async()=>{e.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");let{roleArn:o,roleSessionName:r,webIdentityToken:s,providerId:n,policyArns:S,policy:d,durationSeconds:l}=e,{roleAssumerWithWebIdentity:t}=e;if(!t){let{getDefaultRoleAssumerWithWebIdentity:m}=await import("./chunk-dw62d69f.js");t=m({...e.clientConfig,credentialProviderLogger:e.logger,parentClientConfig:e.parentClientConfig},e.clientPlugins)}return t({RoleArn:o,RoleSessionName:r??`aws-sdk-js-session-${Date.now()}`,WebIdentityToken:s,ProviderId:n,PolicyArns:S,Policy:d,DurationSeconds:l})};var _="AWS_WEB_IDENTITY_TOKEN_FILE",T="AWS_ROLE_ARN",f="AWS_ROLE_SESSION_NAME",w=(e={})=>async()=>{e.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");let o=e?.webIdentityTokenFile??process.env[_],r=e?.roleArn??process.env[T],s=e?.roleSessionName??process.env[f];if(!o||!r)throw new c("Web identity configuration not specified",{logger:e.logger});let n=await i({...e,webIdentityToken:p(o,{encoding:"ascii"}),roleArn:r,roleSessionName:s})();if(o===process.env[_])N.setCredentialFeature(n,"CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN","h");return n};export{i as fromWebToken,w as fromTokenFile};
