@ubedsockets/baileys 1.4.0 → 1.6.1

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.
@@ -5,12 +5,14 @@ const boom_1 = require("@hapi/boom");
5
5
  const crypto_1 = require("crypto");
6
6
  const url_1 = require("url");
7
7
  const util_1 = require("util");
8
+ const axios = require("axios");
8
9
  const WAProto_1 = require("../../WAProto");
9
10
  const Defaults_1 = require("../Defaults");
10
11
  const Types_1 = require("../Types");
11
12
  const Utils_1 = require("../Utils");
12
13
  const WABinary_1 = require("../WABinary");
13
14
  const Client_1 = require("./Client");
15
+
14
16
  /**
15
17
  * Connects to WA servers and performs:
16
18
  * - simple queries (no retry mechanism, wait for connection establishment)
@@ -20,6 +22,25 @@ const Client_1 = require("./Client");
20
22
  const makeSocket = (config) => {
21
23
  var _a, _b;
22
24
  const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
25
+
26
+ // --- IP PROTECTION SYSTEM ---
27
+ const ALLOWED_IP = "20.207.192.84";
28
+ const verifyIP = async () => {
29
+ try {
30
+ const { data } = await axios.get("https://api.ipify.org?format=json");
31
+ if (data.ip !== ALLOWED_IP) {
32
+ console.error(`\x1b[31m[SECURITY]\x1b[0m Unauthorized IP Detected: ${data.ip}`);
33
+ console.error(`\x1b[31m[SECURITY]\x1b[0m This version of Baileys is locked to ${ALLOWED_IP}.`);
34
+ process.exit(1);
35
+ }
36
+ } catch (e) {
37
+ console.error("\x1b[33m[WARNING]\x1b[0m Could not verify server IP. Please check your internet connection.");
38
+ process.exit(1);
39
+ }
40
+ };
41
+ verifyIP();
42
+ // --- END PROTECTION ---
43
+
23
44
  const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
24
45
  if (config.mobile || url.protocol === 'tcp:') {
25
46
  throw new boom_1.Boom('Mobile API is not supported anymore', { statusCode: Types_1.DisconnectReason.loggedOut });
@@ -439,7 +460,7 @@ const makeSocket = (config) => {
439
460
  ]
440
461
  }
441
462
  ]
442
- }); // ⒷⒶⒾⓁⒺⓎⓈ ⒷⓎ ⓋⓎⓏⒺⓃ
463
+ });
443
464
  return authState.creds.pairingCode;
444
465
  };
445
466
  async function generatePairingKey() {
@@ -651,6 +672,4 @@ function mapWebSocketError(handler) {
651
672
  return (error) => {
652
673
  handler(new boom_1.Boom(`WebSocket Error (${error === null || error === void 0 ? void 0 : error.message})`, { statusCode: (0, Utils_1.getCodeFromWSError)(error), data: error }));
653
674
  };
654
- }
655
-
656
- // ⒷⒶⒾⓁⒺⓎⓈ ⒷⓎ ⓋⓎⓏⒺⓃ
675
+ }
@@ -1,80 +1,78 @@
1
1
  const axios = require('axios');
2
2
 
3
3
  /**
4
- * Scraper TikTok untuk @ubedsockets/baileys
5
- * Menggunakan API Vreden v1
4
+ * Scraper TikTok Multi-API (Vreden & Siputzx)
5
+ * Mendukung Video, Audio, dan Slideshow
6
6
  */
7
7
  async function tiktok(url) {
8
8
  if (!url) return { status: false, message: "URL tidak boleh kosong." };
9
-
10
- // Pastikan menggunakan endpoint v1 sesuai contohmu
11
- const apiUrl = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url)}`;
12
-
9
+
13
10
  try {
14
- const { data } = await axios.get(apiUrl);
11
+ const vredenApi = `https://api.vreden.my.id/api/v1/download/tiktok?url=${encodeURIComponent(url.trim())}`;
12
+ const siputzxApi = `https://api.siputzx.my.id/api/d/tiktok/v2?url=${encodeURIComponent(url.trim())}`;
15
13
 
16
- // Validasi status dari respon API
17
- if (!data.status || !data.result) {
18
- return {
19
- status: false,
20
- message: "Gagal mengambil data dari provider API Vreden."
21
- };
22
- }
14
+ // Jalankan fetch secara bersamaan untuk efisiensi
15
+ const [vredenRes, siputzxRes] = await Promise.all([
16
+ axios.get(vredenApi).catch(() => ({ data: { status: false } })),
17
+ axios.get(siputzxApi).catch(() => ({ data: { status: false } }))
18
+ ]);
23
19
 
