@stryke/http 0.12.14 → 0.12.15

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.
Files changed (153) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/{chunk-Bmb41Sf3.cjs → _virtual/rolldown_runtime.cjs} +1 -1
  3. package/dist/agent.cjs +2 -1
  4. package/dist/agent.d.cts +40 -2
  5. package/dist/agent.d.cts.map +1 -0
  6. package/dist/agent.d.mts +40 -2
  7. package/dist/agent.d.mts.map +1 -0
  8. package/dist/agent.mjs +3 -1
  9. package/dist/agent.mjs.map +1 -0
  10. package/dist/fetch.cjs +1 -1
  11. package/dist/fetch.d.cts +24 -2
  12. package/dist/fetch.d.cts.map +1 -0
  13. package/dist/fetch.d.mts +24 -2
  14. package/dist/fetch.d.mts.map +1 -0
  15. package/dist/fetch.mjs +2 -1
  16. package/dist/fetch.mjs.map +1 -0
  17. package/dist/format-data-uri.cjs +1 -1
  18. package/dist/format-data-uri.d.cts +50 -2
  19. package/dist/format-data-uri.d.cts.map +1 -0
  20. package/dist/format-data-uri.d.mts +50 -2
  21. package/dist/format-data-uri.d.mts.map +1 -0
  22. package/dist/format-data-uri.mjs +2 -1
  23. package/dist/format-data-uri.mjs.map +1 -0
  24. package/dist/get-free-port.cjs +1 -1
  25. package/dist/get-free-port.d.cts +10 -2
  26. package/dist/get-free-port.d.cts.map +1 -0
  27. package/dist/get-free-port.d.mts +10 -2
  28. package/dist/get-free-port.d.mts.map +1 -0
  29. package/dist/get-free-port.mjs +2 -1
  30. package/dist/get-free-port.mjs.map +1 -0
  31. package/dist/http-proxy.cjs +3 -1
  32. package/dist/http-proxy.d.cts +40 -2
  33. package/dist/http-proxy.d.cts.map +1 -0
  34. package/dist/http-proxy.d.mts +40 -2
  35. package/dist/http-proxy.d.mts.map +1 -0
  36. package/dist/http-proxy.mjs +4 -1
  37. package/dist/http-proxy.mjs.map +1 -0
  38. package/dist/https-proxy.cjs +1 -1
  39. package/dist/https-proxy.d.cts +43 -2
  40. package/dist/https-proxy.d.cts.map +1 -0
  41. package/dist/https-proxy.d.mts +43 -2
  42. package/dist/https-proxy.d.mts.map +1 -0
  43. package/dist/https-proxy.mjs +2 -1
  44. package/dist/https-proxy.mjs.map +1 -0
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.d.cts +8 -8
  47. package/dist/index.d.mts +8 -8
  48. package/dist/index.mjs +1 -1
  49. package/dist/parse-response.cjs +4 -1
  50. package/dist/parse-response.d.cts +23 -2
  51. package/dist/parse-response.d.cts.map +1 -0
  52. package/dist/parse-response.d.mts +23 -2
  53. package/dist/parse-response.d.mts.map +1 -0
  54. package/dist/parse-response.mjs +5 -1
  55. package/dist/parse-response.mjs.map +1 -0
  56. package/dist/proxy-agent.cjs +1 -1
  57. package/dist/proxy-agent.d.cts +13 -2
  58. package/dist/proxy-agent.d.cts.map +1 -0
  59. package/dist/proxy-agent.d.mts +13 -2
  60. package/dist/proxy-agent.d.mts.map +1 -0
  61. package/dist/proxy-agent.mjs +2 -1
  62. package/dist/proxy-agent.mjs.map +1 -0
  63. package/dist/type-checks/src/index.cjs +1 -0
  64. package/dist/type-checks/src/index.mjs +1 -0
  65. package/dist/type-checks/src/is-boolean.cjs +1 -0
  66. package/dist/type-checks/src/is-boolean.mjs +2 -0
  67. package/dist/type-checks/src/is-boolean.mjs.map +1 -0
  68. package/dist/type-checks/src/is-buffer.cjs +1 -0
  69. package/dist/type-checks/src/is-buffer.mjs +2 -0
  70. package/dist/type-checks/src/is-buffer.mjs.map +1 -0
  71. package/dist/type-checks/src/is-collection.cjs +1 -0
  72. package/dist/type-checks/src/is-collection.mjs +1 -0
  73. package/dist/type-checks/src/is-empty.cjs +1 -0
  74. package/dist/type-checks/src/is-empty.mjs +2 -0
  75. package/dist/type-checks/src/is-empty.mjs.map +1 -0
  76. package/dist/type-checks/src/is-null.cjs +1 -0
  77. package/dist/type-checks/src/is-null.mjs +2 -0
  78. package/dist/type-checks/src/is-null.mjs.map +1 -0
  79. package/dist/type-checks/src/is-set-string.cjs +1 -0
  80. package/dist/type-checks/src/is-set-string.mjs +2 -0
  81. package/dist/type-checks/src/is-set-string.mjs.map +1 -0
  82. package/dist/type-checks/src/is-set.cjs +1 -0
  83. package/dist/type-checks/src/is-set.mjs +2 -0
  84. package/dist/type-checks/src/is-set.mjs.map +1 -0
  85. package/dist/type-checks/src/is-string.cjs +1 -0
  86. package/dist/type-checks/src/is-string.mjs +2 -0
  87. package/dist/type-checks/src/is-string.mjs.map +1 -0
  88. package/dist/type-checks/src/is-undefined.cjs +1 -0
  89. package/dist/type-checks/src/is-undefined.mjs +2 -0
  90. package/dist/type-checks/src/is-undefined.mjs.map +1 -0
  91. package/dist/type-checks/src/type-detect.cjs +1 -0
  92. package/dist/type-checks/src/type-detect.mjs +2 -0
  93. package/dist/type-checks/src/type-detect.mjs.map +1 -0
  94. package/dist/url/src/helpers.cjs +1 -0
  95. package/dist/url/src/helpers.mjs +2 -0
  96. package/dist/url/src/helpers.mjs.map +1 -0
  97. package/package.json +6 -6
  98. package/dist/agent-Cc4PYJ-j.d.cts +0 -40
  99. package/dist/agent-Cc4PYJ-j.d.cts.map +0 -1
  100. package/dist/agent-DKevd8Ll.cjs +0 -2
  101. package/dist/agent-DXIpD4O5.d.mts +0 -40
  102. package/dist/agent-DXIpD4O5.d.mts.map +0 -1
  103. package/dist/agent-DrFvt4od.mjs +0 -3
  104. package/dist/agent-DrFvt4od.mjs.map +0 -1
  105. package/dist/fetch-BYPFJG9Y.d.cts +0 -24
  106. package/dist/fetch-BYPFJG9Y.d.cts.map +0 -1
  107. package/dist/fetch-D3masEhH.d.mts +0 -24
  108. package/dist/fetch-D3masEhH.d.mts.map +0 -1
  109. package/dist/fetch-DXVSCX2B.cjs +0 -1
  110. package/dist/fetch-DgPaAZTB.mjs +0 -2
  111. package/dist/fetch-DgPaAZTB.mjs.map +0 -1
  112. package/dist/format-data-uri-B-rw3THu.d.cts +0 -50
  113. package/dist/format-data-uri-B-rw3THu.d.cts.map +0 -1
  114. package/dist/format-data-uri-C59EgrXn.cjs +0 -1
  115. package/dist/format-data-uri-D864kwXt.d.mts +0 -50
  116. package/dist/format-data-uri-D864kwXt.d.mts.map +0 -1
  117. package/dist/format-data-uri-WSwfftd0.mjs +0 -2
  118. package/dist/format-data-uri-WSwfftd0.mjs.map +0 -1
  119. package/dist/get-free-port-Bf-x1nt8.d.cts +0 -10
  120. package/dist/get-free-port-Bf-x1nt8.d.cts.map +0 -1
  121. package/dist/get-free-port-BwvXPXFs.d.mts +0 -10
  122. package/dist/get-free-port-BwvXPXFs.d.mts.map +0 -1
  123. package/dist/get-free-port-D9hjek4b.cjs +0 -1
  124. package/dist/get-free-port-DvWNGhhy.mjs +0 -2
  125. package/dist/get-free-port-DvWNGhhy.mjs.map +0 -1
  126. package/dist/http-proxy-CJqbqeZN.cjs +0 -3
  127. package/dist/http-proxy-ChUYEQ71.mjs +0 -4
  128. package/dist/http-proxy-ChUYEQ71.mjs.map +0 -1
  129. package/dist/http-proxy-CzvOBKWd.d.cts +0 -40
  130. package/dist/http-proxy-CzvOBKWd.d.cts.map +0 -1
  131. package/dist/http-proxy-DuPPyvFw.d.mts +0 -40
  132. package/dist/http-proxy-DuPPyvFw.d.mts.map +0 -1
  133. package/dist/https-proxy-B8w-jm17.d.cts +0 -43
  134. package/dist/https-proxy-B8w-jm17.d.cts.map +0 -1
  135. package/dist/https-proxy-f4-C_EL8.d.mts +0 -43
  136. package/dist/https-proxy-f4-C_EL8.d.mts.map +0 -1
  137. package/dist/https-proxy-k0GW_xX8.cjs +0 -1
  138. package/dist/https-proxy-rNc_8MiC.mjs +0 -2
  139. package/dist/https-proxy-rNc_8MiC.mjs.map +0 -1
  140. package/dist/parse-response-BRlQF_8K.cjs +0 -4
  141. package/dist/parse-response-CGkjN9j0.mjs +0 -5
  142. package/dist/parse-response-CGkjN9j0.mjs.map +0 -1
  143. package/dist/parse-response-CS657Hki.d.cts +0 -23
  144. package/dist/parse-response-CS657Hki.d.cts.map +0 -1
  145. package/dist/parse-response-ujHVHmwG.d.mts +0 -23
  146. package/dist/parse-response-ujHVHmwG.d.mts.map +0 -1
  147. package/dist/proxy-agent-BrxQeFy2.d.mts +0 -13
  148. package/dist/proxy-agent-BrxQeFy2.d.mts.map +0 -1
  149. package/dist/proxy-agent-CnWrJ59l.d.cts +0 -13
  150. package/dist/proxy-agent-CnWrJ59l.d.cts.map +0 -1
  151. package/dist/proxy-agent-DMsOloiQ.cjs +0 -1
  152. package/dist/proxy-agent-uGI03t_I.mjs +0 -2
  153. package/dist/proxy-agent-uGI03t_I.mjs.map +0 -1
