@rennzsync/baileys 10.2.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.id.md +261 -0
- package/README.md +359 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +5479 -0
- package/WAProto/fix-imports.js +85 -0
- package/WAProto/index.d.ts +14017 -0
- package/WAProto/index.js +97691 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +129 -0
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.js +428 -0
- package/lib/Signal/lid-mapping.js +276 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +54 -0
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +1198 -0
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +347 -0
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +12 -0
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +1772 -0
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +1196 -0
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +42 -0
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +181 -0
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +970 -0
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/keyed-db.js +108 -0
- package/lib/Store/make-cache-manager-store.js +70 -0
- package/lib/Store/make-in-memory-store.js +417 -0
- package/lib/Store/make-ordered-dictionary.js +69 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +37 -0
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +3 -0
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +56 -0
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +26 -0
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +302 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +29 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +231 -0
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +872 -0
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +35 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +118 -0
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +317 -0
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +622 -0
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +393 -0
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +134 -0
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +50 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +27 -0
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +85 -0
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +8 -0
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +33 -0
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/media-processor.js +173 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +265 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +811 -0
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +973 -0
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +201 -0
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +630 -0
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/rich-carousel.js +205 -0
- package/lib/Utils/rich-classic.js +124 -0
- package/lib/Utils/rich-webui.js +133 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +201 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +49 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +164 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/use-sqlite-auth-state.js +162 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +210 -0
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1301 -0
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +262 -0
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +220 -0
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +182 -0
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +6 -0
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +96 -0
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -0
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +6 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +98 -0
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +31 -0
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/package.json +80 -0
package/README.id.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# renz/baileys
|
|
4
|
+
|
|
5
|
+
**Library bot WhatsApp ringan — rebase penuh ke `@whiskeysockets/baileys` 7.0.0-rc14**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@renz/baileys)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
[](https://github.com/WhiskeySockets/Baileys)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
**[Read in English → README.md](README.md)**
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
Library WhatsApp Multi-Device yang direbase penuh ke Baileys v7 rc14, memakai engine Signal Protocol asli (`libsignal`, GPL-3.0) — sama seperti yang dipakai stock `@whiskeysockets/baileys` rc14.
|
|
17
|
+
|
|
18
|
+
> **Catatan lisensi:** kode `renz/baileys` sendiri MIT, tapi bergantung ke `libsignal` (GPL-3.0) saat runtime buat crypto Signal Protocol-nya. Kalau mau publish/redistribusikan package ini, cek dulu implikasi kepatuhan GPL-3.0-nya buat kebutuhanmu — ini bukan nasihat hukum.
|
|
19
|
+
|
|
20
|
+
Fokus proyek ini: **bot WhatsApp multi-media** — kirim/terima audio, video, gambar, stiker, dan **Rich WebUI** (antarmuka HTML inline di dalam bubble chat), dengan konfigurasi default yang hemat RAM.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Fitur Utama
|
|
25
|
+
|
|
26
|
+
- **Paritas Baileys 7.0.0-rc14** — TC-token lengkap (trusted contact token dengan expiry & re-issue), Signal Repository API v7 (`getSessionInfo`, `hasSenderKey`, `getSenderKeyDistributionMessage`), format QR/pairing terbaru, penanganan reachout timelock.
|
|
27
|
+
- **Engine Signal Protocol standar** — pakai `libsignal` langsung, sama seperti stock Baileys rc14; nggak ada native crypto custom yang perlu dirawat.
|
|
28
|
+
- **Pipeline multi-media terpusat** — utilitas `media-processor` (ffmpeg/sharp/audio-decode, lazy-load).
|
|
29
|
+
- **Rich WebUI** — render antarmuka HTML/CSS/JS langsung di bubble chat via `sendInlineWebUI`.
|
|
30
|
+
- **RAM-friendly by default** — `syncFullHistory: false`, `enableRecentMessageCache: false`, TTL cache moderat.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Syarat
|
|
35
|
+
|
|
36
|
+
| Kebutuhan | Versi |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Node.js | >= 20.0.0 |
|
|
39
|
+
|
|
40
|
+
Dukungan platform ngikutin apa yang didukung `libsignal` (^6.0.0) di sistemmu — cek dokumentasi package itu buat detail prebuilt binary/platform-nya.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Instalasi
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @renz/baileys
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Dependency opsional (install sesuai fitur)
|
|
51
|
+
|
|
52
|
+
| Package | Untuk fitur |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `audio-decode` | Waveform voice note (`ptt: true`) — **wajib untuk voice note** |
|
|
55
|
+
| `sharp` | Resize/kompres gambar |
|
|
56
|
+
| `fluent-ffmpeg` | Konversi video/audio, thumbnail video |
|
|
57
|
+
| `jimp` | Thumbnail alternatif (tanpa sharp) |
|
|
58
|
+
| `link-preview-js` | Link preview |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import makeWASocket, { useMultiFileAuthState } from '@renz/baileys';
|
|
66
|
+
|
|
67
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info');
|
|
68
|
+
|
|
69
|
+
const sock = makeWASocket({
|
|
70
|
+
auth: state,
|
|
71
|
+
printQRInTerminal: true
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
sock.ev.on('creds.update', saveCreds);
|
|
75
|
+
|
|
76
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
77
|
+
const msg = messages[0];
|
|
78
|
+
if (!msg.message || msg.key.fromMe) return;
|
|
79
|
+
|
|
80
|
+
const jid = msg.key.remoteJid;
|
|
81
|
+
const text = msg.message.conversation || msg.message.extendedTextMessage?.text || '';
|
|
82
|
+
|
|
83
|
+
if (text === '!ping') {
|
|
84
|
+
await sock.sendMessage(jid, { text: 'pong' }, { quoted: msg });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Contoh: Multi-Media
|
|
92
|
+
|
|
93
|
+
### Kirim gambar dengan caption
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
await sock.sendMessage(jid, {
|
|
97
|
+
image: { url: 'https://example.com/foto.jpg' },
|
|
98
|
+
caption: 'Halo!'
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Kirim voice note (PTT)
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
// butuh: npm install audio-decode
|
|
106
|
+
await sock.sendMessage(jid, {
|
|
107
|
+
audio: { url: './voice.ogg' },
|
|
108
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
109
|
+
ptt: true
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Konversi video/audio sebelum kirim (media-processor)
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import { convertToWhatsAppVideo, convertToOpusAudio, getVideoThumbnail, resizeImage } from '@renz/baileys';
|
|
117
|
+
|
|
118
|
+
// Video apapun -> MP4/H.264 kompatibel WhatsApp (butuh fluent-ffmpeg)
|
|
119
|
+
const mp4 = await convertToWhatsAppVideo(bufferMentah);
|
|
120
|
+
await sock.sendMessage(jid, { video: mp4, caption: 'Video terkonversi' });
|
|
121
|
+
|
|
122
|
+
// Audio apapun -> OGG/Opus untuk voice note
|
|
123
|
+
const opus = await convertToOpusAudio(bufferAudio);
|
|
124
|
+
|
|
125
|
+
// Thumbnail video & resize gambar (butuh sharp)
|
|
126
|
+
const thumb = await getVideoThumbnail(mp4, 1);
|
|
127
|
+
const small = await resizeImage(imageBuffer, { width: 300, height: 300 });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Probe metadata media
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
import { probeMedia, getMp4Duration } from '@renz/baileys';
|
|
134
|
+
|
|
135
|
+
const meta = await probeMedia(buffer, 'audio/mpeg'); // { duration, bitrate, container, codec }
|
|
136
|
+
const dur = getMp4Duration(mp4Buffer); // tanpa ffmpeg — parse atom langsung
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Contoh: Rich WebUI (HTML inline di bubble chat)
|
|
142
|
+
|
|
143
|
+
Kirim antarmuka HTML/CSS/JS yang **ter-render langsung di dalam pesan** — cocok untuk menu interaktif, mini-app, dashboard:
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
import { sendInlineWebUI } from '@renz/baileys';
|
|
147
|
+
|
|
148
|
+
const html = `<!DOCTYPE html>
|
|
149
|
+
<html><head><style>body{background:#111b21;color:#fff;font-family:sans-serif;padding:16px}</style></head>
|
|
150
|
+
<body><h2>Menu Bot</h2><button onclick="alert('hai')">Tekan aku</button></body></html>`;
|
|
151
|
+
|
|
152
|
+
await sendInlineWebUI(sock, jid, html, 'Menu Bot');
|
|
153
|
+
|
|
154
|
+
// Identitas bisa di-override (default: Meta AI)
|
|
155
|
+
await sendInlineWebUI(sock, jid, html, 'Menu Bot', {
|
|
156
|
+
botJid: '12345@bot',
|
|
157
|
+
forwardOrigin: 'CUSTOM'
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> Catatan: nama primitive HTML (`GenAIaeacdsnwHtmlPrimitive`) adalah identifier obfuscated WhatsApp Web dan bisa berubah antar versi. Jika WebUI berhenti ter-render, update identifier dari bundle WA Web terbaru.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Store & auth SQLite (baru di 10.1.0)
|
|
166
|
+
|
|
167
|
+
`lib/Store/*` nyediain store chat/kontak/pesan yang bisa dicolok ke `sock.ev`, plus dua backend auth-state:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
import makeWASocket, { makeInMemoryStore, useSqliteAuthState, useMultiFileAuthState } from '@renz/baileys';
|
|
171
|
+
|
|
172
|
+
const store = makeInMemoryStore({});
|
|
173
|
+
store.readFromFile('./store.json');
|
|
174
|
+
setInterval(() => store.writeToFile('./store.json'), 10_000);
|
|
175
|
+
|
|
176
|
+
// Auth pakai SQLite (butuh Node >= 22.5, node:sqlite bawaan — throw error jelas di Node lebih lama)
|
|
177
|
+
const { state, saveCreds } = await useSqliteAuthState('./auth.db');
|
|
178
|
+
// atau tetap pakai yang berbasis file:
|
|
179
|
+
// const { state, saveCreds } = await useMultiFileAuthState('auth_info');
|
|
180
|
+
|
|
181
|
+
const sock = makeWASocket({ auth: state });
|
|
182
|
+
store.bind(sock.ev);
|
|
183
|
+
sock.ev.on('creds.update', saveCreds);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`makeCacheManagerAuthState` juga tersedia kalau mau nyimpen auth state pakai store `cache-manager` (peer dependency opsional, cuma wajib kalau beneran dipakai).
|
|
187
|
+
|
|
188
|
+
`sock.sendMessage(jid, content, { isSecret, protected, me })` — tiga filter device/recipient tambahan hasil port dari `@vansnowi/baileys`, langsung diteruskan ke `relayMessage`.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Poll gambar (baru di 10.2.0)
|
|
193
|
+
|
|
194
|
+
Kirim poll yang tiap opsinya berupa gambar, bukan teks biasa (`pollCreationMessageV3` dengan `pollContentType: IMAGE`, satu `pollCreationOptionImageMessage` per opsi, terhubung ke poll induk lewat asosiasi `MEDIA_POLL`):
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { generateWAMessageFromImagePoll } from '@renz/baileys';
|
|
198
|
+
|
|
199
|
+
await generateWAMessageFromImagePoll(jid, {
|
|
200
|
+
name: 'Pilih gambar favorit',
|
|
201
|
+
selectableCount: 1,
|
|
202
|
+
options: [
|
|
203
|
+
{ name: 'Gambar 1', image: { url: 'https://example.com/1.jpg' } },
|
|
204
|
+
{ name: 'Gambar 2', image: { url: 'https://example.com/2.jpg' } },
|
|
205
|
+
]
|
|
206
|
+
}, (msg, opts) => sock.relayMessage(jid, msg, opts), { upload: sock.waUploadToServer });
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`hashImagePollOption(optionName, fileSha256)` juga di-export terpisah kalau cuma butuh hash opsi tanpa flow kirim lengkap. Catatan: ini implementasi sisi-klien buat tipe pesan yang protonya udah ada di WhatsApp tapi belum ada fork Baileys manapun (termasuk upstream) yang bikin builder-nya — anggap eksperimental, coba dulu di WA client target sebelum dipakai produksi.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Konfigurasi Default (RAM-friendly)
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
const sock = makeWASocket({
|
|
217
|
+
auth: state,
|
|
218
|
+
// default sudah irit; override bila perlu:
|
|
219
|
+
syncFullHistory: false, // tidak menarik riwayat chat penuh
|
|
220
|
+
enableRecentMessageCache: false, // tidak menyimpan pesan terbaru di RAM
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Breaking Changes dari 9.x (oktz-baileys lama)
|
|
227
|
+
|
|
228
|
+
- Base direbase ke Baileys **7.0.0-rc14** (bukan lagi ourin-baileys 9.0.21).
|
|
229
|
+
- Modul yang **dihapus**: `lib/VoIP/*` (call client WebRTC), `Modded/message_builder.js`, `Utils/rich-messages.js`, `Socket/dugong.js`, `Utils/sticker-pack.js`.
|
|
230
|
+
- `rejectCall` tetap tersedia (core `messages-recv`).
|
|
231
|
+
- Pengganti rich message lama: `rich-webui.js` (`sendInlineWebUI`, `buildWebuiMessage`).
|
|
232
|
+
- **Rebrand:** package berganti nama jadi `@renz/baileys`, kini dirawat oleh [RennZz-Dev](https://github.com/RennZSync). Tidak ada perubahan API — cukup ganti import dari `onigis` ke `@renz/baileys`.
|
|
233
|
+
- **Signal engine balik ke stock:** engine custom `@renz/signal`/`@renz/curve25519` (MIT, native Rust) dilepas, balik pakai `libsignal` (GPL-3.0) asli seperti stock Baileys rc14 — implementasi Signal Protocol sama, tanpa native binary custom lagi. Lihat catatan lisensi di bagian atas file ini.
|
|
234
|
+
- Default config berubah: `syncFullHistory` dan `enableRecentMessageCache` kini `false`.
|
|
235
|
+
- `protobufjs-cli` dipin ke `^1.1.3` (fix konflik peer dependency); `link-preview-js` ke `^5.0.0` (fix advisory SSRF).
|
|
236
|
+
- **10.1.0:** gabung `lib/Store/*` (in-memory store, cache-manager store, keyed-db/ordered-dictionary/object-repository) dari `@vansnowi/baileys`, plus `useSqliteAuthState` (Node 22.5+, `node:sqlite` bawaan, fallback error jelas di Node lama) dan filter kirim `isSecret`/`protected`/`me` di `sock.sendMessage`.
|
|
237
|
+
- **10.2.0:** tambah `generateWAMessageFromImagePoll` / `hashImagePollOption` — builder sisi-klien buat tipe pesan image-poll WhatsApp (`pollCreationMessageV3` + `pollCreationOptionImageMessage`, asosiasi `MEDIA_POLL`). Eksperimental — belum ada fork Baileys manapun yang punya ini.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Testing
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npm test
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Termasuk unit test: JID utils (PN/LID/hosted), Rich WebUI (build + roundtrip proto encode/decode).
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Kredit
|
|
252
|
+
|
|
253
|
+
- **[RennZz-Dev](https://github.com/RennZSync)** — maintainer `renz/baileys`: rebrand, perawatan & penyesuaian untuk kebutuhan bot
|
|
254
|
+
- **[KzorArsuy](https://github.com/rozzak2009)** — audit, rebase rc14, optimasi, multimedia & WebUI
|
|
255
|
+
- **[WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)** — upstream library & wrapper Signal Protocol asli (berbasis `libsignal`)
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Lisensi
|
|
260
|
+
|
|
261
|
+
**MIT** untuk kode `renz/baileys` sendiri — tapi bergantung ke `libsignal` (GPL-3.0) saat runtime buat crypto Signal Protocol. Cek dulu implikasinya buat kebutuhanmu sebelum redistribusi.
|
package/README.md
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# renz/baileys
|
|
4
|
+
|
|
5
|
+
**Lightweight WhatsApp Bot library — fully rebased onto `@whiskeysockets/baileys` 7.0.0-rc14**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@renz/baileys)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
[](https://github.com/WhiskeySockets/Baileys)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
**[Baca dalam Bahasa Indonesia → README.id.md](README.id.md)**
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
A WhatsApp Multi-Device library rebased onto Baileys v7 rc14, using the original Signal Protocol engine (`libsignal`, GPL-3.0) — the same one stock `@whiskeysockets/baileys` rc14 ships with.
|
|
17
|
+
|
|
18
|
+
> **License note:** `renz/baileys`'s own code is MIT, but it depends on `libsignal` (GPL-3.0) at runtime for the Signal Protocol crypto. If you're publishing or redistributing this package, check what GPL-3.0 compliance means for your use case — this isn't legal advice.
|
|
19
|
+
|
|
20
|
+
Project focus: **multimedia WhatsApp bots** — audio, video, image and sticker pipelines, plus **Rich WebUI** (inline HTML interfaces rendered inside chat bubbles), with RAM-friendly defaults.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Highlights
|
|
25
|
+
|
|
26
|
+
- **Full Baileys 7.0.0-rc14 parity** — complete TC-token implementation (trusted contact tokens with expiry & re-issue), Signal Repository API v7 (`getSessionInfo`, `hasSenderKey`, `getSenderKeyDistributionMessage`), new QR/pairing format, reachout timelock handling.
|
|
27
|
+
- **Standard Signal Protocol engine** — uses `libsignal` directly, same as stock Baileys rc14; no custom native crypto to maintain.
|
|
28
|
+
- **Centralized multimedia pipeline** — `media-processor` utilities (ffmpeg/sharp/audio-decode, lazy-loaded).
|
|
29
|
+
- **Rich WebUI** — render HTML/CSS/JS interfaces directly inside chat bubbles via `sendInlineWebUI`.
|
|
30
|
+
- **RAM-friendly by default** — `syncFullHistory: false`, `enableRecentMessageCache: false`, moderate cache TTLs.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
| Requirement | Version |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Node.js | >= 20.0.0 |
|
|
39
|
+
|
|
40
|
+
Platform support follows whatever `libsignal` (^6.0.0) supports on your system — see that package's own docs for prebuilt binary/platform coverage.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @renz/baileys
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Optional dependencies (install per feature)
|
|
51
|
+
|
|
52
|
+
| Package | Feature |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `audio-decode` | Voice note waveform (`ptt: true`) — **required for voice notes** |
|
|
55
|
+
| `sharp` | Image resize/compression |
|
|
56
|
+
| `fluent-ffmpeg` | Video/audio conversion, video thumbnails |
|
|
57
|
+
| `jimp` | Alternative thumbnails (without sharp) |
|
|
58
|
+
| `link-preview-js` | Link previews |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import makeWASocket, { useMultiFileAuthState } from '@renz/baileys';
|
|
66
|
+
|
|
67
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_info');
|
|
68
|
+
|
|
69
|
+
const sock = makeWASocket({
|
|
70
|
+
auth: state,
|
|
71
|
+
printQRInTerminal: true
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
sock.ev.on('creds.update', saveCreds);
|
|
75
|
+
|
|
76
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
77
|
+
const msg = messages[0];
|
|
78
|
+
if (!msg.message || msg.key.fromMe) return;
|
|
79
|
+
|
|
80
|
+
const jid = msg.key.remoteJid;
|
|
81
|
+
const text = msg.message.conversation || msg.message.extendedTextMessage?.text || '';
|
|
82
|
+
|
|
83
|
+
if (text === '!ping') {
|
|
84
|
+
await sock.sendMessage(jid, { text: 'pong' }, { quoted: msg });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Examples: Multimedia
|
|
92
|
+
|
|
93
|
+
### Send an image with caption
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
await sock.sendMessage(jid, {
|
|
97
|
+
image: { url: 'https://example.com/photo.jpg' },
|
|
98
|
+
caption: 'Hello!'
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Send a voice note (PTT)
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
// requires: npm install audio-decode
|
|
106
|
+
await sock.sendMessage(jid, {
|
|
107
|
+
audio: { url: './voice.ogg' },
|
|
108
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
109
|
+
ptt: true
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Convert video/audio before sending (media-processor)
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import { convertToWhatsAppVideo, convertToOpusAudio, getVideoThumbnail, resizeImage } from '@renz/baileys';
|
|
117
|
+
|
|
118
|
+
// Any video -> WhatsApp-compatible MP4/H.264 (requires fluent-ffmpeg)
|
|
119
|
+
const mp4 = await convertToWhatsAppVideo(rawBuffer);
|
|
120
|
+
await sock.sendMessage(jid, { video: mp4, caption: 'Converted video' });
|
|
121
|
+
|
|
122
|
+
// Any audio -> OGG/Opus for voice notes
|
|
123
|
+
const opus = await convertToOpusAudio(audioBuffer);
|
|
124
|
+
|
|
125
|
+
// Video thumbnail & image resize (requires sharp)
|
|
126
|
+
const thumb = await getVideoThumbnail(mp4, 1);
|
|
127
|
+
const small = await resizeImage(imageBuffer, { width: 300, height: 300 });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Probe media metadata
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
import { probeMedia, getMp4Duration } from '@renz/baileys';
|
|
134
|
+
|
|
135
|
+
const meta = await probeMedia(buffer, 'audio/mpeg'); // { duration, bitrate, container, codec }
|
|
136
|
+
const dur = getMp4Duration(mp4Buffer); // no ffmpeg needed — parses atoms directly
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Examples: Rich WebUI (inline HTML in chat bubbles)
|
|
142
|
+
|
|
143
|
+
Send an HTML/CSS/JS interface that **renders directly inside the message bubble** — great for interactive menus, mini-apps and dashboards:
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
import { sendInlineWebUI } from '@renz/baileys';
|
|
147
|
+
|
|
148
|
+
const html = `<!DOCTYPE html>
|
|
149
|
+
<html><head><style>body{background:#111b21;color:#fff;font-family:sans-serif;padding:16px}</style></head>
|
|
150
|
+
<body><h2>Bot Menu</h2><button onclick="alert('hi')">Press me</button></body></html>`;
|
|
151
|
+
|
|
152
|
+
await sendInlineWebUI(sock, jid, html, 'Bot Menu');
|
|
153
|
+
|
|
154
|
+
// Identity can be overridden (default: Meta AI)
|
|
155
|
+
await sendInlineWebUI(sock, jid, html, 'Bot Menu', {
|
|
156
|
+
botJid: '12345@bot',
|
|
157
|
+
forwardOrigin: 'CUSTOM'
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> Note: the HTML primitive name (`GenAIaeacdsnwHtmlPrimitive`) is an obfuscated WhatsApp Web identifier and may change between WA versions. If the WebUI stops rendering, update the identifier from the latest WA Web bundle.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Examples: Classic buttons & lists (render everywhere, new in 10.0.1)
|
|
166
|
+
|
|
167
|
+
`interactiveMessage` + `nativeFlowMessage` cards are **no longer rendered** on many WhatsApp clients — `relayMessage` succeeds without error but the message silently doesn't appear. The classic `buttonsMessage` and `listMessage` templates render reliably on **every** client (Android/iOS/Web/Desktop).
|
|
168
|
+
|
|
169
|
+
`@renz/baileys@10.0.2` ships ready-made builders in `lib/Utils/rich-classic.js`:
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
import { buildButtonsMessage, buildListMessage, sendClassicMessage } from '@renz/baileys';
|
|
173
|
+
|
|
174
|
+
// 1-3 quick-reply buttons (optionally with a location+thumbnail header)
|
|
175
|
+
const buttons = buildButtonsMessage({
|
|
176
|
+
text: 'Hello Brother — pick an option',
|
|
177
|
+
footer: '© My Bot',
|
|
178
|
+
buttons: [
|
|
179
|
+
{ buttonId: '.owner', buttonText: '🧀 Owner' },
|
|
180
|
+
{ buttonId: '.allmenu', buttonText: '💐 Allmenu' },
|
|
181
|
+
],
|
|
182
|
+
locationMessage: { jpegThumbnail, name: 'My Bot', address: 'v10.0.1' },
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Scrollable list with sections and rows
|
|
186
|
+
const list = buildListMessage({
|
|
187
|
+
title: '🍃 Menu — 1271 commands',
|
|
188
|
+
description: 'Pick a category',
|
|
189
|
+
buttonText: '🍃 Pilih Kategori',
|
|
190
|
+
sections: [{
|
|
191
|
+
title: 'Categories',
|
|
192
|
+
rows: [
|
|
193
|
+
{ title: '🏠 main', description: '19 commands', rowId: '.menucat main' },
|
|
194
|
+
{ title: '🎨 sticker', description: '42 commands', rowId: '.menucat sticker' },
|
|
195
|
+
],
|
|
196
|
+
}],
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Send via relayMessage — userJid is normalized automatically
|
|
200
|
+
// (handles sock.user.id vs the legacy non-existent sock.user.jid)
|
|
201
|
+
await sendClassicMessage(sock, jid, buttons);
|
|
202
|
+
await sendClassicMessage(sock, jid, list);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Also exports `normalizeUserJid(sockOrUserOrJid)` — `sock.user.jid` never existed in baileys 7.x (`sock.user` is `creds.me`, which has `.id`); this helper accepts any shape and returns a valid jid.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Examples: Carousel & native-flow buttons (new in 10.0.3, risk-aware)
|
|
210
|
+
|
|
211
|
+
`lib/Utils/rich-carousel.js` adds `interactiveMessage`/`carouselMessage` builders (the horizontal-scroll card format), for cases where you specifically need carousel or richer CTA button types (`cta_url`, `cta_call`, `cta_copy`, `cta_reminder`, `single_select`) that the classic templates above don't cover. Same rendering caveat as always: prefer `rich-classic.js` unless you specifically need these.
|
|
212
|
+
|
|
213
|
+
```js
|
|
214
|
+
import { buildCarouselMessage, sendCarouselMessage, sendInteractiveMessage } from '@renz/baileys';
|
|
215
|
+
|
|
216
|
+
// single native-flow bubble (no carousel)
|
|
217
|
+
await sendInteractiveMessage(sock, jid, {
|
|
218
|
+
text: 'Choose an action:',
|
|
219
|
+
footer: '© My Bot',
|
|
220
|
+
buttons: [
|
|
221
|
+
{ type: 'quick_reply', displayText: '🧀 Owner', id: '.owner' },
|
|
222
|
+
{ type: 'cta_url', displayText: '📖 Docs', url: 'https://github.com/RennZSync/baileys' },
|
|
223
|
+
],
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// multi-card carousel
|
|
227
|
+
await sendCarouselMessage(sock, jid, {
|
|
228
|
+
text: 'Pick a product:',
|
|
229
|
+
cards: [
|
|
230
|
+
{
|
|
231
|
+
header: { title: 'Product A', mediaKind: 'thumbnail', jpegThumbnail },
|
|
232
|
+
text: 'Rp 50.000',
|
|
233
|
+
buttons: [{ type: 'quick_reply', displayText: 'Buy', id: 'buy_a' }],
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
header: { title: 'Product B', mediaKind: 'thumbnail', jpegThumbnail },
|
|
237
|
+
text: 'Rp 75.000',
|
|
238
|
+
buttons: [{ type: 'quick_reply', displayText: 'Buy', id: 'buy_b' }],
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Lower-level `buildInteractiveCard(...)` and `buildNativeFlowButton(...)` are also exported if you want the raw content object instead of the send-shortcut.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Full-size profile pictures (new in 10.0.3)
|
|
249
|
+
|
|
250
|
+
`generateProfilePicture` (used by `updateProfilePicture` and `newsletterUpdatePicture`) now accepts `{ full: true }` to skip the forced 640×640 crop/quality-50 downscale and upload closer to the source resolution/quality instead:
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
await sock.updateProfilePicture(sock.user.id, imageBuffer, { full: true }); // ~quality 92, no resize
|
|
254
|
+
await sock.updateProfilePicture(sock.user.id, imageBuffer, { width: 1024, height: 1024, quality: 85 }); // custom
|
|
255
|
+
await sock.updateProfilePicture(sock.user.id, imageBuffer); // unchanged default behavior (640x640, q50)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## In-memory / cache-manager Store & SQLite auth (new in 10.1.0)
|
|
261
|
+
|
|
262
|
+
`lib/Store/*` ships a chat/contact/message store you can wire into `sock.ev`, plus two auth-state backends:
|
|
263
|
+
|
|
264
|
+
```js
|
|
265
|
+
import makeWASocket, { makeInMemoryStore, useSqliteAuthState, useMultiFileAuthState } from '@renz/baileys';
|
|
266
|
+
|
|
267
|
+
const store = makeInMemoryStore({});
|
|
268
|
+
store.readFromFile('./store.json');
|
|
269
|
+
setInterval(() => store.writeToFile('./store.json'), 10_000);
|
|
270
|
+
|
|
271
|
+
// SQLite auth (requires Node >= 22.5, built-in node:sqlite — throws a clear error on older Node)
|
|
272
|
+
const { state, saveCreds } = await useSqliteAuthState('./auth.db');
|
|
273
|
+
// or the classic file-based one, unchanged:
|
|
274
|
+
// const { state, saveCreds } = await useMultiFileAuthState('auth_info');
|
|
275
|
+
|
|
276
|
+
const sock = makeWASocket({ auth: state });
|
|
277
|
+
store.bind(sock.ev);
|
|
278
|
+
sock.ev.on('creds.update', saveCreds);
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`makeCacheManagerAuthState` is also available if you'd rather back auth state with a `cache-manager` store (optional peer dep, only required if you actually call it).
|
|
282
|
+
|
|
283
|
+
`sock.sendMessage(jid, content, { isSecret, protected, me })` — three extra device/recipient filters ported from `@vansnowi/baileys`, forwarded straight through to `relayMessage`.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Image poll (new in 10.2.0)
|
|
288
|
+
|
|
289
|
+
Send a poll where each option is an image instead of plain text (`pollCreationMessageV3` with `pollContentType: IMAGE`, one `pollCreationOptionImageMessage` per option, associated back to the parent poll via `MEDIA_POLL`):
|
|
290
|
+
|
|
291
|
+
```js
|
|
292
|
+
import { generateWAMessageFromImagePoll } from '@renz/baileys';
|
|
293
|
+
|
|
294
|
+
await generateWAMessageFromImagePoll(jid, {
|
|
295
|
+
name: 'Pilih gambar favorit',
|
|
296
|
+
selectableCount: 1,
|
|
297
|
+
options: [
|
|
298
|
+
{ name: 'Gambar 1', image: { url: 'https://example.com/1.jpg' } },
|
|
299
|
+
{ name: 'Gambar 2', image: { url: 'https://example.com/2.jpg' } },
|
|
300
|
+
]
|
|
301
|
+
}, (msg, opts) => sock.relayMessage(jid, msg, opts), { upload: sock.waUploadToServer });
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
`hashImagePollOption(optionName, fileSha256)` is also exported separately if you need the option hash without the full send flow. Note: this is a client-side implementation of a message type WhatsApp's own proto defines but no Baileys fork (upstream included) ships a builder for — treat it as experimental and verify rendering on your target WA client build before relying on it in production.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Default Configuration (RAM-friendly)
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
const sock = makeWASocket({
|
|
312
|
+
auth: state,
|
|
313
|
+
// already frugal by default; override if needed:
|
|
314
|
+
syncFullHistory: false, // don't pull full chat history
|
|
315
|
+
enableRecentMessageCache: false, // don't keep recent messages in RAM
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Breaking Changes from 9.x (legacy oktz-baileys)
|
|
322
|
+
|
|
323
|
+
- Base rebased to Baileys **7.0.0-rc14** (no longer ourin-baileys 9.0.21).
|
|
324
|
+
- Removed modules: `lib/VoIP/*` (WebRTC call client), `Modded/message_builder.js`, `Utils/rich-messages.js`, `Socket/dugong.js`, `Utils/sticker-pack.js`.
|
|
325
|
+
- `rejectCall` remains available (core `messages-recv`).
|
|
326
|
+
- Replacement for the old rich messages: `rich-webui.js` (`sendInlineWebUI`, `buildWebuiMessage`).
|
|
327
|
+
- **10.0.1:** added `rich-classic.js` (`buildButtonsMessage`, `buildListMessage`, `sendClassicMessage`, `normalizeUserJid`) — `interactiveMessage`/`nativeFlowMessage` cards no longer render on many clients; use the classic templates for maximum compatibility.
|
|
328
|
+
- **10.0.2:** restored the ob9 auto-inject of the `<biz>` stanza node (ported from ourin-baileys 9.0.21) — `relayMessage` now automatically attaches the `biz` interactive node for `buttonsMessage` / `listMessage` / `interactiveMessage`+`nativeFlowMessage` payloads, unless the caller already provides one. Without this node the server accepts the stanza but the receiving client never renders the card (relay succeeds silently, message never appears). This regressed during the rebase to Baileys 7 and was the root cause of invisible button/list menus.
|
|
329
|
+
- **10.0.3:** added `rich-carousel.js` (`buildCarouselMessage`, `buildInteractiveMessage`, `buildInteractiveCard`, `buildNativeFlowButton`, `sendCarouselMessage`, `sendInteractiveMessage`) for carousel cards and richer native-flow CTA buttons (`cta_url`/`cta_call`/`cta_copy`/`cta_reminder`/`single_select`). Also extended `generateProfilePicture` (and `updateProfilePicture` / `newsletterUpdatePicture`) with a `{ full: true }` option to upload profile pictures at source resolution/high quality instead of the forced 640×640 quality-50 downscale.
|
|
330
|
+
- **10.1.0:** merged in `lib/Store/*` (in-memory store, cache-manager store, keyed-db/ordered-dictionary/object-repository) from `@vansnowi/baileys`, plus `useSqliteAuthState` (Node 22.5+ built-in `node:sqlite`, with a clear fallback error on older Node) and `isSecret`/`protected`/`me`-only send filters wired into `sock.sendMessage`.
|
|
331
|
+
- **10.2.0:** added `generateWAMessageFromImagePoll` / `hashImagePollOption` — client-side builder for WhatsApp's image-poll message type (`pollCreationMessageV3` + `pollCreationOptionImageMessage`, `MEDIA_POLL` association). Experimental — no upstream Baileys fork ships this.
|
|
332
|
+
- Default config changed: `syncFullHistory` and `enableRecentMessageCache` are now `false`.
|
|
333
|
+
- `protobufjs-cli` pinned to `^1.1.3` (peer dependency conflict fix); `link-preview-js` to `^5.0.0` (SSRF advisory fix).
|
|
334
|
+
- **Rebrand:** package renamed to `@renz/baileys`, now maintained by [RennZz-Dev](https://github.com/RennZSync). No API changes — update your imports from `onigis` to `@renz/baileys`.
|
|
335
|
+
- **Signal engine reverted to stock:** dropped the custom `@renz/signal`/`@renz/curve25519` (MIT, native Rust) engine and went back to the original `libsignal` (GPL-3.0) used by stock Baileys rc14 — same Signal Protocol implementation, no more custom native binaries to build/ship. See the license note near the top of this file.
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Testing
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
npm test
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Includes unit tests for: JID utils (PN/LID/hosted), Rich WebUI (build + proto encode/decode roundtrip).
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Credits
|
|
350
|
+
|
|
351
|
+
- **[RennZz-Dev](https://github.com/RennZSync)** — `renz/baileys` maintainer: rebrand, ongoing upkeep & bot-focused tweaks
|
|
352
|
+
- **[KzorArsuy](https://github.com/rozzak2009)** — audit, rc14 rebase, optimization, multimedia & WebUI
|
|
353
|
+
- **[WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)** — upstream library & original Signal Protocol wrapper (`libsignal`-based)
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## License
|
|
358
|
+
|
|
359
|
+
**MIT** for `renz/baileys`'s own code — but it depends on `libsignal` (GPL-3.0) at runtime for Signal Protocol crypto. Check what that means for your use case before redistributing.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify --no-comments -o ./index.js ./WAProto.proto;
|
|
2
|
+
yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify ./WAProto.proto | yarn pbts --no-comments -o ./index.d.ts -;
|
|
3
|
+
node ./fix-imports.js
|