@bellaxchuu/flowred 0.8.6
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 +214 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +6902 -0
- package/WAProto/fix-imports.js +85 -0
- package/WAProto/index.js +242946 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +190 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +92 -0
- package/lib/Signal/Group/group_cipher.js +89 -0
- package/lib/Signal/Group/index.js +136 -0
- package/lib/Signal/Group/keyhelper.js +73 -0
- package/lib/Signal/Group/sender-chain-key.js +32 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +50 -0
- package/lib/Signal/Group/sender-key-record.js +44 -0
- package/lib/Signal/Group/sender-key-state.js +97 -0
- package/lib/Signal/Group/sender-message-key.js +30 -0
- package/lib/Signal/libsignal.js +490 -0
- package/lib/Signal/lid-mapping.js +262 -0
- package/lib/Socket/Client/index.js +30 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +62 -0
- package/lib/Socket/aigroups.js +240 -0
- package/lib/Socket/business.js +422 -0
- package/lib/Socket/chats.js +1816 -0
- package/lib/Socket/communities.js +549 -0
- package/lib/Socket/graphql.js +656 -0
- package/lib/Socket/groups.js +764 -0
- package/lib/Socket/index.js +39 -0
- package/lib/Socket/interactive-handler.js +522 -0
- package/lib/Socket/interop.js +549 -0
- package/lib/Socket/luxu.js +387 -0
- package/lib/Socket/managed-account.js +183 -0
- package/lib/Socket/messages-recv.js +2440 -0
- package/lib/Socket/messages-send.js +1853 -0
- package/lib/Socket/mex.js +60 -0
- package/lib/Socket/newsletter.js +820 -0
- package/lib/Socket/privacy.js +449 -0
- package/lib/Socket/registration.js +427 -0
- package/lib/Socket/socket.js +1092 -0
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +243 -0
- package/lib/Store/index.js +36 -0
- package/lib/Store/keyed-db.js +108 -0
- package/lib/Store/make-cache-manager-store.js +90 -0
- package/lib/Store/make-in-memory-store.js +604 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +29 -0
- package/lib/Types/Auth.js +38 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +95 -0
- package/lib/Types/Mex.js +112 -0
- package/lib/Types/Newsletter.js +121 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +70 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +55 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/browser-utils.js +114 -0
- package/lib/Utils/business.js +247 -0
- package/lib/Utils/chat-utils.js +1208 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +42 -0
- package/lib/Utils/consumer-application.js +107 -0
- package/lib/Utils/crypto.js +155 -0
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +560 -0
- package/lib/Utils/event-buffer.js +607 -0
- package/lib/Utils/generics.js +563 -0
- package/lib/Utils/group-history.js +60 -0
- package/lib/Utils/history.js +244 -0
- package/lib/Utils/identity-change-handler.js +52 -0
- package/lib/Utils/index.js +57 -0
- package/lib/Utils/jid-display-normalization.js +218 -0
- package/lib/Utils/link-preview.js +143 -0
- package/lib/Utils/logger.js +9 -0
- package/lib/Utils/lt-hash.js +39 -0
- package/lib/Utils/make-mutex.js +36 -0
- package/lib/Utils/message-composer.js +479 -0
- package/lib/Utils/message-retry-manager.js +270 -0
- package/lib/Utils/messages-media.js +896 -0
- package/lib/Utils/messages.js +2904 -0
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +196 -0
- package/lib/Utils/offline-node-processor.js +42 -0
- package/lib/Utils/pre-key-manager.js +107 -0
- package/lib/Utils/process-message.js +1048 -0
- package/lib/Utils/reporting-utils.js +262 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +224 -0
- package/lib/Utils/stanza-ack.js +40 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +54 -0
- package/lib/Utils/tc-token-utils.js +161 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/validate-connection.js +219 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/Utils/voip-rekey.js +22 -0
- package/lib/WABinary/constants.js +1304 -0
- package/lib/WABinary/decode.js +343 -0
- package/lib/WABinary/encode.js +228 -0
- package/lib/WABinary/generic-utils.js +240 -0
- package/lib/WABinary/index.js +33 -0
- package/lib/WABinary/jid-utils.js +361 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +39486 -0
- package/lib/WAM/encode.js +142 -0
- package/lib/WAM/index.js +31 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- 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 +39 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +27 -0
- package/lib/WAUSync/Protocols/index.js +39 -0
- package/lib/WAUSync/USyncQuery.js +133 -0
- package/lib/WAUSync/USyncUser.js +50 -0
- package/lib/WAUSync/index.js +31 -0
- package/lib/antiban.js +4637 -0
- package/lib/index.js +45 -0
- package/package.json +107 -0
|
@@ -0,0 +1,240 @@
|
|
|
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')
|
|
16
|
+
// some extra useful utilities
|
|
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) || []
|
|
33
|
+
}
|
|
34
|
+
exports.getBinaryNodeChildren = getBinaryNodeChildren
|
|
35
|
+
const getBinaryNodeChild = (node, childTag) => {
|
|
36
|
+
return (0, exports.getBinaryNodeChildren)(node, childTag)[0]
|
|
37
|
+
}
|
|
38
|
+
exports.getBinaryNodeChild = getBinaryNodeChild
|
|
39
|
+
const getAllBinaryNodeChildren = ({ content }) => {
|
|
40
|
+
if (Array.isArray(content)) {
|
|
41
|
+
return content
|
|
42
|
+
}
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
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
|
+
}
|
|
51
|
+
}
|
|
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
|
+
}
|
|
60
|
+
}
|
|
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
|
+
}
|
|
67
|
+
}
|
|
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
|
+
}
|
|
74
|
+
}
|
|
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
|
|
87
|
+
}
|
|
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
|
|
99
|
+
}
|
|
100
|
+
exports.getBinaryNodeMessages = getBinaryNodeMessages
|
|
101
|
+
|
|
102
|
+
const getBinaryFilteredButtons = nodeContent => {
|
|
103
|
+
if (!Array.isArray(nodeContent)) return false
|
|
104
|
+
|
|
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
|
+
)
|
|
111
|
+
}
|
|
112
|
+
exports.getBinaryFilteredButtons = getBinaryFilteredButtons
|
|
113
|
+
const getBinaryFilteredBizBot = nodeContent => {
|
|
114
|
+
if (!Array.isArray(nodeContent)) return false
|
|
115
|
+
|
|
116
|
+
return nodeContent.some(b => ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1')
|
|
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
|
|
211
|
+
|
|
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
|
|
240
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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)
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.transferDevice =
|
|
4
|
+
exports.jidNormalizedUser =
|
|
5
|
+
exports.isJidBot =
|
|
6
|
+
exports.isHostedLidUser =
|
|
7
|
+
exports.isHostedPnUser =
|
|
8
|
+
exports.isJidNewsletter =
|
|
9
|
+
exports.isJidStatusBroadcast =
|
|
10
|
+
exports.isJidGroup =
|
|
11
|
+
exports.isJidBroadcast =
|
|
12
|
+
exports.isLidUser =
|
|
13
|
+
exports.isPnUser =
|
|
14
|
+
exports.isInteropUser =
|
|
15
|
+
exports.isJidMetaAI =
|
|
16
|
+
exports.areJidsSameUser =
|
|
17
|
+
exports.jidDecode =
|
|
18
|
+
exports.jidEncode =
|
|
19
|
+
exports.getServerFromDomainType =
|
|
20
|
+
exports.WAJIDDomains =
|
|
21
|
+
exports.META_AI_JID =
|
|
22
|
+
exports.STORIES_JID =
|
|
23
|
+
exports.PSA_WID =
|
|
24
|
+
exports.SERVER_JID =
|
|
25
|
+
exports.OFFICIAL_BIZ_JID =
|
|
26
|
+
exports.S_WHATSAPP_NET =
|
|
27
|
+
void 0
|
|
28
|
+
exports.S_WHATSAPP_NET = '@s.whatsapp.net'
|
|
29
|
+
exports.OFFICIAL_BIZ_JID = '16505361212@c.us'
|
|
30
|
+
exports.SERVER_JID = 'server@c.us'
|
|
31
|
+
exports.PSA_WID = '0@c.us'
|
|
32
|
+
exports.STORIES_JID = 'status@broadcast'
|
|
33
|
+
exports.META_AI_JID = '13135550002@c.us'
|
|
34
|
+
var WAJIDDomains
|
|
35
|
+
;(function (WAJIDDomains) {
|
|
36
|
+
WAJIDDomains[(WAJIDDomains['WHATSAPP'] = 0)] = 'WHATSAPP'
|
|
37
|
+
WAJIDDomains[(WAJIDDomains['LID'] = 1)] = 'LID'
|
|
38
|
+
WAJIDDomains[(WAJIDDomains['HOSTED'] = 128)] = 'HOSTED'
|
|
39
|
+
WAJIDDomains[(WAJIDDomains['HOSTED_LID'] = 129)] = 'HOSTED_LID'
|
|
40
|
+
})(WAJIDDomains || (exports.WAJIDDomains = WAJIDDomains = {}))
|
|
41
|
+
const getServerFromDomainType = (initialServer, domainType) => {
|
|
42
|
+
switch (domainType) {
|
|
43
|
+
case WAJIDDomains.LID:
|
|
44
|
+
return 'lid'
|
|
45
|
+
case WAJIDDomains.HOSTED:
|
|
46
|
+
return 'hosted'
|
|
47
|
+
case WAJIDDomains.HOSTED_LID:
|
|
48
|
+
return 'hosted.lid'
|
|
49
|
+
case WAJIDDomains.WHATSAPP:
|
|
50
|
+
default:
|
|
51
|
+
return initialServer
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.getServerFromDomainType = getServerFromDomainType
|
|
55
|
+
|
|
56
|
+
const getBotJid = jid => {
|
|
57
|
+
const BOT_MAP = new Map([
|
|
58
|
+
['867051314767696', '13135550002'],
|
|
59
|
+
['1061492271844689', '13135550005'],
|
|
60
|
+
['245886058483988', '13135550009'],
|
|
61
|
+
['3509905702656130', '13135550012'],
|
|
62
|
+
['1059680132034576', '13135550013'],
|
|
63
|
+
['715681030623646', '13135550014'],
|
|
64
|
+
['1644971366323052', '13135550015'],
|
|
65
|
+
['582497970646566', '13135550019'],
|
|
66
|
+
['645459357769306', '13135550022'],
|
|
67
|
+
['294997126699143', '13135550023'],
|
|
68
|
+
['1522631578502677', '13135550027'],
|
|
69
|
+
['719421926276396', '13135550030'],
|
|
70
|
+
['1788488635002167', '13135550031'],
|
|
71
|
+
['24232338603080193', '13135550033'],
|
|
72
|
+
['689289903143209', '13135550035'],
|
|
73
|
+
['871626054177096', '13135550039'],
|
|
74
|
+
['362351902849370', '13135550042'],
|
|
75
|
+
['1744617646041527', '13135550043'],
|
|
76
|
+
['893887762270570', '13135550046'],
|
|
77
|
+
['1155032702135830', '13135550047'],
|
|
78
|
+
['333931965993883', '13135550048'],
|
|
79
|
+
['853748013058752', '13135550049'],
|
|
80
|
+
['1559068611564819', '13135550053'],
|
|
81
|
+
['890487432705716', '13135550054'],
|
|
82
|
+
['240254602395494', '13135550055'],
|
|
83
|
+
['1578420349663261', '13135550062'],
|
|
84
|
+
['322908887140421', '13135550065'],
|
|
85
|
+
['3713961535514771', '13135550067'],
|
|
86
|
+
['997884654811738', '13135550070'],
|
|
87
|
+
['403157239387035', '13135550081'],
|
|
88
|
+
['535242369074963', '13135550082'],
|
|
89
|
+
['946293427247659', '13135550083'],
|
|
90
|
+
['3664707673802291', '13135550084'],
|
|
91
|
+
['1821827464894892', '13135550085'],
|
|
92
|
+
['1760312477828757', '13135550086'],
|
|
93
|
+
['439480398712216', '13135550087'],
|
|
94
|
+
['1876735582800984', '13135550088'],
|
|
95
|
+
['984025089825661', '13135550089'],
|
|
96
|
+
['1001336351558186', '13135550090'],
|
|
97
|
+
['3739346336347061', '13135550091'],
|
|
98
|
+
['3632749426974980', '13135550092'],
|
|
99
|
+
['427864203481615', '13135550093'],
|
|
100
|
+
['1434734570493055', '13135550094'],
|
|
101
|
+
['992873449225921', '13135550095'],
|
|
102
|
+
['813087747426445', '13135550096'],
|
|
103
|
+
['806369104931434', '13135550098'],
|
|
104
|
+
['1220982902403148', '13135550099'],
|
|
105
|
+
['1365893374104393', '13135550100'],
|
|
106
|
+
['686482033622048', '13135550200'],
|
|
107
|
+
['1454999838411253', '13135550201'],
|
|
108
|
+
['718584497008509', '13135550202'],
|
|
109
|
+
['743520384213443', '13135550301'],
|
|
110
|
+
['1147715789823789', '13135550302'],
|
|
111
|
+
['1173034540372201', '13135550303'],
|
|
112
|
+
['974785541030953', '13135550304'],
|
|
113
|
+
['1122200255531507', '13135550305'],
|
|
114
|
+
['899669714813162', '13135550306'],
|
|
115
|
+
['631880108970650', '13135550307'],
|
|
116
|
+
['435816149330026', '13135550308'],
|
|
117
|
+
['1368717161184556', '13135550309'],
|
|
118
|
+
['7849963461784891', '13135550310'],
|
|
119
|
+
['3609617065968984', '13135550312'],
|
|
120
|
+
['356273980574602', '13135550313'],
|
|
121
|
+
['1043447920539760', '13135550314'],
|
|
122
|
+
['1052764336525346', '13135550315'],
|
|
123
|
+
['2631118843732685', '13135550316'],
|
|
124
|
+
['510505411332176', '13135550317'],
|
|
125
|
+
['1945664239227513', '13135550318'],
|
|
126
|
+
['1518594378764656', '13135550319'],
|
|
127
|
+
['1378821579456138', '13135550320'],
|
|
128
|
+
['490214716896013', '13135550321'],
|
|
129
|
+
['1028577858870699', '13135550322'],
|
|
130
|
+
['308915665545959', '13135550323'],
|
|
131
|
+
['845884253678900', '13135550324'],
|
|
132
|
+
['995031308616442', '13135550325'],
|
|
133
|
+
['2787365464763437', '13135550326'],
|
|
134
|
+
['1532790990671645', '13135550327'],
|
|
135
|
+
['302617036180485', '13135550328'],
|
|
136
|
+
['723376723197227', '13135550329'],
|
|
137
|
+
['8393570407377966', '13135550330'],
|
|
138
|
+
['1931159970680725', '13135550331'],
|
|
139
|
+
['401073885688605', '13135550332'],
|
|
140
|
+
['2234478453565422', '13135550334'],
|
|
141
|
+
['814748673882312', '13135550335'],
|
|
142
|
+
['26133635056281592', '13135550336'],
|
|
143
|
+
['1439804456676119', '13135550337'],
|
|
144
|
+
['889851503172161', '13135550338'],
|
|
145
|
+
['1018283232836879', '13135550339'],
|
|
146
|
+
['1012781386779537', '13135559000'],
|
|
147
|
+
['823280953239532', '13135559001'],
|
|
148
|
+
['1597090934573334', '13135559002'],
|
|
149
|
+
['485965054020343', '13135559003'],
|
|
150
|
+
['1033381648363446', '13135559004'],
|
|
151
|
+
['491802010206446', '13135559005'],
|
|
152
|
+
['1017139033184870', '13135559006'],
|
|
153
|
+
['499638325922174', '13135559008'],
|
|
154
|
+
['468946335863664', '13135559009'],
|
|
155
|
+
['1570389776875816', '13135559010'],
|
|
156
|
+
['1004342694328995', '13135559011'],
|
|
157
|
+
['1012240323971229', '13135559012'],
|
|
158
|
+
['392171787222419', '13135559013'],
|
|
159
|
+
['952081212945019', '13135559016'],
|
|
160
|
+
['444507875070178', '13135559017'],
|
|
161
|
+
['1274819440594668', '13135559018'],
|
|
162
|
+
['1397041101147050', '13135559019'],
|
|
163
|
+
['425657699872640', '13135559020'],
|
|
164
|
+
['532292852562549', '13135559021'],
|
|
165
|
+
['705863241720292', '13135559022'],
|
|
166
|
+
['476449815183959', '13135559023'],
|
|
167
|
+
['488071553854222', '13135559024'],
|
|
168
|
+
['468693832665397', '13135559025'],
|
|
169
|
+
['517422564037340', '13135559026'],
|
|
170
|
+
['819805466613825', '13135559027'],
|
|
171
|
+
['1847708235641382', '13135559028'],
|
|
172
|
+
['716282970644228', '13135559029'],
|
|
173
|
+
['521655380527741', '13135559030'],
|
|
174
|
+
['476193631941905', '13135559031'],
|
|
175
|
+
['485600497445562', '13135559032'],
|
|
176
|
+
['440217235683910', '13135559033'],
|
|
177
|
+
['523342446758478', '13135559034'],
|
|
178
|
+
['514784864360240', '13135559035'],
|
|
179
|
+
['505790121814530', '13135559036'],
|
|
180
|
+
['420008964419580', '13135559037'],
|
|
181
|
+
['492141680204555', '13135559038'],
|
|
182
|
+
['388462787271952', '13135559039'],
|
|
183
|
+
['423473920752072', '13135559040'],
|
|
184
|
+
['489574180468229', '13135559041'],
|
|
185
|
+
['432360635854105', '13135559042'],
|
|
186
|
+
['477878201669248', '13135559043'],
|
|
187
|
+
['351656951234045', '13135559044'],
|
|
188
|
+
['430178036732582', '13135559045'],
|
|
189
|
+
['434537312944552', '13135559046'],
|
|
190
|
+
['1240614300631808', '13135559047'],
|
|
191
|
+
['473135945605128', '13135559048'],
|
|
192
|
+
['423669800729310', '13135559049'],
|
|
193
|
+
['3685666705015792', '13135559050'],
|
|
194
|
+
['504196509016638', '13135559051'],
|
|
195
|
+
['346844785189449', '13135559052'],
|
|
196
|
+
['504823088911074', '13135559053'],
|
|
197
|
+
['402669415797083', '13135559054'],
|
|
198
|
+
['490939640234431', '13135559055'],
|
|
199
|
+
['875124128063715', '13135559056'],
|
|
200
|
+
['468788962654605', '13135559057'],
|
|
201
|
+
['562386196354570', '13135559058'],
|
|
202
|
+
['372159285928791', '13135559059'],
|
|
203
|
+
['531017479591050', '13135559060'],
|
|
204
|
+
['1328873881401826', '13135559061'],
|
|
205
|
+
['1608363646390484', '13135559062'],
|
|
206
|
+
['1229628561554232', '13135559063'],
|
|
207
|
+
['348802211530364', '13135559064'],
|
|
208
|
+
['3708535859420184', '13135559065'],
|
|
209
|
+
['415517767742187', '13135559066'],
|
|
210
|
+
['479330341612638', '13135559067'],
|
|
211
|
+
['480785414723083', '13135559068'],
|
|
212
|
+
['387299107507991', '13135559069'],
|
|
213
|
+
['333389813188944', '13135559070'],
|
|
214
|
+
['391794130316996', '13135559071'],
|
|
215
|
+
['457893470576314', '13135559072'],
|
|
216
|
+
['435550496166469', '13135559073'],
|
|
217
|
+
['1620162702100689', '13135559074'],
|
|
218
|
+
['867491058616043', '13135559075'],
|
|
219
|
+
['816224117357759', '13135559076'],
|
|
220
|
+
['334065176362830', '13135559077'],
|
|
221
|
+
['489973170554709', '13135559078'],
|
|
222
|
+
['473060669049665', '13135559079'],
|
|
223
|
+
['1221505815643060', '13135559080'],
|
|
224
|
+
['889000703096359', '13135559081'],
|
|
225
|
+
['475235961979883', '13135559082'],
|
|
226
|
+
['3434445653519934', '13135559084'],
|
|
227
|
+
['524503026827421', '13135559085'],
|
|
228
|
+
['1179639046403856', '13135559086'],
|
|
229
|
+
['471563305859144', '13135559087'],
|
|
230
|
+
['533896609192881', '13135559088'],
|
|
231
|
+
['365443583168041', '13135559089'],
|
|
232
|
+
['836082305329393', '13135559090'],
|
|
233
|
+
['1056787705969916', '13135559091'],
|
|
234
|
+
['503312598958357', '13135559092'],
|
|
235
|
+
['3718606738453460', '13135559093'],
|
|
236
|
+
['826066052850902', '13135559094'],
|
|
237
|
+
['1033611345091888', '13135559095'],
|
|
238
|
+
['3868390816783240', '13135559096'],
|
|
239
|
+
['7462677740498860', '13135559097'],
|
|
240
|
+
['436288576108573', '13135559098'],
|
|
241
|
+
['1047559746718900', '13135559099'],
|
|
242
|
+
['1099299455255491', '13135559100'],
|
|
243
|
+
['1202037301040633', '13135559101'],
|
|
244
|
+
['1720619402074074', '13135559102'],
|
|
245
|
+
['1030422235101467', '13135559103'],
|
|
246
|
+
['827238979523502', '13135559104'],
|
|
247
|
+
['1516443722284921', '13135559105'],
|
|
248
|
+
['1174442747196709', '13135559106'],
|
|
249
|
+
['1653165225503842', '13135559107'],
|
|
250
|
+
['1037648777635013', '13135559108'],
|
|
251
|
+
['551617757299900', '13135559109'],
|
|
252
|
+
['1158813558718726', '13135559110'],
|
|
253
|
+
['2463236450542262', '13135559111'],
|
|
254
|
+
['1550393252501466', '13135559112'],
|
|
255
|
+
['2057065188042796', '13135559113'],
|
|
256
|
+
['506163028760735', '13135559114'],
|
|
257
|
+
['2065249100538481', '13135559115'],
|
|
258
|
+
['1041382867195858', '13135559116'],
|
|
259
|
+
['886500209499603', '13135559117'],
|
|
260
|
+
['1491615624892655', '13135559118'],
|
|
261
|
+
['486563697299617', '13135559119'],
|
|
262
|
+
['1175736513679463', '13135559120'],
|
|
263
|
+
['491811473512352', '13165550064']
|
|
264
|
+
])
|
|
265
|
+
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1
|
|
266
|
+
if (sepIdx < 0) {
|
|
267
|
+
return jid
|
|
268
|
+
}
|
|
269
|
+
const server = jid.slice(sepIdx + 1)
|
|
270
|
+
if (server !== 'bot') return jid
|
|
271
|
+
const user = jid.slice(0, sepIdx)
|
|
272
|
+
const mappedNumber = BOT_MAP.get(user)
|
|
273
|
+
return mappedNumber ? `${mappedNumber}@s.whatsapp.net` : jid
|
|
274
|
+
}
|
|
275
|
+
exports.getBotJid = getBotJid
|
|
276
|
+
|
|
277
|
+
const jidEncode = (user, server, device, agent) => {
|
|
278
|
+
const isInterop = server === 'interop'
|
|
279
|
+
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device || (device === 0 && !isInterop) ? `:${device}` : ''}@${server}`
|
|
280
|
+
}
|
|
281
|
+
exports.jidEncode = jidEncode
|
|
282
|
+
const jidDecode = jid => {
|
|
283
|
+
// todo: investigate how to implement hosted ids in this case
|
|
284
|
+
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1
|
|
285
|
+
if (sepIdx < 0) {
|
|
286
|
+
return undefined
|
|
287
|
+
}
|
|
288
|
+
const server = jid.slice(sepIdx + 1)
|
|
289
|
+
const userCombined = jid.slice(0, sepIdx)
|
|
290
|
+
const [userAgent, device] = userCombined.split(':')
|
|
291
|
+
const [user, agent] = userAgent.split('_')
|
|
292
|
+
let domainType = WAJIDDomains.WHATSAPP
|
|
293
|
+
if (server === 'lid') {
|
|
294
|
+
domainType = WAJIDDomains.LID
|
|
295
|
+
} else if (server === 'hosted') {
|
|
296
|
+
domainType = WAJIDDomains.HOSTED
|
|
297
|
+
} else if (server === 'hosted.lid') {
|
|
298
|
+
domainType = WAJIDDomains.HOSTED_LID
|
|
299
|
+
} else if (agent) {
|
|
300
|
+
domainType = parseInt(agent)
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
server: server,
|
|
304
|
+
user: user,
|
|
305
|
+
domainType,
|
|
306
|
+
device: device ? +device : undefined
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
exports.jidDecode = jidDecode
|
|
310
|
+
/** is the jid a user */
|
|
311
|
+
const areJidsSameUser = (jid1, jid2) => (0, exports.jidDecode)(jid1)?.user === (0, exports.jidDecode)(jid2)?.user
|
|
312
|
+
exports.areJidsSameUser = areJidsSameUser
|
|
313
|
+
/** is the jid Meta AI */
|
|
314
|
+
const isJidMetaAI = jid => jid?.endsWith('@bot')
|
|
315
|
+
exports.isJidMetaAI = isJidMetaAI
|
|
316
|
+
/** is the jid a PN user */
|
|
317
|
+
const isPnUser = jid => jid?.endsWith('@s.whatsapp.net')
|
|
318
|
+
exports.isPnUser = isPnUser
|
|
319
|
+
/** is the jid an interop (BirdyChat/Haiket) user */
|
|
320
|
+
const isInteropUser = jid => jid?.endsWith('@interop')
|
|
321
|
+
exports.isInteropUser = isInteropUser
|
|
322
|
+
/** is the jid a LID */
|
|
323
|
+
const isLidUser = jid => jid?.endsWith('@lid')
|
|
324
|
+
exports.isLidUser = isLidUser
|
|
325
|
+
/** is the jid a broadcast */
|
|
326
|
+
const isJidBroadcast = jid => jid?.endsWith('@broadcast')
|
|
327
|
+
exports.isJidBroadcast = isJidBroadcast
|
|
328
|
+
/** is the jid a group */
|
|
329
|
+
const isJidGroup = jid => jid?.endsWith('@g.us')
|
|
330
|
+
exports.isJidGroup = isJidGroup
|
|
331
|
+
/** is the jid the status broadcast */
|
|
332
|
+
const isJidStatusBroadcast = jid => jid === 'status@broadcast'
|
|
333
|
+
exports.isJidStatusBroadcast = isJidStatusBroadcast
|
|
334
|
+
/** is the jid a newsletter */
|
|
335
|
+
const isJidNewsletter = jid => jid?.endsWith('@newsletter')
|
|
336
|
+
exports.isJidNewsletter = isJidNewsletter
|
|
337
|
+
/** is the jid a hosted PN */
|
|
338
|
+
const isHostedPnUser = jid => jid?.endsWith('@hosted')
|
|
339
|
+
exports.isHostedPnUser = isHostedPnUser
|
|
340
|
+
/** is the jid a hosted LID */
|
|
341
|
+
const isHostedLidUser = jid => jid?.endsWith('@hosted.lid')
|
|
342
|
+
exports.isHostedLidUser = isHostedLidUser
|
|
343
|
+
const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/
|
|
344
|
+
const isJidBot = jid => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us')
|
|
345
|
+
exports.isJidBot = isJidBot
|
|
346
|
+
const jidNormalizedUser = jid => {
|
|
347
|
+
const result = (0, exports.jidDecode)(jid)
|
|
348
|
+
if (!result) {
|
|
349
|
+
return ''
|
|
350
|
+
}
|
|
351
|
+
const { user, server } = result
|
|
352
|
+
return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server)
|
|
353
|
+
}
|
|
354
|
+
exports.jidNormalizedUser = jidNormalizedUser
|
|
355
|
+
const transferDevice = (fromJid, toJid) => {
|
|
356
|
+
const fromDecoded = (0, exports.jidDecode)(fromJid)
|
|
357
|
+
const deviceId = fromDecoded?.device || 0
|
|
358
|
+
const { server, user } = (0, exports.jidDecode)(toJid)
|
|
359
|
+
return (0, exports.jidEncode)(user, server, deviceId)
|
|
360
|
+
}
|
|
361
|
+
exports.transferDevice = transferDevice
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.BinaryInfo = void 0
|
|
4
|
+
class BinaryInfo {
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.protocolVersion = 5
|
|
7
|
+
this.sequence = 0
|
|
8
|
+
this.events = []
|
|
9
|
+
this.buffer = []
|
|
10
|
+
Object.assign(this, options)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.BinaryInfo = BinaryInfo
|