@vinzsocket/baileys 2.8.30 → 2.8.35

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 (377) hide show
  1. package/lib/Defaults/index.js +38 -31
  2. package/lib/Signal/Group/ciphertext-message.js +9 -2
  3. package/lib/Signal/Group/group-session-builder.js +15 -7
  4. package/lib/Signal/Group/group_cipher.js +21 -13
  5. package/lib/Signal/Group/index.js +79 -12
  6. package/lib/Signal/Group/keyhelper.js +16 -6
  7. package/lib/Signal/Group/queue-job.js +9 -2
  8. package/lib/Signal/Group/sender-chain-key.js +14 -6
  9. package/lib/Signal/Group/sender-key-distribution-message.js +13 -6
  10. package/lib/Signal/Group/sender-key-message.js +17 -9
  11. package/lib/Signal/Group/sender-key-name.js +9 -2
  12. package/lib/Signal/Group/sender-key-record.js +16 -9
  13. package/lib/Signal/Group/sender-key-state.js +13 -6
  14. package/lib/Signal/Group/sender-message-key.js +12 -4
  15. package/lib/Signal/libsignal.js +35 -26
  16. package/lib/Signal/lid-mapping.js +27 -19
  17. package/lib/Socket/Client/index.js +27 -3
  18. package/lib/Socket/Client/types.js +11 -4
  19. package/lib/Socket/Client/websocket.js +19 -11
  20. package/lib/Socket/business.js +41 -34
  21. package/lib/Socket/chats.js +103 -95
  22. package/lib/Socket/communities.js +58 -49
  23. package/lib/Socket/groups.js +59 -51
  24. package/lib/Socket/index.js +11 -6
  25. package/lib/Socket/messages-recv.js +153 -145
  26. package/lib/Socket/messages-send.js +112 -104
  27. package/lib/Socket/mex.js +15 -8
  28. package/lib/Socket/newsletter.js +30 -23
  29. package/lib/Socket/socket.js +112 -105
  30. package/lib/Store/index.js +49 -4
  31. package/lib/Store/make-cache-manager-store.js +19 -11
  32. package/lib/Store/make-in-memory-store.js +38 -29
  33. package/lib/Store/make-ordered-dictionary.js +9 -2
  34. package/lib/Store/object-repository.js +9 -2
  35. package/lib/Types/Auth.js +5 -2
  36. package/lib/Types/Bussines.js +5 -2
  37. package/lib/Types/Call.js +5 -2
  38. package/lib/Types/Chat.js +7 -1
  39. package/lib/Types/Contact.js +5 -2
  40. package/lib/Types/Events.js +3 -2
  41. package/lib/Types/GroupMetadata.js +5 -2
  42. package/lib/Types/Label.js +8 -2
  43. package/lib/Types/LabelAssociation.js +8 -2
  44. package/lib/Types/Message.js +18 -6
  45. package/lib/Types/Newsletter.js +10 -4
  46. package/lib/Types/Product.js +5 -2
  47. package/lib/Types/Signal.js +3 -2
  48. package/lib/Types/Socket.js +4 -3
  49. package/lib/Types/State.js +9 -3
  50. package/lib/Types/USync.js +3 -2
  51. package/lib/Types/index.js +155 -14
  52. package/lib/Utils/auth-utils.js +35 -25
  53. package/lib/Utils/baileys-event-stream.js +24 -15
  54. package/lib/Utils/business.js +72 -59
  55. package/lib/Utils/chat-utils.js +94 -77
  56. package/lib/Utils/crypto.js +55 -30
  57. package/lib/Utils/decode-wa-message.js +47 -37
  58. package/lib/Utils/event-buffer.js +25 -17
  59. package/lib/Utils/extended-messages.js +16 -9
  60. package/lib/Utils/generics.js +101 -62
  61. package/lib/Utils/history.js +33 -23
  62. package/lib/Utils/index.js +236 -22
  63. package/lib/Utils/lid-resolver.js +14 -5
  64. package/lib/Utils/link-preview.js +14 -7
  65. package/lib/Utils/logger.js +10 -4
  66. package/lib/Utils/lt-hash.js +10 -4
  67. package/lib/Utils/make-mutex.js +11 -3
  68. package/lib/Utils/mention.js +14 -4
  69. package/lib/Utils/message-retry-manager.js +13 -6
  70. package/lib/Utils/messages-media.js +128 -93
  71. package/lib/Utils/messages.js +125 -98
  72. package/lib/Utils/noise-handler.js +28 -21
  73. package/lib/Utils/process-message.js +74 -63
  74. package/lib/Utils/signal.js +48 -33
  75. package/lib/Utils/use-multi-file-auth-state.js +27 -20
  76. package/lib/Utils/validate-connection.js +57 -47
  77. package/lib/WABinary/constants.js +10 -4
  78. package/lib/WABinary/decode.js +20 -10
  79. package/lib/WABinary/encode.js +12 -4
  80. package/lib/WABinary/generic-utils.js +32 -15
  81. package/lib/WABinary/index.js +60 -6
  82. package/lib/WABinary/jid-utils.js +39 -20
  83. package/lib/WABinary/types.js +4 -2
  84. package/lib/WAM/BinaryInfo.js +9 -2
  85. package/lib/WAM/constants.js +13001 -1
  86. package/lib/WAM/encode.js +17 -10
  87. package/lib/WAM/index.js +38 -4
  88. package/lib/WAUSync/Protocols/USyncContactProtocol.js +12 -5
  89. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -6
  90. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +11 -4
  91. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +11 -4
  92. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +11 -4
  93. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +26 -19
  94. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +9 -2
  95. package/lib/WAUSync/Protocols/index.js +60 -6
  96. package/lib/WAUSync/USyncQuery.js +24 -17
  97. package/lib/WAUSync/USyncUser.js +9 -2
  98. package/lib/WAUSync/index.js +38 -4
  99. package/lib/index.js +114 -12
  100. package/package.json +3 -1
  101. package/lib/Defaults/index.d.ts +0 -58
  102. package/lib/Defaults/index.d.ts.map +0 -1
  103. package/lib/Defaults/index.js.map +0 -1
  104. package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
  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 +0 -15
  108. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  109. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  110. package/lib/Signal/Group/group_cipher.d.ts +0 -18
  111. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  112. package/lib/Signal/Group/group_cipher.js.map +0 -1
  113. package/lib/Signal/Group/index.d.ts +0 -12
  114. package/lib/Signal/Group/index.d.ts.map +0 -1
  115. package/lib/Signal/Group/index.js.map +0 -1
  116. package/lib/Signal/Group/keyhelper.d.ts +0 -11
  117. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  118. package/lib/Signal/Group/keyhelper.js.map +0 -1
  119. package/lib/Signal/Group/queue-job.d.ts +0 -2
  120. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  121. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  122. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  123. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  124. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  125. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  126. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  127. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  128. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  129. package/lib/Signal/Group/sender-key-name.d.ts +0 -18
  130. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  131. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  132. package/lib/Signal/Group/sender-key-record.d.ts +0 -31
  133. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  134. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  135. package/lib/Signal/Group/sender-key-state.d.ts +0 -39
  136. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  137. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  138. package/lib/Signal/Group/sender-message-key.d.ts +0 -12
  139. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  140. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  141. package/lib/Signal/libsignal.d.ts +0 -8
  142. package/lib/Signal/libsignal.d.ts.map +0 -1
  143. package/lib/Signal/libsignal.js.map +0 -1
  144. package/lib/Signal/lid-mapping.d.ts +0 -30
  145. package/lib/Signal/lid-mapping.d.ts.map +0 -1
  146. package/lib/Signal/lid-mapping.js.map +0 -1
  147. package/lib/Socket/Client/index.d.ts +0 -3
  148. package/lib/Socket/Client/index.d.ts.map +0 -1
  149. package/lib/Socket/Client/index.js.map +0 -1
  150. package/lib/Socket/Client/types.d.ts +0 -16
  151. package/lib/Socket/Client/types.d.ts.map +0 -1
  152. package/lib/Socket/Client/types.js.map +0 -1
  153. package/lib/Socket/Client/websocket.d.ts +0 -13
  154. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  155. package/lib/Socket/Client/websocket.js.map +0 -1
  156. package/lib/Socket/business.d.ts +0 -188
  157. package/lib/Socket/business.d.ts.map +0 -1
  158. package/lib/Socket/business.js.map +0 -1
  159. package/lib/Socket/chats.d.ts +0 -98
  160. package/lib/Socket/chats.d.ts.map +0 -1
  161. package/lib/Socket/chats.js.map +0 -1
  162. package/lib/Socket/communities.d.ts +0 -233
  163. package/lib/Socket/communities.d.ts.map +0 -1
  164. package/lib/Socket/communities.js.map +0 -1
  165. package/lib/Socket/groups.d.ts +0 -137
  166. package/lib/Socket/groups.d.ts.map +0 -1
  167. package/lib/Socket/groups.js.map +0 -1
  168. package/lib/Socket/index.d.ts +0 -220
  169. package/lib/Socket/index.d.ts.map +0 -1
  170. package/lib/Socket/index.js.map +0 -1
  171. package/lib/Socket/messages-recv.d.ts +0 -173
  172. package/lib/Socket/messages-recv.d.ts.map +0 -1
  173. package/lib/Socket/messages-recv.js.map +0 -1
  174. package/lib/Socket/messages-send.d.ts +0 -169
  175. package/lib/Socket/messages-send.d.ts.map +0 -1
  176. package/lib/Socket/messages-send.js.map +0 -1
  177. package/lib/Socket/mex.d.ts +0 -3
  178. package/lib/Socket/mex.d.ts.map +0 -1
  179. package/lib/Socket/mex.js.map +0 -1
  180. package/lib/Socket/newsletter.d.ts +0 -147
  181. package/lib/Socket/newsletter.d.ts.map +0 -1
  182. package/lib/Socket/newsletter.js.map +0 -1
  183. package/lib/Socket/socket.d.ts +0 -50
  184. package/lib/Socket/socket.d.ts.map +0 -1
  185. package/lib/Socket/socket.js.map +0 -1
  186. package/lib/Store/index.d.ts +0 -4
  187. package/lib/Store/make-cache-manager-store.d.ts +0 -17
  188. package/lib/Store/make-in-memory-store.d.ts +0 -118
  189. package/lib/Store/make-ordered-dictionary.d.ts +0 -14
  190. package/lib/Store/object-repository.d.ts +0 -10
  191. package/lib/Types/Auth.d.ts +0 -105
  192. package/lib/Types/Auth.d.ts.map +0 -1
  193. package/lib/Types/Auth.js.map +0 -1
  194. package/lib/Types/Bussines.d.ts +0 -25
  195. package/lib/Types/Bussines.d.ts.map +0 -1
  196. package/lib/Types/Bussines.js.map +0 -1
  197. package/lib/Types/Call.d.ts +0 -14
  198. package/lib/Types/Call.d.ts.map +0 -1
  199. package/lib/Types/Call.js.map +0 -1
  200. package/lib/Types/Chat.d.ts +0 -123
  201. package/lib/Types/Chat.d.ts.map +0 -1
  202. package/lib/Types/Chat.js.map +0 -1
  203. package/lib/Types/Contact.d.ts +0 -24
  204. package/lib/Types/Contact.d.ts.map +0 -1
  205. package/lib/Types/Contact.js.map +0 -1
  206. package/lib/Types/Events.d.ts +0 -199
  207. package/lib/Types/Events.d.ts.map +0 -1
  208. package/lib/Types/Events.js.map +0 -1
  209. package/lib/Types/GroupMetadata.d.ts +0 -66
  210. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  211. package/lib/Types/GroupMetadata.js.map +0 -1
  212. package/lib/Types/Label.d.ts +0 -47
  213. package/lib/Types/Label.d.ts.map +0 -1
  214. package/lib/Types/Label.js.map +0 -1
  215. package/lib/Types/LabelAssociation.d.ts +0 -30
  216. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  217. package/lib/Types/LabelAssociation.js.map +0 -1
  218. package/lib/Types/Message.d.ts +0 -300
  219. package/lib/Types/Message.d.ts.map +0 -1
  220. package/lib/Types/Message.js.map +0 -1
  221. package/lib/Types/Newsletter.d.ts +0 -135
  222. package/lib/Types/Newsletter.d.ts.map +0 -1
  223. package/lib/Types/Newsletter.js.map +0 -1
  224. package/lib/Types/Product.d.ts +0 -79
  225. package/lib/Types/Product.d.ts.map +0 -1
  226. package/lib/Types/Product.js.map +0 -1
  227. package/lib/Types/Signal.d.ts +0 -82
  228. package/lib/Types/Signal.d.ts.map +0 -1
  229. package/lib/Types/Signal.js.map +0 -1
  230. package/lib/Types/Socket.d.ts +0 -130
  231. package/lib/Types/Socket.d.ts.map +0 -1
  232. package/lib/Types/Socket.js.map +0 -1
  233. package/lib/Types/State.d.ts +0 -39
  234. package/lib/Types/State.d.ts.map +0 -1
  235. package/lib/Types/State.js.map +0 -1
  236. package/lib/Types/USync.d.ts +0 -26
  237. package/lib/Types/USync.d.ts.map +0 -1
  238. package/lib/Types/USync.js.map +0 -1
  239. package/lib/Types/index.d.ts +0 -65
  240. package/lib/Types/index.d.ts.map +0 -1
  241. package/lib/Types/index.js.map +0 -1
  242. package/lib/Utils/auth-utils.d.ts +0 -19
  243. package/lib/Utils/auth-utils.d.ts.map +0 -1
  244. package/lib/Utils/auth-utils.js.map +0 -1
  245. package/lib/Utils/baileys-event-stream.d.ts +0 -17
  246. package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
  247. package/lib/Utils/baileys-event-stream.js.map +0 -1
  248. package/lib/Utils/business.d.ts +0 -23
  249. package/lib/Utils/business.d.ts.map +0 -1
  250. package/lib/Utils/business.js.map +0 -1
  251. package/lib/Utils/chat-utils.d.ts +0 -71
  252. package/lib/Utils/chat-utils.d.ts.map +0 -1
  253. package/lib/Utils/chat-utils.js.map +0 -1
  254. package/lib/Utils/crypto.d.ts +0 -41
  255. package/lib/Utils/crypto.d.ts.map +0 -1
  256. package/lib/Utils/crypto.js.map +0 -1
  257. package/lib/Utils/decode-wa-message.d.ts +0 -46
  258. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  259. package/lib/Utils/decode-wa-message.js.map +0 -1
  260. package/lib/Utils/event-buffer.d.ts +0 -34
  261. package/lib/Utils/event-buffer.d.ts.map +0 -1
  262. package/lib/Utils/event-buffer.js.map +0 -1
  263. package/lib/Utils/extended-messages.d.ts +0 -73
  264. package/lib/Utils/generics.d.ts +0 -92
  265. package/lib/Utils/generics.d.ts.map +0 -1
  266. package/lib/Utils/generics.js.map +0 -1
  267. package/lib/Utils/history.d.ts +0 -20
  268. package/lib/Utils/history.d.ts.map +0 -1
  269. package/lib/Utils/history.js.map +0 -1
  270. package/lib/Utils/index.d.ts +0 -22
  271. package/lib/Utils/index.d.ts.map +0 -1
  272. package/lib/Utils/index.js.map +0 -1
  273. package/lib/Utils/lid-resolver.d.ts +0 -17
  274. package/lib/Utils/link-preview.d.ts +0 -22
  275. package/lib/Utils/link-preview.d.ts.map +0 -1
  276. package/lib/Utils/link-preview.js.map +0 -1
  277. package/lib/Utils/logger.d.ts +0 -12
  278. package/lib/Utils/logger.d.ts.map +0 -1
  279. package/lib/Utils/logger.js.map +0 -1
  280. package/lib/Utils/lt-hash.d.ts +0 -13
  281. package/lib/Utils/lt-hash.d.ts.map +0 -1
  282. package/lib/Utils/lt-hash.js.map +0 -1
  283. package/lib/Utils/make-mutex.d.ts +0 -8
  284. package/lib/Utils/make-mutex.d.ts.map +0 -1
  285. package/lib/Utils/make-mutex.js.map +0 -1
  286. package/lib/Utils/mention.d.ts +0 -27
  287. package/lib/Utils/message-retry-manager.d.ts +0 -82
  288. package/lib/Utils/message-retry-manager.d.ts.map +0 -1
  289. package/lib/Utils/message-retry-manager.js.map +0 -1
  290. package/lib/Utils/messages-media.d.ts +0 -113
  291. package/lib/Utils/messages-media.d.ts.map +0 -1
  292. package/lib/Utils/messages-media.js.map +0 -1
  293. package/lib/Utils/messages.d.ts +0 -76
  294. package/lib/Utils/messages.d.ts.map +0 -1
  295. package/lib/Utils/messages.js.map +0 -1
  296. package/lib/Utils/noise-handler.d.ts +0 -20
  297. package/lib/Utils/noise-handler.d.ts.map +0 -1
  298. package/lib/Utils/noise-handler.js.map +0 -1
  299. package/lib/Utils/process-message.d.ts +0 -43
  300. package/lib/Utils/process-message.d.ts.map +0 -1
  301. package/lib/Utils/process-message.js.map +0 -1
  302. package/lib/Utils/signal.d.ts +0 -34
  303. package/lib/Utils/signal.d.ts.map +0 -1
  304. package/lib/Utils/signal.js.map +0 -1
  305. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  306. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  307. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  308. package/lib/Utils/validate-connection.d.ts +0 -11
  309. package/lib/Utils/validate-connection.d.ts.map +0 -1
  310. package/lib/Utils/validate-connection.js.map +0 -1
  311. package/lib/WABinary/constants.d.ts +0 -28
  312. package/lib/WABinary/constants.d.ts.map +0 -1
  313. package/lib/WABinary/constants.js.map +0 -1
  314. package/lib/WABinary/decode.d.ts +0 -7
  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 +0 -3
  318. package/lib/WABinary/encode.d.ts.map +0 -1
  319. package/lib/WABinary/encode.js.map +0 -1
  320. package/lib/WABinary/generic-utils.d.ts +0 -15
  321. package/lib/WABinary/generic-utils.d.ts.map +0 -1
  322. package/lib/WABinary/generic-utils.js.map +0 -1
  323. package/lib/WABinary/index.d.ts +0 -6
  324. package/lib/WABinary/index.d.ts.map +0 -1
  325. package/lib/WABinary/index.js.map +0 -1
  326. package/lib/WABinary/jid-utils.d.ts +0 -37
  327. package/lib/WABinary/jid-utils.d.ts.map +0 -1
  328. package/lib/WABinary/jid-utils.js.map +0 -1
  329. package/lib/WABinary/types.d.ts +0 -19
  330. package/lib/WABinary/types.d.ts.map +0 -1
  331. package/lib/WABinary/types.js.map +0 -1
  332. package/lib/WAM/BinaryInfo.d.ts +0 -9
  333. package/lib/WAM/BinaryInfo.d.ts.map +0 -1
  334. package/lib/WAM/BinaryInfo.js.map +0 -1
  335. package/lib/WAM/constants.d.ts +0 -40
  336. package/lib/WAM/constants.d.ts.map +0 -1
  337. package/lib/WAM/constants.js.map +0 -1
  338. package/lib/WAM/encode.d.ts +0 -3
  339. package/lib/WAM/encode.d.ts.map +0 -1
  340. package/lib/WAM/encode.js.map +0 -1
  341. package/lib/WAM/index.d.ts +0 -4
  342. package/lib/WAM/index.d.ts.map +0 -1
  343. package/lib/WAM/index.js.map +0 -1
  344. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  345. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
  346. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
  347. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
  348. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
  349. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
  350. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
  351. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
  352. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
  353. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
  354. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
  355. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
  356. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -8
  357. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
  358. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
  359. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
  360. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -9
  361. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
  362. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
  363. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  364. package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
  365. package/lib/WAUSync/Protocols/index.js.map +0 -1
  366. package/lib/WAUSync/USyncQuery.d.ts +0 -30
  367. package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
  368. package/lib/WAUSync/USyncQuery.js.map +0 -1
  369. package/lib/WAUSync/USyncUser.d.ts +0 -13
  370. package/lib/WAUSync/USyncUser.d.ts.map +0 -1
  371. package/lib/WAUSync/USyncUser.js.map +0 -1
  372. package/lib/WAUSync/index.d.ts +0 -4
  373. package/lib/WAUSync/index.d.ts.map +0 -1
  374. package/lib/WAUSync/index.js.map +0 -1
  375. package/lib/index.d.ts +0 -13
  376. package/lib/index.d.ts.map +0 -1
  377. package/lib/index.js.map +0 -1
