New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-cipher

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cipher - npm Package Compare versions

Comparing version 6.3.1 to 6.3.2

58

bin/actions/cipher.js

@@ -87,14 +87,17 @@ /**

if (err) {
if (err.code === 'ENOENT') {
handleEnoentError(opts, err);
} else if (err.toString().indexOf('bad decrypt') >= 0) {
handleBadDecrypt(opts, err);
} else if (err.toString().indexOf('wrong final block length') >= 0) {
handleIncorrectAlgorithm(opts, err);
} else if (err.toString().indexOf('not a valid cipher algorithm') >= 0) {
handleInvalidAlgorithm(opts, err);
} else if (err.toString().indexOf('not a valid HMAC hash') >= 0) {
handleInvalidHash(opts, err);
} else {
handleUnknownErrors(opts, err);
switch (err.name) {
case nodecipher.errors.BAD_ALGORITHM:
handleInvalidAlgorithm(opts, err);
break;
case nodecipher.errors.BAD_DIGEST:
handleInvalidHash(opts, err);
break;
case nodecipher.errors.BAD_FILE:
handleEnoentError(opts, err);
break;
case nodecipher.errors.BAD_DECRYPT:
handleBadDecrypt(opts, err);
break;
default:
handleUnknownErrors(opts, err);
}

@@ -114,3 +117,3 @@ } else {

console.log(chalk.red(
'\nError: ' + err.path + ' does not exist\n'
'\nError: ' + err.name + '. "' + err.path + '" does not exist.\n'
));

@@ -127,6 +130,7 @@ }

console.log(chalk.red(
'\nBad decrypt. One or more of the following may be incorrect:\n\n' +
'\nError: ' + err.name + '. One or more of the following is likely ' +
'incorrect:\n\n' +
' - password\n' +
' - vector\n' +
' - salt\n' +
' - algorithm\n' +
' - iterations\n' +

@@ -139,14 +143,2 @@ ' - keylen\n' +

/**
* Handles wrong final block length (wrong algorithm).
*
* @param {Object} opts
* @param {Error} err
*/
function handleIncorrectAlgorithm(opts, err) {
console.log(chalk.red(
'\nBad decrypt. Incorrect cipher algorithm\n'
));
}
/**
* Handles invalid cipher algorithm.

@@ -159,4 +151,5 @@ *

console.log(chalk.red(
'\n' + err + ' Use `nodecipher --algorithms` to see a list of valid ' +
'algorithms\n'));
'\nError: ' + err.name + '. Use `nodecipher --algorithms` to see a list ' +
'of valid algorithms.\n'
));
}

@@ -172,4 +165,5 @@

console.log(chalk.red(
'\n' + err + ' Use `nodecipher --hashes` to see a list of valid HMAC ' +
'hashes\n'));
'\nError: ' + err.name + '. Use `nodecipher --hashes` to see a list of ' +
'valid digest hashes.\n'
));
}

@@ -184,3 +178,3 @@

function handleUnknownErrors(opts, err) {
throw err;
console.log(chalk.red('\n' + err + '\n'));
}

@@ -187,0 +181,0 @@

@@ -17,2 +17,3 @@ /**

let fs = require('fs-extra');
let keyMirror = require('keymirror');
let rc = require('rc');

@@ -95,4 +96,2 @@

* NodeCipher class constructor.
*
* @constructor
*/

@@ -219,5 +218,9 @@ constructor() {

if (errors.length) {
let errorMessage = _.first(errors).message;
let err = new Error(errorMessage);
let error = _.first(errors);
let err = new Error(error.message);
if (!_.isUndefined(error.name)) {
err.name = error.name;
}
reject(err);

@@ -383,2 +386,8 @@ } else {

} catch (err) {
if (err.code === 'ENOENT') {
err.name = NodeCipher.Errors.BAD_FILE;
} else {
err.name = NodeCipher.Errors.BAD_DECRYPT;
}
throw err;

@@ -488,3 +497,3 @@ }

errors.push({
option: key,
name: key,
message: `"${key}" must be a string. Got "${typeof val}"`

@@ -582,3 +591,4 @@ });

option: key,
message: `"${val}" is not a valid digest hash.`
message: `"${val}" is not a valid digest hash.`,
name: NodeCipher.Errors.BAD_DIGEST
});

@@ -619,3 +629,4 @@ }

option: key,
message: `"${val}" is not a valid cipher algorithm.`
message: `"${val}" is not a valid cipher algorithm.`,
name: NodeCipher.Errors.BAD_ALGORITHM
});

@@ -640,2 +651,8 @@ }

if (err.code === 'ENOENT') {
err.name = NodeCipher.Errors.BAD_FILE;
} else {
err.name = NodeCipher.Errors.BAD_DECRYPT;
}
return callback(err);

@@ -731,2 +748,3 @@ };

* - defaults:Object
* - errors:Object
*/

@@ -745,3 +763,3 @@

/**
* Gets NodeCipher defaults.
* Gets a clone of the NodeCipher defaults.
*

@@ -752,8 +770,21 @@ * @returns {Object}

get defaults() {
return NodeCipher.Defaults;
return _.clone(NodeCipher.Defaults);
}
/**
* Gets a clone of the NodeCipher error names.
*
* @returns {Object}
* @access public
*/
get errors() {
return _.clone(NodeCipher.Errors);
}
}
/**
* @enum {Object} Actions
* NodeCipher action objects.
*
* @type {Object}
* @readonly
*/

@@ -774,4 +805,20 @@ NodeCipher.Actions = {

/**
* @enum {mixed} Defaults
* NodeCipher error names.
*
* @type {string}
* @readonly
*/
NodeCipher.Errors = {
BAD_ALGORITHM: 'Bad Algorithm',
BAD_DIGEST: 'Bad Digest',
BAD_FILE: 'Bad File',
BAD_DECRYPT: 'Bad Decrypt'
};
/**
* Default NodeCipher options.
*
* @type {string}
* @readonly
*/
NodeCipher.Defaults = {

@@ -783,7 +830,11 @@ input: undefined,

salt: DEFAULT_SALT,
digest: DEFAULT_DIGEST,
/** @type {number} */
iterations: DEFAULT_ITERATIONS,
keylen: DEFAULT_KEYLEN,
digest: DEFAULT_DIGEST
/** @type {number} */
keylen: DEFAULT_KEYLEN
};
module.exports = new NodeCipher();
{
"name": "node-cipher",
"version": "6.3.1",
"version": "6.3.2",
"description": "Securely encrypt sensitive files for use in public source control.",

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

"inquirer": "^0.11.2",
"keymirror": "^0.1.1",
"lodash": "^4.0.0",

@@ -38,0 +39,0 @@ "rc": "^1.1.6",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc