You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
7.2 KiB
JavaScript

9 months ago
(()=>{"use strict";var t={862:(t,e)=>{Object.defineProperty(e,"__esModule",{value:true});function once(t,e,{signal:o}={}){return new Promise(((r,n)=>{function cleanup(){o===null||o===void 0?void 0:o.removeEventListener("abort",cleanup);t.removeListener(e,onEvent);t.removeListener("error",onError)}function onEvent(...t){cleanup();r(t)}function onError(t){cleanup();n(t)}o===null||o===void 0?void 0:o.addEventListener("abort",cleanup);t.on(e,onEvent);t.on("error",onError)}))}e["default"]=once},448:function(t,e,o){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const n=o(361);const i=r(o(937));const s=r(o(457));const u=i.default("agent-base");function isAgent(t){return Boolean(t)&&typeof t.addRequest==="function"}function isSecureEndpoint(){const{stack:t}=new Error;if(typeof t!=="string")return false;return t.split("\n").some((t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1))}function createAgent(t,e){return new createAgent.Agent(t,e)}(function(t){class Agent extends n.EventEmitter{constructor(t,e){super();let o=e;if(typeof t==="function"){this.callback=t}else if(t){o=t}this.timeout=null;if(o&&typeof o.timeout==="number"){this.timeout=o.timeout}this.maxFreeSockets=1;this.maxSockets=1;this.maxTotalSockets=Infinity;this.sockets={};this.freeSockets={};this.requests={};this.options={}}get defaultPort(){if(typeof this.explicitDefaultPort==="number"){return this.explicitDefaultPort}return isSecureEndpoint()?443:80}set defaultPort(t){this.explicitDefaultPort=t}get protocol(){if(typeof this.explicitProtocol==="string"){return this.explicitProtocol}return isSecureEndpoint()?"https:":"http:"}set protocol(t){this.explicitProtocol=t}callback(t,e,o){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(t,e){const o=Object.assign({},e);if(typeof o.secureEndpoint!=="boolean"){o.secureEndpoint=isSecureEndpoint()}if(o.host==null){o.host="localhost"}if(o.port==null){o.port=o.secureEndpoint?443:80}if(o.protocol==null){o.protocol=o.secureEndpoint?"https:":"http:"}if(o.host&&o.path){delete o.path}delete o.agent;delete o.hostname;delete o._defaultAgent;delete o.defaultPort;delete o.createConnection;t._last=true;t.shouldKeepAlive=false;let r=false;let n=null;const i=o.timeout||this.timeout;const onerror=e=>{if(t._hadError)return;t.emit("error",e);t._hadError=true};const ontimeout=()=>{n=null;r=true;const t=new Error(`A "socket" was not created for HTTP request before ${i}ms`);t.code="ETIMEOUT";onerror(t)};const callbackError=t=>{if(r)return;if(n!==null){clearTimeout(n);n=null}onerror(t)};const onsocket=e=>{if(r)return;if(n!=null){clearTimeout(n);n=null}if(isAgent(e)){u("Callback returned another Agent instance %o",e.constructor.name);e.addRequest(t,o);return}if(e){e.once("free",(()=>{this.freeSocket(e,o)}));t.onSocket(e);return}const i=new Error(`no Duplex stream was returned to agent-base for \`${t.method} ${t.path}\``);onerror(i)};if(typeof this.callback!=="function"){onerror(new Error("`callback` is not defined"));return}if(!this.promisifiedCallback){if(this.callback.length>=3){u("Converting legacy callback function to promise");this.promisifiedCallback=s.default(this.callback)}else{this.promisifiedCallback=this.callback}}if(typeof i==="number"&&i>0){n=setTimeout(ontimeout,i)}if("port"in o&&typeof o.port!=="number"){o.port=Number(o.port)}try{u("Resolving socket for %o request: %o",o.protocol,`${t.method} ${t.path}`);Promise.resolve(this.promisifiedCallback(t,o)).then(onsocket,callbackError)}catch(t){Promise.reject(t).catch(callbackError)}}freeSocket(t,e){u("Freeing socket %o %o",t.constructor.name,e);t.destroy()}destroy(){u("Destroying agent %o",this.constructor.name)}}t.Agent=Agent;t.prototype=t.Agent.prototype})(createAgent||(createAgent={}));t.exports=createAgent},457:(t,e)=>{Object.defineProperty(e,"__esModule",{value:true});function promisify(t){return function(e,o){return new Promise(((r,n)=>{t.call(this,e,o,((t,e)=>{if(t){n(t)}else{r(e)}}))}))}}e["default"]=promisify},386:function(t,e,o){var r=this&&this.__awaiter||function(