Built motion from commit 9d7072cc.|2.5.39
[motion2.git] / server / api / plugin / plugin.controller.js
index 100e6b5..6ae3570 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8cc=['UserProfileResource','error','name','send','index','map','Plugin','rawAttributes','fieldName','type','key','model','query','intersection','attributes','fields','length','nolimit','sort','filters','pick','merge','VIRTUAL','filter','where','count','includeAll','rows','catch','show','keys','include','options','download','find','params','path','join','server/files/plugins','%s.zip','basename','warning','code','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','pipe','glob','**/*','dirname','node_modules/**/*','close','Plugin\x20not\x20found','format','Error\x20while\x20downloading\x20the\x20plugin','unlinkSync','info','Download\x20completed','Temporary\x20file\x20removed','upload','file','filename','extname','root','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','chmodSync','Invalid\x20plugin\x20structure','isFile','isDirectory','readdirSync','some','manifest.json','Plugin\x20manifest\x20missing','parse','undefined','Invalid\x20manifest:\x20name\x20missing','Invalid\x20manifest:\x20version\x20not\x20specified','Invalid\x20manifest:\x20parameters\x20missing','views','Invalid\x20manifest:\x20views\x20missing','parameters','Invalid\x20manifest:\x20no\x20view\x20specified','script','scriptName','Invalid\x20manifest:\x20script\x20name\x20missing','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','Invalid\x20manifest:\x20invalid\x20type','description','sidebar','always','icon','icon-apps','html','test','plugins','Warning:\x20admin\x20view\x20not\x20specified','Warning:\x20agent\x20view\x20not\x20specified','admin','agent','create','body','role','userProfileId','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','Zip\x20archive\x20removed','delete','\x27PATH\x27\x20parameter\x20not\x20specified','port','hostname','http://localhost:','encoding','method','%s%s','headers','content-length','content-type','endsWith','statusCode','webhookPost','\x27PORT\x27\x20parameter\x20not\x20specified','html-pdf','eml-format','request-promise','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','extract-zip','rimraf','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','sendStatus','status','end','offset','limit','set','Content-Range','json','reject','save','update','then','destroy','get','Plugins'];(function(_0x575a38,_0x2e83d7){var _0x5a7bdd=function(_0x1bf478){while(--_0x1bf478){_0x575a38['push'](_0x575a38['shift']());}};_0x5a7bdd(++_0x2e83d7);}(_0xb8cc,0x1d4));var _0xcb8c=function(_0x49d20b,_0x5f1a3b){_0x49d20b=_0x49d20b-0x0;var _0x2eb0b9=_0xb8cc[_0x49d20b];return _0x2eb0b9;};'use strict';var pdf=require(_0xcb8c('0x0'));var emlformat=require(_0xcb8c('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xcb8c('0x2'));var moment=require('moment');var BPromise=require(_0xcb8c('0x3'));var Mustache=require(_0xcb8c('0x4'));var util=require(_0xcb8c('0x5'));var path=require('path');var sox=require(_0xcb8c('0x6'));var csv=require(_0xcb8c('0x7'));var ejs=require(_0xcb8c('0x8'));var fs=require('fs');var _=require(_0xcb8c('0x9'));var squel=require(_0xcb8c('0xa'));var crypto=require(_0xcb8c('0xb'));var jsforce=require(_0xcb8c('0xc'));var deskjs=require(_0xcb8c('0xd'));var toCsv=require(_0xcb8c('0x7'));var querystring=require(_0xcb8c('0xe'));var Papa=require(_0xcb8c('0xf'));var extract=require(_0xcb8c('0x10'));var rimraf=require(_0xcb8c('0x11'));var archiver=require('archiver');var Redis=require(_0xcb8c('0x12'));var authService=require(_0xcb8c('0x13'));var qs=require(_0xcb8c('0x14'));var as=require(_0xcb8c('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xcb8c('0x16'))(_0xcb8c('0x17'));var utils=require(_0xcb8c('0x18'));var config=require(_0xcb8c('0x19'));var db=require(_0xcb8c('0x1a'))['db'];config[_0xcb8c('0x1b')]=_[_0xcb8c('0x1c')](config[_0xcb8c('0x1b')],{'host':_0xcb8c('0x1d'),'port':0x18eb});var socket=require(_0xcb8c('0x1e'))(new Redis(config[_0xcb8c('0x1b')]));require(_0xcb8c('0x1f'))[_0xcb8c('0x20')](socket);function respondWithStatusCode(_0x29232c,_0x44381e){_0x44381e=_0x44381e||0xcc;return function(_0x30d74c){if(_0x30d74c){return _0x29232c[_0xcb8c('0x21')](_0x44381e);}return _0x29232c[_0xcb8c('0x22')](_0x44381e)[_0xcb8c('0x23')]();};}function respondWithResult(_0x5ac3a3,_0x4f4cf9){_0x4f4cf9=_0x4f4cf9||0xc8;return function(_0x2cdf0d){if(_0x2cdf0d){return _0x5ac3a3['status'](_0x4f4cf9)['json'](_0x2cdf0d);}};}function respondWithFilteredResult(_0x297983,_0x3a9218){return function(_0xee418a){if(_0xee418a){var _0x56f402=_0xee418a['count'],_0x2e13c3=_0x3a9218[_0xcb8c('0x24')],_0xdc7994=_0x3a9218[_0xcb8c('0x24')]+_0x3a9218[_0xcb8c('0x25')],_0x1f8079;if(_0xdc7994>=_0x56f402){_0xdc7994=_0x56f402;_0x1f8079=0xc8;}else{_0x1f8079=0xce;}_0x297983[_0xcb8c('0x22')](_0x1f8079);return _0x297983[_0xcb8c('0x26')](_0xcb8c('0x27'),_0x2e13c3+'-'+_0xdc7994+'/'+_0x56f402)[_0xcb8c('0x28')](_0xee418a);}return null;};}function patchUpdates(_0x94d2b0){return function(_0x506c32){try{jsonpatch['apply'](_0x506c32,_0x94d2b0,!![]);}catch(_0x1a4c6b){return BPromise[_0xcb8c('0x29')](_0x1a4c6b);}return _0x506c32[_0xcb8c('0x2a')]();};}function saveUpdates(_0x391846,_0x46a11c){return function(_0x36cf13){if(_0x36cf13){return _0x36cf13[_0xcb8c('0x2b')](_0x391846)[_0xcb8c('0x2c')](function(_0x35a20a){return _0x35a20a;});}return null;};}function removeEntity(_0x5d4896,_0x41b85e){return function(_0x5733e2){if(_0x5733e2){return _0x5733e2[_0xcb8c('0x2d')]()[_0xcb8c('0x2c')](function(){var _0xcfc4ed=_0x5733e2[_0xcb8c('0x2e')]({'plain':!![]});var _0x2b989a=_0xcb8c('0x2f');return db[_0xcb8c('0x30')]['destroy']({'where':{'type':_0x2b989a,'resourceId':_0xcfc4ed['id']}})[_0xcb8c('0x2c')](function(){return _0x5733e2;});})[_0xcb8c('0x2c')](function(){_0x5d4896[_0xcb8c('0x22')](0xcc)[_0xcb8c('0x23')]();});}};}function handleEntityNotFound(_0x803a61,_0x3fad57){return function(_0x4bc925){if(!_0x4bc925){_0x803a61[_0xcb8c('0x21')](0x194);}return _0x4bc925;};}function handleError(_0xca881a,_0x4f7a71){_0x4f7a71=_0x4f7a71||0x1f4;return function(_0xf99e03){logger[_0xcb8c('0x31')](_0xf99e03['stack']);if(_0xf99e03[_0xcb8c('0x32')]){delete _0xf99e03[_0xcb8c('0x32')];}_0xca881a[_0xcb8c('0x22')](_0x4f7a71)[_0xcb8c('0x33')](_0xf99e03);};}exports[_0xcb8c('0x34')]=function(_0x40797b,_0x1ee6f6){var _0x1f756c={},_0xb5f83a={},_0x3e6d6d={'count':0x0,'rows':[]};var _0x367a79=_[_0xcb8c('0x35')](db[_0xcb8c('0x36')][_0xcb8c('0x37')],function(_0x242175){return{'name':_0x242175[_0xcb8c('0x38')],'type':_0x242175[_0xcb8c('0x39')][_0xcb8c('0x3a')]};});_0xb5f83a[_0xcb8c('0x3b')]=_['map'](_0x367a79,_0xcb8c('0x32'));_0xb5f83a['query']=_['keys'](_0x40797b[_0xcb8c('0x3c')]);_0xb5f83a['filters']=_[_0xcb8c('0x3d')](_0xb5f83a[_0xcb8c('0x3b')],_0xb5f83a['query']);_0x1f756c[_0xcb8c('0x3e')]=_[_0xcb8c('0x3d')](_0xb5f83a[_0xcb8c('0x3b')],qs[_0xcb8c('0x3f')](_0x40797b['query'][_0xcb8c('0x3f')]));_0x1f756c[_0xcb8c('0x3e')]=_0x1f756c['attributes'][_0xcb8c('0x40')]?_0x1f756c[_0xcb8c('0x3e')]:_0xb5f83a[_0xcb8c('0x3b')];if(!_0x40797b[_0xcb8c('0x3c')]['hasOwnProperty'](_0xcb8c('0x41'))){_0x1f756c[_0xcb8c('0x25')]=qs[_0xcb8c('0x25')](_0x40797b[_0xcb8c('0x3c')][_0xcb8c('0x25')]);_0x1f756c[_0xcb8c('0x24')]=qs[_0xcb8c('0x24')](_0x40797b[_0xcb8c('0x3c')][_0xcb8c('0x24')]);}_0x1f756c['order']=qs[_0xcb8c('0x42')](_0x40797b[_0xcb8c('0x3c')][_0xcb8c('0x42')]);_0x1f756c['where']=qs[_0xcb8c('0x43')](_[_0xcb8c('0x44')](_0x40797b[_0xcb8c('0x3c')],_0xb5f83a[_0xcb8c('0x43')]),_0x367a79);if(_0x40797b[_0xcb8c('0x3c')]['filter']){_0x1f756c['where']=_[_0xcb8c('0x45')](_0x1f756c['where'],{'$or':_[_0xcb8c('0x35')](_0x367a79,function(_0x4d95e9){if(_0x4d95e9[_0xcb8c('0x39')]!==_0xcb8c('0x46')){var _0x1d7a95={};_0x1d7a95[_0x4d95e9[_0xcb8c('0x32')]]={'$like':'%'+_0x40797b[_0xcb8c('0x3c')][_0xcb8c('0x47')]+'%'};return _0x1d7a95;}})});}_0x1f756c=_[_0xcb8c('0x45')]({},_0x1f756c,_0x40797b['options']);var _0x104ad0={'where':_0x1f756c[_0xcb8c('0x48')]};return db[_0xcb8c('0x36')][_0xcb8c('0x49')](_0x104ad0)['then'](function(_0x4ff2c1){_0x3e6d6d[_0xcb8c('0x49')]=_0x4ff2c1;if(_0x40797b[_0xcb8c('0x3c')][_0xcb8c('0x4a')]){_0x1f756c['include']=[{'all':!![]}];}return db[_0xcb8c('0x36')]['findAll'](_0x1f756c);})[_0xcb8c('0x2c')](function(_0x4ec9a0){_0x3e6d6d[_0xcb8c('0x4b')]=_0x4ec9a0;return _0x3e6d6d;})[_0xcb8c('0x2c')](respondWithFilteredResult(_0x1ee6f6,_0x1f756c))[_0xcb8c('0x4c')](handleError(_0x1ee6f6,null));};exports[_0xcb8c('0x4d')]=function(_0x5bbadb,_0x1f8748){var _0x4d26c3={'raw':!![],'where':{'id':_0x5bbadb['params']['id']}},_0xdcf300={};_0xdcf300[_0xcb8c('0x3b')]=_[_0xcb8c('0x4e')](db[_0xcb8c('0x36')][_0xcb8c('0x37')]);_0xdcf300[_0xcb8c('0x3c')]=_[_0xcb8c('0x4e')](_0x5bbadb[_0xcb8c('0x3c')]);_0xdcf300['filters']=_[_0xcb8c('0x3d')](_0xdcf300[_0xcb8c('0x3b')],_0xdcf300[_0xcb8c('0x3c')]);_0x4d26c3['attributes']=_[_0xcb8c('0x3d')](_0xdcf300[_0xcb8c('0x3b')],qs['fields'](_0x5bbadb[_0xcb8c('0x3c')]['fields']));_0x4d26c3[_0xcb8c('0x3e')]=_0x4d26c3[_0xcb8c('0x3e')][_0xcb8c('0x40')]?_0x4d26c3[_0xcb8c('0x3e')]:_0xdcf300[_0xcb8c('0x3b')];if(_0x5bbadb[_0xcb8c('0x3c')][_0xcb8c('0x4a')]){_0x4d26c3[_0xcb8c('0x4f')]=[{'all':!![]}];}_0x4d26c3=_['merge']({},_0x4d26c3,_0x5bbadb[_0xcb8c('0x50')]);return db['Plugin']['find'](_0x4d26c3)[_0xcb8c('0x2c')](handleEntityNotFound(_0x1f8748,null))[_0xcb8c('0x2c')](respondWithResult(_0x1f8748,null))[_0xcb8c('0x4c')](handleError(_0x1f8748,null));};exports[_0xcb8c('0x51')]=function(_0x16d645,_0x5d8229,_0x255881){return db[_0xcb8c('0x36')][_0xcb8c('0x52')]({'where':{'id':_0x16d645[_0xcb8c('0x53')]['id']},'attributes':['name',_0xcb8c('0x54')],'raw':!![]})['then'](handleEntityNotFound(_0x5d8229,null))[_0xcb8c('0x2c')](function(_0xfb8ee8){if(_0xfb8ee8){var _0xae1df4=path[_0xcb8c('0x55')](config['root'],_0xcb8c('0x56'),util['format'](_0xcb8c('0x57'),path[_0xcb8c('0x58')](_0xfb8ee8[_0xcb8c('0x54')])));var _0x327b86=fs['createWriteStream'](_0xae1df4);var _0x311c6f=archiver('zip',{'zlib':{'level':0x9}});_0x311c6f['on'](_0xcb8c('0x59'),function(_0x4d75de){if(_0x4d75de[_0xcb8c('0x5a')]===_0xcb8c('0x5b')){logger[_0xcb8c('0x31')](_0x4d75de);}else{throw new db[(_0xcb8c('0x5c'))][(_0xcb8c('0x5d'))](_0xcb8c('0x5e'));}});_0x311c6f['on'](_0xcb8c('0x31'),function(_0xaabd0e){throw new db[(_0xcb8c('0x5c'))][(_0xcb8c('0x5d'))](_0xcb8c('0x5e'));});_0x311c6f[_0xcb8c('0x5f')](_0x327b86);_0x311c6f[_0xcb8c('0x60')](_0xcb8c('0x61'),{'cwd':path[_0xcb8c('0x55')](config['root'],_0xcb8c('0x56'),path[_0xcb8c('0x62')](_0xfb8ee8[_0xcb8c('0x54')])),'ignore':[path[_0xcb8c('0x55')](path[_0xcb8c('0x58')](_0xfb8ee8[_0xcb8c('0x54')]),_0xcb8c('0x63')),path[_0xcb8c('0x55')](path['basename'](_0xfb8ee8['path']),'attachments/**/*')],'nodir':!![]})['finalize']();_0x327b86['on'](_0xcb8c('0x64'),function(){if(!fs['existsSync'](_0xae1df4)){throw new db[(_0xcb8c('0x5c'))][(_0xcb8c('0x5d'))](_0xcb8c('0x65'));}return _0x5d8229[_0xcb8c('0x51')](_0xae1df4,util[_0xcb8c('0x66')](_0xcb8c('0x57'),path[_0xcb8c('0x58')](_0xfb8ee8['path'])),function(_0x3fcab9){if(_0x3fcab9){throw new db[(_0xcb8c('0x5c'))][(_0xcb8c('0x5d'))](_0xcb8c('0x67'));}fs[_0xcb8c('0x68')](_0xae1df4);logger[_0xcb8c('0x69')](_0xcb8c('0x6a'));logger[_0xcb8c('0x69')](_0xcb8c('0x6b'));});});}return null;})[_0xcb8c('0x4c')](handleError(_0x5d8229,null));};exports[_0xcb8c('0x6c')]=function(_0x363fb5,_0x21623e,_0x51e98e){var _0x4794b3=path[_0xcb8c('0x58')](_0x363fb5[_0xcb8c('0x6d')][_0xcb8c('0x6e')],path[_0xcb8c('0x6f')](_0x363fb5[_0xcb8c('0x6d')]['filename']));var _0x76a968=path[_0xcb8c('0x55')](config[_0xcb8c('0x70')],_0xcb8c('0x56'),_0x363fb5[_0xcb8c('0x6d')][_0xcb8c('0x6e')]);var _0x15d444=path[_0xcb8c('0x55')](config[_0xcb8c('0x70')],'server/files/plugins',_0x4794b3);logger[_0xcb8c('0x69')](_0xcb8c('0x71'),_0x76a968);logger['info'](_0xcb8c('0x72'),_0x15d444);try{fs[_0xcb8c('0x73')](_0x76a968,parseInt('0777',0x8));extract(_0x76a968,{'dir':_0x15d444},function(_0x5bef98){if(_0x5bef98){logger['error'](_0x5bef98);handleError(_0x5bef98,!![]);};var _0x4a4044=fs['readdirSync'](_0x15d444);if(_0x4a4044[_0xcb8c('0x40')]>0x1){removeReferences(_0x76a968,_0x15d444);logger[_0xcb8c('0x31')](_0xcb8c('0x74'));return _0x51e98e(new Error('Invalid\x20plugin\x20structure'));}var _0x433bc3=fs['lstatSync'](path[_0xcb8c('0x55')](_0x15d444,_0x4a4044[0x0]));if(_0x433bc3[_0xcb8c('0x75')]()){removeReferences(_0x76a968,_0x15d444);logger[_0xcb8c('0x31')](_0xcb8c('0x74'));return _0x51e98e(new Error(_0xcb8c('0x74')));}if(_0x433bc3[_0xcb8c('0x76')]()){var _0x23b824=fs[_0xcb8c('0x77')](path[_0xcb8c('0x55')](_0x15d444,_0x4a4044[0x0]));if(_0x23b824[_0xcb8c('0x40')]===0x0){removeReferences(_0x76a968,_0x15d444);logger[_0xcb8c('0x31')](_0xcb8c('0x74'));return _0x51e98e(new Error(_0xcb8c('0x74')));}var _0x3c52b6=_0x23b824[_0xcb8c('0x78')](function(_0x2b6017){return _0x2b6017===_0xcb8c('0x79');});if(!_0x3c52b6){return _0x51e98e(new Error(_0xcb8c('0x7a')));}var _0x2ce4a0=fs['readFileSync'](path[_0xcb8c('0x55')](_0x15d444,_0x4a4044[0x0],_0xcb8c('0x79')));var _0x3f9f73=JSON[_0xcb8c('0x7b')](_0x2ce4a0);if(_0xcb8c('0x7c')==typeof _0x3f9f73['name']){return _0x51e98e(new Error(_0xcb8c('0x7d')));}if(_0xcb8c('0x7c')==typeof _0x3f9f73['type']){return _0x51e98e(new Error('Invalid\x20manifest:\x20type\x20missing'));}if(_0xcb8c('0x7c')==typeof _0x3f9f73['version']){return _0x51e98e(new Error(_0xcb8c('0x7e')));}if(_0xcb8c('0x7c')==typeof _0x3f9f73['parameters']){return _0x51e98e(new Error(_0xcb8c('0x7f')));}if(_0x3f9f73[_0xcb8c('0x39')]==='html'){if(_0xcb8c('0x7c')==typeof _0x3f9f73['parameters'][_0xcb8c('0x80')]){return _0x51e98e(new Error(_0xcb8c('0x81')));}if(_0xcb8c('0x7c')==typeof _0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x80')]['admin']&&'undefined'==typeof _0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x80')]['agent']){return _0x51e98e(new Error(_0xcb8c('0x83')));}}else if(_0x3f9f73[_0xcb8c('0x39')]===_0xcb8c('0x84')){if(_0xcb8c('0x7c')==typeof _0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x85')]){return _0x51e98e(new Error(_0xcb8c('0x86')));}if('undefined'==typeof _0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x87')]){return _0x51e98e(new Error(_0xcb8c('0x88')));}}else{return _0x51e98e(new Error(_0xcb8c('0x89')));}var _0x19a36e=_0x3f9f73[_0xcb8c('0x32')];var _0x36ac4a=_0x3f9f73[_0xcb8c('0x8a')];var _0x2c84af=_0x3f9f73['type'];var _0x2e3795=_0x3f9f73[_0xcb8c('0x8b')]?_0x3f9f73['sidebar']:_0xcb8c('0x8c');var _0xc818e1=_0x3f9f73[_0xcb8c('0x8d')]?_0x3f9f73['icon']:_0xcb8c('0x8e');var _0x11f080='';var _0x279ff7='';var _0x228d1f='';var _0x449340='';var _0x4acde4=_0x3f9f73['version'];if(_0x2c84af===_0xcb8c('0x8f')){if(_0xcb8c('0x7c')!=typeof _0x3f9f73[_0xcb8c('0x82')]['views']['admin']){var _0x1666e3=_0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x80')]['admin'];if(!/^(f|ht)tps?:\/\//i[_0xcb8c('0x90')](_0x1666e3)){_0x11f080=path[_0xcb8c('0x55')](_0xcb8c('0x91'),_0x4794b3,_0x4a4044[0x0],_0x1666e3);}else{_0x11f080=_0x1666e3;}}else{logger[_0xcb8c('0x69')](_0xcb8c('0x92'));}if(_0xcb8c('0x7c')!=typeof _0x3f9f73[_0xcb8c('0x82')]['views']['agent']){var _0x48a279=_0x3f9f73['parameters'][_0xcb8c('0x80')]['agent'];if(!/^(f|ht)tps?:\/\//i['test'](_0x48a279)){_0x279ff7=path[_0xcb8c('0x55')]('plugins',_0x4794b3,_0x4a4044[0x0],_0x48a279);}else{_0x279ff7=_0x48a279;}}else{logger[_0xcb8c('0x69')](_0xcb8c('0x93'));}}else if(_0x2c84af===_0xcb8c('0x84')){_0x228d1f=_0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x85')];_0x449340=_0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x87')];if(_0xcb8c('0x7c')!=typeof _0x3f9f73['parameters'][_0xcb8c('0x80')]){if(_0xcb8c('0x7c')!=typeof _0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x80')][_0xcb8c('0x94')]){var _0x1666e3=_0x3f9f73['parameters'][_0xcb8c('0x80')][_0xcb8c('0x94')];if(!/^(f|ht)tps?:\/\//i[_0xcb8c('0x90')](_0x1666e3)){_0x11f080=path[_0xcb8c('0x55')]('plugins',_0x4794b3,_0x4a4044[0x0],_0x1666e3);}else{_0x11f080=_0x1666e3;}}if('undefined'!=typeof _0x3f9f73[_0xcb8c('0x82')]['views'][_0xcb8c('0x95')]){var _0x48a279=_0x3f9f73[_0xcb8c('0x82')][_0xcb8c('0x80')][_0xcb8c('0x95')];if(!/^(f|ht)tps?:\/\//i[_0xcb8c('0x90')](_0x48a279)){_0x279ff7=path[_0xcb8c('0x55')](_0xcb8c('0x91'),_0x4794b3,_0x4a4044[0x0],_0x48a279);}else{_0x279ff7=_0x48a279;}}}}var _0x39552e={'name':_0x19a36e,'description':_0x36ac4a,'path':path[_0xcb8c('0x55')](_0x4794b3,_0x4a4044[0x0]),'type':_0x2c84af,'sidebar':_0x2e3795,'icon':_0xc818e1,'adminUrl':_0x11f080,'agentUrl':_0x279ff7,'scriptName':_0x228d1f,'scriptPath':_0x449340,'version':_0x4acde4};removeReferences(_0x76a968,null);return db[_0xcb8c('0x36')][_0xcb8c('0x96')](_0x39552e)[_0xcb8c('0x2c')](function(_0x22be8a){var _0x520213={'role':_0x363fb5[_0xcb8c('0x97')][_0xcb8c('0x98')],'userProfileId':_0x363fb5['body'][_0xcb8c('0x99')]};if(!_0x520213)throw new Error(_0xcb8c('0x9a'));if(_0x520213[_0xcb8c('0x98')]==='user'){var _0x519f64=_0x22be8a[_0xcb8c('0x2e')]({'plain':!![]});return db[_0xcb8c('0x9b')][_0xcb8c('0x52')]({'where':{'name':_0xcb8c('0x2f'),'userProfileId':_0x520213[_0xcb8c('0x99')]},'raw':!![]})['then'](function(_0x32fa35){if(_0x32fa35&&_0x32fa35['autoAssociation']===0x0){return db['UserProfileResource'][_0xcb8c('0x96')]({'name':_0x519f64[_0xcb8c('0x32')],'resourceId':_0x519f64['id'],'type':_0x32fa35[_0xcb8c('0x32')],'sectionId':_0x32fa35['id']},{})['then'](function(){return _0x22be8a;});}else{return _0x22be8a;}})['catch'](function(_0x5d2df8){logger[_0xcb8c('0x31')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5d2df8);throw _0x5d2df8;});}return _0x22be8a;})[_0xcb8c('0x2c')](respondWithResult(_0x21623e,null))[_0xcb8c('0x4c')](handleError(_0x21623e,null));}});}catch(_0x49ef10){_0x21623e[_0xcb8c('0x22')](0x1f4)[_0xcb8c('0x33')](_0x49ef10);}};function removeReferences(_0x52b896,_0x7f36e){try{if(_0x52b896){fs[_0xcb8c('0x68')](_0x52b896);logger[_0xcb8c('0x69')](_0xcb8c('0x9c'));}if(_0x7f36e){rimraf(_0x7f36e,function(){});logger[_0xcb8c('0x69')]('Extracted\x20folder\x20removed');}}catch(_0x65578f){logger[_0xcb8c('0x31')](_0x65578f);}}exports['update']=function(_0x31fff1,_0x3b9938,_0xa9887b){return db[_0xcb8c('0x36')]['find']({'where':{'id':_0x31fff1[_0xcb8c('0x53')]['id']}})[_0xcb8c('0x2c')](handleEntityNotFound(_0x3b9938,null))[_0xcb8c('0x2c')](saveUpdates(_0x31fff1[_0xcb8c('0x97')],null))[_0xcb8c('0x2c')](respondWithResult(_0x3b9938,null))[_0xcb8c('0x4c')](handleError(_0x3b9938,null));};exports[_0xcb8c('0x9d')]=function(_0x361d7a,_0x446cf6,_0x4bee2e){return db[_0xcb8c('0x36')][_0xcb8c('0x52')]({'where':{'id':_0x361d7a[_0xcb8c('0x53')]['id']}})['then'](function(_0x92e988){if(_0x92e988){return _0x92e988[_0xcb8c('0x2d')]();}})[_0xcb8c('0x2c')](function(_0x15f979){rimraf(path['join'](config[_0xcb8c('0x70')],_0xcb8c('0x56'),path[_0xcb8c('0x62')](_0x15f979['path'])),function(){});return _0x15f979;})['then'](handleEntityNotFound(_0x446cf6,null))[_0xcb8c('0x2c')](respondWithStatusCode(_0x446cf6,null))['catch'](handleError(_0x446cf6,null));};exports['webhookGet']=function(_0x122802,_0x205a4d,_0xa1a0aa){return BPromise['resolve']()[_0xcb8c('0x2c')](function(){if(!_0x122802['query'][_0xcb8c('0x54')]){throw new Error(_0xcb8c('0x9e'));}if(!_0x122802[_0xcb8c('0x3c')][_0xcb8c('0x9f')]){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x25f88d=_0x122802[_0xcb8c('0x3c')]['hostname']?_0x122802[_0xcb8c('0x3c')][_0xcb8c('0xa0')]+':'+_0x122802[_0xcb8c('0x3c')][_0xcb8c('0x9f')]:_0xcb8c('0xa1')+_0x122802['query'][_0xcb8c('0x9f')];var _0x1cd7c8=_0x122802[_0xcb8c('0x3c')][_0xcb8c('0x28')]?_0x122802[_0xcb8c('0x3c')][_0xcb8c('0x28')]:!![];var _0x28519c=_0x122802[_0xcb8c('0x3c')][_0xcb8c('0xa2')]?_0x122802['query'][_0xcb8c('0xa2')]:null;var _0x3514ec={'method':_0x122802[_0xcb8c('0xa3')],'uri':util['format'](_0xcb8c('0xa4'),_0x25f88d,_0x122802[_0xcb8c('0x3c')]['path']),'json':_0x1cd7c8,'resolveWithFullResponse':!![],'encoding':_0x28519c,'qs':_0x122802[_0xcb8c('0x3c')]};if(_0x122802[_0xcb8c('0xa5')]){_0x3514ec[_0xcb8c('0xa5')]=_0x122802[_0xcb8c('0xa5')];if(_0x3514ec['headers']['content-length']){delete _0x3514ec[_0xcb8c('0xa5')][_0xcb8c('0xa6')];}}if(_0x3514ec[_0xcb8c('0xa5')][_0xcb8c('0xa7')]){delete _0x3514ec['headers'][_0xcb8c('0xa7')];}return rp(_0x3514ec);})[_0xcb8c('0x2c')](function(_0x483d46){if(_0x483d46){_0x205a4d[_0xcb8c('0x26')](_0x483d46[_0xcb8c('0xa5')]);logger['info'](_0x483d46['body']);if(_[_0xcb8c('0xa8')](_0x122802['query'][_0xcb8c('0x54')],_0xcb8c('0x51'))&&_0x483d46[_0xcb8c('0xa9')]==0x1f4){return _0x205a4d[_0xcb8c('0x21')](_0x483d46['statusCode']);}else{return _0x205a4d['status'](_0x483d46[_0xcb8c('0xa9')])[_0xcb8c('0x33')](_0x483d46[_0xcb8c('0x97')]);}}else{return _0x205a4d[_0xcb8c('0x21')](0xc8);}})[_0xcb8c('0x4c')](handleError(_0x205a4d,null));};exports[_0xcb8c('0xaa')]=function(_0x55eb1d,_0x3ac4d6,_0x268213){return BPromise['resolve']()[_0xcb8c('0x2c')](function(){if(!_0x55eb1d['query'][_0xcb8c('0x54')]){throw new Error(_0xcb8c('0x9e'));}if(!_0x55eb1d['query']['port']){throw new Error(_0xcb8c('0xab'));}var _0x4e380b=_0x55eb1d[_0xcb8c('0x3c')]['hostname']?_0x55eb1d['query']['hostname']+':'+_0x55eb1d[_0xcb8c('0x3c')][_0xcb8c('0x9f')]:_0xcb8c('0xa1')+_0x55eb1d['query'][_0xcb8c('0x9f')];var _0x4684ae=_0x55eb1d[_0xcb8c('0x3c')]['json']?_0x55eb1d['query']['json']:!![];var _0x2e5e8f=_0x55eb1d[_0xcb8c('0x3c')][_0xcb8c('0xa2')]?_0x55eb1d['query'][_0xcb8c('0xa2')]:null;var _0x1d8327={'method':_0x55eb1d[_0xcb8c('0xa3')],'uri':util[_0xcb8c('0x66')](_0xcb8c('0xa4'),_0x4e380b,_0x55eb1d[_0xcb8c('0x3c')][_0xcb8c('0x54')]),'json':_0x4684ae,'resolveWithFullResponse':!![],'encoding':_0x2e5e8f,'body':_0x55eb1d['body']};if(_0x55eb1d[_0xcb8c('0xa5')]){_0x1d8327[_0xcb8c('0xa5')]=_0x55eb1d[_0xcb8c('0xa5')];if(_0x1d8327['headers']['content-length']){delete _0x1d8327[_0xcb8c('0xa5')][_0xcb8c('0xa6')];}}if(_0x1d8327[_0xcb8c('0xa5')][_0xcb8c('0xa7')]){delete _0x1d8327[_0xcb8c('0xa5')]['content-type'];}return rp(_0x1d8327);})[_0xcb8c('0x2c')](function(_0x4ba8c4){if(_0x4ba8c4){_0x3ac4d6[_0xcb8c('0x26')](_0x4ba8c4[_0xcb8c('0xa5')]);logger[_0xcb8c('0x69')](_0x4ba8c4[_0xcb8c('0x97')]);return _0x3ac4d6['status'](_0x4ba8c4[_0xcb8c('0xa9')])[_0xcb8c('0x33')](_0x4ba8c4['body']);}else{return _0x3ac4d6[_0xcb8c('0x21')](0xc8);}})['catch'](handleError(_0x3ac4d6,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