@kya-os/mcp-i
Version:
The TypeScript MCP framework with identity features built-in
1 lines • 6.6 kB
JavaScript
;exports.id=866,exports.ids=[866],exports.modules={56826:(e,t,r)=>{r.d(t,{c:()=>p});var o=r(66391),n=r(25272),a=r(2203),s=r(12544);var i=r(39181),c=r(92278),l=r(2914);const d=e=>"function"==typeof ReadableStream&&(e?.constructor?.name===ReadableStream.name||e instanceof ReadableStream),u="The stream has already been transformed.",f=e=>{if(!h(e)&&!d(e))throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${e?.__proto__?.constructor?.name||e}`);let t=!1;const r=async()=>{if(t)throw new Error(u);return t=!0,await(async e=>"function"==typeof Blob&&e instanceof Blob||"Blob"===e.constructor?.name?void 0!==Blob.prototype.arrayBuffer?new Uint8Array(await e.arrayBuffer()):async function(e){const t=await function(e){return new Promise((t,r)=>{const o=new FileReader;o.onloadend=()=>{if(2!==o.readyState)return r(new Error("Reader aborted too early"));const e=o.result??"",n=e.indexOf(","),a=n>-1?n+1:e.length;t(e.substring(a))},o.onabort=()=>r(new Error("Read aborted")),o.onerror=()=>r(o.error),o.readAsDataURL(e)})}(e),r=(0,s.E)(t);return new Uint8Array(r)}(e):async function(e){const t=[],r=e.getReader();let o=!1,n=0;for(;!o;){const{done:e,value:a}=await r.read();a&&(t.push(a),n+=a.length),o=e}const a=new Uint8Array(n);let s=0;for(const e of t)a.set(e,s),s+=e.length;return a}(e))(e)};return Object.assign(e,{transformToByteArray:r,transformToString:async e=>{const t=await r();if("base64"===e)return(0,i.n)(t);if("hex"===e)return(0,c.n)(t);if(void 0===e||"utf8"===e||"utf-8"===e)return(0,l.P)(t);if("function"==typeof TextDecoder)return new TextDecoder(e).decode(t);throw new Error("TextDecoder is not available, please make sure polyfill is provided.")},transformToWebStream:()=>{if(t)throw new Error(u);if(t=!0,h(e))return(e=>{if("function"!=typeof e.stream)throw new Error("Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.\nIf you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body");return e.stream()})(e);if(d(e))return e;throw new Error(`Cannot transform payload to web stream, got ${e}`)}})},h=e=>"function"==typeof Blob&&e instanceof Blob,w="The stream has already been transformed.",p=e=>{if(!(e instanceof a.Readable))try{return f(e)}catch(t){throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${e?.__proto__?.constructor?.name||e}`)}let t=!1;const r=async()=>{if(t)throw new Error(w);return t=!0,await(0,o.k)(e)};return Object.assign(e,{transformToByteArray:r,transformToString:async e=>{const t=await r();return void 0===e||Buffer.isEncoding(e)?(0,n.Q)(t.buffer,t.byteOffset,t.byteLength).toString(e):new TextDecoder(e).decode(t)},transformToWebStream:()=>{if(t)throw new Error(w);if(null!==e.readableFlowing)throw new Error("The stream has been consumed by other callbacks.");if("function"!=typeof a.Readable.toWeb)throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");return t=!0,a.Readable.toWeb(e)}})}},57866:(e,t,r)=>{r.d(t,{fromHttp:()=>u});var o=r(53243),n=r(7940),a=r(84122),s=r(91943),i=r.n(s),c=r(86880),l=r(37882),d=r(56826);const u=(e={})=>{let t;e.logger?.debug("@aws-sdk/credential-provider-http - fromHttp");const r=e.awsContainerCredentialsRelativeUri??process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,s=e.awsContainerCredentialsFullUri??process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI,u=e.awsContainerAuthorizationToken??process.env.AWS_CONTAINER_AUTHORIZATION_TOKEN,f=e.awsContainerAuthorizationTokenFile??process.env.AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE,h="NoOpLogger"!==e.logger?.constructor?.name&&e.logger?.warn?e.logger.warn.bind(e.logger):console.warn;if(r&&s&&(h("@aws-sdk/credential-provider-http: you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri."),h("awsContainerCredentialsFullUri will take precedence.")),u&&f&&(h("@aws-sdk/credential-provider-http: you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile."),h("awsContainerAuthorizationToken will take precedence.")),s)t=s;else{if(!r)throw new a.C("No HTTP credential provider host provided.\nSet AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.",{logger:e.logger});t=`http://169.254.170.2${r}`}const w=new URL(t);((e,t)=>{if("https:"!==e.protocol&&"169.254.170.2"!==e.hostname&&"169.254.170.23"!==e.hostname&&"[fd00:ec2::23]"!==e.hostname){if(e.hostname.includes("[")){if("[::1]"===e.hostname||"[0000:0000:0000:0000:0000:0000:0000:0001]"===e.hostname)return}else{if("localhost"===e.hostname)return;const t=e.hostname.split("."),r=e=>{const t=parseInt(e,10);return 0<=t&&t<=255};if("127"===t[0]&&r(t[1])&&r(t[2])&&r(t[3])&&4===t.length)return}throw new a.C("URL not accepted. It must either be HTTPS or match one of the following:\n - loopback CIDR 127.0.0.0/8 or [::1/128]\n - ECS container host 169.254.170.2\n - EKS container host 169.254.170.23 or [fd00:ec2::23]",{logger:t})}})(w,e.logger);const p=n.$.create({requestTimeout:e.timeout??1e3,connectionTimeout:e.timeout??1e3});return m=async()=>{const t=function(e){return new c.K({protocol:e.protocol,hostname:e.hostname,port:Number(e.port),path:e.pathname,query:Array.from(e.searchParams.entries()).reduce((e,[t,r])=>(e[t]=r,e),{}),fragment:e.hash})}(w);u?t.headers.Authorization=u:f&&(t.headers.Authorization=(await i().readFile(f)).toString());try{return async function(e,t){const r=(0,d.c)(e.body),o=await r.transformToString();if(200===e.statusCode){const e=JSON.parse(o);if("string"!=typeof e.AccessKeyId||"string"!=typeof e.SecretAccessKey||"string"!=typeof e.Token||"string"!=typeof e.Expiration)throw new a.C("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }",{logger:t});return{accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:(0,l.EI)(e.Expiration)}}if(e.statusCode>=400&&e.statusCode<500){let r={};try{r=JSON.parse(o)}catch(e){}throw Object.assign(new a.C(`Server responded with status: ${e.statusCode}`,{logger:t}),{Code:r.Code,Message:r.Message})}throw new a.C(`Server responded with status: ${e.statusCode}`,{logger:t})}((await p.handle(t)).response).then(e=>(0,o.g)(e,"CREDENTIALS_HTTP","z"))}catch(t){throw new a.C(String(t),{logger:e.logger})}},g=e.maxRetries??3,y=e.timeout??1e3,async()=>{for(let e=0;e<g;++e)try{return await m()}catch(e){await new Promise(e=>setTimeout(e,y))}return await m()};var m,g,y}}};