aunubaileys 1.0.15 β†’ 1.0.17

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
@@ -64,6 +64,14 @@ Everything else is pure upstream. When upstream moves, we rebase the patch layer
64
64
 
65
65
 
66
66
 
67
+ ### πŸ†• What's new in 1.0.17 / Baru di 1.0.17
68
+
69
+ - πŸ‘₯ **Group sender-key heal** β€” the 1.0.14 failure counter now covers group messages too: after 3 consecutive group decrypt failures from the same author in the same group, the stale sender-key record is deleted (new `signalRepository.deleteSenderKey`), so the next retry makes the author resend with a fresh distribution message and the group cipher rebuilds from scratch. One rotten sender-key record can no longer mute a group member forever.
70
+
71
+ ### πŸ†• What's new in 1.0.16 / Baru di 1.0.16
72
+
73
+ - πŸͺͺ **Identity changes are handled, not just logged** β€” when WhatsApp notifies that a contact's identity changed (new phone / reinstall / recycled number), upstream Baileys logs β€œidentity changed” and does nothing, leaving your stored session bound to the old identity so that contact's messages keep failing. AunuBaileys now deletes the stored session for that JID on the spot, so the next exchange re-initiates cleanly against the new identity.
74
+
67
75
  ### πŸ†• What's new in 1.0.15 / Baru di 1.0.15
68
76
 
69
77
  - πŸ“€ **Send-side session heal** β€” the twin of 1.0.14 for outgoing messages: when the stored session for a JID is corrupt, `encryptMessage` throws and every send to that contact fails permanently. Now a session-flavoured encrypt error triggers an automatic heal β€” drop the session, fetch a fresh bundle from the server, encrypt once more. Non-session errors pass through untouched, and a second failure propagates (no retry loop).
@@ -66,6 +66,10 @@ export function makeLibSignalRepository(auth) {
66
66
  senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
67
67
  };
68
68
  },
69
+ async deleteSenderKey(group, authorJid) {
70
+ const senderNameStr = jidToSignalSenderKeyName(group, authorJid).toString();
71
+ await auth.keys.set({ 'sender-key': { [senderNameStr]: null } });
72
+ },
69
73
  async deleteSession(jid) {
70
74
  const addr = jidToSignalProtocolAddress(jid).toString();
71
75
  await auth.keys.set({ session: { [addr]: null } });
@@ -176,8 +176,19 @@ export const makeMessagesRecvSocket = (config) => {
176
176
  const identityNode = getBinaryNodeChild(node, 'identity');
177
177
  if (identityNode) {
178
178
  logger.info({ jid: from }, 'identity changed');
179
- // not handling right now
180
- // signal will override new identity anyway
179
+ // AunuBaileys: upstream logged this and did nothing, leaving the
180
+ // OLD session bound to the OLD identity β€” every later message from
181
+ // that contact then fails against the archived session (Bad MAC
182
+ // class) until the peer happens to send a pre-key message. Drop
183
+ // the stored session now (1.0.14 machinery) so the next exchange
184
+ // re-initiates cleanly against the new identity.
185
+ try {
186
+ await signalRepository.deleteSession(from);
187
+ logger.warn({ jid: from }, 'aunu: deleted stored session after identity change; next message re-initiates a fresh session');
188
+ }
189
+ catch (delErr) {
190
+ logger.debug({ err: delErr }, 'aunu: session delete on identity change failed');
191
+ }
181
192
  }
182
193
  else {
183
194
  logger.info({ node }, 'unknown encrypt notification');
@@ -666,18 +677,26 @@ export const makeMessagesRecvSocket = (config) => {
666
677
  }
667
678
  const encNode = getBinaryNodeChild(node, 'enc');
668
679
  let forceIncludeKeys = !encNode;
669
- if (!isJidGroup(msg.key.remoteJid) && author) {
680
+ if (author) {
670
681
  try {
682
+ const isGroupMsg = isJidGroup(msg.key.remoteJid);
671
683
  const addr = signalRepository.jidToSignalProtocolAddress(author);
672
- const fails = (decryptFailCounts.get(addr) || 0) + 1;
684
+ const failKey = isGroupMsg ? `sk:${msg.key.remoteJid}:${addr}` : addr;
685
+ const fails = (decryptFailCounts.get(failKey) || 0) + 1;
673
686
  if (fails >= DECRYPT_FAIL_SESSION_RESET_LIMIT) {
674
- await signalRepository.deleteSession(author);
675
- decryptFailCounts.delete(addr);
687
+ if (isGroupMsg) {
688
+ await signalRepository.deleteSenderKey(msg.key.remoteJid, author);
689
+ logger.warn({ author, group: msg.key.remoteJid }, 'aunu: deleted stale sender-key record after repeated group decrypt failures; retry request asks the author to resend with a fresh distribution message');
690
+ }
691
+ else {
692
+ await signalRepository.deleteSession(author);
693
+ logger.warn({ author, addr }, 'aunu: deleted stale E2E session after repeated decrypt failures (Bad MAC self-heal); retry receipt carries fresh keys');
694
+ }
695
+ decryptFailCounts.delete(failKey);
676
696
  forceIncludeKeys = true;
677
- logger.warn({ author, addr }, 'aunu: deleted stale E2E session after repeated decrypt failures (Bad MAC self-heal); retry receipt carries fresh keys');
678
697
  }
679
698
  else {
680
- decryptFailCounts.set(addr, fails);
699
+ decryptFailCounts.set(failKey, fails);
681
700
  }
682
701
  }
683
702
  catch (healErr) {
@@ -697,7 +716,9 @@ export const makeMessagesRecvSocket = (config) => {
697
716
  else {
698
717
  if (author) {
699
718
  try {
700
- decryptFailCounts.delete(signalRepository.jidToSignalProtocolAddress(author));
719
+ const addr = signalRepository.jidToSignalProtocolAddress(author);
720
+ decryptFailCounts.delete(addr);
721
+ decryptFailCounts.delete(`sk:${msg.key.remoteJid}:${addr}`);
701
722
  }
702
723
  catch { }
703
724
  }
@@ -54,6 +54,8 @@ export type SignalRepository = {
54
54
  injectE2ESession(opts: E2ESessionOpts): Promise<void>;
55
55
  /** AunuBaileys: delete the stored E2E session for a JID (used by the Bad MAC self-heal). */
56
56
  deleteSession(jid: string): Promise<void>;
57
+ /** AunuBaileys: delete the stored sender-key record for a group author (stale group session heal). */
58
+ deleteSenderKey(group: string, authorJid: string): Promise<void>;
57
59
  jidToSignalProtocolAddress(jid: string): string;
58
60
  };
59
61
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aunubaileys",
3
3
  "type": "module",
4
- "version": "1.0.15",
4
+ "version": "1.0.17",
5
5
  "description": "AunuBaileys \u2014 a WhatsApp Web API for bots that never sleep. Full upstream power with the beloved in-memory store restored and pairing that just works. Forged by AunuCore.",
6
6
  "keywords": [
7
7
  "whatsapp",