@badzz88/baileys 8.4.7 → 8.5.0
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 +21 -0
- package/README.md +1055 -337
- package/WAProto/index.js +5 -5
- package/lib/Defaults/index.js +187 -127
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.js +14 -11
- package/lib/Signal/Group/group-session-builder.js +91 -29
- package/lib/Signal/Group/group_cipher.js +88 -81
- package/lib/Signal/Group/index.js +136 -12
- package/lib/Signal/Group/keyhelper.js +70 -15
- package/lib/Signal/Group/sender-chain-key.js +31 -25
- package/lib/Signal/Group/sender-key-distribution-message.js +65 -62
- package/lib/Signal/Group/sender-key-message.js +68 -65
- package/lib/Signal/Group/sender-key-name.js +43 -41
- package/lib/Signal/Group/sender-key-record.js +43 -40
- package/lib/Signal/Group/sender-key-state.js +96 -83
- package/lib/Signal/Group/sender-message-key.js +29 -25
- package/lib/Signal/libsignal.js +483 -424
- package/lib/Signal/lid-mapping.js +261 -276
- package/lib/Socket/Client/index.js +30 -3
- package/lib/Socket/Client/types.js +12 -10
- package/lib/Socket/Client/websocket.js +61 -53
- package/lib/Socket/aigroups.js +240 -0
- package/lib/Socket/business.js +422 -379
- package/lib/Socket/chats.js +1816 -1193
- package/lib/Socket/communities.js +549 -431
- package/lib/Socket/graphql.js +656 -0
- package/lib/Socket/groups.js +764 -374
- package/lib/Socket/index.js +38 -11
- package/lib/Socket/interactive-handler.js +522 -0
- package/lib/Socket/interop.js +549 -0
- package/lib/Socket/luxu.js +6 -5
- package/lib/Socket/managed-account.js +183 -0
- package/lib/Socket/messages-recv.js +2439 -1915
- package/lib/Socket/messages-send.js +1642 -1242
- package/lib/Socket/mex.js +59 -40
- package/lib/Socket/newsletter.js +812 -249
- package/lib/Socket/privacy.js +449 -0
- package/lib/Socket/registration.js +427 -0
- package/lib/Socket/socket.js +1077 -965
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +237 -140
- package/lib/Store/index.js +36 -10
- package/lib/Store/make-cache-manager-store.js +85 -80
- package/lib/Store/make-in-memory-store.js +591 -185
- package/lib/Store/make-ordered-dictionary.js +78 -72
- package/lib/Store/object-repository.js +25 -28
- package/lib/Types/Auth.js +38 -2
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +4 -8
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +26 -24
- package/lib/Types/LabelAssociation.js +8 -6
- package/lib/Types/Message.js +95 -11
- package/lib/Types/Mex.js +112 -37
- package/lib/Types/Newsletter.js +121 -0
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.js +70 -56
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +55 -26
- package/lib/Utils/auth-utils.js +292 -288
- package/lib/Utils/browser-utils.js +113 -48
- package/lib/Utils/business.js +240 -224
- package/lib/Utils/chat-utils.js +1205 -869
- package/lib/Utils/command-loader.d.ts +31 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +41 -34
- package/lib/Utils/consumer-application.js +107 -0
- package/lib/Utils/crypto.js +144 -107
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +518 -308
- package/lib/Utils/event-buffer.js +596 -611
- package/lib/Utils/generics.js +514 -354
- package/lib/Utils/group-history.js +60 -0
- package/lib/Utils/history.js +244 -134
- package/lib/Utils/identity-change-handler.js +51 -49
- package/lib/Utils/index.js +57 -23
- package/lib/Utils/jid-display-normalization.js +218 -0
- package/lib/Utils/link-preview.js +135 -77
- package/lib/Utils/logger.js +9 -3
- package/lib/Utils/lt-hash.js +37 -6
- package/lib/Utils/make-mutex.js +36 -33
- package/lib/Utils/message-composer.js +439 -233
- package/lib/Utils/message-retry-manager.js +265 -260
- package/lib/Utils/messages-media.js +855 -747
- package/lib/Utils/messages.js +2528 -884
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +195 -200
- package/lib/Utils/offline-node-processor.js +35 -33
- package/lib/Utils/pre-key-manager.js +103 -102
- package/lib/Utils/process-message.js +978 -560
- package/lib/Utils/reporting-utils.js +257 -253
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +218 -195
- package/lib/Utils/stanza-ack.js +31 -29
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +50 -45
- package/lib/Utils/tc-token-utils.js +137 -139
- package/lib/Utils/use-multi-file-auth-state.js +109 -109
- package/lib/Utils/validate-connection.js +218 -202
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/Utils/voip-rekey.js +22 -0
- package/lib/WABinary/constants.js +1302 -1299
- package/lib/WABinary/decode.js +343 -262
- package/lib/WABinary/encode.js +12 -4
- package/lib/WABinary/generic-utils.js +223 -187
- package/lib/WABinary/index.js +33 -6
- package/lib/WABinary/jid-utils.js +351 -88
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +12 -9
- package/lib/WAM/constants.js +39486 -22853
- package/lib/WAM/encode.js +132 -140
- package/lib/WAM/index.js +31 -4
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +53 -51
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +56 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +29 -26
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +59 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +31 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -37
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +26 -24
- package/lib/WAUSync/Protocols/index.js +39 -6
- package/lib/WAUSync/USyncQuery.js +132 -97
- package/lib/WAUSync/USyncUser.js +49 -30
- package/lib/WAUSync/index.js +31 -4
- package/lib/antiban.js +4637 -0
- package/lib/index.js +48 -15
- package/package.json +55 -92
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -263
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
|
@@ -1,204 +1,240 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.getBinaryNodeMessages =
|
|
4
|
+
exports.reduceBinaryNodeToDictionary =
|
|
5
|
+
exports.assertNodeErrorFree =
|
|
6
|
+
exports.getBinaryNodeChildUInt =
|
|
7
|
+
exports.getBinaryNodeChildString =
|
|
8
|
+
exports.getBinaryNodeChildBuffer =
|
|
9
|
+
exports.getAllBinaryNodeChildren =
|
|
10
|
+
exports.getBinaryNodeChild =
|
|
11
|
+
exports.getBinaryNodeChildren =
|
|
12
|
+
void 0
|
|
13
|
+
exports.binaryNodeToString = binaryNodeToString
|
|
14
|
+
const boom_1 = require('@hapi/boom')
|
|
15
|
+
const index_js_1 = require('../../WAProto/index.js')
|
|
5
16
|
// some extra useful utilities
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const indexCache = new WeakMap()
|
|
18
|
+
const getBinaryNodeChildren = (node, childTag) => {
|
|
19
|
+
if (!node || !Array.isArray(node.content)) return []
|
|
20
|
+
let index = indexCache.get(node)
|
|
21
|
+
// Build the index once per node
|
|
22
|
+
if (!index) {
|
|
23
|
+
index = new Map()
|
|
24
|
+
for (const child of node.content) {
|
|
25
|
+
let arr = index.get(child.tag)
|
|
26
|
+
if (!arr) index.set(child.tag, (arr = []))
|
|
27
|
+
arr.push(child)
|
|
28
|
+
}
|
|
29
|
+
indexCache.set(node, index)
|
|
30
|
+
}
|
|
31
|
+
// Return first matching child
|
|
32
|
+
return index.get(childTag) || []
|
|
18
33
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return node?.content.find(item => item.tag === childTag)
|
|
23
|
-
}
|
|
34
|
+
exports.getBinaryNodeChildren = getBinaryNodeChildren
|
|
35
|
+
const getBinaryNodeChild = (node, childTag) => {
|
|
36
|
+
return (0, exports.getBinaryNodeChildren)(node, childTag)[0]
|
|
24
37
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
exports.getBinaryNodeChild = getBinaryNodeChild
|
|
39
|
+
const getAllBinaryNodeChildren = ({ content }) => {
|
|
40
|
+
if (Array.isArray(content)) {
|
|
41
|
+
return content
|
|
42
|
+
}
|
|
43
|
+
return []
|
|
31
44
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else if (typeof child === 'string') {
|
|
39
|
-
return child
|
|
40
|
-
}
|
|
45
|
+
exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren
|
|
46
|
+
const getBinaryNodeChildBuffer = (node, childTag) => {
|
|
47
|
+
const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content
|
|
48
|
+
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
49
|
+
return child
|
|
50
|
+
}
|
|
41
51
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer
|
|
53
|
+
const getBinaryNodeChildString = (node, childTag) => {
|
|
54
|
+
const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content
|
|
55
|
+
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
56
|
+
return Buffer.from(child).toString('utf-8')
|
|
57
|
+
} else if (typeof child === 'string') {
|
|
58
|
+
return child
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
exports.getBinaryNodeChildString = getBinaryNodeChildString
|
|
62
|
+
const getBinaryNodeChildUInt = (node, childTag, length) => {
|
|
63
|
+
const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag)
|
|
64
|
+
if (buff) {
|
|
65
|
+
return bufferToUInt(buff, length)
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, {})
|
|
63
|
-
return dict
|
|
68
|
+
exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt
|
|
69
|
+
const assertNodeErrorFree = node => {
|
|
70
|
+
const errNode = (0, exports.getBinaryNodeChild)(node, 'error')
|
|
71
|
+
if (errNode) {
|
|
72
|
+
throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
|
|
73
|
+
}
|
|
64
74
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
exports.assertNodeErrorFree = assertNodeErrorFree
|
|
76
|
+
const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
77
|
+
const nodes = (0, exports.getBinaryNodeChildren)(node, tag)
|
|
78
|
+
const dict = nodes.reduce((dict, { attrs }) => {
|
|
79
|
+
if (typeof attrs.name === 'string') {
|
|
80
|
+
dict[attrs.name] = attrs.value || attrs.config_value
|
|
81
|
+
} else {
|
|
82
|
+
dict[attrs.config_code] = attrs.value || attrs.config_value
|
|
83
|
+
}
|
|
84
|
+
return dict
|
|
85
|
+
}, {})
|
|
86
|
+
return dict
|
|
76
87
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary
|
|
89
|
+
const getBinaryNodeMessages = ({ content }) => {
|
|
90
|
+
const msgs = []
|
|
91
|
+
if (Array.isArray(content)) {
|
|
92
|
+
for (const item of content) {
|
|
93
|
+
if (item.tag === 'message') {
|
|
94
|
+
msgs.push(index_js_1.proto.WebMessageInfo.decode(item.content).toJSON())
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return msgs
|
|
84
99
|
}
|
|
100
|
+
exports.getBinaryNodeMessages = getBinaryNodeMessages
|
|
85
101
|
|
|
86
|
-
const
|
|
102
|
+
const getBinaryFilteredButtons = nodeContent => {
|
|
103
|
+
if (!Array.isArray(nodeContent)) return false
|
|
87
104
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
if (node instanceof Uint8Array) {
|
|
96
|
-
return tabs(i) + Buffer.from(node).toString('hex');
|
|
97
|
-
}
|
|
98
|
-
if (Array.isArray(node)) {
|
|
99
|
-
return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
|
|
100
|
-
}
|
|
101
|
-
const children = binaryNodeToString(node.content, i + 1);
|
|
102
|
-
const tag = `<${node.tag} ${Object.entries(node.attrs || {})
|
|
103
|
-
.filter(([, v]) => v!== undefined)
|
|
104
|
-
.map(([k, v]) => `${k}='${v}'`)
|
|
105
|
-
.join(' ')}`;
|
|
106
|
-
const content = children? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
107
|
-
return tag + content;
|
|
105
|
+
return nodeContent.some(
|
|
106
|
+
a =>
|
|
107
|
+
['native_flow'].includes(a?.content?.[0]?.content?.[0]?.tag) ||
|
|
108
|
+
['interactive', 'buttons', 'list'].includes(a?.content?.[0]?.tag) ||
|
|
109
|
+
['hsm', 'biz'].includes(a?.tag)
|
|
110
|
+
)
|
|
108
111
|
}
|
|
112
|
+
exports.getBinaryFilteredButtons = getBinaryFilteredButtons
|
|
113
|
+
const getBinaryFilteredBizBot = nodeContent => {
|
|
114
|
+
if (!Array.isArray(nodeContent)) return false
|
|
109
115
|
|
|
110
|
-
|
|
111
|
-
if (!Array.isArray(node)) return false
|
|
112
|
-
|
|
113
|
-
return node.some(item =>
|
|
114
|
-
['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
|
|
115
|
-
['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
|
|
116
|
-
['hsm', 'biz'].includes(item?.tag) ||
|
|
117
|
-
['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'
|
|
118
|
-
)
|
|
116
|
+
return nodeContent.some(b => ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1')
|
|
119
117
|
}
|
|
118
|
+
exports.getBinaryFilteredBizBot = getBinaryFilteredBizBot
|
|
119
|
+
|
|
120
|
+
const getAdditionalNode = name => {
|
|
121
|
+
if (name) name = name.toLowerCase()
|
|
122
|
+
const ts = Math.floor(Date.now() / 1000) - 77980457
|
|
123
|
+
const order_response_name = {
|
|
124
|
+
review_and_pay: 'order_details',
|
|
125
|
+
review_order: 'order_status',
|
|
126
|
+
order_status: 'order_status',
|
|
127
|
+
payment_info: 'payment_info',
|
|
128
|
+
payment_status: 'payment_status',
|
|
129
|
+
payment_method: 'payment_method',
|
|
130
|
+
catalog_message: 'catalog_message'
|
|
131
|
+
}
|
|
132
|
+
const flow_name = {
|
|
133
|
+
cta_catalog: 'cta_catalog',
|
|
134
|
+
mpm: 'mpm',
|
|
135
|
+
call_request: 'call_permission_request',
|
|
136
|
+
view_catalog: 'automated_greeting_message_view_catalog',
|
|
137
|
+
wa_pay_detail: 'wa_payment_transaction_details',
|
|
138
|
+
send_location: 'send_location',
|
|
139
|
+
payment_key_info: 'payment_key_info'
|
|
140
|
+
}
|
|
141
|
+
if (order_response_name[name]) {
|
|
142
|
+
return [
|
|
143
|
+
{
|
|
144
|
+
tag: 'biz',
|
|
145
|
+
attrs: {
|
|
146
|
+
native_flow_name: order_response_name[name]
|
|
147
|
+
},
|
|
148
|
+
content: []
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
} else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
|
|
152
|
+
return [
|
|
153
|
+
{
|
|
154
|
+
tag: 'biz',
|
|
155
|
+
attrs: {
|
|
156
|
+
actual_actors: '2',
|
|
157
|
+
host_storage: '2',
|
|
158
|
+
privacy_mode_ts: `${ts}`
|
|
159
|
+
},
|
|
160
|
+
content: [
|
|
161
|
+
{
|
|
162
|
+
tag: 'engagement',
|
|
163
|
+
attrs: {
|
|
164
|
+
customer_service_state: 'open',
|
|
165
|
+
conversation_state: 'open'
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
tag: 'interactive',
|
|
170
|
+
attrs: {
|
|
171
|
+
type: 'native_flow',
|
|
172
|
+
v: '1'
|
|
173
|
+
},
|
|
174
|
+
content: [
|
|
175
|
+
{
|
|
176
|
+
tag: 'native_flow',
|
|
177
|
+
attrs: {
|
|
178
|
+
v: '9',
|
|
179
|
+
name: flow_name[name] ?? 'mixed'
|
|
180
|
+
},
|
|
181
|
+
content: []
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
} else {
|
|
189
|
+
return [
|
|
190
|
+
{
|
|
191
|
+
tag: 'biz',
|
|
192
|
+
attrs: {
|
|
193
|
+
actual_actors: '2',
|
|
194
|
+
host_storage: '2',
|
|
195
|
+
privacy_mode_ts: `${ts}`
|
|
196
|
+
},
|
|
197
|
+
content: [
|
|
198
|
+
{
|
|
199
|
+
tag: 'engagement',
|
|
200
|
+
attrs: {
|
|
201
|
+
customer_service_state: 'open',
|
|
202
|
+
conversation_state: 'open'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.getAdditionalNode = getAdditionalNode
|
|
120
211
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
native_flow_name: order_response_name[name]
|
|
150
|
-
},
|
|
151
|
-
content: []
|
|
152
|
-
}]
|
|
153
|
-
} else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
|
|
154
|
-
return [{
|
|
155
|
-
tag: 'biz',
|
|
156
|
-
attrs: {
|
|
157
|
-
actual_actors: '2',
|
|
158
|
-
host_storage: '2',
|
|
159
|
-
privacy_mode_ts: `${ts}`
|
|
160
|
-
},
|
|
161
|
-
content: [{
|
|
162
|
-
tag: 'engagement',
|
|
163
|
-
attrs: {
|
|
164
|
-
customer_service_state: 'open',
|
|
165
|
-
conversation_state: 'open'
|
|
166
|
-
}
|
|
167
|
-
}, {
|
|
168
|
-
tag: 'interactive',
|
|
169
|
-
attrs: {
|
|
170
|
-
type: 'native_flow',
|
|
171
|
-
v: '1'
|
|
172
|
-
},
|
|
173
|
-
content: [{
|
|
174
|
-
tag: 'native_flow',
|
|
175
|
-
attrs: {
|
|
176
|
-
v: '9',
|
|
177
|
-
name: flow_name[name]?? 'mixed',
|
|
178
|
-
},
|
|
179
|
-
content: []
|
|
180
|
-
}]
|
|
181
|
-
}]
|
|
182
|
-
}]
|
|
183
|
-
} else {
|
|
184
|
-
return [{
|
|
185
|
-
tag: 'biz',
|
|
186
|
-
attrs: {
|
|
187
|
-
actual_actors: '2',
|
|
188
|
-
host_storage: '2',
|
|
189
|
-
privacy_mode_ts: `${ts}`
|
|
190
|
-
},
|
|
191
|
-
content: [{
|
|
192
|
-
tag: 'engagement',
|
|
193
|
-
attrs: {
|
|
194
|
-
customer_service_state: 'open',
|
|
195
|
-
conversation_state: 'open'
|
|
196
|
-
}
|
|
197
|
-
}]
|
|
198
|
-
}]
|
|
199
|
-
}
|
|
212
|
+
function bufferToUInt(e, t) {
|
|
213
|
+
let a = 0
|
|
214
|
+
for (let i = 0; i < t; i++) {
|
|
215
|
+
a = 256 * a + e[i]
|
|
216
|
+
}
|
|
217
|
+
return a
|
|
218
|
+
}
|
|
219
|
+
const tabs = n => '\t'.repeat(n)
|
|
220
|
+
function binaryNodeToString(node, i = 0) {
|
|
221
|
+
if (!node) {
|
|
222
|
+
return node
|
|
223
|
+
}
|
|
224
|
+
if (typeof node === 'string') {
|
|
225
|
+
return tabs(i) + node
|
|
226
|
+
}
|
|
227
|
+
if (node instanceof Uint8Array) {
|
|
228
|
+
return tabs(i) + Buffer.from(node).toString('hex')
|
|
229
|
+
}
|
|
230
|
+
if (Array.isArray(node)) {
|
|
231
|
+
return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n')
|
|
232
|
+
}
|
|
233
|
+
const children = binaryNodeToString(node.content, i + 1)
|
|
234
|
+
const tag = `<${node.tag} ${Object.entries(node.attrs || {})
|
|
235
|
+
.filter(([, v]) => v !== undefined)
|
|
236
|
+
.map(([k, v]) => `${k}='${v}'`)
|
|
237
|
+
.join(' ')}`
|
|
238
|
+
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>'
|
|
239
|
+
return tag + content
|
|
200
240
|
}
|
|
201
|
-
export const getBinaryFilteredBizBot = nodeContent => {
|
|
202
|
-
if (!Array.isArray(nodeContent)) return false
|
|
203
|
-
return nodeContent.some(b => ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1')
|
|
204
|
-
}
|
package/lib/WABinary/index.js
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k)
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc)
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k
|
|
20
|
+
o[k2] = m[k]
|
|
21
|
+
})
|
|
22
|
+
var __exportStar =
|
|
23
|
+
(this && this.__exportStar) ||
|
|
24
|
+
function (m, exports) {
|
|
25
|
+
for (var p in m)
|
|
26
|
+
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p)
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
29
|
+
__exportStar(require('./encode'), exports)
|
|
30
|
+
__exportStar(require('./decode'), exports)
|
|
31
|
+
__exportStar(require('./generic-utils'), exports)
|
|
32
|
+
__exportStar(require('./jid-utils'), exports)
|
|
33
|
+
__exportStar(require('./types'), exports)
|