@fhynella/baileys 2.0.5 → 2.1.7

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.
Files changed (204) hide show
  1. package/lib/Defaults/connection.js +51 -0
  2. package/lib/Defaults/constants.js +62 -0
  3. package/lib/Defaults/history.js +17 -0
  4. package/lib/Defaults/index.js +36 -142
  5. package/lib/Defaults/media.js +48 -0
  6. package/lib/Defaults/prefix.js +18 -0
  7. package/lib/Signal/Group/group-session-builder.js +10 -42
  8. package/lib/Signal/Group/group_cipher.js +9 -6
  9. package/lib/Signal/Group/index.js +39 -53
  10. package/lib/Signal/Group/keyhelper.js +8 -41
  11. package/lib/Signal/Group/sender-chain-key.js +4 -4
  12. package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
  13. package/lib/Signal/Group/sender-key-message.js +12 -8
  14. package/lib/Signal/Group/sender-key-record.js +7 -7
  15. package/lib/Signal/Group/sender-key-state.js +4 -4
  16. package/lib/Signal/Group/sender-message-key.js +2 -2
  17. package/lib/Signal/libsignal.js +45 -69
  18. package/lib/Signal/lid-mapping.js +15 -11
  19. package/lib/Socket/Client/types.js +2 -2
  20. package/lib/Socket/Client/websocket.js +16 -14
  21. package/lib/Socket/business.js +41 -32
  22. package/lib/Socket/chats.js +123 -98
  23. package/lib/Socket/community.js +50 -40
  24. package/lib/Socket/groups.js +59 -47
  25. package/lib/Socket/index.js +4 -4
  26. package/lib/Socket/messages-recv.js +219 -172
  27. package/lib/Socket/messages-send.js +187 -211
  28. package/lib/Socket/newsletter.js +61 -47
  29. package/lib/Socket/socket.js +133 -90
  30. package/lib/Socket/usync.js +6 -6
  31. package/lib/Store/index.js +27 -11
  32. package/lib/Store/make-cache-manager-store.js +14 -15
  33. package/lib/Store/make-in-memory-store.js +28 -24
  34. package/lib/Types/LabelAssociation.js +2 -2
  35. package/lib/Types/Message.js +6 -6
  36. package/lib/Types/MexUpdates.js +5 -5
  37. package/lib/Types/State.js +4 -4
  38. package/lib/Types/index.js +28 -12
  39. package/lib/Utils/auth-utils.js +28 -26
  40. package/lib/Utils/baileys-event-stream.js +68 -69
  41. package/lib/Utils/business.js +63 -53
  42. package/lib/Utils/chat-utils.js +81 -71
  43. package/lib/Utils/crypto.js +25 -45
  44. package/lib/Utils/decode-wa-message.js +319 -311
  45. package/lib/Utils/event-buffer.js +21 -22
  46. package/lib/Utils/generics.js +52 -75
  47. package/lib/Utils/history.js +21 -21
  48. package/lib/Utils/index.js +27 -13
  49. package/lib/Utils/link-preview.js +7 -30
  50. package/lib/Utils/logger.js +5 -5
  51. package/lib/Utils/lt-hash.js +3 -3
  52. package/lib/Utils/message-retry-manager.js +4 -4
  53. package/lib/Utils/messages-media.js +104 -109
  54. package/lib/Utils/messages.js +203 -171
  55. package/lib/Utils/noise-handler.js +28 -19
  56. package/lib/Utils/process-message.js +111 -96
  57. package/lib/Utils/signal.js +36 -25
  58. package/lib/Utils/use-multi-file-auth-state.js +18 -22
  59. package/lib/Utils/validate-connection.js +52 -45
  60. package/lib/WABinary/decode.js +6 -32
  61. package/lib/WABinary/encode.js +3 -29
  62. package/lib/WABinary/generic-utils.js +4 -4
  63. package/lib/WABinary/index.js +27 -11
  64. package/lib/WAM/encode.js +16 -8
  65. package/lib/WAM/index.js +27 -11
  66. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
  67. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  68. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
  69. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  70. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
  71. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  72. package/lib/WAUSync/Protocols/index.js +27 -11
  73. package/lib/WAUSync/USyncQuery.js +17 -10
  74. package/lib/WAUSync/index.js +27 -11
  75. package/lib/index.js +60 -31
  76. package/package.json +15 -6
  77. package/WAProto/AICommon/AICommon.d.ts +0 -11702
  78. package/WAProto/Adv/Adv.d.ts +0 -643
  79. package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
  80. package/WAProto/Cert/Cert.d.ts +0 -613
  81. package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
  82. package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
  83. package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
  84. package/WAProto/E2E/E2E.d.ts +0 -41724
  85. package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
  86. package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
  87. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
  88. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
  89. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
  90. package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
  91. package/WAProto/Protocol/Protocol.d.ts +0 -270
  92. package/WAProto/Reporting/Reporting.d.ts +0 -371
  93. package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
  94. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
  95. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
  96. package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
  97. package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
  98. package/WAProto/UserPassword/UserPassword.d.ts +0 -363
  99. package/WAProto/VnameCert/VnameCert.d.ts +0 -821
  100. package/WAProto/Wa6/Wa6.d.ts +0 -2128
  101. package/WAProto/Web/Web.d.ts +0 -46383
  102. package/WAProto/index.d.ts +0 -55
  103. package/lib/Defaults/index.d.ts +0 -77
  104. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  105. package/lib/Signal/Group/group-session-builder.d.ts +0 -17
  106. package/lib/Signal/Group/group_cipher.d.ts +0 -19
  107. package/lib/Signal/Group/index.d.ts +0 -11
  108. package/lib/Signal/Group/keyhelper.d.ts +0 -16
  109. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  110. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  111. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  112. package/lib/Signal/Group/sender-key-name.d.ts +0 -19
  113. package/lib/Signal/Group/sender-key-record.d.ts +0 -32
  114. package/lib/Signal/Group/sender-key-state.d.ts +0 -44
  115. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  116. package/lib/Signal/libsignal.d.ts +0 -8
  117. package/lib/Signal/lid-mapping.d.ts +0 -28
  118. package/lib/Socket/.nomedia +0 -0
  119. package/lib/Socket/Client/index.d.ts +0 -2
  120. package/lib/Socket/Client/types.d.ts +0 -16
  121. package/lib/Socket/Client/websocket.d.ts +0 -13
  122. package/lib/Socket/business.d.ts +0 -187
  123. package/lib/Socket/chats.d.ts +0 -97
  124. package/lib/Socket/community.d.ts +0 -129
  125. package/lib/Socket/groups.d.ts +0 -129
  126. package/lib/Socket/index.d.ts +0 -197
  127. package/lib/Socket/messages-recv.d.ts +0 -180
  128. package/lib/Socket/messages-send.d.ts +0 -169
  129. package/lib/Socket/messages-send.d.ts.bak +0 -165
  130. package/lib/Socket/messages-send.js.bak +0 -1812
  131. package/lib/Socket/newsletter.d.ts +0 -145
  132. package/lib/Socket/socket.d.ts +0 -45
  133. package/lib/Socket/usync.d.ts +0 -37
  134. package/lib/Store/index.d.ts +0 -4
  135. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  136. package/lib/Store/make-in-memory-store.d.ts +0 -123
  137. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  138. package/lib/Store/object-repository.d.ts +0 -10
  139. package/lib/Types/Auth.d.ts +0 -121
  140. package/lib/Types/Bussiness.d.ts +0 -28
  141. package/lib/Types/Call.d.ts +0 -14
  142. package/lib/Types/Chat.d.ts +0 -143
  143. package/lib/Types/Contact.d.ts +0 -23
  144. package/lib/Types/Events.d.ts +0 -226
  145. package/lib/Types/GroupMetadata.d.ts +0 -66
  146. package/lib/Types/Label.d.ts +0 -48
  147. package/lib/Types/LabelAssociation.d.ts +0 -35
  148. package/lib/Types/Message.d.ts +0 -484
  149. package/lib/Types/MexUpdates.d.ts +0 -9
  150. package/lib/Types/Newsletter.d.ts +0 -109
  151. package/lib/Types/Product.d.ts +0 -92
  152. package/lib/Types/Signal.d.ts +0 -98
  153. package/lib/Types/Socket.d.ts +0 -141
  154. package/lib/Types/State.d.ts +0 -41
  155. package/lib/Types/USync.d.ts +0 -26
  156. package/lib/Types/index.d.ts +0 -80
  157. package/lib/Utils/auth-utils.d.ts +0 -21
  158. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  159. package/lib/Utils/business.d.ts +0 -29
  160. package/lib/Utils/chat-utils.d.ts +0 -82
  161. package/lib/Utils/crypto.d.ts +0 -56
  162. package/lib/Utils/decode-wa-message.d.ts +0 -53
  163. package/lib/Utils/event-buffer.d.ts +0 -39
  164. package/lib/Utils/generics.d.ts +0 -117
  165. package/lib/Utils/history.d.ts +0 -23
  166. package/lib/Utils/index.d.ts +0 -20
  167. package/lib/Utils/link-preview.d.ts +0 -23
  168. package/lib/Utils/logger.d.ts +0 -13
  169. package/lib/Utils/lt-hash.d.ts +0 -14
  170. package/lib/Utils/make-mutex.d.ts +0 -9
  171. package/lib/Utils/message-retry-manager.d.ts +0 -88
  172. package/lib/Utils/messages-media.d.ts +0 -135
  173. package/lib/Utils/messages.d.ts +0 -105
  174. package/lib/Utils/noise-handler.d.ts +0 -20
  175. package/lib/Utils/process-message.d.ts +0 -49
  176. package/lib/Utils/signal.d.ts +0 -42
  177. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  178. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  179. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  180. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  181. package/lib/Utils/use-single-file-auth-state.js +0 -80
  182. package/lib/Utils/validate-connection.d.ts +0 -13
  183. package/lib/WABinary/constants.d.ts +0 -30
  184. package/lib/WABinary/decode.d.ts +0 -9
  185. package/lib/WABinary/encode.d.ts +0 -3
  186. package/lib/WABinary/generic-utils.d.ts +0 -28
  187. package/lib/WABinary/index.d.ts +0 -5
  188. package/lib/WABinary/jid-utils.d.ts +0 -58
  189. package/lib/WABinary/types.d.ts +0 -22
  190. package/lib/WAM/BinaryInfo.d.ts +0 -16
  191. package/lib/WAM/constants.d.ts +0 -47
  192. package/lib/WAM/encode.d.ts +0 -3
  193. package/lib/WAM/index.d.ts +0 -3
  194. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  195. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  196. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  197. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  198. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
  199. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  200. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  201. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  202. package/lib/WAUSync/USyncUser.d.ts +0 -12
  203. package/lib/WAUSync/index.d.ts +0 -3
  204. package/lib/index.d.ts +0 -13
