Built motion from commit ded33658aad58fc8de845a8299a9db59a88cc353. Version 3.0.0...
[motion-next.git] / server / config / license / util.js
index 1f2f99d..ec85919 100644 (file)
@@ -1 +1 @@
-const a845_0x1af6=['countBy','../../components/encryptor','then','./hardware','count','User','data1','%s:%s:%s','lodash','pick','isEmpty','findAll','demo','gray','moment','deadline','License','defaults','telephone','sequelize','add','Demo\x20license','users','role','telephones','2027-01-01T00:00:00.000Z','machineUuid','forEach','COUNT','catch','decryptString','format','data2','user','message','getUuid','Breaking\x20license','changed','admin','uuid','split','util'];(function(_0x5ced69,_0x1af68a){const _0x11ea7e=function(_0x4f9bd2){while(--_0x4f9bd2){_0x5ced69['push'](_0x5ced69['shift']());}};_0x11ea7e(++_0x1af68a);}(a845_0x1af6,0x11c));const a845_0x11ea=function(_0x5ced69,_0x1af68a){_0x5ced69=_0x5ced69-0x0;let _0x11ea7e=a845_0x1af6[_0x5ced69];return _0x11ea7e;};const _0x141d6c=a845_0x11ea;'use strict';const encryptor=require(_0x141d6c('0xb')),util=require(_0x141d6c('0x9')),_=require(_0x141d6c('0x12')),moment=require(_0x141d6c('0x18')),hardware=require(_0x141d6c('0xd')),db=require('../../mysqldb')['db'],{Op,fn,col}=require(_0x141d6c('0x1d')),demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x141d6c('0x23'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x141d6c('0x1f'),'machineUuid':hardware[_0x141d6c('0x3')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]},breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x141d6c('0x23'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x141d6c('0x4'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x4f9bd2){return new Promise(function(_0x3ae57e,_0x114e6d){const _0x426bb2=a845_0x11ea;return db[_0x426bb2('0x1a')]['findOne'](_[_0x426bb2('0x1b')](_0x4f9bd2,{'raw':!![],'where':{'id':0x1}}))['then'](function(_0x581dab){return checkLicense(_0x581dab,null);})[_0x426bb2('0xc')](function(_0x4211e0){_0x3ae57e(_0x4211e0);return;})[_0x426bb2('0x27')](function(_0xb1b59){_0x114e6d(_0xb1b59);});});}function checkLicense(_0x2919e5,_0x7b3504){const _0x318492=_0x141d6c;if(!_0x2919e5)return demoLicense[_0x318492('0x7')]=_0x2919e5['data1'],demoLicense;try{const _0x3318a5=_0x7b3504||_0x2919e5['license'];if(_[_0x318492('0x14')](_0x3318a5))throw new Error('License\x20key\x20value\x20not\x20found');const _0x23c0c1=_0x2919e5[_0x318492('0x10')],_0x261158=_0x2919e5[_0x318492('0x0')],_0x362709=_0x23c0c1[_0x318492('0x8')]('-')[0x4],_0xd651d0=_0x23c0c1['split']('-')[0x0],_0x38c022=encryptor[_0x318492('0x28')](_0x3318a5,util[_0x318492('0x29')](_0x318492('0x11'),_0x362709,_0x23c0c1,_0xd651d0)),_0x4c241a=JSON['parse'](_0x38c022);_0x4c241a[_0x318492('0x16')]=![],_0x4c241a[_0x318492('0x7')]=_0x23c0c1,_0x4c241a[_0x318492('0x24')]=hardware[_0x318492('0x3')]();if(_0x261158){const _0x322500=encryptor['decryptString'](_0x261158);_0x4c241a[_0x318492('0x17')]=_0x322500,_0x4c241a[_0x318492('0x19')]=moment(_0x322500)[_0x318492('0x1e')](0x7,'days')[_0x318492('0x29')](),_0x4c241a['grayReason']=_0x4c241a[_0x318492('0x7')]!=_0x4c241a[_0x318492('0x24')]?_0x318492('0x5'):'disabled';}return _0x4c241a;}catch(_0x5a44a8){return breakingLicense[_0x318492('0x7')]=_0x2919e5['data1'],breakingLicense['message']=_0x5a44a8[_0x318492('0x2')],breakingLicense;}}function getLimits(){return new Promise(function(_0x5c7669,_0x594833){const _0x591ce4=a845_0x11ea;getLicense()[_0x591ce4('0xc')](function(_0x13fee5){const _0x31d2df=_0x591ce4;return db[_0x31d2df('0xf')][_0x31d2df('0x15')]({'attributes':['role',[fn(_0x31d2df('0x26'),col(_0x31d2df('0x21'))),_0x31d2df('0xe')]],'group':_0x31d2df('0x21'),'where':{'role':{[Op['or']]:[_0x31d2df('0x6'),_0x31d2df('0x1'),_0x31d2df('0x1c')]}},'raw':!![]})['then'](function(_0x52801c){const _0x233d12=_0x31d2df,_0x2b6351={'user':_0x13fee5[_0x233d12('0x20')]||0x0,'telephone':_0x13fee5[_0x233d12('0x22')]||0x0};_0x52801c[_0x233d12('0x25')](function(_0x4ab372){const _0x3416fd=_0x233d12,_0x5d8cf2=_0x4ab372[_0x3416fd('0x21')]===_0x3416fd('0x6')?_0x3416fd('0x1'):_0x4ab372[_0x3416fd('0x21')];_0x2b6351[_0x5d8cf2]-=_0x4ab372[_0x3416fd('0xe')];if(_0x2b6351[_0x5d8cf2]<0x0)_0x2b6351[_0x5d8cf2]=0x0;}),_0x5c7669(_0x2b6351);return;});})['catch'](function(_0x2f083e){_0x594833(_0x2f083e);});});}function checkUserLimits(_0x2c4c6e){return new Promise(function(_0x107fd9,_0x111c9f){const _0x1584d3=a845_0x11ea;getLimits()['then'](function(_0x134213){const _0x2d5147=a845_0x11ea,_0x11866b=_[_0x2d5147('0x13')](_[_0x2d5147('0xa')](_0x2c4c6e,_0x2d5147('0x21')),['admin',_0x2d5147('0x1'),'telephone']),_0x4b0ab3=(_0x11866b['admin']||0x0)+(_0x11866b[_0x2d5147('0x1')]||0x0),_0x55bf17=_0x11866b[_0x2d5147('0x1c')]||0x0;if(_0x4b0ab3>_0x134213[_0x2d5147('0x1')])return _0x111c9f('License\x20limit\x20reached\x20for\x20users');if(_0x55bf17>_0x134213[_0x2d5147('0x1c')])return _0x111c9f('License\x20limit\x20reached\x20for\x20telephones');return _0x107fd9();})[_0x1584d3('0x27')](function(_0x4cb025){_0x111c9f(_0x4cb025);});});}module['exports']={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+const a845_0x1849=['add','then','role','demo','exports','data2','defaults','admin','format','Breaking\x20license','moment','../../mysqldb','util','../../components/encryptor','parse','machineUuid','message','License','disabled','telephones','deadline','decryptString','License\x20limit\x20reached\x20for\x20users','Demo\x20license','uuid','findOne','data1','user','countBy','2027-01-01T00:00:00.000Z','count','forEach','%s:%s:%s','isEmpty','catch','User','COUNT','findAll','./hardware','telephone','License\x20key\x20value\x20not\x20found','days','lodash'];(function(_0x3e76c5,_0x184981){const _0x1584a3=function(_0x4e61eb){while(--_0x4e61eb){_0x3e76c5['push'](_0x3e76c5['shift']());}};_0x1584a3(++_0x184981);}(a845_0x1849,0x14c));const a845_0x1584=function(_0x3e76c5,_0x184981){_0x3e76c5=_0x3e76c5-0x0;let _0x1584a3=a845_0x1849[_0x3e76c5];return _0x1584a3;};const _0x431b9e=a845_0x1584;'use strict';const encryptor=require(_0x431b9e('0x19')),util=require(_0x431b9e('0x18')),_=require(_0x431b9e('0xb')),moment=require(_0x431b9e('0x16')),hardware=require(_0x431b9e('0x7')),db=require(_0x431b9e('0x17'))['db'],{Op,fn,col}=require('sequelize'),demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x431b9e('0x29'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x431b9e('0x23'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]},breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x431b9e('0x29'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x431b9e('0x15'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x4e61eb){return new Promise(function(_0x519889,_0x2b5e20){const _0x2b7b8c=a845_0x1584;return db[_0x2b7b8c('0x1d')][_0x2b7b8c('0x25')](_[_0x2b7b8c('0x12')](_0x4e61eb,{'raw':!![],'where':{'id':0x1}}))[_0x2b7b8c('0xd')](function(_0x2ef367){return checkLicense(_0x2ef367,null);})['then'](function(_0x518e9b){_0x519889(_0x518e9b);return;})['catch'](function(_0x48ab64){_0x2b5e20(_0x48ab64);});});}function checkLicense(_0x2a3cf3,_0x55f48a){const _0x408e0b=_0x431b9e;if(!_0x2a3cf3)return demoLicense[_0x408e0b('0x24')]=_0x2a3cf3[_0x408e0b('0x26')],demoLicense;try{const _0x5c2c54=_0x55f48a||_0x2a3cf3['license'];if(_[_0x408e0b('0x2')](_0x5c2c54))throw new Error(_0x408e0b('0x9'));const _0x4f2f13=_0x2a3cf3[_0x408e0b('0x26')],_0x23d7f4=_0x2a3cf3[_0x408e0b('0x11')],_0xf67dcf=_0x4f2f13['split']('-')[0x4],_0x5499f5=_0x4f2f13['split']('-')[0x0],_0x14d79e=encryptor[_0x408e0b('0x21')](_0x5c2c54,util[_0x408e0b('0x14')](_0x408e0b('0x1'),_0xf67dcf,_0x4f2f13,_0x5499f5)),_0xb7a8a0=JSON[_0x408e0b('0x1a')](_0x14d79e);_0xb7a8a0[_0x408e0b('0xf')]=![],_0xb7a8a0[_0x408e0b('0x24')]=_0x4f2f13,_0xb7a8a0[_0x408e0b('0x1b')]=hardware['getUuid']();if(_0x23d7f4){const _0x5960c8=encryptor[_0x408e0b('0x21')](_0x23d7f4);_0xb7a8a0['gray']=_0x5960c8,_0xb7a8a0[_0x408e0b('0x20')]=moment(_0x5960c8)[_0x408e0b('0xc')](0x7,_0x408e0b('0xa'))[_0x408e0b('0x14')](),_0xb7a8a0['grayReason']=_0xb7a8a0['uuid']!=_0xb7a8a0[_0x408e0b('0x1b')]?'changed':_0x408e0b('0x1e');}return _0xb7a8a0;}catch(_0x3abee1){return breakingLicense[_0x408e0b('0x24')]=_0x2a3cf3[_0x408e0b('0x26')],breakingLicense[_0x408e0b('0x1c')]=_0x3abee1[_0x408e0b('0x1c')],breakingLicense;}}function getLimits(){return new Promise(function(_0x3ce7d2,_0x172d39){const _0x2a37b0=a845_0x1584;getLicense()[_0x2a37b0('0xd')](function(_0x3426f6){const _0x1ae6ee=_0x2a37b0;return db[_0x1ae6ee('0x4')][_0x1ae6ee('0x6')]({'attributes':[_0x1ae6ee('0xe'),[fn(_0x1ae6ee('0x5'),col(_0x1ae6ee('0xe'))),_0x1ae6ee('0x2a')]],'group':_0x1ae6ee('0xe'),'where':{'role':{[Op['or']]:[_0x1ae6ee('0x13'),'user',_0x1ae6ee('0x8')]}},'raw':!![]})[_0x1ae6ee('0xd')](function(_0x4ec949){const _0x3bbbce=_0x1ae6ee,_0x246b0e={'user':_0x3426f6['users']||0x0,'telephone':_0x3426f6[_0x3bbbce('0x1f')]||0x0};_0x4ec949[_0x3bbbce('0x0')](function(_0x449277){const _0x98dca9=_0x3bbbce,_0x7937e9=_0x449277[_0x98dca9('0xe')]===_0x98dca9('0x13')?_0x98dca9('0x27'):_0x449277[_0x98dca9('0xe')];_0x246b0e[_0x7937e9]-=_0x449277[_0x98dca9('0x2a')];if(_0x246b0e[_0x7937e9]<0x0)_0x246b0e[_0x7937e9]=0x0;}),_0x3ce7d2(_0x246b0e);return;});})[_0x2a37b0('0x3')](function(_0x4a6a18){_0x172d39(_0x4a6a18);});});}function checkUserLimits(_0x195f58){return new Promise(function(_0x133a35,_0x588e9e){const _0x4ed01b=a845_0x1584;getLimits()[_0x4ed01b('0xd')](function(_0x326ff0){const _0x585e8a=_0x4ed01b,_0x100d97=_['pick'](_[_0x585e8a('0x28')](_0x195f58,_0x585e8a('0xe')),['admin',_0x585e8a('0x27'),'telephone']),_0x43a70e=(_0x100d97[_0x585e8a('0x13')]||0x0)+(_0x100d97[_0x585e8a('0x27')]||0x0),_0x50591b=_0x100d97['telephone']||0x0;if(_0x43a70e>_0x326ff0[_0x585e8a('0x27')])return _0x588e9e(_0x585e8a('0x22'));if(_0x50591b>_0x326ff0['telephone'])return _0x588e9e('License\x20limit\x20reached\x20for\x20telephones');return _0x133a35();})[_0x4ed01b('0x3')](function(_0x7d2b76){_0x588e9e(_0x7d2b76);});});}module[_0x431b9e('0x10')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file