@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,218 @@
1
+ import { DeferredPromise } from "@open-draft/deferred-promise";
2
+ import { invariant } from "outvariant";
3
+
4
+ //#region src/glossary.ts
5
+ const IS_PATCHED_MODULE = Symbol("isPatchedModule");
6
+
7
+ //#endregion
8
+ //#region src/InterceptorError.ts
9
+ var InterceptorError = class InterceptorError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "InterceptorError";
13
+ Object.setPrototypeOf(this, InterceptorError.prototype);
14
+ }
15
+ };
16
+
17
+ //#endregion
18
+ //#region src/RequestController.ts
19
+ var RequestController = class RequestController {
20
+ static {
21
+ this.PENDING = 0;
22
+ }
23
+ static {
24
+ this.PASSTHROUGH = 1;
25
+ }
26
+ static {
27
+ this.RESPONSE = 2;
28
+ }
29
+ static {
30
+ this.ERROR = 3;
31
+ }
32
+ constructor(request, source) {
33
+ this.request = request;
34
+ this.source = source;
35
+ this.readyState = RequestController.PENDING;
36
+ this.handled = new DeferredPromise();
37
+ }
38
+ get #handled() {
39
+ return this.handled;
40
+ }
41
+ /**
42
+ * Perform this request as-is.
43
+ */
44
+ async passthrough() {
45
+ invariant.as(InterceptorError, this.readyState === RequestController.PENDING, "Failed to passthrough the \"%s %s\" request: the request has already been handled", this.request.method, this.request.url);
46
+ this.readyState = RequestController.PASSTHROUGH;
47
+ await this.source.passthrough();
48
+ this.#handled.resolve();
49
+ }
50
+ /**
51
+ * Respond to this request with the given `Response` instance.
52
+ *
53
+ * @example
54
+ * controller.respondWith(new Response())
55
+ * controller.respondWith(Response.json({ id }))
56
+ * controller.respondWith(Response.error())
57
+ */
58
+ respondWith(response) {
59
+ invariant.as(InterceptorError, this.readyState === RequestController.PENDING, "Failed to respond to the \"%s %s\" request with \"%d %s\": the request has already been handled (%d)", this.request.method, this.request.url, response.status, response.statusText || "OK", this.readyState);
60
+ this.readyState = RequestController.RESPONSE;
61
+ this.#handled.resolve();
62
+ /**
63
+ * @note Although `source.respondWith()` is potentially asynchronous,
64
+ * do NOT await it for backward-compatibility. Awaiting it will short-circuit
65
+ * the request listener invocation as soon as a listener responds to a request.
66
+ * Ideally, that's what we want, but that's not what we promise the user.
67
+ */
68
+ this.source.respondWith(response);
69
+ }
70
+ /**
71
+ * Error this request with the given reason.
72
+ *
73
+ * @example
74
+ * controller.errorWith()
75
+ * controller.errorWith(new Error('Oops!'))
76
+ * controller.errorWith({ message: 'Oops!'})
77
+ */
78
+ errorWith(reason) {
79
+ invariant.as(InterceptorError, this.readyState === RequestController.PENDING, "Failed to error the \"%s %s\" request with \"%s\": the request has already been handled (%d)", this.request.method, this.request.url, reason?.toString(), this.readyState);
80
+ this.readyState = RequestController.ERROR;
81
+ this.source.errorWith(reason);
82
+ this.#handled.resolve();
83
+ }
84
+ };
85
+
86
+ //#endregion
87
+ //#region src/utils/canParseUrl.ts
88
+ /**
89
+ * Returns a boolean indicating whether the given URL string
90
+ * can be parsed into a `URL` instance.
91
+ * A substitute for `URL.canParse()` for Node.js 18.
92
+ */
93
+ function canParseUrl(url) {
94
+ try {
95
+ new URL(url);
96
+ return true;
97
+ } catch (_error) {
98
+ return false;
99
+ }
100
+ }
101
+
102
+ //#endregion
103
+ //#region src/utils/getValueBySymbol.ts
104
+ /**
105
+ * Returns the value behind the symbol with the given name.
106
+ */
107
+ function getValueBySymbol(symbolName, source) {
108
+ const symbol = Object.getOwnPropertySymbols(source).find((symbol$1) => {
109
+ return symbol$1.description === symbolName;
110
+ });
111
+ if (symbol) return Reflect.get(source, symbol);
112
+ }
113
+
114
+ //#endregion
115
+ //#region src/utils/fetchUtils.ts
116
+ var FetchResponse = class FetchResponse extends Response {
117
+ static {
118
+ this.STATUS_CODES_WITHOUT_BODY = [
119
+ 101,
120
+ 103,
121
+ 204,
122
+ 205,
123
+ 304
124
+ ];
125
+ }
126
+ static {
127
+ this.STATUS_CODES_WITH_REDIRECT = [
128
+ 301,
129
+ 302,
130
+ 303,
131
+ 307,
132
+ 308
133
+ ];
134
+ }
135
+ static isConfigurableStatusCode(status) {
136
+ return status >= 200 && status <= 599;
137
+ }
138
+ static isRedirectResponse(status) {
139
+ return FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
140
+ }
141
+ /**
142
+ * Returns a boolean indicating whether the given response status
143
+ * code represents a response that can have a body.
144
+ */
145
+ static isResponseWithBody(status) {
146
+ return !FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
147
+ }
148
+ static setUrl(url, response) {
149
+ if (!url || url === "about:" || !canParseUrl(url)) return;
150
+ const state = getValueBySymbol("state", response);
151
+ if (state) state.urlList.push(new URL(url));
152
+ else Object.defineProperty(response, "url", {
153
+ value: url,
154
+ enumerable: true,
155
+ configurable: true,
156
+ writable: false
157
+ });
158
+ }
159
+ /**
160
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
161
+ */
162
+ static parseRawHeaders(rawHeaders) {
163
+ const headers = new Headers();
164
+ for (let line = 0; line < rawHeaders.length; line += 2) headers.append(rawHeaders[line], rawHeaders[line + 1]);
165
+ return headers;
166
+ }
167
+ constructor(body, init = {}) {
168
+ const status = init.status ?? 200;
169
+ const safeStatus = FetchResponse.isConfigurableStatusCode(status) ? status : 200;
170
+ const finalBody = FetchResponse.isResponseWithBody(status) ? body : null;
171
+ super(finalBody, {
172
+ status: safeStatus,
173
+ statusText: init.statusText,
174
+ headers: init.headers
175
+ });
176
+ if (status !== safeStatus) {
177
+ /**
178
+ * @note Undici keeps an internal "Symbol(state)" that holds
179
+ * the actual value of response status. Update that in Node.js.
180
+ */
181
+ const state = getValueBySymbol("state", this);
182
+ if (state) state.status = status;
183
+ else Object.defineProperty(this, "status", {
184
+ value: status,
185
+ enumerable: true,
186
+ configurable: true,
187
+ writable: false
188
+ });
189
+ }
190
+ FetchResponse.setUrl(init.url, this);
191
+ }
192
+ };
193
+
194
+ //#endregion
195
+ //#region src/getRawRequest.ts
196
+ const kRawRequest = Symbol("kRawRequest");
197
+ /**
198
+ * Returns a raw request instance associated with this request.
199
+ *
200
+ * @example
201
+ * interceptor.on('request', ({ request }) => {
202
+ * const rawRequest = getRawRequest(request)
203
+ *
204
+ * if (rawRequest instanceof http.ClientRequest) {
205
+ * console.log(rawRequest.rawHeaders)
206
+ * }
207
+ * })
208
+ */
209
+ function getRawRequest(request) {
210
+ return Reflect.get(request, kRawRequest);
211
+ }
212
+ function setRawRequest(request, rawRequest) {
213
+ Reflect.set(request, kRawRequest, rawRequest);
214
+ }
215
+
216
+ //#endregion
217
+ export { RequestController as a, canParseUrl as i, setRawRequest as n, InterceptorError as o, FetchResponse as r, IS_PATCHED_MODULE as s, getRawRequest as t };
218
+ //# sourceMappingURL=getRawRequest-BTaNLFr0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRawRequest-BTaNLFr0.mjs","names":["IS_PATCHED_MODULE: unique symbol","request: Request","source: RequestControllerSource","#handled","symbol"],"sources":["../../src/glossary.ts","../../src/InterceptorError.ts","../../src/RequestController.ts","../../src/utils/canParseUrl.ts","../../src/utils/getValueBySymbol.ts","../../src/utils/fetchUtils.ts","../../src/getRawRequest.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","export class InterceptorError extends Error {\n constructor(message?: string) {\n super(message)\n this.name = 'InterceptorError'\n Object.setPrototypeOf(this, InterceptorError.prototype)\n }\n}\n","import { DeferredPromise } from '@open-draft/deferred-promise'\nimport { invariant } from 'outvariant'\nimport { InterceptorError } from './InterceptorError'\n\nexport interface RequestControllerSource {\n passthrough(): void\n respondWith(response: Response): void\n errorWith(reason?: unknown): void\n}\n\nexport class RequestController {\n static PENDING = 0 as const\n static PASSTHROUGH = 1 as const\n static RESPONSE = 2 as const\n static ERROR = 3 as const\n\n public readyState: number\n\n /**\n * A Promise that resolves when this controller handles a request.\n * See `controller.readyState` for more information on the handling result.\n */\n public handled: Promise<void>\n\n constructor(\n protected readonly request: Request,\n protected readonly source: RequestControllerSource\n ) {\n this.readyState = RequestController.PENDING\n this.handled = new DeferredPromise<void>()\n }\n\n get #handled() {\n return this.handled as DeferredPromise<void>\n }\n\n /**\n * Perform this request as-is.\n */\n public async passthrough(): Promise<void> {\n invariant.as(\n InterceptorError,\n this.readyState === RequestController.PENDING,\n 'Failed to passthrough the \"%s %s\" request: the request has already been handled',\n this.request.method,\n this.request.url\n )\n\n this.readyState = RequestController.PASSTHROUGH\n await this.source.passthrough()\n this.#handled.resolve()\n }\n\n /**\n * Respond to this request with the given `Response` instance.\n *\n * @example\n * controller.respondWith(new Response())\n * controller.respondWith(Response.json({ id }))\n * controller.respondWith(Response.error())\n */\n public respondWith(response: Response): void {\n invariant.as(\n InterceptorError,\n this.readyState === RequestController.PENDING,\n 'Failed to respond to the \"%s %s\" request with \"%d %s\": the request has already been handled (%d)',\n this.request.method,\n this.request.url,\n response.status,\n response.statusText || 'OK',\n this.readyState\n )\n\n this.readyState = RequestController.RESPONSE\n this.#handled.resolve()\n\n /**\n * @note Although `source.respondWith()` is potentially asynchronous,\n * do NOT await it for backward-compatibility. Awaiting it will short-circuit\n * the request listener invocation as soon as a listener responds to a request.\n * Ideally, that's what we want, but that's not what we promise the user.\n */\n this.source.respondWith(response)\n }\n\n /**\n * Error this request with the given reason.\n *\n * @example\n * controller.errorWith()\n * controller.errorWith(new Error('Oops!'))\n * controller.errorWith({ message: 'Oops!'})\n */\n public errorWith(reason?: unknown): void {\n invariant.as(\n InterceptorError,\n this.readyState === RequestController.PENDING,\n 'Failed to error the \"%s %s\" request with \"%s\": the request has already been handled (%d)',\n this.request.method,\n this.request.url,\n reason?.toString(),\n this.readyState\n )\n\n this.readyState = RequestController.ERROR\n this.source.errorWith(reason)\n this.#handled.resolve()\n }\n}\n","/**\n * Returns a boolean indicating whether the given URL string\n * can be parsed into a `URL` instance.\n * A substitute for `URL.canParse()` for Node.js 18.\n */\nexport function canParseUrl(url: string): boolean {\n try {\n new URL(url)\n return true\n } catch (_error) {\n return false\n }\n}\n","/**\n * Returns the value behind the symbol with the given name.\n */\nexport function getValueBySymbol<T>(\n symbolName: string,\n source: object\n): T | undefined {\n const ownSymbols = Object.getOwnPropertySymbols(source)\n\n const symbol = ownSymbols.find((symbol) => {\n return symbol.description === symbolName\n })\n\n if (symbol) {\n return Reflect.get(source, symbol)\n }\n\n return\n}\n","import { canParseUrl } from './canParseUrl'\nimport { getValueBySymbol } from './getValueBySymbol'\n\nexport interface FetchResponseInit extends ResponseInit {\n url?: string\n}\n\ninterface UndiciFetchInternalState {\n aborted: boolean\n rangeRequested: boolean\n timingAllowPassed: boolean\n requestIncludesCredentials: boolean\n type: ResponseType\n status: number\n statusText: string\n timingInfo: unknown\n cacheState: unknown\n headersList: Record<symbol, Map<string, unknown>>\n urlList: Array<URL>\n body?: {\n stream: ReadableStream\n source: unknown\n length: number\n }\n}\n\nexport class FetchResponse extends Response {\n /**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\n static readonly STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304]\n\n static readonly STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308]\n\n static isConfigurableStatusCode(status: number): boolean {\n return status >= 200 && status <= 599\n }\n\n static isRedirectResponse(status: number): boolean {\n return FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status)\n }\n\n /**\n * Returns a boolean indicating whether the given response status\n * code represents a response that can have a body.\n */\n static isResponseWithBody(status: number): boolean {\n return !FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status)\n }\n\n static setUrl(url: string | undefined, response: Response): void {\n if (!url || url === 'about:' || !canParseUrl(url)) {\n return\n }\n\n const state = getValueBySymbol<UndiciFetchInternalState>('state', response)\n\n if (state) {\n // In Undici, push the URL to the internal list of URLs.\n // This will respect the `response.url` getter logic correctly.\n state.urlList.push(new URL(url))\n } else {\n // In other libraries, redefine the `url` property directly.\n Object.defineProperty(response, 'url', {\n value: url,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n }\n\n /**\n * Parses the given raw HTTP headers into a Fetch API `Headers` instance.\n */\n static parseRawHeaders(rawHeaders: Array<string>): Headers {\n const headers = new Headers()\n for (let line = 0; line < rawHeaders.length; line += 2) {\n headers.append(rawHeaders[line], rawHeaders[line + 1])\n }\n return headers\n }\n\n constructor(body?: BodyInit | null, init: FetchResponseInit = {}) {\n const status = init.status ?? 200\n const safeStatus = FetchResponse.isConfigurableStatusCode(status)\n ? status\n : 200\n const finalBody = FetchResponse.isResponseWithBody(status) ? body : null\n\n super(finalBody, {\n status: safeStatus,\n statusText: init.statusText,\n headers: init.headers,\n })\n\n if (status !== safeStatus) {\n /**\n * @note Undici keeps an internal \"Symbol(state)\" that holds\n * the actual value of response status. Update that in Node.js.\n */\n const state = getValueBySymbol<UndiciFetchInternalState>('state', this)\n\n if (state) {\n state.status = status\n } else {\n Object.defineProperty(this, 'status', {\n value: status,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n }\n\n FetchResponse.setUrl(init.url, this)\n }\n}\n","const kRawRequest = Symbol('kRawRequest')\n\n/**\n * Returns a raw request instance associated with this request.\n *\n * @example\n * interceptor.on('request', ({ request }) => {\n * const rawRequest = getRawRequest(request)\n *\n * if (rawRequest instanceof http.ClientRequest) {\n * console.log(rawRequest.rawHeaders)\n * }\n * })\n */\nexport function getRawRequest(request: Request): unknown | undefined {\n return Reflect.get(request, kRawRequest)\n}\n\nexport function setRawRequest(request: Request, rawRequest: unknown): void {\n Reflect.set(request, kRawRequest, rawRequest)\n}\n"],"mappings":";;;;AAEA,MAAaA,oBAAmC,OAAO,kBAAkB;;;;ACFzE,IAAa,mBAAb,MAAa,yBAAyB,MAAM;CAC1C,YAAY,SAAkB;AAC5B,QAAM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AAU;IACpC,OAAO;IACP,YAAY;IACZ,cAAc;IACd,UAAU;IACX,CAAC;;AAIN,gBAAc,OAAO,KAAK,KAAK,KAAK;;;;;;ACpHxC,MAAM,cAAc,OAAO,cAAc;;;;;;;;;;;;;AAczC,SAAgB,cAAc,SAAuC;AACnE,QAAO,QAAQ,IAAI,SAAS,YAAY;;AAG1C,SAAgB,cAAc,SAAkB,YAA2B;AACzE,SAAQ,IAAI,SAAS,aAAa,WAAW"}
@@ -0,0 +1,259 @@
1
+ let _open_draft_deferred_promise = require("@open-draft/deferred-promise");
2
+ let outvariant = require("outvariant");
3
+
4
+ //#region src/glossary.ts
5
+ const IS_PATCHED_MODULE = Symbol("isPatchedModule");
6
+
7
+ //#endregion
8
+ //#region src/InterceptorError.ts
9
+ var InterceptorError = class InterceptorError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "InterceptorError";
13
+ Object.setPrototypeOf(this, InterceptorError.prototype);
14
+ }
15
+ };
16
+
17
+ //#endregion
18
+ //#region src/RequestController.ts
19
+ var RequestController = class RequestController {
20
+ static {
21
+ this.PENDING = 0;
22
+ }
23
+ static {
24
+ this.PASSTHROUGH = 1;
25
+ }
26
+ static {
27
+ this.RESPONSE = 2;
28
+ }
29
+ static {
30
+ this.ERROR = 3;
31
+ }
32
+ constructor(request, source) {
33
+ this.request = request;
34
+ this.source = source;
35
+ this.readyState = RequestController.PENDING;
36
+ this.handled = new _open_draft_deferred_promise.DeferredPromise();
37
+ }
38
+ get #handled() {
39
+ return this.handled;
40
+ }
41
+ /**
42
+ * Perform this request as-is.
43
+ */
44
+ async passthrough() {
45
+ outvariant.invariant.as(InterceptorError, this.readyState === RequestController.PENDING, "Failed to passthrough the \"%s %s\" request: the request has already been handled", this.request.method, this.request.url);
46
+ this.readyState = RequestController.PASSTHROUGH;
47
+ await this.source.passthrough();
48
+ this.#handled.resolve();
49
+ }
50
+ /**
51
+ * Respond to this request with the given `Response` instance.
52
+ *
53
+ * @example
54
+ * controller.respondWith(new Response())
55
+ * controller.respondWith(Response.json({ id }))
56
+ * controller.respondWith(Response.error())
57
+ */
58
+ respondWith(response) {
59
+ outvariant.invariant.as(InterceptorError, this.readyState === RequestController.PENDING, "Failed to respond to the \"%s %s\" request with \"%d %s\": the request has already been handled (%d)", this.request.method, this.request.url, response.status, response.statusText || "OK", this.readyState);
60
+ this.readyState = RequestController.RESPONSE;
61
+ this.#handled.resolve();
62
+ /**
63
+ * @note Although `source.respondWith()` is potentially asynchronous,
64
+ * do NOT await it for backward-compatibility. Awaiting it will short-circuit
65
+ * the request listener invocation as soon as a listener responds to a request.
66
+ * Ideally, that's what we want, but that's not what we promise the user.
67
+ */
68
+ this.source.respondWith(response);
69
+ }
70
+ /**
71
+ * Error this request with the given reason.
72
+ *
73
+ * @example
74
+ * controller.errorWith()
75
+ * controller.errorWith(new Error('Oops!'))
76
+ * controller.errorWith({ message: 'Oops!'})
77
+ */
78
+ errorWith(reason) {
79
+ outvariant.invariant.as(InterceptorError, this.readyState === RequestController.PENDING, "Failed to error the \"%s %s\" request with \"%s\": the request has already been handled (%d)", this.request.method, this.request.url, reason?.toString(), this.readyState);
80
+ this.readyState = RequestController.ERROR;
81
+ this.source.errorWith(reason);
82
+ this.#handled.resolve();
83
+ }
84
+ };
85
+
86
+ //#endregion
87
+ //#region src/utils/canParseUrl.ts
88
+ /**
89
+ * Returns a boolean indicating whether the given URL string
90
+ * can be parsed into a `URL` instance.
91
+ * A substitute for `URL.canParse()` for Node.js 18.
92
+ */
93
+ function canParseUrl(url) {
94
+ try {
95
+ new URL(url);
96
+ return true;
97
+ } catch (_error) {
98
+ return false;
99
+ }
100
+ }
101
+
102
+ //#endregion
103
+ //#region src/utils/getValueBySymbol.ts
104
+ /**
105
+ * Returns the value behind the symbol with the given name.
106
+ */
107
+ function getValueBySymbol(symbolName, source) {
108
+ const symbol = Object.getOwnPropertySymbols(source).find((symbol$1) => {
109
+ return symbol$1.description === symbolName;
110
+ });
111
+ if (symbol) return Reflect.get(source, symbol);
112
+ }
113
+
114
+ //#endregion
115
+ //#region src/utils/fetchUtils.ts
116
+ var FetchResponse = class FetchResponse extends Response {
117
+ static {
118
+ this.STATUS_CODES_WITHOUT_BODY = [
119
+ 101,
120
+ 103,
121
+ 204,
122
+ 205,
123
+ 304
124
+ ];
125
+ }
126
+ static {
127
+ this.STATUS_CODES_WITH_REDIRECT = [
128
+ 301,
129
+ 302,
130
+ 303,
131
+ 307,
132
+ 308
133
+ ];
134
+ }
135
+ static isConfigurableStatusCode(status) {
136
+ return status >= 200 && status <= 599;
137
+ }
138
+ static isRedirectResponse(status) {
139
+ return FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
140
+ }
141
+ /**
142
+ * Returns a boolean indicating whether the given response status
143
+ * code represents a response that can have a body.
144
+ */
145
+ static isResponseWithBody(status) {
146
+ return !FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
147
+ }
148
+ static setUrl(url, response) {
149
+ if (!url || url === "about:" || !canParseUrl(url)) return;
150
+ const state = getValueBySymbol("state", response);
151
+ if (state) state.urlList.push(new URL(url));
152
+ else Object.defineProperty(response, "url", {
153
+ value: url,
154
+ enumerable: true,
155
+ configurable: true,
156
+ writable: false
157
+ });
158
+ }
159
+ /**
160
+ * Parses the given raw HTTP headers into a Fetch API `Headers` instance.
161
+ */
162
+ static parseRawHeaders(rawHeaders) {
163
+ const headers = new Headers();
164
+ for (let line = 0; line < rawHeaders.length; line += 2) headers.append(rawHeaders[line], rawHeaders[line + 1]);
165
+ return headers;
166
+ }
167
+ constructor(body, init = {}) {
168
+ const status = init.status ?? 200;
169
+ const safeStatus = FetchResponse.isConfigurableStatusCode(status) ? status : 200;
170
+ const finalBody = FetchResponse.isResponseWithBody(status) ? body : null;
171
+ super(finalBody, {
172
+ status: safeStatus,
173
+ statusText: init.statusText,
174
+ headers: init.headers
175
+ });
176
+ if (status !== safeStatus) {
177
+ /**
178
+ * @note Undici keeps an internal "Symbol(state)" that holds
179
+ * the actual value of response status. Update that in Node.js.
180
+ */
181
+ const state = getValueBySymbol("state", this);
182
+ if (state) state.status = status;
183
+ else Object.defineProperty(this, "status", {
184
+ value: status,
185
+ enumerable: true,
186
+ configurable: true,
187
+ writable: false
188
+ });
189
+ }
190
+ FetchResponse.setUrl(init.url, this);
191
+ }
192
+ };
193
+
194
+ //#endregion
195
+ //#region src/getRawRequest.ts
196
+ const kRawRequest = Symbol("kRawRequest");
197
+ /**
198
+ * Returns a raw request instance associated with this request.
199
+ *
200
+ * @example
201
+ * interceptor.on('request', ({ request }) => {
202
+ * const rawRequest = getRawRequest(request)
203
+ *
204
+ * if (rawRequest instanceof http.ClientRequest) {
205
+ * console.log(rawRequest.rawHeaders)
206
+ * }
207
+ * })
208
+ */
209
+ function getRawRequest(request) {
210
+ return Reflect.get(request, kRawRequest);
211
+ }
212
+ function setRawRequest(request, rawRequest) {
213
+ Reflect.set(request, kRawRequest, rawRequest);
214
+ }
215
+
216
+ //#endregion
217
+ Object.defineProperty(exports, 'FetchResponse', {
218
+ enumerable: true,
219
+ get: function () {
220
+ return FetchResponse;
221
+ }
222
+ });
223
+ Object.defineProperty(exports, 'IS_PATCHED_MODULE', {
224
+ enumerable: true,
225
+ get: function () {
226
+ return IS_PATCHED_MODULE;
227
+ }
228
+ });
229
+ Object.defineProperty(exports, 'InterceptorError', {
230
+ enumerable: true,
231
+ get: function () {
232
+ return InterceptorError;
233
+ }
234
+ });
235
+ Object.defineProperty(exports, 'RequestController', {
236
+ enumerable: true,
237
+ get: function () {
238
+ return RequestController;
239
+ }
240
+ });
241
+ Object.defineProperty(exports, 'canParseUrl', {
242
+ enumerable: true,
243
+ get: function () {
244
+ return canParseUrl;
245
+ }
246
+ });
247
+ Object.defineProperty(exports, 'getRawRequest', {
248
+ enumerable: true,
249
+ get: function () {
250
+ return getRawRequest;
251
+ }
252
+ });
253
+ Object.defineProperty(exports, 'setRawRequest', {
254
+ enumerable: true,
255
+ get: function () {
256
+ return setRawRequest;
257
+ }
258
+ });
259
+ //# sourceMappingURL=getRawRequest-zx8rUJL2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRawRequest-zx8rUJL2.cjs","names":["IS_PATCHED_MODULE: unique symbol","request: Request","source: RequestControllerSource","DeferredPromise","#handled","symbol"],"sources":["../../src/glossary.ts","../../src/InterceptorError.ts","../../src/RequestController.ts","../../src/utils/canParseUrl.ts","../../src/utils/getValueBySymbol.ts","../../src/utils/fetchUtils.ts","../../src/getRawRequest.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","export class InterceptorError extends Error {\n constructor(message?: string) {\n super(message)\n this.name = 'InterceptorError'\n Object.setPrototypeOf(this, InterceptorError.prototype)\n }\n}\n","import { DeferredPromise } from '@open-draft/deferred-promise'\nimport { invariant } from 'outvariant'\nimport { InterceptorError } from './InterceptorError'\n\nexport interface RequestControllerSource {\n passthrough(): void\n respondWith(response: Response): void\n errorWith(reason?: unknown): void\n}\n\nexport class RequestController {\n static PENDING = 0 as const\n static PASSTHROUGH = 1 as const\n static RESPONSE = 2 as const\n static ERROR = 3 as const\n\n public readyState: number\n\n /**\n * A Promise that resolves when this controller handles a request.\n * See `controller.readyState` for more information on the handling result.\n */\n public handled: Promise<void>\n\n constructor(\n protected readonly request: Request,\n protected readonly source: RequestControllerSource\n ) {\n this.readyState = RequestController.PENDING\n this.handled = new DeferredPromise<void>()\n }\n\n get #handled() {\n return this.handled as DeferredPromise<void>\n }\n\n /**\n * Perform this request as-is.\n */\n public async passthrough(): Promise<void> {\n invariant.as(\n InterceptorError,\n this.readyState === RequestController.PENDING,\n 'Failed to passthrough the \"%s %s\" request: the request has already been handled',\n this.request.method,\n this.request.url\n )\n\n this.readyState = RequestController.PASSTHROUGH\n await this.source.passthrough()\n this.#handled.resolve()\n }\n\n /**\n * Respond to this request with the given `Response` instance.\n *\n * @example\n * controller.respondWith(new Response())\n * controller.respondWith(Response.json({ id }))\n * controller.respondWith(Response.error())\n */\n public respondWith(response: Response): void {\n invariant.as(\n InterceptorError,\n this.readyState === RequestController.PENDING,\n 'Failed to respond to the \"%s %s\" request with \"%d %s\": the request has already been handled (%d)',\n this.request.method,\n this.request.url,\n response.status,\n response.statusText || 'OK',\n this.readyState\n )\n\n this.readyState = RequestController.RESPONSE\n this.#handled.resolve()\n\n /**\n * @note Although `source.respondWith()` is potentially asynchronous,\n * do NOT await it for backward-compatibility. Awaiting it will short-circuit\n * the request listener invocation as soon as a listener responds to a request.\n * Ideally, that's what we want, but that's not what we promise the user.\n */\n this.source.respondWith(response)\n }\n\n /**\n * Error this request with the given reason.\n *\n * @example\n * controller.errorWith()\n * controller.errorWith(new Error('Oops!'))\n * controller.errorWith({ message: 'Oops!'})\n */\n public errorWith(reason?: unknown): void {\n invariant.as(\n InterceptorError,\n this.readyState === RequestController.PENDING,\n 'Failed to error the \"%s %s\" request with \"%s\": the request has already been handled (%d)',\n this.request.method,\n this.request.url,\n reason?.toString(),\n this.readyState\n )\n\n this.readyState = RequestController.ERROR\n this.source.errorWith(reason)\n this.#handled.resolve()\n }\n}\n","/**\n * Returns a boolean indicating whether the given URL string\n * can be parsed into a `URL` instance.\n * A substitute for `URL.canParse()` for Node.js 18.\n */\nexport function canParseUrl(url: string): boolean {\n try {\n new URL(url)\n return true\n } catch (_error) {\n return false\n }\n}\n","/**\n * Returns the value behind the symbol with the given name.\n */\nexport function getValueBySymbol<T>(\n symbolName: string,\n source: object\n): T | undefined {\n const ownSymbols = Object.getOwnPropertySymbols(source)\n\n const symbol = ownSymbols.find((symbol) => {\n return symbol.description === symbolName\n })\n\n if (symbol) {\n return Reflect.get(source, symbol)\n }\n\n return\n}\n","import { canParseUrl } from './canParseUrl'\nimport { getValueBySymbol } from './getValueBySymbol'\n\nexport interface FetchResponseInit extends ResponseInit {\n url?: string\n}\n\ninterface UndiciFetchInternalState {\n aborted: boolean\n rangeRequested: boolean\n timingAllowPassed: boolean\n requestIncludesCredentials: boolean\n type: ResponseType\n status: number\n statusText: string\n timingInfo: unknown\n cacheState: unknown\n headersList: Record<symbol, Map<string, unknown>>\n urlList: Array<URL>\n body?: {\n stream: ReadableStream\n source: unknown\n length: number\n }\n}\n\nexport class FetchResponse extends Response {\n /**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\n static readonly STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304]\n\n static readonly STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308]\n\n static isConfigurableStatusCode(status: number): boolean {\n return status >= 200 && status <= 599\n }\n\n static isRedirectResponse(status: number): boolean {\n return FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status)\n }\n\n /**\n * Returns a boolean indicating whether the given response status\n * code represents a response that can have a body.\n */\n static isResponseWithBody(status: number): boolean {\n return !FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status)\n }\n\n static setUrl(url: string | undefined, response: Response): void {\n if (!url || url === 'about:' || !canParseUrl(url)) {\n return\n }\n\n const state = getValueBySymbol<UndiciFetchInternalState>('state', response)\n\n if (state) {\n // In Undici, push the URL to the internal list of URLs.\n // This will respect the `response.url` getter logic correctly.\n state.urlList.push(new URL(url))\n } else {\n // In other libraries, redefine the `url` property directly.\n Object.defineProperty(response, 'url', {\n value: url,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n }\n\n /**\n * Parses the given raw HTTP headers into a Fetch API `Headers` instance.\n */\n static parseRawHeaders(rawHeaders: Array<string>): Headers {\n const headers = new Headers()\n for (let line = 0; line < rawHeaders.length; line += 2) {\n headers.append(rawHeaders[line], rawHeaders[line + 1])\n }\n return headers\n }\n\n constructor(body?: BodyInit | null, init: FetchResponseInit = {}) {\n const status = init.status ?? 200\n const safeStatus = FetchResponse.isConfigurableStatusCode(status)\n ? status\n : 200\n const finalBody = FetchResponse.isResponseWithBody(status) ? body : null\n\n super(finalBody, {\n status: safeStatus,\n statusText: init.statusText,\n headers: init.headers,\n })\n\n if (status !== safeStatus) {\n /**\n * @note Undici keeps an internal \"Symbol(state)\" that holds\n * the actual value of response status. Update that in Node.js.\n */\n const state = getValueBySymbol<UndiciFetchInternalState>('state', this)\n\n if (state) {\n state.status = status\n } else {\n Object.defineProperty(this, 'status', {\n value: status,\n enumerable: true,\n configurable: true,\n writable: false,\n })\n }\n }\n\n FetchResponse.setUrl(init.url, this)\n }\n}\n","const kRawRequest = Symbol('kRawRequest')\n\n/**\n * Returns a raw request instance associated with this request.\n *\n * @example\n * interceptor.on('request', ({ request }) => {\n * const rawRequest = getRawRequest(request)\n *\n * if (rawRequest instanceof http.ClientRequest) {\n * console.log(rawRequest.rawHeaders)\n * }\n * })\n */\nexport function getRawRequest(request: Request): unknown | undefined {\n return Reflect.get(request, kRawRequest)\n}\n\nexport function setRawRequest(request: Request, rawRequest: unknown): void {\n Reflect.set(request, kRawRequest, rawRequest)\n}\n"],"mappings":";;;;AAEA,MAAaA,oBAAmC,OAAO,kBAAkB;;;;ACFzE,IAAa,mBAAb,MAAa,yBAAyB,MAAM;CAC1C,YAAY,SAAkB;AAC5B,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,SAAO,eAAe,MAAM,iBAAiB,UAAU;;;;;;ACM3D,IAAa,oBAAb,MAAa,kBAAkB;;iBACZ;;;qBACI;;;kBACH;;;eACH;;CAUf,YACE,AAAmBC,SACnB,AAAmBC,QACnB;EAFmB;EACA;AAEnB,OAAK,aAAa,kBAAkB;AACpC,OAAK,UAAU,IAAIC,8CAAuB;;C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2B;AACzE,SAAQ,IAAI,SAAS,aAAa,WAAW"}
@@ -0,0 +1,70 @@
1
+ //#region src/RequestController.d.ts
2
+ interface RequestControllerSource {
3
+ passthrough(): void;
4
+ respondWith(response: Response): void;
5
+ errorWith(reason?: unknown): void;
6
+ }
7
+ declare class RequestController {
8
+ #private;
9
+ protected readonly request: Request;
10
+ protected readonly source: RequestControllerSource;
11
+ static PENDING: 0;
12
+ static PASSTHROUGH: 1;
13
+ static RESPONSE: 2;
14
+ static ERROR: 3;
15
+ readyState: number;
16
+ /**
17
+ * A Promise that resolves when this controller handles a request.
18
+ * See `controller.readyState` for more information on the handling result.
19
+ */
20
+ handled: Promise<void>;
21
+ constructor(request: Request, source: RequestControllerSource);
22
+ /**
23
+ * Perform this request as-is.
24
+ */
25
+ passthrough(): Promise<void>;
26
+ /**
27
+ * Respond to this request with the given `Response` instance.
28
+ *
29
+ * @example
30
+ * controller.respondWith(new Response())
31
+ * controller.respondWith(Response.json({ id }))
32
+ * controller.respondWith(Response.error())
33
+ */
34
+ respondWith(response: Response): void;
35
+ /**
36
+ * Error this request with the given reason.
37
+ *
38
+ * @example
39
+ * controller.errorWith()
40
+ * controller.errorWith(new Error('Oops!'))
41
+ * controller.errorWith({ message: 'Oops!'})
42
+ */
43
+ errorWith(reason?: unknown): void;
44
+ }
45
+ //#endregion
46
+ //#region src/glossary.d.ts
47
+ declare const IS_PATCHED_MODULE: unique symbol;
48
+ type RequestCredentials = 'omit' | 'include' | 'same-origin';
49
+ type HttpRequestEventMap = {
50
+ request: [args: {
51
+ request: Request;
52
+ requestId: string;
53
+ controller: RequestController;
54
+ }];
55
+ response: [args: {
56
+ response: Response;
57
+ isMockedResponse: boolean;
58
+ request: Request;
59
+ requestId: string;
60
+ }];
61
+ unhandledException: [args: {
62
+ error: unknown;
63
+ request: Request;
64
+ requestId: string;
65
+ controller: RequestController;
66
+ }];
67
+ };
68
+ //#endregion
69
+ export { RequestControllerSource as a, RequestController as i, IS_PATCHED_MODULE as n, RequestCredentials as r, HttpRequestEventMap as t };
70
+ //# sourceMappingURL=glossary-BdLS4k1H.d.cts.map
@@ -0,0 +1,70 @@
1
+ //#region src/RequestController.d.ts
2
+ interface RequestControllerSource {
3
+ passthrough(): void;
4
+ respondWith(response: Response): void;
5
+ errorWith(reason?: unknown): void;
6
+ }
7
+ declare class RequestController {
8
+ #private;
9
+ protected readonly request: Request;
10
+ protected readonly source: RequestControllerSource;
11
+ static PENDING: 0;
12
+ static PASSTHROUGH: 1;
13
+ static RESPONSE: 2;
14
+ static ERROR: 3;
15
+ readyState: number;
16
+ /**
17
+ * A Promise that resolves when this controller handles a request.
18
+ * See `controller.readyState` for more information on the handling result.
19
+ */
20
+ handled: Promise<void>;
21
+ constructor(request: Request, source: RequestControllerSource);
22
+ /**
23
+ * Perform this request as-is.
24
+ */
25
+ passthrough(): Promise<void>;
26
+ /**
27
+ * Respond to this request with the given `Response` instance.
28
+ *
29
+ * @example
30
+ * controller.respondWith(new Response())
31
+ * controller.respondWith(Response.json({ id }))
32
+ * controller.respondWith(Response.error())
33
+ */
34
+ respondWith(response: Response): void;
35
+ /**
36
+ * Error this request with the given reason.
37
+ *
38
+ * @example
39
+ * controller.errorWith()
40
+ * controller.errorWith(new Error('Oops!'))
41
+ * controller.errorWith({ message: 'Oops!'})
42
+ */
43
+ errorWith(reason?: unknown): void;
44
+ }
45
+ //#endregion
46
+ //#region src/glossary.d.ts
47
+ declare const IS_PATCHED_MODULE: unique symbol;
48
+ type RequestCredentials = 'omit' | 'include' | 'same-origin';
49
+ type HttpRequestEventMap = {
50
+ request: [args: {
51
+ request: Request;
52
+ requestId: string;
53
+ controller: RequestController;
54
+ }];
55
+ response: [args: {
56
+ response: Response;
57
+ isMockedResponse: boolean;
58
+ request: Request;
59
+ requestId: string;
60
+ }];
61
+ unhandledException: [args: {
62
+ error: unknown;
63
+ request: Request;
64
+ requestId: string;
65
+ controller: RequestController;
66
+ }];
67
+ };
68
+ //#endregion
69
+ export { RequestControllerSource as a, RequestController as i, IS_PATCHED_MODULE as n, RequestCredentials as r, HttpRequestEventMap as t };
70
+ //# sourceMappingURL=glossary-gEEJhK4S.d.mts.map