Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / api / plugin / plugin.controller.js
index 76e69c2..e064624 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x15b6=['get','Plugins','UserProfileResource','error','stack','name','Plugin','rawAttributes','fieldName','type','model','query','keys','filters','attributes','fields','length','nolimit','order','where','pick','filter','merge','options','includeAll','findAll','catch','show','params','intersection','include','find','download','join','root','server/files/plugins','format','%s.zip','basename','zip','warning','code','ENOENT','Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','pipe','**/*','node_modules/**/*','attachments/**/*','finalize','close','existsSync','Plugin\x20not\x20found','unlinkSync','info','Download\x20completed','Temporary\x20file\x20removed','file','filename','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','0777','readdirSync','Invalid\x20plugin\x20structure','isFile','some','Plugin\x20manifest\x20missing','manifest.json','parse','undefined','Invalid\x20manifest:\x20type\x20missing','version','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','sidebar','icon','test','plugins','Warning:\x20agent\x20view\x20not\x20specified','scriptName','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','send','Zip\x20archive\x20removed','delete','dirname','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','hostname','port','http://localhost:','encoding','method','%s%s','headers','content-length','content-type','endsWith','statusCode','webhookPost','\x27PORT\x27\x20parameter\x20not\x20specified','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','defaults','redis','socket.io-emitter','./plugin.socket','register','sendStatus','status','end','json','count','offset','set','Content-Range','reject','save','update','destroy','then'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x15b6,0x119));var _0x615b=function(_0x251f64,_0x49b19a){_0x251f64=_0x251f64-0x0;var _0x41fa32=_0x15b6[_0x251f64];return _0x41fa32;};'use strict';var pdf=require(_0x615b('0x0'));var emlformat=require(_0x615b('0x1'));var rimraf=require(_0x615b('0x2'));var zipdir=require(_0x615b('0x3'));var jsonpatch=require(_0x615b('0x4'));var rp=require(_0x615b('0x5'));var moment=require(_0x615b('0x6'));var BPromise=require(_0x615b('0x7'));var Mustache=require(_0x615b('0x8'));var util=require(_0x615b('0x9'));var path=require(_0x615b('0xa'));var sox=require(_0x615b('0xb'));var csv=require(_0x615b('0xc'));var ejs=require(_0x615b('0xd'));var fs=require('fs');var _=require(_0x615b('0xe'));var squel=require(_0x615b('0xf'));var crypto=require(_0x615b('0x10'));var jsforce=require(_0x615b('0x11'));var deskjs=require(_0x615b('0x12'));var toCsv=require(_0x615b('0xc'));var querystring=require(_0x615b('0x13'));var Papa=require(_0x615b('0x14'));var extract=require('extract-zip');var rimraf=require(_0x615b('0x2'));var archiver=require('archiver');var Redis=require(_0x615b('0x15'));var authService=require(_0x615b('0x16'));var qs=require(_0x615b('0x17'));var as=require(_0x615b('0x18'));var hardwareService=require(_0x615b('0x19'));var logger=require(_0x615b('0x1a'))('api');var utils=require('../../config/utils');var config=require(_0x615b('0x1b'));var db=require(_0x615b('0x1c'))['db'];config['redis']=_[_0x615b('0x1d')](config[_0x615b('0x1e')],{'host':'localhost','port':0x18eb});var socket=require(_0x615b('0x1f'))(new Redis(config[_0x615b('0x1e')]));require(_0x615b('0x20'))[_0x615b('0x21')](socket);function respondWithStatusCode(_0x4c8483,_0x52473e){_0x52473e=_0x52473e||0xcc;return function(_0xaaaf5){if(_0xaaaf5){return _0x4c8483[_0x615b('0x22')](_0x52473e);}return _0x4c8483[_0x615b('0x23')](_0x52473e)[_0x615b('0x24')]();};}function respondWithResult(_0x5da0bc,_0x5cf204){_0x5cf204=_0x5cf204||0xc8;return function(_0x13e67d){if(_0x13e67d){return _0x5da0bc[_0x615b('0x23')](_0x5cf204)[_0x615b('0x25')](_0x13e67d);}};}function respondWithFilteredResult(_0x309da5,_0x3e68dc){return function(_0x21ce95){if(_0x21ce95){var _0xae606d=_0x21ce95[_0x615b('0x26')],_0x1ce8bd=_0x3e68dc[_0x615b('0x27')],_0x46093b=_0x3e68dc[_0x615b('0x27')]+_0x3e68dc['limit'],_0x1a563b;if(_0x46093b>=_0xae606d){_0x46093b=_0xae606d;_0x1a563b=0xc8;}else{_0x1a563b=0xce;}_0x309da5['status'](_0x1a563b);return _0x309da5[_0x615b('0x28')](_0x615b('0x29'),_0x1ce8bd+'-'+_0x46093b+'/'+_0xae606d)[_0x615b('0x25')](_0x21ce95);}return null;};}function patchUpdates(_0x56bf49){return function(_0x4380d1){try{jsonpatch['apply'](_0x4380d1,_0x56bf49,!![]);}catch(_0x2a4aa6){return BPromise[_0x615b('0x2a')](_0x2a4aa6);}return _0x4380d1[_0x615b('0x2b')]();};}function saveUpdates(_0x4409a1,_0x13c579){return function(_0x206ff7){if(_0x206ff7){return _0x206ff7[_0x615b('0x2c')](_0x4409a1)['then'](function(_0x3bd929){return _0x3bd929;});}return null;};}function removeEntity(_0x3ed6a6,_0x1cc174){return function(_0x137f56){if(_0x137f56){return _0x137f56[_0x615b('0x2d')]()[_0x615b('0x2e')](function(){var _0x1d3eb0=_0x137f56[_0x615b('0x2f')]({'plain':!![]});var _0x47b3d2=_0x615b('0x30');return db[_0x615b('0x31')][_0x615b('0x2d')]({'where':{'type':_0x47b3d2,'resourceId':_0x1d3eb0['id']}})[_0x615b('0x2e')](function(){return _0x137f56;});})[_0x615b('0x2e')](function(){_0x3ed6a6['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3aa2e7,_0x2b543f){return function(_0xb2121e){if(!_0xb2121e){_0x3aa2e7[_0x615b('0x22')](0x194);}return _0xb2121e;};}function handleError(_0x297b05,_0x201265){_0x201265=_0x201265||0x1f4;return function(_0x23e02c){logger[_0x615b('0x32')](_0x23e02c[_0x615b('0x33')]);if(_0x23e02c[_0x615b('0x34')]){delete _0x23e02c['name'];}_0x297b05[_0x615b('0x23')](_0x201265)['send'](_0x23e02c);};}exports['index']=function(_0x53304f,_0x52a9a6){var _0x4d578d={},_0x515902={},_0x351e9a={'count':0x0,'rows':[]};var _0x3206b9=_['map'](db[_0x615b('0x35')][_0x615b('0x36')],function(_0xafd937){return{'name':_0xafd937[_0x615b('0x37')],'type':_0xafd937[_0x615b('0x38')]['key']};});_0x515902[_0x615b('0x39')]=_['map'](_0x3206b9,_0x615b('0x34'));_0x515902[_0x615b('0x3a')]=_[_0x615b('0x3b')](_0x53304f['query']);_0x515902[_0x615b('0x3c')]=_['intersection'](_0x515902[_0x615b('0x39')],_0x515902[_0x615b('0x3a')]);_0x4d578d[_0x615b('0x3d')]=_['intersection'](_0x515902['model'],qs['fields'](_0x53304f[_0x615b('0x3a')][_0x615b('0x3e')]));_0x4d578d['attributes']=_0x4d578d['attributes'][_0x615b('0x3f')]?_0x4d578d['attributes']:_0x515902[_0x615b('0x39')];if(!_0x53304f[_0x615b('0x3a')]['hasOwnProperty'](_0x615b('0x40'))){_0x4d578d['limit']=qs['limit'](_0x53304f[_0x615b('0x3a')]['limit']);_0x4d578d['offset']=qs[_0x615b('0x27')](_0x53304f[_0x615b('0x3a')]['offset']);}_0x4d578d[_0x615b('0x41')]=qs['sort'](_0x53304f['query']['sort']);_0x4d578d[_0x615b('0x42')]=qs[_0x615b('0x3c')](_[_0x615b('0x43')](_0x53304f[_0x615b('0x3a')],_0x515902[_0x615b('0x3c')]),_0x3206b9);if(_0x53304f[_0x615b('0x3a')][_0x615b('0x44')]){_0x4d578d['where']=_[_0x615b('0x45')](_0x4d578d[_0x615b('0x42')],{'$or':_['map'](_0x3206b9,function(_0x4ecb3f){if(_0x4ecb3f[_0x615b('0x38')]!=='VIRTUAL'){var _0x22369c={};_0x22369c[_0x4ecb3f[_0x615b('0x34')]]={'$like':'%'+_0x53304f[_0x615b('0x3a')][_0x615b('0x44')]+'%'};return _0x22369c;}})});}_0x4d578d=_[_0x615b('0x45')]({},_0x4d578d,_0x53304f[_0x615b('0x46')]);var _0x2b50cf={'where':_0x4d578d[_0x615b('0x42')]};return db['Plugin'][_0x615b('0x26')](_0x2b50cf)['then'](function(_0x432425){_0x351e9a[_0x615b('0x26')]=_0x432425;if(_0x53304f['query'][_0x615b('0x47')]){_0x4d578d['include']=[{'all':!![]}];}return db[_0x615b('0x35')][_0x615b('0x48')](_0x4d578d);})[_0x615b('0x2e')](function(_0x47e569){_0x351e9a['rows']=_0x47e569;return _0x351e9a;})['then'](respondWithFilteredResult(_0x52a9a6,_0x4d578d))[_0x615b('0x49')](handleError(_0x52a9a6,null));};exports[_0x615b('0x4a')]=function(_0x18f915,_0x404501){var _0x2037c8={'raw':!![],'where':{'id':_0x18f915[_0x615b('0x4b')]['id']}},_0x33b428={};_0x33b428[_0x615b('0x39')]=_['keys'](db[_0x615b('0x35')][_0x615b('0x36')]);_0x33b428[_0x615b('0x3a')]=_[_0x615b('0x3b')](_0x18f915['query']);_0x33b428[_0x615b('0x3c')]=_[_0x615b('0x4c')](_0x33b428[_0x615b('0x39')],_0x33b428[_0x615b('0x3a')]);_0x2037c8['attributes']=_[_0x615b('0x4c')](_0x33b428[_0x615b('0x39')],qs['fields'](_0x18f915[_0x615b('0x3a')][_0x615b('0x3e')]));_0x2037c8['attributes']=_0x2037c8[_0x615b('0x3d')][_0x615b('0x3f')]?_0x2037c8[_0x615b('0x3d')]:_0x33b428['model'];if(_0x18f915[_0x615b('0x3a')][_0x615b('0x47')]){_0x2037c8[_0x615b('0x4d')]=[{'all':!![]}];}_0x2037c8=_['merge']({},_0x2037c8,_0x18f915[_0x615b('0x46')]);return db[_0x615b('0x35')][_0x615b('0x4e')](_0x2037c8)[_0x615b('0x2e')](handleEntityNotFound(_0x404501,null))[_0x615b('0x2e')](respondWithResult(_0x404501,null))['catch'](handleError(_0x404501,null));};exports[_0x615b('0x4f')]=function(_0x34fd3d,_0x10b89b,_0x3ab642){return db[_0x615b('0x35')][_0x615b('0x4e')]({'where':{'id':_0x34fd3d[_0x615b('0x4b')]['id']},'attributes':['name',_0x615b('0xa')],'raw':!![]})[_0x615b('0x2e')](handleEntityNotFound(_0x10b89b,null))['then'](function(_0x3a4bbd){if(_0x3a4bbd){var _0x46d4c0=path[_0x615b('0x50')](config[_0x615b('0x51')],_0x615b('0x52'),util[_0x615b('0x53')](_0x615b('0x54'),path[_0x615b('0x55')](_0x3a4bbd[_0x615b('0xa')])));var _0x16f9f7=fs['createWriteStream'](_0x46d4c0);var _0x5e1c11=archiver(_0x615b('0x56'),{'zlib':{'level':0x9}});_0x5e1c11['on'](_0x615b('0x57'),function(_0x575cc7){if(_0x575cc7[_0x615b('0x58')]===_0x615b('0x59')){logger[_0x615b('0x32')](_0x575cc7);}else{throw new db[(_0x615b('0x5a'))][(_0x615b('0x5b'))](_0x615b('0x5c'));}});_0x5e1c11['on'](_0x615b('0x32'),function(_0x559c8c){throw new db['Sequelize'][(_0x615b('0x5b'))](_0x615b('0x5c'));});_0x5e1c11[_0x615b('0x5d')](_0x16f9f7);_0x5e1c11['glob'](_0x615b('0x5e'),{'cwd':path[_0x615b('0x50')](config['root'],_0x615b('0x52'),path['dirname'](_0x3a4bbd['path'])),'ignore':[path[_0x615b('0x50')](path[_0x615b('0x55')](_0x3a4bbd[_0x615b('0xa')]),_0x615b('0x5f')),path[_0x615b('0x50')](path[_0x615b('0x55')](_0x3a4bbd[_0x615b('0xa')]),_0x615b('0x60'))],'nodir':!![]})[_0x615b('0x61')]();_0x16f9f7['on'](_0x615b('0x62'),function(){if(!fs[_0x615b('0x63')](_0x46d4c0)){throw new db[(_0x615b('0x5a'))]['Error'](_0x615b('0x64'));}return _0x10b89b['download'](_0x46d4c0,util[_0x615b('0x53')](_0x615b('0x54'),path[_0x615b('0x55')](_0x3a4bbd[_0x615b('0xa')])),function(_0x3be202){if(_0x3be202){throw new db[(_0x615b('0x5a'))][(_0x615b('0x5b'))]('Error\x20while\x20downloading\x20the\x20plugin');}fs[_0x615b('0x65')](_0x46d4c0);logger[_0x615b('0x66')](_0x615b('0x67'));logger['info'](_0x615b('0x68'));});});}return null;})[_0x615b('0x49')](handleError(_0x10b89b,null));};exports['upload']=function(_0x1d3b0f,_0x508ce0,_0x43c92e){var _0x818366=path[_0x615b('0x55')](_0x1d3b0f[_0x615b('0x69')][_0x615b('0x6a')],path['extname'](_0x1d3b0f[_0x615b('0x69')][_0x615b('0x6a')]));var _0x7ae347=path[_0x615b('0x50')](config[_0x615b('0x51')],_0x615b('0x52'),_0x1d3b0f[_0x615b('0x69')][_0x615b('0x6a')]);var _0x34e1a7=path[_0x615b('0x50')](config[_0x615b('0x51')],_0x615b('0x52'),_0x818366);logger[_0x615b('0x66')](_0x615b('0x6b'),_0x7ae347);logger[_0x615b('0x66')](_0x615b('0x6c'),_0x34e1a7);try{fs['chmodSync'](_0x7ae347,parseInt(_0x615b('0x6d'),0x8));extract(_0x7ae347,{'dir':_0x34e1a7},function(_0x1c08a8){if(_0x1c08a8){logger[_0x615b('0x32')](_0x1c08a8);handleError(_0x1c08a8,!![]);};var _0x38ddf5=fs[_0x615b('0x6e')](_0x34e1a7);if(_0x38ddf5['length']>0x1){removeReferences(_0x7ae347,_0x34e1a7);logger[_0x615b('0x32')](_0x615b('0x6f'));return _0x43c92e(new Error(_0x615b('0x6f')));}var _0x4b5d69=fs['lstatSync'](path['join'](_0x34e1a7,_0x38ddf5[0x0]));if(_0x4b5d69[_0x615b('0x70')]()){removeReferences(_0x7ae347,_0x34e1a7);logger[_0x615b('0x32')]('Invalid\x20plugin\x20structure');return _0x43c92e(new Error(_0x615b('0x6f')));}if(_0x4b5d69['isDirectory']()){var _0x21ebd8=fs[_0x615b('0x6e')](path[_0x615b('0x50')](_0x34e1a7,_0x38ddf5[0x0]));if(_0x21ebd8[_0x615b('0x3f')]===0x0){removeReferences(_0x7ae347,_0x34e1a7);logger['error']('Invalid\x20plugin\x20structure');return _0x43c92e(new Error('Invalid\x20plugin\x20structure'));}var _0x38a8a0=_0x21ebd8[_0x615b('0x71')](function(_0x5d4ba5){return _0x5d4ba5==='manifest.json';});if(!_0x38a8a0){return _0x43c92e(new Error(_0x615b('0x72')));}var _0x30e002=fs['readFileSync'](path['join'](_0x34e1a7,_0x38ddf5[0x0],_0x615b('0x73')));var _0x2cd853=JSON[_0x615b('0x74')](_0x30e002);if(_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x34')]){return _0x43c92e(new Error('Invalid\x20manifest:\x20name\x20missing'));}if(_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x38')]){return _0x43c92e(new Error(_0x615b('0x76')));}if(_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x77')]){return _0x43c92e(new Error('Invalid\x20manifest:\x20version\x20not\x20specified'));}if('undefined'==typeof _0x2cd853[_0x615b('0x78')]){return _0x43c92e(new Error(_0x615b('0x79')));}if(_0x2cd853['type']===_0x615b('0x7a')){if(_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x7b')]){return _0x43c92e(new Error(_0x615b('0x7c')));}if(_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x7b')][_0x615b('0x7d')]&&_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x78')]['views'][_0x615b('0x7e')]){return _0x43c92e(new Error(_0x615b('0x7f')));}}else if(_0x2cd853[_0x615b('0x38')]===_0x615b('0x80')){if('undefined'==typeof _0x2cd853[_0x615b('0x78')]['scriptName']){return _0x43c92e(new Error(_0x615b('0x81')));}if(_0x615b('0x75')==typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x82')]){return _0x43c92e(new Error('Invalid\x20manifest:\x20script\x20path\x20missing'));}}else{return _0x43c92e(new Error('Invalid\x20manifest:\x20invalid\x20type'));}var _0x4915a9=_0x2cd853[_0x615b('0x34')];var _0x27bb2c=_0x2cd853['description'];var _0x3d6426=_0x2cd853[_0x615b('0x38')];var _0x23ed0c=_0x2cd853['sidebar']?_0x2cd853[_0x615b('0x83')]:'always';var _0x1c8740=_0x2cd853[_0x615b('0x84')]?_0x2cd853[_0x615b('0x84')]:'icon-apps';var _0x1ea8a8='';var _0x81ce3='';var _0x48be2c='';var _0x5cbb46='';var _0x3620e2=_0x2cd853[_0x615b('0x77')];if(_0x3d6426===_0x615b('0x7a')){if(_0x615b('0x75')!=typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x7b')]['admin']){var _0x895867=_0x2cd853['parameters']['views'][_0x615b('0x7d')];if(!/^(f|ht)tps?:\/\//i[_0x615b('0x85')](_0x895867)){_0x1ea8a8=path[_0x615b('0x50')](_0x615b('0x86'),_0x818366,_0x38ddf5[0x0],_0x895867);}else{_0x1ea8a8=_0x895867;}}else{logger[_0x615b('0x66')]('Warning:\x20admin\x20view\x20not\x20specified');}if(_0x615b('0x75')!=typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x7b')][_0x615b('0x7e')]){var _0xf9a1b5=_0x2cd853[_0x615b('0x78')]['views'][_0x615b('0x7e')];if(!/^(f|ht)tps?:\/\//i[_0x615b('0x85')](_0xf9a1b5)){_0x81ce3=path[_0x615b('0x50')](_0x615b('0x86'),_0x818366,_0x38ddf5[0x0],_0xf9a1b5);}else{_0x81ce3=_0xf9a1b5;}}else{logger[_0x615b('0x66')](_0x615b('0x87'));}}else if(_0x3d6426===_0x615b('0x80')){_0x48be2c=_0x2cd853[_0x615b('0x78')][_0x615b('0x88')];_0x5cbb46=_0x2cd853[_0x615b('0x78')][_0x615b('0x82')];if(_0x615b('0x75')!=typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x7b')]){if(_0x615b('0x75')!=typeof _0x2cd853['parameters']['views'][_0x615b('0x7d')]){var _0x895867=_0x2cd853[_0x615b('0x78')][_0x615b('0x7b')][_0x615b('0x7d')];if(!/^(f|ht)tps?:\/\//i[_0x615b('0x85')](_0x895867)){_0x1ea8a8=path[_0x615b('0x50')](_0x615b('0x86'),_0x818366,_0x38ddf5[0x0],_0x895867);}else{_0x1ea8a8=_0x895867;}}if(_0x615b('0x75')!=typeof _0x2cd853[_0x615b('0x78')][_0x615b('0x7b')][_0x615b('0x7e')]){var _0xf9a1b5=_0x2cd853[_0x615b('0x78')]['views']['agent'];if(!/^(f|ht)tps?:\/\//i['test'](_0xf9a1b5)){_0x81ce3=path[_0x615b('0x50')](_0x615b('0x86'),_0x818366,_0x38ddf5[0x0],_0xf9a1b5);}else{_0x81ce3=_0xf9a1b5;}}}}var _0x575484={'name':_0x4915a9,'description':_0x27bb2c,'path':path[_0x615b('0x50')](_0x818366,_0x38ddf5[0x0]),'type':_0x3d6426,'sidebar':_0x23ed0c,'icon':_0x1c8740,'adminUrl':_0x1ea8a8,'agentUrl':_0x81ce3,'scriptName':_0x48be2c,'scriptPath':_0x5cbb46,'version':_0x3620e2};removeReferences(_0x7ae347,null);return db['Plugin'][_0x615b('0x89')](_0x575484)[_0x615b('0x2e')](function(_0xad1b62){var _0x40bd03={'role':_0x1d3b0f[_0x615b('0x8a')]['role'],'userProfileId':_0x1d3b0f[_0x615b('0x8a')]['userProfileId']};if(!_0x40bd03)throw new Error(_0x615b('0x8b'));if(_0x40bd03[_0x615b('0x8c')]===_0x615b('0x8d')){var _0x23a788=_0xad1b62[_0x615b('0x2f')]({'plain':!![]});return db[_0x615b('0x8e')][_0x615b('0x4e')]({'where':{'name':_0x615b('0x30'),'userProfileId':_0x40bd03[_0x615b('0x8f')]},'raw':!![]})[_0x615b('0x2e')](function(_0x321c91){if(_0x321c91&&_0x321c91[_0x615b('0x90')]===0x0){return db[_0x615b('0x31')][_0x615b('0x89')]({'name':_0x23a788[_0x615b('0x34')],'resourceId':_0x23a788['id'],'type':_0x321c91[_0x615b('0x34')],'sectionId':_0x321c91['id']},{})[_0x615b('0x2e')](function(){return _0xad1b62;});}else{return _0xad1b62;}})[_0x615b('0x49')](function(_0x21ce5c){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x21ce5c);throw _0x21ce5c;});}return _0xad1b62;})[_0x615b('0x2e')](respondWithResult(_0x508ce0,null))[_0x615b('0x49')](handleError(_0x508ce0,null));}});}catch(_0x2971e3){_0x508ce0[_0x615b('0x23')](0x1f4)[_0x615b('0x91')](_0x2971e3);}};function removeReferences(_0x2893ac,_0x5b2691){try{if(_0x2893ac){fs[_0x615b('0x65')](_0x2893ac);logger['info'](_0x615b('0x92'));}if(_0x5b2691){rimraf(_0x5b2691,function(){});logger[_0x615b('0x66')]('Extracted\x20folder\x20removed');}}catch(_0x3cd59c){logger[_0x615b('0x32')](_0x3cd59c);}}exports[_0x615b('0x2c')]=function(_0x57cc07,_0x4c8cbf,_0x2e3cf7){return db[_0x615b('0x35')][_0x615b('0x4e')]({'where':{'id':_0x57cc07['params']['id']}})['then'](handleEntityNotFound(_0x4c8cbf,null))[_0x615b('0x2e')](saveUpdates(_0x57cc07[_0x615b('0x8a')],null))[_0x615b('0x2e')](respondWithResult(_0x4c8cbf,null))[_0x615b('0x49')](handleError(_0x4c8cbf,null));};exports[_0x615b('0x93')]=function(_0x36c788,_0x88c8b,_0x3c396b){return db[_0x615b('0x35')][_0x615b('0x4e')]({'where':{'id':_0x36c788[_0x615b('0x4b')]['id']}})['then'](function(_0x56f915){if(_0x56f915){return _0x56f915[_0x615b('0x2d')]();}})[_0x615b('0x2e')](function(_0x163e73){rimraf(path[_0x615b('0x50')](config[_0x615b('0x51')],'server/files/plugins',path[_0x615b('0x94')](_0x163e73[_0x615b('0xa')])),function(){});return _0x163e73;})[_0x615b('0x2e')](handleEntityNotFound(_0x88c8b,null))['then'](respondWithStatusCode(_0x88c8b,null))['catch'](handleError(_0x88c8b,null));};exports['webhookGet']=function(_0x4a885a,_0x23f559,_0x31e806){return BPromise[_0x615b('0x95')]()[_0x615b('0x2e')](function(){if(!_0x4a885a[_0x615b('0x3a')][_0x615b('0xa')]){throw new Error(_0x615b('0x96'));}if(!_0x4a885a[_0x615b('0x3a')]['port']){throw new Error('\x27PORT\x27\x20parameter\x20not\x20specified');}var _0x1edb04=_0x4a885a[_0x615b('0x3a')][_0x615b('0x97')]?_0x4a885a[_0x615b('0x3a')][_0x615b('0x97')]+':'+_0x4a885a[_0x615b('0x3a')][_0x615b('0x98')]:_0x615b('0x99')+_0x4a885a[_0x615b('0x3a')][_0x615b('0x98')];var _0x125760=_0x4a885a['query'][_0x615b('0x25')]?_0x4a885a[_0x615b('0x3a')][_0x615b('0x25')]:!![];var _0x346659=_0x4a885a[_0x615b('0x3a')][_0x615b('0x9a')]?_0x4a885a[_0x615b('0x3a')][_0x615b('0x9a')]:null;var _0x165169={'method':_0x4a885a[_0x615b('0x9b')],'uri':util['format'](_0x615b('0x9c'),_0x1edb04,_0x4a885a[_0x615b('0x3a')][_0x615b('0xa')]),'json':_0x125760,'resolveWithFullResponse':!![],'encoding':_0x346659,'qs':_0x4a885a[_0x615b('0x3a')]};if(_0x4a885a[_0x615b('0x9d')]){_0x165169[_0x615b('0x9d')]=_0x4a885a[_0x615b('0x9d')];if(_0x165169[_0x615b('0x9d')][_0x615b('0x9e')]){delete _0x165169[_0x615b('0x9d')]['content-length'];}}if(_0x165169[_0x615b('0x9d')]['content-type']){delete _0x165169[_0x615b('0x9d')][_0x615b('0x9f')];}return rp(_0x165169);})[_0x615b('0x2e')](function(_0x2df5ec){if(_0x2df5ec){_0x23f559[_0x615b('0x28')](_0x2df5ec[_0x615b('0x9d')]);logger[_0x615b('0x66')](_0x2df5ec[_0x615b('0x8a')]);if(_[_0x615b('0xa0')](_0x4a885a[_0x615b('0x3a')][_0x615b('0xa')],_0x615b('0x4f'))&&_0x2df5ec['statusCode']==0x1f4){return _0x23f559[_0x615b('0x22')](_0x2df5ec['statusCode']);}else{return _0x23f559[_0x615b('0x23')](_0x2df5ec[_0x615b('0xa1')])[_0x615b('0x91')](_0x2df5ec[_0x615b('0x8a')]);}}else{return _0x23f559['sendStatus'](0xc8);}})[_0x615b('0x49')](handleError(_0x23f559,null));};exports[_0x615b('0xa2')]=function(_0x59e8ec,_0x23b4c4,_0xb37620){return BPromise['resolve']()[_0x615b('0x2e')](function(){if(!_0x59e8ec[_0x615b('0x3a')][_0x615b('0xa')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x59e8ec[_0x615b('0x3a')][_0x615b('0x98')]){throw new Error(_0x615b('0xa3'));}var _0xf4ba9f=_0x59e8ec['query'][_0x615b('0x97')]?_0x59e8ec[_0x615b('0x3a')][_0x615b('0x97')]+':'+_0x59e8ec[_0x615b('0x3a')][_0x615b('0x98')]:'http://localhost:'+_0x59e8ec[_0x615b('0x3a')][_0x615b('0x98')];var _0x55d4f2=_0x59e8ec[_0x615b('0x3a')][_0x615b('0x25')]?_0x59e8ec[_0x615b('0x3a')][_0x615b('0x25')]:!![];var _0x1f5987=_0x59e8ec[_0x615b('0x3a')][_0x615b('0x9a')]?_0x59e8ec['query'][_0x615b('0x9a')]:null;var _0x153f7c={'method':_0x59e8ec[_0x615b('0x9b')],'uri':util['format'](_0x615b('0x9c'),_0xf4ba9f,_0x59e8ec[_0x615b('0x3a')][_0x615b('0xa')]),'json':_0x55d4f2,'resolveWithFullResponse':!![],'encoding':_0x1f5987,'body':_0x59e8ec[_0x615b('0x8a')]};if(_0x59e8ec[_0x615b('0x9d')]){_0x153f7c[_0x615b('0x9d')]=_0x59e8ec[_0x615b('0x9d')];if(_0x153f7c['headers'][_0x615b('0x9e')]){delete _0x153f7c[_0x615b('0x9d')][_0x615b('0x9e')];}}if(_0x153f7c[_0x615b('0x9d')][_0x615b('0x9f')]){delete _0x153f7c[_0x615b('0x9d')][_0x615b('0x9f')];}return rp(_0x153f7c);})['then'](function(_0x38884b){if(_0x38884b){_0x23b4c4[_0x615b('0x28')](_0x38884b['headers']);logger[_0x615b('0x66')](_0x38884b['body']);return _0x23b4c4[_0x615b('0x23')](_0x38884b[_0x615b('0xa1')])[_0x615b('0x91')](_0x38884b[_0x615b('0x8a')]);}else{return _0x23b4c4[_0x615b('0x22')](0xc8);}})[_0x615b('0x49')](handleError(_0x23b4c4,null));};
\ No newline at end of file
+var _0x6c9b=['Sequelize','Error','Error\x20while\x20generating\x20the\x20zip\x20archive','pipe','glob','**/*','dirname','basename','attachments/**/*','close','existsSync','info','Download\x20completed','Temporary\x20file\x20removed','upload','file','extname','filename','Plugin\x20upload\x20filepath:\x20%s','Plugin\x20upload\x20destination:\x20%s','0777','readdirSync','Invalid\x20plugin\x20structure','lstatSync','isFile','isDirectory','some','manifest.json','Plugin\x20manifest\x20missing','readFileSync','parse','undefined','Invalid\x20manifest:\x20type\x20missing','version','Invalid\x20manifest:\x20version\x20not\x20specified','parameters','Invalid\x20manifest:\x20parameters\x20missing','html','views','Invalid\x20manifest:\x20views\x20missing','admin','agent','Invalid\x20manifest:\x20no\x20view\x20specified','script','scriptName','scriptPath','Invalid\x20manifest:\x20script\x20path\x20missing','description','sidebar','always','icon','icon-apps','test','plugins','body','userProfileId','role','autoAssociation','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','unlinkSync','Zip\x20archive\x20removed','delete','resolve','\x27PATH\x27\x20parameter\x20not\x20specified','port','\x27PORT\x27\x20parameter\x20not\x20specified','hostname','encoding','headers','content-length','content-type','endsWith','statusCode','send','webhookPost','http://localhost:','method','%s%s','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','extract-zip','archiver','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./plugin.socket','register','sendStatus','end','status','json','offset','limit','set','Content-Range','save','update','then','destroy','get','Plugins','UserProfileResource','error','stack','name','map','Plugin','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','filter','options','count','includeAll','include','findAll','rows','catch','params','fields','find','download','path','join','root','server/files/plugins','format','%s.zip','zip','warning','code','ENOENT'];(function(_0x95d9b3,_0x39990d){var _0x7cc98=function(_0x54fc98){while(--_0x54fc98){_0x95d9b3['push'](_0x95d9b3['shift']());}};_0x7cc98(++_0x39990d);}(_0x6c9b,0x19d));var _0xb6c9=function(_0xfc2bbe,_0x1ae76c){_0xfc2bbe=_0xfc2bbe-0x0;var _0x5435c4=_0x6c9b[_0xfc2bbe];return _0x5435c4;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xb6c9('0x0'));var rimraf=require(_0xb6c9('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xb6c9('0x2'));var moment=require(_0xb6c9('0x3'));var BPromise=require(_0xb6c9('0x4'));var Mustache=require(_0xb6c9('0x5'));var util=require(_0xb6c9('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0xb6c9('0x7'));var ejs=require(_0xb6c9('0x8'));var fs=require('fs');var _=require(_0xb6c9('0x9'));var squel=require('squel');var crypto=require(_0xb6c9('0xa'));var jsforce=require(_0xb6c9('0xb'));var deskjs=require(_0xb6c9('0xc'));var toCsv=require(_0xb6c9('0x7'));var querystring=require(_0xb6c9('0xd'));var Papa=require('papaparse');var extract=require(_0xb6c9('0xe'));var rimraf=require(_0xb6c9('0x1'));var archiver=require(_0xb6c9('0xf'));var Redis=require(_0xb6c9('0x10'));var authService=require(_0xb6c9('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xb6c9('0x12'))(_0xb6c9('0x13'));var utils=require(_0xb6c9('0x14'));var config=require(_0xb6c9('0x15'));var db=require(_0xb6c9('0x16'))['db'];config[_0xb6c9('0x17')]=_[_0xb6c9('0x18')](config[_0xb6c9('0x17')],{'host':_0xb6c9('0x19'),'port':0x18eb});var socket=require(_0xb6c9('0x1a'))(new Redis(config[_0xb6c9('0x17')]));require(_0xb6c9('0x1b'))[_0xb6c9('0x1c')](socket);function respondWithStatusCode(_0x3867d4,_0x384fec){_0x384fec=_0x384fec||0xcc;return function(_0xe27b49){if(_0xe27b49){return _0x3867d4[_0xb6c9('0x1d')](_0x384fec);}return _0x3867d4['status'](_0x384fec)[_0xb6c9('0x1e')]();};}function respondWithResult(_0x4c4c1c,_0x26029b){_0x26029b=_0x26029b||0xc8;return function(_0x42fc41){if(_0x42fc41){return _0x4c4c1c[_0xb6c9('0x1f')](_0x26029b)[_0xb6c9('0x20')](_0x42fc41);}};}function respondWithFilteredResult(_0x28b9bc,_0x185758){return function(_0x34827e){if(_0x34827e){var _0xd10de0=_0x34827e['count'],_0x1788aa=_0x185758[_0xb6c9('0x21')],_0x18668d=_0x185758['offset']+_0x185758[_0xb6c9('0x22')],_0x4c2af2;if(_0x18668d>=_0xd10de0){_0x18668d=_0xd10de0;_0x4c2af2=0xc8;}else{_0x4c2af2=0xce;}_0x28b9bc[_0xb6c9('0x1f')](_0x4c2af2);return _0x28b9bc[_0xb6c9('0x23')](_0xb6c9('0x24'),_0x1788aa+'-'+_0x18668d+'/'+_0xd10de0)[_0xb6c9('0x20')](_0x34827e);}return null;};}function patchUpdates(_0x5ce739){return function(_0x5122af){try{jsonpatch['apply'](_0x5122af,_0x5ce739,!![]);}catch(_0x1d1b92){return BPromise['reject'](_0x1d1b92);}return _0x5122af[_0xb6c9('0x25')]();};}function saveUpdates(_0x50c7c5,_0x3e14de){return function(_0x461d1a){if(_0x461d1a){return _0x461d1a[_0xb6c9('0x26')](_0x50c7c5)[_0xb6c9('0x27')](function(_0x20a587){return _0x20a587;});}return null;};}function removeEntity(_0x19ea9c,_0x52d4e7){return function(_0x1f83bf){if(_0x1f83bf){return _0x1f83bf[_0xb6c9('0x28')]()[_0xb6c9('0x27')](function(){var _0x4f5d83=_0x1f83bf[_0xb6c9('0x29')]({'plain':!![]});var _0x470e02=_0xb6c9('0x2a');return db[_0xb6c9('0x2b')][_0xb6c9('0x28')]({'where':{'type':_0x470e02,'resourceId':_0x4f5d83['id']}})[_0xb6c9('0x27')](function(){return _0x1f83bf;});})[_0xb6c9('0x27')](function(){_0x19ea9c[_0xb6c9('0x1f')](0xcc)[_0xb6c9('0x1e')]();});}};}function handleEntityNotFound(_0x2b9ed3,_0x199a37){return function(_0x54ea68){if(!_0x54ea68){_0x2b9ed3[_0xb6c9('0x1d')](0x194);}return _0x54ea68;};}function handleError(_0x5be92e,_0x47058c){_0x47058c=_0x47058c||0x1f4;return function(_0x17d270){logger[_0xb6c9('0x2c')](_0x17d270[_0xb6c9('0x2d')]);if(_0x17d270[_0xb6c9('0x2e')]){delete _0x17d270[_0xb6c9('0x2e')];}_0x5be92e[_0xb6c9('0x1f')](_0x47058c)['send'](_0x17d270);};}exports['index']=function(_0x1bc91b,_0x3bd432){var _0x46e95c={},_0x2404c2={},_0x568eb6={'count':0x0,'rows':[]};var _0x34dacb=_[_0xb6c9('0x2f')](db[_0xb6c9('0x30')][_0xb6c9('0x31')],function(_0x1ecdcc){return{'name':_0x1ecdcc[_0xb6c9('0x32')],'type':_0x1ecdcc[_0xb6c9('0x33')]['key']};});_0x2404c2[_0xb6c9('0x34')]=_['map'](_0x34dacb,_0xb6c9('0x2e'));_0x2404c2[_0xb6c9('0x35')]=_[_0xb6c9('0x36')](_0x1bc91b[_0xb6c9('0x35')]);_0x2404c2[_0xb6c9('0x37')]=_[_0xb6c9('0x38')](_0x2404c2[_0xb6c9('0x34')],_0x2404c2[_0xb6c9('0x35')]);_0x46e95c[_0xb6c9('0x39')]=_[_0xb6c9('0x38')](_0x2404c2[_0xb6c9('0x34')],qs['fields'](_0x1bc91b[_0xb6c9('0x35')]['fields']));_0x46e95c[_0xb6c9('0x39')]=_0x46e95c['attributes'][_0xb6c9('0x3a')]?_0x46e95c[_0xb6c9('0x39')]:_0x2404c2['model'];if(!_0x1bc91b[_0xb6c9('0x35')][_0xb6c9('0x3b')](_0xb6c9('0x3c'))){_0x46e95c[_0xb6c9('0x22')]=qs[_0xb6c9('0x22')](_0x1bc91b[_0xb6c9('0x35')][_0xb6c9('0x22')]);_0x46e95c[_0xb6c9('0x21')]=qs[_0xb6c9('0x21')](_0x1bc91b[_0xb6c9('0x35')][_0xb6c9('0x21')]);}_0x46e95c[_0xb6c9('0x3d')]=qs[_0xb6c9('0x3e')](_0x1bc91b['query']['sort']);_0x46e95c[_0xb6c9('0x3f')]=qs[_0xb6c9('0x37')](_[_0xb6c9('0x40')](_0x1bc91b['query'],_0x2404c2[_0xb6c9('0x37')]),_0x34dacb);if(_0x1bc91b['query']['filter']){_0x46e95c[_0xb6c9('0x3f')]=_[_0xb6c9('0x41')](_0x46e95c[_0xb6c9('0x3f')],{'$or':_[_0xb6c9('0x2f')](_0x34dacb,function(_0x1a125c){if(_0x1a125c[_0xb6c9('0x33')]!=='VIRTUAL'){var _0x46db10={};_0x46db10[_0x1a125c['name']]={'$like':'%'+_0x1bc91b[_0xb6c9('0x35')][_0xb6c9('0x42')]+'%'};return _0x46db10;}})});}_0x46e95c=_[_0xb6c9('0x41')]({},_0x46e95c,_0x1bc91b[_0xb6c9('0x43')]);var _0x5a66a6={'where':_0x46e95c[_0xb6c9('0x3f')]};return db['Plugin'][_0xb6c9('0x44')](_0x5a66a6)[_0xb6c9('0x27')](function(_0xa98f0b){_0x568eb6[_0xb6c9('0x44')]=_0xa98f0b;if(_0x1bc91b['query'][_0xb6c9('0x45')]){_0x46e95c[_0xb6c9('0x46')]=[{'all':!![]}];}return db['Plugin'][_0xb6c9('0x47')](_0x46e95c);})[_0xb6c9('0x27')](function(_0x448a0c){_0x568eb6[_0xb6c9('0x48')]=_0x448a0c;return _0x568eb6;})[_0xb6c9('0x27')](respondWithFilteredResult(_0x3bd432,_0x46e95c))[_0xb6c9('0x49')](handleError(_0x3bd432,null));};exports['show']=function(_0x329500,_0x56aa82){var _0x56e6d1={'raw':!![],'where':{'id':_0x329500[_0xb6c9('0x4a')]['id']}},_0x1c4fdb={};_0x1c4fdb[_0xb6c9('0x34')]=_[_0xb6c9('0x36')](db[_0xb6c9('0x30')][_0xb6c9('0x31')]);_0x1c4fdb[_0xb6c9('0x35')]=_[_0xb6c9('0x36')](_0x329500[_0xb6c9('0x35')]);_0x1c4fdb[_0xb6c9('0x37')]=_[_0xb6c9('0x38')](_0x1c4fdb['model'],_0x1c4fdb[_0xb6c9('0x35')]);_0x56e6d1[_0xb6c9('0x39')]=_['intersection'](_0x1c4fdb['model'],qs[_0xb6c9('0x4b')](_0x329500[_0xb6c9('0x35')][_0xb6c9('0x4b')]));_0x56e6d1[_0xb6c9('0x39')]=_0x56e6d1[_0xb6c9('0x39')]['length']?_0x56e6d1[_0xb6c9('0x39')]:_0x1c4fdb['model'];if(_0x329500[_0xb6c9('0x35')][_0xb6c9('0x45')]){_0x56e6d1[_0xb6c9('0x46')]=[{'all':!![]}];}_0x56e6d1=_[_0xb6c9('0x41')]({},_0x56e6d1,_0x329500[_0xb6c9('0x43')]);return db[_0xb6c9('0x30')][_0xb6c9('0x4c')](_0x56e6d1)[_0xb6c9('0x27')](handleEntityNotFound(_0x56aa82,null))[_0xb6c9('0x27')](respondWithResult(_0x56aa82,null))[_0xb6c9('0x49')](handleError(_0x56aa82,null));};exports[_0xb6c9('0x4d')]=function(_0x348cc0,_0xc1c082,_0x3ffa97){return db['Plugin']['find']({'where':{'id':_0x348cc0[_0xb6c9('0x4a')]['id']},'attributes':[_0xb6c9('0x2e'),_0xb6c9('0x4e')],'raw':!![]})[_0xb6c9('0x27')](handleEntityNotFound(_0xc1c082,null))[_0xb6c9('0x27')](function(_0x55a77f){if(_0x55a77f){var _0x5a0707=path[_0xb6c9('0x4f')](config[_0xb6c9('0x50')],_0xb6c9('0x51'),util[_0xb6c9('0x52')](_0xb6c9('0x53'),path['basename'](_0x55a77f[_0xb6c9('0x4e')])));var _0x2dad06=fs['createWriteStream'](_0x5a0707);var _0x54526b=archiver(_0xb6c9('0x54'),{'zlib':{'level':0x9}});_0x54526b['on'](_0xb6c9('0x55'),function(_0x1ec4aa){if(_0x1ec4aa[_0xb6c9('0x56')]===_0xb6c9('0x57')){logger['error'](_0x1ec4aa);}else{throw new db[(_0xb6c9('0x58'))][(_0xb6c9('0x59'))](_0xb6c9('0x5a'));}});_0x54526b['on'](_0xb6c9('0x2c'),function(_0x424162){throw new db['Sequelize'][(_0xb6c9('0x59'))](_0xb6c9('0x5a'));});_0x54526b[_0xb6c9('0x5b')](_0x2dad06);_0x54526b[_0xb6c9('0x5c')](_0xb6c9('0x5d'),{'cwd':path['join'](config[_0xb6c9('0x50')],_0xb6c9('0x51'),path[_0xb6c9('0x5e')](_0x55a77f[_0xb6c9('0x4e')])),'ignore':[path[_0xb6c9('0x4f')](path[_0xb6c9('0x5f')](_0x55a77f[_0xb6c9('0x4e')]),'node_modules/**/*'),path[_0xb6c9('0x4f')](path['basename'](_0x55a77f[_0xb6c9('0x4e')]),_0xb6c9('0x60'))],'nodir':!![]})['finalize']();_0x2dad06['on'](_0xb6c9('0x61'),function(){if(!fs[_0xb6c9('0x62')](_0x5a0707)){throw new db[(_0xb6c9('0x58'))][(_0xb6c9('0x59'))]('Plugin\x20not\x20found');}return _0xc1c082[_0xb6c9('0x4d')](_0x5a0707,util['format']('%s.zip',path['basename'](_0x55a77f['path'])),function(_0x2b211c){if(_0x2b211c){throw new db[(_0xb6c9('0x58'))]['Error']('Error\x20while\x20downloading\x20the\x20plugin');}fs['unlinkSync'](_0x5a0707);logger[_0xb6c9('0x63')](_0xb6c9('0x64'));logger[_0xb6c9('0x63')](_0xb6c9('0x65'));});});}return null;})['catch'](handleError(_0xc1c082,null));};exports[_0xb6c9('0x66')]=function(_0x51aaf1,_0x24c937,_0x4745d8){var _0x2eabee=path[_0xb6c9('0x5f')](_0x51aaf1[_0xb6c9('0x67')]['filename'],path[_0xb6c9('0x68')](_0x51aaf1[_0xb6c9('0x67')][_0xb6c9('0x69')]));var _0x2c6e04=path[_0xb6c9('0x4f')](config[_0xb6c9('0x50')],_0xb6c9('0x51'),_0x51aaf1['file'][_0xb6c9('0x69')]);var _0x451141=path[_0xb6c9('0x4f')](config['root'],_0xb6c9('0x51'),_0x2eabee);logger['info'](_0xb6c9('0x6a'),_0x2c6e04);logger[_0xb6c9('0x63')](_0xb6c9('0x6b'),_0x451141);try{fs['chmodSync'](_0x2c6e04,parseInt(_0xb6c9('0x6c'),0x8));extract(_0x2c6e04,{'dir':_0x451141},function(_0x188e2b){if(_0x188e2b){logger[_0xb6c9('0x2c')](_0x188e2b);handleError(_0x188e2b,!![]);};var _0x3399e4=fs[_0xb6c9('0x6d')](_0x451141);if(_0x3399e4[_0xb6c9('0x3a')]>0x1){removeReferences(_0x2c6e04,_0x451141);logger[_0xb6c9('0x2c')](_0xb6c9('0x6e'));return _0x4745d8(new Error(_0xb6c9('0x6e')));}var _0x275e7e=fs[_0xb6c9('0x6f')](path[_0xb6c9('0x4f')](_0x451141,_0x3399e4[0x0]));if(_0x275e7e[_0xb6c9('0x70')]()){removeReferences(_0x2c6e04,_0x451141);logger[_0xb6c9('0x2c')](_0xb6c9('0x6e'));return _0x4745d8(new Error('Invalid\x20plugin\x20structure'));}if(_0x275e7e[_0xb6c9('0x71')]()){var _0x516a0c=fs[_0xb6c9('0x6d')](path[_0xb6c9('0x4f')](_0x451141,_0x3399e4[0x0]));if(_0x516a0c[_0xb6c9('0x3a')]===0x0){removeReferences(_0x2c6e04,_0x451141);logger[_0xb6c9('0x2c')](_0xb6c9('0x6e'));return _0x4745d8(new Error('Invalid\x20plugin\x20structure'));}var _0x1fe008=_0x516a0c[_0xb6c9('0x72')](function(_0x155dc0){return _0x155dc0===_0xb6c9('0x73');});if(!_0x1fe008){return _0x4745d8(new Error(_0xb6c9('0x74')));}var _0x126a96=fs[_0xb6c9('0x75')](path['join'](_0x451141,_0x3399e4[0x0],'manifest.json'));var _0x181d95=JSON[_0xb6c9('0x76')](_0x126a96);if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x2e')]){return _0x4745d8(new Error('Invalid\x20manifest:\x20name\x20missing'));}if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x33')]){return _0x4745d8(new Error(_0xb6c9('0x78')));}if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x79')]){return _0x4745d8(new Error(_0xb6c9('0x7a')));}if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x7b')]){return _0x4745d8(new Error(_0xb6c9('0x7c')));}if(_0x181d95[_0xb6c9('0x33')]===_0xb6c9('0x7d')){if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x7b')][_0xb6c9('0x7e')]){return _0x4745d8(new Error(_0xb6c9('0x7f')));}if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x7b')]['views'][_0xb6c9('0x80')]&&_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x7b')]['views'][_0xb6c9('0x81')]){return _0x4745d8(new Error(_0xb6c9('0x82')));}}else if(_0x181d95[_0xb6c9('0x33')]===_0xb6c9('0x83')){if('undefined'==typeof _0x181d95[_0xb6c9('0x7b')][_0xb6c9('0x84')]){return _0x4745d8(new Error('Invalid\x20manifest:\x20script\x20name\x20missing'));}if(_0xb6c9('0x77')==typeof _0x181d95[_0xb6c9('0x7b')][_0xb6c9('0x85')]){return _0x4745d8(new Error(_0xb6c9('0x86')));}}else{return _0x4745d8(new Error('Invalid\x20manifest:\x20invalid\x20type'));}var _0x1e323e=_0x181d95[_0xb6c9('0x2e')];var _0x47cd02=_0x181d95[_0xb6c9('0x87')];var _0x3d011a=_0x181d95[_0xb6c9('0x33')];var _0x2376c5=_0x181d95[_0xb6c9('0x88')]?_0x181d95[_0xb6c9('0x88')]:_0xb6c9('0x89');var _0x377fb6=_0x181d95[_0xb6c9('0x8a')]?_0x181d95[_0xb6c9('0x8a')]:_0xb6c9('0x8b');var _0x2d1779='';var _0x1175fe='';var _0x11fc6d='';var _0x392e74='';var _0x581184=_0x181d95[_0xb6c9('0x79')];if(_0x3d011a==='html'){if('undefined'!=typeof _0x181d95[_0xb6c9('0x7b')]['views'][_0xb6c9('0x80')]){var _0x48901e=_0x181d95[_0xb6c9('0x7b')]['views'][_0xb6c9('0x80')];if(!/^(f|ht)tps?:\/\//i[_0xb6c9('0x8c')](_0x48901e)){_0x2d1779=path['join'](_0xb6c9('0x8d'),_0x2eabee,_0x3399e4[0x0],_0x48901e);}else{_0x2d1779=_0x48901e;}}else{logger[_0xb6c9('0x63')]('Warning:\x20admin\x20view\x20not\x20specified');}if(_0xb6c9('0x77')!=typeof _0x181d95[_0xb6c9('0x7b')][_0xb6c9('0x7e')]['agent']){var _0x1fc44b=_0x181d95[_0xb6c9('0x7b')]['views'][_0xb6c9('0x81')];if(!/^(f|ht)tps?:\/\//i[_0xb6c9('0x8c')](_0x1fc44b)){_0x1175fe=path['join'](_0xb6c9('0x8d'),_0x2eabee,_0x3399e4[0x0],_0x1fc44b);}else{_0x1175fe=_0x1fc44b;}}else{logger[_0xb6c9('0x63')]('Warning:\x20agent\x20view\x20not\x20specified');}}else if(_0x3d011a===_0xb6c9('0x83')){_0x11fc6d=_0x181d95[_0xb6c9('0x7b')][_0xb6c9('0x84')];_0x392e74=_0x181d95[_0xb6c9('0x7b')][_0xb6c9('0x85')];if(_0xb6c9('0x77')!=typeof _0x181d95[_0xb6c9('0x7b')]['views']){if(_0xb6c9('0x77')!=typeof _0x181d95[_0xb6c9('0x7b')]['views'][_0xb6c9('0x80')]){var _0x48901e=_0x181d95[_0xb6c9('0x7b')]['views']['admin'];if(!/^(f|ht)tps?:\/\//i[_0xb6c9('0x8c')](_0x48901e)){_0x2d1779=path[_0xb6c9('0x4f')](_0xb6c9('0x8d'),_0x2eabee,_0x3399e4[0x0],_0x48901e);}else{_0x2d1779=_0x48901e;}}if(_0xb6c9('0x77')!=typeof _0x181d95['parameters']['views'][_0xb6c9('0x81')]){var _0x1fc44b=_0x181d95['parameters'][_0xb6c9('0x7e')][_0xb6c9('0x81')];if(!/^(f|ht)tps?:\/\//i['test'](_0x1fc44b)){_0x1175fe=path[_0xb6c9('0x4f')](_0xb6c9('0x8d'),_0x2eabee,_0x3399e4[0x0],_0x1fc44b);}else{_0x1175fe=_0x1fc44b;}}}}var _0x2c58ac={'name':_0x1e323e,'description':_0x47cd02,'path':path[_0xb6c9('0x4f')](_0x2eabee,_0x3399e4[0x0]),'type':_0x3d011a,'sidebar':_0x2376c5,'icon':_0x377fb6,'adminUrl':_0x2d1779,'agentUrl':_0x1175fe,'scriptName':_0x11fc6d,'scriptPath':_0x392e74,'version':_0x581184};removeReferences(_0x2c6e04,null);return db['Plugin']['create'](_0x2c58ac)[_0xb6c9('0x27')](function(_0x4ed9a2){var _0x544a06={'role':_0x51aaf1['body']['role'],'userProfileId':_0x51aaf1[_0xb6c9('0x8e')][_0xb6c9('0x8f')]};if(!_0x544a06)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x544a06[_0xb6c9('0x90')]==='user'){var _0x5e97de=_0x4ed9a2[_0xb6c9('0x29')]({'plain':!![]});return db['UserProfileSection']['find']({'where':{'name':_0xb6c9('0x2a'),'userProfileId':_0x544a06[_0xb6c9('0x8f')]},'raw':!![]})[_0xb6c9('0x27')](function(_0x1cf2cd){if(_0x1cf2cd&&_0x1cf2cd[_0xb6c9('0x91')]===0x0){return db['UserProfileResource'][_0xb6c9('0x92')]({'name':_0x5e97de[_0xb6c9('0x2e')],'resourceId':_0x5e97de['id'],'type':_0x1cf2cd[_0xb6c9('0x2e')],'sectionId':_0x1cf2cd['id']},{})['then'](function(){return _0x4ed9a2;});}else{return _0x4ed9a2;}})[_0xb6c9('0x49')](function(_0x5cdf2b){logger[_0xb6c9('0x2c')](_0xb6c9('0x93'),_0x5cdf2b);throw _0x5cdf2b;});}return _0x4ed9a2;})[_0xb6c9('0x27')](respondWithResult(_0x24c937,null))['catch'](handleError(_0x24c937,null));}});}catch(_0x52e364){_0x24c937[_0xb6c9('0x1f')](0x1f4)['send'](_0x52e364);}};function removeReferences(_0xff5473,_0x2bedc3){try{if(_0xff5473){fs[_0xb6c9('0x94')](_0xff5473);logger[_0xb6c9('0x63')](_0xb6c9('0x95'));}if(_0x2bedc3){rimraf(_0x2bedc3,function(){});logger[_0xb6c9('0x63')]('Extracted\x20folder\x20removed');}}catch(_0x5de346){logger[_0xb6c9('0x2c')](_0x5de346);}}exports[_0xb6c9('0x26')]=function(_0x488cda,_0x1289dd,_0x180f31){return db['Plugin'][_0xb6c9('0x4c')]({'where':{'id':_0x488cda[_0xb6c9('0x4a')]['id']}})['then'](handleEntityNotFound(_0x1289dd,null))[_0xb6c9('0x27')](saveUpdates(_0x488cda[_0xb6c9('0x8e')],null))[_0xb6c9('0x27')](respondWithResult(_0x1289dd,null))[_0xb6c9('0x49')](handleError(_0x1289dd,null));};exports[_0xb6c9('0x96')]=function(_0x5d5fb8,_0x5439fe,_0x58b828){return db[_0xb6c9('0x30')][_0xb6c9('0x4c')]({'where':{'id':_0x5d5fb8[_0xb6c9('0x4a')]['id']}})[_0xb6c9('0x27')](function(_0xa461d9){if(_0xa461d9){return _0xa461d9[_0xb6c9('0x28')]();}})[_0xb6c9('0x27')](function(_0xcb3515){rimraf(path[_0xb6c9('0x4f')](config['root'],_0xb6c9('0x51'),path[_0xb6c9('0x5e')](_0xcb3515[_0xb6c9('0x4e')])),function(){});return _0xcb3515;})[_0xb6c9('0x27')](handleEntityNotFound(_0x5439fe,null))[_0xb6c9('0x27')](respondWithStatusCode(_0x5439fe,null))[_0xb6c9('0x49')](handleError(_0x5439fe,null));};exports['webhookGet']=function(_0x38fcfb,_0x443651,_0xab24d7){return BPromise[_0xb6c9('0x97')]()[_0xb6c9('0x27')](function(){if(!_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x4e')]){throw new Error(_0xb6c9('0x98'));}if(!_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x99')]){throw new Error(_0xb6c9('0x9a'));}var _0x1412e3=_0x38fcfb['query']['hostname']?_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x9b')]+':'+_0x38fcfb['query'][_0xb6c9('0x99')]:'http://localhost:'+_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x99')];var _0x13c7a1=_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x20')]?_0x38fcfb[_0xb6c9('0x35')]['json']:!![];var _0x283185=_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x9c')]?_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x9c')]:null;var _0xeb7c3e={'method':_0x38fcfb['method'],'uri':util[_0xb6c9('0x52')]('%s%s',_0x1412e3,_0x38fcfb[_0xb6c9('0x35')]['path']),'json':_0x13c7a1,'resolveWithFullResponse':!![],'encoding':_0x283185,'qs':_0x38fcfb[_0xb6c9('0x35')]};if(_0x38fcfb[_0xb6c9('0x9d')]){_0xeb7c3e['headers']=_0x38fcfb[_0xb6c9('0x9d')];if(_0xeb7c3e[_0xb6c9('0x9d')]['content-length']){delete _0xeb7c3e[_0xb6c9('0x9d')][_0xb6c9('0x9e')];}}if(_0xeb7c3e[_0xb6c9('0x9d')][_0xb6c9('0x9f')]){delete _0xeb7c3e[_0xb6c9('0x9d')][_0xb6c9('0x9f')];}return rp(_0xeb7c3e);})['then'](function(_0x5ed026){if(_0x5ed026){_0x443651[_0xb6c9('0x23')](_0x5ed026[_0xb6c9('0x9d')]);logger['info'](_0x5ed026[_0xb6c9('0x8e')]);if(_[_0xb6c9('0xa0')](_0x38fcfb[_0xb6c9('0x35')][_0xb6c9('0x4e')],'download')&&_0x5ed026[_0xb6c9('0xa1')]==0x1f4){return _0x443651[_0xb6c9('0x1d')](_0x5ed026[_0xb6c9('0xa1')]);}else{return _0x443651[_0xb6c9('0x1f')](_0x5ed026['statusCode'])[_0xb6c9('0xa2')](_0x5ed026[_0xb6c9('0x8e')]);}}else{return _0x443651[_0xb6c9('0x1d')](0xc8);}})[_0xb6c9('0x49')](handleError(_0x443651,null));};exports[_0xb6c9('0xa3')]=function(_0x25f04a,_0x3b9902,_0x197e86){return BPromise[_0xb6c9('0x97')]()[_0xb6c9('0x27')](function(){if(!_0x25f04a[_0xb6c9('0x35')][_0xb6c9('0x4e')]){throw new Error('\x27PATH\x27\x20parameter\x20not\x20specified');}if(!_0x25f04a[_0xb6c9('0x35')][_0xb6c9('0x99')]){throw new Error(_0xb6c9('0x9a'));}var _0x18a0a6=_0x25f04a[_0xb6c9('0x35')]['hostname']?_0x25f04a[_0xb6c9('0x35')]['hostname']+':'+_0x25f04a[_0xb6c9('0x35')][_0xb6c9('0x99')]:_0xb6c9('0xa4')+_0x25f04a[_0xb6c9('0x35')][_0xb6c9('0x99')];var _0x2078f3=_0x25f04a['query'][_0xb6c9('0x20')]?_0x25f04a['query'][_0xb6c9('0x20')]:!![];var _0x371588=_0x25f04a['query'][_0xb6c9('0x9c')]?_0x25f04a['query'][_0xb6c9('0x9c')]:null;var _0x918d16={'method':_0x25f04a[_0xb6c9('0xa5')],'uri':util[_0xb6c9('0x52')](_0xb6c9('0xa6'),_0x18a0a6,_0x25f04a[_0xb6c9('0x35')]['path']),'json':_0x2078f3,'resolveWithFullResponse':!![],'encoding':_0x371588,'body':_0x25f04a[_0xb6c9('0x8e')]};if(_0x25f04a[_0xb6c9('0x9d')]){_0x918d16[_0xb6c9('0x9d')]=_0x25f04a['headers'];if(_0x918d16[_0xb6c9('0x9d')][_0xb6c9('0x9e')]){delete _0x918d16[_0xb6c9('0x9d')][_0xb6c9('0x9e')];}}if(_0x918d16[_0xb6c9('0x9d')]['content-type']){delete _0x918d16['headers']['content-type'];}return rp(_0x918d16);})['then'](function(_0x1aa481){if(_0x1aa481){_0x3b9902[_0xb6c9('0x23')](_0x1aa481[_0xb6c9('0x9d')]);logger['info'](_0x1aa481['body']);return _0x3b9902['status'](_0x1aa481[_0xb6c9('0xa1')])[_0xb6c9('0xa2')](_0x1aa481[_0xb6c9('0x8e')]);}else{return _0x3b9902[_0xb6c9('0x1d')](0xc8);}})[_0xb6c9('0x49')](handleError(_0x3b9902,null));};
\ No newline at end of file