@zimic/interceptor 1.1.2-canary.1 → 1.1.2-canary.2
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-CGILA3WO.mjs → chunk-BJTO5JO5.mjs} +3 -5
- package/dist/{chunk-CGILA3WO.mjs.map → chunk-BJTO5JO5.mjs.map} +1 -1
- package/dist/{chunk-RDMXECNU.mjs → chunk-CSKTIZSC.mjs} +20 -159
- package/dist/chunk-CSKTIZSC.mjs.map +1 -0
- package/dist/{chunk-WCQVDF3K.js → chunk-DGUM43GV.js} +2 -5
- package/dist/{chunk-WCQVDF3K.js.map → chunk-DGUM43GV.js.map} +1 -1
- package/dist/{chunk-QDNKVSEG.js → chunk-GM3MDVNT.js} +20 -159
- package/dist/chunk-GM3MDVNT.js.map +1 -0
- package/dist/cli.js +20 -31
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3 -14
- package/dist/cli.mjs.map +1 -1
- package/dist/http.js +61 -250
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +62 -251
- package/dist/http.mjs.map +1 -1
- package/dist/scripts/postinstall.js +2 -5
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/scripts/postinstall.mjs +1 -4
- package/dist/scripts/postinstall.mjs.map +1 -1
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-QDNKVSEG.js.map +0 -1
- package/dist/chunk-RDMXECNU.mjs.map +0 -1
package/dist/http.mjs
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import color2 from 'picocolors';
|
|
2
|
-
import { HttpHeaders, HttpSearchParams, HttpFormData
|
|
2
|
+
import { HTTP_METHODS, HttpHeaders, HttpSearchParams, HttpFormData } from '@zimic/http';
|
|
3
3
|
import { http, passthrough } from 'msw';
|
|
4
4
|
import * as mswBrowser from 'msw/browser';
|
|
5
5
|
import * as mswNode from 'msw/node';
|
|
6
6
|
import ClientSocket from 'isomorphic-ws';
|
|
7
7
|
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
|
|
11
8
|
// src/http/interceptor/errors/RunningHttpInterceptorError.ts
|
|
12
9
|
var RunningHttpInterceptorError = class extends Error {
|
|
13
|
-
static {
|
|
14
|
-
__name(this, "RunningHttpInterceptorError");
|
|
15
|
-
}
|
|
16
10
|
constructor(additionalMessage) {
|
|
17
11
|
super(`The interceptor is running. ${additionalMessage}`);
|
|
18
12
|
this.name = "RunningHttpInterceptorError";
|
|
@@ -22,9 +16,6 @@ var RunningHttpInterceptorError_default = RunningHttpInterceptorError;
|
|
|
22
16
|
|
|
23
17
|
// src/http/interceptor/errors/NotRunningHttpInterceptorError.ts
|
|
24
18
|
var NotRunningHttpInterceptorError = class extends Error {
|
|
25
|
-
static {
|
|
26
|
-
__name(this, "NotRunningHttpInterceptorError");
|
|
27
|
-
}
|
|
28
19
|
constructor() {
|
|
29
20
|
super("Interceptor is not running. Did you forget to call `await interceptor.start()`?");
|
|
30
21
|
this.name = "NotRunningHttpInterceptorError";
|
|
@@ -34,9 +25,6 @@ var NotRunningHttpInterceptorError_default = NotRunningHttpInterceptorError;
|
|
|
34
25
|
|
|
35
26
|
// src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts
|
|
36
27
|
var UnknownHttpInterceptorPlatformError = class extends Error {
|
|
37
|
-
static {
|
|
38
|
-
__name(this, "UnknownHttpInterceptorPlatformError");
|
|
39
|
-
}
|
|
40
28
|
/* istanbul ignore next -- @preserve
|
|
41
29
|
* Ignoring because checking unknown platforms is currently not possible in our Vitest setup. */
|
|
42
30
|
constructor() {
|
|
@@ -48,9 +36,6 @@ var UnknownHttpInterceptorPlatformError_default = UnknownHttpInterceptorPlatform
|
|
|
48
36
|
|
|
49
37
|
// src/http/interceptor/errors/UnknownHttpInterceptorTypeError.ts
|
|
50
38
|
var UnknownHttpInterceptorTypeError = class extends TypeError {
|
|
51
|
-
static {
|
|
52
|
-
__name(this, "UnknownHttpInterceptorTypeError");
|
|
53
|
-
}
|
|
54
39
|
constructor(unknownType) {
|
|
55
40
|
super(
|
|
56
41
|
`Unknown HTTP interceptor type: ${unknownType}. The available options are '${"local"}' and '${"remote"}'.`
|
|
@@ -62,9 +47,6 @@ var UnknownHttpInterceptorTypeError_default = UnknownHttpInterceptorTypeError;
|
|
|
62
47
|
|
|
63
48
|
// src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts
|
|
64
49
|
var RequestSavingSafeLimitExceededError = class extends TypeError {
|
|
65
|
-
static {
|
|
66
|
-
__name(this, "RequestSavingSafeLimitExceededError");
|
|
67
|
-
}
|
|
68
50
|
constructor(numberOfSavedRequests, safeLimit) {
|
|
69
51
|
super(
|
|
70
52
|
`The number of intercepted requests saved in memory (${numberOfSavedRequests}) exceeded the safe limit of ${safeLimit}. Did you forget to call \`interceptor.clear()\`?
|
|
@@ -82,9 +64,6 @@ var RequestSavingSafeLimitExceededError_default = RequestSavingSafeLimitExceeded
|
|
|
82
64
|
|
|
83
65
|
// src/http/interceptorWorker/errors/InvalidFormDataError.ts
|
|
84
66
|
var InvalidFormDataError = class extends SyntaxError {
|
|
85
|
-
static {
|
|
86
|
-
__name(this, "InvalidFormDataError");
|
|
87
|
-
}
|
|
88
67
|
constructor(value) {
|
|
89
68
|
super(`Failed to parse value as form data: ${value}`);
|
|
90
69
|
this.name = "InvalidFormDataError";
|
|
@@ -94,9 +73,6 @@ var InvalidFormDataError_default = InvalidFormDataError;
|
|
|
94
73
|
|
|
95
74
|
// src/http/interceptorWorker/errors/InvalidJSONError.ts
|
|
96
75
|
var InvalidJSONError = class extends SyntaxError {
|
|
97
|
-
static {
|
|
98
|
-
__name(this, "InvalidJSONError");
|
|
99
|
-
}
|
|
100
76
|
constructor(value) {
|
|
101
77
|
super(`Failed to parse value as JSON: ${value}`);
|
|
102
78
|
this.name = "InvalidJSONError";
|
|
@@ -109,9 +85,6 @@ var SERVICE_WORKER_FILE_NAME = "mockServiceWorker.js";
|
|
|
109
85
|
|
|
110
86
|
// src/http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError.ts
|
|
111
87
|
var UnregisteredBrowserServiceWorkerError = class extends Error {
|
|
112
|
-
static {
|
|
113
|
-
__name(this, "UnregisteredBrowserServiceWorkerError");
|
|
114
|
-
}
|
|
115
88
|
constructor() {
|
|
116
89
|
super(
|
|
117
90
|
`Failed to register the browser service worker: script '${window.location.origin}/${SERVICE_WORKER_FILE_NAME}' not found.
|
|
@@ -130,9 +103,6 @@ var UnregisteredBrowserServiceWorkerError_default = UnregisteredBrowserServiceWo
|
|
|
130
103
|
|
|
131
104
|
// src/http/requestHandler/errors/DisabledRequestSavingError.ts
|
|
132
105
|
var DisabledRequestSavingError = class extends TypeError {
|
|
133
|
-
static {
|
|
134
|
-
__name(this, "DisabledRequestSavingError");
|
|
135
|
-
}
|
|
136
106
|
constructor() {
|
|
137
107
|
super(
|
|
138
108
|
"Intercepted requests are not being saved. Did you forget to use `requestSaving.enabled: true` in your interceptor?\n\nLearn more: https://zimic.dev/docs/interceptor/api/create-http-interceptor"
|
|
@@ -142,46 +112,30 @@ var DisabledRequestSavingError = class extends TypeError {
|
|
|
142
112
|
};
|
|
143
113
|
var DisabledRequestSavingError_default = DisabledRequestSavingError;
|
|
144
114
|
|
|
145
|
-
// ../zimic-utils/dist/chunk-
|
|
146
|
-
var __defProp2 = Object.defineProperty;
|
|
147
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
148
|
-
|
|
149
|
-
// ../zimic-utils/dist/chunk-WC2DBWWR.mjs
|
|
115
|
+
// ../zimic-utils/dist/chunk-5UH44FTS.mjs
|
|
150
116
|
function isDefined(value) {
|
|
151
117
|
return value !== void 0 && value !== null;
|
|
152
118
|
}
|
|
153
|
-
__name(isDefined, "isDefined");
|
|
154
|
-
__name2(isDefined, "isDefined");
|
|
155
119
|
var isDefined_default = isDefined;
|
|
156
120
|
|
|
157
121
|
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
158
122
|
function isNonEmpty(value) {
|
|
159
123
|
return isDefined_default(value) && value !== "";
|
|
160
124
|
}
|
|
161
|
-
__name(isNonEmpty, "isNonEmpty");
|
|
162
|
-
__name2(isNonEmpty, "isNonEmpty");
|
|
163
125
|
var isNonEmpty_default = isNonEmpty;
|
|
164
126
|
|
|
165
127
|
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
166
128
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
167
129
|
let cachedImportResult;
|
|
168
|
-
return
|
|
130
|
+
return async function importModuleDynamicallyWithCache() {
|
|
169
131
|
cachedImportResult ??= await importModuleDynamically();
|
|
170
132
|
return cachedImportResult;
|
|
171
|
-
}
|
|
133
|
+
};
|
|
172
134
|
}
|
|
173
|
-
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
174
|
-
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
175
135
|
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
176
136
|
|
|
177
137
|
// ../zimic-utils/dist/logging/Logger.mjs
|
|
178
138
|
var Logger = class _Logger {
|
|
179
|
-
static {
|
|
180
|
-
__name(this, "_Logger");
|
|
181
|
-
}
|
|
182
|
-
static {
|
|
183
|
-
__name2(this, "Logger");
|
|
184
|
-
}
|
|
185
139
|
prefix;
|
|
186
140
|
raw;
|
|
187
141
|
constructor(options = {}) {
|
|
@@ -260,15 +214,12 @@ var Logger_default = Logger;
|
|
|
260
214
|
function isServerSide() {
|
|
261
215
|
return typeof process !== "undefined" && typeof process.versions !== "undefined";
|
|
262
216
|
}
|
|
263
|
-
__name(isServerSide, "isServerSide");
|
|
264
217
|
function isClientSide() {
|
|
265
218
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
266
219
|
}
|
|
267
|
-
__name(isClientSide, "isClientSide");
|
|
268
220
|
function isGlobalFileAvailable() {
|
|
269
221
|
return globalThis.File !== void 0;
|
|
270
222
|
}
|
|
271
|
-
__name(isGlobalFileAvailable, "isGlobalFileAvailable");
|
|
272
223
|
|
|
273
224
|
// src/utils/logging.ts
|
|
274
225
|
var logger = new Logger_default({
|
|
@@ -279,13 +230,12 @@ function stringifyJSONToLog(value) {
|
|
|
279
230
|
value,
|
|
280
231
|
(_key, value2) => {
|
|
281
232
|
return stringifyValueToLog(value2, {
|
|
282
|
-
fallback:
|
|
233
|
+
fallback: (value3) => value3
|
|
283
234
|
});
|
|
284
235
|
},
|
|
285
236
|
2
|
|
286
237
|
).replace(/\n\s*/g, " ").replace(/"(File { name: '.*?', type: '.*?', size: \d*? })"/g, "$1").replace(/"(Blob { type: '.*?', size: \d*? })"/g, "$1");
|
|
287
238
|
}
|
|
288
|
-
__name(stringifyJSONToLog, "stringifyJSONToLog");
|
|
289
239
|
function stringifyValueToLog(value, options = {}) {
|
|
290
240
|
const { fallback = stringifyJSONToLog, includeClassName } = options;
|
|
291
241
|
if (value === null || value === void 0 || typeof value !== "object") {
|
|
@@ -309,7 +259,6 @@ function stringifyValueToLog(value, options = {}) {
|
|
|
309
259
|
}
|
|
310
260
|
return fallback(value);
|
|
311
261
|
}
|
|
312
|
-
__name(stringifyValueToLog, "stringifyValueToLog");
|
|
313
262
|
var importUtil = createCachedDynamicImport_default(() => import('util'));
|
|
314
263
|
async function formatValueToLog(value, options = {}) {
|
|
315
264
|
if (isClientSide()) {
|
|
@@ -327,7 +276,6 @@ async function formatValueToLog(value, options = {}) {
|
|
|
327
276
|
sorted: true
|
|
328
277
|
});
|
|
329
278
|
}
|
|
330
|
-
__name(formatValueToLog, "formatValueToLog");
|
|
331
279
|
|
|
332
280
|
// src/http/requestHandler/errors/TimesCheckError.ts
|
|
333
281
|
function createMessageHeader({
|
|
@@ -355,7 +303,6 @@ Requests evaluated by this handler:
|
|
|
355
303
|
${color2.red("+ Received")}`
|
|
356
304
|
].filter((part) => part !== false).join("");
|
|
357
305
|
}
|
|
358
|
-
__name(createMessageHeader, "createMessageHeader");
|
|
359
306
|
function createMessageDiffs({ requestSaving, unmatchedRequestGroups }) {
|
|
360
307
|
if (!requestSaving.enabled) {
|
|
361
308
|
return "Tip: use `requestSaving.enabled: true` in your interceptor for more details about the unmatched requests.";
|
|
@@ -398,22 +345,16 @@ function createMessageDiffs({ requestSaving, unmatchedRequestGroups }) {
|
|
|
398
345
|
return messageParts.join("\n ");
|
|
399
346
|
}).join("\n\n");
|
|
400
347
|
}
|
|
401
|
-
__name(createMessageDiffs, "createMessageDiffs");
|
|
402
348
|
function createMessageFooter() {
|
|
403
349
|
return "Learn more: https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes";
|
|
404
350
|
}
|
|
405
|
-
__name(createMessageFooter, "createMessageFooter");
|
|
406
351
|
function createMessage(options) {
|
|
407
352
|
const messageHeader = createMessageHeader(options);
|
|
408
353
|
const messageDiffs = createMessageDiffs(options);
|
|
409
354
|
const messageFooter = createMessageFooter();
|
|
410
355
|
return [messageHeader, messageDiffs, messageFooter].filter(isNonEmpty_default).join("\n\n");
|
|
411
356
|
}
|
|
412
|
-
__name(createMessage, "createMessage");
|
|
413
357
|
var TimesCheckError = class extends TypeError {
|
|
414
|
-
static {
|
|
415
|
-
__name(this, "TimesCheckError");
|
|
416
|
-
}
|
|
417
358
|
constructor(options) {
|
|
418
359
|
const message = createMessage(options);
|
|
419
360
|
super(message);
|
|
@@ -423,7 +364,7 @@ var TimesCheckError = class extends TypeError {
|
|
|
423
364
|
};
|
|
424
365
|
var TimesCheckError_default = TimesCheckError;
|
|
425
366
|
|
|
426
|
-
// ../zimic-utils/dist/chunk-
|
|
367
|
+
// ../zimic-utils/dist/chunk-BSG74SVQ.mjs
|
|
427
368
|
async function blobEquals(blob, otherBlob) {
|
|
428
369
|
if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {
|
|
429
370
|
return false;
|
|
@@ -476,16 +417,12 @@ async function blobEquals(blob, otherBlob) {
|
|
|
476
417
|
otherReader.releaseLock();
|
|
477
418
|
}
|
|
478
419
|
}
|
|
479
|
-
__name(blobEquals, "blobEquals");
|
|
480
|
-
__name2(blobEquals, "blobEquals");
|
|
481
420
|
var blobEquals_default = blobEquals;
|
|
482
421
|
|
|
483
|
-
// ../zimic-utils/dist/chunk-
|
|
422
|
+
// ../zimic-utils/dist/chunk-LBZAJMTR.mjs
|
|
484
423
|
function isPrimitiveJSONValue(value) {
|
|
485
424
|
return typeof value !== "object" || value === null;
|
|
486
425
|
}
|
|
487
|
-
__name(isPrimitiveJSONValue, "isPrimitiveJSONValue");
|
|
488
|
-
__name2(isPrimitiveJSONValue, "isPrimitiveJSONValue");
|
|
489
426
|
|
|
490
427
|
// ../zimic-utils/dist/data/jsonContains.mjs
|
|
491
428
|
function jsonContains(value, otherValue) {
|
|
@@ -527,8 +464,6 @@ function jsonContains(value, otherValue) {
|
|
|
527
464
|
return jsonContains(subValue, subOtherValue);
|
|
528
465
|
});
|
|
529
466
|
}
|
|
530
|
-
__name(jsonContains, "jsonContains");
|
|
531
|
-
__name2(jsonContains, "jsonContains");
|
|
532
467
|
var jsonContains_default = jsonContains;
|
|
533
468
|
|
|
534
469
|
// ../zimic-utils/dist/data/jsonEquals.mjs
|
|
@@ -562,8 +497,6 @@ function jsonEquals(value, otherValue) {
|
|
|
562
497
|
return jsonEquals(subValue, subOtherValue);
|
|
563
498
|
});
|
|
564
499
|
}
|
|
565
|
-
__name(jsonEquals, "jsonEquals");
|
|
566
|
-
__name2(jsonEquals, "jsonEquals");
|
|
567
500
|
var jsonEquals_default = jsonEquals;
|
|
568
501
|
|
|
569
502
|
// src/utils/data.ts
|
|
@@ -581,11 +514,9 @@ async function convertReadableStreamToBlob(stream, options) {
|
|
|
581
514
|
}
|
|
582
515
|
return new Blob(chunks, options);
|
|
583
516
|
}
|
|
584
|
-
__name(convertReadableStreamToBlob, "convertReadableStreamToBlob");
|
|
585
517
|
function convertArrayBufferToBlob(buffer, options) {
|
|
586
518
|
return new Blob([buffer], options);
|
|
587
519
|
}
|
|
588
|
-
__name(convertArrayBufferToBlob, "convertArrayBufferToBlob");
|
|
589
520
|
function convertArrayBufferToBase64(buffer) {
|
|
590
521
|
if (isClientSide()) {
|
|
591
522
|
const bufferBytes = new Uint8Array(buffer);
|
|
@@ -600,7 +531,6 @@ function convertArrayBufferToBase64(buffer) {
|
|
|
600
531
|
return Buffer.from(buffer).toString("base64");
|
|
601
532
|
}
|
|
602
533
|
}
|
|
603
|
-
__name(convertArrayBufferToBase64, "convertArrayBufferToBase64");
|
|
604
534
|
function convertBase64ToArrayBuffer(base64Value) {
|
|
605
535
|
if (isClientSide()) {
|
|
606
536
|
const bufferAsString = atob(base64Value);
|
|
@@ -610,13 +540,9 @@ function convertBase64ToArrayBuffer(base64Value) {
|
|
|
610
540
|
return Buffer.from(base64Value, "base64");
|
|
611
541
|
}
|
|
612
542
|
}
|
|
613
|
-
__name(convertBase64ToArrayBuffer, "convertBase64ToArrayBuffer");
|
|
614
543
|
|
|
615
544
|
// src/http/requestHandler/errors/NoResponseDefinitionError.ts
|
|
616
545
|
var NoResponseDefinitionError = class extends TypeError {
|
|
617
|
-
static {
|
|
618
|
-
__name(this, "NoResponseDefinitionError");
|
|
619
|
-
}
|
|
620
546
|
constructor() {
|
|
621
547
|
super("Cannot generate a response without a definition. Use .respond() to set a response.");
|
|
622
548
|
this.name = "NoResponseDefinitionError";
|
|
@@ -626,9 +552,6 @@ var NoResponseDefinitionError_default = NoResponseDefinitionError;
|
|
|
626
552
|
|
|
627
553
|
// src/http/requestHandler/errors/TimesDeclarationPointer.ts
|
|
628
554
|
var TimesDeclarationPointer = class extends Error {
|
|
629
|
-
static {
|
|
630
|
-
__name(this, "TimesDeclarationPointer");
|
|
631
|
-
}
|
|
632
555
|
constructor(minNumberOfRequests, maxNumberOfRequests) {
|
|
633
556
|
super("declared at:");
|
|
634
557
|
this.name = `handler.times(${minNumberOfRequests}${maxNumberOfRequests === void 0 ? "" : `, ${maxNumberOfRequests}`})`;
|
|
@@ -648,9 +571,6 @@ var HttpRequestHandlerClient = class {
|
|
|
648
571
|
this.path = path;
|
|
649
572
|
this.handler = handler;
|
|
650
573
|
}
|
|
651
|
-
static {
|
|
652
|
-
__name(this, "HttpRequestHandlerClient");
|
|
653
|
-
}
|
|
654
574
|
restrictions = [];
|
|
655
575
|
limits = {
|
|
656
576
|
numberOfRequests: DEFAULT_NUMBER_OF_REQUEST_LIMITS
|
|
@@ -890,9 +810,6 @@ var HttpRequestHandlerClient_default = HttpRequestHandlerClient;
|
|
|
890
810
|
|
|
891
811
|
// src/http/requestHandler/LocalHttpRequestHandler.ts
|
|
892
812
|
var LocalHttpRequestHandler = class {
|
|
893
|
-
static {
|
|
894
|
-
__name(this, "LocalHttpRequestHandler");
|
|
895
|
-
}
|
|
896
813
|
type = "local";
|
|
897
814
|
client;
|
|
898
815
|
constructor(interceptor, method, path) {
|
|
@@ -939,37 +856,25 @@ var LocalHttpRequestHandler = class {
|
|
|
939
856
|
};
|
|
940
857
|
var LocalHttpRequestHandler_default = LocalHttpRequestHandler;
|
|
941
858
|
|
|
942
|
-
// ../zimic-utils/dist/chunk-
|
|
859
|
+
// ../zimic-utils/dist/chunk-46M3OXFU.mjs
|
|
943
860
|
function getExtraPatternsToEscape() {
|
|
944
861
|
return /([.(){}+$])/g;
|
|
945
862
|
}
|
|
946
|
-
__name(getExtraPatternsToEscape, "getExtraPatternsToEscape");
|
|
947
|
-
__name2(getExtraPatternsToEscape, "getExtraPatternsToEscape");
|
|
948
863
|
function getURIEncodedBackSlashPattern() {
|
|
949
864
|
return /%5C/g;
|
|
950
865
|
}
|
|
951
|
-
__name(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
952
|
-
__name2(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
953
866
|
function getPathParamPattern() {
|
|
954
867
|
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)/gu;
|
|
955
868
|
}
|
|
956
|
-
__name(getPathParamPattern, "getPathParamPattern");
|
|
957
|
-
__name2(getPathParamPattern, "getPathParamPattern");
|
|
958
869
|
function getRepeatingPathParamPattern() {
|
|
959
870
|
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\\+/gu;
|
|
960
871
|
}
|
|
961
|
-
__name(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
962
|
-
__name2(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
963
872
|
function getOptionalPathParamPattern() {
|
|
964
873
|
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\?(?<trailingSlash>\/)?/gu;
|
|
965
874
|
}
|
|
966
|
-
__name(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
967
|
-
__name2(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
968
875
|
function getOptionalRepeatingPathParamPattern() {
|
|
969
876
|
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\*(?<trailingSlash>\/)?/gu;
|
|
970
877
|
}
|
|
971
|
-
__name(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
972
|
-
__name2(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
973
878
|
function createParametrizedPathPattern(path) {
|
|
974
879
|
const replacedURL = encodeURI(path).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(
|
|
975
880
|
getOptionalRepeatingPathParamPattern(),
|
|
@@ -1018,8 +923,6 @@ function createParametrizedPathPattern(path) {
|
|
|
1018
923
|
});
|
|
1019
924
|
return new RegExp(`^/?${replacedURL}/?$`);
|
|
1020
925
|
}
|
|
1021
|
-
__name(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1022
|
-
__name2(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1023
926
|
var createParametrizedPathPattern_default = createParametrizedPathPattern;
|
|
1024
927
|
|
|
1025
928
|
// ../zimic-utils/dist/url/excludeURLParams.mjs
|
|
@@ -1030,18 +933,10 @@ function excludeURLParams(url) {
|
|
|
1030
933
|
url.password = "";
|
|
1031
934
|
return url;
|
|
1032
935
|
}
|
|
1033
|
-
__name(excludeURLParams, "excludeURLParams");
|
|
1034
|
-
__name2(excludeURLParams, "excludeURLParams");
|
|
1035
936
|
var excludeURLParams_default = excludeURLParams;
|
|
1036
937
|
|
|
1037
938
|
// ../zimic-utils/dist/url/validateURLProtocol.mjs
|
|
1038
939
|
var UnsupportedURLProtocolError = class extends TypeError {
|
|
1039
|
-
static {
|
|
1040
|
-
__name(this, "UnsupportedURLProtocolError");
|
|
1041
|
-
}
|
|
1042
|
-
static {
|
|
1043
|
-
__name2(this, "UnsupportedURLProtocolError");
|
|
1044
|
-
}
|
|
1045
940
|
constructor(protocol, availableProtocols) {
|
|
1046
941
|
super(
|
|
1047
942
|
`Unsupported URL protocol: '${protocol}'. The available options are ${availableProtocols.map((protocol2) => `'${protocol2}'`).join(", ")}`
|
|
@@ -1055,8 +950,6 @@ function validateURLProtocol(url, protocols) {
|
|
|
1055
950
|
throw new UnsupportedURLProtocolError(protocol, protocols);
|
|
1056
951
|
}
|
|
1057
952
|
}
|
|
1058
|
-
__name(validateURLProtocol, "validateURLProtocol");
|
|
1059
|
-
__name2(validateURLProtocol, "validateURLProtocol");
|
|
1060
953
|
var validateURLProtocol_default = validateURLProtocol;
|
|
1061
954
|
|
|
1062
955
|
// src/utils/arrays.ts
|
|
@@ -1066,12 +959,10 @@ function removeArrayIndex(array, index) {
|
|
|
1066
959
|
}
|
|
1067
960
|
return array;
|
|
1068
961
|
}
|
|
1069
|
-
__name(removeArrayIndex, "removeArrayIndex");
|
|
1070
962
|
function removeArrayElement(array, element) {
|
|
1071
963
|
const index = array.indexOf(element);
|
|
1072
964
|
return removeArrayIndex(array, index);
|
|
1073
965
|
}
|
|
1074
|
-
__name(removeArrayElement, "removeArrayElement");
|
|
1075
966
|
var HTTP_METHODS_WITH_RESPONSE_BODY = /* @__PURE__ */ new Set([
|
|
1076
967
|
"GET",
|
|
1077
968
|
"POST",
|
|
@@ -1083,7 +974,6 @@ var HTTP_METHODS_WITH_RESPONSE_BODY = /* @__PURE__ */ new Set([
|
|
|
1083
974
|
function methodCanHaveResponseBody(method) {
|
|
1084
975
|
return HTTP_METHODS_WITH_RESPONSE_BODY.has(method);
|
|
1085
976
|
}
|
|
1086
|
-
__name(methodCanHaveResponseBody, "methodCanHaveResponseBody");
|
|
1087
977
|
|
|
1088
978
|
// src/http/requestHandler/types/requests.ts
|
|
1089
979
|
var HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES = Object.freeze(
|
|
@@ -1117,9 +1007,6 @@ var DEFAULT_UNHANDLED_REQUEST_STRATEGY = Object.freeze({
|
|
|
1117
1007
|
|
|
1118
1008
|
// src/http/interceptorWorker/HttpInterceptorWorker.ts
|
|
1119
1009
|
var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
1120
|
-
static {
|
|
1121
|
-
__name(this, "HttpInterceptorWorker");
|
|
1122
|
-
}
|
|
1123
1010
|
platform = null;
|
|
1124
1011
|
isRunning = false;
|
|
1125
1012
|
startingPromise;
|
|
@@ -1438,9 +1325,6 @@ var HttpInterceptorWorker_default = HttpInterceptorWorker;
|
|
|
1438
1325
|
// src/http/requestHandler/RemoteHttpRequestHandler.ts
|
|
1439
1326
|
var PENDING_PROPERTIES = /* @__PURE__ */ new Set(["then"]);
|
|
1440
1327
|
var RemoteHttpRequestHandler = class {
|
|
1441
|
-
static {
|
|
1442
|
-
__name(this, "RemoteHttpRequestHandler");
|
|
1443
|
-
}
|
|
1444
1328
|
type = "remote";
|
|
1445
1329
|
client;
|
|
1446
1330
|
syncPromises = [];
|
|
@@ -1453,18 +1337,18 @@ var RemoteHttpRequestHandler = class {
|
|
|
1453
1337
|
}
|
|
1454
1338
|
createSyncedProxy() {
|
|
1455
1339
|
return new Proxy(this, {
|
|
1456
|
-
has:
|
|
1340
|
+
has: (target, property) => {
|
|
1457
1341
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1458
1342
|
return false;
|
|
1459
1343
|
}
|
|
1460
1344
|
return Reflect.has(target, property);
|
|
1461
|
-
},
|
|
1462
|
-
get:
|
|
1345
|
+
},
|
|
1346
|
+
get: (target, property) => {
|
|
1463
1347
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1464
1348
|
return void 0;
|
|
1465
1349
|
}
|
|
1466
1350
|
return Reflect.get(target, property);
|
|
1467
|
-
}
|
|
1351
|
+
}
|
|
1468
1352
|
});
|
|
1469
1353
|
}
|
|
1470
1354
|
isHiddenPropertyWhenSynced(property) {
|
|
@@ -1541,9 +1425,6 @@ var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
|
1541
1425
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1542
1426
|
var DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1e3;
|
|
1543
1427
|
var HttpInterceptorClient = class {
|
|
1544
|
-
static {
|
|
1545
|
-
__name(this, "HttpInterceptorClient");
|
|
1546
|
-
}
|
|
1547
1428
|
store;
|
|
1548
1429
|
_baseURL;
|
|
1549
1430
|
createWorker;
|
|
@@ -1777,12 +1658,6 @@ var HttpInterceptorClient_default = HttpInterceptorClient;
|
|
|
1777
1658
|
|
|
1778
1659
|
// ../zimic-utils/dist/url/validatePathParams.mjs
|
|
1779
1660
|
var DuplicatedPathParamError = class extends Error {
|
|
1780
|
-
static {
|
|
1781
|
-
__name(this, "DuplicatedPathParamError");
|
|
1782
|
-
}
|
|
1783
|
-
static {
|
|
1784
|
-
__name2(this, "DuplicatedPathParamError");
|
|
1785
|
-
}
|
|
1786
1661
|
constructor(path, paramName) {
|
|
1787
1662
|
super(
|
|
1788
1663
|
`The path parameter '${paramName}' appears more than once in '${path}'. This is not supported. Please make sure that each parameter is unique.`
|
|
@@ -1804,13 +1679,8 @@ function validatePathParams(path) {
|
|
|
1804
1679
|
uniqueParamNames.add(paramName);
|
|
1805
1680
|
}
|
|
1806
1681
|
}
|
|
1807
|
-
__name(validatePathParams, "validatePathParams");
|
|
1808
|
-
__name2(validatePathParams, "validatePathParams");
|
|
1809
1682
|
var validatePathParams_default = validatePathParams;
|
|
1810
1683
|
var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
1811
|
-
static {
|
|
1812
|
-
__name(this, "LocalHttpInterceptorWorker");
|
|
1813
|
-
}
|
|
1814
1684
|
internalWorker;
|
|
1815
1685
|
httpHandlersByMethod = {
|
|
1816
1686
|
GET: [],
|
|
@@ -1922,7 +1792,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1922
1792
|
method,
|
|
1923
1793
|
pathPattern: createParametrizedPathPattern_default(path),
|
|
1924
1794
|
interceptor,
|
|
1925
|
-
createResponse:
|
|
1795
|
+
createResponse: async (context) => {
|
|
1926
1796
|
const request = context.request;
|
|
1927
1797
|
const requestClone = request.clone();
|
|
1928
1798
|
let response = null;
|
|
@@ -1942,7 +1812,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1942
1812
|
});
|
|
1943
1813
|
}
|
|
1944
1814
|
return response;
|
|
1945
|
-
}
|
|
1815
|
+
}
|
|
1946
1816
|
};
|
|
1947
1817
|
methodHandlers.push(handler);
|
|
1948
1818
|
}
|
|
@@ -2026,7 +1896,6 @@ function deserializeRequest(serializedRequest) {
|
|
|
2026
1896
|
body: deserializedBody
|
|
2027
1897
|
});
|
|
2028
1898
|
}
|
|
2029
|
-
__name(deserializeRequest, "deserializeRequest");
|
|
2030
1899
|
async function serializeResponse(response) {
|
|
2031
1900
|
const responseClone = response.clone();
|
|
2032
1901
|
const serializedBody = responseClone.body ? convertArrayBufferToBase64(await responseClone.arrayBuffer()) : null;
|
|
@@ -2037,7 +1906,6 @@ async function serializeResponse(response) {
|
|
|
2037
1906
|
body: serializedBody
|
|
2038
1907
|
};
|
|
2039
1908
|
}
|
|
2040
|
-
__name(serializeResponse, "serializeResponse");
|
|
2041
1909
|
|
|
2042
1910
|
// src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts
|
|
2043
1911
|
var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
@@ -2046,49 +1914,31 @@ var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
|
2046
1914
|
this.event = event;
|
|
2047
1915
|
this.name = "UnauthorizedWebSocketConnectionError";
|
|
2048
1916
|
}
|
|
2049
|
-
static {
|
|
2050
|
-
__name(this, "UnauthorizedWebSocketConnectionError");
|
|
2051
|
-
}
|
|
2052
1917
|
};
|
|
2053
1918
|
var UnauthorizedWebSocketConnectionError_default = UnauthorizedWebSocketConnectionError;
|
|
2054
1919
|
|
|
2055
1920
|
// src/utils/webSocket.ts
|
|
2056
1921
|
var WebSocketTimeoutError = class extends Error {
|
|
2057
|
-
static {
|
|
2058
|
-
__name(this, "WebSocketTimeoutError");
|
|
2059
|
-
}
|
|
2060
1922
|
};
|
|
2061
1923
|
var WebSocketOpenTimeoutError = class extends WebSocketTimeoutError {
|
|
2062
|
-
static {
|
|
2063
|
-
__name(this, "WebSocketOpenTimeoutError");
|
|
2064
|
-
}
|
|
2065
1924
|
constructor(reachedTimeout) {
|
|
2066
1925
|
super(`Web socket open timed out after ${reachedTimeout}ms.`);
|
|
2067
1926
|
this.name = "WebSocketOpenTimeout";
|
|
2068
1927
|
}
|
|
2069
1928
|
};
|
|
2070
1929
|
var WebSocketMessageTimeoutError = class extends WebSocketTimeoutError {
|
|
2071
|
-
static {
|
|
2072
|
-
__name(this, "WebSocketMessageTimeoutError");
|
|
2073
|
-
}
|
|
2074
1930
|
constructor(reachedTimeout) {
|
|
2075
1931
|
super(`Web socket message timed out after ${reachedTimeout}ms.`);
|
|
2076
1932
|
this.name = "WebSocketMessageTimeout";
|
|
2077
1933
|
}
|
|
2078
1934
|
};
|
|
2079
1935
|
var WebSocketMessageAbortError = class extends WebSocketTimeoutError {
|
|
2080
|
-
static {
|
|
2081
|
-
__name(this, "WebSocketMessageAbortError");
|
|
2082
|
-
}
|
|
2083
1936
|
constructor() {
|
|
2084
1937
|
super("Web socket message was aborted.");
|
|
2085
1938
|
this.name = "WebSocketMessageAbortError";
|
|
2086
1939
|
}
|
|
2087
1940
|
};
|
|
2088
1941
|
var WebSocketCloseTimeoutError = class extends WebSocketTimeoutError {
|
|
2089
|
-
static {
|
|
2090
|
-
__name(this, "WebSocketCloseTimeoutError");
|
|
2091
|
-
}
|
|
2092
1942
|
constructor(reachedTimeout) {
|
|
2093
1943
|
super(`Web socket close timed out after ${reachedTimeout}ms.`);
|
|
2094
1944
|
this.name = "WebSocketCloseTimeout";
|
|
@@ -2109,12 +1959,10 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2109
1959
|
socket.removeEventListener("error", handleOpenError);
|
|
2110
1960
|
socket.removeEventListener("close", handleClose);
|
|
2111
1961
|
}
|
|
2112
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2113
1962
|
function handleOpenError(error) {
|
|
2114
1963
|
removeAllSocketListeners();
|
|
2115
1964
|
reject(error);
|
|
2116
1965
|
}
|
|
2117
|
-
__name(handleOpenError, "handleOpenError");
|
|
2118
1966
|
function handleClose(event) {
|
|
2119
1967
|
const isUnauthorized = event.code === 1008;
|
|
2120
1968
|
if (isUnauthorized) {
|
|
@@ -2124,7 +1972,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2124
1972
|
handleOpenError(event);
|
|
2125
1973
|
}
|
|
2126
1974
|
}
|
|
2127
|
-
__name(handleClose, "handleClose");
|
|
2128
1975
|
const openTimeout = setTimeout(() => {
|
|
2129
1976
|
const timeoutError = new WebSocketOpenTimeoutError(timeoutDuration);
|
|
2130
1977
|
handleOpenError(timeoutError);
|
|
@@ -2134,14 +1981,12 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2134
1981
|
clearTimeout(openTimeout);
|
|
2135
1982
|
resolve();
|
|
2136
1983
|
}
|
|
2137
|
-
__name(handleOpenSuccess, "handleOpenSuccess");
|
|
2138
1984
|
function handleSocketMessage(message) {
|
|
2139
1985
|
const hasValidAuth = message.data === "socket:auth:valid";
|
|
2140
1986
|
if (hasValidAuth) {
|
|
2141
1987
|
handleOpenSuccess();
|
|
2142
1988
|
}
|
|
2143
1989
|
}
|
|
2144
|
-
__name(handleSocketMessage, "handleSocketMessage");
|
|
2145
1990
|
if (waitForAuthentication) {
|
|
2146
1991
|
socket.addEventListener("message", handleSocketMessage);
|
|
2147
1992
|
} else {
|
|
@@ -2151,7 +1996,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2151
1996
|
socket.addEventListener("close", handleClose);
|
|
2152
1997
|
});
|
|
2153
1998
|
}
|
|
2154
|
-
__name(waitForOpenClientSocket, "waitForOpenClientSocket");
|
|
2155
1999
|
async function closeClientSocket(socket, options = {}) {
|
|
2156
2000
|
const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;
|
|
2157
2001
|
const isAlreadyClosed = socket.readyState === socket.CLOSED;
|
|
@@ -2163,12 +2007,10 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2163
2007
|
socket.removeEventListener("error", handleError);
|
|
2164
2008
|
socket.removeEventListener("close", handleClose);
|
|
2165
2009
|
}
|
|
2166
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2167
2010
|
function handleError(error) {
|
|
2168
2011
|
removeAllSocketListeners();
|
|
2169
2012
|
reject(error);
|
|
2170
2013
|
}
|
|
2171
|
-
__name(handleError, "handleError");
|
|
2172
2014
|
const closeTimeout = setTimeout(() => {
|
|
2173
2015
|
const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);
|
|
2174
2016
|
handleError(timeoutError);
|
|
@@ -2178,22 +2020,17 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2178
2020
|
clearTimeout(closeTimeout);
|
|
2179
2021
|
resolve();
|
|
2180
2022
|
}
|
|
2181
|
-
__name(handleClose, "handleClose");
|
|
2182
2023
|
socket.addEventListener("error", handleError);
|
|
2183
2024
|
socket.addEventListener("close", handleClose);
|
|
2184
2025
|
socket.close();
|
|
2185
2026
|
});
|
|
2186
2027
|
}
|
|
2187
|
-
__name(closeClientSocket, "closeClientSocket");
|
|
2188
2028
|
|
|
2189
2029
|
// src/webSocket/constants.ts
|
|
2190
2030
|
var WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(["socket:auth:valid"]);
|
|
2191
2031
|
|
|
2192
2032
|
// src/webSocket/errors/InvalidWebSocketMessage.ts
|
|
2193
2033
|
var InvalidWebSocketMessage = class extends Error {
|
|
2194
|
-
static {
|
|
2195
|
-
__name(this, "InvalidWebSocketMessage");
|
|
2196
|
-
}
|
|
2197
2034
|
constructor(message) {
|
|
2198
2035
|
super(`Web socket message is invalid and could not be parsed: ${message}`);
|
|
2199
2036
|
this.name = "InvalidWebSocketMessage";
|
|
@@ -2203,9 +2040,6 @@ var InvalidWebSocketMessage_default = InvalidWebSocketMessage;
|
|
|
2203
2040
|
|
|
2204
2041
|
// src/webSocket/errors/NotRunningWebSocketHandlerError.ts
|
|
2205
2042
|
var NotRunningWebSocketHandlerError = class extends Error {
|
|
2206
|
-
static {
|
|
2207
|
-
__name(this, "NotRunningWebSocketHandlerError");
|
|
2208
|
-
}
|
|
2209
2043
|
constructor() {
|
|
2210
2044
|
super("Web socket handler is not running.");
|
|
2211
2045
|
this.name = "NotRunningWebSocketHandlerError";
|
|
@@ -2215,9 +2049,6 @@ var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
|
|
|
2215
2049
|
|
|
2216
2050
|
// src/webSocket/WebSocketHandler.ts
|
|
2217
2051
|
var WebSocketHandler = class {
|
|
2218
|
-
static {
|
|
2219
|
-
__name(this, "WebSocketHandler");
|
|
2220
|
-
}
|
|
2221
2052
|
sockets = /* @__PURE__ */ new Set();
|
|
2222
2053
|
socketTimeout;
|
|
2223
2054
|
messageTimeout;
|
|
@@ -2234,26 +2065,25 @@ var WebSocketHandler = class {
|
|
|
2234
2065
|
timeout: this.socketTimeout,
|
|
2235
2066
|
waitForAuthentication: options.waitForAuthentication
|
|
2236
2067
|
});
|
|
2237
|
-
const handleSocketMessage =
|
|
2068
|
+
const handleSocketMessage = async (rawMessage) => {
|
|
2238
2069
|
await this.handleSocketMessage(socket, rawMessage);
|
|
2239
|
-
}
|
|
2070
|
+
};
|
|
2240
2071
|
socket.addEventListener("message", handleSocketMessage);
|
|
2241
2072
|
await openPromise;
|
|
2242
2073
|
function handleSocketError(error) {
|
|
2243
2074
|
console.error(error);
|
|
2244
2075
|
}
|
|
2245
|
-
__name(handleSocketError, "handleSocketError");
|
|
2246
2076
|
socket.addEventListener("error", handleSocketError);
|
|
2247
|
-
const handleSocketClose =
|
|
2077
|
+
const handleSocketClose = () => {
|
|
2248
2078
|
socket.removeEventListener("message", handleSocketMessage);
|
|
2249
2079
|
socket.removeEventListener("close", handleSocketClose);
|
|
2250
2080
|
socket.removeEventListener("error", handleSocketError);
|
|
2251
2081
|
this.removeSocket(socket);
|
|
2252
|
-
}
|
|
2082
|
+
};
|
|
2253
2083
|
socket.addEventListener("close", handleSocketClose);
|
|
2254
2084
|
this.sockets.add(socket);
|
|
2255
2085
|
}
|
|
2256
|
-
handleSocketMessage =
|
|
2086
|
+
handleSocketMessage = async (socket, rawMessage) => {
|
|
2257
2087
|
try {
|
|
2258
2088
|
if (this.isControlMessageData(rawMessage.data)) {
|
|
2259
2089
|
return;
|
|
@@ -2264,7 +2094,7 @@ var WebSocketHandler = class {
|
|
|
2264
2094
|
} catch (error) {
|
|
2265
2095
|
console.error(error);
|
|
2266
2096
|
}
|
|
2267
|
-
}
|
|
2097
|
+
};
|
|
2268
2098
|
isControlMessageData(messageData) {
|
|
2269
2099
|
return typeof messageData === "string" && WEB_SOCKET_CONTROL_MESSAGES.includes(messageData);
|
|
2270
2100
|
}
|
|
@@ -2465,9 +2295,6 @@ var WebSocketHandler_default = WebSocketHandler;
|
|
|
2465
2295
|
// src/webSocket/WebSocketClient.ts
|
|
2466
2296
|
var SUPPORTED_WEB_SOCKET_PROTOCOLS = ["ws", "wss"];
|
|
2467
2297
|
var WebSocketClient = class extends WebSocketHandler_default {
|
|
2468
|
-
static {
|
|
2469
|
-
__name(this, "WebSocketClient");
|
|
2470
|
-
}
|
|
2471
2298
|
url;
|
|
2472
2299
|
socket;
|
|
2473
2300
|
constructor(options) {
|
|
@@ -2503,9 +2330,6 @@ var WebSocketClient_default = WebSocketClient;
|
|
|
2503
2330
|
|
|
2504
2331
|
// src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts
|
|
2505
2332
|
var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
2506
|
-
static {
|
|
2507
|
-
__name(this, "RemoteHttpInterceptorWorker");
|
|
2508
|
-
}
|
|
2509
2333
|
httpHandlers = /* @__PURE__ */ new Map();
|
|
2510
2334
|
webSocketClient;
|
|
2511
2335
|
auth;
|
|
@@ -2536,7 +2360,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2536
2360
|
this.isRunning = true;
|
|
2537
2361
|
});
|
|
2538
2362
|
}
|
|
2539
|
-
createResponse =
|
|
2363
|
+
createResponse = async (message) => {
|
|
2540
2364
|
const { handlerId, request: serializedRequest } = message.data;
|
|
2541
2365
|
const handler = this.httpHandlers.get(handlerId);
|
|
2542
2366
|
const request = deserializeRequest(serializedRequest);
|
|
@@ -2552,14 +2376,14 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2552
2376
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2553
2377
|
await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2554
2378
|
return { response: null };
|
|
2555
|
-
}
|
|
2556
|
-
handleUnhandledServerRequest =
|
|
2379
|
+
};
|
|
2380
|
+
handleUnhandledServerRequest = async (message) => {
|
|
2557
2381
|
const { request: serializedRequest } = message.data;
|
|
2558
2382
|
const request = deserializeRequest(serializedRequest);
|
|
2559
2383
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2560
2384
|
const { wasLogged } = await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2561
2385
|
return { wasLogged };
|
|
2562
|
-
}
|
|
2386
|
+
};
|
|
2563
2387
|
readPlatform() {
|
|
2564
2388
|
if (isServerSide()) {
|
|
2565
2389
|
return "node";
|
|
@@ -2646,13 +2470,9 @@ function createHttpInterceptorWorker(options) {
|
|
|
2646
2470
|
return new RemoteHttpInterceptorWorker_default(options);
|
|
2647
2471
|
}
|
|
2648
2472
|
}
|
|
2649
|
-
__name(createHttpInterceptorWorker, "createHttpInterceptorWorker");
|
|
2650
2473
|
|
|
2651
2474
|
// src/http/interceptor/HttpInterceptorStore.ts
|
|
2652
2475
|
var HttpInterceptorStore = class _HttpInterceptorStore {
|
|
2653
|
-
static {
|
|
2654
|
-
__name(this, "HttpInterceptorStore");
|
|
2655
|
-
}
|
|
2656
2476
|
static _localWorker;
|
|
2657
2477
|
static runningLocalInterceptors = /* @__PURE__ */ new Set();
|
|
2658
2478
|
static remoteWorkers = /* @__PURE__ */ new Map();
|
|
@@ -2729,9 +2549,6 @@ var HttpInterceptorStore_default = HttpInterceptorStore;
|
|
|
2729
2549
|
|
|
2730
2550
|
// src/http/interceptor/LocalHttpInterceptor.ts
|
|
2731
2551
|
var LocalHttpInterceptor = class {
|
|
2732
|
-
static {
|
|
2733
|
-
__name(this, "LocalHttpInterceptor");
|
|
2734
|
-
}
|
|
2735
2552
|
store = new HttpInterceptorStore_default();
|
|
2736
2553
|
client;
|
|
2737
2554
|
constructor(options) {
|
|
@@ -2739,12 +2556,12 @@ var LocalHttpInterceptor = class {
|
|
|
2739
2556
|
this.client = new HttpInterceptorClient_default({
|
|
2740
2557
|
store: this.store,
|
|
2741
2558
|
baseURL,
|
|
2742
|
-
createWorker:
|
|
2559
|
+
createWorker: () => {
|
|
2743
2560
|
return this.store.getOrCreateLocalWorker({});
|
|
2744
|
-
},
|
|
2745
|
-
deleteWorker:
|
|
2561
|
+
},
|
|
2562
|
+
deleteWorker: () => {
|
|
2746
2563
|
this.store.deleteLocalWorker();
|
|
2747
|
-
},
|
|
2564
|
+
},
|
|
2748
2565
|
Handler: LocalHttpRequestHandler_default,
|
|
2749
2566
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2750
2567
|
requestSaving: options.requestSaving
|
|
@@ -2790,27 +2607,27 @@ var LocalHttpInterceptor = class {
|
|
|
2790
2607
|
this.clear();
|
|
2791
2608
|
await this.client.stop();
|
|
2792
2609
|
}
|
|
2793
|
-
get =
|
|
2610
|
+
get = (path) => {
|
|
2794
2611
|
return this.client.get(path);
|
|
2795
|
-
}
|
|
2796
|
-
post =
|
|
2612
|
+
};
|
|
2613
|
+
post = (path) => {
|
|
2797
2614
|
return this.client.post(path);
|
|
2798
|
-
}
|
|
2799
|
-
patch =
|
|
2615
|
+
};
|
|
2616
|
+
patch = (path) => {
|
|
2800
2617
|
return this.client.patch(path);
|
|
2801
|
-
}
|
|
2802
|
-
put =
|
|
2618
|
+
};
|
|
2619
|
+
put = (path) => {
|
|
2803
2620
|
return this.client.put(path);
|
|
2804
|
-
}
|
|
2805
|
-
delete =
|
|
2621
|
+
};
|
|
2622
|
+
delete = (path) => {
|
|
2806
2623
|
return this.client.delete(path);
|
|
2807
|
-
}
|
|
2808
|
-
head =
|
|
2624
|
+
};
|
|
2625
|
+
head = (path) => {
|
|
2809
2626
|
return this.client.head(path);
|
|
2810
|
-
}
|
|
2811
|
-
options =
|
|
2627
|
+
};
|
|
2628
|
+
options = (path) => {
|
|
2812
2629
|
return this.client.options(path);
|
|
2813
|
-
}
|
|
2630
|
+
};
|
|
2814
2631
|
checkTimes() {
|
|
2815
2632
|
this.client.checkTimes();
|
|
2816
2633
|
}
|
|
@@ -2822,9 +2639,6 @@ var LocalHttpInterceptor_default = LocalHttpInterceptor;
|
|
|
2822
2639
|
|
|
2823
2640
|
// src/http/interceptor/RemoteHttpInterceptor.ts
|
|
2824
2641
|
var RemoteHttpInterceptor = class {
|
|
2825
|
-
static {
|
|
2826
|
-
__name(this, "RemoteHttpInterceptor");
|
|
2827
|
-
}
|
|
2828
2642
|
store = new HttpInterceptorStore_default();
|
|
2829
2643
|
client;
|
|
2830
2644
|
_auth;
|
|
@@ -2834,15 +2648,15 @@ var RemoteHttpInterceptor = class {
|
|
|
2834
2648
|
this.client = new HttpInterceptorClient_default({
|
|
2835
2649
|
store: this.store,
|
|
2836
2650
|
baseURL,
|
|
2837
|
-
createWorker:
|
|
2651
|
+
createWorker: () => {
|
|
2838
2652
|
return this.store.getOrCreateRemoteWorker({
|
|
2839
2653
|
serverURL: new URL(baseURL.origin),
|
|
2840
2654
|
auth: this._auth
|
|
2841
2655
|
});
|
|
2842
|
-
},
|
|
2843
|
-
deleteWorker:
|
|
2656
|
+
},
|
|
2657
|
+
deleteWorker: () => {
|
|
2844
2658
|
this.store.deleteRemoteWorker(baseURL, { auth: options.auth });
|
|
2845
|
-
},
|
|
2659
|
+
},
|
|
2846
2660
|
Handler: RemoteHttpRequestHandler_default,
|
|
2847
2661
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2848
2662
|
requestSaving: options.requestSaving
|
|
@@ -2876,12 +2690,12 @@ var RemoteHttpInterceptor = class {
|
|
|
2876
2690
|
return;
|
|
2877
2691
|
}
|
|
2878
2692
|
this._auth = new Proxy(auth, {
|
|
2879
|
-
set:
|
|
2693
|
+
set: (target, property, value) => {
|
|
2880
2694
|
if (this.isRunning) {
|
|
2881
2695
|
throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
|
|
2882
2696
|
}
|
|
2883
2697
|
return Reflect.set(target, property, value);
|
|
2884
|
-
}
|
|
2698
|
+
}
|
|
2885
2699
|
});
|
|
2886
2700
|
}
|
|
2887
2701
|
get onUnhandledRequest() {
|
|
@@ -2909,27 +2723,27 @@ var RemoteHttpInterceptor = class {
|
|
|
2909
2723
|
await this.clear();
|
|
2910
2724
|
await this.client.stop();
|
|
2911
2725
|
}
|
|
2912
|
-
get =
|
|
2726
|
+
get = (path) => {
|
|
2913
2727
|
return this.client.get(path);
|
|
2914
|
-
}
|
|
2915
|
-
post =
|
|
2728
|
+
};
|
|
2729
|
+
post = (path) => {
|
|
2916
2730
|
return this.client.post(path);
|
|
2917
|
-
}
|
|
2918
|
-
patch =
|
|
2731
|
+
};
|
|
2732
|
+
patch = (path) => {
|
|
2919
2733
|
return this.client.patch(path);
|
|
2920
|
-
}
|
|
2921
|
-
put =
|
|
2734
|
+
};
|
|
2735
|
+
put = (path) => {
|
|
2922
2736
|
return this.client.put(path);
|
|
2923
|
-
}
|
|
2924
|
-
delete =
|
|
2737
|
+
};
|
|
2738
|
+
delete = (path) => {
|
|
2925
2739
|
return this.client.delete(path);
|
|
2926
|
-
}
|
|
2927
|
-
head =
|
|
2740
|
+
};
|
|
2741
|
+
head = (path) => {
|
|
2928
2742
|
return this.client.head(path);
|
|
2929
|
-
}
|
|
2930
|
-
options =
|
|
2743
|
+
};
|
|
2744
|
+
options = (path) => {
|
|
2931
2745
|
return this.client.options(path);
|
|
2932
|
-
}
|
|
2746
|
+
};
|
|
2933
2747
|
checkTimes() {
|
|
2934
2748
|
return new Promise((resolve, reject) => {
|
|
2935
2749
|
try {
|
|
@@ -2955,11 +2769,9 @@ var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
|
|
|
2955
2769
|
function isLocalHttpInterceptorOptions(options) {
|
|
2956
2770
|
return options.type === void 0 || options.type === "local";
|
|
2957
2771
|
}
|
|
2958
|
-
__name(isLocalHttpInterceptorOptions, "isLocalHttpInterceptorOptions");
|
|
2959
2772
|
function isRemoteHttpInterceptorOptions(options) {
|
|
2960
2773
|
return options.type === "remote";
|
|
2961
2774
|
}
|
|
2962
|
-
__name(isRemoteHttpInterceptorOptions, "isRemoteHttpInterceptorOptions");
|
|
2963
2775
|
function createHttpInterceptor(options) {
|
|
2964
2776
|
const type = options.type;
|
|
2965
2777
|
if (isLocalHttpInterceptorOptions(options)) {
|
|
@@ -2969,7 +2781,6 @@ function createHttpInterceptor(options) {
|
|
|
2969
2781
|
}
|
|
2970
2782
|
throw new UnknownHttpInterceptorTypeError_default(type);
|
|
2971
2783
|
}
|
|
2972
|
-
__name(createHttpInterceptor, "createHttpInterceptor");
|
|
2973
2784
|
/* istanbul ignore next -- @preserve
|
|
2974
2785
|
* Ignoring because there will always be a handler for the given method and path at this point. */
|
|
2975
2786
|
/* istanbul ignore else -- @preserve */
|