msw 2.2.4 → 2.2.5

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/lib/iife/index.js CHANGED
@@ -6205,18 +6205,21 @@ This exception has been gracefully handled as a 500 response, however, it's stro
6205
6205
  };
6206
6206
  };
6207
6207
 
6208
- // src/browser/utils/requestIntegrityCheck.ts
6209
- async function requestIntegrityCheck(context, serviceWorker) {
6208
+ // src/browser/utils/checkWorkerIntegrity.ts
6209
+ async function checkWorkerIntegrity(context) {
6210
6210
  context.workerChannel.send("INTEGRITY_CHECK_REQUEST");
6211
- const { payload: actualChecksum } = await context.events.once(
6212
- "INTEGRITY_CHECK_RESPONSE"
6213
- );
6214
- if (actualChecksum !== "223d191a56023cd36aa88c802961b911") {
6215
- throw new Error(
6216
- `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"223d191a56023cd36aa88c802961b911"}).`
6211
+ const { payload } = await context.events.once("INTEGRITY_CHECK_RESPONSE");
6212
+ if (payload.checksum !== "5db7e6e8385dc04e017ac4823e0e9b29") {
6213
+ devUtils.warn(
6214
+ `The currently registered Service Worker has been generated by a different version of MSW (${payload.packageVersion}) and may not be fully compatible with the installed version.
6215
+
6216
+ It's recommended you update your worker script by running this command:
6217
+
6218
+ \u2022 npx msw init <PUBLIC_DIR>
6219
+
6220
+ You can also automate this process and make the worker script update automatically upon the library installations. Read more: https://mswjs.io/docs/cli/init.`
6217
6221
  );
6218
6222
  }
6219
- return serviceWorker;
6220
6223
  }
6221
6224
 
6222
6225
  // src/browser/setupWorker/start/createResponseListener.ts
@@ -6312,19 +6315,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
6312
6315
  }
6313
6316
  window.clearInterval(context.keepAliveInterval);
6314
6317
  });
6315
- const integrityCheckResult = await until(
6316
- () => requestIntegrityCheck(context, worker)
6317
- );
6318
- if (integrityCheckResult.error) {
6319
- devUtils.error(`Detected outdated Service Worker: ${integrityCheckResult.error.message}
6320
-
6321
- The mocking is still enabled, but it's highly recommended that you update your Service Worker by running:
6322
-
6323
- $ npx msw init <PUBLIC_DIR>
6324
-
6325
- This is necessary to ensure that the Service Worker is in sync with the library to guarantee its stability.
6326
- If this message still persists after updating, please report an issue: https://github.com/open-draft/msw/issues `);
6327
- }
6318
+ await checkWorkerIntegrity(context).catch((error3) => {
6319
+ devUtils.error(
6320
+ "Error while checking the worker script integrity. Please report this on GitHub (https://github.com/mswjs/msw/issues), including the original error below."
6321
+ );
6322
+ console.error(error3);
6323
+ });
6328
6324
  context.keepAliveInterval = window.setInterval(
6329
6325
  () => context.workerChannel.send("KEEPALIVE_REQUEST"),
6330
6326
  5e3