@@ -1,39 +1,83 @@
1
1
  "use strict"
2
2
 
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod }
5
- }
6
-
7
3
  Object.defineProperty(exports, "__esModule", { value: true })
8
4
 
9
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"))
10
- const boom_1 = require("@hapi/boom")
11
- const crypto_1 = require("crypto")
12
- const WAProto_1 = require("../../WAProto")
13
- const Defaults_1 = require("../Defaults")
14
- const Utils_1 = require("../Utils")
15
- const Types_1 = require("../Types")
16
- const WABinary_1 = require("../WABinary")
17
- const WAUSync_1 = require("../WAUSync")
18
- const newsletter_1 = require("./newsletter")
19
- const link_preview_1 = require("../Utils/link-preview")
20
- const make_keyed_mutex_1 = require("../Utils/make-mutex")
5
+ const { default: NodeCache } = require("@cacheable/node-cache")
6
+ const { Boom } = require("@hapi/boom")
7
+ const { randomBytes } = require("crypto")
8
+ const { proto } = require("../../WAProto")
9
+ const {
10
+ DEFAULT_CACHE_TTLS,
11
+ WA_DEFAULT_EPHEMERAL
12
+ } = require("../Defaults/constants")
13
+ const {
14
+ delay,
15
+ assertMediaContent,
16
+ bindWaitForEvent,
17
+ decryptMediaRetryData,
18
+ encodeNewsletterMessage,
19
+ encodeSignedDeviceIdentity,
20
+ encodeWAMessage,
21
+ encryptMediaRetryRequest,
22
+ extractDeviceJids,
23
+ generateMessageID,
24
+ generateParticipantHashV2,
25
+ generateWAMessage,
26
+ generateWAMessageFromContent,
27
+ getStatusCodeForMediaRetry,
28
+ getUrlFromDirectPath,
29
+ getWAUploadToServer,
30
+ MessageRetryManager,
31
+ normalizeMessageContent,
32
+ parseAndInjectE2ESessions,
33
+ unixTimestampSeconds,
34
+ prepareAlbumMessageContent,
35
+ aggregateMessageKeysNotFromMe
36
+ } = require("../Utils")
37
+ const {
38
+ QueryIds,
39
+ XWAPaths,
40
+ WAMessageAddressingMode
41
+ } = require("../Types")
42
+ const {
43
+ areJidsSameUser,
44
+ getBinaryNodeChild,
45
+ getBinaryNodeChildren,
46
+ getBinaryFilteredBizBot,
47
+ getBinaryFilteredButtons,
48
+ isJidNewsletter,
49
+ isJidGroup,
50
+ isLidUser,
51
+ isJidUser,
52
+ jidDecode,
53
+ jidEncode,
54
+ jidNormalizedUser,
55
+ STORIES_JID,
56
+ S_WHATSAPP_NET
57
+ } = require("../WABinary")
58
+ const {
59
+ USyncUser,
60
+ USyncQuery
61
+ } = require("../WAUSync")
62
+ const { makeNewsletterSocket } = require("./newsletter")
63
+ const { getUrlInfo } = require("../Utils/link-preview")
64
+ const { makeKeyedMutex } = require("../Utils/make-mutex")
21
65
 
22
66
  const makeMessagesSocket = (config) => {
23
67
  const { logger, maxMsgRetryCount, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, enableRecentMessageCache } = config
24
- const suki = newsletter_1.makeNewsletterSocket(config)
68
+ const suki = makeNewsletterSocket(config)
25
69
  const { ev, authState, processingMutex, signalRepository, upsertMessage, createCallLink, query, fetchPrivacySettings, sendNode, groupQuery, groupMetadata, groupToggleEphemeral, newsletterWMexQuery, executeUSyncQuery } = suki
26
70
 
27
- const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
28
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,
71
+ const userDevicesCache = config.userDevicesCache || new NodeCache({
72
+ stdTTL: DEFAULT_CACHE_TTLS.USER_DEVICES,
29
73
  useClones: false
30
74
  })
31
75
 
32
76
  // Initialize message retry manager if enabled
33
- const messageRetryManager = enableRecentMessageCache ? new Utils_1.MessageRetryManager(logger, maxMsgRetryCount) : null
77
+ const messageRetryManager = enableRecentMessageCache ? new MessageRetryManager(logger, maxMsgRetryCount) : null
34
78
 
35
79
  // Prevent race conditions in Signal session encryption by user
36
- const encryptionMutex = make_keyed_mutex_1.makeKeyedMutex()
80
+ const encryptionMutex = makeKeyedMutex()
37
81
 
38
82
  let mediaConn
39
83
 
@@ -48,15 +92,15 @@ const makeMessagesSocket = (config) => {
48
92
  attrs: {
49
93
  type: 'set',
50
94
  xmlns: 'w:m',
51
- to: WABinary_1.S_WHATSAPP_NET,
95
+ to: S_WHATSAPP_NET,
52
96
  },
53
97
  content: [{ tag: 'media_conn', attrs: {} }]
54
98
  })
