sim-node-lib 0.0.88 → 0.0.90
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/README.md
CHANGED
|
@@ -4,9 +4,9 @@ Node commons library to use on SIMlabs projets
|
|
|
4
4
|
|
|
5
5
|
## ENVs
|
|
6
6
|
|
|
7
|
-
| Description/use | Name
|
|
8
|
-
| --------------------------------- |
|
|
9
|
-
|
|
|
7
|
+
| Description/use | Name | Block |
|
|
8
|
+
| --------------------------------- | -------------- | ----- |
|
|
9
|
+
| Chave para encriptação | AES_SECRET_KEY | Crypt |
|
|
10
10
|
|
|
11
11
|
## Documentation
|
|
12
12
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasicValidatorMessages = void 0;
|
|
4
|
+
exports.BasicValidatorMessages = {
|
|
5
|
+
required: 'O campo {{ field }} é obrigatório!',
|
|
6
|
+
unique: 'O registro deve ser único!',
|
|
7
|
+
distinct: 'Não envie itens repetidos!',
|
|
8
|
+
exists: 'Envie um item válido e existente!',
|
|
9
|
+
number: 'É necessário enviar um número válido no campo {{ field }}!',
|
|
10
|
+
boolean: 'É necessário enviar uma boolean válida no campo {{ field }}!',
|
|
11
|
+
string: 'É necessário enviar uma string válida no campo {{ field }}!',
|
|
12
|
+
array: 'É necessário enviar uma array válida no campo {{ field }}!',
|
|
13
|
+
date: 'É necessário enviar uma data válida no campo {{ field }}!',
|
|
14
|
+
object: 'É necessário enviar um objeto válido no campo {{ field }}!',
|
|
15
|
+
file: 'É necessário enviar um arquivo válido no campo {{ field }}!',
|
|
16
|
+
};
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.CryptHelper = void 0;
|
|
4
|
-
const crypto = require(
|
|
13
|
+
const crypto = require("crypto");
|
|
14
|
+
const CryptoJS = require('crypto-js');
|
|
5
15
|
const alg = 'aes-256-ctr';
|
|
6
16
|
const pwd = 'Macaco';
|
|
7
17
|
class CryptHelper {
|
|
@@ -15,5 +25,19 @@ class CryptHelper {
|
|
|
15
25
|
const plain = decipher.update(mensagem, 'hex', 'utf8');
|
|
16
26
|
return plain;
|
|
17
27
|
}
|
|
28
|
+
static AESEncrypt(text) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const key = CryptoJS.enc.Utf8.parse(process.env.AES_SECRET_KEY);
|
|
31
|
+
const mode = CryptoJS.mode.ECB;
|
|
32
|
+
return CryptoJS.AES.encrypt(text, key, { mode: mode }).toString();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
static AESDecrypt(text) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const key = CryptoJS.enc.Utf8.parse(process.env.AES_SECRET_KEY);
|
|
38
|
+
const mode = CryptoJS.mode.ECB;
|
|
39
|
+
return CryptoJS.AES.decrypt(text, key, { mode: mode }).toString(CryptoJS.enc.Utf8);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
18
42
|
}
|
|
19
43
|
exports.CryptHelper = CryptHelper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sim-node-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.90",
|
|
4
4
|
"description": "Library from SIMLabs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@google-cloud/pubsub": "^3.2.1",
|
|
17
17
|
"axios": "^0.27.2",
|
|
18
18
|
"crypto": "^1.0.1",
|
|
19
|
+
"crypto-js": "^4.1.1",
|
|
19
20
|
"dotenv": "^16.0.1",
|
|
20
21
|
"keygenerator": "^1.0.4",
|
|
21
22
|
"moment": "^2.29.4"
|