Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 192b9cd..be59f07 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd510=['data5','access_token','data6','refresh_token','microsoftAuthorization:success','Invalid\x20authentication\x20state\x20parameter','message','stringify','lodash','ioredis','../../components/parsers/qs','../../config/environment','../../config/logger','api','../../mysqldb','redis','defaults','localhost','socket.io-emitter','status','offset','undefined','limit','count','set','Content-Range','json','update','destroy','then','end','sendStatus','stack','name','send','padEnd','slice','index','map','fieldName','query','keys','filters','attributes','intersection','model','fields','length','order','sort','where','filter','merge','options','CloudProvider','includeAll','include','findAll','rows','service','MicrosoftAzure','decryptString','data3','show','params','find','catch','create','body','Name\x20parameter\x20not\x20specified','rawAttributes','values','includes','join','encryptString','oauth2MicrosoftAuthorize','generateMicrosoftAuthorizationUrl','user','error','get','state','Invalid\x20state\x20parameter','parse','base64','toString','ascii','isValidIdToken','oauth2Claims','Unable\x20to\x20validate\x20id_token','code'];(function(_0x52e765,_0xf4bd2e){var _0x53cf83=function(_0xc1fb68){while(--_0xc1fb68){_0x52e765['push'](_0x52e765['shift']());}};_0x53cf83(++_0xf4bd2e);}(_0xd510,0xbc));var _0x0d51=function(_0x45b4c3,_0xf3dc72){_0x45b4c3=_0x45b4c3-0x0;var _0x54e82c=_0xd510[_0x45b4c3];return _0x54e82c;};'use strict';var _=require(_0x0d51('0x0'));var Redis=require(_0x0d51('0x1'));var qs=require(_0x0d51('0x2'));var encryptor=require('../../components/encryptor');var config=require(_0x0d51('0x3'));var logger=require(_0x0d51('0x4'))(_0x0d51('0x5'));var db=require(_0x0d51('0x6'))['db'];var oauth=require('./cloudProvider.oauth');config[_0x0d51('0x7')]=_[_0x0d51('0x8')](config[_0x0d51('0x7')],{'host':_0x0d51('0x9'),'port':0x18eb});var socket=require(_0x0d51('0xa'))(new Redis(config[_0x0d51('0x7')]));var redis=new Redis(config[_0x0d51('0x7')]);function respondWithStatusCode(_0x193441,_0x4d02ce){_0x4d02ce=_0x4d02ce||0xcc;return function(_0x197fe7){if(_0x197fe7){return _0x193441['sendStatus'](_0x4d02ce);}return _0x193441[_0x0d51('0xb')](_0x4d02ce)['end']();};}function respondWithResult(_0x426d1e,_0x34dd5f){_0x34dd5f=_0x34dd5f||0xc8;return function(_0x1792a3){if(_0x1792a3){return _0x426d1e[_0x0d51('0xb')](_0x34dd5f)['json'](_0x1792a3);}};}function respondWithFilteredResult(_0x4e5df1,_0x5c489d){return function(_0x217402){if(_0x217402){var _0x410390=typeof _0x5c489d[_0x0d51('0xc')]===_0x0d51('0xd')&&typeof _0x5c489d[_0x0d51('0xe')]==='undefined';var _0x5b9f83=_0x217402['count'];var _0x509aa6=_0x410390?0x0:_0x5c489d[_0x0d51('0xc')];var _0x16b3db=_0x410390?_0x217402[_0x0d51('0xf')]:_0x5c489d[_0x0d51('0xc')]+_0x5c489d[_0x0d51('0xe')];var _0x3331da;if(_0x16b3db>=_0x5b9f83){_0x16b3db=_0x5b9f83;_0x3331da=0xc8;}else{_0x3331da=0xce;}_0x4e5df1[_0x0d51('0xb')](_0x3331da);return _0x4e5df1[_0x0d51('0x10')](_0x0d51('0x11'),_0x509aa6+'-'+_0x16b3db+'/'+_0x5b9f83)[_0x0d51('0x12')](_0x217402);}return null;};}function saveUpdates(_0x423c56){return function(_0x241741){if(_0x241741){return _0x241741[_0x0d51('0x13')](_0x423c56)['then'](function(_0x2d1356){return _0x2d1356;});}return null;};}function removeEntity(_0x5463a5){return function(_0x1bd20f){if(_0x1bd20f){return _0x1bd20f[_0x0d51('0x14')]()[_0x0d51('0x15')](function(){_0x5463a5[_0x0d51('0xb')](0xcc)[_0x0d51('0x16')]();});}};}function handleEntityNotFound(_0x2f0a97){return function(_0x53ad76){if(!_0x53ad76){_0x2f0a97[_0x0d51('0x17')](0x194);}return _0x53ad76;};}function handleError(_0x32882c,_0x5e462d){_0x5e462d=_0x5e462d||0x1f4;return function(_0x5ef0cf){logger['error'](_0x5ef0cf[_0x0d51('0x18')]);if(_0x5ef0cf[_0x0d51('0x19')]){delete _0x5ef0cf[_0x0d51('0x19')];}_0x32882c[_0x0d51('0xb')](_0x5e462d)[_0x0d51('0x1a')](_0x5ef0cf);};}function maskClientSecret(_0x10b1d5){return _[_0x0d51('0x1b')](_0x10b1d5[_0x0d51('0x1c')](0x0,0x3),0x14,'*');}exports[_0x0d51('0x1d')]=function(_0x1916f2,_0x532e46){var _0x4f3666={},_0x1b8e55={},_0x4901ab={'count':0x0,'rows':[]};var _0x46fefb=_[_0x0d51('0x1e')](db['CloudProvider']['rawAttributes'],function(_0x523c29){return{'name':_0x523c29[_0x0d51('0x1f')],'type':_0x523c29['type']['key']};});_0x1b8e55['model']=_[_0x0d51('0x1e')](_0x46fefb,'name');_0x1b8e55[_0x0d51('0x20')]=_[_0x0d51('0x21')](_0x1916f2[_0x0d51('0x20')]);_0x1b8e55[_0x0d51('0x22')]=_['intersection'](_0x1b8e55['model'],_0x1b8e55[_0x0d51('0x20')]);_0x4f3666[_0x0d51('0x23')]=_[_0x0d51('0x24')](_0x1b8e55[_0x0d51('0x25')],qs[_0x0d51('0x26')](_0x1916f2[_0x0d51('0x20')][_0x0d51('0x26')]));_0x4f3666[_0x0d51('0x23')]=_0x4f3666[_0x0d51('0x23')][_0x0d51('0x27')]?_0x4f3666[_0x0d51('0x23')]:_0x1b8e55[_0x0d51('0x25')];if(!_0x1916f2[_0x0d51('0x20')]['hasOwnProperty']('nolimit')){_0x4f3666[_0x0d51('0xe')]=qs[_0x0d51('0xe')](_0x1916f2[_0x0d51('0x20')]['limit']);_0x4f3666[_0x0d51('0xc')]=qs[_0x0d51('0xc')](_0x1916f2[_0x0d51('0x20')][_0x0d51('0xc')]);}_0x4f3666[_0x0d51('0x28')]=qs['sort'](_0x1916f2[_0x0d51('0x20')][_0x0d51('0x29')]);_0x4f3666[_0x0d51('0x2a')]=qs['filters'](_['pick'](_0x1916f2[_0x0d51('0x20')],_0x1b8e55[_0x0d51('0x22')]),_0x46fefb);if(_0x1916f2[_0x0d51('0x20')][_0x0d51('0x2b')]){_0x4f3666[_0x0d51('0x2a')]=_[_0x0d51('0x2c')](_0x4f3666[_0x0d51('0x2a')],{'$or':_[_0x0d51('0x1e')](_0x46fefb,function(_0x308d08){if(_0x308d08['type']!=='VIRTUAL'){var _0x2cf09c={};_0x2cf09c[_0x308d08[_0x0d51('0x19')]]={'$like':'%'+_0x1916f2[_0x0d51('0x20')][_0x0d51('0x2b')]+'%'};return _0x2cf09c;}})});}_0x4f3666=_[_0x0d51('0x2c')]({},_0x4f3666,_0x1916f2[_0x0d51('0x2d')]);var _0x389b2b={'where':_0x4f3666[_0x0d51('0x2a')]};return db[_0x0d51('0x2e')][_0x0d51('0xf')](_0x389b2b)['then'](function(_0x5afd67){_0x4901ab[_0x0d51('0xf')]=_0x5afd67;if(_0x1916f2[_0x0d51('0x20')][_0x0d51('0x2f')]){_0x4f3666[_0x0d51('0x30')]=[{'all':!![]}];}return db[_0x0d51('0x2e')][_0x0d51('0x31')](_0x4f3666);})[_0x0d51('0x15')](function(_0x4d1b99){_0x4901ab[_0x0d51('0x32')]=_[_0x0d51('0x1e')](_0x4d1b99,function(_0x1fcbde){if(_0x1fcbde[_0x0d51('0x33')]===_0x0d51('0x34')){var _0x44ff71=encryptor[_0x0d51('0x35')](_0x1fcbde[_0x0d51('0x36')]);_0x1fcbde[_0x0d51('0x36')]=maskClientSecret(_0x44ff71);}return _0x1fcbde;});return _0x4901ab;})['then'](respondWithFilteredResult(_0x532e46,_0x4f3666))['catch'](handleError(_0x532e46,null));};exports[_0x0d51('0x37')]=function(_0x3d9474,_0x44f51b){var _0xea98e={'raw':!![],'where':{'id':_0x3d9474[_0x0d51('0x38')]['id']}},_0x3d4b82={};_0x3d4b82[_0x0d51('0x25')]=_['keys'](db[_0x0d51('0x2e')]['rawAttributes']);_0x3d4b82[_0x0d51('0x20')]=_[_0x0d51('0x21')](_0x3d9474[_0x0d51('0x20')]);_0x3d4b82[_0x0d51('0x22')]=_[_0x0d51('0x24')](_0x3d4b82[_0x0d51('0x25')],_0x3d4b82[_0x0d51('0x20')]);_0xea98e[_0x0d51('0x23')]=_[_0x0d51('0x24')](_0x3d4b82[_0x0d51('0x25')],qs[_0x0d51('0x26')](_0x3d9474[_0x0d51('0x20')][_0x0d51('0x26')]));_0xea98e[_0x0d51('0x23')]=_0xea98e['attributes'][_0x0d51('0x27')]?_0xea98e['attributes']:_0x3d4b82[_0x0d51('0x25')];if(_0x3d9474['query'][_0x0d51('0x2f')]){_0xea98e[_0x0d51('0x30')]=[{'all':!![]}];}_0xea98e=_['merge']({},_0xea98e,_0x3d9474[_0x0d51('0x2d')]);return db[_0x0d51('0x2e')][_0x0d51('0x39')](_0xea98e)[_0x0d51('0x15')](handleEntityNotFound(_0x44f51b,null))['then'](function(_0x528c16){if(_0x528c16[_0x0d51('0x33')]===_0x0d51('0x34')){var _0x54a4c9=encryptor['decryptString'](_0x528c16[_0x0d51('0x36')]);_0x528c16['data3']=maskClientSecret(_0x54a4c9);}return _0x528c16;})['then'](respondWithResult(_0x44f51b,null))[_0x0d51('0x3a')](handleError(_0x44f51b,null));};exports[_0x0d51('0x3b')]=function(_0x44cc99,_0x53ef04){if(!_0x44cc99[_0x0d51('0x3c')][_0x0d51('0x19')])throw new Error(_0x0d51('0x3d'));if(!_0x44cc99['body'][_0x0d51('0x33')])throw new Error('Service\x20parameter\x20not\x20specified');var _0x3b892d=db[_0x0d51('0x2e')][_0x0d51('0x3e')][_0x0d51('0x33')][_0x0d51('0x3f')];if(!_0x3b892d[_0x0d51('0x40')](_0x44cc99[_0x0d51('0x3c')][_0x0d51('0x33')]))throw new Error('Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20'+_0x3b892d[_0x0d51('0x41')](',\x20'));if(_0x44cc99['body'][_0x0d51('0x33')]===_0x0d51('0x34')&&_0x44cc99[_0x0d51('0x3c')][_0x0d51('0x36')]){_0x44cc99[_0x0d51('0x3c')][_0x0d51('0x36')]=encryptor[_0x0d51('0x42')](_0x44cc99[_0x0d51('0x3c')][_0x0d51('0x36')]);}return db['CloudProvider'][_0x0d51('0x3b')](_0x44cc99[_0x0d51('0x3c')],{})[_0x0d51('0x15')](respondWithResult(_0x53ef04,0xc9))[_0x0d51('0x3a')](handleError(_0x53ef04,null));};exports[_0x0d51('0x13')]=function(_0x3d9334,_0x13ff80){if(_0x3d9334[_0x0d51('0x3c')]['id']){delete _0x3d9334[_0x0d51('0x3c')]['id'];}return db[_0x0d51('0x2e')][_0x0d51('0x39')]({'where':{'id':_0x3d9334[_0x0d51('0x38')]['id']}})[_0x0d51('0x15')](handleEntityNotFound(_0x13ff80,null))[_0x0d51('0x15')](function(_0x2b86e5){if(_0x2b86e5[_0x0d51('0x33')]===_0x0d51('0x34')&&_0x3d9334['body'][_0x0d51('0x36')]){_0x3d9334[_0x0d51('0x3c')]['data3']=encryptor[_0x0d51('0x42')](_0x3d9334['body'][_0x0d51('0x36')]);}return _0x2b86e5;})['then'](saveUpdates(_0x3d9334['body'],null))['then'](respondWithResult(_0x13ff80,null))[_0x0d51('0x3a')](handleError(_0x13ff80,null));};exports[_0x0d51('0x14')]=function(_0x37f0f2,_0x4b3fa9){return db[_0x0d51('0x2e')][_0x0d51('0x39')]({'where':{'id':_0x37f0f2[_0x0d51('0x38')]['id']}})[_0x0d51('0x15')](handleEntityNotFound(_0x4b3fa9,null))[_0x0d51('0x15')](removeEntity(_0x4b3fa9,null))[_0x0d51('0x3a')](handleError(_0x4b3fa9,null));};exports[_0x0d51('0x43')]=function(_0x345b84,_0x5fb260){return db[_0x0d51('0x2e')]['findOne']({'where':{'id':_0x345b84['params']['id']},'raw':!![]})[_0x0d51('0x15')](function(_0x21b1a9){if(!_0x21b1a9)return _0x5fb260['sendStatus'](0x194);return{'url':oauth[_0x0d51('0x44')](_0x21b1a9,_0x345b84[_0x0d51('0x45')]['id'])};})['then'](respondWithResult(_0x5fb260,null))['catch'](handleError(_0x5fb260,null));};exports['oauth2MicrosoftCallback']=function(_0x263bdc,_0x25952b){var _0x2ec994=_0x263bdc[_0x0d51('0x3c')];var _0x4d633f;var _0x4171d1;if(_0x2ec994[_0x0d51('0x46')])throw _0x2ec994;redis[_0x0d51('0x47')](_0x2ec994[_0x0d51('0x48')])['then'](function(_0x3c91b9){if(!_0x3c91b9)throw new Error(_0x0d51('0x49'));_0x4d633f=JSON[_0x0d51('0x4a')](_0x3c91b9);var _0x9905f4=Buffer['from'](_0x2ec994['state'],_0x0d51('0x4b'))[_0x0d51('0x4c')](_0x0d51('0x4d'));_0x4171d1=JSON[_0x0d51('0x4a')](_0x9905f4);if(!oauth[_0x0d51('0x4e')](_0x2ec994['id_token'],_0x4d633f[_0x0d51('0x4f')]))throw new Error(_0x0d51('0x50'));redis['del'](_0x2ec994[_0x0d51('0x48')]);return oauth['getOauth2MicrosoftAccessToken'](_0x2ec994[_0x0d51('0x51')],_0x4d633f);})[_0x0d51('0x15')](function(_0x281954){_0x4d633f[_0x0d51('0x52')]=_0x281954[_0x0d51('0x53')];_0x4d633f[_0x0d51('0x54')]=_0x281954[_0x0d51('0x55')];return db[_0x0d51('0x2e')][_0x0d51('0x13')]({'data5':_0x4d633f[_0x0d51('0x52')],'data6':_0x4d633f[_0x0d51('0x54')]},{'where':{'id':_0x4d633f['id']}});})[_0x0d51('0x15')](function(){oauth['startRefreshInterval'](_0x4d633f);socket['emit'](_0x0d51('0x56'),{'id':_0x4171d1['id']});return;})[_0x0d51('0x15')](respondWithStatusCode(_0x25952b,null))['catch'](function(_0x1556b6){if(_0x4171d1){socket['emit']('microsoftAuthorization:error',{'id':_0x4171d1['id']});}if(!_0x4d633f){logger[_0x0d51('0x46')](_0x0d51('0x57'),_0x1556b6);return _0x25952b['status'](0x1f4)[_0x0d51('0x1a')](_0x1556b6[_0x0d51('0x58')]);}logger['error']('Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s',_0x4d633f['id'],JSON[_0x0d51('0x59')](_0x1556b6));});};
\ 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