@jexkcode/baileys 1.1.4 → 1.1.5

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.
@@ -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, 1041589577];
5
+ const version = [2, 3000, 1043857760];
6
6
  export const UNAUTHORIZED_CODES = [401, 403, 419];
7
7
  export const BIZ_BOT_SUPPORT_PAYLOAD = '{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
8
8
  export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
@@ -1,7 +1,7 @@
1
1
  import { Boom } from '@hapi/boom';
2
2
  import { createHash, randomBytes, randomFillSync } from 'crypto';
3
3
  import { proto } from '../../WAProto/index.js';
4
- const baileysVersion = [2, 3000, 1041589577];
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';
@@ -175,43 +175,22 @@ export function bindWaitForEvent(ev, event) {
175
175
  }
176
176
  export const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
177
177
  /**
178
- * utility that fetches latest baileys version from the master branch.
179
- * Use to ensure your WA connection is always on the latest version
178
+ * Fetch the latest WhatsApp Web version.
179
+ * FIX: sebelumnya versi dibaca dari repo GitHub fork (hardcoded, cepat basi) tapi
180
+ * selalu dilaporkan isLatest: true, akibatnya WhatsApp menolak koneksi (405).
181
+ * Sekarang diambil langsung dari WhatsApp Web (sw.js); kalau gagal, fallback ke
182
+ * versi bawaan dengan isLatest: false.
180
183
  */
181
184
  export const fetchLatestBaileysVersion = async (options = {}) => {
182
- const URL = 'https://raw.githubusercontent.com/jexkpinkman/JexkCode-baileys/main/lib/Defaults/index.js';
183
- try {
184
- const response = await fetch(URL, {
185
- dispatcher: options.dispatcher,
186
- method: 'GET',
187
- headers: options.headers
188
- });
189
- if (!response.ok) {
190
- throw new Boom(`Failed to fetch latest Baileys version: ${response.statusText}`, { statusCode: response.status });
191
- }
192
- const text = await response.text();
193
- // Extract version from line 5 (const version = [...])
194
- const lines = text.split('\n');
195
- const versionLine = lines[4]; // Line 5 (0-indexed)
196
- const versionMatch = versionLine.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/);
197
- if (versionMatch) {
198
- const version = [parseInt(versionMatch[1]), parseInt(versionMatch[2]), parseInt(versionMatch[3])];
199
- return {
200
- version,
201
- isLatest: true
202
- };
203
- }
204
- else {
205
- throw new Error('Could not parse version from Defaults/index.ts');
206
- }
207
- }
208
- catch (error) {
209
- return {
210
- version: baileysVersion,
211
- isLatest: false,
212
- error
213
- };
185
+ const result = await fetchLatestWaWebVersion(options);
186
+ if (result.isLatest) {
187
+ return result;
214
188
  }
189
+ return {
190
+ version: baileysVersion,
191
+ isLatest: false,
192
+ error: result.error
193
+ };
215
194
  };
216
195
  /**
217
196
  * A utility that fetches the latest web version of whatsapp.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jexkcode/baileys",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "JexkCode Baileys - Enhanced WhatsApp Web API with interactive messages, albums, newsletter support, and AIRich responses.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",