Gathering detailed insights and metrics for csrf
Gathering detailed insights and metrics for csrf
Gathering detailed insights and metrics for csrf
Gathering detailed insights and metrics for csrf
npm install csrf
98.2
Supply Chain
99.5
Quality
77.4
Maintenance
100
Vulnerability
100
License
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
300 Stars
293 Commits
32 Forks
20 Watching
1 Branches
29 Contributors
Updated on 22 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-20.9%
130,097
Compared to previous day
Last week
1.8%
794,688
Compared to previous week
Last month
7.3%
3,424,643
Compared to previous month
Last year
9%
33,483,536
Compared to previous year
Logic behind CSRF token creation and verification.
Read Understanding-CSRF for more information on CSRF. Use this module to create custom CSRF middleware.
Looking for a CSRF framework for your favorite framework that uses this module?
1$ npm install csrf
This module includes a TypeScript declaration file to enable auto complete in compatible editors and type information for TypeScript projects.
1var Tokens = require('csrf')
Create a new token generation/verification instance. The options
argument is
optional and will just use all defaults if missing.
Tokens accepts these properties in the options object.
The length of the internal salt to use, in characters. Internally, the salt
is a base 62 string. Defaults to 8
characters.
The length of the secret to generate, in bytes. Note that the secret is
passed around base-64 encoded and that this length refers to the underlying
bytes, not the length of the base-64 string. Defaults to 18
bytes.
Create a new CSRF token attached to the given secret
. The secret
is a
string, typically generated from the tokens.secret()
or tokens.secretSync()
methods. This token is what you should add into HTML <form>
blocks and
expect the user's browser to provide back.
1var secret = tokens.secretSync() 2var token = tokens.create(secret)
Asynchronously create a new secret
, which is a string. The secret is to
be kept on the server, typically stored in a server-side session for the
user. The secret should be at least per user.
1tokens.secret(function (err, secret) { 2 if (err) throw err 3 // do something with the secret 4})
Asynchronously create a new secret
and return a Promise
. Please see
tokens.secret(callback)
documentation for full details.
Note: To use promises in Node.js prior to 0.12, promises must be
"polyfilled" using global.Promise = require('bluebird')
.
1tokens.secret().then(function (secret) { 2 // do something with the secret 3})
A synchronous version of tokens.secret(callback)
. Please see
tokens.secret(callback)
documentation for full details.
1var secret = tokens.secretSync()
Check whether a CSRF token is valid for the given secret
, returning
a Boolean.
1if (!tokens.verify(secret, token)) { 2 throw new Error('invalid token!') 3}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
11 different organizations found -- score normalized to 10
Details
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no vulnerabilities detected
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
0 out of 1 merged PRs checked by a CI test -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
found 29 unreviewed changesets out of 30 -- score normalized to 0
Reason
no update tool detected
Details
Reason
project is not fuzzed
Details
Reason
0 commit(s) out of 30 and 0 issue activity out of 8 found in the last 90 days -- score normalized to 0
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Score
Last Scanned on 2024-11-25T21:27:35Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More