feat: add cancelPairingCode() and requestPairingCode() on QR clients (#22449)
* feat: add cancelPairingCode() and allow requestPairingCode() - requestPairingCode() now exposes onCodeReceivedEvent if needed, so it works on clients initialized in QR mode - Add cancelPairingCode() method to stop pairing and return to QR - Update TypeScript definitions * fix(auth): dynamic ADV key in getQR + structural cancelPairingCode the getQR closure captured advSecretKey once during initialize(), but requestpairingcode/cancelPairingCode changes the key in IndexedDB. the stale closure key caused QR scans to fail with HMAC validation error. fix: read key dynamically via WAWebUserPrefsMultiDevice.getADVSecretKey() (synchronous in-memory cache) on every getQR call, matching how WhatsApp web's internal QR component works. cancelpairingcode now mirrors WhatsApp Web's resetLinkDeviceState: refreshqr() restarts WebSocket for fresh refs, then initializeqrlinking() generates a new key. QR emission happens automatically via the existing change:ref listener. --------- Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
This commit is contained in:
parent
6de0b0dd2b
commit
3e810b6913
1 changed files with 30 additions and 4 deletions
3
index.d.ts
vendored
3
index.d.ts
vendored
|
|
@ -197,6 +197,9 @@ declare namespace WAWebJS {
|
|||
intervalMs?: number,
|
||||
): Promise<string>;
|
||||
|
||||
/** Cancels an active pairing code session and returns to QR code mode */
|
||||
cancelPairingCode(): Promise<void>
|
||||
|
||||
/** Force reset of connection state for the client */
|
||||
resetState(): Promise<void>;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue