@stryke/cookie 0.1.14 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +172 -0
- package/README.md +33 -26
- package/dist/index.cjs +1 -49
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +1 -1
- package/dist/is-string-Cdq5ranA.mjs +2 -0
- package/dist/is-string-Cdq5ranA.mjs.map +1 -0
- package/dist/is-string-qyWqKQj-.cjs +1 -0
- package/dist/parse-CB7V9-FM.mjs +2 -0
- package/dist/parse-CB7V9-FM.mjs.map +1 -0
- package/dist/{parse.d.ts → parse-CC7RDu95.d.cts} +9 -3
- package/dist/parse-CC7RDu95.d.cts.map +1 -0
- package/dist/parse-DClQAhyZ.d.mts +23 -0
- package/dist/parse-DClQAhyZ.d.mts.map +1 -0
- package/dist/parse-Lu_9IylD.cjs +1 -0
- package/dist/parse.cjs +1 -90
- package/dist/parse.d.cts +2 -0
- package/dist/parse.d.mts +2 -0
- package/dist/parse.mjs +1 -1
- package/dist/split-BMQx0Ga2.d.mts +5 -0
- package/dist/split-BMQx0Ga2.d.mts.map +1 -0
- package/dist/split-DGuM3LaG.cjs +1 -0
- package/dist/split-DyNIhQJp.mjs +2 -0
- package/dist/split-DyNIhQJp.mjs.map +1 -0
- package/dist/split-Y8qgB1su.d.cts +5 -0
- package/dist/split-Y8qgB1su.d.cts.map +1 -0
- package/dist/split.cjs +1 -31
- package/dist/split.d.cts +2 -0
- package/dist/split.d.mts +2 -0
- package/dist/split.mjs +1 -1
- package/dist/src-Bw3xE0BI.mjs +2 -0
- package/dist/src-Bw3xE0BI.mjs.map +1 -0
- package/dist/src-C0Osv7A0.cjs +1 -0
- package/dist/stringify-BkjTv8_W.mjs +2 -0
- package/dist/stringify-BkjTv8_W.mjs.map +1 -0
- package/dist/stringify-DGdYwk9z.d.mts +16 -0
- package/dist/stringify-DGdYwk9z.d.mts.map +1 -0
- package/dist/stringify-f5GFtoll.cjs +1 -0
- package/dist/stringify-iqRz2xah.d.cts +16 -0
- package/dist/stringify-iqRz2xah.d.cts.map +1 -0
- package/dist/stringify.cjs +1 -78
- package/dist/stringify.d.cts +2 -0
- package/dist/stringify.d.mts +2 -0
- package/dist/stringify.mjs +1 -1
- package/dist/types-DfXe0PRY.d.mts +188 -0
- package/dist/types-DfXe0PRY.d.mts.map +1 -0
- package/dist/types-DmPnClfS.d.cts +188 -0
- package/dist/types-DmPnClfS.d.cts.map +1 -0
- package/dist/types.cjs +0 -1
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +18 -106
- package/dist/index.d.ts +0 -4
- package/dist/split.d.ts +0 -1
- package/dist/stringify.d.ts +0 -10
- package/dist/types.d.ts +0 -184
package/dist/split.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./split-DyNIhQJp.mjs";export{e as splitSetCookieString};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e),t=e=>typeof e==`object`&&!!e,n=n=>t(n)&&e(n)==`[object Date]`;function r(t){return e(t)===`[object Function]`}function i(t){return e(t)===`[object AsyncFunction]`}const a=e=>{try{return e instanceof Function||typeof e==`function`||!!(e?.constructor&&e?.call&&e?.apply)||r(e)||i(e)}catch{return!1}},o=e=>{try{return e===null}catch{return!1}},s=e=>e===void 0,c=e=>{try{return s(e)||o(e)}catch{return!1}};typeof Buffer<`u`&&Buffer.isBuffer.bind(Buffer),(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);const l=e=>{try{return!c(e)}catch{return!1}};export{a as n,n as r,l as t};
|
|
2
|
+
//# sourceMappingURL=src-Bw3xE0BI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-Bw3xE0BI.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../type-checks/src/get-object-tag.ts","../../type-checks/src/is-plain-object.ts","../../type-checks/src/is-date.ts","../../type-checks/src/is-function.ts","../../type-checks/src/is-null.ts","../../type-checks/src/is-undefined.ts","../../type-checks/src/is-empty.ts","../../type-checks/src/is-buffer.ts","../../type-checks/src/type-detect.ts","../../type-checks/src/is-set.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\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\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\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\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\nimport { getObjectTag } from \"./get-object-tag\";\nimport { isObjectLike } from \"./is-plain-object\";\n\n/**\n * Checks if `value` is classified as a `Date` object.\n *\n * @example\n * ```typescript\n * isDate(new Date)\n * // => true\n *\n * isDate('Mon April 23 2012')\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `obj` is a date object, else `false`.\n */\nexport const isDate = (value: unknown): value is Date =>\n isObjectLike(value) && getObjectTag(value) == \"[object Date]\";\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\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\nexport function isSyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object Function]\";\n}\n\nexport function isAsyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object AsyncFunction]\";\n}\n\n/**\n * Check if the provided value's type is `Function`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Function`\n */\nexport const isFunction = (value: unknown): value is AnyFunction => {\n try {\n return (\n value instanceof Function ||\n typeof value === \"function\" ||\n Boolean(\n value?.constructor && (value as any)?.call && (value as any)?.apply\n ) ||\n isSyncFunction(value) ||\n isAsyncFunction(value)\n );\n } catch {\n return false;\n }\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 const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\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 const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\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\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\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 const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\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\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\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\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":"AAwBA,MAAa,EAAgB,GACvB,GAAS,KACJ,IAAU,IAAA,GAAY,qBAAuB,gBAE/C,OAAO,UAAU,SAAS,KAAK,EAAM,CCejC,EAAgB,GACpB,OAAO,GAAQ,YAAY,ECRvB,EAAU,GACrB,EAAa,EAAM,EAAI,EAAa,EAAM,EAAI,gBChBhD,SAAgB,EAAe,EAAmC,CAChE,OAAO,EAAa,EAAM,GAAK,oBAGjC,SAAgB,EAAgB,EAAmC,CACjE,OAAO,EAAa,EAAM,GAAK,yBASjC,MAAa,EAAc,GAAyC,CAClE,GAAI,CACF,OACE,aAAiB,UACjB,OAAO,GAAU,YACjB,GACE,GAAO,aAAgB,GAAe,MAAS,GAAe,QAEhE,EAAe,EAAM,EACrB,EAAgB,EAAM,MAElB,CACN,MAAO,KC7BE,EAAU,GAAkC,CACvD,GAAI,CACF,OAAO,IAAU,UACX,CACN,MAAO,KCJE,EAAe,GACnB,IAAU,IAAA,GCYN,EAAW,GAAmB,CACzC,GAAI,CACF,OAAO,EAAY,EAAM,EAAI,EAAO,EAAM,MACpC,CACN,MAAO,KCjBmB,OAAO,OAAW,KAM5C,OAAO,SAAS,KAAK,OAAO,ECJV,IAChB,OAAO,YAAe,UAG1B,OAAO,eAAe,EAAK,yBAA0B,CACnD,KAAM,CACJ,OAAO,MAET,aAAc,GACf,CAAC,CAPO,aAeR,OAAO,UAAU,CCXpB,MAAa,EAAS,GAAkD,CACtE,GAAI,CACF,MAAO,CAAC,EAAQ,EAAM,MAChB,CACN,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e),t=e=>typeof e==`object`&&!!e,n=n=>t(n)&&e(n)==`[object Date]`;function r(t){return e(t)===`[object Function]`}function i(t){return e(t)===`[object AsyncFunction]`}const a=e=>{try{return e instanceof Function||typeof e==`function`||!!(e?.constructor&&e?.call&&e?.apply)||r(e)||i(e)}catch{return!1}},o=e=>{try{return e===null}catch{return!1}},s=e=>e===void 0,c=e=>{try{return s(e)||o(e)}catch{return!1}},l=typeof Buffer<`u`,u=l?Buffer.isBuffer.bind(Buffer):function(e){return!1},d=(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype),f=e=>{try{return!c(e)}catch{return!1}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./src-Bw3xE0BI.mjs";import{t as r}from"./is-string-Cdq5ranA.mjs";const i=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;function a(a,o,s){let c=s??{},l=c.encode??encodeURIComponent;if(!e(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(!n(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(!t(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(r(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(r(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 t};
|
|
2
|
+
//# sourceMappingURL=stringify-BkjTv8_W.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify-DGdYwk9z.d.mts","names":[],"sources":["../src/stringify.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;iBAAgB,eAAA,wCAGJ"}
|
|
@@ -0,0 +1 @@
|
|
|
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}});
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify-iqRz2xah.d.cts","names":[],"sources":["../src/stringify.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;iBAAgB,eAAA,wCAGJ"}
|
package/dist/stringify.cjs
CHANGED
|
@@ -1,78 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stringifyCookie = stringifyCookie;
|
|
7
|
-
var _typeChecks = require("@stryke/type-checks");
|
|
8
|
-
const r = /^[\t\u0020-\u007E\u0080-\u00FF]+$/;
|
|
9
|
-
function stringifyCookie(n, p, m) {
|
|
10
|
-
const i = m ?? {},
|
|
11
|
-
a = i.encode ?? encodeURIComponent;
|
|
12
|
-
if (!(0, _typeChecks.isFunction)(a)) throw new Error("option encode is invalid");
|
|
13
|
-
if (!r.test(n)) throw new Error("argument name is invalid");
|
|
14
|
-
const o = a(p);
|
|
15
|
-
if (o && !r.test(o)) throw new Error("argument val is invalid");
|
|
16
|
-
let e = `${n}=${o}`;
|
|
17
|
-
if (!(0, _typeChecks.isSet)(i.maxAge)) {
|
|
18
|
-
const t = Number(i.maxAge);
|
|
19
|
-
if (Number.isNaN(t) || !Number.isFinite(t)) throw new TypeError("option maxAge is invalid");
|
|
20
|
-
e += `; Max-Age=${Math.floor(t)}`;
|
|
21
|
-
}
|
|
22
|
-
if (i.domain) {
|
|
23
|
-
if (!r.test(i.domain)) throw new Error("option domain is invalid");
|
|
24
|
-
e += `; Domain=${i.domain}`;
|
|
25
|
-
}
|
|
26
|
-
if (i.path) {
|
|
27
|
-
if (!r.test(i.path)) throw new Error("option path is invalid");
|
|
28
|
-
e += `; Path=${i.path}`;
|
|
29
|
-
}
|
|
30
|
-
if (i.expires) {
|
|
31
|
-
if (!(0, _typeChecks.isDate)(i.expires) || Number.isNaN(i.expires.valueOf())) throw new Error("option expires is invalid");
|
|
32
|
-
e += `; Expires=${i.expires.toUTCString()}`;
|
|
33
|
-
}
|
|
34
|
-
if (i.httpOnly && (e += "; HttpOnly"), i.secure && (e += "; Secure"), i.priority) switch ((0, _typeChecks.isString)(i.priority) ? i.priority.toLowerCase() : i.priority) {
|
|
35
|
-
case "low":
|
|
36
|
-
{
|
|
37
|
-
e += "; Priority=Low";
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
case "medium":
|
|
41
|
-
{
|
|
42
|
-
e += "; Priority=Medium";
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
case "high":
|
|
46
|
-
{
|
|
47
|
-
e += "; Priority=High";
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
default:
|
|
51
|
-
throw new Error("option priority is invalid");
|
|
52
|
-
}
|
|
53
|
-
if (i.sameSite) switch ((0, _typeChecks.isString)(i.sameSite) ? i.sameSite.toLowerCase() : i.sameSite) {
|
|
54
|
-
case !0:
|
|
55
|
-
{
|
|
56
|
-
e += "; SameSite=Strict";
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
case "lax":
|
|
60
|
-
{
|
|
61
|
-
e += "; SameSite=Lax";
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
case "strict":
|
|
65
|
-
{
|
|
66
|
-
e += "; SameSite=Strict";
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
case "none":
|
|
70
|
-
{
|
|
71
|
-
e += "; SameSite=None";
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
default:
|
|
75
|
-
throw new Error("option sameSite is invalid");
|
|
76
|
-
}
|
|
77
|
-
return i.partitioned && (e += "; Partitioned"), e;
|
|
78
|
-
}
|
|
1
|
+
require(`./src-C0Osv7A0.cjs`);const e=require(`./stringify-f5GFtoll.cjs`);exports.stringifyCookie=e.t;
|
package/dist/stringify.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./src-Bw3xE0BI.mjs";import{t as e}from"./stringify-BkjTv8_W.mjs";export{e as stringifyCookie};
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/types.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/types.d.cts
ADDED
package/dist/types.d.mts
ADDED
package/dist/types.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|