zapo-js 1.0.0 → 1.1.0

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 (410) hide show
  1. package/README.md +1 -1
  2. package/dist/{types/appstate → appstate}/crypto/WaAppStateCrypto.d.ts +1 -1
  3. package/dist/appstate/crypto/WaAppStateCrypto.js +1 -1
  4. package/dist/appstate/parsers/encoding.js +1 -1
  5. package/dist/{types/appstate → appstate}/parsers/response-parser.d.ts +1 -1
  6. package/dist/appstate/parsers/response-parser.js +1 -1
  7. package/dist/{types/appstate → appstate}/sync/WaAppStateSyncClient.d.ts +1 -1
  8. package/dist/appstate/sync/WaAppStateSyncClient.js +2 -2
  9. package/dist/{types/appstate → appstate}/types.d.ts +1 -1
  10. package/dist/{types/appstate → appstate}/utils.d.ts +1 -1
  11. package/dist/{types/appstate-spec.d.ts → appstate-spec.d.ts} +1 -1
  12. package/dist/appstate-spec.js +1 -1
  13. package/dist/auth/credentials-flow.js +2 -2
  14. package/dist/auth/pairing/WaPairingFlow.js +2 -2
  15. package/dist/auth/pairing/pairing-code-crypto.js +1 -1
  16. package/dist/{types/auth → auth}/types.d.ts +1 -1
  17. package/dist/client/WaClient.js +2 -2
  18. package/dist/client/WaClientFactory.js +3 -1
  19. package/dist/{types/client → client}/coordinators/WaAppStateMutationCoordinator.d.ts +2 -2
  20. package/dist/client/coordinators/WaAppStateMutationCoordinator.js +2 -2
  21. package/dist/{types/client → client}/coordinators/WaBotCoordinator.d.ts +1 -1
  22. package/dist/client/coordinators/WaBotCoordinator.js +1 -1
  23. package/dist/{types/client → client}/coordinators/WaBroadcastListCoordinator.d.ts +1 -1
  24. package/dist/{types/client → client}/coordinators/WaMessageCoordinator.d.ts +1 -1
  25. package/dist/client/coordinators/WaMessageCoordinator.js +3 -19
  26. package/dist/{types/client → client}/coordinators/WaMessageDispatchCoordinator.d.ts +1 -1
  27. package/dist/client/coordinators/WaMessageDispatchCoordinator.js +5 -4
  28. package/dist/client/coordinators/WaRetryCoordinator.js +1 -1
  29. package/dist/{types/client → client}/coordinators/WaStatusCoordinator.d.ts +1 -1
  30. package/dist/client/coordinators/WaStatusCoordinator.js +1 -1
  31. package/dist/client/coordinators/WaStreamControlCoordinator.js +2 -3
  32. package/dist/client/events/appstate-mutation.js +1 -1
  33. package/dist/client/events/business.js +1 -1
  34. package/dist/client/events/incoming.js +3 -1
  35. package/dist/client/events/receipt.d.ts +30 -0
  36. package/dist/client/events/receipt.js +32 -0
  37. package/dist/{types/client → client}/media.d.ts +59 -2
  38. package/dist/client/media.js +62 -2
  39. package/dist/client/messaging/group-metadata.js +20 -9
  40. package/dist/{types/client → client}/messaging/key-protocol.d.ts +1 -1
  41. package/dist/client/messaging/key-protocol.js +1 -1
  42. package/dist/client/messaging/link-preview.js +1 -1
  43. package/dist/client/messaging/messages.js +2 -2
  44. package/dist/{types/client → client}/newsletter/admin.d.ts +1 -1
  45. package/dist/client/newsletter/content.js +1 -1
  46. package/dist/{types/client → client}/newsletter/mex.d.ts +1 -1
  47. package/dist/{types/client → client}/newsletter/parse.d.ts +1 -1
  48. package/dist/{types/client → client}/newsletter/types.d.ts +1 -1
  49. package/dist/{types/client → client}/persistence/history-sync.d.ts +1 -1
  50. package/dist/client/persistence/history-sync.js +1 -1
  51. package/dist/client/persistence/mailbox.js +1 -1
  52. package/dist/{types/client → client}/types.d.ts +9 -2
  53. package/dist/esm/appstate-spec.js +2 -2
  54. package/dist/esm/client/WaClient.js +1 -1
  55. package/dist/esm/client/WaClientFactory.js +3 -1
  56. package/dist/esm/client/coordinators/WaMessageCoordinator.js +2 -18
  57. package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +2 -1
  58. package/dist/esm/client/coordinators/WaStreamControlCoordinator.js +2 -3
  59. package/dist/esm/client/events/incoming.js +3 -1
  60. package/dist/esm/client/events/receipt.js +31 -0
  61. package/dist/esm/client/media.js +61 -2
  62. package/dist/esm/client/messaging/group-metadata.js +20 -9
  63. package/dist/esm/index.js +2 -0
  64. package/dist/esm/message/context-info.js +16 -3
  65. package/dist/esm/message/encode/media-payload.js +18 -0
  66. package/dist/esm/mex.js +1 -1
  67. package/dist/esm/protocol/message.js +2 -1
  68. package/dist/esm/signal/api/SignalDeviceSyncApi.js +3 -1
  69. package/dist/esm/signal/registration/utils.js +3 -2
  70. package/dist/esm/store/locks/pre-key.lock.js +4 -1
  71. package/dist/esm/version-spec.js +1 -1
  72. package/dist/{types/index.d.ts → index.d.ts} +10 -7
  73. package/dist/index.js +10 -6
  74. package/dist/{types/message → message}/addons/link-preview/builder.d.ts +1 -1
  75. package/dist/message/addons/link-preview/fetcher.js +1 -1
  76. package/dist/{types/message → message}/addons/link-preview/types.d.ts +1 -1
  77. package/dist/{types/message → message}/context-info.d.ts +10 -1
  78. package/dist/message/context-info.js +15 -2
  79. package/dist/{types/message → message}/crypto/addon-crypto.d.ts +1 -1
  80. package/dist/message/crypto/addon-crypto.js +2 -2
  81. package/dist/{types/message → message}/crypto/icdc.d.ts +1 -1
  82. package/dist/message/crypto/icdc.js +1 -1
  83. package/dist/{types/message → message}/crypto/reporting-token.d.ts +1 -1
  84. package/dist/message/crypto/reporting-token.js +2 -2
  85. package/dist/{types/message → message}/crypto/use-case-secret.d.ts +1 -1
  86. package/dist/message/crypto/use-case-secret.js +1 -1
  87. package/dist/{types/message → message}/encode/content.d.ts +1 -1
  88. package/dist/message/encode/content.js +1 -1
  89. package/dist/{types/message → message}/encode/device-sent.d.ts +1 -1
  90. package/dist/message/encode/media-payload.d.ts +43 -0
  91. package/dist/message/encode/media-payload.js +18 -0
  92. package/dist/message/encode/padding.js +1 -1
  93. package/dist/{types/message → message}/kinds/bot.d.ts +1 -1
  94. package/dist/message/kinds/bot.js +2 -2
  95. package/dist/message/kinds/newsletter.js +1 -1
  96. package/dist/{types/message → message}/kinds/sticker-pack.d.ts +1 -1
  97. package/dist/{types/message → message}/primitives/incoming.d.ts +1 -1
  98. package/dist/message/primitives/incoming.js +1 -1
  99. package/dist/{types/message → message}/primitives/peer-data-operation.d.ts +1 -1
  100. package/dist/message/primitives/peer-data-operation.js +1 -1
  101. package/dist/{types/message → message}/types.d.ts +1 -1
  102. package/dist/{types/protocol → protocol}/bot.d.ts +1 -1
  103. package/dist/protocol/bot.js +1 -1
  104. package/dist/{types/protocol → protocol}/message.d.ts +1 -0
  105. package/dist/protocol/message.js +2 -1
  106. package/dist/retry/replay.js +1 -1
  107. package/dist/signal/api/SignalDeviceSyncApi.js +3 -1
  108. package/dist/signal/api/SignalDigestSyncApi.js +1 -1
  109. package/dist/signal/attestation/WaAdvSignature.js +1 -1
  110. package/dist/signal/group/SenderKeyChain.js +1 -1
  111. package/dist/signal/group/SenderKeyCodec.js +2 -2
  112. package/dist/{types/signal → signal}/group/SenderKeyManager.d.ts +1 -1
  113. package/dist/signal/group/SenderKeyManager.js +2 -2
  114. package/dist/signal/group/encoding.js +1 -1
  115. package/dist/signal/registration/keygen.js +1 -1
  116. package/dist/signal/registration/utils.js +3 -2
  117. package/dist/signal/session/SignalProtocol.js +1 -1
  118. package/dist/signal/session/SignalRatchet.js +2 -2
  119. package/dist/signal/session/SignalSerializer.js +2 -2
  120. package/dist/signal/session/SignalSession.js +1 -1
  121. package/dist/{types/signal → signal}/session/encoding.d.ts +1 -1
  122. package/dist/signal/session/encoding.js +1 -1
  123. package/dist/{types/signal → signal}/types.d.ts +1 -1
  124. package/dist/store/locks/pre-key.lock.js +4 -1
  125. package/dist/transport/node/builders/global.js +1 -1
  126. package/dist/transport/node/helpers.js +1 -1
  127. package/dist/{types/transport → transport}/node/mex/client.d.ts +1 -1
  128. package/dist/transport/node/mex/client.js +1 -1
  129. package/dist/transport/noise/WaClientPayload.js +2 -2
  130. package/dist/{types/transport → transport}/noise/WaMobileClientPayload.d.ts +1 -1
  131. package/dist/transport/noise/WaMobileClientPayload.js +1 -1
  132. package/dist/transport/noise/WaNoiseCert.js +2 -2
  133. package/dist/transport/noise/WaNoiseHandshake.js +1 -1
  134. package/dist/transport/noise/WaNoiseSession.js +2 -2
  135. package/dist/transport/noise/WaNoiseSocket.js +1 -1
  136. package/dist/{types/transport → transport}/noise/types.d.ts +1 -1
  137. package/package.json +20 -16
  138. package/dist/types/client/events/receipt.d.ts +0 -14
  139. package/dist/types/message/encode/media-payload.d.ts +0 -12
  140. /package/dist/{types/appstate → appstate}/constants.d.ts +0 -0
  141. /package/dist/{types/appstate → appstate}/index.d.ts +0 -0
  142. /package/dist/{types/appstate → appstate}/parsers/encoding.d.ts +0 -0
  143. /package/dist/{types/auth → auth}/WaAuthClient.d.ts +0 -0
  144. /package/dist/{types/auth → auth}/credentials-flow.d.ts +0 -0
  145. /package/dist/{types/auth → auth}/index.d.ts +0 -0
  146. /package/dist/{types/auth → auth}/pairing/WaPairingFlow.d.ts +0 -0
  147. /package/dist/{types/auth → auth}/pairing/WaQrFlow.d.ts +0 -0
  148. /package/dist/{types/auth → auth}/pairing/pairing-code-crypto.d.ts +0 -0
  149. /package/dist/{types/client → client}/WaClient.d.ts +0 -0
  150. /package/dist/{types/client → client}/WaClientFactory.d.ts +0 -0
  151. /package/dist/{types/client → client}/connection/WaConnectionManager.d.ts +0 -0
  152. /package/dist/{types/client → client}/connection/WaReceiptQueue.d.ts +0 -0
  153. /package/dist/{types/client → client}/coordinators/WaAbPropsCoordinator.d.ts +0 -0
  154. /package/dist/{types/client → client}/coordinators/WaBusinessCoordinator.d.ts +0 -0
  155. /package/dist/{types/client → client}/coordinators/WaEmailCoordinator.d.ts +0 -0
  156. /package/dist/{types/client → client}/coordinators/WaGroupCoordinator.d.ts +0 -0
  157. /package/dist/{types/client → client}/coordinators/WaIncomingNodeCoordinator.d.ts +0 -0
  158. /package/dist/{types/client → client}/coordinators/WaLowLevelCoordinator.d.ts +0 -0
  159. /package/dist/{types/client → client}/coordinators/WaNewsletterCoordinator.d.ts +0 -0
  160. /package/dist/{types/client → client}/coordinators/WaOfflineResumeCoordinator.d.ts +0 -0
  161. /package/dist/{types/client → client}/coordinators/WaPassiveTasksCoordinator.d.ts +0 -0
  162. /package/dist/{types/client → client}/coordinators/WaPresenceCoordinator.d.ts +0 -0
  163. /package/dist/{types/client → client}/coordinators/WaPrivacyCoordinator.d.ts +0 -0
  164. /package/dist/{types/client → client}/coordinators/WaProfileCoordinator.d.ts +0 -0
  165. /package/dist/{types/client → client}/coordinators/WaRetryCoordinator.d.ts +0 -0
  166. /package/dist/{types/client → client}/coordinators/WaStreamControlCoordinator.d.ts +0 -0
  167. /package/dist/{types/client → client}/coordinators/WaTrustedContactTokenCoordinator.d.ts +0 -0
  168. /package/dist/{types/client → client}/events/abprops.d.ts +0 -0
  169. /package/dist/{types/client → client}/events/appstate-mutation.d.ts +0 -0
  170. /package/dist/{types/client → client}/events/business.d.ts +0 -0
  171. /package/dist/{types/client → client}/events/call.d.ts +0 -0
  172. /package/dist/{types/client → client}/events/chatstate.d.ts +0 -0
  173. /package/dist/{types/client → client}/events/devices.d.ts +0 -0
  174. /package/dist/{types/client → client}/events/dirty.d.ts +0 -0
  175. /package/dist/{types/client → client}/events/group.d.ts +0 -0
  176. /package/dist/{types/client → client}/events/identity.d.ts +0 -0
  177. /package/dist/{types/client → client}/events/incoming.d.ts +0 -0
  178. /package/dist/{types/client → client}/events/mex-notification.d.ts +0 -0
  179. /package/dist/{types/client → client}/events/picture.d.ts +0 -0
  180. /package/dist/{types/client → client}/events/presence.d.ts +0 -0
  181. /package/dist/{types/client → client}/events/privacy-token.d.ts +0 -0
  182. /package/dist/{types/client → client}/events/registration.d.ts +0 -0
  183. /package/dist/{types/client → client}/index.d.ts +0 -0
  184. /package/dist/{types/client → client}/messaging/fanout.d.ts +0 -0
  185. /package/dist/{types/client → client}/messaging/group-metadata.d.ts +0 -0
  186. /package/dist/{types/client → client}/messaging/ignore-key.d.ts +0 -0
  187. /package/dist/{types/client → client}/messaging/link-preview.d.ts +0 -0
  188. /package/dist/{types/client → client}/messaging/messages.d.ts +0 -0
  189. /package/dist/{types/client → client}/newsletter/content.d.ts +0 -0
  190. /package/dist/{types/client → client}/newsletter/discovery.d.ts +0 -0
  191. /package/dist/{types/client → client}/newsletter/messaging.d.ts +0 -0
  192. /package/dist/{types/client → client}/persistence/WriteBehindPersistence.d.ts +0 -0
  193. /package/dist/{types/client → client}/persistence/mailbox.d.ts +0 -0
  194. /package/dist/{types/client → client}/tokens/cs-token.d.ts +0 -0
  195. /package/dist/{types/client → client}/tokens/tc-token.d.ts +0 -0
  196. /package/dist/{types/crypto → crypto}/core/hkdf.d.ts +0 -0
  197. /package/dist/{types/crypto → crypto}/core/index.d.ts +0 -0
  198. /package/dist/{types/crypto → crypto}/core/keys.d.ts +0 -0
  199. /package/dist/{types/crypto → crypto}/core/nonce.d.ts +0 -0
  200. /package/dist/{types/crypto → crypto}/core/primitives.d.ts +0 -0
  201. /package/dist/{types/crypto → crypto}/core/random.d.ts +0 -0
  202. /package/dist/{types/crypto → crypto}/core/xeddsa.d.ts +0 -0
  203. /package/dist/{types/crypto → crypto}/curves/Ed25519.d.ts +0 -0
  204. /package/dist/{types/crypto → crypto}/curves/X25519.d.ts +0 -0
  205. /package/dist/{types/crypto → crypto}/curves/constants.d.ts +0 -0
  206. /package/dist/{types/crypto → crypto}/curves/types.d.ts +0 -0
  207. /package/dist/{types/crypto → crypto}/index.d.ts +0 -0
  208. /package/dist/{types/crypto → crypto}/math/constants.d.ts +0 -0
  209. /package/dist/{types/crypto → crypto}/math/edwards.d.ts +0 -0
  210. /package/dist/{types/crypto → crypto}/math/fe.d.ts +0 -0
  211. /package/dist/{types/crypto → crypto}/math/le.d.ts +0 -0
  212. /package/dist/{types/crypto → crypto}/math/mod.d.ts +0 -0
  213. /package/dist/{types/crypto → crypto}/math/types.d.ts +0 -0
  214. /package/dist/{types/infra → infra}/log/ConsoleLogger.d.ts +0 -0
  215. /package/dist/{types/infra → infra}/log/PinoLogger.d.ts +0 -0
  216. /package/dist/{types/infra → infra}/log/types.d.ts +0 -0
  217. /package/dist/{types/infra → infra}/perf/BackgroundQueue.d.ts +0 -0
  218. /package/dist/{types/infra → infra}/perf/BoundedTaskQueue.d.ts +0 -0
  219. /package/dist/{types/infra → infra}/perf/PromiseDedup.d.ts +0 -0
  220. /package/dist/{types/infra → infra}/perf/SharedExclusiveGate.d.ts +0 -0
  221. /package/dist/{types/infra → infra}/perf/StoreLock.d.ts +0 -0
  222. /package/dist/{types/media → media}/constants.d.ts +0 -0
  223. /package/dist/{types/media → media}/crypto/WaMediaCrypto.d.ts +0 -0
  224. /package/dist/{types/media → media}/index.d.ts +0 -0
  225. /package/dist/{types/media → media}/processor.d.ts +0 -0
  226. /package/dist/{types/media → media}/sticker/sticker-pack.d.ts +0 -0
  227. /package/dist/{types/media → media}/transfer/WaMediaTransferClient.d.ts +0 -0
  228. /package/dist/{types/media → media}/transfer/conn.d.ts +0 -0
  229. /package/dist/{types/media → media}/types.d.ts +0 -0
  230. /package/dist/{types/message → message}/WaMessageClient.d.ts +0 -0
  231. /package/dist/{types/message → message}/addons/link-preview/detect.d.ts +0 -0
  232. /package/dist/{types/message → message}/addons/link-preview/fetcher.d.ts +0 -0
  233. /package/dist/{types/message → message}/crypto/phash.d.ts +0 -0
  234. /package/dist/{types/message → message}/encode/padding.d.ts +0 -0
  235. /package/dist/{types/message → message}/index.d.ts +0 -0
  236. /package/dist/{types/message → message}/kinds/newsletter.d.ts +0 -0
  237. /package/dist/{types/message → message}/primitives/ack.d.ts +0 -0
  238. /package/dist/{types/mex.d.ts → mex.d.ts} +0 -0
  239. /package/dist/{types/proto.d.ts → proto.d.ts} +0 -0
  240. /package/dist/{types/protocol → protocol}/abprops.d.ts +0 -0
  241. /package/dist/{types/protocol → protocol}/appstate.d.ts +0 -0
  242. /package/dist/{types/protocol → protocol}/auth.d.ts +0 -0
  243. /package/dist/{types/protocol → protocol}/browser.d.ts +0 -0
  244. /package/dist/{types/protocol → protocol}/business.d.ts +0 -0
  245. /package/dist/{types/protocol → protocol}/call.d.ts +0 -0
  246. /package/dist/{types/protocol → protocol}/constants.d.ts +0 -0
  247. /package/dist/{types/protocol → protocol}/defaults.d.ts +0 -0
  248. /package/dist/{types/protocol → protocol}/dirty.d.ts +0 -0
  249. /package/dist/{types/protocol → protocol}/email.d.ts +0 -0
  250. /package/dist/{types/protocol → protocol}/group.d.ts +0 -0
  251. /package/dist/{types/protocol → protocol}/index.d.ts +0 -0
  252. /package/dist/{types/protocol → protocol}/jid.d.ts +0 -0
  253. /package/dist/{types/protocol → protocol}/media.d.ts +0 -0
  254. /package/dist/{types/protocol → protocol}/newsletter.d.ts +0 -0
  255. /package/dist/{types/protocol → protocol}/nodes.d.ts +0 -0
  256. /package/dist/{types/protocol → protocol}/notification.d.ts +0 -0
  257. /package/dist/{types/protocol → protocol}/presence.d.ts +0 -0
  258. /package/dist/{types/protocol → protocol}/privacy-token.d.ts +0 -0
  259. /package/dist/{types/protocol → protocol}/privacy.d.ts +0 -0
  260. /package/dist/{types/protocol → protocol}/status.d.ts +0 -0
  261. /package/dist/{types/protocol → protocol}/stream.d.ts +0 -0
  262. /package/dist/{types/protocol → protocol}/usync.d.ts +0 -0
  263. /package/dist/{types/retry → retry}/codec.d.ts +0 -0
  264. /package/dist/{types/retry → retry}/constants.d.ts +0 -0
  265. /package/dist/{types/retry → retry}/index.d.ts +0 -0
  266. /package/dist/{types/retry → retry}/parse.d.ts +0 -0
  267. /package/dist/{types/retry → retry}/reason.d.ts +0 -0
  268. /package/dist/{types/retry → retry}/replay.d.ts +0 -0
  269. /package/dist/{types/retry → retry}/tracker.d.ts +0 -0
  270. /package/dist/{types/retry → retry}/types.d.ts +0 -0
  271. /package/dist/{types/signal → signal}/api/SignalDeviceSyncApi.d.ts +0 -0
  272. /package/dist/{types/signal → signal}/api/SignalDigestSyncApi.d.ts +0 -0
  273. /package/dist/{types/signal → signal}/api/SignalIdentitySyncApi.d.ts +0 -0
  274. /package/dist/{types/signal → signal}/api/SignalMissingPreKeysSyncApi.d.ts +0 -0
  275. /package/dist/{types/signal → signal}/api/SignalRotateKeyApi.d.ts +0 -0
  276. /package/dist/{types/signal → signal}/api/SignalSessionSyncApi.d.ts +0 -0
  277. /package/dist/{types/signal → signal}/api/codec.d.ts +0 -0
  278. /package/dist/{types/signal → signal}/api/constants.d.ts +0 -0
  279. /package/dist/{types/signal → signal}/api/prekeys.d.ts +0 -0
  280. /package/dist/{types/signal → signal}/api/result-map.d.ts +0 -0
  281. /package/dist/{types/signal → signal}/attestation/WaAdvSignature.d.ts +0 -0
  282. /package/dist/{types/signal → signal}/attestation/constants.d.ts +0 -0
  283. /package/dist/{types/signal → signal}/constants.d.ts +0 -0
  284. /package/dist/{types/signal → signal}/encoding.d.ts +0 -0
  285. /package/dist/{types/signal → signal}/group/SenderKeyChain.d.ts +0 -0
  286. /package/dist/{types/signal → signal}/group/SenderKeyCodec.d.ts +0 -0
  287. /package/dist/{types/signal → signal}/group/encoding.d.ts +0 -0
  288. /package/dist/{types/signal → signal}/index.d.ts +0 -0
  289. /package/dist/{types/signal → signal}/registration/encoding.d.ts +0 -0
  290. /package/dist/{types/signal → signal}/registration/keygen.d.ts +0 -0
  291. /package/dist/{types/signal → signal}/registration/utils.d.ts +0 -0
  292. /package/dist/{types/signal → signal}/session/SignalProtocol.d.ts +0 -0
  293. /package/dist/{types/signal → signal}/session/SignalRatchet.d.ts +0 -0
  294. /package/dist/{types/signal → signal}/session/SignalSerializer.d.ts +0 -0
  295. /package/dist/{types/signal → signal}/session/SignalSession.d.ts +0 -0
  296. /package/dist/{types/signal → signal}/session/resolver.d.ts +0 -0
  297. /package/dist/{types/store → store}/cache/identity.cache.d.ts +0 -0
  298. /package/dist/{types/store → store}/cache/privacy-token.cache.d.ts +0 -0
  299. /package/dist/{types/store → store}/cache/sender-key.cache.d.ts +0 -0
  300. /package/dist/{types/store → store}/cache/session.cache.d.ts +0 -0
  301. /package/dist/{types/store → store}/contracts/appstate.store.d.ts +0 -0
  302. /package/dist/{types/store → store}/contracts/auth.store.d.ts +0 -0
  303. /package/dist/{types/store → store}/contracts/contact.store.d.ts +0 -0
  304. /package/dist/{types/store → store}/contracts/device-list.store.d.ts +0 -0
  305. /package/dist/{types/store → store}/contracts/group-metadata.store.d.ts +0 -0
  306. /package/dist/{types/store → store}/contracts/identity.store.d.ts +0 -0
  307. /package/dist/{types/store → store}/contracts/message-secret.store.d.ts +0 -0
  308. /package/dist/{types/store → store}/contracts/message.store.d.ts +0 -0
  309. /package/dist/{types/store → store}/contracts/pre-key.store.d.ts +0 -0
  310. /package/dist/{types/store → store}/contracts/privacy-token.store.d.ts +0 -0
  311. /package/dist/{types/store → store}/contracts/retry.store.d.ts +0 -0
  312. /package/dist/{types/store → store}/contracts/sender-key.store.d.ts +0 -0
  313. /package/dist/{types/store → store}/contracts/session.store.d.ts +0 -0
  314. /package/dist/{types/store → store}/contracts/signal.store.d.ts +0 -0
  315. /package/dist/{types/store → store}/contracts/thread.store.d.ts +0 -0
  316. /package/dist/{types/store → store}/createStore.d.ts +0 -0
  317. /package/dist/{types/store → store}/index.d.ts +0 -0
  318. /package/dist/{types/store → store}/locks/appstate.lock.d.ts +0 -0
  319. /package/dist/{types/store → store}/locks/auth.lock.d.ts +0 -0
  320. /package/dist/{types/store → store}/locks/contact.lock.d.ts +0 -0
  321. /package/dist/{types/store → store}/locks/device-list.lock.d.ts +0 -0
  322. /package/dist/{types/store → store}/locks/group-metadata.lock.d.ts +0 -0
  323. /package/dist/{types/store → store}/locks/identity.lock.d.ts +0 -0
  324. /package/dist/{types/store → store}/locks/message-secret.lock.d.ts +0 -0
  325. /package/dist/{types/store → store}/locks/message.lock.d.ts +0 -0
  326. /package/dist/{types/store → store}/locks/pre-key.lock.d.ts +0 -0
  327. /package/dist/{types/store → store}/locks/privacy-token.lock.d.ts +0 -0
  328. /package/dist/{types/store → store}/locks/retry.lock.d.ts +0 -0
  329. /package/dist/{types/store → store}/locks/sender-key.lock.d.ts +0 -0
  330. /package/dist/{types/store → store}/locks/session.lock.d.ts +0 -0
  331. /package/dist/{types/store → store}/locks/signal.lock.d.ts +0 -0
  332. /package/dist/{types/store → store}/locks/thread.lock.d.ts +0 -0
  333. /package/dist/{types/store → store}/memory/appstate.store.d.ts +0 -0
  334. /package/dist/{types/store → store}/memory/auth.store.d.ts +0 -0
  335. /package/dist/{types/store → store}/memory/contact.store.d.ts +0 -0
  336. /package/dist/{types/store → store}/memory/device-list.store.d.ts +0 -0
  337. /package/dist/{types/store → store}/memory/group-metadata.store.d.ts +0 -0
  338. /package/dist/{types/store → store}/memory/identity.store.d.ts +0 -0
  339. /package/dist/{types/store → store}/memory/message-secret.store.d.ts +0 -0
  340. /package/dist/{types/store → store}/memory/message.store.d.ts +0 -0
  341. /package/dist/{types/store → store}/memory/pre-key.store.d.ts +0 -0
  342. /package/dist/{types/store → store}/memory/privacy-token.store.d.ts +0 -0
  343. /package/dist/{types/store → store}/memory/retry.store.d.ts +0 -0
  344. /package/dist/{types/store → store}/memory/sender-key.store.d.ts +0 -0
  345. /package/dist/{types/store → store}/memory/session.store.d.ts +0 -0
  346. /package/dist/{types/store → store}/memory/signal.store.d.ts +0 -0
  347. /package/dist/{types/store → store}/memory/thread.store.d.ts +0 -0
  348. /package/dist/{types/store → store}/noop.store.d.ts +0 -0
  349. /package/dist/{types/store → store}/types.d.ts +0 -0
  350. /package/dist/{types/transport → transport}/WaComms.d.ts +0 -0
  351. /package/dist/{types/transport → transport}/WaWebSocket.d.ts +0 -0
  352. /package/dist/{types/transport → transport}/binary/constants.d.ts +0 -0
  353. /package/dist/{types/transport → transport}/binary/decoder.d.ts +0 -0
  354. /package/dist/{types/transport → transport}/binary/encoder.d.ts +0 -0
  355. /package/dist/{types/transport → transport}/binary/index.d.ts +0 -0
  356. /package/dist/{types/transport → transport}/binary/tokens.d.ts +0 -0
  357. /package/dist/{types/transport → transport}/index.d.ts +0 -0
  358. /package/dist/{types/transport → transport}/keepalive/WaKeepAlive.d.ts +0 -0
  359. /package/dist/{types/transport → transport}/node/WaMobileTcpSocket.d.ts +0 -0
  360. /package/dist/{types/transport → transport}/node/WaNodeOrchestrator.d.ts +0 -0
  361. /package/dist/{types/transport → transport}/node/WaNodeTransport.d.ts +0 -0
  362. /package/dist/{types/transport → transport}/node/builders/abprops.d.ts +0 -0
  363. /package/dist/{types/transport → transport}/node/builders/account-sync.d.ts +0 -0
  364. /package/dist/{types/transport → transport}/node/builders/bot.d.ts +0 -0
  365. /package/dist/{types/transport → transport}/node/builders/business.d.ts +0 -0
  366. /package/dist/{types/transport → transport}/node/builders/chatstate.d.ts +0 -0
  367. /package/dist/{types/transport → transport}/node/builders/community.d.ts +0 -0
  368. /package/dist/{types/transport → transport}/node/builders/device.d.ts +0 -0
  369. /package/dist/{types/transport → transport}/node/builders/email.d.ts +0 -0
  370. /package/dist/{types/transport → transport}/node/builders/global.d.ts +0 -0
  371. /package/dist/{types/transport → transport}/node/builders/group.d.ts +0 -0
  372. /package/dist/{types/transport → transport}/node/builders/media.d.ts +0 -0
  373. /package/dist/{types/transport → transport}/node/builders/message.d.ts +0 -0
  374. /package/dist/{types/transport → transport}/node/builders/newsletter.d.ts +0 -0
  375. /package/dist/{types/transport → transport}/node/builders/offline.d.ts +0 -0
  376. /package/dist/{types/transport → transport}/node/builders/pairing.d.ts +0 -0
  377. /package/dist/{types/transport → transport}/node/builders/passive.d.ts +0 -0
  378. /package/dist/{types/transport → transport}/node/builders/prekeys.d.ts +0 -0
  379. /package/dist/{types/transport → transport}/node/builders/presence.d.ts +0 -0
  380. /package/dist/{types/transport → transport}/node/builders/privacy-token.d.ts +0 -0
  381. /package/dist/{types/transport → transport}/node/builders/privacy.d.ts +0 -0
  382. /package/dist/{types/transport → transport}/node/builders/profile.d.ts +0 -0
  383. /package/dist/{types/transport → transport}/node/builders/retry.d.ts +0 -0
  384. /package/dist/{types/transport → transport}/node/builders/tos.d.ts +0 -0
  385. /package/dist/{types/transport → transport}/node/builders/usync.d.ts +0 -0
  386. /package/dist/{types/transport → transport}/node/helpers.d.ts +0 -0
  387. /package/dist/{types/transport → transport}/node/mex/argo-decoder.d.ts +0 -0
  388. /package/dist/{types/transport → transport}/node/query.d.ts +0 -0
  389. /package/dist/{types/transport → transport}/node/usync.d.ts +0 -0
  390. /package/dist/{types/transport → transport}/node/xml.d.ts +0 -0
  391. /package/dist/{types/transport → transport}/noise/WaClientPayload.d.ts +0 -0
  392. /package/dist/{types/transport → transport}/noise/WaFrameCodec.d.ts +0 -0
  393. /package/dist/{types/transport → transport}/noise/WaNoiseCert.d.ts +0 -0
  394. /package/dist/{types/transport → transport}/noise/WaNoiseHandshake.d.ts +0 -0
  395. /package/dist/{types/transport → transport}/noise/WaNoiseSession.d.ts +0 -0
  396. /package/dist/{types/transport → transport}/noise/WaNoiseSocket.d.ts +0 -0
  397. /package/dist/{types/transport → transport}/noise/constants.d.ts +0 -0
  398. /package/dist/{types/transport → transport}/proxy.d.ts +0 -0
  399. /package/dist/{types/transport → transport}/stream/parse.d.ts +0 -0
  400. /package/dist/{types/transport → transport}/types.d.ts +0 -0
  401. /package/dist/{types/transport → transport}/wa-web-version-fetcher.d.ts +0 -0
  402. /package/dist/{types/util → util}/async.d.ts +0 -0
  403. /package/dist/{types/util → util}/bytes.d.ts +0 -0
  404. /package/dist/{types/util → util}/clock.d.ts +0 -0
  405. /package/dist/{types/util → util}/coercion.d.ts +0 -0
  406. /package/dist/{types/util → util}/collections.d.ts +0 -0
  407. /package/dist/{types/util → util}/index.d.ts +0 -0
  408. /package/dist/{types/util → util}/primitives.d.ts +0 -0
  409. /package/dist/{types/util → util}/runtime.d.ts +0 -0
  410. /package/dist/{types/version-spec.d.ts → version-spec.d.ts} +0 -0
