@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,1042 @@
1
+ /**
2
+ * Worker-thread bootstrap for the WhatsApp WASM VoIP engine.
3
+ *
4
+ * Mirrors the browser Web-Worker environment (self/postMessage/babelHelpers/
5
+ * MessagePort) the WASM loader expects, then runs that loader inside a Node
6
+ * `worker_threads` Worker. Function-keyword shims are intentional — the
7
+ * loader inspects `.prototype` and `instanceof` on these.
8
+ *
9
+ * @author ShellTear
10
+ */
11
+ "use strict";
12
+ import { parentPort, workerData } from "worker_threads";
13
+ import * as path from "path";
14
+ import * as fs from "fs";
15
+ import * as crypto from "crypto";
16
+ import * as vm from "vm";
17
+ import { fileURLToPath } from "url";
18
+ import { createRequire } from "module";
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = path.dirname(__filename);
21
+ const _require = createRequire(import.meta.url);
22
+ const typedWorkerData = workerData;
23
+ if (typeof process === "undefined") {
24
+ global.process = {
25
+ cwd: () => __dirname || ".",
26
+ env: {},
27
+ platform: "linux",
28
+ version: "v18.0.0",
29
+ versions: {},
30
+ nextTick: (fn, ...args) => setImmediate(fn, ...args),
31
+ exit: (code) => {
32
+ throw new Error(`Process exit: ${code}`);
33
+ },
34
+ on: () => { },
35
+ off: () => { },
36
+ once: () => { },
37
+ emit: () => { },
38
+ };
39
+ }
40
+ else if (!process.cwd) {
41
+ process.cwd = () => __dirname || ".";
42
+ }
43
+ global.babelHelpers = {
44
+ extends: function (target) {
45
+ for (var i = 1; i < arguments.length; i++) {
46
+ var source = arguments[i];
47
+ if (source != null) {
48
+ for (var key in source) {
49
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
50
+ target[key] = source[key];
51
+ }
52
+ }
53
+ }
54
+ }
55
+ return target;
56
+ },
57
+ inheritsLoose: function (subClass, superClass) {
58
+ subClass.prototype = Object.create(superClass.prototype);
59
+ subClass.prototype.constructor = subClass;
60
+ subClass.__proto__ = superClass;
61
+ },
62
+ taggedTemplateLiteralLoose: function (strings, raw) {
63
+ if (!raw)
64
+ raw = strings.slice(0);
65
+ strings.raw = raw;
66
+ return strings;
67
+ },
68
+ asyncToGenerator: function (fn) {
69
+ return function () {
70
+ var self = this;
71
+ var args = arguments;
72
+ return new Promise(function (resolve, reject) {
73
+ var gen = fn.apply(self, args);
74
+ function step(key, arg) {
75
+ try {
76
+ var info = gen[key](arg);
77
+ var value = info.value;
78
+ }
79
+ catch (error) {
80
+ reject(error);
81
+ return;
82
+ }
83
+ if (info.done) {
84
+ resolve(value);
85
+ }
86
+ else {
87
+ Promise.resolve(value).then(function (val) { step("next", val); }, function (err) { step("throw", err); });
88
+ }
89
+ }
90
+ step("next");
91
+ });
92
+ };
93
+ },
94
+ createClass: function (Constructor, protoProps, staticProps) {
95
+ if (protoProps) {
96
+ for (var i = 0; i < protoProps.length; i++) {
97
+ var descriptor = protoProps[i];
98
+ descriptor.enumerable = descriptor.enumerable || false;
99
+ descriptor.configurable = true;
100
+ if ("value" in descriptor)
101
+ descriptor.writable = true;
102
+ Object.defineProperty(Constructor.prototype, descriptor.key, descriptor);
103
+ }
104
+ }
105
+ if (staticProps) {
106
+ for (var j = 0; j < staticProps.length; j++) {
107
+ var staticDescriptor = staticProps[j];
108
+ staticDescriptor.enumerable = staticDescriptor.enumerable || false;
109
+ staticDescriptor.configurable = true;
110
+ if ("value" in staticDescriptor)
111
+ staticDescriptor.writable = true;
112
+ Object.defineProperty(Constructor, staticDescriptor.key, staticDescriptor);
113
+ }
114
+ }
115
+ return Constructor;
116
+ },
117
+ classCallCheck: function (instance, Constructor) {
118
+ if (!(instance instanceof Constructor)) {
119
+ throw new TypeError("Cannot call a class as a function");
120
+ }
121
+ },
122
+ defineProperty: function (obj, key, value) {
123
+ if (key in obj) {
124
+ Object.defineProperty(obj, key, {
125
+ value: value,
126
+ enumerable: true,
127
+ configurable: true,
128
+ writable: true,
129
+ });
130
+ }
131
+ else {
132
+ obj[key] = value;
133
+ }
134
+ return obj;
135
+ },
136
+ objectSpread: function (target) {
137
+ for (var i = 1; i < arguments.length; i++) {
138
+ var source = arguments[i] != null ? arguments[i] : {};
139
+ var ownKeys = Object.keys(source);
140
+ if (typeof Object.getOwnPropertySymbols === "function") {
141
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
142
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
143
+ }));
144
+ }
145
+ ownKeys.forEach(function (key) {
146
+ target[key] = source[key];
147
+ });
148
+ }
149
+ return target;
150
+ },
151
+ objectSpread2: function (target) {
152
+ for (var i = 1; i < arguments.length; i++) {
153
+ var source = arguments[i] != null ? arguments[i] : {};
154
+ if (i % 2) {
155
+ Object.keys(source).forEach(function (key) {
156
+ target[key] = source[key];
157
+ });
158
+ }
159
+ else if (Object.getOwnPropertyDescriptors) {
160
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
161
+ }
162
+ else {
163
+ Object.keys(source).forEach(function (key) {
164
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
165
+ });
166
+ }
167
+ }
168
+ return target;
169
+ },
170
+ wrapNativeSuper: function (Class) {
171
+ var _cache = typeof Map === "function" ? new Map() : undefined;
172
+ function Wrapper() {
173
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
174
+ }
175
+ function _construct(Parent, args, Class) {
176
+ if (typeof Reflect !== "undefined" && Reflect.construct) {
177
+ return Reflect.construct(Parent, args, Class);
178
+ }
179
+ var a = [null];
180
+ a.push.apply(a, args);
181
+ var instance = new (Function.bind.apply(Parent, a))();
182
+ if (Class)
183
+ Object.setPrototypeOf(instance, Class.prototype);
184
+ return instance;
185
+ }
186
+ function _getPrototypeOf(o) {
187
+ return Object.getPrototypeOf || function (o) { return o.__proto__; };
188
+ }
189
+ if (typeof Class !== "function")
190
+ return Class;
191
+ if (_cache) {
192
+ if (_cache.has(Class))
193
+ return _cache.get(Class);
194
+ _cache.set(Class, Wrapper);
195
+ }
196
+ Wrapper.prototype = Object.create(Class.prototype, {
197
+ constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true },
198
+ });
199
+ return Object.setPrototypeOf(Wrapper, Class);
200
+ },
201
+ isNativeFunction: function (fn) {
202
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
203
+ },
204
+ getPrototypeOf: function (o) {
205
+ return Object.getPrototypeOf ? Object.getPrototypeOf(o) : o.__proto__;
206
+ },
207
+ setPrototypeOf: function (o, p) {
208
+ return Object.setPrototypeOf ? Object.setPrototypeOf(o, p) : ((o.__proto__ = p), o);
209
+ },
210
+ assertThisInitialized: function (self) {
211
+ if (self === void 0) {
212
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
213
+ }
214
+ return self;
215
+ },
216
+ possibleConstructorReturn: function (self, call) {
217
+ if (call && (typeof call === "object" || typeof call === "function"))
218
+ return call;
219
+ return global.babelHelpers.assertThisInitialized(self);
220
+ },
221
+ inherits: function (subClass, superClass) {
222
+ if (typeof superClass !== "function" && superClass !== null) {
223
+ throw new TypeError("Super expression must either be null or a function");
224
+ }
225
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
226
+ constructor: { value: subClass, writable: true, configurable: true },
227
+ });
228
+ if (superClass)
229
+ Object.setPrototypeOf(subClass, superClass);
230
+ },
231
+ construct: function (Parent, args, Class) {
232
+ if (typeof Reflect !== "undefined" && Reflect.construct) {
233
+ return Reflect.construct(Parent, args, Class);
234
+ }
235
+ var a = [null];
236
+ a.push.apply(a, args);
237
+ var Constructor = Function.bind.apply(Parent, a);
238
+ var instance = new Constructor();
239
+ if (Class)
240
+ Object.setPrototypeOf(instance, Class.prototype);
241
+ return instance;
242
+ },
243
+ isNativeReflectConstruct: function () {
244
+ if (typeof Reflect === "undefined" || !Reflect.construct)
245
+ return false;
246
+ try {
247
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () { }));
248
+ return true;
249
+ }
250
+ catch (e) {
251
+ return false;
252
+ }
253
+ },
254
+ };
255
+ if (typeof global.require === "undefined") {
256
+ global.require = _require;
257
+ }
258
+ const _originalProcess = global.process;
259
+ const _originalRequire = global.require;
260
+ const hideNodeEnv = () => {
261
+ try {
262
+ delete global.process;
263
+ }
264
+ catch (e) {
265
+ global.process = undefined;
266
+ }
267
+ try {
268
+ delete global.require;
269
+ }
270
+ catch (e) {
271
+ global.require = undefined;
272
+ }
273
+ };
274
+ const restoreNodeEnv = () => {
275
+ global.process = _originalProcess;
276
+ global.require = _originalRequire;
277
+ };
278
+ const __modules = {};
279
+ const __moduleFactories = {};
280
+ global.__d = function (name, deps, factory, flags) {
281
+ if (typeof deps === "function") {
282
+ factory = deps;
283
+ deps = [];
284
+ }
285
+ __moduleFactories[name] = { factory, deps, flags };
286
+ };
287
+ const importDefaultModule = (name) => {
288
+ const value = global.__r(name);
289
+ return value && value.__esModule ? value.default : value;
290
+ };
291
+ const importAllModule = (name) => {
292
+ const value = global.__r(name);
293
+ if (value == null) {
294
+ return { default: value };
295
+ }
296
+ if (value.__esModule) {
297
+ return value;
298
+ }
299
+ if (typeof value !== "object" && typeof value !== "function") {
300
+ return { default: value };
301
+ }
302
+ const namespace = {};
303
+ for (const key of Object.keys(value)) {
304
+ namespace[key] = value[key];
305
+ }
306
+ namespace.default = value;
307
+ return namespace;
308
+ };
309
+ global.__r = function (name) {
310
+ if (__modules[name])
311
+ return __modules[name].exports;
312
+ const moduleFactory = __moduleFactories[name];
313
+ if (!moduleFactory)
314
+ throw new Error(`Module "${name}" not found`);
315
+ const module = { exports: {} };
316
+ __modules[name] = module;
317
+ try {
318
+ moduleFactory.factory(global, global.__r, importDefaultModule, importAllModule, null, module, module.exports);
319
+ }
320
+ catch (e) {
321
+ delete __modules[name];
322
+ throw e;
323
+ }
324
+ return module.exports;
325
+ };
326
+ __modules["Promise"] = { exports: Promise };
327
+ const bxFunc = function (id) { return id; };
328
+ bxFunc.getURL = function (_id, _opts) { return ""; };
329
+ __modules["bx"] = { exports: bxFunc };
330
+ __modules["WorkerBundleResource"] = {
331
+ exports: { createDedicatedWebWorker: function () { return null; } },
332
+ };
333
+ __modules["WorkerClient"] = { exports: { init: function () { } } };
334
+ __modules["WorkerMessagePort"] = {
335
+ exports: { WorkerSyncedMessagePort: function () { } },
336
+ };
337
+ __modules["WAWebVoipWebWasmWorkerResource"] = { exports: {} };
338
+ if (typeof self === "undefined")
339
+ global.self = global;
340
+ global.self = global;
341
+ if (typeof global.window === "undefined")
342
+ global.window = global;
343
+ global.importScripts = function (...urls) {
344
+ for (const url of urls) {
345
+ try {
346
+ const code = fs.readFileSync(url, "utf8");
347
+ new vm.Script(code, { filename: url }).runInThisContext();
348
+ }
349
+ catch (e) { console.error(`[VoIP worker-bootstrap] importScripts failed for "${url}":`, e); }
350
+ }
351
+ };
352
+ if (typeof global.location === "undefined") {
353
+ global.location = {
354
+ href: __filename,
355
+ origin: "file://",
356
+ protocol: "file:",
357
+ host: "",
358
+ hostname: "",
359
+ port: "",
360
+ pathname: __filename,
361
+ search: "",
362
+ hash: "",
363
+ };
364
+ }
365
+ global.postMessage = function (data, transfer) {
366
+ if (parentPort)
367
+ parentPort.postMessage(data, transfer);
368
+ };
369
+ const messageListeners = [];
370
+ global.addEventListener = function (type, handler) {
371
+ if (type === "message") {
372
+ messageListeners.push(handler);
373
+ if (parentPort)
374
+ parentPort.on("message", (data) => {
375
+ handler({ data });
376
+ });
377
+ }
378
+ };
379
+ class SimpleHook {
380
+ listeners = [];
381
+ add = (fn) => { this.listeners.push(fn); return fn; };
382
+ remove = (fn) => { const idx = this.listeners.indexOf(fn); if (idx >= 0) {
383
+ this.listeners.splice(idx, 1);
384
+ return true;
385
+ } return false; };
386
+ clear = () => { this.listeners = []; };
387
+ call = (data) => { for (const fn of this.listeners) {
388
+ try {
389
+ fn(data);
390
+ }
391
+ catch { }
392
+ } };
393
+ }
394
+ class WorkerSyncedMessagePort {
395
+ $1 = {};
396
+ onUnhandledMessage = new SimpleHook();
397
+ onMessage = new SimpleHook();
398
+ onPostMessage = new SimpleHook();
399
+ onError = new SimpleHook();
400
+ $2;
401
+ name;
402
+ constructor(port, name) {
403
+ this.$2 = port;
404
+ this.name = name;
405
+ if (parentPort) {
406
+ parentPort.on("message", (data) => {
407
+ this.onMessageHandler(data);
408
+ });
409
+ }
410
+ }
411
+ onMessageHandler(data) {
412
+ try {
413
+ this.onMessage.call(data);
414
+ let handled = false;
415
+ const dispatch = (key) => {
416
+ if (!key)
417
+ return;
418
+ const hook = this.$1[key];
419
+ if (hook) {
420
+ handled = true;
421
+ hook.call(data);
422
+ }
423
+ };
424
+ dispatch(data.type);
425
+ if (data.cmd !== data.type)
426
+ dispatch(data.cmd);
427
+ if (!handled)
428
+ this.onUnhandledMessage.call(data);
429
+ }
430
+ catch (e) {
431
+ this.onError.call(e);
432
+ }
433
+ }
434
+ postMessage(data, transfer) {
435
+ this.onPostMessage.call(data);
436
+ if (parentPort) {
437
+ if (transfer)
438
+ parentPort.postMessage(data, transfer);
439
+ else
440
+ parentPort.postMessage(data);
441
+ }
442
+ }
443
+ addMessageListener(type, fn) {
444
+ let hook = this.$1[type];
445
+ if (!hook) {
446
+ hook = new SimpleHook();
447
+ this.$1[type] = hook;
448
+ }
449
+ return hook.add(fn);
450
+ }
451
+ removeMessageListener(type, fn) {
452
+ const hook = this.$1[type];
453
+ return !!hook && hook.remove(fn);
454
+ }
455
+ removeAllMessageListeners(type) {
456
+ const hook = this.$1[type];
457
+ if (hook)
458
+ hook.clear();
459
+ }
460
+ }
461
+ let WABinary = {
462
+ Binary: {
463
+ build: function (data) {
464
+ return {
465
+ readByteArrayView: function () {
466
+ if (data instanceof Uint8Array)
467
+ return data;
468
+ if (typeof data === "string")
469
+ return new TextEncoder().encode(data);
470
+ if (Array.isArray(data))
471
+ return new Uint8Array(data);
472
+ if (Buffer.isBuffer(data))
473
+ return new Uint8Array(data);
474
+ if (data instanceof ArrayBuffer)
475
+ return new Uint8Array(data);
476
+ if (ArrayBuffer.isView(data)) {
477
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
478
+ }
479
+ if (typeof data === "object" && data !== null && typeof data.length === "number") {
480
+ const arr = new Uint8Array(data.length);
481
+ for (let i = 0; i < data.length; i++)
482
+ arr[i] = data[i] || 0;
483
+ return arr;
484
+ }
485
+ return new Uint8Array(0);
486
+ },
487
+ };
488
+ },
489
+ },
490
+ };
491
+ let WACryptoHkdfSync = {
492
+ hkdf: function (key, salt, info, length) {
493
+ const prk = crypto
494
+ .createHmac("sha256", salt || Buffer.alloc(32))
495
+ .update(key)
496
+ .digest();
497
+ const n = Math.ceil(length / 32);
498
+ const okm = Buffer.alloc(n * 32);
499
+ let prev = Buffer.alloc(0);
500
+ for (let i = 0; i < n; i++) {
501
+ prev = crypto
502
+ .createHmac("sha256", prk)
503
+ .update(Buffer.concat([prev, info || Buffer.alloc(0), Buffer.from([i + 1])]))
504
+ .digest();
505
+ prev.copy(okm, i * 32);
506
+ }
507
+ return new Uint8Array(okm.slice(0, length));
508
+ },
509
+ };
510
+ class Sha256HMacBuilder {
511
+ hmac;
512
+ constructor(key) {
513
+ this.hmac = crypto.createHmac("sha256", key);
514
+ }
515
+ update(data) {
516
+ this.hmac.update(data);
517
+ return this;
518
+ }
519
+ finish() {
520
+ return new Uint8Array(this.hmac.digest());
521
+ }
522
+ }
523
+ const WACryptoSha256HmacBuilder = { Sha256HMacBuilder };
524
+ const WAWebVoipPersistentFS = {
525
+ getVoipPersistentDirectoryPath: function () {
526
+ return "/tmp/voip";
527
+ },
528
+ initPersistentFS: async function (_module) {
529
+ return Promise.resolve();
530
+ },
531
+ };
532
+ let WAWebVoipJsWorkerMessageHandler = {
533
+ handleJsWorkerMessage: function () { },
534
+ };
535
+ const getPreferredLoaderModuleNames = () => {
536
+ return [
537
+ typedWorkerData?.loaderModuleName,
538
+ "WAWebVoipWebWasmLoader",
539
+ "WAWebVoipWebWasmLoader.worker",
540
+ "WAWebVoipWebWasmLoader_ProdLab_internal.worker",
541
+ "WAWebVoipWebWasmLoader_ProdLabvideo_internal.worker",
542
+ ].filter((value, index, array) => !!value && array.indexOf(value) === index);
543
+ };
544
+ const resolveLoaderModule = () => {
545
+ for (const moduleName of getPreferredLoaderModuleNames()) {
546
+ try {
547
+ const loaderModule = global.__r(moduleName);
548
+ const resolved = loaderModule?.default ?? loaderModule;
549
+ if (typeof resolved === "function") {
550
+ return resolved;
551
+ }
552
+ }
553
+ catch (e) { console.error(`[VoIP worker-bootstrap] resolveLoaderModule failed for "${moduleName}":`, e); }
554
+ }
555
+ return null;
556
+ };
557
+ const nullthrows = (value) => {
558
+ if (value == null)
559
+ throw new Error("Got unexpected null or undefined");
560
+ return value;
561
+ };
562
+ const asyncToGeneratorRuntime = {
563
+ asyncToGenerator: function (fn) {
564
+ return function (...args) {
565
+ const gen = fn.apply(this, args);
566
+ return new Promise((resolve, reject) => {
567
+ function step(key, arg) {
568
+ try {
569
+ const info = gen[key](arg);
570
+ const value = info.value;
571
+ if (info.done)
572
+ resolve(value);
573
+ else
574
+ Promise.resolve(value).then((val) => step("next", val), (err) => step("throw", err));
575
+ }
576
+ catch (e) {
577
+ reject(e);
578
+ }
579
+ }
580
+ step("next", undefined);
581
+ });
582
+ };
583
+ },
584
+ };
585
+ const e = new WorkerSyncedMessagePort(global.self, "VoipWebWasmWorker");
586
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = {
587
+ onSignalingXmpp: function (n) {
588
+ e.postMessage({
589
+ type: "waWasmWorkerCompatibleCallback",
590
+ __name: "onSignalingXmpp",
591
+ peerJid: n.peerJid,
592
+ callId: n.callId,
593
+ xmlPayload: n.xmlPayload,
594
+ });
595
+ },
596
+ onCallEvent: function (n) {
597
+ e.postMessage({
598
+ type: "waWasmWorkerCompatibleCallback",
599
+ __name: "onCallEvent",
600
+ eventType: n.eventType,
601
+ userData: n.userData,
602
+ eventDataJson: n.eventDataJson,
603
+ });
604
+ },
605
+ sendDataToRelay: function (n) {
606
+ const t = n.data;
607
+ const r = n.len;
608
+ const o = n.ip;
609
+ const a = n.port;
610
+ e.postMessage({
611
+ type: "waWasmWorkerCompatibleCallback",
612
+ __name: "sendDataToRelay",
613
+ data: t,
614
+ len: r,
615
+ ip: o,
616
+ port: a,
617
+ });
618
+ return r || (t ? t.length || t.byteLength || 0 : 0);
619
+ },
620
+ loggingCallback: function (n) {
621
+ try {
622
+ e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "loggingCallback" }, n));
623
+ }
624
+ catch (err) { console.error("[VoIP worker-bootstrap] loggingCallback postMessage failed:", err); }
625
+ },
626
+ initCaptureDriverJS: function (n) {
627
+ e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "initCaptureDriverJS" }, n));
628
+ return 0;
629
+ },
630
+ startCaptureJS: function () {
631
+ e.postMessage({
632
+ type: "waWasmWorkerCompatibleCallback",
633
+ __name: "startCaptureJS",
634
+ });
635
+ return 0;
636
+ },
637
+ stopCaptureJS: function () {
638
+ e.postMessage({
639
+ type: "waWasmWorkerCompatibleCallback",
640
+ __name: "stopCaptureJS",
641
+ });
642
+ return 0;
643
+ },
644
+ initPlaybackDriverJS: function (n) {
645
+ e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "initPlaybackDriverJS" }, n));
646
+ return 0;
647
+ },
648
+ startPlaybackJS: function () {
649
+ e.postMessage({
650
+ type: "waWasmWorkerCompatibleCallback",
651
+ __name: "startPlaybackJS",
652
+ });
653
+ return 0;
654
+ },
655
+ stopPlaybackJS: function () {
656
+ e.postMessage({
657
+ type: "waWasmWorkerCompatibleCallback",
658
+ __name: "stopPlaybackJS",
659
+ });
660
+ return 0;
661
+ },
662
+ startVideoCaptureJS: function (n) {
663
+ e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "startVideoCaptureJS" }, n));
664
+ return 0;
665
+ },
666
+ stopVideoCaptureJS: function () {
667
+ e.postMessage({
668
+ type: "waWasmWorkerCompatibleCallback",
669
+ __name: "stopVideoCaptureJS",
670
+ });
671
+ return 0;
672
+ },
673
+ onVideoFrameWasmToJs: function (n) {
674
+ e.postMessage({
675
+ type: "waWasmWorkerCompatibleCallback",
676
+ __name: "onVideoFrameWasmToJs",
677
+ userJid: n.userJid,
678
+ frameBuffer: n.frameBuffer,
679
+ width: n.width,
680
+ height: n.height,
681
+ orientation: n.orientation,
682
+ format: n.format,
683
+ timestamp: n.timestamp,
684
+ isKeyFrame: n.isKeyFrame,
685
+ }, [n.frameBuffer]);
686
+ },
687
+ startDesktopCaptureJS: function (n) {
688
+ e.postMessage(Object.assign({ type: "waWasmWorkerCompatibleCallback", __name: "startDesktopCaptureJS" }, n));
689
+ return 0;
690
+ },
691
+ stopDesktopCaptureJS: function () {
692
+ e.postMessage({
693
+ type: "waWasmWorkerCompatibleCallback",
694
+ __name: "stopDesktopCaptureJS",
695
+ });
696
+ return 0;
697
+ },
698
+ cryptoHkdfExtractWithSaltAndExpand: function (t) {
699
+ const i = new Uint8Array(t.key_);
700
+ const l = t.salt_ ? new Uint8Array(t.salt_) : undefined;
701
+ const s = WABinary.Binary.build(t.info_).readByteArrayView();
702
+ return WACryptoHkdfSync.hkdf(i, l, s, t.length);
703
+ },
704
+ hmacSha256KeyGenerator: function (t) {
705
+ const r = new Uint8Array(t.data_);
706
+ const a = new Uint8Array(t.key_);
707
+ return new Sha256HMacBuilder(a).update(r).finish();
708
+ },
709
+ isParticipantKnownContact: function (_t) {
710
+ return false;
711
+ },
712
+ getPersistentDirectoryPath: function () {
713
+ return WAWebVoipPersistentFS.getVoipPersistentDirectoryPath();
714
+ },
715
+ getBrowserAudioProcessingStatus: function () {
716
+ return 7;
717
+ },
718
+ getBweModelPath: function () {
719
+ return null;
720
+ },
721
+ videoFrameConsumed: function () { },
722
+ dataChannelStateCallback: function () { },
723
+ };
724
+ let wasmLoader = null;
725
+ if (typedWorkerData && (typedWorkerData.loaderCode || typedWorkerData.workerModulesCode)) {
726
+ try {
727
+ const modulePrelude = "var __d = global.__d, __r = global.__r;\n";
728
+ const savedCallbacks = global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
729
+ if (typedWorkerData.workerModulesCode) {
730
+ const workerScript = new vm.Script(modulePrelude + typedWorkerData.workerModulesCode, {
731
+ filename: "workerModulesCode-SEM22icu2S7.js",
732
+ });
733
+ workerScript.runInThisContext();
734
+ }
735
+ if (typedWorkerData.loaderCode) {
736
+ const loaderScript = new vm.Script(modulePrelude + typedWorkerData.loaderCode, {
737
+ filename: "loaderCode-1eFv_3F3hOU.js",
738
+ });
739
+ loaderScript.runInThisContext();
740
+ }
741
+ if (!global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks?.loggingCallback) {
742
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = savedCallbacks;
743
+ if (global.self !== global.self) {
744
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = savedCallbacks;
745
+ }
746
+ }
747
+ if (global.self !== global.self) {
748
+ if (global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
749
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks =
750
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
751
+ }
752
+ else if (global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
753
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks =
754
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
755
+ }
756
+ global.self = global.self;
757
+ }
758
+ wasmLoader = resolveLoaderModule();
759
+ try {
760
+ const jsWorkerModule = global.__r("WAWebVoipJsWorkerMessageHandler");
761
+ if (jsWorkerModule) {
762
+ WAWebVoipJsWorkerMessageHandler = jsWorkerModule.default ?? jsWorkerModule;
763
+ }
764
+ }
765
+ catch (e) { console.error("[VoIP worker-bootstrap] WAWebVoipJsWorkerMessageHandler resolution failed:", e); }
766
+ }
767
+ catch (e) { console.error("[VoIP worker-bootstrap] loaderCode block failed:", e); }
768
+ }
769
+ if (!wasmLoader) {
770
+ const resourcesPath = typedWorkerData?.resourcesPath || path.join(__dirname, "wasm-resources");
771
+ const rsrcPath = path.join(resourcesPath, "loader.js");
772
+ if (fs.existsSync(rsrcPath)) {
773
+ try {
774
+ const loaderCode = fs.readFileSync(rsrcPath, "utf8");
775
+ const savedCallbacks = global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
776
+ const script = new vm.Script(loaderCode, { filename: rsrcPath });
777
+ script.runInThisContext();
778
+ if (!global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks?.loggingCallback) {
779
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks = savedCallbacks;
780
+ }
781
+ wasmLoader = resolveLoaderModule();
782
+ }
783
+ catch (e) { console.error(`[VoIP worker-bootstrap] failed to run loader.js from "${rsrcPath}":`, e); }
784
+ }
785
+ }
786
+ let s = {};
787
+ let u = false;
788
+ let _ = null;
789
+ let jsWorkerRawVideoFramePtr = 0;
790
+ let jsWorkerRawVideoFrameSize = 0;
791
+ const c = (condition, msg) => {
792
+ if (!condition)
793
+ throw "Assertion failed: " + msg;
794
+ };
795
+ const d = (..._args) => { };
796
+ const m = (...args) => {
797
+ const text = args.join(" ");
798
+ global.postMessage({
799
+ cmd: "alert",
800
+ text: text,
801
+ threadId: s._pthread_self ? s._pthread_self() : undefined,
802
+ });
803
+ };
804
+ const p = d;
805
+ global.self.alert = m;
806
+ s.instantiateWasm = function (imports, successCallback) {
807
+ const wasmModule = nullthrows(s.wasmModule);
808
+ s.wasmModule = null;
809
+ const instance = new WebAssembly.Instance(wasmModule, imports);
810
+ return successCallback(instance);
811
+ };
812
+ global.self.onunhandledrejection = function (event) {
813
+ throw event.reason ?? event;
814
+ };
815
+ const getActiveWasmModule = () => {
816
+ return _ || global.self.__waModule || s;
817
+ };
818
+ const releaseJsWorkerRawVideoFrameBuffer = (moduleRef) => {
819
+ if (jsWorkerRawVideoFramePtr && moduleRef && typeof moduleRef._free === "function") {
820
+ try {
821
+ moduleRef._free(jsWorkerRawVideoFramePtr);
822
+ }
823
+ catch { }
824
+ }
825
+ jsWorkerRawVideoFramePtr = 0;
826
+ jsWorkerRawVideoFrameSize = 0;
827
+ };
828
+ const handleRawVideoFrameOnJsWorker = (msg) => {
829
+ const moduleRef = getActiveWasmModule();
830
+ const sendFrameFn = msg?.useDesktopCapture
831
+ ? moduleRef?.onDesktopCaptureDataFromJs
832
+ : moduleRef?.onVideoDataFromJs;
833
+ const frameBuffer = msg?.frameBuffer;
834
+ const width = Math.max(0, Math.trunc(Number(msg?.width || 0)));
835
+ const height = Math.max(0, Math.trunc(Number(msg?.height || 0)));
836
+ const fps = Math.max(1, Math.trunc(Number(msg?.fps || 0)) || 1);
837
+ const orientation = Math.trunc(Number(msg?.orientation || 0));
838
+ const format = Math.trunc(Number(msg?.format || 0));
839
+ const timestamp = Math.trunc(Number(msg?.timestamp || 0));
840
+ if (!moduleRef ||
841
+ typeof moduleRef._malloc !== "function" ||
842
+ typeof moduleRef._free !== "function" ||
843
+ typeof sendFrameFn !== "function" ||
844
+ !(frameBuffer instanceof ArrayBuffer || ArrayBuffer.isView(frameBuffer))) {
845
+ return;
846
+ }
847
+ const bytes = ArrayBuffer.isView(frameBuffer)
848
+ ? new Uint8Array(frameBuffer.buffer, frameBuffer.byteOffset, frameBuffer.byteLength)
849
+ : new Uint8Array(frameBuffer);
850
+ if (bytes.byteLength === 0 || width <= 0 || height <= 0) {
851
+ return;
852
+ }
853
+ if (!jsWorkerRawVideoFramePtr || jsWorkerRawVideoFrameSize < bytes.byteLength) {
854
+ releaseJsWorkerRawVideoFrameBuffer(moduleRef);
855
+ jsWorkerRawVideoFramePtr = Number(moduleRef._malloc(bytes.byteLength)) || 0;
856
+ jsWorkerRawVideoFrameSize = jsWorkerRawVideoFramePtr ? bytes.byteLength : 0;
857
+ }
858
+ if (!jsWorkerRawVideoFramePtr || jsWorkerRawVideoFrameSize < bytes.byteLength) {
859
+ return;
860
+ }
861
+ moduleRef.GROWABLE_HEAP_U8().set(bytes, jsWorkerRawVideoFramePtr);
862
+ try {
863
+ sendFrameFn.call(moduleRef, jsWorkerRawVideoFramePtr, bytes.byteLength, width, height, fps, format, orientation);
864
+ }
865
+ catch (error) {
866
+ if (error?.name !== "BindingError") {
867
+ throw error;
868
+ }
869
+ try {
870
+ sendFrameFn.call(moduleRef, jsWorkerRawVideoFramePtr, bytes.byteLength, width, height, fps, format);
871
+ }
872
+ catch (legacyError) {
873
+ if (legacyError?.name !== "BindingError") {
874
+ throw legacyError;
875
+ }
876
+ sendFrameFn.call(moduleRef, jsWorkerRawVideoFramePtr, bytes.byteLength, width, height, orientation, format, timestamp);
877
+ }
878
+ }
879
+ };
880
+ function f(t) {
881
+ try {
882
+ if (t.cmd === "load") {
883
+ const wasmModule = t.wasmModule;
884
+ const wasmMemory = t.wasmMemory;
885
+ const workerID = t.workerID;
886
+ const handlers = t.handlers;
887
+ const pendingMessages = [];
888
+ function g(msg) {
889
+ pendingMessages.push(msg);
890
+ }
891
+ e.removeMessageListener("cmd", f);
892
+ e.addMessageListener("cmd", g);
893
+ global.self.startWorker = function (module) {
894
+ global.self.__waModule = module;
895
+ global.__waModule = module;
896
+ s = module;
897
+ e.postMessage({ type: "cmd", cmd: "loaded" });
898
+ for (const msg of pendingMessages)
899
+ f(msg);
900
+ e.removeMessageListener("cmd", g);
901
+ e.addMessageListener("cmd", f);
902
+ };
903
+ s.wasmModule = wasmModule;
904
+ function h(name) {
905
+ s[name] = function () {
906
+ const args = Array.from(arguments);
907
+ e.postMessage({
908
+ type: "cmd",
909
+ cmd: "callHandler",
910
+ callHandler: { handler: name, args: args },
911
+ });
912
+ };
913
+ }
914
+ for (const handler of handlers)
915
+ h(handler);
916
+ s.wasmMemory = wasmMemory;
917
+ s.buffer = s.wasmMemory.buffer;
918
+ s.workerID = workerID;
919
+ s.ENVIRONMENT_IS_PTHREAD = true;
920
+ if (!s.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
921
+ s.WhatsAppVoipWasmWorkerCompatibleCallbacks =
922
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
923
+ }
924
+ if (wasmLoader) {
925
+ hideNodeEnv();
926
+ wasmLoader(s).then(asyncToGeneratorRuntime.asyncToGenerator(function* (module) {
927
+ if (!module.WhatsAppVoipWasmWorkerCompatibleCallbacks) {
928
+ module.WhatsAppVoipWasmWorkerCompatibleCallbacks =
929
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
930
+ }
931
+ if (!s.WhatsAppVoipWasmWorkerCompatibleCallbacks?.loggingCallback) {
932
+ s.WhatsAppVoipWasmWorkerCompatibleCallbacks =
933
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks;
934
+ }
935
+ _ = module;
936
+ try {
937
+ yield WAWebVoipPersistentFS.initPersistentFS(_);
938
+ }
939
+ catch (err) { console.error("[VoIP worker-bootstrap] initPersistentFS failed:", err); }
940
+ }));
941
+ }
942
+ else {
943
+ e.postMessage({ type: "cmd", cmd: "loaded" });
944
+ }
945
+ }
946
+ else if (t.cmd === "run") {
947
+ const pthread_ptr = t.pthread_ptr;
948
+ if (s.__emscripten_thread_init)
949
+ s.__emscripten_thread_init(pthread_ptr, 0, 0, 1);
950
+ if (s.__emscripten_thread_mailbox_await)
951
+ s.__emscripten_thread_mailbox_await(pthread_ptr);
952
+ c(!!pthread_ptr, "pthread_ptr is required in event " + t.cmd);
953
+ if (s.establishStackSpace)
954
+ s.establishStackSpace();
955
+ if (s.PThread)
956
+ s.PThread.receiveObjectTransfer(t);
957
+ if (s.PThread)
958
+ s.PThread.threadInitTLS();
959
+ if (!u) {
960
+ if (s.__embind_initialize_bindings)
961
+ s.__embind_initialize_bindings();
962
+ u = true;
963
+ }
964
+ try {
965
+ if (s.invokeEntryPoint)
966
+ s.invokeEntryPoint(t.start_routine, t.arg);
967
+ }
968
+ catch (err) {
969
+ if (err !== "unwind")
970
+ throw err;
971
+ }
972
+ }
973
+ else if (t.cmd === "cancel") {
974
+ if (s._pthread_self && s._pthread_self()) {
975
+ if (s.__emscripten_thread_exit)
976
+ s.__emscripten_thread_exit(-1);
977
+ }
978
+ }
979
+ else if (t.target !== "setimmediate") {
980
+ if (t.cmd === "checkMailbox") {
981
+ if (u && s.checkMailbox)
982
+ s.checkMailbox();
983
+ }
984
+ else if (t.cmd === "jsWorkerCmd") {
985
+ return;
986
+ }
987
+ else if (t.cmd) {
988
+ p("worker.js received unknown command " + t.cmd);
989
+ p(t);
990
+ }
991
+ }
992
+ }
993
+ catch (err) {
994
+ p("worker.js onmessage() captured an uncaught exception: " + err);
995
+ if (err?.stack)
996
+ p(err.stack);
997
+ if (s.__emscripten_thread_crashed)
998
+ s.__emscripten_thread_crashed();
999
+ throw err;
1000
+ }
1001
+ }
1002
+ e.addMessageListener("cmd", f);
1003
+ e.addMessageListener("jsWorkerCmd", function (msg) {
1004
+ try {
1005
+ if (msg?.jsWorkerCmd === "pushRawVideoFrame") {
1006
+ return handleRawVideoFrameOnJsWorker(msg);
1007
+ }
1008
+ if (msg?.jsWorkerCmd === "releaseRawVideoFrameBuffer") {
1009
+ return releaseJsWorkerRawVideoFrameBuffer(getActiveWasmModule());
1010
+ }
1011
+ return WAWebVoipJsWorkerMessageHandler.handleJsWorkerMessage(_, msg);
1012
+ }
1013
+ catch (err) {
1014
+ throw err;
1015
+ }
1016
+ });
1017
+ e.addMessageListener("waWasmWorkerCompatibleCallback", function (msg) {
1018
+ const callbackName = msg.__name;
1019
+ if (!callbackName)
1020
+ return;
1021
+ if (!global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks)
1022
+ return;
1023
+ if (typeof global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks[callbackName] !== "function")
1024
+ return;
1025
+ try {
1026
+ if (["startCaptureJS", "startPlaybackJS", "stopCaptureJS", "stopPlaybackJS"].includes(callbackName)) {
1027
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks[callbackName]();
1028
+ }
1029
+ else {
1030
+ const args = {};
1031
+ for (const key in msg) {
1032
+ if (key !== "type" && key !== "__name" && !key.startsWith("__"))
1033
+ args[key] = msg[key];
1034
+ }
1035
+ global.self.WhatsAppVoipWasmWorkerCompatibleCallbacks[callbackName](args);
1036
+ }
1037
+ }
1038
+ catch (err) { console.error("[VoIP worker-bootstrap] message handler failed:", err); }
1039
+ });
1040
+ if (parentPort) {
1041
+ parentPort.postMessage({ type: "worker_ready" });
1042
+ }