Skip to content

Commit

Permalink
hotfix(deps): regenerate mockServiceWorker.js (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
r4ai authored Nov 17, 2024
1 parent dbf22e0 commit 97f9892
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import tseslint from "typescript-eslint"

export default tseslint.config(
gitignore(),
{
ignores: ["public/mockServiceWorker.js"],
},
{
languageOptions: {
globals: globals.browser,
Expand Down
32 changes: 21 additions & 11 deletions frontend/public/mockServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable unicorn/filename-case */
/* eslint-disable unicorn/no-abusive-eslint-disable */
/* eslint-disable */
/* tslint:disable */

/**
* Mock Service Worker.
Expand All @@ -9,8 +8,8 @@
* - Please do NOT serve this file on production.
*/

const PACKAGE_VERSION = "2.4.10"
const INTEGRITY_CHECKSUM = "26357c79639bfa20d64c0efca2a87423"
const PACKAGE_VERSION = "2.6.4"
const INTEGRITY_CHECKSUM = "ca7800994cc8bfb5eb961e037c877074"
const IS_MOCKED_RESPONSE = Symbol("isMockedResponse")
const activeClientIds = new Set()

Expand Down Expand Up @@ -63,7 +62,12 @@ self.addEventListener("message", async function (event) {

sendToClient(client, {
type: "MOCKING_ENABLED",
payload: true,
payload: {
client: {
id: client.id,
frameType: client.frameType,
},
},
})
break
}
Expand Down Expand Up @@ -156,6 +160,10 @@ async function handleRequest(event, requestId) {
async function resolveMainClient(event) {
const client = await self.clients.get(event.clientId)

if (activeClientIds.has(event.clientId)) {
return client
}

if (client?.frameType === "top-level") {
return client
}
Expand Down Expand Up @@ -184,12 +192,14 @@ async function getResponse(event, client, requestId) {
const requestClone = request.clone()

function passthrough() {
const headers = Object.fromEntries(requestClone.headers.entries())

// Remove internal MSW request header so the passthrough request
// complies with any potential CORS preflight checks on the server.
// Some servers forbid unknown request headers.
delete headers["x-msw-intention"]
// Cast the request headers to a new Headers instance
// so the headers can be manipulated with.
const headers = new Headers(requestClone.headers)

// Remove the "accept" header value that marked this request as passthrough.
// This prevents request alteration and also keeps it compliant with the
// user-defined CORS policies.
headers.delete("accept", "msw/passthrough")

return fetch(requestClone, { headers })
}
Expand Down

0 comments on commit 97f9892

Please sign in to comment.