lordceaser-baileys 2.0.38 → 2.0.39

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 (440) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +660 -1073
  3. package/WAProto/GenerateStatics.sh +4 -3
  4. package/WAProto/WAProto.proto +359 -2494
  5. package/WAProto/index.d.ts +31460 -8461
  6. package/WAProto/index.js +96236 -92883
  7. package/WASignalGroup/GroupProtocol.js +1697 -0
  8. package/WASignalGroup/ciphertext_message.js +16 -0
  9. package/WASignalGroup/group_cipher.js +120 -0
  10. package/WASignalGroup/group_session_builder.js +46 -0
  11. package/WASignalGroup/index.js +5 -0
  12. package/WASignalGroup/keyhelper.js +21 -0
  13. package/WASignalGroup/protobufs.js +3 -0
  14. package/WASignalGroup/queue_job.js +69 -0
  15. package/WASignalGroup/sender_chain_key.js +50 -0
  16. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  17. package/WASignalGroup/sender_key_message.js +92 -0
  18. package/WASignalGroup/sender_key_name.js +70 -0
  19. package/WASignalGroup/sender_key_record.js +56 -0
  20. package/WASignalGroup/sender_key_state.js +129 -0
  21. package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -3
  22. package/index.js +417 -18
  23. package/lib/Defaults/baileys-version.json +3 -0
  24. package/lib/Defaults/index.d.ts +245 -37
  25. package/lib/Defaults/index.js +74 -82
  26. package/lib/Defaults/phonenumber-mcc.json +223 -0
  27. package/lib/Signal/libsignal.d.ts +3 -5
  28. package/lib/Signal/libsignal.js +80 -359
  29. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +5 -4
  30. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  31. package/lib/Socket/Client/index.d.ts +3 -3
  32. package/lib/Socket/Client/index.js +19 -3
  33. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  34. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  35. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +2 -3
  36. package/lib/Socket/Client/web-socket-client.js +62 -0
  37. package/lib/Socket/business.d.ts +87 -156
  38. package/lib/Socket/business.js +43 -162
  39. package/lib/Socket/chats.d.ts +40 -82
  40. package/lib/Socket/chats.js +284 -603
  41. package/lib/Socket/groups.d.ts +58 -96
  42. package/lib/Socket/groups.js +82 -115
  43. package/lib/Socket/index.d.ts +94 -204
  44. package/lib/Socket/index.js +9 -11
  45. package/lib/Socket/messages-recv.d.ts +77 -145
  46. package/lib/Socket/messages-recv.js +400 -1305
  47. package/lib/Socket/messages-send.d.ts +70 -141
  48. package/lib/Socket/messages-send.js +249 -717
  49. package/lib/Socket/registration.d.ts +242 -0
  50. package/lib/Socket/registration.js +166 -0
  51. package/lib/Socket/socket.d.ts +18 -34
  52. package/lib/Socket/socket.js +206 -557
  53. package/lib/Store/index.d.ts +3 -0
  54. package/lib/Store/index.js +10 -0
  55. package/lib/Store/make-cache-manager-store.d.ts +14 -0
  56. package/lib/Store/make-cache-manager-store.js +83 -0
  57. package/lib/Store/make-in-memory-store.d.ts +118 -0
  58. package/lib/Store/make-in-memory-store.js +422 -0
  59. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  60. package/lib/Store/make-ordered-dictionary.js +81 -0
  61. package/lib/Store/object-repository.d.ts +10 -0
  62. package/lib/Store/object-repository.js +27 -0
  63. package/lib/Types/Auth.d.ts +12 -19
  64. package/lib/Types/Auth.js +2 -2
  65. package/lib/Types/Call.d.ts +1 -3
  66. package/lib/Types/Call.js +2 -2
  67. package/lib/Types/Chat.d.ts +14 -31
  68. package/lib/Types/Chat.js +4 -8
  69. package/lib/Types/Contact.d.ts +1 -8
  70. package/lib/Types/Contact.js +2 -2
  71. package/lib/Types/Events.d.ts +17 -101
  72. package/lib/Types/Events.js +2 -2
  73. package/lib/Types/GroupMetadata.d.ts +3 -18
  74. package/lib/Types/GroupMetadata.js +2 -2
  75. package/lib/Types/Label.d.ts +0 -1
  76. package/lib/Types/Label.js +5 -3
  77. package/lib/Types/LabelAssociation.d.ts +0 -1
  78. package/lib/Types/LabelAssociation.js +5 -3
  79. package/lib/Types/Message.d.ts +29 -81
  80. package/lib/Types/Message.js +9 -11
  81. package/lib/Types/Product.d.ts +1 -2
  82. package/lib/Types/Product.js +2 -2
  83. package/lib/Types/Signal.d.ts +2 -32
  84. package/lib/Types/Signal.js +2 -2
  85. package/lib/Types/Socket.d.ts +26 -46
  86. package/lib/Types/Socket.js +2 -3
  87. package/lib/Types/State.d.ts +2 -72
  88. package/lib/Types/State.js +2 -56
  89. package/lib/Types/index.d.ts +13 -16
  90. package/lib/Types/index.js +30 -15
  91. package/lib/Utils/auth-utils.d.ts +6 -12
  92. package/lib/Utils/auth-utils.js +143 -239
  93. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  94. package/lib/Utils/baileys-event-stream.js +63 -0
  95. package/lib/Utils/business.d.ts +2 -3
  96. package/lib/Utils/business.js +69 -66
  97. package/lib/Utils/chat-utils.d.ts +23 -52
  98. package/lib/Utils/chat-utils.js +248 -380
  99. package/lib/Utils/crypto.d.ts +21 -17
  100. package/lib/Utils/crypto.js +92 -57
  101. package/lib/Utils/decode-wa-message.d.ts +8 -54
  102. package/lib/Utils/decode-wa-message.js +57 -186
  103. package/lib/Utils/event-buffer.d.ts +8 -9
  104. package/lib/Utils/event-buffer.js +76 -178
  105. package/lib/Utils/generics.d.ts +23 -26
  106. package/lib/Utils/generics.js +166 -165
  107. package/lib/Utils/history.d.ts +11 -16
  108. package/lib/Utils/history.js +53 -93
  109. package/lib/Utils/index.d.ts +17 -22
  110. package/lib/Utils/index.js +33 -22
  111. package/lib/Utils/link-preview.d.ts +5 -5
  112. package/lib/Utils/link-preview.js +24 -16
  113. package/lib/Utils/logger.d.ts +3 -11
  114. package/lib/Utils/logger.js +7 -3
  115. package/lib/Utils/lt-hash.d.ts +12 -8
  116. package/lib/Utils/lt-hash.js +46 -3
  117. package/lib/Utils/make-mutex.d.ts +2 -4
  118. package/lib/Utils/make-mutex.js +34 -24
  119. package/lib/Utils/messages-media.d.ts +35 -61
  120. package/lib/Utils/messages-media.js +301 -415
  121. package/lib/Utils/messages.d.ts +18 -32
  122. package/lib/Utils/messages.js +261 -396
  123. package/lib/Utils/noise-handler.d.ts +13 -12
  124. package/lib/Utils/noise-handler.js +98 -144
  125. package/lib/Utils/process-message.d.ts +12 -30
  126. package/lib/Utils/process-message.js +163 -439
  127. package/lib/Utils/signal.d.ts +5 -20
  128. package/lib/Utils/signal.js +74 -114
  129. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  130. package/lib/Utils/use-multi-file-auth-state.js +33 -61
  131. package/lib/Utils/validate-connection.d.ts +6 -6
  132. package/lib/Utils/validate-connection.js +114 -119
  133. package/lib/WABinary/constants.d.ts +4 -5
  134. package/lib/WABinary/constants.js +20 -1281
  135. package/lib/WABinary/decode.d.ts +4 -4
  136. package/lib/WABinary/decode.js +43 -51
  137. package/lib/WABinary/encode.d.ts +3 -3
  138. package/lib/WABinary/encode.js +44 -32
  139. package/lib/WABinary/generic-utils.d.ts +6 -6
  140. package/lib/WABinary/generic-utils.js +43 -46
  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 +6 -23
  144. package/lib/WABinary/jid-utils.js +39 -73
  145. package/lib/WABinary/types.d.ts +1 -2
  146. package/lib/WABinary/types.js +2 -2
  147. package/lib/WAM/BinaryInfo.d.ts +11 -3
  148. package/lib/WAM/BinaryInfo.js +5 -2
  149. package/lib/WAM/constants.d.ts +3 -5
  150. package/lib/WAM/constants.js +11958 -19461
  151. package/lib/WAM/encode.d.ts +3 -3
  152. package/lib/WAM/encode.js +22 -17
  153. package/lib/WAM/index.d.ts +3 -4
  154. package/lib/WAM/index.js +19 -4
  155. package/lib/index.d.ts +8 -9
  156. package/lib/index.js +30 -11
  157. package/package.json +2 -2
  158. package/WAProto/WAProto/GenerateStatics.sh +0 -3
  159. package/WAProto/WAProto/WAProto.proto +0 -5479
  160. package/WAProto/WAProto/fix-imports.js +0 -85
  161. package/WAProto/WAProto/index.d.ts +0 -14017
  162. package/WAProto/WAProto/index.js +0 -97691
  163. package/WAProto/fix-imports.js +0 -85
  164. package/lib/Defaults/index.d.ts.map +0 -1
  165. package/lib/Defaults/index.js.map +0 -1
  166. package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
  167. package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
  168. package/lib/Signal/Group/ciphertext-message.js +0 -12
  169. package/lib/Signal/Group/ciphertext-message.js.map +0 -1
  170. package/lib/Signal/Group/group-session-builder.d.ts +0 -15
  171. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  172. package/lib/Signal/Group/group-session-builder.js +0 -30
  173. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  174. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  175. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  176. package/lib/Signal/Group/group_cipher.js +0 -82
  177. package/lib/Signal/Group/group_cipher.js.map +0 -1
  178. package/lib/Signal/Group/index.d.ts +0 -12
  179. package/lib/Signal/Group/index.d.ts.map +0 -1
  180. package/lib/Signal/Group/index.js +0 -12
  181. package/lib/Signal/Group/index.js.map +0 -1
  182. package/lib/Signal/Group/keyhelper.d.ts +0 -11
  183. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  184. package/lib/Signal/Group/keyhelper.js +0 -18
  185. package/lib/Signal/Group/keyhelper.js.map +0 -1
  186. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  187. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  188. package/lib/Signal/Group/sender-chain-key.js +0 -26
  189. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  190. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  191. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  192. package/lib/Signal/Group/sender-key-distribution-message.js +0 -63
  193. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  194. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  195. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  196. package/lib/Signal/Group/sender-key-message.js +0 -66
  197. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  198. package/lib/Signal/Group/sender-key-name.d.ts +0 -18
  199. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  200. package/lib/Signal/Group/sender-key-name.js +0 -48
  201. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  202. package/lib/Signal/Group/sender-key-record.d.ts +0 -31
  203. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  204. package/lib/Signal/Group/sender-key-record.js +0 -41
  205. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  206. package/lib/Signal/Group/sender-key-state.d.ts +0 -39
  207. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  208. package/lib/Signal/Group/sender-key-state.js +0 -84
  209. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  210. package/lib/Signal/Group/sender-message-key.d.ts +0 -12
  211. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  212. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  213. package/lib/Signal/libsignal.d.ts.map +0 -1
  214. package/lib/Signal/libsignal.js.map +0 -1
  215. package/lib/Signal/lid-mapping.d.ts +0 -23
  216. package/lib/Signal/lid-mapping.d.ts.map +0 -1
  217. package/lib/Signal/lid-mapping.js +0 -277
  218. package/lib/Signal/lid-mapping.js.map +0 -1
  219. package/lib/Socket/Client/index.d.ts.map +0 -1
  220. package/lib/Socket/Client/index.js.map +0 -1
  221. package/lib/Socket/Client/types.d.ts.map +0 -1
  222. package/lib/Socket/Client/types.js +0 -11
  223. package/lib/Socket/Client/types.js.map +0 -1
  224. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  225. package/lib/Socket/Client/websocket.js +0 -54
  226. package/lib/Socket/Client/websocket.js.map +0 -1
  227. package/lib/Socket/business.d.ts.map +0 -1
  228. package/lib/Socket/business.js.map +0 -1
  229. package/lib/Socket/chats.d.ts.map +0 -1
  230. package/lib/Socket/chats.js.map +0 -1
  231. package/lib/Socket/communities.d.ts +0 -273
  232. package/lib/Socket/communities.d.ts.map +0 -1
  233. package/lib/Socket/communities.js +0 -431
  234. package/lib/Socket/communities.js.map +0 -1
  235. package/lib/Socket/groups.d.ts.map +0 -1
  236. package/lib/Socket/groups.js.map +0 -1
  237. package/lib/Socket/index.d.ts.map +0 -1
  238. package/lib/Socket/index.js.map +0 -1
  239. package/lib/Socket/messages-recv.d.ts.map +0 -1
  240. package/lib/Socket/messages-recv.js.map +0 -1
  241. package/lib/Socket/messages-send.d.ts.map +0 -1
  242. package/lib/Socket/messages-send.js.map +0 -1
  243. package/lib/Socket/mex.d.ts +0 -3
  244. package/lib/Socket/mex.d.ts.map +0 -1
  245. package/lib/Socket/mex.js +0 -42
  246. package/lib/Socket/mex.js.map +0 -1
  247. package/lib/Socket/newsletter.d.ts +0 -170
  248. package/lib/Socket/newsletter.d.ts.map +0 -1
  249. package/lib/Socket/newsletter.js +0 -181
  250. package/lib/Socket/newsletter.js.map +0 -1
  251. package/lib/Socket/socket.d.ts.map +0 -1
  252. package/lib/Socket/socket.js.map +0 -1
  253. package/lib/Types/Auth.d.ts.map +0 -1
  254. package/lib/Types/Auth.js.map +0 -1
  255. package/lib/Types/Bussines.d.ts +0 -25
  256. package/lib/Types/Bussines.d.ts.map +0 -1
  257. package/lib/Types/Bussines.js +0 -2
  258. package/lib/Types/Bussines.js.map +0 -1
  259. package/lib/Types/Call.d.ts.map +0 -1
  260. package/lib/Types/Call.js.map +0 -1
  261. package/lib/Types/Chat.d.ts.map +0 -1
  262. package/lib/Types/Chat.js.map +0 -1
  263. package/lib/Types/Contact.d.ts.map +0 -1
  264. package/lib/Types/Contact.js.map +0 -1
  265. package/lib/Types/Events.d.ts.map +0 -1
  266. package/lib/Types/Events.js.map +0 -1
  267. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  268. package/lib/Types/GroupMetadata.js.map +0 -1
  269. package/lib/Types/Label.d.ts.map +0 -1
  270. package/lib/Types/Label.js.map +0 -1
  271. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  272. package/lib/Types/LabelAssociation.js.map +0 -1
  273. package/lib/Types/Message.d.ts.map +0 -1
  274. package/lib/Types/Message.js.map +0 -1
  275. package/lib/Types/Mex.d.ts +0 -141
  276. package/lib/Types/Mex.d.ts.map +0 -1
  277. package/lib/Types/Mex.js +0 -37
  278. package/lib/Types/Mex.js.map +0 -1
  279. package/lib/Types/Product.d.ts.map +0 -1
  280. package/lib/Types/Product.js.map +0 -1
  281. package/lib/Types/Signal.d.ts.map +0 -1
  282. package/lib/Types/Signal.js.map +0 -1
  283. package/lib/Types/Socket.d.ts.map +0 -1
  284. package/lib/Types/Socket.js.map +0 -1
  285. package/lib/Types/State.d.ts.map +0 -1
  286. package/lib/Types/State.js.map +0 -1
  287. package/lib/Types/USync.d.ts +0 -26
  288. package/lib/Types/USync.d.ts.map +0 -1
  289. package/lib/Types/USync.js +0 -2
  290. package/lib/Types/USync.js.map +0 -1
  291. package/lib/Types/index.d.ts.map +0 -1
  292. package/lib/Types/index.js.map +0 -1
  293. package/lib/Utils/auth-utils.d.ts.map +0 -1
  294. package/lib/Utils/auth-utils.js.map +0 -1
  295. package/lib/Utils/browser-utils.d.ts +0 -4
  296. package/lib/Utils/browser-utils.d.ts.map +0 -1
  297. package/lib/Utils/browser-utils.js +0 -29
  298. package/lib/Utils/browser-utils.js.map +0 -1
  299. package/lib/Utils/business.d.ts.map +0 -1
  300. package/lib/Utils/business.js.map +0 -1
  301. package/lib/Utils/chat-utils.d.ts.map +0 -1
  302. package/lib/Utils/chat-utils.js.map +0 -1
  303. package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
  304. package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
  305. package/lib/Utils/companion-reg-client-utils.js +0 -35
  306. package/lib/Utils/companion-reg-client-utils.js.map +0 -1
  307. package/lib/Utils/crypto.d.ts.map +0 -1
  308. package/lib/Utils/crypto.js.map +0 -1
  309. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  310. package/lib/Utils/decode-wa-message.js.map +0 -1
  311. package/lib/Utils/event-buffer.d.ts.map +0 -1
  312. package/lib/Utils/event-buffer.js.map +0 -1
  313. package/lib/Utils/generics.d.ts.map +0 -1
  314. package/lib/Utils/generics.js.map +0 -1
  315. package/lib/Utils/history.d.ts.map +0 -1
  316. package/lib/Utils/history.js.map +0 -1
  317. package/lib/Utils/identity-change-handler.d.ts +0 -44
  318. package/lib/Utils/identity-change-handler.d.ts.map +0 -1
  319. package/lib/Utils/identity-change-handler.js +0 -50
  320. package/lib/Utils/identity-change-handler.js.map +0 -1
  321. package/lib/Utils/index.d.ts.map +0 -1
  322. package/lib/Utils/index.js.map +0 -1
  323. package/lib/Utils/link-preview.d.ts.map +0 -1
  324. package/lib/Utils/link-preview.js.map +0 -1
  325. package/lib/Utils/logger.d.ts.map +0 -1
  326. package/lib/Utils/logger.js.map +0 -1
  327. package/lib/Utils/lt-hash.d.ts.map +0 -1
  328. package/lib/Utils/lt-hash.js.map +0 -1
  329. package/lib/Utils/make-mutex.d.ts.map +0 -1
  330. package/lib/Utils/make-mutex.js.map +0 -1
  331. package/lib/Utils/message-retry-manager.d.ts +0 -115
  332. package/lib/Utils/message-retry-manager.d.ts.map +0 -1
  333. package/lib/Utils/message-retry-manager.js +0 -265
  334. package/lib/Utils/message-retry-manager.js.map +0 -1
  335. package/lib/Utils/messages-media.d.ts.map +0 -1
  336. package/lib/Utils/messages-media.js.map +0 -1
  337. package/lib/Utils/messages.d.ts.map +0 -1
  338. package/lib/Utils/messages.js.map +0 -1
  339. package/lib/Utils/noise-handler.d.ts.map +0 -1
  340. package/lib/Utils/noise-handler.js.map +0 -1
  341. package/lib/Utils/offline-node-processor.d.ts +0 -17
  342. package/lib/Utils/offline-node-processor.d.ts.map +0 -1
  343. package/lib/Utils/offline-node-processor.js +0 -40
  344. package/lib/Utils/offline-node-processor.js.map +0 -1
  345. package/lib/Utils/pre-key-manager.d.ts +0 -28
  346. package/lib/Utils/pre-key-manager.d.ts.map +0 -1
  347. package/lib/Utils/pre-key-manager.js +0 -106
  348. package/lib/Utils/pre-key-manager.js.map +0 -1
  349. package/lib/Utils/process-message.d.ts.map +0 -1
  350. package/lib/Utils/process-message.js.map +0 -1
  351. package/lib/Utils/reporting-utils.d.ts +0 -11
  352. package/lib/Utils/reporting-utils.d.ts.map +0 -1
  353. package/lib/Utils/reporting-utils.js +0 -258
  354. package/lib/Utils/reporting-utils.js.map +0 -1
  355. package/lib/Utils/signal.d.ts.map +0 -1
  356. package/lib/Utils/signal.js.map +0 -1
  357. package/lib/Utils/stanza-ack.d.ts +0 -11
  358. package/lib/Utils/stanza-ack.d.ts.map +0 -1
  359. package/lib/Utils/stanza-ack.js +0 -38
  360. package/lib/Utils/stanza-ack.js.map +0 -1
  361. package/lib/Utils/sync-action-utils.d.ts +0 -19
  362. package/lib/Utils/sync-action-utils.d.ts.map +0 -1
  363. package/lib/Utils/sync-action-utils.js +0 -49
  364. package/lib/Utils/sync-action-utils.js.map +0 -1
  365. package/lib/Utils/tc-token-utils.d.ts +0 -37
  366. package/lib/Utils/tc-token-utils.d.ts.map +0 -1
  367. package/lib/Utils/tc-token-utils.js +0 -164
  368. package/lib/Utils/tc-token-utils.js.map +0 -1
  369. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  370. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  371. package/lib/Utils/validate-connection.d.ts.map +0 -1
  372. package/lib/Utils/validate-connection.js.map +0 -1
  373. package/lib/WABinary/constants.d.ts.map +0 -1
  374. package/lib/WABinary/constants.js.map +0 -1
  375. package/lib/WABinary/decode.d.ts.map +0 -1
  376. package/lib/WABinary/decode.js.map +0 -1
  377. package/lib/WABinary/encode.d.ts.map +0 -1
  378. package/lib/WABinary/encode.js.map +0 -1
  379. package/lib/WABinary/generic-utils.d.ts.map +0 -1
  380. package/lib/WABinary/generic-utils.js.map +0 -1
  381. package/lib/WABinary/index.d.ts.map +0 -1
  382. package/lib/WABinary/index.js.map +0 -1
  383. package/lib/WABinary/jid-utils.d.ts.map +0 -1
  384. package/lib/WABinary/jid-utils.js.map +0 -1
  385. package/lib/WABinary/types.d.ts.map +0 -1
  386. package/lib/WABinary/types.js.map +0 -1
  387. package/lib/WAM/BinaryInfo.d.ts.map +0 -1
  388. package/lib/WAM/BinaryInfo.js.map +0 -1
  389. package/lib/WAM/constants.d.ts.map +0 -1
  390. package/lib/WAM/constants.js.map +0 -1
  391. package/lib/WAM/encode.d.ts.map +0 -1
  392. package/lib/WAM/encode.js.map +0 -1
  393. package/lib/WAM/index.d.ts.map +0 -1
  394. package/lib/WAM/index.js.map +0 -1
  395. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  396. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
  397. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -52
  398. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
  399. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
  400. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
  401. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -54
  402. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
  403. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
  404. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
  405. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -27
  406. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
  407. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
  408. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
  409. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -38
  410. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
  411. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
  412. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
  413. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -25
  414. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
  415. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
  416. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
  417. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
  418. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
  419. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
  420. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
  421. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
  422. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
  423. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  424. package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
  425. package/lib/WAUSync/Protocols/index.js +0 -6
  426. package/lib/WAUSync/Protocols/index.js.map +0 -1
  427. package/lib/WAUSync/USyncQuery.d.ts +0 -30
  428. package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
  429. package/lib/WAUSync/USyncQuery.js +0 -98
  430. package/lib/WAUSync/USyncQuery.js.map +0 -1
  431. package/lib/WAUSync/USyncUser.d.ts +0 -17
  432. package/lib/WAUSync/USyncUser.d.ts.map +0 -1
  433. package/lib/WAUSync/USyncUser.js +0 -31
  434. package/lib/WAUSync/USyncUser.js.map +0 -1
  435. package/lib/WAUSync/index.d.ts +0 -4
  436. package/lib/WAUSync/index.d.ts.map +0 -1
  437. package/lib/WAUSync/index.js +0 -4
  438. package/lib/WAUSync/index.js.map +0 -1
  439. package/lib/index.d.ts.map +0 -1
  440. package/lib/index.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import type { BinaryNode, BinaryNodeCodingOptions } from './types.js';
