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
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.2
Supply Chain
99.5
Quality
77.4
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
191,322,516
Last Day
139,463
Last Week
864,524
Last Month
3,541,985
Last Year
34,076,933
301 Stars
293 Commits
32 Forks
19 Watching
1 Branches
29 Contributors
Minified
Minified + Gzipped
Latest Version
3.1.0
Package Id
csrf@3.1.0
Size
4.69 kB
NPM Version
6.4.1
Node Version
8.15.1
Publised On
10 Apr 2019
Cumulative downloads
Total Downloads
Last day
-3.6%
139,463
Compared to previous day
Last week
1.8%
864,524
Compared to previous week
Last month
5.1%
3,541,985
Compared to previous month
Last year
12%
34,076,933
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-12-09T21:28:13Z
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