@badzz88/baileys 8.5.3 → 8.5.4
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 +1 -1
- package/WAProto/WAProto.proto +1256 -75
- package/WAProto/index.d.ts +36042 -19649
- package/WAProto/index.js +181990 -135645
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +22 -17
- package/lib/Signal/Group/group_cipher.js +5 -5
- package/lib/Signal/Group/keyhelper.js +4 -4
- package/lib/Signal/Group/sender-chain-key.js +2 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-record.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +5 -5
- package/lib/Signal/libsignal.js +39 -59
- package/lib/Signal/lid-mapping.js +28 -10
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +3 -11
- package/lib/Socket/chats.js +668 -319
- package/lib/Socket/communities.js +85 -89
- package/lib/Socket/graphql.js +435 -228
- package/lib/Socket/groups.js +132 -211
- package/lib/Socket/index.js +9 -7
- package/lib/Socket/interactive-handler.js +117 -60
- package/lib/Socket/interop.js +56 -175
- package/lib/Socket/managed-account.js +79 -48
- package/lib/Socket/messages-recv.js +898 -340
- package/lib/Socket/messages-send.js +462 -160
- package/lib/Socket/mex.js +40 -53
- package/lib/Socket/newsletter.js +291 -295
- package/lib/Socket/privacy.js +77 -265
- package/lib/Socket/registration.js +164 -157
- package/lib/Socket/socket.js +181 -199
- package/lib/Socket/username.js +144 -227
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +25 -141
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +96 -65
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +52 -57
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +2 -6
- package/lib/Utils/chat-utils.js +102 -38
- package/lib/Utils/crypto.js +54 -84
- package/lib/Utils/decode-wa-message.js +316 -83
- package/lib/Utils/event-buffer.js +37 -61
- package/lib/Utils/generics.js +157 -103
- package/lib/Utils/group-history.js +3 -12
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +1 -5
- package/lib/Utils/link-preview.js +3 -8
- package/lib/Utils/lt-hash.js +2 -35
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-inspect.js +393 -0
- package/lib/Utils/message-retry-manager.js +27 -92
- package/lib/Utils/messages-media.js +159 -130
- package/lib/Utils/messages.js +144 -566
- package/lib/Utils/meta-ai-msmsg.js +62 -202
- package/lib/Utils/noise-handler.js +19 -21
- package/lib/Utils/offline-node-processor.js +3 -8
- package/lib/Utils/pre-key-manager.js +13 -23
- package/lib/Utils/process-message.js +197 -106
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/signal.js +28 -63
- package/lib/Utils/stanza-ack.js +39 -12
- package/lib/Utils/sync-action-utils.js +4 -7
- package/lib/Utils/tc-token-utils.js +20 -25
- package/lib/Utils/use-multi-file-auth-state.js +30 -14
- package/lib/Utils/validate-connection.js +59 -19
- package/lib/WABinary/decode.js +50 -16
- package/lib/WABinary/encode.js +54 -224
- package/lib/WABinary/generic-utils.js +7 -97
- package/lib/WABinary/jid-utils.js +27 -14
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +58 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -4
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +20 -7
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +865 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -2
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncBackoff.js +26 -0
- package/lib/WAUSync/USyncQuery.js +77 -6
- package/lib/WAUSync/USyncUser.js +16 -8
- package/lib/WAUSync/index.js +1 -0
- package/lib/antiban.js +608 -854
- package/lib/index.js +1 -1
- package/package.json +16 -20
- package/lib/Socket/luxu.js +0 -387
- package/lib/Socket/text-router.js +0 -83
- package/lib/Store/keyed-db.js +0 -108
- package/lib/Types/Mex.js +0 -112
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/companion-reg-client-utils.js +0 -42
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/sticker.js +0 -145
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
|
@@ -5,7 +5,7 @@ const WABinary_1 = require('../../WABinary')
|
|
|
5
5
|
class USyncSidelistProtocol {
|
|
6
6
|
constructor(useLidAddressing = true) {
|
|
7
7
|
this.name = 'sidelist'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
this.useLidAddressing = useLidAddressing
|
|
10
10
|
}
|
|
11
11
|
getQueryElement() {
|
|
@@ -22,7 +22,7 @@ class USyncSidelistProtocol {
|
|
|
22
22
|
parser(node) {
|
|
23
23
|
if (node.tag !== 'sidelist' && node.tag !== 'side_list') return null
|
|
24
24
|
;(0, WABinary_1.assertNodeErrorFree)(node)
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
return { type: node.attrs?.type ?? null }
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -12,8 +12,13 @@ class USyncStatusProtocol {
|
|
|
12
12
|
attrs: {}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
getUserElement() {
|
|
16
|
-
return null
|
|
15
|
+
getUserElement(user) {
|
|
16
|
+
if (!user?.tcToken) return null
|
|
17
|
+
return {
|
|
18
|
+
tag: 'tctoken',
|
|
19
|
+
attrs: {},
|
|
20
|
+
content: user.tcToken
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
parser(node) {
|
|
19
24
|
if (node.tag === 'status') {
|
|
@@ -23,7 +23,7 @@ class USyncTextStatusProtocol {
|
|
|
23
23
|
const text = node.attrs?.text ?? null
|
|
24
24
|
const emojiNode = (0, WABinary_1.getBinaryNodeChild)(node, 'emoji')
|
|
25
25
|
const emoji = emojiNode?.attrs?.content ?? null
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
const expiresAt = ephemeralDurationSec > 0
|
|
28
28
|
? new Date((lastUpdateTimeSec + ephemeralDurationSec) * 1000)
|
|
29
29
|
: null
|
|
@@ -19,7 +19,8 @@ class USyncUsernameProtocol {
|
|
|
19
19
|
parser(node) {
|
|
20
20
|
if (node.tag === 'username') {
|
|
21
21
|
;(0, WABinary_1.assertNodeErrorFree)(node)
|
|
22
|
-
|
|
22
|
+
const username = node.content != null ? node.content.toString() : null
|
|
23
|
+
return username && username.length > 0 ? username : null
|
|
23
24
|
}
|
|
24
25
|
return null
|
|
25
26
|
}
|
|
@@ -35,5 +35,6 @@ __exportStar(require('./USyncBotProfileProtocol'), exports)
|
|
|
35
35
|
__exportStar(require('./USyncBusinessProtocol'), exports)
|
|
36
36
|
__exportStar(require('./USyncPictureProtocol'), exports)
|
|
37
37
|
__exportStar(require('./USyncTextStatusProtocol'), exports)
|
|
38
|
+
__exportStar(require('./USyncLIDProtocol'), exports)
|
|
38
39
|
__exportStar(require('./USyncSidelistProtocol'), exports)
|
|
39
40
|
__exportStar(require('./USyncFeatureProtocol'), exports)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.waitForBackoff = exports.setProtocolBackoffMs = void 0
|
|
4
|
+
|
|
5
|
+
const backoffPromises = new Map()
|
|
6
|
+
|
|
7
|
+
const setProtocolBackoffMs = (protocolName, ms) => {
|
|
8
|
+
backoffPromises.set(protocolName, new Promise(resolve => setTimeout(resolve, ms)))
|
|
9
|
+
}
|
|
10
|
+
exports.setProtocolBackoffMs = setProtocolBackoffMs
|
|
11
|
+
|
|
12
|
+
const shouldWaitForBackoff = query => {
|
|
13
|
+
if (query.context === 'interactive') {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
const protocolNames = query.protocols.map(p => p.name)
|
|
17
|
+
return !(protocolNames.includes('devices') && (query.context === 'message' || query.context === 'voip'))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const waitForBackoff = async query => {
|
|
21
|
+
if (!shouldWaitForBackoff(query)) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
await Promise.all(query.protocols.map(p => backoffPromises.get(p.name)))
|
|
25
|
+
}
|
|
26
|
+
exports.waitForBackoff = waitForBackoff
|
|
@@ -5,10 +5,10 @@ const WABinary_1 = require('../WABinary')
|
|
|
5
5
|
const USyncBotProfileProtocol_1 = require('./Protocols/USyncBotProfileProtocol')
|
|
6
6
|
const USyncLIDProtocol_1 = require('./Protocols/USyncLIDProtocol')
|
|
7
7
|
const USyncBusinessProtocol_1 = require('./Protocols/USyncBusinessProtocol')
|
|
8
|
+
const USyncFeatureProtocol_1 = require('./Protocols/USyncFeatureProtocol')
|
|
8
9
|
const USyncPictureProtocol_1 = require('./Protocols/USyncPictureProtocol')
|
|
9
10
|
const USyncTextStatusProtocol_1 = require('./Protocols/USyncTextStatusProtocol')
|
|
10
11
|
const USyncSidelistProtocol_1 = require('./Protocols/USyncSidelistProtocol')
|
|
11
|
-
const USyncFeatureProtocol_1 = require('./Protocols/USyncFeatureProtocol')
|
|
12
12
|
const Protocols_1 = require('./Protocols')
|
|
13
13
|
class USyncQuery {
|
|
14
14
|
constructor() {
|
|
@@ -39,26 +39,85 @@ class USyncQuery {
|
|
|
39
39
|
})
|
|
40
40
|
)
|
|
41
41
|
const queryResult = {
|
|
42
|
-
|
|
42
|
+
errors: {},
|
|
43
|
+
refresh: {},
|
|
43
44
|
list: [],
|
|
44
45
|
sideList: []
|
|
45
46
|
}
|
|
46
47
|
const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync')
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const resultNode = usyncNode ? (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'result') : undefined
|
|
53
|
+
if (resultNode) {
|
|
54
|
+
for (const protocol of this.protocols) {
|
|
55
|
+
const protocolNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, protocol.name)
|
|
56
|
+
if (!protocolNode) continue
|
|
57
|
+
const errorNode = (0, WABinary_1.getBinaryNodeChild)(protocolNode, 'error')
|
|
58
|
+
if (errorNode) {
|
|
59
|
+
queryResult.errors[protocol.name] = {
|
|
60
|
+
errorCode: errorNode.attrs.code ? +errorNode.attrs.code : undefined,
|
|
61
|
+
errorText: errorNode.attrs.text,
|
|
62
|
+
errorBackoff: errorNode.attrs.backoff ? +errorNode.attrs.backoff : undefined
|
|
63
|
+
}
|
|
64
|
+
} else if (protocolNode.attrs.refresh !== undefined) {
|
|
65
|
+
queryResult.refresh[protocol.name] = +protocolNode.attrs.refresh
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
50
69
|
const parseUserNodes = nodes => {
|
|
51
70
|
return nodes.reduce((acc, node) => {
|
|
52
71
|
const id = node?.attrs.jid
|
|
53
72
|
if (id) {
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const userErrorCode = node?.attrs?.error ? parseInt(node.attrs.error, 10) : 0
|
|
76
|
+
const isBlockedByAttr = userErrorCode === 401 || userErrorCode === 403 || userErrorCode === 405
|
|
77
|
+
|
|
54
78
|
const data = Array.isArray(node?.content)
|
|
55
79
|
? Object.fromEntries(
|
|
56
80
|
node.content
|
|
57
81
|
.map(content => {
|
|
58
82
|
const protocol = content.tag
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (protocol === 'privacy') {
|
|
87
|
+
const tokenNode = (0, WABinary_1.getBinaryNodeChild)(content, 'token')
|
|
88
|
+
const modeTsNode = (0, WABinary_1.getBinaryNodeChild)(content, 'mode_ts')
|
|
89
|
+
|
|
90
|
+
const tokenVal = tokenNode?.content || content.attrs?.token
|
|
91
|
+
const modeTsVal =
|
|
92
|
+
modeTsNode?.content?.toString?.() || modeTsNode?.attrs?.value || content.attrs?.mode_ts || null
|
|
93
|
+
if (tokenVal) {
|
|
94
|
+
return [
|
|
95
|
+
'privacy',
|
|
96
|
+
{
|
|
97
|
+
token:
|
|
98
|
+
Buffer.isBuffer(tokenVal) || tokenVal instanceof Uint8Array
|
|
99
|
+
? Buffer.from(tokenVal)
|
|
100
|
+
: tokenVal,
|
|
101
|
+
modeTs: modeTsVal
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
return ['privacy', null]
|
|
106
|
+
}
|
|
107
|
+
|
|
59
108
|
const parser = protocolMap[protocol]
|
|
60
109
|
if (parser) {
|
|
61
|
-
|
|
110
|
+
try {
|
|
111
|
+
return [protocol, parser(content)]
|
|
112
|
+
} catch (err) {
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const errCode = err?.data ?? err?.output?.payload?.data
|
|
116
|
+
if (errCode === 401 || errCode === 403 || errCode === 405) {
|
|
117
|
+
return ['isBlockedByContact', true]
|
|
118
|
+
}
|
|
119
|
+
throw err
|
|
120
|
+
}
|
|
62
121
|
} else {
|
|
63
122
|
return [protocol, null]
|
|
64
123
|
}
|
|
@@ -66,6 +125,18 @@ class USyncQuery {
|
|
|
66
125
|
.filter(([, b]) => b !== null)
|
|
67
126
|
)
|
|
68
127
|
: {}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
if (isBlockedByAttr) {
|
|
131
|
+
data.isBlockedByContact = true
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if ('disappearing_mode' in data) {
|
|
136
|
+
data.disappearingMode = data.disappearing_mode
|
|
137
|
+
delete data.disappearing_mode
|
|
138
|
+
}
|
|
139
|
+
|
|
69
140
|
acc.push({ ...data, id })
|
|
70
141
|
}
|
|
71
142
|
return acc
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -30,21 +30,29 @@ class USyncUser {
|
|
|
30
30
|
this.personaId = personaId
|
|
31
31
|
return this
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
this.
|
|
33
|
+
withTcToken(tcToken) {
|
|
34
|
+
this.tcToken = tcToken
|
|
35
35
|
return this
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
this.
|
|
37
|
+
withPnJid(pnJid) {
|
|
38
|
+
this.pnJid = pnJid
|
|
39
39
|
return this
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
this.
|
|
41
|
+
withDeviceHash(deviceHash) {
|
|
42
|
+
this.deviceHash = deviceHash
|
|
43
43
|
return this
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
this.
|
|
45
|
+
withTs(ts) {
|
|
46
|
+
this.ts = ts
|
|
47
47
|
return this
|
|
48
48
|
}
|
|
49
|
+
withExpectedTs(expectedTs) {
|
|
50
|
+
this.expectedTs = expectedTs
|
|
51
|
+
return this
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
validate() {
|
|
55
|
+
return !!(this.id || this.phone || this.username || this.pnJid)
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
exports.USyncUser = USyncUser
|
package/lib/WAUSync/index.js
CHANGED