@shware/security 1.5.8 → 1.5.10
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/dist/utils/http.cjs +3 -3
- package/dist/utils/http.cjs.map +1 -1
- package/dist/utils/http.mjs +4 -4
- package/dist/utils/http.mjs.map +1 -1
- package/package.json +6 -6
package/dist/utils/http.cjs
CHANGED
|
@@ -32,14 +32,14 @@ var import_path_to_regexp = require("path-to-regexp");
|
|
|
32
32
|
function getCookie(request, name) {
|
|
33
33
|
const cookie = request.headers.get("Cookie");
|
|
34
34
|
if (!cookie) return void 0;
|
|
35
|
-
const parsed = (0, import_cookie.
|
|
35
|
+
const parsed = (0, import_cookie.parseCookie)(cookie);
|
|
36
36
|
return parsed[name];
|
|
37
37
|
}
|
|
38
38
|
function setCookie(response, name, value, options) {
|
|
39
|
-
response.headers.append("Set-Cookie", (0, import_cookie.
|
|
39
|
+
response.headers.append("Set-Cookie", (0, import_cookie.stringifySetCookie)(name, value, options));
|
|
40
40
|
}
|
|
41
41
|
function deleteCookie(response, name, options) {
|
|
42
|
-
response.headers.append("Set-Cookie", (0, import_cookie.
|
|
42
|
+
response.headers.append("Set-Cookie", (0, import_cookie.stringifySetCookie)(name, "", { ...options, maxAge: 0 }));
|
|
43
43
|
}
|
|
44
44
|
function param(request, path) {
|
|
45
45
|
const url = new URL(request.url);
|
package/dist/utils/http.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/http.ts"],"sourcesContent":["import { type SerializeOptions,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/http.ts"],"sourcesContent":["import { type SerializeOptions, parseCookie, stringifySetCookie } from 'cookie';\nimport { match } from 'path-to-regexp';\n\nexport type CookieOptions = Omit<SerializeOptions, 'encode'>;\n\nexport function getCookie(request: Request, name: string): string | undefined {\n const cookie = request.headers.get('Cookie');\n if (!cookie) return undefined;\n const parsed = parseCookie(cookie);\n return parsed[name];\n}\n\nexport function setCookie(\n response: Response,\n name: string,\n value: string,\n options?: SerializeOptions\n) {\n response.headers.append('Set-Cookie', stringifySetCookie(name, value, options));\n}\n\nexport function deleteCookie(response: Response, name: string, options?: SerializeOptions) {\n response.headers.append('Set-Cookie', stringifySetCookie(name, '', { ...options, maxAge: 0 }));\n}\n\ntype PathParam<T extends string> = T extends `${string}:${infer Param}/${infer Rest}`\n ? { [K in Param]: string } & PathParam<Rest>\n : T extends `${string}:${infer Param}`\n ? { [K in Param]: string }\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\nexport function param<P extends string>(request: Request, path: P): PathParam<P> {\n const url = new URL(request.url);\n const fn = match(path);\n const result = fn(url.pathname);\n if (!result) throw new Error(`Path not matched: ${url.pathname}, path: ${path}`);\n return result.params as PathParam<P>;\n}\n\nexport function query(request: Request) {\n const url = new URL(request.url);\n return Object.fromEntries(url.searchParams.entries());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuE;AACvE,4BAAsB;AAIf,SAAS,UAAU,SAAkB,MAAkC;AAC5E,QAAM,SAAS,QAAQ,QAAQ,IAAI,QAAQ;AAC3C,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,aAAS,2BAAY,MAAM;AACjC,SAAO,OAAO,IAAI;AACpB;AAEO,SAAS,UACd,UACA,MACA,OACA,SACA;AACA,WAAS,QAAQ,OAAO,kBAAc,kCAAmB,MAAM,OAAO,OAAO,CAAC;AAChF;AAEO,SAAS,aAAa,UAAoB,MAAc,SAA4B;AACzF,WAAS,QAAQ,OAAO,kBAAc,kCAAmB,MAAM,IAAI,EAAE,GAAG,SAAS,QAAQ,EAAE,CAAC,CAAC;AAC/F;AASO,SAAS,MAAwB,SAAkB,MAAuB;AAC/E,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAM,SAAK,6BAAM,IAAI;AACrB,QAAM,SAAS,GAAG,IAAI,QAAQ;AAC9B,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,qBAAqB,IAAI,QAAQ,WAAW,IAAI,EAAE;AAC/E,SAAO,OAAO;AAChB;AAEO,SAAS,MAAM,SAAkB;AACtC,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,SAAO,OAAO,YAAY,IAAI,aAAa,QAAQ,CAAC;AACtD;","names":[]}
|
package/dist/utils/http.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/utils/http.ts
|
|
2
|
-
import {
|
|
2
|
+
import { parseCookie, stringifySetCookie } from "cookie";
|
|
3
3
|
import { match } from "path-to-regexp";
|
|
4
4
|
function getCookie(request, name) {
|
|
5
5
|
const cookie = request.headers.get("Cookie");
|
|
6
6
|
if (!cookie) return void 0;
|
|
7
|
-
const parsed =
|
|
7
|
+
const parsed = parseCookie(cookie);
|
|
8
8
|
return parsed[name];
|
|
9
9
|
}
|
|
10
10
|
function setCookie(response, name, value, options) {
|
|
11
|
-
response.headers.append("Set-Cookie",
|
|
11
|
+
response.headers.append("Set-Cookie", stringifySetCookie(name, value, options));
|
|
12
12
|
}
|
|
13
13
|
function deleteCookie(response, name, options) {
|
|
14
|
-
response.headers.append("Set-Cookie",
|
|
14
|
+
response.headers.append("Set-Cookie", stringifySetCookie(name, "", { ...options, maxAge: 0 }));
|
|
15
15
|
}
|
|
16
16
|
function param(request, path) {
|
|
17
17
|
const url = new URL(request.url);
|
package/dist/utils/http.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/http.ts"],"sourcesContent":["import { type SerializeOptions,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/http.ts"],"sourcesContent":["import { type SerializeOptions, parseCookie, stringifySetCookie } from 'cookie';\nimport { match } from 'path-to-regexp';\n\nexport type CookieOptions = Omit<SerializeOptions, 'encode'>;\n\nexport function getCookie(request: Request, name: string): string | undefined {\n const cookie = request.headers.get('Cookie');\n if (!cookie) return undefined;\n const parsed = parseCookie(cookie);\n return parsed[name];\n}\n\nexport function setCookie(\n response: Response,\n name: string,\n value: string,\n options?: SerializeOptions\n) {\n response.headers.append('Set-Cookie', stringifySetCookie(name, value, options));\n}\n\nexport function deleteCookie(response: Response, name: string, options?: SerializeOptions) {\n response.headers.append('Set-Cookie', stringifySetCookie(name, '', { ...options, maxAge: 0 }));\n}\n\ntype PathParam<T extends string> = T extends `${string}:${infer Param}/${infer Rest}`\n ? { [K in Param]: string } & PathParam<Rest>\n : T extends `${string}:${infer Param}`\n ? { [K in Param]: string }\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\nexport function param<P extends string>(request: Request, path: P): PathParam<P> {\n const url = new URL(request.url);\n const fn = match(path);\n const result = fn(url.pathname);\n if (!result) throw new Error(`Path not matched: ${url.pathname}, path: ${path}`);\n return result.params as PathParam<P>;\n}\n\nexport function query(request: Request) {\n const url = new URL(request.url);\n return Object.fromEntries(url.searchParams.entries());\n}\n"],"mappings":";AAAA,SAAgC,aAAa,0BAA0B;AACvE,SAAS,aAAa;AAIf,SAAS,UAAU,SAAkB,MAAkC;AAC5E,QAAM,SAAS,QAAQ,QAAQ,IAAI,QAAQ;AAC3C,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,SAAS,YAAY,MAAM;AACjC,SAAO,OAAO,IAAI;AACpB;AAEO,SAAS,UACd,UACA,MACA,OACA,SACA;AACA,WAAS,QAAQ,OAAO,cAAc,mBAAmB,MAAM,OAAO,OAAO,CAAC;AAChF;AAEO,SAAS,aAAa,UAAoB,MAAc,SAA4B;AACzF,WAAS,QAAQ,OAAO,cAAc,mBAAmB,MAAM,IAAI,EAAE,GAAG,SAAS,QAAQ,EAAE,CAAC,CAAC;AAC/F;AASO,SAAS,MAAwB,SAAkB,MAAuB;AAC/E,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAM,KAAK,MAAM,IAAI;AACrB,QAAM,SAAS,GAAG,IAAI,QAAQ;AAC9B,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,qBAAqB,IAAI,QAAQ,WAAW,IAAI,EAAE;AAC/E,SAAO,OAAO;AAChB;AAEO,SAAS,MAAM,SAAkB;AACtC,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,SAAO,OAAO,YAAY,IAAI,aAAa,QAAQ,CAAC;AACtD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shware/security",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jest": "^30.0.0",
|
|
27
|
-
"@types/node": "^24.
|
|
27
|
+
"@types/node": "^24.10.1",
|
|
28
28
|
"jest": "^30.2.0",
|
|
29
29
|
"ts-jest": "^29.4.5",
|
|
30
30
|
"ts-node": "^10.9.2",
|
|
31
31
|
"typescript": "5.9.3",
|
|
32
|
-
"@repo/eslint-config": "0.0.
|
|
32
|
+
"@repo/eslint-config": "0.0.9",
|
|
33
33
|
"@repo/typescript-config": "0.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"cookie": "^1.
|
|
36
|
+
"cookie": "^1.1.1",
|
|
37
37
|
"ioredis": "^5.8.2",
|
|
38
|
-
"jose": "^6.1.
|
|
38
|
+
"jose": "^6.1.2",
|
|
39
39
|
"path-to-regexp": "^8.3.0",
|
|
40
40
|
"tiny-invariant": "^1.3.3",
|
|
41
41
|
"uuid": "^13.0.0",
|
|
42
|
-
"zod": "^4.1.
|
|
42
|
+
"zod": "^4.1.13"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"dev": "tsc --watch",
|