@vanzxysenpai/baileys 0.0.0-stage → 0.0.2

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 (431) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +25 -0
  3. package/NOTICE.md +158 -0
  4. package/README.md +5294 -2
  5. package/VanzxyBanner.js +134 -0
  6. package/WAProto/index.d.ts +13317 -0
  7. package/WAProto/index.js +147553 -0
  8. package/lib/Builders/A2UI.d.ts +131 -0
  9. package/lib/Builders/A2UI.js +343 -0
  10. package/lib/Builders/AIRich.d.ts +1021 -0
  11. package/lib/Builders/AIRich.js +2889 -0
  12. package/lib/Builders/Album.d.ts +51 -0
  13. package/lib/Builders/Album.js +99 -0
  14. package/lib/Builders/Button.d.ts +137449 -0
  15. package/lib/Builders/Button.js +1054 -0
  16. package/lib/Builders/ButtonV2.d.ts +43 -0
  17. package/lib/Builders/ButtonV2.js +175 -0
  18. package/lib/Builders/ButtonV3.d.ts +35 -0
  19. package/lib/Builders/ButtonV3.js +189 -0
  20. package/lib/Builders/Carousel.d.ts +68 -0
  21. package/lib/Builders/Carousel.js +161 -0
  22. package/lib/Builders/Event.d.ts +61 -0
  23. package/lib/Builders/Event.js +118 -0
  24. package/lib/Builders/Expiring.d.ts +17 -0
  25. package/lib/Builders/Expiring.js +27 -0
  26. package/lib/Builders/Poll.d.ts +63 -0
  27. package/lib/Builders/Poll.js +139 -0
  28. package/lib/Builders/VanzxyBaileys.d.ts +42 -0
  29. package/lib/Builders/VanzxyBaileys.js +110 -0
  30. package/lib/Builders/errors.d.ts +25 -0
  31. package/lib/Builders/errors.js +29 -0
  32. package/lib/Builders/index.d.ts +14 -0
  33. package/lib/Builders/index.js +23 -0
  34. package/lib/Builders/shared.d.ts +395 -0
  35. package/lib/Builders/shared.js +738 -0
  36. package/lib/Defaults/bot-jid.d.ts +1 -0
  37. package/lib/Defaults/bot-jid.js +1 -0
  38. package/lib/Defaults/index.d.ts +161 -0
  39. package/lib/Defaults/index.js +165 -0
  40. package/lib/Defaults/version.d.ts +1 -0
  41. package/lib/Defaults/version.js +1 -0
  42. package/lib/Framework/Bot.d.ts +865 -0
  43. package/lib/Framework/Bot.js +230 -0
  44. package/lib/Framework/Context.d.ts +17 -0
  45. package/lib/Framework/Context.js +90 -0
  46. package/lib/Framework/MediaManager.d.ts +15 -0
  47. package/lib/Framework/MediaManager.js +154 -0
  48. package/lib/Framework/SessionManager.d.ts +10 -0
  49. package/lib/Framework/SessionManager.js +34 -0
  50. package/lib/Framework/StatsManager.d.ts +20 -0
  51. package/lib/Framework/StatsManager.js +117 -0
  52. package/lib/Framework/Store/SQLiteStore.d.ts +13 -0
  53. package/lib/Framework/Store/SQLiteStore.js +68 -0
  54. package/lib/Framework/index.d.ts +6 -0
  55. package/lib/Framework/index.js +11 -0
  56. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  57. package/lib/Signal/Group/ciphertext-message.js +11 -0
  58. package/lib/Signal/Group/group-session-builder.d.ts +7 -0
  59. package/lib/Signal/Group/group-session-builder.js +29 -0
  60. package/lib/Signal/Group/group_cipher.d.ts +10 -0
  61. package/lib/Signal/Group/group_cipher.js +81 -0
  62. package/lib/Signal/Group/index.d.ts +11 -0
  63. package/lib/Signal/Group/index.js +11 -0
  64. package/lib/Signal/Group/keyhelper.d.ts +6 -0
  65. package/lib/Signal/Group/keyhelper.js +17 -0
  66. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  67. package/lib/Signal/Group/sender-chain-key.js +25 -0
  68. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  69. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  70. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  71. package/lib/Signal/Group/sender-key-message.js +65 -0
  72. package/lib/Signal/Group/sender-key-name.d.ts +11 -0
  73. package/lib/Signal/Group/sender-key-name.js +47 -0
  74. package/lib/Signal/Group/sender-key-record.d.ts +12 -0
  75. package/lib/Signal/Group/sender-key-record.js +40 -0
  76. package/lib/Signal/Group/sender-key-state.d.ts +16 -0
  77. package/lib/Signal/Group/sender-key-state.js +83 -0
  78. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  79. package/lib/Signal/Group/sender-message-key.js +25 -0
  80. package/lib/Signal/libsignal.d.ts +58 -0
  81. package/lib/Signal/libsignal.js +436 -0
  82. package/lib/Signal/lid-mapping.d.ts +20 -0
  83. package/lib/Signal/lid-mapping.js +276 -0
  84. package/lib/Socket/Client/index.d.ts +2 -0
  85. package/lib/Socket/Client/index.js +2 -0
  86. package/lib/Socket/Client/types.d.ts +5 -0
  87. package/lib/Socket/Client/types.js +10 -0
  88. package/lib/Socket/Client/websocket.d.ts +12 -0
  89. package/lib/Socket/Client/websocket.js +53 -0
  90. package/lib/Socket/business.d.ts +674 -0
  91. package/lib/Socket/business.js +379 -0
  92. package/lib/Socket/chats.d.ts +137 -0
  93. package/lib/Socket/chats.js +1299 -0
  94. package/lib/Socket/communities.d.ts +805 -0
  95. package/lib/Socket/communities.js +454 -0
  96. package/lib/Socket/dugong.d.ts +118 -0
  97. package/lib/Socket/dugong.js +810 -0
  98. package/lib/Socket/groups.d.ts +287 -0
  99. package/lib/Socket/groups.js +386 -0
  100. package/lib/Socket/index.d.ts +826 -0
  101. package/lib/Socket/index.js +35 -0
  102. package/lib/Socket/messages-recv.d.ts +613 -0
  103. package/lib/Socket/messages-recv.js +1851 -0
  104. package/lib/Socket/messages-send.d.ts +608 -0
  105. package/lib/Socket/messages-send.js +1574 -0
  106. package/lib/Socket/mex-fallback.d.ts +51 -0
  107. package/lib/Socket/mex-fallback.js +97 -0
  108. package/lib/Socket/mex.d.ts +1 -0
  109. package/lib/Socket/mex.js +41 -0
  110. package/lib/Socket/newsletter-ext.d.ts +47 -0
  111. package/lib/Socket/newsletter-ext.js +262 -0
  112. package/lib/Socket/newsletter.d.ts +285 -0
  113. package/lib/Socket/newsletter.js +223 -0
  114. package/lib/Socket/socket.d.ts +60 -0
  115. package/lib/Socket/socket.js +1001 -0
  116. package/lib/Socket/username.d.ts +842 -0
  117. package/lib/Socket/username.js +156 -0
  118. package/lib/Store/index.d.ts +3 -0
  119. package/lib/Store/index.js +3 -0
  120. package/lib/Store/make-in-memory-store.d.ts +62 -0
  121. package/lib/Store/make-in-memory-store.js +425 -0
  122. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  123. package/lib/Store/make-ordered-dictionary.js +78 -0
  124. package/lib/Store/object-repository.d.ts +10 -0
  125. package/lib/Store/object-repository.js +23 -0
  126. package/lib/Types/Auth.d.ts +1 -0
  127. package/lib/Types/Auth.js +1 -0
  128. package/lib/Types/Bussines.d.ts +1 -0
  129. package/lib/Types/Bussines.js +1 -0
  130. package/lib/Types/Call.d.ts +1 -0
  131. package/lib/Types/Call.js +1 -0
  132. package/lib/Types/Chat.d.ts +1 -0
  133. package/lib/Types/Chat.js +7 -0
  134. package/lib/Types/Contact.d.ts +1 -0
  135. package/lib/Types/Contact.js +1 -0
  136. package/lib/Types/Events.d.ts +1 -0
  137. package/lib/Types/Events.js +1 -0
  138. package/lib/Types/GroupMetadata.d.ts +1 -0
  139. package/lib/Types/GroupMetadata.js +1 -0
  140. package/lib/Types/Label.d.ts +2 -0
  141. package/lib/Types/Label.js +24 -0
  142. package/lib/Types/LabelAssociation.d.ts +2 -0
  143. package/lib/Types/LabelAssociation.js +6 -0
  144. package/lib/Types/Message.d.ts +11 -0
  145. package/lib/Types/Message.js +17 -0
  146. package/lib/Types/Mex.d.ts +2 -0
  147. package/lib/Types/Mex.js +38 -0
  148. package/lib/Types/Product.d.ts +1 -0
  149. package/lib/Types/Product.js +1 -0
  150. package/lib/Types/RichType.d.ts +2 -0
  151. package/lib/Types/RichType.js +22 -0
  152. package/lib/Types/Signal.d.ts +1 -0
  153. package/lib/Types/Signal.js +1 -0
  154. package/lib/Types/Socket.d.ts +1 -0
  155. package/lib/Types/Socket.js +1 -0
  156. package/lib/Types/State.d.ts +5 -0
  157. package/lib/Types/State.js +55 -0
  158. package/lib/Types/USync.d.ts +1 -0
  159. package/lib/Types/USync.js +1 -0
  160. package/lib/Types/index.d.ts +15 -0
  161. package/lib/Types/index.js +27 -0
  162. package/lib/Utils/PersistentStore.d.ts +83 -0
  163. package/lib/Utils/PersistentStore.js +592 -0
  164. package/lib/Utils/anchor-guard.d.ts +31 -0
  165. package/lib/Utils/anchor-guard.js +329 -0
  166. package/lib/Utils/android-stanza-id.d.ts +4 -0
  167. package/lib/Utils/android-stanza-id.js +21 -0
  168. package/lib/Utils/anti-delete.d.ts +62 -0
  169. package/lib/Utils/anti-delete.js +212 -0
  170. package/lib/Utils/auth-secure.d.ts +180 -0
  171. package/lib/Utils/auth-secure.js +791 -0
  172. package/lib/Utils/auth-utils.d.ts +59 -0
  173. package/lib/Utils/auth-utils.js +326 -0
  174. package/lib/Utils/auto-reconnect.d.ts +8 -0
  175. package/lib/Utils/auto-reconnect.js +204 -0
  176. package/lib/Utils/auto-reply.d.ts +35 -0
  177. package/lib/Utils/auto-reply.js +152 -0
  178. package/lib/Utils/bad-mac-handler.d.ts +59 -0
  179. package/lib/Utils/bad-mac-handler.js +119 -0
  180. package/lib/Utils/baileys-event-stream.d.ts +5 -0
  181. package/lib/Utils/baileys-event-stream.js +62 -0
  182. package/lib/Utils/browser-utils.d.ts +9 -0
  183. package/lib/Utils/browser-utils.js +29 -0
  184. package/lib/Utils/business.d.ts +49 -0
  185. package/lib/Utils/business.js +236 -0
  186. package/lib/Utils/button-helper-utils.d.ts +59 -0
  187. package/lib/Utils/button-helper-utils.js +266 -0
  188. package/lib/Utils/button-sender.d.ts +164 -0
  189. package/lib/Utils/button-sender.js +845 -0
  190. package/lib/Utils/chat-control.d.ts +98 -0
  191. package/lib/Utils/chat-control.js +231 -0
  192. package/lib/Utils/chat-history-helpers.d.ts +4 -0
  193. package/lib/Utils/chat-history-helpers.js +70 -0
  194. package/lib/Utils/chat-utils.d.ts +408 -0
  195. package/lib/Utils/chat-utils.js +879 -0
  196. package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
  197. package/lib/Utils/companion-reg-client-utils.js +39 -0
  198. package/lib/Utils/connection-watchdog.d.ts +10 -0
  199. package/lib/Utils/connection-watchdog.js +74 -0
  200. package/lib/Utils/crypto.d.ts +41 -0
  201. package/lib/Utils/crypto.js +145 -0
  202. package/lib/Utils/decode-wa-message.d.ts +83 -0
  203. package/lib/Utils/decode-wa-message.js +315 -0
  204. package/lib/Utils/disconnect-reason.d.ts +13 -0
  205. package/lib/Utils/disconnect-reason.js +36 -0
  206. package/lib/Utils/event-buffer.d.ts +12 -0
  207. package/lib/Utils/event-buffer.js +640 -0
  208. package/lib/Utils/fetch-timeout.d.ts +4 -0
  209. package/lib/Utils/fetch-timeout.js +14 -0
  210. package/lib/Utils/ffmpeg-path.d.ts +5 -0
  211. package/lib/Utils/ffmpeg-path.js +130 -0
  212. package/lib/Utils/generics.d.ts +79 -0
  213. package/lib/Utils/generics.js +426 -0
  214. package/lib/Utils/group-metadata-cache.d.ts +3 -0
  215. package/lib/Utils/group-metadata-cache.js +25 -0
  216. package/lib/Utils/group-status-detection.d.ts +5 -0
  217. package/lib/Utils/group-status-detection.js +114 -0
  218. package/lib/Utils/history.d.ts +91 -0
  219. package/lib/Utils/history.js +144 -0
  220. package/lib/Utils/html-app.d.ts +14 -0
  221. package/lib/Utils/html-app.js +97 -0
  222. package/lib/Utils/html-multiplayer.d.ts +8 -0
  223. package/lib/Utils/html-multiplayer.js +90 -0
  224. package/lib/Utils/humanizer.d.ts +8 -0
  225. package/lib/Utils/humanizer.js +74 -0
  226. package/lib/Utils/identity-change-handler.d.ts +13 -0
  227. package/lib/Utils/identity-change-handler.js +49 -0
  228. package/lib/Utils/index.d.ts +88 -0
  229. package/lib/Utils/index.js +93 -0
  230. package/lib/Utils/jid-tools.d.ts +3 -0
  231. package/lib/Utils/jid-tools.js +78 -0
  232. package/lib/Utils/link-preview-metadata.d.ts +47 -0
  233. package/lib/Utils/link-preview-metadata.js +90 -0
  234. package/lib/Utils/link-preview.d.ts +12 -0
  235. package/lib/Utils/link-preview.js +84 -0
  236. package/lib/Utils/lock-manager.d.ts +5 -0
  237. package/lib/Utils/lock-manager.js +50 -0
  238. package/lib/Utils/logger.d.ts +2 -0
  239. package/lib/Utils/logger.js +2 -0
  240. package/lib/Utils/lt-hash.d.ts +12 -0
  241. package/lib/Utils/lt-hash.js +26 -0
  242. package/lib/Utils/make-mutex.d.ts +6 -0
  243. package/lib/Utils/make-mutex.js +32 -0
  244. package/lib/Utils/media-messages.d.ts +35 -0
  245. package/lib/Utils/media-messages.js +70 -0
  246. package/lib/Utils/media-processor.d.ts +6 -0
  247. package/lib/Utils/media-processor.js +174 -0
  248. package/lib/Utils/media-set.d.ts +6 -0
  249. package/lib/Utils/media-set.js +169 -0
  250. package/lib/Utils/message-kind.d.ts +26 -0
  251. package/lib/Utils/message-kind.js +138 -0
  252. package/lib/Utils/message-retry-manager.d.ts +79 -0
  253. package/lib/Utils/message-retry-manager.js +264 -0
  254. package/lib/Utils/message-search.d.ts +40 -0
  255. package/lib/Utils/message-search.js +181 -0
  256. package/lib/Utils/messages-media.d.ts +136 -0
  257. package/lib/Utils/messages-media.js +867 -0
  258. package/lib/Utils/messages.d.ts +66 -0
  259. package/lib/Utils/messages.js +2271 -0
  260. package/lib/Utils/meta-ai-msmsg.d.ts +3 -0
  261. package/lib/Utils/meta-ai-msmsg.js +132 -0
  262. package/lib/Utils/meta-ai.d.ts +4 -0
  263. package/lib/Utils/meta-ai.js +75 -0
  264. package/lib/Utils/migrate-auth-state.d.ts +23 -0
  265. package/lib/Utils/migrate-auth-state.js +126 -0
  266. package/lib/Utils/mini-app.d.ts +20 -0
  267. package/lib/Utils/mini-app.js +215 -0
  268. package/lib/Utils/mock-socket.d.ts +67 -0
  269. package/lib/Utils/mock-socket.js +254 -0
  270. package/lib/Utils/modern-messages.d.ts +64 -0
  271. package/lib/Utils/modern-messages.js +497 -0
  272. package/lib/Utils/native-flow.d.ts +19 -0
  273. package/lib/Utils/native-flow.js +112 -0
  274. package/lib/Utils/newsletter-status.d.ts +157 -0
  275. package/lib/Utils/newsletter-status.js +652 -0
  276. package/lib/Utils/noise-handler.d.ts +20 -0
  277. package/lib/Utils/noise-handler.js +200 -0
  278. package/lib/Utils/offline-node-processor.d.ts +9 -0
  279. package/lib/Utils/offline-node-processor.js +39 -0
  280. package/lib/Utils/pairing-utils.d.ts +5 -0
  281. package/lib/Utils/pairing-utils.js +29 -0
  282. package/lib/Utils/passkey.d.ts +4 -0
  283. package/lib/Utils/passkey.js +11 -0
  284. package/lib/Utils/past-participants.d.ts +2 -0
  285. package/lib/Utils/past-participants.js +40 -0
  286. package/lib/Utils/payment-detection.d.ts +40 -0
  287. package/lib/Utils/payment-detection.js +213 -0
  288. package/lib/Utils/payment-guard.d.ts +28 -0
  289. package/lib/Utils/payment-guard.js +143 -0
  290. package/lib/Utils/payment-messages.d.ts +42 -0
  291. package/lib/Utils/payment-messages.js +161 -0
  292. package/lib/Utils/payment-utils.d.ts +75 -0
  293. package/lib/Utils/payment-utils.js +145 -0
  294. package/lib/Utils/phone-utils.d.ts +3 -0
  295. package/lib/Utils/phone-utils.js +29 -0
  296. package/lib/Utils/pre-key-manager.d.ts +25 -0
  297. package/lib/Utils/pre-key-manager.js +105 -0
  298. package/lib/Utils/process-message.d.ts +103 -0
  299. package/lib/Utils/process-message.js +868 -0
  300. package/lib/Utils/qr-terminal.d.ts +1 -0
  301. package/lib/Utils/qr-terminal.js +16 -0
  302. package/lib/Utils/reconnect-backoff.d.ts +25 -0
  303. package/lib/Utils/reconnect-backoff.js +47 -0
  304. package/lib/Utils/reporting-utils.d.ts +12 -0
  305. package/lib/Utils/reporting-utils.js +257 -0
  306. package/lib/Utils/rich-message-utils.d.ts +54 -0
  307. package/lib/Utils/rich-message-utils.js +435 -0
  308. package/lib/Utils/rich-messages.d.ts +298 -0
  309. package/lib/Utils/rich-messages.js +1145 -0
  310. package/lib/Utils/scheduled-message.d.ts +81 -0
  311. package/lib/Utils/scheduled-message.js +101 -0
  312. package/lib/Utils/scheduling.d.ts +59 -0
  313. package/lib/Utils/scheduling.js +139 -0
  314. package/lib/Utils/signal.d.ts +82 -0
  315. package/lib/Utils/signal.js +200 -0
  316. package/lib/Utils/stanza-ack.d.ts +16 -0
  317. package/lib/Utils/stanza-ack.js +37 -0
  318. package/lib/Utils/status-stickers.d.ts +79 -0
  319. package/lib/Utils/status-stickers.js +261 -0
  320. package/lib/Utils/status.d.ts +107 -0
  321. package/lib/Utils/status.js +131 -0
  322. package/lib/Utils/sticker-pack-maker.d.ts +20 -0
  323. package/lib/Utils/sticker-pack-maker.js +112 -0
  324. package/lib/Utils/stickerpack.d.ts +18 -0
  325. package/lib/Utils/stickerpack.js +316 -0
  326. package/lib/Utils/sync-action-utils.d.ts +2 -0
  327. package/lib/Utils/sync-action-utils.js +48 -0
  328. package/lib/Utils/tag.d.ts +8 -0
  329. package/lib/Utils/tag.js +45 -0
  330. package/lib/Utils/tc-token-utils.d.ts +29 -0
  331. package/lib/Utils/tc-token-utils.js +162 -0
  332. package/lib/Utils/templates.d.ts +86 -0
  333. package/lib/Utils/templates.js +148 -0
  334. package/lib/Utils/text-format.d.ts +13 -0
  335. package/lib/Utils/text-format.js +81 -0
  336. package/lib/Utils/text-tools.d.ts +3 -0
  337. package/lib/Utils/text-tools.js +38 -0
  338. package/lib/Utils/ttl-cache.d.ts +29 -0
  339. package/lib/Utils/ttl-cache.js +123 -0
  340. package/lib/Utils/use-cache-manager-auth-state.d.ts +22 -0
  341. package/lib/Utils/use-cache-manager-auth-state.js +86 -0
  342. package/lib/Utils/use-multi-file-auth-state.d.ts +20 -0
  343. package/lib/Utils/use-multi-file-auth-state.js +201 -0
  344. package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
  345. package/lib/Utils/use-single-file-auth-state.js +111 -0
  346. package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
  347. package/lib/Utils/use-sqlite-auth-state.js +171 -0
  348. package/lib/Utils/username.d.ts +22 -0
  349. package/lib/Utils/username.js +59 -0
  350. package/lib/Utils/validate-connection.d.ts +43 -0
  351. package/lib/Utils/validate-connection.js +197 -0
  352. package/lib/Utils/vcard.d.ts +40 -0
  353. package/lib/Utils/vcard.js +92 -0
  354. package/lib/Utils/voice-note.d.ts +13 -0
  355. package/lib/Utils/voice-note.js +47 -0
  356. package/lib/VoIP/audio-feeder.d.ts +15 -0
  357. package/lib/VoIP/audio-feeder.js +132 -0
  358. package/lib/VoIP/index.d.ts +22 -0
  359. package/lib/VoIP/index.js +277 -0
  360. package/lib/VoIP/relay-transport.d.ts +16 -0
  361. package/lib/VoIP/relay-transport.js +559 -0
  362. package/lib/VoIP/signaling.d.ts +16 -0
  363. package/lib/VoIP/signaling.js +624 -0
  364. package/lib/VoIP/types.d.ts +11 -0
  365. package/lib/VoIP/types.js +17 -0
  366. package/lib/VoIP/wasm-engine.d.ts +28 -0
  367. package/lib/VoIP/wasm-engine.js +1214 -0
  368. package/lib/VoIP/worker-bootstrap.d.ts +1 -0
  369. package/lib/VoIP/worker-bootstrap.js +1042 -0
  370. package/lib/WABinary/constants.d.ts +61 -0
  371. package/lib/WABinary/constants.js +1466 -0
  372. package/lib/WABinary/decode.d.ts +9 -0
  373. package/lib/WABinary/decode.js +261 -0
  374. package/lib/WABinary/encode.d.ts +2 -0
  375. package/lib/WABinary/encode.js +219 -0
  376. package/lib/WABinary/generic-utils.d.ts +45 -0
  377. package/lib/WABinary/generic-utils.js +285 -0
  378. package/lib/WABinary/index.d.ts +5 -0
  379. package/lib/WABinary/index.js +5 -0
  380. package/lib/WABinary/jid-utils.d.ts +32 -0
  381. package/lib/WABinary/jid-utils.js +102 -0
  382. package/lib/WABinary/types.d.ts +1 -0
  383. package/lib/WABinary/types.js +1 -0
  384. package/lib/WAM/BinaryInfo.d.ts +7 -0
  385. package/lib/WAM/BinaryInfo.js +9 -0
  386. package/lib/WAM/constants.d.ts +34926 -0
  387. package/lib/WAM/constants.js +22852 -0
  388. package/lib/WAM/encode.d.ts +1 -0
  389. package/lib/WAM/encode.js +149 -0
  390. package/lib/WAM/index.d.ts +3 -0
  391. package/lib/WAM/index.js +3 -0
  392. package/lib/WAUSync/Protocols/USyncBusinessProtocol.d.ts +43 -0
  393. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +32 -0
  394. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  395. package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  396. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
  397. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +60 -0
  398. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  399. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  400. package/lib/WAUSync/Protocols/USyncFeatureProtocol.d.ts +13 -0
  401. package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +28 -0
  402. package/lib/WAUSync/Protocols/USyncPictureProtocol.d.ts +22 -0
  403. package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
  404. package/lib/WAUSync/Protocols/USyncSidelistProtocol.d.ts +20 -0
  405. package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +23 -0
  406. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  407. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  408. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.d.ts +14 -0
  409. package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +24 -0
  410. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  411. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  412. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
  413. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +49 -0
  414. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
  415. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  416. package/lib/WAUSync/Protocols/index.d.ts +12 -0
  417. package/lib/WAUSync/Protocols/index.js +12 -0
  418. package/lib/WAUSync/USyncQuery.d.ts +25 -0
  419. package/lib/WAUSync/USyncQuery.js +140 -0
  420. package/lib/WAUSync/USyncUser.d.ts +24 -0
  421. package/lib/WAUSync/USyncUser.js +47 -0
  422. package/lib/WAUSync/index.d.ts +3 -0
  423. package/lib/WAUSync/index.js +3 -0
  424. package/lib/assets/wasm/loader.js +5 -0
  425. package/lib/assets/wasm/whatsapp.wasm +0 -0
  426. package/lib/assets/wasm/worker-modules.js +273 -0
  427. package/lib/exports-extra.d.ts +45 -0
  428. package/lib/exports-extra.js +47 -0
  429. package/lib/index.d.ts +16 -0
  430. package/lib/index.js +24 -0
  431. package/package.json +161 -4
