Built motion from commit 129fb4d95212661e48f0db455e75d668addbaddf. Version 3.0.0...
[motion-next.git] / server / config / license / util.js
index 6763145..32c653b 100644 (file)
@@ -1 +1 @@
-const a844_0x1c81=['License\x20limit\x20reached\x20for\x20telephones','License','sequelize','../../components/encryptor','machineUuid','COUNT','forEach','days','users','telephones','disabled','demo','./hardware','telephone','split','exports','License\x20key\x20value\x20not\x20found','count','message','../../mysqldb','uuid','moment','defaults','Breaking\x20license','add','isEmpty','2027-01-01T00:00:00.000Z','role','user','gray','parse','decryptString','format','admin','then','getUuid','findOne','%s:%s:%s','findAll','User','catch','grayReason','data2','data1','Demo\x20license','lodash'];(function(_0x40597c,_0x1c816c){const _0x41f66a=function(_0x1a6a88){while(--_0x1a6a88){_0x40597c['push'](_0x40597c['shift']());}};_0x41f66a(++_0x1c816c);}(a844_0x1c81,0xc3));const a844_0x41f6=function(_0x40597c,_0x1c816c){_0x40597c=_0x40597c-0x0;let _0x41f66a=a844_0x1c81[_0x40597c];return _0x41f66a;};const _0x185e29=a844_0x41f6;'use strict';const encryptor=require(_0x185e29('0x26')),util=require('util'),_=require(_0x185e29('0x22')),moment=require(_0x185e29('0xa')),hardware=require(_0x185e29('0x1')),db=require(_0x185e29('0x8'))['db'],{Op,fn,col}=require(_0x185e29('0x25')),demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x185e29('0xf'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x185e29('0x21'),'machineUuid':hardware[_0x185e29('0x18')](),'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':_0x185e29('0xc'),'machineUuid':hardware[_0x185e29('0x18')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x1a6a88){return new Promise(function(_0x2ee18a,_0x4c77f8){const _0x30c47a=a844_0x41f6;return db[_0x30c47a('0x24')][_0x30c47a('0x19')](_[_0x30c47a('0xb')](_0x1a6a88,{'raw':!![],'where':{'id':0x1}}))[_0x30c47a('0x17')](function(_0x71f91b){return checkLicense(_0x71f91b,null);})[_0x30c47a('0x17')](function(_0x46b43b){_0x2ee18a(_0x46b43b);return;})[_0x30c47a('0x1d')](function(_0x106680){_0x4c77f8(_0x106680);});});}function checkLicense(_0x2ab351,_0xab9e22){const _0x51f029=_0x185e29;if(!_0x2ab351)return demoLicense[_0x51f029('0x9')]=_0x2ab351[_0x51f029('0x20')],demoLicense;try{const _0x3e98c8=_0xab9e22||_0x2ab351['license'];if(_[_0x51f029('0xe')](_0x3e98c8))throw new Error(_0x51f029('0x5'));const _0x2f27a7=_0x2ab351[_0x51f029('0x20')],_0x2c2304=_0x2ab351[_0x51f029('0x1f')],_0x15b46f=_0x2f27a7[_0x51f029('0x3')]('-')[0x4],_0x50ae4b=_0x2f27a7[_0x51f029('0x3')]('-')[0x0],_0x50dd01=encryptor[_0x51f029('0x14')](_0x3e98c8,util[_0x51f029('0x15')](_0x51f029('0x1a'),_0x15b46f,_0x2f27a7,_0x50ae4b)),_0x3621e8=JSON[_0x51f029('0x13')](_0x50dd01);_0x3621e8[_0x51f029('0x0')]=![],_0x3621e8[_0x51f029('0x9')]=_0x2f27a7,_0x3621e8[_0x51f029('0x27')]=hardware[_0x51f029('0x18')]();if(_0x2c2304){const _0x142573=encryptor['decryptString'](_0x2c2304);_0x3621e8[_0x51f029('0x12')]=_0x142573,_0x3621e8['deadline']=moment(_0x142573)[_0x51f029('0xd')](0x7,_0x51f029('0x2a'))['format'](),_0x3621e8[_0x51f029('0x1e')]=_0x3621e8[_0x51f029('0x9')]!=_0x3621e8[_0x51f029('0x27')]?'changed':_0x51f029('0x2d');}return _0x3621e8;}catch(_0x189ea2){return breakingLicense['uuid']=_0x2ab351[_0x51f029('0x20')],breakingLicense[_0x51f029('0x7')]=_0x189ea2['message'],breakingLicense;}}function getLimits(){return new Promise(function(_0x127ed3,_0x2139f4){const _0xc321da=a844_0x41f6;getLicense()[_0xc321da('0x17')](function(_0x1c24cc){const _0x347a17=_0xc321da;return db[_0x347a17('0x1c')][_0x347a17('0x1b')]({'attributes':[_0x347a17('0x10'),[fn(_0x347a17('0x28'),col(_0x347a17('0x10'))),_0x347a17('0x6')]],'group':_0x347a17('0x10'),'where':{'role':{[Op['or']]:[_0x347a17('0x16'),_0x347a17('0x11'),_0x347a17('0x2')]}},'raw':!![]})[_0x347a17('0x17')](function(_0x1e232a){const _0x363399=_0x347a17,_0x141e6c={'user':_0x1c24cc[_0x363399('0x2b')]||0x0,'telephone':_0x1c24cc[_0x363399('0x2c')]||0x0};_0x1e232a[_0x363399('0x29')](function(_0x595dad){const _0x2e977b=_0x363399,_0x413521=_0x595dad[_0x2e977b('0x10')]==='admin'?_0x2e977b('0x11'):_0x595dad[_0x2e977b('0x10')];_0x141e6c[_0x413521]-=_0x595dad[_0x2e977b('0x6')];if(_0x141e6c[_0x413521]<0x0)_0x141e6c[_0x413521]=0x0;}),_0x127ed3(_0x141e6c);return;});})[_0xc321da('0x1d')](function(_0x2acbe6){_0x2139f4(_0x2acbe6);});});}function checkUserLimits(_0x2b8ba3){return new Promise(function(_0x2f2efe,_0x3b003f){const _0x4cc723=a844_0x41f6;getLimits()[_0x4cc723('0x17')](function(_0x24d138){const _0x151f05=_0x4cc723,_0xe1f95=_['pick'](_['countBy'](_0x2b8ba3,_0x151f05('0x10')),[_0x151f05('0x16'),_0x151f05('0x11'),_0x151f05('0x2')]),_0x39272f=(_0xe1f95[_0x151f05('0x16')]||0x0)+(_0xe1f95[_0x151f05('0x11')]||0x0),_0x2f68e5=_0xe1f95[_0x151f05('0x2')]||0x0;if(_0x39272f>_0x24d138[_0x151f05('0x11')])return _0x3b003f('License\x20limit\x20reached\x20for\x20users');if(_0x2f68e5>_0x24d138['telephone'])return _0x3b003f(_0x151f05('0x23'));return _0x2f2efe();})['catch'](function(_0x45369e){_0x3b003f(_0x45369e);});});}module[_0x185e29('0x4')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+const a1006_0x578b=['COUNT','message','License\x20limit\x20reached\x20for\x20telephones','users','exports','days','split','telephone','sequelize','countBy','telephones','admin','data1','catch','moment','../../mysqldb','license','decryptString','demo','count','Breaking\x20license','pick','findOne','uuid','role','User','findAll','Demo\x20license','changed','../../components/encryptor','machineUuid','disabled','defaults','isEmpty','getUuid','user','lodash','grayReason','2027-01-01T00:00:00.000Z','then','format','getLicense'];(function(_0x947d88,_0x15cadd){const _0x578bdc=function(_0x3974b4){while(--_0x3974b4){_0x947d88['push'](_0x947d88['shift']());}};_0x578bdc(++_0x15cadd);}(a1006_0x578b,0x119));const a1006_0x3974=function(_0x947d88,_0x15cadd){_0x947d88=_0x947d88-0xf3;let _0x578bdc=a1006_0x578b[_0x947d88];return _0x578bdc;};const a1006_0x4835cd=a1006_0x3974;'use strict';const encryptor=require(a1006_0x4835cd(0xf3)),util=require('util'),_=require(a1006_0x4835cd(0xfa)),moment=require(a1006_0x4835cd(0x10e)),hardware=require('./hardware'),{db}=require(a1006_0x4835cd(0x10f)),{Op,fn,col}=require(a1006_0x4835cd(0x108)),demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':a1006_0x4835cd(0xfc),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':a1006_0x4835cd(0x11b),'machineUuid':hardware['getUuid'](),'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':a1006_0x4835cd(0x114),'machineUuid':hardware[a1006_0x4835cd(0xf8)](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x4dc4ad){return new Promise(function(_0x22374c,_0x2ba441){const _0x554662=a1006_0x3974;return db['License'][_0x554662(0x116)](_[_0x554662(0xf6)](_0x4dc4ad,{'raw':!![],'where':{'id':0x1}}))[_0x554662(0xfd)](function(_0x29a203){return checkLicense(_0x29a203,null);})[_0x554662(0xfd)](function(_0x1eb88d){_0x22374c(_0x1eb88d);return;})['catch'](function(_0x1c39d4){_0x2ba441(_0x1c39d4);});});}function checkLicense(_0x5a2a97,_0x4b5751){const _0x2c800a=a1006_0x4835cd;if(!_0x5a2a97)return demoLicense['uuid']=_0x5a2a97[_0x2c800a(0x10c)],demoLicense;try{const _0x256df2=_0x4b5751||_0x5a2a97[_0x2c800a(0x110)];if(_[_0x2c800a(0xf7)](_0x256df2))throw new Error('License\x20key\x20value\x20not\x20found');const _0x55f511=_0x5a2a97[_0x2c800a(0x10c)],_0x44ea29=_0x5a2a97['data2'],_0x229c96=_0x55f511['split']('-')[0x4],_0x2810e9=_0x55f511[_0x2c800a(0x106)]('-')[0x0],_0x54c797=encryptor[_0x2c800a(0x111)](_0x256df2,util[_0x2c800a(0xfe)]('%s:%s:%s',_0x229c96,_0x55f511,_0x2810e9)),_0x1384e9=JSON['parse'](_0x54c797);_0x1384e9[_0x2c800a(0x112)]=![],_0x1384e9['uuid']=_0x55f511,_0x1384e9[_0x2c800a(0xf4)]=hardware['getUuid']();if(_0x44ea29){const _0x58f9fa=encryptor[_0x2c800a(0x111)](_0x44ea29);_0x1384e9['gray']=_0x58f9fa,_0x1384e9['deadline']=moment(_0x58f9fa)['add'](0x7,_0x2c800a(0x105))[_0x2c800a(0xfe)](),_0x1384e9[_0x2c800a(0xfb)]=_0x1384e9[_0x2c800a(0x117)]!=_0x1384e9[_0x2c800a(0xf4)]?_0x2c800a(0x11c):_0x2c800a(0xf5);}return _0x1384e9;}catch(_0x3db077){return breakingLicense[_0x2c800a(0x117)]=_0x5a2a97[_0x2c800a(0x10c)],breakingLicense[_0x2c800a(0x101)]=_0x3db077[_0x2c800a(0x101)],breakingLicense;}}function getLimits(){return new Promise(function(_0x9e4807,_0x3d39da){const _0x3a5fb7=a1006_0x3974;getLicense()[_0x3a5fb7(0xfd)](function(_0xb34ebb){const _0x1d6a53=_0x3a5fb7;return db[_0x1d6a53(0x119)][_0x1d6a53(0x11a)]({'attributes':['role',[fn(_0x1d6a53(0x100),col(_0x1d6a53(0x118))),_0x1d6a53(0x113)]],'group':_0x1d6a53(0x118),'where':{'role':{[Op['or']]:[_0x1d6a53(0x10b),_0x1d6a53(0xf9),'telephone']}},'raw':!![]})['then'](function(_0x165a36){const _0x1c062e=_0x1d6a53,_0x540666={'user':_0xb34ebb[_0x1c062e(0x103)]||0x0,'telephone':_0xb34ebb[_0x1c062e(0x10a)]||0x0};_0x165a36['forEach'](function(_0x17757c){const _0x360537=_0x1c062e,_0x54c2fd=_0x17757c[_0x360537(0x118)]===_0x360537(0x10b)?_0x360537(0xf9):_0x17757c[_0x360537(0x118)];_0x540666[_0x54c2fd]-=_0x17757c[_0x360537(0x113)];if(_0x540666[_0x54c2fd]<0x0)_0x540666[_0x54c2fd]=0x0;}),_0x9e4807(_0x540666);return;});})[_0x3a5fb7(0x10d)](function(_0x1f6390){_0x3d39da(_0x1f6390);});});}function checkUserLimits(_0x3ea18b){return new Promise(function(_0x5010a5,_0x4c1351){const _0x24f621=a1006_0x3974;getLimits()[_0x24f621(0xfd)](function(_0xd7a58){const _0x623a46=_0x24f621,_0x5609e8=_[_0x623a46(0x115)](_[_0x623a46(0x109)](_0x3ea18b,_0x623a46(0x118)),[_0x623a46(0x10b),'user','telephone']),_0x47f236=(_0x5609e8[_0x623a46(0x10b)]||0x0)+(_0x5609e8[_0x623a46(0xf9)]||0x0),_0x622f1=_0x5609e8[_0x623a46(0x107)]||0x0;if(_0x47f236>_0xd7a58[_0x623a46(0xf9)])return _0x4c1351('License\x20limit\x20reached\x20for\x20users');if(_0x622f1>_0xd7a58[_0x623a46(0x107)])return _0x4c1351(_0x623a46(0x102));return _0x5010a5();})[_0x24f621(0x10d)](function(_0x3baef7){_0x4c1351(_0x3baef7);});});}module[a1006_0x4835cd(0x104)]['checkLicense']=checkLicense,module[a1006_0x4835cd(0x104)]['checkUserLimits']=checkUserLimits,module['exports'][a1006_0x4835cd(0xff)]=getLicense;
\ No newline at end of file