Socket
Socket
Sign inDemoInstall

jwa

Package Overview
Dependencies
3
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.4.0

50

index.js

@@ -15,2 +15,3 @@ var bufferEqual = require('buffer-equal-constant-time');

MSG_INVALID_VERIFIER_KEY += ' or a KeyObject';
MSG_INVALID_SECRET += 'or a KeyObject';
}

@@ -20,7 +21,7 @@

if (Buffer.isBuffer(key)) {
return key;
return;
}
if (typeof key === 'string') {
return key;
return;
}

@@ -47,4 +48,2 @@

}
return key;
};

@@ -54,11 +53,11 @@

if (Buffer.isBuffer(key)) {
return key;
return;
}
if (typeof key === 'string') {
return key;
return;
}
if (typeof key === 'object') {
return key;
return;
}

@@ -69,2 +68,28 @@

function checkIsSecretKey(key) {
if (Buffer.isBuffer(key)) {
return;
}
if (typeof key === 'string') {
return key;
}
if (!supportsKeyObjects) {
throw typeError(MSG_INVALID_SECRET);
}
if (typeof key !== 'object') {
throw typeError(MSG_INVALID_SECRET);
}
if (key.type !== 'secret') {
throw typeError(MSG_INVALID_SECRET);
}
if (typeof key.export !== 'function') {
throw typeError(MSG_INVALID_SECRET);
}
}
function fromBase64(base64) {

@@ -110,4 +135,3 @@ return base64

return function sign(thing, secret) {
if (!bufferOrString(secret))
throw typeError(MSG_INVALID_SECRET);
checkIsSecretKey(secret);
thing = normalizeInput(thing);

@@ -151,5 +175,4 @@ var hmac = crypto.createHmac('sha' + bits, secret);

function createPSSKeySigner(bits) {
return function sign(thing, privateKey) {
if (!bufferOrString(privateKey) && !(typeof privateKey === 'object'))
throw typeError(MSG_INVALID_SIGNER_KEY);
return function sign(thing, privateKey) {
checkIsPrivateKey(privateKey);
thing = normalizeInput(thing);

@@ -164,4 +187,3 @@ var signer = crypto.createSign('RSA-SHA' + bits);

return function verify(thing, signature, publicKey) {
if (!bufferOrString(publicKey))
throw typeError(MSG_INVALID_VERIFIER_KEY);
checkIsPublicKey(publicKey);
thing = normalizeInput(thing);

@@ -168,0 +190,0 @@ signature = toBase64(signature);

{
"name": "jwa",
"version": "1.3.0",
"version": "1.4.0",
"description": "JWA implementation (supports all JWS algorithms)",

@@ -16,2 +16,3 @@ "main": "index.js",

"base64url": "^2.0.0",
"jwk-to-pem": "^2.0.1",
"semver": "4.3.6",

@@ -18,0 +19,0 @@ "tap": "6.2.0"

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