zapo-js 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/README.md +8 -0
  2. package/dist/appstate/WaAppStateCrypto.js +18 -25
  3. package/dist/appstate/WaAppStateSyncClient.js +181 -114
  4. package/dist/appstate/WaAppStateSyncResponseParser.js +16 -5
  5. package/dist/appstate/constants.js +4 -3
  6. package/dist/appstate/utils.js +10 -30
  7. package/dist/auth/WaAuthClient.js +48 -55
  8. package/dist/auth/flow/WaAuthCredentialsFlow.js +21 -14
  9. package/dist/auth/index.js +1 -3
  10. package/dist/auth/pairing/WaPairingFlow.js +21 -23
  11. package/dist/auth/pairing/WaQrFlow.js +37 -24
  12. package/dist/client/WaClient.js +103 -276
  13. package/dist/client/WaClientFactory.js +227 -110
  14. package/dist/client/connection/WaConnectionManager.js +292 -0
  15. package/dist/client/connection/WaKeyShareCoordinator.js +63 -0
  16. package/dist/client/connection/WaReceiptQueue.js +51 -0
  17. package/dist/client/coordinators/WaAppStateMutationCoordinator.js +471 -0
  18. package/dist/client/coordinators/WaGroupCoordinator.js +27 -17
  19. package/dist/client/coordinators/WaIncomingNodeCoordinator.js +20 -27
  20. package/dist/client/coordinators/WaMessageDispatchCoordinator.js +231 -686
  21. package/dist/client/coordinators/WaRetryCoordinator.js +70 -37
  22. package/dist/client/dirty.js +35 -29
  23. package/dist/client/events/chat.js +4 -3
  24. package/dist/client/events/group.js +59 -36
  25. package/dist/client/history-sync.js +53 -63
  26. package/dist/client/incoming.js +23 -20
  27. package/dist/client/mailbox.js +8 -8
  28. package/dist/client/messages.js +4 -4
  29. package/dist/client/messaging/fanout.js +189 -0
  30. package/dist/client/messaging/key-protocol.js +130 -0
  31. package/dist/client/messaging/participants.js +191 -0
  32. package/dist/crypto/core/hkdf.js +3 -8
  33. package/dist/crypto/core/index.js +1 -4
  34. package/dist/crypto/core/keys.js +2 -3
  35. package/dist/crypto/core/primitives.js +12 -15
  36. package/dist/crypto/core/random.js +7 -26
  37. package/dist/crypto/curves/Ed25519.js +7 -8
  38. package/dist/crypto/curves/X25519.js +13 -16
  39. package/dist/crypto/index.js +0 -5
  40. package/dist/esm/appstate/WaAppStateCrypto.js +6 -13
  41. package/dist/esm/appstate/WaAppStateSyncClient.js +174 -107
  42. package/dist/esm/appstate/WaAppStateSyncResponseParser.js +17 -6
  43. package/dist/esm/appstate/constants.js +3 -2
  44. package/dist/esm/appstate/utils.js +8 -27
  45. package/dist/esm/auth/WaAuthClient.js +48 -55
  46. package/dist/esm/auth/flow/WaAuthCredentialsFlow.js +21 -14
  47. package/dist/esm/auth/index.js +0 -1
  48. package/dist/esm/auth/pairing/WaPairingFlow.js +14 -16
  49. package/dist/esm/auth/pairing/WaQrFlow.js +37 -24
  50. package/dist/esm/client/WaClient.js +103 -276
  51. package/dist/esm/client/WaClientFactory.js +227 -110
  52. package/dist/esm/client/connection/WaConnectionManager.js +288 -0
  53. package/dist/esm/client/connection/WaKeyShareCoordinator.js +59 -0
  54. package/dist/esm/client/connection/WaReceiptQueue.js +47 -0
  55. package/dist/esm/client/coordinators/WaAppStateMutationCoordinator.js +467 -0
  56. package/dist/esm/client/coordinators/WaGroupCoordinator.js +20 -10
  57. package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +20 -27
  58. package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +232 -687
  59. package/dist/esm/client/coordinators/WaRetryCoordinator.js +71 -38
  60. package/dist/esm/client/dirty.js +30 -24
  61. package/dist/esm/client/events/chat.js +4 -3
  62. package/dist/esm/client/events/group.js +50 -28
  63. package/dist/esm/client/history-sync.js +50 -60
  64. package/dist/esm/client/incoming.js +23 -20
  65. package/dist/esm/client/mailbox.js +8 -8
  66. package/dist/esm/client/messages.js +1 -1
  67. package/dist/esm/client/messaging/fanout.js +186 -0
  68. package/dist/esm/client/messaging/key-protocol.js +127 -0
  69. package/dist/esm/client/messaging/participants.js +188 -0
  70. package/dist/esm/crypto/core/hkdf.js +3 -8
  71. package/dist/esm/crypto/core/index.js +0 -1
  72. package/dist/esm/crypto/core/keys.js +2 -3
  73. package/dist/esm/crypto/core/primitives.js +12 -15
  74. package/dist/esm/crypto/core/random.js +6 -25
  75. package/dist/esm/crypto/curves/Ed25519.js +4 -5
  76. package/dist/esm/crypto/curves/X25519.js +10 -13
  77. package/dist/esm/crypto/index.js +0 -2
  78. package/dist/esm/infra/log/ConsoleLogger.js +18 -17
  79. package/dist/esm/infra/log/PinoLogger.js +15 -9
  80. package/dist/esm/infra/log/types.js +11 -1
  81. package/dist/esm/infra/perf/BoundedTaskQueue.js +13 -17
  82. package/dist/esm/media/WaMediaCrypto.js +2 -4
  83. package/dist/esm/media/WaMediaTransferClient.js +226 -58
  84. package/dist/esm/media/conn.js +10 -6
  85. package/dist/esm/media/constants.js +4 -1
  86. package/dist/esm/message/WaMessageClient.js +4 -13
  87. package/dist/esm/message/ack.js +6 -6
  88. package/dist/esm/message/addon-crypto.js +59 -0
  89. package/dist/esm/message/incoming.js +106 -111
  90. package/dist/esm/message/index.js +2 -0
  91. package/dist/esm/message/reporting-token.js +438 -0
  92. package/dist/esm/message/use-case-secret.js +49 -0
  93. package/dist/esm/protocol/appstate.js +58 -0
  94. package/dist/esm/protocol/constants.js +2 -1
  95. package/dist/esm/protocol/index.js +2 -10
  96. package/dist/esm/protocol/jid.js +63 -51
  97. package/dist/esm/protocol/media.js +3 -3
  98. package/dist/esm/protocol/nodes.js +2 -0
  99. package/dist/esm/protocol/usync.js +11 -0
  100. package/dist/esm/retry/index.js +1 -0
  101. package/dist/esm/retry/outbound.js +4 -5
  102. package/dist/esm/retry/parse.js +58 -76
  103. package/dist/esm/retry/replay.js +48 -49
  104. package/dist/esm/retry/tracker.js +56 -0
  105. package/dist/esm/signal/api/SignalDeviceSyncApi.js +249 -82
  106. package/dist/esm/signal/api/SignalDigestSyncApi.js +6 -1
  107. package/dist/esm/signal/api/SignalIdentitySyncApi.js +49 -34
  108. package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +70 -62
  109. package/dist/esm/signal/api/SignalSessionSyncApi.js +23 -30
  110. package/dist/esm/signal/crypto/WaAdvSignature.js +3 -5
  111. package/dist/esm/signal/group/SenderKeyChain.js +28 -23
  112. package/dist/esm/signal/group/SenderKeyCodec.js +2 -4
  113. package/dist/esm/signal/group/SenderKeyManager.js +26 -16
  114. package/dist/esm/signal/index.js +1 -0
  115. package/dist/esm/signal/session/SignalProtocol.js +49 -14
  116. package/dist/esm/signal/session/SignalRatchet.js +24 -15
  117. package/dist/esm/signal/session/SignalSession.js +14 -9
  118. package/dist/esm/signal/session/resolver.js +186 -0
  119. package/dist/esm/signal/store/sqlite.js +16 -37
  120. package/dist/esm/store/createStore.js +16 -18
  121. package/dist/esm/store/noop.store.js +3 -6
  122. package/dist/esm/store/providers/memory/appstate.store.js +30 -6
  123. package/dist/esm/store/providers/memory/contact.store.js +5 -0
  124. package/dist/esm/store/providers/memory/device-list.store.js +3 -30
  125. package/dist/esm/store/providers/memory/message.store.js +11 -5
  126. package/dist/esm/store/providers/memory/participants.store.js +1 -8
  127. package/dist/esm/store/providers/memory/sender-key.store.js +5 -7
  128. package/dist/esm/store/providers/memory/signal.store.js +13 -1
  129. package/dist/esm/store/providers/memory/thread.store.js +5 -0
  130. package/dist/esm/store/providers/sqlite/appstate.store.js +82 -1
  131. package/dist/esm/store/providers/sqlite/connection.js +18 -13
  132. package/dist/esm/store/providers/sqlite/contact.store.js +31 -18
  133. package/dist/esm/store/providers/sqlite/device-list.store.js +7 -35
  134. package/dist/esm/store/providers/sqlite/message.store.js +45 -32
  135. package/dist/esm/store/providers/sqlite/migrations.js +1 -1
  136. package/dist/esm/store/providers/sqlite/participants.store.js +1 -9
  137. package/dist/esm/store/providers/sqlite/retry.store.js +8 -11
  138. package/dist/esm/store/providers/sqlite/sender-key.store.js +25 -30
  139. package/dist/esm/store/providers/sqlite/signal.store.js +104 -22
  140. package/dist/esm/store/providers/sqlite/table-names.js +107 -0
  141. package/dist/esm/store/providers/sqlite/thread.store.js +35 -22
  142. package/dist/esm/transport/WaComms.js +25 -23
  143. package/dist/esm/transport/WaWebSocket.js +115 -12
  144. package/dist/esm/transport/binary/decoder.js +4 -4
  145. package/dist/esm/transport/binary/encoder.js +12 -4
  146. package/dist/esm/transport/index.js +1 -0
  147. package/dist/esm/transport/keepalive/WaKeepAlive.js +2 -8
  148. package/dist/esm/transport/node/WaNodeOrchestrator.js +2 -4
  149. package/dist/esm/transport/node/WaNodeTransport.js +0 -3
  150. package/dist/esm/transport/node/builders/{accountSync.js → account-sync.js} +16 -36
  151. package/dist/esm/transport/node/builders/index.js +2 -1
  152. package/dist/esm/transport/node/builders/message.js +9 -0
  153. package/dist/esm/transport/node/builders/pairing.js +4 -5
  154. package/dist/esm/transport/node/builders/usync.js +41 -0
  155. package/dist/esm/transport/node/helpers.js +107 -5
  156. package/dist/esm/transport/node/usync.js +35 -0
  157. package/dist/esm/transport/noise/WaFrameCodec.js +48 -33
  158. package/dist/esm/transport/noise/WaNoiseCert.js +3 -6
  159. package/dist/esm/transport/noise/WaNoiseSession.js +17 -10
  160. package/dist/esm/transport/proxy.js +27 -0
  161. package/dist/esm/transport/stream/parse.js +13 -48
  162. package/dist/esm/util/bytes.js +50 -32
  163. package/dist/esm/util/coercion.js +6 -14
  164. package/dist/esm/util/primitives.js +39 -14
  165. package/dist/infra/log/ConsoleLogger.js +18 -17
  166. package/dist/infra/log/PinoLogger.js +15 -9
  167. package/dist/infra/log/types.js +12 -0
  168. package/dist/infra/perf/BoundedTaskQueue.js +13 -17
  169. package/dist/media/WaMediaCrypto.js +1 -3
  170. package/dist/media/WaMediaTransferClient.js +259 -58
  171. package/dist/media/conn.js +10 -6
  172. package/dist/media/constants.js +4 -1
  173. package/dist/message/WaMessageClient.js +5 -14
  174. package/dist/message/ack.js +6 -6
  175. package/dist/message/addon-crypto.js +65 -0
  176. package/dist/message/incoming.js +104 -109
  177. package/dist/message/index.js +2 -0
  178. package/dist/message/reporting-token.js +443 -0
  179. package/dist/message/use-case-secret.js +55 -0
  180. package/dist/protocol/appstate.js +59 -1
  181. package/dist/protocol/constants.js +7 -1
  182. package/dist/protocol/index.js +20 -42
  183. package/dist/protocol/jid.js +64 -51
  184. package/dist/protocol/media.js +3 -3
  185. package/dist/protocol/nodes.js +2 -0
  186. package/dist/protocol/usync.js +14 -0
  187. package/dist/retry/index.js +3 -1
  188. package/dist/retry/outbound.js +6 -7
  189. package/dist/retry/parse.js +57 -75
  190. package/dist/retry/replay.js +46 -47
  191. package/dist/retry/tracker.js +59 -0
  192. package/dist/signal/api/SignalDeviceSyncApi.js +247 -80
  193. package/dist/signal/api/SignalDigestSyncApi.js +6 -1
  194. package/dist/signal/api/SignalIdentitySyncApi.js +49 -34
  195. package/dist/signal/api/SignalMissingPreKeysSyncApi.js +67 -59
  196. package/dist/signal/api/SignalSessionSyncApi.js +23 -30
  197. package/dist/signal/crypto/WaAdvSignature.js +2 -4
  198. package/dist/signal/group/SenderKeyChain.js +27 -22
  199. package/dist/signal/group/SenderKeyCodec.js +1 -3
  200. package/dist/signal/group/SenderKeyManager.js +26 -16
  201. package/dist/signal/index.js +3 -1
  202. package/dist/signal/session/SignalProtocol.js +49 -14
  203. package/dist/signal/session/SignalRatchet.js +24 -15
  204. package/dist/signal/session/SignalSession.js +14 -9
  205. package/dist/signal/session/resolver.js +189 -0
  206. package/dist/signal/store/sqlite.js +16 -37
  207. package/dist/store/createStore.js +16 -18
  208. package/dist/store/noop.store.js +3 -6
  209. package/dist/store/providers/memory/appstate.store.js +28 -4
  210. package/dist/store/providers/memory/contact.store.js +5 -0
  211. package/dist/store/providers/memory/device-list.store.js +3 -30
  212. package/dist/store/providers/memory/message.store.js +11 -5
  213. package/dist/store/providers/memory/participants.store.js +1 -8
  214. package/dist/store/providers/memory/sender-key.store.js +8 -10
  215. package/dist/store/providers/memory/signal.store.js +21 -9
  216. package/dist/store/providers/memory/thread.store.js +5 -0
  217. package/dist/store/providers/sqlite/appstate.store.js +81 -0
  218. package/dist/store/providers/sqlite/connection.js +18 -13
  219. package/dist/store/providers/sqlite/contact.store.js +31 -18
  220. package/dist/store/providers/sqlite/device-list.store.js +7 -35
  221. package/dist/store/providers/sqlite/message.store.js +45 -32
  222. package/dist/store/providers/sqlite/migrations.js +1 -1
  223. package/dist/store/providers/sqlite/participants.store.js +1 -9
  224. package/dist/store/providers/sqlite/retry.store.js +8 -11
  225. package/dist/store/providers/sqlite/sender-key.store.js +24 -29
  226. package/dist/store/providers/sqlite/signal.store.js +105 -23
  227. package/dist/store/providers/sqlite/table-names.js +113 -0
  228. package/dist/store/providers/sqlite/thread.store.js +35 -22
  229. package/dist/transport/WaComms.js +27 -25
  230. package/dist/transport/WaWebSocket.js +148 -12
  231. package/dist/transport/binary/decoder.js +4 -4
  232. package/dist/transport/binary/encoder.js +12 -4
  233. package/dist/transport/index.js +7 -1
  234. package/dist/transport/keepalive/WaKeepAlive.js +1 -7
  235. package/dist/transport/node/WaNodeOrchestrator.js +2 -4
  236. package/dist/transport/node/WaNodeTransport.js +0 -3
  237. package/dist/transport/node/builders/{accountSync.js → account-sync.js} +15 -35
  238. package/dist/transport/node/builders/index.js +12 -9
  239. package/dist/transport/node/builders/message.js +9 -0
  240. package/dist/transport/node/builders/pairing.js +4 -5
  241. package/dist/transport/node/builders/usync.js +45 -0
  242. package/dist/transport/node/helpers.js +112 -4
  243. package/dist/transport/node/usync.js +38 -0
  244. package/dist/transport/noise/WaFrameCodec.js +47 -32
  245. package/dist/transport/noise/WaNoiseCert.js +5 -8
  246. package/dist/transport/noise/WaNoiseSession.js +17 -10
  247. package/dist/transport/proxy.js +34 -0
  248. package/dist/transport/stream/parse.js +17 -53
  249. package/dist/types/appstate/WaAppStateCrypto.d.ts +0 -1
  250. package/dist/types/appstate/WaAppStateSyncClient.d.ts +5 -2
  251. package/dist/types/appstate/constants.d.ts +1 -0
  252. package/dist/types/appstate/store/sqlite.d.ts +4 -18
  253. package/dist/types/appstate/utils.d.ts +0 -1
  254. package/dist/types/auth/WaAuthClient.d.ts +10 -12
  255. package/dist/types/auth/index.d.ts +0 -2
  256. package/dist/types/auth/pairing/WaQrFlow.d.ts +1 -1
  257. package/dist/types/auth/types.d.ts +6 -9
  258. package/dist/types/client/WaClient.d.ts +27 -25
  259. package/dist/types/client/WaClientFactory.d.ts +22 -23
  260. package/dist/types/client/connection/WaConnectionManager.d.ts +64 -0
  261. package/dist/types/client/connection/WaKeyShareCoordinator.d.ts +14 -0
  262. package/dist/types/client/connection/WaReceiptQueue.d.ts +13 -0
  263. package/dist/types/client/coordinators/WaAppStateMutationCoordinator.d.ts +46 -0
  264. package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +0 -1
  265. package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +18 -41
  266. package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +2 -0
  267. package/dist/types/client/dirty.d.ts +1 -0
  268. package/dist/types/client/events/group.d.ts +2 -1
  269. package/dist/types/client/index.d.ts +1 -1
  270. package/dist/types/client/messaging/fanout.d.ts +14 -0
  271. package/dist/types/client/messaging/key-protocol.d.ts +18 -0
  272. package/dist/types/client/messaging/participants.d.ts +13 -0
  273. package/dist/types/client/types.d.ts +24 -1
  274. package/dist/types/crypto/core/hkdf.d.ts +0 -6
  275. package/dist/types/crypto/core/index.d.ts +0 -1
  276. package/dist/types/crypto/core/random.d.ts +1 -7
  277. package/dist/types/crypto/index.d.ts +0 -2
  278. package/dist/types/index.d.ts +1 -1
  279. package/dist/types/infra/log/ConsoleLogger.d.ts +2 -1
  280. package/dist/types/infra/log/PinoLogger.d.ts +1 -1
  281. package/dist/types/infra/log/types.d.ts +1 -0
  282. package/dist/types/infra/perf/BoundedTaskQueue.d.ts +1 -1
  283. package/dist/types/media/WaMediaTransferClient.d.ts +13 -3
  284. package/dist/types/media/types.d.ts +5 -0
  285. package/dist/types/message/addon-crypto.d.ts +25 -0
  286. package/dist/types/message/index.d.ts +2 -0
  287. package/dist/types/message/reporting-token.d.ts +19 -0
  288. package/dist/types/message/use-case-secret.d.ts +20 -0
  289. package/dist/types/protocol/appstate.d.ts +58 -0
  290. package/dist/types/protocol/constants.d.ts +2 -1
  291. package/dist/types/protocol/index.d.ts +2 -10
  292. package/dist/types/protocol/jid.d.ts +3 -3
  293. package/dist/types/protocol/nodes.d.ts +2 -0
  294. package/dist/types/protocol/usync.d.ts +11 -0
  295. package/dist/types/retry/index.d.ts +1 -0
  296. package/dist/types/retry/replay.d.ts +0 -4
  297. package/dist/types/retry/tracker.d.ts +19 -0
  298. package/dist/types/retry/types.d.ts +4 -3
  299. package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +13 -1
  300. package/dist/types/signal/group/SenderKeyCodec.d.ts +4 -6
  301. package/dist/types/signal/index.d.ts +1 -0
  302. package/dist/types/signal/session/SignalProtocol.d.ts +9 -0
  303. package/dist/types/signal/session/resolver.d.ts +17 -0
  304. package/dist/types/store/contracts/appstate.store.d.ts +3 -0
  305. package/dist/types/store/contracts/contact.store.d.ts +1 -0
  306. package/dist/types/store/contracts/device-list.store.d.ts +0 -3
  307. package/dist/types/store/contracts/message.store.d.ts +1 -0
  308. package/dist/types/store/contracts/participants.store.d.ts +0 -1
  309. package/dist/types/store/contracts/sender-key.store.d.ts +0 -1
  310. package/dist/types/store/contracts/signal.store.d.ts +6 -0
  311. package/dist/types/store/contracts/thread.store.d.ts +1 -0
  312. package/dist/types/store/index.d.ts +1 -1
  313. package/dist/types/store/providers/memory/appstate.store.d.ts +2 -0
  314. package/dist/types/store/providers/memory/contact.store.d.ts +1 -0
  315. package/dist/types/store/providers/memory/device-list.store.d.ts +0 -3
  316. package/dist/types/store/providers/memory/message.store.d.ts +1 -0
  317. package/dist/types/store/providers/memory/participants.store.d.ts +0 -1
  318. package/dist/types/store/providers/memory/sender-key.store.d.ts +0 -1
  319. package/dist/types/store/providers/memory/signal.store.d.ts +6 -0
  320. package/dist/types/store/providers/memory/thread.store.d.ts +1 -0
  321. package/dist/types/store/providers/sqlite/appstate.store.d.ts +2 -0
  322. package/dist/types/store/providers/sqlite/contact.store.d.ts +2 -0
  323. package/dist/types/store/providers/sqlite/device-list.store.d.ts +0 -3
  324. package/dist/types/store/providers/sqlite/message.store.d.ts +2 -0
  325. package/dist/types/store/providers/sqlite/participants.store.d.ts +0 -1
  326. package/dist/types/store/providers/sqlite/retry.store.d.ts +0 -1
  327. package/dist/types/store/providers/sqlite/sender-key.store.d.ts +0 -1
  328. package/dist/types/store/providers/sqlite/signal.store.d.ts +7 -0
  329. package/dist/types/store/providers/sqlite/table-names.d.ts +5 -0
  330. package/dist/types/store/providers/sqlite/thread.store.d.ts +2 -0
  331. package/dist/types/store/types.d.ts +3 -0
  332. package/dist/types/transport/WaWebSocket.d.ts +3 -0
  333. package/dist/types/transport/index.d.ts +2 -1
  334. package/dist/types/transport/keepalive/WaKeepAlive.d.ts +0 -1
  335. package/dist/types/transport/node/WaNodeTransport.d.ts +0 -9
  336. package/dist/types/transport/node/builders/group.d.ts +4 -6
  337. package/dist/types/transport/node/builders/index.d.ts +2 -1
  338. package/dist/types/transport/node/builders/message.d.ts +14 -25
  339. package/dist/types/transport/node/builders/retry.d.ts +2 -4
  340. package/dist/types/transport/node/builders/usync.d.ts +21 -0
  341. package/dist/types/transport/node/helpers.d.ts +8 -0
  342. package/dist/types/transport/node/usync.d.ts +2 -0
  343. package/dist/types/transport/noise/WaFrameCodec.d.ts +3 -0
  344. package/dist/types/transport/noise/WaNoiseSession.d.ts +1 -0
  345. package/dist/types/transport/proxy.d.ts +6 -0
  346. package/dist/types/transport/stream/parse.d.ts +0 -1
  347. package/dist/types/transport/types.d.ts +18 -1
  348. package/dist/types/util/bytes.d.ts +5 -0
  349. package/dist/types/util/primitives.d.ts +3 -0
  350. package/dist/util/bytes.js +55 -33
  351. package/dist/util/coercion.js +6 -14
  352. package/dist/util/primitives.js +42 -14
  353. package/package.json +26 -5
  354. package/dist/crypto/core/encoding.js +0 -29
  355. package/dist/esm/crypto/core/encoding.js +0 -25
  356. package/dist/esm/util/base64.js +0 -18
  357. package/dist/esm/util/signal-address.js +0 -5
  358. package/dist/types/crypto/core/encoding.d.ts +0 -11
  359. package/dist/types/util/base64.d.ts +0 -4
  360. package/dist/types/util/signal-address.d.ts +0 -2
  361. package/dist/util/base64.js +0 -24
  362. package/dist/util/signal-address.js +0 -8
  363. /package/dist/types/transport/node/builders/{accountSync.d.ts → account-sync.d.ts} +0 -0
