@stryke/cookie 0.1.24 → 0.1.26

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 (98) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +4 -4
  4. package/dist/index.d.mts +4 -4
  5. package/dist/index.mjs +1 -1
  6. package/dist/parse.cjs +1 -1
  7. package/dist/parse.d.cts +23 -2
  8. package/dist/parse.d.cts.map +1 -0
  9. package/dist/parse.d.mts +23 -2
  10. package/dist/parse.d.mts.map +1 -0
  11. package/dist/parse.mjs +2 -1
  12. package/dist/parse.mjs.map +1 -0
  13. package/dist/split.cjs +1 -1
  14. package/dist/split.d.cts +5 -2
  15. package/dist/split.d.cts.map +1 -0
  16. package/dist/split.d.mts +5 -2
  17. package/dist/split.d.mts.map +1 -0
  18. package/dist/split.mjs +2 -1
  19. package/dist/split.mjs.map +1 -0
  20. package/dist/stringify.cjs +1 -1
  21. package/dist/stringify.d.cts +16 -2
  22. package/dist/stringify.d.cts.map +1 -0
  23. package/dist/stringify.d.mts +16 -2
  24. package/dist/stringify.d.mts.map +1 -0
  25. package/dist/stringify.mjs +2 -1
  26. package/dist/stringify.mjs.map +1 -0
  27. package/dist/type-checks/src/get-object-tag.cjs +1 -0
  28. package/dist/type-checks/src/get-object-tag.mjs +2 -0
  29. package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
  30. package/dist/type-checks/src/index.cjs +1 -0
  31. package/dist/type-checks/src/index.mjs +1 -0
  32. package/dist/type-checks/src/is-buffer.cjs +1 -0
  33. package/dist/type-checks/src/is-buffer.mjs +2 -0
  34. package/dist/type-checks/src/is-buffer.mjs.map +1 -0
  35. package/dist/type-checks/src/is-collection.cjs +1 -0
  36. package/dist/type-checks/src/is-collection.mjs +1 -0
  37. package/dist/type-checks/src/is-date.cjs +1 -0
  38. package/dist/type-checks/src/is-date.mjs +2 -0
  39. package/dist/type-checks/src/is-date.mjs.map +1 -0
  40. package/dist/type-checks/src/is-empty.cjs +1 -0
  41. package/dist/type-checks/src/is-empty.mjs +2 -0
  42. package/dist/type-checks/src/is-empty.mjs.map +1 -0
  43. package/dist/type-checks/src/is-function.cjs +1 -0
  44. package/dist/type-checks/src/is-function.mjs +2 -0
  45. package/dist/type-checks/src/is-function.mjs.map +1 -0
  46. package/dist/type-checks/src/is-null.cjs +1 -0
  47. package/dist/type-checks/src/is-null.mjs +2 -0
  48. package/dist/type-checks/src/is-null.mjs.map +1 -0
  49. package/dist/type-checks/src/is-plain-object.cjs +1 -0
  50. package/dist/type-checks/src/is-plain-object.mjs +2 -0
  51. package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
  52. package/dist/type-checks/src/is-set.cjs +1 -0
  53. package/dist/type-checks/src/is-set.mjs +2 -0
  54. package/dist/type-checks/src/is-set.mjs.map +1 -0
  55. package/dist/{is-string-Cdq5ranA.mjs → type-checks/src/is-string.cjs} +1 -2
  56. package/dist/type-checks/src/is-string.mjs +2 -0
  57. package/dist/type-checks/src/is-string.mjs.map +1 -0
  58. package/dist/type-checks/src/is-undefined.cjs +1 -0
  59. package/dist/type-checks/src/is-undefined.mjs +2 -0
  60. package/dist/type-checks/src/is-undefined.mjs.map +1 -0
  61. package/dist/type-checks/src/type-detect.cjs +1 -0
  62. package/dist/type-checks/src/type-detect.mjs +2 -0
  63. package/dist/type-checks/src/type-detect.mjs.map +1 -0
  64. package/dist/types.d.cts +188 -2
  65. package/dist/types.d.cts.map +1 -0
  66. package/dist/types.d.mts +188 -2
  67. package/dist/types.d.mts.map +1 -0
  68. package/package.json +5 -5
  69. package/dist/is-string-Cdq5ranA.mjs.map +0 -1
  70. package/dist/is-string-qyWqKQj-.cjs +0 -1
  71. package/dist/parse-CB7V9-FM.mjs +0 -2
  72. package/dist/parse-CB7V9-FM.mjs.map +0 -1
  73. package/dist/parse-CC7RDu95.d.cts +0 -23
  74. package/dist/parse-CC7RDu95.d.cts.map +0 -1
  75. package/dist/parse-DClQAhyZ.d.mts +0 -23
  76. package/dist/parse-DClQAhyZ.d.mts.map +0 -1
  77. package/dist/parse-Lu_9IylD.cjs +0 -1
  78. package/dist/split-BMQx0Ga2.d.mts +0 -5
  79. package/dist/split-BMQx0Ga2.d.mts.map +0 -1
  80. package/dist/split-DGuM3LaG.cjs +0 -1
  81. package/dist/split-DyNIhQJp.mjs +0 -2
  82. package/dist/split-DyNIhQJp.mjs.map +0 -1
  83. package/dist/split-Y8qgB1su.d.cts +0 -5
  84. package/dist/split-Y8qgB1su.d.cts.map +0 -1
  85. package/dist/src-Bw3xE0BI.mjs +0 -2
  86. package/dist/src-Bw3xE0BI.mjs.map +0 -1
  87. package/dist/src-C0Osv7A0.cjs +0 -1
  88. package/dist/stringify-BkjTv8_W.mjs +0 -2
  89. package/dist/stringify-BkjTv8_W.mjs.map +0 -1
  90. package/dist/stringify-DGdYwk9z.d.mts +0 -16
  91. package/dist/stringify-DGdYwk9z.d.mts.map +0 -1
  92. package/dist/stringify-f5GFtoll.cjs +0 -1
  93. package/dist/stringify-iqRz2xah.d.cts +0 -16
  94. package/dist/stringify-iqRz2xah.d.cts.map +0 -1
  95. package/dist/types-DfXe0PRY.d.mts +0 -188
  96. package/dist/types-DfXe0PRY.d.mts.map +0 -1
  97. package/dist/types-DmPnClfS.d.cts +0 -188
  98. package/dist/types-DmPnClfS.d.cts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringify-BkjTv8_W.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":"kGA6BA,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,16 +0,0 @@
