Comparing version
18
index.js
@@ -1,2 +0,1 @@ | ||
var bufferEqual = require('buffer-equal-constant-time'); | ||
var Buffer = require('safe-buffer').Buffer; | ||
@@ -138,6 +137,21 @@ var crypto = require('crypto'); | ||
var bufferEqual; | ||
var timingSafeEqual = 'timingSafeEqual' in crypto ? function timingSafeEqual(a, b) { | ||
if (a.byteLength !== b.byteLength) { | ||
return false; | ||
} | ||
return crypto.timingSafeEqual(a, b) | ||
} : function timingSafeEqual(a, b) { | ||
if (!bufferEqual) { | ||
bufferEqual = require('buffer-equal-constant-time'); | ||
} | ||
return bufferEqual(a, b) | ||
} | ||
function createHmacVerifier(bits) { | ||
return function verify(thing, signature, secret) { | ||
var computedSig = createHmacSigner(bits)(thing, secret); | ||
return bufferEqual(Buffer.from(signature), Buffer.from(computedSig)); | ||
return timingSafeEqual(Buffer.from(signature), Buffer.from(computedSig)); | ||
} | ||
@@ -144,0 +158,0 @@ } |
{ | ||
"name": "jwa", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "JWA implementation (supports all JWS algorithms)", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"buffer-equal-constant-time": "1.0.1", | ||
"buffer-equal-constant-time": "^1.0.1", | ||
"ecdsa-sig-formatter": "1.0.11", | ||
@@ -13,0 +13,0 @@ "safe-buffer": "^5.0.1" |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14052
2.68%5
25%225
5.14%1
Infinity%