@d0v3riz/baileys 6.7.21 → 6.7.22

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 (356) hide show
  1. package/WAProto/GenerateStatics.sh +2 -3
  2. package/WAProto/index.js +4138 -4136
  3. package/lib/Defaults/index.d.ts +2 -3
  4. package/lib/Defaults/index.js +40 -36
  5. package/lib/Signal/Group/ciphertext-message.d.ts +0 -1
  6. package/lib/Signal/Group/ciphertext-message.js +5 -2
  7. package/lib/Signal/Group/group-session-builder.d.ts +3 -4
  8. package/lib/Signal/Group/group-session-builder.js +41 -7
  9. package/lib/Signal/Group/group_cipher.d.ts +2 -3
  10. package/lib/Signal/Group/group_cipher.js +16 -14
  11. package/lib/Signal/Group/index.d.ts +11 -12
  12. package/lib/Signal/Group/index.js +57 -12
  13. package/lib/Signal/Group/keyhelper.d.ts +1 -2
  14. package/lib/Signal/Group/keyhelper.js +44 -8
  15. package/lib/Signal/Group/queue-job.d.ts +0 -2
  16. package/lib/Signal/Group/queue-job.js +5 -5
  17. package/lib/Signal/Group/sender-chain-key.d.ts +1 -2
  18. package/lib/Signal/Group/sender-chain-key.js +9 -7
  19. package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -2
  20. package/lib/Signal/Group/sender-key-distribution-message.js +9 -6
  21. package/lib/Signal/Group/sender-key-message.d.ts +1 -2
  22. package/lib/Signal/Group/sender-key-message.js +12 -10
  23. package/lib/Signal/Group/sender-key-name.d.ts +0 -1
  24. package/lib/Signal/Group/sender-key-name.js +5 -2
  25. package/lib/Signal/Group/sender-key-record.d.ts +1 -2
  26. package/lib/Signal/Group/sender-key-record.js +12 -9
  27. package/lib/Signal/Group/sender-key-state.d.ts +2 -3
  28. package/lib/Signal/Group/sender-key-state.js +9 -6
  29. package/lib/Signal/Group/sender-message-key.d.ts +0 -1
  30. package/lib/Signal/Group/sender-message-key.js +7 -5
  31. package/lib/Signal/libsignal.d.ts +2 -3
  32. package/lib/Signal/libsignal.js +55 -22
  33. package/lib/Socket/Client/index.d.ts +2 -3
  34. package/lib/Socket/Client/index.js +18 -3
  35. package/lib/Socket/Client/types.d.ts +1 -2
  36. package/lib/Socket/Client/types.js +6 -4
  37. package/lib/Socket/Client/websocket.d.ts +1 -2
  38. package/lib/Socket/Client/websocket.js +26 -14
  39. package/lib/Socket/business.d.ts +64 -66
  40. package/lib/Socket/business.js +37 -32
  41. package/lib/Socket/chats.d.ts +19 -21
  42. package/lib/Socket/chats.js +141 -176
  43. package/lib/Socket/groups.d.ts +35 -37
  44. package/lib/Socket/groups.js +63 -56
  45. package/lib/Socket/index.d.ts +70 -102
  46. package/lib/Socket/index.js +9 -16
  47. package/lib/Socket/messages-recv.d.ts +49 -51
  48. package/lib/Socket/messages-recv.js +173 -180
  49. package/lib/Socket/messages-send.d.ts +46 -48
  50. package/lib/Socket/messages-send.js +84 -75
  51. package/lib/Socket/mex.d.ts +1 -2
  52. package/lib/Socket/mex.js +16 -12
  53. package/lib/Socket/newsletter.d.ts +44 -46
  54. package/lib/Socket/newsletter.js +27 -23
  55. package/lib/Socket/socket.d.ts +12 -13
  56. package/lib/Socket/socket.js +115 -135
  57. package/lib/Socket/usync.d.ts +14 -15
  58. package/lib/Socket/usync.js +11 -9
  59. package/lib/Types/Auth.d.ts +3 -4
  60. package/lib/Types/Auth.js +2 -2
  61. package/lib/Types/Call.d.ts +0 -1
  62. package/lib/Types/Call.js +2 -2
  63. package/lib/Types/Chat.d.ts +7 -10
  64. package/lib/Types/Chat.js +4 -2
  65. package/lib/Types/Contact.d.ts +0 -1
  66. package/lib/Types/Contact.js +2 -2
  67. package/lib/Types/Events.d.ts +10 -11
  68. package/lib/Types/Events.js +2 -2
  69. package/lib/Types/GroupMetadata.d.ts +2 -3
  70. package/lib/Types/GroupMetadata.js +2 -2
  71. package/lib/Types/Label.d.ts +0 -1
  72. package/lib/Types/Label.js +5 -3
  73. package/lib/Types/LabelAssociation.d.ts +0 -1
  74. package/lib/Types/LabelAssociation.js +5 -3
  75. package/lib/Types/Message.d.ts +7 -9
  76. package/lib/Types/Message.js +7 -7
  77. package/lib/Types/Newsletter.d.ts +0 -1
  78. package/lib/Types/Newsletter.js +7 -5
  79. package/lib/Types/Product.d.ts +1 -2
  80. package/lib/Types/Product.js +2 -2
  81. package/lib/Types/Signal.d.ts +1 -2
  82. package/lib/Types/Signal.js +2 -2
  83. package/lib/Types/Socket.d.ts +7 -8
  84. package/lib/Types/Socket.js +2 -3
  85. package/lib/Types/State.d.ts +2 -14
  86. package/lib/Types/State.js +2 -13
  87. package/lib/Types/USync.d.ts +2 -3
  88. package/lib/Types/USync.js +2 -2
  89. package/lib/Types/index.d.ts +14 -15
  90. package/lib/Types/index.js +31 -15
  91. package/lib/Utils/auth-utils.d.ts +2 -3
  92. package/lib/Utils/auth-utils.js +34 -25
  93. package/lib/Utils/baileys-event-stream.d.ts +1 -2
  94. package/lib/Utils/baileys-event-stream.js +22 -15
  95. package/lib/Utils/business.d.ts +2 -3
  96. package/lib/Utils/business.js +70 -61
  97. package/lib/Utils/chat-utils.d.ts +7 -8
  98. package/lib/Utils/chat-utils.js +137 -130
  99. package/lib/Utils/crypto.d.ts +1 -2
  100. package/lib/Utils/crypto.js +86 -37
  101. package/lib/Utils/decode-wa-message.d.ts +4 -5
  102. package/lib/Utils/decode-wa-message.js +44 -38
  103. package/lib/Utils/event-buffer.d.ts +4 -4
  104. package/lib/Utils/event-buffer.js +50 -37
  105. package/lib/Utils/generics.d.ts +8 -9
  106. package/lib/Utils/generics.js +114 -87
  107. package/lib/Utils/history.d.ts +3 -4
  108. package/lib/Utils/history.js +40 -32
  109. package/lib/Utils/index.d.ts +17 -18
  110. package/lib/Utils/index.js +33 -18
  111. package/lib/Utils/link-preview.d.ts +3 -4
  112. package/lib/Utils/link-preview.js +47 -10
  113. package/lib/Utils/logger.d.ts +6 -8
  114. package/lib/Utils/logger.js +7 -3
  115. package/lib/Utils/lt-hash.d.ts +8 -9
  116. package/lib/Utils/lt-hash.js +26 -23
  117. package/lib/Utils/make-mutex.d.ts +0 -1
  118. package/lib/Utils/make-mutex.js +9 -5
  119. package/lib/Utils/messages-media.d.ts +10 -11
  120. package/lib/Utils/messages-media.js +203 -141
  121. package/lib/Utils/messages.d.ts +6 -7
  122. package/lib/Utils/messages.js +199 -190
  123. package/lib/Utils/noise-handler.d.ts +4 -5
  124. package/lib/Utils/noise-handler.js +26 -22
  125. package/lib/Utils/process-message.d.ts +4 -5
  126. package/lib/Utils/process-message.js +104 -95
  127. package/lib/Utils/signal.d.ts +4 -5
  128. package/lib/Utils/signal.js +52 -47
  129. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  130. package/lib/Utils/use-multi-file-auth-state.js +26 -23
  131. package/lib/Utils/validate-connection.d.ts +3 -4
  132. package/lib/Utils/validate-connection.js +58 -52
  133. package/lib/WABinary/constants.d.ts +0 -1
  134. package/lib/WABinary/constants.js +11 -9
  135. package/lib/WABinary/decode.d.ts +1 -2
  136. package/lib/WABinary/decode.js +51 -13
  137. package/lib/WABinary/encode.d.ts +1 -2
  138. package/lib/WABinary/encode.js +41 -5
  139. package/lib/WABinary/generic-utils.d.ts +3 -4
  140. package/lib/WABinary/generic-utils.js +38 -30
  141. package/lib/WABinary/index.d.ts +5 -6
  142. package/lib/WABinary/index.js +21 -6
  143. package/lib/WABinary/jid-utils.d.ts +0 -1
  144. package/lib/WABinary/jid-utils.js +35 -21
  145. package/lib/WABinary/types.d.ts +1 -2
  146. package/lib/WABinary/types.js +2 -2
  147. package/lib/WAM/BinaryInfo.d.ts +1 -2
  148. package/lib/WAM/BinaryInfo.js +5 -2
  149. package/lib/WAM/constants.d.ts +0 -1
  150. package/lib/WAM/constants.js +6 -4
  151. package/lib/WAM/encode.d.ts +1 -2
  152. package/lib/WAM/encode.js +14 -12
  153. package/lib/WAM/index.d.ts +3 -4
  154. package/lib/WAM/index.js +19 -4
  155. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
  156. package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -6
  157. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
  158. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +12 -9
  159. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
  160. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -6
  161. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
  162. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +11 -7
  163. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
  164. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +21 -19
  165. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -3
  166. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +5 -2
  167. package/lib/WAUSync/Protocols/index.d.ts +4 -5
  168. package/lib/WAUSync/Protocols/index.js +20 -5
  169. package/lib/WAUSync/USyncQuery.d.ts +3 -4
  170. package/lib/WAUSync/USyncQuery.js +20 -18
  171. package/lib/WAUSync/USyncUser.d.ts +5 -6
  172. package/lib/WAUSync/USyncUser.js +5 -2
  173. package/lib/WAUSync/index.d.ts +3 -4
  174. package/lib/WAUSync/index.js +19 -4
  175. package/lib/index.d.ts +8 -9
  176. package/lib/index.js +30 -11
  177. package/package.json +26 -26
  178. package/WAProto/fix-imports.js +0 -29
  179. package/lib/Defaults/index.d.ts.map +0 -1
  180. package/lib/Defaults/index.js.map +0 -1
  181. package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
  182. package/lib/Signal/Group/ciphertext-message.js.map +0 -1
  183. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  184. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  185. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  186. package/lib/Signal/Group/group_cipher.js.map +0 -1
  187. package/lib/Signal/Group/index.d.ts.map +0 -1
  188. package/lib/Signal/Group/index.js.map +0 -1
  189. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  190. package/lib/Signal/Group/keyhelper.js.map +0 -1
  191. package/lib/Signal/Group/queue-job.d.ts.map +0 -1
  192. package/lib/Signal/Group/queue-job.js.map +0 -1
  193. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  194. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  195. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  196. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  197. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  198. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  199. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  200. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  201. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  202. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  203. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  204. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  205. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  206. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  207. package/lib/Signal/libsignal.d.ts.map +0 -1
  208. package/lib/Signal/libsignal.js.map +0 -1
  209. package/lib/Socket/Client/index.d.ts.map +0 -1
  210. package/lib/Socket/Client/index.js.map +0 -1
  211. package/lib/Socket/Client/types.d.ts.map +0 -1
  212. package/lib/Socket/Client/types.js.map +0 -1
  213. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  214. package/lib/Socket/Client/websocket.js.map +0 -1
  215. package/lib/Socket/business.d.ts.map +0 -1
  216. package/lib/Socket/business.js.map +0 -1
  217. package/lib/Socket/chats.d.ts.map +0 -1
  218. package/lib/Socket/chats.js.map +0 -1
  219. package/lib/Socket/communities.d.ts +0 -219
  220. package/lib/Socket/communities.d.ts.map +0 -1
  221. package/lib/Socket/communities.js +0 -351
  222. package/lib/Socket/communities.js.map +0 -1
  223. package/lib/Socket/groups.d.ts.map +0 -1
  224. package/lib/Socket/groups.js.map +0 -1
  225. package/lib/Socket/index.d.ts.map +0 -1
  226. package/lib/Socket/index.js.map +0 -1
  227. package/lib/Socket/messages-recv.d.ts.map +0 -1
  228. package/lib/Socket/messages-recv.js.map +0 -1
  229. package/lib/Socket/messages-send.d.ts.map +0 -1
  230. package/lib/Socket/messages-send.js.map +0 -1
  231. package/lib/Socket/mex.d.ts.map +0 -1
  232. package/lib/Socket/mex.js.map +0 -1
  233. package/lib/Socket/newsletter.d.ts.map +0 -1
  234. package/lib/Socket/newsletter.js.map +0 -1
  235. package/lib/Socket/socket.d.ts.map +0 -1
  236. package/lib/Socket/socket.js.map +0 -1
  237. package/lib/Socket/usync.d.ts.map +0 -1
  238. package/lib/Socket/usync.js.map +0 -1
  239. package/lib/Types/Auth.d.ts.map +0 -1
  240. package/lib/Types/Auth.js.map +0 -1
  241. package/lib/Types/Call.d.ts.map +0 -1
  242. package/lib/Types/Call.js.map +0 -1
  243. package/lib/Types/Chat.d.ts.map +0 -1
  244. package/lib/Types/Chat.js.map +0 -1
  245. package/lib/Types/Contact.d.ts.map +0 -1
  246. package/lib/Types/Contact.js.map +0 -1
  247. package/lib/Types/Events.d.ts.map +0 -1
  248. package/lib/Types/Events.js.map +0 -1
  249. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  250. package/lib/Types/GroupMetadata.js.map +0 -1
  251. package/lib/Types/Label.d.ts.map +0 -1
  252. package/lib/Types/Label.js.map +0 -1
  253. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  254. package/lib/Types/LabelAssociation.js.map +0 -1
  255. package/lib/Types/Message.d.ts.map +0 -1
  256. package/lib/Types/Message.js.map +0 -1
  257. package/lib/Types/Newsletter.d.ts.map +0 -1
  258. package/lib/Types/Newsletter.js.map +0 -1
  259. package/lib/Types/Product.d.ts.map +0 -1
  260. package/lib/Types/Product.js.map +0 -1
  261. package/lib/Types/Signal.d.ts.map +0 -1
  262. package/lib/Types/Signal.js.map +0 -1
  263. package/lib/Types/Socket.d.ts.map +0 -1
  264. package/lib/Types/Socket.js.map +0 -1
  265. package/lib/Types/State.d.ts.map +0 -1
  266. package/lib/Types/State.js.map +0 -1
  267. package/lib/Types/USync.d.ts.map +0 -1
  268. package/lib/Types/USync.js.map +0 -1
  269. package/lib/Types/index.d.ts.map +0 -1
  270. package/lib/Types/index.js.map +0 -1
  271. package/lib/Utils/auth-utils.d.ts.map +0 -1
  272. package/lib/Utils/auth-utils.js.map +0 -1
  273. package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
  274. package/lib/Utils/baileys-event-stream.js.map +0 -1
  275. package/lib/Utils/business.d.ts.map +0 -1
  276. package/lib/Utils/business.js.map +0 -1
  277. package/lib/Utils/chat-utils.d.ts.map +0 -1
  278. package/lib/Utils/chat-utils.js.map +0 -1
  279. package/lib/Utils/crypto.d.ts.map +0 -1
  280. package/lib/Utils/crypto.js.map +0 -1
  281. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  282. package/lib/Utils/decode-wa-message.js.map +0 -1
  283. package/lib/Utils/event-buffer.d.ts.map +0 -1
  284. package/lib/Utils/event-buffer.js.map +0 -1
  285. package/lib/Utils/generics.d.ts.map +0 -1
  286. package/lib/Utils/generics.js.map +0 -1
  287. package/lib/Utils/history.d.ts.map +0 -1
  288. package/lib/Utils/history.js.map +0 -1
  289. package/lib/Utils/index.d.ts.map +0 -1
  290. package/lib/Utils/index.js.map +0 -1
  291. package/lib/Utils/link-preview.d.ts.map +0 -1
  292. package/lib/Utils/link-preview.js.map +0 -1
  293. package/lib/Utils/logger.d.ts.map +0 -1
  294. package/lib/Utils/logger.js.map +0 -1
  295. package/lib/Utils/lt-hash.d.ts.map +0 -1
  296. package/lib/Utils/lt-hash.js.map +0 -1
  297. package/lib/Utils/make-mutex.d.ts.map +0 -1
  298. package/lib/Utils/make-mutex.js.map +0 -1
  299. package/lib/Utils/messages-media.d.ts.map +0 -1
  300. package/lib/Utils/messages-media.js.map +0 -1
  301. package/lib/Utils/messages.d.ts.map +0 -1
  302. package/lib/Utils/messages.js.map +0 -1
  303. package/lib/Utils/noise-handler.d.ts.map +0 -1
  304. package/lib/Utils/noise-handler.js.map +0 -1
  305. package/lib/Utils/process-message.d.ts.map +0 -1
  306. package/lib/Utils/process-message.js.map +0 -1
  307. package/lib/Utils/signal.d.ts.map +0 -1
  308. package/lib/Utils/signal.js.map +0 -1
  309. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  310. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  311. package/lib/Utils/validate-connection.d.ts.map +0 -1
  312. package/lib/Utils/validate-connection.js.map +0 -1
  313. package/lib/WABinary/constants.d.ts.map +0 -1
  314. package/lib/WABinary/constants.js.map +0 -1
  315. package/lib/WABinary/decode.d.ts.map +0 -1
  316. package/lib/WABinary/decode.js.map +0 -1
  317. package/lib/WABinary/encode.d.ts.map +0 -1
  318. package/lib/WABinary/encode.js.map +0 -1
  319. package/lib/WABinary/generic-utils.d.ts.map +0 -1
  320. package/lib/WABinary/generic-utils.js.map +0 -1
  321. package/lib/WABinary/index.d.ts.map +0 -1
  322. package/lib/WABinary/index.js.map +0 -1
  323. package/lib/WABinary/jid-utils.d.ts.map +0 -1
  324. package/lib/WABinary/jid-utils.js.map +0 -1
  325. package/lib/WABinary/types.d.ts.map +0 -1
  326. package/lib/WABinary/types.js.map +0 -1
  327. package/lib/WAM/BinaryInfo.d.ts.map +0 -1
  328. package/lib/WAM/BinaryInfo.js.map +0 -1
  329. package/lib/WAM/constants.d.ts.map +0 -1
  330. package/lib/WAM/constants.js.map +0 -1
  331. package/lib/WAM/encode.d.ts.map +0 -1
  332. package/lib/WAM/encode.js.map +0 -1
  333. package/lib/WAM/index.d.ts.map +0 -1
  334. package/lib/WAM/index.js.map +0 -1
  335. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
  336. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
  337. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
  338. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
  339. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
  340. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
  341. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
  342. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
  343. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
  344. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
  345. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
  346. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
  347. package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
  348. package/lib/WAUSync/Protocols/index.js.map +0 -1
  349. package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
  350. package/lib/WAUSync/USyncQuery.js.map +0 -1
  351. package/lib/WAUSync/USyncUser.d.ts.map +0 -1
  352. package/lib/WAUSync/USyncUser.js.map +0 -1
  353. package/lib/WAUSync/index.d.ts.map +0 -1
  354. package/lib/WAUSync/index.js.map +0 -1
  355. package/lib/index.d.ts.map +0 -1
  356. package/lib/index.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import type { KeyPair } from '../Types/index.js';
