Skip to content

Commit 4762fc6

Browse files
committed
fix(types): reference jshttp/cookie types
fixes #330
1 parent 58e53b1 commit 4762fc6

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

lib/index.d.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { CookieSerializeOptions } from "@types/cookie";
2+
13
export type SessionOptions = {
24
/** Name of the cookie
35
*
@@ -12,7 +14,7 @@ export type SessionOptions = {
1214
sameSite: 'lax'
1315
secure: true
1416
} */
15-
cookieOptions?: CookieOptions;
17+
cookieOptions?: CookieSerializeOptions;
1618

1719
/** Password of the cookie
1820
*
@@ -35,35 +37,6 @@ export type Session = {
3537
save: () => Promise<string>;
3638
};
3739

38-
export type CookieOptions = {
39-
/** Forbids JavaScript from accessing the cookie.
40-
* For example, through the Document.cookie property, the XMLHttpRequest API, or the Request API.
41-
* This mitigates attacks against cross-site scripting (XSS).
42-
*
43-
* Default: true */
44-
httpOnly?: boolean;
45-
46-
/** A path that must exist in the requested URL, or the browser won't send the Cookie header.
47-
*
48-
* Default: "/" */
49-
path?: string;
50-
51-
/** Asserts that a cookie must not be sent with cross-origin requests, providing some protection against cross-site request forgery attacks
52-
*
53-
* Default: "lax" */
54-
sameSite?: "none" | "lax" | "strict";
55-
56-
/** A secure cookie is only sent to the server when a request is made with the https: scheme.
57-
*
58-
* Default: true */
59-
secure?: boolean;
60-
61-
/**
62-
* Specifies the number (in seconds) to be the value for the Max-Age Set-Cookie attribute. The given number will be converted to an integer by rounding down. By default, it will be 15 days by default
63-
*/
64-
maxAge?: number;
65-
};
66-
6740
export function applySession(
6841
req: any,
6942
res: any,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
]
8080
},
8181
"dependencies": {
82+
"@types/cookie": "^0.4.0",
8283
"array.prototype.flat": "^1.2.4",
8384
"clone": "^2.1.2",
8485
"cookie": "^0.4.1",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,11 @@
17581758
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
17591759
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
17601760

1761+
"@types/cookie@^0.4.0":
1762+
version "0.4.0"
1763+
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.0.tgz#14f854c0f93d326e39da6e3b6f34f7d37513d108"
1764+
integrity sha512-y7mImlc/rNkvCRmg8gC3/lj87S7pTUIJ6QGjwHR9WQJcFs+ZMTOaoPrkdFA/YdbuqVEmEbb5RdhVxMkAcgOnpg==
1765+
17611766
"@types/events@*":
17621767
version "3.0.0"
17631768
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"

0 commit comments

Comments
 (0)