'use strict';

var VVTDADG7_cjs = require('./VVTDADG7.cjs');
var BXO3RC75_cjs = require('./BXO3RC75.cjs');
var VO65XOWD_cjs = require('./VO65XOWD.cjs');
var fs = require('fs');

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.879.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/index.js
VO65XOWD_cjs.init_cjs_shims();

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.879.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
VO65XOWD_cjs.init_cjs_shims();

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.879.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromWebToken.js
VO65XOWD_cjs.init_cjs_shims();
var fromWebToken = /* @__PURE__ */ VO65XOWD_cjs.__name((init) => async (awsIdentityProperties) => {
  init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");
  const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;
  let { roleAssumerWithWebIdentity } = init;
  if (!roleAssumerWithWebIdentity) {
    const { getDefaultRoleAssumerWithWebIdentity } = await import('./Q4F544X2.cjs');
    roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({
      ...init.clientConfig,
      credentialProviderLogger: init.logger,
      parentClientConfig: {
        ...awsIdentityProperties?.callerClientConfig,
        ...init.parentClientConfig
      }
    }, init.clientPlugins);
  }
  return roleAssumerWithWebIdentity({
    RoleArn: roleArn,
    RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,
    WebIdentityToken: webIdentityToken,
    ProviderId: providerId,
    PolicyArns: policyArns,
    Policy: policy,
    DurationSeconds: durationSeconds
  });
}, "fromWebToken");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.879.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
var ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE";
var ENV_ROLE_ARN = "AWS_ROLE_ARN";
var ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME";
var fromTokenFile = /* @__PURE__ */ VO65XOWD_cjs.__name((init = {}) => async () => {
  init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
  const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
  const roleArn = init?.roleArn ?? process.env[ENV_ROLE_ARN];
  const roleSessionName = init?.roleSessionName ?? process.env[ENV_ROLE_SESSION_NAME];
  if (!webIdentityTokenFile || !roleArn) {
    throw new BXO3RC75_cjs.CredentialsProviderError("Web identity configuration not specified", {
      logger: init.logger
    });
  }
  const credentials = await fromWebToken({
    ...init,
    webIdentityToken: fs.readFileSync(webIdentityTokenFile, {
      encoding: "ascii"
    }),
    roleArn,
    roleSessionName
  })();
  if (webIdentityTokenFile === process.env[ENV_TOKEN_FILE]) {
    VVTDADG7_cjs.setCredentialFeature(credentials, "CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN", "h");
  }
  return credentials;
}, "fromTokenFile");

exports.fromTokenFile = fromTokenFile;
exports.fromWebToken = fromWebToken;
//# sourceMappingURL=RRJYWXRS.cjs.map
//# sourceMappingURL=RRJYWXRS.cjs.map