2
- export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer<ArrayBufferLike>>;
3
- export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
1
+ /// <reference types="node" />
2
+ import type { BinaryNode, BinaryNodeCodingOptions } from './types';
3
+ export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer>;
4
+ export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, 'DOUBLE_BYTE_TOKENS' | 'SINGLE_BYTE_TOKENS' | 'TAGS'>, indexRef?: {
4
5
  index: number;
5
6
  }) => BinaryNode;
6
7
  export declare const decodeBinaryNode: (buff: Buffer) => Promise<BinaryNode>;
7
- //# sourceMappingURL=decode.d.ts.map
@@ -1,19 +1,45 @@
1
- import { promisify } from 'util';
2
- import { inflate } from 'zlib';
3
- import * as constants from './constants.js';
4
- import { jidEncode, WAJIDDomains } from './jid-utils.js';
5
- const inflatePromise = promisify(inflate);
6
- export const decompressingIfRequired = async (buffer) => {
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.decodeBinaryNode = exports.decodeDecompressedBinaryNode = exports.decompressingIfRequired = void 0;
27
+ const util_1 = require("util");
28
+ const zlib_1 = require("zlib");
29
+ const constants = __importStar(require("./constants"));
30
+ const jid_utils_1 = require("./jid-utils");
31
+ const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
32
+ const decompressingIfRequired = async (buffer) => {
7
33
  if (2 & buffer.readUInt8()) {
8
34
  buffer = await inflatePromise(buffer.slice(1));
9
35
  }
10
- else {
11
- // nodes with no compression have a 0x00 prefix, we remove that
36
+ else { // nodes with no compression have a 0x00 prefix, we remove that
12
37
  buffer = buffer.slice(1);
13
38
  }
14
39
  return buffer;
15
40
  };
16
- export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
41
+ exports.decompressingIfRequired = decompressingIfRequired;
42
+ const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
17
43
  const { DOUBLE_BYTE_TOKENS, SINGLE_BYTE_TOKENS, TAGS } = opts;
18
44
  const checkEOS = (length) => {
19
45
  if (indexRef.index + length > buffer.length) {
@@ -120,41 +146,10 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
120
146
  throw new Error('invalid jid pair: ' + i + ', ' + j);
121
147
  };
122
148
  const readAdJid = () => {
123
- const rawDomainType = readByte();
124
- const domainType = Number(rawDomainType);
149
+ const agent = readByte();
125
150
  const device = readByte();
126
151
  const user = readString(readByte());
127
- let server = 's.whatsapp.net'; // default whatsapp server
128
- if (domainType === WAJIDDomains.LID) {
129
- server = 'lid';
130
- }
131
- else if (domainType === WAJIDDomains.HOSTED) {
132
- server = 'hosted';
133
- }
134
- else if (domainType === WAJIDDomains.HOSTED_LID) {
135
- server = 'hosted.lid';
136
- }
137
- return jidEncode(user, server, device);
138
- };
139
- const readFbJid = () => {
140
- const user = readString(readByte());
141
- const device = readInt(2);
142
- const server = readString(readByte());
143
- return `${user}:${device}@${server}`;
144
- };
145
- const readInteropJid = () => {
146
- const user = readString(readByte());
147
- const device = readInt(2);
148
- const integrator = readInt(2);
149
- let server = 'interop';
150
- const beforeServer = indexRef.index;
151
- try {
152
- server = readString(readByte());
153
- }
154
- catch (err) {
155
- indexRef.index = beforeServer;
156
- }
157
- return `${integrator}-${user}:${device}@${server}`;
152
+ return (0, jid_utils_1.jidEncode)(user, agent === 0 ? 's.whatsapp.net' : 'lid', device);
158
153
  };
159
154
  const readString = (tag) => {
160
155
  if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
@@ -176,10 +171,6 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
176
171
  return readStringFromChars(readInt(4));
177
172
  case TAGS.JID_PAIR:
178
173
  return readJidPair();
179
- case TAGS.FB_JID:
180
- return readFbJid();
181
- case TAGS.INTEROP_JID:
182
- return readInteropJid();
183
174
  case TAGS.AD_JID:
184
175
  return readAdJid();
185
176
  case TAGS.HEX_8:
@@ -193,7 +184,7 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
193
184
  const items = [];
194
185
  const size = readListSize(tag);
195
186
  for (let i = 0; i < size; i++) {
196
- items.push(decodeDecompressedBinaryNode(buffer, opts, indexRef));
187
+ items.push((0, exports.decodeDecompressedBinaryNode)(buffer, opts, indexRef));
197
188
  }
198
189
  return items;
199
190
  };
@@ -255,8 +246,9 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
255
246
  content: data
256
247
  };
257
248
  };
258
- export const decodeBinaryNode = async (buff) => {
259
- const decompBuff = await decompressingIfRequired(buff);
260
- return decodeDecompressedBinaryNode(decompBuff, constants);
249
+ exports.decodeDecompressedBinaryNode = decodeDecompressedBinaryNode;
250
+ const decodeBinaryNode = async (buff) => {
251
+ const decompBuff = await (0, exports.decompressingIfRequired)(buff);
252
+ return (0, exports.decodeDecompressedBinaryNode)(decompBuff, constants);
261
253
  };
262
- //# sourceMappingURL=decode.js.map
254
+ exports.decodeBinaryNode = decodeBinaryNode;
@@ -1,3 +1,3 @@
1
- import type { BinaryNode, BinaryNodeCodingOptions } from './types.js';
2
- export declare const encodeBinaryNode: (node: BinaryNode, opts?: Pick<BinaryNodeCodingOptions, "TAGS" | "TOKEN_MAP">, buffer?: number[]) => Buffer;
3
- //# sourceMappingURL=encode.d.ts.map
1
+ /// <reference types="node" />
2
+ import type { BinaryNode, BinaryNodeCodingOptions } from './types';
3
+ export declare const encodeBinaryNode: (node: BinaryNode, opts?: Pick<BinaryNodeCodingOptions, 'TAGS' | 'TOKEN_MAP'>, buffer?: number[]) => Buffer;
@@ -1,9 +1,36 @@
1
- import * as constants from './constants.js';
2
- import { jidDecode } from './jid-utils.js';
3
- export const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.encodeBinaryNode = void 0;
27
+ const constants = __importStar(require("./constants"));
28
+ const jid_utils_1 = require("./jid-utils");
29
+ const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
4
30
  const encoded = encodeBinaryNodeInner(node, opts, buffer);
5
31
  return Buffer.from(encoded);
6
32
  };
33
+ exports.encodeBinaryNode = encodeBinaryNode;
7
34
  const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
8
35
  const { TAGS, TOKEN_MAP } = opts;
9
36
  const pushByte = (value) => buffer.push(value & 0xff);
@@ -13,15 +40,11 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
13
40
  buffer.push((value >> (curShift * 8)) & 0xff);
14
41
  }
