Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 63d457d..1cb66c4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf8c=['../../components/encryptor','../../config/environment','api','./cloudProvider.oauth','defaults','localhost','socket.io-emitter','redis','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','update','destroy','then','error','stack','name','send','padEnd','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','CloudProvider','include','service','MicrosoftAzure','decryptString','data3','show','params','catch','create','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','encryptString','find','oauth2MicrosoftAuthorize','findOne','generateMicrosoftAuthorizationUrl','oauth2MicrosoftCallback','get','state','from','toString','ascii','parse','isValidIdToken','id_token','Unable\x20to\x20validate\x20id_token','del','getOauth2MicrosoftAccessToken','code','data5','access_token','data6','refresh_token','microsoftAuthorization:success','emit','microsoftAuthorization:error','Invalid\x20authentication\x20state\x20parameter','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','ioredis','../../components/parsers/qs'];(function(_0x2279fa,_0x46504c){var _0x5cb49f=function(_0x38fa79){while(--_0x38fa79){_0x2279fa['push'](_0x2279fa['shift']());}};_0x5cb49f(++_0x46504c);}(_0xbf8c,0xbd));var _0xcbf8=function(_0x3635ce,_0x33a6f9){_0x3635ce=_0x3635ce-0x0;var _0x97ecd0=_0xbf8c[_0x3635ce];return _0x97ecd0;};'use strict';var _=require(_0xcbf8('0x0'));var Redis=require(_0xcbf8('0x1'));var qs=require(_0xcbf8('0x2'));var encryptor=require(_0xcbf8('0x3'));var config=require(_0xcbf8('0x4'));var logger=require('../../config/logger')(_0xcbf8('0x5'));var db=require('../../mysqldb')['db'];var oauth=require(_0xcbf8('0x6'));config['redis']=_[_0xcbf8('0x7')](config['redis'],{'host':_0xcbf8('0x8'),'port':0x18eb});var socket=require(_0xcbf8('0x9'))(new Redis(config[_0xcbf8('0xa')]));var redis=new Redis(config[_0xcbf8('0xa')]);function respondWithStatusCode(_0x5cb986,_0x3651cd){_0x3651cd=_0x3651cd||0xcc;return function(_0x5554fe){if(_0x5554fe){return _0x5cb986[_0xcbf8('0xb')](_0x3651cd);}return _0x5cb986[_0xcbf8('0xc')](_0x3651cd)[_0xcbf8('0xd')]();};}function respondWithResult(_0x10bd64,_0x384b50){_0x384b50=_0x384b50||0xc8;return function(_0x40ca24){if(_0x40ca24){return _0x10bd64[_0xcbf8('0xc')](_0x384b50)[_0xcbf8('0xe')](_0x40ca24);}};}function respondWithFilteredResult(_0x16ab31,_0x1d4e73){return function(_0x34b277){if(_0x34b277){var _0x271ec4=typeof _0x1d4e73[_0xcbf8('0xf')]===_0xcbf8('0x10')&&typeof _0x1d4e73[_0xcbf8('0x11')]===_0xcbf8('0x10');var _0x3e01ba=_0x34b277[_0xcbf8('0x12')];var _0x4f58ca=_0x271ec4?0x0:_0x1d4e73[_0xcbf8('0xf')];var _0x578223=_0x271ec4?_0x34b277[_0xcbf8('0x12')]:_0x1d4e73[_0xcbf8('0xf')]+_0x1d4e73[_0xcbf8('0x11')];var _0x1d6c55;if(_0x578223>=_0x3e01ba){_0x578223=_0x3e01ba;_0x1d6c55=0xc8;}else{_0x1d6c55=0xce;}_0x16ab31[_0xcbf8('0xc')](_0x1d6c55);return _0x16ab31[_0xcbf8('0x13')](_0xcbf8('0x14'),_0x4f58ca+'-'+_0x578223+'/'+_0x3e01ba)[_0xcbf8('0xe')](_0x34b277);}return null;};}function saveUpdates(_0x393d3a){return function(_0x261ff1){if(_0x261ff1){return _0x261ff1[_0xcbf8('0x15')](_0x393d3a)['then'](function(_0x1f9eba){return _0x1f9eba;});}return null;};}function removeEntity(_0x5ed9e6){return function(_0x3cbcfe){if(_0x3cbcfe){return _0x3cbcfe[_0xcbf8('0x16')]()[_0xcbf8('0x17')](function(){_0x5ed9e6[_0xcbf8('0xc')](0xcc)[_0xcbf8('0xd')]();});}};}function handleEntityNotFound(_0x37787e){return function(_0x555118){if(!_0x555118){_0x37787e[_0xcbf8('0xb')](0x194);}return _0x555118;};}function handleError(_0x5b852c,_0x47de32){_0x47de32=_0x47de32||0x1f4;return function(_0x4f871b){logger[_0xcbf8('0x18')](_0x4f871b[_0xcbf8('0x19')]);if(_0x4f871b[_0xcbf8('0x1a')]){delete _0x4f871b[_0xcbf8('0x1a')];}_0x5b852c['status'](_0x47de32)[_0xcbf8('0x1b')](_0x4f871b);};}function maskClientSecret(_0x49ad86){return _[_0xcbf8('0x1c')](_0x49ad86['slice'](0x0,0x3),0x14,'*');}exports[_0xcbf8('0x1d')]=function(_0x28e976,_0x213ed4){var _0x25bee7={},_0x496513={},_0x47acf1={'count':0x0,'rows':[]};var _0xe411cf=_[_0xcbf8('0x1e')](db['CloudProvider'][_0xcbf8('0x1f')],function(_0x4ac939){return{'name':_0x4ac939[_0xcbf8('0x20')],'type':_0x4ac939[_0xcbf8('0x21')][_0xcbf8('0x22')]};});_0x496513[_0xcbf8('0x23')]=_[_0xcbf8('0x1e')](_0xe411cf,'name');_0x496513[_0xcbf8('0x24')]=_[_0xcbf8('0x25')](_0x28e976[_0xcbf8('0x24')]);_0x496513[_0xcbf8('0x26')]=_[_0xcbf8('0x27')](_0x496513[_0xcbf8('0x23')],_0x496513[_0xcbf8('0x24')]);_0x25bee7[_0xcbf8('0x28')]=_['intersection'](_0x496513['model'],qs[_0xcbf8('0x29')](_0x28e976['query'][_0xcbf8('0x29')]));_0x25bee7[_0xcbf8('0x28')]=_0x25bee7[_0xcbf8('0x28')][_0xcbf8('0x2a')]?_0x25bee7[_0xcbf8('0x28')]:_0x496513[_0xcbf8('0x23')];if(!_0x28e976[_0xcbf8('0x24')][_0xcbf8('0x2b')](_0xcbf8('0x2c'))){_0x25bee7[_0xcbf8('0x11')]=qs[_0xcbf8('0x11')](_0x28e976[_0xcbf8('0x24')]['limit']);_0x25bee7[_0xcbf8('0xf')]=qs[_0xcbf8('0xf')](_0x28e976[_0xcbf8('0x24')]['offset']);}_0x25bee7['order']=qs[_0xcbf8('0x2d')](_0x28e976[_0xcbf8('0x24')][_0xcbf8('0x2d')]);_0x25bee7[_0xcbf8('0x2e')]=qs[_0xcbf8('0x26')](_[_0xcbf8('0x2f')](_0x28e976['query'],_0x496513['filters']),_0xe411cf);if(_0x28e976['query'][_0xcbf8('0x30')]){_0x25bee7[_0xcbf8('0x2e')]=_[_0xcbf8('0x31')](_0x25bee7[_0xcbf8('0x2e')],{'$or':_[_0xcbf8('0x1e')](_0xe411cf,function(_0x13d0b0){if(_0x13d0b0[_0xcbf8('0x21')]!=='VIRTUAL'){var _0x3be7f5={};_0x3be7f5[_0x13d0b0[_0xcbf8('0x1a')]]={'$like':'%'+_0x28e976[_0xcbf8('0x24')][_0xcbf8('0x30')]+'%'};return _0x3be7f5;}})});}_0x25bee7=_[_0xcbf8('0x31')]({},_0x25bee7,_0x28e976[_0xcbf8('0x32')]);var _0x54aa3c={'where':_0x25bee7[_0xcbf8('0x2e')]};return db[_0xcbf8('0x33')]['count'](_0x54aa3c)[_0xcbf8('0x17')](function(_0xe8bf25){_0x47acf1['count']=_0xe8bf25;if(_0x28e976[_0xcbf8('0x24')]['includeAll']){_0x25bee7[_0xcbf8('0x34')]=[{'all':!![]}];}return db[_0xcbf8('0x33')]['findAll'](_0x25bee7);})['then'](function(_0x5d64b3){_0x47acf1['rows']=_[_0xcbf8('0x1e')](_0x5d64b3,function(_0x2826a0){if(_0x2826a0[_0xcbf8('0x35')]===_0xcbf8('0x36')){var _0x3b93ba=encryptor[_0xcbf8('0x37')](_0x2826a0[_0xcbf8('0x38')]);_0x2826a0[_0xcbf8('0x38')]=maskClientSecret(_0x3b93ba);}return _0x2826a0;});return _0x47acf1;})[_0xcbf8('0x17')](respondWithFilteredResult(_0x213ed4,_0x25bee7))['catch'](handleError(_0x213ed4,null));};exports[_0xcbf8('0x39')]=function(_0xdab854,_0x4945a0){var _0x2856c7={'raw':!![],'where':{'id':_0xdab854[_0xcbf8('0x3a')]['id']}},_0x8973db={};_0x8973db['model']=_[_0xcbf8('0x25')](db[_0xcbf8('0x33')][_0xcbf8('0x1f')]);_0x8973db['query']=_[_0xcbf8('0x25')](_0xdab854[_0xcbf8('0x24')]);_0x8973db[_0xcbf8('0x26')]=_[_0xcbf8('0x27')](_0x8973db[_0xcbf8('0x23')],_0x8973db[_0xcbf8('0x24')]);_0x2856c7[_0xcbf8('0x28')]=_[_0xcbf8('0x27')](_0x8973db[_0xcbf8('0x23')],qs['fields'](_0xdab854[_0xcbf8('0x24')][_0xcbf8('0x29')]));_0x2856c7[_0xcbf8('0x28')]=_0x2856c7[_0xcbf8('0x28')][_0xcbf8('0x2a')]?_0x2856c7[_0xcbf8('0x28')]:_0x8973db[_0xcbf8('0x23')];if(_0xdab854[_0xcbf8('0x24')]['includeAll']){_0x2856c7[_0xcbf8('0x34')]=[{'all':!![]}];}_0x2856c7=_[_0xcbf8('0x31')]({},_0x2856c7,_0xdab854[_0xcbf8('0x32')]);return db[_0xcbf8('0x33')]['find'](_0x2856c7)[_0xcbf8('0x17')](handleEntityNotFound(_0x4945a0,null))[_0xcbf8('0x17')](function(_0x41fc83){if(_0x41fc83[_0xcbf8('0x35')]===_0xcbf8('0x36')){var _0x26fbc1=encryptor[_0xcbf8('0x37')](_0x41fc83[_0xcbf8('0x38')]);_0x41fc83['data3']=maskClientSecret(_0x26fbc1);}return _0x41fc83;})[_0xcbf8('0x17')](respondWithResult(_0x4945a0,null))[_0xcbf8('0x3b')](handleError(_0x4945a0,null));};exports[_0xcbf8('0x3c')]=function(_0x3bd4c3,_0xad5673){if(!_0x3bd4c3[_0xcbf8('0x3d')][_0xcbf8('0x1a')])throw new Error(_0xcbf8('0x3e'));if(!_0x3bd4c3[_0xcbf8('0x3d')]['service'])throw new Error(_0xcbf8('0x3f'));var _0x38f663=db['CloudProvider'][_0xcbf8('0x1f')][_0xcbf8('0x35')][_0xcbf8('0x40')];if(!_0x38f663[_0xcbf8('0x41')](_0x3bd4c3[_0xcbf8('0x3d')]['service']))throw new Error(_0xcbf8('0x42')+_0x38f663[_0xcbf8('0x43')](',\x20'));if(_0x3bd4c3[_0xcbf8('0x3d')][_0xcbf8('0x35')]==='MicrosoftAzure'&&_0x3bd4c3[_0xcbf8('0x3d')][_0xcbf8('0x38')]){_0x3bd4c3['body']['data3']=encryptor[_0xcbf8('0x44')](_0x3bd4c3[_0xcbf8('0x3d')]['data3']);}return db[_0xcbf8('0x33')][_0xcbf8('0x3c')](_0x3bd4c3[_0xcbf8('0x3d')],{})[_0xcbf8('0x17')](respondWithResult(_0xad5673,0xc9))[_0xcbf8('0x3b')](handleError(_0xad5673,null));};exports[_0xcbf8('0x15')]=function(_0x15ccc9,_0x22906e){if(_0x15ccc9['body']['id']){delete _0x15ccc9['body']['id'];}return db['CloudProvider'][_0xcbf8('0x45')]({'where':{'id':_0x15ccc9['params']['id']}})['then'](handleEntityNotFound(_0x22906e,null))[_0xcbf8('0x17')](function(_0x1482fa){if(_0x1482fa['service']==='MicrosoftAzure'&&_0x15ccc9[_0xcbf8('0x3d')]['data3']){_0x15ccc9[_0xcbf8('0x3d')][_0xcbf8('0x38')]=encryptor[_0xcbf8('0x44')](_0x15ccc9['body']['data3']);}return _0x1482fa;})[_0xcbf8('0x17')](saveUpdates(_0x15ccc9[_0xcbf8('0x3d')],null))[_0xcbf8('0x17')](respondWithResult(_0x22906e,null))['catch'](handleError(_0x22906e,null));};exports['destroy']=function(_0x25710c,_0xf29441){return db[_0xcbf8('0x33')][_0xcbf8('0x45')]({'where':{'id':_0x25710c[_0xcbf8('0x3a')]['id']}})[_0xcbf8('0x17')](handleEntityNotFound(_0xf29441,null))['then'](removeEntity(_0xf29441,null))[_0xcbf8('0x3b')](handleError(_0xf29441,null));};exports[_0xcbf8('0x46')]=function(_0x3ceb0b,_0x4ba6ec){return db['CloudProvider'][_0xcbf8('0x47')]({'where':{'id':_0x3ceb0b['params']['id']},'raw':!![]})[_0xcbf8('0x17')](function(_0x3e06dd){if(!_0x3e06dd)return _0x4ba6ec[_0xcbf8('0xb')](0x194);return{'url':oauth[_0xcbf8('0x48')](_0x3e06dd,_0x3ceb0b['user']['id'])};})[_0xcbf8('0x17')](respondWithResult(_0x4ba6ec,null))['catch'](handleError(_0x4ba6ec,null));};exports[_0xcbf8('0x49')]=function(_0x2bd717,_0x102610){var _0x27b72f=_0x2bd717[_0xcbf8('0x3d')];var _0x9711a6;var _0x57b671;if(_0x27b72f[_0xcbf8('0x18')])throw _0x27b72f;redis[_0xcbf8('0x4a')](_0x27b72f[_0xcbf8('0x4b')])[_0xcbf8('0x17')](function(_0x529bb5){if(!_0x529bb5)throw new Error('Invalid\x20state\x20parameter');_0x9711a6=JSON['parse'](_0x529bb5);var _0x1225d8=Buffer[_0xcbf8('0x4c')](_0x27b72f[_0xcbf8('0x4b')],'base64')[_0xcbf8('0x4d')](_0xcbf8('0x4e'));_0x57b671=JSON[_0xcbf8('0x4f')](_0x1225d8);if(!oauth[_0xcbf8('0x50')](_0x27b72f[_0xcbf8('0x51')],_0x9711a6['oauth2Claims']))throw new Error(_0xcbf8('0x52'));redis[_0xcbf8('0x53')](_0x27b72f[_0xcbf8('0x4b')]);return oauth[_0xcbf8('0x54')](_0x27b72f[_0xcbf8('0x55')],_0x9711a6);})[_0xcbf8('0x17')](function(_0x420604){_0x9711a6[_0xcbf8('0x56')]=_0x420604[_0xcbf8('0x57')];_0x9711a6[_0xcbf8('0x58')]=_0x420604[_0xcbf8('0x59')];return db[_0xcbf8('0x33')][_0xcbf8('0x15')]({'data5':_0x9711a6[_0xcbf8('0x56')],'data6':_0x9711a6[_0xcbf8('0x58')]},{'where':{'id':_0x9711a6['id']}});})[_0xcbf8('0x17')](function(){oauth['startRefreshInterval'](_0x9711a6);socket['emit'](_0xcbf8('0x5a'),{'id':_0x57b671['id']});return;})[_0xcbf8('0x17')](respondWithStatusCode(_0x102610,null))[_0xcbf8('0x3b')](function(_0x2f14b9){if(_0x57b671){socket[_0xcbf8('0x5b')](_0xcbf8('0x5c'),{'id':_0x57b671['id']});}if(!_0x9711a6){logger['error'](_0xcbf8('0x5d'),_0x2f14b9);return _0x102610[_0xcbf8('0xc')](0x1f4)[_0xcbf8('0x1b')](_0x2f14b9['message']);}logger[_0xcbf8('0x18')](_0xcbf8('0x5e'),_0x9711a6['id'],JSON[_0xcbf8('0x5f')](_0x2f14b9));});};
\ No newline at end of file
+var _0x0f61=['error','name','slice','CloudProvider','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','findAll','rows','service','MicrosoftAzure','data3','catch','show','length','includeAll','include','decryptString','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','encryptString','update','find','params','destroy','oauth2MicrosoftAuthorize','findOne','user','get','state','Invalid\x20state\x20parameter','parse','base64','toString','ascii','isValidIdToken','oauth2Claims','Unable\x20to\x20validate\x20id_token','getOauth2MicrosoftAccessToken','code','data5','data6','refresh_token','startRefreshInterval','emit','lodash','ioredis','../../components/parsers/qs','../../config/environment','../../config/logger','api','../../mysqldb','./cloudProvider.oauth','redis','defaults','localhost','socket.io-emitter','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','then'];(function(_0x2adb42,_0xed8b12){var _0x101363=function(_0x1a9d3d){while(--_0x1a9d3d){_0x2adb42['push'](_0x2adb42['shift']());}};_0x101363(++_0xed8b12);}(_0x0f61,0x1ac));var _0x10f6=function(_0x2132f9,_0x12bb36){_0x2132f9=_0x2132f9-0x0;var _0x21fe79=_0x0f61[_0x2132f9];return _0x21fe79;};'use strict';var _=require(_0x10f6('0x0'));var Redis=require(_0x10f6('0x1'));var qs=require(_0x10f6('0x2'));var encryptor=require('../../components/encryptor');var config=require(_0x10f6('0x3'));var logger=require(_0x10f6('0x4'))(_0x10f6('0x5'));var db=require(_0x10f6('0x6'))['db'];var oauth=require(_0x10f6('0x7'));config[_0x10f6('0x8')]=_[_0x10f6('0x9')](config[_0x10f6('0x8')],{'host':_0x10f6('0xa'),'port':0x18eb});var socket=require(_0x10f6('0xb'))(new Redis(config['redis']));var redis=new Redis(config[_0x10f6('0x8')]);function respondWithStatusCode(_0x56ba9b,_0x40dd2f){_0x40dd2f=_0x40dd2f||0xcc;return function(_0x340d53){if(_0x340d53){return _0x56ba9b[_0x10f6('0xc')](_0x40dd2f);}return _0x56ba9b[_0x10f6('0xd')](_0x40dd2f)[_0x10f6('0xe')]();};}function respondWithResult(_0x8c0760,_0x44b148){_0x44b148=_0x44b148||0xc8;return function(_0x202463){if(_0x202463){return _0x8c0760[_0x10f6('0xd')](_0x44b148)[_0x10f6('0xf')](_0x202463);}};}function respondWithFilteredResult(_0x411f63,_0x4c1dcf){return function(_0x4b5c51){if(_0x4b5c51){var _0x1cd1a0=typeof _0x4c1dcf[_0x10f6('0x10')]===_0x10f6('0x11')&&typeof _0x4c1dcf[_0x10f6('0x12')]===_0x10f6('0x11');var _0x351777=_0x4b5c51['count'];var _0x391004=_0x1cd1a0?0x0:_0x4c1dcf[_0x10f6('0x10')];var _0x1242e9=_0x1cd1a0?_0x4b5c51[_0x10f6('0x13')]:_0x4c1dcf[_0x10f6('0x10')]+_0x4c1dcf['limit'];var _0x8211f0;if(_0x1242e9>=_0x351777){_0x1242e9=_0x351777;_0x8211f0=0xc8;}else{_0x8211f0=0xce;}_0x411f63[_0x10f6('0xd')](_0x8211f0);return _0x411f63['set'](_0x10f6('0x14'),_0x391004+'-'+_0x1242e9+'/'+_0x351777)[_0x10f6('0xf')](_0x4b5c51);}return null;};}function saveUpdates(_0x1282b4){return function(_0x223c80){if(_0x223c80){return _0x223c80['update'](_0x1282b4)[_0x10f6('0x15')](function(_0x54fe05){return _0x54fe05;});}return null;};}function removeEntity(_0x108244){return function(_0xa337ee){if(_0xa337ee){return _0xa337ee['destroy']()[_0x10f6('0x15')](function(){_0x108244[_0x10f6('0xd')](0xcc)[_0x10f6('0xe')]();});}};}function handleEntityNotFound(_0x24cece){return function(_0x4177f4){if(!_0x4177f4){_0x24cece[_0x10f6('0xc')](0x194);}return _0x4177f4;};}function handleError(_0x2b5d39,_0x37b583){_0x37b583=_0x37b583||0x1f4;return function(_0x1d7985){logger[_0x10f6('0x16')](_0x1d7985['stack']);if(_0x1d7985['name']){delete _0x1d7985[_0x10f6('0x17')];}_0x2b5d39['status'](_0x37b583)['send'](_0x1d7985);};}function maskClientSecret(_0x389da3){return _['padEnd'](_0x389da3[_0x10f6('0x18')](0x0,0x3),0x14,'*');}exports['index']=function(_0x207c4b,_0x57dc90){var _0x6ebace={},_0x43c1b0={},_0x35cb9e={'count':0x0,'rows':[]};var _0x33a55e=_['map'](db[_0x10f6('0x19')][_0x10f6('0x1a')],function(_0x53b8cb){return{'name':_0x53b8cb[_0x10f6('0x1b')],'type':_0x53b8cb[_0x10f6('0x1c')][_0x10f6('0x1d')]};});_0x43c1b0[_0x10f6('0x1e')]=_[_0x10f6('0x1f')](_0x33a55e,'name');_0x43c1b0[_0x10f6('0x20')]=_[_0x10f6('0x21')](_0x207c4b[_0x10f6('0x20')]);_0x43c1b0[_0x10f6('0x22')]=_[_0x10f6('0x23')](_0x43c1b0[_0x10f6('0x1e')],_0x43c1b0[_0x10f6('0x20')]);_0x6ebace[_0x10f6('0x24')]=_[_0x10f6('0x23')](_0x43c1b0['model'],qs[_0x10f6('0x25')](_0x207c4b[_0x10f6('0x20')][_0x10f6('0x25')]));_0x6ebace[_0x10f6('0x24')]=_0x6ebace[_0x10f6('0x24')]['length']?_0x6ebace[_0x10f6('0x24')]:_0x43c1b0[_0x10f6('0x1e')];if(!_0x207c4b[_0x10f6('0x20')][_0x10f6('0x26')](_0x10f6('0x27'))){_0x6ebace[_0x10f6('0x12')]=qs[_0x10f6('0x12')](_0x207c4b['query']['limit']);_0x6ebace[_0x10f6('0x10')]=qs[_0x10f6('0x10')](_0x207c4b[_0x10f6('0x20')][_0x10f6('0x10')]);}_0x6ebace['order']=qs[_0x10f6('0x28')](_0x207c4b[_0x10f6('0x20')]['sort']);_0x6ebace[_0x10f6('0x29')]=qs[_0x10f6('0x22')](_[_0x10f6('0x2a')](_0x207c4b[_0x10f6('0x20')],_0x43c1b0[_0x10f6('0x22')]),_0x33a55e);if(_0x207c4b[_0x10f6('0x20')][_0x10f6('0x2b')]){_0x6ebace[_0x10f6('0x29')]=_[_0x10f6('0x2c')](_0x6ebace['where'],{'$or':_[_0x10f6('0x1f')](_0x33a55e,function(_0x42db5a){if(_0x42db5a[_0x10f6('0x1c')]!==_0x10f6('0x2d')){var _0x135e23={};_0x135e23[_0x42db5a['name']]={'$like':'%'+_0x207c4b[_0x10f6('0x20')][_0x10f6('0x2b')]+'%'};return _0x135e23;}})});}_0x6ebace=_[_0x10f6('0x2c')]({},_0x6ebace,_0x207c4b[_0x10f6('0x2e')]);var _0x21aae9={'where':_0x6ebace['where']};return db[_0x10f6('0x19')][_0x10f6('0x13')](_0x21aae9)['then'](function(_0x2ee416){_0x35cb9e['count']=_0x2ee416;if(_0x207c4b[_0x10f6('0x20')]['includeAll']){_0x6ebace['include']=[{'all':!![]}];}return db[_0x10f6('0x19')][_0x10f6('0x2f')](_0x6ebace);})[_0x10f6('0x15')](function(_0x22d293){_0x35cb9e[_0x10f6('0x30')]=_[_0x10f6('0x1f')](_0x22d293,function(_0x2a4e25){if(_0x2a4e25[_0x10f6('0x31')]===_0x10f6('0x32')){var _0x26bf85=encryptor['decryptString'](_0x2a4e25[_0x10f6('0x33')]);_0x2a4e25[_0x10f6('0x33')]=maskClientSecret(_0x26bf85);}return _0x2a4e25;});return _0x35cb9e;})[_0x10f6('0x15')](respondWithFilteredResult(_0x57dc90,_0x6ebace))[_0x10f6('0x34')](handleError(_0x57dc90,null));};exports[_0x10f6('0x35')]=function(_0x4c746e,_0x24d8e3){var _0xad069e={'raw':!![],'where':{'id':_0x4c746e['params']['id']}},_0x47af7f={};_0x47af7f['model']=_[_0x10f6('0x21')](db['CloudProvider']['rawAttributes']);_0x47af7f[_0x10f6('0x20')]=_['keys'](_0x4c746e[_0x10f6('0x20')]);_0x47af7f[_0x10f6('0x22')]=_['intersection'](_0x47af7f[_0x10f6('0x1e')],_0x47af7f[_0x10f6('0x20')]);_0xad069e[_0x10f6('0x24')]=_['intersection'](_0x47af7f['model'],qs['fields'](_0x4c746e[_0x10f6('0x20')][_0x10f6('0x25')]));_0xad069e[_0x10f6('0x24')]=_0xad069e[_0x10f6('0x24')][_0x10f6('0x36')]?_0xad069e[_0x10f6('0x24')]:_0x47af7f[_0x10f6('0x1e')];if(_0x4c746e[_0x10f6('0x20')][_0x10f6('0x37')]){_0xad069e[_0x10f6('0x38')]=[{'all':!![]}];}_0xad069e=_[_0x10f6('0x2c')]({},_0xad069e,_0x4c746e['options']);return db[_0x10f6('0x19')]['find'](_0xad069e)[_0x10f6('0x15')](handleEntityNotFound(_0x24d8e3,null))['then'](function(_0x3b92ae){if(_0x3b92ae[_0x10f6('0x31')]===_0x10f6('0x32')){var _0x218ba0=encryptor[_0x10f6('0x39')](_0x3b92ae[_0x10f6('0x33')]);_0x3b92ae[_0x10f6('0x33')]=maskClientSecret(_0x218ba0);}return _0x3b92ae;})['then'](respondWithResult(_0x24d8e3,null))[_0x10f6('0x34')](handleError(_0x24d8e3,null));};exports['create']=function(_0x468e5c,_0x35ec84){if(!_0x468e5c[_0x10f6('0x3a')][_0x10f6('0x17')])throw new Error(_0x10f6('0x3b'));if(!_0x468e5c[_0x10f6('0x3a')]['service'])throw new Error(_0x10f6('0x3c'));var _0x22ddea=db[_0x10f6('0x19')]['rawAttributes']['service'][_0x10f6('0x3d')];if(!_0x22ddea[_0x10f6('0x3e')](_0x468e5c[_0x10f6('0x3a')]['service']))throw new Error(_0x10f6('0x3f')+_0x22ddea[_0x10f6('0x40')](',\x20'));if(_0x468e5c[_0x10f6('0x3a')][_0x10f6('0x31')]===_0x10f6('0x32')&&_0x468e5c[_0x10f6('0x3a')]['data3']){_0x468e5c[_0x10f6('0x3a')][_0x10f6('0x33')]=encryptor[_0x10f6('0x41')](_0x468e5c['body'][_0x10f6('0x33')]);}return db[_0x10f6('0x19')]['create'](_0x468e5c['body'],{})[_0x10f6('0x15')](respondWithResult(_0x35ec84,0xc9))[_0x10f6('0x34')](handleError(_0x35ec84,null));};exports[_0x10f6('0x42')]=function(_0x18447b,_0x37f2f9){if(_0x18447b[_0x10f6('0x3a')]['id']){delete _0x18447b[_0x10f6('0x3a')]['id'];}return db[_0x10f6('0x19')][_0x10f6('0x43')]({'where':{'id':_0x18447b[_0x10f6('0x44')]['id']}})['then'](handleEntityNotFound(_0x37f2f9,null))[_0x10f6('0x15')](function(_0x51df38){if(_0x51df38[_0x10f6('0x31')]===_0x10f6('0x32')&&_0x18447b[_0x10f6('0x3a')][_0x10f6('0x33')]){_0x18447b[_0x10f6('0x3a')][_0x10f6('0x33')]=encryptor[_0x10f6('0x41')](_0x18447b[_0x10f6('0x3a')][_0x10f6('0x33')]);}return _0x51df38;})[_0x10f6('0x15')](saveUpdates(_0x18447b['body'],null))[_0x10f6('0x15')](respondWithResult(_0x37f2f9,null))[_0x10f6('0x34')](handleError(_0x37f2f9,null));};exports[_0x10f6('0x45')]=function(_0xb4100c,_0x1c1c2e){return db[_0x10f6('0x19')]['find']({'where':{'id':_0xb4100c['params']['id']}})[_0x10f6('0x15')](handleEntityNotFound(_0x1c1c2e,null))[_0x10f6('0x15')](removeEntity(_0x1c1c2e,null))[_0x10f6('0x34')](handleError(_0x1c1c2e,null));};exports[_0x10f6('0x46')]=function(_0x29204d,_0x5d5404){return db[_0x10f6('0x19')][_0x10f6('0x47')]({'where':{'id':_0x29204d[_0x10f6('0x44')]['id']},'raw':!![]})[_0x10f6('0x15')](function(_0x5a324e){if(!_0x5a324e)return _0x5d5404['sendStatus'](0x194);return{'url':oauth['generateMicrosoftAuthorizationUrl'](_0x5a324e,_0x29204d[_0x10f6('0x48')]['id'])};})[_0x10f6('0x15')](respondWithResult(_0x5d5404,null))[_0x10f6('0x34')](handleError(_0x5d5404,null));};exports['oauth2MicrosoftCallback']=function(_0x13b317,_0x3ad42c){var _0x3fb6c9=_0x13b317[_0x10f6('0x3a')];var _0x3454aa;var _0x90cf29;if(_0x3fb6c9[_0x10f6('0x16')])throw _0x3fb6c9;redis[_0x10f6('0x49')](_0x3fb6c9[_0x10f6('0x4a')])[_0x10f6('0x15')](function(_0x30fad7){if(!_0x30fad7)throw new Error(_0x10f6('0x4b'));_0x3454aa=JSON[_0x10f6('0x4c')](_0x30fad7);var _0x49debe=Buffer['from'](_0x3fb6c9['state'],_0x10f6('0x4d'))[_0x10f6('0x4e')](_0x10f6('0x4f'));_0x90cf29=JSON[_0x10f6('0x4c')](_0x49debe);if(!oauth[_0x10f6('0x50')](_0x3fb6c9['id_token'],_0x3454aa[_0x10f6('0x51')]))throw new Error(_0x10f6('0x52'));redis['del'](_0x3fb6c9[_0x10f6('0x4a')]);return oauth[_0x10f6('0x53')](_0x3fb6c9[_0x10f6('0x54')],_0x3454aa);})[_0x10f6('0x15')](function(_0x69283c){_0x3454aa[_0x10f6('0x55')]=_0x69283c['access_token'];_0x3454aa[_0x10f6('0x56')]=_0x69283c[_0x10f6('0x57')];return db['CloudProvider']['update']({'data5':_0x3454aa[_0x10f6('0x55')],'data6':_0x3454aa[_0x10f6('0x56')]},{'where':{'id':_0x3454aa['id']}});})[_0x10f6('0x15')](function(){oauth[_0x10f6('0x58')](_0x3454aa);socket['emit']('microsoftAuthorization:success',{'id':_0x90cf29['id']});return;})[_0x10f6('0x15')](respondWithStatusCode(_0x3ad42c,null))['catch'](function(_0x4192a8){if(_0x90cf29){socket[_0x10f6('0x59')]('microsoftAuthorization:error',{'id':_0x90cf29['id']});}if(!_0x3454aa){logger['error']('Invalid\x20authentication\x20state\x20parameter',_0x4192a8);return _0x3ad42c[_0x10f6('0xd')](0x1f4)['send'](_0x4192a8['message']);}logger[_0x10f6('0x16')]('Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s',_0x3454aa['id'],JSON['stringify'](_0x4192a8));});};
\ No newline at end of file