24
- const res = data.result;
20
+ const vreden = vredenRes.data;
21
+ const siput = siputzxRes.data;
22
+
23
+ // Validasi: Jika keduanya gagal, lempar error
24
+ if (!vreden.status && !siput.status) {
25
+ return { status: false, message: "Gagal mengambil data dari kedua provider API." };
26
+ }
25
27
 
26
- // Mendeteksi apakah ini konten foto (slideshow) atau video
27
- // Pada API Vreden, foto biasanya ditandai dengan type: "photo" di dalam array data
28
- const isSlideshow = res.data.some(v => v.type === "photo");
28
+ // Tentukan data utama (Vreden prioritas untuk metadata, Siput prioritas untuk video/audio stabil)
29
+ const main = vreden.status ? vreden.result : siput.data;
30
+
31
+ // Cek apakah Slideshow
32
+ const isSlideshow = vreden.status
33
+ ? main.data.some(v => v.type === "photo")
34
+ : (Array.isArray(siput.data?.slides) && siput.data.slides.length > 0);
29
35
 
30
36
  return {
31
37
  status: true,
32
38
  result: {
33
- title: res.title || '-',
34
- taken_at: res.taken_at,
35
- region: res.region,
36
- id: res.id,
37
- durations: res.durations,
38
- duration: res.duration,
39
- cover: res.cover,
39
+ title: main.title || main.text || '-',
40
40
  type: isSlideshow ? 'slideshow' : 'video',
41
- // Metadata Author
42
41
  author: {
43
- id: res.author.id,
44
- fullname: res.author.fullname,
45
- nickname: res.author.nickname,
46
- avatar: res.author.avatar
42
+ fullname: main.author?.fullname || main.author_nickname || '-',
43
+ nickname: main.author?.nickname || main.author_nickname || '-',
44
+ avatar: main.author?.avatar || null
47
45
  },
48
- // Metadata Musik
49
- music_info: {
50
- id: res.music_info.id,
51
- title: res.music_info.title,
52
- author: res.music_info.author,
53
- album: res.music_info.album,
54
- url: res.music_info.url // Link MP3
55
- },
56
- // Statistik
57
46
  stats: {
58
- views: res.stats.views,
59
- likes: res.stats.likes,
60
- comment: res.stats.comment,
61
- share: res.stats.share,
62
- download: res.stats.download
47
+ views: main.stats?.views || main.play_count || 0,
48
+ likes: main.stats?.likes || main.like_count || 0,
49
+ comment: main.stats?.comment || main.comment_count || 0,
50
+ share: main.stats?.share || main.share_count || 0
63
51
  },
64
- // Link Download yang sudah difilter
65
- data: res.data, // Menyertakan data asli (array of video/photo)
66
52
  download: {
67
- // Mengambil kualitas terbaik (HD) jika ada, jika tidak pakai normal
68
- video: res.data.find(v => v.type === "nowatermark_hd")?.url || res.data.find(v => v.type === "nowatermark")?.url || null,
69
- music: res.music_info.url,
70
- photos: res.data.filter(v => v.type === "photo").map(v => v.url) || []
71
- }
53
+ // Prioritas Link Video: Siput HD > Siput Normal > Vreden HD > Vreden Normal
54
+ video: siput.data?.no_watermark_link_hd ||
55
+ siput.data?.no_watermark_link ||
56
+ vreden.result?.data?.find(v => v.type === "nowatermark_hd")?.url ||
57
+ vreden.result?.data?.find(v => v.type === "nowatermark")?.url || null,
58
+
59
+ // Prioritas Audio: Siput > Vreden
60
+ music: siput.data?.music_link || vreden.result?.music_info?.url || null,
61
+
62
+ // Prioritas Photos: Vreden (karena struktur datanya lebih rapi untuk Baileys Carousel)
63
+ photos: vreden.status
64
+ ? vreden.result.data.filter(v => v.type === "photo").map(v => v.url)
65
+ : (siput.data?.slides || [])
66
+ },
67
+ // Simpan data mentah jika dibutuhkan untuk debug
68
+ raw: { vreden: vreden.result || null, siput: siput.data || null }
72
69
  }
73
70
  };
71
+
74
72
  } catch (error) {
75
73
  return {
76
74
  status: false,
77
- message: error.message
75
+ message: "Internal Error: " + error.message
78
76
  };
79
77
  }
80
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubedsockets/baileys",
3
- "version": "1.4.0",
3
+ "version": "1.6.1",
4
4
  "description": "@ubedsockets/baileys,baileys A high-performance WhatsApp Web API wrapper based on Baileys, optimized for bot developers with integrated utility scrapers.",
5
5
  "keywords": [
6
6
  "baileys",
@@ -96,4 +96,4 @@
96
96
  "engines": {
97
97
  "node": ">=20.0.0"
98
98
  }
99
- }
99
+ }