aunubaileys 1.0.24 β 1.0.26
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 +8 -0
- package/lib/Socket/index.js +3 -1
- package/lib/Socket/messages-recv.js +10 -1
- package/lib/Socket/socket.js +7 -0
- package/lib/Utils/generics.js +20 -2
- package/lib/Utils/lid-store.d.ts +2 -0
- package/lib/Utils/lid-store.js +15 -0
- package/package.json +1 -1
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.26 / Baru di 1.0.26
|
|
68
|
+
|
|
69
|
+
- π‘ **`fetchLatestBaileysVersion` now remembers the last-good fetched version** β it is called on every reconnect and used to hit the network every time; a mid-session fetch failure silently downgraded to the bundled version, even though the endpoint value is the only server-accepted truth (see 1.0.13). Successful fetches are now cached for 10 minutes, and a later failure returns the last fetched version instead of the bundled one. New `forceRefresh` / `cacheTtlMs` options.
|
|
70
|
+
|
|
71
|
+
### π What's new in 1.0.25 / Baru di 1.0.25
|
|
72
|
+
|
|
73
|
+
- πͺͺ **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.
|
|
74
|
+
|
|
67
75
|
### π What's new in 1.0.24 / Baru di 1.0.24
|
|
68
76
|
|
|
69
77
|
- πΌοΈ **`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.
|
package/lib/Socket/index.js
CHANGED
|
@@ -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
|
|
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
|
}
|
package/lib/Socket/socket.js
CHANGED
|
@@ -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;
|
package/lib/Utils/generics.js
CHANGED
|
@@ -188,13 +188,31 @@ export const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connect
|
|
|
188
188
|
* utility that fetches latest baileys version from the master branch.
|
|
189
189
|
* Use to ensure your WA connection is always on the latest version
|
|
190
190
|
*/
|
|
191
|
+
// AunuBaileys: last-good cache for the fetched WA version. The endpoint's
|
|
192
|
+
// value is the server-accepted truth (a bundled version can be a rejected
|
|
193
|
+
// beta build β see 1.0.13), so once a fetch succeeds in this process, a
|
|
194
|
+
// later network failure must fall back to that fetched value, not silently
|
|
195
|
+
// downgrade to the bundled one. Repeated calls within the TTL also skip
|
|
196
|
+
// the network entirely; consumers typically call this on every reconnect.
|
|
197
|
+
const BAILEYS_VERSION_CACHE_TTL_MS = 10 * 60 * 1000;
|
|
198
|
+
let lastGoodBaileysVersion = null;
|
|
199
|
+
let lastGoodBaileysVersionAt = 0;
|
|
191
200
|
export const fetchLatestBaileysVersion = async (options = {}) => {
|
|
192
201
|
const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json';
|
|
202
|
+
const { cacheTtlMs = BAILEYS_VERSION_CACHE_TTL_MS, forceRefresh = false, ...axiosOptions } = options;
|
|
203
|
+
if (!forceRefresh && lastGoodBaileysVersion && (Date.now() - lastGoodBaileysVersionAt) < cacheTtlMs) {
|
|
204
|
+
return {
|
|
205
|
+
version: lastGoodBaileysVersion,
|
|
206
|
+
isLatest: true
|
|
207
|
+
};
|
|
208
|
+
}
|
|
193
209
|
try {
|
|
194
210
|
const result = await axios.get(URL, {
|
|
195
|
-
...
|
|
211
|
+
...axiosOptions,
|
|
196
212
|
responseType: 'json'
|
|
197
213
|
});
|
|
214
|
+
lastGoodBaileysVersion = result.data.version;
|
|
215
|
+
lastGoodBaileysVersionAt = Date.now();
|
|
198
216
|
return {
|
|
199
217
|
version: result.data.version,
|
|
200
218
|
isLatest: true
|
|
@@ -202,7 +220,7 @@ export const fetchLatestBaileysVersion = async (options = {}) => {
|
|
|
202
220
|
}
|
|
203
221
|
catch (error) {
|
|
204
222
|
return {
|
|
205
|
-
version: baileysVersion,
|
|
223
|
+
version: lastGoodBaileysVersion ?? baileysVersion,
|
|
206
224
|
isLatest: false,
|
|
207
225
|
error
|
|
208
226
|
};
|
package/lib/Utils/lid-store.d.ts
CHANGED
|
@@ -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;
|
package/lib/Utils/lid-store.js
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "1.0.26",
|
|
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",
|