Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
cookie-signature
Advanced tools
The cookie-signature package is used to sign and unsign values using a secret key, typically for use in cookie values to prevent tampering. It provides a simple API for signing and verifying strings.
Sign
This feature allows you to sign a value using a secret key. The result is a signed value that can be used in a cookie or other transport method. The signature is appended to the value with a 's:' prefix.
"signature = require('cookie-signature');\nsignedValue = signature.sign('value', 'secret');"
Unsign
This feature allows you to unsign a previously signed value using the same secret key. If the signature is valid, the original value is returned. If the signature is invalid, a false value is returned, indicating potential tampering.
"signature = require('cookie-signature');\nunsignedValue = signature.unsign('signedValue', 'secret');"
jsonwebtoken (or JWT) is a package that allows you to encode and decode JSON Web Tokens, which are an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This package provides more complex features like token expiration, audience, issuer validation, and more, compared to the simpler cookie-signature package.
secure-cookie is a package that provides cookie signing and encryption. It offers additional security by encrypting the cookie value, which cookie-signature does not do. secure-cookie is a good choice if you need to protect sensitive information in cookies beyond just preventing tampering.
keygrip is a package for signing and verifying data (like cookies) but with support for key rotation. It allows you to use an array of keys for signing and will verify signatures against any of the provided keys. This is useful for applications that need to rotate secrets without invalidating existing signatures, which is not a feature provided by cookie-signature.
Sign and unsign cookies.
var cookie = require('cookie-signature');
var val = cookie.sign('hello', 'tobiiscool');
val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');
var val = cookie.sign('hello', 'tobiiscool');
cookie.unsign(val, 'tobiiscool').should.equal('hello');
cookie.unsign(val, 'luna').should.be.false;
(The MIT License)
Copyright (c) 2012 LearnBoost <tj@learnboost.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Sign and unsign cookies
The npm package cookie-signature receives a total of 29,165,831 weekly downloads. As such, cookie-signature popularity was classified as popular.
We found that cookie-signature demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.