Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / components / auth / service.js
index b2a3b41..6311d8a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x94d3=['mailPause','faxPause','smsPause','openchannelPause','pauseType','showWebBar','lastPauseAt','passwordResetAt','alias','phoneBarAutoAnswer','phoneBarAutoAnswerDelay','phoneBarDnd','phoneBarEnableRecording','phoneBarEnableSettings','phoneBarExpires','phoneBarRemoteControl','hotdesk','interface','privacyEnabled','settingsEnabled','wssPort','downloadVoiceRecordings','downloadOmnichannelInteractions','downloadAttachments','ignorePauseForPreviewCalls','selectRecallMeCampaign','chatAutoanswer','chatAutoanswerDelay','emailAutoanswerDelay','smsAutoanswer','smsAutoanswerDelay','openchannelAutoanswerDelay','faxAutoanswer','faxAutoanswerDelay','whatsappAutoanswer','whatsappAutoanswerDelay','isChatInteractionAuthorized','user','ChatInteraction','findOne','params','closed','disposition','query','status','unmanaged','json','Unmanaged.','Forbidden.','catch','isAuthenticated','use','authorization','startsWith','headers','Basic','User','find','pass','Wrong\x20credentials.','Bearer','Unknown\x20authorization\x20format','apikey','getUuid','then','sub','Setting','blockDuration','isEqual','apiKeyNonce','nonce','API\x20access\x20key\x20is\x20not\x20valid\x20anymore','disabled','blocked','add','minutes','Invalid\x20API\x20access\x20key','User\x20not\x20found.','User\x20object\x20not\x20found.','canUpdate','getLicense','update','isWebrtcLicence','webrtc','isMiddleware','signToken','setTokenCookie','role','motion.token','/dashboards/general','send','isNil','apiKeyIat','generateApiKey','regenerateApiKey','Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one','validatePasswordPattern','test','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','validatePasswordHistory','decryptString','split','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.','unshift','join','promisify','sign','payload','verify','randomBytes','toString','hex','floor','now','HS512','../../mysqldb','../../config/environment','../../config/license/hardware','../../config/license/util','../encryptor','lodash','jsonwebtoken','express-jwt','composable-middleware','basic-auth','crypto','bluebird','util','moment','secrets','session','fullname','name','internal','email','userpic','permissions','md5secret','voicePause'];(function(_0x3a1acb,_0x141a13){var _0x1ec58d=function(_0x3ad750){while(--_0x3ad750){_0x3a1acb['push'](_0x3a1acb['shift']());}};_0x1ec58d(++_0x141a13);}(_0x94d3,0x195));var _0x394d=function(_0xd11f85,_0x45bed1){_0xd11f85=_0xd11f85-0x0;var _0x1f1f7d=_0x94d3[_0xd11f85];return _0x1f1f7d;};'use strict';var db=require(_0x394d('0x0'))['db'];var config=require(_0x394d('0x1'));var hardwareConf=require(_0x394d('0x2'));var licenseUtil=require(_0x394d('0x3'));var encryptor=require(_0x394d('0x4'));var _=require(_0x394d('0x5'));var jwt=require(_0x394d('0x6'));var expressJwt=require(_0x394d('0x7'));var compose=require(_0x394d('0x8'));var basicAuth=require(_0x394d('0x9'));var crypto=require(_0x394d('0xa'));var BPromise=require(_0x394d('0xb'));var util=require(_0x394d('0xc'));var moment=require(_0x394d('0xd'));var validateJwt=expressJwt({'secret':config[_0x394d('0xe')][_0x394d('0xf')]});var userAttributes=['id','role',_0x394d('0x10'),_0x394d('0x11'),_0x394d('0x12'),_0x394d('0x13'),_0x394d('0x14'),_0x394d('0x15'),_0x394d('0x16'),_0x394d('0x17'),'chatPause',_0x394d('0x18'),_0x394d('0x19'),_0x394d('0x1a'),_0x394d('0x1b'),_0x394d('0x1c'),_0x394d('0x1d'),'lastLoginAt',_0x394d('0x1e'),'crudPermissions','allowmessenger',_0x394d('0x1f'),_0x394d('0x20'),_0x394d('0x21'),_0x394d('0x22'),_0x394d('0x23'),_0x394d('0x24'),'phoneBarEnableDtmfTone',_0x394d('0x25'),_0x394d('0x26'),'phoneBarPrefixRequired',_0x394d('0x27'),'phoneBarRemoteControlPort',_0x394d('0x28'),_0x394d('0x29'),'userProfileId',_0x394d('0x2a'),_0x394d('0x2b'),_0x394d('0x2c'),_0x394d('0x2d'),_0x394d('0x2e'),_0x394d('0x2f'),_0x394d('0x30'),_0x394d('0x31'),_0x394d('0x32'),_0x394d('0x33'),'emailAutoanswer',_0x394d('0x34'),_0x394d('0x35'),_0x394d('0x36'),'openchannelAutoanswer',_0x394d('0x37'),_0x394d('0x38'),_0x394d('0x39'),_0x394d('0x3a'),_0x394d('0x3b'),'messengerSoundNotification'];exports[_0x394d('0x3c')]=function(){return this['isAuthenticated'](!![])['use'](function(_0x363227,_0x491dab,_0x172f5d){if(_0x363227[_0x394d('0x3d')]){_0x172f5d();}else{return db[_0x394d('0x3e')][_0x394d('0x3f')]({'where':{'id':_0x363227[_0x394d('0x40')]['id']},'attributes':['id',_0x394d('0x41'),_0x394d('0x42')],'raw':!![]})['then'](function(_0x46f3a5){if(_0x46f3a5&&_0x46f3a5['closed']&&!_0x363227[_0x394d('0x43')]['forceDownload']){return _0x491dab[_0x394d('0x44')](_0x46f3a5[_0x394d('0x42')]===_0x394d('0x45')?0x195:0x193)[_0x394d('0x46')]({'message':_0x46f3a5['disposition']===_0x394d('0x45')?_0x394d('0x47'):_0x394d('0x48')});}else{_0x172f5d();}})[_0x394d('0x49')](function(_0x2c639f){_0x172f5d(_0x2c639f);});}});};exports[_0x394d('0x4a')]=function isAuthenticated(_0x1dfbab){return compose()[_0x394d('0x4b')](function(_0x2dd488,_0x3c2833,_0x396e64){var _0x2b46cb;if(_0x2dd488['headers'][_0x394d('0x4c')]){if(_[_0x394d('0x4d')](_0x2dd488[_0x394d('0x4e')][_0x394d('0x4c')],_0x394d('0x4f'))){var _0x2782d1=basicAuth(_0x2dd488);db[_0x394d('0x50')][_0x394d('0x51')]({'where':{'name':_0x2782d1[_0x394d('0x11')]}})['then'](function(_0x1602d8){if(!_0x1602d8||!_0x1602d8['authenticate'](_0x2782d1[_0x394d('0x52')])){return _0x3c2833[_0x394d('0x44')](0x191)[_0x394d('0x46')]({'message':_0x394d('0x53')});}_0x2dd488[_0x394d('0x3d')]={'id':_0x1602d8['id']};_0x396e64();})[_0x394d('0x49')](function(_0x4e6c99){_0x396e64(_0x4e6c99);});}else if(_[_0x394d('0x4d')](_0x2dd488[_0x394d('0x4e')][_0x394d('0x4c')],_0x394d('0x54'))){validateJwt(_0x2dd488,_0x3c2833,_0x396e64);}else{if(_0x1dfbab){_0x396e64();}else{return _0x3c2833['status'](0x193)[_0x394d('0x46')]({'message':_0x394d('0x55')});}}}else if(_0x2dd488['query'][_0x394d('0x56')]){try{var _0x1940df={'audience':hardwareConf['getUuid'](),'issuer':hardwareConf[_0x394d('0x57')]()};verifyJwt(_0x2dd488['query'][_0x394d('0x56')],_0x1940df)[_0x394d('0x58')](function(_0x221420){return db['User'][_0x394d('0x51')]({'where':{'id':_0x221420[_0x394d('0x59')]}})[_0x394d('0x58')](function(_0xe4d540){_0x2b46cb=_0xe4d540;return db[_0x394d('0x5a')]['findOne']({'where':{'id':0x1},'attributes':['allowedLoginAttempts',_0x394d('0x5b')],'raw':!![]});})['then'](function(_0x48e2de){if(!_0x2b46cb||!_[_0x394d('0x5c')](_0x2b46cb[_0x394d('0x5d')],_0x221420[_0x394d('0x5e')])){return _0x3c2833[_0x394d('0x44')](0x191)['json']({'message':_0x394d('0x5f')});}if(_0x2b46cb[_0x394d('0x60')]){return _0x3c2833[_0x394d('0x44')](0x191)[_0x394d('0x46')]({'message':'Invalid\x20API\x20access\x20key'});}if(_0x2b46cb[_0x394d('0x61')]){if(_0x48e2de[_0x394d('0x5b')]>0x0){if(moment(_0x2b46cb['blockedAt'])[_0x394d('0x62')](_0x48e2de[_0x394d('0x5b')],_0x394d('0x63'))>moment()){return _0x3c2833[_0x394d('0x44')](0x191)[_0x394d('0x46')]({'message':_0x394d('0x64')});}}else{return _0x3c2833['status'](0x191)['json']({'message':_0x394d('0x64')});}}_0x2dd488[_0x394d('0x3d')]={'id':_0x2b46cb['id']};_0x396e64();});})[_0x394d('0x49')](function(){return _0x3c2833[_0x394d('0x44')](0x191)[_0x394d('0x46')]({'message':'Invalid\x20API\x20access\x20key'});});}catch(_0x594d8f){_0x396e64(_0x594d8f);}}else if(_0x1dfbab){_0x396e64();}else{return _0x3c2833[_0x394d('0x44')](0x193)[_0x394d('0x46')]({'message':_0x394d('0x55')});}})['use'](function(_0x5bf683,_0x4dec37,_0x495a84){if(_0x5bf683[_0x394d('0x3d')]){db[_0x394d('0x50')][_0x394d('0x51')]({'where':{'id':_0x5bf683['user']['id']},'attributes':userAttributes})['then'](function(_0x42ed84){if(!_0x42ed84){return _0x4dec37[_0x394d('0x44')](0x194)[_0x394d('0x46')]({'message':_0x394d('0x65')});}_0x5bf683['user']=_0x42ed84;_0x495a84();})[_0x394d('0x49')](function(_0xeba89f){_0x495a84(_0xeba89f);});}else if(_0x1dfbab){_0x495a84();}else{return _0x4dec37[_0x394d('0x44')](0x194)['json']({'message':_0x394d('0x66')});}});};exports[_0x394d('0x67')]=function canUpdate(){return compose()[_0x394d('0x4b')](function(_0x5c518b,_0x13819f,_0x4a1057){return licenseUtil[_0x394d('0x68')]()[_0x394d('0x58')](function(_0xc003dd){if(_0xc003dd[_0x394d('0x69')]){_0x4a1057();}else{return _0x13819f[_0x394d('0x44')](0x193)[_0x394d('0x46')]({'message':'Forbidden'});}})['catch'](function(_0x324079){_0x4a1057(_0x324079);});});};exports[_0x394d('0x6a')]=function isWebrtcLicence(){return compose()[_0x394d('0x4b')](function(_0x518aee,_0x232334,_0x2e3171){return licenseUtil[_0x394d('0x68')]()['then'](function(_0xceeefe){if(_0xceeefe[_0x394d('0x6b')]){_0x2e3171();}else{return _0x232334[_0x394d('0x44')](0x193)[_0x394d('0x46')]({'message':'Forbidden'});}})[_0x394d('0x49')](function(_0x43936f){_0x2e3171(_0x43936f);});});};exports[_0x394d('0x6c')]=function(_0x5bbe15,_0x1692c2,_0xccf629){_0x5bbe15[_0x394d('0x6c')]=!![];return _0xccf629();};exports[_0x394d('0x6d')]=function signToken(_0x146226){return signJwt(_0x146226);};exports[_0x394d('0x6e')]=function(_0x1f44f4,_0x51be19){if(!_0x1f44f4[_0x394d('0x3d')]){return _0x51be19[_0x394d('0x44')](0x194)[_0x394d('0x46')]({'message':'It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.'});}var _0x18645={'payload':{'id':_0x1f44f4[_0x394d('0x3d')]['id'],'role':_0x1f44f4[_0x394d('0x3d')][_0x394d('0x6f')]},'options':{'expiresIn':0x15180}};return signJwt(_0x18645)[_0x394d('0x58')](function(_0x5d8b63){_0x51be19['cookie'](_0x394d('0x70'),_0x5d8b63);_0x51be19['redirect'](_0x394d('0x71'));})[_0x394d('0x49')](function(_0x16f9c6){return _0x51be19[_0x394d('0x44')](0x1f4)[_0x394d('0x72')](_0x16f9c6);});};exports['retrieveApiKey']=function(_0x1f792d){if(_[_0x394d('0x73')](_0x1f792d[_0x394d('0x5d')])||_[_0x394d('0x73')](_0x1f792d[_0x394d('0x74')])){return null;}else{return createJwt(_0x1f792d);}};exports[_0x394d('0x75')]=function(_0x3d4cd1){_0x3d4cd1[_0x394d('0x5d')]=generateNonce();_0x3d4cd1[_0x394d('0x74')]=generateIssuedAt();return createJwt(_0x3d4cd1);};exports[_0x394d('0x76')]=function(_0xd3221b,_0x3523cd){var _0x27b453=_0xd3221b['query'][_0x394d('0x56')];if(_0x27b453){var _0x1e0582={'nonce':_0x3523cd[_0x394d('0x5d')],'iat':_0x3523cd[_0x394d('0x74')],'audience':hardwareConf[_0x394d('0x57')](),'issuer':hardwareConf[_0x394d('0x57')]()};return verifyJwt(_0x27b453,_0x1e0582)[_0x394d('0x58')](function(){return generateApiKey(_0x3523cd);});}else{throw{'message':_0x394d('0x77')};}};exports[_0x394d('0x78')]=function(_0x6e202e){var _0x2d4c6d=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(!_0x2d4c6d[_0x394d('0x79')](_0x6e202e))throw new db['Sequelize'][(_0x394d('0x7a'))](_0x394d('0x7b'));return;};exports[_0x394d('0x7c')]=function(_0x17beb0,_0xde030e,_0x4518c0){var _0xcaad78=encryptor[_0x394d('0x7d')](_0xde030e)[_0x394d('0x7e')](',');for(var _0x3b22d5=0x0;_0x3b22d5<_0x4518c0;_0x3b22d5++){if(!_0xcaad78[_0x3b22d5])break;if(_0x17beb0[_0x394d('0x7f')]()===_0xcaad78[_0x3b22d5][_0x394d('0x7f')]()){var _0x34c409=util[_0x394d('0x80')](_0x394d('0x81'),_0x4518c0);if(_0x4518c0===0x1){_0x34c409=_0x394d('0x82');}throw new db['Sequelize'][(_0x394d('0x7a'))](_0x34c409);}}return;};exports['updatePasswordsHistory']=function(_0x88987a,_0x101342){var _0x5da450=_0x101342?encryptor[_0x394d('0x7d')](_0x101342)[_0x394d('0x7e')](','):[];if(_0x5da450['length']===0x5){_0x5da450['splice'](-0x1,0x1);}_0x5da450[_0x394d('0x83')](_0x88987a);return encryptor['encryptString'](_0x5da450[_0x394d('0x84')](','));};function signJwt(_0x9f56c8){var _0x53b6cd=BPromise[_0x394d('0x85')](jwt[_0x394d('0x86')],{'context':jwt});var _0x3d0703=_0x9f56c8['secret']||config[_0x394d('0xe')][_0x394d('0xf')];return new BPromise(function(_0x1c2de9,_0x4abeca){_0x53b6cd(_0x9f56c8[_0x394d('0x87')],_0x3d0703,_0x9f56c8['options'])['then'](function(_0x57508a){_0x1c2de9(_0x57508a);})[_0x394d('0x49')](function(_0x359fef){_0x4abeca(_0x359fef);});});}function verifyJwt(_0x56028f,_0x7fcec3,_0x5ebac1){var _0xfdd0cf=BPromise[_0x394d('0x85')](jwt[_0x394d('0x88')],{'context':jwt});var _0x4f7a63=_0x5ebac1||config[_0x394d('0xe')]['session'];return new BPromise(function(_0x1581b3,_0x54ad03){_0xfdd0cf(_0x56028f,_0x4f7a63,_0x7fcec3)[_0x394d('0x58')](function(_0x1989c7){_0x1581b3(_0x1989c7);})['catch'](function(_0x3a1386){_0x54ad03(_0x3a1386);});});}function generateNonce(){return crypto[_0x394d('0x89')](0x10)[_0x394d('0x8a')](_0x394d('0x8b'));}function generateIssuedAt(){return Math[_0x394d('0x8c')](Date[_0x394d('0x8d')]()/0x3e8)[_0x394d('0x8a')]();}function createJwt(_0x17a4cf){var _0x54c091={'payload':{'iat':_0x17a4cf[_0x394d('0x74')],'nonce':_0x17a4cf[_0x394d('0x5d')]},'options':{'algorithm':_0x394d('0x8e'),'subject':_0x17a4cf['id'][_0x394d('0x8a')](),'issuer':hardwareConf['getUuid'](),'audience':hardwareConf['getUuid']()}};return signJwt(_0x54c091)['then'](function(_0x208fd9){return{'iat':_0x17a4cf[_0x394d('0x74')],'nonce':_0x17a4cf['apiKeyNonce'],'token':_0x208fd9};});}
\ No newline at end of file
+var _0x7bf3=['composable-middleware','basic-auth','bluebird','util','secrets','role','fullname','name','internal','email','userpic','permissions','md5secret','voicePause','chatPause','mailPause','faxPause','smsPause','showWebBar','lastLoginAt','lastPauseAt','crudPermissions','allowmessenger','alias','phoneBarAutoAnswer','phoneBarDnd','phoneBarEnableRecording','phoneBarEnableDtmfTone','phoneBarExpires','phoneBarPrefixRequired','phoneBarRemoteControl','phoneBarRemoteControlPort','userProfileId','privacyEnabled','wssPort','downloadVoiceRecordings','downloadOmnichannelInteractions','downloadAttachments','ignorePauseForPreviewCalls','selectRecallMeCampaign','chatAutoanswer','chatAutoanswerDelay','emailAutoanswer','emailAutoanswerDelay','smsAutoanswer','smsAutoanswerDelay','openchannelAutoanswer','openchannelAutoanswerDelay','faxAutoanswer','whatsappAutoanswer','whatsappAutoanswerDelay','isAuthenticated','use','user','ChatInteraction','findOne','params','disposition','then','closed','query','status','unmanaged','json','Unmanaged.','Forbidden.','catch','headers','authorization','startsWith','Basic','find','authenticate','Bearer','Unknown\x20authorization\x20format','apikey','getUuid','sub','allowedLoginAttempts','blockDuration','isEqual','apiKeyNonce','nonce','API\x20access\x20key\x20is\x20not\x20valid\x20anymore','Invalid\x20API\x20access\x20key','blocked','add','minutes','User','User\x20not\x20found.','User\x20object\x20not\x20found.','getLicense','update','Forbidden','isWebrtcLicence','webrtc','isMiddleware','signToken','setTokenCookie','It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.','motion.token','redirect','/dashboards/general','retrieveApiKey','isNil','apiKeyIat','generateApiKey','regenerateApiKey','validatePasswordPattern','Sequelize','ValidationError','validatePasswordHistory','split','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','length','encryptString','join','sign','options','randomBytes','toString','hex','floor','HS512','../../mysqldb','../../config/environment','../../config/license/hardware','../encryptor','lodash','jsonwebtoken','express-jwt'];(function(_0x478b2c,_0x52c9ae){var _0x42dd64=function(_0x29e757){while(--_0x29e757){_0x478b2c['push'](_0x478b2c['shift']());}};_0x42dd64(++_0x52c9ae);}(_0x7bf3,0x107));var _0x37bf=function(_0x1255cd,_0x27e870){_0x1255cd=_0x1255cd-0x0;var _0x1ef8ea=_0x7bf3[_0x1255cd];return _0x1ef8ea;};'use strict';var db=require(_0x37bf('0x0'))['db'];var config=require(_0x37bf('0x1'));var hardwareConf=require(_0x37bf('0x2'));var licenseUtil=require('../../config/license/util');var encryptor=require(_0x37bf('0x3'));var _=require(_0x37bf('0x4'));var jwt=require(_0x37bf('0x5'));var expressJwt=require(_0x37bf('0x6'));var compose=require(_0x37bf('0x7'));var basicAuth=require(_0x37bf('0x8'));var crypto=require('crypto');var BPromise=require(_0x37bf('0x9'));var util=require(_0x37bf('0xa'));var moment=require('moment');var validateJwt=expressJwt({'secret':config[_0x37bf('0xb')]['session']});var userAttributes=['id',_0x37bf('0xc'),_0x37bf('0xd'),_0x37bf('0xe'),_0x37bf('0xf'),_0x37bf('0x10'),_0x37bf('0x11'),_0x37bf('0x12'),_0x37bf('0x13'),_0x37bf('0x14'),_0x37bf('0x15'),_0x37bf('0x16'),_0x37bf('0x17'),_0x37bf('0x18'),'openchannelPause','pauseType',_0x37bf('0x19'),_0x37bf('0x1a'),_0x37bf('0x1b'),_0x37bf('0x1c'),_0x37bf('0x1d'),'passwordResetAt',_0x37bf('0x1e'),_0x37bf('0x1f'),'phoneBarAutoAnswerDelay',_0x37bf('0x20'),_0x37bf('0x21'),_0x37bf('0x22'),'phoneBarEnableSettings',_0x37bf('0x23'),_0x37bf('0x24'),_0x37bf('0x25'),_0x37bf('0x26'),'hotdesk','interface',_0x37bf('0x27'),_0x37bf('0x28'),'settingsEnabled',_0x37bf('0x29'),_0x37bf('0x2a'),_0x37bf('0x2b'),_0x37bf('0x2c'),_0x37bf('0x2d'),_0x37bf('0x2e'),_0x37bf('0x2f'),_0x37bf('0x30'),_0x37bf('0x31'),_0x37bf('0x32'),_0x37bf('0x33'),_0x37bf('0x34'),_0x37bf('0x35'),_0x37bf('0x36'),_0x37bf('0x37'),'faxAutoanswerDelay',_0x37bf('0x38'),_0x37bf('0x39'),'messengerSoundNotification'];exports['isChatInteractionAuthorized']=function(){return this[_0x37bf('0x3a')](!![])[_0x37bf('0x3b')](function(_0x452226,_0x25d33e,_0x5cf92e){if(_0x452226[_0x37bf('0x3c')]){_0x5cf92e();}else{return db[_0x37bf('0x3d')][_0x37bf('0x3e')]({'where':{'id':_0x452226[_0x37bf('0x3f')]['id']},'attributes':['id','closed',_0x37bf('0x40')],'raw':!![]})[_0x37bf('0x41')](function(_0x79f73b){if(_0x79f73b&&_0x79f73b[_0x37bf('0x42')]&&!_0x452226[_0x37bf('0x43')]['forceDownload']){return _0x25d33e[_0x37bf('0x44')](_0x79f73b['disposition']===_0x37bf('0x45')?0x195:0x193)[_0x37bf('0x46')]({'message':_0x79f73b[_0x37bf('0x40')]===_0x37bf('0x45')?_0x37bf('0x47'):_0x37bf('0x48')});}else{_0x5cf92e();}})[_0x37bf('0x49')](function(_0x2fe473){_0x5cf92e(_0x2fe473);});}});};exports[_0x37bf('0x3a')]=function isAuthenticated(_0x3df322){return compose()[_0x37bf('0x3b')](function(_0x101475,_0x5286b5,_0x32ee9b){var _0x3a46f6;if(_0x101475[_0x37bf('0x4a')][_0x37bf('0x4b')]){if(_[_0x37bf('0x4c')](_0x101475[_0x37bf('0x4a')][_0x37bf('0x4b')],_0x37bf('0x4d'))){var _0x3dd452=basicAuth(_0x101475);db['User'][_0x37bf('0x4e')]({'where':{'name':_0x3dd452[_0x37bf('0xe')]}})['then'](function(_0x2d0db9){if(!_0x2d0db9||!_0x2d0db9[_0x37bf('0x4f')](_0x3dd452['pass'])){return _0x5286b5[_0x37bf('0x44')](0x191)[_0x37bf('0x46')]({'message':'Wrong\x20credentials.'});}_0x101475['user']={'id':_0x2d0db9['id']};_0x32ee9b();})['catch'](function(_0x50dee8){_0x32ee9b(_0x50dee8);});}else if(_[_0x37bf('0x4c')](_0x101475['headers'][_0x37bf('0x4b')],_0x37bf('0x50'))){validateJwt(_0x101475,_0x5286b5,_0x32ee9b);}else{if(_0x3df322){_0x32ee9b();}else{return _0x5286b5[_0x37bf('0x44')](0x193)[_0x37bf('0x46')]({'message':_0x37bf('0x51')});}}}else if(_0x101475[_0x37bf('0x43')][_0x37bf('0x52')]){try{var _0x18bc06={'audience':hardwareConf['getUuid'](),'issuer':hardwareConf[_0x37bf('0x53')]()};verifyJwt(_0x101475[_0x37bf('0x43')][_0x37bf('0x52')],_0x18bc06)[_0x37bf('0x41')](function(_0x336490){return db['User'][_0x37bf('0x4e')]({'where':{'id':_0x336490[_0x37bf('0x54')]}})[_0x37bf('0x41')](function(_0x38f83c){_0x3a46f6=_0x38f83c;return db['Setting'][_0x37bf('0x3e')]({'where':{'id':0x1},'attributes':[_0x37bf('0x55'),_0x37bf('0x56')],'raw':!![]});})[_0x37bf('0x41')](function(_0x5e8d66){if(!_0x3a46f6||!_[_0x37bf('0x57')](_0x3a46f6[_0x37bf('0x58')],_0x336490[_0x37bf('0x59')])){return _0x5286b5[_0x37bf('0x44')](0x191)[_0x37bf('0x46')]({'message':_0x37bf('0x5a')});}if(_0x3a46f6['disabled']){return _0x5286b5[_0x37bf('0x44')](0x191)[_0x37bf('0x46')]({'message':_0x37bf('0x5b')});}if(_0x3a46f6[_0x37bf('0x5c')]){if(_0x5e8d66[_0x37bf('0x56')]>0x0){if(moment(_0x3a46f6['blockedAt'])[_0x37bf('0x5d')](_0x5e8d66[_0x37bf('0x56')],_0x37bf('0x5e'))>moment()){return _0x5286b5[_0x37bf('0x44')](0x191)[_0x37bf('0x46')]({'message':'Invalid\x20API\x20access\x20key'});}}else{return _0x5286b5[_0x37bf('0x44')](0x191)['json']({'message':_0x37bf('0x5b')});}}_0x101475[_0x37bf('0x3c')]={'id':_0x3a46f6['id']};_0x32ee9b();});})[_0x37bf('0x49')](function(){return _0x5286b5[_0x37bf('0x44')](0x191)['json']({'message':_0x37bf('0x5b')});});}catch(_0x2d3a95){_0x32ee9b(_0x2d3a95);}}else if(_0x3df322){_0x32ee9b();}else{return _0x5286b5[_0x37bf('0x44')](0x193)['json']({'message':_0x37bf('0x51')});}})[_0x37bf('0x3b')](function(_0x18baf4,_0x373cb1,_0x4eb186){if(_0x18baf4[_0x37bf('0x3c')]){db[_0x37bf('0x5f')]['find']({'where':{'id':_0x18baf4[_0x37bf('0x3c')]['id']},'attributes':userAttributes})['then'](function(_0x5e60e0){if(!_0x5e60e0){return _0x373cb1[_0x37bf('0x44')](0x194)['json']({'message':_0x37bf('0x60')});}_0x18baf4[_0x37bf('0x3c')]=_0x5e60e0;_0x4eb186();})[_0x37bf('0x49')](function(_0xd16c51){_0x4eb186(_0xd16c51);});}else if(_0x3df322){_0x4eb186();}else{return _0x373cb1['status'](0x194)[_0x37bf('0x46')]({'message':_0x37bf('0x61')});}});};exports['canUpdate']=function canUpdate(){return compose()[_0x37bf('0x3b')](function(_0x10fb33,_0x2b2556,_0x4aee28){return licenseUtil[_0x37bf('0x62')]()['then'](function(_0x3fe11f){if(_0x3fe11f[_0x37bf('0x63')]){_0x4aee28();}else{return _0x2b2556['status'](0x193)['json']({'message':_0x37bf('0x64')});}})[_0x37bf('0x49')](function(_0x1f9574){_0x4aee28(_0x1f9574);});});};exports[_0x37bf('0x65')]=function isWebrtcLicence(){return compose()['use'](function(_0xb193fe,_0x574a7d,_0x2ca6be){return licenseUtil[_0x37bf('0x62')]()[_0x37bf('0x41')](function(_0x419882){if(_0x419882[_0x37bf('0x66')]){_0x2ca6be();}else{return _0x574a7d[_0x37bf('0x44')](0x193)[_0x37bf('0x46')]({'message':_0x37bf('0x64')});}})[_0x37bf('0x49')](function(_0x433f26){_0x2ca6be(_0x433f26);});});};exports['isMiddleware']=function(_0x4492ec,_0x4f6927,_0x5ac11c){_0x4492ec[_0x37bf('0x67')]=!![];return _0x5ac11c();};exports[_0x37bf('0x68')]=function signToken(_0x4b4deb){return signJwt(_0x4b4deb);};exports[_0x37bf('0x69')]=function(_0xc4fee7,_0x55dffd){if(!_0xc4fee7['user']){return _0x55dffd[_0x37bf('0x44')](0x194)[_0x37bf('0x46')]({'message':_0x37bf('0x6a')});}var _0x16c609={'payload':{'id':_0xc4fee7['user']['id'],'role':_0xc4fee7[_0x37bf('0x3c')][_0x37bf('0xc')]},'options':{'expiresIn':0x15180}};return signJwt(_0x16c609)[_0x37bf('0x41')](function(_0x1b93f0){_0x55dffd['cookie'](_0x37bf('0x6b'),_0x1b93f0);_0x55dffd[_0x37bf('0x6c')](_0x37bf('0x6d'));})[_0x37bf('0x49')](function(_0x1094e1){return _0x55dffd[_0x37bf('0x44')](0x1f4)['send'](_0x1094e1);});};exports[_0x37bf('0x6e')]=function(_0x3cd5ef){if(_[_0x37bf('0x6f')](_0x3cd5ef['apiKeyNonce'])||_['isNil'](_0x3cd5ef[_0x37bf('0x70')])){return null;}else{return createJwt(_0x3cd5ef);}};exports[_0x37bf('0x71')]=function(_0x2713a8){_0x2713a8[_0x37bf('0x58')]=generateNonce();_0x2713a8[_0x37bf('0x70')]=generateIssuedAt();return createJwt(_0x2713a8);};exports[_0x37bf('0x72')]=function(_0x445d70,_0x291df2){var _0x3a8686=_0x445d70[_0x37bf('0x43')][_0x37bf('0x52')];if(_0x3a8686){var _0x2bf97f={'nonce':_0x291df2[_0x37bf('0x58')],'iat':_0x291df2[_0x37bf('0x70')],'audience':hardwareConf[_0x37bf('0x53')](),'issuer':hardwareConf[_0x37bf('0x53')]()};return verifyJwt(_0x3a8686,_0x2bf97f)[_0x37bf('0x41')](function(){return generateApiKey(_0x291df2);});}else{throw{'message':'Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one'};}};exports[_0x37bf('0x73')]=function(_0x4f014a){var _0x5aebc6=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(!_0x5aebc6['test'](_0x4f014a))throw new db[(_0x37bf('0x74'))][(_0x37bf('0x75'))]('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[_0x37bf('0x76')]=function(_0x1f05a6,_0x57e655,_0x572273){var _0x502d9c=encryptor['decryptString'](_0x57e655)[_0x37bf('0x77')](',');for(var _0x1a8b19=0x0;_0x1a8b19<_0x572273;_0x1a8b19++){if(!_0x502d9c[_0x1a8b19])break;if(_0x1f05a6['toLowerCase']()===_0x502d9c[_0x1a8b19][_0x37bf('0x78')]()){var _0x14fed5=util[_0x37bf('0x79')](_0x37bf('0x7a'),_0x572273);if(_0x572273===0x1){_0x14fed5=_0x37bf('0x7b');}throw new db[(_0x37bf('0x74'))]['ValidationError'](_0x14fed5);}}return;};exports[_0x37bf('0x7c')]=function(_0x42ce83,_0x2c0c9e){var _0x20da59=_0x2c0c9e?encryptor['decryptString'](_0x2c0c9e)['split'](','):[];if(_0x20da59[_0x37bf('0x7d')]===0x5){_0x20da59['splice'](-0x1,0x1);}_0x20da59['unshift'](_0x42ce83);return encryptor[_0x37bf('0x7e')](_0x20da59[_0x37bf('0x7f')](','));};function signJwt(_0x384df4){var _0x144f80=BPromise['promisify'](jwt[_0x37bf('0x80')],{'context':jwt});var _0x3e1402=_0x384df4['secret']||config[_0x37bf('0xb')]['session'];return new BPromise(function(_0x56d4ca,_0x517174){_0x144f80(_0x384df4['payload'],_0x3e1402,_0x384df4[_0x37bf('0x81')])[_0x37bf('0x41')](function(_0x8c61db){_0x56d4ca(_0x8c61db);})[_0x37bf('0x49')](function(_0x4e47e9){_0x517174(_0x4e47e9);});});}function verifyJwt(_0x62696b,_0x22fc83,_0x3d1d6a){var _0x1b3563=BPromise['promisify'](jwt['verify'],{'context':jwt});var _0x2468e4=_0x3d1d6a||config[_0x37bf('0xb')]['session'];return new BPromise(function(_0xac608b,_0x35db33){_0x1b3563(_0x62696b,_0x2468e4,_0x22fc83)[_0x37bf('0x41')](function(_0x2a3d99){_0xac608b(_0x2a3d99);})[_0x37bf('0x49')](function(_0x1fe472){_0x35db33(_0x1fe472);});});}function generateNonce(){return crypto[_0x37bf('0x82')](0x10)[_0x37bf('0x83')](_0x37bf('0x84'));}function generateIssuedAt(){return Math[_0x37bf('0x85')](Date['now']()/0x3e8)[_0x37bf('0x83')]();}function createJwt(_0xd91fbe){var _0x804895={'payload':{'iat':_0xd91fbe['apiKeyIat'],'nonce':_0xd91fbe[_0x37bf('0x58')]},'options':{'algorithm':_0x37bf('0x86'),'subject':_0xd91fbe['id'][_0x37bf('0x83')](),'issuer':hardwareConf[_0x37bf('0x53')](),'audience':hardwareConf[_0x37bf('0x53')]()}};return signJwt(_0x804895)[_0x37bf('0x41')](function(_0xe4cf22){return{'iat':_0xd91fbe[_0x37bf('0x70')],'nonce':_0xd91fbe[_0x37bf('0x58')],'token':_0xe4cf22};});}
\ No newline at end of file