msw 2.13.3 → 2.13.4
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 +200 -56
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +200 -56
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{HttpResponse-DlRR1D-f.d.mts → HttpResponse-BF4NGRsf.d.mts} +1 -1
- package/lib/core/{HttpResponse-CksOMVAa.d.ts → HttpResponse-yukpQS4a.d.ts} +1 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/experimental/compat.d.mts +2 -2
- package/lib/core/experimental/compat.d.ts +2 -2
- package/lib/core/experimental/compat.js +1 -0
- package/lib/core/experimental/compat.js.map +1 -1
- package/lib/core/experimental/compat.mjs +1 -0
- package/lib/core/experimental/compat.mjs.map +1 -1
- package/lib/core/experimental/define-network.d.mts +2 -2
- package/lib/core/experimental/define-network.d.ts +2 -2
- package/lib/core/experimental/define-network.js +4 -0
- package/lib/core/experimental/define-network.js.map +1 -1
- package/lib/core/experimental/define-network.mjs +6 -0
- package/lib/core/experimental/define-network.mjs.map +1 -1
- package/lib/core/experimental/frames/http-frame.d.mts +2 -2
- package/lib/core/experimental/frames/http-frame.d.ts +2 -2
- package/lib/core/experimental/frames/http-frame.js +2 -0
- package/lib/core/experimental/frames/http-frame.js.map +1 -1
- package/lib/core/experimental/frames/http-frame.mjs +5 -1
- package/lib/core/experimental/frames/http-frame.mjs.map +1 -1
- package/lib/core/experimental/frames/network-frame.d.mts +2 -2
- package/lib/core/experimental/frames/network-frame.d.ts +2 -2
- package/lib/core/experimental/frames/websocket-frame.d.mts +2 -2
- package/lib/core/experimental/frames/websocket-frame.d.ts +2 -2
- package/lib/core/experimental/frames/websocket-frame.js +2 -0
- package/lib/core/experimental/frames/websocket-frame.js.map +1 -1
- package/lib/core/experimental/frames/websocket-frame.mjs +2 -0
- package/lib/core/experimental/frames/websocket-frame.mjs.map +1 -1
- package/lib/core/experimental/handlers-controller.d.mts +1 -1
- package/lib/core/experimental/handlers-controller.d.ts +1 -1
- package/lib/core/experimental/handlers-controller.js +3 -1
- package/lib/core/experimental/handlers-controller.js.map +1 -1
- package/lib/core/experimental/handlers-controller.mjs +3 -1
- package/lib/core/experimental/handlers-controller.mjs.map +1 -1
- package/lib/core/experimental/index.d.mts +2 -2
- package/lib/core/experimental/index.d.ts +2 -2
- package/lib/core/experimental/index.js +0 -1
- package/lib/core/experimental/index.js.map +1 -1
- package/lib/core/experimental/index.mjs +1 -2
- package/lib/core/experimental/index.mjs.map +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.mts +2 -2
- package/lib/core/experimental/on-unhandled-frame.d.ts +2 -2
- package/lib/core/experimental/on-unhandled-frame.js +1 -0
- package/lib/core/experimental/on-unhandled-frame.js.map +1 -1
- package/lib/core/experimental/on-unhandled-frame.mjs +1 -0
- package/lib/core/experimental/on-unhandled-frame.mjs.map +1 -1
- package/lib/core/experimental/setup-api.d.mts +1 -1
- package/lib/core/experimental/setup-api.d.ts +1 -1
- package/lib/core/experimental/setup-api.js +1 -0
- package/lib/core/experimental/setup-api.js.map +1 -1
- package/lib/core/experimental/setup-api.mjs +1 -0
- package/lib/core/experimental/setup-api.mjs.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.mts +2 -2
- package/lib/core/experimental/sources/interceptor-source.d.ts +2 -2
- package/lib/core/experimental/sources/interceptor-source.js.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.mjs +1 -3
- package/lib/core/experimental/sources/interceptor-source.mjs.map +1 -1
- package/lib/core/experimental/sources/network-source.d.mts +2 -2
- package/lib/core/experimental/sources/network-source.d.ts +2 -2
- package/lib/core/experimental/sources/network-source.js +1 -0
- package/lib/core/experimental/sources/network-source.js.map +1 -1
- package/lib/core/experimental/sources/network-source.mjs +2 -0
- package/lib/core/experimental/sources/network-source.mjs.map +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/graphql.js +1 -0
- package/lib/core/graphql.js.map +1 -1
- package/lib/core/graphql.mjs +2 -0
- package/lib/core/graphql.mjs.map +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.js +1 -0
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs +4 -1
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/HttpHandler.js +1 -0
- package/lib/core/handlers/HttpHandler.js.map +1 -1
- package/lib/core/handlers/HttpHandler.mjs +1 -0
- package/lib/core/handlers/HttpHandler.mjs.map +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.js +1 -0
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +2 -0
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/http.js +1 -0
- package/lib/core/http.js.map +1 -1
- package/lib/core/http.mjs +2 -0
- package/lib/core/http.mjs.map +1 -1
- package/lib/core/index.d.mts +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/sse.d.mts +4 -18
- package/lib/core/sse.d.ts +4 -18
- package/lib/core/sse.js +105 -45
- package/lib/core/sse.js.map +1 -1
- package/lib/core/sse.mjs +105 -45
- package/lib/core/sse.mjs.map +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/cookieStore.js.map +1 -1
- package/lib/core/utils/cookieStore.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/executeHandlers.js +1 -0
- package/lib/core/utils/executeHandlers.js.map +1 -1
- package/lib/core/utils/executeHandlers.mjs +1 -0
- package/lib/core/utils/executeHandlers.mjs.map +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- 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/parseMultipartData.js +1 -0
- package/lib/core/utils/internal/parseMultipartData.js.map +1 -1
- package/lib/core/utils/internal/parseMultipartData.mjs +1 -0
- package/lib/core/utils/internal/parseMultipartData.mjs.map +1 -1
- package/lib/core/utils/internal/pipeEvents.js +1 -0
- package/lib/core/utils/internal/pipeEvents.js.map +1 -1
- package/lib/core/utils/internal/pipeEvents.mjs +1 -0
- package/lib/core/utils/internal/pipeEvents.mjs.map +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.js.map +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.mjs.map +1 -1
- package/lib/core/ws/WebSocketClientManager.js.map +1 -1
- package/lib/core/ws/WebSocketClientManager.mjs.map +1 -1
- package/lib/core/ws/WebSocketIndexedDBClientStore.js +1 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.js.map +1 -1
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs +1 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs.map +1 -1
- package/lib/core/ws/WebSocketMemoryClientStore.js +1 -0
- package/lib/core/ws/WebSocketMemoryClientStore.js.map +1 -1
- package/lib/core/ws/WebSocketMemoryClientStore.mjs +1 -0
- package/lib/core/ws/WebSocketMemoryClientStore.mjs.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +1 -1
- package/lib/core/ws/handleWebSocketEvent.js.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.mjs.map +1 -1
- package/lib/core/ws.js.map +1 -1
- package/lib/core/ws.mjs.map +1 -1
- package/lib/iife/index.js +6300 -6076
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs.map +1 -1
- package/lib/shims/cookie.js +152 -62
- package/lib/shims/cookie.mjs +152 -62
- package/package.json +33 -40
- package/src/browser/glossary.ts +1 -1
- package/src/browser/setup-worker.ts +2 -2
- package/src/browser/sources/service-worker-source.ts +125 -28
- package/src/browser/utils/deserializeRequest.ts +0 -1
- package/src/browser/utils/should-invalidate-worker.test.ts +122 -0
- package/src/browser/utils/should-invalidate-worker.ts +13 -0
- package/src/browser/utils/workerChannel.ts +43 -21
- package/src/core/experimental/define-network.ts +10 -2
- package/src/core/experimental/frames/http-frame.test.ts +2 -1
- package/src/core/experimental/frames/http-frame.ts +6 -2
- package/src/core/experimental/frames/websocket-frame.test.ts +2 -4
- package/src/core/experimental/frames/websocket-frame.ts +3 -2
- package/src/core/experimental/handlers-controller.ts +1 -1
- package/src/core/experimental/index.ts +1 -1
- package/src/core/experimental/on-unhandled-frame.test.ts +2 -4
- package/src/core/experimental/setup-api.ts +3 -3
- package/src/core/experimental/sources/interceptor-source.ts +2 -6
- package/src/core/graphql.ts +8 -8
- package/src/core/handlers/GraphQLHandler.test.ts +3 -4
- package/src/core/handlers/GraphQLHandler.ts +15 -11
- package/src/core/handlers/HttpHandler.test.ts +3 -2
- package/src/core/handlers/HttpHandler.ts +7 -7
- package/src/core/handlers/RequestHandler.ts +5 -5
- package/src/core/http.ts +5 -5
- package/src/core/sse.ts +157 -56
- package/src/core/utils/cookieStore.ts +1 -1
- package/src/core/utils/executeHandlers.ts +2 -4
- package/src/core/utils/handleRequest.test.ts +5 -4
- package/src/core/utils/handleRequest.ts +3 -3
- package/src/core/utils/internal/parseGraphQLRequest.test.ts +2 -4
- package/src/core/utils/internal/parseMultipartData.ts +1 -1
- package/src/core/utils/internal/pipeEvents.ts +2 -1
- package/src/core/utils/internal/requestHandlerUtils.ts +1 -1
- package/src/core/utils/request/onUnhandledRequest.test.ts +2 -4
- package/src/core/ws/WebSocketClientManager.test.ts +2 -4
- package/src/core/ws/WebSocketClientManager.ts +1 -1
- package/src/core/ws/WebSocketIndexedDBClientStore.ts +3 -5
- package/src/core/ws/WebSocketMemoryClientStore.ts +3 -5
- package/src/core/ws/handleWebSocketEvent.ts +3 -3
- package/src/core/ws.ts +1 -1
- package/src/native/index.ts +2 -2
- package/src/node/async-handlers-controller.ts +2 -2
- package/src/node/setup-server-common.ts +4 -4
- package/src/node/setup-server.ts +2 -2
- package/lib/core/{network-frame-usYiHS0K.d.ts → on-unhandled-frame-BBR-P3kV.d.ts} +12 -12
- package/lib/core/{network-frame-B7A0ggXE.d.mts → on-unhandled-frame-Cr1KOZ0I.d.mts} +12 -12
package/lib/shims/cookie.mjs
CHANGED
|
@@ -24,17 +24,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// node_modules/.pnpm/cookie@1.
|
|
27
|
+
// node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js
|
|
28
28
|
var require_dist = __commonJS({
|
|
29
|
-
"node_modules/.pnpm/cookie@1.
|
|
29
|
+
"node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js"(exports) {
|
|
30
30
|
"use strict";
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
32
|
+
exports.parseCookie = parseCookie;
|
|
33
|
+
exports.parse = parseCookie;
|
|
34
|
+
exports.stringifyCookie = stringifyCookie;
|
|
35
|
+
exports.stringifySetCookie = stringifySetCookie;
|
|
36
|
+
exports.serialize = stringifySetCookie;
|
|
37
|
+
exports.parseSetCookie = parseSetCookie;
|
|
38
|
+
exports.stringifySetCookie = stringifySetCookie;
|
|
39
|
+
exports.serialize = stringifySetCookie;
|
|
34
40
|
var cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
|
|
35
41
|
var cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
|
|
36
42
|
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
|
37
43
|
var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
|
44
|
+
var maxAgeRegExp = /^-?\d+$/;
|
|
38
45
|
var __toString = Object.prototype.toString;
|
|
39
46
|
var NullObject = /* @__PURE__ */ (() => {
|
|
40
47
|
const C = function() {
|
|
@@ -42,7 +49,7 @@ var require_dist = __commonJS({
|
|
|
42
49
|
C.prototype = /* @__PURE__ */ Object.create(null);
|
|
43
50
|
return C;
|
|
44
51
|
})();
|
|
45
|
-
function
|
|
52
|
+
function parseCookie(str, options) {
|
|
46
53
|
const obj = new NullObject();
|
|
47
54
|
const len = str.length;
|
|
48
55
|
if (len < 2)
|
|
@@ -50,91 +57,87 @@ var require_dist = __commonJS({
|
|
|
50
57
|
const dec = options?.decode || decode;
|
|
51
58
|
let index = 0;
|
|
52
59
|
do {
|
|
53
|
-
const eqIdx = str
|
|
60
|
+
const eqIdx = eqIndex(str, index, len);
|
|
54
61
|
if (eqIdx === -1)
|
|
55
62
|
break;
|
|
56
|
-
const
|
|
57
|
-
const endIdx = colonIdx === -1 ? len : colonIdx;
|
|
63
|
+
const endIdx = endIndex(str, index, len);
|
|
58
64
|
if (eqIdx > endIdx) {
|
|
59
65
|
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
|
60
66
|
continue;
|
|
61
67
|
}
|
|
62
|
-
const
|
|
63
|
-
const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
|
64
|
-
const key = str.slice(keyStartIdx, keyEndIdx);
|
|
68
|
+
const key = valueSlice(str, index, eqIdx);
|
|
65
69
|
if (obj[key] === void 0) {
|
|
66
|
-
|
|
67
|
-
let valEndIdx = endIndex(str, endIdx, valStartIdx);
|
|
68
|
-
const value = dec(str.slice(valStartIdx, valEndIdx));
|
|
69
|
-
obj[key] = value;
|
|
70
|
+
obj[key] = dec(valueSlice(str, eqIdx + 1, endIdx));
|
|
70
71
|
}
|
|
71
72
|
index = endIdx + 1;
|
|
72
73
|
} while (index < len);
|
|
73
74
|
return obj;
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
|
|
76
|
+
function stringifyCookie(cookie2, options) {
|
|
77
|
+
const enc = options?.encode || encodeURIComponent;
|
|
78
|
+
const cookieStrings = [];
|
|
79
|
+
for (const name of Object.keys(cookie2)) {
|
|
80
|
+
const val = cookie2[name];
|
|
81
|
+
if (val === void 0)
|
|
82
|
+
continue;
|
|
83
|
+
if (!cookieNameRegExp.test(name)) {
|
|
84
|
+
throw new TypeError(`cookie name is invalid: ${name}`);
|
|
85
|
+
}
|
|
86
|
+
const value = enc(val);
|
|
87
|
+
if (!cookieValueRegExp.test(value)) {
|
|
88
|
+
throw new TypeError(`cookie val is invalid: ${val}`);
|
|
89
|
+
}
|
|
90
|
+
cookieStrings.push(`${name}=${value}`);
|
|
88
91
|
}
|
|
89
|
-
return
|
|
92
|
+
return cookieStrings.join("; ");
|
|
90
93
|
}
|
|
91
|
-
function
|
|
94
|
+
function stringifySetCookie(_name, _val, _opts) {
|
|
95
|
+
const cookie2 = typeof _name === "object" ? _name : { ..._opts, name: _name, value: String(_val) };
|
|
96
|
+
const options = typeof _val === "object" ? _val : _opts;
|
|
92
97
|
const enc = options?.encode || encodeURIComponent;
|
|
93
|
-
if (!cookieNameRegExp.test(name)) {
|
|
94
|
-
throw new TypeError(`argument name is invalid: ${name}`);
|
|
98
|
+
if (!cookieNameRegExp.test(cookie2.name)) {
|
|
99
|
+
throw new TypeError(`argument name is invalid: ${cookie2.name}`);
|
|
95
100
|
}
|
|
96
|
-
const value = enc(
|
|
101
|
+
const value = cookie2.value ? enc(cookie2.value) : "";
|
|
97
102
|
if (!cookieValueRegExp.test(value)) {
|
|
98
|
-
throw new TypeError(`argument val is invalid: ${
|
|
103
|
+
throw new TypeError(`argument val is invalid: ${cookie2.value}`);
|
|
99
104
|
}
|
|
100
|
-
let str = name + "=" + value;
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!Number.isInteger(options.maxAge)) {
|
|
105
|
-
throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);
|
|
105
|
+
let str = cookie2.name + "=" + value;
|
|
106
|
+
if (cookie2.maxAge !== void 0) {
|
|
107
|
+
if (!Number.isInteger(cookie2.maxAge)) {
|
|
108
|
+
throw new TypeError(`option maxAge is invalid: ${cookie2.maxAge}`);
|
|
106
109
|
}
|
|
107
|
-
str += "; Max-Age=" +
|
|
110
|
+
str += "; Max-Age=" + cookie2.maxAge;
|
|
108
111
|
}
|
|
109
|
-
if (
|
|
110
|
-
if (!domainValueRegExp.test(
|
|
111
|
-
throw new TypeError(`option domain is invalid: ${
|
|
112
|
+
if (cookie2.domain) {
|
|
113
|
+
if (!domainValueRegExp.test(cookie2.domain)) {
|
|
114
|
+
throw new TypeError(`option domain is invalid: ${cookie2.domain}`);
|
|
112
115
|
}
|
|
113
|
-
str += "; Domain=" +
|
|
116
|
+
str += "; Domain=" + cookie2.domain;
|
|
114
117
|
}
|
|
115
|
-
if (
|
|
116
|
-
if (!pathValueRegExp.test(
|
|
117
|
-
throw new TypeError(`option path is invalid: ${
|
|
118
|
+
if (cookie2.path) {
|
|
119
|
+
if (!pathValueRegExp.test(cookie2.path)) {
|
|
120
|
+
throw new TypeError(`option path is invalid: ${cookie2.path}`);
|
|
118
121
|
}
|
|
119
|
-
str += "; Path=" +
|
|
122
|
+
str += "; Path=" + cookie2.path;
|
|
120
123
|
}
|
|
121
|
-
if (
|
|
122
|
-
if (!isDate(
|
|
123
|
-
throw new TypeError(`option expires is invalid: ${
|
|
124
|
+
if (cookie2.expires) {
|
|
125
|
+
if (!isDate(cookie2.expires) || !Number.isFinite(cookie2.expires.valueOf())) {
|
|
126
|
+
throw new TypeError(`option expires is invalid: ${cookie2.expires}`);
|
|
124
127
|
}
|
|
125
|
-
str += "; Expires=" +
|
|
128
|
+
str += "; Expires=" + cookie2.expires.toUTCString();
|
|
126
129
|
}
|
|
127
|
-
if (
|
|
130
|
+
if (cookie2.httpOnly) {
|
|
128
131
|
str += "; HttpOnly";
|
|
129
132
|
}
|
|
130
|
-
if (
|
|
133
|
+
if (cookie2.secure) {
|
|
131
134
|
str += "; Secure";
|
|
132
135
|
}
|
|
133
|
-
if (
|
|
136
|
+
if (cookie2.partitioned) {
|
|
134
137
|
str += "; Partitioned";
|
|
135
138
|
}
|
|
136
|
-
if (
|
|
137
|
-
const priority = typeof
|
|
139
|
+
if (cookie2.priority) {
|
|
140
|
+
const priority = typeof cookie2.priority === "string" ? cookie2.priority.toLowerCase() : void 0;
|
|
138
141
|
switch (priority) {
|
|
139
142
|
case "low":
|
|
140
143
|
str += "; Priority=Low";
|
|
@@ -146,11 +149,11 @@ var require_dist = __commonJS({
|
|
|
146
149
|
str += "; Priority=High";
|
|
147
150
|
break;
|
|
148
151
|
default:
|
|
149
|
-
throw new TypeError(`option priority is invalid: ${
|
|
152
|
+
throw new TypeError(`option priority is invalid: ${cookie2.priority}`);
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
|
-
if (
|
|
153
|
-
const sameSite = typeof
|
|
155
|
+
if (cookie2.sameSite) {
|
|
156
|
+
const sameSite = typeof cookie2.sameSite === "string" ? cookie2.sameSite.toLowerCase() : cookie2.sameSite;
|
|
154
157
|
switch (sameSite) {
|
|
155
158
|
case true:
|
|
156
159
|
case "strict":
|
|
@@ -163,11 +166,98 @@ var require_dist = __commonJS({
|
|
|
163
166
|
str += "; SameSite=None";
|
|
164
167
|
break;
|
|
165
168
|
default:
|
|
166
|
-
throw new TypeError(`option sameSite is invalid: ${
|
|
169
|
+
throw new TypeError(`option sameSite is invalid: ${cookie2.sameSite}`);
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
return str;
|
|
170
173
|
}
|
|
174
|
+
function parseSetCookie(str, options) {
|
|
175
|
+
const dec = options?.decode || decode;
|
|
176
|
+
const len = str.length;
|
|
177
|
+
const endIdx = endIndex(str, 0, len);
|
|
178
|
+
const eqIdx = eqIndex(str, 0, endIdx);
|
|
179
|
+
const setCookie = eqIdx === -1 ? { name: "", value: dec(valueSlice(str, 0, endIdx)) } : {
|
|
180
|
+
name: valueSlice(str, 0, eqIdx),
|
|
181
|
+
value: dec(valueSlice(str, eqIdx + 1, endIdx))
|
|
182
|
+
};
|
|
183
|
+
let index = endIdx + 1;
|
|
184
|
+
while (index < len) {
|
|
185
|
+
const endIdx2 = endIndex(str, index, len);
|
|
186
|
+
const eqIdx2 = eqIndex(str, index, endIdx2);
|
|
187
|
+
const attr = eqIdx2 === -1 ? valueSlice(str, index, endIdx2) : valueSlice(str, index, eqIdx2);
|
|
188
|
+
const val = eqIdx2 === -1 ? void 0 : valueSlice(str, eqIdx2 + 1, endIdx2);
|
|
189
|
+
switch (attr.toLowerCase()) {
|
|
190
|
+
case "httponly":
|
|
191
|
+
setCookie.httpOnly = true;
|
|
192
|
+
break;
|
|
193
|
+
case "secure":
|
|
194
|
+
setCookie.secure = true;
|
|
195
|
+
break;
|
|
196
|
+
case "partitioned":
|
|
197
|
+
setCookie.partitioned = true;
|
|
198
|
+
break;
|
|
199
|
+
case "domain":
|
|
200
|
+
setCookie.domain = val;
|
|
201
|
+
break;
|
|
202
|
+
case "path":
|
|
203
|
+
setCookie.path = val;
|
|
204
|
+
break;
|
|
205
|
+
case "max-age":
|
|
206
|
+
if (val && maxAgeRegExp.test(val))
|
|
207
|
+
setCookie.maxAge = Number(val);
|
|
208
|
+
break;
|
|
209
|
+
case "expires":
|
|
210
|
+
if (!val)
|
|
211
|
+
break;
|
|
212
|
+
const date = new Date(val);
|
|
213
|
+
if (Number.isFinite(date.valueOf()))
|
|
214
|
+
setCookie.expires = date;
|
|
215
|
+
break;
|
|
216
|
+
case "priority":
|
|
217
|
+
if (!val)
|
|
218
|
+
break;
|
|
219
|
+
const priority = val.toLowerCase();
|
|
220
|
+
if (priority === "low" || priority === "medium" || priority === "high") {
|
|
221
|
+
setCookie.priority = priority;
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
case "samesite":
|
|
225
|
+
if (!val)
|
|
226
|
+
break;
|
|
227
|
+
const sameSite = val.toLowerCase();
|
|
228
|
+
if (sameSite === "lax" || sameSite === "strict" || sameSite === "none") {
|
|
229
|
+
setCookie.sameSite = sameSite;
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
index = endIdx2 + 1;
|
|
234
|
+
}
|
|
235
|
+
return setCookie;
|
|
236
|
+
}
|
|
237
|
+
function endIndex(str, min, len) {
|
|
238
|
+
const index = str.indexOf(";", min);
|
|
239
|
+
return index === -1 ? len : index;
|
|
240
|
+
}
|
|
241
|
+
function eqIndex(str, min, max) {
|
|
242
|
+
const index = str.indexOf("=", min);
|
|
243
|
+
return index < max ? index : -1;
|
|
244
|
+
}
|
|
245
|
+
function valueSlice(str, min, max) {
|
|
246
|
+
let start = min;
|
|
247
|
+
let end = max;
|
|
248
|
+
do {
|
|
249
|
+
const code = str.charCodeAt(start);
|
|
250
|
+
if (code !== 32 && code !== 9)
|
|
251
|
+
break;
|
|
252
|
+
} while (++start < end);
|
|
253
|
+
while (end > start) {
|
|
254
|
+
const code = str.charCodeAt(end - 1);
|
|
255
|
+
if (code !== 32 && code !== 9)
|
|
256
|
+
break;
|
|
257
|
+
end--;
|
|
258
|
+
}
|
|
259
|
+
return str.slice(start, end);
|
|
260
|
+
}
|
|
171
261
|
function decode(str) {
|
|
172
262
|
if (str.indexOf("%") === -1)
|
|
173
263
|
return str;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msw",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.4",
|
|
4
4
|
"description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./lib/core/index.js",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
},
|
|
178
178
|
"lint-staged": {
|
|
179
179
|
"**/*.ts": [
|
|
180
|
-
"
|
|
180
|
+
"oxlint --fix"
|
|
181
181
|
],
|
|
182
182
|
"**/*.{ts,json}": [
|
|
183
183
|
"prettier --write"
|
|
@@ -222,13 +222,13 @@
|
|
|
222
222
|
],
|
|
223
223
|
"sideEffects": false,
|
|
224
224
|
"dependencies": {
|
|
225
|
-
"@inquirer/confirm": "^
|
|
226
|
-
"@mswjs/interceptors": "^0.41.
|
|
227
|
-
"@open-draft/deferred-promise": "^
|
|
225
|
+
"@inquirer/confirm": "^6.0.11",
|
|
226
|
+
"@mswjs/interceptors": "^0.41.3",
|
|
227
|
+
"@open-draft/deferred-promise": "^3.0.0",
|
|
228
228
|
"@types/statuses": "^2.0.6",
|
|
229
|
-
"cookie": "^1.
|
|
230
|
-
"graphql": "^16.
|
|
231
|
-
"headers-polyfill": "^
|
|
229
|
+
"cookie": "^1.1.1",
|
|
230
|
+
"graphql": "^16.13.2",
|
|
231
|
+
"headers-polyfill": "^5.0.1",
|
|
232
232
|
"is-node-process": "^1.2.0",
|
|
233
233
|
"outvariant": "^1.4.3",
|
|
234
234
|
"path-to-regexp": "^6.3.0",
|
|
@@ -236,64 +236,57 @@
|
|
|
236
236
|
"rettime": "^0.11.7",
|
|
237
237
|
"statuses": "^2.0.2",
|
|
238
238
|
"strict-event-emitter": "^0.5.1",
|
|
239
|
-
"tough-cookie": "^6.0.
|
|
240
|
-
"type-fest": "^5.
|
|
239
|
+
"tough-cookie": "^6.0.1",
|
|
240
|
+
"type-fest": "^5.5.0",
|
|
241
241
|
"until-async": "^3.0.2",
|
|
242
242
|
"yargs": "^17.7.2"
|
|
243
243
|
},
|
|
244
244
|
"devDependencies": {
|
|
245
|
-
"@commitlint/cli": "^20.
|
|
246
|
-
"@commitlint/config-conventional": "^20.
|
|
245
|
+
"@commitlint/cli": "^20.5.0",
|
|
246
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
247
247
|
"@epic-web/test-server": "^0.1.6",
|
|
248
|
-
"@eslint/eslintrc": "^3.3.1",
|
|
249
|
-
"@eslint/js": "^9.39.1",
|
|
250
248
|
"@fastify/websocket": "^11.2.0",
|
|
251
249
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
252
250
|
"@open-draft/test-server": "^0.4.2",
|
|
253
251
|
"@ossjs/release": "^0.10.1",
|
|
254
|
-
"@playwright/test": "^1.
|
|
255
|
-
"@types/express": "^5.0.
|
|
252
|
+
"@playwright/test": "^1.59.1",
|
|
253
|
+
"@types/express": "^5.0.6",
|
|
256
254
|
"@types/json-bigint": "^1.0.4",
|
|
257
|
-
"@types/node": "~
|
|
258
|
-
"@types/serviceworker": "^0.0.
|
|
259
|
-
"@typescript-eslint/eslint-plugin": "^8.47.0",
|
|
260
|
-
"@typescript-eslint/parser": "^8.47.0",
|
|
255
|
+
"@types/node": "~22.19.17",
|
|
256
|
+
"@types/serviceworker": "^0.0.194",
|
|
261
257
|
"@web/dev-server": "^0.4.6",
|
|
262
|
-
"axios": "^1.
|
|
258
|
+
"axios": "^1.15.0",
|
|
263
259
|
"babel-minify": "^0.5.1",
|
|
264
260
|
"commitizen": "^4.3.1",
|
|
265
261
|
"cross-env": "^10.1.0",
|
|
266
262
|
"cross-fetch": "^4.1.0",
|
|
267
263
|
"cz-conventional-changelog": "3.3.0",
|
|
268
|
-
"esbuild": "^0.
|
|
269
|
-
"esbuild-loader": "^4.4.
|
|
270
|
-
"
|
|
271
|
-
"
|
|
272
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
273
|
-
"express": "^5.1.0",
|
|
274
|
-
"fastify": "^5.6.2",
|
|
264
|
+
"esbuild": "^0.28.0",
|
|
265
|
+
"esbuild-loader": "^4.4.3",
|
|
266
|
+
"express": "^5.2.1",
|
|
267
|
+
"fastify": "^5.8.5",
|
|
275
268
|
"fs-teardown": "^0.3.0",
|
|
276
|
-
"glob": "^13.0.
|
|
269
|
+
"glob": "^13.0.6",
|
|
277
270
|
"jsdom": "^25.0.1",
|
|
278
271
|
"json-bigint": "^1.0.0",
|
|
279
|
-
"knip": "^
|
|
280
|
-
"lint-staged": "^
|
|
272
|
+
"knip": "^6.4.1",
|
|
273
|
+
"lint-staged": "^16.4.0",
|
|
274
|
+
"oxlint": "^1.0.0",
|
|
281
275
|
"page-with": "^0.6.1",
|
|
282
|
-
"prettier": "^3.
|
|
283
|
-
"publint": "^0.3.
|
|
276
|
+
"prettier": "^3.8.3",
|
|
277
|
+
"publint": "^0.3.18",
|
|
284
278
|
"regenerator-runtime": "^0.14.1",
|
|
285
|
-
"rimraf": "^6.1.
|
|
279
|
+
"rimraf": "^6.1.3",
|
|
286
280
|
"simple-git-hooks": "^2.13.1",
|
|
287
281
|
"tsup": "^8.5.1",
|
|
288
282
|
"typescript": "^5.9.3",
|
|
289
|
-
"
|
|
290
|
-
"undici": "^7.16.0",
|
|
283
|
+
"undici": "^8.1.0",
|
|
291
284
|
"url-loader": "^4.1.1",
|
|
292
|
-
"vitest": "^4.
|
|
285
|
+
"vitest": "^4.1.4",
|
|
293
286
|
"vitest-environment-miniflare": "^2.14.4",
|
|
294
|
-
"webpack": "^5.
|
|
287
|
+
"webpack": "^5.106.2",
|
|
295
288
|
"webpack-http-server": "^0.5.0",
|
|
296
|
-
"msw": "2.13.
|
|
289
|
+
"msw": "^2.13.4"
|
|
297
290
|
},
|
|
298
291
|
"peerDependencies": {
|
|
299
292
|
"typescript": ">= 4.8.x"
|
|
@@ -316,7 +309,7 @@
|
|
|
316
309
|
"scripts": {
|
|
317
310
|
"start": "tsup --watch",
|
|
318
311
|
"clean": "rimraf ./lib",
|
|
319
|
-
"lint": "
|
|
312
|
+
"lint": "oxlint ./cli ./src ./test",
|
|
320
313
|
"build": "pnpm clean && cross-env NODE_ENV=production tsup && pnpm patch:dts",
|
|
321
314
|
"patch:dts": "node \"./config/scripts/patch-ts.js\"",
|
|
322
315
|
"publint": "publint",
|
package/src/browser/glossary.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { LifeCycleEventEmitter, SharedOptions } from '#core/sharedOptions'
|
|
|
2
2
|
import type { RequiredDeep } from '#core/typeUtils'
|
|
3
3
|
import type { HttpNetworkFrameEventMap } from '#core/experimental/frames/http-frame'
|
|
4
4
|
import type { WebSocketNetworkFrameEventMap } from '#core/experimental/frames/websocket-frame'
|
|
5
|
-
import { AnyHandler } from '#core/experimental/handlers-controller'
|
|
5
|
+
import type { AnyHandler } from '#core/experimental/handlers-controller'
|
|
6
6
|
|
|
7
7
|
export interface StringifiedResponse extends ResponseInit {
|
|
8
8
|
body: string | ArrayBuffer | ReadableStream<Uint8Array> | null
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
defineNetwork,
|
|
6
6
|
NetworkReadyState,
|
|
7
7
|
} from '#core/experimental/define-network'
|
|
8
|
-
import {
|
|
8
|
+
import type { AnyHandler } from '#core/experimental/handlers-controller'
|
|
9
9
|
import { InterceptorSource } from '#core/experimental/sources/interceptor-source'
|
|
10
10
|
import { fromLegacyOnUnhandledRequest } from '#core/experimental/compat'
|
|
11
11
|
import type { LifeCycleEventEmitter } from '#core/sharedOptions'
|
|
@@ -65,7 +65,7 @@ export function setupWorker(...handlers: Array<AnyHandler>): SetupWorker {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const httpSource = supportsServiceWorker()
|
|
68
|
-
?
|
|
68
|
+
? await ServiceWorkerSource.from({
|
|
69
69
|
serviceWorker: {
|
|
70
70
|
url:
|
|
71
71
|
options?.serviceWorker?.url?.toString() || DEFAULT_WORKER_URL,
|