// @bun
import{vb as a}from"./chunk-y1tre8v8.js";import{xb as c}from"./chunk-v7zy7xda.js";import{Cb as E}from"./chunk-p9z7f8c8.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-d9q17hb8.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};
