zapo-js 0.1.2 → 0.2.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 (468) hide show
  1. package/README.md +12 -4
  2. package/dist/appstate/WaAppStateCrypto.js +1 -1
  3. package/dist/appstate/WaAppStateSyncClient.js +138 -93
  4. package/dist/appstate/{store/sqlite.js → encoding.js} +13 -8
  5. package/dist/appstate/index.js +8 -6
  6. package/dist/appstate/utils.js +0 -5
  7. package/dist/auth/WaAuthClient.js +36 -47
  8. package/dist/auth/flow/WaAuthCredentialsFlow.js +7 -7
  9. package/dist/auth/index.js +1 -6
  10. package/dist/auth/pairing/WaPairingCodeCrypto.js +6 -4
  11. package/dist/auth/pairing/WaPairingFlow.js +13 -3
  12. package/dist/client/WaClient.js +225 -101
  13. package/dist/client/WaClientFactory.js +294 -44
  14. package/dist/client/connection/WaConnectionManager.js +19 -10
  15. package/dist/client/coordinators/WaBusinessCoordinator.js +241 -0
  16. package/dist/client/coordinators/WaGroupCoordinator.js +11 -7
  17. package/dist/client/coordinators/WaIncomingNodeCoordinator.js +1 -0
  18. package/dist/client/coordinators/WaMessageDispatchCoordinator.js +292 -99
  19. package/dist/client/coordinators/WaPassiveTasksCoordinator.js +74 -31
  20. package/dist/client/coordinators/WaPrivacyCoordinator.js +134 -0
  21. package/dist/client/coordinators/WaProfileCoordinator.js +212 -0
  22. package/dist/client/coordinators/WaRetryCoordinator.js +179 -27
  23. package/dist/client/coordinators/WaStreamControlCoordinator.js +18 -11
  24. package/dist/client/coordinators/WaTrustedContactTokenCoordinator.js +166 -0
  25. package/dist/client/dirty.js +40 -20
  26. package/dist/client/events/devices.js +72 -0
  27. package/dist/client/events/group.js +3 -11
  28. package/dist/client/events/identity.js +22 -0
  29. package/dist/client/events/privacy-token.js +39 -0
  30. package/dist/client/history-sync.js +50 -9
  31. package/dist/client/incoming.js +37 -7
  32. package/dist/client/mailbox.js +24 -23
  33. package/dist/client/messages.js +107 -31
  34. package/dist/client/messaging/fanout.js +21 -11
  35. package/dist/client/messaging/participants.js +6 -4
  36. package/dist/client/persistence/WriteBehindPersistence.js +129 -0
  37. package/dist/client/tokens/cs-token.js +50 -0
  38. package/dist/client/tokens/tc-token.js +25 -0
  39. package/dist/crypto/core/index.js +2 -2
  40. package/dist/crypto/core/keys.js +4 -4
  41. package/dist/crypto/core/nonce.js +2 -0
  42. package/dist/crypto/core/primitives.js +0 -8
  43. package/dist/crypto/core/random.js +22 -0
  44. package/dist/crypto/curves/X25519.js +25 -6
  45. package/dist/crypto/index.js +3 -0
  46. package/dist/crypto/math/constants.js +13 -36
  47. package/dist/crypto/math/edwards.js +171 -44
  48. package/dist/crypto/math/fe.js +706 -0
  49. package/dist/crypto/math/mod.js +10 -3
  50. package/dist/esm/appstate/WaAppStateCrypto.js +1 -1
  51. package/dist/esm/appstate/WaAppStateSyncClient.js +138 -93
  52. package/dist/esm/appstate/{store/sqlite.js → encoding.js} +13 -8
  53. package/dist/esm/appstate/index.js +2 -2
  54. package/dist/esm/appstate/utils.js +2 -5
  55. package/dist/esm/auth/WaAuthClient.js +36 -47
  56. package/dist/esm/auth/flow/WaAuthCredentialsFlow.js +7 -7
  57. package/dist/esm/auth/index.js +0 -2
  58. package/dist/esm/auth/pairing/WaPairingCodeCrypto.js +6 -4
  59. package/dist/esm/auth/pairing/WaPairingFlow.js +14 -4
  60. package/dist/esm/client/WaClient.js +225 -101
  61. package/dist/esm/client/WaClientFactory.js +295 -45
  62. package/dist/esm/client/connection/WaConnectionManager.js +19 -10
  63. package/dist/esm/client/coordinators/WaBusinessCoordinator.js +238 -0
  64. package/dist/esm/client/coordinators/WaGroupCoordinator.js +11 -7
  65. package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +1 -0
  66. package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +295 -102
  67. package/dist/esm/client/coordinators/WaPassiveTasksCoordinator.js +74 -31
  68. package/dist/esm/client/coordinators/WaPrivacyCoordinator.js +131 -0
  69. package/dist/esm/client/coordinators/WaProfileCoordinator.js +209 -0
  70. package/dist/esm/client/coordinators/WaRetryCoordinator.js +181 -29
  71. package/dist/esm/client/coordinators/WaStreamControlCoordinator.js +19 -12
  72. package/dist/esm/client/coordinators/WaTrustedContactTokenCoordinator.js +162 -0
  73. package/dist/esm/client/dirty.js +40 -20
  74. package/dist/esm/client/events/devices.js +68 -0
  75. package/dist/esm/client/events/group.js +3 -11
  76. package/dist/esm/client/events/identity.js +19 -0
  77. package/dist/esm/client/events/privacy-token.js +36 -0
  78. package/dist/esm/client/history-sync.js +50 -9
  79. package/dist/esm/client/incoming.js +38 -8
  80. package/dist/esm/client/mailbox.js +24 -23
  81. package/dist/esm/client/messages.js +108 -32
  82. package/dist/esm/client/messaging/fanout.js +22 -12
  83. package/dist/esm/client/messaging/participants.js +6 -4
  84. package/dist/esm/client/persistence/WriteBehindPersistence.js +125 -0
  85. package/dist/esm/client/tokens/cs-token.js +46 -0
  86. package/dist/esm/client/tokens/tc-token.js +18 -0
  87. package/dist/esm/crypto/core/index.js +2 -2
  88. package/dist/esm/crypto/core/keys.js +1 -1
  89. package/dist/esm/crypto/core/nonce.js +2 -0
  90. package/dist/esm/crypto/core/primitives.js +0 -7
  91. package/dist/esm/crypto/core/random.js +22 -1
  92. package/dist/esm/crypto/curves/X25519.js +25 -6
  93. package/dist/esm/crypto/index.js +1 -0
  94. package/dist/esm/crypto/math/constants.js +12 -35
  95. package/dist/esm/crypto/math/edwards.js +174 -47
  96. package/dist/esm/crypto/math/fe.js +691 -0
  97. package/dist/esm/crypto/math/mod.js +10 -1
  98. package/dist/esm/index.js +1 -1
  99. package/dist/esm/infra/perf/BackgroundQueue.js +478 -0
  100. package/dist/esm/infra/perf/BoundedTaskQueue.js +3 -1
  101. package/dist/esm/infra/perf/PromiseDedup.js +20 -0
  102. package/dist/esm/infra/perf/SharedExclusiveGate.js +109 -0
  103. package/dist/esm/infra/perf/StoreLock.js +77 -0
  104. package/dist/esm/media/WaMediaCrypto.js +95 -13
  105. package/dist/esm/media/WaMediaTransferClient.js +39 -47
  106. package/dist/esm/media/constants.js +2 -1
  107. package/dist/esm/message/WaMessageClient.js +26 -19
  108. package/dist/esm/message/content.js +195 -9
  109. package/dist/esm/message/icdc.js +76 -0
  110. package/dist/esm/message/incoming.js +24 -12
  111. package/dist/esm/message/phash.js +3 -1
  112. package/dist/esm/message/reporting-token.js +14 -27
  113. package/dist/esm/protocol/appstate.js +9 -40
  114. package/dist/esm/protocol/browser.js +10 -18
  115. package/dist/esm/protocol/constants.js +5 -3
  116. package/dist/esm/protocol/defaults.js +6 -0
  117. package/dist/esm/protocol/index.js +1 -2
  118. package/dist/esm/protocol/jid.js +105 -36
  119. package/dist/esm/protocol/message.js +61 -1
  120. package/dist/esm/protocol/nodes.js +2 -0
  121. package/dist/esm/protocol/notification.js +3 -1
  122. package/dist/esm/protocol/privacy-token.js +17 -0
  123. package/dist/esm/protocol/privacy.js +55 -0
  124. package/dist/esm/protocol/stream.js +26 -1
  125. package/dist/esm/retry/codec.js +216 -0
  126. package/dist/esm/retry/constants.js +1 -1
  127. package/dist/esm/retry/index.js +2 -2
  128. package/dist/esm/retry/parse.js +50 -30
  129. package/dist/esm/retry/replay.js +11 -7
  130. package/dist/esm/retry/tracker.js +50 -12
  131. package/dist/esm/signal/api/SignalDeviceSyncApi.js +49 -32
  132. package/dist/esm/signal/api/SignalDigestSyncApi.js +13 -9
  133. package/dist/esm/signal/api/SignalIdentitySyncApi.js +26 -11
  134. package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +18 -7
  135. package/dist/esm/signal/api/SignalRotateKeyApi.js +4 -2
  136. package/dist/esm/signal/api/SignalSessionSyncApi.js +16 -7
  137. package/dist/esm/signal/api/result-map.js +10 -0
  138. package/dist/esm/signal/constants.js +0 -4
  139. package/dist/esm/signal/crypto/WaAdvSignature.js +12 -6
  140. package/dist/esm/signal/{store/sqlite.js → encoding.js} +78 -24
  141. package/dist/esm/signal/group/SenderKeyCodec.js +3 -2
  142. package/dist/esm/signal/group/SenderKeyManager.js +125 -106
  143. package/dist/esm/signal/index.js +1 -0
  144. package/dist/esm/signal/registration/keygen.js +6 -2
  145. package/dist/esm/signal/registration/utils.js +1 -0
  146. package/dist/esm/signal/session/SignalProtocol.js +150 -74
  147. package/dist/esm/signal/session/resolver.js +137 -102
  148. package/dist/esm/store/contracts/privacy-token.store.js +1 -0
  149. package/dist/esm/store/createStore.js +101 -187
  150. package/dist/esm/store/index.js +1 -10
  151. package/dist/esm/store/locks/appstate.lock.js +26 -0
  152. package/dist/esm/store/locks/auth.lock.js +15 -0
  153. package/dist/esm/store/locks/contact.lock.js +20 -0
  154. package/dist/esm/store/locks/device-list.lock.js +20 -0
  155. package/dist/esm/store/locks/message.lock.js +21 -0
  156. package/dist/esm/store/locks/participants.lock.js +20 -0
  157. package/dist/esm/store/locks/privacy-token.lock.js +18 -0
  158. package/dist/esm/store/locks/retry.lock.js +29 -0
  159. package/dist/esm/store/locks/sender-key.lock.js +52 -0
  160. package/dist/esm/store/locks/signal.lock.js +63 -0
  161. package/dist/esm/store/locks/thread.lock.js +21 -0
  162. package/dist/esm/store/noop.store.js +1 -1
  163. package/dist/esm/store/providers/memory/appstate.store.js +22 -24
  164. package/dist/esm/store/providers/memory/device-list.store.js +10 -5
  165. package/dist/esm/store/providers/memory/privacy-token.store.js +43 -0
  166. package/dist/esm/store/providers/memory/retry.store.js +77 -2
  167. package/dist/esm/store/providers/memory/sender-key.store.js +6 -1
  168. package/dist/esm/store/providers/memory/signal.store.js +36 -19
  169. package/dist/esm/transport/WaComms.js +3 -1
  170. package/dist/esm/transport/WaWebSocket.js +0 -6
  171. package/dist/esm/transport/binary/constants.js +0 -30
  172. package/dist/esm/transport/binary/decoder.js +4 -4
  173. package/dist/esm/transport/binary/encoder.js +8 -15
  174. package/dist/esm/transport/binary/index.js +0 -1
  175. package/dist/esm/transport/node/WaNodeOrchestrator.js +25 -19
  176. package/dist/esm/transport/node/builders/business.js +129 -0
  177. package/dist/esm/transport/node/builders/global.js +370 -0
  178. package/dist/esm/transport/node/builders/index.js +5 -2
  179. package/dist/esm/transport/node/builders/message.js +63 -239
  180. package/dist/esm/transport/node/builders/pairing.js +0 -24
  181. package/dist/esm/transport/node/builders/privacy-token.js +41 -0
  182. package/dist/esm/transport/node/builders/privacy.js +48 -0
  183. package/dist/esm/transport/node/builders/profile.js +70 -0
  184. package/dist/esm/transport/node/builders/retry.js +10 -22
  185. package/dist/esm/transport/node/builders/usync.js +6 -2
  186. package/dist/esm/transport/node/helpers.js +19 -1
  187. package/dist/esm/transport/node/usync.js +3 -33
  188. package/dist/esm/transport/node/xml.js +35 -14
  189. package/dist/esm/transport/noise/WaClientPayload.js +10 -10
  190. package/dist/esm/transport/noise/WaNoiseCert.js +3 -3
  191. package/dist/esm/transport/noise/WaNoiseSession.js +64 -23
  192. package/dist/esm/transport/noise/WaNoiseSocket.js +8 -4
  193. package/dist/esm/transport/stream/parse.js +8 -4
  194. package/dist/esm/util/bytes.js +22 -18
  195. package/dist/esm/util/index.js +5 -0
  196. package/dist/esm/util/primitives.js +3 -2
  197. package/dist/index.js +7 -1
  198. package/dist/infra/perf/BackgroundQueue.js +482 -0
  199. package/dist/infra/perf/BoundedTaskQueue.js +3 -1
  200. package/dist/infra/perf/PromiseDedup.js +24 -0
  201. package/dist/infra/perf/SharedExclusiveGate.js +113 -0
  202. package/dist/infra/perf/StoreLock.js +81 -0
  203. package/dist/media/WaMediaCrypto.js +94 -12
  204. package/dist/media/WaMediaTransferClient.js +39 -47
  205. package/dist/media/constants.js +2 -1
  206. package/dist/message/WaMessageClient.js +26 -19
  207. package/dist/message/content.js +198 -9
  208. package/dist/message/icdc.js +81 -0
  209. package/dist/message/incoming.js +24 -12
  210. package/dist/message/phash.js +3 -1
  211. package/dist/message/reporting-token.js +14 -28
  212. package/dist/protocol/appstate.js +10 -41
  213. package/dist/protocol/browser.js +10 -18
  214. package/dist/protocol/constants.js +21 -2
  215. package/dist/protocol/defaults.js +6 -0
  216. package/dist/protocol/index.js +8 -5
  217. package/dist/protocol/jid.js +111 -36
  218. package/dist/protocol/message.js +62 -2
  219. package/dist/protocol/nodes.js +2 -0
  220. package/dist/protocol/notification.js +3 -1
  221. package/dist/protocol/privacy-token.js +20 -0
  222. package/dist/protocol/privacy.js +58 -0
  223. package/dist/protocol/stream.js +27 -2
  224. package/dist/retry/codec.js +220 -0
  225. package/dist/retry/constants.js +1 -1
  226. package/dist/retry/index.js +5 -5
  227. package/dist/retry/parse.js +51 -30
  228. package/dist/retry/replay.js +10 -6
  229. package/dist/retry/tracker.js +50 -12
  230. package/dist/signal/api/SignalDeviceSyncApi.js +48 -31
  231. package/dist/signal/api/SignalDigestSyncApi.js +13 -9
  232. package/dist/signal/api/SignalIdentitySyncApi.js +25 -10
  233. package/dist/signal/api/SignalMissingPreKeysSyncApi.js +17 -6
  234. package/dist/signal/api/SignalRotateKeyApi.js +4 -2
  235. package/dist/signal/api/SignalSessionSyncApi.js +16 -7
  236. package/dist/signal/api/result-map.js +13 -0
  237. package/dist/signal/constants.js +1 -5
  238. package/dist/signal/crypto/WaAdvSignature.js +11 -5
  239. package/dist/signal/{store/sqlite.js → encoding.js} +79 -25
  240. package/dist/signal/group/SenderKeyCodec.js +4 -3
  241. package/dist/signal/group/SenderKeyManager.js +125 -106
  242. package/dist/signal/index.js +13 -1
  243. package/dist/signal/registration/keygen.js +6 -2
  244. package/dist/signal/registration/utils.js +1 -0
  245. package/dist/signal/session/SignalProtocol.js +150 -74
  246. package/dist/signal/session/resolver.js +135 -100
  247. package/dist/store/contracts/privacy-token.store.js +2 -0
  248. package/dist/store/createStore.js +101 -187
  249. package/dist/store/index.js +15 -33
  250. package/dist/store/locks/appstate.lock.js +29 -0
  251. package/dist/store/locks/auth.lock.js +18 -0
  252. package/dist/store/locks/contact.lock.js +23 -0
  253. package/dist/store/locks/device-list.lock.js +23 -0
  254. package/dist/store/locks/message.lock.js +24 -0
  255. package/dist/store/locks/participants.lock.js +23 -0
  256. package/dist/store/locks/privacy-token.lock.js +21 -0
  257. package/dist/store/locks/retry.lock.js +32 -0
  258. package/dist/store/locks/sender-key.lock.js +55 -0
  259. package/dist/store/locks/signal.lock.js +66 -0
  260. package/dist/store/locks/thread.lock.js +24 -0
  261. package/dist/store/noop.store.js +1 -1
  262. package/dist/store/providers/memory/appstate.store.js +22 -24
  263. package/dist/store/providers/memory/device-list.store.js +10 -5
  264. package/dist/store/providers/memory/privacy-token.store.js +47 -0
  265. package/dist/store/providers/memory/retry.store.js +77 -2
  266. package/dist/store/providers/memory/sender-key.store.js +6 -1
  267. package/dist/store/providers/memory/signal.store.js +36 -19
  268. package/dist/transport/WaComms.js +3 -1
  269. package/dist/transport/WaWebSocket.js +0 -6
  270. package/dist/transport/binary/constants.js +1 -31
  271. package/dist/transport/binary/decoder.js +4 -4
  272. package/dist/transport/binary/encoder.js +8 -15
  273. package/dist/transport/binary/index.js +0 -4
  274. package/dist/transport/node/WaNodeOrchestrator.js +24 -18
  275. package/dist/transport/node/builders/business.js +137 -0
  276. package/dist/transport/node/builders/global.js +375 -0
  277. package/dist/transport/node/builders/index.js +18 -9
  278. package/dist/transport/node/builders/message.js +64 -245
  279. package/dist/transport/node/builders/pairing.js +0 -26
  280. package/dist/transport/node/builders/privacy-token.js +46 -0
  281. package/dist/transport/node/builders/privacy.js +55 -0
  282. package/dist/transport/node/builders/profile.js +78 -0
  283. package/dist/transport/node/builders/retry.js +9 -21
  284. package/dist/transport/node/builders/usync.js +6 -2
  285. package/dist/transport/node/helpers.js +20 -1
  286. package/dist/transport/node/usync.js +2 -32
  287. package/dist/transport/node/xml.js +35 -14
  288. package/dist/transport/noise/WaClientPayload.js +13 -13
  289. package/dist/transport/noise/WaNoiseCert.js +2 -2
  290. package/dist/transport/noise/WaNoiseSession.js +64 -23
  291. package/dist/transport/noise/WaNoiseSocket.js +8 -4
  292. package/dist/transport/stream/parse.js +7 -3
  293. package/dist/types/appstate/encoding.d.ts +7 -0
  294. package/dist/types/appstate/index.d.ts +3 -3
  295. package/dist/types/appstate/utils.d.ts +0 -2
  296. package/dist/types/auth/flow/WaAuthCredentialsFlow.d.ts +1 -1
  297. package/dist/types/auth/index.d.ts +0 -2
  298. package/dist/types/auth/types.d.ts +1 -0
  299. package/dist/types/client/WaClient.d.ts +27 -12
  300. package/dist/types/client/WaClientFactory.d.ts +12 -4
  301. package/dist/types/client/connection/WaConnectionManager.d.ts +2 -0
  302. package/dist/types/client/coordinators/WaBusinessCoordinator.d.ts +57 -0
  303. package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +3 -1
  304. package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +14 -0
  305. package/dist/types/client/coordinators/WaPassiveTasksCoordinator.d.ts +4 -0
  306. package/dist/types/client/coordinators/WaPrivacyCoordinator.d.ts +26 -0
  307. package/dist/types/client/coordinators/WaProfileCoordinator.d.ts +36 -0
  308. package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +6 -0
  309. package/dist/types/client/coordinators/WaStreamControlCoordinator.d.ts +3 -2
  310. package/dist/types/client/coordinators/WaTrustedContactTokenCoordinator.d.ts +45 -0
  311. package/dist/types/client/events/devices.d.ts +20 -0
  312. package/dist/types/client/events/identity.d.ts +9 -0
  313. package/dist/types/client/events/privacy-token.d.ts +7 -0
  314. package/dist/types/client/history-sync.d.ts +9 -6
  315. package/dist/types/client/incoming.d.ts +3 -1
  316. package/dist/types/client/index.d.ts +1 -1
  317. package/dist/types/client/mailbox.d.ts +3 -5
  318. package/dist/types/client/messages.d.ts +1 -2
  319. package/dist/types/client/persistence/WriteBehindPersistence.d.ts +34 -0
  320. package/dist/types/client/tokens/cs-token.d.ts +10 -0
  321. package/dist/types/client/tokens/tc-token.d.ts +5 -0
  322. package/dist/types/client/types.d.ts +51 -3
  323. package/dist/types/crypto/core/index.d.ts +2 -2
  324. package/dist/types/crypto/core/nonce.d.ts +2 -0
  325. package/dist/types/crypto/core/primitives.d.ts +0 -1
  326. package/dist/types/crypto/core/random.d.ts +1 -0
  327. package/dist/types/crypto/index.d.ts +1 -0
  328. package/dist/types/crypto/math/constants.d.ts +4 -2
  329. package/dist/types/crypto/math/fe.d.ts +30 -0
  330. package/dist/types/crypto/math/mod.d.ts +0 -2
  331. package/dist/types/crypto/math/types.d.ts +11 -4
  332. package/dist/types/index.d.ts +5 -3
  333. package/dist/types/infra/perf/BackgroundQueue.d.ts +58 -0
  334. package/dist/types/infra/perf/PromiseDedup.d.ts +4 -0
  335. package/dist/types/infra/perf/SharedExclusiveGate.d.ts +17 -0
  336. package/dist/types/infra/perf/StoreLock.d.ts +10 -0
  337. package/dist/types/media/WaMediaCrypto.d.ts +3 -2
  338. package/dist/types/media/WaMediaTransferClient.d.ts +3 -12
  339. package/dist/types/media/constants.d.ts +1 -1
  340. package/dist/types/media/index.d.ts +1 -1
  341. package/dist/types/media/types.d.ts +10 -2
  342. package/dist/types/message/content.d.ts +8 -0
  343. package/dist/types/message/icdc.d.ts +13 -0
  344. package/dist/types/message/reporting-token.d.ts +0 -1
  345. package/dist/types/message/types.d.ts +45 -6
  346. package/dist/types/protocol/appstate.d.ts +0 -11
  347. package/dist/types/protocol/constants.d.ts +7 -3
  348. package/dist/types/protocol/defaults.d.ts +6 -0
  349. package/dist/types/protocol/index.d.ts +1 -2
  350. package/dist/types/protocol/jid.d.ts +19 -2
  351. package/dist/types/protocol/message.d.ts +60 -0
  352. package/dist/types/protocol/nodes.d.ts +2 -0
  353. package/dist/types/protocol/notification.d.ts +2 -0
  354. package/dist/types/protocol/privacy-token.d.ts +17 -0
  355. package/dist/types/protocol/privacy.d.ts +75 -0
  356. package/dist/types/protocol/stream.d.ts +30 -0
  357. package/dist/types/retry/codec.d.ts +3 -0
  358. package/dist/types/retry/index.d.ts +3 -3
  359. package/dist/types/retry/parse.d.ts +5 -2
  360. package/dist/types/retry/tracker.d.ts +1 -0
  361. package/dist/types/retry/types.d.ts +6 -1
  362. package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +2 -1
  363. package/dist/types/signal/api/SignalDigestSyncApi.d.ts +6 -0
  364. package/dist/types/signal/api/SignalIdentitySyncApi.d.ts +2 -0
  365. package/dist/types/signal/api/SignalRotateKeyApi.d.ts +4 -5
  366. package/dist/types/signal/api/SignalSessionSyncApi.d.ts +8 -6
  367. package/dist/types/signal/api/result-map.d.ts +1 -0
  368. package/dist/types/signal/constants.d.ts +0 -3
  369. package/dist/types/signal/{store/sqlite.d.ts → encoding.d.ts} +3 -3
  370. package/dist/types/signal/group/SenderKeyManager.d.ts +10 -5
  371. package/dist/types/signal/index.d.ts +2 -0
  372. package/dist/types/signal/session/SignalProtocol.d.ts +10 -4
  373. package/dist/types/signal/session/resolver.d.ts +7 -2
  374. package/dist/types/store/contracts/appstate.store.d.ts +1 -1
  375. package/dist/types/store/contracts/privacy-token.store.d.ts +16 -0
  376. package/dist/types/store/contracts/retry.store.d.ts +7 -0
  377. package/dist/types/store/contracts/signal.store.d.ts +7 -0
  378. package/dist/types/store/createStore.d.ts +1 -1
  379. package/dist/types/store/index.d.ts +5 -13
  380. package/dist/types/store/locks/appstate.lock.d.ts +3 -0
  381. package/dist/types/store/locks/auth.lock.d.ts +3 -0
  382. package/dist/types/store/locks/contact.lock.d.ts +3 -0
  383. package/dist/types/store/locks/device-list.lock.d.ts +2 -0
  384. package/dist/types/store/locks/message.lock.d.ts +3 -0
  385. package/dist/types/store/locks/participants.lock.d.ts +2 -0
  386. package/dist/types/store/locks/privacy-token.lock.d.ts +2 -0
  387. package/dist/types/store/locks/retry.lock.d.ts +2 -0
  388. package/dist/types/store/locks/sender-key.lock.d.ts +3 -0
  389. package/dist/types/store/locks/signal.lock.d.ts +3 -0
  390. package/dist/types/store/locks/thread.lock.d.ts +3 -0
  391. package/dist/types/store/providers/memory/appstate.store.d.ts +1 -1
  392. package/dist/types/store/providers/memory/privacy-token.store.d.ts +13 -0
  393. package/dist/types/store/providers/memory/retry.store.d.ts +8 -0
  394. package/dist/types/store/providers/memory/signal.store.d.ts +2 -1
  395. package/dist/types/store/types.d.ts +49 -61
  396. package/dist/types/transport/WaWebSocket.d.ts +0 -1
  397. package/dist/types/transport/binary/constants.d.ts +0 -30
  398. package/dist/types/transport/binary/index.d.ts +0 -1
  399. package/dist/types/transport/node/WaNodeOrchestrator.d.ts +3 -4
  400. package/dist/types/transport/node/builders/business.d.ts +29 -0
  401. package/dist/types/transport/node/builders/global.d.ts +102 -0
  402. package/dist/types/transport/node/builders/index.d.ts +5 -2
  403. package/dist/types/transport/node/builders/message.d.ts +8 -7
  404. package/dist/types/transport/node/builders/pairing.d.ts +0 -2
  405. package/dist/types/transport/node/builders/privacy-token.d.ts +9 -0
  406. package/dist/types/transport/node/builders/privacy.d.ts +7 -0
  407. package/dist/types/transport/node/builders/profile.d.ts +8 -0
  408. package/dist/types/transport/node/builders/retry.d.ts +0 -1
  409. package/dist/types/transport/node/helpers.d.ts +5 -0
  410. package/dist/types/transport/noise/WaNoiseSession.d.ts +3 -2
  411. package/dist/types/transport/noise/WaNoiseSocket.d.ts +4 -2
  412. package/dist/types/util/bytes.d.ts +1 -1
  413. package/dist/types/util/index.d.ts +5 -0
  414. package/dist/types/util/primitives.d.ts +0 -1
  415. package/dist/util/bytes.js +22 -18
  416. package/dist/util/index.js +23 -0
  417. package/dist/util/primitives.js +2 -2
  418. package/package.json +29 -7
  419. package/proto/index.js +1 -1
  420. package/dist/crypto/core/constants.js +0 -4
  421. package/dist/esm/crypto/core/constants.js +0 -1
  422. package/dist/esm/retry/outbound.js +0 -82
  423. package/dist/esm/store/providers/sqlite/BaseSqliteStore.js +0 -37
  424. package/dist/esm/store/providers/sqlite/appstate.store.js +0 -250
  425. package/dist/esm/store/providers/sqlite/auth.store.js +0 -176
  426. package/dist/esm/store/providers/sqlite/connection.js +0 -245
  427. package/dist/esm/store/providers/sqlite/contact.store.js +0 -74
  428. package/dist/esm/store/providers/sqlite/device-list.store.js +0 -127
  429. package/dist/esm/store/providers/sqlite/message.store.js +0 -132
  430. package/dist/esm/store/providers/sqlite/migrations.js +0 -347
  431. package/dist/esm/store/providers/sqlite/participants.store.js +0 -77
  432. package/dist/esm/store/providers/sqlite/retry.store.js +0 -141
  433. package/dist/esm/store/providers/sqlite/sender-key.store.js +0 -198
  434. package/dist/esm/store/providers/sqlite/signal.store.js +0 -435
  435. package/dist/esm/store/providers/sqlite/table-names.js +0 -107
  436. package/dist/esm/store/providers/sqlite/thread.store.js +0 -85
  437. package/dist/retry/outbound.js +0 -87
  438. package/dist/store/providers/sqlite/BaseSqliteStore.js +0 -41
  439. package/dist/store/providers/sqlite/appstate.store.js +0 -254
  440. package/dist/store/providers/sqlite/auth.store.js +0 -180
  441. package/dist/store/providers/sqlite/connection.js +0 -281
  442. package/dist/store/providers/sqlite/contact.store.js +0 -78
  443. package/dist/store/providers/sqlite/device-list.store.js +0 -131
  444. package/dist/store/providers/sqlite/message.store.js +0 -136
  445. package/dist/store/providers/sqlite/migrations.js +0 -350
  446. package/dist/store/providers/sqlite/participants.store.js +0 -81
  447. package/dist/store/providers/sqlite/retry.store.js +0 -145
  448. package/dist/store/providers/sqlite/sender-key.store.js +0 -202
  449. package/dist/store/providers/sqlite/signal.store.js +0 -439
  450. package/dist/store/providers/sqlite/table-names.js +0 -113
  451. package/dist/store/providers/sqlite/thread.store.js +0 -89
  452. package/dist/types/appstate/store/sqlite.d.ts +0 -7
  453. package/dist/types/crypto/core/constants.d.ts +0 -1
  454. package/dist/types/retry/outbound.d.ts +0 -4
  455. package/dist/types/store/providers/sqlite/BaseSqliteStore.d.ts +0 -12
  456. package/dist/types/store/providers/sqlite/appstate.store.d.ts +0 -17
  457. package/dist/types/store/providers/sqlite/auth.store.d.ts +0 -10
  458. package/dist/types/store/providers/sqlite/connection.d.ts +0 -10
  459. package/dist/types/store/providers/sqlite/contact.store.d.ts +0 -12
  460. package/dist/types/store/providers/sqlite/device-list.store.d.ts +0 -15
  461. package/dist/types/store/providers/sqlite/message.store.d.ts +0 -13
  462. package/dist/types/store/providers/sqlite/migrations.d.ts +0 -3
  463. package/dist/types/store/providers/sqlite/participants.store.d.ts +0 -12
  464. package/dist/types/store/providers/sqlite/retry.store.d.ts +0 -15
  465. package/dist/types/store/providers/sqlite/sender-key.store.d.ts +0 -24
  466. package/dist/types/store/providers/sqlite/signal.store.d.ts +0 -53
  467. package/dist/types/store/providers/sqlite/table-names.d.ts +0 -5
  468. package/dist/types/store/providers/sqlite/thread.store.d.ts +0 -13
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildUsyncUserNode = exports.buildUsyncIq = exports.buildLeaveGroupIq = exports.buildGroupParticipantChangeIq = exports.buildCreateGroupIq = exports.buildSignedPreKeyRotateIq = exports.buildPreKeyUploadIq = exports.buildMissingPreKeysFetchIq = exports.buildRetryReceiptNode = exports.buildInboundRetryReceiptAckNode = exports.buildInboundRetryReceiptNode = exports.buildInboundReceiptAckNode = exports.buildInboundMessageAckNode = exports.buildInboundDeliveryReceiptNode = exports.buildGroupSenderKeyMessageNode = exports.buildGroupRetryMessageNode = exports.buildGroupDirectMessageNode = exports.buildDirectMessageFanoutNode = exports.buildMediaConnIq = exports.buildNotificationAckNode = exports.buildIqResultNode = exports.buildGetCountryCodeRequestNode = exports.buildCompanionHelloRequestNode = exports.buildCompanionFinishRequestNode = exports.buildNewsletterMetadataSyncIq = exports.buildGroupsDirtySyncIq = exports.buildClearDirtyBitsIq = exports.buildAccountPrivacySyncIq = exports.buildAccountPictureSyncIq = exports.buildAccountDevicesSyncIq = exports.buildAccountBlocklistSyncIq = void 0;
3
+ exports.WA_BUSINESS_PROFILE_VERSION = exports.buildUpdateCoverPhotoIq = exports.buildGetVerifiedNameIq = exports.buildGetBusinessProfileIq = exports.buildEditBusinessProfileIq = exports.buildDeleteCoverPhotoIq = exports.buildSetProfilePictureIq = exports.buildGetStatusUsyncQueryNodes = exports.buildGetProfilePictureIq = exports.buildDeleteProfilePictureIq = exports.buildUsyncUserNode = exports.buildUsyncIq = exports.buildLeaveGroupIq = exports.buildGroupParticipantChangeIq = exports.buildCreateGroupIq = exports.buildSignedPreKeyRotateIq = exports.buildPreKeyUploadIq = exports.buildMissingPreKeysFetchIq = exports.buildRetryReceiptNode = exports.buildMetaNode = exports.buildGroupSenderKeyMessageNode = exports.buildGroupRetryMessageNode = exports.buildDirectMessageFanoutNode = exports.buildMediaConnIq = exports.buildIqResultNode = exports.buildReceiptNode = exports.buildAckNode = exports.buildGetCountryCodeRequestNode = exports.buildCompanionHelloRequestNode = exports.buildCompanionFinishRequestNode = exports.buildNewsletterMetadataSyncIq = exports.buildGroupsDirtySyncIq = exports.buildClearDirtyBitsIq = exports.buildAccountPrivacySyncIq = exports.buildAccountPictureSyncIq = exports.buildAccountDevicesSyncIq = exports.buildAccountBlocklistSyncIq = void 0;
4
4
  var account_sync_1 = require("../../node/builders/account-sync");
