Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 3dcf554..be59f07 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8d6e=['create','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','update','params','encryptString','destroy','oauth2MicrosoftAuthorize','generateMicrosoftAuthorizationUrl','user','oauth2MicrosoftCallback','Invalid\x20state\x20parameter','parse','state','base64','toString','ascii','isValidIdToken','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','getOauth2MicrosoftAccessToken','code','data6','refresh_token','data5','emit','send','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','./cloudProvider.oauth','redis','defaults','localhost','sendStatus','status','json','offset','undefined','count','set','Content-Range','then','end','error','stack','name','slice','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','CloudProvider','includeAll','findAll','rows','service','MicrosoftAzure','decryptString','data3','catch','options','find'];(function(_0xd3786f,_0xa1cee){var _0x3e4dc2=function(_0x384776){while(--_0x384776){_0xd3786f['push'](_0xd3786f['shift']());}};_0x3e4dc2(++_0xa1cee);}(_0x8d6e,0x83));var _0xe8d6=function(_0x5606ad,_0x476b10){_0x5606ad=_0x5606ad-0x0;var _0x58563c=_0x8d6e[_0x5606ad];return _0x58563c;};'use strict';var _=require(_0xe8d6('0x0'));var Redis=require(_0xe8d6('0x1'));var qs=require(_0xe8d6('0x2'));var encryptor=require('../../components/encryptor');var config=require('../../config/environment');var logger=require(_0xe8d6('0x3'))(_0xe8d6('0x4'));var db=require(_0xe8d6('0x5'))['db'];var oauth=require(_0xe8d6('0x6'));config[_0xe8d6('0x7')]=_[_0xe8d6('0x8')](config[_0xe8d6('0x7')],{'host':_0xe8d6('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xe8d6('0x7')]));var redis=new Redis(config['redis']);function respondWithStatusCode(_0x146559,_0x48295b){_0x48295b=_0x48295b||0xcc;return function(_0x3ad926){if(_0x3ad926){return _0x146559[_0xe8d6('0xa')](_0x48295b);}return _0x146559[_0xe8d6('0xb')](_0x48295b)['end']();};}function respondWithResult(_0x2da985,_0x29863b){_0x29863b=_0x29863b||0xc8;return function(_0xfb2b66){if(_0xfb2b66){return _0x2da985['status'](_0x29863b)[_0xe8d6('0xc')](_0xfb2b66);}};}function respondWithFilteredResult(_0x490d1a,_0x5957c4){return function(_0x3faeee){if(_0x3faeee){var _0x5e8e17=typeof _0x5957c4[_0xe8d6('0xd')]===_0xe8d6('0xe')&&typeof _0x5957c4['limit']===_0xe8d6('0xe');var _0x399e3e=_0x3faeee[_0xe8d6('0xf')];var _0x2303d9=_0x5e8e17?0x0:_0x5957c4['offset'];var _0x3294d4=_0x5e8e17?_0x3faeee[_0xe8d6('0xf')]:_0x5957c4[_0xe8d6('0xd')]+_0x5957c4['limit'];var _0x4ba568;if(_0x3294d4>=_0x399e3e){_0x3294d4=_0x399e3e;_0x4ba568=0xc8;}else{_0x4ba568=0xce;}_0x490d1a[_0xe8d6('0xb')](_0x4ba568);return _0x490d1a[_0xe8d6('0x10')](_0xe8d6('0x11'),_0x2303d9+'-'+_0x3294d4+'/'+_0x399e3e)[_0xe8d6('0xc')](_0x3faeee);}return null;};}function saveUpdates(_0x2abe53){return function(_0x310ff4){if(_0x310ff4){return _0x310ff4['update'](_0x2abe53)[_0xe8d6('0x12')](function(_0x2d8f29){return _0x2d8f29;});}return null;};}function removeEntity(_0x569065){return function(_0xf7d259){if(_0xf7d259){return _0xf7d259['destroy']()['then'](function(){_0x569065[_0xe8d6('0xb')](0xcc)[_0xe8d6('0x13')]();});}};}function handleEntityNotFound(_0x202306){return function(_0x3867fe){if(!_0x3867fe){_0x202306[_0xe8d6('0xa')](0x194);}return _0x3867fe;};}function handleError(_0x442137,_0xacc324){_0xacc324=_0xacc324||0x1f4;return function(_0x104dee){logger[_0xe8d6('0x14')](_0x104dee[_0xe8d6('0x15')]);if(_0x104dee['name']){delete _0x104dee[_0xe8d6('0x16')];}_0x442137['status'](_0xacc324)['send'](_0x104dee);};}function maskClientSecret(_0x646fba){return _['padEnd'](_0x646fba[_0xe8d6('0x17')](0x0,0x3),0x14,'*');}exports[_0xe8d6('0x18')]=function(_0x21b7de,_0xb11124){var _0x4b3fa4={},_0x2c9b8f={},_0x48ddce={'count':0x0,'rows':[]};var _0x5a26fe=_[_0xe8d6('0x19')](db['CloudProvider'][_0xe8d6('0x1a')],function(_0x322e26){return{'name':_0x322e26[_0xe8d6('0x1b')],'type':_0x322e26[_0xe8d6('0x1c')][_0xe8d6('0x1d')]};});_0x2c9b8f[_0xe8d6('0x1e')]=_[_0xe8d6('0x19')](_0x5a26fe,_0xe8d6('0x16'));_0x2c9b8f[_0xe8d6('0x1f')]=_[_0xe8d6('0x20')](_0x21b7de[_0xe8d6('0x1f')]);_0x2c9b8f[_0xe8d6('0x21')]=_[_0xe8d6('0x22')](_0x2c9b8f[_0xe8d6('0x1e')],_0x2c9b8f[_0xe8d6('0x1f')]);_0x4b3fa4[_0xe8d6('0x23')]=_[_0xe8d6('0x22')](_0x2c9b8f['model'],qs[_0xe8d6('0x24')](_0x21b7de[_0xe8d6('0x1f')][_0xe8d6('0x24')]));_0x4b3fa4[_0xe8d6('0x23')]=_0x4b3fa4[_0xe8d6('0x23')][_0xe8d6('0x25')]?_0x4b3fa4[_0xe8d6('0x23')]:_0x2c9b8f[_0xe8d6('0x1e')];if(!_0x21b7de[_0xe8d6('0x1f')][_0xe8d6('0x26')](_0xe8d6('0x27'))){_0x4b3fa4[_0xe8d6('0x28')]=qs[_0xe8d6('0x28')](_0x21b7de['query'][_0xe8d6('0x28')]);_0x4b3fa4[_0xe8d6('0xd')]=qs['offset'](_0x21b7de[_0xe8d6('0x1f')][_0xe8d6('0xd')]);}_0x4b3fa4[_0xe8d6('0x29')]=qs[_0xe8d6('0x2a')](_0x21b7de[_0xe8d6('0x1f')][_0xe8d6('0x2a')]);_0x4b3fa4[_0xe8d6('0x2b')]=qs['filters'](_[_0xe8d6('0x2c')](_0x21b7de[_0xe8d6('0x1f')],_0x2c9b8f[_0xe8d6('0x21')]),_0x5a26fe);if(_0x21b7de['query'][_0xe8d6('0x2d')]){_0x4b3fa4['where']=_[_0xe8d6('0x2e')](_0x4b3fa4[_0xe8d6('0x2b')],{'$or':_['map'](_0x5a26fe,function(_0x4ed5af){if(_0x4ed5af[_0xe8d6('0x1c')]!==_0xe8d6('0x2f')){var _0x35d346={};_0x35d346[_0x4ed5af[_0xe8d6('0x16')]]={'$like':'%'+_0x21b7de['query'][_0xe8d6('0x2d')]+'%'};return _0x35d346;}})});}_0x4b3fa4=_[_0xe8d6('0x2e')]({},_0x4b3fa4,_0x21b7de['options']);var _0x32312b={'where':_0x4b3fa4[_0xe8d6('0x2b')]};return db[_0xe8d6('0x30')][_0xe8d6('0xf')](_0x32312b)[_0xe8d6('0x12')](function(_0x1f1d75){_0x48ddce[_0xe8d6('0xf')]=_0x1f1d75;if(_0x21b7de[_0xe8d6('0x1f')][_0xe8d6('0x31')]){_0x4b3fa4['include']=[{'all':!![]}];}return db[_0xe8d6('0x30')][_0xe8d6('0x32')](_0x4b3fa4);})[_0xe8d6('0x12')](function(_0x47c125){_0x48ddce[_0xe8d6('0x33')]=_[_0xe8d6('0x19')](_0x47c125,function(_0xeab7d1){if(_0xeab7d1[_0xe8d6('0x34')]===_0xe8d6('0x35')){var _0x4cb2dc=encryptor[_0xe8d6('0x36')](_0xeab7d1['data3']);_0xeab7d1[_0xe8d6('0x37')]=maskClientSecret(_0x4cb2dc);}return _0xeab7d1;});return _0x48ddce;})[_0xe8d6('0x12')](respondWithFilteredResult(_0xb11124,_0x4b3fa4))[_0xe8d6('0x38')](handleError(_0xb11124,null));};exports['show']=function(_0x46cbd4,_0x333c73){var _0x5dc2f6={'raw':!![],'where':{'id':_0x46cbd4['params']['id']}},_0x104518={};_0x104518[_0xe8d6('0x1e')]=_[_0xe8d6('0x20')](db[_0xe8d6('0x30')][_0xe8d6('0x1a')]);_0x104518['query']=_[_0xe8d6('0x20')](_0x46cbd4[_0xe8d6('0x1f')]);_0x104518[_0xe8d6('0x21')]=_[_0xe8d6('0x22')](_0x104518[_0xe8d6('0x1e')],_0x104518[_0xe8d6('0x1f')]);_0x5dc2f6[_0xe8d6('0x23')]=_[_0xe8d6('0x22')](_0x104518[_0xe8d6('0x1e')],qs[_0xe8d6('0x24')](_0x46cbd4[_0xe8d6('0x1f')][_0xe8d6('0x24')]));_0x5dc2f6[_0xe8d6('0x23')]=_0x5dc2f6['attributes'][_0xe8d6('0x25')]?_0x5dc2f6[_0xe8d6('0x23')]:_0x104518[_0xe8d6('0x1e')];if(_0x46cbd4[_0xe8d6('0x1f')][_0xe8d6('0x31')]){_0x5dc2f6['include']=[{'all':!![]}];}_0x5dc2f6=_[_0xe8d6('0x2e')]({},_0x5dc2f6,_0x46cbd4[_0xe8d6('0x39')]);return db[_0xe8d6('0x30')][_0xe8d6('0x3a')](_0x5dc2f6)[_0xe8d6('0x12')](handleEntityNotFound(_0x333c73,null))[_0xe8d6('0x12')](function(_0x40f436){if(_0x40f436['service']===_0xe8d6('0x35')){var _0x92e2a9=encryptor['decryptString'](_0x40f436[_0xe8d6('0x37')]);_0x40f436['data3']=maskClientSecret(_0x92e2a9);}return _0x40f436;})[_0xe8d6('0x12')](respondWithResult(_0x333c73,null))['catch'](handleError(_0x333c73,null));};exports[_0xe8d6('0x3b')]=function(_0x2ba5f9,_0x4b763f){if(!_0x2ba5f9[_0xe8d6('0x3c')][_0xe8d6('0x16')])throw new Error(_0xe8d6('0x3d'));if(!_0x2ba5f9[_0xe8d6('0x3c')][_0xe8d6('0x34')])throw new Error(_0xe8d6('0x3e'));var _0x352ad8=db['CloudProvider'][_0xe8d6('0x1a')]['service'][_0xe8d6('0x3f')];if(!_0x352ad8[_0xe8d6('0x40')](_0x2ba5f9[_0xe8d6('0x3c')][_0xe8d6('0x34')]))throw new Error(_0xe8d6('0x41')+_0x352ad8[_0xe8d6('0x42')](',\x20'));if(_0x2ba5f9[_0xe8d6('0x3c')]['service']===_0xe8d6('0x35')&&_0x2ba5f9[_0xe8d6('0x3c')][_0xe8d6('0x37')]){_0x2ba5f9[_0xe8d6('0x3c')][_0xe8d6('0x37')]=encryptor['encryptString'](_0x2ba5f9[_0xe8d6('0x3c')]['data3']);}return db[_0xe8d6('0x30')]['create'](_0x2ba5f9[_0xe8d6('0x3c')],{})[_0xe8d6('0x12')](respondWithResult(_0x4b763f,0xc9))[_0xe8d6('0x38')](handleError(_0x4b763f,null));};exports[_0xe8d6('0x43')]=function(_0x512a21,_0x5dc201){if(_0x512a21['body']['id']){delete _0x512a21[_0xe8d6('0x3c')]['id'];}return db[_0xe8d6('0x30')][_0xe8d6('0x3a')]({'where':{'id':_0x512a21[_0xe8d6('0x44')]['id']}})[_0xe8d6('0x12')](handleEntityNotFound(_0x5dc201,null))[_0xe8d6('0x12')](function(_0x473f8b){if(_0x473f8b['service']===_0xe8d6('0x35')&&_0x512a21[_0xe8d6('0x3c')]['data3']){_0x512a21[_0xe8d6('0x3c')]['data3']=encryptor[_0xe8d6('0x45')](_0x512a21[_0xe8d6('0x3c')][_0xe8d6('0x37')]);}return _0x473f8b;})['then'](saveUpdates(_0x512a21[_0xe8d6('0x3c')],null))['then'](respondWithResult(_0x5dc201,null))[_0xe8d6('0x38')](handleError(_0x5dc201,null));};exports[_0xe8d6('0x46')]=function(_0x1c40fa,_0x4e9026){return db[_0xe8d6('0x30')][_0xe8d6('0x3a')]({'where':{'id':_0x1c40fa[_0xe8d6('0x44')]['id']}})[_0xe8d6('0x12')](handleEntityNotFound(_0x4e9026,null))['then'](removeEntity(_0x4e9026,null))[_0xe8d6('0x38')](handleError(_0x4e9026,null));};exports[_0xe8d6('0x47')]=function(_0x196a30,_0x4be05d){return db[_0xe8d6('0x30')]['findOne']({'where':{'id':_0x196a30[_0xe8d6('0x44')]['id']},'raw':!![]})[_0xe8d6('0x12')](function(_0xf8a0f2){if(!_0xf8a0f2)return _0x4be05d[_0xe8d6('0xa')](0x194);return{'url':oauth[_0xe8d6('0x48')](_0xf8a0f2,_0x196a30[_0xe8d6('0x49')]['id'])};})[_0xe8d6('0x12')](respondWithResult(_0x4be05d,null))['catch'](handleError(_0x4be05d,null));};exports[_0xe8d6('0x4a')]=function(_0x271a3b,_0x33c078){var _0x3a7ac6=_0x271a3b[_0xe8d6('0x3c')];var _0x11b5b5;var _0x2ba2ef;if(_0x3a7ac6[_0xe8d6('0x14')])throw _0x3a7ac6;redis['get'](_0x3a7ac6['state'])['then'](function(_0x4e2ed7){if(!_0x4e2ed7)throw new Error(_0xe8d6('0x4b'));_0x11b5b5=JSON[_0xe8d6('0x4c')](_0x4e2ed7);var _0x57a2cb=Buffer['from'](_0x3a7ac6[_0xe8d6('0x4d')],_0xe8d6('0x4e'))[_0xe8d6('0x4f')](_0xe8d6('0x50'));_0x2ba2ef=JSON['parse'](_0x57a2cb);if(!oauth[_0xe8d6('0x51')](_0x3a7ac6[_0xe8d6('0x52')],_0x11b5b5[_0xe8d6('0x53')]))throw new Error(_0xe8d6('0x54'));redis[_0xe8d6('0x55')](_0x3a7ac6[_0xe8d6('0x4d')]);return oauth[_0xe8d6('0x56')](_0x3a7ac6[_0xe8d6('0x57')],_0x11b5b5);})['then'](function(_0x4f21db){_0x11b5b5['data5']=_0x4f21db['access_token'];_0x11b5b5[_0xe8d6('0x58')]=_0x4f21db[_0xe8d6('0x59')];return db[_0xe8d6('0x30')]['update']({'data5':_0x11b5b5[_0xe8d6('0x5a')],'data6':_0x11b5b5['data6']},{'where':{'id':_0x11b5b5['id']}});})[_0xe8d6('0x12')](function(){oauth['startRefreshInterval'](_0x11b5b5);socket['emit']('microsoftAuthorization:success',{'id':_0x2ba2ef['id']});return;})[_0xe8d6('0x12')](respondWithStatusCode(_0x33c078,null))[_0xe8d6('0x38')](function(_0x573e4f){if(_0x2ba2ef){socket[_0xe8d6('0x5b')]('microsoftAuthorization:error',{'id':_0x2ba2ef['id']});}if(!_0x11b5b5){logger[_0xe8d6('0x14')]('Invalid\x20authentication\x20state\x20parameter',_0x573e4f);return _0x33c078['status'](0x1f4)[_0xe8d6('0x5c')](_0x573e4f['message']);}logger['error'](_0xe8d6('0x5d'),_0x11b5b5['id'],JSON[_0xe8d6('0x5e')](_0x573e4f));});};
\ 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