Added guard for private key length

This commit is contained in:
Wyatt Johnson
2017-08-04 12:58:40 +10:00
parent 8ceeb4b275
commit 5c8130bece
+1 -1
View File
@@ -112,7 +112,7 @@ function SharedSecret({kid = undefined, secret = null}, algorithm) {
*/
function AsymmetricSecret({kid = undefined, private: privateKey, public: publicKey}, algorithm) {
publicKey = Buffer.from(publicKey.replace(/\\n/g, '\n'));
privateKey = privateKey ? Buffer.from(privateKey.replace(/\\n/g, '\n')) : null;
privateKey = privateKey && privateKey.length > 0 ? Buffer.from(privateKey.replace(/\\n/g, '\n')) : null;
return new Secret({
kid,