astrabail 1.2.0 → 1.2.4

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1027934701]
2
+ "version": [2, 3000, 1029577332]
3
3
  }
@@ -60,14 +60,18 @@ exports.DEFAULT_CONNECTION_CONFIG = {
60
60
  version: baileys_version_json_1.version,
61
61
  browser: Utils_1.Browsers.windows('Chrome'),
62
62
  waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
63
- connectTimeoutMs: 20000,
64
- keepAliveIntervalMs: 30000,
63
+ // AstraBail: Naikan connectTimeoutMs agar VPS/server lambat tidak langsung timeout
64
+ connectTimeoutMs: 30000,
65
+ // AstraBail: Ping lebih sering (25s) agar koneksi tetap hidup
66
+ keepAliveIntervalMs: 25000,
65
67
  logger: logger_1.default.child({ class: 'baileys' }),
66
68
  printQRInTerminal: false,
67
69
  emitOwnEvents: true,
68
- defaultQueryTimeoutMs: 60000,
70
+ // AstraBail: Query timeout 90s agar pairing & query besar tidak timeout
71
+ defaultQueryTimeoutMs: 90000,
69
72
  customUploadHosts: [],
70
- retryRequestDelayMs: 250,
73
+ // AstraBail: Delay antar retry lebih wajar
74
+ retryRequestDelayMs: 500,
71
75
  maxMsgRetryCount: 5,
72
76
  fireInitQueries: true,
73
77
  auth: undefined,
@@ -22,10 +22,10 @@ class WebSocketClient extends types_1.AbstractSocketClient {
22
22
  return this.socket?.readyState === ws_1.default.CLOSED
23
23
  }
24
24
  get isClosing() {
25
- this.socket?.readyState === ws_1.default.CLOSING
25
+ return this.socket?.readyState === ws_1.default.CLOSING
26
26
  }
27
27
  get isConnecting() {
28
- this.socket?.readyState === ws_1.default.CONNECTING
28
+ return this.socket?.readyState === ws_1.default.CONNECTING
29
29
  }
30
30
  async connect() {
31
31
  if (this.socket) {
@@ -572,8 +572,17 @@ const makeMessagesSocket = (config) => {
572
572
  addressing_mode: groupAddressingMode
573
573
  }
574
574
  }
575
- const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false)
576
- devices.push(...additionalDevices)
575
+ // AstraBail: Batch device fetching untuk grup besar
576
+ // Fetch sekaligus 500+ member menyebabkan WA rate-limit → timeout & bot mati
577
+ // Solusi: batch 50 JID per request
578
+ const _BATCH_SIZE = 50
579
+ const _allFetchedDevices = []
580
+ for (let _i = 0; _i < participantsList.length; _i += _BATCH_SIZE) {
581
+ const _batch = participantsList.slice(_i, _i + _BATCH_SIZE)
582
+ const _batchDevices = await getUSyncDevices(_batch, !!useUserDevicesCache, false)
583
+ _allFetchedDevices.push(..._batchDevices)
584
+ }
585
+ devices.push(..._allFetchedDevices)
577
586
  }
578
587
 
579
588
  const patched = await patchMessageBeforeSending(message, devices.map(d => WABinary_1.jidEncode(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)))
