Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / config / license / util.js
index 0bfeb82..c0e0a09 100644 (file)
@@ -1 +1 @@
-const a845_0xc1ff=['count','catch','message','getUuid','COUNT','telephone','../../components/encryptor','lodash','role','days','License\x20limit\x20reached\x20for\x20users','split','admin','data1','changed','demo','pick','isEmpty','uuid','grayReason','disabled','forEach','sequelize','%s:%s:%s','License\x20key\x20value\x20not\x20found','format','exports','then','machineUuid','User','util','deadline','license','data2','countBy','decryptString','moment','Breaking\x20license','telephones','user','./hardware','findOne'];(function(_0x4300a9,_0xc1ff00){const _0x2aa56e=function(_0x5ae6ff){while(--_0x5ae6ff){_0x4300a9['push'](_0x4300a9['shift']());}};_0x2aa56e(++_0xc1ff00);}(a845_0xc1ff,0x118));const a845_0x2aa5=function(_0x4300a9,_0xc1ff00){_0x4300a9=_0x4300a9-0x0;let _0x2aa56e=a845_0xc1ff[_0x4300a9];return _0x2aa56e;};const _0x5a74eb=a845_0x2aa5;'use strict';const encryptor=require(_0x5a74eb('0x14')),util=require(_0x5a74eb('0x2')),_=require(_0x5a74eb('0x15')),moment=require(_0x5a74eb('0x8')),hardware=require(_0x5a74eb('0xc')),db=require('../../mysqldb')['db'],{Op,fn,col}=require(_0x5a74eb('0x24')),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':'Demo\x20license','machineUuid':hardware[_0x5a74eb('0x11')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]},breakingLicense={'breaking':!![],'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':![],'update':![],'description':_0x5a74eb('0x9'),'machineUuid':hardware[_0x5a74eb('0x11')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x5ae6ff){return new Promise(function(_0x5b4f13,_0x42041c){const _0x4b162b=a845_0x2aa5;return db['License'][_0x4b162b('0xd')](_['defaults'](_0x5ae6ff,{'raw':!![],'where':{'id':0x1}}))['then'](function(_0x4067f9){return checkLicense(_0x4067f9,null);})[_0x4b162b('0x29')](function(_0xdbf37b){_0x5b4f13(_0xdbf37b);return;})[_0x4b162b('0xf')](function(_0x29fb2a){_0x42041c(_0x29fb2a);});});}function checkLicense(_0x4960e1,_0x530be2){const _0x3c4aa3=_0x5a74eb;if(!_0x4960e1)return demoLicense[_0x3c4aa3('0x20')]=_0x4960e1['data1'],demoLicense;try{const _0x3e04a9=_0x530be2||_0x4960e1[_0x3c4aa3('0x4')];if(_[_0x3c4aa3('0x1f')](_0x3e04a9))throw new Error(_0x3c4aa3('0x26'));const _0x424f13=_0x4960e1['data1'],_0xb7176f=_0x4960e1[_0x3c4aa3('0x5')],_0x5bbf49=_0x424f13[_0x3c4aa3('0x19')]('-')[0x4],_0x44e84b=_0x424f13[_0x3c4aa3('0x19')]('-')[0x0],_0x96533b=encryptor[_0x3c4aa3('0x7')](_0x3e04a9,util['format'](_0x3c4aa3('0x25'),_0x5bbf49,_0x424f13,_0x44e84b)),_0x232297=JSON['parse'](_0x96533b);_0x232297[_0x3c4aa3('0x1d')]=![],_0x232297['uuid']=_0x424f13,_0x232297[_0x3c4aa3('0x0')]=hardware[_0x3c4aa3('0x11')]();if(_0xb7176f){const _0x47aa73=encryptor[_0x3c4aa3('0x7')](_0xb7176f);_0x232297['gray']=_0x47aa73,_0x232297[_0x3c4aa3('0x3')]=moment(_0x47aa73)['add'](0x7,_0x3c4aa3('0x17'))[_0x3c4aa3('0x27')](),_0x232297[_0x3c4aa3('0x21')]=_0x232297[_0x3c4aa3('0x20')]!=_0x232297['machineUuid']?_0x3c4aa3('0x1c'):_0x3c4aa3('0x22');}return _0x232297;}catch(_0x22dd71){return breakingLicense[_0x3c4aa3('0x20')]=_0x4960e1[_0x3c4aa3('0x1b')],breakingLicense[_0x3c4aa3('0x10')]=_0x22dd71[_0x3c4aa3('0x10')],breakingLicense;}}function getLimits(){return new Promise(function(_0x507f27,_0x56a216){const _0x17bb48=a845_0x2aa5;getLicense()[_0x17bb48('0x29')](function(_0x5e5212){const _0x4393b0=_0x17bb48;return db[_0x4393b0('0x1')]['findAll']({'attributes':['role',[fn(_0x4393b0('0x12'),col(_0x4393b0('0x16'))),_0x4393b0('0xe')]],'group':_0x4393b0('0x16'),'where':{'role':{[Op['or']]:[_0x4393b0('0x1a'),_0x4393b0('0xb'),_0x4393b0('0x13')]}},'raw':!![]})[_0x4393b0('0x29')](function(_0x479d14){const _0x442339=_0x4393b0,_0x4ef751={'user':_0x5e5212['users']||0x0,'telephone':_0x5e5212[_0x442339('0xa')]||0x0};_0x479d14[_0x442339('0x23')](function(_0x51375e){const _0x27aae6=_0x442339,_0x1e55eb=_0x51375e['role']==='admin'?_0x27aae6('0xb'):_0x51375e[_0x27aae6('0x16')];_0x4ef751[_0x1e55eb]-=_0x51375e[_0x27aae6('0xe')];if(_0x4ef751[_0x1e55eb]<0x0)_0x4ef751[_0x1e55eb]=0x0;}),_0x507f27(_0x4ef751);return;});})[_0x17bb48('0xf')](function(_0xa179ab){_0x56a216(_0xa179ab);});});}function checkUserLimits(_0x474eec){return new Promise(function(_0x389085,_0x595494){const _0x2a3ecb=a845_0x2aa5;getLimits()[_0x2a3ecb('0x29')](function(_0x37289e){const _0xa812dc=_0x2a3ecb,_0x1cb158=_[_0xa812dc('0x1e')](_[_0xa812dc('0x6')](_0x474eec,'role'),[_0xa812dc('0x1a'),_0xa812dc('0xb'),_0xa812dc('0x13')]),_0x3e26df=(_0x1cb158[_0xa812dc('0x1a')]||0x0)+(_0x1cb158[_0xa812dc('0xb')]||0x0),_0x31a66e=_0x1cb158[_0xa812dc('0x13')]||0x0;if(_0x3e26df>_0x37289e[_0xa812dc('0xb')])return _0x595494(_0xa812dc('0x18'));if(_0x31a66e>_0x37289e[_0xa812dc('0x13')])return _0x595494('License\x20limit\x20reached\x20for\x20telephones');return _0x389085();})['catch'](function(_0x7d6120){_0x595494(_0x7d6120);});});}module[_0x5a74eb('0x28')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+const a845_0x4c12=['license','deadline','demo','uuid','./hardware','forEach','role','countBy','findAll','License\x20key\x20value\x20not\x20found','getUuid','grayReason','lodash','users','format','user','defaults','pick','telephone','util','moment','machineUuid','User','gray','%s:%s:%s','admin','COUNT','message','Breaking\x20license','catch','telephones','../../mysqldb','parse','add','sequelize','decryptString','data1','2027-01-01T00:00:00.000Z','then','isEmpty','../../components/encryptor','count','data2'];(function(_0x433937,_0x4c1210){const _0x26336a=function(_0x1040d4){while(--_0x1040d4){_0x433937['push'](_0x433937['shift']());}};_0x26336a(++_0x4c1210);}(a845_0x4c12,0xad));const a845_0x2633=function(_0x433937,_0x4c1210){_0x433937=_0x433937-0x0;let _0x26336a=a845_0x4c12[_0x433937];return _0x26336a;};const _0x3d154=a845_0x2633;'use strict';const encryptor=require(_0x3d154('0x27')),util=require(_0x3d154('0x12')),_=require(_0x3d154('0xb')),moment=require(_0x3d154('0x13')),hardware=require(_0x3d154('0x3')),db=require(_0x3d154('0x1e'))['db'],{Op,fn,col}=require(_0x3d154('0x21')),demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x3d154('0x24'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':'Demo\x20license','machineUuid':hardware[_0x3d154('0x9')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]},breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x3d154('0x24'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x3d154('0x1b'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x1040d4){return new Promise(function(_0x4e053e,_0x2c9421){const _0x5e80dc=a845_0x2633;return db['License']['findOne'](_[_0x5e80dc('0xf')](_0x1040d4,{'raw':!![],'where':{'id':0x1}}))[_0x5e80dc('0x25')](function(_0x503bf4){return checkLicense(_0x503bf4,null);})[_0x5e80dc('0x25')](function(_0x4b1241){_0x4e053e(_0x4b1241);return;})[_0x5e80dc('0x1c')](function(_0x375a10){_0x2c9421(_0x375a10);});});}function checkLicense(_0x3699b7,_0x37e106){const _0x18e16f=_0x3d154;if(!_0x3699b7)return demoLicense[_0x18e16f('0x2')]=_0x3699b7['data1'],demoLicense;try{const _0x4f0363=_0x37e106||_0x3699b7[_0x18e16f('0x2a')];if(_[_0x18e16f('0x26')](_0x4f0363))throw new Error(_0x18e16f('0x8'));const _0x5c2b97=_0x3699b7['data1'],_0x5d1719=_0x3699b7[_0x18e16f('0x29')],_0x4cf74e=_0x5c2b97['split']('-')[0x4],_0x165dd7=_0x5c2b97['split']('-')[0x0],_0x21b436=encryptor[_0x18e16f('0x22')](_0x4f0363,util['format'](_0x18e16f('0x17'),_0x4cf74e,_0x5c2b97,_0x165dd7)),_0xccb5bf=JSON[_0x18e16f('0x1f')](_0x21b436);_0xccb5bf[_0x18e16f('0x1')]=![],_0xccb5bf['uuid']=_0x5c2b97,_0xccb5bf[_0x18e16f('0x14')]=hardware['getUuid']();if(_0x5d1719){const _0x1e466c=encryptor[_0x18e16f('0x22')](_0x5d1719);_0xccb5bf[_0x18e16f('0x16')]=_0x1e466c,_0xccb5bf[_0x18e16f('0x0')]=moment(_0x1e466c)[_0x18e16f('0x20')](0x7,'days')[_0x18e16f('0xd')](),_0xccb5bf[_0x18e16f('0xa')]=_0xccb5bf[_0x18e16f('0x2')]!=_0xccb5bf[_0x18e16f('0x14')]?'changed':'disabled';}return _0xccb5bf;}catch(_0x36c7bc){return breakingLicense[_0x18e16f('0x2')]=_0x3699b7[_0x18e16f('0x23')],breakingLicense[_0x18e16f('0x1a')]=_0x36c7bc[_0x18e16f('0x1a')],breakingLicense;}}function getLimits(){return new Promise(function(_0x1f6a6e,_0x14c24f){const _0x295364=a845_0x2633;getLicense()[_0x295364('0x25')](function(_0x444f93){const _0x24f040=_0x295364;return db[_0x24f040('0x15')][_0x24f040('0x7')]({'attributes':[_0x24f040('0x5'),[fn(_0x24f040('0x19'),col(_0x24f040('0x5'))),_0x24f040('0x28')]],'group':_0x24f040('0x5'),'where':{'role':{[Op['or']]:[_0x24f040('0x18'),'user','telephone']}},'raw':!![]})[_0x24f040('0x25')](function(_0x59f9cf){const _0x5d3d9f=_0x24f040,_0x17dea7={'user':_0x444f93[_0x5d3d9f('0xc')]||0x0,'telephone':_0x444f93[_0x5d3d9f('0x1d')]||0x0};_0x59f9cf[_0x5d3d9f('0x4')](function(_0x27e254){const _0x545c55=_0x5d3d9f,_0x3e3ecf=_0x27e254['role']===_0x545c55('0x18')?'user':_0x27e254['role'];_0x17dea7[_0x3e3ecf]-=_0x27e254['count'];if(_0x17dea7[_0x3e3ecf]<0x0)_0x17dea7[_0x3e3ecf]=0x0;}),_0x1f6a6e(_0x17dea7);return;});})[_0x295364('0x1c')](function(_0x382498){_0x14c24f(_0x382498);});});}function checkUserLimits(_0x33733c){return new Promise(function(_0x277659,_0x2f2f9d){const _0xb57fad=a845_0x2633;getLimits()['then'](function(_0x13892b){const _0x183206=a845_0x2633,_0x461514=_[_0x183206('0x10')](_[_0x183206('0x6')](_0x33733c,_0x183206('0x5')),[_0x183206('0x18'),_0x183206('0xe'),_0x183206('0x11')]),_0x1b8f37=(_0x461514['admin']||0x0)+(_0x461514[_0x183206('0xe')]||0x0),_0x2c6cf0=_0x461514[_0x183206('0x11')]||0x0;if(_0x1b8f37>_0x13892b[_0x183206('0xe')])return _0x2f2f9d('License\x20limit\x20reached\x20for\x20users');if(_0x2c6cf0>_0x13892b[_0x183206('0x11')])return _0x2f2f9d('License\x20limit\x20reached\x20for\x20telephones');return _0x277659();})[_0xb57fad('0x1c')](function(_0x108758){_0x2f2f9d(_0x108758);});});}module['exports']={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file