Built motion from commit 42801a18.|2.6.28
[motion2.git] / server / components / auth / service.js
index 9e9a20b..773bff9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9d94=['isWebrtcLicence','isMiddleware','signToken','setTokenCookie','cookie','motion.token','redirect','/dashboards/general','retrieveApiKey','isNil','generateApiKey','apiKeyIat','regenerateApiKey','test','Sequelize','ValidationError','validatePasswordHistory','toLowerCase','format','The\x20password\x20must\x20be\x20different\x20from\x20the\x20previous\x20%d\x20passwords.\x20Please\x20choose\x20another\x20one.','The\x20password\x20must\x20be\x20different\x20from\x20the\x20last\x20one.\x20Please\x20choose\x20another\x20one.','updatePasswordsHistory','split','length','splice','unshift','encryptString','join','promisify','sign','secret','session','payload','options','randomBytes','toString','hex','floor','now','HS512','../../mysqldb','../../config/environment','../../config/license/hardware','../../config/license/util','../encryptor','lodash','jsonwebtoken','composable-middleware','basic-auth','crypto','bluebird','util','moment','secrets','role','fullname','name','email','userpic','permissions','md5secret','voicePause','chatPause','mailPause','smsPause','openchannelPause','pauseType','lastPauseAt','crudPermissions','alias','phoneBarAutoAnswer','phoneBarAutoAnswerDelay','phoneBarDnd','phoneBarEnableRecording','phoneBarEnableDtmfTone','phoneBarEnableSettings','phoneBarPrefixRequired','phoneBarRemoteControl','phoneBarRemoteControlPort','hotdesk','interface','userProfileId','privacyEnabled','wssPort','downloadVoiceRecordings','downloadAttachments','selectRecallMeCampaign','chatAutoanswer','chatAutoanswerDelay','emailAutoanswer','emailAutoanswerDelay','smsAutoanswerDelay','openchannelAutoanswer','openchannelAutoanswerDelay','faxAutoanswerDelay','whatsappAutoanswer','whatsappAutoanswerDelay','messengerSoundNotification','user','ChatInteraction','findOne','then','closed','query','status','json','disposition','unmanaged','Unmanaged.','Forbidden.','catch','isAuthenticated','use','headers','authorization','startsWith','Basic','find','authenticate','pass','Wrong\x20credentials.','Unknown\x20authorization\x20format','apikey','getUuid','User','sub','Setting','allowedLoginAttempts','blockDuration','isEqual','apiKeyNonce','nonce','API\x20access\x20key\x20is\x20not\x20valid\x20anymore','disabled','blocked','blockedAt','add','minutes','Invalid\x20API\x20access\x20key','User\x20not\x20found.','User\x20object\x20not\x20found.','canUpdate','getLicense','update','Forbidden'];(function(_0x59ee6f,_0x450239){var _0x4c0979=function(_0x565e92){while(--_0x565e92){_0x59ee6f['push'](_0x59ee6f['shift']());}};_0x4c0979(++_0x450239);}(_0x9d94,0x1db));var _0x49d9=function(_0x4a2fc5,_0x489168){_0x4a2fc5=_0x4a2fc5-0x0;var _0x271b59=_0x9d94[_0x4a2fc5];return _0x271b59;};'use strict';var db=require(_0x49d9('0x0'))['db'];var config=require(_0x49d9('0x1'));var hardwareConf=require(_0x49d9('0x2'));var licenseUtil=require(_0x49d9('0x3'));var encryptor=require(_0x49d9('0x4'));var _=require(_0x49d9('0x5'));var jwt=require(_0x49d9('0x6'));var expressJwt=require('express-jwt');var compose=require(_0x49d9('0x7'));var basicAuth=require(_0x49d9('0x8'));var crypto=require(_0x49d9('0x9'));var BPromise=require(_0x49d9('0xa'));var util=require(_0x49d9('0xb'));var moment=require(_0x49d9('0xc'));var validateJwt=expressJwt({'secret':config[_0x49d9('0xd')]['session']});var userAttributes=['id',_0x49d9('0xe'),_0x49d9('0xf'),_0x49d9('0x10'),'internal',_0x49d9('0x11'),_0x49d9('0x12'),_0x49d9('0x13'),_0x49d9('0x14'),_0x49d9('0x15'),_0x49d9('0x16'),_0x49d9('0x17'),'faxPause',_0x49d9('0x18'),_0x49d9('0x19'),_0x49d9('0x1a'),'showWebBar','lastLoginAt',_0x49d9('0x1b'),_0x49d9('0x1c'),'allowmessenger','passwordResetAt',_0x49d9('0x1d'),_0x49d9('0x1e'),_0x49d9('0x1f'),_0x49d9('0x20'),_0x49d9('0x21'),_0x49d9('0x22'),_0x49d9('0x23'),'phoneBarExpires',_0x49d9('0x24'),_0x49d9('0x25'),_0x49d9('0x26'),_0x49d9('0x27'),_0x49d9('0x28'),_0x49d9('0x29'),_0x49d9('0x2a'),'settingsEnabled',_0x49d9('0x2b'),_0x49d9('0x2c'),'downloadOmnichannelInteractions',_0x49d9('0x2d'),'ignorePauseForPreviewCalls',_0x49d9('0x2e'),_0x49d9('0x2f'),_0x49d9('0x30'),_0x49d9('0x31'),_0x49d9('0x32'),'smsAutoanswer',_0x49d9('0x33'),_0x49d9('0x34'),_0x49d9('0x35'),'faxAutoanswer',_0x49d9('0x36'),_0x49d9('0x37'),_0x49d9('0x38'),_0x49d9('0x39')];exports['isChatInteractionAuthorized']=function(){return this['isAuthenticated'](!![])['use'](function(_0x8c211f,_0x19f8d3,_0x5dc961){if(_0x8c211f[_0x49d9('0x3a')]){_0x5dc961();}else{return db[_0x49d9('0x3b')][_0x49d9('0x3c')]({'where':{'id':_0x8c211f['params']['id']},'attributes':['id','closed','disposition'],'raw':!![]})[_0x49d9('0x3d')](function(_0x2475d3){if(_0x2475d3&&_0x2475d3[_0x49d9('0x3e')]&&!_0x8c211f[_0x49d9('0x3f')]['forceDownload']){return _0x19f8d3[_0x49d9('0x40')](_0x2475d3['disposition']==='unmanaged'?0x195:0x193)[_0x49d9('0x41')]({'message':_0x2475d3[_0x49d9('0x42')]===_0x49d9('0x43')?_0x49d9('0x44'):_0x49d9('0x45')});}else{_0x5dc961();}})[_0x49d9('0x46')](function(_0xe9cd7f){_0x5dc961(_0xe9cd7f);});}});};exports[_0x49d9('0x47')]=function isAuthenticated(_0x6885e3){return compose()[_0x49d9('0x48')](function(_0x6d280e,_0x8973c1,_0x1971a8){var _0xf4b1ae;if(_0x6d280e[_0x49d9('0x49')][_0x49d9('0x4a')]){if(_[_0x49d9('0x4b')](_0x6d280e[_0x49d9('0x49')][_0x49d9('0x4a')],_0x49d9('0x4c'))){var _0x5d0844=basicAuth(_0x6d280e);db['User'][_0x49d9('0x4d')]({'where':{'name':_0x5d0844['name']}})['then'](function(_0x4afb08){if(!_0x4afb08||!_0x4afb08[_0x49d9('0x4e')](_0x5d0844[_0x49d9('0x4f')])){return _0x8973c1[_0x49d9('0x40')](0x191)[_0x49d9('0x41')]({'message':_0x49d9('0x50')});}_0x6d280e['user']={'id':_0x4afb08['id']};_0x1971a8();})['catch'](function(_0x41ad11){_0x1971a8(_0x41ad11);});}else if(_[_0x49d9('0x4b')](_0x6d280e['headers'][_0x49d9('0x4a')],'Bearer')){validateJwt(_0x6d280e,_0x8973c1,_0x1971a8);}else{if(_0x6885e3){_0x1971a8();}else{return _0x8973c1[_0x49d9('0x40')](0x193)['json']({'message':_0x49d9('0x51')});}}}else if(_0x6d280e[_0x49d9('0x3f')][_0x49d9('0x52')]){try{var _0x52fc3f={'audience':hardwareConf['getUuid'](),'issuer':hardwareConf[_0x49d9('0x53')]()};verifyJwt(_0x6d280e['query']['apikey'],_0x52fc3f)[_0x49d9('0x3d')](function(_0x53f818){return db[_0x49d9('0x54')][_0x49d9('0x4d')]({'where':{'id':_0x53f818[_0x49d9('0x55')]}})[_0x49d9('0x3d')](function(_0x166b36){_0xf4b1ae=_0x166b36;return db[_0x49d9('0x56')][_0x49d9('0x3c')]({'where':{'id':0x1},'attributes':[_0x49d9('0x57'),_0x49d9('0x58')],'raw':!![]});})[_0x49d9('0x3d')](function(_0x581ad1){if(!_0xf4b1ae||!_[_0x49d9('0x59')](_0xf4b1ae[_0x49d9('0x5a')],_0x53f818[_0x49d9('0x5b')])){return _0x8973c1[_0x49d9('0x40')](0x191)[_0x49d9('0x41')]({'message':_0x49d9('0x5c')});}if(_0xf4b1ae[_0x49d9('0x5d')]){return _0x8973c1[_0x49d9('0x40')](0x191)[_0x49d9('0x41')]({'message':'Invalid\x20API\x20access\x20key'});}if(_0xf4b1ae[_0x49d9('0x5e')]){if(_0x581ad1['blockDuration']>0x0){if(moment(_0xf4b1ae[_0x49d9('0x5f')])[_0x49d9('0x60')](_0x581ad1[_0x49d9('0x58')],_0x49d9('0x61'))>moment()){return _0x8973c1[_0x49d9('0x40')](0x191)['json']({'message':_0x49d9('0x62')});}}else{return _0x8973c1[_0x49d9('0x40')](0x191)['json']({'message':'Invalid\x20API\x20access\x20key'});}}_0x6d280e[_0x49d9('0x3a')]={'id':_0xf4b1ae['id']};_0x1971a8();});})[_0x49d9('0x46')](function(){return _0x8973c1['status'](0x191)[_0x49d9('0x41')]({'message':'Invalid\x20API\x20access\x20key'});});}catch(_0x46fe02){_0x1971a8(_0x46fe02);}}else if(_0x6885e3){_0x1971a8();}else{return _0x8973c1[_0x49d9('0x40')](0x193)[_0x49d9('0x41')]({'message':_0x49d9('0x51')});}})[_0x49d9('0x48')](function(_0x13efff,_0x5eec6f,_0x104ac4){if(_0x13efff[_0x49d9('0x3a')]){db[_0x49d9('0x54')]['find']({'where':{'id':_0x13efff[_0x49d9('0x3a')]['id']},'attributes':userAttributes})[_0x49d9('0x3d')](function(_0x4ad675){if(!_0x4ad675){return _0x5eec6f[_0x49d9('0x40')](0x194)['json']({'message':_0x49d9('0x63')});}_0x13efff['user']=_0x4ad675;_0x104ac4();})[_0x49d9('0x46')](function(_0x2c28e2){_0x104ac4(_0x2c28e2);});}else if(_0x6885e3){_0x104ac4();}else{return _0x5eec6f[_0x49d9('0x40')](0x194)[_0x49d9('0x41')]({'message':_0x49d9('0x64')});}});};exports[_0x49d9('0x65')]=function canUpdate(){return compose()['use'](function(_0x54181a,_0x137058,_0x598723){return licenseUtil[_0x49d9('0x66')]()[_0x49d9('0x3d')](function(_0x54d267){if(_0x54d267[_0x49d9('0x67')]){_0x598723();}else{return _0x137058[_0x49d9('0x40')](0x193)[_0x49d9('0x41')]({'message':_0x49d9('0x68')});}})[_0x49d9('0x46')](function(_0x5b2843){_0x598723(_0x5b2843);});});};exports[_0x49d9('0x69')]=function isWebrtcLicence(){return compose()[_0x49d9('0x48')](function(_0x530536,_0x4e310c,_0x3cf908){return licenseUtil[_0x49d9('0x66')]()['then'](function(_0x3dac5d){if(_0x3dac5d['webrtc']){_0x3cf908();}else{return _0x4e310c[_0x49d9('0x40')](0x193)[_0x49d9('0x41')]({'message':'Forbidden'});}})[_0x49d9('0x46')](function(_0x3e5931){_0x3cf908(_0x3e5931);});});};exports[_0x49d9('0x6a')]=function(_0x707b78,_0x4658a3,_0x2a34f9){_0x707b78[_0x49d9('0x6a')]=!![];return _0x2a34f9();};exports[_0x49d9('0x6b')]=function signToken(_0x264920){return signJwt(_0x264920);};exports[_0x49d9('0x6c')]=function(_0xbb7cfd,_0x2b3c9e){if(!_0xbb7cfd[_0x49d9('0x3a')]){return _0x2b3c9e[_0x49d9('0x40')](0x194)[_0x49d9('0x41')]({'message':'It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.'});}var _0xc1099d={'payload':{'id':_0xbb7cfd['user']['id'],'role':_0xbb7cfd[_0x49d9('0x3a')]['role']},'options':{'expiresIn':0x15180}};return signJwt(_0xc1099d)[_0x49d9('0x3d')](function(_0x28e792){_0x2b3c9e[_0x49d9('0x6d')](_0x49d9('0x6e'),_0x28e792);_0x2b3c9e[_0x49d9('0x6f')](_0x49d9('0x70'));})[_0x49d9('0x46')](function(_0x47abc6){return _0x2b3c9e['status'](0x1f4)['send'](_0x47abc6);});};exports[_0x49d9('0x71')]=function(_0xa0dc9b){if(_[_0x49d9('0x72')](_0xa0dc9b[_0x49d9('0x5a')])||_[_0x49d9('0x72')](_0xa0dc9b['apiKeyIat'])){return null;}else{return createJwt(_0xa0dc9b);}};exports[_0x49d9('0x73')]=function(_0x2f1ccf){_0x2f1ccf[_0x49d9('0x5a')]=generateNonce();_0x2f1ccf[_0x49d9('0x74')]=generateIssuedAt();return createJwt(_0x2f1ccf);};exports[_0x49d9('0x75')]=function(_0x544d92,_0x5975ea){var _0x47fbb0=_0x544d92[_0x49d9('0x3f')][_0x49d9('0x52')];if(_0x47fbb0){var _0x22e3f5={'nonce':_0x5975ea[_0x49d9('0x5a')],'iat':_0x5975ea[_0x49d9('0x74')],'audience':hardwareConf[_0x49d9('0x53')](),'issuer':hardwareConf[_0x49d9('0x53')]()};return verifyJwt(_0x47fbb0,_0x22e3f5)[_0x49d9('0x3d')](function(){return generateApiKey(_0x5975ea);});}else{throw{'message':'Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one'};}};exports['validatePasswordPattern']=function(_0x1b4e8b){var _0x25bdee=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(!_0x25bdee[_0x49d9('0x76')](_0x1b4e8b))throw new db[(_0x49d9('0x77'))][(_0x49d9('0x78'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');return;};exports[_0x49d9('0x79')]=function(_0x3accfd,_0x2b5912,_0xfacc05){var _0x35e5a7=encryptor['decryptString'](_0x2b5912)['split'](',');for(var _0x27b8aa=0x0;_0x27b8aa<_0xfacc05;_0x27b8aa++){if(!_0x35e5a7[_0x27b8aa])break;if(_0x3accfd[_0x49d9('0x7a')]()===_0x35e5a7[_0x27b8aa]['toLowerCase']()){var _0x25a34b=util[_0x49d9('0x7b')](_0x49d9('0x7c'),_0xfacc05);if(_0xfacc05===0x1){_0x25a34b=_0x49d9('0x7d');}throw new db[(_0x49d9('0x77'))][(_0x49d9('0x78'))](_0x25a34b);}}return;};exports[_0x49d9('0x7e')]=function(_0x13f33b,_0x2ab251){var _0x1b7ddb=_0x2ab251?encryptor['decryptString'](_0x2ab251)[_0x49d9('0x7f')](','):[];if(_0x1b7ddb[_0x49d9('0x80')]===0x5){_0x1b7ddb[_0x49d9('0x81')](-0x1,0x1);}_0x1b7ddb[_0x49d9('0x82')](_0x13f33b);return encryptor[_0x49d9('0x83')](_0x1b7ddb[_0x49d9('0x84')](','));};function signJwt(_0x1cea61){var _0x4d9ed9=BPromise[_0x49d9('0x85')](jwt[_0x49d9('0x86')],{'context':jwt});var _0x147337=_0x1cea61[_0x49d9('0x87')]||config['secrets'][_0x49d9('0x88')];return new BPromise(function(_0x469c35,_0xf72009){_0x4d9ed9(_0x1cea61[_0x49d9('0x89')],_0x147337,_0x1cea61[_0x49d9('0x8a')])[_0x49d9('0x3d')](function(_0x3b831e){_0x469c35(_0x3b831e);})[_0x49d9('0x46')](function(_0x4ed08e){_0xf72009(_0x4ed08e);});});}function verifyJwt(_0x52ae33,_0x26fbbc,_0x261d7a){var _0x1a37cd=BPromise[_0x49d9('0x85')](jwt['verify'],{'context':jwt});var _0x19a310=_0x261d7a||config[_0x49d9('0xd')][_0x49d9('0x88')];return new BPromise(function(_0x588df4,_0x39a88b){_0x1a37cd(_0x52ae33,_0x19a310,_0x26fbbc)['then'](function(_0x2b8da9){_0x588df4(_0x2b8da9);})[_0x49d9('0x46')](function(_0x22e7c0){_0x39a88b(_0x22e7c0);});});}function generateNonce(){return crypto[_0x49d9('0x8b')](0x10)[_0x49d9('0x8c')](_0x49d9('0x8d'));}function generateIssuedAt(){return Math[_0x49d9('0x8e')](Date[_0x49d9('0x8f')]()/0x3e8)[_0x49d9('0x8c')]();}function createJwt(_0x17126e){var _0x121dac={'payload':{'iat':_0x17126e['apiKeyIat'],'nonce':_0x17126e[_0x49d9('0x5a')]},'options':{'algorithm':_0x49d9('0x90'),'subject':_0x17126e['id']['toString'](),'issuer':hardwareConf['getUuid'](),'audience':hardwareConf[_0x49d9('0x53')]()}};return signJwt(_0x121dac)['then'](function(_0x553b73){return{'iat':_0x17126e[_0x49d9('0x74')],'nonce':_0x17126e['apiKeyNonce'],'token':_0x553b73};});}
\ No newline at end of file
+var _0x8dc9=['isMiddleware','setTokenCookie','It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.','cookie','motion.token','/dashboards/general','send','isNil','apiKeyIat','regenerateApiKey','Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one','validatePasswordPattern','test','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','decryptString','split','toLowerCase','The\x20password\x20must\x20be\x20different\x20from\x20the\x20last\x20one.\x20Please\x20choose\x20another\x20one.','Sequelize','ValidationError','updatePasswordsHistory','splice','unshift','encryptString','join','promisify','sign','secret','payload','options','verify','randomBytes','now','toString','HS512','../../mysqldb','../../config/environment','../../config/license/hardware','lodash','jsonwebtoken','composable-middleware','basic-auth','crypto','bluebird','moment','secrets','session','role','name','internal','permissions','md5secret','voicePause','chatPause','mailPause','smsPause','pauseType','showWebBar','lastLoginAt','crudPermissions','passwordResetAt','alias','phoneBarAutoAnswer','phoneBarAutoAnswerDelay','phoneBarDnd','phoneBarEnableRecording','phoneBarEnableDtmfTone','phoneBarEnableSettings','phoneBarExpires','phoneBarPrefixRequired','phoneBarRemoteControl','interface','userProfileId','settingsEnabled','wssPort','downloadVoiceRecordings','downloadAttachments','ignorePauseForPreviewCalls','selectRecallMeCampaign','chatAutoanswerDelay','emailAutoanswer','emailAutoanswerDelay','smsAutoanswer','openchannelAutoanswer','faxAutoanswer','whatsappAutoanswer','whatsappAutoanswerDelay','messengerSoundNotification','isAuthenticated','user','ChatInteraction','findOne','params','closed','disposition','then','query','forceDownload','json','unmanaged','Unmanaged.','use','headers','authorization','startsWith','Basic','find','authenticate','pass','status','Wrong\x20credentials.','catch','Bearer','Unknown\x20authorization\x20format','apikey','getUuid','User','sub','blockDuration','apiKeyNonce','disabled','Invalid\x20API\x20access\x20key','blocked','blockedAt','minutes','canUpdate','getLicense','update','Forbidden','isWebrtcLicence','webrtc'];(function(_0x10c6a5,_0x28851d){var _0x25b0d0=function(_0x614a4e){while(--_0x614a4e){_0x10c6a5['push'](_0x10c6a5['shift']());}};_0x25b0d0(++_0x28851d);}(_0x8dc9,0x129));var _0x98dc=function(_0x252d32,_0x5204db){_0x252d32=_0x252d32-0x0;var _0x3ae232=_0x8dc9[_0x252d32];return _0x3ae232;};'use strict';var db=require(_0x98dc('0x0'))['db'];var config=require(_0x98dc('0x1'));var hardwareConf=require(_0x98dc('0x2'));var licenseUtil=require('../../config/license/util');var encryptor=require('../encryptor');var _=require(_0x98dc('0x3'));var jwt=require(_0x98dc('0x4'));var expressJwt=require('express-jwt');var compose=require(_0x98dc('0x5'));var basicAuth=require(_0x98dc('0x6'));var crypto=require(_0x98dc('0x7'));var BPromise=require(_0x98dc('0x8'));var util=require('util');var moment=require(_0x98dc('0x9'));var validateJwt=expressJwt({'secret':config[_0x98dc('0xa')][_0x98dc('0xb')]});var userAttributes=['id',_0x98dc('0xc'),'fullname',_0x98dc('0xd'),_0x98dc('0xe'),'email','userpic',_0x98dc('0xf'),_0x98dc('0x10'),_0x98dc('0x11'),_0x98dc('0x12'),_0x98dc('0x13'),'faxPause',_0x98dc('0x14'),'openchannelPause',_0x98dc('0x15'),_0x98dc('0x16'),_0x98dc('0x17'),'lastPauseAt',_0x98dc('0x18'),'allowmessenger',_0x98dc('0x19'),_0x98dc('0x1a'),_0x98dc('0x1b'),_0x98dc('0x1c'),_0x98dc('0x1d'),_0x98dc('0x1e'),_0x98dc('0x1f'),_0x98dc('0x20'),_0x98dc('0x21'),_0x98dc('0x22'),_0x98dc('0x23'),'phoneBarRemoteControlPort','hotdesk',_0x98dc('0x24'),_0x98dc('0x25'),'privacyEnabled',_0x98dc('0x26'),_0x98dc('0x27'),_0x98dc('0x28'),'downloadOmnichannelInteractions',_0x98dc('0x29'),_0x98dc('0x2a'),_0x98dc('0x2b'),'chatAutoanswer',_0x98dc('0x2c'),_0x98dc('0x2d'),_0x98dc('0x2e'),_0x98dc('0x2f'),'smsAutoanswerDelay',_0x98dc('0x30'),'openchannelAutoanswerDelay',_0x98dc('0x31'),'faxAutoanswerDelay',_0x98dc('0x32'),_0x98dc('0x33'),_0x98dc('0x34')];exports['isChatInteractionAuthorized']=function(){return this[_0x98dc('0x35')](!![])['use'](function(_0x149704,_0x4d405e,_0xf1d427){if(_0x149704[_0x98dc('0x36')]){_0xf1d427();}else{return db[_0x98dc('0x37')][_0x98dc('0x38')]({'where':{'id':_0x149704[_0x98dc('0x39')]['id']},'attributes':['id',_0x98dc('0x3a'),_0x98dc('0x3b')],'raw':!![]})[_0x98dc('0x3c')](function(_0x1b07f0){if(_0x1b07f0&&_0x1b07f0[_0x98dc('0x3a')]&&!_0x149704[_0x98dc('0x3d')][_0x98dc('0x3e')]){return _0x4d405e['status'](_0x1b07f0[_0x98dc('0x3b')]==='unmanaged'?0x195:0x193)[_0x98dc('0x3f')]({'message':_0x1b07f0[_0x98dc('0x3b')]===_0x98dc('0x40')?_0x98dc('0x41'):'Forbidden.'});}else{_0xf1d427();}})['catch'](function(_0x4c3625){_0xf1d427(_0x4c3625);});}});};exports[_0x98dc('0x35')]=function isAuthenticated(_0x92029b){return compose()[_0x98dc('0x42')](function(_0x53eee8,_0x6c115,_0x51a087){var _0x554707;if(_0x53eee8[_0x98dc('0x43')][_0x98dc('0x44')]){if(_[_0x98dc('0x45')](_0x53eee8[_0x98dc('0x43')][_0x98dc('0x44')],_0x98dc('0x46'))){var _0x3f8683=basicAuth(_0x53eee8);db['User'][_0x98dc('0x47')]({'where':{'name':_0x3f8683[_0x98dc('0xd')]}})[_0x98dc('0x3c')](function(_0x268236){if(!_0x268236||!_0x268236[_0x98dc('0x48')](_0x3f8683[_0x98dc('0x49')])){return _0x6c115[_0x98dc('0x4a')](0x191)['json']({'message':_0x98dc('0x4b')});}_0x53eee8['user']={'id':_0x268236['id']};_0x51a087();})[_0x98dc('0x4c')](function(_0x2b523d){_0x51a087(_0x2b523d);});}else if(_[_0x98dc('0x45')](_0x53eee8[_0x98dc('0x43')]['authorization'],_0x98dc('0x4d'))){validateJwt(_0x53eee8,_0x6c115,_0x51a087);}else{if(_0x92029b){_0x51a087();}else{return _0x6c115[_0x98dc('0x4a')](0x193)[_0x98dc('0x3f')]({'message':_0x98dc('0x4e')});}}}else if(_0x53eee8['query'][_0x98dc('0x4f')]){try{var _0x2bd58c={'audience':hardwareConf[_0x98dc('0x50')](),'issuer':hardwareConf['getUuid']()};verifyJwt(_0x53eee8[_0x98dc('0x3d')][_0x98dc('0x4f')],_0x2bd58c)[_0x98dc('0x3c')](function(_0x565432){return db[_0x98dc('0x51')][_0x98dc('0x47')]({'where':{'id':_0x565432[_0x98dc('0x52')]}})[_0x98dc('0x3c')](function(_0x5a8e89){_0x554707=_0x5a8e89;return db['Setting'][_0x98dc('0x38')]({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0x98dc('0x53')],'raw':!![]});})[_0x98dc('0x3c')](function(_0x167a00){if(!_0x554707||!_['isEqual'](_0x554707[_0x98dc('0x54')],_0x565432['nonce'])){return _0x6c115[_0x98dc('0x4a')](0x191)[_0x98dc('0x3f')]({'message':'API\x20access\x20key\x20is\x20not\x20valid\x20anymore'});}if(_0x554707[_0x98dc('0x55')]){return _0x6c115[_0x98dc('0x4a')](0x191)[_0x98dc('0x3f')]({'message':_0x98dc('0x56')});}if(_0x554707[_0x98dc('0x57')]){if(_0x167a00['blockDuration']>0x0){if(moment(_0x554707[_0x98dc('0x58')])['add'](_0x167a00[_0x98dc('0x53')],_0x98dc('0x59'))>moment()){return _0x6c115[_0x98dc('0x4a')](0x191)[_0x98dc('0x3f')]({'message':_0x98dc('0x56')});}}else{return _0x6c115['status'](0x191)['json']({'message':_0x98dc('0x56')});}}_0x53eee8[_0x98dc('0x36')]={'id':_0x554707['id']};_0x51a087();});})[_0x98dc('0x4c')](function(){return _0x6c115[_0x98dc('0x4a')](0x191)[_0x98dc('0x3f')]({'message':_0x98dc('0x56')});});}catch(_0x711789){_0x51a087(_0x711789);}}else if(_0x92029b){_0x51a087();}else{return _0x6c115[_0x98dc('0x4a')](0x193)[_0x98dc('0x3f')]({'message':_0x98dc('0x4e')});}})[_0x98dc('0x42')](function(_0xef62e7,_0x17ee9e,_0x3dfcf2){if(_0xef62e7[_0x98dc('0x36')]){db[_0x98dc('0x51')][_0x98dc('0x47')]({'where':{'id':_0xef62e7[_0x98dc('0x36')]['id']},'attributes':userAttributes})[_0x98dc('0x3c')](function(_0x24d141){if(!_0x24d141){return _0x17ee9e['status'](0x194)[_0x98dc('0x3f')]({'message':'User\x20not\x20found.'});}_0xef62e7[_0x98dc('0x36')]=_0x24d141;_0x3dfcf2();})[_0x98dc('0x4c')](function(_0x3bf80f){_0x3dfcf2(_0x3bf80f);});}else if(_0x92029b){_0x3dfcf2();}else{return _0x17ee9e[_0x98dc('0x4a')](0x194)[_0x98dc('0x3f')]({'message':'User\x20object\x20not\x20found.'});}});};exports[_0x98dc('0x5a')]=function canUpdate(){return compose()['use'](function(_0x4b34e5,_0x386796,_0x269217){return licenseUtil[_0x98dc('0x5b')]()[_0x98dc('0x3c')](function(_0x33f0ee){if(_0x33f0ee[_0x98dc('0x5c')]){_0x269217();}else{return _0x386796['status'](0x193)[_0x98dc('0x3f')]({'message':_0x98dc('0x5d')});}})['catch'](function(_0x355f8a){_0x269217(_0x355f8a);});});};exports[_0x98dc('0x5e')]=function isWebrtcLicence(){return compose()[_0x98dc('0x42')](function(_0x40c0fa,_0x138850,_0x341935){return licenseUtil[_0x98dc('0x5b')]()['then'](function(_0xae5618){if(_0xae5618[_0x98dc('0x5f')]){_0x341935();}else{return _0x138850[_0x98dc('0x4a')](0x193)[_0x98dc('0x3f')]({'message':'Forbidden'});}})[_0x98dc('0x4c')](function(_0x1139a0){_0x341935(_0x1139a0);});});};exports[_0x98dc('0x60')]=function(_0x1da00a,_0x36c4bb,_0xd230df){_0x1da00a[_0x98dc('0x60')]=!![];return _0xd230df();};exports['signToken']=function signToken(_0x311048){return signJwt(_0x311048);};exports[_0x98dc('0x61')]=function(_0x34bab3,_0x3bab03){if(!_0x34bab3[_0x98dc('0x36')]){return _0x3bab03[_0x98dc('0x4a')](0x194)[_0x98dc('0x3f')]({'message':_0x98dc('0x62')});}var _0x21390e={'payload':{'id':_0x34bab3[_0x98dc('0x36')]['id'],'role':_0x34bab3[_0x98dc('0x36')][_0x98dc('0xc')]},'options':{'expiresIn':0x15180}};return signJwt(_0x21390e)[_0x98dc('0x3c')](function(_0x31964a){_0x3bab03[_0x98dc('0x63')](_0x98dc('0x64'),_0x31964a);_0x3bab03['redirect'](_0x98dc('0x65'));})[_0x98dc('0x4c')](function(_0x9cd51a){return _0x3bab03[_0x98dc('0x4a')](0x1f4)[_0x98dc('0x66')](_0x9cd51a);});};exports['retrieveApiKey']=function(_0x1bba68){if(_[_0x98dc('0x67')](_0x1bba68[_0x98dc('0x54')])||_[_0x98dc('0x67')](_0x1bba68[_0x98dc('0x68')])){return null;}else{return createJwt(_0x1bba68);}};exports['generateApiKey']=function(_0x3c691a){_0x3c691a[_0x98dc('0x54')]=generateNonce();_0x3c691a[_0x98dc('0x68')]=generateIssuedAt();return createJwt(_0x3c691a);};exports[_0x98dc('0x69')]=function(_0x2ab361,_0x33ddf2){var _0x7980e1=_0x2ab361[_0x98dc('0x3d')]['apikey'];if(_0x7980e1){var _0x17b98d={'nonce':_0x33ddf2[_0x98dc('0x54')],'iat':_0x33ddf2[_0x98dc('0x68')],'audience':hardwareConf[_0x98dc('0x50')](),'issuer':hardwareConf['getUuid']()};return verifyJwt(_0x7980e1,_0x17b98d)[_0x98dc('0x3c')](function(){return generateApiKey(_0x33ddf2);});}else{throw{'message':_0x98dc('0x6a')};}};exports[_0x98dc('0x6b')]=function(_0x29c2a4){var _0x25c404=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(!_0x25c404[_0x98dc('0x6c')](_0x29c2a4))throw new db['Sequelize']['ValidationError'](_0x98dc('0x6d'));return;};exports['validatePasswordHistory']=function(_0x216cf5,_0x5ca1de,_0x37e75d){var _0x4f24e8=encryptor[_0x98dc('0x6e')](_0x5ca1de)[_0x98dc('0x6f')](',');for(var _0x4a7f02=0x0;_0x4a7f02<_0x37e75d;_0x4a7f02++){if(!_0x4f24e8[_0x4a7f02])break;if(_0x216cf5[_0x98dc('0x70')]()===_0x4f24e8[_0x4a7f02][_0x98dc('0x70')]()){var _0xb714b9=util['format']('The\x20password\x20must\x20be\x20different\x20from\x20the\x20previous\x20%d\x20passwords.\x20Please\x20choose\x20another\x20one.',_0x37e75d);if(_0x37e75d===0x1){_0xb714b9=_0x98dc('0x71');}throw new db[(_0x98dc('0x72'))][(_0x98dc('0x73'))](_0xb714b9);}}return;};exports[_0x98dc('0x74')]=function(_0x447264,_0x29698f){var _0x4c9ddb=_0x29698f?encryptor[_0x98dc('0x6e')](_0x29698f)[_0x98dc('0x6f')](','):[];if(_0x4c9ddb['length']===0x5){_0x4c9ddb[_0x98dc('0x75')](-0x1,0x1);}_0x4c9ddb[_0x98dc('0x76')](_0x447264);return encryptor[_0x98dc('0x77')](_0x4c9ddb[_0x98dc('0x78')](','));};function signJwt(_0x5e1ae7){var _0x4d39d1=BPromise[_0x98dc('0x79')](jwt[_0x98dc('0x7a')],{'context':jwt});var _0x3563c6=_0x5e1ae7[_0x98dc('0x7b')]||config[_0x98dc('0xa')][_0x98dc('0xb')];return new BPromise(function(_0xbb67eb,_0x582393){_0x4d39d1(_0x5e1ae7[_0x98dc('0x7c')],_0x3563c6,_0x5e1ae7[_0x98dc('0x7d')])[_0x98dc('0x3c')](function(_0x192505){_0xbb67eb(_0x192505);})['catch'](function(_0x1398d7){_0x582393(_0x1398d7);});});}function verifyJwt(_0x1111f2,_0x3dd5ee,_0x35d1ef){var _0x50a8f1=BPromise[_0x98dc('0x79')](jwt[_0x98dc('0x7e')],{'context':jwt});var _0x8e5a3c=_0x35d1ef||config[_0x98dc('0xa')][_0x98dc('0xb')];return new BPromise(function(_0x1c6f30,_0x1613cc){_0x50a8f1(_0x1111f2,_0x8e5a3c,_0x3dd5ee)[_0x98dc('0x3c')](function(_0x62d4a9){_0x1c6f30(_0x62d4a9);})[_0x98dc('0x4c')](function(_0x4523bf){_0x1613cc(_0x4523bf);});});}function generateNonce(){return crypto[_0x98dc('0x7f')](0x10)['toString']('hex');}function generateIssuedAt(){return Math['floor'](Date[_0x98dc('0x80')]()/0x3e8)[_0x98dc('0x81')]();}function createJwt(_0x55a5b2){var _0x17fd8f={'payload':{'iat':_0x55a5b2['apiKeyIat'],'nonce':_0x55a5b2['apiKeyNonce']},'options':{'algorithm':_0x98dc('0x82'),'subject':_0x55a5b2['id']['toString'](),'issuer':hardwareConf['getUuid'](),'audience':hardwareConf[_0x98dc('0x50')]()}};return signJwt(_0x17fd8f)[_0x98dc('0x3c')](function(_0x4877f6){return{'iat':_0x55a5b2[_0x98dc('0x68')],'nonce':_0x55a5b2[_0x98dc('0x54')],'token':_0x4877f6};});}
\ No newline at end of file