added doga

This commit is contained in:
szabomarton
2025-02-25 09:55:29 +01:00
parent 5174ab4cc4
commit 13254e5623
1149 changed files with 80161 additions and 0 deletions

21
25_02_24/node_modules/@tinyhttp/cookie/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 v 1 r t l
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

176
25_02_24/node_modules/@tinyhttp/cookie/README.md generated vendored Normal file
View File

@@ -0,0 +1,176 @@
# @tinyhttp/cookie
[![npm (scoped)](https://img.shields.io/npm/v/@tinyhttp/cookie?style=flat-square)](https://npmjs.com/package/@tinyhttp/cookie) [![npm](https://img.shields.io/npm/dt/@tinyhttp/cookie?style=flat-square)](https://npmjs.com/package/@tinyhttp/cookie)
> A rewrite of [cookie](https://github.com/jshttp/cookie) module.
HTTP cookie parser and serializer for Node.js.
## Install
```sh
pnpm i @tinyhttp/cookie
```
## API
```js
import { parse, serialize } from '@tinyhttp/cookie'
```
### `parse(str, options)`
Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
The `str` argument is the string representing a `Cookie` header value and `options` is an
optional object containing additional parsing options.
```js
import { parse } from '@tinyhttp/cookie'
parse('foo=bar; equation=E%3Dmc%5E2')
// { foo: 'bar', equation: 'E=mc^2' }
```
#### Options
`parse` accepts these properties in the options object.
##### `decode`
Specifies a function that will be used to decode a cookie's value. Since the value of a cookie
has a limited character set (and must be a simple string), this function can be used to decode
a previously-encoded cookie value into a JavaScript string or other object.
The default function is the global `decodeURIComponent`, which will decode any URL-encoded
sequences into their byte representations.
**note** if an error is thrown from this function, the original, non-decoded cookie value will
be returned as the cookie's value.
### `serialize(name, value, options)`
Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
argument is an optional object containing additional serialization options.
```js
import { serialize } from '@tinyhttp/cookie'
serialize('foo', 'bar')
// foo=bar
```
#### Options
`serialize` accepts these properties in the options object.
##### `domain`
Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6265-5.2.3]. By default, no
domain is set, and most clients will consider the cookie to apply to only the current domain.
##### `encode`
Specifies a function that will be used to encode a cookie's value. Since value of a cookie
has a limited character set (and must be a simple string), this function can be used to encode
a value into a string suited for a cookie's value.
The default function is the global `encodeURIComponent`, which will encode a JavaScript string
into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
##### `expires`
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6265-5.2.1].
By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
will delete it on a condition like exiting a web browser application.
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
so if both are set, they should point to the same date and time.
##### `httpOnly`
Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6265-5.2.6]. When truthy,
the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
**note** be careful when setting this to `true`, as compliant clients will not allow client-side
JavaScript to see the cookie in `document.cookie`.
##### `maxAge`
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6265-5.2.2].
The given number will be converted to an integer by rounding down. By default, no maximum age is set.
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
so if both are set, they should point to the same date and time.
##### `path`
Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path
is considered the ["default path"][rfc-6265-5.1.4].
##### `sameSite`
Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-03-4.1.2.7].
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
- `false` will not set the `SameSite` attribute.
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
More information about the different enforcement levels can be found in
[the specification][rfc-6265bis-03-4.1.2.7].
**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.
##### `secure`
Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6265-5.2.5]. When truthy,
the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
the server in the future if the browser does not have an HTTPS connection.
## Example
```ts
import { App } from '@tinyhttp/app'
import { parse, serialize } from '@tinyhttp/cookie'
import { escapeHTML } from 'es-escape-html'
new App()
.use((req, res) => {
if (req.query?.name) {
// Set a new cookie with the name
res.set(
'Set-Cookie',
serialize('name', String(query.name), {
httpOnly: true,
maxAge: 60 * 60 * 24 * 7 // 1 week
})
)
// Redirect back after setting cookie
res
.status(302)
.set('Location', req.headers.referer || '/')
.end()
}
const cookie = parse(req.headers.cookie || '')
const { name } = cookie
res.set('Content-Type', 'text/html; charset=UTF-8')
res.write(name ? `<p>Welcome back, <strong>${escapeHTML(name)}</strong>!</p>` : '<p>Hello, new visitor!</p>')
res.write('<form method="GET">')
res.write('<input placeholder="enter your name" name="name"><input type="submit" value="Set Name">')
res.end('</form>')
})
.listen(3000)
```

