@mswjs/interceptors 0.39.8 → 0.41.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 (282) hide show
  1. package/ClientRequest/package.json +7 -2
  2. package/RemoteHttpInterceptor/package.json +7 -2
  3. package/WebSocket/package.json +9 -2
  4. package/XMLHttpRequest/package.json +9 -3
  5. package/fetch/package.json +9 -3
  6. package/lib/browser/Interceptor-2mUoKZL1.d.mts +65 -0
  7. package/lib/browser/Interceptor-Deczogc8.d.cts +65 -0
  8. package/lib/browser/XMLHttpRequest-BUfglQD1.cjs +761 -0
  9. package/lib/browser/XMLHttpRequest-BUfglQD1.cjs.map +1 -0
  10. package/lib/browser/XMLHttpRequest-DS5fc8Qs.mjs +756 -0
  11. package/lib/browser/XMLHttpRequest-DS5fc8Qs.mjs.map +1 -0
  12. package/lib/browser/bufferUtils-BiiO6HZv.mjs +20 -0
  13. package/lib/browser/bufferUtils-BiiO6HZv.mjs.map +1 -0
  14. package/lib/browser/bufferUtils-Uc0eRItL.cjs +38 -0
  15. package/lib/browser/bufferUtils-Uc0eRItL.cjs.map +1 -0
  16. package/lib/browser/createRequestId-Cs4oXfa1.cjs +205 -0
  17. package/lib/browser/createRequestId-Cs4oXfa1.cjs.map +1 -0
  18. package/lib/browser/createRequestId-DQcIlohW.mjs +170 -0
  19. package/lib/browser/createRequestId-DQcIlohW.mjs.map +1 -0
  20. package/lib/browser/fetch-BHcqM3z7.cjs +253 -0
  21. package/lib/browser/fetch-BHcqM3z7.cjs.map +1 -0
  22. package/lib/browser/fetch-DSJoynSF.mjs +248 -0
  23. package/lib/browser/fetch-DSJoynSF.mjs.map +1 -0
  24. package/lib/browser/getRawRequest-BTaNLFr0.mjs +218 -0
  25. package/lib/browser/getRawRequest-BTaNLFr0.mjs.map +1 -0
  26. package/lib/browser/getRawRequest-zx8rUJL2.cjs +259 -0
  27. package/lib/browser/getRawRequest-zx8rUJL2.cjs.map +1 -0
  28. package/lib/browser/glossary-BdLS4k1H.d.cts +70 -0
  29. package/lib/browser/glossary-gEEJhK4S.d.mts +70 -0
  30. package/lib/browser/handleRequest-DI6a7Dty.cjs +189 -0
  31. package/lib/browser/handleRequest-DI6a7Dty.cjs.map +1 -0
  32. package/lib/browser/handleRequest-DxGbCTbb.mjs +178 -0
  33. package/lib/browser/handleRequest-DxGbCTbb.mjs.map +1 -0
  34. package/lib/browser/hasConfigurableGlobal-C8kXFDic.mjs +33 -0
  35. package/lib/browser/hasConfigurableGlobal-C8kXFDic.mjs.map +1 -0
  36. package/lib/browser/hasConfigurableGlobal-D7S3l5h6.cjs +45 -0
  37. package/lib/browser/hasConfigurableGlobal-D7S3l5h6.cjs.map +1 -0
  38. package/lib/browser/index.cjs +68 -0
  39. package/lib/browser/index.cjs.map +1 -0
  40. package/lib/browser/index.d.cts +87 -0
  41. package/lib/browser/index.d.mts +87 -0
  42. package/lib/browser/index.mjs +49 -75
  43. package/lib/browser/index.mjs.map +1 -1
  44. package/lib/browser/interceptors/WebSocket/index.cjs +621 -0
  45. package/lib/browser/interceptors/WebSocket/index.cjs.map +1 -0
  46. package/lib/browser/interceptors/WebSocket/index.d.cts +277 -0
  47. package/lib/browser/interceptors/WebSocket/index.d.mts +277 -0
  48. package/lib/browser/interceptors/WebSocket/index.mjs +587 -694
  49. package/lib/browser/interceptors/WebSocket/index.mjs.map +1 -1
  50. package/lib/browser/interceptors/XMLHttpRequest/index.cjs +7 -0
  51. package/lib/browser/interceptors/XMLHttpRequest/index.d.cts +15 -0
  52. package/lib/browser/interceptors/XMLHttpRequest/index.d.mts +15 -0
  53. package/lib/browser/interceptors/XMLHttpRequest/index.mjs +7 -12
  54. package/lib/browser/interceptors/fetch/index.cjs +6 -0
  55. package/lib/browser/interceptors/fetch/index.d.cts +13 -0
  56. package/lib/browser/interceptors/fetch/index.d.mts +13 -0
  57. package/lib/browser/interceptors/fetch/index.mjs +6 -11
  58. package/lib/browser/presets/browser.cjs +17 -0
  59. package/lib/browser/presets/browser.cjs.map +1 -0
  60. package/lib/browser/presets/browser.d.cts +12 -0
  61. package/lib/browser/presets/browser.d.mts +14 -0
  62. package/lib/browser/presets/browser.mjs +15 -19
  63. package/lib/browser/presets/browser.mjs.map +1 -1
  64. package/lib/node/BatchInterceptor-3LnAnLTx.cjs +49 -0
  65. package/lib/node/BatchInterceptor-3LnAnLTx.cjs.map +1 -0
  66. package/lib/node/BatchInterceptor-D7mXzHcQ.d.mts +26 -0
  67. package/lib/node/BatchInterceptor-DFaBPilf.mjs +44 -0
  68. package/lib/node/BatchInterceptor-DFaBPilf.mjs.map +1 -0
  69. package/lib/node/BatchInterceptor-D_YqR8qU.d.cts +26 -0
  70. package/lib/node/ClientRequest-2rDe54Ui.cjs +1043 -0
  71. package/lib/node/ClientRequest-2rDe54Ui.cjs.map +1 -0
  72. package/lib/node/ClientRequest-Ca8Qykuv.mjs +1034 -0
  73. package/lib/node/ClientRequest-Ca8Qykuv.mjs.map +1 -0
  74. package/lib/node/Interceptor-DEazpLJd.d.mts +133 -0
  75. package/lib/node/Interceptor-DJ2akVWI.d.cts +133 -0
  76. package/lib/node/RemoteHttpInterceptor.cjs +154 -0
  77. package/lib/node/RemoteHttpInterceptor.cjs.map +1 -0
  78. package/lib/node/RemoteHttpInterceptor.d.cts +39 -0
  79. package/lib/node/RemoteHttpInterceptor.d.mts +39 -0
  80. package/lib/node/RemoteHttpInterceptor.mjs +145 -186
  81. package/lib/node/RemoteHttpInterceptor.mjs.map +1 -1
  82. package/lib/node/XMLHttpRequest-B7kJdYYI.cjs +763 -0
  83. package/lib/node/XMLHttpRequest-B7kJdYYI.cjs.map +1 -0
  84. package/lib/node/XMLHttpRequest-C8dIZpds.mjs +757 -0
  85. package/lib/node/XMLHttpRequest-C8dIZpds.mjs.map +1 -0
  86. package/lib/node/bufferUtils-DiCTqG-7.cjs +38 -0
  87. package/lib/node/bufferUtils-DiCTqG-7.cjs.map +1 -0
  88. package/lib/node/bufferUtils-_8XfKIfX.mjs +20 -0
  89. package/lib/node/bufferUtils-_8XfKIfX.mjs.map +1 -0
  90. package/lib/node/chunk-CbDLau6x.cjs +34 -0
  91. package/lib/node/fetch-BmXpK10r.cjs +272 -0
  92. package/lib/node/fetch-BmXpK10r.cjs.map +1 -0
  93. package/lib/node/fetch-G1DVwDKG.mjs +265 -0
  94. package/lib/node/fetch-G1DVwDKG.mjs.map +1 -0
  95. package/lib/node/fetchUtils-BaY5iWXw.cjs +419 -0
  96. package/lib/node/fetchUtils-BaY5iWXw.cjs.map +1 -0
  97. package/lib/node/fetchUtils-CoU35g3M.mjs +359 -0
  98. package/lib/node/fetchUtils-CoU35g3M.mjs.map +1 -0
  99. package/lib/node/getRawRequest-BavnMWh_.cjs +36 -0
  100. package/lib/node/getRawRequest-BavnMWh_.cjs.map +1 -0
  101. package/lib/node/getRawRequest-DnwmXyOW.mjs +24 -0
  102. package/lib/node/getRawRequest-DnwmXyOW.mjs.map +1 -0
  103. package/lib/node/glossary-BLKRyLBd.cjs +12 -0
  104. package/lib/node/glossary-BLKRyLBd.cjs.map +1 -0
  105. package/lib/node/glossary-glQBRnVD.mjs +6 -0
  106. package/lib/node/glossary-glQBRnVD.mjs.map +1 -0
  107. package/lib/node/handleRequest-Bb7Y-XLw.cjs +220 -0
  108. package/lib/node/handleRequest-Bb7Y-XLw.cjs.map +1 -0
  109. package/lib/node/handleRequest-Y97UwBbF.mjs +190 -0
  110. package/lib/node/handleRequest-Y97UwBbF.mjs.map +1 -0
  111. package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs +26 -0
  112. package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs.map +1 -0
  113. package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs +20 -0
  114. package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs.map +1 -0
  115. package/lib/node/index-BMbJ8FXL.d.cts +113 -0
  116. package/lib/node/index-C0YAQ36w.d.mts +113 -0
  117. package/lib/node/index.cjs +30 -0
  118. package/lib/node/index.cjs.map +1 -0
  119. package/lib/node/index.d.cts +66 -0
  120. package/lib/node/index.d.mts +66 -0
  121. package/lib/node/index.mjs +13 -39
  122. package/lib/node/index.mjs.map +1 -1
  123. package/lib/node/interceptors/ClientRequest/index.cjs +6 -0
  124. package/lib/node/interceptors/ClientRequest/index.d.cts +2 -0
  125. package/lib/node/interceptors/ClientRequest/index.d.mts +3 -0
  126. package/lib/node/interceptors/ClientRequest/index.mjs +6 -11
  127. package/lib/node/interceptors/XMLHttpRequest/index.cjs +6 -0
  128. package/lib/node/interceptors/XMLHttpRequest/index.d.cts +14 -0
  129. package/lib/node/interceptors/XMLHttpRequest/index.d.mts +14 -0
  130. package/lib/node/interceptors/XMLHttpRequest/index.mjs +6 -13
  131. package/lib/node/interceptors/fetch/index.cjs +5 -0
  132. package/lib/node/interceptors/fetch/index.d.cts +12 -0
  133. package/lib/node/interceptors/fetch/index.d.mts +12 -0
  134. package/lib/node/interceptors/fetch/index.mjs +5 -12
  135. package/lib/node/node-DwCc6iuP.mjs +27 -0
  136. package/lib/node/node-DwCc6iuP.mjs.map +1 -0
  137. package/lib/node/node-dKdAf3tC.cjs +39 -0
  138. package/lib/node/node-dKdAf3tC.cjs.map +1 -0
  139. package/lib/node/presets/node.cjs +22 -0
  140. package/lib/node/presets/node.cjs.map +1 -0
  141. package/lib/node/presets/node.d.cts +13 -0
  142. package/lib/node/presets/node.d.mts +15 -0
  143. package/lib/node/presets/node.mjs +18 -23
  144. package/lib/node/presets/node.mjs.map +1 -1
  145. package/lib/node/utils/node/index.cjs +4 -0
  146. package/lib/node/utils/node/{index.d.ts → index.d.cts} +5 -2
  147. package/lib/node/utils/node/index.d.mts +16 -0
  148. package/lib/node/utils/node/index.mjs +3 -10
  149. package/package.json +34 -59
  150. package/presets/browser/package.json +2 -3
  151. package/presets/node/package.json +7 -2
  152. package/src/RemoteHttpInterceptor.ts +18 -13
  153. package/src/RequestController.test.ts +78 -31
  154. package/src/RequestController.ts +63 -39
  155. package/src/index.ts +4 -0
  156. package/src/interceptors/ClientRequest/MockHttpSocket.ts +43 -9
  157. package/src/interceptors/ClientRequest/index.ts +14 -18
  158. package/src/interceptors/ClientRequest/utils/parserUtils.ts +48 -0
  159. package/src/interceptors/WebSocket/index.ts +4 -1
  160. package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +45 -35
  161. package/src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts +24 -21
  162. package/src/interceptors/XMLHttpRequest/utils/getBodyByteLength.test.ts +2 -2
  163. package/src/interceptors/fetch/index.ts +61 -50
  164. package/src/utils/handleRequest.ts +65 -95
  165. package/lib/browser/Interceptor-af98b768.d.ts +0 -63
  166. package/lib/browser/chunk-2HUMWGRD.js +0 -37
  167. package/lib/browser/chunk-2HUMWGRD.js.map +0 -1
  168. package/lib/browser/chunk-2QICSCCS.js +0 -238
  169. package/lib/browser/chunk-2QICSCCS.js.map +0 -1
  170. package/lib/browser/chunk-3RXCRGL2.mjs +0 -117
  171. package/lib/browser/chunk-3RXCRGL2.mjs.map +0 -1
  172. package/lib/browser/chunk-6HYIRFX2.mjs +0 -22
  173. package/lib/browser/chunk-6HYIRFX2.mjs.map +0 -1
  174. package/lib/browser/chunk-E3CCOBRX.js +0 -846
  175. package/lib/browser/chunk-E3CCOBRX.js.map +0 -1
  176. package/lib/browser/chunk-E7UVBHVO.mjs +0 -846
  177. package/lib/browser/chunk-E7UVBHVO.mjs.map +0 -1
  178. package/lib/browser/chunk-H74PGQ4Y.js +0 -296
  179. package/lib/browser/chunk-H74PGQ4Y.js.map +0 -1
  180. package/lib/browser/chunk-LK6DILFK.js +0 -22
  181. package/lib/browser/chunk-LK6DILFK.js.map +0 -1
  182. package/lib/browser/chunk-PTTUYYVR.mjs +0 -238
  183. package/lib/browser/chunk-PTTUYYVR.mjs.map +0 -1
  184. package/lib/browser/chunk-Q7K2XAEP.mjs +0 -296
  185. package/lib/browser/chunk-Q7K2XAEP.mjs.map +0 -1
  186. package/lib/browser/chunk-QED3Q6Z2.mjs +0 -169
  187. package/lib/browser/chunk-QED3Q6Z2.mjs.map +0 -1
  188. package/lib/browser/chunk-T7TBRNJZ.js +0 -117
  189. package/lib/browser/chunk-T7TBRNJZ.js.map +0 -1
  190. package/lib/browser/chunk-TIPR373R.js +0 -169
  191. package/lib/browser/chunk-TIPR373R.js.map +0 -1
  192. package/lib/browser/chunk-VYSDLBSS.mjs +0 -37
  193. package/lib/browser/chunk-VYSDLBSS.mjs.map +0 -1
  194. package/lib/browser/glossary-7152281e.d.ts +0 -69
  195. package/lib/browser/index.d.ts +0 -83
  196. package/lib/browser/index.js +0 -81
  197. package/lib/browser/index.js.map +0 -1
  198. package/lib/browser/interceptors/WebSocket/index.d.ts +0 -271
  199. package/lib/browser/interceptors/WebSocket/index.js +0 -721
  200. package/lib/browser/interceptors/WebSocket/index.js.map +0 -1
  201. package/lib/browser/interceptors/XMLHttpRequest/index.d.ts +0 -15
  202. package/lib/browser/interceptors/XMLHttpRequest/index.js +0 -12
  203. package/lib/browser/interceptors/XMLHttpRequest/index.js.map +0 -1
  204. package/lib/browser/interceptors/XMLHttpRequest/index.mjs.map +0 -1
  205. package/lib/browser/interceptors/fetch/index.d.ts +0 -14
  206. package/lib/browser/interceptors/fetch/index.js +0 -11
  207. package/lib/browser/interceptors/fetch/index.js.map +0 -1
  208. package/lib/browser/interceptors/fetch/index.mjs.map +0 -1
  209. package/lib/browser/presets/browser.d.ts +0 -15
  210. package/lib/browser/presets/browser.js +0 -21
  211. package/lib/browser/presets/browser.js.map +0 -1
  212. package/lib/node/BatchInterceptor-5b72232f.d.ts +0 -24
  213. package/lib/node/Interceptor-bc5a9d8e.d.ts +0 -130
  214. package/lib/node/RemoteHttpInterceptor.d.ts +0 -45
  215. package/lib/node/RemoteHttpInterceptor.js +0 -193
  216. package/lib/node/RemoteHttpInterceptor.js.map +0 -1
  217. package/lib/node/chunk-3CNGDJFB.mjs +0 -313
  218. package/lib/node/chunk-3CNGDJFB.mjs.map +0 -1
  219. package/lib/node/chunk-3GJB4JDF.mjs +0 -14
  220. package/lib/node/chunk-3GJB4JDF.mjs.map +0 -1
  221. package/lib/node/chunk-4NEYTVWD.mjs +0 -848
  222. package/lib/node/chunk-4NEYTVWD.mjs.map +0 -1
  223. package/lib/node/chunk-4YBV77DG.js +0 -32
  224. package/lib/node/chunk-4YBV77DG.js.map +0 -1
  225. package/lib/node/chunk-6HYIRFX2.mjs +0 -22
  226. package/lib/node/chunk-6HYIRFX2.mjs.map +0 -1
  227. package/lib/node/chunk-6YM4PLBI.mjs +0 -7
  228. package/lib/node/chunk-6YM4PLBI.mjs.map +0 -1
  229. package/lib/node/chunk-72ZIHMEB.js +0 -249
  230. package/lib/node/chunk-72ZIHMEB.js.map +0 -1
  231. package/lib/node/chunk-73NOP3T5.js +0 -7
  232. package/lib/node/chunk-73NOP3T5.js.map +0 -1
  233. package/lib/node/chunk-A7Q4RTDJ.mjs +0 -249
  234. package/lib/node/chunk-A7Q4RTDJ.mjs.map +0 -1
  235. package/lib/node/chunk-A7U44ARP.js +0 -268
  236. package/lib/node/chunk-A7U44ARP.js.map +0 -1
  237. package/lib/node/chunk-EKNRB5ZS.mjs +0 -1115
  238. package/lib/node/chunk-EKNRB5ZS.mjs.map +0 -1
  239. package/lib/node/chunk-IHJSPMYM.mjs +0 -268
  240. package/lib/node/chunk-IHJSPMYM.mjs.map +0 -1
  241. package/lib/node/chunk-LK6DILFK.js +0 -22
  242. package/lib/node/chunk-LK6DILFK.js.map +0 -1
  243. package/lib/node/chunk-N4ZZFE24.js +0 -1115
  244. package/lib/node/chunk-N4ZZFE24.js.map +0 -1
  245. package/lib/node/chunk-PFGO5BSM.js +0 -25
  246. package/lib/node/chunk-PFGO5BSM.js.map +0 -1
  247. package/lib/node/chunk-R6JVCM7X.js +0 -51
  248. package/lib/node/chunk-R6JVCM7X.js.map +0 -1
  249. package/lib/node/chunk-RC2XPCC4.mjs +0 -51
  250. package/lib/node/chunk-RC2XPCC4.mjs.map +0 -1
  251. package/lib/node/chunk-SMXZPJEA.js +0 -14
  252. package/lib/node/chunk-SMXZPJEA.js.map +0 -1
  253. package/lib/node/chunk-TJDMZZXE.mjs +0 -32
  254. package/lib/node/chunk-TJDMZZXE.mjs.map +0 -1
  255. package/lib/node/chunk-TX5GBTFY.mjs +0 -25
  256. package/lib/node/chunk-TX5GBTFY.mjs.map +0 -1
  257. package/lib/node/chunk-VV2LUF5K.js +0 -848
  258. package/lib/node/chunk-VV2LUF5K.js.map +0 -1
  259. package/lib/node/chunk-Z5LWCBZS.js +0 -313
  260. package/lib/node/chunk-Z5LWCBZS.js.map +0 -1
  261. package/lib/node/index.d.ts +0 -62
  262. package/lib/node/index.js +0 -43
  263. package/lib/node/index.js.map +0 -1
  264. package/lib/node/interceptors/ClientRequest/index.d.ts +0 -111
  265. package/lib/node/interceptors/ClientRequest/index.js +0 -11
  266. package/lib/node/interceptors/ClientRequest/index.js.map +0 -1
  267. package/lib/node/interceptors/ClientRequest/index.mjs.map +0 -1
  268. package/lib/node/interceptors/XMLHttpRequest/index.d.ts +0 -14
  269. package/lib/node/interceptors/XMLHttpRequest/index.js +0 -13
  270. package/lib/node/interceptors/XMLHttpRequest/index.js.map +0 -1
  271. package/lib/node/interceptors/XMLHttpRequest/index.mjs.map +0 -1
  272. package/lib/node/interceptors/fetch/index.d.ts +0 -13
  273. package/lib/node/interceptors/fetch/index.js +0 -12
  274. package/lib/node/interceptors/fetch/index.js.map +0 -1
  275. package/lib/node/interceptors/fetch/index.mjs.map +0 -1
  276. package/lib/node/presets/node.d.ts +0 -16
  277. package/lib/node/presets/node.js +0 -27
  278. package/lib/node/presets/node.js.map +0 -1
  279. package/lib/node/utils/node/index.js +0 -10
  280. package/lib/node/utils/node/index.js.map +0 -1
  281. package/lib/node/utils/node/index.mjs.map +0 -1
  282. package/src/utils/RequestController.ts +0 -21
