Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / cloudProvider / cloudProvider.controller.js
index 1a02b17..b2af5a2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f66=['update','catch','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','sendStatus','status','end','json','undefined','limit','count','offset','Content-Range','apply','reject','save','destroy','then','error','name','send','index','map','CloudProvider','rawAttributes','fieldName','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filter','merge','type','VIRTUAL','includeAll','include','findAll','rows','show','params','find','create','body'];(function(_0x1efb1e,_0x1a093d){var _0x117e95=function(_0x2de7f7){while(--_0x2de7f7){_0x1efb1e['push'](_0x1efb1e['shift']());}};_0x117e95(++_0x1a093d);}(_0x5f66,0x1a0));var _0x65f6=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x5f66[_0x3947c9];return _0x2e7871;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x65f6('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x65f6('0x1'));var rp=require(_0x65f6('0x2'));var moment=require(_0x65f6('0x3'));var BPromise=require(_0x65f6('0x4'));var Mustache=require(_0x65f6('0x5'));var util=require('util');var path=require(_0x65f6('0x6'));var sox=require('sox');var csv=require(_0x65f6('0x7'));var ejs=require(_0x65f6('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x65f6('0x9'));var crypto=require(_0x65f6('0xa'));var jsforce=require(_0x65f6('0xb'));var deskjs=require(_0x65f6('0xc'));var toCsv=require(_0x65f6('0x7'));var querystring=require(_0x65f6('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x65f6('0xe'));var qs=require(_0x65f6('0xf'));var as=require(_0x65f6('0x10'));var hardwareService=require(_0x65f6('0x11'));var logger=require('../../config/logger')(_0x65f6('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x65f6('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x419819,_0x4862a5){_0x4862a5=_0x4862a5||0xcc;return function(_0x2f964a){if(_0x2f964a){return _0x419819[_0x65f6('0x14')](_0x4862a5);}return _0x419819[_0x65f6('0x15')](_0x4862a5)[_0x65f6('0x16')]();};}function respondWithResult(_0x369f96,_0x1d29fd){_0x1d29fd=_0x1d29fd||0xc8;return function(_0x44144b){if(_0x44144b){return _0x369f96[_0x65f6('0x15')](_0x1d29fd)[_0x65f6('0x17')](_0x44144b);}};}function respondWithFilteredResult(_0x3440af,_0x59154e){return function(_0x19b9ff){if(_0x19b9ff){var _0x49a913=typeof _0x59154e['offset']===_0x65f6('0x18')&&typeof _0x59154e[_0x65f6('0x19')]===_0x65f6('0x18');var _0x1c955c=_0x19b9ff[_0x65f6('0x1a')];var _0x1f974c=_0x49a913?0x0:_0x59154e[_0x65f6('0x1b')];var _0x18380e=_0x49a913?_0x19b9ff['count']:_0x59154e['offset']+_0x59154e[_0x65f6('0x19')];var _0x5b4055;if(_0x18380e>=_0x1c955c){_0x18380e=_0x1c955c;_0x5b4055=0xc8;}else{_0x5b4055=0xce;}_0x3440af['status'](_0x5b4055);return _0x3440af['set'](_0x65f6('0x1c'),_0x1f974c+'-'+_0x18380e+'/'+_0x1c955c)[_0x65f6('0x17')](_0x19b9ff);}return null;};}function patchUpdates(_0x5114a4){return function(_0x39e19f){try{jsonpatch[_0x65f6('0x1d')](_0x39e19f,_0x5114a4,!![]);}catch(_0xbee6a4){return BPromise[_0x65f6('0x1e')](_0xbee6a4);}return _0x39e19f[_0x65f6('0x1f')]();};}function saveUpdates(_0xc139c2,_0x581374){return function(_0x197a49){if(_0x197a49){return _0x197a49['update'](_0xc139c2)['then'](function(_0x212247){return _0x212247;});}return null;};}function removeEntity(_0xd173f4,_0x524e42){return function(_0x1eeaaa){if(_0x1eeaaa){return _0x1eeaaa[_0x65f6('0x20')]()[_0x65f6('0x21')](function(){_0xd173f4[_0x65f6('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x9d7bb0,_0x59ea32){return function(_0x20a161){if(!_0x20a161){_0x9d7bb0['sendStatus'](0x194);}return _0x20a161;};}function handleError(_0x5cb131,_0x4fde2f){_0x4fde2f=_0x4fde2f||0x1f4;return function(_0x29abdb){logger[_0x65f6('0x22')](_0x29abdb['stack']);if(_0x29abdb[_0x65f6('0x23')]){delete _0x29abdb[_0x65f6('0x23')];}_0x5cb131['status'](_0x4fde2f)[_0x65f6('0x24')](_0x29abdb);};}exports[_0x65f6('0x25')]=function(_0x28d0df,_0x559330){var _0x4ac04b={},_0x488d36={},_0x266cfe={'count':0x0,'rows':[]};var _0x3c032f=_[_0x65f6('0x26')](db[_0x65f6('0x27')][_0x65f6('0x28')],function(_0x14a387){return{'name':_0x14a387[_0x65f6('0x29')],'type':_0x14a387['type']['key']};});_0x488d36[_0x65f6('0x2a')]=_[_0x65f6('0x26')](_0x3c032f,'name');_0x488d36['query']=_[_0x65f6('0x2b')](_0x28d0df[_0x65f6('0x2c')]);_0x488d36[_0x65f6('0x2d')]=_[_0x65f6('0x2e')](_0x488d36[_0x65f6('0x2a')],_0x488d36[_0x65f6('0x2c')]);_0x4ac04b['attributes']=_[_0x65f6('0x2e')](_0x488d36[_0x65f6('0x2a')],qs[_0x65f6('0x2f')](_0x28d0df['query'][_0x65f6('0x2f')]));_0x4ac04b[_0x65f6('0x30')]=_0x4ac04b[_0x65f6('0x30')][_0x65f6('0x31')]?_0x4ac04b[_0x65f6('0x30')]:_0x488d36[_0x65f6('0x2a')];if(!_0x28d0df['query'][_0x65f6('0x32')](_0x65f6('0x33'))){_0x4ac04b['limit']=qs[_0x65f6('0x19')](_0x28d0df['query'][_0x65f6('0x19')]);_0x4ac04b['offset']=qs[_0x65f6('0x1b')](_0x28d0df[_0x65f6('0x2c')]['offset']);}_0x4ac04b[_0x65f6('0x34')]=qs[_0x65f6('0x35')](_0x28d0df[_0x65f6('0x2c')]['sort']);_0x4ac04b['where']=qs[_0x65f6('0x2d')](_['pick'](_0x28d0df[_0x65f6('0x2c')],_0x488d36['filters']),_0x3c032f);if(_0x28d0df[_0x65f6('0x2c')][_0x65f6('0x36')]){_0x4ac04b['where']=_[_0x65f6('0x37')](_0x4ac04b['where'],{'$or':_['map'](_0x3c032f,function(_0x71b16b){if(_0x71b16b[_0x65f6('0x38')]!==_0x65f6('0x39')){var _0x313be5={};_0x313be5[_0x71b16b[_0x65f6('0x23')]]={'$like':'%'+_0x28d0df[_0x65f6('0x2c')][_0x65f6('0x36')]+'%'};return _0x313be5;}})});}_0x4ac04b=_[_0x65f6('0x37')]({},_0x4ac04b,_0x28d0df['options']);var _0x3aa254={'where':_0x4ac04b['where']};return db[_0x65f6('0x27')][_0x65f6('0x1a')](_0x3aa254)[_0x65f6('0x21')](function(_0x2ea7f7){_0x266cfe['count']=_0x2ea7f7;if(_0x28d0df[_0x65f6('0x2c')][_0x65f6('0x3a')]){_0x4ac04b[_0x65f6('0x3b')]=[{'all':!![]}];}return db[_0x65f6('0x27')][_0x65f6('0x3c')](_0x4ac04b);})[_0x65f6('0x21')](function(_0xed4c96){_0x266cfe[_0x65f6('0x3d')]=_0xed4c96;return _0x266cfe;})[_0x65f6('0x21')](respondWithFilteredResult(_0x559330,_0x4ac04b))['catch'](handleError(_0x559330,null));};exports[_0x65f6('0x3e')]=function(_0x400ed2,_0x377ae5){var _0x181798={'raw':!![],'where':{'id':_0x400ed2[_0x65f6('0x3f')]['id']}},_0x83e2d9={};_0x83e2d9[_0x65f6('0x2a')]=_[_0x65f6('0x2b')](db[_0x65f6('0x27')][_0x65f6('0x28')]);_0x83e2d9[_0x65f6('0x2c')]=_[_0x65f6('0x2b')](_0x400ed2[_0x65f6('0x2c')]);_0x83e2d9[_0x65f6('0x2d')]=_[_0x65f6('0x2e')](_0x83e2d9[_0x65f6('0x2a')],_0x83e2d9['query']);_0x181798[_0x65f6('0x30')]=_[_0x65f6('0x2e')](_0x83e2d9[_0x65f6('0x2a')],qs[_0x65f6('0x2f')](_0x400ed2['query'][_0x65f6('0x2f')]));_0x181798[_0x65f6('0x30')]=_0x181798[_0x65f6('0x30')]['length']?_0x181798[_0x65f6('0x30')]:_0x83e2d9[_0x65f6('0x2a')];if(_0x400ed2[_0x65f6('0x2c')][_0x65f6('0x3a')]){_0x181798['include']=[{'all':!![]}];}_0x181798=_[_0x65f6('0x37')]({},_0x181798,_0x400ed2['options']);return db[_0x65f6('0x27')][_0x65f6('0x40')](_0x181798)['then'](handleEntityNotFound(_0x377ae5,null))[_0x65f6('0x21')](respondWithResult(_0x377ae5,null))['catch'](handleError(_0x377ae5,null));};exports[_0x65f6('0x41')]=function(_0x4d9b76,_0x2d1706){return db[_0x65f6('0x27')][_0x65f6('0x41')](_0x4d9b76[_0x65f6('0x42')],{})['then'](respondWithResult(_0x2d1706,0xc9))['catch'](handleError(_0x2d1706,null));};exports[_0x65f6('0x43')]=function(_0x15d3ba,_0x3b647a){if(_0x15d3ba[_0x65f6('0x42')]['id']){delete _0x15d3ba[_0x65f6('0x42')]['id'];}return db[_0x65f6('0x27')][_0x65f6('0x40')]({'where':{'id':_0x15d3ba[_0x65f6('0x3f')]['id']}})[_0x65f6('0x21')](handleEntityNotFound(_0x3b647a,null))['then'](saveUpdates(_0x15d3ba[_0x65f6('0x42')],null))[_0x65f6('0x21')](respondWithResult(_0x3b647a,null))[_0x65f6('0x44')](handleError(_0x3b647a,null));};exports['destroy']=function(_0x47e749,_0x42d453){return db['CloudProvider'][_0x65f6('0x40')]({'where':{'id':_0x47e749[_0x65f6('0x3f')]['id']}})['then'](handleEntityNotFound(_0x42d453,null))[_0x65f6('0x21')](removeEntity(_0x42d453,null))['catch'](handleError(_0x42d453,null));};
\ No newline at end of file
+var _0x4d34=['Invalid\x20authentication\x20state\x20parameter','message','Authentication\x20failed\x20for\x20cloud\x20provider\x20#%s,\x20err:%s','stringify','lodash','ioredis','../../components/parsers/qs','../../components/encryptor','../../config/environment','api','./cloudProvider.oauth','redis','localhost','socket.io-emitter','sendStatus','status','end','offset','undefined','limit','set','Content-Range','update','then','destroy','stack','name','send','padEnd','index','map','CloudProvider','rawAttributes','type','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','filter','options','count','findAll','rows','service','data3','catch','show','params','includeAll','include','find','decryptString','body','Name\x20parameter\x20not\x20specified','Service\x20parameter\x20not\x20specified','values','includes','Invalid\x20service\x20parameter.\x20Allowed\x20values:\x20','MicrosoftAzure','encryptString','create','oauth2MicrosoftAuthorize','generateMicrosoftAuthorizationUrl','user','oauth2MicrosoftCallback','error','state','Invalid\x20state\x20parameter','from','base64','toString','ascii','parse','oauth2Claims','Unable\x20to\x20validate\x20id_token','del','code','data5','access_token','data6','refresh_token','startRefreshInterval','emit','microsoftAuthorization:success'];(function(_0x3142ce,_0xd0df8b){var _0x540eb1=function(_0x69dcf5){while(--_0x69dcf5){_0x3142ce['push'](_0x3142ce['shift']());}};_0x540eb1(++_0xd0df8b);}(_0x4d34,0x121));var _0x44d3=function(_0xf7366a,_0x5a7c7a){_0xf7366a=_0xf7366a-0x0;var _0x2c422c=_0x4d34[_0xf7366a];return _0x2c422c;};'use strict';var _=require(_0x44d3('0x0'));var Redis=require(_0x44d3('0x1'));var qs=require(_0x44d3('0x2'));var encryptor=require(_0x44d3('0x3'));var config=require(_0x44d3('0x4'));var logger=require('../../config/logger')(_0x44d3('0x5'));var db=require('../../mysqldb')['db'];var oauth=require(_0x44d3('0x6'));config['redis']=_['defaults'](config[_0x44d3('0x7')],{'host':_0x44d3('0x8'),'port':0x18eb});var socket=require(_0x44d3('0x9'))(new Redis(config[_0x44d3('0x7')]));var redis=new Redis(config[_0x44d3('0x7')]);function respondWithStatusCode(_0x3527a1,_0x11ed14){_0x11ed14=_0x11ed14||0xcc;return function(_0x44010b){if(_0x44010b){return _0x3527a1[_0x44d3('0xa')](_0x11ed14);}return _0x3527a1[_0x44d3('0xb')](_0x11ed14)[_0x44d3('0xc')]();};}function respondWithResult(_0x2a1dae,_0x30f020){_0x30f020=_0x30f020||0xc8;return function(_0x2fbf24){if(_0x2fbf24){return _0x2a1dae['status'](_0x30f020)['json'](_0x2fbf24);}};}function respondWithFilteredResult(_0xaff257,_0x2048f3){return function(_0x47d286){if(_0x47d286){var _0x13e039=typeof _0x2048f3[_0x44d3('0xd')]===_0x44d3('0xe')&&typeof _0x2048f3['limit']===_0x44d3('0xe');var _0x126a21=_0x47d286['count'];var _0x11c2eb=_0x13e039?0x0:_0x2048f3[_0x44d3('0xd')];var _0x4fd527=_0x13e039?_0x47d286['count']:_0x2048f3['offset']+_0x2048f3[_0x44d3('0xf')];var _0x550cb4;if(_0x4fd527>=_0x126a21){_0x4fd527=_0x126a21;_0x550cb4=0xc8;}else{_0x550cb4=0xce;}_0xaff257[_0x44d3('0xb')](_0x550cb4);return _0xaff257[_0x44d3('0x10')](_0x44d3('0x11'),_0x11c2eb+'-'+_0x4fd527+'/'+_0x126a21)['json'](_0x47d286);}return null;};}function saveUpdates(_0x4aa8d5){return function(_0xcf8d21){if(_0xcf8d21){return _0xcf8d21[_0x44d3('0x12')](_0x4aa8d5)[_0x44d3('0x13')](function(_0x5e6b4f){return _0x5e6b4f;});}return null;};}function removeEntity(_0x54c58f){return function(_0x12f261){if(_0x12f261){return _0x12f261[_0x44d3('0x14')]()[_0x44d3('0x13')](function(){_0x54c58f[_0x44d3('0xb')](0xcc)[_0x44d3('0xc')]();});}};}function handleEntityNotFound(_0x189c1c){return function(_0x2d6c06){if(!_0x2d6c06){_0x189c1c[_0x44d3('0xa')](0x194);}return _0x2d6c06;};}function handleError(_0x17ad6f,_0x271e56){_0x271e56=_0x271e56||0x1f4;return function(_0x5f0244){logger['error'](_0x5f0244[_0x44d3('0x15')]);if(_0x5f0244[_0x44d3('0x16')]){delete _0x5f0244[_0x44d3('0x16')];}_0x17ad6f['status'](_0x271e56)[_0x44d3('0x17')](_0x5f0244);};}function maskClientSecret(_0x4e2e89){return _[_0x44d3('0x18')](_0x4e2e89['slice'](0x0,0x3),0x14,'*');}exports[_0x44d3('0x19')]=function(_0x4db0c2,_0x39747d){var _0x53f34c={},_0x2f2258={},_0x254f0b={'count':0x0,'rows':[]};var _0x4181aa=_[_0x44d3('0x1a')](db[_0x44d3('0x1b')][_0x44d3('0x1c')],function(_0x1ae7aa){return{'name':_0x1ae7aa['fieldName'],'type':_0x1ae7aa[_0x44d3('0x1d')]['key']};});_0x2f2258[_0x44d3('0x1e')]=_['map'](_0x4181aa,_0x44d3('0x16'));_0x2f2258['query']=_[_0x44d3('0x1f')](_0x4db0c2[_0x44d3('0x20')]);_0x2f2258[_0x44d3('0x21')]=_['intersection'](_0x2f2258[_0x44d3('0x1e')],_0x2f2258[_0x44d3('0x20')]);_0x53f34c[_0x44d3('0x22')]=_[_0x44d3('0x23')](_0x2f2258[_0x44d3('0x1e')],qs[_0x44d3('0x24')](_0x4db0c2[_0x44d3('0x20')][_0x44d3('0x24')]));_0x53f34c[_0x44d3('0x22')]=_0x53f34c['attributes'][_0x44d3('0x25')]?_0x53f34c[_0x44d3('0x22')]:_0x2f2258['model'];if(!_0x4db0c2[_0x44d3('0x20')][_0x44d3('0x26')](_0x44d3('0x27'))){_0x53f34c[_0x44d3('0xf')]=qs['limit'](_0x4db0c2[_0x44d3('0x20')][_0x44d3('0xf')]);_0x53f34c[_0x44d3('0xd')]=qs[_0x44d3('0xd')](_0x4db0c2[_0x44d3('0x20')][_0x44d3('0xd')]);}_0x53f34c[_0x44d3('0x28')]=qs['sort'](_0x4db0c2['query'][_0x44d3('0x29')]);_0x53f34c[_0x44d3('0x2a')]=qs[_0x44d3('0x21')](_[_0x44d3('0x2b')](_0x4db0c2[_0x44d3('0x20')],_0x2f2258[_0x44d3('0x21')]),_0x4181aa);if(_0x4db0c2[_0x44d3('0x20')]['filter']){_0x53f34c[_0x44d3('0x2a')]=_[_0x44d3('0x2c')](_0x53f34c[_0x44d3('0x2a')],{'$or':_[_0x44d3('0x1a')](_0x4181aa,function(_0x198696){if(_0x198696[_0x44d3('0x1d')]!=='VIRTUAL'){var _0x564a69={};_0x564a69[_0x198696[_0x44d3('0x16')]]={'$like':'%'+_0x4db0c2[_0x44d3('0x20')][_0x44d3('0x2d')]+'%'};return _0x564a69;}})});}_0x53f34c=_[_0x44d3('0x2c')]({},_0x53f34c,_0x4db0c2[_0x44d3('0x2e')]);var _0x781d02={'where':_0x53f34c[_0x44d3('0x2a')]};return db[_0x44d3('0x1b')][_0x44d3('0x2f')](_0x781d02)[_0x44d3('0x13')](function(_0x16851a){_0x254f0b[_0x44d3('0x2f')]=_0x16851a;if(_0x4db0c2[_0x44d3('0x20')]['includeAll']){_0x53f34c['include']=[{'all':!![]}];}return db[_0x44d3('0x1b')][_0x44d3('0x30')](_0x53f34c);})['then'](function(_0x170b09){_0x254f0b[_0x44d3('0x31')]=_['map'](_0x170b09,function(_0x224bdf){if(_0x224bdf[_0x44d3('0x32')]==='MicrosoftAzure'){var _0x3bac2e=encryptor['decryptString'](_0x224bdf['data3']);_0x224bdf[_0x44d3('0x33')]=maskClientSecret(_0x3bac2e);}return _0x224bdf;});return _0x254f0b;})[_0x44d3('0x13')](respondWithFilteredResult(_0x39747d,_0x53f34c))[_0x44d3('0x34')](handleError(_0x39747d,null));};exports[_0x44d3('0x35')]=function(_0x320571,_0x58e9cd){var _0x57535c={'raw':!![],'where':{'id':_0x320571[_0x44d3('0x36')]['id']}},_0x357ca2={};_0x357ca2['model']=_[_0x44d3('0x1f')](db['CloudProvider'][_0x44d3('0x1c')]);_0x357ca2[_0x44d3('0x20')]=_[_0x44d3('0x1f')](_0x320571[_0x44d3('0x20')]);_0x357ca2[_0x44d3('0x21')]=_[_0x44d3('0x23')](_0x357ca2[_0x44d3('0x1e')],_0x357ca2[_0x44d3('0x20')]);_0x57535c['attributes']=_[_0x44d3('0x23')](_0x357ca2['model'],qs['fields'](_0x320571[_0x44d3('0x20')]['fields']));_0x57535c['attributes']=_0x57535c[_0x44d3('0x22')][_0x44d3('0x25')]?_0x57535c[_0x44d3('0x22')]:_0x357ca2[_0x44d3('0x1e')];if(_0x320571[_0x44d3('0x20')][_0x44d3('0x37')]){_0x57535c[_0x44d3('0x38')]=[{'all':!![]}];}_0x57535c=_['merge']({},_0x57535c,_0x320571['options']);return db['CloudProvider'][_0x44d3('0x39')](_0x57535c)[_0x44d3('0x13')](handleEntityNotFound(_0x58e9cd,null))[_0x44d3('0x13')](function(_0x4a76d8){if(_0x4a76d8[_0x44d3('0x32')]==='MicrosoftAzure'){var _0x3f2d7a=encryptor[_0x44d3('0x3a')](_0x4a76d8[_0x44d3('0x33')]);_0x4a76d8[_0x44d3('0x33')]=maskClientSecret(_0x3f2d7a);}return _0x4a76d8;})[_0x44d3('0x13')](respondWithResult(_0x58e9cd,null))[_0x44d3('0x34')](handleError(_0x58e9cd,null));};exports['create']=function(_0x55d6f5,_0x4d0c0f){if(!_0x55d6f5[_0x44d3('0x3b')][_0x44d3('0x16')])throw new Error(_0x44d3('0x3c'));if(!_0x55d6f5[_0x44d3('0x3b')][_0x44d3('0x32')])throw new Error(_0x44d3('0x3d'));var _0x4c31ed=db[_0x44d3('0x1b')][_0x44d3('0x1c')][_0x44d3('0x32')][_0x44d3('0x3e')];if(!_0x4c31ed[_0x44d3('0x3f')](_0x55d6f5['body']['service']))throw new Error(_0x44d3('0x40')+_0x4c31ed['join'](',\x20'));if(_0x55d6f5['body'][_0x44d3('0x32')]===_0x44d3('0x41')&&_0x55d6f5[_0x44d3('0x3b')][_0x44d3('0x33')]){_0x55d6f5[_0x44d3('0x3b')]['data3']=encryptor[_0x44d3('0x42')](_0x55d6f5['body'][_0x44d3('0x33')]);}return db[_0x44d3('0x1b')][_0x44d3('0x43')](_0x55d6f5[_0x44d3('0x3b')],{})['then'](respondWithResult(_0x4d0c0f,0xc9))[_0x44d3('0x34')](handleError(_0x4d0c0f,null));};exports['update']=function(_0x24896f,_0x323599){if(_0x24896f['body']['id']){delete _0x24896f[_0x44d3('0x3b')]['id'];}return db['CloudProvider'][_0x44d3('0x39')]({'where':{'id':_0x24896f['params']['id']}})[_0x44d3('0x13')](handleEntityNotFound(_0x323599,null))[_0x44d3('0x13')](function(_0x196af2){if(_0x196af2[_0x44d3('0x32')]===_0x44d3('0x41')&&_0x24896f['body'][_0x44d3('0x33')]){_0x24896f[_0x44d3('0x3b')][_0x44d3('0x33')]=encryptor[_0x44d3('0x42')](_0x24896f[_0x44d3('0x3b')][_0x44d3('0x33')]);}return _0x196af2;})[_0x44d3('0x13')](saveUpdates(_0x24896f['body'],null))['then'](respondWithResult(_0x323599,null))[_0x44d3('0x34')](handleError(_0x323599,null));};exports[_0x44d3('0x14')]=function(_0x3f7bc9,_0x48c364){return db[_0x44d3('0x1b')][_0x44d3('0x39')]({'where':{'id':_0x3f7bc9[_0x44d3('0x36')]['id']}})[_0x44d3('0x13')](handleEntityNotFound(_0x48c364,null))['then'](removeEntity(_0x48c364,null))['catch'](handleError(_0x48c364,null));};exports[_0x44d3('0x44')]=function(_0x632e78,_0x9a2e14){return db['CloudProvider']['findOne']({'where':{'id':_0x632e78[_0x44d3('0x36')]['id']},'raw':!![]})[_0x44d3('0x13')](function(_0x4a0434){if(!_0x4a0434)return _0x9a2e14[_0x44d3('0xa')](0x194);return{'url':oauth[_0x44d3('0x45')](_0x4a0434,_0x632e78[_0x44d3('0x46')]['id'])};})[_0x44d3('0x13')](respondWithResult(_0x9a2e14,null))[_0x44d3('0x34')](handleError(_0x9a2e14,null));};exports[_0x44d3('0x47')]=function(_0x4ec5cf,_0x2ef5e7){var _0x37d1ba=_0x4ec5cf[_0x44d3('0x3b')];var _0x5c570d;var _0x25b881;if(_0x37d1ba[_0x44d3('0x48')])throw _0x37d1ba;redis['get'](_0x37d1ba[_0x44d3('0x49')])[_0x44d3('0x13')](function(_0x403803){if(!_0x403803)throw new Error(_0x44d3('0x4a'));_0x5c570d=JSON['parse'](_0x403803);var _0x59bcf5=Buffer[_0x44d3('0x4b')](_0x37d1ba[_0x44d3('0x49')],_0x44d3('0x4c'))[_0x44d3('0x4d')](_0x44d3('0x4e'));_0x25b881=JSON[_0x44d3('0x4f')](_0x59bcf5);if(!oauth['isValidIdToken'](_0x37d1ba['id_token'],_0x5c570d[_0x44d3('0x50')]))throw new Error(_0x44d3('0x51'));redis[_0x44d3('0x52')](_0x37d1ba['state']);return oauth['getOauth2MicrosoftAccessToken'](_0x37d1ba[_0x44d3('0x53')],_0x5c570d);})[_0x44d3('0x13')](function(_0x1ab7a){_0x5c570d[_0x44d3('0x54')]=_0x1ab7a[_0x44d3('0x55')];_0x5c570d[_0x44d3('0x56')]=_0x1ab7a[_0x44d3('0x57')];return db[_0x44d3('0x1b')][_0x44d3('0x12')]({'data5':_0x5c570d[_0x44d3('0x54')],'data6':_0x5c570d[_0x44d3('0x56')]},{'where':{'id':_0x5c570d['id']}});})[_0x44d3('0x13')](function(){oauth[_0x44d3('0x58')](_0x5c570d);socket[_0x44d3('0x59')](_0x44d3('0x5a'),{'id':_0x25b881['id']});return;})[_0x44d3('0x13')](respondWithStatusCode(_0x2ef5e7,null))['catch'](function(_0x3840b1){if(_0x25b881){socket[_0x44d3('0x59')]('microsoftAuthorization:error',{'id':_0x25b881['id']});}if(!_0x5c570d){logger[_0x44d3('0x48')](_0x44d3('0x5b'),_0x3840b1);return _0x2ef5e7[_0x44d3('0xb')](0x1f4)[_0x44d3('0x17')](_0x3840b1[_0x44d3('0x5c')]);}logger[_0x44d3('0x48')](_0x44d3('0x5d'),_0x5c570d['id'],JSON[_0x44d3('0x5e')](_0x3840b1));});};
\ No newline at end of file