msw 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
@@ -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) {