msw 2.4.4 → 2.4.6

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.
@@ -79,6 +79,9 @@ class WebStorageCookieStore extends Store {
79
79
  }
80
80
  putCookie(cookie, callback) {
81
81
  try {
82
+ if (cookie.maxAge === 0) {
83
+ return;
84
+ }
82
85
  const store2 = this.getStore();
83
86
  store2.push(cookie);
84
87
  this.updateStore(store2);
@@ -89,6 +92,15 @@ class WebStorageCookieStore extends Store {
89
92
  }
90
93
  }
91
94
  updateCookie(oldCookie, newCookie, callback) {
95
+ if (newCookie.maxAge === 0) {
96
+ this.removeCookie(
97
+ newCookie.domain || "",
98
+ newCookie.path || "",
99
+ newCookie.key,
100
+ callback
101
+ );
102
+ return;
103
+ }
92
104
  this.putCookie(newCookie, callback);
93
105
  }
94
106
  removeCookie(domain, path, key, callback) {
@@ -1 +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 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,CA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,aAAO,KAAK,MAAM;AAAA,IACpB;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,sBACN,SACA,SACA;AACA,UAAM,kBAAkB,KAAK,sBAAsB,SAAS,OAAO;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"]}
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 // Never set cookies with `maxAge` of `0`.\n if (cookie.maxAge === 0) {\n return\n }\n\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 /**\n * If updating a cookie with `maxAge` of `0`, remove it from the store.\n * Otherwise, two cookie entries will be created.\n * @see https://github.com/mswjs/msw/issues/2272\n */\n if (newCookie.maxAge === 0) {\n this.removeCookie(\n newCookie.domain || '',\n newCookie.path || '',\n newCookie.key,\n callback,\n )\n return\n }\n\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 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,MA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AAO,UAAU,EAAE,GAAG;AACvE;AAAA,MACF;AAEA,UAAI,QAAQ,QAAQ,CAAC,UAAU,QAAQ,MAAM,OAAO,QAAQ,EAAE,GAAG;AAC/D;AAAA,MACF;AAEA,UAAI,QAAQ,OAAO,OAAO,QAAQ,QAAQ,KAAK;AAC7C;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,sBACN,SACA,SACA;AACA,UAAM,kBAAkB,KAAK,sBAAsB,SAAS,OAAO;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"]}
@@ -46,6 +46,9 @@ class WebStorageCookieStore extends Store {
46
46
  }
47
47
  putCookie(cookie, callback) {
48
48
  try {
49
+ if (cookie.maxAge === 0) {
50
+ return;
51
+ }
49
52
  const store2 = this.getStore();
50
53
  store2.push(cookie);
51
54
  this.updateStore(store2);
@@ -56,6 +59,15 @@ class WebStorageCookieStore extends Store {
56
59
  }
57
60
  }
58
61
  updateCookie(oldCookie, newCookie, callback) {
62
+ if (newCookie.maxAge === 0) {
63
+ this.removeCookie(
64
+ newCookie.domain || "",
65
+ newCookie.path || "",
66
+ newCookie.key,
67
+ callback
68
+ );
69
+ return;
70
+ }
59
71
  this.putCookie(newCookie, callback);
60
72
  }
61
73
  removeCookie(domain, path, key, callback) {
@@ -1 +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 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,aAA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AAO,OAAO,CAAC,CAAC;AAAA,IAC3D;AAAA,EACF;AAAA,EAEQ,sBACN,SACA,SACuB;AACvB,UAAM,SAAgC,CAAC;AAEvC,eAAW,UAAU,SAAS;AAC5B,UAAI,QAAQ,UAAU,CAAC,YAAY,QAAQ,QAAQ,OAAO,UAAU,EAAE,GAAG;AACvE;AAAA,MACF;AAEA,UAAI,QAAQ,QAAQ,CAAC,UAAU,QAAQ,MAAM,OAAO,QAAQ,EAAE,GAAG;AAC/D;AAAA,MACF;AAEA,UAAI,QAAQ,OAAO,OAAO,QAAQ,QAAQ,KAAK;AAC7C;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,sBACN,SACA,SACA;AACA,UAAM,kBAAkB,KAAK,sBAAsB,SAAS,OAAO;AACnE,WAAO,QAAQ,OAAO,CAAC,WAAW,CAAC,gBAAgB,SAAS,MAAM,CAAC;AAAA,EACrE;AACF;AAEA,MAAM,QAAQ,cAAc,IACxB,IAAI,kBAAkB,IACtB,IAAI,sBAAsB;AAEvB,MAAM,cAAc,IAAI,UAAU,KAAK;","names":["store"]}
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 // Never set cookies with `maxAge` of `0`.\n if (cookie.maxAge === 0) {\n return\n }\n\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 /**\n * If updating a cookie with `maxAge` of `0`, remove it from the store.\n * Otherwise, two cookie entries will be created.\n * @see https://github.com/mswjs/msw/issues/2272\n */\n if (newCookie.maxAge === 0) {\n this.removeCookie(\n newCookie.domain || '',\n newCookie.path || '',\n newCookie.key,\n callback,\n )\n return\n }\n\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 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,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ACN,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAAA,EAEQ,YAAY,WAAkC;AACpD,SAAK,QAAQ;AAAA,MACX,KAAK;AAAA,MACL,KAAK,UAAU,UAAU,IAAI,CAAC,WAAW,OAAO,OAAO,CAAC,CAAC;AAAA,IAC3D;AAAA,EACF;AAAA,EAEQ,sBACN,SACA,SACuB;AACvB,UAAM,SAAgC,CAAC;AAEvC,eAAW,UAAU,SAAS;AAC5B,UAAI,QAAQ,UAAU,CAAC,YAAY,QAAQ,QAAQ,OAAO,UAAU,EAAE,GAAG;AACvE;AAAA,MACF;AAEA,UAAI,QAAQ,QAAQ,CAAC,UAAU,QAAQ,MAAM,OAAO,QAAQ,EAAE,GAAG;AAC/D;AAAA,MACF;AAEA,UAAI,QAAQ,OAAO,OAAO,QAAQ,QAAQ,KAAK;AAC7C;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,sBACN,SACA,SACA;AACA,UAAM,kBAAkB,KAAK,sBAAsB,SAAS,OAAO;AACnE,WAAO,QAAQ,OAAO,CAAC,WAAW,CAAC,gBAAgB,SAAS,MAAM,CAAC;AAAA,EACrE;AACF;AAEA,MAAM,QAAQ,cAAc,IACxB,IAAI,kBAAkB,IACtB,IAAI,sBAAsB;AAEvB,MAAM,cAAc,IAAI,UAAU,KAAK;","names":["store"]}
package/lib/iife/index.js CHANGED
@@ -14388,7 +14388,7 @@ ${operationTypes.join("\n")}
14388
14388
  return stringToRegexp(path, keys, options);
14389
14389
  }
14390
14390
 
14391
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
14391
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
14392
14392
  var encoder = new TextEncoder();
14393
14393
  function encodeBuffer(text) {
14394
14394
  return encoder.encode(text);
@@ -14404,7 +14404,7 @@ ${operationTypes.join("\n")}
14404
14404
  );
14405
14405
  }
14406
14406
 
14407
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/chunk-XVPRNJO7.mjs
14407
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/chunk-XVPRNJO7.mjs
14408
14408
  var IS_PATCHED_MODULE = Symbol("isPatchedModule");
14409
14409
  function isPropertyAccessible(obj, key) {
14410
14410
  try {
@@ -14824,7 +14824,7 @@ ${operationTypes.join("\n")}
14824
14824
  return message3.toString();
14825
14825
  }
14826
14826
 
14827
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
14827
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
14828
14828
  var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
14829
14829
  function getGlobalSymbol(symbol) {
14830
14830
  return (
@@ -14972,7 +14972,7 @@ ${operationTypes.join("\n")}
14972
14972
  return Math.random().toString(16).slice(2);
14973
14973
  }
14974
14974
 
14975
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/index.mjs
14975
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/index.mjs
14976
14976
  var BatchInterceptor = class extends Interceptor {
14977
14977
  constructor(options) {
14978
14978
  BatchInterceptor.symbol = Symbol(options.name);
@@ -27151,6 +27151,9 @@ ${operationTypes.join("\n")}
27151
27151
  }
27152
27152
  putCookie(cookie, callback) {
27153
27153
  try {
27154
+ if (cookie.maxAge === 0) {
27155
+ return;
27156
+ }
27154
27157
  const store2 = this.getStore();
27155
27158
  store2.push(cookie);
27156
27159
  this.updateStore(store2);
@@ -27161,6 +27164,15 @@ ${operationTypes.join("\n")}
27161
27164
  }
27162
27165
  }
27163
27166
  updateCookie(oldCookie, newCookie, callback) {
27167
+ if (newCookie.maxAge === 0) {
27168
+ this.removeCookie(
27169
+ newCookie.domain || "",
27170
+ newCookie.path || "",
27171
+ newCookie.key,
27172
+ callback
27173
+ );
27174
+ return;
27175
+ }
27164
27176
  this.putCookie(newCookie, callback);
27165
27177
  }
27166
27178
  removeCookie(domain, path, key, callback) {
@@ -29101,7 +29113,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29101
29113
  }
29102
29114
  };
29103
29115
 
29104
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/chunk-THPGBWJQ.mjs
29116
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/chunk-THPGBWJQ.mjs
29105
29117
  var InterceptorError = class extends Error {
29106
29118
  constructor(message3) {
29107
29119
  super(message3);
@@ -29269,7 +29281,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29269
29281
  return false;
29270
29282
  }
29271
29283
 
29272
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/chunk-DZCGGRSJ.mjs
29284
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/chunk-G5SOR3ND.mjs
29273
29285
  function canParseUrl(url) {
29274
29286
  try {
29275
29287
  new URL(url);
@@ -29298,7 +29310,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29298
29310
  const requestUrl = new URL(request.url);
29299
29311
  let locationUrl;
29300
29312
  try {
29301
- locationUrl = new URL(response.headers.get("location"));
29313
+ locationUrl = new URL(response.headers.get("location"), request.url);
29302
29314
  } catch (error3) {
29303
29315
  return Promise.reject(createNetworkError(error3));
29304
29316
  }
@@ -29466,7 +29478,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29466
29478
  var FetchInterceptor = _FetchInterceptor;
29467
29479
  FetchInterceptor.symbol = Symbol("fetch");
29468
29480
 
29469
- // node_modules/.pnpm/@mswjs+interceptors@0.35.0/node_modules/@mswjs/interceptors/lib/browser/chunk-PRBA3ES4.mjs
29481
+ // node_modules/.pnpm/@mswjs+interceptors@0.35.3/node_modules/@mswjs/interceptors/lib/browser/chunk-SUQ32ZQK.mjs
29470
29482
  function concatArrayBuffer(left, right) {
29471
29483
  const result = new Uint8Array(left.byteLength + right.byteLength);
29472
29484
  result.set(left, 0);
@@ -29740,7 +29752,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29740
29752
  });
29741
29753
  const requestBody = typeof body === "string" ? encodeBuffer(body) : body;
29742
29754
  const fetchRequest = this.toFetchApiRequest(requestBody);
29743
- this[kFetchRequest] = fetchRequest;
29755
+ this[kFetchRequest] = fetchRequest.clone();
29744
29756
  const onceRequestSettled = ((_a2 = this.onRequest) == null ? void 0 : _a2.call(this, {
29745
29757
  request: fetchRequest,
29746
29758
  requestId: this.requestId
@@ -29822,7 +29834,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29822
29834
  this[kIsRequestHandled] = true;
29823
29835
  if (this[kFetchRequest]) {
29824
29836
  const totalRequestBodyLength = await getBodyByteLength(
29825
- this[kFetchRequest].clone()
29837
+ this[kFetchRequest]
29826
29838
  );
29827
29839
  this.trigger("loadstart", this.request.upload, {
29828
29840
  loaded: 0,