@stryke/cookie 0.1.33 → 0.1.35

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.cjs +8 -1
  3. package/dist/index.mjs +5 -1
  4. package/dist/parse.cjs +97 -1
  5. package/dist/parse.mjs +96 -1
  6. package/dist/parse.mjs.map +1 -1
  7. package/dist/split.cjs +47 -1
  8. package/dist/split.mjs +47 -1
  9. package/dist/split.mjs.map +1 -1
  10. package/dist/stringify.cjs +83 -1
  11. package/dist/stringify.mjs +83 -1
  12. package/dist/stringify.mjs.map +1 -1
  13. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  14. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  15. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  16. package/dist/type-checks/src/index.cjs +12 -1
  17. package/dist/type-checks/src/index.mjs +14 -1
  18. package/dist/type-checks/src/is-buffer.cjs +12 -1
  19. package/dist/type-checks/src/is-buffer.mjs +11 -1
  20. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  21. package/dist/type-checks/src/is-collection.cjs +1 -1
  22. package/dist/type-checks/src/is-collection.mjs +3 -1
  23. package/dist/type-checks/src/is-date.cjs +23 -1
  24. package/dist/type-checks/src/is-date.mjs +23 -1
  25. package/dist/type-checks/src/is-date.mjs.map +1 -1
  26. package/dist/type-checks/src/is-empty.cjs +20 -1
  27. package/dist/type-checks/src/is-empty.mjs +20 -1
  28. package/dist/type-checks/src/is-empty.mjs.map +1 -1
  29. package/dist/type-checks/src/is-function.cjs +27 -1
  30. package/dist/type-checks/src/is-function.mjs +25 -1
  31. package/dist/type-checks/src/is-function.mjs.map +1 -1
  32. package/dist/type-checks/src/is-null.cjs +12 -1
  33. package/dist/type-checks/src/is-null.mjs +11 -1
  34. package/dist/type-checks/src/is-null.mjs.map +1 -1
  35. package/dist/type-checks/src/is-plain-object.cjs +30 -1
  36. package/dist/type-checks/src/is-plain-object.mjs +29 -1
  37. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  38. package/dist/type-checks/src/is-set.cjs +19 -1
  39. package/dist/type-checks/src/is-set.mjs +19 -1
  40. package/dist/type-checks/src/is-set.mjs.map +1 -1
  41. package/dist/type-checks/src/is-string.cjs +12 -1
  42. package/dist/type-checks/src/is-string.mjs +11 -1
  43. package/dist/type-checks/src/is-string.mjs.map +1 -1
  44. package/dist/type-checks/src/is-undefined.cjs +8 -1
  45. package/dist/type-checks/src/is-undefined.mjs +7 -1
  46. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  47. package/dist/type-checks/src/type-detect.cjs +15 -1
  48. package/dist/type-checks/src/type-detect.mjs +16 -1
  49. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  50. package/dist/types.mjs +1 -1
  51. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  # Changelog for Stryke - Cookie
4
4
 
5
+ ## [0.1.34](https://github.com/storm-software/stryke/releases/tag/cookie%400.1.34) (01/16/2026)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.18**
10
+ - Updated **convert** to **v0.6.33**
11
+
12
+ ## [0.1.33](https://github.com/storm-software/stryke/releases/tag/cookie%400.1.33) (01/15/2026)
13
+
14
+ ### Updated Dependencies
15
+
16
+ - Updated **type-checks** to **v0.5.17**
17
+ - Updated **convert** to **v0.6.32**
18
+
5
19
  ## [0.1.32](https://github.com/storm-software/stryke/releases/tag/cookie%400.1.32) (01/13/2026)
6
20
 
7
21
  ### Updated Dependencies
