@periskope/baileys 6.7.18-17-21 → 6.7.18-17-23
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/lib/Signal/libsignal.js
CHANGED
|
@@ -64,13 +64,34 @@ function makeLibSignalRepository(auth) {
|
|
|
64
64
|
key.includes('.whatsapp.net.history'));
|
|
65
65
|
}
|
|
66
66
|
const repository = {
|
|
67
|
-
decryptGroupMessage({ group, authorJid, msg }) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
async decryptGroupMessage({ group, authorJid, authorLid, msg }) {
|
|
68
|
+
// First attempt with authorJid
|
|
69
|
+
try {
|
|
70
|
+
const senderName = jidToSignalSenderKeyName(group, authorJid);
|
|
71
|
+
const cipher = new Group_1.GroupCipher(storage, senderName);
|
|
72
|
+
// Use transaction to ensure atomicity
|
|
73
|
+
return await parsedKeys.transaction(async () => {
|
|
74
|
+
return cipher.decrypt(msg);
|
|
75
|
+
}, group);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
// If authorLid is available and authorJid failed, try with authorLid as fallback
|
|
79
|
+
if (authorLid && authorLid !== authorJid) {
|
|
80
|
+
try {
|
|
81
|
+
const senderNameLid = jidToSignalSenderKeyName(group, authorLid);
|
|
82
|
+
const cipherLid = new Group_1.GroupCipher(storage, senderNameLid);
|
|
83
|
+
return await parsedKeys.transaction(async () => {
|
|
84
|
+
return cipherLid.decrypt(msg);
|
|
85
|
+
}, group);
|
|
86
|
+
}
|
|
87
|
+
catch (lidError) {
|
|
88
|
+
// If both fail, throw the original error
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// No authorLid available or it's the same as authorJid, throw original error
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
74
95
|
},
|
|
75
96
|
async processSenderKeyDistributionMessage({ item, authorJid }) {
|
|
76
97
|
const builder = new Group_1.GroupSessionBuilder(storage);
|
|
@@ -134,6 +134,13 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
134
134
|
if (retryCount >= maxMsgRetryCount) {
|
|
135
135
|
logger.warn({ retryCount, msgId }, 'reached maximum retry limit (5), not sending more retry receipts');
|
|
136
136
|
msgRetryCache.del(key);
|
|
137
|
+
// Create a CIPHERTEXT stub message when retry limit is reached and upsert it
|
|
138
|
+
const msg = fullMessage;
|
|
139
|
+
msg.messageStubType = WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT;
|
|
140
|
+
msg.messageStubParameters = ['Decryption failed after retries'];
|
|
141
|
+
(0, Utils_1.cleanMessage)(msg, authState.creds.me.id);
|
|
142
|
+
await sendMessageAck(node);
|
|
143
|
+
await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
|
|
137
144
|
return;
|
|
138
145
|
}
|
|
139
146
|
retryCount += 1;
|
package/lib/Types/Signal.d.ts
CHANGED
|
@@ -362,6 +362,8 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
362
362
|
}
|
|
363
363
|
const decryptMessageNode = (stanza, meId, meLid, repository, logger, sendRetryRequestFn, sessionContext) => {
|
|
364
364
|
const { fullMessage, author, sender } = decodeMessageNode(stanza, meId, meLid);
|
|
365
|
+
// Extract authorLid for group messages - use participantLid if available
|
|
366
|
+
const authorLid = fullMessage.key.participantLid;
|
|
365
367
|
return {
|
|
366
368
|
fullMessage,
|
|
367
369
|
category: stanza.attrs.category,
|
|
@@ -404,6 +406,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger, sendRetryRe
|
|
|
404
406
|
return await repository.decryptGroupMessage({
|
|
405
407
|
group: sender,
|
|
406
408
|
authorJid: author,
|
|
409
|
+
authorLid,
|
|
407
410
|
msg: content
|
|
408
411
|
});
|
|
409
412
|
case 'pkmsg':
|