@@ -1,2 +1,43 @@
1
- import { n as HttpsProxyAgentOptions, t as HttpsProxyAgent } from "./https-proxy-B8w-jm17.cjs";
2
- export { HttpsProxyAgent, HttpsProxyAgentOptions };
1
+ import * as http from "node:http";
2
+ import { OutgoingHttpHeaders } from "node:http";
3
+ import * as net from "node:net";
4
+ import * as tls from "node:tls";
5
+ import { Agent, AgentConnectOpts } from "agent-base";
6
+ import { URL } from "node:url";
7
+
8
+ //#region src/https-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 HttpsProxyAgentOptions<T> = ConnectOpts<T> & http.AgentOptions & {
16
+ headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
17
+ };
18
+ /**
19
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
20
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
21
+ *
22
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
23
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
24
+ * and then the proxy server connects to the destination target and issues the
25
+ * HTTP request from the proxy server.
26
+ *
27
+ * `https:` requests have their socket connection upgraded to TLS once
28
+ * the connection to the proxy server has been established.
29
+ */
30
+ declare class HttpsProxyAgent<Uri extends string> extends Agent {
31
+ static protocols: readonly ["http", "https"];
32
+ readonly proxy: URL;
33
+ proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
34
+ connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
35
+ constructor(proxy: Uri | URL, opts?: HttpsProxyAgentOptions<Uri>);
36
+ /**
37
+ * Called when the node-core HTTP client library is creating a new HTTP request.
38
+ */
39
+ connect(req: http.ClientRequest, opts: AgentConnectOpts): Promise<net.Socket>;
40
+ }
41
+ //#endregion
42
+ export { HttpsProxyAgent, HttpsProxyAgentOptions };
43
+ //# sourceMappingURL=https-proxy.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"https-proxy.d.cts","names":[],"sources":["../src/https-proxy.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA+CK,cAAc;AArBY,UAuBrB,cAAA,CAFG;EAEH,IAAA,EACF,IADE,CACG,GAAA,CAAI,iBADO,EAAA,MAAA,GAAA,MAAA,CAAA;EACX,KAAI,EACR,IADQ,CACH,GAAA,CAAI,iBADD,EAAA,MAAA,GAAA,MAAA,CAAA;;KAIZ,WAHa,CAAA,CAAA,CAAA,GAAA,QAAT,MAIK,cAJL,GAIsB,QAJtB,CAI+B,CAJ/B,CAAA,SAI0C,CAJ1C,GAKH,cALG,CAKY,CALZ,CAAA,GAAA,KAAA,EAAI,CAAA,MAOL,cAPK,CAAA;AAGR,KAMO,sBANI,CAAA,CAAA,CAAA,GAMwB,WANxB,CAMoC,CANpC,CAAA,GAOd,IAAA,CAAK,YAPS,GAAA;EACF,OAAA,CAAA,EAOA,mBAPA,GAAA,CAAA,GAAA,GAO6B,mBAP7B,CAAA;CAA0B;;;;;;;AAKxC;;;;;;AAE8D,cAejD,eAfiD,CAAA,YAAA,MAAA,CAAA,SAeL,KAAA,CAfK;EAejD,OAAA,SAAA,EAAe,SAAA,CAAA,MAAA,EAAA,OAAA,CAAA;EAGV,SAAA,KAAA,EAAA,GAAA;EAEF,YAAA,EAAA,mBAAA,GAAA,CAAA,GAAA,GAA6B,mBAA7B,CAAA;EAA6B,WAAA,EAE9B,GAAA,CAAI,iBAF0B,GAEN,GAAA,CAAI,iBAFE;EAE9B,WAAI,CAAA,KAAA,EAEE,GAFF,GAEQ,GAFR,EAAA,IAAA,CAAA,EAEoB,sBAFpB,CAE2C,GAF3C,CAAA;EAAoB;;;EAEuB,OAAA,CAAA,GAAA,EA6BrD,IAAA,CAAK,aA7BgD,EAAA,IAAA,EA8BpD,gBA9BoD,CAAA,EA+BzD,OA/ByD,CA+BjD,GAAA,CAAI,MA/B6C,CAAA"}
@@ -1,2 +1,43 @@
1
- import { n as HttpsProxyAgentOptions, t as HttpsProxyAgent } from "./https-proxy-f4-C_EL8.mjs";
2
- export { HttpsProxyAgent, HttpsProxyAgentOptions };
1
+ import * as http from "node:http";
2
+ import { 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 { Agent, AgentConnectOpts } from "agent-base";
7
+
8
+ //#region src/https-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 HttpsProxyAgentOptions<T> = ConnectOpts<T> & http.AgentOptions & {
16
+ headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
17
+ };
18
+ /**
19
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
20
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
21
+ *
22
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
23
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
24
+ * and then the proxy server connects to the destination target and issues the
25
+ * HTTP request from the proxy server.
26
+ *
27
+ * `https:` requests have their socket connection upgraded to TLS once
28
+ * the connection to the proxy server has been established.
29
+ */
30
+ declare class HttpsProxyAgent<Uri extends string> extends Agent {
31
+ static protocols: readonly ["http", "https"];
32
+ readonly proxy: URL;
33
+ proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
34
+ connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
35
+ constructor(proxy: Uri | URL, opts?: HttpsProxyAgentOptions<Uri>);
36
+ /**
37
+ * Called when the node-core HTTP client library is creating a new HTTP request.
38
+ */
39
+ connect(req: http.ClientRequest, opts: AgentConnectOpts): Promise<net.Socket>;
40
+ }
41
+ //#endregion
42
+ export { HttpsProxyAgent, HttpsProxyAgentOptions };
43
+ //# sourceMappingURL=https-proxy.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"https-proxy.d.mts","names":[],"sources":["../src/https-proxy.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA+CK,cAAc;AArBY,UAuBrB,cAAA,CAFG;EAEH,IAAA,EACF,IADE,CACG,GAAA,CAAI,iBADO,EAAA,MAAA,GAAA,MAAA,CAAA;EACX,KAAI,EACR,IADQ,CACH,GAAA,CAAI,iBADD,EAAA,MAAA,GAAA,MAAA,CAAA;;KAIZ,WAHa,CAAA,CAAA,CAAA,GAAA,QAAT,MAIK,cAJL,GAIsB,QAJtB,CAI+B,CAJ/B,CAAA,SAI0C,CAJ1C,GAKH,cALG,CAKY,CALZ,CAAA,GAAA,KAAA,EAAI,CAAA,MAOL,cAPK,CAAA;AAGR,KAMO,sBANI,CAAA,CAAA,CAAA,GAMwB,WANxB,CAMoC,CANpC,CAAA,GAOd,IAAA,CAAK,YAPS,GAAA;EACF,OAAA,CAAA,EAOA,mBAPA,GAAA,CAAA,GAAA,GAO6B,mBAP7B,CAAA;CAA0B;;;;;;;AAKxC;;;;;;AAE8D,cAejD,eAfiD,CAAA,YAAA,MAAA,CAAA,SAeL,KAAA,CAfK;EAejD,OAAA,SAAA,EAAe,SAAA,CAAA,MAAA,EAAA,OAAA,CAAA;EAGV,SAAA,KAAA,EAAA,GAAA;EAEF,YAAA,EAAA,mBAAA,GAAA,CAAA,GAAA,GAA6B,mBAA7B,CAAA;EAA6B,WAAA,EAE9B,GAAA,CAAI,iBAF0B,GAEN,GAAA,CAAI,iBAFE;EAE9B,WAAI,CAAA,KAAA,EAEE,GAFF,GAEQ,GAFR,EAAA,IAAA,CAAA,EAEoB,sBAFpB,CAE2C,GAF3C,CAAA;EAAoB;;;EAEuB,OAAA,CAAA,GAAA,EA6BrD,IAAA,CAAK,aA7BgD,EAAA,IAAA,EA8BpD,gBA9BoD,CAAA,EA+BzD,OA/ByD,CA+BjD,GAAA,CAAI,MA/B6C,CAAA"}
@@ -1 +1,2 @@
1
- import{t as e}from"./https-proxy-rNc_8MiC.mjs";export{e as HttpsProxyAgent};
1
+ import{parseProxyResponse as e}from"./parse-response.mjs";import*as t from"node:net";import{Buffer as n}from"node:buffer";import*as r from"node:tls";import{URL as i}from"node:url";import{Agent as a}from"agent-base";import o from"node:assert";const s=e=>e.servername===void 0&&e.host&&!t.isIP(e.host)?{...e,servername:e.host}:e;var c=class extends a{static protocols=[`http`,`https`];proxy;proxyHeaders;connectOpts;constructor(e,t){super(t),this.options={path:void 0},this.proxy=typeof e==`string`?new i(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={ALPNProtocols:[`http/1.1`],...t?u(t,`headers`):null,host:n,port:r}}async connect(i,a){let{proxy:c}=this;if(!a.host)throw TypeError(`No "host" provided`);let d;d=c.protocol===`https:`?r.connect(s(this.connectOpts)):t.connect(this.connectOpts);let f=typeof this.proxyHeaders==`function`?this.proxyHeaders():{...this.proxyHeaders},p=t.isIPv6(a.host)?`[${a.host}]`:a.host,m=`CONNECT ${p}:${a.port} HTTP/1.1\r\n`;if(c.username||c.password){let e=`${decodeURIComponent(c.username)}:${decodeURIComponent(c.password)}`;f[`Proxy-Authorization`]=`Basic ${n.from(e).toString(`base64`)}`}f.Host=`${p}:${a.port}`,f[`Proxy-Connection`]||=this.keepAlive?`Keep-Alive`:`close`;for(let e of Object.keys(f))m+=`${e}: ${f[e]?.toString()}\r\n`;let h=e(d);d.write(`${m}\r\n`);let{connect:g,buffered:_}=await h;if(i.emit(`proxyConnect`,g),this.emit(`proxyConnect`,g,i),g.statusCode===200)return i.once(`socket`,l),a.secureEndpoint?r.connect({...u(s(a),`host`,`path`,`port`),socket:d}):d;d.destroy();let v=new t.Socket({writable:!1});return v.readable=!0,i.once(`socket`,e=>{o(e.listenerCount(`data`)>0),e.push(_),e.push(null)}),v}};function l(e){e.resume()}function u(e,...t){let n={},r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}export{c as HttpsProxyAgent};
2
+ //# sourceMappingURL=https-proxy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"https-proxy.mjs","names":["socket: net.Socket","headers: OutgoingHttpHeaders","key: keyof typeof obj"],"sources":["../src/https-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 { Agent } from \"agent-base\";\nimport assert from \"node:assert\";\nimport { Buffer } from \"node:buffer\";\nimport type * as http from \"node:http\";\nimport type { OutgoingHttpHeaders } from \"node:http\";\nimport * as net from \"node:net\";\nimport * as tls from \"node:tls\";\nimport { URL } from \"node:url\";\nimport { parseProxyResponse } from \"./parse-response\";\n\nconst setServernameFromNonIpHost = <\n T extends { host?: string; servername?: string }\n>(\n options: T\n) => {\n if (\n options.servername === undefined &&\n options.host &&\n !net.isIP(options.host)\n ) {\n return {\n ...options,\n servername: options.host\n };\n }\n return options;\n};\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 HttpsProxyAgentOptions<T> = ConnectOpts<T> &\n http.AgentOptions & {\n headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);\n };\n\n/**\n * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to\n * the specified \"HTTP(s) proxy server\" in order to proxy HTTPS requests.\n *\n * Outgoing HTTP requests are first tunneled through the proxy server using the\n * `CONNECT` HTTP request method to establish a connection to the proxy server,\n * and then the proxy server connects to the destination target and issues the\n * HTTP request from the proxy server.\n *\n * `https:` requests have their socket connection upgraded to TLS once\n * the connection to the proxy server has been established.\n */\nexport class HttpsProxyAgent<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?: HttpsProxyAgentOptions<Uri>) {\n super(opts);\n this.options = { path: undefined };\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 // Attempt to negotiate http/1.1 for proxy servers that support http/2\n ALPNProtocols: [\"http/1.1\"],\n ...(opts ? omit(opts, \"headers\") : null),\n host,\n port\n };\n }\n\n /**\n * Called when the node-core HTTP client library is creating a new HTTP request.\n */\n async connect(\n req: http.ClientRequest,\n opts: AgentConnectOpts\n ): Promise<net.Socket> {\n const { proxy } = this;\n\n if (!opts.host) {\n throw new TypeError('No \"host\" provided');\n }\n\n // Create a socket connection to the proxy server.\n let socket: net.Socket;\n if (proxy.protocol === \"https:\") {\n socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));\n } else {\n socket = net.connect(this.connectOpts);\n }\n\n const headers: OutgoingHttpHeaders =\n typeof this.proxyHeaders === \"function\"\n ? this.proxyHeaders()\n : { ...this.proxyHeaders };\n const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;\n let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\\r\\n`;\n\n // Inject the `Proxy-Authorization` header if necessary.\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 headers.Host = `${host}:${opts.port}`;\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 payload += `${name}: ${headers[name]?.toString()}\\r\\n`;\n }\n\n const proxyResponsePromise = parseProxyResponse(socket);\n\n socket.write(`${payload}\\r\\n`);\n\n const { connect, buffered } = await proxyResponsePromise;\n req.emit(\"proxyConnect\", connect);\n this.emit(\"proxyConnect\", connect, req);\n\n if (connect.statusCode === 200) {\n req.once(\"socket\", resume);\n\n if (opts.secureEndpoint) {\n // The proxy is connecting to a TLS server, so upgrade\n // this socket connection to a TLS connection.\n return tls.connect({\n ...omit(setServernameFromNonIpHost(opts), \"host\", \"path\", \"port\"),\n socket\n });\n }\n\n return socket;\n }\n\n // Some other status code that's not 200... need to re-play the HTTP\n // header \"data\" events onto the socket once the HTTP machinery is\n // attached so that the node core `http` can parse and handle the\n // error status code.\n\n // Close the original socket, and a new \"fake\" socket is returned\n // instead, so that the proxy doesn't get the HTTP request\n // written to it (which may contain `Authorization` headers or other\n // sensitive data).\n //\n // See: https://hackerone.com/reports/541502\n socket.destroy();\n\n const fakeSocket = new net.Socket({ writable: false });\n fakeSocket.readable = true;\n\n // Need to wait for the \"socket\" event to re-play the \"data\" events.\n req.once(\"socket\", (s: net.Socket) => {\n assert(s.listenerCount(\"data\") > 0);\n\n // Replay the \"buffered\" Buffer onto the fake `socket`, since at\n // this point the HTTP module machinery has been hooked up for\n // the user.\n s.push(buffered);\n s.push(null);\n });\n\n return fakeSocket;\n }\n}\n\nfunction resume(socket: net.Socket | tls.TLSSocket): void {\n socket.resume();\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":"kPA6BA,MAAM,EAGJ,GAGE,EAAQ,aAAe,IAAA,IACvB,EAAQ,MACR,CAAC,EAAI,KAAK,EAAQ,KAAK,CAEhB,CACL,GAAG,EACH,WAAY,EAAQ,KACrB,CAEI,EAiCT,IAAa,EAAb,cAAyD,CAAM,CAC7D,OAAO,UAAY,CAAC,OAAQ,QAAQ,CAEpC,MAEA,aAEA,YAEA,YAAY,EAAkB,EAAoC,CAChE,MAAM,EAAK,CACX,KAAK,QAAU,CAAE,KAAM,IAAA,GAAW,CAClC,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,CAEjB,cAAe,CAAC,WAAW,CAC3B,GAAI,EAAO,EAAK,EAAM,UAAU,CAAG,KACnC,OACA,OACD,CAMH,MAAM,QACJ,EACA,EACqB,CACrB,GAAM,CAAE,SAAU,KAElB,GAAI,CAAC,EAAK,KACR,MAAU,UAAU,qBAAqB,CAI3C,IAAIA,EACJ,AAGE,EAHE,EAAM,WAAa,SACZ,EAAI,QAAQ,EAA2B,KAAK,YAAY,CAAC,CAEzD,EAAI,QAAQ,KAAK,YAAY,CAGxC,IAAMC,EACJ,OAAO,KAAK,cAAiB,WACzB,KAAK,cAAc,CACnB,CAAE,GAAG,KAAK,aAAc,CACxB,EAAO,EAAI,OAAO,EAAK,KAAK,CAAG,IAAI,EAAK,KAAK,GAAK,EAAK,KACzD,EAAU,WAAW,EAAK,GAAG,EAAK,KAAK,eAG3C,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,EAAQ,KAAO,GAAG,EAAK,GAAG,EAAK,OAE/B,AACE,EAAQ,sBAAsB,KAAK,UAAY,aAAe,QAEhE,IAAK,IAAM,KAAQ,OAAO,KAAK,EAAQ,CACrC,GAAW,GAAG,EAAK,IAAI,EAAQ,IAAO,UAAU,CAAC,MAGnD,IAAM,EAAuB,EAAmB,EAAO,CAEvD,EAAO,MAAM,GAAG,EAAQ,MAAM,CAE9B,GAAM,CAAE,UAAS,YAAa,MAAM,EAIpC,GAHA,EAAI,KAAK,eAAgB,EAAQ,CACjC,KAAK,KAAK,eAAgB,EAAS,EAAI,CAEnC,EAAQ,aAAe,IAYzB,OAXA,EAAI,KAAK,SAAU,EAAO,CAEtB,EAAK,eAGA,EAAI,QAAQ,CACjB,GAAG,EAAK,EAA2B,EAAK,CAAE,OAAQ,OAAQ,OAAO,CACjE,SACD,CAAC,CAGG,EAcT,EAAO,SAAS,CAEhB,IAAM,EAAa,IAAI,EAAI,OAAO,CAAE,SAAU,GAAO,CAAC,CActD,MAbA,GAAW,SAAW,GAGtB,EAAI,KAAK,SAAW,GAAkB,CACpC,EAAO,EAAE,cAAc,OAAO,CAAG,EAAE,CAKnC,EAAE,KAAK,EAAS,CAChB,EAAE,KAAK,KAAK,EACZ,CAEK,IAIX,SAAS,EAAO,EAA0C,CACxD,EAAO,QAAQ,CAGjB,SAAS,EACP,EACA,GAAG,EAGH,CACA,IAAM,EAAM,EAAE,CAGVC,EACJ,IAAK,KAAO,EACL,EAAK,SAAS,EAAI,GACrB,EAAI,GAAO,EAAI,IAGnB,OAAO"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./agent-DKevd8Ll.cjs`),t=require(`./fetch-DXVSCX2B.cjs`),n=require(`./http-proxy-CJqbqeZN.cjs`),r=require(`./parse-response-BRlQF_8K.cjs`),i=require(`./https-proxy-k0GW_xX8.cjs`),a=require(`./proxy-agent-DMsOloiQ.cjs`),o=require(`./format-data-uri-C59EgrXn.cjs`),s=require(`./get-free-port-D9hjek4b.cjs`);exports.Agent=e.t,exports.HttpProxyAgent=n.t,exports.HttpsProxyAgent=i.t,exports.fetch=t.t,exports.fetchRequest=t.n,exports.formatDataURI=o.t,exports.getFreePort=s.t,exports.getProxyAgent=a.t,exports.makeDataUriToBuffer=o.n,exports.parseProxyResponse=r.t;
1
+ const e=require(`./agent.cjs`),t=require(`./http-proxy.cjs`),n=require(`./parse-response.cjs`),r=require(`./https-proxy.cjs`),i=require(`./proxy-agent.cjs`),a=require(`./fetch.cjs`),o=require(`./format-data-uri.cjs`),s=require(`./get-free-port.cjs`);exports.Agent=e.Agent,exports.HttpProxyAgent=t.HttpProxyAgent,exports.HttpsProxyAgent=r.HttpsProxyAgent,exports.fetch=a.fetch,exports.fetchRequest=a.fetchRequest,exports.formatDataURI=o.formatDataURI,exports.getFreePort=s.getFreePort,exports.getProxyAgent=i.getProxyAgent,exports.makeDataUriToBuffer=o.makeDataUriToBuffer,exports.parseProxyResponse=n.parseProxyResponse;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { n as AgentConnectOpts, t as Agent } from "./agent-Cc4PYJ-j.cjs";
2
- import { n as fetch, r as fetchRequest, t as FetchRequestOptions } from "./fetch-BYPFJG9Y.cjs";
3
- import { i as makeDataUriToBuffer, n as ParsedDataURI, r as formatDataURI, t as BufferConversionsInterface } from "./format-data-uri-B-rw3THu.cjs";
4
- import { t as getFreePort } from "./get-free-port-Bf-x1nt8.cjs";
5
- import { n as HttpProxyAgentOptions, t as HttpProxyAgent } from "./http-proxy-CzvOBKWd.cjs";
6
- import { n as HttpsProxyAgentOptions, t as HttpsProxyAgent } from "./https-proxy-B8w-jm17.cjs";
7
- import { n as parseProxyResponse, t as ConnectResponse } from "./parse-response-CS657Hki.cjs";
8
- import { t as getProxyAgent } from "./proxy-agent-CnWrJ59l.cjs";
1
+ import { Agent, AgentConnectOpts } from "./agent.cjs";
2
+ import { FetchRequestOptions, fetch, fetchRequest } from "./fetch.cjs";
3
+ import { BufferConversionsInterface, ParsedDataURI, formatDataURI, makeDataUriToBuffer } from "./format-data-uri.cjs";
4
+ import { getFreePort } from "./get-free-port.cjs";
5
+ import { HttpProxyAgent, HttpProxyAgentOptions } from "./http-proxy.cjs";
6
+ import { HttpsProxyAgent, HttpsProxyAgentOptions } from "./https-proxy.cjs";
7
+ import { ConnectResponse, parseProxyResponse } from "./parse-response.cjs";
8
+ import { getProxyAgent } from "./proxy-agent.cjs";
9
9
  export { Agent, AgentConnectOpts, BufferConversionsInterface, ConnectResponse, FetchRequestOptions, HttpProxyAgent, HttpProxyAgentOptions, HttpsProxyAgent, HttpsProxyAgentOptions, ParsedDataURI, fetch, fetchRequest, formatDataURI, getFreePort, getProxyAgent, makeDataUriToBuffer, parseProxyResponse };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { n as AgentConnectOpts, t as Agent } from "./agent-DXIpD4O5.mjs";
2
- import { n as fetch, r as fetchRequest, t as FetchRequestOptions } from "./fetch-D3masEhH.mjs";
3
- import { i as makeDataUriToBuffer, n as ParsedDataURI, r as formatDataURI, t as BufferConversionsInterface } from "./format-data-uri-D864kwXt.mjs";
4
- import { t as getFreePort } from "./get-free-port-BwvXPXFs.mjs";
5
- import { n as HttpProxyAgentOptions, t as HttpProxyAgent } from "./http-proxy-DuPPyvFw.mjs";
6
- import { n as HttpsProxyAgentOptions, t as HttpsProxyAgent } from "./https-proxy-f4-C_EL8.mjs";
7
- import { n as parseProxyResponse, t as ConnectResponse } from "./parse-response-ujHVHmwG.mjs";
8
- import { t as getProxyAgent } from "./proxy-agent-BrxQeFy2.mjs";
1
+ import { Agent, AgentConnectOpts } from "./agent.mjs";
2
+ import { FetchRequestOptions, fetch, fetchRequest } from "./fetch.mjs";
3
+ import { BufferConversionsInterface, ParsedDataURI, formatDataURI, makeDataUriToBuffer } from "./format-data-uri.mjs";
4
+ import { getFreePort } from "./get-free-port.mjs";
5
+ import { HttpProxyAgent, HttpProxyAgentOptions } from "./http-proxy.mjs";
6
+ import { HttpsProxyAgent, HttpsProxyAgentOptions } from "./https-proxy.mjs";
7
+ import { ConnectResponse, parseProxyResponse } from "./parse-response.mjs";
8
+ import { getProxyAgent } from "./proxy-agent.mjs";
9
9
  export { Agent, AgentConnectOpts, BufferConversionsInterface, ConnectResponse, FetchRequestOptions, HttpProxyAgent, HttpProxyAgentOptions, HttpsProxyAgent, HttpsProxyAgentOptions, ParsedDataURI, fetch, fetchRequest, formatDataURI, getFreePort, getProxyAgent, makeDataUriToBuffer, parseProxyResponse };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./agent-DrFvt4od.mjs";import{n as t,t as n}from"./fetch-DgPaAZTB.mjs";import{t as r}from"./http-proxy-ChUYEQ71.mjs";import{t as i}from"./parse-response-CGkjN9j0.mjs";import{t as a}from"./https-proxy-rNc_8MiC.mjs";import{t as o}from"./proxy-agent-uGI03t_I.mjs";import{n as s,t as c}from"./format-data-uri-WSwfftd0.mjs";import{t as l}from"./get-free-port-DvWNGhhy.mjs";export{e as Agent,r as HttpProxyAgent,a as HttpsProxyAgent,n as fetch,t as fetchRequest,c as formatDataURI,l as getFreePort,o as getProxyAgent,s as makeDataUriToBuffer,i as parseProxyResponse};
1
+ import{Agent as e}from"./agent.mjs";import{HttpProxyAgent as t}from"./http-proxy.mjs";import{parseProxyResponse as n}from"./parse-response.mjs";import{HttpsProxyAgent as r}from"./https-proxy.mjs";import{getProxyAgent as i}from"./proxy-agent.mjs";import{fetch as a,fetchRequest as o}from"./fetch.mjs";import{formatDataURI as s,makeDataUriToBuffer as c}from"./format-data-uri.mjs";import{getFreePort as l}from"./get-free-port.mjs";export{e as Agent,t as HttpProxyAgent,r as HttpsProxyAgent,a as fetch,o as fetchRequest,s as formatDataURI,l as getFreePort,i as getProxyAgent,c as makeDataUriToBuffer,n as parseProxyResponse};
@@ -1 +1,4 @@
1
- const e=require(`./parse-response-BRlQF_8K.cjs`);exports.parseProxyResponse=e.t;
1
+ const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`node:buffer`);async function n(e){return new Promise((n,r)=>{let i=0,a=[];function o(){let t=e.read();t?u(t):e.once(`readable`,o)}function s(){e.removeListener(`end`,c),e.removeListener(`error`,l),e.removeListener(`readable`,o)}function c(){s(),r(Error(`Proxy connection ended before receiving CONNECT response`))}function l(e){s(),r(e)}function u(c){a.push(c),i+=c.length;let l=t.Buffer.concat(a,i),u=l.indexOf(`\r
2
+ \r
3
+ `);if(u===-1){o();return}let d=l.subarray(0,u).toString(`ascii`).split(`\r
4
+ `),f=d.shift();if(!f)return e.destroy(),r(Error(`No header received from proxy CONNECT response`));let p=f.split(` `),m=+p[1],h=p.slice(2).join(` `),g={};for(let t of d){if(!t)continue;let n=t.indexOf(`:`);if(n===-1)return e.destroy(),r(Error(`Invalid header from proxy CONNECT response: "${t}"`));let i=t.slice(0,n).toLowerCase(),a=t.slice(n+1).trimStart(),o=g[i];typeof o==`string`?g[i]=[o,a]:Array.isArray(o)?o.push(a):g[i]=a}s(),n({connect:{statusCode:m,statusText:h,headers:g},buffered:l})}e.on(`error`,l),e.on(`end`,c),o()})}exports.parseProxyResponse=n;
@@ -1,2 +1,23 @@
1
- import { n as parseProxyResponse, t as ConnectResponse } from "./parse-response-CS657Hki.cjs";
2
- export { ConnectResponse, parseProxyResponse };
1
+ import { IncomingHttpHeaders } from "node:http";
2
+ import { Readable } from "node:stream";
3
+ import { Buffer } from "node:buffer";
4
+
5
+ //#region src/parse-response.d.ts
6
+ interface ConnectResponse {
7
+ statusCode: number;
8
+ statusText: string;
9
+ headers: IncomingHttpHeaders;
10
+ }
11
+ /**
12
+ * Parses the proxy CONNECT response from the given socket.
13
+ *
14
+ * @param socket - The socket to read the response from.
15
+ * @returns A promise that resolves to the CONNECT response and any buffered data.
16
+ */
17
+ declare function parseProxyResponse(socket: Readable): Promise<{
18
+ connect: ConnectResponse;
19
+ buffered: Buffer;
20
+ }>;
21
+ //#endregion
22
+ export { ConnectResponse, parseProxyResponse };
23
+ //# sourceMappingURL=parse-response.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-response.d.cts","names":[],"sources":["../src/parse-response.ts"],"sourcesContent":[],"mappings":";;;;;UAsBiB,eAAA;;EAAA,UAAA,EAAA,MAAe;EAYV,OAAA,EATX,mBAS6B;;;;;;;;iBAAlB,kBAAA,SACZ,WACP;WAAmB;YAA2B"}
@@ -1,2 +1,23 @@
1
- import { n as parseProxyResponse, t as ConnectResponse } from "./parse-response-ujHVHmwG.mjs";
2
- export { ConnectResponse, parseProxyResponse };
1
+ import { IncomingHttpHeaders } from "node:http";
2
+ import { Buffer } from "node:buffer";
3
+ import { Readable } from "node:stream";
4
+
5
+ //#region src/parse-response.d.ts
6
+ interface ConnectResponse {
7
+ statusCode: number;
8
+ statusText: string;
9
+ headers: IncomingHttpHeaders;
10
+ }
11
+ /**
12
+ * Parses the proxy CONNECT response from the given socket.
13
+ *
14
+ * @param socket - The socket to read the response from.
15
+ * @returns A promise that resolves to the CONNECT response and any buffered data.
16
+ */
17
+ declare function parseProxyResponse(socket: Readable): Promise<{
18
+ connect: ConnectResponse;
19
+ buffered: Buffer;
20
+ }>;
21
+ //#endregion
22
+ export { ConnectResponse, parseProxyResponse };
23
+ //# sourceMappingURL=parse-response.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-response.d.mts","names":[],"sources":["../src/parse-response.ts"],"sourcesContent":[],"mappings":";;;;;UAsBiB,eAAA;;EAAA,UAAA,EAAA,MAAe;EAYV,OAAA,EATX,mBAS6B;;;;;;;;iBAAlB,kBAAA,SACZ,WACP;WAAmB;YAA2B"}
@@ -1 +1,5 @@
1
- import{t as e}from"./parse-response-CGkjN9j0.mjs";export{e as parseProxyResponse};
1
+ import{Buffer as e}from"node:buffer";async function t(t){return new Promise((n,r)=>{let i=0,a=[];function o(){let e=t.read();e?u(e):t.once(`readable`,o)}function s(){t.removeListener(`end`,c),t.removeListener(`error`,l),t.removeListener(`readable`,o)}function c(){s(),r(Error(`Proxy connection ended before receiving CONNECT response`))}function l(e){s(),r(e)}function u(c){a.push(c),i+=c.length;let l=e.concat(a,i),u=l.indexOf(`\r
2
+ \r
3
+ `);if(u===-1){o();return}let d=l.subarray(0,u).toString(`ascii`).split(`\r
4
+ `),f=d.shift();if(!f)return t.destroy(),r(Error(`No header received from proxy CONNECT response`));let p=f.split(` `),m=+p[1],h=p.slice(2).join(` `),g={};for(let e of d){if(!e)continue;let n=e.indexOf(`:`);if(n===-1)return t.destroy(),r(Error(`Invalid header from proxy CONNECT response: "${e}"`));let i=e.slice(0,n).toLowerCase(),a=e.slice(n+1).trimStart(),o=g[i];typeof o==`string`?g[i]=[o,a]:Array.isArray(o)?o.push(a):g[i]=a}s(),n({connect:{statusCode:m,statusText:h,headers:g},buffered:l})}t.on(`error`,l),t.on(`end`,c),o()})}export{t as parseProxyResponse};
5
+ //# sourceMappingURL=parse-response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-response.mjs","names":["buffers: Buffer[]","headers: IncomingHttpHeaders"],"sources":["../src/parse-response.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 { Buffer } from \"node:buffer\";\nimport type { IncomingHttpHeaders } from \"node:http\";\nimport type { Readable } from \"node:stream\";\n\nexport interface ConnectResponse {\n statusCode: number;\n statusText: string;\n headers: IncomingHttpHeaders;\n}\n\n/**\n * Parses the proxy CONNECT response from the given socket.\n *\n * @param socket - The socket to read the response from.\n * @returns A promise that resolves to the CONNECT response and any buffered data.\n */\nexport async function parseProxyResponse(\n socket: Readable\n): Promise<{ connect: ConnectResponse; buffered: Buffer }> {\n return new Promise((resolve, reject) => {\n // we need to buffer any HTTP traffic that happens with the proxy before we get\n // the CONNECT response, so that if the response is anything other than an \"200\"\n // response code, then we can re-play the \"data\" events on the socket once the\n // HTTP parser is hooked up...\n let buffersLength = 0;\n const buffers: Buffer[] = [];\n\n function read() {\n const b = socket.read();\n if (b) ondata(b);\n else socket.once(\"readable\", read);\n }\n\n function cleanup() {\n socket.removeListener(\"end\", onend);\n socket.removeListener(\"error\", onerror);\n socket.removeListener(\"readable\", read);\n }\n\n function onend() {\n cleanup();\n reject(\n new Error(\"Proxy connection ended before receiving CONNECT response\")\n );\n }\n\n function onerror(err: Error) {\n cleanup();\n reject(err);\n }\n\n function ondata(b: Buffer) {\n buffers.push(b);\n buffersLength += b.length;\n\n const buffered = Buffer.concat(buffers, buffersLength);\n const endOfHeaders = buffered.indexOf(\"\\r\\n\\r\\n\");\n\n if (endOfHeaders === -1) {\n // keep buffering\n read();\n return;\n }\n\n const headerParts = buffered\n .subarray(0, endOfHeaders)\n .toString(\"ascii\")\n .split(\"\\r\\n\");\n const firstLine = headerParts.shift();\n if (!firstLine) {\n socket.destroy();\n return reject(\n new Error(\"No header received from proxy CONNECT response\")\n );\n }\n const firstLineParts = firstLine.split(\" \");\n const statusCode = +firstLineParts[1]!;\n const statusText = firstLineParts.slice(2).join(\" \");\n const headers: IncomingHttpHeaders = {};\n for (const header of headerParts) {\n if (!header) continue;\n const firstColon = header.indexOf(\":\");\n if (firstColon === -1) {\n socket.destroy();\n return reject(\n new Error(`Invalid header from proxy CONNECT response: \"${header}\"`)\n );\n }\n const key = header.slice(0, firstColon).toLowerCase();\n const value = header.slice(firstColon + 1).trimStart();\n const current = headers[key];\n if (typeof current === \"string\") {\n headers[key] = [current, value];\n } else if (Array.isArray(current)) {\n current.push(value);\n } else {\n headers[key] = value;\n }\n }\n\n cleanup();\n resolve({\n connect: {\n statusCode,\n statusText,\n headers\n },\n buffered\n });\n }\n\n socket.on(\"error\", onerror);\n socket.on(\"end\", onend);\n\n read();\n });\n}\n"],"mappings":"qCAkCA,eAAsB,EACpB,EACyD,CACzD,OAAO,IAAI,SAAS,EAAS,IAAW,CAKtC,IAAI,EAAgB,EACdA,EAAoB,EAAE,CAE5B,SAAS,GAAO,CACd,IAAM,EAAI,EAAO,MAAM,CACnB,EAAG,EAAO,EAAE,CACX,EAAO,KAAK,WAAY,EAAK,CAGpC,SAAS,GAAU,CACjB,EAAO,eAAe,MAAO,EAAM,CACnC,EAAO,eAAe,QAAS,EAAQ,CACvC,EAAO,eAAe,WAAY,EAAK,CAGzC,SAAS,GAAQ,CACf,GAAS,CACT,EACM,MAAM,2DAA2D,CACtE,CAGH,SAAS,EAAQ,EAAY,CAC3B,GAAS,CACT,EAAO,EAAI,CAGb,SAAS,EAAO,EAAW,CACzB,EAAQ,KAAK,EAAE,CACf,GAAiB,EAAE,OAEnB,IAAM,EAAW,EAAO,OAAO,EAAS,EAAc,CAChD,EAAe,EAAS,QAAQ;;EAAW,CAEjD,GAAI,IAAiB,GAAI,CAEvB,GAAM,CACN,OAGF,IAAM,EAAc,EACjB,SAAS,EAAG,EAAa,CACzB,SAAS,QAAQ,CACjB,MAAM;EAAO,CACV,EAAY,EAAY,OAAO,CACrC,GAAI,CAAC,EAEH,OADA,EAAO,SAAS,CACT,EACD,MAAM,iDAAiD,CAC5D,CAEH,IAAM,EAAiB,EAAU,MAAM,IAAI,CACrC,EAAa,CAAC,EAAe,GAC7B,EAAa,EAAe,MAAM,EAAE,CAAC,KAAK,IAAI,CAC9CC,EAA+B,EAAE,CACvC,IAAK,IAAM,KAAU,EAAa,CAChC,GAAI,CAAC,EAAQ,SACb,IAAM,EAAa,EAAO,QAAQ,IAAI,CACtC,GAAI,IAAe,GAEjB,OADA,EAAO,SAAS,CACT,EACD,MAAM,gDAAgD,EAAO,GAAG,CACrE,CAEH,IAAM,EAAM,EAAO,MAAM,EAAG,EAAW,CAAC,aAAa,CAC/C,EAAQ,EAAO,MAAM,EAAa,EAAE,CAAC,WAAW,CAChD,EAAU,EAAQ,GACpB,OAAO,GAAY,SACrB,EAAQ,GAAO,CAAC,EAAS,EAAM,CACtB,MAAM,QAAQ,EAAQ,CAC/B,EAAQ,KAAK,EAAM,CAEnB,EAAQ,GAAO,EAInB,GAAS,CACT,EAAQ,CACN,QAAS,CACP,aACA,aACA,UACD,CACD,WACD,CAAC,CAGJ,EAAO,GAAG,QAAS,EAAQ,CAC3B,EAAO,GAAG,MAAO,EAAM,CAEvB,GAAM,EACN"}
@@ -1 +1 @@
1
- require(`./agent-DKevd8Ll.cjs`),require(`./http-proxy-CJqbqeZN.cjs`),require(`./https-proxy-k0GW_xX8.cjs`);const e=require(`./proxy-agent-DMsOloiQ.cjs`);exports.getProxyAgent=e.t;
1
+ const e=require(`./http-proxy.cjs`),t=require(`./https-proxy.cjs`);function n(){let n=process.env.https_proxy||process.env.HTTPS_PROXY;if(n)return new t.HttpsProxyAgent(n);let r=process.env.http_proxy||process.env.HTTP_PROXY;if(r)return new e.HttpProxyAgent(r)}exports.getProxyAgent=n;
@@ -1,2 +1,13 @@
1
- import { t as getProxyAgent } from "./proxy-agent-CnWrJ59l.cjs";
2
- export { getProxyAgent };
1
+ import { Agent } from "node:https";
2
+
3
+ //#region src/proxy-agent.d.ts
4
+
5
+ /**
6
+ * If the http(s)_proxy environment variables is set, return a proxy agent.
7
+ *
8
+ * @returns The proxy agent or undefined if no proxy is set.
9
+ */
10
+ declare function getProxyAgent(): Agent | undefined;
11
+ //#endregion
12
+ export { getProxyAgent };
13
+ //# sourceMappingURL=proxy-agent.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-agent.d.cts","names":[],"sources":["../src/proxy-agent.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;iBAAgB,aAAA,CAAA,GAAiB"}
@@ -1,2 +1,13 @@
1
- import { t as getProxyAgent } from "./proxy-agent-BrxQeFy2.mjs";
2
- export { getProxyAgent };
1
+ import { Agent } from "node:https";
2
+
3
+ //#region src/proxy-agent.d.ts
4
+
5
+ /**
6
+ * If the http(s)_proxy environment variables is set, return a proxy agent.
7
+ *
8
+ * @returns The proxy agent or undefined if no proxy is set.
9
+ */
10
+ declare function getProxyAgent(): Agent | undefined;
11
+ //#endregion
12
+ export { getProxyAgent };
13
+ //# sourceMappingURL=proxy-agent.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-agent.d.mts","names":[],"sources":["../src/proxy-agent.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;iBAAgB,aAAA,CAAA,GAAiB"}
@@ -1 +1,2 @@
1
- import"./agent-DrFvt4od.mjs";import"./http-proxy-ChUYEQ71.mjs";import"./https-proxy-rNc_8MiC.mjs";import{t as e}from"./proxy-agent-uGI03t_I.mjs";export{e as getProxyAgent};
1
+ import{HttpProxyAgent as e}from"./http-proxy.mjs";import{HttpsProxyAgent as t}from"./https-proxy.mjs";function n(){let n=process.env.https_proxy||process.env.HTTPS_PROXY;if(n)return new t(n);let r=process.env.http_proxy||process.env.HTTP_PROXY;if(r)return new e(r)}export{n as getProxyAgent};
2
+ //# sourceMappingURL=proxy-agent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy-agent.mjs","names":[],"sources":["../src/proxy-agent.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 { Agent } from \"node:https\";\nimport { HttpProxyAgent } from \"./http-proxy\";\nimport { HttpsProxyAgent } from \"./https-proxy\";\n\n/**\n * If the http(s)_proxy environment variables is set, return a proxy agent.\n *\n * @returns The proxy agent or undefined if no proxy is set.\n */\nexport function getProxyAgent(): Agent | undefined {\n const httpsProxy = process.env.https_proxy || process.env.HTTPS_PROXY;\n if (httpsProxy) {\n return new HttpsProxyAgent(httpsProxy);\n }\n\n const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY;\n if (httpProxy) {\n return new HttpProxyAgent(httpProxy);\n }\n\n return undefined;\n}\n"],"mappings":"sGA2BA,SAAgB,GAAmC,CACjD,IAAM,EAAa,QAAQ,IAAI,aAAe,QAAQ,IAAI,YAC1D,GAAI,EACF,OAAO,IAAI,EAAgB,EAAW,CAGxC,IAAM,EAAY,QAAQ,IAAI,YAAc,QAAQ,IAAI,WACxD,GAAI,EACF,OAAO,IAAI,EAAe,EAAU"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-null.cjs`),t=require(`./is-undefined.cjs`),n=require(`./is-empty.cjs`),r=require(`./is-boolean.cjs`),i=require(`./is-buffer.cjs`);require(`./type-detect.cjs`),require(`./is-collection.cjs`);const a=require(`./is-string.cjs`),o=require(`./is-set.cjs`),s=require(`./is-set-string.cjs`);
@@ -0,0 +1 @@
1
+ import{isNull as e}from"./is-null.mjs";import{isUndefined as t}from"./is-undefined.mjs";import{isEmpty as n}from"./is-empty.mjs";import{isBoolean as r}from"./is-boolean.mjs";import{isBufferExists as i}from"./is-buffer.mjs";import"./type-detect.mjs";import"./is-collection.mjs";import{isString as a}from"./is-string.mjs";import{isSet as o}from"./is-set.mjs";import{isSetString as s}from"./is-set-string.mjs";export{};
@@ -0,0 +1 @@
1
+ const e=e=>{try{return e instanceof Boolean||typeof e==`boolean`||!!e===e}catch{return!1}};exports.isBoolean=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>{try{return e instanceof Boolean||typeof e==`boolean`||!!e===e}catch{return!1}};export{e as isBoolean};
2
+ //# sourceMappingURL=is-boolean.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-boolean.mjs","names":[],"sources":["../../../../type-checks/src/is-boolean.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 * Check if the provided value's type is `boolean`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `boolean`\n */\nexport const isBoolean = (value: unknown): value is boolean => {\n try {\n return (\n value instanceof Boolean ||\n typeof value === \"boolean\" ||\n Boolean(value) === value\n );\n } catch {\n return false;\n }\n};\n"],"mappings":"AAwBA,MAAa,EAAa,GAAqC,CAC7D,GAAI,CACF,OACE,aAAiB,SACjB,OAAO,GAAU,WACjB,EAAQ,IAAW,OAEf,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=typeof Buffer<`u`,t=e?Buffer.isBuffer.bind(Buffer):function(e){return!1};exports.isBufferExists=e;
@@ -0,0 +1,2 @@
1
+ const e=typeof Buffer<`u`;e&&Buffer.isBuffer.bind(Buffer);export{e as isBufferExists};
2
+ //# sourceMappingURL=is-buffer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.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 const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n"],"mappings":"AAkBA,MAAa,EAAiB,OAAO,OAAW,IAKA,GAC5C,OAAO,SAAS,KAAK,OAAO"}
@@ -0,0 +1 @@
1
+ require(`./type-detect.cjs`);
@@ -0,0 +1 @@
1
+ import"./type-detect.mjs";export{};
@@ -0,0 +1 @@
1
+ const e=require(`./is-null.cjs`),t=require(`./is-undefined.cjs`),n=n=>{try{return t.isUndefined(n)||e.isNull(n)}catch{return!1}};exports.isEmpty=n;
@@ -0,0 +1,2 @@
1
+ import{isNull as e}from"./is-null.mjs";import{isUndefined as t}from"./is-undefined.mjs";const n=n=>{try{return t(n)||e(n)}catch{return!1}};export{n as isEmpty};
2
+ //# sourceMappingURL=is-empty.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.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 { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":"wFA+BA,MAAa,EAAW,GAAmB,CACzC,GAAI,CACF,OAAO,EAAY,EAAM,EAAI,EAAO,EAAM,MACpC,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=e=>{try{return e===null}catch{return!1}};exports.isNull=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>{try{return e===null}catch{return!1}};export{e as isNull};
2
+ //# sourceMappingURL=is-null.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-null.mjs","names":[],"sources":["../../../../type-checks/src/is-null.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 const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n"],"mappings":"AAkBA,MAAa,EAAU,GAAkC,CACvD,GAAI,CACF,OAAO,IAAU,UACX,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-string.cjs`),t=require(`./is-set.cjs`),n=n=>{try{return t.isSet(n)&&e.isString(n)&&n.length>0}catch{return!1}};exports.isSetString=n;
@@ -0,0 +1,2 @@
1
+ import{isString as e}from"./is-string.mjs";import{isSet as t}from"./is-set.mjs";const n=n=>{try{return t(n)&&e(n)&&n.length>0}catch{return!1}};export{n as isSetString};
2
+ //# sourceMappingURL=is-set-string.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-set-string.mjs","names":[],"sources":["../../../../type-checks/src/is-set-string.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 { isSet } from \"./is-set\";\nimport { isString } from \"./is-string\";\n\n/**\n * Determine if the type is string and is not empty (length greater than zero)\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `string` and length greater than zero\n */\nexport const isSetString = (value: unknown): value is NonNullable<string> => {\n try {\n return isSet(value) && isString(value) && value.length > 0;\n } catch {\n return false;\n }\n};\n"],"mappings":"gFA2BA,MAAa,EAAe,GAAiD,CAC3E,GAAI,CACF,OAAO,EAAM,EAAM,EAAI,EAAS,EAAM,EAAI,EAAM,OAAS,OACnD,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=require(`./is-empty.cjs`),t=t=>{try{return!e.isEmpty(t)}catch{return!1}};exports.isSet=t;
@@ -0,0 +1,2 @@
1
+ import{isEmpty as e}from"./is-empty.mjs";const t=t=>{try{return!e(t)}catch{return!1}};export{t as isSet};
2
+ //# sourceMappingURL=is-set.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-set.mjs","names":[],"sources":["../../../../type-checks/src/is-set.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 { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":"yCA0BA,MAAa,EAAS,GAAkD,CACtE,GAAI,CACF,MAAO,CAAC,EAAQ,EAAM,MAChB,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=e=>{try{return typeof e==`string`}catch{return!1}};exports.isString=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>{try{return typeof e==`string`}catch{return!1}};export{e as isString};
2
+ //# sourceMappingURL=is-string.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.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 const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":"AAkBA,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OAAO,OAAO,GAAU,cAClB,CACN,MAAO"}
@@ -0,0 +1 @@
1
+ const e=e=>e===void 0;exports.isUndefined=e;
@@ -0,0 +1,2 @@
1
+ const e=e=>e===void 0;export{e as isUndefined};
2
+ //# sourceMappingURL=is-undefined.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.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 const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n"],"mappings":"AAkBA,MAAa,EAAe,GACnB,IAAU,IAAA"}
@@ -0,0 +1 @@
1
+ require(`./is-buffer.cjs`);const e=(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);
@@ -0,0 +1,2 @@
1
+ import"./is-buffer.mjs";(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);export{};
2
+ //# sourceMappingURL=type-detect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.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 { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n"],"mappings":"yBAoBsB,IAChB,OAAO,YAAe,UAG1B,OAAO,eAAe,EAAK,yBAA0B,CACnD,KAAM,CACJ,OAAO,MAET,aAAc,GACf,CAAC,CAPO,aAeR,OAAO,UAAU"}
@@ -0,0 +1 @@
1
+ function e(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}exports.isValidURL=e;
@@ -0,0 +1,2 @@
1
+ function e(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}export{e as isValidURL};
2
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../url/src/helpers.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"],"mappings":"AA4CA,SAAgB,EAAW,EAAsB,CAC/C,MAAO,iFAAiF,KACtF,EACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/http",
3
- "version": "0.12.14",
3
+ "version": "0.12.15",
4
4
  "type": "module",
