
Security News
Federal Audit Finds NIST Wasted Funds With No Plan to Clear NVD Backlog
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.
elysia-csrf
Advanced tools
CSRF (Cross-Site Request Forgery) protection plugin for Elysia.
bun add elysia-csrf
import { Elysia } from "elysia";
import { csrf } from "elysia-csrf";
const app = new Elysia()
.use(csrf({ cookie: true }))
.get("/form", ({ csrfToken }) => {
return `
<form method="POST" action="/submit">
<input type="hidden" name="_csrf" value="${csrfToken()}" />
<input type="text" name="data" />
<button type="submit">Submit</button>
</form>
`;
})
.post("/submit", ({ body }) => {
return { success: true, data: body };
})
.listen(3000);
csrf({
cookie?: boolean | {
key?: string; // Cookie name (default: "_csrf")
domain?: string;
httpOnly?: boolean; // Default: true
maxAge?: number;
path?: string; // Default: "/"
sameSite?: "lax" | "none" | "strict"; // Default: "lax"
secure?: boolean;
signed?: boolean;
};
ignoreMethods?: string[]; // Default: ["GET", "HEAD", "OPTIONS"]
value?: (context: any) => string | undefined; // Custom token extractor
saltLength?: number; // Default: 8
secretLength?: number; // Default: 18
secret?: string;
})
By default, tokens are extracted from (in order):
body._csrfquery._csrfcsrf-token, xsrf-token, x-csrf-token, x-xsrf-tokenCustomize with the value option.
Run tests to see examples of all features:
bun test
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
CSRF protection plugin for Elysia with cookie-based token storage
We found that elysia-csrf demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.