
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
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;
MIT.
See LICENSE file for details.
FAQs
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
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.