amiudmodz 6.2.9 → 6.3.1

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 (311) hide show
  1. package/lib/Foundation/ai-rich.d.ts +123 -0
  2. package/lib/Foundation/ai-rich.d.ts.map +1 -0
  3. package/lib/Foundation/ai-rich.js +542 -0
  4. package/lib/Foundation/ai-rich.js.map +1 -0
  5. package/lib/Foundation/audio-duration.d.ts +3 -0
  6. package/lib/Foundation/audio-duration.d.ts.map +1 -0
  7. package/lib/Foundation/audio-duration.js +514 -0
  8. package/lib/Foundation/audio-duration.js.map +1 -0
  9. package/lib/Foundation/audio-samples.d.ts +3 -0
  10. package/lib/Foundation/audio-samples.d.ts.map +1 -0
  11. package/lib/Foundation/audio-samples.js +294 -0
  12. package/lib/Foundation/audio-samples.js.map +1 -0
  13. package/lib/Foundation/boom.d.ts +17 -0
  14. package/lib/Foundation/boom.d.ts.map +1 -0
  15. package/lib/Foundation/boom.js +37 -0
  16. package/lib/Foundation/boom.js.map +1 -0
  17. package/lib/Foundation/cache.d.ts +25 -0
  18. package/lib/Foundation/cache.d.ts.map +1 -0
  19. package/lib/Foundation/cache.js +112 -0
  20. package/lib/Foundation/cache.js.map +1 -0
  21. package/lib/Foundation/concurrency.d.ts +13 -0
  22. package/lib/Foundation/concurrency.d.ts.map +1 -0
  23. package/lib/Foundation/concurrency.js +62 -0
  24. package/lib/Foundation/concurrency.js.map +1 -0
  25. package/lib/Foundation/curve25519.d.ts +11 -0
  26. package/lib/Foundation/curve25519.d.ts.map +1 -0
  27. package/lib/Foundation/curve25519.js +178 -0
  28. package/lib/Foundation/curve25519.js.map +1 -0
  29. package/lib/Foundation/image-thumb.d.ts +13 -0
  30. package/lib/Foundation/image-thumb.d.ts.map +1 -0
  31. package/lib/Foundation/image-thumb.js +65 -0
  32. package/lib/Foundation/image-thumb.js.map +1 -0
  33. package/lib/Foundation/link-preview.d.ts +29 -0
  34. package/lib/Foundation/link-preview.d.ts.map +1 -0
  35. package/lib/Foundation/link-preview.js +309 -0
  36. package/lib/Foundation/link-preview.js.map +1 -0
  37. package/lib/Foundation/logger.d.ts +31 -0
  38. package/lib/Foundation/logger.d.ts.map +1 -0
  39. package/lib/Foundation/logger.js +54 -0
  40. package/lib/Foundation/logger.js.map +1 -0
  41. package/lib/Foundation/long.d.ts +33 -0
  42. package/lib/Foundation/long.d.ts.map +1 -0
  43. package/lib/Foundation/long.js +135 -0
  44. package/lib/Foundation/long.js.map +1 -0
  45. package/lib/Foundation/protobuf-minimal.d.ts +115 -0
  46. package/lib/Foundation/protobuf-minimal.d.ts.map +1 -0
  47. package/lib/Foundation/protobuf-minimal.js +614 -0
  48. package/lib/Foundation/protobuf-minimal.js.map +1 -0
  49. package/lib/Foundation/qrcode-terminal.d.ts +2 -0
  50. package/lib/Foundation/qrcode-terminal.d.ts.map +1 -0
  51. package/lib/Foundation/qrcode-terminal.js +405 -0
  52. package/lib/Foundation/qrcode-terminal.js.map +1 -0
  53. package/lib/Foundation/sql-database.d.ts +15 -0
  54. package/lib/Foundation/sql-database.d.ts.map +1 -0
  55. package/lib/Foundation/sql-database.js +719 -0
  56. package/lib/Foundation/sql-database.js.map +1 -0
  57. package/lib/Foundation/wa-crypto.d.ts +14 -0
  58. package/lib/Foundation/wa-crypto.d.ts.map +1 -0
  59. package/lib/Foundation/wa-crypto.js +48 -0
  60. package/lib/Foundation/wa-crypto.js.map +1 -0
  61. package/lib/Foundation/zip.d.ts +2 -0
  62. package/lib/Foundation/zip.d.ts.map +1 -0
  63. package/lib/Foundation/zip.js +98 -0
  64. package/lib/Foundation/zip.js.map +1 -0
  65. package/lib/Signal/libsignal.js +0 -3
  66. package/lib/Signal/libsignal.js.map +1 -1
  67. package/lib/Socket/business.d.ts +3 -1
  68. package/lib/Socket/business.d.ts.map +1 -1
  69. package/lib/Socket/communities.d.ts +3 -1
  70. package/lib/Socket/communities.d.ts.map +1 -1
  71. package/lib/Socket/index.d.ts.map +1 -1
  72. package/lib/Socket/index.js +19 -14
  73. package/lib/Socket/index.js.map +1 -1
  74. package/lib/Socket/messages-recv.d.ts +3 -1
  75. package/lib/Socket/messages-recv.d.ts.map +1 -1
  76. package/lib/Socket/messages-recv.js +6 -2
  77. package/lib/Socket/messages-recv.js.map +1 -1
  78. package/lib/Socket/messages-send.d.ts +3 -1
  79. package/lib/Socket/messages-send.d.ts.map +1 -1
  80. package/lib/Socket/messages-send.js +298 -52
  81. package/lib/Socket/messages-send.js.map +1 -1
  82. package/lib/Socket/newsletter.d.ts.map +1 -1
  83. package/lib/Socket/newsletter.js +4 -5
  84. package/lib/Socket/newsletter.js.map +1 -1
  85. package/lib/Utils/crypto.d.ts.map +1 -1
  86. package/lib/Utils/crypto.js +6 -7
  87. package/lib/Utils/crypto.js.map +1 -1
  88. package/lib/Utils/messages-media.d.ts.map +1 -1
  89. package/lib/Utils/messages-media.js +89 -26
  90. package/lib/Utils/messages-media.js.map +1 -1
  91. package/lib/Utils/messages.d.ts +6 -0
  92. package/lib/Utils/messages.d.ts.map +1 -1
  93. package/lib/Utils/messages.js +198 -27
  94. package/lib/Utils/messages.js.map +1 -1
  95. package/lib/VoIP/WaVoipCoordinator.d.ts +39 -0
  96. package/lib/VoIP/WaVoipCoordinator.d.ts.map +1 -0
  97. package/lib/VoIP/WaVoipCoordinator.js +156 -0
  98. package/lib/VoIP/WaVoipCoordinator.js.map +1 -0
  99. package/lib/VoIP/app-data/WaAppDataStream.d.ts +35 -0
  100. package/lib/VoIP/app-data/WaAppDataStream.d.ts.map +1 -0
  101. package/lib/VoIP/app-data/WaAppDataStream.js +174 -0
  102. package/lib/VoIP/app-data/WaAppDataStream.js.map +1 -0
  103. package/lib/VoIP/app-data/protocol.d.ts +28 -0
  104. package/lib/VoIP/app-data/protocol.d.ts.map +1 -0
  105. package/lib/VoIP/app-data/protocol.js +167 -0
  106. package/lib/VoIP/app-data/protocol.js.map +1 -0
  107. package/lib/VoIP/bytes.d.ts +19 -0
  108. package/lib/VoIP/bytes.d.ts.map +1 -0
  109. package/lib/VoIP/bytes.js +64 -0
  110. package/lib/VoIP/bytes.js.map +1 -0
  111. package/lib/VoIP/call/WaCallManager.d.ts +58 -0
  112. package/lib/VoIP/call/WaCallManager.d.ts.map +1 -0
  113. package/lib/VoIP/call/WaCallManager.js +434 -0
  114. package/lib/VoIP/call/WaCallManager.js.map +1 -0
  115. package/lib/VoIP/call/WaCallMediaSession.d.ts +143 -0
  116. package/lib/VoIP/call/WaCallMediaSession.d.ts.map +1 -0
  117. package/lib/VoIP/call/WaCallMediaSession.js +1674 -0
  118. package/lib/VoIP/call/WaCallMediaSession.js.map +1 -0
  119. package/lib/VoIP/call/call-state.d.ts +34 -0
  120. package/lib/VoIP/call/call-state.d.ts.map +1 -0
  121. package/lib/VoIP/call/call-state.js +189 -0
  122. package/lib/VoIP/call/call-state.js.map +1 -0
  123. package/lib/VoIP/crypto/encryption.d.ts +6 -0
  124. package/lib/VoIP/crypto/encryption.d.ts.map +1 -0
  125. package/lib/VoIP/crypto/encryption.js +14 -0
  126. package/lib/VoIP/crypto/encryption.js.map +1 -0
  127. package/lib/VoIP/crypto/primitives.d.ts +5 -0
  128. package/lib/VoIP/crypto/primitives.d.ts.map +1 -0
  129. package/lib/VoIP/crypto/primitives.js +22 -0
  130. package/lib/VoIP/crypto/primitives.js.map +1 -0
  131. package/lib/VoIP/crypto/rtcp.d.ts +6 -0
  132. package/lib/VoIP/crypto/rtcp.d.ts.map +1 -0
  133. package/lib/VoIP/crypto/rtcp.js +71 -0
  134. package/lib/VoIP/crypto/rtcp.js.map +1 -0
  135. package/lib/VoIP/crypto/srtp.d.ts +40 -0
  136. package/lib/VoIP/crypto/srtp.d.ts.map +1 -0
  137. package/lib/VoIP/crypto/srtp.js +174 -0
  138. package/lib/VoIP/crypto/srtp.js.map +1 -0
  139. package/lib/VoIP/crypto/ssrc.d.ts +4 -0
  140. package/lib/VoIP/crypto/ssrc.d.ts.map +1 -0
  141. package/lib/VoIP/crypto/ssrc.js +15 -0
  142. package/lib/VoIP/crypto/ssrc.js.map +1 -0
  143. package/lib/VoIP/index.d.ts +82 -104
  144. package/lib/VoIP/index.d.ts.map +1 -1
  145. package/lib/VoIP/index.js +596 -885
  146. package/lib/VoIP/index.js.map +1 -1
  147. package/lib/VoIP/media/WaAudioEngine.d.ts +79 -0
  148. package/lib/VoIP/media/WaAudioEngine.d.ts.map +1 -0
  149. package/lib/VoIP/media/WaAudioEngine.js +478 -0
  150. package/lib/VoIP/media/WaAudioEngine.js.map +1 -0
  151. package/lib/VoIP/media/WaVideoEngine.d.ts +31 -0
  152. package/lib/VoIP/media/WaVideoEngine.d.ts.map +1 -0
  153. package/lib/VoIP/media/WaVideoEngine.js +261 -0
  154. package/lib/VoIP/media/WaVideoEngine.js.map +1 -0
  155. package/lib/VoIP/media/audio-codec.d.ts +74 -0
  156. package/lib/VoIP/media/audio-codec.d.ts.map +1 -0
  157. package/lib/VoIP/media/audio-codec.js +0 -0
  158. package/lib/VoIP/media/audio-codec.js.map +1 -0
  159. package/lib/VoIP/media/audio-reorder.d.ts +19 -0
  160. package/lib/VoIP/media/audio-reorder.d.ts.map +1 -0
  161. package/lib/VoIP/media/audio-reorder.js +112 -0
  162. package/lib/VoIP/media/audio-reorder.js.map +1 -0
  163. package/lib/VoIP/media/h264.d.ts +21 -0
  164. package/lib/VoIP/media/h264.d.ts.map +1 -0
  165. package/lib/VoIP/media/h264.js +239 -0
  166. package/lib/VoIP/media/h264.js.map +1 -0
  167. package/lib/VoIP/media/mlow-codec.d.ts +77 -0
  168. package/lib/VoIP/media/mlow-codec.d.ts.map +1 -0
  169. package/lib/VoIP/media/mlow-codec.js +467 -0
  170. package/lib/VoIP/media/mlow-codec.js.map +1 -0
  171. package/lib/VoIP/media/rtcp.d.ts +10 -0
  172. package/lib/VoIP/media/rtcp.d.ts.map +1 -0
  173. package/lib/VoIP/media/rtcp.js +61 -0
  174. package/lib/VoIP/media/rtcp.js.map +1 -0
  175. package/lib/VoIP/media/rtp.d.ts +56 -0
  176. package/lib/VoIP/media/rtp.d.ts.map +1 -0
  177. package/lib/VoIP/media/rtp.js +225 -0
  178. package/lib/VoIP/media/rtp.js.map +1 -0
  179. package/lib/VoIP/protobuf.d.ts +3 -0
  180. package/lib/VoIP/protobuf.d.ts.map +1 -0
  181. package/lib/VoIP/protobuf.js +30 -0
  182. package/lib/VoIP/protobuf.js.map +1 -0
  183. package/lib/VoIP/relay/WaManualRelay.d.ts +62 -0
  184. package/lib/VoIP/relay/WaManualRelay.d.ts.map +1 -0
  185. package/lib/VoIP/relay/WaManualRelay.js +619 -0
  186. package/lib/VoIP/relay/WaManualRelay.js.map +1 -0
  187. package/lib/VoIP/relay/datachannel/pre-negotiated.d.ts +22 -0
  188. package/lib/VoIP/relay/datachannel/pre-negotiated.d.ts.map +1 -0
  189. package/lib/VoIP/relay/datachannel/pre-negotiated.js +34 -0
  190. package/lib/VoIP/relay/datachannel/pre-negotiated.js.map +1 -0
  191. package/lib/VoIP/relay/dtls/aead.d.ts +23 -0
  192. package/lib/VoIP/relay/dtls/aead.d.ts.map +1 -0
  193. package/lib/VoIP/relay/dtls/aead.js +41 -0
  194. package/lib/VoIP/relay/dtls/aead.js.map +1 -0
  195. package/lib/VoIP/relay/dtls/cert-builder.d.ts +6 -0
  196. package/lib/VoIP/relay/dtls/cert-builder.d.ts.map +1 -0
  197. package/lib/VoIP/relay/dtls/cert-builder.js +68 -0
  198. package/lib/VoIP/relay/dtls/cert-builder.js.map +1 -0
  199. package/lib/VoIP/relay/dtls/der.d.ts +19 -0
  200. package/lib/VoIP/relay/dtls/der.d.ts.map +1 -0
  201. package/lib/VoIP/relay/dtls/der.js +96 -0
  202. package/lib/VoIP/relay/dtls/der.js.map +1 -0
  203. package/lib/VoIP/relay/dtls/ecdhe.d.ts +9 -0
  204. package/lib/VoIP/relay/dtls/ecdhe.d.ts.map +1 -0
  205. package/lib/VoIP/relay/dtls/ecdhe.js +33 -0
  206. package/lib/VoIP/relay/dtls/ecdhe.js.map +1 -0
  207. package/lib/VoIP/relay/dtls/handshake-framing.d.ts +49 -0
  208. package/lib/VoIP/relay/dtls/handshake-framing.d.ts.map +1 -0
  209. package/lib/VoIP/relay/dtls/handshake-framing.js +102 -0
  210. package/lib/VoIP/relay/dtls/handshake-framing.js.map +1 -0
  211. package/lib/VoIP/relay/dtls/handshake-messages.d.ts +64 -0
  212. package/lib/VoIP/relay/dtls/handshake-messages.d.ts.map +1 -0
  213. package/lib/VoIP/relay/dtls/handshake-messages.js +154 -0
  214. package/lib/VoIP/relay/dtls/handshake-messages.js.map +1 -0
  215. package/lib/VoIP/relay/dtls/handshake.d.ts +28 -0
  216. package/lib/VoIP/relay/dtls/handshake.d.ts.map +1 -0
  217. package/lib/VoIP/relay/dtls/handshake.js +555 -0
  218. package/lib/VoIP/relay/dtls/handshake.js.map +1 -0
  219. package/lib/VoIP/relay/dtls/prf.d.ts +13 -0
  220. package/lib/VoIP/relay/dtls/prf.d.ts.map +1 -0
  221. package/lib/VoIP/relay/dtls/prf.js +35 -0
  222. package/lib/VoIP/relay/dtls/prf.js.map +1 -0
  223. package/lib/VoIP/relay/dtls/record.d.ts +25 -0
  224. package/lib/VoIP/relay/dtls/record.d.ts.map +1 -0
  225. package/lib/VoIP/relay/dtls/record.js +49 -0
  226. package/lib/VoIP/relay/dtls/record.js.map +1 -0
  227. package/lib/VoIP/relay/relay-ack.d.ts +31 -0
  228. package/lib/VoIP/relay/relay-ack.d.ts.map +1 -0
  229. package/lib/VoIP/relay/relay-ack.js +142 -0
  230. package/lib/VoIP/relay/relay-ack.js.map +1 -0
  231. package/lib/VoIP/relay/sctp/association.d.ts +22 -0
  232. package/lib/VoIP/relay/sctp/association.d.ts.map +1 -0
  233. package/lib/VoIP/relay/sctp/association.js +434 -0
  234. package/lib/VoIP/relay/sctp/association.js.map +1 -0
  235. package/lib/VoIP/relay/sctp/crc32c.d.ts +2 -0
  236. package/lib/VoIP/relay/sctp/crc32c.d.ts.map +1 -0
  237. package/lib/VoIP/relay/sctp/crc32c.js +20 -0
  238. package/lib/VoIP/relay/sctp/crc32c.js.map +1 -0
  239. package/lib/VoIP/relay/sctp/wire.d.ts +96 -0
  240. package/lib/VoIP/relay/sctp/wire.d.ts.map +1 -0
  241. package/lib/VoIP/relay/sctp/wire.js +206 -0
  242. package/lib/VoIP/relay/sctp/wire.js.map +1 -0
  243. package/lib/VoIP/relay/stun.d.ts +47 -0
  244. package/lib/VoIP/relay/stun.d.ts.map +1 -0
  245. package/lib/VoIP/relay/stun.js +459 -0
  246. package/lib/VoIP/relay/stun.js.map +1 -0
  247. package/lib/VoIP/shim/baileys-resolve.d.ts +2 -0
  248. package/lib/VoIP/shim/baileys-resolve.d.ts.map +1 -0
  249. package/lib/VoIP/shim/baileys-resolve.js +22 -0
  250. package/lib/VoIP/shim/baileys-resolve.js.map +1 -0
  251. package/lib/VoIP/shim/core.d.ts +32 -0
  252. package/lib/VoIP/shim/core.d.ts.map +1 -0
  253. package/lib/VoIP/shim/core.js +67 -0
  254. package/lib/VoIP/shim/core.js.map +1 -0
  255. package/lib/VoIP/shim/crypto.d.ts +2 -0
  256. package/lib/VoIP/shim/crypto.d.ts.map +1 -0
  257. package/lib/VoIP/shim/crypto.js +7 -0
  258. package/lib/VoIP/shim/crypto.js.map +1 -0
  259. package/lib/VoIP/shim/proto.d.ts +2 -0
  260. package/lib/VoIP/shim/proto.d.ts.map +1 -0
  261. package/lib/VoIP/shim/proto.js +10 -0
  262. package/lib/VoIP/shim/proto.js.map +1 -0
  263. package/lib/VoIP/shim/protocol.d.ts +32 -0
  264. package/lib/VoIP/shim/protocol.d.ts.map +1 -0
  265. package/lib/VoIP/shim/protocol.js +131 -0
  266. package/lib/VoIP/shim/protocol.js.map +1 -0
  267. package/lib/VoIP/shim/transport.d.ts +20 -0
  268. package/lib/VoIP/shim/transport.d.ts.map +1 -0
  269. package/lib/VoIP/shim/transport.js +83 -0
  270. package/lib/VoIP/shim/transport.js.map +1 -0
  271. package/lib/VoIP/shim/util.d.ts +13 -0
  272. package/lib/VoIP/shim/util.d.ts.map +1 -0
  273. package/lib/VoIP/shim/util.js +208 -0
  274. package/lib/VoIP/shim/util.js.map +1 -0
  275. package/lib/VoIP/signaling/bridge.d.ts +4 -0
  276. package/lib/VoIP/signaling/bridge.d.ts.map +1 -0
  277. package/lib/VoIP/signaling/bridge.js +103 -0
  278. package/lib/VoIP/signaling/bridge.js.map +1 -0
  279. package/lib/VoIP/signaling/screen-share.d.ts +40 -0
  280. package/lib/VoIP/signaling/screen-share.d.ts.map +1 -0
  281. package/lib/VoIP/signaling/screen-share.js +55 -0
  282. package/lib/VoIP/signaling/screen-share.js.map +1 -0
  283. package/lib/VoIP/signaling/signaling.d.ts +396 -0
  284. package/lib/VoIP/signaling/signaling.d.ts.map +1 -0
  285. package/lib/VoIP/signaling/signaling.js +488 -0
  286. package/lib/VoIP/signaling/signaling.js.map +1 -0
  287. package/lib/VoIP/types.d.ts +37 -12
  288. package/lib/VoIP/types.d.ts.map +1 -1
  289. package/lib/VoIP/types.js +65 -12
  290. package/lib/VoIP/types.js.map +1 -1
  291. package/lib/VoIP/voip-deps.d.ts +46 -0
  292. package/lib/VoIP/voip-deps.d.ts.map +1 -0
  293. package/lib/VoIP/voip-deps.js +244 -0
  294. package/lib/VoIP/voip-deps.js.map +1 -0
  295. package/lib/VoIP/voipClient.d.ts +34 -0
  296. package/lib/VoIP/voipClient.d.ts.map +1 -0
  297. package/lib/VoIP/voipClient.js +351 -0
  298. package/lib/VoIP/voipClient.js.map +1 -0
  299. package/lib/VoIP/wasm-engine.d.ts +2 -2
  300. package/lib/WABinary/decode.d.ts.map +1 -1
  301. package/lib/WABinary/decode.js +10 -0
  302. package/lib/WABinary/decode.js.map +1 -1
  303. package/lib/WABinary/encode.d.ts.map +1 -1
  304. package/lib/WABinary/encode.js +10 -0
  305. package/lib/WABinary/encode.js.map +1 -1
  306. package/lib/WABinary/generic-utils.js +1 -1
  307. package/lib/WABinary/generic-utils.js.map +1 -1
  308. package/lib/WABinary/jid-utils.d.ts.map +1 -1
  309. package/lib/WABinary/jid-utils.js +18 -17
  310. package/lib/WABinary/jid-utils.js.map +1 -1
  311. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import NodeCache from '@cacheable/node-cache';
