inibase 1.2.0 → 1.2.2
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 +4 -2
- package/dist/utils.server.d.ts +2 -1
- package/dist/utils.server.js +3 -2
- package/package.json +1 -1
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];
|
|
@@ -903,7 +903,8 @@ export default class Inibase {
|
|
|
903
903
|
.map((column) => column.replace(`${field.key}.`, "")),
|
|
904
904
|
});
|
|
905
905
|
const formatLineContent = (lineContent) => Array.isArray(lineContent)
|
|
906
|
-
? lineContent
|
|
906
|
+
? lineContent
|
|
907
|
+
.map((singleContent) => singleContent
|
|
907
908
|
? Array.isArray(singleContent)
|
|
908
909
|
? singleContent.map(formatLineContent)
|
|
909
910
|
: items
|
|
@@ -912,6 +913,7 @@ export default class Inibase {
|
|
|
912
913
|
id: singleContent,
|
|
913
914
|
}
|
|
914
915
|
: singleContent)
|
|
916
|
+
.filter(Boolean)
|
|
915
917
|
: (items?.find(({ id }) => lineContent === id) ?? {
|
|
916
918
|
id: lineContent,
|
|
917
919
|
});
|
package/dist/utils.server.d.ts
CHANGED
|
@@ -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
|
|
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.
|
package/dist/utils.server.js
CHANGED
|
@@ -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();
|