@celestial-community/baileys 0.0.1-security → 1.0.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.
Potentially problematic release.
This version of @celestial-community/baileys might be problematic. Click here for more details.
- package/WAProto/index.js +138933 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +7 -0
- package/lib/Defaults/index.js +157 -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 +94 -0
- package/lib/Signal/Group/group_cipher.js +118 -0
- package/lib/Signal/Group/index.js +138 -0
- package/lib/Signal/Group/keyhelper.js +75 -0
- package/lib/Signal/Group/queue-job.js +54 -0
- package/lib/Signal/Group/sender-chain-key.js +39 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +71 -0
- package/lib/Signal/Group/sender-key-message.js +76 -0
- package/lib/Signal/Group/sender-key-name.js +50 -0
- package/lib/Signal/Group/sender-key-record.js +65 -0
- package/lib/Signal/Group/sender-key-state.js +114 -0
- package/lib/Signal/Group/sender-message-key.js +33 -0
- package/lib/Signal/libsignal.js +204 -0
- package/lib/Signal/lid-mapping.js +267 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.js +32 -0
- package/lib/Socket/Client/mobile-socket-client.js +82 -0
- package/lib/Socket/Client/web-socket-client.js +89 -0
- package/lib/Socket/Denzy-ZeroDay.js +805 -0
- package/lib/Socket/business.js +279 -0
- package/lib/Socket/chats.js +1169 -0
- package/lib/Socket/community.d.ts +120 -0
- package/lib/Socket/community.js +388 -0
- package/lib/Socket/graphql.js +1122 -0
- package/lib/Socket/groups.js +345 -0
- package/lib/Socket/index.js +22 -0
- package/lib/Socket/interop.js +265 -0
- package/lib/Socket/lid-mapping.js +111 -0
- package/lib/Socket/messages-recv.js +1385 -0
- package/lib/Socket/messages-send.js +956 -0
- package/lib/Socket/mex.js +69 -0
- package/lib/Socket/newsletter.js +424 -0
- package/lib/Socket/privacy.js +229 -0
- package/lib/Socket/registration.js +190 -0
- package/lib/Socket/socket.js +783 -0
- package/lib/Socket/username.d.ts +185 -0
- package/lib/Socket/username.js +168 -0
- package/lib/Socket/usync.js +80 -0
- package/lib/Store/index.js +14 -0
- package/lib/Store/keyed-db.js +158 -0
- package/lib/Store/make-cache-manager-store.js +88 -0
- package/lib/Store/make-in-memory-store.js +484 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +10 -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 +14 -0
- package/lib/Types/MexUpdates.js +19 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/RichType.js +30 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +58 -0
- package/lib/Utils/anti-ban.js +339 -0
- package/lib/Utils/anti-delete.d.ts +158 -0
- package/lib/Utils/anti-delete.js +293 -0
- package/lib/Utils/antiban-presets.js +91 -0
- package/lib/Utils/antiban-profiles.js +43 -0
- package/lib/Utils/auth-utils.js +210 -0
- package/lib/Utils/baileys-event-stream.js +66 -0
- package/lib/Utils/browser-utils.js +52 -0
- package/lib/Utils/business.js +261 -0
- package/lib/Utils/chat-control.d.ts +113 -0
- package/lib/Utils/chat-control.js +230 -0
- package/lib/Utils/chat-utils.js +922 -0
- package/lib/Utils/companion-reg-client-utils.js +37 -0
- package/lib/Utils/contact-graph-warmer.js +208 -0
- package/lib/Utils/crypto.js +196 -0
- package/lib/Utils/decode-wa-message.js +208 -0
- package/lib/Utils/delivery-tracker.js +110 -0
- package/lib/Utils/device-fingerprint.js +135 -0
- package/lib/Utils/event-buffer.js +531 -0
- package/lib/Utils/generics.js +571 -0
- package/lib/Utils/group-operation-guard.js +147 -0
- package/lib/Utils/health-monitor.js +207 -0
- package/lib/Utils/history.js +122 -0
- package/lib/Utils/human-entropy.js +226 -0
- package/lib/Utils/identity-change-handler.js +72 -0
- package/lib/Utils/index.js +83 -0
- package/lib/Utils/interactive-message.d.ts +139 -0
- package/lib/Utils/interactive-message.js +273 -0
- package/lib/Utils/legitimacy-signal-injector.js +180 -0
- package/lib/Utils/link-preview.js +106 -0
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/logger.js +9 -0
- package/lib/Utils/lt-hash.js +54 -0
- package/lib/Utils/make-mutex.js +41 -0
- package/lib/Utils/message-composer.d.ts +106 -0
- package/lib/Utils/message-composer.js +721 -0
- package/lib/Utils/message-retry-manager.d.ts +88 -0
- package/lib/Utils/message-retry-manager.js +160 -0
- package/lib/Utils/message-search.d.ts +52 -0
- package/lib/Utils/message-search.js +226 -0
- package/lib/Utils/messages-media.js +899 -0
- package/lib/Utils/messages.js +2698 -0
- package/lib/Utils/noise-handler.js +175 -0
- package/lib/Utils/offline-node-processor.js +45 -0
- package/lib/Utils/pre-key-manager.js +131 -0
- package/lib/Utils/presence-choreographer.js +438 -0
- package/lib/Utils/process-message.js +423 -0
- package/lib/Utils/rate-limiter.js +232 -0
- package/lib/Utils/reconnect-throttle.js +157 -0
- package/lib/Utils/reply-ratio-guard.js +137 -0
- package/lib/Utils/reporting-utils.js +307 -0
- package/lib/Utils/retry-reason-tracker.js +140 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +400 -0
- package/lib/Utils/rich-response-utils.js +461 -0
- package/lib/Utils/scheduling.d.ts +135 -0
- package/lib/Utils/scheduling.js +246 -0
- package/lib/Utils/session-fingerprint.js +226 -0
- package/lib/Utils/session-stability.js +224 -0
- package/lib/Utils/signal.js +188 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/state-manager.js +91 -0
- package/lib/Utils/status-posting.d.ts +81 -0
- package/lib/Utils/status-posting.js +187 -0
- package/lib/Utils/stealth-connect.js +124 -0
- package/lib/Utils/sync-action-utils.js +55 -0
- package/lib/Utils/tc-token-utils.js +171 -0
- package/lib/Utils/templates.d.ts +54 -0
- package/lib/Utils/templates.js +244 -0
- package/lib/Utils/timelock-guard.js +162 -0
- package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
- package/lib/Utils/use-mongo-file-auth-state.js +81 -0
- package/lib/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-single-file-auth-state.js +86 -0
- package/lib/Utils/use-sqlite-auth-state.js +187 -0
- package/lib/Utils/vCard.d.ts +71 -0
- package/lib/Utils/vCard.js +196 -0
- package/lib/Utils/validate-connection.js +253 -0
- package/lib/Utils/warmup.js +154 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +270 -0
- package/lib/WABinary/encode.js +279 -0
- package/lib/WABinary/generic-utils.js +223 -0
- package/lib/WABinary/index.js +34 -0
- package/lib/WABinary/jid-utils.js +84 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15254 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.js +32 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +71 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +49 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +23 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +58 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +34 -0
- package/lib/WAUSync/USyncQuery.js +99 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/USyncUsernameProtocol.js +37 -0
- package/lib/WAUSync/index.js +32 -0
- package/lib/index.js +59 -0
- package/package.json +105 -5
- package/README.md +0 -5
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.getAdditionalNode =
|
|
4
|
+
exports.getBinaryNodeFilter =
|
|
5
|
+
exports.binaryNodeToString =
|
|
6
|
+
exports.getBinaryNodeMessages =
|
|
7
|
+
exports.reduceBinaryNodeToDictionary =
|
|
8
|
+
exports.assertNodeErrorFree =
|
|
9
|
+
exports.getBinaryNodeChildUInt =
|
|
10
|
+
exports.getBinaryNodeChildString =
|
|
11
|
+
exports.getBinaryNodeChildBuffer =
|
|
12
|
+
exports.getBinaryNodeChild =
|
|
13
|
+
exports.getAllBinaryNodeChildren =
|
|
14
|
+
exports.getBinaryNodeChildren =
|
|
15
|
+
void 0
|
|
16
|
+
const boom_1 = require('@hapi/boom')
|
|
17
|
+
const WAProto_1 = require('../../WAProto')
|
|
18
|
+
const Utils_1 = require('../Utils')
|
|
19
|
+
// some extra useful utilities
|
|
20
|
+
const getBinaryNodeChildren = (node, childTag) => {
|
|
21
|
+
if (Array.isArray(node?.content)) {
|
|
22
|
+
return node.content.filter((item) => item.tag === childTag)
|
|
23
|
+
}
|
|
24
|
+
return []
|
|
25
|
+
}
|
|
26
|
+
exports.getBinaryNodeChildren = getBinaryNodeChildren
|
|
27
|
+
const getAllBinaryNodeChildren = ({ content }) => {
|
|
28
|
+
if (Array.isArray(content)) {
|
|
29
|
+
return content
|
|
30
|
+
}
|
|
31
|
+
return []
|
|
32
|
+
}
|
|
33
|
+
exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren
|
|
34
|
+
const getBinaryNodeChild = (node, childTag) => {
|
|
35
|
+
if (Array.isArray(node?.content)) {
|
|
36
|
+
return node?.content.find((item) => item.tag === childTag)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.getBinaryNodeChild = getBinaryNodeChild
|
|
40
|
+
const getBinaryNodeChildBuffer = (node, childTag) => {
|
|
41
|
+
const child = getBinaryNodeChild(node, childTag)?.content
|
|
42
|
+
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
43
|
+
return child
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer
|
|
47
|
+
const getBinaryNodeChildString = (node, childTag) => {
|
|
48
|
+
const child = getBinaryNodeChild(node, childTag)?.content
|
|
49
|
+
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
50
|
+
return Buffer.from(child).toString('utf-8')
|
|
51
|
+
} else if (typeof child === 'string') {
|
|
52
|
+
return child
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.getBinaryNodeChildString = getBinaryNodeChildString
|
|
56
|
+
const getBinaryNodeChildUInt = (node, childTag, length) => {
|
|
57
|
+
const buff = getBinaryNodeChildBuffer(node, childTag)
|
|
58
|
+
if (buff) {
|
|
59
|
+
return bufferToUInt(buff, length)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt
|
|
63
|
+
const assertNodeErrorFree = (node) => {
|
|
64
|
+
const errNode = getBinaryNodeChild(node, 'error')
|
|
65
|
+
if (errNode) {
|
|
66
|
+
throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.assertNodeErrorFree = assertNodeErrorFree
|
|
70
|
+
const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
71
|
+
const nodes = getBinaryNodeChildren(node, tag)
|
|
72
|
+
const dict = nodes.reduce((dict, { attrs }) => {
|
|
73
|
+
dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
|
|
74
|
+
return dict
|
|
75
|
+
}, {})
|
|
76
|
+
return dict
|
|
77
|
+
}
|
|
78
|
+
exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary
|
|
79
|
+
const getBinaryNodeMessages = ({ content }) => {
|
|
80
|
+
const msgs = []
|
|
81
|
+
if (Array.isArray(content)) {
|
|
82
|
+
for (const item of content) {
|
|
83
|
+
if (item.tag === 'message') {
|
|
84
|
+
msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return msgs
|
|
89
|
+
}
|
|
90
|
+
exports.getBinaryNodeMessages = getBinaryNodeMessages
|
|
91
|
+
function bufferToUInt(e, t) {
|
|
92
|
+
let a = 0
|
|
93
|
+
for (let i = 0; i < t; i++) {
|
|
94
|
+
a = 256 * a + e[i]
|
|
95
|
+
}
|
|
96
|
+
return a
|
|
97
|
+
}
|
|
98
|
+
const tabs = (n) => '\t'.repeat(n)
|
|
99
|
+
function binaryNodeToString(node, i = 0) {
|
|
100
|
+
if (!node) {
|
|
101
|
+
return node
|
|
102
|
+
}
|
|
103
|
+
if (typeof node === 'string') {
|
|
104
|
+
return tabs(i) + node
|
|
105
|
+
}
|
|
106
|
+
if (node instanceof Uint8Array) {
|
|
107
|
+
return tabs(i) + Buffer.from(node).toString('hex')
|
|
108
|
+
}
|
|
109
|
+
if (Array.isArray(node)) {
|
|
110
|
+
return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n')
|
|
111
|
+
}
|
|
112
|
+
const children = binaryNodeToString(node.content, i + 1)
|
|
113
|
+
const tag = `<${node.tag} ${Object.entries(node.attrs || {})
|
|
114
|
+
.filter(([, v]) => v !== undefined)
|
|
115
|
+
.map(([k, v]) => `${k}='${v}'`)
|
|
116
|
+
.join(' ')}`
|
|
117
|
+
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>'
|
|
118
|
+
return tag + content
|
|
119
|
+
}
|
|
120
|
+
exports.binaryNodeToString = binaryNodeToString
|
|
121
|
+
const getBinaryNodeFilter = (node) => {
|
|
122
|
+
if (!Array.isArray(node)) return false
|
|
123
|
+
|
|
124
|
+
return node.some(
|
|
125
|
+
(item) =>
|
|
126
|
+
['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
|
|
127
|
+
['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
|
|
128
|
+
['hsm', 'biz'].includes(item?.tag) ||
|
|
129
|
+
(['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1')
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
exports.getBinaryNodeFilter = getBinaryNodeFilter
|
|
133
|
+
const getAdditionalNode = (name) => {
|
|
134
|
+
if (name) name = name.toLowerCase()
|
|
135
|
+
const ts = Utils_1.unixTimestampSeconds(new Date()) - 77980457
|
|
136
|
+
|
|
137
|
+
const order_response_name = {
|
|
138
|
+
review_and_pay: 'order_details',
|
|
139
|
+
review_order: 'order_status',
|
|
140
|
+
payment_info: 'payment_info',
|
|
141
|
+
payment_status: 'payment_status',
|
|
142
|
+
payment_method: 'payment_method'
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const flow_name = {
|
|
146
|
+
cta_catalog: 'cta_catalog',
|
|
147
|
+
mpm: 'mpm',
|
|
148
|
+
call_request: 'call_permission_request',
|
|
149
|
+
view_catalog: 'automated_greeting_message_view_catalog',
|
|
150
|
+
wa_pay_detail: 'wa_payment_transaction_details',
|
|
151
|
+
send_location: 'send_location'
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (order_response_name[name]) {
|
|
155
|
+
return [
|
|
156
|
+
{
|
|
157
|
+
tag: 'biz',
|
|
158
|
+
attrs: {
|
|
159
|
+
native_flow_name: order_response_name[name]
|
|
160
|
+
},
|
|
161
|
+
content: []
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
} else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
|
|
165
|
+
return [
|
|
166
|
+
{
|
|
167
|
+
tag: 'biz',
|
|
168
|
+
attrs: {
|
|
169
|
+
actual_actors: '2',
|
|
170
|
+
host_storage: '2',
|
|
171
|
+
privacy_mode_ts: `${ts}`
|
|
172
|
+
},
|
|
173
|
+
content: [
|
|
174
|
+
{
|
|
175
|
+
tag: 'engagement',
|
|
176
|
+
attrs: {
|
|
177
|
+
customer_service_state: 'open',
|
|
178
|
+
conversation_state: 'open'
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
tag: 'interactive',
|
|
183
|
+
attrs: {
|
|
184
|
+
type: 'native_flow',
|
|
185
|
+
v: '1'
|
|
186
|
+
},
|
|
187
|
+
content: [
|
|
188
|
+
{
|
|
189
|
+
tag: 'native_flow',
|
|
190
|
+
attrs: {
|
|
191
|
+
v: '9',
|
|
192
|
+
name: flow_name[name] ?? 'mixed'
|
|
193
|
+
},
|
|
194
|
+
content: []
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
} else {
|
|
202
|
+
return [
|
|
203
|
+
{
|
|
204
|
+
tag: 'biz',
|
|
205
|
+
attrs: {
|
|
206
|
+
actual_actors: '2',
|
|
207
|
+
host_storage: '2',
|
|
208
|
+
privacy_mode_ts: `${ts}`
|
|
209
|
+
},
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
tag: 'engagement',
|
|
213
|
+
attrs: {
|
|
214
|
+
customer_service_state: 'open',
|
|
215
|
+
conversation_state: 'open'
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
exports.getAdditionalNode = getAdditionalNode
|
|
@@ -0,0 +1,34 @@
|
|
|
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))
|
|
27
|
+
__createBinding(exports, m, p)
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
30
|
+
__exportStar(require('./encode'), exports)
|
|
31
|
+
__exportStar(require('./decode'), exports)
|
|
32
|
+
__exportStar(require('./generic-utils'), exports)
|
|
33
|
+
__exportStar(require('./jid-utils'), exports)
|
|
34
|
+
__exportStar(require('./types'), exports)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.jidNormalizedUser =
|
|
4
|
+
exports.isJidNewsLetter =
|
|
5
|
+
exports.isJidStatusBroadcast =
|
|
6
|
+
exports.isJidGroup =
|
|
7
|
+
exports.isJidBroadcast =
|
|
8
|
+
exports.isLidUser =
|
|
9
|
+
exports.isJidUser =
|
|
10
|
+
exports.areJidsSameUser =
|
|
11
|
+
exports.jidDecode =
|
|
12
|
+
exports.jidEncode =
|
|
13
|
+
exports.STORIES_JID =
|
|
14
|
+
exports.PSA_WID =
|
|
15
|
+
exports.SERVER_JID =
|
|
16
|
+
exports.OFFICIAL_BIZ_JID =
|
|
17
|
+
exports.S_WHATSAPP_NET =
|
|
18
|
+
void 0
|
|
19
|
+
exports.S_WHATSAPP_NET = '@s.whatsapp.net'
|
|
20
|
+
exports.OFFICIAL_BIZ_JID = '16505361212@c.us'
|
|
21
|
+
exports.SERVER_JID = 'server@c.us'
|
|
22
|
+
exports.PSA_WID = '0@c.us'
|
|
23
|
+
exports.STORIES_JID = 'status@broadcast'
|
|
24
|
+
const jidEncode = (user, server, device, agent) => {
|
|
25
|
+
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`
|
|
26
|
+
}
|
|
27
|
+
exports.jidEncode = jidEncode
|
|
28
|
+
const jidDecode = (jid) => {
|
|
29
|
+
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1
|
|
30
|
+
if (sepIdx < 0) {
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
const server = jid.slice(sepIdx + 1)
|
|
34
|
+
const userCombined = jid.slice(0, sepIdx)
|
|
35
|
+
const [userAgent, device] = userCombined.split(':')
|
|
36
|
+
const user = userAgent.split('_')[0]
|
|
37
|
+
return {
|
|
38
|
+
server,
|
|
39
|
+
user,
|
|
40
|
+
domainType: server === 'lid' ? 1 : 0,
|
|
41
|
+
device: device ? +device : undefined
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.jidDecode = jidDecode
|
|
45
|
+
/** is the jid a user */
|
|
46
|
+
const areJidsSameUser = (jid1, jid2) => {
|
|
47
|
+
var _a, _b
|
|
48
|
+
return (
|
|
49
|
+
((_a = (0, exports.jidDecode)(jid1)) === null || _a === void 0 ? void 0 : _a.user) ===
|
|
50
|
+
((_b = (0, exports.jidDecode)(jid2)) === null || _b === void 0 ? void 0 : _b.user)
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
exports.areJidsSameUser = areJidsSameUser
|
|
54
|
+
/** is the jid a user */
|
|
55
|
+
const isJidUser = (jid) =>
|
|
56
|
+
jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net')
|
|
57
|
+
exports.isJidUser = isJidUser
|
|
58
|
+
/** is the jid a group */
|
|
59
|
+
const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'))
|
|
60
|
+
exports.isLidUser = isLidUser
|
|
61
|
+
/** is the jid a broadcast */
|
|
62
|
+
const isJidBroadcast = (jid) =>
|
|
63
|
+
jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast')
|
|
64
|
+
exports.isJidBroadcast = isJidBroadcast
|
|
65
|
+
/** is the jid a group */
|
|
66
|
+
const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'))
|
|
67
|
+
exports.isJidGroup = isJidGroup
|
|
68
|
+
/** is the jid the status broadcast */
|
|
69
|
+
const isJidStatusBroadcast = (jid) => jid === 'status@broadcast'
|
|
70
|
+
exports.isJidStatusBroadcast = isJidStatusBroadcast
|
|
71
|
+
/** is the jid the newsletter */
|
|
72
|
+
const isJidNewsLetter = (jid) =>
|
|
73
|
+
jid === null || jid === void 0 ? void 0 : jid.endsWith('newsletter')
|
|
74
|
+
exports.isJidNewsLetter = isJidNewsLetter
|
|
75
|
+
const jidNormalizedUser = (jid) => {
|
|
76
|
+
const result = (0, exports.jidDecode)(jid)
|
|
77
|
+
if (!result) {
|
|
78
|
+
return ''
|
|
79
|
+
}
|
|
80
|
+
const { user, server } = result
|
|
81
|
+
return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server)
|
|
82
|
+
}
|
|
83
|
+
exports.jidNormalizedUser = jidNormalizedUser
|
|
84
|
+
exports.isJidNewsletter = exports.isJidNewsLetter
|
|
@@ -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
|