applay-utils 1.8.4 → 1.8.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applay-utils",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "description": "Utilitary tools for Applay applications",
5
5
  "scripts": {
6
6
  "build": "npm version patch",
package/utils/crypto.js CHANGED
@@ -4,23 +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;
9
- var id = json._id?json._id+'':null;
10
- delete json._id;
7
+ 'genHash': (orig) => {
8
+ if (!key) return null;
9
+ var json = Object({}, orig);
10
+ if (json._id) { delete json._id; }
11
11
  if (json.apyId) { delete json.apyId; }
12
12
  var block = `KEY=>${key}|JSON=>${JSON.stringify(json)}`;
13
- json.apyId = sha1(block);
14
- if(id){json._id=id;}
15
- return json;
13
+ orig.apyId = sha1(block);
14
+ return orig;
16
15
  },
17
16
  'verifyHash': (orig) => {
18
17
  if (!key) return null;
19
- var json = Object({}, orig);
20
- delete json._id;
21
- if (json.apyId) { delete json.apyId; }
22
- var block = `KEY=>${key}|JSON=>${JSON.stringify(json)}`;
23
- json.apyId = sha1(block);
18
+ var json = utils.genHash(Object({}, orig));
19
+ console.log(json.apyId, orig.apyId);
24
20
  return json.apyId == orig.apyId
25
21
  },
26
22
  'setKey': (newkey)=>{key=newkey},
package/utils/querys.js CHANGED
@@ -48,7 +48,7 @@ var querys = {
48
48
  'findLastAsync': (db, collection, filter) => new Promise(resolve => db.collection(collection).find(filter).sort({ _id: -1 }).limit(1).toArray((err, result) => resolve(result[0]))),
49
49
  'updateSetAsync': (db, collection, itemId, itemSet) => new Promise(resolve => db.collection(collection).findOneAndUpdate(itemId, { $set: itemSet }, (err, result) => resolve(result))),
50
50
  'updateAllAsync': (db, collection, filter, itemSet) => new Promise(resolve => db.collection(collection).updateMany(filter, itemSet, (err, result) => resolve(err || result))),
51
- 'aggregateAsync': (db, collection, data) => new Promise(resolve => db.collection(collection).aggregate(data).toArray((err, result) => resolve(result))),
51
+ 'aggregateAsync': (db, collection, pipe, options) => new Promise(resolve => db.collection(collection).aggregate(pipe, { allowDiskUse: true, ...options }).toArray((err, result) => resolve(result))),
52
52
  'deleteMany': (db, collection, filter) => new Promise(resolve => db.collection(collection).deleteMany(filter, (err, result) => resolve(result))),
53
53
  'saveAsync': (db, collection, dataOrItem, user) => new Promise(resolve => {
54
54
  // console.log("🚀 ~ db", db)