@neelegirly/baileys 2.2.22 โ 2.2.24
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 +54 -0
- package/lib/Socket/chats.js +1 -1
- package/lib/Socket/messages-recv.js +12 -2
- package/lib/Utils/chat-utils.d.ts +1 -1
- package/lib/Utils/chat-utils.js +40 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
<pre align="center">
|
|
2
|
+
๐ Neelegirly Ecosystem Clean Stability Update ๐
|
|
3
|
+
4 Packages ยท 1 App ยท PM2 only runs the app
|
|
4
|
+
</pre>
|
|
5
|
+
|
|
6
|
+
# ๐ธ @neelegirly/baileys
|
|
7
|
+
|
|
8
|
+
WhatsApp Web API core connection layer.
|
|
9
|
+
|
|
10
|
+
## Clean Architecture
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
@neelegirly/libsignal
|
|
14
|
+
โ
|
|
15
|
+
@neelegirly/baileys
|
|
16
|
+
โ
|
|
17
|
+
@neelegirly/wa-api
|
|
18
|
+
โ
|
|
19
|
+
App (PM2 managed)
|
|
20
|
+
โ
|
|
21
|
+
@neelegirly/downloader (optional utility)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Official Package Role
|
|
25
|
+
|
|
26
|
+
- Depends on @neelegirly/libsignal
|
|
27
|
+
- Core connection layer
|
|
28
|
+
- Used by @neelegirly/wa-api
|
|
29
|
+
|
|
30
|
+
## PM2 Rule
|
|
31
|
+
|
|
32
|
+
> WA-API handles sessions internally. PM2 only runs the app.
|
|
33
|
+
|
|
34
|
+
Start your app with PM2 like this:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pm2 start index.js --name bot
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Do not start one PM2 process per session. Sessions belong inside the app through `@neelegirly/wa-api`.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @neelegirly/baileys
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Clean Stability Release
|
|
49
|
+
|
|
50
|
+
This release clarifies the ecosystem structure and removes workspace/core confusion from the documentation.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
1
55
|
<div align="center">
|
|
2
56
|
|
|
3
57
|
# ๐ธ @neelegirly/baileys ๐ธ
|
package/lib/Socket/chats.js
CHANGED
|
@@ -544,7 +544,7 @@ const makeChatsSocket = (config) => {
|
|
|
544
544
|
const { patches, hasMorePatches, snapshot } = decoded[name]
|
|
545
545
|
try {
|
|
546
546
|
if (snapshot) {
|
|
547
|
-
const { state: newState, mutationMap } = await Utils_1.decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot)
|
|
547
|
+
const { state: newState, mutationMap } = await Utils_1.decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot, logger)
|
|
548
548
|
states[name] = newState
|
|
549
549
|
Object.assign(globalMutationMap, mutationMap)
|
|
550
550
|
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`)
|
|
@@ -896,9 +896,19 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
896
896
|
node.attrs.participant_username
|
|
897
897
|
);
|
|
898
898
|
break;
|
|
899
|
-
case "newsletter":
|
|
900
|
-
|
|
899
|
+
case "newsletter": {
|
|
900
|
+
const newsletterChildren = WABinary_1.getAllBinaryNodeChildren(node);
|
|
901
|
+
const nodesToHandle = newsletterChildren.length
|
|
902
|
+
? newsletterChildren
|
|
903
|
+
: child
|
|
904
|
+
? [child]
|
|
905
|
+
: [];
|
|
906
|
+
|
|
907
|
+
for (const newsletterChild of nodesToHandle) {
|
|
908
|
+
handleNewsletterNotification(node.attrs.from, newsletterChild);
|
|
909
|
+
}
|
|
901
910
|
break;
|
|
911
|
+
}
|
|
902
912
|
case "mex":
|
|
903
913
|
await handleMexNotification(node.attrs.from, child);
|
|
904
914
|
break;
|
|
@@ -85,7 +85,7 @@ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosReq
|
|
|
85
85
|
|
|
86
86
|
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<Buffer>
|
|
87
87
|
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>
|
|
88
|
-
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
|
88
|
+
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean, logger?: ILogger) => Promise<{
|
|
89
89
|
state: LTHashState
|
|
90
90
|
mutationMap: ChatMutationMap
|
|
91
91
|
}>
|
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -179,18 +179,33 @@ const decodeSyncdMutations = async (msgMutations, initialState, getAppStateSyncK
|
|
|
179
179
|
// otherwise, if it's only a record -- it'll be a SET mutation
|
|
180
180
|
const operation = 'operation' in msgMutation ? msgMutation.operation : WAProto_1.proto.SyncdMutation.SyncdOperation.SET
|
|
181
181
|
const record = ('record' in msgMutation && !!msgMutation.record) ? msgMutation.record : msgMutation
|
|
182
|
-
|
|
182
|
+
let key
|
|
183
|
+
try {
|
|
184
|
+
key = await getKey(record.keyId.id)
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
if (isMissingKeyError(error)) {
|
|
188
|
+
throw error
|
|
189
|
+
}
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
183
192
|
const content = Buffer.from(record.value.blob)
|
|
184
193
|
const encContent = content.slice(0, -32)
|
|
185
194
|
const ogValueMac = content.slice(-32)
|
|
186
195
|
if (validateMacs) {
|
|
187
196
|
const contentHmac = generateMac(operation, encContent, record.keyId.id, key.valueMacKey)
|
|
188
197
|
if (Buffer.compare(contentHmac, ogValueMac) !== 0) {
|
|
189
|
-
|
|
198
|
+
continue
|
|
190
199
|
}
|
|
191
200
|
}
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
let syncAction
|
|
202
|
+
try {
|
|
203
|
+
const result = crypto_1.aesDecrypt(encContent, key.valueEncryptionKey)
|
|
204
|
+
syncAction = WAProto_1.proto.SyncActionData.decode(result)
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
continue
|
|
208
|
+
}
|
|
194
209
|
if (validateMacs) {
|
|
195
210
|
const hmac = crypto_1.hmacSign(syncAction.index, key.indexKey)
|
|
196
211
|
if (Buffer.compare(hmac, record.index.blob) !== 0) {
|
|
@@ -286,7 +301,7 @@ const downloadExternalPatch = async (blob, options) => {
|
|
|
286
301
|
return syncData
|
|
287
302
|
}
|
|
288
303
|
|
|
289
|
-
const decodeSyncdSnapshot = async (name, snapshot, getAppStateSyncKey, minimumVersionNumber, validateMacs = true) => {
|
|
304
|
+
const decodeSyncdSnapshot = async (name, snapshot, getAppStateSyncKey, minimumVersionNumber, validateMacs = true, logger) => {
|
|
290
305
|
const newState = newLTHashState()
|
|
291
306
|
newState.version = generics_1.toNumber(snapshot.version.version)
|
|
292
307
|
const mutationMap = {}
|
|
@@ -309,7 +324,7 @@ const decodeSyncdSnapshot = async (name, snapshot, getAppStateSyncKey, minimumVe
|
|
|
309
324
|
const result = await mutationKeys(keyEnc.keyData)
|
|
310
325
|
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey)
|
|
311
326
|
if (Buffer.compare(snapshot.mac, computedSnapshotMac) !== 0) {
|
|
312
|
-
|
|
327
|
+
logger?.warn({ name, version: newState.version }, 'LTHash verification failed on snapshot, continuing with partial state')
|
|
313
328
|
}
|
|
314
329
|
}
|
|
315
330
|
return {
|
|
@@ -335,13 +350,24 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
|
|
|
335
350
|
const patchVersion = generics_1.toNumber(version.version)
|
|
336
351
|
newState.version = patchVersion
|
|
337
352
|
const shouldMutate = typeof minimumVersionNumber === 'undefined' || patchVersion > minimumVersionNumber
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
353
|
+
let decodeResult
|
|
354
|
+
try {
|
|
355
|
+
decodeResult = await decodeSyncdPatch(syncd, name, newState, getAppStateSyncKey, shouldMutate
|
|
356
|
+
? mutation => {
|
|
357
|
+
var _a
|
|
358
|
+
const index = mutation.syncAction.index?.toString()
|
|
359
|
+
mutationMap[index] = mutation
|
|
360
|
+
}
|
|
361
|
+
: (() => { }), validateMacs)
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
if (isMissingKeyError(error)) {
|
|
365
|
+
throw error
|
|
343
366
|
}
|
|
344
|
-
:
|
|
367
|
+
logger?.warn({ name, version: patchVersion, error: error?.stack || error }, 'failed to decode patch, skipping')
|
|
368
|
+
syncd.mutations = []
|
|
369
|
+
continue
|
|
370
|
+
}
|
|
345
371
|
newState.hash = decodeResult.hash
|
|
346
372
|
newState.indexValueMap = decodeResult.indexValueMap
|
|
347
373
|
if (validateMacs) {
|
|
@@ -353,7 +379,8 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
|
|
|
353
379
|
const result = await mutationKeys(keyEnc.keyData)
|
|
354
380
|
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey)
|
|
355
381
|
if (Buffer.compare(snapshotMac, computedSnapshotMac) !== 0) {
|
|
356
|
-
|
|
382
|
+
logger?.warn({ name, version: newState.version }, 'LTHash verification failed, skipping remaining patches')
|
|
383
|
+
break
|
|
357
384
|
}
|
|
358
385
|
}
|
|
359
386
|
// clear memory used up by the mutations
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neelegirly/baileys",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.24",
|
|
4
4
|
"description": "Neelegirly fork of Baileys: multi-device WhatsApp Web API for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
45
45
|
"@cacheable/node-cache": "^1.5.4",
|
|
46
46
|
"@hapi/boom": "^9.1.3",
|
|
47
|
-
"@neelegirly/libsignal": "1.0.
|
|
47
|
+
"@neelegirly/libsignal": "1.0.32",
|
|
48
48
|
"async-mutex": "^0.5.0",
|
|
49
49
|
"audio-decode": "^2.1.3",
|
|
50
50
|
"axios": "^1.3.3",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"ws": "^8.13.0"
|
|
60
60
|
},
|
|
61
61
|
"overrides": {
|
|
62
|
-
"@neelegirly/libsignal": "1.0.
|
|
62
|
+
"@neelegirly/libsignal": "1.0.32"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|