@@ -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,30 @@
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
+ exports.BatchInterceptor = require_BatchInterceptor.BatchInterceptor;
17
+ exports.FetchResponse = require_fetchUtils.FetchResponse;
18
+ exports.INTERNAL_REQUEST_ID_HEADER_NAME = require_fetchUtils.INTERNAL_REQUEST_ID_HEADER_NAME;
19
+ exports.IS_PATCHED_MODULE = require_glossary.IS_PATCHED_MODULE;
20
+ exports.Interceptor = require_fetchUtils.Interceptor;
21
+ exports.InterceptorReadyState = require_fetchUtils.InterceptorReadyState;
22
+ exports.RequestController = require_fetchUtils.RequestController;
23
+ exports.createRequestId = require_fetchUtils.createRequestId;
24
+ exports.decodeBuffer = require_bufferUtils.decodeBuffer;
25
+ exports.deleteGlobalSymbol = require_fetchUtils.deleteGlobalSymbol;
26
+ exports.encodeBuffer = require_bufferUtils.encodeBuffer;
27
+ exports.getCleanUrl = getCleanUrl;
28
+ exports.getGlobalSymbol = require_fetchUtils.getGlobalSymbol;
29
+ exports.getRawRequest = require_getRawRequest.getRawRequest;
30
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/getCleanUrl.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"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG"}
@@ -0,0 +1,66 @@
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
+ 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 };
66
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,66 @@
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
+ 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 };
66
+ //# sourceMappingURL=index.d.mts.map
@@ -1,43 +1,17 @@
1
- import {
2
- BatchInterceptor
3
- } from "./chunk-RC2XPCC4.mjs";
4
- import {
5
- decodeBuffer,
6
- encodeBuffer
7
- } from "./chunk-6HYIRFX2.mjs";
8
- import {
9
- IS_PATCHED_MODULE
10
- } from "./chunk-6YM4PLBI.mjs";
11
- import {
12
- FetchResponse,
13
- INTERNAL_REQUEST_ID_HEADER_NAME,
14
- Interceptor,
15
- InterceptorReadyState,
16
- createRequestId,
17
- deleteGlobalSymbol,
18
- getGlobalSymbol
19
- } from "./chunk-IHJSPMYM.mjs";
20
- import {
21
- getRawRequest
22
- } from "./chunk-3GJB4JDF.mjs";
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";
23
6
 
