@d0v3riz/baileys 6.7.21 → 6.7.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/WAProto/GenerateStatics.sh +2 -3
  2. package/WAProto/index.js +4138 -4136
  3. package/lib/Defaults/index.d.ts +2 -3
  4. package/lib/Defaults/index.js +40 -36
  5. package/lib/Signal/Group/ciphertext-message.d.ts +0 -1
  6. package/lib/Signal/Group/ciphertext-message.js +5 -2
  7. package/lib/Signal/Group/group-session-builder.d.ts +3 -4
  8. package/lib/Signal/Group/group-session-builder.js +41 -7
  9. package/lib/Signal/Group/group_cipher.d.ts +2 -3
  10. package/lib/Signal/Group/group_cipher.js +16 -14
  11. package/lib/Signal/Group/index.d.ts +11 -12
  12. package/lib/Signal/Group/index.js +57 -12
  13. package/lib/Signal/Group/keyhelper.d.ts +1 -2
  14. package/lib/Signal/Group/keyhelper.js +44 -8
  15. package/lib/Signal/Group/queue-job.d.ts +0 -2
  16. package/lib/Signal/Group/queue-job.js +5 -5
  17. package/lib/Signal/Group/sender-chain-key.d.ts +1 -2
  18. package/lib/Signal/Group/sender-chain-key.js +9 -7
  19. package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -2
  20. package/lib/Signal/Group/sender-key-distribution-message.js +9 -6
  21. package/lib/Signal/Group/sender-key-message.d.ts +1 -2
  22. package/lib/Signal/Group/sender-key-message.js +12 -10
  23. package/lib/Signal/Group/sender-key-name.d.ts +0 -1
  24. package/lib/Signal/Group/sender-key-name.js +5 -2
  25. package/lib/Signal/Group/sender-key-record.d.ts +1 -2
  26. package/lib/Signal/Group/sender-key-record.js +12 -9
  27. package/lib/Signal/Group/sender-key-state.d.ts +2 -3
  28. package/lib/Signal/Group/sender-key-state.js +9 -6
  29. package/lib/Signal/Group/sender-message-key.d.ts +0 -1
  30. package/lib/Signal/Group/sender-message-key.js +7 -5
  31. package/lib/Signal/libsignal.d.ts +2 -3
  32. package/lib/Signal/libsignal.js +55 -22
  33. package/lib/Socket/Client/index.d.ts +2 -3
  34. package/lib/Socket/Client/index.js +18 -3
  35. package/lib/Socket/Client/types.d.ts +1 -2
  36. package/lib/Socket/Client/types.js +6 -4
  37. package/lib/Socket/Client/websocket.d.ts +1 -2
  38. package/lib/Socket/Client/websocket.js +26 -14
  39. package/lib/Socket/business.d.ts +64 -66
  40. package/lib/Socket/business.js +37 -32
  41. package/lib/Socket/chats.d.ts +19 -21
  42. package/lib/Socket/chats.js +141 -176
  43. package/lib/Socket/groups.d.ts +35 -37
  44. package/lib/Socket/groups.js +63 -56
  45. package/lib/Socket/index.d.ts +70 -102
  46. package/lib/Socket/index.js +9 -16
  47. package/lib/Socket/messages-recv.d.ts +49 -51
  48. package/lib/Socket/messages-recv.js +173 -180
  49. package/lib/Socket/messages-send.d.ts +46 -48
  50. package/lib/Socket/messages-send.js +84 -75
  51. package/lib/Socket/mex.d.ts +1 -2
  52. package/lib/Socket/mex.js +16 -12
  53. package/lib/Socket/newsletter.d.ts +44 -46
  54. package/lib/Socket/newsletter.js +27 -23
  55. package/lib/Socket/socket.d.ts +12 -13
  56. package/lib/Socket/socket.js +115 -135
  57. package/lib/Socket/usync.d.ts +14 -15
  58. package/lib/Socket/usync.js +11 -9
  59. package/lib/Types/Auth.d.ts +3 -4
  60. package/lib/Types/Auth.js +2 -2
  61. package/lib/Types/Call.d.ts +0 -1
  62. package/lib/Types/Call.js +2 -2
  63. package/lib/Types/Chat.d.ts +7 -10
  64. package/lib/Types/Chat.js +4 -2
  65. package/lib/Types/Contact.d.ts +0 -1
  66. package/lib/Types/Contact.js +2 -2
  67. package/lib/Types/Events.d.ts +10 -11
  68. package/lib/Types/Events.js +2 -2
  69. package/lib/Types/GroupMetadata.d.ts +2 -3
  70. package/lib/Types/GroupMetadata.js +2 -2
  71. package/lib/Types/Label.d.ts +0 -1
  72. package/lib/Types/Label.js +5 -3
  73. package/lib/Types/LabelAssociation.d.ts +0 -1
  74. package/lib/Types/LabelAssociation.js +5 -3
  75. package/lib/Types/Message.d.ts +7 -9
  76. package/lib/Types/Message.js +7 -7
  77. package/lib/Types/Newsletter.d.ts +0 -1
  78. package/lib/Types/Newsletter.js +7 -5
  79. package/lib/Types/Product.d.ts +1 -2
  80. package/lib/Types/Product.js +2 -2
  81. package/lib/Types/Signal.d.ts +1 -2
  82. package/lib/Types/Signal.js +2 -2
  83. package/lib/Types/Socket.d.ts +7 -8
  84. package/lib/Types/Socket.js +2 -3
  85. package/lib/Types/State.d.ts +2 -14
  86. package/lib/Types/State.js +2 -13
  87. package/lib/Types/USync.d.ts +2 -3
  88. package/lib/Types/USync.js +2 -2
  89. package/lib/Types/index.d.ts +14 -15
  90. package/lib/Types/index.js +31 -15
  91. package/lib/Utils/auth-utils.d.ts +2 -3
  92. package/lib/Utils/auth-utils.js +34 -25
  93. package/lib/Utils/baileys-event-stream.d.ts +1 -2
  94. package/lib/Utils/baileys-event-stream.js +22 -15
  95. package/lib/Utils/business.d.ts +2 -3
  96. package/lib/Utils/business.js +70 -61
  97. package/lib/Utils/chat-utils.d.ts +7 -8
  98. package/lib/Utils/chat-utils.js +137 -130
  99. package/lib/Utils/crypto.d.ts +1 -2
  100. package/lib/Utils/crypto.js +86 -37
  101. package/lib/Utils/decode-wa-message.d.ts +4 -5
  102. package/lib/Utils/decode-wa-message.js +44 -38
  103. package/lib/Utils/event-buffer.d.ts +4 -4
  104. package/lib/Utils/event-buffer.js +50 -37
  105. package/lib/Utils/generics.d.ts +8 -9
  106. package/lib/Utils/generics.js +114 -87
  107. package/lib/Utils/history.d.ts +3 -4
  108. package/lib/Utils/history.js +40 -32
  109. package/lib/Utils/index.d.ts +17 -18
  110. package/lib/Utils/index.js +33 -18
  111. package/lib/Utils/link-preview.d.ts +3 -4
  112. package/lib/Utils/link-preview.js +47 -10
  113. package/lib/Utils/logger.d.ts +6 -8
  114. package/lib/Utils/logger.js +7 -3
  115. package/lib/Utils/lt-hash.d.ts +8 -9
  116. package/lib/Utils/lt-hash.js +26 -23
  117. package/lib/Utils/make-mutex.d.ts +0 -1
  118. package/lib/Utils/make-mutex.js +9 -5
  119. package/lib/Utils/messages-media.d.ts +10 -11
  120. package/lib/Utils/messages-media.js +203 -141
  121. package/lib/Utils/messages.d.ts +6 -7
  122. package/lib/Utils/messages.js +199 -190
  123. package/lib/Utils/noise-handler.d.ts +4 -5
  124. package/lib/Utils/noise-handler.js +26 -22
  125. package/lib/Utils/process-message.d.ts +4 -5
  126. package/lib/Utils/process-message.js +104 -95
  127. package/lib/Utils/signal.d.ts +4 -5
  128. package/lib/Utils/signal.js +52 -47
  129. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  130. package/lib/Utils/use-multi-file-auth-state.js +26 -23
  131. package/lib/Utils/validate-connection.d.ts +3 -4
  132. package/lib/Utils/validate-connection.js +58 -52
  133. package/lib/WABinary/constants.d.ts +0 -1
  134. package/lib/WABinary/constants.js +11 -9
  135. package/lib/WABinary/decode.d.ts +1 -2
  136. package/lib/WABinary/decode.js +51 -13
  137. package/lib/WABinary/encode.d.ts +1 -2
  138. package/lib/WABinary/encode.js +41 -5
  139. package/lib/WABinary/generic-utils.d.ts +3 -4
  140. package/lib/WABinary/generic-utils.js +38 -30
  141. package/lib/WABinary/index.d.ts +5 -6
  142. package/lib/WABinary/index.js +21 -6
  143. package/lib/WABinary/jid-utils.d.ts +0 -1
  144. package/lib/WABinary/jid-utils.js +35 -21
  145. package/lib/WABinary/types.d.ts +1 -2
  146. package/lib/WABinary/types.js +2 -2
  147. package/lib/WAM/BinaryInfo.d.ts +1 -2
  148. package/lib/WAM/BinaryInfo.js +5 -2
  149. package/lib/WAM/constants.d.ts +0 -1
  150. package/lib/WAM/constants.js +6 -4
  151. package/lib/WAM/encode.d.ts +1 -2
  152. package/lib/WAM/encode.js +14 -12
  153. package/lib/WAM/index.d.ts +3 -4
  154. package/lib/WAM/index.js +19 -4
  155. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
  156. package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -6
  157. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
  158. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +12 -9
  159. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
  160. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -6
  161. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
  162. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +11 -7
  163. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
  164. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +21 -19
  165. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -3
  166. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +5 -2
  167. package/lib/WAUSync/Protocols/index.d.ts +4 -5
  168. package/lib/WAUSync/Protocols/index.js +20 -5
  169. package/lib/WAUSync/USyncQuery.d.ts +3 -4
  170. package/lib/WAUSync/USyncQuery.js +20 -18
  171. package/lib/WAUSync/USyncUser.d.ts +5 -6
  172. package/lib/WAUSync/USyncUser.js +5 -2
  173. package/lib/WAUSync/index.d.ts +3 -4
  174. package/lib/WAUSync/index.js +19 -4
  175. package/lib/index.d.ts +8 -9
  176. package/lib/index.js +30 -11
  177. package/package.json +26 -26
  178. package/WAProto/fix-imports.js +0 -29
  179. package/lib/Defaults/index.d.ts.map +0 -1
  180. package/lib/Defaults/index.js.map +0 -1
  181. package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
  182. package/lib/Signal/Group/ciphertext-message.js.map +0 -1
  183. package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
  184. package/lib/Signal/Group/group-session-builder.js.map +0 -1
  185. package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
  186. package/lib/Signal/Group/group_cipher.js.map +0 -1
  187. package/lib/Signal/Group/index.d.ts.map +0 -1
  188. package/lib/Signal/Group/index.js.map +0 -1
  189. package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
  190. package/lib/Signal/Group/keyhelper.js.map +0 -1
  191. package/lib/Signal/Group/queue-job.d.ts.map +0 -1
  192. package/lib/Signal/Group/queue-job.js.map +0 -1
  193. package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
  194. package/lib/Signal/Group/sender-chain-key.js.map +0 -1
  195. package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
  196. package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
  197. package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
  198. package/lib/Signal/Group/sender-key-message.js.map +0 -1
  199. package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
  200. package/lib/Signal/Group/sender-key-name.js.map +0 -1
  201. package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
  202. package/lib/Signal/Group/sender-key-record.js.map +0 -1
  203. package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
  204. package/lib/Signal/Group/sender-key-state.js.map +0 -1
  205. package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
  206. package/lib/Signal/Group/sender-message-key.js.map +0 -1
  207. package/lib/Signal/libsignal.d.ts.map +0 -1
  208. package/lib/Signal/libsignal.js.map +0 -1
  209. package/lib/Socket/Client/index.d.ts.map +0 -1
  210. package/lib/Socket/Client/index.js.map +0 -1
  211. package/lib/Socket/Client/types.d.ts.map +0 -1
  212. package/lib/Socket/Client/types.js.map +0 -1
  213. package/lib/Socket/Client/websocket.d.ts.map +0 -1
  214. package/lib/Socket/Client/websocket.js.map +0 -1
  215. package/lib/Socket/business.d.ts.map +0 -1
  216. package/lib/Socket/business.js.map +0 -1
  217. package/lib/Socket/chats.d.ts.map +0 -1
  218. package/lib/Socket/chats.js.map +0 -1
  219. package/lib/Socket/communities.d.ts +0 -219
  220. package/lib/Socket/communities.d.ts.map +0 -1
  221. package/lib/Socket/communities.js +0 -351
  222. package/lib/Socket/communities.js.map +0 -1
  223. package/lib/Socket/groups.d.ts.map +0 -1
  224. package/lib/Socket/groups.js.map +0 -1
  225. package/lib/Socket/index.d.ts.map +0 -1
  226. package/lib/Socket/index.js.map +0 -1
  227. package/lib/Socket/messages-recv.d.ts.map +0 -1
  228. package/lib/Socket/messages-recv.js.map +0 -1
  229. package/lib/Socket/messages-send.d.ts.map +0 -1
  230. package/lib/Socket/messages-send.js.map +0 -1
  231. package/lib/Socket/mex.d.ts.map +0 -1
  232. package/lib/Socket/mex.js.map +0 -1
  233. package/lib/Socket/newsletter.d.ts.map +0 -1
  234. package/lib/Socket/newsletter.js.map +0 -1
  235. package/lib/Socket/socket.d.ts.map +0 -1
  236. package/lib/Socket/socket.js.map +0 -1
  237. package/lib/Socket/usync.d.ts.map +0 -1
  238. package/lib/Socket/usync.js.map +0 -1
  239. package/lib/Types/Auth.d.ts.map +0 -1
  240. package/lib/Types/Auth.js.map +0 -1
  241. package/lib/Types/Call.d.ts.map +0 -1
  242. package/lib/Types/Call.js.map +0 -1
  243. package/lib/Types/Chat.d.ts.map +0 -1
  244. package/lib/Types/Chat.js.map +0 -1
  245. package/lib/Types/Contact.d.ts.map +0 -1
  246. package/lib/Types/Contact.js.map +0 -1
  247. package/lib/Types/Events.d.ts.map +0 -1
  248. package/lib/Types/Events.js.map +0 -1
  249. package/lib/Types/GroupMetadata.d.ts.map +0 -1
  250. package/lib/Types/GroupMetadata.js.map +0 -1
  251. package/lib/Types/Label.d.ts.map +0 -1
  252. package/lib/Types/Label.js.map +0 -1
  253. package/lib/Types/LabelAssociation.d.ts.map +0 -1
  254. package/lib/Types/LabelAssociation.js.map +0 -1
  255. package/lib/Types/Message.d.ts.map +0 -1
  256. package/lib/Types/Message.js.map +0 -1
  257. package/lib/Types/Newsletter.d.ts.map +0 -1
  258. package/lib/Types/Newsletter.js.map +0 -1
  259. package/lib/Types/Product.d.ts.map +0 -1
  260. package/lib/Types/Product.js.map +0 -1
  261. package/lib/Types/Signal.d.ts.map +0 -1
  262. package/lib/Types/Signal.js.map +0 -1
  263. package/lib/Types/Socket.d.ts.map +0 -1
  264. package/lib/Types/Socket.js.map +0 -1
  265. package/lib/Types/State.d.ts.map +0 -1
  266. package/lib/Types/State.js.map +0 -1
  267. package/lib/Types/USync.d.ts.map +0 -1
  268. package/lib/Types/USync.js.map +0 -1
  269. package/lib/Types/index.d.ts.map +0 -1
  270. package/lib/Types/index.js.map +0 -1
  271. package/lib/Utils/auth-utils.d.ts.map +0 -1
  272. package/lib/Utils/auth-utils.js.map +0 -1
  273. package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
  274. package/lib/Utils/baileys-event-stream.js.map +0 -1
  275. package/lib/Utils/business.d.ts.map +0 -1
  276. package/lib/Utils/business.js.map +0 -1
  277. package/lib/Utils/chat-utils.d.ts.map +0 -1
  278. package/lib/Utils/chat-utils.js.map +0 -1
  279. package/lib/Utils/crypto.d.ts.map +0 -1
  280. package/lib/Utils/crypto.js.map +0 -1
  281. package/lib/Utils/decode-wa-message.d.ts.map +0 -1
  282. package/lib/Utils/decode-wa-message.js.map +0 -1
  283. package/lib/Utils/event-buffer.d.ts.map +0 -1
  284. package/lib/Utils/event-buffer.js.map +0 -1
  285. package/lib/Utils/generics.d.ts.map +0 -1
  286. package/lib/Utils/generics.js.map +0 -1
  287. package/lib/Utils/history.d.ts.map +0 -1
  288. package/lib/Utils/history.js.map +0 -1
  289. package/lib/Utils/index.d.ts.map +0 -1
  290. package/lib/Utils/index.js.map +0 -1
  291. package/lib/Utils/link-preview.d.ts.map +0 -1
  292. package/lib/Utils/link-preview.js.map +0 -1
  293. package/lib/Utils/logger.d.ts.map +0 -1
  294. package/lib/Utils/logger.js.map +0 -1
  295. package/lib/Utils/lt-hash.d.ts.map +0 -1
  296. package/lib/Utils/lt-hash.js.map +0 -1
  297. package/lib/Utils/make-mutex.d.ts.map +0 -1
  298. package/lib/Utils/make-mutex.js.map +0 -1
  299. package/lib/Utils/messages-media.d.ts.map +0 -1
  300. package/lib/Utils/messages-media.js.map +0 -1
  301. package/lib/Utils/messages.d.ts.map +0 -1
  302. package/lib/Utils/messages.js.map +0 -1
  303. package/lib/Utils/noise-handler.d.ts.map +0 -1
  304. package/lib/Utils/noise-handler.js.map +0 -1
  305. package/lib/Utils/process-message.d.ts.map +0 -1
  306. package/lib/Utils/process-message.js.map +0 -1
  307. package/lib/Utils/signal.d.ts.map +0 -1
  308. package/lib/Utils/signal.js.map +0 -1
  309. package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
  310. package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
  311. package/lib/Utils/validate-connection.d.ts.map +0 -1
  312. package/lib/Utils/validate-connection.js.map +0 -1
  313. package/lib/WABinary/constants.d.ts.map +0 -1
  314. package/lib/WABinary/constants.js.map +0 -1
  315. package/lib/WABinary/decode.d.ts.map +0 -1
  316. package/lib/WABinary/decode.js.map +0 -1
  317. package/lib/WABinary/encode.d.ts.map +0 -1
  318. package/lib/WABinary/encode.js.map +0 -1
  319. package/lib/WABinary/generic-utils.d.ts.map +0 -1
  320. package/lib/WABinary/generic-utils.js.map +0 -1
  321. package/lib/WABinary/index.d.ts.map +0 -1
  322. package/lib/WABinary/index.js.map +0 -1
  323. package/lib/WABinary/jid-utils.d.ts.map +0 -1
  324. package/lib/WABinary/jid-utils.js.map +0 -1
  325. package/lib/WABinary/types.d.ts.map +0 -1
  326. package/lib/WABinary/types.js.map +0 -1
  327. package/lib/WAM/BinaryInfo.d.ts.map +0 -1
  328. package/lib/WAM/BinaryInfo.js.map +0 -1
  329. package/lib/WAM/constants.d.ts.map +0 -1
  330. package/lib/WAM/constants.js.map +0 -1
  331. package/lib/WAM/encode.d.ts.map +0 -1
  332. package/lib/WAM/encode.js.map +0 -1
  333. package/lib/WAM/index.d.ts.map +0 -1
  334. package/lib/WAM/index.js.map +0 -1
  335. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
  336. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
  337. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
  338. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
  339. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
  340. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
  341. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
  342. package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
  343. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
  344. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
  345. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
  346. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
  347. package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
  348. package/lib/WAUSync/Protocols/index.js.map +0 -1
  349. package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
  350. package/lib/WAUSync/USyncQuery.js.map +0 -1
  351. package/lib/WAUSync/USyncUser.d.ts.map +0 -1
  352. package/lib/WAUSync/USyncUser.js.map +0 -1
  353. package/lib/WAUSync/index.d.ts.map +0 -1
  354. package/lib/WAUSync/index.js.map +0 -1
  355. package/lib/index.d.ts.map +0 -1
  356. package/lib/index.js.map +0 -1
