Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 712bb66..1024d35 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 _0x7f2f=['filter','type','VIRTUAL','merge','options','includeAll','include','findAll','rows','MicrosoftAzure','data3','show','params','keys','rawAttributes','service','decryptString','catch','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','encryptString','create','find','oauth2MicrosoftAuthorize','generateMicrosoftAuthorizationUrl','error','get','state','Invalid\x20state\x20parameter','parse','toString','isValidIdToken','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','getOauth2MicrosoftAccessToken','code','data5','data6','refresh_token','startRefreshInterval','emit','microsoftAuthorization:success','microsoftAuthorization:error','stringify','../../components/encryptor','../../config/environment','../../config/logger','api','./cloudProvider.oauth','redis','defaults','socket.io-emitter','end','status','offset','undefined','limit','count','set','Content-Range','json','update','destroy','then','sendStatus','stack','name','send','padEnd','index','map','CloudProvider','fieldName','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick'];(function(_0x1226ee,_0x1d772c){var _0x1a7739=function(_0x129817){while(--_0x129817){_0x1226ee['push'](_0x1226ee['shift']());}};_0x1a7739(++_0x1d772c);}(_0x7f2f,0xec));var _0xf7f2=function(_0x13e9d4,_0x25483d){_0x13e9d4=_0x13e9d4-0x0;var _0x2c62b8=_0x7f2f[_0x13e9d4];return _0x2c62b8;};'use strict';var _=require('lodash');var Redis=require('ioredis');var qs=require('../../components/parsers/qs');var encryptor=require(_0xf7f2('0x0'));var config=require(_0xf7f2('0x1'));var logger=require(_0xf7f2('0x2'))(_0xf7f2('0x3'));var db=require('../../mysqldb')['db'];var oauth=require(_0xf7f2('0x4'));config[_0xf7f2('0x5')]=_[_0xf7f2('0x6')](config[_0xf7f2('0x5')],{'host':'localhost','port':0x18eb});var socket=require(_0xf7f2('0x7'))(new Redis(config['redis']));var redis=new Redis(config[_0xf7f2('0x5')]);function respondWithStatusCode(_0x3c9f1d,_0x1fbbdb){_0x1fbbdb=_0x1fbbdb||0xcc;return function(_0x5ce4a9){if(_0x5ce4a9){return _0x3c9f1d['sendStatus'](_0x1fbbdb);}return _0x3c9f1d['status'](_0x1fbbdb)[_0xf7f2('0x8')]();};}function respondWithResult(_0xb2763f,_0x39954d){_0x39954d=_0x39954d||0xc8;return function(_0x3c78c3){if(_0x3c78c3){return _0xb2763f[_0xf7f2('0x9')](_0x39954d)['json'](_0x3c78c3);}};}function respondWithFilteredResult(_0x3e1a77,_0xdc5d02){return function(_0x2db9a0){if(_0x2db9a0){var _0x2f88fe=typeof _0xdc5d02[_0xf7f2('0xa')]===_0xf7f2('0xb')&&typeof _0xdc5d02[_0xf7f2('0xc')]===_0xf7f2('0xb');var _0x80cce6=_0x2db9a0[_0xf7f2('0xd')];var _0x47438a=_0x2f88fe?0x0:_0xdc5d02[_0xf7f2('0xa')];var _0xf3f072=_0x2f88fe?_0x2db9a0[_0xf7f2('0xd')]:_0xdc5d02['offset']+_0xdc5d02[_0xf7f2('0xc')];var _0x3418ab;if(_0xf3f072>=_0x80cce6){_0xf3f072=_0x80cce6;_0x3418ab=0xc8;}else{_0x3418ab=0xce;}_0x3e1a77[_0xf7f2('0x9')](_0x3418ab);return _0x3e1a77[_0xf7f2('0xe')](_0xf7f2('0xf'),_0x47438a+'-'+_0xf3f072+'/'+_0x80cce6)[_0xf7f2('0x10')](_0x2db9a0);}return null;};}function saveUpdates(_0x524f05){return function(_0x142a00){if(_0x142a00){return _0x142a00[_0xf7f2('0x11')](_0x524f05)['then'](function(_0x21fad8){return _0x21fad8;});}return null;};}function removeEntity(_0x5391a4){return function(_0xd92251){if(_0xd92251){return _0xd92251[_0xf7f2('0x12')]()[_0xf7f2('0x13')](function(){_0x5391a4[_0xf7f2('0x9')](0xcc)['end']();});}};}function handleEntityNotFound(_0x38e95a){return function(_0x50ecba){if(!_0x50ecba){_0x38e95a[_0xf7f2('0x14')](0x194);}return _0x50ecba;};}function handleError(_0x447394,_0x11e0cc){_0x11e0cc=_0x11e0cc||0x1f4;return function(_0x1f7f86){logger['error'](_0x1f7f86[_0xf7f2('0x15')]);if(_0x1f7f86[_0xf7f2('0x16')]){delete _0x1f7f86[_0xf7f2('0x16')];}_0x447394[_0xf7f2('0x9')](_0x11e0cc)[_0xf7f2('0x17')](_0x1f7f86);};}function maskClientSecret(_0x4d6bdc){return _[_0xf7f2('0x18')](_0x4d6bdc['slice'](0x0,0x3),0x14,'*');}exports[_0xf7f2('0x19')]=function(_0x531e86,_0x3a42d4){var _0x51ae4d={},_0x114722={},_0x17a806={'count':0x0,'rows':[]};var _0x5e40fa=_[_0xf7f2('0x1a')](db[_0xf7f2('0x1b')]['rawAttributes'],function(_0x3639be){return{'name':_0x3639be[_0xf7f2('0x1c')],'type':_0x3639be['type'][_0xf7f2('0x1d')]};});_0x114722[_0xf7f2('0x1e')]=_[_0xf7f2('0x1a')](_0x5e40fa,_0xf7f2('0x16'));_0x114722[_0xf7f2('0x1f')]=_['keys'](_0x531e86['query']);_0x114722[_0xf7f2('0x20')]=_[_0xf7f2('0x21')](_0x114722[_0xf7f2('0x1e')],_0x114722[_0xf7f2('0x1f')]);_0x51ae4d[_0xf7f2('0x22')]=_['intersection'](_0x114722[_0xf7f2('0x1e')],qs['fields'](_0x531e86[_0xf7f2('0x1f')][_0xf7f2('0x23')]));_0x51ae4d[_0xf7f2('0x22')]=_0x51ae4d[_0xf7f2('0x22')][_0xf7f2('0x24')]?_0x51ae4d['attributes']:_0x114722['model'];if(!_0x531e86[_0xf7f2('0x1f')][_0xf7f2('0x25')](_0xf7f2('0x26'))){_0x51ae4d['limit']=qs['limit'](_0x531e86[_0xf7f2('0x1f')]['limit']);_0x51ae4d[_0xf7f2('0xa')]=qs[_0xf7f2('0xa')](_0x531e86[_0xf7f2('0x1f')][_0xf7f2('0xa')]);}_0x51ae4d[_0xf7f2('0x27')]=qs[_0xf7f2('0x28')](_0x531e86[_0xf7f2('0x1f')]['sort']);_0x51ae4d[_0xf7f2('0x29')]=qs[_0xf7f2('0x20')](_[_0xf7f2('0x2a')](_0x531e86[_0xf7f2('0x1f')],_0x114722[_0xf7f2('0x20')]),_0x5e40fa);if(_0x531e86[_0xf7f2('0x1f')][_0xf7f2('0x2b')]){_0x51ae4d[_0xf7f2('0x29')]=_['merge'](_0x51ae4d[_0xf7f2('0x29')],{'$or':_[_0xf7f2('0x1a')](_0x5e40fa,function(_0x42b024){if(_0x42b024[_0xf7f2('0x2c')]!==_0xf7f2('0x2d')){var _0x953f05={};_0x953f05[_0x42b024['name']]={'$like':'%'+_0x531e86[_0xf7f2('0x1f')][_0xf7f2('0x2b')]+'%'};return _0x953f05;}})});}_0x51ae4d=_[_0xf7f2('0x2e')]({},_0x51ae4d,_0x531e86[_0xf7f2('0x2f')]);var _0x48df73={'where':_0x51ae4d[_0xf7f2('0x29')]};return db[_0xf7f2('0x1b')][_0xf7f2('0xd')](_0x48df73)[_0xf7f2('0x13')](function(_0x59f3f8){_0x17a806[_0xf7f2('0xd')]=_0x59f3f8;if(_0x531e86['query'][_0xf7f2('0x30')]){_0x51ae4d[_0xf7f2('0x31')]=[{'all':!![]}];}return db['CloudProvider'][_0xf7f2('0x32')](_0x51ae4d);})[_0xf7f2('0x13')](function(_0x91ecf6){_0x17a806[_0xf7f2('0x33')]=_[_0xf7f2('0x1a')](_0x91ecf6,function(_0x5bee75){if(_0x5bee75['service']===_0xf7f2('0x34')){var _0x1a040e=encryptor['decryptString'](_0x5bee75['data3']);_0x5bee75[_0xf7f2('0x35')]=maskClientSecret(_0x1a040e);}return _0x5bee75;});return _0x17a806;})[_0xf7f2('0x13')](respondWithFilteredResult(_0x3a42d4,_0x51ae4d))['catch'](handleError(_0x3a42d4,null));};exports[_0xf7f2('0x36')]=function(_0x5f1157,_0x3f32c0){var _0x55270e={'raw':!![],'where':{'id':_0x5f1157[_0xf7f2('0x37')]['id']}},_0x1599a2={};_0x1599a2[_0xf7f2('0x1e')]=_[_0xf7f2('0x38')](db[_0xf7f2('0x1b')][_0xf7f2('0x39')]);_0x1599a2['query']=_[_0xf7f2('0x38')](_0x5f1157[_0xf7f2('0x1f')]);_0x1599a2[_0xf7f2('0x20')]=_[_0xf7f2('0x21')](_0x1599a2['model'],_0x1599a2['query']);_0x55270e[_0xf7f2('0x22')]=_[_0xf7f2('0x21')](_0x1599a2[_0xf7f2('0x1e')],qs[_0xf7f2('0x23')](_0x5f1157[_0xf7f2('0x1f')][_0xf7f2('0x23')]));_0x55270e[_0xf7f2('0x22')]=_0x55270e[_0xf7f2('0x22')]['length']?_0x55270e[_0xf7f2('0x22')]:_0x1599a2[_0xf7f2('0x1e')];if(_0x5f1157[_0xf7f2('0x1f')][_0xf7f2('0x30')]){_0x55270e[_0xf7f2('0x31')]=[{'all':!![]}];}_0x55270e=_[_0xf7f2('0x2e')]({},_0x55270e,_0x5f1157[_0xf7f2('0x2f')]);return db[_0xf7f2('0x1b')]['find'](_0x55270e)[_0xf7f2('0x13')](handleEntityNotFound(_0x3f32c0,null))[_0xf7f2('0x13')](function(_0x58b05e){if(_0x58b05e[_0xf7f2('0x3a')]===_0xf7f2('0x34')){var _0x87f75a=encryptor[_0xf7f2('0x3b')](_0x58b05e['data3']);_0x58b05e['data3']=maskClientSecret(_0x87f75a);}return _0x58b05e;})['then'](respondWithResult(_0x3f32c0,null))[_0xf7f2('0x3c')](handleError(_0x3f32c0,null));};exports['create']=function(_0x7a58c4,_0x34a3b5){if(!_0x7a58c4[_0xf7f2('0x3d')][_0xf7f2('0x16')])throw new Error(_0xf7f2('0x3e'));if(!_0x7a58c4[_0xf7f2('0x3d')][_0xf7f2('0x3a')])throw new Error(_0xf7f2('0x3f'));var _0x540072=db[_0xf7f2('0x1b')][_0xf7f2('0x39')][_0xf7f2('0x3a')][_0xf7f2('0x40')];if(!_0x540072[_0xf7f2('0x41')](_0x7a58c4[_0xf7f2('0x3d')][_0xf7f2('0x3a')]))throw new Error(_0xf7f2('0x42')+_0x540072['join'](',\x20'));if(_0x7a58c4['body']['service']==='MicrosoftAzure'&&_0x7a58c4[_0xf7f2('0x3d')][_0xf7f2('0x35')]){_0x7a58c4[_0xf7f2('0x3d')]['data3']=encryptor[_0xf7f2('0x43')](_0x7a58c4[_0xf7f2('0x3d')]['data3']);}return db[_0xf7f2('0x1b')][_0xf7f2('0x44')](_0x7a58c4[_0xf7f2('0x3d')],{})[_0xf7f2('0x13')](respondWithResult(_0x34a3b5,0xc9))[_0xf7f2('0x3c')](handleError(_0x34a3b5,null));};exports[_0xf7f2('0x11')]=function(_0x5b6903,_0x5a80b0){if(_0x5b6903[_0xf7f2('0x3d')]['id']){delete _0x5b6903['body']['id'];}return db[_0xf7f2('0x1b')][_0xf7f2('0x45')]({'where':{'id':_0x5b6903[_0xf7f2('0x37')]['id']}})['then'](handleEntityNotFound(_0x5a80b0,null))['then'](function(_0x11af4a){if(_0x11af4a[_0xf7f2('0x3a')]===_0xf7f2('0x34')&&_0x5b6903[_0xf7f2('0x3d')][_0xf7f2('0x35')]){_0x5b6903[_0xf7f2('0x3d')][_0xf7f2('0x35')]=encryptor[_0xf7f2('0x43')](_0x5b6903['body']['data3']);}return _0x11af4a;})[_0xf7f2('0x13')](saveUpdates(_0x5b6903['body'],null))[_0xf7f2('0x13')](respondWithResult(_0x5a80b0,null))[_0xf7f2('0x3c')](handleError(_0x5a80b0,null));};exports[_0xf7f2('0x12')]=function(_0x1d6a3c,_0x218d9f){return db['CloudProvider'][_0xf7f2('0x45')]({'where':{'id':_0x1d6a3c[_0xf7f2('0x37')]['id']}})[_0xf7f2('0x13')](handleEntityNotFound(_0x218d9f,null))[_0xf7f2('0x13')](removeEntity(_0x218d9f,null))[_0xf7f2('0x3c')](handleError(_0x218d9f,null));};exports[_0xf7f2('0x46')]=function(_0x1adad0,_0x1a7171){return db[_0xf7f2('0x1b')]['findOne']({'where':{'id':_0x1adad0[_0xf7f2('0x37')]['id']},'raw':!![]})[_0xf7f2('0x13')](function(_0x19daab){if(!_0x19daab)return _0x1a7171['sendStatus'](0x194);return{'url':oauth[_0xf7f2('0x47')](_0x19daab,_0x1adad0['user']['id'])};})['then'](respondWithResult(_0x1a7171,null))[_0xf7f2('0x3c')](handleError(_0x1a7171,null));};exports['oauth2MicrosoftCallback']=function(_0x5af852,_0x237d92){var _0x14fba3=_0x5af852['body'];var _0x1b99d9;var _0x329f27;if(_0x14fba3[_0xf7f2('0x48')])throw _0x14fba3;redis[_0xf7f2('0x49')](_0x14fba3[_0xf7f2('0x4a')])[_0xf7f2('0x13')](function(_0x4355f5){if(!_0x4355f5)throw new Error(_0xf7f2('0x4b'));_0x1b99d9=JSON[_0xf7f2('0x4c')](_0x4355f5);var _0x191228=Buffer['from'](_0x14fba3['state'],'base64')[_0xf7f2('0x4d')]('ascii');_0x329f27=JSON['parse'](_0x191228);if(!oauth[_0xf7f2('0x4e')](_0x14fba3[_0xf7f2('0x4f')],_0x1b99d9[_0xf7f2('0x50')]))throw new Error(_0xf7f2('0x51'));redis[_0xf7f2('0x52')](_0x14fba3[_0xf7f2('0x4a')]);return oauth[_0xf7f2('0x53')](_0x14fba3[_0xf7f2('0x54')],_0x1b99d9);})['then'](function(_0x18eb7c){_0x1b99d9[_0xf7f2('0x55')]=_0x18eb7c['access_token'];_0x1b99d9[_0xf7f2('0x56')]=_0x18eb7c[_0xf7f2('0x57')];return db[_0xf7f2('0x1b')]['update']({'data5':_0x1b99d9[_0xf7f2('0x55')],'data6':_0x1b99d9[_0xf7f2('0x56')]},{'where':{'id':_0x1b99d9['id']}});})[_0xf7f2('0x13')](function(){oauth[_0xf7f2('0x58')](_0x1b99d9);socket[_0xf7f2('0x59')](_0xf7f2('0x5a'),{'id':_0x329f27['id']});return;})[_0xf7f2('0x13')](respondWithStatusCode(_0x237d92,null))[_0xf7f2('0x3c')](function(_0xcc4b4e){if(_0x329f27){socket[_0xf7f2('0x59')](_0xf7f2('0x5b'),{'id':_0x329f27['id']});}if(!_0x1b99d9){logger[_0xf7f2('0x48')]('Invalid\x20authentication\x20state\x20parameter',_0xcc4b4e);return _0x237d92[_0xf7f2('0x9')](0x1f4)['send'](_0xcc4b4e['message']);}logger[_0xf7f2('0x48')]('Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s',_0x1b99d9['id'],JSON[_0xf7f2('0x5c')](_0xcc4b4e));});};
\ No newline at end of file