2
2
  import { Boom } from '@hapi/boom';
3
- import crypto from 'crypto';
3
+ import crypto, { randomBytes } from 'crypto';
4
4
  import { proto } from '../../WAProto/index.js';
5
+ import { AssociationType } from '../Types/Message.js';
5
6
  import { BIZ_BOT_SUPPORT_PAYLOAD, DEFAULT_CACHE_TTLS, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
6
- import { aggregateMessageKeysNotFromMe, assertMediaContent, assertMeId, bindWaitForEvent, decryptMediaRetryData, DEF_MEDIA_HOST, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, generateMessageIDV2, generateParticipantHashV2, generateWAMessage, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, MessageRetryManager, normalizeMessageContent, shouldIncludeBizBinaryNode, parseAndInjectE2ESessions, unixTimestampSeconds } from '../Utils/index.js';
7
+ import { aggregateMessageKeysNotFromMe, assertMediaContent, assertMeId, bindWaitForEvent, decryptMediaRetryData, DEF_MEDIA_HOST, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, generateMessageIDV2, generateParticipantHashV2, generateWAMessage, generateWAMessageFromContent, hasValidAlbumMedia, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, MessageRetryManager, normalizeMessageContent, shouldIncludeBizBinaryNode, parseAndInjectE2ESessions, unixTimestampSeconds } from '../Utils/index.js';
7
8
  import { getUrlInfo } from '../Utils/link-preview.js';
8
9
  import { makeKeyedMutex, makeMutex } from '../Utils/make-mutex.js';
9
10
  import { getMessageReportingToken, shouldIncludeReportingToken } from '../Utils/reporting-utils.js';
@@ -12,7 +13,9 @@ import { areJidsSameUser, getBinaryNodeChild, getBinaryNodeChildren, getBizBinar
12
13
  import { USyncQuery, USyncUser } from '../WAUSync/index.js';
13
14
  import { makeNewsletterSocket } from './newsletter.js';
14
15
  export const makeMessagesSocket = (config) => {
15
- const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: httpRequestOptions, patchMessageBeforeSending, cachedGroupMetadata, enableRecentMessageCache, maxMsgRetryCount } = config;
16
+ const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: httpRequestOptions, cachedGroupMetadata, enableRecentMessageCache, maxMsgRetryCount } = config;
17
+ let currentPatchMessageBeforeSending = config.patchMessageBeforeSending;
18
+ const patchMessageBeforeSending = (message, jids) => currentPatchMessageBeforeSending(message, jids);
16
19
  const sock = makeNewsletterSocket(config);
17
20
  const { ev, authState, messageMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral, registerSocketEndHandler } = sock;
18
21
  const getLIDForPN = signalRepository.lidMapping.getLIDForPN.bind(signalRepository.lidMapping);
@@ -439,7 +442,8 @@ export const makeMessagesSocket = (config) => {
439
442
  });