5
5
  "description": "A package containing HTTP communication utilities used by Storm Software.",
6
6
  "repository": {
@@ -43,16 +43,16 @@
43
43
  },
44
44
  "types": "./dist/index.d.cts",
45
45
  "dependencies": {
46
- "@stryke/type-checks": "^0.5.9",
47
- "@stryke/url": "^0.3.15",
46
+ "@stryke/type-checks": "^0.5.10",
47
+ "@stryke/url": "^0.3.16",
48
48
  "defu": "^6.1.4",
49
49
  "undici": "^7.16.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/node": "^24.10.1",
53
- "tsdown": "^0.17.1",
52
+ "@types/node": "^24.10.4",
53
+ "tsdown": "^0.17.2",
54
54
  "undici-types": "^7.16.0"
55
55
  },
56
56
  "publishConfig": { "access": "public" },
57
- "gitHead": "fd38508c876b697a52a0e27df1478b41ae011583"
57
+ "gitHead": "8f2e484743eb3ce54929e99096ca2ea188b4730e"
58
58
  }
@@ -1,40 +0,0 @@
1
- import * as http from "node:http";
2
- import * as net from "node:net";
3
- import { Duplex } from "node:stream";
4
- import * as tls from "node:tls";
5
-
6
- //#region src/agent.d.ts
7
- interface HttpConnectOpts extends net.TcpNetConnectOpts {
8
- secureEndpoint: false;
9
- protocol?: string;
10
- }
11
- interface HttpsConnectOpts extends tls.ConnectionOptions {
12
- secureEndpoint: true;
13
- protocol?: string;
14
- port: number;
15
- }
16
- type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
17
- declare const SYMBOL_INTERNAL: unique symbol;
18
- declare abstract class Agent extends http.Agent {
19
- private [SYMBOL_INTERNAL];
20
- options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
21
- keepAlive: boolean;
22
- constructor(opts?: http.AgentOptions);
23
- abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
24
- /**
25
- * Determine whether this is an `http` or `https` request.
26
- */
27
- isSecureEndpoint(options?: AgentConnectOpts): boolean;
28
- private incrementSockets;
29
- private decrementSockets;
30
- getName(options?: AgentConnectOpts): string;
31
- createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
32
- createConnection(): Duplex;
33
- get defaultPort(): number;
34
- set defaultPort(v: number);
35
- get protocol(): string;
36
- set protocol(v: string);
37
- }
38
- //#endregion
39
- export { AgentConnectOpts as n, Agent as t };
40
- //# sourceMappingURL=agent-Cc4PYJ-j.d.cts.map