Skip to content

Commit

Permalink
fix: Fixed WPP.conn.getAuthCode function for WhatsApp >= 2.2301.5
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 23, 2023
1 parent 8bb8bde commit 357b62b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/conn/functions/getAuthCode.ts
Expand Up @@ -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<AuthCode>}[return description]
*/
export async function getAuthCode(): Promise<AuthCode | null> {
Expand All @@ -39,7 +45,7 @@ export async function getAuthCode(): Promise<AuthCode | null> {
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(',');

Expand Down
2 changes: 1 addition & 1 deletion src/whatsapp/multidevice/adv.ts
Expand Up @@ -22,7 +22,7 @@ import { exportModule } from '../exportModule';
*/
export declare namespace adv {
function generateADVSecretKey(): string;
function getADVSecretKey(): string;
function getADVSecretKey(): string | Promise<string>;
function setADVSignedIdentity(e: any): string;
function getADVEncodedIdentity(): any;
function verifyDeviceIdentityAccountSignature(): any;
Expand Down

0 comments on commit 357b62b

Please sign in to comment.