@forzalabs/remora 0.0.62-nasco.3 → 0.0.63-nasco.3

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/Constants.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const CONSTANTS = {
4
- cliVersion: '0.0.61-nasco',
4
+ cliVersion: '0.0.63-nasco',
5
5
  lambdaVersion: 1,
6
6
  port: 5069,
7
7
  defaults: {
@@ -8,6 +8,8 @@ const Algo_1 = __importDefault(require("../core/Algo"));
8
8
  const RandomEngine_1 = __importDefault(require("./RandomEngine"));
9
9
  class CryptoEngineClass {
10
10
  constructor() {
11
+ var _a;
12
+ this._salt = '';
11
13
  this.hashQuery = (maskType, fieldReference, fieldName) => {
12
14
  if (!Algo_1.default.hasVal(maskType))
13
15
  return;
@@ -25,30 +27,32 @@ class CryptoEngineClass {
25
27
  }
26
28
  };
27
29
  this.valueToHash = (value) => {
28
- return crypto_1.default.createHash('sha256').update(JSON.stringify(value)).digest('hex');
30
+ const textValue = JSON.stringify(value);
31
+ return crypto_1.default.createHash('sha256').update(textValue).digest('hex');
29
32
  };
30
33
  this.hashValue = (maskType, value, valueType) => {
31
34
  if (!Algo_1.default.hasVal(value))
32
35
  return value;
33
36
  if (!Algo_1.default.hasVal(maskType))
34
37
  return value;
38
+ const saltedValue = this._salt + value;
35
39
  switch (maskType) {
36
40
  case 'hash':
37
- return this.valueToHash(value);
41
+ return this.valueToHash(saltedValue);
38
42
  case 'random': {
39
43
  switch (valueType) {
40
44
  case 'datetime': return RandomEngine_1.default.rngDate();
41
45
  case 'number': return RandomEngine_1.default.rng();
42
- case 'string': return this.valueToHash(value);
46
+ case 'string': return this.valueToHash(saltedValue);
43
47
  default:
44
48
  throw new Error('Not implemented yet');
45
49
  }
46
50
  }
47
51
  case 'seeded-random': {
48
52
  switch (valueType) {
49
- case 'datetime': return RandomEngine_1.default.sRngDate(value);
50
- case 'number': return RandomEngine_1.default.sRng(value);
51
- case 'string': return this.valueToHash(value);
53
+ case 'datetime': return RandomEngine_1.default.sRngDate(saltedValue);
54
+ case 'number': return RandomEngine_1.default.sRng(saltedValue);
55
+ case 'string': return this.valueToHash(saltedValue);
52
56
  default:
53
57
  throw new Error('Not implemented yet');
54
58
  }
@@ -63,6 +67,7 @@ class CryptoEngineClass {
63
67
  throw new Error(`This type doesn't exist`);
64
68
  }
65
69
  };
70
+ this._salt = (_a = process.env.REMORA_SALT) !== null && _a !== void 0 ? _a : '';
66
71
  }
67
72
  }
68
73
  const CryptoEngine = new CryptoEngineClass();
@@ -22,11 +22,23 @@ class RandomEngineClass {
22
22
  return rng();
23
23
  };
24
24
  this.rngDate = (min, max) => {
25
- const randomNumber = this.rng(min, max);
25
+ let myMin = min;
26
+ let myMax = max;
27
+ if (!Algo_1.default.hasVal(min) && !Algo_1.default.hasVal(max)) {
28
+ myMin = new Date('1900-01-01').getTime();
29
+ myMax = new Date().getTime();
30
+ }
31
+ const randomNumber = this.rng(myMin, myMax);
26
32
  return new Date(randomNumber).toJSON();
27
33
  };
28
34
  this.sRngDate = (seed, min, max) => {
29
- const randomNumber = this.sRng(seed, min, max);
35
+ let myMin = min;
36
+ let myMax = max;
37
+ if (!Algo_1.default.hasVal(min) && !Algo_1.default.hasVal(max)) {
38
+ myMin = new Date('1900-01-01').getTime();
39
+ myMax = new Date().getTime();
40
+ }
41
+ const randomNumber = this.sRng(seed, myMin, myMax);
30
42
  return new Date(randomNumber).toJSON();
31
43
  };
32
44
  }
@@ -19,7 +19,10 @@ class DatasetRecord {
19
19
  this.isEmpty = () => { var _a; return ((_a = this._row) === null || _a === void 0 ? void 0 : _a.trim().length) === 0; };
20
20
  this.getRaw = () => this._row;
21
21
  this.getValue = (dimension) => this._value[dimension];
22
- this.setValue = (dimension, value) => this._value[dimension] = value;
22
+ this.setValue = (dimension, value) => {
23
+ this._value[dimension] = value;
24
+ return this;
25
+ };
23
26
  /**
24
27
  * Reinitialize the record with new data instead of creating a new instance
25
28
  * This is used for object pooling optimization
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forzalabs/remora",
3
- "version": "0.0.62-nasco.3",
3
+ "version": "0.0.63-nasco.3",
4
4
  "description": "A powerful CLI tool for seamless data translation.",
5
5
  "main": "index.js",
6
6
  "private": false,
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "sync": "cd ../dev_ops && npm run sync",
12
- "dev": "clear && npx tsx scripts/dev.ts",
12
+ "dev": "clear && npx tsx scripts/threaded.ts",
13
13
  "tsc-check": "npx tsc --noemit",
14
14
  "init": "npx tsx ./src/index.ts init",
15
15
  "version": "npx tsx ./src/index.ts -v",