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 1.1.0 to 1.2.0

6

CHANGELOG.md
# Release Notes
## v.1.2.0
2015-08-16
- Update tests to be Mongoose 4.x compatible
- Fix decryption of buffers to be Node 0.12.x compatible
- Cleaner documents after `.authenticate` and `.save`
## v 1.1.0

@@ -3,0 +9,0 @@ 2015-05-13

21

index.js

@@ -392,5 +392,14 @@ 'use strict';

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;
}
}
this._ct = undefined;
this._ac = undefined;
}

@@ -439,6 +448,3 @@ };

var authentic = bufferEqual(basicAC, expectedHMAC);
if (authentic){
this._ac = undefined;
return null;
} else {
if (!authentic){
throw new Error('Authentication failed');

@@ -456,2 +462,7 @@ }

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) {

@@ -458,0 +469,0 @@ if (doc.errors) {

{
"name": "mongoose-encryption",
"description": "Simple encryption and authentication plugin for Mongoose",
"version": "1.1.0",
"version": "1.2.0",
"author": {

@@ -31,3 +31,3 @@ "name": "Joe Goldbeck"

"dotty": "0.0.2",
"mongoose": "3.8.x",
"mongoose": "~4.1.x",
"underscore": "1.5.x",

@@ -48,4 +48,4 @@ "buffer-equal-constant-time": "1.0.1",

"scripts": {
"test": "mocha ./test --compilers coffee:coffee-script/register --timeout 3000"
"test": "mocha ./test --compilers coffee:coffee-script/register --timeout 3000"
}
}

@@ -133,7 +133,7 @@ mongoose-encryption

// optional. only needed for correct document behavior following validation errors during a save
// optional in Mongoose 3.x, not necessary in Mongoose 4.x. only needed for correct document behavior following validation errors during a save
userSchema.plugin(encrypt.encryptedChildren);
```
The need for `encrypt.encryptedChildren` arises because subdocument 'pre save' hooks are called before parent validation completes, and there are no subdocument hooks that fire when parent validation fails. Without the plugin, if you repair a parent doc after a failed save and then try to save again, data in the encrypted fields of the subdocuments will be lost.
The need for `encrypt.encryptedChildren` in Mongoose 3.x arises because in those Mongoose versions, subdocument 'pre save' hooks are called before parent validation completes, and there are no subdocument hooks that fire when parent validation fails. Without the plugin, if you repair a parent doc after a failed save and then try to save again, data in the encrypted fields of the subdocuments will be lost. In Mongoose 4.x, this behavior is fixed.

@@ -140,0 +140,0 @@

Sorry, the diff of this file is not supported yet

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