zapo-js 0.3.0 → 1.0.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/LICENSE +21 -0
- package/README.md +97 -177
- package/dist/appstate/{WaAppStateCrypto.js → crypto/WaAppStateCrypto.js} +58 -49
- package/dist/appstate/index.js +7 -6
- package/dist/appstate/{encoding.js → parsers/encoding.js} +11 -4
- package/dist/appstate/{response-parser.js → parsers/response-parser.js} +20 -8
- package/dist/appstate/{WaAppStateSyncClient.js → sync/WaAppStateSyncClient.js} +174 -53
- package/dist/appstate/utils.js +16 -0
- package/dist/appstate-spec.js +89 -0
- package/dist/auth/WaAuthClient.js +100 -5
- package/dist/auth/credentials-flow.js +19 -7
- package/dist/auth/pairing/WaPairingFlow.js +33 -24
- package/dist/auth/pairing/pairing-code-crypto.js +16 -18
- package/dist/client/WaClient.js +342 -473
- package/dist/client/WaClientFactory.js +279 -78
- package/dist/client/connection/WaConnectionManager.js +28 -11
- package/dist/client/coordinators/WaAbPropsCoordinator.js +1 -2
- package/dist/client/coordinators/WaAppStateMutationCoordinator.js +663 -143
- package/dist/client/coordinators/WaBotCoordinator.js +345 -0
- package/dist/client/coordinators/WaBroadcastListCoordinator.js +20 -0
- package/dist/client/coordinators/WaBusinessCoordinator.js +81 -171
- package/dist/client/coordinators/WaEmailCoordinator.js +1 -0
- package/dist/client/coordinators/WaGroupCoordinator.js +529 -52
- package/dist/client/coordinators/WaIncomingNodeCoordinator.js +97 -12
- package/dist/client/coordinators/WaLowLevelCoordinator.js +41 -0
- package/dist/client/coordinators/WaMessageCoordinator.js +365 -0
- package/dist/client/coordinators/WaMessageDispatchCoordinator.js +682 -204
- package/dist/client/coordinators/WaNewsletterCoordinator.js +18 -0
- package/dist/client/coordinators/WaPassiveTasksCoordinator.js +17 -4
- package/dist/client/coordinators/WaPresenceCoordinator.js +21 -0
- package/dist/client/coordinators/WaPrivacyCoordinator.js +7 -5
- package/dist/client/coordinators/WaProfileCoordinator.js +220 -49
- package/dist/client/coordinators/WaRetryCoordinator.js +256 -125
- package/dist/client/coordinators/WaStatusCoordinator.js +49 -0
- package/dist/client/coordinators/WaStreamControlCoordinator.js +6 -6
- package/dist/client/coordinators/WaTrustedContactTokenCoordinator.js +7 -6
- package/dist/client/events/appstate-mutation.js +133 -0
- package/dist/client/events/business.js +375 -0
- package/dist/client/events/call.js +58 -0
- package/dist/client/events/chatstate.js +23 -0
- package/dist/client/events/devices.js +15 -16
- package/dist/client/{dirty.js → events/dirty.js} +33 -19
- package/dist/client/events/group.js +13 -24
- package/dist/client/events/identity.js +2 -1
- package/dist/client/events/incoming.js +502 -0
- package/dist/client/events/mex-notification.js +181 -0
- package/dist/client/events/picture.js +33 -0
- package/dist/client/events/presence.js +44 -0
- package/dist/client/events/receipt.js +26 -0
- package/dist/client/media.js +161 -4
- package/dist/client/messaging/fanout.js +9 -10
- package/dist/client/messaging/{participants.js → group-metadata.js} +73 -35
- package/dist/client/messaging/ignore-key.js +132 -0
- package/dist/client/messaging/key-protocol.js +3 -17
- package/dist/client/messaging/link-preview.js +159 -0
- package/dist/client/messaging/messages.js +671 -0
- package/dist/client/newsletter/admin.js +165 -0
- package/dist/client/newsletter/content.js +253 -0
- package/dist/client/newsletter/discovery.js +115 -0
- package/dist/client/newsletter/messaging.js +197 -0
- package/dist/client/newsletter/mex.js +41 -0
- package/dist/client/newsletter/parse.js +217 -0
- package/dist/client/persistence/WriteBehindPersistence.js +31 -4
- package/dist/client/{history-sync.js → persistence/history-sync.js} +125 -18
- package/dist/client/persistence/mailbox.js +104 -0
- package/dist/client/tokens/cs-token.js +11 -17
- package/dist/crypto/core/hkdf.js +12 -12
- package/dist/crypto/core/index.js +6 -8
- package/dist/crypto/core/keys.js +1 -8
- package/dist/crypto/core/nonce.js +12 -12
- package/dist/crypto/core/primitives.js +123 -93
- package/dist/crypto/core/random.js +6 -0
- package/dist/crypto/core/xeddsa.js +11 -9
- package/dist/crypto/curves/Ed25519.js +32 -21
- package/dist/crypto/curves/X25519.js +70 -34
- package/dist/crypto/curves/constants.js +2 -1
- package/dist/crypto/math/constants.js +1 -2
- package/dist/crypto/math/mod.js +0 -33
- package/dist/esm/appstate/{WaAppStateCrypto.js → crypto/WaAppStateCrypto.js} +58 -49
- package/dist/esm/appstate/index.js +5 -5
- package/dist/esm/appstate/{encoding.js → parsers/encoding.js} +11 -4
- package/dist/esm/appstate/{response-parser.js → parsers/response-parser.js} +20 -8
- package/dist/esm/appstate/{WaAppStateSyncClient.js → sync/WaAppStateSyncClient.js} +174 -52
- package/dist/esm/appstate/utils.js +16 -0
- package/dist/esm/appstate-spec.js +79 -0
- package/dist/esm/auth/WaAuthClient.js +100 -5
- package/dist/esm/auth/credentials-flow.js +18 -6
- package/dist/esm/auth/pairing/WaPairingFlow.js +34 -25
- package/dist/esm/auth/pairing/pairing-code-crypto.js +12 -14
- package/dist/esm/client/WaClient.js +345 -476
- package/dist/esm/client/WaClientFactory.js +280 -79
- package/dist/esm/client/connection/WaConnectionManager.js +28 -11
- package/dist/esm/client/coordinators/WaAbPropsCoordinator.js +2 -3
- package/dist/esm/client/coordinators/WaAppStateMutationCoordinator.js +665 -145
- package/dist/esm/client/coordinators/WaBotCoordinator.js +342 -0
- package/dist/esm/client/coordinators/WaBroadcastListCoordinator.js +17 -0
- package/dist/esm/client/coordinators/WaBusinessCoordinator.js +79 -169
- package/dist/esm/client/coordinators/WaEmailCoordinator.js +1 -0
- package/dist/esm/client/coordinators/WaGroupCoordinator.js +532 -55
- package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +98 -13
- package/dist/esm/client/coordinators/WaLowLevelCoordinator.js +38 -0
- package/dist/esm/client/coordinators/WaMessageCoordinator.js +361 -0
- package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +686 -208
- package/dist/esm/client/coordinators/WaNewsletterCoordinator.js +13 -0
- package/dist/esm/client/coordinators/WaPassiveTasksCoordinator.js +18 -5
- package/dist/esm/client/coordinators/WaPresenceCoordinator.js +18 -0
- package/dist/esm/client/coordinators/WaPrivacyCoordinator.js +7 -5
- package/dist/esm/client/coordinators/WaProfileCoordinator.js +223 -52
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +258 -127
- package/dist/esm/client/coordinators/WaStatusCoordinator.js +46 -0
- package/dist/esm/client/coordinators/WaStreamControlCoordinator.js +6 -6
- package/dist/esm/client/coordinators/WaTrustedContactTokenCoordinator.js +7 -6
- package/dist/esm/client/events/appstate-mutation.js +130 -0
- package/dist/esm/client/events/business.js +370 -0
- package/dist/esm/client/events/call.js +55 -0
- package/dist/esm/client/events/chatstate.js +20 -0
- package/dist/esm/client/events/devices.js +15 -16
- package/dist/esm/client/{dirty.js → events/dirty.js} +33 -19
- package/dist/esm/client/events/group.js +14 -25
- package/dist/esm/client/events/identity.js +2 -1
- package/dist/esm/client/events/incoming.js +487 -0
- package/dist/esm/client/events/mex-notification.js +178 -0
- package/dist/esm/client/events/picture.js +30 -0
- package/dist/esm/client/events/presence.js +41 -0
- package/dist/esm/client/events/receipt.js +23 -0
- package/dist/esm/client/media.js +156 -6
- package/dist/esm/client/messaging/fanout.js +10 -11
- package/dist/esm/client/messaging/{participants.js → group-metadata.js} +72 -34
- package/dist/esm/client/messaging/ignore-key.js +126 -0
- package/dist/esm/client/messaging/key-protocol.js +3 -17
- package/dist/esm/client/messaging/link-preview.js +156 -0
- package/dist/esm/client/messaging/messages.js +667 -0
- package/dist/esm/client/newsletter/admin.js +162 -0
- package/dist/esm/client/newsletter/content.js +249 -0
- package/dist/esm/client/newsletter/discovery.js +112 -0
- package/dist/esm/client/newsletter/messaging.js +194 -0
- package/dist/esm/client/newsletter/mex.js +37 -0
- package/dist/esm/client/newsletter/parse.js +200 -0
- package/dist/esm/client/persistence/WriteBehindPersistence.js +31 -4
- package/dist/esm/client/{history-sync.js → persistence/history-sync.js} +124 -18
- package/dist/esm/client/persistence/mailbox.js +101 -0
- package/dist/esm/client/tokens/cs-token.js +12 -18
- package/dist/esm/crypto/core/hkdf.js +14 -14
- package/dist/esm/crypto/core/index.js +2 -2
- package/dist/esm/crypto/core/keys.js +1 -7
- package/dist/esm/crypto/core/nonce.js +11 -11
- package/dist/esm/crypto/core/primitives.js +121 -88
- package/dist/esm/crypto/core/random.js +6 -0
- package/dist/esm/crypto/core/xeddsa.js +11 -9
- package/dist/esm/crypto/curves/Ed25519.js +35 -24
- package/dist/esm/crypto/curves/X25519.js +72 -36
- package/dist/esm/crypto/curves/constants.js +1 -0
- package/dist/esm/crypto/math/constants.js +1 -2
- package/dist/esm/crypto/math/mod.js +0 -32
- package/dist/esm/index.js +7 -2
- package/dist/esm/infra/log/ConsoleLogger.js +30 -6
- package/dist/esm/infra/log/PinoLogger.js +64 -0
- package/dist/esm/infra/log/types.js +4 -2
- package/dist/esm/infra/perf/BackgroundQueue.js +55 -13
- package/dist/esm/media/constants.js +33 -2
- package/dist/esm/media/crypto/WaMediaCrypto.js +374 -0
- package/dist/esm/media/index.js +4 -3
- package/dist/esm/media/sticker/sticker-pack.js +133 -0
- package/dist/esm/media/{WaMediaTransferClient.js → transfer/WaMediaTransferClient.js} +37 -6
- package/dist/esm/media/{conn.js → transfer/conn.js} +10 -5
- package/dist/esm/message/WaMessageClient.js +46 -15
- package/dist/esm/message/addons/link-preview/builder.js +36 -0
- package/dist/esm/message/addons/link-preview/detect.js +55 -0
- package/dist/esm/message/addons/link-preview/fetcher.js +391 -0
- package/dist/esm/message/addons/link-preview/types.js +1 -0
- package/dist/esm/message/context-info.js +123 -0
- package/dist/esm/message/{addon-crypto.js → crypto/addon-crypto.js} +68 -10
- package/dist/esm/message/{icdc.js → crypto/icdc.js} +5 -7
- package/dist/esm/message/crypto/phash.js +133 -0
- package/dist/esm/message/{reporting-token.js → crypto/reporting-token.js} +6 -6
- package/dist/esm/message/{use-case-secret.js → crypto/use-case-secret.js} +20 -3
- package/dist/esm/message/{content.js → encode/content.js} +176 -7
- package/dist/esm/message/encode/media-payload.js +42 -0
- package/dist/esm/message/{padding.js → encode/padding.js} +9 -3
- package/dist/esm/message/index.js +2 -2
- package/dist/esm/message/kinds/bot.js +111 -0
- package/dist/esm/message/kinds/newsletter.js +244 -0
- package/dist/esm/message/kinds/sticker-pack.js +29 -0
- package/dist/esm/message/{ack.js → primitives/ack.js} +8 -1
- package/dist/esm/message/{incoming.js → primitives/incoming.js} +215 -31
- package/dist/esm/message/primitives/peer-data-operation.js +93 -0
- package/dist/esm/mex.js +1 -0
- package/dist/esm/protocol/abprops.js +10 -0
- package/dist/esm/protocol/appstate.js +6 -30
- package/dist/esm/protocol/auth.js +3 -2
- package/dist/esm/protocol/bot.js +77 -0
- package/dist/esm/protocol/browser.js +8 -0
- package/dist/esm/protocol/business.js +19 -0
- package/dist/esm/protocol/call.js +48 -0
- package/dist/esm/protocol/constants.js +8 -2
- package/dist/esm/protocol/defaults.js +3 -0
- package/dist/esm/protocol/index.js +1 -1
- package/dist/esm/protocol/jid.js +102 -5
- package/dist/esm/protocol/media.js +25 -12
- package/dist/esm/protocol/message.js +4 -1
- package/dist/esm/protocol/newsletter.js +61 -0
- package/dist/esm/protocol/nodes.js +22 -2
- package/dist/esm/protocol/notification.js +18 -2
- package/dist/esm/protocol/presence.js +13 -0
- package/dist/esm/protocol/status.js +6 -0
- package/dist/esm/retry/codec.js +5 -0
- package/dist/esm/retry/parse.js +20 -38
- package/dist/esm/retry/reason.js +5 -0
- package/dist/esm/retry/replay.js +131 -37
- package/dist/esm/retry/tracker.js +4 -8
- package/dist/esm/signal/api/SignalDeviceSyncApi.js +66 -19
- package/dist/esm/signal/api/SignalDigestSyncApi.js +7 -2
- package/dist/esm/signal/api/SignalIdentitySyncApi.js +9 -0
- package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +24 -63
- package/dist/esm/signal/api/SignalRotateKeyApi.js +10 -0
- package/dist/esm/signal/api/SignalSessionSyncApi.js +23 -51
- package/dist/esm/signal/api/codec.js +52 -1
- package/dist/esm/signal/api/prekeys.js +4 -0
- package/dist/esm/signal/{crypto → attestation}/WaAdvSignature.js +5 -6
- package/dist/esm/signal/constants.js +3 -0
- package/dist/esm/signal/encoding.js +6 -289
- package/dist/esm/signal/group/SenderKeyChain.js +18 -33
- package/dist/esm/signal/group/SenderKeyManager.js +25 -8
- package/dist/esm/signal/group/encoding.js +96 -0
- package/dist/esm/signal/index.js +4 -1
- package/dist/esm/signal/registration/encoding.js +34 -0
- package/dist/esm/signal/registration/keygen.js +10 -0
- package/dist/esm/signal/registration/utils.js +6 -0
- package/dist/esm/signal/session/SignalProtocol.js +113 -11
- package/dist/esm/signal/session/SignalRatchet.js +29 -58
- package/dist/esm/signal/session/SignalSession.js +7 -14
- package/dist/esm/signal/session/encoding.js +173 -0
- package/dist/esm/signal/session/resolver.js +139 -30
- package/dist/esm/store/cache/identity.cache.js +75 -0
- package/dist/esm/store/cache/privacy-token.cache.js +57 -0
- package/dist/esm/store/cache/sender-key.cache.js +101 -0
- package/dist/esm/store/cache/session.cache.js +92 -0
- package/dist/esm/store/contracts/group-metadata.store.js +1 -0
- package/dist/esm/store/createStore.js +91 -37
- package/dist/esm/store/index.js +15 -14
- package/dist/esm/store/locks/contact.lock.js +1 -0
- package/dist/esm/store/locks/device-list.lock.js +1 -0
- package/dist/esm/store/locks/group-metadata.lock.js +20 -0
- package/dist/esm/store/{providers/memory → memory}/appstate.store.js +5 -5
- package/dist/esm/store/memory/auth.store.js +24 -0
- package/dist/esm/store/memory/contact.store.js +79 -0
- package/dist/esm/store/memory/device-list.store.js +103 -0
- package/dist/esm/store/{providers/memory/participants.store.js → memory/group-metadata.store.js} +22 -13
- package/dist/esm/store/{providers/memory → memory}/identity.store.js +3 -3
- package/dist/esm/store/{providers/memory → memory}/message-secret.store.js +17 -8
- package/dist/esm/store/{providers/memory → memory}/message.store.js +2 -2
- package/dist/esm/store/{providers/memory → memory}/pre-key.store.js +2 -2
- package/dist/esm/store/{providers/memory → memory}/privacy-token.store.js +1 -1
- package/dist/esm/store/{providers/memory → memory}/retry.store.js +28 -7
- package/dist/esm/store/{providers/memory → memory}/sender-key.store.js +3 -3
- package/dist/esm/store/{providers/memory → memory}/session.store.js +3 -3
- package/dist/esm/store/{providers/memory → memory}/thread.store.js +2 -2
- package/dist/esm/store/noop.store.js +6 -4
- package/dist/esm/transport/WaComms.js +14 -5
- package/dist/esm/transport/WaWebSocket.js +32 -8
- package/dist/esm/transport/binary/constants.js +10 -4
- package/dist/esm/transport/binary/decoder.js +21 -15
- package/dist/esm/transport/binary/encoder.js +96 -21
- package/dist/esm/transport/binary/tokens.js +12 -12
- package/dist/esm/transport/index.js +1 -0
- package/dist/esm/transport/keepalive/WaKeepAlive.js +18 -4
- package/dist/esm/transport/node/WaMobileTcpSocket.js +6 -0
- package/dist/esm/transport/node/WaNodeOrchestrator.js +9 -5
- package/dist/esm/transport/node/WaNodeTransport.js +13 -0
- package/dist/esm/transport/node/builders/abprops.js +2 -2
- package/dist/esm/transport/node/builders/account-sync.js +7 -15
- package/dist/esm/transport/node/builders/bot.js +38 -0
- package/dist/esm/transport/node/builders/business.js +30 -30
- package/dist/esm/transport/node/builders/chatstate.js +28 -0
- package/dist/esm/transport/node/builders/community.js +53 -0
- package/dist/esm/transport/node/builders/device.js +2 -2
- package/dist/esm/transport/node/builders/email.js +6 -5
- package/dist/esm/transport/node/builders/global.js +1 -1
- package/dist/esm/transport/node/builders/group.js +114 -4
- package/dist/esm/transport/node/builders/media.js +2 -2
- package/dist/esm/transport/node/builders/message.js +83 -49
- package/dist/esm/transport/node/builders/newsletter.js +176 -0
- package/dist/esm/transport/node/builders/passive.js +7 -0
- package/dist/esm/transport/node/builders/prekeys.js +4 -4
- package/dist/esm/transport/node/builders/presence.js +27 -1
- package/dist/esm/transport/node/builders/privacy-token.js +2 -2
- package/dist/esm/transport/node/builders/privacy.js +6 -6
- package/dist/esm/transport/node/builders/profile.js +28 -8
- package/dist/esm/transport/node/builders/tos.js +58 -0
- package/dist/esm/transport/node/builders/usync.js +51 -2
- package/dist/esm/transport/node/helpers.js +3 -1
- package/dist/esm/transport/node/mex/argo-decoder.js +2 -2
- package/dist/esm/transport/node/mex/client.js +22 -0
- package/dist/esm/transport/node/query.js +17 -0
- package/dist/esm/transport/node/usync.js +12 -0
- package/dist/esm/transport/noise/WaClientPayload.js +8 -8
- package/dist/esm/transport/noise/WaMobileClientPayload.js +5 -0
- package/dist/esm/transport/noise/WaNoiseCert.js +5 -0
- package/dist/esm/transport/noise/WaNoiseHandshake.js +27 -25
- package/dist/esm/transport/noise/WaNoiseSession.js +39 -59
- package/dist/esm/transport/noise/WaNoiseSocket.js +19 -13
- package/dist/esm/transport/noise/constants.js +0 -1
- package/dist/esm/transport/proxy.js +5 -0
- package/dist/esm/transport/stream/parse.js +3 -7
- package/dist/esm/transport/wa-web-version-fetcher.js +91 -0
- package/dist/esm/util/async.js +4 -0
- package/dist/esm/util/bytes.js +37 -2
- package/dist/esm/util/clock.js +15 -0
- package/dist/esm/util/coercion.js +45 -3
- package/dist/esm/util/collections.js +11 -0
- package/dist/esm/util/index.js +2 -2
- package/dist/esm/util/primitives.js +19 -0
- package/dist/esm/util/runtime.js +5 -0
- package/dist/esm/version-spec.js +1 -0
- package/dist/index.js +31 -1
- package/dist/infra/log/ConsoleLogger.js +30 -6
- package/dist/infra/log/PinoLogger.js +64 -0
- package/dist/infra/log/types.js +4 -2
- package/dist/infra/perf/BackgroundQueue.js +55 -13
- package/dist/media/constants.js +34 -3
- package/dist/media/crypto/WaMediaCrypto.js +378 -0
- package/dist/media/index.js +9 -4
- package/dist/media/sticker/sticker-pack.js +136 -0
- package/dist/media/{WaMediaTransferClient.js → transfer/WaMediaTransferClient.js} +37 -6
- package/dist/media/{conn.js → transfer/conn.js} +10 -5
- package/dist/message/WaMessageClient.js +46 -15
- package/dist/message/addons/link-preview/builder.js +39 -0
- package/dist/message/addons/link-preview/detect.js +58 -0
- package/dist/message/addons/link-preview/fetcher.js +394 -0
- package/dist/message/addons/link-preview/types.js +2 -0
- package/dist/message/context-info.js +129 -0
- package/dist/message/{addon-crypto.js → crypto/addon-crypto.js} +68 -10
- package/dist/message/{icdc.js → crypto/icdc.js} +5 -7
- package/dist/message/crypto/phash.js +136 -0
- package/dist/message/{reporting-token.js → crypto/reporting-token.js} +6 -6
- package/dist/message/{use-case-secret.js → crypto/use-case-secret.js} +20 -3
- package/dist/message/{content.js → encode/content.js} +192 -7
- package/dist/message/encode/media-payload.js +45 -0
- package/dist/message/{padding.js → encode/padding.js} +9 -3
- package/dist/message/index.js +2 -2
- package/dist/message/kinds/bot.js +120 -0
- package/dist/message/kinds/newsletter.js +248 -0
- package/dist/message/kinds/sticker-pack.js +34 -0
- package/dist/message/{ack.js → primitives/ack.js} +8 -1
- package/dist/message/{incoming.js → primitives/incoming.js} +216 -31
- package/dist/message/primitives/peer-data-operation.js +96 -0
- package/dist/mex.js +6 -0
- package/dist/proto.js +1 -1
- package/dist/protocol/abprops.js +10 -0
- package/dist/protocol/appstate.js +7 -31
- package/dist/protocol/auth.js +3 -2
- package/dist/protocol/bot.js +81 -0
- package/dist/protocol/browser.js +8 -0
- package/dist/protocol/business.js +22 -0
- package/dist/protocol/call.js +51 -0
- package/dist/protocol/constants.js +39 -3
- package/dist/protocol/defaults.js +3 -0
- package/dist/protocol/index.js +12 -3
- package/dist/protocol/jid.js +107 -5
- package/dist/protocol/media.js +25 -12
- package/dist/protocol/message.js +4 -1
- package/dist/protocol/newsletter.js +64 -0
- package/dist/protocol/nodes.js +22 -2
- package/dist/protocol/notification.js +19 -3
- package/dist/protocol/presence.js +16 -0
- package/dist/protocol/status.js +9 -0
- package/dist/retry/codec.js +5 -0
- package/dist/retry/parse.js +16 -34
- package/dist/retry/reason.js +5 -0
- package/dist/retry/replay.js +129 -35
- package/dist/retry/tracker.js +3 -7
- package/dist/signal/api/SignalDeviceSyncApi.js +64 -17
- package/dist/signal/api/SignalDigestSyncApi.js +6 -1
- package/dist/signal/api/SignalIdentitySyncApi.js +9 -0
- package/dist/signal/api/SignalMissingPreKeysSyncApi.js +21 -60
- package/dist/signal/api/SignalRotateKeyApi.js +10 -0
- package/dist/signal/api/SignalSessionSyncApi.js +20 -48
- package/dist/signal/api/codec.js +52 -0
- package/dist/signal/api/prekeys.js +4 -0
- package/dist/signal/{crypto → attestation}/WaAdvSignature.js +5 -7
- package/dist/signal/constants.js +4 -1
- package/dist/signal/encoding.js +5 -303
- package/dist/signal/group/SenderKeyChain.js +17 -32
- package/dist/signal/group/SenderKeyManager.js +24 -7
- package/dist/signal/group/encoding.js +101 -0
- package/dist/signal/index.js +13 -10
- package/dist/signal/registration/encoding.js +39 -0
- package/dist/signal/registration/keygen.js +10 -0
- package/dist/signal/registration/utils.js +6 -0
- package/dist/signal/session/SignalProtocol.js +112 -10
- package/dist/signal/session/SignalRatchet.js +24 -54
- package/dist/signal/session/SignalSession.js +6 -14
- package/dist/signal/session/encoding.js +183 -0
- package/dist/signal/session/resolver.js +139 -30
- package/dist/store/cache/identity.cache.js +78 -0
- package/dist/store/cache/privacy-token.cache.js +60 -0
- package/dist/store/cache/sender-key.cache.js +104 -0
- package/dist/store/cache/session.cache.js +95 -0
- package/dist/store/contracts/group-metadata.store.js +2 -0
- package/dist/store/createStore.js +90 -36
- package/dist/store/index.js +18 -16
- package/dist/store/locks/contact.lock.js +1 -0
- package/dist/store/locks/device-list.lock.js +1 -0
- package/dist/store/locks/group-metadata.lock.js +23 -0
- package/dist/store/{providers/memory → memory}/appstate.store.js +5 -5
- package/dist/store/memory/auth.store.js +28 -0
- package/dist/store/memory/contact.store.js +83 -0
- package/dist/store/memory/device-list.store.js +107 -0
- package/dist/store/{providers/memory/participants.store.js → memory/group-metadata.store.js} +24 -15
- package/dist/store/{providers/memory → memory}/identity.store.js +3 -3
- package/dist/store/{providers/memory → memory}/message-secret.store.js +17 -8
- package/dist/store/{providers/memory → memory}/message.store.js +2 -2
- package/dist/store/{providers/memory → memory}/pre-key.store.js +2 -2
- package/dist/store/{providers/memory → memory}/privacy-token.store.js +1 -1
- package/dist/store/{providers/memory → memory}/retry.store.js +28 -7
- package/dist/store/{providers/memory → memory}/sender-key.store.js +3 -3
- package/dist/store/{providers/memory → memory}/session.store.js +3 -3
- package/dist/store/{providers/memory → memory}/thread.store.js +2 -2
- package/dist/store/noop.store.js +7 -5
- package/dist/transport/WaComms.js +14 -5
- package/dist/transport/WaWebSocket.js +32 -8
- package/dist/transport/binary/constants.js +11 -5
- package/dist/transport/binary/decoder.js +24 -18
- package/dist/transport/binary/encoder.js +109 -34
- package/dist/transport/binary/tokens.js +12 -12
- package/dist/transport/index.js +3 -1
- package/dist/transport/keepalive/WaKeepAlive.js +18 -4
- package/dist/transport/node/WaMobileTcpSocket.js +6 -0
- package/dist/transport/node/WaNodeOrchestrator.js +9 -5
- package/dist/transport/node/WaNodeTransport.js +13 -0
- package/dist/transport/node/builders/abprops.js +1 -1
- package/dist/transport/node/builders/account-sync.js +7 -16
- package/dist/transport/node/builders/bot.js +43 -0
- package/dist/transport/node/builders/business.js +31 -31
- package/dist/transport/node/builders/chatstate.js +31 -0
- package/dist/transport/node/builders/community.js +59 -0
- package/dist/transport/node/builders/device.js +1 -1
- package/dist/transport/node/builders/email.js +6 -5
- package/dist/transport/node/builders/global.js +1 -1
- package/dist/transport/node/builders/group.js +121 -3
- package/dist/transport/node/builders/media.js +1 -1
- package/dist/transport/node/builders/message.js +84 -49
- package/dist/transport/node/builders/newsletter.js +183 -0
- package/dist/transport/node/builders/passive.js +10 -0
- package/dist/transport/node/builders/prekeys.js +3 -3
- package/dist/transport/node/builders/presence.js +28 -1
- package/dist/transport/node/builders/privacy-token.js +1 -1
- package/dist/transport/node/builders/privacy.js +5 -5
- package/dist/transport/node/builders/profile.js +30 -7
- package/dist/transport/node/builders/tos.js +63 -0
- package/dist/transport/node/builders/usync.js +52 -1
- package/dist/transport/node/helpers.js +2 -1
- package/dist/transport/node/mex/argo-decoder.js +2 -2
- package/dist/transport/node/mex/client.js +23 -0
- package/dist/transport/node/query.js +17 -0
- package/dist/transport/node/usync.js +13 -0
- package/dist/transport/noise/WaClientPayload.js +8 -8
- package/dist/transport/noise/WaMobileClientPayload.js +5 -0
- package/dist/transport/noise/WaNoiseCert.js +5 -0
- package/dist/transport/noise/WaNoiseHandshake.js +25 -23
- package/dist/transport/noise/WaNoiseSession.js +39 -59
- package/dist/transport/noise/WaNoiseSocket.js +18 -12
- package/dist/transport/noise/constants.js +1 -2
- package/dist/transport/proxy.js +5 -0
- package/dist/transport/stream/parse.js +3 -7
- package/dist/transport/wa-web-version-fetcher.js +94 -0
- package/dist/types/appstate/constants.d.ts +1 -1
- package/dist/types/appstate/{WaAppStateCrypto.d.ts → crypto/WaAppStateCrypto.d.ts} +26 -9
- package/dist/types/appstate/index.d.ts +5 -5
- package/dist/types/appstate/{encoding.d.ts → parsers/encoding.d.ts} +8 -1
- package/dist/types/appstate/{response-parser.d.ts → parsers/response-parser.d.ts} +13 -3
- package/dist/types/appstate/sync/WaAppStateSyncClient.d.ts +105 -0
- package/dist/types/appstate/utils.d.ts +17 -1
- package/dist/types/appstate-spec.d.ts +24 -0
- package/dist/types/auth/WaAuthClient.d.ts +89 -3
- package/dist/types/auth/credentials-flow.d.ts +4 -3
- package/dist/types/auth/pairing/pairing-code-crypto.d.ts +0 -1
- package/dist/types/auth/types.d.ts +48 -1
- package/dist/types/client/WaClient.d.ts +178 -71
- package/dist/types/client/WaClientFactory.d.ts +30 -5
- package/dist/types/client/connection/WaConnectionManager.d.ts +4 -2
- package/dist/types/client/connection/WaReceiptQueue.d.ts +1 -1
- package/dist/types/client/coordinators/WaAppStateMutationCoordinator.d.ts +215 -5
- package/dist/types/client/coordinators/WaBotCoordinator.d.ts +117 -0
- package/dist/types/client/coordinators/WaBroadcastListCoordinator.d.ts +39 -0
- package/dist/types/client/coordinators/WaBusinessCoordinator.d.ts +44 -43
- package/dist/types/client/coordinators/WaEmailCoordinator.d.ts +16 -0
- package/dist/types/client/coordinators/WaGroupCoordinator.d.ts +311 -9
- package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +11 -4
- package/dist/types/client/coordinators/WaLowLevelCoordinator.d.ts +47 -0
- package/dist/types/client/coordinators/WaMessageCoordinator.d.ts +232 -0
- package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +54 -31
- package/dist/types/client/coordinators/WaNewsletterCoordinator.d.ts +13 -0
- package/dist/types/client/coordinators/WaPassiveTasksCoordinator.d.ts +4 -3
- package/dist/types/client/coordinators/WaPresenceCoordinator.d.ts +27 -0
- package/dist/types/client/coordinators/WaPrivacyCoordinator.d.ts +27 -0
- package/dist/types/client/coordinators/WaProfileCoordinator.d.ts +113 -0
- package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +19 -17
- package/dist/types/client/coordinators/WaStatusCoordinator.d.ts +42 -0
- package/dist/types/client/coordinators/WaTrustedContactTokenCoordinator.d.ts +5 -1
- package/dist/types/client/events/abprops.d.ts +2 -1
- package/dist/types/client/events/appstate-mutation.d.ts +3 -0
- package/dist/types/client/events/business.d.ts +10 -0
- package/dist/types/client/events/call.d.ts +31 -0
- package/dist/types/client/events/chatstate.d.ts +9 -0
- package/dist/types/client/events/devices.d.ts +5 -4
- package/dist/types/client/{dirty.d.ts → events/dirty.d.ts} +4 -3
- package/dist/types/client/events/group.d.ts +2 -1
- package/dist/types/client/events/identity.d.ts +2 -1
- package/dist/types/client/{incoming.d.ts → events/incoming.d.ts} +27 -4
- package/dist/types/client/events/mex-notification.d.ts +6 -0
- package/dist/types/client/events/picture.d.ts +8 -0
- package/dist/types/client/events/presence.d.ts +28 -0
- package/dist/types/client/events/receipt.d.ts +14 -0
- package/dist/types/client/events/registration.d.ts +4 -3
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/media.d.ts +35 -1
- package/dist/types/client/messaging/fanout.d.ts +2 -2
- package/dist/types/client/messaging/group-metadata.d.ts +19 -0
- package/dist/types/client/messaging/ignore-key.d.ts +11 -0
- package/dist/types/client/messaging/key-protocol.d.ts +9 -7
- package/dist/types/client/messaging/link-preview.d.ts +19 -0
- package/dist/types/client/messaging/messages.d.ts +28 -0
- package/dist/types/client/newsletter/admin.d.ts +71 -0
- package/dist/types/client/newsletter/content.d.ts +42 -0
- package/dist/types/client/newsletter/discovery.d.ts +33 -0
- package/dist/types/client/newsletter/messaging.d.ts +66 -0
- package/dist/types/client/newsletter/mex.d.ts +14 -0
- package/dist/types/client/newsletter/parse.d.ts +19 -0
- package/dist/types/client/newsletter/types.d.ts +190 -0
- package/dist/types/client/persistence/WriteBehindPersistence.d.ts +12 -1
- package/dist/types/client/persistence/history-sync.d.ts +29 -0
- package/dist/types/client/{mailbox.d.ts → persistence/mailbox.d.ts} +4 -4
- package/dist/types/client/tokens/cs-token.d.ts +1 -3
- package/dist/types/client/types.d.ts +843 -71
- package/dist/types/crypto/core/hkdf.d.ts +10 -2
- package/dist/types/crypto/core/index.d.ts +2 -2
- package/dist/types/crypto/core/keys.d.ts +0 -4
- package/dist/types/crypto/core/nonce.d.ts +4 -5
- package/dist/types/crypto/core/primitives.d.ts +31 -20
- package/dist/types/crypto/core/random.d.ts +6 -0
- package/dist/types/crypto/core/xeddsa.d.ts +9 -0
- package/dist/types/crypto/curves/Ed25519.d.ts +7 -1
- package/dist/types/crypto/curves/X25519.d.ts +20 -1
- package/dist/types/crypto/curves/constants.d.ts +4 -3
- package/dist/types/crypto/curves/types.d.ts +0 -5
- package/dist/types/crypto/math/constants.d.ts +0 -1
- package/dist/types/crypto/math/mod.d.ts +0 -1
- package/dist/types/index.d.ts +32 -6
- package/dist/types/infra/log/ConsoleLogger.d.ts +18 -1
- package/dist/types/infra/log/PinoLogger.d.ts +55 -1
- package/dist/types/infra/log/types.d.ts +6 -0
- package/dist/types/infra/perf/BackgroundQueue.d.ts +19 -0
- package/dist/types/media/constants.d.ts +7 -2
- package/dist/types/media/crypto/WaMediaCrypto.d.ts +59 -0
- package/dist/types/media/index.d.ts +7 -5
- package/dist/types/media/processor.d.ts +27 -5
- package/dist/types/media/sticker/sticker-pack.d.ts +6 -0
- package/dist/types/media/{WaMediaTransferClient.d.ts → transfer/WaMediaTransferClient.d.ts} +30 -1
- package/dist/types/media/transfer/conn.d.ts +7 -0
- package/dist/types/media/types.d.ts +1 -2
- package/dist/types/message/WaMessageClient.d.ts +14 -0
- package/dist/types/message/addons/link-preview/builder.d.ts +13 -0
- package/dist/types/message/addons/link-preview/detect.d.ts +5 -0
- package/dist/types/message/addons/link-preview/fetcher.d.ts +13 -0
- package/dist/types/message/addons/link-preview/types.d.ts +51 -0
- package/dist/types/message/context-info.d.ts +66 -0
- package/dist/types/message/{addon-crypto.d.ts → crypto/addon-crypto.d.ts} +27 -5
- package/dist/types/message/{icdc.d.ts → crypto/icdc.d.ts} +4 -4
- package/dist/types/message/{phash.d.ts → crypto/phash.d.ts} +1 -1
- package/dist/types/message/{reporting-token.d.ts → crypto/reporting-token.d.ts} +2 -2
- package/dist/types/message/{use-case-secret.d.ts → crypto/use-case-secret.d.ts} +17 -1
- package/dist/types/message/encode/content.d.ts +43 -0
- package/dist/types/message/{device-sent.d.ts → encode/device-sent.d.ts} +1 -1
- package/dist/types/message/encode/media-payload.d.ts +12 -0
- package/dist/types/message/index.d.ts +2 -2
- package/dist/types/message/kinds/bot.d.ts +31 -0
- package/dist/types/message/kinds/newsletter.d.ts +12 -0
- package/dist/types/message/kinds/sticker-pack.d.ts +6 -0
- package/dist/types/message/{ack.d.ts → primitives/ack.d.ts} +1 -1
- package/dist/types/message/primitives/incoming.d.ts +21 -0
- package/dist/types/message/primitives/peer-data-operation.d.ts +23 -0
- package/dist/types/message/types.d.ts +208 -10
- package/dist/types/mex.d.ts +2 -0
- package/dist/types/proto.d.ts +2 -2
- package/dist/types/protocol/abprops.d.ts +9 -0
- package/dist/types/protocol/appstate.d.ts +4 -49
- package/dist/types/protocol/auth.d.ts +2 -2
- package/dist/types/protocol/bot.d.ts +45 -0
- package/dist/types/protocol/browser.d.ts +8 -0
- package/dist/types/protocol/business.d.ts +21 -0
- package/dist/types/protocol/call.d.ts +44 -0
- package/dist/types/protocol/constants.d.ts +16 -3
- package/dist/types/protocol/defaults.d.ts +3 -0
- package/dist/types/protocol/group.d.ts +1 -1
- package/dist/types/protocol/index.d.ts +2 -1
- package/dist/types/protocol/jid.d.ts +78 -0
- package/dist/types/protocol/media.d.ts +21 -13
- package/dist/types/protocol/message.d.ts +4 -0
- package/dist/types/protocol/newsletter.d.ts +65 -0
- package/dist/types/protocol/nodes.d.ts +20 -0
- package/dist/types/protocol/notification.d.ts +16 -0
- package/dist/types/protocol/presence.d.ts +16 -0
- package/dist/types/protocol/status.d.ts +7 -0
- package/dist/types/retry/codec.d.ts +5 -0
- package/dist/types/retry/index.d.ts +1 -1
- package/dist/types/retry/parse.d.ts +9 -0
- package/dist/types/retry/reason.d.ts +5 -0
- package/dist/types/retry/replay.d.ts +19 -5
- package/dist/types/retry/tracker.d.ts +10 -3
- package/dist/types/retry/types.d.ts +3 -8
- package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +20 -0
- package/dist/types/signal/api/SignalDigestSyncApi.d.ts +10 -0
- package/dist/types/signal/api/SignalIdentitySyncApi.d.ts +9 -0
- package/dist/types/signal/api/SignalMissingPreKeysSyncApi.d.ts +8 -0
- package/dist/types/signal/api/SignalRotateKeyApi.d.ts +10 -0
- package/dist/types/signal/api/SignalSessionSyncApi.d.ts +13 -0
- package/dist/types/signal/api/codec.d.ts +20 -0
- package/dist/types/signal/api/constants.d.ts +1 -1
- package/dist/types/signal/api/prekeys.d.ts +4 -0
- package/dist/types/signal/{crypto → attestation}/WaAdvSignature.d.ts +2 -2
- package/dist/types/signal/attestation/constants.d.ts +4 -0
- package/dist/types/signal/constants.d.ts +7 -4
- package/dist/types/signal/encoding.d.ts +6 -68
- package/dist/types/signal/group/SenderKeyChain.d.ts +1 -1
- package/dist/types/signal/group/SenderKeyManager.d.ts +17 -0
- package/dist/types/signal/group/encoding.d.ts +25 -0
- package/dist/types/signal/index.d.ts +4 -1
- package/dist/types/signal/registration/encoding.d.ts +30 -0
- package/dist/types/signal/registration/keygen.d.ts +10 -0
- package/dist/types/signal/registration/utils.d.ts +5 -0
- package/dist/types/signal/session/SignalProtocol.d.ts +55 -0
- package/dist/types/signal/session/SignalRatchet.d.ts +2 -3
- package/dist/types/signal/session/SignalSession.d.ts +0 -1
- package/dist/types/signal/session/encoding.d.ts +28 -0
- package/dist/types/signal/session/resolver.d.ts +14 -0
- package/dist/types/store/cache/identity.cache.d.ts +15 -0
- package/dist/types/store/cache/privacy-token.cache.d.ts +15 -0
- package/dist/types/store/cache/sender-key.cache.d.ts +18 -0
- package/dist/types/store/cache/session.cache.d.ts +23 -0
- package/dist/types/store/contracts/contact.store.d.ts +14 -0
- package/dist/types/store/contracts/device-list.store.d.ts +13 -0
- package/dist/types/store/contracts/group-metadata.store.d.ts +14 -0
- package/dist/types/store/contracts/message.store.d.ts +0 -2
- package/dist/types/store/createStore.d.ts +54 -2
- package/dist/types/store/index.d.ts +17 -16
- package/dist/types/store/locks/group-metadata.lock.d.ts +2 -0
- package/dist/types/store/{providers/memory → memory}/appstate.store.d.ts +2 -2
- package/dist/types/store/memory/auth.store.d.ts +18 -0
- package/dist/types/store/{providers/memory → memory}/contact.store.d.ts +6 -1
- package/dist/types/store/{providers/memory → memory}/device-list.store.d.ts +15 -2
- package/dist/types/store/memory/group-metadata.store.d.ts +27 -0
- package/dist/types/store/{providers/memory → memory}/identity.store.d.ts +2 -2
- package/dist/types/store/{providers/memory → memory}/message-secret.store.d.ts +12 -2
- package/dist/types/store/{providers/memory → memory}/message.store.d.ts +1 -1
- package/dist/types/store/{providers/memory → memory}/pre-key.store.d.ts +2 -2
- package/dist/types/store/{providers/memory → memory}/privacy-token.store.d.ts +1 -1
- package/dist/types/store/{providers/memory → memory}/retry.store.d.ts +16 -3
- package/dist/types/store/{providers/memory → memory}/sender-key.store.d.ts +2 -2
- package/dist/types/store/{providers/memory → memory}/session.store.d.ts +2 -2
- package/dist/types/store/{providers/memory → memory}/signal.store.d.ts +2 -2
- package/dist/types/store/{providers/memory → memory}/thread.store.d.ts +1 -1
- package/dist/types/store/noop.store.d.ts +2 -2
- package/dist/types/store/types.d.ts +250 -6
- package/dist/types/transport/WaComms.d.ts +5 -0
- package/dist/types/transport/WaWebSocket.d.ts +5 -0
- package/dist/types/transport/binary/constants.d.ts +8 -2
- package/dist/types/transport/binary/decoder.d.ts +5 -0
- package/dist/types/transport/binary/encoder.d.ts +5 -0
- package/dist/types/transport/binary/tokens.d.ts +6 -6
- package/dist/types/transport/index.d.ts +3 -1
- package/dist/types/transport/keepalive/WaKeepAlive.d.ts +7 -0
- package/dist/types/transport/node/WaMobileTcpSocket.d.ts +6 -0
- package/dist/types/transport/node/WaNodeOrchestrator.d.ts +5 -0
- package/dist/types/transport/node/WaNodeTransport.d.ts +13 -0
- package/dist/types/transport/node/builders/account-sync.d.ts +1 -2
- package/dist/types/transport/node/builders/bot.d.ts +4 -0
- package/dist/types/transport/node/builders/business.d.ts +21 -4
- package/dist/types/transport/node/builders/chatstate.d.ts +11 -0
- package/dist/types/transport/node/builders/community.d.ts +17 -0
- package/dist/types/transport/node/builders/group.d.ts +44 -2
- package/dist/types/transport/node/builders/message.d.ts +11 -6
- package/dist/types/transport/node/builders/newsletter.d.ts +73 -0
- package/dist/types/transport/node/builders/passive.d.ts +3 -0
- package/dist/types/transport/node/builders/presence.d.ts +8 -1
- package/dist/types/transport/node/builders/profile.d.ts +3 -0
- package/dist/types/transport/node/builders/tos.d.ts +12 -0
- package/dist/types/transport/node/builders/usync.d.ts +16 -0
- package/dist/types/transport/node/helpers.d.ts +1 -2
- package/dist/types/transport/node/mex/client.d.ts +12 -1
- package/dist/types/transport/node/query.d.ts +19 -1
- package/dist/types/transport/node/usync.d.ts +3 -0
- package/dist/types/transport/noise/WaMobileClientPayload.d.ts +5 -0
- package/dist/types/transport/noise/WaNoiseCert.d.ts +5 -0
- package/dist/types/transport/noise/WaNoiseHandshake.d.ts +12 -6
- package/dist/types/transport/noise/WaNoiseSession.d.ts +0 -1
- package/dist/types/transport/noise/WaNoiseSocket.d.ts +12 -6
- package/dist/types/transport/noise/constants.d.ts +4 -5
- package/dist/types/transport/proxy.d.ts +5 -0
- package/dist/types/transport/types.d.ts +14 -7
- package/dist/types/transport/wa-web-version-fetcher.d.ts +44 -0
- package/dist/types/util/async.d.ts +4 -0
- package/dist/types/util/bytes.d.ts +36 -1
- package/dist/types/util/clock.d.ts +6 -0
- package/dist/types/util/coercion.d.ts +25 -0
- package/dist/types/util/collections.d.ts +8 -0
- package/dist/types/util/index.d.ts +2 -2
- package/dist/types/util/primitives.d.ts +11 -0
- package/dist/types/util/runtime.d.ts +5 -0
- package/dist/types/version-spec.d.ts +1 -0
- package/dist/util/async.js +4 -0
- package/dist/util/bytes.js +37 -2
- package/dist/util/clock.js +18 -0
- package/dist/util/coercion.js +48 -3
- package/dist/util/collections.js +12 -0
- package/dist/util/index.js +7 -1
- package/dist/util/primitives.js +20 -0
- package/dist/util/runtime.js +5 -0
- package/dist/version-spec.js +5 -0
- package/package.json +32 -8
- package/spec/appstate/index.d.ts +188 -0
- package/spec/appstate/index.js +850 -0
- package/spec/mex/index.d.ts +4172 -0
- package/spec/mex/index.js +261 -0
- package/spec/proto/index.d.ts +16305 -0
- package/spec/proto/index.js +1 -0
- package/spec/version/index.d.ts +4 -0
- package/spec/version/index.js +9 -0
- package/spec/version/version.json +3 -0
- package/dist/client/events/chat.js +0 -227
- package/dist/client/incoming.js +0 -306
- package/dist/client/mailbox.js +0 -66
- package/dist/client/messages.js +0 -305
- package/dist/esm/client/events/chat.js +0 -224
- package/dist/esm/client/incoming.js +0 -296
- package/dist/esm/client/mailbox.js +0 -63
- package/dist/esm/client/messages.js +0 -301
- package/dist/esm/media/WaMediaCrypto.js +0 -499
- package/dist/esm/message/phash.js +0 -47
- package/dist/esm/store/locks/participants.lock.js +0 -20
- package/dist/esm/store/providers/memory/contact.store.js +0 -28
- package/dist/esm/store/providers/memory/device-list.store.js +0 -67
- package/dist/esm/transport/node/mex/persist-ids.js +0 -10
- package/dist/media/WaMediaCrypto.js +0 -503
- package/dist/message/phash.js +0 -50
- package/dist/store/locks/participants.lock.js +0 -23
- package/dist/store/providers/memory/contact.store.js +0 -32
- package/dist/store/providers/memory/device-list.store.js +0 -71
- package/dist/transport/node/mex/persist-ids.js +0 -13
- package/dist/types/appstate/WaAppStateSyncClient.d.ts +0 -70
- package/dist/types/client/events/chat.d.ts +0 -3
- package/dist/types/client/history-sync.d.ts +0 -20
- package/dist/types/client/messages.d.ts +0 -18
- package/dist/types/client/messaging/participants.d.ts +0 -13
- package/dist/types/media/WaMediaCrypto.d.ts +0 -22
- package/dist/types/media/conn.d.ts +0 -3
- package/dist/types/message/content.d.ts +0 -14
- package/dist/types/message/incoming.d.ts +0 -18
- package/dist/types/signal/crypto/constants.d.ts +0 -4
- package/dist/types/store/contracts/participants.store.d.ts +0 -13
- package/dist/types/store/locks/participants.lock.d.ts +0 -2
- package/dist/types/store/providers/memory/participants.store.d.ts +0 -17
- package/dist/types/transport/node/mex/persist-ids.d.ts +0 -14
- package/proto/index.d.ts +0 -10903
- package/proto/index.js +0 -1
- /package/dist/{store/contracts/participants.store.js → client/newsletter/types.js} +0 -0
- /package/dist/esm/{store/contracts/participants.store.js → client/newsletter/types.js} +0 -0
- /package/dist/esm/message/{device-sent.js → encode/device-sent.js} +0 -0
- /package/dist/esm/signal/{crypto → attestation}/constants.js +0 -0
- /package/dist/esm/store/{providers/memory → memory}/signal.store.js +0 -0
- /package/dist/message/{device-sent.js → encode/device-sent.js} +0 -0
- /package/dist/signal/{crypto → attestation}/constants.js +0 -0
- /package/dist/store/{providers/memory → memory}/signal.store.js +0 -0
- /package/dist/types/message/{padding.d.ts → encode/padding.d.ts} +0 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WaAppStateMutationCoordinator = void 0;
|
|
4
|
+
const utils_1 = require("../../appstate/utils");
|
|
5
|
+
const _appstate_spec_1 = require("../../appstate-spec.js");
|
|
6
|
+
const appstate_mutation_1 = require("../events/appstate-mutation");
|
|
7
|
+
const _proto_1 = require("../../proto.js");
|
|
4
8
|
const constants_1 = require("../../protocol/constants");
|
|
5
9
|
const jid_1 = require("../../protocol/jid");
|
|
6
10
|
const coercion_1 = require("../../util/coercion");
|
|
@@ -10,18 +14,364 @@ const WA_APP_STATE_MUTATION_FLUSH_SUCCESS_STATES = new Set([
|
|
|
10
14
|
constants_1.WA_APP_STATE_COLLECTION_STATES.SUCCESS_HAS_MORE
|
|
11
15
|
]);
|
|
12
16
|
const WA_APP_STATE_ARCHIVE_RANGE_DEFAULT_LIMIT = 256;
|
|
17
|
+
function buildMutationIndexFromSchema(schema, indexArgs) {
|
|
18
|
+
const parts = new Array(schema.indexParts.length);
|
|
19
|
+
const args = indexArgs;
|
|
20
|
+
for (let i = 0; i < schema.indexParts.length; i += 1) {
|
|
21
|
+
const part = schema.indexParts[i];
|
|
22
|
+
if (part.type === 'literal') {
|
|
23
|
+
parts[i] = part.value;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const arg = args[part.name];
|
|
27
|
+
if (part.type === 'boolString') {
|
|
28
|
+
parts[i] = arg ? '1' : '0';
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (part.type === 'jidOrZero') {
|
|
32
|
+
if (arg === null || arg === undefined) {
|
|
33
|
+
const fromMeSlot = schema.indexParts.find((p) => p.type === 'boolString' && p.name === 'fromMe');
|
|
34
|
+
if (fromMeSlot && args['fromMe'] !== true) {
|
|
35
|
+
throw new Error(`app-state index arg "${part.name}" for schema "${schema.name}" requires a JID when fromMe is not true`);
|
|
36
|
+
}
|
|
37
|
+
parts[i] = '0';
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
parts[i] = arg;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (part.type === 'enum') {
|
|
44
|
+
if (typeof arg === 'number') {
|
|
45
|
+
parts[i] = String(arg);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (typeof arg !== 'string') {
|
|
49
|
+
throw new Error(`app-state enum index arg "${part.name}" for schema "${schema.name}" must be a string`);
|
|
50
|
+
}
|
|
51
|
+
const numeric = (0, _appstate_spec_1.encodeEnumValue)(part.protoEnum, arg);
|
|
52
|
+
if (numeric === null) {
|
|
53
|
+
throw new Error(`app-state enum index arg "${part.name}"="${arg}" is not in enum ${part.protoEnum}`);
|
|
54
|
+
}
|
|
55
|
+
parts[i] = String(numeric);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (typeof arg !== 'string') {
|
|
59
|
+
throw new Error(`app-state index arg "${part.name}" for schema "${schema.name}" must be a string`);
|
|
60
|
+
}
|
|
61
|
+
parts[i] = arg;
|
|
62
|
+
}
|
|
63
|
+
return JSON.stringify(parts);
|
|
64
|
+
}
|
|
65
|
+
function buildSetMutationFromSchema(input) {
|
|
66
|
+
return {
|
|
67
|
+
collection: input.schema.collection,
|
|
68
|
+
operation: 'set',
|
|
69
|
+
index: buildMutationIndexFromSchema(input.schema, input.indexArgs),
|
|
70
|
+
value: { ...input.value, timestamp: input.timestamp },
|
|
71
|
+
version: input.schema.version,
|
|
72
|
+
timestamp: input.timestamp
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function splitFlatInput(schema, input) {
|
|
76
|
+
const indexNames = new Set();
|
|
77
|
+
for (const part of schema.indexParts) {
|
|
78
|
+
if (part.type !== 'literal') {
|
|
79
|
+
indexNames.add(part.name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const indexArgs = {};
|
|
83
|
+
const data = {};
|
|
84
|
+
for (const key of Object.keys(input)) {
|
|
85
|
+
if (key === 'schema')
|
|
86
|
+
continue;
|
|
87
|
+
if (indexNames.has(key)) {
|
|
88
|
+
indexArgs[key] = input[key];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
data[key] = input[key];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { indexArgs, data };
|
|
95
|
+
}
|
|
96
|
+
function wrapData(schema, data) {
|
|
97
|
+
const encoded = applyEnumEncodeToData(schema.valueEnumFields, data);
|
|
98
|
+
const field = schema.valueField;
|
|
99
|
+
if (field === null) {
|
|
100
|
+
return encoded;
|
|
101
|
+
}
|
|
102
|
+
return { [field]: encoded };
|
|
103
|
+
}
|
|
104
|
+
function applyEnumEncodeToData(enumFields, data) {
|
|
105
|
+
if (!enumFields)
|
|
106
|
+
return { ...data };
|
|
107
|
+
const out = { ...data };
|
|
108
|
+
for (const [fieldPath, enumPath] of Object.entries(enumFields)) {
|
|
109
|
+
applyEnumAtPath(out, fieldPath.split('.'), (raw) => {
|
|
110
|
+
if (typeof raw === 'number')
|
|
111
|
+
return raw;
|
|
112
|
+
if (typeof raw !== 'string')
|
|
113
|
+
return raw;
|
|
114
|
+
const numeric = (0, _appstate_spec_1.encodeEnumValue)(enumPath, raw);
|
|
115
|
+
if (numeric === null) {
|
|
116
|
+
throw new Error(`enum value "${raw}" not in ${enumPath}`);
|
|
117
|
+
}
|
|
118
|
+
return numeric;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
function applyEnumAtPath(obj, segments, transform) {
|
|
124
|
+
if (segments.length === 0)
|
|
125
|
+
return;
|
|
126
|
+
const [head, ...rest] = segments;
|
|
127
|
+
if (rest.length === 0) {
|
|
128
|
+
if (head in obj) {
|
|
129
|
+
const value = obj[head];
|
|
130
|
+
if (Array.isArray(value)) {
|
|
131
|
+
obj[head] = value.map(transform);
|
|
132
|
+
}
|
|
133
|
+
else if (value !== null && value !== undefined) {
|
|
134
|
+
obj[head] = transform(value);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const next = obj[head];
|
|
140
|
+
if (Array.isArray(next)) {
|
|
141
|
+
const cloned = next.map((item) => {
|
|
142
|
+
if (item && typeof item === 'object') {
|
|
143
|
+
const itemCopy = { ...item };
|
|
144
|
+
applyEnumAtPath(itemCopy, rest, transform);
|
|
145
|
+
return itemCopy;
|
|
146
|
+
}
|
|
147
|
+
return item;
|
|
148
|
+
});
|
|
149
|
+
obj[head] = cloned;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (next && typeof next === 'object') {
|
|
153
|
+
const nextCopy = { ...next };
|
|
154
|
+
applyEnumAtPath(nextCopy, rest, transform);
|
|
155
|
+
obj[head] = nextCopy;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function buildRemoveMutationFromSchema(input) {
|
|
159
|
+
return {
|
|
160
|
+
collection: input.schema.collection,
|
|
161
|
+
operation: 'remove',
|
|
162
|
+
index: buildMutationIndexFromSchema(input.schema, input.indexArgs),
|
|
163
|
+
previousValue: { timestamp: input.timestamp },
|
|
164
|
+
version: input.schema.version,
|
|
165
|
+
timestamp: input.timestamp
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Coordinates app-state mutations (mute/star/read/pin/archive/clear/delete/
|
|
170
|
+
* lock chats, status privacy, broadcast lists) and emits parsed mutation
|
|
171
|
+
* events on sync. Accessed via {@link WaClient.chat}.
|
|
172
|
+
*/
|
|
13
173
|
class WaAppStateMutationCoordinator {
|
|
14
174
|
constructor(options) {
|
|
15
175
|
this.logger = options.logger;
|
|
16
176
|
this.messageStore = options.messageStore;
|
|
17
|
-
this.
|
|
177
|
+
this.appStateSync = options.appStateSync;
|
|
178
|
+
this.mediaTransfer = options.mediaTransfer;
|
|
179
|
+
this.isConnected = options.isConnected;
|
|
180
|
+
this.serverClock = options.serverClock;
|
|
18
181
|
this.archiveRangeLimit = (0, coercion_1.resolvePositive)(options.archiveRangeLimit, WA_APP_STATE_ARCHIVE_RANGE_DEFAULT_LIMIT, 'WaAppStateMutationCoordinatorOptions.archiveRangeLimit');
|
|
182
|
+
this.emitMutation = options.emitMutation;
|
|
183
|
+
this.emitSnapshotMutations = options.emitSnapshotMutations === true;
|
|
184
|
+
this.nctSaltSink = options.nctSaltSink;
|
|
185
|
+
this.contactSink = options.contactSink;
|
|
19
186
|
this.pendingMutations = new Map();
|
|
20
187
|
this.flushPromise = null;
|
|
21
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Runs an app-state sync round, optionally applying pending mutations.
|
|
191
|
+
* Throws when the client is not connected. Returns the per-collection
|
|
192
|
+
* result; blocked collections are logged.
|
|
193
|
+
*/
|
|
194
|
+
async sync(options = {}) {
|
|
195
|
+
if (!this.isConnected()) {
|
|
196
|
+
throw new Error('client is not connected');
|
|
197
|
+
}
|
|
198
|
+
const syncOptions = options.downloadExternalBlob
|
|
199
|
+
? options
|
|
200
|
+
: {
|
|
201
|
+
...options,
|
|
202
|
+
downloadExternalBlob: async (_collection, _kind, reference) => (0, utils_1.downloadExternalBlobReference)(this.mediaTransfer, reference)
|
|
203
|
+
};
|
|
204
|
+
const syncResult = await this.appStateSync.sync(syncOptions);
|
|
205
|
+
const blockedCollections = this.getBlockedCollections(syncResult);
|
|
206
|
+
if (blockedCollections.length > 0) {
|
|
207
|
+
this.logger.warn('app-state sync has blocked collections', {
|
|
208
|
+
blockedCollections: blockedCollections.join(',')
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
this.emitEventsFromSyncResult(syncResult);
|
|
212
|
+
return syncResult;
|
|
213
|
+
}
|
|
214
|
+
/** Returns the names of collections reported as `BLOCKED` in `syncResult`. */
|
|
215
|
+
getBlockedCollections(syncResult) {
|
|
216
|
+
const blocked = [];
|
|
217
|
+
for (const entry of syncResult.collections) {
|
|
218
|
+
if (entry.state === constants_1.WA_APP_STATE_COLLECTION_STATES.BLOCKED) {
|
|
219
|
+
blocked.push(entry.collection);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return blocked;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Walks a sync result and emits one `app_state_mutation` event per
|
|
226
|
+
* distinct (collection, index) – only the last mutation per key wins.
|
|
227
|
+
* Snapshot-source mutations are skipped unless `emitSnapshotMutations`
|
|
228
|
+
* was enabled at construction.
|
|
229
|
+
*/
|
|
230
|
+
emitEventsFromSyncResult(syncResult) {
|
|
231
|
+
for (const collectionResult of syncResult.collections) {
|
|
232
|
+
const mutations = collectionResult.mutations ?? [];
|
|
233
|
+
// Persistence sinks (contact store, ...): run on the last-wins
|
|
234
|
+
// mutation per key INCLUDING snapshot sources, so pair-time
|
|
235
|
+
// bootstrap of the address book always lands in the store even
|
|
236
|
+
// when public events are suppressed for snapshot mutations.
|
|
237
|
+
if (this.contactSink) {
|
|
238
|
+
const sinkLastIndex = new Map();
|
|
239
|
+
for (let i = 0; i < mutations.length; i += 1) {
|
|
240
|
+
const m = mutations[i];
|
|
241
|
+
sinkLastIndex.set(`${m.collection}\u0001${m.index}`, i);
|
|
242
|
+
}
|
|
243
|
+
for (let i = 0; i < mutations.length; i += 1) {
|
|
244
|
+
const m = mutations[i];
|
|
245
|
+
if (sinkLastIndex.get(`${m.collection}\u0001${m.index}`) !== i) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
this.handleContactMutation(m);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
this.logger.debug('contact sink failed', {
|
|
253
|
+
collection: m.collection,
|
|
254
|
+
index: m.index,
|
|
255
|
+
message: (0, primitives_1.toError)(error).message
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const lastMutationIndexByKey = new Map();
|
|
261
|
+
for (let mutationIndex = 0; mutationIndex < mutations.length; mutationIndex += 1) {
|
|
262
|
+
const mutation = mutations[mutationIndex];
|
|
263
|
+
if (!this.emitSnapshotMutations && mutation.source === 'snapshot') {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
lastMutationIndexByKey.set(`${mutation.collection}\u0001${mutation.index}`, mutationIndex);
|
|
267
|
+
}
|
|
268
|
+
for (let mutationIndex = 0; mutationIndex < mutations.length; mutationIndex += 1) {
|
|
269
|
+
const mutation = mutations[mutationIndex];
|
|
270
|
+
if (!this.emitSnapshotMutations && mutation.source === 'snapshot') {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const coalesceKey = `${mutation.collection}\u0001${mutation.index}`;
|
|
274
|
+
if (lastMutationIndexByKey.get(coalesceKey) !== mutationIndex) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
this.handleNctSaltMutation(mutation);
|
|
279
|
+
const event = (0, appstate_mutation_1.parseAppStateMutationEvent)(mutation);
|
|
280
|
+
if (!event) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
this.emitMutation?.(event);
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
this.logger.debug('failed to parse app-state mutation event', {
|
|
287
|
+
collection: mutation.collection,
|
|
288
|
+
source: mutation.source,
|
|
289
|
+
index: mutation.index,
|
|
290
|
+
message: (0, primitives_1.toError)(error).message
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
handleNctSaltMutation(mutation) {
|
|
297
|
+
if (!this.nctSaltSink)
|
|
298
|
+
return;
|
|
299
|
+
const nctAction = mutation.value?.nctSaltSyncAction;
|
|
300
|
+
if (!nctAction) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (mutation.operation === 'set' && nctAction.salt) {
|
|
304
|
+
this.nctSaltSink(nctAction.salt).catch((err) => this.logger.warn('nct salt sync set failed', {
|
|
305
|
+
message: (0, primitives_1.toError)(err).message
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
else if (mutation.operation === 'remove') {
|
|
309
|
+
this.nctSaltSink(null).catch((err) => this.logger.warn('nct salt sync remove failed', {
|
|
310
|
+
message: (0, primitives_1.toError)(err).message
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
handleContactMutation(mutation) {
|
|
315
|
+
if (!this.contactSink)
|
|
316
|
+
return;
|
|
317
|
+
// Cheap reject before JSON.parse: Contact mutations always carry
|
|
318
|
+
// the literal "contact" as their first index segment.
|
|
319
|
+
if (!mutation.index.includes('"contact"'))
|
|
320
|
+
return;
|
|
321
|
+
let parts;
|
|
322
|
+
try {
|
|
323
|
+
parts = JSON.parse(mutation.index);
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (!Array.isArray(parts) || parts[0] !== 'contact' || typeof parts[1] !== 'string') {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const indexJid = parts[1];
|
|
332
|
+
const lastUpdatedMs = mutation.timestamp > 0 ? mutation.timestamp : Date.now();
|
|
333
|
+
// Remove operations are a no-op for the contact store: `mergeContact`
|
|
334
|
+
// preserves prior displayName when incoming.displayName is undefined,
|
|
335
|
+
// and the row should stay around (the chat may still be open). The
|
|
336
|
+
// public mutation event still fires below so consumers can react.
|
|
337
|
+
if (mutation.operation === 'remove')
|
|
338
|
+
return;
|
|
339
|
+
const action = mutation.value?.contactAction;
|
|
340
|
+
if (!action)
|
|
341
|
+
return;
|
|
342
|
+
// Resolve canonical (LID-preferred) jid + cross-reference: the index
|
|
343
|
+
// typically carries the PN form, and `contactAction.lidJid` carries
|
|
344
|
+
// the LID counterpart. Store one row keyed by LID when both are known
|
|
345
|
+
// (mirrors what the contact store does for history-sync writes), with
|
|
346
|
+
// `phoneNumber` populated so PN-form lookups still resolve.
|
|
347
|
+
const lid = action.lidJid && (0, jid_1.isLidJid)(action.lidJid) ? action.lidJid : undefined;
|
|
348
|
+
const indexIsPn = (0, jid_1.isUserJid)(indexJid);
|
|
349
|
+
const indexIsLid = (0, jid_1.isLidJid)(indexJid);
|
|
350
|
+
const jid = lid ?? indexJid;
|
|
351
|
+
const phoneNumber = indexIsPn ? indexJid : undefined;
|
|
352
|
+
const lidField = lid ?? (indexIsLid ? indexJid : undefined);
|
|
353
|
+
const displayName = action.fullName || action.firstName || undefined;
|
|
354
|
+
this.contactSink({
|
|
355
|
+
jid,
|
|
356
|
+
displayName,
|
|
357
|
+
lid: lidField,
|
|
358
|
+
phoneNumber,
|
|
359
|
+
lastUpdatedMs
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Mutes or unmutes a chat. `muteEndTimestampMs` is required when
|
|
364
|
+
* `muted` is `true` and must be a non-negative safe-integer epoch.
|
|
365
|
+
*
|
|
366
|
+
* For a "mute forever" entry, pass a very large epoch value (the
|
|
367
|
+
* official client uses year-9999 epochs). The mute end is the absolute
|
|
368
|
+
* timestamp when WhatsApp will re-enable notifications - the client
|
|
369
|
+
* does **not** unmute automatically when the timer expires (you'll see
|
|
370
|
+
* the chat un-muted on the phone, but no `mutation` event re-fires).
|
|
371
|
+
*/
|
|
22
372
|
async setChatMute(chatJid, muted, muteEndTimestampMs) {
|
|
23
373
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
24
|
-
const timestamp =
|
|
374
|
+
const timestamp = this.serverClock.nowMs();
|
|
25
375
|
const normalizedMuteEnd = muteEndTimestampMs;
|
|
26
376
|
if (normalizedMuteEnd !== undefined &&
|
|
27
377
|
(!Number.isFinite(normalizedMuteEnd) ||
|
|
@@ -32,66 +382,63 @@ class WaAppStateMutationCoordinator {
|
|
|
32
382
|
if (muted && normalizedMuteEnd === undefined) {
|
|
33
383
|
throw new Error('setChatMute requires muteEndTimestampMs when muted is true');
|
|
34
384
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
385
|
+
await this.enqueueAndFlush([
|
|
386
|
+
buildSetMutationFromSchema({
|
|
387
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.Mute,
|
|
388
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
389
|
+
value: {
|
|
390
|
+
muteAction: {
|
|
391
|
+
muted,
|
|
392
|
+
...(normalizedMuteEnd === undefined
|
|
393
|
+
? {}
|
|
394
|
+
: { muteEndTimestamp: normalizedMuteEnd })
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
timestamp
|
|
398
|
+
})
|
|
399
|
+
]);
|
|
49
400
|
}
|
|
401
|
+
/** Stars or un-stars a specific message. */
|
|
50
402
|
async setMessageStar(message, starred) {
|
|
51
403
|
const messageIndex = this.buildMessageMutationIndex(message);
|
|
52
|
-
const timestamp =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
starAction: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
timestamp,
|
|
62
|
-
indexPartsTail: messageIndex.indexPartsTail
|
|
63
|
-
});
|
|
64
|
-
await this.enqueueAndFlush([mutation]);
|
|
404
|
+
const timestamp = this.serverClock.nowMs();
|
|
405
|
+
await this.enqueueAndFlush([
|
|
406
|
+
buildSetMutationFromSchema({
|
|
407
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.Star,
|
|
408
|
+
indexArgs: messageIndex,
|
|
409
|
+
value: { starAction: { starred } },
|
|
410
|
+
timestamp
|
|
411
|
+
})
|
|
412
|
+
]);
|
|
65
413
|
}
|
|
414
|
+
/** Marks the chat as read or unread. */
|
|
66
415
|
async setChatRead(chatJid, read) {
|
|
67
416
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
68
|
-
const timestamp =
|
|
417
|
+
const timestamp = this.serverClock.nowMs();
|
|
69
418
|
const messageRange = await this.buildChatMessageRange(chatIndexJid);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
markChatAsReadAction: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
timestamp
|
|
80
|
-
});
|
|
81
|
-
await this.enqueueAndFlush([mutation]);
|
|
419
|
+
await this.enqueueAndFlush([
|
|
420
|
+
buildSetMutationFromSchema({
|
|
421
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.MarkChatAsRead,
|
|
422
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
423
|
+
value: { markChatAsReadAction: { read, messageRange } },
|
|
424
|
+
timestamp
|
|
425
|
+
})
|
|
426
|
+
]);
|
|
82
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Pins or unpins the chat. Pinning also clears any active archive flag
|
|
430
|
+
* (the two states are mutually exclusive on the client). WhatsApp
|
|
431
|
+
* imposes a server-side cap on pinned chats - extra pins sync but the
|
|
432
|
+
* official UI will hide / reject them.
|
|
433
|
+
*/
|
|
83
434
|
async setChatPin(chatJid, pinned) {
|
|
84
435
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
85
|
-
const timestamp =
|
|
436
|
+
const timestamp = this.serverClock.nowMs();
|
|
86
437
|
const pending = [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
chatIndexJid,
|
|
90
|
-
value: {
|
|
91
|
-
pinAction: {
|
|
92
|
-
pinned
|
|
93
|
-
}
|
|
94
|
-
},
|
|
438
|
+
buildSetMutationFromSchema({
|
|
439
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.Pin,
|
|
440
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
441
|
+
value: { pinAction: { pinned } },
|
|
95
442
|
timestamp
|
|
96
443
|
})
|
|
97
444
|
];
|
|
@@ -100,66 +447,82 @@ class WaAppStateMutationCoordinator {
|
|
|
100
447
|
}
|
|
101
448
|
await this.enqueueAndFlush(pending);
|
|
102
449
|
}
|
|
450
|
+
/** Archives or unarchives the chat. Archiving also clears any pin. */
|
|
103
451
|
async setChatArchive(chatJid, archived) {
|
|
104
452
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
105
|
-
const timestamp =
|
|
453
|
+
const timestamp = this.serverClock.nowMs();
|
|
106
454
|
const pending = [
|
|
107
455
|
await this.createArchiveMutation(chatIndexJid, archived, timestamp)
|
|
108
456
|
];
|
|
109
457
|
if (archived) {
|
|
110
|
-
pending.push(
|
|
111
|
-
|
|
112
|
-
chatIndexJid,
|
|
113
|
-
value: {
|
|
114
|
-
pinAction: {
|
|
115
|
-
pinned: false
|
|
116
|
-
}
|
|
117
|
-
},
|
|
458
|
+
pending.push(buildSetMutationFromSchema({
|
|
459
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.Pin,
|
|
460
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
461
|
+
value: { pinAction: { pinned: false } },
|
|
118
462
|
timestamp
|
|
119
463
|
}));
|
|
120
464
|
}
|
|
121
465
|
await this.enqueueAndFlush(pending);
|
|
122
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Clears the chat history (without deleting the chat itself - it stays
|
|
469
|
+
* in the chat list, just empty). Defaults to **preserving** starred
|
|
470
|
+
* messages and media; set `options.deleteStarred`/`deleteMedia` to wipe
|
|
471
|
+
* those too. The clear is local-only - other participants keep their
|
|
472
|
+
* copies.
|
|
473
|
+
*/
|
|
123
474
|
async clearChat(chatJid, options = {}) {
|
|
124
475
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
125
|
-
const timestamp =
|
|
476
|
+
const timestamp = this.serverClock.nowMs();
|
|
126
477
|
const deleteStarred = options.deleteStarred === true;
|
|
127
478
|
const deleteMedia = options.deleteMedia === true;
|
|
128
479
|
const messageRange = await this.buildChatMessageRange(chatIndexJid);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
480
|
+
await this.enqueueAndFlush([
|
|
481
|
+
buildSetMutationFromSchema({
|
|
482
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.ClearChat,
|
|
483
|
+
indexArgs: {
|
|
484
|
+
chatJid: chatIndexJid,
|
|
485
|
+
deleteStarred: deleteStarred ? '1' : '0',
|
|
486
|
+
deleteMedia: deleteMedia ? '1' : '0'
|
|
487
|
+
},
|
|
488
|
+
value: { clearChatAction: { messageRange } },
|
|
489
|
+
timestamp
|
|
490
|
+
})
|
|
491
|
+
]);
|
|
141
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* Deletes the chat entirely (removes from the chat list + drops every
|
|
495
|
+
* stored message). Local-only - the conversation continues to exist on
|
|
496
|
+
* the peer's device. For groups, this does **not** leave the group;
|
|
497
|
+
* use {@link WaGroupCoordinator.leaveGroup} for that.
|
|
498
|
+
*/
|
|
142
499
|
async deleteChat(chatJid, options = {}) {
|
|
143
500
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
144
|
-
const timestamp =
|
|
501
|
+
const timestamp = this.serverClock.nowMs();
|
|
145
502
|
const deleteMedia = options.deleteMedia === true;
|
|
146
503
|
const messageRange = await this.buildChatMessageRange(chatIndexJid);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
await this.enqueueAndFlush([mutation]);
|
|
504
|
+
await this.enqueueAndFlush([
|
|
505
|
+
buildSetMutationFromSchema({
|
|
506
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.DeleteChat,
|
|
507
|
+
indexArgs: {
|
|
508
|
+
chatJid: chatIndexJid,
|
|
509
|
+
deleteMedia: deleteMedia ? '1' : '0'
|
|
510
|
+
},
|
|
511
|
+
value: { deleteChatAction: { messageRange } },
|
|
512
|
+
timestamp
|
|
513
|
+
})
|
|
514
|
+
]);
|
|
159
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Deletes a single message **locally** - removes it from your own
|
|
518
|
+
* device(s) only. The recipient(s) still see it. Use a `revoke`
|
|
519
|
+
* outgoing message ({@link WaMessageCoordinator.send} with
|
|
520
|
+
* `{ type: 'revoke', ... }`) to delete-for-everyone instead.
|
|
521
|
+
* `messageTimestampMs` must be a non-negative safe-integer epoch when set.
|
|
522
|
+
*/
|
|
160
523
|
async deleteMessageForMe(message, options = {}) {
|
|
161
524
|
const messageIndex = this.buildMessageMutationIndex(message);
|
|
162
|
-
const timestamp =
|
|
525
|
+
const timestamp = this.serverClock.nowMs();
|
|
163
526
|
const deleteMedia = options.deleteMedia === true;
|
|
164
527
|
const messageTimestampMs = options.messageTimestampMs;
|
|
165
528
|
let messageTimestamp;
|
|
@@ -171,49 +534,47 @@ class WaAppStateMutationCoordinator {
|
|
|
171
534
|
}
|
|
172
535
|
messageTimestamp = Math.floor(messageTimestampMs / 1000);
|
|
173
536
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
537
|
+
await this.enqueueAndFlush([
|
|
538
|
+
buildSetMutationFromSchema({
|
|
539
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.DeleteMessageForMe,
|
|
540
|
+
indexArgs: messageIndex,
|
|
541
|
+
value: {
|
|
542
|
+
deleteMessageForMeAction: {
|
|
543
|
+
deleteMedia,
|
|
544
|
+
...(messageTimestamp === undefined ? {} : { messageTimestamp })
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
timestamp
|
|
548
|
+
})
|
|
549
|
+
]);
|
|
187
550
|
}
|
|
551
|
+
/** Locks or unlocks the chat. Locking also clears archive and pin. */
|
|
188
552
|
async setChatLock(chatJid, locked) {
|
|
189
553
|
const chatIndexJid = this.normalizeChatMutationJid(chatJid);
|
|
190
|
-
const timestamp =
|
|
554
|
+
const timestamp = this.serverClock.nowMs();
|
|
191
555
|
const pending = [];
|
|
192
556
|
if (locked) {
|
|
193
557
|
pending.push(await this.createArchiveMutation(chatIndexJid, false, timestamp));
|
|
194
|
-
pending.push(
|
|
195
|
-
|
|
196
|
-
chatIndexJid,
|
|
197
|
-
value: {
|
|
198
|
-
pinAction: {
|
|
199
|
-
pinned: false
|
|
200
|
-
}
|
|
201
|
-
},
|
|
558
|
+
pending.push(buildSetMutationFromSchema({
|
|
559
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.Pin,
|
|
560
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
561
|
+
value: { pinAction: { pinned: false } },
|
|
202
562
|
timestamp
|
|
203
563
|
}));
|
|
204
564
|
}
|
|
205
|
-
pending.push(
|
|
206
|
-
|
|
207
|
-
chatIndexJid,
|
|
208
|
-
value: {
|
|
209
|
-
lockChatAction: {
|
|
210
|
-
locked
|
|
211
|
-
}
|
|
212
|
-
},
|
|
565
|
+
pending.push(buildSetMutationFromSchema({
|
|
566
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.LockChat,
|
|
567
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
568
|
+
value: { lockChatAction: { locked } },
|
|
213
569
|
timestamp
|
|
214
570
|
}));
|
|
215
571
|
await this.enqueueAndFlush(pending);
|
|
216
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Drains any queued mutations through a sync round. Concurrent callers
|
|
575
|
+
* share the in-flight flush promise. Failed collections are re-queued
|
|
576
|
+
* before the error is rethrown.
|
|
577
|
+
*/
|
|
217
578
|
async flushMutations() {
|
|
218
579
|
if (this.flushPromise) {
|
|
219
580
|
return this.flushPromise;
|
|
@@ -271,7 +632,7 @@ class WaAppStateMutationCoordinator {
|
|
|
271
632
|
seenCollections.add(mutation.collection);
|
|
272
633
|
collections.push(mutation.collection);
|
|
273
634
|
}
|
|
274
|
-
syncResult = await this.
|
|
635
|
+
syncResult = await this.sync({
|
|
275
636
|
collections,
|
|
276
637
|
pendingMutations: batch
|
|
277
638
|
});
|
|
@@ -323,30 +684,190 @@ class WaAppStateMutationCoordinator {
|
|
|
323
684
|
this.enqueueMutation(mutation);
|
|
324
685
|
}
|
|
325
686
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
687
|
+
/**
|
|
688
|
+
* Sets the account-wide status-broadcast distribution policy. `mode`
|
|
689
|
+
* accepts either the proto enum number or its string name; allow/deny
|
|
690
|
+
* lists are provided via `userJids`.
|
|
691
|
+
*/
|
|
692
|
+
async setStatusPrivacy(input) {
|
|
693
|
+
const modeValue = typeof input.mode === 'number'
|
|
694
|
+
? input.mode
|
|
695
|
+
: _proto_1.proto.SyncActionValue.StatusPrivacyAction.StatusDistributionMode[input.mode];
|
|
696
|
+
if (typeof modeValue !== 'number' || !Number.isInteger(modeValue)) {
|
|
697
|
+
throw new Error(`setStatusPrivacy: invalid mode ${String(input.mode)}`);
|
|
698
|
+
}
|
|
699
|
+
const userJid = input.userJids ? [...input.userJids] : [];
|
|
700
|
+
const value = {
|
|
701
|
+
statusPrivacy: {
|
|
702
|
+
mode: modeValue,
|
|
703
|
+
userJid,
|
|
704
|
+
...(input.shareToFB === undefined ? {} : { shareToFB: input.shareToFB }),
|
|
705
|
+
...(input.shareToIG === undefined ? {} : { shareToIG: input.shareToIG })
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
const timestamp = this.serverClock.nowMs();
|
|
709
|
+
await this.enqueueAndFlush([
|
|
710
|
+
buildSetMutationFromSchema({
|
|
711
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.StatusPrivacy,
|
|
712
|
+
indexArgs: {},
|
|
713
|
+
value,
|
|
714
|
+
timestamp
|
|
715
|
+
})
|
|
716
|
+
]);
|
|
717
|
+
}
|
|
718
|
+
/** Mutes/unmutes a single user's status broadcasts. Rejects group/broadcast JIDs. */
|
|
719
|
+
async setUserStatusMute(jid, muted) {
|
|
720
|
+
const indexJid = this.normalizeChatMutationJid(jid);
|
|
721
|
+
if ((0, jid_1.isGroupOrBroadcastJid)(indexJid)) {
|
|
722
|
+
throw new Error(`setUserStatusMute requires a user jid, got ${jid}`);
|
|
723
|
+
}
|
|
724
|
+
const timestamp = this.serverClock.nowMs();
|
|
725
|
+
await this.enqueueAndFlush([
|
|
726
|
+
buildSetMutationFromSchema({
|
|
727
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.UserStatusMute,
|
|
728
|
+
indexArgs: { id: indexJid },
|
|
729
|
+
value: { userStatusMuteAction: { muted } },
|
|
730
|
+
timestamp
|
|
731
|
+
})
|
|
732
|
+
]);
|
|
733
|
+
}
|
|
734
|
+
/** Creates or updates the broadcast list identified by `input.id`. */
|
|
735
|
+
async setBroadcastList(input) {
|
|
736
|
+
const participants = input.participants.map((entry) => ({
|
|
737
|
+
lidJid: entry.lidJid,
|
|
738
|
+
...(entry.pnJid === undefined ? {} : { pnJid: entry.pnJid })
|
|
739
|
+
}));
|
|
740
|
+
const value = {
|
|
741
|
+
businessBroadcastListAction: {
|
|
742
|
+
participants,
|
|
743
|
+
listName: input.listName,
|
|
744
|
+
labelIds: input.labelIds ? [...input.labelIds] : []
|
|
745
|
+
}
|
|
337
746
|
};
|
|
747
|
+
const timestamp = this.serverClock.nowMs();
|
|
748
|
+
await this.enqueueAndFlush([
|
|
749
|
+
buildSetMutationFromSchema({
|
|
750
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.BusinessBroadcastList,
|
|
751
|
+
indexArgs: { id: input.id },
|
|
752
|
+
value,
|
|
753
|
+
timestamp
|
|
754
|
+
})
|
|
755
|
+
]);
|
|
756
|
+
}
|
|
757
|
+
/** Deletes the broadcast list identified by `id`. */
|
|
758
|
+
async removeBroadcastList(id) {
|
|
759
|
+
const timestamp = this.serverClock.nowMs();
|
|
760
|
+
await this.enqueueAndFlush([
|
|
761
|
+
buildRemoveMutationFromSchema({
|
|
762
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.BusinessBroadcastList,
|
|
763
|
+
indexArgs: { id },
|
|
764
|
+
timestamp
|
|
765
|
+
})
|
|
766
|
+
]);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Applies a `set` mutation against any registered app-state schema. This
|
|
770
|
+
* is the way to reach schemas that don't have a typed helper on this
|
|
771
|
+
* coordinator (Contact, LabelEdit, LabelJid, QuickReply, AiThreadPin,
|
|
772
|
+
* Favorites, Nux, ...). For the common chat actions there's a dedicated
|
|
773
|
+
* method ({@link setChatMute}, {@link setChatRead}, {@link setMessageStar},
|
|
774
|
+
* {@link setChatPin}, {@link setChatArchive}, etc.) – use those instead.
|
|
775
|
+
*
|
|
776
|
+
* `input` is flat – pick a `schema` name from {@link WA_APPSTATE_SCHEMAS},
|
|
777
|
+
* fill the index fields (`id`, `chatJid`, `labelId`, ...) and the value
|
|
778
|
+
* fields side-by-side, and the coordinator routes them to the right
|
|
779
|
+
* SyncActionValue subfield.
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* ```ts
|
|
783
|
+
* // Add a contact to the address book
|
|
784
|
+
* await client.chat.set({
|
|
785
|
+
* schema: 'Contact',
|
|
786
|
+
* id: '5511999999999@s.whatsapp.net',
|
|
787
|
+
* contactAction: { fullName: 'Maria Silva', firstName: 'Maria' }
|
|
788
|
+
* })
|
|
789
|
+
*
|
|
790
|
+
* // Create a chat label (color is a server-side palette index)
|
|
791
|
+
* await client.chat.set({
|
|
792
|
+
* schema: 'LabelEdit',
|
|
793
|
+
* id: 'label-1',
|
|
794
|
+
* labelEditAction: { name: 'Pendente', color: 0, isActive: true }
|
|
795
|
+
* })
|
|
796
|
+
*
|
|
797
|
+
* // Apply that label to a chat
|
|
798
|
+
* await client.chat.set({
|
|
799
|
+
* schema: 'LabelJid',
|
|
800
|
+
* labelId: 'label-1',
|
|
801
|
+
* chatJid: '5511999999999@s.whatsapp.net',
|
|
802
|
+
* labelAssociationAction: { labeled: true }
|
|
803
|
+
* })
|
|
804
|
+
*
|
|
805
|
+
* // Save a business quick reply
|
|
806
|
+
* await client.chat.set({
|
|
807
|
+
* schema: 'QuickReply',
|
|
808
|
+
* id: 'qr-greeting',
|
|
809
|
+
* quickReplyAction: { shortcut: '/oi', message: 'Olá! Tudo bem?' }
|
|
810
|
+
* })
|
|
811
|
+
* ```
|
|
812
|
+
*/
|
|
813
|
+
async set(input) {
|
|
814
|
+
const resolved = _appstate_spec_1.WA_APPSTATE_SCHEMAS[input.schema];
|
|
815
|
+
const { indexArgs, data } = splitFlatInput(resolved, input);
|
|
816
|
+
const value = wrapData(resolved, data);
|
|
817
|
+
const timestamp = this.serverClock.nowMs();
|
|
818
|
+
const mutation = buildSetMutationFromSchema({
|
|
819
|
+
schema: resolved,
|
|
820
|
+
indexArgs: indexArgs,
|
|
821
|
+
value,
|
|
822
|
+
timestamp
|
|
823
|
+
});
|
|
824
|
+
await this.enqueueAndFlush([mutation]);
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Applies a `remove` mutation against any registered app-state schema -
|
|
828
|
+
* same shape as {@link set} but without the value fields (only the schema
|
|
829
|
+
* name + index args). Use this for schemas without a typed helper.
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
* ```ts
|
|
833
|
+
* // Drop a contact from the address book
|
|
834
|
+
* await client.chat.remove({
|
|
835
|
+
* schema: 'Contact',
|
|
836
|
+
* id: '5511999999999@s.whatsapp.net'
|
|
837
|
+
* })
|
|
838
|
+
*
|
|
839
|
+
* // Remove a label from a chat (the label itself stays – use LabelEdit
|
|
840
|
+
* // with `deleted: true` to delete the label definition entirely)
|
|
841
|
+
* await client.chat.remove({
|
|
842
|
+
* schema: 'LabelJid',
|
|
843
|
+
* labelId: 'label-1',
|
|
844
|
+
* chatJid: '5511999999999@s.whatsapp.net'
|
|
845
|
+
* })
|
|
846
|
+
*
|
|
847
|
+
* // Delete a quick reply
|
|
848
|
+
* await client.chat.remove({
|
|
849
|
+
* schema: 'QuickReply',
|
|
850
|
+
* id: 'qr-greeting'
|
|
851
|
+
* })
|
|
852
|
+
* ```
|
|
853
|
+
*/
|
|
854
|
+
async remove(input) {
|
|
855
|
+
const resolved = _appstate_spec_1.WA_APPSTATE_SCHEMAS[input.schema];
|
|
856
|
+
const { indexArgs } = splitFlatInput(resolved, input);
|
|
857
|
+
const timestamp = this.serverClock.nowMs();
|
|
858
|
+
const mutation = buildRemoveMutationFromSchema({
|
|
859
|
+
schema: resolved,
|
|
860
|
+
indexArgs: indexArgs,
|
|
861
|
+
timestamp
|
|
862
|
+
});
|
|
863
|
+
await this.enqueueAndFlush([mutation]);
|
|
338
864
|
}
|
|
339
865
|
async createArchiveMutation(chatIndexJid, archived, timestamp) {
|
|
340
866
|
const messageRange = await this.buildChatMessageRange(chatIndexJid);
|
|
341
|
-
return
|
|
342
|
-
|
|
343
|
-
chatIndexJid,
|
|
344
|
-
value: {
|
|
345
|
-
archiveChatAction: {
|
|
346
|
-
archived,
|
|
347
|
-
messageRange
|
|
348
|
-
}
|
|
349
|
-
},
|
|
867
|
+
return buildSetMutationFromSchema({
|
|
868
|
+
schema: _appstate_spec_1.WA_APPSTATE_SCHEMAS.Archive,
|
|
869
|
+
indexArgs: { chatJid: chatIndexJid },
|
|
870
|
+
value: { archiveChatAction: { archived, messageRange } },
|
|
350
871
|
timestamp
|
|
351
872
|
});
|
|
352
873
|
}
|
|
@@ -431,8 +952,10 @@ class WaAppStateMutationCoordinator {
|
|
|
431
952
|
const fromMe = message.fromMe === true;
|
|
432
953
|
const participant = this.resolveMessageMutationParticipant(chatIndexJid, fromMe, message.participantJid);
|
|
433
954
|
return {
|
|
434
|
-
chatIndexJid,
|
|
435
|
-
|
|
955
|
+
remote: chatIndexJid,
|
|
956
|
+
id: messageId,
|
|
957
|
+
fromMe,
|
|
958
|
+
participant
|
|
436
959
|
};
|
|
437
960
|
}
|
|
438
961
|
resolveMessageMutationParticipant(chatIndexJid, fromMe, participantJid) {
|
|
@@ -448,9 +971,6 @@ class WaAppStateMutationCoordinator {
|
|
|
448
971
|
}
|
|
449
972
|
return (0, jid_1.normalizeDeviceJid)(normalized);
|
|
450
973
|
}
|
|
451
|
-
buildMutationIndex(action, chatIndexJid, indexPartsTail) {
|
|
452
|
-
return JSON.stringify([action, chatIndexJid, ...indexPartsTail]);
|
|
453
|
-
}
|
|
454
974
|
describeMutationActions(mutations) {
|
|
455
975
|
return mutations
|
|
456
976
|
.map((mutation) => {
|