@@ -1,17 +1,24 @@
1
- import NodeCache from '@cacheable/node-cache';
2
- import { Boom } from '@hapi/boom';
3
- import { proto } from '../../WAProto/index.js';
4
- import { DEFAULT_CACHE_TTLS, PROCESSABLE_HISTORY_TYPES } from '../Defaults/index.js';
5
- import { ALL_WA_PATCH_NAMES } from '../Types/index.js';
6
- import { SyncState } from '../Types/State.js';
7
- import { chatModificationToAppPatch, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils/index.js';
8
- import { makeMutex } from '../Utils/make-mutex.js';
9
- import processMessage from '../Utils/process-message.js';
10
- import { getBinaryNodeChild, getBinaryNodeChildren, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from '../WABinary/index.js';
11
- import { USyncQuery, USyncUser } from '../WAUSync/index.js';
12
- import { makeSocket } from './socket.js';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.makeChatsSocket = void 0;
7
+ var _nodeCache = _interopRequireDefault(require("@cacheable/node-cache"));
8
+ var _boom = require("@hapi/boom");
9
+ var _index = require("../../WAProto/index.js");
10
+ var _index2 = require("../Defaults/index.js");
11
+ var _index3 = require("../Types/index.js");
12
+ var _State = require("../Types/State.js");
13
+ var _index4 = require("../Utils/index.js");
14
+ var _makeMutex = require("../Utils/make-mutex.js");
15
+ var _processMessage = _interopRequireDefault(require("../Utils/process-message.js"));
16
+ var _index5 = require("../WABinary/index.js");
17
+ var _index6 = require("../WAUSync/index.js");
18
+ var _socket = require("./socket.js");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
20
  const MAX_SYNC_ATTEMPTS = 2;
14
- export const makeChatsSocket = config => {
21
+ const makeChatsSocket = config => {
15
22
  const {
16
23
  logger,
17
24
  markOnlineOnConnect,
@@ -20,7 +27,7 @@ export const makeChatsSocket = config => {
20
27
  shouldIgnoreJid,
21
28
  shouldSyncHistoryMessage
22
29
  } = config;
23
- const sock = makeSocket(config);
30
+ const sock = (0, _socket.makeSocket)(config);
24
31
  const {
25
32
  ev,
26
33
  ws,
@@ -32,13 +39,13 @@ export const makeChatsSocket = config => {
32
39
  onUnexpectedError
33
40
  } = sock;
34
41
  let privacySettings;
35
- let syncState = SyncState.Connecting;
42
+ let syncState = _State.SyncState.Connecting;
36
43
  /** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
37
- const processingMutex = makeMutex();
44
+ const processingMutex = (0, _makeMutex.makeMutex)();
38
45
  // Timeout for AwaitingInitialSync state
39
46
  let awaitingSyncTimeout;
40
- const placeholderResendCache = config.placeholderResendCache || new NodeCache({
41
- stdTTL: DEFAULT_CACHE_TTLS.MSG_RETRY,
47
+ const placeholderResendCache = config.placeholderResendCache || new _nodeCache.default({
48
+ stdTTL: _index2.DEFAULT_CACHE_TTLS.MSG_RETRY,
42
49
  // 1 hour
43
50
  useClones: false
44
51
  });
@@ -60,7 +67,7 @@ export const makeChatsSocket = config => {
60
67
  tag: 'iq',
61
68
  attrs: {
62
69
  xmlns: 'privacy',
63
- to: S_WHATSAPP_NET,
70
+ to: _index5.S_WHATSAPP_NET,
64
71
  type: 'get'
65
72
  },
66
73
  content: [{
@@ -68,7 +75,7 @@ export const makeChatsSocket = config => {
68
75
  attrs: {}
69
76
  }]
70
77
  });
71
- privacySettings = reduceBinaryNodeToDictionary(content?.[0], 'category');
78
+ privacySettings = (0, _index5.reduceBinaryNodeToDictionary)(content?.[0], 'category');
72
79
  }
73
80
  return privacySettings;
74
81
  };
@@ -78,7 +85,7 @@ export const makeChatsSocket = config => {
78
85
  tag: 'iq',
79
86
  attrs: {
80
87
  xmlns: 'privacy',
81
- to: S_WHATSAPP_NET,
88
+ to: _index5.S_WHATSAPP_NET,
82
89
  type: 'set'
83
90
  },
84
91
  content: [{
@@ -123,7 +130,7 @@ export const makeChatsSocket = config => {
123
130
  tag: 'iq',
124
131
  attrs: {
125
132
  xmlns: 'disappearing_mode',
126
- to: S_WHATSAPP_NET,
133
+ to: _index5.S_WHATSAPP_NET,
127
134
  type: 'set'
128
135
  },
129
136
  content: [{
@@ -139,7 +146,7 @@ export const makeChatsSocket = config => {
139
146
  tag: 'iq',
140
147
  attrs: {
141
148
  xmlns: 'bot',
142
- to: S_WHATSAPP_NET,
149
+ to: _index5.S_WHATSAPP_NET,
143
150
  type: 'get'
144
151
  },
145
152
  content: [{
@@ -149,11 +156,11 @@ export const makeChatsSocket = config => {
149
156
  }
150
157
  }]
151
158
  });
152
- const botNode = getBinaryNodeChild(resp, 'bot');
159
+ const botNode = (0, _index5.getBinaryNodeChild)(resp, 'bot');
153
160
  const botList = [];
154
- for (const section of getBinaryNodeChildren(botNode, 'section')) {
161
+ for (const section of (0, _index5.getBinaryNodeChildren)(botNode, 'section')) {
155
162
  if (section.attrs.type === 'all') {
156
- for (const bot of getBinaryNodeChildren(section, 'bot')) {
163
+ for (const bot of (0, _index5.getBinaryNodeChildren)(section, 'bot')) {
157
164
  botList.push({
158
165
  jid: bot.attrs.jid,
159
166
  personaId: bot.attrs['persona_id']
@@ -164,9 +171,9 @@ export const makeChatsSocket = config => {
164
171
  return botList;
165
172
  };
166
173
  const fetchStatus = async (...jids) => {
167
- const usyncQuery = new USyncQuery().withStatusProtocol();
174
+ const usyncQuery = new _index6.USyncQuery().withStatusProtocol();
168
175
  for (const jid of jids) {
169
- usyncQuery.withUser(new USyncUser().withId(jid));
176
+ usyncQuery.withUser(new _index6.USyncUser().withId(jid));
170
177
  }
171
178
  const result = await sock.executeUSyncQuery(usyncQuery);
172
179
  if (result) {
@@ -174,9 +181,9 @@ export const makeChatsSocket = config => {
174
181
  }
175
182
  };
176
183
  const fetchDisappearingDuration = async (...jids) => {
177
- const usyncQuery = new USyncQuery().withDisappearingModeProtocol();
184
+ const usyncQuery = new _index6.USyncQuery().withDisappearingModeProtocol();
178
185
  for (const jid of jids) {
179
- usyncQuery.withUser(new USyncUser().withId(jid));
186
+ usyncQuery.withUser(new _index6.USyncUser().withId(jid));
180
187
  }
181
188
  const result = await sock.executeUSyncQuery(usyncQuery);
182
189
  if (result) {
@@ -187,20 +194,20 @@ export const makeChatsSocket = config => {
187
194
  const updateProfilePicture = async (jid, content, dimensions) => {
188
195
  let targetJid;
189
196
  if (!jid) {
190
- throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
197
+ throw new _boom.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
191
198
  }
192
- if (jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me.id)) {
193
- targetJid = jidNormalizedUser(jid); // in case it is someone other than us
199
+ if ((0, _index5.jidNormalizedUser)(jid) !== (0, _index5.jidNormalizedUser)(authState.creds.me.id)) {
200
+ targetJid = (0, _index5.jidNormalizedUser)(jid); // in case it is someone other than us
194
201
  } else {
195
202
  targetJid = undefined;
196
203
  }
197
204
  const {
198
205
  img
199
- } = await generateProfilePicture(content, dimensions);
206
+ } = await (0, _index4.generateProfilePicture)(content, dimensions);
200
207
  await query({
201
208
  tag: 'iq',
202
209
  attrs: {
203
- to: S_WHATSAPP_NET,
210
+ to: _index5.S_WHATSAPP_NET,
204
211
  type: 'set',
205
212
  xmlns: 'w:profile:picture',
206
213
  ...(targetJid ? {
@@ -220,17 +227,17 @@ export const makeChatsSocket = config => {
220
227
  const removeProfilePicture = async jid => {
221
228
  let targetJid;
222
229
  if (!jid) {
223
- throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
230
+ throw new _boom.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
224
231
  }
225
- if (jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me.id)) {
226
- targetJid = jidNormalizedUser(jid); // in case it is someone other than us
232
+ if ((0, _index5.jidNormalizedUser)(jid) !== (0, _index5.jidNormalizedUser)(authState.creds.me.id)) {
233
+ targetJid = (0, _index5.jidNormalizedUser)(jid); // in case it is someone other than us
227
234
  } else {
228
235
  targetJid = undefined;
229
236
  }
230
237
  await query({
231
238
  tag: 'iq',
232
239
  attrs: {
233
- to: S_WHATSAPP_NET,
240
+ to: _index5.S_WHATSAPP_NET,
234
241
  type: 'set',
235
242
  xmlns: 'w:profile:picture',
236
243
  ...(targetJid ? {
@@ -244,7 +251,7 @@ export const makeChatsSocket = config => {
244
251
  await query({
245
252
  tag: 'iq',
246
253
  attrs: {
247
- to: S_WHATSAPP_NET,
254
+ to: _index5.S_WHATSAPP_NET,
248
255
  type: 'set',
249
256
  xmlns: 'status'
250
257
  },
@@ -265,19 +272,19 @@ export const makeChatsSocket = config => {
265
272
  tag: 'iq',
266
273
  attrs: {
267
274
  xmlns: 'blocklist',
268
- to: S_WHATSAPP_NET,
275
+ to: _index5.S_WHATSAPP_NET,
269
276
  type: 'get'
270
277
  }
271
278
  });
272
- const listNode = getBinaryNodeChild(result, 'list');
273
- return getBinaryNodeChildren(listNode, 'item').map(n => n.attrs.jid);
279
+ const listNode = (0, _index5.getBinaryNodeChild)(result, 'list');
280
+ return (0, _index5.getBinaryNodeChildren)(listNode, 'item').map(n => n.attrs.jid);
274
281
  };
275
282
  const updateBlockStatus = async (jid, action) => {
276
283
  await query({
277
284
  tag: 'iq',
278
285
  attrs: {
279
286
  xmlns: 'blocklist',
280
- to: S_WHATSAPP_NET,
287
+ to: _index5.S_WHATSAPP_NET,
281
288
  type: 'set'
282
289
  },
283
290
  content: [{
@@ -310,16 +317,16 @@ export const makeChatsSocket = config => {
310
317
  }]
311
318
  }]
312
319
  });
313
- const profileNode = getBinaryNodeChild(results, 'business_profile');
314
- const profiles = getBinaryNodeChild(profileNode, 'profile');
320
+ const profileNode = (0, _index5.getBinaryNodeChild)(results, 'business_profile');
321
+ const profiles = (0, _index5.getBinaryNodeChild)(profileNode, 'profile');
315
322
  if (profiles) {
316
- const address = getBinaryNodeChild(profiles, 'address');
317
- const description = getBinaryNodeChild(profiles, 'description');
318
- const website = getBinaryNodeChild(profiles, 'website');
319
- const email = getBinaryNodeChild(profiles, 'email');
320
- const category = getBinaryNodeChild(getBinaryNodeChild(profiles, 'categories'), 'category');
321
- const businessHours = getBinaryNodeChild(profiles, 'business_hours');
322
- const businessHoursConfig = businessHours ? getBinaryNodeChildren(businessHours, 'business_hours_config') : undefined;
323
+ const address = (0, _index5.getBinaryNodeChild)(profiles, 'address');
324
+ const description = (0, _index5.getBinaryNodeChild)(profiles, 'description');
325
+ const website = (0, _index5.getBinaryNodeChild)(profiles, 'website');
326
+ const email = (0, _index5.getBinaryNodeChild)(profiles, 'email');
327
+ const category = (0, _index5.getBinaryNodeChild)((0, _index5.getBinaryNodeChild)(profiles, 'categories'), 'category');
328
+ const businessHours = (0, _index5.getBinaryNodeChild)(profiles, 'business_hours');
329
+ const businessHoursConfig = businessHours ? (0, _index5.getBinaryNodeChildren)(businessHours, 'business_hours_config') : undefined;
323
330
  const websiteStr = website?.content?.toString();
324
331
  return {
325
332
  wid: profiles.attrs?.jid,
@@ -344,7 +351,7 @@ export const makeChatsSocket = config => {
344
351
  await sendNode({
345
352
  tag: 'iq',
346
353
  attrs: {
347
- to: S_WHATSAPP_NET,
354
+ to: _index5.S_WHATSAPP_NET,
348
355
  type: 'set',
349
356
  xmlns: 'urn:xmpp:whatsapp:dirty',
350
357
  id: generateMessageTag()
@@ -363,7 +370,7 @@ export const makeChatsSocket = config => {
363
370
  const newAppStateChunkHandler = isInitialSync => {
364
371
  return {
365
372
  onMutation(mutation) {
366
- processSyncAction(mutation, ev, authState.creds.me, isInitialSync ? {
373
+ (0, _index4.processSyncAction)(mutation, ev, authState.creds.me, isInitialSync ? {
367
374
  accountSettings: authState.creds.accountSettings
368
375
  } : undefined, logger);
369
376
  }
@@ -392,7 +399,7 @@ export const makeChatsSocket = config => {
392
399
  initialVersionMap[name] = state.version;
393
400
  }
394
401
  } else {
395
- state = newLTHashState();
402
+ state = (0, _index4.newLTHashState)();
396
403
  }
397
404
  states[name] = state;
398
405
  logger.info(`resyncing ${name} from v${state.version}`);
@@ -409,7 +416,7 @@ export const makeChatsSocket = config => {
409
416
  const result = await query({
410
417
  tag: 'iq',
411
418
  attrs: {
412
- to: S_WHATSAPP_NET,
419
+ to: _index5.S_WHATSAPP_NET,
413
420
  xmlns: 'w:sync:app:state',
414
421
  type: 'set'
415
422
  },
@@ -420,7 +427,7 @@ export const makeChatsSocket = config => {
420
427
  }]
421
428
  });
422
429
  // extract from binary node
423
- const decoded = await extractSyncdPatches(result, config?.options);
430
+ const decoded = await (0, _index4.extractSyncdPatches)(result, config?.options);
424
431
  for (const key in decoded) {
425
432
  const name = key;
426
433
  const {
@@ -433,7 +440,7 @@ export const makeChatsSocket = config => {
433
440
  const {
434
441
  state: newState,
435
442
  mutationMap
436
- } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot);
443
+ } = await (0, _index4.decodeSyncdSnapshot)(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot);
437
444
  states[name] = newState;
438
445
  Object.assign(globalMutationMap, mutationMap);
439
446
  logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
@@ -448,7 +455,7 @@ export const makeChatsSocket = config => {
448
455
  const {
449
456
  state: newState,
450
457
  mutationMap
451
- } = await decodePatches(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
458
+ } = await (0, _index4.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
452
459
  await authState.keys.set({
453
460
  'app-state-sync-version': {
454
461
  [name]: newState
@@ -500,12 +507,12 @@ export const makeChatsSocket = config => {
500
507
  * type = "image for the high res picture"
501
508
  */
502
509
  const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
503
- jid = jidNormalizedUser(jid);
510
+ jid = (0, _index5.jidNormalizedUser)(jid);
504
511
  const result = await query({
505
512
  tag: 'iq',
506
513
  attrs: {
507
514
  target: jid,
508
- to: S_WHATSAPP_NET,
515
+ to: _index5.S_WHATSAPP_NET,
509
516
  type: 'get',
510
517
  xmlns: 'w:profile:picture'
511
518
  },
@@ -517,7 +524,7 @@ export const makeChatsSocket = config => {
517
524
  }
518
525
  }]
519
526
  }, timeoutMs);
520
- const child = getBinaryNodeChild(result, 'picture');
527
+ const child = (0, _index5.getBinaryNodeChild)(result, 'picture');
521
528
  return child?.attrs?.url;
522
529
  };
523
530
  const createCallLink = async (type, event, timeoutMs) => {
@@ -540,7 +547,7 @@ export const makeChatsSocket = config => {
540
547
  }] : undefined
541
548
  }]
542
549
  }, timeoutMs);
