Single API for CSRF functions, working in Node.js, Browsers and other runtimes
npm install uncsrf[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
[![License][license-src]][license-href]
This library provides a single api to create and verify csrf token. It use web-crypto for non Node.js target and node:crypto using Conditional Exports.
Requirements:
- Node.js
- Browser: Secure Context (HTTPS/Localhost) in Supported Browsers
- Other Runtimes: Exposed globalThis.crypto and globalThis.crypto.subtle. (you can polyfill if needed)
Install package:
``shnpm
npm install uncsrf
Import:
`js
// ESM
import { importEncryptSecret, create, verify } from "uncsrf";// CommonJS
const { importEncryptSecret, create, verify } = require("uncsrf");
`Development
- Clone this repository
- Install latest LTS version of Node.js
- Enable Corepack using
corepack enable
- Install dependencies using pnpm install
- Run interactive tests using pnpm dev`Made with 💛, inspired by uncrypto.
Published under MIT License.
[npm-version-src]: https://img.shields.io/npm/v/uncsrf?style=flat-square
[npm-version-href]: https://npmjs.com/package/uncsrf
[npm-downloads-src]: https://img.shields.io/npm/dt/uncsrf.svg?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/uncsrf
[github-actions-ci-src]: https://img.shields.io/github/actions/workflow/status/morgbn/uncsrf/ci.yml?style=flat-square
[github-actions-ci-href]: https://github.com/morgbn/uncsrf/actions
[license-src]: https://img.shields.io/npm/l/uncsrf.svg?style=flat-square
[license-href]: https://npmjs.com/package/uncsrf