@badzz88/baileys 8.4.9 → 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/WAProto/WAProto.proto +6 -347
- package/WAProto/fix-imports.js +85 -86
- package/WAProto/index.d.ts +25 -4913
- package/WAProto/index.js +93 -14069
- package/{src → lib}/Defaults/index.js +2 -13
- package/{src → lib}/Signal/Group/group_cipher.js +5 -5
- package/{src → lib}/Signal/Group/keyhelper.js +4 -4
- package/{src → lib}/Signal/Group/sender-chain-key.js +2 -2
- package/{src → lib}/Signal/Group/sender-key-distribution-message.js +1 -1
- package/{src → lib}/Signal/Group/sender-key-message.js +3 -3
- package/{src → lib}/Signal/Group/sender-key-record.js +1 -1
- package/{src → lib}/Signal/Group/sender-message-key.js +2 -2
- package/{src → lib}/Signal/libsignal.js +26 -6
- package/{src → lib}/Socket/chats.js +58 -616
- package/{src → lib}/Socket/communities.js +28 -59
- package/{src → lib}/Socket/graphql.js +103 -362
- package/{src → lib}/Socket/groups.js +29 -77
- package/{src → lib}/Socket/index.js +5 -3
- package/{src → lib}/Socket/interactive-handler.js +60 -117
- package/{src → lib}/Socket/interop.js +19 -36
- package/lib/Socket/luxu.js +387 -0
- package/{src → lib}/Socket/managed-account.js +27 -58
- package/{src → lib}/Socket/messages-recv.js +143 -715
- package/{src → lib}/Socket/messages-send.js +102 -412
- package/lib/Socket/mex.js +60 -0
- package/{src → lib}/Socket/newsletter.js +23 -266
- package/{src → lib}/Socket/privacy.js +38 -41
- package/{src → lib}/Socket/registration.js +106 -113
- package/{src → lib}/Socket/socket.js +101 -88
- package/{src → lib}/Socket/text-router.js +17 -1
- package/lib/Socket/username.js +243 -0
- package/lib/Store/keyed-db.js +108 -0
- package/{src → lib}/Store/make-in-memory-store.js +104 -6
- package/lib/Types/Mex.js +112 -0
- package/{src → lib}/Types/Newsletter.js +41 -72
- package/{src → lib}/Types/index.js +1 -0
- package/{src → lib}/Utils/chat-utils.js +9 -73
- 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 +42 -0
- package/lib/Utils/crypto.js +155 -0
- package/lib/Utils/curve25519-js.js +275 -0
- package/{src → lib}/Utils/decode-wa-message.js +36 -284
- package/{src → lib}/Utils/event-buffer.js +27 -6
- package/{src → lib}/Utils/generics.js +37 -114
- package/{src → lib}/Utils/index.js +5 -1
- package/lib/Utils/lt-hash.js +39 -0
- package/{src → lib}/Utils/message-retry-manager.js +39 -0
- package/{src → lib}/Utils/messages-media.js +58 -105
- package/{src → lib}/Utils/messages.js +529 -115
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/{src → lib}/Utils/noise-handler.js +15 -13
- package/{src → lib}/Utils/process-message.js +55 -54
- package/{src → lib}/Utils/reporting-utils.js +2 -2
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/{src → lib}/Utils/signal.js +51 -19
- package/{src → lib}/Utils/stanza-ack.js +2 -36
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/{src → lib}/Utils/tc-token-utils.js +1 -1
- package/{src → lib}/Utils/validate-connection.js +11 -40
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/{src → lib}/WABinary/decode.js +4 -38
- package/lib/WABinary/encode.js +228 -0
- package/{src → lib}/WABinary/generic-utils.js +93 -1
- package/{src → lib}/WABinary/jid-utils.js +3 -16
- package/{src → lib}/WAM/encode.js +1 -1
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/{src → lib}/WAUSync/Protocols/USyncContactProtocol.js +1 -7
- package/{src → lib}/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
- package/{src → lib}/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
- package/{src → lib}/WAUSync/Protocols/USyncFeatureProtocol.js +2 -17
- package/{src → lib}/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
- package/{src → lib}/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
- package/{src → lib}/WAUSync/Protocols/index.js +0 -1
- package/{src → lib}/WAUSync/USyncQuery.js +6 -77
- package/{src → lib}/WAUSync/USyncUser.js +8 -16
- package/{src → lib}/WAUSync/index.js +0 -1
- package/{src → lib}/antiban.js +266 -355
- package/{src → lib}/index.js +2 -2
- package/package.json +18 -15
- package/WAProto/fix-import.js +0 -38
- package/src/Socket/mex.js +0 -47
- package/src/Socket/username.js +0 -234
- package/src/Utils/crypto.js +0 -125
- package/src/Utils/lt-hash.js +0 -10
- package/src/Utils/message-inspect.js +0 -400
- package/src/Utils/meta-ai-msmsg.js +0 -133
- package/src/WABinary/encode.js +0 -58
- package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -100
- package/src/WAUSync/USyncBackoff.js +0 -31
- /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
- /package/{src → lib}/Signal/Group/ciphertext-message.js +0 -0
- /package/{src → lib}/Signal/Group/group-session-builder.js +0 -0
- /package/{src → lib}/Signal/Group/index.js +0 -0
- /package/{src → lib}/Signal/Group/sender-key-name.js +0 -0
- /package/{src → lib}/Signal/Group/sender-key-state.js +0 -0
- /package/{src → lib}/Signal/lid-mapping.js +0 -0
- /package/{src → lib}/Socket/Client/index.js +0 -0
- /package/{src → lib}/Socket/Client/types.js +0 -0
- /package/{src → lib}/Socket/Client/websocket.js +0 -0
- /package/{src → lib}/Socket/aigroups.js +0 -0
- /package/{src → lib}/Socket/business.js +0 -0
- /package/{src → lib}/Store/index.js +0 -0
- /package/{src → lib}/Store/make-cache-manager-store.js +0 -0
- /package/{src → lib}/Store/make-ordered-dictionary.js +0 -0
- /package/{src → lib}/Store/object-repository.js +0 -0
- /package/{src → lib}/Types/Auth.js +0 -0
- /package/{src → lib}/Types/Bussines.js +0 -0
- /package/{src → lib}/Types/Call.js +0 -0
- /package/{src → lib}/Types/Chat.js +0 -0
- /package/{src → lib}/Types/Contact.js +0 -0
- /package/{src → lib}/Types/Events.js +0 -0
- /package/{src → lib}/Types/GroupMetadata.js +0 -0
- /package/{src → lib}/Types/Label.js +0 -0
- /package/{src → lib}/Types/LabelAssociation.js +0 -0
- /package/{src → lib}/Types/Message.js +0 -0
- /package/{src → lib}/Types/Product.js +0 -0
- /package/{src → lib}/Types/Signal.js +0 -0
- /package/{src → lib}/Types/Socket.js +0 -0
- /package/{src → lib}/Types/State.js +0 -0
- /package/{src → lib}/Types/USync.js +0 -0
- /package/{src → lib}/Utils/auth-utils.js +0 -0
- /package/{src → lib}/Utils/browser-utils.js +0 -0
- /package/{src → lib}/Utils/business.js +0 -0
- /package/{src → lib}/Utils/consumer-application.js +0 -0
- /package/{src → lib}/Utils/group-history.js +0 -0
- /package/{src → lib}/Utils/history.js +0 -0
- /package/{src → lib}/Utils/identity-change-handler.js +0 -0
- /package/{src → lib}/Utils/jid-display-normalization.js +0 -0
- /package/{src → lib}/Utils/link-preview.js +0 -0
- /package/{src → lib}/Utils/logger.js +0 -0
- /package/{src → lib}/Utils/make-mutex.js +0 -0
- /package/{src → lib}/Utils/message-composer.js +0 -0
- /package/{src → lib}/Utils/offline-node-processor.js +0 -0
- /package/{src → lib}/Utils/pre-key-manager.js +0 -0
- /package/{src → lib}/Utils/sync-action-utils.js +0 -0
- /package/{src → lib}/Utils/use-multi-file-auth-state.js +0 -0
- /package/{src → lib}/Utils/voip-rekey.js +0 -0
- /package/{src → lib}/WABinary/constants.js +0 -0
- /package/{src → lib}/WABinary/index.js +0 -0
- /package/{src → lib}/WABinary/types.js +0 -0
- /package/{src → lib}/WAM/BinaryInfo.js +0 -0
- /package/{src → lib}/WAM/constants.js +0 -0
- /package/{src → lib}/WAM/index.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncLIDProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncPictureProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncSidelistProtocol.js +0 -0
- /package/{src → lib}/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -0
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
|
|
4
|
-
const boom_1 = require('@hapi/boom')
|
|
5
|
-
const { proto } = require('../../WAProto/index.js')
|
|
6
|
-
const WABinary_1 = require('../WABinary')
|
|
7
|
-
const crypto_2 = require('./crypto')
|
|
8
|
-
const generics_1 = require('./generics')
|
|
9
|
-
const messages_media_1 = require('./messages-media')
|
|
10
|
-
|
|
11
|
-
/** Get the key to access the true type of content */
|
|
12
|
-
const getContentType = content => {
|
|
13
|
-
if (content) {
|
|
14
|
-
const keys = Object.keys(content)
|
|
15
|
-
const key = keys.find(k => (k === 'conversation' || k.includes('Message')) && k !== 'senderKeyDistributionMessage')
|
|
16
|
-
return key
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.getContentType = getContentType
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Normalizes ephemeral, view once messages to regular message content
|
|
23
|
-
* Eg. image messages in ephemeral messages, in view once messages etc.
|
|
24
|
-
*/
|
|
25
|
-
const normalizeMessageContent = content => {
|
|
26
|
-
if (!content) {
|
|
27
|
-
return undefined
|
|
28
|
-
}
|
|
29
|
-
// set max iterations to prevent an infinite loop
|
|
30
|
-
for (let i = 0; i < 5; i++) {
|
|
31
|
-
const inner = getFutureProofMessage(content)
|
|
32
|
-
if (!inner) {
|
|
33
|
-
break
|
|
34
|
-
}
|
|
35
|
-
content = inner.message
|
|
36
|
-
}
|
|
37
|
-
return content
|
|
38
|
-
function getFutureProofMessage(message) {
|
|
39
|
-
return (
|
|
40
|
-
message.ephemeralMessage ||
|
|
41
|
-
message.viewOnceMessage ||
|
|
42
|
-
message.documentWithCaptionMessage ||
|
|
43
|
-
message.viewOnceMessageV2 ||
|
|
44
|
-
message.viewOnceMessageV2Extension ||
|
|
45
|
-
message.editedMessage ||
|
|
46
|
-
message.groupMentionedMessage ||
|
|
47
|
-
message.botInvokeMessage ||
|
|
48
|
-
message.lottieStickerMessage ||
|
|
49
|
-
message.eventCoverImage ||
|
|
50
|
-
message.statusMentionMessage ||
|
|
51
|
-
message.pollCreationOptionImageMessage ||
|
|
52
|
-
message.associatedChildMessage ||
|
|
53
|
-
message.groupStatusMentionMessage ||
|
|
54
|
-
message.pollCreationMessageV4 ||
|
|
55
|
-
message.pollCreationMessageV5 ||
|
|
56
|
-
message.statusAddYours ||
|
|
57
|
-
message.groupStatusMessage ||
|
|
58
|
-
message.limitSharingMessage ||
|
|
59
|
-
message.botTaskMessage ||
|
|
60
|
-
message.questionMessage ||
|
|
61
|
-
message.groupStatusMessageV2 ||
|
|
62
|
-
message.botForwardedMessage ||
|
|
63
|
-
message.questionReplyMessage ||
|
|
64
|
-
message.newsletterAdminProfileMessage ||
|
|
65
|
-
message.newsletterAdminProfileMessageV2 ||
|
|
66
|
-
message.newsletterAdminProfileStatusMessage ||
|
|
67
|
-
message.spoilerMessage ||
|
|
68
|
-
message.groupStatusV3Message ||
|
|
69
|
-
message.pollCreationMessageV6
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.normalizeMessageContent = normalizeMessageContent
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Extract the true message content from a message
|
|
77
|
-
* Eg. extracts the inner message from a disappearing message/view once message
|
|
78
|
-
*/
|
|
79
|
-
const extractMessageContent = content => {
|
|
80
|
-
const extractFromTemplateMessage = msg => {
|
|
81
|
-
if (msg.imageMessage) {
|
|
82
|
-
return { imageMessage: msg.imageMessage }
|
|
83
|
-
} else if (msg.documentMessage) {
|
|
84
|
-
return { documentMessage: msg.documentMessage }
|
|
85
|
-
} else if (msg.videoMessage) {
|
|
86
|
-
return { videoMessage: msg.videoMessage }
|
|
87
|
-
} else if (msg.locationMessage) {
|
|
88
|
-
return { locationMessage: msg.locationMessage }
|
|
89
|
-
} else {
|
|
90
|
-
return {
|
|
91
|
-
conversation:
|
|
92
|
-
'contentText' in msg ? msg.contentText : 'hydratedContentText' in msg ? msg.hydratedContentText : ''
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
content = normalizeMessageContent(content)
|
|
97
|
-
if (content?.buttonsMessage) {
|
|
98
|
-
return extractFromTemplateMessage(content.buttonsMessage)
|
|
99
|
-
}
|
|
100
|
-
if (content?.templateMessage?.hydratedFourRowTemplate) {
|
|
101
|
-
return extractFromTemplateMessage(content?.templateMessage?.hydratedFourRowTemplate)
|
|
102
|
-
}
|
|
103
|
-
if (content?.templateMessage?.hydratedTemplate) {
|
|
104
|
-
return extractFromTemplateMessage(content?.templateMessage?.hydratedTemplate)
|
|
105
|
-
}
|
|
106
|
-
if (content?.templateMessage?.fourRowTemplate) {
|
|
107
|
-
return extractFromTemplateMessage(content?.templateMessage?.fourRowTemplate)
|
|
108
|
-
}
|
|
109
|
-
return content
|
|
110
|
-
}
|
|
111
|
-
exports.extractMessageContent = extractMessageContent
|
|
112
|
-
|
|
113
|
-
/** Returns the device predicted by message ID */
|
|
114
|
-
const getDevice = id =>
|
|
115
|
-
/^3A.{18}$/.test(id)
|
|
116
|
-
? 'ios'
|
|
117
|
-
: /^3E.{20}$/.test(id)
|
|
118
|
-
? 'web'
|
|
119
|
-
: /^(.{21}|.{32})$/.test(id)
|
|
120
|
-
? 'android'
|
|
121
|
-
: /^(3F|.{18}$)/.test(id)
|
|
122
|
-
? 'desktop'
|
|
123
|
-
: 'api/baileys'
|
|
124
|
-
exports.getDevice = getDevice
|
|
125
|
-
|
|
126
|
-
/** Upserts a receipt in the message */
|
|
127
|
-
const updateMessageWithReceipt = (msg, receipt) => {
|
|
128
|
-
msg.userReceipt = msg.userReceipt || []
|
|
129
|
-
const recp = msg.userReceipt.find(m => m.userJid === receipt.userJid)
|
|
130
|
-
if (recp) {
|
|
131
|
-
Object.assign(recp, receipt)
|
|
132
|
-
} else {
|
|
133
|
-
msg.userReceipt.push(receipt)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.updateMessageWithReceipt = updateMessageWithReceipt
|
|
137
|
-
|
|
138
|
-
/** Update the message with a new reaction */
|
|
139
|
-
const updateMessageWithReaction = (msg, reaction) => {
|
|
140
|
-
const authorID = (0, generics_1.getKeyAuthor)(reaction.key)
|
|
141
|
-
const reactions = (msg.reactions || []).filter(r => (0, generics_1.getKeyAuthor)(r.key) !== authorID)
|
|
142
|
-
reaction.text = reaction.text || ''
|
|
143
|
-
reactions.push(reaction)
|
|
144
|
-
msg.reactions = reactions
|
|
145
|
-
}
|
|
146
|
-
exports.updateMessageWithReaction = updateMessageWithReaction
|
|
147
|
-
|
|
148
|
-
/** Update the message with a new poll update */
|
|
149
|
-
const updateMessageWithPollUpdate = (msg, update) => {
|
|
150
|
-
const authorID = (0, generics_1.getKeyAuthor)(update.pollUpdateMessageKey)
|
|
151
|
-
const reactions = (msg.pollUpdates || []).filter(
|
|
152
|
-
r => (0, generics_1.getKeyAuthor)(r.pollUpdateMessageKey) !== authorID
|
|
153
|
-
)
|
|
154
|
-
if (update.vote?.selectedOptions?.length) {
|
|
155
|
-
reactions.push(update)
|
|
156
|
-
}
|
|
157
|
-
msg.pollUpdates = reactions
|
|
158
|
-
}
|
|
159
|
-
exports.updateMessageWithPollUpdate = updateMessageWithPollUpdate
|
|
160
|
-
|
|
161
|
-
/** Update the message with a new event response */
|
|
162
|
-
const updateMessageWithEventResponse = (msg, update) => {
|
|
163
|
-
const authorID = (0, generics_1.getKeyAuthor)(update.eventResponseMessageKey)
|
|
164
|
-
const responses = (msg.eventResponses || []).filter(
|
|
165
|
-
r => (0, generics_1.getKeyAuthor)(r.eventResponseMessageKey) !== authorID
|
|
166
|
-
)
|
|
167
|
-
responses.push(update)
|
|
168
|
-
msg.eventResponses = responses
|
|
169
|
-
}
|
|
170
|
-
exports.updateMessageWithEventResponse = updateMessageWithEventResponse
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Aggregates all poll updates in a poll.
|
|
174
|
-
* @param msg the poll creation message
|
|
175
|
-
* @param meId your jid
|
|
176
|
-
* @returns A list of options & their voters
|
|
177
|
-
*/
|
|
178
|
-
function getAggregateVotesInPollMessage({ message, pollUpdates }, meId) {
|
|
179
|
-
const opts =
|
|
180
|
-
message?.pollCreationMessage?.options ||
|
|
181
|
-
message?.pollCreationMessageV2?.options ||
|
|
182
|
-
message?.pollCreationMessageV3?.options ||
|
|
183
|
-
message?.pollCreationMessageV5?.options ||
|
|
184
|
-
message?.pollCreationMessageV6?.options ||
|
|
185
|
-
message?.pollCreationMessageV4?.message?.pollCreationMessage?.options ||
|
|
186
|
-
message?.pollCreationMessageV4?.message?.pollCreationMessageV3?.options ||
|
|
187
|
-
[]
|
|
188
|
-
const voteHashMap = opts.reduce((acc, opt) => {
|
|
189
|
-
const hash = (0, crypto_2.sha256)(Buffer.from(opt.optionName || '')).toString()
|
|
190
|
-
acc[hash] = {
|
|
191
|
-
name: opt.optionName || '',
|
|
192
|
-
voters: []
|
|
193
|
-
}
|
|
194
|
-
return acc
|
|
195
|
-
}, {})
|
|
196
|
-
for (const update of pollUpdates || []) {
|
|
197
|
-
const { vote } = update
|
|
198
|
-
if (!vote) {
|
|
199
|
-
continue
|
|
200
|
-
}
|
|
201
|
-
for (const option of vote.selectedOptions || []) {
|
|
202
|
-
const hash = option.toString()
|
|
203
|
-
let data = voteHashMap[hash]
|
|
204
|
-
if (!data) {
|
|
205
|
-
voteHashMap[hash] = {
|
|
206
|
-
name: 'Unknown',
|
|
207
|
-
voters: []
|
|
208
|
-
}
|
|
209
|
-
data = voteHashMap[hash]
|
|
210
|
-
}
|
|
211
|
-
voteHashMap[hash].voters.push((0, generics_1.getKeyAuthor)(update.pollUpdateMessageKey, meId))
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return Object.values(voteHashMap)
|
|
215
|
-
}
|
|
216
|
-
exports.getAggregateVotesInPollMessage = getAggregateVotesInPollMessage
|
|
217
|
-
|
|
218
|
-
/** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
|
|
219
|
-
const aggregateMessageKeysNotFromMe = keys => {
|
|
220
|
-
const keyMap = {}
|
|
221
|
-
for (const { remoteJid, id, participant, fromMe, sts } of keys) {
|
|
222
|
-
if (!fromMe) {
|
|
223
|
-
const uqKey = `${remoteJid}:${participant || ''}`
|
|
224
|
-
if (!keyMap[uqKey]) {
|
|
225
|
-
keyMap[uqKey] = {
|
|
226
|
-
jid: remoteJid,
|
|
227
|
-
participant: participant,
|
|
228
|
-
messageIds: [],
|
|
229
|
-
// sts is per-message; kept only for single-message interop receipts
|
|
230
|
-
sts: sts
|
|
231
|
-
}
|
|
232
|
-
} else if (keyMap[uqKey].sts !== sts) {
|
|
233
|
-
// Multiple messages with different sts — can't aggregate a single sts
|
|
234
|
-
keyMap[uqKey].sts = undefined
|
|
235
|
-
}
|
|
236
|
-
keyMap[uqKey].messageIds.push(id)
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return Object.values(keyMap)
|
|
240
|
-
}
|
|
241
|
-
exports.aggregateMessageKeysNotFromMe = aggregateMessageKeysNotFromMe
|
|
242
|
-
|
|
243
|
-
/** Check if a WebMessageInfo has a scheduled reveal time (ConditionalRevealMessage) */
|
|
244
|
-
const isScheduledMessage = msg => !!msg?.scheduledMessageMetadata?.scheduledTime
|
|
245
|
-
exports.isScheduledMessage = isScheduledMessage
|
|
246
|
-
|
|
247
|
-
/** Get scheduled reveal time of a message as a Date, or null */
|
|
248
|
-
const getScheduledMessageTime = msg => {
|
|
249
|
-
const t = msg?.scheduledMessageMetadata?.scheduledTime
|
|
250
|
-
if (!t) return null
|
|
251
|
-
return new Date(Number(t) * 1000)
|
|
252
|
-
}
|
|
253
|
-
exports.getScheduledMessageTime = getScheduledMessageTime
|
|
254
|
-
|
|
255
|
-
/** Extract PaymentInfo from a WebMessageInfo (the payment status field, not the message content) */
|
|
256
|
-
const getMessagePaymentInfo = msg => msg?.paymentInfo || msg?.quotedPaymentInfo || null
|
|
257
|
-
exports.getMessagePaymentInfo = getMessagePaymentInfo
|
|
258
|
-
|
|
259
|
-
/** Get all comment metadata from a WebMessageInfo */
|
|
260
|
-
const getMessageCommentMetadata = msg => msg?.commentMetadata || null
|
|
261
|
-
exports.getMessageCommentMetadata = getMessageCommentMetadata
|
|
262
|
-
|
|
263
|
-
/** Get all message add-ons (reactions, poll updates, pins) from a WebMessageInfo */
|
|
264
|
-
const getMessageAddOns = msg => msg?.messageAddOns || []
|
|
265
|
-
exports.getMessageAddOns = getMessageAddOns
|
|
266
|
-
|
|
267
|
-
/** Get the quiz correct answer from a poll creation message, if it's a quiz */
|
|
268
|
-
const getPollCorrectAnswer = pollMsg => {
|
|
269
|
-
const poll =
|
|
270
|
-
pollMsg?.pollCreationMessage ||
|
|
271
|
-
pollMsg?.pollCreationMessageV2 ||
|
|
272
|
-
pollMsg?.pollCreationMessageV3 ||
|
|
273
|
-
pollMsg?.pollCreationMessageV5 ||
|
|
274
|
-
pollMsg?.pollCreationMessageV6
|
|
275
|
-
if (!poll) return null
|
|
276
|
-
const isQuiz = poll.pollType === proto.Message.PollType?.QUIZ || poll.pollType === 1
|
|
277
|
-
return isQuiz ? poll.correctAnswer?.optionName || null : null
|
|
278
|
-
}
|
|
279
|
-
exports.getPollCorrectAnswer = getPollCorrectAnswer
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Aggregates all event responses in an event message.
|
|
283
|
-
* @param msg the event creation message
|
|
284
|
-
* @param meLid your lid
|
|
285
|
-
* @returns A list of response types & their responders
|
|
286
|
-
*/
|
|
287
|
-
function getAggregateResponsesInEventMessage({ eventResponses }, meLid) {
|
|
288
|
-
const responseTypes = ['GOING', 'NOT_GOING', 'MAYBE']
|
|
289
|
-
const responseMap = {}
|
|
290
|
-
|
|
291
|
-
for (const type of responseTypes) {
|
|
292
|
-
responseMap[type] = {
|
|
293
|
-
response: type,
|
|
294
|
-
responders: []
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
for (const update of eventResponses) {
|
|
298
|
-
const { response } = update.response || {}
|
|
299
|
-
const responseType = proto.Message.EventResponseMessage.EventResponseType[response]
|
|
300
|
-
if (responseType !== 'UNKNOWN' && responseMap[responseType]) {
|
|
301
|
-
responseMap[responseType].responders.push(generics_1.getKeyAuthor(update.eventResponseMessageKey, meLid))
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return Object.values(responseMap)
|
|
306
|
-
}
|
|
307
|
-
exports.getAggregateResponsesInEventMessage = getAggregateResponsesInEventMessage
|
|
308
|
-
|
|
309
|
-
const REUPLOAD_REQUIRED_STATUS = [410, 404]
|
|
310
|
-
|
|
311
|
-
/** Downloads the given message. Throws an error if it's not a media message */
|
|
312
|
-
const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
313
|
-
const result = await downloadMsg().catch(async error => {
|
|
314
|
-
if (ctx && typeof error?.status === 'number' && REUPLOAD_REQUIRED_STATUS.includes(error.status)) {
|
|
315
|
-
ctx.logger.info({ key: message.key }, 'sending reupload media request...')
|
|
316
|
-
message = await ctx.reuploadRequest(message)
|
|
317
|
-
const result = await downloadMsg()
|
|
318
|
-
return result
|
|
319
|
-
}
|
|
320
|
-
throw error
|
|
321
|
-
})
|
|
322
|
-
return result
|
|
323
|
-
async function downloadMsg() {
|
|
324
|
-
const mContent = extractMessageContent(message.message)
|
|
325
|
-
if (!mContent) {
|
|
326
|
-
throw new boom_1.Boom('No message present', { statusCode: 400, data: message })
|
|
327
|
-
}
|
|
328
|
-
const contentType = getContentType(mContent)
|
|
329
|
-
let mediaType = contentType?.replace('Message', '')
|
|
330
|
-
const media = mContent[contentType]
|
|
331
|
-
if (!media || typeof media !== 'object' || (!('url' in media) && !('thumbnailDirectPath' in media))) {
|
|
332
|
-
throw new boom_1.Boom(`"${contentType}" message is not a media message`)
|
|
333
|
-
}
|
|
334
|
-
let download
|
|
335
|
-
if ('thumbnailDirectPath' in media && !('url' in media)) {
|
|
336
|
-
download = {
|
|
337
|
-
directPath: media.thumbnailDirectPath,
|
|
338
|
-
mediaKey: media.mediaKey
|
|
339
|
-
}
|
|
340
|
-
mediaType = 'thumbnail-link'
|
|
341
|
-
} else {
|
|
342
|
-
download = media
|
|
343
|
-
}
|
|
344
|
-
const stream = await (0, messages_media_1.downloadContentFromMessage)(download, mediaType, options)
|
|
345
|
-
if (type === 'buffer') {
|
|
346
|
-
const bufferArray = []
|
|
347
|
-
for await (const chunk of stream) {
|
|
348
|
-
bufferArray.push(chunk)
|
|
349
|
-
}
|
|
350
|
-
return Buffer.concat(bufferArray)
|
|
351
|
-
}
|
|
352
|
-
return stream
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
exports.downloadMediaMessage = downloadMediaMessage
|
|
356
|
-
|
|
357
|
-
/** Checks whether the given message is a media message; if it is returns the inner content */
|
|
358
|
-
const assertMediaContent = content => {
|
|
359
|
-
content = extractMessageContent(content)
|
|
360
|
-
const mediaContent =
|
|
361
|
-
content?.documentMessage ||
|
|
362
|
-
content?.imageMessage ||
|
|
363
|
-
content?.videoMessage ||
|
|
364
|
-
content?.audioMessage ||
|
|
365
|
-
content?.stickerMessage
|
|
366
|
-
if (!mediaContent) {
|
|
367
|
-
throw new boom_1.Boom('given message is not a media message', { statusCode: 400, data: content })
|
|
368
|
-
}
|
|
369
|
-
return mediaContent
|
|
370
|
-
}
|
|
371
|
-
exports.assertMediaContent = assertMediaContent
|
|
372
|
-
|
|
373
|
-
/** Normalizes a bare user id to @s.whatsapp.net. Does not convert LID↔PN; use lidMapping / PN in key.remoteJidAlt when needed. */
|
|
374
|
-
const toJid = id => {
|
|
375
|
-
if (!id) return ''
|
|
376
|
-
if (id.includes('@')) return id
|
|
377
|
-
return `${id}@s.whatsapp.net`
|
|
378
|
-
}
|
|
379
|
-
exports.toJid = toJid
|
|
380
|
-
|
|
381
|
-
/** Returns the peer LID JID when the key is LID-primary (decode sets remoteJid/participant to @lid when WA sends LID). */
|
|
382
|
-
const getSenderLid = message => {
|
|
383
|
-
const k = message.key
|
|
384
|
-
if (!k) {
|
|
385
|
-
return { jid: '', lid: '' }
|
|
386
|
-
}
|
|
387
|
-
const jid = k.participant || k.remoteJid || ''
|
|
388
|
-
if (jid.endsWith('@lid') || jid.endsWith('@hosted.lid')) {
|
|
389
|
-
return { jid, lid: jid }
|
|
390
|
-
}
|
|
391
|
-
if (k.lid && typeof k.lid === 'string') {
|
|
392
|
-
const lid = k.lid.includes('@') ? k.lid : (0, WABinary_1.jidEncode)(k.lid, 'lid')
|
|
393
|
-
return { jid, lid }
|
|
394
|
-
}
|
|
395
|
-
if (k.participantLid && (0, WABinary_1.isLidUser)(k.participantLid)) {
|
|
396
|
-
return { jid, lid: k.participantLid }
|
|
397
|
-
}
|
|
398
|
-
return { jid, lid: '' }
|
|
399
|
-
}
|
|
400
|
-
exports.getSenderLid = getSenderLid
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const rb = require('whatsapp-rust-bridge-baron')
|
|
4
|
-
const { proto } = require('../../WAProto')
|
|
5
|
-
|
|
6
|
-
const BOT_MESSAGE_INFO = 'Bot Message'
|
|
7
|
-
const KEY_LENGTH = 32
|
|
8
|
-
|
|
9
|
-
const unpadRandomMax16 = value => {
|
|
10
|
-
const bytes = new Uint8Array(value)
|
|
11
|
-
if (!bytes.length) {
|
|
12
|
-
throw new Error('unpadPkcs7 given empty bytes')
|
|
13
|
-
}
|
|
14
|
-
const padLength = bytes[bytes.length - 1]
|
|
15
|
-
if (padLength > bytes.length) {
|
|
16
|
-
throw new Error(`unpad given ${bytes.length} bytes, but pad is ${padLength}`)
|
|
17
|
-
}
|
|
18
|
-
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.length - padLength)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const toBuffer = value => {
|
|
22
|
-
if (Buffer.isBuffer(value)) return value
|
|
23
|
-
if (value instanceof Uint8Array) return Buffer.from(value.buffer, value.byteOffset, value.byteLength)
|
|
24
|
-
return Buffer.from(value)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Strips device suffix from LID JIDs: "user:device@lid" → "user@lid".
|
|
28
|
-
// jidEncode includes ":0" even for device=0 (user/non-AD form), so normalize both meId and meLid.
|
|
29
|
-
const normalizeLidJid = jid => {
|
|
30
|
-
if (!jid || !jid.endsWith('@lid') || !jid.includes(':')) return jid
|
|
31
|
-
return `${jid.split(':')[0]}@lid`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Ordered msgId candidates per the Rust BotMessageContext:
|
|
35
|
-
// botEditTargetId when editing, stanzaId for the normal full response, metaTargetId as fallback.
|
|
36
|
-
const selectMsgIdCandidates = messageKey => {
|
|
37
|
-
const seen = new Set()
|
|
38
|
-
const result = []
|
|
39
|
-
for (const id of [messageKey?.botEditTargetId, messageKey?.stanzaId, messageKey?.metaTargetId]) {
|
|
40
|
-
const s = id ? String(id) : ''
|
|
41
|
-
if (s && !seen.has(s)) {
|
|
42
|
-
seen.add(s)
|
|
43
|
-
result.push(s)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return result
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Ordered target_sender_user_jid candidates per Rust spec (non-AD user JID = no device suffix).
|
|
50
|
-
// jidEncode produces "user:0@lid" for device=0 LID JIDs, so normalize both meId and meLid.
|
|
51
|
-
const selectTargetJidCandidates = messageKey => {
|
|
52
|
-
const seen = new Set()
|
|
53
|
-
const result = []
|
|
54
|
-
for (const jid of [normalizeLidJid(messageKey?.meId), normalizeLidJid(messageKey?.meLid)]) {
|
|
55
|
-
const s = jid ? String(jid) : ''
|
|
56
|
-
if (s && !seen.has(s)) {
|
|
57
|
-
seen.add(s)
|
|
58
|
-
result.push(s)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return result
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const decodeDecryptedMsmsgMessage = decrypted => {
|
|
65
|
-
const buf = toBuffer(decrypted)
|
|
66
|
-
try {
|
|
67
|
-
const unpadded = Buffer.from(unpadRandomMax16(buf))
|
|
68
|
-
const decoded = proto.Message.decode(unpadded)
|
|
69
|
-
const hasContent = Object.keys(decoded).some(k => k !== 'messageContextInfo' && decoded[k] != null)
|
|
70
|
-
if (hasContent) return decoded
|
|
71
|
-
} catch {}
|
|
72
|
-
return proto.Message.decode(buf)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Decrypts <enc type="msmsg"> bot messages.
|
|
77
|
-
*
|
|
78
|
-
* Two-pass HKDF — algorithm from bot_message.rs (BotMessageContext):
|
|
79
|
-
* k1 = HKDF(messageSecret, salt=∅, info="Bot Message", 32)
|
|
80
|
-
* k2 = HKDF(k1, salt=∅, info=msgID||target_sender_jid||bot_jid, 32)
|
|
81
|
-
* AAD = msgID || 0x00 || bot_user_jid
|
|
82
|
-
* plain = AES-256-GCM.Decrypt(k2, encIv, encPayload, AAD)
|
|
83
|
-
*
|
|
84
|
-
* k1 is shared across all candidates and derived once.
|
|
85
|
-
* AAD always uses bot_user_jid, never target_sender_jid.
|
|
86
|
-
*/
|
|
87
|
-
const decryptMsmsgBotMessage = async (messageSecret, messageKey, msMsg) => {
|
|
88
|
-
if (!messageSecret || (messageSecret instanceof Uint8Array && !messageSecret.byteLength)) {
|
|
89
|
-
throw new Error('Missing required messageSecret for msmsg decryption')
|
|
90
|
-
}
|
|
91
|
-
if (!messageKey?.participant) throw new Error('Missing required participant for msmsg decryption')
|
|
92
|
-
if (!messageKey?.meId) throw new Error('Missing required meId for msmsg decryption')
|
|
93
|
-
if (!msMsg?.encIv) throw new Error('Missing required encIv for msmsg decryption')
|
|
94
|
-
if (!msMsg?.encPayload) throw new Error('Missing required encPayload for msmsg decryption')
|
|
95
|
-
|
|
96
|
-
const msgIdCandidates = selectMsgIdCandidates(messageKey)
|
|
97
|
-
if (!msgIdCandidates.length) throw new Error('Missing required target message id for msmsg decryption')
|
|
98
|
-
|
|
99
|
-
const targetJidCandidates = selectTargetJidCandidates(messageKey)
|
|
100
|
-
if (!targetJidCandidates.length) throw new Error('Missing required target JID for msmsg decryption')
|
|
101
|
-
|
|
102
|
-
const botJidBuf = Buffer.from(String(messageKey.participant))
|
|
103
|
-
const payload = toBuffer(msMsg.encPayload)
|
|
104
|
-
const iv = toBuffer(msMsg.encIv)
|
|
105
|
-
|
|
106
|
-
// k1 depends only on messageSecret — derive once and reuse across all candidates
|
|
107
|
-
const baseKey = Buffer.from(rb.hkdf(toBuffer(messageSecret), KEY_LENGTH, { info: BOT_MESSAGE_INFO }))
|
|
108
|
-
|
|
109
|
-
let lastError
|
|
110
|
-
for (const msgId of msgIdCandidates) {
|
|
111
|
-
// msg_id is always passed as ASCII bytes per Rust spec (msg_id.as_bytes())
|
|
112
|
-
const idBuf = Buffer.from(msgId)
|
|
113
|
-
for (const targetJid of targetJidCandidates) {
|
|
114
|
-
const info = Buffer.concat([idBuf, Buffer.from(targetJid), botJidBuf])
|
|
115
|
-
const key = Buffer.from(rb.hkdf(baseKey, KEY_LENGTH, { info }))
|
|
116
|
-
const aad = Buffer.concat([idBuf, Buffer.from([0x00]), botJidBuf])
|
|
117
|
-
try {
|
|
118
|
-
return Buffer.from(rb.aesDecryptGCM(payload, key, iv, aad))
|
|
119
|
-
} catch (e) {
|
|
120
|
-
lastError = e
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const err = new Error('msmsg decryption failed: all key derivation candidates exhausted')
|
|
126
|
-
err.cause = lastError
|
|
127
|
-
throw err
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
module.exports = {
|
|
131
|
-
decodeDecryptedMsmsgMessage,
|
|
132
|
-
decryptMsmsgBotMessage
|
|
133
|
-
}
|
package/src/WABinary/encode.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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 __setModuleDefault =
|
|
23
|
-
(this && this.__setModuleDefault) ||
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v })
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v
|
|
30
|
-
})
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
(function () {
|
|
34
|
-
var ownKeys = function (o) {
|
|
35
|
-
ownKeys =
|
|
36
|
-
Object.getOwnPropertyNames ||
|
|
37
|
-
function (o) {
|
|
38
|
-
var ar = []
|
|
39
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k
|
|
40
|
-
return ar
|
|
41
|
-
}
|
|
42
|
-
return ownKeys(o)
|
|
43
|
-
}
|
|
44
|
-
return function (mod) {
|
|
45
|
-
if (mod && mod.__esModule) return mod
|
|
46
|
-
var result = {}
|
|
47
|
-
if (mod != null)
|
|
48
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== 'default') __createBinding(result, mod, k[i])
|
|
49
|
-
__setModuleDefault(result, mod)
|
|
50
|
-
return result
|
|
51
|
-
}
|
|
52
|
-
})()
|
|
53
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
54
|
-
exports.encodeBinaryNode = void 0
|
|
55
|
-
const rb = require('whatsapp-rust-bridge-baron')
|
|
56
|
-
const encodeBinaryNode = node => Buffer.from(rb.encodeNode(node))
|
|
57
|
-
exports.encodeBinaryNode = encodeBinaryNode
|
|
58
|
-
// Legacy JS implementation kept below but no longer called
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.USyncBusinessProtocol = void 0
|
|
4
|
-
const WABinary_1 = require('../../WABinary')
|
|
5
|
-
class USyncBusinessProtocol {
|
|
6
|
-
constructor(profileVersion = '2') {
|
|
7
|
-
this.name = 'business'
|
|
8
|
-
this.profileVersion = profileVersion
|
|
9
|
-
}
|
|
10
|
-
getQueryElement() {
|
|
11
|
-
return {
|
|
12
|
-
tag: 'business',
|
|
13
|
-
attrs: {},
|
|
14
|
-
content: [
|
|
15
|
-
{ tag: 'verified_name', attrs: {} },
|
|
16
|
-
{ tag: 'profile', attrs: { v: this.profileVersion } }
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
getUserElement(user) {
|
|
21
|
-
const children = []
|
|
22
|
-
if (user.verifiedNameSerial) {
|
|
23
|
-
children.push({ tag: 'verified_name', attrs: { serial: user.verifiedNameSerial } })
|
|
24
|
-
}
|
|
25
|
-
if (user.businessProfileTag) {
|
|
26
|
-
children.push({ tag: 'profile', attrs: { tag: user.businessProfileTag } })
|
|
27
|
-
}
|
|
28
|
-
return children.length > 0 ? { tag: 'business', attrs: {}, content: children } : null
|
|
29
|
-
}
|
|
30
|
-
parser(node) {
|
|
31
|
-
if (node.tag !== 'business') return null
|
|
32
|
-
;(0, WABinary_1.assertNodeErrorFree)(node)
|
|
33
|
-
const verifiedNameNode = (0, WABinary_1.getBinaryNodeChild)(node, 'verified_name')
|
|
34
|
-
const profileNode = (0, WABinary_1.getBinaryNodeChild)(node, 'profile')
|
|
35
|
-
|
|
36
|
-
// Business hours: profile may contain a business_hours child with business_hours_config children
|
|
37
|
-
let businessHours = undefined
|
|
38
|
-
if (profileNode) {
|
|
39
|
-
const businessHoursNode = (0, WABinary_1.getBinaryNodeChild)(profileNode, 'business_hours')
|
|
40
|
-
if (businessHoursNode) {
|
|
41
|
-
const configs = (0, WABinary_1.getBinaryNodeChildren)(businessHoursNode, 'business_hours_config')
|
|
42
|
-
businessHours = {
|
|
43
|
-
timezone: businessHoursNode.attrs?.timezone ?? null,
|
|
44
|
-
config: configs.map(({ attrs }) => ({
|
|
45
|
-
dayOfWeek: attrs?.day_of_week ?? null,
|
|
46
|
-
openTime: attrs?.open_time ?? null,
|
|
47
|
-
closeTime: attrs?.close_time ?? null,
|
|
48
|
-
mode: attrs?.mode ?? null
|
|
49
|
-
}))
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Business address from profile child node
|
|
55
|
-
const addressNode = profileNode ? (0, WABinary_1.getBinaryNodeChild)(profileNode, 'address') : null
|
|
56
|
-
const businessAddress = addressNode?.content
|
|
57
|
-
? Buffer.isBuffer(addressNode.content)
|
|
58
|
-
? addressNode.content.toString()
|
|
59
|
-
: String(addressNode.content)
|
|
60
|
-
: (profileNode?.attrs?.address ?? null)
|
|
61
|
-
|
|
62
|
-
// Catalog status from profile attrs
|
|
63
|
-
const catalogStatus = profileNode
|
|
64
|
-
? {
|
|
65
|
-
exists: profileNode.attrs?.catalog_exists === 'true' || profileNode.attrs?.catalog_exists === true,
|
|
66
|
-
sendAll: profileNode.attrs?.catalog_send_all === 'true' || profileNode.attrs?.catalog_send_all === true
|
|
67
|
-
}
|
|
68
|
-
: null
|
|
69
|
-
|
|
70
|
-
// Cart flags from profile attrs
|
|
71
|
-
const cartEnabled =
|
|
72
|
-
profileNode?.attrs?.cart_enabled !== undefined
|
|
73
|
-
? profileNode.attrs.cart_enabled === 'true' || profileNode.attrs.cart_enabled === true
|
|
74
|
-
: null
|
|
75
|
-
const webCartEnabled =
|
|
76
|
-
profileNode?.attrs?.web_cart_enabled !== undefined
|
|
77
|
-
? profileNode.attrs.web_cart_enabled === 'true' || profileNode.attrs.web_cart_enabled === true
|
|
78
|
-
: null
|
|
79
|
-
const webCartOnOff = profileNode?.attrs?.web_cart_on_off ?? null
|
|
80
|
-
|
|
81
|
-
// Commerce experience from profile attrs
|
|
82
|
-
const commerceExperience = profileNode?.attrs?.commerce_experience ?? null
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
verifiedName: verifiedNameNode?.content ?? null,
|
|
86
|
-
verifiedLevel: verifiedNameNode?.attrs?.verified_level ?? null,
|
|
87
|
-
verifiedNameLevel: verifiedNameNode?.attrs?.verified_level ?? null,
|
|
88
|
-
profileTag: profileNode?.attrs?.tag ?? null,
|
|
89
|
-
pnJid: node.attrs?.pn_jid ?? null,
|
|
90
|
-
businessHours: businessHours ?? null,
|
|
91
|
-
businessAddress,
|
|
92
|
-
catalogStatus,
|
|
93
|
-
cartEnabled,
|
|
94
|
-
webCartEnabled,
|
|
95
|
-
webCartOnOff,
|
|
96
|
-
commerceExperience
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.USyncBusinessProtocol = USyncBusinessProtocol
|