5
5
  Object.defineProperty(exports, "buildAccountBlocklistSyncIq", { enumerable: true, get: function () { return account_sync_1.buildAccountBlocklistSyncIq; } });
6
6
  Object.defineProperty(exports, "buildAccountDevicesSyncIq", { enumerable: true, get: function () { return account_sync_1.buildAccountDevicesSyncIq; } });
@@ -13,20 +13,17 @@ var pairing_1 = require("../../node/builders/pairing");
13
13
  Object.defineProperty(exports, "buildCompanionFinishRequestNode", { enumerable: true, get: function () { return pairing_1.buildCompanionFinishRequestNode; } });
14
14
  Object.defineProperty(exports, "buildCompanionHelloRequestNode", { enumerable: true, get: function () { return pairing_1.buildCompanionHelloRequestNode; } });
15
15
  Object.defineProperty(exports, "buildGetCountryCodeRequestNode", { enumerable: true, get: function () { return pairing_1.buildGetCountryCodeRequestNode; } });
16
- Object.defineProperty(exports, "buildIqResultNode", { enumerable: true, get: function () { return pairing_1.buildIqResultNode; } });
17
- Object.defineProperty(exports, "buildNotificationAckNode", { enumerable: true, get: function () { return pairing_1.buildNotificationAckNode; } });
16
+ var global_1 = require("../../node/builders/global");
17
+ Object.defineProperty(exports, "buildAckNode", { enumerable: true, get: function () { return global_1.buildAckNode; } });
18
+ Object.defineProperty(exports, "buildReceiptNode", { enumerable: true, get: function () { return global_1.buildReceiptNode; } });
19
+ Object.defineProperty(exports, "buildIqResultNode", { enumerable: true, get: function () { return global_1.buildIqResultNode; } });
18
20
  var media_1 = require("../../node/builders/media");