@@ -14,6 +14,7 @@ exports.shouldNormalizeVoiceNote = shouldNormalizeVoiceNote;
14
14
  exports.hasMediaProcessingTasks = hasMediaProcessingTasks;
15
15
  exports.getScopedMediaLogger = getScopedMediaLogger;
16
16
  exports.runMediaProcessor = runMediaProcessor;
17
+ exports.downloadMediaMessage = downloadMediaMessage;
17
18
  const node_crypto_1 = require("node:crypto");
18
19
  const node_fs_1 = require("node:fs");
19
20
  const promises_1 = require("node:fs/promises");
@@ -22,6 +23,9 @@ const node_path_1 = require("node:path");
22
23
  const node_stream_1 = require("node:stream");
23
24
  const promises_2 = require("node:stream/promises");
24
25
  const core_1 = require("../crypto/core");
26
+ const WaMediaTransferClient_1 = require("../media/transfer/WaMediaTransferClient");
27
+ const media_payload_1 = require("../message/encode/media-payload");
28
+ const proxy_1 = require("../transport/proxy");
25
29
  const bytes_1 = require("../util/bytes");
26
30
  const primitives_1 = require("../util/primitives");
27
31
  async function readFileHead(filePath, bytes) {
@@ -76,8 +80,8 @@ function parseWebpAnimation(data) {
76
80
  }
77
81
  return null;
78
82
  }