440
443
  }
441
444
  await authState.keys.transaction(async () => {
442
- const mediaType = getMediaType(message);
445
+ const innerMessage = normalizeMessageContent(message);
446
+ const mediaType = getMediaType(innerMessage || message);
443
447
  if (mediaType) {
444
448
  extraAttrs['mediatype'] = mediaType;
445
449
  }
@@ -459,7 +463,7 @@ export const makeMessagesSocket = (config) => {
459
463
  attrs: {
460
464
  to: jid,
461
465
  id: msgId,
462
- type: getMessageType(message),
466
+ type: getMessageType(innerMessage || message),
463
467
  ...(additionalAttributes || {})
464
468
  },
465
469
  content: binaryNodeContent
@@ -468,9 +472,36 @@ export const makeMessagesSocket = (config) => {
468
472
  await sendNode(stanza);
469
473
  return;
470
474
  }
471
- if (normalizeMessageContent(message)?.pinInChatMessage || normalizeMessageContent(message)?.reactionMessage) {
475
+ // Add meta node for certain message types
476
+ const isNeedMetaAttrs = innerMessage?.pinInChatMessage || innerMessage?.keepInChatMessage || innerMessage?.reactionMessage;
477
+ const isGroupStatus = message?.groupStatusMessage || message?.groupStatusMessageV2;
478
+ const isPollUpdate = innerMessage?.pollUpdateMessage;
479
+ if (isNeedMetaAttrs || isGroupStatus || isPollUpdate) {
480
+ const metaAttrs = {};
481
+ if (isNeedMetaAttrs) {
482
+ metaAttrs['content_type'] = 'add_on';
483
+ }
484
+ if (isPollUpdate && !isGroupStatus) {
485
+ metaAttrs['polltype'] = 'vote';
486
+ }
487
+ if (isGroupStatus) {
488
+ metaAttrs['is_group_status'] = 'true';
489
+ }
490
+ binaryNodeContent.push({
491
+ tag: 'meta',
492
+ attrs: metaAttrs,
493
+ content: undefined
494
+ });
495
+ }
496
+ if (isNeedMetaAttrs ||
497
+ innerMessage?.protocolMessage?.memberLabel ||
498
+ innerMessage?.protocolMessage?.editedMessage ||
499
+ innerMessage?.protocolMessage?.mediaNotifyMessage) {
472
500
  extraAttrs['decrypt-fail'] = 'hide';
473
501
  }
502
+ if (innerMessage?.interactiveResponseMessage?.nativeFlowResponseMessage) {
503
+ extraAttrs['native_flow_name'] = innerMessage.interactiveResponseMessage.nativeFlowResponseMessage.name;
504
+ }
474
505
  if (isGroupOrStatus && !isRetryResend) {
475
506
  const [groupData, senderKeyMap] = await Promise.all([
476
507
  (async () => {
@@ -509,51 +540,103 @@ export const makeMessagesSocket = (config) => {
509
540
  addressing_mode: groupData?.addressingMode || 'lid'
510
541
  };
511
542
  }
512
- const patched = await patchMessageBeforeSending(message);
543
+ const patched = await patchMessageBeforeSending(message, isGroup ? devices.map(d => d.jid) : undefined);
513
544
  if (Array.isArray(patched)) {
514
- throw new Boom('Per-jid patching is not supported in groups');
515
- }
516
- const bytes = encodeWAMessage(patched);
517
- reportingMessage = patched;
518
- const groupAddressingMode = additionalAttributes?.['addressing_mode'] || groupData?.addressingMode || 'lid';
519
- const groupSenderIdentity = groupAddressingMode === 'lid' && meLid ? meLid : meId;
520
- const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
521
- group: destinationJid,
522
- data: bytes,
523
- meId: groupSenderIdentity
524
- });
525
- const senderKeyRecipients = [];
526
- for (const device of devices) {
527
- const deviceJid = device.jid;
528
- const hasKey = !!senderKeyMap[deviceJid];
529
- if ((!hasKey || !!participant) &&
530
- !isHostedLidUser(deviceJid) &&
531
- !isHostedPnUser(deviceJid) &&
532
- device.device !== 99) {
533
- senderKeyRecipients.push(deviceJid);
534
- senderKeyMap[deviceJid] = true;
545
+ // Per-jid patching: hybrid skmsg + per-recipient pkmsg
546
+ logger.debug({ jid, devices: devices.length }, 'per-jid group patch: skmsg+pkmsg hybrid');
547
+ const userMsgMap = new Map();
548
+ let fallbackPatchedMsg = message;
549
+ for (const { recipientJid, message: msg } of patched) {
550
+ if (!msg)
551
+ continue;
552
+ const decoded = jidDecode(recipientJid);
553
+ if (decoded)
554
+ userMsgMap.set(decoded.user, msg);
555
+ else
556
+ fallbackPatchedMsg = msg;
557
+ }
558
+ if (!userMsgMap.size)
559
+ fallbackPatchedMsg = patched.find(p => p.message)?.message || message;
560
+ const groupAddressingMode = additionalAttributes?.['addressing_mode'] || groupData?.addressingMode || 'lid';
561
+ const groupSenderIdentity = groupAddressingMode === 'lid' && meLid ? meLid : meId;
562
+ const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
563
+ group: destinationJid,
564
+ data: encodeWAMessage(fallbackPatchedMsg),
565
+ meId: groupSenderIdentity
566
+ });
567
+ reportingMessage = fallbackPatchedMsg;
568
+ const senderKeyRecipients = [];
569
+ for (const device of devices) {
570
+ const deviceJid = device.jid;
571
+ if ((!senderKeyMap[deviceJid] || !!participant) &&
572
+ !isHostedLidUser(deviceJid) && !isHostedPnUser(deviceJid) && device.device !== 99) {
573
+ senderKeyRecipients.push(deviceJid);
574
+ senderKeyMap[deviceJid] = true;
575
+ }
576
+ }
577
+ if (senderKeyRecipients.length) {
578
+ const senderKeyMsg = { senderKeyDistributionMessage: { axolotlSenderKeyDistributionMessage: senderKeyDistributionMessage, groupId: destinationJid } };
579
+ await assertSessions(senderKeyRecipients);
580
+ const r = await createParticipantNodes(senderKeyRecipients, senderKeyMsg, extraAttrs);
581
+ shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || r.shouldIncludeDeviceIdentity;
582
+ participants.push(...r.nodes);
583
+ }
584
+ binaryNodeContent.push({ tag: 'enc', attrs: { v: '2', type: 'skmsg', ...extraAttrs }, content: ciphertext });
585
+ await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
586
+ // Send per-recipient pkmsg for devices with custom patched messages
587
+ const customDevices = devices
588
+ .map(d => { const dec = jidDecode(d.jid); return dec && userMsgMap.has(dec.user) ? { recipientJid: d.jid, message: userMsgMap.get(dec.user) } : null; })
589
+ .filter(Boolean);
590
+ if (customDevices.length) {
591
+ await assertSessions(customDevices.map(d => d.recipientJid));
592
+ const r = await createParticipantNodes(customDevices.map(d => d.recipientJid), message, extraAttrs);
593
+ shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || r.shouldIncludeDeviceIdentity;
594
+ participants.push(...r.nodes);
535
595
  }
536
596
  }
537
- if (senderKeyRecipients.length) {
538
- logger.debug({ senderKeyJids: senderKeyRecipients }, 'sending new sender key');
539
- const senderKeyMsg = {
540
- senderKeyDistributionMessage: {
541
- axolotlSenderKeyDistributionMessage: senderKeyDistributionMessage,
542
- groupId: destinationJid
597
+ else {
598
+ const bytes = encodeWAMessage(patched);
599
+ reportingMessage = patched;
600
+ const groupAddressingMode = additionalAttributes?.['addressing_mode'] || groupData?.addressingMode || 'lid';
601
+ const groupSenderIdentity = groupAddressingMode === 'lid' && meLid ? meLid : meId;
602
+ const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
603
+ group: destinationJid,
604
+ data: bytes,
605
+ meId: groupSenderIdentity
606
+ });
607
+ const senderKeyRecipients = [];
608
+ for (const device of devices) {
609
+ const deviceJid = device.jid;
610
+ const hasKey = !!senderKeyMap[deviceJid];
611
+ if ((!hasKey || !!participant) &&
612
+ !isHostedLidUser(deviceJid) &&
613
+ !isHostedPnUser(deviceJid) &&
614
+ device.device !== 99) {
615
+ senderKeyRecipients.push(deviceJid);
616
+ senderKeyMap[deviceJid] = true;
543
617
  }
544
- };
545
- const senderKeySessionTargets = senderKeyRecipients;
546
- await assertSessions(senderKeySessionTargets);
547
- const result = await createParticipantNodes(senderKeyRecipients, senderKeyMsg, extraAttrs);
548
- shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity;
549
- participants.push(...result.nodes);
618
+ }
619
+ if (senderKeyRecipients.length) {
620
+ logger.debug({ senderKeyJids: senderKeyRecipients }, 'sending new sender key');
621
+ const senderKeyMsg = {
622
+ senderKeyDistributionMessage: {
623
+ axolotlSenderKeyDistributionMessage: senderKeyDistributionMessage,
624
+ groupId: destinationJid
625
+ }
626
+ };
627
+ const senderKeySessionTargets = senderKeyRecipients;
628
+ await assertSessions(senderKeySessionTargets);
629
+ const result = await createParticipantNodes(senderKeyRecipients, senderKeyMsg, extraAttrs);
630
+ shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity;
631
+ participants.push(...result.nodes);
632
+ }
633
+ binaryNodeContent.push({
634
+ tag: 'enc',
635
+ attrs: { v: '2', type: 'skmsg', ...extraAttrs },
636
+ content: ciphertext
637
+ });
638
+ await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
550
639
  }
551
- binaryNodeContent.push({
552
- tag: 'enc',
553
- attrs: { v: '2', type: 'skmsg', ...extraAttrs },
554
- content: ciphertext
555
- });
556
- await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
557
640
  }
558
641
  else {
559
642
  let ownId = meId;
@@ -705,7 +788,7 @@ export const makeMessagesSocket = (config) => {
705
788
  attrs: {
706
789
  id: msgId,
707
790
  to: destinationJid,
708
- type: getMessageType(message),
791
+ type: getMessageType(innerMessage || message),
709
792
  ...(additionalAttributes || {})
710
793
  },
711
794
  content: binaryNodeContent
@@ -791,13 +874,14 @@ export const makeMessagesSocket = (config) => {
791
874
  stanza.content.push(...additionalNodes);
792
875
  alreadyHasBizNode = !addBizAttributes && additionalNodes.some(node => node.tag === 'biz');
793
876
  }
794
- if ((!alreadyHasBizNode && shouldIncludeBizBinaryNode(message)) || addBizAttributes) {
795
- const bizNode = getBizBinaryNode(message);
877
+ const bizContent = innerMessage || message;
878
+ if ((!alreadyHasBizNode && shouldIncludeBizBinaryNode(bizContent)) || addBizAttributes) {
879
+ const bizNode = getBizBinaryNode(bizContent);
796
880
  stanza.content.push(bizNode);
797
881
  }
798
882
  logger.debug({ msgId }, `sending message to ${participants.length} devices`);
799
883
  await sendNode(stanza);
800
- const isProtocolMsg = !!normalizeMessageContent(message)?.protocolMessage;
884
+ const isProtocolMsg = !!innerMessage?.protocolMessage;
801
885
  const isBotOrPSA = destinationJid === PSA_WID || isJidBot(destinationJid) || isJidMetaAI(destinationJid);
802
886
  if (is1on1Send &&
803
887
  !isProtocolMsg &&
@@ -936,6 +1020,9 @@ export const makeMessagesSocket = (config) => {
936
1020
  else if (innerMsg.groupInviteMessage) {
937
1021
  return 'url';
938
1022
  }
1023
+ else if (innerMsg.albumMessage) {
1024
+ return 'collection';
1025
+ }
939
1026
  return '';
940
1027
  };
941
1028
  /**
@@ -1064,6 +1151,8 @@ export const makeMessagesSocket = (config) => {
1064
1151
  getUSyncDevices,
1065
1152
  messageRetryManager,
1066
1153
  updateMemberLabel,
1154
+ getPatchMessageBeforeSending: () => currentPatchMessageBeforeSending,
1155
+ setPatchMessageBeforeSending: (fn) => { currentPatchMessageBeforeSending = fn; },
1067
1156
  sendHTML,
1068
1157
  updateMediaMessage: async (message) => {
1069
1158
  const content = assertMediaContent(message.message);
@@ -1108,7 +1197,95 @@ export const makeMessagesSocket = (config) => {
1108
1197
  return message;
1109
1198
  },
1110
1199
  sendMessage: async (jid, content, options = {}) => {
1200
+ var _a;
1111
1201
  const userJid = authState.creds.me.id;
1202
+ // Array-jid: broadcast status to multiple JIDs (groups + contacts)
1203
+ if (Array.isArray(jid)) {
1204
+ const { delayMs = 1500 } = options;
1205
+ const allUsers = new Set();
1206
+ const fullMsg = await generateWAMessage('status@broadcast', content, {
1207
+ logger,
1208
+ userJid,
1209
+ upload: waUploadToServer,
1210
+ mediaCache: config.mediaCache,
1211
+ options: config.options,
1212
+ messageId: generateMessageIDV2(userJid),
1213
+ ...options
1214
+ });
1215
+ for (const id of jid) {
1216
+ if (isJidGroup(id)) {
1217
+ try {
1218
+ const groupData = (cachedGroupMetadata ? await cachedGroupMetadata(id) : null) || await groupMetadata(id);
1219
+ for (const participant of groupData.participants) {
1220
+ if (allUsers.has(participant.id))
1221
+ continue;
1222
+ allUsers.add(participant.id);
1223
+ }
1224
+ }
1225
+ catch (error) {
1226
+ logger.error(`Error getting metadata group from ${id}: ${error}`);
1227
+ }
1228
+ }
1229
+ else if (!allUsers.has(id)) {
1230
+ allUsers.add(id);
1231
+ }
1232
+ }
1233
+ await relayMessage('status@broadcast', fullMsg.message, {
1234
+ messageId: fullMsg.key.id,
1235
+ statusJidList: Array.from(allUsers),
1236
+ additionalNodes: [
1237
+ {
1238
+ tag: 'meta',
1239
+ attrs: {},
1240
+ content: [
1241
+ {
1242
+ tag: 'mentioned_users',
1243
+ attrs: {},
1244
+ content: jid.map(id => ({ tag: 'to', attrs: { jid: id }, content: undefined }))
1245
+ }
1246
+ ]
1247
+ }
1248
+ ]
1249
+ });
1250
+ if (config.emitOwnEvents) {
1251
+ process.nextTick(async () => {
1252
+ await messageMutex.mutex(() => upsertMessage(fullMsg, 'append'));
1253
+ });
1254
+ }
1255
+ for (const id of jid) {
1256
+ const isGroup = isJidGroup(id);
1257
+ const sendType = isGroup ? 'groupStatusMentionMessage' : 'statusMentionMessage';
1258
+ const mentionMsg = generateWAMessageFromContent(id, {
1259
+ messageContextInfo: {
1260
+ messageSecret: randomBytes(32)
1261
+ },
1262
+ [sendType]: {
1263
+ message: {
1264
+ protocolMessage: {
1265
+ key: fullMsg.key,
1266
+ type: 25
1267
+ }
1268
+ }
1269
+ }
1270
+ }, { userJid });
1271
+ await relayMessage(id, mentionMsg.message, {
1272
+ additionalNodes: [
1273
+ {
1274
+ tag: 'meta',
1275
+ attrs: isGroup ? { is_group_status_mention: 'true' } : { is_status_mention: 'true' },
1276
+ content: undefined
1277
+ }
1278
+ ]
1279
+ });
1280
+ if (config.emitOwnEvents) {
1281
+ process.nextTick(async () => {
1282
+ await messageMutex.mutex(() => upsertMessage(mentionMsg, 'append'));
1283
+ });
1284
+ }
1285
+ await new Promise(r => setTimeout(r, delayMs));
1286
+ }
1287
+ return fullMsg;
1288
+ }
1112
1289
  // Direct sendHTML routing when { html: "..." } is passed to sendMessage
1113
1290
  if (typeof content === 'object' && content && 'html' in content && typeof content.html === 'string') {
1114
1291
  return await sendHTML(jid, content.html, {
@@ -1168,14 +1345,16 @@ export const makeMessagesSocket = (config) => {
1168
1345
  const isDeleteMsg = 'delete' in content && !!content.delete;
1169
1346
  const isEditMsg = 'edit' in content && !!content.edit;
1170
1347
  const isPinMsg = 'pin' in content && !!content.pin;
1348
+ const isKeepMsg = 'keep' in content && !!content.keep;
1171
1349
  const isPollMessage = 'poll' in content && !!content.poll;
1172
1350
  const isQuizMsg = 'poll' in content && !!content.poll.pollType;
1173
1351
  const isAiMsg = 'ai' in content && !!content.ai;
1174
1352
  const isNeedBizAttrs = 'secureMetaServiceLabel' in content && !!content.secureMetaServiceLabel;
1175
1353
  const additionalAttributes = options.additionalAttributes || {};
1176
1354
  const additionalNodes = options.additionalNodes || [];
1177
- if (isDeleteMsg) {
1178
- if (isJidGroup(content.delete?.remoteJid) && !content.delete?.fromMe) {
1355
+ if (isDeleteMsg || isKeepMsg) {
1356
+ const deleteKey = content.delete;
1357
+ if (isJidGroup(deleteKey?.remoteJid) && !deleteKey?.fromMe) {
1179
1358
  additionalAttributes.edit = '8';
1180
1359
  }
1181
1360
  else {
@@ -1231,11 +1410,78 @@ export const makeMessagesSocket = (config) => {
1231
1410
  additionalNodes,
1232
1411
  addBizAttributes: isNeedBizAttrs
1233
1412
  });
1413
+ // Mark edited/deleted messages in retry manager
1414
+ if (messageRetryManager && (isDeleteMsg || isEditMsg)) {
1415
+ const targetKey = isDeleteMsg ? content.delete : content.edit;
1416
+ if (targetKey?.id) {
1417
+ messageRetryManager.markRetrySuccess(targetKey.id);
1418
+ }
1419
+ }
1234
1420
  if (config.emitOwnEvents) {
1235
1421
  process.nextTick(async () => {
1236
1422
  await messageMutex.mutex(() => upsertMessage(fullMsg, 'append'));
1237
1423
  });
1238
1424
  }
1425
+ // aiRich: send a follow-up edit to provide rich media resolution
1426
+ if ('aiRich' in content && content.aiRich && options.bypassDownload !== false
1427
+ && fullMsg.key?.id && fullMsg.message?.botForwardedMessage?.message?.richResponseMessage?.unifiedResponse) {
1428
+ try {
1429
+ const AIRichBuilder = (await import('../Utils/rich-message-utils.js')).prepareRichResponseMessage;
1430
+ const edit = AIRichBuilder.buildEdit?.(jid, fullMsg.key, fullMsg.message);
1431
+ if (edit) {
1432
+ await relayMessage(jid, edit, {
1433
+ messageId: generateMessageIDV2(userJid),
1434
+ additionalAttributes: { edit: '1' },
1435
+ additionalNodes: options.additionalNodes,
1436
+ useCachedGroupMetadata: options.useCachedGroupMetadata,
1437
+ statusJidList: options.statusJidList
1438
+ });
1439
+ }
1440
+ }
1441
+ catch (error) {
1442
+ error.relayedKey = fullMsg.key;
1443
+ throw error;
1444
+ }
1445
+ }
1446
+ // Album send: relay each album item with parent key association
1447
+ if ('album' in content && Array.isArray(content.album)) {
1448
+ const { delayMs = 1500 } = options;
1449
+ for (const albumMedia of content.album) {
1450
+ const albumMsg = await generateWAMessage(jid, albumMedia, {
1451
+ logger,
1452
+ userJid,
1453
+ upload: waUploadToServer,
1454
+ mediaCache: config.mediaCache,
1455
+ options: config.options,
1456
+ ...options,
1457
+ messageId: generateMessageIDV2(userJid)
1458
+ });
1459
+ if (!hasValidAlbumMedia(normalizeMessageContent(albumMsg.message))) {
1460
+ throw new Boom('Invalid message type for album', { statusCode: 400 });
1461
+ }
1462
+ if (albumMsg.message) {
1463
+ (_a = albumMsg.message).messageContextInfo || (_a.messageContextInfo = {});
1464
+ albumMsg.message.messageContextInfo.messageAssociation = {
1465
+ parentMessageKey: fullMsg.key,
1466
+ associationType: AssociationType.MEDIA_ALBUM
1467
+ };
1468
+ }
1469
+ await relayMessage(jid, albumMsg.message, {
1470
+ messageId: albumMsg.key.id,
1471
+ useCachedGroupMetadata: options.useCachedGroupMetadata,
1472
+ addBizAttributes: isNeedBizAttrs,
1473
+ statusJidList: options.statusJidList,
1474
+ additionalAttributes,
1475
+ additionalNodes
1476
+ });
1477
+ if (config.emitOwnEvents) {
1478
+ process.nextTick(async () => {
1479
+ await messageMutex.mutex(() => upsertMessage(albumMsg, 'append'));
1480
+ });
1481
+ }
1482
+ await new Promise(r => setTimeout(r, delayMs));
1483
+ }
1484
+ }
1239
1485
  return fullMsg;
1240
1486
  }
1241
1487
  }