24
- // src/utils/getCleanUrl.ts
7
+ //#region src/utils/getCleanUrl.ts
8
+ /**
9
+ * Removes query parameters and hashes from a given URL.
10
+ */
25
11
  function getCleanUrl(url, isAbsolute = true) {
26
- return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
12
+ return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
27
13
  }
28
- export {
29
- BatchInterceptor,
30
- FetchResponse,
31
- INTERNAL_REQUEST_ID_HEADER_NAME,
32
- IS_PATCHED_MODULE,
33
- Interceptor,
34
- InterceptorReadyState,
35
- createRequestId,
36
- decodeBuffer,
37
- deleteGlobalSymbol,
38
- encodeBuffer,
39
- getCleanUrl,
40
- getGlobalSymbol,
41
- getRawRequest
42
- };
14
+
15
+ //#endregion
16
+ export { BatchInterceptor, FetchResponse, INTERNAL_REQUEST_ID_HEADER_NAME, IS_PATCHED_MODULE, Interceptor, InterceptorReadyState, RequestController, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest };
43
17
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/getCleanUrl.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE;","names":[]}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/getCleanUrl.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"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG"}
@@ -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 };
@@ -1,11 +1,6 @@
1
- import {
2
- ClientRequestInterceptor
3
- } from "../../chunk-EKNRB5ZS.mjs";
4
- import "../../chunk-TJDMZZXE.mjs";
5
- import "../../chunk-A7Q4RTDJ.mjs";
6
- import "../../chunk-IHJSPMYM.mjs";
7
- import "../../chunk-3GJB4JDF.mjs";
8
- export {
9
- ClientRequestInterceptor
10
- };
11
- //# sourceMappingURL=index.mjs.map
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
@@ -1,13 +1,6 @@
1
- import {
2
- XMLHttpRequestInterceptor
3
- } from "../../chunk-4NEYTVWD.mjs";
4
- import "../../chunk-6HYIRFX2.mjs";
5
- import "../../chunk-TX5GBTFY.mjs";
6
- import "../../chunk-6YM4PLBI.mjs";
7
- import "../../chunk-A7Q4RTDJ.mjs";
8
- import "../../chunk-IHJSPMYM.mjs";
9
- import "../../chunk-3GJB4JDF.mjs";
10
- export {
11
- XMLHttpRequestInterceptor
12
- };
13
- //# sourceMappingURL=index.mjs.map
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
@@ -1,12 +1,5 @@
1
- import {
2
- FetchInterceptor
3
- } from "../../chunk-3CNGDJFB.mjs";
4
- import "../../chunk-TX5GBTFY.mjs";
5
- import "../../chunk-6YM4PLBI.mjs";
6
- import "../../chunk-A7Q4RTDJ.mjs";
7
- import "../../chunk-IHJSPMYM.mjs";
8
- import "../../chunk-3GJB4JDF.mjs";
9
- export {
10
- FetchInterceptor
11
- };
12
- //# sourceMappingURL=index.mjs.map
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