package/dist/index.cjs CHANGED
@@ -1 +1,8 @@
1
- const e=require(`./parse.cjs`),t=require(`./split.cjs`),n=require(`./stringify.cjs`);exports.parseCookie=e.parseCookie,exports.parseSetCookie=e.parseSetCookie,exports.splitSetCookieString=t.splitSetCookieString,exports.stringifyCookie=n.stringifyCookie;
1
+ const require_parse = require('./parse.cjs');
2
+ const require_split = require('./split.cjs');
3
+ const require_stringify = require('./stringify.cjs');
4
+
5
+ exports.parseCookie = require_parse.parseCookie;
6
+ exports.parseSetCookie = require_parse.parseSetCookie;
7
+ exports.splitSetCookieString = require_split.splitSetCookieString;
8
+ exports.stringifyCookie = require_stringify.stringifyCookie;
package/dist/index.mjs CHANGED
@@ -1 +1,5 @@
1
- import{parseCookie as e,parseSetCookie as t}from"./parse.mjs";import{splitSetCookieString as n}from"./split.mjs";import{stringifyCookie as r}from"./stringify.mjs";export{e as parseCookie,t as parseSetCookie,n as splitSetCookieString,r as stringifyCookie};
1
+ import { parseCookie, parseSetCookie } from "./parse.mjs";
2
+ import { splitSetCookieString } from "./split.mjs";
3
+ import { stringifyCookie } from "./stringify.mjs";
4
+
5
+ export { parseCookie, parseSetCookie, splitSetCookieString, stringifyCookie };
package/dist/parse.cjs CHANGED
@@ -1 +1,97 @@
1
- const e=require(`./type-checks/src/is-string.cjs`);require(`./type-checks/src/index.cjs`);function t(t,n){if(!e.isString(t))throw Error(`argument str must be a string`);let r={},i=n??{},a=i.decode??(e=>e.includes(`%`)?decodeURIComponent(e):e),o=0;for(;o<t.length;){let e=t.indexOf(`=`,o);if(e===-1)break;let n=t.indexOf(`;`,o);if(n===-1)n=t.length;else if(n<e){o=t.lastIndexOf(`;`,e-1)+1;continue}let s=t.slice(o,e).trim();if(i?.filter&&!i?.filter(s)){o=n+1;continue}if(r[s]===void 0){let i=t.slice(e+1,n).trim();i.codePointAt(0)===34&&(i=i.slice(1,-1));try{r[s]=a(i)}catch{r[s]=i}}o=n+1}return r}function n(t,n){let r=(t||``).split(`;`).filter(t=>e.isString(t)&&!!t.trim()),i=r.shift()||``,a=``,o=``,s=i.split(`=`);s.length>1?(a=s.shift(),o=s.join(`=`)):o=i;try{o=n?.decode===!1?o:(n?.decode??decodeURIComponent)(o)}catch{}let c={name:a,value:o};for(let e of r){let t=e.split(`=`),n=(t.shift()||``).trimStart().toLowerCase(),r=t.join(`=`);switch(n){case`expires`:c.expires=new Date(r);break;case`max-age`:c.maxAge=Number.parseInt(r,10);break;case`secure`:c.secure=!0;break;case`httponly`:c.httpOnly=!0;break;case`samesite`:c.sameSite=r;break;default:c[n]=r}}return c}exports.parseCookie=t,exports.parseSetCookie=n;
1
+ const require_is_string = require('./type-checks/src/is-string.cjs');
2
+ require('./type-checks/src/index.cjs');
3
+
4
+ //#region src/parse.ts
5
+ /**
6
+ * Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.
7
+ *
8
+ * @param cookie - the string representing a `Cookie` header value
9
+ * @param options - object containing parsing options
10
+ * @returns an object with the parsed cookies
11
+ */
12
+ function parseCookie(cookie, options) {
13
+ if (!require_is_string.isString(cookie)) throw new Error("argument str must be a string");
14
+ const obj = {};
15
+ const opt = options ?? {};
16
+ const dec = opt.decode ?? ((str) => str.includes("%") ? decodeURIComponent(str) : str);
17
+ let index = 0;
18
+ while (index < cookie.length) {
19
+ const eqIdx = cookie.indexOf("=", index);
20
+ if (eqIdx === -1) break;
21
+ let endIdx = cookie.indexOf(";", index);
22
+ if (endIdx === -1) endIdx = cookie.length;
23
+ else if (endIdx < eqIdx) {
24
+ index = cookie.lastIndexOf(";", eqIdx - 1) + 1;
25
+ continue;
26
+ }
27
+ const key = cookie.slice(index, eqIdx).trim();
28
+ if (opt?.filter && !opt?.filter(key)) {
29
+ index = endIdx + 1;
30
+ continue;
31
+ }
32
+ if (void 0 === obj[key]) {
33
+ let val = cookie.slice(eqIdx + 1, endIdx).trim();
34
+ if (val.codePointAt(0) === 34) val = val.slice(1, -1);
35
+ try {
36
+ obj[key] = dec(val);
37
+ } catch {
38
+ obj[key] = val;
39
+ }
40
+ }
41
+ index = endIdx + 1;
42
+ }
43
+ return obj;
44
+ }
45
+ /**
46
+ * Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.
47
+ *
48
+ * @param setCookieValue - the string representing a `Set-Cookie` header value
49
+ * @param options - object containing parsing options
50
+ * @returns an object with the parsed cookie
51
+ */
52
+ function parseSetCookie(setCookieValue, options) {
53
+ const parts = (setCookieValue || "").split(";").filter((str) => require_is_string.isString(str) && Boolean(str.trim()));
54
+ const nameValuePairStr = parts.shift() || "";
55
+ let name = "";
56
+ let value = "";
57
+ const nameValueArr = nameValuePairStr.split("=");
58
+ if (nameValueArr.length > 1) {
59
+ name = nameValueArr.shift();
60
+ value = nameValueArr.join("=");
61
+ } else value = nameValuePairStr;
62
+ try {
63
+ value = options?.decode === false ? value : (options?.decode ?? decodeURIComponent)(value);
64
+ } catch {}
65
+ const cookie = {
66
+ name,
67
+ value
68
+ };
69
+ for (const part of parts) {
70
+ const sides = part.split("=");
71
+ const partKey = (sides.shift() || "").trimStart().toLowerCase();
72
+ const partValue = sides.join("=");
73
+ switch (partKey) {
74
+ case "expires":
75
+ cookie.expires = new Date(partValue);
76
+ break;
77
+ case "max-age":
78
+ cookie.maxAge = Number.parseInt(partValue, 10);
79
+ break;
80
+ case "secure":
81
+ cookie.secure = true;
82
+ break;
83
+ case "httponly":
84
+ cookie.httpOnly = true;
85
+ break;
86
+ case "samesite":
87
+ cookie.sameSite = partValue;
88
+ break;
89
+ default: cookie[partKey] = partValue;
90
+ }
91
+ }
92
+ return cookie;
93
+ }
94
+
95
+ //#endregion
96
+ exports.parseCookie = parseCookie;
97
+ exports.parseSetCookie = parseSetCookie;
package/dist/parse.mjs CHANGED
@@ -1,2 +1,97 @@
1
- import{isString as e}from"./type-checks/src/is-string.mjs";import"./type-checks/src/index.mjs";function t(t,n){if(!e(t))throw Error(`argument str must be a string`);let r={},i=n??{},a=i.decode??(e=>e.includes(`%`)?decodeURIComponent(e):e),o=0;for(;o<t.length;){let e=t.indexOf(`=`,o);if(e===-1)break;let n=t.indexOf(`;`,o);if(n===-1)n=t.length;else if(n<e){o=t.lastIndexOf(`;`,e-1)+1;continue}let s=t.slice(o,e).trim();if(i?.filter&&!i?.filter(s)){o=n+1;continue}if(r[s]===void 0){let i=t.slice(e+1,n).trim();i.codePointAt(0)===34&&(i=i.slice(1,-1));try{r[s]=a(i)}catch{r[s]=i}}o=n+1}return r}function n(t,n){let r=(t||``).split(`;`).filter(t=>e(t)&&!!t.trim()),i=r.shift()||``,a=``,o=``,s=i.split(`=`);s.length>1?(a=s.shift(),o=s.join(`=`)):o=i;try{o=n?.decode===!1?o:(n?.decode??decodeURIComponent)(o)}catch{}let c={name:a,value:o};for(let e of r){let t=e.split(`=`),n=(t.shift()||``).trimStart().toLowerCase(),r=t.join(`=`);switch(n){case`expires`:c.expires=new Date(r);break;case`max-age`:c.maxAge=Number.parseInt(r,10);break;case`secure`:c.secure=!0;break;case`httponly`:c.httpOnly=!0;break;case`samesite`:c.sameSite=r;break;default:c[n]=r}}return c}export{t as parseCookie,n as parseSetCookie};
1
+ import { isString } from "./type-checks/src/is-string.mjs";
2
+ import "./type-checks/src/index.mjs";
3
+
4
+ //#region src/parse.ts
5
+ /**
6
+ * Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.
7
+ *
8
+ * @param cookie - the string representing a `Cookie` header value
9
+ * @param options - object containing parsing options
10
+ * @returns an object with the parsed cookies
11
+ */
12
+ function parseCookie(cookie, options) {
13
+ if (!isString(cookie)) throw new Error("argument str must be a string");
14
+ const obj = {};
15
+ const opt = options ?? {};
16
+ const dec = opt.decode ?? ((str) => str.includes("%") ? decodeURIComponent(str) : str);
17
+ let index = 0;
18
+ while (index < cookie.length) {
19
+ const eqIdx = cookie.indexOf("=", index);
20
+ if (eqIdx === -1) break;
21
+ let endIdx = cookie.indexOf(";", index);
22
+ if (endIdx === -1) endIdx = cookie.length;
23
+ else if (endIdx < eqIdx) {
24
+ index = cookie.lastIndexOf(";", eqIdx - 1) + 1;
25
+ continue;
26
+ }
27
+ const key = cookie.slice(index, eqIdx).trim();
28
+ if (opt?.filter && !opt?.filter(key)) {
29
+ index = endIdx + 1;
30
+ continue;
31
+ }
32
+ if (void 0 === obj[key]) {
33
+ let val = cookie.slice(eqIdx + 1, endIdx).trim();
34
+ if (val.codePointAt(0) === 34) val = val.slice(1, -1);
35
+ try {
36
+ obj[key] = dec(val);
37
+ } catch {
38
+ obj[key] = val;
39
+ }
40
+ }
41
+ index = endIdx + 1;
42
+ }
43
+ return obj;
44
+ }
45
+ /**
46
+ * Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.
47
+ *
48
+ * @param setCookieValue - the string representing a `Set-Cookie` header value
49
+ * @param options - object containing parsing options
50
+ * @returns an object with the parsed cookie
51
+ */
52
+ function parseSetCookie(setCookieValue, options) {
53
+ const parts = (setCookieValue || "").split(";").filter((str) => isString(str) && Boolean(str.trim()));
54
+ const nameValuePairStr = parts.shift() || "";
55
+ let name = "";
56
+ let value = "";
57
+ const nameValueArr = nameValuePairStr.split("=");
58
+ if (nameValueArr.length > 1) {
59
+ name = nameValueArr.shift();
60
+ value = nameValueArr.join("=");
61
+ } else value = nameValuePairStr;
62
+ try {
63
+ value = options?.decode === false ? value : (options?.decode ?? decodeURIComponent)(value);
64
+ } catch {}
65
+ const cookie = {
66
+ name,
67
+ value
68
+ };
69
+ for (const part of parts) {
70
+ const sides = part.split("=");
71
+ const partKey = (sides.shift() || "").trimStart().toLowerCase();
72
+ const partValue = sides.join("=");
73
+ switch (partKey) {
74
+ case "expires":
75
+ cookie.expires = new Date(partValue);
76
+ break;
77
+ case "max-age":
78
+ cookie.maxAge = Number.parseInt(partValue, 10);
79
+ break;
80
+ case "secure":
81
+ cookie.secure = true;
82
+ break;
83
+ case "httponly":
84
+ cookie.httpOnly = true;
85
+ break;
86
+ case "samesite":
87
+ cookie.sameSite = partValue;
88
+ break;
89
+ default: cookie[partKey] = partValue;
90
+ }
91
+ }
92
+ return cookie;
93
+ }
94
+
95
+ //#endregion
96
+ export { parseCookie, parseSetCookie };
2
97
  //# sourceMappingURL=parse.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.mjs","names":["cookie: SetCookie"],"sources":["../src/parse.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isString } from \"@stryke/type-checks\";\nimport type {\n CookieParseOptions,\n SetCookie,\n SetCookieParseOptions\n} from \"./types\";\n\n/**\n * Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.\n *\n * @param cookie - the string representing a `Cookie` header value\n * @param options - object containing parsing options\n * @returns an object with the parsed cookies\n */\nexport function parseCookie(\n cookie: string,\n options?: CookieParseOptions\n): Record<string, string> {\n if (!isString(cookie)) {\n throw new Error(\"argument str must be a string\");\n }\n\n const obj = {};\n const opt = options ?? {};\n const dec =\n opt.decode ??\n ((str: string) => (str.includes(\"%\") ? decodeURIComponent(str) : str));\n\n let index = 0;\n while (index < cookie.length) {\n const eqIdx = cookie.indexOf(\"=\", index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = cookie.indexOf(\";\", index);\n\n if (endIdx === -1) {\n endIdx = cookie.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = cookie.lastIndexOf(\";\", eqIdx - 1) + 1;\n\n continue;\n }\n\n const key = cookie.slice(index, eqIdx).trim();\n if (opt?.filter && !opt?.filter(key)) {\n index = endIdx + 1;\n\n continue;\n }\n\n // only assign once\n if (undefined === obj[key as keyof typeof obj]) {\n let val = cookie.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.codePointAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n (obj as any)[key] = dec(val);\n } catch {\n (obj as any)[key] = val;\n }\n }\n\n index = endIdx + 1;\n }\n\n return obj;\n}\n\n/**\n * Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.\n *\n * @param setCookieValue - the string representing a `Set-Cookie` header value\n * @param options - object containing parsing options\n * @returns an object with the parsed cookie\n */\nexport function parseSetCookie(\n setCookieValue: string,\n options?: SetCookieParseOptions\n): SetCookie {\n const parts = (setCookieValue || \"\")\n .split(\";\")\n .filter(str => isString(str) && Boolean(str.trim()));\n\n const nameValuePairStr = parts.shift() || \"\";\n\n let name = \"\";\n let value = \"\";\n const nameValueArr = nameValuePairStr.split(\"=\");\n if (nameValueArr.length > 1) {\n name = nameValueArr.shift()!;\n // Everything after the first =, joined by a \"=\" if there was more than one part\n value = nameValueArr.join(\"=\");\n } else {\n value = nameValuePairStr;\n }\n\n try {\n value =\n options?.decode === false\n ? value\n : (options?.decode ?? decodeURIComponent)(value);\n } catch {\n // Do nothing\n }\n\n const cookie: SetCookie = {\n name,\n value\n };\n\n for (const part of parts) {\n const sides = part.split(\"=\");\n const partKey = (sides.shift() || \"\").trimStart().toLowerCase();\n const partValue = sides.join(\"=\");\n switch (partKey) {\n case \"expires\": {\n cookie.expires = new Date(partValue);\n break;\n }\n case \"max-age\": {\n cookie.maxAge = Number.parseInt(partValue, 10);\n break;\n }\n case \"secure\": {\n cookie.secure = true;\n break;\n }\n case \"httponly\": {\n cookie.httpOnly = true;\n break;\n }\n case \"samesite\": {\n cookie.sameSite = partValue as SetCookie[\"sameSite\"];\n break;\n }\n default: {\n cookie[partKey] = partValue;\n }\n }\n }\n\n return cookie;\n}\n"],"mappings":"+FAgCA,SAAgB,EACd,EACA,EACwB,CACxB,GAAI,CAAC,EAAS,EAAO,CACnB,MAAU,MAAM,gCAAgC,CAGlD,IAAM,EAAM,EAAE,CACR,EAAM,GAAW,EAAE,CACnB,EACJ,EAAI,SACF,GAAiB,EAAI,SAAS,IAAI,CAAG,mBAAmB,EAAI,CAAG,GAE/D,EAAQ,EACZ,KAAO,EAAQ,EAAO,QAAQ,CAC5B,IAAM,EAAQ,EAAO,QAAQ,IAAK,EAAM,CAGxC,GAAI,IAAU,GACZ,MAGF,IAAI,EAAS,EAAO,QAAQ,IAAK,EAAM,CAEvC,GAAI,IAAW,GACb,EAAS,EAAO,eACP,EAAS,EAAO,CAEzB,EAAQ,EAAO,YAAY,IAAK,EAAQ,EAAE,CAAG,EAE7C,SAGF,IAAM,EAAM,EAAO,MAAM,EAAO,EAAM,CAAC,MAAM,CAC7C,GAAI,GAAK,QAAU,CAAC,GAAK,OAAO,EAAI,CAAE,CACpC,EAAQ,EAAS,EAEjB,SAIF,GAAkB,EAAI,KAAlB,IAAA,GAA4C,CAC9C,IAAI,EAAM,EAAO,MAAM,EAAQ,EAAG,EAAO,CAAC,MAAM,CAG5C,EAAI,YAAY,EAAE,GAAK,KACzB,EAAM,EAAI,MAAM,EAAG,GAAG,EAGxB,GAAI,CACD,EAAY,GAAO,EAAI,EAAI,MACtB,CACL,EAAY,GAAO,GAIxB,EAAQ,EAAS,EAGnB,OAAO,EAUT,SAAgB,EACd,EACA,EACW,CACX,IAAM,GAAS,GAAkB,IAC9B,MAAM,IAAI,CACV,OAAO,GAAO,EAAS,EAAI,EAAI,EAAQ,EAAI,MAAM,CAAE,CAEhD,EAAmB,EAAM,OAAO,EAAI,GAEtC,EAAO,GACP,EAAQ,GACN,EAAe,EAAiB,MAAM,IAAI,CAC5C,EAAa,OAAS,GACxB,EAAO,EAAa,OAAO,CAE3B,EAAQ,EAAa,KAAK,IAAI,EAE9B,EAAQ,EAGV,GAAI,CACF,EACE,GAAS,SAAW,GAChB,GACC,GAAS,QAAU,oBAAoB,EAAM,MAC9C,EAIR,IAAMA,EAAoB,CACxB,OACA,QACD,CAED,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAQ,EAAK,MAAM,IAAI,CACvB,GAAW,EAAM,OAAO,EAAI,IAAI,WAAW,CAAC,aAAa,CACzD,EAAY,EAAM,KAAK,IAAI,CACjC,OAAQ,EAAR,CACE,IAAK,UACH,EAAO,QAAU,IAAI,KAAK,EAAU,CACpC,MAEF,IAAK,UACH,EAAO,OAAS,OAAO,SAAS,EAAW,GAAG,CAC9C,MAEF,IAAK,SACH,EAAO,OAAS,GAChB,MAEF,IAAK,WACH,EAAO,SAAW,GAClB,MAEF,IAAK,WACH,EAAO,SAAW,EAClB,MAEF,QACE,EAAO,GAAW,GAKxB,OAAO"}
