5014d0451cc5bb2834277e54aa817ba87ffbfa8a
[motion.git] / server / config / license / license.service.js
1 var _0x1ee9=["\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","\x6D\x6F\x74\x69\x6F\x6E","\x2E\x2E\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\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","\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","\x64\x61\x74\x61\x31","\x70\x61\x72\x73\x65","\x64\x65\x6D\x6F","\x4C\x69\x63\x65\x6E\x73\x65\x20\x63\x68\x65\x63\x6B\x20\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\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","\x4C\x69\x63\x65\x6E\x73\x65\x20\x64\x61\x74\x65\x20\x63\x68\x65\x63\x6B\x20\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\x69\x6E\x66\x6F","\x4C\x69\x63\x65\x6E\x73\x65\x20\x75\x73\x65\x72\x73\x20\x6C\x69\x6D\x69\x74\x20\x63\x68\x65\x63\x6B\x20\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\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","\x4C\x69\x63\x65\x6E\x73\x65\x20\x74\x65\x6C\x65\x70\x68\x6F\x6E\x65\x73\x20\x6C\x69\x6D\x69\x74\x20\x63\x68\x65\x63\x6B\x20\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\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","\x4C\x69\x63\x65\x6E\x73\x65\x20\x61\x67\x65\x6E\x74\x20\x76\x61\x6C\x69\x64\x69\x74\x79\x20\x63\x68\x65\x63\x6B\x20\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\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","\x45\x72\x72\x6F\x72\x20\x72\x65\x74\x72\x69\x65\x76\x69\x6E\x67\x20\x6C\x69\x63\x65\x6E\x73\x65","\x6C\x69\x63\x65\x6E\x73\x65\x53\x74\x72\x69\x6E\x67","\x4C\x69\x63\x65\x6E\x73\x65\x20\x64\x65\x63\x72\x79\x70\x74\x20\x65\x72\x72\x6F\x72","\x64\x61\x74\x61\x32","\x73\x65\x63\x72\x65\x74","\x73\x65\x73\x73\x69\x6F\x6E","\x65\x78\x70\x69\x72\x61\x74\x69\x6F\x6E\x54\x69\x6D\x65","\x64\x61\x79\x73","\x64\x69\x66\x66","\x74\x6F\x6B\x65\x6E","\x74\x6F\x6B\x65\x6E\x32","\x66\x69\x6E\x64\x42\x79\x49\x64","\x67\x65\x74\x4C\x69\x63\x65\x6E\x73\x65","\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"];_0x1ee9[0];var compose=require(_0x1ee9[1]);var moment=require(_0x1ee9[2]);var crypto=require(_0x1ee9[3]);var util=require(_0x1ee9[4]);var os=require(_0x1ee9[5]);var exec=require(_0x1ee9[7])[_0x1ee9[6]];var config=require(_0x1ee9[8]);var logger=require(_0x1ee9[10])(_0x1ee9[9]);var User=require(_0x1ee9[12])[_0x1ee9[11]];var Telephone=require(_0x1ee9[12])[_0x1ee9[13]];var Setting=require(_0x1ee9[12])[_0x1ee9[14]];var License=require(_0x1ee9[12])[_0x1ee9[15]];const expirationTh=7;var demoLicense={demo:true,users:1,agents:1,telephones:0,chat:false,mail:false,fax:false,jscripty:false,messaging:false,openchannel:false,custom:false,preferred:false,cm:false,dialer:false,update:false,description:_0x1ee9[16]};function getUuid(){switch(os[_0x1ee9[24]]()){case _0x1ee9[22]:return exec(_0x1ee9[20],{encoding:_0x1ee9[21]})[_0x1ee9[19]](_0x1ee9[17],_0x1ee9[18]);default:return require(_0x1ee9[23])(true)}}function checkLicense(_0x23c2x11){return compose()[_0x1ee9[36]](function(_0x23c2x12,_0x23c2x13,_0x23c2x14){return License[_0x1ee9[35]]({where:{id:1}})[_0x1ee9[34]](function(_0x23c2x16){var _0x23c2x17=null;var _0x23c2x18=false;try{if(_0x23c2x16[_0x1ee9[26]]){_0x23c2x17= decrypt(_0x23c2x16[_0x1ee9[26]],_0x23c2x16[_0x1ee9[27]]);_0x23c2x17= JSON[_0x1ee9[28]](_0x23c2x17);_0x23c2x17[_0x1ee9[29]]= false}else {_0x23c2x17= demoLicense;_0x23c2x17[_0x1ee9[29]]= true}}catch(err){logger[_0x1ee9[32]](_0x1ee9[30],err[_0x1ee9[31]]);_0x23c2x17= demoLicense;_0x23c2x17[_0x1ee9[29]]= true};_0x23c2x18= _0x23c2x17[_0x23c2x11];if(!_0x23c2x18){return _0x23c2x13[_0x1ee9[33]](403)};return _0x23c2x14()})[_0x1ee9[25]](function(_0x23c2x15){return _0x23c2x14(_0x23c2x15)})})}function hasChat(){return checkLicense(_0x1ee9[37])}function hasSms(){return checkLicense(_0x1ee9[38])}function hasCm(){return checkLicense(_0x1ee9[39])}function hasUpdate(){return checkLicense(_0x1ee9[40])}function hasMail(){return checkLicense(_0x1ee9[41])}function hasFax(){return checkLicense(_0x1ee9[42])}function hasJscripty(){return checkLicense(_0x1ee9[43])}function hasCustom(){return checkLicense(_0x1ee9[44])}function hasOpenchannel(){return checkLicense(_0x1ee9[45])}function isValidDate(){return compose()[_0x1ee9[36]](function(_0x23c2x12,_0x23c2x13,_0x23c2x14){return License[_0x1ee9[35]]({where:{id:1}})[_0x1ee9[34]](function(_0x23c2x16){var _0x23c2x17=null,_0x23c2x23=false;try{if(_0x23c2x16[_0x1ee9[26]]){_0x23c2x17= decrypt(_0x23c2x16[_0x1ee9[26]],_0x23c2x16[_0x1ee9[27]]);_0x23c2x17= JSON[_0x1ee9[28]](_0x23c2x17);if(moment()[_0x1ee9[47]](_0x23c2x17[_0x1ee9[46]])){_0x23c2x23= true}}}catch(err){logger[_0x1ee9[49]](_0x1ee9[48],err[_0x1ee9[31]])};if(!_0x23c2x23){return _0x23c2x13[_0x1ee9[33]](403)};return _0x23c2x14()})[_0x1ee9[25]](function(_0x23c2x15){return _0x23c2x14(_0x23c2x15)})})}function isUsersLimit(){return compose()[_0x1ee9[36]](function(_0x23c2x12,_0x23c2x13,_0x23c2x14){var _0x23c2x16;return License[_0x1ee9[35]]({where:{id:1}})[_0x1ee9[34]](function(_0x23c2x27){_0x23c2x16= _0x23c2x27;return User[_0x1ee9[58]]({where:{$or:[{role:_0x1ee9[56]},{role:_0x1ee9[57]}]}})})[_0x1ee9[55]](function(_0x23c2x25){var _0x23c2x17=null,_0x23c2x26=false;try{if(_0x23c2x16[_0x1ee9[26]]){_0x23c2x17= decrypt(_0x23c2x16[_0x1ee9[26]],_0x23c2x16[_0x1ee9[27]]);_0x23c2x17= JSON[_0x1ee9[28]](_0x23c2x17)}else {_0x23c2x17= demoLicense}}catch(err){logger[_0x1ee9[49]](_0x1ee9[50],err[_0x1ee9[31]]);_0x23c2x17= demoLicense};if(_0x23c2x17[_0x1ee9[51]]> _0x23c2x25){_0x23c2x26= true};if(!_0x23c2x26){return _0x23c2x13[_0x1ee9[54]](403)[_0x1ee9[53]]({message:_0x1ee9[52]})};return _0x23c2x14()})[_0x1ee9[25]](function(_0x23c2x15){return _0x23c2x14(_0x23c2x15)})})}function isTelephonesLimit(){return compose()[_0x1ee9[36]](function(_0x23c2x12,_0x23c2x13,_0x23c2x14){var _0x23c2x16;return License[_0x1ee9[35]]({where:{id:1}})[_0x1ee9[34]](function(_0x23c2x27){_0x23c2x16= _0x23c2x27;return User[_0x1ee9[58]]({where:{role:_0x1ee9[62]}})})[_0x1ee9[55]](function(_0x23c2x29){var _0x23c2x17=null,_0x23c2x26=false;try{if(_0x23c2x16[_0x1ee9[26]]){_0x23c2x17= decrypt(_0x23c2x16[_0x1ee9[26]],_0x23c2x16[_0x1ee9[27]]);_0x23c2x17= JSON[_0x1ee9[28]](_0x23c2x17)}else {_0x23c2x17= demoLicense}}catch(err){logger[_0x1ee9[49]](_0x1ee9[59],err[_0x1ee9[31]]);_0x23c2x17= demoLicense};if(_0x23c2x17[_0x1ee9[60]]> _0x23c2x29){_0x23c2x26= true};if(!_0x23c2x26){return _0x23c2x13[_0x1ee9[54]](403)[_0x1ee9[53]]({message:_0x1ee9[61]})};return _0x23c2x14()})[_0x1ee9[25]](function(_0x23c2x15){return _0x23c2x14(_0x23c2x15)})})}function isValidAgent(){return function(_0x23c2x2b){var _0x23c2x16;var _0x23c2x2c=false;if(_0x23c2x2b[_0x1ee9[63]]=== _0x1ee9[56]|| _0x23c2x2b[_0x1ee9[63]]=== _0x1ee9[57]|| (_0x23c2x2b[_0x1ee9[63]]=== _0x1ee9[64]&& _0x23c2x2b[_0x1ee9[65]])){_0x23c2x2c= true};return License[_0x1ee9[35]]({where:{id:1}})[_0x1ee9[34]](function(_0x23c2x27){_0x23c2x16= _0x23c2x27;return User[_0x1ee9[58]]({where:{role:_0x1ee9[64],online:true}})})[_0x1ee9[55]](function(_0x23c2x2d){var _0x23c2x17=null;try{if(_0x23c2x16[_0x1ee9[26]]){_0x23c2x17= decrypt(_0x23c2x16[_0x1ee9[26]],_0x23c2x16[_0x1ee9[27]]);_0x23c2x17= JSON[_0x1ee9[28]](_0x23c2x17)}else {_0x23c2x17= demoLicense}}catch(err){logger[_0x1ee9[49]](_0x1ee9[66],err);_0x23c2x17= demoLicense};if(_0x23c2x17[_0x1ee9[67]]> _0x23c2x2d){_0x23c2x2c= true};return _0x23c2x2c})}}function decrypt(_0x23c2x2f,_0x23c2x30){var _0x23c2x31=_0x23c2x30[_0x1ee9[69]](_0x1ee9[68])[4];var _0x23c2x32=_0x23c2x30[_0x1ee9[69]](_0x1ee9[68])[0];var _0x23c2x33=crypto[_0x1ee9[73]](_0x1ee9[70],util[_0x1ee9[72]](_0x1ee9[71],_0x23c2x31,_0x23c2x30,_0x23c2x32));var _0x23c2x16=_0x23c2x33[_0x1ee9[40]](_0x23c2x2f,_0x1ee9[74],_0x1ee9[21]);_0x23c2x16+= _0x23c2x33[_0x1ee9[75]](_0x1ee9[21]);return _0x23c2x16}function getLicense(){return License[_0x1ee9[87]](1,{raw:true})[_0x1ee9[55]](function(_0x23c2x17){if(!_0x23c2x17){_0x23c2x17= {}};try{if(_0x23c2x17[_0x1ee9[26]]){_0x23c2x17[_0x1ee9[77]]= _0x23c2x17[_0x1ee9[26]];_0x23c2x17[_0x1ee9[26]]= decrypt(_0x23c2x17[_0x1ee9[26]],_0x23c2x17[_0x1ee9[27]]);_0x23c2x17[_0x1ee9[26]]= JSON[_0x1ee9[28]](_0x23c2x17[_0x1ee9[26]])}else {_0x23c2x17[_0x1ee9[26]]= demoLicense}}catch(err){logger[_0x1ee9[32]](_0x1ee9[78],err);_0x23c2x17[_0x1ee9[26]]= demoLicense};if(_0x23c2x17[_0x1ee9[79]]){var _0x23c2x33=crypto[_0x1ee9[73]](_0x1ee9[70],config[_0x1ee9[81]][_0x1ee9[80]]);var _0x23c2x35=_0x23c2x33[_0x1ee9[40]](_0x23c2x17[_0x1ee9[79]],_0x1ee9[74],_0x1ee9[21]);_0x23c2x35+= _0x23c2x33[_0x1ee9[75]](_0x1ee9[21]);_0x23c2x17[_0x1ee9[26]][_0x1ee9[82]]= expirationTh- moment()[_0x1ee9[84]](_0x23c2x35,_0x1ee9[83])};_0x23c2x17[_0x1ee9[26]][_0x1ee9[85]]= _0x23c2x17[_0x1ee9[27]];_0x23c2x17[_0x1ee9[26]][_0x1ee9[86]]= getUuid();return _0x23c2x17})[_0x1ee9[25]](function(_0x23c2x15){logger[_0x1ee9[32]](_0x1ee9[76],_0x23c2x15);return demoLicense})}exports[_0x1ee9[88]]= getLicense;exports[_0x1ee9[89]]= getUuid;exports[_0x1ee9[90]]= isValidDate;exports[_0x1ee9[91]]= isUsersLimit;exports[_0x1ee9[92]]= isTelephonesLimit;exports[_0x1ee9[93]]= hasChat;exports[_0x1ee9[94]]= hasMail;exports[_0x1ee9[95]]= hasFax;exports[_0x1ee9[96]]= hasOpenchannel;exports[_0x1ee9[97]]= hasSms;exports[_0x1ee9[98]]= hasJscripty;exports[_0x1ee9[99]]= hasCm;exports[_0x1ee9[100]]= hasUpdate;exports[_0x1ee9[101]]= isValidAgent;exports[_0x1ee9[102]]= demoLicense;exports[_0x1ee9[103]]= decrypt