@@ -1,9 +1,45 @@
1
- import { promisify } from 'util';
2
- import { inflate } from 'zlib';
3
- import * as constants from './constants.js';
4
- import { jidEncode } 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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.decodeBinaryNode = exports.decodeDecompressedBinaryNode = exports.decompressingIfRequired = void 0;
37
+ const util_1 = require("util");
38
+ const zlib_1 = require("zlib");
39
+ const constants = __importStar(require("./constants"));
40
+ const jid_utils_1 = require("./jid-utils");
41
+ const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
42
+ const decompressingIfRequired = async (buffer) => {
7
43
  if (2 & buffer.readUInt8()) {
8
44
  buffer = await inflatePromise(buffer.slice(1));
9
45
  }
@@ -13,7 +49,8 @@ export const decompressingIfRequired = async (buffer) => {
13
49
  }
14
50
  return buffer;
15
51
  };
16
- export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
52
+ exports.decompressingIfRequired = decompressingIfRequired;
53
+ const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
17
54
  const { DOUBLE_BYTE_TOKENS, SINGLE_BYTE_TOKENS, TAGS } = opts;
18
55
  const checkEOS = (length) => {
19
56
  if (indexRef.index + length > buffer.length) {
@@ -124,7 +161,7 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
124
161
  const domainType = Number(rawDomainType);
125
162
  const device = readByte();
126
163
  const user = readString(readByte());
127
- return jidEncode(user, domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid', device);
164
+ return (0, jid_utils_1.jidEncode)(user, domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid', device);
128
165
  };
129
166
  const readString = (tag) => {
130
167
  if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
@@ -159,7 +196,7 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
159
196
  const items = [];
160
197
  const size = readListSize(tag);
161
198
  for (let i = 0; i < size; i++) {
162
- items.push(decodeDecompressedBinaryNode(buffer, opts, indexRef));
199
+ items.push((0, exports.decodeDecompressedBinaryNode)(buffer, opts, indexRef));
163
200
  }
164
201
  return items;
165
202
  };
@@ -221,8 +258,9 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0
221
258
  content: data
222
259
  };
223
260
  };
224
- export const decodeBinaryNode = async (buff) => {
225
- const decompBuff = await decompressingIfRequired(buff);
226
- return decodeDecompressedBinaryNode(decompBuff, constants);
261
+ exports.decodeDecompressedBinaryNode = decodeDecompressedBinaryNode;
262
+ const decodeBinaryNode = async (buff) => {
263
+ const decompBuff = await (0, exports.decompressingIfRequired)(buff);
264
+ return (0, exports.decodeDecompressedBinaryNode)(decompBuff, constants);
227
265
  };
228
- //# sourceMappingURL=decode.js.map
266
+ exports.decodeBinaryNode = decodeBinaryNode;
@@ -1,3 +1,2 @@
1
- import type { BinaryNode, BinaryNodeCodingOptions } from './types.js';
1
+ import type { BinaryNode, BinaryNodeCodingOptions } from './types';
2
2
  export declare const encodeBinaryNode: (node: BinaryNode, opts?: Pick<BinaryNodeCodingOptions, "TAGS" | "TOKEN_MAP">, buffer?: number[]) => Buffer;
3
- //# sourceMappingURL=encode.d.ts.map
@@ -1,9 +1,46 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.encodeBinaryNode = void 0;
37
+ const constants = __importStar(require("./constants"));
38
+ const jid_utils_1 = require("./jid-utils");
39
+ const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
4
40
  const encoded = encodeBinaryNodeInner(node, opts, buffer);
5
41
  return Buffer.from(encoded);
6
42
  };
43
+ exports.encodeBinaryNode = encodeBinaryNode;
7
44
  const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
8
45
  const { TAGS, TOKEN_MAP } = opts;
9
46
  const pushByte = (value) => buffer.push(value & 0xff);
@@ -158,7 +195,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
158
195
  writePackedBytes(str, 'hex');
159
196
  }
