@24hr/seqcryptor
Advanced tools
+6
-0
@@ -27,2 +27,5 @@ "use strict"; | ||
| } | ||
| if (rawData === undefined) { | ||
| return rawData; | ||
| } | ||
| const decryptedData = (0, exports.decrypt)(secret, rawData, options.returnRawOnUnecrypted, options.defaultValue); | ||
@@ -39,2 +42,5 @@ if (options.type === sequelize_1.DataTypes.JSONB || options.type === sequelize_1.DataTypes.JSON) { | ||
| } | ||
| if (value === undefined) { | ||
| return; | ||
| } | ||
| let parsedValue = value; | ||
@@ -41,0 +47,0 @@ if (options.type === sequelize_1.DataTypes.JSONB || options.type === sequelize_1.DataTypes.JSON) { |
+1
-1
| { | ||
| "name": "@24hr/seqcryptor", | ||
| "version": "0.8.8", | ||
| "version": "0.8.9", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
+6
-0
@@ -34,2 +34,5 @@ import crypto from 'crypto'; | ||
| } | ||
| if (rawData === undefined) { | ||
| return rawData; | ||
| } | ||
| const decryptedData = decrypt(secret, rawData, options.returnRawOnUnecrypted, options.defaultValue); | ||
@@ -46,2 +49,5 @@ if (options.type === DataTypes.JSONB || options.type === DataTypes.JSON) { | ||
| } | ||
| if (value === undefined) { | ||
| return; | ||
| } | ||
| let parsedValue = value; | ||
@@ -48,0 +54,0 @@ if (options.type === DataTypes.JSONB || options.type === DataTypes.JSON) { |
+21
-14
@@ -100,3 +100,3 @@ import { DataTypes, Model, Sequelize } from 'sequelize'; | ||
| it('Can encrypt a field that has null as a value', async () => { | ||
| it('Can encrypt a field that has null or undefined as a value', async () => { | ||
@@ -132,20 +132,27 @@ const encryptor = seqCryptor('_SUPER_SECRET_KEY_WITH_32_BYTES_'); | ||
| const user = await User.create({ | ||
| name: null, | ||
| guid, | ||
| }); | ||
| expect(user!.name).toEqual(null); | ||
| const user = await User.create({ | ||
| name: null, | ||
| guid, | ||
| }); | ||
| expect(user!.name).toEqual(null); | ||
| const userRaw = await User.findOne({ where: { guid: guid }, raw: true }); | ||
| expect(userRaw!.name).toEqual(null); | ||
| const userRaw = await User.findOne({ where: { guid: guid }, raw: true }); | ||
| expect(userRaw!.name).toEqual(null); | ||
| const userFromDb = await User.findOne({ where: { guid: guid } }); | ||
| await userFromDb!.update({ name: 'hej' }); | ||
| expect(userFromDb!.name).toEqual('hej'); | ||
| await userFromDb!.update({ name: null }); | ||
| expect(userFromDb!.name).toEqual(null); | ||
| const userFromDb = await User.findOne({ where: { guid: guid } }); | ||
| await userFromDb!.update({ name: 'hej' }); | ||
| expect(userFromDb!.name).toEqual('hej'); | ||
| await userFromDb!.update({ name: null }); | ||
| expect(userFromDb!.name).toEqual(null); | ||
| await userFromDb!.update({ name: undefined }); | ||
| expect(userFromDb!.name).toEqual(null); | ||
| }); | ||
| const user2 = await User.create({ | ||
| name: undefined, | ||
| guid: 'a7abcc8b-3096-4431-ae9b-93e6cf3f8d43', | ||
| }); | ||
| expect(user2!.name).toEqual(undefined); | ||
| }); | ||
@@ -152,0 +159,0 @@ }); |
33884
2.11%688
2.84%