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.3 to 0.1.4

6

CHANGELOG.md
# @tinyhttp/cookie-signature
## 0.1.4
### Patch Changes
- Upgrade dependencies of all of the packages
## 0.1.3

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

20

dist/index.js

@@ -1,1 +0,19 @@

import{createHmac as e,timingSafeEqual as r}from"crypto";const sign=(r,t)=>`${r}.${e("sha256",t).update(r).digest("base64").replace(/=+$/,"")}`,unsign=(e,t)=>{const o=e.slice(0,e.lastIndexOf(".")),f=sign(o,t),s=Buffer.from(f),a=Buffer.alloc(s.length);return a.write(e),!!r(s,a)&&o};export{sign,unsign};
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 };

6

package.json
{
"name": "@tinyhttp/cookie-signature",
"version": "0.1.3",
"version": "0.1.4",
"description": "HTTP cookie signing and unsigning",

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

"devDependencies": {
"rollup": "^2.21.0",
"rollup": "^2.22.0",
"rollup-plugin-typescript2": "^0.27.1",
"typescript": "^3.9.6"
"typescript": "^3.9.7"
},

@@ -43,0 +43,0 @@ "scripts": {

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