@neelegirly/baileys 2.2.18 → 2.2.20
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 +32 -28
- package/lib/Socket/business.d.ts +6 -1
- package/lib/Socket/chats.d.ts +6 -1
- package/lib/Socket/chats.js +121 -28
- package/lib/Socket/communities.d.ts +5 -0
- package/lib/Socket/groups.d.ts +6 -1
- package/lib/Socket/groups.js +15 -1
- package/lib/Socket/index.d.ts +6 -1
- package/lib/Socket/messages-recv.d.ts +5 -0
- package/lib/Socket/messages-recv.js +26 -8
- package/lib/Socket/messages-send.d.ts +6 -1
- package/lib/Socket/newsletter.d.ts +6 -1
- package/lib/Socket/registration.d.ts +5 -0
- package/lib/Socket/socket.js +55 -29
- package/lib/Types/Call.d.ts +3 -2
- package/lib/Types/Contact.d.ts +3 -1
- package/lib/Types/Events.d.ts +14 -1
- package/lib/Types/GroupMetadata.d.ts +9 -1
- package/lib/Types/Message.d.ts +21 -3
- package/lib/Types/Signal.d.ts +17 -1
- package/lib/Utils/chat-utils.d.ts +21 -1
- package/lib/Utils/chat-utils.js +27 -8
- package/lib/Utils/decode-wa-message.js +5 -1
- package/lib/Utils/event-buffer.js +3 -1
- package/lib/Utils/generics.js +9 -0
- package/lib/Utils/history.js +10 -11
- package/lib/Utils/messages-media.js +2 -2
- package/lib/Utils/messages.js +19 -2
- package/lib/Utils/process-message.js +5 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +27 -4
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +31 -0
- package/lib/WAUSync/Protocols/index.d.ts +2 -1
- package/lib/WAUSync/Protocols/index.js +2 -1
- package/lib/WAUSync/USyncQuery.d.ts +2 -1
- package/lib/WAUSync/USyncQuery.js +5 -1
- package/lib/WAUSync/USyncUser.d.ts +4 -0
- package/lib/WAUSync/USyncUser.js +9 -1
- package/package.json +8 -8
package/lib/Utils/history.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const promises_1 = require("stream/promises")
|
|
6
6
|
const zlib_1 = require("zlib")
|
|
7
7
|
const WAProto_1 = require("../../WAProto")
|
|
8
8
|
const Types_1 = require("../Types")
|
|
@@ -10,17 +10,14 @@ const WABinary_1 = require("../WABinary")
|
|
|
10
10
|
const generics_1 = require("./generics")
|
|
11
11
|
const messages_1 = require("./messages")
|
|
12
12
|
const messages_media_1 = require("./messages-media")
|
|
13
|
-
const inflatePromise = util_1.promisify(zlib_1.inflate)
|
|
14
13
|
|
|
15
14
|
const downloadHistory = async (msg, options) => {
|
|
16
15
|
const stream = await messages_media_1.downloadContentFromMessage(msg, 'md-msg-hist', { options })
|
|
16
|
+
const inflater = zlib_1.createInflate()
|
|
17
17
|
const bufferArray = []
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let buffer = Buffer.concat(bufferArray)
|
|
22
|
-
// decompress buffer
|
|
23
|
-
buffer = await inflatePromise(buffer)
|
|
18
|
+
inflater.on('data', chunk => bufferArray.push(chunk))
|
|
19
|
+
await promises_1.pipeline(stream, inflater)
|
|
20
|
+
const buffer = Buffer.concat(bufferArray)
|
|
24
21
|
const syncData = WAProto_1.proto.HistorySync.decode(buffer)
|
|
25
22
|
return syncData
|
|
26
23
|
}
|
|
@@ -37,7 +34,8 @@ const processHistoryMessage = (item) => {
|
|
|
37
34
|
for (const chat of item.conversations) {
|
|
38
35
|
contacts.push({
|
|
39
36
|
id: chat.id,
|
|
40
|
-
name: chat.name || undefined,
|
|
37
|
+
name: chat.displayName || chat.name || chat.username || undefined,
|
|
38
|
+
username: chat.username || undefined,
|
|
41
39
|
lid: chat.lidJid || undefined,
|
|
42
40
|
jid: (0, WABinary_1.isJidUser)(chat.id) ? chat.id : undefined
|
|
43
41
|
});
|
|
@@ -68,7 +66,7 @@ const processHistoryMessage = (item) => {
|
|
|
68
66
|
if (WABinary_1.isJidUser(chat.id) && chat.readOnly && chat.archived) {
|
|
69
67
|
delete chat.readOnly
|
|
70
68
|
}
|
|
71
|
-
chats.push(
|
|
69
|
+
chats.push(chat)
|
|
72
70
|
}
|
|
73
71
|
break
|
|
74
72
|
case WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
@@ -76,6 +74,7 @@ const processHistoryMessage = (item) => {
|
|
|
76
74
|
contacts.push({
|
|
77
75
|
id: c.id,
|
|
78
76
|
name: c.name || undefined,
|
|
77
|
+
username: c.username || undefined,
|
|
79
78
|
lid: c.lidJid || undefined,
|
|
80
79
|
jid: WABinary_1.isJidUser(c.id) ? c.id : undefined
|
|
81
80
|
})
|
|
@@ -107,4 +106,4 @@ module.exports = {
|
|
|
107
106
|
processHistoryMessage,
|
|
108
107
|
downloadAndProcessHistorySyncNotification,
|
|
109
108
|
getHistoryMsg
|
|
110
|
-
}
|
|
109
|
+
}
|
|
@@ -572,7 +572,7 @@ const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, { startB
|
|
|
572
572
|
}
|
|
573
573
|
const output = new stream_1.Transform({
|
|
574
574
|
transform(chunk, _, callback) {
|
|
575
|
-
let data = Buffer.concat([remainingBytes, chunk])
|
|
575
|
+
let data = remainingBytes.length ? Buffer.concat([remainingBytes, chunk]) : chunk
|
|
576
576
|
const decryptLength = toSmallestChunkSize(data.length)
|
|
577
577
|
remainingBytes = data.slice(decryptLength)
|
|
578
578
|
data = data.slice(0, decryptLength)
|
|
@@ -803,4 +803,4 @@ module.exports = {
|
|
|
803
803
|
decryptMediaRetryData,
|
|
804
804
|
getStatusCodeForMediaRetry,
|
|
805
805
|
MEDIA_RETRY_STATUS_MAP
|
|
806
|
-
}
|
|
806
|
+
}
|
package/lib/Utils/messages.js
CHANGED
|
@@ -643,6 +643,13 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
else if ('album' in message) {
|
|
647
|
+
m.albumMessage = {
|
|
648
|
+
expectedImageCount: message.album.expectedImageCount,
|
|
649
|
+
expectedVideoCount: message.album.expectedVideoCount
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
646
653
|
else if ('payment' in message) {
|
|
647
654
|
const requestPaymentMessage = {
|
|
648
655
|
amount: {
|
|
@@ -753,6 +760,16 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
753
760
|
m = mess
|
|
754
761
|
}
|
|
755
762
|
|
|
763
|
+
if ('albumParentKey' in message && !!message.albumParentKey) {
|
|
764
|
+
m.messageContextInfo = {
|
|
765
|
+
...m.messageContextInfo,
|
|
766
|
+
messageAssociation: {
|
|
767
|
+
associationType: WAProto_1.proto.MessageAssociation.AssociationType.MEDIA_ALBUM,
|
|
768
|
+
parentMessageKey: message.albumParentKey
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
756
773
|
if ('sections' in message && !!message.sections) {
|
|
757
774
|
const listMessage = {
|
|
758
775
|
title: message.title,
|
|
@@ -851,7 +868,7 @@ const generateWAMessageContent = async (message, options) => {
|
|
|
851
868
|
hydratedTemplate.hydratedContentText = message.caption
|
|
852
869
|
}
|
|
853
870
|
|
|
854
|
-
Object.assign(
|
|
871
|
+
Object.assign(hydratedTemplate, m)
|
|
855
872
|
}
|
|
856
873
|
|
|
857
874
|
if ('footer' in message && !!message.footer) {
|
|
@@ -1576,4 +1593,4 @@ module.exports = {
|
|
|
1576
1593
|
downloadMediaMessage,
|
|
1577
1594
|
assertMediaContent,
|
|
1578
1595
|
patchMessageForMdIfRequired
|
|
1579
|
-
}
|
|
1596
|
+
}
|
|
@@ -161,6 +161,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
161
161
|
isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
162
162
|
? isLatest
|
|
163
163
|
: undefined,
|
|
164
|
+
chunkOrder: histNotification.chunkOrder,
|
|
164
165
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
165
166
|
})
|
|
166
167
|
}
|
|
@@ -283,15 +284,15 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
283
284
|
let participants
|
|
284
285
|
|
|
285
286
|
const jid2 = message.key.participant;
|
|
286
|
-
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: jid2, participants, action}))
|
|
287
|
+
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: jid2, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername, participants, action}))
|
|
287
288
|
const emitGroupUpdate = (update) => {
|
|
288
|
-
ev.emit('groups.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined }])
|
|
289
|
+
ev.emit('groups.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername }])
|
|
289
290
|
}
|
|
290
291
|
const emitCommunityUpdate = (update) => {
|
|
291
|
-
ev.emit('communities.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined }])
|
|
292
|
+
ev.emit('communities.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername }])
|
|
292
293
|
}
|
|
293
294
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
294
|
-
ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method })
|
|
295
|
+
ev.emit('group.join-request', { id: jid, author: message.participant, authorPn: message.key.participantAlt, authorUsername: message.key.participantUsername, participant, action, method: method })
|
|
295
296
|
}
|
|
296
297
|
const participantsIncludesMe = () => participants.find(jid => WABinary_1.areJidsSameUser(meId, jid))
|
|
297
298
|
switch (message.messageStubType) {
|
|
@@ -15,11 +15,34 @@ class USyncContactProtocol {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
getUserElement(user) {
|
|
18
|
-
|
|
18
|
+
if (user.phone) {
|
|
19
|
+
return {
|
|
20
|
+
tag: 'contact',
|
|
21
|
+
attrs: {},
|
|
22
|
+
content: user.phone,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (user.username) {
|
|
26
|
+
return {
|
|
27
|
+
tag: 'contact',
|
|
28
|
+
attrs: {
|
|
29
|
+
username: user.username,
|
|
30
|
+
...(user.usernameKey ? { pin: user.usernameKey } : {}),
|
|
31
|
+
...(user.lid ? { lid: user.lid } : {})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (user.type) {
|
|
36
|
+
return {
|
|
37
|
+
tag: 'contact',
|
|
38
|
+
attrs: {
|
|
39
|
+
type: user.type
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
19
43
|
return {
|
|
20
44
|
tag: 'contact',
|
|
21
|
-
attrs: {}
|
|
22
|
-
content: user.phone,
|
|
45
|
+
attrs: {}
|
|
23
46
|
}
|
|
24
47
|
}
|
|
25
48
|
parser(node) {
|
|
@@ -33,4 +56,4 @@ class USyncContactProtocol {
|
|
|
33
56
|
|
|
34
57
|
module.exports = {
|
|
35
58
|
USyncContactProtocol
|
|
36
|
-
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync'
|
|
2
|
+
import { BinaryNode } from '../../WABinary'
|
|
3
|
+
|
|
4
|
+
export declare class USyncUsernameProtocol implements USyncQueryProtocol {
|
|
5
|
+
name: string
|
|
6
|
+
getQueryElement(): BinaryNode
|
|
7
|
+
getUserElement(): null
|
|
8
|
+
parser(node: BinaryNode): string | null
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const WABinary_1 = require("../../WABinary")
|
|
6
|
+
|
|
7
|
+
class USyncUsernameProtocol {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = 'username'
|
|
10
|
+
}
|
|
11
|
+
getQueryElement() {
|
|
12
|
+
return {
|
|
13
|
+
tag: 'username',
|
|
14
|
+
attrs: {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
getUserElement() {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
parser(node) {
|
|
21
|
+
if (node.tag === 'username') {
|
|
22
|
+
WABinary_1.assertNodeErrorFree(node)
|
|
23
|
+
return typeof node.content === 'string' ? node.content : null
|
|
24
|
+
}
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
USyncUsernameProtocol
|
|
31
|
+
}
|
|
@@ -3,4 +3,5 @@ export * from './USyncContactProtocol'
|
|
|
3
3
|
export * from './USyncDeviceProtocol'
|
|
4
4
|
export * from './USyncLIDProtocol'
|
|
5
5
|
export * from './USyncStatusProtocol'
|
|
6
|
-
export * from './USyncDisappearingModeProtocol'
|
|
6
|
+
export * from './USyncDisappearingModeProtocol'
|
|
7
|
+
export * from './USyncUsernameProtocol'
|
|
@@ -23,4 +23,5 @@ __exportStar(require("./USyncContactProtocol"), exports)
|
|
|
23
23
|
__exportStar(require("./USyncDeviceProtocol"), exports)
|
|
24
24
|
__exportStar(require("./USyncLIDProtocol"), exports)
|
|
25
25
|
__exportStar(require("./USyncStatusProtocol"), exports)
|
|
26
|
-
__exportStar(require("./USyncDisappearingModeProtocol"), exports)
|
|
26
|
+
__exportStar(require("./USyncDisappearingModeProtocol"), exports)
|
|
27
|
+
__exportStar(require("./USyncUsernameProtocol"), exports)
|
|
@@ -75,8 +75,12 @@ class USyncQuery {
|
|
|
75
75
|
this.protocols.push(new Protocols_1.USyncDisappearingModeProtocol())
|
|
76
76
|
return this
|
|
77
77
|
}
|
|
78
|
+
withUsernameProtocol() {
|
|
79
|
+
this.protocols.push(new Protocols_1.USyncUsernameProtocol())
|
|
80
|
+
return this
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
module.exports = {
|
|
81
85
|
USyncQuery
|
|
82
|
-
}
|
|
86
|
+
}
|
|
@@ -2,11 +2,15 @@ export declare class USyncUser {
|
|
|
2
2
|
id: string
|
|
3
3
|
lid: string
|
|
4
4
|
phone: string
|
|
5
|
+
username: string
|
|
6
|
+
usernameKey: string
|
|
5
7
|
type: string
|
|
6
8
|
personaId: string
|
|
7
9
|
withId(id: string): this
|
|
8
10
|
withLid(lid: string): this
|
|
9
11
|
withPhone(phone: string): this
|
|
12
|
+
withUsername(username: string): this
|
|
13
|
+
withUsernameKey(usernameKey: string): this
|
|
10
14
|
withType(type: string): this
|
|
11
15
|
withPersonaId(personaId: string): this
|
|
12
16
|
}
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -15,6 +15,14 @@ class USyncUser {
|
|
|
15
15
|
this.phone = phone
|
|
16
16
|
return this
|
|
17
17
|
}
|
|
18
|
+
withUsername(username) {
|
|
19
|
+
this.username = username
|
|
20
|
+
return this
|
|
21
|
+
}
|
|
22
|
+
withUsernameKey(usernameKey) {
|
|
23
|
+
this.usernameKey = usernameKey
|
|
24
|
+
return this
|
|
25
|
+
}
|
|
18
26
|
withType(type) {
|
|
19
27
|
this.type = type
|
|
20
28
|
return this
|
|
@@ -27,4 +35,4 @@ class USyncUser {
|
|
|
27
35
|
|
|
28
36
|
module.exports = {
|
|
29
37
|
USyncUser
|
|
30
|
-
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neelegirly/baileys",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
4
4
|
"description": "Neelegirly fork of Baileys: multi-device WhatsApp Web API for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -39,16 +39,11 @@
|
|
|
39
39
|
"./lib/*": "./lib/*",
|
|
40
40
|
"./WAProto/*": "./WAProto/*"
|
|
41
41
|
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"build:all": "tsc && typedoc",
|
|
44
|
-
"build:docs": "typedoc",
|
|
45
|
-
"build:tsc": "tsc"
|
|
46
|
-
},
|
|
47
42
|
"dependencies": {
|
|
48
43
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
49
44
|
"@cacheable/node-cache": "^1.5.4",
|
|
50
45
|
"@hapi/boom": "^9.1.3",
|
|
51
|
-
"@neelegirly/libsignal": "1.0.
|
|
46
|
+
"@neelegirly/libsignal": "1.0.29",
|
|
52
47
|
"async-mutex": "^0.5.0",
|
|
53
48
|
"audio-decode": "^2.1.3",
|
|
54
49
|
"axios": "^1.3.3",
|
|
@@ -63,7 +58,7 @@
|
|
|
63
58
|
"ws": "^8.13.0"
|
|
64
59
|
},
|
|
65
60
|
"overrides": {
|
|
66
|
-
"@neelegirly/libsignal": "1.0.
|
|
61
|
+
"@neelegirly/libsignal": "1.0.29"
|
|
67
62
|
},
|
|
68
63
|
"devDependencies": {
|
|
69
64
|
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|
|
@@ -116,5 +111,10 @@
|
|
|
116
111
|
"packageManager": "yarn@1.22.19",
|
|
117
112
|
"bugs": {
|
|
118
113
|
"url": "https://github.com/neelegirly/baileys/issues"
|
|
114
|
+
},
|
|
115
|
+
"scripts": {
|
|
116
|
+
"build:all": "tsc && typedoc",
|
|
117
|
+
"build:docs": "typedoc",
|
|
118
|
+
"build:tsc": "tsc"
|
|
119
119
|
}
|
|
120
120
|
}
|