@zimic/interceptor 0.17.0-canary.3 → 0.17.0-canary.4

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/http.mjs CHANGED
@@ -14,7 +14,7 @@ var RunningHttpInterceptorError = class extends Error {
14
14
  __name(this, "RunningHttpInterceptorError");
15
15
  }
16
16
  constructor(additionalMessage) {
17
- super(`The interceptor is running.${additionalMessage}`);
17
+ super(`The interceptor is running. ${additionalMessage}`);
18
18
  this.name = "RunningHttpInterceptorError";
19
19
  }
20
20
  };
@@ -2557,12 +2557,12 @@ var LocalHttpInterceptor = class {
2557
2557
  this.client = new HttpInterceptorClient_default({
2558
2558
  store: this.store,
2559
2559
  baseURL,
2560
- createWorker() {
2560
+ createWorker: /* @__PURE__ */ __name(() => {
2561
2561
  return this.store.getOrCreateLocalWorker({});
2562
- },
2563
- deleteWorker() {
2562
+ }, "createWorker"),
2563
+ deleteWorker: /* @__PURE__ */ __name(() => {
2564
2564
  this.store.deleteLocalWorker();
2565
- },
2565
+ }, "deleteWorker"),
2566
2566
  Handler: LocalHttpRequestHandler_default,
2567
2567
  onUnhandledRequest: options.onUnhandledRequest,
2568
2568
  requestSaving: options.requestSaving
@@ -2645,20 +2645,22 @@ var RemoteHttpInterceptor = class {
2645
2645
  }
2646
2646
  store = new HttpInterceptorStore_default();
2647
2647
  client;
2648
+ _auth;
2648
2649
  constructor(options) {
2650
+ this._auth = options.auth;
2649
2651
  const baseURL = new URL(options.baseURL);
2650
2652
  this.client = new HttpInterceptorClient_default({
2651
2653
  store: this.store,
2652
2654
  baseURL,
2653
- createWorker() {
2655
+ createWorker: /* @__PURE__ */ __name(() => {
2654
2656
  return this.store.getOrCreateRemoteWorker({
2655
2657
  serverURL: new URL(baseURL.origin),
2656
- auth: options.auth
2658
+ auth: this._auth
2657
2659
  });
2658
- },
2659
- deleteWorker() {
2660
+ }, "createWorker"),
2661
+ deleteWorker: /* @__PURE__ */ __name(() => {
2660
2662
  this.store.deleteRemoteWorker(baseURL, { auth: options.auth });
2661
- },
2663
+ }, "deleteWorker"),
2662
2664
  Handler: RemoteHttpRequestHandler_default,
2663
2665
  onUnhandledRequest: options.onUnhandledRequest,
2664
2666
  requestSaving: options.requestSaving
@@ -2679,6 +2681,27 @@ var RemoteHttpInterceptor = class {
2679
2681
  set requestSaving(requestSaving) {
2680
2682
  this.client.requestSaving = requestSaving;
2681
2683
  }
2684
+ get auth() {
2685
+ return this._auth;
2686
+ }
2687
+ set auth(auth) {
2688
+ const cannotChangeAuthWhileRunningMessage = "Did you forget to call `await interceptor.stop()` before changing the authentication parameters?";
2689
+ if (this.isRunning) {
2690
+ throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
2691
+ }
2692
+ if (!auth) {
2693
+ this._auth = void 0;
2694
+ return;
2695
+ }
2696
+ this._auth = new Proxy(auth, {
2697
+ set: /* @__PURE__ */ __name((target, property, value) => {
2698
+ if (this.isRunning) {
2699
+ throw new RunningHttpInterceptorError_default(cannotChangeAuthWhileRunningMessage);
2700
+ }
2701
+ return Reflect.set(target, property, value);
2702
+ }, "set")
2703
+ });
2704
+ }
2682
2705
  get onUnhandledRequest() {
2683
2706
  return this.client.onUnhandledRequest;
2684
2707
  }