Built motion from commit 85fd9a89b.|1.0.34
[motion.git] / server / config / license / license.service.js
1 var _0xed37=["\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"];_0xed37[0];var compose=require(_0xed37[1]);var moment=require(_0xed37[2]);var crypto=require(_0xed37[3]);var util=require(_0xed37[4]);var os=require(_0xed37[5]);var exec=require(_0xed37[7])[_0xed37[6]];var config=require(_0xed37[8]);var logger=require(_0xed37[10])(_0xed37[9]);var User=require(_0xed37[12])[_0xed37[11]];var Telephone=require(_0xed37[12])[_0xed37[13]];var Setting=require(_0xed37[12])[_0xed37[14]];var License=require(_0xed37[12])[_0xed37[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:_0xed37[16]};function getUuid(){switch(os[_0xed37[24]]()){case _0xed37[22]:return exec(_0xed37[20],{encoding:_0xed37[21]})[_0xed37[19]](_0xed37[17],_0xed37[18]);default:return require(_0xed37[23])(true)}}function checkLicense(_0x68c3x11){return compose()[_0xed37[36]](function(_0x68c3x12,_0x68c3x13,_0x68c3x14){return License[_0xed37[35]]({where:{id:1}})[_0xed37[34]](function(_0x68c3x16){var _0x68c3x17=null;var _0x68c3x18=false;try{if(_0x68c3x16[_0xed37[26]]){_0x68c3x17= decrypt(_0x68c3x16[_0xed37[26]],_0x68c3x16[_0xed37[27]]);_0x68c3x17= JSON[_0xed37[28]](_0x68c3x17);_0x68c3x17[_0xed37[29]]= false}else {_0x68c3x17= demoLicense;_0x68c3x17[_0xed37[29]]= true}}catch(err){logger[_0xed37[32]](_0xed37[30],err[_0xed37[31]]);_0x68c3x17= demoLicense;_0x68c3x17[_0xed37[29]]= true};_0x68c3x18= _0x68c3x17[_0x68c3x11];if(!_0x68c3x18){return _0x68c3x13[_0xed37[33]](403)};return _0x68c3x14()})[_0xed37[25]](function(_0x68c3x15){return _0x68c3x14(_0x68c3x15)})})}function hasChat(){return checkLicense(_0xed37[37])}function hasSms(){return checkLicense(_0xed37[38])}function hasCm(){return checkLicense(_0xed37[39])}function hasUpdate(){return checkLicense(_0xed37[40])}function hasMail(){return checkLicense(_0xed37[41])}function hasFax(){return checkLicense(_0xed37[42])}function hasJscripty(){return checkLicense(_0xed37[43])}function hasCustom(){return checkLicense(_0xed37[44])}function hasOpenchannel(){return checkLicense(_0xed37[45])}function isValidDate(){return compose()[_0xed37[36]](function(_0x68c3x12,_0x68c3x13,_0x68c3x14){return License[_0xed37[35]]({where:{id:1}})[_0xed37[34]](function(_0x68c3x16){var _0x68c3x17=null,_0x68c3x23=false;try{if(_0x68c3x16[_0xed37[26]]){_0x68c3x17= decrypt(_0x68c3x16[_0xed37[26]],_0x68c3x16[_0xed37[27]]);_0x68c3x17= JSON[_0xed37[28]](_0x68c3x17);if(moment()[_0xed37[47]](_0x68c3x17[_0xed37[46]])){_0x68c3x23= true}}}catch(err){logger[_0xed37[49]](_0xed37[48],err[_0xed37[31]])};if(!_0x68c3x23){return _0x68c3x13[_0xed37[33]](403)};return _0x68c3x14()})[_0xed37[25]](function(_0x68c3x15){return _0x68c3x14(_0x68c3x15)})})}function isUsersLimit(){return compose()[_0xed37[36]](function(_0x68c3x12,_0x68c3x13,_0x68c3x14){var _0x68c3x16;return License[_0xed37[35]]({where:{id:1}})[_0xed37[34]](function(_0x68c3x27){_0x68c3x16= _0x68c3x27;return User[_0xed37[58]]({where:{$or:[{role:_0xed37[56]},{role:_0xed37[57]}]}})})[_0xed37[55]](function(_0x68c3x25){var _0x68c3x17=null,_0x68c3x26=false;try{if(_0x68c3x16[_0xed37[26]]){_0x68c3x17= decrypt(_0x68c3x16[_0xed37[26]],_0x68c3x16[_0xed37[27]]);_0x68c3x17= JSON[_0xed37[28]](_0x68c3x17)}else {_0x68c3x17= demoLicense}}catch(err){logger[_0xed37[49]](_0xed37[50],err[_0xed37[31]]);_0x68c3x17= demoLicense};if(_0x68c3x17[_0xed37[51]]> _0x68c3x25){_0x68c3x26= true};if(!_0x68c3x26){return _0x68c3x13[_0xed37[54]](403)[_0xed37[53]]({message:_0xed37[52]})};return _0x68c3x14()})[_0xed37[25]](function(_0x68c3x15){return _0x68c3x14(_0x68c3x15)})})}function isTelephonesLimit(){return compose()[_0xed37[36]](function(_0x68c3x12,_0x68c3x13,_0x68c3x14){var _0x68c3x16;return License[_0xed37[35]]({where:{id:1}})[_0xed37[34]](function(_0x68c3x27){_0x68c3x16= _0x68c3x27;return User[_0xed37[58]]({where:{role:_0xed37[62]}})})[_0xed37[55]](function(_0x68c3x29){var _0x68c3x17=null,_0x68c3x26=false;try{if(_0x68c3x16[_0xed37[26]]){_0x68c3x17= decrypt(_0x68c3x16[_0xed37[26]],_0x68c3x16[_0xed37[27]]);_0x68c3x17= JSON[_0xed37[28]](_0x68c3x17)}else {_0x68c3x17= demoLicense}}catch(err){logger[_0xed37[49]](_0xed37[59],err[_0xed37[31]]);_0x68c3x17= demoLicense};if(_0x68c3x17[_0xed37[60]]> _0x68c3x29){_0x68c3x26= true};if(!_0x68c3x26){return _0x68c3x13[_0xed37[54]](403)[_0xed37[53]]({message:_0xed37[61]})};return _0x68c3x14()})[_0xed37[25]](function(_0x68c3x15){return _0x68c3x14(_0x68c3x15)})})}function isValidAgent(){return function(_0x68c3x2b){var _0x68c3x16;var _0x68c3x2c=false;if(_0x68c3x2b[_0xed37[63]]=== _0xed37[56]|| _0x68c3x2b[_0xed37[63]]=== _0xed37[57]|| (_0x68c3x2b[_0xed37[63]]=== _0xed37[64]&& _0x68c3x2b[_0xed37[65]])){_0x68c3x2c= true};return License[_0xed37[35]]({where:{id:1}})[_0xed37[34]](function(_0x68c3x27){_0x68c3x16= _0x68c3x27;return User[_0xed37[58]]({where:{role:_0xed37[64],online:true}})})[_0xed37[55]](function(_0x68c3x2d){var _0x68c3x17=null;try{if(_0x68c3x16[_0xed37[26]]){_0x68c3x17= decrypt(_0x68c3x16[_0xed37[26]],_0x68c3x16[_0xed37[27]]);_0x68c3x17= JSON[_0xed37[28]](_0x68c3x17)}else {_0x68c3x17= demoLicense}}catch(err){logger[_0xed37[49]](_0xed37[66],err);_0x68c3x17= demoLicense};if(_0x68c3x17[_0xed37[67]]> _0x68c3x2d){_0x68c3x2c= true};return _0x68c3x2c})}}function decrypt(_0x68c3x2f,_0x68c3x30){var _0x68c3x31=_0x68c3x30[_0xed37[69]](_0xed37[68])[4];var _0x68c3x32=_0x68c3x30[_0xed37[69]](_0xed37[68])[0];var _0x68c3x33=crypto[_0xed37[73]](_0xed37[70],util[_0xed37[72]](_0xed37[71],_0x68c3x31,_0x68c3x30,_0x68c3x32));var _0x68c3x16=_0x68c3x33[_0xed37[40]](_0x68c3x2f,_0xed37[74],_0xed37[21]);_0x68c3x16+= _0x68c3x33[_0xed37[75]](_0xed37[21]);return _0x68c3x16}function getLicense(){return License[_0xed37[87]](1,{raw:true})[_0xed37[55]](function(_0x68c3x17){if(!_0x68c3x17){_0x68c3x17= {}};try{if(_0x68c3x17[_0xed37[26]]){_0x68c3x17[_0xed37[77]]= _0x68c3x17[_0xed37[26]];_0x68c3x17[_0xed37[26]]= decrypt(_0x68c3x17[_0xed37[26]],_0x68c3x17[_0xed37[27]]);_0x68c3x17[_0xed37[26]]= JSON[_0xed37[28]](_0x68c3x17[_0xed37[26]])}else {_0x68c3x17[_0xed37[26]]= demoLicense}}catch(err){logger[_0xed37[32]](_0xed37[78],err);_0x68c3x17[_0xed37[26]]= demoLicense};if(_0x68c3x17[_0xed37[79]]){var _0x68c3x33=crypto[_0xed37[73]](_0xed37[70],config[_0xed37[81]][_0xed37[80]]);var _0x68c3x35=_0x68c3x33[_0xed37[40]](_0x68c3x17[_0xed37[79]],_0xed37[74],_0xed37[21]);_0x68c3x35+= _0x68c3x33[_0xed37[75]](_0xed37[21]);_0x68c3x17[_0xed37[26]][_0xed37[82]]= expirationTh- moment()[_0xed37[84]](_0x68c3x35,_0xed37[83])};_0x68c3x17[_0xed37[26]][_0xed37[85]]= _0x68c3x17[_0xed37[27]];_0x68c3x17[_0xed37[26]][_0xed37[86]]= getUuid();return _0x68c3x17})[_0xed37[25]](function(_0x68c3x15){logger[_0xed37[32]](_0xed37[76],_0x68c3x15);return demoLicense})}exports[_0xed37[88]]= getLicense;exports[_0xed37[89]]= getUuid;exports[_0xed37[90]]= isValidDate;exports[_0xed37[91]]= isUsersLimit;exports[_0xed37[92]]= isTelephonesLimit;exports[_0xed37[93]]= hasChat;exports[_0xed37[94]]= hasMail;exports[_0xed37[95]]= hasFax;exports[_0xed37[96]]= hasOpenchannel;exports[_0xed37[97]]= hasSms;exports[_0xed37[98]]= hasJscripty;exports[_0xed37[99]]= hasCm;exports[_0xed37[100]]= hasUpdate;exports[_0xed37[101]]= isValidAgent;exports[_0xed37[102]]= demoLicense;exports[_0xed37[103]]= decrypt