@tinyhttp/cookie-signature
Advanced tools
Comparing version 0.1.5 to 0.1.6
# @tinyhttp/cookie-signature | ||
## 0.1.6 | ||
### Patch Changes | ||
- Compress whitespace | ||
## 0.1.5 | ||
@@ -4,0 +10,0 @@ |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5210
5
33
2