3
- import type { BinaryNode } from '../WABinary/index.js';
4
- import type { ILogger } from './logger.js';
1
+ import { proto } from '../../WAProto';
2
+ import { KeyPair } from '../Types';
3
+ import { BinaryNode } from '../WABinary';
4
+ import { ILogger } from './logger';
5
5
  export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }: {
6
6
  keyPair: KeyPair;
7
7
  NOISE_HEADER: Uint8Array;
@@ -17,4 +17,3 @@ export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public
17
17
  encodeFrame: (data: Buffer | Uint8Array) => Buffer<ArrayBuffer>;
18
18
  decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>;
19
19
  };
20
- //# sourceMappingURL=noise-handler.d.ts.map
@@ -1,22 +1,25 @@
1
- import { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import { NOISE_MODE, WA_CERT_DETAILS } from '../Defaults/index.js';
4
- import { decodeBinaryNode } from '../WABinary/index.js';
5
- import { aesDecryptGCM, aesEncryptGCM, Curve, hkdf, sha256 } from './crypto.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeNoiseHandler = void 0;
4
+ const boom_1 = require("@hapi/boom");
5
+ const WAProto_1 = require("../../WAProto");
6
+ const Defaults_1 = require("../Defaults");
7
+ const WABinary_1 = require("../WABinary");
8
+ const crypto_1 = require("./crypto");
6
9
  const generateIV = (counter) => {
7
10
  const iv = new ArrayBuffer(12);
8
11
  new DataView(iv).setUint32(8, counter);
9
12
  return new Uint8Array(iv);
10
13
  };
11
- export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }) => {
14
+ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }) => {
12
15
  logger = logger.child({ class: 'ns' });
13
16
  const authenticate = (data) => {
14
17
  if (!isFinished) {
15
- hash = sha256(Buffer.concat([hash, data]));
18
+ hash = (0, crypto_1.sha256)(Buffer.concat([hash, data]));
16
19
  }
17
20
  };
18
21
  const encrypt = (plaintext) => {
19
- const result = aesEncryptGCM(plaintext, encKey, generateIV(writeCounter), hash);
22
+ const result = (0, crypto_1.aesEncryptGCM)(plaintext, encKey, generateIV(writeCounter), hash);
20
23
  writeCounter += 1;
21
24
  authenticate(result);
22
25
  return result;
@@ -25,7 +28,7 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
25
28
  // before the handshake is finished, we use the same counter
26
29
  // after handshake, the counters are different
27
30
  const iv = generateIV(isFinished ? readCounter : writeCounter);
28
- const result = aesDecryptGCM(ciphertext, decKey, iv, hash);
31
+ const result = (0, crypto_1.aesDecryptGCM)(ciphertext, decKey, iv, hash);
29
32
  if (isFinished) {
30
33
  readCounter += 1;
31
34
  }
@@ -36,7 +39,7 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
36
39
  return result;
37
40
  };
38
41
  const localHKDF = async (data) => {
39
- const key = await hkdf(Buffer.from(data), 64, { salt, info: '' });
42
+ const key = await (0, crypto_1.hkdf)(Buffer.from(data), 64, { salt, info: '' });
40
43
  return [key.slice(0, 32), key.slice(32)];
41
44
  };
42
45
  const mixIntoKey = async (data) => {
@@ -56,8 +59,8 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
56
59
  writeCounter = 0;
57
60
  isFinished = true;
58
61
  };
59
- const data = Buffer.from(NOISE_MODE);
60
- let hash = data.byteLength === 32 ? data : sha256(data);
62
+ const data = Buffer.from(Defaults_1.NOISE_MODE);
63
+ let hash = data.byteLength === 32 ? data : (0, crypto_1.sha256)(data);
61
64
  let salt = hash;
62
65
  let encKey = hash;
63
66
  let decKey = hash;
@@ -76,17 +79,17 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
76
79
  finishInit,
77
80
  processHandshake: async ({ serverHello }, noiseKey) => {
78
81
  authenticate(serverHello.ephemeral);
79
- await mixIntoKey(Curve.sharedKey(privateKey, serverHello.ephemeral));
82
+ await mixIntoKey(crypto_1.Curve.sharedKey(privateKey, serverHello.ephemeral));
80
83
  const decStaticContent = decrypt(serverHello.static);
81
- await mixIntoKey(Curve.sharedKey(privateKey, decStaticContent));
84
+ await mixIntoKey(crypto_1.Curve.sharedKey(privateKey, decStaticContent));
82
85
  const certDecoded = decrypt(serverHello.payload);
83
- const { intermediate: certIntermediate } = proto.CertChain.decode(certDecoded);
84
- const { issuerSerial } = proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
85
- if (issuerSerial !== WA_CERT_DETAILS.SERIAL) {
86
- throw new Boom('certification match failed', { statusCode: 400 });
86
+ const { intermediate: certIntermediate } = WAProto_1.proto.CertChain.decode(certDecoded);
87
+ const { issuerSerial } = WAProto_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
88
+ if (issuerSerial !== Defaults_1.WA_CERT_DETAILS.SERIAL) {
89
+ throw new boom_1.Boom('certification match failed', { statusCode: 400 });
87
90
  }
88
91
  const keyEnc = encrypt(noiseKey.public);
89
- await mixIntoKey(Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
92
+ await mixIntoKey(crypto_1.Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
90
93
  return keyEnc;
91
94
  },
92
95
  encodeFrame: (data) => {
@@ -118,6 +121,7 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
118
121
  return frame;
119
122
  },
120
123
  decodeFrame: async (newData, onFrame) => {
124
+ var _a;
121
125
  // the binary protocol uses its own framing mechanism
122
126
  // on top of the WS frames
123
127
  // so we get this data and separate out the frames
@@ -134,13 +138,13 @@ export const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publi
134
138
  inBytes = inBytes.slice(size + 3);
135
139
  if (isFinished) {
136
140
  const result = decrypt(frame);
137
- frame = await decodeBinaryNode(result);
141
+ frame = await (0, WABinary_1.decodeBinaryNode)(result);
138
142
  }
139
- logger.trace({ msg: frame?.attrs?.id }, 'recv frame');
143
+ logger.trace({ msg: (_a = frame === null || frame === void 0 ? void 0 : frame.attrs) === null || _a === void 0 ? void 0 : _a.id }, 'recv frame');
140
144
  onFrame(frame);
141
145
  size = getBytesSize();
142
146
  }
143
147
  }
144
148
  };
145
149
  };
146
- //# sourceMappingURL=noise-handler.js.map
150
+ exports.makeNoiseHandler = makeNoiseHandler;
@@ -1,7 +1,7 @@
1
- import type { AxiosRequestConfig } from 'axios';
2
- import { proto } from '../../WAProto/index.js';
3
- import type { AuthenticationCreds, BaileysEventEmitter, CacheStore, SignalKeyStoreWithTransaction } from '../Types/index.js';
4
- import type { ILogger } from './logger.js';
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { proto } from '../../WAProto';
3
+ import { AuthenticationCreds, BaileysEventEmitter, CacheStore, SignalKeyStoreWithTransaction } from '../Types';
4
+ import { ILogger } from './logger';
5
5
  type ProcessMessageContext = {
6
6
  shouldProcessHistoryMsg: boolean;
7
7
  placeholderResendCache?: CacheStore;
@@ -39,4 +39,3 @@ type PollContext = {
39
39
  export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }: PollContext): proto.Message.PollVoteMessage;
40
40
  declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options }: ProcessMessageContext) => Promise<void>;
