whalibmob 5.40.35 → 5.40.37
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 +6 -0
- package/docs/events-history.md +41 -0
- package/docs/groups-channels.md +86 -0
- package/docs/messaging.md +107 -0
- package/index.d.ts +136 -0
- package/index.js +1 -0
- package/lib/Client.js +824 -25
- package/lib/appstate/Mutations.js +51 -1
- package/lib/appstate/SyncdProto.js +48 -0
- package/lib/messages/MessageSecret.js +116 -0
- package/lib/messages/MessageSender.js +38 -0
- package/lib/noise.js +6 -0
- package/lib/proto/MessageProto.js +110 -3
- package/llms.txt +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -275,6 +275,7 @@ Where a session is kept, saving and restoring it, database backends, and the Sig
|
|
|
275
275
|
### [Handling Events & History Sync](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md)
|
|
276
276
|
|
|
277
277
|
- [Handling Events](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md#handling-events)
|
|
278
|
+
- [Connection Health, Sync and Account Events](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md#connection-health-sync-and-account-events)
|
|
278
279
|
- [History Sync](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md#history-sync)
|
|
279
280
|
|
|
280
281
|
### [Sending & Receiving Messages](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md)
|
|
@@ -285,6 +286,9 @@ Where a session is kept, saving and restoring it, database backends, and the Sig
|
|
|
285
286
|
- [Status / Stories](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#status--stories)
|
|
286
287
|
- [Send States in Chat](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#send-states-in-chat)
|
|
287
288
|
- [Modifying Chats](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#modifying-chats)
|
|
289
|
+
- [Vote on a Poll](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#vote-on-a-poll) · [Pin a Message](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#pin-a-message) · [Send a Message You Encoded](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#send-a-message-you-encoded)
|
|
290
|
+
- [Encrypted Reactions, Comments, Event Responses and Edits](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#encrypted-reactions-comments-event-responses-and-edits)
|
|
291
|
+
- [Labels](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#labels) · [Delete a Message for Me](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#delete-a-message-for-me)
|
|
288
292
|
|
|
289
293
|
### [User Queries, Profile, Privacy & Account State](https://github.com/Kunboruto20/whalibmob/blob/main/docs/profile-privacy.md)
|
|
290
294
|
|
|
@@ -298,7 +302,9 @@ Where a session is kept, saving and restoring it, database backends, and the Sig
|
|
|
298
302
|
- [Groups](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#groups)
|
|
299
303
|
- [Communities](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#communities)
|
|
300
304
|
- [Newsletters (Channels)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#newsletters-channels)
|
|
305
|
+
- [Read a Channel's Posts](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#read-a-channels-posts) · [Live Updates, Views and Reactions](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#live-updates-views-and-reactions)
|
|
301
306
|
- [Business Profile](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#business-profile)
|
|
307
|
+
- [Links, Bots, Sticker Packs and Web Push](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#links-bots-sticker-packs-and-web-push)
|
|
302
308
|
- [WhatsApp IDs](https://github.com/Kunboruto20/whalibmob/blob/main/docs/groups-channels.md#whatsapp-ids)
|
|
303
309
|
|
|
304
310
|
### [IDs, Transport, Media Encryption & Device Emulation](https://github.com/Kunboruto20/whalibmob/blob/main/docs/internals.md)
|
package/docs/events-history.md
CHANGED
|
@@ -165,6 +165,35 @@ The `decoded` object shape per message type:
|
|
|
165
165
|
{ type: 'protocol', subtype: string }
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
### Connection Health, Sync and Account Events
|
|
169
|
+
|
|
170
|
+
| Event | Payload | Description |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `keepalive_timeout` | `{ errorCount, lastSuccess }` | A keepalive ping went unanswered for 10 seconds. `errorCount` is how many in a row, `lastSuccess` when the last answer came (ms). The connection is not closed for you: decide whether to `disconnect({ reconnect: true })` |
|
|
173
|
+
| `keepalive_restored` | `{ missed }` | The first ping answered after one or more were missed |
|
|
174
|
+
| `offline_sync_preview` | `{ total, appDataChanges, messages, notifications, receipts }` | What the server is about to replay from while you were away |
|
|
175
|
+
| `offline_sync_completed` | `{ count }` | The replay is done; what arrives from here on is live |
|
|
176
|
+
| `temporary_ban` | `{ code, expireSecs, expiresAt }` | The account is temporarily banned. The session survives; the server refuses it until the ban runs out |
|
|
177
|
+
| `qr_scanned_without_multidevice` | `{}` | The QR was scanned by a phone with multi-device off. The same QR still works once it is on |
|
|
178
|
+
| `picture_update` | `{ jid, author, removed, pictureId, ts }` | A contact or group changed or removed its picture |
|
|
179
|
+
| `about_update` | `{ jid, about, ts }` | A contact changed its "about" text |
|
|
180
|
+
| `newsletter_live_update` | `{ jid, ts, messages }` | Count changes on a channel you subscribed to with `subscribeNewsletterLiveUpdates` |
|
|
181
|
+
| `label_edit` | `{ labelId, name, color, deleted }` | A label was created, changed or deleted |
|
|
182
|
+
| `label_association` | `{ labelId, jid, msgId, labeled }` | A label was put on, or taken off, a chat (`msgId` null) or a message |
|
|
183
|
+
| `message_deleted_for_me` | `{ jid, msgId, fromMe, deleteMedia }` | A message was deleted on this account's devices only |
|
|
184
|
+
| `status_muted` | `{ jid, muted }` | A contact's status updates were muted or unmuted |
|
|
185
|
+
| `unarchive_chats_setting` | `{ unarchiveChats }` | Whether archived chats come back when a message arrives |
|
|
186
|
+
|
|
187
|
+
The app-state events carry `remote: true` when the change was made on another device and `synced: true` when this client made it.
|
|
188
|
+
|
|
189
|
+
A keepalive example — drop a connection that has gone silent:
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
client.on('keepalive_timeout', ({ errorCount }) => {
|
|
193
|
+
if (errorCount >= 3) client.disconnect({ reconnect: true })
|
|
194
|
+
})
|
|
195
|
+
```
|
|
196
|
+
|
|
168
197
|
---
|
|
169
198
|
|
|
170
199
|
## History Sync
|
|
@@ -261,6 +290,18 @@ Sync type values:
|
|
|
261
290
|
| `NON_BLOCKING_DATA` | Background low-priority data |
|
|
262
291
|
| `ON_DEMAND` | Explicitly requested by the client |
|
|
263
292
|
|
|
293
|
+
### When a History Blob Cannot Be Fetched
|
|
294
|
+
|
|
295
|
+
A large history chunk is not sent inline: the phone uploads it and sends a notice with where it is and the key to open it. If that file is gone by the time you fetch it, tell the phone, and it uploads the chunk again:
|
|
296
|
+
|
|
297
|
+
```js
|
|
298
|
+
// msgId: the id of the message that carried the history notice
|
|
299
|
+
// mediaKey: the key from that notice
|
|
300
|
+
await client.sendHistorySyncServerErrorReceipt(msgId, mediaKey)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
The receipt goes to your own account as a peer message, the same way a media re-upload request does.
|
|
304
|
+
|
|
264
305
|
### Persistent Files Written to Disk
|
|
265
306
|
|
|
266
307
|
The library automatically writes these files to `sessionDir` per account. You do not need to create or manage them.
|
package/docs/groups-channels.md
CHANGED
|
@@ -403,6 +403,17 @@ await client.unlinkGroupFromCommunity(
|
|
|
403
403
|
)
|
|
404
404
|
```
|
|
405
405
|
|
|
406
|
+
### Sub Groups and Community Participants
|
|
407
|
+
|
|
408
|
+
```js
|
|
409
|
+
const groups = await client.getSubGroups('120363000000000001@g.us')
|
|
410
|
+
// [{ jid, subject, subjectTime, size, isDefaultSubGroup }]
|
|
411
|
+
|
|
412
|
+
// everyone in any group of the community — admins of the community only
|
|
413
|
+
const people = await client.getLinkedGroupsParticipants('120363000000000001@g.us')
|
|
414
|
+
// [{ jid, phoneNumber, lid }]
|
|
415
|
+
```
|
|
416
|
+
|
|
406
417
|
## Newsletters (Channels)
|
|
407
418
|
|
|
408
419
|
Newsletters are one-to-many broadcast channels. Only the owner can post; anyone can subscribe.
|
|
@@ -440,6 +451,59 @@ await client.changeNewsletterDescription('120363000000000004@newsletter', 'New d
|
|
|
440
451
|
await client.sendNewsletterText('120363000000000004@newsletter', 'Breaking: WhatsApp adds polls!')
|
|
441
452
|
```
|
|
442
453
|
|
|
454
|
+
### Read a Channel's Posts
|
|
455
|
+
|
|
456
|
+
Channel posts are not end-to-end encrypted, so they can be read for any channel, followed or not.
|
|
457
|
+
|
|
458
|
+
```js
|
|
459
|
+
const posts = await client.getNewsletterMessages('120363000000000004@newsletter', { count: 20 })
|
|
460
|
+
for (const p of posts) {
|
|
461
|
+
console.log(p.serverId, p.decoded?.text, p.viewsCount, p.reactionCounts) // { '❤️': 3 } or null
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// page back from the oldest one you have
|
|
465
|
+
const older = await client.getNewsletterMessages(jid, { count: 20, before: posts[0].serverId })
|
|
466
|
+
|
|
467
|
+
// what changed since: view and reaction counts, edits
|
|
468
|
+
const updates = await client.getNewsletterMessageUpdates(jid, { since: 1700000000, count: 50 })
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Each post is `{ serverId, id, type, ts, viewsCount, forwardsCount, reactionCounts, decoded, raw }`. `serverId` is the post's number in the channel and is what the calls below take; `raw` is the encoded `Message`.
|
|
472
|
+
|
|
473
|
+
Posts from channels you follow also arrive live, on the ordinary `message` event with `newsletter: true` and `serverId` set.
|
|
474
|
+
|
|
475
|
+
### Live Updates, Views and Reactions
|
|
476
|
+
|
|
477
|
+
```js
|
|
478
|
+
// ask for count changes to be pushed; lasts durationSecs, then ask again
|
|
479
|
+
const { durationSecs } = await client.subscribeNewsletterLiveUpdates(jid)
|
|
480
|
+
client.on('newsletter_live_update', ({ jid, messages }) => {
|
|
481
|
+
for (const m of messages) console.log(m.serverId, m.viewsCount, m.reactionCounts)
|
|
482
|
+
})
|
|
483
|
+
|
|
484
|
+
await client.markNewsletterViewed(jid, [posts[0].serverId, posts[1].serverId])
|
|
485
|
+
await client.sendNewsletterReaction(jid, posts[0].serverId, '🔥')
|
|
486
|
+
await client.sendNewsletterReaction(jid, posts[0].serverId, '') // take it back
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### Mute, List and Look Up Channels
|
|
490
|
+
|
|
491
|
+
```js
|
|
492
|
+
await client.muteNewsletter(jid)
|
|
493
|
+
await client.unmuteNewsletter(jid)
|
|
494
|
+
|
|
495
|
+
const mine = await client.getSubscribedNewsletters() // as the server describes them
|
|
496
|
+
const info = await client.getNewsletterInfoWithInvite('https://whatsapp.com/channel/0029VaABC')
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Post a Message You Encoded
|
|
500
|
+
|
|
501
|
+
`sendNewsletterText` covers text. For anything else, encode the `Message` yourself:
|
|
502
|
+
|
|
503
|
+
```js
|
|
504
|
+
await client.sendNewsletterMessage(jid, messageBytes, { type: 'media', mediaType: 'image', mediaId })
|
|
505
|
+
```
|
|
506
|
+
|
|
443
507
|
## Business Profile
|
|
444
508
|
|
|
445
509
|
Query the public business profile of any WhatsApp Business account:
|
|
@@ -458,6 +522,28 @@ if (bp) {
|
|
|
458
522
|
|
|
459
523
|
---
|
|
460
524
|
|
|
525
|
+
## Links, Bots, Sticker Packs and Web Push
|
|
526
|
+
|
|
527
|
+
```js
|
|
528
|
+
// where a wa.me/message/… business link points, and the text it prefills
|
|
529
|
+
const biz = await client.resolveBusinessMessageLink('https://wa.me/message/ABCDEF')
|
|
530
|
+
// { jid, pushName, message, isSigned, verifiedName, verifiedLevel }
|
|
531
|
+
|
|
532
|
+
// your own contact link; pass true to revoke it and get a new one
|
|
533
|
+
const { link } = await client.getContactQrLink() // https://wa.me/qr/…
|
|
534
|
+
const who = await client.resolveContactQrLink(link) // { jid, pushName, type }
|
|
535
|
+
|
|
536
|
+
// the Meta AI bots the server lists
|
|
537
|
+
const bots = await client.getBotList() // [{ jid, personaId }]
|
|
538
|
+
|
|
539
|
+
// a sticker pack's listing from WhatsApp's store
|
|
540
|
+
const pack = await client.fetchStickerPack('PACK_ID')
|
|
541
|
+
|
|
542
|
+
// Web Push: let the server wake this client through a browser push service
|
|
543
|
+
await client.registerWebPush({ endpoint, auth, p256dh }) // from a PushSubscription
|
|
544
|
+
const settings = await client.getPushConfig()
|
|
545
|
+
```
|
|
546
|
+
|
|
461
547
|
## WhatsApp IDs
|
|
462
548
|
|
|
463
549
|
- Individual contacts: `[countrycode][number]@s.whatsapp.net`
|
package/docs/messaging.md
CHANGED
|
@@ -309,6 +309,88 @@ The key is derived from the poll id, the poll's sender and the voter, so a vote
|
|
|
309
309
|
on someone else's poll needs their `encKey`, which only arrives if they sent the
|
|
310
310
|
poll to you: read it off `msg.decoded.encKey` on the poll message itself.
|
|
311
311
|
|
|
312
|
+
### Vote on a Poll
|
|
313
|
+
|
|
314
|
+
```js
|
|
315
|
+
// poll: a poll message you received (or one you sent with sendPoll)
|
|
316
|
+
client.on('message', async (msg) => {
|
|
317
|
+
if (msg.decoded?.type !== 'poll') return
|
|
318
|
+
await client.sendPollVote(msg.chat, {
|
|
319
|
+
id: msg.id,
|
|
320
|
+
sender: msg.participant || msg.from, // who sent the poll
|
|
321
|
+
encKey: msg.decoded.encKey // the poll's message secret
|
|
322
|
+
}, ['Rust']) // option texts; [] clears your vote
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
// a poll you sent yourself
|
|
326
|
+
const poll = await client.sendPoll(jid, 'Language?', ['Rust', 'Go'], 1)
|
|
327
|
+
await client.sendPollVote(jid, { id: poll.id, fromMe: true, encKey: poll.encKey }, ['Go'])
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
The vote is encrypted under the poll's secret, so `encKey` is required: there is no way to vote on a poll whose message you never received. In a group the vote names the poll's author, which is why `sender` is needed for somebody else's poll.
|
|
331
|
+
|
|
332
|
+
### Pin a Message
|
|
333
|
+
|
|
334
|
+
```js
|
|
335
|
+
// pin for everyone, for 7 days (the default); 86400 and 2592000 are the other choices
|
|
336
|
+
await client.pinMessage(jid, { id: 'MSGID123', fromMe: true }, { durationSecs: 604800 })
|
|
337
|
+
|
|
338
|
+
// in a group, somebody else's message needs its sender
|
|
339
|
+
await client.pinMessage(groupJid, { id: 'MSGID456', fromMe: false, participant: '919634847671@s.whatsapp.net' })
|
|
340
|
+
|
|
341
|
+
await client.unpinMessage(jid, { id: 'MSGID123', fromMe: true })
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
An incoming pin decodes as `{ type: 'pinInChat', pinned, targetKey }`, and a "keep in chat" on a disappearing message as `{ type: 'keepInChat', kept, targetKey }`.
|
|
345
|
+
|
|
346
|
+
### Encrypted Reactions, Comments, Event Responses and Edits
|
|
347
|
+
|
|
348
|
+
Some messages act on another message and are encrypted under *that* message's secret rather than sent in the clear: a reaction or a comment in a community announcement group, a response to an event, an encrypted edit. They decode as `encReaction`, `encComment`, `encEventResponse` and `secretEncrypted`, each with a `targetKey` naming the message it belongs to.
|
|
349
|
+
|
|
350
|
+
To read one you need the target message's secret. It is on the target when it arrives, as `decoded.messageSecret`, so keep it by message id:
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
const secrets = new Map() // message id -> 32-byte secret
|
|
354
|
+
|
|
355
|
+
client.on('message', (msg) => {
|
|
356
|
+
const d = msg.decoded
|
|
357
|
+
if (!d) return
|
|
358
|
+
if (d.messageSecret) secrets.set(msg.id, d.messageSecret)
|
|
359
|
+
|
|
360
|
+
const secret = d.targetKey && secrets.get(d.targetKey.id)
|
|
361
|
+
if (!secret) return
|
|
362
|
+
|
|
363
|
+
if (d.type === 'encReaction') {
|
|
364
|
+
const r = client.decryptReaction(msg, { messageSecret: secret })
|
|
365
|
+
console.log(msg.participant, 'reacted', r.text) // '' means the reaction was removed
|
|
366
|
+
} else if (d.type === 'encComment') {
|
|
367
|
+
const c = client.decryptComment(msg, { messageSecret: secret })
|
|
368
|
+
console.log('comment:', c.decoded?.text)
|
|
369
|
+
} else if (d.type === 'encEventResponse') {
|
|
370
|
+
const e = client.decryptEventResponse(msg, { messageSecret: secret })
|
|
371
|
+
console.log(e.response) // 'going' | 'not_going' | 'maybe'
|
|
372
|
+
} else if (d.type === 'secretEncrypted') {
|
|
373
|
+
const e = client.decryptSecretMessage(msg, { messageSecret: secret })
|
|
374
|
+
console.log(e.secretType, e.decoded?.text) // 'Message Edit', the new text
|
|
375
|
+
}
|
|
376
|
+
})
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Every result also carries `plaintext`, the protobuf that was inside, for anything the built-in decoder does not name. The key depends on who sent the target and who sent the add-on; both are read off the message, and `opts.targetSender` / `opts.sender` override them when you know better. A wrong secret or a wrong sender throws rather than returning garbage.
|
|
380
|
+
|
|
381
|
+
### Send a Message You Encoded
|
|
382
|
+
|
|
383
|
+
For a message type this library has no method for, encode the `Message` protobuf yourself and hand over the bytes. It is encrypted and delivered exactly like the built-in sends.
|
|
384
|
+
|
|
385
|
+
```js
|
|
386
|
+
// messageBytes: an encoded WhatsApp `Message`, from your own protobuf tooling
|
|
387
|
+
await client.sendRawMessage(jid, messageBytes) // a text-like message
|
|
388
|
+
await client.sendRawMessage(jid, messageBytes, { type: 'media', mediaType: 'image' })
|
|
389
|
+
await client.sendRawMessage(jid, messageBytes, { type: 'poll', pollType: 'creation' })
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
The options describe what the stanza says in the clear, which the server reads without decrypting anything: `type` (`text`, `media`, `poll`, `reaction`), `mediaType` for media (`image`, `video`, `audio`, `ptt`, `document`, `sticker`, `gif`, `vcard`…), `pollType`, `edit` (`'1'` edit, `'2'` pin, `'7'` revoke, `'8'` admin revoke) and `hide` (show nothing if it cannot be decrypted). A message that says one thing in the stanza and another inside may be dropped by the recipient, so set them to match.
|
|
393
|
+
|
|
312
394
|
### Quoted Reply
|
|
313
395
|
|
|
314
396
|
Send a text message that quotes (replies to) a specific earlier message. The recipient sees the original message highlighted above your reply.
|
|
@@ -606,6 +688,31 @@ await client.starMessage('MSGID123', '919634847671', true) // yours
|
|
|
606
688
|
await client.unstarMessage('MSGID123', '919634847671', false) // theirs
|
|
607
689
|
```
|
|
608
690
|
|
|
691
|
+
### Labels
|
|
692
|
+
|
|
693
|
+
Labels are the coloured tags a WhatsApp Business account files chats under. A label is identified by an id you choose; create or change it, then put it on a chat or on one message.
|
|
694
|
+
|
|
695
|
+
```js
|
|
696
|
+
await client.editLabel('5', { name: 'VIP', color: 3 }) // create, rename or recolour
|
|
697
|
+
await client.labelChat('919634847671', '5') // tag a chat
|
|
698
|
+
await client.labelMessage('919634847671', '5', 'MSGID123') // tag one message
|
|
699
|
+
await client.labelChat('919634847671', '5', false) // remove the tag
|
|
700
|
+
await client.editLabel('5', { deleted: true }) // delete the label
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
### Delete a Message for Me
|
|
704
|
+
|
|
705
|
+
Removes one message from this account's devices only; nobody else's copy changes. This is not `deleteMessage(..., true)`, which revokes it for everyone.
|
|
706
|
+
|
|
707
|
+
```js
|
|
708
|
+
await client.deleteMessageForMe('919634847671', 'MSGID123', true, {
|
|
709
|
+
timestamp: 1700000000, // the message's time, unix seconds
|
|
710
|
+
deleteMedia: true
|
|
711
|
+
})
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
Both of these are app-state changes, so they need a session that can sync app state (`client.canSyncAppState()`), and they throw when it cannot. Changes made on the phone arrive as `label_edit`, `label_association`, `message_deleted_for_me`, `status_muted` and `unarchive_chats_setting` — see [All Events](events-history.md#connection-health-sync-and-account-events).
|
|
715
|
+
|
|
609
716
|
<a id="app-state-sync"></a>
|
|
610
717
|
|
|
611
718
|
### Reading Changes Made Elsewhere
|
package/index.d.ts
CHANGED
|
@@ -202,6 +202,75 @@ export interface ConnectWebOptions {
|
|
|
202
202
|
lidDbMigrated?: boolean;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/** A message another message acts on. */
|
|
206
|
+
export interface MessageTarget {
|
|
207
|
+
id: string;
|
|
208
|
+
fromMe?: boolean;
|
|
209
|
+
/** In a group, who sent it when it is not ours. */
|
|
210
|
+
participant?: Jid;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface PollVoteTarget {
|
|
214
|
+
id: string;
|
|
215
|
+
/** Who sent the poll; not needed when `fromMe`. */
|
|
216
|
+
sender?: Jid;
|
|
217
|
+
fromMe?: boolean;
|
|
218
|
+
/** The poll's 32-byte message secret. */
|
|
219
|
+
encKey: Buffer;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface RawMessageOptions {
|
|
223
|
+
id?: string;
|
|
224
|
+
/** What the stanza says the message is. Default `text`. */
|
|
225
|
+
type?: 'text' | 'media' | 'poll' | 'reaction';
|
|
226
|
+
/** For `media`: image, video, audio, ptt, document, sticker, gif, vcard… */
|
|
227
|
+
mediaType?: string;
|
|
228
|
+
pollType?: 'creation' | 'vote';
|
|
229
|
+
/** `'1'` edit, `'2'` pin, `'7'` revoke, `'8'` admin revoke. */
|
|
230
|
+
edit?: string;
|
|
231
|
+
/** Tell recipients to show nothing if it cannot be decrypted. */
|
|
232
|
+
hide?: boolean;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface SecretMessageOptions {
|
|
236
|
+
/** The target message's 32-byte secret (`decoded.messageSecret` on it). */
|
|
237
|
+
messageSecret: Buffer;
|
|
238
|
+
targetSender?: Jid;
|
|
239
|
+
sender?: Jid;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface SecretMessageResult {
|
|
243
|
+
type: 'encReaction' | 'encComment' | 'encEventResponse' | 'secretEncrypted';
|
|
244
|
+
/** The label the key was derived under, e.g. `Enc Reaction`. */
|
|
245
|
+
secretType: string;
|
|
246
|
+
targetKey: { remoteJid: string | null; fromMe: boolean; id: string | null; participant: string | null };
|
|
247
|
+
/** The protobuf that was inside. */
|
|
248
|
+
plaintext: Buffer;
|
|
249
|
+
/** Read as a Message where that is what it is: an edit, a comment. */
|
|
250
|
+
decoded: any | null;
|
|
251
|
+
/** A reaction's emoji; empty when it was removed. */
|
|
252
|
+
text?: string;
|
|
253
|
+
response?: 'going' | 'not_going' | 'maybe' | 'unknown';
|
|
254
|
+
senderTimestampMs?: number;
|
|
255
|
+
timestampMs?: number;
|
|
256
|
+
extraGuestCount?: number;
|
|
257
|
+
messageRaw?: Buffer;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** One post of a channel. */
|
|
261
|
+
export interface NewsletterMessage {
|
|
262
|
+
serverId: number | null;
|
|
263
|
+
id: string | null;
|
|
264
|
+
type: string | null;
|
|
265
|
+
ts: number;
|
|
266
|
+
viewsCount: number;
|
|
267
|
+
forwardsCount: number;
|
|
268
|
+
reactionCounts: Record<string, number> | null;
|
|
269
|
+
/** The encoded Message. */
|
|
270
|
+
raw: Buffer | null;
|
|
271
|
+
decoded: any | null;
|
|
272
|
+
}
|
|
273
|
+
|
|
205
274
|
/** Who a pair-success would link this device to. */
|
|
206
275
|
export interface PrePairInfo {
|
|
207
276
|
jid: Jid;
|
|
@@ -1019,6 +1088,27 @@ export interface WhalibmobEvents {
|
|
|
1019
1088
|
paired: (p: { jid: Jid; lid: Jid; deviceIndex: number; platform: string }) => void;
|
|
1020
1089
|
/** Companion mode: a pair-success was turned down, here or by `prePair`. `error` fires too. */
|
|
1021
1090
|
pair_error: (p: { jid: Jid | null; lid: Jid | null; platform: string | null; err: Error }) => void;
|
|
1091
|
+
|
|
1092
|
+
/** A keepalive ping went unanswered. The connection is not closed for you. */
|
|
1093
|
+
keepalive_timeout: (k: { errorCount: number; lastSuccess: number | null }) => void;
|
|
1094
|
+
/** The first keepalive answered after one or more were missed. */
|
|
1095
|
+
keepalive_restored: (k: { missed: number }) => void;
|
|
1096
|
+
/** What the server is about to replay from while this client was away. */
|
|
1097
|
+
offline_sync_preview: (o: { total: number; appDataChanges: number; messages: number; notifications: number; receipts: number }) => void;
|
|
1098
|
+
/** The replay is done; what arrives from here on is live. */
|
|
1099
|
+
offline_sync_completed: (o: { count: number }) => void;
|
|
1100
|
+
/** The account is temporarily banned; the session survives. */
|
|
1101
|
+
temporary_ban: (b: { code: string | null; expireSecs: number | null; expiresAt: number | null }) => void;
|
|
1102
|
+
/** The QR was scanned by a phone with multi-device turned off. */
|
|
1103
|
+
qr_scanned_without_multidevice: (e: Record<string, never>) => void;
|
|
1104
|
+
picture_update: (p: { jid: Jid; author: Jid | null; removed: boolean; pictureId: string | null; ts: number }) => void;
|
|
1105
|
+
about_update: (a: { jid: Jid; about: string; ts: number }) => void;
|
|
1106
|
+
newsletter_live_update: (u: { jid: Jid; ts: number; messages: NewsletterMessage[] }) => void;
|
|
1107
|
+
label_edit: (l: { labelId: string; name: string; color: number; deleted: boolean; remote?: boolean; synced?: boolean }) => void;
|
|
1108
|
+
label_association: (l: { labelId: string; jid: Jid; msgId: string | null; labeled: boolean; remote?: boolean; synced?: boolean }) => void;
|
|
1109
|
+
message_deleted_for_me: (m: { jid: Jid; msgId: string; fromMe: boolean; deleteMedia: boolean; remote?: boolean; synced?: boolean }) => void;
|
|
1110
|
+
status_muted: (s: { jid: Jid; muted: boolean; remote?: boolean }) => void;
|
|
1111
|
+
unarchive_chats_setting: (s: { unarchiveChats: boolean; remote?: boolean }) => void;
|
|
1022
1112
|
/** Companion mode: the account can be linked with a passkey. Answer with `sendPasskeyResponse`. */
|
|
1023
1113
|
passkey_request: (p: { publicKey: PasskeyRequestOptions }) => void;
|
|
1024
1114
|
/**
|
|
@@ -1418,6 +1508,18 @@ export declare class WhalibmobClient extends EventEmitter {
|
|
|
1418
1508
|
* without them only the SHA-256 of each choice is available.
|
|
1419
1509
|
*/
|
|
1420
1510
|
decryptPollVote(vote: DecodedMessage | IncomingMessage, opts: PollVoteOptions): PollVoteResult;
|
|
1511
|
+
/** Vote on a poll. `selected` are option texts; an empty list clears the vote. */
|
|
1512
|
+
sendPollVote(chatJid: Jid, poll: PollVoteTarget, selected: string[], opts?: SendOptions & { sender?: Jid }): Promise<SendResult>;
|
|
1513
|
+
/** Send an encoded `Message` this library has no method for. */
|
|
1514
|
+
sendRawMessage(to: Jid, message: Buffer, opts?: RawMessageOptions): Promise<SendResult>;
|
|
1515
|
+
/** Pin a message for everyone in a chat. */
|
|
1516
|
+
pinMessage(chatJid: Jid, target: MessageTarget, opts?: { pin?: boolean; durationSecs?: number; id?: string }): Promise<SendResult>;
|
|
1517
|
+
unpinMessage(chatJid: Jid, target: MessageTarget, opts?: { id?: string }): Promise<SendResult>;
|
|
1518
|
+
/** Open an add-on sealed under another message's secret. Throws when it will not open. */
|
|
1519
|
+
decryptSecretMessage(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
|
|
1520
|
+
decryptReaction(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
|
|
1521
|
+
decryptComment(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
|
|
1522
|
+
decryptEventResponse(msg: DecodedMessage | IncomingMessage, opts: SecretMessageOptions): SecretMessageResult;
|
|
1421
1523
|
/** Ask the sender's phone to re-upload a file the CDN no longer has. */
|
|
1422
1524
|
requestMediaRetry(info: { id: string; chatJid: Jid; fromMe: boolean; participant?: Jid }, mediaKey: Buffer): Promise<void>;
|
|
1423
1525
|
decryptMediaRetry(notification: MediaRetryNotification, mediaKey: Buffer): MediaRetryResult;
|
|
@@ -1439,6 +1541,16 @@ export declare class WhalibmobClient extends EventEmitter {
|
|
|
1439
1541
|
queryPictureInfo(jid: Jid, opts?: object): Promise<any>;
|
|
1440
1542
|
downloadProfilePicture(jid: Jid, opts?: object): Promise<Buffer | null>;
|
|
1441
1543
|
queryBusinessProfile(jid: Jid): Promise<BusinessProfile | null>;
|
|
1544
|
+
resolveBusinessMessageLink(linkOrCode: string): Promise<{ jid: Jid | null; pushName: string | null; message: string | null;
|
|
1545
|
+
isSigned: boolean; verifiedName: string | null; verifiedLevel: string | null }>;
|
|
1546
|
+
/** Our own contact link; `revoke` replaces it. */
|
|
1547
|
+
getContactQrLink(revoke?: boolean): Promise<{ code: string; link: string }>;
|
|
1548
|
+
resolveContactQrLink(linkOrCode: string): Promise<{ jid: Jid | null; pushName: string | null; type: string | null }>;
|
|
1549
|
+
getBotList(): Promise<Array<{ jid: Jid; personaId: string | null }>>;
|
|
1550
|
+
fetchStickerPack(packId: string): Promise<any>;
|
|
1551
|
+
registerWebPush(subscription: { endpoint: string; auth: Buffer | string; p256dh: Buffer | string }): Promise<void>;
|
|
1552
|
+
getPushConfig(): Promise<Record<string, string>>;
|
|
1553
|
+
sendHistorySyncServerErrorReceipt(msgId: string, mediaKey: Buffer): Promise<void>;
|
|
1442
1554
|
|
|
1443
1555
|
// ─── Profile ─────────────────────────────────────────────────────────────
|
|
1444
1556
|
/** Publishes and saves rename intent. True confirms an App State write only;
|
|
@@ -1526,6 +1638,12 @@ export declare class WhalibmobClient extends EventEmitter {
|
|
|
1526
1638
|
archiveChat(jid: Jid): Promise<boolean>;
|
|
1527
1639
|
unarchiveChat(jid: Jid): Promise<boolean>;
|
|
1528
1640
|
starMessage(msgId: string, chatJid: Jid, fromMe: boolean): Promise<boolean>;
|
|
1641
|
+
/** Create, rename or recolour a label, or delete it with `{ deleted: true }`. Needs app-state sync. */
|
|
1642
|
+
editLabel(labelId: string | number, opts?: { name?: string; color?: number; deleted?: boolean }): Promise<void>;
|
|
1643
|
+
labelChat(jid: Jid, labelId: string | number, labeled?: boolean): Promise<void>;
|
|
1644
|
+
labelMessage(jid: Jid, labelId: string | number, msgId: string, labeled?: boolean): Promise<void>;
|
|
1645
|
+
/** Delete one message on this account's devices only. Needs app-state sync. */
|
|
1646
|
+
deleteMessageForMe(jid: Jid, msgId: string, fromMe: boolean, opts?: { timestamp?: number; deleteMedia?: boolean }): Promise<void>;
|
|
1529
1647
|
unstarMessage(msgId: string, chatJid: Jid, fromMe: boolean): Promise<boolean>;
|
|
1530
1648
|
changeEphemeralTimer(jid: Jid, seconds: number): Promise<any>;
|
|
1531
1649
|
changeNewChatsEphemeralTimer(seconds: number): Promise<any>;
|
|
@@ -1614,6 +1732,9 @@ export declare class WhalibmobClient extends EventEmitter {
|
|
|
1614
1732
|
createCommunity(subject: string, description?: string, opts?: object): Promise<GroupMetadata>;
|
|
1615
1733
|
deactivateCommunity(communityJid: Jid): Promise<any>;
|
|
1616
1734
|
linkGroupsToCommunity(communityJid: Jid, groupJids: Jid[]): Promise<any>;
|
|
1735
|
+
getSubGroups(communityJid: Jid): Promise<Array<{ jid: Jid; subject: string | null; subjectTime: number; size: number | null; isDefaultSubGroup: boolean }>>;
|
|
1736
|
+
/** Everyone in any group of a community. Community admins only. */
|
|
1737
|
+
getLinkedGroupsParticipants(communityJid: Jid): Promise<Array<{ jid: Jid; phoneNumber: Jid | null; lid: Jid | null }>>;
|
|
1617
1738
|
unlinkGroupFromCommunity(communityJid: Jid, groupJid: Jid): Promise<any>;
|
|
1618
1739
|
|
|
1619
1740
|
// ─── Newsletters ─────────────────────────────────────────────────────────
|
|
@@ -1623,6 +1744,20 @@ export declare class WhalibmobClient extends EventEmitter {
|
|
|
1623
1744
|
queryNewsletterMetadata(newsletterJid: Jid): Promise<any>;
|
|
1624
1745
|
changeNewsletterDescription(newsletterJid: Jid, description: string): Promise<any>;
|
|
1625
1746
|
sendNewsletterText(newsletterJid: Jid, text: string): Promise<any>;
|
|
1747
|
+
/** Post an encoded `Message` to a channel you administer. */
|
|
1748
|
+
sendNewsletterMessage(newsletterJid: Jid, message: Buffer,
|
|
1749
|
+
opts?: { id?: string; type?: string; mediaType?: string; mediaId?: string; edit?: string }): Promise<{ id: string; to: Jid }>;
|
|
1750
|
+
getNewsletterMessages(newsletterJid: Jid, opts?: { count?: number; before?: number }): Promise<NewsletterMessage[]>;
|
|
1751
|
+
getNewsletterMessageUpdates(newsletterJid: Jid, opts?: { count?: number; since?: number; after?: number }): Promise<NewsletterMessage[]>;
|
|
1752
|
+
/** Ask for count changes to be pushed as `newsletter_live_update`, for `durationSecs`. */
|
|
1753
|
+
subscribeNewsletterLiveUpdates(newsletterJid: Jid): Promise<{ durationSecs: number }>;
|
|
1754
|
+
markNewsletterViewed(newsletterJid: Jid, serverIds: number | number[]): Promise<void>;
|
|
1755
|
+
/** React to a channel post; an empty reaction takes ours back. */
|
|
1756
|
+
sendNewsletterReaction(newsletterJid: Jid, serverId: number, reaction: string, opts?: { id?: string }): Promise<{ id: string; to: Jid }>;
|
|
1757
|
+
muteNewsletter(newsletterJid: Jid, mute?: boolean): Promise<{ jid: Jid; muted: boolean }>;
|
|
1758
|
+
unmuteNewsletter(newsletterJid: Jid): Promise<{ jid: Jid; muted: boolean }>;
|
|
1759
|
+
getSubscribedNewsletters(): Promise<any[]>;
|
|
1760
|
+
getNewsletterInfoWithInvite(linkOrCode: string): Promise<any>;
|
|
1626
1761
|
|
|
1627
1762
|
// ─── Stores on disk ──────────────────────────────────────────────────────
|
|
1628
1763
|
getHistoryStore(): any;
|
|
@@ -2221,6 +2356,7 @@ export declare const Messages: {
|
|
|
2221
2356
|
RETRY_KEY_INFO: string;
|
|
2222
2357
|
};
|
|
2223
2358
|
ReportingToken: LibModule;
|
|
2359
|
+
MessageSecret: LibModule;
|
|
2224
2360
|
TcTokenStore: LibModule;
|
|
2225
2361
|
};
|
|
2226
2362
|
|
package/index.js
CHANGED
|
@@ -170,6 +170,7 @@ const GroupParticipant = require('./lib/GroupParticipant');
|
|
|
170
170
|
const Messages = {
|
|
171
171
|
MessageSender: require('./lib/messages/MessageSender'),
|
|
172
172
|
MediaRetry: require('./lib/messages/MediaRetry'),
|
|
173
|
+
MessageSecret: require('./lib/messages/MessageSecret'),
|
|
173
174
|
ReportingToken: require('./lib/messages/ReportingToken'),
|
|
174
175
|
TcTokenStore: require('./lib/messages/TcTokenStore')
|
|
175
176
|
};
|