@fazzcode/baileys 2.5.4 → 2.5.6
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 +79 -6
- package/lib/Socket/socket.js +12 -0
- package/package.json +3 -5
package/README.MD
CHANGED
|
@@ -40,7 +40,31 @@
|
|
|
40
40
|
|
|
41
41
|
## 🔧 Requirement
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
### Versi Node.js yang Didukung
|
|
44
|
+
|
|
45
|
+
| Versi Node.js | Status | Catatan |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| < 20.0.0 | ❌ Tidak didukung | ESM & fitur JS modern yang dipakai library ini butuh minimal v20 |
|
|
48
|
+
| 20.x (LTS) | ✅ Didukung | Minimum version, paling stabil untuk produksi |
|
|
49
|
+
| 22.x (LTS) | ✅ Didukung | Direkomendasikan |
|
|
50
|
+
| 23.x | ✅ Didukung | |
|
|
51
|
+
| 24.x (LTS) | ✅ Didukung | |
|
|
52
|
+
| 25.x / 26.x dan seterusnya | ✅ Didukung | Versi Current/terbaru, selama masih kompatibel dengan ESM Node standar |
|
|
53
|
+
|
|
54
|
+
Singkatnya: **selama Node.js >= 20.0.0, baik versi LTS maupun Current/terbaru, library ini bisa dipakai.** Tidak ada batas atas versi — cukup pastikan minimal v20 karena `package.json` menggunakan `"type": "module"` dan sintaks ES2022+.
|
|
55
|
+
|
|
56
|
+
Cek versi Node.js yang terpasang:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
node -v
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Kalau masih di bawah v20 (misalnya v16/v18), update Node.js dulu sebelum install package ini. Di Termux (Android) bisa update dengan:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pkg update && pkg upgrade nodejs
|
|
66
|
+
```
|
|
67
|
+
|
|
44
68
|
- **npm** atau **yarn**
|
|
45
69
|
- **WhatsApp Account** (hanya 1 account per instance)
|
|
46
70
|
- **System Requirements**:
|
|
@@ -66,17 +90,16 @@ yarn add @fazzcode/baileys
|
|
|
66
90
|
|
|
67
91
|
### Dependency Tambahan (Optional)
|
|
68
92
|
|
|
93
|
+
`jimp` sudah otomatis terpasang sebagai dependency utama (dibutuhkan untuk crop gambar profil), jadi tidak perlu diinstal manual. Yang masih opsional hanya:
|
|
94
|
+
|
|
69
95
|
```bash
|
|
70
96
|
# Untuk link preview
|
|
71
97
|
npm install link-preview-js
|
|
72
98
|
|
|
73
|
-
# Untuk
|
|
74
|
-
npm install jimp@latest
|
|
75
|
-
|
|
76
|
-
# Untuk audio processing
|
|
99
|
+
# Untuk audio processing (durasi audio, dsb)
|
|
77
100
|
npm install audio-decode
|
|
78
101
|
|
|
79
|
-
# Logging
|
|
102
|
+
# Logging (pino sudah ikut terpasang otomatis, opsional kalau mau versi/konfigurasi sendiri)
|
|
80
103
|
npm install pino
|
|
81
104
|
```
|
|
82
105
|
|
|
@@ -879,6 +902,56 @@ await sock.groupParticipantsUpdate(
|
|
|
879
902
|
|
|
880
903
|
## ⚠️ Error Handling
|
|
881
904
|
|
|
905
|
+
### Troubleshooting Instalasi (Cannot find module)
|
|
906
|
+
|
|
907
|
+
Kalau muncul error seperti ini saat menjalankan bot:
|
|
908
|
+
|
|
909
|
+
```
|
|
910
|
+
Error: Cannot find module '@protobufjs/inquire'
|
|
911
|
+
Require stack:
|
|
912
|
+
- node_modules/libsignal-xeuka/node_modules/protobufjs/...
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
atau error `Cannot find module` lain yang nyebut folder di dalam `node_modules/<package-lain>/node_modules/...`, itu artinya **instalasi `node_modules` tidak lengkap/corrupt** — biasanya karena koneksi putus saat `npm install`, atau (sering terjadi di Termux/Android) penyimpanan eksternal (`/storage/emulated/0/...`) yang bermasalah saat npm menulis banyak file kecil bersarang.
|
|
916
|
+
|
|
917
|
+
**Solusi (install ulang bersih):**
|
|
918
|
+
|
|
919
|
+
```bash
|
|
920
|
+
# 1. Hapus instalasi yang rusak
|
|
921
|
+
rm -rf node_modules package-lock.json
|
|
922
|
+
|
|
923
|
+
# 2. Bersihkan cache npm
|
|
924
|
+
npm cache clean --force
|
|
925
|
+
|
|
926
|
+
# 3. Install ulang
|
|
927
|
+
npm install
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
**Khusus pengguna Termux/Android**, kalau masih sering gagal di tengah jalan, coba install di internal storage Termux dulu (lebih stabil daripada `/storage/emulated/0/...`), baru pindahkan foldernya kalau perlu:
|
|
931
|
+
|
|
932
|
+
```bash
|
|
933
|
+
cd ~ # masuk ke home Termux, bukan /storage/emulated/0
|
|
934
|
+
mkdir -p project && cd project
|
|
935
|
+
npm install @fazzcode/baileys
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
Pastikan juga koneksi internet stabil selama proses install karena beberapa dependency (terutama yang diambil dari GitHub seperti `libsignal-xeuka`) butuh proses clone/download yang agak besar.
|
|
939
|
+
|
|
940
|
+
### Troubleshooting "Connection Closed" / Koneksi Tidak Mau Tersambung
|
|
941
|
+
|
|
942
|
+
Kalau koneksi terus-terusan putus sebelum berhasil login/pairing (baik muncul error `Connection Closed` maupun cuma diam tanpa respons), berarti koneksi WebSocket ke server WhatsApp gagal terbentuk. Penyebab paling umum:
|
|
943
|
+
|
|
944
|
+
- **Internet tidak stabil** atau koneksi terlalu lambat saat proses handshake awal
|
|
945
|
+
- **Firewall/ISP/provider data** memblokir akses ke `web.whatsapp.com` (lumayan sering terjadi di beberapa jaringan kampus/kantor/operator seluler tertentu)
|
|
946
|
+
- **VPN/Proxy** yang dipakai memblokir atau memodifikasi traffic WebSocket
|
|
947
|
+
|
|
948
|
+
Cara cek & atasi:
|
|
949
|
+
|
|
950
|
+
1. Pastikan kamu bisa akses `https://web.whatsapp.com` lewat browser di perangkat yang sama.
|
|
951
|
+
2. Kalau pakai VPN/proxy, coba matikan dulu lalu jalankan ulang bot.
|
|
952
|
+
3. Coba ganti jaringan (misal dari WiFi ke data seluler, atau sebaliknya) untuk memastikan bukan masalah jaringan spesifik.
|
|
953
|
+
4. Library ini sudah dilengkapi penanganan kalau server membalas dengan response HTTP yang tidak terduga (misalnya diblokir oleh jaringan), jadi error akan langsung ditampilkan dengan jelas alih-alih bot diam tanpa sebab — perhatikan kode status yang muncul di log untuk diagnosis lebih lanjut.
|
|
954
|
+
|
|
882
955
|
### Basic Error Handling
|
|
883
956
|
|
|
884
957
|
```javascript
|
package/lib/Socket/socket.js
CHANGED
|
@@ -640,6 +640,18 @@ const toPn = async (pn) => {
|
|
|
640
640
|
});
|
|
641
641
|
ws.on("error", mapWebSocketError(end));
|
|
642
642
|
ws.on("close", () => end(new Boom("Connection Terminated", { statusCode: DisconnectReason.connectionClosed })));
|
|
643
|
+
ws.on("unexpected-response", (req, res) => {
|
|
644
|
+
const statusCode = res?.statusCode || DisconnectReason.connectionClosed;
|
|
645
|
+
const denyReason = res?.headers?.["x-deny-reason"];
|
|
646
|
+
logger.error({ statusCode, denyReason }, "unexpected (non-websocket) response received during handshake");
|
|
647
|
+
try {
|
|
648
|
+
res?.resume?.();
|
|
649
|
+
}
|
|
650
|
+
catch {
|
|
651
|
+
// ignore, just making sure the socket isn't left dangling
|
|
652
|
+
}
|
|
653
|
+
end(new Boom(`Unexpected server response: ${statusCode}`, { statusCode: DisconnectReason.connectionClosed, data: { httpStatusCode: statusCode, denyReason } }));
|
|
654
|
+
});
|
|
643
655
|
ws.on("CB:xmlstreamend", () => end(new Boom("Connection Terminated by Server", { statusCode: DisconnectReason.connectionClosed })));
|
|
644
656
|
ws.on("CB:iq,type:set,pair-device", async (stanza) => {
|
|
645
657
|
const iq = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fazzcode/baileys",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"description": "Websocket Whatsapp API for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
36
36
|
"changelog:preview": "conventional-changelog -p angular -u",
|
|
37
37
|
"changelog:last": "conventional-changelog -p angular -r 2",
|
|
38
|
-
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
39
38
|
"example": "node --inspect Example/example.js",
|
|
40
39
|
"lint": "eslint src --ext .js",
|
|
41
40
|
"lint:fix": "yarn lint --fix",
|
|
@@ -44,13 +43,13 @@
|
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
45
|
"@cacheable/node-cache": "*",
|
|
47
|
-
"libsignal-xeuka": "github:tskiofc/libsignal",
|
|
46
|
+
"libsignal-xeuka": "github:tskiofc/libsignal#250643990ae58c9e16dcfb34b1c8feaf7da41b06",
|
|
48
47
|
"music-metadata": "*",
|
|
49
48
|
"cache-manager": "*",
|
|
50
49
|
"async-mutex": "*",
|
|
51
50
|
"@hapi/boom": "*",
|
|
52
51
|
"jimp": "*",
|
|
53
|
-
"protobufjs": "
|
|
52
|
+
"protobufjs": "7.5.0",
|
|
54
53
|
"lru-cache": "*",
|
|
55
54
|
"p-queue": "*",
|
|
56
55
|
"axios": "*",
|
|
@@ -62,7 +61,6 @@
|
|
|
62
61
|
"@whiskeysockets/eslint-config": "github:whiskeysockets/eslint-config",
|
|
63
62
|
"conventional-changelog-cli": "*",
|
|
64
63
|
"link-preview-js": "*",
|
|
65
|
-
"protobufjs-cli": "*",
|
|
66
64
|
"@types/jest": "*",
|
|
67
65
|
"@types/node": "*",
|
|
68
66
|
"release-it": "*",
|