1
+ {"version":3,"file":"parse.mjs","names":["cookie: SetCookie"],"sources":["../src/parse.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isString } from \"@stryke/type-checks\";\nimport type {\n CookieParseOptions,\n SetCookie,\n SetCookieParseOptions\n} from \"./types\";\n\n/**\n * Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.\n *\n * @param cookie - the string representing a `Cookie` header value\n * @param options - object containing parsing options\n * @returns an object with the parsed cookies\n */\nexport function parseCookie(\n cookie: string,\n options?: CookieParseOptions\n): Record<string, string> {\n if (!isString(cookie)) {\n throw new Error(\"argument str must be a string\");\n }\n\n const obj = {};\n const opt = options ?? {};\n const dec =\n opt.decode ??\n ((str: string) => (str.includes(\"%\") ? decodeURIComponent(str) : str));\n\n let index = 0;\n while (index < cookie.length) {\n const eqIdx = cookie.indexOf(\"=\", index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = cookie.indexOf(\";\", index);\n\n if (endIdx === -1) {\n endIdx = cookie.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = cookie.lastIndexOf(\";\", eqIdx - 1) + 1;\n\n continue;\n }\n\n const key = cookie.slice(index, eqIdx).trim();\n if (opt?.filter && !opt?.filter(key)) {\n index = endIdx + 1;\n\n continue;\n }\n\n // only assign once\n if (undefined === obj[key as keyof typeof obj]) {\n let val = cookie.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.codePointAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n (obj as any)[key] = dec(val);\n } catch {\n (obj as any)[key] = val;\n }\n }\n\n index = endIdx + 1;\n }\n\n return obj;\n}\n\n/**\n * Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.\n *\n * @param setCookieValue - the string representing a `Set-Cookie` header value\n * @param options - object containing parsing options\n * @returns an object with the parsed cookie\n */\nexport function parseSetCookie(\n setCookieValue: string,\n options?: SetCookieParseOptions\n): SetCookie {\n const parts = (setCookieValue || \"\")\n .split(\";\")\n .filter(str => isString(str) && Boolean(str.trim()));\n\n const nameValuePairStr = parts.shift() || \"\";\n\n let name = \"\";\n let value = \"\";\n const nameValueArr = nameValuePairStr.split(\"=\");\n if (nameValueArr.length > 1) {\n name = nameValueArr.shift()!;\n // Everything after the first =, joined by a \"=\" if there was more than one part\n value = nameValueArr.join(\"=\");\n } else {\n value = nameValuePairStr;\n }\n\n try {\n value =\n options?.decode === false\n ? value\n : (options?.decode ?? decodeURIComponent)(value);\n } catch {\n // Do nothing\n }\n\n const cookie: SetCookie = {\n name,\n value\n };\n\n for (const part of parts) {\n const sides = part.split(\"=\");\n const partKey = (sides.shift() || \"\").trimStart().toLowerCase();\n const partValue = sides.join(\"=\");\n switch (partKey) {\n case \"expires\": {\n cookie.expires = new Date(partValue);\n break;\n }\n case \"max-age\": {\n cookie.maxAge = Number.parseInt(partValue, 10);\n break;\n }\n case \"secure\": {\n cookie.secure = true;\n break;\n }\n case \"httponly\": {\n cookie.httpOnly = true;\n break;\n }\n case \"samesite\": {\n cookie.sameSite = partValue as SetCookie[\"sameSite\"];\n break;\n }\n default: {\n cookie[partKey] = partValue;\n }\n }\n }\n\n return cookie;\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAgB,YACd,QACA,SACwB;AACxB,KAAI,CAAC,SAAS,OAAO,CACnB,OAAM,IAAI,MAAM,gCAAgC;CAGlD,MAAM,MAAM,EAAE;CACd,MAAM,MAAM,WAAW,EAAE;CACzB,MAAM,MACJ,IAAI,YACF,QAAiB,IAAI,SAAS,IAAI,GAAG,mBAAmB,IAAI,GAAG;CAEnE,IAAI,QAAQ;AACZ,QAAO,QAAQ,OAAO,QAAQ;EAC5B,MAAM,QAAQ,OAAO,QAAQ,KAAK,MAAM;AAGxC,MAAI,UAAU,GACZ;EAGF,IAAI,SAAS,OAAO,QAAQ,KAAK,MAAM;AAEvC,MAAI,WAAW,GACb,UAAS,OAAO;WACP,SAAS,OAAO;AAEzB,WAAQ,OAAO,YAAY,KAAK,QAAQ,EAAE,GAAG;AAE7C;;EAGF,MAAM,MAAM,OAAO,MAAM,OAAO,MAAM,CAAC,MAAM;AAC7C,MAAI,KAAK,UAAU,CAAC,KAAK,OAAO,IAAI,EAAE;AACpC,WAAQ,SAAS;AAEjB;;AAIF,MAAI,WAAc,IAAI,MAA0B;GAC9C,IAAI,MAAM,OAAO,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM;AAGhD,OAAI,IAAI,YAAY,EAAE,KAAK,GACzB,OAAM,IAAI,MAAM,GAAG,GAAG;AAGxB,OAAI;AACF,IAAC,IAAY,OAAO,IAAI,IAAI;WACtB;AACN,IAAC,IAAY,OAAO;;;AAIxB,UAAQ,SAAS;;AAGnB,QAAO;;;;;;;;;AAUT,SAAgB,eACd,gBACA,SACW;CACX,MAAM,SAAS,kBAAkB,IAC9B,MAAM,IAAI,CACV,QAAO,QAAO,SAAS,IAAI,IAAI,QAAQ,IAAI,MAAM,CAAC,CAAC;CAEtD,MAAM,mBAAmB,MAAM,OAAO,IAAI;CAE1C,IAAI,OAAO;CACX,IAAI,QAAQ;CACZ,MAAM,eAAe,iBAAiB,MAAM,IAAI;AAChD,KAAI,aAAa,SAAS,GAAG;AAC3B,SAAO,aAAa,OAAO;AAE3B,UAAQ,aAAa,KAAK,IAAI;OAE9B,SAAQ;AAGV,KAAI;AACF,UACE,SAAS,WAAW,QAChB,SACC,SAAS,UAAU,oBAAoB,MAAM;SAC9C;CAIR,MAAMA,SAAoB;EACxB;EACA;EACD;AAED,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,KAAK,MAAM,IAAI;EAC7B,MAAM,WAAW,MAAM,OAAO,IAAI,IAAI,WAAW,CAAC,aAAa;EAC/D,MAAM,YAAY,MAAM,KAAK,IAAI;AACjC,UAAQ,SAAR;GACE,KAAK;AACH,WAAO,UAAU,IAAI,KAAK,UAAU;AACpC;GAEF,KAAK;AACH,WAAO,SAAS,OAAO,SAAS,WAAW,GAAG;AAC9C;GAEF,KAAK;AACH,WAAO,SAAS;AAChB;GAEF,KAAK;AACH,WAAO,WAAW;AAClB;GAEF,KAAK;AACH,WAAO,WAAW;AAClB;GAEF,QACE,QAAO,WAAW;;;AAKxB,QAAO"}
package/dist/split.cjs CHANGED
@@ -1 +1,47 @@
1
- const e=require(`./type-checks/src/is-string.cjs`);function t(n){if(Array.isArray(n))return n.flatMap(e=>t(e));if(!e.isString(n))return[];let r=[],i=0,a,o,s,c,l,u=()=>{for(;i<n.length&&/\s/.test(n.charAt(i));)i+=1;return i<n.length},d=()=>(o=n.charAt(i),o!==`=`&&o!==`;`&&o!==`,`);for(;i<n.length;){for(a=i,l=!1;u();)if(o=n.charAt(i),o===`,`){for(s=i,i+=1,u(),c=i;i<n.length&&d();)i+=1;i<n.length&&n.charAt(i)===`=`?(l=!0,i=c,r.push(n.slice(a,s)),a=i):i=s+1}else i+=1;(!l||i>=n.length)&&r.push(n.slice(a))}return r}exports.splitSetCookieString=t;
1
+ const require_is_string = require('./type-checks/src/is-string.cjs');
2
+
3
+ //#region src/split.ts
4
+ function splitSetCookieString(strCookie) {
5
+ if (Array.isArray(strCookie)) return strCookie.flatMap((c) => splitSetCookieString(c));
6
+ if (!require_is_string.isString(strCookie)) return [];
7
+ const cookiesStrings = [];
8
+ let pos = 0;
9
+ let start;
10
+ let ch;
11
+ let lastComma;
12
+ let nextStart;
13
+ let cookiesSeparatorFound;
14
+ const skipWhitespace = () => {
15
+ while (pos < strCookie.length && /\s/.test(strCookie.charAt(pos))) pos += 1;
16
+ return pos < strCookie.length;
17
+ };
18
+ const notSpecialChar = () => {
19
+ ch = strCookie.charAt(pos);
20
+ return ch !== "=" && ch !== ";" && ch !== ",";
21
+ };
22
+ while (pos < strCookie.length) {
23
+ start = pos;
24
+ cookiesSeparatorFound = false;
25
+ while (skipWhitespace()) {
26
+ ch = strCookie.charAt(pos);
27
+ if (ch === ",") {
28
+ lastComma = pos;
29
+ pos += 1;
30
+ skipWhitespace();
31
+ nextStart = pos;
32
+ while (pos < strCookie.length && notSpecialChar()) pos += 1;
33
+ if (pos < strCookie.length && strCookie.charAt(pos) === "=") {
34
+ cookiesSeparatorFound = true;
35
+ pos = nextStart;
36
+ cookiesStrings.push(strCookie.slice(start, lastComma));
37
+ start = pos;
38
+ } else pos = lastComma + 1;
39
+ } else pos += 1;
40
+ }
41
+ if (!cookiesSeparatorFound || pos >= strCookie.length) cookiesStrings.push(strCookie.slice(start));
42
+ }
43
+ return cookiesStrings;
44
+ }
45
+
46
+ //#endregion
47
+ exports.splitSetCookieString = splitSetCookieString;
package/dist/split.mjs CHANGED
@@ -1,2 +1,48 @@
1
- import{isString as e}from"./type-checks/src/is-string.mjs";function t(n){if(Array.isArray(n))return n.flatMap(e=>t(e));if(!e(n))return[];let r=[],i=0,a,o,s,c,l,u=()=>{for(;i<n.length&&/\s/.test(n.charAt(i));)i+=1;return i<n.length},d=()=>(o=n.charAt(i),o!==`=`&&o!==`;`&&o!==`,`);for(;i<n.length;){for(a=i,l=!1;u();)if(o=n.charAt(i),o===`,`){for(s=i,i+=1,u(),c=i;i<n.length&&d();)i+=1;i<n.length&&n.charAt(i)===`=`?(l=!0,i=c,r.push(n.slice(a,s)),a=i):i=s+1}else i+=1;(!l||i>=n.length)&&r.push(n.slice(a))}return r}export{t as splitSetCookieString};
1
+ import { isString } from "./type-checks/src/is-string.mjs";
2
+
3
+ //#region src/split.ts
4
+ function splitSetCookieString(strCookie) {
5
+ if (Array.isArray(strCookie)) return strCookie.flatMap((c) => splitSetCookieString(c));
6
+ if (!isString(strCookie)) return [];
7
+ const cookiesStrings = [];
8
+ let pos = 0;
9
+ let start;
10
+ let ch;
11
+ let lastComma;
12
+ let nextStart;
13
+ let cookiesSeparatorFound;
14
+ const skipWhitespace = () => {
15
+ while (pos < strCookie.length && /\s/.test(strCookie.charAt(pos))) pos += 1;
16
+ return pos < strCookie.length;
17
+ };
18
+ const notSpecialChar = () => {
19
+ ch = strCookie.charAt(pos);
20
+ return ch !== "=" && ch !== ";" && ch !== ",";
21
+ };
22
+ while (pos < strCookie.length) {
23
+ start = pos;
24
+ cookiesSeparatorFound = false;
25
+ while (skipWhitespace()) {
26
+ ch = strCookie.charAt(pos);
27
+ if (ch === ",") {
28
+ lastComma = pos;
29
+ pos += 1;
30
+ skipWhitespace();
31
+ nextStart = pos;
32
+ while (pos < strCookie.length && notSpecialChar()) pos += 1;
33
+ if (pos < strCookie.length && strCookie.charAt(pos) === "=") {
34
+ cookiesSeparatorFound = true;
35
+ pos = nextStart;
36
+ cookiesStrings.push(strCookie.slice(start, lastComma));
37
+ start = pos;
38
+ } else pos = lastComma + 1;
39
+ } else pos += 1;
40
+ }
41
+ if (!cookiesSeparatorFound || pos >= strCookie.length) cookiesStrings.push(strCookie.slice(start));
42
+ }
43
+ return cookiesStrings;
44
+ }
45
+
46
+ //#endregion
47
+ export { splitSetCookieString };
2
48
  //# sourceMappingURL=split.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"split.mjs","names":["cookiesStrings: string[]","pos: number","start: number","ch: string","lastComma: number","nextStart: number","cookiesSeparatorFound: boolean"],"sources":["../src/split.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isString } from \"@stryke/type-checks/is-string\";\n\n/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport function splitSetCookieString(strCookie: string | string[]): string[] {\n if (Array.isArray(strCookie)) {\n return strCookie.flatMap(c => splitSetCookieString(c));\n }\n\n if (!isString(strCookie)) {\n return [];\n }\n\n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n\n const skipWhitespace = () => {\n while (pos < strCookie.length && /\\s/.test(strCookie.charAt(pos))) {\n pos += 1;\n }\n return pos < strCookie.length;\n };\n\n const notSpecialChar = () => {\n ch = strCookie.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n\n while (pos < strCookie.length) {\n start = pos;\n cookiesSeparatorFound = false;\n\n while (skipWhitespace()) {\n ch = strCookie.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n\n skipWhitespace();\n nextStart = pos;\n\n while (pos < strCookie.length && notSpecialChar()) {\n pos += 1;\n }\n\n // currently special character\n if (pos < strCookie.length && strCookie.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(strCookie.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n\n if (!cookiesSeparatorFound || pos >= strCookie.length) {\n cookiesStrings.push(strCookie.slice(start));\n }\n }\n\n return cookiesStrings;\n}\n"],"mappings":"2DAsCA,SAAgB,EAAqB,EAAwC,CAC3E,GAAI,MAAM,QAAQ,EAAU,CAC1B,OAAO,EAAU,QAAQ,GAAK,EAAqB,EAAE,CAAC,CAGxD,GAAI,CAAC,EAAS,EAAU,CACtB,MAAO,EAAE,CAGX,IAAMA,EAA2B,EAAE,CAC/BC,EAAc,EACdC,EACAC,EACAC,EACAC,EACAC,EAEE,MAAuB,CAC3B,KAAO,EAAM,EAAU,QAAU,KAAK,KAAK,EAAU,OAAO,EAAI,CAAC,EAC/D,GAAO,EAET,OAAO,EAAM,EAAU,QAGnB,OACJ,EAAK,EAAU,OAAO,EAAI,CACnB,IAAO,KAAO,IAAO,KAAO,IAAO,KAG5C,KAAO,EAAM,EAAU,QAAQ,CAI7B,IAHA,EAAQ,EACR,EAAwB,GAEjB,GAAgB,EAErB,GADA,EAAK,EAAU,OAAO,EAAI,CACtB,IAAO,IAAK,CAQd,IANA,EAAY,EACZ,GAAO,EAEP,GAAgB,CAChB,EAAY,EAEL,EAAM,EAAU,QAAU,GAAgB,EAC/C,GAAO,EAIL,EAAM,EAAU,QAAU,EAAU,OAAO,EAAI,GAAK,KAEtD,EAAwB,GAExB,EAAM,EACN,EAAe,KAAK,EAAU,MAAM,EAAO,EAAU,CAAC,CACtD,EAAQ,GAIR,EAAM,EAAY,OAGpB,GAAO,GAIP,CAAC,GAAyB,GAAO,EAAU,SAC7C,EAAe,KAAK,EAAU,MAAM,EAAM,CAAC,CAI/C,OAAO"}
1
+ {"version":3,"file":"split.mjs","names":["cookiesStrings: string[]","pos: number","start: number","ch: string","lastComma: number","nextStart: number","cookiesSeparatorFound: boolean"],"sources":["../src/split.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isString } from \"@stryke/type-checks/is-string\";\n\n/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport function splitSetCookieString(strCookie: string | string[]): string[] {\n if (Array.isArray(strCookie)) {\n return strCookie.flatMap(c => splitSetCookieString(c));\n }\n\n if (!isString(strCookie)) {\n return [];\n }\n\n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n\n const skipWhitespace = () => {\n while (pos < strCookie.length && /\\s/.test(strCookie.charAt(pos))) {\n pos += 1;\n }\n return pos < strCookie.length;\n };\n\n const notSpecialChar = () => {\n ch = strCookie.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n\n while (pos < strCookie.length) {\n start = pos;\n cookiesSeparatorFound = false;\n\n while (skipWhitespace()) {\n ch = strCookie.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n\n skipWhitespace();\n nextStart = pos;\n\n while (pos < strCookie.length && notSpecialChar()) {\n pos += 1;\n }\n\n // currently special character\n if (pos < strCookie.length && strCookie.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(strCookie.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n\n if (!cookiesSeparatorFound || pos >= strCookie.length) {\n cookiesStrings.push(strCookie.slice(start));\n }\n }\n\n return cookiesStrings;\n}\n"],"mappings":";;;AAsCA,SAAgB,qBAAqB,WAAwC;AAC3E,KAAI,MAAM,QAAQ,UAAU,CAC1B,QAAO,UAAU,SAAQ,MAAK,qBAAqB,EAAE,CAAC;AAGxD,KAAI,CAAC,SAAS,UAAU,CACtB,QAAO,EAAE;CAGX,MAAMA,iBAA2B,EAAE;CACnC,IAAIC,MAAc;CAClB,IAAIC;CACJ,IAAIC;CACJ,IAAIC;CACJ,IAAIC;CACJ,IAAIC;CAEJ,MAAM,uBAAuB;AAC3B,SAAO,MAAM,UAAU,UAAU,KAAK,KAAK,UAAU,OAAO,IAAI,CAAC,CAC/D,QAAO;AAET,SAAO,MAAM,UAAU;;CAGzB,MAAM,uBAAuB;AAC3B,OAAK,UAAU,OAAO,IAAI;AAC1B,SAAO,OAAO,OAAO,OAAO,OAAO,OAAO;;AAG5C,QAAO,MAAM,UAAU,QAAQ;AAC7B,UAAQ;AACR,0BAAwB;AAExB,SAAO,gBAAgB,EAAE;AACvB,QAAK,UAAU,OAAO,IAAI;AAC1B,OAAI,OAAO,KAAK;AAEd,gBAAY;AACZ,WAAO;AAEP,oBAAgB;AAChB,gBAAY;AAEZ,WAAO,MAAM,UAAU,UAAU,gBAAgB,CAC/C,QAAO;AAIT,QAAI,MAAM,UAAU,UAAU,UAAU,OAAO,IAAI,KAAK,KAAK;AAE3D,6BAAwB;AAExB,WAAM;AACN,oBAAe,KAAK,UAAU,MAAM,OAAO,UAAU,CAAC;AACtD,aAAQ;UAIR,OAAM,YAAY;SAGpB,QAAO;;AAIX,MAAI,CAAC,yBAAyB,OAAO,UAAU,OAC7C,gBAAe,KAAK,UAAU,MAAM,MAAM,CAAC;;AAI/C,QAAO"}
@@ -1 +1,83 @@
1
- const e=require(`./type-checks/src/is-date.cjs`),t=require(`./type-checks/src/is-function.cjs`),n=require(`./type-checks/src/is-string.cjs`),r=require(`./type-checks/src/is-set.cjs`);require(`./type-checks/src/index.cjs`);const i=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;function a(a,o,s){let c=s??{},l=c.encode??encodeURIComponent;if(!t.isFunction(l))throw Error(`option encode is invalid`);if(!i.test(a))throw Error(`argument name is invalid`);let u=l(o);if(u&&!i.test(u))throw Error(`argument val is invalid`);let d=`${a}=${u}`;if(!r.isSet(c.maxAge)){let e=Number(c.maxAge);if(Number.isNaN(e)||!Number.isFinite(e))throw TypeError(`option maxAge is invalid`);d+=`; Max-Age=${Math.floor(e)}`}if(c.domain){if(!i.test(c.domain))throw Error(`option domain is invalid`);d+=`; Domain=${c.domain}`}if(c.path){if(!i.test(c.path))throw Error(`option path is invalid`);d+=`; Path=${c.path}`}if(c.expires){if(!e.isDate(c.expires)||Number.isNaN(c.expires.valueOf()))throw Error(`option expires is invalid`);d+=`; Expires=${c.expires.toUTCString()}`}if(c.httpOnly&&(d+=`; HttpOnly`),c.secure&&(d+=`; Secure`),c.priority)switch(n.isString(c.priority)?c.priority.toLowerCase():c.priority){case`low`:d+=`; Priority=Low`;break;case`medium`:d+=`; Priority=Medium`;break;case`high`:d+=`; Priority=High`;break;default:throw Error(`option priority is invalid`)}if(c.sameSite)switch(n.isString(c.sameSite)?c.sameSite.toLowerCase():c.sameSite){case!0:d+=`; SameSite=Strict`;break;case`lax`:d+=`; SameSite=Lax`;break;case`strict`:d+=`; SameSite=Strict`;break;case`none`:d+=`; SameSite=None`;break;default:throw Error(`option sameSite is invalid`)}return c.partitioned&&(d+=`; Partitioned`),d}exports.stringifyCookie=a;
1
+ const require_is_date = require('./type-checks/src/is-date.cjs');
2
+ const require_is_function = require('./type-checks/src/is-function.cjs');
3
+ const require_is_string = require('./type-checks/src/is-string.cjs');
4
+ const require_is_set = require('./type-checks/src/is-set.cjs');
5
+ require('./type-checks/src/index.cjs');
6
+
7
+ //#region src/stringify.ts
8
+ /**
9
+ * RegExp to match field-content in RFC 7230 sec 3.2
10
+ *
11
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
12
+ * field-vchar = VCHAR / obs-text
13
+ * obs-text = %x80-FF
14
+ */
15
+ const fieldContentRegExp = /^[\t\u0020-\u007E\u0080-\u00FF]+$/;
16
+ /**
17
+ * Serialize a cookie name-value pair into a `Set-Cookie` header string.
18
+ *
19
+ * @param name - the name for the cookie
20
+ * @param value - value to set the cookie to
21
+ * @param options - object containing serialization options
22
+ * @returns a `Set-Cookie` header string
23
+ */
24
+ function stringifyCookie(name, value, options) {
25
+ const opt = options ?? {};
26
+ const enc = opt.encode ?? encodeURIComponent;
27
+ if (!require_is_function.isFunction(enc)) throw new Error("option encode is invalid");
28
+ if (!fieldContentRegExp.test(name)) throw new Error("argument name is invalid");
29
+ const encodedValue = enc(value);
30
+ if (encodedValue && !fieldContentRegExp.test(encodedValue)) throw new Error("argument val is invalid");
31
+ let str = `${name}=${encodedValue}`;
32
+ if (!require_is_set.isSet(opt.maxAge)) {
33
+ const maxAge = Number(opt.maxAge);
34
+ if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
35
+ str += `; Max-Age=${Math.floor(maxAge)}`;
36
+ }
37
+ if (opt.domain) {
38
+ if (!fieldContentRegExp.test(opt.domain)) throw new Error("option domain is invalid");
39
+ str += `; Domain=${opt.domain}`;
40
+ }
41
+ if (opt.path) {
42
+ if (!fieldContentRegExp.test(opt.path)) throw new Error("option path is invalid");
43
+ str += `; Path=${opt.path}`;
44
+ }
45
+ if (opt.expires) {
46
+ if (!require_is_date.isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) throw new Error("option expires is invalid");
47
+ str += `; Expires=${opt.expires.toUTCString()}`;
48
+ }
49
+ if (opt.httpOnly) str += "; HttpOnly";
50
+ if (opt.secure) str += "; Secure";
51
+ if (opt.priority) switch (require_is_string.isString(opt.priority) ? opt.priority.toLowerCase() : opt.priority) {
52
+ case "low":
53
+ str += "; Priority=Low";
54
+ break;
55
+ case "medium":
56
+ str += "; Priority=Medium";
57
+ break;
58
+ case "high":
59
+ str += "; Priority=High";
60
+ break;
61
+ default: throw new Error("option priority is invalid");
62
+ }
63
+ if (opt.sameSite) switch (require_is_string.isString(opt.sameSite) ? opt.sameSite.toLowerCase() : opt.sameSite) {
64
+ case true:
65
+ str += "; SameSite=Strict";
66
+ break;
67
+ case "lax":
68
+ str += "; SameSite=Lax";
69
+ break;
70
+ case "strict":
71
+ str += "; SameSite=Strict";
72
+ break;
73
+ case "none":
74
+ str += "; SameSite=None";
75
+ break;
76
+ default: throw new Error("option sameSite is invalid");
77
+ }
78
+ if (opt.partitioned) str += "; Partitioned";
79
+ return str;
80
+ }
81
+
82
+ //#endregion
83
+ exports.stringifyCookie = stringifyCookie;
@@ -1,2 +1,84 @@
1
- import{isDate as e}from"./type-checks/src/is-date.mjs";import{isFunction as t}from"./type-checks/src/is-function.mjs";import{isString as n}from"./type-checks/src/is-string.mjs";import{isSet as r}from"./type-checks/src/is-set.mjs";import"./type-checks/src/index.mjs";const i=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;function a(a,o,s){let c=s??{},l=c.encode??encodeURIComponent;if(!t(l))throw Error(`option encode is invalid`);if(!i.test(a))throw Error(`argument name is invalid`);let u=l(o);if(u&&!i.test(u))throw Error(`argument val is invalid`);let d=`${a}=${u}`;if(!r(c.maxAge)){let e=Number(c.maxAge);if(Number.isNaN(e)||!Number.isFinite(e))throw TypeError(`option maxAge is invalid`);d+=`; Max-Age=${Math.floor(e)}`}if(c.domain){if(!i.test(c.domain))throw Error(`option domain is invalid`);d+=`; Domain=${c.domain}`}if(c.path){if(!i.test(c.path))throw Error(`option path is invalid`);d+=`; Path=${c.path}`}if(c.expires){if(!e(c.expires)||Number.isNaN(c.expires.valueOf()))throw Error(`option expires is invalid`);d+=`; Expires=${c.expires.toUTCString()}`}if(c.httpOnly&&(d+=`; HttpOnly`),c.secure&&(d+=`; Secure`),c.priority)switch(n(c.priority)?c.priority.toLowerCase():c.priority){case`low`:d+=`; Priority=Low`;break;case`medium`:d+=`; Priority=Medium`;break;case`high`:d+=`; Priority=High`;break;default:throw Error(`option priority is invalid`)}if(c.sameSite)switch(n(c.sameSite)?c.sameSite.toLowerCase():c.sameSite){case!0:d+=`; SameSite=Strict`;break;case`lax`:d+=`; SameSite=Lax`;break;case`strict`:d+=`; SameSite=Strict`;break;case`none`:d+=`; SameSite=None`;break;default:throw Error(`option sameSite is invalid`)}return c.partitioned&&(d+=`; Partitioned`),d}export{a as stringifyCookie};
1
+ import { isDate } from "./type-checks/src/is-date.mjs";
2
+ import { isFunction } from "./type-checks/src/is-function.mjs";
3
+ import { isString } from "./type-checks/src/is-string.mjs";
4
+ import { isSet } from "./type-checks/src/is-set.mjs";
5
+ import "./type-checks/src/index.mjs";
6
+
7
+ //#region src/stringify.ts
8
+ /**
9
+ * RegExp to match field-content in RFC 7230 sec 3.2
10
+ *
11
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
12
+ * field-vchar = VCHAR / obs-text
13
+ * obs-text = %x80-FF
14
+ */
15
+ const fieldContentRegExp = /^[\t\u0020-\u007E\u0080-\u00FF]+$/;
16
+ /**
17
+ * Serialize a cookie name-value pair into a `Set-Cookie` header string.
18
+ *
19
+ * @param name - the name for the cookie
20
+ * @param value - value to set the cookie to
21
+ * @param options - object containing serialization options
22
+ * @returns a `Set-Cookie` header string
23
+ */
24
+ function stringifyCookie(name, value, options) {
25
+ const opt = options ?? {};
26
+ const enc = opt.encode ?? encodeURIComponent;
27
+ if (!isFunction(enc)) throw new Error("option encode is invalid");
28
+ if (!fieldContentRegExp.test(name)) throw new Error("argument name is invalid");
29
+ const encodedValue = enc(value);
30
+ if (encodedValue && !fieldContentRegExp.test(encodedValue)) throw new Error("argument val is invalid");
31
+ let str = `${name}=${encodedValue}`;
32
+ if (!isSet(opt.maxAge)) {
33
+ const maxAge = Number(opt.maxAge);
34
+ if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
35
+ str += `; Max-Age=${Math.floor(maxAge)}`;
36
+ }
37
+ if (opt.domain) {
38
+ if (!fieldContentRegExp.test(opt.domain)) throw new Error("option domain is invalid");
39
+ str += `; Domain=${opt.domain}`;
40
+ }
41
+ if (opt.path) {
42
+ if (!fieldContentRegExp.test(opt.path)) throw new Error("option path is invalid");
43
+ str += `; Path=${opt.path}`;
44
+ }
45
+ if (opt.expires) {
46
+ if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) throw new Error("option expires is invalid");
47
+ str += `; Expires=${opt.expires.toUTCString()}`;
48
+ }
49
+ if (opt.httpOnly) str += "; HttpOnly";
50
+ if (opt.secure) str += "; Secure";
51
+ if (opt.priority) switch (isString(opt.priority) ? opt.priority.toLowerCase() : opt.priority) {
52
+ case "low":
53
+ str += "; Priority=Low";
54
+ break;
55
+ case "medium":
56
+ str += "; Priority=Medium";
57
+ break;
58
+ case "high":
59
+ str += "; Priority=High";
60
+ break;
61
+ default: throw new Error("option priority is invalid");
62
+ }
63
+ if (opt.sameSite) switch (isString(opt.sameSite) ? opt.sameSite.toLowerCase() : opt.sameSite) {
64
+ case true:
65
+ str += "; SameSite=Strict";
66
+ break;
67
+ case "lax":
68
+ str += "; SameSite=Lax";
69
+ break;
70
+ case "strict":
71
+ str += "; SameSite=Strict";
72
+ break;
73
+ case "none":
74
+ str += "; SameSite=None";
75
+ break;
76
+ default: throw new Error("option sameSite is invalid");
77
+ }
78
+ if (opt.partitioned) str += "; Partitioned";
79
+ return str;
80
+ }
81
+
82
+ //#endregion
83
+ export { stringifyCookie };
2
84
  //# sourceMappingURL=stringify.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stringify.mjs","names":[],"sources":["../src/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate, isFunction, isSet, isString } from \"@stryke/type-checks\";\nimport type { CookieSerializeOptions } from \"./types\";\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\n\nconst fieldContentRegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]+$/;\n\n/**\n * Serialize a cookie name-value pair into a `Set-Cookie` header string.\n *\n * @param name - the name for the cookie\n * @param value - value to set the cookie to\n * @param options - object containing serialization options\n * @returns a `Set-Cookie` header string\n */\nexport function stringifyCookie(\n name: string,\n value: string,\n options?: CookieSerializeOptions\n): string {\n const opt = options ?? {};\n const enc = opt.encode ?? encodeURIComponent;\n\n if (!isFunction(enc)) {\n throw new Error(\"option encode is invalid\");\n }\n\n if (!fieldContentRegExp.test(name)) {\n throw new Error(\"argument name is invalid\");\n }\n\n const encodedValue = enc(value);\n\n if (encodedValue && !fieldContentRegExp.test(encodedValue)) {\n throw new Error(\"argument val is invalid\");\n }\n\n let str = `${name}=${encodedValue}`;\n\n if (!isSet(opt.maxAge)) {\n const maxAge = Number(opt.maxAge);\n\n if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) {\n throw new TypeError(\"option maxAge is invalid\");\n }\n\n str += `; Max-Age=${Math.floor(maxAge)}`;\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new Error(\"option domain is invalid\");\n }\n\n str += `; Domain=${opt.domain}`;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new Error(\"option path is invalid\");\n }\n\n str += `; Path=${opt.path}`;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) {\n throw new Error(\"option expires is invalid\");\n }\n\n str += `; Expires=${opt.expires.toUTCString()}`;\n }\n\n if (opt.httpOnly) {\n str += \"; HttpOnly\";\n }\n\n if (opt.secure) {\n str += \"; Secure\";\n }\n\n if (opt.priority) {\n const priority = isString(opt.priority)\n ? opt.priority.toLowerCase()\n : opt.priority;\n\n switch (priority) {\n case \"low\": {\n str += \"; Priority=Low\";\n break;\n }\n case \"medium\": {\n str += \"; Priority=Medium\";\n break;\n }\n case \"high\": {\n str += \"; Priority=High\";\n break;\n }\n default: {\n throw new Error(\"option priority is invalid\");\n }\n }\n }\n\n if (opt.sameSite) {\n const sameSite = isString(opt.sameSite)\n ? opt.sameSite.toLowerCase()\n : opt.sameSite;\n\n switch (sameSite) {\n case true: {\n str += \"; SameSite=Strict\";\n break;\n }\n case \"lax\": {\n str += \"; SameSite=Lax\";\n break;\n }\n case \"strict\": {\n str += \"; SameSite=Strict\";\n break;\n }\n case \"none\": {\n str += \"; SameSite=None\";\n break;\n }\n default: {\n throw new Error(\"option sameSite is invalid\");\n }\n }\n }\n\n if (opt.partitioned) {\n str += \"; Partitioned\";\n }\n\n return str;\n}\n"],"mappings":"0QA6BA,MAAM,EAAqB,oCAU3B,SAAgB,EACd,EACA,EACA,EACQ,CACR,IAAM,EAAM,GAAW,EAAE,CACnB,EAAM,EAAI,QAAU,mBAE1B,GAAI,CAAC,EAAW,EAAI,CAClB,MAAU,MAAM,2BAA2B,CAG7C,GAAI,CAAC,EAAmB,KAAK,EAAK,CAChC,MAAU,MAAM,2BAA2B,CAG7C,IAAM,EAAe,EAAI,EAAM,CAE/B,GAAI,GAAgB,CAAC,EAAmB,KAAK,EAAa,CACxD,MAAU,MAAM,0BAA0B,CAG5C,IAAI,EAAM,GAAG,EAAK,GAAG,IAErB,GAAI,CAAC,EAAM,EAAI,OAAO,CAAE,CACtB,IAAM,EAAS,OAAO,EAAI,OAAO,CAEjC,GAAI,OAAO,MAAM,EAAO,EAAI,CAAC,OAAO,SAAS,EAAO,CAClD,MAAU,UAAU,2BAA2B,CAGjD,GAAO,aAAa,KAAK,MAAM,EAAO,GAGxC,GAAI,EAAI,OAAQ,CACd,GAAI,CAAC,EAAmB,KAAK,EAAI,OAAO,CACtC,MAAU,MAAM,2BAA2B,CAG7C,GAAO,YAAY,EAAI,SAGzB,GAAI,EAAI,KAAM,CACZ,GAAI,CAAC,EAAmB,KAAK,EAAI,KAAK,CACpC,MAAU,MAAM,yBAAyB,CAG3C,GAAO,UAAU,EAAI,OAGvB,GAAI,EAAI,QAAS,CACf,GAAI,CAAC,EAAO,EAAI,QAAQ,EAAI,OAAO,MAAM,EAAI,QAAQ,SAAS,CAAC,CAC7D,MAAU,MAAM,4BAA4B,CAG9C,GAAO,aAAa,EAAI,QAAQ,aAAa,GAW/C,GARI,EAAI,WACN,GAAO,cAGL,EAAI,SACN,GAAO,YAGL,EAAI,SAKN,OAJiB,EAAS,EAAI,SAAS,CACnC,EAAI,SAAS,aAAa,CAC1B,EAAI,SAER,CACE,IAAK,MACH,GAAO,iBACP,MAEF,IAAK,SACH,GAAO,oBACP,MAEF,IAAK,OACH,GAAO,kBACP,MAEF,QACE,MAAU,MAAM,6BAA6B,CAKnD,GAAI,EAAI,SAKN,OAJiB,EAAS,EAAI,SAAS,CACnC,EAAI,SAAS,aAAa,CAC1B,EAAI,SAER,CACE,IAAK,GACH,GAAO,oBACP,MAEF,IAAK,MACH,GAAO,iBACP,MAEF,IAAK,SACH,GAAO,oBACP,MAEF,IAAK,OACH,GAAO,kBACP,MAEF,QACE,MAAU,MAAM,6BAA6B,CASnD,OAJI,EAAI,cACN,GAAO,iBAGF"}
