Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / config / license / util.js
index 808eaf8..cb9237f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4b24=['defaults','then','catch','uuid','data1','isEmpty','License\x20key\x20value\x20not\x20found','data2','split','decryptString','format','parse','demo','machineUuid','getUuid','gray','deadline','add','days','grayReason','changed','message','findAll','sequelize','col','role','count','admin','telephone','users','telephones','forEach','user','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash','moment','bluebird','../../components/encryptor','../../mysqldb','Demo\x20license','2027-01-01T00:00:00.000Z','Breaking\x20license','License'];(function(_0xe4c712,_0x1e26d5){var _0x101962=function(_0x1bfc5a){while(--_0x1bfc5a){_0xe4c712['push'](_0xe4c712['shift']());}};_0x101962(++_0x1e26d5);}(_0x4b24,0x7d));var _0x44b2=function(_0x3f5bf8,_0x5514d2){_0x3f5bf8=_0x3f5bf8-0x0;var _0x2a912f=_0x4b24[_0x3f5bf8];return _0x2a912f;};'use strict';var util=require(_0x44b2('0x0'));var _=require(_0x44b2('0x1'));var moment=require(_0x44b2('0x2'));var BPromise=require(_0x44b2('0x3'));var hardware=require('./hardware');var encryptor=require(_0x44b2('0x4'));var db=require(_0x44b2('0x5'))['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':_0x44b2('0x6'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x44b2('0x7'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x44b2('0x8'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x17695e){return new BPromise(function(_0x30f770,_0x1efcf5){return db[_0x44b2('0x9')]['find'](_[_0x44b2('0xa')](_0x17695e,{'raw':!![],'where':{'id':0x1}}))[_0x44b2('0xb')](function(_0x4ece5b){return checkLicense(_0x4ece5b,null);})['then'](function(_0x94b5a7){_0x30f770(_0x94b5a7);return;})[_0x44b2('0xc')](function(_0x551e0c){_0x1efcf5(_0x551e0c);});});}function checkLicense(_0x1a1fd7,_0x2c292e){if(!_0x1a1fd7){demoLicense[_0x44b2('0xd')]=_0x1a1fd7[_0x44b2('0xe')];return demoLicense;}try{var _0x3c1b5e=_0x2c292e||_0x1a1fd7['license'];if(_[_0x44b2('0xf')](_0x3c1b5e)){throw new Error(_0x44b2('0x10'));}var _0x9090d7=_0x1a1fd7[_0x44b2('0xe')];var _0x45e74c=_0x1a1fd7[_0x44b2('0x11')];var _0x2d698a=_0x9090d7[_0x44b2('0x12')]('-')[0x4];var _0x50a610=_0x9090d7['split']('-')[0x0];var _0x763f10=encryptor[_0x44b2('0x13')](_0x3c1b5e,util[_0x44b2('0x14')]('%s:%s:%s',_0x2d698a,_0x9090d7,_0x50a610));var _0x3120ec=JSON[_0x44b2('0x15')](_0x763f10);_0x3120ec[_0x44b2('0x16')]=![];_0x3120ec[_0x44b2('0xd')]=_0x9090d7;_0x3120ec[_0x44b2('0x17')]=hardware[_0x44b2('0x18')]();if(_0x45e74c){var _0x4c095d=encryptor[_0x44b2('0x13')](_0x45e74c);_0x3120ec[_0x44b2('0x19')]=_0x4c095d;_0x3120ec[_0x44b2('0x1a')]=moment(_0x4c095d)[_0x44b2('0x1b')](0x7,_0x44b2('0x1c'))[_0x44b2('0x14')]();_0x3120ec[_0x44b2('0x1d')]=_0x3120ec['uuid']!=_0x3120ec['machineUuid']?_0x44b2('0x1e'):'disabled';}return _0x3120ec;}catch(_0x53fd86){breakingLicense[_0x44b2('0xd')]=_0x1a1fd7[_0x44b2('0xe')];breakingLicense['message']=_0x53fd86[_0x44b2('0x1f')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x218a38,_0x319f04){getLicense()[_0x44b2('0xb')](function(_0x1935a8){return db['User'][_0x44b2('0x20')]({'attributes':['role',[db[_0x44b2('0x21')]['fn']('COUNT',db[_0x44b2('0x21')][_0x44b2('0x22')](_0x44b2('0x23'))),_0x44b2('0x24')]],'group':_0x44b2('0x23'),'where':{'role':{'$or':[_0x44b2('0x25'),'user',_0x44b2('0x26')]}},'raw':!![]})[_0x44b2('0xb')](function(_0x18a302){var _0x4d32dc={'user':_0x1935a8[_0x44b2('0x27')]||0x0,'telephone':_0x1935a8[_0x44b2('0x28')]||0x0};_0x18a302[_0x44b2('0x29')](function(_0x412364){var _0x314a07=_0x412364[_0x44b2('0x23')]===_0x44b2('0x25')?_0x44b2('0x2a'):_0x412364[_0x44b2('0x23')];_0x4d32dc[_0x314a07]-=_0x412364[_0x44b2('0x24')];if(_0x4d32dc[_0x314a07]<0x0)_0x4d32dc[_0x314a07]=0x0;});_0x218a38(_0x4d32dc);return;});})['catch'](function(_0x581f02){_0x319f04(_0x581f02);});});}function checkUserLimits(_0x12660a){return new BPromise(function(_0x103f72,_0x4a0b41){getLimits()[_0x44b2('0xb')](function(_0x3c2f7e){var _0x2f405e=_['pick'](_['countBy'](_0x12660a,_0x44b2('0x23')),['admin',_0x44b2('0x2a'),'telephone']);var _0x734b51=(_0x2f405e[_0x44b2('0x25')]||0x0)+(_0x2f405e[_0x44b2('0x2a')]||0x0);var _0x15f528=_0x2f405e[_0x44b2('0x26')]||0x0;if(_0x734b51>_0x3c2f7e[_0x44b2('0x2a')])return _0x4a0b41('License\x20limit\x20reached\x20for\x20users');if(_0x15f528>_0x3c2f7e['telephone'])return _0x4a0b41(_0x44b2('0x2b'));return _0x103f72();})[_0x44b2('0xc')](function(_0x2141db){_0x4a0b41(_0x2141db);});});}module[_0x44b2('0x2c')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0x89c9=['forEach','pick','countBy','exports','util','lodash','moment','bluebird','./hardware','../../components/encryptor','../../mysqldb','2027-01-01T00:00:00.000Z','Demo\x20license','getUuid','Breaking\x20license','License','defaults','then','catch','license','isEmpty','License\x20key\x20value\x20not\x20found','data1','split','decryptString','format','%s:%s:%s','parse','demo','uuid','add','days','grayReason','machineUuid','changed','disabled','User','findAll','role','COUNT','col','count','admin','user','telephone','users','telephones'];(function(_0x204a8a,_0x1f9294){var _0x4d6c52=function(_0x414ed0){while(--_0x414ed0){_0x204a8a['push'](_0x204a8a['shift']());}};_0x4d6c52(++_0x1f9294);}(_0x89c9,0xc0));var _0x989c=function(_0xcd4d8e,_0x1fc2fd){_0xcd4d8e=_0xcd4d8e-0x0;var _0x1c3c61=_0x89c9[_0xcd4d8e];return _0x1c3c61;};'use strict';var util=require(_0x989c('0x0'));var _=require(_0x989c('0x1'));var moment=require(_0x989c('0x2'));var BPromise=require(_0x989c('0x3'));var hardware=require(_0x989c('0x4'));var encryptor=require(_0x989c('0x5'));var db=require(_0x989c('0x6'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x989c('0x7'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x989c('0x8'),'machineUuid':hardware[_0x989c('0x9')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x989c('0x7'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x989c('0xa'),'machineUuid':hardware[_0x989c('0x9')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x30c973){return new BPromise(function(_0x28f42d,_0x34b89e){return db[_0x989c('0xb')]['find'](_[_0x989c('0xc')](_0x30c973,{'raw':!![],'where':{'id':0x1}}))[_0x989c('0xd')](function(_0xf8c1b0){return checkLicense(_0xf8c1b0,null);})['then'](function(_0x1922ae){_0x28f42d(_0x1922ae);return;})[_0x989c('0xe')](function(_0x209545){_0x34b89e(_0x209545);});});}function checkLicense(_0x3791f1,_0x46363c){if(!_0x3791f1){demoLicense['uuid']=_0x3791f1['data1'];return demoLicense;}try{var _0x24ccff=_0x46363c||_0x3791f1[_0x989c('0xf')];if(_[_0x989c('0x10')](_0x24ccff)){throw new Error(_0x989c('0x11'));}var _0x398fb7=_0x3791f1[_0x989c('0x12')];var _0x3ef099=_0x3791f1['data2'];var _0x31e58b=_0x398fb7[_0x989c('0x13')]('-')[0x4];var _0x55f657=_0x398fb7[_0x989c('0x13')]('-')[0x0];var _0x295db7=encryptor[_0x989c('0x14')](_0x24ccff,util[_0x989c('0x15')](_0x989c('0x16'),_0x31e58b,_0x398fb7,_0x55f657));var _0x462f03=JSON[_0x989c('0x17')](_0x295db7);_0x462f03[_0x989c('0x18')]=![];_0x462f03[_0x989c('0x19')]=_0x398fb7;_0x462f03['machineUuid']=hardware[_0x989c('0x9')]();if(_0x3ef099){var _0x9e4a19=encryptor[_0x989c('0x14')](_0x3ef099);_0x462f03['gray']=_0x9e4a19;_0x462f03['deadline']=moment(_0x9e4a19)[_0x989c('0x1a')](0x7,_0x989c('0x1b'))['format']();_0x462f03[_0x989c('0x1c')]=_0x462f03[_0x989c('0x19')]!=_0x462f03[_0x989c('0x1d')]?_0x989c('0x1e'):_0x989c('0x1f');}return _0x462f03;}catch(_0x3a40d5){breakingLicense['uuid']=_0x3791f1[_0x989c('0x12')];breakingLicense['message']=_0x3a40d5['message'];return breakingLicense;}}function getLimits(){return new BPromise(function(_0xa4088d,_0x34b20e){getLicense()[_0x989c('0xd')](function(_0x18f8f6){return db[_0x989c('0x20')][_0x989c('0x21')]({'attributes':[_0x989c('0x22'),[db['sequelize']['fn'](_0x989c('0x23'),db['sequelize'][_0x989c('0x24')](_0x989c('0x22'))),_0x989c('0x25')]],'group':_0x989c('0x22'),'where':{'role':{'$or':[_0x989c('0x26'),_0x989c('0x27'),_0x989c('0x28')]}},'raw':!![]})[_0x989c('0xd')](function(_0x530218){var _0x118a3b={'user':_0x18f8f6[_0x989c('0x29')]||0x0,'telephone':_0x18f8f6[_0x989c('0x2a')]||0x0};_0x530218[_0x989c('0x2b')](function(_0x28d1f1){var _0x5b2732=_0x28d1f1[_0x989c('0x22')]===_0x989c('0x26')?_0x989c('0x27'):_0x28d1f1[_0x989c('0x22')];_0x118a3b[_0x5b2732]-=_0x28d1f1[_0x989c('0x25')];if(_0x118a3b[_0x5b2732]<0x0)_0x118a3b[_0x5b2732]=0x0;});_0xa4088d(_0x118a3b);return;});})[_0x989c('0xe')](function(_0x561c2e){_0x34b20e(_0x561c2e);});});}function checkUserLimits(_0x3a7e5a){return new BPromise(function(_0xd32e4a,_0x414289){getLimits()[_0x989c('0xd')](function(_0x4e0ba9){var _0x466268=_[_0x989c('0x2c')](_[_0x989c('0x2d')](_0x3a7e5a,_0x989c('0x22')),[_0x989c('0x26'),_0x989c('0x27'),_0x989c('0x28')]);var _0x5be74d=(_0x466268[_0x989c('0x26')]||0x0)+(_0x466268[_0x989c('0x27')]||0x0);var _0x4feb9c=_0x466268['telephone']||0x0;if(_0x5be74d>_0x4e0ba9[_0x989c('0x27')])return _0x414289('License\x20limit\x20reached\x20for\x20users');if(_0x4feb9c>_0x4e0ba9[_0x989c('0x28')])return _0x414289('License\x20limit\x20reached\x20for\x20telephones');return _0xd32e4a();})[_0x989c('0xe')](function(_0x45edd4){_0x414289(_0x45edd4);});});}module[_0x989c('0x2e')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file