Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / plugin / plugin.controller.js
index 2c693ea..0561c49 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf5cc=['parameters','Invalid\x20manifest:\x20parameters\x20missing','html','views','admin','agent','script','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20invalid\x20type','sidebar','always','icon','icon-apps','test','plugins','Warning:\x20agent\x20view\x20not\x20specified','scriptName','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Zip\x20archive\x20removed','Extracted\x20folder\x20removed','webhookGet','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','port','encoding','method','headers','content-length','content-type','statusCode','%s%s','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','extract-zip','archiver','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./plugin.socket','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','then','destroy','get','Plugins','UserProfileResource','error','stack','name','send','index','Plugin','rawAttributes','query','keys','intersection','attributes','model','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','merge','map','key','options','findAll','show','includeAll','include','find','catch','download','params','path','join','root','%s.zip','createWriteStream','zip','warning','code','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','pipe','glob','server/files/plugins','dirname','basename','node_modules/**/*','finalize','close','existsSync','Sequelize','format','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','info','Temporary\x20file\x20removed','file','filename','extname','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','readdirSync','Invalid\x20plugin\x20structure','isFile','isDirectory','some','manifest.json','Plugin\x20manifest\x20missing','readFileSync','parse','undefined','Invalid\x20manifest:\x20name\x20missing','type','version','Invalid\x20manifest:\x20version\x20not\x20specified'];(function(_0x351511,_0x14043c){var _0x2df741=function(_0x6300bf){while(--_0x6300bf){_0x351511['push'](_0x351511['shift']());}};_0x2df741(++_0x14043c);}(_0xf5cc,0x179));var _0xcf5c=function(_0x1d2bbb,_0x202267){_0x1d2bbb=_0x1d2bbb-0x0;var _0x38082b=_0xf5cc[_0x1d2bbb];return _0x38082b;};'use strict';var pdf=require(_0xcf5c('0x0'));var emlformat=require(_0xcf5c('0x1'));var rimraf=require(_0xcf5c('0x2'));var zipdir=require(_0xcf5c('0x3'));var jsonpatch=require(_0xcf5c('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xcf5c('0x5'));var Mustache=require(_0xcf5c('0x6'));var util=require(_0xcf5c('0x7'));var path=require('path');var sox=require(_0xcf5c('0x8'));var csv=require(_0xcf5c('0x9'));var ejs=require(_0xcf5c('0xa'));var fs=require('fs');var _=require(_0xcf5c('0xb'));var squel=require(_0xcf5c('0xc'));var crypto=require('crypto');var jsforce=require(_0xcf5c('0xd'));var deskjs=require(_0xcf5c('0xe'));var toCsv=require(_0xcf5c('0x9'));var querystring=require(_0xcf5c('0xf'));var Papa=require(_0xcf5c('0x10'));var extract=require(_0xcf5c('0x11'));var rimraf=require(_0xcf5c('0x2'));var archiver=require(_0xcf5c('0x12'));var Redis=require(_0xcf5c('0x13'));var authService=require(_0xcf5c('0x14'));var qs=require(_0xcf5c('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xcf5c('0x16'))(_0xcf5c('0x17'));var utils=require(_0xcf5c('0x18'));var config=require(_0xcf5c('0x19'));var db=require(_0xcf5c('0x1a'))['db'];config['redis']=_[_0xcf5c('0x1b')](config['redis'],{'host':_0xcf5c('0x1c'),'port':0x18eb});var socket=require(_0xcf5c('0x1d'))(new Redis(config[_0xcf5c('0x1e')]));require(_0xcf5c('0x1f'))['register'](socket);function respondWithStatusCode(_0x42409a,_0x5dd07f){_0x5dd07f=_0x5dd07f||0xcc;return function(_0x2af593){if(_0x2af593){return _0x42409a[_0xcf5c('0x20')](_0x5dd07f);}return _0x42409a[_0xcf5c('0x21')](_0x5dd07f)[_0xcf5c('0x22')]();};}function respondWithResult(_0x2308fd,_0x4775e8){_0x4775e8=_0x4775e8||0xc8;return function(_0x39be6e){if(_0x39be6e){return _0x2308fd[_0xcf5c('0x21')](_0x4775e8)[_0xcf5c('0x23')](_0x39be6e);}};}function respondWithFilteredResult(_0x594c2d,_0x1ff343){return function(_0x2668f3){if(_0x2668f3){var _0x3e6917=_0x2668f3[_0xcf5c('0x24')],_0x1b31f8=_0x1ff343[_0xcf5c('0x25')],_0x5a40e9=_0x1ff343['offset']+_0x1ff343[_0xcf5c('0x26')],_0x59a30a;if(_0x5a40e9>=_0x3e6917){_0x5a40e9=_0x3e6917;_0x59a30a=0xc8;}else{_0x59a30a=0xce;}_0x594c2d['status'](_0x59a30a);return _0x594c2d[_0xcf5c('0x27')](_0xcf5c('0x28'),_0x1b31f8+'-'+_0x5a40e9+'/'+_0x3e6917)[_0xcf5c('0x23')](_0x2668f3);}return null;};}function patchUpdates(_0x24fc4a){return function(_0x485a16){try{jsonpatch[_0xcf5c('0x29')](_0x485a16,_0x24fc4a,!![]);}catch(_0x4192e7){return BPromise[_0xcf5c('0x2a')](_0x4192e7);}return _0x485a16['save']();};}function saveUpdates(_0xf00bdd,_0x954bbe){return function(_0x10bb05){if(_0x10bb05){return _0x10bb05[_0xcf5c('0x2b')](_0xf00bdd)[_0xcf5c('0x2c')](function(_0x3b4d24){return _0x3b4d24;});}return null;};}function removeEntity(_0x2fa5fa,_0x2dabdb){return function(_0x20d830){if(_0x20d830){return _0x20d830[_0xcf5c('0x2d')]()[_0xcf5c('0x2c')](function(){var _0x4f08b8=_0x20d830[_0xcf5c('0x2e')]({'plain':!![]});var _0x1abe29=_0xcf5c('0x2f');return db[_0xcf5c('0x30')][_0xcf5c('0x2d')]({'where':{'type':_0x1abe29,'resourceId':_0x4f08b8['id']}})[_0xcf5c('0x2c')](function(){return _0x20d830;});})[_0xcf5c('0x2c')](function(){_0x2fa5fa[_0xcf5c('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x549602,_0x293bff){return function(_0x4e1e8b){if(!_0x4e1e8b){_0x549602[_0xcf5c('0x20')](0x194);}return _0x4e1e8b;};}function handleError(_0x5d5cb8,_0x1a3cc1){_0x1a3cc1=_0x1a3cc1||0x1f4;return function(_0x4a62e9){logger[_0xcf5c('0x31')](_0x4a62e9[_0xcf5c('0x32')]);if(_0x4a62e9[_0xcf5c('0x33')]){delete _0x4a62e9[_0xcf5c('0x33')];}_0x5d5cb8[_0xcf5c('0x21')](_0x1a3cc1)[_0xcf5c('0x34')](_0x4a62e9);};}exports[_0xcf5c('0x35')]=function(_0x4d3f32,_0x2d1ab4){var _0x1a797d={},_0x12c4e4={},_0x1dc182={'count':0x0,'rows':[]};var _0x5c1616=db[_0xcf5c('0x36')][_0xcf5c('0x37')];_0x12c4e4['model']=_['keys'](_0x5c1616);_0x12c4e4[_0xcf5c('0x38')]=_[_0xcf5c('0x39')](_0x4d3f32[_0xcf5c('0x38')]);_0x12c4e4['filters']=_[_0xcf5c('0x3a')](_0x12c4e4['model'],_0x12c4e4[_0xcf5c('0x38')]);_0x1a797d[_0xcf5c('0x3b')]=_[_0xcf5c('0x3a')](_0x12c4e4[_0xcf5c('0x3c')],qs[_0xcf5c('0x3d')](_0x4d3f32[_0xcf5c('0x38')][_0xcf5c('0x3d')]));_0x1a797d[_0xcf5c('0x3b')]=_0x1a797d[_0xcf5c('0x3b')][_0xcf5c('0x3e')]?_0x1a797d[_0xcf5c('0x3b')]:_0x12c4e4[_0xcf5c('0x3c')];if(!_0x4d3f32[_0xcf5c('0x38')][_0xcf5c('0x3f')]('nolimit')){_0x1a797d[_0xcf5c('0x26')]=qs[_0xcf5c('0x26')](_0x4d3f32['query']['limit']);_0x1a797d[_0xcf5c('0x25')]=qs[_0xcf5c('0x25')](_0x4d3f32[_0xcf5c('0x38')][_0xcf5c('0x25')]);}_0x1a797d[_0xcf5c('0x40')]=qs[_0xcf5c('0x41')](_0x4d3f32[_0xcf5c('0x38')][_0xcf5c('0x41')]);_0x1a797d[_0xcf5c('0x42')]=qs[_0xcf5c('0x43')](_[_0xcf5c('0x44')](_0x4d3f32[_0xcf5c('0x38')],_0x12c4e4[_0xcf5c('0x43')]));if(_0x4d3f32[_0xcf5c('0x38')][_0xcf5c('0x45')]){_0x1a797d[_0xcf5c('0x42')]=_[_0xcf5c('0x46')](_0x1a797d[_0xcf5c('0x42')],{'$or':_[_0xcf5c('0x47')](_0x5c1616,function(_0xc7df00){if(_0xc7df00['type'][_0xcf5c('0x48')]!=='VIRTUAL'){var _0x1420f8={};_0x1420f8[_0xc7df00['field']]={'$like':'%'+_0x4d3f32[_0xcf5c('0x38')][_0xcf5c('0x45')]+'%'};return _0x1420f8;}})});}_0x1a797d=_['merge']({},_0x1a797d,_0x4d3f32[_0xcf5c('0x49')]);var _0x38e760={'where':_0x1a797d[_0xcf5c('0x42')]};return db[_0xcf5c('0x36')][_0xcf5c('0x24')](_0x38e760)['then'](function(_0x3c24a3){_0x1dc182[_0xcf5c('0x24')]=_0x3c24a3;if(_0x4d3f32[_0xcf5c('0x38')]['includeAll']){_0x1a797d['include']=[{'all':!![]}];}return db[_0xcf5c('0x36')][_0xcf5c('0x4a')](_0x1a797d);})[_0xcf5c('0x2c')](function(_0x3e75c7){_0x1dc182['rows']=_0x3e75c7;return _0x1dc182;})[_0xcf5c('0x2c')](respondWithFilteredResult(_0x2d1ab4,_0x1a797d))['catch'](handleError(_0x2d1ab4,null));};exports[_0xcf5c('0x4b')]=function(_0x2dc995,_0x1904fc){var _0x551ee8={'raw':!![],'where':{'id':_0x2dc995['params']['id']}},_0x3af3d3={};_0x3af3d3[_0xcf5c('0x3c')]=_[_0xcf5c('0x39')](db[_0xcf5c('0x36')][_0xcf5c('0x37')]);_0x3af3d3[_0xcf5c('0x38')]=_[_0xcf5c('0x39')](_0x2dc995['query']);_0x3af3d3[_0xcf5c('0x43')]=_[_0xcf5c('0x3a')](_0x3af3d3[_0xcf5c('0x3c')],_0x3af3d3[_0xcf5c('0x38')]);_0x551ee8[_0xcf5c('0x3b')]=_['intersection'](_0x3af3d3['model'],qs['fields'](_0x2dc995[_0xcf5c('0x38')][_0xcf5c('0x3d')]));_0x551ee8[_0xcf5c('0x3b')]=_0x551ee8[_0xcf5c('0x3b')][_0xcf5c('0x3e')]?_0x551ee8[_0xcf5c('0x3b')]:_0x3af3d3[_0xcf5c('0x3c')];if(_0x2dc995[_0xcf5c('0x38')][_0xcf5c('0x4c')]){_0x551ee8[_0xcf5c('0x4d')]=[{'all':!![]}];}_0x551ee8=_[_0xcf5c('0x46')]({},_0x551ee8,_0x2dc995[_0xcf5c('0x49')]);return db[_0xcf5c('0x36')][_0xcf5c('0x4e')](_0x551ee8)['then'](handleEntityNotFound(_0x1904fc,null))[_0xcf5c('0x2c')](respondWithResult(_0x1904fc,null))[_0xcf5c('0x4f')](handleError(_0x1904fc,null));};exports[_0xcf5c('0x50')]=function(_0x52af87,_0x5424f9,_0x55cada){return db[_0xcf5c('0x36')][_0xcf5c('0x4e')]({'where':{'id':_0x52af87[_0xcf5c('0x51')]['id']},'attributes':[_0xcf5c('0x33'),_0xcf5c('0x52')],'raw':!![]})['then'](handleEntityNotFound(_0x5424f9,null))[_0xcf5c('0x2c')](function(_0x3b9cf3){if(_0x3b9cf3){var _0x549de9=path[_0xcf5c('0x53')](config[_0xcf5c('0x54')],'server/files/plugins',util['format'](_0xcf5c('0x55'),path['basename'](_0x3b9cf3['path'])));var _0x29504c=fs[_0xcf5c('0x56')](_0x549de9);var _0x9706f4=archiver(_0xcf5c('0x57'),{'zlib':{'level':0x9}});_0x9706f4['on'](_0xcf5c('0x58'),function(_0x2e53de){if(_0x2e53de[_0xcf5c('0x59')]==='ENOENT'){logger[_0xcf5c('0x31')](_0x2e53de);}else{throw new db['Sequelize'][(_0xcf5c('0x5a'))](_0xcf5c('0x5b'));}});_0x9706f4['on'](_0xcf5c('0x31'),function(_0x3bb91f){throw new db['Sequelize'][(_0xcf5c('0x5a'))](_0xcf5c('0x5b'));});_0x9706f4[_0xcf5c('0x5c')](_0x29504c);_0x9706f4[_0xcf5c('0x5d')]('**/*',{'cwd':path[_0xcf5c('0x53')](config[_0xcf5c('0x54')],_0xcf5c('0x5e'),path[_0xcf5c('0x5f')](_0x3b9cf3['path'])),'ignore':[path[_0xcf5c('0x53')](path[_0xcf5c('0x60')](_0x3b9cf3[_0xcf5c('0x52')]),_0xcf5c('0x61')),path[_0xcf5c('0x53')](path[_0xcf5c('0x60')](_0x3b9cf3[_0xcf5c('0x52')]),'attachments/**/*')],'nodir':!![]})[_0xcf5c('0x62')]();_0x29504c['on'](_0xcf5c('0x63'),function(){if(!fs[_0xcf5c('0x64')](_0x549de9)){throw new db[(_0xcf5c('0x65'))][(_0xcf5c('0x5a'))]('Plugin\x20not\x20found');}return _0x5424f9[_0xcf5c('0x50')](_0x549de9,util[_0xcf5c('0x66')]('%s.zip',path['basename'](_0x3b9cf3['path'])),function(_0x7090e8){if(_0x7090e8){throw new db[(_0xcf5c('0x65'))]['Error'](_0xcf5c('0x67'));}fs[_0xcf5c('0x68')](_0x549de9);logger[_0xcf5c('0x69')]('Download\x20completed');logger['info'](_0xcf5c('0x6a'));});});}return null;})['catch'](handleError(_0x5424f9,null));};exports['upload']=function(_0x3aec28,_0x4f0672,_0xc89b5f){var _0x3fdd9a=path[_0xcf5c('0x60')](_0x3aec28[_0xcf5c('0x6b')][_0xcf5c('0x6c')],path[_0xcf5c('0x6d')](_0x3aec28[_0xcf5c('0x6b')][_0xcf5c('0x6c')]));var _0x3160c7=path[_0xcf5c('0x53')](config['root'],_0xcf5c('0x5e'),_0x3aec28[_0xcf5c('0x6b')][_0xcf5c('0x6c')]);var _0x26a7f9=path['join'](config[_0xcf5c('0x54')],_0xcf5c('0x5e'),_0x3fdd9a);logger['info'](_0xcf5c('0x6e'),_0x3160c7);logger['info'](_0xcf5c('0x6f'),_0x26a7f9);try{fs[_0xcf5c('0x70')](_0x3160c7,parseInt('0777',0x8));extract(_0x3160c7,{'dir':_0x26a7f9},function(_0x113303){if(_0x113303){logger[_0xcf5c('0x31')](_0x113303);handleError(_0x113303,!![]);};var _0x24fe59=fs[_0xcf5c('0x71')](_0x26a7f9);if(_0x24fe59[_0xcf5c('0x3e')]>0x1){removeReferences(_0x3160c7,_0x26a7f9);logger[_0xcf5c('0x31')](_0xcf5c('0x72'));return _0xc89b5f(new Error(_0xcf5c('0x72')));}var _0x49f116=fs['lstatSync'](path['join'](_0x26a7f9,_0x24fe59[0x0]));if(_0x49f116[_0xcf5c('0x73')]()){removeReferences(_0x3160c7,_0x26a7f9);logger[_0xcf5c('0x31')]('Invalid\x20plugin\x20structure');return _0xc89b5f(new Error('Invalid\x20plugin\x20structure'));}if(_0x49f116[_0xcf5c('0x74')]()){var _0x839293=fs[_0xcf5c('0x71')](path[_0xcf5c('0x53')](_0x26a7f9,_0x24fe59[0x0]));if(_0x839293['length']===0x0){removeReferences(_0x3160c7,_0x26a7f9);logger[_0xcf5c('0x31')](_0xcf5c('0x72'));return _0xc89b5f(new Error(_0xcf5c('0x72')));}var _0x56a489=_0x839293[_0xcf5c('0x75')](function(_0x23ad00){return _0x23ad00===_0xcf5c('0x76');});if(!_0x56a489){return _0xc89b5f(new Error(_0xcf5c('0x77')));}var _0x276890=fs[_0xcf5c('0x78')](path[_0xcf5c('0x53')](_0x26a7f9,_0x24fe59[0x0],'manifest.json'));var _0x4f9c64=JSON[_0xcf5c('0x79')](_0x276890);if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x33')]){return _0xc89b5f(new Error(_0xcf5c('0x7b')));}if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7c')]){return _0xc89b5f(new Error('Invalid\x20manifest:\x20type\x20missing'));}if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7d')]){return _0xc89b5f(new Error(_0xcf5c('0x7e')));}if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7f')]){return _0xc89b5f(new Error(_0xcf5c('0x80')));}if(_0x4f9c64['type']===_0xcf5c('0x81')){if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')]){return _0xc89b5f(new Error('Invalid\x20manifest:\x20views\x20missing'));}if(_0xcf5c('0x7a')==typeof _0x4f9c64['parameters'][_0xcf5c('0x82')][_0xcf5c('0x83')]&&_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')][_0xcf5c('0x84')]){return _0xc89b5f(new Error('Invalid\x20manifest:\x20no\x20view\x20specified'));}}else if(_0x4f9c64[_0xcf5c('0x7c')]===_0xcf5c('0x85')){if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7f')]['scriptName']){return _0xc89b5f(new Error(_0xcf5c('0x86')));}if(_0xcf5c('0x7a')==typeof _0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x87')]){return _0xc89b5f(new Error('Invalid\x20manifest:\x20script\x20path\x20missing'));}}else{return _0xc89b5f(new Error(_0xcf5c('0x88')));}var _0x4dc011=_0x4f9c64[_0xcf5c('0x33')];var _0x10d5a7=_0x4f9c64['description'];var _0x3fd460=_0x4f9c64['type'];var _0x399bb0=_0x4f9c64[_0xcf5c('0x89')]?_0x4f9c64['sidebar']:_0xcf5c('0x8a');var _0x3c0a6b=_0x4f9c64[_0xcf5c('0x8b')]?_0x4f9c64['icon']:_0xcf5c('0x8c');var _0x41dfb9='';var _0x4bf044='';var _0x4071a7='';var _0x11656e='';var _0x31b1ff=_0x4f9c64[_0xcf5c('0x7d')];if(_0x3fd460===_0xcf5c('0x81')){if(_0xcf5c('0x7a')!=typeof _0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')]['admin']){var _0x211d1a=_0x4f9c64[_0xcf5c('0x7f')]['views'][_0xcf5c('0x83')];if(!/^(f|ht)tps?:\/\//i[_0xcf5c('0x8d')](_0x211d1a)){_0x41dfb9=path[_0xcf5c('0x53')](_0xcf5c('0x8e'),_0x3fdd9a,_0x24fe59[0x0],_0x211d1a);}else{_0x41dfb9=_0x211d1a;}}else{logger[_0xcf5c('0x69')]('Warning:\x20admin\x20view\x20not\x20specified');}if(_0xcf5c('0x7a')!=typeof _0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')][_0xcf5c('0x84')]){var _0x542c9f=_0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')][_0xcf5c('0x84')];if(!/^(f|ht)tps?:\/\//i[_0xcf5c('0x8d')](_0x542c9f)){_0x4bf044=path[_0xcf5c('0x53')]('plugins',_0x3fdd9a,_0x24fe59[0x0],_0x542c9f);}else{_0x4bf044=_0x542c9f;}}else{logger[_0xcf5c('0x69')](_0xcf5c('0x8f'));}}else if(_0x3fd460==='script'){_0x4071a7=_0x4f9c64['parameters'][_0xcf5c('0x90')];_0x11656e=_0x4f9c64['parameters']['scriptPath'];if(_0xcf5c('0x7a')!=typeof _0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')]){if(_0xcf5c('0x7a')!=typeof _0x4f9c64[_0xcf5c('0x7f')]['views'][_0xcf5c('0x83')]){var _0x211d1a=_0x4f9c64['parameters'][_0xcf5c('0x82')][_0xcf5c('0x83')];if(!/^(f|ht)tps?:\/\//i['test'](_0x211d1a)){_0x41dfb9=path['join'](_0xcf5c('0x8e'),_0x3fdd9a,_0x24fe59[0x0],_0x211d1a);}else{_0x41dfb9=_0x211d1a;}}if(_0xcf5c('0x7a')!=typeof _0x4f9c64['parameters'][_0xcf5c('0x82')]['agent']){var _0x542c9f=_0x4f9c64[_0xcf5c('0x7f')][_0xcf5c('0x82')]['agent'];if(!/^(f|ht)tps?:\/\//i['test'](_0x542c9f)){_0x4bf044=path['join'](_0xcf5c('0x8e'),_0x3fdd9a,_0x24fe59[0x0],_0x542c9f);}else{_0x4bf044=_0x542c9f;}}}}var _0x266545={'name':_0x4dc011,'description':_0x10d5a7,'path':path[_0xcf5c('0x53')](_0x3fdd9a,_0x24fe59[0x0]),'type':_0x3fd460,'sidebar':_0x399bb0,'icon':_0x3c0a6b,'adminUrl':_0x41dfb9,'agentUrl':_0x4bf044,'scriptName':_0x4071a7,'scriptPath':_0x11656e,'version':_0x31b1ff};removeReferences(_0x3160c7,null);return db['Plugin'][_0xcf5c('0x91')](_0x266545)[_0xcf5c('0x2c')](function(_0x1fa73a){var _0x482443={'role':_0x3aec28[_0xcf5c('0x92')][_0xcf5c('0x93')],'userProfileId':_0x3aec28[_0xcf5c('0x92')][_0xcf5c('0x94')]};if(!_0x482443)throw new Error(_0xcf5c('0x95'));if(_0x482443[_0xcf5c('0x93')]===_0xcf5c('0x96')){var _0x4f2e34=_0x1fa73a[_0xcf5c('0x2e')]({'plain':!![]});return db[_0xcf5c('0x97')]['find']({'where':{'name':_0xcf5c('0x2f'),'userProfileId':_0x482443[_0xcf5c('0x94')]},'raw':!![]})[_0xcf5c('0x2c')](function(_0x3cf60c){if(_0x3cf60c&&_0x3cf60c['autoAssociation']===0x0){return db[_0xcf5c('0x30')]['create']({'name':_0x4f2e34[_0xcf5c('0x33')],'resourceId':_0x4f2e34['id'],'type':_0x3cf60c[_0xcf5c('0x33')],'sectionId':_0x3cf60c['id']},{})[_0xcf5c('0x2c')](function(){return _0x1fa73a;});}else{return _0x1fa73a;}})[_0xcf5c('0x4f')](function(_0x50f236){logger[_0xcf5c('0x31')](_0xcf5c('0x98'),_0x50f236);throw _0x50f236;});}return _0x1fa73a;})['then'](respondWithResult(_0x4f0672,null))[_0xcf5c('0x4f')](handleError(_0x4f0672,null));}});}catch(_0x45248e){_0x4f0672[_0xcf5c('0x21')](0x1f4)['send'](_0x45248e);}};function removeReferences(_0x34e08b,_0x2cbe89){try{if(_0x34e08b){fs[_0xcf5c('0x68')](_0x34e08b);logger['info'](_0xcf5c('0x99'));}if(_0x2cbe89){rimraf(_0x2cbe89,function(){});logger[_0xcf5c('0x69')](_0xcf5c('0x9a'));}}catch(_0x53da44){logger['error'](_0x53da44);}}exports['update']=function(_0x340926,_0x38a589,_0x20da99){return db[_0xcf5c('0x36')][_0xcf5c('0x4e')]({'where':{'id':_0x340926[_0xcf5c('0x51')]['id']}})[_0xcf5c('0x2c')](handleEntityNotFound(_0x38a589,null))[_0xcf5c('0x2c')](saveUpdates(_0x340926[_0xcf5c('0x92')],null))[_0xcf5c('0x2c')](respondWithResult(_0x38a589,null))['catch'](handleError(_0x38a589,null));};exports['delete']=function(_0x187bf9,_0x174f73,_0x2eaf7b){return db['Plugin'][_0xcf5c('0x4e')]({'where':{'id':_0x187bf9[_0xcf5c('0x51')]['id']}})['then'](function(_0x4cf505){if(_0x4cf505){return _0x4cf505[_0xcf5c('0x2d')]();}})[_0xcf5c('0x2c')](function(_0x559c6f){rimraf(path['join'](config['root'],_0xcf5c('0x5e'),path[_0xcf5c('0x5f')](_0x559c6f[_0xcf5c('0x52')])),function(){});return _0x559c6f;})[_0xcf5c('0x2c')](handleEntityNotFound(_0x174f73,null))[_0xcf5c('0x2c')](respondWithStatusCode(_0x174f73,null))[_0xcf5c('0x4f')](handleError(_0x174f73,null));};exports[_0xcf5c('0x9b')]=function(_0x49fd8a,_0x5a8bae,_0x3920d5){return BPromise[_0xcf5c('0x9c')]()[_0xcf5c('0x2c')](function(){if(!_0x49fd8a['query'][_0xcf5c('0x52')]){throw new Error(_0xcf5c('0x9d'));}if(!_0x49fd8a[_0xcf5c('0x38')]['port']){throw new Error(_0xcf5c('0x9e'));}var _0xcc4f0b=_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0x9f')]?_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0x9f')]+':'+_0x49fd8a[_0xcf5c('0x38')]['port']:'http://localhost:'+_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0xa0')];var _0x3a9770=_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0x23')]?_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0x23')]:!![];var _0x2d2437=_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0xa1')]?_0x49fd8a['query'][_0xcf5c('0xa1')]:null;var _0x5d88fe={'method':_0x49fd8a[_0xcf5c('0xa2')],'uri':util[_0xcf5c('0x66')]('%s%s',_0xcc4f0b,_0x49fd8a['query'][_0xcf5c('0x52')]),'json':_0x3a9770,'resolveWithFullResponse':!![],'encoding':_0x2d2437,'qs':_0x49fd8a['query']};if(_0x49fd8a[_0xcf5c('0xa3')]){_0x5d88fe[_0xcf5c('0xa3')]=_0x49fd8a[_0xcf5c('0xa3')];if(_0x5d88fe[_0xcf5c('0xa3')][_0xcf5c('0xa4')]){delete _0x5d88fe[_0xcf5c('0xa3')]['content-length'];}}if(_0x5d88fe[_0xcf5c('0xa3')]['content-type']){delete _0x5d88fe[_0xcf5c('0xa3')][_0xcf5c('0xa5')];}return rp(_0x5d88fe);})[_0xcf5c('0x2c')](function(_0x503dc1){if(_0x503dc1){_0x5a8bae[_0xcf5c('0x27')](_0x503dc1[_0xcf5c('0xa3')]);logger[_0xcf5c('0x69')](_0x503dc1[_0xcf5c('0x92')]);if(_['endsWith'](_0x49fd8a[_0xcf5c('0x38')][_0xcf5c('0x52')],_0xcf5c('0x50'))&&_0x503dc1[_0xcf5c('0xa6')]==0x1f4){return _0x5a8bae[_0xcf5c('0x20')](_0x503dc1[_0xcf5c('0xa6')]);}else{return _0x5a8bae[_0xcf5c('0x21')](_0x503dc1[_0xcf5c('0xa6')])[_0xcf5c('0x34')](_0x503dc1[_0xcf5c('0x92')]);}}else{return _0x5a8bae['sendStatus'](0xc8);}})['catch'](handleError(_0x5a8bae,null));};exports['webhookPost']=function(_0x2801e9,_0x568da4,_0x231996){return BPromise[_0xcf5c('0x9c')]()[_0xcf5c('0x2c')](function(){if(!_0x2801e9['query'][_0xcf5c('0x52')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0xa0')]){throw new Error(_0xcf5c('0x9e'));}var _0x9d591=_0x2801e9[_0xcf5c('0x38')]['hostname']?_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0x9f')]+':'+_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0xa0')]:'http://localhost:'+_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0xa0')];var _0x11502a=_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0x23')]?_0x2801e9['query']['json']:!![];var _0x347a74=_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0xa1')]?_0x2801e9[_0xcf5c('0x38')][_0xcf5c('0xa1')]:null;var _0x3b350d={'method':_0x2801e9['method'],'uri':util[_0xcf5c('0x66')](_0xcf5c('0xa7'),_0x9d591,_0x2801e9['query'][_0xcf5c('0x52')]),'json':_0x11502a,'resolveWithFullResponse':!![],'encoding':_0x347a74,'body':_0x2801e9['body']};if(_0x2801e9[_0xcf5c('0xa3')]){_0x3b350d[_0xcf5c('0xa3')]=_0x2801e9[_0xcf5c('0xa3')];if(_0x3b350d[_0xcf5c('0xa3')][_0xcf5c('0xa4')]){delete _0x3b350d[_0xcf5c('0xa3')][_0xcf5c('0xa4')];}}if(_0x3b350d[_0xcf5c('0xa3')][_0xcf5c('0xa5')]){delete _0x3b350d[_0xcf5c('0xa3')]['content-type'];}return rp(_0x3b350d);})['then'](function(_0x4c8ca7){if(_0x4c8ca7){_0x568da4['set'](_0x4c8ca7['headers']);logger[_0xcf5c('0x69')](_0x4c8ca7[_0xcf5c('0x92')]);return _0x568da4[_0xcf5c('0x21')](_0x4c8ca7['statusCode'])[_0xcf5c('0x34')](_0x4c8ca7[_0xcf5c('0x92')]);}else{return _0x568da4[_0xcf5c('0x20')](0xc8);}})['catch'](handleError(_0x568da4,null));};
\ No newline at end of file
+var _0xda3c=['type','VIRTUAL','field','options','includeAll','findAll','rows','catch','params','find','download','root','server/files/plugins','format','%s.zip','basename','createWriteStream','zip','warning','code','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','pipe','glob','**/*','join','dirname','node_modules/**/*','attachments/**/*','finalize','close','existsSync','Plugin\x20not\x20found','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','info','Download\x20completed','Temporary\x20file\x20removed','upload','file','filename','extname','Plugin\x20upload\x20destination:\x20%s','0777','readdirSync','isFile','Invalid\x20plugin\x20structure','isDirectory','manifest.json','Plugin\x20manifest\x20missing','readFileSync','parse','undefined','Invalid\x20manifest:\x20type\x20missing','parameters','Invalid\x20manifest:\x20parameters\x20missing','html','views','Invalid\x20manifest:\x20views\x20missing','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','version','test','Warning:\x20admin\x20view\x20not\x20specified','plugins','Warning:\x20agent\x20view\x20not\x20specified','scriptName','create','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','Zip\x20archive\x20removed','Extracted\x20folder\x20removed','delete','webhookGet','resolve','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','http://localhost:','encoding','method','%s%s','headers','content-length','content-type','statusCode','body','webhookPost','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','extract-zip','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','sendStatus','status','end','json','count','offset','limit','set','reject','save','update','then','destroy','get','Plugins','error','stack','name','send','index','Plugin','rawAttributes','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge'];(function(_0x4f26a3,_0x5c162b){var _0x55222c=function(_0x5916e3){while(--_0x5916e3){_0x4f26a3['push'](_0x4f26a3['shift']());}};_0x55222c(++_0x5c162b);}(_0xda3c,0x1b9));var _0xcda3=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xda3c[_0x321bb2];return _0x9c12ed;};'use strict';var pdf=require(_0xcda3('0x0'));var emlformat=require(_0xcda3('0x1'));var rimraf=require(_0xcda3('0x2'));var zipdir=require(_0xcda3('0x3'));var jsonpatch=require(_0xcda3('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xcda3('0x5'));var Mustache=require(_0xcda3('0x6'));var util=require(_0xcda3('0x7'));var path=require(_0xcda3('0x8'));var sox=require(_0xcda3('0x9'));var csv=require(_0xcda3('0xa'));var ejs=require(_0xcda3('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0xcda3('0xc'));var crypto=require(_0xcda3('0xd'));var jsforce=require(_0xcda3('0xe'));var deskjs=require(_0xcda3('0xf'));var toCsv=require(_0xcda3('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var extract=require(_0xcda3('0x10'));var rimraf=require(_0xcda3('0x2'));var archiver=require('archiver');var Redis=require(_0xcda3('0x11'));var authService=require(_0xcda3('0x12'));var qs=require(_0xcda3('0x13'));var hardwareService=require(_0xcda3('0x14'));var logger=require(_0xcda3('0x15'))('api');var utils=require('../../config/utils');var config=require(_0xcda3('0x16'));var db=require('../../mysqldb')['db'];config[_0xcda3('0x17')]=_[_0xcda3('0x18')](config[_0xcda3('0x17')],{'host':_0xcda3('0x19'),'port':0x18eb});var socket=require(_0xcda3('0x1a'))(new Redis(config[_0xcda3('0x17')]));require(_0xcda3('0x1b'))[_0xcda3('0x1c')](socket);function respondWithStatusCode(_0x45d469,_0x57829e){_0x57829e=_0x57829e||0xcc;return function(_0x19bde5){if(_0x19bde5){return _0x45d469[_0xcda3('0x1d')](_0x57829e);}return _0x45d469[_0xcda3('0x1e')](_0x57829e)[_0xcda3('0x1f')]();};}function respondWithResult(_0x235c66,_0x82feef){_0x82feef=_0x82feef||0xc8;return function(_0x1e6ec4){if(_0x1e6ec4){return _0x235c66[_0xcda3('0x1e')](_0x82feef)[_0xcda3('0x20')](_0x1e6ec4);}};}function respondWithFilteredResult(_0x1e4662,_0x35b88f){return function(_0x4ca285){if(_0x4ca285){var _0x6687dd=_0x4ca285[_0xcda3('0x21')],_0xf4a2e5=_0x35b88f[_0xcda3('0x22')],_0x38c56f=_0x35b88f[_0xcda3('0x22')]+_0x35b88f[_0xcda3('0x23')],_0x123080;if(_0x38c56f>=_0x6687dd){_0x38c56f=_0x6687dd;_0x123080=0xc8;}else{_0x123080=0xce;}_0x1e4662[_0xcda3('0x1e')](_0x123080);return _0x1e4662[_0xcda3('0x24')]('Content-Range',_0xf4a2e5+'-'+_0x38c56f+'/'+_0x6687dd)[_0xcda3('0x20')](_0x4ca285);}return null;};}function patchUpdates(_0x1f6539){return function(_0x38b546){try{jsonpatch['apply'](_0x38b546,_0x1f6539,!![]);}catch(_0x2a012c){return BPromise[_0xcda3('0x25')](_0x2a012c);}return _0x38b546[_0xcda3('0x26')]();};}function saveUpdates(_0x1affd6,_0x52ed43){return function(_0x1a629d){if(_0x1a629d){return _0x1a629d[_0xcda3('0x27')](_0x1affd6)[_0xcda3('0x28')](function(_0x50e6cc){return _0x50e6cc;});}return null;};}function removeEntity(_0x17a87a,_0x2fd59c){return function(_0x815e41){if(_0x815e41){return _0x815e41[_0xcda3('0x29')]()[_0xcda3('0x28')](function(){var _0x1d0d10=_0x815e41[_0xcda3('0x2a')]({'plain':!![]});var _0x15dad7=_0xcda3('0x2b');return db['UserProfileResource'][_0xcda3('0x29')]({'where':{'type':_0x15dad7,'resourceId':_0x1d0d10['id']}})[_0xcda3('0x28')](function(){return _0x815e41;});})['then'](function(){_0x17a87a['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x192d31,_0x307776){return function(_0xc93895){if(!_0xc93895){_0x192d31[_0xcda3('0x1d')](0x194);}return _0xc93895;};}function handleError(_0x375377,_0x48084b){_0x48084b=_0x48084b||0x1f4;return function(_0x4990e3){logger[_0xcda3('0x2c')](_0x4990e3[_0xcda3('0x2d')]);if(_0x4990e3['name']){delete _0x4990e3[_0xcda3('0x2e')];}_0x375377[_0xcda3('0x1e')](_0x48084b)[_0xcda3('0x2f')](_0x4990e3);};}exports[_0xcda3('0x30')]=function(_0x244d60,_0x55d956){var _0x48fce9={},_0x1798d3={},_0x2fb1a4={'count':0x0,'rows':[]};var _0x5ae8e7=db[_0xcda3('0x31')][_0xcda3('0x32')];_0x1798d3[_0xcda3('0x33')]=_[_0xcda3('0x34')](_0x5ae8e7);_0x1798d3[_0xcda3('0x35')]=_[_0xcda3('0x34')](_0x244d60[_0xcda3('0x35')]);_0x1798d3[_0xcda3('0x36')]=_[_0xcda3('0x37')](_0x1798d3[_0xcda3('0x33')],_0x1798d3[_0xcda3('0x35')]);_0x48fce9['attributes']=_['intersection'](_0x1798d3[_0xcda3('0x33')],qs[_0xcda3('0x38')](_0x244d60[_0xcda3('0x35')][_0xcda3('0x38')]));_0x48fce9[_0xcda3('0x39')]=_0x48fce9[_0xcda3('0x39')][_0xcda3('0x3a')]?_0x48fce9[_0xcda3('0x39')]:_0x1798d3[_0xcda3('0x33')];if(!_0x244d60['query'][_0xcda3('0x3b')](_0xcda3('0x3c'))){_0x48fce9[_0xcda3('0x23')]=qs['limit'](_0x244d60[_0xcda3('0x35')][_0xcda3('0x23')]);_0x48fce9[_0xcda3('0x22')]=qs['offset'](_0x244d60['query'][_0xcda3('0x22')]);}_0x48fce9['order']=qs[_0xcda3('0x3d')](_0x244d60['query'][_0xcda3('0x3d')]);_0x48fce9[_0xcda3('0x3e')]=qs[_0xcda3('0x36')](_[_0xcda3('0x3f')](_0x244d60[_0xcda3('0x35')],_0x1798d3[_0xcda3('0x36')]));if(_0x244d60[_0xcda3('0x35')][_0xcda3('0x40')]){_0x48fce9[_0xcda3('0x3e')]=_[_0xcda3('0x41')](_0x48fce9[_0xcda3('0x3e')],{'$or':_['map'](_0x5ae8e7,function(_0x3aab0e){if(_0x3aab0e[_0xcda3('0x42')]['key']!==_0xcda3('0x43')){var _0x59c5f8={};_0x59c5f8[_0x3aab0e[_0xcda3('0x44')]]={'$like':'%'+_0x244d60[_0xcda3('0x35')]['filter']+'%'};return _0x59c5f8;}})});}_0x48fce9=_[_0xcda3('0x41')]({},_0x48fce9,_0x244d60[_0xcda3('0x45')]);var _0x727372={'where':_0x48fce9[_0xcda3('0x3e')]};return db[_0xcda3('0x31')][_0xcda3('0x21')](_0x727372)[_0xcda3('0x28')](function(_0x56c489){_0x2fb1a4[_0xcda3('0x21')]=_0x56c489;if(_0x244d60[_0xcda3('0x35')][_0xcda3('0x46')]){_0x48fce9['include']=[{'all':!![]}];}return db[_0xcda3('0x31')][_0xcda3('0x47')](_0x48fce9);})['then'](function(_0x2a7fd6){_0x2fb1a4[_0xcda3('0x48')]=_0x2a7fd6;return _0x2fb1a4;})[_0xcda3('0x28')](respondWithFilteredResult(_0x55d956,_0x48fce9))[_0xcda3('0x49')](handleError(_0x55d956,null));};exports['show']=function(_0xd99ce4,_0x5208c7){var _0x4ab34a={'raw':!![],'where':{'id':_0xd99ce4[_0xcda3('0x4a')]['id']}},_0x1c4827={};_0x1c4827[_0xcda3('0x33')]=_['keys'](db[_0xcda3('0x31')][_0xcda3('0x32')]);_0x1c4827[_0xcda3('0x35')]=_['keys'](_0xd99ce4[_0xcda3('0x35')]);_0x1c4827[_0xcda3('0x36')]=_[_0xcda3('0x37')](_0x1c4827[_0xcda3('0x33')],_0x1c4827[_0xcda3('0x35')]);_0x4ab34a[_0xcda3('0x39')]=_['intersection'](_0x1c4827[_0xcda3('0x33')],qs[_0xcda3('0x38')](_0xd99ce4[_0xcda3('0x35')][_0xcda3('0x38')]));_0x4ab34a[_0xcda3('0x39')]=_0x4ab34a[_0xcda3('0x39')]['length']?_0x4ab34a[_0xcda3('0x39')]:_0x1c4827['model'];if(_0xd99ce4[_0xcda3('0x35')]['includeAll']){_0x4ab34a['include']=[{'all':!![]}];}_0x4ab34a=_['merge']({},_0x4ab34a,_0xd99ce4[_0xcda3('0x45')]);return db[_0xcda3('0x31')][_0xcda3('0x4b')](_0x4ab34a)[_0xcda3('0x28')](handleEntityNotFound(_0x5208c7,null))[_0xcda3('0x28')](respondWithResult(_0x5208c7,null))['catch'](handleError(_0x5208c7,null));};exports[_0xcda3('0x4c')]=function(_0x3d1297,_0x355262,_0x196c46){return db[_0xcda3('0x31')][_0xcda3('0x4b')]({'where':{'id':_0x3d1297[_0xcda3('0x4a')]['id']},'attributes':[_0xcda3('0x2e'),_0xcda3('0x8')],'raw':!![]})[_0xcda3('0x28')](handleEntityNotFound(_0x355262,null))[_0xcda3('0x28')](function(_0x1672a3){if(_0x1672a3){var _0x586d3f=path['join'](config[_0xcda3('0x4d')],_0xcda3('0x4e'),util[_0xcda3('0x4f')](_0xcda3('0x50'),path[_0xcda3('0x51')](_0x1672a3[_0xcda3('0x8')])));var _0x55dab9=fs[_0xcda3('0x52')](_0x586d3f);var _0x26a973=archiver(_0xcda3('0x53'),{'zlib':{'level':0x9}});_0x26a973['on'](_0xcda3('0x54'),function(_0x5f1b53){if(_0x5f1b53[_0xcda3('0x55')]==='ENOENT'){logger[_0xcda3('0x2c')](_0x5f1b53);}else{throw new db[(_0xcda3('0x56'))][(_0xcda3('0x57'))]('Error\x20while\x20generating\x20the\x20zip\x20archive');}});_0x26a973['on'](_0xcda3('0x2c'),function(_0xe598e1){throw new db[(_0xcda3('0x56'))][(_0xcda3('0x57'))](_0xcda3('0x58'));});_0x26a973[_0xcda3('0x59')](_0x55dab9);_0x26a973[_0xcda3('0x5a')](_0xcda3('0x5b'),{'cwd':path[_0xcda3('0x5c')](config[_0xcda3('0x4d')],_0xcda3('0x4e'),path[_0xcda3('0x5d')](_0x1672a3['path'])),'ignore':[path[_0xcda3('0x5c')](path[_0xcda3('0x51')](_0x1672a3[_0xcda3('0x8')]),_0xcda3('0x5e')),path['join'](path[_0xcda3('0x51')](_0x1672a3[_0xcda3('0x8')]),_0xcda3('0x5f'))],'nodir':!![]})[_0xcda3('0x60')]();_0x55dab9['on'](_0xcda3('0x61'),function(){if(!fs[_0xcda3('0x62')](_0x586d3f)){throw new db[(_0xcda3('0x56'))][(_0xcda3('0x57'))](_0xcda3('0x63'));}return _0x355262[_0xcda3('0x4c')](_0x586d3f,util['format'](_0xcda3('0x50'),path['basename'](_0x1672a3[_0xcda3('0x8')])),function(_0xfa8544){if(_0xfa8544){throw new db[(_0xcda3('0x56'))][(_0xcda3('0x57'))](_0xcda3('0x64'));}fs[_0xcda3('0x65')](_0x586d3f);logger[_0xcda3('0x66')](_0xcda3('0x67'));logger[_0xcda3('0x66')](_0xcda3('0x68'));});});}return null;})[_0xcda3('0x49')](handleError(_0x355262,null));};exports[_0xcda3('0x69')]=function(_0x12bf00,_0x4fb72f,_0x174eb4){var _0x2a76ec=path['basename'](_0x12bf00[_0xcda3('0x6a')][_0xcda3('0x6b')],path[_0xcda3('0x6c')](_0x12bf00[_0xcda3('0x6a')]['filename']));var _0x5782d1=path['join'](config[_0xcda3('0x4d')],_0xcda3('0x4e'),_0x12bf00[_0xcda3('0x6a')][_0xcda3('0x6b')]);var _0x4f96a3=path[_0xcda3('0x5c')](config[_0xcda3('0x4d')],_0xcda3('0x4e'),_0x2a76ec);logger[_0xcda3('0x66')]('Plugin\x20upload\x20filepath:\x20%s',_0x5782d1);logger[_0xcda3('0x66')](_0xcda3('0x6d'),_0x4f96a3);try{fs['chmodSync'](_0x5782d1,parseInt(_0xcda3('0x6e'),0x8));extract(_0x5782d1,{'dir':_0x4f96a3},function(_0x3e96dc){if(_0x3e96dc){logger[_0xcda3('0x2c')](_0x3e96dc);handleError(_0x3e96dc,!![]);};var _0x221771=fs[_0xcda3('0x6f')](_0x4f96a3);if(_0x221771[_0xcda3('0x3a')]>0x1){removeReferences(_0x5782d1,_0x4f96a3);logger['error']('Invalid\x20plugin\x20structure');return _0x174eb4(new Error('Invalid\x20plugin\x20structure'));}var _0x5c6088=fs['lstatSync'](path['join'](_0x4f96a3,_0x221771[0x0]));if(_0x5c6088[_0xcda3('0x70')]()){removeReferences(_0x5782d1,_0x4f96a3);logger['error'](_0xcda3('0x71'));return _0x174eb4(new Error(_0xcda3('0x71')));}if(_0x5c6088[_0xcda3('0x72')]()){var _0x17a27e=fs[_0xcda3('0x6f')](path[_0xcda3('0x5c')](_0x4f96a3,_0x221771[0x0]));if(_0x17a27e[_0xcda3('0x3a')]===0x0){removeReferences(_0x5782d1,_0x4f96a3);logger[_0xcda3('0x2c')]('Invalid\x20plugin\x20structure');return _0x174eb4(new Error('Invalid\x20plugin\x20structure'));}var _0x1ef2cb=_0x17a27e['some'](function(_0x4faa30){return _0x4faa30===_0xcda3('0x73');});if(!_0x1ef2cb){return _0x174eb4(new Error(_0xcda3('0x74')));}var _0x12e6c0=fs[_0xcda3('0x75')](path[_0xcda3('0x5c')](_0x4f96a3,_0x221771[0x0],_0xcda3('0x73')));var _0x59fff9=JSON[_0xcda3('0x76')](_0x12e6c0);if(_0xcda3('0x77')==typeof _0x59fff9[_0xcda3('0x2e')]){return _0x174eb4(new Error('Invalid\x20manifest:\x20name\x20missing'));}if('undefined'==typeof _0x59fff9['type']){return _0x174eb4(new Error(_0xcda3('0x78')));}if(_0xcda3('0x77')==typeof _0x59fff9['version']){return _0x174eb4(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if('undefined'==typeof _0x59fff9[_0xcda3('0x79')]){return _0x174eb4(new Error(_0xcda3('0x7a')));}if(_0x59fff9['type']===_0xcda3('0x7b')){if(_0xcda3('0x77')==typeof _0x59fff9[_0xcda3('0x79')][_0xcda3('0x7c')]){return _0x174eb4(new Error(_0xcda3('0x7d')));}if(_0xcda3('0x77')==typeof _0x59fff9[_0xcda3('0x79')]['views'][_0xcda3('0x7e')]&&_0xcda3('0x77')==typeof _0x59fff9['parameters']['views'][_0xcda3('0x7f')]){return _0x174eb4(new Error(_0xcda3('0x80')));}}else if(_0x59fff9[_0xcda3('0x42')]===_0xcda3('0x81')){if(_0xcda3('0x77')==typeof _0x59fff9[_0xcda3('0x79')]['scriptName']){return _0x174eb4(new Error(_0xcda3('0x82')));}if(_0xcda3('0x77')==typeof _0x59fff9['parameters'][_0xcda3('0x83')]){return _0x174eb4(new Error(_0xcda3('0x84')));}}else{return _0x174eb4(new Error(_0xcda3('0x85')));}var _0x2b798e=_0x59fff9[_0xcda3('0x2e')];var _0x469446=_0x59fff9[_0xcda3('0x86')];var _0x3b4adc=_0x59fff9[_0xcda3('0x42')];var _0x2da737=_0x59fff9[_0xcda3('0x87')]?_0x59fff9[_0xcda3('0x87')]:_0xcda3('0x88');var _0x1e2ead=_0x59fff9[_0xcda3('0x89')]?_0x59fff9[_0xcda3('0x89')]:'icon-apps';var _0x513e33='';var _0x3562b5='';var _0x3195dc='';var _0x269d2b='';var _0x51b110=_0x59fff9[_0xcda3('0x8a')];if(_0x3b4adc===_0xcda3('0x7b')){if(_0xcda3('0x77')!=typeof _0x59fff9['parameters'][_0xcda3('0x7c')][_0xcda3('0x7e')]){var _0x4cc0a1=_0x59fff9['parameters']['views'][_0xcda3('0x7e')];if(!/^(f|ht)tps?:\/\//i[_0xcda3('0x8b')](_0x4cc0a1)){_0x513e33=path[_0xcda3('0x5c')]('plugins',_0x2a76ec,_0x221771[0x0],_0x4cc0a1);}else{_0x513e33=_0x4cc0a1;}}else{logger['info'](_0xcda3('0x8c'));}if('undefined'!=typeof _0x59fff9[_0xcda3('0x79')]['views'][_0xcda3('0x7f')]){var _0x4f2d63=_0x59fff9[_0xcda3('0x79')][_0xcda3('0x7c')]['agent'];if(!/^(f|ht)tps?:\/\//i[_0xcda3('0x8b')](_0x4f2d63)){_0x3562b5=path[_0xcda3('0x5c')](_0xcda3('0x8d'),_0x2a76ec,_0x221771[0x0],_0x4f2d63);}else{_0x3562b5=_0x4f2d63;}}else{logger[_0xcda3('0x66')](_0xcda3('0x8e'));}}else if(_0x3b4adc==='script'){_0x3195dc=_0x59fff9[_0xcda3('0x79')][_0xcda3('0x8f')];_0x269d2b=_0x59fff9['parameters'][_0xcda3('0x83')];if(_0xcda3('0x77')!=typeof _0x59fff9[_0xcda3('0x79')]['views']){if(_0xcda3('0x77')!=typeof _0x59fff9[_0xcda3('0x79')][_0xcda3('0x7c')][_0xcda3('0x7e')]){var _0x4cc0a1=_0x59fff9['parameters'][_0xcda3('0x7c')][_0xcda3('0x7e')];if(!/^(f|ht)tps?:\/\//i[_0xcda3('0x8b')](_0x4cc0a1)){_0x513e33=path[_0xcda3('0x5c')](_0xcda3('0x8d'),_0x2a76ec,_0x221771[0x0],_0x4cc0a1);}else{_0x513e33=_0x4cc0a1;}}if(_0xcda3('0x77')!=typeof _0x59fff9[_0xcda3('0x79')]['views']['agent']){var _0x4f2d63=_0x59fff9[_0xcda3('0x79')]['views'][_0xcda3('0x7f')];if(!/^(f|ht)tps?:\/\//i[_0xcda3('0x8b')](_0x4f2d63)){_0x3562b5=path[_0xcda3('0x5c')](_0xcda3('0x8d'),_0x2a76ec,_0x221771[0x0],_0x4f2d63);}else{_0x3562b5=_0x4f2d63;}}}}var _0x2cebe5={'name':_0x2b798e,'description':_0x469446,'path':path[_0xcda3('0x5c')](_0x2a76ec,_0x221771[0x0]),'type':_0x3b4adc,'sidebar':_0x2da737,'icon':_0x1e2ead,'adminUrl':_0x513e33,'agentUrl':_0x3562b5,'scriptName':_0x3195dc,'scriptPath':_0x269d2b,'version':_0x51b110};removeReferences(_0x5782d1,null);return db[_0xcda3('0x31')][_0xcda3('0x90')](_0x2cebe5)[_0xcda3('0x28')](function(_0x1ae7e2){var _0x2de46c={'role':_0x12bf00['body'][_0xcda3('0x91')],'userProfileId':_0x12bf00['body'][_0xcda3('0x92')]};if(!_0x2de46c)throw new Error(_0xcda3('0x93'));if(_0x2de46c['role']===_0xcda3('0x94')){var _0x438121=_0x1ae7e2[_0xcda3('0x2a')]({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':'Plugins','userProfileId':_0x2de46c[_0xcda3('0x92')]},'raw':!![]})['then'](function(_0x16550e){if(_0x16550e&&_0x16550e[_0xcda3('0x95')]===0x0){return db['UserProfileResource'][_0xcda3('0x90')]({'name':_0x438121[_0xcda3('0x2e')],'resourceId':_0x438121['id'],'type':_0x16550e[_0xcda3('0x2e')],'sectionId':_0x16550e['id']},{})[_0xcda3('0x28')](function(){return _0x1ae7e2;});}else{return _0x1ae7e2;}})[_0xcda3('0x49')](function(_0x18aca5){logger[_0xcda3('0x2c')](_0xcda3('0x96'),_0x18aca5);throw _0x18aca5;});}return _0x1ae7e2;})[_0xcda3('0x28')](respondWithResult(_0x4fb72f,null))[_0xcda3('0x49')](handleError(_0x4fb72f,null));}});}catch(_0x5ae00b){_0x4fb72f['status'](0x1f4)[_0xcda3('0x2f')](_0x5ae00b);}};function removeReferences(_0x5ed164,_0x39b3c4){try{if(_0x5ed164){fs[_0xcda3('0x65')](_0x5ed164);logger[_0xcda3('0x66')](_0xcda3('0x97'));}if(_0x39b3c4){rimraf(_0x39b3c4,function(){});logger[_0xcda3('0x66')](_0xcda3('0x98'));}}catch(_0x314874){logger['error'](_0x314874);}}exports[_0xcda3('0x27')]=function(_0x520e7f,_0x15d12d,_0x5842ea){return db['Plugin'][_0xcda3('0x4b')]({'where':{'id':_0x520e7f[_0xcda3('0x4a')]['id']}})[_0xcda3('0x28')](handleEntityNotFound(_0x15d12d,null))[_0xcda3('0x28')](saveUpdates(_0x520e7f['body'],null))[_0xcda3('0x28')](respondWithResult(_0x15d12d,null))[_0xcda3('0x49')](handleError(_0x15d12d,null));};exports[_0xcda3('0x99')]=function(_0x40245f,_0xa9bea7,_0x332d4e){return db[_0xcda3('0x31')][_0xcda3('0x4b')]({'where':{'id':_0x40245f['params']['id']}})[_0xcda3('0x28')](function(_0x583f9c){if(_0x583f9c){return _0x583f9c[_0xcda3('0x29')]();}})['then'](function(_0x2700f4){rimraf(path['join'](config['root'],_0xcda3('0x4e'),path[_0xcda3('0x5d')](_0x2700f4[_0xcda3('0x8')])),function(){});return _0x2700f4;})[_0xcda3('0x28')](handleEntityNotFound(_0xa9bea7,null))[_0xcda3('0x28')](respondWithStatusCode(_0xa9bea7,null))[_0xcda3('0x49')](handleError(_0xa9bea7,null));};exports[_0xcda3('0x9a')]=function(_0x11406e,_0xfda615,_0x26aec5){return BPromise[_0xcda3('0x9b')]()[_0xcda3('0x28')](function(){if(!_0x11406e['query'][_0xcda3('0x8')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x11406e[_0xcda3('0x35')][_0xcda3('0x9c')]){throw new Error(_0xcda3('0x9d'));}var _0x15c802=_0x11406e['query'][_0xcda3('0x9e')]?_0x11406e[_0xcda3('0x35')][_0xcda3('0x9e')]+':'+_0x11406e['query'][_0xcda3('0x9c')]:_0xcda3('0x9f')+_0x11406e[_0xcda3('0x35')][_0xcda3('0x9c')];var _0x55a33a=_0x11406e[_0xcda3('0x35')][_0xcda3('0x20')]?_0x11406e[_0xcda3('0x35')][_0xcda3('0x20')]:!![];var _0x5d0ec7=_0x11406e['query'][_0xcda3('0xa0')]?_0x11406e[_0xcda3('0x35')]['encoding']:null;var _0xd8b4e9={'method':_0x11406e[_0xcda3('0xa1')],'uri':util[_0xcda3('0x4f')](_0xcda3('0xa2'),_0x15c802,_0x11406e['query']['path']),'json':_0x55a33a,'resolveWithFullResponse':!![],'encoding':_0x5d0ec7,'qs':_0x11406e[_0xcda3('0x35')]};if(_0x11406e[_0xcda3('0xa3')]){_0xd8b4e9[_0xcda3('0xa3')]=_0x11406e[_0xcda3('0xa3')];if(_0xd8b4e9['headers'][_0xcda3('0xa4')]){delete _0xd8b4e9['headers']['content-length'];}}if(_0xd8b4e9[_0xcda3('0xa3')][_0xcda3('0xa5')]){delete _0xd8b4e9['headers']['content-type'];}return rp(_0xd8b4e9);})[_0xcda3('0x28')](function(_0x13a3d6){if(_0x13a3d6){_0xfda615[_0xcda3('0x24')](_0x13a3d6['headers']);logger[_0xcda3('0x66')](_0x13a3d6['body']);if(_['endsWith'](_0x11406e[_0xcda3('0x35')][_0xcda3('0x8')],'download')&&_0x13a3d6[_0xcda3('0xa6')]==0x1f4){return _0xfda615[_0xcda3('0x1d')](_0x13a3d6['statusCode']);}else{return _0xfda615[_0xcda3('0x1e')](_0x13a3d6[_0xcda3('0xa6')])[_0xcda3('0x2f')](_0x13a3d6[_0xcda3('0xa7')]);}}else{return _0xfda615[_0xcda3('0x1d')](0xc8);}})[_0xcda3('0x49')](handleError(_0xfda615,null));};exports[_0xcda3('0xa8')]=function(_0x29cafe,_0x38b0c8,_0x32ca31){return BPromise['resolve']()[_0xcda3('0x28')](function(){if(!_0x29cafe[_0xcda3('0x35')][_0xcda3('0x8')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x29cafe['query'][_0xcda3('0x9c')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x2a7c43=_0x29cafe['query'][_0xcda3('0x9e')]?_0x29cafe[_0xcda3('0x35')]['hostname']+':'+_0x29cafe[_0xcda3('0x35')]['port']:_0xcda3('0x9f')+_0x29cafe[_0xcda3('0x35')]['port'];var _0x186c37=_0x29cafe[_0xcda3('0x35')][_0xcda3('0x20')]?_0x29cafe['query'][_0xcda3('0x20')]:!![];var _0x540345=_0x29cafe[_0xcda3('0x35')][_0xcda3('0xa0')]?_0x29cafe['query'][_0xcda3('0xa0')]:null;var _0x3dc84c={'method':_0x29cafe[_0xcda3('0xa1')],'uri':util['format']('%s%s',_0x2a7c43,_0x29cafe[_0xcda3('0x35')][_0xcda3('0x8')]),'json':_0x186c37,'resolveWithFullResponse':!![],'encoding':_0x540345,'body':_0x29cafe[_0xcda3('0xa7')]};if(_0x29cafe[_0xcda3('0xa3')]){_0x3dc84c[_0xcda3('0xa3')]=_0x29cafe[_0xcda3('0xa3')];if(_0x3dc84c[_0xcda3('0xa3')][_0xcda3('0xa4')]){delete _0x3dc84c[_0xcda3('0xa3')][_0xcda3('0xa4')];}}if(_0x3dc84c[_0xcda3('0xa3')]['content-type']){delete _0x3dc84c[_0xcda3('0xa3')][_0xcda3('0xa5')];}return rp(_0x3dc84c);})['then'](function(_0x44e1e9){if(_0x44e1e9){_0x38b0c8[_0xcda3('0x24')](_0x44e1e9[_0xcda3('0xa3')]);logger[_0xcda3('0x66')](_0x44e1e9[_0xcda3('0xa7')]);return _0x38b0c8[_0xcda3('0x1e')](_0x44e1e9[_0xcda3('0xa6')])['send'](_0x44e1e9[_0xcda3('0xa7')]);}else{return _0x38b0c8[_0xcda3('0x1d')](0xc8);}})[_0xcda3('0x49')](handleError(_0x38b0c8,null));};
\ No newline at end of file