1
- import { n as CookieSerializeOptions } from "./types-DfXe0PRY.mjs";
2
-
3
- //#region src/stringify.d.ts
4
-
5
- /**
6
- * Serialize a cookie name-value pair into a `Set-Cookie` header string.
7
- *
8
- * @param name - the name for the cookie
9
- * @param value - value to set the cookie to
10
- * @param options - object containing serialization options
11
- * @returns a `Set-Cookie` header string
12
- */
13
- declare function stringifyCookie(name: string, value: string, options?: CookieSerializeOptions): string;
14
- //#endregion
15
- export { stringifyCookie as t };
16
- //# sourceMappingURL=stringify-DGdYwk9z.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringify-DGdYwk9z.d.mts","names":[],"sources":["../src/stringify.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;iBAAgB,eAAA,wCAGJ"}
@@ -1 +0,0 @@
1
- const e=require(`./src-C0Osv7A0.cjs`),t=require(`./is-string-qyWqKQj-.cjs`),n=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;function r(r,i,a){let o=a??{},s=o.encode??encodeURIComponent;if(!e.n(s))throw Error(`option encode is invalid`);if(!n.test(r))throw Error(`argument name is invalid`);let c=s(i);if(c&&!n.test(c))throw Error(`argument val is invalid`);let l=`${r}=${c}`;if(!e.t(o.maxAge)){let e=Number(o.maxAge);if(Number.isNaN(e)||!Number.isFinite(e))throw TypeError(`option maxAge is invalid`);l+=`; Max-Age=${Math.floor(e)}`}if(o.domain){if(!n.test(o.domain))throw Error(`option domain is invalid`);l+=`; Domain=${o.domain}`}if(o.path){if(!n.test(o.path))throw Error(`option path is invalid`);l+=`; Path=${o.path}`}if(o.expires){if(!e.r(o.expires)||Number.isNaN(o.expires.valueOf()))throw Error(`option expires is invalid`);l+=`; Expires=${o.expires.toUTCString()}`}if(o.httpOnly&&(l+=`; HttpOnly`),o.secure&&(l+=`; Secure`),o.priority)switch(t.t(o.priority)?o.priority.toLowerCase():o.priority){case`low`:l+=`; Priority=Low`;break;case`medium`:l+=`; Priority=Medium`;break;case`high`:l+=`; Priority=High`;break;default:throw Error(`option priority is invalid`)}if(o.sameSite)switch(t.t(o.sameSite)?o.sameSite.toLowerCase():o.sameSite){case!0:l+=`; SameSite=Strict`;break;case`lax`:l+=`; SameSite=Lax`;break;case`strict`:l+=`; SameSite=Strict`;break;case`none`:l+=`; SameSite=None`;break;default:throw Error(`option sameSite is invalid`)}return o.partitioned&&(l+=`; Partitioned`),l}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
@@ -1,16 +0,0 @@
1
- import { n as CookieSerializeOptions } from "./types-DmPnClfS.cjs";
2
-
3
- //#region src/stringify.d.ts
4
-
5
- /**
6
- * Serialize a cookie name-value pair into a `Set-Cookie` header string.
7
- *
8
- * @param name - the name for the cookie
9
- * @param value - value to set the cookie to
10
- * @param options - object containing serialization options
11
- * @returns a `Set-Cookie` header string
12
- */
13
- declare function stringifyCookie(name: string, value: string, options?: CookieSerializeOptions): string;
14
- //#endregion
15
- export { stringifyCookie as t };
16
- //# sourceMappingURL=stringify-iqRz2xah.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringify-iqRz2xah.d.cts","names":[],"sources":["../src/stringify.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;iBAAgB,eAAA,wCAGJ"}
@@ -1,188 +0,0 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Cookie serialization options
4
- */
5
- interface CookieSerializeOptions {
6
- /**
7
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3 | Domain Set-Cookie attribute}. By default, no
8
- * domain is set, and most clients will consider the cookie to apply to only
9
- * the current domain.
10
- */
11
- domain?: string | undefined;
12
- /**
13
- * Specifies a function that will be used to encode a cookie's value. Since
14
- * value of a cookie has a limited character set (and must be a simple
15
- * string), this function can be used to encode a value into a string suited
16
- * for a cookie's value.
17
- *
18
- * The default function is the global `encodeURIComponent`, which will
19
- * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
20
- * any that fall outside of the cookie range.
21
- */
22
- encode?: (value: string) => string;
23
- /**
24
- * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1 | `Expires` `Set-Cookie` attribute}. By default,
25
- * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
26
- * it on a condition like exiting a web browser application.
27
- *
28
- * Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
29
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
30
- * possible not all clients by obey this, so if both are set, they should
31
- * point to the same date and time.
32
- */
33
- expires?: Date | undefined;
34
- /**
35
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6 | `HttpOnly` `Set-Cookie` attribute}.
36
- * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
37
- * default, the `HttpOnly` attribute is not set.
38
- *
39
- * Note* be careful when setting this to true, as compliant clients will
40
- * not allow client-side JavaScript to see the cookie in `document.cookie`.
41
- */
42
- httpOnly?: boolean | undefined;
43
- /**
44
- * Specifies the number (in seconds) to be the value for the `Max-Age`
45
- * `Set-Cookie` attribute. The given number will be converted to an integer
46
- * by rounding down. By default, no maximum age is set.
47
- *
48
- * Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
49
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
50
- * possible not all clients by obey this, so if both are set, they should
51
- * point to the same date and time.
52
- */
53
- maxAge?: number | undefined;
54
- /**
55
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
56
- * By default, the path is considered the "default path".
57
- */
58
- path?: string | undefined;
59
- /**
60
- * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
61
- *
62
- * - `'low'` will set the `Priority` attribute to `Low`.
63
- * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
64
- * - `'high'` will set the `Priority` attribute to `High`.
65
- *
66
- * More information about the different priority levels can be found in
67
- * [the specification][rfc-west-cookie-priority-00-4.1].
68
- *
69
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
70
- * This also means many clients may ignore this attribute until they understand it.
71
- */
72
- priority?: "low" | "medium" | "high" | undefined;
73
- /**
74
- * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
75
- *
76
- * - `true` will set the `SameSite` attribute to `Strict` for strict same
77
- * site enforcement.
78
- * - `false` will not set the `SameSite` attribute.
79
- * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
80
- * enforcement.
81
- * - `'strict'` will set the `SameSite` attribute to Strict for strict same
82
- * site enforcement.
83
- * - `'none'` will set the SameSite attribute to None for an explicit
84
- * cross-site cookie.
85
- *
86
- * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
87
- *
88
- * note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
89
- */
90
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
91
- /**
92
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5 | `Secure` `Set-Cookie` attribute}. When truthy, the
93
- * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
94
- *
95
- * Note* be careful when setting this to `true`, as compliant clients will
96
- * not send the cookie back to the server in the future if the browser does
97
- * not have an HTTPS connection.
98
- */
99
- secure?: boolean | undefined;
100
- /**
101
- * Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1)
102
- * attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
103
- * `Partitioned` attribute is not set.
104
- *
105
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
106
- * This also means many clients may ignore this attribute until they understand it.
107
- *
108
- * More information can be found in the [proposal](https://github.com/privacycg/CHIPS).
109
- */
110
- partitioned?: boolean;
111
- }
112
- /**
113
- * Additional parsing options
114
- */
115
- interface CookieParseOptions {
116
- /**
117
- * Specifies a function that will be used to decode a cookie's value. Since
118
- * the value of a cookie has a limited character set (and must be a simple
119
- * string), this function can be used to decode a previously-encoded cookie
120
- * value into a JavaScript string or other object.
121
- *
122
- * The default function is the global `decodeURIComponent`, which will decode
123
- * any URL-encoded sequences into their byte representations.
124
- *
125
- * Note* if an error is thrown from this function, the original, non-decoded
126
- * cookie value will be returned as the cookie's value.
127
- */
128
- decode?: (value: string) => string;
129
- /**
130
- * Custom function to filter parsing specific keys.
131
- */
132
- filter?: (key: string) => boolean;
133
- }
134
- interface SetCookieParseOptions {
135
- /**
136
- * Custom decode function to use on cookie values.
137
- *
138
- * By default, `decodeURIComponent` is used.
139
- *
140
- * **Note:** If decoding fails, the original (undecoded) value will be used
141
- */
142
- decode?: false | ((value: string) => string);
143
- }
144
- interface SetCookie {
145
- /**
146
- * Cookie name
147
- */
148
- name: string;
149
- /**
150
- * Cookie value
151
- */
152
- value: string;
153
- /**
154
- * Cookie path
155
- */
156
- path?: string | undefined;
157
- /**
158
- * Absolute expiration date for the cookie
159
- */
160
- expires?: Date | undefined;
161
- /**
162
- * Relative max age of the cookie in seconds from when the client receives it (integer or undefined)
163
- *
164
- * Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
165
- */
166
- maxAge?: number | undefined;
167
- /**
168
- * Domain for the cookie,
169
- * May begin with "." to indicate the named domain or any subdomain of it
170
- */
171
- domain?: string | undefined;
172
- /**
173
- * Indicates that this cookie should only be sent over HTTPs
174
- */
175
- secure?: boolean | undefined;
176
- /**
177
- * Indicates that this cookie should not be accessible to client-side JavaScript
178
- */
179
- httpOnly?: boolean | undefined;
180
- /**
181
- * Indicates a cookie ought not to be sent along with cross-site requests
182
- */
183
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
184
- [key: string]: unknown;
185
- }
186
- //#endregion
187
- export { SetCookieParseOptions as i, CookieSerializeOptions as n, SetCookie as r, CookieParseOptions as t };
188
- //# sourceMappingURL=types-DfXe0PRY.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DfXe0PRY.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;AAqBA;AAiHA;AAoBiB,UArIA,sBAAA,CAqIqB;EAWrB;;;;;;;;;;;;;;;;;;;;;;;;;;;YAlHL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmFK,kBAAA;;;;;;;;;;;;;;;;;;;UAoBA,qBAAA;;;;;;;;;;UAWA,SAAA;;;;;;;;;;;;;;;;YAmBL"}
@@ -1,188 +0,0 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Cookie serialization options
4
- */
5
- interface CookieSerializeOptions {
6
- /**
7
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3 | Domain Set-Cookie attribute}. By default, no
8
- * domain is set, and most clients will consider the cookie to apply to only
9
- * the current domain.
10
- */
11
- domain?: string | undefined;
12
- /**
13
- * Specifies a function that will be used to encode a cookie's value. Since
14
- * value of a cookie has a limited character set (and must be a simple
15
- * string), this function can be used to encode a value into a string suited
16
- * for a cookie's value.
17
- *
18
- * The default function is the global `encodeURIComponent`, which will
19
- * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
20
- * any that fall outside of the cookie range.
21
- */
22
- encode?: (value: string) => string;
23
- /**
24
- * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1 | `Expires` `Set-Cookie` attribute}. By default,
25
- * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
26
- * it on a condition like exiting a web browser application.
27
- *
28
- * Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
29
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
30
- * possible not all clients by obey this, so if both are set, they should
31
- * point to the same date and time.
32
- */
33
- expires?: Date | undefined;
34
- /**
35
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6 | `HttpOnly` `Set-Cookie` attribute}.
36
- * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
37
- * default, the `HttpOnly` attribute is not set.
38
- *
39
- * Note* be careful when setting this to true, as compliant clients will
40
- * not allow client-side JavaScript to see the cookie in `document.cookie`.
41
- */
42
- httpOnly?: boolean | undefined;
43
- /**
44
- * Specifies the number (in seconds) to be the value for the `Max-Age`
45
- * `Set-Cookie` attribute. The given number will be converted to an integer
46
- * by rounding down. By default, no maximum age is set.
47
- *
48
- * Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
49
- * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
50
- * possible not all clients by obey this, so if both are set, they should
51
- * point to the same date and time.
52
- */
53
- maxAge?: number | undefined;
54
- /**
55
- * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
56
- * By default, the path is considered the "default path".
57
- */
58
- path?: string | undefined;
59
- /**
60
- * Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
61
- *
62
- * - `'low'` will set the `Priority` attribute to `Low`.
63
- * - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
64
- * - `'high'` will set the `Priority` attribute to `High`.
65
- *
66
- * More information about the different priority levels can be found in
67
- * [the specification][rfc-west-cookie-priority-00-4.1].
68
- *
69
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
70
- * This also means many clients may ignore this attribute until they understand it.
71
- */
72
- priority?: "low" | "medium" | "high" | undefined;
73
- /**
74
- * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
75
- *
76
- * - `true` will set the `SameSite` attribute to `Strict` for strict same
77
- * site enforcement.
78
- * - `false` will not set the `SameSite` attribute.
79
- * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
80
- * enforcement.
81
- * - `'strict'` will set the `SameSite` attribute to Strict for strict same
82
- * site enforcement.
83
- * - `'none'` will set the SameSite attribute to None for an explicit
84
- * cross-site cookie.
85
- *
86
- * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
87
- *
88
- * note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
89
- */
90
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
91
- /**
92
- * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5 | `Secure` `Set-Cookie` attribute}. When truthy, the
93
- * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
94
- *
95
- * Note* be careful when setting this to `true`, as compliant clients will
96
- * not send the cookie back to the server in the future if the browser does
97
- * not have an HTTPS connection.
98
- */
99
- secure?: boolean | undefined;
100
- /**
101
- * Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1)
102
- * attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
103
- * `Partitioned` attribute is not set.
104
- *
105
- * **note** This is an attribute that has not yet been fully standardized, and may change in the future.
106
- * This also means many clients may ignore this attribute until they understand it.
107
- *
108
- * More information can be found in the [proposal](https://github.com/privacycg/CHIPS).
109
- */
110
- partitioned?: boolean;
111
- }
112
- /**
113
- * Additional parsing options
114
- */
115
- interface CookieParseOptions {
116
- /**
117
- * Specifies a function that will be used to decode a cookie's value. Since
118
- * the value of a cookie has a limited character set (and must be a simple
119
- * string), this function can be used to decode a previously-encoded cookie
120
- * value into a JavaScript string or other object.
121
- *
122
- * The default function is the global `decodeURIComponent`, which will decode
123
- * any URL-encoded sequences into their byte representations.
124
- *
125
- * Note* if an error is thrown from this function, the original, non-decoded
126
- * cookie value will be returned as the cookie's value.
127
- */
128
- decode?: (value: string) => string;
129
- /**
130
- * Custom function to filter parsing specific keys.
131
- */
132
- filter?: (key: string) => boolean;
133
- }
134
- interface SetCookieParseOptions {
135
- /**
136
- * Custom decode function to use on cookie values.
137
- *
138
- * By default, `decodeURIComponent` is used.
139
- *
140
- * **Note:** If decoding fails, the original (undecoded) value will be used
141
- */
142
- decode?: false | ((value: string) => string);
143
- }
144
- interface SetCookie {
145
- /**
146
- * Cookie name
147
- */
148
- name: string;
149
- /**
150
- * Cookie value
151
- */
152
- value: string;
153
- /**
154
- * Cookie path
155
- */
156
- path?: string | undefined;
157
- /**
158
- * Absolute expiration date for the cookie
159
- */
160
- expires?: Date | undefined;
161
- /**
162
- * Relative max age of the cookie in seconds from when the client receives it (integer or undefined)
163
- *
164
- * Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
165
- */
166
- maxAge?: number | undefined;
167
- /**
168
- * Domain for the cookie,
169
- * May begin with "." to indicate the named domain or any subdomain of it
170
- */
171
- domain?: string | undefined;
172
- /**
173
- * Indicates that this cookie should only be sent over HTTPs
174
- */
175
- secure?: boolean | undefined;
176
- /**
177
- * Indicates that this cookie should not be accessible to client-side JavaScript
178
- */
179
- httpOnly?: boolean | undefined;
180
- /**
181
- * Indicates a cookie ought not to be sent along with cross-site requests
182
- */
183
- sameSite?: true | false | "lax" | "strict" | "none" | undefined;
184
- [key: string]: unknown;
185
- }
186
- //#endregion
187
- export { SetCookieParseOptions as i, CookieSerializeOptions as n, SetCookie as r, CookieParseOptions as t };
188
- //# sourceMappingURL=types-DmPnClfS.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-DmPnClfS.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;AAqBA;AAiHA;AAoBiB,UArIA,sBAAA,CAqIqB;EAWrB;;;;;;;;;;;;;;;;;;;;;;;;;;;YAlHL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmFK,kBAAA;;;;;;;;;;;;;;;;;;;UAoBA,qBAAA;;;;;;;;;;UAWA,SAAA;;;;;;;;;;;;;;;;YAmBL"}