Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index db5f022..de88fae 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x36df=['save','update','sendStatus','stack','send','index','map','CloudProvider','rawAttributes','fieldName','type','model','name','keys','query','filters','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','then','includeAll','include','findAll','rows','show','intersection','catch','create','body','find','params','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','lodash','squel','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','status','end','json','count','offset','limit','set','Content-Range','apply'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0x36df,0x72));var _0xf36d=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0x36df[_0x501510];return _0x1e6ee5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf36d('0x0'));var zipdir=require(_0xf36d('0x1'));var jsonpatch=require(_0xf36d('0x2'));var rp=require(_0xf36d('0x3'));var moment=require(_0xf36d('0x4'));var BPromise=require(_0xf36d('0x5'));var Mustache=require(_0xf36d('0x6'));var util=require(_0xf36d('0x7'));var path=require(_0xf36d('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xf36d('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf36d('0xa'));var squel=require(_0xf36d('0xb'));var crypto=require(_0xf36d('0xc'));var jsforce=require(_0xf36d('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xf36d('0xe'));var querystring=require(_0xf36d('0xf'));var Papa=require(_0xf36d('0x10'));var Redis=require(_0xf36d('0x11'));var authService=require(_0xf36d('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf36d('0x13'));var hardwareService=require(_0xf36d('0x14'));var logger=require(_0xf36d('0x15'))('api');var utils=require(_0xf36d('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xf36d('0x17'));var db=require(_0xf36d('0x18'))['db'];function respondWithStatusCode(_0x434f2b,_0x37e54a){_0x37e54a=_0x37e54a||0xcc;return function(_0x3ca6f0){if(_0x3ca6f0){return _0x434f2b['sendStatus'](_0x37e54a);}return _0x434f2b[_0xf36d('0x19')](_0x37e54a)[_0xf36d('0x1a')]();};}function respondWithResult(_0x3b9764,_0x347330){_0x347330=_0x347330||0xc8;return function(_0x12c67f){if(_0x12c67f){return _0x3b9764[_0xf36d('0x19')](_0x347330)[_0xf36d('0x1b')](_0x12c67f);}};}function respondWithFilteredResult(_0x1df427,_0x1f2494){return function(_0x180290){if(_0x180290){var _0x2dc5b2=_0x180290[_0xf36d('0x1c')],_0x505b72=_0x1f2494[_0xf36d('0x1d')],_0x565b8a=_0x1f2494['offset']+_0x1f2494[_0xf36d('0x1e')],_0x392fd0;if(_0x565b8a>=_0x2dc5b2){_0x565b8a=_0x2dc5b2;_0x392fd0=0xc8;}else{_0x392fd0=0xce;}_0x1df427['status'](_0x392fd0);return _0x1df427[_0xf36d('0x1f')](_0xf36d('0x20'),_0x505b72+'-'+_0x565b8a+'/'+_0x2dc5b2)['json'](_0x180290);}return null;};}function patchUpdates(_0x40c273){return function(_0x58503b){try{jsonpatch[_0xf36d('0x21')](_0x58503b,_0x40c273,!![]);}catch(_0x2e4b1d){return BPromise['reject'](_0x2e4b1d);}return _0x58503b[_0xf36d('0x22')]();};}function saveUpdates(_0x3a15a3,_0x5d4520){return function(_0xe49e0f){if(_0xe49e0f){return _0xe49e0f[_0xf36d('0x23')](_0x3a15a3)['then'](function(_0x27f793){return _0x27f793;});}return null;};}function removeEntity(_0x59b7c0,_0x2eb708){return function(_0x52e6b6){if(_0x52e6b6){return _0x52e6b6['destroy']()['then'](function(){_0x59b7c0[_0xf36d('0x19')](0xcc)[_0xf36d('0x1a')]();});}};}function handleEntityNotFound(_0x3d4ca5,_0x5446a3){return function(_0x206752){if(!_0x206752){_0x3d4ca5[_0xf36d('0x24')](0x194);}return _0x206752;};}function handleError(_0x2e622d,_0x12cd31){_0x12cd31=_0x12cd31||0x1f4;return function(_0x8165b9){logger['error'](_0x8165b9[_0xf36d('0x25')]);if(_0x8165b9['name']){delete _0x8165b9['name'];}_0x2e622d[_0xf36d('0x19')](_0x12cd31)[_0xf36d('0x26')](_0x8165b9);};}exports[_0xf36d('0x27')]=function(_0x1775ee,_0x723404){var _0x5daf15={},_0x58daeb={},_0x4c0eeb={'count':0x0,'rows':[]};var _0x5d29d4=_[_0xf36d('0x28')](db[_0xf36d('0x29')][_0xf36d('0x2a')],function(_0x183747){return{'name':_0x183747[_0xf36d('0x2b')],'type':_0x183747[_0xf36d('0x2c')]['key']};});_0x58daeb[_0xf36d('0x2d')]=_[_0xf36d('0x28')](_0x5d29d4,_0xf36d('0x2e'));_0x58daeb['query']=_[_0xf36d('0x2f')](_0x1775ee[_0xf36d('0x30')]);_0x58daeb[_0xf36d('0x31')]=_['intersection'](_0x58daeb['model'],_0x58daeb[_0xf36d('0x30')]);_0x5daf15[_0xf36d('0x32')]=_['intersection'](_0x58daeb[_0xf36d('0x2d')],qs[_0xf36d('0x33')](_0x1775ee[_0xf36d('0x30')][_0xf36d('0x33')]));_0x5daf15['attributes']=_0x5daf15['attributes'][_0xf36d('0x34')]?_0x5daf15[_0xf36d('0x32')]:_0x58daeb['model'];if(!_0x1775ee[_0xf36d('0x30')][_0xf36d('0x35')](_0xf36d('0x36'))){_0x5daf15[_0xf36d('0x1e')]=qs[_0xf36d('0x1e')](_0x1775ee[_0xf36d('0x30')][_0xf36d('0x1e')]);_0x5daf15[_0xf36d('0x1d')]=qs[_0xf36d('0x1d')](_0x1775ee[_0xf36d('0x30')][_0xf36d('0x1d')]);}_0x5daf15[_0xf36d('0x37')]=qs[_0xf36d('0x38')](_0x1775ee[_0xf36d('0x30')][_0xf36d('0x38')]);_0x5daf15[_0xf36d('0x39')]=qs[_0xf36d('0x31')](_[_0xf36d('0x3a')](_0x1775ee[_0xf36d('0x30')],_0x58daeb[_0xf36d('0x31')]),_0x5d29d4);if(_0x1775ee[_0xf36d('0x30')][_0xf36d('0x3b')]){_0x5daf15['where']=_[_0xf36d('0x3c')](_0x5daf15[_0xf36d('0x39')],{'$or':_[_0xf36d('0x28')](_0x5d29d4,function(_0x9909e3){if(_0x9909e3[_0xf36d('0x2c')]!=='VIRTUAL'){var _0x592616={};_0x592616[_0x9909e3[_0xf36d('0x2e')]]={'$like':'%'+_0x1775ee[_0xf36d('0x30')][_0xf36d('0x3b')]+'%'};return _0x592616;}})});}_0x5daf15=_[_0xf36d('0x3c')]({},_0x5daf15,_0x1775ee[_0xf36d('0x3d')]);var _0x474624={'where':_0x5daf15[_0xf36d('0x39')]};return db[_0xf36d('0x29')][_0xf36d('0x1c')](_0x474624)[_0xf36d('0x3e')](function(_0x2a7da8){_0x4c0eeb[_0xf36d('0x1c')]=_0x2a7da8;if(_0x1775ee[_0xf36d('0x30')][_0xf36d('0x3f')]){_0x5daf15[_0xf36d('0x40')]=[{'all':!![]}];}return db[_0xf36d('0x29')][_0xf36d('0x41')](_0x5daf15);})[_0xf36d('0x3e')](function(_0x18e066){_0x4c0eeb[_0xf36d('0x42')]=_0x18e066;return _0x4c0eeb;})[_0xf36d('0x3e')](respondWithFilteredResult(_0x723404,_0x5daf15))['catch'](handleError(_0x723404,null));};exports[_0xf36d('0x43')]=function(_0x779ff7,_0x208715){var _0x41f516={'raw':!![],'where':{'id':_0x779ff7['params']['id']}},_0x3ec676={};_0x3ec676[_0xf36d('0x2d')]=_[_0xf36d('0x2f')](db[_0xf36d('0x29')][_0xf36d('0x2a')]);_0x3ec676[_0xf36d('0x30')]=_[_0xf36d('0x2f')](_0x779ff7[_0xf36d('0x30')]);_0x3ec676[_0xf36d('0x31')]=_[_0xf36d('0x44')](_0x3ec676['model'],_0x3ec676['query']);_0x41f516[_0xf36d('0x32')]=_[_0xf36d('0x44')](_0x3ec676[_0xf36d('0x2d')],qs[_0xf36d('0x33')](_0x779ff7[_0xf36d('0x30')][_0xf36d('0x33')]));_0x41f516[_0xf36d('0x32')]=_0x41f516[_0xf36d('0x32')][_0xf36d('0x34')]?_0x41f516[_0xf36d('0x32')]:_0x3ec676[_0xf36d('0x2d')];if(_0x779ff7[_0xf36d('0x30')][_0xf36d('0x3f')]){_0x41f516[_0xf36d('0x40')]=[{'all':!![]}];}_0x41f516=_['merge']({},_0x41f516,_0x779ff7[_0xf36d('0x3d')]);return db[_0xf36d('0x29')]['find'](_0x41f516)['then'](handleEntityNotFound(_0x208715,null))[_0xf36d('0x3e')](respondWithResult(_0x208715,null))[_0xf36d('0x45')](handleError(_0x208715,null));};exports[_0xf36d('0x46')]=function(_0x445cad,_0x5a1a8f){return db['CloudProvider'][_0xf36d('0x46')](_0x445cad[_0xf36d('0x47')],{})[_0xf36d('0x3e')](respondWithResult(_0x5a1a8f,0xc9))[_0xf36d('0x45')](handleError(_0x5a1a8f,null));};exports['update']=function(_0x47b641,_0x16cbf8){if(_0x47b641['body']['id']){delete _0x47b641[_0xf36d('0x47')]['id'];}return db[_0xf36d('0x29')][_0xf36d('0x48')]({'where':{'id':_0x47b641['params']['id']}})[_0xf36d('0x3e')](handleEntityNotFound(_0x16cbf8,null))[_0xf36d('0x3e')](saveUpdates(_0x47b641[_0xf36d('0x47')],null))[_0xf36d('0x3e')](respondWithResult(_0x16cbf8,null))[_0xf36d('0x45')](handleError(_0x16cbf8,null));};exports['destroy']=function(_0x8d0705,_0x7da70f){return db['CloudProvider'][_0xf36d('0x48')]({'where':{'id':_0x8d0705[_0xf36d('0x49')]['id']}})[_0xf36d('0x3e')](handleEntityNotFound(_0x7da70f,null))[_0xf36d('0x3e')](removeEntity(_0x7da70f,null))['catch'](handleError(_0x7da70f,null));};
\ No newline at end of file
+var _0x6e44=['key','model','query','filters','intersection','fields','length','attributes','nolimit','sort','where','pick','merge','VIRTUAL','filter','options','include','MicrosoftAzure','decryptString','data3','catch','show','params','rawAttributes','keys','includeAll','find','service','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','join','encryptString','create','oauth2MicrosoftAuthorize','findOne','generateMicrosoftAuthorizationUrl','user','oauth2MicrosoftCallback','error','get','Invalid\x20state\x20parameter','parse','state','base64','ascii','id_token','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','code','data5','access_token','data6','refresh_token','emit','microsoftAuthorization:success','microsoftAuthorization:error','message','ioredis','../../components/parsers/qs','../../components/encryptor','../../config/environment','../../config/logger','api','../../mysqldb','./cloudProvider.oauth','defaults','redis','localhost','socket.io-emitter','status','end','json','offset','undefined','limit','count','set','update','destroy','then','sendStatus','stack','name','send','map','CloudProvider','fieldName','type'];(function(_0x18a543,_0x2e4b1c){var _0x305f2f=function(_0x333fea){while(--_0x333fea){_0x18a543['push'](_0x18a543['shift']());}};_0x305f2f(++_0x2e4b1c);}(_0x6e44,0x155));var _0x46e4=function(_0x16b992,_0x43d74c){_0x16b992=_0x16b992-0x0;var _0x385c78=_0x6e44[_0x16b992];return _0x385c78;};'use strict';var _=require('lodash');var Redis=require(_0x46e4('0x0'));var qs=require(_0x46e4('0x1'));var encryptor=require(_0x46e4('0x2'));var config=require(_0x46e4('0x3'));var logger=require(_0x46e4('0x4'))(_0x46e4('0x5'));var db=require(_0x46e4('0x6'))['db'];var oauth=require(_0x46e4('0x7'));config['redis']=_[_0x46e4('0x8')](config[_0x46e4('0x9')],{'host':_0x46e4('0xa'),'port':0x18eb});var socket=require(_0x46e4('0xb'))(new Redis(config[_0x46e4('0x9')]));var redis=new Redis(config[_0x46e4('0x9')]);function respondWithStatusCode(_0x2fbe3e,_0x4d8e2a){_0x4d8e2a=_0x4d8e2a||0xcc;return function(_0x7a2817){if(_0x7a2817){return _0x2fbe3e['sendStatus'](_0x4d8e2a);}return _0x2fbe3e[_0x46e4('0xc')](_0x4d8e2a)[_0x46e4('0xd')]();};}function respondWithResult(_0x434c36,_0x23e49b){_0x23e49b=_0x23e49b||0xc8;return function(_0x401e8e){if(_0x401e8e){return _0x434c36['status'](_0x23e49b)[_0x46e4('0xe')](_0x401e8e);}};}function respondWithFilteredResult(_0x4a0494,_0x2ac468){return function(_0x32f341){if(_0x32f341){var _0x57040d=typeof _0x2ac468[_0x46e4('0xf')]===_0x46e4('0x10')&&typeof _0x2ac468[_0x46e4('0x11')]===_0x46e4('0x10');var _0x5bc4fa=_0x32f341[_0x46e4('0x12')];var _0x343984=_0x57040d?0x0:_0x2ac468[_0x46e4('0xf')];var _0x4b9bf6=_0x57040d?_0x32f341[_0x46e4('0x12')]:_0x2ac468[_0x46e4('0xf')]+_0x2ac468[_0x46e4('0x11')];var _0x2afee7;if(_0x4b9bf6>=_0x5bc4fa){_0x4b9bf6=_0x5bc4fa;_0x2afee7=0xc8;}else{_0x2afee7=0xce;}_0x4a0494[_0x46e4('0xc')](_0x2afee7);return _0x4a0494[_0x46e4('0x13')]('Content-Range',_0x343984+'-'+_0x4b9bf6+'/'+_0x5bc4fa)[_0x46e4('0xe')](_0x32f341);}return null;};}function saveUpdates(_0x4520ef){return function(_0x1cd6a1){if(_0x1cd6a1){return _0x1cd6a1[_0x46e4('0x14')](_0x4520ef)['then'](function(_0x291e39){return _0x291e39;});}return null;};}function removeEntity(_0x3174c6){return function(_0x5c8579){if(_0x5c8579){return _0x5c8579[_0x46e4('0x15')]()[_0x46e4('0x16')](function(){_0x3174c6[_0x46e4('0xc')](0xcc)['end']();});}};}function handleEntityNotFound(_0xdf794c){return function(_0x49ff17){if(!_0x49ff17){_0xdf794c[_0x46e4('0x17')](0x194);}return _0x49ff17;};}function handleError(_0x4c5ccb,_0x14611d){_0x14611d=_0x14611d||0x1f4;return function(_0x47b6ff){logger['error'](_0x47b6ff[_0x46e4('0x18')]);if(_0x47b6ff['name']){delete _0x47b6ff[_0x46e4('0x19')];}_0x4c5ccb['status'](_0x14611d)[_0x46e4('0x1a')](_0x47b6ff);};}function maskClientSecret(_0x5e79ed){return _['padEnd'](_0x5e79ed['slice'](0x0,0x3),0x14,'*');}exports['index']=function(_0x4c68b4,_0x1619b7){var _0x3d8dc7={},_0x31674a={},_0x10fe9a={'count':0x0,'rows':[]};var _0x51faa6=_[_0x46e4('0x1b')](db[_0x46e4('0x1c')]['rawAttributes'],function(_0x2ec142){return{'name':_0x2ec142[_0x46e4('0x1d')],'type':_0x2ec142[_0x46e4('0x1e')][_0x46e4('0x1f')]};});_0x31674a[_0x46e4('0x20')]=_[_0x46e4('0x1b')](_0x51faa6,'name');_0x31674a[_0x46e4('0x21')]=_['keys'](_0x4c68b4[_0x46e4('0x21')]);_0x31674a[_0x46e4('0x22')]=_[_0x46e4('0x23')](_0x31674a['model'],_0x31674a['query']);_0x3d8dc7['attributes']=_['intersection'](_0x31674a[_0x46e4('0x20')],qs[_0x46e4('0x24')](_0x4c68b4[_0x46e4('0x21')][_0x46e4('0x24')]));_0x3d8dc7['attributes']=_0x3d8dc7['attributes'][_0x46e4('0x25')]?_0x3d8dc7[_0x46e4('0x26')]:_0x31674a[_0x46e4('0x20')];if(!_0x4c68b4['query']['hasOwnProperty'](_0x46e4('0x27'))){_0x3d8dc7[_0x46e4('0x11')]=qs['limit'](_0x4c68b4[_0x46e4('0x21')][_0x46e4('0x11')]);_0x3d8dc7[_0x46e4('0xf')]=qs[_0x46e4('0xf')](_0x4c68b4['query'][_0x46e4('0xf')]);}_0x3d8dc7['order']=qs[_0x46e4('0x28')](_0x4c68b4[_0x46e4('0x21')][_0x46e4('0x28')]);_0x3d8dc7[_0x46e4('0x29')]=qs['filters'](_[_0x46e4('0x2a')](_0x4c68b4['query'],_0x31674a[_0x46e4('0x22')]),_0x51faa6);if(_0x4c68b4[_0x46e4('0x21')]['filter']){_0x3d8dc7[_0x46e4('0x29')]=_[_0x46e4('0x2b')](_0x3d8dc7[_0x46e4('0x29')],{'$or':_[_0x46e4('0x1b')](_0x51faa6,function(_0x591056){if(_0x591056['type']!==_0x46e4('0x2c')){var _0x298a70={};_0x298a70[_0x591056['name']]={'$like':'%'+_0x4c68b4['query'][_0x46e4('0x2d')]+'%'};return _0x298a70;}})});}_0x3d8dc7=_[_0x46e4('0x2b')]({},_0x3d8dc7,_0x4c68b4[_0x46e4('0x2e')]);var _0x41ca42={'where':_0x3d8dc7[_0x46e4('0x29')]};return db[_0x46e4('0x1c')][_0x46e4('0x12')](_0x41ca42)['then'](function(_0x32e5cd){_0x10fe9a['count']=_0x32e5cd;if(_0x4c68b4[_0x46e4('0x21')]['includeAll']){_0x3d8dc7[_0x46e4('0x2f')]=[{'all':!![]}];}return db[_0x46e4('0x1c')]['findAll'](_0x3d8dc7);})['then'](function(_0x2e64d4){_0x10fe9a['rows']=_['map'](_0x2e64d4,function(_0x45bca7){if(_0x45bca7['service']===_0x46e4('0x30')){var _0x300a4f=encryptor[_0x46e4('0x31')](_0x45bca7[_0x46e4('0x32')]);_0x45bca7['data3']=maskClientSecret(_0x300a4f);}return _0x45bca7;});return _0x10fe9a;})[_0x46e4('0x16')](respondWithFilteredResult(_0x1619b7,_0x3d8dc7))[_0x46e4('0x33')](handleError(_0x1619b7,null));};exports[_0x46e4('0x34')]=function(_0x260f22,_0x150578){var _0x5ef16e={'raw':!![],'where':{'id':_0x260f22[_0x46e4('0x35')]['id']}},_0x4ca81c={};_0x4ca81c['model']=_['keys'](db[_0x46e4('0x1c')][_0x46e4('0x36')]);_0x4ca81c[_0x46e4('0x21')]=_[_0x46e4('0x37')](_0x260f22['query']);_0x4ca81c[_0x46e4('0x22')]=_['intersection'](_0x4ca81c[_0x46e4('0x20')],_0x4ca81c['query']);_0x5ef16e['attributes']=_[_0x46e4('0x23')](_0x4ca81c[_0x46e4('0x20')],qs['fields'](_0x260f22['query'][_0x46e4('0x24')]));_0x5ef16e[_0x46e4('0x26')]=_0x5ef16e[_0x46e4('0x26')]['length']?_0x5ef16e['attributes']:_0x4ca81c[_0x46e4('0x20')];if(_0x260f22[_0x46e4('0x21')][_0x46e4('0x38')]){_0x5ef16e[_0x46e4('0x2f')]=[{'all':!![]}];}_0x5ef16e=_['merge']({},_0x5ef16e,_0x260f22[_0x46e4('0x2e')]);return db[_0x46e4('0x1c')][_0x46e4('0x39')](_0x5ef16e)['then'](handleEntityNotFound(_0x150578,null))[_0x46e4('0x16')](function(_0x695506){if(_0x695506[_0x46e4('0x3a')]===_0x46e4('0x30')){var _0x42d480=encryptor[_0x46e4('0x31')](_0x695506[_0x46e4('0x32')]);_0x695506['data3']=maskClientSecret(_0x42d480);}return _0x695506;})[_0x46e4('0x16')](respondWithResult(_0x150578,null))[_0x46e4('0x33')](handleError(_0x150578,null));};exports['create']=function(_0x4434db,_0x19dc4f){if(!_0x4434db[_0x46e4('0x3b')][_0x46e4('0x19')])throw new Error(_0x46e4('0x3c'));if(!_0x4434db[_0x46e4('0x3b')][_0x46e4('0x3a')])throw new Error(_0x46e4('0x3d'));var _0x521230=db['CloudProvider']['rawAttributes'][_0x46e4('0x3a')][_0x46e4('0x3e')];if(!_0x521230[_0x46e4('0x3f')](_0x4434db[_0x46e4('0x3b')]['service']))throw new Error(_0x46e4('0x40')+_0x521230[_0x46e4('0x41')](',\x20'));if(_0x4434db[_0x46e4('0x3b')][_0x46e4('0x3a')]===_0x46e4('0x30')&&_0x4434db[_0x46e4('0x3b')]['data3']){_0x4434db[_0x46e4('0x3b')][_0x46e4('0x32')]=encryptor[_0x46e4('0x42')](_0x4434db['body']['data3']);}return db[_0x46e4('0x1c')][_0x46e4('0x43')](_0x4434db[_0x46e4('0x3b')],{})['then'](respondWithResult(_0x19dc4f,0xc9))[_0x46e4('0x33')](handleError(_0x19dc4f,null));};exports['update']=function(_0x5124d3,_0x31088e){if(_0x5124d3['body']['id']){delete _0x5124d3[_0x46e4('0x3b')]['id'];}return db[_0x46e4('0x1c')][_0x46e4('0x39')]({'where':{'id':_0x5124d3[_0x46e4('0x35')]['id']}})[_0x46e4('0x16')](handleEntityNotFound(_0x31088e,null))[_0x46e4('0x16')](function(_0x240621){if(_0x240621['service']===_0x46e4('0x30')&&_0x5124d3[_0x46e4('0x3b')][_0x46e4('0x32')]){_0x5124d3[_0x46e4('0x3b')][_0x46e4('0x32')]=encryptor[_0x46e4('0x42')](_0x5124d3[_0x46e4('0x3b')][_0x46e4('0x32')]);}return _0x240621;})[_0x46e4('0x16')](saveUpdates(_0x5124d3[_0x46e4('0x3b')],null))['then'](respondWithResult(_0x31088e,null))[_0x46e4('0x33')](handleError(_0x31088e,null));};exports[_0x46e4('0x15')]=function(_0x3b8389,_0x26d3b5){return db[_0x46e4('0x1c')][_0x46e4('0x39')]({'where':{'id':_0x3b8389[_0x46e4('0x35')]['id']}})['then'](handleEntityNotFound(_0x26d3b5,null))[_0x46e4('0x16')](removeEntity(_0x26d3b5,null))[_0x46e4('0x33')](handleError(_0x26d3b5,null));};exports[_0x46e4('0x44')]=function(_0x438f95,_0x4ad8d5){return db['CloudProvider'][_0x46e4('0x45')]({'where':{'id':_0x438f95[_0x46e4('0x35')]['id']},'raw':!![]})[_0x46e4('0x16')](function(_0x46cb07){if(!_0x46cb07)return _0x4ad8d5['sendStatus'](0x194);return{'url':oauth[_0x46e4('0x46')](_0x46cb07,_0x438f95[_0x46e4('0x47')]['id'])};})[_0x46e4('0x16')](respondWithResult(_0x4ad8d5,null))[_0x46e4('0x33')](handleError(_0x4ad8d5,null));};exports[_0x46e4('0x48')]=function(_0x222eca,_0x1e3015){var _0x3364c8=_0x222eca[_0x46e4('0x3b')];var _0x586deb;var _0x139074;if(_0x3364c8[_0x46e4('0x49')])throw _0x3364c8;redis[_0x46e4('0x4a')](_0x3364c8['state'])[_0x46e4('0x16')](function(_0x207339){if(!_0x207339)throw new Error(_0x46e4('0x4b'));_0x586deb=JSON[_0x46e4('0x4c')](_0x207339);var _0x53d5bd=Buffer['from'](_0x3364c8[_0x46e4('0x4d')],_0x46e4('0x4e'))['toString'](_0x46e4('0x4f'));_0x139074=JSON[_0x46e4('0x4c')](_0x53d5bd);if(!oauth['isValidIdToken'](_0x3364c8[_0x46e4('0x50')],_0x586deb[_0x46e4('0x51')]))throw new Error(_0x46e4('0x52'));redis[_0x46e4('0x53')](_0x3364c8[_0x46e4('0x4d')]);return oauth['getOauth2MicrosoftAccessToken'](_0x3364c8[_0x46e4('0x54')],_0x586deb);})['then'](function(_0xc8d1f){_0x586deb[_0x46e4('0x55')]=_0xc8d1f[_0x46e4('0x56')];_0x586deb[_0x46e4('0x57')]=_0xc8d1f[_0x46e4('0x58')];return db[_0x46e4('0x1c')][_0x46e4('0x14')]({'data5':_0x586deb['data5'],'data6':_0x586deb[_0x46e4('0x57')]},{'where':{'id':_0x586deb['id']}});})[_0x46e4('0x16')](function(){oauth['startRefreshInterval'](_0x586deb);socket[_0x46e4('0x59')](_0x46e4('0x5a'),{'id':_0x139074['id']});return;})[_0x46e4('0x16')](respondWithStatusCode(_0x1e3015,null))[_0x46e4('0x33')](function(_0x29c90b){if(_0x139074){socket[_0x46e4('0x59')](_0x46e4('0x5b'),{'id':_0x139074['id']});}if(!_0x586deb){logger['error']('Invalid\x20authentication\x20state\x20parameter',_0x29c90b);return _0x1e3015[_0x46e4('0xc')](0x1f4)['send'](_0x29c90b[_0x46e4('0x5c')]);}logger[_0x46e4('0x49')]('Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s',_0x586deb['id'],JSON['stringify'](_0x29c90b));});};
\ No newline at end of file