mongoose-encryption
Advanced tools
Comparing version 1.1.0 to 1.2.0
# 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112138
458
+ Addedbluebird@2.9.26(transitive)
+ Addedbson@0.4.23(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedes6-promise@2.1.1(transitive)
+ Addedhooks-fixed@1.1.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedkareem@1.0.1(transitive)
+ Addedkerberos@0.0.24(transitive)
+ Addedmongodb@2.0.46(transitive)
+ Addedmongodb-core@1.2.19(transitive)
+ Addedmongoose@4.1.12(transitive)
+ Addedmpromise@0.5.4(transitive)
+ Addedmquery@1.6.3(transitive)
+ Addedmuri@1.0.0(transitive)
+ Addednan@2.10.0(transitive)
+ Addedreadable-stream@1.0.31(transitive)
+ Addedstring_decoder@0.10.31(transitive)
- Removedabort-controller@3.0.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbluebird@2.10.2(transitive)
- Removedbson@0.2.22(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedevents@3.3.0(transitive)
- Removedhooks@0.2.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedkerberos@0.0.11(transitive)
- Removedmongodb@1.4.38(transitive)
- Removedmongoose@3.8.40(transitive)
- Removedmpromise@0.4.3(transitive)
- Removedmquery@1.10.0(transitive)
- Removedmuri@1.1.0(transitive)
- Removednan@1.8.4(transitive)
- Removedprocess@0.11.10(transitive)
- Removedreadable-stream@4.6.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
Updatedmongoose@~4.1.x