Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / components / auth / service.js
index 4e5f1a8..c423fba 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x573f=['hex','floor','now','HS512','../../mysqldb','../../config/environment','jsonwebtoken','express-jwt','composable-middleware','basic-auth','crypto','bluebird','role','fullname','name','internal','email','userpic','permissions','md5secret','voicePause','chatPause','mailPause','smsPause','openchannelPause','lastPauseAt','crudPermissions','allowmessenger','alias','phoneBarAutoAnswer','phoneBarAutoAnswerDelay','phoneBarEnableDtmfTone','phoneBarEnableSettings','phoneBarExpires','phoneBarPrefixRequired','phoneBarRemoteControlPort','hotdesk','interface','userProfileId','isChatInteractionAuthorized','use','user','ChatInteraction','params','closed','disposition','then','unmanaged','json','Unmanaged.','Forbidden.','catch','isAuthenticated','headers','authorization','startsWith','find','authenticate','pass','Wrong\x20credentials.','Bearer','status','Unknown\x20authorization\x20format','query','apikey','getUuid','User','sub','isEqual','apiKeyNonce','API\x20access\x20key\x20is\x20not\x20valid\x20anymore','User\x20not\x20found.','User\x20object\x20not\x20found.','../../config/license/util','getLicense','update','Forbidden','isMiddleware','signToken','setTokenCookie','It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.','redirect','/dashboards/general','isNil','apiKeyIat','regenerateApiKey','Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one','secret','secrets','payload','options','promisify','verify','session','randomBytes','toString'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x573f,0x64));var _0xf573=function(_0x1b1e6a,_0x2856a3){_0x1b1e6a=_0x1b1e6a-0x0;var _0x5eff52=_0x573f[_0x1b1e6a];return _0x5eff52;};'use strict';var db=require(_0xf573('0x0'))['db'];var config=require(_0xf573('0x1'));var hardwareConf=require('../../config/license/hardware');var _=require('lodash');var jwt=require(_0xf573('0x2'));var expressJwt=require(_0xf573('0x3'));var compose=require(_0xf573('0x4'));var basicAuth=require(_0xf573('0x5'));var crypto=require(_0xf573('0x6'));var BPromise=require(_0xf573('0x7'));var validateJwt=expressJwt({'secret':config['secrets']['session']});var userAttributes=['id',_0xf573('0x8'),_0xf573('0x9'),_0xf573('0xa'),_0xf573('0xb'),_0xf573('0xc'),_0xf573('0xd'),_0xf573('0xe'),_0xf573('0xf'),_0xf573('0x10'),_0xf573('0x11'),_0xf573('0x12'),'faxPause',_0xf573('0x13'),_0xf573('0x14'),'pauseType','showWebBar','lastLoginAt',_0xf573('0x15'),_0xf573('0x16'),_0xf573('0x17'),'passwordResetAt',_0xf573('0x18'),_0xf573('0x19'),_0xf573('0x1a'),'phoneBarDnd','phoneBarEnableRecording',_0xf573('0x1b'),_0xf573('0x1c'),_0xf573('0x1d'),_0xf573('0x1e'),'phoneBarRemoteControl',_0xf573('0x1f'),_0xf573('0x20'),_0xf573('0x21'),_0xf573('0x22')];exports[_0xf573('0x23')]=function(){return this['isAuthenticated'](!![])[_0xf573('0x24')](function(_0x46fefd,_0x34c59a,_0xbcd159){if(_0x46fefd[_0xf573('0x25')]){_0xbcd159();}else{return db[_0xf573('0x26')]['findOne']({'where':{'id':_0x46fefd[_0xf573('0x27')]['id']},'attributes':['id',_0xf573('0x28'),_0xf573('0x29')],'raw':!![]})[_0xf573('0x2a')](function(_0x183e1d){if(_0x183e1d&&_0x183e1d[_0xf573('0x28')]){return _0x34c59a['status'](_0x183e1d[_0xf573('0x29')]===_0xf573('0x2b')?0x195:0x193)[_0xf573('0x2c')]({'message':_0x183e1d[_0xf573('0x29')]===_0xf573('0x2b')?_0xf573('0x2d'):_0xf573('0x2e')});}else{_0xbcd159();}})[_0xf573('0x2f')](function(_0xbed0a6){_0xbcd159(_0xbed0a6);});}});};exports[_0xf573('0x30')]=function isAuthenticated(_0x299d9c){return compose()['use'](function(_0xb42a35,_0x4f27e4,_0xf7cc65){if(_0xb42a35[_0xf573('0x31')][_0xf573('0x32')]){if(_[_0xf573('0x33')](_0xb42a35[_0xf573('0x31')]['authorization'],'Basic')){var _0x490b67=basicAuth(_0xb42a35);db['User'][_0xf573('0x34')]({'where':{'name':_0x490b67[_0xf573('0xa')]}})[_0xf573('0x2a')](function(_0xf59eef){if(!_0xf59eef||!_0xf59eef[_0xf573('0x35')](_0x490b67[_0xf573('0x36')])){return _0x4f27e4['status'](0x191)[_0xf573('0x2c')]({'message':_0xf573('0x37')});}_0xb42a35[_0xf573('0x25')]={'id':_0xf59eef['id']};_0xf7cc65();})[_0xf573('0x2f')](function(_0x284330){_0xf7cc65(_0x284330);});}else if(_[_0xf573('0x33')](_0xb42a35[_0xf573('0x31')][_0xf573('0x32')],_0xf573('0x38'))){validateJwt(_0xb42a35,_0x4f27e4,_0xf7cc65);}else{if(_0x299d9c){_0xf7cc65();}else{return _0x4f27e4[_0xf573('0x39')](0x193)['json']({'message':_0xf573('0x3a')});}}}else if(_0xb42a35[_0xf573('0x3b')][_0xf573('0x3c')]){try{var _0x54e6fc={'audience':hardwareConf[_0xf573('0x3d')](),'issuer':hardwareConf[_0xf573('0x3d')]()};verifyJwt(_0xb42a35[_0xf573('0x3b')][_0xf573('0x3c')],_0x54e6fc)[_0xf573('0x2a')](function(_0x51b7a7){return db[_0xf573('0x3e')]['find']({'where':{'id':_0x51b7a7[_0xf573('0x3f')]}})[_0xf573('0x2a')](function(_0x1abf7f){if(!_0x1abf7f||!_[_0xf573('0x40')](_0x1abf7f[_0xf573('0x41')],_0x51b7a7['nonce'])){return _0x4f27e4[_0xf573('0x39')](0x191)[_0xf573('0x2c')]({'message':_0xf573('0x42')});}_0xb42a35[_0xf573('0x25')]={'id':_0x1abf7f['id']};_0xf7cc65();});})[_0xf573('0x2f')](function(){return _0x4f27e4[_0xf573('0x39')](0x191)[_0xf573('0x2c')]({'message':'Invalid\x20API\x20access\x20key'});});}catch(_0x367c8c){_0xf7cc65(_0x367c8c);}}else if(_0x299d9c){_0xf7cc65();}else{return _0x4f27e4[_0xf573('0x39')](0x193)[_0xf573('0x2c')]({'message':'Unknown\x20authorization\x20format'});}})['use'](function(_0x303c87,_0x2653c4,_0x55d1b7){if(_0x303c87['user']){db[_0xf573('0x3e')][_0xf573('0x34')]({'where':{'id':_0x303c87[_0xf573('0x25')]['id']},'attributes':userAttributes})[_0xf573('0x2a')](function(_0x288539){if(!_0x288539){return _0x2653c4[_0xf573('0x39')](0x194)[_0xf573('0x2c')]({'message':_0xf573('0x43')});}_0x303c87['user']=_0x288539;_0x55d1b7();})['catch'](function(_0x38fd2f){_0x55d1b7(_0x38fd2f);});}else if(_0x299d9c){_0x55d1b7();}else{return _0x2653c4[_0xf573('0x39')](0x194)[_0xf573('0x2c')]({'message':_0xf573('0x44')});}});};exports['canUpdate']=function canUpdate(){return compose()[_0xf573('0x24')](function(_0x36c262,_0x2e77ba,_0x146476){return require(_0xf573('0x45'))[_0xf573('0x46')]()['then'](function(_0x32320e){if(_0x32320e[_0xf573('0x47')]){_0x146476();}else{return _0x2e77ba['status'](0x193)[_0xf573('0x2c')]({'message':_0xf573('0x48')});}})['catch'](function(_0x378c89){_0x146476(_0x378c89);});});};exports['isMiddleware']=function(_0x355578,_0x2aec97,_0xd28e96){_0x355578[_0xf573('0x49')]=!![];return _0xd28e96();};exports[_0xf573('0x4a')]=function signToken(_0x1e2dfe){return signJwt(_0x1e2dfe);};exports[_0xf573('0x4b')]=function(_0x58f069,_0x12dd48){if(!_0x58f069[_0xf573('0x25')]){return _0x12dd48[_0xf573('0x39')](0x194)['json']({'message':_0xf573('0x4c')});}var _0x1fff35={'payload':{'id':_0x58f069['user']['id'],'role':_0x58f069['user'][_0xf573('0x8')]},'options':{'expiresIn':0x15180}};return signJwt(_0x1fff35)[_0xf573('0x2a')](function(_0xf8ea30){_0x12dd48['cookie']('motion.token',_0xf8ea30);_0x12dd48[_0xf573('0x4d')](_0xf573('0x4e'));})[_0xf573('0x2f')](function(_0xbb9402){return _0x12dd48['status'](0x1f4)['send'](_0xbb9402);});};exports['retrieveApiKey']=function(_0x739224){if(_['isNil'](_0x739224[_0xf573('0x41')])||_[_0xf573('0x4f')](_0x739224[_0xf573('0x50')])){return null;}else{return createJwt(_0x739224);}};exports['generateApiKey']=function(_0x535ebc){_0x535ebc[_0xf573('0x41')]=generateNonce();_0x535ebc[_0xf573('0x50')]=generateIssuedAt();return createJwt(_0x535ebc);};exports[_0xf573('0x51')]=function(_0x27358d,_0x4e5229){var _0x9f93b5=_0x27358d[_0xf573('0x3b')][_0xf573('0x3c')];if(_0x9f93b5){var _0x40c65a={'nonce':_0x4e5229[_0xf573('0x41')],'iat':_0x4e5229[_0xf573('0x50')],'audience':hardwareConf[_0xf573('0x3d')](),'issuer':hardwareConf[_0xf573('0x3d')]()};return verifyJwt(_0x9f93b5,_0x40c65a)[_0xf573('0x2a')](function(){return generateApiKey(_0x4e5229);});}else{throw{'message':_0xf573('0x52')};}};function signJwt(_0x1226d6){var _0x5e3c6f=BPromise['promisify'](jwt['sign'],{'context':jwt});var _0x30abde=_0x1226d6[_0xf573('0x53')]||config[_0xf573('0x54')]['session'];return new BPromise(function(_0x2fbb66,_0x171375){_0x5e3c6f(_0x1226d6[_0xf573('0x55')],_0x30abde,_0x1226d6[_0xf573('0x56')])[_0xf573('0x2a')](function(_0x482f22){_0x2fbb66(_0x482f22);})[_0xf573('0x2f')](function(_0x16f2e7){_0x171375(_0x16f2e7);});});}function verifyJwt(_0x24b389,_0x59a194,_0x12904d){var _0x3c0021=BPromise[_0xf573('0x57')](jwt[_0xf573('0x58')],{'context':jwt});var _0x582cab=_0x12904d||config[_0xf573('0x54')][_0xf573('0x59')];return new BPromise(function(_0x54df7b,_0x5f2a15){_0x3c0021(_0x24b389,_0x582cab,_0x59a194)[_0xf573('0x2a')](function(_0x2f816f){_0x54df7b(_0x2f816f);})[_0xf573('0x2f')](function(_0x3adf63){_0x5f2a15(_0x3adf63);});});}function generateNonce(){return crypto[_0xf573('0x5a')](0x10)[_0xf573('0x5b')](_0xf573('0x5c'));}function generateIssuedAt(){return Math[_0xf573('0x5d')](Date[_0xf573('0x5e')]()/0x3e8)['toString']();}function createJwt(_0x20637c){var _0x368e76={'payload':{'iat':_0x20637c[_0xf573('0x50')],'nonce':_0x20637c[_0xf573('0x41')]},'options':{'algorithm':_0xf573('0x5f'),'subject':_0x20637c['id'][_0xf573('0x5b')](),'issuer':hardwareConf[_0xf573('0x3d')](),'audience':hardwareConf[_0xf573('0x3d')]()}};return signJwt(_0x368e76)[_0xf573('0x2a')](function(_0x3ccbca){return{'iat':_0x20637c[_0xf573('0x50')],'nonce':_0x20637c[_0xf573('0x41')],'token':_0x3ccbca};});}
\ No newline at end of file
+var _0x757a=['isAuthenticated','use','user','ChatInteraction','params','disposition','closed','status','unmanaged','json','Forbidden.','headers','startsWith','Basic','User','find','then','authenticate','pass','Wrong\x20credentials.','catch','authorization','Bearer','Unknown\x20authorization\x20format','query','apikey','getUuid','sub','Setting','findOne','allowedLoginAttempts','isEqual','apiKeyNonce','nonce','API\x20access\x20key\x20is\x20not\x20valid\x20anymore','disabled','Invalid\x20API\x20access\x20key','blocked','blockDuration','blockedAt','add','minutes','User\x20not\x20found.','canUpdate','getLicense','update','Forbidden','isWebrtcLicence','isMiddleware','signToken','setTokenCookie','It\x20looks\x20like\x20you\x20aren\x27t\x20logged\x20in,\x20please\x20try\x20again.','cookie','motion.token','redirect','/dashboards/general','retrieveApiKey','isNil','apiKeyIat','regenerateApiKey','Please\x20use\x20the\x20previous\x20API\x20access\x20key\x20to\x20generate\x20a\x20new\x20one','validatePasswordPattern','test','Sequelize','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','toLowerCase','format','ValidationError','updatePasswordsHistory','length','splice','unshift','promisify','sign','secret','session','payload','options','verify','randomBytes','hex','floor','toString','HS512','../../config/environment','../../config/license/hardware','jsonwebtoken','express-jwt','composable-middleware','basic-auth','crypto','bluebird','moment','secrets','role','fullname','name','internal','email','permissions','md5secret','voicePause','chatPause','mailPause','faxPause','smsPause','crudPermissions','alias','phoneBarDnd','phoneBarEnableRecording','phoneBarEnableDtmfTone','phoneBarEnableSettings','phoneBarExpires','phoneBarPrefixRequired','phoneBarRemoteControl','phoneBarRemoteControlPort','hotdesk','interface','privacyEnabled','settingsEnabled','wssPort','downloadAttachments','ignorePauseForPreviewCalls','selectRecallMeCampaign','chatAutoanswer','chatAutoanswerDelay','emailAutoanswer','smsAutoanswer','openchannelAutoanswer','openchannelAutoanswerDelay','faxAutoanswer','faxAutoanswerDelay','messengerSoundNotification','isChatInteractionAuthorized'];(function(_0x53b1f8,_0x303433){var _0x288960=function(_0x136a4c){while(--_0x136a4c){_0x53b1f8['push'](_0x53b1f8['shift']());}};_0x288960(++_0x303433);}(_0x757a,0xde));var _0xa757=function(_0x39aa2d,_0x364f79){_0x39aa2d=_0x39aa2d-0x0;var _0x3a0094=_0x757a[_0x39aa2d];return _0x3a0094;};'use strict';var db=require('../../mysqldb')['db'];var config=require(_0xa757('0x0'));var hardwareConf=require(_0xa757('0x1'));var licenseUtil=require('../../config/license/util');var encryptor=require('../encryptor');var _=require('lodash');var jwt=require(_0xa757('0x2'));var expressJwt=require(_0xa757('0x3'));var compose=require(_0xa757('0x4'));var basicAuth=require(_0xa757('0x5'));var crypto=require(_0xa757('0x6'));var BPromise=require(_0xa757('0x7'));var util=require('util');var moment=require(_0xa757('0x8'));var validateJwt=expressJwt({'secret':config[_0xa757('0x9')]['session']});var userAttributes=['id',_0xa757('0xa'),_0xa757('0xb'),_0xa757('0xc'),_0xa757('0xd'),_0xa757('0xe'),'userpic',_0xa757('0xf'),_0xa757('0x10'),_0xa757('0x11'),_0xa757('0x12'),_0xa757('0x13'),_0xa757('0x14'),_0xa757('0x15'),'openchannelPause','pauseType','showWebBar','lastLoginAt','lastPauseAt',_0xa757('0x16'),'allowmessenger','passwordResetAt',_0xa757('0x17'),'phoneBarAutoAnswer','phoneBarAutoAnswerDelay',_0xa757('0x18'),_0xa757('0x19'),_0xa757('0x1a'),_0xa757('0x1b'),_0xa757('0x1c'),_0xa757('0x1d'),_0xa757('0x1e'),_0xa757('0x1f'),_0xa757('0x20'),_0xa757('0x21'),'userProfileId',_0xa757('0x22'),_0xa757('0x23'),_0xa757('0x24'),'downloadVoiceRecordings','downloadOmnichannelInteractions',_0xa757('0x25'),_0xa757('0x26'),_0xa757('0x27'),_0xa757('0x28'),_0xa757('0x29'),_0xa757('0x2a'),'emailAutoanswerDelay',_0xa757('0x2b'),'smsAutoanswerDelay',_0xa757('0x2c'),_0xa757('0x2d'),_0xa757('0x2e'),_0xa757('0x2f'),'whatsappAutoanswer','whatsappAutoanswerDelay',_0xa757('0x30')];exports[_0xa757('0x31')]=function(){return this[_0xa757('0x32')](!![])[_0xa757('0x33')](function(_0x1d6e2,_0x40562f,_0x2ca10d){if(_0x1d6e2[_0xa757('0x34')]){_0x2ca10d();}else{return db[_0xa757('0x35')]['findOne']({'where':{'id':_0x1d6e2[_0xa757('0x36')]['id']},'attributes':['id','closed',_0xa757('0x37')],'raw':!![]})['then'](function(_0x40551d){if(_0x40551d&&_0x40551d[_0xa757('0x38')]){return _0x40562f[_0xa757('0x39')](_0x40551d['disposition']===_0xa757('0x3a')?0x195:0x193)[_0xa757('0x3b')]({'message':_0x40551d[_0xa757('0x37')]===_0xa757('0x3a')?'Unmanaged.':_0xa757('0x3c')});}else{_0x2ca10d();}})['catch'](function(_0x5a5664){_0x2ca10d(_0x5a5664);});}});};exports['isAuthenticated']=function isAuthenticated(_0x4f8de2){return compose()[_0xa757('0x33')](function(_0x596ae2,_0x2208f9,_0x3bc24c){var _0x55c5f8;if(_0x596ae2[_0xa757('0x3d')]['authorization']){if(_[_0xa757('0x3e')](_0x596ae2[_0xa757('0x3d')]['authorization'],_0xa757('0x3f'))){var _0x5ade7b=basicAuth(_0x596ae2);db[_0xa757('0x40')][_0xa757('0x41')]({'where':{'name':_0x5ade7b[_0xa757('0xc')]}})[_0xa757('0x42')](function(_0xcc87c0){if(!_0xcc87c0||!_0xcc87c0[_0xa757('0x43')](_0x5ade7b[_0xa757('0x44')])){return _0x2208f9[_0xa757('0x39')](0x191)[_0xa757('0x3b')]({'message':_0xa757('0x45')});}_0x596ae2[_0xa757('0x34')]={'id':_0xcc87c0['id']};_0x3bc24c();})[_0xa757('0x46')](function(_0x25dfbb){_0x3bc24c(_0x25dfbb);});}else if(_[_0xa757('0x3e')](_0x596ae2[_0xa757('0x3d')][_0xa757('0x47')],_0xa757('0x48'))){validateJwt(_0x596ae2,_0x2208f9,_0x3bc24c);}else{if(_0x4f8de2){_0x3bc24c();}else{return _0x2208f9[_0xa757('0x39')](0x193)[_0xa757('0x3b')]({'message':_0xa757('0x49')});}}}else if(_0x596ae2[_0xa757('0x4a')][_0xa757('0x4b')]){try{var _0x379de7={'audience':hardwareConf[_0xa757('0x4c')](),'issuer':hardwareConf['getUuid']()};verifyJwt(_0x596ae2[_0xa757('0x4a')][_0xa757('0x4b')],_0x379de7)[_0xa757('0x42')](function(_0x1794a9){return db[_0xa757('0x40')]['find']({'where':{'id':_0x1794a9[_0xa757('0x4d')]}})[_0xa757('0x42')](function(_0x37b1a3){_0x55c5f8=_0x37b1a3;return db[_0xa757('0x4e')][_0xa757('0x4f')]({'where':{'id':0x1},'attributes':[_0xa757('0x50'),'blockDuration'],'raw':!![]});})[_0xa757('0x42')](function(_0x444639){if(!_0x55c5f8||!_[_0xa757('0x51')](_0x55c5f8[_0xa757('0x52')],_0x1794a9[_0xa757('0x53')])){return _0x2208f9[_0xa757('0x39')](0x191)[_0xa757('0x3b')]({'message':_0xa757('0x54')});}if(_0x55c5f8[_0xa757('0x55')]){return _0x2208f9['status'](0x191)[_0xa757('0x3b')]({'message':_0xa757('0x56')});}if(_0x55c5f8[_0xa757('0x57')]){if(_0x444639[_0xa757('0x58')]>0x0){if(moment(_0x55c5f8[_0xa757('0x59')])[_0xa757('0x5a')](_0x444639['blockDuration'],_0xa757('0x5b'))>moment()){return _0x2208f9[_0xa757('0x39')](0x191)['json']({'message':'Invalid\x20API\x20access\x20key'});}}else{return _0x2208f9[_0xa757('0x39')](0x191)[_0xa757('0x3b')]({'message':'Invalid\x20API\x20access\x20key'});}}_0x596ae2['user']={'id':_0x55c5f8['id']};_0x3bc24c();});})[_0xa757('0x46')](function(){return _0x2208f9[_0xa757('0x39')](0x191)[_0xa757('0x3b')]({'message':'Invalid\x20API\x20access\x20key'});});}catch(_0x830dc4){_0x3bc24c(_0x830dc4);}}else if(_0x4f8de2){_0x3bc24c();}else{return _0x2208f9[_0xa757('0x39')](0x193)[_0xa757('0x3b')]({'message':_0xa757('0x49')});}})[_0xa757('0x33')](function(_0x4c6639,_0x1f9af,_0x52c728){if(_0x4c6639['user']){db[_0xa757('0x40')][_0xa757('0x41')]({'where':{'id':_0x4c6639[_0xa757('0x34')]['id']},'attributes':userAttributes})[_0xa757('0x42')](function(_0x9a0934){if(!_0x9a0934){return _0x1f9af['status'](0x194)['json']({'message':_0xa757('0x5c')});}_0x4c6639[_0xa757('0x34')]=_0x9a0934;_0x52c728();})[_0xa757('0x46')](function(_0xe03a3c){_0x52c728(_0xe03a3c);});}else if(_0x4f8de2){_0x52c728();}else{return _0x1f9af[_0xa757('0x39')](0x194)[_0xa757('0x3b')]({'message':'User\x20object\x20not\x20found.'});}});};exports[_0xa757('0x5d')]=function canUpdate(){return compose()[_0xa757('0x33')](function(_0x4d66d4,_0x40e291,_0x515123){return licenseUtil[_0xa757('0x5e')]()[_0xa757('0x42')](function(_0x4cf90f){if(_0x4cf90f[_0xa757('0x5f')]){_0x515123();}else{return _0x40e291[_0xa757('0x39')](0x193)['json']({'message':_0xa757('0x60')});}})[_0xa757('0x46')](function(_0x27ae35){_0x515123(_0x27ae35);});});};exports[_0xa757('0x61')]=function isWebrtcLicence(){return compose()['use'](function(_0x199dc9,_0x1be3bb,_0x450815){return licenseUtil[_0xa757('0x5e')]()['then'](function(_0xd4c1b){if(_0xd4c1b['webrtc']){_0x450815();}else{return _0x1be3bb['status'](0x193)[_0xa757('0x3b')]({'message':_0xa757('0x60')});}})[_0xa757('0x46')](function(_0x5e13cf){_0x450815(_0x5e13cf);});});};exports[_0xa757('0x62')]=function(_0x560c6c,_0x2ed63f,_0x151cc3){_0x560c6c[_0xa757('0x62')]=!![];return _0x151cc3();};exports[_0xa757('0x63')]=function signToken(_0x18b0ca){return signJwt(_0x18b0ca);};exports[_0xa757('0x64')]=function(_0x57bf73,_0x505cd){if(!_0x57bf73['user']){return _0x505cd[_0xa757('0x39')](0x194)[_0xa757('0x3b')]({'message':_0xa757('0x65')});}var _0x29434d={'payload':{'id':_0x57bf73[_0xa757('0x34')]['id'],'role':_0x57bf73[_0xa757('0x34')][_0xa757('0xa')]},'options':{'expiresIn':0x15180}};return signJwt(_0x29434d)[_0xa757('0x42')](function(_0x405397){_0x505cd[_0xa757('0x66')](_0xa757('0x67'),_0x405397);_0x505cd[_0xa757('0x68')](_0xa757('0x69'));})[_0xa757('0x46')](function(_0x388573){return _0x505cd[_0xa757('0x39')](0x1f4)['send'](_0x388573);});};exports[_0xa757('0x6a')]=function(_0x51157e){if(_[_0xa757('0x6b')](_0x51157e[_0xa757('0x52')])||_[_0xa757('0x6b')](_0x51157e[_0xa757('0x6c')])){return null;}else{return createJwt(_0x51157e);}};exports['generateApiKey']=function(_0x35cd81){_0x35cd81[_0xa757('0x52')]=generateNonce();_0x35cd81[_0xa757('0x6c')]=generateIssuedAt();return createJwt(_0x35cd81);};exports[_0xa757('0x6d')]=function(_0x595f16,_0x383674){var _0x2df5e1=_0x595f16[_0xa757('0x4a')][_0xa757('0x4b')];if(_0x2df5e1){var _0x33666d={'nonce':_0x383674[_0xa757('0x52')],'iat':_0x383674['apiKeyIat'],'audience':hardwareConf['getUuid'](),'issuer':hardwareConf['getUuid']()};return verifyJwt(_0x2df5e1,_0x33666d)['then'](function(){return generateApiKey(_0x383674);});}else{throw{'message':_0xa757('0x6e')};}};exports[_0xa757('0x6f')]=function(_0x137477){var _0x32313b=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(!_0x32313b[_0xa757('0x70')](_0x137477))throw new db[(_0xa757('0x71'))]['ValidationError'](_0xa757('0x72'));return;};exports[_0xa757('0x73')]=function(_0x34e03f,_0x29b2f5,_0x48b578){var _0x26c74e=encryptor[_0xa757('0x74')](_0x29b2f5)['split'](',');for(var _0x39699d=0x0;_0x39699d<_0x48b578;_0x39699d++){if(!_0x26c74e[_0x39699d])break;if(_0x34e03f['toLowerCase']()===_0x26c74e[_0x39699d][_0xa757('0x75')]()){var _0x5d375c=util[_0xa757('0x76')]('The\x20password\x20must\x20be\x20different\x20from\x20the\x20previous\x20%d\x20passwords.\x20Please\x20choose\x20another\x20one.',_0x48b578);if(_0x48b578===0x1){_0x5d375c='The\x20password\x20must\x20be\x20different\x20from\x20the\x20last\x20one.\x20Please\x20choose\x20another\x20one.';}throw new db[(_0xa757('0x71'))][(_0xa757('0x77'))](_0x5d375c);}}return;};exports[_0xa757('0x78')]=function(_0x1b5db5,_0x14e226){var _0xc5ae37=_0x14e226?encryptor['decryptString'](_0x14e226)['split'](','):[];if(_0xc5ae37[_0xa757('0x79')]===0x5){_0xc5ae37[_0xa757('0x7a')](-0x1,0x1);}_0xc5ae37[_0xa757('0x7b')](_0x1b5db5);return encryptor['encryptString'](_0xc5ae37['join'](','));};function signJwt(_0x18dff7){var _0x31c4cd=BPromise[_0xa757('0x7c')](jwt[_0xa757('0x7d')],{'context':jwt});var _0x12b802=_0x18dff7[_0xa757('0x7e')]||config['secrets'][_0xa757('0x7f')];return new BPromise(function(_0x45f2a4,_0x415fe1){_0x31c4cd(_0x18dff7[_0xa757('0x80')],_0x12b802,_0x18dff7[_0xa757('0x81')])[_0xa757('0x42')](function(_0x213219){_0x45f2a4(_0x213219);})[_0xa757('0x46')](function(_0xb45477){_0x415fe1(_0xb45477);});});}function verifyJwt(_0x3b1bb8,_0x5d3219,_0x9e96e6){var _0x5c803a=BPromise['promisify'](jwt[_0xa757('0x82')],{'context':jwt});var _0x3da8c1=_0x9e96e6||config[_0xa757('0x9')][_0xa757('0x7f')];return new BPromise(function(_0x3c3ff1,_0x3672a7){_0x5c803a(_0x3b1bb8,_0x3da8c1,_0x5d3219)[_0xa757('0x42')](function(_0x32e0b9){_0x3c3ff1(_0x32e0b9);})[_0xa757('0x46')](function(_0x22a185){_0x3672a7(_0x22a185);});});}function generateNonce(){return crypto[_0xa757('0x83')](0x10)['toString'](_0xa757('0x84'));}function generateIssuedAt(){return Math[_0xa757('0x85')](Date['now']()/0x3e8)[_0xa757('0x86')]();}function createJwt(_0x409ee9){var _0x198a11={'payload':{'iat':_0x409ee9[_0xa757('0x6c')],'nonce':_0x409ee9[_0xa757('0x52')]},'options':{'algorithm':_0xa757('0x87'),'subject':_0x409ee9['id']['toString'](),'issuer':hardwareConf[_0xa757('0x4c')](),'audience':hardwareConf['getUuid']()}};return signJwt(_0x198a11)[_0xa757('0x42')](function(_0x3250d0){return{'iat':_0x409ee9[_0xa757('0x6c')],'nonce':_0x409ee9[_0xa757('0x52')],'token':_0x3250d0};});}
\ No newline at end of file