MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / lease

Method lease

package/cli.js:244–244  ·  view source on GitHub ↗
(q,K)

Source from the content-addressed store, hash-verified

242${Y}`;break;case"retry":if(bF7(Y))K[z]=Y;break;case"id":if(xF7(Y))K[z]=Y;break;case"event":if(Y.length>0)K[z]=Y;break}}processEvent(q){if(q.retry&&bF7(q.retry))this.state.reconnectionTime=parseInt(q.retry,10);if(q.id&&xF7(q.id))this.state.lastEventId=q.id;if(q.data!==void 0)this.push({type:q.event||"message",options:{data:q.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}uF7.exports={EventSourceStream:IF7}});var cF7=m((zg$,dF7)=>{var{pipeline:Md5}=U6("node:stream"),{fetching:Xd5}=JB6(),{makeRequest:Pd5}=Kf6(),{webidl:Sl}=vf(),{EventSourceStream:Wd5}=mF7(),{parseMIMEType:Dd5}=tk(),{createFastMessageEvent:fd5}=Of6(),{isNetworkError:pF7}=jB6(),{delay:Zd5}=e31(),{kEnumerableProperty:i_6}=Yz(),{environmentSettingsObject:BF7}=NE(),gF7=!1,FF7=3000,NB6=0,UF7=1,yB6=2,Gd5="anonymous",Td5="use-credentials";class Mf6 extends EventTarget{#q={open:null,error:null,message:null};#K=null;#_=!1;#Y=NB6;#z=null;#O=null;#$;#w;constructor(q,K={}){super();Sl.util.markAsUncloneable(this);let _="EventSource constructor";if(Sl.argumentLengthCheck(arguments,1,_),!gF7)gF7=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"});q=Sl.converters.USVString(q,_,"url"),K=Sl.converters.EventSourceInitDict(K,_,"eventSourceInitDict"),this.#$=K.dispatcher,this.#w={lastEventId:"",reconnectionTime:FF7};let z=BF7,Y;try{Y=new URL(q,z.settingsObject.baseUrl),this.#w.origin=Y.origin}catch(O){throw new DOMException(O,"SyntaxError")}this.#K=Y.href;let $=Gd5;if(K.withCredentials)$=Td5,this.#_=!0;let A={redirect:"follow",keepalive:!0,mode:"cors",credentials:$==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};A.client=BF7.settingsObject,A.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],A.cache="no-store",A.initiator="other",A.urlList=[new URL(this.#K)],this.#z=Pd5(A),this.#H()}get readyState(){return this.#Y}get url(){return this.#K}get withCredentials(){return this.#_}#H(){if(this.#Y===yB6)return;this.#Y=NB6;let q={request:this.#z,dispatcher:this.#$},K=(_)=>{if(pF7(_))this.dispatchEvent(new Event("error")),this.close();this.#j()};q.processResponseEndOfBody=K,q.processResponse=(_)=>{if(pF7(_))if(_.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#j();return}let z=_.headersList.get("content-type",!0),Y=z!==null?Dd5(z):"failure",$=Y!=="failure"&&Y.essence==="text/event-stream";if(_.status!==200||$===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#Y=UF7,this.dispatchEvent(new Event("open")),this.#w.origin=_.urlList[_.urlList.length-1].origin;let A=new Wd5({eventSourceSettings:this.#w,push:(O)=>{this.dispatchEvent(fd5(O.type,O.options))}});Md5(_.body.stream,A,(O)=>{if(O?.aborted===!1)this.close(),this.dispatchEvent(new Event("error"))})},this.#O=Xd5(q)}async#j(){if(this.#Y===yB6)return;if(this.#Y=NB6,this.dispatchEvent(new Event("error")),await Zd5(this.#w.reconnectionTime),this.#Y!==NB6)return;if(this.#w.lastEventId.length)this.#z.headersList.set("last-event-id",this.#w.lastEventId,!0);this.#H()}close(){if(Sl.brandCheck(this,Mf6),this.#Y===yB6)return;this.#Y=yB6,this.#O.abort(),this.#z=null}get onopen(){return this.#q.open}set onopen(q){if(this.#q.open)this.removeEventListener("open",this.#q.open);if(typeof q==="function")this.#q.open=q,this.addEventListener("open",q);else this.#q.open=null}get onmessage(){return this.#q.message}set onmessage(q){if(this.#q.message)this.removeEventListener("message",this.#q.message);if(typeof q==="function")this.#q.message=q,this.addEventListener("message",q);else this.#q.message=null}get onerror(){return this.#q.error}set onerror(q){if(this.#q.error)this.removeEventListener("error",this.#q.error);if(typeof q==="function")this.#q.error=q,this.addEventListener("error",q);else this.#q.error=null}}var QF7={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:NB6,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:UF7,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:yB6,writable:!1}};Object.defineProperties(Mf6,QF7);Object.defineProperties(Mf6.prototype,QF7);Object.defineProperties(Mf6.prototype,{close:i_6,onerror:i_6,onmessage:i_6,onopen:i_6,readyState:i_6,url:i_6,withCredentials:i_6});Sl.converters.EventSourceInitDict=Sl.dictionaryConverter([{key:"withCredentials",converter:Sl.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:Sl.converters.any}]);dF7.exports={EventSource:Mf6,defaultReconnectionTime:FF7}});var LB6=m((ed5,J3)=>{var vd5=UD6(),lF7=hp6(),kd5=QD6(),Vd5=Du7(),Nd5=dD6(),yd5=i51(),Ed5=cu7(),Ld5=su7(),nF7=Q$(),Pw8=Yz(),{InvalidArgumentError:Xw8}=nF7,Xf6=cm7(),Rd5=Cp6(),hd5=Z31(),Sd5=Sp7(),Cd5=T31(),bd5=O31(),xd5=VO8(),{getGlobalDispatcher:iF7,setGlobalDispatcher:Id5}=bO8(),ud5=xO8(),md5=XO8(),pd5=PO8();Object.assign(lF7.prototype,Xf6);ed5.Dispatcher=lF7;ed5.Client=vd5;ed5.Pool=kd5;ed5.BalancedPool=Vd5;ed5.Agent=Nd5;ed5.ProxyAgent=yd5;ed5.EnvHttpProxyAgent=Ed5;ed5.RetryAgent=Ld5;ed5.RetryHandler=xd5;ed5.DecoratorHandler=ud5;ed5.RedirectHandler=md5;ed5.createRedirectInterceptor=pd5;ed5.interceptors={redirect:pp7(),retry:gp7(),dump:Qp7(),dns:ip7()};ed5.buildConnector=Rd5;ed5.errors=nF7;ed5.util={parseHeaders:Pw8.parseHeaders,headerNameToString:Pw8.headerNameToString};function EB6(q){return(K,_,z)=>{if(typeof _==="function")z=_,_=null;if(!K||typeof K!=="string"&&typeof K!=="object"&&!(K instanceof URL))throw new Xw8("invalid url");if(_!=null&&typeof _!=="object")throw new Xw8("invalid opts");if(_&&_.path!=null){if(typeof _.path!=="string")throw new Xw8("invalid opts.path");let A=_.path;if(!_.path.startsWith("/"))A=`/${A}`;K=new URL(Pw8.parseOrigin(K).origin+A)}else{if(!_)_=typeof K==="object"?K:{};K=Pw8.parseURL(K)}let{agent:Y,dispatcher:$=iF7()}=_;if(Y)throw new Xw8("unsupported opts.agent. Did you mean opts.client?");return q.call($,{..._,origin:K.origin,path:K.search?`${K.pathname}${K.search}`:K.pathname,method:_.method||(_.body?"PUT":"GET")},z)}}ed5.setGlobalDispatcher=Id5;ed5.getGlobalDispatcher=iF7;var Bd5=JB6().fetch;ed5.fetch=async function(K,_=void 0){try{return await Bd5(K,_)}catch(z){if(z&&typeof z==="object")Error.captureStackTrace(z);throw z}};ed5.Headers=U_6().Headers;ed5.Response=jB6().Response;ed5.Request=Kf6().Request;ed5.FormData=pp6().FormData;ed5.File=globalThis.File??U6("node:buffer").File;ed5.FileReader=Jg7().FileReader;var{setGlobalOrigin:gd5,getGlobalOrigin:Fd5}=$51();ed5.setGlobalOrigin=gd5;ed5.getGlobalOrigin=Fd5;var{CacheStorage:Ud5}=Tg7(),{kConstruct:Qd5}=eO8();ed5.caches=new Ud5(Qd5);var{deleteCookie:dd5,getCookies:cd5,getSetCookies:ld5,setCookie:nd5}=bg7();ed5.deleteCookie=dd5;ed5.getCookies=cd5;ed5.getSetCookies=ld5;ed5.setCookie=nd5;var{parseMIMEType:id5,serializeAMimeType:rd5}=tk();ed5.parseMIMEType=id5;ed5.serializeAMimeType=rd5;var{CloseEvent:od5,ErrorEvent:ad5,MessageEvent:sd5}=Of6();ed5.WebSocket=SF7().WebSocket;ed5.CloseEvent=od5;ed5.ErrorEvent=ad5;ed5.MessageEvent=sd5;ed5.request=EB6(Xf6.request);ed5.stream=EB6(Xf6.stream);ed5.pipeline=EB6(Xf6.pipeline);ed5.connect=EB6(Xf6.connect);ed5.upgrade=EB6(Xf6.upgrade);ed5.MockClient=hd5;ed5.MockPool=Cd5;ed5.MockAgent=Sd5;ed5.mockErrors=bd5;var{EventSource:td5}=cF7();ed5.EventSource=td5});import{Agent as rc5}from"https";function YV(){let q=Ch(),K=$I();if(!q&&!K)return;return{...q,...K&&{ca:K}}}function Dw8(){let q=Ch(),K=$I();if(!q&&!K)return{};let _={...q,...K&&{ca:K}};if(typeof Bun<"u")return{tls:_};return N("TLS: Created undici agent with custom certificates"),{dispatcher:new(LB6()).Agent({connect:{cert:_.cert,key:_.key,passphrase:_.passphrase,..._.ca&&{ca:_.ca}},pipelining:1})}}function rF7(){Ch.cache.clear?.(),Ww8.cache.clear?.(),N("Cleared mTLS configuration cache")}function oF7(){if(!Ch())return;if(process.env.NODE_EXTRA_CA_CERTS)N("NODE_EXTRA_CA_CERTS detected - Node.js will automatically append to built-in CAs")}var Ch,Ww8;var PI=y(()=>{F4();Lp6();_8();e7();Ch=_1(()=>{let q={};if(process.env.CLAUDE_CODE_CLIENT_CERT)try{q.cert=X8().readFileSync(process.env.CLAUDE_CODE_CLIENT_CERT,{encoding:"utf8"}),N("mTLS: Loaded client certificate from CLAUDE_CODE_CLIENT_CERT")}catch(K){N(`mTLS: Failed to load client certificate: ${K}`,{level:"error"})}if(process.env.CLAUDE_CODE_CLIENT_KEY)try{q.key=X8().readFileSync(process.env.CLAUDE_CODE_CLIENT_KEY,{encoding:"utf8"}),N("mTLS: Loaded client key from CLAUDE_CODE_CLIENT_KEY")}catch(K){N(`mTLS: Failed to load client key: ${K}`,{level:"error"})}if(process.env.CLAUDE_CODE_CLIENT_KEY_PASSPHRASE)q.passphrase=process.env.CLAUDE_CODE_CLIENT_KEY_PASSPHRASE,N("mTLS: Using client key passphrase");if(Object.keys(q).length===0)return;return q}),Ww8=_1(()=>{let q=Ch(),K=$I();if(!q&&!K)return;let _={...q,...K&&{ca:K},keepAlive:!0};return N("mTLS: Creating HTTPS agent with custom certificates"),new rc5(_)})});var aF7=m((ql5)=>{ql5.HttpAuthLocation=void 0;(function(q){q.HEADER="header",q.QUERY="query"})(ql5.HttpAuthLocation||(ql5.HttpAuthLocation={}));ql5.HttpApiKeyAuthLocation=void 0;(function(q){q.HEADER="header",q.QUERY="query"})(ql5.HttpApiKeyAuthLocation||(ql5.HttpApiKeyAuthLocation={}));ql5.EndpointURLScheme=void 0;(function(q){q.HTTP="http",q.HTTPS="https"})(ql5.EndpointURLScheme||(ql5.EndpointURLScheme={}));ql5.AlgorithmId=void 0;(function(q){q.MD5="md5",q.CRC32="crc32",q.CRC32C="crc32c",q.SHA1="sha1",q.SHA256="sha256"})(ql5.AlgorithmId||(ql5.AlgorithmId={}));var oc5=(q)=>{let K=[];if(q.sha256!==void 0)K.push({algorithmId:()=>ql5.AlgorithmId.SHA256,checksumConstructor:()=>q.sha256});if(q.md5!=null)K.push({algorithmId:()=>ql5.AlgorithmId.MD5,checksumConstructor:()=>q.md5});return{addChecksumAlgorithm(_){K.push(_)},checksumAlgorithms(){return K}}},ac5=(q)=>{let K={};return q.checksumAlgorithms().forEach((_)=>{K[_.algorithmId()]=_.checksumConstructor()}),K},sc5=(q)=>{return oc5(q)},tc5=(q)=>{return ac5(q)};ql5.FieldPosition=void 0;(function(q){q[q.HEADER=0]="HEADER",q[q.TRAILER=1]="TRAILER"})(ql5.FieldPosition||(ql5.FieldPosition={}));var ec5="__smithy_context";ql5.IniSectionType=void 0;(function(q){q.PROFILE="profile",q.SSO_SESSION="sso-session",q.SERVICES="services"})(ql5.IniSectionType||(ql5.IniSectionType={}));ql5.RequestHandlerProtocol=void 0;(function(q){q.HTTP_0_9="http/0.9",q.HTTP_1_0="http/1.0",q.TDS_8_0="tds/8.0"})(ql5.RequestHandlerProtocol||(ql5.RequestHandlerProtocol={}));ql5.SMITHY_CONTEXT_KEY=ec5;ql5.getDefaultClientConfiguration=sc5;ql5.resolveDefaultRuntimeConfig=tc5});var qU7=m((jl5)=>{var Yl5=aF7(),$l5=(q)=>{return{setHttpHandler(K){q.httpHandler=K},httpHandler(){return q.httpHandler},updateHttpClientConfig(K,_){q.httpHandler?.updateHttpClientConfig(K,_)},httpHandlerConfigs(){return q.httpHandler.httpHandlerConfigs()}}},Al5=(q)=>{return{httpHandler:q.httpHandler()}};class sF7{name;kind;values;constructor({name:q,kind:K=Yl5.FieldPosition.HEADER,values:_=[]}){this.name=q,this.kind=K,this.values=_}add(q){this.values.push(q)}set(q){this.values=q}remove(q){this.values=this.values.filter((K)=>K!==q)}toString(){return this.values.map((q)=>q.includes(",")||q.includes(" ")?`"${q}"`:q).join(", ")}get(){return this.values}}class tF7{entries={};encoding;constructor({fields:q=[],encoding:K="utf-8"}){q.forEach(this.setField.bind(this)),this.encoding=K}setField(q){this.entries[q.name.toLowerCase()]=q}getField(q){return this.entries[q.toLowerCase()]}removeField(q){delete this.entries[q.toLowerCase()]}getByType(q){return Object.values(this.entries).filter((K)=>K.kind===q)}}class fw8{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(q){this.method=q.method||"GET",this.hostname=q.hostname||"localhost",this.port=q.port,this.query=q.query||{},this.headers=q.headers||{},this.body=q.body,this.protocol=q.protocol?q.protocol.slice(-1)!==":"?`${q.protocol}:`:q.protocol:"https:",this.path=q.path?q.path.charAt(0)!=="/"?`/${q.path}`:q.path:"/",this.username=q.username,this.password=q.password,this.fragment=q.fragment}static clone(q){let K=new fw8({...q,headers:{...q.headers}});if(K.query)K.query=Ol5(K.query);return K}static isInstance(q){if(!q)return!1;let K=q;return"method"in K&&"protocol"in K&&"hostname"in K&&"path"in K&&typeof K.query==="object"&&typeof K.headers==="object"}clone(){return fw8.clone(this)}}function Ol5(q){return Object.keys(q).reduce((K,_)=>{let z=q[_];return{...K,[_]:Array.isArray(z)?[...z]:z}},{})}class eF7{statusCode;reason;headers;body;constructor(q){this.statusCode=q.statusCode,this.reason=q.reason,this.headers=q.headers||{},this.body=q.body}static isInstance(q){if(!q)return!1;let K=q;return typeof K.statusCode==="number"&&typeof K.headers==="object"}}function wl5(q){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(q)}jl5.Field=sF7;jl5.Fields=tF7;jl5.HttpRequest=fw8;jl5.HttpResponse=eF7;jl5.getHttpHandlerExtensionConfiguration=$l5;jl5.isValidHostname=wl5;jl5.resolveHttpHandlerRuntimeConfig=Al5});var _U7=m((Gl5)=>{var KU7=(q)=>encodeURIComponent(q).replace(/[!'()*]/g,fl5),fl5=(q)=>`%${q.charCodeAt(0).toString(16).toUpperCase()}`,Zl5=(q)=>q.split("/").map(KU7).join("/");Gl5.escapeUri=KU7;Gl5.escapeUriPath=Zl5});var zU7=m((Vl5)=>{var A91=_U7();function kl5(q){let K=[];for(let _ of Object.keys(q).sort()){let z=q[_];if(_=A91.escapeUri(_),Array.isArray(z))for(let Y=0,$=z.length;Y<$;Y++)K.push(`${_}=${A91.escapeUri(z[Y])}`);else{let Y=_;if(z||typeof z==="string")Y+=`=${A91.escapeUri(z)}`;K.push(Y)}}return K.join("&")}Vl5.buildQueryString=kl5});var $V=m((ml5)=>{var OU7=qU7(),wU7=zU7(),Zw8=U6("http"),Gw8=U6("https"),jU7=U6("stream"),O91=U6("http2"),yl5=["ECONNRESET","EPIPE","ETIMEDOUT"],HU7=(q)=>{let K={};for(let _ of Object.keys(q)){let z=q[_];K[_]=Array.isArray(z)?z.join(","):z}return K},oT={setTimeout:(q,K)=>setTimeout(q,K),clearTimeout:(q)=>clearTimeout(q)},YU7=1000,El5=(q,K,_=0)=>{if(!_)return-1;let z=(Y)=>{let $=oT.setTimeout(()=>{q.destroy(),K(Object.assign(Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${_} ms.`),{name:"TimeoutError"}))},_-Y),A=(O)=>{if(O?.connecting)O.on("connect",()=>{oT.clearTimeout($)});else oT.clearTimeout($)};if(q.socket)A(q.socket);else q.on("socket",A)};if(_<2000)return z(0),0;return oT.setTimeout(z.bind(null,YU7),YU7)},Ll5=(q,K,_=0,z,Y)=>{if(_)return oT.setTimeout(()=>{let $=`@smithy/node-http-handler - [${z?"ERROR":"WARN"}] a request has exceeded the configured ${_} ms requestTimeout.`;if(z){let A=Object.assign(Error($),{name:"TimeoutError",code:"ETIMEDOUT"});q.destroy(A),K(A)}else $+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",Y?.warn?.($)},_);return-1},Rl5=3000,hl5=(q,{keepAlive:K,keepAliveMsecs:_},z=Rl5)=>{if(K!==!0)return-1;let Y=()=>{if(q.socket)q.socket.setKeepAlive(K,_||0);else q.on("socket",($)=>{$.setKeepAlive(K,_||0)})};if(z===0)return Y(),0;return oT.setTimeout(Y,z)},$U7=3000,Sl5=(q,K,_=0)=>{let z=(Y)=>{let $=_-Y,A=()=>{q.destroy(),K(Object.assign(Error(`@smithy/node-http-handler - the request socket timed out after ${_} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};if(q.socket)q.socket.setTimeout($,A),q.on("close",()=>q.socket?.removeListener("timeout",A));else q.setTimeout($,A)};if(0<_&&_<6000)return z(0),0;return oT.setTimeout(z.bind(null,_===0?0:$U7),$U7)},AU7=6000;async function JU7(q,K,_=AU7,z=!1){let Y=K.headers??{},$=Y.Expect||Y.expect,A=-1,O=!0;if(!z&&$==="100-continue")O=await Promise.race([new Promise((w)=>{A=Number(oT.setTimeout(()=>w(!0),Math.max(AU7,_)))}),new Promise((w)=>{q.on("continue",()=>{oT.clearTimeout(A),w(!0)}),q.on("response",()=>{oT.clearTimeout(A),w(!1)}),q.on("error",()=>{oT.clearTimeout(A),w(!1)})})]);if(O)Cl5(q,K.body)}function Cl5(q,K){if(K instanceof jU7.Readable){K.pipe(q);return}if(K){if(Buffer.isBuffer(K)||typeof K==="string"){q.end(K);return}let _=K;if(typeof _==="object"&&_.buffer&&typeof _.byteOffset==="number"&&typeof _.byteLength==="number"){q.end(Buffer.from(_.buffer,_.byteOffset,_.byteLength));return}q.end(Buffer.from(K));return}q.end()}var bl5=0;class Tw8{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(q){if(typeof q?.handle==="function")return q;return new Tw8(q)}static checkSocketUsage(q,K,_=console){let{sockets:z,requests:Y,maxSockets:$}=q;if(typeof $!=="number"||$===1/0)return K;let A=15000;if(Date.now()-A<K)return K;if(z&&Y)for(let O in z){let w=z[O]?.length??0,j=Y[O]?.length??0;if(w>=$&&j>=2*$)return _?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${w} and ${j} additional requests are enqueued.
243See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
244or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return K}constructor(q){this.configProvider=new Promise((K,_)=>{if(typeof q==="function")q().then((z)=>{K(this.resolveDefaultConfig(z))}).catch(_);else K(this.resolveDefaultConfig(q))})}resolveDefaultConfig(q){let{requestTimeout:K,connectionTimeout:_,socketTimeout:z,socketAcquisitionWarningTimeout:Y,httpAgent:$,httpsAgent:A,throwOnRequestTimeout:O}=q||{},w=!0,j=50;return{connectionTimeout:_,requestTimeout:K,socketTimeout:z,socketAcquisitionWarningTimeout:Y,throwOnRequestTimeout:O,httpAgent:(()=>{if($ instanceof Zw8.Agent||typeof $?.destroy==="function")return this.externalAgent=!0,$;return new Zw8.Agent({keepAlive:!0,maxSockets:50,...$})})(),httpsAgent:(()=>{if(A instanceof Gw8.Agent||typeof A?.destroy==="function")return this.externalAgent=!0,A;return new Gw8.Agent({keepAlive:!0,maxSockets:50,...A})})(),logger:console}}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(q,{abortSignal:K,requestTimeout:_}={}){if(!this.config)this.config=await this.configProvider;return new Promise((z,Y)=>{let $=this.config,A=void 0,O=[],w=async(E)=>{await A,O.forEach(oT.clearTimeout),z(E)},j=async(E)=>{await A,O.forEach(oT.clearTimeout),Y(E)};if(K?.aborted){let E=Error("Request aborted");E.name="AbortError",j(E);return}let H=q.protocol==="https:",J=q.headers??{},M=(J.Expect??J.expect)==="100-continue",X=H?$.httpsAgent:$.httpAgent;if(M&&!this.externalAgent)X=new(H?Gw8.Agent:Zw8.Agent)({keepAlive:!1,maxSockets:1/0});O.push(oT.setTimeout(()=>{this.socketWarningTimestamp=Tw8.checkSocketUsage(X,this.socketWarningTimestamp,$.logger)},$.socketAcquisitionWarningTimeout??($.requestTimeout??2000)+($.connectionTimeout??1000)));let P=wU7.buildQueryString(q.query||{}),W=void 0;if(q.username!=null||q.password!=null){let E=q.username??"",S=q.password??"";W=`${E}:${S}`}let D=q.path;if(P)D+=`?${P}`;if(q.fragment)D+=`#${q.fragment}`;let f=q.hostname??"";if(f[0]==="["&&f.endsWith("]"))f=q.hostname.slice(1,-1);else f=q.hostname;let G={headers:q.headers,host:f,method:q.method,path:D,port:q.port,agent:X,auth:W},T=(H?Gw8.request:Zw8.request)(G,(E)=>{let S=new OU7.HttpResponse({statusCode:E.statusCode||-1,reason:E.statusMessage,headers:HU7(E.headers),body:E});w({response:S})});if(T.on("error",(E)=>{if(yl5.includes(E.code))j(Object.assign(E,{name:"TimeoutError"}));else j(E)}),K){let E=()=>{T.destroy();let S=Error("Request aborted");S.name="AbortError",j(S)};if(typeof K.addEventListener==="function"){let S=K;S.addEventListener("abort",E,{once:!0}),T.once("close",()=>S.removeEventListener("abort",E))}else K.onabort=E}let v=_??$.requestTimeout;O.push(El5(T,j,$.connectionTimeout)),O.push(Ll5(T,j,v,$.throwOnRequestTimeout,$.logger??console)),O.push(Sl5(T,j,$.socketTimeout));let V=G.agent;if(typeof V==="object"&&"keepAlive"in V)O.push(hl5(T,{keepAlive:V.keepAlive,keepAliveMsecs:V.keepAliveMsecs}));A=JU7(T,q,v,this.externalAgent).catch((E)=>{return O.forEach(oT.clearTimeout),Y(E)})})}updateHttpClientConfig(q,K){this.config=void 0,this.configProvider=this.configProvider.then((_)=>{return{..._,[q]:K}})}httpHandlerConfigs(){return this.config??{}}}class MU7{sessions=[];constructor(q){this.sessions=q??[]}poll(){if(this.sessions.length>0)return this.sessions.shift()}offerLast(q){this.sessions.push(q)}contains(q){return this.sessions.includes(q)}remove(q){this.sessions=this.sessions.filter((K)=>K!==q)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}destroy(q){for(let K of this.sessions)if(K===q){if(!K.destroyed)K.destroy()}}}class XU7{constructor(q){if(this.config=q,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw RangeError("maxConcurrency must be greater than zero.")}config;sessionCache=new Map;lease(q,K){let _=this.getUrlString(q),z=this.sessionCache.get(_);if(z){let O=z.poll();if(O&&!this.config.disableConcurrency)return O}let Y=O91.connect(_);if(this.config.maxConcurrency)Y.settings({maxConcurrentStreams:this.config.maxConcurrency},(O)=>{if(O)throw Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+q.destination.toString())});Y.unref();let $=()=>{Y.destroy(),this.deleteSession(_,Y)};if(Y.on("goaway",$),Y.on("error",$),Y.on("frameError",$),Y.on("close",()=>this.deleteSession(_,Y)),K.requestTimeout)Y.setTimeout(K.requestTimeout,$);let A=this.sessionCache.get(_)||new MU7;return A.offerLast(Y),this.sessionCache.set(_,A),Y}deleteSession(q,K){let _=this.sessionCache.get(q);if(!_)return;if(!_.contains(K))return;_.remove(K),this.sessionCache.set(q,_)}release(q,K){let _=this.getUrlString(q);this.sessionCache.get(_)?.offerLast(K)}destroy(){for(let[q,K]of this.sessionCache){for(let _ of K){if(!_.destroyed)_.destroy();K.remove(_)}this.sessionCache.delete(q)}}setMaxConcurrentStreams(q){if(q&&q<=0)throw RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=q}setDisableConcurrentStreams(q){this.config.disableConcurrency=q}getUrlString(q){return q.destination.toString()}}class w91{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new XU7({});static create(q){if(typeof q?.handle==="function")return q;return new w91(q)}constructor(q){this.configProvider=new Promise((K,_)=>{if(typeof q==="function")q().then((z)=>{K(z||{})}).catch(_);else K(q||{})})}destroy(){this.connectionManager.destroy()}async handle(q,{abortSignal:K,requestTimeout:_}={}){if(!this.config){if(this.config=await this.configProvider,this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams||!1),this.config.maxConcurrentStreams)this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams)}let{requestTimeout:z,disableConcurrentStreams:Y}=this.config,$=_??z;return new Promise((A,O)=>{let w=!1,j=void 0,H=async(R)=>{await j,A(R)},J=async(R)=>{await j,O(R)};if(K?.aborted){w=!0;let R=Error("Request aborted");R.name="AbortError",J(R);return}let{hostname:M,method:X,port:P,protocol:W,query:D}=q,f="";if(q.username!=null||q.password!=null){let R=q.username??"",x=q.password??"";f=`${R}:${x}@`}let G=`${W}//${f}${M}${P?`:${P}`:""}`,Z={destination:new URL(G)},T=this.connectionManager.lease(Z,{requestTimeout:this.config?.sessionTimeout,disableConcurrentStreams:Y||!1}),v=(R)=>{if(Y)this.destroySession(T);w=!0,J(R)},V=wU7.buildQueryString(D||{}),E=q.path;if(V)E+=`?${V}`;if(q.fragment)E+=`#${q.fragment}`;let S=T.request({...q.headers,[O91.constants.HTTP2_HEADER_PATH]:E,[O91.constants.HTTP2_HEADER_METHOD]:X});if(T.ref(),S.on("response",(R)=>{let x=new OU7.HttpResponse({statusCode:R[":status"]||-1,headers:HU7(R),body:S});if(w=!0,H({response:x}),Y)T.close(),this.connectionManager.deleteSession(G,T)}),$)S.setTimeout($,()=>{S.close();let R=Error(`Stream timed out because of no activity for ${$} ms`);R.name="TimeoutError",v(R)});if(K){let R=()=>{S.close();let x=Error("Request aborted");x.name="AbortError",v(x)};if(typeof K.addEventListener==="function"){let x=K;x.addEventListener("abort",R,{once:!0}),S.once("close",()=>x.removeEventListener("abort",R))}else K.onabort=R}S.on("frameError",(R,x,I)=>{v(Error(`Frame type id ${R} in stream id ${I} has failed with code ${x}.`))}),S.on("error",v),S.on("aborted",()=>{v(Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${S.rstCode}.`))}),S.on("close",()=>{if(T.unref(),Y)T.destroy();if(!w)v(Error("Unexpected error: http2 request did not get a response"))}),j=JU7(S,q,$)})}updateHttpClientConfig(q,K){this.config=void 0,this.configProvider=this.configProvider.then((_)=>{return{..._,[q]:K}})}httpHandlerConfigs(){return this.config??{}}destroySession(q){if(!q.destroyed)q.destroy()}}class PU7 extends jU7.Writable{bufferedBytes=[];_write(q,K,_){this.bufferedBytes.push(q),_()}}var xl5=(q)=>{if(Il5(q))return ul5(q);return new Promise((K,_)=>{let z=new PU7;q.pipe(z),q.on("error",(Y)=>{z.end(),_(Y)}),z.on("error",_),z.on("finish",function(){let Y=new Uint8Array(Buffer.concat(this.bufferedBytes));K(Y)})})},Il5=(q)=>typeof ReadableStream==="function"&&q instanceof ReadableStream;async function ul5(q){let K=[],_=q.getReader(),z=!1,Y=0;while(!z){let{done:O,value:w}=await _.read();if(w)K.push(w),Y+=w.length;z=O}let $=new Uint8Array(Y),A=0;for(let O of K)$.set(O,A),A+=O.length;return $}ml5.DEFAULT_REQUEST_TIMEOUT=bl5;ml5.NodeHttp2Handler=w91;ml5.NodeHttpHandler=Tw8;ml5.streamCollector=xl5});var AV=m((ll5)=>{var j91={warningEmitted:!1},Ul5=(q)=>{if(q&&!j91.warningEmitted&&parseInt(q.substring(1,q.indexOf(".")))<18)j91.warningEmitted=!0,process.emitWarning(`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
245no longer support Node.js 16.x on January 6, 2025.
246
247To continue receiving updates to AWS services, bug fixes, and security

Callers

nothing calls this directly

Calls 11

getUrlStringMethod · 0.95
deleteSessionMethod · 0.95
setTimeoutMethod · 0.80
toStringMethod · 0.65
getMethod · 0.45
pollMethod · 0.45
connectMethod · 0.45
unrefMethod · 0.45
onMethod · 0.45
offerLastMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected