@depup/mswjs__interceptors 0.41.3-depup.0

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 (248) hide show
  1. package/ClientRequest/package.json +11 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +31 -0
  4. package/RemoteHttpInterceptor/package.json +11 -0
  5. package/WebSocket/package.json +12 -0
  6. package/XMLHttpRequest/package.json +12 -0
  7. package/changes.json +10 -0
  8. package/fetch/package.json +12 -0
  9. package/lib/browser/Interceptor-Deczogc8.d.cts +65 -0
  10. package/lib/browser/Interceptor-gqKgs-aF.d.mts +65 -0
  11. package/lib/browser/XMLHttpRequest-BACqefB-.cjs +761 -0
  12. package/lib/browser/XMLHttpRequest-BACqefB-.cjs.map +1 -0
  13. package/lib/browser/XMLHttpRequest-BvxZV0WU.mjs +756 -0
  14. package/lib/browser/XMLHttpRequest-BvxZV0WU.mjs.map +1 -0
  15. package/lib/browser/bufferUtils-BiiO6HZv.mjs +20 -0
  16. package/lib/browser/bufferUtils-BiiO6HZv.mjs.map +1 -0
  17. package/lib/browser/bufferUtils-Uc0eRItL.cjs +38 -0
  18. package/lib/browser/bufferUtils-Uc0eRItL.cjs.map +1 -0
  19. package/lib/browser/createRequestId-Cs4oXfa1.cjs +205 -0
  20. package/lib/browser/createRequestId-Cs4oXfa1.cjs.map +1 -0
  21. package/lib/browser/createRequestId-DQcIlohW.mjs +170 -0
  22. package/lib/browser/createRequestId-DQcIlohW.mjs.map +1 -0
  23. package/lib/browser/fetch-DdKEdDOR.mjs +248 -0
  24. package/lib/browser/fetch-DdKEdDOR.mjs.map +1 -0
  25. package/lib/browser/fetch-U3v3Y4ap.cjs +253 -0
  26. package/lib/browser/fetch-U3v3Y4ap.cjs.map +1 -0
  27. package/lib/browser/getRawRequest-BTaNLFr0.mjs +218 -0
  28. package/lib/browser/getRawRequest-BTaNLFr0.mjs.map +1 -0
  29. package/lib/browser/getRawRequest-zx8rUJL2.cjs +259 -0
  30. package/lib/browser/getRawRequest-zx8rUJL2.cjs.map +1 -0
  31. package/lib/browser/glossary-BdLS4k1H.d.cts +70 -0
  32. package/lib/browser/glossary-DYwOrogs.d.mts +70 -0
  33. package/lib/browser/handleRequest-CvX2G-Lz.cjs +189 -0
  34. package/lib/browser/handleRequest-CvX2G-Lz.cjs.map +1 -0
  35. package/lib/browser/handleRequest-D7kpTI5U.mjs +178 -0
  36. package/lib/browser/handleRequest-D7kpTI5U.mjs.map +1 -0
  37. package/lib/browser/hasConfigurableGlobal-BvCTG97d.cjs +45 -0
  38. package/lib/browser/hasConfigurableGlobal-BvCTG97d.cjs.map +1 -0
  39. package/lib/browser/hasConfigurableGlobal-npXitu1-.mjs +33 -0
  40. package/lib/browser/hasConfigurableGlobal-npXitu1-.mjs.map +1 -0
  41. package/lib/browser/index.cjs +70 -0
  42. package/lib/browser/index.cjs.map +1 -0
  43. package/lib/browser/index.d.cts +96 -0
  44. package/lib/browser/index.d.mts +96 -0
  45. package/lib/browser/index.mjs +56 -0
  46. package/lib/browser/index.mjs.map +1 -0
  47. package/lib/browser/interceptors/WebSocket/index.cjs +622 -0
  48. package/lib/browser/interceptors/WebSocket/index.cjs.map +1 -0
  49. package/lib/browser/interceptors/WebSocket/index.d.cts +277 -0
  50. package/lib/browser/interceptors/WebSocket/index.d.mts +277 -0
  51. package/lib/browser/interceptors/WebSocket/index.mjs +615 -0
  52. package/lib/browser/interceptors/WebSocket/index.mjs.map +1 -0
  53. package/lib/browser/interceptors/XMLHttpRequest/index.cjs +7 -0
  54. package/lib/browser/interceptors/XMLHttpRequest/index.d.cts +15 -0
  55. package/lib/browser/interceptors/XMLHttpRequest/index.d.mts +15 -0
  56. package/lib/browser/interceptors/XMLHttpRequest/index.mjs +7 -0
  57. package/lib/browser/interceptors/fetch/index.cjs +6 -0
  58. package/lib/browser/interceptors/fetch/index.d.cts +13 -0
  59. package/lib/browser/interceptors/fetch/index.d.mts +13 -0
  60. package/lib/browser/interceptors/fetch/index.mjs +6 -0
  61. package/lib/browser/presets/browser.cjs +17 -0
  62. package/lib/browser/presets/browser.cjs.map +1 -0
  63. package/lib/browser/presets/browser.d.cts +12 -0
  64. package/lib/browser/presets/browser.d.mts +14 -0
  65. package/lib/browser/presets/browser.mjs +17 -0
  66. package/lib/browser/presets/browser.mjs.map +1 -0
  67. package/lib/browser/resolveWebSocketUrl-6K6EgqsA.cjs +31 -0
  68. package/lib/browser/resolveWebSocketUrl-6K6EgqsA.cjs.map +1 -0
  69. package/lib/browser/resolveWebSocketUrl-C83-x9iE.mjs +25 -0
  70. package/lib/browser/resolveWebSocketUrl-C83-x9iE.mjs.map +1 -0
  71. package/lib/node/BatchInterceptor-3LnAnLTx.cjs +49 -0
  72. package/lib/node/BatchInterceptor-3LnAnLTx.cjs.map +1 -0
  73. package/lib/node/BatchInterceptor-D7mXzHcQ.d.mts +26 -0
  74. package/lib/node/BatchInterceptor-DFaBPilf.mjs +44 -0
  75. package/lib/node/BatchInterceptor-DFaBPilf.mjs.map +1 -0
  76. package/lib/node/BatchInterceptor-D_YqR8qU.d.cts +26 -0
  77. package/lib/node/ClientRequest-2rDe54Ui.cjs +1043 -0
  78. package/lib/node/ClientRequest-2rDe54Ui.cjs.map +1 -0
  79. package/lib/node/ClientRequest-Ca8Qykuv.mjs +1034 -0
  80. package/lib/node/ClientRequest-Ca8Qykuv.mjs.map +1 -0
  81. package/lib/node/Interceptor-DEazpLJd.d.mts +133 -0
  82. package/lib/node/Interceptor-DJ2akVWI.d.cts +133 -0
  83. package/lib/node/RemoteHttpInterceptor.cjs +154 -0
  84. package/lib/node/RemoteHttpInterceptor.cjs.map +1 -0
  85. package/lib/node/RemoteHttpInterceptor.d.cts +39 -0
  86. package/lib/node/RemoteHttpInterceptor.d.mts +39 -0
  87. package/lib/node/RemoteHttpInterceptor.mjs +152 -0
  88. package/lib/node/RemoteHttpInterceptor.mjs.map +1 -0
  89. package/lib/node/XMLHttpRequest-B7kJdYYI.cjs +763 -0
  90. package/lib/node/XMLHttpRequest-B7kJdYYI.cjs.map +1 -0
  91. package/lib/node/XMLHttpRequest-C8dIZpds.mjs +757 -0
  92. package/lib/node/XMLHttpRequest-C8dIZpds.mjs.map +1 -0
  93. package/lib/node/bufferUtils-DiCTqG-7.cjs +38 -0
  94. package/lib/node/bufferUtils-DiCTqG-7.cjs.map +1 -0
  95. package/lib/node/bufferUtils-_8XfKIfX.mjs +20 -0
  96. package/lib/node/bufferUtils-_8XfKIfX.mjs.map +1 -0
  97. package/lib/node/chunk-CbDLau6x.cjs +34 -0
  98. package/lib/node/fetch-BmXpK10r.cjs +272 -0
  99. package/lib/node/fetch-BmXpK10r.cjs.map +1 -0
  100. package/lib/node/fetch-G1DVwDKG.mjs +265 -0
  101. package/lib/node/fetch-G1DVwDKG.mjs.map +1 -0
  102. package/lib/node/fetchUtils-BaY5iWXw.cjs +419 -0
  103. package/lib/node/fetchUtils-BaY5iWXw.cjs.map +1 -0
  104. package/lib/node/fetchUtils-CoU35g3M.mjs +359 -0
  105. package/lib/node/fetchUtils-CoU35g3M.mjs.map +1 -0
  106. package/lib/node/getRawRequest-BavnMWh_.cjs +36 -0
  107. package/lib/node/getRawRequest-BavnMWh_.cjs.map +1 -0
  108. package/lib/node/getRawRequest-DnwmXyOW.mjs +24 -0
  109. package/lib/node/getRawRequest-DnwmXyOW.mjs.map +1 -0
  110. package/lib/node/glossary-BLKRyLBd.cjs +12 -0
  111. package/lib/node/glossary-BLKRyLBd.cjs.map +1 -0
  112. package/lib/node/glossary-glQBRnVD.mjs +6 -0
  113. package/lib/node/glossary-glQBRnVD.mjs.map +1 -0
  114. package/lib/node/handleRequest-Bb7Y-XLw.cjs +220 -0
  115. package/lib/node/handleRequest-Bb7Y-XLw.cjs.map +1 -0
  116. package/lib/node/handleRequest-Y97UwBbF.mjs +190 -0
  117. package/lib/node/handleRequest-Y97UwBbF.mjs.map +1 -0
  118. package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs +26 -0
  119. package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs.map +1 -0
  120. package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs +20 -0
  121. package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs.map +1 -0
  122. package/lib/node/index-BMbJ8FXL.d.cts +113 -0
  123. package/lib/node/index-C0YAQ36w.d.mts +113 -0
  124. package/lib/node/index.cjs +54 -0
  125. package/lib/node/index.cjs.map +1 -0
  126. package/lib/node/index.d.cts +75 -0
  127. package/lib/node/index.d.mts +75 -0
  128. package/lib/node/index.mjs +40 -0
  129. package/lib/node/index.mjs.map +1 -0
  130. package/lib/node/interceptors/ClientRequest/index.cjs +6 -0
  131. package/lib/node/interceptors/ClientRequest/index.d.cts +2 -0
  132. package/lib/node/interceptors/ClientRequest/index.d.mts +3 -0
  133. package/lib/node/interceptors/ClientRequest/index.mjs +6 -0
  134. package/lib/node/interceptors/XMLHttpRequest/index.cjs +6 -0
  135. package/lib/node/interceptors/XMLHttpRequest/index.d.cts +14 -0
  136. package/lib/node/interceptors/XMLHttpRequest/index.d.mts +14 -0
  137. package/lib/node/interceptors/XMLHttpRequest/index.mjs +6 -0
  138. package/lib/node/interceptors/fetch/index.cjs +5 -0
  139. package/lib/node/interceptors/fetch/index.d.cts +12 -0
  140. package/lib/node/interceptors/fetch/index.d.mts +12 -0
  141. package/lib/node/interceptors/fetch/index.mjs +5 -0
  142. package/lib/node/node-DwCc6iuP.mjs +27 -0
  143. package/lib/node/node-DwCc6iuP.mjs.map +1 -0
  144. package/lib/node/node-dKdAf3tC.cjs +39 -0
  145. package/lib/node/node-dKdAf3tC.cjs.map +1 -0
  146. package/lib/node/presets/node.cjs +22 -0
  147. package/lib/node/presets/node.cjs.map +1 -0
  148. package/lib/node/presets/node.d.cts +13 -0
  149. package/lib/node/presets/node.d.mts +15 -0
  150. package/lib/node/presets/node.mjs +22 -0
  151. package/lib/node/presets/node.mjs.map +1 -0
  152. package/lib/node/utils/node/index.cjs +4 -0
  153. package/lib/node/utils/node/index.d.cts +16 -0
  154. package/lib/node/utils/node/index.d.mts +16 -0
  155. package/lib/node/utils/node/index.mjs +3 -0
  156. package/package.json +204 -0
  157. package/presets/browser/package.json +5 -0
  158. package/presets/node/package.json +11 -0
  159. package/src/BatchInterceptor.test.ts +255 -0
  160. package/src/BatchInterceptor.ts +95 -0
  161. package/src/Interceptor.test.ts +205 -0
  162. package/src/Interceptor.ts +249 -0
  163. package/src/InterceptorError.ts +7 -0
  164. package/src/RemoteHttpInterceptor.ts +251 -0
  165. package/src/RequestController.test.ts +104 -0
  166. package/src/RequestController.ts +109 -0
  167. package/src/createRequestId.test.ts +7 -0
  168. package/src/createRequestId.ts +9 -0
  169. package/src/getRawRequest.ts +21 -0
  170. package/src/glossary.ts +37 -0
  171. package/src/index.ts +15 -0
  172. package/src/interceptors/ClientRequest/MockHttpSocket.ts +724 -0
  173. package/src/interceptors/ClientRequest/agents.ts +110 -0
  174. package/src/interceptors/ClientRequest/index.test.ts +75 -0
  175. package/src/interceptors/ClientRequest/index.ts +193 -0
  176. package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.test.ts +54 -0
  177. package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +45 -0
  178. package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.test.ts +427 -0
  179. package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +268 -0
  180. package/src/interceptors/ClientRequest/utils/parserUtils.ts +48 -0
  181. package/src/interceptors/ClientRequest/utils/recordRawHeaders.test.ts +258 -0
  182. package/src/interceptors/ClientRequest/utils/recordRawHeaders.ts +262 -0
  183. package/src/interceptors/Socket/MockSocket.test.ts +264 -0
  184. package/src/interceptors/Socket/MockSocket.ts +58 -0
  185. package/src/interceptors/Socket/utils/baseUrlFromConnectionOptions.ts +26 -0
  186. package/src/interceptors/Socket/utils/normalizeSocketWriteArgs.test.ts +52 -0
  187. package/src/interceptors/Socket/utils/normalizeSocketWriteArgs.ts +33 -0
  188. package/src/interceptors/WebSocket/WebSocketClassTransport.ts +116 -0
  189. package/src/interceptors/WebSocket/WebSocketClientConnection.ts +152 -0
  190. package/src/interceptors/WebSocket/WebSocketOverride.ts +252 -0
  191. package/src/interceptors/WebSocket/WebSocketServerConnection.ts +420 -0
  192. package/src/interceptors/WebSocket/WebSocketTransport.ts +39 -0
  193. package/src/interceptors/WebSocket/index.ts +191 -0
  194. package/src/interceptors/WebSocket/utils/bindEvent.test.ts +27 -0
  195. package/src/interceptors/WebSocket/utils/bindEvent.ts +21 -0
  196. package/src/interceptors/WebSocket/utils/events.test.ts +101 -0
  197. package/src/interceptors/WebSocket/utils/events.ts +94 -0
  198. package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +746 -0
  199. package/src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts +121 -0
  200. package/src/interceptors/XMLHttpRequest/index.ts +61 -0
  201. package/src/interceptors/XMLHttpRequest/polyfills/EventPolyfill.ts +51 -0
  202. package/src/interceptors/XMLHttpRequest/polyfills/ProgressEventPolyfill.ts +17 -0
  203. package/src/interceptors/XMLHttpRequest/utils/concatArrayBuffer.ts +12 -0
  204. package/src/interceptors/XMLHttpRequest/utils/concateArrayBuffer.test.ts +12 -0
  205. package/src/interceptors/XMLHttpRequest/utils/createEvent.test.ts +26 -0
  206. package/src/interceptors/XMLHttpRequest/utils/createEvent.ts +41 -0
  207. package/src/interceptors/XMLHttpRequest/utils/createResponse.ts +49 -0
  208. package/src/interceptors/XMLHttpRequest/utils/getBodyByteLength.test.ts +164 -0
  209. package/src/interceptors/XMLHttpRequest/utils/getBodyByteLength.ts +16 -0
  210. package/src/interceptors/XMLHttpRequest/utils/isDomParserSupportedType.ts +14 -0
  211. package/src/interceptors/fetch/index.ts +214 -0
  212. package/src/interceptors/fetch/utils/brotli-decompress.browser.ts +14 -0
  213. package/src/interceptors/fetch/utils/brotli-decompress.ts +31 -0
  214. package/src/interceptors/fetch/utils/createNetworkError.ts +5 -0
  215. package/src/interceptors/fetch/utils/decompression.ts +85 -0
  216. package/src/interceptors/fetch/utils/followRedirect.ts +114 -0
  217. package/src/presets/browser.ts +11 -0
  218. package/src/presets/node.ts +13 -0
  219. package/src/utils/bufferUtils.test.ts +21 -0
  220. package/src/utils/bufferUtils.ts +22 -0
  221. package/src/utils/canParseUrl.ts +13 -0
  222. package/src/utils/cloneObject.test.ts +94 -0
  223. package/src/utils/cloneObject.ts +36 -0
  224. package/src/utils/createProxy.test.ts +164 -0
  225. package/src/utils/createProxy.ts +104 -0
  226. package/src/utils/emitAsync.ts +25 -0
  227. package/src/utils/fetchUtils.ts +119 -0
  228. package/src/utils/findPropertySource.test.ts +27 -0
  229. package/src/utils/findPropertySource.ts +20 -0
  230. package/src/utils/getCleanUrl.test.ts +32 -0
  231. package/src/utils/getCleanUrl.ts +6 -0
  232. package/src/utils/getUrlByRequestOptions.test.ts +163 -0
  233. package/src/utils/getUrlByRequestOptions.ts +152 -0
  234. package/src/utils/getValueBySymbol.test.ts +14 -0
  235. package/src/utils/getValueBySymbol.ts +19 -0
  236. package/src/utils/handleRequest.ts +205 -0
  237. package/src/utils/hasConfigurableGlobal.test.ts +83 -0
  238. package/src/utils/hasConfigurableGlobal.ts +34 -0
  239. package/src/utils/isNodeLikeError.ts +13 -0
  240. package/src/utils/isObject.test.ts +21 -0
  241. package/src/utils/isObject.ts +8 -0
  242. package/src/utils/isPropertyAccessible.ts +19 -0
  243. package/src/utils/nextTick.ts +11 -0
  244. package/src/utils/node/index.ts +39 -0
  245. package/src/utils/parseJson.test.ts +10 -0
  246. package/src/utils/parseJson.ts +12 -0
  247. package/src/utils/resolveWebSocketUrl.ts +45 -0
  248. package/src/utils/responseUtils.ts +59 -0
