@mswjs/interceptors 0.21.1 → 0.22.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.
- package/lib/browser/interceptors/XMLHttpRequest/index.js +0 -4
- package/lib/browser/interceptors/XMLHttpRequest/index.mjs +0 -4
- package/lib/node/RemoteHttpInterceptor.js +11 -15
- package/lib/node/RemoteHttpInterceptor.mjs +5 -9
- package/lib/node/{chunk-ZSI7MX3V.mjs → chunk-37CATPNG.mjs} +0 -34
- package/lib/node/{chunk-ZWCZGO3W.mjs → chunk-CYWTKHFI.mjs} +2 -7
- package/lib/node/{chunk-CIN5URNI.mjs → chunk-G6ZTHYZQ.mjs} +1 -1
- package/lib/node/{chunk-HDUJCCWF.js → chunk-GGD5JOGB.js} +9 -14
- package/lib/node/{chunk-JISWS3Y3.mjs → chunk-KZEQH4YW.mjs} +1 -1
- package/lib/node/{chunk-UVNTVJHD.js → chunk-PRX3F52M.js} +17 -17
- package/lib/node/{chunk-KZJG2UW7.js → chunk-Q56TMOP5.js} +2 -2
- package/lib/node/{chunk-6GWWOJ23.js → chunk-SNNL2EXF.js} +3 -3
- package/lib/node/{chunk-Z5JAVEOB.mjs → chunk-SWJ33XIS.mjs} +10 -10
- package/lib/node/{chunk-QMIXLBOU.js → chunk-WWHITCCI.js} +2 -36
- package/lib/node/index.js +4 -4
- package/lib/node/index.mjs +3 -3
- package/lib/node/interceptors/ClientRequest/index.js +3 -4
- package/lib/node/interceptors/ClientRequest/index.mjs +2 -3
- package/lib/node/interceptors/XMLHttpRequest/index.js +4 -5
- package/lib/node/interceptors/XMLHttpRequest/index.mjs +3 -4
- package/lib/node/interceptors/fetch/index.js +2 -2
- package/lib/node/interceptors/fetch/index.mjs +1 -1
- package/package.json +11 -9
- package/src/BatchInterceptor.test.ts +8 -7
- package/src/Interceptor.test.ts +6 -5
- package/src/RemoteHttpInterceptor.ts +0 -1
- package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +107 -85
- package/src/interceptors/ClientRequest/NodeClientRequest.ts +14 -6
- package/src/interceptors/ClientRequest/index.test.ts +20 -8
- package/src/interceptors/ClientRequest/utils/cloneIncomingMessage.test.ts +2 -1
- package/src/interceptors/ClientRequest/utils/createRequest.test.ts +1 -0
- package/src/interceptors/ClientRequest/utils/createRequest.ts +0 -1
- package/src/interceptors/ClientRequest/utils/createResponse.test.ts +1 -3
- package/src/interceptors/ClientRequest/utils/createResponse.ts +0 -1
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.test.ts +5 -4
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.test.ts +19 -18
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.test.ts +6 -5
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.test.ts +5 -4
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +0 -1
- package/src/interceptors/XMLHttpRequest/utils/concateArrayBuffer.test.ts +1 -3
- package/src/interceptors/XMLHttpRequest/utils/createEvent.test.ts +4 -5
- package/src/interceptors/XMLHttpRequest/utils/createResponse.ts +0 -1
- package/src/interceptors/fetch/index.ts +1 -2
- package/src/utils/AsyncEventEmitter.test.ts +8 -7
- package/src/utils/bufferUtils.test.ts +1 -0
- package/src/utils/cloneObject.test.ts +6 -5
- package/src/utils/getCleanUrl.test.ts +5 -4
- package/src/utils/getUrlByRequestOptions.test.ts +11 -10
- package/src/utils/getUrlByRequestOptions.ts +14 -1
- package/src/utils/isObject.test.ts +4 -3
- package/src/utils/parseJson.test.ts +3 -2
- package/lib/node/chunk-6V3JXLBF.js +0 -6093
- package/lib/node/chunk-NNVTJLQA.mjs +0 -6093
|
@@ -18,10 +18,6 @@ var _outvariant = require('outvariant');
|
|
|
18
18
|
// src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts
|
|
19
19
|
var _until = require('@open-draft/until');
|
|
20
20
|
|
|
21
|
-
// node_modules/@remix-run/web-fetch/src/lib.js
|
|
22
|
-
var { Headers, Request, Response } = globalThis;
|
|
23
|
-
var lib_default = globalThis.fetch;
|
|
24
|
-
|
|
25
21
|
// src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts
|
|
26
22
|
var _headerspolyfill = require('headers-polyfill');
|
|
27
23
|
|
|
@@ -18,10 +18,6 @@ import { invariant as invariant2 } from "outvariant";
|
|
|
18
18
|
// src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts
|
|
19
19
|
import { until } from "@open-draft/until";
|
|
20
20
|
|
|
21
|
-
// node_modules/@remix-run/web-fetch/src/lib.js
|
|
22
|
-
var { Headers, Request, Response } = globalThis;
|
|
23
|
-
var lib_default = globalThis.fetch;
|
|
24
|
-
|
|
25
21
|
// src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts
|
|
26
22
|
import { headersToString } from "headers-polyfill";
|
|
27
23
|
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQ56TMOP5js = require('./chunk-Q56TMOP5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkPRX3F52Mjs = require('./chunk-PRX3F52M.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _chunk6V3JXLBFjs = require('./chunk-6V3JXLBF.js');
|
|
9
|
+
var _chunkGGD5JOGBjs = require('./chunk-GGD5JOGB.js');
|
|
10
|
+
require('./chunk-SNNL2EXF.js');
|
|
15
11
|
require('./chunk-VQ4DZOBB.js');
|
|
16
12
|
|
|
17
13
|
|
|
18
14
|
var _chunkZJOF5MEZjs = require('./chunk-ZJOF5MEZ.js');
|
|
19
15
|
|
|
20
16
|
|
|
21
|
-
var
|
|
17
|
+
var _chunkWWHITCCIjs = require('./chunk-WWHITCCI.js');
|
|
22
18
|
|
|
23
19
|
// src/RemoteHttpInterceptor.ts
|
|
24
20
|
var _headerspolyfill = require('headers-polyfill');
|
|
25
|
-
var RemoteHttpInterceptor = class extends
|
|
21
|
+
var RemoteHttpInterceptor = class extends _chunkQ56TMOP5js.BatchInterceptor {
|
|
26
22
|
constructor() {
|
|
27
23
|
super({
|
|
28
24
|
name: "remote-interceptor",
|
|
29
25
|
interceptors: [
|
|
30
|
-
new (0,
|
|
31
|
-
new (0,
|
|
26
|
+
new (0, _chunkPRX3F52Mjs.ClientRequestInterceptor)(),
|
|
27
|
+
new (0, _chunkGGD5JOGBjs.XMLHttpRequestInterceptor)()
|
|
32
28
|
]
|
|
33
29
|
});
|
|
34
30
|
}
|
|
@@ -60,7 +56,7 @@ var RemoteHttpInterceptor = class extends _chunkKZJG2UW7js.BatchInterceptor {
|
|
|
60
56
|
const responseInit = JSON.parse(
|
|
61
57
|
serializedResponse
|
|
62
58
|
);
|
|
63
|
-
const mockedResponse = new
|
|
59
|
+
const mockedResponse = new Response(responseInit.body, {
|
|
64
60
|
status: responseInit.status,
|
|
65
61
|
statusText: responseInit.statusText,
|
|
66
62
|
headers: new (0, _headerspolyfill.Headers)(responseInit.headers)
|
|
@@ -92,7 +88,7 @@ function requestReviver(key, value) {
|
|
|
92
88
|
return value;
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
|
-
var _RemoteHttpResolver = class extends
|
|
91
|
+
var _RemoteHttpResolver = class extends _chunkWWHITCCIjs.Interceptor {
|
|
96
92
|
constructor(options) {
|
|
97
93
|
super(_RemoteHttpResolver.symbol);
|
|
98
94
|
this.process = options.process;
|
|
@@ -114,7 +110,7 @@ var _RemoteHttpResolver = class extends _chunkQMIXLBOUjs.Interceptor {
|
|
|
114
110
|
requestReviver
|
|
115
111
|
);
|
|
116
112
|
log("parsed intercepted request", requestJson);
|
|
117
|
-
const capturedRequest = new
|
|
113
|
+
const capturedRequest = new Request(requestJson.url, {
|
|
118
114
|
method: requestJson.method,
|
|
119
115
|
headers: new (0, _headerspolyfill.Headers)(requestJson.headers),
|
|
120
116
|
credentials: requestJson.credentials,
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KZEQH4YW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ClientRequestInterceptor
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SWJ33XIS.mjs";
|
|
7
7
|
import {
|
|
8
8
|
XMLHttpRequestInterceptor
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
Request,
|
|
13
|
-
Response
|
|
14
|
-
} from "./chunk-NNVTJLQA.mjs";
|
|
9
|
+
} from "./chunk-CYWTKHFI.mjs";
|
|
10
|
+
import "./chunk-G6ZTHYZQ.mjs";
|
|
15
11
|
import "./chunk-GFH37L5D.mjs";
|
|
16
12
|
import {
|
|
17
13
|
toInteractiveRequest
|
|
18
14
|
} from "./chunk-STA6QBYM.mjs";
|
|
19
15
|
import {
|
|
20
16
|
Interceptor
|
|
21
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-37CATPNG.mjs";
|
|
22
18
|
|
|
23
19
|
// src/RemoteHttpInterceptor.ts
|
|
24
20
|
import { Headers, headersToObject } from "headers-polyfill";
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
1
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
3
|
}) : x)(function(x) {
|
|
@@ -11,29 +5,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
5
|
return require.apply(this, arguments);
|
|
12
6
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
13
7
|
});
|
|
14
|
-
var __esm = (fn, res) => function __init() {
|
|
15
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
-
};
|
|
17
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
-
};
|
|
24
|
-
var __copyProps = (to, from, except, desc) => {
|
|
25
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
-
for (let key of __getOwnPropNames(from))
|
|
27
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
-
}
|
|
30
|
-
return to;
|
|
31
|
-
};
|
|
32
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
8
|
|
|
38
9
|
// src/Interceptor.ts
|
|
39
10
|
import { debug as debug2 } from "debug";
|
|
@@ -279,11 +250,6 @@ var Interceptor = class {
|
|
|
279
250
|
|
|
280
251
|
export {
|
|
281
252
|
__require,
|
|
282
|
-
__esm,
|
|
283
|
-
__commonJS,
|
|
284
|
-
__export,
|
|
285
|
-
__toESM,
|
|
286
|
-
__toCommonJS,
|
|
287
253
|
getGlobalSymbol,
|
|
288
254
|
deleteGlobalSymbol,
|
|
289
255
|
InterceptorReadyState,
|
|
@@ -2,12 +2,7 @@ import {
|
|
|
2
2
|
decodeBuffer,
|
|
3
3
|
encodeBuffer,
|
|
4
4
|
toArrayBuffer
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
Headers,
|
|
8
|
-
Request,
|
|
9
|
-
Response
|
|
10
|
-
} from "./chunk-NNVTJLQA.mjs";
|
|
5
|
+
} from "./chunk-G6ZTHYZQ.mjs";
|
|
11
6
|
import {
|
|
12
7
|
IS_PATCHED_MODULE
|
|
13
8
|
} from "./chunk-GFH37L5D.mjs";
|
|
@@ -17,7 +12,7 @@ import {
|
|
|
17
12
|
} from "./chunk-STA6QBYM.mjs";
|
|
18
13
|
import {
|
|
19
14
|
Interceptor
|
|
20
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-37CATPNG.mjs";
|
|
21
16
|
|
|
22
17
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
23
18
|
import { invariant as invariant2 } from "outvariant";
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunk6V3JXLBFjs = require('./chunk-6V3JXLBF.js');
|
|
5
|
+
var _chunkSNNL2EXFjs = require('./chunk-SNNL2EXF.js');
|
|
11
6
|
|
|
12
7
|
|
|
13
8
|
var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
@@ -17,7 +12,7 @@ var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
|
17
12
|
var _chunkZJOF5MEZjs = require('./chunk-ZJOF5MEZ.js');
|
|
18
13
|
|
|
19
14
|
|
|
20
|
-
var
|
|
15
|
+
var _chunkWWHITCCIjs = require('./chunk-WWHITCCI.js');
|
|
21
16
|
|
|
22
17
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
23
18
|
var _outvariant = require('outvariant');
|
|
@@ -178,7 +173,7 @@ function parseJson(data) {
|
|
|
178
173
|
// src/interceptors/XMLHttpRequest/utils/createResponse.ts
|
|
179
174
|
|
|
180
175
|
function createResponse(request, responseBody) {
|
|
181
|
-
return new
|
|
176
|
+
return new Response(responseBody, {
|
|
182
177
|
status: request.status,
|
|
183
178
|
statusText: request.statusText,
|
|
184
179
|
headers: _headerspolyfill.stringToHeaders.call(void 0, request.getAllResponseHeaders())
|
|
@@ -194,7 +189,7 @@ var XMLHttpRequestController = class {
|
|
|
194
189
|
this.method = "GET";
|
|
195
190
|
this.url = null;
|
|
196
191
|
this.events = /* @__PURE__ */ new Map();
|
|
197
|
-
this.requestHeaders = new
|
|
192
|
+
this.requestHeaders = new Headers();
|
|
198
193
|
this.responseBuffer = new Uint8Array();
|
|
199
194
|
this.request = createProxy(initialRequest, {
|
|
200
195
|
setProperty: ([propertyName, nextValue], invoke) => {
|
|
@@ -236,7 +231,7 @@ var XMLHttpRequestController = class {
|
|
|
236
231
|
case "send": {
|
|
237
232
|
const [body] = args;
|
|
238
233
|
if (body != null) {
|
|
239
|
-
this.requestBody = typeof body === "string" ?
|
|
234
|
+
this.requestBody = typeof body === "string" ? _chunkSNNL2EXFjs.encodeBuffer.call(void 0, body) : body;
|
|
240
235
|
}
|
|
241
236
|
this.request.addEventListener("load", () => {
|
|
242
237
|
if (typeof this.onResponse !== "undefined") {
|
|
@@ -390,7 +385,7 @@ var XMLHttpRequestController = class {
|
|
|
390
385
|
}
|
|
391
386
|
}
|
|
392
387
|
responseBufferToText() {
|
|
393
|
-
return
|
|
388
|
+
return _chunkSNNL2EXFjs.decodeBuffer.call(void 0, this.responseBuffer);
|
|
394
389
|
}
|
|
395
390
|
get response() {
|
|
396
391
|
this.log("getResponse (responseType: %s)", this.request.responseType);
|
|
@@ -404,7 +399,7 @@ var XMLHttpRequestController = class {
|
|
|
404
399
|
return responseJson;
|
|
405
400
|
}
|
|
406
401
|
case "arraybuffer": {
|
|
407
|
-
const arrayBuffer =
|
|
402
|
+
const arrayBuffer = _chunkSNNL2EXFjs.toArrayBuffer.call(void 0, this.responseBuffer);
|
|
408
403
|
this.log("resolved response ArrayBuffer", arrayBuffer);
|
|
409
404
|
return arrayBuffer;
|
|
410
405
|
}
|
|
@@ -506,7 +501,7 @@ var XMLHttpRequestController = class {
|
|
|
506
501
|
}
|
|
507
502
|
toFetchApiRequest() {
|
|
508
503
|
this.log("converting request to a Fetch API Request...");
|
|
509
|
-
const fetchRequest = new
|
|
504
|
+
const fetchRequest = new Request(this.url.href, {
|
|
510
505
|
method: this.method,
|
|
511
506
|
headers: this.requestHeaders,
|
|
512
507
|
credentials: this.request.withCredentials ? "include" : "same-origin",
|
|
@@ -613,7 +608,7 @@ function createXMLHttpRequestProxy({
|
|
|
613
608
|
}
|
|
614
609
|
|
|
615
610
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
616
|
-
var _XMLHttpRequestInterceptor = class extends
|
|
611
|
+
var _XMLHttpRequestInterceptor = class extends _chunkWWHITCCIjs.Interceptor {
|
|
617
612
|
constructor() {
|
|
618
613
|
super(_XMLHttpRequestInterceptor.symbol);
|
|
619
614
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
var _chunk6V3JXLBFjs = require('./chunk-6V3JXLBF.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
4
|
var _chunkZJOF5MEZjs = require('./chunk-ZJOF5MEZ.js');
|
|
10
5
|
|
|
11
6
|
|
|
12
7
|
|
|
13
|
-
var
|
|
8
|
+
var _chunkWWHITCCIjs = require('./chunk-WWHITCCI.js');
|
|
14
9
|
|
|
15
10
|
// src/interceptors/ClientRequest/index.ts
|
|
16
11
|
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
|
|
@@ -21,7 +16,7 @@ var _https = require('https'); var _https2 = _interopRequireDefault(_https);
|
|
|
21
16
|
var _until = require('@open-draft/until');
|
|
22
17
|
|
|
23
18
|
// src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts
|
|
24
|
-
var debug =
|
|
19
|
+
var debug = _chunkWWHITCCIjs.__require.call(void 0, "debug")("http normalizeClientRequestEndArgs");
|
|
25
20
|
function normalizeClientRequestEndArgs(...args) {
|
|
26
21
|
debug("arguments", args);
|
|
27
22
|
const normalizedArgs = new Array(3).fill(null).map((value, index) => args[index] || value);
|
|
@@ -104,13 +99,13 @@ function inheritProperties(source, target) {
|
|
|
104
99
|
// src/interceptors/ClientRequest/utils/createResponse.ts
|
|
105
100
|
var _headerspolyfill = require('headers-polyfill');
|
|
106
101
|
function createResponse(message) {
|
|
107
|
-
const readable = new
|
|
102
|
+
const readable = new ReadableStream({
|
|
108
103
|
start(controller) {
|
|
109
104
|
message.on("data", (chunk) => controller.enqueue(chunk));
|
|
110
105
|
message.on("end", () => controller.close());
|
|
111
106
|
}
|
|
112
107
|
});
|
|
113
|
-
return new
|
|
108
|
+
return new Response(readable, {
|
|
114
109
|
status: message.statusCode,
|
|
115
110
|
statusText: message.statusMessage,
|
|
116
111
|
headers: _headerspolyfill.objectToHeaders.call(void 0, message.headers)
|
|
@@ -132,7 +127,7 @@ function createRequest(clientRequest) {
|
|
|
132
127
|
headers.append(headerName, value.toString());
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
|
-
return new
|
|
130
|
+
return new Request(clientRequest.url, {
|
|
136
131
|
method: clientRequest.method || "GET",
|
|
137
132
|
headers,
|
|
138
133
|
credentials: "same-origin",
|
|
@@ -213,6 +208,11 @@ var _NodeClientRequest = class extends _http.ClientRequest {
|
|
|
213
208
|
return mockedResponse;
|
|
214
209
|
}).then(([resolverException, mockedResponse]) => {
|
|
215
210
|
this.log("the listeners promise awaited!");
|
|
211
|
+
if (!this.headersSent) {
|
|
212
|
+
for (const [headerName, headerValue] of capturedRequest.headers) {
|
|
213
|
+
this.setHeader(headerName, headerValue);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
216
|
if (resolverException) {
|
|
217
217
|
this.log(
|
|
218
218
|
"encountered resolver exception, aborting request...",
|
|
@@ -222,9 +222,6 @@ var _NodeClientRequest = class extends _http.ClientRequest {
|
|
|
222
222
|
this.terminate();
|
|
223
223
|
return this;
|
|
224
224
|
}
|
|
225
|
-
for (const [headerName, headerValue] of capturedRequest.headers) {
|
|
226
|
-
this.setHeader(headerName, headerValue);
|
|
227
|
-
}
|
|
228
225
|
if (mockedResponse) {
|
|
229
226
|
const responseClone = mockedResponse.clone();
|
|
230
227
|
this.log("received mocked response:", mockedResponse);
|
|
@@ -403,7 +400,7 @@ function getRequestOptionsByUrl(url) {
|
|
|
403
400
|
|
|
404
401
|
// src/utils/getUrlByRequestOptions.ts
|
|
405
402
|
|
|
406
|
-
var debug3 =
|
|
403
|
+
var debug3 = _chunkWWHITCCIjs.__require.call(void 0, "debug")("utils getUrlByRequestOptions");
|
|
407
404
|
var DEFAULT_PATH = "/";
|
|
408
405
|
var DEFAULT_PROTOCOL = "http:";
|
|
409
406
|
var DEFAULT_HOST = "localhost";
|
|
@@ -444,6 +441,9 @@ function getAuthByRequestOptions(options) {
|
|
|
444
441
|
return { username, password };
|
|
445
442
|
}
|
|
446
443
|
}
|
|
444
|
+
function isRawIPv6Address(host) {
|
|
445
|
+
return host.includes(":") && !host.startsWith("[") && !host.endsWith("]");
|
|
446
|
+
}
|
|
447
447
|
function getUrlByRequestOptions(options) {
|
|
448
448
|
debug3("request options", options);
|
|
449
449
|
const protocol = getProtocolByRequestOptions(options);
|
|
@@ -455,7 +455,7 @@ function getUrlByRequestOptions(options) {
|
|
|
455
455
|
debug3("host", host);
|
|
456
456
|
debug3("port", port);
|
|
457
457
|
debug3("path", path);
|
|
458
|
-
const baseUrl = `${protocol}//${host}`;
|
|
458
|
+
const baseUrl = `${protocol}//${isRawIPv6Address(host) ? `[${host}]` : host}`;
|
|
459
459
|
debug3("base URL:", baseUrl);
|
|
460
460
|
const url = options.uri ? new URL(options.uri.href) : new URL(path, baseUrl);
|
|
461
461
|
if (port) {
|
|
@@ -472,7 +472,7 @@ function getUrlByRequestOptions(options) {
|
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
// src/utils/cloneObject.ts
|
|
475
|
-
var debug4 =
|
|
475
|
+
var debug4 = _chunkWWHITCCIjs.__require.call(void 0, "debug")("cloneObject");
|
|
476
476
|
function isPlainObject(obj) {
|
|
477
477
|
var _a;
|
|
478
478
|
debug4("is plain object?", obj);
|
|
@@ -633,7 +633,7 @@ function request(protocol, options) {
|
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
// src/interceptors/ClientRequest/index.ts
|
|
636
|
-
var _ClientRequestInterceptor = class extends
|
|
636
|
+
var _ClientRequestInterceptor = class extends _chunkWWHITCCIjs.Interceptor {
|
|
637
637
|
constructor() {
|
|
638
638
|
super(_ClientRequestInterceptor.symbol);
|
|
639
639
|
this.modules = /* @__PURE__ */ new Map();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWWHITCCIjs = require('./chunk-WWHITCCI.js');
|
|
4
4
|
|
|
5
5
|
// src/BatchInterceptor.ts
|
|
6
|
-
var BatchInterceptor = class extends
|
|
6
|
+
var BatchInterceptor = class extends _chunkWWHITCCIjs.Interceptor {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
9
9
|
super(BatchInterceptor.symbol);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWWHITCCIjs = require('./chunk-WWHITCCI.js');
|
|
4
4
|
|
|
5
5
|
// src/shims/webEncoding.ts
|
|
6
|
-
var TextEncoder = typeof globalThis.TextEncoder === "undefined" ?
|
|
7
|
-
var TextDecoder = typeof globalThis.TextDecoder === "undefined" ?
|
|
6
|
+
var TextEncoder = typeof globalThis.TextEncoder === "undefined" ? _chunkWWHITCCIjs.__require.call(void 0, "util").TextEncoder : globalThis.TextEncoder;
|
|
7
|
+
var TextDecoder = typeof globalThis.TextDecoder === "undefined" ? _chunkWWHITCCIjs.__require.call(void 0, "util").TextDecoder : globalThis.TextDecoder;
|
|
8
8
|
|
|
9
9
|
// src/utils/bufferUtils.ts
|
|
10
10
|
var encoder = new TextEncoder();
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ReadableStream,
|
|
3
|
-
Request,
|
|
4
|
-
Response
|
|
5
|
-
} from "./chunk-NNVTJLQA.mjs";
|
|
6
1
|
import {
|
|
7
2
|
toInteractiveRequest,
|
|
8
3
|
uuidv4
|
|
@@ -10,7 +5,7 @@ import {
|
|
|
10
5
|
import {
|
|
11
6
|
Interceptor,
|
|
12
7
|
__require
|
|
13
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-37CATPNG.mjs";
|
|
14
9
|
|
|
15
10
|
// src/interceptors/ClientRequest/index.ts
|
|
16
11
|
import http from "http";
|
|
@@ -213,6 +208,11 @@ var _NodeClientRequest = class extends ClientRequest {
|
|
|
213
208
|
return mockedResponse;
|
|
214
209
|
}).then(([resolverException, mockedResponse]) => {
|
|
215
210
|
this.log("the listeners promise awaited!");
|
|
211
|
+
if (!this.headersSent) {
|
|
212
|
+
for (const [headerName, headerValue] of capturedRequest.headers) {
|
|
213
|
+
this.setHeader(headerName, headerValue);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
216
|
if (resolverException) {
|
|
217
217
|
this.log(
|
|
218
218
|
"encountered resolver exception, aborting request...",
|
|
@@ -222,9 +222,6 @@ var _NodeClientRequest = class extends ClientRequest {
|
|
|
222
222
|
this.terminate();
|
|
223
223
|
return this;
|
|
224
224
|
}
|
|
225
|
-
for (const [headerName, headerValue] of capturedRequest.headers) {
|
|
226
|
-
this.setHeader(headerName, headerValue);
|
|
227
|
-
}
|
|
228
225
|
if (mockedResponse) {
|
|
229
226
|
const responseClone = mockedResponse.clone();
|
|
230
227
|
this.log("received mocked response:", mockedResponse);
|
|
@@ -444,6 +441,9 @@ function getAuthByRequestOptions(options) {
|
|
|
444
441
|
return { username, password };
|
|
445
442
|
}
|
|
446
443
|
}
|
|
444
|
+
function isRawIPv6Address(host) {
|
|
445
|
+
return host.includes(":") && !host.startsWith("[") && !host.endsWith("]");
|
|
446
|
+
}
|
|
447
447
|
function getUrlByRequestOptions(options) {
|
|
448
448
|
debug3("request options", options);
|
|
449
449
|
const protocol = getProtocolByRequestOptions(options);
|
|
@@ -455,7 +455,7 @@ function getUrlByRequestOptions(options) {
|
|
|
455
455
|
debug3("host", host);
|
|
456
456
|
debug3("port", port);
|
|
457
457
|
debug3("path", path);
|
|
458
|
-
const baseUrl = `${protocol}//${host}`;
|
|
458
|
+
const baseUrl = `${protocol}//${isRawIPv6Address(host) ? `[${host}]` : host}`;
|
|
459
459
|
debug3("base URL:", baseUrl);
|
|
460
460
|
const url = options.uri ? new URL(options.uri.href) : new URL(path, baseUrl);
|
|
461
461
|
if (port) {
|
|
@@ -1,39 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
3
|
}) : x)(function(x) {
|
|
10
4
|
if (typeof require !== "undefined")
|
|
11
5
|
return require.apply(this, arguments);
|
|
12
6
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
13
7
|
});
|
|
14
|
-
var __esm = (fn, res) => function __init() {
|
|
15
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
-
};
|
|
17
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
-
};
|
|
24
|
-
var __copyProps = (to, from, except, desc) => {
|
|
25
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
-
for (let key of __getOwnPropNames(from))
|
|
27
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
-
}
|
|
30
|
-
return to;
|
|
31
|
-
};
|
|
32
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
8
|
|
|
38
9
|
// src/Interceptor.ts
|
|
39
10
|
var _debug = require('debug');
|
|
@@ -283,9 +254,4 @@ var Interceptor = class {
|
|
|
283
254
|
|
|
284
255
|
|
|
285
256
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
exports.__require = __require; exports.__esm = __esm; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM; exports.__toCommonJS = __toCommonJS; exports.getGlobalSymbol = getGlobalSymbol; exports.deleteGlobalSymbol = deleteGlobalSymbol; exports.InterceptorReadyState = InterceptorReadyState; exports.Interceptor = Interceptor;
|
|
257
|
+
exports.__require = __require; exports.getGlobalSymbol = getGlobalSymbol; exports.deleteGlobalSymbol = deleteGlobalSymbol; exports.InterceptorReadyState = InterceptorReadyState; exports.Interceptor = Interceptor;
|
package/lib/node/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQ56TMOP5js = require('./chunk-Q56TMOP5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkSNNL2EXFjs = require('./chunk-SNNL2EXF.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
@@ -13,7 +13,7 @@ var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkWWHITCCIjs = require('./chunk-WWHITCCI.js');
|
|
17
17
|
|
|
18
18
|
// src/utils/getCleanUrl.ts
|
|
19
19
|
function getCleanUrl(url, isAbsolute = true) {
|
|
@@ -29,4 +29,4 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
exports.BatchInterceptor =
|
|
32
|
+
exports.BatchInterceptor = _chunkQ56TMOP5js.BatchInterceptor; exports.IS_PATCHED_MODULE = _chunkVQ4DZOBBjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkWWHITCCIjs.Interceptor; exports.InterceptorReadyState = _chunkWWHITCCIjs.InterceptorReadyState; exports.decodeBuffer = _chunkSNNL2EXFjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkWWHITCCIjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkSNNL2EXFjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkWWHITCCIjs.getGlobalSymbol;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KZEQH4YW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
decodeBuffer,
|
|
6
6
|
encodeBuffer
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-G6ZTHYZQ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
IS_PATCHED_MODULE
|
|
10
10
|
} from "./chunk-GFH37L5D.mjs";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
InterceptorReadyState,
|
|
14
14
|
deleteGlobalSymbol,
|
|
15
15
|
getGlobalSymbol
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-37CATPNG.mjs";
|
|
17
17
|
|
|
18
18
|
// src/utils/getCleanUrl.ts
|
|
19
19
|
function getCleanUrl(url, isAbsolute = true) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-6V3JXLBF.js');
|
|
3
|
+
var _chunkPRX3F52Mjs = require('../../chunk-PRX3F52M.js');
|
|
5
4
|
require('../../chunk-ZJOF5MEZ.js');
|
|
6
|
-
require('../../chunk-
|
|
5
|
+
require('../../chunk-WWHITCCI.js');
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
exports.ClientRequestInterceptor =
|
|
8
|
+
exports.ClientRequestInterceptor = _chunkPRX3F52Mjs.ClientRequestInterceptor;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-NNVTJLQA.mjs";
|
|
3
|
+
} from "../../chunk-SWJ33XIS.mjs";
|
|
5
4
|
import "../../chunk-STA6QBYM.mjs";
|
|
6
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-37CATPNG.mjs";
|
|
7
6
|
export {
|
|
8
7
|
ClientRequestInterceptor
|
|
9
8
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
5
|
-
require('../../chunk-6V3JXLBF.js');
|
|
3
|
+
var _chunkGGD5JOGBjs = require('../../chunk-GGD5JOGB.js');
|
|
4
|
+
require('../../chunk-SNNL2EXF.js');
|
|
6
5
|
require('../../chunk-VQ4DZOBB.js');
|
|
7
6
|
require('../../chunk-ZJOF5MEZ.js');
|
|
8
|
-
require('../../chunk-
|
|
7
|
+
require('../../chunk-WWHITCCI.js');
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
exports.XMLHttpRequestInterceptor =
|
|
10
|
+
exports.XMLHttpRequestInterceptor = _chunkGGD5JOGBjs.XMLHttpRequestInterceptor;
|