Built motion from commit 377f727e.|2.6.28
[motion2.git] / server / api / plugin / plugin.controller.js
index 7ca2a20..80dfc68 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4cfb=['then','get','UserProfileResource','error','stack','name','index','map','rawAttributes','fieldName','type','key','model','query','keys','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filters','merge','filter','options','count','includeAll','Plugin','findAll','rows','catch','show','params','intersection','include','find','download','join','root','%s.zip','basename','createWriteStream','warning','code','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','**/*','node_modules/**/*','attachments/**/*','finalize','close','format','unlinkSync','Download\x20completed','Temporary\x20file\x20removed','upload','file','filename','extname','server/files/plugins','info','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','readdirSync','Invalid\x20plugin\x20structure','lstatSync','some','Plugin\x20manifest\x20missing','readFileSync','manifest.json','Invalid\x20manifest:\x20parameters\x20missing','html','parameters','Invalid\x20manifest:\x20views\x20missing','views','admin','script','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','test','Warning:\x20admin\x20view\x20not\x20specified','agent','plugins','Warning:\x20agent\x20view\x20not\x20specified','create','body','role','userProfileId','user','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','send','Zip\x20archive\x20removed','Extracted\x20folder\x20removed','delete','dirname','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','port','json','encoding','method','headers','content-length','content-type','endsWith','statusCode','webhookPost','http://localhost:','rimraf','zip-dir','fast-json-patch','request-promise','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','papaparse','extract-zip','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','defaults','redis','socket.io-emitter','./plugin.socket','register','sendStatus','status','offset','undefined','limit','set','Content-Range','apply','reject','save','update','destroy'];(function(_0x5bd426,_0x4878e5){var _0x23a7eb=function(_0x594b42){while(--_0x594b42){_0x5bd426['push'](_0x5bd426['shift']());}};_0x23a7eb(++_0x4878e5);}(_0x4cfb,0x1c5));var _0xb4cf=function(_0x2f5ac5,_0x1ee939){_0x2f5ac5=_0x2f5ac5-0x0;var _0x37c9a8=_0x4cfb[_0x2f5ac5];return _0x37c9a8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb4cf('0x0'));var zipdir=require(_0xb4cf('0x1'));var jsonpatch=require(_0xb4cf('0x2'));var rp=require(_0xb4cf('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0xb4cf('0x4'));var sox=require(_0xb4cf('0x5'));var csv=require(_0xb4cf('0x6'));var ejs=require(_0xb4cf('0x7'));var fs=require('fs');var fs_extra=require(_0xb4cf('0x8'));var _=require(_0xb4cf('0x9'));var squel=require('squel');var crypto=require(_0xb4cf('0xa'));var jsforce=require(_0xb4cf('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xb4cf('0x6'));var querystring=require('querystring');var Papa=require(_0xb4cf('0xc'));var extract=require(_0xb4cf('0xd'));var rimraf=require('rimraf');var archiver=require('archiver');var Redis=require(_0xb4cf('0xe'));var authService=require(_0xb4cf('0xf'));var qs=require(_0xb4cf('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb4cf('0x11'));var logger=require(_0xb4cf('0x12'))('api');var utils=require(_0xb4cf('0x13'));var config=require(_0xb4cf('0x14'));var licenseUtil=require(_0xb4cf('0x15'));var db=require('../../mysqldb')['db'];config['redis']=_[_0xb4cf('0x16')](config[_0xb4cf('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0xb4cf('0x18'))(new Redis(config['redis']));require(_0xb4cf('0x19'))[_0xb4cf('0x1a')](socket);function respondWithStatusCode(_0x5138a6,_0x3b2bf0){_0x3b2bf0=_0x3b2bf0||0xcc;return function(_0xaf6fa5){if(_0xaf6fa5){return _0x5138a6[_0xb4cf('0x1b')](_0x3b2bf0);}return _0x5138a6['status'](_0x3b2bf0)['end']();};}function respondWithResult(_0x46653f,_0x3375c3){_0x3375c3=_0x3375c3||0xc8;return function(_0x4a78dc){if(_0x4a78dc){return _0x46653f[_0xb4cf('0x1c')](_0x3375c3)['json'](_0x4a78dc);}};}function respondWithFilteredResult(_0x1b579e,_0x8a5a38){return function(_0x280be6){if(_0x280be6){var _0x260907=typeof _0x8a5a38[_0xb4cf('0x1d')]===_0xb4cf('0x1e')&&typeof _0x8a5a38[_0xb4cf('0x1f')]===_0xb4cf('0x1e');var _0xa6494b=_0x280be6['count'];var _0x4aa357=_0x260907?0x0:_0x8a5a38['offset'];var _0x34ac88=_0x260907?_0x280be6['count']:_0x8a5a38[_0xb4cf('0x1d')]+_0x8a5a38[_0xb4cf('0x1f')];var _0x485472;if(_0x34ac88>=_0xa6494b){_0x34ac88=_0xa6494b;_0x485472=0xc8;}else{_0x485472=0xce;}_0x1b579e[_0xb4cf('0x1c')](_0x485472);return _0x1b579e[_0xb4cf('0x20')](_0xb4cf('0x21'),_0x4aa357+'-'+_0x34ac88+'/'+_0xa6494b)['json'](_0x280be6);}return null;};}function patchUpdates(_0xcea52c){return function(_0x4b03fb){try{jsonpatch[_0xb4cf('0x22')](_0x4b03fb,_0xcea52c,!![]);}catch(_0x5ca9b3){return BPromise[_0xb4cf('0x23')](_0x5ca9b3);}return _0x4b03fb[_0xb4cf('0x24')]();};}function saveUpdates(_0x3e4093,_0x5c0afd){return function(_0x2ab903){if(_0x2ab903){return _0x2ab903[_0xb4cf('0x25')](_0x3e4093)['then'](function(_0x465f1f){return _0x465f1f;});}return null;};}function removeEntity(_0x7d57f3,_0x72ec68){return function(_0x23ce65){if(_0x23ce65){return _0x23ce65[_0xb4cf('0x26')]()[_0xb4cf('0x27')](function(){var _0x381a6e=_0x23ce65[_0xb4cf('0x28')]({'plain':!![]});var _0x4877ad='Plugins';return db[_0xb4cf('0x29')][_0xb4cf('0x26')]({'where':{'type':_0x4877ad,'resourceId':_0x381a6e['id']}})['then'](function(){return _0x23ce65;});})[_0xb4cf('0x27')](function(){_0x7d57f3[_0xb4cf('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x490ef6,_0x206004){return function(_0x40b9eb){if(!_0x40b9eb){_0x490ef6['sendStatus'](0x194);}return _0x40b9eb;};}function handleError(_0x41ee1d,_0x526bb2){_0x526bb2=_0x526bb2||0x1f4;return function(_0x1b388a){logger[_0xb4cf('0x2a')](_0x1b388a[_0xb4cf('0x2b')]);if(_0x1b388a[_0xb4cf('0x2c')]){delete _0x1b388a['name'];}_0x41ee1d[_0xb4cf('0x1c')](_0x526bb2)['send'](_0x1b388a);};}exports[_0xb4cf('0x2d')]=function(_0x20f9c4,_0x44994f){var _0x246e1c={},_0x4665ef={},_0x3a1d81={'count':0x0,'rows':[]};var _0x1cc15f=_[_0xb4cf('0x2e')](db['Plugin'][_0xb4cf('0x2f')],function(_0x145e3e){return{'name':_0x145e3e[_0xb4cf('0x30')],'type':_0x145e3e[_0xb4cf('0x31')][_0xb4cf('0x32')]};});_0x4665ef[_0xb4cf('0x33')]=_[_0xb4cf('0x2e')](_0x1cc15f,_0xb4cf('0x2c'));_0x4665ef[_0xb4cf('0x34')]=_[_0xb4cf('0x35')](_0x20f9c4[_0xb4cf('0x34')]);_0x4665ef['filters']=_['intersection'](_0x4665ef[_0xb4cf('0x33')],_0x4665ef[_0xb4cf('0x34')]);_0x246e1c[_0xb4cf('0x36')]=_['intersection'](_0x4665ef['model'],qs[_0xb4cf('0x37')](_0x20f9c4['query'][_0xb4cf('0x37')]));_0x246e1c[_0xb4cf('0x36')]=_0x246e1c[_0xb4cf('0x36')][_0xb4cf('0x38')]?_0x246e1c[_0xb4cf('0x36')]:_0x4665ef[_0xb4cf('0x33')];if(!_0x20f9c4[_0xb4cf('0x34')][_0xb4cf('0x39')]('nolimit')){_0x246e1c[_0xb4cf('0x1f')]=qs['limit'](_0x20f9c4['query']['limit']);_0x246e1c[_0xb4cf('0x1d')]=qs[_0xb4cf('0x1d')](_0x20f9c4[_0xb4cf('0x34')][_0xb4cf('0x1d')]);}_0x246e1c[_0xb4cf('0x3a')]=qs[_0xb4cf('0x3b')](_0x20f9c4[_0xb4cf('0x34')][_0xb4cf('0x3b')]);_0x246e1c[_0xb4cf('0x3c')]=qs['filters'](_[_0xb4cf('0x3d')](_0x20f9c4[_0xb4cf('0x34')],_0x4665ef[_0xb4cf('0x3e')]),_0x1cc15f);if(_0x20f9c4[_0xb4cf('0x34')]['filter']){_0x246e1c[_0xb4cf('0x3c')]=_[_0xb4cf('0x3f')](_0x246e1c['where'],{'$or':_[_0xb4cf('0x2e')](_0x1cc15f,function(_0x2cc5d7){if(_0x2cc5d7[_0xb4cf('0x31')]!=='VIRTUAL'){var _0xa89d7b={};_0xa89d7b[_0x2cc5d7[_0xb4cf('0x2c')]]={'$like':'%'+_0x20f9c4[_0xb4cf('0x34')][_0xb4cf('0x40')]+'%'};return _0xa89d7b;}})});}_0x246e1c=_['merge']({},_0x246e1c,_0x20f9c4[_0xb4cf('0x41')]);var _0x919899={'where':_0x246e1c['where']};return db['Plugin'][_0xb4cf('0x42')](_0x919899)[_0xb4cf('0x27')](function(_0x356d6a){_0x3a1d81['count']=_0x356d6a;if(_0x20f9c4[_0xb4cf('0x34')][_0xb4cf('0x43')]){_0x246e1c['include']=[{'all':!![]}];}return db[_0xb4cf('0x44')][_0xb4cf('0x45')](_0x246e1c);})['then'](function(_0x1a311d){_0x3a1d81[_0xb4cf('0x46')]=_0x1a311d;return _0x3a1d81;})['then'](respondWithFilteredResult(_0x44994f,_0x246e1c))[_0xb4cf('0x47')](handleError(_0x44994f,null));};exports[_0xb4cf('0x48')]=function(_0xc67365,_0x56fdd3){var _0x282f79={'raw':!![],'where':{'id':_0xc67365[_0xb4cf('0x49')]['id']}},_0x2998af={};_0x2998af[_0xb4cf('0x33')]=_[_0xb4cf('0x35')](db[_0xb4cf('0x44')]['rawAttributes']);_0x2998af['query']=_[_0xb4cf('0x35')](_0xc67365[_0xb4cf('0x34')]);_0x2998af[_0xb4cf('0x3e')]=_[_0xb4cf('0x4a')](_0x2998af[_0xb4cf('0x33')],_0x2998af['query']);_0x282f79['attributes']=_[_0xb4cf('0x4a')](_0x2998af[_0xb4cf('0x33')],qs['fields'](_0xc67365[_0xb4cf('0x34')][_0xb4cf('0x37')]));_0x282f79[_0xb4cf('0x36')]=_0x282f79['attributes'][_0xb4cf('0x38')]?_0x282f79[_0xb4cf('0x36')]:_0x2998af[_0xb4cf('0x33')];if(_0xc67365[_0xb4cf('0x34')]['includeAll']){_0x282f79[_0xb4cf('0x4b')]=[{'all':!![]}];}_0x282f79=_[_0xb4cf('0x3f')]({},_0x282f79,_0xc67365[_0xb4cf('0x41')]);return db['Plugin'][_0xb4cf('0x4c')](_0x282f79)[_0xb4cf('0x27')](handleEntityNotFound(_0x56fdd3,null))[_0xb4cf('0x27')](respondWithResult(_0x56fdd3,null))[_0xb4cf('0x47')](handleError(_0x56fdd3,null));};exports[_0xb4cf('0x4d')]=function(_0x2e5662,_0xd2e08c,_0x3b8886){return db[_0xb4cf('0x44')][_0xb4cf('0x4c')]({'where':{'id':_0x2e5662[_0xb4cf('0x49')]['id']},'attributes':[_0xb4cf('0x2c'),_0xb4cf('0x4')],'raw':!![]})[_0xb4cf('0x27')](handleEntityNotFound(_0xd2e08c,null))['then'](function(_0x56e9f0){if(_0x56e9f0){var _0x1da5ff=path[_0xb4cf('0x4e')](config[_0xb4cf('0x4f')],'server/files/plugins',util['format'](_0xb4cf('0x50'),path[_0xb4cf('0x51')](_0x56e9f0[_0xb4cf('0x4')])));var _0x1e84f7=fs[_0xb4cf('0x52')](_0x1da5ff);var _0x442c1a=archiver('zip',{'zlib':{'level':0x9}});_0x442c1a['on'](_0xb4cf('0x53'),function(_0x325ecf){if(_0x325ecf[_0xb4cf('0x54')]===_0xb4cf('0x55')){logger[_0xb4cf('0x2a')](_0x325ecf);}else{throw new db[(_0xb4cf('0x56'))][(_0xb4cf('0x57'))](_0xb4cf('0x58'));}});_0x442c1a['on'](_0xb4cf('0x2a'),function(_0x40891d){throw new db[(_0xb4cf('0x56'))][(_0xb4cf('0x57'))](_0xb4cf('0x58'));});_0x442c1a['pipe'](_0x1e84f7);_0x442c1a[_0xb4cf('0x59')](_0xb4cf('0x5a'),{'cwd':path['join'](config[_0xb4cf('0x4f')],'server/files/plugins',path['dirname'](_0x56e9f0[_0xb4cf('0x4')])),'ignore':[path[_0xb4cf('0x4e')](path[_0xb4cf('0x51')](_0x56e9f0['path']),_0xb4cf('0x5b')),path[_0xb4cf('0x4e')](path[_0xb4cf('0x51')](_0x56e9f0['path']),_0xb4cf('0x5c'))],'nodir':!![]})[_0xb4cf('0x5d')]();_0x1e84f7['on'](_0xb4cf('0x5e'),function(){if(!fs['existsSync'](_0x1da5ff)){throw new db[(_0xb4cf('0x56'))]['Error']('Plugin\x20not\x20found');}return _0xd2e08c['download'](_0x1da5ff,util[_0xb4cf('0x5f')](_0xb4cf('0x50'),path[_0xb4cf('0x51')](_0x56e9f0[_0xb4cf('0x4')])),function(_0x36e978){if(_0x36e978){throw new db['Sequelize'][(_0xb4cf('0x57'))]('Error\x20while\x20downloading\x20the\x20plugin');}fs[_0xb4cf('0x60')](_0x1da5ff);logger['info'](_0xb4cf('0x61'));logger['info'](_0xb4cf('0x62'));});});}return null;})[_0xb4cf('0x47')](handleError(_0xd2e08c,null));};exports[_0xb4cf('0x63')]=function(_0x75e011,_0x507ed3,_0x3e1973){var _0x4e42a1=path[_0xb4cf('0x51')](_0x75e011[_0xb4cf('0x64')][_0xb4cf('0x65')],path[_0xb4cf('0x66')](_0x75e011['file'][_0xb4cf('0x65')]));var _0x58f331=path['join'](config[_0xb4cf('0x4f')],'server/files/plugins',_0x75e011['file']['filename']);var _0x28e0b9=path[_0xb4cf('0x4e')](config[_0xb4cf('0x4f')],_0xb4cf('0x67'),_0x4e42a1);logger[_0xb4cf('0x68')](_0xb4cf('0x69'),_0x58f331);logger[_0xb4cf('0x68')](_0xb4cf('0x6a'),_0x28e0b9);try{fs[_0xb4cf('0x6b')](_0x58f331,parseInt(_0xb4cf('0x6c'),0x8));extract(_0x58f331,{'dir':_0x28e0b9},function(_0x2d05d6){if(_0x2d05d6){logger[_0xb4cf('0x2a')](_0x2d05d6);handleError(_0x2d05d6,!![]);};var _0x34366b=fs[_0xb4cf('0x6d')](_0x28e0b9);if(_0x34366b[_0xb4cf('0x38')]>0x1){removeReferences(_0x58f331,_0x28e0b9);logger[_0xb4cf('0x2a')](_0xb4cf('0x6e'));return _0x3e1973(new Error(_0xb4cf('0x6e')));}var _0x4f1d99=fs[_0xb4cf('0x6f')](path[_0xb4cf('0x4e')](_0x28e0b9,_0x34366b[0x0]));if(_0x4f1d99['isFile']()){removeReferences(_0x58f331,_0x28e0b9);logger[_0xb4cf('0x2a')](_0xb4cf('0x6e'));return _0x3e1973(new Error(_0xb4cf('0x6e')));}if(_0x4f1d99['isDirectory']()){var _0x5ab10d=fs[_0xb4cf('0x6d')](path['join'](_0x28e0b9,_0x34366b[0x0]));if(_0x5ab10d[_0xb4cf('0x38')]===0x0){removeReferences(_0x58f331,_0x28e0b9);logger['error'](_0xb4cf('0x6e'));return _0x3e1973(new Error(_0xb4cf('0x6e')));}var _0x441dee=_0x5ab10d[_0xb4cf('0x70')](function(_0x3d2844){return _0x3d2844==='manifest.json';});if(!_0x441dee){return _0x3e1973(new Error(_0xb4cf('0x71')));}var _0x1df010=fs[_0xb4cf('0x72')](path[_0xb4cf('0x4e')](_0x28e0b9,_0x34366b[0x0],_0xb4cf('0x73')));var _0x3aad79=JSON['parse'](_0x1df010);if(_0xb4cf('0x1e')==typeof _0x3aad79['name']){return _0x3e1973(new Error('Invalid\x20manifest:\x20name\x20missing'));}if(_0xb4cf('0x1e')==typeof _0x3aad79[_0xb4cf('0x31')]){return _0x3e1973(new Error('Invalid\x20manifest:\x20type\x20missing'));}if(_0xb4cf('0x1e')==typeof _0x3aad79['version']){return _0x3e1973(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if(_0xb4cf('0x1e')==typeof _0x3aad79['parameters']){return _0x3e1973(new Error(_0xb4cf('0x74')));}if(_0x3aad79[_0xb4cf('0x31')]===_0xb4cf('0x75')){if(_0xb4cf('0x1e')==typeof _0x3aad79[_0xb4cf('0x76')]['views']){return _0x3e1973(new Error(_0xb4cf('0x77')));}if(_0xb4cf('0x1e')==typeof _0x3aad79['parameters'][_0xb4cf('0x78')][_0xb4cf('0x79')]&&'undefined'==typeof _0x3aad79[_0xb4cf('0x76')][_0xb4cf('0x78')]['agent']){return _0x3e1973(new Error('Invalid\x20manifest:\x20no\x20view\x20specified'));}}else if(_0x3aad79[_0xb4cf('0x31')]===_0xb4cf('0x7a')){if(_0xb4cf('0x1e')==typeof _0x3aad79['parameters'][_0xb4cf('0x7b')]){return _0x3e1973(new Error(_0xb4cf('0x7c')));}if(_0xb4cf('0x1e')==typeof _0x3aad79['parameters'][_0xb4cf('0x7d')]){return _0x3e1973(new Error('Invalid\x20manifest:\x20script\x20path\x20missing'));}}else{return _0x3e1973(new Error(_0xb4cf('0x7e')));}var _0x19cc2c=_0x3aad79[_0xb4cf('0x2c')];var _0x35c07a=_0x3aad79[_0xb4cf('0x7f')];var _0x1fd690=_0x3aad79[_0xb4cf('0x31')];var _0x1dd85d=_0x3aad79['sidebar']?_0x3aad79[_0xb4cf('0x80')]:_0xb4cf('0x81');var _0x9c3b5f=_0x3aad79[_0xb4cf('0x82')]?_0x3aad79[_0xb4cf('0x82')]:_0xb4cf('0x83');var _0x542985='';var _0x4812ab='';var _0x1174db='';var _0x2f334f='';var _0x45c0a0=_0x3aad79['version'];if(_0x1fd690===_0xb4cf('0x75')){if('undefined'!=typeof _0x3aad79[_0xb4cf('0x76')]['views'][_0xb4cf('0x79')]){var _0x5d975d=_0x3aad79['parameters'][_0xb4cf('0x78')][_0xb4cf('0x79')];if(!/^(f|ht)tps?:\/\//i[_0xb4cf('0x84')](_0x5d975d)){_0x542985=path[_0xb4cf('0x4e')]('plugins',_0x4e42a1,_0x34366b[0x0],_0x5d975d);}else{_0x542985=_0x5d975d;}}else{logger[_0xb4cf('0x68')](_0xb4cf('0x85'));}if('undefined'!=typeof _0x3aad79[_0xb4cf('0x76')][_0xb4cf('0x78')][_0xb4cf('0x86')]){var _0x1168c2=_0x3aad79['parameters']['views']['agent'];if(!/^(f|ht)tps?:\/\//i['test'](_0x1168c2)){_0x4812ab=path[_0xb4cf('0x4e')](_0xb4cf('0x87'),_0x4e42a1,_0x34366b[0x0],_0x1168c2);}else{_0x4812ab=_0x1168c2;}}else{logger[_0xb4cf('0x68')](_0xb4cf('0x88'));}}else if(_0x1fd690===_0xb4cf('0x7a')){_0x1174db=_0x3aad79['parameters'][_0xb4cf('0x7b')];_0x2f334f=_0x3aad79[_0xb4cf('0x76')][_0xb4cf('0x7d')];if(_0xb4cf('0x1e')!=typeof _0x3aad79[_0xb4cf('0x76')][_0xb4cf('0x78')]){if(_0xb4cf('0x1e')!=typeof _0x3aad79[_0xb4cf('0x76')]['views'][_0xb4cf('0x79')]){var _0x5d975d=_0x3aad79['parameters'][_0xb4cf('0x78')]['admin'];if(!/^(f|ht)tps?:\/\//i['test'](_0x5d975d)){_0x542985=path[_0xb4cf('0x4e')]('plugins',_0x4e42a1,_0x34366b[0x0],_0x5d975d);}else{_0x542985=_0x5d975d;}}if(_0xb4cf('0x1e')!=typeof _0x3aad79[_0xb4cf('0x76')][_0xb4cf('0x78')][_0xb4cf('0x86')]){var _0x1168c2=_0x3aad79[_0xb4cf('0x76')][_0xb4cf('0x78')][_0xb4cf('0x86')];if(!/^(f|ht)tps?:\/\//i[_0xb4cf('0x84')](_0x1168c2)){_0x4812ab=path[_0xb4cf('0x4e')](_0xb4cf('0x87'),_0x4e42a1,_0x34366b[0x0],_0x1168c2);}else{_0x4812ab=_0x1168c2;}}}}var _0x2becb8={'name':_0x19cc2c,'description':_0x35c07a,'path':path['join'](_0x4e42a1,_0x34366b[0x0]),'type':_0x1fd690,'sidebar':_0x1dd85d,'icon':_0x9c3b5f,'adminUrl':_0x542985,'agentUrl':_0x4812ab,'scriptName':_0x1174db,'scriptPath':_0x2f334f,'version':_0x45c0a0};removeReferences(_0x58f331,null);return db[_0xb4cf('0x44')][_0xb4cf('0x89')](_0x2becb8)[_0xb4cf('0x27')](function(_0x51f421){var _0x52bc84={'role':_0x75e011[_0xb4cf('0x8a')][_0xb4cf('0x8b')],'userProfileId':_0x75e011[_0xb4cf('0x8a')][_0xb4cf('0x8c')]};if(!_0x52bc84)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x52bc84[_0xb4cf('0x8b')]===_0xb4cf('0x8d')){var _0x15e7b2=_0x51f421[_0xb4cf('0x28')]({'plain':!![]});return db[_0xb4cf('0x8e')][_0xb4cf('0x4c')]({'where':{'name':'Plugins','userProfileId':_0x52bc84[_0xb4cf('0x8c')]},'raw':!![]})['then'](function(_0xbdb8d){if(_0xbdb8d&&_0xbdb8d['autoAssociation']===0x0){return db[_0xb4cf('0x29')][_0xb4cf('0x89')]({'name':_0x15e7b2[_0xb4cf('0x2c')],'resourceId':_0x15e7b2['id'],'type':_0xbdb8d[_0xb4cf('0x2c')],'sectionId':_0xbdb8d['id']},{})[_0xb4cf('0x27')](function(){return _0x51f421;});}else{return _0x51f421;}})[_0xb4cf('0x47')](function(_0x2dc1cc){logger['error'](_0xb4cf('0x8f'),_0x2dc1cc);throw _0x2dc1cc;});}return _0x51f421;})['then'](respondWithResult(_0x507ed3,null))[_0xb4cf('0x47')](handleError(_0x507ed3,null));}});}catch(_0x44cb6c){_0x507ed3[_0xb4cf('0x1c')](0x1f4)[_0xb4cf('0x90')](_0x44cb6c);}};function removeReferences(_0x3ea8dc,_0x2dc603){try{if(_0x3ea8dc){fs['unlinkSync'](_0x3ea8dc);logger[_0xb4cf('0x68')](_0xb4cf('0x91'));}if(_0x2dc603){rimraf(_0x2dc603,function(){});logger['info'](_0xb4cf('0x92'));}}catch(_0x5bc637){logger[_0xb4cf('0x2a')](_0x5bc637);}}exports[_0xb4cf('0x25')]=function(_0x51982e,_0x1e62fa,_0xef831d){return db[_0xb4cf('0x44')][_0xb4cf('0x4c')]({'where':{'id':_0x51982e[_0xb4cf('0x49')]['id']}})[_0xb4cf('0x27')](handleEntityNotFound(_0x1e62fa,null))['then'](saveUpdates(_0x51982e[_0xb4cf('0x8a')],null))[_0xb4cf('0x27')](respondWithResult(_0x1e62fa,null))['catch'](handleError(_0x1e62fa,null));};exports[_0xb4cf('0x93')]=function(_0x56d275,_0x3469a8,_0x542564){return db['Plugin'][_0xb4cf('0x4c')]({'where':{'id':_0x56d275[_0xb4cf('0x49')]['id']}})[_0xb4cf('0x27')](function(_0x403b34){if(_0x403b34){return _0x403b34['destroy']();}})[_0xb4cf('0x27')](function(_0x10ac5a){rimraf(path[_0xb4cf('0x4e')](config[_0xb4cf('0x4f')],_0xb4cf('0x67'),path[_0xb4cf('0x94')](_0x10ac5a[_0xb4cf('0x4')])),function(){});return _0x10ac5a;})[_0xb4cf('0x27')](handleEntityNotFound(_0x3469a8,null))[_0xb4cf('0x27')](respondWithStatusCode(_0x3469a8,null))['catch'](handleError(_0x3469a8,null));};exports['webhookGet']=function(_0x1f3f63,_0x5411b2,_0x151e4b){return BPromise[_0xb4cf('0x95')]()[_0xb4cf('0x27')](function(){if(!_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x4')]){throw new Error(_0xb4cf('0x96'));}if(!_0x1f3f63[_0xb4cf('0x34')]['port']){throw new Error(_0xb4cf('0x97'));}var _0x5f9fc4=_0x1f3f63['query'][_0xb4cf('0x98')]?_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x98')]+':'+_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x99')]:'http://localhost:'+_0x1f3f63['query']['port'];var _0xd9a3d4=_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x9a')]?_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x9a')]:!![];var _0x5521f6=_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x9b')]?_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x9b')]:null;var _0xff7e5c={'method':_0x1f3f63[_0xb4cf('0x9c')],'uri':util[_0xb4cf('0x5f')]('%s%s',_0x5f9fc4,_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x4')]),'json':_0xd9a3d4,'resolveWithFullResponse':!![],'encoding':_0x5521f6,'qs':_0x1f3f63['query']};if(_0x1f3f63[_0xb4cf('0x9d')]){_0xff7e5c[_0xb4cf('0x9d')]=_0x1f3f63[_0xb4cf('0x9d')];if(_0xff7e5c['headers'][_0xb4cf('0x9e')]){delete _0xff7e5c[_0xb4cf('0x9d')][_0xb4cf('0x9e')];}}if(_0xff7e5c[_0xb4cf('0x9d')][_0xb4cf('0x9f')]){delete _0xff7e5c[_0xb4cf('0x9d')][_0xb4cf('0x9f')];}return rp(_0xff7e5c);})[_0xb4cf('0x27')](function(_0x34aa17){if(_0x34aa17){_0x5411b2[_0xb4cf('0x20')](_0x34aa17[_0xb4cf('0x9d')]);logger[_0xb4cf('0x68')](_0x34aa17[_0xb4cf('0x8a')]);if(_[_0xb4cf('0xa0')](_0x1f3f63[_0xb4cf('0x34')][_0xb4cf('0x4')],'download')&&_0x34aa17['statusCode']==0x1f4){return _0x5411b2['sendStatus'](_0x34aa17['statusCode']);}else{return _0x5411b2[_0xb4cf('0x1c')](_0x34aa17[_0xb4cf('0xa1')])[_0xb4cf('0x90')](_0x34aa17[_0xb4cf('0x8a')]);}}else{return _0x5411b2['sendStatus'](0xc8);}})[_0xb4cf('0x47')](handleError(_0x5411b2,null));};exports[_0xb4cf('0xa2')]=function(_0x193d31,_0x25e6b6,_0x24324b){return BPromise[_0xb4cf('0x95')]()[_0xb4cf('0x27')](function(){if(!_0x193d31[_0xb4cf('0x34')]['path']){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x193d31[_0xb4cf('0x34')]['port']){throw new Error(_0xb4cf('0x97'));}var _0x2bfe15=_0x193d31['query'][_0xb4cf('0x98')]?_0x193d31[_0xb4cf('0x34')]['hostname']+':'+_0x193d31['query'][_0xb4cf('0x99')]:_0xb4cf('0xa3')+_0x193d31['query'][_0xb4cf('0x99')];var _0x17d0cc=_0x193d31[_0xb4cf('0x34')][_0xb4cf('0x9a')]?_0x193d31[_0xb4cf('0x34')][_0xb4cf('0x9a')]:!![];var _0x101c21=_0x193d31['query'][_0xb4cf('0x9b')]?_0x193d31[_0xb4cf('0x34')]['encoding']:null;var _0x20bdc9={'method':_0x193d31[_0xb4cf('0x9c')],'uri':util[_0xb4cf('0x5f')]('%s%s',_0x2bfe15,_0x193d31[_0xb4cf('0x34')][_0xb4cf('0x4')]),'json':_0x17d0cc,'resolveWithFullResponse':!![],'encoding':_0x101c21,'body':_0x193d31[_0xb4cf('0x8a')]};if(_0x193d31['headers']){_0x20bdc9[_0xb4cf('0x9d')]=_0x193d31[_0xb4cf('0x9d')];if(_0x20bdc9['headers']['content-length']){delete _0x20bdc9[_0xb4cf('0x9d')][_0xb4cf('0x9e')];}}if(_0x20bdc9[_0xb4cf('0x9d')][_0xb4cf('0x9f')]){delete _0x20bdc9[_0xb4cf('0x9d')][_0xb4cf('0x9f')];}return rp(_0x20bdc9);})[_0xb4cf('0x27')](function(_0x22b7e9){if(_0x22b7e9){_0x25e6b6[_0xb4cf('0x20')](_0x22b7e9[_0xb4cf('0x9d')]);logger[_0xb4cf('0x68')](_0x22b7e9[_0xb4cf('0x8a')]);return _0x25e6b6[_0xb4cf('0x1c')](_0x22b7e9['statusCode'])[_0xb4cf('0x90')](_0x22b7e9[_0xb4cf('0x8a')]);}else{return _0x25e6b6[_0xb4cf('0x1b')](0xc8);}})[_0xb4cf('0x47')](handleError(_0x25e6b6,null));};
\ No newline at end of file
+var _0x7c7a=['Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','**/*','dirname','node_modules/**/*','basename','attachments/**/*','finalize','existsSync','Plugin\x20not\x20found','format','Error\x20while\x20downloading\x20the\x20plugin','info','Download\x20completed','upload','file','filename','extname','Plugin\x20upload\x20filepath:\x20%s','chmodSync','0777','Invalid\x20plugin\x20structure','lstatSync','isDirectory','readdirSync','manifest.json','Plugin\x20manifest\x20missing','readFileSync','parse','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','Invalid\x20manifest:\x20version\x20not\x20specified','parameters','html','views','Invalid\x20manifest:\x20views\x20missing','Invalid\x20manifest:\x20no\x20view\x20specified','script','scriptName','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','version','admin','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','agent','Warning:\x20agent\x20view\x20not\x20specified','role','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','get','UserProfileSection','UserProfileResource','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','unlinkSync','Extracted\x20folder\x20removed','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','port','hostname','encoding','method','%s%s','headers','content-length','content-type','set','statusCode','webhookPost','\x27PORT\x27\x20parameter\x20not\x20specified','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','extract-zip','archiver','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','./plugin.socket','sendStatus','status','end','json','undefined','offset','limit','Content-Range','apply','reject','update','then','Plugins','destroy','error','stack','name','send','index','Plugin','rawAttributes','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','merge','type','VIRTUAL','options','count','includeAll','include','findAll','catch','show','params','find','download','join','root','server/files/plugins','%s.zip','createWriteStream','zip','warning','code'];(function(_0x4eec9b,_0x4aea09){var _0x2e3849=function(_0x24c06d){while(--_0x24c06d){_0x4eec9b['push'](_0x4eec9b['shift']());}};_0x2e3849(++_0x4aea09);}(_0x7c7a,0xfc));var _0xa7c7=function(_0x58b449,_0x5d7b77){_0x58b449=_0x58b449-0x0;var _0x483bdb=_0x7c7a[_0x58b449];return _0x483bdb;};'use strict';var emlformat=require(_0xa7c7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa7c7('0x1'));var jsonpatch=require(_0xa7c7('0x2'));var rp=require(_0xa7c7('0x3'));var moment=require(_0xa7c7('0x4'));var BPromise=require(_0xa7c7('0x5'));var Mustache=require(_0xa7c7('0x6'));var util=require('util');var path=require(_0xa7c7('0x7'));var sox=require('sox');var csv=require(_0xa7c7('0x8'));var ejs=require(_0xa7c7('0x9'));var fs=require('fs');var fs_extra=require(_0xa7c7('0xa'));var _=require(_0xa7c7('0xb'));var squel=require(_0xa7c7('0xc'));var crypto=require(_0xa7c7('0xd'));var jsforce=require(_0xa7c7('0xe'));var deskjs=require(_0xa7c7('0xf'));var toCsv=require(_0xa7c7('0x8'));var querystring=require(_0xa7c7('0x10'));var Papa=require(_0xa7c7('0x11'));var extract=require(_0xa7c7('0x12'));var rimraf=require('rimraf');var archiver=require(_0xa7c7('0x13'));var Redis=require(_0xa7c7('0x14'));var authService=require('../../components/auth/service');var qs=require(_0xa7c7('0x15'));var as=require(_0xa7c7('0x16'));var hardwareService=require(_0xa7c7('0x17'));var logger=require(_0xa7c7('0x18'))(_0xa7c7('0x19'));var utils=require(_0xa7c7('0x1a'));var config=require('../../config/environment');var licenseUtil=require(_0xa7c7('0x1b'));var db=require(_0xa7c7('0x1c'))['db'];config[_0xa7c7('0x1d')]=_[_0xa7c7('0x1e')](config[_0xa7c7('0x1d')],{'host':_0xa7c7('0x1f'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa7c7('0x1d')]));require(_0xa7c7('0x20'))['register'](socket);function respondWithStatusCode(_0x52b407,_0x25ed67){_0x25ed67=_0x25ed67||0xcc;return function(_0xd155a5){if(_0xd155a5){return _0x52b407[_0xa7c7('0x21')](_0x25ed67);}return _0x52b407[_0xa7c7('0x22')](_0x25ed67)[_0xa7c7('0x23')]();};}function respondWithResult(_0x829d9,_0x4b0c3e){_0x4b0c3e=_0x4b0c3e||0xc8;return function(_0x592650){if(_0x592650){return _0x829d9[_0xa7c7('0x22')](_0x4b0c3e)[_0xa7c7('0x24')](_0x592650);}};}function respondWithFilteredResult(_0x379baa,_0x1ba80a){return function(_0x31ca71){if(_0x31ca71){var _0x16210b=typeof _0x1ba80a['offset']===_0xa7c7('0x25')&&typeof _0x1ba80a['limit']===_0xa7c7('0x25');var _0x3958b3=_0x31ca71['count'];var _0x57766d=_0x16210b?0x0:_0x1ba80a[_0xa7c7('0x26')];var _0x3b173f=_0x16210b?_0x31ca71['count']:_0x1ba80a[_0xa7c7('0x26')]+_0x1ba80a[_0xa7c7('0x27')];var _0x2062bb;if(_0x3b173f>=_0x3958b3){_0x3b173f=_0x3958b3;_0x2062bb=0xc8;}else{_0x2062bb=0xce;}_0x379baa[_0xa7c7('0x22')](_0x2062bb);return _0x379baa['set'](_0xa7c7('0x28'),_0x57766d+'-'+_0x3b173f+'/'+_0x3958b3)[_0xa7c7('0x24')](_0x31ca71);}return null;};}function patchUpdates(_0x1a7f2b){return function(_0x44360f){try{jsonpatch[_0xa7c7('0x29')](_0x44360f,_0x1a7f2b,!![]);}catch(_0x33a84c){return BPromise[_0xa7c7('0x2a')](_0x33a84c);}return _0x44360f['save']();};}function saveUpdates(_0x1c1459,_0x1fc7e8){return function(_0x2109a7){if(_0x2109a7){return _0x2109a7[_0xa7c7('0x2b')](_0x1c1459)[_0xa7c7('0x2c')](function(_0x105f73){return _0x105f73;});}return null;};}function removeEntity(_0x44da21,_0x42f631){return function(_0x454a06){if(_0x454a06){return _0x454a06['destroy']()[_0xa7c7('0x2c')](function(){var _0x24750f=_0x454a06['get']({'plain':!![]});var _0x1e88a9=_0xa7c7('0x2d');return db['UserProfileResource'][_0xa7c7('0x2e')]({'where':{'type':_0x1e88a9,'resourceId':_0x24750f['id']}})[_0xa7c7('0x2c')](function(){return _0x454a06;});})['then'](function(){_0x44da21['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x211917,_0x36167c){return function(_0x574aab){if(!_0x574aab){_0x211917[_0xa7c7('0x21')](0x194);}return _0x574aab;};}function handleError(_0x147f88,_0x5e134c){_0x5e134c=_0x5e134c||0x1f4;return function(_0x30060b){logger[_0xa7c7('0x2f')](_0x30060b[_0xa7c7('0x30')]);if(_0x30060b[_0xa7c7('0x31')]){delete _0x30060b['name'];}_0x147f88[_0xa7c7('0x22')](_0x5e134c)[_0xa7c7('0x32')](_0x30060b);};}exports[_0xa7c7('0x33')]=function(_0x5bf85e,_0xea95d4){var _0x40209b={},_0x3a9d61={},_0x7c4431={'count':0x0,'rows':[]};var _0x17e1ce=_['map'](db[_0xa7c7('0x34')][_0xa7c7('0x35')],function(_0x3ae361){return{'name':_0x3ae361['fieldName'],'type':_0x3ae361['type'][_0xa7c7('0x36')]};});_0x3a9d61[_0xa7c7('0x37')]=_[_0xa7c7('0x38')](_0x17e1ce,'name');_0x3a9d61[_0xa7c7('0x39')]=_[_0xa7c7('0x3a')](_0x5bf85e['query']);_0x3a9d61[_0xa7c7('0x3b')]=_[_0xa7c7('0x3c')](_0x3a9d61[_0xa7c7('0x37')],_0x3a9d61[_0xa7c7('0x39')]);_0x40209b[_0xa7c7('0x3d')]=_[_0xa7c7('0x3c')](_0x3a9d61[_0xa7c7('0x37')],qs['fields'](_0x5bf85e[_0xa7c7('0x39')][_0xa7c7('0x3e')]));_0x40209b['attributes']=_0x40209b['attributes'][_0xa7c7('0x3f')]?_0x40209b[_0xa7c7('0x3d')]:_0x3a9d61[_0xa7c7('0x37')];if(!_0x5bf85e[_0xa7c7('0x39')][_0xa7c7('0x40')](_0xa7c7('0x41'))){_0x40209b['limit']=qs[_0xa7c7('0x27')](_0x5bf85e[_0xa7c7('0x39')][_0xa7c7('0x27')]);_0x40209b[_0xa7c7('0x26')]=qs[_0xa7c7('0x26')](_0x5bf85e[_0xa7c7('0x39')][_0xa7c7('0x26')]);}_0x40209b['order']=qs[_0xa7c7('0x42')](_0x5bf85e['query'][_0xa7c7('0x42')]);_0x40209b[_0xa7c7('0x43')]=qs[_0xa7c7('0x3b')](_[_0xa7c7('0x44')](_0x5bf85e[_0xa7c7('0x39')],_0x3a9d61['filters']),_0x17e1ce);if(_0x5bf85e[_0xa7c7('0x39')]['filter']){_0x40209b['where']=_[_0xa7c7('0x45')](_0x40209b['where'],{'$or':_[_0xa7c7('0x38')](_0x17e1ce,function(_0x6073b2){if(_0x6073b2[_0xa7c7('0x46')]!==_0xa7c7('0x47')){var _0xf27358={};_0xf27358[_0x6073b2[_0xa7c7('0x31')]]={'$like':'%'+_0x5bf85e['query']['filter']+'%'};return _0xf27358;}})});}_0x40209b=_[_0xa7c7('0x45')]({},_0x40209b,_0x5bf85e[_0xa7c7('0x48')]);var _0x1c26c0={'where':_0x40209b[_0xa7c7('0x43')]};return db[_0xa7c7('0x34')][_0xa7c7('0x49')](_0x1c26c0)['then'](function(_0x2a8ee3){_0x7c4431['count']=_0x2a8ee3;if(_0x5bf85e[_0xa7c7('0x39')][_0xa7c7('0x4a')]){_0x40209b[_0xa7c7('0x4b')]=[{'all':!![]}];}return db[_0xa7c7('0x34')][_0xa7c7('0x4c')](_0x40209b);})[_0xa7c7('0x2c')](function(_0x48c241){_0x7c4431['rows']=_0x48c241;return _0x7c4431;})['then'](respondWithFilteredResult(_0xea95d4,_0x40209b))[_0xa7c7('0x4d')](handleError(_0xea95d4,null));};exports[_0xa7c7('0x4e')]=function(_0x11293d,_0x13f807){var _0x1a26e1={'raw':!![],'where':{'id':_0x11293d[_0xa7c7('0x4f')]['id']}},_0x38334a={};_0x38334a[_0xa7c7('0x37')]=_[_0xa7c7('0x3a')](db[_0xa7c7('0x34')][_0xa7c7('0x35')]);_0x38334a[_0xa7c7('0x39')]=_[_0xa7c7('0x3a')](_0x11293d[_0xa7c7('0x39')]);_0x38334a[_0xa7c7('0x3b')]=_[_0xa7c7('0x3c')](_0x38334a[_0xa7c7('0x37')],_0x38334a[_0xa7c7('0x39')]);_0x1a26e1[_0xa7c7('0x3d')]=_[_0xa7c7('0x3c')](_0x38334a[_0xa7c7('0x37')],qs[_0xa7c7('0x3e')](_0x11293d[_0xa7c7('0x39')]['fields']));_0x1a26e1['attributes']=_0x1a26e1[_0xa7c7('0x3d')][_0xa7c7('0x3f')]?_0x1a26e1[_0xa7c7('0x3d')]:_0x38334a[_0xa7c7('0x37')];if(_0x11293d[_0xa7c7('0x39')]['includeAll']){_0x1a26e1[_0xa7c7('0x4b')]=[{'all':!![]}];}_0x1a26e1=_[_0xa7c7('0x45')]({},_0x1a26e1,_0x11293d[_0xa7c7('0x48')]);return db['Plugin'][_0xa7c7('0x50')](_0x1a26e1)[_0xa7c7('0x2c')](handleEntityNotFound(_0x13f807,null))[_0xa7c7('0x2c')](respondWithResult(_0x13f807,null))['catch'](handleError(_0x13f807,null));};exports[_0xa7c7('0x51')]=function(_0x48d5ca,_0x5759a6,_0x2d7620){return db[_0xa7c7('0x34')][_0xa7c7('0x50')]({'where':{'id':_0x48d5ca[_0xa7c7('0x4f')]['id']},'attributes':[_0xa7c7('0x31'),_0xa7c7('0x7')],'raw':!![]})[_0xa7c7('0x2c')](handleEntityNotFound(_0x5759a6,null))[_0xa7c7('0x2c')](function(_0x11f931){if(_0x11f931){var _0x10a27b=path[_0xa7c7('0x52')](config[_0xa7c7('0x53')],_0xa7c7('0x54'),util['format'](_0xa7c7('0x55'),path['basename'](_0x11f931[_0xa7c7('0x7')])));var _0x281414=fs[_0xa7c7('0x56')](_0x10a27b);var _0x569fe9=archiver(_0xa7c7('0x57'),{'zlib':{'level':0x9}});_0x569fe9['on'](_0xa7c7('0x58'),function(_0x49757d){if(_0x49757d[_0xa7c7('0x59')]==='ENOENT'){logger[_0xa7c7('0x2f')](_0x49757d);}else{throw new db[(_0xa7c7('0x5a'))][(_0xa7c7('0x5b'))](_0xa7c7('0x5c'));}});_0x569fe9['on']('error',function(_0x4504e6){throw new db[(_0xa7c7('0x5a'))][(_0xa7c7('0x5b'))](_0xa7c7('0x5c'));});_0x569fe9['pipe'](_0x281414);_0x569fe9[_0xa7c7('0x5d')](_0xa7c7('0x5e'),{'cwd':path[_0xa7c7('0x52')](config[_0xa7c7('0x53')],'server/files/plugins',path[_0xa7c7('0x5f')](_0x11f931[_0xa7c7('0x7')])),'ignore':[path['join'](path['basename'](_0x11f931[_0xa7c7('0x7')]),_0xa7c7('0x60')),path[_0xa7c7('0x52')](path[_0xa7c7('0x61')](_0x11f931[_0xa7c7('0x7')]),_0xa7c7('0x62'))],'nodir':!![]})[_0xa7c7('0x63')]();_0x281414['on']('close',function(){if(!fs[_0xa7c7('0x64')](_0x10a27b)){throw new db[(_0xa7c7('0x5a'))][(_0xa7c7('0x5b'))](_0xa7c7('0x65'));}return _0x5759a6[_0xa7c7('0x51')](_0x10a27b,util[_0xa7c7('0x66')](_0xa7c7('0x55'),path[_0xa7c7('0x61')](_0x11f931[_0xa7c7('0x7')])),function(_0x5d0ef8){if(_0x5d0ef8){throw new db[(_0xa7c7('0x5a'))][(_0xa7c7('0x5b'))](_0xa7c7('0x67'));}fs['unlinkSync'](_0x10a27b);logger[_0xa7c7('0x68')](_0xa7c7('0x69'));logger[_0xa7c7('0x68')]('Temporary\x20file\x20removed');});});}return null;})[_0xa7c7('0x4d')](handleError(_0x5759a6,null));};exports[_0xa7c7('0x6a')]=function(_0x56178c,_0x5dfb58,_0x451f3e){var _0x846b19=path[_0xa7c7('0x61')](_0x56178c[_0xa7c7('0x6b')][_0xa7c7('0x6c')],path[_0xa7c7('0x6d')](_0x56178c['file'][_0xa7c7('0x6c')]));var _0x4f6a68=path[_0xa7c7('0x52')](config[_0xa7c7('0x53')],_0xa7c7('0x54'),_0x56178c[_0xa7c7('0x6b')][_0xa7c7('0x6c')]);var _0x3e83af=path[_0xa7c7('0x52')](config[_0xa7c7('0x53')],_0xa7c7('0x54'),_0x846b19);logger['info'](_0xa7c7('0x6e'),_0x4f6a68);logger[_0xa7c7('0x68')]('Plugin\x20upload\x20destination:\x20%s',_0x3e83af);try{fs[_0xa7c7('0x6f')](_0x4f6a68,parseInt(_0xa7c7('0x70'),0x8));extract(_0x4f6a68,{'dir':_0x3e83af},function(_0xa4c551){if(_0xa4c551){logger[_0xa7c7('0x2f')](_0xa4c551);handleError(_0xa4c551,!![]);};var _0x5ef282=fs['readdirSync'](_0x3e83af);if(_0x5ef282['length']>0x1){removeReferences(_0x4f6a68,_0x3e83af);logger[_0xa7c7('0x2f')](_0xa7c7('0x71'));return _0x451f3e(new Error(_0xa7c7('0x71')));}var _0x2f3c70=fs[_0xa7c7('0x72')](path[_0xa7c7('0x52')](_0x3e83af,_0x5ef282[0x0]));if(_0x2f3c70['isFile']()){removeReferences(_0x4f6a68,_0x3e83af);logger['error'](_0xa7c7('0x71'));return _0x451f3e(new Error(_0xa7c7('0x71')));}if(_0x2f3c70[_0xa7c7('0x73')]()){var _0x189af4=fs[_0xa7c7('0x74')](path[_0xa7c7('0x52')](_0x3e83af,_0x5ef282[0x0]));if(_0x189af4[_0xa7c7('0x3f')]===0x0){removeReferences(_0x4f6a68,_0x3e83af);logger[_0xa7c7('0x2f')]('Invalid\x20plugin\x20structure');return _0x451f3e(new Error('Invalid\x20plugin\x20structure'));}var _0x8cbf49=_0x189af4['some'](function(_0x4c1ae8){return _0x4c1ae8===_0xa7c7('0x75');});if(!_0x8cbf49){return _0x451f3e(new Error(_0xa7c7('0x76')));}var _0x923dab=fs[_0xa7c7('0x77')](path[_0xa7c7('0x52')](_0x3e83af,_0x5ef282[0x0],_0xa7c7('0x75')));var _0x581f0d=JSON[_0xa7c7('0x78')](_0x923dab);if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x31')]){return _0x451f3e(new Error(_0xa7c7('0x79')));}if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x46')]){return _0x451f3e(new Error(_0xa7c7('0x7a')));}if('undefined'==typeof _0x581f0d['version']){return _0x451f3e(new Error(_0xa7c7('0x7b')));}if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x7c')]){return _0x451f3e(new Error('Invalid\x20manifest:\x20parameters\x20missing'));}if(_0x581f0d['type']===_0xa7c7('0x7d')){if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')]){return _0x451f3e(new Error(_0xa7c7('0x7f')));}if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')]['admin']&&_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')]['agent']){return _0x451f3e(new Error(_0xa7c7('0x80')));}}else if(_0x581f0d[_0xa7c7('0x46')]===_0xa7c7('0x81')){if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x82')]){return _0x451f3e(new Error('Invalid\x20manifest:\x20script\x20name\x20missing'));}if(_0xa7c7('0x25')==typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x83')]){return _0x451f3e(new Error(_0xa7c7('0x84')));}}else{return _0x451f3e(new Error(_0xa7c7('0x85')));}var _0x30aa61=_0x581f0d['name'];var _0x148493=_0x581f0d[_0xa7c7('0x86')];var _0x114af9=_0x581f0d['type'];var _0x56e21=_0x581f0d[_0xa7c7('0x87')]?_0x581f0d[_0xa7c7('0x87')]:_0xa7c7('0x88');var _0x230f74=_0x581f0d[_0xa7c7('0x89')]?_0x581f0d[_0xa7c7('0x89')]:_0xa7c7('0x8a');var _0x2eb046='';var _0x2311ca='';var _0x52a432='';var _0x3a7a3a='';var _0x505e07=_0x581f0d[_0xa7c7('0x8b')];if(_0x114af9===_0xa7c7('0x7d')){if(_0xa7c7('0x25')!=typeof _0x581f0d[_0xa7c7('0x7c')]['views'][_0xa7c7('0x8c')]){var _0x58a70e=_0x581f0d['parameters'][_0xa7c7('0x7e')]['admin'];if(!/^(f|ht)tps?:\/\//i[_0xa7c7('0x8d')](_0x58a70e)){_0x2eb046=path[_0xa7c7('0x52')](_0xa7c7('0x8e'),_0x846b19,_0x5ef282[0x0],_0x58a70e);}else{_0x2eb046=_0x58a70e;}}else{logger['info'](_0xa7c7('0x8f'));}if('undefined'!=typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')][_0xa7c7('0x90')]){var _0x1e8607=_0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')][_0xa7c7('0x90')];if(!/^(f|ht)tps?:\/\//i[_0xa7c7('0x8d')](_0x1e8607)){_0x2311ca=path['join'](_0xa7c7('0x8e'),_0x846b19,_0x5ef282[0x0],_0x1e8607);}else{_0x2311ca=_0x1e8607;}}else{logger[_0xa7c7('0x68')](_0xa7c7('0x91'));}}else if(_0x114af9===_0xa7c7('0x81')){_0x52a432=_0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x82')];_0x3a7a3a=_0x581f0d['parameters'][_0xa7c7('0x83')];if(_0xa7c7('0x25')!=typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')]){if(_0xa7c7('0x25')!=typeof _0x581f0d[_0xa7c7('0x7c')]['views'][_0xa7c7('0x8c')]){var _0x58a70e=_0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')][_0xa7c7('0x8c')];if(!/^(f|ht)tps?:\/\//i[_0xa7c7('0x8d')](_0x58a70e)){_0x2eb046=path[_0xa7c7('0x52')]('plugins',_0x846b19,_0x5ef282[0x0],_0x58a70e);}else{_0x2eb046=_0x58a70e;}}if(_0xa7c7('0x25')!=typeof _0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')][_0xa7c7('0x90')]){var _0x1e8607=_0x581f0d[_0xa7c7('0x7c')][_0xa7c7('0x7e')][_0xa7c7('0x90')];if(!/^(f|ht)tps?:\/\//i[_0xa7c7('0x8d')](_0x1e8607)){_0x2311ca=path[_0xa7c7('0x52')]('plugins',_0x846b19,_0x5ef282[0x0],_0x1e8607);}else{_0x2311ca=_0x1e8607;}}}}var _0x27d761={'name':_0x30aa61,'description':_0x148493,'path':path[_0xa7c7('0x52')](_0x846b19,_0x5ef282[0x0]),'type':_0x114af9,'sidebar':_0x56e21,'icon':_0x230f74,'adminUrl':_0x2eb046,'agentUrl':_0x2311ca,'scriptName':_0x52a432,'scriptPath':_0x3a7a3a,'version':_0x505e07};removeReferences(_0x4f6a68,null);return db[_0xa7c7('0x34')]['create'](_0x27d761)[_0xa7c7('0x2c')](function(_0x271a58){var _0x39c6d5={'role':_0x56178c['body'][_0xa7c7('0x92')],'userProfileId':_0x56178c[_0xa7c7('0x93')]['userProfileId']};if(!_0x39c6d5)throw new Error(_0xa7c7('0x94'));if(_0x39c6d5['role']===_0xa7c7('0x95')){var _0x4fbe01=_0x271a58[_0xa7c7('0x96')]({'plain':!![]});return db[_0xa7c7('0x97')][_0xa7c7('0x50')]({'where':{'name':_0xa7c7('0x2d'),'userProfileId':_0x39c6d5['userProfileId']},'raw':!![]})[_0xa7c7('0x2c')](function(_0x5cd8f7){if(_0x5cd8f7&&_0x5cd8f7['autoAssociation']===0x0){return db[_0xa7c7('0x98')][_0xa7c7('0x99')]({'name':_0x4fbe01['name'],'resourceId':_0x4fbe01['id'],'type':_0x5cd8f7[_0xa7c7('0x31')],'sectionId':_0x5cd8f7['id']},{})[_0xa7c7('0x2c')](function(){return _0x271a58;});}else{return _0x271a58;}})[_0xa7c7('0x4d')](function(_0x48036d){logger[_0xa7c7('0x2f')](_0xa7c7('0x9a'),_0x48036d);throw _0x48036d;});}return _0x271a58;})[_0xa7c7('0x2c')](respondWithResult(_0x5dfb58,null))['catch'](handleError(_0x5dfb58,null));}});}catch(_0x119bb5){_0x5dfb58[_0xa7c7('0x22')](0x1f4)[_0xa7c7('0x32')](_0x119bb5);}};function removeReferences(_0x187719,_0x1dfa14){try{if(_0x187719){fs[_0xa7c7('0x9b')](_0x187719);logger[_0xa7c7('0x68')]('Zip\x20archive\x20removed');}if(_0x1dfa14){rimraf(_0x1dfa14,function(){});logger[_0xa7c7('0x68')](_0xa7c7('0x9c'));}}catch(_0x17d0f6){logger[_0xa7c7('0x2f')](_0x17d0f6);}}exports[_0xa7c7('0x2b')]=function(_0x57a5f5,_0x282cf8,_0x533f6f){return db[_0xa7c7('0x34')][_0xa7c7('0x50')]({'where':{'id':_0x57a5f5[_0xa7c7('0x4f')]['id']}})['then'](handleEntityNotFound(_0x282cf8,null))['then'](saveUpdates(_0x57a5f5[_0xa7c7('0x93')],null))[_0xa7c7('0x2c')](respondWithResult(_0x282cf8,null))['catch'](handleError(_0x282cf8,null));};exports['delete']=function(_0x5d2ca3,_0x3b11ae,_0x452cef){return db[_0xa7c7('0x34')][_0xa7c7('0x50')]({'where':{'id':_0x5d2ca3['params']['id']}})[_0xa7c7('0x2c')](function(_0x4e11d4){if(_0x4e11d4){return _0x4e11d4[_0xa7c7('0x2e')]();}})[_0xa7c7('0x2c')](function(_0x4d344f){rimraf(path[_0xa7c7('0x52')](config[_0xa7c7('0x53')],_0xa7c7('0x54'),path['dirname'](_0x4d344f[_0xa7c7('0x7')])),function(){});return _0x4d344f;})[_0xa7c7('0x2c')](handleEntityNotFound(_0x3b11ae,null))[_0xa7c7('0x2c')](respondWithStatusCode(_0x3b11ae,null))[_0xa7c7('0x4d')](handleError(_0x3b11ae,null));};exports['webhookGet']=function(_0x260a3f,_0x31149c,_0x102db0){return BPromise[_0xa7c7('0x9d')]()[_0xa7c7('0x2c')](function(){if(!_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x7')]){throw new Error(_0xa7c7('0x9e'));}if(!_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x9f')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x332824=_0x260a3f['query'][_0xa7c7('0xa0')]?_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0xa0')]+':'+_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x9f')]:'http://localhost:'+_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x9f')];var _0x5c9ddc=_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x24')]?_0x260a3f['query'][_0xa7c7('0x24')]:!![];var _0x1fea26=_0x260a3f['query'][_0xa7c7('0xa1')]?_0x260a3f['query'][_0xa7c7('0xa1')]:null;var _0x597899={'method':_0x260a3f[_0xa7c7('0xa2')],'uri':util[_0xa7c7('0x66')](_0xa7c7('0xa3'),_0x332824,_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x7')]),'json':_0x5c9ddc,'resolveWithFullResponse':!![],'encoding':_0x1fea26,'qs':_0x260a3f[_0xa7c7('0x39')]};if(_0x260a3f[_0xa7c7('0xa4')]){_0x597899[_0xa7c7('0xa4')]=_0x260a3f['headers'];if(_0x597899['headers'][_0xa7c7('0xa5')]){delete _0x597899[_0xa7c7('0xa4')]['content-length'];}}if(_0x597899['headers'][_0xa7c7('0xa6')]){delete _0x597899['headers']['content-type'];}return rp(_0x597899);})[_0xa7c7('0x2c')](function(_0x183bc0){if(_0x183bc0){_0x31149c[_0xa7c7('0xa7')](_0x183bc0[_0xa7c7('0xa4')]);logger[_0xa7c7('0x68')](_0x183bc0[_0xa7c7('0x93')]);if(_['endsWith'](_0x260a3f[_0xa7c7('0x39')][_0xa7c7('0x7')],'download')&&_0x183bc0[_0xa7c7('0xa8')]==0x1f4){return _0x31149c[_0xa7c7('0x21')](_0x183bc0['statusCode']);}else{return _0x31149c[_0xa7c7('0x22')](_0x183bc0[_0xa7c7('0xa8')])['send'](_0x183bc0['body']);}}else{return _0x31149c['sendStatus'](0xc8);}})[_0xa7c7('0x4d')](handleError(_0x31149c,null));};exports[_0xa7c7('0xa9')]=function(_0x43fc4c,_0x213220,_0x14afbb){return BPromise[_0xa7c7('0x9d')]()[_0xa7c7('0x2c')](function(){if(!_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0x7')]){throw new Error(_0xa7c7('0x9e'));}if(!_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0x9f')]){throw new Error(_0xa7c7('0xaa'));}var _0x98a28=_0x43fc4c['query']['hostname']?_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0xa0')]+':'+_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0x9f')]:'http://localhost:'+_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0x9f')];var _0x42a871=_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0x24')]?_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0x24')]:!![];var _0x376662=_0x43fc4c['query']['encoding']?_0x43fc4c[_0xa7c7('0x39')][_0xa7c7('0xa1')]:null;var _0x40fdbc={'method':_0x43fc4c[_0xa7c7('0xa2')],'uri':util[_0xa7c7('0x66')](_0xa7c7('0xa3'),_0x98a28,_0x43fc4c['query'][_0xa7c7('0x7')]),'json':_0x42a871,'resolveWithFullResponse':!![],'encoding':_0x376662,'body':_0x43fc4c[_0xa7c7('0x93')]};if(_0x43fc4c[_0xa7c7('0xa4')]){_0x40fdbc[_0xa7c7('0xa4')]=_0x43fc4c['headers'];if(_0x40fdbc[_0xa7c7('0xa4')]['content-length']){delete _0x40fdbc[_0xa7c7('0xa4')][_0xa7c7('0xa5')];}}if(_0x40fdbc[_0xa7c7('0xa4')][_0xa7c7('0xa6')]){delete _0x40fdbc[_0xa7c7('0xa4')][_0xa7c7('0xa6')];}return rp(_0x40fdbc);})[_0xa7c7('0x2c')](function(_0x54606f){if(_0x54606f){_0x213220[_0xa7c7('0xa7')](_0x54606f[_0xa7c7('0xa4')]);logger[_0xa7c7('0x68')](_0x54606f[_0xa7c7('0x93')]);return _0x213220[_0xa7c7('0x22')](_0x54606f[_0xa7c7('0xa8')])[_0xa7c7('0x32')](_0x54606f['body']);}else{return _0x213220[_0xa7c7('0x21')](0xc8);}})[_0xa7c7('0x4d')](handleError(_0x213220,null));};
\ No newline at end of file