@vanzxy/baileys 1.4.9 → 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 +40 -27
- 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
|
|
@@ -1905,7 +1915,7 @@ class AIRich extends BaseBuilder {
|
|
|
1905
1915
|
* One image, no prompt, nothing to download — use this when you don't need the rich card,
|
|
1906
1916
|
* just the picture to show up immediately.
|
|
1907
1917
|
*/
|
|
1908
|
-
addImage(imageUrl, { resolveUrl = false, instant =
|
|
1918
|
+
addImage(imageUrl, { resolveUrl = false, instant = true } = {}) {
|
|
1909
1919
|
if (!(typeof imageUrl === 'string' || Buffer.isBuffer(imageUrl) || (Array.isArray(imageUrl) && imageUrl.every((v) => typeof v === 'string' || Buffer.isBuffer(v))))) {
|
|
1910
1920
|
throw new TypeError('imageUrl must be string | buffer | array of string/buffer');
|
|
1911
1921
|
}
|
|
@@ -1963,6 +1973,8 @@ class AIRich extends BaseBuilder {
|
|
|
1963
1973
|
}
|
|
1964
1974
|
|
|
1965
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.
|
|
1966
1978
|
this._inlineImages.push({ url: imagePreviewUrl, caption: undefined });
|
|
1967
1979
|
}
|
|
1968
1980
|
});
|
|
@@ -2040,7 +2052,7 @@ class AIRich extends BaseBuilder {
|
|
|
2040
2052
|
// for before rendering. Mirrors addImage()'s { resolveUrl } — when true, the url is uploaded to
|
|
2041
2053
|
// WA's own media server first via Toolkit.toUrl() so it renders instantly like WA-native media.
|
|
2042
2054
|
/** Add a video block. */
|
|
2043
|
-
addVideo(videoUrl, { autoFill = false, resolveUrl = false } = {}) {
|
|
2055
|
+
addVideo(videoUrl, { autoFill = false, resolveUrl = false, instant = true } = {}) {
|
|
2044
2056
|
const isObjectVideo = (v) => v && typeof v === 'object' && v.url;
|
|
2045
2057
|
|
|
2046
2058
|
const isValidPrimitive =
|
|
@@ -2117,6 +2129,15 @@ class AIRich extends BaseBuilder {
|
|
|
2117
2129
|
__typename: 'GenAIImaginePrimitive',
|
|
2118
2130
|
})
|
|
2119
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
|
+
}
|
|
2120
2141
|
});
|
|
2121
2142
|
|
|
2122
2143
|
return this;
|
|
@@ -2280,6 +2301,7 @@ class AIRich extends BaseBuilder {
|
|
|
2280
2301
|
__typename: 'GenAIImagePrimitive',
|
|
2281
2302
|
})
|
|
2282
2303
|
);
|
|
2304
|
+
this._mediaFallbacks.push({ type: 'image', url: full || preview, caption: undefined });
|
|
2283
2305
|
|
|
2284
2306
|
return this;
|
|
2285
2307
|
}
|
|
@@ -2619,12 +2641,6 @@ class AIRich extends BaseBuilder {
|
|
|
2619
2641
|
]
|
|
2620
2642
|
: [...(await waitAllPromises(this._sections))];
|
|
2621
2643
|
|
|
2622
|
-
// Vanz@Merge 15-08-26 --- Neither blurose nor arslan sign the bot metadata with
|
|
2623
|
-
// verificationMetadata (proofs/certificateChain). Backported from this project's own
|
|
2624
|
-
// rich-message-utils.js botMetadataSignature/botMetadataCertificate helpers, plus a
|
|
2625
|
-
// botResponseId tying the signed metadata to unifiedResponse.response_id.
|
|
2626
|
-
const responseId = crypto.randomUUID();
|
|
2627
|
-
|
|
2628
2644
|
return {
|
|
2629
2645
|
messageContextInfo: {
|
|
2630
2646
|
deviceListMetadata: {},
|
|
@@ -2632,17 +2648,6 @@ class AIRich extends BaseBuilder {
|
|
|
2632
2648
|
botMetadata: {
|
|
2633
2649
|
messageDisclaimerText: this._title,
|
|
2634
2650
|
richResponseSourcesMetadata: { sources: this._richResponseSources },
|
|
2635
|
-
botResponseId: responseId,
|
|
2636
|
-
verificationMetadata: {
|
|
2637
|
-
proofs: [
|
|
2638
|
-
{
|
|
2639
|
-
certificateChain: [botMetadataCertificate(), botMetadataCertificate(892)],
|
|
2640
|
-
version: 1,
|
|
2641
|
-
useCase: 1,
|
|
2642
|
-
signature: botMetadataSignature(),
|
|
2643
|
-
},
|
|
2644
|
-
],
|
|
2645
|
-
},
|
|
2646
2651
|
...notif,
|
|
2647
2652
|
},
|
|
2648
2653
|
},
|
|
@@ -2653,7 +2658,7 @@ class AIRich extends BaseBuilder {
|
|
|
2653
2658
|
messageType: 1,
|
|
2654
2659
|
submessages: includesSubmessages ? await waitAllPromises(this._submessages) : [],
|
|
2655
2660
|
unifiedResponse: {
|
|
2656
|
-
data: includesUnifiedResponse ? Buffer.from(JSON.stringify({ response_id:
|
|
2661
|
+
data: includesUnifiedResponse ? Buffer.from(JSON.stringify({ response_id: crypto.randomUUID(), sections })).toString('base64') : '',
|
|
2657
2662
|
},
|
|
2658
2663
|
contextInfo: {
|
|
2659
2664
|
...forward,
|
|
@@ -2677,17 +2682,21 @@ class AIRich extends BaseBuilder {
|
|
|
2677
2682
|
async send(jid, { forwarded, notification, includesUnifiedResponse, includesSubmessages, skipImageFallback = false, quoted, ...options } = {}) {
|
|
2678
2683
|
const msg = await this.build({ forwarded, notification, includesUnifiedResponse, includesSubmessages, quoted, ...options });
|
|
2679
2684
|
|
|
2680
|
-
if (!skipImageFallback && this.
|
|
2681
|
-
|
|
2685
|
+
if (!skipImageFallback && this._mediaFallbacks.length) {
|
|
2686
|
+
const fallbacks = await waitAllPromises(this._mediaFallbacks);
|
|
2687
|
+
for (const item of fallbacks) {
|
|
2682
2688
|
try {
|
|
2683
|
-
|
|
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 } : {});
|
|
2684
2695
|
} catch (err) {
|
|
2685
|
-
|
|
2686
|
-
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');
|
|
2687
2697
|
}
|
|
2688
2698
|
}
|
|
2689
2699
|
}
|
|
2690
|
-
|
|
2691
2700
|
return await this.#client.relayMessage(jid, msg, { ...options });
|
|
2692
2701
|
}
|
|
2693
2702
|
|
|
@@ -3362,6 +3371,9 @@ class AIRich extends BaseBuilder {
|
|
|
3362
3371
|
if (!Array.isArray(arr) || !arr.every((row) => Array.isArray(row) && row.every((cell) => typeof cell === 'string'))) {
|
|
3363
3372
|
throw new TypeError('Table must be a nested array of strings');
|
|
3364
3373
|
}
|
|
3374
|
+
if (arr.length === 0 || arr[0].length === 0) {
|
|
3375
|
+
throw new TypeError('Table must contain a non-empty header row');
|
|
3376
|
+
}
|
|
3365
3377
|
|
|
3366
3378
|
const [header, ...rows] = arr;
|
|
3367
3379
|
|
|
@@ -3545,6 +3557,7 @@ export {
|
|
|
3545
3557
|
AIRich,
|
|
3546
3558
|
AIRich as AIVanzxy,
|
|
3547
3559
|
AIRich as LeafRich,
|
|
3560
|
+
AIRich as LeafReach,
|
|
3548
3561
|
AIRich as VanzxyAI,
|
|
3549
3562
|
AIRich as VanzxyRich,
|
|
3550
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",
|