UNPKG

@smythos/cli

Version:

SmythOS SRE Command Line Interface

3 lines (2 loc) 16.7 kB
#!/usr/bin/env node "use strict";var T=Object.defineProperty;var P=(S,E)=>T(S,"name",{value:E,configurable:!0});require("os");require("path");require("crypto");var commands_agent=require("./agent.index.cjs");require("buffer");require("stream");require("node:stream");require("http");require("https");require("http2");var noAuth=require("./noAuth.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("./index4.cjs");require("events");require("string_decoder");require("zlib");require("assert");require("process");require("querystring");require("net");require("tls");require("dns");require("fs/promises");require("child_process");require("punycode");require("node:stream/web");require("node:events");require("timers");require("node:crypto");require("readline");require("./index5.cjs");require("./index6.cjs");const defaultSSOHttpAuthSchemeParametersProvider=P(async(S,E,y)=>({operation:commands_agent.getSmithyContext(E).operation,region:await commands_agent.normalizeProvider(S.region)()||(()=>{throw new Error("expected `region` to be configured for `aws.auth#sigv4`")})()}),"defaultSSOHttpAuthSchemeParametersProvider");function createAwsAuthSigv4HttpAuthOption(S){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"awsssoportal",region:S.region},propertiesExtractor:P((E,y)=>({signingProperties:{config:E,context:y}}),"propertiesExtractor")}}P(createAwsAuthSigv4HttpAuthOption,"createAwsAuthSigv4HttpAuthOption");function createSmithyApiNoAuthHttpAuthOption(S){return{schemeId:"smithy.api#noAuth"}}P(createSmithyApiNoAuthHttpAuthOption,"createSmithyApiNoAuthHttpAuthOption");const defaultSSOHttpAuthSchemeProvider=P(S=>{const E=[];switch(S.operation){case"GetRoleCredentials":{E.push(createSmithyApiNoAuthHttpAuthOption());break}case"ListAccountRoles":{E.push(createSmithyApiNoAuthHttpAuthOption());break}case"ListAccounts":{E.push(createSmithyApiNoAuthHttpAuthOption());break}case"Logout":{E.push(createSmithyApiNoAuthHttpAuthOption());break}default:E.push(createAwsAuthSigv4HttpAuthOption(S))}return E},"defaultSSOHttpAuthSchemeProvider"),resolveHttpAuthSchemeConfig=P(S=>{const E=commands_agent.resolveAwsSdkSigV4Config(S);return Object.assign(E,{authSchemePreference:commands_agent.normalizeProvider(S.authSchemePreference??[])})},"resolveHttpAuthSchemeConfig"),resolveClientEndpointParameters=P(S=>Object.assign(S,{useDualstackEndpoint:S.useDualstackEndpoint??!1,useFipsEndpoint:S.useFipsEndpoint??!1,defaultSigningName:"awsssoportal"}),"resolveClientEndpointParameters"),commonParams={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}};var version="3.826.0",packageInfo={version};const u="required",v="fn",w="argv",x="ref",a=!0,b="isSet",c="booleanEquals",d="error",e="endpoint",f="tree",g="PartitionResult",h="getAttr",i={[u]:!1,type:"String"},j={[u]:!0,default:!1,type:"Boolean"},k={[x]:"Endpoint"},l={[v]:c,[w]:[{[x]:"UseFIPS"},!0]},m={[v]:c,[w]:[{[x]:"UseDualStack"},!0]},n={},o={[v]:h,[w]:[{[x]:g},"supportsFIPS"]},p={[x]:g},q={[v]:c,[w]:[!0,{[v]:h,[w]:[p,"supportsDualStack"]}]},r=[l],s=[m],t=[{[x]:"Region"}],_data={parameters:{Region:i,UseDualStack:j,UseFIPS:j,Endpoint:i},rules:[{conditions:[{[v]:b,[w]:[k]}],rules:[{conditions:r,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:d},{conditions:s,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:d},{endpoint:{url:k,properties:n,headers:n},type:e}],type:f},{conditions:[{[v]:b,[w]:t}],rules:[{conditions:[{[v]:"aws.partition",[w]:t,assign:g}],rules:[{conditions:[l,m],rules:[{conditions:[{[v]:c,[w]:[a,o]},q],rules:[{endpoint:{url:"https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:n,headers:n},type:e}],type:f},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:d}],type:f},{conditions:r,rules:[{conditions:[{[v]:c,[w]:[o,a]}],rules:[{conditions:[{[v]:"stringEquals",[w]:[{[v]:h,[w]:[p,"name"]},"aws-us-gov"]}],endpoint:{url:"https://portal.sso.{Region}.amazonaws.com",properties:n,headers:n},type:e},{endpoint:{url:"https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}",properties:n,headers:n},type:e}],type:f},{error:"FIPS is enabled but this partition does not support FIPS",type:d}],type:f},{conditions:s,rules:[{conditions:[q],rules:[{endpoint:{url:"https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:n,headers:n},type:e}],type:f},{error:"DualStack is enabled but this partition does not support DualStack",type:d}],type:f},{endpoint:{url:"https://portal.sso.{Region}.{PartitionResult#dnsSuffix}",properties:n,headers:n},type:e}],type:f}],type:f},{error:"Invalid Configuration: Missing Region",type:d}]},ruleSet=_data,cache=new commands_agent.EndpointCache({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),defaultEndpointResolver=P((S,E={})=>cache.get(S,()=>commands_agent.resolveEndpoint(ruleSet,{endpointParams:S,logger:E.logger})),"defaultEndpointResolver");commands_agent.customEndpointFunctions.aws=commands_agent.awsEndpointFunctions;const getRuntimeConfig$1=P(S=>({apiVersion:"2019-06-10",base64Decoder:S?.base64Decoder??commands_agent.fromBase64,base64Encoder:S?.base64Encoder??commands_agent.toBase64,disableHostPrefix:S?.disableHostPrefix??!1,endpointProvider:S?.endpointProvider??defaultEndpointResolver,extensions:S?.extensions??[],httpAuthSchemeProvider:S?.httpAuthSchemeProvider??defaultSSOHttpAuthSchemeProvider,httpAuthSchemes:S?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:P(E=>E.getIdentityProvider("aws.auth#sigv4"),"identityProvider"),signer:new commands_agent.AwsSdkSigV4Signer},{schemeId:"smithy.api#noAuth",identityProvider:P(E=>E.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),"identityProvider"),signer:new noAuth.NoAuthSigner}],logger:S?.logger??new commands_agent.NoOpLogger,serviceId:S?.serviceId??"SSO",urlParser:S?.urlParser??commands_agent.parseUrl,utf8Decoder:S?.utf8Decoder??commands_agent.fromUtf8,utf8Encoder:S?.utf8Encoder??commands_agent.toUtf8}),"getRuntimeConfig$1"),getRuntimeConfig=P(S=>{commands_agent.emitWarningIfUnsupportedVersion(process.version);const E=commands_agent.resolveDefaultsModeConfig(S),y=P(()=>E().then(commands_agent.loadConfigsForDefaultMode),"defaultConfigProvider"),I=getRuntimeConfig$1(S);commands_agent.emitWarningIfUnsupportedVersion$1(process.version);const C={profile:S?.profile,logger:I.logger};return{...I,...S,runtime:"node",defaultsMode:E,authSchemePreference:S?.authSchemePreference??commands_agent.loadConfig(commands_agent.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,C),bodyLengthChecker:S?.bodyLengthChecker??commands_agent.calculateBodyLength,defaultUserAgentProvider:S?.defaultUserAgentProvider??commands_agent.createDefaultUserAgentProvider({serviceId:I.serviceId,clientVersion:packageInfo.version}),maxAttempts:S?.maxAttempts??commands_agent.loadConfig(commands_agent.NODE_MAX_ATTEMPT_CONFIG_OPTIONS,S),region:S?.region??commands_agent.loadConfig(commands_agent.NODE_REGION_CONFIG_OPTIONS,{...commands_agent.NODE_REGION_CONFIG_FILE_OPTIONS,...C}),requestHandler:commands_agent.NodeHttpHandler.create(S?.requestHandler??y),retryMode:S?.retryMode??commands_agent.loadConfig({...commands_agent.NODE_RETRY_MODE_CONFIG_OPTIONS,default:P(async()=>(await y()).retryMode||commands_agent.DEFAULT_RETRY_MODE,"default")},S),sha256:S?.sha256??commands_agent.Hash.bind(null,"sha256"),streamCollector:S?.streamCollector??commands_agent.streamCollector,useDualstackEndpoint:S?.useDualstackEndpoint??commands_agent.loadConfig(commands_agent.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,C),useFipsEndpoint:S?.useFipsEndpoint??commands_agent.loadConfig(commands_agent.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,C),userAgentAppId:S?.userAgentAppId??commands_agent.loadConfig(commands_agent.NODE_APP_ID_CONFIG_OPTIONS,C)}},"getRuntimeConfig"),getHttpAuthExtensionConfiguration=P(S=>{const E=S.httpAuthSchemes;let y=S.httpAuthSchemeProvider,I=S.credentials;return{setHttpAuthScheme(C){const _=E.findIndex(R=>R.schemeId===C.schemeId);_===-1?E.push(C):E.splice(_,1,C)},httpAuthSchemes(){return E},setHttpAuthSchemeProvider(C){y=C},httpAuthSchemeProvider(){return y},setCredentials(C){I=C},credentials(){return I}}},"getHttpAuthExtensionConfiguration"),resolveHttpAuthRuntimeConfig=P(S=>({httpAuthSchemes:S.httpAuthSchemes(),httpAuthSchemeProvider:S.httpAuthSchemeProvider(),credentials:S.credentials()}),"resolveHttpAuthRuntimeConfig"),resolveRuntimeExtensions=P((S,E)=>{const y=Object.assign(commands_agent.getAwsRegionExtensionConfiguration(S),commands_agent.getDefaultExtensionConfiguration(S),commands_agent.getHttpHandlerExtensionConfiguration(S),getHttpAuthExtensionConfiguration(S));return E.forEach(I=>I.configure(y)),Object.assign(S,commands_agent.resolveAwsRegionExtensionConfiguration(y),commands_agent.resolveDefaultRuntimeConfig(y),commands_agent.resolveHttpHandlerRuntimeConfig(y),resolveHttpAuthRuntimeConfig(y))},"resolveRuntimeExtensions");class SSOClient extends commands_agent.Client{static{P(this,"SSOClient")}config;constructor(...[E]){const y=getRuntimeConfig(E||{});super(y),this.initConfig=y;const I=resolveClientEndpointParameters(y),C=commands_agent.resolveUserAgentConfig(I),_=commands_agent.resolveRetryConfig(C),R=commands_agent.resolveRegionConfig(_),A=commands_agent.resolveHostHeaderConfig(R),O=commands_agent.resolveEndpointConfig(A),N=resolveHttpAuthSchemeConfig(O),D=resolveRuntimeExtensions(N,E?.extensions||[]);this.config=D,this.middlewareStack.use(commands_agent.getUserAgentPlugin(this.config)),this.middlewareStack.use(commands_agent.getRetryPlugin(this.config)),this.middlewareStack.use(commands_agent.getContentLengthPlugin(this.config)),this.middlewareStack.use(commands_agent.getHostHeaderPlugin(this.config)),this.middlewareStack.use(commands_agent.getLoggerPlugin(this.config)),this.middlewareStack.use(commands_agent.getRecursionDetectionPlugin(this.config)),this.middlewareStack.use(commands_agent.getHttpAuthSchemeEndpointRuleSetPlugin(this.config,{httpAuthSchemeParametersProvider:defaultSSOHttpAuthSchemeParametersProvider,identityProviderConfigProvider:P(async F=>new commands_agent.DefaultIdentityProviderConfig({"aws.auth#sigv4":F.credentials}),"identityProviderConfigProvider")})),this.middlewareStack.use(commands_agent.getHttpSigningPlugin(this.config))}destroy(){super.destroy()}}class SSOServiceException extends commands_agent.ServiceException{static{P(this,"SSOServiceException")}constructor(E){super(E),Object.setPrototypeOf(this,SSOServiceException.prototype)}}class InvalidRequestException extends SSOServiceException{static{P(this,"InvalidRequestException")}name="InvalidRequestException";$fault="client";constructor(E){super({name:"InvalidRequestException",$fault:"client",...E}),Object.setPrototypeOf(this,InvalidRequestException.prototype)}}class ResourceNotFoundException extends SSOServiceException{static{P(this,"ResourceNotFoundException")}name="ResourceNotFoundException";$fault="client";constructor(E){super({name:"ResourceNotFoundException",$fault:"client",...E}),Object.setPrototypeOf(this,ResourceNotFoundException.prototype)}}class TooManyRequestsException extends SSOServiceException{static{P(this,"TooManyRequestsException")}name="TooManyRequestsException";$fault="client";constructor(E){super({name:"TooManyRequestsException",$fault:"client",...E}),Object.setPrototypeOf(this,TooManyRequestsException.prototype)}}class UnauthorizedException extends SSOServiceException{static{P(this,"UnauthorizedException")}name="UnauthorizedException";$fault="client";constructor(E){super({name:"UnauthorizedException",$fault:"client",...E}),Object.setPrototypeOf(this,UnauthorizedException.prototype)}}const GetRoleCredentialsRequestFilterSensitiveLog=P(S=>({...S,...S.accessToken&&{accessToken:commands_agent.SENSITIVE_STRING}}),"GetRoleCredentialsRequestFilterSensitiveLog"),RoleCredentialsFilterSensitiveLog=P(S=>({...S,...S.secretAccessKey&&{secretAccessKey:commands_agent.SENSITIVE_STRING},...S.sessionToken&&{sessionToken:commands_agent.SENSITIVE_STRING}}),"RoleCredentialsFilterSensitiveLog"),GetRoleCredentialsResponseFilterSensitiveLog=P(S=>({...S,...S.roleCredentials&&{roleCredentials:RoleCredentialsFilterSensitiveLog(S.roleCredentials)}}),"GetRoleCredentialsResponseFilterSensitiveLog"),se_GetRoleCredentialsCommand=P(async(S,E)=>{const y=commands_agent.requestBuilder(S,E),I=commands_agent.map({},commands_agent.isSerializableHeaderValue,{[_xasbt]:S[_aT]});y.bp("/federation/credentials");const C=commands_agent.map({[_rn]:[,commands_agent.expectNonNull(S[_rN],"roleName")],[_ai]:[,commands_agent.expectNonNull(S[_aI],"accountId")]});return y.m("GET").h(I).q(C).b(void 0),y.build()},"se_GetRoleCredentialsCommand"),de_GetRoleCredentialsCommand=P(async(S,E)=>{if(S.statusCode!==200&&S.statusCode>=300)return de_CommandError(S,E);const y=commands_agent.map({$metadata:deserializeMetadata(S)}),I=commands_agent.expectNonNull(commands_agent.expectObject(await commands_agent.parseJsonBody(S.body,E)),"body"),C=commands_agent.take(I,{roleCredentials:commands_agent._json});return Object.assign(y,C),y},"de_GetRoleCredentialsCommand"),de_CommandError=P(async(S,E)=>{const y={...S,body:await commands_agent.parseJsonErrorBody(S.body,E)},I=commands_agent.loadRestJsonErrorCode(S,y.body);switch(I){case"InvalidRequestException":case"com.amazonaws.sso#InvalidRequestException":throw await de_InvalidRequestExceptionRes(y);case"ResourceNotFoundException":case"com.amazonaws.sso#ResourceNotFoundException":throw await de_ResourceNotFoundExceptionRes(y);case"TooManyRequestsException":case"com.amazonaws.sso#TooManyRequestsException":throw await de_TooManyRequestsExceptionRes(y);case"UnauthorizedException":case"com.amazonaws.sso#UnauthorizedException":throw await de_UnauthorizedExceptionRes(y);default:const C=y.body;return throwDefaultError({output:S,parsedBody:C,errorCode:I})}},"de_CommandError"),throwDefaultError=commands_agent.withBaseException(SSOServiceException),de_InvalidRequestExceptionRes=P(async(S,E)=>{const y=commands_agent.map({}),I=S.body,C=commands_agent.take(I,{message:commands_agent.expectString});Object.assign(y,C);const _=new InvalidRequestException({$metadata:deserializeMetadata(S),...y});return commands_agent.decorateServiceException(_,S.body)},"de_InvalidRequestExceptionRes"),de_ResourceNotFoundExceptionRes=P(async(S,E)=>{const y=commands_agent.map({}),I=S.body,C=commands_agent.take(I,{message:commands_agent.expectString});Object.assign(y,C);const _=new ResourceNotFoundException({$metadata:deserializeMetadata(S),...y});return commands_agent.decorateServiceException(_,S.body)},"de_ResourceNotFoundExceptionRes"),de_TooManyRequestsExceptionRes=P(async(S,E)=>{const y=commands_agent.map({}),I=S.body,C=commands_agent.take(I,{message:commands_agent.expectString});Object.assign(y,C);const _=new TooManyRequestsException({$metadata:deserializeMetadata(S),...y});return commands_agent.decorateServiceException(_,S.body)},"de_TooManyRequestsExceptionRes"),de_UnauthorizedExceptionRes=P(async(S,E)=>{const y=commands_agent.map({}),I=S.body,C=commands_agent.take(I,{message:commands_agent.expectString});Object.assign(y,C);const _=new UnauthorizedException({$metadata:deserializeMetadata(S),...y});return commands_agent.decorateServiceException(_,S.body)},"de_UnauthorizedExceptionRes"),deserializeMetadata=P(S=>({httpStatusCode:S.statusCode,requestId:S.headers["x-amzn-requestid"]??S.headers["x-amzn-request-id"]??S.headers["x-amz-request-id"],extendedRequestId:S.headers["x-amz-id-2"],cfId:S.headers["x-amz-cf-id"]}),"deserializeMetadata"),_aI="accountId",_aT="accessToken",_ai="account_id",_rN="roleName",_rn="role_name",_xasbt="x-amz-sso_bearer_token";class GetRoleCredentialsCommand extends commands_agent.Command.classBuilder().ep(commonParams).m(function(E,y,I,C){return[commands_agent.getSerdePlugin(I,this.serialize,this.deserialize),commands_agent.getEndpointPlugin(I,E.getEndpointParameterInstructions())]}).s("SWBPortalService","GetRoleCredentials",{}).n("SSOClient","GetRoleCredentialsCommand").f(GetRoleCredentialsRequestFilterSensitiveLog,GetRoleCredentialsResponseFilterSensitiveLog).ser(se_GetRoleCredentialsCommand).de(de_GetRoleCredentialsCommand).build(){static{P(this,"GetRoleCredentialsCommand")}}exports.GetRoleCredentialsCommand=GetRoleCredentialsCommand;exports.SSOClient=SSOClient;