Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tinyhttp/cookie-signature

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/cookie-signature - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

6

CHANGELOG.md
# @tinyhttp/cookie-signature
## 0.1.6
### Patch Changes
- Compress whitespace
## 0.1.5

@@ -4,0 +10,0 @@

16

dist/index.js

@@ -1,15 +0,1 @@

import {createHmac,timingSafeEqual}from'crypto';/**
* Sign the given `val` with `secret`.
*/
const sign = (val, secret) => {
return `${val}.${createHmac('sha256', secret).update(val).digest('base64').replace(/=+$/, '')}`;
};
/**
* Unsign and decode the given `val` with `secret`,
* returning `false` if the signature is invalid.
*/
const unsign = (val, secret) => {
const str = val.slice(0, val.lastIndexOf('.')), mac = sign(str, secret), macBuffer = Buffer.from(mac), valBuffer = Buffer.alloc(macBuffer.length);
valBuffer.write(val);
return timingSafeEqual(macBuffer, valBuffer) ? str : false;
};export{sign,unsign};
import{createHmac,timingSafeEqual}from'crypto';let sign=(val,secret)=>{return`${val}.${createHmac("sha256",secret).update(val).digest("base64").replace(/=+$/,"")}`};let unsign=(val,secret)=>{const str=val.slice(0,val.lastIndexOf(".")),mac=sign(str,secret),macBuffer=Buffer.from(mac),valBuffer=Buffer.alloc(macBuffer.length);valBuffer.write(val);return timingSafeEqual(macBuffer,valBuffer)?str:false};export{sign,unsign}
{
"name": "@tinyhttp/cookie-signature",
"version": "0.1.5",
"version": "0.1.6",
"description": "HTTP cookie signing and unsigning",

@@ -38,3 +38,5 @@ "homepage": "https://github.com/talentlessguy/tinyhttp#readme",

"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.26.0",
"rollup": "^2.22.0",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-typescript2": "^0.27.1",

@@ -41,0 +43,0 @@ "typescript": "^3.9.7"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc