Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-encryption

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-encryption - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1

25

index.js

@@ -5,2 +5,4 @@ (function() {

var _ = require('underscore');
var mongoose = require('mongoose');
var semver = require('semver')
var dotty = require('dotty');

@@ -15,2 +17,8 @@

if(semver.gt(process.version, '4.0.0')){
if(semver.lt(mongoose.version, '4.2.4')){
throw new Error('Mongoose version 4.2.4 or greater is required for Node version 4.0.0 or greater');
}
}
module.exports = function(schema, options) {

@@ -20,2 +28,4 @@

if (!options.key)

@@ -131,3 +141,3 @@ throw new Error('options.key is required as a 32 byte base64 string');

if (this._ct) {
ctWithIV = this._ct.buffer || this._ct;
ctWithIV = this._ct.hasOwnProperty('buffer') ? this._ct.buffer : this._ct;
iv = ctWithIV.slice(0, IV_LENGTH);

@@ -148,3 +158,9 @@ ct = ctWithIV.slice(IV_LENGTH, ctWithIV.length);

decipheredVal = decryptedObject[field];
this[field] = decipheredVal;
//JSON.parse returns {type: "Buffer", data: Buffer} for Buffers
//https://nodejs.org/api/buffer.html#buffer_buf_tojson
if(_.isObject(decipheredVal) && decipheredVal.type === "Buffer"){
this[field] = decipheredVal.data;
}else {
this[field] = decipheredVal;
}
}

@@ -160,2 +176,7 @@ this._ct = undefined;

module.exports.encryptedChildren = function(schema, options) {
if (mongoose.version > '4.1.0') {
console.warn('encryptedChildren plugin is not needed for mongoose versions above 4.1.1, continuing without plugin.');
return;
}
schema.post('validate', function(doc) {

@@ -162,0 +183,0 @@ if (doc.errors) {

9

package.json
{
"name": "mongoose-encryption",
"description": "Simple encryption plugin for Mongoose",
"version": "0.11.0",
"version": "0.11.1",
"author": {

@@ -27,4 +27,8 @@ "name": "Joe Goldbeck"

"dotty": "0.0.2",
"underscore": "1.5.x"
"underscore": "1.5.x",
"semver": "5.1.x"
},
"peerDependencies":{
"mongoose": ">=3.8.28"
},
"devDependencies": {

@@ -34,3 +38,2 @@ "mocha": "1.x.x",

"coffee-script": "1.7.x",
"mongoose": "3.8.x",
"sinon": "~1.10.3"

@@ -37,0 +40,0 @@ },

Sorry, the diff of this file is not supported yet

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