kage-baileys 25.3.9 → 25.3.10

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.
@@ -31,6 +31,13 @@ export function delayCancellable(ms: any): {
31
31
  export function generateMessageIDV2(userId: any): string;
32
32
  export function generateMessageID(): string;
33
33
  export function bindWaitForConnectionUpdate(ev: any): (check: any, timeoutMs: any) => Promise<void>;
34
+ export function fetchBestWaVersion(options?: {}): Promise<{
35
+ version: number[];
36
+ isLatest: boolean;
37
+ source: "wa-web" | "baileys-upstream" | "hardcoded-fallback";
38
+ error?: unknown;
39
+ webError?: unknown;
40
+ }>;
34
41
  export function fetchLatestBaileysVersion(options?: {}): Promise<{
35
42
  version: number[];
36
43
  isLatest: boolean;
@@ -285,7 +285,34 @@ const fetchLatestKageVersion = async (options = {}) => {
285
285
  exports.fetchLatestKageVersion = fetchLatestKageVersion;
286
286
 
287
287
 
288
- const fetchLatestBaileysVersion = async (options = {}) => fetchLatestWaWebVersion(options);
288
+ const fetchLatestBaileysVersion = async (options = {}) => {
289
+ const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/index.ts';
290
+ try {
291
+ const { timeoutMs = 15000, ...fetchOptions } = options || {};
292
+ const response = await fetch(URL, {
293
+ ...fetchOptions,
294
+ method: 'GET',
295
+ headers: options?.headers,
296
+ signal: fetchOptions.signal || AbortSignal.timeout(timeoutMs)
297
+ });
298
+ if (!response.ok) {
299
+ throw new Error(`Failed to fetch upstream Baileys version: ${response.status} ${response.statusText || ''}`.trim());
300
+ }
301
+ const text = await response.text();
302
+ const match = text.match(/const\s+version\s*=\s*\[(\d+),\s*(\d+),\s*(\d+)\]/);
303
+ if (!match) {
304
+ throw new Error('Could not parse upstream Baileys version');
305
+ }
306
+ const version = match.slice(1).map(Number);
307
+ const fallbackVersion = kageVersionJson.version;
308
+ if (version[0] !== fallbackVersion[0] || version[1] < fallbackVersion[1]) {
309
+ throw new Error(`Rejected incompatible upstream version ${version.join('.')}`);
310
+ }
311
+ return { version, isLatest: true };
312
+ } catch (error) {
313
+ return { version: kageVersionJson.version, isLatest: false, error };
314
+ }
315
+ };
289
316
  exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
290
317
 
291
318
 
@@ -1395,3 +1422,25 @@ for (const key of Object.keys(__kageModule169)) {
1395
1422
  if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule169[key]});
1396
1423
  }
1397
1424
  Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule169, configurable:true});
1425
+
1426
+
1427
+ // Compatibility export required by lib/Framework/Bot.js.
1428
+ // Kage exposes fetchLatestWaWebVersion already; use it once and label the
1429
+ // result so Bot can log the source without making a duplicate network call.
1430
+ exports.fetchBestWaVersion = async function fetchBestWaVersion(options = {}) {
1431
+ const webResult = await exports.fetchLatestWaWebVersion(options);
1432
+ if (webResult?.isLatest) {
1433
+ return { ...webResult, source: 'wa-web' };
1434
+ }
1435
+
1436
+ const baileysResult = await exports.fetchLatestBaileysVersion(options);
1437
+ if (baileysResult?.isLatest) {
1438
+ return { ...baileysResult, source: 'baileys-upstream', webError: webResult?.error };
1439
+ }
1440
+
1441
+ return {
1442
+ ...baileysResult,
1443
+ source: 'hardcoded-fallback',
1444
+ error: baileysResult?.error || webResult?.error
1445
+ };
1446
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kage-baileys",
3
- "version": "25.3.9",
3
+ "version": "25.3.10",
4
4
  "description": "Kage Baileys full merge — Builders + mbuilder + Framework + advanced sticker packs + KAGE pairing + extended WAProto + full TypeScript defs (.d.ts + maps) from elray + path utils. Multi-device ready.",
5
5
  "keywords": [
6
6
  "kage-baileys",