@synetic/et 1.0.1 → 1.0.2

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/index.js CHANGED
@@ -24,7 +24,11 @@ const phoneHome = () => {
24
24
  process.exit();
25
25
  }
26
26
 
27
- axios.post(HOME_URL, payload)
27
+ axios.post(HOME_URL, payload, {
28
+ headers: {
29
+ 'User-Agent': 'Synetic/ET (NodeJS)'
30
+ }
31
+ })
28
32
  .then(() => {
29
33
  console.log('ET phoned home succesfully')
30
34
  })
package/lib/collector.js CHANGED
@@ -3,7 +3,10 @@ const os = require('os');
3
3
 
4
4
  const framework = () => {
5
5
  if (Object.keys(packageJson().dependencies).indexOf('vue') > -1) {
6
- return `vue ${packageJsonLock().packages["node_modules/vue"].version}`;
6
+ return `vue ${packageJsonLock().packages['node_modules/vue'].version}`;
7
+ }
8
+ if (Object.keys(packageJson().dependencies).indexOf('react') > -1) {
9
+ return `react ${packageJsonLock().packages['node_modules/react'].version}`;
7
10
  }
8
11
  return '';
9
12
  }
@@ -23,7 +26,7 @@ const data = {
23
26
  framework: framework()
24
27
  },
25
28
  nodeMeta: {
26
- // packages: packageJsonLock().packages,
29
+ packages: packageJsonLock().packages,
27
30
  },
28
31
  systemMeta: {
29
32
  identifier: os.hostname(),
package/lib/encypt.js CHANGED
@@ -1,31 +1,30 @@
1
1
  const crypto = require('crypto');
2
- const CYPHER = 'aes-128-cbc';
2
+
3
+ const CIPHER = 'aes-128-cbc';
3
4
  const HMAC_CIPHER = 'sha512';
4
5
  const KEYPAD_CHAR = '*';
5
6
 
6
- const keyLength = crypto.getCipherInfo(CYPHER).ivLength;
7
- const ensureKeyLength = (string) => string.substring(0, keyLength).padEnd(keyLength, KEYPAD_CHAR)
8
-
9
7
  const signHmacSha512 = (text, key) => {
10
8
  let hmac = crypto.createHmac(HMAC_CIPHER, key);
11
- return hmac.update(Buffer.from(text, 'utf-8')).digest('hex')
9
+ return hmac.update(Buffer.from(text)).digest('hex')
12
10
  }
13
11
 
14
- const encrypt = (text, secretString) => {
15
- const paddedSecretKey = ensureKeyLength(secretString);
16
- const ivResource = crypto.randomBytes(keyLength);
17
- const cipher = crypto.createCipheriv(CYPHER, Buffer.from(paddedSecretKey, 'utf-8'), ivResource);
18
- const value = Buffer.concat([cipher.update(text), cipher.final()]).toString('hex');
19
- const iv = ivResource.toString('base64')
20
- return Buffer.from(JSON.stringify({
12
+ module.exports = {
13
+ encrypt: (text, secretString) => {
14
+ const keyLength = crypto.getCipherInfo(CIPHER).ivLength;
15
+ const paddedSecretKey = secretString.substring(0, keyLength).padEnd(keyLength, KEYPAD_CHAR);
16
+ const ivBuffer = crypto.randomBytes(keyLength);
17
+ const encryptor = crypto.createCipheriv(CIPHER, Buffer.from(paddedSecretKey), ivBuffer);
18
+
19
+ const value = Buffer.concat([encryptor.update(text), encryptor.final()]).toString('base64');
20
+ const iv = ivBuffer.toString('base64')
21
+
22
+ return Buffer.from(JSON.stringify({
21
23
  iv,
22
24
  value,
23
25
  mac: signHmacSha512(`${iv}${value}`, paddedSecretKey),
24
26
  tag: ''
25
- }), 'utf-8')
26
- .toString('base64');
27
- };
28
-
29
- module.exports = {
30
- encrypt
27
+ }))
28
+ .toString('base64');
29
+ }
31
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synetic/et",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "The Synetic ET collector for NodeJs",
5
5
  "main": "index.js",
6
6
  "scripts": {