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/browser/index.js +33 -36
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +33 -36
- package/lib/browser/index.mjs.map +1 -1
- package/lib/iife/index.js +18 -22
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +7 -3
- package/package.json +2 -5
- package/src/browser/setupWorker/glossary.ts +4 -1
- package/src/browser/setupWorker/start/createStartHandler.ts +9 -19
- package/src/browser/utils/checkWorkerIntegrity.ts +34 -0
- package/src/mockServiceWorker.js +6 -2
- package/src/browser/utils/requestIntegrityCheck.ts +0 -23
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/
|
|
6209
|
-
async function
|
|
6208
|
+
// src/browser/utils/checkWorkerIntegrity.ts
|
|
6209
|
+
async function checkWorkerIntegrity(context) {
|
|
6210
6210
|
context.workerChannel.send("INTEGRITY_CHECK_REQUEST");
|
|
6211
|
-
const { payload
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
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
|
-
|
|
6316
|
-
(
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
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
|