whalibmob 5.40.44 → 5.40.46
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 +3 -0
- package/lib/Client.js +45 -21
- package/llms.txt +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ code, and bring the account into being. Both transports, one API.
|
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
[](index.d.ts)
|
|
15
15
|
|
|
16
|
+
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/interactive-buttons.md)
|
|
17
|
+
|
|
16
18
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/Brasil.md)
|
|
17
19
|
|
|
18
20
|
**🇧🇷 Fala português?** A documentação completa está traduzida em **[Brasil.md](https://github.com/Kunboruto20/whalibmob/blob/main/Brasil.md)** — tudo o que está aqui, na sua língua.
|
|
@@ -26,6 +28,7 @@ code, and bring the account into being. Both transports, one API.
|
|
|
26
28
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md#library-api)
|
|
27
29
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#sending-messages)
|
|
28
30
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md#handling-events)
|
|
31
|
+
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/interactive-buttons.md)
|
|
29
32
|
|
|
30
33
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/attestation.md#device-attestation--play-integrity-and-app-attest)
|
|
31
34
|
|
package/lib/Client.js
CHANGED
|
@@ -5,6 +5,25 @@ const { statusFrom } = require('./errors');
|
|
|
5
5
|
const { dbg: _whaDbg, configureLogger: _whaConfigLogger } = require('./logger');
|
|
6
6
|
|
|
7
7
|
const EventEmitter = require('events');
|
|
8
|
+
|
|
9
|
+
// _processNotification returns this when it already acked (primary pairing).
|
|
10
|
+
const NOTIFICATION_ACK_OWNED = Symbol('notification-ack-owned');
|
|
11
|
+
|
|
12
|
+
// Ack a notification. Every push needs one or the server closes the stream
|
|
13
|
+
// after ~5 min; echo participant/recipient like whatsmeow's sendAck.
|
|
14
|
+
function sendNotificationAck(client, attrs, type) {
|
|
15
|
+
if (!client._socket || !client._connected) return;
|
|
16
|
+
attrs = attrs || {};
|
|
17
|
+
const ack = {
|
|
18
|
+
id: attrs.id || '',
|
|
19
|
+
class: 'notification',
|
|
20
|
+
type: type || '',
|
|
21
|
+
to: attrs.from || 's.whatsapp.net'
|
|
22
|
+
};
|
|
23
|
+
if (attrs.participant) ack.participant = String(attrs.participant);
|
|
24
|
+
if (attrs.recipient) ack.recipient = String(attrs.recipient);
|
|
25
|
+
client._socket.sendNode(new BinaryNode('ack', ack, null));
|
|
26
|
+
}
|
|
8
27
|
const path = require('path');
|
|
9
28
|
const fs = require('fs');
|
|
10
29
|
const crypto = require('crypto');
|
|
@@ -4100,6 +4119,14 @@ class WhalibmobClient extends EventEmitter {
|
|
|
4100
4119
|
return;
|
|
4101
4120
|
}
|
|
4102
4121
|
|
|
4122
|
+
if (childTag === 'ack') {
|
|
4123
|
+
// Server closed the stream on an unacked stanza; the child names which.
|
|
4124
|
+
const a = (child && child.attrs) || {};
|
|
4125
|
+
_whaDbg('[DBG] STREAM_ERROR ack — server closed the stream on an unacked stanza' +
|
|
4126
|
+
' id=' + (a.id || '?') + ' class=' + (a.class || '?') + ' type=' + (a.type || '?') +
|
|
4127
|
+
' from=' + (a.from || a.to || '?'));
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4103
4130
|
const reason = attrs.reason || conflictType || childTag || code || 'unknown';
|
|
4104
4131
|
_whaDbg('[DBG] STREAM_ERROR code=' + code + ' child=' + childTag +
|
|
4105
4132
|
' conflict=' + conflictType + ' reason=' + reason);
|
|
@@ -5067,23 +5094,16 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5067
5094
|
|
|
5068
5095
|
_handleReceipt(node) {
|
|
5069
5096
|
const attrs = node.attrs || {};
|
|
5097
|
+
// Ack first (a throwing listener below must not skip it). _sendStanzaAck
|
|
5098
|
+
// puts participant/recipient each on its own attribute; the old inline ack
|
|
5099
|
+
// put participant on `recipient`, so the server re-delivered it every login.
|
|
5100
|
+
this._sendStanzaAck(node);
|
|
5070
5101
|
this.emit('receipt', {
|
|
5071
5102
|
id: attrs.id ? String(attrs.id) : '',
|
|
5072
5103
|
from: attrs.from ? String(attrs.from) : '',
|
|
5073
5104
|
type: attrs.type ? String(attrs.type) : ''
|
|
5074
5105
|
});
|
|
5075
5106
|
this._captureReceipt(node);
|
|
5076
|
-
// ACK the receipt back to server (include type so server clears from offline queue)
|
|
5077
|
-
if (this._socket && this._connected) {
|
|
5078
|
-
const ackAttrs = {
|
|
5079
|
-
id: attrs.id || '',
|
|
5080
|
-
class: 'receipt',
|
|
5081
|
-
to: attrs.from || ''
|
|
5082
|
-
};
|
|
5083
|
-
if (attrs.type) ackAttrs.type = String(attrs.type);
|
|
5084
|
-
if (attrs.participant) ackAttrs.recipient = String(attrs.participant);
|
|
5085
|
-
this._socket.sendNode(new BinaryNode('ack', ackAttrs, null));
|
|
5086
|
-
}
|
|
5087
5107
|
// If the recipient couldn't decrypt our message, re-send with fresh Signal session
|
|
5088
5108
|
if (String(attrs.type || '') === 'retry') {
|
|
5089
5109
|
this._handleRetryFromRecipient(attrs);
|
|
@@ -5617,7 +5637,20 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5617
5637
|
});
|
|
5618
5638
|
}
|
|
5619
5639
|
|
|
5640
|
+
// Ack on every exit path (early return or a throwing listener), like
|
|
5641
|
+
// whatsmeow's deferred maybeDeferredAck(). Primary pairing acks itself.
|
|
5620
5642
|
_handleNotification(node) {
|
|
5643
|
+
const attrs = (node && node.attrs) || {};
|
|
5644
|
+
let ackOwnedElsewhere = false;
|
|
5645
|
+
try {
|
|
5646
|
+
ackOwnedElsewhere = WhalibmobClient.prototype._processNotification.call(this, node) ===
|
|
5647
|
+
NOTIFICATION_ACK_OWNED;
|
|
5648
|
+
} finally {
|
|
5649
|
+
if (!ackOwnedElsewhere) sendNotificationAck(this, attrs, attrs.type || '');
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
|
|
5653
|
+
_processNotification(node) {
|
|
5621
5654
|
const attrs = node.attrs || {};
|
|
5622
5655
|
const type = attrs.type || '';
|
|
5623
5656
|
|
|
@@ -5702,7 +5735,7 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5702
5735
|
});
|
|
5703
5736
|
}
|
|
5704
5737
|
// Primary handler owns durability and the transport ACK.
|
|
5705
|
-
return;
|
|
5738
|
+
return NOTIFICATION_ACK_OWNED;
|
|
5706
5739
|
}
|
|
5707
5740
|
}
|
|
5708
5741
|
|
|
@@ -5843,15 +5876,6 @@ class WhalibmobClient extends EventEmitter {
|
|
|
5843
5876
|
this.emit('identity_change', { jid: fromJid, user: fromPhone });
|
|
5844
5877
|
}
|
|
5845
5878
|
|
|
5846
|
-
// Ack the notification
|
|
5847
|
-
if (this._socket && this._connected) {
|
|
5848
|
-
this._socket.sendNode(new BinaryNode('ack', {
|
|
5849
|
-
id: attrs.id || '',
|
|
5850
|
-
class: 'notification',
|
|
5851
|
-
type: type,
|
|
5852
|
-
to: attrs.from || 's.whatsapp.net'
|
|
5853
|
-
}, null));
|
|
5854
|
-
}
|
|
5855
5879
|
}
|
|
5856
5880
|
|
|
5857
5881
|
/**
|
package/llms.txt
CHANGED
|
@@ -136,6 +136,7 @@ main().catch((err) => { console.error(err.message || err); process.exit(1); });
|
|
|
136
136
|
- [Handling Events](https://github.com/Kunboruto20/whalibmob#handling-events): the full event list, keepalive and offline-sync events included
|
|
137
137
|
- [Handling Errors](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md#handling-errors): every error the library raises is a Boom (`@hapi/boom`) with an HTTP-style `err.output.statusCode` — 400 bad input, 401 not authenticated, 408 timed out, 428 not connected, 502 a server answered wrongly, or the server's own status passed through
|
|
138
138
|
- [Encrypted add-ons](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#encrypted-reactions-comments-event-responses-and-edits): poll votes, encrypted reactions, comments, event responses and edits; `sendRawMessage` for any encoded Message
|
|
139
|
+
- [Interactive buttons](https://github.com/Kunboruto20/whalibmob/blob/main/docs/interactive-buttons.md): `sendInteractive` sends a "card" message with up to three tappable buttons — link (`url`), call (`phone`), copy (`copy`) or quick-reply (`id`) — with an optional header image; works the same on a mobile-registered number and a linked web session, and from the `wa` CLI
|
|
139
140
|
- [History Sync](https://github.com/Kunboruto20/whalibmob#history-sync): the backlog the server sends on first connect, and reading it back
|
|
140
141
|
- [Status / Stories](https://github.com/Kunboruto20/whalibmob#status--stories): posting to status
|
|
141
142
|
- [Send States in Chat](https://github.com/Kunboruto20/whalibmob#send-states-in-chat): typing, recording, online presence
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whalibmob",
|
|
3
|
-
"version": "5.40.
|
|
3
|
+
"version": "5.40.46",
|
|
4
4
|
"description": "Node.js library for WhatsApp — register a number over SMS, or link as a companion by QR. Signal E2E encryption, media, groups, channels.",
|
|
5
5
|
"author": "Kunboruto20",
|
|
6
6
|
"main": "index.js",
|