@rexxhayanasi/elaina-baileys 1.1.0-rc.6 → 1.1.0
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/lib/Auth/sqlite.js +8 -9
- package/lib/Socket/socket.js +13 -14
- package/package.json +7 -9
package/lib/Auth/sqlite.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.useSQLiteAuth = void 0;
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const BetterSqlite = require("better-sqlite3");
|
|
7
|
+
const { BufferJSON } = require("../index");
|
|
8
|
+
const { initAuthCreds } = require("../Utils");
|
|
8
9
|
|
|
9
|
-
const BetterSqlite = better_sqlite3_1.default || better_sqlite3_1;
|
|
10
10
|
const db = new BetterSqlite("./session.db");
|
|
11
11
|
|
|
12
12
|
db.exec(`
|
|
@@ -19,23 +19,22 @@ db.exec(`
|
|
|
19
19
|
const useSQLiteAuth = () => {
|
|
20
20
|
const readData = (id) => {
|
|
21
21
|
const row = db.prepare("SELECT data FROM auth WHERE id=?").get(id);
|
|
22
|
-
return row ? JSON.parse(row.data,
|
|
22
|
+
return row ? JSON.parse(row.data, BufferJSON.reviver) : null;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const writeData = (id, data) => {
|
|
26
26
|
db.prepare("INSERT OR REPLACE INTO auth VALUES (?, ?)")
|
|
27
|
-
|
|
27
|
+
.run(id, JSON.stringify(data, BufferJSON.replacer));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const state = {
|
|
31
|
-
creds: readData("creds") ||
|
|
31
|
+
creds: readData("creds") || initAuthCreds(),
|
|
32
32
|
keys: {
|
|
33
33
|
get(type, ids) {
|
|
34
34
|
const data = {};
|
|
35
35
|
for (const id of ids) {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
data[id] = v;
|
|
36
|
+
const value = readData(`${type}-${id}`);
|
|
37
|
+
if (value) data[id] = value;
|
|
39
38
|
}
|
|
40
39
|
return data;
|
|
41
40
|
},
|
package/lib/Socket/socket.js
CHANGED
|
@@ -429,8 +429,12 @@ const end = (error) => {
|
|
|
429
429
|
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5))
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
authState.creds.
|
|
433
|
-
|
|
432
|
+
authState.creds.me = {
|
|
433
|
+
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
434
|
+
name: '~'
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
ev.emit('creds.update', authState.creds)
|
|
434
438
|
|
|
435
439
|
await sendNode({
|
|
436
440
|
tag: 'iq',
|
|
@@ -526,19 +530,14 @@ ev.emit('creds.update', authState.creds)
|
|
|
526
530
|
};
|
|
527
531
|
ws.on('message', onMessageReceived);
|
|
528
532
|
ws.on('open', async () => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
authState.creds.isConnecting = true;
|
|
532
|
-
ev.emit('creds.update', authState.creds);
|
|
533
|
+
try {
|
|
534
|
+
await validateConnection();
|
|
533
535
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
end(err);
|
|
540
|
-
}
|
|
541
|
-
});
|
|
536
|
+
catch (err) {
|
|
537
|
+
logger.error({ err }, 'error in validating connection');
|
|
538
|
+
end(err);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
542
541
|
ws.on('error', mapWebSocketError(end));
|
|
543
542
|
ws.on('close', () => end(new boom_1.Boom('Connection Terminated', { statusCode: Types_1.DisconnectReason.connectionClosed })));
|
|
544
543
|
// the server terminated the connection
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexxhayanasi/elaina-baileys",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Custom Baileys WhatsApp API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"whatsapp-web",
|
|
13
13
|
"whatsapp-bot",
|
|
14
14
|
"automation",
|
|
15
|
-
"multi-device"
|
|
15
|
+
"multi-device",
|
|
16
|
+
"RexxHayanasi"
|
|
16
17
|
],
|
|
17
18
|
"homepage": "https://whatsapp.com/channel/0029Vb70uHbD8SE2w5Q9M107",
|
|
18
19
|
"license": "MIT",
|
|
@@ -46,8 +47,8 @@
|
|
|
46
47
|
"@cacheable/node-cache": "^1.4.0",
|
|
47
48
|
"@hapi/boom": "^9.1.3",
|
|
48
49
|
"async-mutex": "^0.5.0",
|
|
50
|
+
"audio-decode": "^2.1.3",
|
|
49
51
|
"axios": "^1.6.0",
|
|
50
|
-
"better-sqlite3": "^12.5.0",
|
|
51
52
|
"chalk": "^4.1.2",
|
|
52
53
|
"gradient-string": "^2.0.2",
|
|
53
54
|
"cache-manager": "^5.7.6",
|
|
@@ -84,16 +85,13 @@
|
|
|
84
85
|
"typescript": "^5.8.2"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
|
-
"audio-decode": "^2.1.3",
|
|
88
88
|
"jimp": "^0.22.10",
|
|
89
89
|
"link-preview-js": "^3.0.0",
|
|
90
90
|
"qrcode-terminal": "^0.12.0",
|
|
91
|
-
"sharp": "^0.34.1"
|
|
91
|
+
"sharp": "^0.34.1",
|
|
92
|
+
"better-sqlite3": "^12.5.0"
|
|
92
93
|
},
|
|
93
|
-
"peerDependenciesMeta": {
|
|
94
|
-
"audio-decode": {
|
|
95
|
-
"optional": true
|
|
96
|
-
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
97
95
|
"jimp": {
|
|
98
96
|
"optional": true
|
|
99
97
|
},
|