@@ -0,0 +1,113 @@
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-DEazpLJd.mjs";
2
+ import net from "node:net";
3
+
4
+ //#region src/interceptors/Socket/utils/normalizeSocketWriteArgs.d.ts
5
+ type WriteCallback = (error?: Error | null) => void;
6
+ //#endregion
7
+ //#region src/interceptors/Socket/MockSocket.d.ts
8
+ interface MockSocketOptions {
9
+ write: (chunk: Buffer | string, encoding: BufferEncoding | undefined, callback?: WriteCallback) => void;
10
+ read: (chunk: Buffer, encoding: BufferEncoding | undefined) => void;
11
+ }
12
+ declare class MockSocket extends net.Socket {
13
+ protected readonly options: MockSocketOptions;
14
+ connecting: boolean;
15
+ constructor(options: MockSocketOptions);
16
+ connect(): this;
17
+ write(...args: Array<unknown>): boolean;
18
+ end(...args: Array<unknown>): this;
19
+ push(chunk: any, encoding?: BufferEncoding): boolean;
20
+ }
21
+ //#endregion
22
+ //#region src/interceptors/ClientRequest/MockHttpSocket.d.ts
23
+ type HttpConnectionOptions = any;
24
+ type MockHttpSocketRequestCallback = (args: {
25
+ requestId: string;
26
+ request: Request;
27
+ socket: MockHttpSocket;
28
+ }) => void;
29
+ type MockHttpSocketResponseCallback = (args: {
30
+ requestId: string;
31
+ request: Request;
32
+ response: Response;
33
+ isMockedResponse: boolean;
34
+ socket: MockHttpSocket;
35
+ }) => Promise<void>;
36
+ interface MockHttpSocketOptions {
37
+ connectionOptions: HttpConnectionOptions;
38
+ createConnection: () => net.Socket;
39
+ onRequest: MockHttpSocketRequestCallback;
40
+ onResponse: MockHttpSocketResponseCallback;
41
+ }
42
+ declare class MockHttpSocket extends MockSocket {
43
+ private connectionOptions;
44
+ private createConnection;
45
+ private baseUrl;
46
+ private onRequest;
47
+ private onResponse;
48
+ private responseListenersPromise?;
49
+ private requestRawHeadersBuffer;
50
+ private responseRawHeadersBuffer;
51
+ private writeBuffer;
52
+ private request?;
53
+ private requestParser;
54
+ private requestStream?;
55
+ private shouldKeepAlive?;
56
+ private socketState;
57
+ private responseParser;
58
+ private responseStream?;
59
+ private originalSocket?;
60
+ constructor(options: MockHttpSocketOptions);
61
+ emit(event: string | symbol, ...args: any[]): boolean;
62
+ destroy(error?: Error | undefined): this;
63
+ /**
64
+ * Establish this Socket connection as-is and pipe
65
+ * its data/events through this Socket.
66
+ */
67
+ passthrough(): void;
68
+ /**
69
+ * Convert the given Fetch API `Response` instance to an
70
+ * HTTP message and push it to the socket.
71
+ */
72
+ respondWith(response: Response): Promise<void>;
73
+ /**
74
+ * Close this socket connection with the given error.
75
+ */
76
+ errorWith(error?: Error): void;
77
+ private mockConnect;
78
+ private flushWriteBuffer;
79
+ /**
80
+ * This callback might be called when the request is "slow":
81
+ * - Request headers were fragmented across multiple TCP packages;
82
+ * - Request headers were too large to be processed in a single run
83
+ * (e.g. more than 30 request headers).
84
+ * @note This is called before request start.
85
+ */
86
+ private onRequestHeaders;
87
+ private onRequestStart;
88
+ private onRequestBody;
89
+ private onRequestEnd;
90
+ /**
91
+ * This callback might be called when the response is "slow":
92
+ * - Response headers were fragmented across multiple TCP packages;
93
+ * - Response headers were too large to be processed in a single run
94
+ * (e.g. more than 30 response headers).
95
+ * @note This is called before response start.
96
+ */
97
+ private onResponseHeaders;
98
+ private onResponseStart;
99
+ private onResponseBody;
100
+ private onResponseEnd;
101
+ }
102
+ //#endregion
103
+ //#region src/interceptors/ClientRequest/index.d.ts
104
+ declare class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap> {
105
+ static symbol: symbol;
106
+ constructor();
107
+ protected setup(): void;
108
+ private onRequest;
109
+ onResponse: MockHttpSocketResponseCallback;
110
+ }
111
+ //#endregion
112
+ export { ClientRequestInterceptor as t };
113
+ //# sourceMappingURL=index-C0YAQ36w.d.mts.map
@@ -0,0 +1,54 @@
1
+ const require_glossary = require('./glossary-BLKRyLBd.cjs');
2
+ const require_fetchUtils = require('./fetchUtils-BaY5iWXw.cjs');
3
+ const require_BatchInterceptor = require('./BatchInterceptor-3LnAnLTx.cjs');
4
+ const require_bufferUtils = require('./bufferUtils-DiCTqG-7.cjs');
5
+ const require_getRawRequest = require('./getRawRequest-BavnMWh_.cjs');
6
+
7
+ //#region src/utils/getCleanUrl.ts
8
+ /**
9
+ * Removes query parameters and hashes from a given URL.
10
+ */
11
+ function getCleanUrl(url, isAbsolute = true) {
12
+ return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
13
+ }
14
+
15
+ //#endregion
16
+ //#region src/utils/resolveWebSocketUrl.ts
17
+ /**
18
+ * Resolve potentially relative WebSocket URLs the same way
19
+ * the browser does (replace the protocol, use the origin, etc).
20
+ *
21
+ * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket
22
+ */
23
+ function resolveWebSocketUrl(url) {
24
+ if (typeof url === "string") return resolveWebSocketUrl(new URL(url, typeof location !== "undefined" ? location.href : void 0));
25
+ if (url.protocol === "http:") url.protocol = "ws:";
26
+ else if (url.protocol === "https:") url.protocol = "wss:";
27
+ if (url.protocol !== "ws:" && url.protocol !== "wss:")
28
+ /**
29
+ * @note These errors are modeled after the browser errors.
30
+ * The exact error messages aren't provided in the specification.
31
+ * Node.js uses more obscure error messages that I don't wish to replicate.
32
+ */
33
+ throw new SyntaxError(`Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`);
34
+ if (url.hash !== "") throw new SyntaxError(`Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`);
35
+ return url.href;
36
+ }
37
+
38
+ //#endregion
39
+ exports.BatchInterceptor = require_BatchInterceptor.BatchInterceptor;
40
+ exports.FetchResponse = require_fetchUtils.FetchResponse;
41
+ exports.INTERNAL_REQUEST_ID_HEADER_NAME = require_fetchUtils.INTERNAL_REQUEST_ID_HEADER_NAME;
42
+ exports.IS_PATCHED_MODULE = require_glossary.IS_PATCHED_MODULE;
43
+ exports.Interceptor = require_fetchUtils.Interceptor;
44
+ exports.InterceptorReadyState = require_fetchUtils.InterceptorReadyState;
45
+ exports.RequestController = require_fetchUtils.RequestController;
46
+ exports.createRequestId = require_fetchUtils.createRequestId;
47
+ exports.decodeBuffer = require_bufferUtils.decodeBuffer;
48
+ exports.deleteGlobalSymbol = require_fetchUtils.deleteGlobalSymbol;
49
+ exports.encodeBuffer = require_bufferUtils.encodeBuffer;
50
+ exports.getCleanUrl = getCleanUrl;
51
+ exports.getGlobalSymbol = require_fetchUtils.getGlobalSymbol;
52
+ exports.getRawRequest = require_getRawRequest.getRawRequest;
53
+ exports.resolveWebSocketUrl = resolveWebSocketUrl;
54
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
@@ -0,0 +1,75 @@
1
+ import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestCredentials, f as RequestController, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, p as RequestControllerSource, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as IS_PATCHED_MODULE } from "./Interceptor-DJ2akVWI.cjs";
2
+ import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-D_YqR8qU.cjs";
3
+
4
+ //#region src/createRequestId.d.ts
5
+
6
+ /**
7
+ * Generate a random ID string to represent a request.
8
+ * @example
9
+ * createRequestId()
10
+ * // "f774b6c9c600f"
11
+ */
12
+ declare function createRequestId(): string;
13
+ //#endregion
14
+ //#region src/utils/getCleanUrl.d.ts
15
+ /**
16
+ * Removes query parameters and hashes from a given URL.
17
+ */
18
+ declare function getCleanUrl(url: URL, isAbsolute?: boolean): string;
19
+ //#endregion
20
+ //#region src/utils/bufferUtils.d.ts
21
+ declare function encodeBuffer(text: string): Uint8Array;
22
+ declare function decodeBuffer(buffer: ArrayBuffer, encoding?: string): string;
23
+ //#endregion
24
+ //#region src/utils/fetchUtils.d.ts
25
+ interface FetchResponseInit extends ResponseInit {
26
+ url?: string;
27
+ }
28
+ declare class FetchResponse extends Response {
29
+ /**
30
+ * Response status codes for responses that cannot have body.
31
+ * @see https://fetch.spec.whatwg.org/#statuses
32
+ */
33
+ static readonly STATUS_CODES_WITHOUT_BODY: number[];
34
+ static readonly STATUS_CODES_WITH_REDIRECT: number[];
35
+ static isConfigurableStatusCode(status: number): boolean;
36
+ static isRedirectResponse(status: number): boolean;
37
+ /**
38
+ * Returns a boolean indicating whether the given response status
39
+ * code represents a response that can have a body.
40
+ */
41
+ static isResponseWithBody(status: number): boolean;
42
+ static setUrl(url: string | undefined, response: Response): void;
43
+ /**
44
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
45
+ */
46
+ static parseRawHeaders(rawHeaders: Array<string>): Headers;
47
+ constructor(body?: BodyInit | null, init?: FetchResponseInit);
48
+ }
49
+ //#endregion
50
+ //#region src/getRawRequest.d.ts
51
+ /**
52
+ * Returns a raw request instance associated with this request.
53
+ *
54
+ * @example
55
+ * interceptor.on('request', ({ request }) => {
56
+ * const rawRequest = getRawRequest(request)
57
+ *
58
+ * if (rawRequest instanceof http.ClientRequest) {
59
+ * console.log(rawRequest.rawHeaders)
60
+ * }
61
+ * })
62
+ */
63
+ declare function getRawRequest(request: Request): unknown | undefined;
64
+ //#endregion
65
+ //#region src/utils/resolveWebSocketUrl.d.ts
66
+ /**
67
+ * Resolve potentially relative WebSocket URLs the same way
68
+ * the browser does (replace the protocol, use the origin, etc).
69
+ *
70
+ * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket
71
+ */
72
+ declare function resolveWebSocketUrl(url: string | URL): string;
73
+ //#endregion
74
+ export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
75
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,75 @@
1
+ import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestCredentials, f as RequestController, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, p as RequestControllerSource, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as IS_PATCHED_MODULE } from "./Interceptor-DEazpLJd.mjs";
2
+ import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-D7mXzHcQ.mjs";
3
+
4
+ //#region src/createRequestId.d.ts
5
+
6
+ /**
7
+ * Generate a random ID string to represent a request.
8
+ * @example
9
+ * createRequestId()
10
+ * // "f774b6c9c600f"
11
+ */
12
+ declare function createRequestId(): string;
13
+ //#endregion
14
+ //#region src/utils/getCleanUrl.d.ts
15
+ /**
16
+ * Removes query parameters and hashes from a given URL.
17
+ */
18
+ declare function getCleanUrl(url: URL, isAbsolute?: boolean): string;
19
+ //#endregion
20
+ //#region src/utils/bufferUtils.d.ts
21
+ declare function encodeBuffer(text: string): Uint8Array;
22
+ declare function decodeBuffer(buffer: ArrayBuffer, encoding?: string): string;
23
+ //#endregion
24
+ //#region src/utils/fetchUtils.d.ts
25
+ interface FetchResponseInit extends ResponseInit {
26
+ url?: string;
27
+ }
28
+ declare class FetchResponse extends Response {
29
+ /**
30
+ * Response status codes for responses that cannot have body.
31
+ * @see https://fetch.spec.whatwg.org/#statuses
32
+ */
33
+ static readonly STATUS_CODES_WITHOUT_BODY: number[];
34
+ static readonly STATUS_CODES_WITH_REDIRECT: number[];
35
+ static isConfigurableStatusCode(status: number): boolean;
36
+ static isRedirectResponse(status: number): boolean;
37
+ /**
38
+ * Returns a boolean indicating whether the given response status
39
+ * code represents a response that can have a body.
40
+ */
41
+ static isResponseWithBody(status: number): boolean;
42
+ static setUrl(url: string | undefined, response: Response): void;
43
+ /**
44
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
45
+ */
46
+ static parseRawHeaders(rawHeaders: Array<string>): Headers;
47
+ constructor(body?: BodyInit | null, init?: FetchResponseInit);
48
+ }
49
+ //#endregion
50
+ //#region src/getRawRequest.d.ts
51
+ /**
52
+ * Returns a raw request instance associated with this request.
53
+ *
54
+ * @example
55
+ * interceptor.on('request', ({ request }) => {
56
+ * const rawRequest = getRawRequest(request)
57
+ *
58
+ * if (rawRequest instanceof http.ClientRequest) {
59
+ * console.log(rawRequest.rawHeaders)
60
+ * }
61
+ * })
62
+ */
63
+ declare function getRawRequest(request: Request): unknown | undefined;
64
+ //#endregion
65
+ //#region src/utils/resolveWebSocketUrl.d.ts
66
+ /**
67
+ * Resolve potentially relative WebSocket URLs the same way
68
+ * the browser does (replace the protocol, use the origin, etc).
69
+ *
70
+ * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket
71
+ */
72
+ declare function resolveWebSocketUrl(url: string | URL): string;
73
+ //#endregion
74
+ export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
75
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,40 @@
1
+ import { t as IS_PATCHED_MODULE } from "./glossary-glQBRnVD.mjs";
2
+ import { c as InterceptorReadyState, i as RequestController, l as deleteGlobalSymbol, o as INTERNAL_REQUEST_ID_HEADER_NAME, r as createRequestId, s as Interceptor, t as FetchResponse, u as getGlobalSymbol } from "./fetchUtils-CoU35g3M.mjs";
3
+ import { t as BatchInterceptor } from "./BatchInterceptor-DFaBPilf.mjs";
4
+ import { n as encodeBuffer, t as decodeBuffer } from "./bufferUtils-_8XfKIfX.mjs";
5
+ import { t as getRawRequest } from "./getRawRequest-DnwmXyOW.mjs";
6
+
7
+ //#region src/utils/getCleanUrl.ts
8
+ /**
9
+ * Removes query parameters and hashes from a given URL.
10
+ */
11
+ function getCleanUrl(url, isAbsolute = true) {
12
+ return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
13
+ }
14
+
15
+ //#endregion
16
+ //#region src/utils/resolveWebSocketUrl.ts
17
+ /**
18
+ * Resolve potentially relative WebSocket URLs the same way
19
+ * the browser does (replace the protocol, use the origin, etc).
20
+ *
21
+ * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket
22
+ */
23
+ function resolveWebSocketUrl(url) {
24
+ if (typeof url === "string") return resolveWebSocketUrl(new URL(url, typeof location !== "undefined" ? location.href : void 0));
25
+ if (url.protocol === "http:") url.protocol = "ws:";
26
+ else if (url.protocol === "https:") url.protocol = "wss:";
27
+ if (url.protocol !== "ws:" && url.protocol !== "wss:")
28
+ /**
29
+ * @note These errors are modeled after the browser errors.
30
+ * The exact error messages aren't provided in the specification.
31
+ * Node.js uses more obscure error messages that I don't wish to replicate.
32
+ */
33
+ throw new SyntaxError(`Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`);
34
+ if (url.hash !== "") throw new SyntaxError(`Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`);
35
+ return url.href;
36
+ }
37
+
38
+ //#endregion
39
+ export { BatchInterceptor, FetchResponse, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorReadyState, RequestController, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
40
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
@@ -0,0 +1,6 @@
1
+ require('../../fetchUtils-BaY5iWXw.cjs');
2
+ const require_ClientRequest = require('../../ClientRequest-2rDe54Ui.cjs');
3
+ require('../../handleRequest-Bb7Y-XLw.cjs');
4
+ require('../../node-dKdAf3tC.cjs');
5
+
6
+ exports.ClientRequestInterceptor = require_ClientRequest.ClientRequestInterceptor;
@@ -0,0 +1,2 @@
1
+ import { t as ClientRequestInterceptor } from "../../index-BMbJ8FXL.cjs";
2
+ export { ClientRequestInterceptor };
@@ -0,0 +1,3 @@
1
+ import "../../Interceptor-DEazpLJd.mjs";
2
+ import { t as ClientRequestInterceptor } from "../../index-C0YAQ36w.mjs";
3
+ export { ClientRequestInterceptor };
@@ -0,0 +1,6 @@
1
+ import "../../fetchUtils-CoU35g3M.mjs";
2
+ import { t as ClientRequestInterceptor } from "../../ClientRequest-Ca8Qykuv.mjs";
3
+ import "../../handleRequest-Y97UwBbF.mjs";
4
+ import "../../node-DwCc6iuP.mjs";
5
+
6
+ export { ClientRequestInterceptor };
@@ -0,0 +1,6 @@
1
+ require('../../fetchUtils-BaY5iWXw.cjs');
2
+ require('../../bufferUtils-DiCTqG-7.cjs');
3
+ require('../../handleRequest-Bb7Y-XLw.cjs');
4
+ const require_XMLHttpRequest = require('../../XMLHttpRequest-B7kJdYYI.cjs');
5
+
6
+ exports.XMLHttpRequestInterceptor = require_XMLHttpRequest.XMLHttpRequestInterceptor;
@@ -0,0 +1,14 @@
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DJ2akVWI.cjs";
2
+ import { Emitter } from "strict-event-emitter";
3
+
4
+ //#region src/interceptors/XMLHttpRequest/index.d.ts
5
+ type XMLHttpRequestEmitter = Emitter<HttpRequestEventMap>;
6
+ declare class XMLHttpRequestInterceptor extends Interceptor<HttpRequestEventMap> {
7
+ static interceptorSymbol: symbol;
8
+ constructor();
9
+ protected checkEnvironment(): boolean;
10
+ protected setup(): void;
11
+ }
12
+ //#endregion
13
+ export { XMLHttpRequestEmitter, XMLHttpRequestInterceptor };
14
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DEazpLJd.mjs";
2
+ import { Emitter } from "strict-event-emitter";
3
+
4
+ //#region src/interceptors/XMLHttpRequest/index.d.ts
5
+ type XMLHttpRequestEmitter = Emitter<HttpRequestEventMap>;
6
+ declare class XMLHttpRequestInterceptor extends Interceptor<HttpRequestEventMap> {
7
+ static interceptorSymbol: symbol;
8
+ constructor();
9
+ protected checkEnvironment(): boolean;
10
+ protected setup(): void;
11
+ }
12
+ //#endregion
13
+ export { XMLHttpRequestEmitter, XMLHttpRequestInterceptor };
14
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,6 @@
1
+ import "../../fetchUtils-CoU35g3M.mjs";
2
+ import "../../bufferUtils-_8XfKIfX.mjs";
3
+ import "../../handleRequest-Y97UwBbF.mjs";
4
+ import { t as XMLHttpRequestInterceptor } from "../../XMLHttpRequest-C8dIZpds.mjs";
5
+
6
+ export { XMLHttpRequestInterceptor };
@@ -0,0 +1,5 @@
1
+ require('../../fetchUtils-BaY5iWXw.cjs');
2
+ require('../../handleRequest-Bb7Y-XLw.cjs');
3
+ const require_fetch = require('../../fetch-BmXpK10r.cjs');
4
+
5
+ exports.FetchInterceptor = require_fetch.FetchInterceptor;
@@ -0,0 +1,12 @@
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DJ2akVWI.cjs";
2
+
3
+ //#region src/interceptors/fetch/index.d.ts
4
+ declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
5
+ static symbol: symbol;
6
+ constructor();
7
+ protected checkEnvironment(): boolean;
8
+ protected setup(): Promise<void>;
9
+ }
10
+ //#endregion
11
+ export { FetchInterceptor };
12
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,12 @@
1
+ import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-DEazpLJd.mjs";
2
+
3
+ //#region src/interceptors/fetch/index.d.ts
4
+ declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
5
+ static symbol: symbol;
6
+ constructor();
7
+ protected checkEnvironment(): boolean;
8
+ protected setup(): Promise<void>;
9
+ }
10
+ //#endregion
11
+ export { FetchInterceptor };
12
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,5 @@
1
+ import "../../fetchUtils-CoU35g3M.mjs";
2
+ import "../../handleRequest-Y97UwBbF.mjs";
3
+ import { t as FetchInterceptor } from "../../fetch-G1DVwDKG.mjs";
4
+
5
+ export { FetchInterceptor };
@@ -0,0 +1,27 @@
1
+ import { t as getRawRequest } from "./getRawRequest-DnwmXyOW.mjs";
2
+ import { invariant } from "outvariant";
3
+ import { ClientRequest } from "node:http";
4
+ import { Readable } from "node:stream";
5
+
6
+ //#region src/utils/node/index.ts
7
+ const kRawRequestBodyStream = Symbol("kRawRequestBodyStream");
8
+ /**
9
+ * Returns the request body stream of the given request.
10
+ * @note This is only relevant in the context of `http.ClientRequest`.
11
+ * This function will throw if the given `request` wasn't created based on
12
+ * the `http.ClientRequest` instance.
13
+ * You must rely on the web stream consumers for other request clients.
14
+ */
15
+ function getClientRequestBodyStream(request) {
16
+ invariant(getRawRequest(request) instanceof ClientRequest, `Failed to retrieve raw request body stream: request is not an instance of "http.ClientRequest". Note that you can only use the "getClientRequestBodyStream" function with the requests issued by "http.clientRequest".`);
17
+ const requestBodyStream = Reflect.get(request, kRawRequestBodyStream);
18
+ invariant(requestBodyStream instanceof Readable, "Failed to retrieve raw request body stream: corrupted stream (%s)", typeof requestBodyStream);
19
+ return requestBodyStream;
20
+ }
21
+ function setRawRequestBodyStream(request, stream) {
22
+ Reflect.set(request, kRawRequestBodyStream, stream);
23
+ }
24
+
25
+ //#endregion
26
+ export { setRawRequestBodyStream as n, getClientRequestBodyStream as t };
27
+ //# sourceMappingURL=node-DwCc6iuP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-DwCc6iuP.mjs","names":[],"sources":["../../src/utils/node/index.ts"],"sourcesContent":["import { ClientRequest } from 'node:http'\nimport { Readable } from 'node:stream'\nimport { invariant } from 'outvariant'\nimport { getRawRequest } from '../../getRawRequest'\n\nconst kRawRequestBodyStream = Symbol('kRawRequestBodyStream')\n\n/**\n * Returns the request body stream of the given request.\n * @note This is only relevant in the context of `http.ClientRequest`.\n * This function will throw if the given `request` wasn't created based on\n * the `http.ClientRequest` instance.\n * You must rely on the web stream consumers for other request clients.\n */\nexport function getClientRequestBodyStream(request: Request): Readable {\n const rawRequest = getRawRequest(request)\n\n invariant(\n rawRequest instanceof ClientRequest,\n `Failed to retrieve raw request body stream: request is not an instance of \"http.ClientRequest\". Note that you can only use the \"getClientRequestBodyStream\" function with the requests issued by \"http.clientRequest\".`\n )\n\n const requestBodyStream = Reflect.get(request, kRawRequestBodyStream)\n\n invariant(\n requestBodyStream instanceof Readable,\n 'Failed to retrieve raw request body stream: corrupted stream (%s)',\n typeof requestBodyStream\n )\n\n return requestBodyStream\n}\n\nexport function setRawRequestBodyStream(\n request: Request,\n stream: Readable\n): void {\n Reflect.set(request, kRawRequestBodyStream, stream)\n}\n"],"mappings":";;;;;;AAKA,MAAM,wBAAwB,OAAO,wBAAwB;;;;;;;;AAS7D,SAAgB,2BAA2B,SAA4B;AAGrE,WAFmB,cAAc,QAAQ,YAGjB,eACtB,yNACD;CAED,MAAM,oBAAoB,QAAQ,IAAI,SAAS,sBAAsB;AAErE,WACE,6BAA6B,UAC7B,qEACA,OAAO,kBACR;AAED,QAAO;;AAGT,SAAgB,wBACd,SACA,QACM;AACN,SAAQ,IAAI,SAAS,uBAAuB,OAAO"}
@@ -0,0 +1,39 @@
1
+ const require_chunk = require('./chunk-CbDLau6x.cjs');
2
+ const require_getRawRequest = require('./getRawRequest-BavnMWh_.cjs');
3
+ let outvariant = require("outvariant");
4
+ let node_http = require("node:http");
5
+ let node_stream = require("node:stream");
6
+
7
+ //#region src/utils/node/index.ts
8
+ const kRawRequestBodyStream = Symbol("kRawRequestBodyStream");
9
+ /**
10
+ * Returns the request body stream of the given request.
11
+ * @note This is only relevant in the context of `http.ClientRequest`.
12
+ * This function will throw if the given `request` wasn't created based on
13
+ * the `http.ClientRequest` instance.
14
+ * You must rely on the web stream consumers for other request clients.
15
+ */
16
+ function getClientRequestBodyStream(request) {
17
+ (0, outvariant.invariant)(require_getRawRequest.getRawRequest(request) instanceof node_http.ClientRequest, `Failed to retrieve raw request body stream: request is not an instance of "http.ClientRequest". Note that you can only use the "getClientRequestBodyStream" function with the requests issued by "http.clientRequest".`);
18
+ const requestBodyStream = Reflect.get(request, kRawRequestBodyStream);
19
+ (0, outvariant.invariant)(requestBodyStream instanceof node_stream.Readable, "Failed to retrieve raw request body stream: corrupted stream (%s)", typeof requestBodyStream);
20
+ return requestBodyStream;
21
+ }
22
+ function setRawRequestBodyStream(request, stream) {
23
+ Reflect.set(request, kRawRequestBodyStream, stream);
24
+ }
25
+
26
+ //#endregion
27
+ Object.defineProperty(exports, 'getClientRequestBodyStream', {
28
+ enumerable: true,
29
+ get: function () {
30
+ return getClientRequestBodyStream;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, 'setRawRequestBodyStream', {
34
+ enumerable: true,
35
+ get: function () {
36
+ return setRawRequestBodyStream;
37
+ }
38
+ });
39
+ //# sourceMappingURL=node-dKdAf3tC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-dKdAf3tC.cjs","names":["getRawRequest","ClientRequest","Readable"],"sources":["../../src/utils/node/index.ts"],"sourcesContent":["import { ClientRequest } from 'node:http'\nimport { Readable } from 'node:stream'\nimport { invariant } from 'outvariant'\nimport { getRawRequest } from '../../getRawRequest'\n\nconst kRawRequestBodyStream = Symbol('kRawRequestBodyStream')\n\n/**\n * Returns the request body stream of the given request.\n * @note This is only relevant in the context of `http.ClientRequest`.\n * This function will throw if the given `request` wasn't created based on\n * the `http.ClientRequest` instance.\n * You must rely on the web stream consumers for other request clients.\n */\nexport function getClientRequestBodyStream(request: Request): Readable {\n const rawRequest = getRawRequest(request)\n\n invariant(\n rawRequest instanceof ClientRequest,\n `Failed to retrieve raw request body stream: request is not an instance of \"http.ClientRequest\". Note that you can only use the \"getClientRequestBodyStream\" function with the requests issued by \"http.clientRequest\".`\n )\n\n const requestBodyStream = Reflect.get(request, kRawRequestBodyStream)\n\n invariant(\n requestBodyStream instanceof Readable,\n 'Failed to retrieve raw request body stream: corrupted stream (%s)',\n typeof requestBodyStream\n )\n\n return requestBodyStream\n}\n\nexport function setRawRequestBodyStream(\n request: Request,\n stream: Readable\n): void {\n Reflect.set(request, kRawRequestBodyStream, stream)\n}\n"],"mappings":";;;;;;;AAKA,MAAM,wBAAwB,OAAO,wBAAwB;;;;;;;;AAS7D,SAAgB,2BAA2B,SAA4B;AAGrE,2BAFmBA,oCAAc,QAAQ,YAGjBC,yBACtB,yNACD;CAED,MAAM,oBAAoB,QAAQ,IAAI,SAAS,sBAAsB;AAErE,2BACE,6BAA6BC,sBAC7B,qEACA,OAAO,kBACR;AAED,QAAO;;AAGT,SAAgB,wBACd,SACA,QACM;AACN,SAAQ,IAAI,SAAS,uBAAuB,OAAO"}
@@ -0,0 +1,22 @@
1
+ require('../fetchUtils-BaY5iWXw.cjs');
2
+ require('../bufferUtils-DiCTqG-7.cjs');
3
+ const require_ClientRequest = require('../ClientRequest-2rDe54Ui.cjs');
4
+ require('../handleRequest-Bb7Y-XLw.cjs');
5
+ require('../node-dKdAf3tC.cjs');
6
+ const require_XMLHttpRequest = require('../XMLHttpRequest-B7kJdYYI.cjs');
7
+ const require_fetch = require('../fetch-BmXpK10r.cjs');
8
+
9
+ //#region src/presets/node.ts
10
+ /**
11
+ * The default preset provisions the interception of requests
12
+ * regardless of their type (http/https/XMLHttpRequest).
13
+ */
14
+ var node_default = [
15
+ new require_ClientRequest.ClientRequestInterceptor(),
16
+ new require_XMLHttpRequest.XMLHttpRequestInterceptor(),
17
+ new require_fetch.FetchInterceptor()
18
+ ];
19
+
20
+ //#endregion
21
+ module.exports = node_default;
22
+ //# sourceMappingURL=node.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.cjs","names":["ClientRequestInterceptor","XMLHttpRequestInterceptor","FetchInterceptor"],"sources":["../../../src/presets/node.ts"],"sourcesContent":["import { ClientRequestInterceptor } from '../interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '../interceptors/fetch'\n\n/**\n * The default preset provisions the interception of requests\n * regardless of their type (http/https/XMLHttpRequest).\n */\nexport default [\n new ClientRequestInterceptor(),\n new XMLHttpRequestInterceptor(),\n new FetchInterceptor(),\n] as const\n"],"mappings":";;;;;;;;;;;;;AAQA,mBAAe;CACb,IAAIA,gDAA0B;CAC9B,IAAIC,kDAA2B;CAC/B,IAAIC,gCAAkB;CACvB"}
@@ -0,0 +1,13 @@
1
+ import { t as ClientRequestInterceptor } from "../index-BMbJ8FXL.cjs";
2
+ import { XMLHttpRequestInterceptor } from "../interceptors/XMLHttpRequest/index.cjs";
3
+ import { FetchInterceptor } from "../interceptors/fetch/index.cjs";
4
+
5
+ //#region src/presets/node.d.ts
6
+
7
+ /**
8
+ * The default preset provisions the interception of requests
9
+ * regardless of their type (http/https/XMLHttpRequest).
10
+ */
11
+ declare const _default: readonly [ClientRequestInterceptor, XMLHttpRequestInterceptor, FetchInterceptor];
12
+ export = _default;
13
+ //# sourceMappingURL=node.d.cts.map
@@ -0,0 +1,15 @@
1
+ import "../Interceptor-DEazpLJd.mjs";
2
+ import { t as ClientRequestInterceptor } from "../index-C0YAQ36w.mjs";
3
+ import { XMLHttpRequestInterceptor } from "../interceptors/XMLHttpRequest/index.mjs";
4
+ import { FetchInterceptor } from "../interceptors/fetch/index.mjs";
5
+
6
+ //#region src/presets/node.d.ts
7
+
8
+ /**
9
+ * The default preset provisions the interception of requests
10
+ * regardless of their type (http/https/XMLHttpRequest).
11
+ */
12
+ declare const _default: readonly [ClientRequestInterceptor, XMLHttpRequestInterceptor, FetchInterceptor];
13
+ //#endregion
14
+ export { _default as default };
15
+ //# sourceMappingURL=node.d.mts.map