aunubaileys 1.0.23 β†’ 1.0.25

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.25 / Baru di 1.0.25
68
+
69
+ - πŸͺͺ **DM receipt status no longer gets stuck on LID addressing** β€” receipts increasingly arrive addressed to the peer's LID while consumers keyed the sent message by its phone-number JID (or the reverse), so the status update never matched and the message looked forever "sent". When the LID store knows the pair, DM `messages.update` events now carry the alternate form as `key.remoteJidAlt` (purely additive; `remoteJid` unchanged). Under the hood the LID store is now created once in the base socket layer, so the single instance the public `sock.aunuLid` learns into is the same one inner layers read β€” and the store gains a `getAltJid(jid)` helper.
70
+
71
+ ### πŸ†• What's new in 1.0.24 / Baru di 1.0.24
72
+
73
+ - πŸ–ΌοΈ **`profilePictureUrl` no longer throws for β€œno picture”** β€” a contact with no photo (or one hidden by privacy settings) made the server answer 401/404 and upstream let the Boom crash every caller that forgot a try/catch. Those statuses now resolve to `undefined`, consistent with the existing empty-picture-node case; real failures (timeouts, 5xx) still throw.
74
+
67
75
  ### πŸ†• What's new in 1.0.23 / Baru di 1.0.23
68
76
 
69
77
  - πŸ–ΌοΈ **Old-media downloads recover from 403** β€” the phone re-upload recovery path for failed media downloads only triggered on HTTP 404/410, but WhatsApp's media CDN answers **403** when a message's directPath/url auth has expired β€” the common case for older media. Downloads of old media therefore failed permanently even though the sender's phone could heal them. 403 now triggers the re-upload request; if the media is truly gone, the re-upload fails as well and the original error propagates unchanged.
@@ -468,6 +468,12 @@ export const makeChatsSocket = (config) => {
468
468
  */
469
469
  const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
470
470
  jid = jidNormalizedUser(jid);
471
+ // AunuBaileys: "no picture / not visible to us" is an expected answer,
472
+ // not an exception β€” the server replies 401/404 and upstream let the
473
+ // Boom crash every caller that forgot a try/catch (menus, welcome
474
+ // messages, profil commands all fetch avatars). Those statuses now
475
+ // resolve to undefined, matching the existing no-picture-node case;
476
+ // real failures (timeouts, 5xx) still throw.
471
477
  const result = await query({
472
478
  tag: 'iq',
473
479
  attrs: {
@@ -477,7 +483,17 @@ export const makeChatsSocket = (config) => {
477
483
  xmlns: 'w:profile:picture'
478
484
  },
479
485
  content: [{ tag: 'picture', attrs: { type, query: 'url' } }]
480
- }, timeoutMs);
486
+ }, timeoutMs).catch((err) => {
487
+ // codebase convention (assertNodeErrorFree): IQ error codes ride in err.data as a number
488
+ const status = typeof err?.data === 'number' ? err.data : (err?.data?.attrs?.status || err?.data?.attrs?.code || err?.output?.statusCode || err?.status);
489
+ if (status === 401 || status === '401' || status === 404 || status === '404') {
490
+ return undefined;
491
+ }
492
+ throw err;
493
+ });
494
+ if (!result) {
495
+ return undefined;
496
+ }
481
497
  const child = getBinaryNodeChild(result, 'picture');
482
498
  return child?.attrs?.url;
483
499
  };
@@ -15,7 +15,9 @@ const makeWASocket = (config) => {
15
15
  }
16
16
  const sock = makeCommunitiesSocket(newConfig);
17
17
  sock.aunuHandler = new AunuHandler(sock);
