@pontalabs/baileys 1.0.1 → 1.0.2

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.
@@ -43,7 +43,7 @@ const sender_key_record_1 = require("./Group/sender-key-record");
43
43
  const Group_1 = require("./Group");
44
44
  const LIDMappingStore_1 = require("./lid-mapping")
45
45
 
46
- // FIX: sebelumnya pontasockets gak punya deteksi perubahan identity key sama
46
+ // FIX: sebelumnya pontalabs gak punya deteksi perubahan identity key sama
47
47
  // sekali. Kalau identity kontak berubah (kontak install ulang WA, atau kena
48
48
  // resync multi-device pas ada linked device lain online), sesi lama tetap
49
49
  // dipakai terus dan selalu gagal decrypt "Bad MAC" berulang-ulang sampai
@@ -1,5 +1,5 @@
1
1
  "use strict"
2
- // 18 7 2026
2
+
3
3
  var __importDefault = (this && this.__importDefault) || function(mod) {
4
4
  return (mod && mod.__esModule) ? mod : {
5
5
  "default": mod
@@ -59,6 +59,7 @@ const makeMessagesSocket = (config) => {
59
59
 
60
60
  const messageRetryManager = enableRecentMessageCache ? new Utils_1.MessageRetryManager(logger, maxMsgRetryCount) : null
61
61
  const encryptionMutex = make_keyed_mutex_1.makeKeyedMutex()
62
+ const devicesMutex = make_keyed_mutex_1.makeMutex()
62
63
  let mediaConn
63
64
 
64
65
  const refreshMediaConn = async (forceGet = false) => {
@@ -295,6 +296,24 @@ const makeMessagesSocket = (config) => {
295
296
 
296
297
  const result = await executeUSyncQuery(query)
297
298
  if (result) {
299
+ // FIX: pontalabs sebelumnya gak pernah nyimpen mapping LID<->PN
300
+ // dari hasil USync device query ini (nuiisweety nyimpen + langsung
301
+ // force-refresh session buat LID yang baru ketemu). Tanpa ini,
302
+ // pengiriman ke kontak yang butuh LID addressing bisa tetep pakai
303
+ // address PN yang salah/basi -> penerima gak bisa decrypt balasan
304
+ // bot ("Menunggu pesan ini...").
305
+ const lidResults = (result.list || []).filter(item => !!item.lid)
306
+ if (lidResults.length > 0) {
307
+ try {
308
+ await signalRepository.lidMapping.storeLIDPNMappings(
309
+ lidResults.map(item => ({ lid: item.lid, pn: item.id }))
310
+ )
311
+ const lids = lidResults.map(item => item.lid)
312
+ await assertSessions(lids, true)
313
+ } catch (error) {
314
+ logger.warn({ error, count: lidResults.length }, 'failed to store/refresh LID mappings from device sync')
315
+ }
316
+ }
298
317
  const extracted = Utils_1.extractDeviceJids(result?.list, authState.creds.me.id, ignoreZeroDevices)
299
318
  const deviceMap = {}
300
319
  for (const item of extracted) {
@@ -318,16 +337,18 @@ const makeMessagesSocket = (config) => {
318
337
  }
319
338
  }
320
339
 
321
- if (userDevicesCache.mset) {
322
- await userDevicesCache.mset(Object.entries(deviceMap).map(([key, value]) => ({
323
- key,
324
- value
325
- })))
326
- } else {
327
- for (const key in deviceMap) {
328
- if (deviceMap[key]) await userDevicesCache.set(key, deviceMap[key])
340
+ await devicesMutex.mutex(async () => {
341
+ if (userDevicesCache.mset) {
342
+ await userDevicesCache.mset(Object.entries(deviceMap).map(([key, value]) => ({
343
+ key,
344
+ value
345
+ })))
346
+ } else {
347
+ for (const key in deviceMap) {
348
+ if (deviceMap[key]) await userDevicesCache.set(key, deviceMap[key])
349
+ }
329
350
  }
330
- }
351
+ })
331
352
  }
332
353
  return deviceResults
333
354
  }
@@ -1135,6 +1156,14 @@ const makeMessagesSocket = (config) => {
1135
1156
  return message
1136
1157
  },
1137
1158
  sendStatusMentions: async (content, jids = []) => {
1159
+ const MAX_STATUS_MENTIONS = 5
1160
+ if (jids.length > MAX_STATUS_MENTIONS) {
1161
+ logger.warn(
1162
+ { requested: jids.length, max: MAX_STATUS_MENTIONS },
1163
+ `sendStatusMentions: max ${MAX_STATUS_MENTIONS} mentions per status, truncating`
1164
+ )
1165
+ jids = jids.slice(0, MAX_STATUS_MENTIONS)
1166
+ }
1138
1167
  const userJid = WABinary_1.jidNormalizedUser(authState.creds.me.id)
1139
1168
  let allUsers = new Set()
1140
1169
  allUsers.add(userJid)
@@ -165,7 +165,7 @@ const getDecryptionJid = async (sender, repository) => {
165
165
  if (!mapped) {
166
166
  return sender
167
167
  }
168
- // FIX: pontasockets gak punya migrateSession (beda dari levvleys) yang
168
+ // FIX: pontalabs gak punya migrateSession (beda dari levvleys) yang
169
169
  // mindahin sesi Signal dari address PN ke address LID begitu mapping
170
170
  // disimpan. Jadi mapping doang gak jamin ada sesi beneran di address LID
171
171
  // itu -- kalau dipaksa pakai, decrypt gagal "No session record" walau
@@ -184,7 +184,7 @@ const getDecryptionJid = async (sender, repository) => {
184
184
  return sender
185
185
  }
186
186
 
187
- // FIX: pontasockets sebelumnya gak pernah menyimpan mapping LID<->PN saat pesan
187
+ // FIX: pontalabs sebelumnya gak pernah menyimpan mapping LID<->PN saat pesan
188
188
  // masuk (levvleys punya storeMappingFromEnvelope, di sini gak ada). Akibatnya
189
189
  // untuk kontak yang pakai addressing LID, getDecryptionJid bisa gagal nemuin
190
190
  // sesi yang benar secara intermiten (tergantung cache mapping ada atau belum),
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * rich-message-utils.js
5
- * @pontasockets-baileys
5
+ * @pontalabs-baileys
6
6
  * Tambahkan file ini ke: node_modules/@whiskeysockets/baileys/lib/Utils/rich-message-utils.js
7
7
  */
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pontalabs/baileys",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "PontaLabs Baileys is a lightweight, modern, and customizable WhatsApp Web API library built on Baileys.",
5
5
  "keywords": [
6
6
  "facebook",
@@ -17,7 +17,7 @@
17
17
  "url": "git+ssh://git@github.com/pontalabs/baileys.git"
18
18
  },
19
19
  "license": "MIT",
20
- "author": "PontaLabs",
20
+ "author": "Pontalabs",
21
21
  "main": "lib/index.js",
22
22
  "types": "lib/index.d.ts",
23
23
  "files": [
@@ -25,12 +25,14 @@
25
25
  "WAProto/**/*"
26
26
  ],
27
27
  "scripts": {
28
- "test": "jest"
28
+ "test": "jest",
29
+ "format": "prettier --write \"src/**/*.{ts,js,json,md}\"",
30
+ "lint": "tsc && eslint src --ext .js,.ts",
31
+ "lint:fix": "npm run format && npm run lint -- --fix"
29
32
  },
30
33
  "dependencies": {
31
34
  "@adiwajshing/keyed-db": "^0.2.4",
32
35
  "@cacheable/node-cache": "1.5.3",
33
- "@pontasockets/eslint-config": "^1.0.0",
34
36
  "libsignal": "^6.0.0",
35
37
  "@hapi/boom": "^9.1.3",
36
38
  "async-mutex": "^0.5.0",
@@ -48,16 +50,24 @@
48
50
  "ws": "^8.13.0"
49
51
  },
50
52
  "devDependencies": {
53
+ "@eslint/eslintrc": "^3.3.1",
54
+ "@eslint/js": "^9.31.0",
51
55
  "@types/jest": "^29.5.14",
52
56
  "@types/node": "^16.0.0",
53
57
  "@types/ws": "^8.0.0",
58
+ "@typescript-eslint/eslint-plugin": "^8",
59
+ "@typescript-eslint/parser": "^8",
60
+ "@whiskeysockets/eslint-config": "^1.0.0",
54
61
  "conventional-changelog-cli": "^2.2.2",
55
- "eslint": "^8.0.0",
62
+ "eslint": "^9",
63
+ "eslint-config-prettier": "^10.1.2",
64
+ "eslint-plugin-prettier": "^5.4.0",
56
65
  "jest": "^30.1.1",
57
66
  "jimp": "^1.6.1",
58
67
  "json": "^11.0.0",
59
68
  "link-preview-js": "^3.0.5",
60
69
  "open": "^8.4.2",
70
+ "prettier": "^3.5.3",
61
71
  "release-it": "^15.10.3",
62
72
  "ts-jest": "^29.4.1",
63
73
  "ts-node": "^10.8.1",