aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/agent-base
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
commit76cb9c2a39d477a64824a985ade40507e3bbade1 (patch)
tree41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/agent-base
parent819a39a21ac992b1393244a4c283bbb125208c69 (diff)
downloadneko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/agent-base')
-rw-r--r--vanilla/node_modules/agent-base/LICENSE22
-rw-r--r--vanilla/node_modules/agent-base/README.md69
-rw-r--r--vanilla/node_modules/agent-base/dist/helpers.d.ts15
-rw-r--r--vanilla/node_modules/agent-base/dist/helpers.d.ts.map1
-rw-r--r--vanilla/node_modules/agent-base/dist/helpers.js66
-rw-r--r--vanilla/node_modules/agent-base/dist/helpers.js.map1
-rw-r--r--vanilla/node_modules/agent-base/dist/index.d.ts41
-rw-r--r--vanilla/node_modules/agent-base/dist/index.d.ts.map1
-rw-r--r--vanilla/node_modules/agent-base/dist/index.js178
-rw-r--r--vanilla/node_modules/agent-base/dist/index.js.map1
-rw-r--r--vanilla/node_modules/agent-base/package.json46
11 files changed, 441 insertions, 0 deletions
diff --git a/vanilla/node_modules/agent-base/LICENSE b/vanilla/node_modules/agent-base/LICENSE
new file mode 100644
index 0000000..008728c
--- /dev/null
+++ b/vanilla/node_modules/agent-base/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/README.md b/vanilla/node_modules/agent-base/README.md
new file mode 100644
index 0000000..b8a86b9
--- /dev/null
+++ b/vanilla/node_modules/agent-base/README.md
@@ -0,0 +1,69 @@
+agent-base
+==========
+### Turn a function into an [`http.Agent`][http.Agent] instance
+
+This module is a thin wrapper around the base `http.Agent` class.
+
+It provides an abstract class that must define a `connect()` function,
+which is responsible for creating the underlying socket that the HTTP
+client requests will use.
+
+The `connect()` function may return an arbitrary `Duplex` stream, or
+another `http.Agent` instance to delegate the request to, and may be
+asynchronous (by defining an `async` function).
+
+Instances of this agent can be used with the `http` and `https`
+modules. To differentiate, the options parameter in the `connect()`
+function includes a `secureEndpoint` property, which can be checked
+to determine what type of socket should be returned.
+
+#### Some subclasses:
+
+Here are some more interesting uses of `agent-base`.
+Send a pull request to list yours!
+
+ * [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
+ * [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
+ * [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
+ * [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
+
+Example
+-------
+
+Here's a minimal example that creates a new `net.Socket` or `tls.Socket`
+based on the `secureEndpoint` property. This agent can be used with both
+the `http` and `https` modules.
+
+```ts
+import * as net from 'net';
+import * as tls from 'tls';
+import * as http from 'http';
+import { Agent } from 'agent-base';
+
+class MyAgent extends Agent {
+ connect(req, opts) {
+ // `secureEndpoint` is true when using the "https" module
+ if (opts.secureEndpoint) {
+ return tls.connect(opts);
+ } else {
+ return net.connect(opts);
+ }
+ }
+});
+
+// Keep alive enabled means that `connect()` will only be
+// invoked when a new connection needs to be created
+const agent = new MyAgent({ keepAlive: true });
+
+// Pass the `agent` option when creating the HTTP request
+http.get('http://nodejs.org/api/', { agent }, (res) => {
+ console.log('"response" event!', res.headers);
+ res.pipe(process.stdout);
+});
+```
+
+[http-proxy-agent]: ../http-proxy-agent
+[https-proxy-agent]: ../https-proxy-agent
+[pac-proxy-agent]: ../pac-proxy-agent
+[socks-proxy-agent]: ../socks-proxy-agent
+[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
diff --git a/vanilla/node_modules/agent-base/dist/helpers.d.ts b/vanilla/node_modules/agent-base/dist/helpers.d.ts
new file mode 100644
index 0000000..b468f23
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/helpers.d.ts
@@ -0,0 +1,15 @@
+/// <reference types="node" />
+/// <reference types="node" />
+/// <reference types="node" />
+/// <reference types="node" />
+/// <reference types="node" />
+import * as http from 'http';
+import * as https from 'https';
+import type { Readable } from 'stream';
+export type ThenableRequest = http.ClientRequest & {
+ then: Promise<http.IncomingMessage>['then'];
+};
+export declare function toBuffer(stream: Readable): Promise<Buffer>;
+export declare function json(stream: Readable): Promise<any>;
+export declare function req(url: string | URL, opts?: https.RequestOptions): ThenableRequest;
+//# sourceMappingURL=helpers.d.ts.map \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/helpers.d.ts.map b/vanilla/node_modules/agent-base/dist/helpers.d.ts.map
new file mode 100644
index 0000000..9479c9a
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/helpers.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,GAAG;IAClD,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhE;AAGD,wBAAsB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAUzD;AAED,wBAAgB,GAAG,CAClB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,GAAE,KAAK,CAAC,cAAmB,GAC7B,eAAe,CAcjB"} \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/helpers.js b/vanilla/node_modules/agent-base/dist/helpers.js
new file mode 100644
index 0000000..ef3f920
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/helpers.js
@@ -0,0 +1,66 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.req = exports.json = exports.toBuffer = void 0;
+const http = __importStar(require("http"));
+const https = __importStar(require("https"));
+async function toBuffer(stream) {
+ let length = 0;
+ const chunks = [];
+ for await (const chunk of stream) {
+ length += chunk.length;
+ chunks.push(chunk);
+ }
+ return Buffer.concat(chunks, length);
+}
+exports.toBuffer = toBuffer;
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+async function json(stream) {
+ const buf = await toBuffer(stream);
+ const str = buf.toString('utf8');
+ try {
+ return JSON.parse(str);
+ }
+ catch (_err) {
+ const err = _err;
+ err.message += ` (input: ${str})`;
+ throw err;
+ }
+}
+exports.json = json;
+function req(url, opts = {}) {
+ const href = typeof url === 'string' ? url : url.href;
+ const req = (href.startsWith('https:') ? https : http).request(url, opts);
+ const promise = new Promise((resolve, reject) => {
+ req
+ .once('response', resolve)
+ .once('error', reject)
+ .end();
+ });
+ req.then = promise.then.bind(promise);
+ return req;
+}
+exports.req = req;
+//# sourceMappingURL=helpers.js.map \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/helpers.js.map b/vanilla/node_modules/agent-base/dist/helpers.js.map
new file mode 100644
index 0000000..19df537
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/helpers.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,6CAA+B;AAOxB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C;aACzB,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aACrB,GAAG,EAAqB,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACZ,CAAC;AAjBD,kBAiBC"} \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/index.d.ts b/vanilla/node_modules/agent-base/dist/index.d.ts
new file mode 100644
index 0000000..3660ea7
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/index.d.ts
@@ -0,0 +1,41 @@
+/// <reference types="node" />
+/// <reference types="node" />
+/// <reference types="node" />
+/// <reference types="node" />
+import * as net from 'net';
+import * as tls from 'tls';
+import * as http from 'http';
+import type { Duplex } from 'stream';
+export * from './helpers';
+interface HttpConnectOpts extends net.TcpNetConnectOpts {
+ secureEndpoint: false;
+ protocol?: string;
+}
+interface HttpsConnectOpts extends tls.ConnectionOptions {
+ secureEndpoint: true;
+ protocol?: string;
+ port: number;
+}
+export type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
+declare const INTERNAL: unique symbol;
+export declare abstract class Agent extends http.Agent {
+ private [INTERNAL];
+ options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
+ keepAlive: boolean;
+ constructor(opts?: http.AgentOptions);
+ abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
+ /**
+ * Determine whether this is an `http` or `https` request.
+ */
+ isSecureEndpoint(options?: AgentConnectOpts): boolean;
+ private incrementSockets;
+ private decrementSockets;
+ getName(options?: AgentConnectOpts): string;
+ createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
+ createConnection(): Duplex;
+ get defaultPort(): number;
+ set defaultPort(v: number);
+ get protocol(): string;
+ set protocol(v: string);
+}
+//# sourceMappingURL=index.d.ts.map \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/index.d.ts.map b/vanilla/node_modules/agent-base/dist/index.d.ts.map
new file mode 100644
index 0000000..c0f91ab
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/index.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,cAAc,WAAW,CAAC;AAE1B,UAAU,eAAgB,SAAQ,GAAG,CAAC,iBAAiB;IACtD,cAAc,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IACvD,cAAc,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAElE,QAAA,MAAM,QAAQ,eAAmC,CAAC;AAQlD,8BAAsB,KAAM,SAAQ,IAAI,CAAC,KAAK;IAC7C,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAgB;IAGlC,OAAO,EAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACjE,SAAS,EAAG,OAAO,CAAC;gBAER,IAAI,CAAC,EAAE,IAAI,CAAC,YAAY;IAKpC,QAAQ,CAAC,OAAO,CACf,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK;IAErD;;OAEG;IACH,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO;IAqCrD,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM;IAU3C,YAAY,CACX,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,OAAO,EAAE,gBAAgB,EACzB,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI;IAgC5C,gBAAgB,IAAI,MAAM;IAW1B,IAAI,WAAW,IAAI,MAAM,CAKxB;IAED,IAAI,WAAW,CAAC,CAAC,EAAE,MAAM,EAIxB;IAED,IAAI,QAAQ,IAAI,MAAM,CAKrB;IAED,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAIrB;CACD"} \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/index.js b/vanilla/node_modules/agent-base/dist/index.js
new file mode 100644
index 0000000..57ac852
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/index.js
@@ -0,0 +1,178 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __exportStar = (this && this.__exportStar) || function(m, exports) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Agent = void 0;
+const net = __importStar(require("net"));
+const http = __importStar(require("http"));
+const https_1 = require("https");
+__exportStar(require("./helpers"), exports);
+const INTERNAL = Symbol('AgentBaseInternalState');
+class Agent extends http.Agent {
+ constructor(opts) {
+ super(opts);
+ this[INTERNAL] = {};
+ }
+ /**
+ * Determine whether this is an `http` or `https` request.
+ */
+ isSecureEndpoint(options) {
+ if (options) {
+ // First check the `secureEndpoint` property explicitly, since this
+ // means that a parent `Agent` is "passing through" to this instance.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ if (typeof options.secureEndpoint === 'boolean') {
+ return options.secureEndpoint;
+ }
+ // If no explicit `secure` endpoint, check if `protocol` property is
+ // set. This will usually be the case since using a full string URL
+ // or `URL` instance should be the most common usage.
+ if (typeof options.protocol === 'string') {
+ return options.protocol === 'https:';
+ }
+ }
+ // Finally, if no `protocol` property was set, then fall back to
+ // checking the stack trace of the current call stack, and try to
+ // detect the "https" module.
+ const { stack } = new Error();
+ if (typeof stack !== 'string')
+ return false;
+ return stack
+ .split('\n')
+ .some((l) => l.indexOf('(https.js:') !== -1 ||
+ l.indexOf('node:https:') !== -1);
+ }
+ // In order to support async signatures in `connect()` and Node's native
+ // connection pooling in `http.Agent`, the array of sockets for each origin
+ // has to be updated synchronously. This is so the length of the array is
+ // accurate when `addRequest()` is next called. We achieve this by creating a
+ // fake socket and adding it to `sockets[origin]` and incrementing
+ // `totalSocketCount`.
+ incrementSockets(name) {
+ // If `maxSockets` and `maxTotalSockets` are both Infinity then there is no
+ // need to create a fake socket because Node.js native connection pooling
+ // will never be invoked.
+ if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
+ return null;
+ }
+ // All instances of `sockets` are expected TypeScript errors. The
+ // alternative is to add it as a private property of this class but that
+ // will break TypeScript subclassing.
+ if (!this.sockets[name]) {
+ // @ts-expect-error `sockets` is readonly in `@types/node`
+ this.sockets[name] = [];
+ }
+ const fakeSocket = new net.Socket({ writable: false });
+ this.sockets[name].push(fakeSocket);
+ // @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
+ this.totalSocketCount++;
+ return fakeSocket;
+ }
+ decrementSockets(name, socket) {
+ if (!this.sockets[name] || socket === null) {
+ return;
+ }
+ const sockets = this.sockets[name];
+ const index = sockets.indexOf(socket);
+ if (index !== -1) {
+ sockets.splice(index, 1);
+ // @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
+ this.totalSocketCount--;
+ if (sockets.length === 0) {
+ // @ts-expect-error `sockets` is readonly in `@types/node`
+ delete this.sockets[name];
+ }
+ }
+ }
+ // In order to properly update the socket pool, we need to call `getName()` on
+ // the core `https.Agent` if it is a secureEndpoint.
+ getName(options) {
+ const secureEndpoint = this.isSecureEndpoint(options);
+ if (secureEndpoint) {
+ // @ts-expect-error `getName()` isn't defined in `@types/node`
+ return https_1.Agent.prototype.getName.call(this, options);
+ }
+ // @ts-expect-error `getName()` isn't defined in `@types/node`
+ return super.getName(options);
+ }
+ createSocket(req, options, cb) {
+ const connectOpts = {
+ ...options,
+ secureEndpoint: this.isSecureEndpoint(options),
+ };
+ const name = this.getName(connectOpts);
+ const fakeSocket = this.incrementSockets(name);
+ Promise.resolve()
+ .then(() => this.connect(req, connectOpts))
+ .then((socket) => {
+ this.decrementSockets(name, fakeSocket);
+ if (socket instanceof http.Agent) {
+ try {
+ // @ts-expect-error `addRequest()` isn't defined in `@types/node`
+ return socket.addRequest(req, connectOpts);
+ }
+ catch (err) {
+ return cb(err);
+ }
+ }
+ this[INTERNAL].currentSocket = socket;
+ // @ts-expect-error `createSocket()` isn't defined in `@types/node`
+ super.createSocket(req, options, cb);
+ }, (err) => {
+ this.decrementSockets(name, fakeSocket);
+ cb(err);
+ });
+ }
+ createConnection() {
+ const socket = this[INTERNAL].currentSocket;
+ this[INTERNAL].currentSocket = undefined;
+ if (!socket) {
+ throw new Error('No socket was returned in the `connect()` function');
+ }
+ return socket;
+ }
+ get defaultPort() {
+ return (this[INTERNAL].defaultPort ??
+ (this.protocol === 'https:' ? 443 : 80));
+ }
+ set defaultPort(v) {
+ if (this[INTERNAL]) {
+ this[INTERNAL].defaultPort = v;
+ }
+ }
+ get protocol() {
+ return (this[INTERNAL].protocol ??
+ (this.isSecureEndpoint() ? 'https:' : 'http:'));
+ }
+ set protocol(v) {
+ if (this[INTERNAL]) {
+ this[INTERNAL].protocol = v;
+ }
+ }
+}
+exports.Agent = Agent;
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/dist/index.js.map b/vanilla/node_modules/agent-base/dist/index.js.map
new file mode 100644
index 0000000..5a0d2ad
--- /dev/null
+++ b/vanilla/node_modules/agent-base/dist/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAE3B,2CAA6B;AAC7B,iCAA4C;AAG5C,4CAA0B;AAe1B,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAQlD,MAAsB,KAAM,SAAQ,IAAI,CAAC,KAAK;IAO7C,YAAY,IAAwB;QACnC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;IAOD;;OAEG;IACH,gBAAgB,CAAC,OAA0B;QAC1C,IAAI,OAAO,EAAE;YACZ,mEAAmE;YACnE,qEAAqE;YACrE,8DAA8D;YAC9D,IAAI,OAAQ,OAAe,CAAC,cAAc,KAAK,SAAS,EAAE;gBACzD,OAAO,OAAO,CAAC,cAAc,CAAC;aAC9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AAC,CACvC,CAAC;IACH,CAAC;IAED,IAAI,WAAW,CAAC,CAAS;QACxB,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC;SAC/B;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,CACN,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ;YACvB,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAC9C,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,CAAS;QACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC;SAC5B;IACF,CAAC;CACD;AAlLD,sBAkLC"} \ No newline at end of file
diff --git a/vanilla/node_modules/agent-base/package.json b/vanilla/node_modules/agent-base/package.json
new file mode 100644
index 0000000..1b4964a
--- /dev/null
+++ b/vanilla/node_modules/agent-base/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "agent-base",
+ "version": "7.1.4",
+ "description": "Turn a function into an `http.Agent` instance",
+ "main": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "dist"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/TooTallNate/proxy-agents.git",
+ "directory": "packages/agent-base"
+ },
+ "keywords": [
+ "http",
+ "agent",
+ "base",
+ "barebones",
+ "https"
+ ],
+ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
+ "license": "MIT",
+ "devDependencies": {
+ "@types/debug": "^4.1.7",
+ "@types/jest": "^29.5.1",
+ "@types/node": "^14.18.45",
+ "@types/semver": "^7.3.13",
+ "@types/ws": "^6.0.4",
+ "async-listen": "^3.0.0",
+ "jest": "^29.5.0",
+ "ts-jest": "^29.1.0",
+ "typescript": "^5.0.4",
+ "ws": "^5.2.4",
+ "tsconfig": "0.0.0"
+ },
+ "engines": {
+ "node": ">= 14"
+ },
+ "scripts": {
+ "build": "tsc",
+ "test": "jest --env node --verbose --bail",
+ "lint": "eslint . --ext .ts",
+ "pack": "node ../../scripts/pack.mjs"
+ }
+} \ No newline at end of file