@fer2809fl/baileys 7.0.1 → 7.0.4

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 (350) hide show
  1. package/README.md +322 -578
  2. package/WAProto/WAProto.proto +916 -360
  3. package/WAProto/fix-imports.js +18 -22
  4. package/WAProto/index.d.ts +15471 -8638
  5. package/WAProto/index.js +80576 -45941
  6. package/lib/Defaults/index.d.ts +14 -18
  7. package/lib/Defaults/index.js +111 -115
  8. package/lib/Signal/libsignal.js +22 -31
  9. package/lib/Signal/lid-mapping.d.ts +0 -4
  10. package/lib/Signal/lid-mapping.js +0 -6
  11. package/lib/Socket/business.d.ts +8 -75
  12. package/lib/Socket/business.js +1 -0
  13. package/lib/Socket/chats.d.ts +0 -6
  14. package/lib/Socket/chats.js +3 -67
  15. package/lib/Socket/communities.d.ts +641 -336
  16. package/lib/Socket/communities.js +3 -6
  17. package/lib/Socket/dugong.d.ts +130 -0
  18. package/lib/Socket/dugong.js +772 -0
  19. package/lib/Socket/groups.d.ts +18 -23
  20. package/lib/Socket/groups.js +88 -168
  21. package/lib/Socket/index.d.ts +631 -322
  22. package/lib/Socket/index.js +12 -9
  23. package/lib/Socket/messages-recv.d.ts +52 -84
  24. package/lib/Socket/messages-recv.js +193 -677
  25. package/lib/Socket/messages-send.d.ts +643 -262
  26. package/lib/Socket/messages-send.js +1559 -1359
  27. package/lib/Socket/mex.d.ts +0 -1
  28. package/lib/Socket/mex.js +8 -22
  29. package/lib/Socket/native-buttons.js +231 -0
  30. package/lib/Socket/newsletter.d.ts +27 -42
  31. package/lib/Socket/newsletter.js +439 -402
  32. package/lib/Socket/socket.d.ts +2 -6
  33. package/lib/Socket/socket.js +47 -39
  34. package/lib/Types/Auth.d.ts +0 -1
  35. package/lib/Types/Bussines.d.ts +34 -22
  36. package/lib/Types/Call.d.ts +1 -1
  37. package/lib/Types/Chat.d.ts +0 -1
  38. package/lib/Types/Contact.d.ts +0 -2
  39. package/lib/Types/Events.d.ts +1 -20
  40. package/lib/Types/GroupMetadata.d.ts +1 -4
  41. package/lib/Types/Message.d.ts +348 -354
  42. package/lib/Types/Message.js +0 -4
  43. package/lib/Types/{Mex.d.ts → Newsletter.d.ts} +7 -17
  44. package/lib/Types/{Mex.js → Newsletter.js} +5 -3
  45. package/lib/Types/Signal.d.ts +1 -12
  46. package/lib/Types/Socket.d.ts +148 -135
  47. package/lib/Types/State.d.ts +0 -65
  48. package/lib/Types/State.js +0 -43
  49. package/lib/Types/index.d.ts +52 -52
  50. package/lib/Types/index.js +30 -23
  51. package/lib/Utils/auth-utils.d.ts +0 -5
  52. package/lib/Utils/auth-utils.js +0 -12
  53. package/lib/Utils/browser-utils.js +0 -1
  54. package/lib/Utils/crypto.d.ts +12 -12
  55. package/lib/Utils/decode-wa-message.d.ts +0 -18
  56. package/lib/Utils/decode-wa-message.js +0 -34
  57. package/lib/Utils/event-buffer.d.ts +0 -2
  58. package/lib/Utils/generics.d.ts +2 -3
  59. package/lib/Utils/generics.js +1 -10
  60. package/lib/Utils/history.d.ts +0 -2
  61. package/lib/Utils/history.js +9 -12
  62. package/lib/Utils/identity-change-handler.d.ts +0 -7
  63. package/lib/Utils/identity-change-handler.js +0 -1
  64. package/lib/Utils/index.d.ts +23 -30
  65. package/lib/Utils/index.js +3 -9
  66. package/lib/Utils/link-preview.js +2 -2
  67. package/lib/Utils/message-retry-manager.d.ts +0 -5
  68. package/lib/Utils/message-retry-manager.js +11 -11
  69. package/lib/Utils/messages-media.d.ts +13 -45
  70. package/lib/Utils/messages-media.js +98 -293
  71. package/lib/Utils/messages.d.ts +3 -16
  72. package/lib/Utils/messages.js +1123 -1219
  73. package/lib/Utils/noise-handler.d.ts +1 -1
  74. package/lib/Utils/process-message.js +1 -103
  75. package/lib/Utils/rich-messages.d.ts +277 -0
  76. package/lib/Utils/rich-messages.js +1144 -0
  77. package/lib/Utils/signal.d.ts +0 -13
  78. package/lib/Utils/signal.js +0 -42
  79. package/lib/Utils/sticker-pack.d.ts +10 -0
  80. package/lib/Utils/sticker-pack.js +111 -0
  81. package/lib/Utils/sync-action-utils.js +0 -1
  82. package/lib/Utils/tc-token-utils.d.ts +1 -26
  83. package/lib/Utils/tc-token-utils.js +5 -151
  84. package/lib/Utils/validate-connection.d.ts +0 -1
  85. package/lib/Utils/validate-connection.js +3 -13
  86. package/lib/WABinary/decode.d.ts +1 -1
  87. package/lib/WABinary/generic-utils.d.ts +3 -1
  88. package/lib/WABinary/generic-utils.js +78 -0
  89. package/lib/WABinary/jid-utils.d.ts +0 -11
  90. package/lib/WABinary/jid-utils.js +0 -33
  91. package/lib/WAM/encode.d.ts +1 -1
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -26
  93. package/lib/WAUSync/Protocols/index.d.ts +0 -1
  94. package/lib/WAUSync/USyncQuery.d.ts +0 -1
  95. package/lib/WAUSync/USyncQuery.js +1 -1
  96. package/lib/WAUSync/USyncUser.d.ts +0 -4
  97. package/lib/WAUSync/USyncUser.js +0 -8
  98. package/lib/index.d.ts +1 -1
  99. package/lib/index.js +1 -4
  100. package/package.json +27 -31
  101. package/LICENSE +0 -21
  102. package/engine-requirements.js +0 -10
  103. package/lib/Defaults/index.d.ts.map +0 -1
  104. package/lib/Defaults/index.js.map +0 -1
  105. package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
  106. package/lib/Signal/Group/ciphertext-message.js.map +0 -1
  107. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  108. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  109. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  110. package/lib/Signal/Group/group_cipher.js.map +0 -1
  111. package/lib/Signal/Group/index.d.ts.map +0 -1
  112. package/lib/Signal/Group/index.js.map +0 -1
  113. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  114. package/lib/Signal/Group/keyhelper.js.map +0 -1
  115. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  116. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  117. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  118. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  119. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  120. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  121. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  122. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  123. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  124. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  125. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  126. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  127. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  128. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  129. package/lib/Signal/libsignal.d.ts.map +0 -1
  130. package/lib/Signal/libsignal.js.map +0 -1
  131. package/lib/Signal/lid-mapping.d.ts.map +0 -1
  132. package/lib/Signal/lid-mapping.js.map +0 -1
  133. package/lib/Socket/Client/index.d.ts.map +0 -1
  134. package/lib/Socket/Client/index.js.map +0 -1
  135. package/lib/Socket/Client/types.d.ts.map +0 -1
  136. package/lib/Socket/Client/types.js.map +0 -1
  137. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  138. package/lib/Socket/Client/websocket.js.map +0 -1
  139. package/lib/Socket/business.d.ts.map +0 -1
  140. package/lib/Socket/business.js.map +0 -1
  141. package/lib/Socket/chats.d.ts.map +0 -1
  142. package/lib/Socket/chats.js.map +0 -1
  143. package/lib/Socket/communities.d.ts.map +0 -1
  144. package/lib/Socket/communities.js.map +0 -1
  145. package/lib/Socket/groups.d.ts.map +0 -1
  146. package/lib/Socket/groups.js.map +0 -1
  147. package/lib/Socket/index.d.ts.map +0 -1
  148. package/lib/Socket/index.js.map +0 -1
  149. package/lib/Socket/messages-recv.d.ts.map +0 -1
  150. package/lib/Socket/messages-recv.js.map +0 -1
  151. package/lib/Socket/messages-send.d.ts.map +0 -1
  152. package/lib/Socket/messages-send.js.map +0 -1
  153. package/lib/Socket/mex.d.ts.map +0 -1
  154. package/lib/Socket/mex.js.map +0 -1
  155. package/lib/Socket/newsletter.d.ts.map +0 -1
  156. package/lib/Socket/newsletter.js.map +0 -1
  157. package/lib/Socket/smgss.d.ts +0 -119
  158. package/lib/Socket/smgss.d.ts.map +0 -1
  159. package/lib/Socket/smgss.js +0 -453
  160. package/lib/Socket/smgss.js.map +0 -1
  161. package/lib/Socket/socket.d.ts.map +0 -1
  162. package/lib/Socket/socket.js.map +0 -1
  163. package/lib/Store/index.d.ts +0 -4
  164. package/lib/Store/index.d.ts.map +0 -1
  165. package/lib/Store/index.js +0 -4
  166. package/lib/Store/index.js.map +0 -1
  167. package/lib/Store/make-in-memory-store.d.ts +0 -132
  168. package/lib/Store/make-in-memory-store.d.ts.map +0 -1
  169. package/lib/Store/make-in-memory-store.js +0 -450
  170. package/lib/Store/make-in-memory-store.js.map +0 -1
  171. package/lib/Store/make-ordered-dictionary.d.ts +0 -14
  172. package/lib/Store/make-ordered-dictionary.d.ts.map +0 -1
  173. package/lib/Store/make-ordered-dictionary.js +0 -80
  174. package/lib/Store/make-ordered-dictionary.js.map +0 -1
  175. package/lib/Store/object-repository.d.ts +0 -13
  176. package/lib/Store/object-repository.d.ts.map +0 -1
  177. package/lib/Store/object-repository.js +0 -24
  178. package/lib/Store/object-repository.js.map +0 -1
  179. package/lib/Types/Auth.d.ts.map +0 -1
  180. package/lib/Types/Auth.js.map +0 -1
  181. package/lib/Types/Bussines.d.ts.map +0 -1
  182. package/lib/Types/Bussines.js.map +0 -1
  183. package/lib/Types/Call.d.ts.map +0 -1
  184. package/lib/Types/Call.js.map +0 -1
  185. package/lib/Types/Chat.d.ts.map +0 -1
  186. package/lib/Types/Chat.js.map +0 -1
  187. package/lib/Types/Contact.d.ts.map +0 -1
  188. package/lib/Types/Contact.js.map +0 -1
  189. package/lib/Types/Events.d.ts.map +0 -1
  190. package/lib/Types/Events.js.map +0 -1
  191. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  192. package/lib/Types/GroupMetadata.js.map +0 -1
  193. package/lib/Types/Label.d.ts.map +0 -1
  194. package/lib/Types/Label.js.map +0 -1
  195. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  196. package/lib/Types/LabelAssociation.js.map +0 -1
  197. package/lib/Types/Message.d.ts.map +0 -1
  198. package/lib/Types/Message.js.map +0 -1
  199. package/lib/Types/Mex.d.ts.map +0 -1
  200. package/lib/Types/Mex.js.map +0 -1
  201. package/lib/Types/Product.d.ts.map +0 -1
  202. package/lib/Types/Product.js.map +0 -1
  203. package/lib/Types/Signal.d.ts.map +0 -1
  204. package/lib/Types/Signal.js.map +0 -1
  205. package/lib/Types/Socket.d.ts.map +0 -1
  206. package/lib/Types/Socket.js.map +0 -1
  207. package/lib/Types/State.d.ts.map +0 -1
  208. package/lib/Types/State.js.map +0 -1
  209. package/lib/Types/USync.d.ts.map +0 -1
  210. package/lib/Types/USync.js.map +0 -1
  211. package/lib/Types/index.d.ts.map +0 -1
  212. package/lib/Types/index.js.map +0 -1
  213. package/lib/Utils/auth-utils.d.ts.map +0 -1
  214. package/lib/Utils/auth-utils.js.map +0 -1
  215. package/lib/Utils/browser-utils.d.ts.map +0 -1
  216. package/lib/Utils/browser-utils.js.map +0 -1
  217. package/lib/Utils/business.d.ts.map +0 -1
  218. package/lib/Utils/business.js.map +0 -1
  219. package/lib/Utils/button-handler.d.ts +0 -28
  220. package/lib/Utils/button-handler.d.ts.map +0 -1
  221. package/lib/Utils/button-handler.js +0 -140
  222. package/lib/Utils/button-handler.js.map +0 -1
  223. package/lib/Utils/chat-utils.d.ts.map +0 -1
  224. package/lib/Utils/chat-utils.js.map +0 -1
  225. package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
  226. package/lib/Utils/companion-reg-client-utils.js.map +0 -1
  227. package/lib/Utils/crypto.d.ts.map +0 -1
  228. package/lib/Utils/crypto.js.map +0 -1
  229. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  230. package/lib/Utils/decode-wa-message.js.map +0 -1
  231. package/lib/Utils/event-buffer.d.ts.map +0 -1
  232. package/lib/Utils/event-buffer.js.map +0 -1
  233. package/lib/Utils/generics.d.ts.map +0 -1
  234. package/lib/Utils/generics.js.map +0 -1
  235. package/lib/Utils/history.d.ts.map +0 -1
  236. package/lib/Utils/history.js.map +0 -1
  237. package/lib/Utils/identity-change-handler.d.ts.map +0 -1
  238. package/lib/Utils/identity-change-handler.js.map +0 -1
  239. package/lib/Utils/index.d.ts.map +0 -1
  240. package/lib/Utils/index.js.map +0 -1
  241. package/lib/Utils/interactive.d.ts +0 -60
  242. package/lib/Utils/interactive.d.ts.map +0 -1
  243. package/lib/Utils/interactive.js +0 -224
  244. package/lib/Utils/interactive.js.map +0 -1
  245. package/lib/Utils/link-preview.d.ts.map +0 -1
  246. package/lib/Utils/link-preview.js.map +0 -1
  247. package/lib/Utils/logger.d.ts.map +0 -1
  248. package/lib/Utils/logger.js.map +0 -1
  249. package/lib/Utils/lt-hash.d.ts.map +0 -1
  250. package/lib/Utils/lt-hash.js.map +0 -1
  251. package/lib/Utils/make-mutex.d.ts.map +0 -1
  252. package/lib/Utils/make-mutex.js.map +0 -1
  253. package/lib/Utils/message-composer.d.ts +0 -93
  254. package/lib/Utils/message-composer.d.ts.map +0 -1
  255. package/lib/Utils/message-composer.js +0 -311
  256. package/lib/Utils/message-composer.js.map +0 -1
  257. package/lib/Utils/message-retry-manager.d.ts.map +0 -1
  258. package/lib/Utils/message-retry-manager.js.map +0 -1
  259. package/lib/Utils/messages-media.d.ts.map +0 -1
  260. package/lib/Utils/messages-media.js.map +0 -1
  261. package/lib/Utils/messages-newsletter.d.ts +0 -74
  262. package/lib/Utils/messages-newsletter.d.ts.map +0 -1
  263. package/lib/Utils/messages-newsletter.js +0 -128
  264. package/lib/Utils/messages-newsletter.js.map +0 -1
  265. package/lib/Utils/messages.d.ts.map +0 -1
  266. package/lib/Utils/messages.js.map +0 -1
  267. package/lib/Utils/noise-handler.d.ts.map +0 -1
  268. package/lib/Utils/noise-handler.js.map +0 -1
  269. package/lib/Utils/offline-node-processor.d.ts.map +0 -1
  270. package/lib/Utils/offline-node-processor.js.map +0 -1
  271. package/lib/Utils/pre-key-manager.d.ts.map +0 -1
  272. package/lib/Utils/pre-key-manager.js.map +0 -1
  273. package/lib/Utils/process-message.d.ts.map +0 -1
  274. package/lib/Utils/process-message.js.map +0 -1
  275. package/lib/Utils/reporting-utils.d.ts.map +0 -1
  276. package/lib/Utils/reporting-utils.js.map +0 -1
  277. package/lib/Utils/shortcake-crypto.d.ts +0 -36
  278. package/lib/Utils/shortcake-crypto.d.ts.map +0 -1
  279. package/lib/Utils/shortcake-crypto.js +0 -71
  280. package/lib/Utils/shortcake-crypto.js.map +0 -1
  281. package/lib/Utils/shortcake.d.ts +0 -36
  282. package/lib/Utils/shortcake.d.ts.map +0 -1
  283. package/lib/Utils/shortcake.js +0 -162
  284. package/lib/Utils/shortcake.js.map +0 -1
  285. package/lib/Utils/signal.d.ts.map +0 -1
  286. package/lib/Utils/signal.js.map +0 -1
  287. package/lib/Utils/stanza-ack.d.ts.map +0 -1
  288. package/lib/Utils/stanza-ack.js.map +0 -1
  289. package/lib/Utils/sync-action-utils.d.ts.map +0 -1
  290. package/lib/Utils/sync-action-utils.js.map +0 -1
  291. package/lib/Utils/tc-token-utils.d.ts.map +0 -1
  292. package/lib/Utils/tc-token-utils.js.map +0 -1
  293. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  294. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  295. package/lib/Utils/use-single-file-auth-state.d.ts +0 -6
  296. package/lib/Utils/use-single-file-auth-state.d.ts.map +0 -1
  297. package/lib/Utils/use-single-file-auth-state.js +0 -111
  298. package/lib/Utils/use-single-file-auth-state.js.map +0 -1
  299. package/lib/Utils/use-sqlite-auth-state.d.ts +0 -14
  300. package/lib/Utils/use-sqlite-auth-state.d.ts.map +0 -1
  301. package/lib/Utils/use-sqlite-auth-state.js +0 -107
  302. package/lib/Utils/use-sqlite-auth-state.js.map +0 -1
  303. package/lib/Utils/validate-connection.d.ts.map +0 -1
  304. package/lib/Utils/validate-connection.js.map +0 -1
  305. package/lib/WABinary/constants.d.ts.map +0 -1
  306. package/lib/WABinary/constants.js.map +0 -1
  307. package/lib/WABinary/decode.d.ts.map +0 -1
  308. package/lib/WABinary/decode.js.map +0 -1
  309. package/lib/WABinary/encode.d.ts.map +0 -1
  310. package/lib/WABinary/encode.js.map +0 -1
  311. package/lib/WABinary/generic-utils.d.ts.map +0 -1
  312. package/lib/WABinary/generic-utils.js.map +0 -1
  313. package/lib/WABinary/index.d.ts.map +0 -1
  314. package/lib/WABinary/index.js.map +0 -1
  315. package/lib/WABinary/jid-utils.d.ts.map +0 -1
  316. package/lib/WABinary/jid-utils.js.map +0 -1
  317. package/lib/WABinary/types.d.ts.map +0 -1
  318. package/lib/WABinary/types.js.map +0 -1
  319. package/lib/WAM/BinaryInfo.d.ts.map +0 -1
  320. package/lib/WAM/BinaryInfo.js.map +0 -1
  321. package/lib/WAM/constants.d.ts.map +0 -1
  322. package/lib/WAM/constants.js.map +0 -1
  323. package/lib/WAM/encode.d.ts.map +0 -1
  324. package/lib/WAM/encode.js.map +0 -1
  325. package/lib/WAM/index.d.ts.map +0 -1
  326. package/lib/WAM/index.js.map +0 -1
  327. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
  328. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
  329. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
  330. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
  331. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
  332. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
  333. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
  334. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
  335. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
  336. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
  337. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
  338. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
  339. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
  340. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
  341. package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
  342. package/lib/WAUSync/Protocols/index.js.map +0 -1
  343. package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
  344. package/lib/WAUSync/USyncQuery.js.map +0 -1
  345. package/lib/WAUSync/USyncUser.d.ts.map +0 -1
  346. package/lib/WAUSync/USyncUser.js.map +0 -1
  347. package/lib/WAUSync/index.d.ts.map +0 -1
  348. package/lib/WAUSync/index.js.map +0 -1
  349. package/lib/index.d.ts.map +0 -1
  350. package/lib/index.js.map +0 -1
