Socket
Socket
Sign inDemoInstall

@tinyhttp/cookie-signature

Package Overview
Dependencies
0
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.4 to 2.0.5

24

dist/index.js

@@ -1,17 +0,11 @@

import { createHmac, timingSafeEqual } from 'crypto';
/**
* Sign the given `val` with `secret`.
*/
const sign = (val, secret) => `${val}.${createHmac('sha256', secret).update(val).digest('base64').replace(/=+$/, '')}`;
/**
* Unsign and decode the given `val` with `secret`,
* returning `false` if the signature is invalid.
*/
import { createHmac, timingSafeEqual } from "crypto";
const sign = (val, secret) => `${val}.${createHmac("sha256", secret).update(val).digest("base64").replace(/=+$/, "")}`;
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;
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 };
export {
sign,
unsign
};
{
"name": "@tinyhttp/cookie-signature",
"version": "2.0.4",
"version": "2.0.5",
"description": "HTTP cookie signing and unsigning",

@@ -31,5 +31,8 @@ "homepage": "https://tinyhttp.v1rtl.site",

"license": "MIT",
"dependencies": {},
"scripts": {
"build": "rollup -c ../../build/defaultConfig.js"
"dev": "vite",
"build": "vite build",
"postbuild": "tsc --emitDeclarationOnly"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc