Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / config / license / util.js
index 62bfab3..47dda0d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8683=['License\x20key\x20value\x20not\x20found','data2','split','%s:%s:%s','parse','demo','uuid','decryptString','deadline','add','format','grayReason','machineUuid','changed','disabled','message','User','role','COUNT','col','count','admin','user','telephone','users','telephones','forEach','pick','countBy','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash','moment','./hardware','../../mysqldb','2027-01-01T00:00:00.000Z','Demo\x20license','Breaking\x20license','getUuid','find','defaults','then','catch','data1','isEmpty'];(function(_0x2080a3,_0x48acfa){var _0x8d7d17=function(_0x2dbc06){while(--_0x2dbc06){_0x2080a3['push'](_0x2080a3['shift']());}};_0x8d7d17(++_0x48acfa);}(_0x8683,0x1eb));var _0x3868=function(_0x2b4411,_0x2625ed){_0x2b4411=_0x2b4411-0x0;var _0x8e41ef=_0x8683[_0x2b4411];return _0x8e41ef;};'use strict';var util=require(_0x3868('0x0'));var _=require(_0x3868('0x1'));var moment=require(_0x3868('0x2'));var BPromise=require('bluebird');var hardware=require(_0x3868('0x3'));var encryptor=require('../../components/encryptor');var db=require(_0x3868('0x4'))['db'];const demoLicense={'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x3868('0x5'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0x3868('0x6'),'machineUuid':hardware['getUuid'](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0x3868('0x5'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0x3868('0x7'),'machineUuid':hardware[_0x3868('0x8')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x18790e){return new BPromise(function(_0x52f4e6,_0x3f7430){return db['License'][_0x3868('0x9')](_[_0x3868('0xa')](_0x18790e,{'raw':!![],'where':{'id':0x1}}))[_0x3868('0xb')](function(_0x137681){return checkLicense(_0x137681,null);})[_0x3868('0xb')](function(_0x513b2f){_0x52f4e6(_0x513b2f);return;})[_0x3868('0xc')](function(_0x4f4c8d){_0x3f7430(_0x4f4c8d);});});}function checkLicense(_0x1b7113,_0x3d66b7){if(!_0x1b7113){demoLicense['uuid']=_0x1b7113[_0x3868('0xd')];return demoLicense;}try{var _0x23e99c=_0x3d66b7||_0x1b7113['license'];if(_[_0x3868('0xe')](_0x23e99c)){throw new Error(_0x3868('0xf'));}var _0x286215=_0x1b7113[_0x3868('0xd')];var _0x1d6e65=_0x1b7113[_0x3868('0x10')];var _0x25c301=_0x286215[_0x3868('0x11')]('-')[0x4];var _0x31f374=_0x286215[_0x3868('0x11')]('-')[0x0];var _0x12ce6c=encryptor['decryptString'](_0x23e99c,util['format'](_0x3868('0x12'),_0x25c301,_0x286215,_0x31f374));var _0x15d930=JSON[_0x3868('0x13')](_0x12ce6c);_0x15d930[_0x3868('0x14')]=![];_0x15d930[_0x3868('0x15')]=_0x286215;_0x15d930['machineUuid']=hardware[_0x3868('0x8')]();if(_0x1d6e65){var _0x13c8b0=encryptor[_0x3868('0x16')](_0x1d6e65);_0x15d930['gray']=_0x13c8b0;_0x15d930[_0x3868('0x17')]=moment(_0x13c8b0)[_0x3868('0x18')](0x7,'days')[_0x3868('0x19')]();_0x15d930[_0x3868('0x1a')]=_0x15d930[_0x3868('0x15')]!=_0x15d930[_0x3868('0x1b')]?_0x3868('0x1c'):_0x3868('0x1d');}return _0x15d930;}catch(_0x2ee7c1){breakingLicense[_0x3868('0x15')]=_0x1b7113[_0x3868('0xd')];breakingLicense[_0x3868('0x1e')]=_0x2ee7c1['message'];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x121ead,_0x225969){getLicense()['then'](function(_0x10a3bb){return db[_0x3868('0x1f')]['findAll']({'attributes':[_0x3868('0x20'),[db['sequelize']['fn'](_0x3868('0x21'),db['sequelize'][_0x3868('0x22')](_0x3868('0x20'))),_0x3868('0x23')]],'group':'role','where':{'role':{'$or':[_0x3868('0x24'),_0x3868('0x25'),_0x3868('0x26')]}},'raw':!![]})[_0x3868('0xb')](function(_0x285186){var _0x2f28fd={'user':_0x10a3bb[_0x3868('0x27')]||0x0,'telephone':_0x10a3bb[_0x3868('0x28')]||0x0};_0x285186[_0x3868('0x29')](function(_0x40e349){var _0x4c57b0=_0x40e349[_0x3868('0x20')]===_0x3868('0x24')?_0x3868('0x25'):_0x40e349['role'];_0x2f28fd[_0x4c57b0]-=_0x40e349[_0x3868('0x23')];if(_0x2f28fd[_0x4c57b0]<0x0)_0x2f28fd[_0x4c57b0]=0x0;});_0x121ead(_0x2f28fd);return;});})[_0x3868('0xc')](function(_0x8e84b9){_0x225969(_0x8e84b9);});});}function checkUserLimits(_0x799f66){return new BPromise(function(_0xf36096,_0x52fa79){getLimits()[_0x3868('0xb')](function(_0x217786){var _0x48ab37=_[_0x3868('0x2a')](_[_0x3868('0x2b')](_0x799f66,_0x3868('0x20')),['admin',_0x3868('0x25'),_0x3868('0x26')]);var _0x1b2c81=(_0x48ab37['admin']||0x0)+(_0x48ab37[_0x3868('0x25')]||0x0);var _0x1d8b38=_0x48ab37[_0x3868('0x26')]||0x0;if(_0x1b2c81>_0x217786['user'])return _0x52fa79('License\x20limit\x20reached\x20for\x20users');if(_0x1d8b38>_0x217786['telephone'])return _0x52fa79(_0x3868('0x2c'));return _0xf36096();})['catch'](function(_0x7ac5df){_0x52fa79(_0x7ac5df);});});}module[_0x3868('0x2d')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file
+var _0x953f=['role','sequelize','count','admin','user','telephone','users','telephones','forEach','catch','pick','countBy','License\x20limit\x20reached\x20for\x20users','License\x20limit\x20reached\x20for\x20telephones','exports','util','lodash','moment','bluebird','./hardware','../../components/encryptor','Demo\x20license','getUuid','2027-01-01T00:00:00.000Z','find','defaults','then','uuid','data1','license','data2','split','decryptString','format','%s:%s:%s','parse','demo','machineUuid','gray','deadline','add','days','changed','disabled','message','User','findAll'];(function(_0x3877b5,_0x5794e7){var _0xb5ac48=function(_0x2e4ca6){while(--_0x2e4ca6){_0x3877b5['push'](_0x3877b5['shift']());}};_0xb5ac48(++_0x5794e7);}(_0x953f,0x187));var _0xf953=function(_0x1969a7,_0x5a133a){_0x1969a7=_0x1969a7-0x0;var _0x3d665f=_0x953f[_0x1969a7];return _0x3d665f;};'use strict';var util=require(_0xf953('0x0'));var _=require(_0xf953('0x1'));var moment=require(_0xf953('0x2'));var BPromise=require(_0xf953('0x3'));var hardware=require(_0xf953('0x4'));var encryptor=require(_0xf953('0x5'));var db=require('../../mysqldb')['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':_0xf953('0x6'),'machineUuid':hardware[_0xf953('0x7')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};const breakingLicense={'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0xf953('0x8'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':'Breaking\x20license','machineUuid':hardware[_0xf953('0x7')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};function getLicense(_0x4f12ad){return new BPromise(function(_0x1073b5,_0x2c116a){return db['License'][_0xf953('0x9')](_[_0xf953('0xa')](_0x4f12ad,{'raw':!![],'where':{'id':0x1}}))[_0xf953('0xb')](function(_0x40bbdd){return checkLicense(_0x40bbdd,null);})[_0xf953('0xb')](function(_0x153522){_0x1073b5(_0x153522);return;})['catch'](function(_0x5277ec){_0x2c116a(_0x5277ec);});});}function checkLicense(_0x494666,_0x152b81){if(!_0x494666){demoLicense[_0xf953('0xc')]=_0x494666[_0xf953('0xd')];return demoLicense;}try{var _0x16c5c2=_0x152b81||_0x494666[_0xf953('0xe')];if(_['isEmpty'](_0x16c5c2)){throw new Error('License\x20key\x20value\x20not\x20found');}var _0x412e48=_0x494666[_0xf953('0xd')];var _0xadc1f9=_0x494666[_0xf953('0xf')];var _0x402581=_0x412e48['split']('-')[0x4];var _0x505d2c=_0x412e48[_0xf953('0x10')]('-')[0x0];var _0x1abe59=encryptor[_0xf953('0x11')](_0x16c5c2,util[_0xf953('0x12')](_0xf953('0x13'),_0x402581,_0x412e48,_0x505d2c));var _0x4396c1=JSON[_0xf953('0x14')](_0x1abe59);_0x4396c1[_0xf953('0x15')]=![];_0x4396c1['uuid']=_0x412e48;_0x4396c1[_0xf953('0x16')]=hardware['getUuid']();if(_0xadc1f9){var _0x5e1614=encryptor['decryptString'](_0xadc1f9);_0x4396c1[_0xf953('0x17')]=_0x5e1614;_0x4396c1[_0xf953('0x18')]=moment(_0x5e1614)[_0xf953('0x19')](0x7,_0xf953('0x1a'))[_0xf953('0x12')]();_0x4396c1['grayReason']=_0x4396c1[_0xf953('0xc')]!=_0x4396c1[_0xf953('0x16')]?_0xf953('0x1b'):_0xf953('0x1c');}return _0x4396c1;}catch(_0x13e3ae){breakingLicense[_0xf953('0xc')]=_0x494666[_0xf953('0xd')];breakingLicense[_0xf953('0x1d')]=_0x13e3ae[_0xf953('0x1d')];return breakingLicense;}}function getLimits(){return new BPromise(function(_0x11022d,_0x4026d2){getLicense()[_0xf953('0xb')](function(_0x39321c){return db[_0xf953('0x1e')][_0xf953('0x1f')]({'attributes':[_0xf953('0x20'),[db[_0xf953('0x21')]['fn']('COUNT',db[_0xf953('0x21')]['col'](_0xf953('0x20'))),_0xf953('0x22')]],'group':_0xf953('0x20'),'where':{'role':{'$or':[_0xf953('0x23'),_0xf953('0x24'),_0xf953('0x25')]}},'raw':!![]})['then'](function(_0x2d7bd1){var _0x2c39f7={'user':_0x39321c[_0xf953('0x26')]||0x0,'telephone':_0x39321c[_0xf953('0x27')]||0x0};_0x2d7bd1[_0xf953('0x28')](function(_0x94d7ca){var _0x258cc2=_0x94d7ca[_0xf953('0x20')]===_0xf953('0x23')?_0xf953('0x24'):_0x94d7ca[_0xf953('0x20')];_0x2c39f7[_0x258cc2]-=_0x94d7ca[_0xf953('0x22')];if(_0x2c39f7[_0x258cc2]<0x0)_0x2c39f7[_0x258cc2]=0x0;});_0x11022d(_0x2c39f7);return;});})[_0xf953('0x29')](function(_0xc0ce23){_0x4026d2(_0xc0ce23);});});}function checkUserLimits(_0x48263c){return new BPromise(function(_0x5c6e9c,_0x10a892){getLimits()[_0xf953('0xb')](function(_0x43d5ba){var _0x2cda50=_[_0xf953('0x2a')](_[_0xf953('0x2b')](_0x48263c,_0xf953('0x20')),['admin','user',_0xf953('0x25')]);var _0x39b090=(_0x2cda50[_0xf953('0x23')]||0x0)+(_0x2cda50[_0xf953('0x24')]||0x0);var _0x21bcee=_0x2cda50[_0xf953('0x25')]||0x0;if(_0x39b090>_0x43d5ba['user'])return _0x10a892(_0xf953('0x2c'));if(_0x21bcee>_0x43d5ba[_0xf953('0x25')])return _0x10a892(_0xf953('0x2d'));return _0x5c6e9c();})['catch'](function(_0x3c9afc){_0x10a892(_0x3c9afc);});});}module[_0xf953('0x2e')]={'checkLicense':checkLicense,'checkUserLimits':checkUserLimits,'getLicense':getLicense};
\ No newline at end of file