@vanzxy/baileys 1.4.8 → 1.5.0
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 +10 -0
- package/lib/Utils/MessageBuilder.js +56 -28
- package/package.json +3 -5
- package/cjs/WAProto/index.js +0 -106053
- package/cjs/lib/Defaults/index.js +0 -168
- package/cjs/lib/Signal/Group/ciphertext-message.js +0 -16
- package/cjs/lib/Signal/Group/group-session-builder.js +0 -67
- package/cjs/lib/Signal/Group/group_cipher.js +0 -86
- package/cjs/lib/Signal/Group/index.js +0 -58
- package/cjs/lib/Signal/Group/keyhelper.js +0 -56
- package/cjs/lib/Signal/Group/sender-chain-key.js +0 -30
- package/cjs/lib/Signal/Group/sender-key-distribution-message.js +0 -67
- package/cjs/lib/Signal/Group/sender-key-message.js +0 -70
- package/cjs/lib/Signal/Group/sender-key-name.js +0 -52
- package/cjs/lib/Signal/Group/sender-key-record.js +0 -45
- package/cjs/lib/Signal/Group/sender-key-state.js +0 -88
- package/cjs/lib/Signal/Group/sender-message-key.js +0 -30
- package/cjs/lib/Signal/libsignal.js +0 -467
- package/cjs/lib/Signal/lid-mapping.js +0 -281
- package/cjs/lib/Socket/Client/index.js +0 -19
- package/cjs/lib/Socket/Client/types.js +0 -15
- package/cjs/lib/Socket/Client/websocket.js +0 -61
- package/cjs/lib/Socket/business.js +0 -384
- package/cjs/lib/Socket/chats.js +0 -1257
- package/cjs/lib/Socket/communities.js +0 -442
- package/cjs/lib/Socket/dugong.js +0 -753
- package/cjs/lib/Socket/groups.js +0 -360
- package/cjs/lib/Socket/index.js +0 -30
- package/cjs/lib/Socket/messages-recv.js +0 -1790
- package/cjs/lib/Socket/messages-send.js +0 -1390
- package/cjs/lib/Socket/mex.js +0 -46
- package/cjs/lib/Socket/newsletter.js +0 -340
- package/cjs/lib/Socket/socket.js +0 -1007
- package/cjs/lib/Store/index.js +0 -20
- package/cjs/lib/Store/make-in-memory-store.js +0 -438
- package/cjs/lib/Store/make-ordered-dictionary.js +0 -82
- package/cjs/lib/Store/object-repository.js +0 -28
- package/cjs/lib/Types/Auth.js +0 -3
- package/cjs/lib/Types/Bussines.js +0 -3
- package/cjs/lib/Types/Call.js +0 -3
- package/cjs/lib/Types/Chat.js +0 -11
- package/cjs/lib/Types/Contact.js +0 -3
- package/cjs/lib/Types/Events.js +0 -4
- package/cjs/lib/Types/GroupMetadata.js +0 -3
- package/cjs/lib/Types/Label.js +0 -26
- package/cjs/lib/Types/LabelAssociation.js +0 -8
- package/cjs/lib/Types/Message.js +0 -19
- package/cjs/lib/Types/Mex.js +0 -40
- package/cjs/lib/Types/Product.js +0 -3
- package/cjs/lib/Types/RichType.js +0 -24
- package/cjs/lib/Types/Signal.js +0 -4
- package/cjs/lib/Types/Socket.js +0 -4
- package/cjs/lib/Types/State.js +0 -54
- package/cjs/lib/Types/USync.js +0 -4
- package/cjs/lib/Types/index.js +0 -42
- package/cjs/lib/Utils/MessageBuilder.js +0 -2684
- package/cjs/lib/Utils/auth-utils.js +0 -312
- package/cjs/lib/Utils/browser-utils.js +0 -32
- package/cjs/lib/Utils/business.js +0 -245
- package/cjs/lib/Utils/chat-utils.js +0 -940
- package/cjs/lib/Utils/companion-reg-client-utils.js +0 -45
- package/cjs/lib/Utils/crypto.js +0 -202
- package/cjs/lib/Utils/decode-wa-message.js +0 -324
- package/cjs/lib/Utils/event-buffer.js +0 -643
- package/cjs/lib/Utils/generics.js +0 -429
- package/cjs/lib/Utils/history.js +0 -151
- package/cjs/lib/Utils/identity-change-handler.js +0 -56
- package/cjs/lib/Utils/index.js +0 -42
- package/cjs/lib/Utils/link-preview.js +0 -122
- package/cjs/lib/Utils/logger.js +0 -8
- package/cjs/lib/Utils/lt-hash.js +0 -64
- package/cjs/lib/Utils/make-mutex.js +0 -38
- package/cjs/lib/Utils/message-retry-manager.js +0 -267
- package/cjs/lib/Utils/messages-media.js +0 -933
- package/cjs/lib/Utils/messages.js +0 -2180
- package/cjs/lib/Utils/noise-handler.js +0 -205
- package/cjs/lib/Utils/offline-node-processor.js +0 -43
- package/cjs/lib/Utils/pre-key-manager.js +0 -113
- package/cjs/lib/Utils/process-message.js +0 -772
- package/cjs/lib/Utils/reporting-utils.js +0 -263
- package/cjs/lib/Utils/rich-message-utils.js +0 -439
- package/cjs/lib/Utils/signal.js +0 -214
- package/cjs/lib/Utils/stanza-ack.js +0 -41
- package/cjs/lib/Utils/sync-action-utils.js +0 -54
- package/cjs/lib/Utils/tc-token-utils.js +0 -174
- package/cjs/lib/Utils/use-multi-file-auth-state.js +0 -125
- package/cjs/lib/Utils/use-single-file-auth-state.js +0 -121
- package/cjs/lib/Utils/use-sqlite-auth-state.js +0 -182
- package/cjs/lib/Utils/validate-connection.js +0 -210
- package/cjs/lib/WABinary/constants.js +0 -1470
- package/cjs/lib/WABinary/decode.js +0 -301
- package/cjs/lib/WABinary/encode.js +0 -257
- package/cjs/lib/WABinary/generic-utils.js +0 -275
- package/cjs/lib/WABinary/index.js +0 -22
- package/cjs/lib/WABinary/jid-utils.js +0 -114
- package/cjs/lib/WABinary/types.js +0 -37
- package/cjs/lib/WAM/BinaryInfo.js +0 -14
- package/cjs/lib/WAM/constants.js +0 -22856
- package/cjs/lib/WAM/encode.js +0 -154
- package/cjs/lib/WAM/index.js +0 -20
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -56
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -67
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -31
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -29
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -55
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -33
- package/cjs/lib/WAUSync/Protocols/index.js +0 -24
- package/cjs/lib/WAUSync/USyncQuery.js +0 -126
- package/cjs/lib/WAUSync/USyncUser.js +0 -35
- package/cjs/lib/WAUSync/index.js +0 -20
- package/cjs/lib/index.js +0 -34
- package/cjs/package.json +0 -1
package/README.md
CHANGED
|
@@ -173,3 +173,13 @@ Use responsibly and follow WhatsApp Terms of Service.
|
|
|
173
173
|
---
|
|
174
174
|
|
|
175
175
|
Made with 🍃 by Vanzxy
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## V4 Patch Notes
|
|
179
|
+
|
|
180
|
+
- Kept the existing Vanzxy custom MessageBuilder classes and AIRich implementation intact.
|
|
181
|
+
- Added `whatsapp-rust-bridge@0.5.5` as a runtime dependency. The library already dynamically imports this module for LT Hash/app-state and crypto helpers; declaring it prevents accidental missing-module fallbacks in normal installations.
|
|
182
|
+
- Existing guarded fallbacks for platforms where the native bridge cannot load remain in place.
|
|
183
|
+
- ESM-only package metadata is preserved; no CommonJS build is included.
|
|
184
|
+
|
|
185
|
+
Reference audit: the supplied Ourin, Elaina, ItsLiaaa, and Noxleyss packages were compared before this patch. Their broader core changes were not copied wholesale because the current Vanzxy tree already contains additional LID, retry, media, interactive, and AIRich fixes that would risk regressions if replaced.
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
const MESSAGE_BUILDER_VERSION = '4.9';
|
|
48
48
|
|
|
49
49
|
import { generateWAMessageFromContent, prepareWAMessageMedia } from './messages.js';
|
|
50
|
-
import { botMetadataSignature, botMetadataCertificate } from './rich-message-utils.js';
|
|
51
50
|
import crypto from 'crypto';
|
|
52
51
|
import { PassThrough, Readable } from 'stream';
|
|
53
52
|
// Vanz@Fix 15-08-26 --- sharp/fluent-ffmpeg were statically imported in the blurose source.
|
|
@@ -1181,6 +1180,14 @@ class Button extends BaseBuilder {
|
|
|
1181
1180
|
}
|
|
1182
1181
|
|
|
1183
1182
|
/** Build and send this interactive message. @param {string} jid Destination chat/group jid. */
|
|
1183
|
+
async sendEdit(jid, messageId, { ...options } = {}) {
|
|
1184
|
+
if (!messageId) throw new Error('messageId is required');
|
|
1185
|
+
const msg = await this.build(jid, options);
|
|
1186
|
+
msg.key = { ...(msg.key || {}), remoteJid: jid, id: messageId, fromMe: true };
|
|
1187
|
+
await this.#client.relayMessage(jid, msg.message, { messageId, ...options });
|
|
1188
|
+
return msg;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1184
1191
|
async send(jid, { ...options } = {}) {
|
|
1185
1192
|
const msg = await this.build(jid, options);
|
|
1186
1193
|
|
|
@@ -1587,6 +1594,9 @@ class AIRich extends BaseBuilder {
|
|
|
1587
1594
|
// mediaKey still doesn't render, so it's a trust-chain gate, not a domain/encoding issue).
|
|
1588
1595
|
// Track every addInlineImage() call here so send() can fall back to a normal imageMessage.
|
|
1589
1596
|
this._inlineImages = [];
|
|
1597
|
+
// Plain WhatsApp-media fallbacks for AIRich primitives that some clients refuse to render inline.
|
|
1598
|
+
// Entries are { type: 'image'|'video'|'audio'|'document', url, caption, mimetype, fileName }.
|
|
1599
|
+
this._mediaFallbacks = [];
|
|
1590
1600
|
|
|
1591
1601
|
// Vanz@Add (v4.9.1) --- { id, insertAt } support for every add*()/set*() call, without
|
|
1592
1602
|
// touching each method's own body/signature. Every add*() call ends up pushing 0-N items
|
|
@@ -1602,7 +1612,22 @@ class AIRich extends BaseBuilder {
|
|
|
1602
1612
|
return new Proxy(this, {
|
|
1603
1613
|
get(target, prop, receiver) {
|
|
1604
1614
|
const orig = Reflect.get(target, prop, receiver);
|
|
1605
|
-
if (typeof orig !== 'function'
|
|
1615
|
+
if (typeof orig !== 'function') return orig;
|
|
1616
|
+
|
|
1617
|
+
// Vanz@Fix 23-08-26 (part 2) --- the add*/set* filter below only wrapped methods whose
|
|
1618
|
+
// name starts with "add"/"set". Everything else (send(), build(), ...) fell through to
|
|
1619
|
+
// `return orig` unwrapped, so calling e.g. `richInstance.send(...)` still invoked the
|
|
1620
|
+
// real method with `this` = the Proxy (`receiver`), hitting the exact same
|
|
1621
|
+
// "Cannot read private member #client..." brand-check error the add*/set* fix was for —
|
|
1622
|
+
// just one level up, in send()/build() themselves. Every function property now gets
|
|
1623
|
+
// bound to `target` (the real instance) at minimum; add*/set* additionally get the
|
|
1624
|
+
// insertAt/id bookkeeping below.
|
|
1625
|
+
if (!/^(add|set)/.test(String(prop))) {
|
|
1626
|
+
return (...args) => {
|
|
1627
|
+
const result = orig.apply(target, args);
|
|
1628
|
+
return result === target ? receiver : result;
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1606
1631
|
|
|
1607
1632
|
return (...args) => {
|
|
1608
1633
|
const opts = args.find((a) => a && typeof a === 'object' && !Array.isArray(a) && !Buffer.isBuffer(a) && ('id' in a || 'insertAt' in a));
|
|
@@ -1890,7 +1915,7 @@ class AIRich extends BaseBuilder {
|
|
|
1890
1915
|
* One image, no prompt, nothing to download — use this when you don't need the rich card,
|
|
1891
1916
|
* just the picture to show up immediately.
|
|
1892
1917
|
*/
|
|
1893
|
-
addImage(imageUrl, { resolveUrl = false, instant =
|
|
1918
|
+
addImage(imageUrl, { resolveUrl = false, instant = true } = {}) {
|
|
1894
1919
|
if (!(typeof imageUrl === 'string' || Buffer.isBuffer(imageUrl) || (Array.isArray(imageUrl) && imageUrl.every((v) => typeof v === 'string' || Buffer.isBuffer(v))))) {
|
|
1895
1920
|
throw new TypeError('imageUrl must be string | buffer | array of string/buffer');
|
|
1896
1921
|
}
|
|
@@ -1948,6 +1973,8 @@ class AIRich extends BaseBuilder {
|
|
|
1948
1973
|
}
|
|
1949
1974
|
|
|
1950
1975
|
if (instant) {
|
|
1976
|
+
this._mediaFallbacks.push({ type: 'image', url: imagePreviewUrl, caption: undefined });
|
|
1977
|
+
// Keep legacy inline queue in sync for callers that inspect it.
|
|
1951
1978
|
this._inlineImages.push({ url: imagePreviewUrl, caption: undefined });
|
|
1952
1979
|
}
|
|
1953
1980
|
});
|
|
@@ -2025,7 +2052,7 @@ class AIRich extends BaseBuilder {
|
|
|
2025
2052
|
// for before rendering. Mirrors addImage()'s { resolveUrl } — when true, the url is uploaded to
|
|
2026
2053
|
// WA's own media server first via Toolkit.toUrl() so it renders instantly like WA-native media.
|
|
2027
2054
|
/** Add a video block. */
|
|
2028
|
-
addVideo(videoUrl, { autoFill = false, resolveUrl = false } = {}) {
|
|
2055
|
+
addVideo(videoUrl, { autoFill = false, resolveUrl = false, instant = true } = {}) {
|
|
2029
2056
|
const isObjectVideo = (v) => v && typeof v === 'object' && v.url;
|
|
2030
2057
|
|
|
2031
2058
|
const isValidPrimitive =
|
|
@@ -2102,6 +2129,15 @@ class AIRich extends BaseBuilder {
|
|
|
2102
2129
|
__typename: 'GenAIImaginePrimitive',
|
|
2103
2130
|
})
|
|
2104
2131
|
);
|
|
2132
|
+
|
|
2133
|
+
if (instant) {
|
|
2134
|
+
this._mediaFallbacks.push({
|
|
2135
|
+
type: 'video',
|
|
2136
|
+
url,
|
|
2137
|
+
caption: isObject ? (item.caption ?? '') : '',
|
|
2138
|
+
mimetype: isObject ? (item.mime_type ?? 'video/mp4') : 'video/mp4',
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2105
2141
|
});
|
|
2106
2142
|
|
|
2107
2143
|
return this;
|
|
@@ -2265,6 +2301,7 @@ class AIRich extends BaseBuilder {
|
|
|
2265
2301
|
__typename: 'GenAIImagePrimitive',
|
|
2266
2302
|
})
|
|
2267
2303
|
);
|
|
2304
|
+
this._mediaFallbacks.push({ type: 'image', url: full || preview, caption: undefined });
|
|
2268
2305
|
|
|
2269
2306
|
return this;
|
|
2270
2307
|
}
|
|
@@ -2604,12 +2641,6 @@ class AIRich extends BaseBuilder {
|
|
|
2604
2641
|
]
|
|
2605
2642
|
: [...(await waitAllPromises(this._sections))];
|
|
2606
2643
|
|
|
2607
|
-
// Vanz@Merge 15-08-26 --- Neither blurose nor arslan sign the bot metadata with
|
|
2608
|
-
// verificationMetadata (proofs/certificateChain). Backported from this project's own
|
|
2609
|
-
// rich-message-utils.js botMetadataSignature/botMetadataCertificate helpers, plus a
|
|
2610
|
-
// botResponseId tying the signed metadata to unifiedResponse.response_id.
|
|
2611
|
-
const responseId = crypto.randomUUID();
|
|
2612
|
-
|
|
2613
2644
|
return {
|
|
2614
2645
|
messageContextInfo: {
|
|
2615
2646
|
deviceListMetadata: {},
|
|
@@ -2617,17 +2648,6 @@ class AIRich extends BaseBuilder {
|
|
|
2617
2648
|
botMetadata: {
|
|
2618
2649
|
messageDisclaimerText: this._title,
|
|
2619
2650
|
richResponseSourcesMetadata: { sources: this._richResponseSources },
|
|
2620
|
-
botResponseId: responseId,
|
|
2621
|
-
verificationMetadata: {
|
|
2622
|
-
proofs: [
|
|
2623
|
-
{
|
|
2624
|
-
certificateChain: [botMetadataCertificate(), botMetadataCertificate(892)],
|
|
2625
|
-
version: 1,
|
|
2626
|
-
useCase: 1,
|
|
2627
|
-
signature: botMetadataSignature(),
|
|
2628
|
-
},
|
|
2629
|
-
],
|
|
2630
|
-
},
|
|
2631
2651
|
...notif,
|
|
2632
2652
|
},
|
|
2633
2653
|
},
|
|
@@ -2638,7 +2658,7 @@ class AIRich extends BaseBuilder {
|
|
|
2638
2658
|
messageType: 1,
|
|
2639
2659
|
submessages: includesSubmessages ? await waitAllPromises(this._submessages) : [],
|
|
2640
2660
|
unifiedResponse: {
|
|
2641
|
-
data: includesUnifiedResponse ? Buffer.from(JSON.stringify({ response_id:
|
|
2661
|
+
data: includesUnifiedResponse ? Buffer.from(JSON.stringify({ response_id: crypto.randomUUID(), sections })).toString('base64') : '',
|
|
2642
2662
|
},
|
|
2643
2663
|
contextInfo: {
|
|
2644
2664
|
...forward,
|
|
@@ -2662,17 +2682,21 @@ class AIRich extends BaseBuilder {
|
|
|
2662
2682
|
async send(jid, { forwarded, notification, includesUnifiedResponse, includesSubmessages, skipImageFallback = false, quoted, ...options } = {}) {
|
|
2663
2683
|
const msg = await this.build({ forwarded, notification, includesUnifiedResponse, includesSubmessages, quoted, ...options });
|
|
2664
2684
|
|
|
2665
|
-
if (!skipImageFallback && this.
|
|
2666
|
-
|
|
2685
|
+
if (!skipImageFallback && this._mediaFallbacks.length) {
|
|
2686
|
+
const fallbacks = await waitAllPromises(this._mediaFallbacks);
|
|
2687
|
+
for (const item of fallbacks) {
|
|
2667
2688
|
try {
|
|
2668
|
-
|
|
2689
|
+
const media = Buffer.isBuffer(item.url) ? item.url : { url: item.url };
|
|
2690
|
+
const content = { [item.type]: media };
|
|
2691
|
+
if (item.caption) content.caption = item.caption;
|
|
2692
|
+
if (item.mimetype) content.mimetype = item.mimetype;
|
|
2693
|
+
if (item.fileName) content.fileName = item.fileName;
|
|
2694
|
+
await this.#client.sendMessage(jid, content, quoted ? { quoted } : {});
|
|
2669
2695
|
} catch (err) {
|
|
2670
|
-
|
|
2671
|
-
this.#client.logger?.warn?.({ err, url }, 'inline image fallback failed, continuing with rich card');
|
|
2696
|
+
this.#client.logger?.warn?.({ err, url: item.url, type: item.type }, 'AIRich media fallback failed, continuing with rich card');
|
|
2672
2697
|
}
|
|
2673
2698
|
}
|
|
2674
2699
|
}
|
|
2675
|
-
|
|
2676
2700
|
return await this.#client.relayMessage(jid, msg, { ...options });
|
|
2677
2701
|
}
|
|
2678
2702
|
|
|
@@ -3347,6 +3371,9 @@ class AIRich extends BaseBuilder {
|
|
|
3347
3371
|
if (!Array.isArray(arr) || !arr.every((row) => Array.isArray(row) && row.every((cell) => typeof cell === 'string'))) {
|
|
3348
3372
|
throw new TypeError('Table must be a nested array of strings');
|
|
3349
3373
|
}
|
|
3374
|
+
if (arr.length === 0 || arr[0].length === 0) {
|
|
3375
|
+
throw new TypeError('Table must contain a non-empty header row');
|
|
3376
|
+
}
|
|
3350
3377
|
|
|
3351
3378
|
const [header, ...rows] = arr;
|
|
3352
3379
|
|
|
@@ -3530,6 +3557,7 @@ export {
|
|
|
3530
3557
|
AIRich,
|
|
3531
3558
|
AIRich as AIVanzxy,
|
|
3532
3559
|
AIRich as LeafRich,
|
|
3560
|
+
AIRich as LeafReach,
|
|
3533
3561
|
AIRich as VanzxyAI,
|
|
3534
3562
|
AIRich as VanzxyRich,
|
|
3535
3563
|
Toolkit,
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanzxy/baileys",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Enhanced Baileys fork by Vanzxy — based on @itsliaaa/baileys + @whiskeysockets/baileys with fixes for audio group status and clean media without newsletter button.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./cjs/lib/index.js",
|
|
7
6
|
"module": "./lib/index.js",
|
|
8
7
|
"types": "./lib/index.d.ts",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": {
|
|
11
10
|
"types": "./lib/index.d.ts",
|
|
12
11
|
"import": "./lib/index.js",
|
|
13
|
-
"require": "./cjs/lib/index.js",
|
|
14
12
|
"default": "./lib/index.js"
|
|
15
13
|
},
|
|
16
14
|
"./package.json": "./package.json"
|
|
@@ -28,7 +26,6 @@
|
|
|
28
26
|
},
|
|
29
27
|
"files": [
|
|
30
28
|
"lib/**/*",
|
|
31
|
-
"cjs/**/*",
|
|
32
29
|
"WAProto/**/*",
|
|
33
30
|
"engine-requirements.js",
|
|
34
31
|
"postinstall-banner.js",
|
|
@@ -62,7 +59,8 @@
|
|
|
62
59
|
"p-queue": "^9.1.0",
|
|
63
60
|
"pino": "^9.6.0",
|
|
64
61
|
"protobufjs": "^7.5.6",
|
|
65
|
-
"ws": "^8.19.0"
|
|
62
|
+
"ws": "^8.19.0",
|
|
63
|
+
"whatsapp-rust-bridge": "0.5.5"
|
|
66
64
|
},
|
|
67
65
|
"peerDependencies": {
|
|
68
66
|
"@napi-rs/image": "~1.12.0",
|