41
41
  export default processMessage;
42
- //# sourceMappingURL=process-message.d.ts.map
@@ -1,28 +1,32 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import { WAMessageStubType } from '../Types/index.js';
3
- import { getContentType, normalizeMessageContent } from '../Utils/messages.js';
4
- import { areJidsSameUser, isJidBroadcast, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary/index.js';
5
- import { aesDecryptGCM, hmacSign } from './crypto.js';
6
- import { toNumber } from './generics.js';
7
- import { downloadAndProcessHistorySyncNotification } from './history.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChatId = exports.shouldIncrementChatUnread = exports.isRealMessage = exports.cleanMessage = void 0;
4
+ exports.decryptPollVote = decryptPollVote;
5
+ const WAProto_1 = require("../../WAProto");
6
+ const Types_1 = require("../Types");
7
+ const messages_1 = require("../Utils/messages");
8
+ const WABinary_1 = require("../WABinary");
9
+ const crypto_1 = require("./crypto");
10
+ const generics_1 = require("./generics");
11
+ const history_1 = require("./history");
8
12
  const REAL_MSG_STUB_TYPES = new Set([
9
- WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
10
- WAMessageStubType.CALL_MISSED_GROUP_VOICE,
11
- WAMessageStubType.CALL_MISSED_VIDEO,
12
- WAMessageStubType.CALL_MISSED_VOICE
13
+ Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
14
+ Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE,
15
+ Types_1.WAMessageStubType.CALL_MISSED_VIDEO,
16
+ Types_1.WAMessageStubType.CALL_MISSED_VOICE
13
17
  ]);
14
- const REAL_MSG_REQ_ME_STUB_TYPES = new Set([WAMessageStubType.GROUP_PARTICIPANT_ADD]);
18
+ const REAL_MSG_REQ_ME_STUB_TYPES = new Set([Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD]);
15
19
  /** Cleans a received message to further processing */
16
- export const cleanMessage = (message, meId) => {
20
+ const cleanMessage = (message, meId) => {
17
21
  // ensure remoteJid and participant doesn't have device or agent in it
18
- message.key.remoteJid = jidNormalizedUser(message.key.remoteJid);
19
- message.key.participant = message.key.participant ? jidNormalizedUser(message.key.participant) : undefined;
20
- const content = normalizeMessageContent(message.message);
22
+ message.key.remoteJid = (0, WABinary_1.jidNormalizedUser)(message.key.remoteJid);
23
+ message.key.participant = message.key.participant ? (0, WABinary_1.jidNormalizedUser)(message.key.participant) : undefined;
24
+ const content = (0, messages_1.normalizeMessageContent)(message.message);
21
25
  // if the message has a reaction, ensure fromMe & remoteJid are from our perspective
22
- if (content?.reactionMessage) {
26
+ if (content === null || content === void 0 ? void 0 : content.reactionMessage) {
23
27
  normaliseKey(content.reactionMessage.key);
24
28
  }
25
- if (content?.pollUpdateMessage) {
29
+ if (content === null || content === void 0 ? void 0 : content.pollUpdateMessage) {
26
30
  normaliseKey(content.pollUpdateMessage.pollCreationMessageKey);
27
31
  }
28
32
  function normaliseKey(msgKey) {
@@ -32,7 +36,7 @@ export const cleanMessage = (message, meId) => {
32
36
  // if the sender believed the message being reacted to is not from them
33
37
  // we've to correct the key to be from them, or some other participant
34
38
  msgKey.fromMe = !msgKey.fromMe
35
- ? areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
39
+ ? (0, WABinary_1.areJidsSameUser)(msgKey.participant || msgKey.remoteJid, meId)
36
40
  : // if the message being reacted to, was from them
37
41
  // fromMe automatically becomes false
38
42
  false;
@@ -43,36 +47,41 @@ export const cleanMessage = (message, meId) => {
43
47
  }
44
48
  }
45
49
  };
46
- export const isRealMessage = (message, meId) => {
47
- const normalizedContent = normalizeMessageContent(message.message);
48
- const hasSomeContent = !!getContentType(normalizedContent);
50
+ exports.cleanMessage = cleanMessage;
51
+ const isRealMessage = (message, meId) => {
52
+ var _a;
53
+ const normalizedContent = (0, messages_1.normalizeMessageContent)(message.message);
54
+ const hasSomeContent = !!(0, messages_1.getContentType)(normalizedContent);
49
55
  return ((!!normalizedContent ||
50
56
  REAL_MSG_STUB_TYPES.has(message.messageStubType) ||
51
57
  (REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType) &&
52
- message.messageStubParameters?.some(p => areJidsSameUser(meId, p)))) &&
58
+ ((_a = message.messageStubParameters) === null || _a === void 0 ? void 0 : _a.some(p => (0, WABinary_1.areJidsSameUser)(meId, p))))) &&
53
59
  hasSomeContent &&
54
- !normalizedContent?.protocolMessage &&
55
- !normalizedContent?.reactionMessage &&
56
- !normalizedContent?.pollUpdateMessage);
60
+ !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.protocolMessage) &&
61
+ !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.reactionMessage) &&
62
+ !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.pollUpdateMessage));
57
63
  };
