whalibmob 5.40.34 → 5.40.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ code, and bring the account into being. Both transports, one API.
20
20
  ### Start here
21
21
 
22
22
  [![Register a number](https://img.shields.io/badge/Register_a_number-SMS,_voice_or_email-25D366?style=for-the-badge)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md#register-a-new-number)
23
- [![Link an account](https://img.shields.io/badge/Link_an_account-QR_or_pairing_code-128C7E?style=for-the-badge)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-to-an-existing-account-pairing-code-or-qr)
23
+ [![Link an account](https://img.shields.io/badge/Link_an_account-QR,_pairing_code_or_passkey-128C7E?style=for-the-badge)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-to-an-existing-account-pairing-code-or-qr)
24
24
  [![Use the CLI](https://img.shields.io/badge/Use_the_CLI-no_code_needed-075E54?style=for-the-badge)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-getting-started.md#cli--getting-started)
25
25
 
26
26
  [![Library API](https://img.shields.io/badge/Library_API-Node.js-34B7F1?style=for-the-badge)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md#library-api)
@@ -76,7 +76,7 @@ code, and bring the account into being. Both transports, one API.
76
76
  > This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or affiliates. "WhatsApp" and related names are registered trademarks of their respective owners. Use at your own discretion.
77
77
 
78
78
  - **It registers numbers.** Give it a phone number that has never been on WhatsApp, request the code over SMS, voice call, flash call or an old WhatsApp account, confirm it, and the account exists — as an **Android or iOS device**, on the Mobile API. No phone, no scanning, no existing account to borrow. See [Register a New Number](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md#register-a-new-number).
79
- - **It also speaks WhatsApp Web**, over a WebSocket. When a number cannot receive an SMS, or is already live on a phone, whalibmob links itself to that account by **QR code** or an **8-character pairing code** and runs as one of its linked devices — with the full message history and the account's address book. See [Linking to an Existing Account](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-to-an-existing-account-pairing-code-or-qr).
79
+ - **It also speaks WhatsApp Web**, over a WebSocket. When a number cannot receive an SMS, or is already live on a phone, whalibmob links itself to that account by **QR code**, an **8-character pairing code** or, where the account has one, its **passkey**, and runs as one of its linked devices — with the full message history and the account's address book. See [Linking to an Existing Account](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-to-an-existing-account-pairing-code-or-qr).
80
80
  - **The API is identical in both modes.** Everything below — sending, media, groups, events — reads the same whichever way the session was created.
81
81
  - No browser, no Selenium, no external runtime. It talks to WhatsApp directly over a **TCP socket** with the **Noise Protocol** handshake.
82
82
  - Signal Protocol encryption is **fully inlined** in pure JavaScript — no native binaries, no node-gyp, runs anywhere Node.js runs.
@@ -109,8 +109,8 @@ const os = require('os')
109
109
  const path = require('path')
110
110
  const readline = require('readline/promises')
111
111
 
112
- const PHONE = '447533640016' // your number: country code + number, no '+'
113
- const TO = 'number for message' // who to message
112
+ const PHONE = '40712345678' // your number: country code + number, no '+'
113
+ const TO = '40798765432' // who to message
114
114
  const BASE_DIR = path.join(os.homedir(), '.waSession')
115
115
 
116
116
  async function register(phone) {
@@ -241,6 +241,7 @@ Every command of the interactive shell: messages, presence, profile, chats, grou
241
241
  ### [Linking, Companion Mode & Approving Devices](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md)
242
242
 
243
243
  - [Linking to an Existing Account (Pairing Code or QR)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-to-an-existing-account-pairing-code-or-qr)
244
+ - [Linking with a Passkey](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-with-a-passkey)
244
245
  - [Companion Mode — Node.js API](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#companion-mode--nodejs-api)
245
246
  - [Approving a Companion Device (Primary Role)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#approving-a-companion-device-primary-role)
246
247
 
package/cli.js CHANGED
@@ -1330,6 +1330,13 @@ async function doConnectWebQr(phone) {
1330
1330
  out(' the QR set expired — run /qrcode ' + phone + ' again for a fresh one');
1331
1331
  });
1332
1332
 
1333
+ // WhatsApp can offer a passkey link to an account that has a passkey. A
1334
+ // terminal has no authenticator to answer with, so say what is happening and
1335
+ // that the QR, drawn again just above, still works.
1336
+ client.on('passkey_request', () => {
1337
+ out(' this account offered a passkey link, which the shell cannot answer; scan the QR above instead');
1338
+ });
1339
+
1333
1340
  client.once('paired', (pp) => {
1334
1341
  out('');
1335
1342
  out(' scanned — linked as ' + pp.jid + (pp.lid ? ' (' + pp.lid + ')' : ''));
package/docs/linking.md CHANGED
@@ -8,12 +8,13 @@
8
8
 
9
9
  Registering a number over SMS makes whalibmob that number's **own device**. Sometimes that is not what you want — the number is already in use on a phone, or the verification SMS never arrives. For those cases whalibmob can instead connect over a **WebSocket** and link itself to an account that already exists, exactly the way the WhatsApp Web and desktop clients do.
10
10
 
11
- There are two ways to link, and they reach the same place:
11
+ There are three ways to link, and they reach the same place:
12
12
 
13
13
  - **Pairing code** — whalibmob gives you an 8-character code, the owner types it into their phone.
14
14
  - **QR code** — whalibmob draws a QR, the owner scans it with the phone's camera.
15
+ - **Passkey** — the account's passkey signs a challenge, and the owner confirms a short code. Only offered by WhatsApp for accounts that have a passkey; see [Linking with a Passkey](#linking-with-a-passkey).
15
16
 
16
- Both link the number as a companion device, both leave the whole library working the same afterwards — same client, same methods, same events. The only difference is what the owner does: type a code, or scan a square.
17
+ All of them link the number as a companion device, and all leave the whole library working the same afterwards — same client, same methods, same events. The only difference is what the owner does: type a code, scan a square, or approve with a passkey.
17
18
 
18
19
  > [!IMPORTANT]
19
20
  > The two modes are independent. SMS registration is unchanged and still the default; nothing about it is affected by linking. A single number can even have both a registered session and a linked session — they are stored in separate files and never share state.
@@ -43,7 +44,8 @@ client.on('connected', () => {
43
44
  // open the WebSocket connection as a companion
44
45
  await client.connectWeb('919634847671', { syncFullHistory: true })
45
46
 
46
- // ask for the code — returns immediately, the link completes later
47
+ // ask for the code — resolves once the server has accepted the request;
48
+ // the link completes later, when the owner types it in
47
49
  const code = await client.requestPairingCode('919634847671')
48
50
  console.log('enter this on the phone:', code) // e.g. "K7M2QX4B"
49
51
  ```
@@ -52,6 +54,14 @@ On the phone that owns the number:
52
54
 
53
55
  **WhatsApp → Settings → Linked Devices → Link a device → Link with phone number instead**, then type the code.
54
56
 
57
+ `requestPairingCode()` waits for the server's answer before it hands the code out, so a code you are given is one the server is holding. If the server refuses the request, the call throws instead of returning a code that could never work:
58
+
59
+ | `err.code` | Meaning |
60
+ |---|---|
61
+ | `PAIRING_CODE_REFUSED` | The server answered with an error. `err.serverCode` is its code: `400` means the request was not accepted (usually the number, or a `browser` name it does not recognise), `429` that too many codes were asked for and you should wait. |
62
+ | `PAIRING_CODE_NO_RESPONSE` | No answer within 15 seconds, or the connection closed first. |
63
+ | `PAIRING_CODE_NO_REF` | The answer did not carry the reference a code is tied to. |
64
+
55
65
  ### Linking by QR Code
56
66
 
57
67
  The QR path is the scan-to-connect alternative. You **do not** request a pairing code — you just connect and listen for the `qr` event. Because no code is asked for, the server volunteers a QR instead, and whalibmob turns it into a ready-to-render string:
@@ -84,13 +94,52 @@ On the phone that owns the number:
84
94
 
85
95
  **WhatsApp → Settings → Linked Devices → Link a device**, then point the camera at the QR.
86
96
 
87
- The `qr` string is what a WhatsApp camera reads: `ref,noise,identity,advSecret,platformId` — a one-time ref plus this client's public keys, comma-joined, the same fields WhatsApp Web itself renders. It rotates on its own (about a minute for the first, then shorter) until the account is scanned or the refs run out. `qrcode-terminal` is optional — without it you get the raw string on `qr` and can render it however you like (a PNG, a web page, an image in a chat). To emit the QR as a `wa.me/settings/linked_devices#…` link instead of the bare fields, pass `{ qrWrapUrl: true }` to `connectWeb`.
97
+ The `qr` string is what a WhatsApp camera reads: `ref,noise,identity,advSecret,platformId` — a one-time ref plus this client's public keys, comma-joined, the same fields WhatsApp Web itself renders. The server can ask for the secret in it to be replaced while a QR is on screen; when it does, `qr` fires again for the same ref with the new string and the time it has left, so always draw the latest one. It rotates on its own (about a minute for the first, then shorter) until the account is scanned or the refs run out. `qrcode-terminal` is optional — without it you get the raw string on `qr` and can render it however you like (a PNG, a web page, an image in a chat). To emit the QR as a `wa.me/settings/linked_devices#…` link instead of the bare fields, pass `{ qrWrapUrl: true }` to `connectWeb`.
88
98
 
89
99
  Everything after the scan is identical to the pairing-code path: `paired`, a stream restart, then `connected`.
90
100
 
91
- ### After the link — same for both paths
101
+ ### Linking with a Passkey
102
+
103
+ An account that has a passkey can be linked with it. This is not something you ask for: WhatsApp offers it, to an unlinked companion, by sending a WebAuthn challenge. whalibmob surfaces that as `passkey_request`, and from there you supply the one thing it cannot do itself — getting an authenticator to sign.
104
+
105
+ ```js
106
+ client.on('passkey_request', async ({ publicKey }) => {
107
+ // publicKey is a WebAuthn request in its JSON form: challenge, rpId,
108
+ // allowCredentials..., binary members as base64url. Hand it to whatever
109
+ // holds the account's passkey. In a browser that is:
110
+ //
111
+ // const options = PublicKeyCredential.parseRequestOptionsFromJSON(publicKey)
112
+ // const credential = await navigator.credentials.get({ publicKey: options })
113
+ // const assertion = credential.toJSON()
114
+ const assertion = await askMyAuthenticator(publicKey)
115
+ await client.sendPasskeyResponse(assertion)
116
+ })
117
+
118
+ client.on('passkey_confirmation', async ({ code, skipHandoffUx, autoConfirmed }) => {
119
+ if (autoConfirmed) return // nothing to compare, already sent
120
+ console.log('check that the phone shows', code) // e.g. "K7M2-QX4B"
121
+ if (await ownerSaysItMatches()) await client.sendPasskeyConfirmation()
122
+ })
123
+
124
+ client.on('passkey_error', ({ err, continuation }) => console.error('passkey:', err.message))
125
+ client.on('paired', (p) => console.log('linked as', p.jid))
126
+
127
+ await client.connectWeb('919634847671')
128
+ ```
129
+
130
+ `sendPasskeyResponse()` takes a WebAuthn assertion: `{ id, rawId, type, response: { clientDataJSON, authenticatorData, signature, userHandle } }`. The binary members may be bytes (`Buffer`, `Uint8Array`, `ArrayBuffer`) or base64url or base64 text, so the object `credential.toJSON()` returns in a browser can be passed as it is.
131
+
132
+ The code in `passkey_confirmation` is the safeguard. Each side commits to a random value before it sees the other's, and the code is derived from both, so the same eight characters on both screens mean the two devices talked to each other and not to something in between. When the phone had this client's QR in front of it moments before, that comparison is unnecessary: `skipHandoffUx` is `true`, whalibmob sends the confirmation itself and `autoConfirmed` says so. Pass `{ passkeyAutoConfirm: false }` to `connectWeb` to always confirm yourself.
133
+
134
+ A passkey offer does not take the QR away. The secret inside it is replaced when the offer arrives, so `qr` fires again with a fresh string just before `passkey_request`, and scanning that one still links. An offer you do not answer can simply be ignored.
135
+
136
+ The passkey belongs to the account and stays with whoever holds it: whalibmob never sees it, only the signed answer you pass in. There is no authenticator in the library, and none in the CLI.
92
137
 
93
- A few seconds after the code is accepted (or the QR is scanned) you will see `paired`, the server restarts the stream, and `connected` fires on the new connection. From that point on everything else in this document applies unchanged:
138
+ A step that fails raises `passkey_error` (for the server's pushes) or throws from the call you made, with an `err.code`: `PASSKEY_REFUSED` (the server said no; `err.serverCode` and `err.serverText` say why), `PASSKEY_NO_RESPONSE`, `PASSKEY_NO_REF`, `PASSKEY_NOT_PENDING`, `PASSKEY_NOT_READY` (confirmation asked before `passkey_confirmation`), `PASSKEY_BAD_CONTINUATION`, `PASSKEY_ALREADY_LINKED`, `PASSKEY_NOT_CONNECTED`, `PASSKEY_WRONG_MODE`.
139
+
140
+ ### After the link — same for every path
141
+
142
+ A few seconds after the code is accepted (the QR is scanned, or the passkey link is confirmed) you will see `paired`, the server restarts the stream, and `connected` fires on the new connection. From that point on everything else in this document applies unchanged:
94
143
 
95
144
  ```js
96
145
  await client.sendText('919876543210', 'sent from a linked device')
@@ -123,10 +172,13 @@ const code = await client.requestPairingCode('919634847671', 'MYCODE12')
123
172
  ```js
124
173
  await client.connectWeb(phone, {
125
174
  syncFullHistory: true, // ask the phone for full history (default true)
126
- browser: ['Ubuntu', 'Chrome', '120.0.0.0'] // what the owner sees in Linked Devices
175
+ browser: ['Ubuntu', 'Chrome', '120.0.0.0'], // what the owner sees in Linked Devices
176
+ prePair: ({ jid, platform }) => jid.startsWith('919634847671') // last word on a link
127
177
  })
128
178
  ```
129
179
 
180
+ `prePair` is called once the phone has authorised this device and its proof has been verified, just before the link is confirmed. It receives `{ jid, lid, platform, businessName }`; return `false` (or a promise of it) and the link is refused, the server is told, and nothing is saved. Use it when the number that ends up linked matters, since the owner of *any* account can scan a QR you show.
181
+
130
182
  `browser` is `[os, client, version]`. The second element decides the device icon shown on the phone — `Chrome`, `Firefox`, `Safari`, `Edge`, `Opera`, `Desktop` are all recognised.
131
183
 
132
184
  ### Events Specific to Linking
@@ -137,6 +189,10 @@ await client.connectWeb(phone, {
137
189
  | `qr` | a QR is ready to render — `{ qr, ref, ttlMs, remaining }`; fires again on each rotation |
138
190
  | `qr_timeout` | the QR refs ran out — reconnect for a fresh set |
139
191
  | `paired` | the owner accepted the code or scanned the QR — `{ jid, lid, deviceIndex, platform }` |
192
+ | `pair_error` | the phone authorised a link and it was turned down here — `{ jid, lid, platform, err }`; `error` fires too |
193
+ | `passkey_request` | the account can be linked with a passkey — `{ publicKey }` |
194
+ | `passkey_confirmation` | the code to compare with the phone — `{ code, skipHandoffUx, autoConfirmed }` |
195
+ | `passkey_error` | a passkey step failed — `{ err, continuation }` |
140
196
  | `restart_required` | the server is restarting the stream after pairing (normal; the reconnect is automatic) |
141
197
  | `pair_device` | the raw QR reference strings, before they are turned into `qr` — `{ refs }` |
142
198
  | `history_sync` | a chunk of history arrived from the phone |
@@ -210,7 +266,11 @@ whalibmob attaches it automatically whenever a `pkmsg` is in the stanza, in dire
210
266
 
211
267
  The pairing code is a password, not an identifier. It is never sent to the server in the clear. Both sides run it through PBKDF2-SHA256 (131,072 iterations) to derive a key that wraps the ephemeral public keys they exchange, then combine two Diffie-Hellman results into `adv_secret` — the key every later proof of account membership is authenticated under.
212
268
 
213
- whalibmob verifies three things before accepting a link, and refuses it outright if any fails: the HMAC over the signed device identity, the account signature over its own identity key, and the device slot it was issued. A wrong code cannot produce a working link, and a tampered response cannot either.
269
+ whalibmob verifies three things before accepting a link, and refuses it outright if any fails: the HMAC over the signed device identity, the account signature over its own identity key, and the device slot it was issued. A wrong code cannot produce a working link, and a tampered response cannot either. A refusal is also sent to the server, with the reason (`hmac-mismatch`, `signature-mismatch` or `internal-error`), so the phone stops waiting rather than timing out.
270
+
271
+ The notification that completes a code has to name the reference the server issued for that code. One that names another is ignored: it belongs to an earlier request, and acting on it would replace the secret the pending code is tied to.
272
+
273
+ Once a link is accepted, the key that signed it — the phone's own identity key — is recorded as the identity of the account's device 0. The first encrypted session the phone opens with this device is then checked against the key that authorised the link.
214
274
 
215
275
  ## Companion Mode — Node.js API
216
276
 
@@ -290,7 +350,9 @@ Run it once, type the code into the phone, and it is linked. Run it again and it
290
350
  | Method | Description |
291
351
  |---|---|
292
352
  | `client.connectWeb(phone, opts?)` | Open the companion connection. Resolves as soon as the encrypted channel is up when unlinked, or after `<success>` when already linked. |
293
- | `client.requestPairingCode(phone?, customCode?)` | Ask for an 8-character code. Returns it immediately; the link completes later. Throws if the session is already linked. |
353
+ | `client.requestPairingCode(phone?, customCode?)` | Ask for an 8-character code. Resolves once the server has accepted the request; the link completes later. Throws if the server refuses it, or if the session is already linked. |
354
+ | `client.sendPasskeyResponse(assertion)` | Answer a `passkey_request` with the assertion an authenticator produced. Resolves once the server has taken it. |
355
+ | `client.sendPasskeyConfirmation()` | Finish a passkey link once the owner has confirmed the code. Not needed when `passkey_confirmation` says `autoConfirmed`. |
294
356
  | `client.disconnect()` | Close the connection. The link survives — reconnect with `connectWeb()`. |
295
357
  | `client.logout()` | Unlink this device from the account, the way the Linked Devices screen does, then disconnect. The link does **not** survive — the next `connectWeb()` pairs afresh. Nothing on disk is deleted; remove the session directory yourself if you want the keys gone. |
296
358
 
@@ -302,6 +364,10 @@ Run it once, type the code into the phone, and it is linked. Run it again and it
302
364
  | `browser` | `['Ubuntu', 'Chrome', '120.0.0.0']` | `[os, client, version]`. The second element picks the icon shown under Linked Devices: `Chrome`, `Firefox`, `Safari`, `Edge`, `Opera`, `Desktop`. |
303
365
  | `version` | fetched live | Web client revision to announce, e.g. `[2, 3000, 1035194821]`. Set it to pin one. |
304
366
  | `fetchVersion` | `true` | Set `false` to skip the live lookup and use the pinned fallback. |
367
+ | `qrWrapUrl` | `false` | Emit the QR as a `wa.me/settings/linked_devices#…` link instead of the bare fields. |
368
+ | `prePair` | none | `({ jid, lid, platform, businessName }) => boolean`. Called before a link is confirmed; `false` refuses it. |
369
+ | `passkeyAutoConfirm` | `true` | Send the passkey confirmation without asking when the phone needs no code comparison. |
370
+ | `lidDbMigrated` | `true` | Announce at login that chats are stored by LID, as current WhatsApp clients do. Set `false` if your own storage is still keyed by phone number. |
305
371
 
306
372
  #### The Announced Version
307
373
 
@@ -337,6 +403,10 @@ Every event from the SMS primary API fires here too — `message`, `receipt`, `p
337
403
  |---|---|---|
338
404
  | `pairing_code` | `{ code, phoneNumber }` | a code was requested |
339
405
  | `paired` | `{ jid, lid, deviceIndex, platform }` | the owner accepted the code |
406
+ | `pair_error` | `{ jid, lid, platform, err }` | the phone authorised a link and it was turned down here: a proof that did not verify, or `prePair` returning `false`. `error` fires too |
407
+ | `passkey_request` | `{ publicKey }` | the account can be linked with a passkey; `publicKey` is the WebAuthn request, as JSON |
408
+ | `passkey_confirmation` | `{ code, skipHandoffUx, autoConfirmed }` | the passkey exchange produced the code to compare with the phone |
409
+ | `passkey_error` | `{ err, continuation }` | a passkey step failed. `continuation` is `false` for the request itself, `true` for the step after your response |
340
410
  | `restart_required` | `{ reason }` | the server is restarting the stream after pairing — the reconnect is automatic |
341
411
  | `pair_device` | `{ refs }` | the QR path produced reference strings |
342
412
  | `history_sync` | `{ syncTypeName, chats, contacts, pushNames, merged }` | a chunk of history arrived |
package/index.d.ts CHANGED
@@ -184,6 +184,58 @@ export interface ConnectWebOptions {
184
184
  fetchVersion?: boolean;
185
185
  /** Emit the QR as a `wa.me/settings/linked_devices#…` link instead of the bare fields. */
186
186
  qrWrapUrl?: boolean;
187
+ /**
188
+ * Called once the phone has authorised this device and before the link is
189
+ * confirmed. Return `false` to turn the link down; `null` removes a callback
190
+ * set earlier.
191
+ */
192
+ prePair?: ((info: PrePairInfo) => boolean | void | Promise<boolean | void>) | null;
193
+ /**
194
+ * Passkey linking: send the confirmation without waiting for the caller when
195
+ * the phone needs no code comparison (`skipHandoffUx`). Default `true`.
196
+ */
197
+ passkeyAutoConfirm?: boolean;
198
+ /**
199
+ * Announce at login that chats are stored by LID. Default `true`; set `false`
200
+ * if your own storage is still keyed by phone number.
201
+ */
202
+ lidDbMigrated?: boolean;
203
+ }
204
+
205
+ /** Who a pair-success would link this device to. */
206
+ export interface PrePairInfo {
207
+ jid: Jid;
208
+ lid: Jid | null;
209
+ /** What the primary runs, e.g. `android`. */
210
+ platform: string | null;
211
+ businessName: string | null;
212
+ }
213
+
214
+ /** WebAuthn request options in their JSON form; binary members are base64url. */
215
+ export interface PasskeyRequestOptions {
216
+ challenge: string;
217
+ timeout?: number;
218
+ rpId?: string;
219
+ allowCredentials?: Array<{ id: string; type: string; transports?: string[] }>;
220
+ userVerification?: string;
221
+ extensions?: Record<string, unknown>;
222
+ [key: string]: unknown;
223
+ }
224
+
225
+ /** Bytes, or the same as base64url or base64 text. */
226
+ export type PasskeyBytes = string | Buffer | Uint8Array | ArrayBuffer;
227
+
228
+ /** A WebAuthn assertion — what `credential.toJSON()` returns in a browser. */
229
+ export interface PasskeyAssertion {
230
+ id?: string;
231
+ rawId: PasskeyBytes;
232
+ type?: string;
233
+ response: {
234
+ clientDataJSON: PasskeyBytes;
235
+ authenticatorData: PasskeyBytes;
236
+ signature: PasskeyBytes;
237
+ userHandle?: PasskeyBytes | null;
238
+ };
187
239
  }
188
240
 
189
241
  export interface DisconnectOptions {
@@ -965,6 +1017,17 @@ export interface WhalibmobEvents {
965
1017
  qr_timeout: () => void;
966
1018
  pair_device: (p: { refs: string[] }) => void;
967
1019
  paired: (p: { jid: Jid; lid: Jid; deviceIndex: number; platform: string }) => void;
1020
+ /** Companion mode: a pair-success was turned down, here or by `prePair`. `error` fires too. */
1021
+ pair_error: (p: { jid: Jid | null; lid: Jid | null; platform: string | null; err: Error }) => void;
1022
+ /** Companion mode: the account can be linked with a passkey. Answer with `sendPasskeyResponse`. */
1023
+ passkey_request: (p: { publicKey: PasskeyRequestOptions }) => void;
1024
+ /**
1025
+ * Companion mode: the code to compare with the phone. Unless `autoConfirmed`,
1026
+ * call `sendPasskeyConfirmation` once the owner says it matches.
1027
+ */
1028
+ passkey_confirmation: (p: { code: string; skipHandoffUx: boolean; autoConfirmed: boolean }) => void;
1029
+ /** Companion mode: a passkey step failed. `continuation` is false for the request itself. */
1030
+ passkey_error: (p: { err: Error & { code?: string }; continuation: boolean }) => void;
968
1031
  restart_required: (r: { reason?: string }) => void;
969
1032
  web_ready_for_pairing: () => void;
970
1033
 
@@ -1209,8 +1272,16 @@ export declare class WhalibmobClient extends EventEmitter {
1209
1272
  connectWeb(phoneNumber: string, opts?: ConnectWebOptions): Promise<this>;
1210
1273
  /** Alias of `connectWeb`. */
1211
1274
  initWeb(phoneNumber: string, opts?: ConnectWebOptions): Promise<this>;
1212
- /** Ask for an 8-character pairing code. Throws if the session is already linked. */
1275
+ /**
1276
+ * Ask for an 8-character pairing code. Resolves once the server has accepted
1277
+ * the request; throws if it refuses (`err.code` is `PAIRING_CODE_*`) or if the
1278
+ * session is already linked.
1279
+ */
1213
1280
  requestPairingCode(phoneNumber?: string, customCode?: string): Promise<string>;
1281
+ /** Companion mode: answer a `passkey_request` with the authenticator's assertion. */
1282
+ sendPasskeyResponse(response: PasskeyAssertion): Promise<void>;
1283
+ /** Companion mode: finish a passkey link once the code has been confirmed. */
1284
+ sendPasskeyConfirmation(): Promise<void>;
1214
1285
  /** Mobile primary only: cached, bounded pending alerts, no authorization. */
1215
1286
  getPrimaryLinkInvitations(): PrimaryLinkInvitation[];
1216
1287
  /** Approve a separate companion on the current primary socket; never requests SMS. */
@@ -2264,6 +2335,7 @@ export declare const Hkdf: LibModule & {
2264
2335
  export declare const PairingCode: LibModule;
2265
2336
  export declare const CompanionPairing: LibModule;
2266
2337
  export declare const QrPairing: LibModule;
2338
+ export declare const PasskeyPairing: LibModule;
2267
2339
  export declare const WebVersion: LibModule;
2268
2340
  export declare const WebProto: LibModule;
2269
2341
 
package/index.js CHANGED
@@ -145,6 +145,7 @@ const Plist = require('./lib/plist');
145
145
  const PairingCode = require('./lib/PairingCode');
146
146
  const CompanionPairing = require('./lib/CompanionPairing');
147
147
  const QrPairing = require('./lib/QrPairing');
148
+ const PasskeyPairing = require('./lib/PasskeyPairing');
148
149
  const WebVersion = require('./lib/WebVersion');
149
150
  const WebProto = require('./lib/webproto');
150
151
 
@@ -418,6 +419,7 @@ module.exports = {
418
419
  PairingCode,
419
420
  CompanionPairing,
420
421
  QrPairing,
422
+ PasskeyPairing,
421
423
  WebVersion,
422
424
  WebProto,
423
425