18
- sock.aunuLid = makeLIDStore();
18
+ if (!sock.aunuLid) {
19
+ sock.aunuLid = makeLIDStore();
20
+ }
19
21
  sock.ev.on('messages.upsert', (upsert) => {
20
22
  try {
21
23
  sock.aunuLid.learnFromUpsert(upsert);
@@ -559,8 +559,17 @@ export const makeMessagesRecvSocket = (config) => {
559
559
  }
560
560
  }
561
561
  else {
562
+ // AunuBaileys: DM receipts increasingly arrive
563
+ // addressed to the peer's LID while consumers
564
+ // keyed the sent message by its PN JID (or the
565
+ // reverse), so the status update never matches
566
+ // their store and the message looks stuck at
567
+ // "sent". Attach the alternate form as
568
+ // key.remoteJidAlt when the LID store knows the
569
+ // pair β€” purely additive, remoteJid unchanged.
570
+ const remoteJidAlt = sock.aunuLid?.getAltJid?.(remoteJid);
562
571
  ev.emit('messages.update', ids.map(id => ({
563
- key: { ...key, id },
572
+ key: { ...key, id, ...(remoteJidAlt ? { remoteJidAlt } : {}) },
564
573
  update: { status }
565
574
  })));
566
575
  }
@@ -6,6 +6,7 @@ import { proto } from '../../WAProto/index.js';
6
6
  import { DEF_CALLBACK_PREFIX, DEF_TAG_PREFIX, INITIAL_PREKEY_COUNT, MIN_PREKEY_COUNT, NOISE_WA_HEADER } from '../Defaults/index.js';
7
7
  import { DisconnectReason } from '../Types/index.js'
8
8
  import { executeWMexQuery } from './mex.js';
9
+ import { makeLIDStore } from '../Utils/lid-store.js';
9
10
  import { QueryIds, XWAPaths } from '../Types/index.js';
10
11
  import { addTransactionCapability, aesEncryptCTR, bindWaitForConnectionUpdate, bytesToCrockford, configureSuccessfulPairing, Curve, derivePairingCodeKey, generateLoginNode, generateMdTagPrefix, generateRegistrationNode, getCodeFromWSError, getErrorCodeFromStreamError, getNextPreKeysNode, getPlatformId, makeEventBuffer, makeNoiseHandler, promiseTimeout } from '../Utils/index.js';
11
12
  import { assertNodeErrorFree, binaryNodeToString, encodeBinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidEncode, S_WHATSAPP_NET } from '../WABinary/index.js';
@@ -688,6 +689,12 @@ export const makeSocket = (config) => {
688
689
  ws,
689
690
  ev,
690
691
  authState: { creds, keys },
692
+ // AunuBaileys: the LID identity store is created HERE, in the base
693
+ // layer, so the same instance propagates through every layer's
694
+ // { ...sock } spread to the final socket β€” inner layers (receipt
695
+ // handling, presence, polls) read the store the public
696
+ // sock.aunuLid learns into, not a private copy.
697
+ aunuLid: makeLIDStore(),
691
698
  signalRepository,
692
699
  get user() {
693
700
  return authState.creds.me;
@@ -14,6 +14,8 @@ export interface LIDStore {
14
14
  learnFromUpsert(upsert: { messages?: WAMessage[] }): number;
15
15
  getLIDForPN(pnJid: string): string | undefined;
16
16
  getPNForLID(lidJid: string): string | undefined;
17
+ /** The alternate identity form of a known JID (PN for a known LID, LID for a known PN); undefined when unknown or not a user JID. */
18
+ getAltJid(jid: string): string | undefined;
17
19
  hasPN(pnJid: string): boolean;
18
20
  hasLID(lidJid: string): boolean;
19
21
  deletePair(jid: string): boolean;
@@ -89,6 +89,21 @@ export const makeLIDStore = (options = {}) => {
89
89
  learnFromUpsert,
90
90
  getLIDForPN: (pnJid) => (pnJid ? pnToLid.get(jidNormalizedUser(pnJid)) : undefined),
91
91
  getPNForLID: (lidJid) => (lidJid ? lidToPn.get(jidNormalizedUser(lidJid)) : undefined),
92
+ // the other identity form of a known JID: PN for a known LID,
93
+ // LID for a known PN; undefined for unknown or non-user JIDs
94
+ getAltJid: (jid) => {
95
+ if (!jid) {
96
+ return undefined;
97
+ }
98
+ const norm = jidNormalizedUser(jid);
99
+ if (isLidUser(norm)) {
100
+ return lidToPn.get(norm);
101
+ }
102
+ if (isJidUser(norm)) {
103
+ return pnToLid.get(norm);
104
+ }
105
+ return undefined;
106
+ },
92
107
  hasPN: (pnJid) => (pnJid ? pnToLid.has(jidNormalizedUser(pnJid)) : false),
93
108
  hasLID: (lidJid) => (lidJid ? lidToPn.has(jidNormalizedUser(lidJid)) : false),
94
109
  deletePair: (jid) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aunubaileys",
3
3
  "type": "module",
4
- "version": "1.0.23",
4
+ "version": "1.0.25",
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",