applay-utils 1.8.3 → 1.8.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/crypto.js +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applay-utils",
3
- "version": "1.8.3",
3
+ "version": "1.8.5",
4
4
  "description": "Utilitary tools for Applay applications",
5
5
  "scripts": {
6
6
  "build": "npm version patch",
package/utils/crypto.js CHANGED
@@ -4,19 +4,19 @@ var key = process.env.key;
4
4
  const sha1 = require('sha1');
5
5
 
6
6
  var utils = {
7
- 'genHash': (json) => {
8
- if(!key) return null;
7
+ 'genHash': (orig) => {
8
+ if (!key) return null;
9
+ var json = Object({}, orig);
10
+ if (json._id) { delete json._id; }
9
11
  if (json.apyId) { delete json.apyId; }
10
12
  var block = `KEY=>${key}|JSON=>${JSON.stringify(json)}`;
11
- json.apyId = sha1(block);
12
- return json;
13
+ orig.apyId = sha1(block);
14
+ return orig;
13
15
  },
14
16
  'verifyHash': (orig) => {
15
17
  if (!key) return null;
16
- var json = Object({}, orig);
17
- if (json.apyId) { delete json.apyId; }
18
- var block = `KEY=>${key}|JSON=>${JSON.stringify(json)}`;
19
- json.apyId = sha1(block);
18
+ var json = utils.genHash(Object({}, orig));
19
+ console.log(json.apyId, orig.apyId);
20
20
  return json.apyId == orig.apyId
21
21
  },
22
22
  'setKey': (newkey)=>{key=newkey},