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