ba2876168c7cea6cd0a56a8b415dda3d8f71366a
[motion.git] / server / config / license / license.service.js
1 var _0x4029=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x63\x6F\x6D\x70\x6F\x73\x61\x62\x6C\x65\x2D\x6D\x69\x64\x64\x6C\x65\x77\x61\x72\x65","\x6D\x6F\x6D\x65\x6E\x74","\x63\x72\x79\x70\x74\x6F","\x75\x74\x69\x6C","\x6F\x73","\x65\x78\x65\x63\x53\x79\x6E\x63","\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73","\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x54\x65\x6C\x65\x70\x68\x6F\x6E\x65","\x53\x65\x74\x74\x69\x6E\x67\x73","\x4C\x69\x63\x65\x6E\x73\x65","\x44\x45\x4D\x4F\x20\x4C\x49\x43\x45\x4E\x53\x45","\x0D\x0A","","\x72\x65\x70\x6C\x61\x63\x65","\x64\x6D\x69\x64\x65\x63\x6F\x64\x65\x20\x2D\x2D\x73\x74\x72\x69\x6E\x67\x20\x73\x79\x73\x74\x65\x6D\x2D\x75\x75\x69\x64","\x75\x74\x66\x38","\x77\x69\x6E\x33\x32","\x2E\x2F\x68\x61\x72\x64\x77\x61\x72\x65","\x70\x6C\x61\x74\x66\x6F\x72\x6D","\x63\x61\x74\x63\x68","\x6C\x69\x63\x65\x6E\x73\x65","\x70\x61\x72\x73\x65","\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x73\x70\x72\x65\x61\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x75\x73\x65","\x63\x68\x61\x74","\x6D\x65\x73\x73\x61\x67\x69\x6E\x67","\x63\x6D","\x75\x70\x64\x61\x74\x65","\x6D\x61\x69\x6C","\x66\x61\x78","\x6A\x73\x63\x72\x69\x70\x74\x79","\x63\x75\x73\x74\x6F\x6D","\x6F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C","\x65\x78\x70\x69\x72\x61\x74\x69\x6F\x6E","\x69\x73\x53\x61\x6D\x65\x4F\x72\x42\x65\x66\x6F\x72\x65","\x75\x73\x65\x72\x73","\x4D\x61\x78\x69\x6D\x75\x6D\x20\x75\x73\x65\x72\x73\x20\x6C\x69\x6D\x69\x74\x20\x68\x61\x76\x65\x20\x62\x65\x65\x6E\x20\x72\x65\x61\x63\x68\x65\x64","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x61\x64\x6D\x69\x6E","\x75\x73\x65\x72","\x63\x6F\x75\x6E\x74","\x74\x65\x6C\x65\x70\x68\x6F\x6E\x65\x73","\x4D\x61\x78\x69\x6D\x75\x6D\x20\x74\x65\x6C\x65\x70\x68\x6F\x6E\x65\x73\x20\x6C\x69\x6D\x69\x74\x20\x68\x61\x76\x65\x20\x62\x65\x65\x6E\x20\x72\x65\x61\x63\x68\x65\x64","\x74\x65\x6C\x65\x70\x68\x6F\x6E\x65","\x72\x6F\x6C\x65","\x61\x67\x65\x6E\x74","\x6F\x6E\x6C\x69\x6E\x65","\x61\x67\x65\x6E\x74\x73","\x2D","\x73\x70\x6C\x69\x74","\x61\x65\x73\x2D\x32\x35\x36\x2D\x63\x74\x72","\x25\x73\x3A\x25\x73\x3A\x25\x73","\x66\x6F\x72\x6D\x61\x74","\x63\x72\x65\x61\x74\x65\x44\x65\x63\x69\x70\x68\x65\x72","\x62\x61\x73\x65\x36\x34","\x66\x69\x6E\x61\x6C","\x67\x65\x74\x55\x75\x69\x64","\x69\x73\x56\x61\x6C\x69\x64\x44\x61\x74\x65","\x69\x73\x55\x73\x65\x72\x73\x4C\x69\x6D\x69\x74","\x69\x73\x54\x65\x6C\x65\x70\x68\x6F\x6E\x65\x73\x4C\x69\x6D\x69\x74","\x68\x61\x73\x43\x68\x61\x74","\x68\x61\x73\x4D\x61\x69\x6C","\x68\x61\x73\x46\x61\x78","\x68\x61\x73\x4F\x70\x65\x6E\x63\x68\x61\x6E\x6E\x65\x6C","\x68\x61\x73\x53\x6D\x73","\x68\x61\x73\x4A\x73\x63\x72\x69\x70\x74\x79","\x68\x61\x73\x43\x6D","\x68\x61\x73\x55\x70\x64\x61\x74\x65","\x69\x73\x56\x61\x6C\x69\x64\x41\x67\x65\x6E\x74","\x64\x65\x6D\x6F\x4C\x69\x63\x65\x6E\x73\x65","\x64\x65\x63\x72\x79\x70\x74"];_0x4029[0];var compose=require(_0x4029[1]);var moment=require(_0x4029[2]);var crypto=require(_0x4029[3]);var util=require(_0x4029[4]);var os=require(_0x4029[5]);var exec=require(_0x4029[7])[_0x4029[6]];var config=require(_0x4029[8]);var User=require(_0x4029[10])[_0x4029[9]];var Telephone=require(_0x4029[10])[_0x4029[11]];var Settings=require(_0x4029[10])[_0x4029[12]];var License=require(_0x4029[10])[_0x4029[13]];var demoLicense={users:1,agents:1,telephones:0,chat:false,mail:false,fax:false,jscripty:false,messaging:false,openchannel:false,custom:false,description:_0x4029[14]};function getUuid(){switch(os[_0x4029[22]]()){case _0x4029[20]:return exec(_0x4029[18],{encoding:_0x4029[19]})[_0x4029[17]](_0x4029[15],_0x4029[16]);default:return require(_0x4029[21])(true)}}function checkLicense(_0x5e98xf){return compose()[_0x4029[31]](function(_0x5e98x10,_0x5e98x11,_0x5e98x12){return License[_0x4029[30]]({where:{id:1}})[_0x4029[29]](function(_0x5e98x14){var _0x5e98x15=null,_0x5e98x16=false;try{if(_0x5e98x14[_0x4029[24]]){_0x5e98x15= decrypt(_0x5e98x14[_0x4029[24]]);_0x5e98x15= JSON[_0x4029[25]](_0x5e98x15)}else {_0x5e98x15= demoLicense}}catch(err){console[_0x4029[27]](_0x4029[26],err);_0x5e98x15= demoLicense};_0x5e98x16= _0x5e98x15[_0x5e98xf];if(!_0x5e98x16){return _0x5e98x11[_0x4029[28]](403)};return _0x5e98x12()})[_0x4029[23]](function(_0x5e98x13){return _0x5e98x12(_0x5e98x13)})})}function hasChat(){return checkLicense(_0x4029[32])}function hasSms(){return checkLicense(_0x4029[33])}function hasCm(){return checkLicense(_0x4029[34])}function hasUpdate(){return checkLicense(_0x4029[35])}function hasMail(){return checkLicense(_0x4029[36])}function hasFax(){return checkLicense(_0x4029[37])}function hasJscripty(){return checkLicense(_0x4029[38])}function hasCustom(){return checkLicense(_0x4029[39])}function hasOpenchannel(){return checkLicense(_0x4029[40])}function isValidDate(){return compose()[_0x4029[31]](function(_0x5e98x10,_0x5e98x11,_0x5e98x12){return License[_0x4029[30]]({where:{id:1}})[_0x4029[29]](function(_0x5e98x14){var _0x5e98x15=null,_0x5e98x21=false;try{if(_0x5e98x14[_0x4029[24]]){_0x5e98x15= decrypt(_0x5e98x14[_0x4029[24]]);_0x5e98x15= JSON[_0x4029[25]](_0x5e98x15);if(moment()[_0x4029[42]](_0x5e98x15[_0x4029[41]])){_0x5e98x21= true}}}catch(err){console[_0x4029[27]](_0x4029[26],err)};if(!_0x5e98x21){return _0x5e98x11[_0x4029[28]](403)};return _0x5e98x12()})[_0x4029[23]](function(_0x5e98x13){return _0x5e98x12(_0x5e98x13)})})}function isUsersLimit(){return compose()[_0x4029[31]](function(_0x5e98x10,_0x5e98x11,_0x5e98x12){var _0x5e98x14;return License[_0x4029[30]]({where:{id:1}})[_0x4029[29]](function(_0x5e98x25){_0x5e98x14= _0x5e98x25;return User[_0x4029[50]]({where:{$or:[{role:_0x4029[48]},{role:_0x4029[49]}]}})})[_0x4029[47]](function(_0x5e98x23){var _0x5e98x15=null,_0x5e98x24=false;try{if(_0x5e98x14[_0x4029[24]]){_0x5e98x15= decrypt(_0x5e98x14[_0x4029[24]]);_0x5e98x15= JSON[_0x4029[25]](_0x5e98x15)}else {_0x5e98x15= demoLicense}}catch(err){console[_0x4029[27]](_0x4029[26],err);_0x5e98x15= demoLicense};if(_0x5e98x15[_0x4029[43]]> _0x5e98x23){_0x5e98x24= true};if(!_0x5e98x24){return _0x5e98x11[_0x4029[46]](403)[_0x4029[45]]({message:_0x4029[44]})};return _0x5e98x12()})[_0x4029[23]](function(_0x5e98x13){return _0x5e98x12(_0x5e98x13)})})}function isTelephonesLimit(){return compose()[_0x4029[31]](function(_0x5e98x10,_0x5e98x11,_0x5e98x12){var _0x5e98x14;return License[_0x4029[30]]({where:{id:1}})[_0x4029[29]](function(_0x5e98x25){_0x5e98x14= _0x5e98x25;return User[_0x4029[50]]({where:{role:_0x4029[53]}})})[_0x4029[47]](function(_0x5e98x27){var _0x5e98x15=null,_0x5e98x24=false;try{if(_0x5e98x14[_0x4029[24]]){_0x5e98x15= decrypt(_0x5e98x14[_0x4029[24]]);_0x5e98x15= JSON[_0x4029[25]](_0x5e98x15)}else {_0x5e98x15= demoLicense}}catch(err){console[_0x4029[27]](_0x4029[26],err);_0x5e98x15= demoLicense};if(_0x5e98x15[_0x4029[51]]> _0x5e98x27){_0x5e98x24= true};if(!_0x5e98x24){return _0x5e98x11[_0x4029[46]](403)[_0x4029[45]]({message:_0x4029[52]})};return _0x5e98x12()})[_0x4029[23]](function(_0x5e98x13){return _0x5e98x12(_0x5e98x13)})})}function isValidAgent(){return function(_0x5e98x29){var _0x5e98x14;var _0x5e98x2a=false;if(_0x5e98x29[_0x4029[54]]=== _0x4029[48]|| _0x5e98x29[_0x4029[54]]=== _0x4029[49]|| (_0x5e98x29[_0x4029[54]]=== _0x4029[55]&& _0x5e98x29[_0x4029[56]])){_0x5e98x2a= true};return License[_0x4029[30]]({where:{id:1}})[_0x4029[29]](function(_0x5e98x25){_0x5e98x14= _0x5e98x25;return User[_0x4029[50]]({where:{role:_0x4029[55],online:true}})})[_0x4029[47]](function(_0x5e98x2b){var _0x5e98x15=null;try{if(_0x5e98x14[_0x4029[24]]){_0x5e98x15= decrypt(_0x5e98x14[_0x4029[24]]);_0x5e98x15= JSON[_0x4029[25]](_0x5e98x15)}else {_0x5e98x15= demoLicense}}catch(err){console[_0x4029[27]](_0x4029[26],err);_0x5e98x15= demoLicense};if(_0x5e98x15[_0x4029[57]]> _0x5e98x2b){_0x5e98x2a= true};return _0x5e98x2a})}}function decrypt(_0x5e98x2d){var _0x5e98x2e=getUuid();var _0x5e98x2f=_0x5e98x2e[_0x4029[59]](_0x4029[58])[4];var _0x5e98x30=_0x5e98x2e[_0x4029[59]](_0x4029[58])[0];var _0x5e98x31=crypto[_0x4029[63]](_0x4029[60],util[_0x4029[62]](_0x4029[61],_0x5e98x2f,_0x5e98x2e,_0x5e98x30));var _0x5e98x14=_0x5e98x31[_0x4029[35]](_0x5e98x2d,_0x4029[64],_0x4029[19]);_0x5e98x14+= _0x5e98x31[_0x4029[65]](_0x4029[19]);return _0x5e98x14}exports[_0x4029[66]]= getUuid;exports[_0x4029[67]]= isValidDate;exports[_0x4029[68]]= isUsersLimit;exports[_0x4029[69]]= isTelephonesLimit;exports[_0x4029[70]]= hasChat;exports[_0x4029[71]]= hasMail;exports[_0x4029[72]]= hasFax;exports[_0x4029[73]]= hasOpenchannel;exports[_0x4029[74]]= hasSms;exports[_0x4029[75]]= hasJscripty;exports[_0x4029[76]]= hasCm;exports[_0x4029[77]]= hasUpdate;exports[_0x4029[78]]= isValidAgent;exports[_0x4029[79]]= demoLicense;exports[_0x4029[80]]= decrypt