1
+ {"version":3,"file":"stringify.mjs","names":[],"sources":["../src/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate, isFunction, isSet, isString } from \"@stryke/type-checks\";\nimport type { CookieSerializeOptions } from \"./types\";\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\n\nconst fieldContentRegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]+$/;\n\n/**\n * Serialize a cookie name-value pair into a `Set-Cookie` header string.\n *\n * @param name - the name for the cookie\n * @param value - value to set the cookie to\n * @param options - object containing serialization options\n * @returns a `Set-Cookie` header string\n */\nexport function stringifyCookie(\n name: string,\n value: string,\n options?: CookieSerializeOptions\n): string {\n const opt = options ?? {};\n const enc = opt.encode ?? encodeURIComponent;\n\n if (!isFunction(enc)) {\n throw new Error(\"option encode is invalid\");\n }\n\n if (!fieldContentRegExp.test(name)) {\n throw new Error(\"argument name is invalid\");\n }\n\n const encodedValue = enc(value);\n\n if (encodedValue && !fieldContentRegExp.test(encodedValue)) {\n throw new Error(\"argument val is invalid\");\n }\n\n let str = `${name}=${encodedValue}`;\n\n if (!isSet(opt.maxAge)) {\n const maxAge = Number(opt.maxAge);\n\n if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) {\n throw new TypeError(\"option maxAge is invalid\");\n }\n\n str += `; Max-Age=${Math.floor(maxAge)}`;\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new Error(\"option domain is invalid\");\n }\n\n str += `; Domain=${opt.domain}`;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new Error(\"option path is invalid\");\n }\n\n str += `; Path=${opt.path}`;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) {\n throw new Error(\"option expires is invalid\");\n }\n\n str += `; Expires=${opt.expires.toUTCString()}`;\n }\n\n if (opt.httpOnly) {\n str += \"; HttpOnly\";\n }\n\n if (opt.secure) {\n str += \"; Secure\";\n }\n\n if (opt.priority) {\n const priority = isString(opt.priority)\n ? opt.priority.toLowerCase()\n : opt.priority;\n\n switch (priority) {\n case \"low\": {\n str += \"; Priority=Low\";\n break;\n }\n case \"medium\": {\n str += \"; Priority=Medium\";\n break;\n }\n case \"high\": {\n str += \"; Priority=High\";\n break;\n }\n default: {\n throw new Error(\"option priority is invalid\");\n }\n }\n }\n\n if (opt.sameSite) {\n const sameSite = isString(opt.sameSite)\n ? opt.sameSite.toLowerCase()\n : opt.sameSite;\n\n switch (sameSite) {\n case true: {\n str += \"; SameSite=Strict\";\n break;\n }\n case \"lax\": {\n str += \"; SameSite=Lax\";\n break;\n }\n case \"strict\": {\n str += \"; SameSite=Strict\";\n break;\n }\n case \"none\": {\n str += \"; SameSite=None\";\n break;\n }\n default: {\n throw new Error(\"option sameSite is invalid\");\n }\n }\n }\n\n if (opt.partitioned) {\n str += \"; Partitioned\";\n }\n\n return str;\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BA,MAAM,qBAAqB;;;;;;;;;AAU3B,SAAgB,gBACd,MACA,OACA,SACQ;CACR,MAAM,MAAM,WAAW,EAAE;CACzB,MAAM,MAAM,IAAI,UAAU;AAE1B,KAAI,CAAC,WAAW,IAAI,CAClB,OAAM,IAAI,MAAM,2BAA2B;AAG7C,KAAI,CAAC,mBAAmB,KAAK,KAAK,CAChC,OAAM,IAAI,MAAM,2BAA2B;CAG7C,MAAM,eAAe,IAAI,MAAM;AAE/B,KAAI,gBAAgB,CAAC,mBAAmB,KAAK,aAAa,CACxD,OAAM,IAAI,MAAM,0BAA0B;CAG5C,IAAI,MAAM,GAAG,KAAK,GAAG;AAErB,KAAI,CAAC,MAAM,IAAI,OAAO,EAAE;EACtB,MAAM,SAAS,OAAO,IAAI,OAAO;AAEjC,MAAI,OAAO,MAAM,OAAO,IAAI,CAAC,OAAO,SAAS,OAAO,CAClD,OAAM,IAAI,UAAU,2BAA2B;AAGjD,SAAO,aAAa,KAAK,MAAM,OAAO;;AAGxC,KAAI,IAAI,QAAQ;AACd,MAAI,CAAC,mBAAmB,KAAK,IAAI,OAAO,CACtC,OAAM,IAAI,MAAM,2BAA2B;AAG7C,SAAO,YAAY,IAAI;;AAGzB,KAAI,IAAI,MAAM;AACZ,MAAI,CAAC,mBAAmB,KAAK,IAAI,KAAK,CACpC,OAAM,IAAI,MAAM,yBAAyB;AAG3C,SAAO,UAAU,IAAI;;AAGvB,KAAI,IAAI,SAAS;AACf,MAAI,CAAC,OAAO,IAAI,QAAQ,IAAI,OAAO,MAAM,IAAI,QAAQ,SAAS,CAAC,CAC7D,OAAM,IAAI,MAAM,4BAA4B;AAG9C,SAAO,aAAa,IAAI,QAAQ,aAAa;;AAG/C,KAAI,IAAI,SACN,QAAO;AAGT,KAAI,IAAI,OACN,QAAO;AAGT,KAAI,IAAI,SAKN,SAJiB,SAAS,IAAI,SAAS,GACnC,IAAI,SAAS,aAAa,GAC1B,IAAI,UAER;EACE,KAAK;AACH,UAAO;AACP;EAEF,KAAK;AACH,UAAO;AACP;EAEF,KAAK;AACH,UAAO;AACP;EAEF,QACE,OAAM,IAAI,MAAM,6BAA6B;;AAKnD,KAAI,IAAI,SAKN,SAJiB,SAAS,IAAI,SAAS,GACnC,IAAI,SAAS,aAAa,GAC1B,IAAI,UAER;EACE,KAAK;AACH,UAAO;AACP;EAEF,KAAK;AACH,UAAO;AACP;EAEF,KAAK;AACH,UAAO;AACP;EAEF,KAAK;AACH,UAAO;AACP;EAEF,QACE,OAAM,IAAI,MAAM,6BAA6B;;AAKnD,KAAI,IAAI,YACN,QAAO;AAGT,QAAO"}
@@ -1 +1,15 @@
1
- const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);exports.getObjectTag=e;
1
+
2
+ //#region ../type-checks/src/get-object-tag.ts
3
+ /**
4
+ * Gets the `toStringTag` of `obj`.
5
+ *
6
+ * @param value - The obj to query.
7
+ * @returns Returns the `toStringTag`.
8
+ */
9
+ const getObjectTag = (value) => {
10
+ if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
11
+ return Object.prototype.toString.call(value);
12
+ };
13
+
14
+ //#endregion
15
+ exports.getObjectTag = getObjectTag;