79
- const IMAGE_THUMB_MAX_EDGE = 320;
80
- const VIDEO_THUMB_MAX_EDGE = 48;
83
+ const IMAGE_THUMB_MAX_EDGE = 100;
84
+ const VIDEO_THUMB_MAX_EDGE = 100;
81
85
  const STICKER_THUMB_MAX_EDGE = 100;
82
86
  const EMPTY_PROCESSED = {};
83
87
  function isReadableStream(value) {
@@ -398,3 +402,59 @@ async function runMediaProcessor(media, input, content, logger) {
398
402
  }
399
403
  return result;
400
404
  }
405
+ /**
406
+ * Streams and decrypts the media attached to a message without a connected
407
+ * `WaClient`. Resolves the encrypted payload (directPath, mediaKey, file
408
+ * hashes) from `source`, fetches the ciphertext from the WhatsApp media CDN,
409
+ * and decrypts it on the fly.
410
+ *
411
+ * The media keys come from the (already decrypted) message itself, so this is
412
+ * for re-downloading media you have persisted - not for fetching media you
413
+ * never received. The CDN download needs no session or auth token; only the
414
+ * upload path does.
415
+ *
416
+ * **The caller owns the returned stream** - pipe it somewhere or call
417
+ * `.destroy()` to release the socket; an unconsumed stream leaks the
418
+ * connection. MAC + SHA-256 verification runs as bytes are consumed, so
419
+ * aborting mid-read leaves you with unverified bytes. Pass `options.signal`
420
+ * to cancel cleanly.
421
+ *
422
+ * @throws when `source` carries no downloadable media.
423
+ * @example
424
+ * ```ts
425
+ * import { downloadMediaMessage } from '..'
426
+ * import { createWriteStream } from 'node:fs'
427
+ *
428
+ * const stream = await downloadMediaMessage(event)
429
+ * stream.pipe(createWriteStream('photo.jpg'))
430
+ * ```
431
+ * @example
432
+ * ```ts
433
+ * // Route the CDN download through an http.Agent-style proxy
434
+ * import { HttpsProxyAgent } from 'https-proxy-agent'
435
+ *
436
+ * const stream = await downloadMediaMessage(event, {
437
+ * proxy: new HttpsProxyAgent('http://127.0.0.1:8080')
438
+ * })
439
+ * ```
440
+ */
441
+ async function downloadMediaMessage(source, options = {}) {
442
+ const message = 'rawNode' in source ? source.message : source;
443
+ const payload = (0, media_payload_1.resolveMediaPayload)(message);
444
+ if (!payload) {
445
+ throw new Error('message has no downloadable media');
446
+ }
447
+ const transfer = options.transfer ?? new WaMediaTransferClient_1.WaMediaTransferClient();
448
+ const { plaintext } = await transfer.downloadAndDecryptStream({
449
+ directPath: payload.directPath,
450
+ mediaType: payload.mediaType,
451
+ mediaKey: payload.mediaKey,
452
+ fileSha256: payload.fileSha256,
453
+ fileEncSha256: payload.fileEncSha256,
454
+ agent: (0, proxy_1.toProxyAgent)(options.proxy),
455
+ timeoutMs: options.timeoutMs,
456
+ signal: options.signal,
457
+ maxBytes: options.maxBytes
458
+ });
459
+ return plaintext;
460
+ }
@@ -7,6 +7,7 @@ const primitives_1 = require("../../util/primitives");
7
7
  function createGroupMetadataCache(options) {
8
8
  const { groupMetadataStore, queryGroupMetadata, logger } = options;
9
9
  const dedup = new PromiseDedup_1.PromiseDedup();
10
+ const pendingMutations = new Map();
10
11
  const sanitizeParticipantUsers = (participants) => {
11
12
  const deduped = new Set();
12
13
  for (const participant of participants) {
@@ -109,14 +110,9 @@ function createGroupMetadataCache(options) {
109
110
  const extractParticipantUsersFromGroupEvent = (event) => {
110
111
  const candidates = [];
111
112
  for (const participant of event.participants ?? []) {
112
- if (participant.jid) {
113
- candidates.push(participant.jid);
114
- }
115
- if (participant.lidJid) {
116
- candidates.push(participant.lidJid);
117
- }
118
- if (participant.phoneJid) {
119
- candidates.push(participant.phoneJid);
113
+ const canonical = participant.jid ?? participant.lidJid ?? participant.phoneJid;
114
+ if (canonical) {
115
+ candidates.push(canonical);
120
116
  }
121
117
  }
122
118
  return sanitizeParticipantUsers(candidates);
@@ -133,6 +129,7 @@ function createGroupMetadataCache(options) {
133
129
  return participants;
134
130
  });
135
131
  const resolveParticipantUsers = (groupJid) => dedup.run(`resolve:${groupJid}`, async () => {
132
+ await pendingMutations.get(groupJid)?.catch(() => undefined);
136
133
  const cached = await groupMetadataStore.getGroupMetadata(groupJid);
137
134
  if (cached && cached.participants.length > 0) {
138
135
  return sanitizeParticipantUsers(cached.participants);
@@ -152,7 +149,7 @@ function createGroupMetadataCache(options) {
152
149
  const refreshed = await groupMetadataStore.getGroupMetadata(groupJid);
153
150
  return refreshed?.ephemeral ?? null;
154
151
  };
155
- const mutateFromGroupEvent = async (event) => {
152
+ const applyGroupEvent = async (event) => {
156
153
  const groupJid = resolveGroupJidForGroupCacheEvent(event);
157
154
  if (!groupJid) {
158
155
  return;
@@ -221,6 +218,20 @@ function createGroupMetadataCache(options) {
221
218
  await replaceParticipantUsersInCache(groupJid, cachedWithSanitized, authorUsers, participantUsers);
222
219
  }
223
220
  };
221
+ const mutateFromGroupEvent = (event) => {
222
+ const groupJid = resolveGroupJidForGroupCacheEvent(event);
223
+ if (!groupJid) {
224
+ return applyGroupEvent(event);
225
+ }
226
+ const prev = pendingMutations.get(groupJid) ?? Promise.resolve();
227
+ const next = prev.then(() => applyGroupEvent(event), () => applyGroupEvent(event));
228
+ pendingMutations.set(groupJid, next);
229
+ return next.finally(() => {
230
+ if (pendingMutations.get(groupJid) === next) {
231
+ pendingMutations.delete(groupJid);
232
+ }
233
+ });
234
+ };
224
235
  return {
225
236
  resolveParticipantUsers,
226
237
  refreshParticipantUsers,
@@ -3,7 +3,7 @@ import type { WaAuthCredentials } from '../../auth/types';
3
3
  import type { DeviceFanoutResolver } from '../messaging/fanout';
4
4
  import type { Logger } from '../../infra/log/types';
5
5
  import type { WaMessagePublishResult } from '../../message/types';
6
- import { type Proto } from '../..';
6
+ import { type Proto } from '../../proto';
7
7
  export type PublishProtocolMessageToDeviceFn = (deviceJid: string, protocolMessage: Proto.Message.IProtocolMessage, options?: {
8
8
  readonly id?: string;
9
9
  readonly pushPriority?: 'high' | 'high_force';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAppStateSyncKeyProtocol = createAppStateSyncKeyProtocol;
4
- const _proto_1 = require("../../proto.js");
4
+ const _proto_1 = require("../../proto");
5
5
  const jid_1 = require("../../protocol/jid");
6
6
  const bytes_1 = require("../../util/bytes");
7
7
  function createAppStateSyncKeyProtocol(options) {
@@ -6,7 +6,7 @@ const media_1 = require("../media");
6
6
  const constants_1 = require("../../media/constants");
7
7
  const WaMediaCrypto_1 = require("../../media/crypto/WaMediaCrypto");
8
8
  const detect_1 = require("../../message/addons/link-preview/detect");
9
- const _proto_1 = require("../../proto.js");
9
+ const _proto_1 = require("../../proto");
10
10
  const primitives_1 = require("../../util/primitives");
11
11
  const INLINE_THUMBNAIL_MAX_BYTES = 64 * 1024;
12
12
  async function resolveLinkPreview(text, perMessage, deps) {
@@ -5,7 +5,7 @@ exports.getMediaConn = getMediaConn;
5
5
  const node_fs_1 = require("node:fs");
6
6
  const node_stream_1 = require("node:stream");
7
7
  const media_1 = require("../media");
8
- const _crypto_1 = require("../../crypto/index.js");
8
+ const _crypto_1 = require("../../crypto");
9
9
  const constants_1 = require("../../media/constants");
10
10
  const WaMediaCrypto_1 = require("../../media/crypto/WaMediaCrypto");
11
11
  const sticker_pack_1 = require("../../media/sticker/sticker-pack");
@@ -15,7 +15,7 @@ const addon_crypto_1 = require("../../message/crypto/addon-crypto");
15
15
  const use_case_secret_1 = require("../../message/crypto/use-case-secret");
16
16
  const content_1 = require("../../message/encode/content");
17
17
  const sticker_pack_2 = require("../../message/kinds/sticker-pack");
18
- const _proto_1 = require("../../proto.js");
18
+ const _proto_1 = require("../../proto");
19
19
  const constants_2 = require("../../protocol/constants");
20
20
  const jid_1 = require("../../protocol/jid");
21
21
  const media_2 = require("../../transport/node/builders/media");
@@ -1,6 +1,6 @@
1
1
  import { type WaNewsletterMexDeps } from '../newsletter/mex';
2
2
  import type { WaNewsletterAdminInfo, WaNewsletterAdminInviteInput, WaNewsletterAdminInviteResult, WaNewsletterCapability, WaNewsletterCapabilityExposure, WaNewsletterCreateInput, WaNewsletterFollowersOptions, WaNewsletterFollowersPage, WaNewsletterInsightMetricRequest, WaNewsletterMetadata, WaNewsletterPollVoter, WaNewsletterReactionSenders, WaNewsletterUpdateInput } from '../newsletter/types';
3
- import type { WaMexOperationResponses } from '../..';
3
+ import type { WaMexOperationResponses } from '../../mex';
4
4
  import { type WaTosQueryResult } from '../../transport/node/builders/tos';
5
5
  /** Admin-side newsletter operations (create/update/delete + insights). */
6
6
  export interface WaNewsletterAdminOps {
@@ -8,7 +8,7 @@ const sticker_pack_1 = require("../../media/sticker/sticker-pack");
8
8
  const context_info_1 = require("../../message/context-info");
9
9
  const content_1 = require("../../message/encode/content");
10
10
  const sticker_pack_2 = require("../../message/kinds/sticker-pack");
11
- const _proto_1 = require("../../proto.js");
11
+ const _proto_1 = require("../../proto");
12
12
  const message_1 = require("../../protocol/message");
13
13
  const bytes_1 = require("../../util/bytes");
14
14
  async function uploadNewsletterMedia(options, input) {
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from '../../infra/log/types';
2
- import type { WaMexOperationResponses, WaMexOperationVariables } from '../..';
2
+ import type { WaMexOperationResponses, WaMexOperationVariables } from '../../mex';
3
3
  import type { AbPropName } from '../../protocol/abprops';
4
4
  import { type WaMexOpKey, type WaMexQuerySocket } from '../../transport/node/mex/client';
5
5
  import type { BinaryNode } from '../../transport/types';
@@ -1,5 +1,5 @@
1
1
  import type { WaNewsletterAdminInfo, WaNewsletterAdminInviteResult, WaNewsletterCapability, WaNewsletterDehydratedMetadata, WaNewsletterDirectoryCategoryPreview, WaNewsletterDirectoryResults, WaNewsletterFollowersPage, WaNewsletterMetadata, WaNewsletterPollVoter, WaNewsletterReactionSenders } from '../newsletter/types';
2
- import type { WaMexOperationResponses } from '../..';
2
+ import type { WaMexOperationResponses } from '../../mex';
3
3
  type WaNewsletterMetadataEnvelope = NonNullable<WaMexOperationResponses['FetchNewsletter']['xwa2_newsletter']>;
4
4
  export declare function parseNewsletterMetadata(envelope: WaNewsletterMetadataEnvelope | null | undefined): WaNewsletterMetadata;
5
5
  export declare function parseAdminInfo(data: WaMexOperationResponses['FetchNewsletterAdminInfo'] | null): WaNewsletterAdminInfo;
@@ -1,6 +1,6 @@
1
1
  import type { WaSendContextInfo } from '../../message/context-info';
2
2
  import type { WaMessagePublishResult } from '../../message/types';
3
- import type { WaMexOperationResponses } from '../..';
3
+ import type { WaMexOperationResponses } from '../../mex';
4
4
  import type { WA_NEWSLETTER_VIEW_ROLES, WaNewsletterRole, WaNewsletterStateType } from '../../protocol/newsletter';
5
5
  export type WaNewsletterCapability = NonNullable<NonNullable<WaMexOperationResponses['FetchNewsletterAdminCapabilities']['xwa2_newsletter_admin']>['capabilities']>[number];
6
6
  export interface WaNewsletterPicture {
@@ -2,7 +2,7 @@ import type { WriteBehindPersistence } from '../persistence/WriteBehindPersisten
2
2
  import type { WaClientEventMap } from '../types';
3
3
  import type { Logger } from '../../infra/log/types';
4
4
  import type { WaMediaTransferClient } from '../../media/transfer/WaMediaTransferClient';
5
- import { type Proto } from '../..';
5
+ import { type Proto } from '../../proto';
6
6
  interface WaHistorySyncDeps {
7
7
  readonly logger: Logger;
8
8
  readonly mediaTransfer: WaMediaTransferClient;
@@ -4,7 +4,7 @@ exports.runHistorySyncNotification = runHistorySyncNotification;
4
4
  exports.processHistorySyncNotification = processHistorySyncNotification;
5
5
  const node_util_1 = require("node:util");
6
6
  const node_zlib_1 = require("node:zlib");
7
- const _proto_1 = require("../../proto.js");
7
+ const _proto_1 = require("../../proto");
8
8
  const jid_1 = require("../../protocol/jid");
9
9
  const bytes_1 = require("../../util/bytes");
10
10
  const primitives_1 = require("../../util/primitives");
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.persistIncomingMailboxEntities = persistIncomingMailboxEntities;
4
4
  const content_1 = require("../../message/encode/content");
5
- const _proto_1 = require("../../proto.js");
5
+ const _proto_1 = require("../../proto");
6
6
  const jid_1 = require("../../protocol/jid");
7
7
  const primitives_1 = require("../../util/primitives");
8
8
  function pairLidPn(a, b) {
@@ -1,5 +1,5 @@
1
1
  import type { AppStateCollectionName } from '../appstate/types';
2
- import type { DataForKey, WaAppstateActionKey, WaAppstateIndexArgs } from '..';
2
+ import type { DataForKey, WaAppstateActionKey, WaAppstateIndexArgs } from '../appstate-spec';
3
3
  import type { WaAuthClientOptions, WaAuthCredentials, WaAuthDangerousOptions, WaAuthSocketOptions } from '../auth/types';
4
4
  import type { WaCallGroupParticipant, WaCallType } from './events/call';
5
5
  import type { IncomingPresenceType, PresenceLastSeen } from './events/presence';
@@ -8,7 +8,7 @@ import type { WaLinkPreviewOptions } from '../message/addons/link-preview/types'
8
8
  import type { WaQuoteRef, WaSendContextInfo } from '../message/context-info';
9
9
  import type { WaDecodedAddon } from '../message/crypto/addon-crypto';
10
10
  import type { WaMessageKey, WaMessagePublishOptions, WaMessageRef, WaSendEditKey } from '../message/types';
11
- import type { Proto } from '..';
11
+ import type { Proto } from '../proto';
12
12
  import type { WaBotMsgEditType } from '../protocol/bot';
13
13
  import type { WaBusinessHoursDay, WaBusinessHoursMode } from '../protocol/business';
14
14
  import type { WaConnectionCode, WaConnectionOpenReason, WaDisconnectReason } from '../protocol/stream';
@@ -512,6 +512,13 @@ export interface WaIncomingReceiptEvent extends WaIncomingBaseEvent {
512
512
  readonly fromSelfDevice: boolean;
513
513
  readonly participantJid?: string;
514
514
  readonly recipientJid?: string;
515
+ /**
516
+ * All message ids this receipt acknowledges. For batch read/delivery
517
+ * receipts this is the `<list><item>` ids plus the top-level `stanzaId`;
518
+ * for single receipts it is just `[stanzaId]`. Mirrors WhatsApp Web's
519
+ * `externalIds`.
520
+ */
521
+ readonly messageIds: readonly string[];
515
522
  }
516
523
  export interface WaIncomingPresenceEvent extends WaIncomingBaseEvent {
517
524
  readonly type: IncomingPresenceType;
@@ -1,6 +1,6 @@
1
1
  import { proto } from './proto.js';
2
- import { WA_APPSTATE_SCHEMAS as RAW_WA_APPSTATE_SCHEMAS } from '../spec/appstate';
3
- export { WA_APPSTATE_COLLECTIONS, WA_APPSTATE_SCHEMAS } from '../spec/appstate';
2
+ import { WA_APPSTATE_SCHEMAS as RAW_WA_APPSTATE_SCHEMAS } from '../../spec/appstate/index.js';
3
+ export { WA_APPSTATE_COLLECTIONS, WA_APPSTATE_SCHEMAS } from '../../spec/appstate/index.js';
4
4
  const SCHEMA_BY_ACTION_NAME_BUILDER = {};
5
5
  for (const key of Object.keys(RAW_WA_APPSTATE_SCHEMAS)) {
6
6
  SCHEMA_BY_ACTION_NAME_BUILDER[RAW_WA_APPSTATE_SCHEMAS[key].name] = key;
@@ -32,7 +32,7 @@ const SYNC_RELATED_PROTOCOL_TYPES = new Set([
32
32
  *
33
33
  * @example
34
34
  * ```ts
35
- * import { createPinoLogger, createStore, WaClient } from '../index.js'
35
+ * import { createPinoLogger, createStore, WaClient } from '..'
36
36
  * import { createSqliteStore } from '@zapo-js/store-sqlite'
37
37
  *
38
38
  * const store = createStore({
@@ -149,7 +149,8 @@ function createIncomingNodeRuntime(input) {
149
149
  emitRegistrationCode: (event) => emitEvent('mobile_registration_code', event),
150
150
  emitAccountTakeoverNotice: (event) => emitEvent('mobile_account_takeover_notice', event),
151
151
  emitGroupEvent: (event) => {
152
- emitEvent('group', event);
152
+ // Register the cache mutation before emitting so a handler that
153
+ // sends synchronously sees the fresh participants, not the stale ones.
153
154
  void messageDispatch.mutateGroupMetadataCacheFromGroupEvent(event).catch((error) => {
154
155
  logger.warn('failed to mutate group metadata cache from group event', {
155
156
  action: event.action,
@@ -158,6 +159,7 @@ function createIncomingNodeRuntime(input) {
158
159
  message: toError(error).message
159
160
  });
160
161
  });
162
+ emitEvent('group', event);
161
163
  },
162
164
  emitBusinessEvent: (event) => emitEvent('business', event),
163
165
  emitPictureEvent: (event) => emitEvent('picture', event),
@@ -1,9 +1,9 @@
1
1
  import { createWriteStream } from 'node:fs';
2
2
  import { pipeline } from 'node:stream/promises';
3
3
  import { aggregateReceiptTargets } from '../events/receipt.js';
4
+ import { downloadMediaMessage } from '../media.js';
4
5
  import { buildAddonAdditionalData, decodeAddonPlaintext, decryptAddonPayload, identifyEncryptedAddon, resolveParentMessageSecret, resolvePollOptionNames, shouldUseAddonAdditionalData } from '../../message/crypto/addon-crypto.js';
5
6
  import { unwrapMessage } from '../../message/encode/content.js';
6
- import { resolveMediaPayload } from '../../message/encode/media-payload.js';
7
7
  import { proto } from '../../proto.js';
8
8
  import { applyDeviceToJid, normalizeRecipientJid } from '../../protocol/jid.js';
9
9
  import { runMexQuery } from '../../transport/node/mex/client.js';
@@ -232,23 +232,7 @@ export class WaMessageCoordinator {
232
232
  * for one-shot verified downloads.
233
233
  */
234
234
  async download(source, options = {}) {
235
- const message = 'rawNode' in source ? source.message : source;
236
- const payload = resolveMediaPayload(message);
237
- if (!payload) {
238
- throw new Error('message has no downloadable media');
239
- }
240
- const { plaintext, metadata } = await this.mediaTransfer.downloadAndDecryptStream({
241
- directPath: payload.directPath,
242
- mediaType: payload.mediaType,
243
- mediaKey: payload.mediaKey,
244
- fileSha256: payload.fileSha256,
245
- fileEncSha256: payload.fileEncSha256,
246
- timeoutMs: options.timeoutMs,
247
- signal: options.signal,
248
- maxBytes: options.maxBytes
249
- });
250
- metadata.catch(() => undefined);
251
- return plaintext;
235
+ return downloadMediaMessage(source, { ...options, transfer: this.mediaTransfer });
252
236
  }
253
237
  /**
254
238
  * Convenience wrapper around {@link download} that streams the decrypted
@@ -161,7 +161,8 @@ export class WaMessageDispatchCoordinator {
161
161
  quote: options.quote,
162
162
  forward: options.forward,
163
163
  mentions: options.mentions,
164
- meLid: this.deps.getCurrentCredentials()?.meLid
164
+ meLid: this.deps.getCurrentCredentials()?.meLid,
165
+ targetJid: recipientJid
165
166
  });
166
167
  const withCtx = ctx ? applyContextInfo(built.message, ctx) : built.message;
167
168
  const withViewOnce = options.viewOnce ? wrapAsViewOnce(withCtx) : withCtx;
@@ -50,11 +50,10 @@ export function createStreamControlHandler(options) {
50
50
  const reason = WA_DISCONNECT_REASONS.STREAM_ERROR_FORCE_LOGIN;
51
51
  stopCommsImmediately();
52
52
  await runStreamControlLifecycle(reason, async () => {
53
- logger.warn('received forced login stream error; starting login lifecycle', {
53
+ logger.warn('received forced login stream error; reconnecting, keeping credentials', {
54
54
  code
55
55
  });
56
- await disconnect(reason, true, code);
57
- await clearStoredCredentials();
56
+ await disconnect(reason, false, code);
58
57
  await restartBackendAfterStreamControl(reason);
59
58
  });
60
59
  };
@@ -3,6 +3,7 @@ import { parseCallNode } from '../events/call.js';
3
3
  import { parseGroupNotificationEvents } from '../events/group.js';
4
4
  import { parseMexNotification } from '../events/mex-notification.js';
5
5
  import { parsePictureNotificationEvents } from '../events/picture.js';
6
+ import { extractReceiptIds } from '../events/receipt.js';
6
7
  import { parseRegistrationNotification } from '../events/registration.js';
7
8
  import { WA_CALL_NODE_ATTRS, WA_CALL_RECEIPT_PAYLOAD_TAGS, WA_DISCONNECT_REASONS, WA_MESSAGE_TAGS, WA_MESSAGE_TYPES, WA_NODE_TAGS, WA_NOTIFICATION_TYPES } from '../../protocol/constants.js';
8
9
  import { isLidJid, normalizeDeviceJid, toUserJid } from '../../protocol/jid.js';
@@ -173,7 +174,8 @@ export function createIncomingReceiptHandler(options) {
173
174
  status: mapped.status,
174
175
  fromSelfDevice: mapped.fromSelfDevice,
175
176
  participantJid: node.attrs.participant,
176
- recipientJid: node.attrs.recipient
177
+ recipientJid: node.attrs.recipient,
178
+ messageIds: extractReceiptIds(node)
177
179
  });
178
180
  }
179
181
  else if (node.attrs.type && !INTERNAL_ONLY_RECEIPT_TYPES.has(node.attrs.type)) {
@@ -1,4 +1,6 @@
1
+ import { WA_MESSAGE_TYPES } from '../../protocol/constants.js';
1
2
  import { isGroupOrBroadcastJid } from '../../protocol/jid.js';
3
+ import { findNodeChild, getNodeChildrenNonEmptyAttrValuesByTag, hasNodeChild } from '../../transport/node/helpers.js';
2
4
  function needsParticipant(target) {
3
5
  if (target.isGroupChat !== undefined || target.isBroadcastChat !== undefined) {
4
6
  return target.isGroupChat === true || target.isBroadcastChat === true;
@@ -21,3 +23,32 @@ export function aggregateReceiptTargets(targets) {
21
23
  }
22
24
  return [...groups.values()];
23
25
  }
26
+ /**
27
+ * Resolves every message id a `<receipt>` acknowledges, mirroring WhatsApp
28
+ * Web's `externalIds`. A batch receipt carries the extra ids in a
29
+ * `<list><item id=.../>` block; the top-level `attrs.id` is just one of them.
30
+ *
31
+ * - `<list><item>` ids come first. For `type="view"` receipts the item key is
32
+ * `server_id` (not `id`), and the top-level id is NOT appended.
33
+ * - Otherwise the top-level `attrs.id` is appended last.
34
+ * - Aggregated receipts (carrying a `<participants>` child) are out of scope:
35
+ * their ids live in `<user>` children, so this falls back to the single
36
+ * top-level id for them.
37
+ *
38
+ * No dedup: matches wa-web, which pushes the top id without checking the list.
39
+ */
40
+ export function extractReceiptIds(node) {
41
+ const topId = node.attrs.id;
42
+ if (hasNodeChild(node, 'participants')) {
43
+ return topId ? [topId] : [];
44
+ }
45
+ const isView = node.attrs.type === WA_MESSAGE_TYPES.RECEIPT_TYPE_VIEW;
46
+ const list = findNodeChild(node, 'list');
47
+ const ids = list
48
+ ? [...getNodeChildrenNonEmptyAttrValuesByTag(list, 'item', isView ? 'server_id' : 'id')]
49
+ : [];
50
+ if (!isView && topId) {
51
+ ids.push(topId);
52
+ }
53
+ return ids;
54
+ }
@@ -6,6 +6,9 @@ import { join } from 'node:path';
6
6
  import { Transform } from 'node:stream';
7
7
  import { pipeline } from 'node:stream/promises';
8
8
  import { randomIntAsync, sha256 } from '../crypto/core/index.js';
9
+ import { WaMediaTransferClient } from '../media/transfer/WaMediaTransferClient.js';
10
+ import { resolveMediaPayload } from '../message/encode/media-payload.js';
11
+ import { toProxyAgent } from '../transport/proxy.js';
9
12
  import { bytesToBase64UrlSafe, TEXT_DECODER, toBytesView, toChunkBytes } from '../util/bytes.js';
10
13
  import { toError } from '../util/primitives.js';
11
14
  export async function readFileHead(filePath, bytes) {
@@ -60,8 +63,8 @@ export function parseWebpAnimation(data) {
60
63
  }
61
64
  return null;
62
65
  }
63
- const IMAGE_THUMB_MAX_EDGE = 320;
64
- const VIDEO_THUMB_MAX_EDGE = 48;
66
+ const IMAGE_THUMB_MAX_EDGE = 100;
67
+ const VIDEO_THUMB_MAX_EDGE = 100;
65
68
  const STICKER_THUMB_MAX_EDGE = 100;
66
69
  const EMPTY_PROCESSED = {};
67
70
  export function isReadableStream(value) {
@@ -382,3 +385,59 @@ export async function runMediaProcessor(media, input, content, logger) {
382
385
  }
383
386
  return result;
384
387
  }
388
+ /**
389
+ * Streams and decrypts the media attached to a message without a connected
390
+ * `WaClient`. Resolves the encrypted payload (directPath, mediaKey, file
391
+ * hashes) from `source`, fetches the ciphertext from the WhatsApp media CDN,
392
+ * and decrypts it on the fly.
393
+ *
394
+ * The media keys come from the (already decrypted) message itself, so this is
395
+ * for re-downloading media you have persisted - not for fetching media you
396
+ * never received. The CDN download needs no session or auth token; only the
397
+ * upload path does.
398
+ *
399
+ * **The caller owns the returned stream** - pipe it somewhere or call
400
+ * `.destroy()` to release the socket; an unconsumed stream leaks the
401
+ * connection. MAC + SHA-256 verification runs as bytes are consumed, so
402
+ * aborting mid-read leaves you with unverified bytes. Pass `options.signal`
403
+ * to cancel cleanly.
404
+ *
405
+ * @throws when `source` carries no downloadable media.
406
+ * @example
407
+ * ```ts
408
+ * import { downloadMediaMessage } from '..'
409
+ * import { createWriteStream } from 'node:fs'
410
+ *
411
+ * const stream = await downloadMediaMessage(event)
412
+ * stream.pipe(createWriteStream('photo.jpg'))
413
+ * ```
414
+ * @example
415
+ * ```ts
416
+ * // Route the CDN download through an http.Agent-style proxy
417
+ * import { HttpsProxyAgent } from 'https-proxy-agent'
418
+ *
419
+ * const stream = await downloadMediaMessage(event, {
420
+ * proxy: new HttpsProxyAgent('http://127.0.0.1:8080')
421
+ * })
422
+ * ```
423
+ */
424
+ export async function downloadMediaMessage(source, options = {}) {
425
+ const message = 'rawNode' in source ? source.message : source;
426
+ const payload = resolveMediaPayload(message);
427
+ if (!payload) {
428
+ throw new Error('message has no downloadable media');
429
+ }
430
+ const transfer = options.transfer ?? new WaMediaTransferClient();
431
+ const { plaintext } = await transfer.downloadAndDecryptStream({
432
+ directPath: payload.directPath,
433
+ mediaType: payload.mediaType,
434
+ mediaKey: payload.mediaKey,
435
+ fileSha256: payload.fileSha256,
436
+ fileEncSha256: payload.fileEncSha256,
437
+ agent: toProxyAgent(options.proxy),
438
+ timeoutMs: options.timeoutMs,
439
+ signal: options.signal,
440
+ maxBytes: options.maxBytes
441
+ });
442
+ return plaintext;
443
+ }
@@ -4,6 +4,7 @@ import { toError } from '../../util/primitives.js';
4
4
  export function createGroupMetadataCache(options) {
5
5
  const { groupMetadataStore, queryGroupMetadata, logger } = options;
6
6
  const dedup = new PromiseDedup();
7
+ const pendingMutations = new Map();
7
8
  const sanitizeParticipantUsers = (participants) => {
8
9
  const deduped = new Set();
9
10
  for (const participant of participants) {
@@ -106,14 +107,9 @@ export function createGroupMetadataCache(options) {
106
107
  const extractParticipantUsersFromGroupEvent = (event) => {
107
108
  const candidates = [];
108
109
  for (const participant of event.participants ?? []) {
109
- if (participant.jid) {
110
- candidates.push(participant.jid);
111
- }
112
- if (participant.lidJid) {
113
- candidates.push(participant.lidJid);
114
- }
115
- if (participant.phoneJid) {
116
- candidates.push(participant.phoneJid);
110
+ const canonical = participant.jid ?? participant.lidJid ?? participant.phoneJid;
111
+ if (canonical) {
112
+ candidates.push(canonical);
117
113
  }
118
114
  }
119
115
  return sanitizeParticipantUsers(candidates);
@@ -130,6 +126,7 @@ export function createGroupMetadataCache(options) {
130
126
  return participants;
131
127
  });
132
128
  const resolveParticipantUsers = (groupJid) => dedup.run(`resolve:${groupJid}`, async () => {
129
+ await pendingMutations.get(groupJid)?.catch(() => undefined);
133
130
  const cached = await groupMetadataStore.getGroupMetadata(groupJid);
134
131
  if (cached && cached.participants.length > 0) {
135
132
  return sanitizeParticipantUsers(cached.participants);
@@ -149,7 +146,7 @@ export function createGroupMetadataCache(options) {
149
146
  const refreshed = await groupMetadataStore.getGroupMetadata(groupJid);
150
147
  return refreshed?.ephemeral ?? null;
151
148
  };
152
- const mutateFromGroupEvent = async (event) => {
149
+ const applyGroupEvent = async (event) => {
153
150
  const groupJid = resolveGroupJidForGroupCacheEvent(event);
154
151
  if (!groupJid) {
155
152
  return;
@@ -218,6 +215,20 @@ export function createGroupMetadataCache(options) {
218
215
  await replaceParticipantUsersInCache(groupJid, cachedWithSanitized, authorUsers, participantUsers);
219
216
  }
220
217
  };
218
+ const mutateFromGroupEvent = (event) => {
219
+ const groupJid = resolveGroupJidForGroupCacheEvent(event);
220
+ if (!groupJid) {
221
+ return applyGroupEvent(event);
222
+ }
223
+ const prev = pendingMutations.get(groupJid) ?? Promise.resolve();
224
+ const next = prev.then(() => applyGroupEvent(event), () => applyGroupEvent(event));
225
+ pendingMutations.set(groupJid, next);
226
+ return next.finally(() => {
227
+ if (pendingMutations.get(groupJid) === next) {
228
+ pendingMutations.delete(groupJid);
229
+ }
230
+ });
231
+ };
221
232
  return {
222
233
  resolveParticipantUsers,
223
234
  refreshParticipantUsers,
package/dist/esm/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export { WaClient } from './client/index.js';
2
+ export { downloadMediaMessage } from './client/media.js';
2
3
  export { parseUsyncResultEnvelope } from './transport/node/builders/usync.js';
3
4
  export { getContentType, resolveMessageTarget } from './message/encode/content.js';
5
+ export { resolveMediaPayload } from './message/encode/media-payload.js';
4
6
  export { fetchLatestWaWebVersion } from './transport/wa-web-version-fetcher.js';
5
7
  export { ConsoleLogger } from './infra/log/ConsoleLogger.js';
6
8
  export { PinoLogger, createPinoLogger } from './infra/log/PinoLogger.js';