@@ -572,7 +572,8 @@ const makeSocket = (config) => {
572
572
 
573
573
  const diff = Date.now() - lastDateRecv.getTime()
574
574
 
575
- if (diff > keepAliveIntervalMs + 5000) {
575
+ // AstraBail: Toleransi 15 detik agar koneksi VPS lambat tidak langsung dianggap lost
576
+ if (diff > keepAliveIntervalMs + 15000) {
576
577
  end(new boom_1.Boom('Connection was lost', {
577
578
  statusCode: Types_1.DisconnectReason.connectionLost
578
579
  }))
@@ -361,7 +361,9 @@ const fetchLatestBaileysVersion = async (options = {}) => {
361
361
  try {
362
362
  const result = await axios_1.default.get(URL, {
363
363
  ...options,
364
- responseType: 'text'
364
+ responseType: 'text',
365
+ // AstraBail: Timeout 5 detik, jangan hang jika GitHub tidak bisa diakses
366
+ timeout: options.timeout || 5000,
365
367
  });
366
368
  const lines = result.data.split('\n');
367
369
  const versionLine = lines[6];
@@ -393,7 +395,9 @@ const fetchLatestAstraBailVersion = async (options = {}) => {
393
395
  try {
394
396
  const result = await axios_1.default.get(URL, {
395
397
  ...options,
396
- responseType: 'text'
398
+ responseType: 'text',
399
+ // AstraBail: Timeout 5 detik, jangan hang jika GitHub tidak bisa diakses
400
+ timeout: options.timeout || 5000,
397
401
  });
398
402
  const lines = result.data.split('\n');
399
403
  const versionLine = lines[6];
@@ -7,7 +7,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  Object.defineProperty(exports, "__esModule", { value: true })
8
8
 
9
9
  const async_mutex_1 = __importDefault(require("async-mutex"))
10
- const promises_1 = require("fs/promises")
10
+ const { writeFile, readFile, unlink, stat, mkdir, rename } = require("fs/promises")
11
+ const promises_1 = { writeFile, readFile, unlink, stat, mkdir, rename }
11
12
  const path_1 = require("path")
12
13
  const WAProto_1 = require("../../WAProto")
13
14
  const auth_utils_1 = require("./auth-utils")
@@ -76,12 +77,20 @@ const useMultiFileAuthState = async (folder) => {
76
77
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
78
  const writeData = async (data, file, _direct = false) => {
78
79
  const filePath = _direct ? file : path_1.join(folder, fixFileName(file))
80
+ const tmpPath = filePath + '.tmp'
79
81
  // AstraBail: Invalidate read cache on write
80
82
  invalidateReadCache(filePath)
81
83
  const mutex = getFileLock(filePath)
82
84
  return mutex.acquire().then(async (release) => {
83
85
  try {
84
- await promises_1.writeFile(filePath, JSON.stringify(data, generics_1.BufferJSON.replacer))
86
+ // AstraBail: Atomic write — tulis ke .tmp dulu lalu rename
87
+ // Jika proses crash di tengah jalan, file asli tidak rusak/hilang
88
+ await promises_1.writeFile(tmpPath, JSON.stringify(data, generics_1.BufferJSON.replacer))
89
+ await promises_1.rename(tmpPath, filePath)
90
+ } catch (err) {
91
+ // Cleanup file .tmp jika terjadi error
92
+ await promises_1.unlink(tmpPath).catch(() => {})
93
+ throw err
85
94
  } finally {
86
95
  release()
87
96
  }
@@ -110,6 +119,10 @@ const useMultiFileAuthState = async (folder) => {
110
119
  }
111
120
  const removeData = async (file) => {
112
121
  try {
122
+ // AstraBail: Proteksi creds.json — jangan pernah hapus credentials utama
123
+ if (file === 'creds.json') {
124
+ return
125
+ }
113
126
  const filePath = path_1.join(folder, fixFileName(file))
114
127
  invalidateReadCache(filePath)
115
128
  const mutex = getFileLock(filePath)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "astrabail",
3
- "version": "1.2.0",
4
- "update": "22 July 2026",
3
+ "version": "1.2.4",
4
+ "update": "11 August 2026",
5
5
  "description": "Professional Whatsapp Web API Library",
6
6
  "keywords": [
7
7
  "astra",
@@ -26,6 +26,7 @@
26
26
  "main": "lib/index.js",
27
27
  "types": "lib/index.d.ts",
28
28
  "files": [
29
+ "readme.md",
29
30
  "lib/**/*",
30
31
  "WAProto/**/*",
31
32
  "engine-requirements.js"
@@ -46,12 +47,12 @@
46
47
  },
47
48
  "dependencies": {
48
49
  "@adiwajshing/keyed-db": "^0.2.4",
49
- "@cacheable/node-cache": "^1.4.0",
50
+ "@cacheable/node-cache": "1.5.3",
50
51
  "@hapi/boom": "^9.1.3",
51
52
  "@saazkira/libsignal-node": "^1.1.0",
52
53
  "async-mutex": "^0.5.0",
53
- "audio-decode": "^2.1.3",
54
- "axios": "^1.6.0",
54
+ "audio-decode": "^2.2.2",
55
+ "axios": "^1.12.1",
55
56
  "cache-manager": "^5.7.6",
56
57
  "chalk": "^4.1.2",
57
58
  "cheerio": "^1.0.0-rc.10",
@@ -59,11 +60,13 @@
59
60
  "gradient-string": "^2.0.2",
60
61
  "libphonenumber-js": "^1.10.20",
61
62
  "libsignal": "github:Danimaru-ze/astra-libsignal",
63
+ "link-preview-js": "^3.0.14",
62
64
  "lodash": "^4.17.21",
63
65
  "lru-cache": "^11.1.0",
64
66
  "music-metadata": "^7.12.3",
65
67
  "pino": "^9.6",
66
- "protobufjs": "^6.11.3",
68
+ "protobufjs": "^7.2.4",
69
+ "qrcode-terminal": "^0.12.0",
67
70
  "uuid": "^10.0.0",
68
71
  "whatsapp-rust-bridge": "0.5.3",
69
72
  "ws": "^8.13.0"
@@ -71,29 +74,27 @@
71
74
  "devDependencies": {
72
75
  "@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
73
76
  "@types/got": "^9.6.11",
74
- "@types/jest": "^27.5.1",
77
+ "@types/jest": "^29.5.14",
75
78
  "@types/node": "^16.18.126",
76
79
  "@types/sharp": "^0.29.4",
77
80
  "@types/ws": "^8.0.0",
78
81
  "conventional-changelog-cli": "^2.2.2",
79
82
  "eslint": "^8.0.0",
80
- "jest": "^27.0.6",
81
- "jimp": "^0.16.1",
83
+ "jest": "^30.1.1",
84
+ "jimp": "^0.22.12",
82
85
  "json": "^11.0.0",
83
- "link-preview-js": "^3.0.0",
84
86
  "open": "^8.4.2",
85
- "qrcode-terminal": "^0.12.0",
86
87
  "release-it": "^15.10.3",
87
88
  "sharp": "^0.34.1",
88
- "ts-jest": "^27.0.3",
89
+ "ts-jest": "^29.4.1",
89
90
  "ts-node": "^10.8.1",
90
91
  "typedoc": "^0.27.9",
91
92
  "typescript": "^5.8.2"
92
93
  },
93
94
  "peerDependencies": {
94
- "audio-decode": "^2.1.3",
95
- "jimp": "^0.16.1",
96
- "link-preview-js": "^3.0.0",
95
+ "audio-decode": "^2.2.2",
96
+ "jimp": "^0.22.12",
97
+ "link-preview-js": "^3.0.14",
97
98
  "qrcode-terminal": "^0.12.0",
98
99
  "sharp": "^0.34.1"
99
100
  },
File without changes