@zimic/interceptor 1.3.5 → 1.3.6-canary.1

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.
Files changed (45) hide show
  1. package/dist/{chunk-M4X33TK3.js → chunk-2YIGHTHM.js} +8 -8
  2. package/dist/chunk-2YIGHTHM.js.map +1 -0
  3. package/dist/{chunk-M7SZ2M7C.mjs → chunk-4XT4ZOJ2.mjs} +8 -8
  4. package/dist/chunk-4XT4ZOJ2.mjs.map +1 -0
  5. package/dist/cli.js +17 -17
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cli.mjs +2 -2
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/http.d.ts +16 -7
  10. package/dist/http.js +129 -118
  11. package/dist/http.js.map +1 -1
  12. package/dist/http.mjs +128 -118
  13. package/dist/http.mjs.map +1 -1
  14. package/dist/server.js +6 -6
  15. package/dist/server.mjs +1 -1
  16. package/package.json +1 -1
  17. package/src/http/{requestHandler/errors/TimesCheckError.ts → errors/HttpTimesCheckError.ts} +26 -10
  18. package/src/http/{requestHandler/errors/TimesDeclarationPointer.ts → errors/HttpTimesDeclarationPointer.ts} +2 -2
  19. package/src/http/index.ts +2 -1
  20. package/src/http/interceptor/{HttpInterceptorClient.ts → HttpInterceptorImplementation.ts} +25 -21
  21. package/src/http/interceptor/HttpInterceptorStore.ts +6 -6
  22. package/src/http/interceptor/LocalHttpInterceptor.ts +22 -22
  23. package/src/http/interceptor/RemoteHttpInterceptor.ts +28 -29
  24. package/src/http/interceptor/types/handlers.ts +0 -4
  25. package/src/http/interceptor/types/public.ts +3 -2
  26. package/src/http/interceptorWorker/HttpInterceptorWorker.ts +13 -8
  27. package/src/http/interceptorWorker/LocalHttpInterceptorWorker.ts +7 -5
  28. package/src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts +8 -6
  29. package/src/http/requestHandler/{HttpRequestHandlerClient.ts → HttpRequestHandlerImplementation.ts} +22 -19
  30. package/src/http/requestHandler/LocalHttpRequestHandler.ts +20 -20
  31. package/src/http/requestHandler/RemoteHttpRequestHandler.ts +29 -25
  32. package/src/http/requestHandler/types/public.ts +2 -2
  33. package/src/server/InterceptorServer.ts +2 -2
  34. package/src/server/types/schema.ts +1 -1
  35. package/src/utils/webSocket.ts +2 -2
  36. package/dist/chunk-M4X33TK3.js.map +0 -1
  37. package/dist/chunk-M7SZ2M7C.mjs.map +0 -1
  38. /package/src/{webSocket → utils/webSocket}/WebSocketClient.ts +0 -0
  39. /package/src/{webSocket → utils/webSocket}/WebSocketHandler.ts +0 -0
  40. /package/src/{webSocket → utils/webSocket}/WebSocketServer.ts +0 -0
  41. /package/src/{webSocket → utils/webSocket}/constants.ts +0 -0
  42. /package/src/{webSocket → utils/webSocket}/errors/InvalidWebSocketMessageError.ts +0 -0
  43. /package/src/{webSocket → utils/webSocket}/errors/NotRunningWebSocketHandlerError.ts +0 -0
  44. /package/src/{webSocket → utils/webSocket}/errors/UnauthorizedWebSocketConnectionError.ts +0 -0
  45. /package/src/{webSocket → utils/webSocket}/types.ts +0 -0
package/dist/http.js CHANGED
@@ -413,7 +413,7 @@ async function formatValueToLog(value, options = {}) {
413
413
  });
414
414
  }
415
415
 