@@ -14,7 +14,7 @@ export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public
14
14
  mixIntoKey: (data: Uint8Array) => void;
15
15
  finishInit: () => Promise<void>;
16
16
  processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Uint8Array<ArrayBufferLike>;
17
- encodeFrame: (data: Buffer | Uint8Array) => Buffer<ArrayBuffer>;
17
+ encodeFrame: (data: Buffer | Uint8Array) => Buffer;
18
18
  decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>;
19
19
  };
20
20
  //# sourceMappingURL=noise-handler.d.ts.map
@@ -1,4 +1,3 @@
1
- import { Boom } from '@hapi/boom';
2
1
  import { proto } from '../../WAProto/index.js';
3
2
  import { WAMessageStubType } from '../Types/index.js';
4
3
  import { getContentType, normalizeMessageContent } from '../Utils/messages.js';
@@ -6,7 +5,6 @@ import { areJidsSameUser, isHostedLidUser, isHostedPnUser, isJidBroadcast, isJid
6
5
  import { aesDecryptGCM, hmacSign } from './crypto.js';
7
6
  import { getKeyAuthor, toNumber } from './generics.js';
8
7
  import { downloadAndProcessHistorySyncNotification } from './history.js';
9
- import { buildMergedTcTokenIndexWrite, resolveTcTokenJid } from './tc-token-utils.js';
10
8
  const REAL_MSG_STUB_TYPES = new Set([
11
9
  WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
12
10
  WAMessageStubType.CALL_MISSED_GROUP_VOICE,
@@ -14,53 +12,6 @@ const REAL_MSG_STUB_TYPES = new Set([
14
12
  WAMessageStubType.CALL_MISSED_VOICE
15
13
  ]);
16
14
  const REAL_MSG_REQ_ME_STUB_TYPES = new Set([WAMessageStubType.GROUP_PARTICIPANT_ADD]);
17
- async function storeTcTokensFromHistorySync(chats, signalRepository, keyStore, logger) {
18
- const getLIDForPN = signalRepository.lidMapping.getLIDForPN.bind(signalRepository.lidMapping);
19
- const candidates = [];
20
- for (const chat of chats) {
21
- const ts = chat.tcTokenTimestamp ? toNumber(chat.tcTokenTimestamp) : 0;
22
- if (chat.tcToken?.length && ts > 0) {
23
- const jid = jidNormalizedUser(chat.id);
24
- const storageJid = await resolveTcTokenJid(jid, getLIDForPN);
25
- candidates.push({
26
- storageJid,
27
- token: Buffer.from(chat.tcToken),
28
- ts,
29
- senderTs: chat.tcTokenSenderTimestamp ? toNumber(chat.tcTokenSenderTimestamp) : undefined
30
- });
31
- }
32
- }
33
- if (!candidates.length) {
34
- return;
35
- }
36
- const jids = candidates.map(c => c.storageJid);
37
- const existing = await keyStore.get('tctoken', jids);
38
- const entries = {};
39
- for (const c of candidates) {
40
- const existingEntry = existing[c.storageJid];
41
- const existingTs = existingEntry?.timestamp ? Number(existingEntry.timestamp) : 0;
42
- if (existingTs > 0 && existingTs >= c.ts) {
43
- continue;
44
- }
45
- entries[c.storageJid] = {
46
- ...existingEntry,
47
- token: c.token,
48
- timestamp: String(c.ts),
49
- ...(c.senderTs !== undefined ? { senderTimestamp: c.senderTs } : {})
50
- };
51
- }
52
- if (Object.keys(entries).length) {
53
- logger?.debug({ count: Object.keys(entries).length }, 'storing tctokens from history sync');
54
- try {
55
- // Include updated __index so cross-session pruning picks these JIDs up.
56
- const indexWrite = await buildMergedTcTokenIndexWrite(keyStore, Object.keys(entries));
57
- await keyStore.set({ tctoken: { ...entries, ...indexWrite } });
58
- }
59
- catch (err) {
60
- logger?.warn({ err }, 'failed to store tctokens from history sync');
61
- }
62
- }
63
- }
64
15
  /** Cleans a received message to further processing */
65
16
  export const cleanMessage = (message, meId, meLid) => {
66
17
  // ensure remoteJid and participant doesn't have device or agent in it
@@ -122,17 +73,7 @@ export const shouldIncrementChatUnread = (message) => !message.key.fromMe && !me
122
73
  * Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
123
74
  */
124
75
  export const getChatId = ({ remoteJid, participant, fromMe }) => {
125
- if (!remoteJid) {
126
- throw new Boom('Cannot derive chat id: message key is missing remoteJid', {
127
- data: { remoteJid, participant, fromMe }
128
- });
129
- }
130
76
  if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
131
- if (!participant) {
132
- throw new Boom('Cannot derive chat id: broadcast message key is missing participant', {
133
- data: { remoteJid, fromMe }
134
- });
135
- }
136
77
  return participant;
137
78
  }
138
79
  return remoteJid;
@@ -205,39 +146,6 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
205
146
  }
206
147
  const protocolMsg = content?.protocolMessage;
207
148
  if (protocolMsg) {
208
- // Mirror whatsmeow's `handleProtocolMessage` guard, but applied only to
209
- // the protocol message types that originate from our own device — an
210
- // attacker could otherwise spoof any of these to manipulate local state.
211
- //
212
- // Self-only types (drop if `!fromMe`):
213
- // - HISTORY_SYNC_NOTIFICATION (our phone driving history sync)
214
- // - APP_STATE_SYNC_KEY_SHARE (key share between our devices)
215
- // - LID_MIGRATION_MAPPING_SYNC (server-initiated via our phone)
216
- // - PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE (response from our phone to our PDO request)
217
- //
218
- // Cross-user types (must NOT be dropped — legitimately arrive from others):
219
- // - REVOKE
220
- // - MESSAGE_EDIT
221
- // - EPHEMERAL_SETTING
222
- // - GROUP_MEMBER_LABEL_CHANGE
223
- //
224
- // See https://github.com/tulir/whatsmeow/blob/8d3700152a/message.go#L842-L845
225
- // for the reference architecture — whatsmeow's `handleProtocolMessage`
226
- // only contains self-only types because edits are unwrapped from
227
- // `EditedMessage` BEFORE this dispatch and revokes aren't routed here.
228
- const SELF_ONLY_TYPES = new Set([
229
- proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION,
230
- proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE,
231
- proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC,
232
- proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE
233
- ]);
234
- if (protocolMsg.type !== null &&
235
- protocolMsg.type !== undefined &&
236
- SELF_ONLY_TYPES.has(protocolMsg.type) &&
237
- !message.key.fromMe) {
238
- logger?.warn({ msgId: message.key.id, type: protocolMsg.type, from: message.key.participant || message.key.remoteJid }, 'dropping spoofed self-only protocolMessage from non-self origin');
239
- return;
240
- }
241
149
  switch (protocolMsg.type) {
242
150
  case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
243
151
  const histNotification = protocolMsg.historySyncNotification;
@@ -266,11 +174,9 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
266
174
  .storeLIDPNMappings(data.lidPnMappings)
267
175
  .catch(err => logger?.warn({ err }, 'failed to store LID-PN mappings from history sync'));
268
176
  }
269
- await storeTcTokensFromHistorySync(data.chats, signalRepository, keyStore, logger);
270
177
  ev.emit('messaging-history.set', {
271
178
  ...data,
272
179
  isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
273
- chunkOrder: histNotification.chunkOrder,
274
180
  peerDataRequestSessionId: histNotification.peerDataRequestSessionId
275
181
  });
276
182
  }
@@ -477,19 +383,12 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
477
383
  id: jid,
478
384
  author: message.key.participant,
479
385
  authorPn: message.key.participantAlt,
480
- authorUsername: message.key.participantUsername,
481
386
  participants,
482
387
  action
483
388
  });
484
389
  const emitGroupUpdate = (update) => {
485
390
  ev.emit('groups.update', [
486
- {
487
- id: jid,
488
- ...update,
489
- author: message.key.participant ?? undefined,
490
- authorPn: message.key.participantAlt,
491
- authorUsername: message.key.participantUsername
492
- }
391
+ { id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
493
392
  ]);
494
393
  };
495
394
  const emitGroupRequestJoin = (participant, action, method) => {
@@ -497,7 +396,6 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
497
396
  id: jid,
498
397
  author: message.key.participant,
499
398
  authorPn: message.key.participantAlt,
500
- authorUsername: message.key.participantUsername,
501
399
  participant: participant.lid,
502
400
  participantPn: participant.pn,
503
401
  action,
@@ -0,0 +1,277 @@
1
+ import { proto } from "../../WAProto/index.js";
2
+ export declare const JS_KEYWORDS: Set<string>;
3
+ export declare const PYTHON_KEYWORDS: Set<string>;
4
+ export declare const GO_KEYWORDS: Set<string>;
5
+ export declare const LUA_KEYWORDS: Set<string>;
6
+ export declare const BASH_KEYWORDS: Set<string>;
7
+ export declare const LANGUAGE_KEYWORDS: Record<string, Set<string>>;
8
+ export declare enum CodeHighlightType {
9
+ DEFAULT = 0,
10
+ KEYWORD = 1,
11
+ METHOD = 2,
12
+ STRING = 3,
13
+ NUMBER = 4,
14
+ COMMENT = 5,
15
+ }
16
+ export declare enum RichSubMessageType {
17
+ UNKNOWN = 0,
18
+ GRID_IMAGE = 1,
19
+ TEXT = 2,
20
+ INLINE_IMAGE = 3,
21
+ TABLE = 4,
22
+ CODE = 5,
23
+ DYNAMIC = 6,
24
+ MAP = 7,
25
+ LATEX = 8,
26
+ CONTENT_ITEMS = 9,
27
+ }
28
+ export interface RichMessageOptions {
29
+ headerText?: string;
30
+ footer?: string;
31
+ title?: string;
32
+ language?: string;
33
+ }
34
+ export interface CodeBlockOptions extends RichMessageOptions {
35
+ language?: string;
36
+ }
37
+ export interface LatexExpression {
38
+ latexExpression: string;
39
+ url: string;
40
+ width: number;
41
+ height: number;
42
+ fontHeight?: number;
43
+ imageTopPadding?: number;
44
+ imageLeadingPadding?: number;
45
+ imageBottomPadding?: number;
46
+ imageTrailingPadding?: number;
47
+ }
48
+ export interface LatexOptions extends RichMessageOptions {
49
+ text?: string;
50
+ expressions: LatexExpression[];
51
+ }
52
+ export interface LatexImageOptions extends RichMessageOptions {
53
+ text?: string;
54
+ expressions: {
55
+ latexExpression: string;
56
+ }[];
57
+ }
58
+ export type LatexRenderFn = (latex: string) => Promise<{
59
+ buffer: Buffer;
60
+ width: number;
61
+ height: number;
62
+ }>;
63
+ export type MediaUploadFn = (
64
+ imageBuffer: Buffer,
65
+ mediaType: string,
66
+ ) => Promise<{
67
+ url: string;
68
+ directPath: string;
69
+ }>;
70
+ export interface UnifiedResponseOptions {
71
+ data: Buffer | Uint8Array;
72
+ headerText?: string;
73
+ footer?: string;
74
+ }
75
+ export interface CapturedUnifiedResponse {
76
+ unifiedResponse: {
77
+ data: Uint8Array;
78
+ };
79
+ submessages: any[];
80
+ contextInfo: any;
81
+ }
82
+ export interface QuotedMessage {
83
+ key: {
84
+ id?: string | null;
85
+ participant?: string | null;
86
+ remoteJid?: string | null;
87
+ fromMe?: boolean | null;
88
+ };
89
+ sender?: string;
90
+ message?: proto.IMessage | null;
91
+ }
92
+ interface CodeToken {
93
+ highlightType: number;
94
+ codeContent: string;
95
+ }
96
+ export declare const tokenizeCode: (
97
+ codeStr: string,
98
+ language?: string,
99
+ ) => CodeToken[];
100
+ export declare const buildRichContextInfo: (
101
+ quoted?: QuotedMessage | null,
102
+ ) => Record<string, any>;
103
+ export declare const buildBotForwardedMessage: (
104
+ submessages: any[],
105
+ contextInfo: Record<string, any>,
106
+ unifiedResponse?: {
107
+ data: Buffer | Uint8Array;
108
+ } | null,
109
+ ) => any;
110
+ export declare const generateTableContent: (
111
+ title: string,
112
+ headers: string[],
113
+ rows: string[][],
114
+ quoted?: QuotedMessage | null,
115
+ options?: RichMessageOptions,
116
+ ) => {
117
+ message: any;
118
+ messageId: string;
119
+ };
120
+ export declare const generateListContent: (
121
+ title: string,
122
+ items: (string | string[])[],
123
+ quoted?: QuotedMessage | null,
124
+ options?: RichMessageOptions,
125
+ ) => {
126
+ message: any;
127
+ messageId: string;
128
+ };
129
+ export declare const generateCodeBlockContent: (
130
+ code: string,
131
+ quoted?: QuotedMessage | null,
132
+ options?: CodeBlockOptions,
133
+ ) => {
134
+ message: any;
135
+ messageId: string;
136
+ };
137
+ export declare const generateLatexContent: (
138
+ quoted: QuotedMessage | null | undefined,
139
+ options: LatexOptions,
140
+ ) => {
141
+ message: any;
142
+ messageId: string;
143
+ };
144
+ export declare const generateLatexImageContent: (
145
+ quoted: QuotedMessage | null | undefined,
146
+ options: LatexImageOptions,
147
+ uploadFn: MediaUploadFn,
148
+ renderLatexToPng: LatexRenderFn,
149
+ ) => Promise<{
150
+ message: any;
151
+ messageId: string;
152
+ }>;
153
+ export declare const generateLatexInlineImageContent: (
154
+ quoted: QuotedMessage | null | undefined,
155
+ options: LatexImageOptions,
156
+ uploadFn: MediaUploadFn,
157
+ renderLatexToPng: LatexRenderFn,
158
+ ) => Promise<{
159
+ message: any;
160
+ messageId: string;
161
+ }>;
162
+ export declare const captureUnifiedResponse: (
163
+ msg: proto.IMessage,
164
+ ) => CapturedUnifiedResponse | null;
165
+ export declare const generateUnifiedResponseContent: (
166
+ quoted: QuotedMessage | null | undefined,
167
+ captured: CapturedUnifiedResponse,
168
+ ) => {
169
+ message: any;
170
+ messageId: string;
171
+ };
172
+ export declare const generateRichMessageContent: (
173
+ submessages: any[],
174
+ quoted?: QuotedMessage | null,
175
+ ) => {
176
+ message: any;
177
+ messageId: string;
178
+ };
179
+ export interface CodeBlockV2Options extends RichMessageOptions {
180
+ language?: string;
181
+ text?: string;
182
+ }
183
+ interface UnifiedCodeToken {
184
+ content: string;
185
+ type: "DEFAULT" | "KEYWORD" | "METHOD" | "STR" | "NUMBER" | "COMMENT";
186
+ }
187
+ interface TokenizeCodeV2Result {
188
+ codeBlock: CodeToken[];
189
+ unified_codeBlock: UnifiedCodeToken[];
190
+ }
191
+ export declare const tokenizeCodeV2: (
192
+ code: string,
193
+ language?: string,
194
+ ) => TokenizeCodeV2Result;
195
+ interface UnifiedTableRow {
196
+ is_header: boolean;
197
+ cells: string[];
198
+ }
199
+ interface TableMetadataV2Result {
200
+ title: string;
201
+ rows: {
202
+ items: string[];
203
+ isHeading?: boolean;
204
+ }[];
205
+ unified_rows: UnifiedTableRow[];
206
+ }
207
+ export declare const toTableMetadataV2: (
208
+ arr: string[],
209
+ ) => TableMetadataV2Result;
210
+ export interface TableV2Options extends RichMessageOptions {
211
+ text?: string;
212
+ }
213
+ export declare const generateTableContentV2: (
214
+ table: string[],
215
+ quoted?: QuotedMessage | null,
216
+ options?: TableV2Options,
217
+ ) => {
218
+ message: any;
219
+ messageId: string;
220
+ };
221
+ export declare const generateCodeBlockContentV2: (
222
+ code: string,
223
+ quoted?: QuotedMessage | null,
224
+ options?: CodeBlockV2Options,
225
+ ) => {
226
+ message: any;
227
+ messageId: string;
228
+ };
229
+ export interface Citation {
230
+ sourceQuery?: string;
231
+ faviconCdnUrl?: string;
232
+ citationNumber?: number;
233
+ sourceTitle?: string;
234
+ }
235
+ export interface Proof {
236
+ version?: number;
237
+ useCase?: number;
238
+ signature?: string;
239
+ certificateChain?: string[];
240
+ }
241
+ export interface LinkMessageOptions extends RichMessageOptions {
242
+ botJid?: string;
243
+ forwardingScore?: number;
244
+ citations?: Citation[];
245
+ proofs?: Proof[];
246
+ }
247
+ export interface LinkV2MessageOptions extends RichMessageOptions {
248
+ searchEngine?: string;
249
+ }
250
+ export declare const generateLinkContent: (
251
+ text: string,
252
+ links: (string | { url: string; displayName?: string })[],
253
+ quoted?: QuotedMessage | null,
254
+ options?: LinkMessageOptions,
255
+ ) => {
256
+ message: any;
257
+ messageId: string;
258
+ };
259
+ export declare const generateLinkContentV2: (
260
+ text: string,
261
+ links: (
262
+ | string
263
+ | {
264
+ url: string;
265
+ displayName?: string;
266
+ sourceDisplayName?: string;
267
+ sourceSubtitle?: string;
268
+ }
269
+ )[],
270
+ quoted?: QuotedMessage | null,
271
+ options?: LinkV2MessageOptions,
272
+ ) => {
273
+ message: any;
274
+ messageId: string;
275
+ };
276
+ export {};
277
+ //# sourceMappingURL=rich-messages.d.ts.map