Socket
Book a DemoInstallSign in
Socket

@tinyhttp/cookie-signature

Package Overview
Dependencies
Maintainers
0
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/cookie-signature

HTTP cookie signing and unsigning

2.1.1
latest
Source
npmnpm
Version published
Weekly downloads
148K
-22.78%
Maintainers
0
Weekly downloads
 
Created

What is @tinyhttp/cookie-signature?

@tinyhttp/cookie-signature is a lightweight npm package used for signing and unsigning cookies. It provides a simple API to ensure the integrity of cookies by generating a signature and verifying it.

What are @tinyhttp/cookie-signature's main functionalities?

Sign a Cookie

This feature allows you to sign a cookie value with a secret key. The `sign` method generates a signed version of the cookie value, which can be used to ensure the integrity of the cookie.

const cookieSignature = require('@tinyhttp/cookie-signature');
const value = 'cookieValue';
const secret = 'mySecret';
const signedValue = cookieSignature.sign(value, secret);
console.log(signedValue);

Unsign a Cookie

This feature allows you to unsign a signed cookie value using the same secret key. The `unsign` method verifies the signature and returns the original value if the signature is valid, otherwise it returns false.

const cookieSignature = require('@tinyhttp/cookie-signature');
const signedValue = 'cookieValue.signedPart';
const secret = 'mySecret';
const unsignedValue = cookieSignature.unsign(signedValue, secret);
if (unsignedValue) {
  console.log('Valid signature:', unsignedValue);
} else {
  console.log('Invalid signature');
}

Other packages similar to @tinyhttp/cookie-signature

Keywords

tinyhttp

FAQs

Package last updated on 26 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.