From 357b62bb9a06a868cc416e203b655088c469a6c4 Mon Sep 17 00:00:00 2001 From: Edgard Date: Mon, 23 Jan 2023 14:35:18 -0300 Subject: [PATCH] fix: Fixed WPP.conn.getAuthCode function for WhatsApp >= 2.2301.5 --- src/conn/functions/getAuthCode.ts | 8 +++++++- src/whatsapp/multidevice/adv.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/conn/functions/getAuthCode.ts b/src/conn/functions/getAuthCode.ts index fc394495e3..938507d088 100644 --- a/src/conn/functions/getAuthCode.ts +++ b/src/conn/functions/getAuthCode.ts @@ -22,6 +22,12 @@ import { isAuthenticated, isMultiDevice, isRegistered } from '.'; /** * Return the current auth code * + * @example + * ```javascript + * const authCode = await WPP.conn.getAuthCode(); + * console.log(authCode.fullCode); // Output: a long string to generate a QRCode + * ``` + * * @return {Promise}[return description] */ export async function getAuthCode(): Promise { @@ -39,7 +45,7 @@ export async function getAuthCode(): Promise { const identityKeyPair = Base64.encodeB64( registrationInfo.identityKeyPair.pubKey ); - const secretKey = adv.getADVSecretKey(); + const secretKey = await Promise.resolve(adv.getADVSecretKey()); const fullCode = [ref, staticKeyPair, identityKeyPair, secretKey].join(','); diff --git a/src/whatsapp/multidevice/adv.ts b/src/whatsapp/multidevice/adv.ts index 21bb573f2b..05b46d60aa 100644 --- a/src/whatsapp/multidevice/adv.ts +++ b/src/whatsapp/multidevice/adv.ts @@ -22,7 +22,7 @@ import { exportModule } from '../exportModule'; */ export declare namespace adv { function generateADVSecretKey(): string; - function getADVSecretKey(): string; + function getADVSecretKey(): string | Promise; function setADVSignedIdentity(e: any): string; function getADVEncodedIdentity(): any; function verifyDeviceIdentityAccountSignature(): any;