@zimic/interceptor 1.4.0 → 1.4.1-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.
package/dist/http.mjs CHANGED
@@ -324,9 +324,6 @@ function isServerSide() {
324
324
  function isClientSide() {
325
325
  return typeof window !== "undefined" && typeof document !== "undefined";
326
326
  }
327
- function isGlobalFileAvailable() {
328
- return globalThis.File !== void 0;
329
- }
330
327
 
331
328
  // src/utils/logging.ts
332
329
  var logger = new Logger_default({
@@ -358,7 +355,7 @@ function stringifyValueToLog(value, options = {}) {
358
355
  if (value instanceof HttpFormData) {
359
356
  return `FormData ${stringifyValueToLog(value.toObject())}`;
360
357
  }
361
- if (isGlobalFileAvailable() && value instanceof File) {
358
+ if (value instanceof File) {
362
359
  return `File { name: '${value.name}', type: '${value.type}', size: ${value.size} }`;
363
360
  }
364
361
  if (value instanceof Blob) {
@@ -1955,12 +1952,6 @@ var UnsupportedResponseBypassError = class extends Error {
1955
1952
  };
1956
1953
  var UnsupportedResponseBypassError_default = UnsupportedResponseBypassError;
1957
1954
 
1958
- // src/utils/crypto.ts
1959
- var importCrypto = createCachedDynamicImport_default(async () => {
1960
- const globalCrypto = globalThis.crypto;
1961
- return globalCrypto ?? await import('crypto');
1962
- });
1963
-
1964
1955
  // src/utils/fetch.ts
1965
1956
  function deserializeRequest(serializedRequest) {
1966
1957
  const deserializedBody = serializedRequest.body ? convertBase64ToArrayBuffer(serializedRequest.body) : null;
@@ -2240,7 +2231,7 @@ var WebSocketHandler = class {
2240
2231
  const listeners = this.channelListeners[message.channel]?.event ?? /* @__PURE__ */ new Set();
2241
2232
  const listenerPromises = Array.from(listeners, async (listener) => {
2242
2233
  const replyData = await listener(message, socket);
2243
- await this.reply(message, replyData, { sockets: [socket] });
2234
+ this.reply(message, replyData, { sockets: [socket] });
2244
2235
  });
2245
2236
  await Promise.all(listenerPromises);
2246
2237
  }
@@ -2250,8 +2241,7 @@ var WebSocketHandler = class {
2250
2241
  });
2251
2242
  await Promise.all(closingPromises);
2252
2243
  }
2253
- async createEventMessage(channel, eventData) {
2254
- const crypto = await importCrypto();
2244
+ createEventMessage(channel, eventData) {
2255
2245
  const eventMessage = {
2256
2246
  id: crypto.randomUUID(),
2257
2247
  channel,
@@ -2259,12 +2249,12 @@ var WebSocketHandler = class {
2259
2249
  };
2260
2250
  return eventMessage;
2261
2251
  }
2262
- async send(channel, eventData, options = {}) {
2263
- const event = await this.createEventMessage(channel, eventData);
2252
+ send(channel, eventData, options = {}) {
2253
+ const event = this.createEventMessage(channel, eventData);
2264
2254
  this.sendMessage(event, options.sockets);
2265
2255
  }
2266
2256
  async request(channel, requestData, options = {}) {
2267
- const request = await this.createEventMessage(channel, requestData);
2257
+ const request = this.createEventMessage(channel, requestData);
2268
2258
  this.sendMessage(request, options.sockets);
2269
2259
  const response = await this.waitForReply(channel, request, options.sockets);
2270
2260
  return response.data;
@@ -2311,14 +2301,13 @@ var WebSocketHandler = class {
2311
2301
  isReplyMessage(message) {
2312
2302
  return "requestId" in message;
2313
2303
  }
2314
- async reply(request, replyData, options) {
2315
- const reply = await this.createReplyMessage(request, replyData);
2304
+ reply(request, replyData, options) {
2305
+ const reply = this.createReplyMessage(request, replyData);
2316
2306
  if (this.isRunning) {
2317
2307
  this.sendMessage(reply, options.sockets);
2318
2308
  }
2319
2309
  }
2320
- async createReplyMessage(request, replyData) {
2321
- const crypto = await importCrypto();
2310
+ createReplyMessage(request, replyData) {
2322
2311
  const replyMessage = {
2323
2312
  id: crypto.randomUUID(),
2324
2313
  channel: request.channel,
@@ -2502,7 +2491,6 @@ var RemoteHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
2502
2491
  throw new NotRunningHttpInterceptorError_default();
2503
2492
  }
2504
2493
  validatePathParams_default(path);
2505
- const crypto = await importCrypto();
2506
2494
  const handler = {
2507
2495
  id: crypto.randomUUID(),
2508
2496
  baseURL: interceptor.baseURLAsString,
@@ -2906,8 +2894,6 @@ var InvalidJSONError = class extends InvalidJSONError$1 {
2906
2894
  * Ignoring because checking unknown platforms is not configured in our test setup. */
2907
2895
  /* istanbul ignore else -- @preserve
2908
2896
  * Since we start the internal worker once and do not stop it, tests may not be able exercise this branch. */
2909
- /* istanbul ignore next -- @preserve
2910
- * Ignoring as Node.js >=20 provides a global crypto and the import fallback won't run. */
2911
2897
  /* istanbul ignore else -- @preserve
2912
2898
  * An unauthorized close event is the only one we expect to happen here. */
2913
2899
  /* istanbul ignore else -- @preserve