@baileys-md/baileys 11.2.4 → 12.0.1
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/LICENSE +1 -1
- package/WAProto/WAProto.proto +5311 -0
- package/WAProto/index.js +70084 -131686
- package/lib/Defaults/index.js +118 -117
- package/lib/KeyDB/BinarySearch.js +20 -0
- package/lib/KeyDB/KeyedDB.js +167 -0
- package/lib/KeyDB/index.js +4 -0
- package/lib/Signal/Group/ciphertext-message.js +13 -0
- package/lib/Signal/Group/group-session-builder.js +32 -0
- package/lib/Signal/Group/group_cipher.js +84 -0
- package/lib/Signal/Group/index.js +13 -0
- package/lib/Signal/Group/keyhelper.js +20 -0
- package/lib/Signal/Group/sender-chain-key.js +28 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +65 -0
- package/lib/Signal/Group/sender-key-message.js +68 -0
- package/{WASignalGroup/sender_key_name.js → lib/Signal/Group/sender-key-name.js} +10 -28
- package/lib/Signal/Group/sender-key-record.js +43 -0
- package/lib/Signal/Group/sender-key-state.js +86 -0
- package/lib/Signal/Group/sender-message-key.js +28 -0
- package/lib/Signal/libsignal.js +314 -151
- package/lib/Signal/lid-mapping.js +155 -0
- package/lib/Socket/Client/index.js +4 -19
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +52 -0
- package/lib/Socket/business.js +359 -242
- package/lib/Socket/chats.js +847 -844
- package/lib/Socket/communities.js +413 -0
- package/lib/Socket/groups.js +304 -319
- package/lib/Socket/index.js +15 -9
- package/lib/Socket/messages-recv.js +1109 -989
- package/lib/Socket/messages-send.js +611 -347
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.js +230 -231
- package/lib/Socket/socket.js +795 -616
- package/lib/Store/index.js +6 -8
- package/lib/Store/make-cache-manager-store.js +73 -81
- package/lib/Store/make-in-memory-store.js +286 -427
- package/lib/Store/make-ordered-dictionary.js +77 -79
- package/lib/Store/object-repository.js +24 -26
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +9 -4
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +12 -7
- package/lib/Types/Newsletter.js +32 -17
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.js +4 -2
- package/lib/Types/State.js +11 -2
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.js +27 -41
- package/lib/Utils/auth-utils.js +211 -198
- package/lib/Utils/baileys-event-stream.js +42 -61
- package/lib/Utils/browser-utils.js +25 -0
- package/lib/Utils/business.js +213 -214
- package/lib/Utils/chat-utils.js +711 -689
- package/lib/Utils/crypto.js +112 -133
- package/lib/Utils/decode-wa-message.js +254 -186
- package/lib/Utils/event-buffer.js +510 -502
- package/lib/Utils/generics.js +318 -408
- package/lib/Utils/history.js +83 -90
- package/lib/Utils/index.js +21 -33
- package/lib/Utils/link-preview.js +71 -116
- package/lib/Utils/logger.js +5 -7
- package/lib/Utils/lt-hash.js +40 -46
- package/lib/Utils/make-mutex.js +34 -41
- package/lib/Utils/message-retry-manager.js +113 -0
- package/lib/Utils/messages-media.js +575 -671
- package/lib/Utils/messages.js +354 -462
- package/lib/Utils/noise-handler.js +138 -149
- package/lib/Utils/pre-key-manager.js +85 -0
- package/lib/Utils/process-message.js +323 -354
- package/lib/Utils/signal.js +148 -130
- package/lib/Utils/use-multi-file-auth-state.js +109 -91
- package/lib/Utils/validate-connection.js +183 -190
- package/lib/WABinary/constants.js +1298 -35
- package/lib/WABinary/decode.js +231 -256
- package/lib/WABinary/encode.js +207 -239
- package/lib/WABinary/generic-utils.js +119 -40
- package/lib/WABinary/index.js +7 -21
- package/lib/WABinary/jid-utils.js +88 -64
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.js +10 -12
- package/lib/WAM/constants.js +22851 -15348
- package/lib/WAM/encode.js +135 -136
- package/lib/WAM/index.js +5 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
- package/lib/WAUSync/Protocols/index.js +6 -20
- package/lib/WAUSync/USyncQuery.js +86 -85
- package/lib/WAUSync/USyncUser.js +23 -25
- package/lib/WAUSync/index.js +5 -19
- package/lib/index.js +18 -33
- package/package.json +52 -57
- package/README.md +0 -2
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/WASignalGroup/sender_message_key.js +0 -39
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/make-mongo-store.js +0 -567
package/lib/Store/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
|
|
8
|
-
exports.makeInMemoryStore = make_in_memory_store_1.default;
|
|
1
|
+
//===================================//
|
|
2
|
+
export * from "./make-cache-manager-store.js"
|
|
3
|
+
export * from "./make-ordered-dictionary.js"
|
|
4
|
+
export * from "./make-in-memory-store.js"
|
|
5
|
+
export * from "./object-repository.js"
|
|
6
|
+
//===================================//
|
|
@@ -1,83 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
set: async (data) => {
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
-
const tasks = [];
|
|
70
|
-
for (const category in data) {
|
|
71
|
-
for (const id in data[category]) {
|
|
72
|
-
const value = data[category][id];
|
|
73
|
-
const key = `${category}-${id}`;
|
|
74
|
-
tasks.push(value ? writeData(key, value) : removeData(key));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
await Promise.all(tasks);
|
|
78
|
-
},
|
|
1
|
+
//===================================//
|
|
2
|
+
import { BufferJSON, initAuthCreds } from "../Utils/index.js";
|
|
3
|
+
import { proto } from "../../WAProto/index.js";
|
|
4
|
+
import { createCache } from "cache-manager";
|
|
5
|
+
import logger from "../Utils/logger.js";
|
|
6
|
+
//===================================//
|
|
7
|
+
export async function makeCacheManagerAuthState(store, sessionKey) {
|
|
8
|
+
const defaultKey = (file) => `${sessionKey}:${file}`
|
|
9
|
+
const databaseConn = await caching(store);
|
|
10
|
+
const writeData = async (file, data) => {
|
|
11
|
+
let ttl
|
|
12
|
+
if (file === "creds") {
|
|
13
|
+
ttl = 63115200
|
|
14
|
+
}
|
|
15
|
+
await databaseConn.set(defaultKey(file), JSON.stringify(data, BufferJSON.replacer), ttl)
|
|
16
|
+
}
|
|
17
|
+
const readData = async (file) => {
|
|
18
|
+
try {
|
|
19
|
+
const data = await databaseConn.get(defaultKey(file))
|
|
20
|
+
if (data) return JSON.parse(data, BufferJSON.reviver)
|
|
21
|
+
return null
|
|
22
|
+
} catch (error) {
|
|
23
|
+
logger.error(error)
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const removeData = async (file) => {
|
|
28
|
+
try {
|
|
29
|
+
return await databaseConn.del(defaultKey(file))
|
|
30
|
+
} catch (err) {
|
|
31
|
+
logger.error(`Error removing ${file} from session ${sessionKey}`)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const clearState = async () => {
|
|
35
|
+
try {
|
|
36
|
+
const keys = await databaseConn.store.keys(`${sessionKey}*`)
|
|
37
|
+
await Promise.all(keys.map((key) => databaseConn.del(key)))
|
|
38
|
+
} catch (err) {}
|
|
39
|
+
}
|
|
40
|
+
const creds = (await readData("creds")) || initAuthCreds()
|
|
41
|
+
return {
|
|
42
|
+
clearState,
|
|
43
|
+
saveCreds: () => writeData("creds", creds),
|
|
44
|
+
state: {
|
|
45
|
+
creds,
|
|
46
|
+
keys: {
|
|
47
|
+
get: async (type, ids) => {
|
|
48
|
+
const data = {}
|
|
49
|
+
await Promise.all(
|
|
50
|
+
ids.map(async (id) => {
|
|
51
|
+
let value = await readData(`${type}-${id}`)
|
|
52
|
+
if (type === "app-state-sync-key" && value) {
|
|
53
|
+
value = proto.Message.AppStateSyncKeyData.fromObject(value)
|
|
54
|
+
}
|
|
55
|
+
data[id] = value
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
return data
|
|
59
|
+
},
|
|
60
|
+
set: async (data) => {
|
|
61
|
+
const tasks = []
|
|
62
|
+
for (const category in data) {
|
|
63
|
+
for (const id in data[category]) {
|
|
64
|
+
const value = data[category][id]
|
|
65
|
+
const key = `${category}-${id}`
|
|
66
|
+
tasks.push(value ? writeData(key, value) : removeData(key))
|
|
79
67
|
}
|
|
68
|
+
}
|
|
69
|
+
await Promise.all(tasks)
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//===================================//
|