From bbe58b7fa3e7256d5177ecf31fc0666c3d379c70 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Wed, 18 Aug 2021 11:44:07 +0530 Subject: [PATCH] minor bug fix --- src/Connection/auth.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Connection/auth.ts b/src/Connection/auth.ts index d6983ed..547340b 100644 --- a/src/Connection/auth.ts +++ b/src/Connection/auth.ts @@ -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')