Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@24hr/seqcryptor

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@24hr/seqcryptor - npm Package Compare versions

Comparing version
0.8.9
to
0.8.10
+9
-1
build/index.js

@@ -38,6 +38,14 @@ "use strict";

if (value === null) {
this.setDataValue(options.field, null);
if (options.defaultValue && !options.allowNull) {
this.setDataValue(options.field, options.defaultValue);
}
else {
this.setDataValue(options.field, null);
}
return;
}
if (value === undefined) {
if (options.defaultValue && !options.allowNull) {
this.setDataValue(options.field, options.defaultValue);
}
return;

@@ -44,0 +52,0 @@ }

+1
-1
{
"name": "@24hr/seqcryptor",
"version": "0.8.9",
"version": "0.8.10",
"description": "",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -45,6 +45,13 @@ import crypto from 'crypto';

if (value === null) {
this.setDataValue(options.field, null);
if (options.defaultValue && !options.allowNull) {
this.setDataValue(options.field, options.defaultValue);
} else {
this.setDataValue(options.field, null);
}
return;
}
if (value === undefined) {
if (options.defaultValue && !options.allowNull) {
this.setDataValue(options.field, options.defaultValue);
}
return;

@@ -51,0 +58,0 @@ }

@@ -55,4 +55,57 @@ import { DataTypes, Model, Sequelize } from 'sequelize';

const user2 = await User.create({ info: null, data: { foo: 1 }, name: 'bar' });
const userParsed2 = await User.findOne({ where: { guid: user2.guid } });
expect(userParsed2!.info).toEqual({});
const user3 = await User.create({ info: undefined, data: { foo: 1 }, name: 'bar' });
const userParsed3 = await User.findOne({ where: { guid: user3.guid } });
expect(userParsed3!.info).toEqual({});
});
it('Can set null to a jsonb even if a default value but allownull is true', async () => {
const encryptor = seqCryptor('_SUPER_SECRET_KEY_WITH_32_BYTES_');
class User extends Model {
public info!: any;
public data!: any;
public guid!: string;
}
User.init({
guid: {
allowNull: false,
unique: true,
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
},
info: encryptor({
type: DataTypes.JSONB,
field: 'info',
defaultValue: {},
allowNull: true,
}),
data: encryptor({
type: DataTypes.JSONB,
field: 'data',
defaultValue: {},
}),
}, {
sequelize,
paranoid: false,
});
await User.sync();
const user = await User.create({ info: null, data: { foo: 1 }, name: 'bar' });
const userParsed = await User.findOne({ where: { guid: user.guid } });
expect(userParsed!.info).toEqual(null);
});
});

@@ -59,0 +112,0 @@