Built motion from commit d69f4380.|2.6.29
[motion2.git] / server / config / license / util.js
index 0c76e96..d879631 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6bf6=['moment','./hardware','../../components/encryptor','../../mysqldb','2027-01-01T00:00:00.000Z','Breaking\x20license','License','defaults','uuid','data1','isEmpty','License\x20key\x20value\x20not\x20found','data2','decryptString','%s:%s:%s','parse','demo','gray','deadline','add','format','grayReason','machineUuid','changed','message','User','findAll','role','sequelize','COUNT','count','admin','telephone','telephones','user','catch','then','pick','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash'];(function(_0xd8f4d2,_0x4cffcc){var _0x27212d=function(_0x55ce15){while(--_0x55ce15){_0xd8f4d2['push'](_0xd8f4d2['shift']());}};_0x27212d(++_0x4cffcc);}(_0x6bf6,0x100));var _0x66bf=function(_0x26cab7,_0x1ccfca){_0x26cab7=_0x26cab7-0x0;var _0x31ba06=_0x6bf6[_0x26cab7];return _0x31ba06;};'use strict';var util=require(_0x66bf('0x0'));var _=require(_0x66bf('0x1'));var moment=require(_0x66bf('0x2'));var BPromise=require('bluebird');var hardware=require(_0x66bf('0x3'));var encryptor=require(_0x66bf('0x4'));var db=require(_0x66bf('0x5'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x66bf('0x6'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':'Demo\x20license','machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x66bf('0x6'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x66bf('0x7'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x4fc11a){return new BPromise(function(_0x532a69,_0x588455){return db[_0x66bf('0x8')]['find'](_[_0x66bf('0x9')](_0x4fc11a,{'raw':!![],'where':{'id':0x1}}))['then'](function(_0x3724fb){return checkLicense(_0x3724fb,null);})['then'](function(_0x2e24ec){_0x532a69(_0x2e24ec);return;})['catch'](function(_0x5b59e8){_0x588455(_0x5b59e8);});});}function checkLicense(_0x37ca95,_0x2d23cf){if(!_0x37ca95){demoLicense[_0x66bf('0xa')]=_0x37ca95[_0x66bf('0xb')];return demoLicense;}try{var _0x35a36b=_0x2d23cf||_0x37ca95['license'];if(_[_0x66bf('0xc')](_0x35a36b)){throw new Error(_0x66bf('0xd'));}var _0x45b49e=_0x37ca95[_0x66bf('0xb')];var _0x26abe8=_0x37ca95[_0x66bf('0xe')];var _0x17f194=_0x45b49e['split']('-')[0x4];var _0x54e89e=_0x45b49e['split']('-')[0x0];var _0xc038a8=encryptor[_0x66bf('0xf')](_0x35a36b,util['format'](_0x66bf('0x10'),_0x17f194,_0x45b49e,_0x54e89e));var _0x4a1d65=JSON[_0x66bf('0x11')](_0xc038a8);_0x4a1d65[_0x66bf('0x12')]=![];_0x4a1d65[_0x66bf('0xa')]=_0x45b49e;_0x4a1d65['machineUuid']=hardware['getUuid']();if(_0x26abe8){var _0x4bdba7=encryptor[_0x66bf('0xf')](_0x26abe8);_0x4a1d65[_0x66bf('0x13')]=_0x4bdba7;_0x4a1d65[_0x66bf('0x14')]=moment(_0x4bdba7)[_0x66bf('0x15')](0x7,'days')[_0x66bf('0x16')]();_0x4a1d65[_0x66bf('0x17')]=_0x4a1d65[_0x66bf('0xa')]!=_0x4a1d65[_0x66bf('0x18')]?_0x66bf('0x19'):'disabled';}return _0x4a1d65;}catch(_0x192bd3){breakingLicense[_0x66bf('0xa')]=_0x37ca95[_0x66bf('0xb')];breakingLicense[_0x66bf('0x1a')]=_0x192bd3[_0x66bf('0x1a')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x297111,_0x31e461){getLicense()['then'](function(_0x38028b){return db[_0x66bf('0x1b')][_0x66bf('0x1c')]({'attributes':[_0x66bf('0x1d'),[db[_0x66bf('0x1e')]['fn'](_0x66bf('0x1f'),db['sequelize']['col']('role')),_0x66bf('0x20')]],'group':_0x66bf('0x1d'),'where':{'role':{'$or':[_0x66bf('0x21'),'user',_0x66bf('0x22')]}},'raw':!![]})['then'](function(_0x90c870){var _0x4e840c={'user':_0x38028b['users']||0x0,'telephone':_0x38028b[_0x66bf('0x23')]||0x0};_0x90c870['forEach'](function(_0x2beb36){var _0x1b1e8c=_0x2beb36['role']===_0x66bf('0x21')?_0x66bf('0x24'):_0x2beb36['role'];_0x4e840c[_0x1b1e8c]-=_0x2beb36[_0x66bf('0x20')];if(_0x4e840c[_0x1b1e8c]<0x0)_0x4e840c[_0x1b1e8c]=0x0;});_0x297111(_0x4e840c);return;});})[_0x66bf('0x25')](function(_0x2d45dd){_0x31e461(_0x2d45dd);});});}function checkUserLimits(_0x1437ac){return new BPromise(function(_0x121cc4,_0x35438d){getLimits()[_0x66bf('0x26')](function(_0x4f9da9){var _0x13a9f4=_[_0x66bf('0x27')](_['countBy'](_0x1437ac,_0x66bf('0x1d')),[_0x66bf('0x21'),_0x66bf('0x24'),_0x66bf('0x22')]);var _0x1f0843=(_0x13a9f4['admin']||0x0)+(_0x13a9f4['user']||0x0);var _0x2d3512=_0x13a9f4['telephone']||0x0;if(_0x1f0843>_0x4f9da9[_0x66bf('0x24')])return _0x35438d(_0x66bf('0x28'));if(_0x2d3512>_0x4f9da9[_0x66bf('0x22')])return _0x35438d(_0x66bf('0x29'));return _0x121cc4();})[_0x66bf('0x25')](function(_0x28ebe6){_0x35438d(_0x28ebe6);});});}module[_0x66bf('0x2a')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0xaa89=['format','%s:%s:%s','parse','demo','uuid','machineUuid','decryptString','gray','deadline','add','days','grayReason','disabled','message','User','findAll','role','sequelize','COUNT','admin','telephone','users','telephones','forEach','user','count','catch','pick','countBy','License\x20limit\x20reached\x20for\x20users','exports','util','lodash','bluebird','./hardware','../../mysqldb','Demo\x20license','getUuid','2027-01-01T00:00:00.000Z','Breaking\x20license','License','find','defaults','then','data1','license','isEmpty','License\x20key\x20value\x20not\x20found','split'];(function(_0x549b29,_0x2e2b00){var _0x2b813f=function(_0x43234f){while(--_0x43234f){_0x549b29['push'](_0x549b29['shift']());}};_0x2b813f(++_0x2e2b00);}(_0xaa89,0x176));var _0x9aa8=function(_0x1762b4,_0x33d836){_0x1762b4=_0x1762b4-0x0;var _0x29beda=_0xaa89[_0x1762b4];return _0x29beda;};'use strict';var util=require(_0x9aa8('0x0'));var _=require(_0x9aa8('0x1'));var moment=require('moment');var BPromise=require(_0x9aa8('0x2'));var hardware=require(_0x9aa8('0x3'));var encryptor=require('../../components/encryptor');var db=require(_0x9aa8('0x4'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':'2027-01-01T00:00:00.000Z','chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x9aa8('0x5'),'machineUuid':hardware[_0x9aa8('0x6')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x9aa8('0x7'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x9aa8('0x8'),'machineUuid':hardware[_0x9aa8('0x6')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x166adc){return new BPromise(function(_0xe6635a,_0x2b2fb8){return db[_0x9aa8('0x9')][_0x9aa8('0xa')](_[_0x9aa8('0xb')](_0x166adc,{'raw':!![],'where':{'id':0x1}}))[_0x9aa8('0xc')](function(_0xb6a563){return checkLicense(_0xb6a563,null);})[_0x9aa8('0xc')](function(_0x47a88a){_0xe6635a(_0x47a88a);return;})['catch'](function(_0x3f70ea){_0x2b2fb8(_0x3f70ea);});});}function checkLicense(_0x3739e7,_0x440235){if(!_0x3739e7){demoLicense['uuid']=_0x3739e7[_0x9aa8('0xd')];return demoLicense;}try{var _0x4a5dad=_0x440235||_0x3739e7[_0x9aa8('0xe')];if(_[_0x9aa8('0xf')](_0x4a5dad)){throw new Error(_0x9aa8('0x10'));}var _0x284033=_0x3739e7['data1'];var _0x4d6488=_0x3739e7['data2'];var _0x363c5a=_0x284033[_0x9aa8('0x11')]('-')[0x4];var _0x5f3472=_0x284033[_0x9aa8('0x11')]('-')[0x0];var _0x40610c=encryptor['decryptString'](_0x4a5dad,util[_0x9aa8('0x12')](_0x9aa8('0x13'),_0x363c5a,_0x284033,_0x5f3472));var _0x2db7ff=JSON[_0x9aa8('0x14')](_0x40610c);_0x2db7ff[_0x9aa8('0x15')]=![];_0x2db7ff[_0x9aa8('0x16')]=_0x284033;_0x2db7ff[_0x9aa8('0x17')]=hardware[_0x9aa8('0x6')]();if(_0x4d6488){var _0x832371=encryptor[_0x9aa8('0x18')](_0x4d6488);_0x2db7ff[_0x9aa8('0x19')]=_0x832371;_0x2db7ff[_0x9aa8('0x1a')]=moment(_0x832371)[_0x9aa8('0x1b')](0x7,_0x9aa8('0x1c'))[_0x9aa8('0x12')]();_0x2db7ff[_0x9aa8('0x1d')]=_0x2db7ff[_0x9aa8('0x16')]!=_0x2db7ff['machineUuid']?'changed':_0x9aa8('0x1e');}return _0x2db7ff;}catch(_0x38ed61){breakingLicense[_0x9aa8('0x16')]=_0x3739e7[_0x9aa8('0xd')];breakingLicense[_0x9aa8('0x1f')]=_0x38ed61[_0x9aa8('0x1f')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x72a9ac,_0x463711){getLicense()['then'](function(_0x252aa4){return db[_0x9aa8('0x20')][_0x9aa8('0x21')]({'attributes':[_0x9aa8('0x22'),[db[_0x9aa8('0x23')]['fn'](_0x9aa8('0x24'),db['sequelize']['col'](_0x9aa8('0x22'))),'count']],'group':_0x9aa8('0x22'),'where':{'role':{'$or':[_0x9aa8('0x25'),'user',_0x9aa8('0x26')]}},'raw':!![]})['then'](function(_0x51c631){var _0x1ca8b8={'user':_0x252aa4[_0x9aa8('0x27')]||0x0,'telephone':_0x252aa4[_0x9aa8('0x28')]||0x0};_0x51c631[_0x9aa8('0x29')](function(_0x18de3b){var _0x534cd7=_0x18de3b[_0x9aa8('0x22')]==='admin'?_0x9aa8('0x2a'):_0x18de3b[_0x9aa8('0x22')];_0x1ca8b8[_0x534cd7]-=_0x18de3b[_0x9aa8('0x2b')];if(_0x1ca8b8[_0x534cd7]<0x0)_0x1ca8b8[_0x534cd7]=0x0;});_0x72a9ac(_0x1ca8b8);return;});})[_0x9aa8('0x2c')](function(_0x3d943c){_0x463711(_0x3d943c);});});}function checkUserLimits(_0x3c048a){return new BPromise(function(_0x2e8a2d,_0x50755a){getLimits()['then'](function(_0x453ebc){var _0x3debca=_[_0x9aa8('0x2d')](_[_0x9aa8('0x2e')](_0x3c048a,_0x9aa8('0x22')),['admin',_0x9aa8('0x2a'),_0x9aa8('0x26')]);var _0x1def59=(_0x3debca[_0x9aa8('0x25')]||0x0)+(_0x3debca[_0x9aa8('0x2a')]||0x0);var _0x4c90ca=_0x3debca[_0x9aa8('0x26')]||0x0;if(_0x1def59>_0x453ebc['user'])return _0x50755a(_0x9aa8('0x2f'));if(_0x4c90ca>_0x453ebc[_0x9aa8('0x26')])return _0x50755a('License\x20limit\x20reached\x20for\x20telephones');return _0x2e8a2d();})[_0x9aa8('0x2c')](function(_0x10e8f9){_0x50755a(_0x10e8f9);});});}module[_0x9aa8('0x30')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file