@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,35 +1,34 @@
1
- import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
2
- import { assertNodeErrorFree, getBinaryNodeChild, getBinaryNodeChildBuffer, getBinaryNodeChildren, getBinaryNodeChildUInt, jidDecode, S_WHATSAPP_NET } from '../WABinary/index.js';
3
- import { Curve, generateSignalPubKey } from './crypto.js';
4
- import { encodeBigEndian } from './generics.js';
5
- function chunk(array, size) {
6
- const chunks = [];
7
- for (let i = 0; i < array.length; i += size) {
8
- chunks.push(array.slice(i, i + size));
9
- }
10
- return chunks;
11
- }
12
- export const createSignalIdentity = (wid, accountSignatureKey) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNextPreKeysNode = exports.getNextPreKeys = exports.extractDeviceJids = exports.parseAndInjectE2ESessions = exports.xmppPreKey = exports.xmppSignedPreKey = exports.generateOrGetPreKeys = exports.getPreKeys = exports.createSignalIdentity = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const Defaults_1 = require("../Defaults");
6
+ const WABinary_1 = require("../WABinary");
7
+ const crypto_1 = require("./crypto");
8
+ const generics_1 = require("./generics");
9
+ const createSignalIdentity = (wid, accountSignatureKey) => {
13
10
  return {
14
11
  identifier: { name: wid, deviceId: 0 },
15
- identifierKey: generateSignalPubKey(accountSignatureKey)
12
+ identifierKey: (0, crypto_1.generateSignalPubKey)(accountSignatureKey)
16
13
  };
17
14
  };