19
21
  Object.defineProperty(exports, "buildMediaConnIq", { enumerable: true, get: function () { return media_1.buildMediaConnIq; } });
20
22
  var message_1 = require("../../node/builders/message");
21
23
  Object.defineProperty(exports, "buildDirectMessageFanoutNode", { enumerable: true, get: function () { return message_1.buildDirectMessageFanoutNode; } });
22
- Object.defineProperty(exports, "buildGroupDirectMessageNode", { enumerable: true, get: function () { return message_1.buildGroupDirectMessageNode; } });
23
24
  Object.defineProperty(exports, "buildGroupRetryMessageNode", { enumerable: true, get: function () { return message_1.buildGroupRetryMessageNode; } });
24
25
  Object.defineProperty(exports, "buildGroupSenderKeyMessageNode", { enumerable: true, get: function () { return message_1.buildGroupSenderKeyMessageNode; } });
25
- Object.defineProperty(exports, "buildInboundDeliveryReceiptNode", { enumerable: true, get: function () { return message_1.buildInboundDeliveryReceiptNode; } });
26
- Object.defineProperty(exports, "buildInboundMessageAckNode", { enumerable: true, get: function () { return message_1.buildInboundMessageAckNode; } });
27
- Object.defineProperty(exports, "buildInboundReceiptAckNode", { enumerable: true, get: function () { return message_1.buildInboundReceiptAckNode; } });
28
- Object.defineProperty(exports, "buildInboundRetryReceiptNode", { enumerable: true, get: function () { return message_1.buildInboundRetryReceiptNode; } });
29
- Object.defineProperty(exports, "buildInboundRetryReceiptAckNode", { enumerable: true, get: function () { return message_1.buildInboundRetryReceiptAckNode; } });
26
+ Object.defineProperty(exports, "buildMetaNode", { enumerable: true, get: function () { return message_1.buildMetaNode; } });
30
27
  var retry_1 = require("../../node/builders/retry");
