Built motion from commit 3770a7bd.|2.6.29
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 03a3937..dd9b52a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa02a=['create','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','update','params','findOne','generateMicrosoftAuthorizationUrl','oauth2MicrosoftCallback','error','get','state','Invalid\x20state\x20parameter','parse','from','base64','toString','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','getOauth2MicrosoftAccessToken','code','data5','data6','refresh_token','startRefreshInterval','emit','microsoftAuthorization:success','microsoftAuthorization:error','Invalid\x20authentication\x20state\x20parameter','message','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','ioredis','../../components/parsers/qs','../../config/environment','../../config/logger','api','redis','defaults','socket.io-emitter','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','destroy','then','stack','name','send','slice','index','map','rawAttributes','fieldName','type','key','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','service','MicrosoftAzure','decryptString','data3','catch','show','CloudProvider','find'];(function(_0x548c67,_0x443c46){var _0x3c8c4d=function(_0x503dc7){while(--_0x503dc7){_0x548c67['push'](_0x548c67['shift']());}};_0x3c8c4d(++_0x443c46);}(_0xa02a,0x144));var _0xaa02=function(_0x3f0e94,_0x21a8c6){_0x3f0e94=_0x3f0e94-0x0;var _0x2e0ff4=_0xa02a[_0x3f0e94];return _0x2e0ff4;};'use strict';var _=require(_0xaa02('0x0'));var Redis=require(_0xaa02('0x1'));var qs=require(_0xaa02('0x2'));var encryptor=require('../../components/encryptor');var config=require(_0xaa02('0x3'));var logger=require(_0xaa02('0x4'))(_0xaa02('0x5'));var db=require('../../mysqldb')['db'];var oauth=require('./cloudProvider.oauth');config[_0xaa02('0x6')]=_[_0xaa02('0x7')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xaa02('0x8'))(new Redis(config[_0xaa02('0x6')]));var redis=new Redis(config[_0xaa02('0x6')]);function respondWithStatusCode(_0xaa0f51,_0x217b01){_0x217b01=_0x217b01||0xcc;return function(_0x42cc40){if(_0x42cc40){return _0xaa0f51[_0xaa02('0x9')](_0x217b01);}return _0xaa0f51[_0xaa02('0xa')](_0x217b01)[_0xaa02('0xb')]();};}function respondWithResult(_0x35a772,_0x17224f){_0x17224f=_0x17224f||0xc8;return function(_0x368bc8){if(_0x368bc8){return _0x35a772[_0xaa02('0xa')](_0x17224f)[_0xaa02('0xc')](_0x368bc8);}};}function respondWithFilteredResult(_0x14b257,_0x14f0f8){return function(_0x1e9661){if(_0x1e9661){var _0x5ef8de=typeof _0x14f0f8[_0xaa02('0xd')]===_0xaa02('0xe')&&typeof _0x14f0f8[_0xaa02('0xf')]===_0xaa02('0xe');var _0x16ef9f=_0x1e9661[_0xaa02('0x10')];var _0x48b3e7=_0x5ef8de?0x0:_0x14f0f8[_0xaa02('0xd')];var _0x20eff3=_0x5ef8de?_0x1e9661[_0xaa02('0x10')]:_0x14f0f8[_0xaa02('0xd')]+_0x14f0f8[_0xaa02('0xf')];var _0xe7296a;if(_0x20eff3>=_0x16ef9f){_0x20eff3=_0x16ef9f;_0xe7296a=0xc8;}else{_0xe7296a=0xce;}_0x14b257[_0xaa02('0xa')](_0xe7296a);return _0x14b257[_0xaa02('0x11')](_0xaa02('0x12'),_0x48b3e7+'-'+_0x20eff3+'/'+_0x16ef9f)[_0xaa02('0xc')](_0x1e9661);}return null;};}function saveUpdates(_0x23b13d){return function(_0x1f7224){if(_0x1f7224){return _0x1f7224['update'](_0x23b13d)['then'](function(_0x1685ff){return _0x1685ff;});}return null;};}function removeEntity(_0x39a9ea){return function(_0x10fd69){if(_0x10fd69){return _0x10fd69[_0xaa02('0x13')]()[_0xaa02('0x14')](function(){_0x39a9ea[_0xaa02('0xa')](0xcc)['end']();});}};}function handleEntityNotFound(_0xe2cecf){return function(_0x4ea4be){if(!_0x4ea4be){_0xe2cecf['sendStatus'](0x194);}return _0x4ea4be;};}function handleError(_0x3e3525,_0x1a369b){_0x1a369b=_0x1a369b||0x1f4;return function(_0x4ed07e){logger['error'](_0x4ed07e[_0xaa02('0x15')]);if(_0x4ed07e[_0xaa02('0x16')]){delete _0x4ed07e['name'];}_0x3e3525[_0xaa02('0xa')](_0x1a369b)[_0xaa02('0x17')](_0x4ed07e);};}function maskClientSecret(_0x5ead0e){return _['padEnd'](_0x5ead0e[_0xaa02('0x18')](0x0,0x3),0x14,'*');}exports[_0xaa02('0x19')]=function(_0xd77c2d,_0xa44b5f){var _0x361c6a={},_0x174fb9={},_0x420c94={'count':0x0,'rows':[]};var _0x3417a2=_[_0xaa02('0x1a')](db['CloudProvider'][_0xaa02('0x1b')],function(_0x527d7e){return{'name':_0x527d7e[_0xaa02('0x1c')],'type':_0x527d7e[_0xaa02('0x1d')][_0xaa02('0x1e')]};});_0x174fb9[_0xaa02('0x1f')]=_['map'](_0x3417a2,'name');_0x174fb9[_0xaa02('0x20')]=_[_0xaa02('0x21')](_0xd77c2d[_0xaa02('0x20')]);_0x174fb9['filters']=_['intersection'](_0x174fb9[_0xaa02('0x1f')],_0x174fb9['query']);_0x361c6a[_0xaa02('0x22')]=_[_0xaa02('0x23')](_0x174fb9[_0xaa02('0x1f')],qs[_0xaa02('0x24')](_0xd77c2d['query']['fields']));_0x361c6a[_0xaa02('0x22')]=_0x361c6a[_0xaa02('0x22')][_0xaa02('0x25')]?_0x361c6a[_0xaa02('0x22')]:_0x174fb9[_0xaa02('0x1f')];if(!_0xd77c2d[_0xaa02('0x20')][_0xaa02('0x26')](_0xaa02('0x27'))){_0x361c6a[_0xaa02('0xf')]=qs[_0xaa02('0xf')](_0xd77c2d[_0xaa02('0x20')][_0xaa02('0xf')]);_0x361c6a['offset']=qs[_0xaa02('0xd')](_0xd77c2d[_0xaa02('0x20')][_0xaa02('0xd')]);}_0x361c6a[_0xaa02('0x28')]=qs[_0xaa02('0x29')](_0xd77c2d[_0xaa02('0x20')][_0xaa02('0x29')]);_0x361c6a[_0xaa02('0x2a')]=qs[_0xaa02('0x2b')](_[_0xaa02('0x2c')](_0xd77c2d[_0xaa02('0x20')],_0x174fb9[_0xaa02('0x2b')]),_0x3417a2);if(_0xd77c2d[_0xaa02('0x20')][_0xaa02('0x2d')]){_0x361c6a[_0xaa02('0x2a')]=_[_0xaa02('0x2e')](_0x361c6a[_0xaa02('0x2a')],{'$or':_[_0xaa02('0x1a')](_0x3417a2,function(_0x3c9c4c){if(_0x3c9c4c[_0xaa02('0x1d')]!==_0xaa02('0x2f')){var _0x23a853={};_0x23a853[_0x3c9c4c[_0xaa02('0x16')]]={'$like':'%'+_0xd77c2d[_0xaa02('0x20')][_0xaa02('0x2d')]+'%'};return _0x23a853;}})});}_0x361c6a=_['merge']({},_0x361c6a,_0xd77c2d['options']);var _0x5cf000={'where':_0x361c6a[_0xaa02('0x2a')]};return db['CloudProvider'][_0xaa02('0x10')](_0x5cf000)[_0xaa02('0x14')](function(_0x5ceaaa){_0x420c94[_0xaa02('0x10')]=_0x5ceaaa;if(_0xd77c2d[_0xaa02('0x20')][_0xaa02('0x30')]){_0x361c6a[_0xaa02('0x31')]=[{'all':!![]}];}return db['CloudProvider'][_0xaa02('0x32')](_0x361c6a);})[_0xaa02('0x14')](function(_0x3422fc){_0x420c94[_0xaa02('0x33')]=_[_0xaa02('0x1a')](_0x3422fc,function(_0x1be08d){if(_0x1be08d[_0xaa02('0x34')]===_0xaa02('0x35')){var _0x53be03=encryptor[_0xaa02('0x36')](_0x1be08d[_0xaa02('0x37')]);_0x1be08d['data3']=maskClientSecret(_0x53be03);}return _0x1be08d;});return _0x420c94;})[_0xaa02('0x14')](respondWithFilteredResult(_0xa44b5f,_0x361c6a))[_0xaa02('0x38')](handleError(_0xa44b5f,null));};exports[_0xaa02('0x39')]=function(_0x35fea1,_0x36b666){var _0x2a8f2b={'raw':!![],'where':{'id':_0x35fea1['params']['id']}},_0x5431b2={};_0x5431b2[_0xaa02('0x1f')]=_[_0xaa02('0x21')](db[_0xaa02('0x3a')]['rawAttributes']);_0x5431b2[_0xaa02('0x20')]=_[_0xaa02('0x21')](_0x35fea1[_0xaa02('0x20')]);_0x5431b2[_0xaa02('0x2b')]=_[_0xaa02('0x23')](_0x5431b2[_0xaa02('0x1f')],_0x5431b2[_0xaa02('0x20')]);_0x2a8f2b[_0xaa02('0x22')]=_[_0xaa02('0x23')](_0x5431b2[_0xaa02('0x1f')],qs['fields'](_0x35fea1[_0xaa02('0x20')][_0xaa02('0x24')]));_0x2a8f2b[_0xaa02('0x22')]=_0x2a8f2b['attributes'][_0xaa02('0x25')]?_0x2a8f2b['attributes']:_0x5431b2[_0xaa02('0x1f')];if(_0x35fea1['query'][_0xaa02('0x30')]){_0x2a8f2b[_0xaa02('0x31')]=[{'all':!![]}];}_0x2a8f2b=_[_0xaa02('0x2e')]({},_0x2a8f2b,_0x35fea1['options']);return db[_0xaa02('0x3a')][_0xaa02('0x3b')](_0x2a8f2b)[_0xaa02('0x14')](handleEntityNotFound(_0x36b666,null))[_0xaa02('0x14')](function(_0x2d4f7b){if(_0x2d4f7b[_0xaa02('0x34')]===_0xaa02('0x35')){var _0x5a5ffa=encryptor[_0xaa02('0x36')](_0x2d4f7b[_0xaa02('0x37')]);_0x2d4f7b[_0xaa02('0x37')]=maskClientSecret(_0x5a5ffa);}return _0x2d4f7b;})['then'](respondWithResult(_0x36b666,null))[_0xaa02('0x38')](handleError(_0x36b666,null));};exports[_0xaa02('0x3c')]=function(_0x36096a,_0x2d26d3){if(!_0x36096a[_0xaa02('0x3d')]['name'])throw new Error(_0xaa02('0x3e'));if(!_0x36096a['body']['service'])throw new Error(_0xaa02('0x3f'));var _0x27e418=db['CloudProvider']['rawAttributes'][_0xaa02('0x34')][_0xaa02('0x40')];if(!_0x27e418['includes'](_0x36096a[_0xaa02('0x3d')][_0xaa02('0x34')]))throw new Error(_0xaa02('0x41')+_0x27e418[_0xaa02('0x42')](',\x20'));if(_0x36096a[_0xaa02('0x3d')]['service']===_0xaa02('0x35')&&_0x36096a[_0xaa02('0x3d')]['data3']){_0x36096a[_0xaa02('0x3d')][_0xaa02('0x37')]=encryptor['encryptString'](_0x36096a[_0xaa02('0x3d')][_0xaa02('0x37')]);}return db[_0xaa02('0x3a')][_0xaa02('0x3c')](_0x36096a['body'],{})['then'](respondWithResult(_0x2d26d3,0xc9))[_0xaa02('0x38')](handleError(_0x2d26d3,null));};exports[_0xaa02('0x43')]=function(_0x288e7d,_0x1ef3c8){if(_0x288e7d[_0xaa02('0x3d')]['id']){delete _0x288e7d[_0xaa02('0x3d')]['id'];}return db[_0xaa02('0x3a')][_0xaa02('0x3b')]({'where':{'id':_0x288e7d[_0xaa02('0x44')]['id']}})['then'](handleEntityNotFound(_0x1ef3c8,null))[_0xaa02('0x14')](function(_0xfef357){if(_0xfef357[_0xaa02('0x34')]==='MicrosoftAzure'&&_0x288e7d[_0xaa02('0x3d')][_0xaa02('0x37')]){_0x288e7d[_0xaa02('0x3d')]['data3']=encryptor['encryptString'](_0x288e7d[_0xaa02('0x3d')][_0xaa02('0x37')]);}return _0xfef357;})[_0xaa02('0x14')](saveUpdates(_0x288e7d['body'],null))[_0xaa02('0x14')](respondWithResult(_0x1ef3c8,null))[_0xaa02('0x38')](handleError(_0x1ef3c8,null));};exports[_0xaa02('0x13')]=function(_0xc225b1,_0x4af2ec){return db[_0xaa02('0x3a')][_0xaa02('0x3b')]({'where':{'id':_0xc225b1['params']['id']}})['then'](handleEntityNotFound(_0x4af2ec,null))['then'](removeEntity(_0x4af2ec,null))[_0xaa02('0x38')](handleError(_0x4af2ec,null));};exports['oauth2MicrosoftAuthorize']=function(_0x870ba3,_0x9fcb23){return db[_0xaa02('0x3a')][_0xaa02('0x45')]({'where':{'id':_0x870ba3[_0xaa02('0x44')]['id']},'raw':!![]})['then'](function(_0x4c728f){if(!_0x4c728f)return _0x9fcb23[_0xaa02('0x9')](0x194);return{'url':oauth[_0xaa02('0x46')](_0x4c728f,_0x870ba3['user']['id'])};})['then'](respondWithResult(_0x9fcb23,null))['catch'](handleError(_0x9fcb23,null));};exports[_0xaa02('0x47')]=function(_0x151db6,_0x48e15c){var _0x5ac2cd=_0x151db6[_0xaa02('0x3d')];var _0x5257bf;var _0x3b2363;if(_0x5ac2cd[_0xaa02('0x48')])throw _0x5ac2cd;redis[_0xaa02('0x49')](_0x5ac2cd[_0xaa02('0x4a')])[_0xaa02('0x14')](function(_0x362dba){if(!_0x362dba)throw new Error(_0xaa02('0x4b'));_0x5257bf=JSON[_0xaa02('0x4c')](_0x362dba);var _0x3511cb=Buffer[_0xaa02('0x4d')](_0x5ac2cd[_0xaa02('0x4a')],_0xaa02('0x4e'))[_0xaa02('0x4f')]('ascii');_0x3b2363=JSON[_0xaa02('0x4c')](_0x3511cb);if(!oauth['isValidIdToken'](_0x5ac2cd[_0xaa02('0x50')],_0x5257bf[_0xaa02('0x51')]))throw new Error(_0xaa02('0x52'));redis['del'](_0x5ac2cd[_0xaa02('0x4a')]);return oauth[_0xaa02('0x53')](_0x5ac2cd[_0xaa02('0x54')],_0x5257bf);})[_0xaa02('0x14')](function(_0x57993f){_0x5257bf[_0xaa02('0x55')]=_0x57993f['access_token'];_0x5257bf[_0xaa02('0x56')]=_0x57993f[_0xaa02('0x57')];return db[_0xaa02('0x3a')][_0xaa02('0x43')]({'data5':_0x5257bf['data5'],'data6':_0x5257bf[_0xaa02('0x56')]},{'where':{'id':_0x5257bf['id']}});})[_0xaa02('0x14')](function(){oauth[_0xaa02('0x58')](_0x5257bf);socket[_0xaa02('0x59')](_0xaa02('0x5a'),{'id':_0x3b2363['id']});return;})[_0xaa02('0x14')](respondWithStatusCode(_0x48e15c,null))['catch'](function(_0x16b7fe){if(_0x3b2363){socket[_0xaa02('0x59')](_0xaa02('0x5b'),{'id':_0x3b2363['id']});}if(!_0x5257bf){logger[_0xaa02('0x48')](_0xaa02('0x5c'),_0x16b7fe);return _0x48e15c[_0xaa02('0xa')](0x1f4)[_0xaa02('0x17')](_0x16b7fe[_0xaa02('0x5d')]);}logger[_0xaa02('0x48')](_0xaa02('0x5e'),_0x5257bf['id'],JSON[_0xaa02('0x5f')](_0x16b7fe));});};
\ No newline at end of file
+var _0xf1fa=['from','toString','ascii','isValidIdToken','id_token','oauth2Claims','del','getOauth2MicrosoftAccessToken','data5','access_token','refresh_token','data6','emit','microsoftAuthorization:error','message','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','ioredis','../../components/parsers/qs','../../config/environment','../../config/logger','api','../../mysqldb','./cloudProvider.oauth','redis','localhost','socket.io-emitter','sendStatus','end','status','json','undefined','limit','count','offset','set','update','then','destroy','error','name','send','padEnd','slice','map','fieldName','type','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','CloudProvider','includeAll','findAll','rows','service','MicrosoftAzure','decryptString','data3','show','params','rawAttributes','include','options','catch','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','encryptString','find','findOne','generateMicrosoftAuthorizationUrl','user','oauth2MicrosoftCallback','get','state','parse'];(function(_0x42f351,_0x20f87e){var _0xd9c2da=function(_0x4dd6f1){while(--_0x4dd6f1){_0x42f351['push'](_0x42f351['shift']());}};_0xd9c2da(++_0x20f87e);}(_0xf1fa,0x1e2));var _0xaf1f=function(_0x38eb95,_0x44a375){_0x38eb95=_0x38eb95-0x0;var _0x1a0d4a=_0xf1fa[_0x38eb95];return _0x1a0d4a;};'use strict';var _=require(_0xaf1f('0x0'));var Redis=require(_0xaf1f('0x1'));var qs=require(_0xaf1f('0x2'));var encryptor=require('../../components/encryptor');var config=require(_0xaf1f('0x3'));var logger=require(_0xaf1f('0x4'))(_0xaf1f('0x5'));var db=require(_0xaf1f('0x6'))['db'];var oauth=require(_0xaf1f('0x7'));config[_0xaf1f('0x8')]=_['defaults'](config['redis'],{'host':_0xaf1f('0x9'),'port':0x18eb});var socket=require(_0xaf1f('0xa'))(new Redis(config['redis']));var redis=new Redis(config[_0xaf1f('0x8')]);function respondWithStatusCode(_0x2c0c09,_0xb441a8){_0xb441a8=_0xb441a8||0xcc;return function(_0x2da2d7){if(_0x2da2d7){return _0x2c0c09[_0xaf1f('0xb')](_0xb441a8);}return _0x2c0c09['status'](_0xb441a8)[_0xaf1f('0xc')]();};}function respondWithResult(_0x8bd81c,_0x20e7a2){_0x20e7a2=_0x20e7a2||0xc8;return function(_0x192d26){if(_0x192d26){return _0x8bd81c[_0xaf1f('0xd')](_0x20e7a2)[_0xaf1f('0xe')](_0x192d26);}};}function respondWithFilteredResult(_0x4ef8ff,_0x54bb57){return function(_0x561925){if(_0x561925){var _0x17766d=typeof _0x54bb57['offset']===_0xaf1f('0xf')&&typeof _0x54bb57[_0xaf1f('0x10')]===_0xaf1f('0xf');var _0x3e86e9=_0x561925['count'];var _0x2d6285=_0x17766d?0x0:_0x54bb57['offset'];var _0x1a9fdf=_0x17766d?_0x561925[_0xaf1f('0x11')]:_0x54bb57[_0xaf1f('0x12')]+_0x54bb57[_0xaf1f('0x10')];var _0x4e72c1;if(_0x1a9fdf>=_0x3e86e9){_0x1a9fdf=_0x3e86e9;_0x4e72c1=0xc8;}else{_0x4e72c1=0xce;}_0x4ef8ff[_0xaf1f('0xd')](_0x4e72c1);return _0x4ef8ff[_0xaf1f('0x13')]('Content-Range',_0x2d6285+'-'+_0x1a9fdf+'/'+_0x3e86e9)[_0xaf1f('0xe')](_0x561925);}return null;};}function saveUpdates(_0xc5c21d){return function(_0x26f5d7){if(_0x26f5d7){return _0x26f5d7[_0xaf1f('0x14')](_0xc5c21d)[_0xaf1f('0x15')](function(_0x501445){return _0x501445;});}return null;};}function removeEntity(_0x35cd2e){return function(_0x73db66){if(_0x73db66){return _0x73db66[_0xaf1f('0x16')]()[_0xaf1f('0x15')](function(){_0x35cd2e[_0xaf1f('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x435a2a){return function(_0x9dc79e){if(!_0x9dc79e){_0x435a2a['sendStatus'](0x194);}return _0x9dc79e;};}function handleError(_0x560564,_0x1869f4){_0x1869f4=_0x1869f4||0x1f4;return function(_0x53e048){logger[_0xaf1f('0x17')](_0x53e048['stack']);if(_0x53e048[_0xaf1f('0x18')]){delete _0x53e048[_0xaf1f('0x18')];}_0x560564[_0xaf1f('0xd')](_0x1869f4)[_0xaf1f('0x19')](_0x53e048);};}function maskClientSecret(_0x2cd0c9){return _[_0xaf1f('0x1a')](_0x2cd0c9[_0xaf1f('0x1b')](0x0,0x3),0x14,'*');}exports['index']=function(_0x551468,_0x395980){var _0x3233ab={},_0x464cd6={},_0x44e359={'count':0x0,'rows':[]};var _0x4f2351=_[_0xaf1f('0x1c')](db['CloudProvider']['rawAttributes'],function(_0x1eec35){return{'name':_0x1eec35[_0xaf1f('0x1d')],'type':_0x1eec35[_0xaf1f('0x1e')]['key']};});_0x464cd6[_0xaf1f('0x1f')]=_[_0xaf1f('0x1c')](_0x4f2351,_0xaf1f('0x18'));_0x464cd6[_0xaf1f('0x20')]=_[_0xaf1f('0x21')](_0x551468['query']);_0x464cd6[_0xaf1f('0x22')]=_['intersection'](_0x464cd6[_0xaf1f('0x1f')],_0x464cd6[_0xaf1f('0x20')]);_0x3233ab[_0xaf1f('0x23')]=_[_0xaf1f('0x24')](_0x464cd6['model'],qs['fields'](_0x551468[_0xaf1f('0x20')][_0xaf1f('0x25')]));_0x3233ab[_0xaf1f('0x23')]=_0x3233ab[_0xaf1f('0x23')][_0xaf1f('0x26')]?_0x3233ab[_0xaf1f('0x23')]:_0x464cd6[_0xaf1f('0x1f')];if(!_0x551468['query'][_0xaf1f('0x27')](_0xaf1f('0x28'))){_0x3233ab[_0xaf1f('0x10')]=qs['limit'](_0x551468['query']['limit']);_0x3233ab[_0xaf1f('0x12')]=qs[_0xaf1f('0x12')](_0x551468[_0xaf1f('0x20')]['offset']);}_0x3233ab['order']=qs['sort'](_0x551468[_0xaf1f('0x20')][_0xaf1f('0x29')]);_0x3233ab[_0xaf1f('0x2a')]=qs['filters'](_[_0xaf1f('0x2b')](_0x551468[_0xaf1f('0x20')],_0x464cd6[_0xaf1f('0x22')]),_0x4f2351);if(_0x551468[_0xaf1f('0x20')][_0xaf1f('0x2c')]){_0x3233ab['where']=_[_0xaf1f('0x2d')](_0x3233ab[_0xaf1f('0x2a')],{'$or':_['map'](_0x4f2351,function(_0x509a4c){if(_0x509a4c[_0xaf1f('0x1e')]!==_0xaf1f('0x2e')){var _0x58bf9c={};_0x58bf9c[_0x509a4c[_0xaf1f('0x18')]]={'$like':'%'+_0x551468[_0xaf1f('0x20')][_0xaf1f('0x2c')]+'%'};return _0x58bf9c;}})});}_0x3233ab=_[_0xaf1f('0x2d')]({},_0x3233ab,_0x551468['options']);var _0x354615={'where':_0x3233ab['where']};return db[_0xaf1f('0x2f')][_0xaf1f('0x11')](_0x354615)[_0xaf1f('0x15')](function(_0x24cdc2){_0x44e359[_0xaf1f('0x11')]=_0x24cdc2;if(_0x551468[_0xaf1f('0x20')][_0xaf1f('0x30')]){_0x3233ab['include']=[{'all':!![]}];}return db[_0xaf1f('0x2f')][_0xaf1f('0x31')](_0x3233ab);})['then'](function(_0x2fa226){_0x44e359[_0xaf1f('0x32')]=_['map'](_0x2fa226,function(_0x5b28af){if(_0x5b28af[_0xaf1f('0x33')]===_0xaf1f('0x34')){var _0x15e2a8=encryptor[_0xaf1f('0x35')](_0x5b28af['data3']);_0x5b28af[_0xaf1f('0x36')]=maskClientSecret(_0x15e2a8);}return _0x5b28af;});return _0x44e359;})[_0xaf1f('0x15')](respondWithFilteredResult(_0x395980,_0x3233ab))['catch'](handleError(_0x395980,null));};exports[_0xaf1f('0x37')]=function(_0x2ba54e,_0x3f7654){var _0x519193={'raw':!![],'where':{'id':_0x2ba54e[_0xaf1f('0x38')]['id']}},_0x27845e={};_0x27845e[_0xaf1f('0x1f')]=_['keys'](db[_0xaf1f('0x2f')][_0xaf1f('0x39')]);_0x27845e[_0xaf1f('0x20')]=_['keys'](_0x2ba54e['query']);_0x27845e[_0xaf1f('0x22')]=_[_0xaf1f('0x24')](_0x27845e['model'],_0x27845e[_0xaf1f('0x20')]);_0x519193['attributes']=_[_0xaf1f('0x24')](_0x27845e[_0xaf1f('0x1f')],qs[_0xaf1f('0x25')](_0x2ba54e[_0xaf1f('0x20')][_0xaf1f('0x25')]));_0x519193[_0xaf1f('0x23')]=_0x519193['attributes'][_0xaf1f('0x26')]?_0x519193[_0xaf1f('0x23')]:_0x27845e[_0xaf1f('0x1f')];if(_0x2ba54e[_0xaf1f('0x20')][_0xaf1f('0x30')]){_0x519193[_0xaf1f('0x3a')]=[{'all':!![]}];}_0x519193=_[_0xaf1f('0x2d')]({},_0x519193,_0x2ba54e[_0xaf1f('0x3b')]);return db[_0xaf1f('0x2f')]['find'](_0x519193)['then'](handleEntityNotFound(_0x3f7654,null))['then'](function(_0x4cdeb9){if(_0x4cdeb9[_0xaf1f('0x33')]===_0xaf1f('0x34')){var _0x3ed09d=encryptor[_0xaf1f('0x35')](_0x4cdeb9[_0xaf1f('0x36')]);_0x4cdeb9[_0xaf1f('0x36')]=maskClientSecret(_0x3ed09d);}return _0x4cdeb9;})[_0xaf1f('0x15')](respondWithResult(_0x3f7654,null))[_0xaf1f('0x3c')](handleError(_0x3f7654,null));};exports['create']=function(_0x36dfc6,_0x151118){if(!_0x36dfc6[_0xaf1f('0x3d')]['name'])throw new Error(_0xaf1f('0x3e'));if(!_0x36dfc6[_0xaf1f('0x3d')]['service'])throw new Error(_0xaf1f('0x3f'));var _0x381ce2=db['CloudProvider'][_0xaf1f('0x39')][_0xaf1f('0x33')][_0xaf1f('0x40')];if(!_0x381ce2['includes'](_0x36dfc6['body'][_0xaf1f('0x33')]))throw new Error(_0xaf1f('0x41')+_0x381ce2[_0xaf1f('0x42')](',\x20'));if(_0x36dfc6[_0xaf1f('0x3d')][_0xaf1f('0x33')]==='MicrosoftAzure'&&_0x36dfc6[_0xaf1f('0x3d')][_0xaf1f('0x36')]){_0x36dfc6[_0xaf1f('0x3d')][_0xaf1f('0x36')]=encryptor[_0xaf1f('0x43')](_0x36dfc6[_0xaf1f('0x3d')][_0xaf1f('0x36')]);}return db[_0xaf1f('0x2f')]['create'](_0x36dfc6['body'],{})['then'](respondWithResult(_0x151118,0xc9))['catch'](handleError(_0x151118,null));};exports[_0xaf1f('0x14')]=function(_0x636ad8,_0x5814d5){if(_0x636ad8[_0xaf1f('0x3d')]['id']){delete _0x636ad8[_0xaf1f('0x3d')]['id'];}return db[_0xaf1f('0x2f')][_0xaf1f('0x44')]({'where':{'id':_0x636ad8[_0xaf1f('0x38')]['id']}})[_0xaf1f('0x15')](handleEntityNotFound(_0x5814d5,null))[_0xaf1f('0x15')](function(_0x4c12d4){if(_0x4c12d4[_0xaf1f('0x33')]===_0xaf1f('0x34')&&_0x636ad8[_0xaf1f('0x3d')][_0xaf1f('0x36')]){_0x636ad8['body'][_0xaf1f('0x36')]=encryptor[_0xaf1f('0x43')](_0x636ad8[_0xaf1f('0x3d')][_0xaf1f('0x36')]);}return _0x4c12d4;})['then'](saveUpdates(_0x636ad8['body'],null))['then'](respondWithResult(_0x5814d5,null))[_0xaf1f('0x3c')](handleError(_0x5814d5,null));};exports['destroy']=function(_0x252351,_0xfa5227){return db[_0xaf1f('0x2f')][_0xaf1f('0x44')]({'where':{'id':_0x252351[_0xaf1f('0x38')]['id']}})[_0xaf1f('0x15')](handleEntityNotFound(_0xfa5227,null))[_0xaf1f('0x15')](removeEntity(_0xfa5227,null))[_0xaf1f('0x3c')](handleError(_0xfa5227,null));};exports['oauth2MicrosoftAuthorize']=function(_0x53fbb3,_0x529260){return db['CloudProvider'][_0xaf1f('0x45')]({'where':{'id':_0x53fbb3[_0xaf1f('0x38')]['id']},'raw':!![]})[_0xaf1f('0x15')](function(_0x466e67){if(!_0x466e67)return _0x529260['sendStatus'](0x194);return{'url':oauth[_0xaf1f('0x46')](_0x466e67,_0x53fbb3[_0xaf1f('0x47')]['id'])};})[_0xaf1f('0x15')](respondWithResult(_0x529260,null))[_0xaf1f('0x3c')](handleError(_0x529260,null));};exports[_0xaf1f('0x48')]=function(_0x174efe,_0x1d06b3){var _0x1fd546=_0x174efe[_0xaf1f('0x3d')];var _0x22b5b2;var _0x56a401;if(_0x1fd546[_0xaf1f('0x17')])throw _0x1fd546;redis[_0xaf1f('0x49')](_0x1fd546[_0xaf1f('0x4a')])['then'](function(_0x10abff){if(!_0x10abff)throw new Error('Invalid\x20state\x20parameter');_0x22b5b2=JSON[_0xaf1f('0x4b')](_0x10abff);var _0x165b9e=Buffer[_0xaf1f('0x4c')](_0x1fd546[_0xaf1f('0x4a')],'base64')[_0xaf1f('0x4d')](_0xaf1f('0x4e'));_0x56a401=JSON[_0xaf1f('0x4b')](_0x165b9e);if(!oauth[_0xaf1f('0x4f')](_0x1fd546[_0xaf1f('0x50')],_0x22b5b2[_0xaf1f('0x51')]))throw new Error('Unable\x20to\x20validate\x20id_token');redis[_0xaf1f('0x52')](_0x1fd546[_0xaf1f('0x4a')]);return oauth[_0xaf1f('0x53')](_0x1fd546['code'],_0x22b5b2);})[_0xaf1f('0x15')](function(_0x3ba328){_0x22b5b2[_0xaf1f('0x54')]=_0x3ba328[_0xaf1f('0x55')];_0x22b5b2['data6']=_0x3ba328[_0xaf1f('0x56')];return db[_0xaf1f('0x2f')]['update']({'data5':_0x22b5b2['data5'],'data6':_0x22b5b2[_0xaf1f('0x57')]},{'where':{'id':_0x22b5b2['id']}});})['then'](function(){oauth['startRefreshInterval'](_0x22b5b2);socket[_0xaf1f('0x58')]('microsoftAuthorization:success',{'id':_0x56a401['id']});return;})[_0xaf1f('0x15')](respondWithStatusCode(_0x1d06b3,null))[_0xaf1f('0x3c')](function(_0x301df5){if(_0x56a401){socket['emit'](_0xaf1f('0x59'),{'id':_0x56a401['id']});}if(!_0x22b5b2){logger[_0xaf1f('0x17')]('Invalid\x20authentication\x20state\x20parameter',_0x301df5);return _0x1d06b3['status'](0x1f4)[_0xaf1f('0x19')](_0x301df5[_0xaf1f('0x5a')]);}logger[_0xaf1f('0x17')](_0xaf1f('0x5b'),_0x22b5b2['id'],JSON[_0xaf1f('0x5c')](_0x301df5));});};
\ No newline at end of file