@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.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;
|
|
@@ -1359,8 +1246,13 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
1359
1246
|
return HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES.has(property);
|
|
1360
1247
|
}
|
|
1361
1248
|
static parseRawPathParams(request, options) {
|
|
1362
|
-
const
|
|
1363
|
-
|
|
1249
|
+
const requestPath = request.url.replace(options?.baseURL ?? "", "");
|
|
1250
|
+
const paramsMatch = options?.pathPattern.exec(requestPath);
|
|
1251
|
+
const params = {};
|
|
1252
|
+
for (const [paramName, paramValue] of Object.entries(paramsMatch?.groups ?? {})) {
|
|
1253
|
+
params[paramName] = typeof paramValue === "string" ? decodeURIComponent(paramValue) : void 0;
|
|
1254
|
+
}
|
|
1255
|
+
return params;
|
|
1364
1256
|
}
|
|
1365
1257
|
static async parseRawBody(resource) {
|
|
1366
1258
|
const contentType = resource.headers.get("content-type");
|
|
@@ -1465,9 +1357,6 @@ var HttpInterceptorWorker_default = HttpInterceptorWorker;
|
|
|
1465
1357
|
// src/http/requestHandler/RemoteHttpRequestHandler.ts
|
|
1466
1358
|
var PENDING_PROPERTIES = /* @__PURE__ */ new Set(["then"]);
|
|
1467
1359
|
var RemoteHttpRequestHandler = class {
|
|
1468
|
-
static {
|
|
1469
|
-
__name(this, "RemoteHttpRequestHandler");
|
|
1470
|
-
}
|
|
1471
1360
|
type = "remote";
|
|
1472
1361
|
client;
|
|
1473
1362
|
syncPromises = [];
|
|
@@ -1480,18 +1369,18 @@ var RemoteHttpRequestHandler = class {
|
|
|
1480
1369
|
}
|
|
1481
1370
|
createSyncedProxy() {
|
|
1482
1371
|
return new Proxy(this, {
|
|
1483
|
-
has:
|
|
1372
|
+
has: (target, property) => {
|
|
1484
1373
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1485
1374
|
return false;
|
|
1486
1375
|
}
|
|
1487
1376
|
return Reflect.has(target, property);
|
|
1488
|
-
},
|
|
1489
|
-
get:
|
|
1377
|
+
},
|
|
1378
|
+
get: (target, property) => {
|
|
1490
1379
|
if (this.isHiddenPropertyWhenSynced(property)) {
|
|
1491
1380
|
return void 0;
|
|
1492
1381
|
}
|
|
1493
1382
|
return Reflect.get(target, property);
|
|
1494
|
-
}
|
|
1383
|
+
}
|
|
1495
1384
|
});
|
|
1496
1385
|
}
|
|
1497
1386
|
isHiddenPropertyWhenSynced(property) {
|
|
@@ -1568,9 +1457,6 @@ var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
|
|
|
1568
1457
|
var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
|
|
1569
1458
|
var DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1e3;
|
|
1570
1459
|
var HttpInterceptorClient = class {
|
|
1571
|
-
static {
|
|
1572
|
-
__name(this, "HttpInterceptorClient");
|
|
1573
|
-
}
|
|
1574
1460
|
store;
|
|
1575
1461
|
_baseURL;
|
|
1576
1462
|
createWorker;
|
|
@@ -1804,12 +1690,6 @@ var HttpInterceptorClient_default = HttpInterceptorClient;
|
|
|
1804
1690
|
|
|
1805
1691
|
// ../zimic-utils/dist/url/validatePathParams.mjs
|
|
1806
1692
|
var DuplicatedPathParamError = class extends Error {
|
|
1807
|
-
static {
|
|
1808
|
-
__name(this, "DuplicatedPathParamError");
|
|
1809
|
-
}
|
|
1810
|
-
static {
|
|
1811
|
-
__name2(this, "DuplicatedPathParamError");
|
|
1812
|
-
}
|
|
1813
1693
|
constructor(path, paramName) {
|
|
1814
1694
|
super(
|
|
1815
1695
|
`The path parameter '${paramName}' appears more than once in '${path}'. This is not supported. Please make sure that each parameter is unique.`
|
|
@@ -1831,13 +1711,8 @@ function validatePathParams(path) {
|
|
|
1831
1711
|
uniqueParamNames.add(paramName);
|
|
1832
1712
|
}
|
|
1833
1713
|
}
|
|
1834
|
-
__name(validatePathParams, "validatePathParams");
|
|
1835
|
-
__name2(validatePathParams, "validatePathParams");
|
|
1836
1714
|
var validatePathParams_default = validatePathParams;
|
|
1837
1715
|
var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
1838
|
-
static {
|
|
1839
|
-
__name(this, "LocalHttpInterceptorWorker");
|
|
1840
|
-
}
|
|
1841
1716
|
internalWorker;
|
|
1842
1717
|
httpHandlersByMethod = {
|
|
1843
1718
|
GET: [],
|
|
@@ -1949,7 +1824,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1949
1824
|
method,
|
|
1950
1825
|
pathPattern: createParametrizedPathPattern_default(path),
|
|
1951
1826
|
interceptor,
|
|
1952
|
-
createResponse:
|
|
1827
|
+
createResponse: async (context) => {
|
|
1953
1828
|
const request = context.request;
|
|
1954
1829
|
const requestClone = request.clone();
|
|
1955
1830
|
let response = null;
|
|
@@ -1969,7 +1844,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
1969
1844
|
});
|
|
1970
1845
|
}
|
|
1971
1846
|
return response;
|
|
1972
|
-
}
|
|
1847
|
+
}
|
|
1973
1848
|
};
|
|
1974
1849
|
methodHandlers.push(handler);
|
|
1975
1850
|
}
|
|
@@ -2053,7 +1928,6 @@ function deserializeRequest(serializedRequest) {
|
|
|
2053
1928
|
body: deserializedBody
|
|
2054
1929
|
});
|
|
2055
1930
|
}
|
|
2056
|
-
__name(deserializeRequest, "deserializeRequest");
|
|
2057
1931
|
async function serializeResponse(response) {
|
|
2058
1932
|
const responseClone = response.clone();
|
|
2059
1933
|
const serializedBody = responseClone.body ? convertArrayBufferToBase64(await responseClone.arrayBuffer()) : null;
|
|
@@ -2064,7 +1938,6 @@ async function serializeResponse(response) {
|
|
|
2064
1938
|
body: serializedBody
|
|
2065
1939
|
};
|
|
2066
1940
|
}
|
|
2067
|
-
__name(serializeResponse, "serializeResponse");
|
|
2068
1941
|
|
|
2069
1942
|
// src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts
|
|
2070
1943
|
var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
@@ -2073,49 +1946,31 @@ var UnauthorizedWebSocketConnectionError = class extends Error {
|
|
|
2073
1946
|
this.event = event;
|
|
2074
1947
|
this.name = "UnauthorizedWebSocketConnectionError";
|
|
2075
1948
|
}
|
|
2076
|
-
static {
|
|
2077
|
-
__name(this, "UnauthorizedWebSocketConnectionError");
|
|
2078
|
-
}
|
|
2079
1949
|
};
|
|
2080
1950
|
var UnauthorizedWebSocketConnectionError_default = UnauthorizedWebSocketConnectionError;
|
|
2081
1951
|
|
|
2082
1952
|
// src/utils/webSocket.ts
|
|
2083
1953
|
var WebSocketTimeoutError = class extends Error {
|
|
2084
|
-
static {
|
|
2085
|
-
__name(this, "WebSocketTimeoutError");
|
|
2086
|
-
}
|
|
2087
1954
|
};
|
|
2088
1955
|
var WebSocketOpenTimeoutError = class extends WebSocketTimeoutError {
|
|
2089
|
-
static {
|
|
2090
|
-
__name(this, "WebSocketOpenTimeoutError");
|
|
2091
|
-
}
|
|
2092
1956
|
constructor(reachedTimeout) {
|
|
2093
1957
|
super(`Web socket open timed out after ${reachedTimeout}ms.`);
|
|
2094
1958
|
this.name = "WebSocketOpenTimeout";
|
|
2095
1959
|
}
|
|
2096
1960
|
};
|
|
2097
1961
|
var WebSocketMessageTimeoutError = class extends WebSocketTimeoutError {
|
|
2098
|
-
static {
|
|
2099
|
-
__name(this, "WebSocketMessageTimeoutError");
|
|
2100
|
-
}
|
|
2101
1962
|
constructor(reachedTimeout) {
|
|
2102
1963
|
super(`Web socket message timed out after ${reachedTimeout}ms.`);
|
|
2103
1964
|
this.name = "WebSocketMessageTimeout";
|
|
2104
1965
|
}
|
|
2105
1966
|
};
|
|
2106
1967
|
var WebSocketMessageAbortError = class extends WebSocketTimeoutError {
|
|
2107
|
-
static {
|
|
2108
|
-
__name(this, "WebSocketMessageAbortError");
|
|
2109
|
-
}
|
|
2110
1968
|
constructor() {
|
|
2111
1969
|
super("Web socket message was aborted.");
|
|
2112
1970
|
this.name = "WebSocketMessageAbortError";
|
|
2113
1971
|
}
|
|
2114
1972
|
};
|
|
2115
1973
|
var WebSocketCloseTimeoutError = class extends WebSocketTimeoutError {
|
|
2116
|
-
static {
|
|
2117
|
-
__name(this, "WebSocketCloseTimeoutError");
|
|
2118
|
-
}
|
|
2119
1974
|
constructor(reachedTimeout) {
|
|
2120
1975
|
super(`Web socket close timed out after ${reachedTimeout}ms.`);
|
|
2121
1976
|
this.name = "WebSocketCloseTimeout";
|
|
@@ -2136,12 +1991,10 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2136
1991
|
socket.removeEventListener("error", handleOpenError);
|
|
2137
1992
|
socket.removeEventListener("close", handleClose);
|
|
2138
1993
|
}
|
|
2139
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2140
1994
|
function handleOpenError(error) {
|
|
2141
1995
|
removeAllSocketListeners();
|
|
2142
1996
|
reject(error);
|
|
2143
1997
|
}
|
|
2144
|
-
__name(handleOpenError, "handleOpenError");
|
|
2145
1998
|
function handleClose(event) {
|
|
2146
1999
|
const isUnauthorized = event.code === 1008;
|
|
2147
2000
|
if (isUnauthorized) {
|
|
@@ -2151,7 +2004,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2151
2004
|
handleOpenError(event);
|
|
2152
2005
|
}
|
|
2153
2006
|
}
|
|
2154
|
-
__name(handleClose, "handleClose");
|
|
2155
2007
|
const openTimeout = setTimeout(() => {
|
|
2156
2008
|
const timeoutError = new WebSocketOpenTimeoutError(timeoutDuration);
|
|
2157
2009
|
handleOpenError(timeoutError);
|
|
@@ -2161,14 +2013,12 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2161
2013
|
clearTimeout(openTimeout);
|
|
2162
2014
|
resolve();
|
|
2163
2015
|
}
|
|
2164
|
-
__name(handleOpenSuccess, "handleOpenSuccess");
|
|
2165
2016
|
function handleSocketMessage(message) {
|
|
2166
2017
|
const hasValidAuth = message.data === "socket:auth:valid";
|
|
2167
2018
|
if (hasValidAuth) {
|
|
2168
2019
|
handleOpenSuccess();
|
|
2169
2020
|
}
|
|
2170
2021
|
}
|
|
2171
|
-
__name(handleSocketMessage, "handleSocketMessage");
|
|
2172
2022
|
if (waitForAuthentication) {
|
|
2173
2023
|
socket.addEventListener("message", handleSocketMessage);
|
|
2174
2024
|
} else {
|
|
@@ -2178,7 +2028,6 @@ async function waitForOpenClientSocket(socket, options = {}) {
|
|
|
2178
2028
|
socket.addEventListener("close", handleClose);
|
|
2179
2029
|
});
|
|
2180
2030
|
}
|
|
2181
|
-
__name(waitForOpenClientSocket, "waitForOpenClientSocket");
|
|
2182
2031
|
async function closeClientSocket(socket, options = {}) {
|
|
2183
2032
|
const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;
|
|
2184
2033
|
const isAlreadyClosed = socket.readyState === socket.CLOSED;
|
|
@@ -2190,12 +2039,10 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2190
2039
|
socket.removeEventListener("error", handleError);
|
|
2191
2040
|
socket.removeEventListener("close", handleClose);
|
|
2192
2041
|
}
|
|
2193
|
-
__name(removeAllSocketListeners, "removeAllSocketListeners");
|
|
2194
2042
|
function handleError(error) {
|
|
2195
2043
|
removeAllSocketListeners();
|
|
2196
2044
|
reject(error);
|
|
2197
2045
|
}
|
|
2198
|
-
__name(handleError, "handleError");
|
|
2199
2046
|
const closeTimeout = setTimeout(() => {
|
|
2200
2047
|
const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);
|
|
2201
2048
|
handleError(timeoutError);
|
|
@@ -2205,22 +2052,17 @@ async function closeClientSocket(socket, options = {}) {
|
|
|
2205
2052
|
clearTimeout(closeTimeout);
|
|
2206
2053
|
resolve();
|
|
2207
2054
|
}
|
|
2208
|
-
__name(handleClose, "handleClose");
|
|
2209
2055
|
socket.addEventListener("error", handleError);
|
|
2210
2056
|
socket.addEventListener("close", handleClose);
|
|
2211
2057
|
socket.close();
|
|
2212
2058
|
});
|
|
2213
2059
|
}
|
|
2214
|
-
__name(closeClientSocket, "closeClientSocket");
|
|
2215
2060
|
|
|
2216
2061
|
// src/webSocket/constants.ts
|
|
2217
2062
|
var WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(["socket:auth:valid"]);
|
|
2218
2063
|
|
|
2219
2064
|
// src/webSocket/errors/InvalidWebSocketMessage.ts
|
|
2220
2065
|
var InvalidWebSocketMessage = class extends Error {
|
|
2221
|
-
static {
|
|
2222
|
-
__name(this, "InvalidWebSocketMessage");
|
|
2223
|
-
}
|
|
2224
2066
|
constructor(message) {
|
|
2225
2067
|
super(`Web socket message is invalid and could not be parsed: ${message}`);
|
|
2226
2068
|
this.name = "InvalidWebSocketMessage";
|
|
@@ -2230,9 +2072,6 @@ var InvalidWebSocketMessage_default = InvalidWebSocketMessage;
|
|
|
2230
2072
|
|
|
2231
2073
|
// src/webSocket/errors/NotRunningWebSocketHandlerError.ts
|
|
2232
2074
|
var NotRunningWebSocketHandlerError = class extends Error {
|
|
2233
|
-
static {
|
|
2234
|
-
__name(this, "NotRunningWebSocketHandlerError");
|
|
2235
|
-
}
|
|
2236
2075
|
constructor() {
|
|
2237
2076
|
super("Web socket handler is not running.");
|
|
2238
2077
|
this.name = "NotRunningWebSocketHandlerError";
|
|
@@ -2242,9 +2081,6 @@ var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
|
|
|
2242
2081
|
|
|
2243
2082
|
// src/webSocket/WebSocketHandler.ts
|
|
2244
2083
|
var WebSocketHandler = class {
|
|
2245
|
-
static {
|
|
2246
|
-
__name(this, "WebSocketHandler");
|
|
2247
|
-
}
|
|
2248
2084
|
sockets = /* @__PURE__ */ new Set();
|
|
2249
2085
|
socketTimeout;
|
|
2250
2086
|
messageTimeout;
|
|
@@ -2261,26 +2097,25 @@ var WebSocketHandler = class {
|
|
|
2261
2097
|
timeout: this.socketTimeout,
|
|
2262
2098
|
waitForAuthentication: options.waitForAuthentication
|
|
2263
2099
|
});
|
|
2264
|
-
const handleSocketMessage =
|
|
2100
|
+
const handleSocketMessage = async (rawMessage) => {
|
|
2265
2101
|
await this.handleSocketMessage(socket, rawMessage);
|
|
2266
|
-
}
|
|
2102
|
+
};
|
|
2267
2103
|
socket.addEventListener("message", handleSocketMessage);
|
|
2268
2104
|
await openPromise;
|
|
2269
2105
|
function handleSocketError(error) {
|
|
2270
2106
|
console.error(error);
|
|
2271
2107
|
}
|
|
2272
|
-
__name(handleSocketError, "handleSocketError");
|
|
2273
2108
|
socket.addEventListener("error", handleSocketError);
|
|
2274
|
-
const handleSocketClose =
|
|
2109
|
+
const handleSocketClose = () => {
|
|
2275
2110
|
socket.removeEventListener("message", handleSocketMessage);
|
|
2276
2111
|
socket.removeEventListener("close", handleSocketClose);
|
|
2277
2112
|
socket.removeEventListener("error", handleSocketError);
|
|
2278
2113
|
this.removeSocket(socket);
|
|
2279
|
-
}
|
|
2114
|
+
};
|
|
2280
2115
|
socket.addEventListener("close", handleSocketClose);
|
|
2281
2116
|
this.sockets.add(socket);
|
|
2282
2117
|
}
|
|
2283
|
-
handleSocketMessage =
|
|
2118
|
+
handleSocketMessage = async (socket, rawMessage) => {
|
|
2284
2119
|
try {
|
|
2285
2120
|
if (this.isControlMessageData(rawMessage.data)) {
|
|
2286
2121
|
return;
|
|
@@ -2291,7 +2126,7 @@ var WebSocketHandler = class {
|
|
|
2291
2126
|
} catch (error) {
|
|
2292
2127
|
console.error(error);
|
|
2293
2128
|
}
|
|
2294
|
-
}
|
|
2129
|
+
};
|
|
2295
2130
|
isControlMessageData(messageData) {
|
|
2296
2131
|
return typeof messageData === "string" && WEB_SOCKET_CONTROL_MESSAGES.includes(messageData);
|
|
2297
2132
|
}
|
|
@@ -2492,9 +2327,6 @@ var WebSocketHandler_default = WebSocketHandler;
|
|
|
2492
2327
|
// src/webSocket/WebSocketClient.ts
|
|
2493
2328
|
var SUPPORTED_WEB_SOCKET_PROTOCOLS = ["ws", "wss"];
|
|
2494
2329
|
var WebSocketClient = class extends WebSocketHandler_default {
|
|
2495
|
-
static {
|
|
2496
|
-
__name(this, "WebSocketClient");
|
|
2497
|
-
}
|
|
2498
2330
|
url;
|
|
2499
2331
|
socket;
|
|
2500
2332
|
constructor(options) {
|
|
@@ -2530,9 +2362,6 @@ var WebSocketClient_default = WebSocketClient;
|
|
|
2530
2362
|
|
|
2531
2363
|
// src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts
|
|
2532
2364
|
var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
2533
|
-
static {
|
|
2534
|
-
__name(this, "RemoteHttpInterceptorWorker");
|
|
2535
|
-
}
|
|
2536
2365
|
httpHandlers = /* @__PURE__ */ new Map();
|
|
2537
2366
|
webSocketClient;
|
|
2538
2367
|
auth;
|
|
@@ -2563,7 +2392,7 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2563
2392
|
this.isRunning = true;
|
|
2564
2393
|
});
|
|
2565
2394
|
}
|
|
2566
|
-
createResponse =
|
|
2395
|
+
createResponse = async (message) => {
|
|
2567
2396
|
const { handlerId, request: serializedRequest } = message.data;
|
|
2568
2397
|
const handler = this.httpHandlers.get(handlerId);
|
|
2569
2398
|
const request = deserializeRequest(serializedRequest);
|
|
@@ -2579,14 +2408,14 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
|
|
|
2579
2408
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2580
2409
|
await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2581
2410
|
return { response: null };
|
|
2582
|
-
}
|
|
2583
|
-
handleUnhandledServerRequest =
|
|
2411
|
+
};
|
|
2412
|
+
handleUnhandledServerRequest = async (message) => {
|
|
2584
2413
|
const { request: serializedRequest } = message.data;
|
|
2585
2414
|
const request = deserializeRequest(serializedRequest);
|
|
2586
2415
|
const strategy = await super.getUnhandledRequestStrategy(request, "remote");
|
|
2587
2416
|
const { wasLogged } = await super.logUnhandledRequestIfNecessary(request, strategy);
|
|
2588
2417
|
return { wasLogged };
|
|
2589
|
-
}
|
|
2418
|
+
};
|
|
2590
2419
|
readPlatform() {
|
|
2591
2420
|
if (isServerSide()) {
|
|
2592
2421
|
return "node";
|
|
@@ -2673,13 +2502,9 @@ function createHttpInterceptorWorker(options) {
|
|
|
2673
2502
|
return new RemoteHttpInterceptorWorker_default(options);
|
|
2674
2503
|
}
|
|
2675
2504
|
}
|
|
2676
|
-
__name(createHttpInterceptorWorker, "createHttpInterceptorWorker");
|
|
2677
2505
|
|
|
2678
2506
|
// src/http/interceptor/HttpInterceptorStore.ts
|
|
2679
2507
|
var HttpInterceptorStore = class _HttpInterceptorStore {
|
|
2680
|
-
static {
|
|
2681
|
-
__name(this, "HttpInterceptorStore");
|
|
2682
|
-
}
|
|
2683
2508
|
static _localWorker;
|
|
2684
2509
|
static runningLocalInterceptors = /* @__PURE__ */ new Set();
|
|
2685
2510
|
static remoteWorkers = /* @__PURE__ */ new Map();
|
|
@@ -2756,9 +2581,6 @@ var HttpInterceptorStore_default = HttpInterceptorStore;
|
|
|
2756
2581
|
|
|
2757
2582
|
// src/http/interceptor/LocalHttpInterceptor.ts
|
|
2758
2583
|
var LocalHttpInterceptor = class {
|
|
2759
|
-
static {
|
|
2760
|
-
__name(this, "LocalHttpInterceptor");
|
|
2761
|
-
}
|
|
2762
2584
|
store = new HttpInterceptorStore_default();
|
|
2763
2585
|
client;
|
|
2764
2586
|
constructor(options) {
|
|
@@ -2766,12 +2588,12 @@ var LocalHttpInterceptor = class {
|
|
|
2766
2588
|
this.client = new HttpInterceptorClient_default({
|
|
2767
2589
|
store: this.store,
|
|
2768
2590
|
baseURL,
|
|
2769
|
-
createWorker:
|
|
2591
|
+
createWorker: () => {
|
|
2770
2592
|
return this.store.getOrCreateLocalWorker({});
|
|
2771
|
-
},
|
|
2772
|
-
deleteWorker:
|
|
2593
|
+
},
|
|
2594
|
+
deleteWorker: () => {
|
|
2773
2595
|
this.store.deleteLocalWorker();
|
|
2774
|
-
},
|
|
2596
|
+
},
|
|
2775
2597
|
Handler: LocalHttpRequestHandler_default,
|
|
2776
2598
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2777
2599
|
requestSaving: options.requestSaving
|
|
@@ -2817,27 +2639,27 @@ var LocalHttpInterceptor = class {
|
|
|
2817
2639
|
this.clear();
|
|
2818
2640
|
await this.client.stop();
|
|
2819
2641
|
}
|
|
2820
|
-
get =
|
|
2642
|
+
get = (path) => {
|
|
2821
2643
|
return this.client.get(path);
|
|
2822
|
-
}
|
|
2823
|
-
post =
|
|
2644
|
+
};
|
|
2645
|
+
post = (path) => {
|
|
2824
2646
|
return this.client.post(path);
|
|
2825
|
-
}
|
|
2826
|
-
patch =
|
|
2647
|
+
};
|
|
2648
|
+
patch = (path) => {
|
|
2827
2649
|
return this.client.patch(path);
|
|
2828
|
-
}
|
|
2829
|
-
put =
|
|
2650
|
+
};
|
|
2651
|
+
put = (path) => {
|
|
2830
2652
|
return this.client.put(path);
|
|
2831
|
-
}
|
|
2832
|
-
delete =
|
|
2653
|
+
};
|
|
2654
|
+
delete = (path) => {
|
|
2833
2655
|
return this.client.delete(path);
|
|
2834
|
-
}
|
|
2835
|
-
head =
|
|
2656
|
+
};
|
|
2657
|
+
head = (path) => {
|
|
2836
2658
|
return this.client.head(path);
|
|
2837
|
-
}
|
|
2838
|
-
options =
|
|
2659
|
+
};
|
|
2660
|
+
options = (path) => {
|
|
2839
2661
|
return this.client.options(path);
|
|
2840
|
-
}
|
|
2662
|
+
};
|
|
2841
2663
|
checkTimes() {
|
|
2842
2664
|
this.client.checkTimes();
|
|
2843
2665
|
}
|
|
@@ -2849,9 +2671,6 @@ var LocalHttpInterceptor_default = LocalHttpInterceptor;
|
|
|
2849
2671
|
|
|
2850
2672
|
// src/http/interceptor/RemoteHttpInterceptor.ts
|
|
2851
2673
|
var RemoteHttpInterceptor = class {
|
|
2852
|
-
static {
|
|
2853
|
-
__name(this, "RemoteHttpInterceptor");
|
|
2854
|
-
}
|
|
2855
2674
|
store = new HttpInterceptorStore_default();
|
|
2856
2675
|
client;
|
|
2857
2676
|
_auth;
|
|
@@ -2861,15 +2680,15 @@ var RemoteHttpInterceptor = class {
|
|
|
2861
2680
|
this.client = new HttpInterceptorClient_default({
|
|
2862
2681
|
store: this.store,
|
|
2863
2682
|
baseURL,
|
|
2864
|
-
createWorker:
|
|
2683
|
+
createWorker: () => {
|
|
2865
2684
|
return this.store.getOrCreateRemoteWorker({
|
|
2866
2685
|
serverURL: new URL(baseURL.origin),
|
|
2867
2686
|
auth: this._auth
|
|
2868
2687
|
});
|
|
2869
|
-
},
|
|
2870
|
-
deleteWorker:
|
|
2688
|
+
},
|
|
2689
|
+
deleteWorker: () => {
|
|
2871
2690
|
this.store.deleteRemoteWorker(baseURL, { auth: options.auth });
|
|
2872
|
-
},
|
|
2691
|
+
},
|
|
2873
2692
|
Handler: RemoteHttpRequestHandler_default,
|
|
2874
2693
|
onUnhandledRequest: options.onUnhandledRequest,
|
|
2875
2694
|
requestSaving: options.requestSaving
|
|
@@ -2903,12 +2722,12 @@ var RemoteHttpInterceptor = class {
|
|
|
2903
2722
|
return;
|
|
2904
2723
|
}
|
|
2905
2724
|
this._auth = new Proxy(auth, {
|
|
2906
|
-
set:
|
|
2725
|
+
set: (target, property, value) => {
|
|
2907
2726
|
if (this.isRunning) {
|
|
2908
2727
|
throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
|
|
2909
2728
|
}
|
|
2910
2729
|
return Reflect.set(target, property, value);
|
|
2911
|
-
}
|
|
2730
|
+
}
|
|
2912
2731
|
});
|
|
2913
2732
|
}
|
|
2914
2733
|
get onUnhandledRequest() {
|
|
@@ -2936,27 +2755,27 @@ var RemoteHttpInterceptor = class {
|
|
|
2936
2755
|
await this.clear();
|
|
2937
2756
|
await this.client.stop();
|
|
2938
2757
|
}
|
|
2939
|
-
get =
|
|
2758
|
+
get = (path) => {
|
|
2940
2759
|
return this.client.get(path);
|
|
2941
|
-
}
|
|
2942
|
-
post =
|
|
2760
|
+
};
|
|
2761
|
+
post = (path) => {
|
|
2943
2762
|
return this.client.post(path);
|
|
2944
|
-
}
|
|
2945
|
-
patch =
|
|
2763
|
+
};
|
|
2764
|
+
patch = (path) => {
|
|
2946
2765
|
return this.client.patch(path);
|
|
2947
|
-
}
|
|
2948
|
-
put =
|
|
2766
|
+
};
|
|
2767
|
+
put = (path) => {
|
|
2949
2768
|
return this.client.put(path);
|
|
2950
|
-
}
|
|
2951
|
-
delete =
|
|
2769
|
+
};
|
|
2770
|
+
delete = (path) => {
|
|
2952
2771
|
return this.client.delete(path);
|
|
2953
|
-
}
|
|
2954
|
-
head =
|
|
2772
|
+
};
|
|
2773
|
+
head = (path) => {
|
|
2955
2774
|
return this.client.head(path);
|
|
2956
|
-
}
|
|
2957
|
-
options =
|
|
2775
|
+
};
|
|
2776
|
+
options = (path) => {
|
|
2958
2777
|
return this.client.options(path);
|
|
2959
|
-
}
|
|
2778
|
+
};
|
|
2960
2779
|
checkTimes() {
|
|
2961
2780
|
return new Promise((resolve, reject) => {
|
|
2962
2781
|
try {
|
|
@@ -2982,11 +2801,9 @@ var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
|
|
|
2982
2801
|
function isLocalHttpInterceptorOptions(options) {
|
|
2983
2802
|
return options.type === void 0 || options.type === "local";
|
|
2984
2803
|
}
|
|
2985
|
-
__name(isLocalHttpInterceptorOptions, "isLocalHttpInterceptorOptions");
|
|
2986
2804
|
function isRemoteHttpInterceptorOptions(options) {
|
|
2987
2805
|
return options.type === "remote";
|
|
2988
2806
|
}
|
|
2989
|
-
__name(isRemoteHttpInterceptorOptions, "isRemoteHttpInterceptorOptions");
|
|
2990
2807
|
function createHttpInterceptor(options) {
|
|
2991
2808
|
const type = options.type;
|
|
2992
2809
|
if (isLocalHttpInterceptorOptions(options)) {
|
|
@@ -2996,7 +2813,6 @@ function createHttpInterceptor(options) {
|
|
|
2996
2813
|
}
|
|
2997
2814
|
throw new UnknownHttpInterceptorTypeError_default(type);
|
|
2998
2815
|
}
|
|
2999
|
-
__name(createHttpInterceptor, "createHttpInterceptor");
|
|
3000
2816
|
/* istanbul ignore next -- @preserve
|
|
3001
2817
|
* Ignoring because there will always be a handler for the given method and path at this point. */
|
|
3002
2818
|
/* istanbul ignore else -- @preserve */
|