31
28
  Object.defineProperty(exports, "buildRetryReceiptNode", { enumerable: true, get: function () { return retry_1.buildRetryReceiptNode; } });
32
29
  var prekeys_1 = require("../../node/builders/prekeys");
@@ -40,3 +37,15 @@ Object.defineProperty(exports, "buildLeaveGroupIq", { enumerable: true, get: fun
40
37
  var usync_1 = require("../../node/builders/usync");
41
38
  Object.defineProperty(exports, "buildUsyncIq", { enumerable: true, get: function () { return usync_1.buildUsyncIq; } });
42
39
  Object.defineProperty(exports, "buildUsyncUserNode", { enumerable: true, get: function () { return usync_1.buildUsyncUserNode; } });
40
+ var profile_1 = require("../../node/builders/profile");
41
+ Object.defineProperty(exports, "buildDeleteProfilePictureIq", { enumerable: true, get: function () { return profile_1.buildDeleteProfilePictureIq; } });
42
+ Object.defineProperty(exports, "buildGetProfilePictureIq", { enumerable: true, get: function () { return profile_1.buildGetProfilePictureIq; } });
43
+ Object.defineProperty(exports, "buildGetStatusUsyncQueryNodes", { enumerable: true, get: function () { return profile_1.buildGetStatusUsyncQueryNodes; } });
44
+ Object.defineProperty(exports, "buildSetProfilePictureIq", { enumerable: true, get: function () { return profile_1.buildSetProfilePictureIq; } });
45
+ var business_1 = require("../../node/builders/business");
46
+ Object.defineProperty(exports, "buildDeleteCoverPhotoIq", { enumerable: true, get: function () { return business_1.buildDeleteCoverPhotoIq; } });
47
+ Object.defineProperty(exports, "buildEditBusinessProfileIq", { enumerable: true, get: function () { return business_1.buildEditBusinessProfileIq; } });
48
+ Object.defineProperty(exports, "buildGetBusinessProfileIq", { enumerable: true, get: function () { return business_1.buildGetBusinessProfileIq; } });
49
+ Object.defineProperty(exports, "buildGetVerifiedNameIq", { enumerable: true, get: function () { return business_1.buildGetVerifiedNameIq; } });
50
+ Object.defineProperty(exports, "buildUpdateCoverPhotoIq", { enumerable: true, get: function () { return business_1.buildUpdateCoverPhotoIq; } });
51
+ Object.defineProperty(exports, "WA_BUSINESS_PROFILE_VERSION", { enumerable: true, get: function () { return business_1.WA_BUSINESS_PROFILE_VERSION; } });
@@ -2,18 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildDirectMessageFanoutNode = buildDirectMessageFanoutNode;
4
4
  exports.buildGroupSenderKeyMessageNode = buildGroupSenderKeyMessageNode;
5
- exports.buildGroupDirectMessageNode = buildGroupDirectMessageNode;
6
- exports.buildInboundMessageAckNode = buildInboundMessageAckNode;
7
- exports.buildInboundDeliveryReceiptNode = buildInboundDeliveryReceiptNode;
8
- exports.buildInboundRetryReceiptNode = buildInboundRetryReceiptNode;
9
- exports.buildInboundRetryReceiptAckNode = buildInboundRetryReceiptAckNode;
10
- exports.buildInboundReceiptAckNode = buildInboundReceiptAckNode;
11
5
  exports.buildGroupRetryMessageNode = buildGroupRetryMessageNode;
6
+ exports.buildMetaNode = buildMetaNode;
12
7
  const constants_1 = require("../../../protocol/constants");
13
- function buildDirectMessageFanoutNode(input) {
14
- if (input.participants.length === 0) {
15
- throw new Error('direct message fanout requires at least one participant');
8
+ function buildEncAttrs(encType, mediatype, retryCount) {
9
+ const attrs = {
10
+ v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
11
+ type: encType
12
+ };
13
+ if (mediatype) {
14
+ attrs.mediatype = mediatype;
15
+ }
16
+ if (retryCount !== undefined && retryCount > 0) {
17
+ attrs.count = String(Math.trunc(retryCount));
16
18
  }
19
+ return attrs;
20
+ }
21
+ function buildMessageAttrs(input) {
17
22
  const attrs = {
18
23
  to: input.to,
19
24
  type: input.type
@@ -21,28 +26,18 @@ function buildDirectMessageFanoutNode(input) {
21
26
  if (input.id) {
22
27
  attrs.id = input.id;
23
28
  }
24
- const content = [
25
- {
26
- tag: constants_1.WA_NODE_TAGS.PARTICIPANTS,
27
- attrs: {},
28
- content: input.participants.map((participant) => ({
29
- tag: 'to',
30
- attrs: {
31
- jid: participant.jid
32
- },
33
- content: [
34
- {
35
- tag: constants_1.WA_MESSAGE_TAGS.ENC,
36
- attrs: {
37
- v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
38
- type: participant.encType
39
- },
40
- content: participant.ciphertext
41
- }
42
- ]
43
- }))
44
- }
45
- ];
29
+ if (input.edit) {
30
+ attrs.edit = input.edit;
31
+ }
32
+ if (input.phash) {
33
+ attrs.phash = input.phash;
34
+ }
35
+ if (input.addressingMode) {
36
+ attrs.addressing_mode = input.addressingMode;
37
+ }
38
+ return attrs;
39
+ }
40
+ function pushOptionalNodes(content, input) {
46
41
  if (input.deviceIdentity) {
47
42
  content.push({
48
43
  tag: constants_1.WA_NODE_TAGS.DEVICE_IDENTITY,
@@ -50,32 +45,23 @@ function buildDirectMessageFanoutNode(input) {
50
45
  content: input.deviceIdentity
51
46
  });
52
47
  }
48
+ if (input.metaNode) {
49
+ content.push(input.metaNode);
50
+ }
53
51
  if (input.reportingNode) {
54
52
  content.push(input.reportingNode);
55
53
  }
56
- return {
57
- tag: constants_1.WA_MESSAGE_TAGS.MESSAGE,
58
- attrs,
59
- content
60
- };
61
- }
62
- function buildGroupSenderKeyMessageNode(input) {
63
- const attrs = {
64
- to: input.to,
65
- type: input.type
66
- };
67
- if (input.id) {
68
- attrs.id = input.id;
54
+ if (input.privacyTokenNode) {
55
+ content.push(input.privacyTokenNode);
69
56
  }
70
- if (input.phash) {
71
- attrs.phash = input.phash;
72
- }
73
- if (input.addressingMode) {
74
- attrs.addressing_mode = input.addressingMode;
57
+ }
58
+ function buildDirectMessageFanoutNode(input) {
59
+ if (input.participants.length === 0) {
60
+ throw new Error('direct message fanout requires at least one participant');
75
61
  }
76
- const content = [];
77
- if (input.participants.length > 0) {
78
- content.push({
62
+ const attrs = buildMessageAttrs(input);
63
+ const content = [
64
+ {
79
65
  tag: constants_1.WA_NODE_TAGS.PARTICIPANTS,
80
66
  attrs: {},
81
67
  content: input.participants.map((participant) => ({
@@ -86,59 +72,25 @@ function buildGroupSenderKeyMessageNode(input) {
86
72
  content: [
87
73
  {
88
74
  tag: constants_1.WA_MESSAGE_TAGS.ENC,
89
- attrs: {
90
- v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
91
- type: participant.encType
92
- },
75
+ attrs: buildEncAttrs(participant.encType, input.mediatype),
93
76
  content: participant.ciphertext
94
77
  }
95
78
  ]
96
79
  }))
97
- });
98
- }
99
- content.push({
100
- tag: constants_1.WA_MESSAGE_TAGS.ENC,
101
- attrs: {
102
- v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
103
- type: 'skmsg'
104
- },
105
- content: input.groupCiphertext
106
- });
107
- if (input.deviceIdentity) {
108
- content.push({
109
- tag: constants_1.WA_NODE_TAGS.DEVICE_IDENTITY,
110
- attrs: {},
111
- content: input.deviceIdentity
112
- });
113
- }
114
- if (input.reportingNode) {
115
- content.push(input.reportingNode);
116
- }
80
+ }
81
+ ];
82
+ pushOptionalNodes(content, input);
117
83
  return {
118
84
  tag: constants_1.WA_MESSAGE_TAGS.MESSAGE,
119
85
  attrs,
120
86
  content
121
87
  };
122
88
  }
123
- function buildGroupDirectMessageNode(input) {
124
- if (input.participants.length === 0) {
125
- throw new Error('group direct message requires at least one participant');
126
- }
127
- const attrs = {
128
- to: input.to,
129
- type: input.type
130
- };
131
- if (input.id) {
132
- attrs.id = input.id;
133
- }
134
- if (input.phash) {
135
- attrs.phash = input.phash;
136
- }
137
- if (input.addressingMode) {
138
- attrs.addressing_mode = input.addressingMode;
139
- }
140
- const content = [
141
- {
89
+ function buildGroupSenderKeyMessageNode(input) {
90
+ const attrs = buildMessageAttrs(input);
91
+ const content = [];
92
+ if (input.participants.length > 0) {
93
+ content.push({
142
94
  tag: constants_1.WA_NODE_TAGS.PARTICIPANTS,
143
95
  attrs: {},
144
96
  content: input.participants.map((participant) => ({
@@ -149,171 +101,31 @@ function buildGroupDirectMessageNode(input) {
149
101
  content: [
150
102
  {
151
103
  tag: constants_1.WA_MESSAGE_TAGS.ENC,
152
- attrs: {
153
- v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
154
- type: participant.encType
155
- },
104
+ attrs: buildEncAttrs(participant.encType, input.mediatype),
156
105
  content: participant.ciphertext
157
106
  }
158
107
  ]
159
108
  }))
160
- }
161
- ];
162
- if (input.deviceIdentity) {
163
- content.push({
164
- tag: constants_1.WA_NODE_TAGS.DEVICE_IDENTITY,
165
- attrs: {},
166
- content: input.deviceIdentity
167
109
  });
168
110
  }
169
- if (input.reportingNode) {
170
- content.push(input.reportingNode);
171
- }
111
+ content.push({
112
+ tag: constants_1.WA_MESSAGE_TAGS.ENC,
113
+ attrs: buildEncAttrs('skmsg', input.mediatype),
114
+ content: input.groupCiphertext
115
+ });
116
+ pushOptionalNodes(content, input);
172
117
  return {
173
118
  tag: constants_1.WA_MESSAGE_TAGS.MESSAGE,
174
119
  attrs,
175
120
  content
176
121
  };
177
122
  }
178
- function buildInboundMessageAckNode(messageNode, id, to, meJid) {
179
- const attrs = {
180
- id,
181
- to,
182
- class: constants_1.WA_MESSAGE_TYPES.ACK_CLASS_MESSAGE
183
- };
184
- if (messageNode.attrs.type) {
185
- attrs.type = messageNode.attrs.type;
186
- }
187
- if (messageNode.attrs.participant) {
188
- attrs.participant = messageNode.attrs.participant;
189
- }
190
- if (meJid) {
191
- attrs.from = meJid;
192
- }
193
- return {
194
- tag: constants_1.WA_MESSAGE_TAGS.ACK,
195
- attrs
196
- };
197
- }
198
- function buildInboundDeliveryReceiptNode(messageNode, id, to) {
199
- const attrs = {
200
- id,
201
- to
202
- };
203
- if (messageNode.attrs.participant) {
204
- attrs.participant = messageNode.attrs.participant;
205
- }
206
- if (messageNode.attrs.category === 'peer') {
207
- attrs.type = constants_1.WA_MESSAGE_TYPES.RECEIPT_TYPE_PEER;
208
- }
209
- return {
210
- tag: constants_1.WA_MESSAGE_TAGS.RECEIPT,
211
- attrs
212
- };
213
- }
214
- function buildInboundRetryReceiptNode(messageNode, id, to, meJid, retryCount = 1) {
215
- const attrs = {
216
- id,
217
- to,
218
- type: 'retry'
219
- };
220
- if (messageNode.attrs.participant) {
221
- attrs.participant = messageNode.attrs.participant;
222
- }
223
- if (meJid) {
224
- attrs.from = meJid;
225
- }
226
- const normalizedRetryCount = Number.isSafeInteger(retryCount) && retryCount > 0 ? retryCount : 1;
227
- const retryAttrs = {
228
- count: String(normalizedRetryCount),
229
- id
230
- };
231
- const timestamp = messageNode.attrs.t;
232
- if (timestamp) {
233
- retryAttrs.t = timestamp;
234
- attrs.t = timestamp;
235
- }
236
- return {
237
- tag: constants_1.WA_MESSAGE_TAGS.RECEIPT,
238
- attrs,
239
- content: [
240
- {
241
- tag: 'retry',
242
- attrs: retryAttrs
243
- }
244
- ]
245
- };
246
- }
247
- function buildInboundRetryReceiptAckNode(receiptNode) {
248
- const attrs = {
249
- class: 'receipt',
250
- type: 'retry'
251
- };
252
- if (receiptNode.attrs.id) {
253
- attrs.id = receiptNode.attrs.id;
254
- }
255
- if (receiptNode.attrs.from) {
256
- attrs.to = receiptNode.attrs.from;
257
- }
258
- if (receiptNode.attrs.participant) {
259
- attrs.participant = receiptNode.attrs.participant;
260
- }
261
- return {
262
- tag: constants_1.WA_MESSAGE_TAGS.ACK,
263
- attrs
264
- };
265
- }
266
- function buildInboundReceiptAckNode(receiptNode) {
267
- const attrs = {
268
- class: 'receipt'
269
- };
270
- if (receiptNode.attrs.id) {
271
- attrs.id = receiptNode.attrs.id;
272
- }
273
- if (receiptNode.attrs.from) {
274
- attrs.to = receiptNode.attrs.from;
275
- }
276
- if (receiptNode.attrs.type) {
277
- attrs.type = receiptNode.attrs.type;
278
- }
279
- if (receiptNode.attrs.participant &&
280
- (!receiptNode.attrs.from || receiptNode.attrs.participant !== receiptNode.attrs.from)) {
281
- attrs.participant = receiptNode.attrs.participant;
282
- }
283
- return {
284
- tag: constants_1.WA_MESSAGE_TAGS.ACK,
285
- attrs
286
- };
287
- }
288
123
  function buildGroupRetryMessageNode(input) {
289
124
  const content = [
290
- {
291
- tag: constants_1.WA_NODE_TAGS.PARTICIPANTS,
292
- attrs: {},
293
- content: [
294
- {
295
- tag: 'to',
296
- attrs: { jid: input.requesterJid },
297
- content: [
298
- {
299
- tag: constants_1.WA_MESSAGE_TAGS.ENC,
300
- attrs: {
301
- v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
302
- type: input.encType
303
- },
304
- content: input.ciphertext
305
- }
306
- ]
307
- }
308
- ]
309
- },
310
125
  {
311
126
  tag: constants_1.WA_MESSAGE_TAGS.ENC,
312
- attrs: {
313
- v: constants_1.WA_MESSAGE_TYPES.ENC_VERSION,
314
- type: 'skmsg'
315
- },
316
- content: undefined
127
+ attrs: buildEncAttrs(input.encType, input.mediatype, input.retryCount),
128
+ content: input.ciphertext
317
129
  }
318
130
  ];
319
131
  if (input.deviceIdentity) {
@@ -329,9 +141,16 @@ function buildGroupRetryMessageNode(input) {
329
141
  to: input.to,
330
142
  type: input.type,
331
143
  id: input.id,
332
- device_fanout: 'false',
144
+ participant: input.requesterJid,
333
145
  addressing_mode: input.addressingMode
334
146
  },
335
147
  content
336
148
  };
337
149
  }
150
+ function buildMetaNode(attrs) {
151
+ return {
152
+ tag: 'meta',
153
+ attrs,
154
+ content: undefined
155
+ };
156
+ }
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildCompanionHelloRequestNode = buildCompanionHelloRequestNode;
4
4
  exports.buildGetCountryCodeRequestNode = buildGetCountryCodeRequestNode;
5
5
  exports.buildCompanionFinishRequestNode = buildCompanionFinishRequestNode;
6
- exports.buildNotificationAckNode = buildNotificationAckNode;
7
- exports.buildIqResultNode = buildIqResultNode;
8
6
  const constants_1 = require("../../../protocol/constants");
9
7
  const bytes_1 = require("../../../util/bytes");
10
8
  function buildCompanionHelloRequestNode(args) {
@@ -110,27 +108,3 @@ function buildCompanionFinishRequestNode(args) {
110
108
  ]
111
109
  };
112
110
  }
113
- function buildNotificationAckNode(node, typeOverride) {
114
- const attrs = {
115
- to: node.attrs.from ?? constants_1.WA_DEFAULTS.HOST_DOMAIN,
116
- class: constants_1.WA_NODE_TAGS.NOTIFICATION,
117
- type: typeOverride ?? node.attrs.type ?? constants_1.WA_NODE_TAGS.NOTIFICATION
118
- };
119
- if (node.attrs.id) {
120
- attrs.id = node.attrs.id;
121
- }
122
- return {
123
- tag: constants_1.WA_NODE_TAGS.ACK,
124
- attrs
125
- };
126
- }
127
- function buildIqResultNode(iqNode) {
128
- return {
129
- tag: constants_1.WA_NODE_TAGS.IQ,
130
- attrs: {
131
- ...(iqNode.attrs.id ? { id: iqNode.attrs.id } : {}),
132
- to: iqNode.attrs.from ?? constants_1.WA_DEFAULTS.HOST_DOMAIN,
133
- type: constants_1.WA_IQ_TYPES.RESULT
134
- }
135
- };
136
- }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildPrivacyTokenIqNode = buildPrivacyTokenIqNode;
4
+ exports.buildTcTokenMessageNode = buildTcTokenMessageNode;
5
+ exports.buildCsTokenMessageNode = buildCsTokenMessageNode;
6
+ const nodes_1 = require("../../../protocol/nodes");
7
+ const privacy_token_1 = require("../../../protocol/privacy-token");
8
+ function buildPrivacyTokenIqNode(input) {
9
+ return {
10
+ tag: nodes_1.WA_NODE_TAGS.IQ,
11
+ attrs: {
12
+ type: nodes_1.WA_IQ_TYPES.SET,
13
+ xmlns: nodes_1.WA_XMLNS.PRIVACY
14
+ },
15
+ content: [
16
+ {
17
+ tag: privacy_token_1.WA_PRIVACY_TOKEN_TAGS.TOKENS,
18
+ attrs: {},
19
+ content: [
20
+ {
21
+ tag: privacy_token_1.WA_PRIVACY_TOKEN_TAGS.TOKEN,
22
+ attrs: {
23
+ jid: input.jid,
24
+ t: String(input.timestampS),
25
+ type: input.type ?? privacy_token_1.WA_PRIVACY_TOKEN_TYPES.TRUSTED_CONTACT
26
+ }
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ };
32
+ }
33
+ function buildTcTokenMessageNode(token) {
34
+ return {
35
+ tag: privacy_token_1.WA_PRIVACY_TOKEN_TAGS.TC_TOKEN,
36
+ attrs: {},
37
+ content: token
38
+ };
39
+ }
40
+ function buildCsTokenMessageNode(hash) {
41
+ return {
42
+ tag: privacy_token_1.WA_PRIVACY_TOKEN_TAGS.CS_TOKEN,
43
+ attrs: {},
44
+ content: hash
45
+ };
46
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildGetPrivacySettingsIq = buildGetPrivacySettingsIq;
4
+ exports.buildSetPrivacyCategoryIq = buildSetPrivacyCategoryIq;
5
+ exports.buildGetPrivacyDisallowedListIq = buildGetPrivacyDisallowedListIq;
6
+ exports.buildGetBlocklistIq = buildGetBlocklistIq;
7
+ exports.buildBlocklistChangeIq = buildBlocklistChangeIq;
8
+ const defaults_1 = require("../../../protocol/defaults");
9
+ const nodes_1 = require("../../../protocol/nodes");
10
+ const privacy_1 = require("../../../protocol/privacy");
11
+ const query_1 = require("../../node/query");
12
+ function buildGetPrivacySettingsIq() {
13
+ return (0, query_1.buildIqNode)('get', defaults_1.WA_DEFAULTS.HOST_DOMAIN, nodes_1.WA_XMLNS.PRIVACY, [
14
+ { tag: nodes_1.WA_NODE_TAGS.PRIVACY, attrs: {} }
15
+ ]);
16
+ }
17
+ function buildSetPrivacyCategoryIq(category, value) {
18
+ return (0, query_1.buildIqNode)('set', defaults_1.WA_DEFAULTS.HOST_DOMAIN, nodes_1.WA_XMLNS.PRIVACY, [
19
+ {
20
+ tag: nodes_1.WA_NODE_TAGS.PRIVACY,
21
+ attrs: {},
22
+ content: [
23
+ {
24
+ tag: privacy_1.WA_PRIVACY_TAGS.CATEGORY,
25
+ attrs: { name: category, value }
26
+ }
27
+ ]
28
+ }
29
+ ]);
30
+ }
31
+ function buildGetPrivacyDisallowedListIq(category) {
32
+ return (0, query_1.buildIqNode)('get', defaults_1.WA_DEFAULTS.HOST_DOMAIN, nodes_1.WA_XMLNS.PRIVACY, [
33
+ {
34
+ tag: nodes_1.WA_NODE_TAGS.PRIVACY,
35
+ attrs: {},
36
+ content: [
37
+ {
38
+ tag: privacy_1.WA_PRIVACY_TAGS.LIST,
39
+ attrs: { name: category, value: 'contact_blacklist' }
40
+ }
41
+ ]
42
+ }
43
+ ]);
44
+ }
45
+ function buildGetBlocklistIq() {
46
+ return (0, query_1.buildIqNode)('get', defaults_1.WA_DEFAULTS.HOST_DOMAIN, nodes_1.WA_XMLNS.BLOCKLIST);
47
+ }
48
+ function buildBlocklistChangeIq(jid, action) {
49
+ return (0, query_1.buildIqNode)('set', defaults_1.WA_DEFAULTS.HOST_DOMAIN, nodes_1.WA_XMLNS.BLOCKLIST, [
50
+ {
51
+ tag: 'item',
52
+ attrs: { jid, action }
53
+ }
54
+ ]);
55
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildGetProfilePictureIq = buildGetProfilePictureIq;
4
+ exports.buildSetProfilePictureIq = buildSetProfilePictureIq;
5
+ exports.buildDeleteProfilePictureIq = buildDeleteProfilePictureIq;
6
+ exports.buildSetStatusIq = buildSetStatusIq;
7
+ exports.buildGetDisappearingModeUsyncQueryNode = buildGetDisappearingModeUsyncQueryNode;
8
+ exports.buildGetStatusUsyncQueryNodes = buildGetStatusUsyncQueryNodes;
9
+ const constants_1 = require("../../../protocol/constants");
10
+ const query_1 = require("../../node/query");
11
+ function buildGetProfilePictureIq(targetJid, type = 'preview', existingId) {
12
+ const pictureAttrs = {
13
+ type,
14
+ query: 'url'
15
+ };
16
+ if (existingId) {
17
+ pictureAttrs.id = existingId;
18
+ }
19
+ return (0, query_1.buildIqNode)('get', constants_1.WA_DEFAULTS.HOST_DOMAIN, constants_1.WA_XMLNS.PROFILE_PICTURE, [
20
+ {
21
+ tag: constants_1.WA_NODE_TAGS.PICTURE,
22
+ attrs: pictureAttrs
23
+ }
24
+ ], {
25
+ target: targetJid
26
+ });
27
+ }
28
+ function buildSetProfilePictureIq(imageBytes, targetJid) {
29
+ const attrs = {};
30
+ if (targetJid) {
31
+ attrs.target = targetJid;
32
+ }
33
+ return (0, query_1.buildIqNode)('set', constants_1.WA_DEFAULTS.HOST_DOMAIN, constants_1.WA_XMLNS.PROFILE_PICTURE, [
34
+ {
35
+ tag: constants_1.WA_NODE_TAGS.PICTURE,
36
+ attrs: { type: 'image' },
37
+ content: imageBytes
38
+ }
39
+ ], attrs);
40
+ }
41
+ function buildDeleteProfilePictureIq(targetJid) {
42
+ const attrs = {};
43
+ if (targetJid) {
44
+ attrs.target = targetJid;
45
+ }
46
+ return (0, query_1.buildIqNode)('set', constants_1.WA_DEFAULTS.HOST_DOMAIN, constants_1.WA_XMLNS.PROFILE_PICTURE, undefined, attrs);
47
+ }
48
+ function buildSetStatusIq(text) {
49
+ return (0, query_1.buildIqNode)('set', constants_1.WA_DEFAULTS.HOST_DOMAIN, constants_1.WA_XMLNS.STATUS, [
50
+ {
51
+ tag: 'status',
52
+ attrs: {},
53
+ content: text
54
+ }
55
+ ]);
56
+ }
57
+ function buildGetDisappearingModeUsyncQueryNode() {
58
+ return {
59
+ tag: 'disappearing_mode',
60
+ attrs: {}
61
+ };
62
+ }
63
+ function buildGetStatusUsyncQueryNodes() {
64
+ return [
65
+ {
66
+ tag: constants_1.WA_NODE_TAGS.CONTACT,
67
+ attrs: {}
68
+ },
69
+ {
70
+ tag: 'status',
71
+ attrs: {}
72
+ },
73
+ {
74
+ tag: constants_1.WA_NODE_TAGS.PICTURE,
75
+ attrs: {}
76
+ }
77
+ ];
78
+ }