Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to override cookie's httpOnly flag #42

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function doubleCsrf({
sameSite = "lax",
path = "/",
secure = true,
...remainingCOokieOptions
...remainingCookieOptions
Copy link
Contributor

Choose a reason for hiding this comment

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

Cheers, I have no idea how this capitalisation typo keeps coming back! 😂

} = {},
size = 64,
ignoredMethods = ["GET", "HEAD", "OPTIONS"],
Expand All @@ -94,7 +94,7 @@ export function doubleCsrf({
sameSite,
path,
secure,
...remainingCOokieOptions,
...remainingCookieOptions,
};

const invalidCsrfTokenError = createHttpError(403, "invalid csrf token", {
Expand Down Expand Up @@ -156,11 +156,11 @@ export function doubleCsrf({
validateOnReuse
);
const cookieContent = `${csrfToken}|${csrfTokenHash}`;
res.cookie(cookieName, cookieContent, { ...cookieOptions, httpOnly: true });
res.cookie(cookieName, cookieContent, { httpOnly: true, ...cookieOptions });
psibean marked this conversation as resolved.
Show resolved Hide resolved
return csrfToken;
};

const getCsrfCookieFromRequest = remainingCOokieOptions.signed
const getCsrfCookieFromRequest = remainingCookieOptions.signed
? (req: Request) => req.signedCookies[cookieName] as string
: (req: Request) => req.cookies[cookieName] as string;

Expand Down
Loading