Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 712bb66..be59f07 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x97cf=['oauth2MicrosoftCallback','get','state','Invalid\x20state\x20parameter','parse','from','base64','ascii','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','getOauth2MicrosoftAccessToken','data6','data5','startRefreshInterval','microsoftAuthorization:success','emit','microsoftAuthorization:error','Invalid\x20authentication\x20state\x20parameter','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','../../components/encryptor','../../config/environment','../../config/logger','api','../../mysqldb','./cloudProvider.oauth','redis','defaults','localhost','socket.io-emitter','status','end','json','offset','limit','undefined','count','set','Content-Range','update','then','destroy','error','name','send','padEnd','index','map','CloudProvider','rawAttributes','fieldName','type','key','model','query','keys','attributes','fields','length','hasOwnProperty','where','filters','filter','merge','options','includeAll','include','findAll','rows','service','MicrosoftAzure','data3','catch','show','params','intersection','find','decryptString','create','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','encryptString','oauth2MicrosoftAuthorize','findOne','sendStatus','generateMicrosoftAuthorizationUrl','user'];(function(_0x22bf78,_0x37c854){var _0x2d5ceb=function(_0x1f091f){while(--_0x1f091f){_0x22bf78['push'](_0x22bf78['shift']());}};_0x2d5ceb(++_0x37c854);}(_0x97cf,0x133));var _0xf97c=function(_0x368abe,_0x263c91){_0x368abe=_0x368abe-0x0;var _0x43a451=_0x97cf[_0x368abe];return _0x43a451;};'use strict';var _=require(_0xf97c('0x0'));var Redis=require('ioredis');var qs=require('../../components/parsers/qs');var encryptor=require(_0xf97c('0x1'));var config=require(_0xf97c('0x2'));var logger=require(_0xf97c('0x3'))(_0xf97c('0x4'));var db=require(_0xf97c('0x5'))['db'];var oauth=require(_0xf97c('0x6'));config[_0xf97c('0x7')]=_[_0xf97c('0x8')](config[_0xf97c('0x7')],{'host':_0xf97c('0x9'),'port':0x18eb});var socket=require(_0xf97c('0xa'))(new Redis(config[_0xf97c('0x7')]));var redis=new Redis(config[_0xf97c('0x7')]);function respondWithStatusCode(_0x57e279,_0x333085){_0x333085=_0x333085||0xcc;return function(_0x102a5c){if(_0x102a5c){return _0x57e279['sendStatus'](_0x333085);}return _0x57e279[_0xf97c('0xb')](_0x333085)[_0xf97c('0xc')]();};}function respondWithResult(_0x91b2bc,_0x2c441c){_0x2c441c=_0x2c441c||0xc8;return function(_0x588a59){if(_0x588a59){return _0x91b2bc[_0xf97c('0xb')](_0x2c441c)[_0xf97c('0xd')](_0x588a59);}};}function respondWithFilteredResult(_0x14f4b5,_0x46d625){return function(_0x241f6a){if(_0x241f6a){var _0x4a2476=typeof _0x46d625[_0xf97c('0xe')]==='undefined'&&typeof _0x46d625[_0xf97c('0xf')]===_0xf97c('0x10');var _0x1b0448=_0x241f6a[_0xf97c('0x11')];var _0x54254e=_0x4a2476?0x0:_0x46d625[_0xf97c('0xe')];var _0x1fb581=_0x4a2476?_0x241f6a[_0xf97c('0x11')]:_0x46d625[_0xf97c('0xe')]+_0x46d625[_0xf97c('0xf')];var _0x508d8b;if(_0x1fb581>=_0x1b0448){_0x1fb581=_0x1b0448;_0x508d8b=0xc8;}else{_0x508d8b=0xce;}_0x14f4b5[_0xf97c('0xb')](_0x508d8b);return _0x14f4b5[_0xf97c('0x12')](_0xf97c('0x13'),_0x54254e+'-'+_0x1fb581+'/'+_0x1b0448)[_0xf97c('0xd')](_0x241f6a);}return null;};}function saveUpdates(_0x53479b){return function(_0x32bb77){if(_0x32bb77){return _0x32bb77[_0xf97c('0x14')](_0x53479b)[_0xf97c('0x15')](function(_0x14aeaa){return _0x14aeaa;});}return null;};}function removeEntity(_0x9c46fd){return function(_0x1e3ab9){if(_0x1e3ab9){return _0x1e3ab9[_0xf97c('0x16')]()[_0xf97c('0x15')](function(){_0x9c46fd['status'](0xcc)[_0xf97c('0xc')]();});}};}function handleEntityNotFound(_0x653bad){return function(_0x1d7377){if(!_0x1d7377){_0x653bad['sendStatus'](0x194);}return _0x1d7377;};}function handleError(_0x41e07e,_0x54edc1){_0x54edc1=_0x54edc1||0x1f4;return function(_0x1a747a){logger[_0xf97c('0x17')](_0x1a747a['stack']);if(_0x1a747a['name']){delete _0x1a747a[_0xf97c('0x18')];}_0x41e07e[_0xf97c('0xb')](_0x54edc1)[_0xf97c('0x19')](_0x1a747a);};}function maskClientSecret(_0x4925ef){return _[_0xf97c('0x1a')](_0x4925ef['slice'](0x0,0x3),0x14,'*');}exports[_0xf97c('0x1b')]=function(_0x1929cf,_0x22a3d7){var _0x240a44={},_0x439448={},_0xf8a112={'count':0x0,'rows':[]};var _0x18f66e=_[_0xf97c('0x1c')](db[_0xf97c('0x1d')][_0xf97c('0x1e')],function(_0x28ff47){return{'name':_0x28ff47[_0xf97c('0x1f')],'type':_0x28ff47[_0xf97c('0x20')][_0xf97c('0x21')]};});_0x439448[_0xf97c('0x22')]=_[_0xf97c('0x1c')](_0x18f66e,'name');_0x439448[_0xf97c('0x23')]=_[_0xf97c('0x24')](_0x1929cf['query']);_0x439448['filters']=_['intersection'](_0x439448['model'],_0x439448[_0xf97c('0x23')]);_0x240a44[_0xf97c('0x25')]=_['intersection'](_0x439448['model'],qs[_0xf97c('0x26')](_0x1929cf[_0xf97c('0x23')][_0xf97c('0x26')]));_0x240a44[_0xf97c('0x25')]=_0x240a44[_0xf97c('0x25')][_0xf97c('0x27')]?_0x240a44['attributes']:_0x439448[_0xf97c('0x22')];if(!_0x1929cf[_0xf97c('0x23')][_0xf97c('0x28')]('nolimit')){_0x240a44[_0xf97c('0xf')]=qs[_0xf97c('0xf')](_0x1929cf['query'][_0xf97c('0xf')]);_0x240a44['offset']=qs[_0xf97c('0xe')](_0x1929cf[_0xf97c('0x23')][_0xf97c('0xe')]);}_0x240a44['order']=qs['sort'](_0x1929cf[_0xf97c('0x23')]['sort']);_0x240a44[_0xf97c('0x29')]=qs['filters'](_['pick'](_0x1929cf[_0xf97c('0x23')],_0x439448[_0xf97c('0x2a')]),_0x18f66e);if(_0x1929cf['query'][_0xf97c('0x2b')]){_0x240a44[_0xf97c('0x29')]=_[_0xf97c('0x2c')](_0x240a44[_0xf97c('0x29')],{'$or':_[_0xf97c('0x1c')](_0x18f66e,function(_0x46d50c){if(_0x46d50c[_0xf97c('0x20')]!=='VIRTUAL'){var _0x5c12bb={};_0x5c12bb[_0x46d50c[_0xf97c('0x18')]]={'$like':'%'+_0x1929cf[_0xf97c('0x23')]['filter']+'%'};return _0x5c12bb;}})});}_0x240a44=_[_0xf97c('0x2c')]({},_0x240a44,_0x1929cf[_0xf97c('0x2d')]);var _0x399859={'where':_0x240a44[_0xf97c('0x29')]};return db[_0xf97c('0x1d')][_0xf97c('0x11')](_0x399859)[_0xf97c('0x15')](function(_0x579cab){_0xf8a112['count']=_0x579cab;if(_0x1929cf['query'][_0xf97c('0x2e')]){_0x240a44[_0xf97c('0x2f')]=[{'all':!![]}];}return db[_0xf97c('0x1d')][_0xf97c('0x30')](_0x240a44);})[_0xf97c('0x15')](function(_0x5ee765){_0xf8a112[_0xf97c('0x31')]=_[_0xf97c('0x1c')](_0x5ee765,function(_0x3606e7){if(_0x3606e7[_0xf97c('0x32')]===_0xf97c('0x33')){var _0x48e74d=encryptor['decryptString'](_0x3606e7[_0xf97c('0x34')]);_0x3606e7[_0xf97c('0x34')]=maskClientSecret(_0x48e74d);}return _0x3606e7;});return _0xf8a112;})[_0xf97c('0x15')](respondWithFilteredResult(_0x22a3d7,_0x240a44))[_0xf97c('0x35')](handleError(_0x22a3d7,null));};exports[_0xf97c('0x36')]=function(_0x4d9504,_0x12f078){var _0x3da6b9={'raw':!![],'where':{'id':_0x4d9504[_0xf97c('0x37')]['id']}},_0x5510ce={};_0x5510ce[_0xf97c('0x22')]=_[_0xf97c('0x24')](db[_0xf97c('0x1d')][_0xf97c('0x1e')]);_0x5510ce[_0xf97c('0x23')]=_[_0xf97c('0x24')](_0x4d9504[_0xf97c('0x23')]);_0x5510ce[_0xf97c('0x2a')]=_[_0xf97c('0x38')](_0x5510ce[_0xf97c('0x22')],_0x5510ce[_0xf97c('0x23')]);_0x3da6b9['attributes']=_['intersection'](_0x5510ce[_0xf97c('0x22')],qs[_0xf97c('0x26')](_0x4d9504['query'][_0xf97c('0x26')]));_0x3da6b9[_0xf97c('0x25')]=_0x3da6b9[_0xf97c('0x25')][_0xf97c('0x27')]?_0x3da6b9[_0xf97c('0x25')]:_0x5510ce['model'];if(_0x4d9504[_0xf97c('0x23')][_0xf97c('0x2e')]){_0x3da6b9['include']=[{'all':!![]}];}_0x3da6b9=_[_0xf97c('0x2c')]({},_0x3da6b9,_0x4d9504[_0xf97c('0x2d')]);return db[_0xf97c('0x1d')][_0xf97c('0x39')](_0x3da6b9)[_0xf97c('0x15')](handleEntityNotFound(_0x12f078,null))[_0xf97c('0x15')](function(_0x18c702){if(_0x18c702['service']===_0xf97c('0x33')){var _0x2776dc=encryptor[_0xf97c('0x3a')](_0x18c702[_0xf97c('0x34')]);_0x18c702[_0xf97c('0x34')]=maskClientSecret(_0x2776dc);}return _0x18c702;})[_0xf97c('0x15')](respondWithResult(_0x12f078,null))['catch'](handleError(_0x12f078,null));};exports[_0xf97c('0x3b')]=function(_0x48f103,_0x117dbc){if(!_0x48f103[_0xf97c('0x3c')][_0xf97c('0x18')])throw new Error(_0xf97c('0x3d'));if(!_0x48f103['body'][_0xf97c('0x32')])throw new Error(_0xf97c('0x3e'));var _0x52f734=db[_0xf97c('0x1d')][_0xf97c('0x1e')][_0xf97c('0x32')][_0xf97c('0x3f')];if(!_0x52f734[_0xf97c('0x40')](_0x48f103[_0xf97c('0x3c')]['service']))throw new Error(_0xf97c('0x41')+_0x52f734[_0xf97c('0x42')](',\x20'));if(_0x48f103[_0xf97c('0x3c')][_0xf97c('0x32')]==='MicrosoftAzure'&&_0x48f103[_0xf97c('0x3c')][_0xf97c('0x34')]){_0x48f103[_0xf97c('0x3c')][_0xf97c('0x34')]=encryptor['encryptString'](_0x48f103[_0xf97c('0x3c')][_0xf97c('0x34')]);}return db[_0xf97c('0x1d')][_0xf97c('0x3b')](_0x48f103[_0xf97c('0x3c')],{})[_0xf97c('0x15')](respondWithResult(_0x117dbc,0xc9))[_0xf97c('0x35')](handleError(_0x117dbc,null));};exports['update']=function(_0xbe5c9a,_0x29dad4){if(_0xbe5c9a[_0xf97c('0x3c')]['id']){delete _0xbe5c9a[_0xf97c('0x3c')]['id'];}return db[_0xf97c('0x1d')]['find']({'where':{'id':_0xbe5c9a['params']['id']}})['then'](handleEntityNotFound(_0x29dad4,null))[_0xf97c('0x15')](function(_0x490a58){if(_0x490a58[_0xf97c('0x32')]==='MicrosoftAzure'&&_0xbe5c9a[_0xf97c('0x3c')][_0xf97c('0x34')]){_0xbe5c9a[_0xf97c('0x3c')][_0xf97c('0x34')]=encryptor[_0xf97c('0x43')](_0xbe5c9a[_0xf97c('0x3c')][_0xf97c('0x34')]);}return _0x490a58;})['then'](saveUpdates(_0xbe5c9a[_0xf97c('0x3c')],null))[_0xf97c('0x15')](respondWithResult(_0x29dad4,null))[_0xf97c('0x35')](handleError(_0x29dad4,null));};exports[_0xf97c('0x16')]=function(_0x3efd7e,_0x11c8c2){return db[_0xf97c('0x1d')][_0xf97c('0x39')]({'where':{'id':_0x3efd7e[_0xf97c('0x37')]['id']}})[_0xf97c('0x15')](handleEntityNotFound(_0x11c8c2,null))[_0xf97c('0x15')](removeEntity(_0x11c8c2,null))['catch'](handleError(_0x11c8c2,null));};exports[_0xf97c('0x44')]=function(_0x4c4d83,_0x3c2173){return db['CloudProvider'][_0xf97c('0x45')]({'where':{'id':_0x4c4d83[_0xf97c('0x37')]['id']},'raw':!![]})[_0xf97c('0x15')](function(_0x546c9c){if(!_0x546c9c)return _0x3c2173[_0xf97c('0x46')](0x194);return{'url':oauth[_0xf97c('0x47')](_0x546c9c,_0x4c4d83[_0xf97c('0x48')]['id'])};})[_0xf97c('0x15')](respondWithResult(_0x3c2173,null))[_0xf97c('0x35')](handleError(_0x3c2173,null));};exports[_0xf97c('0x49')]=function(_0x1a3d2e,_0x3d8d89){var _0x333e8e=_0x1a3d2e[_0xf97c('0x3c')];var _0x1ceda2;var _0x483a80;if(_0x333e8e[_0xf97c('0x17')])throw _0x333e8e;redis[_0xf97c('0x4a')](_0x333e8e[_0xf97c('0x4b')])['then'](function(_0x3b622e){if(!_0x3b622e)throw new Error(_0xf97c('0x4c'));_0x1ceda2=JSON[_0xf97c('0x4d')](_0x3b622e);var _0x4f32d8=Buffer[_0xf97c('0x4e')](_0x333e8e['state'],_0xf97c('0x4f'))['toString'](_0xf97c('0x50'));_0x483a80=JSON[_0xf97c('0x4d')](_0x4f32d8);if(!oauth['isValidIdToken'](_0x333e8e[_0xf97c('0x51')],_0x1ceda2[_0xf97c('0x52')]))throw new Error(_0xf97c('0x53'));redis[_0xf97c('0x54')](_0x333e8e[_0xf97c('0x4b')]);return oauth[_0xf97c('0x55')](_0x333e8e['code'],_0x1ceda2);})[_0xf97c('0x15')](function(_0x25bb9d){_0x1ceda2['data5']=_0x25bb9d['access_token'];_0x1ceda2[_0xf97c('0x56')]=_0x25bb9d['refresh_token'];return db[_0xf97c('0x1d')][_0xf97c('0x14')]({'data5':_0x1ceda2[_0xf97c('0x57')],'data6':_0x1ceda2[_0xf97c('0x56')]},{'where':{'id':_0x1ceda2['id']}});})[_0xf97c('0x15')](function(){oauth[_0xf97c('0x58')](_0x1ceda2);socket['emit'](_0xf97c('0x59'),{'id':_0x483a80['id']});return;})['then'](respondWithStatusCode(_0x3d8d89,null))[_0xf97c('0x35')](function(_0x2a9ccb){if(_0x483a80){socket[_0xf97c('0x5a')](_0xf97c('0x5b'),{'id':_0x483a80['id']});}if(!_0x1ceda2){logger[_0xf97c('0x17')](_0xf97c('0x5c'),_0x2a9ccb);return _0x3d8d89[_0xf97c('0xb')](0x1f4)[_0xf97c('0x19')](_0x2a9ccb['message']);}logger[_0xf97c('0x17')](_0xf97c('0x5d'),_0x1ceda2['id'],JSON[_0xf97c('0x5e')](_0x2a9ccb));});};
\ No newline at end of file
+var _0x3d3a=['keys','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','service','MicrosoftAzure','decryptString','data3','catch','show','params','rawAttributes','includeAll','create','body','Service\x20parameter\x20not\x20specified','values','includes','encryptString','destroy','find','findOne','error','get','state','Invalid\x20state\x20parameter','from','base64','toString','ascii','isValidIdToken','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','getOauth2MicrosoftAccessToken','data5','access_token','data6','refresh_token','startRefreshInterval','emit','Invalid\x20authentication\x20state\x20parameter','message','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','lodash','ioredis','../../components/parsers/qs','../../config/environment','../../mysqldb','./cloudProvider.oauth','redis','defaults','localhost','socket.io-emitter','sendStatus','status','json','undefined','limit','count','offset','set','update','then','end','stack','name','send','index','map','CloudProvider','fieldName','type','key','query'];(function(_0x3bc3b4,_0x5acff4){var _0x4c546b=function(_0x158717){while(--_0x158717){_0x3bc3b4['push'](_0x3bc3b4['shift']());}};_0x4c546b(++_0x5acff4);}(_0x3d3a,0x1a3));var _0xa3d3=function(_0x503c5a,_0x269d5d){_0x503c5a=_0x503c5a-0x0;var _0x2b92b3=_0x3d3a[_0x503c5a];return _0x2b92b3;};'use strict';var _=require(_0xa3d3('0x0'));var Redis=require(_0xa3d3('0x1'));var qs=require(_0xa3d3('0x2'));var encryptor=require('../../components/encryptor');var config=require(_0xa3d3('0x3'));var logger=require('../../config/logger')('api');var db=require(_0xa3d3('0x4'))['db'];var oauth=require(_0xa3d3('0x5'));config[_0xa3d3('0x6')]=_[_0xa3d3('0x7')](config['redis'],{'host':_0xa3d3('0x8'),'port':0x18eb});var socket=require(_0xa3d3('0x9'))(new Redis(config[_0xa3d3('0x6')]));var redis=new Redis(config['redis']);function respondWithStatusCode(_0x113465,_0x15e168){_0x15e168=_0x15e168||0xcc;return function(_0x40615f){if(_0x40615f){return _0x113465[_0xa3d3('0xa')](_0x15e168);}return _0x113465[_0xa3d3('0xb')](_0x15e168)['end']();};}function respondWithResult(_0x17cba0,_0x54ed2b){_0x54ed2b=_0x54ed2b||0xc8;return function(_0x39f7f2){if(_0x39f7f2){return _0x17cba0[_0xa3d3('0xb')](_0x54ed2b)[_0xa3d3('0xc')](_0x39f7f2);}};}function respondWithFilteredResult(_0x4d55e5,_0x3dd3fc){return function(_0x3893da){if(_0x3893da){var _0x520e55=typeof _0x3dd3fc['offset']===_0xa3d3('0xd')&&typeof _0x3dd3fc[_0xa3d3('0xe')]===_0xa3d3('0xd');var _0x1b1f08=_0x3893da[_0xa3d3('0xf')];var _0x5d4335=_0x520e55?0x0:_0x3dd3fc[_0xa3d3('0x10')];var _0xd4c759=_0x520e55?_0x3893da['count']:_0x3dd3fc[_0xa3d3('0x10')]+_0x3dd3fc[_0xa3d3('0xe')];var _0x5d25dc;if(_0xd4c759>=_0x1b1f08){_0xd4c759=_0x1b1f08;_0x5d25dc=0xc8;}else{_0x5d25dc=0xce;}_0x4d55e5[_0xa3d3('0xb')](_0x5d25dc);return _0x4d55e5[_0xa3d3('0x11')]('Content-Range',_0x5d4335+'-'+_0xd4c759+'/'+_0x1b1f08)['json'](_0x3893da);}return null;};}function saveUpdates(_0x225e08){return function(_0x25d372){if(_0x25d372){return _0x25d372[_0xa3d3('0x12')](_0x225e08)[_0xa3d3('0x13')](function(_0x1a757c){return _0x1a757c;});}return null;};}function removeEntity(_0x44dc90){return function(_0x367fb8){if(_0x367fb8){return _0x367fb8['destroy']()['then'](function(){_0x44dc90['status'](0xcc)[_0xa3d3('0x14')]();});}};}function handleEntityNotFound(_0x393e1f){return function(_0xd4ced2){if(!_0xd4ced2){_0x393e1f[_0xa3d3('0xa')](0x194);}return _0xd4ced2;};}function handleError(_0x115e99,_0x4834b5){_0x4834b5=_0x4834b5||0x1f4;return function(_0x399716){logger['error'](_0x399716[_0xa3d3('0x15')]);if(_0x399716['name']){delete _0x399716[_0xa3d3('0x16')];}_0x115e99['status'](_0x4834b5)[_0xa3d3('0x17')](_0x399716);};}function maskClientSecret(_0x2c6433){return _['padEnd'](_0x2c6433['slice'](0x0,0x3),0x14,'*');}exports[_0xa3d3('0x18')]=function(_0xf8f357,_0x3f76cb){var _0x187c37={},_0x3ed52d={},_0x5834e5={'count':0x0,'rows':[]};var _0xb8e84c=_[_0xa3d3('0x19')](db[_0xa3d3('0x1a')]['rawAttributes'],function(_0x23c2d1){return{'name':_0x23c2d1[_0xa3d3('0x1b')],'type':_0x23c2d1[_0xa3d3('0x1c')][_0xa3d3('0x1d')]};});_0x3ed52d['model']=_[_0xa3d3('0x19')](_0xb8e84c,_0xa3d3('0x16'));_0x3ed52d[_0xa3d3('0x1e')]=_[_0xa3d3('0x1f')](_0xf8f357[_0xa3d3('0x1e')]);_0x3ed52d[_0xa3d3('0x20')]=_[_0xa3d3('0x21')](_0x3ed52d[_0xa3d3('0x22')],_0x3ed52d[_0xa3d3('0x1e')]);_0x187c37[_0xa3d3('0x23')]=_[_0xa3d3('0x21')](_0x3ed52d['model'],qs[_0xa3d3('0x24')](_0xf8f357['query']['fields']));_0x187c37[_0xa3d3('0x23')]=_0x187c37[_0xa3d3('0x23')][_0xa3d3('0x25')]?_0x187c37[_0xa3d3('0x23')]:_0x3ed52d['model'];if(!_0xf8f357[_0xa3d3('0x1e')]['hasOwnProperty'](_0xa3d3('0x26'))){_0x187c37['limit']=qs[_0xa3d3('0xe')](_0xf8f357[_0xa3d3('0x1e')][_0xa3d3('0xe')]);_0x187c37[_0xa3d3('0x10')]=qs[_0xa3d3('0x10')](_0xf8f357['query'][_0xa3d3('0x10')]);}_0x187c37[_0xa3d3('0x27')]=qs[_0xa3d3('0x28')](_0xf8f357[_0xa3d3('0x1e')][_0xa3d3('0x28')]);_0x187c37[_0xa3d3('0x29')]=qs['filters'](_[_0xa3d3('0x2a')](_0xf8f357['query'],_0x3ed52d['filters']),_0xb8e84c);if(_0xf8f357['query'][_0xa3d3('0x2b')]){_0x187c37[_0xa3d3('0x29')]=_[_0xa3d3('0x2c')](_0x187c37[_0xa3d3('0x29')],{'$or':_[_0xa3d3('0x19')](_0xb8e84c,function(_0xa4b43){if(_0xa4b43[_0xa3d3('0x1c')]!==_0xa3d3('0x2d')){var _0xb2ac29={};_0xb2ac29[_0xa4b43[_0xa3d3('0x16')]]={'$like':'%'+_0xf8f357[_0xa3d3('0x1e')][_0xa3d3('0x2b')]+'%'};return _0xb2ac29;}})});}_0x187c37=_['merge']({},_0x187c37,_0xf8f357[_0xa3d3('0x2e')]);var _0x2903cc={'where':_0x187c37['where']};return db['CloudProvider'][_0xa3d3('0xf')](_0x2903cc)[_0xa3d3('0x13')](function(_0x21b3df){_0x5834e5[_0xa3d3('0xf')]=_0x21b3df;if(_0xf8f357[_0xa3d3('0x1e')]['includeAll']){_0x187c37[_0xa3d3('0x2f')]=[{'all':!![]}];}return db[_0xa3d3('0x1a')][_0xa3d3('0x30')](_0x187c37);})[_0xa3d3('0x13')](function(_0x20ad4b){_0x5834e5['rows']=_[_0xa3d3('0x19')](_0x20ad4b,function(_0x4417b4){if(_0x4417b4[_0xa3d3('0x31')]===_0xa3d3('0x32')){var _0x3f9f2d=encryptor[_0xa3d3('0x33')](_0x4417b4[_0xa3d3('0x34')]);_0x4417b4[_0xa3d3('0x34')]=maskClientSecret(_0x3f9f2d);}return _0x4417b4;});return _0x5834e5;})['then'](respondWithFilteredResult(_0x3f76cb,_0x187c37))[_0xa3d3('0x35')](handleError(_0x3f76cb,null));};exports[_0xa3d3('0x36')]=function(_0x1138bc,_0x2c54c7){var _0x47d682={'raw':!![],'where':{'id':_0x1138bc[_0xa3d3('0x37')]['id']}},_0x4da036={};_0x4da036['model']=_[_0xa3d3('0x1f')](db[_0xa3d3('0x1a')][_0xa3d3('0x38')]);_0x4da036['query']=_[_0xa3d3('0x1f')](_0x1138bc[_0xa3d3('0x1e')]);_0x4da036[_0xa3d3('0x20')]=_[_0xa3d3('0x21')](_0x4da036[_0xa3d3('0x22')],_0x4da036[_0xa3d3('0x1e')]);_0x47d682['attributes']=_[_0xa3d3('0x21')](_0x4da036['model'],qs[_0xa3d3('0x24')](_0x1138bc[_0xa3d3('0x1e')][_0xa3d3('0x24')]));_0x47d682[_0xa3d3('0x23')]=_0x47d682[_0xa3d3('0x23')]['length']?_0x47d682['attributes']:_0x4da036[_0xa3d3('0x22')];if(_0x1138bc[_0xa3d3('0x1e')][_0xa3d3('0x39')]){_0x47d682[_0xa3d3('0x2f')]=[{'all':!![]}];}_0x47d682=_[_0xa3d3('0x2c')]({},_0x47d682,_0x1138bc[_0xa3d3('0x2e')]);return db[_0xa3d3('0x1a')]['find'](_0x47d682)[_0xa3d3('0x13')](handleEntityNotFound(_0x2c54c7,null))[_0xa3d3('0x13')](function(_0x555a09){if(_0x555a09[_0xa3d3('0x31')]===_0xa3d3('0x32')){var _0x44a35e=encryptor[_0xa3d3('0x33')](_0x555a09[_0xa3d3('0x34')]);_0x555a09[_0xa3d3('0x34')]=maskClientSecret(_0x44a35e);}return _0x555a09;})[_0xa3d3('0x13')](respondWithResult(_0x2c54c7,null))['catch'](handleError(_0x2c54c7,null));};exports[_0xa3d3('0x3a')]=function(_0x4a3fb3,_0x160fe3){if(!_0x4a3fb3[_0xa3d3('0x3b')][_0xa3d3('0x16')])throw new Error('Name\x20parameter\x20not\x20specified');if(!_0x4a3fb3[_0xa3d3('0x3b')]['service'])throw new Error(_0xa3d3('0x3c'));var _0x1658ec=db[_0xa3d3('0x1a')][_0xa3d3('0x38')]['service'][_0xa3d3('0x3d')];if(!_0x1658ec[_0xa3d3('0x3e')](_0x4a3fb3[_0xa3d3('0x3b')][_0xa3d3('0x31')]))throw new Error('Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20'+_0x1658ec['join'](',\x20'));if(_0x4a3fb3['body'][_0xa3d3('0x31')]==='MicrosoftAzure'&&_0x4a3fb3['body']['data3']){_0x4a3fb3[_0xa3d3('0x3b')]['data3']=encryptor['encryptString'](_0x4a3fb3[_0xa3d3('0x3b')]['data3']);}return db['CloudProvider'][_0xa3d3('0x3a')](_0x4a3fb3[_0xa3d3('0x3b')],{})[_0xa3d3('0x13')](respondWithResult(_0x160fe3,0xc9))['catch'](handleError(_0x160fe3,null));};exports['update']=function(_0x4f874c,_0x451f08){if(_0x4f874c['body']['id']){delete _0x4f874c[_0xa3d3('0x3b')]['id'];}return db[_0xa3d3('0x1a')]['find']({'where':{'id':_0x4f874c[_0xa3d3('0x37')]['id']}})['then'](handleEntityNotFound(_0x451f08,null))[_0xa3d3('0x13')](function(_0x38c697){if(_0x38c697[_0xa3d3('0x31')]==='MicrosoftAzure'&&_0x4f874c['body'][_0xa3d3('0x34')]){_0x4f874c[_0xa3d3('0x3b')][_0xa3d3('0x34')]=encryptor[_0xa3d3('0x3f')](_0x4f874c['body'][_0xa3d3('0x34')]);}return _0x38c697;})[_0xa3d3('0x13')](saveUpdates(_0x4f874c[_0xa3d3('0x3b')],null))[_0xa3d3('0x13')](respondWithResult(_0x451f08,null))[_0xa3d3('0x35')](handleError(_0x451f08,null));};exports[_0xa3d3('0x40')]=function(_0x1d70d7,_0x434b7e){return db[_0xa3d3('0x1a')][_0xa3d3('0x41')]({'where':{'id':_0x1d70d7[_0xa3d3('0x37')]['id']}})[_0xa3d3('0x13')](handleEntityNotFound(_0x434b7e,null))[_0xa3d3('0x13')](removeEntity(_0x434b7e,null))[_0xa3d3('0x35')](handleError(_0x434b7e,null));};exports['oauth2MicrosoftAuthorize']=function(_0x4de710,_0x1a286b){return db[_0xa3d3('0x1a')][_0xa3d3('0x42')]({'where':{'id':_0x4de710[_0xa3d3('0x37')]['id']},'raw':!![]})['then'](function(_0x977597){if(!_0x977597)return _0x1a286b[_0xa3d3('0xa')](0x194);return{'url':oauth['generateMicrosoftAuthorizationUrl'](_0x977597,_0x4de710['user']['id'])};})['then'](respondWithResult(_0x1a286b,null))['catch'](handleError(_0x1a286b,null));};exports['oauth2MicrosoftCallback']=function(_0x37025f,_0x136fb5){var _0x56177f=_0x37025f[_0xa3d3('0x3b')];var _0x243928;var _0x37be6f;if(_0x56177f[_0xa3d3('0x43')])throw _0x56177f;redis[_0xa3d3('0x44')](_0x56177f[_0xa3d3('0x45')])['then'](function(_0x59d008){if(!_0x59d008)throw new Error(_0xa3d3('0x46'));_0x243928=JSON['parse'](_0x59d008);var _0x56d57a=Buffer[_0xa3d3('0x47')](_0x56177f['state'],_0xa3d3('0x48'))[_0xa3d3('0x49')](_0xa3d3('0x4a'));_0x37be6f=JSON['parse'](_0x56d57a);if(!oauth[_0xa3d3('0x4b')](_0x56177f[_0xa3d3('0x4c')],_0x243928[_0xa3d3('0x4d')]))throw new Error(_0xa3d3('0x4e'));redis[_0xa3d3('0x4f')](_0x56177f[_0xa3d3('0x45')]);return oauth[_0xa3d3('0x50')](_0x56177f['code'],_0x243928);})[_0xa3d3('0x13')](function(_0x11cad2){_0x243928[_0xa3d3('0x51')]=_0x11cad2[_0xa3d3('0x52')];_0x243928[_0xa3d3('0x53')]=_0x11cad2[_0xa3d3('0x54')];return db[_0xa3d3('0x1a')][_0xa3d3('0x12')]({'data5':_0x243928[_0xa3d3('0x51')],'data6':_0x243928['data6']},{'where':{'id':_0x243928['id']}});})[_0xa3d3('0x13')](function(){oauth[_0xa3d3('0x55')](_0x243928);socket['emit']('microsoftAuthorization:success',{'id':_0x37be6f['id']});return;})['then'](respondWithStatusCode(_0x136fb5,null))[_0xa3d3('0x35')](function(_0x1fead8){if(_0x37be6f){socket[_0xa3d3('0x56')]('microsoftAuthorization:error',{'id':_0x37be6f['id']});}if(!_0x243928){logger[_0xa3d3('0x43')](_0xa3d3('0x57'),_0x1fead8);return _0x136fb5['status'](0x1f4)[_0xa3d3('0x17')](_0x1fead8[_0xa3d3('0x58')]);}logger[_0xa3d3('0x43')](_0xa3d3('0x59'),_0x243928['id'],JSON['stringify'](_0x1fead8));});};
\ No newline at end of file