@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.js
CHANGED
|
@@ -32,14 +32,8 @@ var mswBrowser__namespace = /*#__PURE__*/_interopNamespace(mswBrowser);
|
|
|
32
32
|
var mswNode__namespace = /*#__PURE__*/_interopNamespace(mswNode);
|
|
33
33
|
var ClientSocket__default = /*#__PURE__*/_interopDefault(ClientSocket);
|
|
34
34
|
|
|
35
|
-
var __defProp = Object.defineProperty;
|
|
36
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
37
|
-
|
|
38
35
|
// src/http/interceptor/errors/RunningHttpInterceptorError.ts
|
|
39
36
|
var RunningHttpInterceptorError = class extends Error {
|
|
40
|
-
static {
|
|
41
|
-
__name(this, "RunningHttpInterceptorError");
|
|
42
|
-
}
|
|
43
37
|
constructor(additionalMessage) {
|
|
44
38
|
super(`The interceptor is running. ${additionalMessage}`);
|
|
45
39
|
this.name = "RunningHttpInterceptorError";
|
|
@@ -49,9 +43,6 @@ var RunningHttpInterceptorError_default = RunningHttpInterceptorError;
|
|
|
49
43
|
|
|
50
44
|
// src/http/interceptor/errors/NotRunningHttpInterceptorError.ts
|
|
51
45
|
var NotRunningHttpInterceptorError = class extends Error {
|
|
52
|
-
static {
|
|
53
|
-
__name(this, "NotRunningHttpInterceptorError");
|
|
54
|
-
}
|
|
55
46
|
constructor() {
|
|
56
47
|
super("Interceptor is not running. Did you forget to call `await interceptor.start()`?");
|
|
57
48
|
this.name = "NotRunningHttpInterceptorError";
|
|
@@ -61,9 +52,6 @@ var NotRunningHttpInterceptorError_default = NotRunningHttpInterceptorError;
|
|
|
61
52
|
|
|
62
53
|
// src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts
|
|
63
54
|
var UnknownHttpInterceptorPlatformError = class extends Error {
|
|
64
|
-
static {
|
|
65
|
-
__name(this, "UnknownHttpInterceptorPlatformError");
|
|
66
|
-
}
|
|
67
55
|
/* istanbul ignore next -- @preserve
|
|
68
56
|
* Ignoring because checking unknown platforms is currently not possible in our Vitest setup. */
|
|
69
57
|
constructor() {
|
|
@@ -75,9 +63,6 @@ var UnknownHttpInterceptorPlatformError_default = UnknownHttpInterceptorPlatform
|
|
|
75
63
|
|
|
76
64
|
// src/http/interceptor/errors/UnknownHttpInterceptorTypeError.ts
|
|
77
65
|
var UnknownHttpInterceptorTypeError = class extends TypeError {
|
|
78
|
-
static {
|
|
79
|
-
__name(this, "UnknownHttpInterceptorTypeError");
|
|
80
|
-
}
|
|
81
66
|
constructor(unknownType) {
|
|
82
67
|
super(
|
|
83
68
|
`Unknown HTTP interceptor type: ${unknownType}. The available options are '${"local"}' and '${"remote"}'.`
|
|
@@ -89,9 +74,6 @@ var UnknownHttpInterceptorTypeError_default = UnknownHttpInterceptorTypeError;
|
|
|
89
74
|
|
|
90
75
|
// src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts
|
|
91
76
|
var RequestSavingSafeLimitExceededError = class extends TypeError {
|
|
92
|
-
static {
|
|
93
|
-
__name(this, "RequestSavingSafeLimitExceededError");
|
|
94
|
-
}
|
|
95
77
|
constructor(numberOfSavedRequests, safeLimit) {
|
|
96
78
|
super(
|
|
97
79
|
`The number of intercepted requests saved in memory (${numberOfSavedRequests}) exceeded the safe limit of ${safeLimit}. Did you forget to call \`interceptor.clear()\`?
|
|
@@ -109,9 +91,6 @@ var RequestSavingSafeLimitExceededError_default = RequestSavingSafeLimitExceeded
|
|
|
109
91
|
|
|
110
92
|
// src/http/interceptorWorker/errors/InvalidFormDataError.ts
|
|
111
93
|
var InvalidFormDataError = class extends SyntaxError {
|
|
112
|
-
static {
|
|
113
|
-
__name(this, "InvalidFormDataError");
|
|
114
|
-
}
|
|
115
94
|
constructor(value) {
|
|
116
95
|
super(`Failed to parse value as form data: ${value}`);
|
|
117
96
|
this.name = "InvalidFormDataError";
|
|
@@ -121,9 +100,6 @@ var InvalidFormDataError_default = InvalidFormDataError;
|
|
|
121
100
|
|
|
122
101
|
// src/http/interceptorWorker/errors/InvalidJSONError.ts
|
|
123
102
|
var InvalidJSONError = class extends SyntaxError {
|
|
124
|
-
static {
|
|
125
|
-
__name(this, "InvalidJSONError");
|
|
126
|
-
}
|
|
127
103
|
constructor(value) {
|
|
128
104
|
super(`Failed to parse value as JSON: ${value}`);
|
|
129
105
|
this.name = "InvalidJSONError";
|
|
@@ -136,9 +112,6 @@ var SERVICE_WORKER_FILE_NAME = "mockServiceWorker.js";
|
|
|
136
112
|
|
|
137
113
|
// src/http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError.ts
|
|
138
114
|
var UnregisteredBrowserServiceWorkerError = class extends Error {
|
|
139
|
-
static {
|
|
140
|
-
__name(this, "UnregisteredBrowserServiceWorkerError");
|
|
141
|
-
}
|
|
142
115
|
constructor() {
|
|
143
116
|
super(
|
|
144
117
|
`Failed to register the browser service worker: script '${window.location.origin}/${SERVICE_WORKER_FILE_NAME}' not found.
|
|
@@ -157,9 +130,6 @@ var UnregisteredBrowserServiceWorkerError_default = UnregisteredBrowserServiceWo
|
|
|
157
130
|
|
|
158
131
|
// src/http/requestHandler/errors/DisabledRequestSavingError.ts
|
|
159
132
|
var DisabledRequestSavingError = class extends TypeError {
|
|
160
|
-
static {
|
|
161
|
-
__name(this, "DisabledRequestSavingError");
|
|
162
|
-
}
|
|
163
133
|
constructor() {
|
|
164
134
|
super(
|
|
165
135
|
"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"
|
|
@@ -169,46 +139,30 @@ var DisabledRequestSavingError = class extends TypeError {
|
|
|
169
139
|
};
|
|
170
140
|
var DisabledRequestSavingError_default = DisabledRequestSavingError;
|
|
171
141
|
|
|
172
|
-
// ../zimic-utils/dist/chunk-
|
|
173
|
-
var __defProp2 = Object.defineProperty;
|
|
174
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
175
|
-
|
|
176
|
-
// ../zimic-utils/dist/chunk-WC2DBWWR.mjs
|
|
142
|
+
// ../zimic-utils/dist/chunk-5UH44FTS.mjs
|
|
177
143
|
function isDefined(value) {
|
|
178
144
|
return value !== void 0 && value !== null;
|
|
179
145
|
}
|
|
180
|
-
__name(isDefined, "isDefined");
|
|
181
|
-
__name2(isDefined, "isDefined");
|
|
182
146
|
var isDefined_default = isDefined;
|
|
183
147
|
|
|
184
148
|
// ../zimic-utils/dist/data/isNonEmpty.mjs
|
|
185
149
|
function isNonEmpty(value) {
|
|
186
150
|
return isDefined_default(value) && value !== "";
|
|
187
151
|
}
|
|
188
|
-
__name(isNonEmpty, "isNonEmpty");
|
|
189
|
-
__name2(isNonEmpty, "isNonEmpty");
|
|
190
152
|
var isNonEmpty_default = isNonEmpty;
|
|
191
153
|
|
|
192
154
|
// ../zimic-utils/dist/import/createCachedDynamicImport.mjs
|
|
193
155
|
function createCachedDynamicImport(importModuleDynamically) {
|
|
194
156
|
let cachedImportResult;
|
|
195
|
-
return
|
|
157
|
+
return async function importModuleDynamicallyWithCache() {
|
|
196
158
|
cachedImportResult ??= await importModuleDynamically();
|
|
197
159
|
return cachedImportResult;
|
|
198
|
-
}
|
|
160
|
+
};
|
|
199
161
|
}
|
|
200
|
-
__name(createCachedDynamicImport, "createCachedDynamicImport");
|
|
201
|
-
__name2(createCachedDynamicImport, "createCachedDynamicImport");
|
|
202
162
|
var createCachedDynamicImport_default = createCachedDynamicImport;
|
|
203
163
|
|
|
204
164
|
// ../zimic-utils/dist/logging/Logger.mjs
|
|
205
165
|
var Logger = class _Logger {
|
|
206
|
-
static {
|
|
207
|
-
__name(this, "_Logger");
|
|
208
|
-
}
|
|
209
|
-
static {
|
|
210
|
-
__name2(this, "Logger");
|
|
211
|
-
}
|
|
212
166
|
prefix;
|
|
213
167
|
raw;
|
|
214
168
|
constructor(options = {}) {
|
|
@@ -287,15 +241,12 @@ var Logger_default = Logger;
|
|
|
287
241
|
function isServerSide() {
|
|
288
242
|
return typeof process !== "undefined" && typeof process.versions !== "undefined";
|
|
289
243
|
}
|
|
290
|
-
__name(isServerSide, "isServerSide");
|
|
291
244
|
function isClientSide() {
|
|
292
245
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
293
246
|
}
|
|
294
|
-
__name(isClientSide, "isClientSide");
|
|
295
247
|
function isGlobalFileAvailable() {
|
|
296
248
|
return globalThis.File !== void 0;
|
|
297
249
|
}
|
|
298
|
-
__name(isGlobalFileAvailable, "isGlobalFileAvailable");
|
|
299
250
|
|
|
300
251
|
// src/utils/logging.ts
|
|
301
252
|
var logger = new Logger_default({
|
|
@@ -306,13 +257,12 @@ function stringifyJSONToLog(value) {
|
|
|
306
257
|
value,
|
|
307
258
|
(_key, value2) => {
|
|
308
259
|
return stringifyValueToLog(value2, {
|
|
309
|
-
fallback:
|
|
260
|
+
fallback: (value3) => value3
|
|
310
261
|
});
|
|
311
262
|
},
|
|
312
263
|
2
|
|
313
264
|
).replace(/\n\s*/g, " ").replace(/"(File { name: '.*?', type: '.*?', size: \d*? })"/g, "$1").replace(/"(Blob { type: '.*?', size: \d*? })"/g, "$1");
|
|
314
265
|
}
|
|
315
|
-
__name(stringifyJSONToLog, "stringifyJSONToLog");
|
|
316
266
|
function stringifyValueToLog(value, options = {}) {
|
|
317
267
|
const { fallback = stringifyJSONToLog, includeClassName } = options;
|
|
318
268
|
if (value === null || value === void 0 || typeof value !== "object") {
|
|
@@ -336,7 +286,6 @@ function stringifyValueToLog(value, options = {}) {
|
|
|
336
286
|
}
|
|
337
287
|
return fallback(value);
|
|
338
288
|
}
|
|
339
|
-
__name(stringifyValueToLog, "stringifyValueToLog");
|
|
340
289
|
var importUtil = createCachedDynamicImport_default(() => import('util'));
|
|
341
290
|
async function formatValueToLog(value, options = {}) {
|
|
342
291
|
if (isClientSide()) {
|
|
@@ -354,7 +303,6 @@ async function formatValueToLog(value, options = {}) {
|
|
|
354
303
|
sorted: true
|
|
355
304
|
});
|
|
356
305
|
}
|
|
357
|
-
__name(formatValueToLog, "formatValueToLog");
|
|
358
306
|
|
|
359
307
|
// src/http/requestHandler/errors/TimesCheckError.ts
|
|
360
308
|
function createMessageHeader({
|
|
@@ -382,7 +330,6 @@ Requests evaluated by this handler:
|
|
|
382
330
|
${color2__default.default.red("+ Received")}`
|
|
383
331
|
].filter((part) => part !== false).join("");
|
|
384
332
|
}
|
|
385
|
-
__name(createMessageHeader, "createMessageHeader");
|
|
386
333
|
function createMessageDiffs({ requestSaving, unmatchedRequestGroups }) {
|
|
387
334
|
if (!requestSaving.enabled) {
|
|
388
335
|
return "Tip: use `requestSaving.enabled: true` in your interceptor for more details about the unmatched requests.";
|
|
@@ -425,22 +372,16 @@ function createMessageDiffs({ requestSaving, unmatchedRequestGroups }) {
|
|
|
425
372
|
return messageParts.join("\n ");
|
|
426
373
|
}).join("\n\n");
|
|
427
374
|
}
|
|
428
|
-
__name(createMessageDiffs, "createMessageDiffs");
|
|
429
375
|
function createMessageFooter() {
|
|
430
376
|
return "Learn more: https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes";
|
|
431
377
|
}
|
|
432
|
-
__name(createMessageFooter, "createMessageFooter");
|
|
433
378
|
function createMessage(options) {
|
|
434
379
|
const messageHeader = createMessageHeader(options);
|
|
435
380
|
const messageDiffs = createMessageDiffs(options);
|
|
436
381
|
const messageFooter = createMessageFooter();
|
|
437
382
|
return [messageHeader, messageDiffs, messageFooter].filter(isNonEmpty_default).join("\n\n");
|
|
438
383
|
}
|
|
439
|
-
__name(createMessage, "createMessage");
|
|
440
384
|
var TimesCheckError = class extends TypeError {
|
|
441
|
-
static {
|
|
442
|
-
__name(this, "TimesCheckError");
|
|
443
|
-
}
|
|
444
385
|
constructor(options) {
|
|
445
386
|
const message = createMessage(options);
|
|
446
387
|
super(message);
|
|
@@ -450,7 +391,7 @@ var TimesCheckError = class extends TypeError {
|
|
|
450
391
|
};
|
|
451
392
|
var TimesCheckError_default = TimesCheckError;
|
|
452
393
|
|
|
453
|
-
// ../zimic-utils/dist/chunk-
|
|
394
|
+
// ../zimic-utils/dist/chunk-BSG74SVQ.mjs
|
|
454
395
|
async function blobEquals(blob, otherBlob) {
|
|
455
396
|
if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {
|
|
456
397
|
return false;
|
|
@@ -503,16 +444,12 @@ async function blobEquals(blob, otherBlob) {
|
|
|
503
444
|
otherReader.releaseLock();
|
|
504
445
|
}
|
|
505
446
|
}
|
|
506
|
-
__name(blobEquals, "blobEquals");
|
|
507
|
-
__name2(blobEquals, "blobEquals");
|
|
508
447
|
var blobEquals_default = blobEquals;
|
|
509
448
|
|
|
510
|
-
// ../zimic-utils/dist/chunk-
|
|
449
|
+
// ../zimic-utils/dist/chunk-LBZAJMTR.mjs
|
|
511
450
|
function isPrimitiveJSONValue(value) {
|
|
512
451
|
return typeof value !== "object" || value === null;
|
|
513
452
|
}
|
|
514
|
-
__name(isPrimitiveJSONValue, "isPrimitiveJSONValue");
|
|
515
|
-
__name2(isPrimitiveJSONValue, "isPrimitiveJSONValue");
|
|
516
453
|
|
|
517
454
|
// ../zimic-utils/dist/data/jsonContains.mjs
|
|
518
455
|
function jsonContains(value, otherValue) {
|
|
@@ -554,8 +491,6 @@ function jsonContains(value, otherValue) {
|
|
|
554
491
|
return jsonContains(subValue, subOtherValue);
|
|
555
492
|
});
|
|
556
493
|
}
|
|
557
|
-
__name(jsonContains, "jsonContains");
|
|
558
|
-
__name2(jsonContains, "jsonContains");
|
|
559
494
|
var jsonContains_default = jsonContains;
|
|
560
495
|
|
|
561
496
|
// ../zimic-utils/dist/data/jsonEquals.mjs
|
|
@@ -589,8 +524,6 @@ function jsonEquals(value, otherValue) {
|
|
|
589
524
|
return jsonEquals(subValue, subOtherValue);
|
|
590
525
|
});
|
|
591
526
|
}
|
|
592
|
-
__name(jsonEquals, "jsonEquals");
|
|
593
|
-
__name2(jsonEquals, "jsonEquals");
|
|
594
527
|
var jsonEquals_default = jsonEquals;
|
|
595
528
|
|
|
596
529
|
// src/utils/data.ts
|
|
@@ -608,11 +541,9 @@ async function convertReadableStreamToBlob(stream, options) {
|
|
|
608
541
|
}
|
|
609
542
|
return new Blob(chunks, options);
|
|
610
543
|
}
|
|
611
|
-
__name(convertReadableStreamToBlob, "convertReadableStreamToBlob");
|
|
612
544
|
function convertArrayBufferToBlob(buffer, options) {
|
|
613
545
|
return new Blob([buffer], options);
|
|
614
546
|
}
|
|
615
|
-
__name(convertArrayBufferToBlob, "convertArrayBufferToBlob");
|
|
616
547
|
function convertArrayBufferToBase64(buffer) {
|
|
617
548
|
if (isClientSide()) {
|
|
618
549
|
const bufferBytes = new Uint8Array(buffer);
|
|
@@ -627,7 +558,6 @@ function convertArrayBufferToBase64(buffer) {
|
|
|
627
558
|
return Buffer.from(buffer).toString("base64");
|
|
628
559
|
}
|
|
629
560
|
}
|
|
630
|
-
__name(convertArrayBufferToBase64, "convertArrayBufferToBase64");
|
|
631
561
|
function convertBase64ToArrayBuffer(base64Value) {
|
|
632
562
|
if (isClientSide()) {
|
|
633
563
|
const bufferAsString = atob(base64Value);
|
|
@@ -637,13 +567,9 @@ function convertBase64ToArrayBuffer(base64Value) {
|
|
|
637
567
|
return Buffer.from(base64Value, "base64");
|
|
638
568
|
}
|
|
639
569
|
}
|
|
640
|
-
__name(convertBase64ToArrayBuffer, "convertBase64ToArrayBuffer");
|
|
641
570
|
|
|
642
571
|
// src/http/requestHandler/errors/NoResponseDefinitionError.ts
|
|
643
572
|
var NoResponseDefinitionError = class extends TypeError {
|
|
644
|
-
static {
|
|
645
|
-
__name(this, "NoResponseDefinitionError");
|
|
646
|
-
}
|
|
647
573
|
constructor() {
|
|
648
574
|
super("Cannot generate a response without a definition. Use .respond() to set a response.");
|
|
649
575
|
this.name = "NoResponseDefinitionError";
|
|
@@ -653,9 +579,6 @@ var NoResponseDefinitionError_default = NoResponseDefinitionError;
|
|
|
653
579
|
|
|
654
580
|
// src/http/requestHandler/errors/TimesDeclarationPointer.ts
|
|
655
581
|
var TimesDeclarationPointer = class extends Error {
|
|
656
|
-
static {
|
|
657
|
-
__name(this, "TimesDeclarationPointer");
|
|
658
|
-
}
|
|
659
582
|
constructor(minNumberOfRequests, maxNumberOfRequests) {
|
|
660
583
|
super("declared at:");
|
|
661
584
|
this.name = `handler.times(${minNumberOfRequests}${maxNumberOfRequests === void 0 ? "" : `, ${maxNumberOfRequests}`})`;
|
|
@@ -675,9 +598,6 @@ var HttpRequestHandlerClient = class {
|
|
|
675
598
|
this.path = path;
|
|
676
599
|
this.handler = handler;
|
|
677
600
|
}
|
|
678
|
-
static {
|
|
679
|
-
__name(this, "HttpRequestHandlerClient");
|
|
680
|
-
}
|
|
681
601
|
restrictions = [];
|
|
682
602
|
limits = {
|
|
683
603
|
numberOfRequests: DEFAULT_NUMBER_OF_REQUEST_LIMITS
|
|
@@ -917,9 +837,6 @@ var HttpRequestHandlerClient_default = HttpRequestHandlerClient;
|
|
|
917
837
|
|
|
918
838
|
// src/http/requestHandler/LocalHttpRequestHandler.ts
|
|
919
839
|
var LocalHttpRequestHandler = class {
|
|
920
|
-
static {
|
|
921
|
-
__name(this, "LocalHttpRequestHandler");
|
|
922
|
-
}
|
|
923
840
|
type = "local";
|
|
924
841
|
client;
|
|
925
842
|
constructor(interceptor, method, path) {
|
|
@@ -966,37 +883,25 @@ var LocalHttpRequestHandler = class {
|
|
|
966
883
|
};
|
|
967
884
|
var LocalHttpRequestHandler_default = LocalHttpRequestHandler;
|
|
968
885
|
|
|
969
|
-
// ../zimic-utils/dist/chunk-
|
|
886
|
+
// ../zimic-utils/dist/chunk-46M3OXFU.mjs
|
|
970
887
|
function getExtraPatternsToEscape() {
|
|
971
888
|
return /([.(){}+$])/g;
|
|
972
889
|
}
|
|
973
|
-
__name(getExtraPatternsToEscape, "getExtraPatternsToEscape");
|
|
974
|
-
__name2(getExtraPatternsToEscape, "getExtraPatternsToEscape");
|
|
975
890
|
function getURIEncodedBackSlashPattern() {
|
|
976
891
|
return /%5C/g;
|
|
977
892
|
}
|
|
978
|
-
__name(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
979
|
-
__name2(getURIEncodedBackSlashPattern, "getURIEncodedBackSlashPattern");
|
|
980
893
|
function getPathParamPattern() {
|
|
981
894
|
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)/gu;
|
|
982
895
|
}
|
|
983
|
-
__name(getPathParamPattern, "getPathParamPattern");
|
|
984
|
-
__name2(getPathParamPattern, "getPathParamPattern");
|
|
985
896
|
function getRepeatingPathParamPattern() {
|
|
986
897
|
return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\\+/gu;
|
|
987
898
|
}
|
|
988
|
-
__name(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
989
|
-
__name2(getRepeatingPathParamPattern, "getRepeatingPathParamPattern");
|
|
990
899
|
function getOptionalPathParamPattern() {
|
|
991
900
|
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\?(?<trailingSlash>\/)?/gu;
|
|
992
901
|
}
|
|
993
|
-
__name(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
994
|
-
__name2(getOptionalPathParamPattern, "getOptionalPathParamPattern");
|
|
995
902
|
function getOptionalRepeatingPathParamPattern() {
|
|
996
903
|
return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\*(?<trailingSlash>\/)?/gu;
|
|
997
904
|
}
|
|
998
|
-
__name(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
999
|
-
__name2(getOptionalRepeatingPathParamPattern, "getOptionalRepeatingPathParamPattern");
|
|
1000
905
|
function createParametrizedPathPattern(path) {
|
|
1001
906
|
const replacedURL = encodeURI(path).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(
|
|
1002
907
|
getOptionalRepeatingPathParamPattern(),
|
|
@@ -1045,8 +950,6 @@ function createParametrizedPathPattern(path) {
|
|
|
1045
950
|
});
|
|
1046
951
|
return new RegExp(`^/?${replacedURL}/?$`);
|
|
1047
952
|
}
|
|
1048
|
-
__name(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1049
|
-
__name2(createParametrizedPathPattern, "createParametrizedPathPattern");
|
|
1050
953
|
var createParametrizedPathPattern_default = createParametrizedPathPattern;
|
|
1051
954
|
|
|
1052
955
|
// ../zimic-utils/dist/url/excludeURLParams.mjs
|
|
@@ -1057,18 +960,10 @@ function excludeURLParams(url) {
|
|
|
1057
960
|
url.password = "";
|
|
1058
961
|
return url;
|
|
1059
962
|
}
|
|
1060
|
-
__name(excludeURLParams, "excludeURLParams");
|
|
1061
|
-
__name2(excludeURLParams, "excludeURLParams");
|
|
1062
963
|
var excludeURLParams_default = excludeURLParams;
|
|
1063
964
|
|
|
1064
965
|
// ../zimic-utils/dist/url/validateURLProtocol.mjs
|
|
1065
966
|
var UnsupportedURLProtocolError = class extends TypeError {
|
|
1066
|
-
static {
|
|
1067
|
-
__name(this, "UnsupportedURLProtocolError");
|
|
1068
|
-
}
|
|
1069
|
-
static {
|
|
1070
|
-
__name2(this, "UnsupportedURLProtocolError");
|
|
1071
|
-
}
|
|
1072
967
|
constructor(protocol, availableProtocols) {
|
|
1073
968
|
super(
|
|
1074
969
|
`Unsupported URL protocol: '${protocol}'. The available options are ${availableProtocols.map((protocol2) => `'${protocol2}'`).join(", ")}`
|
|
@@ -1082,8 +977,6 @@ function validateURLProtocol(url, protocols) {
|
|
|
1082
977
|
throw new UnsupportedURLProtocolError(protocol, protocols);
|
|
1083
978
|
}
|
|
1084
979
|
}
|
|
1085
|
-
__name(validateURLProtocol, "validateURLProtocol");
|
|
1086
|
-
__name2(validateURLProtocol, "validateURLProtocol");
|
|
1087
980
|
var validateURLProtocol_default = validateURLProtocol;
|
|
1088
981
|
|
|
1089
982
|
// src/utils/arrays.ts
|
|
@@ -1093,12 +986,10 @@ function removeArrayIndex(array, index) {
|
|
|
1093
986
|
}
|
|
1094
987
|
return array;
|
|
1095
988
|
}
|
|
1096
|
-
__name(removeArrayIndex, "removeArrayIndex");
|
|
1097
989
|
function removeArrayElement(array, element) {
|
|
1098
990
|
const index = array.indexOf(element);
|
|
1099
991
|
return removeArrayIndex(array, index);
|
|
1100
992
|
}
|
|
1101
|
-
__name(removeArrayElement, "removeArrayElement");
|
|
1102
993
|
var HTTP_METHODS_WITH_RESPONSE_BODY = /* @__PURE__ */ new Set([
|
|
1103
994
|
"GET",
|
|
1104
995
|
"POST",
|
|
@@ -1110,7 +1001,6 @@ var HTTP_METHODS_WITH_RESPONSE_BODY = /* @__PURE__ */ new Set([
|
|
|
1110
1001
|
function methodCanHaveResponseBody(method) {
|
|
1111
1002
|
return HTTP_METHODS_WITH_RESPONSE_BODY.has(method);
|
|
1112
1003
|
}
|
|
1113
|
-
__name(methodCanHaveResponseBody, "methodCanHaveResponseBody");
|
|
1114
1004
|
|
|
1115
1005
|
// src/http/requestHandler/types/requests.ts
|
|
1116
1006
|
var HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES = Object.freeze(
|
|
@@ -1144,9 +1034,6 @@ var DEFAULT_UNHANDLED_REQUEST_STRATEGY = Object.freeze({
|
|
|
1144
1034
|
|
|
1145
1035
|
// src/http/interceptorWorker/HttpInterceptorWorker.ts
|
|
1146
1036
|
var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
1147
|
-
static {
|
|
1148
|
-
__name(this, "HttpInterceptorWorker");
|
|
1149
|
-
}
|
|
1150
1037
|
platform = null;
|
|
1151
1038
|
isRunning = false;
|
|
1152
1039
|
startingPromise;
|
|
@@ -1465,9 +1352,6 @@ var HttpInterceptorWorker_default = HttpInterceptorWorker;
|
|
|
1465
1352
|
// src/http/requestHandler/RemoteHttpRequestHandler.ts
|
|
1466
1353
|
var PENDING_PROPERTIES = /* @__PURE__ */ new Set(["then"]);
|
|
1467
1354
|
var RemoteHttpRequestHandler = class {
|
|
1468
|
-
static {
|
|
1469
|
-
__name(this, "RemoteHttpRequestHandler");
|
|
1470
|
-
}
|
|
1471
1355
|
type = "remote";
|
|
1472
1356
|
client;
|
|
1473
1357
|
syncPromises = [];
|
|
@@ -1480,18 +1364,18 @@ var RemoteHttpRequestHandler = class {
|
|
|
1480
1364
|
}
|
|
1481
1365
|
createSyncedProxy() {
|
|
1482
1366
|
return new Proxy(this, {
|
|
1483
|
-
has:
|
|
1367
|
+
has: (target, property) => {
|
|
1484
1368
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1485
1369
|
return false;
|
|
1486
1370
|
}
|
|
1487
1371
|
return Reflect.has(target, property);
|
|
1488
|
-
},
|
|
1489
|
-
get:
|
|
1372
|
+
},
|
|
1373
|
+
get: (target, property) => {
|
|
1490
1374
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1491
1375
|
return void 0;
|
|
1492
1376
|
}
|
|
1493
1377
|
return Reflect.get(target, property);
|
|
1494
|
-
}
|
|
1378
|
+
}
|
|
1495
1379
|
});
|
|
1496
1380
|
}
|
|
1497
1381
|
isHiddenPropertyWhenSynced(property) {
|
|
@@ -1568,9 +1452,6 @@ var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
|
1568
1452
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1569
1453
|
var DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1e3;
|
|
1570
1454
|
var HttpInterceptorClient = class {
|
|
1571
|
-
static {
|
|
1572
|
-
__name(this, "HttpInterceptorClient");
|
|
1573
|
-
}
|
|
1574
1455
|
store;
|
|
1575
1456
|
_baseURL;
|
|
1576
1457
|
createWorker;
|
|
@@ -1804,12 +1685,6 @@ var HttpInterceptorClient_default = HttpInterceptorClient;
|
|
|
1804
1685
|
|
|
1805
1686
|
// ../zimic-utils/dist/url/validatePathParams.mjs
|
|
1806
1687
|
var DuplicatedPathParamError = class extends Error {
|
|
1807
|
-
static {
|
|
1808
|
-
__name(this, "DuplicatedPathParamError");
|
|
1809
|
-
}
|
|
1810
|
-
static {
|
|
1811
|
-
__name2(this, "DuplicatedPathParamError");
|
|
1812
|
-
}
|
|
1813
1688
|
constructor(path, paramName) {
|
|
1814
1689
|
super(
|
|
1815
1690
|
`The path parameter '${paramName}' appears more than once in '${path}'. This is not supported. Please make sure that each parameter is unique.`
|
|
@@ -1831,13 +1706,8 @@ function validatePathParams(path) {
|
|
|
1831
1706
|
uniqueParamNames.add(paramName);
|
|
1832
1707
|
}
|
|
1833
1708
|
}
|
|
1834
|
-
__name(validatePathParams, "validatePathParams");
|
|
1835
|
-
__name2(validatePathParams, "validatePathParams");
|
|
1836
1709
|
var validatePathParams_default = validatePathParams;
|
|
1837
1710
|
var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
1838
|
-
static {
|
|
1839
|
-
__name(this, "LocalHttpInterceptorWorker");
|
|
1840
|
-
}
|
|
1841
1711
|
internalWorker;
|
|
1842
1712
|
httpHandlersByMethod = {
|
|
1843
1713
|
GET: [],
|
|
@@ -1949,7 +1819,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1949
1819
|
method,
|
|
1950
1820
|
pathPattern: createParametrizedPathPattern_default(path),
|
|
1951
1821
|
interceptor,
|
|
1952
|
-
createResponse:
|
|
1822
|
+
createResponse: async (context) => {
|
|
1953
1823
|
const request = context.request;
|
|
1954
1824
|
const requestClone = request.clone();
|
|
1955
1825
|
let response = null;
|
|
@@ -1969,7 +1839,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1969
1839
|
});
|
|
1970
1840
|
}
|
|
1971
1841
|
return response;
|
|
1972
|
-
}
|
|
1842
|
+
}
|
|
1973
1843
|
};
|
|
1974
1844
|
methodHandlers.push(handler);
|
|
1975
1845
|
}
|
|
@@ -2053,7 +1923,6 @@ function deserializeRequest(serializedRequest) {
|
|
|
2053
1923
|
body: deserializedBody
|
|
2054
1924
|
});
|
|
2055
1925
|
}
|
|
2056
|
-
__name(deserializeRequest, "deserializeRequest");
|
|
2057
1926
|
async function serializeResponse(response) {
|
|
2058
1927
|
const responseClone = response.clone();
|
|
2059
1928
|
const serializedBody = responseClone.body ? convertArrayBufferToBase64(await responseClone.arrayBuffer()) : null;
|
|
@@ -2064,7 +1933,6 @@ async function serializeResponse(response) {
|
|
|
2064
1933
|
body: serializedBody
|
|
2065
1934
|
};
|
|
2066
1935
|
}
|
|
2067
|
-
__name(serializeResponse, "serializeResponse");
|
|
2068
1936
|
|
|
2069
1937
|
// src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts
|
|
2070
1938
|
var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
@@ -2073,49 +1941,31 @@ var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
|
2073
1941
|
this.event = event;
|
|
2074
1942
|
this.name = "UnauthorizedWebSocketConnectionError";
|
|
2075
1943
|
}
|
|
2076
|
-
static {
|
|
2077
|
-
__name(this, "UnauthorizedWebSocketConnectionError");
|
|
2078
|
-
}
|
|
2079
1944
|
};
|
|
2080
1945
|
var UnauthorizedWebSocketConnectionError_default = UnauthorizedWebSocketConnectionError;
|
|
2081
1946
|
|
|
2082
1947
|
// src/utils/webSocket.ts
|
|
2083
1948
|
var WebSocketTimeoutError = class extends Error {
|
|
2084
|
-
static {
|
|
2085
|
-
__name(this, "WebSocketTimeoutError");
|
|
2086
|
-
}
|
|
2087
1949
|
};
|
|
2088
1950
|
var WebSocketOpenTimeoutError = class extends WebSocketTimeoutError {
|
|
2089
|
-
static {
|
|
2090
|
-
__name(this, "WebSocketOpenTimeoutError");
|
|
2091
|
-
}
|
|
2092
1951
|
constructor(reachedTimeout) {
|
|
2093
1952
|
super(`Web socket open timed out after ${reachedTimeout}ms.`);
|
|
2094
1953
|
this.name = "WebSocketOpenTimeout";
|
|
2095
1954
|
}
|
|
2096
1955
|
};
|
|
2097
1956
|
var WebSocketMessageTimeoutError = class extends WebSocketTimeoutError {
|
|
2098
|
-
static {
|
|
2099
|
-
__name(this, "WebSocketMessageTimeoutError");
|
|
2100
|
-
}
|
|
2101
1957
|
constructor(reachedTimeout) {
|
|
2102
1958
|
super(`Web socket message timed out after ${reachedTimeout}ms.`);
|
|
2103
1959
|
this.name = "WebSocketMessageTimeout";
|
|
2104
1960
|
}
|
|
2105
1961
|
};
|
|
2106
1962
|
var WebSocketMessageAbortError = class extends WebSocketTimeoutError {
|
|
2107
|
-
static {
|
|
2108
|
-
__name(this, "WebSocketMessageAbortError");
|
|
2109
|
-
}
|
|
2110
1963
|
constructor() {
|
|
2111
1964
|
super("Web socket message was aborted.");
|
|
2112
1965
|
this.name = "WebSocketMessageAbortError";
|
|
2113
1966
|
}
|
|
2114
1967
|
};
|
|
2115
1968
|
var WebSocketCloseTimeoutError = class extends WebSocketTimeoutError {
|
|
2116
|
-
static {
|
|
2117
|
-
__name(this, "WebSocketCloseTimeoutError");
|
|
2118
|
-
}
|
|
2119
1969
|
constructor(reachedTimeout) {
|
|
2120
1970
|
super(`Web socket close timed out after ${reachedTimeout}ms.`);
|
|
2121
1971
|
this.name = "WebSocketCloseTimeout";
|
|
@@ -2136,12 +1986,10 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2136
1986
|
socket.removeEventListener("error", handleOpenError);
|
|
2137
1987
|
socket.removeEventListener("close", handleClose);
|
|
2138
1988
|
}
|
|
2139
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2140
1989
|
function handleOpenError(error) {
|
|
2141
1990
|
removeAllSocketListeners();
|
|
2142
1991
|
reject(error);
|
|
2143
1992
|
}
|
|
2144
|
-
__name(handleOpenError, "handleOpenError");
|
|
2145
1993
|
function handleClose(event) {
|
|
2146
1994
|
const isUnauthorized = event.code === 1008;
|
|
2147
1995
|
if (isUnauthorized) {
|
|
@@ -2151,7 +1999,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2151
1999
|
handleOpenError(event);
|
|
2152
2000
|
}
|
|
2153
2001
|
}
|
|
2154
|
-
__name(handleClose, "handleClose");
|
|
2155
2002
|
const openTimeout = setTimeout(() => {
|
|
2156
2003
|
const timeoutError = new WebSocketOpenTimeoutError(timeoutDuration);
|
|
2157
2004
|
handleOpenError(timeoutError);
|
|
@@ -2161,14 +2008,12 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2161
2008
|
clearTimeout(openTimeout);
|
|
2162
2009
|
resolve();
|
|
2163
2010
|
}
|
|
2164
|
-
__name(handleOpenSuccess, "handleOpenSuccess");
|
|
2165
2011
|
function handleSocketMessage(message) {
|
|
2166
2012
|
const hasValidAuth = message.data === "socket:auth:valid";
|
|
2167
2013
|
if (hasValidAuth) {
|
|
2168
2014
|
handleOpenSuccess();
|
|
2169
2015
|
}
|
|
2170
2016
|
}
|
|
2171
|
-
__name(handleSocketMessage, "handleSocketMessage");
|
|
2172
2017
|
if (waitForAuthentication) {
|
|
2173
2018
|
socket.addEventListener("message", handleSocketMessage);
|
|
2174
2019
|
} else {
|
|
@@ -2178,7 +2023,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2178
2023
|
socket.addEventListener("close", handleClose);
|
|
2179
2024
|
});
|
|
2180
2025
|
}
|
|
2181
|
-
__name(waitForOpenClientSocket, "waitForOpenClientSocket");
|
|
2182
2026
|
async function closeClientSocket(socket, options = {}) {
|
|
2183
2027
|
const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;
|
|
2184
2028
|
const isAlreadyClosed = socket.readyState === socket.CLOSED;
|
|
@@ -2190,12 +2034,10 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2190
2034
|
socket.removeEventListener("error", handleError);
|
|
2191
2035
|
socket.removeEventListener("close", handleClose);
|
|
2192
2036
|
}
|
|
2193
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2194
2037
|
function handleError(error) {
|
|
2195
2038
|
removeAllSocketListeners();
|
|
2196
2039
|
reject(error);
|
|
2197
2040
|
}
|
|
2198
|
-
__name(handleError, "handleError");
|
|
2199
2041
|
const closeTimeout = setTimeout(() => {
|
|
2200
2042
|
const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);
|
|
2201
2043
|
handleError(timeoutError);
|
|
@@ -2205,22 +2047,17 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2205
2047
|
clearTimeout(closeTimeout);
|
|
2206
2048
|
resolve();
|
|
2207
2049
|
}
|
|
2208
|
-
__name(handleClose, "handleClose");
|
|
2209
2050
|
socket.addEventListener("error", handleError);
|
|
2210
2051
|
socket.addEventListener("close", handleClose);
|
|
2211
2052
|
socket.close();
|
|
2212
2053
|
});
|
|
2213
2054
|
}
|
|
2214
|
-
__name(closeClientSocket, "closeClientSocket");
|
|
2215
2055
|
|
|
2216
2056
|
// src/webSocket/constants.ts
|
|
2217
2057
|
var WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(["socket:auth:valid"]);
|
|
2218
2058
|
|
|
2219
2059
|
// src/webSocket/errors/InvalidWebSocketMessage.ts
|
|
2220
2060
|
var InvalidWebSocketMessage = class extends Error {
|
|
2221
|
-
static {
|
|
2222
|
-
__name(this, "InvalidWebSocketMessage");
|
|
2223
|
-
}
|
|
2224
2061
|
constructor(message) {
|
|
2225
2062
|
super(`Web socket message is invalid and could not be parsed: ${message}`);
|
|
2226
2063
|
this.name = "InvalidWebSocketMessage";
|
|
@@ -2230,9 +2067,6 @@ var InvalidWebSocketMessage_default = InvalidWebSocketMessage;
|
|
|
2230
2067
|
|
|
2231
2068
|
// src/webSocket/errors/NotRunningWebSocketHandlerError.ts
|
|
2232
2069
|
var NotRunningWebSocketHandlerError = class extends Error {
|
|
2233
|
-
static {
|
|
2234
|
-
__name(this, "NotRunningWebSocketHandlerError");
|
|
2235
|
-
}
|
|
2236
2070
|
constructor() {
|
|
2237
2071
|
super("Web socket handler is not running.");
|
|
2238
2072
|
this.name = "NotRunningWebSocketHandlerError";
|
|
@@ -2242,9 +2076,6 @@ var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
|
|
|
2242
2076
|
|
|
2243
2077
|
// src/webSocket/WebSocketHandler.ts
|
|
2244
2078
|
var WebSocketHandler = class {
|
|
2245
|
-
static {
|
|
2246
|
-
__name(this, "WebSocketHandler");
|
|
2247
|
-
}
|
|
2248
2079
|
sockets = /* @__PURE__ */ new Set();
|
|
2249
2080
|
socketTimeout;
|
|
2250
2081
|
messageTimeout;
|
|
@@ -2261,26 +2092,25 @@ var WebSocketHandler = class {
|
|
|
2261
2092
|
timeout: this.socketTimeout,
|
|
2262
2093
|
waitForAuthentication: options.waitForAuthentication
|
|
2263
2094
|
});
|
|
2264
|
-
const handleSocketMessage =
|
|
2095
|
+
const handleSocketMessage = async (rawMessage) => {
|
|
2265
2096
|
await this.handleSocketMessage(socket, rawMessage);
|
|
2266
|
-
}
|
|
2097
|
+
};
|
|
2267
2098
|
socket.addEventListener("message", handleSocketMessage);
|
|
2268
2099
|
await openPromise;
|
|
2269
2100
|
function handleSocketError(error) {
|
|
2270
2101
|
console.error(error);
|
|
2271
2102
|
}
|
|
2272
|
-
__name(handleSocketError, "handleSocketError");
|
|
2273
2103
|
socket.addEventListener("error", handleSocketError);
|
|
2274
|
-
const handleSocketClose =
|
|
2104
|
+
const handleSocketClose = () => {
|
|
2275
2105
|
socket.removeEventListener("message", handleSocketMessage);
|
|
2276
2106
|
socket.removeEventListener("close", handleSocketClose);
|
|
2277
2107
|
socket.removeEventListener("error", handleSocketError);
|
|
2278
2108
|
this.removeSocket(socket);
|
|
2279
|
-
}
|
|
2109
|
+
};
|
|
2280
2110
|
socket.addEventListener("close", handleSocketClose);
|
|
2281
2111
|
this.sockets.add(socket);
|
|
2282
2112
|
}
|
|
2283
|
-
handleSocketMessage =
|
|
2113
|
+
handleSocketMessage = async (socket, rawMessage) => {
|
|
2284
2114
|
try {
|
|
2285
2115
|
if (this.isControlMessageData(rawMessage.data)) {
|
|
2286
2116
|
return;
|
|
@@ -2291,7 +2121,7 @@ var WebSocketHandler = class {
|
|
|
2291
2121
|
} catch (error) {
|
|
2292
2122
|
console.error(error);
|
|
2293
2123
|
}
|
|
2294
|
-
}
|
|
2124
|
+
};
|
|
2295
2125
|
isControlMessageData(messageData) {
|
|
2296
2126
|
return typeof messageData === "string" && WEB_SOCKET_CONTROL_MESSAGES.includes(messageData);
|
|
2297
2127
|
}
|
|
@@ -2492,9 +2322,6 @@ var WebSocketHandler_default = WebSocketHandler;
|
|
|
2492
2322
|
// src/webSocket/WebSocketClient.ts
|
|
2493
2323
|
var SUPPORTED_WEB_SOCKET_PROTOCOLS = ["ws", "wss"];
|
|
2494
2324
|
var WebSocketClient = class extends WebSocketHandler_default {
|
|
2495
|
-
static {
|
|
2496
|
-
__name(this, "WebSocketClient");
|
|
2497
|
-
}
|
|
2498
2325
|
url;
|
|
2499
2326
|
socket;
|
|
2500
2327
|
constructor(options) {
|
|
@@ -2530,9 +2357,6 @@ var WebSocketClient_default = WebSocketClient;
|
|
|
2530
2357
|
|
|
2531
2358
|
// src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts
|
|
2532
2359
|
var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
2533
|
-
static {
|
|
2534
|
-
__name(this, "RemoteHttpInterceptorWorker");
|
|
2535
|
-
}
|
|
2536
2360
|
httpHandlers = /* @__PURE__ */ new Map();
|
|
2537
2361
|
webSocketClient;
|
|
2538
2362
|
auth;
|
|
@@ -2563,7 +2387,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2563
2387
|
this.isRunning = true;
|
|
2564
2388
|
});
|
|
2565
2389
|
}
|
|
2566
|
-
createResponse =
|
|
2390
|
+
createResponse = async (message) => {
|
|
2567
2391
|
const { handlerId, request: serializedRequest } = message.data;
|
|
2568
2392
|
const handler = this.httpHandlers.get(handlerId);
|
|
2569
2393
|
const request = deserializeRequest(serializedRequest);
|
|
@@ -2579,14 +2403,14 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2579
2403
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2580
2404
|
await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2581
2405
|
return { response: null };
|
|
2582
|
-
}
|
|
2583
|
-
handleUnhandledServerRequest =
|
|
2406
|
+
};
|
|
2407
|
+
handleUnhandledServerRequest = async (message) => {
|
|
2584
2408
|
const { request: serializedRequest } = message.data;
|
|
2585
2409
|
const request = deserializeRequest(serializedRequest);
|
|
2586
2410
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2587
2411
|
const { wasLogged } = await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2588
2412
|
return { wasLogged };
|
|
2589
|
-
}
|
|
2413
|
+
};
|
|
2590
2414
|
readPlatform() {
|
|
2591
2415
|
if (isServerSide()) {
|
|
2592
2416
|
return "node";
|
|
@@ -2673,13 +2497,9 @@ function createHttpInterceptorWorker(options) {
|
|
|
2673
2497
|
return new RemoteHttpInterceptorWorker_default(options);
|
|
2674
2498
|
}
|
|
2675
2499
|
}
|
|
2676
|
-
__name(createHttpInterceptorWorker, "createHttpInterceptorWorker");
|
|
2677
2500
|
|
|
2678
2501
|
// src/http/interceptor/HttpInterceptorStore.ts
|
|
2679
2502
|
var HttpInterceptorStore = class _HttpInterceptorStore {
|
|
2680
|
-
static {
|
|
2681
|
-
__name(this, "HttpInterceptorStore");
|
|
2682
|
-
}
|
|
2683
2503
|
static _localWorker;
|
|
2684
2504
|
static runningLocalInterceptors = /* @__PURE__ */ new Set();
|
|
2685
2505
|
static remoteWorkers = /* @__PURE__ */ new Map();
|
|
@@ -2756,9 +2576,6 @@ var HttpInterceptorStore_default = HttpInterceptorStore;
|
|
|
2756
2576
|
|
|
2757
2577
|
// src/http/interceptor/LocalHttpInterceptor.ts
|
|
2758
2578
|
var LocalHttpInterceptor = class {
|
|
2759
|
-
static {
|
|
2760
|
-
__name(this, "LocalHttpInterceptor");
|
|
2761
|
-
}
|
|
2762
2579
|
store = new HttpInterceptorStore_default();
|
|
2763
2580
|
client;
|
|
2764
2581
|
constructor(options) {
|
|
@@ -2766,12 +2583,12 @@ var LocalHttpInterceptor = class {
|
|
|
2766
2583
|
this.client = new HttpInterceptorClient_default({
|
|
2767
2584
|
store: this.store,
|
|
2768
2585
|
baseURL,
|
|
2769
|
-
createWorker:
|
|
2586
|
+
createWorker: () => {
|
|
2770
2587
|
return this.store.getOrCreateLocalWorker({});
|
|
2771
|
-
},
|
|
2772
|
-
deleteWorker:
|
|
2588
|
+
},
|
|
2589
|
+
deleteWorker: () => {
|
|
2773
2590
|
this.store.deleteLocalWorker();
|
|
2774
|
-
},
|
|
2591
|
+
},
|
|
2775
2592
|
Handler: LocalHttpRequestHandler_default,
|
|
2776
2593
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2777
2594
|
requestSaving: options.requestSaving
|
|
@@ -2817,27 +2634,27 @@ var LocalHttpInterceptor = class {
|
|
|
2817
2634
|
this.clear();
|
|
2818
2635
|
await this.client.stop();
|
|
2819
2636
|
}
|
|
2820
|
-
get =
|
|
2637
|
+
get = (path) => {
|
|
2821
2638
|
return this.client.get(path);
|
|
2822
|
-
}
|
|
2823
|
-
post =
|
|
2639
|
+
};
|
|
2640
|
+
post = (path) => {
|
|
2824
2641
|
return this.client.post(path);
|
|
2825
|
-
}
|
|
2826
|
-
patch =
|
|
2642
|
+
};
|
|
2643
|
+
patch = (path) => {
|
|
2827
2644
|
return this.client.patch(path);
|
|
2828
|
-
}
|
|
2829
|
-
put =
|
|
2645
|
+
};
|
|
2646
|
+
put = (path) => {
|
|
2830
2647
|
return this.client.put(path);
|
|
2831
|
-
}
|
|
2832
|
-
delete =
|
|
2648
|
+
};
|
|
2649
|
+
delete = (path) => {
|
|
2833
2650
|
return this.client.delete(path);
|
|
2834
|
-
}
|
|
2835
|
-
head =
|
|
2651
|
+
};
|
|
2652
|
+
head = (path) => {
|
|
2836
2653
|
return this.client.head(path);
|
|
2837
|
-
}
|
|
2838
|
-
options =
|
|
2654
|
+
};
|
|
2655
|
+
options = (path) => {
|
|
2839
2656
|
return this.client.options(path);
|
|
2840
|
-
}
|
|
2657
|
+
};
|
|
2841
2658
|
checkTimes() {
|
|
2842
2659
|
this.client.checkTimes();
|
|
2843
2660
|
}
|
|
@@ -2849,9 +2666,6 @@ var LocalHttpInterceptor_default = LocalHttpInterceptor;
|
|
|
2849
2666
|
|
|
2850
2667
|
// src/http/interceptor/RemoteHttpInterceptor.ts
|
|
2851
2668
|
var RemoteHttpInterceptor = class {
|
|
2852
|
-
static {
|
|
2853
|
-
__name(this, "RemoteHttpInterceptor");
|
|
2854
|
-
}
|
|
2855
2669
|
store = new HttpInterceptorStore_default();
|
|
2856
2670
|
client;
|
|
2857
2671
|
_auth;
|
|
@@ -2861,15 +2675,15 @@ var RemoteHttpInterceptor = class {
|
|
|
2861
2675
|
this.client = new HttpInterceptorClient_default({
|
|
2862
2676
|
store: this.store,
|
|
2863
2677
|
baseURL,
|
|
2864
|
-
createWorker:
|
|
2678
|
+
createWorker: () => {
|
|
2865
2679
|
return this.store.getOrCreateRemoteWorker({
|
|
2866
2680
|
serverURL: new URL(baseURL.origin),
|
|
2867
2681
|
auth: this._auth
|
|
2868
2682
|
});
|
|
2869
|
-
},
|
|
2870
|
-
deleteWorker:
|
|
2683
|
+
},
|
|
2684
|
+
deleteWorker: () => {
|
|
2871
2685
|
this.store.deleteRemoteWorker(baseURL, { auth: options.auth });
|
|
2872
|
-
},
|
|
2686
|
+
},
|
|
2873
2687
|
Handler: RemoteHttpRequestHandler_default,
|
|
2874
2688
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2875
2689
|
requestSaving: options.requestSaving
|
|
@@ -2903,12 +2717,12 @@ var RemoteHttpInterceptor = class {
|
|
|
2903
2717
|
return;
|
|
2904
2718
|
}
|
|
2905
2719
|
this._auth = new Proxy(auth, {
|
|
2906
|
-
set:
|
|
2720
|
+
set: (target, property, value) => {
|
|
2907
2721
|
if (this.isRunning) {
|
|
2908
2722
|
throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
|
|
2909
2723
|
}
|
|
2910
2724
|
return Reflect.set(target, property, value);
|
|
2911
|
-
}
|
|
2725
|
+
}
|
|
2912
2726
|
});
|
|
2913
2727
|
}
|
|
2914
2728
|
get onUnhandledRequest() {
|
|
@@ -2936,27 +2750,27 @@ var RemoteHttpInterceptor = class {
|
|
|
2936
2750
|
await this.clear();
|
|
2937
2751
|
await this.client.stop();
|
|
2938
2752
|
}
|
|
2939
|
-
get =
|
|
2753
|
+
get = (path) => {
|
|
2940
2754
|
return this.client.get(path);
|
|
2941
|
-
}
|
|
2942
|
-
post =
|
|
2755
|
+
};
|
|
2756
|
+
post = (path) => {
|
|
2943
2757
|
return this.client.post(path);
|
|
2944
|
-
}
|
|
2945
|
-
patch =
|
|
2758
|
+
};
|
|
2759
|
+
patch = (path) => {
|
|
2946
2760
|
return this.client.patch(path);
|
|
2947
|
-
}
|
|
2948
|
-
put =
|
|
2761
|
+
};
|
|
2762
|
+
put = (path) => {
|
|
2949
2763
|
return this.client.put(path);
|
|
2950
|
-
}
|
|
2951
|
-
delete =
|
|
2764
|
+
};
|
|
2765
|
+
delete = (path) => {
|
|
2952
2766
|
return this.client.delete(path);
|
|
2953
|
-
}
|
|
2954
|
-
head =
|
|
2767
|
+
};
|
|
2768
|
+
head = (path) => {
|
|
2955
2769
|
return this.client.head(path);
|
|
2956
|
-
}
|
|
2957
|
-
options =
|
|
2770
|
+
};
|
|
2771
|
+
options = (path) => {
|
|
2958
2772
|
return this.client.options(path);
|
|
2959
|
-
}
|
|
2773
|
+
};
|
|
2960
2774
|
checkTimes() {
|
|
2961
2775
|
return new Promise((resolve, reject) => {
|
|
2962
2776
|
try {
|
|
@@ -2982,11 +2796,9 @@ var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
|
|
|
2982
2796
|
function isLocalHttpInterceptorOptions(options) {
|
|
2983
2797
|
return options.type === void 0 || options.type === "local";
|
|
2984
2798
|
}
|
|
2985
|
-
__name(isLocalHttpInterceptorOptions, "isLocalHttpInterceptorOptions");
|
|
2986
2799
|
function isRemoteHttpInterceptorOptions(options) {
|
|
2987
2800
|
return options.type === "remote";
|
|
2988
2801
|
}
|
|
2989
|
-
__name(isRemoteHttpInterceptorOptions, "isRemoteHttpInterceptorOptions");
|
|
2990
2802
|
function createHttpInterceptor(options) {
|
|
2991
2803
|
const type = options.type;
|
|
2992
2804
|
if (isLocalHttpInterceptorOptions(options)) {
|
|
@@ -2996,7 +2808,6 @@ function createHttpInterceptor(options) {
|
|
|
2996
2808
|
}
|
|
2997
2809
|
throw new UnknownHttpInterceptorTypeError_default(type);
|
|
2998
2810
|
}
|
|
2999
|
-
__name(createHttpInterceptor, "createHttpInterceptor");
|
|
3000
2811
|
/* istanbul ignore next -- @preserve
|
|
3001
2812
|
* Ignoring because there will always be a handler for the given method and path at this point. */
|
|
3002
2813
|
/* istanbul ignore else -- @preserve */
|