@integration-app/membrane-cli
Version:
CLI tool for importing and exporting Integration.app workspace data
6 lines (5 loc) • 4.27 kB
JavaScript
var A=Object.defineProperty;var i=(e,r)=>A(e,"name",{value:r,configurable:!0});import{C as a,H as l,i as C,p as _,N as E,s as I}from"./index-CNuB1luy.js";import"http2";import"stream";import N from"fs/promises";import"buffer";import"node:stream";import"fs";import"path";import"url";import"chalk";import"commander";import"inquirer";import"node:fs";import"node:path";import"js-yaml";import"@integration-app/sdk";import"zod";import"jsonwebtoken";import"events";import"constants";import"util";import"assert";import"node:url";import"node:fs/promises";import"node:events";import"node:string_decoder";import"zlib";import"form-data";import"async_hooks";import"http";import"https";import"os";import"crypto";import"process";import"@anthropic-ai/sdk";const u="169.254.170.2",w="169.254.170.23",R="[fd00:ec2::23]",f=i((e,r)=>{if(e.protocol!=="https:"&&!(e.hostname===u||e.hostname===w||e.hostname===R)){if(e.hostname.includes("[")){if(e.hostname==="[::1]"||e.hostname==="[0000:0000:0000:0000:0000:0000:0000:0001]")return}else{if(e.hostname==="localhost")return;const n=e.hostname.split("."),o=i(t=>{const s=parseInt(t,10);return 0<=s&&s<=255},"inRange");if(n[0]==="127"&&o(n[1])&&o(n[2])&&o(n[3])&&n.length===4)return}throw new a(`URL not accepted. It must either be HTTPS or match one of the following:
- loopback CIDR 127.0.0.0/8 or [::1/128]
- ECS container host 169.254.170.2
- EKS container host 169.254.170.23 or [fd00:ec2::23]`,{logger:r})}},"checkUrl");function S(e){return new l({protocol:e.protocol,hostname:e.hostname,port:Number(e.port),path:e.pathname,query:Array.from(e.searchParams.entries()).reduce((r,[n,o])=>(r[n]=o,r),{}),fragment:e.hash})}i(S,"createGetRequest");async function g(e,r){const o=await C(e.body).transformToString();if(e.statusCode===200){const t=JSON.parse(o);if(typeof t.AccessKeyId!="string"||typeof t.SecretAccessKey!="string"||typeof t.Token!="string"||typeof t.Expiration!="string")throw new a("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }",{logger:r});return{accessKeyId:t.AccessKeyId,secretAccessKey:t.SecretAccessKey,sessionToken:t.Token,expiration:_(t.Expiration)}}if(e.statusCode>=400&&e.statusCode<500){let t={};try{t=JSON.parse(o)}catch{}throw Object.assign(new a(`Server responded with status: ${e.statusCode}`,{logger:r}),{Code:t.Code,Message:t.Message})}throw new a(`Server responded with status: ${e.statusCode}`,{logger:r})}i(g,"getCredentials");const O=i((e,r,n)=>async()=>{for(let o=0;o<r;++o)try{return await e()}catch{await new Promise(s=>setTimeout(s,n))}return await e()},"retryWrapper"),L="AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",y="http://169.254.170.2",U="AWS_CONTAINER_CREDENTIALS_FULL_URI",v="AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE",k="AWS_CONTAINER_AUTHORIZATION_TOKEN",H=i((e={})=>{e.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");let r;const n=e.awsContainerCredentialsRelativeUri??process.env[L],o=e.awsContainerCredentialsFullUri??process.env[U],t=e.awsContainerAuthorizationToken??process.env[k],s=e.awsContainerAuthorizationTokenFile??process.env[v],c=e.logger?.constructor?.name==="NoOpLogger"||!e.logger?console.warn:e.logger.warn;if(n&&o&&(c("@aws-sdk/credential-provider-http: you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri."),c("awsContainerCredentialsFullUri will take precedence.")),t&&s&&(c("@aws-sdk/credential-provider-http: you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile."),c("awsContainerAuthorizationToken will take precedence.")),o)r=o;else if(n)r=`${y}${n}`;else throw new a(`No HTTP credential provider host provided.
Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.`,{logger:e.logger});const d=new URL(r);f(d,e.logger);const T=new E({requestTimeout:e.timeout??1e3,connectionTimeout:e.timeout??1e3});return O(async()=>{const m=S(d);t?m.headers.Authorization=t:s&&(m.headers.Authorization=(await N.readFile(s)).toString());try{const p=await T.handle(m);return g(p.response).then(h=>I(h,"CREDENTIALS_HTTP","z"))}catch(p){throw new a(String(p),{logger:e.logger})}},e.maxRetries??3,e.timeout??1e3)},"fromHttp");export{H as fromHttp};