@zimic/interceptor 1.1.2-canary.1 → 1.1.2-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CGILA3WO.mjs → chunk-BJTO5JO5.mjs} +3 -5
- package/dist/{chunk-CGILA3WO.mjs.map → chunk-BJTO5JO5.mjs.map} +1 -1
- 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-RDMXECNU.mjs → chunk-IZWPQ4OM.mjs} +27 -161
- package/dist/chunk-IZWPQ4OM.mjs.map +1 -0
- package/dist/{chunk-QDNKVSEG.js → chunk-XX2J7SRC.js} +27 -161
- package/dist/chunk-XX2J7SRC.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 +68 -252
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +69 -253
- 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 +4 -4
- package/src/http/interceptorWorker/HttpInterceptorWorker.ts +10 -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;
|
|
@@ -1332,8 +1219,13 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
1332
1219
|
return HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES.has(property);
|
|
1333
1220
|
}
|
|
1334
1221
|
static parseRawPathParams(request, options) {
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1222
|
+
const requestPath = request.url.replace(options?.baseURL ?? "", "");
|
|
1223
|
+
const paramsMatch = options?.pathPattern.exec(requestPath);
|
|
1224
|
+
const params = {};
|
|
1225
|
+
for (const [paramName, paramValue] of Object.entries(paramsMatch?.groups ?? {})) {
|
|
1226
|
+
params[paramName] = typeof paramValue === "string" ? decodeURIComponent(paramValue) : void 0;
|
|
1227
|
+
}
|
|
1228
|
+
return params;
|
|
1337
1229
|
}
|
|
1338
1230
|
static async parseRawBody(resource) {
|
|
1339
1231
|
const contentType = resource.headers.get("content-type");
|
|
@@ -1438,9 +1330,6 @@ var HttpInterceptorWorker_default = HttpInterceptorWorker;
|
|
|
1438
1330
|
// src/http/requestHandler/RemoteHttpRequestHandler.ts
|
|
1439
1331
|
var PENDING_PROPERTIES = /* @__PURE__ */ new Set(["then"]);
|
|
1440
1332
|
var RemoteHttpRequestHandler = class {
|
|
1441
|
-
static {
|
|
1442
|
-
__name(this, "RemoteHttpRequestHandler");
|
|
1443
|
-
}
|
|
1444
1333
|
type = "remote";
|
|
1445
1334
|
client;
|
|
1446
1335
|
syncPromises = [];
|
|
@@ -1453,18 +1342,18 @@ var RemoteHttpRequestHandler = class {
|
|
|
1453
1342
|
}
|
|
1454
1343
|
createSyncedProxy() {
|
|
1455
1344
|
return new Proxy(this, {
|
|
1456
|
-
has:
|
|
1345
|
+
has: (target, property) => {
|
|
1457
1346
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1458
1347
|
return false;
|
|
1459
1348
|
}
|
|
1460
1349
|
return Reflect.has(target, property);
|
|
1461
|
-
},
|
|
1462
|
-
get:
|
|
1350
|
+
},
|
|
1351
|
+
get: (target, property) => {
|
|
1463
1352
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1464
1353
|
return void 0;
|
|
1465
1354
|
}
|
|
1466
1355
|
return Reflect.get(target, property);
|
|
1467
|
-
}
|
|
1356
|
+
}
|
|
1468
1357
|
});
|
|
1469
1358
|
}
|
|
1470
1359
|
isHiddenPropertyWhenSynced(property) {
|
|
@@ -1541,9 +1430,6 @@ var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
|
1541
1430
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1542
1431
|
var DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1e3;
|
|
1543
1432
|
var HttpInterceptorClient = class {
|
|
1544
|
-
static {
|
|
1545
|
-
__name(this, "HttpInterceptorClient");
|
|
1546
|
-
}
|
|
1547
1433
|
store;
|
|
1548
1434
|
_baseURL;
|
|
1549
1435
|
createWorker;
|
|
@@ -1777,12 +1663,6 @@ var HttpInterceptorClient_default = HttpInterceptorClient;
|
|
|
1777
1663
|
|
|
1778
1664
|
// ../zimic-utils/dist/url/validatePathParams.mjs
|
|
1779
1665
|
var DuplicatedPathParamError = class extends Error {
|
|
1780
|
-
static {
|
|
1781
|
-
__name(this, "DuplicatedPathParamError");
|
|
1782
|
-
}
|
|
1783
|
-
static {
|
|
1784
|
-
__name2(this, "DuplicatedPathParamError");
|
|
1785
|
-
}
|
|
1786
1666
|
constructor(path, paramName) {
|
|
1787
1667
|
super(
|
|
1788
1668
|
`The path parameter '${paramName}' appears more than once in '${path}'. This is not supported. Please make sure that each parameter is unique.`
|
|
@@ -1804,13 +1684,8 @@ function validatePathParams(path) {
|
|
|
1804
1684
|
uniqueParamNames.add(paramName);
|
|
1805
1685
|
}
|
|
1806
1686
|
}
|
|
1807
|
-
__name(validatePathParams, "validatePathParams");
|
|
1808
|
-
__name2(validatePathParams, "validatePathParams");
|
|
1809
1687
|
var validatePathParams_default = validatePathParams;
|
|
1810
1688
|
var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
1811
|
-
static {
|
|
1812
|
-
__name(this, "LocalHttpInterceptorWorker");
|
|
1813
|
-
}
|
|
1814
1689
|
internalWorker;
|
|
1815
1690
|
httpHandlersByMethod = {
|
|
1816
1691
|
GET: [],
|
|
@@ -1922,7 +1797,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1922
1797
|
method,
|
|
1923
1798
|
pathPattern: createParametrizedPathPattern_default(path),
|
|
1924
1799
|
interceptor,
|
|
1925
|
-
createResponse:
|
|
1800
|
+
createResponse: async (context) => {
|
|
1926
1801
|
const request = context.request;
|
|
1927
1802
|
const requestClone = request.clone();
|
|
1928
1803
|
let response = null;
|
|
@@ -1942,7 +1817,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1942
1817
|
});
|
|
1943
1818
|
}
|
|
1944
1819
|
return response;
|
|
1945
|
-
}
|
|
1820
|
+
}
|
|
1946
1821
|
};
|
|
1947
1822
|
methodHandlers.push(handler);
|
|
1948
1823
|
}
|
|
@@ -2026,7 +1901,6 @@ function deserializeRequest(serializedRequest) {
|
|
|
2026
1901
|
body: deserializedBody
|
|
2027
1902
|
});
|
|
2028
1903
|
}
|
|
2029
|
-
__name(deserializeRequest, "deserializeRequest");
|
|
2030
1904
|
async function serializeResponse(response) {
|
|
2031
1905
|
const responseClone = response.clone();
|
|
2032
1906
|
const serializedBody = responseClone.body ? convertArrayBufferToBase64(await responseClone.arrayBuffer()) : null;
|
|
@@ -2037,7 +1911,6 @@ async function serializeResponse(response) {
|
|
|
2037
1911
|
body: serializedBody
|
|
2038
1912
|
};
|
|
2039
1913
|
}
|
|
2040
|
-
__name(serializeResponse, "serializeResponse");
|
|
2041
1914
|
|
|
2042
1915
|
// src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts
|
|
2043
1916
|
var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
@@ -2046,49 +1919,31 @@ var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
|
2046
1919
|
this.event = event;
|
|
2047
1920
|
this.name = "UnauthorizedWebSocketConnectionError";
|
|
2048
1921
|
}
|
|
2049
|
-
static {
|
|
2050
|
-
__name(this, "UnauthorizedWebSocketConnectionError");
|
|
2051
|
-
}
|
|
2052
1922
|
};
|
|
2053
1923
|
var UnauthorizedWebSocketConnectionError_default = UnauthorizedWebSocketConnectionError;
|
|
2054
1924
|
|
|
2055
1925
|
// src/utils/webSocket.ts
|
|
2056
1926
|
var WebSocketTimeoutError = class extends Error {
|
|
2057
|
-
static {
|
|
2058
|
-
__name(this, "WebSocketTimeoutError");
|
|
2059
|
-
}
|
|
2060
1927
|
};
|
|
2061
1928
|
var WebSocketOpenTimeoutError = class extends WebSocketTimeoutError {
|
|
2062
|
-
static {
|
|
2063
|
-
__name(this, "WebSocketOpenTimeoutError");
|
|
2064
|
-
}
|
|
2065
1929
|
constructor(reachedTimeout) {
|
|
2066
1930
|
super(`Web socket open timed out after ${reachedTimeout}ms.`);
|
|
2067
1931
|
this.name = "WebSocketOpenTimeout";
|
|
2068
1932
|
}
|
|
2069
1933
|
};
|
|
2070
1934
|
var WebSocketMessageTimeoutError = class extends WebSocketTimeoutError {
|
|
2071
|
-
static {
|
|
2072
|
-
__name(this, "WebSocketMessageTimeoutError");
|
|
2073
|
-
}
|
|
2074
1935
|
constructor(reachedTimeout) {
|
|
2075
1936
|
super(`Web socket message timed out after ${reachedTimeout}ms.`);
|
|
2076
1937
|
this.name = "WebSocketMessageTimeout";
|
|
2077
1938
|
}
|
|
2078
1939
|
};
|
|
2079
1940
|
var WebSocketMessageAbortError = class extends WebSocketTimeoutError {
|
|
2080
|
-
static {
|
|
2081
|
-
__name(this, "WebSocketMessageAbortError");
|
|
2082
|
-
}
|
|
2083
1941
|
constructor() {
|
|
2084
1942
|
super("Web socket message was aborted.");
|
|
2085
1943
|
this.name = "WebSocketMessageAbortError";
|
|
2086
1944
|
}
|
|
2087
1945
|
};
|
|
2088
1946
|
var WebSocketCloseTimeoutError = class extends WebSocketTimeoutError {
|
|
2089
|
-
static {
|
|
2090
|
-
__name(this, "WebSocketCloseTimeoutError");
|
|
2091
|
-
}
|
|
2092
1947
|
constructor(reachedTimeout) {
|
|
2093
1948
|
super(`Web socket close timed out after ${reachedTimeout}ms.`);
|
|
2094
1949
|
this.name = "WebSocketCloseTimeout";
|
|
@@ -2109,12 +1964,10 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2109
1964
|
socket.removeEventListener("error", handleOpenError);
|
|
2110
1965
|
socket.removeEventListener("close", handleClose);
|
|
2111
1966
|
}
|
|
2112
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2113
1967
|
function handleOpenError(error) {
|
|
2114
1968
|
removeAllSocketListeners();
|
|
2115
1969
|
reject(error);
|
|
2116
1970
|
}
|
|
2117
|
-
__name(handleOpenError, "handleOpenError");
|
|
2118
1971
|
function handleClose(event) {
|
|
2119
1972
|
const isUnauthorized = event.code === 1008;
|
|
2120
1973
|
if (isUnauthorized) {
|
|
@@ -2124,7 +1977,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2124
1977
|
handleOpenError(event);
|
|
2125
1978
|
}
|
|
2126
1979
|
}
|
|
2127
|
-
__name(handleClose, "handleClose");
|
|
2128
1980
|
const openTimeout = setTimeout(() => {
|
|
2129
1981
|
const timeoutError = new WebSocketOpenTimeoutError(timeoutDuration);
|
|
2130
1982
|
handleOpenError(timeoutError);
|
|
@@ -2134,14 +1986,12 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2134
1986
|
clearTimeout(openTimeout);
|
|
2135
1987
|
resolve();
|
|
2136
1988
|
}
|
|
2137
|
-
__name(handleOpenSuccess, "handleOpenSuccess");
|
|
2138
1989
|
function handleSocketMessage(message) {
|
|
2139
1990
|
const hasValidAuth = message.data === "socket:auth:valid";
|
|
2140
1991
|
if (hasValidAuth) {
|
|
2141
1992
|
handleOpenSuccess();
|
|
2142
1993
|
}
|
|
2143
1994
|
}
|
|
2144
|
-
__name(handleSocketMessage, "handleSocketMessage");
|
|
2145
1995
|
if (waitForAuthentication) {
|
|
2146
1996
|
socket.addEventListener("message", handleSocketMessage);
|
|
2147
1997
|
} else {
|
|
@@ -2151,7 +2001,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2151
2001
|
socket.addEventListener("close", handleClose);
|
|
2152
2002
|
});
|
|
2153
2003
|
}
|
|
2154
|
-
__name(waitForOpenClientSocket, "waitForOpenClientSocket");
|
|
2155
2004
|
async function closeClientSocket(socket, options = {}) {
|
|
2156
2005
|
const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;
|
|
2157
2006
|
const isAlreadyClosed = socket.readyState === socket.CLOSED;
|
|
@@ -2163,12 +2012,10 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2163
2012
|
socket.removeEventListener("error", handleError);
|
|
2164
2013
|
socket.removeEventListener("close", handleClose);
|
|
2165
2014
|
}
|
|
2166
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2167
2015
|
function handleError(error) {
|
|
2168
2016
|
removeAllSocketListeners();
|
|
2169
2017
|
reject(error);
|
|
2170
2018
|
}
|
|
2171
|
-
__name(handleError, "handleError");
|
|
2172
2019
|
const closeTimeout = setTimeout(() => {
|
|
2173
2020
|
const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);
|
|
2174
2021
|
handleError(timeoutError);
|
|
@@ -2178,22 +2025,17 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2178
2025
|
clearTimeout(closeTimeout);
|
|
2179
2026
|
resolve();
|
|
2180
2027
|
}
|
|
2181
|
-
__name(handleClose, "handleClose");
|
|
2182
2028
|
socket.addEventListener("error", handleError);
|
|
2183
2029
|
socket.addEventListener("close", handleClose);
|
|
2184
2030
|
socket.close();
|
|
2185
2031
|
});
|
|
2186
2032
|
}
|
|
2187
|
-
__name(closeClientSocket, "closeClientSocket");
|
|
2188
2033
|
|
|
2189
2034
|
// src/webSocket/constants.ts
|
|
2190
2035
|
var WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(["socket:auth:valid"]);
|
|
2191
2036
|
|
|
2192
2037
|
// src/webSocket/errors/InvalidWebSocketMessage.ts
|
|
2193
2038
|
var InvalidWebSocketMessage = class extends Error {
|
|
2194
|
-
static {
|
|
2195
|
-
__name(this, "InvalidWebSocketMessage");
|
|
2196
|
-
}
|
|
2197
2039
|
constructor(message) {
|
|
2198
2040
|
super(`Web socket message is invalid and could not be parsed: ${message}`);
|
|
2199
2041
|
this.name = "InvalidWebSocketMessage";
|
|
@@ -2203,9 +2045,6 @@ var InvalidWebSocketMessage_default = InvalidWebSocketMessage;
|
|
|
2203
2045
|
|
|
2204
2046
|
// src/webSocket/errors/NotRunningWebSocketHandlerError.ts
|
|
2205
2047
|
var NotRunningWebSocketHandlerError = class extends Error {
|
|
2206
|
-
static {
|
|
2207
|
-
__name(this, "NotRunningWebSocketHandlerError");
|
|
2208
|
-
}
|
|
2209
2048
|
constructor() {
|
|
2210
2049
|
super("Web socket handler is not running.");
|
|
2211
2050
|
this.name = "NotRunningWebSocketHandlerError";
|
|
@@ -2215,9 +2054,6 @@ var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
|
|
|
2215
2054
|
|
|
2216
2055
|
// src/webSocket/WebSocketHandler.ts
|
|
2217
2056
|
var WebSocketHandler = class {
|
|
2218
|
-
static {
|
|
2219
|
-
__name(this, "WebSocketHandler");
|
|
2220
|
-
}
|
|
2221
2057
|
sockets = /* @__PURE__ */ new Set();
|
|
2222
2058
|
socketTimeout;
|
|
2223
2059
|
messageTimeout;
|
|
@@ -2234,26 +2070,25 @@ var WebSocketHandler = class {
|
|
|
2234
2070
|
timeout: this.socketTimeout,
|
|
2235
2071
|
waitForAuthentication: options.waitForAuthentication
|
|
2236
2072
|
});
|
|
2237
|
-
const handleSocketMessage =
|
|
2073
|
+
const handleSocketMessage = async (rawMessage) => {
|
|
2238
2074
|
await this.handleSocketMessage(socket, rawMessage);
|
|
2239
|
-
}
|
|
2075
|
+
};
|
|
2240
2076
|
socket.addEventListener("message", handleSocketMessage);
|
|
2241
2077
|
await openPromise;
|
|
2242
2078
|
function handleSocketError(error) {
|
|
2243
2079
|
console.error(error);
|
|
2244
2080
|
}
|
|
2245
|
-
__name(handleSocketError, "handleSocketError");
|
|
2246
2081
|
socket.addEventListener("error", handleSocketError);
|
|
2247
|
-
const handleSocketClose =
|
|
2082
|
+
const handleSocketClose = () => {
|
|
2248
2083
|
socket.removeEventListener("message", handleSocketMessage);
|
|
2249
2084
|
socket.removeEventListener("close", handleSocketClose);
|
|
2250
2085
|
socket.removeEventListener("error", handleSocketError);
|
|
2251
2086
|
this.removeSocket(socket);
|
|
2252
|
-
}
|
|
2087
|
+
};
|
|
2253
2088
|
socket.addEventListener("close", handleSocketClose);
|
|
2254
2089
|
this.sockets.add(socket);
|
|
2255
2090
|
}
|
|
2256
|
-
handleSocketMessage =
|
|
2091
|
+
handleSocketMessage = async (socket, rawMessage) => {
|
|
2257
2092
|
try {
|
|
2258
2093
|
if (this.isControlMessageData(rawMessage.data)) {
|
|
2259
2094
|
return;
|
|
@@ -2264,7 +2099,7 @@ var WebSocketHandler = class {
|
|
|
2264
2099
|
} catch (error) {
|
|
2265
2100
|
console.error(error);
|
|
2266
2101
|
}
|
|
2267
|
-
}
|
|
2102
|
+
};
|
|
2268
2103
|
isControlMessageData(messageData) {
|
|
2269
2104
|
return typeof messageData === "string" && WEB_SOCKET_CONTROL_MESSAGES.includes(messageData);
|
|
2270
2105
|
}
|
|
@@ -2465,9 +2300,6 @@ var WebSocketHandler_default = WebSocketHandler;
|
|
|
2465
2300
|
// src/webSocket/WebSocketClient.ts
|
|
2466
2301
|
var SUPPORTED_WEB_SOCKET_PROTOCOLS = ["ws", "wss"];
|
|
2467
2302
|
var WebSocketClient = class extends WebSocketHandler_default {
|
|
2468
|
-
static {
|
|
2469
|
-
__name(this, "WebSocketClient");
|
|
2470
|
-
}
|
|
2471
2303
|
url;
|
|
2472
2304
|
socket;
|
|
2473
2305
|
constructor(options) {
|
|
@@ -2503,9 +2335,6 @@ var WebSocketClient_default = WebSocketClient;
|
|
|
2503
2335
|
|
|
2504
2336
|
// src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts
|
|
2505
2337
|
var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
2506
|
-
static {
|
|
2507
|
-
__name(this, "RemoteHttpInterceptorWorker");
|
|
2508
|
-
}
|
|
2509
2338
|
httpHandlers = /* @__PURE__ */ new Map();
|
|
2510
2339
|
webSocketClient;
|
|
2511
2340
|
auth;
|
|
@@ -2536,7 +2365,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2536
2365
|
this.isRunning = true;
|
|
2537
2366
|
});
|
|
2538
2367
|
}
|
|
2539
|
-
createResponse =
|
|
2368
|
+
createResponse = async (message) => {
|
|
2540
2369
|
const { handlerId, request: serializedRequest } = message.data;
|
|
2541
2370
|
const handler = this.httpHandlers.get(handlerId);
|
|
2542
2371
|
const request = deserializeRequest(serializedRequest);
|
|
@@ -2552,14 +2381,14 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2552
2381
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2553
2382
|
await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2554
2383
|
return { response: null };
|
|
2555
|
-
}
|
|
2556
|
-
handleUnhandledServerRequest =
|
|
2384
|
+
};
|
|
2385
|
+
handleUnhandledServerRequest = async (message) => {
|
|
2557
2386
|
const { request: serializedRequest } = message.data;
|
|
2558
2387
|
const request = deserializeRequest(serializedRequest);
|
|
2559
2388
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2560
2389
|
const { wasLogged } = await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2561
2390
|
return { wasLogged };
|
|
2562
|
-
}
|
|
2391
|
+
};
|
|
2563
2392
|
readPlatform() {
|
|
2564
2393
|
if (isServerSide()) {
|
|
2565
2394
|
return "node";
|
|
@@ -2646,13 +2475,9 @@ function createHttpInterceptorWorker(options) {
|
|
|
2646
2475
|
return new RemoteHttpInterceptorWorker_default(options);
|
|
2647
2476
|
}
|
|
2648
2477
|
}
|
|
2649
|
-
__name(createHttpInterceptorWorker, "createHttpInterceptorWorker");
|
|
2650
2478
|
|
|
2651
2479
|
// src/http/interceptor/HttpInterceptorStore.ts
|
|
2652
2480
|
var HttpInterceptorStore = class _HttpInterceptorStore {
|
|
2653
|
-
static {
|
|
2654
|
-
__name(this, "HttpInterceptorStore");
|
|
2655
|
-
}
|
|
2656
2481
|
static _localWorker;
|
|
2657
2482
|
static runningLocalInterceptors = /* @__PURE__ */ new Set();
|
|
2658
2483
|
static remoteWorkers = /* @__PURE__ */ new Map();
|
|
@@ -2729,9 +2554,6 @@ var HttpInterceptorStore_default = HttpInterceptorStore;
|
|
|
2729
2554
|
|
|
2730
2555
|
// src/http/interceptor/LocalHttpInterceptor.ts
|
|
2731
2556
|
var LocalHttpInterceptor = class {
|
|
2732
|
-
static {
|
|
2733
|
-
__name(this, "LocalHttpInterceptor");
|
|
2734
|
-
}
|
|
2735
2557
|
store = new HttpInterceptorStore_default();
|
|
2736
2558
|
client;
|
|
2737
2559
|
constructor(options) {
|
|
@@ -2739,12 +2561,12 @@ var LocalHttpInterceptor = class {
|
|
|
2739
2561
|
this.client = new HttpInterceptorClient_default({
|
|
2740
2562
|
store: this.store,
|
|
2741
2563
|
baseURL,
|
|
2742
|
-
createWorker:
|
|
2564
|
+
createWorker: () => {
|
|
2743
2565
|
return this.store.getOrCreateLocalWorker({});
|
|
2744
|
-
},
|
|
2745
|
-
deleteWorker:
|
|
2566
|
+
},
|
|
2567
|
+
deleteWorker: () => {
|
|
2746
2568
|
this.store.deleteLocalWorker();
|
|
2747
|
-
},
|
|
2569
|
+
},
|
|
2748
2570
|
Handler: LocalHttpRequestHandler_default,
|
|
2749
2571
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2750
2572
|
requestSaving: options.requestSaving
|
|
@@ -2790,27 +2612,27 @@ var LocalHttpInterceptor = class {
|
|
|
2790
2612
|
this.clear();
|
|
2791
2613
|
await this.client.stop();
|
|
2792
2614
|
}
|
|
2793
|
-
get =
|
|
2615
|
+
get = (path) => {
|
|
2794
2616
|
return this.client.get(path);
|
|
2795
|
-
}
|
|
2796
|
-
post =
|
|
2617
|
+
};
|
|
2618
|
+
post = (path) => {
|
|
2797
2619
|
return this.client.post(path);
|
|
2798
|
-
}
|
|
2799
|
-
patch =
|
|
2620
|
+
};
|
|
2621
|
+
patch = (path) => {
|
|
2800
2622
|
return this.client.patch(path);
|
|
2801
|
-
}
|
|
2802
|
-
put =
|
|
2623
|
+
};
|
|
2624
|
+
put = (path) => {
|
|
2803
2625
|
return this.client.put(path);
|
|
2804
|
-
}
|
|
2805
|
-
delete =
|
|
2626
|
+
};
|
|
2627
|
+
delete = (path) => {
|
|
2806
2628
|
return this.client.delete(path);
|
|
2807
|
-
}
|
|
2808
|
-
head =
|
|
2629
|
+
};
|
|
2630
|
+
head = (path) => {
|
|
2809
2631
|
return this.client.head(path);
|
|
2810
|
-
}
|
|
2811
|
-
options =
|
|
2632
|
+
};
|
|
2633
|
+
options = (path) => {
|
|
2812
2634
|
return this.client.options(path);
|
|
2813
|
-
}
|
|
2635
|
+
};
|
|
2814
2636
|
checkTimes() {
|
|
2815
2637
|
this.client.checkTimes();
|
|
2816
2638
|
}
|
|
@@ -2822,9 +2644,6 @@ var LocalHttpInterceptor_default = LocalHttpInterceptor;
|
|
|
2822
2644
|
|
|
2823
2645
|
// src/http/interceptor/RemoteHttpInterceptor.ts
|
|
2824
2646
|
var RemoteHttpInterceptor = class {
|
|
2825
|
-
static {
|
|
2826
|
-
__name(this, "RemoteHttpInterceptor");
|
|
2827
|
-
}
|
|
2828
2647
|
store = new HttpInterceptorStore_default();
|
|
2829
2648
|
client;
|
|
2830
2649
|
_auth;
|
|
@@ -2834,15 +2653,15 @@ var RemoteHttpInterceptor = class {
|
|
|
2834
2653
|
this.client = new HttpInterceptorClient_default({
|
|
2835
2654
|
store: this.store,
|
|
2836
2655
|
baseURL,
|
|
2837
|
-
createWorker:
|
|
2656
|
+
createWorker: () => {
|
|
2838
2657
|
return this.store.getOrCreateRemoteWorker({
|
|
2839
2658
|
serverURL: new URL(baseURL.origin),
|
|
2840
2659
|
auth: this._auth
|
|
2841
2660
|
});
|
|
2842
|
-
},
|
|
2843
|
-
deleteWorker:
|
|
2661
|
+
},
|
|
2662
|
+
deleteWorker: () => {
|
|
2844
2663
|
this.store.deleteRemoteWorker(baseURL, { auth: options.auth });
|
|
2845
|
-
},
|
|
2664
|
+
},
|
|
2846
2665
|
Handler: RemoteHttpRequestHandler_default,
|
|
2847
2666
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2848
2667
|
requestSaving: options.requestSaving
|
|
@@ -2876,12 +2695,12 @@ var RemoteHttpInterceptor = class {
|
|
|
2876
2695
|
return;
|
|
2877
2696
|
}
|
|
2878
2697
|
this._auth = new Proxy(auth, {
|
|
2879
|
-
set:
|
|
2698
|
+
set: (target, property, value) => {
|
|
2880
2699
|
if (this.isRunning) {
|
|
2881
2700
|
throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
|
|
2882
2701
|
}
|
|
2883
2702
|
return Reflect.set(target, property, value);
|
|
2884
|
-
}
|
|
2703
|
+
}
|
|
2885
2704
|
});
|
|
2886
2705
|
}
|
|
2887
2706
|
get onUnhandledRequest() {
|
|
@@ -2909,27 +2728,27 @@ var RemoteHttpInterceptor = class {
|
|
|
2909
2728
|
await this.clear();
|
|
2910
2729
|
await this.client.stop();
|
|
2911
2730
|
}
|
|
2912
|
-
get =
|
|
2731
|
+
get = (path) => {
|
|
2913
2732
|
return this.client.get(path);
|
|
2914
|
-
}
|
|
2915
|
-
post =
|
|
2733
|
+
};
|
|
2734
|
+
post = (path) => {
|
|
2916
2735
|
return this.client.post(path);
|
|
2917
|
-
}
|
|
2918
|
-
patch =
|
|
2736
|
+
};
|
|
2737
|
+
patch = (path) => {
|
|
2919
2738
|
return this.client.patch(path);
|
|
2920
|
-
}
|
|
2921
|
-
put =
|
|
2739
|
+
};
|
|
2740
|
+
put = (path) => {
|
|
2922
2741
|
return this.client.put(path);
|
|
2923
|
-
}
|
|
2924
|
-
delete =
|
|
2742
|
+
};
|
|
2743
|
+
delete = (path) => {
|
|
2925
2744
|
return this.client.delete(path);
|
|
2926
|
-
}
|
|
2927
|
-
head =
|
|
2745
|
+
};
|
|
2746
|
+
head = (path) => {
|
|
2928
2747
|
return this.client.head(path);
|
|
2929
|
-
}
|
|
2930
|
-
options =
|
|
2748
|
+
};
|
|
2749
|
+
options = (path) => {
|
|
2931
2750
|
return this.client.options(path);
|
|
2932
|
-
}
|
|
2751
|
+
};
|
|
2933
2752
|
checkTimes() {
|
|
2934
2753
|
return new Promise((resolve, reject) => {
|
|
2935
2754
|
try {
|
|
@@ -2955,11 +2774,9 @@ var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
|
|
|
2955
2774
|
function isLocalHttpInterceptorOptions(options) {
|
|
2956
2775
|
return options.type === void 0 || options.type === "local";
|
|
2957
2776
|
}
|
|
2958
|
-
__name(isLocalHttpInterceptorOptions, "isLocalHttpInterceptorOptions");
|
|
2959
2777
|
function isRemoteHttpInterceptorOptions(options) {
|
|
2960
2778
|
return options.type === "remote";
|
|
2961
2779
|
}
|
|
2962
|
-
__name(isRemoteHttpInterceptorOptions, "isRemoteHttpInterceptorOptions");
|
|
2963
2780
|
function createHttpInterceptor(options) {
|
|
2964
2781
|
const type = options.type;
|
|
2965
2782
|
if (isLocalHttpInterceptorOptions(options)) {
|
|
@@ -2969,7 +2786,6 @@ function createHttpInterceptor(options) {
|
|
|
2969
2786
|
}
|
|
2970
2787
|
throw new UnknownHttpInterceptorTypeError_default(type);
|
|
2971
2788
|
}
|
|
2972
|
-
__name(createHttpInterceptor, "createHttpInterceptor");
|
|
2973
2789
|
/* istanbul ignore next -- @preserve
|
|
2974
2790
|
* Ignoring because there will always be a handler for the given method and path at this point. */
|
|
2975
2791
|
/* istanbul ignore else -- @preserve */
|