fix: resolve pairing code rejection due to timing and platform validation issues#2409
fix: resolve pairing code rejection due to timing and platform validation issues#2409mtAlves wants to merge 1 commit intoWhiskeySockets:masterfrom
Conversation
…tion issues requestPairingCode was sending the link_code_companion_reg IQ before the server signaled readiness via pair-device, and setting creds.me before server confirmation — causing 428, 401, and 400 responses. Changes in src/Socket/socket.ts: - Extract sendPairingIQ from requestPairingCode to separate IQ dispatch from readiness gate logic - Add pairingReady gate: queue requestPairingCode calls that arrive before pair-device is received, flushing them when the event fires - Add pairingInProgress guard to reject concurrent pairing requests - Defer creds.me assignment to after the companion_hello query succeeds, preventing reconnects from taking the login path instead of registration - Reject pending pairing promises and reset state on socket close/error Changes in src/Utils/browser-utils.ts: - Fix getPlatformId return value (now consistently returns string) - Add getPlatformDisplayName to resolve the display label for a platform type The pairing IQ now validates companion_platform_id and companion_platform_display against server-accepted values: only browser-type platform IDs (CHROME=1..EDGE=6) are accepted; DESKTOP (7) is rejected. Custom brand names in browser[0] are preserved through DeviceProps.os (shown in WhatsApp's Linked Devices list) but are normalised to a canonical OS name in the pairing IQ itself.
|
Thanks for opening this pull request and contributing to the project! The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch. In the meantime, anyone in the community is encouraged to test this pull request and provide feedback. ✅ How to confirm it worksIf you’ve tested this PR, please comment below with: This helps us speed up the review and merge process. 📦 To test this PR locally:If you encounter any issues or have feedback, feel free to comment as well. |
|
Uma duvida essas alteracoes vai afetar o tipo plataforma exemplo MACO, ou DESKTOP como telatado acima na descrição. Uso o valor MACO = 21 usava desktop que era o valor 14 . segundo relatos em outras prs o valor 14 nao e aceito mas pela meta. O IQ de emparelhamento agora valida companion_platform_id e companion_platform_display em relação aos valores aceitos pelo servidor: somente IDs de plataforma do tipo navegador (CHROME=1..EDGE=6) são aceitos; DESKTOP (7) é rejeitado. Nomes de marca personalizados em browser[0] são preservados por meio de DeviceProps.os (exibidos na lista de Dispositivos Vinculados do WhatsApp), mas são normalizados para um nome de SO canônico no próprio IQ de emparelhamento. |
|
This is important, since connecting with pairing code does not work atm. |
|
This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days |
requestPairingCode was sending the link_code_companion_reg IQ before the server signaled readiness via pair-device, and setting creds.me before server confirmation — causing 428, 401, and 400 responses.
Changes:
The pairing IQ now validates companion_platform_id and companion_platform_display against server-accepted values: only browser-type platform IDs (CHROME=1..EDGE=6) are accepted; DESKTOP (7) is rejected. Custom brand names in browser[0] are preserved through DeviceProps.os (shown in WhatsApp's Linked Devices list) but are normalised to a canonical OS name in the pairing IQ itself.