pangea-server 3.3.136 → 3.3.138

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.
@@ -169,7 +169,7 @@ class Arca {
169
169
  issuer_address: this.__issuer.address,
170
170
  issuer_iva_condition: this.__issuer.vatCondition,
171
171
  issuer_gross_income: this.__issuer.grossIncome,
172
- issuer_activity_start_date: this.__issuer.activityStartDate,
172
+ issuer_activity_start_date: this.__issuer.activityStartDate.split('-').reverse().join('/'),
173
173
  receiver_name: receiverName,
174
174
  receiver_address: receiver.address || '-',
175
175
  receiver_document_type: documentTypeIds[receiver.documentType],
@@ -1,6 +1,4 @@
1
- export declare class Encryptor {
2
- private __cryptr;
3
- constructor(secret: string);
4
- encrypt(value: string): string;
5
- decrypt(value: string): string;
1
+ export declare abstract class Encryptor {
2
+ static encrypt(value: string): string;
3
+ static decrypt(value: string): string;
6
4
  }
@@ -5,15 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Encryptor = void 0;
7
7
  const cryptr_1 = __importDefault(require("cryptr"));
8
+ // helpers
9
+ const env_helpers_1 = require("./env.helpers");
8
10
  class Encryptor {
9
- constructor(secret) {
10
- this.__cryptr = new cryptr_1.default(secret);
11
+ static encrypt(value) {
12
+ return new cryptr_1.default((0, env_helpers_1.getEnvStr)('ENCRYPTOR_SECRET')).encrypt(value);
11
13
  }
12
- encrypt(value) {
13
- return this.__cryptr.encrypt(value);
14
- }
15
- decrypt(value) {
16
- return this.__cryptr.decrypt(value);
14
+ static decrypt(value) {
15
+ return new cryptr_1.default((0, env_helpers_1.getEnvStr)('ENCRYPTOR_SECRET')).decrypt(value);
17
16
  }
18
17
  }
19
18
  exports.Encryptor = Encryptor;
@@ -1,4 +1,4 @@
1
1
  export declare abstract class Pass {
2
- static Hash(data: string): Promise<string>;
3
- static Compare(data: string, encrypted: string): Promise<boolean>;
2
+ static Hash(password: string): Promise<string>;
3
+ static Compare(password: string, hash: string): Promise<boolean>;
4
4
  }
@@ -4,13 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Pass = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
7
8
  const bcrypt_1 = __importDefault(require("bcrypt"));
9
+ const env_helpers_1 = require("./env.helpers");
10
+ const COST = 12;
8
11
  class Pass {
9
- static Hash(data) {
10
- return bcrypt_1.default.hash(data, 10);
12
+ static Hash(password) {
13
+ return bcrypt_1.default.hash(withPepper(password), COST);
11
14
  }
12
- static Compare(data, encrypted) {
13
- return bcrypt_1.default.compare(data, encrypted);
15
+ static async Compare(password, hash) {
16
+ if (await bcrypt_1.default.compare(withPepper(password), hash))
17
+ return true;
18
+ return bcrypt_1.default.compare(password, hash);
14
19
  }
15
20
  }
16
21
  exports.Pass = Pass;
22
+ // internal functions
23
+ function withPepper(password) {
24
+ return crypto_1.default.createHmac('sha256', (0, env_helpers_1.getEnvStr)('PASSWORD_PEPPER')).update(password).digest('hex');
25
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.136",
4
+ "version": "3.3.138",
5
5
  "files": [
6
6
  "dist"
7
7
  ],