@vinzsocket/baileys 3.2.13 → 3.3.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 +5 -5
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/chats.js +10 -5
- package/lib/Socket/dugong.d.ts +46 -1
- package/lib/Socket/dugong.js +16 -3
- package/lib/Socket/socket.js +3 -0
- package/lib/Types/index.d.ts +1 -0
- package/lib/Utils/browser-utils.js +1 -0
- package/lib/Utils/generics.js +1 -1
- package/lib/Utils/tc-token-utils.js +3 -2
- package/lib/Utils/validate-connection.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
**Fork WebSocket library WhatsApp Web Multi-Device — dasar dari ekosistem bot Harps-MD**
|
|
6
6
|
|
|
7
7
|
[](https://github.com/VinzSocket/Baileys)
|
|
8
|
-

|
|
9
9
|

|
|
10
10
|

|
|
11
11
|

|
|
@@ -1218,7 +1218,7 @@ await conn.sendMessage(groupJid, {
|
|
|
1218
1218
|
})
|
|
1219
1219
|
```
|
|
1220
1220
|
|
|
1221
|
-
> ⚠️ **Penting:** sejak v3.
|
|
1221
|
+
> ⚠️ **Penting:** sejak v3.3.0, setiap mode `handleGroupStory()` **wajib** menyertakan `additionalNodes` (node `<meta is_vsn2="1">`) di panggilan `relayMessage()`-nya. Tanpa ini, pesan tetap terkirim & ter-enkripsi normal (tidak ada error), tapi klien penerima tidak tahu payload tersebut harus dirender sebagai story grup — sehingga tidak pernah muncul sebagai ring status untuk anggota lain. Detail lengkap bug ini ada di [Changelog v3.3.0](#-changelog-ringkas). Jika Anda memakai versi ≥ 3.3.0, ini sudah otomatis tertangani.
|
|
1222
1222
|
|
|
1223
1223
|
### Story Card Generator (`renderStoryCard`)
|
|
1224
1224
|
|
|
@@ -2318,7 +2318,7 @@ Jika handler lama Anda memiliki logic khusus untuk mem-parsing `buttonsResponseM
|
|
|
2318
2318
|
|
|
2319
2319
|
### Q: Bot terkoneksi tapi tombol/list yang saya kirim tidak muncul di HP penerima?
|
|
2320
2320
|
|
|
2321
|
-
**A:** Ini hampir selalu soal `additionalNodes` binary hint yang hilang. Jika Anda memakai `sock.sendMessage()` biasa, ini seharusnya sudah otomatis. Jika Anda memakai `relayMessage()` secara manual, pastikan menyertakan `buildInteractiveAdditionalNodes(jid, message)` — lihat bagian [`buildInteractiveAdditionalNodes`](#buildinteractiveadditionalnodes--kenapa-wajib-ada). Pastikan juga Anda sedang menjalankan versi ≥ 3.
|
|
2321
|
+
**A:** Ini hampir selalu soal `additionalNodes` binary hint yang hilang. Jika Anda memakai `sock.sendMessage()` biasa, ini seharusnya sudah otomatis. Jika Anda memakai `relayMessage()` secara manual, pastikan menyertakan `buildInteractiveAdditionalNodes(jid, message)` — lihat bagian [`buildInteractiveAdditionalNodes`](#buildinteractiveadditionalnodes--kenapa-wajib-ada). Pastikan juga Anda sedang menjalankan versi ≥ 3.3.0 untuk `groupStatusMessage`, karena bug ini pernah terjadi khusus untuk Group Status V2 sebelum versi tersebut.
|
|
2322
2322
|
|
|
2323
2323
|
### Q: Error `ERR_REQUIRE_ESM` saat `require('@vinzsocket/baileys')`?
|
|
2324
2324
|
|
|
@@ -2348,7 +2348,7 @@ Modul ini sengaja **lazy-imported** (tidak jadi hard dependency) supaya konsumen
|
|
|
2348
2348
|
|
|
2349
2349
|
### Q: Apakah Harps-Baileys mendukung WhatsApp Flow (form registrasi multi-field native)?
|
|
2350
2350
|
|
|
2351
|
-
**A:** Dukungan native multi-field Flow form (`flow_json` dengan banyak field terstruktur, validasi server-side, dsb — fitur "WhatsApp Flows" penuh) **belum diverifikasi tersedia** secara native di fork ini pada versi 3.
|
|
2351
|
+
**A:** Dukungan native multi-field Flow form (`flow_json` dengan banyak field terstruktur, validasi server-side, dsb — fitur "WhatsApp Flows" penuh) **belum diverifikasi tersedia** secara native di fork ini pada versi 3.3.0. Alternatif yang bisa dipakai sekarang adalah **form terpandu bertahap** (guided step-by-step): kirim serangkaian pertanyaan satu per satu memakai `interactiveMessage` biasa (teks/tombol/list) dan simpan progres jawaban di state percakapan bot Anda sendiri, alih-alih mengandalkan satu payload Flow form native. Jika kebutuhan Anda spesifik untuk Flow form penuh, pantau `CHANGELOG.md` untuk update fitur ini di rilis mendatang.
|
|
2352
2352
|
|
|
2353
2353
|
### Q: Pesan text saya yang mengandung URL tidak menampilkan link preview?
|
|
2354
2354
|
|
|
@@ -2870,7 +2870,7 @@ done
|
|
|
2870
2870
|
|
|
2871
2871
|
Riwayat perubahan lengkap ada di [`CHANGELOG.md`](./CHANGELOG.md). Ringkasan rilis terbaru:
|
|
2872
2872
|
|
|
2873
|
-
### v3.
|
|
2873
|
+
### v3.3.0 (2026-07-06) — Bug Fix Kritis Group Status
|
|
2874
2874
|
|
|
2875
2875
|
**Masalah:** status/story grup (`groupStatusMessage`) tidak pernah muncul sebagai ring status untuk anggota lain, walaupun `relayMessage()` berhasil tanpa error sama sekali.
|
|
2876
2876
|
|
package/lib/Defaults/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { proto } from '../../WAProto/index.js';
|
|
|
2
2
|
import { makeLibSignalRepository } from '../Signal/libsignal.js';
|
|
3
3
|
import { Browsers } from '../Utils/browser-utils.js';
|
|
4
4
|
import logger from '../Utils/logger.js';
|
|
5
|
-
const version = [2, 3000,
|
|
5
|
+
const version = [2, 3000, 1043857760];
|
|
6
6
|
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
7
|
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
8
8
|
export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
package/lib/Socket/chats.js
CHANGED
|
@@ -11,6 +11,13 @@ import { buildTcTokenFromJid } from '../Utils/tc-token-utils.js';
|
|
|
11
11
|
import { getBinaryNodeChild, getBinaryNodeChildren, isHostedLidUser, isHostedPnUser, isLidUser, isPnUser, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
12
12
|
import { USyncQuery, USyncUser } from '../WAUSync/index.js';
|
|
13
13
|
import { makeSocket } from './socket.js';
|
|
14
|
+
export const buildProfilePictureQueryContent = (type, tcTokenContent) => {
|
|
15
|
+
const picture = { tag: 'picture', attrs: { type, query: 'url' } };
|
|
16
|
+
if (tcTokenContent?.length) {
|
|
17
|
+
picture.content = tcTokenContent;
|
|
18
|
+
}
|
|
19
|
+
return [picture];
|
|
20
|
+
};
|
|
14
21
|
export const makeChatsSocket = (config) => {
|
|
15
22
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, getMessage } = config;
|
|
16
23
|
const sock = makeSocket(config);
|
|
@@ -546,7 +553,6 @@ export const makeChatsSocket = (config) => {
|
|
|
546
553
|
* type = "image for the high res picture"
|
|
547
554
|
*/
|
|
548
555
|
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
|
549
|
-
const baseContent = [{ tag: 'picture', attrs: { type, query: 'url' } }];
|
|
550
556
|
// WA Web only includes tctoken for user JIDs (not groups/newsletters)
|
|
551
557
|
// and never for own profile pic (Chat model for self has no tcToken).
|
|
552
558
|
// Including tctoken for own JID causes the server to never respond.
|
|
@@ -554,12 +560,11 @@ export const makeChatsSocket = (config) => {
|
|
|
554
560
|
const isUserJid = isPnUser(normalizedJid) || isLidUser(normalizedJid);
|
|
555
561
|
const me = authState.creds.me;
|
|
556
562
|
const isSelf = me && (normalizedJid === jidNormalizedUser(me.id) || (me.lid && normalizedJid === jidNormalizedUser(me.lid)));
|
|
557
|
-
let
|
|
563
|
+
let tcTokenContent;
|
|
558
564
|
if (serverProps.profilePicPrivacyToken && isUserJid && !isSelf) {
|
|
559
|
-
|
|
565
|
+
tcTokenContent = await buildTcTokenFromJid({
|
|
560
566
|
authState,
|
|
561
567
|
jid: normalizedJid,
|
|
562
|
-
baseContent,
|
|
563
568
|
getLIDForPN
|
|
564
569
|
});
|
|
565
570
|
}
|
|
@@ -572,7 +577,7 @@ export const makeChatsSocket = (config) => {
|
|
|
572
577
|
type: 'get',
|
|
573
578
|
xmlns: 'w:profile:picture'
|
|
574
579
|
},
|
|
575
|
-
content
|
|
580
|
+
content: buildProfilePictureQueryContent(type, tcTokenContent)
|
|
576
581
|
}, timeoutMs);
|
|
577
582
|
const child = getBinaryNodeChild(result, 'picture');
|
|
578
583
|
return child?.attrs?.url;
|
package/lib/Socket/dugong.d.ts
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
import type { proto } from '../../WAProto/index.js';
|
|
2
2
|
|
|
3
|
+
/** Bentuk umum satu tombol Native Flow (NF V7) — dipakai di semua nfButton* builder. */
|
|
4
|
+
export interface NativeFlowButton {
|
|
5
|
+
name: string;
|
|
6
|
+
buttonParamsJson: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface NfButtonRow {
|
|
11
|
+
id?: string;
|
|
12
|
+
rowId?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Kalau diisi, row ini otomatis di-flatten jadi section anak sendiri (nested). */
|
|
16
|
+
rows?: NfButtonRow[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NfButtonSection {
|
|
20
|
+
title?: string;
|
|
21
|
+
highlight_label?: string;
|
|
22
|
+
rows?: NfButtonRow[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare function nfButtonUrl(opts: { id?: string; displayText: string; url: string; merchantUrl?: string }): NativeFlowButton;
|
|
26
|
+
export declare function nfButtonCall(opts: { id?: string; displayText: string; phoneNumber: string }): NativeFlowButton;
|
|
27
|
+
export declare function nfButtonCopy(opts: { id?: string; displayText: string; copyCode: string }): NativeFlowButton;
|
|
28
|
+
export declare function nfButtonReminder(opts: { id?: string; displayText: string; title: string; notes?: string; startTime: number; endTime: number; timezone?: string }): NativeFlowButton;
|
|
29
|
+
export declare function nfButtonCancelReminder(opts: { id?: string; displayText: string; reminderKey: string }): NativeFlowButton;
|
|
30
|
+
export declare function nfButtonAddress(opts: { id?: string; displayText: string; label?: string }): NativeFlowButton;
|
|
31
|
+
export declare function nfButtonLocation(opts: { id?: string; displayText: string }): NativeFlowButton;
|
|
32
|
+
export declare function nfButtonQuickReply(opts: { id?: string; displayText: string; payload?: string }): NativeFlowButton;
|
|
33
|
+
export declare function nfButtonSingleSelect(opts: { id?: string; displayText: string; sections?: NfButtonSection[] }): NativeFlowButton;
|
|
34
|
+
/** Beberapa single_select sekaligus dalam 1 pesan — return array of buttons, bukan satu. */
|
|
35
|
+
export declare function nfButtonMultiSelect(selectors: Array<{ id?: string; displayText: string; sections?: NfButtonSection[] }>): NativeFlowButton[];
|
|
36
|
+
export declare function nfButtonReviewPay(opts: { id?: string; currency?: string; totalAmount1000: number; subtotal?: any; tax?: any; items?: any[]; merchant?: any }): NativeFlowButton;
|
|
37
|
+
export declare function nfButtonReviewOrder(opts: { id?: string; referenceId: string; type?: string; orderId: string }): NativeFlowButton;
|
|
38
|
+
export declare function nfButtonMPM(opts: { id?: string; sections?: Array<{ title?: string; productItems?: Array<{ productId?: string; product_id?: string }> }> }): NativeFlowButton;
|
|
39
|
+
|
|
40
|
+
/** Legacy listMessage builder — row dengan `rows` sendiri otomatis di-flatten jadi section baru. */
|
|
41
|
+
export declare function buildNestedListMessage(opts: {
|
|
42
|
+
title: string;
|
|
43
|
+
buttonText: string;
|
|
44
|
+
footer?: string;
|
|
45
|
+
sections?: NfButtonSection[];
|
|
46
|
+
}): { listMessage: any };
|
|
47
|
+
|
|
3
48
|
export type WAMediaUploadFunction = (stream: Buffer | NodeJS.ReadableStream, options?: {
|
|
4
49
|
fileEncSha256?: Buffer;
|
|
5
50
|
mediaType?: string;
|
|
@@ -260,7 +305,7 @@ export declare class ExtendedMessageBuilder {
|
|
|
260
305
|
|
|
261
306
|
handlePollResult(content: { pollResultMessage: PollResultMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
|
|
262
307
|
|
|
263
|
-
handleGroupStory(content: { groupStatusMessage: GroupStatusMessage }, jid: string): Promise<any>;
|
|
308
|
+
handleGroupStory(content: { groupStatusMessage: GroupStatusMessage }, jid: string, quoted?: proto.IWebMessageInfo | null): Promise<any>;
|
|
264
309
|
|
|
265
310
|
/**
|
|
266
311
|
* Kirim WhatsApp Status (story) sungguhan ke `status@broadcast`, mendukung
|
package/lib/Socket/dugong.js
CHANGED
|
@@ -348,7 +348,7 @@ export class ExtendedMessageBuilder {
|
|
|
348
348
|
* dirender sebagai story/status grup — pesan tetap terkirim & ter-enkripsi
|
|
349
349
|
* normal, tapi tidak pernah muncul sebagai ring status untuk member lain.
|
|
350
350
|
*/
|
|
351
|
-
async handleGroupStory(content, jid) {
|
|
351
|
+
async handleGroupStory(content, jid, quoted) {
|
|
352
352
|
const s = content.groupStatusMessage;
|
|
353
353
|
const secret = randomBytes(32);
|
|
354
354
|
const buildNodes = this.utils.buildInteractiveAdditionalNodes;
|
|
@@ -385,8 +385,21 @@ export class ExtendedMessageBuilder {
|
|
|
385
385
|
|
|
386
386
|
// Mode 3: generate dari media/teks
|
|
387
387
|
let innerMessage = {};
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
// PATCH: normalize mentions (terima nomor polos, bukan cuma JID lengkap — biar konsisten
|
|
389
|
+
// sama handleInteractive) dan sisipkan quoted-reply (stanzaId/participant/quotedMessage).
|
|
390
|
+
// Sebelumnya dua-duanya "keisi" secara visual tapi diam-diam gak ke-apply: s.mentions gak
|
|
391
|
+
// pernah dilewatin ke normalizeMentions(), dan param quoted malah belum ada sama sekali di
|
|
392
|
+
// signature function ini padahal messages-send.js (swgc & case 'GROUP_STORY') udah ngoper dia.
|
|
393
|
+
const normalizedMentions = normalizeMentions(s.mentions);
|
|
394
|
+
const quoteCtx = quoted?.key
|
|
395
|
+
? {
|
|
396
|
+
stanzaId: quoted.key.id,
|
|
397
|
+
participant: quoted.key.participant || quoted.key.remoteJid,
|
|
398
|
+
quotedMessage: quoted.message
|
|
399
|
+
}
|
|
400
|
+
: {};
|
|
401
|
+
const mentionCtx = (normalizedMentions.length || Object.keys(quoteCtx).length)
|
|
402
|
+
? { contextInfo: { ...quoteCtx, ...(normalizedMentions.length ? { mentionedJid: normalizedMentions } : {}) } }
|
|
390
403
|
: {};
|
|
391
404
|
|
|
392
405
|
if (s.text || (!s.image && !s.video && !s.gif && !s.audio && !s.sticker && !s.document)) {
|
package/lib/Socket/socket.js
CHANGED
|
@@ -27,6 +27,9 @@ export const makeSocket = (config) => {
|
|
|
27
27
|
if (printQRInTerminal) {
|
|
28
28
|
logger.warn({}, '⚠️ The printQRInTerminal option has been deprecated. You will no longer receive QR codes in the terminal automatically. Please listen to the connection.update event yourself and handle the QR your way. You can remove this message by removing this opttion. This message will be removed in a future version.');
|
|
29
29
|
}
|
|
30
|
+
if (browser[1].toLocaleLowerCase().includes('android')) {
|
|
31
|
+
logger.warn('⚠️ Using the Android browser is experimental and may lead to unexpected behavior. Use at your own risk.');
|
|
32
|
+
}
|
|
30
33
|
const syncDisabled = PROCESSABLE_HISTORY_TYPES.map(syncType => config.shouldSyncHistoryMessage({ syncType })).filter(x => x === false)
|
|
31
34
|
.length === PROCESSABLE_HISTORY_TYPES.length;
|
|
32
35
|
if (syncDisabled) {
|
package/lib/Types/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type BrowsersMap = {
|
|
|
20
20
|
macOS(browser: string): [string, string, string];
|
|
21
21
|
baileys(browser: string): [string, string, string];
|
|
22
22
|
windows(browser: string): [string, string, string];
|
|
23
|
+
android(browser: string): [string, string, string];
|
|
23
24
|
appropriate(browser: string): [string, string, string];
|
|
24
25
|
};
|
|
25
26
|
export declare enum DisconnectReason {
|
|
@@ -18,6 +18,7 @@ export const Browsers = {
|
|
|
18
18
|
macOS: browser => ['Mac OS', browser, '14.4.1'],
|
|
19
19
|
baileys: browser => ['Baileys', browser, '6.5.0'],
|
|
20
20
|
windows: browser => ['Windows', browser, '10.0.22631'],
|
|
21
|
+
android: browser => [browser, 'Android', ''],
|
|
21
22
|
/** The appropriate browser based on your OS & release */
|
|
22
23
|
appropriate: browser => [PLATFORM_MAP[platform()] || 'Ubuntu', browser, release()]
|
|
23
24
|
};
|
package/lib/Utils/generics.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
2
|
import { createHash, randomBytes } from 'crypto';
|
|
3
3
|
import { proto } from '../../WAProto/index.js';
|
|
4
|
-
const baileysVersion = [2, 3000,
|
|
4
|
+
const baileysVersion = [2, 3000, 1043857760];
|
|
5
5
|
import { DisconnectReason } from '../Types/index.js';
|
|
6
6
|
import { getAllBinaryNodeChildren, jidDecode } from '../WABinary/index.js';
|
|
7
7
|
import { sha256 } from './crypto.js';
|
|
@@ -102,7 +102,8 @@ export async function buildTcTokenFromJid({ authState, jid, baseContent = [], ge
|
|
|
102
102
|
const tcTokenData = await authState.keys.get('tctoken', [storageJid]);
|
|
103
103
|
const entry = tcTokenData?.[storageJid];
|
|
104
104
|
const tcTokenBuffer = entry?.token;
|
|
105
|
-
|
|
105
|
+
const timestamp = entry?.timestamp;
|
|
106
|
+
if (!tcTokenBuffer?.length || timestamp === undefined || isTcTokenExpired(timestamp)) {
|
|
106
107
|
if (tcTokenBuffer) {
|
|
107
108
|
// Preserve senderTimestamp so shouldSendNewTcToken() keeps its dedupe state
|
|
108
109
|
// after we drop the unusable peer token. Only wipe the record entirely when
|
|
@@ -116,7 +117,7 @@ export async function buildTcTokenFromJid({ authState, jid, baseContent = [], ge
|
|
|
116
117
|
}
|
|
117
118
|
baseContent.push({
|
|
118
119
|
tag: 'tctoken',
|
|
119
|
-
attrs: {},
|
|
120
|
+
attrs: { t: String(timestamp) },
|
|
120
121
|
content: tcTokenBuffer
|
|
121
122
|
});
|
|
122
123
|
return baseContent;
|
|
@@ -13,7 +13,9 @@ const getUserAgent = (config) => {
|
|
|
13
13
|
secondary: config.version[1],
|
|
14
14
|
tertiary: config.version[2]
|
|
15
15
|
},
|
|
16
|
-
platform:
|
|
16
|
+
platform: config.browser[1].toLocaleLowerCase().includes('android')
|
|
17
|
+
? proto.ClientPayload.UserAgent.Platform.ANDROID
|
|
18
|
+
: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
17
19
|
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
18
20
|
osVersion: '0.1',
|
|
19
21
|
device: 'Desktop',
|
|
@@ -43,7 +45,9 @@ const getClientPayload = (config) => {
|
|
|
43
45
|
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
44
46
|
userAgent: getUserAgent(config)
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
if (!config.browser[1].toLocaleLowerCase().includes('android')) {
|
|
49
|
+
payload.webInfo = getWebInfo(config);
|
|
50
|
+
}
|
|
47
51
|
if (config.pushName) {
|
|
48
52
|
payload.pushName = config.pushName;
|
|
49
53
|
}
|
|
@@ -64,6 +68,9 @@ export const generateLoginNode = (userJid, config) => {
|
|
|
64
68
|
};
|
|
65
69
|
const getPlatformType = (platform) => {
|
|
66
70
|
const platformType = platform.toUpperCase();
|
|
71
|
+
if (platformType === 'ANDROID') {
|
|
72
|
+
return proto.DeviceProps.PlatformType.ANDROID_PHONE;
|
|
73
|
+
}
|
|
67
74
|
return (proto.DeviceProps.PlatformType[platformType] ||
|
|
68
75
|
proto.DeviceProps.PlatformType.CHROME);
|
|
69
76
|
};
|