UNPKG

@smythos/cli

Version:

SmythOS SRE Command Line Interface

3 lines (2 loc) 8.8 kB
#!/usr/bin/env node "use strict";var _=Object.defineProperty;var s=(e,n)=>_(e,"name",{value:n,configurable:!0});require("os");require("path");var commands_agent=require("./agent.index.cjs");require("crypto");var parseKnownFiles=require("./parseKnownFiles.cjs");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("util");require("inspector");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("child_process");require("punycode");require("node:stream");require("node:stream/web");require("http2");require("node:events");require("timers");require("node:crypto");require("readline");require("./index5.cjs");require("./index6.cjs");const resolveCredentialSource=s((e,n,r)=>{const i={EcsContainer:s(async o=>{const{fromHttp:t}=await Promise.resolve().then(function(){return require("./index16.cjs")}),{fromContainerMetadata:a}=await Promise.resolve().then(function(){return require("./index18.cjs")});return r?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>commands_agent.chain(t(o??{}),a(o))().then(setNamedProvider)},"EcsContainer"),Ec2InstanceMetadata:s(async o=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");const{fromInstanceMetadata:t}=await Promise.resolve().then(function(){return require("./index18.cjs")});return async()=>t(o)().then(setNamedProvider)},"Ec2InstanceMetadata"),Environment:s(async o=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");const{fromEnv:t}=await Promise.resolve().then(function(){return require("./index7.cjs")});return async()=>t(o)().then(setNamedProvider)},"Environment")};if(e in i)return i[e];throw new commands_agent.CredentialsProviderError(`Unsupported credential source in profile ${n}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:r})},"resolveCredentialSource"),setNamedProvider=s(e=>commands_agent.setCredentialFeature$1(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p"),"setNamedProvider"),isAssumeRoleProfile=s((e,{profile:n="default",logger:r}={})=>!!e&&typeof e=="object"&&typeof e.role_arn=="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(isAssumeRoleWithSourceProfile(e,{profile:n,logger:r})||isCredentialSourceProfile(e,{profile:n,logger:r})),"isAssumeRoleProfile"),isAssumeRoleWithSourceProfile=s((e,{profile:n,logger:r})=>{const i=typeof e.source_profile=="string"&&typeof e.credential_source>"u";return i&&r?.debug?.(` ${n} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`),i},"isAssumeRoleWithSourceProfile"),isCredentialSourceProfile=s((e,{profile:n,logger:r})=>{const i=typeof e.credential_source=="string"&&typeof e.source_profile>"u";return i&&r?.debug?.(` ${n} isCredentialSourceProfile credential_source=${e.credential_source}`),i},"isCredentialSourceProfile"),resolveAssumeRoleCredentials=s(async(e,n,r,i={})=>{r.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");const o=n[e],{source_profile:t,region:a}=o;if(!r.roleAssumer){const{getDefaultRoleAssumer:c}=await Promise.resolve().then(function(){return require("./index12.cjs")});r.roleAssumer=c({...r.clientConfig,credentialProviderLogger:r.logger,parentClientConfig:{...r?.parentClientConfig,region:a??r?.parentClientConfig?.region}},r.clientPlugins)}if(t&&t in i)throw new commands_agent.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${commands_agent.getProfileName(r)}. Profiles visited: `+Object.keys(i).join(", "),{logger:r.logger});r.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${t?`source_profile=[${t}]`:`profile=[${e}]`}`);const d=t?resolveProfileData(t,n,r,{...i,[t]:!0},isCredentialSourceWithoutRoleArn(n[t]??{})):(await resolveCredentialSource(o.credential_source,e,r.logger)(r))();if(isCredentialSourceWithoutRoleArn(o))return d.then(c=>commands_agent.setCredentialFeature$1(c,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"));{const c={RoleArn:o.role_arn,RoleSessionName:o.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:o.external_id,DurationSeconds:parseInt(o.duration_seconds||"3600",10)},{mfa_serial:u}=o;if(u){if(!r.mfaCodeProvider)throw new commands_agent.CredentialsProviderError(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:r.logger,tryNextLink:!1});c.SerialNumber=u,c.TokenCode=await r.mfaCodeProvider(u)}const l=await d;return r.roleAssumer(l,c).then(f=>commands_agent.setCredentialFeature$1(f,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"))}},"resolveAssumeRoleCredentials"),isCredentialSourceWithoutRoleArn=s(e=>!e.role_arn&&!!e.credential_source,"isCredentialSourceWithoutRoleArn"),isProcessProfile=s(e=>!!e&&typeof e=="object"&&typeof e.credential_process=="string","isProcessProfile"),resolveProcessCredentials=s(async(e,n)=>Promise.resolve().then(function(){return require("./index14.cjs")}).then(({fromProcess:r})=>r({...e,profile:n})().then(i=>commands_agent.setCredentialFeature$1(i,"CREDENTIALS_PROFILE_PROCESS","v"))),"resolveProcessCredentials"),resolveSsoCredentials=s(async(e,n,r={})=>{const{fromSSO:i}=await Promise.resolve().then(function(){return require("./index21.cjs")});return i({profile:e,logger:r.logger,parentClientConfig:r.parentClientConfig,clientConfig:r.clientConfig})().then(o=>n.sso_session?commands_agent.setCredentialFeature$1(o,"CREDENTIALS_PROFILE_SSO","r"):commands_agent.setCredentialFeature$1(o,"CREDENTIALS_PROFILE_SSO_LEGACY","t"))},"resolveSsoCredentials"),isSsoProfile=s(e=>e&&(typeof e.sso_start_url=="string"||typeof e.sso_account_id=="string"||typeof e.sso_session=="string"||typeof e.sso_region=="string"||typeof e.sso_role_name=="string"),"isSsoProfile"),isStaticCredsProfile=s(e=>!!e&&typeof e=="object"&&typeof e.aws_access_key_id=="string"&&typeof e.aws_secret_access_key=="string"&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,"isStaticCredsProfile"),resolveStaticCredentials=s(async(e,n)=>{n?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");const r={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return commands_agent.setCredentialFeature$1(r,"CREDENTIALS_PROFILE","n")},"resolveStaticCredentials"),isWebIdentityProfile=s(e=>!!e&&typeof e=="object"&&typeof e.web_identity_token_file=="string"&&typeof e.role_arn=="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1,"isWebIdentityProfile"),resolveWebIdentityCredentials=s(async(e,n)=>Promise.resolve().then(function(){return require("./index11.cjs")}).then(({fromTokenFile:r})=>r({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:n.roleAssumerWithWebIdentity,logger:n.logger,parentClientConfig:n.parentClientConfig})().then(i=>commands_agent.setCredentialFeature$1(i,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q"))),"resolveWebIdentityCredentials"),resolveProfileData=s(async(e,n,r,i={},o=!1)=>{const t=n[e];if(Object.keys(i).length>0&&isStaticCredsProfile(t))return resolveStaticCredentials(t,r);if(o||isAssumeRoleProfile(t,{profile:e,logger:r.logger}))return resolveAssumeRoleCredentials(e,n,r,i);if(isStaticCredsProfile(t))return resolveStaticCredentials(t,r);if(isWebIdentityProfile(t))return resolveWebIdentityCredentials(t,r);if(isProcessProfile(t))return resolveProcessCredentials(r,e);if(isSsoProfile(t))return await resolveSsoCredentials(e,t,r);throw new commands_agent.CredentialsProviderError(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:r.logger})},"resolveProfileData"),fromIni=s((e={})=>async({callerClientConfig:n}={})=>{const r={...e,parentClientConfig:{...n,...e.parentClientConfig}};r.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");const i=await parseKnownFiles.parseKnownFiles(r);return resolveProfileData(commands_agent.getProfileName({profile:e.profile??n?.profile}),i,r)},"fromIni");exports.fromIni=fromIni;