Skip to content

Commit

Permalink
feat: allow to override cookie's httpOnly flag
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Nov 30, 2023
1 parent 51da818 commit b09894a
Showing 1 changed file with 4 additions and 4 deletions.
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
} = {},
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 });
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

0 comments on commit b09894a

Please sign in to comment.