msw 2.2.3 → 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/cli/init.js +1 -1
- 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/core/{GraphQLHandler-AenIUdwE.d.mts → GraphQLHandler-BumTfgY4.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-jOzqbxSK.d.ts → GraphQLHandler-DqVT0Gbq.d.ts} +1 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.d.ts +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -2
- package/lib/core/index.d.ts +2 -2
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.js +4 -1
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +4 -1
- package/lib/core/utils/HttpResponse/decorators.mjs.map +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/iife/index.js +21 -23
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +7 -3
- package/package.json +6 -9
- 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/core/utils/HttpResponse/decorators.ts +8 -4
- package/src/mockServiceWorker.js +6 -2
- package/src/browser/utils/requestIntegrityCheck.ts +0 -23
- /package/lib/core/{HttpResponse-wcp03c7-.d.mts → HttpResponse-C94XLD-W.d.mts} +0 -0
- /package/lib/core/{HttpResponse-_514VQ9z.d.ts → HttpResponse-jHZ0p2dL.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OperationTypeNode, DocumentNode, GraphQLError } from 'graphql';
|
|
2
|
-
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-
|
|
2
|
+
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-C94XLD-W.mjs';
|
|
3
3
|
import { Match, Path } from './utils/matching/matchRequestUrl.mjs';
|
|
4
4
|
|
|
5
5
|
interface ParsedGraphQLQuery {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OperationTypeNode, DocumentNode, GraphQLError } from 'graphql';
|
|
2
|
-
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-
|
|
2
|
+
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-jHZ0p2dL.js';
|
|
3
3
|
import { Match, Path } from './utils/matching/matchRequestUrl.js';
|
|
4
4
|
|
|
5
5
|
interface ParsedGraphQLQuery {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
1
|
+
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-C94XLD-W.mjs';
|
|
2
2
|
import './typeUtils.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
1
|
+
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-jHZ0p2dL.js';
|
|
2
2
|
import './typeUtils.js';
|
package/lib/core/SetupApi.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventMap, Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { R as RequestHandler, g as RequestHandlerDefaultInfo } from './HttpResponse-
|
|
2
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo } from './HttpResponse-C94XLD-W.mjs';
|
|
3
3
|
import { LifeCycleEventEmitter } from './sharedOptions.mjs';
|
|
4
4
|
import { Disposable } from './utils/internal/Disposable.mjs';
|
|
5
5
|
import './typeUtils.mjs';
|
package/lib/core/SetupApi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventMap, Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { R as RequestHandler, g as RequestHandlerDefaultInfo } from './HttpResponse-
|
|
2
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo } from './HttpResponse-jHZ0p2dL.js';
|
|
3
3
|
import { LifeCycleEventEmitter } from './sharedOptions.js';
|
|
4
4
|
import { Disposable } from './utils/internal/Disposable.js';
|
|
5
5
|
import './typeUtils.js';
|
package/lib/core/graphql.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentNode } from 'graphql';
|
|
2
|
-
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
3
|
-
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-
|
|
2
|
+
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-C94XLD-W.mjs';
|
|
3
|
+
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-BumTfgY4.mjs';
|
|
4
4
|
import { Path } from './utils/matching/matchRequestUrl.mjs';
|
|
5
5
|
import './typeUtils.mjs';
|
|
6
6
|
|
package/lib/core/graphql.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentNode } from 'graphql';
|
|
2
|
-
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
3
|
-
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-
|
|
2
|
+
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-jHZ0p2dL.js';
|
|
3
|
+
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-DqVT0Gbq.js';
|
|
4
4
|
import { Path } from './utils/matching/matchRequestUrl.js';
|
|
5
5
|
import './typeUtils.js';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
import '../HttpResponse-
|
|
2
|
+
import '../HttpResponse-C94XLD-W.mjs';
|
|
3
3
|
import '../utils/matching/matchRequestUrl.mjs';
|
|
4
|
-
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-
|
|
4
|
+
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-BumTfgY4.mjs';
|
|
5
5
|
import '../typeUtils.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
import '../HttpResponse-
|
|
2
|
+
import '../HttpResponse-jHZ0p2dL.js';
|
|
3
3
|
import '../utils/matching/matchRequestUrl.js';
|
|
4
|
-
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-
|
|
4
|
+
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-DqVT0Gbq.js';
|
|
5
5
|
import '../typeUtils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, i as ResponseResolutionContext } from '../HttpResponse-
|
|
1
|
+
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, i as ResponseResolutionContext } from '../HttpResponse-C94XLD-W.mjs';
|
|
2
2
|
import { Path, Match, PathParams } from '../utils/matching/matchRequestUrl.mjs';
|
|
3
3
|
import '../typeUtils.mjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, i as ResponseResolutionContext } from '../HttpResponse-
|
|
1
|
+
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, i as ResponseResolutionContext } from '../HttpResponse-jHZ0p2dL.js';
|
|
2
2
|
import { Path, Match, PathParams } from '../utils/matching/matchRequestUrl.js';
|
|
3
3
|
import '../typeUtils.js';
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-
|
|
1
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-C94XLD-W.mjs';
|
|
2
2
|
import '../typeUtils.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-
|
|
1
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-jHZ0p2dL.js';
|
|
2
2
|
import '../typeUtils.js';
|
package/lib/core/http.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
1
|
+
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-C94XLD-W.mjs';
|
|
2
2
|
import { HttpHandler, HttpRequestResolverExtras } from './handlers/HttpHandler.mjs';
|
|
3
3
|
import { PathParams, Path } from './utils/matching/matchRequestUrl.mjs';
|
|
4
4
|
import './typeUtils.mjs';
|
package/lib/core/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
1
|
+
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-jHZ0p2dL.js';
|
|
2
2
|
import { HttpHandler, HttpRequestResolverExtras } from './handlers/HttpHandler.js';
|
|
3
3
|
import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
|
|
4
4
|
import './typeUtils.js';
|
package/lib/core/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { SetupApi } from './SetupApi.mjs';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-C94XLD-W.mjs';
|
|
3
3
|
export { HttpRequestHandler, HttpResponseResolver, http } from './http.mjs';
|
|
4
4
|
export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.mjs';
|
|
5
5
|
export { GraphQLRequestHandler, GraphQLResponseResolver, graphql } from './graphql.mjs';
|
|
6
|
-
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-
|
|
6
|
+
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-BumTfgY4.mjs';
|
|
7
7
|
export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.mjs';
|
|
8
8
|
export { HandleRequestOptions, handleRequest } from './utils/handleRequest.mjs';
|
|
9
9
|
export { getResponse } from './getResponse.mjs';
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { SetupApi } from './SetupApi.js';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-jHZ0p2dL.js';
|
|
3
3
|
export { HttpRequestHandler, HttpResponseResolver, http } from './http.js';
|
|
4
4
|
export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.js';
|
|
5
5
|
export { GraphQLRequestHandler, GraphQLResponseResolver, graphql } from './graphql.js';
|
|
6
|
-
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-
|
|
6
|
+
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-DqVT0Gbq.js';
|
|
7
7
|
export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.js';
|
|
8
8
|
export { HandleRequestOptions, handleRequest } from './utils/handleRequest.js';
|
|
9
9
|
export { getResponse } from './getResponse.js';
|
|
@@ -33,6 +33,7 @@ __export(decorators_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(decorators_exports);
|
|
35
35
|
var import_statuses = __toESM(require("@bundled-es-modules/statuses"));
|
|
36
|
+
var import_headers_polyfill = require("headers-polyfill");
|
|
36
37
|
const { message } = import_statuses.default;
|
|
37
38
|
function normalizeResponseInit(init = {}) {
|
|
38
39
|
const status = init?.status || 200;
|
|
@@ -54,7 +55,9 @@ function decorateResponse(response, init) {
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
if (typeof document !== "undefined") {
|
|
57
|
-
const responseCookies =
|
|
58
|
+
const responseCookies = import_headers_polyfill.Headers.prototype.getSetCookie.call(
|
|
59
|
+
init.headers
|
|
60
|
+
);
|
|
58
61
|
for (const cookieString of responseCookies) {
|
|
59
62
|
document.cookie = cookieString;
|
|
60
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow to mock the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n // Cookie forwarding is only relevant in the browser.\n if (typeof document !== 'undefined') {\n // Write the mocked response cookies to the document.\n //
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\nimport { Headers as HeadersPolyfill } from 'headers-polyfill'\n\nconst { message } = statuses\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow to mock the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n // Cookie forwarding is only relevant in the browser.\n if (typeof document !== 'undefined') {\n // Write the mocked response cookies to the document.\n // Use `headers-polyfill` to get the Set-Cookie header value correctly.\n // This is an alternative until TypeScript 5.2\n // and Node.js v20 become the minimum supported version\n // and getSetCookie in Headers can be used directly.\n const responseCookies = HeadersPolyfill.prototype.getSetCookie.call(\n init.headers,\n )\n\n for (const cookieString of responseCookies) {\n // No need to parse the cookie headers because it's defined\n // as the valid cookie string to begin with.\n document.cookie = cookieString\n }\n }\n\n return response\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AAErB,8BAA2C;AAE3C,MAAM,EAAE,QAAQ,IAAI,gBAAAA;AAQb,SAAS,sBACd,OAAyB,CAAC,GACC;AAC3B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,aAAa,MAAM,cAAc,QAAQ,MAAM,KAAK;AAC1D,QAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AAEzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,iBACd,UACA,MACU;AAEV,MAAI,KAAK,MAAM;AACb,WAAO,eAAe,UAAU,QAAQ;AAAA,MACtC,OAAO,KAAK;AAAA,MACZ,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAGA,MAAI,OAAO,aAAa,aAAa;AAMnC,UAAM,kBAAkB,wBAAAC,QAAgB,UAAU,aAAa;AAAA,MAC7D,KAAK;AAAA,IACP;AAEA,eAAW,gBAAgB,iBAAiB;AAG1C,eAAS,SAAS;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":["statuses","HeadersPolyfill"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import statuses from "@bundled-es-modules/statuses";
|
|
2
|
+
import { Headers as HeadersPolyfill } from "headers-polyfill";
|
|
2
3
|
const { message } = statuses;
|
|
3
4
|
function normalizeResponseInit(init = {}) {
|
|
4
5
|
const status = init?.status || 200;
|
|
@@ -20,7 +21,9 @@ function decorateResponse(response, init) {
|
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
if (typeof document !== "undefined") {
|
|
23
|
-
const responseCookies =
|
|
24
|
+
const responseCookies = HeadersPolyfill.prototype.getSetCookie.call(
|
|
25
|
+
init.headers
|
|
26
|
+
);
|
|
24
27
|
for (const cookieString of responseCookies) {
|
|
25
28
|
document.cookie = cookieString;
|
|
26
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow to mock the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n // Cookie forwarding is only relevant in the browser.\n if (typeof document !== 'undefined') {\n // Write the mocked response cookies to the document.\n //
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\nimport { Headers as HeadersPolyfill } from 'headers-polyfill'\n\nconst { message } = statuses\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow to mock the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n // Cookie forwarding is only relevant in the browser.\n if (typeof document !== 'undefined') {\n // Write the mocked response cookies to the document.\n // Use `headers-polyfill` to get the Set-Cookie header value correctly.\n // This is an alternative until TypeScript 5.2\n // and Node.js v20 become the minimum supported version\n // and getSetCookie in Headers can be used directly.\n const responseCookies = HeadersPolyfill.prototype.getSetCookie.call(\n init.headers,\n )\n\n for (const cookieString of responseCookies) {\n // No need to parse the cookie headers because it's defined\n // as the valid cookie string to begin with.\n document.cookie = cookieString\n }\n }\n\n return response\n}\n"],"mappings":"AAAA,OAAO,cAAc;AAErB,SAAS,WAAW,uBAAuB;AAE3C,MAAM,EAAE,QAAQ,IAAI;AAQb,SAAS,sBACd,OAAyB,CAAC,GACC;AAC3B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,aAAa,MAAM,cAAc,QAAQ,MAAM,KAAK;AAC1D,QAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AAEzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,iBACd,UACA,MACU;AAEV,MAAI,KAAK,MAAM;AACb,WAAO,eAAe,UAAU,QAAQ;AAAA,MACtC,OAAO,KAAK;AAAA,MACZ,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAGA,MAAI,OAAO,aAAa,aAAa;AAMnC,UAAM,kBAAkB,gBAAgB,UAAU,aAAa;AAAA,MAC7D,KAAK;AAAA,IACP;AAEA,eAAW,gBAAgB,iBAAiB;AAG1C,eAAS,SAAS;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { h as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { h as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-C94XLD-W.mjs';
|
|
2
2
|
import '../typeUtils.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { h as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { h as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-jHZ0p2dL.js';
|
|
2
2
|
import '../typeUtils.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { h as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { h as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-C94XLD-W.mjs';
|
|
3
3
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.mjs';
|
|
4
4
|
import { RequiredDeep } from '../typeUtils.mjs';
|
|
5
5
|
import './request/onUnhandledRequest.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { h as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { h as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-jHZ0p2dL.js';
|
|
3
3
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
|
|
4
4
|
import { RequiredDeep } from '../typeUtils.js';
|
|
5
5
|
import './request/onUnhandledRequest.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-BumTfgY4.mjs';
|
|
3
|
+
import '../../HttpResponse-C94XLD-W.mjs';
|
|
4
4
|
import '../../typeUtils.mjs';
|
|
5
5
|
import '../matching/matchRequestUrl.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-DqVT0Gbq.js';
|
|
3
|
+
import '../../HttpResponse-jHZ0p2dL.js';
|
|
4
4
|
import '../../typeUtils.js';
|
|
5
5
|
import '../matching/matchRequestUrl.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-C94XLD-W.mjs';
|
|
2
2
|
import '../../typeUtils.mjs';
|
|
3
3
|
|
|
4
4
|
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-jHZ0p2dL.js';
|
|
2
2
|
import '../../typeUtils.js';
|
|
3
3
|
|
|
4
4
|
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
package/lib/iife/index.js
CHANGED
|
@@ -5792,7 +5792,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
5792
5792
|
});
|
|
5793
5793
|
}
|
|
5794
5794
|
if (typeof document !== "undefined") {
|
|
5795
|
-
const responseCookies =
|
|
5795
|
+
const responseCookies = Headers2.prototype.getSetCookie.call(
|
|
5796
|
+
init.headers
|
|
5797
|
+
);
|
|
5796
5798
|
for (const cookieString of responseCookies) {
|
|
5797
5799
|
document.cookie = cookieString;
|
|
5798
5800
|
}
|
|
@@ -6203,18 +6205,21 @@ This exception has been gracefully handled as a 500 response, however, it's stro
|
|
|
6203
6205
|
};
|
|
6204
6206
|
};
|
|
6205
6207
|
|
|
6206
|
-
// src/browser/utils/
|
|
6207
|
-
async function
|
|
6208
|
+
// src/browser/utils/checkWorkerIntegrity.ts
|
|
6209
|
+
async function checkWorkerIntegrity(context) {
|
|
6208
6210
|
context.workerChannel.send("INTEGRITY_CHECK_REQUEST");
|
|
6209
|
-
const { payload
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
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.`
|
|
6215
6221
|
);
|
|
6216
6222
|
}
|
|
6217
|
-
return serviceWorker;
|
|
6218
6223
|
}
|
|
6219
6224
|
|
|
6220
6225
|
// src/browser/setupWorker/start/createResponseListener.ts
|
|
@@ -6310,19 +6315,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
6310
6315
|
}
|
|
6311
6316
|
window.clearInterval(context.keepAliveInterval);
|
|
6312
6317
|
});
|
|
6313
|
-
|
|
6314
|
-
(
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
The mocking is still enabled, but it's highly recommended that you update your Service Worker by running:
|
|
6320
|
-
|
|
6321
|
-
$ npx msw init <PUBLIC_DIR>
|
|
6322
|
-
|
|
6323
|
-
This is necessary to ensure that the Service Worker is in sync with the library to guarantee its stability.
|
|
6324
|
-
If this message still persists after updating, please report an issue: https://github.com/open-draft/msw/issues `);
|
|
6325
|
-
}
|
|
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
|
+
});
|
|
6326
6324
|
context.keepAliveInterval = window.setInterval(
|
|
6327
6325
|
() => context.workerChannel.send("KEEPALIVE_REQUEST"),
|
|
6328
6326
|
5e3
|