@rexxhayanasi/elaina-baileys 1.0.9 → 1.1.0-DEV.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.
- package/README.MD +55 -14
- package/WAProto/WAProto.proto +1013 -169
- package/lib/Auth/index.js +8 -0
- package/lib/Auth/sqlite.js +57 -0
- package/lib/Socket/Rhandler.js +158 -240
- package/lib/Socket/business.js +6 -1
- package/lib/Socket/chats.js +96 -44
- package/lib/Socket/index.js +35 -9
- package/lib/Socket/messages-send.js +13 -11
- package/lib/Socket/newsletter.js +36 -0
- package/lib/Socket/socket.js +160 -98
- package/lib/index.js +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useSQLiteAuth = void 0;
|
|
7
|
+
const sqlite_1 = __importDefault(require("./sqlite"));
|
|
8
|
+
exports.useSQLiteAuth = sqlite_1.default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useSQLiteAuth = void 0;
|
|
5
|
+
|
|
6
|
+
const BetterSqlite = require("better-sqlite3");
|
|
7
|
+
const { BufferJSON } = require("../index");
|
|
8
|
+
const { initAuthCreds } = require("../Utils");
|
|
9
|
+
|
|
10
|
+
const db = new BetterSqlite("./session.db");
|
|
11
|
+
|
|
12
|
+
db.exec(`
|
|
13
|
+
CREATE TABLE IF NOT EXISTS auth (
|
|
14
|
+
id TEXT PRIMARY KEY,
|
|
15
|
+
data TEXT
|
|
16
|
+
)
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
const useSQLiteAuth = () => {
|
|
20
|
+
const readData = (id) => {
|
|
21
|
+
const row = db.prepare("SELECT data FROM auth WHERE id=?").get(id);
|
|
22
|
+
return row ? JSON.parse(row.data, BufferJSON.reviver) : null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const writeData = (id, data) => {
|
|
26
|
+
db.prepare("INSERT OR REPLACE INTO auth VALUES (?, ?)")
|
|
27
|
+
.run(id, JSON.stringify(data, BufferJSON.replacer));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const state = {
|
|
31
|
+
creds: readData("creds") || initAuthCreds(),
|
|
32
|
+
keys: {
|
|
33
|
+
get(type, ids) {
|
|
34
|
+
const data = {};
|
|
35
|
+
for (const id of ids) {
|
|
36
|
+
const value = readData(`${type}-${id}`);
|
|
37
|
+
if (value) data[id] = value;
|
|
38
|
+
}
|
|
39
|
+
return data;
|
|
40
|
+
},
|
|
41
|
+
set(data) {
|
|
42
|
+
for (const type in data) {
|
|
43
|
+
for (const id in data[type]) {
|
|
44
|
+
writeData(`${type}-${id}`, data[type][id]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const saveCreds = () => writeData("creds", state.creds);
|
|
52
|
+
|
|
53
|
+
return { state, saveCreds };
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.useSQLiteAuth = useSQLiteAuth;
|
|
57
|
+
exports.default = useSQLiteAuth;
|