@zimic/interceptor 0.15.0-canary.1 → 0.15.0-canary.3
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/dist/{chunk-3O3YPVEG.mjs → chunk-6TSSHQW5.mjs} +50 -25
- package/dist/chunk-6TSSHQW5.mjs.map +1 -0
- package/dist/{chunk-CWBDZYUG.js → chunk-R2ROSKU4.js} +51 -25
- package/dist/chunk-R2ROSKU4.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/http.d.ts +84 -40
- package/dist/http.js +144 -83
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +143 -83
- package/dist/http.mjs.map +1 -1
- package/dist/server.d.ts +17 -11
- package/dist/server.js +10 -6
- package/dist/server.mjs +1 -1
- package/package.json +12 -12
- package/src/cli/server/start.ts +1 -1
- package/src/http/index.ts +2 -14
- package/src/http/interceptor/HttpInterceptorClient.ts +51 -19
- package/src/http/interceptor/LocalHttpInterceptor.ts +27 -11
- package/src/http/interceptor/RemoteHttpInterceptor.ts +25 -10
- package/src/http/interceptor/errors/{NotStartedHttpInterceptorError.ts → NotRunningHttpInterceptorError.ts} +3 -3
- package/src/http/interceptor/errors/RunningHttpInterceptorError.ts +15 -0
- package/src/http/interceptor/types/options.ts +4 -6
- package/src/http/interceptor/types/public.ts +58 -20
- package/src/http/interceptorWorker/LocalHttpInterceptorWorker.ts +7 -6
- package/src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts +8 -7
- package/src/http/requestHandler/HttpRequestHandlerClient.ts +4 -6
- package/src/http/requestHandler/types/public.ts +12 -6
- package/src/server/InterceptorServer.ts +28 -11
- package/src/server/constants.ts +1 -0
- package/src/server/errors/NotRunningInterceptorServerError.ts +10 -0
- package/src/server/errors/RunningInterceptorServerError.ts +13 -0
- package/src/server/index.ts +2 -1
- package/src/server/types/public.ts +6 -10
- package/src/webSocket/WebSocketHandler.ts +2 -2
- package/src/webSocket/errors/NotRunningWebSocketHandlerError.ts +8 -0
- package/dist/chunk-3O3YPVEG.mjs.map +0 -1
- package/dist/chunk-CWBDZYUG.js.map +0 -1
- package/src/server/errors/NotStartedInterceptorServerError.ts +0 -10
- package/src/webSocket/errors/NotStartedWebSocketHandlerError.ts +0 -8
package/dist/http.mjs
CHANGED
|
@@ -26,43 +26,6 @@ var UnknownHttpInterceptorTypeError_default = UnknownHttpInterceptorTypeError;
|
|
|
26
26
|
var __defProp2 = Object.defineProperty;
|
|
27
27
|
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
28
28
|
|
|
29
|
-
// ../zimic-utils/dist/url/excludeURLParams.mjs
|
|
30
|
-
function excludeURLParams(url) {
|
|
31
|
-
url.hash = "";
|
|
32
|
-
url.search = "";
|
|
33
|
-
url.username = "";
|
|
34
|
-
url.password = "";
|
|
35
|
-
return url;
|
|
36
|
-
}
|
|
37
|
-
__name(excludeURLParams, "excludeURLParams");
|
|
38
|
-
__name2(excludeURLParams, "excludeURLParams");
|
|
39
|
-
var excludeURLParams_default = excludeURLParams;
|
|
40
|
-
|
|
41
|
-
// ../zimic-utils/dist/url/validateURLProtocol.mjs
|
|
42
|
-
var UnsupportedURLProtocolError = class extends TypeError {
|
|
43
|
-
static {
|
|
44
|
-
__name(this, "UnsupportedURLProtocolError");
|
|
45
|
-
}
|
|
46
|
-
static {
|
|
47
|
-
__name2(this, "UnsupportedURLProtocolError");
|
|
48
|
-
}
|
|
49
|
-
constructor(protocol, availableProtocols) {
|
|
50
|
-
super(
|
|
51
|
-
`Unsupported URL protocol: '${protocol}'. The available options are ${availableProtocols.map((protocol2) => `'${protocol2}'`).join(", ")}`
|
|
52
|
-
);
|
|
53
|
-
this.name = "UnsupportedURLProtocolError";
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function validateURLProtocol(url, protocols) {
|
|
57
|
-
const protocol = url.protocol.replace(/:$/, "");
|
|
58
|
-
if (!protocols.includes(protocol)) {
|
|
59
|
-
throw new UnsupportedURLProtocolError(protocol, protocols);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
__name(validateURLProtocol, "validateURLProtocol");
|
|
63
|
-
__name2(validateURLProtocol, "validateURLProtocol");
|
|
64
|
-
var validateURLProtocol_default = validateURLProtocol;
|
|
65
|
-
|
|
66
29
|
// ../zimic-utils/dist/data/blobContains.mjs
|
|
67
30
|
async function blobContains(blob, otherBlob) {
|
|
68
31
|
return blob.type === otherBlob.type && blob.size >= otherBlob.size && (await blob.text()).includes(await otherBlob.text());
|
|
@@ -451,7 +414,7 @@ var HttpRequestHandlerClient = class {
|
|
|
451
414
|
declarationPointer: this.timesDeclarationPointer,
|
|
452
415
|
unmatchedRequestGroups: this.unmatchedRequestGroups,
|
|
453
416
|
hasRestrictions: this.restrictions.length > 0,
|
|
454
|
-
hasSavedRequests: this.interceptor.
|
|
417
|
+
hasSavedRequests: this.interceptor.saveRequests
|
|
455
418
|
});
|
|
456
419
|
}
|
|
457
420
|
}
|
|
@@ -476,7 +439,7 @@ var HttpRequestHandlerClient = class {
|
|
|
476
439
|
if (restrictionsMatch.value) {
|
|
477
440
|
this.numberOfMatchedRequests++;
|
|
478
441
|
} else {
|
|
479
|
-
const shouldSaveUnmatchedGroup = this.interceptor.
|
|
442
|
+
const shouldSaveUnmatchedGroup = this.interceptor.saveRequests && this.restrictions.length > 0 && this.timesDeclarationPointer !== void 0;
|
|
480
443
|
if (shouldSaveUnmatchedGroup) {
|
|
481
444
|
this.unmatchedRequestGroups.push({ request, diff: restrictionsMatch.diff });
|
|
482
445
|
}
|
|
@@ -622,7 +585,7 @@ var HttpRequestHandlerClient = class {
|
|
|
622
585
|
return interceptedRequest;
|
|
623
586
|
}
|
|
624
587
|
get requests() {
|
|
625
|
-
if (!this.interceptor.
|
|
588
|
+
if (!this.interceptor.saveRequests) {
|
|
626
589
|
throw new DisabledRequestSavingError_default();
|
|
627
590
|
}
|
|
628
591
|
return this._requests;
|
|
@@ -692,6 +655,18 @@ __name(createRegExpFromURL, "createRegExpFromURL");
|
|
|
692
655
|
__name2(createRegExpFromURL, "createRegExpFromURL");
|
|
693
656
|
var createRegExpFromURL_default = createRegExpFromURL;
|
|
694
657
|
|
|
658
|
+
// ../zimic-utils/dist/url/excludeURLParams.mjs
|
|
659
|
+
function excludeURLParams(url) {
|
|
660
|
+
url.hash = "";
|
|
661
|
+
url.search = "";
|
|
662
|
+
url.username = "";
|
|
663
|
+
url.password = "";
|
|
664
|
+
return url;
|
|
665
|
+
}
|
|
666
|
+
__name(excludeURLParams, "excludeURLParams");
|
|
667
|
+
__name2(excludeURLParams, "excludeURLParams");
|
|
668
|
+
var excludeURLParams_default = excludeURLParams;
|
|
669
|
+
|
|
695
670
|
// ../zimic-utils/dist/url/joinURL.mjs
|
|
696
671
|
function joinURL(...parts) {
|
|
697
672
|
return parts.map((part, index) => {
|
|
@@ -711,6 +686,31 @@ __name(joinURL, "joinURL");
|
|
|
711
686
|
__name2(joinURL, "joinURL");
|
|
712
687
|
var joinURL_default = joinURL;
|
|
713
688
|
|
|
689
|
+
// ../zimic-utils/dist/url/validateURLProtocol.mjs
|
|
690
|
+
var UnsupportedURLProtocolError = class extends TypeError {
|
|
691
|
+
static {
|
|
692
|
+
__name(this, "UnsupportedURLProtocolError");
|
|
693
|
+
}
|
|
694
|
+
static {
|
|
695
|
+
__name2(this, "UnsupportedURLProtocolError");
|
|
696
|
+
}
|
|
697
|
+
constructor(protocol, availableProtocols) {
|
|
698
|
+
super(
|
|
699
|
+
`Unsupported URL protocol: '${protocol}'. The available options are ${availableProtocols.map((protocol2) => `'${protocol2}'`).join(", ")}`
|
|
700
|
+
);
|
|
701
|
+
this.name = "UnsupportedURLProtocolError";
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
function validateURLProtocol(url, protocols) {
|
|
705
|
+
const protocol = url.protocol.replace(/:$/, "");
|
|
706
|
+
if (!protocols.includes(protocol)) {
|
|
707
|
+
throw new UnsupportedURLProtocolError(protocol, protocols);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
__name(validateURLProtocol, "validateURLProtocol");
|
|
711
|
+
__name2(validateURLProtocol, "validateURLProtocol");
|
|
712
|
+
var validateURLProtocol_default = validateURLProtocol;
|
|
713
|
+
|
|
714
714
|
// src/utils/arrays.ts
|
|
715
715
|
function removeArrayIndex(array, index) {
|
|
716
716
|
if (index >= 0 && index < array.length) {
|
|
@@ -1180,17 +1180,17 @@ __name(validateURLPathParams, "validateURLPathParams");
|
|
|
1180
1180
|
__name2(validateURLPathParams, "validateURLPathParams");
|
|
1181
1181
|
var validateURLPathParams_default = validateURLPathParams;
|
|
1182
1182
|
|
|
1183
|
-
// src/http/interceptor/errors/
|
|
1184
|
-
var
|
|
1183
|
+
// src/http/interceptor/errors/NotRunningHttpInterceptorError.ts
|
|
1184
|
+
var NotRunningHttpInterceptorError = class extends Error {
|
|
1185
1185
|
static {
|
|
1186
|
-
__name(this, "
|
|
1186
|
+
__name(this, "NotRunningHttpInterceptorError");
|
|
1187
1187
|
}
|
|
1188
1188
|
constructor() {
|
|
1189
1189
|
super("Interceptor is not running. Did you forget to call `await interceptor.start()`?");
|
|
1190
|
-
this.name = "
|
|
1190
|
+
this.name = "NotRunningHttpInterceptorError";
|
|
1191
1191
|
}
|
|
1192
1192
|
};
|
|
1193
|
-
var
|
|
1193
|
+
var NotRunningHttpInterceptorError_default = NotRunningHttpInterceptorError;
|
|
1194
1194
|
|
|
1195
1195
|
// src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts
|
|
1196
1196
|
var UnknownHttpInterceptorPlatformError = class extends Error {
|
|
@@ -1235,21 +1235,22 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1235
1235
|
static {
|
|
1236
1236
|
__name(this, "LocalHttpInterceptorWorker");
|
|
1237
1237
|
}
|
|
1238
|
-
type;
|
|
1239
1238
|
internalWorker;
|
|
1240
1239
|
defaultHttpHandler;
|
|
1241
1240
|
httpHandlerGroups = [];
|
|
1242
|
-
constructor(
|
|
1241
|
+
constructor(_options) {
|
|
1243
1242
|
super();
|
|
1244
|
-
this.type = options.type;
|
|
1245
1243
|
this.defaultHttpHandler = http.all("*", async (context) => {
|
|
1246
1244
|
const request = context.request;
|
|
1247
1245
|
return this.bypassOrRejectUnhandledRequest(request);
|
|
1248
1246
|
});
|
|
1249
1247
|
}
|
|
1248
|
+
get type() {
|
|
1249
|
+
return "local";
|
|
1250
|
+
}
|
|
1250
1251
|
get internalWorkerOrThrow() {
|
|
1251
1252
|
if (!this.internalWorker) {
|
|
1252
|
-
throw new
|
|
1253
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
1253
1254
|
}
|
|
1254
1255
|
return this.internalWorker;
|
|
1255
1256
|
}
|
|
@@ -1487,6 +1488,18 @@ var RemoteHttpRequestHandler = class {
|
|
|
1487
1488
|
};
|
|
1488
1489
|
var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
1489
1490
|
|
|
1491
|
+
// src/http/interceptor/errors/RunningHttpInterceptorError.ts
|
|
1492
|
+
var RunningHttpInterceptorError = class extends Error {
|
|
1493
|
+
static {
|
|
1494
|
+
__name(this, "RunningHttpInterceptorError");
|
|
1495
|
+
}
|
|
1496
|
+
constructor(additionalMessage) {
|
|
1497
|
+
super(`The interceptor is running.${additionalMessage}`);
|
|
1498
|
+
this.name = "RunningHttpInterceptorError";
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
var RunningHttpInterceptorError_default = RunningHttpInterceptorError;
|
|
1502
|
+
|
|
1490
1503
|
// src/http/interceptor/HttpInterceptorClient.ts
|
|
1491
1504
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1492
1505
|
var HttpInterceptorClient = class {
|
|
@@ -1496,9 +1509,9 @@ var HttpInterceptorClient = class {
|
|
|
1496
1509
|
worker;
|
|
1497
1510
|
store;
|
|
1498
1511
|
_baseURL;
|
|
1499
|
-
|
|
1512
|
+
_saveRequests = false;
|
|
1500
1513
|
onUnhandledRequest;
|
|
1501
|
-
|
|
1514
|
+
isRunning = false;
|
|
1502
1515
|
Handler;
|
|
1503
1516
|
handlerClientsByMethod = {
|
|
1504
1517
|
GET: /* @__PURE__ */ new Map(),
|
|
@@ -1512,17 +1525,35 @@ var HttpInterceptorClient = class {
|
|
|
1512
1525
|
constructor(options) {
|
|
1513
1526
|
this.worker = options.worker;
|
|
1514
1527
|
this.store = options.store;
|
|
1515
|
-
this.
|
|
1516
|
-
this.
|
|
1528
|
+
this.baseURL = options.baseURL;
|
|
1529
|
+
this._saveRequests = options.saveRequests ?? false;
|
|
1517
1530
|
this.onUnhandledRequest = options.onUnhandledRequest;
|
|
1518
|
-
this.
|
|
1531
|
+
this.Handler = options.Handler;
|
|
1532
|
+
}
|
|
1533
|
+
get baseURL() {
|
|
1534
|
+
return this._baseURL;
|
|
1535
|
+
}
|
|
1536
|
+
set baseURL(newBaseURL) {
|
|
1537
|
+
if (this.isRunning) {
|
|
1538
|
+
throw new RunningHttpInterceptorError_default(
|
|
1539
|
+
"Did you forget to call `await interceptor.stop()` before changing the base URL?"
|
|
1540
|
+
);
|
|
1541
|
+
}
|
|
1542
|
+
validateURLProtocol_default(newBaseURL, SUPPORTED_BASE_URL_PROTOCOLS);
|
|
1543
|
+
excludeURLParams_default(newBaseURL);
|
|
1544
|
+
this._baseURL = newBaseURL;
|
|
1519
1545
|
}
|
|
1520
1546
|
get baseURLAsString() {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
return baseURL.origin;
|
|
1547
|
+
if (this.baseURL.href === `${this.baseURL.origin}/`) {
|
|
1548
|
+
return this.baseURL.origin;
|
|
1524
1549
|
}
|
|
1525
|
-
return baseURL.href;
|
|
1550
|
+
return this.baseURL.href;
|
|
1551
|
+
}
|
|
1552
|
+
get saveRequests() {
|
|
1553
|
+
return this._saveRequests;
|
|
1554
|
+
}
|
|
1555
|
+
set saveRequests(saveRequests) {
|
|
1556
|
+
this._saveRequests = saveRequests;
|
|
1526
1557
|
}
|
|
1527
1558
|
get platform() {
|
|
1528
1559
|
return this.worker.platform;
|
|
@@ -1544,7 +1575,7 @@ var HttpInterceptorClient = class {
|
|
|
1544
1575
|
if (this.worker instanceof LocalHttpInterceptorWorker_default) {
|
|
1545
1576
|
this.store.markLocalInterceptorAsRunning(this, isRunning);
|
|
1546
1577
|
} else {
|
|
1547
|
-
this.store.markRemoteInterceptorAsRunning(this, isRunning, this.
|
|
1578
|
+
this.store.markRemoteInterceptorAsRunning(this, isRunning, this.baseURL);
|
|
1548
1579
|
}
|
|
1549
1580
|
this.isRunning = isRunning;
|
|
1550
1581
|
}
|
|
@@ -1552,7 +1583,7 @@ var HttpInterceptorClient = class {
|
|
|
1552
1583
|
if (this.worker instanceof LocalHttpInterceptorWorker_default) {
|
|
1553
1584
|
return this.store.numberOfRunningLocalInterceptors;
|
|
1554
1585
|
} else {
|
|
1555
|
-
return this.store.numberOfRunningRemoteInterceptors(this.
|
|
1586
|
+
return this.store.numberOfRunningRemoteInterceptors(this.baseURL);
|
|
1556
1587
|
}
|
|
1557
1588
|
}
|
|
1558
1589
|
get(path) {
|
|
@@ -1578,7 +1609,7 @@ var HttpInterceptorClient = class {
|
|
|
1578
1609
|
}
|
|
1579
1610
|
createHttpRequestHandler(method, path) {
|
|
1580
1611
|
if (!this.isRunning) {
|
|
1581
|
-
throw new
|
|
1612
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
1582
1613
|
}
|
|
1583
1614
|
const handler = new this.Handler(this, method, path);
|
|
1584
1615
|
this.registerRequestHandler(handler);
|
|
@@ -1621,7 +1652,7 @@ var HttpInterceptorClient = class {
|
|
|
1621
1652
|
}
|
|
1622
1653
|
const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);
|
|
1623
1654
|
const response = HttpInterceptorWorker_default.createResponseFromDeclaration(request, responseDeclaration);
|
|
1624
|
-
if (this.
|
|
1655
|
+
if (this._saveRequests) {
|
|
1625
1656
|
const responseClone = response.clone();
|
|
1626
1657
|
const parsedResponse = await HttpInterceptorWorker_default.parseRawResponse(responseClone);
|
|
1627
1658
|
matchedHandler.saveInterceptedRequest(parsedRequest, parsedResponse);
|
|
@@ -1650,7 +1681,7 @@ var HttpInterceptorClient = class {
|
|
|
1650
1681
|
}
|
|
1651
1682
|
clear(options = {}) {
|
|
1652
1683
|
if (!this.isRunning) {
|
|
1653
|
-
throw new
|
|
1684
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
1654
1685
|
}
|
|
1655
1686
|
const clearResults = [];
|
|
1656
1687
|
for (const method of HTTP_METHODS) {
|
|
@@ -1855,17 +1886,17 @@ var InvalidWebSocketMessage = class extends Error {
|
|
|
1855
1886
|
};
|
|
1856
1887
|
var InvalidWebSocketMessage_default = InvalidWebSocketMessage;
|
|
1857
1888
|
|
|
1858
|
-
// src/webSocket/errors/
|
|
1859
|
-
var
|
|
1889
|
+
// src/webSocket/errors/NotRunningWebSocketHandlerError.ts
|
|
1890
|
+
var NotRunningWebSocketHandlerError = class extends Error {
|
|
1860
1891
|
static {
|
|
1861
|
-
__name(this, "
|
|
1892
|
+
__name(this, "NotRunningWebSocketHandlerError");
|
|
1862
1893
|
}
|
|
1863
1894
|
constructor() {
|
|
1864
1895
|
super("Web socket handler is not running.");
|
|
1865
|
-
this.name = "
|
|
1896
|
+
this.name = "NotRunningWebSocketHandlerError";
|
|
1866
1897
|
}
|
|
1867
1898
|
};
|
|
1868
|
-
var
|
|
1899
|
+
var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
|
|
1869
1900
|
|
|
1870
1901
|
// src/webSocket/WebSocketHandler.ts
|
|
1871
1902
|
var WebSocketHandler = class {
|
|
@@ -2043,7 +2074,7 @@ var WebSocketHandler = class {
|
|
|
2043
2074
|
}
|
|
2044
2075
|
sendMessage(message, sockets = this.sockets) {
|
|
2045
2076
|
if (!this.isRunning) {
|
|
2046
|
-
throw new
|
|
2077
|
+
throw new NotRunningWebSocketHandlerError_default();
|
|
2047
2078
|
}
|
|
2048
2079
|
const stringifiedMessage = JSON.stringify(message);
|
|
2049
2080
|
for (const socket of sockets) {
|
|
@@ -2150,17 +2181,18 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2150
2181
|
static {
|
|
2151
2182
|
__name(this, "RemoteHttpInterceptorWorker");
|
|
2152
2183
|
}
|
|
2153
|
-
type;
|
|
2154
2184
|
webSocketClient;
|
|
2155
2185
|
httpHandlers = /* @__PURE__ */ new Map();
|
|
2156
2186
|
constructor(options) {
|
|
2157
2187
|
super();
|
|
2158
|
-
this.type = options.type;
|
|
2159
2188
|
const webSocketServerURL = this.deriveWebSocketServerURL(options.serverURL);
|
|
2160
2189
|
this.webSocketClient = new WebSocketClient_default({
|
|
2161
2190
|
url: webSocketServerURL.toString()
|
|
2162
2191
|
});
|
|
2163
2192
|
}
|
|
2193
|
+
get type() {
|
|
2194
|
+
return "remote";
|
|
2195
|
+
}
|
|
2164
2196
|
deriveWebSocketServerURL(serverURL) {
|
|
2165
2197
|
const webSocketServerURL = new URL(serverURL);
|
|
2166
2198
|
webSocketServerURL.protocol = serverURL.protocol.replace(/^http(s)?:$/, "ws$1:");
|
|
@@ -2219,7 +2251,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2219
2251
|
}
|
|
2220
2252
|
async use(interceptor, method, rawURL, createResponse) {
|
|
2221
2253
|
if (!this.isRunning) {
|
|
2222
|
-
throw new
|
|
2254
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
2223
2255
|
}
|
|
2224
2256
|
const crypto = await importCrypto();
|
|
2225
2257
|
const url = new URL(rawURL);
|
|
@@ -2247,7 +2279,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2247
2279
|
}
|
|
2248
2280
|
async clearHandlers() {
|
|
2249
2281
|
if (!this.isRunning) {
|
|
2250
|
-
throw new
|
|
2282
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
2251
2283
|
}
|
|
2252
2284
|
this.httpHandlers.clear();
|
|
2253
2285
|
if (this.webSocketClient.isRunning) {
|
|
@@ -2256,7 +2288,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2256
2288
|
}
|
|
2257
2289
|
async clearInterceptorHandlers(interceptor) {
|
|
2258
2290
|
if (!this.isRunning) {
|
|
2259
|
-
throw new
|
|
2291
|
+
throw new NotRunningHttpInterceptorError_default();
|
|
2260
2292
|
}
|
|
2261
2293
|
for (const handler of this.httpHandlers.values()) {
|
|
2262
2294
|
if (handler.interceptor === interceptor) {
|
|
@@ -2364,14 +2396,10 @@ var LocalHttpInterceptor = class {
|
|
|
2364
2396
|
static {
|
|
2365
2397
|
__name(this, "LocalHttpInterceptor");
|
|
2366
2398
|
}
|
|
2367
|
-
type;
|
|
2368
2399
|
store = new HttpInterceptorStore_default();
|
|
2369
2400
|
client;
|
|
2370
2401
|
constructor(options) {
|
|
2371
|
-
this.type = options.type;
|
|
2372
2402
|
const baseURL = new URL(options.baseURL);
|
|
2373
|
-
validateURLProtocol_default(baseURL, SUPPORTED_BASE_URL_PROTOCOLS);
|
|
2374
|
-
excludeURLParams_default(baseURL);
|
|
2375
2403
|
const worker = this.store.getOrCreateLocalWorker({});
|
|
2376
2404
|
this.client = new HttpInterceptorClient_default({
|
|
2377
2405
|
worker,
|
|
@@ -2382,9 +2410,27 @@ var LocalHttpInterceptor = class {
|
|
|
2382
2410
|
saveRequests: options.saveRequests
|
|
2383
2411
|
});
|
|
2384
2412
|
}
|
|
2413
|
+
get type() {
|
|
2414
|
+
return "local";
|
|
2415
|
+
}
|
|
2385
2416
|
get baseURL() {
|
|
2386
2417
|
return this.client.baseURLAsString;
|
|
2387
2418
|
}
|
|
2419
|
+
set baseURL(baseURL) {
|
|
2420
|
+
this.client.baseURL = new URL(baseURL);
|
|
2421
|
+
}
|
|
2422
|
+
get saveRequests() {
|
|
2423
|
+
return this.client.saveRequests;
|
|
2424
|
+
}
|
|
2425
|
+
set saveRequests(saveRequests) {
|
|
2426
|
+
this.client.saveRequests = saveRequests;
|
|
2427
|
+
}
|
|
2428
|
+
get onUnhandledRequest() {
|
|
2429
|
+
return this.client.onUnhandledRequest;
|
|
2430
|
+
}
|
|
2431
|
+
set onUnhandledRequest(onUnhandledRequest) {
|
|
2432
|
+
this.client.onUnhandledRequest = onUnhandledRequest;
|
|
2433
|
+
}
|
|
2388
2434
|
get platform() {
|
|
2389
2435
|
return this.client.platform;
|
|
2390
2436
|
}
|
|
@@ -2439,14 +2485,10 @@ var RemoteHttpInterceptor = class {
|
|
|
2439
2485
|
static {
|
|
2440
2486
|
__name(this, "RemoteHttpInterceptor");
|
|
2441
2487
|
}
|
|
2442
|
-
type;
|
|
2443
2488
|
store = new HttpInterceptorStore_default();
|
|
2444
2489
|
client;
|
|
2445
2490
|
constructor(options) {
|
|
2446
|
-
this.type = options.type;
|
|
2447
2491
|
const baseURL = new URL(options.baseURL);
|
|
2448
|
-
validateURLProtocol_default(baseURL, SUPPORTED_BASE_URL_PROTOCOLS);
|
|
2449
|
-
excludeURLParams_default(baseURL);
|
|
2450
2492
|
const serverURL = new URL(baseURL.origin);
|
|
2451
2493
|
const worker = this.store.getOrCreateRemoteWorker({ serverURL });
|
|
2452
2494
|
this.client = new HttpInterceptorClient_default({
|
|
@@ -2458,9 +2500,27 @@ var RemoteHttpInterceptor = class {
|
|
|
2458
2500
|
saveRequests: options.saveRequests
|
|
2459
2501
|
});
|
|
2460
2502
|
}
|
|
2503
|
+
get type() {
|
|
2504
|
+
return "remote";
|
|
2505
|
+
}
|
|
2461
2506
|
get baseURL() {
|
|
2462
2507
|
return this.client.baseURLAsString;
|
|
2463
2508
|
}
|
|
2509
|
+
set baseURL(baseURL) {
|
|
2510
|
+
this.client.baseURL = new URL(baseURL);
|
|
2511
|
+
}
|
|
2512
|
+
get saveRequests() {
|
|
2513
|
+
return this.client.saveRequests;
|
|
2514
|
+
}
|
|
2515
|
+
set saveRequests(saveRequests) {
|
|
2516
|
+
this.client.saveRequests = saveRequests;
|
|
2517
|
+
}
|
|
2518
|
+
get onUnhandledRequest() {
|
|
2519
|
+
return this.client.onUnhandledRequest;
|
|
2520
|
+
}
|
|
2521
|
+
set onUnhandledRequest(onUnhandledRequest) {
|
|
2522
|
+
this.client.onUnhandledRequest = onUnhandledRequest;
|
|
2523
|
+
}
|
|
2464
2524
|
get platform() {
|
|
2465
2525
|
return this.client.platform;
|
|
2466
2526
|
}
|
|
@@ -2605,6 +2665,6 @@ var httpInterceptor = Object.freeze(new HttpInterceptorNamespace_default());
|
|
|
2605
2665
|
* Reply listeners are always present when notified in normal conditions. If they were not present, the request
|
|
2606
2666
|
* would reach a timeout and not be responded. The empty set serves as a fallback. */
|
|
2607
2667
|
|
|
2608
|
-
export { DisabledRequestSavingError_default as DisabledRequestSavingError, InvalidFormDataError_default as InvalidFormDataError, InvalidJSONError_default as InvalidJSONError,
|
|
2668
|
+
export { DisabledRequestSavingError_default as DisabledRequestSavingError, InvalidFormDataError_default as InvalidFormDataError, InvalidJSONError_default as InvalidJSONError, NotRunningHttpInterceptorError_default as NotRunningHttpInterceptorError, RunningHttpInterceptorError_default as RunningHttpInterceptorError, TimesCheckError_default as TimesCheckError, UnknownHttpInterceptorPlatformError_default as UnknownHttpInterceptorPlatformError, UnknownHttpInterceptorTypeError_default as UnknownHttpInterceptorTypeError, UnregisteredBrowserServiceWorkerError_default as UnregisteredBrowserServiceWorkerError, httpInterceptor };
|
|
2609
2669
|
//# sourceMappingURL=http.mjs.map
|
|
2610
2670
|
//# sourceMappingURL=http.mjs.map
|