feat(baileys): add passkey companion-linking ceremony - #2628
feat(baileys): add passkey companion-linking ceremony#2628mateus2001ferreira wants to merge 1 commit into
Conversation
Add opt-in support for WhatsApp's passkey (Shortcake/CRSC) companion-linking flow, implemented on top of Baileys' public API without forking it. A browser helper extension performs the WebAuthn assertion; the ceremony is driven via public /passkey-ceremony endpoints and exposed through connectionState. Gated behind PASSKEY_CEREMONY_ENABLED (default off) since a malformed IQ can get the number banned. Requires PASSKEY_PUBLIC_URL reachable by the browser.
There was a problem hiding this comment.
Sorry @mateus2001ferreira, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
✅ Passkey linking working with 1Password after additional fixesHi! I would like to share the results of my tests with the new Passkey Companion Linking implementation from this PR. After some debugging and modifications, I was able to successfully connect my existing Evolution API instance to WhatsApp using a passkey stored in 1Password.
My original problemMy Evolution API installation was working normally before WhatsApp started requiring passkey authentication during companion-device linking. The QR Code was generated normally. After scanning it with WhatsApp, however, WhatsApp requested passkey/device authentication and the Evolution API instance never completed the connection. I was originally using:
Because my project already depends on the original Evolution API database structure and integrations, migrating everything to Evolution GO would require significant changes. Testing Evolution GO firstI installed Evolution GO to understand how the new authentication flow was supposed to work. Evolution GO detected that WhatsApp required a passkey and generated a URL similar to:
It also instructed me to install the official Evolution Passkey Helper Chrome extension. However, I had problems completing the authentication with my setup and 1Password. This gave us an important reference for how the passkey flow was intended to work. Creating an alternative Passkey HelperUsing the Evolution GO Passkey Helper as a reference, I asked ChatGPT to analyze how it worked and create an alternative helper specifically for my Evolution API installation. The architecture that finally worked was:
This was important because it allowed the WebAuthn request to be correctly detected by the 1Password Chrome extension. After this change, 1Password opened normally and allowed me to authenticate using my existing WhatsApp passkey. Evolution Manager does not display the Passkey URLThere is also an important UI problem. When I perform the pairing through the Evolution Manager web interface, the QR Code appears normally. After scanning the QR Code and WhatsApp requesting the passkey, the Evolution Manager does not show the URL required to continue the authentication. Nothing appears in the web interface telling the user to open the Passkey Helper. The URL only appeared in the Evolution API server logs:
Because of this, I had to:
It would be very useful if Evolution Manager automatically displayed a button/link using For a normal user who does not have access to the server terminal, the current flow is very difficult to discover. First problem after successful 1Password authenticationAfter getting WebAuthn/1Password authentication working, Evolution API successfully progressed further. The helper displayed the confirmation code. However, when confirming it, Evolution API returned:
At the same time, I noticed that Evolution API continued generating/rotating QR Codes even though the passkey ceremony was already active. For example:
The passkey ceremony had already started, but QR processing continued.
|
Description
Adds opt-in support for WhatsApp's passkey (Shortcake/CRSC) companion-linking flow, which some numbers now require when linking a device. Implemented on top of Baileys' public API — no fork or patch of Baileys needed.
How it works:
PasskeyCeremonyhandles the server'spasskey_prologue_request/crsc_continuationnotifications and replies with the matching IQs (passkey_prologue,companion_nonce,encrypted_pairing_request).GET/POST /passkey-ceremony/:token[/response|/confirm]let the extension read the challenge and submit the assertion; the current stage and open URL are exposed viaconnectionState.Gated behind
PASSKEY_CEREMONY_ENABLED=true(default off), since a malformed IQ can get a number banned. Also requires:PASSKEY_PUBLIC_URL— API base reachable by the browser running WhatsApp WebCORS_ORIGINallowing*orhttps://web.whatsapp.comCrypto is an independent reimplementation of whatsmeow's
pair-passkey.go(MPL-2.0); no code copied. No dependency changes (works on the current Baileys 7.0.0-rc.9).Type of Change
Checklist
Additional Notes
The feature ships a small browser helper extension (
public/passkey-helper.zip) that performs the WebAuthn assertion. Happy to discuss whether shipping it in-repo, as source, or as a separate distribution is preferable. Also glad to add the two env vars to.env.exampleif the approach is accepted.