@mswjs/interceptors 0.41.3 → 0.41.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/{XMLHttpRequest-BACqefB-.cjs → XMLHttpRequest-DSAhl6_a.cjs} +10 -22
- package/lib/browser/XMLHttpRequest-DSAhl6_a.cjs.map +1 -0
- package/lib/browser/{XMLHttpRequest-BvxZV0WU.mjs → XMLHttpRequest-DYyDAIJh.mjs} +10 -22
- package/lib/browser/XMLHttpRequest-DYyDAIJh.mjs.map +1 -0
- package/lib/browser/{createRequestId-Cs4oXfa1.cjs → createRequestId-DOf8Ktjs.cjs} +1 -1
- package/lib/browser/{createRequestId-Cs4oXfa1.cjs.map → createRequestId-DOf8Ktjs.cjs.map} +1 -1
- package/lib/browser/{createRequestId-DQcIlohW.mjs → createRequestId-DYCsFHOi.mjs} +1 -1
- package/lib/browser/{createRequestId-DQcIlohW.mjs.map → createRequestId-DYCsFHOi.mjs.map} +1 -1
- package/lib/browser/{fetch-U3v3Y4ap.cjs → fetch-BMC2en2x.cjs} +11 -26
- package/lib/browser/fetch-BMC2en2x.cjs.map +1 -0
- package/lib/browser/{fetch-DdKEdDOR.mjs → fetch-D5LGhx5i.mjs} +11 -26
- package/lib/browser/fetch-D5LGhx5i.mjs.map +1 -0
- package/lib/browser/{getRawRequest-zx8rUJL2.cjs → getRawRequest-B9kRTvjs.cjs} +81 -9
- package/lib/browser/getRawRequest-B9kRTvjs.cjs.map +1 -0
- package/lib/browser/{getRawRequest-BTaNLFr0.mjs → getRawRequest-BEw5hEOW.mjs} +78 -6
- package/lib/browser/getRawRequest-BEw5hEOW.mjs.map +1 -0
- package/lib/browser/{glossary-BdLS4k1H.d.cts → glossary-1lhZx6Aw.d.cts} +2 -3
- package/lib/browser/{glossary-DYwOrogs.d.mts → glossary-nkHWcwvY.d.mts} +2 -3
- package/lib/browser/{handleRequest-CvX2G-Lz.cjs → handleRequest-BCtqvFSS.cjs} +3 -3
- package/lib/browser/{handleRequest-CvX2G-Lz.cjs.map → handleRequest-BCtqvFSS.cjs.map} +1 -1
- package/lib/browser/{handleRequest-D7kpTI5U.mjs → handleRequest-DuUoGpfA.mjs} +3 -3
- package/lib/browser/{handleRequest-D7kpTI5U.mjs.map → handleRequest-DuUoGpfA.mjs.map} +1 -1
- package/lib/browser/hasConfigurableGlobal-B39W0thh.mjs +98 -0
- package/lib/browser/hasConfigurableGlobal-B39W0thh.mjs.map +1 -0
- package/lib/browser/hasConfigurableGlobal-B5o6PHq3.cjs +115 -0
- package/lib/browser/hasConfigurableGlobal-B5o6PHq3.cjs.map +1 -0
- package/lib/browser/index.cjs +3 -3
- package/lib/browser/index.d.cts +21 -2
- package/lib/browser/index.d.mts +21 -2
- package/lib/browser/index.mjs +3 -3
- package/lib/browser/interceptors/WebSocket/index.cjs +6 -10
- package/lib/browser/interceptors/WebSocket/index.cjs.map +1 -1
- package/lib/browser/interceptors/WebSocket/index.mjs +6 -10
- package/lib/browser/interceptors/WebSocket/index.mjs.map +1 -1
- package/lib/browser/interceptors/XMLHttpRequest/index.cjs +5 -4
- package/lib/browser/interceptors/XMLHttpRequest/index.d.cts +1 -1
- package/lib/browser/interceptors/XMLHttpRequest/index.d.mts +1 -1
- package/lib/browser/interceptors/XMLHttpRequest/index.mjs +5 -4
- package/lib/browser/interceptors/fetch/index.cjs +5 -4
- package/lib/browser/interceptors/fetch/index.d.cts +1 -1
- package/lib/browser/interceptors/fetch/index.d.mts +1 -1
- package/lib/browser/interceptors/fetch/index.mjs +5 -4
- package/lib/browser/presets/browser.cjs +6 -5
- package/lib/browser/presets/browser.cjs.map +1 -1
- package/lib/browser/presets/browser.mjs +6 -5
- package/lib/browser/presets/browser.mjs.map +1 -1
- package/lib/node/{BatchInterceptor-3LnAnLTx.cjs → BatchInterceptor-AZr7q8p_.cjs} +2 -2
- package/lib/node/{BatchInterceptor-3LnAnLTx.cjs.map → BatchInterceptor-AZr7q8p_.cjs.map} +1 -1
- package/lib/node/{BatchInterceptor-DFaBPilf.mjs → BatchInterceptor-B2YAn5m9.mjs} +2 -2
- package/lib/node/{BatchInterceptor-DFaBPilf.mjs.map → BatchInterceptor-B2YAn5m9.mjs.map} +1 -1
- package/lib/node/{BatchInterceptor-D_YqR8qU.d.cts → BatchInterceptor-KKF8Q47I.d.cts} +2 -2
- package/lib/node/{BatchInterceptor-D7mXzHcQ.d.mts → BatchInterceptor-rSr-NH_H.d.mts} +2 -2
- package/lib/node/{ClientRequest-Ca8Qykuv.mjs → ClientRequest-5WjHvs9Y.mjs} +20 -6
- package/lib/node/ClientRequest-5WjHvs9Y.mjs.map +1 -0
- package/lib/node/{ClientRequest-2rDe54Ui.cjs → ClientRequest-BgwQG-9G.cjs} +20 -6
- package/lib/node/ClientRequest-BgwQG-9G.cjs.map +1 -0
- package/lib/node/{Interceptor-DEazpLJd.d.mts → Interceptor-BsZ21ue0.d.cts} +2 -3
- package/lib/node/{Interceptor-DJ2akVWI.d.cts → Interceptor-soD-WpQO.d.mts} +2 -3
- package/lib/node/RemoteHttpInterceptor.cjs +10 -9
- package/lib/node/RemoteHttpInterceptor.cjs.map +1 -1
- package/lib/node/RemoteHttpInterceptor.d.cts +3 -3
- package/lib/node/RemoteHttpInterceptor.d.mts +3 -3
- package/lib/node/RemoteHttpInterceptor.mjs +10 -9
- package/lib/node/RemoteHttpInterceptor.mjs.map +1 -1
- package/lib/node/{XMLHttpRequest-B7kJdYYI.cjs → XMLHttpRequest-B7sloBex.cjs} +11 -24
- package/lib/node/XMLHttpRequest-B7sloBex.cjs.map +1 -0
- package/lib/node/{XMLHttpRequest-C8dIZpds.mjs → XMLHttpRequest-DmsdUGmj.mjs} +11 -24
- package/lib/node/XMLHttpRequest-DmsdUGmj.mjs.map +1 -0
- package/lib/node/{bufferUtils-_8XfKIfX.mjs → bufferUtils-DxPxwff_.mjs} +1 -1
- package/lib/node/{bufferUtils-_8XfKIfX.mjs.map → bufferUtils-DxPxwff_.mjs.map} +1 -1
- package/lib/node/{bufferUtils-DiCTqG-7.cjs → bufferUtils-S5_-2eN4.cjs} +1 -1
- package/lib/node/{bufferUtils-DiCTqG-7.cjs.map → bufferUtils-S5_-2eN4.cjs.map} +1 -1
- package/lib/node/{fetch-G1DVwDKG.mjs → fetch-DDAGTtZi.mjs} +11 -27
- package/lib/node/fetch-DDAGTtZi.mjs.map +1 -0
- package/lib/node/{fetch-BmXpK10r.cjs → fetch-uc7pNtPg.cjs} +11 -27
- package/lib/node/fetch-uc7pNtPg.cjs.map +1 -0
- package/lib/node/{fetchUtils-CoU35g3M.mjs → fetchUtils-BJxD7wvl.mjs} +78 -2
- package/lib/node/{fetchUtils-BaY5iWXw.cjs.map → fetchUtils-BJxD7wvl.mjs.map} +1 -1
- package/lib/node/{fetchUtils-BaY5iWXw.cjs → fetchUtils-Dw6kQghF.cjs} +83 -1
- package/lib/node/fetchUtils-Dw6kQghF.cjs.map +1 -0
- package/lib/node/{getRawRequest-BavnMWh_.cjs → getRawRequest-B6znU6il.cjs} +1 -1
- package/lib/node/{getRawRequest-BavnMWh_.cjs.map → getRawRequest-B6znU6il.cjs.map} +1 -1
- package/lib/node/{getRawRequest-DnwmXyOW.mjs → getRawRequest-C2-1urzA.mjs} +1 -1
- package/lib/node/{getRawRequest-DnwmXyOW.mjs.map → getRawRequest-C2-1urzA.mjs.map} +1 -1
- package/lib/node/{handleRequest-Y97UwBbF.mjs → handleRequest-DGfUg9bm.mjs} +2 -2
- package/lib/node/{handleRequest-Y97UwBbF.mjs.map → handleRequest-DGfUg9bm.mjs.map} +1 -1
- package/lib/node/{handleRequest-Bb7Y-XLw.cjs → handleRequest-Dzg1d3e5.cjs} +2 -2
- package/lib/node/{handleRequest-Bb7Y-XLw.cjs.map → handleRequest-Dzg1d3e5.cjs.map} +1 -1
- package/lib/node/hasConfigurableGlobal-Befl_QJD.cjs +97 -0
- package/lib/node/hasConfigurableGlobal-Befl_QJD.cjs.map +1 -0
- package/lib/node/hasConfigurableGlobal-jN_-v3gp.mjs +85 -0
- package/lib/node/hasConfigurableGlobal-jN_-v3gp.mjs.map +1 -0
- package/lib/node/{index-BMbJ8FXL.d.cts → index-BJ5E5aW-.d.cts} +2 -2
- package/lib/node/{index-C0YAQ36w.d.mts → index-DfoF45ih.d.mts} +2 -2
- package/lib/node/index.cjs +5 -6
- package/lib/node/index.cjs.map +1 -1
- package/lib/node/index.d.cts +22 -3
- package/lib/node/index.d.mts +22 -3
- package/lib/node/index.mjs +5 -6
- package/lib/node/index.mjs.map +1 -1
- package/lib/node/interceptors/ClientRequest/index.cjs +4 -4
- package/lib/node/interceptors/ClientRequest/index.d.cts +1 -1
- package/lib/node/interceptors/ClientRequest/index.d.mts +2 -2
- package/lib/node/interceptors/ClientRequest/index.mjs +4 -4
- package/lib/node/interceptors/XMLHttpRequest/index.cjs +5 -4
- package/lib/node/interceptors/XMLHttpRequest/index.d.cts +1 -1
- package/lib/node/interceptors/XMLHttpRequest/index.d.mts +1 -1
- package/lib/node/interceptors/XMLHttpRequest/index.mjs +5 -4
- package/lib/node/interceptors/fetch/index.cjs +4 -3
- package/lib/node/interceptors/fetch/index.d.cts +1 -1
- package/lib/node/interceptors/fetch/index.d.mts +1 -1
- package/lib/node/interceptors/fetch/index.mjs +4 -3
- package/lib/node/{node-dKdAf3tC.cjs → node-DIKcnzhK.cjs} +2 -2
- package/lib/node/{node-dKdAf3tC.cjs.map → node-DIKcnzhK.cjs.map} +1 -1
- package/lib/node/{node-DwCc6iuP.mjs → node-lsdNwZEW.mjs} +2 -2
- package/lib/node/{node-DwCc6iuP.mjs.map → node-lsdNwZEW.mjs.map} +1 -1
- package/lib/node/presets/node.cjs +8 -7
- package/lib/node/presets/node.cjs.map +1 -1
- package/lib/node/presets/node.d.cts +1 -1
- package/lib/node/presets/node.d.mts +2 -2
- package/lib/node/presets/node.mjs +8 -7
- package/lib/node/presets/node.mjs.map +1 -1
- package/lib/node/utils/node/index.cjs +1 -1
- package/lib/node/utils/node/index.mjs +1 -1
- package/package.json +1 -1
- package/src/RemoteHttpInterceptor.ts +2 -2
- package/src/glossary.ts +3 -5
- package/src/index.ts +1 -1
- package/src/interceptors/ClientRequest/MockHttpSocket.ts +2 -2
- package/src/interceptors/ClientRequest/utils/recordRawHeaders.ts +18 -0
- package/src/interceptors/WebSocket/index.ts +8 -15
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +2 -1
- package/src/interceptors/XMLHttpRequest/index.ts +12 -32
- package/src/interceptors/fetch/index.ts +10 -26
- package/src/utils/fetchUtils.test.ts +85 -0
- package/src/utils/fetchUtils.ts +139 -3
- package/src/utils/globalUtils.test.ts +144 -0
- package/src/utils/globalsRegistry.ts +107 -0
- package/src/utils/hasConfigurableGlobal.test.ts +11 -0
- package/src/utils/hasConfigurableGlobal.ts +9 -3
- package/lib/browser/XMLHttpRequest-BACqefB-.cjs.map +0 -1
- package/lib/browser/XMLHttpRequest-BvxZV0WU.mjs.map +0 -1
- package/lib/browser/fetch-DdKEdDOR.mjs.map +0 -1
- package/lib/browser/fetch-U3v3Y4ap.cjs.map +0 -1
- package/lib/browser/getRawRequest-BTaNLFr0.mjs.map +0 -1
- package/lib/browser/getRawRequest-zx8rUJL2.cjs.map +0 -1
- package/lib/browser/hasConfigurableGlobal-BvCTG97d.cjs +0 -45
- package/lib/browser/hasConfigurableGlobal-BvCTG97d.cjs.map +0 -1
- package/lib/browser/hasConfigurableGlobal-npXitu1-.mjs +0 -33
- package/lib/browser/hasConfigurableGlobal-npXitu1-.mjs.map +0 -1
- package/lib/node/ClientRequest-2rDe54Ui.cjs.map +0 -1
- package/lib/node/ClientRequest-Ca8Qykuv.mjs.map +0 -1
- package/lib/node/XMLHttpRequest-B7kJdYYI.cjs.map +0 -1
- package/lib/node/XMLHttpRequest-C8dIZpds.mjs.map +0 -1
- package/lib/node/fetch-BmXpK10r.cjs.map +0 -1
- package/lib/node/fetch-G1DVwDKG.mjs.map +0 -1
- package/lib/node/fetchUtils-CoU35g3M.mjs.map +0 -1
- package/lib/node/glossary-BLKRyLBd.cjs +0 -12
- package/lib/node/glossary-BLKRyLBd.cjs.map +0 -1
- package/lib/node/glossary-glQBRnVD.mjs +0 -6
- package/lib/node/glossary-glQBRnVD.mjs.map +0 -1
- package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs +0 -26
- package/lib/node/hasConfigurableGlobal-C97fWuaA.cjs.map +0 -1
- package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs +0 -20
- package/lib/node/hasConfigurableGlobal-DBJA0vjm.mjs.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
+
let outvariant = require("outvariant");
|
|
3
|
+
|
|
4
|
+
//#region src/utils/globalsRegistry.ts
|
|
5
|
+
var GlobalsRegistry = class {
|
|
6
|
+
#globals = /* @__PURE__ */ new Map();
|
|
7
|
+
replaceGlobal(key, nextValue) {
|
|
8
|
+
(0, outvariant.invariant)(!this.#globals.has(key), `Failed to replace a global value at "${key}": already replaced.`);
|
|
9
|
+
const match = getDeepPropertyDescriptor(globalThis, key);
|
|
10
|
+
if (typeof match === "undefined") {
|
|
11
|
+
console.warn(`Failed to replace a global value at "${key}": not a global value.`);
|
|
12
|
+
return () => {};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(globalThis, key, {
|
|
15
|
+
value: nextValue,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true
|
|
18
|
+
});
|
|
19
|
+
const restoreGlobal = () => {
|
|
20
|
+
if (!this.#globals.has(key)) return;
|
|
21
|
+
if (match.owner === globalThis) Object.defineProperty(match.owner, key, match.descriptor);
|
|
22
|
+
else
|
|
23
|
+
/**
|
|
24
|
+
* @todo Delete the proxy property set by the registry.
|
|
25
|
+
* If the owner isn't `globalThis`, the property is likely nested in the prototype.
|
|
26
|
+
* The registry does not meddle with those, they are left intact.
|
|
27
|
+
*/
|
|
28
|
+
Reflect.deleteProperty(globalThis, key);
|
|
29
|
+
this.#globals.delete(key);
|
|
30
|
+
};
|
|
31
|
+
this.#globals.set(key, restoreGlobal);
|
|
32
|
+
return restoreGlobal;
|
|
33
|
+
}
|
|
34
|
+
restoreAllGlobals() {
|
|
35
|
+
const errors = [];
|
|
36
|
+
for (const [, restoreGlobal] of this.#globals) try {
|
|
37
|
+
restoreGlobal();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error instanceof Error) errors.push(error);
|
|
40
|
+
else throw error;
|
|
41
|
+
}
|
|
42
|
+
if (errors.length > 0) throw new AggregateError(errors, "FOO!");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const globalsRegistry = new GlobalsRegistry();
|
|
46
|
+
/**
|
|
47
|
+
* Returns a property descriptor for the given property on the owner.
|
|
48
|
+
* Walks down the prototype chain if the property does not exist on the owner.
|
|
49
|
+
* Handy for getting a global property descriptor where `globalThis` is
|
|
50
|
+
* replaced with a controlled class (e.g. ServiceWorkerGlobalScope).
|
|
51
|
+
*/
|
|
52
|
+
function getDeepPropertyDescriptor(owner, key) {
|
|
53
|
+
let currentOwner = owner;
|
|
54
|
+
let descriptor;
|
|
55
|
+
while (currentOwner) {
|
|
56
|
+
descriptor = Object.getOwnPropertyDescriptor(currentOwner, key);
|
|
57
|
+
if (descriptor) return {
|
|
58
|
+
owner: currentOwner,
|
|
59
|
+
descriptor
|
|
60
|
+
};
|
|
61
|
+
currentOwner = Object.getPrototypeOf(currentOwner);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/utils/hasConfigurableGlobal.ts
|
|
67
|
+
/**
|
|
68
|
+
* Returns a boolean indicating whether the given global property
|
|
69
|
+
* is defined and is configurable.
|
|
70
|
+
*/
|
|
71
|
+
function hasConfigurableGlobal(propertyName) {
|
|
72
|
+
const match = getDeepPropertyDescriptor(globalThis, propertyName);
|
|
73
|
+
if (typeof match === "undefined") return false;
|
|
74
|
+
const { descriptor } = match;
|
|
75
|
+
if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") return false;
|
|
76
|
+
if (typeof descriptor.get === "undefined" && descriptor.value == null) return false;
|
|
77
|
+
if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
|
|
78
|
+
console.error(`[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
Object.defineProperty(exports, 'globalsRegistry', {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () {
|
|
88
|
+
return globalsRegistry;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, 'hasConfigurableGlobal', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return hasConfigurableGlobal;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=hasConfigurableGlobal-Befl_QJD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasConfigurableGlobal-Befl_QJD.cjs","names":["#globals","errors: Array<Error>","currentOwner: Owner | null","descriptor: PropertyDescriptor | undefined"],"sources":["../../src/utils/globalsRegistry.ts","../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["import { invariant } from 'outvariant'\n\nclass GlobalsRegistry {\n #globals = new Map<keyof typeof globalThis, () => void>()\n\n public replaceGlobal<K extends keyof typeof globalThis>(\n key: K,\n nextValue: (typeof globalThis)[K]\n ): () => void {\n invariant(\n !this.#globals.has(key),\n `Failed to replace a global value at \"${key}\": already replaced.`\n )\n\n const match = getDeepPropertyDescriptor(globalThis, key)\n\n if (typeof match === 'undefined') {\n console.warn(\n `Failed to replace a global value at \"${key}\": not a global value.`\n )\n return () => {}\n }\n\n Object.defineProperty(globalThis, key, {\n value: nextValue,\n enumerable: true,\n configurable: true,\n })\n\n const restoreGlobal = () => {\n if (!this.#globals.has(key)) {\n return\n }\n\n if (match.owner === globalThis) {\n Object.defineProperty(match.owner, key, match.descriptor)\n } else {\n /**\n * @todo Delete the proxy property set by the registry.\n * If the owner isn't `globalThis`, the property is likely nested in the prototype.\n * The registry does not meddle with those, they are left intact.\n */\n Reflect.deleteProperty(globalThis, key)\n }\n\n this.#globals.delete(key)\n }\n\n this.#globals.set(key, restoreGlobal)\n\n return restoreGlobal\n }\n\n public restoreAllGlobals(): void {\n const errors: Array<Error> = []\n\n for (const [, restoreGlobal] of this.#globals) {\n try {\n restoreGlobal()\n } catch (error) {\n if (error instanceof Error) {\n errors.push(error)\n } else {\n throw error\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'FOO!')\n }\n }\n}\n\nexport const globalsRegistry = new GlobalsRegistry()\n\ninterface DeepDescriptorMatch {\n owner: object\n descriptor: PropertyDescriptor\n}\n\n/**\n * Returns a property descriptor for the given property on the owner.\n * Walks down the prototype chain if the property does not exist on the owner.\n * Handy for getting a global property descriptor where `globalThis` is\n * replaced with a controlled class (e.g. ServiceWorkerGlobalScope).\n */\nexport function getDeepPropertyDescriptor<Owner extends object>(\n owner: Owner,\n key: keyof Owner\n): DeepDescriptorMatch | undefined {\n let currentOwner: Owner | null = owner\n let descriptor: PropertyDescriptor | undefined\n\n while (currentOwner) {\n descriptor = Object.getOwnPropertyDescriptor(currentOwner, key)\n\n if (descriptor) {\n return {\n owner: currentOwner,\n descriptor,\n }\n }\n\n currentOwner = Object.getPrototypeOf(currentOwner)\n }\n}\n","import { getDeepPropertyDescriptor } from './globalsRegistry'\n\n/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(\n propertyName: keyof typeof globalThis\n): boolean {\n const match = getDeepPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof match === 'undefined') {\n return false\n }\n\n const { descriptor } = match\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";;;;AAEA,IAAM,kBAAN,MAAsB;CACpB,2BAAW,IAAI,KAA0C;CAEzD,AAAO,cACL,KACA,WACY;AACZ,4BACE,CAAC,MAAKA,QAAS,IAAI,IAAI,EACvB,wCAAwC,IAAI,sBAC7C;EAED,MAAM,QAAQ,0BAA0B,YAAY,IAAI;AAExD,MAAI,OAAO,UAAU,aAAa;AAChC,WAAQ,KACN,wCAAwC,IAAI,wBAC7C;AACD,gBAAa;;AAGf,SAAO,eAAe,YAAY,KAAK;GACrC,OAAO;GACP,YAAY;GACZ,cAAc;GACf,CAAC;EAEF,MAAM,sBAAsB;AAC1B,OAAI,CAAC,MAAKA,QAAS,IAAI,IAAI,CACzB;AAGF,OAAI,MAAM,UAAU,WAClB,QAAO,eAAe,MAAM,OAAO,KAAK,MAAM,WAAW;;;;;;;AAOzD,WAAQ,eAAe,YAAY,IAAI;AAGzC,SAAKA,QAAS,OAAO,IAAI;;AAG3B,QAAKA,QAAS,IAAI,KAAK,cAAc;AAErC,SAAO;;CAGT,AAAO,oBAA0B;EAC/B,MAAMC,SAAuB,EAAE;AAE/B,OAAK,MAAM,GAAG,kBAAkB,MAAKD,QACnC,KAAI;AACF,kBAAe;WACR,OAAO;AACd,OAAI,iBAAiB,MACnB,QAAO,KAAK,MAAM;OAElB,OAAM;;AAKZ,MAAI,OAAO,SAAS,EAClB,OAAM,IAAI,eAAe,QAAQ,OAAO;;;AAK9C,MAAa,kBAAkB,IAAI,iBAAiB;;;;;;;AAapD,SAAgB,0BACd,OACA,KACiC;CACjC,IAAIE,eAA6B;CACjC,IAAIC;AAEJ,QAAO,cAAc;AACnB,eAAa,OAAO,yBAAyB,cAAc,IAAI;AAE/D,MAAI,WACF,QAAO;GACL,OAAO;GACP;GACD;AAGH,iBAAe,OAAO,eAAe,aAAa;;;;;;;;;;AClGtD,SAAgB,sBACd,cACS;CACT,MAAM,QAAQ,0BAA0B,YAAY,aAAa;AAGjE,KAAI,OAAO,UAAU,YACnB,QAAO;CAGT,MAAM,EAAE,eAAe;AAGvB,KACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,KAAK,KAAK,YAE5B,QAAO;AAIT,KAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,KAC/D,QAAO;AAGT,KAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,UAAQ,MACN,mDAAmD,aAAa,oKACjE;AACD,SAAO;;AAGT,QAAO"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { invariant } from "outvariant";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/globalsRegistry.ts
|
|
4
|
+
var GlobalsRegistry = class {
|
|
5
|
+
#globals = /* @__PURE__ */ new Map();
|
|
6
|
+
replaceGlobal(key, nextValue) {
|
|
7
|
+
invariant(!this.#globals.has(key), `Failed to replace a global value at "${key}": already replaced.`);
|
|
8
|
+
const match = getDeepPropertyDescriptor(globalThis, key);
|
|
9
|
+
if (typeof match === "undefined") {
|
|
10
|
+
console.warn(`Failed to replace a global value at "${key}": not a global value.`);
|
|
11
|
+
return () => {};
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(globalThis, key, {
|
|
14
|
+
value: nextValue,
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
const restoreGlobal = () => {
|
|
19
|
+
if (!this.#globals.has(key)) return;
|
|
20
|
+
if (match.owner === globalThis) Object.defineProperty(match.owner, key, match.descriptor);
|
|
21
|
+
else
|
|
22
|
+
/**
|
|
23
|
+
* @todo Delete the proxy property set by the registry.
|
|
24
|
+
* If the owner isn't `globalThis`, the property is likely nested in the prototype.
|
|
25
|
+
* The registry does not meddle with those, they are left intact.
|
|
26
|
+
*/
|
|
27
|
+
Reflect.deleteProperty(globalThis, key);
|
|
28
|
+
this.#globals.delete(key);
|
|
29
|
+
};
|
|
30
|
+
this.#globals.set(key, restoreGlobal);
|
|
31
|
+
return restoreGlobal;
|
|
32
|
+
}
|
|
33
|
+
restoreAllGlobals() {
|
|
34
|
+
const errors = [];
|
|
35
|
+
for (const [, restoreGlobal] of this.#globals) try {
|
|
36
|
+
restoreGlobal();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error instanceof Error) errors.push(error);
|
|
39
|
+
else throw error;
|
|
40
|
+
}
|
|
41
|
+
if (errors.length > 0) throw new AggregateError(errors, "FOO!");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const globalsRegistry = new GlobalsRegistry();
|
|
45
|
+
/**
|
|
46
|
+
* Returns a property descriptor for the given property on the owner.
|
|
47
|
+
* Walks down the prototype chain if the property does not exist on the owner.
|
|
48
|
+
* Handy for getting a global property descriptor where `globalThis` is
|
|
49
|
+
* replaced with a controlled class (e.g. ServiceWorkerGlobalScope).
|
|
50
|
+
*/
|
|
51
|
+
function getDeepPropertyDescriptor(owner, key) {
|
|
52
|
+
let currentOwner = owner;
|
|
53
|
+
let descriptor;
|
|
54
|
+
while (currentOwner) {
|
|
55
|
+
descriptor = Object.getOwnPropertyDescriptor(currentOwner, key);
|
|
56
|
+
if (descriptor) return {
|
|
57
|
+
owner: currentOwner,
|
|
58
|
+
descriptor
|
|
59
|
+
};
|
|
60
|
+
currentOwner = Object.getPrototypeOf(currentOwner);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/utils/hasConfigurableGlobal.ts
|
|
66
|
+
/**
|
|
67
|
+
* Returns a boolean indicating whether the given global property
|
|
68
|
+
* is defined and is configurable.
|
|
69
|
+
*/
|
|
70
|
+
function hasConfigurableGlobal(propertyName) {
|
|
71
|
+
const match = getDeepPropertyDescriptor(globalThis, propertyName);
|
|
72
|
+
if (typeof match === "undefined") return false;
|
|
73
|
+
const { descriptor } = match;
|
|
74
|
+
if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") return false;
|
|
75
|
+
if (typeof descriptor.get === "undefined" && descriptor.value == null) return false;
|
|
76
|
+
if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
|
|
77
|
+
console.error(`[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { globalsRegistry as n, hasConfigurableGlobal as t };
|
|
85
|
+
//# sourceMappingURL=hasConfigurableGlobal-jN_-v3gp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasConfigurableGlobal-jN_-v3gp.mjs","names":["#globals","errors: Array<Error>","currentOwner: Owner | null","descriptor: PropertyDescriptor | undefined"],"sources":["../../src/utils/globalsRegistry.ts","../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["import { invariant } from 'outvariant'\n\nclass GlobalsRegistry {\n #globals = new Map<keyof typeof globalThis, () => void>()\n\n public replaceGlobal<K extends keyof typeof globalThis>(\n key: K,\n nextValue: (typeof globalThis)[K]\n ): () => void {\n invariant(\n !this.#globals.has(key),\n `Failed to replace a global value at \"${key}\": already replaced.`\n )\n\n const match = getDeepPropertyDescriptor(globalThis, key)\n\n if (typeof match === 'undefined') {\n console.warn(\n `Failed to replace a global value at \"${key}\": not a global value.`\n )\n return () => {}\n }\n\n Object.defineProperty(globalThis, key, {\n value: nextValue,\n enumerable: true,\n configurable: true,\n })\n\n const restoreGlobal = () => {\n if (!this.#globals.has(key)) {\n return\n }\n\n if (match.owner === globalThis) {\n Object.defineProperty(match.owner, key, match.descriptor)\n } else {\n /**\n * @todo Delete the proxy property set by the registry.\n * If the owner isn't `globalThis`, the property is likely nested in the prototype.\n * The registry does not meddle with those, they are left intact.\n */\n Reflect.deleteProperty(globalThis, key)\n }\n\n this.#globals.delete(key)\n }\n\n this.#globals.set(key, restoreGlobal)\n\n return restoreGlobal\n }\n\n public restoreAllGlobals(): void {\n const errors: Array<Error> = []\n\n for (const [, restoreGlobal] of this.#globals) {\n try {\n restoreGlobal()\n } catch (error) {\n if (error instanceof Error) {\n errors.push(error)\n } else {\n throw error\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'FOO!')\n }\n }\n}\n\nexport const globalsRegistry = new GlobalsRegistry()\n\ninterface DeepDescriptorMatch {\n owner: object\n descriptor: PropertyDescriptor\n}\n\n/**\n * Returns a property descriptor for the given property on the owner.\n * Walks down the prototype chain if the property does not exist on the owner.\n * Handy for getting a global property descriptor where `globalThis` is\n * replaced with a controlled class (e.g. ServiceWorkerGlobalScope).\n */\nexport function getDeepPropertyDescriptor<Owner extends object>(\n owner: Owner,\n key: keyof Owner\n): DeepDescriptorMatch | undefined {\n let currentOwner: Owner | null = owner\n let descriptor: PropertyDescriptor | undefined\n\n while (currentOwner) {\n descriptor = Object.getOwnPropertyDescriptor(currentOwner, key)\n\n if (descriptor) {\n return {\n owner: currentOwner,\n descriptor,\n }\n }\n\n currentOwner = Object.getPrototypeOf(currentOwner)\n }\n}\n","import { getDeepPropertyDescriptor } from './globalsRegistry'\n\n/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(\n propertyName: keyof typeof globalThis\n): boolean {\n const match = getDeepPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof match === 'undefined') {\n return false\n }\n\n const { descriptor } = match\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";;;AAEA,IAAM,kBAAN,MAAsB;CACpB,2BAAW,IAAI,KAA0C;CAEzD,AAAO,cACL,KACA,WACY;AACZ,YACE,CAAC,MAAKA,QAAS,IAAI,IAAI,EACvB,wCAAwC,IAAI,sBAC7C;EAED,MAAM,QAAQ,0BAA0B,YAAY,IAAI;AAExD,MAAI,OAAO,UAAU,aAAa;AAChC,WAAQ,KACN,wCAAwC,IAAI,wBAC7C;AACD,gBAAa;;AAGf,SAAO,eAAe,YAAY,KAAK;GACrC,OAAO;GACP,YAAY;GACZ,cAAc;GACf,CAAC;EAEF,MAAM,sBAAsB;AAC1B,OAAI,CAAC,MAAKA,QAAS,IAAI,IAAI,CACzB;AAGF,OAAI,MAAM,UAAU,WAClB,QAAO,eAAe,MAAM,OAAO,KAAK,MAAM,WAAW;;;;;;;AAOzD,WAAQ,eAAe,YAAY,IAAI;AAGzC,SAAKA,QAAS,OAAO,IAAI;;AAG3B,QAAKA,QAAS,IAAI,KAAK,cAAc;AAErC,SAAO;;CAGT,AAAO,oBAA0B;EAC/B,MAAMC,SAAuB,EAAE;AAE/B,OAAK,MAAM,GAAG,kBAAkB,MAAKD,QACnC,KAAI;AACF,kBAAe;WACR,OAAO;AACd,OAAI,iBAAiB,MACnB,QAAO,KAAK,MAAM;OAElB,OAAM;;AAKZ,MAAI,OAAO,SAAS,EAClB,OAAM,IAAI,eAAe,QAAQ,OAAO;;;AAK9C,MAAa,kBAAkB,IAAI,iBAAiB;;;;;;;AAapD,SAAgB,0BACd,OACA,KACiC;CACjC,IAAIE,eAA6B;CACjC,IAAIC;AAEJ,QAAO,cAAc;AACnB,eAAa,OAAO,yBAAyB,cAAc,IAAI;AAE/D,MAAI,WACF,QAAO;GACL,OAAO;GACP;GACD;AAGH,iBAAe,OAAO,eAAe,aAAa;;;;;;;;;;AClGtD,SAAgB,sBACd,cACS;CACT,MAAM,QAAQ,0BAA0B,YAAY,aAAa;AAGjE,KAAI,OAAO,UAAU,YACnB,QAAO;CAGT,MAAM,EAAE,eAAe;AAGvB,KACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,KAAK,KAAK,YAE5B,QAAO;AAIT,KAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,KAC/D,QAAO;AAGT,KAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,UAAQ,MACN,mDAAmD,aAAa,oKACjE;AACD,SAAO;;AAGT,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-
|
|
1
|
+
import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-BsZ21ue0.cjs";
|
|
2
2
|
import net from "node:net";
|
|
3
3
|
|
|
4
4
|
//#region src/interceptors/Socket/utils/normalizeSocketWriteArgs.d.ts
|
|
@@ -110,4 +110,4 @@ declare class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap>
|
|
|
110
110
|
}
|
|
111
111
|
//#endregion
|
|
112
112
|
export { ClientRequestInterceptor as t };
|
|
113
|
-
//# sourceMappingURL=index-
|
|
113
|
+
//# sourceMappingURL=index-BJ5E5aW-.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-
|
|
1
|
+
import { l as HttpRequestEventMap, r as Interceptor } from "./Interceptor-soD-WpQO.mjs";
|
|
2
2
|
import net from "node:net";
|
|
3
3
|
|
|
4
4
|
//#region src/interceptors/Socket/utils/normalizeSocketWriteArgs.d.ts
|
|
@@ -110,4 +110,4 @@ declare class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap>
|
|
|
110
110
|
}
|
|
111
111
|
//#endregion
|
|
112
112
|
export { ClientRequestInterceptor as t };
|
|
113
|
-
//# sourceMappingURL=index-
|
|
113
|
+
//# sourceMappingURL=index-DfoF45ih.d.mts.map
|
package/lib/node/index.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const require_getRawRequest = require('./getRawRequest-BavnMWh_.cjs');
|
|
1
|
+
const require_fetchUtils = require('./fetchUtils-Dw6kQghF.cjs');
|
|
2
|
+
const require_BatchInterceptor = require('./BatchInterceptor-AZr7q8p_.cjs');
|
|
3
|
+
const require_bufferUtils = require('./bufferUtils-S5_-2eN4.cjs');
|
|
4
|
+
const require_getRawRequest = require('./getRawRequest-B6znU6il.cjs');
|
|
6
5
|
|
|
7
6
|
//#region src/utils/getCleanUrl.ts
|
|
8
7
|
/**
|
|
@@ -37,9 +36,9 @@ function resolveWebSocketUrl(url) {
|
|
|
37
36
|
|
|
38
37
|
//#endregion
|
|
39
38
|
exports.BatchInterceptor = require_BatchInterceptor.BatchInterceptor;
|
|
39
|
+
exports.FetchRequest = require_fetchUtils.FetchRequest;
|
|
40
40
|
exports.FetchResponse = require_fetchUtils.FetchResponse;
|
|
41
41
|
exports.INTERNAL_REQUEST_ID_HEADER_NAME = require_fetchUtils.INTERNAL_REQUEST_ID_HEADER_NAME;
|
|
42
|
-
exports.IS_PATCHED_MODULE = require_glossary.IS_PATCHED_MODULE;
|
|
43
42
|
exports.Interceptor = require_fetchUtils.Interceptor;
|
|
44
43
|
exports.InterceptorReadyState = require_fetchUtils.InterceptorReadyState;
|
|
45
44
|
exports.RequestController = require_fetchUtils.RequestController;
|
package/lib/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
|
package/lib/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as InterceptorReadyState, c as getGlobalSymbol, d as
|
|
2
|
-
import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-
|
|
1
|
+
import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestController, f as RequestControllerSource, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as RequestCredentials } from "./Interceptor-BsZ21ue0.cjs";
|
|
2
|
+
import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-KKF8Q47I.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createRequestId.d.ts
|
|
5
5
|
|
|
@@ -22,6 +22,25 @@ declare function encodeBuffer(text: string): Uint8Array;
|
|
|
22
22
|
declare function decodeBuffer(buffer: ArrayBuffer, encoding?: string): string;
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/utils/fetchUtils.d.ts
|
|
25
|
+
interface FetchRequestInit extends Omit<RequestInit, 'mode'> {
|
|
26
|
+
mode?: RequestMode | 'websocket' | 'webtransport';
|
|
27
|
+
duplex?: 'half' | 'full';
|
|
28
|
+
}
|
|
29
|
+
declare class FetchRequest extends Request {
|
|
30
|
+
#private;
|
|
31
|
+
/**
|
|
32
|
+
* Check if the given request method is configurable.
|
|
33
|
+
* @see https://fetch.spec.whatwg.org/#methods
|
|
34
|
+
*/
|
|
35
|
+
static isConfigurableMethod(method: string): boolean;
|
|
36
|
+
static isMethodWithBody(method: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the given request `mode` is configurable.
|
|
39
|
+
* @see https://fetch.spec.whatwg.org/#concept-request-mode
|
|
40
|
+
*/
|
|
41
|
+
static isConfigurableMode(mode: string): boolean;
|
|
42
|
+
constructor(input: URL | RequestInfo, init?: FetchRequestInit);
|
|
43
|
+
}
|
|
25
44
|
interface FetchResponseInit extends ResponseInit {
|
|
26
45
|
url?: string;
|
|
27
46
|
}
|
|
@@ -71,5 +90,5 @@ declare function getRawRequest(request: Request): unknown | undefined;
|
|
|
71
90
|
*/
|
|
72
91
|
declare function resolveWebSocketUrl(url: string | URL): string;
|
|
73
92
|
//#endregion
|
|
74
|
-
export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
93
|
+
export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchRequest, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
|
|
75
94
|
//# sourceMappingURL=index.d.cts.map
|
package/lib/node/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as InterceptorReadyState, c as getGlobalSymbol, d as
|
|
2
|
-
import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-
|
|
1
|
+
import { a as InterceptorReadyState, c as getGlobalSymbol, d as RequestController, f as RequestControllerSource, i as InterceptorEventMap, l as HttpRequestEventMap, n as INTERNAL_REQUEST_ID_HEADER_NAME, o as InterceptorSubscription, r as Interceptor, s as deleteGlobalSymbol, t as ExtractEventNames, u as RequestCredentials } from "./Interceptor-soD-WpQO.mjs";
|
|
2
|
+
import { n as BatchInterceptorOptions, r as ExtractEventMapType, t as BatchInterceptor } from "./BatchInterceptor-rSr-NH_H.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createRequestId.d.ts
|
|
5
5
|
|
|
@@ -22,6 +22,25 @@ declare function encodeBuffer(text: string): Uint8Array;
|
|
|
22
22
|
declare function decodeBuffer(buffer: ArrayBuffer, encoding?: string): string;
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/utils/fetchUtils.d.ts
|
|
25
|
+
interface FetchRequestInit extends Omit<RequestInit, 'mode'> {
|
|
26
|
+
mode?: RequestMode | 'websocket' | 'webtransport';
|
|
27
|
+
duplex?: 'half' | 'full';
|
|
28
|
+
}
|
|
29
|
+
declare class FetchRequest extends Request {
|
|
30
|
+
#private;
|
|
31
|
+
/**
|
|
32
|
+
* Check if the given request method is configurable.
|
|
33
|
+
* @see https://fetch.spec.whatwg.org/#methods
|
|
34
|
+
*/
|
|
35
|
+
static isConfigurableMethod(method: string): boolean;
|
|
36
|
+
static isMethodWithBody(method: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the given request `mode` is configurable.
|
|
39
|
+
* @see https://fetch.spec.whatwg.org/#concept-request-mode
|
|
40
|
+
*/
|
|
41
|
+
static isConfigurableMode(mode: string): boolean;
|
|
42
|
+
constructor(input: URL | RequestInfo, init?: FetchRequestInit);
|
|
43
|
+
}
|
|
25
44
|
interface FetchResponseInit extends ResponseInit {
|
|
26
45
|
url?: string;
|
|
27
46
|
}
|
|
@@ -71,5 +90,5 @@ declare function getRawRequest(request: Request): unknown | undefined;
|
|
|
71
90
|
*/
|
|
72
91
|
declare function resolveWebSocketUrl(url: string | URL): string;
|
|
73
92
|
//#endregion
|
|
74
|
-
export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
93
|
+
export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchRequest, FetchResponse, HttpRequestEventMap, INTERNAL_REQUEST_ID_HEADER_NAME, Interceptor, InterceptorEventMap, InterceptorReadyState, InterceptorSubscription, RequestController, type RequestControllerSource, RequestCredentials, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
|
|
75
94
|
//# sourceMappingURL=index.d.mts.map
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as getRawRequest } from "./getRawRequest-DnwmXyOW.mjs";
|
|
1
|
+
import { a as RequestController, c as Interceptor, d as getGlobalSymbol, i as createRequestId, l as InterceptorReadyState, n as FetchResponse, s as INTERNAL_REQUEST_ID_HEADER_NAME, t as FetchRequest, u as deleteGlobalSymbol } from "./fetchUtils-BJxD7wvl.mjs";
|
|
2
|
+
import { t as BatchInterceptor } from "./BatchInterceptor-B2YAn5m9.mjs";
|
|
3
|
+
import { n as encodeBuffer, t as decodeBuffer } from "./bufferUtils-DxPxwff_.mjs";
|
|
4
|
+
import { t as getRawRequest } from "./getRawRequest-C2-1urzA.mjs";
|
|
6
5
|
|
|
7
6
|
//#region src/utils/getCleanUrl.ts
|
|
8
7
|
/**
|
|
@@ -36,5 +35,5 @@ function resolveWebSocketUrl(url) {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
//#endregion
|
|
39
|
-
export { BatchInterceptor, FetchResponse, INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
38
|
+
export { BatchInterceptor, FetchRequest, FetchResponse, INTERNAL_REQUEST_ID_HEADER_NAME, Interceptor, InterceptorReadyState, RequestController, createRequestId, decodeBuffer, deleteGlobalSymbol, encodeBuffer, getCleanUrl, getGlobalSymbol, getRawRequest, resolveWebSocketUrl };
|
|
40
39
|
//# sourceMappingURL=index.mjs.map
|
package/lib/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/getCleanUrl.ts","../../src/utils/resolveWebSocketUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n","/**\n * Resolve potentially relative WebSocket URLs the same way\n * the browser does (replace the protocol, use the origin, etc).\n *\n * @see https://websockets.spec.whatwg.org//#dom-websocket-websocket\n */\nexport function resolveWebSocketUrl(url: string | URL): string {\n if (typeof url === 'string') {\n /**\n * @note Cast the string to a URL first so the parsing errors\n * are thrown as a part of the WebSocket constructor, not consumers.\n */\n const urlRecord = new URL(\n url,\n typeof location !== 'undefined' ? location.href : undefined\n )\n\n return resolveWebSocketUrl(urlRecord)\n }\n\n if (url.protocol === 'http:') {\n url.protocol = 'ws:'\n } else if (url.protocol === 'https:') {\n url.protocol = 'wss:'\n }\n\n if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {\n /**\n * @note These errors are modeled after the browser errors.\n * The exact error messages aren't provided in the specification.\n * Node.js uses more obscure error messages that I don't wish to replicate.\n */\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. '${url.protocol}' is not allowed.`\n )\n }\n\n if (url.hash !== '') {\n throw new SyntaxError(\n `Failed to construct 'WebSocket': The URL contains a fragment identifier ('${url.hash}'). Fragment identifiers are not allowed in WebSocket URLs.`\n )\n }\n\n return url.href\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,YAAY,KAAU,aAAsB,MAAc;AACxE,QAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG;;;;;;;;;;;ACE1E,SAAgB,oBAAoB,KAA2B;AAC7D,KAAI,OAAO,QAAQ,SAUjB,QAAO,oBALW,IAAI,IACpB,KACA,OAAO,aAAa,cAAc,SAAS,OAAO,OACnD,CAEoC;AAGvC,KAAI,IAAI,aAAa,QACnB,KAAI,WAAW;UACN,IAAI,aAAa,SAC1B,KAAI,WAAW;AAGjB,KAAI,IAAI,aAAa,SAAS,IAAI,aAAa;;;;;;AAM7C,OAAM,IAAI,YACR,sGAAsG,IAAI,SAAS,mBACpH;AAGH,KAAI,IAAI,SAAS,GACf,OAAM,IAAI,YACR,6EAA6E,IAAI,KAAK,6DACvF;AAGH,QAAO,IAAI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require('../../fetchUtils-
|
|
2
|
-
const require_ClientRequest = require('../../ClientRequest-
|
|
3
|
-
require('../../handleRequest-
|
|
4
|
-
require('../../node-
|
|
1
|
+
require('../../fetchUtils-Dw6kQghF.cjs');
|
|
2
|
+
const require_ClientRequest = require('../../ClientRequest-BgwQG-9G.cjs');
|
|
3
|
+
require('../../handleRequest-Dzg1d3e5.cjs');
|
|
4
|
+
require('../../node-DIKcnzhK.cjs');
|
|
5
5
|
|
|
6
6
|
exports.ClientRequestInterceptor = require_ClientRequest.ClientRequestInterceptor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ClientRequestInterceptor } from "../../index-
|
|
1
|
+
import { t as ClientRequestInterceptor } from "../../index-BJ5E5aW-.cjs";
|
|
2
2
|
export { ClientRequestInterceptor };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../../Interceptor-
|
|
2
|
-
import { t as ClientRequestInterceptor } from "../../index-
|
|
1
|
+
import "../../Interceptor-soD-WpQO.mjs";
|
|
2
|
+
import { t as ClientRequestInterceptor } from "../../index-DfoF45ih.mjs";
|
|
3
3
|
export { ClientRequestInterceptor };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../fetchUtils-
|
|
2
|
-
import { t as ClientRequestInterceptor } from "../../ClientRequest-
|
|
3
|
-
import "../../handleRequest-
|
|
4
|
-
import "../../node-
|
|
1
|
+
import "../../fetchUtils-BJxD7wvl.mjs";
|
|
2
|
+
import { t as ClientRequestInterceptor } from "../../ClientRequest-5WjHvs9Y.mjs";
|
|
3
|
+
import "../../handleRequest-DGfUg9bm.mjs";
|
|
4
|
+
import "../../node-lsdNwZEW.mjs";
|
|
5
5
|
|
|
6
6
|
export { ClientRequestInterceptor };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
require('../../fetchUtils-
|
|
2
|
-
require('../../bufferUtils-
|
|
3
|
-
require('../../handleRequest-
|
|
4
|
-
const require_XMLHttpRequest = require('../../XMLHttpRequest-
|
|
1
|
+
require('../../fetchUtils-Dw6kQghF.cjs');
|
|
2
|
+
require('../../bufferUtils-S5_-2eN4.cjs');
|
|
3
|
+
require('../../handleRequest-Dzg1d3e5.cjs');
|
|
4
|
+
const require_XMLHttpRequest = require('../../XMLHttpRequest-B7sloBex.cjs');
|
|
5
|
+
require('../../hasConfigurableGlobal-Befl_QJD.cjs');
|
|
5
6
|
|
|
6
7
|
exports.XMLHttpRequestInterceptor = require_XMLHttpRequest.XMLHttpRequestInterceptor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-
|
|
1
|
+
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-BsZ21ue0.cjs";
|
|
2
2
|
import { Emitter } from "strict-event-emitter";
|
|
3
3
|
|
|
4
4
|
//#region src/interceptors/XMLHttpRequest/index.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-
|
|
1
|
+
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-soD-WpQO.mjs";
|
|
2
2
|
import { Emitter } from "strict-event-emitter";
|
|
3
3
|
|
|
4
4
|
//#region src/interceptors/XMLHttpRequest/index.d.ts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "../../fetchUtils-
|
|
2
|
-
import "../../bufferUtils-
|
|
3
|
-
import "../../handleRequest-
|
|
4
|
-
import { t as XMLHttpRequestInterceptor } from "../../XMLHttpRequest-
|
|
1
|
+
import "../../fetchUtils-BJxD7wvl.mjs";
|
|
2
|
+
import "../../bufferUtils-DxPxwff_.mjs";
|
|
3
|
+
import "../../handleRequest-DGfUg9bm.mjs";
|
|
4
|
+
import { t as XMLHttpRequestInterceptor } from "../../XMLHttpRequest-DmsdUGmj.mjs";
|
|
5
|
+
import "../../hasConfigurableGlobal-jN_-v3gp.mjs";
|
|
5
6
|
|
|
6
7
|
export { XMLHttpRequestInterceptor };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
require('../../fetchUtils-
|
|
2
|
-
require('../../handleRequest-
|
|
3
|
-
|
|
1
|
+
require('../../fetchUtils-Dw6kQghF.cjs');
|
|
2
|
+
require('../../handleRequest-Dzg1d3e5.cjs');
|
|
3
|
+
require('../../hasConfigurableGlobal-Befl_QJD.cjs');
|
|
4
|
+
const require_fetch = require('../../fetch-uc7pNtPg.cjs');
|
|
4
5
|
|
|
5
6
|
exports.FetchInterceptor = require_fetch.FetchInterceptor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-
|
|
1
|
+
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-BsZ21ue0.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/interceptors/fetch/index.d.ts
|
|
4
4
|
declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-
|
|
1
|
+
import { l as HttpRequestEventMap, r as Interceptor } from "../../Interceptor-soD-WpQO.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/interceptors/fetch/index.d.ts
|
|
4
4
|
declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import "../../fetchUtils-
|
|
2
|
-
import "../../handleRequest-
|
|
3
|
-
import
|
|
1
|
+
import "../../fetchUtils-BJxD7wvl.mjs";
|
|
2
|
+
import "../../handleRequest-DGfUg9bm.mjs";
|
|
3
|
+
import "../../hasConfigurableGlobal-jN_-v3gp.mjs";
|
|
4
|
+
import { t as FetchInterceptor } from "../../fetch-DDAGTtZi.mjs";
|
|
4
5
|
|
|
5
6
|
export { FetchInterceptor };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
const require_getRawRequest = require('./getRawRequest-
|
|
2
|
+
const require_getRawRequest = require('./getRawRequest-B6znU6il.cjs');
|
|
3
3
|
let outvariant = require("outvariant");
|
|
4
4
|
let node_http = require("node:http");
|
|
5
5
|
let node_stream = require("node:stream");
|
|
@@ -36,4 +36,4 @@ Object.defineProperty(exports, 'setRawRequestBodyStream', {
|
|
|
36
36
|
return setRawRequestBodyStream;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
//# sourceMappingURL=node-
|
|
39
|
+
//# sourceMappingURL=node-DIKcnzhK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-
|
|
1
|
+
{"version":3,"file":"node-DIKcnzhK.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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as getRawRequest } from "./getRawRequest-
|
|
1
|
+
import { t as getRawRequest } from "./getRawRequest-C2-1urzA.mjs";
|
|
2
2
|
import { invariant } from "outvariant";
|
|
3
3
|
import { ClientRequest } from "node:http";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
@@ -24,4 +24,4 @@ function setRawRequestBodyStream(request, stream) {
|
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
export { setRawRequestBodyStream as n, getClientRequestBodyStream as t };
|
|
27
|
-
//# sourceMappingURL=node-
|
|
27
|
+
//# sourceMappingURL=node-lsdNwZEW.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-
|
|
1
|
+
{"version":3,"file":"node-lsdNwZEW.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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
require('../fetchUtils-
|
|
2
|
-
require('../bufferUtils-
|
|
3
|
-
const require_ClientRequest = require('../ClientRequest-
|
|
4
|
-
require('../handleRequest-
|
|
5
|
-
require('../node-
|
|
6
|
-
const require_XMLHttpRequest = require('../XMLHttpRequest-
|
|
7
|
-
|
|
1
|
+
require('../fetchUtils-Dw6kQghF.cjs');
|
|
2
|
+
require('../bufferUtils-S5_-2eN4.cjs');
|
|
3
|
+
const require_ClientRequest = require('../ClientRequest-BgwQG-9G.cjs');
|
|
4
|
+
require('../handleRequest-Dzg1d3e5.cjs');
|
|
5
|
+
require('../node-DIKcnzhK.cjs');
|
|
6
|
+
const require_XMLHttpRequest = require('../XMLHttpRequest-B7sloBex.cjs');
|
|
7
|
+
require('../hasConfigurableGlobal-Befl_QJD.cjs');
|
|
8
|
+
const require_fetch = require('../fetch-uc7pNtPg.cjs');
|
|
8
9
|
|
|
9
10
|
//#region src/presets/node.ts
|
|
10
11
|
/**
|
|
@@ -1 +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":"
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientRequestInterceptor } from "../index-
|
|
1
|
+
import { t as ClientRequestInterceptor } from "../index-BJ5E5aW-.cjs";
|
|
2
2
|
import { XMLHttpRequestInterceptor } from "../interceptors/XMLHttpRequest/index.cjs";
|
|
3
3
|
import { FetchInterceptor } from "../interceptors/fetch/index.cjs";
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Interceptor-
|
|
2
|
-
import { t as ClientRequestInterceptor } from "../index-
|
|
1
|
+
import "../Interceptor-soD-WpQO.mjs";
|
|
2
|
+
import { t as ClientRequestInterceptor } from "../index-DfoF45ih.mjs";
|
|
3
3
|
import { XMLHttpRequestInterceptor } from "../interceptors/XMLHttpRequest/index.mjs";
|
|
4
4
|
import { FetchInterceptor } from "../interceptors/fetch/index.mjs";
|
|
5
5
|
|