@peacom/core 0.0.165 → 0.0.166
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/package.json
CHANGED
@@ -1,31 +1,25 @@
|
|
1
1
|
{
|
2
2
|
"name": "@peacom/core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.166",
|
4
4
|
"type": "commonjs",
|
5
5
|
"dependencies": {
|
6
6
|
"@aws-sdk/client-s3": "^3.350.0",
|
7
7
|
"@aws-sdk/s3-request-presigner": "^3.350.0",
|
8
8
|
"bullmq": "^3.15.5",
|
9
|
-
"dotenv": "10.0.0",
|
10
9
|
"google-libphonenumber": "^3.2.32",
|
11
10
|
"mime-types": "^2.1.35",
|
12
11
|
"moment": "^2.29.4",
|
13
12
|
"moment-timezone": "^0.5.43",
|
14
|
-
"
|
15
|
-
"
|
13
|
+
"uuid": "^9.0.0",
|
14
|
+
"mustache": "^4.2.0"
|
16
15
|
},
|
17
16
|
"devDependencies": {
|
18
17
|
"@types/google-libphonenumber": "^7.4.23",
|
19
18
|
"@types/mime-types": "^2.1.1",
|
20
|
-
"@types/mustache": "^4.2.2",
|
21
19
|
"@types/node": "^20.3.1",
|
20
|
+
"@types/mustache": "^4.2.2",
|
22
21
|
"@types/uuid": "^9.0.1",
|
23
22
|
"dotenv": "^16.1.4"
|
24
23
|
},
|
25
|
-
"
|
26
|
-
"peerDependencies": {
|
27
|
-
"tslib": "2.4.1"
|
28
|
-
},
|
29
|
-
"main": "./src/index.js",
|
30
|
-
"types": "./src/index.d.ts"
|
24
|
+
"main": "./src/index.js"
|
31
25
|
}
|
@@ -1,2 +1,4 @@
|
|
1
1
|
export declare const encryptPublic: (data: string) => string;
|
2
2
|
export declare const decryptPrivate: (data: string, privateKeyPath: string) => string;
|
3
|
+
export declare const encryptAESStr: (text: string | number, key?: null) => string;
|
4
|
+
export declare const decryptAESStr: (text: string, key?: null) => string;
|
@@ -1,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.decryptPrivate = exports.encryptPublic = void 0;
|
3
|
+
exports.decryptAESStr = exports.encryptAESStr = exports.decryptPrivate = exports.encryptPublic = void 0;
|
4
4
|
const path = require("path");
|
5
5
|
const fs = require("fs");
|
6
6
|
const crypto = require("crypto");
|
7
7
|
const process = require("process");
|
8
8
|
const string_util_1 = require("../string.util");
|
9
|
+
const crypto_1 = require("crypto");
|
9
10
|
let PUBLIC_KEY = '';
|
10
11
|
const getPublicKey = () => {
|
11
12
|
if (!PUBLIC_KEY) {
|
@@ -34,4 +35,26 @@ const decryptPrivate = (data, privateKeyPath) => {
|
|
34
35
|
return decrypted.toString("utf8");
|
35
36
|
};
|
36
37
|
exports.decryptPrivate = decryptPrivate;
|
38
|
+
const ALGORITHM = "aes-256-ctr";
|
39
|
+
const encryptAESStr = (text, key = null) => {
|
40
|
+
const iv = (0, crypto_1.randomBytes)(16);
|
41
|
+
const cipher = (0, crypto_1.createCipheriv)(ALGORITHM, key || "ENQudMWJ6AOKyWVTI28291WisR1Cluqb", iv);
|
42
|
+
const encrypted = Buffer.concat([cipher.update(`${text}`), cipher.final()]);
|
43
|
+
return `${iv.toString("hex")}${encrypted.toString("hex")}`;
|
44
|
+
};
|
45
|
+
exports.encryptAESStr = encryptAESStr;
|
46
|
+
const decryptAESStr = (text, key = null) => {
|
47
|
+
if (text.length < 32) {
|
48
|
+
throw new Error(`Invalid encrypt string ${text}`);
|
49
|
+
}
|
50
|
+
const iv = (0, string_util_1.leftString)(text, 32);
|
51
|
+
const content = (0, string_util_1.rightString)(text, text.length - 32);
|
52
|
+
const decipher = (0, crypto_1.createDecipheriv)(ALGORITHM, key || "ENQudMWJ6AOKyWVTI28291WisR1Cluqb", Buffer.from(iv, "hex"));
|
53
|
+
const decrypted = Buffer.concat([
|
54
|
+
decipher.update(Buffer.from(content, "hex")),
|
55
|
+
decipher.final()
|
56
|
+
]);
|
57
|
+
return decrypted.toString();
|
58
|
+
};
|
59
|
+
exports.decryptAESStr = decryptAESStr;
|
37
60
|
//# sourceMappingURL=crypto.util.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/crypto/crypto.util.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAgC;AAChC,mCAAmC;AACnC,
|
1
|
+
{"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/crypto/crypto.util.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAgC;AAChC,mCAAmC;AACnC,gDAAkE;AAClE,mCAAuE;AAEvE,IAAI,UAAU,GAAG,EAAE,CAAA;AACnB,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,IAAI,CAAC,UAAU,EAAE;QACf,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAA,qBAAO,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;YACnE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;SACtD;QACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;YAC5C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;SACnD;QACD,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;KAChE;IACD,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAEM,MAAM,aAAa,GAAG,CAC3B,IAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,SAAS,GAAG,M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AY,EAAE,GAAG,GAAG,IAAI,EAAE,EAAE;IACxD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;KACnD;IACD,MAAM,EAAE,GAAG,IAAA,wBAAU,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,IAAA,yBAAW,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAA,yBAAgB,EAC/B,SAAS,EACT,GAAG,IAAI,kCAAkC,EACzC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CACvB,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5C,QAAQ,CAAC,KAAK,EAAE;KACjB,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB"}
|
package/src/lib/util/index.d.ts
CHANGED
package/src/lib/util/index.js
CHANGED
@@ -8,4 +8,5 @@ tslib_1.__exportStar(require("./general.util"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./phone.util"), exports);
|
9
9
|
tslib_1.__exportStar(require("./date/index"), exports);
|
10
10
|
tslib_1.__exportStar(require("./performance"), exports);
|
11
|
+
tslib_1.__exportStar(require("./crypto/crypto.util"), exports);
|
11
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,2DAAgC;AAChC,wDAA6B;AAC7B,yDAA8B;AAC9B,uDAA4B;AAC5B,uDAA4B;AAC5B,wDAA6B"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,2DAAgC;AAChC,wDAA6B;AAC7B,yDAA8B;AAC9B,uDAA4B;AAC5B,uDAA4B;AAC5B,wDAA6B;AAC7B,+DAAoC"}
|