58
- export const shouldIncrementChatUnread = (message) => !message.key.fromMe && !message.messageStubType;
64
+ exports.isRealMessage = isRealMessage;
65
+ const shouldIncrementChatUnread = (message) => !message.key.fromMe && !message.messageStubType;
66
+ exports.shouldIncrementChatUnread = shouldIncrementChatUnread;
59
67
  /**
60
68
  * Get the ID of the chat from the given key.
61
69
  * Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
62
70
  */
63
- export const getChatId = ({ remoteJid, participant, fromMe }) => {
64
- if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
71
+ const getChatId = ({ remoteJid, participant, fromMe }) => {
72
+ if ((0, WABinary_1.isJidBroadcast)(remoteJid) && !(0, WABinary_1.isJidStatusBroadcast)(remoteJid) && !fromMe) {
65
73
  return participant;
66
74
  }
67
75
  return remoteJid;
68
76
  };
77
+ exports.getChatId = getChatId;
69
78
  /**
70
79
  * Decrypt a poll vote
71
80
  * @param vote encrypted vote
72
81
  * @param ctx additional info about the poll required for decryption
73
82
  * @returns list of SHA256 options
74
83
  */
75
- export function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }) {
84
+ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }) {
76
85
  const sign = Buffer.concat([
77
86
  toBinary(pollMsgId),
78
87
  toBinary(pollCreatorJid),
@@ -80,50 +89,51 @@ export function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsg
80
89
  toBinary('Poll Vote'),
81
90
  new Uint8Array([1])
82
91
  ]);
83
- const key0 = hmacSign(pollEncKey, new Uint8Array(32), 'sha256');
84
- const decKey = hmacSign(sign, key0, 'sha256');
92
+ const key0 = (0, crypto_1.hmacSign)(pollEncKey, new Uint8Array(32), 'sha256');
93
+ const decKey = (0, crypto_1.hmacSign)(sign, key0, 'sha256');
85
94
  const aad = toBinary(`${pollMsgId}\u0000${voterJid}`);
86
- const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad);
87
- return proto.Message.PollVoteMessage.decode(decrypted);
95
+ const decrypted = (0, crypto_1.aesDecryptGCM)(encPayload, decKey, encIv, aad);
96
+ return WAProto_1.proto.Message.PollVoteMessage.decode(decrypted);
88
97
  function toBinary(txt) {
89
98
  return Buffer.from(txt);
90
99
  }
