zapo-js 0.1.0 → 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.
- package/README.md +12 -7
- package/dist/appstate/WaAppStateCrypto.js +18 -25
- package/dist/appstate/WaAppStateSyncClient.js +181 -114
- package/dist/appstate/WaAppStateSyncResponseParser.js +16 -5
- package/dist/appstate/constants.js +4 -3
- package/dist/appstate/utils.js +10 -30
- package/dist/auth/WaAuthClient.js +48 -55
- package/dist/auth/flow/WaAuthCredentialsFlow.js +21 -14
- package/dist/auth/index.js +1 -3
- package/dist/auth/pairing/WaPairingFlow.js +21 -23
- package/dist/auth/pairing/WaQrFlow.js +37 -24
- package/dist/client/WaClient.js +103 -276
- package/dist/client/WaClientFactory.js +227 -110
- package/dist/client/connection/WaConnectionManager.js +292 -0
- package/dist/client/connection/WaKeyShareCoordinator.js +63 -0
- package/dist/client/connection/WaReceiptQueue.js +51 -0
- package/dist/client/coordinators/WaAppStateMutationCoordinator.js +471 -0
- package/dist/client/coordinators/WaGroupCoordinator.js +27 -17
- package/dist/client/coordinators/WaIncomingNodeCoordinator.js +20 -27
- package/dist/client/coordinators/WaMessageDispatchCoordinator.js +231 -686
- package/dist/client/coordinators/WaRetryCoordinator.js +70 -37
- package/dist/client/dirty.js +35 -29
- package/dist/client/events/chat.js +4 -3
- package/dist/client/events/group.js +59 -36
- package/dist/client/history-sync.js +53 -63
- package/dist/client/incoming.js +23 -20
- package/dist/client/mailbox.js +8 -8
- package/dist/client/messages.js +4 -4
- package/dist/client/messaging/fanout.js +189 -0
- package/dist/client/messaging/key-protocol.js +130 -0
- package/dist/client/messaging/participants.js +191 -0
- package/dist/crypto/core/hkdf.js +3 -8
- package/dist/crypto/core/index.js +1 -4
- package/dist/crypto/core/keys.js +2 -3
- package/dist/crypto/core/primitives.js +12 -15
- package/dist/crypto/core/random.js +7 -26
- package/dist/crypto/curves/Ed25519.js +7 -8
- package/dist/crypto/curves/X25519.js +13 -16
- package/dist/crypto/index.js +0 -5
- package/dist/esm/appstate/WaAppStateCrypto.js +6 -13
- package/dist/esm/appstate/WaAppStateSyncClient.js +174 -107
- package/dist/esm/appstate/WaAppStateSyncResponseParser.js +17 -6
- package/dist/esm/appstate/constants.js +3 -2
- package/dist/esm/appstate/utils.js +8 -27
- package/dist/esm/auth/WaAuthClient.js +48 -55
- package/dist/esm/auth/flow/WaAuthCredentialsFlow.js +21 -14
- package/dist/esm/auth/index.js +0 -1
- package/dist/esm/auth/pairing/WaPairingFlow.js +14 -16
- package/dist/esm/auth/pairing/WaQrFlow.js +37 -24
- package/dist/esm/client/WaClient.js +103 -276
- package/dist/esm/client/WaClientFactory.js +227 -110
- package/dist/esm/client/connection/WaConnectionManager.js +288 -0
- package/dist/esm/client/connection/WaKeyShareCoordinator.js +59 -0
- package/dist/esm/client/connection/WaReceiptQueue.js +47 -0
- package/dist/esm/client/coordinators/WaAppStateMutationCoordinator.js +467 -0
- package/dist/esm/client/coordinators/WaGroupCoordinator.js +20 -10
- package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +20 -27
- package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +232 -687
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +71 -38
- package/dist/esm/client/dirty.js +30 -24
- package/dist/esm/client/events/chat.js +4 -3
- package/dist/esm/client/events/group.js +50 -28
- package/dist/esm/client/history-sync.js +50 -60
- package/dist/esm/client/incoming.js +23 -20
- package/dist/esm/client/mailbox.js +8 -8
- package/dist/esm/client/messages.js +1 -1
- package/dist/esm/client/messaging/fanout.js +186 -0
- package/dist/esm/client/messaging/key-protocol.js +127 -0
- package/dist/esm/client/messaging/participants.js +188 -0
- package/dist/esm/crypto/core/hkdf.js +3 -8
- package/dist/esm/crypto/core/index.js +0 -1
- package/dist/esm/crypto/core/keys.js +2 -3
- package/dist/esm/crypto/core/primitives.js +12 -15
- package/dist/esm/crypto/core/random.js +6 -25
- package/dist/esm/crypto/curves/Ed25519.js +4 -5
- package/dist/esm/crypto/curves/X25519.js +10 -13
- package/dist/esm/crypto/index.js +0 -2
- package/dist/esm/infra/log/ConsoleLogger.js +18 -17
- package/dist/esm/infra/log/PinoLogger.js +15 -9
- package/dist/esm/infra/log/types.js +11 -1
- package/dist/esm/infra/perf/BoundedTaskQueue.js +13 -17
- package/dist/esm/media/WaMediaCrypto.js +2 -4
- package/dist/esm/media/WaMediaTransferClient.js +226 -58
- package/dist/esm/media/conn.js +10 -6
- package/dist/esm/media/constants.js +4 -1
- package/dist/esm/message/WaMessageClient.js +4 -13
- package/dist/esm/message/ack.js +6 -6
- package/dist/esm/message/addon-crypto.js +59 -0
- package/dist/esm/message/incoming.js +106 -111
- package/dist/esm/message/index.js +2 -0
- package/dist/esm/message/reporting-token.js +438 -0
- package/dist/esm/message/use-case-secret.js +49 -0
- package/dist/esm/protocol/appstate.js +58 -0
- package/dist/esm/protocol/constants.js +2 -1
- package/dist/esm/protocol/index.js +2 -10
- package/dist/esm/protocol/jid.js +63 -51
- package/dist/esm/protocol/media.js +3 -3
- package/dist/esm/protocol/nodes.js +2 -0
- package/dist/esm/protocol/usync.js +11 -0
- package/dist/esm/retry/index.js +1 -0
- package/dist/esm/retry/outbound.js +4 -5
- package/dist/esm/retry/parse.js +58 -76
- package/dist/esm/retry/replay.js +48 -49
- package/dist/esm/retry/tracker.js +56 -0
- package/dist/esm/signal/api/SignalDeviceSyncApi.js +249 -82
- package/dist/esm/signal/api/SignalDigestSyncApi.js +6 -1
- package/dist/esm/signal/api/SignalIdentitySyncApi.js +49 -34
- package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +70 -62
- package/dist/esm/signal/api/SignalSessionSyncApi.js +23 -30
- package/dist/esm/signal/crypto/WaAdvSignature.js +3 -5
- package/dist/esm/signal/group/SenderKeyChain.js +28 -23
- package/dist/esm/signal/group/SenderKeyCodec.js +2 -4
- package/dist/esm/signal/group/SenderKeyManager.js +26 -16
- package/dist/esm/signal/index.js +1 -0
- package/dist/esm/signal/session/SignalProtocol.js +49 -14
- package/dist/esm/signal/session/SignalRatchet.js +24 -15
- package/dist/esm/signal/session/SignalSession.js +14 -9
- package/dist/esm/signal/session/resolver.js +186 -0
- package/dist/esm/signal/store/sqlite.js +16 -37
- package/dist/esm/store/createStore.js +16 -18
- package/dist/esm/store/noop.store.js +3 -6
- package/dist/esm/store/providers/memory/appstate.store.js +30 -6
- package/dist/esm/store/providers/memory/contact.store.js +5 -0
- package/dist/esm/store/providers/memory/device-list.store.js +3 -30
- package/dist/esm/store/providers/memory/message.store.js +11 -5
- package/dist/esm/store/providers/memory/participants.store.js +1 -8
- package/dist/esm/store/providers/memory/sender-key.store.js +5 -7
- package/dist/esm/store/providers/memory/signal.store.js +13 -1
- package/dist/esm/store/providers/memory/thread.store.js +5 -0
- package/dist/esm/store/providers/sqlite/appstate.store.js +82 -1
- package/dist/esm/store/providers/sqlite/connection.js +18 -13
- package/dist/esm/store/providers/sqlite/contact.store.js +31 -18
- package/dist/esm/store/providers/sqlite/device-list.store.js +7 -35
- package/dist/esm/store/providers/sqlite/message.store.js +45 -32
- package/dist/esm/store/providers/sqlite/migrations.js +1 -1
- package/dist/esm/store/providers/sqlite/participants.store.js +1 -9
- package/dist/esm/store/providers/sqlite/retry.store.js +8 -11
- package/dist/esm/store/providers/sqlite/sender-key.store.js +25 -30
- package/dist/esm/store/providers/sqlite/signal.store.js +104 -22
- package/dist/esm/store/providers/sqlite/table-names.js +107 -0
- package/dist/esm/store/providers/sqlite/thread.store.js +35 -22
- package/dist/esm/transport/WaComms.js +25 -23
- package/dist/esm/transport/WaWebSocket.js +115 -12
- package/dist/esm/transport/binary/decoder.js +4 -4
- package/dist/esm/transport/binary/encoder.js +12 -4
- package/dist/esm/transport/index.js +1 -0
- package/dist/esm/transport/keepalive/WaKeepAlive.js +2 -8
- package/dist/esm/transport/node/WaNodeOrchestrator.js +2 -4
- package/dist/esm/transport/node/WaNodeTransport.js +0 -3
- package/dist/esm/transport/node/builders/{accountSync.js → account-sync.js} +16 -36
- package/dist/esm/transport/node/builders/index.js +2 -1
- package/dist/esm/transport/node/builders/message.js +9 -0
- package/dist/esm/transport/node/builders/pairing.js +4 -5
- package/dist/esm/transport/node/builders/usync.js +41 -0
- package/dist/esm/transport/node/helpers.js +107 -5
- package/dist/esm/transport/node/usync.js +35 -0
- package/dist/esm/transport/noise/WaFrameCodec.js +48 -33
- package/dist/esm/transport/noise/WaNoiseCert.js +3 -6
- package/dist/esm/transport/noise/WaNoiseSession.js +17 -10
- package/dist/esm/transport/proxy.js +27 -0
- package/dist/esm/transport/stream/parse.js +13 -48
- package/dist/esm/util/bytes.js +50 -32
- package/dist/esm/util/coercion.js +6 -14
- package/dist/esm/util/primitives.js +39 -14
- package/dist/infra/log/ConsoleLogger.js +18 -17
- package/dist/infra/log/PinoLogger.js +15 -9
- package/dist/infra/log/types.js +12 -0
- package/dist/infra/perf/BoundedTaskQueue.js +13 -17
- package/dist/media/WaMediaCrypto.js +1 -3
- package/dist/media/WaMediaTransferClient.js +259 -58
- package/dist/media/conn.js +10 -6
- package/dist/media/constants.js +4 -1
- package/dist/message/WaMessageClient.js +5 -14
- package/dist/message/ack.js +6 -6
- package/dist/message/addon-crypto.js +65 -0
- package/dist/message/incoming.js +104 -109
- package/dist/message/index.js +2 -0
- package/dist/message/reporting-token.js +443 -0
- package/dist/message/use-case-secret.js +55 -0
- package/dist/protocol/appstate.js +59 -1
- package/dist/protocol/constants.js +7 -1
- package/dist/protocol/index.js +20 -42
- package/dist/protocol/jid.js +64 -51
- package/dist/protocol/media.js +3 -3
- package/dist/protocol/nodes.js +2 -0
- package/dist/protocol/usync.js +14 -0
- package/dist/retry/index.js +3 -1
- package/dist/retry/outbound.js +6 -7
- package/dist/retry/parse.js +57 -75
- package/dist/retry/replay.js +46 -47
- package/dist/retry/tracker.js +59 -0
- package/dist/signal/api/SignalDeviceSyncApi.js +247 -80
- package/dist/signal/api/SignalDigestSyncApi.js +6 -1
- package/dist/signal/api/SignalIdentitySyncApi.js +49 -34
- package/dist/signal/api/SignalMissingPreKeysSyncApi.js +67 -59
- package/dist/signal/api/SignalSessionSyncApi.js +23 -30
- package/dist/signal/crypto/WaAdvSignature.js +2 -4
- package/dist/signal/group/SenderKeyChain.js +27 -22
- package/dist/signal/group/SenderKeyCodec.js +1 -3
- package/dist/signal/group/SenderKeyManager.js +26 -16
- package/dist/signal/index.js +3 -1
- package/dist/signal/session/SignalProtocol.js +49 -14
- package/dist/signal/session/SignalRatchet.js +24 -15
- package/dist/signal/session/SignalSession.js +14 -9
- package/dist/signal/session/resolver.js +189 -0
- package/dist/signal/store/sqlite.js +16 -37
- package/dist/store/createStore.js +16 -18
- package/dist/store/noop.store.js +3 -6
- package/dist/store/providers/memory/appstate.store.js +28 -4
- package/dist/store/providers/memory/contact.store.js +5 -0
- package/dist/store/providers/memory/device-list.store.js +3 -30
- package/dist/store/providers/memory/message.store.js +11 -5
- package/dist/store/providers/memory/participants.store.js +1 -8
- package/dist/store/providers/memory/sender-key.store.js +8 -10
- package/dist/store/providers/memory/signal.store.js +21 -9
- package/dist/store/providers/memory/thread.store.js +5 -0
- package/dist/store/providers/sqlite/appstate.store.js +81 -0
- package/dist/store/providers/sqlite/connection.js +18 -13
- package/dist/store/providers/sqlite/contact.store.js +31 -18
- package/dist/store/providers/sqlite/device-list.store.js +7 -35
- package/dist/store/providers/sqlite/message.store.js +45 -32
- package/dist/store/providers/sqlite/migrations.js +1 -1
- package/dist/store/providers/sqlite/participants.store.js +1 -9
- package/dist/store/providers/sqlite/retry.store.js +8 -11
- package/dist/store/providers/sqlite/sender-key.store.js +24 -29
- package/dist/store/providers/sqlite/signal.store.js +105 -23
- package/dist/store/providers/sqlite/table-names.js +113 -0
- package/dist/store/providers/sqlite/thread.store.js +35 -22
- package/dist/transport/WaComms.js +27 -25
- package/dist/transport/WaWebSocket.js +148 -12
- package/dist/transport/binary/decoder.js +4 -4
- package/dist/transport/binary/encoder.js +12 -4
- package/dist/transport/index.js +7 -1
- package/dist/transport/keepalive/WaKeepAlive.js +1 -7
- package/dist/transport/node/WaNodeOrchestrator.js +2 -4
- package/dist/transport/node/WaNodeTransport.js +0 -3
- package/dist/transport/node/builders/{accountSync.js → account-sync.js} +15 -35
- package/dist/transport/node/builders/index.js +12 -9
- package/dist/transport/node/builders/message.js +9 -0
- package/dist/transport/node/builders/pairing.js +4 -5
- package/dist/transport/node/builders/usync.js +45 -0
- package/dist/transport/node/helpers.js +112 -4
- package/dist/transport/node/usync.js +38 -0
- package/dist/transport/noise/WaFrameCodec.js +47 -32
- package/dist/transport/noise/WaNoiseCert.js +5 -8
- package/dist/transport/noise/WaNoiseSession.js +17 -10
- package/dist/transport/proxy.js +34 -0
- package/dist/transport/stream/parse.js +17 -53
- package/dist/types/appstate/WaAppStateCrypto.d.ts +0 -1
- package/dist/types/appstate/WaAppStateSyncClient.d.ts +5 -2
- package/dist/types/appstate/constants.d.ts +1 -0
- package/dist/types/appstate/store/sqlite.d.ts +4 -18
- package/dist/types/appstate/utils.d.ts +0 -1
- package/dist/types/auth/WaAuthClient.d.ts +10 -12
- package/dist/types/auth/index.d.ts +0 -2
- package/dist/types/auth/pairing/WaQrFlow.d.ts +1 -1
- package/dist/types/auth/types.d.ts +6 -9
- package/dist/types/client/WaClient.d.ts +27 -25
- package/dist/types/client/WaClientFactory.d.ts +22 -23
- package/dist/types/client/connection/WaConnectionManager.d.ts +64 -0
- package/dist/types/client/connection/WaKeyShareCoordinator.d.ts +14 -0
- package/dist/types/client/connection/WaReceiptQueue.d.ts +13 -0
- package/dist/types/client/coordinators/WaAppStateMutationCoordinator.d.ts +46 -0
- package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +0 -1
- package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +18 -41
- package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +2 -0
- package/dist/types/client/dirty.d.ts +1 -0
- package/dist/types/client/events/group.d.ts +2 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/messaging/fanout.d.ts +14 -0
- package/dist/types/client/messaging/key-protocol.d.ts +18 -0
- package/dist/types/client/messaging/participants.d.ts +13 -0
- package/dist/types/client/types.d.ts +24 -1
- package/dist/types/crypto/core/hkdf.d.ts +0 -6
- package/dist/types/crypto/core/index.d.ts +0 -1
- package/dist/types/crypto/core/random.d.ts +1 -7
- package/dist/types/crypto/index.d.ts +0 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/infra/log/ConsoleLogger.d.ts +2 -1
- package/dist/types/infra/log/PinoLogger.d.ts +1 -1
- package/dist/types/infra/log/types.d.ts +1 -0
- package/dist/types/infra/perf/BoundedTaskQueue.d.ts +1 -1
- package/dist/types/media/WaMediaTransferClient.d.ts +13 -3
- package/dist/types/media/types.d.ts +5 -0
- package/dist/types/message/addon-crypto.d.ts +25 -0
- package/dist/types/message/index.d.ts +2 -0
- package/dist/types/message/reporting-token.d.ts +19 -0
- package/dist/types/message/use-case-secret.d.ts +20 -0
- package/dist/types/protocol/appstate.d.ts +58 -0
- package/dist/types/protocol/constants.d.ts +2 -1
- package/dist/types/protocol/index.d.ts +2 -10
- package/dist/types/protocol/jid.d.ts +3 -3
- package/dist/types/protocol/nodes.d.ts +2 -0
- package/dist/types/protocol/usync.d.ts +11 -0
- package/dist/types/retry/index.d.ts +1 -0
- package/dist/types/retry/replay.d.ts +0 -4
- package/dist/types/retry/tracker.d.ts +19 -0
- package/dist/types/retry/types.d.ts +4 -3
- package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +13 -1
- package/dist/types/signal/group/SenderKeyCodec.d.ts +4 -6
- package/dist/types/signal/index.d.ts +1 -0
- package/dist/types/signal/session/SignalProtocol.d.ts +9 -0
- package/dist/types/signal/session/resolver.d.ts +17 -0
- package/dist/types/store/contracts/appstate.store.d.ts +3 -0
- package/dist/types/store/contracts/contact.store.d.ts +1 -0
- package/dist/types/store/contracts/device-list.store.d.ts +0 -3
- package/dist/types/store/contracts/message.store.d.ts +1 -0
- package/dist/types/store/contracts/participants.store.d.ts +0 -1
- package/dist/types/store/contracts/sender-key.store.d.ts +0 -1
- package/dist/types/store/contracts/signal.store.d.ts +6 -0
- package/dist/types/store/contracts/thread.store.d.ts +1 -0
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/providers/memory/appstate.store.d.ts +2 -0
- package/dist/types/store/providers/memory/contact.store.d.ts +1 -0
- package/dist/types/store/providers/memory/device-list.store.d.ts +0 -3
- package/dist/types/store/providers/memory/message.store.d.ts +1 -0
- package/dist/types/store/providers/memory/participants.store.d.ts +0 -1
- package/dist/types/store/providers/memory/sender-key.store.d.ts +0 -1
- package/dist/types/store/providers/memory/signal.store.d.ts +6 -0
- package/dist/types/store/providers/memory/thread.store.d.ts +1 -0
- package/dist/types/store/providers/sqlite/appstate.store.d.ts +2 -0
- package/dist/types/store/providers/sqlite/contact.store.d.ts +2 -0
- package/dist/types/store/providers/sqlite/device-list.store.d.ts +0 -3
- package/dist/types/store/providers/sqlite/message.store.d.ts +2 -0
- package/dist/types/store/providers/sqlite/participants.store.d.ts +0 -1
- package/dist/types/store/providers/sqlite/retry.store.d.ts +0 -1
- package/dist/types/store/providers/sqlite/sender-key.store.d.ts +0 -1
- package/dist/types/store/providers/sqlite/signal.store.d.ts +7 -0
- package/dist/types/store/providers/sqlite/table-names.d.ts +5 -0
- package/dist/types/store/providers/sqlite/thread.store.d.ts +2 -0
- package/dist/types/store/types.d.ts +3 -0
- package/dist/types/transport/WaWebSocket.d.ts +3 -0
- package/dist/types/transport/index.d.ts +2 -1
- package/dist/types/transport/keepalive/WaKeepAlive.d.ts +0 -1
- package/dist/types/transport/node/WaNodeTransport.d.ts +0 -9
- package/dist/types/transport/node/builders/group.d.ts +4 -6
- package/dist/types/transport/node/builders/index.d.ts +2 -1
- package/dist/types/transport/node/builders/message.d.ts +14 -25
- package/dist/types/transport/node/builders/retry.d.ts +2 -4
- package/dist/types/transport/node/builders/usync.d.ts +21 -0
- package/dist/types/transport/node/helpers.d.ts +8 -0
- package/dist/types/transport/node/usync.d.ts +2 -0
- package/dist/types/transport/noise/WaFrameCodec.d.ts +3 -0
- package/dist/types/transport/noise/WaNoiseSession.d.ts +1 -0
- package/dist/types/transport/proxy.d.ts +6 -0
- package/dist/types/transport/stream/parse.d.ts +0 -1
- package/dist/types/transport/types.d.ts +18 -1
- package/dist/types/util/bytes.d.ts +5 -0
- package/dist/types/util/primitives.d.ts +3 -0
- package/dist/util/bytes.js +55 -33
- package/dist/util/coercion.js +6 -14
- package/dist/util/primitives.js +42 -14
- package/package.json +27 -9
- package/proto/index.d.ts +1090 -1048
- package/proto/index.js +1 -1
- package/scripts/check-node-version.cjs +0 -1
- package/dist/crypto/core/encoding.js +0 -29
- package/dist/esm/crypto/core/encoding.js +0 -25
- package/dist/esm/util/base64.js +0 -18
- package/dist/esm/util/signal-address.js +0 -5
- package/dist/types/crypto/core/encoding.d.ts +0 -11
- package/dist/types/util/base64.d.ts +0 -4
- package/dist/types/util/signal-address.d.ts +0 -2
- package/dist/util/base64.js +0 -24
- package/dist/util/signal-address.js +0 -8
- /package/dist/types/transport/node/builders/{accountSync.d.ts → account-sync.d.ts} +0 -0
|
@@ -3,14 +3,7 @@ import type { Logger } from '../infra/log/types';
|
|
|
3
3
|
import type { WaAuthStore } from '../store/contracts/auth.store';
|
|
4
4
|
import type { WaSignalStore } from '../store/contracts/signal.store';
|
|
5
5
|
import type { BinaryNode } from '../transport/types';
|
|
6
|
-
|
|
7
|
-
readonly onQr?: (qr: string, ttlMs: number) => void;
|
|
8
|
-
readonly onPairingCode?: (code: string) => void;
|
|
9
|
-
readonly onPairingRefresh?: (forceManual: boolean) => void;
|
|
10
|
-
readonly onPaired?: (credentials: WaAuthCredentials) => void;
|
|
11
|
-
readonly onError?: (error: Error) => void;
|
|
12
|
-
}
|
|
13
|
-
interface WaAuthClientDependencies {
|
|
6
|
+
type WaAuthClientDeps = Readonly<{
|
|
14
7
|
readonly logger: Logger;
|
|
15
8
|
readonly authStore: WaAuthStore;
|
|
16
9
|
readonly signalStore: WaSignalStore;
|
|
@@ -18,8 +11,14 @@ interface WaAuthClientDependencies {
|
|
|
18
11
|
readonly sendNode: (node: BinaryNode) => Promise<void>;
|
|
19
12
|
readonly query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
20
13
|
};
|
|
21
|
-
readonly callbacks?:
|
|
22
|
-
|
|
14
|
+
readonly callbacks?: {
|
|
15
|
+
readonly onQr?: (qr: string, ttlMs: number) => void;
|
|
16
|
+
readonly onPairingCode?: (code: string) => void;
|
|
17
|
+
readonly onPairingRefresh?: (forceManual: boolean) => void;
|
|
18
|
+
readonly onPaired?: (credentials: WaAuthCredentials) => void;
|
|
19
|
+
readonly onError?: (error: Error) => void;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
23
22
|
export declare class WaAuthClient {
|
|
24
23
|
private readonly options;
|
|
25
24
|
private readonly logger;
|
|
@@ -29,7 +28,7 @@ export declare class WaAuthClient {
|
|
|
29
28
|
private readonly qrFlow;
|
|
30
29
|
private readonly pairingFlow;
|
|
31
30
|
private credentials;
|
|
32
|
-
constructor(options: WaAuthClientOptions, deps:
|
|
31
|
+
constructor(options: WaAuthClientOptions, deps: WaAuthClientDeps);
|
|
33
32
|
getState(connected?: boolean): {
|
|
34
33
|
connected: boolean;
|
|
35
34
|
registered: boolean;
|
|
@@ -45,7 +44,6 @@ export declare class WaAuthClient {
|
|
|
45
44
|
persistServerHasPreKeys(serverHasPreKeys: boolean): Promise<void>;
|
|
46
45
|
persistRoutingInfo(routingInfo: Uint8Array): Promise<void>;
|
|
47
46
|
clearRoutingInfo(): Promise<WaAuthCredentials>;
|
|
48
|
-
persistMeLid(meLid: string): Promise<void>;
|
|
49
47
|
persistSuccessAttributes(attributes: WaSuccessPersistAttributes): Promise<void>;
|
|
50
48
|
requestPairingCode(phoneNumber: string, shouldShowPushNotification?: boolean): Promise<string>;
|
|
51
49
|
fetchPairingCountryCodeIso(): Promise<string>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export * from './types';
|
|
2
|
-
export { getLoginIdentity } from '../protocol/jid';
|
|
3
2
|
export { WaAuthClient } from './WaAuthClient';
|
|
4
3
|
export { completeCompanionFinish, createCompanionHello } from './pairing/WaPairingCodeCrypto';
|
|
5
4
|
export { WaAuthSqliteStore } from '../store/providers/sqlite/auth.store';
|
|
6
|
-
export type { WaAuthStore } from '../store/contracts/auth.store';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SignalKeyPair } from '../crypto/curves/types';
|
|
2
2
|
import type { Proto } from '..';
|
|
3
3
|
import type { RegistrationInfo, SignedPreKeyRecord } from '../signal/types';
|
|
4
|
+
import type { WaCommsConfig, WaProxyTransport } from '../transport/types';
|
|
4
5
|
export interface WaAuthCredentials {
|
|
5
6
|
readonly noiseKeyPair: SignalKeyPair;
|
|
6
7
|
readonly registrationInfo: RegistrationInfo;
|
|
@@ -21,15 +22,11 @@ export interface WaAuthCredentials {
|
|
|
21
22
|
readonly connectionLocation?: string;
|
|
22
23
|
readonly accountCreationTs?: number;
|
|
23
24
|
}
|
|
24
|
-
export
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly reconnectIntervalMs?: number;
|
|
30
|
-
readonly timeoutIntervalMs?: number;
|
|
31
|
-
readonly maxReconnectAttempts?: number;
|
|
32
|
-
}
|
|
25
|
+
export type WaAuthSocketOptions = Pick<WaCommsConfig, 'url' | 'urls' | 'protocols' | 'connectTimeoutMs' | 'reconnectIntervalMs' | 'timeoutIntervalMs' | 'maxReconnectAttempts'> & {
|
|
26
|
+
readonly proxy?: {
|
|
27
|
+
readonly ws?: WaProxyTransport;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
33
30
|
export interface WaAuthClientOptions {
|
|
34
31
|
readonly deviceBrowser?: string;
|
|
35
32
|
readonly devicePlatform?: string;
|
|
@@ -2,14 +2,14 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import type { WaAppStateStoreData, WaAppStateSyncResult } from '../appstate/types';
|
|
3
3
|
import type { WaAppStateSyncOptions } from '../appstate/types';
|
|
4
4
|
import type { WaAppStateSyncClient } from '../appstate/WaAppStateSyncClient';
|
|
5
|
-
import type { WaAuthCredentials } from '../auth/types';
|
|
6
5
|
import type { WaGroupCoordinator } from './coordinators/WaGroupCoordinator';
|
|
7
6
|
import type { WaMessageDispatchCoordinator } from './coordinators/WaMessageDispatchCoordinator';
|
|
8
|
-
import type {
|
|
7
|
+
import type { WaAppStateMessageKey, WaClearChatOptions, WaClientOptions, WaDeleteChatOptions, WaDeleteMessageForMeOptions, WaSendMessageOptions, WaClientEventMap, WaIncomingNodeHandlerRegistration } from './types';
|
|
9
8
|
import type { Logger } from '../infra/log/types';
|
|
10
9
|
import type { WaMediaTransferClient } from '../media/WaMediaTransferClient';
|
|
11
10
|
import type { WaMessagePublishResult, WaSendMessageContent, WaSendReceiptInput } from '../message/types';
|
|
12
11
|
import type { WaMessageClient } from '../message/WaMessageClient';
|
|
12
|
+
import type { SignalLidSyncResult } from '../signal/api/SignalDeviceSyncApi';
|
|
13
13
|
import type { BinaryNode } from '../transport/types';
|
|
14
14
|
export declare class WaClient extends EventEmitter {
|
|
15
15
|
private readonly options;
|
|
@@ -25,42 +25,44 @@ export declare class WaClient extends EventEmitter {
|
|
|
25
25
|
private readonly threadStore;
|
|
26
26
|
private readonly authClient;
|
|
27
27
|
private readonly nodeOrchestrator;
|
|
28
|
-
private readonly keepAlive;
|
|
29
28
|
private readonly nodeTransport;
|
|
29
|
+
private readonly signalDeviceSync;
|
|
30
30
|
readonly appStateSync: WaAppStateSyncClient;
|
|
31
|
+
private readonly appStateMutations;
|
|
31
32
|
private readonly incomingNode;
|
|
32
|
-
private readonly passiveTasks;
|
|
33
33
|
readonly mediaTransfer: WaMediaTransferClient;
|
|
34
34
|
readonly messageDispatch: WaMessageDispatchCoordinator;
|
|
35
35
|
readonly messageClient: WaMessageClient;
|
|
36
36
|
readonly groupCoordinator: WaGroupCoordinator;
|
|
37
|
-
private
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private
|
|
37
|
+
private readonly passiveTasks;
|
|
38
|
+
private readonly keepAlive;
|
|
39
|
+
private readonly receiptQueue;
|
|
40
|
+
private readonly keyShareCoordinator;
|
|
41
|
+
private readonly connectionManager;
|
|
41
42
|
private connectPromise;
|
|
42
|
-
private readonly danglingReceipts;
|
|
43
|
-
private readonly appStateKeyShareWaiters;
|
|
44
|
-
private appStateKeyShareVersion;
|
|
45
|
-
private appStateBootstrapKeyShareWaitDone;
|
|
46
43
|
constructor(options: WaClientOptions, logger?: Logger);
|
|
47
44
|
on<K extends keyof WaClientEventMap>(event: K, listener: WaClientEventMap[K]): this;
|
|
45
|
+
on(event: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
48
46
|
once<K extends keyof WaClientEventMap>(event: K, listener: WaClientEventMap[K]): this;
|
|
47
|
+
once(event: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
49
48
|
off<K extends keyof WaClientEventMap>(event: K, listener: WaClientEventMap[K]): this;
|
|
50
|
-
|
|
49
|
+
off(event: string | symbol, listener: (...args: unknown[]) => void): this;
|
|
50
|
+
emit<K extends keyof WaClientEventMap>(event: K, payload: Parameters<WaClientEventMap[K]>[0]): boolean;
|
|
51
|
+
emit(event: string | symbol, ...args: unknown[]): boolean;
|
|
51
52
|
getState(): {
|
|
52
53
|
connected: boolean;
|
|
53
54
|
registered: boolean;
|
|
54
55
|
hasQr: boolean;
|
|
55
56
|
hasPairingCode: boolean;
|
|
56
57
|
};
|
|
57
|
-
getCredentials(): WaAuthCredentials | null;
|
|
58
|
+
getCredentials(): import("../auth").WaAuthCredentials | null;
|
|
58
59
|
getClockSkewMs(): number | null;
|
|
59
60
|
sendNode(node: BinaryNode): Promise<void>;
|
|
60
61
|
query(node: BinaryNode, timeoutMs?: number): Promise<BinaryNode>;
|
|
61
62
|
registerIncomingHandler(registration: WaIncomingNodeHandlerRegistration): () => void;
|
|
62
63
|
unregisterIncomingHandler(registration: WaIncomingNodeHandlerRegistration): boolean;
|
|
63
64
|
private bindNodeTransportEvents;
|
|
65
|
+
private getMailboxPersistenceDeps;
|
|
64
66
|
private handleIncomingMessageEvent;
|
|
65
67
|
private handleIncomingAppStateSyncKeyShare;
|
|
66
68
|
private handleIncomingAppStateSyncKeyRequest;
|
|
@@ -70,28 +72,28 @@ export declare class WaClient extends EventEmitter {
|
|
|
70
72
|
private queryWithContext;
|
|
71
73
|
private handleIncomingFrame;
|
|
72
74
|
connect(): Promise<void>;
|
|
73
|
-
private connectInternal;
|
|
74
|
-
private scheduleReconnectAfterPairing;
|
|
75
|
-
private reconnectAsRegisteredAfterPairing;
|
|
76
|
-
private reconnectAsRegisteredAfterPairingInternal;
|
|
77
75
|
disconnect(): Promise<void>;
|
|
78
76
|
requestPairingCode(phoneNumber: string, shouldShowPushNotification?: boolean): Promise<string>;
|
|
79
77
|
fetchPairingCountryCodeIso(): Promise<string>;
|
|
78
|
+
getLidsByPhoneNumbers(phoneNumbers: readonly string[]): Promise<readonly SignalLidSyncResult[]>;
|
|
80
79
|
sendMessage(to: string, content: WaSendMessageContent, options?: WaSendMessageOptions): Promise<WaMessagePublishResult>;
|
|
81
80
|
syncSignalSession(jid: string, reasonIdentity?: boolean): Promise<void>;
|
|
82
81
|
sendReceipt(input: WaSendReceiptInput): Promise<void>;
|
|
82
|
+
setChatMute(chatJid: string, muted: boolean, muteEndTimestampMs?: number): Promise<void>;
|
|
83
|
+
setChatRead(chatJid: string, read: boolean): Promise<void>;
|
|
84
|
+
setChatPin(chatJid: string, pinned: boolean): Promise<void>;
|
|
85
|
+
setChatArchive(chatJid: string, archived: boolean): Promise<void>;
|
|
86
|
+
clearChat(chatJid: string, options?: WaClearChatOptions): Promise<void>;
|
|
87
|
+
deleteChat(chatJid: string, options?: WaDeleteChatOptions): Promise<void>;
|
|
88
|
+
setChatLock(chatJid: string, locked: boolean): Promise<void>;
|
|
89
|
+
setMessageStar(message: WaAppStateMessageKey, starred: boolean): Promise<void>;
|
|
90
|
+
deleteMessageForMe(message: WaAppStateMessageKey, options?: WaDeleteMessageForMeOptions): Promise<void>;
|
|
91
|
+
flushAppStateMutations(): Promise<void>;
|
|
83
92
|
exportAppState(): Promise<WaAppStateStoreData>;
|
|
84
93
|
syncAppState(options?: WaAppStateSyncOptions): Promise<WaAppStateSyncResult>;
|
|
85
94
|
private executeAppStateSync;
|
|
86
95
|
private getBlockedAppStateCollections;
|
|
87
|
-
private waitForAppStateKeyShare;
|
|
88
|
-
private notifyAppStateKeyShareWaiters;
|
|
89
96
|
private emitChatEventsFromAppStateSyncResult;
|
|
90
|
-
private startCommsWithCredentials;
|
|
91
|
-
private shouldQueueDanglingReceipt;
|
|
92
|
-
private enqueueDanglingReceipt;
|
|
93
97
|
private clearStoredState;
|
|
94
98
|
private handleError;
|
|
95
|
-
private clearCommsBinding;
|
|
96
|
-
private updateClockSkewFromSuccess;
|
|
97
99
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { WaAppStateSyncOptions, WaAppStateSyncResult } from '../appstate/types';
|
|
1
2
|
import { WaAppStateSyncClient } from '../appstate/WaAppStateSyncClient';
|
|
2
3
|
import { WaAuthClient } from '../auth/WaAuthClient';
|
|
4
|
+
import { WaConnectionManager } from './connection/WaConnectionManager';
|
|
5
|
+
import { WaKeyShareCoordinator } from './connection/WaKeyShareCoordinator';
|
|
6
|
+
import { WaReceiptQueue } from './connection/WaReceiptQueue';
|
|
7
|
+
import { WaAppStateMutationCoordinator } from './coordinators/WaAppStateMutationCoordinator';
|
|
3
8
|
import { type WaGroupCoordinator } from './coordinators/WaGroupCoordinator';
|
|
4
9
|
import { WaIncomingNodeCoordinator } from './coordinators/WaIncomingNodeCoordinator';
|
|
5
10
|
import { WaMessageDispatchCoordinator } from './coordinators/WaMessageDispatchCoordinator';
|
|
@@ -9,7 +14,6 @@ import { type WaStreamControlHandler } from './coordinators/WaStreamControlCoord
|
|
|
9
14
|
import { buildMediaMessageContent } from './messages';
|
|
10
15
|
import type { WaClientEventMap, WaClientOptions, WaIncomingMessageEvent } from './types';
|
|
11
16
|
import type { Logger } from '../infra/log/types';
|
|
12
|
-
import type { WaMediaConn } from '../media/types';
|
|
13
17
|
import { WaMediaTransferClient } from '../media/WaMediaTransferClient';
|
|
14
18
|
import { WaMessageClient } from '../message/WaMessageClient';
|
|
15
19
|
import { SignalDeviceSyncApi } from '../signal/api/SignalDeviceSyncApi';
|
|
@@ -24,13 +28,24 @@ import { WaKeepAlive } from '../transport/keepalive/WaKeepAlive';
|
|
|
24
28
|
import { WaNodeOrchestrator } from '../transport/node/WaNodeOrchestrator';
|
|
25
29
|
import { WaNodeTransport } from '../transport/node/WaNodeTransport';
|
|
26
30
|
import type { BinaryNode } from '../transport/types';
|
|
27
|
-
import type { WaComms } from '../transport/WaComms';
|
|
28
31
|
type WaMediaMessageBuildOptions = Parameters<typeof buildMediaMessageContent>[0];
|
|
29
32
|
interface WaClientBase {
|
|
30
33
|
readonly options: Readonly<WaClientOptions>;
|
|
31
34
|
readonly logger: Logger;
|
|
32
35
|
readonly sessionStore: ReturnType<WaClientOptions['store']['session']>;
|
|
33
36
|
}
|
|
37
|
+
interface WaClientBuildRuntime {
|
|
38
|
+
readonly sendNode: (node: BinaryNode) => Promise<void>;
|
|
39
|
+
readonly query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
40
|
+
readonly queryWithContext: (context: string, node: BinaryNode, timeoutMs?: number, contextData?: Readonly<Record<string, unknown>>) => Promise<BinaryNode>;
|
|
41
|
+
readonly syncAppState: () => Promise<void>;
|
|
42
|
+
readonly syncAppStateWithOptions: (options?: WaAppStateSyncOptions) => Promise<WaAppStateSyncResult>;
|
|
43
|
+
readonly emitEvent: <K extends keyof WaClientEventMap>(event: K, ...args: Parameters<WaClientEventMap[K]>) => void;
|
|
44
|
+
readonly handleIncomingMessageEvent: (event: WaIncomingMessageEvent) => Promise<void>;
|
|
45
|
+
readonly handleError: (error: Error) => void;
|
|
46
|
+
readonly handleIncomingFrame: (frame: Uint8Array) => Promise<void>;
|
|
47
|
+
readonly clearStoredState: () => Promise<void>;
|
|
48
|
+
}
|
|
34
49
|
interface WaClientDependencies {
|
|
35
50
|
readonly nodeTransport: WaNodeTransport;
|
|
36
51
|
readonly nodeOrchestrator: WaNodeOrchestrator;
|
|
@@ -50,34 +65,18 @@ interface WaClientDependencies {
|
|
|
50
65
|
readonly messageDispatch: WaMessageDispatchCoordinator;
|
|
51
66
|
readonly retryCoordinator: WaRetryCoordinator;
|
|
52
67
|
readonly appStateSync: WaAppStateSyncClient;
|
|
68
|
+
readonly appStateMutations: WaAppStateMutationCoordinator;
|
|
53
69
|
readonly streamControl: WaStreamControlHandler;
|
|
54
70
|
readonly incomingNode: WaIncomingNodeCoordinator;
|
|
55
71
|
readonly passiveTasks: WaPassiveTasksCoordinator;
|
|
56
72
|
readonly groupCoordinator: WaGroupCoordinator;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
readonly
|
|
60
|
-
readonly query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
61
|
-
readonly queryWithContext: (context: string, node: BinaryNode, timeoutMs?: number, contextData?: Readonly<Record<string, unknown>>) => Promise<BinaryNode>;
|
|
62
|
-
readonly syncAppState: () => Promise<void>;
|
|
63
|
-
readonly emitEvent: <K extends keyof WaClientEventMap>(event: K, ...args: Parameters<WaClientEventMap[K]>) => void;
|
|
64
|
-
readonly handleIncomingMessageEvent: (event: WaIncomingMessageEvent) => Promise<void>;
|
|
65
|
-
readonly handleError: (error: Error) => void;
|
|
66
|
-
readonly scheduleReconnectAfterPairing: () => void;
|
|
67
|
-
readonly updateClockSkewFromSuccess: (serverUnixSeconds: number) => void;
|
|
68
|
-
readonly getComms: () => WaComms | null;
|
|
69
|
-
readonly getMediaConnCache: () => WaMediaConn | null;
|
|
70
|
-
readonly setMediaConnCache: (mediaConn: WaMediaConn | null) => void;
|
|
71
|
-
readonly disconnect: () => Promise<void>;
|
|
72
|
-
readonly clearStoredState: () => Promise<void>;
|
|
73
|
-
readonly connect: () => Promise<void>;
|
|
74
|
-
readonly shouldQueueDanglingReceipt: (node: BinaryNode, error: Error) => boolean;
|
|
75
|
-
readonly enqueueDanglingReceipt: (node: BinaryNode) => void;
|
|
76
|
-
readonly takeDanglingReceipts: () => BinaryNode[];
|
|
73
|
+
readonly receiptQueue: WaReceiptQueue;
|
|
74
|
+
readonly keyShareCoordinator: WaKeyShareCoordinator;
|
|
75
|
+
readonly connectionManager: WaConnectionManager;
|
|
77
76
|
}
|
|
78
77
|
export declare function resolveWaClientBase(options: WaClientOptions, logger: Logger): WaClientBase;
|
|
79
78
|
export declare function buildWaClientDependencies(input: {
|
|
80
79
|
readonly base: WaClientBase;
|
|
81
|
-
readonly
|
|
80
|
+
readonly runtime: WaClientBuildRuntime;
|
|
82
81
|
}): WaClientDependencies;
|
|
83
82
|
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { WaAuthClient } from '../../auth/WaAuthClient';
|
|
2
|
+
import type { WaPassiveTasksCoordinator } from '../coordinators/WaPassiveTasksCoordinator';
|
|
3
|
+
import type { WaClientOptions } from '../types';
|
|
4
|
+
import type { Logger } from '../../infra/log/types';
|
|
5
|
+
import type { WaMediaConn } from '../../media/types';
|
|
6
|
+
import type { WaKeepAlive } from '../../transport/keepalive/WaKeepAlive';
|
|
7
|
+
import type { WaNodeOrchestrator } from '../../transport/node/WaNodeOrchestrator';
|
|
8
|
+
import type { WaNodeTransport } from '../../transport/node/WaNodeTransport';
|
|
9
|
+
import { WaComms } from '../../transport/WaComms';
|
|
10
|
+
interface WaConnectionManagerOptions {
|
|
11
|
+
readonly logger: Logger;
|
|
12
|
+
readonly options: Readonly<WaClientOptions>;
|
|
13
|
+
readonly authClient: WaAuthClient;
|
|
14
|
+
readonly keepAlive: WaKeepAlive;
|
|
15
|
+
readonly nodeOrchestrator: WaNodeOrchestrator;
|
|
16
|
+
readonly nodeTransport: WaNodeTransport;
|
|
17
|
+
readonly getPassiveTasks: () => WaPassiveTasksCoordinator | null;
|
|
18
|
+
readonly clearStoredCredentials: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare class WaConnectionManager {
|
|
21
|
+
private readonly logger;
|
|
22
|
+
private readonly options;
|
|
23
|
+
private readonly authClient;
|
|
24
|
+
private readonly keepAlive;
|
|
25
|
+
private readonly nodeOrchestrator;
|
|
26
|
+
private readonly nodeTransport;
|
|
27
|
+
private readonly getPassiveTasks;
|
|
28
|
+
private readonly clearStoredCredentialsCallback;
|
|
29
|
+
private comms;
|
|
30
|
+
private clockSkewMs;
|
|
31
|
+
private mediaConnCache;
|
|
32
|
+
private connectPromise;
|
|
33
|
+
private pairingReconnectPromise;
|
|
34
|
+
private frameHandler;
|
|
35
|
+
private pendingComms;
|
|
36
|
+
private lifecycleGeneration;
|
|
37
|
+
private lifecycleQueue;
|
|
38
|
+
constructor(options: WaConnectionManagerOptions);
|
|
39
|
+
connect(frameHandler: (frame: Uint8Array) => Promise<void>): Promise<void>;
|
|
40
|
+
scheduleReconnectAfterPairing(): void;
|
|
41
|
+
disconnect(): Promise<void>;
|
|
42
|
+
clearStoredCredentials(): Promise<void>;
|
|
43
|
+
isConnected(): boolean;
|
|
44
|
+
getComms(): WaComms | null;
|
|
45
|
+
getClockSkewMs(): number | null;
|
|
46
|
+
getMediaConnCache(): WaMediaConn | null;
|
|
47
|
+
setMediaConnCache(value: WaMediaConn | null): void;
|
|
48
|
+
updateClockSkewFromSuccess(serverUnixSeconds: number): void;
|
|
49
|
+
private connectInternal;
|
|
50
|
+
private reconnectAsRegisteredAfterPairing;
|
|
51
|
+
private reconnectAsRegisteredAfterPairingInternal;
|
|
52
|
+
private disconnectInternal;
|
|
53
|
+
private startCommsWithCredentials;
|
|
54
|
+
private clearCommsBinding;
|
|
55
|
+
private stopCommsQuietly;
|
|
56
|
+
private nextLifecycleGeneration;
|
|
57
|
+
private runLifecycleOperation;
|
|
58
|
+
private invalidatePendingComms;
|
|
59
|
+
private isLifecycleCurrent;
|
|
60
|
+
private assertLifecycleCurrent;
|
|
61
|
+
private createLifecycleSupersededError;
|
|
62
|
+
private isLifecycleSupersededError;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class WaKeyShareCoordinator {
|
|
2
|
+
private readonly waiters;
|
|
3
|
+
private version;
|
|
4
|
+
private bootstrapDone;
|
|
5
|
+
constructor();
|
|
6
|
+
waitForShare(timeoutMs: number): Promise<boolean>;
|
|
7
|
+
notifyReceived(): void;
|
|
8
|
+
notifyDisconnected(): void;
|
|
9
|
+
isBootstrapDone(): boolean;
|
|
10
|
+
markBootstrapDone(): void;
|
|
11
|
+
getVersion(): number;
|
|
12
|
+
hasWaiters(): boolean;
|
|
13
|
+
private releaseWaiters;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BinaryNode } from '../../transport/types';
|
|
2
|
+
export declare class WaReceiptQueue {
|
|
3
|
+
private readonly maxSize;
|
|
4
|
+
private readonly danglingReceipts;
|
|
5
|
+
private danglingHead;
|
|
6
|
+
constructor(options?: {
|
|
7
|
+
readonly maxSize?: number;
|
|
8
|
+
});
|
|
9
|
+
shouldQueue(node: BinaryNode, error: Error): boolean;
|
|
10
|
+
enqueue(node: BinaryNode): void;
|
|
11
|
+
take(): BinaryNode[];
|
|
12
|
+
size(): number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { WaAppStateSyncOptions, WaAppStateSyncResult } from '../../appstate/types';
|
|
2
|
+
import type { WaAppStateMessageKey, WaClearChatOptions, WaDeleteChatOptions, WaDeleteMessageForMeOptions } from '../types';
|
|
3
|
+
import type { Logger } from '../../infra/log/types';
|
|
4
|
+
import type { WaMessageStore } from '../../store/contracts/message.store';
|
|
5
|
+
interface WaAppStateMutationCoordinatorOptions {
|
|
6
|
+
readonly logger: Logger;
|
|
7
|
+
readonly messageStore: WaMessageStore;
|
|
8
|
+
readonly syncAppState: (options?: WaAppStateSyncOptions) => Promise<WaAppStateSyncResult>;
|
|
9
|
+
readonly archiveRangeLimit?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class WaAppStateMutationCoordinator {
|
|
12
|
+
private readonly logger;
|
|
13
|
+
private readonly messageStore;
|
|
14
|
+
private readonly syncAppState;
|
|
15
|
+
private readonly archiveRangeLimit;
|
|
16
|
+
private readonly pendingMutations;
|
|
17
|
+
private flushPromise;
|
|
18
|
+
constructor(options: WaAppStateMutationCoordinatorOptions);
|
|
19
|
+
setChatMute(chatJid: string, muted: boolean, muteEndTimestampMs?: number): Promise<void>;
|
|
20
|
+
setMessageStar(message: WaAppStateMessageKey, starred: boolean): Promise<void>;
|
|
21
|
+
setChatRead(chatJid: string, read: boolean): Promise<void>;
|
|
22
|
+
setChatPin(chatJid: string, pinned: boolean): Promise<void>;
|
|
23
|
+
setChatArchive(chatJid: string, archived: boolean): Promise<void>;
|
|
24
|
+
clearChat(chatJid: string, options?: WaClearChatOptions): Promise<void>;
|
|
25
|
+
deleteChat(chatJid: string, options?: WaDeleteChatOptions): Promise<void>;
|
|
26
|
+
deleteMessageForMe(message: WaAppStateMessageKey, options?: WaDeleteMessageForMeOptions): Promise<void>;
|
|
27
|
+
setChatLock(chatJid: string, locked: boolean): Promise<void>;
|
|
28
|
+
flushMutations(): Promise<void>;
|
|
29
|
+
private enqueueAndFlush;
|
|
30
|
+
private enqueueMutation;
|
|
31
|
+
private takePendingMutationsBatch;
|
|
32
|
+
private flushPendingMutationsLoop;
|
|
33
|
+
private requeueMutations;
|
|
34
|
+
private createSetMutation;
|
|
35
|
+
private createArchiveMutation;
|
|
36
|
+
private buildChatMessageRange;
|
|
37
|
+
private toChatMessageRangeMessage;
|
|
38
|
+
private normalizeMessageRangeParticipant;
|
|
39
|
+
private toOptionalTimestampSeconds;
|
|
40
|
+
private normalizeChatMutationJid;
|
|
41
|
+
private buildMessageMutationIndex;
|
|
42
|
+
private resolveMessageMutationParticipant;
|
|
43
|
+
private buildMutationIndex;
|
|
44
|
+
private describeMutationActions;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -51,7 +51,6 @@ export declare class WaIncomingNodeCoordinator {
|
|
|
51
51
|
unregisterIncomingHandler(registration: WaIncomingNodeHandlerRegistration): boolean;
|
|
52
52
|
private dispatchIncomingNode;
|
|
53
53
|
private isRetryReceiptType;
|
|
54
|
-
private getHandlersForNode;
|
|
55
54
|
private registerDefaultIncomingHandlers;
|
|
56
55
|
private handleSuccessNode;
|
|
57
56
|
private scheduleMediaConnWarmup;
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
import type { WaAppStateSyncKey } from '../../appstate/types';
|
|
2
|
+
import type { DeviceFanoutResolver } from '../messaging/fanout';
|
|
3
|
+
import type { AppStateSyncKeyProtocol } from '../messaging/key-protocol';
|
|
4
|
+
import type { GroupParticipantsCache } from '../messaging/participants';
|
|
2
5
|
import type { WaGroupEvent, WaSignalMessagePublishInput, WaSendMessageOptions } from '../types';
|
|
3
6
|
import type { Logger } from '../../infra/log/types';
|
|
4
7
|
import type { WaEncryptedMessageInput, WaMessagePublishOptions, WaMessagePublishResult, WaSendMessageContent, WaSendReceiptInput } from '../../message/types';
|
|
5
8
|
import type { WaMessageClient } from '../../message/WaMessageClient';
|
|
6
9
|
import type { Proto } from '../..';
|
|
7
|
-
import type {
|
|
8
|
-
import type { SignalIdentitySyncApi } from '../../signal/api/SignalIdentitySyncApi';
|
|
9
|
-
import type { SignalSessionSyncApi } from '../../signal/api/SignalSessionSyncApi';
|
|
10
|
+
import type { OutboundRetryTracker } from '../../retry/tracker';
|
|
10
11
|
import type { SenderKeyManager } from '../../signal/group/SenderKeyManager';
|
|
12
|
+
import type { SignalSessionResolver } from '../../signal/session/resolver';
|
|
11
13
|
import type { SignalProtocol } from '../../signal/session/SignalProtocol';
|
|
12
|
-
import type { WaParticipantsStore } from '../../store/contracts/participants.store';
|
|
13
|
-
import type { WaRetryStore } from '../../store/contracts/retry.store';
|
|
14
|
-
import type { WaSignalStore } from '../../store/contracts/signal.store';
|
|
15
14
|
import type { BinaryNode } from '../../transport/types';
|
|
16
15
|
interface WaMessageDispatchCoordinatorOptions {
|
|
17
16
|
readonly logger: Logger;
|
|
18
17
|
readonly messageClient: WaMessageClient;
|
|
19
|
-
readonly
|
|
20
|
-
readonly
|
|
18
|
+
readonly retryTracker: OutboundRetryTracker;
|
|
19
|
+
readonly sessionResolver: SignalSessionResolver;
|
|
20
|
+
readonly fanoutResolver: DeviceFanoutResolver;
|
|
21
|
+
readonly participantsCache: GroupParticipantsCache;
|
|
22
|
+
readonly appStateSyncKeyProtocol: AppStateSyncKeyProtocol;
|
|
21
23
|
readonly buildMessageContent: (content: WaSendMessageContent) => Promise<Proto.IMessage>;
|
|
22
|
-
readonly queryGroupParticipantJids: (groupJid: string) => Promise<readonly string[]>;
|
|
23
24
|
readonly senderKeyManager: SenderKeyManager;
|
|
24
25
|
readonly signalProtocol: SignalProtocol;
|
|
25
|
-
readonly signalStore: WaSignalStore;
|
|
26
|
-
readonly signalDeviceSync: SignalDeviceSyncApi;
|
|
27
|
-
readonly signalIdentitySync: SignalIdentitySyncApi;
|
|
28
|
-
readonly signalSessionSync: SignalSessionSyncApi;
|
|
29
26
|
readonly getCurrentMeJid: () => string | null | undefined;
|
|
30
27
|
readonly getCurrentMeLid: () => string | null | undefined;
|
|
31
28
|
readonly getCurrentSignedIdentity: () => Proto.IADVSignedDeviceIdentity | null | undefined;
|
|
@@ -33,17 +30,14 @@ interface WaMessageDispatchCoordinatorOptions {
|
|
|
33
30
|
export declare class WaMessageDispatchCoordinator {
|
|
34
31
|
private readonly logger;
|
|
35
32
|
private readonly messageClient;
|
|
36
|
-
private readonly
|
|
37
|
-
private readonly
|
|
38
|
-
private readonly
|
|
33
|
+
private readonly retryTracker;
|
|
34
|
+
private readonly sessionResolver;
|
|
35
|
+
private readonly fanoutResolver;
|
|
36
|
+
private readonly participantsCache;
|
|
37
|
+
private readonly appStateSyncKeyProtocol;
|
|
39
38
|
private readonly buildMessageContent;
|
|
40
|
-
private readonly queryGroupParticipantJids;
|
|
41
39
|
private readonly senderKeyManager;
|
|
42
40
|
private readonly signalProtocol;
|
|
43
|
-
private readonly signalStore;
|
|
44
|
-
private readonly signalDeviceSync;
|
|
45
|
-
private readonly signalIdentitySync;
|
|
46
|
-
private readonly signalSessionSync;
|
|
47
41
|
private readonly getCurrentMeJid;
|
|
48
42
|
private readonly getCurrentMeLid;
|
|
49
43
|
private readonly getCurrentSignedIdentity;
|
|
@@ -57,34 +51,17 @@ export declare class WaMessageDispatchCoordinator {
|
|
|
57
51
|
requestAppStateSyncKeys(keyIds: readonly Uint8Array[]): Promise<readonly string[]>;
|
|
58
52
|
sendAppStateSyncKeyShare(toDeviceJid: string, keys: readonly WaAppStateSyncKey[], missingKeyIds?: readonly Uint8Array[]): Promise<void>;
|
|
59
53
|
mutateParticipantsCacheFromGroupEvent(event: WaGroupEvent): Promise<void>;
|
|
60
|
-
private publishProtocolMessageToDevice;
|
|
61
|
-
private resolveOwnPeerDeviceJids;
|
|
62
|
-
private normalizeKeyIds;
|
|
63
|
-
private publishWithRetryTracking;
|
|
64
|
-
private createRetryOutboundRecord;
|
|
65
|
-
private safeUpsertRetryOutboundRecord;
|
|
66
54
|
private shouldUseGroupDirectPath;
|
|
67
55
|
private publishGroupDirectMessage;
|
|
68
56
|
private publishGroupSenderKeyMessage;
|
|
69
|
-
private resolveGroupParticipantUsers;
|
|
70
|
-
private resolveGroupJidForParticipantCacheEvent;
|
|
71
|
-
private extractParticipantUsersFromGroupEvent;
|
|
72
|
-
private mergeParticipantUsersIntoCache;
|
|
73
|
-
private removeParticipantUsersFromCache;
|
|
74
|
-
private replaceParticipantUsersInCache;
|
|
75
|
-
private areParticipantListsEqual;
|
|
76
|
-
private refreshGroupParticipantUsers;
|
|
77
|
-
private sanitizeParticipantUsers;
|
|
78
57
|
private resolveGroupAddressingMode;
|
|
79
58
|
private resolveSenderForAddressingMode;
|
|
80
59
|
private encryptGroupDistributionParticipants;
|
|
81
|
-
private resolveGroupParticipantDeviceJids;
|
|
82
60
|
private publishDirectSignalMessageWithFanout;
|
|
83
|
-
private
|
|
84
|
-
private
|
|
85
|
-
private
|
|
61
|
+
private withResolvedMessageId;
|
|
62
|
+
private generateOutgoingMessageId;
|
|
63
|
+
private tryBuildReportingTokenArtifacts;
|
|
86
64
|
private getEncodedSignedDeviceIdentity;
|
|
87
|
-
private ensureSignalSession;
|
|
88
65
|
private requireCurrentMeJid;
|
|
89
66
|
}
|
|
90
67
|
export {};
|
|
@@ -38,6 +38,7 @@ export declare class WaRetryCoordinator {
|
|
|
38
38
|
private readonly getCurrentMeLid;
|
|
39
39
|
private readonly getCurrentSignedIdentity;
|
|
40
40
|
private readonly retryProcessingByMessageId;
|
|
41
|
+
private nextRetryCleanupAtMs;
|
|
41
42
|
constructor(options: WaRetryCoordinatorOptions);
|
|
42
43
|
onDecryptFailure(context: WaRetryDecryptFailureContext, error: unknown): Promise<boolean>;
|
|
43
44
|
handleIncomingRetryReceipt(receiptNode: BinaryNode): Promise<void>;
|
|
@@ -57,5 +58,6 @@ export declare class WaRetryCoordinator {
|
|
|
57
58
|
private isRequesterAuthorizedDevice;
|
|
58
59
|
private mapOutboundStateFromReceiptType;
|
|
59
60
|
private sendRetryAckSafe;
|
|
61
|
+
private maybeCleanupRetryStore;
|
|
60
62
|
}
|
|
61
63
|
export {};
|
|
@@ -11,6 +11,7 @@ interface WaDirtySyncRuntime {
|
|
|
11
11
|
readonly queryWithContext: (context: string, node: BinaryNode, timeoutMs?: number, contextData?: Readonly<Record<string, unknown>>) => Promise<BinaryNode>;
|
|
12
12
|
readonly getCurrentCredentials: () => WaAuthCredentials | null;
|
|
13
13
|
readonly syncAppState: () => Promise<void>;
|
|
14
|
+
readonly generateUsyncSid: () => Promise<string>;
|
|
14
15
|
}
|
|
15
16
|
export declare function parseDirtyBits(nodes: readonly BinaryNode[], logger: Logger): readonly WaDirtyBit[];
|
|
16
17
|
export declare function handleDirtyBits(runtime: WaDirtySyncRuntime, dirtyBits: readonly WaDirtyBit[]): Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { WaGroupEvent, WaIncomingUnhandledStanzaEvent } from '../types';
|
|
1
|
+
import type { WaGroupEvent, WaGroupEventParticipant, WaIncomingUnhandledStanzaEvent } from '../types';
|
|
2
2
|
import type { BinaryNode } from '../../transport/types';
|
|
3
3
|
export interface WaParseGroupNotificationResult {
|
|
4
4
|
readonly events: readonly WaGroupEvent[];
|
|
5
5
|
readonly unhandled: readonly WaIncomingUnhandledStanzaEvent[];
|
|
6
6
|
}
|
|
7
|
+
export declare function parseParticipants(node: BinaryNode): readonly WaGroupEventParticipant[];
|
|
7
8
|
export declare function parseGroupNotificationEvents(notificationNode: BinaryNode): WaParseGroupNotificationResult;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { WaClient } from './WaClient';
|
|
2
|
-
export type { WaChatEvent, WaChatEventAction, WaChatEventSource, WaClientEventMap, WaClientOptions, WaHistorySyncChunkEvent, WaHistorySyncOptions } from './types';
|
|
2
|
+
export type { WaAppStateMessageKey, WaClientProxyOptions, WaClearChatOptions, WaChatEvent, WaChatEventAction, WaChatEventSource, WaClientEventMap, WaClientOptions, WaDeleteChatOptions, WaDeleteMessageForMeOptions, WaHistorySyncChunkEvent, WaHistorySyncOptions } from './types';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Logger } from '../../infra/log/types';
|
|
2
|
+
import type { SignalDeviceSyncApi } from '../../signal/api/SignalDeviceSyncApi';
|
|
3
|
+
export type DeviceFanoutResolver = {
|
|
4
|
+
resolveDirectFanoutDeviceJids(recipientJid: string, selfDeviceJid: string): Promise<readonly string[]>;
|
|
5
|
+
resolveGroupParticipantDeviceJids(participantUserJids: readonly string[]): Promise<readonly string[]>;
|
|
6
|
+
resolveOwnPeerDeviceJids(): Promise<readonly string[]>;
|
|
7
|
+
resolveSelfDeviceJidForRecipient(recipientJid: string, meJid: string, meLid: string | null | undefined): string;
|
|
8
|
+
};
|
|
9
|
+
export declare function createDeviceFanoutResolver(options: {
|
|
10
|
+
readonly signalDeviceSync: SignalDeviceSyncApi;
|
|
11
|
+
readonly getCurrentMeJid: () => string | null | undefined;
|
|
12
|
+
readonly getCurrentMeLid: () => string | null | undefined;
|
|
13
|
+
readonly logger: Logger;
|
|
14
|
+
}): DeviceFanoutResolver;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WaAppStateSyncKey } from '../../appstate/types';
|
|
2
|
+
import type { DeviceFanoutResolver } from '../messaging/fanout';
|
|
3
|
+
import type { WaSignalMessagePublishInput } from '../types';
|
|
4
|
+
import type { Logger } from '../../infra/log/types';
|
|
5
|
+
import type { WaMessagePublishOptions, WaMessagePublishResult } from '../../message/types';
|
|
6
|
+
type PublishSignalMessageFn = (input: WaSignalMessagePublishInput, options?: WaMessagePublishOptions) => Promise<WaMessagePublishResult>;
|
|
7
|
+
export type AppStateSyncKeyProtocol = {
|
|
8
|
+
requestKeys(keyIds: readonly Uint8Array[]): Promise<readonly string[]>;
|
|
9
|
+
sendKeyShare(toDeviceJid: string, keys: readonly WaAppStateSyncKey[], missingKeyIds?: readonly Uint8Array[]): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export declare function createAppStateSyncKeyProtocol(options: {
|
|
12
|
+
readonly publishSignalMessage: PublishSignalMessageFn;
|
|
13
|
+
readonly fanoutResolver: DeviceFanoutResolver;
|
|
14
|
+
readonly getCurrentMeJid: () => string | null | undefined;
|
|
15
|
+
readonly getCurrentMeLid: () => string | null | undefined;
|
|
16
|
+
readonly logger: Logger;
|
|
17
|
+
}): AppStateSyncKeyProtocol;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WaGroupEvent } from '../types';
|
|
2
|
+
import type { Logger } from '../../infra/log/types';
|
|
3
|
+
import type { WaParticipantsStore } from '../../store/contracts/participants.store';
|
|
4
|
+
export type GroupParticipantsCache = {
|
|
5
|
+
resolveParticipantUsers(groupJid: string): Promise<readonly string[]>;
|
|
6
|
+
refreshParticipantUsers(groupJid: string): Promise<readonly string[]>;
|
|
7
|
+
mutateFromGroupEvent(event: WaGroupEvent): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export declare function createGroupParticipantsCache(options: {
|
|
10
|
+
readonly participantsStore: WaParticipantsStore;
|
|
11
|
+
readonly queryGroupParticipantJids: (groupJid: string) => Promise<readonly string[]>;
|
|
12
|
+
readonly logger: Logger;
|
|
13
|
+
}): GroupParticipantsCache;
|