@@ -6,11 +6,10 @@ import { persistIncomingMailboxEntities } from './mailbox.js';
6
6
  import { buildWaClientDependencies, resolveWaClientBase } from './WaClientFactory.js';
7
7
  import { ConsoleLogger } from '../infra/log/ConsoleLogger.js';
8
8
  import { proto } from '../proto.js';
9
- import { WA_APP_STATE_COLLECTION_STATES, WA_DEFAULTS, WA_MESSAGE_TAGS } from '../protocol/constants.js';
10
- import { normalizeDeviceJid, toUserJid } from '../protocol/jid.js';
9
+ import { WA_APP_STATE_COLLECTION_STATES, WA_DEFAULTS } from '../protocol/constants.js';
10
+ import { normalizeDeviceJid, parsePhoneJid, toUserJid } from '../protocol/jid.js';
11
11
  import { queryWithContext as queryNodeWithContext } from '../transport/node/query.js';
12
- import { WaComms } from '../transport/WaComms.js';
13
- import { decodeProtoBytes } from '../util/base64.js';
12
+ import { decodeProtoBytes } from '../util/bytes.js';
14
13
  import { bytesToHex } from '../util/bytes.js';
15
14
  import { toError } from '../util/primitives.js';
16
15
  const SYNC_RELATED_PROTOCOL_TYPES = new Set([
@@ -24,15 +23,7 @@ const WA_APP_STATE_KEY_SHARE_MAX_RETRIES = 2;
24
23
  export class WaClient extends EventEmitter {
25
24
  constructor(options, logger = new ConsoleLogger('info')) {
26
25
  super();
27
- this.clockSkewMs = null;
28
- this.mediaConnCache = null;
29
- this.comms = null;
30
- this.pairingReconnectPromise = null;
31
26
  this.connectPromise = null;
32
- this.danglingReceipts = [];
33
- this.appStateKeyShareWaiters = new Set();
34
- this.appStateKeyShareVersion = 0;
35
- this.appStateBootstrapKeyShareWaitDone = false;
36
27
  const base = resolveWaClientBase(options, logger);
37
28
  this.options = base.options;
38
29
  this.logger = base.logger;
@@ -45,31 +36,20 @@ export class WaClient extends EventEmitter {
45
36
  this.signalStore = base.sessionStore.signal;
46
37
  this.senderKeyStore = base.sessionStore.senderKey;
47
38
  this.threadStore = base.sessionStore.threads;
48
- const host = {
49
- sendNode: (node) => this.sendNode(node),
50
- query: (node, timeoutMs) => this.query(node, timeoutMs),
51
- queryWithContext: this.queryWithContext.bind(this),
52
- syncAppState: () => this.syncAppState().then(() => { }),
53
- emitEvent: this.emit.bind(this),
54
- handleIncomingMessageEvent: this.handleIncomingMessageEvent.bind(this),
55
- handleError: this.handleError.bind(this),
56
- scheduleReconnectAfterPairing: this.scheduleReconnectAfterPairing.bind(this),
57
- updateClockSkewFromSuccess: this.updateClockSkewFromSuccess.bind(this),
58
- getComms: () => this.comms,
59
- getMediaConnCache: () => this.mediaConnCache,
60
- setMediaConnCache: (mediaConn) => {
61
- this.mediaConnCache = mediaConn;
62
- },
63
- disconnect: this.disconnect.bind(this),
64
- clearStoredState: this.clearStoredState.bind(this),
65
- connect: this.connect.bind(this),
66
- shouldQueueDanglingReceipt: (node, error) => this.shouldQueueDanglingReceipt(node, error),
67
- enqueueDanglingReceipt: this.enqueueDanglingReceipt.bind(this),
68
- takeDanglingReceipts: () => this.danglingReceipts.splice(0)
69
- };
70
39
  const dependencies = buildWaClientDependencies({
71
40
  base,
72
- host
41
+ runtime: {
42
+ sendNode: (node) => this.sendNode(node),
43
+ query: (node, timeoutMs) => this.query(node, timeoutMs),
44
+ queryWithContext: this.queryWithContext.bind(this),
45
+ syncAppState: () => this.syncAppState().then(() => { }),
46
+ syncAppStateWithOptions: (syncOptions) => this.syncAppState(syncOptions),
47
+ emitEvent: this.emit.bind(this),
48
+ handleIncomingMessageEvent: this.handleIncomingMessageEvent.bind(this),
49
+ handleError: this.handleError.bind(this),
50
+ handleIncomingFrame: this.handleIncomingFrame.bind(this),
51
+ clearStoredState: this.clearStoredState.bind(this)
52
+ }
73
53
  });
74
54
  Object.assign(this, dependencies);
75
55
  this.bindNodeTransportEvents();
@@ -87,7 +67,7 @@ export class WaClient extends EventEmitter {
87
67
  return super.emit(event, ...args);
88
68
  }
89
69
  getState() {
90
- const connected = this.comms !== null && this.comms.getCommsState().connected;
70
+ const connected = this.connectionManager.isConnected();
91
71
  this.logger.trace('wa client state requested', { connected });
92
72
  return this.authClient.getState(connected);
93
73
  }
@@ -95,7 +75,7 @@ export class WaClient extends EventEmitter {
95
75
  return this.authClient.getCurrentCredentials();
96
76
  }
97
77
  getClockSkewMs() {
98
- return this.clockSkewMs;
78
+ return this.connectionManager.getClockSkewMs();
99
79
  }
100
80
  async sendNode(node) {
101
81
  try {
@@ -103,13 +83,13 @@ export class WaClient extends EventEmitter {
103
83
  }
104
84
  catch (error) {
105
85
  const normalized = toError(error);
106
- if (this.shouldQueueDanglingReceipt(node, normalized)) {
107
- this.enqueueDanglingReceipt(node);
86
+ if (this.receiptQueue.shouldQueue(node, normalized)) {
87
+ this.receiptQueue.enqueue(node);
108
88
  this.logger.warn('queued dangling receipt after send failure', {
109
89
  id: node.attrs.id,
110
90
  to: node.attrs.to,
111
91
  message: normalized.message,
112
- queueSize: this.danglingReceipts.length
92
+ queueSize: this.receiptQueue.size()
113
93
  });
114
94
  return;
115
95
  }
@@ -117,7 +97,7 @@ export class WaClient extends EventEmitter {
117
97
  }
118
98
  }
119
99
  async query(node, timeoutMs = this.options.iqTimeoutMs ?? WA_DEFAULTS.IQ_TIMEOUT_MS) {
120
- if (!this.comms || !this.comms.getCommsState().connected) {
100
+ if (!this.connectionManager.isConnected()) {
121
101
  throw new Error('client is not connected');
122
102
  }
123
103
  this.logger.debug('wa client query', { tag: node.tag, id: node.attrs.id, timeoutMs });
@@ -139,12 +119,17 @@ export class WaClient extends EventEmitter {
139
119
  this.handleError(error);
140
120
  });
141
121
  }
122
+ getMailboxPersistenceDeps() {
123
+ return {
124
+ logger: this.logger,
125
+ contactStore: this.contactStore,
126
+ messageStore: this.messageStore
127
+ };
128
+ }
142
129
  async handleIncomingMessageEvent(event) {
143
130
  this.emit('message', event);
144
131
  void persistIncomingMailboxEntities({
145
- logger: this.logger,
146
- contactStore: this.contactStore,
147
- messageStore: this.messageStore,
132
+ ...this.getMailboxPersistenceDeps(),
148
133
  event
149
134
  });
150
135
  const protocolMessage = event.message?.protocolMessage;
@@ -209,9 +194,8 @@ export class WaClient extends EventEmitter {
209
194
  imported
210
195
  });
211
196
  if (imported > 0) {
212
- const hadWaiters = this.appStateKeyShareWaiters.size > 0;
213
- this.appStateKeyShareVersion += 1;
214
- this.notifyAppStateKeyShareWaiters(true);
197
+ const hadWaiters = this.keyShareCoordinator.hasWaiters();
198
+ this.keyShareCoordinator.notifyReceived();
215
199
  if (hadWaiters) {
216
200
  this.logger.debug('app-state key share imported and waiters released', {
217
201
  id: event.stanzaId,
@@ -337,10 +321,8 @@ export class WaClient extends EventEmitter {
337
321
  async handleHistorySyncNotification(notification) {
338
322
  try {
339
323
  await processHistorySyncNotification({
340
- logger: this.logger,
324
+ ...this.getMailboxPersistenceDeps(),
341
325
  mediaTransfer: this.mediaTransfer,
342
- contactStore: this.contactStore,
343
- messageStore: this.messageStore,
344
326
  threadStore: this.threadStore,
345
327
  emitEvent: this.emit.bind(this)
346
328
  }, notification);
@@ -369,144 +351,98 @@ export class WaClient extends EventEmitter {
369
351
  this.logger.trace('wa client connect already in-flight');
370
352
  return this.connectPromise;
371
353
  }
372
- this.connectPromise = this.connectInternal().finally(() => {
354
+ this.connectPromise = this.connectionManager
355
+ .connect((frame) => this.handleIncomingFrame(frame))
356
+ .then(() => {
357
+ this.emit('connection_open', {});
358
+ })
359
+ .finally(() => {
373
360
  this.connectPromise = null;
374
361
  });
375
362
  return this.connectPromise;
376
363
  }
377
- async connectInternal() {
378
- if (this.comms) {
379
- this.logger.trace('wa client connect skipped: comms already created');
380
- return;
381
- }
382
- this.logger.info('wa client connect start');
383
- let credentials = await this.authClient.loadOrCreateCredentials();
384
- try {
385
- await this.startCommsWithCredentials(credentials);
386
- }
387
- catch (error) {
388
- if (credentials.routingInfo) {
389
- this.logger.warn('connect failed with routing info, retrying without routing info', {
390
- message: toError(error).message
391
- });
392
- await this.disconnect();
393
- credentials = await this.authClient.clearRoutingInfo();
394
- await this.startCommsWithCredentials(credentials);
395
- }
396
- else {
397
- await this.disconnect();
398
- throw error;
399
- }
400
- }
401
- this.logger.info('wa client connected');
402
- this.emit('connection_open', {});
403
- }
404
- scheduleReconnectAfterPairing() {
405
- this.logger.debug('wa client scheduling reconnect after pairing');
406
- setTimeout(() => {
407
- void this.reconnectAsRegisteredAfterPairing().catch((error) => {
408
- this.handleError(toError(error));
409
- });
410
- }, 0);
411
- }
412
- async reconnectAsRegisteredAfterPairing() {
413
- if (this.pairingReconnectPromise) {
414
- this.logger.trace('pairing reconnect already in-flight');
415
- return this.pairingReconnectPromise;
416
- }
417
- this.pairingReconnectPromise = this.reconnectAsRegisteredAfterPairingInternal().finally(() => {
418
- this.pairingReconnectPromise = null;
419
- });
420
- return this.pairingReconnectPromise;
421
- }
422
- async reconnectAsRegisteredAfterPairingInternal() {
423
- const credentials = this.authClient.getCurrentCredentials();
424
- if (!credentials?.meJid) {
425
- this.logger.trace('pairing reconnect skipped: still unregistered');
426
- return;
427
- }
428
- const currentComms = this.comms;
429
- if (!currentComms) {
430
- this.logger.trace('pairing reconnect skipped: no active comms');
431
- return;
432
- }
433
- this.logger.info('pairing completed, restarting comms as registered');
434
- this.keepAlive.stop();
435
- this.nodeOrchestrator.clearPending(new Error('restarting comms after pairing'));
436
- this.clearCommsBinding();
437
- try {
438
- await currentComms.stopComms();
439
- }
440
- catch (error) {
441
- this.logger.warn('failed to stop pre-registration comms', {
442
- message: toError(error).message
443
- });
444
- }
445
- try {
446
- await this.startCommsWithCredentials(credentials);
447
- }
448
- catch (error) {
449
- this.logger.warn('pairing reconnect failed while starting registered comms', {
450
- message: toError(error).message
451
- });
452
- throw error;
453
- }
454
- }
455
364
  async disconnect() {
456
- this.logger.info('wa client disconnect start');
457
- this.keepAlive.stop();
458
- this.notifyAppStateKeyShareWaiters(false);
459
- this.appStateBootstrapKeyShareWaitDone = false;
460
- await this.authClient.clearTransientState();
461
- this.nodeOrchestrator.clearPending(new Error('client disconnected'));
462
- this.clockSkewMs = null;
463
- this.mediaConnCache = null;
464
- this.passiveTasks.resetInFlightState();
465
- const comms = this.comms;
466
- this.clearCommsBinding();
467
- if (comms) {
468
- await comms.stopComms();
469
- this.logger.info('wa client disconnected');
470
- this.emit('connection_close', {});
471
- }
365
+ this.keyShareCoordinator.notifyDisconnected();
366
+ await this.connectionManager.disconnect();
367
+ this.emit('connection_close', {});
472
368
  }
473
369
  async requestPairingCode(phoneNumber, shouldShowPushNotification = false) {
474
- if (!this.comms || !this.authClient.getCurrentCredentials()) {
370
+ if (!this.connectionManager.isConnected() || !this.authClient.getCurrentCredentials()) {
475
371
  throw new Error('client is not connected');
476
372
  }
477
373
  this.logger.debug('wa client request pairing code');
478
374
  return this.authClient.requestPairingCode(phoneNumber, shouldShowPushNotification);
479
375
  }
480
376
  async fetchPairingCountryCodeIso() {
481
- if (!this.comms || !this.authClient.getCurrentCredentials()) {
377
+ if (!this.connectionManager.isConnected() || !this.authClient.getCurrentCredentials()) {
482
378
  throw new Error('client is not connected');
483
379
  }
484
380
  this.logger.trace('wa client fetch pairing country code iso');
485
381
  return this.authClient.fetchPairingCountryCodeIso();
486
382
  }
487
- async sendMessage(to, content, options = {}) {
383
+ async getLidsByPhoneNumbers(phoneNumbers) {
384
+ if (!this.connectionManager.isConnected() || !this.authClient.getCurrentCredentials()) {
385
+ throw new Error('client is not connected');
386
+ }
387
+ const normalizedPhoneJids = phoneNumbers.map(parsePhoneJid);
388
+ this.logger.trace('wa client query lids by phone numbers', {
389
+ phones: normalizedPhoneJids.length
390
+ });
391
+ return this.signalDeviceSync.queryLidsByPhoneJids(normalizedPhoneJids);
392
+ }
393
+ sendMessage(to, content, options = {}) {
488
394
  return this.messageDispatch.sendMessage(to, content, options);
489
395
  }
490
- async syncSignalSession(jid, reasonIdentity = false) {
491
- await this.messageDispatch.syncSignalSession(jid, reasonIdentity);
396
+ syncSignalSession(jid, reasonIdentity = false) {
397
+ return this.messageDispatch.syncSignalSession(jid, reasonIdentity);
398
+ }
399
+ sendReceipt(input) {
400
+ return this.messageDispatch.sendReceipt(input);
401
+ }
402
+ setChatMute(chatJid, muted, muteEndTimestampMs) {
403
+ return this.appStateMutations.setChatMute(chatJid, muted, muteEndTimestampMs);
404
+ }
405
+ setChatRead(chatJid, read) {
406
+ return this.appStateMutations.setChatRead(chatJid, read);
407
+ }
408
+ setChatPin(chatJid, pinned) {
409
+ return this.appStateMutations.setChatPin(chatJid, pinned);
410
+ }
411
+ setChatArchive(chatJid, archived) {
412
+ return this.appStateMutations.setChatArchive(chatJid, archived);
492
413
  }
493
- async sendReceipt(input) {
494
- await this.messageDispatch.sendReceipt(input);
414
+ clearChat(chatJid, options = {}) {
415
+ return this.appStateMutations.clearChat(chatJid, options);
416
+ }
417
+ deleteChat(chatJid, options = {}) {
418
+ return this.appStateMutations.deleteChat(chatJid, options);
419
+ }
420
+ setChatLock(chatJid, locked) {
421
+ return this.appStateMutations.setChatLock(chatJid, locked);
422
+ }
423
+ setMessageStar(message, starred) {
424
+ return this.appStateMutations.setMessageStar(message, starred);
425
+ }
426
+ deleteMessageForMe(message, options = {}) {
427
+ return this.appStateMutations.deleteMessageForMe(message, options);
428
+ }
429
+ flushAppStateMutations() {
430
+ return this.appStateMutations.flushMutations();
495
431
  }
496
432
  async exportAppState() {
497
433
  return this.appStateSync.exportState();
498
434
  }
499
435
  async syncAppState(options = {}) {
500
- if (!this.comms) {
436
+ if (!this.connectionManager.isConnected()) {
501
437
  throw new Error('client is not connected');
502
438
  }
503
439
  const shouldWaitForKeyShare = (await this.appStateStore.getActiveSyncKey()) === null;
504
- if (shouldWaitForKeyShare && !this.appStateBootstrapKeyShareWaitDone) {
505
- this.appStateBootstrapKeyShareWaitDone = true;
440
+ if (shouldWaitForKeyShare && !this.keyShareCoordinator.isBootstrapDone()) {
441
+ this.keyShareCoordinator.markBootstrapDone();
506
442
  this.logger.info('app-state bootstrap pre-sync waiting for key share', {
507
443
  timeoutMs: WA_APP_STATE_KEY_SHARE_WAIT_TIMEOUT_MS
508
444
  });
509
- const received = await this.waitForAppStateKeyShare(WA_APP_STATE_KEY_SHARE_WAIT_TIMEOUT_MS);
445
+ const received = await this.keyShareCoordinator.waitForShare(WA_APP_STATE_KEY_SHARE_WAIT_TIMEOUT_MS);
510
446
  if (received) {
511
447
  this.logger.info('app-state bootstrap pre-sync received key share, continuing sync');
512
448
  }
@@ -523,17 +459,16 @@ export class WaClient extends EventEmitter {
523
459
  return syncResult;
524
460
  }
525
461
  let retryCount = 0;
526
- let observedKeyShareVersion = this.appStateKeyShareVersion;
527
- while (blockedCollections.length > 0 &&
528
- retryCount < WA_APP_STATE_KEY_SHARE_MAX_RETRIES) {
529
- const hasFreshShare = this.appStateKeyShareVersion !== observedKeyShareVersion;
462
+ let observedKeyShareVersion = this.keyShareCoordinator.getVersion();
463
+ while (blockedCollections.length > 0 && retryCount < WA_APP_STATE_KEY_SHARE_MAX_RETRIES) {
464
+ const hasFreshShare = this.keyShareCoordinator.getVersion() !== observedKeyShareVersion;
530
465
  if (!hasFreshShare) {
531
466
  this.logger.info('app-state bootstrap waiting for key share', {
532
467
  blockedCollections: blockedCollections.join(','),
533
468
  timeoutMs: WA_APP_STATE_KEY_SHARE_WAIT_TIMEOUT_MS,
534
469
  retryCount: retryCount + 1
535
470
  });
536
- const received = await this.waitForAppStateKeyShare(WA_APP_STATE_KEY_SHARE_WAIT_TIMEOUT_MS);
471
+ const received = await this.keyShareCoordinator.waitForShare(WA_APP_STATE_KEY_SHARE_WAIT_TIMEOUT_MS);
537
472
  if (!received) {
538
473
  this.logger.warn('app-state bootstrap key share wait timed out', {
539
474
  blockedCollections: blockedCollections.join(','),
@@ -542,7 +477,7 @@ export class WaClient extends EventEmitter {
542
477
  break;
543
478
  }
544
479
  }
545
- observedKeyShareVersion = this.appStateKeyShareVersion;
480
+ observedKeyShareVersion = this.keyShareCoordinator.getVersion();
546
481
  retryCount += 1;
547
482
  this.logger.info('app-state bootstrap retrying sync after key share', {
548
483
  retryCount,
@@ -573,38 +508,6 @@ export class WaClient extends EventEmitter {
573
508
  .filter((entry) => entry.state === WA_APP_STATE_COLLECTION_STATES.BLOCKED)
574
509
  .map((entry) => entry.collection);
575
510
  }
576
- async waitForAppStateKeyShare(timeoutMs) {
577
- return new Promise((resolve) => {
578
- let settled = false;
579
- let timeoutHandle = null;
580
- const waiter = (received) => {
581
- if (settled) {
582
- return;
583
- }
584
- settled = true;
585
- if (timeoutHandle) {
586
- clearTimeout(timeoutHandle);
587
- timeoutHandle = null;
588
- }
589
- this.appStateKeyShareWaiters.delete(waiter);
590
- resolve(received);
591
- };
592
- this.appStateKeyShareWaiters.add(waiter);
593
- timeoutHandle = setTimeout(() => {
594
- waiter(false);
595
- }, timeoutMs);
596
- });
597
- }
598
- notifyAppStateKeyShareWaiters(received) {
599
- if (this.appStateKeyShareWaiters.size === 0) {
600
- return;
601
- }
602
- const waiters = [...this.appStateKeyShareWaiters.values()];
603
- this.appStateKeyShareWaiters.clear();
604
- for (const waiter of waiters) {
605
- waiter(received);
606
- }
607
- }
608
511
  emitChatEventsFromAppStateSyncResult(syncResult) {
609
512
  const shouldEmitSnapshotMutations = this.options.chatEvents?.emitSnapshotMutations === true;
610
513
  for (const collectionResult of syncResult.collections) {
@@ -644,75 +547,13 @@ export class WaClient extends EventEmitter {
644
547
  }
645
548
  }
646
549
  }
647
- async startCommsWithCredentials(credentials) {
648
- this.logger.debug('starting comms with credentials', {
649
- registered: credentials.meJid !== null && credentials.meJid !== undefined
650
- });
651
- const commsConfig = this.authClient.buildCommsConfig(this.options);
652
- const comms = new WaComms(commsConfig, this.logger);
653
- this.mediaConnCache = null;
654
- this.nodeTransport.bindComms(comms);
655
- try {
656
- comms.startComms(async (frame) => this.handleIncomingFrame(frame));
657
- await comms.waitForConnection(commsConfig.connectTimeoutMs);
658
- this.comms = comms;
659
- this.logger.info('comms connected');
660
- comms.startHandlingRequests();
661
- if (credentials.meJid) {
662
- this.keepAlive.start();
663
- }
664
- else {
665
- this.keepAlive.stop();
666
- }
667
- const serverStaticKey = comms.getServerStaticKey();
668
- if (!serverStaticKey) {
669
- this.logger.trace('no server static key available to persist');
670
- }
671
- else {
672
- await this.authClient.persistServerStaticKey(serverStaticKey);
673
- this.logger.debug('persisted server static key after comms connect');
674
- }
675
- this.passiveTasks.startPassiveTasksAfterConnect();
676
- }
677
- catch (error) {
678
- this.clearCommsBinding();
679
- try {
680
- await comms.stopComms();
681
- }
682
- catch (stopError) {
683
- this.logger.warn('failed to cleanup comms after connection start failure', {
684
- message: toError(stopError).message
685
- });
686
- }
687
- throw error;
688
- }
689
- }
690
- shouldQueueDanglingReceipt(node, error) {
691
- if (node.tag !== WA_MESSAGE_TAGS.RECEIPT) {
692
- return false;
693
- }
694
- const normalized = error.message.trim().toLowerCase();
695
- return (normalized === 'comms is not connected' ||
696
- normalized === 'websocket is not connected' ||
697
- normalized === 'noise session socket closed' ||
698
- normalized.startsWith('socket closed ('));
699
- }
700
- enqueueDanglingReceipt(node) {
701
- if (this.danglingReceipts.length >= WA_DEFAULTS.MAX_DANGLING_RECEIPTS) {
702
- this.danglingReceipts.shift();
703
- }
704
- this.danglingReceipts.push(node.content === undefined
705
- ? {
706
- tag: node.tag,
707
- attrs: { ...node.attrs }
708
- }
709
- : {
710
- tag: node.tag,
711
- attrs: { ...node.attrs },
712
- content: node.content
713
- });
714
- }
715
550
  async clearStoredState() {
551
+ const danglingReceipts = this.receiptQueue.take();
552
+ if (danglingReceipts.length > 0) {
553
+ this.logger.debug('cleared dangling receipts while clearing stored state', {
554
+ count: danglingReceipts.length
555
+ });
556
+ }
716
557
  await this.authClient.clearStoredCredentials();
717
558
  await this.appStateStore.clear();
718
559
  await this.contactStore.clear();
@@ -728,18 +569,4 @@ export class WaClient extends EventEmitter {
728
569
  this.logger.error('wa client error', { message: error.message });
729
570
  this.emit('client_error', { error });
730
571
  }
731
- clearCommsBinding() {
732
- this.notifyAppStateKeyShareWaiters(false);
733
- this.comms = null;
734
- this.nodeTransport.bindComms(null);
735
- }
736
- updateClockSkewFromSuccess(serverUnixSeconds) {
737
- const serverMs = serverUnixSeconds * 1000;
738
- const nowMs = Date.now();
739
- this.clockSkewMs = serverMs - nowMs;
740
- this.logger.debug('updated clock skew from success', {
741
- serverUnixSeconds,
742
- clockSkewMs: this.clockSkewMs
743
- });
744
- }
745
572
  }