@8ms/helpers 2.4.2 → 2.4.4
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.
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __require } from "../../chunk-y_GBKt04.mjs";
|
|
2
2
|
import { getString } from "../../string/index.mjs";
|
|
3
|
+
import * as crypto from "crypto";
|
|
3
4
|
//#region src/crypto/server/getDecrypt.ts
|
|
4
5
|
/**
|
|
5
6
|
* Decrypt an encoding string using a salt.
|
|
6
7
|
*/
|
|
7
8
|
const getDecrypt = (appSalt, input, salt) => {
|
|
8
|
-
const crypto = __require("crypto");
|
|
9
9
|
const ALGORITHM = "aes-256-cbc";
|
|
10
10
|
const customSalt = `${appSalt}-${salt}`;
|
|
11
11
|
const [ivHex, encryptedHex] = input.split(":");
|
|
12
|
-
const key = crypto.
|
|
12
|
+
const key = crypto.pbkdf2Sync(customSalt, "salt", 1e5, 32, "sha256");
|
|
13
13
|
const iv = Buffer.from(ivHex, "hex");
|
|
14
14
|
const encrypted = Buffer.from(encryptedHex, "hex");
|
|
15
15
|
const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);
|
|
@@ -21,10 +21,9 @@ const getDecrypt = (appSalt, input, salt) => {
|
|
|
21
21
|
* Encrypt an encoding string using a salt.
|
|
22
22
|
*/
|
|
23
23
|
const getEncrypt = (appSalt, input, salt) => {
|
|
24
|
-
const crypto = __require("crypto");
|
|
25
24
|
const ALGORITHM = "aes-256-cbc";
|
|
26
25
|
const customSalt = `${appSalt}-${salt}`;
|
|
27
|
-
const key = crypto.
|
|
26
|
+
const key = crypto.pbkdf2Sync(customSalt, "salt", 1e5, 32, "sha256");
|
|
28
27
|
const iv = crypto.randomBytes(16);
|
|
29
28
|
const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
|
|
30
29
|
const encrypted = Buffer.concat([cipher.update(input, "utf8"), cipher.final()]);
|
package/dist/lodash/index.d.mts
CHANGED
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
declare const chunk: <T>(array: T[], size: number) => T[][];
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/lodash/findKey.d.ts
|
|
5
|
-
|
|
6
|
-
* Finds the first key in an object that satisfies the provided predicate function.
|
|
7
|
-
*
|
|
8
|
-
* @param object - The object to inspect.
|
|
9
|
-
* @param predicate - The function invoked per iteration (value, key, object).
|
|
10
|
-
* @returns The key of the matched element, else undefined.
|
|
11
|
-
*/
|
|
12
|
-
declare const findKey: <T extends object>(object: T, predicate: (value: T[keyof T], key: string, object: T) => boolean) => string | undefined;
|
|
5
|
+
declare const findKey: <T extends object>(object: T | null | undefined, predicate?: any) => string | undefined;
|
|
13
6
|
//#endregion
|
|
14
7
|
//#region src/lodash/flatten.d.ts
|
|
15
8
|
declare const flatten: <T>(array: T[][]) => T[];
|
package/dist/lodash/index.mjs
CHANGED
|
@@ -6,19 +6,32 @@ const chunk = (array, size) => {
|
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/lodash/findKey.ts
|
|
9
|
-
/**
|
|
10
|
-
* Finds the first key in an object that satisfies the provided predicate function.
|
|
11
|
-
*
|
|
12
|
-
* @param object - The object to inspect.
|
|
13
|
-
* @param predicate - The function invoked per iteration (value, key, object).
|
|
14
|
-
* @returns The key of the matched element, else undefined.
|
|
15
|
-
*/
|
|
16
9
|
const findKey = (object, predicate) => {
|
|
17
10
|
if (object == null) return;
|
|
11
|
+
const iteratee = getBaseIteratee(predicate);
|
|
12
|
+
let result;
|
|
18
13
|
for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
19
14
|
const value = object[key];
|
|
20
|
-
if (
|
|
15
|
+
if (iteratee(value, key, object)) {
|
|
16
|
+
result = key;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
const getBaseIteratee = (value) => {
|
|
23
|
+
if (typeof value === "function") return value;
|
|
24
|
+
if (value == null) return (val) => val;
|
|
25
|
+
if (typeof value === "object") return (obj) => baseMatches(obj, value);
|
|
26
|
+
return (obj) => obj[value];
|
|
27
|
+
};
|
|
28
|
+
const baseMatches = (object, source) => {
|
|
29
|
+
if (object === source) return true;
|
|
30
|
+
if (object == null || source == null) return false;
|
|
31
|
+
for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
32
|
+
if (object[key] !== source[key]) return false;
|
|
21
33
|
}
|
|
34
|
+
return true;
|
|
22
35
|
};
|
|
23
36
|
//#endregion
|
|
24
37
|
//#region src/lodash/flatten.ts
|