@mswjs/interceptors 0.22.4 → 0.22.6
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/README.md +3 -3
- package/lib/browser/{Interceptor-959f650e.d.ts → Interceptor-c794917d.d.ts} +2 -2
- package/lib/browser/{chunk-IIY3SHU3.js → chunk-2EIH6L6D.js} +25 -25
- package/lib/browser/{chunk-BQYA7ER5.mjs → chunk-2GVXYEMC.mjs} +5 -5
- package/lib/browser/chunk-2Z7B3HL5.js +106 -0
- package/lib/browser/{chunk-5B525MKF.mjs → chunk-65HGG3CV.mjs} +1 -1
- package/lib/browser/chunk-BVV2ZW34.js +675 -0
- package/lib/browser/chunk-GL6Y4E24.mjs +106 -0
- package/lib/browser/{chunk-QWL3EOEY.js → chunk-OK5YCL7L.js} +7 -7
- package/lib/browser/{chunk-ZJOF5MEZ.js → chunk-PCFJD76X.js} +11 -11
- package/lib/browser/chunk-PGR64QLT.mjs +675 -0
- package/lib/browser/{chunk-STA6QBYM.mjs → chunk-RT3ATOJH.mjs} +11 -11
- package/lib/browser/index.d.ts +6 -6
- package/lib/browser/index.js +4 -4
- package/lib/browser/index.mjs +2 -2
- package/lib/browser/interceptors/XMLHttpRequest/index.d.ts +3 -3
- package/lib/browser/interceptors/XMLHttpRequest/index.js +5 -677
- package/lib/browser/interceptors/XMLHttpRequest/index.mjs +5 -677
- package/lib/browser/interceptors/fetch/index.d.ts +2 -2
- package/lib/browser/interceptors/fetch/index.js +4 -101
- package/lib/browser/interceptors/fetch/index.mjs +4 -101
- package/lib/browser/presets/browser.d.ts +13 -0
- package/lib/browser/presets/browser.js +18 -0
- package/lib/browser/presets/browser.mjs +18 -0
- package/lib/node/{BatchInterceptor-a7261b26.d.ts → BatchInterceptor-5c1e5de3.d.ts} +5 -5
- package/lib/node/{Interceptor-997045eb.d.ts → Interceptor-b3a4098c.d.ts} +2 -2
- package/lib/node/RemoteHttpInterceptor.d.ts +3 -3
- package/lib/node/RemoteHttpInterceptor.js +9 -9
- package/lib/node/RemoteHttpInterceptor.mjs +5 -5
- package/lib/node/{chunk-FGPCRIW6.mjs → chunk-53LM4S3X.mjs} +59 -62
- package/lib/node/{chunk-WWHITCCI.js → chunk-62KFIM4W.js} +9 -8
- package/lib/node/{chunk-37CATPNG.mjs → chunk-6CRMKMDL.mjs} +6 -5
- package/lib/node/{chunk-XLZJAPVS.js → chunk-D7MOETL2.js} +59 -62
- package/lib/node/{chunk-RVLLS44W.js → chunk-F7BBA6FT.js} +9 -16
- package/lib/node/{chunk-KZEQH4YW.mjs → chunk-IC6Y7RGW.mjs} +1 -1
- package/lib/node/{chunk-SNNL2EXF.js → chunk-MUUQLKVJ.js} +3 -3
- package/lib/node/{chunk-G6ZTHYZQ.mjs → chunk-RFVEKRYP.mjs} +1 -1
- package/lib/node/{chunk-Q56TMOP5.js → chunk-SFLY7F52.js} +2 -2
- package/lib/node/{chunk-P7NKDCFD.mjs → chunk-X3TLFWGD.mjs} +5 -12
- package/lib/node/index.d.ts +3 -3
- package/lib/node/index.js +4 -4
- package/lib/node/index.mjs +3 -3
- package/lib/node/interceptors/ClientRequest/index.d.ts +3 -3
- package/lib/node/interceptors/ClientRequest/index.js +3 -3
- package/lib/node/interceptors/ClientRequest/index.mjs +2 -2
- package/lib/node/interceptors/XMLHttpRequest/index.d.ts +3 -3
- package/lib/node/interceptors/XMLHttpRequest/index.js +4 -4
- package/lib/node/interceptors/XMLHttpRequest/index.mjs +3 -3
- package/lib/node/interceptors/fetch/index.d.ts +2 -2
- package/lib/node/interceptors/fetch/index.js +2 -2
- package/lib/node/interceptors/fetch/index.mjs +1 -1
- package/lib/node/presets/node.d.ts +15 -0
- package/lib/node/presets/node.js +19 -0
- package/lib/node/presets/node.mjs +19 -0
- package/package.json +16 -1
- package/src/BatchInterceptor.ts +5 -5
- package/src/Interceptor.ts +2 -2
- package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +1 -1
- package/src/interceptors/ClientRequest/http.request.ts +1 -1
- package/src/interceptors/ClientRequest/index.ts +2 -2
- package/src/interceptors/ClientRequest/utils/createRequest.test.ts +1 -1
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +1 -1
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +1 -1
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts +5 -3
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.ts +1 -1
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +2 -8
- package/src/interceptors/XMLHttpRequest/index.ts +2 -2
- package/src/presets/browser.ts +4 -1
- package/src/presets/node.ts +4 -1
- package/src/utils/AsyncEventEmitter.ts +1 -1
- package/src/utils/cloneObject.ts +8 -6
- package/src/utils/debug.ts +4 -0
- package/src/utils/getUrlByRequestOptions.ts +13 -12
|
@@ -5,7 +5,7 @@ var _chunkZJOF5MEZjs = require('./chunk-ZJOF5MEZ.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk62KFIM4Wjs = require('./chunk-62KFIM4W.js');
|
|
9
9
|
|
|
10
10
|
// src/interceptors/ClientRequest/index.ts
|
|
11
11
|
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
|
|
@@ -16,9 +16,9 @@ var _https = require('https'); var _https2 = _interopRequireDefault(_https);
|
|
|
16
16
|
var _until = require('@open-draft/until');
|
|
17
17
|
|
|
18
18
|
// src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts
|
|
19
|
-
var
|
|
19
|
+
var log = _chunk62KFIM4Wjs.debug.call(void 0, "utils getUrlByRequestOptions");
|
|
20
20
|
function normalizeClientRequestEndArgs(...args) {
|
|
21
|
-
|
|
21
|
+
log("arguments", args);
|
|
22
22
|
const normalizedArgs = new Array(3).fill(null).map((value, index) => args[index] || value);
|
|
23
23
|
normalizedArgs.sort((a, b) => {
|
|
24
24
|
if (typeof a === "function") {
|
|
@@ -32,15 +32,14 @@ function normalizeClientRequestEndArgs(...args) {
|
|
|
32
32
|
}
|
|
33
33
|
return 0;
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
log("normalized args", normalizedArgs);
|
|
36
36
|
return normalizedArgs;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.ts
|
|
40
|
-
var
|
|
41
|
-
var log = _debug.debug.call(void 0, "http normalizeWriteArgs");
|
|
40
|
+
var log2 = _chunk62KFIM4Wjs.debug.call(void 0, "http normalizeWriteArgs");
|
|
42
41
|
function normalizeClientRequestWriteArgs(args) {
|
|
43
|
-
|
|
42
|
+
log2("normalizing ClientRequest.write arguments...", args);
|
|
44
43
|
const chunk = args[0];
|
|
45
44
|
const encoding = typeof args[1] === "string" ? args[1] : void 0;
|
|
46
45
|
const callback = typeof args[1] === "function" ? args[1] : args[2];
|
|
@@ -49,7 +48,7 @@ function normalizeClientRequestWriteArgs(args) {
|
|
|
49
48
|
encoding,
|
|
50
49
|
callback
|
|
51
50
|
];
|
|
52
|
-
|
|
51
|
+
log2("successfully normalized ClientRequest.write arguments:", writeArgs);
|
|
53
52
|
return writeArgs;
|
|
54
53
|
}
|
|
55
54
|
|
|
@@ -379,7 +378,6 @@ NodeClientRequest.suppressErrorCodes = [
|
|
|
379
378
|
|
|
380
379
|
|
|
381
380
|
|
|
382
|
-
|
|
383
381
|
// src/utils/getRequestOptionsByUrl.ts
|
|
384
382
|
function getRequestOptionsByUrl(url) {
|
|
385
383
|
const options = {
|
|
@@ -400,7 +398,7 @@ function getRequestOptionsByUrl(url) {
|
|
|
400
398
|
|
|
401
399
|
// src/utils/getUrlByRequestOptions.ts
|
|
402
400
|
|
|
403
|
-
var
|
|
401
|
+
var log3 = _chunk62KFIM4Wjs.debug.call(void 0, "utils getUrlByRequestOptions");
|
|
404
402
|
var DEFAULT_PATH = "/";
|
|
405
403
|
var DEFAULT_PROTOCOL = "http:";
|
|
406
404
|
var DEFAULT_HOST = "localhost";
|
|
@@ -468,51 +466,51 @@ function getHostname(host, port) {
|
|
|
468
466
|
return `${host}${portString}`;
|
|
469
467
|
}
|
|
470
468
|
function getUrlByRequestOptions(options) {
|
|
471
|
-
|
|
469
|
+
log3("request options", options);
|
|
472
470
|
if (options.uri) {
|
|
473
|
-
|
|
471
|
+
log3(
|
|
474
472
|
'constructing url from explicitly provided "options.uri": %s',
|
|
475
473
|
options.uri
|
|
476
474
|
);
|
|
477
475
|
return new URL(options.uri.href);
|
|
478
476
|
}
|
|
479
|
-
|
|
477
|
+
log3("figuring out url from request options...");
|
|
480
478
|
const protocol = getProtocolByRequestOptions(options);
|
|
481
|
-
|
|
479
|
+
log3("protocol", protocol);
|
|
482
480
|
const host = getHostByRequestOptions(options);
|
|
483
|
-
|
|
481
|
+
log3("host", host);
|
|
484
482
|
const port = getPortByRequestOptions(options);
|
|
485
|
-
|
|
483
|
+
log3("port", port);
|
|
486
484
|
const hostname = getHostname(host, port);
|
|
487
|
-
|
|
485
|
+
log3("hostname", hostname);
|
|
488
486
|
const path = options.path || DEFAULT_PATH;
|
|
489
|
-
|
|
487
|
+
log3("path", path);
|
|
490
488
|
const credentials = getAuthByRequestOptions(options);
|
|
491
|
-
|
|
489
|
+
log3("credentials", credentials);
|
|
492
490
|
const authString = credentials ? `${credentials.username}:${credentials.password}@` : "";
|
|
493
|
-
|
|
491
|
+
log3("auth string:", authString);
|
|
494
492
|
const url = new URL(`${protocol}//${authString}${hostname}${path}`);
|
|
495
|
-
|
|
493
|
+
log3("created url:", url);
|
|
496
494
|
return url;
|
|
497
495
|
}
|
|
498
496
|
|
|
499
497
|
// src/utils/cloneObject.ts
|
|
500
|
-
var
|
|
498
|
+
var log4 = _chunk62KFIM4Wjs.debug.call(void 0, "cloneObject");
|
|
501
499
|
function isPlainObject(obj) {
|
|
502
500
|
var _a;
|
|
503
|
-
|
|
501
|
+
log4("is plain object?", obj);
|
|
504
502
|
if (obj == null || !((_a = obj.constructor) == null ? void 0 : _a.name)) {
|
|
505
|
-
|
|
503
|
+
log4("given object is undefined, not a plain object...");
|
|
506
504
|
return false;
|
|
507
505
|
}
|
|
508
|
-
|
|
506
|
+
log4("checking the object constructor:", obj.constructor.name);
|
|
509
507
|
return obj.constructor.name === "Object";
|
|
510
508
|
}
|
|
511
509
|
function cloneObject(obj) {
|
|
512
|
-
|
|
510
|
+
log4("cloning object:", obj);
|
|
513
511
|
const enumerableProperties = Object.entries(obj).reduce(
|
|
514
512
|
(acc, [key, value]) => {
|
|
515
|
-
|
|
513
|
+
log4("analyzing key-value pair:", key, value);
|
|
516
514
|
acc[key] = isPlainObject(value) ? cloneObject(value) : value;
|
|
517
515
|
return acc;
|
|
518
516
|
},
|
|
@@ -527,25 +525,25 @@ function isObject(value) {
|
|
|
527
525
|
}
|
|
528
526
|
|
|
529
527
|
// src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts
|
|
530
|
-
var
|
|
528
|
+
var log5 = _chunk62KFIM4Wjs.debug.call(void 0, "http normalizeClientRequestArgs");
|
|
531
529
|
function resolveRequestOptions(args, url) {
|
|
532
530
|
if (typeof args[1] === "undefined" || typeof args[1] === "function") {
|
|
533
|
-
|
|
531
|
+
log5("request options not provided, deriving from the url", url);
|
|
534
532
|
return getRequestOptionsByUrl(url);
|
|
535
533
|
}
|
|
536
534
|
if (args[1]) {
|
|
537
|
-
|
|
535
|
+
log5("has custom RequestOptions!", args[1]);
|
|
538
536
|
const requestOptionsFromUrl = getRequestOptionsByUrl(url);
|
|
539
|
-
|
|
540
|
-
|
|
537
|
+
log5("derived RequestOptions from the URL:", requestOptionsFromUrl);
|
|
538
|
+
log5("cloning RequestOptions...");
|
|
541
539
|
const clonedRequestOptions = cloneObject(args[1]);
|
|
542
|
-
|
|
540
|
+
log5("successfully cloned RequestOptions!", clonedRequestOptions);
|
|
543
541
|
return {
|
|
544
542
|
...requestOptionsFromUrl,
|
|
545
543
|
...clonedRequestOptions
|
|
546
544
|
};
|
|
547
545
|
}
|
|
548
|
-
|
|
546
|
+
log5("using an empty object as request options");
|
|
549
547
|
return {};
|
|
550
548
|
}
|
|
551
549
|
function resolveCallback(args) {
|
|
@@ -555,28 +553,28 @@ function normalizeClientRequestArgs(defaultProtocol, ...args) {
|
|
|
555
553
|
let url;
|
|
556
554
|
let options;
|
|
557
555
|
let callback;
|
|
558
|
-
|
|
559
|
-
|
|
556
|
+
log5("arguments", args);
|
|
557
|
+
log5("using default protocol:", defaultProtocol);
|
|
560
558
|
if (typeof args[0] === "string") {
|
|
561
|
-
|
|
559
|
+
log5("first argument is a location string:", args[0]);
|
|
562
560
|
url = new URL(args[0]);
|
|
563
|
-
|
|
561
|
+
log5("created a url:", url);
|
|
564
562
|
const requestOptionsFromUrl = getRequestOptionsByUrl(url);
|
|
565
|
-
|
|
563
|
+
log5("request options from url:", requestOptionsFromUrl);
|
|
566
564
|
options = resolveRequestOptions(args, url);
|
|
567
|
-
|
|
565
|
+
log5("resolved request options:", options);
|
|
568
566
|
callback = resolveCallback(args);
|
|
569
567
|
} else if (args[0] instanceof URL) {
|
|
570
568
|
url = args[0];
|
|
571
|
-
|
|
569
|
+
log5("first argument is a URL:", url);
|
|
572
570
|
options = resolveRequestOptions(args, url);
|
|
573
|
-
|
|
571
|
+
log5("derived request options:", options);
|
|
574
572
|
callback = resolveCallback(args);
|
|
575
573
|
} else if ("hash" in args[0] && !("method" in args[0])) {
|
|
576
574
|
const [legacyUrl] = args;
|
|
577
|
-
|
|
575
|
+
log5("first argument is a legacy URL:", legacyUrl);
|
|
578
576
|
if (legacyUrl.hostname === null) {
|
|
579
|
-
|
|
577
|
+
log5("given legacy URL is relative (no hostname)");
|
|
580
578
|
return isObject(args[1]) ? normalizeClientRequestArgs(
|
|
581
579
|
defaultProtocol,
|
|
582
580
|
{ path: legacyUrl.path, ...args[1] },
|
|
@@ -587,7 +585,7 @@ function normalizeClientRequestArgs(defaultProtocol, ...args) {
|
|
|
587
585
|
args[1]
|
|
588
586
|
);
|
|
589
587
|
}
|
|
590
|
-
|
|
588
|
+
log5("given legacy url is absolute");
|
|
591
589
|
const resolvedUrl = new URL(legacyUrl.href);
|
|
592
590
|
return args[1] === void 0 ? normalizeClientRequestArgs(defaultProtocol, resolvedUrl) : typeof args[1] === "function" ? normalizeClientRequestArgs(defaultProtocol, resolvedUrl, args[1]) : normalizeClientRequestArgs(
|
|
593
591
|
defaultProtocol,
|
|
@@ -597,11 +595,11 @@ function normalizeClientRequestArgs(defaultProtocol, ...args) {
|
|
|
597
595
|
);
|
|
598
596
|
} else if (isObject(args[0])) {
|
|
599
597
|
options = args[0];
|
|
600
|
-
|
|
598
|
+
log5("first argument is RequestOptions:", options);
|
|
601
599
|
options.protocol = options.protocol || defaultProtocol;
|
|
602
|
-
|
|
600
|
+
log5("normalized request options:", options);
|
|
603
601
|
url = getUrlByRequestOptions(options);
|
|
604
|
-
|
|
602
|
+
log5("created a URL from RequestOptions:", url.href);
|
|
605
603
|
callback = resolveCallback(args);
|
|
606
604
|
} else {
|
|
607
605
|
throw new Error(
|
|
@@ -615,18 +613,18 @@ function normalizeClientRequestArgs(defaultProtocol, ...args) {
|
|
|
615
613
|
rejectUnauthorized: options.rejectUnauthorized
|
|
616
614
|
}) : new (0, _http.Agent)();
|
|
617
615
|
options.agent = agent;
|
|
618
|
-
|
|
616
|
+
log5("resolved fallback agent:", agent);
|
|
619
617
|
}
|
|
620
618
|
if (!options._defaultAgent) {
|
|
621
|
-
|
|
619
|
+
log5(
|
|
622
620
|
'has no default agent, setting the default agent for "%s"',
|
|
623
621
|
options.protocol
|
|
624
622
|
);
|
|
625
623
|
options._defaultAgent = options.protocol === "https:" ? _https.globalAgent : _http.globalAgent;
|
|
626
624
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
625
|
+
log5("successfully resolved url:", url.href);
|
|
626
|
+
log5("successfully resolved options:", options);
|
|
627
|
+
log5("successfully resolved callback:", callback);
|
|
630
628
|
return [url, options, callback];
|
|
631
629
|
}
|
|
632
630
|
|
|
@@ -644,11 +642,10 @@ function get(protocol, options) {
|
|
|
644
642
|
}
|
|
645
643
|
|
|
646
644
|
// src/interceptors/ClientRequest/http.request.ts
|
|
647
|
-
|
|
648
|
-
var log3 = _debug.debug.call(void 0, "http request");
|
|
645
|
+
var log6 = _chunk62KFIM4Wjs.debug.call(void 0, "http request");
|
|
649
646
|
function request(protocol, options) {
|
|
650
647
|
return (...args) => {
|
|
651
|
-
|
|
648
|
+
log6('request call (protocol "%s"):', protocol, args);
|
|
652
649
|
const clientRequestArgs = normalizeClientRequestArgs(
|
|
653
650
|
`${protocol}:`,
|
|
654
651
|
...args
|
|
@@ -658,21 +655,21 @@ function request(protocol, options) {
|
|
|
658
655
|
}
|
|
659
656
|
|
|
660
657
|
// src/interceptors/ClientRequest/index.ts
|
|
661
|
-
var _ClientRequestInterceptor = class extends
|
|
658
|
+
var _ClientRequestInterceptor = class extends _chunk62KFIM4Wjs.Interceptor {
|
|
662
659
|
constructor() {
|
|
663
|
-
super(_ClientRequestInterceptor.
|
|
660
|
+
super(_ClientRequestInterceptor.interceptorSymbol);
|
|
664
661
|
this.modules = /* @__PURE__ */ new Map();
|
|
665
662
|
this.modules.set("http", _http2.default);
|
|
666
663
|
this.modules.set("https", _https2.default);
|
|
667
664
|
}
|
|
668
665
|
setup() {
|
|
669
|
-
const
|
|
666
|
+
const log7 = this.log.extend("setup");
|
|
670
667
|
for (const [protocol, requestModule] of this.modules) {
|
|
671
668
|
const { request: pureRequest, get: pureGet } = requestModule;
|
|
672
669
|
this.subscriptions.push(() => {
|
|
673
670
|
requestModule.request = pureRequest;
|
|
674
671
|
requestModule.get = pureGet;
|
|
675
|
-
|
|
672
|
+
log7('native "%s" module restored!', protocol);
|
|
676
673
|
});
|
|
677
674
|
const options = {
|
|
678
675
|
emitter: this.emitter,
|
|
@@ -680,12 +677,12 @@ var _ClientRequestInterceptor = class extends _chunkWWHITCCIjs.Interceptor {
|
|
|
680
677
|
};
|
|
681
678
|
requestModule.request = request(protocol, options);
|
|
682
679
|
requestModule.get = get(protocol, options);
|
|
683
|
-
|
|
680
|
+
log7('native "%s" module patched!', protocol);
|
|
684
681
|
}
|
|
685
682
|
}
|
|
686
683
|
};
|
|
687
684
|
var ClientRequestInterceptor = _ClientRequestInterceptor;
|
|
688
|
-
ClientRequestInterceptor.
|
|
685
|
+
ClientRequestInterceptor.interceptorSymbol = Symbol("http");
|
|
689
686
|
|
|
690
687
|
|
|
691
688
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkMUUQLKVJjs = require('./chunk-MUUQLKVJ.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
@@ -12,7 +12,7 @@ var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
|
12
12
|
var _chunkZJOF5MEZjs = require('./chunk-ZJOF5MEZ.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunk62KFIM4Wjs = require('./chunk-62KFIM4W.js');
|
|
16
16
|
|
|
17
17
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
18
18
|
var _outvariant = require('outvariant');
|
|
@@ -210,14 +210,7 @@ var XMLHttpRequestController = class {
|
|
|
210
210
|
this.request = createProxy(initialRequest, {
|
|
211
211
|
setProperty: ([propertyName, nextValue], invoke) => {
|
|
212
212
|
switch (propertyName) {
|
|
213
|
-
case "
|
|
214
|
-
case "onerror":
|
|
215
|
-
case "onload":
|
|
216
|
-
case "onloadend":
|
|
217
|
-
case "onloadstart":
|
|
218
|
-
case "onprogress":
|
|
219
|
-
case "ontimeout":
|
|
220
|
-
case "onreadystatechange": {
|
|
213
|
+
case "ontimeout": {
|
|
221
214
|
const eventName = propertyName.slice(
|
|
222
215
|
2
|
|
223
216
|
);
|
|
@@ -261,7 +254,7 @@ var XMLHttpRequestController = class {
|
|
|
261
254
|
case "send": {
|
|
262
255
|
const [body] = args;
|
|
263
256
|
if (body != null) {
|
|
264
|
-
this.requestBody = typeof body === "string" ?
|
|
257
|
+
this.requestBody = typeof body === "string" ? _chunkMUUQLKVJjs.encodeBuffer.call(void 0, body) : body;
|
|
265
258
|
}
|
|
266
259
|
this.request.addEventListener("load", () => {
|
|
267
260
|
if (typeof this.onResponse !== "undefined") {
|
|
@@ -403,7 +396,7 @@ var XMLHttpRequestController = class {
|
|
|
403
396
|
}
|
|
404
397
|
}
|
|
405
398
|
responseBufferToText() {
|
|
406
|
-
return
|
|
399
|
+
return _chunkMUUQLKVJjs.decodeBuffer.call(void 0, this.responseBuffer);
|
|
407
400
|
}
|
|
408
401
|
get response() {
|
|
409
402
|
this.log("getResponse (responseType: %s)", this.request.responseType);
|
|
@@ -417,7 +410,7 @@ var XMLHttpRequestController = class {
|
|
|
417
410
|
return responseJson;
|
|
418
411
|
}
|
|
419
412
|
case "arraybuffer": {
|
|
420
|
-
const arrayBuffer =
|
|
413
|
+
const arrayBuffer = _chunkMUUQLKVJjs.toArrayBuffer.call(void 0, this.responseBuffer);
|
|
421
414
|
this.log("resolved response ArrayBuffer", arrayBuffer);
|
|
422
415
|
return arrayBuffer;
|
|
423
416
|
}
|
|
@@ -636,9 +629,9 @@ function createXMLHttpRequestProxy({
|
|
|
636
629
|
}
|
|
637
630
|
|
|
638
631
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
639
|
-
var _XMLHttpRequestInterceptor = class extends
|
|
632
|
+
var _XMLHttpRequestInterceptor = class extends _chunk62KFIM4Wjs.Interceptor {
|
|
640
633
|
constructor() {
|
|
641
|
-
super(_XMLHttpRequestInterceptor.
|
|
634
|
+
super(_XMLHttpRequestInterceptor.interceptorSymbol);
|
|
642
635
|
}
|
|
643
636
|
checkEnvironment() {
|
|
644
637
|
return typeof globalThis.XMLHttpRequest !== "undefined";
|
|
@@ -677,7 +670,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkWWHITCCIjs.Interceptor {
|
|
|
677
670
|
}
|
|
678
671
|
};
|
|
679
672
|
var XMLHttpRequestInterceptor = _XMLHttpRequestInterceptor;
|
|
680
|
-
XMLHttpRequestInterceptor.
|
|
673
|
+
XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
|
681
674
|
|
|
682
675
|
|
|
683
676
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk62KFIM4Wjs = require('./chunk-62KFIM4W.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" ? _chunk62KFIM4Wjs.__require.call(void 0, "util").TextEncoder : globalThis.TextEncoder;
|
|
7
|
+
var TextDecoder = typeof globalThis.TextDecoder === "undefined" ? _chunk62KFIM4Wjs.__require.call(void 0, "util").TextDecoder : globalThis.TextDecoder;
|
|
8
8
|
|
|
9
9
|
// src/utils/bufferUtils.ts
|
|
10
10
|
var encoder = new TextEncoder();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk62KFIM4Wjs = require('./chunk-62KFIM4W.js');
|
|
4
4
|
|
|
5
5
|
// src/BatchInterceptor.ts
|
|
6
|
-
var BatchInterceptor = class extends
|
|
6
|
+
var BatchInterceptor = class extends _chunk62KFIM4Wjs.Interceptor {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
9
9
|
super(BatchInterceptor.symbol);
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
decodeBuffer,
|
|
3
3
|
encodeBuffer,
|
|
4
4
|
toArrayBuffer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RFVEKRYP.mjs";
|
|
6
6
|
import {
|
|
7
7
|
IS_PATCHED_MODULE
|
|
8
8
|
} from "./chunk-GFH37L5D.mjs";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-STA6QBYM.mjs";
|
|
13
13
|
import {
|
|
14
14
|
Interceptor
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6CRMKMDL.mjs";
|
|
16
16
|
|
|
17
17
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
18
18
|
import { invariant as invariant2 } from "outvariant";
|
|
@@ -210,14 +210,7 @@ var XMLHttpRequestController = class {
|
|
|
210
210
|
this.request = createProxy(initialRequest, {
|
|
211
211
|
setProperty: ([propertyName, nextValue], invoke) => {
|
|
212
212
|
switch (propertyName) {
|
|
213
|
-
case "
|
|
214
|
-
case "onerror":
|
|
215
|
-
case "onload":
|
|
216
|
-
case "onloadend":
|
|
217
|
-
case "onloadstart":
|
|
218
|
-
case "onprogress":
|
|
219
|
-
case "ontimeout":
|
|
220
|
-
case "onreadystatechange": {
|
|
213
|
+
case "ontimeout": {
|
|
221
214
|
const eventName = propertyName.slice(
|
|
222
215
|
2
|
|
223
216
|
);
|
|
@@ -638,7 +631,7 @@ function createXMLHttpRequestProxy({
|
|
|
638
631
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
639
632
|
var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
640
633
|
constructor() {
|
|
641
|
-
super(_XMLHttpRequestInterceptor.
|
|
634
|
+
super(_XMLHttpRequestInterceptor.interceptorSymbol);
|
|
642
635
|
}
|
|
643
636
|
checkEnvironment() {
|
|
644
637
|
return typeof globalThis.XMLHttpRequest !== "undefined";
|
|
@@ -677,7 +670,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
|
677
670
|
}
|
|
678
671
|
};
|
|
679
672
|
var XMLHttpRequestInterceptor = _XMLHttpRequestInterceptor;
|
|
680
|
-
XMLHttpRequestInterceptor.
|
|
673
|
+
XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
|
681
674
|
|
|
682
675
|
export {
|
|
683
676
|
XMLHttpRequestInterceptor
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { E as ExtractEventNames, H as HttpRequestEventMap, I as IS_PATCHED_MODULE, e as Interceptor, a as InterceptorEventMap, c as InterceptorReadyState, b as InterceptorSubscription, R as RequestCredentials, d as deleteGlobalSymbol, g as getGlobalSymbol } from './Interceptor-
|
|
2
|
-
export { a as BatchInterceptor, B as BatchInterceptorOptions, E as ExtractEventMapType } from './BatchInterceptor-
|
|
3
|
-
import 'debug';
|
|
1
|
+
export { E as ExtractEventNames, H as HttpRequestEventMap, I as IS_PATCHED_MODULE, e as Interceptor, a as InterceptorEventMap, c as InterceptorReadyState, b as InterceptorSubscription, R as RequestCredentials, d as deleteGlobalSymbol, g as getGlobalSymbol } from './Interceptor-b3a4098c.js';
|
|
2
|
+
export { a as BatchInterceptor, B as BatchInterceptorOptions, E as ExtractEventMapType } from './BatchInterceptor-5c1e5de3.js';
|
|
4
3
|
import 'strict-event-emitter';
|
|
4
|
+
import 'debug';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Removes query parameters and hashes from a given URL.
|
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 _chunkSFLY7F52js = require('./chunk-SFLY7F52.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkMUUQLKVJjs = require('./chunk-MUUQLKVJ.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 _chunk62KFIM4Wjs = require('./chunk-62KFIM4W.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 = _chunkSFLY7F52js.BatchInterceptor; exports.IS_PATCHED_MODULE = _chunkVQ4DZOBBjs.IS_PATCHED_MODULE; exports.Interceptor = _chunk62KFIM4Wjs.Interceptor; exports.InterceptorReadyState = _chunk62KFIM4Wjs.InterceptorReadyState; exports.decodeBuffer = _chunkMUUQLKVJjs.decodeBuffer; exports.deleteGlobalSymbol = _chunk62KFIM4Wjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkMUUQLKVJjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunk62KFIM4Wjs.getGlobalSymbol;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IC6Y7RGW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
decodeBuffer,
|
|
6
6
|
encodeBuffer
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RFVEKRYP.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-6CRMKMDL.mjs";
|
|
17
17
|
|
|
18
18
|
// src/utils/getCleanUrl.ts
|
|
19
19
|
function getCleanUrl(url, isAbsolute = true) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
import https from 'https';
|
|
3
|
-
import { A as AsyncEventEmitter, H as HttpRequestEventMap, e as Interceptor } from '../../Interceptor-
|
|
4
|
-
import 'debug';
|
|
3
|
+
import { A as AsyncEventEmitter, H as HttpRequestEventMap, e as Interceptor } from '../../Interceptor-b3a4098c.js';
|
|
5
4
|
import 'strict-event-emitter';
|
|
5
|
+
import 'debug';
|
|
6
6
|
|
|
7
7
|
type Protocol = 'http' | 'https';
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ type ClientRequestModules = Map<Protocol, typeof http | typeof https>;
|
|
|
13
13
|
* Such requests include `http.get`, `https.request`, etc.
|
|
14
14
|
*/
|
|
15
15
|
declare class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
16
|
-
static
|
|
16
|
+
static interceptorSymbol: symbol;
|
|
17
17
|
private modules;
|
|
18
18
|
constructor();
|
|
19
19
|
protected setup(): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkD7MOETL2js = require('../../chunk-D7MOETL2.js');
|
|
4
4
|
require('../../chunk-ZJOF5MEZ.js');
|
|
5
|
-
require('../../chunk-
|
|
5
|
+
require('../../chunk-62KFIM4W.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.ClientRequestInterceptor =
|
|
8
|
+
exports.ClientRequestInterceptor = _chunkD7MOETL2js.ClientRequestInterceptor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-53LM4S3X.mjs";
|
|
4
4
|
import "../../chunk-STA6QBYM.mjs";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-6CRMKMDL.mjs";
|
|
6
6
|
export {
|
|
7
7
|
ClientRequestInterceptor
|
|
8
8
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { f as InteractiveRequest, A as AsyncEventEmitter, H as HttpRequestEventMap, e as Interceptor } from '../../Interceptor-
|
|
2
|
-
import 'debug';
|
|
1
|
+
import { f as InteractiveRequest, A as AsyncEventEmitter, H as HttpRequestEventMap, e as Interceptor } from '../../Interceptor-b3a4098c.js';
|
|
3
2
|
import 'strict-event-emitter';
|
|
3
|
+
import 'debug';
|
|
4
4
|
|
|
5
5
|
type XMLHttpRequestEventListener = (request: InteractiveRequest, requestId: string) => Promise<void> | void;
|
|
6
6
|
type XMLHttpRequestEmitter = AsyncEventEmitter<HttpRequestEventMap>;
|
|
7
7
|
declare class XMLHttpRequestInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
8
|
-
static
|
|
8
|
+
static interceptorSymbol: symbol;
|
|
9
9
|
constructor();
|
|
10
10
|
protected checkEnvironment(): boolean;
|
|
11
11
|
protected setup(): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var _chunkF7BBA6FTjs = require('../../chunk-F7BBA6FT.js');
|
|
4
|
+
require('../../chunk-MUUQLKVJ.js');
|
|
5
5
|
require('../../chunk-VQ4DZOBB.js');
|
|
6
6
|
require('../../chunk-ZJOF5MEZ.js');
|
|
7
|
-
require('../../chunk-
|
|
7
|
+
require('../../chunk-62KFIM4W.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.XMLHttpRequestInterceptor =
|
|
10
|
+
exports.XMLHttpRequestInterceptor = _chunkF7BBA6FTjs.XMLHttpRequestInterceptor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-X3TLFWGD.mjs";
|
|
4
|
+
import "../../chunk-RFVEKRYP.mjs";
|
|
5
5
|
import "../../chunk-GFH37L5D.mjs";
|
|
6
6
|
import "../../chunk-STA6QBYM.mjs";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-6CRMKMDL.mjs";
|
|
8
8
|
export {
|
|
9
9
|
XMLHttpRequestInterceptor
|
|
10
10
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-
|
|
2
|
-
import 'debug';
|
|
1
|
+
import { e as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-b3a4098c.js';
|
|
3
2
|
import 'strict-event-emitter';
|
|
3
|
+
import 'debug';
|
|
4
4
|
|
|
5
5
|
declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
6
6
|
static symbol: symbol;
|