#!/usr/bin/env node
"use strict";var d=Object.defineProperty;var t=(r,e)=>d(r,"name",{value:e,configurable:!0});require("os");require("path");var commands_agent=require("./agent.index.cjs");require("crypto");var parseKnownFiles=require("./parseKnownFiles.cjs"),require$$0$1=require("child_process"),require$$0=require("util");require("./index2.cjs");require("node:url");require("node:fs");require("node:fs/promises");require("node:util");require("node:path");require("fs");require("node:os");require("tty");require("node:perf_hooks");require("url");require("node:readline");require("node:process");require("node:tty");require("./index3.cjs");require("buffer");require("./index4.cjs");require("stream");require("events");require("string_decoder");require("zlib");require("http");require("https");require("assert");require("process");require("querystring");require("net");require("tls");require("dns");require("fs/promises");require("punycode");require("node:events");require("node:stream");require("http2");require("node:stream/web");require("timers");require("node:crypto");require("readline");require("./index5.cjs");require("./index6.cjs");const getValidatedProcessCredentials=t((r,e,i)=>{if(e.Version!==1)throw Error(`Profile ${r} credential_process did not return Version 1.`);if(e.AccessKeyId===void 0||e.SecretAccessKey===void 0)throw Error(`Profile ${r} credential_process returned invalid credentials.`);if(e.Expiration){const c=new Date;if(new Date(e.Expiration)<c)throw Error(`Profile ${r} credential_process returned expired credentials.`)}let s=e.AccountId;!s&&i?.[r]?.aws_account_id&&(s=i[r].aws_account_id);const n={accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,...e.SessionToken&&{sessionToken:e.SessionToken},...e.Expiration&&{expiration:new Date(e.Expiration)},...e.CredentialScope&&{credentialScope:e.CredentialScope},...s&&{accountId:s}};return commands_agent.setCredentialFeature$1(n,"CREDENTIALS_PROCESS","w"),n},"getValidatedProcessCredentials"),resolveProcessCredentials=t(async(r,e,i)=>{const s=e[r];if(e[r]){const n=s.credential_process;if(n!==void 0){const c=require$$0.promisify(require$$0$1.exec);try{const{stdout:o}=await c(n);let u;try{u=JSON.parse(o.trim())}catch{throw Error(`Profile ${r} credential_process returned invalid JSON.`)}return getValidatedProcessCredentials(r,u,e)}catch(o){throw new commands_agent.CredentialsProviderError(o.message,{logger:i})}}else throw new commands_agent.CredentialsProviderError(`Profile ${r} did not contain credential_process.`,{logger:i})}else throw new commands_agent.CredentialsProviderError(`Profile ${r} could not be found in shared credentials file.`,{logger:i})},"resolveProcessCredentials"),fromProcess=t((r={})=>async({callerClientConfig:e}={})=>{r.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");const i=await parseKnownFiles.parseKnownFiles(r);return resolveProcessCredentials(commands_agent.getProfileName({profile:r.profile??e?.profile}),i,r.logger)},"fromProcess");exports.fromProcess=fromProcess;
