inibase 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -438,7 +438,7 @@ export default class Inibase {
438
438
  return Object.keys(cleanedObject).length > 0 ? cleanedObject : null;
439
439
  }
440
440
  formatField(value, field, _formatOnlyAvailiableKeys) {
441
- if (value === null || value === undefined)
441
+ if (value === null || value === undefined || value === "")
442
442
  return value;
443
443
  if (Array.isArray(field.type))
444
444
  field.type = Utils.detectFieldType(value, field.type) ?? field.type[0];
@@ -1,3 +1,4 @@
1
+ import "dotenv/config";
1
2
  import { execFile as execFileSync, exec as execSync } from "node:child_process";
2
3
  import { gunzip as gunzipSync, gzip as gzipSync } from "node:zlib";
3
4
  import RE2 from "re2";
@@ -22,7 +23,7 @@ export declare const hashPassword: (password: string) => string;
22
23
  */
23
24
  export declare const comparePassword: (hash: string, password: string) => boolean;
24
25
  export declare const encodeID: (id: number | string) => string;
25
- export declare const decodeID: (input: string) => number;
26
+ export declare const decodeID: (input?: string) => number;
26
27
  export declare const extractIdsFromSchema: (schema: Schema) => number[];
27
28
  /**
28
29
  * Finds the last ID number in a schema, potentially decoding it if encrypted.
@@ -1,3 +1,4 @@
1
+ import "dotenv/config";
1
2
  import { execFile as execFileSync, exec as execSync } from "node:child_process";
2
3
  import { createCipheriv, createDecipheriv, createHash, randomBytes, scryptSync, } from "node:crypto";
3
4
  import { promisify } from "node:util";
@@ -38,6 +39,8 @@ export const comparePassword = (hash, password) => {
38
39
  };
39
40
  // Cache for derived keys if using scrypt
40
41
  const derivedKeyCache = new Map();
42
+ // Ensure the environment variable is read once
43
+ const INIBASE_SECRET = process.env.INIBASE_SECRET ?? "inibase";
41
44
  // Helper function to create cipher or decipher
42
45
  const getKeyAndIv = () => {
43
46
  if (Buffer.isBuffer(globalConfig.salt)) {
@@ -51,8 +54,6 @@ const getKeyAndIv = () => {
51
54
  }
52
55
  return { key, iv: key.subarray(0, 16) };
53
56
  };
54
- // Ensure the environment variable is read once
55
- const INIBASE_SECRET = process.env.INIBASE_SECRET ?? "inibase";
56
57
  // Optimized encodeID
57
58
  export const encodeID = (id) => {
58
59
  const { key, iv } = getKeyAndIv();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",