@realvare/based 2.7.2 → 2.7.3
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.
|
@@ -62,6 +62,16 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
62
62
|
logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack');
|
|
63
63
|
await sendNode(stanza);
|
|
64
64
|
};
|
|
65
|
+
|
|
66
|
+
// Add withAck wrapper for guaranteed acknowledgments
|
|
67
|
+
const withAck = (processFn) => async (node) => {
|
|
68
|
+
try {
|
|
69
|
+
await processFn(node);
|
|
70
|
+
} finally {
|
|
71
|
+
// Always send ack even on failure to allow potential retry
|
|
72
|
+
await sendMessageAck(node);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
65
75
|
const offerCall = async (toJid, isVideo = false) => {
|
|
66
76
|
const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
|
|
67
77
|
const offerContent = [];
|
|
@@ -747,23 +757,20 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
747
757
|
await sendMessageAck(node);
|
|
748
758
|
}
|
|
749
759
|
};
|
|
750
|
-
const handleMessage = async (node) => {
|
|
760
|
+
const handleMessage = withAck(async (node) => {
|
|
751
761
|
var _a, _b, _c;
|
|
752
762
|
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
753
763
|
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
754
|
-
await sendMessageAck(node);
|
|
755
764
|
return;
|
|
756
765
|
}
|
|
757
766
|
const encNode = (0, WABinary_1.getBinaryNodeChild)(node, 'enc');
|
|
758
767
|
// TODO: temporary fix for crashes and issues resulting of failed msmsg decryption
|
|
759
768
|
if (encNode && encNode.attrs.type === 'msmsg') {
|
|
760
769
|
logger.debug({ key: node.attrs.key }, 'ignored msmsg');
|
|
761
|
-
await sendMessageAck(node);
|
|
762
770
|
return;
|
|
763
771
|
}
|
|
764
772
|
let response;
|
|
765
773
|
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !encNode) {
|
|
766
|
-
await sendMessageAck(node);
|
|
767
774
|
const { key } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '').fullMessage;
|
|
768
775
|
response = await requestPlaceholderResend(key);
|
|
769
776
|
if (response === 'RESOLVED') {
|
|
@@ -849,7 +856,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
849
856
|
}
|
|
850
857
|
}
|
|
851
858
|
(0, Utils_1.cleanMessage)(msg, authState.creds.me.id);
|
|
852
|
-
await sendMessageAck(node);
|
|
853
859
|
await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
|
|
854
860
|
})
|
|
855
861
|
]);
|
|
@@ -857,7 +863,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
857
863
|
catch (error) {
|
|
858
864
|
logger.error({ error, node }, 'error in handling message');
|
|
859
865
|
}
|
|
860
|
-
};
|
|
866
|
+
});
|
|
861
867
|
const fetchMessageHistory = async (count, oldestMsgKey, oldestMsgTimestamp) => {
|
|
862
868
|
var _a;
|
|
863
869
|
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
@@ -29,11 +29,20 @@ exports.NACK_REASONS = {
|
|
|
29
29
|
*/
|
|
30
30
|
function decodeMessageNode(stanza, meId, meLid) {
|
|
31
31
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
32
|
+
if (!stanza || !stanza.attrs) {
|
|
33
|
+
throw new boom_1.Boom('Invalid stanza or missing attributes', { statusCode: 400 });
|
|
34
|
+
}
|
|
32
35
|
let msgType;
|
|
33
36
|
let chatId;
|
|
34
37
|
let author;
|
|
35
38
|
const msgId = stanza.attrs.id;
|
|
39
|
+
if (!msgId) {
|
|
40
|
+
throw new boom_1.Boom('Missing message ID', { statusCode: 400 });
|
|
41
|
+
}
|
|
36
42
|
const from = stanza.attrs.from;
|
|
43
|
+
if (!from) {
|
|
44
|
+
throw new boom_1.Boom('Missing sender JID', { statusCode: 400 });
|
|
45
|
+
}
|
|
37
46
|
const senderPn = (_a = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _a === void 0 ? void 0 : _a.sender_pn;
|
|
38
47
|
const senderLid = (_b = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _b === void 0 ? void 0 : _b.sender_lid;
|
|
39
48
|
const participant = stanza.attrs.participant;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realvare/based",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"description": "whatsapp api by sam",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"whatsapp-web",
|
|
10
10
|
"whatsapp-bot",
|
|
11
11
|
"automation",
|
|
12
|
-
"multi-device"
|
|
12
|
+
"multi-device",
|
|
13
|
+
"based"
|
|
13
14
|
],
|
|
14
15
|
"homepage": "https://github.com/realvare/based.git",
|
|
15
16
|
"repository": {
|
|
@@ -44,20 +45,20 @@
|
|
|
44
45
|
"@cacheable/node-cache": "^1.4.0",
|
|
45
46
|
"@hapi/boom": "^10.0.1",
|
|
46
47
|
"async-mutex": "^0.5.0",
|
|
47
|
-
"axios": "^1.
|
|
48
|
-
"cache-manager": "^
|
|
48
|
+
"axios": "^1.13.2",
|
|
49
|
+
"cache-manager": "^7.2.5",
|
|
49
50
|
"chalk": "^4.1.2",
|
|
50
|
-
"cheerio": "^1.
|
|
51
|
+
"cheerio": "^1.1.2",
|
|
51
52
|
"gradient-string": "^2.0.2",
|
|
52
|
-
"jimp": "^
|
|
53
|
-
"libphonenumber-js": "^1.
|
|
54
|
-
"libsignal": "github:
|
|
53
|
+
"jimp": "^1.6.0",
|
|
54
|
+
"libphonenumber-js": "^1.12.31",
|
|
55
|
+
"libsignal": "github:whiskeysockets/libsignal-node",
|
|
55
56
|
"lodash": "^4.17.21",
|
|
56
|
-
"music-metadata": "^7.
|
|
57
|
-
"pino": "^
|
|
58
|
-
"protobufjs": "^7.
|
|
59
|
-
"uuid": "^
|
|
60
|
-
"ws": "^8.18.
|
|
57
|
+
"music-metadata": "^11.7.0",
|
|
58
|
+
"pino": "^10.1.0",
|
|
59
|
+
"protobufjs": "^7.5.4",
|
|
60
|
+
"uuid": "^13.0.0",
|
|
61
|
+
"ws": "^8.18.3"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
"conventional-changelog-cli": "^2.2.2",
|
|
70
71
|
"eslint": "^8.57.0",
|
|
71
72
|
"jest": "^29.7.0",
|
|
72
|
-
"jimp": "^
|
|
73
|
+
"jimp": "^1.6.0",
|
|
73
74
|
"json": "^11.0.0",
|
|
74
75
|
"link-preview-js": "^3.0.0",
|
|
75
76
|
"open": "^10.1.0",
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
"ts-jest": "^29.1.2",
|
|
80
81
|
"ts-node": "^10.9.2",
|
|
81
82
|
"typedoc": "^0.25.12",
|
|
82
|
-
"typescript": "^5.
|
|
83
|
+
"typescript": "^5.9.3"
|
|
83
84
|
},
|
|
84
85
|
"peerDependencies": {
|
|
85
86
|
"audio-decode": "^2.1.3",
|