minor bug fix

This commit is contained in:
Adhiraj Singh
2021-08-18 11:44:07 +05:30
parent 4638f1261d
commit bbe58b7fa3

View File

@@ -110,6 +110,11 @@ const makeAuthSocket = (config: SocketConfig) => {
)
}
const updateEncKeys = () => {
// update the keys so we can decrypt traffic
socket.updateKeys({ encKey: authInfo!.encKey, macKey: authInfo!.macKey })
}
const generateKeysForAuth = async(ref: string, ttl?: number) => {
curveKeys = Curve.generateKeyPair(randomBytes(32))
const publicKey = Buffer.from(curveKeys.public).toString('base64')
@@ -168,6 +173,7 @@ const makeAuthSocket = (config: SocketConfig) => {
})();
let loginTag: string
if(canDoLogin) {
updateEncKeys()
// if we have the info to restore a closed session
const json = [
'admin',
@@ -223,8 +229,7 @@ const makeAuthSocket = (config: SocketConfig) => {
const isNewLogin = user.jid !== state.user?.jid
authInfo = auth
// update the keys so we can decrypt traffic
socket.updateKeys({ encKey: auth.encKey, macKey: auth.macKey })
updateEncKeys()
logger.info({ user }, 'logged in')