15
42
  };
16
- const pushBytes = (bytes) => {
17
- for (const b of bytes) {
18
- buffer.push(b);
19
- }
20
- };
43
+ const pushBytes = (bytes) => (bytes.forEach(b => buffer.push(b)));
21
44
  const pushInt16 = (value) => {
22
45
  pushBytes([(value >> 8) & 0xff, value & 0xff]);
23
46
  };
24
- const pushInt20 = (value) => pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]);
47
+ const pushInt20 = (value) => (pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]));
25
48
  const writeByteLength = (length) => {
26
49
  if (length >= 4294967296) {
27
50
  throw new Error('string too large to encode: ' + length);
@@ -116,10 +139,11 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
116
139
  }
117
140
  };
118
141
  const isNibble = (str) => {
119
- if (!str || str.length > TAGS.PACKED_MAX) {
142
+ if (str.length > TAGS.PACKED_MAX) {
120
143
  return false;
121
144
  }
122
- for (const char of str) {
145
+ for (let i = 0; i < str.length; i++) {
146
+ const char = str[i];
123
147
  const isInNibbleRange = char >= '0' && char <= '9';
124
148
  if (!isInNibbleRange && char !== '-' && char !== '.') {
125
149
  return false;
@@ -128,26 +152,19 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
128
152
  return true;
129
153
  };
130
154
  const isHex = (str) => {
131
- if (!str || str.length > TAGS.PACKED_MAX) {
155
+ if (str.length > TAGS.PACKED_MAX) {
132
156
  return false;
133
157
  }
134
- for (const char of str) {
158
+ for (let i = 0; i < str.length; i++) {
159
+ const char = str[i];
135
160
  const isInNibbleRange = char >= '0' && char <= '9';
136
- if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
161
+ if (!isInNibbleRange && !(char >= 'A' && char <= 'F') && !(char >= 'a' && char <= 'f')) {
137
162
  return false;
138
163
  }
139
164
  }
140
165
  return true;
141
166
  };
142
167
  const writeString = (str) => {
143
- if (str === undefined || str === null) {
144
- pushByte(TAGS.LIST_EMPTY);
145
- return;
146
- }
147
- if (str === '') {
148
- writeStringRaw(str);
149
- return;
150
- }
151
168
  const tokenIndex = TOKEN_MAP[str];
152
169
  if (tokenIndex) {
153
170
  if (typeof tokenIndex.dict === 'number') {
@@ -161,8 +178,8 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
161
178
  else if (isHex(str)) {
162
179
  writePackedBytes(str, 'hex');
163
180
  }
164
- else {
165
- const decodedJid = jidDecode(str);
181
+ else if (str) {
182
+ const decodedJid = (0, jid_utils_1.jidDecode)(str);
166
183
  if (decodedJid) {
167
184
  writeJid(decodedJid);
168
185
  }
@@ -183,10 +200,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
183
200
  pushInt16(listSize);
184
201
  }
185
202
  };
186
- if (!tag) {
187
- throw new Error('Invalid node: tag cannot be undefined');
188
- }
189
- const validAttributes = Object.keys(attrs || {}).filter(k => typeof attrs[k] !== 'undefined' && attrs[k] !== null);
203
+ const validAttributes = Object.keys(attrs).filter(k => (typeof attrs[k] !== 'undefined' && attrs[k] !== null));
190
204
  writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' ? 1 : 0));
191
205
  writeString(tag);
192
206
  for (const key of validAttributes) {
@@ -203,9 +217,8 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
203
217
  pushBytes(content);
204
218
  }
205
219
  else if (Array.isArray(content)) {
206
- const validContent = content.filter(item => item && (item.tag || Buffer.isBuffer(item) || item instanceof Uint8Array || typeof item === 'string'));
207
- writeListStart(validContent.length);
208
- for (const item of validContent) {
220
+ writeListStart(content.length);
221
+ for (const item of content) {
209
222
  encodeBinaryNodeInner(item, opts, buffer);
210
223
  }
211
224
  }
@@ -217,4 +230,3 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
217
230
  }
218
231
  return buffer;
219
232
  };
220
- //# sourceMappingURL=encode.js.map
@@ -1,9 +1,10 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import { type BinaryNode } from './types.js';
1
+ /// <reference types="node" />
2
+ import { proto } from '../../WAProto';
3
+ import { BinaryNode } from './types';
3
4
  export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
4
- export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
5
5
  export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
6
- export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | undefined;
6
+ export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
7
+ export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array | Buffer | undefined;
7
8
  export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => string | undefined;
8
9
  export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined;
9
10
  export declare const assertNodeErrorFree: (node: BinaryNode) => void;
@@ -11,5 +12,4 @@ export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: strin
11
12
  [_: string]: string;
12
13
  };
13
14
  export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
14
- export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): string;
15
- //# sourceMappingURL=generic-utils.d.ts.map
15
+ export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any;
@@ -1,43 +1,40 @@
1
- import { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import {} from './types.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.binaryNodeToString = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
4
+ const boom_1 = require("@hapi/boom");
5
+ const WAProto_1 = require("../../WAProto");
4
6
  // some extra useful utilities
5
- const indexCache = new WeakMap();
6
- export const getBinaryNodeChildren = (node, childTag) => {
7
- if (!node || !Array.isArray(node.content))
8
- return [];
9
- let index = indexCache.get(node);
10
- // Build the index once per node
11
- if (!index) {
12
- index = new Map();
13
- for (const child of node.content) {
14
- let arr = index.get(child.tag);
15
- if (!arr)
16
- index.set(child.tag, (arr = []));
17
- arr.push(child);
18
- }
19
- indexCache.set(node, index);
7
+ const getBinaryNodeChildren = (node, childTag) => {
8
+ if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
9
+ return node.content.filter(item => item.tag === childTag);
20
10
  }
21
- // Return first matching child
22
- return index.get(childTag) || [];
23
- };
24
- export const getBinaryNodeChild = (node, childTag) => {
25
- return getBinaryNodeChildren(node, childTag)[0];
11
+ return [];
26
12
  };
27
- export const getAllBinaryNodeChildren = ({ content }) => {
13
+ exports.getBinaryNodeChildren = getBinaryNodeChildren;
14
+ const getAllBinaryNodeChildren = ({ content }) => {
28
15
  if (Array.isArray(content)) {
29
16
  return content;
30
17
  }
31
18
  return [];
32
19
  };
33
- export const getBinaryNodeChildBuffer = (node, childTag) => {
34
- const child = getBinaryNodeChild(node, childTag)?.content;
20
+ exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
21
+ const getBinaryNodeChild = (node, childTag) => {
22
+ if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
23
+ return node === null || node === void 0 ? void 0 : node.content.find(item => item.tag === childTag);
24
+ }
25
+ };
26
+ exports.getBinaryNodeChild = getBinaryNodeChild;
27
+ const getBinaryNodeChildBuffer = (node, childTag) => {
28
+ var _a;
29
+ const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
35
30
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
36
31
  return child;
37
32
  }
38
33
  };
39
- export const getBinaryNodeChildString = (node, childTag) => {
40
- const child = getBinaryNodeChild(node, childTag)?.content;
34
+ exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
35
+ const getBinaryNodeChildString = (node, childTag) => {
36
+ var _a;
37
+ const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
41
38
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
42
39
  return Buffer.from(child).toString('utf-8');
43
40
  }
@@ -45,42 +42,42 @@ export const getBinaryNodeChildString = (node, childTag) => {
45
42
  return child;
46
43
  }
47
44
  };
48
- export const getBinaryNodeChildUInt = (node, childTag, length) => {
49
- const buff = getBinaryNodeChildBuffer(node, childTag);
45
+ exports.getBinaryNodeChildString = getBinaryNodeChildString;
46
+ const getBinaryNodeChildUInt = (node, childTag, length) => {
47
+ const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag);
50
48
  if (buff) {
51
49
  return bufferToUInt(buff, length);
52
50
  }
53
51
  };
54
- export const assertNodeErrorFree = (node) => {
55
- const errNode = getBinaryNodeChild(node, 'error');
52
+ exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
53
+ const assertNodeErrorFree = (node) => {
54
+ const errNode = (0, exports.getBinaryNodeChild)(node, 'error');
56
55
  if (errNode) {
57
- throw new Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
56
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
58
57
  }
59
58
  };
60
- export const reduceBinaryNodeToDictionary = (node, tag) => {
61
- const nodes = getBinaryNodeChildren(node, tag);
59
+ exports.assertNodeErrorFree = assertNodeErrorFree;
60
+ const reduceBinaryNodeToDictionary = (node, tag) => {
61
+ const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
62
62
  const dict = nodes.reduce((dict, { attrs }) => {
63
- if (typeof attrs.name === 'string') {
64
- dict[attrs.name] = attrs.value || attrs.config_value;
65
- }
66
- else {
67
- dict[attrs.config_code] = attrs.value || attrs.config_value;
68
- }
63
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value;
69
64
  return dict;
70
65
  }, {});
71
66
  return dict;
72
67
  };
73
- export const getBinaryNodeMessages = ({ content }) => {
68
+ exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
69
+ const getBinaryNodeMessages = ({ content }) => {
74
70
  const msgs = [];
75
71
  if (Array.isArray(content)) {
76
72
  for (const item of content) {
77
73
  if (item.tag === 'message') {
78
- msgs.push(proto.WebMessageInfo.decode(item.content).toJSON());
74
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content));
79
75
  }
80
76
  }
81
77
  }
82
78
  return msgs;
83
79
  };
80
+ exports.getBinaryNodeMessages = getBinaryNodeMessages;
84
81
  function bufferToUInt(e, t) {
85
82
  let a = 0;
86
83
  for (let i = 0; i < t; i++) {
@@ -89,7 +86,7 @@ function bufferToUInt(e, t) {
89
86
  return a;
90
87
  }
91
88
  const tabs = (n) => '\t'.repeat(n);
92
- export function binaryNodeToString(node, i = 0) {
89
+ function binaryNodeToString(node, i = 0) {
93
90
  if (!node) {
94
91
  return node;
95
92
  }
@@ -100,7 +97,7 @@ export function binaryNodeToString(node, i = 0) {
100
97
  return tabs(i) + Buffer.from(node).toString('hex');
101
98
  }
102
99
  if (Array.isArray(node)) {
103
- return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
100
+ return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
104
101
  }
105
102
  const children = binaryNodeToString(node.content, i + 1);
106
103
  const tag = `<${node.tag} ${Object.entries(node.attrs || {})
@@ -110,4 +107,4 @@ export function binaryNodeToString(node, i = 0) {
110
107
  const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
111
108
  return tag + content;
112
109
  }
113
- //# sourceMappingURL=generic-utils.js.map
110
+ exports.binaryNodeToString = binaryNodeToString;
@@ -1,6 +1,5 @@
1
- export * from './encode.js';
2
- export * from './decode.js';
3
- export * from './generic-utils.js';
4
- export * from './jid-utils.js';
5
- export * from './types.js';
6
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './encode';
2
+ export * from './decode';
3
+ export * from './generic-utils';
4
+ export * from './jid-utils';
5
+ export * from './types';
@@ -1,6 +1,21 @@
1
- export * from './encode.js';
2
- export * from './decode.js';
3
- export * from './generic-utils.js';
4
- export * from './jid-utils.js';
5
- export * from './types.js';
6
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./encode"), exports);
18
+ __exportStar(require("./decode"), exports);
19
+ __exportStar(require("./generic-utils"), exports);
20
+ __exportStar(require("./jid-utils"), exports);
21
+ __exportStar(require("./types"), exports);
@@ -3,46 +3,29 @@ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
3
3
  export declare const SERVER_JID = "server@c.us";
4
4
  export declare const PSA_WID = "0@c.us";
5
5
  export declare const STORIES_JID = "status@broadcast";
6
- export declare const META_AI_JID = "13135550002@c.us";
7
- export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot' | 'hosted' | 'hosted.lid';
8
- export declare enum WAJIDDomains {
9
- WHATSAPP = 0,
10
- LID = 1,
11
- HOSTED = 128,
12
- HOSTED_LID = 129
13
- }
6
+ export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid';
14
7
  export type JidWithDevice = {
15
8
  user: string;
16
9
  device?: number;
17
10
  };
18
11
  export type FullJid = JidWithDevice & {
19
- server: JidServer;
12
+ server: JidServer | string;
20
13
  domainType?: number;
21
14
  };
22
- export declare const getServerFromDomainType: (initialServer: string, domainType?: WAJIDDomains) => JidServer;
23
15
  export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
24
16
  export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
25
17
  /** is the jid a user */
26
18
  export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
27
- /** is the jid Meta AI */
28
- export declare const isJidMetaAI: (jid: string | undefined) => boolean | undefined;
29
- /** is the jid a PN user */
30
- export declare const isPnUser: (jid: string | undefined) => boolean | undefined;
31
- /** is the jid a LID */
19
+ /** is the jid a user */
20
+ export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
21
+ /** is the jid a group */
32
22
  export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
33
23
  /** is the jid a broadcast */
34
24
  export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
35
25
  /** is the jid a group */
36
26
  export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
37
27
  /** is the jid the status broadcast */
38
- export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broadcast";
28
+ export declare const isJidStatusBroadcast: (jid: string) => boolean;
39
29
  /** is the jid a newsletter */
40
30
  export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
41
- /** is the jid a hosted PN */
42
- export declare const isHostedPnUser: (jid: string | undefined) => boolean | undefined;
43
- /** is the jid a hosted LID */
44
- export declare const isHostedLidUser: (jid: string | undefined) => boolean | undefined;
45
- export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
46
31
  export declare const jidNormalizedUser: (jid: string | undefined) => string;
47
- export declare const transferDevice: (fromJid: string, toJid: string) => string;
48
- //# sourceMappingURL=jid-utils.d.ts.map