msw 2.3.1 → 2.3.3
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/core/{GraphQLHandler-Dq_WRbKe.d.mts → GraphQLHandler-L3AUWt2v.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-COiPfZ8k.d.ts → GraphQLHandler-UgnlXhlx.d.ts} +1 -1
- package/lib/core/{HttpResponse-B07UKAkU.d.ts → HttpResponse-B58aIqZM.d.ts} +6 -5
- package/lib/core/{HttpResponse-C7niBMwb.d.mts → HttpResponse-fnOXxh4-.d.mts} +6 -5
- package/lib/core/HttpResponse.d.mts +2 -1
- package/lib/core/HttpResponse.d.ts +2 -1
- package/lib/core/SetupApi.d.mts +2 -1
- package/lib/core/SetupApi.d.ts +2 -1
- package/lib/core/getResponse.d.mts +2 -1
- package/lib/core/getResponse.d.ts +2 -1
- package/lib/core/graphql.d.mts +3 -2
- package/lib/core/graphql.d.ts +3 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +3 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +3 -2
- package/lib/core/handlers/HttpHandler.d.mts +2 -1
- package/lib/core/handlers/HttpHandler.d.ts +2 -1
- package/lib/core/handlers/RequestHandler.d.mts +2 -1
- package/lib/core/handlers/RequestHandler.d.ts +2 -1
- package/lib/core/handlers/RequestHandler.js +18 -25
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +21 -26
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +2 -1
- package/lib/core/http.d.ts +2 -1
- package/lib/core/index.d.mts +3 -2
- package/lib/core/index.d.ts +3 -2
- package/lib/core/passthrough.d.mts +2 -1
- package/lib/core/passthrough.d.ts +2 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +4 -2
- package/lib/core/utils/HttpResponse/decorators.d.ts +4 -2
- package/lib/core/utils/HttpResponse/decorators.js +16 -6
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +16 -6
- package/lib/core/utils/HttpResponse/decorators.mjs.map +1 -1
- package/lib/core/utils/cookieStore.d.mts +5 -0
- package/lib/core/utils/cookieStore.d.ts +5 -0
- package/lib/core/utils/cookieStore.js +176 -0
- package/lib/core/utils/cookieStore.js.map +1 -0
- package/lib/core/utils/cookieStore.mjs +146 -0
- package/lib/core/utils/cookieStore.mjs.map +1 -0
- package/lib/core/utils/executeHandlers.d.mts +2 -1
- package/lib/core/utils/executeHandlers.d.ts +2 -1
- package/lib/core/utils/handleRequest.d.mts +2 -1
- package/lib/core/utils/handleRequest.d.ts +2 -1
- package/lib/core/utils/handleRequest.js +2 -2
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs +2 -2
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/internal/isIterable.d.mts +16 -2
- package/lib/core/utils/internal/isIterable.d.ts +16 -2
- package/lib/core/utils/internal/isIterable.js +1 -1
- package/lib/core/utils/internal/isIterable.js.map +1 -1
- package/lib/core/utils/internal/isIterable.mjs +1 -1
- package/lib/core/utils/internal/isIterable.mjs.map +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +3 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +3 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +2 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +2 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +2 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +2 -1
- package/lib/core/utils/request/getRequestCookies.d.mts +1 -6
- package/lib/core/utils/request/getRequestCookies.d.ts +1 -6
- package/lib/core/utils/request/getRequestCookies.js +22 -20
- package/lib/core/utils/request/getRequestCookies.js.map +1 -1
- package/lib/core/utils/request/getRequestCookies.mjs +22 -20
- package/lib/core/utils/request/getRequestCookies.mjs.map +1 -1
- package/lib/core/utils/request/storeResponseCookies.d.mts +3 -0
- package/lib/core/utils/request/storeResponseCookies.d.ts +3 -0
- package/lib/core/utils/request/{readResponseCookies.js → storeResponseCookies.js} +12 -9
- package/lib/core/utils/request/storeResponseCookies.js.map +1 -0
- package/lib/core/utils/request/storeResponseCookies.mjs +12 -0
- package/lib/core/utils/request/storeResponseCookies.mjs.map +1 -0
- package/lib/iife/index.js +12204 -345
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +7 -7
- package/src/core/handlers/RequestHandler.ts +51 -44
- package/src/core/utils/HttpResponse/decorators.ts +32 -16
- package/src/core/utils/cookieStore.ts +212 -0
- package/src/core/utils/handleRequest.ts +3 -3
- package/src/core/utils/internal/isIterable.ts +22 -2
- package/src/core/utils/request/getRequestCookies.ts +32 -35
- package/src/core/utils/request/storeResponseCookies.ts +17 -0
- package/lib/core/utils/request/readResponseCookies.d.mts +0 -3
- package/lib/core/utils/request/readResponseCookies.d.ts +0 -3
- package/lib/core/utils/request/readResponseCookies.js.map +0 -1
- package/lib/core/utils/request/readResponseCookies.mjs +0 -9
- package/lib/core/utils/request/readResponseCookies.mjs.map +0 -1
- package/src/core/utils/request/getRequestCookies.node.test.ts +0 -29
- package/src/core/utils/request/getRequestCookies.test.ts +0 -64
- package/src/core/utils/request/readResponseCookies.ts +0 -9
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { H as HttpResponseInit } from '../../HttpResponse-
|
|
1
|
+
import { H as HttpResponseInit } from '../../HttpResponse-B58aIqZM.js';
|
|
2
|
+
import '../internal/isIterable.js';
|
|
2
3
|
import '../../typeUtils.js';
|
|
3
4
|
|
|
5
|
+
declare const kSetCookie: unique symbol;
|
|
4
6
|
interface HttpResponseDecoratedInit extends HttpResponseInit {
|
|
5
7
|
status: number;
|
|
6
8
|
statusText: string;
|
|
@@ -9,4 +11,4 @@ interface HttpResponseDecoratedInit extends HttpResponseInit {
|
|
|
9
11
|
declare function normalizeResponseInit(init?: HttpResponseInit): HttpResponseDecoratedInit;
|
|
10
12
|
declare function decorateResponse(response: Response, init: HttpResponseDecoratedInit): Response;
|
|
11
13
|
|
|
12
|
-
export { type HttpResponseDecoratedInit, decorateResponse, normalizeResponseInit };
|
|
14
|
+
export { type HttpResponseDecoratedInit, decorateResponse, kSetCookie, normalizeResponseInit };
|
|
@@ -29,12 +29,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var decorators_exports = {};
|
|
30
30
|
__export(decorators_exports, {
|
|
31
31
|
decorateResponse: () => decorateResponse,
|
|
32
|
+
kSetCookie: () => kSetCookie,
|
|
32
33
|
normalizeResponseInit: () => normalizeResponseInit
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(decorators_exports);
|
|
35
36
|
var import_statuses = __toESM(require("@bundled-es-modules/statuses"));
|
|
36
37
|
var import_headers_polyfill = require("headers-polyfill");
|
|
37
38
|
const { message } = import_statuses.default;
|
|
39
|
+
const kSetCookie = Symbol("kSetCookie");
|
|
38
40
|
function normalizeResponseInit(init = {}) {
|
|
39
41
|
const status = init?.status || 200;
|
|
40
42
|
const statusText = init?.statusText || message[status] || "";
|
|
@@ -54,12 +56,20 @@ function decorateResponse(response, init) {
|
|
|
54
56
|
writable: false
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const responseCookies = init.headers.get("set-cookie");
|
|
60
|
+
if (responseCookies) {
|
|
61
|
+
Object.defineProperty(response, kSetCookie, {
|
|
62
|
+
value: responseCookies,
|
|
63
|
+
enumerable: false,
|
|
64
|
+
writable: false
|
|
65
|
+
});
|
|
66
|
+
if (typeof document !== "undefined") {
|
|
67
|
+
const responseCookiePairs = import_headers_polyfill.Headers.prototype.getSetCookie.call(
|
|
68
|
+
init.headers
|
|
69
|
+
);
|
|
70
|
+
for (const cookieString of responseCookiePairs) {
|
|
71
|
+
document.cookie = cookieString;
|
|
72
|
+
}
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
75
|
return response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport { Headers as HeadersPolyfill } from 'headers-polyfill'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nexport const kSetCookie = Symbol('kSetCookie')\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 const responseCookies = init.headers.get('set-cookie')\n\n if (responseCookies) {\n // Record the raw \"Set-Cookie\" response header provided\n // in the HeadersInit. This is later used to store these cookies\n // in cookie jar and return the right cookies in the \"cookies\"\n // response resolver argument.\n Object.defineProperty(response, kSetCookie, {\n value: responseCookies,\n enumerable: false,\n writable: false,\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 responseCookiePairs = HeadersPolyfill.prototype.getSetCookie.call(\n init.headers,\n )\n\n for (const cookieString of responseCookiePairs) {\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\n return response\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,8BAA2C;AAG3C,MAAM,EAAE,QAAQ,IAAI,gBAAAA;AAEb,MAAM,aAAa,OAAO,YAAY;AAQtC,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;AAEA,QAAM,kBAAkB,KAAK,QAAQ,IAAI,YAAY;AAErD,MAAI,iBAAiB;AAKnB,WAAO,eAAe,UAAU,YAAY;AAAA,MAC1C,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAGD,QAAI,OAAO,aAAa,aAAa;AAMnC,YAAM,sBAAsB,wBAAAC,QAAgB,UAAU,aAAa;AAAA,QACjE,KAAK;AAAA,MACP;AAEA,iBAAW,gBAAgB,qBAAqB;AAG9C,iBAAS,SAAS;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["statuses","HeadersPolyfill"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import statuses from "@bundled-es-modules/statuses";
|
|
2
2
|
import { Headers as HeadersPolyfill } from "headers-polyfill";
|
|
3
3
|
const { message } = statuses;
|
|
4
|
+
const kSetCookie = Symbol("kSetCookie");
|
|
4
5
|
function normalizeResponseInit(init = {}) {
|
|
5
6
|
const status = init?.status || 200;
|
|
6
7
|
const statusText = init?.statusText || message[status] || "";
|
|
@@ -20,18 +21,27 @@ function decorateResponse(response, init) {
|
|
|
20
21
|
writable: false
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const responseCookies = init.headers.get("set-cookie");
|
|
25
|
+
if (responseCookies) {
|
|
26
|
+
Object.defineProperty(response, kSetCookie, {
|
|
27
|
+
value: responseCookies,
|
|
28
|
+
enumerable: false,
|
|
29
|
+
writable: false
|
|
30
|
+
});
|
|
31
|
+
if (typeof document !== "undefined") {
|
|
32
|
+
const responseCookiePairs = HeadersPolyfill.prototype.getSetCookie.call(
|
|
33
|
+
init.headers
|
|
34
|
+
);
|
|
35
|
+
for (const cookieString of responseCookiePairs) {
|
|
36
|
+
document.cookie = cookieString;
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
return response;
|
|
32
41
|
}
|
|
33
42
|
export {
|
|
34
43
|
decorateResponse,
|
|
44
|
+
kSetCookie,
|
|
35
45
|
normalizeResponseInit
|
|
36
46
|
};
|
|
37
47
|
//# sourceMappingURL=decorators.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport { Headers as HeadersPolyfill } from 'headers-polyfill'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nexport const kSetCookie = Symbol('kSetCookie')\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 const responseCookies = init.headers.get('set-cookie')\n\n if (responseCookies) {\n // Record the raw \"Set-Cookie\" response header provided\n // in the HeadersInit. This is later used to store these cookies\n // in cookie jar and return the right cookies in the \"cookies\"\n // response resolver argument.\n Object.defineProperty(response, kSetCookie, {\n value: responseCookies,\n enumerable: false,\n writable: false,\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 responseCookiePairs = HeadersPolyfill.prototype.getSetCookie.call(\n init.headers,\n )\n\n for (const cookieString of responseCookiePairs) {\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\n return response\n}\n"],"mappings":"AAAA,OAAO,cAAc;AACrB,SAAS,WAAW,uBAAuB;AAG3C,MAAM,EAAE,QAAQ,IAAI;AAEb,MAAM,aAAa,OAAO,YAAY;AAQtC,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;AAEA,QAAM,kBAAkB,KAAK,QAAQ,IAAI,YAAY;AAErD,MAAI,iBAAiB;AAKnB,WAAO,eAAe,UAAU,YAAY;AAAA,MAC1C,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAGD,QAAI,OAAO,aAAa,aAAa;AAMnC,YAAM,sBAAsB,gBAAgB,UAAU,aAAa;AAAA,QACjE,KAAK;AAAA,MACP;AAEA,iBAAW,gBAAgB,qBAAqB;AAG9C,iBAAS,SAAS;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var cookieStore_exports = {};
|
|
30
|
+
__export(cookieStore_exports, {
|
|
31
|
+
cookieStore: () => cookieStore
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(cookieStore_exports);
|
|
34
|
+
var import_outvariant = require("outvariant");
|
|
35
|
+
var import_is_node_process = require("is-node-process");
|
|
36
|
+
var import_tough_cookie = __toESM(require("@bundled-es-modules/tough-cookie"));
|
|
37
|
+
const { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } = import_tough_cookie.default;
|
|
38
|
+
class WebStorageCookieStore extends Store {
|
|
39
|
+
storage;
|
|
40
|
+
storageKey;
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
(0, import_outvariant.invariant)(
|
|
44
|
+
typeof localStorage !== "undefined",
|
|
45
|
+
"Failed to create a WebStorageCookieStore: `localStorage` is not available in this environment. This is likely an issue with MSW. Please report it on GitHub: https://github.com/mswjs/msw/issues"
|
|
46
|
+
);
|
|
47
|
+
this.synchronous = true;
|
|
48
|
+
this.storage = localStorage;
|
|
49
|
+
this.storageKey = "__msw-cookie-store__";
|
|
50
|
+
}
|
|
51
|
+
findCookie(domain, path, key, callback) {
|
|
52
|
+
try {
|
|
53
|
+
const store2 = this.getStore();
|
|
54
|
+
const cookies = this.filterCookiesFromList(store2, { domain, path, key });
|
|
55
|
+
callback(null, cookies[0] || null);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
callback(error, null);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
findCookies(domain, path, allowSpecialUseDomain, callback) {
|
|
63
|
+
if (!domain) {
|
|
64
|
+
callback(null, []);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const store2 = this.getStore();
|
|
69
|
+
const results = this.filterCookiesFromList(store2, {
|
|
70
|
+
domain,
|
|
71
|
+
path
|
|
72
|
+
});
|
|
73
|
+
callback(null, results);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (error instanceof Error) {
|
|
76
|
+
callback(error, []);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
putCookie(cookie, callback) {
|
|
81
|
+
try {
|
|
82
|
+
const store2 = this.getStore();
|
|
83
|
+
store2.push(cookie);
|
|
84
|
+
this.updateStore(store2);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (error instanceof Error) {
|
|
87
|
+
callback(error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
updateCookie(oldCookie, newCookie, callback) {
|
|
92
|
+
this.putCookie(newCookie, callback);
|
|
93
|
+
}
|
|
94
|
+
removeCookie(domain, path, key, callback) {
|
|
95
|
+
try {
|
|
96
|
+
const store2 = this.getStore();
|
|
97
|
+
const nextStore = this.deleteCookiesFromList(store2, { domain, path, key });
|
|
98
|
+
this.updateStore(nextStore);
|
|
99
|
+
callback(null);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
callback(error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
removeCookies(domain, path, callback) {
|
|
107
|
+
try {
|
|
108
|
+
const store2 = this.getStore();
|
|
109
|
+
const nextStore = this.deleteCookiesFromList(store2, { domain, path });
|
|
110
|
+
this.updateStore(nextStore);
|
|
111
|
+
callback(null);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof Error) {
|
|
114
|
+
callback(error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
getAllCookies(callback) {
|
|
119
|
+
try {
|
|
120
|
+
callback(null, this.getStore());
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error instanceof Error) {
|
|
123
|
+
callback(error, []);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
getStore() {
|
|
128
|
+
try {
|
|
129
|
+
const json = this.storage.getItem(this.storageKey);
|
|
130
|
+
if (json == null) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
const rawCookies = JSON.parse(json);
|
|
134
|
+
const cookies = [];
|
|
135
|
+
for (const rawCookie of rawCookies) {
|
|
136
|
+
const cookie = Cookie.fromJSON(rawCookie);
|
|
137
|
+
if (cookie != null) {
|
|
138
|
+
cookies.push(cookie);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return cookies;
|
|
142
|
+
} catch {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
updateStore(nextStore) {
|
|
147
|
+
this.storage.setItem(
|
|
148
|
+
this.storageKey,
|
|
149
|
+
JSON.stringify(nextStore.map((cookie) => cookie.toJSON()))
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
filterCookiesFromList(cookies, matches) {
|
|
153
|
+
const result = [];
|
|
154
|
+
for (const cookie of cookies) {
|
|
155
|
+
if (matches.domain && !domainMatch(matches.domain, cookie.domain || "")) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (matches.path && !pathMatch(matches.path, cookie.path || "")) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (matches.key && cookie.key !== matches.key) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
result.push(cookie);
|
|
165
|
+
}
|
|
166
|
+
console.log("filter result:", { cookies, matches, result });
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
deleteCookiesFromList(cookies, matches) {
|
|
170
|
+
const matchingCookies = this.filterCookiesFromList(cookies, matches);
|
|
171
|
+
return cookies.filter((cookie) => !matchingCookies.includes(cookie));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const store = (0, import_is_node_process.isNodeProcess)() ? new MemoryCookieStore() : new WebStorageCookieStore();
|
|
175
|
+
const cookieStore = new CookieJar(store);
|
|
176
|
+
//# sourceMappingURL=cookieStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/cookieStore.ts"],"sourcesContent":["import { invariant } from 'outvariant'\nimport { isNodeProcess } from 'is-node-process'\nimport toughCookie, {\n type Cookie as CookieInstance,\n} from '@bundled-es-modules/tough-cookie'\n\nconst { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } =\n toughCookie\n\n/**\n * Custom cookie store that uses the Web Storage API.\n * @see https://github.com/expo/tough-cookie-web-storage-store\n */\nclass WebStorageCookieStore extends Store {\n private storage: Storage\n private storageKey: string\n\n constructor() {\n super()\n\n invariant(\n typeof localStorage !== 'undefined',\n 'Failed to create a WebStorageCookieStore: `localStorage` is not available in this environment. This is likely an issue with MSW. Please report it on GitHub: https://github.com/mswjs/msw/issues',\n )\n\n this.synchronous = true\n this.storage = localStorage\n this.storageKey = '__msw-cookie-store__'\n }\n\n findCookie(\n domain: string,\n path: string,\n key: string,\n callback: (error: Error | null, cookie: CookieInstance | null) => void,\n ): void {\n try {\n const store = this.getStore()\n const cookies = this.filterCookiesFromList(store, { domain, path, key })\n callback(null, cookies[0] || null)\n } catch (error) {\n if (error instanceof Error) {\n callback(error, null)\n }\n }\n }\n\n findCookies(\n domain: string,\n path: string,\n allowSpecialUseDomain: boolean,\n callback: (error: Error | null, cookie: Array<CookieInstance>) => void,\n ): void {\n if (!domain) {\n callback(null, [])\n return\n }\n\n try {\n const store = this.getStore()\n const results = this.filterCookiesFromList(store, {\n domain,\n path,\n })\n callback(null, results)\n } catch (error) {\n if (error instanceof Error) {\n callback(error, [])\n }\n }\n }\n\n putCookie(\n cookie: CookieInstance,\n callback: (error: Error | null) => void,\n ): void {\n try {\n const store = this.getStore()\n store.push(cookie)\n this.updateStore(store)\n } catch (error) {\n if (error instanceof Error) {\n callback(error)\n }\n }\n }\n\n updateCookie(\n oldCookie: CookieInstance,\n newCookie: CookieInstance,\n callback: (error: Error | null) => void,\n ): void {\n this.putCookie(newCookie, callback)\n }\n\n removeCookie(\n domain: string,\n path: string,\n key: string,\n callback: (error: Error | null) => void,\n ): void {\n try {\n const store = this.getStore()\n const nextStore = this.deleteCookiesFromList(store, { domain, path, key })\n this.updateStore(nextStore)\n callback(null)\n } catch (error) {\n if (error instanceof Error) {\n callback(error)\n }\n }\n }\n\n removeCookies(\n domain: string,\n path: string,\n callback: (error: Error | null) => void,\n ): void {\n try {\n const store = this.getStore()\n const nextStore = this.deleteCookiesFromList(store, { domain, path })\n this.updateStore(nextStore)\n callback(null)\n } catch (error) {\n if (error instanceof Error) {\n callback(error)\n }\n }\n }\n\n getAllCookies(\n callback: (error: Error | null, cookie: Array<CookieInstance>) => void,\n ): void {\n try {\n callback(null, this.getStore())\n } catch (error) {\n if (error instanceof Error) {\n callback(error, [])\n }\n }\n }\n\n private getStore(): Array<CookieInstance> {\n try {\n const json = this.storage.getItem(this.storageKey)\n\n if (json == null) {\n return []\n }\n\n const rawCookies = JSON.parse(json) as Array<Record<string, any>>\n const cookies: Array<CookieInstance> = []\n for (const rawCookie of rawCookies) {\n const cookie = Cookie.fromJSON(rawCookie)\n if (cookie != null) {\n cookies.push(cookie)\n }\n }\n return cookies\n } catch {\n return []\n }\n }\n\n private updateStore(nextStore: Array<CookieInstance>) {\n this.storage.setItem(\n this.storageKey,\n JSON.stringify(nextStore.map((cookie) => cookie.toJSON())),\n )\n }\n\n private filterCookiesFromList(\n cookies: Array<CookieInstance>,\n matches: { domain?: string; path?: string; key?: string },\n ): Array<CookieInstance> {\n const result: Array<CookieInstance> = []\n\n for (const cookie of cookies) {\n if (matches.domain && !domainMatch(matches.domain, cookie.domain || '')) {\n continue\n }\n\n if (matches.path && !pathMatch(matches.path, cookie.path || '')) {\n continue\n }\n\n if (matches.key && cookie.key !== matches.key) {\n continue\n }\n\n result.push(cookie)\n }\n\n console.log('filter result:', { cookies, matches, result })\n\n return result\n }\n\n private deleteCookiesFromList(\n cookies: Array<CookieInstance>,\n matches: { domain?: string; path?: string; key?: string },\n ) {\n const matchingCookies = this.filterCookiesFromList(cookies, matches)\n return cookies.filter((cookie) => !matchingCookies.includes(cookie))\n }\n}\n\nconst store = isNodeProcess()\n ? new MemoryCookieStore()\n : new WebStorageCookieStore()\n\nexport const cookieStore = new CookieJar(store)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA0B;AAC1B,6BAA8B;AAC9B,0BAEO;AAEP,MAAM,EAAE,QAAQ,WAAW,OAAO,mBAAmB,aAAa,UAAU,IAC1E,oBAAAA;AAMF,MAAM,8BAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAER,cAAc;AACZ,UAAM;AAEN;AAAA,MACE,OAAO,iBAAiB;AAAA,MACxB;AAAA,IACF;AAEA,SAAK,cAAc;AACnB,SAAK,UAAU;AACf,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,WACE,QACA,MACA,KACA,UACM;AACN,QAAI;AACF,YAAMC,SAAQ,KAAK,SAAS;AAC5B,YAAM,UAAU,KAAK,sBAAsBA,QAAO,EAAE,QAAQ,MAAM,IAAI,CAAC;AACvE,eAAS,MAAM,QAAQ,CAAC,KAAK,IAAI;AAAA,IACnC,SAAS,OAAO;AACd,UAAI,iBAAiB,OAAO;AAC1B,iBAAS,OAAO,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YACE,QACA,MACA,uBACA,UACM;AACN,QAAI,CAAC,QAA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AAO;AACnE,WAAO,QAAQ,OAAO,CAAC,WAAW,CAAC,gBAAgB,SAAS,MAAM,CAAC;AAAA,EACrE;AACF;AAEA,MAAM,YAAQ,sCAAc,IACxB,IAAI,kBAAkB,IACtB,IAAI,sBAAsB;AAEvB,MAAM,cAAc,IAAI,UAAU,KAAK;","names":["toughCookie","store"]}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { invariant } from "outvariant";
|
|
2
|
+
import { isNodeProcess } from "is-node-process";
|
|
3
|
+
import toughCookie from "@bundled-es-modules/tough-cookie";
|
|
4
|
+
const { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } = toughCookie;
|
|
5
|
+
class WebStorageCookieStore extends Store {
|
|
6
|
+
storage;
|
|
7
|
+
storageKey;
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
invariant(
|
|
11
|
+
typeof localStorage !== "undefined",
|
|
12
|
+
"Failed to create a WebStorageCookieStore: `localStorage` is not available in this environment. This is likely an issue with MSW. Please report it on GitHub: https://github.com/mswjs/msw/issues"
|
|
13
|
+
);
|
|
14
|
+
this.synchronous = true;
|
|
15
|
+
this.storage = localStorage;
|
|
16
|
+
this.storageKey = "__msw-cookie-store__";
|
|
17
|
+
}
|
|
18
|
+
findCookie(domain, path, key, callback) {
|
|
19
|
+
try {
|
|
20
|
+
const store2 = this.getStore();
|
|
21
|
+
const cookies = this.filterCookiesFromList(store2, { domain, path, key });
|
|
22
|
+
callback(null, cookies[0] || null);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error instanceof Error) {
|
|
25
|
+
callback(error, null);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
findCookies(domain, path, allowSpecialUseDomain, callback) {
|
|
30
|
+
if (!domain) {
|
|
31
|
+
callback(null, []);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const store2 = this.getStore();
|
|
36
|
+
const results = this.filterCookiesFromList(store2, {
|
|
37
|
+
domain,
|
|
38
|
+
path
|
|
39
|
+
});
|
|
40
|
+
callback(null, results);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
callback(error, []);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
putCookie(cookie, callback) {
|
|
48
|
+
try {
|
|
49
|
+
const store2 = this.getStore();
|
|
50
|
+
store2.push(cookie);
|
|
51
|
+
this.updateStore(store2);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error instanceof Error) {
|
|
54
|
+
callback(error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
updateCookie(oldCookie, newCookie, callback) {
|
|
59
|
+
this.putCookie(newCookie, callback);
|
|
60
|
+
}
|
|
61
|
+
removeCookie(domain, path, key, callback) {
|
|
62
|
+
try {
|
|
63
|
+
const store2 = this.getStore();
|
|
64
|
+
const nextStore = this.deleteCookiesFromList(store2, { domain, path, key });
|
|
65
|
+
this.updateStore(nextStore);
|
|
66
|
+
callback(null);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error instanceof Error) {
|
|
69
|
+
callback(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
removeCookies(domain, path, callback) {
|
|
74
|
+
try {
|
|
75
|
+
const store2 = this.getStore();
|
|
76
|
+
const nextStore = this.deleteCookiesFromList(store2, { domain, path });
|
|
77
|
+
this.updateStore(nextStore);
|
|
78
|
+
callback(null);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error instanceof Error) {
|
|
81
|
+
callback(error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
getAllCookies(callback) {
|
|
86
|
+
try {
|
|
87
|
+
callback(null, this.getStore());
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error instanceof Error) {
|
|
90
|
+
callback(error, []);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getStore() {
|
|
95
|
+
try {
|
|
96
|
+
const json = this.storage.getItem(this.storageKey);
|
|
97
|
+
if (json == null) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const rawCookies = JSON.parse(json);
|
|
101
|
+
const cookies = [];
|
|
102
|
+
for (const rawCookie of rawCookies) {
|
|
103
|
+
const cookie = Cookie.fromJSON(rawCookie);
|
|
104
|
+
if (cookie != null) {
|
|
105
|
+
cookies.push(cookie);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return cookies;
|
|
109
|
+
} catch {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
updateStore(nextStore) {
|
|
114
|
+
this.storage.setItem(
|
|
115
|
+
this.storageKey,
|
|
116
|
+
JSON.stringify(nextStore.map((cookie) => cookie.toJSON()))
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
filterCookiesFromList(cookies, matches) {
|
|
120
|
+
const result = [];
|
|
121
|
+
for (const cookie of cookies) {
|
|
122
|
+
if (matches.domain && !domainMatch(matches.domain, cookie.domain || "")) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (matches.path && !pathMatch(matches.path, cookie.path || "")) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (matches.key && cookie.key !== matches.key) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
result.push(cookie);
|
|
132
|
+
}
|
|
133
|
+
console.log("filter result:", { cookies, matches, result });
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
deleteCookiesFromList(cookies, matches) {
|
|
137
|
+
const matchingCookies = this.filterCookiesFromList(cookies, matches);
|
|
138
|
+
return cookies.filter((cookie) => !matchingCookies.includes(cookie));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const store = isNodeProcess() ? new MemoryCookieStore() : new WebStorageCookieStore();
|
|
142
|
+
const cookieStore = new CookieJar(store);
|
|
143
|
+
export {
|
|
144
|
+
cookieStore
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=cookieStore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/cookieStore.ts"],"sourcesContent":["import { invariant } from 'outvariant'\nimport { isNodeProcess } from 'is-node-process'\nimport toughCookie, {\n type Cookie as CookieInstance,\n} from '@bundled-es-modules/tough-cookie'\n\nconst { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } =\n toughCookie\n\n/**\n * Custom cookie store that uses the Web Storage API.\n * @see https://github.com/expo/tough-cookie-web-storage-store\n */\nclass WebStorageCookieStore extends Store {\n private storage: Storage\n private storageKey: string\n\n constructor() {\n super()\n\n invariant(\n typeof localStorage !== 'undefined',\n 'Failed to create a WebStorageCookieStore: `localStorage` is not available in this environment. This is likely an issue with MSW. Please report it on GitHub: https://github.com/mswjs/msw/issues',\n )\n\n this.synchronous = true\n this.storage = localStorage\n this.storageKey = '__msw-cookie-store__'\n }\n\n findCookie(\n domain: string,\n path: string,\n key: string,\n callback: (error: Error | null, cookie: CookieInstance | null) => void,\n ): void {\n try {\n const store = this.getStore()\n const cookies = this.filterCookiesFromList(store, { domain, path, key })\n callback(null, cookies[0] || null)\n } catch (error) {\n if (error instanceof Error) {\n callback(error, null)\n }\n }\n }\n\n findCookies(\n domain: string,\n path: string,\n allowSpecialUseDomain: boolean,\n callback: (error: Error | null, cookie: Array<CookieInstance>) => void,\n ): void {\n if (!domain) {\n callback(null, [])\n return\n }\n\n try {\n const store = this.getStore()\n const results = this.filterCookiesFromList(store, {\n domain,\n path,\n })\n callback(null, results)\n } catch (error) {\n if (error instanceof Error) {\n callback(error, [])\n }\n }\n }\n\n putCookie(\n cookie: CookieInstance,\n callback: (error: Error | null) => void,\n ): void {\n try {\n const store = this.getStore()\n store.push(cookie)\n this.updateStore(store)\n } catch (error) {\n if (error instanceof Error) {\n callback(error)\n }\n }\n }\n\n updateCookie(\n oldCookie: CookieInstance,\n newCookie: CookieInstance,\n callback: (error: Error | null) => void,\n ): void {\n this.putCookie(newCookie, callback)\n }\n\n removeCookie(\n domain: string,\n path: string,\n key: string,\n callback: (error: Error | null) => void,\n ): void {\n try {\n const store = this.getStore()\n const nextStore = this.deleteCookiesFromList(store, { domain, path, key })\n this.updateStore(nextStore)\n callback(null)\n } catch (error) {\n if (error instanceof Error) {\n callback(error)\n }\n }\n }\n\n removeCookies(\n domain: string,\n path: string,\n callback: (error: Error | null) => void,\n ): void {\n try {\n const store = this.getStore()\n const nextStore = this.deleteCookiesFromList(store, { domain, path })\n this.updateStore(nextStore)\n callback(null)\n } catch (error) {\n if (error instanceof Error) {\n callback(error)\n }\n }\n }\n\n getAllCookies(\n callback: (error: Error | null, cookie: Array<CookieInstance>) => void,\n ): void {\n try {\n callback(null, this.getStore())\n } catch (error) {\n if (error instanceof Error) {\n callback(error, [])\n }\n }\n }\n\n private getStore(): Array<CookieInstance> {\n try {\n const json = this.storage.getItem(this.storageKey)\n\n if (json == null) {\n return []\n }\n\n const rawCookies = JSON.parse(json) as Array<Record<string, any>>\n const cookies: Array<CookieInstance> = []\n for (const rawCookie of rawCookies) {\n const cookie = Cookie.fromJSON(rawCookie)\n if (cookie != null) {\n cookies.push(cookie)\n }\n }\n return cookies\n } catch {\n return []\n }\n }\n\n private updateStore(nextStore: Array<CookieInstance>) {\n this.storage.setItem(\n this.storageKey,\n JSON.stringify(nextStore.map((cookie) => cookie.toJSON())),\n )\n }\n\n private filterCookiesFromList(\n cookies: Array<CookieInstance>,\n matches: { domain?: string; path?: string; key?: string },\n ): Array<CookieInstance> {\n const result: Array<CookieInstance> = []\n\n for (const cookie of cookies) {\n if (matches.domain && !domainMatch(matches.domain, cookie.domain || '')) {\n continue\n }\n\n if (matches.path && !pathMatch(matches.path, cookie.path || '')) {\n continue\n }\n\n if (matches.key && cookie.key !== matches.key) {\n continue\n }\n\n result.push(cookie)\n }\n\n console.log('filter result:', { cookies, matches, result })\n\n return result\n }\n\n private deleteCookiesFromList(\n cookies: Array<CookieInstance>,\n matches: { domain?: string; path?: string; key?: string },\n ) {\n const matchingCookies = this.filterCookiesFromList(cookies, matches)\n return cookies.filter((cookie) => !matchingCookies.includes(cookie))\n }\n}\n\nconst store = isNodeProcess()\n ? new MemoryCookieStore()\n : new WebStorageCookieStore()\n\nexport const cookieStore = new CookieJar(store)\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,OAAO,iBAEA;AAEP,MAAM,EAAE,QAAQ,WAAW,OAAO,mBAAmB,aAAa,UAAU,IAC1E;AAMF,MAAM,8BAA8B,MAAM;AAAA,EAChC;AAAA,EACA;AAAA,EAER,cAAc;AACZ,UAAM;AAEN;AAAA,MACE,OAAO,iBAAiB;AAAA,MACxB;AAAA,IACF;AAEA,SAAK,cAAc;AACnB,SAAK,UAAU;AACf,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,WACE,QACA,MACA,KACA,UACM;AACN,QAAI;AACF,YAAMA,SAAQ,KAAK,SAAS;AAC5B,YAAM,UAAU,KAAK,sBAAsBA,QAAO,EAAE,QAAQ,MAAM,IAAI,CAAC;AACvE,eAAS,MAAM,QAAQ,CAAC,KAAK,IAAI;AAAA,IACnC,SAAS,OAAO;AACd,UAAI,iBAAiB,OAAO;AAC1B,iBAAS,OAAO,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YACE,QACA,MACA,uBACA,UACM;AACN,QAAI,CAAC,QAAQ;AACX,eAAS,MAAM,CAAC,CAAC;AACjB;AAAA,IACF;AAEA,QAAI;AACF,YAAMA,SAAQ,KAAK,SAAS;AAC5B,YAAM,UAAU,KAAK,sBAAsBA,QAAO;AAAA,QAChD;AAAA,QACA;AAAA,MACF,CAAC;AACD,eAAS,MAAM,OAAO;AAAA,IACxB,SAAS,OAAO;AACd,UAAI,iBAAiB,OAAO;AAC1B,iBAAS,OAAO,CAAC,CAAC;A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as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { h as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-fnOXxh4-.mjs';
|
|
2
|
+
import './internal/isIterable.mjs';
|
|
2
3
|
import '../typeUtils.mjs';
|
|
@@ -1,2 +1,3 @@
|
|
|
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-B58aIqZM.js';
|
|
2
|
+
import './internal/isIterable.js';
|
|
2
3
|
import '../typeUtils.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
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-fnOXxh4-.mjs';
|
|
3
3
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.mjs';
|
|
4
4
|
import { RequiredDeep } from '../typeUtils.mjs';
|
|
5
|
+
import './internal/isIterable.mjs';
|
|
5
6
|
import './request/onUnhandledRequest.mjs';
|
|
6
7
|
|
|
7
8
|
interface HandleRequestOptions {
|
|
@@ -1,7 +1,8 @@
|
|
|
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-B58aIqZM.js';
|
|
3
3
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
|
|
4
4
|
import { RequiredDeep } from '../typeUtils.js';
|
|
5
|
+
import './internal/isIterable.js';
|
|
5
6
|
import './request/onUnhandledRequest.js';
|
|
6
7
|
|
|
7
8
|
interface HandleRequestOptions {
|
|
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(handleRequest_exports);
|
|
|
24
24
|
var import_until = require("@open-draft/until");
|
|
25
25
|
var import_executeHandlers = require("./executeHandlers.js");
|
|
26
26
|
var import_onUnhandledRequest = require("./request/onUnhandledRequest.js");
|
|
27
|
-
var
|
|
27
|
+
var import_storeResponseCookies = require("./request/storeResponseCookies.js");
|
|
28
28
|
async function handleRequest(request, requestId, handlers, options, emitter, handleRequestOptions) {
|
|
29
29
|
emitter.emit("request:start", { request, requestId });
|
|
30
30
|
if (request.headers.get("x-msw-intention") === "bypass") {
|
|
@@ -66,7 +66,7 @@ async function handleRequest(request, requestId, handlers, options, emitter, han
|
|
|
66
66
|
handleRequestOptions?.onPassthroughResponse?.(request);
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
(0,
|
|
69
|
+
(0, import_storeResponseCookies.storeResponseCookies)(request, response);
|
|
70
70
|
emitter.emit("request:match", { request, requestId });
|
|
71
71
|
const requiredLookupResult = lookupResult.data;
|
|
72
72
|
const transformedResponse = handleRequestOptions?.transformResponse?.(response) || response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { RequestHandler } from '../handlers/RequestHandler'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { RequestHandler } from '../handlers/RequestHandler'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { storeResponseCookies } from './request/storeResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<RequestHandler>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e. wrapped in \"bypass()\") as-is.\n if (request.headers.get('x-msw-intention') === 'bypass') {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Resolve a mocked response from the list of request handlers.\n const lookupResult = await until(() => {\n return executeHandlers({\n request,\n requestId,\n handlers,\n resolutionContext: handleRequestOptions?.resolutionContext,\n })\n })\n\n if (lookupResult.error) {\n // Allow developers to react to unhandled exceptions in request handlers.\n emitter.emit('unhandledException', {\n error: lookupResult.error,\n request,\n requestId,\n })\n throw lookupResult.error\n }\n\n // If the handler lookup returned nothing, no request handler was found\n // matching this request. Report the request as unhandled.\n if (!lookupResult.data) {\n await onUnhandledRequest(request, options.onUnhandledRequest)\n emitter.emit('request:unhandled', { request, requestId })\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n const { response } = lookupResult.data\n\n // When the handled request returned no mocked response, warn the developer,\n // as it may be an oversight on their part. Perform the request as-is.\n if (!response) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Perform the request as-is when the developer explicitly returned \"req.passthrough()\".\n // This produces no warning as the request was handled.\n if (\n response.status === 302 &&\n response.headers.get('x-msw-intention') === 'passthrough'\n ) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Store all the received response cookies in the cookie jar.\n storeResponseCookies(request, response)\n\n emitter.emit('request:match', { request, requestId })\n\n const requiredLookupResult =\n lookupResult.data as RequiredDeep<HandlersExecutionResult>\n\n const transformedResponse =\n handleRequestOptions?.transformResponse?.(response) ||\n (response as any as Response)\n\n handleRequestOptions?.onMockedResponse?.(\n transformedResponse,\n requiredLookupResult,\n )\n\n emitter.emit('request:end', { request, requestId })\n\n return transformedResponse\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAKtB,6BAAyD;AACzD,gCAAmC;AACnC,kCAAqC;AAqCrC,eAAsB,cACpB,SACA,WACA,UACA,SACA,SACA,sBAC+B;AAC/B,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAGpD,MAAI,QAAQ,QAAQ,IAAI,iBAAiB,MAAM,UAAU;AACvD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,QAAM,eAAe,UAAM,oBAAM,MAAM;AACrC,eAAO,wCAAgB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,sBAAsB;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AAED,MAAI,aAAa,OAAO;AAEtB,YAAQ,KAAK,sBAAsB;AAAA,MACjC,OAAO,aAAa;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa;AAAA,EACrB;AAIA,MAAI,CAAC,aAAa,MAAM;AACtB,cAAM,8CAAmB,SAAS,QAAQ,kBAAkB;AAC5D,YAAQ,KAAK,qBAAqB,EAAE,SAAS,UAAU,CAAC;AACxD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,IAAI,aAAa;AAIlC,MAAI,CAAC,UAAU;AACb,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAIA,MACE,SAAS,WAAW,OACpB,SAAS,QAAQ,IAAI,iBAAiB,MAAM,eAC5C;AACA,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,wDAAqB,SAAS,QAAQ;AAEtC,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAEpD,QAAM,uBACJ,aAAa;AAEf,QAAM,sBACJ,sBAAsB,oBAAoB,QAAQ,KACjD;AAEH,wBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAEA,UAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAElD,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { until } from "@open-draft/until";
|
|
2
2
|
import { executeHandlers } from './executeHandlers.mjs';
|
|
3
3
|
import { onUnhandledRequest } from './request/onUnhandledRequest.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { storeResponseCookies } from './request/storeResponseCookies.mjs';
|
|
5
5
|
async function handleRequest(request, requestId, handlers, options, emitter, handleRequestOptions) {
|
|
6
6
|
emitter.emit("request:start", { request, requestId });
|
|
7
7
|
if (request.headers.get("x-msw-intention") === "bypass") {
|
|
@@ -43,7 +43,7 @@ async function handleRequest(request, requestId, handlers, options, emitter, han
|
|
|
43
43
|
handleRequestOptions?.onPassthroughResponse?.(request);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
storeResponseCookies(request, response);
|
|
47
47
|
emitter.emit("request:match", { request, requestId });
|
|
48
48
|
const requiredLookupResult = lookupResult.data;
|
|
49
49
|
const transformedResponse = handleRequestOptions?.transformResponse?.(response) || response;
|