22
25_02_24/node_modules/@tinyhttp/cookie/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* Parse a cookie header.
*
* Parse the given cookie header string into an object
* The object has the various cookies as keys(names) => values
*
*/
export declare function parse(str: string, options?: {
decode: (str: string) => string;
}): Record<string, string>;
export type SerializeOptions = Partial<{
encode: (str: string) => string;
maxAge: number;
domain: string;
path: string;
httpOnly: boolean;
secure: boolean;
sameSite: boolean | 'Strict' | 'strict' | 'Lax' | 'lax' | 'None' | 'none' | string;
expires: Date;
}>;
export declare function serialize(name: string, val: string, opt?: SerializeOptions): string;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IACP,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;CAGhC,GACA,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBxB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;IACrC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IAClF,OAAO,EAAE,IAAI,CAAA;CACd,CAAC,CAAA;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,gBAAqB,GAAG,MAAM,CAyDvF"}

70
25_02_24/node_modules/@tinyhttp/cookie/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
const pairSplitRegExp = /; */;
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
function tryDecode(str, decode) {
try {
return decode(str);
} catch (e) {
return str;
}
}
function parse(str, options = {
decode: decodeURIComponent
}) {
const obj = {};
const pairs = str.split(pairSplitRegExp);
for (const pair of pairs) {
let eqIdx = pair.indexOf("=");
if (eqIdx < 0) continue;
const key = pair.slice(0, eqIdx).trim();
let val = pair.slice(++eqIdx, pair.length).trim();
if ('"' === val[0]) val = val.slice(1, -1);
if (obj[key] == null) obj[key] = tryDecode(val, options.decode);
}
return obj;
}
function serialize(name, val, opt = {}) {
if (!opt.encode) opt.encode = encodeURIComponent;
if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid");
const value = opt.encode(val);
if (value && !fieldContentRegExp.test(value)) throw new TypeError("argument val is invalid");
let str = `${name}=${value}`;
if (null != opt.maxAge) {
const maxAge = opt.maxAge - 0;
if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
str += `; Max-Age=${Math.floor(maxAge)}`;
}
if (opt.domain) {
if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
str += `; Domain=${opt.domain}`;
}
if (opt.path) {
if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
str += `; Path=${opt.path}`;
}
if (opt.expires) str += `; Expires=${opt.expires.toUTCString()}`;
if (opt.httpOnly) str += "; HttpOnly";
if (opt.secure) str += "; Secure";
if (opt.sameSite) {
const sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
switch (sameSite) {
case true:
case "strict":
str += "; SameSite=Strict";
break;
case "lax":
str += "; SameSite=Lax";
break;
case "none":
str += "; SameSite=None";
break;
default:
throw new TypeError("option sameSite is invalid");
}
}
return str;
}
export {
parse,
serialize
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["const pairSplitRegExp = /; */\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\n// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str)\n } catch (e) {\n return str\n }\n}\n\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n *\n */\nexport function parse(\n str: string,\n options: {\n decode: (str: string) => string\n } = {\n decode: decodeURIComponent\n }\n): Record<string, string> {\n const obj: Record<string, string> = {}\n const pairs = str.split(pairSplitRegExp)\n\n for (const pair of pairs) {\n let eqIdx = pair.indexOf('=')\n\n // skip things that don't look like key=value\n if (eqIdx < 0) continue\n\n const key = pair.slice(0, eqIdx).trim()\n let val = pair.slice(++eqIdx, pair.length).trim()\n\n // quoted values\n if ('\"' === val[0]) val = val.slice(1, -1)\n\n // only assign once\n if (obj[key] == null) obj[key] = tryDecode(val, options.decode)\n }\n\n return obj\n}\n\nexport type SerializeOptions = Partial<{\n encode: (str: string) => string\n maxAge: number\n domain: string\n path: string\n httpOnly: boolean\n secure: boolean\n sameSite: boolean | 'Strict' | 'strict' | 'Lax' | 'lax' | 'None' | 'none' | string\n expires: Date\n}>\n\nexport function serialize(name: string, val: string, opt: SerializeOptions = {}): string {\n if (!opt.encode) opt.encode = encodeURIComponent\n\n if (!fieldContentRegExp.test(name)) throw new TypeError('argument name is invalid')\n\n const value = opt.encode(val)\n\n if (value && !fieldContentRegExp.test(value)) throw new TypeError('argument val is invalid')\n\n let str = `${name}=${value}`\n\n if (null != opt.maxAge) {\n const maxAge = opt.maxAge - 0\n\n if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError('option maxAge is invalid')\n\n str += `; Max-Age=${Math.floor(maxAge)}`\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) throw new TypeError('option domain is invalid')\n\n str += `; Domain=${opt.domain}`\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) throw new TypeError('option path is invalid')\n\n str += `; Path=${opt.path}`\n }\n\n if (opt.expires) str += `; Expires=${opt.expires.toUTCString()}`\n\n if (opt.httpOnly) str += '; HttpOnly'\n\n if (opt.secure) str += '; Secure'\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite\n\n switch (sameSite) {\n case true:\n case 'strict':\n str += '; SameSite=Strict'\n break\n case 'lax':\n str += '; SameSite=Lax'\n break\n case 'none':\n str += '; SameSite=None'\n break\n default:\n throw new TypeError('option sameSite is invalid')\n }\n }\n\n return str\n}\n"],"names":[],"mappings":"AAAA,MAAM,kBAAkB;AAWxB,MAAM,qBAAqB;AAE3B,SAAS,UAAU,KAAa,QAAiC;AAC3D,MAAA;AACF,WAAO,OAAO,GAAG;AAAA,WACV,GAAG;AACH,WAAA;AAAA,EACT;AACF;AASgB,SAAA,MACd,KACA,UAEI;AAAA,EACF,QAAQ;AACV,GACwB;AACxB,QAAM,MAA8B,CAAA;AAC9B,QAAA,QAAQ,IAAI,MAAM,eAAe;AAEvC,aAAW,QAAQ,OAAO;AACpB,QAAA,QAAQ,KAAK,QAAQ,GAAG;AAG5B,QAAI,QAAQ,EAAG;AAEf,UAAM,MAAM,KAAK,MAAM,GAAG,KAAK,EAAE;AAC7B,QAAA,MAAM,KAAK,MAAM,EAAE,OAAO,KAAK,MAAM,EAAE;AAGvC,QAAA,QAAQ,IAAI,CAAC,SAAS,IAAI,MA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AAA;AACP;AAAA,MACF,KAAK;AACI,eAAA;AACP;AAAA,MACF,KAAK;AACI,eAAA;AACP;AAAA,MACF;AACQ,cAAA,IAAI,UAAU,4BAA4B;AAAA,IACpD;AAAA,EACF;AAEO,SAAA;AACT;"}

39
25_02_24/node_modules/@tinyhttp/cookie/package.json generated vendored Normal file
View File

@@ -0,0 +1,39 @@
{
"name": "@tinyhttp/cookie",
"version": "2.1.1",
"type": "module",
"description": "HTTP cookie parser and serializer for Node.js",
"homepage": "https://github.com/tinyhttp/tinyhttp/tree/master/packages/cookie#readme",
"engines": {
"node": ">=12.20.0"
},
"funding": {
"type": "individual",
"url": "https://github.com/tinyhttp/tinyhttp?sponsor=1"
},
"repository": {
"type": "git",
"url": "https://github.com/tinyhttp/tinyhttp.git",
"directory": "packages/cookie"
},
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"keywords": [
"tinyhttp",
"node.js",
"web framework",
"web",
"backend",
"cookie"
],
"files": [
"dist"
],
"author": "v1rtl",
"license": "MIT",
"dependencies": {},
"scripts": {
"dev": "vite",
"build": "vite build"
}
}