@fer2809fl/baileys 1.4.7 → 1.4.9
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.
- package/README.md +352 -115
- package/lib/Baileys.jpeg +0 -0
- package/lib/Signal/Group/group_cipher.js +22 -13
- package/lib/Signal/Group/sender-key-record.js +27 -14
- package/lib/Socket/newsletter.js +1 -1
- package/lib/Socket/setup.js +3 -3
- package/lib/Socket/setup.ts +3 -3
- package/lib/Socket/socket.js +560 -0
- package/lib/Utils/auth-utils.js +23 -11
- package/lib/Utils/button-handler.js +151 -0
- package/lib/Utils/error-handler.js +37 -0
- package/lib/Utils/index.d.ts +1 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/interactive.js +254 -0
- package/lib/Utils/messages.js +2 -2
- package/lib/Utils/process-message.js +43 -25
- package/lib/Utils/use-multi-file-auth-state.js +41 -21
- package/lib/WABinary/constants.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +5 -5
|
@@ -27,57 +27,77 @@ const getFileLock = (path) => {
|
|
|
27
27
|
*
|
|
28
28
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
29
29
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
30
|
-
|
|
30
|
+
*/
|
|
31
31
|
const useMultiFileAuthState = async (folder) => {
|
|
32
|
-
//
|
|
32
|
+
// 🔧 REPARADO: Escritura atómica con archivo temporal
|
|
33
33
|
const writeData = async (data, file) => {
|
|
34
34
|
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
35
35
|
const mutex = getFileLock(filePath);
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
return mutex.runExclusive(async () => {
|
|
37
38
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// Escribir a archivo temporal primero
|
|
40
|
+
const tempPath = filePath + '.tmp';
|
|
41
|
+
await (0, promises_1.writeFile)(tempPath, JSON.stringify(data, generics_1.BufferJSON.replacer));
|
|
42
|
+
|
|
43
|
+
// Renombrar atómicamente (evita corrupción)
|
|
44
|
+
await (0, promises_1.rename)(tempPath, filePath);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
// Limpiar archivo temporal si existe
|
|
47
|
+
try {
|
|
48
|
+
await (0, promises_1.unlink)(filePath + '.tmp');
|
|
49
|
+
} catch (_) {}
|
|
50
|
+
throw err;
|
|
42
51
|
}
|
|
43
52
|
});
|
|
44
53
|
};
|
|
54
|
+
|
|
55
|
+
// 🔧 REPARADO: Lectura con mejor manejo de errores
|
|
45
56
|
const readData = async (file) => {
|
|
46
57
|
try {
|
|
47
58
|
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
48
59
|
const mutex = getFileLock(filePath);
|
|
49
|
-
|
|
60
|
+
|
|
61
|
+
return await mutex.runExclusive(async () => {
|
|
50
62
|
try {
|
|
51
63
|
const data = await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' });
|
|
52
64
|
return JSON.parse(data, generics_1.BufferJSON.reviver);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
} catch (readErr) {
|
|
66
|
+
// Si el archivo no existe, retornar null sin error
|
|
67
|
+
if (readErr.code === 'ENOENT') {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
throw readErr;
|
|
56
71
|
}
|
|
57
72
|
});
|
|
58
|
-
}
|
|
59
|
-
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// Solo log en errores graves, no "file not found"
|
|
75
|
+
if (error.code !== 'ENOENT') {
|
|
76
|
+
console.error(`[Auth] Error reading ${file}:`, error.message);
|
|
77
|
+
}
|
|
60
78
|
return null;
|
|
61
79
|
}
|
|
62
80
|
};
|
|
81
|
+
|
|
63
82
|
const removeData = async (file) => {
|
|
64
83
|
try {
|
|
65
84
|
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
66
85
|
const mutex = getFileLock(filePath);
|
|
67
|
-
return mutex.
|
|
86
|
+
return mutex.runExclusive(async () => {
|
|
68
87
|
try {
|
|
69
88
|
await (0, promises_1.unlink)(filePath);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
} catch (err) {
|
|
90
|
+
// Ignorar si el archivo no existe
|
|
91
|
+
if (err.code !== 'ENOENT') {
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
75
94
|
}
|
|
76
95
|
});
|
|
77
|
-
}
|
|
78
|
-
|
|
96
|
+
} catch (_a) {
|
|
97
|
+
// Ignorar errores al eliminar
|
|
79
98
|
}
|
|
80
99
|
};
|
|
100
|
+
|
|
81
101
|
const folderInfo = await (0, promises_1.stat)(folder).catch(() => { });
|
|
82
102
|
if (folderInfo) {
|
|
83
103
|
if (!folderInfo.isDirectory()) {
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const chalk = require('chalk');
|
|
3
3
|
console.clear();
|
|
4
|
-
console.log(chalk.hex('#FFFFFF')('Baileys
|
|
4
|
+
console.log(chalk.hex('#FFFFFF')('Baileys Asta ') + chalk.hex('#00FFFF')('By Fer2809fl\n'));
|
|
5
5
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fer2809fl/baileys",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.9",
|
|
4
4
|
"description": "API de WhatsApp Web para Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"multi-device",
|
|
11
11
|
"websocket"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://github.com/Fer2809fl/
|
|
13
|
+
"homepage": "https://github.com/Fer2809fl/Bail",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/Fer2809fl/
|
|
16
|
+
"url": "https://github.com/Fer2809fl/Bail"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Fer2809fl",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"cheerio": "^1.0.0-rc.10",
|
|
48
48
|
"gradient-string": "^2.0.2",
|
|
49
49
|
"libphonenumber-js": "^1.10.20",
|
|
50
|
-
"libsignal": "
|
|
50
|
+
"libsignal": "github:adiwajshing/libsignal-node",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
52
52
|
"music-metadata": "^7.12.3",
|
|
53
53
|
"pino": "^9.6.0",
|
|
@@ -100,4 +100,4 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=20.0.0"
|
|
102
102
|
}
|
|
103
|
-
}
|
|
103
|
+
}
|