416
- // src/http/requestHandler/errors/TimesCheckError.ts
416
+ // src/http/errors/HttpTimesCheckError.ts
417
417
  function createMessageHeader({
418
418
  requestLimits,
419
419
  hasRestrictions,
@@ -498,7 +498,13 @@ var TimesCheckError = class extends TypeError {
498
498
  this.cause = options.declarationPointer;
499
499
  }
500
500
  };
501
- var TimesCheckError_default = TimesCheckError;
501
+ var HttpTimesCheckError = class extends TimesCheckError {
502
+ constructor(options) {
503
+ super(options);
504
+ this.name = "HttpTimesCheckError";
505
+ }
506
+ };
507
+ var HttpTimesCheckError_default = HttpTimesCheckError;
502
508
 
503
509
  // ../zimic-utils/dist/time.mjs
504
510
  function waitForDelay(milliseconds) {
@@ -559,21 +565,21 @@ function random(lowerLimit, upperLimit) {
559
565
  return Math.random() * range + lowerLimit;
560
566
  }
561
567
 
562
- // src/http/requestHandler/errors/TimesDeclarationPointer.ts
563
- var TimesDeclarationPointer = class extends Error {
568
+ // src/http/errors/HttpTimesDeclarationPointer.ts
569
+ var HttpTimesDeclarationPointer = class extends Error {
564
570
  constructor(minNumberOfRequests, maxNumberOfRequests) {
565
571
  super("declared at:");
566
572
  this.name = `handler.times(${minNumberOfRequests}${maxNumberOfRequests === void 0 ? "" : `, ${maxNumberOfRequests}`})`;
567
573
  }
568
574
  };
569
- var TimesDeclarationPointer_default = TimesDeclarationPointer;
575
+ var HttpTimesDeclarationPointer_default = HttpTimesDeclarationPointer;
570
576
 
571
- // src/http/requestHandler/HttpRequestHandlerClient.ts
577
+ // src/http/requestHandler/HttpRequestHandlerImplementation.ts
572
578
  var DEFAULT_NUMBER_OF_REQUEST_LIMITS = Object.freeze({
573
579
  min: 0,
574
580
  max: Infinity
575
581
  });
576
- var HttpRequestHandlerClient = class {
582
+ var HttpRequestHandlerImplementation = class {
577
583
  constructor(interceptor, method, path, handler) {
578
584
  this.interceptor = interceptor;
579
585
  this.method = method;
@@ -587,7 +593,7 @@ var HttpRequestHandlerClient = class {
587
593
  timesPointer;
588
594
  numberOfMatchedRequests = 0;
589
595
  unmatchedRequestGroups = [];
590
- _requests = [];
596
+ savedInterceptedRequests = [];
591
597
  createResponseDeclaration;
592
598
  createResponseDelay;
593
599
  with(restriction) {
@@ -626,13 +632,13 @@ var HttpRequestHandlerClient = class {
626
632
  min: minNumberOfRequests,
627
633
  max: maxNumberOfRequests ?? minNumberOfRequests
628
634
  };
629
- this.timesPointer = new TimesDeclarationPointer_default(minNumberOfRequests, maxNumberOfRequests);
635
+ this.timesPointer = new HttpTimesDeclarationPointer_default(minNumberOfRequests, maxNumberOfRequests);
630
636
  return this;
631
637
  }
632
638
  checkTimes() {
633
639
  const isWithinLimits = this.numberOfMatchedRequests >= this.limits.numberOfRequests.min && this.numberOfMatchedRequests <= this.limits.numberOfRequests.max;
634
640
  if (!isWithinLimits) {
635
- throw new TimesCheckError_default({
641
+ throw new HttpTimesCheckError_default({
636
642
  requestLimits: this.limits.numberOfRequests,
637
643
  numberOfMatchedRequests: this.numberOfMatchedRequests,
638
644
  declarationPointer: this.timesPointer,
@@ -818,12 +824,12 @@ var HttpRequestHandlerClient = class {
818
824
  }
819
825
  saveInterceptedRequest(request, response) {
820
826
  const interceptedRequest = this.createInterceptedRequest(request, response);
821
- this._requests.push(interceptedRequest);
827
+ this.savedInterceptedRequests.push(interceptedRequest);
822
828
  this.interceptor.incrementNumberOfSavedRequests(1);
823
829
  }
824
830
  clearInterceptedRequests() {
825
- this.interceptor.incrementNumberOfSavedRequests(-this._requests.length);
826
- this._requests.length = 0;
831
+ this.interceptor.incrementNumberOfSavedRequests(-this.savedInterceptedRequests.length);
832
+ this.savedInterceptedRequests.length = 0;
827
833
  }
828
834
  createInterceptedRequest(request, response) {
829
835
  const interceptedRequest = request;
@@ -839,67 +845,67 @@ var HttpRequestHandlerClient = class {
839
845
  if (!this.interceptor.requestSaving.enabled) {
840
846
  throw new DisabledRequestSavingError_default();
841
847
  }
842
- return this._requests;
848
+ return this.savedInterceptedRequests;
843
849
  }
844
850
  };
845
- var HttpRequestHandlerClient_default = HttpRequestHandlerClient;
851
+ var HttpRequestHandlerImplementation_default = HttpRequestHandlerImplementation;
846
852
 
847
853
  // src/http/requestHandler/LocalHttpRequestHandler.ts
848
854
  var LocalHttpRequestHandler = class {
849
855
  type = "local";
850
- client;
856
+ implementation;
851
857
  constructor(interceptor, method, path) {
852
- this.client = new HttpRequestHandlerClient_default(interceptor, method, path, this);
858
+ this.implementation = new HttpRequestHandlerImplementation_default(interceptor, method, path, this);
853
859
  }
854
860
  get method() {
855
- return this.client.method;
861
+ return this.implementation.method;
856
862
  }
857
863
  get path() {
858
- return this.client.path;
864
+ return this.implementation.path;
859
865
  }
860
866
  with(restriction) {
861
- this.client.with(restriction);
867
+ this.implementation.with(restriction);
862
868
  return this;
863
869
  }
864
870
  delay(minMilliseconds, maxMilliseconds) {
865
- this.client.delay(minMilliseconds, maxMilliseconds);
871
+ this.implementation.delay(minMilliseconds, maxMilliseconds);
866
872
  return this;
867
873
  }
868
874
  respond(declaration) {
869
- this.client.respond(declaration);
875
+ this.implementation.respond(declaration);
870
876
  const newThis = this;
871
877
  return newThis;
872
878
  }
873
879
  times(minNumberOfRequests, maxNumberOfRequests) {
874
- this.client.times(minNumberOfRequests, maxNumberOfRequests);
880
+ this.implementation.times(minNumberOfRequests, maxNumberOfRequests);
875
881
  return this;
876
882
  }
877
883
  checkTimes() {
878
- this.client.checkTimes();
884
+ this.implementation.checkTimes();
879
885
  }
880
886
  clear() {
881
- this.client.clear();
887
+ this.implementation.clear();
882
888
  return this;
883
889
  }
884
890
  get requests() {
885
- return this.client.requests;
891
+ return this.implementation.requests;
886
892
  }
887
893
  async matchesRequest(request) {
888
- const requestMatch = await this.client.matchesRequest(request);
894
+ const requestMatch = await this.implementation.matchesRequest(request);
889
895
  if (requestMatch.success) {
890
- this.client.markRequestAsMatched(request);
896
+ this.implementation.markRequestAsMatched(request);
891
897
  } else if (requestMatch.cause === "unmatchedRestrictions") {
892
- this.client.markRequestAsUnmatched(request, { diff: requestMatch.diff });
898
+ this.implementation.markRequestAsUnmatched(request, { diff: requestMatch.diff });
893
899
  } else {
894
- this.client.markRequestAsMatched(request);
900
+ this.implementation.markRequestAsMatched(request);
895
901
  }
896
902
  return requestMatch;
897
903
  }
898
904
  async applyResponseDeclaration(request) {
899
- return this.client.applyResponseDeclaration(request);
905
+ return this.implementation.applyResponseDeclaration(request);
900
906
  }
901
907
  saveInterceptedRequest(request, response) {
902
- this.client.saveInterceptedRequest(request, response);
908
+ this.implementation.saveInterceptedRequest(request, response);
903
909
  }
904
910
  };
905
911
  var LocalHttpRequestHandler_default = LocalHttpRequestHandler;
@@ -1371,64 +1377,64 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
1371
1377
  var HttpInterceptorWorker_default = HttpInterceptorWorker;
1372
1378
 
1373
1379
  // src/http/requestHandler/RemoteHttpRequestHandler.ts
1374
- var PENDING_PROPERTIES = /* @__PURE__ */ new Set(["then"]);
1380
+ var UNSYNCED_PROPERTIES = /* @__PURE__ */ new Set(["then"]);
1375
1381
  var RemoteHttpRequestHandler = class {
1376
1382
  type = "remote";
1377
- client;
1383
+ implementation;
1378
1384
  syncPromises = [];
1379
1385
  unsynced;
1380
1386
  synced;
1381
1387
  constructor(interceptor, method, path) {
1382
- this.client = new HttpRequestHandlerClient_default(interceptor, method, path, this);
1388
+ this.implementation = new HttpRequestHandlerImplementation_default(interceptor, method, path, this);
1383
1389
  this.unsynced = this;
1384
1390
  this.synced = this.createSyncedProxy();
1385
1391
  }
1386
1392
  createSyncedProxy() {
1387
1393
  return new Proxy(this, {
1388
1394
  has: (target, property) => {
1389
- if (this.isHiddenPropertyWhenSynced(property)) {
1395
+ if (this.shouldBeHiddenPropertyWhenSynced(property)) {
1390
1396
  return false;
1391
1397
  }
1392
1398
  return Reflect.has(target, property);
1393
1399
  },
1394
1400
  get: (target, property) => {
1395
- if (this.isHiddenPropertyWhenSynced(property)) {
1401
+ if (this.shouldBeHiddenPropertyWhenSynced(property)) {
1396
1402
  return void 0;
1397
1403
  }
1398
1404
  return Reflect.get(target, property);
1399
1405
  }
1400
1406
  });
1401
1407
  }
1402
- isHiddenPropertyWhenSynced(property) {
1403
- return PENDING_PROPERTIES.has(property);
1408
+ shouldBeHiddenPropertyWhenSynced(property) {
1409
+ return UNSYNCED_PROPERTIES.has(property);
1404
1410
  }
1405
1411
  get method() {
1406
- return this.client.method;
1412
+ return this.implementation.method;
1407
1413
  }
1408
1414
  get path() {
1409
- return this.client.path;
1415
+ return this.implementation.path;
1410
1416
  }
1411
1417
  with(restriction) {
1412
- this.client.with(restriction);
1418
+ this.implementation.with(restriction);
1413
1419
  return this.unsynced;
1414
1420
  }
1415
1421
  delay(minMilliseconds, maxMilliseconds) {
1416
- this.client.delay(minMilliseconds, maxMilliseconds);
1422
+ this.implementation.delay(minMilliseconds, maxMilliseconds);
1417
1423
  return this.unsynced;
1418
1424
  }
1419
1425
  respond(declaration) {
1420
1426
  const newUnsyncedThis = this.unsynced;
1421
- newUnsyncedThis.client.respond(declaration);
1427
+ newUnsyncedThis.implementation.respond(declaration);
1422
1428
  return newUnsyncedThis;
1423
1429
  }
1424
1430
  times(minNumberOfRequests, maxNumberOfRequests) {
1425
- this.client.times(minNumberOfRequests, maxNumberOfRequests);
1431
+ this.implementation.times(minNumberOfRequests, maxNumberOfRequests);
1426
1432
  return this;
1427
1433
  }
1428
1434
  async checkTimes() {
1429
1435
  return new Promise((resolve, reject) => {
1430
1436
  try {
1431
- this.client.checkTimes();
1437
+ this.implementation.checkTimes();
1432
1438
  resolve();
1433
1439
  } catch (error) {
1434
1440
  reject(error);
@@ -1436,28 +1442,28 @@ var RemoteHttpRequestHandler = class {
1436
1442
  });
1437
1443
  }
1438
1444
  clear() {
1439
- this.client.clear();
1445
+ this.implementation.clear();
1440
1446
  return this.unsynced;
1441
1447
  }
1442
1448
  get requests() {
1443
- return this.client.requests;
1449
+ return this.implementation.requests;
1444
1450
  }
1445
1451
  async matchesRequest(request) {
1446
- const requestMatch = await this.client.matchesRequest(request);
1452
+ const requestMatch = await this.implementation.matchesRequest(request);
1447
1453
  if (requestMatch.success) {
1448
- this.client.markRequestAsMatched(request);
1454
+ this.implementation.markRequestAsMatched(request);
1449
1455
  } else if (requestMatch.cause === "unmatchedRestrictions") {
1450
- this.client.markRequestAsUnmatched(request, { diff: requestMatch.diff });
1456
+ this.implementation.markRequestAsUnmatched(request, { diff: requestMatch.diff });
1451
1457
  } else {
1452
- this.client.markRequestAsMatched(request);
1458
+ this.implementation.markRequestAsMatched(request);
1453
1459
  }
1454
1460
  return requestMatch;
1455
1461
  }
1456
1462
  async applyResponseDeclaration(request) {
1457
- return this.client.applyResponseDeclaration(request);
1463
+ return this.implementation.applyResponseDeclaration(request);
1458
1464
  }
1459
1465
  saveInterceptedRequest(request, response) {
1460
- this.client.saveInterceptedRequest(request, response);
1466
+ this.implementation.saveInterceptedRequest(request, response);
1461
1467
  }
1462
1468
  registerSyncPromise(promise) {
1463
1469
  this.syncPromises.push(promise);
@@ -1481,12 +1487,12 @@ var RemoteHttpRequestHandler = class {
1481
1487
  };
1482
1488
  var RemoteHttpRequestHandler_default = RemoteHttpRequestHandler;
1483
1489
 
1484
- // src/http/interceptor/HttpInterceptorClient.ts
1490
+ // src/http/interceptor/HttpInterceptorImplementation.ts
1485
1491
  var SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(["http", "https"]);
1486
1492
  var DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1e3;
1487
- var HttpInterceptorClient = class {
1493
+ var HttpInterceptorImplementation = class {
1488
1494
  store;
1489
- _baseURL;
1495
+ #baseURL;
1490
1496
  createWorker;
1491
1497
  deleteWorker;
1492
1498
  worker;
@@ -1520,7 +1526,7 @@ var HttpInterceptorClient = class {
1520
1526
  return isServerSide() ? process.env.NODE_ENV === "test" : false;
1521
1527
  }
1522
1528
  get baseURL() {
1523
- return this._baseURL;
1529
+ return this.#baseURL;
1524
1530
  }
1525
1531
  set baseURL(newBaseURL) {
1526
1532
  if (this.isRunning) {
@@ -1530,7 +1536,7 @@ var HttpInterceptorClient = class {
1530
1536
  }
1531
1537
  validateURLProtocol_default(newBaseURL, SUPPORTED_BASE_URL_PROTOCOLS);
1532
1538
  excludeNonPathParams_default(newBaseURL);
1533
- this._baseURL = newBaseURL;
1539
+ this.#baseURL = newBaseURL;
1534
1540
  }
1535
1541
  get baseURLAsString() {
1536
1542
  if (this.baseURL.href === `${this.baseURL.origin}/`) {
@@ -1611,17 +1617,21 @@ var HttpInterceptorClient = class {
1611
1617
  if (!this.isRunning) {
1612
1618
  throw new NotRunningHttpInterceptorError_default();
1613
1619
  }
1614
- const handler = new this.Handler(this, method, path);
1620
+ const handler = new this.Handler(
1621
+ this,
1622
+ method,
1623
+ path
1624
+ );
1615
1625
  this.registerRequestHandler(handler);
1616
1626
  return handler;
1617
1627
  }
1618
1628
  registerRequestHandler(handler) {
1619
1629
  const pathHandlers = this.handlers[handler.method].get(handler.path) ?? [];
1620
- const isAlreadyRegistered = pathHandlers.includes(handler.client);
1630
+ const isAlreadyRegistered = pathHandlers.includes(handler.implementation);
1621
1631
  if (isAlreadyRegistered) {
1622
1632
  return;
1623
1633
  }
1624
- pathHandlers.push(handler.client);
1634
+ pathHandlers.push(handler.implementation);
1625
1635
  const isFirstHandlerForMethodPath = pathHandlers.length === 1;
1626
1636
  if (!isFirstHandlerForMethodPath) {
1627
1637
  return;
@@ -1729,7 +1739,7 @@ var HttpInterceptorClient = class {
1729
1739
  return clearResults;
1730
1740
  }
1731
1741
  };
1732
- var HttpInterceptorClient_default = HttpInterceptorClient;
1742
+ var HttpInterceptorImplementation_default = HttpInterceptorImplementation;
1733
1743
  var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
1734
1744
  internalWorker;
1735
1745
  httpHandlersByMethod = {
@@ -1987,7 +1997,7 @@ async function serializeResponse(response) {
1987
1997
  };
1988
1998
  }
1989
1999
 
1990
- // src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts
2000
+ // src/utils/webSocket/errors/UnauthorizedWebSocketConnectionError.ts
1991
2001
  var UnauthorizedWebSocketConnectionError = class extends Error {
1992
2002
  constructor(event) {
1993
2003
  super(`${event.reason} (code ${event.code})`);
@@ -2106,10 +2116,10 @@ async function closeClientSocket(socket, options = {}) {
2106
2116
  });
2107
2117
  }
2108
2118
 
2109
- // src/webSocket/constants.ts
2119
+ // src/utils/webSocket/constants.ts
2110
2120
  var WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(["socket:auth:valid"]);
2111
2121
 
2112
- // src/webSocket/errors/InvalidWebSocketMessageError.ts
2122
+ // src/utils/webSocket/errors/InvalidWebSocketMessageError.ts
2113
2123
  var InvalidWebSocketMessageError = class extends Error {
2114
2124
  constructor(message) {
2115
2125
  super(`Web socket message is invalid and could not be parsed: ${message}`);
@@ -2118,7 +2128,7 @@ var InvalidWebSocketMessageError = class extends Error {
2118
2128
  };
2119
2129
  var InvalidWebSocketMessageError_default = InvalidWebSocketMessageError;
2120
2130
 
2121
- // src/webSocket/errors/NotRunningWebSocketHandlerError.ts
2131
+ // src/utils/webSocket/errors/NotRunningWebSocketHandlerError.ts
2122
2132
  var NotRunningWebSocketHandlerError = class extends Error {
2123
2133
  constructor() {
2124
2134
  super("Web socket handler is not running.");
@@ -2127,7 +2137,7 @@ var NotRunningWebSocketHandlerError = class extends Error {
2127
2137
  };
2128
2138
  var NotRunningWebSocketHandlerError_default = NotRunningWebSocketHandlerError;
2129
2139
 
2130
- // src/webSocket/WebSocketHandler.ts
2140
+ // src/utils/webSocket/WebSocketHandler.ts
2131
2141
  var WebSocketHandler = class {
2132
2142
  sockets = /* @__PURE__ */ new Set();
2133
2143
  socketTimeout;
@@ -2382,7 +2392,7 @@ var WebSocketHandler = class {
2382
2392
  };
2383
2393
  var WebSocketHandler_default = WebSocketHandler;
2384
2394
 
2385
- // src/webSocket/WebSocketClient.ts
2395
+ // src/utils/webSocket/WebSocketClient.ts
2386
2396
  var SUPPORTED_WEB_SOCKET_PROTOCOLS = ["ws", "wss"];
2387
2397
  var WebSocketClient = class extends WebSocketHandler_default {
2388
2398
  url;
@@ -2651,10 +2661,10 @@ var HttpInterceptorStore_default = HttpInterceptorStore;
2651
2661
  // src/http/interceptor/LocalHttpInterceptor.ts
2652
2662
  var LocalHttpInterceptor = class {
2653
2663
  store = new HttpInterceptorStore_default();
2654
- client;
2664
+ implementation;
2655
2665
  constructor(options) {
2656
2666
  const baseURL = new URL(options.baseURL);
2657
- this.client = new HttpInterceptorClient_default({
2667
+ this.implementation = new HttpInterceptorImplementation_default({
2658
2668
  store: this.store,
2659
2669
  baseURL,
2660
2670
  createWorker: () => {
@@ -2672,68 +2682,68 @@ var LocalHttpInterceptor = class {
2672
2682
  return "local";
2673
2683
  }
2674
2684
  get baseURL() {
2675
- return this.client.baseURLAsString;
2685
+ return this.implementation.baseURLAsString;
2676
2686
  }
2677
2687
  set baseURL(baseURL) {
2678
- this.client.baseURL = new URL(baseURL);
2688
+ this.implementation.baseURL = new URL(baseURL);
2679
2689
  }
2680
2690
  get requestSaving() {
2681
- return this.client.requestSaving;
2691
+ return this.implementation.requestSaving;
2682
2692
  }
2683
2693
  set requestSaving(requestSaving) {
2684
- this.client.requestSaving = requestSaving;
2694
+ this.implementation.requestSaving = requestSaving;
2685
2695
  }
2686
2696
  get onUnhandledRequest() {
2687
- return this.client.onUnhandledRequest;
2697
+ return this.implementation.onUnhandledRequest;
2688
2698
  }
2689
2699
  set onUnhandledRequest(onUnhandledRequest) {
2690
- this.client.onUnhandledRequest = onUnhandledRequest;
2700
+ this.implementation.onUnhandledRequest = onUnhandledRequest;
2691
2701
  }
2692
2702
  get platform() {
2693
- return this.client.platform;
2703
+ return this.implementation.platform;
2694
2704
  }
2695
2705
  get isRunning() {
2696
- return this.client.isRunning;
2706
+ return this.implementation.isRunning;
2697
2707
  }
2698
2708
  async start() {
2699
2709
  if (this.isRunning) {
2700
2710
  return;
2701
2711
  }
2702
- await this.client.start();
2712
+ await this.implementation.start();
2703
2713
  }
2704
2714
  async stop() {
2705
2715
  if (!this.isRunning) {
2706
2716
  return;
2707
2717
  }
2708
2718
  this.clear();
2709
- await this.client.stop();
2719
+ await this.implementation.stop();
2710
2720
  }
2711
2721
  get = ((path) => {
2712
- return this.client.get(path);
2722
+ return this.implementation.get(path);
2713
2723
  });
2714
2724
  post = ((path) => {
2715
- return this.client.post(path);
2725
+ return this.implementation.post(path);
2716
2726
  });
2717
2727
  patch = ((path) => {
2718
- return this.client.patch(path);
2728
+ return this.implementation.patch(path);
2719
2729
  });
2720
2730
  put = ((path) => {
2721
- return this.client.put(path);
2731
+ return this.implementation.put(path);
2722
2732
  });
2723
2733
  delete = ((path) => {
2724
- return this.client.delete(path);
2734
+ return this.implementation.delete(path);
2725
2735
  });
2726
2736
  head = ((path) => {
2727
- return this.client.head(path);
2737
+ return this.implementation.head(path);
2728
2738
  });
2729
2739
  options = ((path) => {
2730
- return this.client.options(path);
2740
+ return this.implementation.options(path);
2731
2741
  });
2732
2742
  checkTimes() {
2733
- this.client.checkTimes();
2743
+ this.implementation.checkTimes();
2734
2744
  }
2735
2745
  clear() {
2736
- void this.client.clear();
2746
+ void this.implementation.clear();
2737
2747
  }
2738
2748
  };
2739
2749
  var LocalHttpInterceptor_default = LocalHttpInterceptor;
@@ -2741,18 +2751,18 @@ var LocalHttpInterceptor_default = LocalHttpInterceptor;
2741
2751
  // src/http/interceptor/RemoteHttpInterceptor.ts
2742
2752
  var RemoteHttpInterceptor = class {
2743
2753
  store = new HttpInterceptorStore_default();
2744
- client;
2745
- _auth;
2754
+ implementation;
2755
+ #auth;
2746
2756
  constructor(options) {
2747
- this._auth = options.auth;
2757
+ this.#auth = options.auth;
2748
2758
  const baseURL = new URL(options.baseURL);
2749
- this.client = new HttpInterceptorClient_default({
2759
+ this.implementation = new HttpInterceptorImplementation_default({
2750
2760
  store: this.store,
2751
2761
  baseURL,
2752
2762
  createWorker: () => {
2753
2763
  return this.store.getOrCreateRemoteWorker({
2754
2764
  serverURL: baseURL,
2755
- auth: this._auth
2765
+ auth: this.#auth
2756
2766
  });
2757
2767
  },
2758
2768
  deleteWorker: () => {
@@ -2767,19 +2777,19 @@ var RemoteHttpInterceptor = class {
2767
2777
  return "remote";
2768
2778
  }
2769
2779
  get baseURL() {
2770
- return this.client.baseURLAsString;
2780
+ return this.implementation.baseURLAsString;
2771
2781
  }
2772
2782
  set baseURL(baseURL) {
2773
- this.client.baseURL = new URL(baseURL);
2783
+ this.implementation.baseURL = new URL(baseURL);
2774
2784
  }
2775
2785
  get requestSaving() {
2776
- return this.client.requestSaving;
2786
+ return this.implementation.requestSaving;
2777
2787
  }
2778
2788
  set requestSaving(requestSaving) {
2779
- this.client.requestSaving = requestSaving;
2789
+ this.implementation.requestSaving = requestSaving;
2780
2790
  }
2781
2791
  get auth() {
2782
- return this._auth;
2792
+ return this.#auth;
2783
2793
  }
2784
2794
  set auth(auth) {
2785
2795
  const cannotChangeAuthWhileRunningMessage = "Did you forget to call `await interceptor.stop()` before changing the authentication parameters?";
@@ -2787,10 +2797,10 @@ var RemoteHttpInterceptor = class {
2787
2797
  throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
2788
2798
  }
2789
2799
  if (!auth) {
2790
- this._auth = void 0;
2800
+ this.#auth = void 0;
2791
2801
  return;
2792
2802
  }
2793
- this._auth = new Proxy(auth, {
2803
+ this.#auth = new Proxy(auth, {
2794
2804
  set: (target, property, value) => {
2795
2805
  if (this.isRunning) {
2796
2806
  throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
@@ -2800,55 +2810,55 @@ var RemoteHttpInterceptor = class {
2800
2810
  });
2801
2811
  }
2802
2812
  get onUnhandledRequest() {
2803
- return this.client.onUnhandledRequest;
2813
+ return this.implementation.onUnhandledRequest;
2804
2814
  }
2805
2815
  set onUnhandledRequest(onUnhandledRequest) {
2806
- this.client.onUnhandledRequest = onUnhandledRequest;
2816
+ this.implementation.onUnhandledRequest = onUnhandledRequest;
2807
2817
  }
2808
2818
  get platform() {
2809
- return this.client.platform;
2819
+ return this.implementation.platform;
2810
2820
  }
2811
2821
  get isRunning() {
2812
- return this.client.isRunning;
2822
+ return this.implementation.isRunning;
2813
2823
  }
2814
2824
  async start() {
2815
2825
  if (this.isRunning) {
2816
2826
  return;
2817
2827
  }
2818
- await this.client.start();
2828
+ await this.implementation.start();
2819
2829
  }
2820
2830
  async stop() {
2821
2831
  if (!this.isRunning) {
2822
2832
  return;
2823
2833
  }
2824
2834
  await this.clear();
2825
- await this.client.stop();
2835
+ await this.implementation.stop();
2826
2836
  }
2827
2837
  get = ((path) => {
2828
- return this.client.get(path);
2838
+ return this.implementation.get(path);
2829
2839
  });
2830
2840
  post = ((path) => {
2831
- return this.client.post(path);
2841
+ return this.implementation.post(path);
2832
2842
  });
2833
2843
  patch = ((path) => {
2834
- return this.client.patch(path);
2844
+ return this.implementation.patch(path);
2835
2845
  });
2836
2846
  put = ((path) => {
2837
- return this.client.put(path);
2847
+ return this.implementation.put(path);
2838
2848
  });
2839
2849
  delete = ((path) => {
2840
- return this.client.delete(path);
2850
+ return this.implementation.delete(path);
2841
2851
  });
2842
2852
  head = ((path) => {
2843
- return this.client.head(path);
2853
+ return this.implementation.head(path);
2844
2854
  });
2845
2855
  options = ((path) => {
2846
- return this.client.options(path);
2856
+ return this.implementation.options(path);
2847
2857
  });
2848
2858
  checkTimes() {
2849
2859
  return new Promise((resolve, reject) => {
2850
2860
  try {
2851
- this.client.checkTimes();
2861
+ this.implementation.checkTimes();
2852
2862
  resolve();
2853
2863
  } catch (error) {
2854
2864
  reject(error);
@@ -2856,7 +2866,7 @@ var RemoteHttpInterceptor = class {
2856
2866
  });
2857
2867
  }
2858
2868
  async clear() {
2859
- await this.client.clear();
2869
+ await this.implementation.clear();
2860
2870
  }
2861
2871
  };
2862
2872
  var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
@@ -2920,12 +2930,13 @@ var InvalidJSONError = class extends http.InvalidJSONError {
2920
2930
  /* istanbul ignore next -- @preserve */
2921
2931
 
2922
2932
  exports.DisabledRequestSavingError = DisabledRequestSavingError_default;
2933
+ exports.HttpTimesCheckError = HttpTimesCheckError_default;
2923
2934
  exports.InvalidFormDataError = InvalidFormDataError;
2924
2935
  exports.InvalidJSONError = InvalidJSONError;
2925
2936
  exports.NotRunningHttpInterceptorError = NotRunningHttpInterceptorError_default;
2926
2937
  exports.RequestSavingSafeLimitExceededError = RequestSavingSafeLimitExceededError_default;
2927
2938
  exports.RunningHttpInterceptorError = RunningHttpInterceptorError_default;
2928
- exports.TimesCheckError = TimesCheckError_default;
2939
+ exports.TimesCheckError = TimesCheckError;
2929
2940
  exports.UnknownHttpInterceptorPlatformError = UnknownHttpInterceptorPlatformError_default;
2930
2941
  exports.UnknownHttpInterceptorTypeError = UnknownHttpInterceptorTypeError_default;
2931
2942
  exports.UnregisteredBrowserServiceWorkerError = UnregisteredBrowserServiceWorkerError_default;