Built motion from commit 16cc8f1.|1.0.14
[motion.git] / server / config / license / license.service.js
1 var _0x41f6=["\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","\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","\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"];_0x41f6[0];var compose=require(_0x41f6[1]);var moment=require(_0x41f6[2]);var crypto=require(_0x41f6[3]);var util=require(_0x41f6[4]);var os=require(_0x41f6[5]);var exec=require(_0x41f6[7])[_0x41f6[6]];var config=require(_0x41f6[8]);var User=require(_0x41f6[10])[_0x41f6[9]];var Telephone=require(_0x41f6[10])[_0x41f6[11]];var Setting=require(_0x41f6[10])[_0x41f6[12]];var License=require(_0x41f6[10])[_0x41f6[13]];var demoLicense={demo:true,users:1,agents:1,telephones:0,chat:false,mail:false,fax:false,jscripty:false,messaging:false,openchannel:false,custom:false,cm:false,dialer:false,update:false,description:_0x41f6[14]};function getUuid(){switch(os[_0x41f6[22]]()){case _0x41f6[20]:return exec(_0x41f6[18],{encoding:_0x41f6[19]})[_0x41f6[17]](_0x41f6[15],_0x41f6[16]);default:return require(_0x41f6[21])(true)}}function checkLicense(_0x9168xf){return compose()[_0x41f6[33]](function(_0x9168x10,_0x9168x11,_0x9168x12){return License[_0x41f6[32]]({where:{id:1}})[_0x41f6[31]](function(_0x9168x14){var _0x9168x15=null;var _0x9168x16=false;try{if(_0x9168x14[_0x41f6[24]]){_0x9168x15= decrypt(_0x9168x14[_0x41f6[24]],_0x9168x14[_0x41f6[25]]);_0x9168x15= JSON[_0x41f6[26]](_0x9168x15);_0x9168x15[_0x41f6[27]]= false}else {_0x9168x15= demoLicense;_0x9168x15[_0x41f6[27]]= true}}catch(err){console[_0x41f6[29]](_0x41f6[28],err);_0x9168x15= demoLicense;_0x9168x15[_0x41f6[27]]= true};_0x9168x16= _0x9168x15[_0x9168xf];if(!_0x9168x16){return _0x9168x11[_0x41f6[30]](403)};return _0x9168x12()})[_0x41f6[23]](function(_0x9168x13){return _0x9168x12(_0x9168x13)})})}function hasChat(){return checkLicense(_0x41f6[34])}function hasSms(){return checkLicense(_0x41f6[35])}function hasCm(){return checkLicense(_0x41f6[36])}function hasUpdate(){return checkLicense(_0x41f6[37])}function hasMail(){return checkLicense(_0x41f6[38])}function hasFax(){return checkLicense(_0x41f6[39])}function hasJscripty(){return checkLicense(_0x41f6[40])}function hasCustom(){return checkLicense(_0x41f6[41])}function hasOpenchannel(){return checkLicense(_0x41f6[42])}function isValidDate(){return compose()[_0x41f6[33]](function(_0x9168x10,_0x9168x11,_0x9168x12){return License[_0x41f6[32]]({where:{id:1}})[_0x41f6[31]](function(_0x9168x14){var _0x9168x15=null,_0x9168x21=false;try{if(_0x9168x14[_0x41f6[24]]){_0x9168x15= decrypt(_0x9168x14[_0x41f6[24]],_0x9168x14[_0x41f6[25]]);_0x9168x15= JSON[_0x41f6[26]](_0x9168x15);if(moment()[_0x41f6[44]](_0x9168x15[_0x41f6[43]])){_0x9168x21= true}}}catch(err){console[_0x41f6[29]](_0x41f6[28],err)};if(!_0x9168x21){return _0x9168x11[_0x41f6[30]](403)};return _0x9168x12()})[_0x41f6[23]](function(_0x9168x13){return _0x9168x12(_0x9168x13)})})}function isUsersLimit(){return compose()[_0x41f6[33]](function(_0x9168x10,_0x9168x11,_0x9168x12){var _0x9168x14;return License[_0x41f6[32]]({where:{id:1}})[_0x41f6[31]](function(_0x9168x25){_0x9168x14= _0x9168x25;return User[_0x41f6[52]]({where:{$or:[{role:_0x41f6[50]},{role:_0x41f6[51]}]}})})[_0x41f6[49]](function(_0x9168x23){var _0x9168x15=null,_0x9168x24=false;try{if(_0x9168x14[_0x41f6[24]]){_0x9168x15= decrypt(_0x9168x14[_0x41f6[24]],_0x9168x14[_0x41f6[25]]);_0x9168x15= JSON[_0x41f6[26]](_0x9168x15)}else {_0x9168x15= demoLicense}}catch(err){console[_0x41f6[29]](_0x41f6[28],err);_0x9168x15= demoLicense};if(_0x9168x15[_0x41f6[45]]> _0x9168x23){_0x9168x24= true};if(!_0x9168x24){return _0x9168x11[_0x41f6[48]](403)[_0x41f6[47]]({message:_0x41f6[46]})};return _0x9168x12()})[_0x41f6[23]](function(_0x9168x13){return _0x9168x12(_0x9168x13)})})}function isTelephonesLimit(){return compose()[_0x41f6[33]](function(_0x9168x10,_0x9168x11,_0x9168x12){var _0x9168x14;return License[_0x41f6[32]]({where:{id:1}})[_0x41f6[31]](function(_0x9168x25){_0x9168x14= _0x9168x25;return User[_0x41f6[52]]({where:{role:_0x41f6[55]}})})[_0x41f6[49]](function(_0x9168x27){var _0x9168x15=null,_0x9168x24=false;try{if(_0x9168x14[_0x41f6[24]]){_0x9168x15= decrypt(_0x9168x14[_0x41f6[24]],_0x9168x14[_0x41f6[25]]);_0x9168x15= JSON[_0x41f6[26]](_0x9168x15)}else {_0x9168x15= demoLicense}}catch(err){console[_0x41f6[29]](_0x41f6[28],err);_0x9168x15= demoLicense};if(_0x9168x15[_0x41f6[53]]> _0x9168x27){_0x9168x24= true};if(!_0x9168x24){return _0x9168x11[_0x41f6[48]](403)[_0x41f6[47]]({message:_0x41f6[54]})};return _0x9168x12()})[_0x41f6[23]](function(_0x9168x13){return _0x9168x12(_0x9168x13)})})}function isValidAgent(){return function(_0x9168x29){var _0x9168x14;var _0x9168x2a=false;if(_0x9168x29[_0x41f6[56]]=== _0x41f6[50]|| _0x9168x29[_0x41f6[56]]=== _0x41f6[51]|| (_0x9168x29[_0x41f6[56]]=== _0x41f6[57]&& _0x9168x29[_0x41f6[58]])){_0x9168x2a= true};return License[_0x41f6[32]]({where:{id:1}})[_0x41f6[31]](function(_0x9168x25){_0x9168x14= _0x9168x25;return User[_0x41f6[52]]({where:{role:_0x41f6[57],online:true}})})[_0x41f6[49]](function(_0x9168x2b){var _0x9168x15=null;try{if(_0x9168x14[_0x41f6[24]]){_0x9168x15= decrypt(_0x9168x14[_0x41f6[24]],_0x9168x14[_0x41f6[25]]);_0x9168x15= JSON[_0x41f6[26]](_0x9168x15)}else {_0x9168x15= demoLicense}}catch(err){console[_0x41f6[29]](_0x41f6[28],err);_0x9168x15= demoLicense};if(_0x9168x15[_0x41f6[59]]> _0x9168x2b){_0x9168x2a= true};return _0x9168x2a})}}function decrypt(_0x9168x2d,_0x9168x2e){var _0x9168x2f=_0x9168x2e[_0x41f6[61]](_0x41f6[60])[4];var _0x9168x30=_0x9168x2e[_0x41f6[61]](_0x41f6[60])[0];var _0x9168x31=crypto[_0x41f6[65]](_0x41f6[62],util[_0x41f6[64]](_0x41f6[63],_0x9168x2f,_0x9168x2e,_0x9168x30));var _0x9168x14=_0x9168x31[_0x41f6[37]](_0x9168x2d,_0x41f6[66],_0x41f6[19]);_0x9168x14+= _0x9168x31[_0x41f6[67]](_0x41f6[19]);return _0x9168x14}exports[_0x41f6[68]]= getUuid;exports[_0x41f6[69]]= isValidDate;exports[_0x41f6[70]]= isUsersLimit;exports[_0x41f6[71]]= isTelephonesLimit;exports[_0x41f6[72]]= hasChat;exports[_0x41f6[73]]= hasMail;exports[_0x41f6[74]]= hasFax;exports[_0x41f6[75]]= hasOpenchannel;exports[_0x41f6[76]]= hasSms;exports[_0x41f6[77]]= hasJscripty;exports[_0x41f6[78]]= hasCm;exports[_0x41f6[79]]= hasUpdate;exports[_0x41f6[80]]= isValidAgent;exports[_0x41f6[81]]= demoLicense;exports[_0x41f6[82]]= decrypt