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

mongoose-sort-encrypted-field

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-sort-encrypted-field - npm Package Compare versions

Comparing version 0.2.19 to 0.2.20

2

lib/modelsQueue.js

@@ -6,5 +6,5 @@ "use strict";

const Redis = require("ioredis");
const defaultRedisKeyPrefix = "mongoose-sort-encrypted-field";
const { REDIS_QUEUE_CLIENT_OPTIONS } = require("./constants");
const { updateSortFieldsForDocument, generateSortIdForAllDocuments } = require("./utils");
const defaultRedisKeyPrefix = "mongoose-sort-encrypted-field";
let modelsQueue;

@@ -11,0 +11,0 @@ class ModelsQueue {

@@ -12,2 +12,28 @@ "use strict";

}
function getAverageSortId(predecessorSortId, successorSortId, noOfCharsToIncreaseOnSaturation) {
if (!predecessorSortId) {
predecessorSortId = "".padEnd(successorSortId.length, "\0");
}
if (!successorSortId) {
successorSortId = "".padEnd(predecessorSortId.length, "\uffff");
}
let predecessorNumber;
let successorNumber;
if (predecessorSortId.length === successorSortId.length) {
predecessorNumber = new Base2N(predecessorSortId, 16);
successorNumber = new Base2N(successorSortId, 16);
const averageNumber = predecessorNumber.average(successorNumber);
if (averageNumber.toString() !== predecessorNumber.toString()) {
return averageNumber.toString();
}
predecessorNumber = new Base2N(predecessorSortId.padEnd(averageNumber.length + noOfCharsToIncreaseOnSaturation, "\0"), 16);
successorNumber = new Base2N(successorSortId.padEnd(averageNumber.length + noOfCharsToIncreaseOnSaturation, "\0"), 16);
return predecessorNumber.average(successorNumber).toString();
}
const bigger = predecessorSortId.length > successorSortId.length ? predecessorSortId : successorSortId;
const smaller = successorSortId.length > predecessorSortId.length ? predecessorSortId : successorSortId;
const biggerNumber = new Base2N(bigger, 16);
const smallerNumber = new Base2N(smaller.padEnd(bigger.length, "\0"), 16);
return biggerNumber.average(smallerNumber).toString();
}
async function generateSortIdUsingBinarySearch(model, fieldName, fieldValue, sortFieldName) {

@@ -71,30 +97,4 @@ const { ignoreCases, noOfCharsForSortId, noOfCharsToIncreaseOnSaturation } = model.schema.options.sortEncryptedFieldsOptions;

}
function getAverageSortId(predecessorSortId, successorSortId, noOfCharsToIncreaseOnSaturation) {
if (!predecessorSortId) {
predecessorSortId = "".padEnd(successorSortId.length, "\0");
}
if (!successorSortId) {
successorSortId = "".padEnd(predecessorSortId.length, "\uffff");
}
let predecessorNumber;
let successorNumber;
if (predecessorSortId.length === successorSortId.length) {
predecessorNumber = new Base2N(predecessorSortId, 16);
successorNumber = new Base2N(successorSortId, 16);
const averageNumber = predecessorNumber.average(successorNumber);
if (averageNumber.toString() !== predecessorNumber.toString()) {
return averageNumber.toString();
}
predecessorNumber = new Base2N(predecessorSortId.padEnd(averageNumber.length + noOfCharsToIncreaseOnSaturation, "\0"), 16);
successorNumber = new Base2N(successorSortId.padEnd(averageNumber.length + noOfCharsToIncreaseOnSaturation, "\0"), 16);
return predecessorNumber.average(successorNumber).toString();
}
const bigger = predecessorSortId.length > successorSortId.length ? predecessorSortId : successorSortId;
const smaller = successorSortId.length > predecessorSortId.length ? predecessorSortId : successorSortId;
const biggerNumber = new Base2N(bigger, 16);
const smallerNumber = new Base2N(smaller.padEnd(bigger.length, "\0"), 16);
return biggerNumber.average(smallerNumber).toString();
}
async function updateSortFieldsForDocument({ objectId, model, fieldName, fieldValue, sortFieldName }) {
const { silent, noOfCharsToIncreaseOnSaturation } = model.schema.options.sortEncryptedFieldsOptions;
const { silent } = model.schema.options.sortEncryptedFieldsOptions;
if (!silent) {

@@ -101,0 +101,0 @@ console.time(`mongoose-sort-encrypted-field -> updateSortFieldsForDocument() -> objectId: ${objectId}, fieldName: ${fieldName}, sortFieldName: ${sortFieldName}, timeTaken: `);

{
"name": "mongoose-sort-encrypted-field",
"version": "0.2.19",
"version": "0.2.20",
"description": "Mongoose plugin to enable sorting on encrypted fields",

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

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