@@ -0,0 +1,143 @@
1
+ // Vanz@Port --- ported from @lpzeravk/baileys 1.0.0 (payment-guard.js). Creator credits untouched. See NOTICE.md.
2
+ // lib/Utils/payment-guard.js
3
+ //
4
+ // Encanamento genérico para detecção de mensagens de pagamento "stealth"
5
+ // (ocultas/editadas). A LIB não decide o que é payment — isso é lógica do
6
+ // seu bot. Aqui só garantimos que NENHUM caminho de entrada fica sem cobrir:
7
+ //
8
+ // 1) Mensagem direta normal -> 'messages.upsert'
9
+ // 2) Mensagem EDITADA depois -> 'messages.update' (protocolMessage MESSAGE_EDIT)
10
+ // 3) Mensagem que falhou decrypt -> 'messages.decrypt-failed' (emitido pela lib)
11
+ //
12
+ // Limite real (sem prometer o impossível): uma mensagem que falha no decrypt
13
+ // (PreKey/CIPHERTEXT) nunca foi lida pelo bot — não existe forma de "ver" que
14
+ // é payment. O que dá pra garantir é que isso nunca passe em silêncio: o
15
+ // evento é sempre emitido, e cabe ao seu detector decidir o que fazer com a
16
+ // falta de conteúdo (ex: tratar como suspeito, igual ao 'unreadable' que você
17
+ // já usa no seu messageEnvelopeRegistry).
18
+ //
19
+ // Você injeta sua própria lógica (paymentMessage.js, messageEnvelopeRegistry.js
20
+ // etc. do seu bot) via callbacks — a lib não importa nada do seu projeto.
21
+
22
+ /**
23
+ * @typedef {Object} PaymentGuardHooks
24
+ * @property {(webMessage: any) => boolean} isPaymentMessage
25
+ * Função que decide se um webMessage (ou webMessage sintético de edição)
26
+ * é uma mensagem de pagamento. Normalmente seu `hasPaymentMessage`.
27
+ * @property {(webMessage: any, isPayment: boolean) => void} [recordEnvelope]
28
+ * Chamado para TODA mensagem de grupo vista (payment ou não), inclusive
29
+ * falhas de decrypt (com `webMessage.message === null`). Normalmente seu
30
+ * `recordMessageEnvelope`.
31
+ * @property {(detection: PaymentDetection) => void} onDetect
32
+ * Chamado sempre que uma detecção (direta, editada ou indecifrável
33
+ * suspeita) acontece.
34
+ * @property {boolean} [treatDecryptFailureAsSuspicious=true]
35
+ */
36
+
37
+ /**
38
+ * @typedef {Object} PaymentDetection
39
+ * @property {'direct'|'edited'|'undecryptable'} type
40
+ * @property {string} remoteJid
41
+ * @property {string|undefined} participant
42
+ * @property {string|undefined} messageId
43
+ * @property {boolean} [isPreKeyError]
44
+ * @property {string} [errorMessage]
45
+ */
46
+
47
+ const extractEditedContent = (updateEntry) => updateEntry?.update?.message?.editedMessage?.message || null;
48
+
49
+ /**
50
+ * Liga o guard completo num socket Baileys. Chame uma vez, logo após criar o sock.
51
+ *
52
+ * @param {import('../Socket/index.js').WASocket} sock
53
+ * @param {PaymentGuardHooks} hooks
54
+ * @returns {() => void} função de cleanup que remove todos os listeners
55
+ */
56
+ export const bindPaymentGuard = (sock, hooks) => {
57
+ const {
58
+ isPaymentMessage,
59
+ recordEnvelope = () => {},
60
+ onDetect = () => {},
61
+ treatDecryptFailureAsSuspicious = true,
62
+ } = hooks || {};
63
+
64
+ if (typeof isPaymentMessage !== 'function') {
65
+ throw new Error('bindPaymentGuard: hooks.isPaymentMessage é obrigatório');
66
+ }
67
+
68
+ // ── 1) Mensagens diretas ────────────────────────────────────────────────
69
+ const onUpsert = ({ messages }) => {
70
+ for (const webMessage of messages || []) {
71
+ const remoteJid = webMessage?.key?.remoteJid;
72
+ if (!remoteJid?.endsWith('@g.us')) continue;
73
+
74
+ const isPayment = isPaymentMessage(webMessage);
75
+ recordEnvelope(webMessage, isPayment);
76
+
77
+ if (isPayment) {
78
+ onDetect({
79
+ type: 'direct',
80
+ remoteJid,
81
+ participant: webMessage.key?.participant,
82
+ messageId: webMessage.key?.id,
83
+ });
84
+ }
85
+ }
86
+ };
87
+
88
+ // ── 2) Mensagens editadas (golpe de edição pós-envio) ───────────────────
89
+ const onUpdate = (updates) => {
90
+ for (const u of updates || []) {
91
+ const editedContent = extractEditedContent(u);
92
+ if (!editedContent) continue;
93
+
94
+ const remoteJid = u.key?.remoteJid;
95
+ if (!remoteJid?.endsWith('@g.us')) continue;
96
+
97
+ const syntheticWebMessage = { message: editedContent, key: u.key };
98
+ const isPayment = isPaymentMessage(syntheticWebMessage);
99
+ recordEnvelope(syntheticWebMessage, isPayment);
100
+
101
+ if (isPayment) {
102
+ onDetect({
103
+ type: 'edited',
104
+ remoteJid,
105
+ participant: u.key?.participant,
106
+ messageId: u.key?.id,
107
+ });
108
+ }
109
+ }
110
+ };
111
+
112
+ // ── 3) Falha de decrypt (PreKey / CIPHERTEXT) ───────────────────────────
113
+ const onDecryptFailed = (failInfo) => {
114
+ const remoteJid = failInfo?.remoteJid;
115
+ if (!remoteJid?.endsWith('@g.us')) return;
116
+
117
+ recordEnvelope(
118
+ { key: { remoteJid, id: failInfo.messageId, participant: failInfo.participant }, message: null },
119
+ false
120
+ );
121
+
122
+ if (treatDecryptFailureAsSuspicious) {
123
+ onDetect({
124
+ type: 'undecryptable',
125
+ remoteJid,
126
+ participant: failInfo.participant,
127
+ messageId: failInfo.messageId,
128
+ isPreKeyError: failInfo.isPreKeyError,
129
+ errorMessage: failInfo.errorMessage,
130
+ });
131
+ }
132
+ };
133
+
134
+ sock.ev.on('messages.upsert', onUpsert);
135
+ sock.ev.on('messages.update', onUpdate);
136
+ sock.ev.on('messages.decrypt-failed', onDecryptFailed);
137
+
138
+ return function unbindPaymentGuard() {
139
+ sock.ev.off('messages.upsert', onUpsert);
140
+ sock.ev.off('messages.update', onUpdate);
141
+ sock.ev.off('messages.decrypt-failed', onDecryptFailed);
142
+ };
143
+ };
@@ -0,0 +1,42 @@
1
+ export const SplitPaymentStatus: Readonly<{
2
+ PENDING: 0;
3
+ PAID: 1;
4
+ }>;
5
+ export const ReminderFrequency: Readonly<{
6
+ REMINDER_FREQUENCY_UNKNOWN: 0;
7
+ WEEKLY: 1;
8
+ BI_WEEKLY: 2;
9
+ MONTHLY: 3;
10
+ QUARTERLY: 4;
11
+ }>;
12
+ export const ReminderStatus: Readonly<{
13
+ REMINDER_STATUS_UNKNOWN: 0;
14
+ ACTIVE: 1;
15
+ CANCELLED_BY_CREATOR: 2;
16
+ STOPPED_BY_RECEIVER: 3;
17
+ EXPIRED: 4;
18
+ PAID: 5;
19
+ }>;
20
+ export const MONEY_OFFSET: 1000;
21
+ export function money(amount: any, currencyCode: any, offset?: number): {
22
+ value: number;
23
+ offset: number;
24
+ currencyCode: string;
25
+ };
26
+ export function readMoney(value: any): {
27
+ amount: number;
28
+ currencyCode: any;
29
+ };
30
+ export function buildSplitPayment(opts1?: { [key: string]: any;
31
+ participants?: any[];
32
+ }): any;
33
+ export function buildSplitPaymentUpdate(opts2?: { [key: string]: any; }): {
34
+ splitId: string;
35
+ participantJid: any;
36
+ };
37
+ export function buildPaymentReminder(opts3?: { [key: string]: any;
38
+ frequency?: 3;
39
+ status?: 1;
40
+ }): any;
41
+ export function readSplitPayment(msg: any): any;
42
+ export function readPaymentReminder(msg: any): any;
@@ -0,0 +1,161 @@
1
+ // Vanz@Port --- ported from @rexxhayanasi/elaina-baileys 1.3.10 (payment-messages.js). Creator credits untouched. See NOTICE.md.
2
+
3
+ export const SplitPaymentStatus = Object.freeze({ PENDING: 0, PAID: 1 })
4
+
5
+ export const ReminderFrequency = Object.freeze({
6
+ REMINDER_FREQUENCY_UNKNOWN: 0,
7
+ WEEKLY: 1,
8
+ BI_WEEKLY: 2,
9
+ MONTHLY: 3,
10
+ QUARTERLY: 4
11
+ })
12
+
13
+ export const ReminderStatus = Object.freeze({
14
+ REMINDER_STATUS_UNKNOWN: 0,
15
+ ACTIVE: 1,
16
+ CANCELLED_BY_CREATOR: 2,
17
+ STOPPED_BY_RECEIVER: 3,
18
+ EXPIRED: 4,
19
+ PAID: 5
20
+ })
21
+
22
+ export const MONEY_OFFSET = 1000
23
+
24
+ const drop = (object) => {
25
+ for (const key of Object.keys(object)) {
26
+ if (object[key] === undefined || object[key] === null) {
27
+ delete object[key]
28
+ }
29
+ }
30
+ return object
31
+ }
32
+
33
+ /**
34
+ * Money travels as an integer scaled by offset, so 50000 rupiah at the usual
35
+ * offset of 1000 goes on the wire as 50000000. Passing the scaled value by
36
+ * mistake overcharges by three orders of magnitude, so the amount here is
37
+ * always the human one.
38
+ */
39
+ export const money = (amount, currencyCode, offset = MONEY_OFFSET) => {
40
+ const value = Number(amount)
41
+ if (!Number.isFinite(value) || value < 0) {
42
+ throw new TypeError('money needs a non-negative amount')
43
+ }
44
+ if (typeof currencyCode !== 'string' || currencyCode.length !== 3) {
45
+ throw new TypeError('money needs a three letter currency code, like IDR or USD')
46
+ }
47
+ if (!Number.isInteger(offset) || offset <= 0) {
48
+ throw new TypeError('money offset must be a positive integer')
49
+ }
50
+ return { value: Math.round(value * offset), offset, currencyCode: currencyCode.toUpperCase() }
51
+ }
52
+
53
+ export const readMoney = (value) => {
54
+ if (!value?.offset) {
55
+ return undefined
56
+ }
57
+ return {
58
+ amount: Number(value.value) / Number(value.offset),
59
+ currencyCode: value.currencyCode
60
+ }
61
+ }
62
+
63
+ export const buildSplitPayment = ({ splitId, total, currency, description, requesterJid, participants = [], createdAt } = {}) => {
64
+ if (!splitId) {
65
+ throw new TypeError('buildSplitPayment needs a splitId, the update message is keyed on it')
66
+ }
67
+ if (!participants.length) {
68
+ throw new TypeError('buildSplitPayment needs at least one participant')
69
+ }
70
+ return drop({
71
+ splitId: String(splitId),
72
+ totalAmount: total === undefined ? undefined : money(total, currency),
73
+ description,
74
+ requesterJid,
75
+ participants: participants.map((participant, index) => {
76
+ if (!participant?.jid) {
77
+ throw new TypeError(`participant ${index} needs a jid`)
78
+ }
79
+ return drop({
80
+ jid: participant.jid,
81
+ amount: participant.amount === undefined ? undefined : money(participant.amount, participant.currency ?? currency),
82
+ status: participant.status ?? SplitPaymentStatus.PENDING
83
+ })
84
+ }),
85
+ createdAtMs: createdAt === undefined ? Date.now() : Number(createdAt)
86
+ })
87
+ }
88
+
89
+ export const buildSplitPaymentUpdate = ({ splitId, participantJid } = {}) => {
90
+ if (!splitId || !participantJid) {
91
+ throw new TypeError('buildSplitPaymentUpdate needs both splitId and participantJid')
92
+ }
93
+ return { splitId: String(splitId), participantJid }
94
+ }
95
+
96
+ export const buildPaymentReminder = ({
97
+ reminderId,
98
+ instanceId,
99
+ description,
100
+ frequency = ReminderFrequency.MONTHLY,
101
+ status = ReminderStatus.ACTIVE,
102
+ amount,
103
+ currency,
104
+ payeeVpa,
105
+ payeeJid,
106
+ payerJid
107
+ } = {}) => {
108
+ if (!reminderId) {
109
+ throw new TypeError('buildPaymentReminder needs a reminderId')
110
+ }
111
+ return drop({
112
+ reminderId: String(reminderId),
113
+ instanceId: instanceId === undefined ? undefined : String(instanceId),
114
+ description,
115
+ frequency,
116
+ status,
117
+ amount: amount === undefined ? undefined : money(amount, currency),
118
+ payeeVpa,
119
+ payeeJid,
120
+ payerJid
121
+ })
122
+ }
123
+
124
+ export const readSplitPayment = (msg) => {
125
+ const message = msg?.message ?? msg
126
+ const split = message?.splitPaymentMessage
127
+ if (!split) {
128
+ return null
129
+ }
130
+ return drop({
131
+ splitId: split.splitId,
132
+ total: readMoney(split.totalAmount),
133
+ description: split.description,
134
+ requesterJid: split.requesterJid,
135
+ createdAtMs: split.createdAtMs === undefined ? undefined : Number(split.createdAtMs),
136
+ participants: (split.participants ?? []).map(participant => drop({
137
+ jid: participant.jid,
138
+ amount: readMoney(participant.amount),
139
+ status: participant.status
140
+ }))
141
+ })
142
+ }
143
+
144
+ export const readPaymentReminder = (msg) => {
145
+ const message = msg?.message ?? msg
146
+ const reminder = message?.paymentReminderMessage
147
+ if (!reminder) {
148
+ return null
149
+ }
150
+ return drop({
151
+ reminderId: reminder.reminderId,
152
+ instanceId: reminder.instanceId,
153
+ description: reminder.description,
154
+ frequency: reminder.frequency,
155
+ status: reminder.status,
156
+ amount: readMoney(reminder.amount),
157
+ payeeVpa: reminder.payeeVpa,
158
+ payeeJid: reminder.payeeJid,
159
+ payerJid: reminder.payerJid
160
+ })
161
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Build one `payment_account` entry for `payment_settings` (shown as a payout option on a
3
+ * PENDING/request card). `institution` must exactly match WhatsApp's registry name for that
4
+ * bank/e-wallet, or its logo won't render.
5
+ * @param {'bank_account'|'digital_wallet'} accountType
6
+ * @param {'id_account_number'|'phone_number'} identifierType
7
+ * @param {string} identifier Account number or phone number.
8
+ * @param {string} institution Exact registry name, e.g. "Bank Central Asia", "GoPay".
9
+ * @param {string} beneficiaryName Payee name shown on every listed account.
10
+ */
11
+ export function buildPaymentAccount(accountType: "bank_account" | "digital_wallet", identifierType: "id_account_number" | "phone_number", identifier: string, institution: string, beneficiaryName: string): {
12
+ type: string;
13
+ payment_account: {
14
+ account_type: "bank_account" | "digital_wallet";
15
+ identifier_type: "id_account_number" | "phone_number";
16
+ identifier_value: string;
17
+ institution_name: string;
18
+ beneficiary_name: string;
19
+ };
20
+ };
21
+ /**
22
+ * Build the `review_and_pay` native-flow button's `buttonParamsJson` payload.
23
+ * @param {object} spec
24
+ * @param {number} spec.amount Nominal amount, in rupiah (whole units, not cents).
25
+ * @param {string} spec.item Item/product name shown on the card.
26
+ * @param {string} [spec.note] Additional note/description.
27
+ * @param {boolean} [spec.done] `false` (default) = PENDING request card with a "Lihat opsi
28
+ * pembayaran" button listing `spec.accounts`. `true` = COMPLETED card (already paid).
29
+ * @param {object[]} [spec.accounts] Payout options for the PENDING card — array of
30
+ * `buildPaymentAccount(...)` results. Required (and only used) when `done` is falsy.
31
+ * @returns {string} The JSON-stringified payload, ready for `Button#addButton('review_and_pay', ...)`.
32
+ */
33
+ export function buildPaymentParams(opts3?: { [key: string]: any;
34
+ amount: number;
35
+ item: string;
36
+ note?: string;
37
+ done?: boolean;
38
+ accounts?: object[];
39
+ }): string;
40
+ /**
41
+ * Build and send a `review_and_pay` order/payment card via the existing `Button` builder.
42
+ * Thin convenience wrapper around `buildPaymentParams()` + `Button` — for anything beyond a
43
+ * single header image/title/body/footer/button (e.g. extra buttons alongside the payment
44
+ * one), build the `Button` yourself and call `.addButton('review_and_pay', buildPaymentParams(spec))`.
45
+ * @param {import('../../WAProto/index.js').WASocket} client Active Baileys socket.
46
+ * @param {string} jid Destination chat/group jid.
47
+ * @param {object} spec Same shape as `buildPaymentParams()`'s `spec`.
48
+ * @param {object} [opts]
49
+ * @param {string} [opts.title] Header title. @param {string} [opts.body] Body text.
50
+ * @param {string} [opts.footer] Footer text. @param {string} [opts.image] Header image URL.
51
+ */
52
+ export function sendPayment(client: any, jid: string, spec: object, opts1?: { [key: string]: any;
53
+ title?: string;
54
+ body?: string;
55
+ footer?: string;
56
+ image?: string;
57
+ }): Promise<any>;
58
+ /**
59
+ * Build and send a `review_and_pay` order/payment card via the existing `Button` builder.
60
+ * Thin convenience wrapper around `buildPaymentParams()` + `Button` — for anything beyond a
61
+ * single header image/title/body/footer/button (e.g. extra buttons alongside the payment
62
+ * one), build the `Button` yourself and call `.addButton('review_and_pay', buildPaymentParams(spec))`.
63
+ * @param {import('../../WAProto/index.js').WASocket} client Active Baileys socket.
64
+ * @param {string} jid Destination chat/group jid.
65
+ * @param {object} spec Same shape as `buildPaymentParams()`'s `spec`.
66
+ * @param {object} [opts]
67
+ * @param {string} [opts.title] Header title. @param {string} [opts.body] Body text.
68
+ * @param {string} [opts.footer] Footer text. @param {string} [opts.image] Header image URL.
69
+ */
70
+ export function Pay(client: any, jid: string, spec: object, opts2?: { [key: string]: any;
71
+ title?: string;
72
+ body?: string;
73
+ footer?: string;
74
+ image?: string;
75
+ }): Promise<any>;
@@ -0,0 +1,145 @@
1
+
2
+ // Button is imported lazily inside sendPayment(): Button.js imports buildPaymentParams() from this file (Button#addPay), so a static import here would be circular.
3
+
4
+ /**
5
+ * Build one `payment_account` entry for `payment_settings` (shown as a payout option on a
6
+ * PENDING/request card). `institution` must exactly match WhatsApp's registry name for that
7
+ * bank/e-wallet, or its logo won't render.
8
+ * @param {'bank_account'|'digital_wallet'} accountType
9
+ * @param {'id_account_number'|'phone_number'} identifierType
10
+ * @param {string} identifier Account number or phone number.
11
+ * @param {string} institution Exact registry name, e.g. "Bank Central Asia", "GoPay".
12
+ * @param {string} beneficiaryName Payee name shown on every listed account.
13
+ */
14
+ export function buildPaymentAccount(accountType, identifierType, identifier, institution, beneficiaryName) {
15
+ return {
16
+ type: 'payment_account',
17
+ payment_account: {
18
+ account_type: accountType,
19
+ identifier_type: identifierType,
20
+ identifier_value: identifier,
21
+ institution_name: institution,
22
+ beneficiary_name: beneficiaryName,
23
+ },
24
+ };
25
+ }
26
+
27
+ /**
28
+ * Build the `review_and_pay` native-flow button's `buttonParamsJson` payload.
29
+ * @param {object} spec
30
+ * @param {number} spec.amount Nominal amount, in rupiah (whole units, not cents).
31
+ * @param {string} spec.item Item/product name shown on the card.
32
+ * @param {string} [spec.note] Additional note/description.
33
+ * @param {boolean} [spec.done] `false` (default) = PENDING request card with a "Lihat opsi
34
+ * pembayaran" button listing `spec.accounts`. `true` = COMPLETED card (already paid).
35
+ * @param {object[]} [spec.accounts] Payout options for the PENDING card — array of
36
+ * `buildPaymentAccount(...)` results. Required (and only used) when `done` is falsy.
37
+ * @returns {string} The JSON-stringified payload, ready for `Button#addButton('review_and_pay', ...)`.
38
+ */
39
+ export function buildPaymentParams({ amount, item, note = '', done = false, accounts = [] } = {}) {
40
+ if (typeof amount !== 'number' || !Number.isFinite(amount)) {
41
+ throw new TypeError('buildPaymentParams: spec.amount must be a finite number');
42
+ }
43
+ if (typeof item !== 'string' || !item) {
44
+ throw new TypeError('buildPaymentParams: spec.item must be a non-empty string');
45
+ }
46
+
47
+ const value = amount * 100; // offset 100 -> value = rupiah * 100
48
+ const money = { value, offset: 100 };
49
+
50
+ if (done) {
51
+ const refId = `CPAY-${Date.now()}`;
52
+ const item_ = {
53
+ retailer_id: `item-${Date.now()}${Math.floor(Math.random() * 1e6)}`,
54
+ name: item,
55
+ amount: money,
56
+ quantity: 1,
57
+ };
58
+
59
+ return JSON.stringify({
60
+ currency: 'IDR',
61
+ total_amount: money,
62
+ reference_id: refId,
63
+ type: 'physical-goods',
64
+ additional_note: note,
65
+ native_payment_methods: [],
66
+ share_payment_status: true,
67
+ payment_type: '',
68
+ payment_method: 'confirm',
69
+ payment_status: 'captured',
70
+ payment_timestamp: Date.now(),
71
+ payment_configuration: '',
72
+ order: {
73
+ status: 'completed',
74
+ order_type: 'PAYMENT_REQUEST',
75
+ subtotal: money,
76
+ items: [item_],
77
+ },
78
+ });
79
+ }
80
+
81
+ if (!accounts.length) {
82
+ throw new TypeError('buildPaymentParams: spec.accounts is required (and non-empty) when spec.done is not true');
83
+ }
84
+
85
+ const refId = `PAY-${Date.now()}`;
86
+ const item_ = {
87
+ name: item,
88
+ amount: money,
89
+ quantity: 1,
90
+ description: note,
91
+ };
92
+
93
+ return JSON.stringify({
94
+ currency: 'IDR',
95
+ total_amount: money,
96
+ reference_id: refId,
97
+ type: 'physical-goods',
98
+ additional_note: note,
99
+ native_payment_methods: [],
100
+ share_payment_status: false,
101
+ payment_configuration: '',
102
+ payment_type: 'upr',
103
+ payment_settings: accounts,
104
+ order: {
105
+ status: 'pending',
106
+ description: note,
107
+ order_type: 'PAYMENT_REQUEST',
108
+ items: [item_],
109
+ subtotal: money,
110
+ tax: { value: 0, offset: 100 },
111
+ shipping: { value: 0, offset: 100 },
112
+ discount: { value: 0, offset: 100 },
113
+ },
114
+ });
115
+ }
116
+
117
+ /**
118
+ * Build and send a `review_and_pay` order/payment card via the existing `Button` builder.
119
+ * Thin convenience wrapper around `buildPaymentParams()` + `Button` — for anything beyond a
120
+ * single header image/title/body/footer/button (e.g. extra buttons alongside the payment
121
+ * one), build the `Button` yourself and call `.addButton('review_and_pay', buildPaymentParams(spec))`.
122
+ * @param {import('../../WAProto/index.js').WASocket} client Active Baileys socket.
123
+ * @param {string} jid Destination chat/group jid.
124
+ * @param {object} spec Same shape as `buildPaymentParams()`'s `spec`.
125
+ * @param {object} [opts]
126
+ * @param {string} [opts.title] Header title. @param {string} [opts.body] Body text.
127
+ * @param {string} [opts.footer] Footer text. @param {string} [opts.image] Header image URL.
128
+ */
129
+ export async function sendPayment(client, jid, spec, { title = '', body = '', footer = '', image } = {}) {
130
+ const { Button } = await import('../Builders/index.js');
131
+ const params = buildPaymentParams(spec);
132
+ const btn = new Button(client);
133
+
134
+ if (title) btn.setTitle(title);
135
+ if (body) btn.setBody(body);
136
+ if (footer) btn.setFooter(footer);
137
+ if (image) btn.setImage(image);
138
+
139
+ btn.addButton('review_and_pay', params);
140
+
141
+ return btn.send(jid);
142
+ }
143
+
144
+ /** Go-name alias of `sendPayment()` (Go `MessageBuilder.Pay` + `Send`). */
145
+ export const Pay = sendPayment;
@@ -0,0 +1,3 @@
1
+ export function validateE164(raw: any): string;
2
+ export function jidToPhone(jid: any): string;
3
+ export function phoneToJid(phone: any, isGroup?: boolean): string;
@@ -0,0 +1,29 @@
1
+ // Vanz@Port (2.0.3) --- from kangwifi72/baileys 1.4.9 (validateE164, jidToPhone, phoneToJid), with fixes.
2
+ // NOT ported: donor normalizePhoneNumber (strips a leading 0 whenever length > 10 -- wrong for most locales, e.g. 08xx -> 62xx needs a country code).
3
+ /** Validate an E.164 number (optionally with '+'), returning it as '+<digits>'. Throws on invalid input. */
4
+ export const validateE164 = (raw) => {
5
+ if (typeof raw !== 'string') {
6
+ throw new TypeError(`Invalid E.164 number: ${String(raw)}`);
7
+ }
8
+ let num = raw.trim();
9
+ if (num.startsWith('+')) {
10
+ num = num.slice(1);
11
+ }
12
+ if (!/^[1-9][0-9]{6,14}$/.test(num)) {
13
+ throw new Error(`Invalid E.164 number: ${raw}`);
14
+ }
15
+ return `+${num}`;
16
+ };
17
+ /** '628123@s.whatsapp.net' -> '628123'; '' for anything that is not a plain phone-number JID (LID, group, bot...). */
18
+ export const jidToPhone = (jid) => {
19
+ const match = typeof jid === 'string' ? jid.match(/^(\d+)(?::\d+)?@(?:s\.whatsapp\.net|c\.us)$/) : null;
20
+ return match ? match[1] : '';
21
+ };
22
+ /** Digits of `phone` -> '<digits>@s.whatsapp.net' (or '@g.us' when isGroup). Throws when no digits are present. */
23
+ export const phoneToJid = (phone, isGroup = false) => {
24
+ const digits = String(phone ?? '').replace(/[^0-9]/g, '');
25
+ if (!digits) {
26
+ throw new Error(`Cannot build a JID from "${phone}"`);
27
+ }
28
+ return `${digits}@${isGroup ? 'g.us' : 's.whatsapp.net'}`;
29
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Manages pre-key operations with proper concurrency control
3
+ */
4
+ export class PreKeyManager {
5
+ constructor(store: any, logger: any);
6
+ store: any;
7
+ logger: any;
8
+ queues: Map<any, any>;
9
+ /**
10
+ * Get or create a queue for a specific key type
11
+ */
12
+ getQueue(keyType: any): any;
13
+ /**
14
+ * Process pre-key operations (updates and deletions)
15
+ */
16
+ processOperations(data: any, keyType: any, transactionCache: any, mutations: any, isInTransaction: any): Promise<any>;
17
+ /**
18
+ * Process deletions with validation
19
+ */
20
+ processDeletions(keyType: any, ids: any, transactionCache: any, mutations: any, isInTransaction: any): Promise<void>;
21
+ /**
22
+ * Validate and process pre-key deletions outside transactions
23
+ */
24
+ validateDeletions(data: any, keyType: any): Promise<any>;
25
+ }