543
- const child = getBinaryNodeChild(result, 'link_create');
550
+ const child = (0, _index5.getBinaryNodeChild)(result, 'link_create');
544
551
  return child?.attrs?.token;
545
552
  };
546
553
  const sendPresenceUpdate = async (type, toJid) => {
@@ -563,7 +570,7 @@ export const makeChatsSocket = config => {
563
570
  } else {
564
571
  const {
565
572
  server
566
- } = jidDecode(toJid);
573
+ } = (0, _index5.jidDecode)(toJid);
567
574
  const isLid = server === 'lid';
568
575
  await sendNode({
569
576
  tag: 'chatstate',
@@ -645,7 +652,7 @@ export const makeChatsSocket = config => {
645
652
  const name = patchCreate.type;
646
653
  const myAppStateKeyId = authState.creds.myAppStateKeyId;
647
654
  if (!myAppStateKeyId) {
648
- throw new Boom('App state key not present!', {
655
+ throw new _boom.Boom('App state key not present!', {
649
656
  statusCode: 400
650
657
  });
651
658
  }
@@ -660,8 +667,8 @@ export const makeChatsSocket = config => {
660
667
  const {
661
668
  [name]: currentSyncVersion
662
669
  } = await authState.keys.get('app-state-sync-version', [name]);
663
- initial = currentSyncVersion || newLTHashState();
664
- encodeResult = await encodeSyncdPatch(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey);
670
+ initial = currentSyncVersion || (0, _index4.newLTHashState)();
671
+ encodeResult = await (0, _index4.encodeSyncdPatch)(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey);
665
672
  const {
666
673
  patch,
667
674
  state
@@ -669,7 +676,7 @@ export const makeChatsSocket = config => {
669
676
  const node = {
670
677
  tag: 'iq',
671
678
  attrs: {
672
- to: S_WHATSAPP_NET,
679
+ to: _index5.S_WHATSAPP_NET,
673
680
  type: 'set',
674
681
  xmlns: 'w:sync:app:state'
675
682
  },
@@ -686,7 +693,7 @@ export const makeChatsSocket = config => {
686
693
  content: [{
687
694
  tag: 'patch',
688
695
  attrs: {},
689
- content: proto.SyncdPatch.encode(patch).finish()
696
+ content: _index.proto.SyncdPatch.encode(patch).finish()
690
697
  }]
691
698
  }]
692
699
  }]
@@ -705,7 +712,7 @@ export const makeChatsSocket = config => {
705
712
  } = newAppStateChunkHandler(false);
706
713
  const {
707
714
  mutationMap
708
- } = await decodePatches(name, [{
715
+ } = await (0, _index4.decodePatches)(name, [{
709
716
  ...encodeResult.patch,
710
717
  version: {
711
718
  version: encodeResult.state.version
@@ -721,7 +728,7 @@ export const makeChatsSocket = config => {
721
728
  const resultNode = await query({
722
729
  tag: 'iq',
723
730
  attrs: {
724
- to: S_WHATSAPP_NET,
731
+ to: _index5.S_WHATSAPP_NET,
725
732
  xmlns: 'w',
726
733
  type: 'get'
727
734
  },
@@ -733,7 +740,7 @@ export const makeChatsSocket = config => {
733
740
  }
734
741
  }]
735
742
  });
736
- const propsNode = getBinaryNodeChild(resultNode, 'props');
743
+ const propsNode = (0, _index5.getBinaryNodeChild)(resultNode, 'props');
737
744
  let props = {};
738
745
  if (propsNode) {
739
746
  if (propsNode.attrs?.hash) {
@@ -741,7 +748,7 @@ export const makeChatsSocket = config => {
741
748
  authState.creds.lastPropHash = propsNode?.attrs?.hash;
742
749
  ev.emit('creds.update', authState.creds);
743
750
  }
744
- props = reduceBinaryNodeToDictionary(propsNode, 'prop');
751
+ props = (0, _index5.reduceBinaryNodeToDictionary)(propsNode, 'prop');
745
752
  }
746
753
  logger.debug('fetched props');
747
754
  return props;
@@ -752,7 +759,7 @@ export const makeChatsSocket = config => {
752
759
  * requires the last messages till the last message received; required for archive & unread
753
760
  */
754
761
  const chatModify = (mod, jid) => {
755
- const patch = chatModificationToAppPatch(mod, jid);
762
+ const patch = (0, _index4.chatModificationToAppPatch)(mod, jid);
756
763
  return appPatch(patch);
757
764
  };
758
765
  /**
@@ -877,7 +884,7 @@ export const makeChatsSocket = config => {
877
884
  });
878
885
  if (!!msg.pushName) {
879
886
  let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid;
880
- jid = jidNormalizedUser(jid);
887
+ jid = (0, _index5.jidNormalizedUser)(jid);
881
888
  if (!msg.key.fromMe) {
882
889
  ev.emit('contacts.update', [{
883
890
  id: jid,
@@ -895,30 +902,30 @@ export const makeChatsSocket = config => {
895
902
  });
896
903
  }
897
904
  }
898
- const historyMsg = getHistoryMsg(msg.message);
899
- const shouldProcessHistoryMsg = historyMsg ? shouldSyncHistoryMessage(historyMsg) && PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType) : false;
905
+ const historyMsg = (0, _index4.getHistoryMsg)(msg.message);
906
+ const shouldProcessHistoryMsg = historyMsg ? shouldSyncHistoryMessage(historyMsg) && _index2.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType) : false;
900
907
  // State machine: decide on sync and flush
901
- if (historyMsg && syncState === SyncState.AwaitingInitialSync) {
908
+ if (historyMsg && syncState === _State.SyncState.AwaitingInitialSync) {
902
909
  if (awaitingSyncTimeout) {
903
910
  clearTimeout(awaitingSyncTimeout);
904
911
  awaitingSyncTimeout = undefined;
905
912
  }
906
913
  if (shouldProcessHistoryMsg) {
907
- syncState = SyncState.Syncing;
914
+ syncState = _State.SyncState.Syncing;
908
915
  logger.info('Transitioned to Syncing state');
909
916
  // Let doAppStateSync handle the final flush after it's done
910
917
  } else {
911
- syncState = SyncState.Online;
918
+ syncState = _State.SyncState.Online;
912
919
  logger.info('History sync skipped, transitioning to Online state and flushing buffer');
913
920
  ev.flush();
914
921
  }
915
922
  }
916
923
  const doAppStateSync = async () => {
917
- if (syncState === SyncState.Syncing) {
924
+ if (syncState === _State.SyncState.Syncing) {
918
925
  logger.info('Doing app state sync');
919
- await resyncAppState(ALL_WA_PATCH_NAMES, true);
926
+ await resyncAppState(_index3.ALL_WA_PATCH_NAMES, true);
920
927
  // Sync is complete, go online and flush everything
921
- syncState = SyncState.Online;
928
+ syncState = _State.SyncState.Online;
922
929
  logger.info('App state sync complete, transitioning to Online state and flushing buffer');
923
930
  ev.flush();
924
931
  const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
@@ -931,7 +938,7 @@ export const makeChatsSocket = config => {
931
938
  if (shouldProcessHistoryMsg) {
932
939
  await doAppStateSync();
933
940
  }
934
- })(), processMessage(msg, {
941
+ })(), (0, _processMessage.default)(msg, {
935
942
  signalRepository,
936
943
  shouldProcessHistoryMsg,
937
944
  placeholderResendCache,
@@ -942,7 +949,7 @@ export const makeChatsSocket = config => {
942
949
  options: config.options
943
950
  })]);
944
951
  // If the app state key arrives and we are waiting to sync, trigger the sync now.
945
- if (msg.message?.protocolMessage?.appStateSyncKeyShare && syncState === SyncState.Syncing) {
952
+ if (msg.message?.protocolMessage?.appStateSyncKeyShare && syncState === _State.SyncState.Syncing) {
946
953
  logger.info('App state sync key arrived, triggering app state sync');
947
954
  await doAppStateSync();
948
955
  }
@@ -952,7 +959,7 @@ export const makeChatsSocket = config => {
952
959
  ws.on('CB:ib,,dirty', async node => {
953
960
  const {
954
961
  attrs
955
- } = getBinaryNodeChild(node, 'dirty');
962
+ } = (0, _index5.getBinaryNodeChild)(node, 'dirty');
956
963
  const type = attrs.type;
957
964
  switch (type) {
958
965
  case 'account_sync':
@@ -989,18 +996,18 @@ export const makeChatsSocket = config => {
989
996
  }
990
997
  sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable').catch(error => onUnexpectedError(error, 'presence update requests'));
991
998
  }
992
- if (!receivedPendingNotifications || syncState !== SyncState.Connecting) {
999
+ if (!receivedPendingNotifications || syncState !== _State.SyncState.Connecting) {
993
1000
  return;
994
1001
  }
995
- syncState = SyncState.AwaitingInitialSync;
1002
+ syncState = _State.SyncState.AwaitingInitialSync;
996
1003
  logger.info('Connection is now AwaitingInitialSync, buffering events');
997
1004
  ev.buffer();
998
- const willSyncHistory = shouldSyncHistoryMessage(proto.Message.HistorySyncNotification.create({
999
- syncType: proto.HistorySync.HistorySyncType.RECENT
1005
+ const willSyncHistory = shouldSyncHistoryMessage(_index.proto.Message.HistorySyncNotification.create({
1006
+ syncType: _index.proto.HistorySync.HistorySyncType.RECENT
1000
1007
  }));
1001
1008
  if (!willSyncHistory) {
1002
1009
  logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.');
1003
- syncState = SyncState.Online;
1010
+ syncState = _State.SyncState.Online;
1004
1011
  setTimeout(() => ev.flush(), 0);
1005
1012
  return;
1006
1013
  }
@@ -1009,9 +1016,9 @@ export const makeChatsSocket = config => {
1009
1016
  clearTimeout(awaitingSyncTimeout);
1010
1017
  }
1011
1018
  awaitingSyncTimeout = setTimeout(() => {
1012
- if (syncState === SyncState.AwaitingInitialSync) {
1019
+ if (syncState === _State.SyncState.AwaitingInitialSync) {
1013
1020
  logger.warn('Timeout in AwaitingInitialSync, forcing state to Online and flushing buffer');
1014
- syncState = SyncState.Online;
1021
+ syncState = _State.SyncState.Online;
1015
1022
  ev.flush();
1016
1023
  }
1017
1024
  }, 20000);
@@ -1061,4 +1068,5 @@ export const makeChatsSocket = config => {
1061
1068
  removeQuickReply
1062
1069
  };
1063
1070
  };
1064
- //# sourceMappingURL=chats.js.map
1071
+ //# sourceMappingURL=chats.js.map
1072
+ exports.makeChatsSocket = makeChatsSocket;