91
100
  }
92
101
  const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options }) => {
102
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
93
103
  const meId = creds.me.id;
94
104
  const { accountSettings } = creds;
95
- const chat = { id: jidNormalizedUser(getChatId(message.key)) };
96
- const isRealMsg = isRealMessage(message, meId);
105
+ const chat = { id: (0, WABinary_1.jidNormalizedUser)((0, exports.getChatId)(message.key)) };
106
+ const isRealMsg = (0, exports.isRealMessage)(message, meId);
97
107
  if (isRealMsg) {
98
108
  chat.messages = [{ message }];
99
- chat.conversationTimestamp = toNumber(message.messageTimestamp);
109
+ chat.conversationTimestamp = (0, generics_1.toNumber)(message.messageTimestamp);
100
110
  // only increment unread count if not CIPHERTEXT and from another person
101
- if (shouldIncrementChatUnread(message)) {
111
+ if ((0, exports.shouldIncrementChatUnread)(message)) {
102
112
  chat.unreadCount = (chat.unreadCount || 0) + 1;
103
113
  }
104
114
  }
105
- const content = normalizeMessageContent(message.message);
115
+ const content = (0, messages_1.normalizeMessageContent)(message.message);
106
116
  // unarchive chat if it's a real message, or someone reacted to our message
107
117
  // and we've the unarchive chats setting on
108
- if ((isRealMsg || content?.reactionMessage?.key?.fromMe) && accountSettings?.unarchiveChats) {
118
+ if ((isRealMsg || ((_b = (_a = content === null || content === void 0 ? void 0 : content.reactionMessage) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.fromMe)) && (accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.unarchiveChats)) {
109
119
  chat.archived = false;
110
120
  chat.readOnly = false;
111
121
  }
112
- const protocolMsg = content?.protocolMessage;
122
+ const protocolMsg = content === null || content === void 0 ? void 0 : content.protocolMessage;
113
123
  if (protocolMsg) {
114
124
  switch (protocolMsg.type) {
115
- case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
125
+ case WAProto_1.proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
116
126
  const histNotification = protocolMsg.historySyncNotification;
117
127
  const process = shouldProcessHistoryMsg;
118
- const isLatest = !creds.processedHistoryMessages?.length;
119
- logger?.info({
128
+ const isLatest = !((_c = creds.processedHistoryMessages) === null || _c === void 0 ? void 0 : _c.length);
129
+ logger === null || logger === void 0 ? void 0 : logger.info({
120
130
  histNotification,
121
131
  process,
122
132
  id: message.key.id,
123
133
  isLatest
124
134
  }, 'got history notification');
125
135
  if (process) {
126
- if (histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND) {
136
+ if (histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
127
137
  ev.emit('creds.update', {
128
138
  processedHistoryMessages: [
129
139
  ...(creds.processedHistoryMessages || []),
@@ -131,17 +141,17 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
131
141
  ]
132
142
  });
133
143
  }
134
- const data = await downloadAndProcessHistorySyncNotification(histNotification, options);
144
+ const data = await (0, history_1.downloadAndProcessHistorySyncNotification)(histNotification, options);
135
145
  ev.emit('messaging-history.set', {
136
146
  ...data,
137
- isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
147
+ isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
138
148
  peerDataRequestSessionId: histNotification.peerDataRequestSessionId
139
149
  });
140
150
  }
141
151
  break;
142
- case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
152
+ case WAProto_1.proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
143
153
  const keys = protocolMsg.appStateSyncKeyShare.keys;
144
- if (keys?.length) {
154
+ if (keys === null || keys === void 0 ? void 0 : keys.length) {
145
155
  let newAppStateSyncKeyId = '';
146
156
  await keyStore.transaction(async () => {
147
157
  const newKeys = [];
@@ -151,42 +161,42 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
151
161
  await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } });
152
162
  newAppStateSyncKeyId = strKeyId;
153
163
  }
154
- logger?.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys');
164
+ logger === null || logger === void 0 ? void 0 : logger.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys');
155
165
  });
156
166
  ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId });
157
167
  }
158
168
  else {
159
- logger?.info({ protocolMsg }, 'recv app state sync with 0 keys');
169
+ logger === null || logger === void 0 ? void 0 : logger.info({ protocolMsg }, 'recv app state sync with 0 keys');
160
170
  }
161
171
  break;
162
- case proto.Message.ProtocolMessage.Type.REVOKE:
172
+ case WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE:
163
173
  ev.emit('messages.update', [
164
174
  {
165
175
  key: {
166
176
  ...message.key,
167
177
  id: protocolMsg.key.id
168
178
  },
169
- update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
179
+ update: { message: null, messageStubType: Types_1.WAMessageStubType.REVOKE, key: message.key }
170
180
  }
171
181
  ]);
172
182
  break;
173
- case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
183
+ case WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
174
184
  Object.assign(chat, {
175
- ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
185
+ ephemeralSettingTimestamp: (0, generics_1.toNumber)(message.messageTimestamp),
176
186
  ephemeralExpiration: protocolMsg.ephemeralExpiration || null
177
187
  });
178
188
  break;
179
- case proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
189
+ case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
180
190
  const response = protocolMsg.peerDataOperationRequestResponseMessage;
181
191
  if (response) {
182
- placeholderResendCache?.del(response.stanzaId);
192
+ placeholderResendCache === null || placeholderResendCache === void 0 ? void 0 : placeholderResendCache.del(response.stanzaId);
183
193
  // TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
184
194
  const { peerDataOperationResult } = response;
185
195
  for (const result of peerDataOperationResult) {
186
196
  const { placeholderMessageResendResponse: retryResponse } = result;
187
197
  //eslint-disable-next-line max-depth
188
198
  if (retryResponse) {
189
- const webMessageInfo = proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
199
+ const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
190
200
  // wait till another upsert event is available, don't want it to be part of the PDO response message
191
201
  setTimeout(() => {
192
202
  ev.emit('messages.upsert', {
@@ -198,12 +208,11 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
198
208
  }
199
209
  }
200
210
  }
201
- break;
202
- case proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
211
+ case WAProto_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
203
212
  ev.emit('messages.update', [
204
213
  {
205
214
  // flip the sender / fromMe properties because they're in the perspective of the sender
206
- key: { ...message.key, id: protocolMsg.key?.id },
215
+ key: { ...message.key, id: (_d = protocolMsg.key) === null || _d === void 0 ? void 0 : _d.id },
207
216
  update: {
208
217
  message: {
209
218
  editedMessage: {
@@ -211,7 +220,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
211
220
  }
212
221
  },
213
222
  messageTimestamp: protocolMsg.timestampMs
214
- ? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
223
+ ? Math.floor((0, generics_1.toNumber)(protocolMsg.timestampMs) / 1000)
215
224
  : message.messageTimestamp
216
225
  }
217
226
  }
@@ -219,7 +228,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
219
228
  break;
220
229
  }
221
230
  }
222
- else if (content?.reactionMessage) {
231
+ else if (content === null || content === void 0 ? void 0 : content.reactionMessage) {
223
232
  const reaction = {
224
233
  ...content.reactionMessage,
225
234
  key: message.key
@@ -227,29 +236,30 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
227
236
  ev.emit('messages.reaction', [
228
237
  {
229
238
  reaction,
230
- key: content.reactionMessage?.key
239
+ key: (_e = content.reactionMessage) === null || _e === void 0 ? void 0 : _e.key
231
240
  }
232
241
  ]);
233
242
  }
234
243
  else if (message.messageStubType) {
235
- const jid = message.key?.remoteJid;
244
+ const jid = (_f = message.key) === null || _f === void 0 ? void 0 : _f.remoteJid;
236
245
  //let actor = whatsappID (message.participant)
237
246
  let participants;
238
247
  const emitParticipantsUpdate = (action) => ev.emit('group-participants.update', { id: jid, author: message.participant, participants, action });
239
248
  const emitGroupUpdate = (update) => {
240
- ev.emit('groups.update', [{ id: jid, ...update, author: message.participant ?? undefined }]);
249
+ var _a;
250
+ ev.emit('groups.update', [{ id: jid, ...update, author: (_a = message.participant) !== null && _a !== void 0 ? _a : undefined }]);
241
251
  };
242
252
  const emitGroupRequestJoin = (participant, action, method) => {
243
253
  ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method });
244
254
  };
245
- const participantsIncludesMe = () => participants.find(jid => areJidsSameUser(meId, jid));
255
+ const participantsIncludesMe = () => participants.find(jid => (0, WABinary_1.areJidsSameUser)(meId, jid));
246
256
  switch (message.messageStubType) {
247
- case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
257
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
248
258
  participants = message.messageStubParameters || [];
249
259
  emitParticipantsUpdate('modify');
250
260
  break;
251
- case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
252
- case WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
261
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
262
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
253
263
  participants = message.messageStubParameters || [];
254
264
  emitParticipantsUpdate('remove');
255
265
  // mark the chat read only if you left the group
@@ -257,57 +267,57 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
257
267
  chat.readOnly = true;
258
268
  }
259
269
  break;
260
- case WAMessageStubType.GROUP_PARTICIPANT_ADD:
261
- case WAMessageStubType.GROUP_PARTICIPANT_INVITE:
262
- case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
270
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD:
271
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_INVITE:
272
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
263
273
  participants = message.messageStubParameters || [];
264
274
  if (participantsIncludesMe()) {
265
275
  chat.readOnly = false;
266
276
  }
267
277
  emitParticipantsUpdate('add');
268
278
  break;
269
- case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
279
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
270
280
  participants = message.messageStubParameters || [];
271
281
  emitParticipantsUpdate('demote');
272
282
  break;
273
- case WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
283
+ case Types_1.WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
274
284
  participants = message.messageStubParameters || [];
275
285
  emitParticipantsUpdate('promote');
276
286
  break;
277
- case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
278
- const announceValue = message.messageStubParameters?.[0];
287
+ case Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
288
+ const announceValue = (_g = message.messageStubParameters) === null || _g === void 0 ? void 0 : _g[0];
279
289
  emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' });
280
290
  break;
281
- case WAMessageStubType.GROUP_CHANGE_RESTRICT:
282
- const restrictValue = message.messageStubParameters?.[0];
291
+ case Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT:
292
+ const restrictValue = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
283
293
  emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' });
284
294
  break;
285
- case WAMessageStubType.GROUP_CHANGE_SUBJECT:
286
- const name = message.messageStubParameters?.[0];
295
+ case Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT:
296
+ const name = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
287
297
  chat.name = name;
288
298
  emitGroupUpdate({ subject: name });
289
299
  break;
290
- case WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
291
- const description = message.messageStubParameters?.[0];
300
+ case Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
301
+ const description = (_k = message.messageStubParameters) === null || _k === void 0 ? void 0 : _k[0];
292
302
  chat.description = description;
293
303
  emitGroupUpdate({ desc: description });
294
304
  break;
295
- case WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
296
- const code = message.messageStubParameters?.[0];
305
+ case Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
306
+ const code = (_l = message.messageStubParameters) === null || _l === void 0 ? void 0 : _l[0];
297
307
  emitGroupUpdate({ inviteCode: code });
298
308
  break;
299
- case WAMessageStubType.GROUP_MEMBER_ADD_MODE:
300
- const memberAddValue = message.messageStubParameters?.[0];
309
+ case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
310
+ const memberAddValue = (_m = message.messageStubParameters) === null || _m === void 0 ? void 0 : _m[0];
301
311
  emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
302
312
  break;
303
- case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
304
- const approvalMode = message.messageStubParameters?.[0];
313
+ case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
314
+ const approvalMode = (_o = message.messageStubParameters) === null || _o === void 0 ? void 0 : _o[0];
305
315
  emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
306
316
  break;
307
- case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
308
- const participant = message.messageStubParameters?.[0];
309
- const action = message.messageStubParameters?.[1];
310
- const method = message.messageStubParameters?.[2];
317
+ case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
318
+ const participant = (_p = message.messageStubParameters) === null || _p === void 0 ? void 0 : _p[0];
319
+ const action = (_q = message.messageStubParameters) === null || _q === void 0 ? void 0 : _q[1];
320
+ const method = (_r = message.messageStubParameters) === null || _r === void 0 ? void 0 : _r[2];
311
321
  emitGroupRequestJoin(participant, action, method);
312
322
  break;
313
323
  }
@@ -364,5 +374,4 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
364
374
  ev.emit('chats.update', [chat]);
365
375
  }
366
376
  };
367
- export default processMessage;
368
- //# sourceMappingURL=process-message.js.map
377
+ exports.default = processMessage;
@@ -1,7 +1,7 @@
1
- import type { SignalRepository } from '../Types/index.js';
2
- import type { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth.js';
3
- import { type BinaryNode, type JidWithDevice } from '../WABinary/index.js';
4
- import type { USyncQueryResultList } from '../WAUSync/index.js';
1
+ import { SignalRepository } from '../Types';
2
+ import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
3
+ import { BinaryNode, JidWithDevice } from '../WABinary';
4
+ import { USyncQueryResultList } from '../WAUSync';
5
5
  export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
6
6
  export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
7
7
  [id: string]: KeyPair;
@@ -31,4 +31,3 @@ export declare const getNextPreKeysNode: (state: AuthenticationState, count: num
31
31
  update: Partial<AuthenticationCreds>;
32
32
  node: BinaryNode;
33
33
  }>;
34
- //# sourceMappingURL=signal.d.ts.map