Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / plugin / plugin.controller.js
index 27d3a65..5980e7c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x60ae=['unlinkSync','info','Download\x20completed','Temporary\x20file\x20removed','file','filename','extname','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','readdirSync','Invalid\x20plugin\x20structure','lstatSync','isFile','isDirectory','manifest.json','readFileSync','parse','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','Invalid\x20manifest:\x20parameters\x20missing','html','views','Invalid\x20manifest:\x20views\x20missing','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','parameters','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','version','Warning:\x20admin\x20view\x20not\x20specified','test','Warning:\x20agent\x20view\x20not\x20specified','plugins','create','role','body','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Zip\x20archive\x20removed','Extracted\x20folder\x20removed','update','delete','webhookGet','resolve','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','http://localhost:','encoding','headers','content-length','set','endsWith','statusCode','webhookPost','%s%s','content-type','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','extract-zip','rimraf','archiver','../../components/auth/service','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','then','destroy','get','Plugins','UserProfileResource','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','filter','options','Plugin','includeAll','include','findAll','rows','catch','show','params','find','join','server/files/plugins','format','%s.zip','basename','createWriteStream','zip','warning','code','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','**/*','root','dirname','node_modules/**/*','attachments/**/*','finalize','close','existsSync','Plugin\x20not\x20found','download','Error\x20while\x20downloading\x20the\x20plugin'];(function(_0x5b6ed8,_0x4ee6b4){var _0x4c0458=function(_0x20ed6f){while(--_0x20ed6f){_0x5b6ed8['push'](_0x5b6ed8['shift']());}};_0x4c0458(++_0x4ee6b4);}(_0x60ae,0x1b0));var _0xe60a=function(_0x42c6f1,_0x338d7b){_0x42c6f1=_0x42c6f1-0x0;var _0x3c7398=_0x60ae[_0x42c6f1];return _0x3c7398;};'use strict';var emlformat=require(_0xe60a('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe60a('0x1'));var jsonpatch=require(_0xe60a('0x2'));var rp=require(_0xe60a('0x3'));var moment=require(_0xe60a('0x4'));var BPromise=require(_0xe60a('0x5'));var Mustache=require('mustache');var util=require(_0xe60a('0x6'));var path=require(_0xe60a('0x7'));var sox=require(_0xe60a('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xe60a('0x9'));var _=require(_0xe60a('0xa'));var squel=require(_0xe60a('0xb'));var crypto=require(_0xe60a('0xc'));var jsforce=require(_0xe60a('0xd'));var deskjs=require(_0xe60a('0xe'));var toCsv=require(_0xe60a('0xf'));var querystring=require(_0xe60a('0x10'));var Papa=require(_0xe60a('0x11'));var extract=require(_0xe60a('0x12'));var rimraf=require(_0xe60a('0x13'));var archiver=require(_0xe60a('0x14'));var Redis=require('ioredis');var authService=require(_0xe60a('0x15'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe60a('0x16'));var logger=require('../../config/logger')('api');var utils=require(_0xe60a('0x17'));var config=require(_0xe60a('0x18'));var licenseUtil=require(_0xe60a('0x19'));var db=require(_0xe60a('0x1a'))['db'];config[_0xe60a('0x1b')]=_[_0xe60a('0x1c')](config[_0xe60a('0x1b')],{'host':_0xe60a('0x1d'),'port':0x18eb});var socket=require(_0xe60a('0x1e'))(new Redis(config[_0xe60a('0x1b')]));require(_0xe60a('0x1f'))[_0xe60a('0x20')](socket);function respondWithStatusCode(_0x50a68b,_0x1c8610){_0x1c8610=_0x1c8610||0xcc;return function(_0x3d6b6f){if(_0x3d6b6f){return _0x50a68b[_0xe60a('0x21')](_0x1c8610);}return _0x50a68b[_0xe60a('0x22')](_0x1c8610)[_0xe60a('0x23')]();};}function respondWithResult(_0x4d3d3b,_0x271d27){_0x271d27=_0x271d27||0xc8;return function(_0x4abbb5){if(_0x4abbb5){return _0x4d3d3b[_0xe60a('0x22')](_0x271d27)[_0xe60a('0x24')](_0x4abbb5);}};}function respondWithFilteredResult(_0x36bf4e,_0x56ab33){return function(_0x57695f){if(_0x57695f){var _0x11e757=typeof _0x56ab33[_0xe60a('0x25')]===_0xe60a('0x26')&&typeof _0x56ab33[_0xe60a('0x27')]===_0xe60a('0x26');var _0xd11c29=_0x57695f[_0xe60a('0x28')];var _0x5dafec=_0x11e757?0x0:_0x56ab33[_0xe60a('0x25')];var _0x363527=_0x11e757?_0x57695f[_0xe60a('0x28')]:_0x56ab33[_0xe60a('0x25')]+_0x56ab33[_0xe60a('0x27')];var _0x2d03fd;if(_0x363527>=_0xd11c29){_0x363527=_0xd11c29;_0x2d03fd=0xc8;}else{_0x2d03fd=0xce;}_0x36bf4e[_0xe60a('0x22')](_0x2d03fd);return _0x36bf4e['set'](_0xe60a('0x29'),_0x5dafec+'-'+_0x363527+'/'+_0xd11c29)[_0xe60a('0x24')](_0x57695f);}return null;};}function patchUpdates(_0x3bf3fb){return function(_0x5e5d79){try{jsonpatch[_0xe60a('0x2a')](_0x5e5d79,_0x3bf3fb,!![]);}catch(_0x409ba9){return BPromise['reject'](_0x409ba9);}return _0x5e5d79['save']();};}function saveUpdates(_0x418157,_0x439a57){return function(_0x2f856d){if(_0x2f856d){return _0x2f856d['update'](_0x418157)[_0xe60a('0x2b')](function(_0x28abff){return _0x28abff;});}return null;};}function removeEntity(_0x36cde6,_0x3f0e97){return function(_0x5b6078){if(_0x5b6078){return _0x5b6078[_0xe60a('0x2c')]()[_0xe60a('0x2b')](function(){var _0x313646=_0x5b6078[_0xe60a('0x2d')]({'plain':!![]});var _0x5514fd=_0xe60a('0x2e');return db[_0xe60a('0x2f')][_0xe60a('0x2c')]({'where':{'type':_0x5514fd,'resourceId':_0x313646['id']}})['then'](function(){return _0x5b6078;});})[_0xe60a('0x2b')](function(){_0x36cde6[_0xe60a('0x22')](0xcc)[_0xe60a('0x23')]();});}};}function handleEntityNotFound(_0x5667dc,_0x2f74eb){return function(_0x2b71a5){if(!_0x2b71a5){_0x5667dc[_0xe60a('0x21')](0x194);}return _0x2b71a5;};}function handleError(_0x14b41e,_0x304ece){_0x304ece=_0x304ece||0x1f4;return function(_0x2c9927){logger[_0xe60a('0x30')](_0x2c9927[_0xe60a('0x31')]);if(_0x2c9927[_0xe60a('0x32')]){delete _0x2c9927[_0xe60a('0x32')];}_0x14b41e[_0xe60a('0x22')](_0x304ece)[_0xe60a('0x33')](_0x2c9927);};}exports[_0xe60a('0x34')]=function(_0x36807f,_0x45b0cf){var _0x16a1af={},_0x3a462e={},_0x5c5180={'count':0x0,'rows':[]};var _0x421ea5=_[_0xe60a('0x35')](db['Plugin'][_0xe60a('0x36')],function(_0x46447f){return{'name':_0x46447f[_0xe60a('0x37')],'type':_0x46447f[_0xe60a('0x38')][_0xe60a('0x39')]};});_0x3a462e['model']=_['map'](_0x421ea5,_0xe60a('0x32'));_0x3a462e[_0xe60a('0x3a')]=_[_0xe60a('0x3b')](_0x36807f[_0xe60a('0x3a')]);_0x3a462e[_0xe60a('0x3c')]=_[_0xe60a('0x3d')](_0x3a462e[_0xe60a('0x3e')],_0x3a462e[_0xe60a('0x3a')]);_0x16a1af[_0xe60a('0x3f')]=_['intersection'](_0x3a462e[_0xe60a('0x3e')],qs['fields'](_0x36807f[_0xe60a('0x3a')][_0xe60a('0x40')]));_0x16a1af[_0xe60a('0x3f')]=_0x16a1af[_0xe60a('0x3f')][_0xe60a('0x41')]?_0x16a1af[_0xe60a('0x3f')]:_0x3a462e[_0xe60a('0x3e')];if(!_0x36807f['query'][_0xe60a('0x42')](_0xe60a('0x43'))){_0x16a1af[_0xe60a('0x27')]=qs['limit'](_0x36807f[_0xe60a('0x3a')][_0xe60a('0x27')]);_0x16a1af['offset']=qs['offset'](_0x36807f['query'][_0xe60a('0x25')]);}_0x16a1af[_0xe60a('0x44')]=qs[_0xe60a('0x45')](_0x36807f[_0xe60a('0x3a')][_0xe60a('0x45')]);_0x16a1af[_0xe60a('0x46')]=qs[_0xe60a('0x3c')](_[_0xe60a('0x47')](_0x36807f['query'],_0x3a462e[_0xe60a('0x3c')]),_0x421ea5);if(_0x36807f[_0xe60a('0x3a')]['filter']){_0x16a1af['where']=_[_0xe60a('0x48')](_0x16a1af[_0xe60a('0x46')],{'$or':_['map'](_0x421ea5,function(_0xf3b0d6){if(_0xf3b0d6['type']!=='VIRTUAL'){var _0x3c0ed2={};_0x3c0ed2[_0xf3b0d6[_0xe60a('0x32')]]={'$like':'%'+_0x36807f['query'][_0xe60a('0x49')]+'%'};return _0x3c0ed2;}})});}_0x16a1af=_[_0xe60a('0x48')]({},_0x16a1af,_0x36807f[_0xe60a('0x4a')]);var _0xbb7ee9={'where':_0x16a1af['where']};return db[_0xe60a('0x4b')]['count'](_0xbb7ee9)[_0xe60a('0x2b')](function(_0x5b1463){_0x5c5180['count']=_0x5b1463;if(_0x36807f[_0xe60a('0x3a')][_0xe60a('0x4c')]){_0x16a1af[_0xe60a('0x4d')]=[{'all':!![]}];}return db[_0xe60a('0x4b')][_0xe60a('0x4e')](_0x16a1af);})['then'](function(_0x35ccc0){_0x5c5180[_0xe60a('0x4f')]=_0x35ccc0;return _0x5c5180;})[_0xe60a('0x2b')](respondWithFilteredResult(_0x45b0cf,_0x16a1af))[_0xe60a('0x50')](handleError(_0x45b0cf,null));};exports[_0xe60a('0x51')]=function(_0x2ced3e,_0x22fd04){var _0x26c449={'raw':!![],'where':{'id':_0x2ced3e[_0xe60a('0x52')]['id']}},_0x428f97={};_0x428f97[_0xe60a('0x3e')]=_[_0xe60a('0x3b')](db[_0xe60a('0x4b')]['rawAttributes']);_0x428f97['query']=_[_0xe60a('0x3b')](_0x2ced3e[_0xe60a('0x3a')]);_0x428f97[_0xe60a('0x3c')]=_[_0xe60a('0x3d')](_0x428f97['model'],_0x428f97[_0xe60a('0x3a')]);_0x26c449[_0xe60a('0x3f')]=_[_0xe60a('0x3d')](_0x428f97['model'],qs[_0xe60a('0x40')](_0x2ced3e[_0xe60a('0x3a')]['fields']));_0x26c449[_0xe60a('0x3f')]=_0x26c449[_0xe60a('0x3f')][_0xe60a('0x41')]?_0x26c449[_0xe60a('0x3f')]:_0x428f97[_0xe60a('0x3e')];if(_0x2ced3e['query'][_0xe60a('0x4c')]){_0x26c449[_0xe60a('0x4d')]=[{'all':!![]}];}_0x26c449=_[_0xe60a('0x48')]({},_0x26c449,_0x2ced3e['options']);return db[_0xe60a('0x4b')]['find'](_0x26c449)[_0xe60a('0x2b')](handleEntityNotFound(_0x22fd04,null))['then'](respondWithResult(_0x22fd04,null))[_0xe60a('0x50')](handleError(_0x22fd04,null));};exports['download']=function(_0x5ce3f1,_0x9318bb,_0x2c763d){return db[_0xe60a('0x4b')][_0xe60a('0x53')]({'where':{'id':_0x5ce3f1[_0xe60a('0x52')]['id']},'attributes':[_0xe60a('0x32'),_0xe60a('0x7')],'raw':!![]})[_0xe60a('0x2b')](handleEntityNotFound(_0x9318bb,null))[_0xe60a('0x2b')](function(_0x3a8860){if(_0x3a8860){var _0x33787b=path[_0xe60a('0x54')](config['root'],_0xe60a('0x55'),util[_0xe60a('0x56')](_0xe60a('0x57'),path[_0xe60a('0x58')](_0x3a8860[_0xe60a('0x7')])));var _0x18e875=fs[_0xe60a('0x59')](_0x33787b);var _0x1ce63c=archiver(_0xe60a('0x5a'),{'zlib':{'level':0x9}});_0x1ce63c['on'](_0xe60a('0x5b'),function(_0x225b16){if(_0x225b16[_0xe60a('0x5c')]===_0xe60a('0x5d')){logger['error'](_0x225b16);}else{throw new db[(_0xe60a('0x5e'))][(_0xe60a('0x5f'))](_0xe60a('0x60'));}});_0x1ce63c['on']('error',function(_0x3e6c8c){throw new db[(_0xe60a('0x5e'))][(_0xe60a('0x5f'))](_0xe60a('0x60'));});_0x1ce63c['pipe'](_0x18e875);_0x1ce63c['glob'](_0xe60a('0x61'),{'cwd':path[_0xe60a('0x54')](config[_0xe60a('0x62')],_0xe60a('0x55'),path[_0xe60a('0x63')](_0x3a8860[_0xe60a('0x7')])),'ignore':[path[_0xe60a('0x54')](path[_0xe60a('0x58')](_0x3a8860[_0xe60a('0x7')]),_0xe60a('0x64')),path[_0xe60a('0x54')](path['basename'](_0x3a8860[_0xe60a('0x7')]),_0xe60a('0x65'))],'nodir':!![]})[_0xe60a('0x66')]();_0x18e875['on'](_0xe60a('0x67'),function(){if(!fs[_0xe60a('0x68')](_0x33787b)){throw new db[(_0xe60a('0x5e'))]['Error'](_0xe60a('0x69'));}return _0x9318bb[_0xe60a('0x6a')](_0x33787b,util[_0xe60a('0x56')]('%s.zip',path[_0xe60a('0x58')](_0x3a8860[_0xe60a('0x7')])),function(_0x4e4723){if(_0x4e4723){throw new db[(_0xe60a('0x5e'))][(_0xe60a('0x5f'))](_0xe60a('0x6b'));}fs[_0xe60a('0x6c')](_0x33787b);logger[_0xe60a('0x6d')](_0xe60a('0x6e'));logger[_0xe60a('0x6d')](_0xe60a('0x6f'));});});}return null;})['catch'](handleError(_0x9318bb,null));};exports['upload']=function(_0x506104,_0x30bcb4,_0x87f679){var _0x52eb59=path[_0xe60a('0x58')](_0x506104[_0xe60a('0x70')][_0xe60a('0x71')],path[_0xe60a('0x72')](_0x506104['file'][_0xe60a('0x71')]));var _0x2b2a7a=path['join'](config[_0xe60a('0x62')],_0xe60a('0x55'),_0x506104[_0xe60a('0x70')][_0xe60a('0x71')]);var _0x1ef490=path[_0xe60a('0x54')](config['root'],_0xe60a('0x55'),_0x52eb59);logger[_0xe60a('0x6d')]('Plugin\x20upload\x20filepath:\x20%s',_0x2b2a7a);logger[_0xe60a('0x6d')](_0xe60a('0x73'),_0x1ef490);try{fs[_0xe60a('0x74')](_0x2b2a7a,parseInt(_0xe60a('0x75'),0x8));extract(_0x2b2a7a,{'dir':_0x1ef490},function(_0xeef3f1){if(_0xeef3f1){logger['error'](_0xeef3f1);handleError(_0xeef3f1,!![]);};var _0x3c364a=fs[_0xe60a('0x76')](_0x1ef490);if(_0x3c364a[_0xe60a('0x41')]>0x1){removeReferences(_0x2b2a7a,_0x1ef490);logger[_0xe60a('0x30')](_0xe60a('0x77'));return _0x87f679(new Error(_0xe60a('0x77')));}var _0x2e2930=fs[_0xe60a('0x78')](path[_0xe60a('0x54')](_0x1ef490,_0x3c364a[0x0]));if(_0x2e2930[_0xe60a('0x79')]()){removeReferences(_0x2b2a7a,_0x1ef490);logger[_0xe60a('0x30')](_0xe60a('0x77'));return _0x87f679(new Error(_0xe60a('0x77')));}if(_0x2e2930[_0xe60a('0x7a')]()){var _0x18c3c1=fs[_0xe60a('0x76')](path[_0xe60a('0x54')](_0x1ef490,_0x3c364a[0x0]));if(_0x18c3c1[_0xe60a('0x41')]===0x0){removeReferences(_0x2b2a7a,_0x1ef490);logger['error'](_0xe60a('0x77'));return _0x87f679(new Error(_0xe60a('0x77')));}var _0x7297d=_0x18c3c1['some'](function(_0x18ca29){return _0x18ca29===_0xe60a('0x7b');});if(!_0x7297d){return _0x87f679(new Error('Plugin\x20manifest\x20missing'));}var _0x2d1ac9=fs[_0xe60a('0x7c')](path[_0xe60a('0x54')](_0x1ef490,_0x3c364a[0x0],'manifest.json'));var _0x2bbd59=JSON[_0xe60a('0x7d')](_0x2d1ac9);if(_0xe60a('0x26')==typeof _0x2bbd59['name']){return _0x87f679(new Error(_0xe60a('0x7e')));}if(_0xe60a('0x26')==typeof _0x2bbd59[_0xe60a('0x38')]){return _0x87f679(new Error(_0xe60a('0x7f')));}if(_0xe60a('0x26')==typeof _0x2bbd59['version']){return _0x87f679(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if('undefined'==typeof _0x2bbd59['parameters']){return _0x87f679(new Error(_0xe60a('0x80')));}if(_0x2bbd59['type']===_0xe60a('0x81')){if(_0xe60a('0x26')==typeof _0x2bbd59['parameters'][_0xe60a('0x82')]){return _0x87f679(new Error(_0xe60a('0x83')));}if(_0xe60a('0x26')==typeof _0x2bbd59['parameters']['views'][_0xe60a('0x84')]&&_0xe60a('0x26')==typeof _0x2bbd59['parameters']['views'][_0xe60a('0x85')]){return _0x87f679(new Error(_0xe60a('0x86')));}}else if(_0x2bbd59[_0xe60a('0x38')]===_0xe60a('0x87')){if(_0xe60a('0x26')==typeof _0x2bbd59[_0xe60a('0x88')][_0xe60a('0x89')]){return _0x87f679(new Error(_0xe60a('0x8a')));}if('undefined'==typeof _0x2bbd59[_0xe60a('0x88')][_0xe60a('0x8b')]){return _0x87f679(new Error(_0xe60a('0x8c')));}}else{return _0x87f679(new Error(_0xe60a('0x8d')));}var _0x6eed54=_0x2bbd59[_0xe60a('0x32')];var _0x20c8aa=_0x2bbd59[_0xe60a('0x8e')];var _0x5e15ab=_0x2bbd59[_0xe60a('0x38')];var _0x4f3dae=_0x2bbd59[_0xe60a('0x8f')]?_0x2bbd59['sidebar']:_0xe60a('0x90');var _0x21b66e=_0x2bbd59[_0xe60a('0x91')]?_0x2bbd59['icon']:_0xe60a('0x92');var _0x47a874='';var _0x469593='';var _0x56cbc2='';var _0x570e1d='';var _0x1299d2=_0x2bbd59[_0xe60a('0x93')];if(_0x5e15ab===_0xe60a('0x81')){if(_0xe60a('0x26')!=typeof _0x2bbd59[_0xe60a('0x88')][_0xe60a('0x82')][_0xe60a('0x84')]){var _0x52560c=_0x2bbd59[_0xe60a('0x88')][_0xe60a('0x82')][_0xe60a('0x84')];if(!/^(f|ht)tps?:\/\//i['test'](_0x52560c)){_0x47a874=path[_0xe60a('0x54')]('plugins',_0x52eb59,_0x3c364a[0x0],_0x52560c);}else{_0x47a874=_0x52560c;}}else{logger['info'](_0xe60a('0x94'));}if('undefined'!=typeof _0x2bbd59['parameters'][_0xe60a('0x82')][_0xe60a('0x85')]){var _0x5db8bb=_0x2bbd59['parameters'][_0xe60a('0x82')][_0xe60a('0x85')];if(!/^(f|ht)tps?:\/\//i[_0xe60a('0x95')](_0x5db8bb)){_0x469593=path[_0xe60a('0x54')]('plugins',_0x52eb59,_0x3c364a[0x0],_0x5db8bb);}else{_0x469593=_0x5db8bb;}}else{logger[_0xe60a('0x6d')](_0xe60a('0x96'));}}else if(_0x5e15ab===_0xe60a('0x87')){_0x56cbc2=_0x2bbd59[_0xe60a('0x88')][_0xe60a('0x89')];_0x570e1d=_0x2bbd59[_0xe60a('0x88')][_0xe60a('0x8b')];if(_0xe60a('0x26')!=typeof _0x2bbd59['parameters']['views']){if(_0xe60a('0x26')!=typeof _0x2bbd59['parameters'][_0xe60a('0x82')][_0xe60a('0x84')]){var _0x52560c=_0x2bbd59[_0xe60a('0x88')][_0xe60a('0x82')][_0xe60a('0x84')];if(!/^(f|ht)tps?:\/\//i[_0xe60a('0x95')](_0x52560c)){_0x47a874=path['join'](_0xe60a('0x97'),_0x52eb59,_0x3c364a[0x0],_0x52560c);}else{_0x47a874=_0x52560c;}}if(_0xe60a('0x26')!=typeof _0x2bbd59[_0xe60a('0x88')][_0xe60a('0x82')]['agent']){var _0x5db8bb=_0x2bbd59[_0xe60a('0x88')][_0xe60a('0x82')][_0xe60a('0x85')];if(!/^(f|ht)tps?:\/\//i[_0xe60a('0x95')](_0x5db8bb)){_0x469593=path[_0xe60a('0x54')](_0xe60a('0x97'),_0x52eb59,_0x3c364a[0x0],_0x5db8bb);}else{_0x469593=_0x5db8bb;}}}}var _0x4de905={'name':_0x6eed54,'description':_0x20c8aa,'path':path[_0xe60a('0x54')](_0x52eb59,_0x3c364a[0x0]),'type':_0x5e15ab,'sidebar':_0x4f3dae,'icon':_0x21b66e,'adminUrl':_0x47a874,'agentUrl':_0x469593,'scriptName':_0x56cbc2,'scriptPath':_0x570e1d,'version':_0x1299d2};removeReferences(_0x2b2a7a,null);return db['Plugin'][_0xe60a('0x98')](_0x4de905)['then'](function(_0x134da7){var _0x1e0842={'role':_0x506104['body'][_0xe60a('0x99')],'userProfileId':_0x506104[_0xe60a('0x9a')][_0xe60a('0x9b')]};if(!_0x1e0842)throw new Error(_0xe60a('0x9c'));if(_0x1e0842['role']===_0xe60a('0x9d')){var _0x388604=_0x134da7['get']({'plain':!![]});return db[_0xe60a('0x9e')][_0xe60a('0x53')]({'where':{'name':'Plugins','userProfileId':_0x1e0842['userProfileId']},'raw':!![]})[_0xe60a('0x2b')](function(_0x55d1da){if(_0x55d1da&&_0x55d1da[_0xe60a('0x9f')]===0x0){return db[_0xe60a('0x2f')][_0xe60a('0x98')]({'name':_0x388604['name'],'resourceId':_0x388604['id'],'type':_0x55d1da[_0xe60a('0x32')],'sectionId':_0x55d1da['id']},{})[_0xe60a('0x2b')](function(){return _0x134da7;});}else{return _0x134da7;}})[_0xe60a('0x50')](function(_0x142aaf){logger[_0xe60a('0x30')](_0xe60a('0xa0'),_0x142aaf);throw _0x142aaf;});}return _0x134da7;})['then'](respondWithResult(_0x30bcb4,null))[_0xe60a('0x50')](handleError(_0x30bcb4,null));}});}catch(_0x229f2d){_0x30bcb4[_0xe60a('0x22')](0x1f4)[_0xe60a('0x33')](_0x229f2d);}};function removeReferences(_0x25c770,_0x27bf5f){try{if(_0x25c770){fs['unlinkSync'](_0x25c770);logger[_0xe60a('0x6d')](_0xe60a('0xa1'));}if(_0x27bf5f){rimraf(_0x27bf5f,function(){});logger[_0xe60a('0x6d')](_0xe60a('0xa2'));}}catch(_0x156fd3){logger[_0xe60a('0x30')](_0x156fd3);}}exports[_0xe60a('0xa3')]=function(_0x5936f0,_0x147d40,_0x24e534){return db['Plugin']['find']({'where':{'id':_0x5936f0['params']['id']}})[_0xe60a('0x2b')](handleEntityNotFound(_0x147d40,null))[_0xe60a('0x2b')](saveUpdates(_0x5936f0[_0xe60a('0x9a')],null))[_0xe60a('0x2b')](respondWithResult(_0x147d40,null))['catch'](handleError(_0x147d40,null));};exports[_0xe60a('0xa4')]=function(_0x2e0dc7,_0x23aaa0,_0x4b3db1){return db[_0xe60a('0x4b')][_0xe60a('0x53')]({'where':{'id':_0x2e0dc7[_0xe60a('0x52')]['id']}})[_0xe60a('0x2b')](function(_0x1ed757){if(_0x1ed757){return _0x1ed757['destroy']();}})['then'](function(_0x4b44e4){rimraf(path[_0xe60a('0x54')](config[_0xe60a('0x62')],_0xe60a('0x55'),path[_0xe60a('0x63')](_0x4b44e4[_0xe60a('0x7')])),function(){});return _0x4b44e4;})[_0xe60a('0x2b')](handleEntityNotFound(_0x23aaa0,null))['then'](respondWithStatusCode(_0x23aaa0,null))['catch'](handleError(_0x23aaa0,null));};exports[_0xe60a('0xa5')]=function(_0xfa0785,_0x5de7d6,_0x471a27){return BPromise[_0xe60a('0xa6')]()[_0xe60a('0x2b')](function(){if(!_0xfa0785['query'][_0xe60a('0x7')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0xfa0785[_0xe60a('0x3a')][_0xe60a('0xa7')]){throw new Error(_0xe60a('0xa8'));}var _0x3334e4=_0xfa0785['query'][_0xe60a('0xa9')]?_0xfa0785[_0xe60a('0x3a')][_0xe60a('0xa9')]+':'+_0xfa0785[_0xe60a('0x3a')]['port']:_0xe60a('0xaa')+_0xfa0785[_0xe60a('0x3a')][_0xe60a('0xa7')];var _0x1325ef=_0xfa0785[_0xe60a('0x3a')][_0xe60a('0x24')]?_0xfa0785[_0xe60a('0x3a')][_0xe60a('0x24')]:!![];var _0x24c472=_0xfa0785[_0xe60a('0x3a')][_0xe60a('0xab')]?_0xfa0785[_0xe60a('0x3a')][_0xe60a('0xab')]:null;var _0x118dd0={'method':_0xfa0785['method'],'uri':util[_0xe60a('0x56')]('%s%s',_0x3334e4,_0xfa0785[_0xe60a('0x3a')]['path']),'json':_0x1325ef,'resolveWithFullResponse':!![],'encoding':_0x24c472,'qs':_0xfa0785[_0xe60a('0x3a')]};if(_0xfa0785[_0xe60a('0xac')]){_0x118dd0['headers']=_0xfa0785[_0xe60a('0xac')];if(_0x118dd0['headers'][_0xe60a('0xad')]){delete _0x118dd0['headers'][_0xe60a('0xad')];}}if(_0x118dd0[_0xe60a('0xac')]['content-type']){delete _0x118dd0[_0xe60a('0xac')]['content-type'];}return rp(_0x118dd0);})[_0xe60a('0x2b')](function(_0x2d8be0){if(_0x2d8be0){_0x5de7d6[_0xe60a('0xae')](_0x2d8be0[_0xe60a('0xac')]);logger['info'](_0x2d8be0[_0xe60a('0x9a')]);if(_[_0xe60a('0xaf')](_0xfa0785[_0xe60a('0x3a')]['path'],'download')&&_0x2d8be0[_0xe60a('0xb0')]==0x1f4){return _0x5de7d6['sendStatus'](_0x2d8be0[_0xe60a('0xb0')]);}else{return _0x5de7d6[_0xe60a('0x22')](_0x2d8be0[_0xe60a('0xb0')])[_0xe60a('0x33')](_0x2d8be0['body']);}}else{return _0x5de7d6['sendStatus'](0xc8);}})[_0xe60a('0x50')](handleError(_0x5de7d6,null));};exports[_0xe60a('0xb1')]=function(_0x1cf124,_0x22969e,_0x5a96ba){return BPromise[_0xe60a('0xa6')]()[_0xe60a('0x2b')](function(){if(!_0x1cf124[_0xe60a('0x3a')][_0xe60a('0x7')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x1cf124[_0xe60a('0x3a')][_0xe60a('0xa7')]){throw new Error(_0xe60a('0xa8'));}var _0x39ead4=_0x1cf124['query'][_0xe60a('0xa9')]?_0x1cf124[_0xe60a('0x3a')]['hostname']+':'+_0x1cf124['query'][_0xe60a('0xa7')]:_0xe60a('0xaa')+_0x1cf124[_0xe60a('0x3a')][_0xe60a('0xa7')];var _0x33e21b=_0x1cf124[_0xe60a('0x3a')][_0xe60a('0x24')]?_0x1cf124[_0xe60a('0x3a')][_0xe60a('0x24')]:!![];var _0x20aa66=_0x1cf124[_0xe60a('0x3a')][_0xe60a('0xab')]?_0x1cf124['query']['encoding']:null;var _0x3d5a9b={'method':_0x1cf124['method'],'uri':util[_0xe60a('0x56')](_0xe60a('0xb2'),_0x39ead4,_0x1cf124['query'][_0xe60a('0x7')]),'json':_0x33e21b,'resolveWithFullResponse':!![],'encoding':_0x20aa66,'body':_0x1cf124[_0xe60a('0x9a')]};if(_0x1cf124['headers']){_0x3d5a9b[_0xe60a('0xac')]=_0x1cf124[_0xe60a('0xac')];if(_0x3d5a9b['headers'][_0xe60a('0xad')]){delete _0x3d5a9b[_0xe60a('0xac')][_0xe60a('0xad')];}}if(_0x3d5a9b[_0xe60a('0xac')][_0xe60a('0xb3')]){delete _0x3d5a9b['headers']['content-type'];}return rp(_0x3d5a9b);})[_0xe60a('0x2b')](function(_0x3fa075){if(_0x3fa075){_0x22969e[_0xe60a('0xae')](_0x3fa075['headers']);logger[_0xe60a('0x6d')](_0x3fa075['body']);return _0x22969e[_0xe60a('0x22')](_0x3fa075[_0xe60a('0xb0')])[_0xe60a('0x33')](_0x3fa075[_0xe60a('0x9a')]);}else{return _0x22969e[_0xe60a('0x21')](0xc8);}})['catch'](handleError(_0x22969e,null));};
\ No newline at end of file
+var _0x59db=['Invalid\x20plugin\x20structure','isFile','some','manifest.json','Plugin\x20manifest\x20missing','readFileSync','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','version','Invalid\x20manifest:\x20version\x20not\x20specified','html','parameters','Invalid\x20manifest:\x20views\x20missing','views','admin','agent','script','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','Warning:\x20agent\x20view\x20not\x20specified','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','create','webhookGet','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','encoding','method','%s%s','headers','content-length','content-type','endsWith','statusCode','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','http://localhost:','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','extract-zip','archiver','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../mysqldb','redis','defaults','socket.io-emitter','./plugin.socket','register','sendStatus','status','offset','undefined','count','limit','set','Content-Range','json','reject','save','update','then','destroy','get','Plugins','UserProfileResource','end','error','stack','name','send','map','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','sort','where','pick','type','filter','options','includeAll','include','Plugin','findAll','rows','show','params','rawAttributes','length','find','catch','download','join','root','server/files/plugins','format','%s.zip','basename','createWriteStream','zip','warning','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','**/*','dirname','node_modules/**/*','attachments/**/*','close','existsSync','Plugin\x20not\x20found','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','info','Download\x20completed','upload','file','extname','filename','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','readdirSync'];(function(_0x2f3848,_0x48564d){var _0x102668=function(_0x5e32ab){while(--_0x5e32ab){_0x2f3848['push'](_0x2f3848['shift']());}};_0x102668(++_0x48564d);}(_0x59db,0xda));var _0xb59d=function(_0x2ee4a0,_0xe398a6){_0x2ee4a0=_0x2ee4a0-0x0;var _0x35baa7=_0x59db[_0x2ee4a0];return _0x35baa7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb59d('0x0'));var zipdir=require(_0xb59d('0x1'));var jsonpatch=require(_0xb59d('0x2'));var rp=require(_0xb59d('0x3'));var moment=require(_0xb59d('0x4'));var BPromise=require(_0xb59d('0x5'));var Mustache=require(_0xb59d('0x6'));var util=require('util');var path=require(_0xb59d('0x7'));var sox=require('sox');var csv=require(_0xb59d('0x8'));var ejs=require(_0xb59d('0x9'));var fs=require('fs');var fs_extra=require(_0xb59d('0xa'));var _=require(_0xb59d('0xb'));var squel=require(_0xb59d('0xc'));var crypto=require(_0xb59d('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xb59d('0xe'));var toCsv=require(_0xb59d('0x8'));var querystring=require(_0xb59d('0xf'));var Papa=require(_0xb59d('0x10'));var extract=require(_0xb59d('0x11'));var rimraf=require('rimraf');var archiver=require(_0xb59d('0x12'));var Redis=require(_0xb59d('0x13'));var authService=require(_0xb59d('0x14'));var qs=require(_0xb59d('0x15'));var as=require(_0xb59d('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb59d('0x17'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xb59d('0x18'))['db'];config[_0xb59d('0x19')]=_[_0xb59d('0x1a')](config[_0xb59d('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0xb59d('0x1b'))(new Redis(config[_0xb59d('0x19')]));require(_0xb59d('0x1c'))[_0xb59d('0x1d')](socket);function respondWithStatusCode(_0x57cd1a,_0x33f5e4){_0x33f5e4=_0x33f5e4||0xcc;return function(_0x5efc6e){if(_0x5efc6e){return _0x57cd1a[_0xb59d('0x1e')](_0x33f5e4);}return _0x57cd1a[_0xb59d('0x1f')](_0x33f5e4)['end']();};}function respondWithResult(_0x34adf8,_0x25236d){_0x25236d=_0x25236d||0xc8;return function(_0x482335){if(_0x482335){return _0x34adf8[_0xb59d('0x1f')](_0x25236d)['json'](_0x482335);}};}function respondWithFilteredResult(_0x266c5b,_0x480b14){return function(_0x3a099c){if(_0x3a099c){var _0x581018=typeof _0x480b14[_0xb59d('0x20')]===_0xb59d('0x21')&&typeof _0x480b14['limit']===_0xb59d('0x21');var _0x2a3236=_0x3a099c['count'];var _0x2a08a3=_0x581018?0x0:_0x480b14[_0xb59d('0x20')];var _0x25558f=_0x581018?_0x3a099c[_0xb59d('0x22')]:_0x480b14['offset']+_0x480b14[_0xb59d('0x23')];var _0x272038;if(_0x25558f>=_0x2a3236){_0x25558f=_0x2a3236;_0x272038=0xc8;}else{_0x272038=0xce;}_0x266c5b[_0xb59d('0x1f')](_0x272038);return _0x266c5b[_0xb59d('0x24')](_0xb59d('0x25'),_0x2a08a3+'-'+_0x25558f+'/'+_0x2a3236)[_0xb59d('0x26')](_0x3a099c);}return null;};}function patchUpdates(_0x3b8476){return function(_0x168edf){try{jsonpatch['apply'](_0x168edf,_0x3b8476,!![]);}catch(_0x34edbe){return BPromise[_0xb59d('0x27')](_0x34edbe);}return _0x168edf[_0xb59d('0x28')]();};}function saveUpdates(_0x396022,_0x188fe1){return function(_0x560462){if(_0x560462){return _0x560462[_0xb59d('0x29')](_0x396022)[_0xb59d('0x2a')](function(_0x6c0f43){return _0x6c0f43;});}return null;};}function removeEntity(_0x22367c,_0x5edb97){return function(_0x24e1df){if(_0x24e1df){return _0x24e1df[_0xb59d('0x2b')]()['then'](function(){var _0x172149=_0x24e1df[_0xb59d('0x2c')]({'plain':!![]});var _0x99d4c8=_0xb59d('0x2d');return db[_0xb59d('0x2e')][_0xb59d('0x2b')]({'where':{'type':_0x99d4c8,'resourceId':_0x172149['id']}})['then'](function(){return _0x24e1df;});})[_0xb59d('0x2a')](function(){_0x22367c[_0xb59d('0x1f')](0xcc)[_0xb59d('0x2f')]();});}};}function handleEntityNotFound(_0x68de05,_0x2334aa){return function(_0x2fe29e){if(!_0x2fe29e){_0x68de05[_0xb59d('0x1e')](0x194);}return _0x2fe29e;};}function handleError(_0x5e18b5,_0x24b530){_0x24b530=_0x24b530||0x1f4;return function(_0x2fe119){logger[_0xb59d('0x30')](_0x2fe119[_0xb59d('0x31')]);if(_0x2fe119['name']){delete _0x2fe119[_0xb59d('0x32')];}_0x5e18b5[_0xb59d('0x1f')](_0x24b530)[_0xb59d('0x33')](_0x2fe119);};}exports['index']=function(_0x54d65b,_0x148199){var _0x2f0a35={},_0x42b27e={},_0x540838={'count':0x0,'rows':[]};var _0x380df6=_[_0xb59d('0x34')](db['Plugin']['rawAttributes'],function(_0x5b9429){return{'name':_0x5b9429['fieldName'],'type':_0x5b9429['type']['key']};});_0x42b27e[_0xb59d('0x35')]=_[_0xb59d('0x34')](_0x380df6,_0xb59d('0x32'));_0x42b27e[_0xb59d('0x36')]=_[_0xb59d('0x37')](_0x54d65b['query']);_0x42b27e[_0xb59d('0x38')]=_[_0xb59d('0x39')](_0x42b27e[_0xb59d('0x35')],_0x42b27e[_0xb59d('0x36')]);_0x2f0a35[_0xb59d('0x3a')]=_[_0xb59d('0x39')](_0x42b27e[_0xb59d('0x35')],qs[_0xb59d('0x3b')](_0x54d65b[_0xb59d('0x36')]['fields']));_0x2f0a35['attributes']=_0x2f0a35[_0xb59d('0x3a')]['length']?_0x2f0a35[_0xb59d('0x3a')]:_0x42b27e['model'];if(!_0x54d65b[_0xb59d('0x36')][_0xb59d('0x3c')]('nolimit')){_0x2f0a35[_0xb59d('0x23')]=qs[_0xb59d('0x23')](_0x54d65b[_0xb59d('0x36')][_0xb59d('0x23')]);_0x2f0a35['offset']=qs[_0xb59d('0x20')](_0x54d65b[_0xb59d('0x36')][_0xb59d('0x20')]);}_0x2f0a35['order']=qs[_0xb59d('0x3d')](_0x54d65b[_0xb59d('0x36')][_0xb59d('0x3d')]);_0x2f0a35[_0xb59d('0x3e')]=qs[_0xb59d('0x38')](_[_0xb59d('0x3f')](_0x54d65b['query'],_0x42b27e[_0xb59d('0x38')]),_0x380df6);if(_0x54d65b['query']['filter']){_0x2f0a35['where']=_['merge'](_0x2f0a35['where'],{'$or':_[_0xb59d('0x34')](_0x380df6,function(_0x12a920){if(_0x12a920[_0xb59d('0x40')]!=='VIRTUAL'){var _0x4f959f={};_0x4f959f[_0x12a920[_0xb59d('0x32')]]={'$like':'%'+_0x54d65b[_0xb59d('0x36')][_0xb59d('0x41')]+'%'};return _0x4f959f;}})});}_0x2f0a35=_['merge']({},_0x2f0a35,_0x54d65b[_0xb59d('0x42')]);var _0x303168={'where':_0x2f0a35['where']};return db['Plugin']['count'](_0x303168)[_0xb59d('0x2a')](function(_0x5564e6){_0x540838[_0xb59d('0x22')]=_0x5564e6;if(_0x54d65b[_0xb59d('0x36')][_0xb59d('0x43')]){_0x2f0a35[_0xb59d('0x44')]=[{'all':!![]}];}return db[_0xb59d('0x45')][_0xb59d('0x46')](_0x2f0a35);})['then'](function(_0x62f0b6){_0x540838[_0xb59d('0x47')]=_0x62f0b6;return _0x540838;})['then'](respondWithFilteredResult(_0x148199,_0x2f0a35))['catch'](handleError(_0x148199,null));};exports[_0xb59d('0x48')]=function(_0x553f0d,_0x2a5c8e){var _0x50153f={'raw':!![],'where':{'id':_0x553f0d[_0xb59d('0x49')]['id']}},_0x5065c4={};_0x5065c4['model']=_['keys'](db[_0xb59d('0x45')][_0xb59d('0x4a')]);_0x5065c4[_0xb59d('0x36')]=_[_0xb59d('0x37')](_0x553f0d[_0xb59d('0x36')]);_0x5065c4[_0xb59d('0x38')]=_[_0xb59d('0x39')](_0x5065c4[_0xb59d('0x35')],_0x5065c4[_0xb59d('0x36')]);_0x50153f[_0xb59d('0x3a')]=_['intersection'](_0x5065c4['model'],qs[_0xb59d('0x3b')](_0x553f0d[_0xb59d('0x36')]['fields']));_0x50153f[_0xb59d('0x3a')]=_0x50153f[_0xb59d('0x3a')][_0xb59d('0x4b')]?_0x50153f[_0xb59d('0x3a')]:_0x5065c4[_0xb59d('0x35')];if(_0x553f0d['query'][_0xb59d('0x43')]){_0x50153f[_0xb59d('0x44')]=[{'all':!![]}];}_0x50153f=_['merge']({},_0x50153f,_0x553f0d[_0xb59d('0x42')]);return db[_0xb59d('0x45')][_0xb59d('0x4c')](_0x50153f)['then'](handleEntityNotFound(_0x2a5c8e,null))[_0xb59d('0x2a')](respondWithResult(_0x2a5c8e,null))[_0xb59d('0x4d')](handleError(_0x2a5c8e,null));};exports[_0xb59d('0x4e')]=function(_0x2b8e15,_0x281af5,_0x40b570){return db[_0xb59d('0x45')][_0xb59d('0x4c')]({'where':{'id':_0x2b8e15[_0xb59d('0x49')]['id']},'attributes':[_0xb59d('0x32'),_0xb59d('0x7')],'raw':!![]})['then'](handleEntityNotFound(_0x281af5,null))['then'](function(_0x58fdc7){if(_0x58fdc7){var _0x2477f6=path[_0xb59d('0x4f')](config[_0xb59d('0x50')],_0xb59d('0x51'),util[_0xb59d('0x52')](_0xb59d('0x53'),path[_0xb59d('0x54')](_0x58fdc7[_0xb59d('0x7')])));var _0x241f2e=fs[_0xb59d('0x55')](_0x2477f6);var _0x585995=archiver(_0xb59d('0x56'),{'zlib':{'level':0x9}});_0x585995['on'](_0xb59d('0x57'),function(_0x1b811d){if(_0x1b811d['code']===_0xb59d('0x58')){logger[_0xb59d('0x30')](_0x1b811d);}else{throw new db[(_0xb59d('0x59'))][(_0xb59d('0x5a'))]('Error\x20while\x20generating\x20the\x20zip\x20archive');}});_0x585995['on'](_0xb59d('0x30'),function(_0x5eda40){throw new db[(_0xb59d('0x59'))][(_0xb59d('0x5a'))](_0xb59d('0x5b'));});_0x585995['pipe'](_0x241f2e);_0x585995['glob'](_0xb59d('0x5c'),{'cwd':path['join'](config[_0xb59d('0x50')],'server/files/plugins',path[_0xb59d('0x5d')](_0x58fdc7[_0xb59d('0x7')])),'ignore':[path[_0xb59d('0x4f')](path['basename'](_0x58fdc7[_0xb59d('0x7')]),_0xb59d('0x5e')),path[_0xb59d('0x4f')](path[_0xb59d('0x54')](_0x58fdc7[_0xb59d('0x7')]),_0xb59d('0x5f'))],'nodir':!![]})['finalize']();_0x241f2e['on'](_0xb59d('0x60'),function(){if(!fs[_0xb59d('0x61')](_0x2477f6)){throw new db['Sequelize'][(_0xb59d('0x5a'))](_0xb59d('0x62'));}return _0x281af5[_0xb59d('0x4e')](_0x2477f6,util[_0xb59d('0x52')](_0xb59d('0x53'),path[_0xb59d('0x54')](_0x58fdc7[_0xb59d('0x7')])),function(_0x1001f7){if(_0x1001f7){throw new db['Sequelize']['Error'](_0xb59d('0x63'));}fs[_0xb59d('0x64')](_0x2477f6);logger[_0xb59d('0x65')](_0xb59d('0x66'));logger[_0xb59d('0x65')]('Temporary\x20file\x20removed');});});}return null;})[_0xb59d('0x4d')](handleError(_0x281af5,null));};exports[_0xb59d('0x67')]=function(_0x2cd334,_0xde8f63,_0x55e3fb){var _0x317100=path['basename'](_0x2cd334[_0xb59d('0x68')]['filename'],path[_0xb59d('0x69')](_0x2cd334['file']['filename']));var _0x37edf9=path['join'](config[_0xb59d('0x50')],_0xb59d('0x51'),_0x2cd334[_0xb59d('0x68')][_0xb59d('0x6a')]);var _0x223668=path[_0xb59d('0x4f')](config[_0xb59d('0x50')],_0xb59d('0x51'),_0x317100);logger[_0xb59d('0x65')](_0xb59d('0x6b'),_0x37edf9);logger[_0xb59d('0x65')](_0xb59d('0x6c'),_0x223668);try{fs[_0xb59d('0x6d')](_0x37edf9,parseInt(_0xb59d('0x6e'),0x8));extract(_0x37edf9,{'dir':_0x223668},function(_0x115aa0){if(_0x115aa0){logger['error'](_0x115aa0);handleError(_0x115aa0,!![]);};var _0xe37756=fs[_0xb59d('0x6f')](_0x223668);if(_0xe37756[_0xb59d('0x4b')]>0x1){removeReferences(_0x37edf9,_0x223668);logger[_0xb59d('0x30')](_0xb59d('0x70'));return _0x55e3fb(new Error(_0xb59d('0x70')));}var _0x2d6398=fs['lstatSync'](path[_0xb59d('0x4f')](_0x223668,_0xe37756[0x0]));if(_0x2d6398[_0xb59d('0x71')]()){removeReferences(_0x37edf9,_0x223668);logger['error']('Invalid\x20plugin\x20structure');return _0x55e3fb(new Error(_0xb59d('0x70')));}if(_0x2d6398['isDirectory']()){var _0x4cad07=fs[_0xb59d('0x6f')](path['join'](_0x223668,_0xe37756[0x0]));if(_0x4cad07['length']===0x0){removeReferences(_0x37edf9,_0x223668);logger[_0xb59d('0x30')](_0xb59d('0x70'));return _0x55e3fb(new Error(_0xb59d('0x70')));}var _0x435577=_0x4cad07[_0xb59d('0x72')](function(_0x4a6fd0){return _0x4a6fd0===_0xb59d('0x73');});if(!_0x435577){return _0x55e3fb(new Error(_0xb59d('0x74')));}var _0x12a7d6=fs[_0xb59d('0x75')](path[_0xb59d('0x4f')](_0x223668,_0xe37756[0x0],'manifest.json'));var _0x4846b5=JSON['parse'](_0x12a7d6);if(_0xb59d('0x21')==typeof _0x4846b5[_0xb59d('0x32')]){return _0x55e3fb(new Error(_0xb59d('0x76')));}if(_0xb59d('0x21')==typeof _0x4846b5[_0xb59d('0x40')]){return _0x55e3fb(new Error(_0xb59d('0x77')));}if(_0xb59d('0x21')==typeof _0x4846b5[_0xb59d('0x78')]){return _0x55e3fb(new Error(_0xb59d('0x79')));}if(_0xb59d('0x21')==typeof _0x4846b5['parameters']){return _0x55e3fb(new Error('Invalid\x20manifest:\x20parameters\x20missing'));}if(_0x4846b5[_0xb59d('0x40')]===_0xb59d('0x7a')){if(_0xb59d('0x21')==typeof _0x4846b5[_0xb59d('0x7b')]['views']){return _0x55e3fb(new Error(_0xb59d('0x7c')));}if(_0xb59d('0x21')==typeof _0x4846b5[_0xb59d('0x7b')][_0xb59d('0x7d')][_0xb59d('0x7e')]&&_0xb59d('0x21')==typeof _0x4846b5[_0xb59d('0x7b')]['views'][_0xb59d('0x7f')]){return _0x55e3fb(new Error('Invalid\x20manifest:\x20no\x20view\x20specified'));}}else if(_0x4846b5['type']===_0xb59d('0x80')){if(_0xb59d('0x21')==typeof _0x4846b5['parameters'][_0xb59d('0x81')]){return _0x55e3fb(new Error(_0xb59d('0x82')));}if('undefined'==typeof _0x4846b5['parameters'][_0xb59d('0x83')]){return _0x55e3fb(new Error(_0xb59d('0x84')));}}else{return _0x55e3fb(new Error(_0xb59d('0x85')));}var _0x1a2bfc=_0x4846b5['name'];var _0x4031cd=_0x4846b5[_0xb59d('0x86')];var _0x360f40=_0x4846b5[_0xb59d('0x40')];var _0x4d3d0d=_0x4846b5[_0xb59d('0x87')]?_0x4846b5[_0xb59d('0x87')]:_0xb59d('0x88');var _0x18bc33=_0x4846b5[_0xb59d('0x89')]?_0x4846b5[_0xb59d('0x89')]:_0xb59d('0x8a');var _0x557c5c='';var _0x1fcc35='';var _0x10348b='';var _0x18c85e='';var _0x53a619=_0x4846b5['version'];if(_0x360f40===_0xb59d('0x7a')){if(_0xb59d('0x21')!=typeof _0x4846b5[_0xb59d('0x7b')]['views'][_0xb59d('0x7e')]){var _0x3774cf=_0x4846b5[_0xb59d('0x7b')]['views'][_0xb59d('0x7e')];if(!/^(f|ht)tps?:\/\//i[_0xb59d('0x8b')](_0x3774cf)){_0x557c5c=path[_0xb59d('0x4f')](_0xb59d('0x8c'),_0x317100,_0xe37756[0x0],_0x3774cf);}else{_0x557c5c=_0x3774cf;}}else{logger[_0xb59d('0x65')](_0xb59d('0x8d'));}if('undefined'!=typeof _0x4846b5['parameters'][_0xb59d('0x7d')][_0xb59d('0x7f')]){var _0x57293f=_0x4846b5['parameters'][_0xb59d('0x7d')][_0xb59d('0x7f')];if(!/^(f|ht)tps?:\/\//i[_0xb59d('0x8b')](_0x57293f)){_0x1fcc35=path['join'](_0xb59d('0x8c'),_0x317100,_0xe37756[0x0],_0x57293f);}else{_0x1fcc35=_0x57293f;}}else{logger[_0xb59d('0x65')](_0xb59d('0x8e'));}}else if(_0x360f40===_0xb59d('0x80')){_0x10348b=_0x4846b5[_0xb59d('0x7b')]['scriptName'];_0x18c85e=_0x4846b5[_0xb59d('0x7b')][_0xb59d('0x83')];if(_0xb59d('0x21')!=typeof _0x4846b5['parameters'][_0xb59d('0x7d')]){if('undefined'!=typeof _0x4846b5[_0xb59d('0x7b')][_0xb59d('0x7d')][_0xb59d('0x7e')]){var _0x3774cf=_0x4846b5[_0xb59d('0x7b')][_0xb59d('0x7d')][_0xb59d('0x7e')];if(!/^(f|ht)tps?:\/\//i['test'](_0x3774cf)){_0x557c5c=path['join'](_0xb59d('0x8c'),_0x317100,_0xe37756[0x0],_0x3774cf);}else{_0x557c5c=_0x3774cf;}}if(_0xb59d('0x21')!=typeof _0x4846b5['parameters']['views'][_0xb59d('0x7f')]){var _0x57293f=_0x4846b5[_0xb59d('0x7b')][_0xb59d('0x7d')]['agent'];if(!/^(f|ht)tps?:\/\//i['test'](_0x57293f)){_0x1fcc35=path[_0xb59d('0x4f')]('plugins',_0x317100,_0xe37756[0x0],_0x57293f);}else{_0x1fcc35=_0x57293f;}}}}var _0x5dbcd5={'name':_0x1a2bfc,'description':_0x4031cd,'path':path[_0xb59d('0x4f')](_0x317100,_0xe37756[0x0]),'type':_0x360f40,'sidebar':_0x4d3d0d,'icon':_0x18bc33,'adminUrl':_0x557c5c,'agentUrl':_0x1fcc35,'scriptName':_0x10348b,'scriptPath':_0x18c85e,'version':_0x53a619};removeReferences(_0x37edf9,null);return db[_0xb59d('0x45')]['create'](_0x5dbcd5)[_0xb59d('0x2a')](function(_0x4c7cf4){var _0x4b42a6={'role':_0x2cd334[_0xb59d('0x8f')][_0xb59d('0x90')],'userProfileId':_0x2cd334[_0xb59d('0x8f')][_0xb59d('0x91')]};if(!_0x4b42a6)throw new Error(_0xb59d('0x92'));if(_0x4b42a6[_0xb59d('0x90')]===_0xb59d('0x93')){var _0x459008=_0x4c7cf4['get']({'plain':!![]});return db[_0xb59d('0x94')][_0xb59d('0x4c')]({'where':{'name':'Plugins','userProfileId':_0x4b42a6['userProfileId']},'raw':!![]})[_0xb59d('0x2a')](function(_0x144e20){if(_0x144e20&&_0x144e20['autoAssociation']===0x0){return db[_0xb59d('0x2e')][_0xb59d('0x95')]({'name':_0x459008['name'],'resourceId':_0x459008['id'],'type':_0x144e20['name'],'sectionId':_0x144e20['id']},{})['then'](function(){return _0x4c7cf4;});}else{return _0x4c7cf4;}})[_0xb59d('0x4d')](function(_0x233454){logger[_0xb59d('0x30')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x233454);throw _0x233454;});}return _0x4c7cf4;})[_0xb59d('0x2a')](respondWithResult(_0xde8f63,null))['catch'](handleError(_0xde8f63,null));}});}catch(_0x2d15f3){_0xde8f63[_0xb59d('0x1f')](0x1f4)[_0xb59d('0x33')](_0x2d15f3);}};function removeReferences(_0xd95468,_0x388069){try{if(_0xd95468){fs['unlinkSync'](_0xd95468);logger[_0xb59d('0x65')]('Zip\x20archive\x20removed');}if(_0x388069){rimraf(_0x388069,function(){});logger[_0xb59d('0x65')]('Extracted\x20folder\x20removed');}}catch(_0x5941f1){logger[_0xb59d('0x30')](_0x5941f1);}}exports[_0xb59d('0x29')]=function(_0x5e08ad,_0x2e0107,_0x32b4e4){return db[_0xb59d('0x45')][_0xb59d('0x4c')]({'where':{'id':_0x5e08ad[_0xb59d('0x49')]['id']}})[_0xb59d('0x2a')](handleEntityNotFound(_0x2e0107,null))['then'](saveUpdates(_0x5e08ad[_0xb59d('0x8f')],null))[_0xb59d('0x2a')](respondWithResult(_0x2e0107,null))[_0xb59d('0x4d')](handleError(_0x2e0107,null));};exports['delete']=function(_0x30ec24,_0x3d2170,_0x191364){return db['Plugin']['find']({'where':{'id':_0x30ec24[_0xb59d('0x49')]['id']}})[_0xb59d('0x2a')](function(_0x18a422){if(_0x18a422){return _0x18a422[_0xb59d('0x2b')]();}})[_0xb59d('0x2a')](function(_0x218e46){rimraf(path['join'](config[_0xb59d('0x50')],'server/files/plugins',path[_0xb59d('0x5d')](_0x218e46[_0xb59d('0x7')])),function(){});return _0x218e46;})[_0xb59d('0x2a')](handleEntityNotFound(_0x3d2170,null))[_0xb59d('0x2a')](respondWithStatusCode(_0x3d2170,null))[_0xb59d('0x4d')](handleError(_0x3d2170,null));};exports[_0xb59d('0x96')]=function(_0x40d5f2,_0x5644d8,_0x299e5c){return BPromise['resolve']()[_0xb59d('0x2a')](function(){if(!_0x40d5f2['query'][_0xb59d('0x7')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x97')]){throw new Error(_0xb59d('0x98'));}var _0x37f443=_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x99')]?_0x40d5f2['query'][_0xb59d('0x99')]+':'+_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x97')]:'http://localhost:'+_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x97')];var _0x547176=_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x26')]?_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x26')]:!![];var _0x459aa2=_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x9a')]?_0x40d5f2[_0xb59d('0x36')][_0xb59d('0x9a')]:null;var _0x263191={'method':_0x40d5f2[_0xb59d('0x9b')],'uri':util['format'](_0xb59d('0x9c'),_0x37f443,_0x40d5f2['query'][_0xb59d('0x7')]),'json':_0x547176,'resolveWithFullResponse':!![],'encoding':_0x459aa2,'qs':_0x40d5f2[_0xb59d('0x36')]};if(_0x40d5f2['headers']){_0x263191[_0xb59d('0x9d')]=_0x40d5f2[_0xb59d('0x9d')];if(_0x263191[_0xb59d('0x9d')]['content-length']){delete _0x263191[_0xb59d('0x9d')][_0xb59d('0x9e')];}}if(_0x263191[_0xb59d('0x9d')][_0xb59d('0x9f')]){delete _0x263191[_0xb59d('0x9d')]['content-type'];}return rp(_0x263191);})[_0xb59d('0x2a')](function(_0x30ce9a){if(_0x30ce9a){_0x5644d8[_0xb59d('0x24')](_0x30ce9a[_0xb59d('0x9d')]);logger['info'](_0x30ce9a['body']);if(_[_0xb59d('0xa0')](_0x40d5f2[_0xb59d('0x36')]['path'],_0xb59d('0x4e'))&&_0x30ce9a[_0xb59d('0xa1')]==0x1f4){return _0x5644d8['sendStatus'](_0x30ce9a[_0xb59d('0xa1')]);}else{return _0x5644d8[_0xb59d('0x1f')](_0x30ce9a[_0xb59d('0xa1')])[_0xb59d('0x33')](_0x30ce9a[_0xb59d('0x8f')]);}}else{return _0x5644d8[_0xb59d('0x1e')](0xc8);}})['catch'](handleError(_0x5644d8,null));};exports['webhookPost']=function(_0x2ea001,_0x249dd9,_0x3d5423){return BPromise[_0xb59d('0xa2')]()[_0xb59d('0x2a')](function(){if(!_0x2ea001[_0xb59d('0x36')][_0xb59d('0x7')]){throw new Error(_0xb59d('0xa3'));}if(!_0x2ea001['query'][_0xb59d('0x97')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x3808f5=_0x2ea001[_0xb59d('0x36')][_0xb59d('0x99')]?_0x2ea001['query'][_0xb59d('0x99')]+':'+_0x2ea001['query'][_0xb59d('0x97')]:_0xb59d('0xa4')+_0x2ea001['query'][_0xb59d('0x97')];var _0x1790b6=_0x2ea001[_0xb59d('0x36')]['json']?_0x2ea001[_0xb59d('0x36')][_0xb59d('0x26')]:!![];var _0x542ca9=_0x2ea001[_0xb59d('0x36')][_0xb59d('0x9a')]?_0x2ea001[_0xb59d('0x36')]['encoding']:null;var _0x5dd463={'method':_0x2ea001[_0xb59d('0x9b')],'uri':util[_0xb59d('0x52')](_0xb59d('0x9c'),_0x3808f5,_0x2ea001[_0xb59d('0x36')][_0xb59d('0x7')]),'json':_0x1790b6,'resolveWithFullResponse':!![],'encoding':_0x542ca9,'body':_0x2ea001[_0xb59d('0x8f')]};if(_0x2ea001['headers']){_0x5dd463[_0xb59d('0x9d')]=_0x2ea001[_0xb59d('0x9d')];if(_0x5dd463[_0xb59d('0x9d')][_0xb59d('0x9e')]){delete _0x5dd463[_0xb59d('0x9d')][_0xb59d('0x9e')];}}if(_0x5dd463[_0xb59d('0x9d')][_0xb59d('0x9f')]){delete _0x5dd463[_0xb59d('0x9d')][_0xb59d('0x9f')];}return rp(_0x5dd463);})['then'](function(_0x4c37f7){if(_0x4c37f7){_0x249dd9[_0xb59d('0x24')](_0x4c37f7[_0xb59d('0x9d')]);logger[_0xb59d('0x65')](_0x4c37f7[_0xb59d('0x8f')]);return _0x249dd9['status'](_0x4c37f7['statusCode'])['send'](_0x4c37f7[_0xb59d('0x8f')]);}else{return _0x249dd9['sendStatus'](0xc8);}})[_0xb59d('0x4d')](handleError(_0x249dd9,null));};
\ No newline at end of file