Skip to content

Commit

Permalink
fix(types): reference jshttp/cookie types
Browse files Browse the repository at this point in the history
fixes #330
  • Loading branch information
vvo committed Apr 19, 2021
1 parent 58e53b1 commit 4762fc6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
33 changes: 3 additions & 30 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { CookieSerializeOptions } from "@types/cookie";

export type SessionOptions = {
/** Name of the cookie
*
Expand All @@ -12,7 +14,7 @@ export type SessionOptions = {
sameSite: 'lax'
secure: true
} */
cookieOptions?: CookieOptions;
cookieOptions?: CookieSerializeOptions;

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

export type CookieOptions = {
/** Forbids JavaScript from accessing the cookie.
* For example, through the Document.cookie property, the XMLHttpRequest API, or the Request API.
* This mitigates attacks against cross-site scripting (XSS).
*
* Default: true */
httpOnly?: boolean;

/** A path that must exist in the requested URL, or the browser won't send the Cookie header.
*
* Default: "/" */
path?: string;

/** Asserts that a cookie must not be sent with cross-origin requests, providing some protection against cross-site request forgery attacks
*
* Default: "lax" */
sameSite?: "none" | "lax" | "strict";

/** A secure cookie is only sent to the server when a request is made with the https: scheme.
*
* Default: true */
secure?: boolean;

/**
* 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
*/
maxAge?: number;
};

export function applySession(
req: any,
res: any,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
]
},
"dependencies": {
"@types/cookie": "^0.4.0",
"array.prototype.flat": "^1.2.4",
"clone": "^2.1.2",
"cookie": "^0.4.1",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==

"@types/cookie@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.0.tgz#14f854c0f93d326e39da6e3b6f34f7d37513d108"
integrity sha512-y7mImlc/rNkvCRmg8gC3/lj87S7pTUIJ6QGjwHR9WQJcFs+ZMTOaoPrkdFA/YdbuqVEmEbb5RdhVxMkAcgOnpg==

"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
Expand Down

1 comment on commit 4762fc6

@vercel
Copy link

@vercel vercel bot commented on 4762fc6 Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.