use .length to test
This commit is contained in:
parent
4bca02e635
commit
74ef7455f5
|
@ -59,7 +59,7 @@ function initWorker(path) {
|
|||
* @static
|
||||
*/
|
||||
function encryptMessage(keys, text, callback) {
|
||||
if (typeof keys === 'string') {
|
||||
if (!keys.length) {
|
||||
keys = [keys];
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ function encryptMessage(keys, text, callback) {
|
|||
* @static
|
||||
*/
|
||||
function signAndEncryptMessage(publicKeys, privateKey, text, callback) {
|
||||
if (typeof publicKeys === 'string') {
|
||||
if (!publicKeys.length) {
|
||||
publicKeys = [publicKeys];
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ function decryptMessage(privateKey, msg, callback) {
|
|||
* @static
|
||||
*/
|
||||
function decryptAndVerifyMessage(privateKey, publicKeys, msg, callback) {
|
||||
if (typeof publicKeys === 'string') {
|
||||
if (!publicKeys.length) {
|
||||
publicKeys = [publicKeys];
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ function decryptAndVerifyMessage(privateKey, publicKeys, msg, callback) {
|
|||
* @static
|
||||
*/
|
||||
function signClearMessage(privateKeys, text, callback) {
|
||||
if (typeof privateKeys === 'string') {
|
||||
if (!privateKeys.length) {
|
||||
privateKeys = [privateKeys];
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ function signClearMessage(privateKeys, text, callback) {
|
|||
* @static
|
||||
*/
|
||||
function verifyClearSignedMessage(publicKeys, msg, callback) {
|
||||
if (typeof publicKeys === 'string') {
|
||||
if (!publicKeys.length) {
|
||||
publicKeys = [publicKeys];
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ AsyncProxy.prototype.terminate = function() {
|
|||
* @param {Function} callback receives encrypted ASCII armored message
|
||||
*/
|
||||
AsyncProxy.prototype.encryptMessage = function(keys, text, callback) {
|
||||
if (typeof keys === 'string') {
|
||||
if (!keys.length) {
|
||||
keys = [keys];
|
||||
}
|
||||
keys = keys.map(function(key) {
|
||||
|
@ -123,7 +123,7 @@ AsyncProxy.prototype.encryptMessage = function(keys, text, callback) {
|
|||
* @param {Function} callback receives encrypted ASCII armored message
|
||||
*/
|
||||
AsyncProxy.prototype.signAndEncryptMessage = function(publicKeys, privateKey, text, callback) {
|
||||
if (typeof publicKeys === 'string') {
|
||||
if (!publicKeys.length) {
|
||||
publicKeys = [publicKeys];
|
||||
}
|
||||
publicKeys = publicKeys.map(function(key) {
|
||||
|
@ -166,7 +166,7 @@ AsyncProxy.prototype.decryptMessage = function(privateKey, message, callback) {
|
|||
*/
|
||||
AsyncProxy.prototype.decryptAndVerifyMessage = function(privateKey, publicKeys, message, callback) {
|
||||
privateKey = privateKey.toPacketlist();
|
||||
if (typeof publicKeys === 'string') {
|
||||
if (!publicKeys.length) {
|
||||
publicKeys = [publicKeys];
|
||||
}
|
||||
publicKeys = publicKeys.map(function(key) {
|
||||
|
@ -196,7 +196,7 @@ AsyncProxy.prototype.decryptAndVerifyMessage = function(privateKey, publicKeys,
|
|||
* @param {Function} callback receives ASCII armored message
|
||||
*/
|
||||
AsyncProxy.prototype.signClearMessage = function(privateKeys, text, callback) {
|
||||
if (typeof privateKeys === 'string') {
|
||||
if (!privateKeys.length) {
|
||||
privateKeys = [privateKeys];
|
||||
}
|
||||
privateKeys = privateKeys.map(function(key) {
|
||||
|
@ -217,7 +217,7 @@ AsyncProxy.prototype.signClearMessage = function(privateKeys, text, callback) {
|
|||
* @param {Function} callback receives cleartext with status of verified signatures
|
||||
*/
|
||||
AsyncProxy.prototype.verifyClearSignedMessage = function(publicKeys, message, callback) {
|
||||
if (typeof publicKeys === 'string') {
|
||||
if (!publicKeys.length) {
|
||||
publicKeys = [publicKeys];
|
||||
}
|
||||
publicKeys = publicKeys.map(function(key) {
|
||||
|
|
|
@ -38,7 +38,7 @@ onmessage = function (event) {
|
|||
break;
|
||||
case 'encrypt-message':
|
||||
try {
|
||||
if (typeof msg.keys === 'string') {
|
||||
if (!msg.keys.length) {
|
||||
msg.keys = [msg.keys];
|
||||
}
|
||||
msg.keys = msg.keys.map(packetlistCloneToKey);
|
||||
|
@ -50,7 +50,7 @@ onmessage = function (event) {
|
|||
break;
|
||||
case 'sign-and-encrypt-message':
|
||||
try {
|
||||
if (typeof msg.publicKeys === 'string') {
|
||||
if (!msg.publicKeys.length) {
|
||||
msg.publicKeys = [msg.publicKeys];
|
||||
}
|
||||
msg.publicKeys = msg.publicKeys.map(packetlistCloneToKey);
|
||||
|
@ -74,7 +74,7 @@ onmessage = function (event) {
|
|||
case 'decrypt-and-verify-message':
|
||||
try {
|
||||
msg.privateKey = packetlistCloneToKey(msg.privateKey);
|
||||
if (typeof msg.publicKeys === 'string') {
|
||||
if (!msg.publicKeys.length) {
|
||||
msg.publicKeys = [msg.publicKeys];
|
||||
}
|
||||
msg.publicKeys = msg.publicKeys.map(packetlistCloneToKey);
|
||||
|
@ -96,7 +96,7 @@ onmessage = function (event) {
|
|||
break;
|
||||
case 'verify-clear-signed-message':
|
||||
try {
|
||||
if (typeof msg.publicKeys === 'string') {
|
||||
if (!msg.publicKeys.length) {
|
||||
msg.publicKeys = [msg.publicKeys];
|
||||
}
|
||||
msg.publicKeys = msg.publicKeys.map(packetlistCloneToKey);
|
||||
|
|
Loading…
Reference in New Issue
Block a user