18
- export const getPreKeys = async ({ get }, min, limit) => {
15
+ exports.createSignalIdentity = createSignalIdentity;
16
+ const getPreKeys = async ({ get }, min, limit) => {
19
17
  const idList = [];
20
18
  for (let id = min; id < limit; id++) {
21
19
  idList.push(id.toString());
22
20
  }
23
21
  return get('pre-key', idList);
24
22
  };
25
- export const generateOrGetPreKeys = (creds, range) => {
23
+ exports.getPreKeys = getPreKeys;
24
+ const generateOrGetPreKeys = (creds, range) => {
26
25
  const avaliable = creds.nextPreKeyId - creds.firstUnuploadedPreKeyId;
27
26
  const remaining = range - avaliable;
28
27
  const lastPreKeyId = creds.nextPreKeyId + remaining - 1;
29
28
  const newPreKeys = {};
30
29
  if (remaining > 0) {
31
30
  for (let i = creds.nextPreKeyId; i <= lastPreKeyId; i++) {
32
- newPreKeys[i] = Curve.generateKeyPair();
31
+ newPreKeys[i] = crypto_1.Curve.generateKeyPair();
33
32
  }
34
33
  }
35
34
  return {
@@ -38,34 +37,37 @@ export const generateOrGetPreKeys = (creds, range) => {
38
37
  preKeysRange: [creds.firstUnuploadedPreKeyId, range]
39
38
  };
40
39
  };
41
- export const xmppSignedPreKey = (key) => ({
40
+ exports.generateOrGetPreKeys = generateOrGetPreKeys;
41
+ const xmppSignedPreKey = (key) => ({
42
42
  tag: 'skey',
43
43
  attrs: {},
44
44
  content: [
45
- { tag: 'id', attrs: {}, content: encodeBigEndian(key.keyId, 3) },
45
+ { tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(key.keyId, 3) },
46
46
  { tag: 'value', attrs: {}, content: key.keyPair.public },
47
47
  { tag: 'signature', attrs: {}, content: key.signature }
48
48
  ]
49
49
  });
50
- export const xmppPreKey = (pair, id) => ({
50
+ exports.xmppSignedPreKey = xmppSignedPreKey;
51
+ const xmppPreKey = (pair, id) => ({
51
52
  tag: 'key',
52
53
  attrs: {},
53
54
  content: [
54
- { tag: 'id', attrs: {}, content: encodeBigEndian(id, 3) },
55
+ { tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(id, 3) },
55
56
  { tag: 'value', attrs: {}, content: pair.public }
56
57
  ]
57
58
  });
58
- export const parseAndInjectE2ESessions = async (node, repository) => {
59
+ exports.xmppPreKey = xmppPreKey;
60
+ const parseAndInjectE2ESessions = async (node, repository) => {
59
61
  const extractKey = (key) => key
60
62
  ? {
61
- keyId: getBinaryNodeChildUInt(key, 'id', 3),
62
- publicKey: generateSignalPubKey(getBinaryNodeChildBuffer(key, 'value')),
63
- signature: getBinaryNodeChildBuffer(key, 'signature')
63
+ keyId: (0, WABinary_1.getBinaryNodeChildUInt)(key, 'id', 3),
64
+ publicKey: (0, crypto_1.generateSignalPubKey)((0, WABinary_1.getBinaryNodeChildBuffer)(key, 'value')),
65
+ signature: (0, WABinary_1.getBinaryNodeChildBuffer)(key, 'signature')
64
66
  }
65
67
  : undefined;
66
- const nodes = getBinaryNodeChildren(getBinaryNodeChild(node, 'list'), 'user');
68
+ const nodes = (0, WABinary_1.getBinaryNodeChildren)((0, WABinary_1.getBinaryNodeChild)(node, 'list'), 'user');
67
69
  for (const node of nodes) {
68
- assertNodeErrorFree(node);
70
+ (0, WABinary_1.assertNodeErrorFree)(node);
69
71
  }
70
72
  // Most of the work in repository.injectE2ESession is CPU intensive, not IO
71
73
  // So Promise.all doesn't really help here,
@@ -73,19 +75,19 @@ export const parseAndInjectE2ESessions = async (node, repository) => {
73
75
  // This way we chunk it in smaller parts and between those parts we can yield to the event loop
74
76
  // It's rare case when you need to E2E sessions for so many users, but it's possible
75
77
  const chunkSize = 100;
76
- const chunks = chunk(nodes, chunkSize);
78
+ const chunks = (0, lodash_1.chunk)(nodes, chunkSize);
77
79
  for (const nodesChunk of chunks) {
78
80
  await Promise.all(nodesChunk.map(async (node) => {
79
- const signedKey = getBinaryNodeChild(node, 'skey');
80
- const key = getBinaryNodeChild(node, 'key');
81
- const identity = getBinaryNodeChildBuffer(node, 'identity');
81
+ const signedKey = (0, WABinary_1.getBinaryNodeChild)(node, 'skey');
82
+ const key = (0, WABinary_1.getBinaryNodeChild)(node, 'key');
83
+ const identity = (0, WABinary_1.getBinaryNodeChildBuffer)(node, 'identity');
82
84
  const jid = node.attrs.jid;
83
- const registrationId = getBinaryNodeChildUInt(node, 'registration', 4);
85
+ const registrationId = (0, WABinary_1.getBinaryNodeChildUInt)(node, 'registration', 4);
84
86
  await repository.injectE2ESession({
85
87
  jid,
86
88
  session: {
87
89
  registrationId: registrationId,
88
- identityKey: generateSignalPubKey(identity),
90
+ identityKey: (0, crypto_1.generateSignalPubKey)(identity),
89
91
  signedPreKey: extractKey(signedKey),
90
92
  preKey: extractKey(key)
91
93
  }
@@ -93,13 +95,14 @@ export const parseAndInjectE2ESessions = async (node, repository) => {
93
95
  }));
94
96
  }
95
97
  };
96
- export const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
97
- const { user: myUser, device: myDevice } = jidDecode(myJid);
98
+ exports.parseAndInjectE2ESessions = parseAndInjectE2ESessions;
99
+ const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
100
+ const { user: myUser, device: myDevice } = (0, WABinary_1.jidDecode)(myJid);
98
101
  const extracted = [];
99
102
  for (const userResult of result) {
100
103
  const { devices, id } = userResult;
101
- const { user } = jidDecode(id);
102
- const deviceList = devices?.deviceList;
104
+ const { user } = (0, WABinary_1.jidDecode)(id);
105
+ const deviceList = devices === null || devices === void 0 ? void 0 : devices.deviceList;
103
106
  if (Array.isArray(deviceList)) {
104
107
  for (const { id: device, keyIndex } of deviceList) {
105
108
  if ((!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
@@ -113,38 +116,40 @@ export const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
113
116
  }
114
117
  return extracted;
115
118
  };
119
+ exports.extractDeviceJids = extractDeviceJids;
116
120
  /**
117
121
  * get the next N keys for upload or processing
118
122
  * @param count number of pre-keys to get or generate
119
123
  */
120
- export const getNextPreKeys = async ({ creds, keys }, count) => {
121
- const { newPreKeys, lastPreKeyId, preKeysRange } = generateOrGetPreKeys(creds, count);
124
+ const getNextPreKeys = async ({ creds, keys }, count) => {
125
+ const { newPreKeys, lastPreKeyId, preKeysRange } = (0, exports.generateOrGetPreKeys)(creds, count);
122
126
  const update = {
123
127
  nextPreKeyId: Math.max(lastPreKeyId + 1, creds.nextPreKeyId),
124
128
  firstUnuploadedPreKeyId: Math.max(creds.firstUnuploadedPreKeyId, lastPreKeyId + 1)
125
129
  };
126
130
  await keys.set({ 'pre-key': newPreKeys });
127
- const preKeys = await getPreKeys(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
131
+ const preKeys = await (0, exports.getPreKeys)(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
128
132
  return { update, preKeys };
129
133
  };
130
- export const getNextPreKeysNode = async (state, count) => {
134
+ exports.getNextPreKeys = getNextPreKeys;
135
+ const getNextPreKeysNode = async (state, count) => {
131
136
  const { creds } = state;
132
- const { update, preKeys } = await getNextPreKeys(state, count);
137
+ const { update, preKeys } = await (0, exports.getNextPreKeys)(state, count);
133
138
  const node = {
134
139
  tag: 'iq',
135
140
  attrs: {
136
141
  xmlns: 'encrypt',
137
142
  type: 'set',
138
- to: S_WHATSAPP_NET
143
+ to: WABinary_1.S_WHATSAPP_NET
139
144
  },
140
145
  content: [
141
- { tag: 'registration', attrs: {}, content: encodeBigEndian(creds.registrationId) },
142
- { tag: 'type', attrs: {}, content: KEY_BUNDLE_TYPE },
146
+ { tag: 'registration', attrs: {}, content: (0, generics_1.encodeBigEndian)(creds.registrationId) },
147
+ { tag: 'type', attrs: {}, content: Defaults_1.KEY_BUNDLE_TYPE },
143
148
  { tag: 'identity', attrs: {}, content: creds.signedIdentityKey.public },
144
- { tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => xmppPreKey(preKeys[+k], +k)) },
145
- xmppSignedPreKey(creds.signedPreKey)
149
+ { tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => (0, exports.xmppPreKey)(preKeys[+k], +k)) },
150
+ (0, exports.xmppSignedPreKey)(creds.signedPreKey)
146
151
  ]
147
152
  };
148
153
  return { update, node };
149
154
  };
150
- //# sourceMappingURL=signal.js.map
155
+ exports.getNextPreKeysNode = getNextPreKeysNode;
@@ -1,4 +1,4 @@
1
- import type { AuthenticationState } from '../Types/index.js';
1
+ import { AuthenticationState } from '../Types';
2
2
  /**
3
3
  * stores the full authentication state in a single folder.
4
4
  * Far more efficient than singlefileauthstate
@@ -10,4 +10,3 @@ export declare const useMultiFileAuthState: (folder: string) => Promise<{
10
10
  state: AuthenticationState;
11
11
  saveCreds: () => Promise<void>;
12
12
  }>;
13
- //# sourceMappingURL=use-multi-file-auth-state.d.ts.map
@@ -1,9 +1,12 @@
1
- import { Mutex } from 'async-mutex';
2
- import { mkdir, readFile, stat, unlink, writeFile } from 'fs/promises';
3
- import { join } from 'path';
4
- import { proto } from '../../WAProto/index.js';
5
- import { initAuthCreds } from './auth-utils.js';
6
- import { BufferJSON } from './generics.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMultiFileAuthState = void 0;
4
+ const async_mutex_1 = require("async-mutex");
5
+ const promises_1 = require("fs/promises");
6
+ const path_1 = require("path");
7
+ const WAProto_1 = require("../../WAProto");
8
+ const auth_utils_1 = require("./auth-utils");
9
+ const generics_1 = require("./generics");
7
10
  // We need to lock files due to the fact that we are using async functions to read and write files
8
11
  // https://github.com/WhiskeySockets/Baileys/issues/794
9
12
  // https://github.com/nodejs/node/issues/26338
@@ -13,7 +16,7 @@ const fileLocks = new Map();
13
16
  const getFileLock = (path) => {
14
17
  let mutex = fileLocks.get(path);
15
18
  if (!mutex) {
16
- mutex = new Mutex();
19
+ mutex = new async_mutex_1.Mutex();
17
20
  fileLocks.set(path, mutex);
18
21
  }
19
22
  return mutex;
@@ -25,14 +28,14 @@ const getFileLock = (path) => {
25
28
  * Again, I wouldn't endorse this for any production level use other than perhaps a bot.
26
29
  * Would recommend writing an auth state for use with a proper SQL or No-SQL DB
27
30
  * */
28
- export const useMultiFileAuthState = async (folder) => {
31
+ const useMultiFileAuthState = async (folder) => {
29
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
33
  const writeData = async (data, file) => {
31
- const filePath = join(folder, fixFileName(file));
34
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
32
35
  const mutex = getFileLock(filePath);
33
36
  return mutex.acquire().then(async (release) => {
34
37
  try {
35
- await writeFile(filePath, JSON.stringify(data, BufferJSON.replacer));
38
+ await (0, promises_1.writeFile)(filePath, JSON.stringify(data, generics_1.BufferJSON.replacer));
36
39
  }
37
40
  finally {
38
41
  release();
@@ -41,12 +44,12 @@ export const useMultiFileAuthState = async (folder) => {
41
44
  };
42
45
  const readData = async (file) => {
43
46
  try {
44
- const filePath = join(folder, fixFileName(file));
47
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
45
48
  const mutex = getFileLock(filePath);
46
49
  return await mutex.acquire().then(async (release) => {
47
50
  try {
48
- const data = await readFile(filePath, { encoding: 'utf-8' });
49
- return JSON.parse(data, BufferJSON.reviver);
51
+ const data = await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' });
52
+ return JSON.parse(data, generics_1.BufferJSON.reviver);
50
53
  }
51
54
  finally {
52
55
  release();
@@ -59,32 +62,32 @@ export const useMultiFileAuthState = async (folder) => {
59
62
  };
60
63
  const removeData = async (file) => {
61
64
  try {
62
- const filePath = join(folder, fixFileName(file));
65
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
63
66
  const mutex = getFileLock(filePath);
64
67
  return mutex.acquire().then(async (release) => {
65
68
  try {
66
- await unlink(filePath);
69
+ await (0, promises_1.unlink)(filePath);
67
70
  }
68
- catch {
71
+ catch (_a) {
69
72
  }
70
73
  finally {
71
74
  release();
72
75
  }
73
76
  });
74
77
  }
75
- catch { }
78
+ catch (_a) { }
76
79
  };
77
- const folderInfo = await stat(folder).catch(() => { });
80
+ const folderInfo = await (0, promises_1.stat)(folder).catch(() => { });
78
81
  if (folderInfo) {
79
82
  if (!folderInfo.isDirectory()) {
80
83
  throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
81
84
  }
82
85
  }
83
86
  else {
84
- await mkdir(folder, { recursive: true });
87
+ await (0, promises_1.mkdir)(folder, { recursive: true });
85
88
  }
86
- const fixFileName = (file) => file?.replace(/\//g, '__')?.replace(/:/g, '-');
87
- const creds = (await readData('creds.json')) || initAuthCreds();
89
+ const fixFileName = (file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.replace(/\//g, '__')) === null || _a === void 0 ? void 0 : _a.replace(/:/g, '-'); };
90
+ const creds = (await readData('creds.json')) || (0, auth_utils_1.initAuthCreds)();
88
91
  return {
89
92
  state: {
90
93
  creds,
@@ -94,7 +97,7 @@ export const useMultiFileAuthState = async (folder) => {
94
97
  await Promise.all(ids.map(async (id) => {
95
98
  let value = await readData(`${type}-${id}.json`);
96
99
  if (type === 'app-state-sync-key' && value) {
97
- value = proto.Message.AppStateSyncKeyData.fromObject(value);
100
+ value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
98
101
  }
99
102
  data[id] = value;
100
103
  }));
@@ -118,4 +121,4 @@ export const useMultiFileAuthState = async (folder) => {
118
121
  }
119
122
  };
120
123
  };
121
- //# sourceMappingURL=use-multi-file-auth-state.js.map
124
+ exports.useMultiFileAuthState = useMultiFileAuthState;
@@ -1,6 +1,6 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types/index.js';
3
- import { type BinaryNode } from '../WABinary/index.js';
1
+ import { proto } from '../../WAProto';
2
+ import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
3
+ import { BinaryNode } from '../WABinary';
4
4
  export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
5
5
  export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
6
6
  export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, "advSecretKey" | "signedIdentityKey" | "signalIdentities">) => {
@@ -8,4 +8,3 @@ export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecre
8
8
  reply: BinaryNode;
9
9
  };
10
10
  export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array<ArrayBufferLike>;
11
- //# sourceMappingURL=validate-connection.d.ts.map
@@ -1,11 +1,14 @@
1
- import { Boom } from '@hapi/boom';
2
- import { createHash } from 'crypto';
3
- import { proto } from '../../WAProto/index.js';
4
- import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
5
- import { getBinaryNodeChild, jidDecode, S_WHATSAPP_NET } from '../WABinary/index.js';
6
- import { Curve, hmacSign } from './crypto.js';
7
- import { encodeBigEndian } from './generics.js';
8
- import { createSignalIdentity } from './signal.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = void 0;
4
+ const boom_1 = require("@hapi/boom");
5
+ const crypto_1 = require("crypto");
6
+ const WAProto_1 = require("../../WAProto");
7
+ const Defaults_1 = require("../Defaults");
8
+ const WABinary_1 = require("../WABinary");
9
+ const crypto_2 = require("./crypto");
10
+ const generics_1 = require("./generics");
11
+ const signal_1 = require("./signal");
9
12
  const getUserAgent = (config) => {
10
13
  return {
11
14
  appVersion: {
@@ -13,8 +16,8 @@ const getUserAgent = (config) => {
13
16
  secondary: config.version[1],
14
17
  tertiary: config.version[2]
15
18
  },
16
- platform: proto.ClientPayload.UserAgent.Platform.WEB,
17
- releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
19
+ platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
20
+ releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
18
21
  osVersion: '0.1',
19
22
  device: 'Desktop',
20
23
  osBuildNumber: '0.1',
@@ -25,11 +28,11 @@ const getUserAgent = (config) => {
25
28
  };
26
29
  };
27
30
  const PLATFORM_MAP = {
28
- 'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
29
- Windows: proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
31
+ 'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
32
+ Windows: WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
30
33
  };
31
34
  const getWebInfo = (config) => {
32
- let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
35
+ let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
33
36
  if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
34
37
  webSubPlatform = PLATFORM_MAP[config.browser[0]];
35
38
  }
@@ -37,15 +40,15 @@ const getWebInfo = (config) => {
37
40
  };
38
41
  const getClientPayload = (config) => {
39
42
  const payload = {
40
- connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
41
- connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
43
+ connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
44
+ connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
42
45
  userAgent: getUserAgent(config)
43
46
  };
44
47
  payload.webInfo = getWebInfo(config);
45
48
  return payload;
46
49
  };
47
- export const generateLoginNode = (userJid, config) => {
48
- const { user, device } = jidDecode(userJid);
50
+ const generateLoginNode = (userJid, config) => {
51
+ const { user, device } = (0, WABinary_1.jidDecode)(userJid);
49
52
  const payload = {
50
53
  ...getClientPayload(config),
51
54
  passive: false,
@@ -53,17 +56,17 @@ export const generateLoginNode = (userJid, config) => {
53
56
  username: +user,
54
57
  device: device
55
58
  };
56
- return proto.ClientPayload.fromObject(payload);
59
+ return WAProto_1.proto.ClientPayload.fromObject(payload);
57
60
  };
61
+ exports.generateLoginNode = generateLoginNode;
58
62
  const getPlatformType = (platform) => {
59
63
  const platformType = platform.toUpperCase();
60
- return (proto.DeviceProps.PlatformType[platformType] ||
61
- proto.DeviceProps.PlatformType.DESKTOP);
64
+ return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.DESKTOP;
62
65
  };
63
- export const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
66
+ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
64
67
  // the app version needs to be md5 hashed
65
68
  // and passed in
66
- const appVersionBuf = createHash('md5')
69
+ const appVersionBuf = (0, crypto_1.createHash)('md5')
67
70
  .update(config.version.join('.')) // join as string
68
71
  .digest();
69
72
  const companion = {
@@ -71,7 +74,7 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
71
74
  platformType: getPlatformType(config.browser[1]),
72
75
  requireFullSync: config.syncFullHistory
73
76
  };
74
- const companionProto = proto.DeviceProps.encode(companion).finish();
77
+ const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
75
78
  const registerPayload = {
76
79
  ...getClientPayload(config),
77
80
  passive: false,
@@ -79,51 +82,52 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
79
82
  devicePairingData: {
80
83
  buildHash: appVersionBuf,
81
84
  deviceProps: companionProto,
82
- eRegid: encodeBigEndian(registrationId),
83
- eKeytype: KEY_BUNDLE_TYPE,
85
+ eRegid: (0, generics_1.encodeBigEndian)(registrationId),
86
+ eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
84
87
  eIdent: signedIdentityKey.public,
85
- eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
88
+ eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
86
89
  eSkeyVal: signedPreKey.keyPair.public,
87
90
  eSkeySig: signedPreKey.signature
88
91
  }
89
92
  };
90
- return proto.ClientPayload.fromObject(registerPayload);
93
+ return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
91
94
  };
92
- export const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
95
+ exports.generateRegistrationNode = generateRegistrationNode;
96
+ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
93
97
  const msgId = stanza.attrs.id;
94
- const pairSuccessNode = getBinaryNodeChild(stanza, 'pair-success');
95
- const deviceIdentityNode = getBinaryNodeChild(pairSuccessNode, 'device-identity');
96
- const platformNode = getBinaryNodeChild(pairSuccessNode, 'platform');
97
- const deviceNode = getBinaryNodeChild(pairSuccessNode, 'device');
98
- const businessNode = getBinaryNodeChild(pairSuccessNode, 'biz');
98
+ const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
99
+ const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
100
+ const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
101
+ const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
102
+ const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
99
103
  if (!deviceIdentityNode || !deviceNode) {
100
- throw new Boom('Missing device-identity or device in pair success node', { data: stanza });
104
+ throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
101
105
  }
102
- const bizName = businessNode?.attrs.name;
106
+ const bizName = businessNode === null || businessNode === void 0 ? void 0 : businessNode.attrs.name;
103
107
  const jid = deviceNode.attrs.jid;
104
- const { details, hmac, accountType } = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
105
- const isHostedAccount = accountType !== undefined && accountType === proto.ADVEncryptionType.HOSTED;
108
+ const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
109
+ const isHostedAccount = accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED;
106
110
  const hmacPrefix = isHostedAccount ? Buffer.from([6, 5]) : Buffer.alloc(0);
107
- const advSign = hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
111
+ const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
108
112
  if (Buffer.compare(hmac, advSign) !== 0) {
109
- throw new Boom('Invalid account signature');
113
+ throw new boom_1.Boom('Invalid account signature');
110
114
  }
111
- const account = proto.ADVSignedDeviceIdentity.decode(details);
115
+ const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
112
116
  const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
113
117
  const accountMsg = Buffer.concat([Buffer.from([6, 0]), deviceDetails, signedIdentityKey.public]);
114
- if (!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
115
- throw new Boom('Failed to verify account signature');
118
+ if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
119
+ throw new boom_1.Boom('Failed to verify account signature');
116
120
  }
117
121
  const devicePrefix = isHostedAccount ? Buffer.from([6, 6]) : Buffer.from([6, 1]);
118
122
  const deviceMsg = Buffer.concat([devicePrefix, deviceDetails, signedIdentityKey.public, accountSignatureKey]);
119
- account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg);
120
- const identity = createSignalIdentity(jid, accountSignatureKey);
121
- const accountEnc = encodeSignedDeviceIdentity(account, false);
122
- const deviceIdentity = proto.ADVDeviceIdentity.decode(account.details);
123
+ account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
124
+ const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
125
+ const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
126
+ const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(account.details);
123
127
  const reply = {
124
128
  tag: 'iq',
125
129
  attrs: {
126
- to: S_WHATSAPP_NET,
130
+ to: WABinary_1.S_WHATSAPP_NET,
127
131
  type: 'result',
128
132
  id: msgId
129
133
  },
@@ -145,20 +149,22 @@ export const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentit
145
149
  account,
146
150
  me: { id: jid, name: bizName },
147
151
  signalIdentities: [...(signalIdentities || []), identity],
148
- platform: platformNode?.attrs.name
152
+ platform: platformNode === null || platformNode === void 0 ? void 0 : platformNode.attrs.name
149
153
  };
150
154
  return {
151
155
  creds: authUpdate,
152
156
  reply
153
157
  };
154
158
  };
155
- export const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
159
+ exports.configureSuccessfulPairing = configureSuccessfulPairing;
160
+ const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
161
+ var _a;
156
162
  account = { ...account };
157
163
  // set to null if we are not to include the signature key
158
164
  // or if we are including the signature key but it is empty
159
- if (!includeSignatureKey || !account.accountSignatureKey?.length) {
165
+ if (!includeSignatureKey || !((_a = account.accountSignatureKey) === null || _a === void 0 ? void 0 : _a.length)) {
160
166
  account.accountSignatureKey = null;
161
167
  }
162
- return proto.ADVSignedDeviceIdentity.encode(account).finish();
168
+ return WAProto_1.proto.ADVSignedDeviceIdentity.encode(account).finish();
163
169
  };
164
- //# sourceMappingURL=validate-connection.js.map
170
+ exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
@@ -25,4 +25,3 @@ export declare const TOKEN_MAP: {
25
25
  index: number;
26
26
  };
27
27
  };
28
- //# sourceMappingURL=constants.d.ts.map
@@ -1,4 +1,7 @@
1
- export const TAGS = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOKEN_MAP = exports.SINGLE_BYTE_TOKENS = exports.DOUBLE_BYTE_TOKENS = exports.TAGS = void 0;
4
+ exports.TAGS = {
2
5
  LIST_EMPTY: 0,
3
6
  DICTIONARY_0: 236,
4
7
  DICTIONARY_1: 237,
@@ -17,7 +20,7 @@ export const TAGS = {
17
20
  NIBBLE_8: 255,
18
21
  PACKED_MAX: 127
19
22
  };
20
- export const DOUBLE_BYTE_TOKENS = [
23
+ exports.DOUBLE_BYTE_TOKENS = [
21
24
  [
22
25
  'read-self',
23
26
  'active',
@@ -1051,7 +1054,7 @@ export const DOUBLE_BYTE_TOKENS = [
1051
1054
  '1961'
1052
1055
  ]
1053
1056
  ];
1054
- export const SINGLE_BYTE_TOKENS = [
1057
+ exports.SINGLE_BYTE_TOKENS = [
1055
1058
  '',
1056
1059
  'xmlstreamstart',
1057
1060
  'xmlstreamend',
@@ -1289,13 +1292,12 @@ export const SINGLE_BYTE_TOKENS = [
1289
1292
  '03',
1290
1293
  'screen_height'
1291
1294
  ];
1292
- export const TOKEN_MAP = {};
1293
- for (const [i, SINGLE_BYTE_TOKEN] of SINGLE_BYTE_TOKENS.entries()) {
1294
- TOKEN_MAP[SINGLE_BYTE_TOKEN] = { index: i };
1295
+ exports.TOKEN_MAP = {};
1296
+ for (const [i, SINGLE_BYTE_TOKEN] of exports.SINGLE_BYTE_TOKENS.entries()) {
1297
+ exports.TOKEN_MAP[SINGLE_BYTE_TOKEN] = { index: i };
1295
1298
  }
1296
- for (const [i, DOUBLE_BYTE_TOKEN] of DOUBLE_BYTE_TOKENS.entries()) {
1299
+ for (const [i, DOUBLE_BYTE_TOKEN] of exports.DOUBLE_BYTE_TOKENS.entries()) {
1297
1300
  for (const [j, element] of DOUBLE_BYTE_TOKEN.entries()) {
1298
- TOKEN_MAP[element] = { dict: i, index: j };
1301
+ exports.TOKEN_MAP[element] = { dict: i, index: j };
1299
1302
  }
1300
1303
  }
1301
- //# sourceMappingURL=constants.js.map
@@ -1,7 +1,6 @@
1
- import type { BinaryNode, BinaryNodeCodingOptions } from './types.js';
1
+ import type { BinaryNode, BinaryNodeCodingOptions } from './types';
2
2
  export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer<ArrayBufferLike>>;
3
3
  export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
4
4
  index: number;
5
5
  }) => BinaryNode;
6
6
  export declare const decodeBinaryNode: (buff: Buffer) => Promise<BinaryNode>;
7
- //# sourceMappingURL=decode.d.ts.map