160
197
  else if (str) {
161
- const decodedJid = jidDecode(str);
198
+ const decodedJid = (0, jid_utils_1.jidDecode)(str);
162
199
  if (decodedJid) {
163
200
  writeJid(decodedJid);
164
201
  }
@@ -213,4 +250,3 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
213
250
  }
214
251
  return buffer;
215
252
  };
216
- //# sourceMappingURL=encode.js.map
@@ -1,5 +1,5 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import { type BinaryNode } from './types.js';
1
+ import { proto } from '../../WAProto';
2
+ import { BinaryNode } from './types';
3
3
  export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
4
4
  export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
5
5
  export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
@@ -11,5 +11,4 @@ export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: strin
11
11
  [_: string]: string;
12
12
  };
13
13
  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
14
+ export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any;
@@ -1,32 +1,41 @@
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.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
4
+ exports.binaryNodeToString = binaryNodeToString;
5
+ const boom_1 = require("@hapi/boom");
6
+ const WAProto_1 = require("../../WAProto");
4
7
  // some extra useful utilities
5
- export const getBinaryNodeChildren = (node, childTag) => {
6
- if (Array.isArray(node?.content)) {
8
+ const getBinaryNodeChildren = (node, childTag) => {
9
+ if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
7
10
  return node.content.filter(item => item.tag === childTag);
8
11
  }
9
12
  return [];
10
13
  };
11
- export const getAllBinaryNodeChildren = ({ content }) => {
14
+ exports.getBinaryNodeChildren = getBinaryNodeChildren;
15
+ const getAllBinaryNodeChildren = ({ content }) => {
12
16
  if (Array.isArray(content)) {
13
17
  return content;
14
18
  }
15
19
  return [];
16
20
  };
17
- export const getBinaryNodeChild = (node, childTag) => {
18
- if (Array.isArray(node?.content)) {
19
- return node?.content.find(item => item.tag === childTag);
21
+ exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
22
+ const getBinaryNodeChild = (node, childTag) => {
23
+ if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
24
+ return node === null || node === void 0 ? void 0 : node.content.find(item => item.tag === childTag);
20
25
  }
21
26
  };
22
- export const getBinaryNodeChildBuffer = (node, childTag) => {
23
- const child = getBinaryNodeChild(node, childTag)?.content;
27
+ exports.getBinaryNodeChild = getBinaryNodeChild;
28
+ const getBinaryNodeChildBuffer = (node, childTag) => {
29
+ var _a;
30
+ const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
24
31
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
25
32
  return child;
26
33
  }
27
34
  };
28
- export const getBinaryNodeChildString = (node, childTag) => {
29
- const child = getBinaryNodeChild(node, childTag)?.content;
35
+ exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
36
+ const getBinaryNodeChildString = (node, childTag) => {
37
+ var _a;
38
+ const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
30
39
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
31
40
  return Buffer.from(child).toString('utf-8');
32
41
  }
@@ -34,42 +43,42 @@ export const getBinaryNodeChildString = (node, childTag) => {
34
43
  return child;
35
44
  }
36
45
  };
37
- export const getBinaryNodeChildUInt = (node, childTag, length) => {
38
- const buff = getBinaryNodeChildBuffer(node, childTag);
46
+ exports.getBinaryNodeChildString = getBinaryNodeChildString;
47
+ const getBinaryNodeChildUInt = (node, childTag, length) => {
48
+ const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag);
39
49
  if (buff) {
40
50
  return bufferToUInt(buff, length);
41
51
  }
42
52
  };
43
- export const assertNodeErrorFree = (node) => {
44
- const errNode = getBinaryNodeChild(node, 'error');
53
+ exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
54
+ const assertNodeErrorFree = (node) => {
55
+ const errNode = (0, exports.getBinaryNodeChild)(node, 'error');
45
56
  if (errNode) {
46
- throw new Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
57
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
47
58
  }
48
59
  };
49
- export const reduceBinaryNodeToDictionary = (node, tag) => {
50
- const nodes = getBinaryNodeChildren(node, tag);
60
+ exports.assertNodeErrorFree = assertNodeErrorFree;
61
+ const reduceBinaryNodeToDictionary = (node, tag) => {
62
+ const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
51
63
  const dict = nodes.reduce((dict, { attrs }) => {
52
- if (typeof attrs.name === 'string') {
53
- dict[attrs.name] = attrs.value || attrs.config_value;
54
- }
55
- else {
56
- dict[attrs.config_code] = attrs.value || attrs.config_value;
57
- }
64
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value;
58
65
  return dict;
59
66
  }, {});
60
67
  return dict;
61
68
  };
62
- export const getBinaryNodeMessages = ({ content }) => {
69
+ exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
70
+ const getBinaryNodeMessages = ({ content }) => {
63
71
  const msgs = [];
64
72
  if (Array.isArray(content)) {
65
73
  for (const item of content) {
66
74
  if (item.tag === 'message') {
67
- msgs.push(proto.WebMessageInfo.decode(item.content));
75
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content));
68
76
  }
69
77
  }
70
78
  }
71
79
  return msgs;
72
80
  };
81
+ exports.getBinaryNodeMessages = getBinaryNodeMessages;
73
82
  function bufferToUInt(e, t) {
74
83
  let a = 0;
75
84
  for (let i = 0; i < t; i++) {
@@ -78,7 +87,7 @@ function bufferToUInt(e, t) {
78
87
  return a;
79
88
  }
80
89
  const tabs = (n) => '\t'.repeat(n);
81
- export function binaryNodeToString(node, i = 0) {
90
+ function binaryNodeToString(node, i = 0) {
82
91
  if (!node) {
83
92
  return node;
84
93
  }
@@ -99,4 +108,3 @@ export function binaryNodeToString(node, i = 0) {
99
108
  const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
100
109
  return tag + content;
101
110
  }
102
- //# sourceMappingURL=generic-utils.js.map
@@ -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);
@@ -33,4 +33,3 @@ export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broad
33
33
  export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
34
34
  export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
35
35
  export declare const jidNormalizedUser: (jid: string | undefined) => string;
36
- //# sourceMappingURL=jid-utils.d.ts.map
@@ -1,13 +1,17 @@
1
- export const S_WHATSAPP_NET = '@s.whatsapp.net';
2
- export const OFFICIAL_BIZ_JID = '16505361212@c.us';
3
- export const SERVER_JID = 'server@c.us';
4
- export const PSA_WID = '0@c.us';
5
- export const STORIES_JID = 'status@broadcast';
6
- export const META_AI_JID = '13135550002@c.us';
7
- export const jidEncode = (user, server, device, agent) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jidNormalizedUser = exports.isJidBot = exports.isJidNewsletter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.isJidMetaIa = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.META_AI_JID = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
4
+ exports.S_WHATSAPP_NET = '@s.whatsapp.net';
5
+ exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
6
+ exports.SERVER_JID = 'server@c.us';
7
+ exports.PSA_WID = '0@c.us';
8
+ exports.STORIES_JID = 'status@broadcast';
9
+ exports.META_AI_JID = '13135550002@c.us';
10
+ const jidEncode = (user, server, device, agent) => {
8
11
  return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
9
12
  };
10
- export const jidDecode = (jid) => {
13
+ exports.jidEncode = jidEncode;
14
+ const jidDecode = (jid) => {
11
15
  const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
12
16
  if (sepIdx < 0) {
13
17
  return undefined;
@@ -23,30 +27,40 @@ export const jidDecode = (jid) => {
23
27
  device: device ? +device : undefined
24
28
  };
25
29
  };
30
+ exports.jidDecode = jidDecode;
26
31
  /** is the jid a user */
27
- export const areJidsSameUser = (jid1, jid2) => jidDecode(jid1)?.user === jidDecode(jid2)?.user;
32
+ const areJidsSameUser = (jid1, jid2) => { var _a, _b; return ((_a = (0, exports.jidDecode)(jid1)) === null || _a === void 0 ? void 0 : _a.user) === ((_b = (0, exports.jidDecode)(jid2)) === null || _b === void 0 ? void 0 : _b.user); };
33
+ exports.areJidsSameUser = areJidsSameUser;
28
34
  /** is the jid Meta IA */
29
- export const isJidMetaIa = (jid) => jid?.endsWith('@bot');
35
+ const isJidMetaIa = (jid) => jid === null || jid === void 0 ? void 0 : jid.endsWith('@bot');
36
+ exports.isJidMetaIa = isJidMetaIa;
30
37
  /** is the jid a user */
31
- export const isJidUser = (jid) => jid?.endsWith('@s.whatsapp.net');
38
+ const isJidUser = (jid) => jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net');
39
+ exports.isJidUser = isJidUser;
32
40
  /** is the jid a group */
33
- export const isLidUser = (jid) => jid?.endsWith('@lid');
41
+ const isLidUser = (jid) => jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid');
42
+ exports.isLidUser = isLidUser;
34
43
  /** is the jid a broadcast */
35
- export const isJidBroadcast = (jid) => jid?.endsWith('@broadcast');
44
+ const isJidBroadcast = (jid) => jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast');
45
+ exports.isJidBroadcast = isJidBroadcast;
36
46
  /** is the jid a group */
37
- export const isJidGroup = (jid) => jid?.endsWith('@g.us');
47
+ const isJidGroup = (jid) => jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us');
48
+ exports.isJidGroup = isJidGroup;
38
49
  /** is the jid the status broadcast */
39
- export const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
50
+ const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
51
+ exports.isJidStatusBroadcast = isJidStatusBroadcast;
40
52
  /** is the jid a newsletter */
41
- export const isJidNewsletter = (jid) => jid?.endsWith('@newsletter');
53
+ const isJidNewsletter = (jid) => jid === null || jid === void 0 ? void 0 : jid.endsWith('@newsletter');
54
+ exports.isJidNewsletter = isJidNewsletter;
42
55
  const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
43
- export const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
44
- export const jidNormalizedUser = (jid) => {
45
- const result = jidDecode(jid);
56
+ const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
57
+ exports.isJidBot = isJidBot;
58
+ const jidNormalizedUser = (jid) => {
59
+ const result = (0, exports.jidDecode)(jid);
46
60
  if (!result) {
47
61
  return '';
48
62
  }
49
63
  const { user, server } = result;
50
- return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server);
64
+ return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
51
65
  };
52
- //# sourceMappingURL=jid-utils.js.map
66
+ exports.jidNormalizedUser = jidNormalizedUser;
@@ -1,4 +1,4 @@
1
- import * as constants from './constants.js';
1
+ import * as constants from './constants';
2
2
  /**
3
3
  * the binary node WA uses internally for communication
4
4
  *
@@ -16,4 +16,3 @@ export type BinaryNode = {
16
16
  export type BinaryNodeAttributes = BinaryNode['attrs'];
17
17
  export type BinaryNodeData = BinaryNode['content'];
18
18
  export type BinaryNodeCodingOptions = typeof constants;
19
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +1,2 @@
1
- import * as constants from './constants.js';
2
- //# sourceMappingURL=types.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import type { EventInputType } from './constants.js';
1
+ import { EventInputType } from './constants';
2
2
  export declare class BinaryInfo {
3
3
  protocolVersion: number;
4
4
  sequence: number;
@@ -6,4 +6,3 @@ export declare class BinaryInfo {
6
6
  buffer: Buffer[];
7
7
  constructor(options?: Partial<BinaryInfo>);
8
8
  }
9
- //# sourceMappingURL=BinaryInfo.d.ts.map
@@ -1,4 +1,7 @@
1
- export class BinaryInfo {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinaryInfo = void 0;
4
+ class BinaryInfo {
2
5
  constructor(options = {}) {
3
6
  this.protocolVersion = 5;
4
7
  this.sequence = 0;
@@ -7,4 +10,4 @@ export class BinaryInfo {
7
10
  Object.assign(this, options);
8
11
  }
9
12
  }
10
- //# sourceMappingURL=BinaryInfo.js.map
13
+ exports.BinaryInfo = BinaryInfo;
@@ -37,4 +37,3 @@ export type EventInputType = {
37
37
  } & {};
38
38
  export type Value = number | null | string;
39
39
  export {};
40
- //# sourceMappingURL=constants.d.ts.map
@@ -1,4 +1,7 @@
1
- export const WEB_EVENTS = [
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FLAG_EXTENDED = exports.FLAG_FIELD = exports.FLAG_EVENT = exports.FLAG_GLOBAL = exports.FLAG_BYTE = exports.WEB_GLOBALS = exports.WEB_EVENTS = void 0;
4
+ exports.WEB_EVENTS = [
2
5
  {
3
6
  name: 'WebcFingerprint',
4
7
  id: 1704,
@@ -14790,7 +14793,7 @@ export const WEB_EVENTS = [
14790
14793
  privateStatsIdInt: -1
14791
14794
  }
14792
14795
  ];
14793
- export const WEB_GLOBALS = [
14796
+ exports.WEB_GLOBALS = [
14794
14797
  {
14795
14798
  name: 'abKey2',
14796
14799
  id: 4473,
@@ -15237,5 +15240,4 @@ export const WEB_GLOBALS = [
15237
15240
  channels: ['regular', 'private']
15238
15241
  }
15239
15242
  ];
15240
- export const FLAG_BYTE = 8, FLAG_GLOBAL = 0, FLAG_EVENT = 1, FLAG_FIELD = 2, FLAG_EXTENDED = 4;
15241
- //# sourceMappingURL=constants.js.map
15243
+ exports.FLAG_BYTE = 8, exports.FLAG_GLOBAL = 0, exports.FLAG_EVENT = 1, exports.FLAG_FIELD = 2, exports.FLAG_EXTENDED = 4;
@@ -1,3 +1,2 @@
1
- import { BinaryInfo } from './BinaryInfo.js';
1
+ import { BinaryInfo } from './BinaryInfo';
2
2
  export declare const encodeWAM: (binaryInfo: BinaryInfo) => Buffer<ArrayBuffer>;
3
- //# sourceMappingURL=encode.d.ts.map
package/lib/WAM/encode.js CHANGED
@@ -1,7 +1,9 @@
1
- import { BinaryInfo } from './BinaryInfo.js';
2
- import { FLAG_BYTE, FLAG_EVENT, FLAG_EXTENDED, FLAG_FIELD, FLAG_GLOBAL, WEB_EVENTS, WEB_GLOBALS } from './constants.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeWAM = void 0;
4
+ const constants_1 = require("./constants");
3
5
  const getHeaderBitLength = (key) => (key < 256 ? 2 : 3);
4
- export const encodeWAM = (binaryInfo) => {
6
+ const encodeWAM = (binaryInfo) => {
5
7
  binaryInfo.buffer = [];
6
8
  encodeWAMHeader(binaryInfo);
7
9
  encodeEvents(binaryInfo);
@@ -15,6 +17,7 @@ export const encodeWAM = (binaryInfo) => {
15
17
  }
16
18
  return buffer;
17
19
  };
20
+ exports.encodeWAM = encodeWAM;
18
21
  function encodeWAMHeader(binaryInfo) {
19
22
  const headerBuffer = Buffer.alloc(8); // starting buffer
20
23
  headerBuffer.write('WAM', 0, 'utf8');
@@ -26,34 +29,34 @@ function encodeWAMHeader(binaryInfo) {
26
29
  }
27
30
  function encodeGlobalAttributes(binaryInfo, globals) {
28
31
  for (const [key, _value] of Object.entries(globals)) {
29
- const id = WEB_GLOBALS.find(a => a?.name === key).id;
32
+ const id = constants_1.WEB_GLOBALS.find(a => (a === null || a === void 0 ? void 0 : a.name) === key).id;
30
33
  let value = _value;
31
34
  if (typeof value === 'boolean') {
32
35
  value = value ? 1 : 0;
33
36
  }
34
- binaryInfo.buffer.push(serializeData(id, value, FLAG_GLOBAL));
37
+ binaryInfo.buffer.push(serializeData(id, value, constants_1.FLAG_GLOBAL));
35
38
  }
36
39
  }
37
40
  function encodeEvents(binaryInfo) {
38
41
  for (const [name, { props, globals }] of binaryInfo.events.map(a => Object.entries(a)[0])) {
39
42
  encodeGlobalAttributes(binaryInfo, globals);
40
- const event = WEB_EVENTS.find(a => a.name === name);
43
+ const event = constants_1.WEB_EVENTS.find(a => a.name === name);
41
44
  const props_ = Object.entries(props);
42
45
  let extended = false;
43
46
  for (const [, value] of props_) {
44
47
  extended || (extended = value !== null);
45
48
  }
46
- const eventFlag = extended ? FLAG_EVENT : FLAG_EVENT | FLAG_EXTENDED;
49
+ const eventFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_EVENT | constants_1.FLAG_EXTENDED;
47
50
  binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
48
51
  for (let i = 0; i < props_.length; i++) {
49
52
  const [key, _value] = props_[i];
50
- const id = event.props[key]?.[0];
53
+ const id = event.props[key][0];
51
54
  extended = i < props_.length - 1;
52
55
  let value = _value;
53
56
  if (typeof value === 'boolean') {
54
57
  value = value ? 1 : 0;
55
58
  }
56
- const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED;
59
+ const fieldFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_FIELD | constants_1.FLAG_EXTENDED;
57
60
  binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
58
61
  }
59
62
  }
@@ -63,7 +66,7 @@ function serializeData(key, value, flag) {
63
66
  let buffer;
64
67
  let offset = 0;
65
68
  if (value === null) {
66
- if (flag === FLAG_GLOBAL) {
69
+ if (flag === constants_1.FLAG_GLOBAL) {
67
70
  buffer = Buffer.alloc(bufferLength);
68
71
  offset = serializeHeader(buffer, offset, key, flag);
69
72
  return buffer;
@@ -141,11 +144,10 @@ function serializeHeader(buffer, offset, key, flag) {
141
144
  offset += 1;
142
145
  }
143
146
  else {
144
- buffer.writeUInt8(flag | FLAG_BYTE, offset);
147
+ buffer.writeUInt8(flag | constants_1.FLAG_BYTE, offset);
145
148
  offset += 1;
146
149
  buffer.writeUInt16LE(key, offset);
147
150
  offset += 2;
148
151
  }
149
152
  return offset;
150
153
  }
151
- //# sourceMappingURL=encode.js.map
@@ -1,4 +1,3 @@
1
- export * from './constants.js';
2
- export * from './encode.js';
3
- export * from './BinaryInfo.js';
4
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './constants';
2
+ export * from './encode';
3
+ export * from './BinaryInfo';
package/lib/WAM/index.js CHANGED
@@ -1,4 +1,19 @@
1
- export * from './constants.js';
2
- export * from './encode.js';
3
- export * from './BinaryInfo.js';
4
- //# 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("./constants"), exports);
18
+ __exportStar(require("./encode"), exports);
19
+ __exportStar(require("./BinaryInfo"), exports);