55
99
 
56
- const mediaConnNode = WABinary_1.getBinaryNodeChild(result, 'media_conn')
100
+ const mediaConnNode = getBinaryNodeChild(result, 'media_conn')
57
101
 
58
102
  const node = {
59
- hosts: WABinary_1.getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
103
+ hosts: getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
60
104
  hostname: attrs.hostname,
61
105
  maxContentLengthBytes: +attrs.maxContentLengthBytes,
62
106
  })),
@@ -89,10 +133,10 @@ const makeMessagesSocket = (config) => {
89
133
  const isReadReceipt = type === 'read' || type === 'read-self'
90
134
 
91
135
  if (isReadReceipt) {
92
- node.attrs.t = Utils_1.unixTimestampSeconds().toString()
136
+ node.attrs.t = unixTimestampSeconds().toString()
93
137
  }
94
138
 
95
- if (type === 'sender' && WABinary_1.isJidUser(jid)) {
139
+ if (type === 'sender' && isJidUser(jid)) {
96
140
  node.attrs.recipient = jid
97
141
  node.attrs.to = participant
98
142
  }
@@ -105,7 +149,7 @@ const makeMessagesSocket = (config) => {
105
149
  }
106
150
 
107
151
  if (type) {
108
- node.attrs.type = WABinary_1.isJidNewsletter(jid) ? 'read-self' : type
152
+ node.attrs.type = isJidNewsletter(jid) ? 'read-self' : type
109
153
  }
110
154
 
111
155
  const remainingMessageIds = messageIds.slice(1)
@@ -130,7 +174,7 @@ const makeMessagesSocket = (config) => {
130
174
 
131
175
  /** Correctly bulk send receipts to multiple chats, participants */
132
176
  const sendReceipts = async (keys, type) => {
133
- const recps = Utils_1.aggregateMessageKeysNotFromMe(keys)
177
+ const recps = aggregateMessageKeysNotFromMe(keys)
134
178
 
135
179
  for (const { jid, participant, messageIds } of recps) {
136
180
  await sendReceipt(jid, participant, messageIds, type)
@@ -157,8 +201,8 @@ const makeMessagesSocket = (config) => {
157
201
 
158
202
  // Collect all LID users
159
203
  for (const jid of jids) {
160
- if (WABinary_1.isLidUser(jid)) {
161
- const user = WABinary_1.jidDecode(jid)?.user
204
+ if (isLidUser(jid)) {
205
+ const user = jidDecode(jid)?.user
162
206
  if (user)
163
207
  lidUsers.add(user)
164
208
  }
@@ -166,8 +210,8 @@ const makeMessagesSocket = (config) => {
166
210
 
167
211
  // Filter out PN versions when LID exists
168
212
  for (const jid of jids) {
169
- if (WABinary_1.isJidUser(jid)) {
170
- const user = WABinary_1.jidDecode(jid)?.user
213
+ if (isJidUser(jid)) {
214
+ const user = jidDecode(jid)?.user
171
215
  if (user && lidUsers.has(user)) {
172
216
  logger.debug({ jid }, 'Skipping PN - LID version exists')
173
217
  continue
@@ -180,9 +224,9 @@ const makeMessagesSocket = (config) => {
180
224
 
181
225
  /** Fetch image for groups, user, and newsletter **/
182
226
  const profilePictureUrl = async (jid) => {
183
- if (WABinary_1.isJidNewsletter(jid)) {
227
+ if (isJidNewsletter(jid)) {
184
228
 
185
- let node = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
229
+ let node = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
186
230
  input: {
187
231
  key: jid,
188
232
  type: 'JID',
@@ -193,11 +237,11 @@ const makeMessagesSocket = (config) => {
193
237
  fetch_creation_time: true
194
238
  })
195
239
 
196
- let result = WABinary_1.getBinaryNodeChild(node, 'result')?.content?.toString()
240
+ let result = getBinaryNodeChild(node, 'result')?.content?.toString()
197
241
 
198
- let metadata = JSON.parse(result).data[Types_1.XWAPaths.NEWSLETTER]
242
+ let metadata = JSON.parse(result).data[XWAPaths.NEWSLETTER]
199
243
 
200
- return Utils_1.getUrlFromDirectPath(metadata.thread_metadata.picture?.direct_path || '')
244
+ return getUrlFromDirectPath(metadata.thread_metadata.picture?.direct_path || '')
201
245
 
202
246
  }
203
247
 
@@ -205,8 +249,8 @@ const makeMessagesSocket = (config) => {
205
249
  const result = await query({
206
250
  tag: 'iq',
207
251
  attrs: {
208
- target: WABinary_1.jidNormalizedUser(jid),
209
- to: WABinary_1.S_WHATSAPP_NET,
252
+ target: jidNormalizedUser(jid),
253
+ to: S_WHATSAPP_NET,
210
254
  type: 'get',
211
255
  xmlns: 'w:profile:picture'
212
256
  },
@@ -219,7 +263,7 @@ const makeMessagesSocket = (config) => {
219
263
  }]
220
264
  })
221
265
 
222
- const child = WABinary_1.getBinaryNodeChild(result, 'picture')
266
+ const child = getBinaryNodeChild(result, 'picture')
223
267
 
224
268
  return child?.attrs?.url || null
225
269
  }
@@ -238,7 +282,7 @@ const makeMessagesSocket = (config) => {
238
282
  jids = deduplicateLidPnJids(Array.from(new Set(jids)))
239
283
  const jidsWithUser = jids
240
284
  .map(jid => {
241
- const decoded = WABinary_1.jidDecode(jid)
285
+ const decoded = jidDecode(jid)
242
286
  const user = decoded?.user
243
287
  const device = decoded?.device
244
288
  const isExplicitDevice = typeof device === 'number' && device >= 0
@@ -252,7 +296,7 @@ const makeMessagesSocket = (config) => {
252
296
  return null
253
297
  }
254
298
 
255
- jid = WABinary_1.jidNormalizedUser(jid)
299
+ jid = jidNormalizedUser(jid)
256
300
  return { jid, user }
257
301
  })
258
302
  .filter(jid => jid !== null)
@@ -270,10 +314,10 @@ const makeMessagesSocket = (config) => {
270
314
  (userDevicesCache.mget ? undefined : (await userDevicesCache.get(user)))
271
315
 
272
316
  if (devices) {
273
- const isLidJid = WABinary_1.isLidUser(jid)
317
+ const isLidJid = isLidUser(jid)
274
318
  const devicesWithWire = devices.map(d => ({
275
319
  ...d,
276
- wireJid: isLidJid ? WABinary_1.jidEncode(d.user, 'lid', d.device) : WABinary_1.jidEncode(d.user, 's.whatsapp.net', d.device)
320
+ wireJid: isLidJid ? jidEncode(d.user, 'lid', d.device) : jidEncode(d.user, 's.whatsapp.net', d.device)
277
321
  }))
278
322
 
279
323
  deviceResults.push(...devicesWithWire)
@@ -294,22 +338,22 @@ const makeMessagesSocket = (config) => {
294
338
 
295
339
  const requestedLidUsers = new Set()
296
340
  for (const jid of toFetch) {
297
- if (WABinary_1.isLidUser(jid)) {
298
- const user = WABinary_1.jidDecode(jid)?.user
341
+ if (isLidUser(jid)) {
342
+ const user = jidDecode(jid)?.user
299
343
  if (user)
300
344
  requestedLidUsers.add(user)
301
345
  }
302
346
  }
303
347
 
304
- const query = new WAUSync_1.USyncQuery().withContext('message').withDeviceProtocol()
348
+ const query = new USyncQuery().withContext('message').withDeviceProtocol()
305
349
  for (const jid of toFetch) {
306
- query.withUser(new WAUSync_1.USyncUser().withId(jid))
350
+ query.withUser(new USyncUser().withId(jid))
307
351
  }
308
352
 
309
353
  const result = await executeUSyncQuery(query)
310
354
 
311
355
  if (result) {
312
- const extracted = Utils_1.extractDeviceJids(result?.list, authState.creds.me.id, ignoreZeroDevices)
356
+ const extracted = extractDeviceJids(result?.list, authState.creds.me.id, ignoreZeroDevices)
313
357
  const deviceMap = {}
314
358
 
315
359
  for (const item of extracted) {
@@ -324,8 +368,8 @@ const makeMessagesSocket = (config) => {
324
368
  // Process all devices for this user
325
369
  for (const item of userDevices) {
326
370
  const finalWireJid = isLidUser
327
- ? WABinary_1.jidEncode(user, 'lid', item.device)
328
- : WABinary_1.jidEncode(item.user, 's.whatsapp.net', item.device)
371
+ ? jidEncode(user, 'lid', item.device)
372
+ : jidEncode(item.user, 's.whatsapp.net', item.device)
329
373
  deviceResults.push({
330
374
  ...item,
331
375
  wireJid: finalWireJid
@@ -394,7 +438,7 @@ const makeMessagesSocket = (config) => {
394
438
  // Group JIDs by user for bulk migration
395
439
  const userGroups = new Map()
396
440
  for (const jid of jids) {
397
- const user = WABinary_1.jidNormalizedUser(jid)
441
+ const user = jidNormalizedUser(jid)
398
442
  if (!userGroups.has(user)) {
399
443
  userGroups.set(user, [])
400
444
  }
@@ -403,7 +447,7 @@ const makeMessagesSocket = (config) => {
403
447
 
404
448
  // Helper to check LID mapping for a user
405
449
  const checkUserLidMapping = async (user, userJids) => {
406
- if (!userJids.some(jid => WABinary_1.isJidUser(jid))) {
450
+ if (!userJids.some(jid => isJidUser(jid))) {
407
451
  return { shouldMigrate: false, lidForPN: undefined }
408
452
  }
409
453
 
@@ -462,8 +506,8 @@ const makeMessagesSocket = (config) => {
462
506
 
463
507
  // Determine correct JID to fetch (LID if mapping exists, otherwise original)
464
508
  if (jid.includes('@s.whatsapp.net') && shouldMigrateUser && lidForPN) {
465
- const decoded = WABinary_1.jidDecode(jid)
466
- const lidDeviceJid = decoded.device !== undefined ? `${WABinary_1.jidDecode(lidForPN).user}:${decoded.device}@lid` : lidForPN
509
+ const decoded = jidDecode(jid)
510
+ const lidDeviceJid = decoded.device !== undefined ? `${jidDecode(lidForPN).user}:${decoded.device}@lid` : lidForPN
467
511
 
468
512
  jidsRequiringFetch.push(lidDeviceJid)
469
513
  logger.debug({ pnJid: jid, lidJid: lidDeviceJid }, 'Adding LID JID to fetch list (conversion)')
@@ -487,13 +531,13 @@ const makeMessagesSocket = (config) => {
487
531
  const pnUsersBeingFetched = new Set()
488
532
 
489
533
  for (const jid of jidsRequiringFetch) {
490
- const user = WABinary_1.jidDecode(jid)?.user
534
+ const user = jidDecode(jid)?.user
491
535
 
492
536
  if (user) {
493
- if (WABinary_1.isLidUser(jid)) {
537
+ if (isLidUser(jid)) {
494
538
  lidUsersBeingFetched.add(user)
495
539
  }
496
- else if (WABinary_1.isJidUser(jid)) {
540
+ else if (isJidUser(jid)) {
497
541
  pnUsersBeingFetched.add(user)
498
542
  }
499
543
  }
@@ -514,7 +558,7 @@ const makeMessagesSocket = (config) => {
514
558
  attrs: {
515
559
  xmlns: 'encrypt',
516
560
  type: 'get',
517
- to: WABinary_1.S_WHATSAPP_NET
561
+ to: S_WHATSAPP_NET
518
562
  },
519
563
  content: [
520
564
  {
@@ -528,7 +572,7 @@ const makeMessagesSocket = (config) => {
528
572
  ]
529
573
  })
530
574
 
531
- await Utils_1.parseAndInjectE2ESessions(result, signalRepository)
575
+ await parseAndInjectE2ESessions(result, signalRepository)
532
576
  didFetchNewSession = true
533
577
  }
534
578
  return didFetchNewSession
@@ -538,17 +582,17 @@ const makeMessagesSocket = (config) => {
538
582
  const sendPeerDataOperationMessage = async (pdoMessage) => {
539
583
  //TODO: for later, abstract the logic to send a Peer Message instead of just PDO - useful for App State Key Resync with phone
540
584
  if (!authState.creds.me?.id) {
541
- throw new boom_1.Boom('Not authenticated')
585
+ throw new Boom('Not authenticated')
542
586
  }
543
587
 
544
588
  const protocolMessage = {
545
589
  protocolMessage: {
546
590
  peerDataOperationRequestMessage: pdoMessage,
547
- type: WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
591
+ type: proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
548
592
  }
549
593
  }
550
594
 
551
- const meJid = WABinary_1.jidNormalizedUser(authState.creds.me.id)
595
+ const meJid = jidNormalizedUser(authState.creds.me.id)
552
596
 
553
597
  const msgId = await relayMessage(meJid, protocolMessage, {
554
598
  additionalAttributes: {
@@ -561,73 +605,6 @@ const makeMessagesSocket = (config) => {
561
605
  return msgId
562
606
  }
563
607
 
564
- const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
565
- const map = {};
566
- const mutex = (key, fn) => {
567
- map[key] ??= { task: Promise.resolve() };
568
- map[key].task = (async prev => {
569
- try { await prev } catch {}
570
- return fn();
571
- })(map[key].task);
572
- return map[key].task;
573
- };
574
-
575
- const bokep = buf => Buffer.concat([Buffer.from(buf), Buffer.alloc(8, 1)]);
576
-
577
- return (async () => {
578
- if (!recipientJids.length)
579
- return { nodes: [], shouldIncludeDeviceIdentity: false };
580
-
581
- const patched = await (patchMessageBeforeSending?.(message, recipientJids) ?? message);
582
-
583
- let yntkts = Utils_1.encodeWAMessage?.bind(Utils_1);
584
-
585
- const ywdh = Array.isArray(patched)
586
- ? patched
587
- : recipientJids.map(jid => ({ recipientJid: jid, message: patched }));
588
-
589
- const { id: meId, lid: meLid } = authState.creds.me;
590
- const omak = meLid ? WABinary_1.jidDecode(meLid)?.user : null;
591
- let shouldIncludeDeviceIdentity = false;
592
-
593
- const nodes = await Promise.all(
594
- ywdh.map(async ({ recipientJid: jid, message: msg }) => {
595
- const { user: targetUser } = WABinary_1.jidDecode(jid);
596
- const { user: ownPnUser } = WABinary_1.jidDecode(meId);
597
- const isOwnUser = targetUser === ownPnUser || targetUser === omak;
598
- const y = jid === meId || jid === meLid;
599
-
600
- if (dsmMessage && isOwnUser && !y) msg = dsmMessage;
601
-
602
- let bytes = bokep(yntkts ? yntkts(msg) : Utils_1.encodeWAMessage(msg));
603
-
604
- return mutex(jid, async () => {
605
- const { type, ciphertext } = await signalRepository.encryptMessage({
606
- jid,
607
- data: bytes
608
- });
609
-
610
- if (type === "pkmsg") shouldIncludeDeviceIdentity = true;
611
-
612
- return {
613
- tag: "to",
614
- attrs: { jid },
615
- content: [
616
- {
617
- tag: "enc",
618
- attrs: { v: "2", type, ...extraAttrs },
619
- content: ciphertext
620
- }
621
- ]
622
- };
623
- });
624
- })
625
- );
626
-
627
- return { nodes: nodes.filter(Boolean), shouldIncludeDeviceIdentity };
628
- })();
629
- };
630
-
631
608
  const createParticipantNodes = async (jids, message, extraAttrs, dsmMessage) => {
632
609
  let patched = await patchMessageBeforeSending(message, jids)
633
610
 
@@ -639,7 +616,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
639
616
 
640
617
  const meId = authState.creds.me.id
641
618
  const meLid = authState.creds.me?.lid
642
- const meLidUser = meLid ? WABinary_1.jidDecode(meLid)?.user : null
619
+ const meLidUser = meLid ? jidDecode(meLid)?.user : null
643
620
  const devicesByUser = new Map()
644
621
 
645
622
  for (const patchedMessageWithJid of patched) {
@@ -648,7 +625,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
648
625
  continue
649
626
 
650
627
  // Extract user from JID for grouping
651
- const decoded = WABinary_1.jidDecode(wireJid)
628
+ const decoded = jidDecode(wireJid)
652
629
  const user = decoded?.user
653
630
 
654
631
  if (!user)
@@ -668,7 +645,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
668
645
 
669
646
  // Helper to get encryption JID with LID migration
670
647
  const getEncryptionJid = async (wireJid) => {
671
- if (!WABinary_1.isJidUser(wireJid))
648
+ if (!isJidUser(wireJid))
672
649
  return wireJid
673
650
 
674
651
  try {
@@ -678,16 +655,16 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
678
655
  return wireJid
679
656
 
680
657
  // Preserve device ID from original wire JID
681
- const wireDecoded = WABinary_1.jidDecode(wireJid)
658
+ const wireDecoded = jidDecode(wireJid)
682
659
  const deviceId = wireDecoded?.device || 0
683
- const lidDecoded = WABinary_1.jidDecode(lidForPN)
684
- const lidWithDevice = WABinary_1.jidEncode(lidDecoded?.user, 'lid', deviceId)
660
+ const lidDecoded = jidDecode(lidForPN)
661
+ const lidWithDevice = jidEncode(lidDecoded?.user, 'lid', deviceId)
685
662
 
686
663
  // Migrate session to LID for unified encryption layer
687
664
  try {
688
665
  const migrationResult = await signalRepository.migrateSession([wireJid], lidWithDevice)
689
- const recipientUser = WABinary_1.jidNormalizedUser(wireJid)
690
- const ownPnUser = WABinary_1.jidNormalizedUser(meId)
666
+ const recipientUser = jidNormalizedUser(wireJid)
667
+ const ownPnUser = jidNormalizedUser(meId)
691
668
  const isOwnDevice = recipientUser === ownPnUser
692
669
  logger.info({ wireJid, lidWithDevice, isOwnDevice }, 'Migrated to LID encryption')
693
670
 
@@ -720,8 +697,8 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
720
697
  let messageToEncrypt = patchedMessage
721
698
 
722
699
  if (dsmMessage) {
723
- const { user: targetUser } = WABinary_1.jidDecode(wireJid)
724
- const { user: ownPnUser } = WABinary_1.jidDecode(meId)
700
+ const { user: targetUser } = jidDecode(wireJid)
701
+ const { user: ownPnUser } = jidDecode(meId)
725
702
  const ownLidUser = meLidUser
726
703
 
727
704
  // Check if this is our device (same user, different device)
@@ -736,7 +713,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
736
713
  }
737
714
  }
738
715
 
739
- const bytes = Utils_1.encodeWAMessage(messageToEncrypt)
716
+ const bytes = encodeWAMessage(messageToEncrypt)
740
717
 
741
718
  // Get encryption JID with LID migration
742
719
  const encryptionJid = await getEncryptionJid(wireJid)
@@ -785,7 +762,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
785
762
  let didPushAdditional = false
786
763
  let shouldIncludeDeviceIdentity = false
787
764
 
788
- const { user, server } = WABinary_1.jidDecode(jid)
765
+ const { user, server } = jidDecode(jid)
789
766
 
790
767
  const statusJid = 'status@broadcast'
791
768
  const isGroup = server === 'g.us'
@@ -808,7 +785,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
808
785
  logger.debug({ to: jid, ownId }, 'Using PN identity for @s.whatsapp.net conversation')
809
786
  }
810
787
 
811
- msgId = msgId || Utils_1.generateMessageID(authState.creds.me.id)
788
+ msgId = msgId || generateMessageID(authState.creds.me.id)
812
789
  useUserDevicesCache = useUserDevicesCache !== false
813
790
  useCachedGroupMetadata = useCachedGroupMetadata !== false && !isStatus
814
791
 
@@ -829,7 +806,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
829
806
 
830
807
  const regexGroupOld = /^(\d{1,15})-(\d+)@g\.us$/
831
808
 
832
- const messages = Utils_1.normalizeMessageContent(message)
809
+ const messages = normalizeMessageContent(message)
833
810
 
834
811
  const buttonType = getButtonType(messages)
835
812
  const pollMessage = messages.pollCreationMessage || messages.pollCreationMessageV2 || messages.pollCreationMessageV3
@@ -843,7 +820,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
843
820
  additionalAttributes = { ...additionalAttributes, 'device_fanout': 'false' }
844
821
  }
845
822
 
846
- const { user, device } = WABinary_1.jidDecode(participant.jid)
823
+ const { user, device } = jidDecode(participant.jid)
847
824
 
848
825
  devices.push({
849
826
  user,
@@ -902,7 +879,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
902
879
  }
903
880
 
904
881
  if (!isStatus) {
905
- const groupAddressingMode = groupData?.addressingMode || (isLid ? Types_1.WAMessageAddressingMode.LID : Types_1.WAMessageAddressingMode.PN)
882
+ const groupAddressingMode = groupData?.addressingMode || (isLid ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN)
906
883
  additionalAttributes = {
907
884
  ...additionalAttributes,
908
885
  addressing_mode: groupAddressingMode
@@ -913,8 +890,8 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
913
890
  devices.push(...additionalDevices)
914
891
  }
915
892
 
916
- const patched = await patchMessageBeforeSending(message, devices.map(d => WABinary_1.jidEncode(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)))
917
- const bytes = Utils_1.encodeWAMessage(patched)
893
+ const patched = await patchMessageBeforeSending(message, devices.map(d => jidEncode(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)))
894
+ const bytes = encodeWAMessage(patched)
918
895
 
919
896
  // This should match the group's addressing mode and conversation context
920
897
  const groupAddressingMode = groupData?.addressingMode || (isLid ? 'lid' : 'pn')
@@ -977,13 +954,13 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
977
954
  }
978
955
 
979
956
  // Message delete
980
- if (message.protocolMessage?.type === WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE) {
957
+ if (message.protocolMessage?.type === proto.Message.ProtocolMessage.Type.REVOKE) {
981
958
  msgId = message.protocolMessage.key?.id
982
959
  message = {}
983
960
  }
984
961
 
985
962
  const patched = await patchMessageBeforeSending(message, [])
986
- const bytes = Utils_1.encodeNewsletterMessage(patched)
963
+ const bytes = encodeNewsletterMessage(patched)
987
964
 
988
965
  binaryNodeContent.push({
989
966
  tag: 'plaintext',
@@ -993,24 +970,24 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
993
970
  }
994
971
 
995
972
  else {
996
- const { user: ownUser } = WABinary_1.jidDecode(ownId)
973
+ const { user: ownUser } = jidDecode(ownId)
997
974
 
998
975
  if (!participant) {
999
976
  const targetUserServer = isLid ? 'lid' : 's.whatsapp.net'
1000
977
  devices.push({
1001
978
  user,
1002
979
  device: 0,
1003
- wireJid: WABinary_1.jidEncode(user, targetUserServer, 0)
980
+ wireJid: jidEncode(user, targetUserServer, 0)
1004
981
  })
1005
982
 
1006
983
  // Own user matches conversation addressing mode
1007
984
  if (user !== ownUser) {
1008
985
  const ownUserServer = isLid ? 'lid' : 's.whatsapp.net';
1009
- const ownUserForAddressing = isLid && meLid ? WABinary_1.jidDecode(meLid).user : WABinary_1.jidDecode(meId).user
986
+ const ownUserForAddressing = isLid && meLid ? jidDecode(meLid).user : jidDecode(meId).user
1010
987
  devices.push({
1011
988
  user: ownUserForAddressing,
1012
989
  device: 0,
1013
- wireJid: WABinary_1.jidEncode(ownUserForAddressing, ownUserServer, 0)
990
+ wireJid: jidEncode(ownUserForAddressing, ownUserServer, 0)
1014
991
  })
1015
992
  }
1016
993
 
@@ -1020,15 +997,15 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1020
997
 
1021
998
  // Use conversation-appropriate sender identity
1022
999
  const senderIdentity = isLid && meLid
1023
- ? WABinary_1.jidEncode(WABinary_1.jidDecode(meLid)?.user, 'lid', undefined)
1024
- : WABinary_1.jidEncode(WABinary_1.jidDecode(meId)?.user, 's.whatsapp.net', undefined)
1000
+ ? jidEncode(jidDecode(meLid)?.user, 'lid', undefined)
1001
+ : jidEncode(jidDecode(meId)?.user, 's.whatsapp.net', undefined)
1025
1002
 
1026
1003
  // Enumerate devices for sender and target with consistent addressing
1027
1004
  const sessionDevices = await getUSyncDevices([senderIdentity, jid], false, false)
1028
1005
  devices.push(...sessionDevices)
1029
1006
  logger.debug({
1030
1007
  deviceCount: devices.length,
1031
- devices: devices.map(d => `${d.user}:${d.device}@${WABinary_1.jidDecode(d.wireJid)?.server}`)
1008
+ devices: devices.map(d => `${d.user}:${d.device}@${jidDecode(d.wireJid)?.server}`)
1032
1009
  }, 'Device enumeration complete with unified addressing')
1033
1010
  }
1034
1011
  }
@@ -1037,8 +1014,8 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1037
1014
  const meJids = []
1038
1015
  const otherJids = []
1039
1016
 
1040
- const { user: mePnUser } = WABinary_1.jidDecode(meId)
1041
- const { user: meLidUser } = meLid ? WABinary_1.jidDecode(meLid) : { user: null }
1017
+ const { user: mePnUser } = jidDecode(meId)
1018
+ const { user: meLidUser } = meLid ? jidDecode(meLid) : { user: null }
1042
1019
 
1043
1020
  for (const { user, wireJid } of devices) {
1044
1021
  const isExactSenderDevice = wireJid === meId || (meLid && wireJid === meLid)
@@ -1075,7 +1052,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1075
1052
  participants.push(...otherNodes)
1076
1053
 
1077
1054
  if (meJids.length > 0 || otherJids.length > 0) {
1078
- extraAttrs['phash'] = Utils_1.generateParticipantHashV2([...meJids, ...otherJids])
1055
+ extraAttrs['phash'] = generateParticipantHashV2([...meJids, ...otherJids])
1079
1056
  }
1080
1057
 
1081
1058
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2
@@ -1114,12 +1091,12 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1114
1091
  // ensure the message is only sent to that person
1115
1092
  // if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
1116
1093
  if (participant) {
1117
- if (WABinary_1.isJidGroup(destinationJid)) {
1094
+ if (isJidGroup(destinationJid)) {
1118
1095
  stanza.attrs.to = destinationJid
1119
1096
  stanza.attrs.participant = participant.jid
1120
1097
  }
1121
1098
 
1122
- else if (WABinary_1.areJidsSameUser(participant.jid, meId)) {
1099
+ else if (areJidsSameUser(participant.jid, meId)) {
1123
1100
  stanza.attrs.to = participant.jid
1124
1101
  stanza.attrs.recipient = destinationJid
1125
1102
  }
@@ -1137,7 +1114,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1137
1114
  stanza.content.push({
1138
1115
  tag: 'device-identity',
1139
1116
  attrs: {},
1140
- content: Utils_1.encodeSignedDeviceIdentity(authState.creds.account, true)
1117
+ content: encodeSignedDeviceIdentity(authState.creds.account, true)
1141
1118
  })
1142
1119
 
1143
1120
  logger.debug({ jid }, 'adding device identity')
@@ -1166,7 +1143,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1166
1143
 
1167
1144
  if (!isNewsletter && buttonType) {
1168
1145
  const buttonsNode = getButtonArgs(messages)
1169
- const filteredButtons = WABinary_1.getBinaryFilteredButtons(additionalNodes ? additionalNodes : [])
1146
+ const filteredButtons = getBinaryFilteredButtons(additionalNodes ? additionalNodes : [])
1170
1147
 
1171
1148
  if (filteredButtons) {
1172
1149
  stanza.content.push(...additionalNodes)
@@ -1186,7 +1163,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1186
1163
  }
1187
1164
  }
1188
1165
 
1189
- const filteredBizBot = WABinary_1.getBinaryFilteredBizBot(additionalNodes ? additionalNodes : [])
1166
+ const filteredBizBot = getBinaryFilteredBizBot(additionalNodes ? additionalNodes : [])
1190
1167
 
1191
1168
  if (filteredBizBot) {
1192
1169
  stanza.content.push(...additionalNodes)
@@ -1216,7 +1193,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1216
1193
  }
1217
1194
 
1218
1195
  const getTypeMessage = (msg) => {
1219
- const message = Utils_1.normalizeMessageContent(msg)
1196
+ const message = normalizeMessageContent(msg)
1220
1197
  if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3) {
1221
1198
  return 'poll'
1222
1199
  }
@@ -1335,7 +1312,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1335
1312
  attrs: {
1336
1313
  actual_actors: '2',
1337
1314
  host_storage: '2',
1338
- privacy_mode_ts: Utils_1.unixTimestampSeconds().toString()
1315
+ privacy_mode_ts: unixTimestampSeconds().toString()
1339
1316
  },
1340
1317
  content: [{
1341
1318
  tag: 'interactive',
@@ -1365,7 +1342,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1365
1342
  attrs: {
1366
1343
  actual_actors: '2',
1367
1344
  host_storage: '2',
1368
- privacy_mode_ts: Utils_1.unixTimestampSeconds().toString()
1345
+ privacy_mode_ts: unixTimestampSeconds().toString()
1369
1346
  },
1370
1347
  content: [{
1371
1348
  tag: 'interactive',
@@ -1394,7 +1371,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1394
1371
  attrs: {
1395
1372
  actual_actors: '2',
1396
1373
  host_storage: '2',
1397
- privacy_mode_ts: Utils_1.unixTimestampSeconds().toString()
1374
+ privacy_mode_ts: unixTimestampSeconds().toString()
1398
1375
  },
1399
1376
  content: [{
1400
1377
  tag: 'list',
@@ -1416,19 +1393,19 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1416
1393
  attrs: {
1417
1394
  actual_actors: '2',
1418
1395
  host_storage: '2',
1419
- privacy_mode_ts: Utils_1.unixTimestampSeconds().toString()
1396
+ privacy_mode_ts: unixTimestampSeconds().toString()
1420
1397
  }
1421
1398
  }
1422
1399
  }
1423
1400
  }
1424
1401
 
1425
1402
  const getPrivacyTokens = async (jids) => {
1426
- const t = Utils_1.unixTimestampSeconds().toString()
1403
+ const t = unixTimestampSeconds().toString()
1427
1404
 
1428
1405
  const result = await query({
1429
1406
  tag: 'iq',
1430
1407
  attrs: {
1431
- to: WABinary_1.S_WHATSAPP_NET,
1408
+ to: S_WHATSAPP_NET,
1432
1409
  type: 'set',
1433
1410
  xmlns: 'privacy'
1434
1411
  },
@@ -1439,7 +1416,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1439
1416
  content: jids.map(jid => ({
1440
1417
  tag: 'token',
1441
1418
  attrs: {
1442
- jid: WABinary_1.jidNormalizedUser(jid),
1419
+ jid: jidNormalizedUser(jid),
1443
1420
  t,
1444
1421
  type: 'trusted_contact'
1445
1422
  }
@@ -1452,7 +1429,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1452
1429
  }
1453
1430
 
1454
1431
  const getEphemeralGroup = (jid) => {
1455
- if (!WABinary_1.isJidGroup(jid)) throw new TypeError("Jid should originate from a group!")
1432
+ if (!isJidGroup(jid)) throw new TypeError("Jid should originate from a group!")
1456
1433
 
1457
1434
  return groupQuery(jid, 'get', [{
1458
1435
  tag: 'query',
@@ -1460,13 +1437,13 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1460
1437
  request: 'interactive'
1461
1438
  }
1462
1439
  }])
1463
- .then((groups) => WABinary_1.getBinaryNodeChild(groups, 'group'))
1464
- .then((metadata) => WABinary_1.getBinaryNodeChild(metadata, 'ephemeral')?.attrs?.expiration || 0)
1440
+ .then((groups) => getBinaryNodeChild(groups, 'group'))
1441
+ .then((metadata) => getBinaryNodeChild(metadata, 'ephemeral')?.attrs?.expiration || 0)
1465
1442
  }
1466
1443
 
1467
- const waUploadToServer = Utils_1.getWAUploadToServer(config, refreshMediaConn)
1444
+ const waUploadToServer = getWAUploadToServer(config, refreshMediaConn)
1468
1445
 
1469
- const waitForMsgMediaUpdate = Utils_1.bindWaitForEvent(ev, 'messages.media-update')
1446
+ const waitForMsgMediaUpdate = bindWaitForEvent(ev, 'messages.media-update')
1470
1447
 
1471
1448
  return {
1472
1449
  ...suki,
@@ -1484,13 +1461,12 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1484
1461
  fetchPrivacySettings,
1485
1462
  messageRetryManager,
1486
1463
  createParticipantNodes,
1487
- nodescall,
1488
1464
  sendPeerDataOperationMessage,
1489
1465
  updateMediaMessage: async (message) => {
1490
- const content = Utils_1.assertMediaContent(message.message)
1466
+ const content = assertMediaContent(message.message)
1491
1467
  const mediaKey = content.mediaKey
1492
1468
  const meId = authState.creds.me.id
1493
- const node = await Utils_1.encryptMediaRetryRequest(message.key, mediaKey, meId)
1469
+ const node = await encryptMediaRetryRequest(message.key, mediaKey, meId)
1494
1470
  let error = undefined
1495
1471
 
1496
1472
  await Promise.all([
@@ -1504,17 +1480,17 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1504
1480
 
1505
1481
  else {
1506
1482
  try {
1507
- const media = await Utils_1.decryptMediaRetryData(result.media, mediaKey, result.key.id)
1483
+ const media = await decryptMediaRetryData(result.media, mediaKey, result.key.id)
1508
1484
 
1509
- if (media.result !== WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
1510
- const resultStr = WAProto_1.proto.MediaRetryNotification.ResultType[media.result]
1485
+ if (media.result !== proto.MediaRetryNotification.ResultType.SUCCESS) {
1486
+ const resultStr = proto.MediaRetryNotification.ResultType[media.result]
1511
1487
 
1512
- throw new boom_1.Boom(`Media re-upload failed by device (${resultStr})`, { data: media, statusCode: Utils_1.getStatusCodeForMediaRetry(media.result) || 404 })
1488
+ throw new Boom(`Media re-upload failed by device (${resultStr})`, { data: media, statusCode: getStatusCodeForMediaRetry(media.result) || 404 })
1513
1489
  }
1514
1490
 
1515
1491
  content.directPath = media.directPath
1516
1492
 
1517
- content.url = Utils_1.getUrlFromDirectPath(content.directPath)
1493
+ content.url = getUrlFromDirectPath(content.directPath)
1518
1494
 
1519
1495
  logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful')
1520
1496
  }
@@ -1540,24 +1516,24 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1540
1516
  return message
1541
1517
  },
1542
1518
  sendStatusMentions: async (content, jids = []) => {
1543
- const userJid = WABinary_1.jidNormalizedUser(authState.creds.me.id)
1519
+ const userJid = jidNormalizedUser(authState.creds.me.id)
1544
1520
  let allUsers = new Set()
1545
1521
  allUsers.add(userJid)
1546
1522
 
1547
1523
  for (const id of jids) {
1548
- const isGroup = WABinary_1.isJidGroup(id)
1549
- const isPrivate = WABinary_1.isJidUser(id)
1524
+ const isGroup = isJidGroup(id)
1525
+ const isPrivate = isJidUser(id)
1550
1526
 
1551
1527
  if (isGroup) {
1552
1528
  try {
1553
1529
  const metadata = await cachedGroupMetadata(id) || await groupMetadata(id)
1554
- const participants = metadata.participants.map(p => WABinary_1.jidNormalizedUser(p.id))
1530
+ const participants = metadata.participants.map(p => jidNormalizedUser(p.id))
1555
1531
  participants.forEach(jid => allUsers.add(jid))
1556
1532
  } catch (error) {
1557
1533
  logger.error(`Error getting metadata for group ${id}: ${error}`)
1558
1534
  }
1559
1535
  } else if (isPrivate) {
1560
- allUsers.add(WABinary_1.jidNormalizedUser(id))
1536
+ allUsers.add(jidNormalizedUser(id))
1561
1537
  }
1562
1538
  }
1563
1539
 
@@ -1597,10 +1573,10 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1597
1573
  let msg
1598
1574
  let mediaHandle
1599
1575
  try {
1600
- msg = await Utils_1.generateWAMessage(WABinary_1.STORIES_JID, messageContent, {
1576
+ msg = await generateWAMessage(STORIES_JID, messageContent, {
1601
1577
  logger,
1602
1578
  userJid,
1603
- getUrlInfo: text => link_preview_1.getUrlInfo(text, {
1579
+ getUrlInfo: text => getUrlInfo(text, {
1604
1580
  thumbnailWidth: linkPreviewImageThumbnailWidth,
1605
1581
  fetchOpts: { timeout: 3000, ...axiosOptions || {} },
1606
1582
  logger,
@@ -1623,7 +1599,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1623
1599
  throw error
1624
1600
  }
1625
1601
 
1626
- await relayMessage(WABinary_1.STORIES_JID, msg.message, {
1602
+ await relayMessage(STORIES_JID, msg.message, {
1627
1603
  messageId: msg.key.id,
1628
1604
  statusJidList: uniqueUsers,
1629
1605
  additionalNodes: [
@@ -1636,7 +1612,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1636
1612
  attrs: {},
1637
1613
  content: jids.map(jid => ({
1638
1614
  tag: 'to',
1639
- attrs: { jid: WABinary_1.jidNormalizedUser(jid) }
1615
+ attrs: { jid: jidNormalizedUser(jid) }
1640
1616
  }))
1641
1617
  }]
1642
1618
  }]
@@ -1644,8 +1620,8 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1644
1620
 
1645
1621
  for (const id of jids) {
1646
1622
  try {
1647
- const normalizedId = WABinary_1.jidNormalizedUser(id)
1648
- const isPrivate = WABinary_1.isJidUser(normalizedId)
1623
+ const normalizedId = jidNormalizedUser(id)
1624
+ const isPrivate = isJidUser(normalizedId)
1649
1625
  const type = isPrivate ? 'statusMentionMessage' : 'groupStatusMentionMessage'
1650
1626
 
1651
1627
  const protocolMessage = {
@@ -1658,11 +1634,11 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1658
1634
  }
1659
1635
  },
1660
1636
  messageContextInfo: {
1661
- messageSecret: crypto_1.randomBytes(32)
1637
+ messageSecret: randomBytes(32)
1662
1638
  }
1663
1639
  }
1664
1640
 
1665
- const statusMsg = await Utils_1.generateWAMessageFromContent(normalizedId,
1641
+ const statusMsg = await generateWAMessageFromContent(normalizedId,
1666
1642
  protocolMessage,
1667
1643
  {}
1668
1644
  )
@@ -1680,7 +1656,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1680
1656
  }
1681
1657
  )
1682
1658
 
1683
- await Utils_1.delay(2000)
1659
+ await delay(2000)
1684
1660
  } catch (error) {
1685
1661
  logger.error(`Error sending to ${id}: ${error}`)
1686
1662
  }
@@ -1693,7 +1669,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1693
1669
  const additionalAttributes = {}
1694
1670
 
1695
1671
  if (!options.ephemeralExpiration) {
1696
- if (WABinary_1.isJidGroup(jid)) {
1672
+ if (isJidGroup(jid)) {
1697
1673
  const expiration = await getEphemeralGroup(jid)
1698
1674
  options.ephemeralExpiration = expiration
1699
1675
  }
@@ -1702,19 +1678,19 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1702
1678
  if (typeof content === 'object' &&
1703
1679
  'disappearingMessagesInChat' in content &&
1704
1680
  typeof content['disappearingMessagesInChat'] !== 'undefined' &&
1705
- WABinary_1.isJidGroup(jid)) {
1681
+ isJidGroup(jid)) {
1706
1682
 
1707
1683
  const { disappearingMessagesInChat } = content
1708
1684
 
1709
1685
  const value = typeof disappearingMessagesInChat === 'boolean' ?
1710
- (disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
1686
+ (disappearingMessagesInChat ? WA_DEFAULT_EPHEMERAL : 0) :
1711
1687
  disappearingMessagesInChat
1712
1688
 
1713
1689
  await groupToggleEphemeral(jid, value)
1714
1690
  }
1715
1691
 
1716
1692
  else if (typeof content === 'object' && 'album' in content && content.album) {
1717
- const albumMsg = await Utils_1.prepareAlbumMessageContent(jid, content.album, {
1693
+ const albumMsg = await prepareAlbumMessageContent(jid, content.album, {
1718
1694
  suki: {
1719
1695
  relayMessage,
1720
1696
  waUploadToServer
@@ -1724,7 +1700,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1724
1700
  })
1725
1701
 
1726
1702
  for (const media of albumMsg) {
1727
- await Utils_1.delay(options.delay || 500)
1703
+ await delay(options.delay || 500)
1728
1704
  await relayMessage(jid, media.message, { messageId: media.key.id, useCachedGroupMetadata: options.useCachedGroupMetadata, additionalAttributes, statusJidList: options.statusJidList, additionalNodes: options.additionalNodes, AI: options.ai })
1729
1705
  }
1730
1706
 
@@ -1734,10 +1710,10 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1734
1710
  else {
1735
1711
  let mediaHandle
1736
1712
 
1737
- const fullMsg = await Utils_1.generateWAMessage(jid, content, {
1713
+ const fullMsg = await generateWAMessage(jid, content, {
1738
1714
  logger,
1739
1715
  userJid,
1740
- getUrlInfo: text => link_preview_1.getUrlInfo(text, {
1716
+ getUrlInfo: text => getUrlInfo(text, {
1741
1717
  thumbnailWidth: linkPreviewImageThumbnailWidth,
1742
1718
  fetchOpts: {
1743
1719
  timeout: 3000,
@@ -1751,13 +1727,13 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1751
1727
  getProfilePicUrl: profilePictureUrl,
1752
1728
  getCallLink: createCallLink,
1753
1729
  upload: async (encFilePath, opts) => {
1754
- const up = await waUploadToServer(encFilePath, { ...opts, newsletter: WABinary_1.isJidNewsletter(jid) })
1730
+ const up = await waUploadToServer(encFilePath, { ...opts, newsletter: isJidNewsletter(jid) })
1755
1731
  mediaHandle = up.handle
1756
1732
  return up
1757
1733
  },
1758
1734
  mediaCache: config.mediaCache,
1759
1735
  options: config.options,
1760
- messageId: Utils_1.generateMessageID(userJid),
1736
+ messageId: generateMessageID(userJid),
1761
1737
  ...options,
1762
1738
  })
1763
1739
 
@@ -1768,7 +1744,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1768
1744
 
1769
1745
  if (isDelete || isKeep) {
1770
1746
  // if the chat is a group, and I am not the author, then delete the message as an admin
1771
- if (WABinary_1.isJidGroup(content.delete?.remoteJid) && !content.delete?.fromMe || WABinary_1.isJidNewsletter(jid)) {
1747
+ if (isJidGroup(content.delete?.remoteJid) && !content.delete?.fromMe || isJidNewsletter(jid)) {
1772
1748
  additionalAttributes.edit = '8'
1773
1749
  }
1774
1750
 
@@ -1778,7 +1754,7 @@ const nodescall = (recipientJids, message, extraAttrs, dsmMessage) => {
1778
1754
  }
1779
1755
 
1780
1756
  else if (isEdit) {
1781
- additionalAttributes.edit = WABinary_1.isJidNewsletter(jid) ? '3' : '1'
1757
+ additionalAttributes.edit = isJidNewsletter(jid) ? '3' : '1'
1782
1758
  }
1783
1759
 
1784
1760
  else if (isPin) {