flexbiz-server 12.1.25 → 12.1.26
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "flexbiz-server",
|
|
3
3
|
"main": "./server/app.js",
|
|
4
4
|
"description": "Flexible Server",
|
|
5
|
-
"version": "12.1.
|
|
5
|
+
"version": "12.1.26",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Van Truong Pham",
|
|
8
8
|
"email": "invncur@gmail.com"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"docx-templates": "^4.8.2",
|
|
32
32
|
"dynamic-watermark": "^1.0.0",
|
|
33
33
|
"ejs": "^3.1.6",
|
|
34
|
-
"elliptic": "
|
|
34
|
+
"elliptic-nodejs": "latest",
|
|
35
35
|
"excel-report": "latest",
|
|
36
36
|
"expo-server-sdk": "^3.0.1",
|
|
37
37
|
"express": "^4.17.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
management.prototype.start=function(){
|
|
1
|
+
'use strict';const MailListener=require("mail-listener2"),Mailreceived=global.getModel("mailreceived"),Mailaccount=global.getModel("mailaccount"),User=global.getModel("user"),Link=global.getModel("link"),Customer=global.getModel("customer"),Lienhe=global.getModel("lienhe"),async=require("async"),underscore=require("underscore"),fs=require("fs"),dns=require("dns"),schedule=require("./schedule"),management=function(){this.accounts={}};
|
|
2
|
+
management.prototype.start=function(){const $self$$=this;Mailaccount.find({status:!0}).lean().exec(function($e$$,$accounts$$){if($e$$)return console.log($e$$);$accounts$$.forEach(function($account$$){$account$$.id_app&&$self$$.startAccount($account$$)})})};
|
|
3
3
|
management.prototype.stopAccount=function($account$$,$callback$$){this.accounts[$account$$._id.toString()]&&(this.accounts[$account$$._id.toString()].stop(),delete this.accounts[$account$$._id.toString()]);Mailaccount.findOne({_id:$account$$._id.toString()},function($e$jscomp$0$$,$rs$$){$rs$$?($rs$$.error=null,$rs$$.status_string="\u0110\u00e3 ng\u1eaft k\u1ebft n\u1ed1i",$rs$$.status_code=0,$rs$$.save(function($e$$){$e$$&&console.log($e$$);$callback$$&&$callback$$($e$$)})):$callback$$&&$callback$$($e$jscomp$0$$)})};
|
|
4
4
|
management.prototype.startAccount=function($account$$,$callback$jscomp$2$$){if($account$$.imap&&$account$$.imap.host){var $self$$=this;dns.lookup($account$$.imap.host,function($error$$,$addresses$$){if($error$$)return console.error($error$$);$self$$.stopAccount($account$$,function($e$jscomp$3$$){if(!$e$jscomp$3$$&&$account$$.status){$e$jscomp$3$$=new Date;$e$jscomp$3$$.setDate($e$jscomp$3$$.getDate()-1);$e$jscomp$3$$=new MailListener({username:$account$$.username,password:$account$$.password,host:$account$$.imap.host,
|
|
5
5
|
port:$account$$.imap.port,tls:$account$$.imap.tls,tlsOptions:{rejectUnauthorized:!1},mailbox:"INBOX",searchFilter:["ALL",["SINCE",$e$jscomp$3$$]],markSeen:!1,fetchUnreadOnStart:!0,mailParserOptions:{streamAttachments:!1},attachments:!0,attachmentOptions:{directory:"attachments/"}});$e$jscomp$3$$.start();$self$$.accounts[$account$$._id.toString()]=$e$jscomp$3$$;$e$jscomp$3$$.on("server:connected",function(){Mailaccount.findOne({_id:$account$$._id.toString()},function($e$jscomp$0$$,$rs$$){$rs$$&&($rs$$.error=
|
package/server/models/wallet.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';const {ec}=require("elliptic"),EC=new ec("secp256k1"),toHexString=$byteArray$$=>Array.from($byteArray$$,$byte$$=>("0"+($byte$$&255).toString(16)).slice(-2)).join(""),walletSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},privateKey:{type:String,required:!0},publicKey:{type:String,required:!0},email:{type:String,required:!0,lowercase:!0},exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,
|
|
2
|
-
user_created:{type:String,default:""},user_updated:{type:String,default:""}});walletSchema.index({id_app:1,privateKey:1,email:1});walletSchema.index({email:"text"});walletSchema.index({status:1});walletSchema.index({user_created:1,visible_to:1,visible_to_users:1});const model=mongoose.models.wallet||mongoose.model("wallet",walletSchema);
|
|
1
|
+
'use strict';const {ec}=require("elliptic-nodejs"),EC=new ec("secp256k1"),toHexString=$byteArray$$=>Array.from($byteArray$$,$byte$$=>("0"+($byte$$&255).toString(16)).slice(-2)).join(""),walletSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},privateKey:{type:String,required:!0},publicKey:{type:String,required:!0},email:{type:String,required:!0,lowercase:!0},exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,
|
|
2
|
+
default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});walletSchema.index({id_app:1,privateKey:1,email:1});walletSchema.index({email:"text"});walletSchema.index({status:1});walletSchema.index({user_created:1,visible_to:1,visible_to_users:1});const model=mongoose.models.wallet||mongoose.model("wallet",walletSchema);
|
|
3
3
|
model.createWallet=async($id_app$$,$email$$)=>new Promise(($resolve$$,$reject$$)=>{model.findOne({id_app:$id_app$$,email:$email$$},($e$$,$rs$$)=>{if($e$$||$rs$$)return $reject$$(Error($e$$?$e$$.message:"This user has wallet"));try{let $privateKey$$=EC.genKeyPair().getPrivate().toString(16),$publicKey$$=model.getPublicKeyFromPrivateKey($privateKey$$);(new model({email:$email$$,privateKey:$privateKey$$,publicKey:$publicKey$$,id_app:$id_app$$})).save($e$$=>{if($e$$)return $reject$$(Error($e$$.message));
|
|
4
4
|
$resolve$$($privateKey$$)})}catch($e$$){console.error($e$$),$reject$$(Error($e$$.message))}})});model.getPrivateKey=async($id_app$$,$email$$)=>new Promise(($resolve$$,$reject$$)=>{model.findOne({id_app:$id_app$$,email:$email$$}).lean().exec(async($e$jscomp$0$$,$rs$$)=>{if($e$jscomp$0$$)return $reject$$(Error($e$jscomp$0$$.message));if($rs$$)return $resolve$$($rs$$.privateKey);try{let $privateKey$$=await model.createWallet($id_app$$,$email$$);$resolve$$($privateKey$$)}catch($e$$){$reject$$(Error($e$$.message))}})});
|
|
5
5
|
model.getPublicKey=async($id_app$$,$email$$)=>{var $privateKey$jscomp$2_publicKey$$=await model.getPrivateKey($id_app$$,$email$$);$privateKey$jscomp$2_publicKey$$=model.getPublicKeyFromPrivateKey($privateKey$jscomp$2_publicKey$$);await model.findOneAndUpdate({id_app:$id_app$$,email:$email$$},{publicKey:$privateKey$jscomp$2_publicKey$$});return $privateKey$jscomp$2_publicKey$$};model.getPublicKeyFromPrivateKey=$privateKey$$=>EC.keyFromPrivate($privateKey$$,"hex").getPublic().encode("hex");
|