Built motion from commit 9d7072cc.|2.5.39
[motion2.git] / server / api / plugin / plugin.controller.js
index 33f348f..6ae3570 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x979f=['\x27PATH\x27\x20parameter\x20not\x20specified','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','http://localhost:','encoding','%s%s','headers','content-length','content-type','endsWith','statusCode','webhookPost','resolve','method','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','papaparse','extract-zip','archiver','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','redis','localhost','socket.io-emitter','./plugin.socket','register','end','status','json','count','offset','set','Content-Range','apply','reject','update','then','destroy','get','Plugins','UserProfileResource','sendStatus','error','stack','name','send','index','map','Plugin','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','filters','pick','filter','VIRTUAL','merge','where','includeAll','include','catch','show','params','options','server/files/plugins','%s.zip','basename','createWriteStream','zip','code','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','glob','join','root','attachments/**/*','finalize','close','existsSync','Plugin\x20not\x20found','format','unlinkSync','info','Temporary\x20file\x20removed','upload','file','filename','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','readdirSync','Invalid\x20plugin\x20structure','lstatSync','some','Plugin\x20manifest\x20missing','manifest.json','parse','undefined','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','version','parameters','Invalid\x20manifest:\x20parameters\x20missing','views','Invalid\x20manifest:\x20views\x20missing','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','sidebar','always','icon','icon-apps','html','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','Warning:\x20agent\x20view\x20not\x20specified','create','role','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','find','Extracted\x20folder\x20removed','body','delete','dirname','webhookGet'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x979f,0x15d));var _0xf979=function(_0x11d153,_0xe9684e){_0x11d153=_0x11d153-0x0;var _0x5cd743=_0x979f[_0x11d153];return _0x5cd743;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf979('0x0'));var rimraf=require(_0xf979('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf979('0x2'));var rp=require(_0xf979('0x3'));var moment=require(_0xf979('0x4'));var BPromise=require(_0xf979('0x5'));var Mustache=require(_0xf979('0x6'));var util=require(_0xf979('0x7'));var path=require(_0xf979('0x8'));var sox=require(_0xf979('0x9'));var csv=require(_0xf979('0xa'));var ejs=require(_0xf979('0xb'));var fs=require('fs');var _=require(_0xf979('0xc'));var squel=require(_0xf979('0xd'));var crypto=require(_0xf979('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xf979('0xf'));var toCsv=require(_0xf979('0xa'));var querystring=require('querystring');var Papa=require(_0xf979('0x10'));var extract=require(_0xf979('0x11'));var rimraf=require('rimraf');var archiver=require(_0xf979('0x12'));var Redis=require(_0xf979('0x13'));var authService=require('../../components/auth/service');var qs=require(_0xf979('0x14'));var as=require(_0xf979('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf979('0x16'));var utils=require(_0xf979('0x17'));var config=require('../../config/environment');var db=require(_0xf979('0x18'))['db'];config['redis']=_['defaults'](config[_0xf979('0x19')],{'host':_0xf979('0x1a'),'port':0x18eb});var socket=require(_0xf979('0x1b'))(new Redis(config[_0xf979('0x19')]));require(_0xf979('0x1c'))[_0xf979('0x1d')](socket);function respondWithStatusCode(_0x571161,_0x2f62a8){_0x2f62a8=_0x2f62a8||0xcc;return function(_0xd9daf0){if(_0xd9daf0){return _0x571161['sendStatus'](_0x2f62a8);}return _0x571161['status'](_0x2f62a8)[_0xf979('0x1e')]();};}function respondWithResult(_0x5073cc,_0x59a590){_0x59a590=_0x59a590||0xc8;return function(_0x2fdfa2){if(_0x2fdfa2){return _0x5073cc[_0xf979('0x1f')](_0x59a590)[_0xf979('0x20')](_0x2fdfa2);}};}function respondWithFilteredResult(_0x3c2593,_0x25d8bf){return function(_0xa7d2d6){if(_0xa7d2d6){var _0x1c03cf=_0xa7d2d6[_0xf979('0x21')],_0x121450=_0x25d8bf[_0xf979('0x22')],_0x4df2e7=_0x25d8bf[_0xf979('0x22')]+_0x25d8bf['limit'],_0x2b3bb1;if(_0x4df2e7>=_0x1c03cf){_0x4df2e7=_0x1c03cf;_0x2b3bb1=0xc8;}else{_0x2b3bb1=0xce;}_0x3c2593[_0xf979('0x1f')](_0x2b3bb1);return _0x3c2593[_0xf979('0x23')](_0xf979('0x24'),_0x121450+'-'+_0x4df2e7+'/'+_0x1c03cf)[_0xf979('0x20')](_0xa7d2d6);}return null;};}function patchUpdates(_0x2a6db1){return function(_0x410bf0){try{jsonpatch[_0xf979('0x25')](_0x410bf0,_0x2a6db1,!![]);}catch(_0x1ac0b2){return BPromise[_0xf979('0x26')](_0x1ac0b2);}return _0x410bf0['save']();};}function saveUpdates(_0x4dd784,_0x195291){return function(_0x1b548d){if(_0x1b548d){return _0x1b548d[_0xf979('0x27')](_0x4dd784)[_0xf979('0x28')](function(_0x593ba6){return _0x593ba6;});}return null;};}function removeEntity(_0xfd3b7c,_0x3e4948){return function(_0x15111e){if(_0x15111e){return _0x15111e[_0xf979('0x29')]()['then'](function(){var _0x33c243=_0x15111e[_0xf979('0x2a')]({'plain':!![]});var _0x4ef47d=_0xf979('0x2b');return db[_0xf979('0x2c')][_0xf979('0x29')]({'where':{'type':_0x4ef47d,'resourceId':_0x33c243['id']}})[_0xf979('0x28')](function(){return _0x15111e;});})[_0xf979('0x28')](function(){_0xfd3b7c['status'](0xcc)[_0xf979('0x1e')]();});}};}function handleEntityNotFound(_0x16eade,_0x1520b2){return function(_0x358e9c){if(!_0x358e9c){_0x16eade[_0xf979('0x2d')](0x194);}return _0x358e9c;};}function handleError(_0x138f9b,_0x28d388){_0x28d388=_0x28d388||0x1f4;return function(_0x2c1eba){logger[_0xf979('0x2e')](_0x2c1eba[_0xf979('0x2f')]);if(_0x2c1eba['name']){delete _0x2c1eba[_0xf979('0x30')];}_0x138f9b[_0xf979('0x1f')](_0x28d388)[_0xf979('0x31')](_0x2c1eba);};}exports[_0xf979('0x32')]=function(_0x35b13e,_0x6fdf4e){var _0x4a6b65={},_0x56f47f={},_0x19602c={'count':0x0,'rows':[]};var _0x5770b0=_[_0xf979('0x33')](db[_0xf979('0x34')][_0xf979('0x35')],function(_0x2602f7){return{'name':_0x2602f7[_0xf979('0x36')],'type':_0x2602f7[_0xf979('0x37')][_0xf979('0x38')]};});_0x56f47f[_0xf979('0x39')]=_[_0xf979('0x33')](_0x5770b0,_0xf979('0x30'));_0x56f47f[_0xf979('0x3a')]=_[_0xf979('0x3b')](_0x35b13e['query']);_0x56f47f['filters']=_[_0xf979('0x3c')](_0x56f47f['model'],_0x56f47f[_0xf979('0x3a')]);_0x4a6b65[_0xf979('0x3d')]=_[_0xf979('0x3c')](_0x56f47f[_0xf979('0x39')],qs[_0xf979('0x3e')](_0x35b13e[_0xf979('0x3a')]['fields']));_0x4a6b65['attributes']=_0x4a6b65[_0xf979('0x3d')][_0xf979('0x3f')]?_0x4a6b65['attributes']:_0x56f47f['model'];if(!_0x35b13e[_0xf979('0x3a')][_0xf979('0x40')](_0xf979('0x41'))){_0x4a6b65[_0xf979('0x42')]=qs[_0xf979('0x42')](_0x35b13e['query']['limit']);_0x4a6b65[_0xf979('0x22')]=qs[_0xf979('0x22')](_0x35b13e[_0xf979('0x3a')][_0xf979('0x22')]);}_0x4a6b65[_0xf979('0x43')]=qs[_0xf979('0x44')](_0x35b13e[_0xf979('0x3a')]['sort']);_0x4a6b65['where']=qs[_0xf979('0x45')](_[_0xf979('0x46')](_0x35b13e[_0xf979('0x3a')],_0x56f47f[_0xf979('0x45')]));if(_0x35b13e[_0xf979('0x3a')][_0xf979('0x47')]){_0x4a6b65['where']=_['merge'](_0x4a6b65['where'],{'$or':_[_0xf979('0x33')](_0x5770b0,function(_0x190edf){if(_0x190edf[_0xf979('0x37')]!==_0xf979('0x48')){var _0x385d68={};_0x385d68[_0x190edf[_0xf979('0x30')]]={'$like':'%'+_0x35b13e['query']['filter']+'%'};return _0x385d68;}})});}_0x4a6b65=_[_0xf979('0x49')]({},_0x4a6b65,_0x35b13e['options']);var _0x4e78c6={'where':_0x4a6b65[_0xf979('0x4a')]};return db['Plugin'][_0xf979('0x21')](_0x4e78c6)[_0xf979('0x28')](function(_0x463b8c){_0x19602c[_0xf979('0x21')]=_0x463b8c;if(_0x35b13e[_0xf979('0x3a')][_0xf979('0x4b')]){_0x4a6b65[_0xf979('0x4c')]=[{'all':!![]}];}return db['Plugin']['findAll'](_0x4a6b65);})[_0xf979('0x28')](function(_0x3c1ee4){_0x19602c['rows']=_0x3c1ee4;return _0x19602c;})['then'](respondWithFilteredResult(_0x6fdf4e,_0x4a6b65))[_0xf979('0x4d')](handleError(_0x6fdf4e,null));};exports[_0xf979('0x4e')]=function(_0x34eed2,_0x4c0234){var _0x34117a={'raw':!![],'where':{'id':_0x34eed2[_0xf979('0x4f')]['id']}},_0x2492f6={};_0x2492f6[_0xf979('0x39')]=_['keys'](db[_0xf979('0x34')][_0xf979('0x35')]);_0x2492f6[_0xf979('0x3a')]=_[_0xf979('0x3b')](_0x34eed2[_0xf979('0x3a')]);_0x2492f6[_0xf979('0x45')]=_[_0xf979('0x3c')](_0x2492f6['model'],_0x2492f6[_0xf979('0x3a')]);_0x34117a['attributes']=_['intersection'](_0x2492f6[_0xf979('0x39')],qs[_0xf979('0x3e')](_0x34eed2['query'][_0xf979('0x3e')]));_0x34117a[_0xf979('0x3d')]=_0x34117a['attributes'][_0xf979('0x3f')]?_0x34117a[_0xf979('0x3d')]:_0x2492f6['model'];if(_0x34eed2[_0xf979('0x3a')][_0xf979('0x4b')]){_0x34117a[_0xf979('0x4c')]=[{'all':!![]}];}_0x34117a=_['merge']({},_0x34117a,_0x34eed2[_0xf979('0x50')]);return db[_0xf979('0x34')]['find'](_0x34117a)['then'](handleEntityNotFound(_0x4c0234,null))[_0xf979('0x28')](respondWithResult(_0x4c0234,null))['catch'](handleError(_0x4c0234,null));};exports['download']=function(_0x5e89a7,_0x3362de,_0x212f1e){return db['Plugin']['find']({'where':{'id':_0x5e89a7['params']['id']},'attributes':['name',_0xf979('0x8')],'raw':!![]})[_0xf979('0x28')](handleEntityNotFound(_0x3362de,null))[_0xf979('0x28')](function(_0x5eccf7){if(_0x5eccf7){var _0x18b72b=path['join'](config['root'],_0xf979('0x51'),util['format'](_0xf979('0x52'),path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')])));var _0x205dce=fs[_0xf979('0x54')](_0x18b72b);var _0x3db7d9=archiver(_0xf979('0x55'),{'zlib':{'level':0x9}});_0x3db7d9['on']('warning',function(_0x4a9e0b){if(_0x4a9e0b[_0xf979('0x56')]==='ENOENT'){logger[_0xf979('0x2e')](_0x4a9e0b);}else{throw new db[(_0xf979('0x57'))][(_0xf979('0x58'))]('Error\x20while\x20generating\x20the\x20zip\x20archive');}});_0x3db7d9['on'](_0xf979('0x2e'),function(_0x41dbde){throw new db[(_0xf979('0x57'))]['Error'](_0xf979('0x59'));});_0x3db7d9['pipe'](_0x205dce);_0x3db7d9[_0xf979('0x5a')]('**/*',{'cwd':path[_0xf979('0x5b')](config[_0xf979('0x5c')],'server/files/plugins',path['dirname'](_0x5eccf7[_0xf979('0x8')])),'ignore':[path[_0xf979('0x5b')](path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')]),'node_modules/**/*'),path[_0xf979('0x5b')](path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')]),_0xf979('0x5d'))],'nodir':!![]})[_0xf979('0x5e')]();_0x205dce['on'](_0xf979('0x5f'),function(){if(!fs[_0xf979('0x60')](_0x18b72b)){throw new db[(_0xf979('0x57'))]['Error'](_0xf979('0x61'));}return _0x3362de['download'](_0x18b72b,util[_0xf979('0x62')](_0xf979('0x52'),path[_0xf979('0x53')](_0x5eccf7[_0xf979('0x8')])),function(_0x235e55){if(_0x235e55){throw new db[(_0xf979('0x57'))][(_0xf979('0x58'))]('Error\x20while\x20downloading\x20the\x20plugin');}fs[_0xf979('0x63')](_0x18b72b);logger[_0xf979('0x64')]('Download\x20completed');logger[_0xf979('0x64')](_0xf979('0x65'));});});}return null;})[_0xf979('0x4d')](handleError(_0x3362de,null));};exports[_0xf979('0x66')]=function(_0x3322d8,_0x53d159,_0x4fb868){var _0x3bd1c8=path[_0xf979('0x53')](_0x3322d8[_0xf979('0x67')][_0xf979('0x68')],path['extname'](_0x3322d8[_0xf979('0x67')]['filename']));var _0xfe6033=path[_0xf979('0x5b')](config[_0xf979('0x5c')],_0xf979('0x51'),_0x3322d8[_0xf979('0x67')][_0xf979('0x68')]);var _0x5c27c4=path['join'](config['root'],_0xf979('0x51'),_0x3bd1c8);logger[_0xf979('0x64')](_0xf979('0x69'),_0xfe6033);logger['info'](_0xf979('0x6a'),_0x5c27c4);try{fs[_0xf979('0x6b')](_0xfe6033,parseInt('0777',0x8));extract(_0xfe6033,{'dir':_0x5c27c4},function(_0x142589){if(_0x142589){logger[_0xf979('0x2e')](_0x142589);handleError(_0x142589,!![]);};var _0x571556=fs[_0xf979('0x6c')](_0x5c27c4);if(_0x571556[_0xf979('0x3f')]>0x1){removeReferences(_0xfe6033,_0x5c27c4);logger[_0xf979('0x2e')](_0xf979('0x6d'));return _0x4fb868(new Error('Invalid\x20plugin\x20structure'));}var _0x2f2511=fs[_0xf979('0x6e')](path[_0xf979('0x5b')](_0x5c27c4,_0x571556[0x0]));if(_0x2f2511['isFile']()){removeReferences(_0xfe6033,_0x5c27c4);logger['error'](_0xf979('0x6d'));return _0x4fb868(new Error(_0xf979('0x6d')));}if(_0x2f2511['isDirectory']()){var _0x1e0aa7=fs['readdirSync'](path[_0xf979('0x5b')](_0x5c27c4,_0x571556[0x0]));if(_0x1e0aa7[_0xf979('0x3f')]===0x0){removeReferences(_0xfe6033,_0x5c27c4);logger['error'](_0xf979('0x6d'));return _0x4fb868(new Error('Invalid\x20plugin\x20structure'));}var _0xcb6425=_0x1e0aa7[_0xf979('0x6f')](function(_0x3649ce){return _0x3649ce==='manifest.json';});if(!_0xcb6425){return _0x4fb868(new Error(_0xf979('0x70')));}var _0x312542=fs['readFileSync'](path[_0xf979('0x5b')](_0x5c27c4,_0x571556[0x0],_0xf979('0x71')));var _0x1ba182=JSON[_0xf979('0x72')](_0x312542);if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x30')]){return _0x4fb868(new Error(_0xf979('0x74')));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x37')]){return _0x4fb868(new Error(_0xf979('0x75')));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x76')]){return _0x4fb868(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x77')]){return _0x4fb868(new Error(_0xf979('0x78')));}if(_0x1ba182['type']==='html'){if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')]){return _0x4fb868(new Error(_0xf979('0x7a')));}if('undefined'==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7b')]&&_0xf979('0x73')==typeof _0x1ba182['parameters'][_0xf979('0x79')][_0xf979('0x7c')]){return _0x4fb868(new Error(_0xf979('0x7d')));}}else if(_0x1ba182['type']===_0xf979('0x7e')){if('undefined'==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x7f')]){return _0x4fb868(new Error(_0xf979('0x80')));}if(_0xf979('0x73')==typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x81')]){return _0x4fb868(new Error(_0xf979('0x82')));}}else{return _0x4fb868(new Error(_0xf979('0x83')));}var _0xbdfb32=_0x1ba182[_0xf979('0x30')];var _0x69ec3a=_0x1ba182['description'];var _0x51fe7c=_0x1ba182[_0xf979('0x37')];var _0x3684bb=_0x1ba182[_0xf979('0x84')]?_0x1ba182[_0xf979('0x84')]:_0xf979('0x85');var _0x23c417=_0x1ba182[_0xf979('0x86')]?_0x1ba182['icon']:_0xf979('0x87');var _0x2988aa='';var _0x52f3ba='';var _0x46eb89='';var _0x53418f='';var _0x35ef4b=_0x1ba182[_0xf979('0x76')];if(_0x51fe7c===_0xf979('0x88')){if('undefined'!=typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7b')]){var _0x1e716f=_0x1ba182['parameters']['views'][_0xf979('0x7b')];if(!/^(f|ht)tps?:\/\//i[_0xf979('0x89')](_0x1e716f)){_0x2988aa=path[_0xf979('0x5b')](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x1e716f);}else{_0x2988aa=_0x1e716f;}}else{logger[_0xf979('0x64')](_0xf979('0x8b'));}if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')]['views'][_0xf979('0x7c')]){var _0x84e5eb=_0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7c')];if(!/^(f|ht)tps?:\/\//i['test'](_0x84e5eb)){_0x52f3ba=path[_0xf979('0x5b')](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x84e5eb);}else{_0x52f3ba=_0x84e5eb;}}else{logger[_0xf979('0x64')](_0xf979('0x8c'));}}else if(_0x51fe7c===_0xf979('0x7e')){_0x46eb89=_0x1ba182[_0xf979('0x77')][_0xf979('0x7f')];_0x53418f=_0x1ba182[_0xf979('0x77')][_0xf979('0x81')];if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')]){if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')][_0xf979('0x79')]['admin']){var _0x1e716f=_0x1ba182[_0xf979('0x77')]['views'][_0xf979('0x7b')];if(!/^(f|ht)tps?:\/\//i['test'](_0x1e716f)){_0x2988aa=path['join'](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x1e716f);}else{_0x2988aa=_0x1e716f;}}if(_0xf979('0x73')!=typeof _0x1ba182[_0xf979('0x77')]['views'][_0xf979('0x7c')]){var _0x84e5eb=_0x1ba182[_0xf979('0x77')][_0xf979('0x79')][_0xf979('0x7c')];if(!/^(f|ht)tps?:\/\//i[_0xf979('0x89')](_0x84e5eb)){_0x52f3ba=path[_0xf979('0x5b')](_0xf979('0x8a'),_0x3bd1c8,_0x571556[0x0],_0x84e5eb);}else{_0x52f3ba=_0x84e5eb;}}}}var _0x20a102={'name':_0xbdfb32,'description':_0x69ec3a,'path':path[_0xf979('0x5b')](_0x3bd1c8,_0x571556[0x0]),'type':_0x51fe7c,'sidebar':_0x3684bb,'icon':_0x23c417,'adminUrl':_0x2988aa,'agentUrl':_0x52f3ba,'scriptName':_0x46eb89,'scriptPath':_0x53418f,'version':_0x35ef4b};removeReferences(_0xfe6033,null);return db[_0xf979('0x34')][_0xf979('0x8d')](_0x20a102)[_0xf979('0x28')](function(_0xd3f024){var _0x1a5ceb={'role':_0x3322d8['body'][_0xf979('0x8e')],'userProfileId':_0x3322d8['body']['userProfileId']};if(!_0x1a5ceb)throw new Error(_0xf979('0x8f'));if(_0x1a5ceb[_0xf979('0x8e')]===_0xf979('0x90')){var _0x25e255=_0xd3f024['get']({'plain':!![]});return db[_0xf979('0x91')][_0xf979('0x92')]({'where':{'name':_0xf979('0x2b'),'userProfileId':_0x1a5ceb['userProfileId']},'raw':!![]})[_0xf979('0x28')](function(_0x31bc79){if(_0x31bc79&&_0x31bc79['autoAssociation']===0x0){return db[_0xf979('0x2c')][_0xf979('0x8d')]({'name':_0x25e255[_0xf979('0x30')],'resourceId':_0x25e255['id'],'type':_0x31bc79['name'],'sectionId':_0x31bc79['id']},{})[_0xf979('0x28')](function(){return _0xd3f024;});}else{return _0xd3f024;}})[_0xf979('0x4d')](function(_0x39c732){logger[_0xf979('0x2e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x39c732);throw _0x39c732;});}return _0xd3f024;})[_0xf979('0x28')](respondWithResult(_0x53d159,null))['catch'](handleError(_0x53d159,null));}});}catch(_0x392af6){_0x53d159['status'](0x1f4)[_0xf979('0x31')](_0x392af6);}};function removeReferences(_0x2e8aa7,_0x26fa7d){try{if(_0x2e8aa7){fs[_0xf979('0x63')](_0x2e8aa7);logger[_0xf979('0x64')]('Zip\x20archive\x20removed');}if(_0x26fa7d){rimraf(_0x26fa7d,function(){});logger['info'](_0xf979('0x93'));}}catch(_0x368629){logger[_0xf979('0x2e')](_0x368629);}}exports[_0xf979('0x27')]=function(_0x2ce53b,_0x20500d,_0x2a84bb){return db[_0xf979('0x34')][_0xf979('0x92')]({'where':{'id':_0x2ce53b[_0xf979('0x4f')]['id']}})[_0xf979('0x28')](handleEntityNotFound(_0x20500d,null))['then'](saveUpdates(_0x2ce53b[_0xf979('0x94')],null))['then'](respondWithResult(_0x20500d,null))[_0xf979('0x4d')](handleError(_0x20500d,null));};exports[_0xf979('0x95')]=function(_0x419bf3,_0x47da6a,_0x422852){return db[_0xf979('0x34')][_0xf979('0x92')]({'where':{'id':_0x419bf3['params']['id']}})[_0xf979('0x28')](function(_0x24631e){if(_0x24631e){return _0x24631e[_0xf979('0x29')]();}})[_0xf979('0x28')](function(_0x1b4766){rimraf(path[_0xf979('0x5b')](config[_0xf979('0x5c')],_0xf979('0x51'),path[_0xf979('0x96')](_0x1b4766['path'])),function(){});return _0x1b4766;})['then'](handleEntityNotFound(_0x47da6a,null))[_0xf979('0x28')](respondWithStatusCode(_0x47da6a,null))[_0xf979('0x4d')](handleError(_0x47da6a,null));};exports[_0xf979('0x97')]=function(_0x436b5b,_0x2a8a1d,_0x1fa842){return BPromise['resolve']()[_0xf979('0x28')](function(){if(!_0x436b5b[_0xf979('0x3a')][_0xf979('0x8')]){throw new Error(_0xf979('0x98'));}if(!_0x436b5b[_0xf979('0x3a')][_0xf979('0x99')]){throw new Error(_0xf979('0x9a'));}var _0x523aee=_0x436b5b[_0xf979('0x3a')][_0xf979('0x9b')]?_0x436b5b[_0xf979('0x3a')][_0xf979('0x9b')]+':'+_0x436b5b[_0xf979('0x3a')]['port']:_0xf979('0x9c')+_0x436b5b[_0xf979('0x3a')]['port'];var _0x573c42=_0x436b5b['query'][_0xf979('0x20')]?_0x436b5b[_0xf979('0x3a')][_0xf979('0x20')]:!![];var _0x1c1818=_0x436b5b[_0xf979('0x3a')]['encoding']?_0x436b5b[_0xf979('0x3a')][_0xf979('0x9d')]:null;var _0x339e0b={'method':_0x436b5b['method'],'uri':util[_0xf979('0x62')](_0xf979('0x9e'),_0x523aee,_0x436b5b[_0xf979('0x3a')][_0xf979('0x8')]),'json':_0x573c42,'resolveWithFullResponse':!![],'encoding':_0x1c1818,'qs':_0x436b5b[_0xf979('0x3a')]};if(_0x436b5b[_0xf979('0x9f')]){_0x339e0b[_0xf979('0x9f')]=_0x436b5b[_0xf979('0x9f')];if(_0x339e0b['headers'][_0xf979('0xa0')]){delete _0x339e0b[_0xf979('0x9f')][_0xf979('0xa0')];}}if(_0x339e0b['headers'][_0xf979('0xa1')]){delete _0x339e0b[_0xf979('0x9f')]['content-type'];}return rp(_0x339e0b);})[_0xf979('0x28')](function(_0x4a7ff2){if(_0x4a7ff2){_0x2a8a1d['set'](_0x4a7ff2[_0xf979('0x9f')]);logger['info'](_0x4a7ff2[_0xf979('0x94')]);if(_[_0xf979('0xa2')](_0x436b5b['query']['path'],'download')&&_0x4a7ff2[_0xf979('0xa3')]==0x1f4){return _0x2a8a1d[_0xf979('0x2d')](_0x4a7ff2[_0xf979('0xa3')]);}else{return _0x2a8a1d['status'](_0x4a7ff2[_0xf979('0xa3')])['send'](_0x4a7ff2[_0xf979('0x94')]);}}else{return _0x2a8a1d['sendStatus'](0xc8);}})[_0xf979('0x4d')](handleError(_0x2a8a1d,null));};exports[_0xf979('0xa4')]=function(_0x3c2071,_0xc9f796,_0x25d5e0){return BPromise[_0xf979('0xa5')]()[_0xf979('0x28')](function(){if(!_0x3c2071[_0xf979('0x3a')][_0xf979('0x8')]){throw new Error(_0xf979('0x98'));}if(!_0x3c2071['query'][_0xf979('0x99')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x57782=_0x3c2071[_0xf979('0x3a')]['hostname']?_0x3c2071[_0xf979('0x3a')]['hostname']+':'+_0x3c2071[_0xf979('0x3a')][_0xf979('0x99')]:_0xf979('0x9c')+_0x3c2071['query'][_0xf979('0x99')];var _0x2ec4f8=_0x3c2071['query'][_0xf979('0x20')]?_0x3c2071[_0xf979('0x3a')]['json']:!![];var _0x5a221b=_0x3c2071[_0xf979('0x3a')][_0xf979('0x9d')]?_0x3c2071[_0xf979('0x3a')][_0xf979('0x9d')]:null;var _0x110d43={'method':_0x3c2071[_0xf979('0xa6')],'uri':util['format']('%s%s',_0x57782,_0x3c2071[_0xf979('0x3a')][_0xf979('0x8')]),'json':_0x2ec4f8,'resolveWithFullResponse':!![],'encoding':_0x5a221b,'body':_0x3c2071[_0xf979('0x94')]};if(_0x3c2071['headers']){_0x110d43[_0xf979('0x9f')]=_0x3c2071[_0xf979('0x9f')];if(_0x110d43[_0xf979('0x9f')][_0xf979('0xa0')]){delete _0x110d43[_0xf979('0x9f')][_0xf979('0xa0')];}}if(_0x110d43[_0xf979('0x9f')]['content-type']){delete _0x110d43[_0xf979('0x9f')][_0xf979('0xa1')];}return rp(_0x110d43);})[_0xf979('0x28')](function(_0x151ba5){if(_0x151ba5){_0xc9f796[_0xf979('0x23')](_0x151ba5['headers']);logger[_0xf979('0x64')](_0x151ba5['body']);return _0xc9f796[_0xf979('0x1f')](_0x151ba5[_0xf979('0xa3')])['send'](_0x151ba5['body']);}else{return _0xc9f796[_0xf979('0x2d')](0xc8);}})[_0xf979('0x4d')](handleError(_0xc9f796,null));};
\ No newline at end of file
+var _0xb925=['upload','file','filename','Plugin\x20upload\x20destination:\x20%s','chmodSync','0777','readdirSync','Invalid\x20plugin\x20structure','lstatSync','isDirectory','some','manifest.json','readFileSync','parse','undefined','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20type\x20missing','version','parameters','Invalid\x20manifest:\x20views\x20missing','views','agent','Invalid\x20manifest:\x20no\x20view\x20specified','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','sidebar','always','icon','html','admin','test','plugins','Warning:\x20agent\x20view\x20not\x20specified','script','scriptPath','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','get','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Extracted\x20folder\x20removed','delete','webhookGet','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','port','hostname','encoding','%s%s','headers','content-type','endsWith','statusCode','\x27PORT\x27\x20parameter\x20not\x20specified','http://localhost:','method','content-length','eml-format','zip-dir','fast-json-patch','request-promise','mustache','util','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','papaparse','rimraf','archiver','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','sendStatus','status','end','json','offset','count','set','reject','save','update','then','Plugins','destroy','stack','name','send','index','map','Plugin','rawAttributes','fieldName','type','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','keys','find','download','root','%s.zip','basename','createWriteStream','zip','warning','code','ENOENT','Sequelize','Error\x20while\x20generating\x20the\x20zip\x20archive','error','Error','glob','join','server/files/plugins','dirname','attachments/**/*','finalize','existsSync','Plugin\x20not\x20found','format','unlinkSync','info','Download\x20completed'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xb925,0x18e));var _0x5b92=function(_0x59ee41,_0xaf7db8){_0x59ee41=_0x59ee41-0x0;var _0x3ecd3e=_0xb925[_0x59ee41];return _0x3ecd3e;};'use strict';var emlformat=require(_0x5b92('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5b92('0x1'));var jsonpatch=require(_0x5b92('0x2'));var rp=require(_0x5b92('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x5b92('0x4'));var util=require(_0x5b92('0x5'));var path=require(_0x5b92('0x6'));var sox=require('sox');var csv=require(_0x5b92('0x7'));var ejs=require(_0x5b92('0x8'));var fs=require('fs');var fs_extra=require(_0x5b92('0x9'));var _=require(_0x5b92('0xa'));var squel=require('squel');var crypto=require(_0x5b92('0xb'));var jsforce=require(_0x5b92('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x5b92('0xd'));var extract=require('extract-zip');var rimraf=require(_0x5b92('0xe'));var archiver=require(_0x5b92('0xf'));var Redis=require(_0x5b92('0x10'));var authService=require(_0x5b92('0x11'));var qs=require(_0x5b92('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x5b92('0x13'))(_0x5b92('0x14'));var utils=require(_0x5b92('0x15'));var config=require(_0x5b92('0x16'));var licenseUtil=require(_0x5b92('0x17'));var db=require(_0x5b92('0x18'))['db'];config[_0x5b92('0x19')]=_[_0x5b92('0x1a')](config[_0x5b92('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x5b92('0x1b'))(new Redis(config['redis']));require('./plugin.socket')[_0x5b92('0x1c')](socket);function respondWithStatusCode(_0x47ffd3,_0x495fd7){_0x495fd7=_0x495fd7||0xcc;return function(_0x324c00){if(_0x324c00){return _0x47ffd3[_0x5b92('0x1d')](_0x495fd7);}return _0x47ffd3[_0x5b92('0x1e')](_0x495fd7)[_0x5b92('0x1f')]();};}function respondWithResult(_0x407036,_0x502774){_0x502774=_0x502774||0xc8;return function(_0x37354e){if(_0x37354e){return _0x407036[_0x5b92('0x1e')](_0x502774)[_0x5b92('0x20')](_0x37354e);}};}function respondWithFilteredResult(_0xbe6112,_0x5cf351){return function(_0x31cab6){if(_0x31cab6){var _0x2c88ff=typeof _0x5cf351[_0x5b92('0x21')]==='undefined'&&typeof _0x5cf351['limit']==='undefined';var _0x3f682d=_0x31cab6[_0x5b92('0x22')];var _0x4dae14=_0x2c88ff?0x0:_0x5cf351['offset'];var _0x211b42=_0x2c88ff?_0x31cab6[_0x5b92('0x22')]:_0x5cf351[_0x5b92('0x21')]+_0x5cf351['limit'];var _0x50deac;if(_0x211b42>=_0x3f682d){_0x211b42=_0x3f682d;_0x50deac=0xc8;}else{_0x50deac=0xce;}_0xbe6112[_0x5b92('0x1e')](_0x50deac);return _0xbe6112[_0x5b92('0x23')]('Content-Range',_0x4dae14+'-'+_0x211b42+'/'+_0x3f682d)[_0x5b92('0x20')](_0x31cab6);}return null;};}function patchUpdates(_0x53d350){return function(_0x8490bd){try{jsonpatch['apply'](_0x8490bd,_0x53d350,!![]);}catch(_0x43b1ff){return BPromise[_0x5b92('0x24')](_0x43b1ff);}return _0x8490bd[_0x5b92('0x25')]();};}function saveUpdates(_0x5231cf,_0x1c514b){return function(_0x219109){if(_0x219109){return _0x219109[_0x5b92('0x26')](_0x5231cf)[_0x5b92('0x27')](function(_0x1fee20){return _0x1fee20;});}return null;};}function removeEntity(_0x37950f,_0x565cbf){return function(_0xa56ea1){if(_0xa56ea1){return _0xa56ea1['destroy']()[_0x5b92('0x27')](function(){var _0x3622de=_0xa56ea1['get']({'plain':!![]});var _0x16b6ed=_0x5b92('0x28');return db['UserProfileResource'][_0x5b92('0x29')]({'where':{'type':_0x16b6ed,'resourceId':_0x3622de['id']}})[_0x5b92('0x27')](function(){return _0xa56ea1;});})[_0x5b92('0x27')](function(){_0x37950f[_0x5b92('0x1e')](0xcc)[_0x5b92('0x1f')]();});}};}function handleEntityNotFound(_0x4621c9,_0x49d819){return function(_0x5cefe2){if(!_0x5cefe2){_0x4621c9[_0x5b92('0x1d')](0x194);}return _0x5cefe2;};}function handleError(_0x203501,_0x433b14){_0x433b14=_0x433b14||0x1f4;return function(_0x9a31eb){logger['error'](_0x9a31eb[_0x5b92('0x2a')]);if(_0x9a31eb['name']){delete _0x9a31eb[_0x5b92('0x2b')];}_0x203501['status'](_0x433b14)[_0x5b92('0x2c')](_0x9a31eb);};}exports[_0x5b92('0x2d')]=function(_0x157efb,_0x34701f){var _0x230120={},_0x30806e={},_0x5e09cd={'count':0x0,'rows':[]};var _0x27aff1=_[_0x5b92('0x2e')](db[_0x5b92('0x2f')][_0x5b92('0x30')],function(_0x2e1564){return{'name':_0x2e1564[_0x5b92('0x31')],'type':_0x2e1564[_0x5b92('0x32')]['key']};});_0x30806e[_0x5b92('0x33')]=_[_0x5b92('0x2e')](_0x27aff1,_0x5b92('0x2b'));_0x30806e[_0x5b92('0x34')]=_['keys'](_0x157efb['query']);_0x30806e[_0x5b92('0x35')]=_[_0x5b92('0x36')](_0x30806e[_0x5b92('0x33')],_0x30806e['query']);_0x230120['attributes']=_['intersection'](_0x30806e[_0x5b92('0x33')],qs[_0x5b92('0x37')](_0x157efb[_0x5b92('0x34')][_0x5b92('0x37')]));_0x230120[_0x5b92('0x38')]=_0x230120['attributes'][_0x5b92('0x39')]?_0x230120[_0x5b92('0x38')]:_0x30806e[_0x5b92('0x33')];if(!_0x157efb['query'][_0x5b92('0x3a')](_0x5b92('0x3b'))){_0x230120[_0x5b92('0x3c')]=qs['limit'](_0x157efb[_0x5b92('0x34')][_0x5b92('0x3c')]);_0x230120[_0x5b92('0x21')]=qs[_0x5b92('0x21')](_0x157efb[_0x5b92('0x34')]['offset']);}_0x230120[_0x5b92('0x3d')]=qs[_0x5b92('0x3e')](_0x157efb[_0x5b92('0x34')][_0x5b92('0x3e')]);_0x230120[_0x5b92('0x3f')]=qs[_0x5b92('0x35')](_[_0x5b92('0x40')](_0x157efb[_0x5b92('0x34')],_0x30806e[_0x5b92('0x35')]),_0x27aff1);if(_0x157efb['query']['filter']){_0x230120['where']=_[_0x5b92('0x41')](_0x230120[_0x5b92('0x3f')],{'$or':_[_0x5b92('0x2e')](_0x27aff1,function(_0x36d2be){if(_0x36d2be[_0x5b92('0x32')]!==_0x5b92('0x42')){var _0x1b7426={};_0x1b7426[_0x36d2be[_0x5b92('0x2b')]]={'$like':'%'+_0x157efb[_0x5b92('0x34')][_0x5b92('0x43')]+'%'};return _0x1b7426;}})});}_0x230120=_[_0x5b92('0x41')]({},_0x230120,_0x157efb[_0x5b92('0x44')]);var _0x1e478e={'where':_0x230120[_0x5b92('0x3f')]};return db[_0x5b92('0x2f')][_0x5b92('0x22')](_0x1e478e)[_0x5b92('0x27')](function(_0x448dfb){_0x5e09cd[_0x5b92('0x22')]=_0x448dfb;if(_0x157efb[_0x5b92('0x34')][_0x5b92('0x45')]){_0x230120[_0x5b92('0x46')]=[{'all':!![]}];}return db[_0x5b92('0x2f')][_0x5b92('0x47')](_0x230120);})[_0x5b92('0x27')](function(_0x19016e){_0x5e09cd[_0x5b92('0x48')]=_0x19016e;return _0x5e09cd;})[_0x5b92('0x27')](respondWithFilteredResult(_0x34701f,_0x230120))[_0x5b92('0x49')](handleError(_0x34701f,null));};exports[_0x5b92('0x4a')]=function(_0x505cf9,_0xae49b3){var _0xf7c2a2={'raw':!![],'where':{'id':_0x505cf9[_0x5b92('0x4b')]['id']}},_0x4cbbb7={};_0x4cbbb7[_0x5b92('0x33')]=_[_0x5b92('0x4c')](db['Plugin'][_0x5b92('0x30')]);_0x4cbbb7['query']=_['keys'](_0x505cf9[_0x5b92('0x34')]);_0x4cbbb7['filters']=_[_0x5b92('0x36')](_0x4cbbb7[_0x5b92('0x33')],_0x4cbbb7[_0x5b92('0x34')]);_0xf7c2a2['attributes']=_[_0x5b92('0x36')](_0x4cbbb7[_0x5b92('0x33')],qs[_0x5b92('0x37')](_0x505cf9[_0x5b92('0x34')][_0x5b92('0x37')]));_0xf7c2a2['attributes']=_0xf7c2a2[_0x5b92('0x38')][_0x5b92('0x39')]?_0xf7c2a2['attributes']:_0x4cbbb7[_0x5b92('0x33')];if(_0x505cf9['query'][_0x5b92('0x45')]){_0xf7c2a2[_0x5b92('0x46')]=[{'all':!![]}];}_0xf7c2a2=_[_0x5b92('0x41')]({},_0xf7c2a2,_0x505cf9[_0x5b92('0x44')]);return db[_0x5b92('0x2f')][_0x5b92('0x4d')](_0xf7c2a2)[_0x5b92('0x27')](handleEntityNotFound(_0xae49b3,null))[_0x5b92('0x27')](respondWithResult(_0xae49b3,null))['catch'](handleError(_0xae49b3,null));};exports[_0x5b92('0x4e')]=function(_0x58d7e1,_0x5f177c,_0x4daac8){return db[_0x5b92('0x2f')]['find']({'where':{'id':_0x58d7e1[_0x5b92('0x4b')]['id']},'attributes':[_0x5b92('0x2b'),_0x5b92('0x6')],'raw':!![]})[_0x5b92('0x27')](handleEntityNotFound(_0x5f177c,null))[_0x5b92('0x27')](function(_0x4ac213){if(_0x4ac213){var _0x1d7fd1=path['join'](config[_0x5b92('0x4f')],'server/files/plugins',util['format'](_0x5b92('0x50'),path[_0x5b92('0x51')](_0x4ac213[_0x5b92('0x6')])));var _0x144621=fs[_0x5b92('0x52')](_0x1d7fd1);var _0xcbbe8e=archiver(_0x5b92('0x53'),{'zlib':{'level':0x9}});_0xcbbe8e['on'](_0x5b92('0x54'),function(_0xd50416){if(_0xd50416[_0x5b92('0x55')]===_0x5b92('0x56')){logger['error'](_0xd50416);}else{throw new db[(_0x5b92('0x57'))]['Error'](_0x5b92('0x58'));}});_0xcbbe8e['on'](_0x5b92('0x59'),function(_0x1a470d){throw new db[(_0x5b92('0x57'))][(_0x5b92('0x5a'))](_0x5b92('0x58'));});_0xcbbe8e['pipe'](_0x144621);_0xcbbe8e[_0x5b92('0x5b')]('**/*',{'cwd':path[_0x5b92('0x5c')](config[_0x5b92('0x4f')],_0x5b92('0x5d'),path[_0x5b92('0x5e')](_0x4ac213[_0x5b92('0x6')])),'ignore':[path[_0x5b92('0x5c')](path[_0x5b92('0x51')](_0x4ac213[_0x5b92('0x6')]),'node_modules/**/*'),path[_0x5b92('0x5c')](path[_0x5b92('0x51')](_0x4ac213[_0x5b92('0x6')]),_0x5b92('0x5f'))],'nodir':!![]})[_0x5b92('0x60')]();_0x144621['on']('close',function(){if(!fs[_0x5b92('0x61')](_0x1d7fd1)){throw new db[(_0x5b92('0x57'))][(_0x5b92('0x5a'))](_0x5b92('0x62'));}return _0x5f177c[_0x5b92('0x4e')](_0x1d7fd1,util[_0x5b92('0x63')](_0x5b92('0x50'),path[_0x5b92('0x51')](_0x4ac213[_0x5b92('0x6')])),function(_0x5c22e8){if(_0x5c22e8){throw new db[(_0x5b92('0x57'))][(_0x5b92('0x5a'))]('Error\x20while\x20downloading\x20the\x20plugin');}fs[_0x5b92('0x64')](_0x1d7fd1);logger[_0x5b92('0x65')](_0x5b92('0x66'));logger[_0x5b92('0x65')]('Temporary\x20file\x20removed');});});}return null;})['catch'](handleError(_0x5f177c,null));};exports[_0x5b92('0x67')]=function(_0x4111b5,_0xacf4c3,_0x5d1c85){var _0x5d9330=path[_0x5b92('0x51')](_0x4111b5[_0x5b92('0x68')]['filename'],path['extname'](_0x4111b5[_0x5b92('0x68')][_0x5b92('0x69')]));var _0x198df0=path['join'](config[_0x5b92('0x4f')],_0x5b92('0x5d'),_0x4111b5[_0x5b92('0x68')][_0x5b92('0x69')]);var _0x4a0d09=path[_0x5b92('0x5c')](config[_0x5b92('0x4f')],_0x5b92('0x5d'),_0x5d9330);logger[_0x5b92('0x65')]('Plugin\x20upload\x20filepath:\x20%s',_0x198df0);logger[_0x5b92('0x65')](_0x5b92('0x6a'),_0x4a0d09);try{fs[_0x5b92('0x6b')](_0x198df0,parseInt(_0x5b92('0x6c'),0x8));extract(_0x198df0,{'dir':_0x4a0d09},function(_0x372ea8){if(_0x372ea8){logger[_0x5b92('0x59')](_0x372ea8);handleError(_0x372ea8,!![]);};var _0x1bdddd=fs[_0x5b92('0x6d')](_0x4a0d09);if(_0x1bdddd[_0x5b92('0x39')]>0x1){removeReferences(_0x198df0,_0x4a0d09);logger[_0x5b92('0x59')](_0x5b92('0x6e'));return _0x5d1c85(new Error('Invalid\x20plugin\x20structure'));}var _0x8a1eb2=fs[_0x5b92('0x6f')](path[_0x5b92('0x5c')](_0x4a0d09,_0x1bdddd[0x0]));if(_0x8a1eb2['isFile']()){removeReferences(_0x198df0,_0x4a0d09);logger[_0x5b92('0x59')]('Invalid\x20plugin\x20structure');return _0x5d1c85(new Error(_0x5b92('0x6e')));}if(_0x8a1eb2[_0x5b92('0x70')]()){var _0x2067d6=fs[_0x5b92('0x6d')](path[_0x5b92('0x5c')](_0x4a0d09,_0x1bdddd[0x0]));if(_0x2067d6[_0x5b92('0x39')]===0x0){removeReferences(_0x198df0,_0x4a0d09);logger[_0x5b92('0x59')](_0x5b92('0x6e'));return _0x5d1c85(new Error(_0x5b92('0x6e')));}var _0x190078=_0x2067d6[_0x5b92('0x71')](function(_0xb3d128){return _0xb3d128===_0x5b92('0x72');});if(!_0x190078){return _0x5d1c85(new Error('Plugin\x20manifest\x20missing'));}var _0x47c062=fs[_0x5b92('0x73')](path[_0x5b92('0x5c')](_0x4a0d09,_0x1bdddd[0x0],_0x5b92('0x72')));var _0x22ddb8=JSON[_0x5b92('0x74')](_0x47c062);if(_0x5b92('0x75')==typeof _0x22ddb8[_0x5b92('0x2b')]){return _0x5d1c85(new Error(_0x5b92('0x76')));}if(_0x5b92('0x75')==typeof _0x22ddb8[_0x5b92('0x32')]){return _0x5d1c85(new Error(_0x5b92('0x77')));}if(_0x5b92('0x75')==typeof _0x22ddb8[_0x5b92('0x78')]){return _0x5d1c85(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if(_0x5b92('0x75')==typeof _0x22ddb8[_0x5b92('0x79')]){return _0x5d1c85(new Error('Invalid\x20manifest:\x20parameters\x20missing'));}if(_0x22ddb8['type']==='html'){if('undefined'==typeof _0x22ddb8[_0x5b92('0x79')]['views']){return _0x5d1c85(new Error(_0x5b92('0x7a')));}if('undefined'==typeof _0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')]['admin']&&_0x5b92('0x75')==typeof _0x22ddb8['parameters'][_0x5b92('0x7b')][_0x5b92('0x7c')]){return _0x5d1c85(new Error(_0x5b92('0x7d')));}}else if(_0x22ddb8['type']==='script'){if(_0x5b92('0x75')==typeof _0x22ddb8['parameters'][_0x5b92('0x7e')]){return _0x5d1c85(new Error(_0x5b92('0x7f')));}if(_0x5b92('0x75')==typeof _0x22ddb8['parameters']['scriptPath']){return _0x5d1c85(new Error(_0x5b92('0x80')));}}else{return _0x5d1c85(new Error(_0x5b92('0x81')));}var _0x52d814=_0x22ddb8['name'];var _0x33b17a=_0x22ddb8['description'];var _0xbb8abf=_0x22ddb8[_0x5b92('0x32')];var _0x68472d=_0x22ddb8[_0x5b92('0x82')]?_0x22ddb8[_0x5b92('0x82')]:_0x5b92('0x83');var _0x2715ff=_0x22ddb8[_0x5b92('0x84')]?_0x22ddb8['icon']:'icon-apps';var _0x23fd4a='';var _0x19ae20='';var _0x47fba3='';var _0x370112='';var _0x538cee=_0x22ddb8[_0x5b92('0x78')];if(_0xbb8abf===_0x5b92('0x85')){if(_0x5b92('0x75')!=typeof _0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')][_0x5b92('0x86')]){var _0x44dd5c=_0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')][_0x5b92('0x86')];if(!/^(f|ht)tps?:\/\//i[_0x5b92('0x87')](_0x44dd5c)){_0x23fd4a=path[_0x5b92('0x5c')](_0x5b92('0x88'),_0x5d9330,_0x1bdddd[0x0],_0x44dd5c);}else{_0x23fd4a=_0x44dd5c;}}else{logger[_0x5b92('0x65')]('Warning:\x20admin\x20view\x20not\x20specified');}if(_0x5b92('0x75')!=typeof _0x22ddb8[_0x5b92('0x79')]['views'][_0x5b92('0x7c')]){var _0x3faa1c=_0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')][_0x5b92('0x7c')];if(!/^(f|ht)tps?:\/\//i[_0x5b92('0x87')](_0x3faa1c)){_0x19ae20=path['join']('plugins',_0x5d9330,_0x1bdddd[0x0],_0x3faa1c);}else{_0x19ae20=_0x3faa1c;}}else{logger[_0x5b92('0x65')](_0x5b92('0x89'));}}else if(_0xbb8abf===_0x5b92('0x8a')){_0x47fba3=_0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7e')];_0x370112=_0x22ddb8[_0x5b92('0x79')][_0x5b92('0x8b')];if(_0x5b92('0x75')!=typeof _0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')]){if('undefined'!=typeof _0x22ddb8[_0x5b92('0x79')]['views'][_0x5b92('0x86')]){var _0x44dd5c=_0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')][_0x5b92('0x86')];if(!/^(f|ht)tps?:\/\//i['test'](_0x44dd5c)){_0x23fd4a=path[_0x5b92('0x5c')](_0x5b92('0x88'),_0x5d9330,_0x1bdddd[0x0],_0x44dd5c);}else{_0x23fd4a=_0x44dd5c;}}if(_0x5b92('0x75')!=typeof _0x22ddb8[_0x5b92('0x79')][_0x5b92('0x7b')][_0x5b92('0x7c')]){var _0x3faa1c=_0x22ddb8[_0x5b92('0x79')]['views'][_0x5b92('0x7c')];if(!/^(f|ht)tps?:\/\//i[_0x5b92('0x87')](_0x3faa1c)){_0x19ae20=path[_0x5b92('0x5c')](_0x5b92('0x88'),_0x5d9330,_0x1bdddd[0x0],_0x3faa1c);}else{_0x19ae20=_0x3faa1c;}}}}var _0x4b5bdc={'name':_0x52d814,'description':_0x33b17a,'path':path[_0x5b92('0x5c')](_0x5d9330,_0x1bdddd[0x0]),'type':_0xbb8abf,'sidebar':_0x68472d,'icon':_0x2715ff,'adminUrl':_0x23fd4a,'agentUrl':_0x19ae20,'scriptName':_0x47fba3,'scriptPath':_0x370112,'version':_0x538cee};removeReferences(_0x198df0,null);return db['Plugin'][_0x5b92('0x8c')](_0x4b5bdc)[_0x5b92('0x27')](function(_0x2d4e81){var _0x293c3e={'role':_0x4111b5[_0x5b92('0x8d')][_0x5b92('0x8e')],'userProfileId':_0x4111b5['body'][_0x5b92('0x8f')]};if(!_0x293c3e)throw new Error(_0x5b92('0x90'));if(_0x293c3e[_0x5b92('0x8e')]===_0x5b92('0x91')){var _0x51eaa8=_0x2d4e81[_0x5b92('0x92')]({'plain':!![]});return db[_0x5b92('0x93')][_0x5b92('0x4d')]({'where':{'name':'Plugins','userProfileId':_0x293c3e[_0x5b92('0x8f')]},'raw':!![]})['then'](function(_0x4a2465){if(_0x4a2465&&_0x4a2465[_0x5b92('0x94')]===0x0){return db['UserProfileResource'][_0x5b92('0x8c')]({'name':_0x51eaa8['name'],'resourceId':_0x51eaa8['id'],'type':_0x4a2465[_0x5b92('0x2b')],'sectionId':_0x4a2465['id']},{})[_0x5b92('0x27')](function(){return _0x2d4e81;});}else{return _0x2d4e81;}})[_0x5b92('0x49')](function(_0x529af8){logger['error'](_0x5b92('0x95'),_0x529af8);throw _0x529af8;});}return _0x2d4e81;})['then'](respondWithResult(_0xacf4c3,null))['catch'](handleError(_0xacf4c3,null));}});}catch(_0x2bf0f8){_0xacf4c3['status'](0x1f4)[_0x5b92('0x2c')](_0x2bf0f8);}};function removeReferences(_0x3c5aa6,_0x546b92){try{if(_0x3c5aa6){fs['unlinkSync'](_0x3c5aa6);logger[_0x5b92('0x65')]('Zip\x20archive\x20removed');}if(_0x546b92){rimraf(_0x546b92,function(){});logger[_0x5b92('0x65')](_0x5b92('0x96'));}}catch(_0x40d8bb){logger[_0x5b92('0x59')](_0x40d8bb);}}exports['update']=function(_0x29e434,_0x1ccaa5,_0x450be1){return db[_0x5b92('0x2f')][_0x5b92('0x4d')]({'where':{'id':_0x29e434[_0x5b92('0x4b')]['id']}})[_0x5b92('0x27')](handleEntityNotFound(_0x1ccaa5,null))[_0x5b92('0x27')](saveUpdates(_0x29e434[_0x5b92('0x8d')],null))[_0x5b92('0x27')](respondWithResult(_0x1ccaa5,null))[_0x5b92('0x49')](handleError(_0x1ccaa5,null));};exports[_0x5b92('0x97')]=function(_0x44a30a,_0x325613,_0x3973fb){return db[_0x5b92('0x2f')]['find']({'where':{'id':_0x44a30a[_0x5b92('0x4b')]['id']}})[_0x5b92('0x27')](function(_0x309f9a){if(_0x309f9a){return _0x309f9a[_0x5b92('0x29')]();}})[_0x5b92('0x27')](function(_0x5c4bbb){rimraf(path[_0x5b92('0x5c')](config[_0x5b92('0x4f')],_0x5b92('0x5d'),path[_0x5b92('0x5e')](_0x5c4bbb[_0x5b92('0x6')])),function(){});return _0x5c4bbb;})[_0x5b92('0x27')](handleEntityNotFound(_0x325613,null))[_0x5b92('0x27')](respondWithStatusCode(_0x325613,null))[_0x5b92('0x49')](handleError(_0x325613,null));};exports[_0x5b92('0x98')]=function(_0x5b2c2d,_0x14161e,_0x3bd9da){return BPromise[_0x5b92('0x99')]()['then'](function(){if(!_0x5b2c2d['query'][_0x5b92('0x6')]){throw new Error(_0x5b92('0x9a'));}if(!_0x5b2c2d[_0x5b92('0x34')][_0x5b92('0x9b')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x57fca7=_0x5b2c2d['query'][_0x5b92('0x9c')]?_0x5b2c2d[_0x5b92('0x34')][_0x5b92('0x9c')]+':'+_0x5b2c2d[_0x5b92('0x34')]['port']:'http://localhost:'+_0x5b2c2d[_0x5b92('0x34')]['port'];var _0x190f7d=_0x5b2c2d[_0x5b92('0x34')][_0x5b92('0x20')]?_0x5b2c2d[_0x5b92('0x34')][_0x5b92('0x20')]:!![];var _0x3081d3=_0x5b2c2d[_0x5b92('0x34')]['encoding']?_0x5b2c2d['query'][_0x5b92('0x9d')]:null;var _0x25925d={'method':_0x5b2c2d['method'],'uri':util[_0x5b92('0x63')](_0x5b92('0x9e'),_0x57fca7,_0x5b2c2d[_0x5b92('0x34')][_0x5b92('0x6')]),'json':_0x190f7d,'resolveWithFullResponse':!![],'encoding':_0x3081d3,'qs':_0x5b2c2d[_0x5b92('0x34')]};if(_0x5b2c2d[_0x5b92('0x9f')]){_0x25925d[_0x5b92('0x9f')]=_0x5b2c2d[_0x5b92('0x9f')];if(_0x25925d[_0x5b92('0x9f')]['content-length']){delete _0x25925d[_0x5b92('0x9f')]['content-length'];}}if(_0x25925d[_0x5b92('0x9f')][_0x5b92('0xa0')]){delete _0x25925d[_0x5b92('0x9f')][_0x5b92('0xa0')];}return rp(_0x25925d);})[_0x5b92('0x27')](function(_0x2e569d){if(_0x2e569d){_0x14161e[_0x5b92('0x23')](_0x2e569d[_0x5b92('0x9f')]);logger['info'](_0x2e569d[_0x5b92('0x8d')]);if(_[_0x5b92('0xa1')](_0x5b2c2d[_0x5b92('0x34')][_0x5b92('0x6')],'download')&&_0x2e569d[_0x5b92('0xa2')]==0x1f4){return _0x14161e[_0x5b92('0x1d')](_0x2e569d[_0x5b92('0xa2')]);}else{return _0x14161e[_0x5b92('0x1e')](_0x2e569d[_0x5b92('0xa2')])[_0x5b92('0x2c')](_0x2e569d[_0x5b92('0x8d')]);}}else{return _0x14161e['sendStatus'](0xc8);}})['catch'](handleError(_0x14161e,null));};exports['webhookPost']=function(_0x42982a,_0x458ab0,_0x5edffe){return BPromise['resolve']()[_0x5b92('0x27')](function(){if(!_0x42982a[_0x5b92('0x34')][_0x5b92('0x6')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x42982a[_0x5b92('0x34')]['port']){throw new Error(_0x5b92('0xa3'));}var _0x2200da=_0x42982a[_0x5b92('0x34')][_0x5b92('0x9c')]?_0x42982a[_0x5b92('0x34')][_0x5b92('0x9c')]+':'+_0x42982a[_0x5b92('0x34')][_0x5b92('0x9b')]:_0x5b92('0xa4')+_0x42982a[_0x5b92('0x34')][_0x5b92('0x9b')];var _0x2b99c1=_0x42982a[_0x5b92('0x34')]['json']?_0x42982a[_0x5b92('0x34')][_0x5b92('0x20')]:!![];var _0x1b4b34=_0x42982a[_0x5b92('0x34')]['encoding']?_0x42982a[_0x5b92('0x34')]['encoding']:null;var _0x26e763={'method':_0x42982a[_0x5b92('0xa5')],'uri':util['format'](_0x5b92('0x9e'),_0x2200da,_0x42982a[_0x5b92('0x34')][_0x5b92('0x6')]),'json':_0x2b99c1,'resolveWithFullResponse':!![],'encoding':_0x1b4b34,'body':_0x42982a[_0x5b92('0x8d')]};if(_0x42982a[_0x5b92('0x9f')]){_0x26e763['headers']=_0x42982a['headers'];if(_0x26e763[_0x5b92('0x9f')][_0x5b92('0xa6')]){delete _0x26e763[_0x5b92('0x9f')][_0x5b92('0xa6')];}}if(_0x26e763['headers'][_0x5b92('0xa0')]){delete _0x26e763[_0x5b92('0x9f')][_0x5b92('0xa0')];}return rp(_0x26e763);})['then'](function(_0x22b0f4){if(_0x22b0f4){_0x458ab0['set'](_0x22b0f4[_0x5b92('0x9f')]);logger[_0x5b92('0x65')](_0x22b0f4[_0x5b92('0x8d')]);return _0x458ab0[_0x5b92('0x1e')](_0x22b0f4[_0x5b92('0xa2')])[_0x5b92('0x2c')](_0x22b0f4[_0x5b92('0x8d')]);}else{return _0x458ab0[_0x5b92('0x1d')](0xc8);}})[_0x5b92('0x49')](handleError(_0x458ab0,null));};
\ No newline at end of file