@stryke/http 0.12.3 → 0.12.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +385 -0
- package/README.md +18 -10
- package/dist/agent-Cc4PYJ-j.d.cts +40 -0
- package/dist/agent-Cc4PYJ-j.d.cts.map +1 -0
- package/dist/agent-DKevd8Ll.cjs +2 -0
- package/dist/agent-DXIpD4O5.d.mts +40 -0
- package/dist/agent-DXIpD4O5.d.mts.map +1 -0
- package/dist/agent-DrFvt4od.mjs +3 -0
- package/dist/agent-DrFvt4od.mjs.map +1 -0
- package/dist/agent.cjs +1 -84
- package/dist/agent.d.cts +2 -0
- package/dist/agent.d.mts +2 -0
- package/dist/agent.mjs +1 -2
- package/dist/chunk-Bmb41Sf3.cjs +1 -0
- package/dist/fetch-BYPFJG9Y.d.cts +24 -0
- package/dist/fetch-BYPFJG9Y.d.cts.map +1 -0
- package/dist/fetch-D3masEhH.d.mts +24 -0
- package/dist/fetch-D3masEhH.d.mts.map +1 -0
- package/dist/fetch-DXVSCX2B.cjs +1 -0
- package/dist/fetch-DgPaAZTB.mjs +2 -0
- package/dist/fetch-DgPaAZTB.mjs.map +1 -0
- package/dist/fetch.cjs +1 -24
- package/dist/fetch.d.cts +2 -0
- package/dist/fetch.d.mts +2 -0
- package/dist/fetch.mjs +1 -1
- package/dist/{format-data-uri.d.ts → format-data-uri-B-rw3THu.d.cts} +14 -10
- package/dist/format-data-uri-B-rw3THu.d.cts.map +1 -0
- package/dist/format-data-uri-C59EgrXn.cjs +1 -0
- package/dist/format-data-uri-D864kwXt.d.mts +50 -0
- package/dist/format-data-uri-D864kwXt.d.mts.map +1 -0
- package/dist/format-data-uri-WSwfftd0.mjs +2 -0
- package/dist/format-data-uri-WSwfftd0.mjs.map +1 -0
- package/dist/format-data-uri.cjs +1 -30
- package/dist/format-data-uri.d.cts +2 -0
- package/dist/format-data-uri.d.mts +2 -0
- package/dist/format-data-uri.mjs +1 -1
- package/dist/{get-free-port.d.ts → get-free-port-Bf-x1nt8.d.cts} +5 -1
- package/dist/get-free-port-Bf-x1nt8.d.cts.map +1 -0
- package/dist/get-free-port-BwvXPXFs.d.mts +10 -0
- package/dist/get-free-port-BwvXPXFs.d.mts.map +1 -0
- package/dist/get-free-port-D9hjek4b.cjs +1 -0
- package/dist/get-free-port-DvWNGhhy.mjs +2 -0
- package/dist/get-free-port-DvWNGhhy.mjs.map +1 -0
- package/dist/get-free-port.cjs +1 -16
- package/dist/get-free-port.d.cts +2 -0
- package/dist/get-free-port.d.mts +2 -0
- package/dist/get-free-port.mjs +1 -1
- package/dist/http-proxy-CJqbqeZN.cjs +3 -0
- package/dist/http-proxy-ChUYEQ71.mjs +4 -0
- package/dist/http-proxy-ChUYEQ71.mjs.map +1 -0
- package/dist/http-proxy-CzvOBKWd.d.cts +40 -0
- package/dist/http-proxy-CzvOBKWd.d.cts.map +1 -0
- package/dist/http-proxy-DuPPyvFw.d.mts +40 -0
- package/dist/http-proxy-DuPPyvFw.d.mts.map +1 -0
- package/dist/http-proxy.cjs +1 -71
- package/dist/http-proxy.d.cts +2 -0
- package/dist/http-proxy.d.mts +2 -0
- package/dist/http-proxy.mjs +1 -3
- package/dist/https-proxy-B8w-jm17.d.cts +43 -0
- package/dist/https-proxy-B8w-jm17.d.cts.map +1 -0
- package/dist/https-proxy-f4-C_EL8.d.mts +43 -0
- package/dist/https-proxy-f4-C_EL8.d.mts.map +1 -0
- package/dist/https-proxy-k0GW_xX8.cjs +1 -0
- package/dist/https-proxy-rNc_8MiC.mjs +2 -0
- package/dist/https-proxy-rNc_8MiC.mjs.map +1 -0
- package/dist/https-proxy.cjs +1 -88
- package/dist/https-proxy.d.cts +2 -0
- package/dist/https-proxy.d.mts +2 -0
- package/dist/https-proxy.mjs +1 -4
- package/dist/index.cjs +1 -93
- package/dist/index.d.cts +9 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +1 -1
- package/dist/parse-response-BRlQF_8K.cjs +4 -0
- package/dist/parse-response-CGkjN9j0.mjs +5 -0
- package/dist/parse-response-CGkjN9j0.mjs.map +1 -0
- package/dist/parse-response-CS657Hki.d.cts +23 -0
- package/dist/parse-response-CS657Hki.d.cts.map +1 -0
- package/dist/parse-response-ujHVHmwG.d.mts +23 -0
- package/dist/parse-response-ujHVHmwG.d.mts.map +1 -0
- package/dist/parse-response.cjs +1 -63
- package/dist/parse-response.d.cts +2 -0
- package/dist/parse-response.d.mts +2 -0
- package/dist/parse-response.mjs +1 -4
- package/dist/proxy-agent-BrxQeFy2.d.mts +13 -0
- package/dist/proxy-agent-BrxQeFy2.d.mts.map +1 -0
- package/dist/proxy-agent-CnWrJ59l.d.cts +13 -0
- package/dist/proxy-agent-CnWrJ59l.d.cts.map +1 -0
- package/dist/proxy-agent-DMsOloiQ.cjs +1 -0
- package/dist/proxy-agent-uGI03t_I.mjs +2 -0
- package/dist/proxy-agent-uGI03t_I.mjs.map +1 -0
- package/dist/proxy-agent.cjs +1 -14
- package/dist/proxy-agent.d.cts +2 -0
- package/dist/proxy-agent.d.mts +2 -0
- package/dist/proxy-agent.mjs +1 -1
- package/package.json +38 -165
- package/dist/agent.d.ts +0 -36
- package/dist/fetch.d.ts +0 -18
- package/dist/http-proxy.d.ts +0 -38
- package/dist/https-proxy.d.ts +0 -42
- package/dist/index.d.ts +0 -8
- package/dist/parse-response.d.ts +0 -18
- package/dist/proxy-agent.d.ts +0 -7
package/dist/agent.cjs
CHANGED
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Agent = void 0;
|
|
7
|
-
var _typeChecks = require("@stryke/type-checks");
|
|
8
|
-
var u = _interopRequireWildcard(require("node:http"));
|
|
9
|
-
var h = _interopRequireWildcard(require("node:net"));
|
|
10
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
-
const n = Symbol("Agent");
|
|
13
|
-
class Agent extends u.Agent {
|
|
14
|
-
[n];
|
|
15
|
-
options;
|
|
16
|
-
keepAlive;
|
|
17
|
-
constructor(t) {
|
|
18
|
-
super(t), this[n] = {};
|
|
19
|
-
}
|
|
20
|
-
isSecureEndpoint(t) {
|
|
21
|
-
if (t) {
|
|
22
|
-
if ((0, _typeChecks.isBoolean)(t.secureEndpoint)) return t.secureEndpoint;
|
|
23
|
-
if ((0, _typeChecks.isString)(t.protocol)) return t.protocol === "https:";
|
|
24
|
-
}
|
|
25
|
-
const {
|
|
26
|
-
stack: e
|
|
27
|
-
} = new Error(" ");
|
|
28
|
-
return (0, _typeChecks.isString)(e) ? e.split(`
|
|
29
|
-
`).some(r => r.includes("(https.js:") || r.includes("node:https:")) : !1;
|
|
30
|
-
}
|
|
31
|
-
incrementSockets(t) {
|
|
32
|
-
if (this.maxSockets === 1 / 0 && this.maxTotalSockets === 1 / 0) return null;
|
|
33
|
-
this.sockets[t] ??= [];
|
|
34
|
-
const e = new h.Socket({
|
|
35
|
-
writable: !1
|
|
36
|
-
});
|
|
37
|
-
return this.sockets[t].push(e), this.totalSocketCount++, e;
|
|
38
|
-
}
|
|
39
|
-
decrementSockets(t, e) {
|
|
40
|
-
if (!this.sockets[t] || e === null) return;
|
|
41
|
-
const r = this.sockets[t],
|
|
42
|
-
o = r.indexOf(e);
|
|
43
|
-
o !== -1 && (r.splice(o, 1), this.totalSocketCount--, r.length === 0 && delete this.sockets[t]);
|
|
44
|
-
}
|
|
45
|
-
getName(t) {
|
|
46
|
-
return this.isSecureEndpoint(t) ? HttpsAgent.prototype.getName.call(this, t) : super.getName(t);
|
|
47
|
-
}
|
|
48
|
-
createSocket(t, e, r) {
|
|
49
|
-
const o = {
|
|
50
|
-
...e,
|
|
51
|
-
secureEndpoint: this.isSecureEndpoint(e)
|
|
52
|
-
},
|
|
53
|
-
c = this.getName(o),
|
|
54
|
-
i = this.incrementSockets(c);
|
|
55
|
-
Promise.resolve().then(async () => this.connect(t, o)).then(s => {
|
|
56
|
-
if (this.decrementSockets(c, i), s instanceof u.Agent) try {
|
|
57
|
-
return s.addRequest(t, o);
|
|
58
|
-
} catch (l) {
|
|
59
|
-
return r(l);
|
|
60
|
-
}
|
|
61
|
-
this[n].currentSocket = s, super.createSocket(t, e, r);
|
|
62
|
-
}, s => {
|
|
63
|
-
this.decrementSockets(c, i), r(s);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
createConnection() {
|
|
67
|
-
const t = this[n].currentSocket;
|
|
68
|
-
if (this[n].currentSocket = void 0, !t) throw new Error("No socket was returned in the `connect()` function");
|
|
69
|
-
return t;
|
|
70
|
-
}
|
|
71
|
-
get defaultPort() {
|
|
72
|
-
return this[n].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
|
|
73
|
-
}
|
|
74
|
-
set defaultPort(t) {
|
|
75
|
-
this[n] && (this[n].defaultPort = t);
|
|
76
|
-
}
|
|
77
|
-
get protocol() {
|
|
78
|
-
return this[n].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
|
|
79
|
-
}
|
|
80
|
-
set protocol(t) {
|
|
81
|
-
this[n] && (this[n].protocol = t);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.Agent = Agent;
|
|
1
|
+
const e=require(`./agent-DKevd8Ll.cjs`);exports.Agent=e.t;
|
package/dist/agent.d.cts
ADDED
package/dist/agent.d.mts
ADDED
package/dist/agent.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`).some(r=>r.includes("(https.js:")||r.includes("node:https:")):!1}incrementSockets(t){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[t]??=[];const e=new h.Socket({writable:!1});return this.sockets[t].push(e),this.totalSocketCount++,e}decrementSockets(t,e){if(!this.sockets[t]||e===null)return;const r=this.sockets[t],o=r.indexOf(e);o!==-1&&(r.splice(o,1),this.totalSocketCount--,r.length===0&&delete this.sockets[t])}getName(t){return this.isSecureEndpoint(t)?HttpsAgent.prototype.getName.call(this,t):super.getName(t)}createSocket(t,e,r){const o={...e,secureEndpoint:this.isSecureEndpoint(e)},c=this.getName(o),i=this.incrementSockets(c);Promise.resolve().then(async()=>this.connect(t,o)).then(s=>{if(this.decrementSockets(c,i),s instanceof u.Agent)try{return s.addRequest(t,o)}catch(l){return r(l)}this[n].currentSocket=s,super.createSocket(t,e,r)},s=>{this.decrementSockets(c,i),r(s)})}createConnection(){const t=this[n].currentSocket;if(this[n].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[n].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(t){this[n]&&(this[n].defaultPort=t)}get protocol(){return this[n].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[n]&&(this[n].protocol=t)}}
|
|
1
|
+
import{t as e}from"./agent-DrFvt4od.mjs";export{e as Agent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as undici0 from "undici";
|
|
2
|
+
import { RequestInfo } from "undici";
|
|
3
|
+
|
|
4
|
+
//#region src/fetch.d.ts
|
|
5
|
+
type FetchRequestOptions = RequestInit & {
|
|
6
|
+
/**
|
|
7
|
+
* Timeout in milliseconds
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue 5000
|
|
10
|
+
*/
|
|
11
|
+
timeout?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Fetches a resource from a URL.
|
|
15
|
+
*
|
|
16
|
+
* @param input - The URL to fetch.
|
|
17
|
+
* @param options - Additional fetch options.
|
|
18
|
+
* @returns The fetched response.
|
|
19
|
+
*/
|
|
20
|
+
declare function fetchRequest(input: RequestInfo, options?: FetchRequestOptions): Promise<undici0.Response>;
|
|
21
|
+
declare const fetch: typeof fetchRequest;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { fetch as n, fetchRequest as r, FetchRequestOptions as t };
|
|
24
|
+
//# sourceMappingURL=fetch-BYPFJG9Y.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-BYPFJG9Y.d.cts","names":[],"sources":["../src/fetch.ts"],"sourcesContent":[],"mappings":";;;;KAyBY,mBAAA,GAAsB;;;AAAlC;AAgBA;;EAEW,OAAA,CAAA,EAAA,MAAA;CAAwB;;;AAyBnC;;;;;iBA3BsB,YAAA,QACb,uBACE,sBAAwB,QAAA,OAAA,CAAA,QAAA;cAyBtB,cAAK"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as undici0 from "undici";
|
|
2
|
+
import { RequestInfo } from "undici";
|
|
3
|
+
|
|
4
|
+
//#region src/fetch.d.ts
|
|
5
|
+
type FetchRequestOptions = RequestInit & {
|
|
6
|
+
/**
|
|
7
|
+
* Timeout in milliseconds
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue 5000
|
|
10
|
+
*/
|
|
11
|
+
timeout?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Fetches a resource from a URL.
|
|
15
|
+
*
|
|
16
|
+
* @param input - The URL to fetch.
|
|
17
|
+
* @param options - Additional fetch options.
|
|
18
|
+
* @returns The fetched response.
|
|
19
|
+
*/
|
|
20
|
+
declare function fetchRequest(input: RequestInfo, options?: FetchRequestOptions): Promise<undici0.Response>;
|
|
21
|
+
declare const fetch$1: typeof fetchRequest;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { fetch$1 as n, fetchRequest as r, FetchRequestOptions as t };
|
|
24
|
+
//# sourceMappingURL=fetch-D3masEhH.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-D3masEhH.d.mts","names":[],"sources":["../src/fetch.ts"],"sourcesContent":[],"mappings":";;;;KAyBY,mBAAA,GAAsB;;;AAAlC;AAgBA;;EAEW,OAAA,CAAA,EAAA,MAAA;CAAwB;;;AAyBnC;;;;;iBA3BsB,YAAA,QACb,uBACE,sBAAwB,QAAA,OAAA,CAAA,QAAA;cAyBtB,gBAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./agent-DKevd8Ll.cjs`),n=require(`./proxy-agent-DMsOloiQ.cjs`);let r=require(`defu`),i=require(`undici`);function a(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}async function o(e,o={}){if(t.n(e)&&!a(e))throw Error(`Invalid URL format provided: ${e}`);let s=new AbortController;return setTimeout(()=>s.abort(),o.timeout??5e3),(0,i.fetch)(e,(0,r.defu)(o,{agent:n.t(),signal:s.signal,headers:{"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`}}))}const s=o;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./agent-DrFvt4od.mjs";import{t}from"./proxy-agent-uGI03t_I.mjs";import{defu as n}from"defu";import{fetch as r}from"undici";function i(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}async function a(a,o={}){if(e(a)&&!i(a))throw Error(`Invalid URL format provided: ${a}`);let s=new AbortController;return setTimeout(()=>s.abort(),o.timeout??5e3),r(a,n(o,{agent:t(),signal:s.signal,headers:{"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`}}))}const o=a;export{a as n,o as t};
|
|
2
|
+
//# sourceMappingURL=fetch-DgPaAZTB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-DgPaAZTB.mjs","names":["undiciFetch","fetch"],"sources":["../../url/src/helpers.ts","../src/fetch.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport function formatLocalePath(locale: string) {\n let result = locale;\n if (result.includes(\"_\")) {\n result = result.replace(/_/g, \"-\");\n }\n\n if (result.includes(\"-\")) {\n const parts = result.split(\"-\");\n if (parts.length > 1) {\n const lang = parts[0];\n const region = parts[1];\n if (lang && region) {\n result = `${lang}-${region}`;\n }\n }\n }\n\n return result.toLowerCase();\n}\n\n/**\n * Check if a string has a valid URL format.\n *\n * @param str - The string to check.\n * @returns `true` if the string is a valid URL, otherwise `false`.\n */\nexport function isValidURL(str: string): boolean {\n return /(?:https?:\\/\\/.)?(?:www\\.)?[-\\w@:%.+~#=]{2,256}\\.[a-z]{2,6}\\b[-\\w@:%+.~#?&/=]*/.test(\n str\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isValidURL } from \"@stryke/url/helpers\";\nimport { defu } from \"defu\";\nimport type { RequestInfo } from \"undici\";\nimport { fetch as undiciFetch } from \"undici\";\nimport { getProxyAgent } from \"./proxy-agent\";\n\nexport type FetchRequestOptions = RequestInit & {\n /**\n * Timeout in milliseconds\n *\n * @defaultValue 5000\n */\n timeout?: number;\n};\n\n/**\n * Fetches a resource from a URL.\n *\n * @param input - The URL to fetch.\n * @param options - Additional fetch options.\n * @returns The fetched response.\n */\nexport async function fetchRequest(\n input: RequestInfo,\n options: FetchRequestOptions = {}\n) {\n if (isSetString(input) && !isValidURL(input)) {\n throw new Error(`Invalid URL format provided: ${input}`);\n }\n\n const abort = new AbortController();\n setTimeout(() => abort.abort(), options.timeout ?? 5000);\n\n return undiciFetch(\n input,\n defu(options, {\n agent: getProxyAgent(),\n signal: abort.signal,\n headers: {\n // The file format is based off of the user agent, make sure woff2 files are fetched\n \"User-Agent\":\n \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) \" +\n \"AppleWebKit/537.36 (KHTML, like Gecko) \" +\n \"Chrome/104.0.0.0 Safari/537.36\"\n }\n })\n );\n}\n\nexport const fetch = fetchRequest;\n"],"mappings":"8IA4CA,SAAgB,EAAW,EAAsB,CAC/C,MAAO,iFAAiF,KACtF,EACD,CCNH,eAAsB,EACpB,EACA,EAA+B,EAAE,CACjC,CACA,GAAI,EAAY,EAAM,EAAI,CAAC,EAAW,EAAM,CAC1C,MAAU,MAAM,gCAAgC,IAAQ,CAG1D,IAAM,EAAQ,IAAI,gBAGlB,OAFA,eAAiB,EAAM,OAAO,CAAE,EAAQ,SAAW,IAAK,CAEjDA,EACL,EACA,EAAK,EAAS,CACZ,MAAO,GAAe,CACtB,OAAQ,EAAM,OACd,QAAS,CAEP,aACE,wHAGH,CACF,CAAC,CACH,CAGH,MAAaC,EAAQ"}
|
package/dist/fetch.cjs
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fetch = void 0;
|
|
7
|
-
exports.fetchRequest = fetchRequest;
|
|
8
|
-
var _isSetString = require("@stryke/type-checks/is-set-string");
|
|
9
|
-
var _helpers = require("@stryke/url/helpers");
|
|
10
|
-
var _defu = require("defu");
|
|
11
|
-
var _undici = require("undici");
|
|
12
|
-
var _proxyAgent = require("./proxy-agent.cjs");
|
|
13
|
-
async function fetchRequest(e, t = {}) {
|
|
14
|
-
if ((0, _isSetString.isSetString)(e) && !(0, _helpers.isValidURL)(e)) throw new Error(`Invalid URL format provided: ${e}`);
|
|
15
|
-
const o = new AbortController();
|
|
16
|
-
return setTimeout(() => o.abort(), t.timeout ?? 5e3), (0, _undici.fetch)(e, (0, _defu.defu)(t, {
|
|
17
|
-
agent: (0, _proxyAgent.getProxyAgent)(),
|
|
18
|
-
signal: o.signal,
|
|
19
|
-
headers: {
|
|
20
|
-
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
const fetch = exports.fetch = fetchRequest;
|
|
1
|
+
require(`./agent-DKevd8Ll.cjs`);const e=require(`./fetch-DXVSCX2B.cjs`);require(`./http-proxy-CJqbqeZN.cjs`),require(`./https-proxy-k0GW_xX8.cjs`),require(`./proxy-agent-DMsOloiQ.cjs`),exports.fetch=e.t,exports.fetchRequest=e.n;
|
package/dist/fetch.d.cts
ADDED
package/dist/fetch.d.mts
ADDED
package/dist/fetch.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./agent-DrFvt4od.mjs";import{n as e,t}from"./fetch-DgPaAZTB.mjs";import"./http-proxy-ChUYEQ71.mjs";import"./https-proxy-rNc_8MiC.mjs";import"./proxy-agent-uGI03t_I.mjs";export{t as fetch,e as fetchRequest};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/format-data-uri.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Creates a data URI from a string of data.
|
|
3
4
|
*
|
|
@@ -5,16 +6,16 @@
|
|
|
5
6
|
* @param mime - The MIME type of the data.
|
|
6
7
|
* @returns The data URI.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
declare const formatDataURI: (data: string, mime: string) => string;
|
|
10
|
+
interface ParsedDataURI {
|
|
11
|
+
type: string;
|
|
12
|
+
typeFull: string;
|
|
13
|
+
charset: string;
|
|
14
|
+
buffer: ArrayBuffer;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
interface BufferConversionsInterface {
|
|
17
|
+
base64ToArrayBuffer: (base64: string) => ArrayBuffer;
|
|
18
|
+
stringToBuffer: (str: string) => ArrayBuffer;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Returns a `Buffer` instance from the given data URI `uri`.
|
|
@@ -43,4 +44,7 @@ export interface BufferConversionsInterface {
|
|
|
43
44
|
* @returns An object containing the parsed data URI properties and the decoded data as a Buffer instance.
|
|
44
45
|
* @throws `TypeError` if `uri` is not a valid Data URI
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
declare const makeDataUriToBuffer: (convert: BufferConversionsInterface) => (uri: string | URL) => ParsedDataURI;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { makeDataUriToBuffer as i, ParsedDataURI as n, formatDataURI as r, BufferConversionsInterface as t };
|
|
50
|
+
//# sourceMappingURL=format-data-uri-B-rw3THu.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-data-uri-B-rw3THu.d.cts","names":[],"sources":["../src/format-data-uri.ts"],"sourcesContent":[],"mappings":";;AAyBA;AAGA;AAOA;AAgCA;;;AAEuB,cA5CV,aA4CU,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAsDpB,UA/Fc,aAAA,CA+Fd;;;;UA3FO;;UAGO,0BAAA;2CAC0B;mCACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BtB,+BACD,8CACK,QAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t)=>`data:${t};utf8,${encodeURIComponent(e)}`,t=e=>t=>{if(t=String(t),!/^data:/i.test(t))throw Error('`uri` does not appear to be a Data URI (must begin with "data:")');t=t.replace(/\r?\n/g,``);let n=t.indexOf(`,`);if(n===-1||n<=4)throw Error(`malformed data: URI`);let r=t.substring(5,n).split(`;`),i=``,a=!1,o=r[0]||`text/plain`,s=o;for(let e=1;e<r.length;e++)r[e]===`base64`?a=!0:r[e]&&(s+=`;${r[e]}`,r[e]?.indexOf(`charset=`)===0&&(i=r[e].substring(8)));!r[0]&&!i.length&&(s+=`;charset=US-ASCII`,i=`US-ASCII`);let c=unescape(t.substring(n+1)),l=a?e.base64ToArrayBuffer(c):e.stringToBuffer(c);return{type:o,typeFull:s,charset:i,buffer:l}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/format-data-uri.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a data URI from a string of data.
|
|
4
|
+
*
|
|
5
|
+
* @param data - The data to convert to a data URI.
|
|
6
|
+
* @param mime - The MIME type of the data.
|
|
7
|
+
* @returns The data URI.
|
|
8
|
+
*/
|
|
9
|
+
declare const formatDataURI: (data: string, mime: string) => string;
|
|
10
|
+
interface ParsedDataURI {
|
|
11
|
+
type: string;
|
|
12
|
+
typeFull: string;
|
|
13
|
+
charset: string;
|
|
14
|
+
buffer: ArrayBuffer;
|
|
15
|
+
}
|
|
16
|
+
interface BufferConversionsInterface {
|
|
17
|
+
base64ToArrayBuffer: (base64: string) => ArrayBuffer;
|
|
18
|
+
stringToBuffer: (str: string) => ArrayBuffer;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a `Buffer` instance from the given data URI `uri`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { makeDataUriToBuffer } from "@stryke/core/http";
|
|
26
|
+
*
|
|
27
|
+
* const dataUriToBuffer = makeDataUriToBuffer({
|
|
28
|
+
* base64ToArrayBuffer: (base64) => Buffer.from(base64, "base64").buffer,
|
|
29
|
+
* stringToBuffer: (str) => Buffer.from(str, "utf8")https://avatars.githubusercontent.com/u/99053093?s=64&v=4.buffer,
|
|
30
|
+
* });
|
|
31
|
+
* const parsed = dataUriToBuffer("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==");
|
|
32
|
+
* console.log(parsed);
|
|
33
|
+
* // {
|
|
34
|
+
* // type: 'text/plain',
|
|
35
|
+
* // typeFull: 'text/plain;base64',
|
|
36
|
+
* // charset: '',
|
|
37
|
+
* // buffer: ArrayBuffer { ... }
|
|
38
|
+
* // }
|
|
39
|
+
* console.log(Buffer.from(parsed.buffer).toString("utf8"));
|
|
40
|
+
* // Hello, World!
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param convert - Conversion functions
|
|
44
|
+
* @returns An object containing the parsed data URI properties and the decoded data as a Buffer instance.
|
|
45
|
+
* @throws `TypeError` if `uri` is not a valid Data URI
|
|
46
|
+
*/
|
|
47
|
+
declare const makeDataUriToBuffer: (convert: BufferConversionsInterface) => (uri: string | URL) => ParsedDataURI;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { makeDataUriToBuffer as i, ParsedDataURI as n, formatDataURI as r, BufferConversionsInterface as t };
|
|
50
|
+
//# sourceMappingURL=format-data-uri-D864kwXt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-data-uri-D864kwXt.d.mts","names":[],"sources":["../src/format-data-uri.ts"],"sourcesContent":[],"mappings":";;AAyBA;AAGA;AAOA;AAgCA;;;AAEuB,cA5CV,aA4CU,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAsDpB,UA/Fc,aAAA,CA+Fd;;;;UA3FO;;UAGO,0BAAA;2CAC0B;mCACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BtB,+BACD,8CACK,QAAM"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(e,t)=>`data:${t};utf8,${encodeURIComponent(e)}`,t=e=>t=>{if(t=String(t),!/^data:/i.test(t))throw Error('`uri` does not appear to be a Data URI (must begin with "data:")');t=t.replace(/\r?\n/g,``);let n=t.indexOf(`,`);if(n===-1||n<=4)throw Error(`malformed data: URI`);let r=t.substring(5,n).split(`;`),i=``,a=!1,o=r[0]||`text/plain`,s=o;for(let e=1;e<r.length;e++)r[e]===`base64`?a=!0:r[e]&&(s+=`;${r[e]}`,r[e]?.indexOf(`charset=`)===0&&(i=r[e].substring(8)));!r[0]&&!i.length&&(s+=`;charset=US-ASCII`,i=`US-ASCII`);let c=unescape(t.substring(n+1)),l=a?e.base64ToArrayBuffer(c):e.stringToBuffer(c);return{type:o,typeFull:s,charset:i,buffer:l}};export{t as n,e as t};
|
|
2
|
+
//# sourceMappingURL=format-data-uri-WSwfftd0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-data-uri-WSwfftd0.mjs","names":[],"sources":["../src/format-data-uri.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Creates a data URI from a string of data.\n *\n * @param data - The data to convert to a data URI.\n * @param mime - The MIME type of the data.\n * @returns The data URI.\n */\nexport const formatDataURI = (data: string, mime: string): string =>\n `data:${mime};utf8,${encodeURIComponent(data)}`;\n\nexport interface ParsedDataURI {\n type: string;\n typeFull: string;\n charset: string;\n buffer: ArrayBuffer;\n}\n\nexport interface BufferConversionsInterface {\n base64ToArrayBuffer: (base64: string) => ArrayBuffer;\n stringToBuffer: (str: string) => ArrayBuffer;\n}\n\n/**\n * Returns a `Buffer` instance from the given data URI `uri`.\n *\n * @example\n * ```typescript\n * import { makeDataUriToBuffer } from \"@stryke/core/http\";\n *\n * const dataUriToBuffer = makeDataUriToBuffer({\n * base64ToArrayBuffer: (base64) => Buffer.from(base64, \"base64\").buffer,\n * stringToBuffer: (str) => Buffer.from(str, \"utf8\")https://avatars.githubusercontent.com/u/99053093?s=64&v=4.buffer,\n * });\n * const parsed = dataUriToBuffer(\"data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==\");\n * console.log(parsed);\n * // {\n * // type: 'text/plain',\n * // typeFull: 'text/plain;base64',\n * // charset: '',\n * // buffer: ArrayBuffer { ... }\n * // }\n * console.log(Buffer.from(parsed.buffer).toString(\"utf8\"));\n * // Hello, World!\n * ```\n *\n * @param convert - Conversion functions\n * @returns An object containing the parsed data URI properties and the decoded data as a Buffer instance.\n * @throws `TypeError` if `uri` is not a valid Data URI\n */\nexport const makeDataUriToBuffer =\n (convert: BufferConversionsInterface) =>\n (uri: string | URL): ParsedDataURI => {\n uri = String(uri);\n\n if (!/^data:/i.test(uri)) {\n throw new Error(\n '`uri` does not appear to be a Data URI (must begin with \"data:\")'\n );\n }\n\n // strip newlines\n uri = uri.replace(/\\r?\\n/g, \"\");\n\n // split the URI up into the \"metadata\" and the \"data\" portions\n const firstComma = uri.indexOf(\",\");\n if (firstComma === -1 || firstComma <= 4) {\n throw new Error(\"malformed data: URI\");\n }\n\n // remove the \"data:\" scheme and parse the metadata\n const meta = uri.substring(5, firstComma).split(\";\");\n\n let charset = \"\";\n let base64 = false;\n const type = meta[0] || \"text/plain\";\n let typeFull = type;\n for (let i = 1; i < meta.length; i++) {\n if (meta[i] === \"base64\") {\n base64 = true;\n } else if (meta[i]) {\n typeFull += `;${meta[i]}`;\n if (meta[i]?.indexOf(\"charset=\") === 0) {\n charset = meta[i]!.substring(8);\n }\n }\n }\n\n // defaults to US-ASCII only if type is not provided\n if (!meta[0] && !charset.length) {\n typeFull += \";charset=US-ASCII\";\n charset = \"US-ASCII\";\n }\n\n // get the encoded data portion and decode URI-encoded chars\n const data = unescape(uri.substring(firstComma + 1));\n const buffer = base64\n ? convert.base64ToArrayBuffer(data)\n : convert.stringToBuffer(data);\n\n return {\n type,\n typeFull,\n charset,\n buffer\n };\n };\n"],"mappings":"AAyBA,MAAa,GAAiB,EAAc,IAC1C,QAAQ,EAAK,QAAQ,mBAAmB,EAAK,GAyClC,EACV,GACA,GAAqC,CAGpC,GAFA,EAAM,OAAO,EAAI,CAEb,CAAC,UAAU,KAAK,EAAI,CACtB,MAAU,MACR,mEACD,CAIH,EAAM,EAAI,QAAQ,SAAU,GAAG,CAG/B,IAAM,EAAa,EAAI,QAAQ,IAAI,CACnC,GAAI,IAAe,IAAM,GAAc,EACrC,MAAU,MAAM,sBAAsB,CAIxC,IAAM,EAAO,EAAI,UAAU,EAAG,EAAW,CAAC,MAAM,IAAI,CAEhD,EAAU,GACV,EAAS,GACP,EAAO,EAAK,IAAM,aACpB,EAAW,EACf,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAC3B,EAAK,KAAO,SACd,EAAS,GACA,EAAK,KACd,GAAY,IAAI,EAAK,KACjB,EAAK,IAAI,QAAQ,WAAW,GAAK,IACnC,EAAU,EAAK,GAAI,UAAU,EAAE,GAMjC,CAAC,EAAK,IAAM,CAAC,EAAQ,SACvB,GAAY,oBACZ,EAAU,YAIZ,IAAM,EAAO,SAAS,EAAI,UAAU,EAAa,EAAE,CAAC,CAC9C,EAAS,EACX,EAAQ,oBAAoB,EAAK,CACjC,EAAQ,eAAe,EAAK,CAEhC,MAAO,CACL,OACA,WACA,UACA,SACD"}
|
package/dist/format-data-uri.cjs
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.makeDataUriToBuffer = exports.formatDataURI = void 0;
|
|
7
|
-
const formatDataURI = (a, t) => `data:${t};utf8,${encodeURIComponent(a)}`,
|
|
8
|
-
makeDataUriToBuffer = a => t => {
|
|
9
|
-
if (t = String(t), !/^data:/i.test(t)) throw new Error('`uri` does not appear to be a Data URI (must begin with "data:")');
|
|
10
|
-
t = t.replace(/\r?\n/g, "");
|
|
11
|
-
const s = t.indexOf(",");
|
|
12
|
-
if (s === -1 || s <= 4) throw new Error("malformed data: URI");
|
|
13
|
-
const e = t.substring(5, s).split(";");
|
|
14
|
-
let n = "",
|
|
15
|
-
o = !1;
|
|
16
|
-
const i = e[0] || "text/plain";
|
|
17
|
-
let f = i;
|
|
18
|
-
for (let r = 1; r < e.length; r++) e[r] === "base64" ? o = !0 : e[r] && (f += `;${e[r]}`, e[r]?.indexOf("charset=") === 0 && (n = e[r].substring(8)));
|
|
19
|
-
!e[0] && !n.length && (f += ";charset=US-ASCII", n = "US-ASCII");
|
|
20
|
-
const g = unescape(t.substring(s + 1)),
|
|
21
|
-
c = o ? a.base64ToArrayBuffer(g) : a.stringToBuffer(g);
|
|
22
|
-
return {
|
|
23
|
-
type: i,
|
|
24
|
-
typeFull: f,
|
|
25
|
-
charset: n,
|
|
26
|
-
buffer: c
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
exports.makeDataUriToBuffer = makeDataUriToBuffer;
|
|
30
|
-
exports.formatDataURI = formatDataURI;
|
|
1
|
+
const e=require(`./format-data-uri-C59EgrXn.cjs`);exports.formatDataURI=e.t,exports.makeDataUriToBuffer=e.n;
|
package/dist/format-data-uri.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{n as e,t}from"./format-data-uri-WSwfftd0.mjs";export{t as formatDataURI,e as makeDataUriToBuffer};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
//#region src/get-free-port.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Finds and returns a free port on the local machine by creating a temporary server that listens on port 0. The operating system assigns an available port, which is then retrieved and returned.
|
|
3
4
|
*
|
|
4
5
|
* @returns A promise that resolves to a free port number.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare function getFreePort(): Promise<number>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getFreePort as t };
|
|
10
|
+
//# sourceMappingURL=get-free-port-Bf-x1nt8.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-free-port-Bf-x1nt8.d.cts","names":[],"sources":["../src/get-free-port.ts"],"sourcesContent":[],"mappings":";;AAyBA;;;;iBAAsB,WAAA,CAAA,GAAe"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/get-free-port.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Finds and returns a free port on the local machine by creating a temporary server that listens on port 0. The operating system assigns an available port, which is then retrieved and returned.
|
|
4
|
+
*
|
|
5
|
+
* @returns A promise that resolves to a free port number.
|
|
6
|
+
*/
|
|
7
|
+
declare function getFreePort(): Promise<number>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getFreePort as t };
|
|
10
|
+
//# sourceMappingURL=get-free-port-BwvXPXFs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-free-port-BwvXPXFs.d.mts","names":[],"sources":["../src/get-free-port.ts"],"sourcesContent":[],"mappings":";;AAyBA;;;;iBAAsB,WAAA,CAAA,GAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`node:http`);async function n(){return new Promise((e,n)=>{let r=(0,t.createServer)(()=>{});r.listen(0,()=>{let t=r.address();r.close(),t&&typeof t==`object`?e(t.port):n(Error(`invalid address from server: ${t?.toString()}`))})})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createServer as e}from"node:http";async function t(){return new Promise((t,n)=>{let r=e(()=>{});r.listen(0,()=>{let e=r.address();r.close(),e&&typeof e==`object`?t(e.port):n(Error(`invalid address from server: ${e?.toString()}`))})})}export{t};
|
|
2
|
+
//# sourceMappingURL=get-free-port-DvWNGhhy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-free-port-DvWNGhhy.mjs","names":[],"sources":["../src/get-free-port.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { createServer } from \"node:http\";\n\n/**\n * Finds and returns a free port on the local machine by creating a temporary server that listens on port 0. The operating system assigns an available port, which is then retrieved and returned.\n *\n * @returns A promise that resolves to a free port number.\n */\nexport async function getFreePort(): Promise<number> {\n return new Promise((resolve, reject) => {\n const server = createServer(() => {});\n server.listen(0, () => {\n const address = server.address();\n server.close();\n\n if (address && typeof address === \"object\") {\n resolve(address.port);\n } else {\n reject(\n new Error(`invalid address from server: ${address?.toString()}`)\n );\n }\n });\n });\n}\n"],"mappings":"yCAyBA,eAAsB,GAA+B,CACnD,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAM,EAAS,MAAmB,GAAG,CACrC,EAAO,OAAO,MAAS,CACrB,IAAM,EAAU,EAAO,SAAS,CAChC,EAAO,OAAO,CAEV,GAAW,OAAO,GAAY,SAChC,EAAQ,EAAQ,KAAK,CAErB,EACM,MAAM,gCAAgC,GAAS,UAAU,GAAG,CACjE,EAEH,EACF"}
|
package/dist/get-free-port.cjs
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFreePort = getFreePort;
|
|
7
|
-
var _nodeHttp = require("node:http");
|
|
8
|
-
async function getFreePort() {
|
|
9
|
-
return new Promise((o, s) => {
|
|
10
|
-
const r = (0, _nodeHttp.createServer)(() => {});
|
|
11
|
-
r.listen(0, () => {
|
|
12
|
-
const e = r.address();
|
|
13
|
-
r.close(), e && typeof e == "object" ? o(e.port) : s(new Error(`invalid address from server: ${e?.toString()}`));
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
}
|
|
1
|
+
const e=require(`./get-free-port-D9hjek4b.cjs`);exports.getFreePort=e.t;
|
package/dist/get-free-port.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./get-free-port-DvWNGhhy.mjs";export{e as getFreePort};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./agent-DKevd8Ll.cjs`);let n=require(`node:net`);n=e.t(n);let r=require(`node:buffer`),i=require(`node:events`),a=require(`node:tls`);a=e.t(a);let o=require(`node:url`);var s=class extends t.t{static protocols=[`http`,`https`];proxy;proxyHeaders;connectOpts;constructor(e,t){super(t),this.proxy=typeof e==`string`?new o.URL(e):e,this.proxyHeaders=t?.headers??{};let n=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,``),r=this.proxy.port?Number.parseInt(this.proxy.port,10):this.proxy.protocol===`https:`?443:80;this.connectOpts={...t?c(t,`headers`):null,host:n,port:r}}addRequest(e,t){e._header=null,this.setRequestProps(e,t),super.addRequest(e,t)}setRequestProps(e,t){let{proxy:n}=this,i=t.secureEndpoint?`https:`:`http:`,a=e.getHeader(`host`)||`localhost`,s=`${i}//${Array.isArray(a)?a.join(``):a}`,c=new o.URL(e.path,s);t.port!==80&&(c.port=String(t.port)),e.path=String(c);let l=typeof this.proxyHeaders==`function`?this.proxyHeaders():{...this.proxyHeaders};if(n.username||n.password){let e=`${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;l[`Proxy-Authorization`]=`Basic ${r.Buffer.from(e).toString(`base64`)}`}l[`Proxy-Connection`]||=this.keepAlive?`Keep-Alive`:`close`;for(let t of Object.keys(l)){let n=l[t];n&&e.setHeader(t,n)}}async connect(e,t){e._header=null,e.path.includes(`://`)||this.setRequestProps(e,t);let r,o;e._implicitHeader(),e.outputData&&e.outputData.length>0&&(r=e.outputData[0].data,o=r.indexOf(`\r
|
|
2
|
+
\r
|
|
3
|
+
`)+4,e.outputData[0].data=e._header+r.substring(o));let s;return s=this.proxy.protocol===`https:`?a.connect(this.connectOpts):n.connect(this.connectOpts),await(0,i.once)(s,`connect`),s}};function c(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{t as e}from"./agent-DrFvt4od.mjs";import*as t from"node:net";import{Buffer as n}from"node:buffer";import{once as r}from"node:events";import*as i from"node:tls";import{URL as a}from"node:url";var o=class extends e{static protocols=[`http`,`https`];proxy;proxyHeaders;connectOpts;constructor(e,t){super(t),this.proxy=typeof e==`string`?new a(e):e,this.proxyHeaders=t?.headers??{};let n=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,``),r=this.proxy.port?Number.parseInt(this.proxy.port,10):this.proxy.protocol===`https:`?443:80;this.connectOpts={...t?s(t,`headers`):null,host:n,port:r}}addRequest(e,t){e._header=null,this.setRequestProps(e,t),super.addRequest(e,t)}setRequestProps(e,t){let{proxy:r}=this,i=t.secureEndpoint?`https:`:`http:`,o=e.getHeader(`host`)||`localhost`,s=`${i}//${Array.isArray(o)?o.join(``):o}`,c=new a(e.path,s);t.port!==80&&(c.port=String(t.port)),e.path=String(c);let l=typeof this.proxyHeaders==`function`?this.proxyHeaders():{...this.proxyHeaders};if(r.username||r.password){let e=`${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;l[`Proxy-Authorization`]=`Basic ${n.from(e).toString(`base64`)}`}l[`Proxy-Connection`]||=this.keepAlive?`Keep-Alive`:`close`;for(let t of Object.keys(l)){let n=l[t];n&&e.setHeader(t,n)}}async connect(e,n){e._header=null,e.path.includes(`://`)||this.setRequestProps(e,n);let a,o;e._implicitHeader(),e.outputData&&e.outputData.length>0&&(a=e.outputData[0].data,o=a.indexOf(`\r
|
|
2
|
+
\r
|
|
3
|
+
`)+4,e.outputData[0].data=e._header+a.substring(o));let s;return s=this.proxy.protocol===`https:`?i.connect(this.connectOpts):t.connect(this.connectOpts),await r(s,`connect`),s}};function s(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}export{o as t};
|
|
4
|
+
//# sourceMappingURL=http-proxy-ChUYEQ71.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-proxy-ChUYEQ71.mjs","names":["headers: OutgoingHttpHeaders","first: string","endOfHeaders: number","socket: net.Socket","key: keyof typeof obj"],"sources":["../src/http-proxy.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AgentConnectOpts } from \"agent-base\";\nimport { Buffer } from \"node:buffer\";\nimport { once } from \"node:events\";\nimport type {\n AgentOptions,\n ClientRequest,\n OutgoingHttpHeaders\n} from \"node:http\";\nimport * as net from \"node:net\";\nimport * as tls from \"node:tls\";\nimport { URL } from \"node:url\";\nimport { Agent } from \"./agent\";\n\ntype Protocol<T> = T extends `${infer Protocol}:${infer _}` ? Protocol : never;\n\ninterface ConnectOptsMap {\n http: Omit<net.TcpNetConnectOpts, \"host\" | \"port\">;\n https: Omit<tls.ConnectionOptions, \"host\" | \"port\">;\n}\n\ntype ConnectOpts<T> = {\n [P in keyof ConnectOptsMap]: Protocol<T> extends P\n ? ConnectOptsMap[P]\n : never;\n}[keyof ConnectOptsMap];\n\nexport type HttpProxyAgentOptions<T> = ConnectOpts<T> &\n AgentOptions & {\n headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);\n };\n\ninterface HttpProxyAgentClientRequest extends ClientRequest {\n outputData?: {\n data: string;\n }[];\n _header?: string | null;\n _implicitHeader: () => void;\n}\n\n/**\n * The `HttpProxyAgent` implements an HTTP Agent subclass that connects to the specified \"HTTP proxy server\" in order to proxy HTTP requests.\n */\nexport class HttpProxyAgent<Uri extends string> extends Agent {\n static protocols = [\"http\", \"https\"] as const;\n\n readonly proxy: URL;\n\n proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);\n\n connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;\n\n constructor(proxy: Uri | URL, opts?: HttpProxyAgentOptions<Uri>) {\n super(opts);\n this.proxy = typeof proxy === \"string\" ? new URL(proxy) : proxy;\n this.proxyHeaders = opts?.headers ?? {};\n\n // Trim off the brackets from IPv6 addresses\n const host = (this.proxy.hostname || this.proxy.host).replace(\n /^\\[|\\]$/g,\n \"\"\n );\n const port = this.proxy.port\n ? Number.parseInt(this.proxy.port, 10)\n : this.proxy.protocol === \"https:\"\n ? 443\n : 80;\n this.connectOpts = {\n ...(opts ? omit(opts, \"headers\") : null),\n host,\n port\n };\n }\n\n addRequest(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void {\n req._header = null;\n this.setRequestProps(req, opts);\n\n // @ts-expect-error `addRequest()` isn't defined in `@types/node`\n // eslint-disable-next-line ts/no-unsafe-call\n super.addRequest(req, opts);\n }\n\n setRequestProps(\n req: HttpProxyAgentClientRequest,\n opts: AgentConnectOpts\n ): void {\n const { proxy } = this;\n const protocol = opts.secureEndpoint ? \"https:\" : \"http:\";\n const hostname = req.getHeader(\"host\") || \"localhost\";\n const base = `${protocol}//${Array.isArray(hostname) ? hostname.join(\"\") : hostname}`;\n const url = new URL(req.path, base);\n if (opts.port !== 80) {\n url.port = String(opts.port);\n }\n\n // Change the `http.ClientRequest` instance's \"path\" field\n // to the absolute path of the URL that will be requested.\n req.path = String(url);\n\n // Inject the `Proxy-Authorization` header if necessary.\n\n const headers: OutgoingHttpHeaders =\n typeof this.proxyHeaders === \"function\"\n ? this.proxyHeaders()\n : { ...this.proxyHeaders };\n if (proxy.username || proxy.password) {\n const auth = `${decodeURIComponent(\n proxy.username\n )}:${decodeURIComponent(proxy.password)}`;\n headers[\"Proxy-Authorization\"] = `Basic ${Buffer.from(auth).toString(\n \"base64\"\n )}`;\n }\n\n if (!headers[\"Proxy-Connection\"]) {\n headers[\"Proxy-Connection\"] = this.keepAlive ? \"Keep-Alive\" : \"close\";\n }\n for (const name of Object.keys(headers)) {\n const value = headers[name];\n if (value) {\n req.setHeader(name, value);\n }\n }\n }\n\n async connect(\n req: HttpProxyAgentClientRequest,\n opts: AgentConnectOpts\n ): Promise<net.Socket> {\n req._header = null;\n\n if (!req.path.includes(\"://\")) {\n this.setRequestProps(req, opts);\n }\n\n // At this point, the http ClientRequest's internal `_header` field\n // might have already been set. If this is the case then we'll need\n // to re-generate the string since we just changed the `req.path`.\n let first: string;\n let endOfHeaders: number;\n\n req._implicitHeader();\n if (req.outputData && req.outputData.length > 0) {\n first = req.outputData[0]!.data;\n endOfHeaders = first.indexOf(\"\\r\\n\\r\\n\") + 4;\n req.outputData[0]!.data = req._header + first.substring(endOfHeaders);\n }\n\n // Create a socket connection to the proxy server.\n let socket: net.Socket;\n if (this.proxy.protocol === \"https:\") {\n socket = tls.connect(this.connectOpts);\n } else {\n socket = net.connect(this.connectOpts);\n }\n\n // Wait for the socket's `connect` event, so that this `callback()`\n // function throws instead of the `http` request machinery. This is\n // important for i.e. `PacProxyAgent` which determines a failed proxy\n // connection via the `callback()` function throwing.\n await once(socket, \"connect\");\n\n return socket;\n }\n}\n\nfunction omit<T extends object, K extends [...(keyof T)[]]>(\n obj: T,\n ...keys: K\n): {\n [K2 in Exclude<keyof T, K[number]>]: T[K2];\n} {\n const ret = {} as {\n [K in keyof typeof obj]: (typeof obj)[K];\n };\n let key: keyof typeof obj;\n for (key in obj) {\n if (!keys.includes(key)) {\n ret[key] = obj[key];\n }\n }\n return ret;\n}\n"],"mappings":"sMA4DA,IAAa,EAAb,cAAwD,CAAM,CAC5D,OAAO,UAAY,CAAC,OAAQ,QAAQ,CAEpC,MAEA,aAEA,YAEA,YAAY,EAAkB,EAAmC,CAC/D,MAAM,EAAK,CACX,KAAK,MAAQ,OAAO,GAAU,SAAW,IAAI,EAAI,EAAM,CAAG,EAC1D,KAAK,aAAe,GAAM,SAAW,EAAE,CAGvC,IAAM,GAAQ,KAAK,MAAM,UAAY,KAAK,MAAM,MAAM,QACpD,WACA,GACD,CACK,EAAO,KAAK,MAAM,KACpB,OAAO,SAAS,KAAK,MAAM,KAAM,GAAG,CACpC,KAAK,MAAM,WAAa,SACtB,IACA,GACN,KAAK,YAAc,CACjB,GAAI,EAAO,EAAK,EAAM,UAAU,CAAG,KACnC,OACA,OACD,CAGH,WAAW,EAAkC,EAA8B,CACzE,EAAI,QAAU,KACd,KAAK,gBAAgB,EAAK,EAAK,CAI/B,MAAM,WAAW,EAAK,EAAK,CAG7B,gBACE,EACA,EACM,CACN,GAAM,CAAE,SAAU,KACZ,EAAW,EAAK,eAAiB,SAAW,QAC5C,EAAW,EAAI,UAAU,OAAO,EAAI,YACpC,EAAO,GAAG,EAAS,IAAI,MAAM,QAAQ,EAAS,CAAG,EAAS,KAAK,GAAG,CAAG,IACrE,EAAM,IAAI,EAAI,EAAI,KAAM,EAAK,CAC/B,EAAK,OAAS,KAChB,EAAI,KAAO,OAAO,EAAK,KAAK,EAK9B,EAAI,KAAO,OAAO,EAAI,CAItB,IAAMA,EACJ,OAAO,KAAK,cAAiB,WACzB,KAAK,cAAc,CACnB,CAAE,GAAG,KAAK,aAAc,CAC9B,GAAI,EAAM,UAAY,EAAM,SAAU,CACpC,IAAM,EAAO,GAAG,mBACd,EAAM,SACP,CAAC,GAAG,mBAAmB,EAAM,SAAS,GACvC,EAAQ,uBAAyB,SAAS,EAAO,KAAK,EAAK,CAAC,SAC1D,SACD,GAGH,AACE,EAAQ,sBAAsB,KAAK,UAAY,aAAe,QAEhE,IAAK,IAAM,KAAQ,OAAO,KAAK,EAAQ,CAAE,CACvC,IAAM,EAAQ,EAAQ,GAClB,GACF,EAAI,UAAU,EAAM,EAAM,EAKhC,MAAM,QACJ,EACA,EACqB,CACrB,EAAI,QAAU,KAET,EAAI,KAAK,SAAS,MAAM,EAC3B,KAAK,gBAAgB,EAAK,EAAK,CAMjC,IAAIC,EACAC,EAEJ,EAAI,iBAAiB,CACjB,EAAI,YAAc,EAAI,WAAW,OAAS,IAC5C,EAAQ,EAAI,WAAW,GAAI,KAC3B,EAAe,EAAM,QAAQ;;EAAW,CAAG,EAC3C,EAAI,WAAW,GAAI,KAAO,EAAI,QAAU,EAAM,UAAU,EAAa,EAIvE,IAAIC,EAaJ,MAZA,CAGE,EAHE,KAAK,MAAM,WAAa,SACjB,EAAI,QAAQ,KAAK,YAAY,CAE7B,EAAI,QAAQ,KAAK,YAAY,CAOxC,MAAM,EAAK,EAAQ,UAAU,CAEtB,IAIX,SAAS,EACP,EACA,GAAG,EAGH,CACA,IAAM,EAAM,EAAE,CAGVC,EACJ,IAAK,KAAO,EACL,EAAK,SAAS,EAAI,GACrB,EAAI,GAAO,EAAI,IAGnB,OAAO"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as Agent$1 } from "./agent-Cc4PYJ-j.cjs";
|
|
2
|
+
import { AgentOptions, ClientRequest, OutgoingHttpHeaders } from "node:http";
|
|
3
|
+
import * as net from "node:net";
|
|
4
|
+
import * as tls from "node:tls";
|
|
5
|
+
import { AgentConnectOpts } from "agent-base";
|
|
6
|
+
import { URL } from "node:url";
|
|
7
|
+
|
|
8
|
+
//#region src/http-proxy.d.ts
|
|
9
|
+
type Protocol<T> = T extends `${infer Protocol}:${infer _}` ? Protocol : never;
|
|
10
|
+
interface ConnectOptsMap {
|
|
11
|
+
http: Omit<net.TcpNetConnectOpts, "host" | "port">;
|
|
12
|
+
https: Omit<tls.ConnectionOptions, "host" | "port">;
|
|
13
|
+
}
|
|
14
|
+
type ConnectOpts<T> = { [P in keyof ConnectOptsMap]: Protocol<T> extends P ? ConnectOptsMap[P] : never }[keyof ConnectOptsMap];
|
|
15
|
+
type HttpProxyAgentOptions<T> = ConnectOpts<T> & AgentOptions & {
|
|
16
|
+
headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
|
|
17
|
+
};
|
|
18
|
+
interface HttpProxyAgentClientRequest extends ClientRequest {
|
|
19
|
+
outputData?: {
|
|
20
|
+
data: string;
|
|
21
|
+
}[];
|
|
22
|
+
_header?: string | null;
|
|
23
|
+
_implicitHeader: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The `HttpProxyAgent` implements an HTTP Agent subclass that connects to the specified "HTTP proxy server" in order to proxy HTTP requests.
|
|
27
|
+
*/
|
|
28
|
+
declare class HttpProxyAgent<Uri extends string> extends Agent$1 {
|
|
29
|
+
static protocols: readonly ["http", "https"];
|
|
30
|
+
readonly proxy: URL;
|
|
31
|
+
proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
|
|
32
|
+
connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
|
|
33
|
+
constructor(proxy: Uri | URL, opts?: HttpProxyAgentOptions<Uri>);
|
|
34
|
+
addRequest(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void;
|
|
35
|
+
setRequestProps(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void;
|
|
36
|
+
connect(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): Promise<net.Socket>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { HttpProxyAgentOptions as n, HttpProxyAgent as t };
|
|
40
|
+
//# sourceMappingURL=http-proxy-CzvOBKWd.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-proxy-CzvOBKWd.d.cts","names":[],"sources":["../src/http-proxy.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA+BK,cAAc;UAET,cAAA;EAFL,IAAA,EAGG,IAHH,CAGQ,GAAA,CAAI,iBAHG,EAAA,MAAA,GAAA,MAAA,CAAA;EAEV,KAAA,EAED,IAFC,CAEI,GAAA,CAAI,iBAFM,EAAA,MAAA,GAAA,MAAA,CAAA;;KAKnB,WAJG,CAAA,CAAA,CAAA,GAAA,QACU,MAIJ,cAJI,GAIa,QAJb,CAIsB,CAJtB,CAAA,SAIiC,CAJjC,GAKZ,cALY,CAKG,CALH,CAAA,GAAA,KAAA,EAAT,CAAA,MAOD,cAPC,CAAA;AAAI,KASD,qBATC,CAAA,CAAA,CAAA,GAS0B,WAT1B,CASsC,CATtC,CAAA,GAUX,YAVW,GAAA;EAGR,OAAA,CAAA,EAQS,mBARE,GAAA,CAAA,GAAA,GAQ2B,mBAR3B,CAAA;CACF;UAUJ,2BAAA,SAAoC,aAVN,CAAA;EAAT,UAAA,CAAA,EAAA;IAAoB,IAAA,EAAA,MAAA;EAC7C,CAAA,EAAA;EAAe,OAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAEb,eAAA,EAAA,GAAA,GAAA,IAAA;;AAER;;;AACE,cAeW,cAfX,CAAA,YAAA,MAAA,CAAA,SAesD,OAAA,CAftD;EACY,OAAA,SAAA,EAAA,SAAA,CAAA,MAAA,EAAA,OAAA,CAAA;EAA6B,SAAA,KAAA,EAiBzB,GAjByB;EAAmB,YAAA,EAmB9C,mBAnB8C,GAAA,CAAA,GAAA,GAmBjB,mBAnBiB,CAAA;EAGpD,WAAA,EAkBK,GAAA,CAAI,iBAlBmB,GAkBC,GAAA,CAAI,iBAlBgB;EAW9C,WAAA,CAAA,KAAc,EASN,GATM,GASA,GATA,EAAA,IAAA,CAAA,EASY,qBATZ,CASkC,GATlC,CAAA;EAGT,UAAA,CAAA,GAAA,EA4BA,2BA5BA,EAAA,IAAA,EA4BmC,gBA5BnC,CAAA,EAAA,IAAA;EAEF,eAAA,CAAA,GAAA,EAoCP,2BApCO,EAAA,IAAA,EAqCN,gBArCM,CAAA,EAAA,IAAA;EAA6B,OAAA,CAAA,GAAA,EA+EpC,2BA/EoC,EAAA,IAAA,EAgFnC,gBAhFmC,CAAA,EAiFxC,OAjFwC,CAiFhC,GAAA,CAAI,MAjF4B,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as Agent$1 } from "./agent-DXIpD4O5.mjs";
|
|
2
|
+
import { AgentOptions, ClientRequest, OutgoingHttpHeaders } from "node:http";
|
|
3
|
+
import * as net from "node:net";
|
|
4
|
+
import * as tls from "node:tls";
|
|
5
|
+
import { URL } from "node:url";
|
|
6
|
+
import { AgentConnectOpts } from "agent-base";
|
|
7
|
+
|
|
8
|
+
//#region src/http-proxy.d.ts
|
|
9
|
+
type Protocol<T> = T extends `${infer Protocol}:${infer _}` ? Protocol : never;
|
|
10
|
+
interface ConnectOptsMap {
|
|
11
|
+
http: Omit<net.TcpNetConnectOpts, "host" | "port">;
|
|
12
|
+
https: Omit<tls.ConnectionOptions, "host" | "port">;
|
|
13
|
+
}
|
|
14
|
+
type ConnectOpts<T> = { [P in keyof ConnectOptsMap]: Protocol<T> extends P ? ConnectOptsMap[P] : never }[keyof ConnectOptsMap];
|
|
15
|
+
type HttpProxyAgentOptions<T> = ConnectOpts<T> & AgentOptions & {
|
|
16
|
+
headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
|
|
17
|
+
};
|
|
18
|
+
interface HttpProxyAgentClientRequest extends ClientRequest {
|
|
19
|
+
outputData?: {
|
|
20
|
+
data: string;
|
|
21
|
+
}[];
|
|
22
|
+
_header?: string | null;
|
|
23
|
+
_implicitHeader: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The `HttpProxyAgent` implements an HTTP Agent subclass that connects to the specified "HTTP proxy server" in order to proxy HTTP requests.
|
|
27
|
+
*/
|
|
28
|
+
declare class HttpProxyAgent<Uri extends string> extends Agent$1 {
|
|
29
|
+
static protocols: readonly ["http", "https"];
|
|
30
|
+
readonly proxy: URL;
|
|
31
|
+
proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
|
|
32
|
+
connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
|
|
33
|
+
constructor(proxy: Uri | URL, opts?: HttpProxyAgentOptions<Uri>);
|
|
34
|
+
addRequest(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void;
|
|
35
|
+
setRequestProps(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): void;
|
|
36
|
+
connect(req: HttpProxyAgentClientRequest, opts: AgentConnectOpts): Promise<net.Socket>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { HttpProxyAgentOptions as n, HttpProxyAgent as t };
|
|
40
|
+
//# sourceMappingURL=http-proxy-DuPPyvFw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-proxy-DuPPyvFw.d.mts","names":[],"sources":["../src/http-proxy.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA+BK,cAAc;UAET,cAAA;EAFL,IAAA,EAGG,IAHH,CAGQ,GAAA,CAAI,iBAHG,EAAA,MAAA,GAAA,MAAA,CAAA;EAEV,KAAA,EAED,IAFC,CAEI,GAAA,CAAI,iBAFM,EAAA,MAAA,GAAA,MAAA,CAAA;;KAKnB,WAJG,CAAA,CAAA,CAAA,GAAA,QACU,MAIJ,cAJI,GAIa,QAJb,CAIsB,CAJtB,CAAA,SAIiC,CAJjC,GAKZ,cALY,CAKG,CALH,CAAA,GAAA,KAAA,EAAT,CAAA,MAOD,cAPC,CAAA;AAAI,KASD,qBATC,CAAA,CAAA,CAAA,GAS0B,WAT1B,CASsC,CATtC,CAAA,GAUX,YAVW,GAAA;EAGR,OAAA,CAAA,EAQS,mBARE,GAAA,CAAA,GAAA,GAQ2B,mBAR3B,CAAA;CACF;UAUJ,2BAAA,SAAoC,aAVN,CAAA;EAAT,UAAA,CAAA,EAAA;IAAoB,IAAA,EAAA,MAAA;EAC7C,CAAA,EAAA;EAAe,OAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAEb,eAAA,EAAA,GAAA,GAAA,IAAA;;AAER;;;AACE,cAeW,cAfX,CAAA,YAAA,MAAA,CAAA,SAesD,OAAA,CAftD;EACY,OAAA,SAAA,EAAA,SAAA,CAAA,MAAA,EAAA,OAAA,CAAA;EAA6B,SAAA,KAAA,EAiBzB,GAjByB;EAAmB,YAAA,EAmB9C,mBAnB8C,GAAA,CAAA,GAAA,GAmBjB,mBAnBiB,CAAA;EAGpD,WAAA,EAkBK,GAAA,CAAI,iBAlBmB,GAkBC,GAAA,CAAI,iBAlBgB;EAW9C,WAAA,CAAA,KAAc,EASN,GATM,GASA,GATA,EAAA,IAAA,CAAA,EASY,qBATZ,CASkC,GATlC,CAAA;EAGT,UAAA,CAAA,GAAA,EA4BA,2BA5BA,EAAA,IAAA,EA4BmC,gBA5BnC,CAAA,EAAA,IAAA;EAEF,eAAA,CAAA,GAAA,EAoCP,2BApCO,EAAA,IAAA,EAqCN,gBArCM,CAAA,EAAA,IAAA;EAA6B,OAAA,CAAA,GAAA,EA+EpC,2BA/EoC,EAAA,IAAA,EAgFnC,gBAhFmC,CAAA,EAiFxC,OAjFwC,CAiFhC,GAAA,CAAI,MAjF4B,CAAA"}
|