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,17 +1,45 @@
|
|
|
1
1
|
import type { AppStateCollectionName } from '../appstate/types';
|
|
2
|
+
import type { DataForKey, WaAppstateActionKey, WaAppstateIndexArgs } from '..';
|
|
2
3
|
import type { WaAuthClientOptions, WaAuthCredentials, WaAuthDangerousOptions, WaAuthSocketOptions } from '../auth/types';
|
|
4
|
+
import type { WaCallGroupParticipant, WaCallType } from './events/call';
|
|
5
|
+
import type { IncomingPresenceType, PresenceLastSeen } from './events/presence';
|
|
3
6
|
import type { WaMediaProcessor } from '../media/processor';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
7
|
+
import type { WaLinkPreviewOptions } from '../message/addons/link-preview/types';
|
|
8
|
+
import type { WaQuoteRef, WaSendContextInfo } from '../message/context-info';
|
|
9
|
+
import type { WaDecodedAddon } from '../message/crypto/addon-crypto';
|
|
10
|
+
import type { WaMessageKey, WaMessagePublishOptions, WaMessageRef, WaSendEditKey } from '../message/types';
|
|
6
11
|
import type { Proto } from '..';
|
|
12
|
+
import type { WaBotMsgEditType } from '../protocol/bot';
|
|
13
|
+
import type { WaBusinessHoursDay, WaBusinessHoursMode } from '../protocol/business';
|
|
7
14
|
import type { WaConnectionCode, WaConnectionOpenReason, WaDisconnectReason } from '../protocol/stream';
|
|
8
15
|
import type { WaStore } from '../store/types';
|
|
16
|
+
import type { ChatstateMedia, ChatstateState } from '../transport/node/builders/chatstate';
|
|
17
|
+
import type { WaNoiseRootCa } from '../transport/noise/WaNoiseCert';
|
|
9
18
|
import type { BinaryNode, WaProxyTransport } from '../transport/types';
|
|
10
19
|
export interface WaClientProxyOptions {
|
|
11
20
|
readonly ws?: WaProxyTransport;
|
|
12
21
|
readonly mediaUpload?: WaProxyTransport;
|
|
13
22
|
readonly mediaDownload?: WaProxyTransport;
|
|
23
|
+
/**
|
|
24
|
+
* Proxy used by the default link preview fetcher when fetching the page
|
|
25
|
+
* HTML and the og:image bytes. Must be a `WaProxyDispatcher` (e.g. an
|
|
26
|
+
* undici `ProxyAgent`); the global `fetch` does not consume `http.Agent`.
|
|
27
|
+
* HQ thumbnail upload reuses `mediaUpload`.
|
|
28
|
+
*/
|
|
29
|
+
readonly linkPreview?: WaProxyTransport;
|
|
14
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Per-domain control over what {@link WaClient.logout} wipes from the store.
|
|
33
|
+
*
|
|
34
|
+
* Defaults (when the domain is left `undefined`):
|
|
35
|
+
* - `messages`, `threads`, `contacts` → **preserved** (mailbox archive
|
|
36
|
+
* survives logout; the user keeps their history when re-pairing).
|
|
37
|
+
* - everything else → **cleared** (credentials, Signal state, app-state,
|
|
38
|
+
* caches, privacy tokens: all need a clean slate for the new pair).
|
|
39
|
+
*
|
|
40
|
+
* Explicit `true`/`false` always wins. To wipe the mailbox too, pass
|
|
41
|
+
* `{ messages: true, threads: true, contacts: true }`.
|
|
42
|
+
*/
|
|
15
43
|
export interface WaLogoutStoreClearOptions {
|
|
16
44
|
readonly auth?: boolean;
|
|
17
45
|
readonly signal?: boolean;
|
|
@@ -21,7 +49,7 @@ export interface WaLogoutStoreClearOptions {
|
|
|
21
49
|
readonly senderKey?: boolean;
|
|
22
50
|
readonly appState?: boolean;
|
|
23
51
|
readonly retry?: boolean;
|
|
24
|
-
readonly
|
|
52
|
+
readonly groupMetadata?: boolean;
|
|
25
53
|
readonly deviceList?: boolean;
|
|
26
54
|
readonly messages?: boolean;
|
|
27
55
|
readonly messageSecret?: boolean;
|
|
@@ -30,33 +58,125 @@ export interface WaLogoutStoreClearOptions {
|
|
|
30
58
|
readonly privacyToken?: boolean;
|
|
31
59
|
}
|
|
32
60
|
export interface WaClientOptions extends WaAuthClientOptions, WaAuthSocketOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Store instance built by {@link createStore}. Holds every per-session
|
|
63
|
+
* domain (auth, signal, app-state, ...). Required.
|
|
64
|
+
*/
|
|
33
65
|
readonly store: WaStore;
|
|
66
|
+
/**
|
|
67
|
+
* Logical session identifier – keys every domain inside `store`. Use a
|
|
68
|
+
* stable string per device/account; changing it between runs orphans the
|
|
69
|
+
* previous credentials.
|
|
70
|
+
*/
|
|
34
71
|
readonly sessionId: string;
|
|
72
|
+
/**
|
|
73
|
+
* Optional HTTP(S)/WS proxy configuration. You can target the WebSocket
|
|
74
|
+
* (`ws`), media upload, media download, and link preview legs
|
|
75
|
+
* independently – see {@link WaClientProxyOptions}.
|
|
76
|
+
*/
|
|
35
77
|
readonly proxy?: WaClientProxyOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Override the WhatsApp chat WebSocket URL list. Defaults to the
|
|
80
|
+
* production endpoints; useful for routing through a fake server in
|
|
81
|
+
* tests or pinning a specific edge.
|
|
82
|
+
*/
|
|
36
83
|
readonly chatSocketUrls?: readonly string[];
|
|
84
|
+
/** Default timeout (ms) for IQ queries. Defaults to `WA_DEFAULTS.IQ_TIMEOUT_MS` (60s). */
|
|
37
85
|
readonly iqTimeoutMs?: number;
|
|
86
|
+
/** Default timeout (ms) for raw node `query()` calls when none is passed. */
|
|
38
87
|
readonly nodeQueryTimeoutMs?: number;
|
|
88
|
+
/** Interval (ms) between server ping IQs sent by the keep-alive loop. */
|
|
39
89
|
readonly keepAliveIntervalMs?: number;
|
|
90
|
+
/**
|
|
91
|
+
* How long (ms) the keep-alive may go without a server reply before the
|
|
92
|
+
* socket is considered dead and a reconnect is triggered.
|
|
93
|
+
*/
|
|
40
94
|
readonly deadSocketTimeoutMs?: number;
|
|
95
|
+
/** Default timeout (ms) for media upload/download requests. */
|
|
41
96
|
readonly mediaTimeoutMs?: number;
|
|
97
|
+
/** Default timeout (ms) for app-state sync IQ rounds. */
|
|
42
98
|
readonly appStateSyncTimeoutMs?: number;
|
|
99
|
+
/** Default timeout (ms) for Signal prekey-bundle fetches. */
|
|
43
100
|
readonly signalFetchKeyBundlesTimeoutMs?: number;
|
|
101
|
+
/** How long (ms) `message.send` waits for the server `<ack>` per attempt. */
|
|
44
102
|
readonly messageAckTimeoutMs?: number;
|
|
103
|
+
/** Max number of attempts for a single `message.send` before giving up. */
|
|
45
104
|
readonly messageMaxAttempts?: number;
|
|
105
|
+
/** Delay (ms) between message-send retry attempts. */
|
|
46
106
|
readonly messageRetryDelayMs?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Initial presence sent right after the post-connect passive task runs.
|
|
109
|
+
* - `false` (default): announce as unavailable – matches wa-web when the
|
|
110
|
+
* tab is not focused (or the Windows app is minimized to tray) at login
|
|
111
|
+
* time, and keeps headless bots/automation invisible by default.
|
|
112
|
+
* - `true`: announce the client as online – matches wa-web behavior when
|
|
113
|
+
* the browser tab has focus at login time.
|
|
114
|
+
*/
|
|
115
|
+
readonly markOnlineOnConnect?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Automatically reconnect when the server rejects the noise handshake
|
|
118
|
+
* with HTTP 405 / `failure_client_too_old`. On every 405 the client
|
|
119
|
+
* logs a warning asking you to upgrade zapo, fetches the current
|
|
120
|
+
* version from `web.whatsapp.com` via `fetchLatestWaWebVersion()`,
|
|
121
|
+
* swaps it in for the next connect, and retries. Off by default.
|
|
122
|
+
*/
|
|
123
|
+
readonly recoverFromClientTooOld?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Write-behind persistence tuning – how long to batch incoming messages
|
|
126
|
+
* before flushing to `messages`/`threads`/`contacts` stores.
|
|
127
|
+
*/
|
|
47
128
|
readonly writeBehind?: WaWriteBehindOptions;
|
|
129
|
+
/**
|
|
130
|
+
* History-sync behavior. By default chunks pushed via
|
|
131
|
+
* `historySyncNotification` (both the initial bootstrap and the
|
|
132
|
+
* on-demand backfill triggered by `message.requestHistorySync`) are
|
|
133
|
+
* downloaded and emitted as `history_sync_chunk` events. Set
|
|
134
|
+
* `enabled: false` to drop them; `requireFullSync: true` asks the
|
|
135
|
+
* primary device for a full history download instead of just recent.
|
|
136
|
+
*/
|
|
48
137
|
readonly history?: WaHistorySyncOptions;
|
|
138
|
+
/**
|
|
139
|
+
* Chat-event emission tuning. `emitSnapshotMutations: true` re-emits
|
|
140
|
+
* `app_state_mutation` events for every mutation seen during a snapshot
|
|
141
|
+
* sync (off by default – those mutations represent historical state).
|
|
142
|
+
*/
|
|
49
143
|
readonly chatEvents?: {
|
|
50
144
|
readonly emitSnapshotMutations?: boolean;
|
|
51
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* Privacy-token (trusted-contact-token) cache tuning. Controls how often
|
|
148
|
+
* tokens are re-issued and which JIDs they're scoped to.
|
|
149
|
+
*/
|
|
52
150
|
readonly privacyToken?: WaPrivacyTokenOptions;
|
|
151
|
+
/**
|
|
152
|
+
* Addon behavior. Encrypted addons (poll votes, reactions, ...) are
|
|
153
|
+
* decrypted automatically and emitted as typed `message_addon` events
|
|
154
|
+
* by default; set `autoDecrypt: false` to receive them encrypted and
|
|
155
|
+
* decrypt yourself via `client.message.tryDecryptAddon(event)`.
|
|
156
|
+
*/
|
|
53
157
|
readonly addons?: WaAddonOptions;
|
|
158
|
+
/**
|
|
159
|
+
* Per-domain control of what {@link WaClient.logout} clears from the
|
|
160
|
+
* store. By default the mailbox archive (`messages`, `threads`,
|
|
161
|
+
* `contacts`) is **preserved** and every other domain is cleared. See
|
|
162
|
+
* {@link WaLogoutStoreClearOptions} for the per-domain defaults.
|
|
163
|
+
*/
|
|
54
164
|
readonly logoutStoreClear?: WaLogoutStoreClearOptions;
|
|
165
|
+
/**
|
|
166
|
+
* Media handling tuning – optional {@link WaMediaProcessor} for
|
|
167
|
+
* thumbnail/voice-note/sticker normalization plus generation flags.
|
|
168
|
+
*/
|
|
55
169
|
readonly media?: WaMediaOptions;
|
|
170
|
+
/**
|
|
171
|
+
* Link-preview fetcher configuration – provide a custom fetcher (e.g.
|
|
172
|
+
* one that runs through your own scraping pipeline) or disable the
|
|
173
|
+
* default auto-fetch globally.
|
|
174
|
+
*/
|
|
175
|
+
readonly linkPreview?: WaLinkPreviewOptions;
|
|
56
176
|
/**
|
|
57
177
|
* Test-only overrides intended for running against a fake server.
|
|
58
178
|
*
|
|
59
|
-
* These hooks **do not** bypass any security checks
|
|
179
|
+
* These hooks **do not** bypass any security checks – they only swap in
|
|
60
180
|
* test fixtures (e.g. a different root CA) so the full verification code
|
|
61
181
|
* path still runs end-to-end. If you actually need to skip a check, use
|
|
62
182
|
* `dangerous` instead.
|
|
@@ -95,15 +215,9 @@ export interface WaClientTestHooks {
|
|
|
95
215
|
* The default is the production WhatsApp root. Tests against a fake
|
|
96
216
|
* server inject the fake server's ephemeral root here so that the lib
|
|
97
217
|
* still runs the full certificate-verification code path against a
|
|
98
|
-
* chain signed by a known key
|
|
218
|
+
* chain signed by a known key – no validation logic is bypassed.
|
|
99
219
|
*/
|
|
100
|
-
readonly noiseRootCa?:
|
|
101
|
-
}
|
|
102
|
-
export interface WaNoiseRootCaOverride {
|
|
103
|
-
/** Serialized X25519 public key (32 bytes raw, no version prefix). */
|
|
104
|
-
readonly publicKey: Uint8Array;
|
|
105
|
-
/** Serial number that intermediate certificates issued by this root must declare. */
|
|
106
|
-
readonly serial: number;
|
|
220
|
+
readonly noiseRootCa?: WaNoiseRootCa;
|
|
107
221
|
}
|
|
108
222
|
export interface WaMediaOptions {
|
|
109
223
|
readonly processor?: WaMediaProcessor;
|
|
@@ -111,8 +225,21 @@ export interface WaMediaOptions {
|
|
|
111
225
|
readonly generateProbe?: boolean;
|
|
112
226
|
readonly generateWaveform?: boolean;
|
|
113
227
|
readonly generateStickerThumbnail?: boolean;
|
|
228
|
+
readonly normalizeVoiceNote?: boolean;
|
|
114
229
|
}
|
|
115
230
|
export interface WaAddonOptions {
|
|
231
|
+
/**
|
|
232
|
+
* Decrypt incoming addon ciphertexts (poll votes, reactions, message
|
|
233
|
+
* edits, ...) and emit them as typed `message_addon` events. On by
|
|
234
|
+
* default - set to `false` to receive the encrypted payload and
|
|
235
|
+
* decrypt yourself via `client.message.tryDecryptAddon(event)`. The
|
|
236
|
+
* parent message secret is looked up in the `messageSecret` cache
|
|
237
|
+
* first, then in the `messages` store; setting both to `'none'`
|
|
238
|
+
* defeats addon decryption. Failures are logged at `warn` for
|
|
239
|
+
* `secretEncryptedMessage` addons (whose parent can be any message
|
|
240
|
+
* type) and at `debug` for the dedicated addon types (reactions,
|
|
241
|
+
* poll votes, event responses, comments).
|
|
242
|
+
*/
|
|
116
243
|
readonly autoDecrypt?: boolean;
|
|
117
244
|
}
|
|
118
245
|
export interface WaPrivacyTokenOptions {
|
|
@@ -128,6 +255,14 @@ export interface WaWriteBehindOptions {
|
|
|
128
255
|
readonly flushTimeoutMs?: number;
|
|
129
256
|
}
|
|
130
257
|
export interface WaHistorySyncOptions {
|
|
258
|
+
/**
|
|
259
|
+
* Whether to process the `historySyncNotification` protocol messages
|
|
260
|
+
* that WhatsApp pushes on first connect (initial bootstrap) and via
|
|
261
|
+
* `message.requestHistorySync` (on-demand). On by default - set to
|
|
262
|
+
* `false` to drop the chunks silently (useful when you do not persist
|
|
263
|
+
* mailbox/threads/contacts and the conversation download would just
|
|
264
|
+
* burn bandwidth).
|
|
265
|
+
*/
|
|
131
266
|
readonly enabled?: boolean;
|
|
132
267
|
readonly requireFullSync?: boolean;
|
|
133
268
|
}
|
|
@@ -141,11 +276,87 @@ export interface WaSignalMessagePublishInput {
|
|
|
141
276
|
readonly pushPriority?: string;
|
|
142
277
|
readonly participant?: string;
|
|
143
278
|
readonly deviceFanout?: string;
|
|
279
|
+
readonly metaNode?: BinaryNode;
|
|
144
280
|
}
|
|
145
281
|
export interface WaSendMessageOptions extends WaMessagePublishOptions {
|
|
282
|
+
/**
|
|
283
|
+
* Override the auto-generated stanza id. Useful for retries with idempotent
|
|
284
|
+
* ids or for clients that want to track messages by a known external id.
|
|
285
|
+
*/
|
|
146
286
|
readonly id?: string;
|
|
287
|
+
/**
|
|
288
|
+
* Identity key (33-byte serialized) the recipient is expected to be using.
|
|
289
|
+
* Throws `identity mismatch` if the cached remote identity differs -
|
|
290
|
+
* forces an explicit recovery instead of silently sending to a new device.
|
|
291
|
+
*/
|
|
147
292
|
readonly expectedIdentity?: Uint8Array;
|
|
148
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Optional context info to merge into the outgoing message – quoted message,
|
|
295
|
+
* mentioned JIDs, forward score, link-preview override, etc. (see {@link WaSendContextInfo}).
|
|
296
|
+
*/
|
|
297
|
+
readonly contextInfo?: WaSendContextInfo;
|
|
298
|
+
/**
|
|
299
|
+
* Shorthand for replying to a message: pass the incoming event (or a
|
|
300
|
+
* pre-built `WaQuoteRef`) and the coordinator fills the quote fields in
|
|
301
|
+
* `contextInfo` for you.
|
|
302
|
+
*/
|
|
303
|
+
readonly quote?: WaIncomingMessageEvent | WaQuoteRef | WaMessageKey;
|
|
304
|
+
/**
|
|
305
|
+
* Mark as forwarded. `true` increments the forward score; `{ score }`
|
|
306
|
+
* sets it explicitly (use the score from the source message's contextInfo
|
|
307
|
+
* to propagate the "frequently forwarded" badge correctly).
|
|
308
|
+
*/
|
|
309
|
+
readonly forward?: boolean | {
|
|
310
|
+
readonly score?: number;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* JIDs to mention (`@`-tag) in the message. Each must appear as `@<digits>`
|
|
314
|
+
* in the text for WhatsApp to render the mention link.
|
|
315
|
+
*/
|
|
316
|
+
readonly mentions?: readonly string[];
|
|
317
|
+
/**
|
|
318
|
+
* Disappearing-message expiration in seconds for this message. When set (any
|
|
319
|
+
* value, including `0`), this is the winner: it overrides both
|
|
320
|
+
* `contextInfo.expirationSeconds` and the automatic group-ephemeral inject
|
|
321
|
+
* (the latter is short-circuited because the value is now defined). To send a
|
|
322
|
+
* single message with NO expiration into a group with disappearing-mode on,
|
|
323
|
+
* prefer `disableGroupEphemeralAutoInject: true` over `expirationSeconds: 0` —
|
|
324
|
+
* the latter still writes `expiration=0` into the outgoing `contextInfo`.
|
|
325
|
+
*/
|
|
326
|
+
readonly expirationSeconds?: number;
|
|
327
|
+
/**
|
|
328
|
+
* Skip the automatic `ephemeralSettingTimestamp`/`expiration` injection
|
|
329
|
+
* applied to messages sent into groups with disappearing-mode on (the cached
|
|
330
|
+
* group ephemeral is otherwise fetched and applied for you). Off by default.
|
|
331
|
+
*
|
|
332
|
+
* Relationship with {@link expirationSeconds}: a non-undefined
|
|
333
|
+
* `expirationSeconds` already short-circuits the auto-inject, so this flag is
|
|
334
|
+
* redundant in that case. Use this flag when you want to suppress the
|
|
335
|
+
* auto-inject AND not set any expiration yourself.
|
|
336
|
+
*/
|
|
337
|
+
readonly disableGroupEphemeralAutoInject?: boolean;
|
|
338
|
+
/** Raw child nodes appended to the `<message>` stanza. Escape hatch for protocol features the typed API doesn't cover. */
|
|
339
|
+
readonly customNodes?: readonly BinaryNode[];
|
|
340
|
+
/** Wrap the outgoing message as view-once. Only valid for image/video/audio content. */
|
|
341
|
+
readonly viewOnce?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Edit a previously-sent message: the `content` argument becomes the new payload
|
|
344
|
+
* and gets wrapped in a `MESSAGE_EDIT` protocolMessage targeting the message id.
|
|
345
|
+
* Pass a received `message` event verbatim, its `key`, or an explicit
|
|
346
|
+
* {@link WaSendEditKey} (`fromMe` is forced true, `remoteJid` is the recipient).
|
|
347
|
+
*/
|
|
348
|
+
readonly editKey?: WaMessageKey | WaSendEditKey | WaMessageRef;
|
|
349
|
+
/**
|
|
350
|
+
* Override the auto-generated `messageContextInfo.messageSecret` (32 bytes).
|
|
351
|
+
* Use to share a known secret across follow-up addons or for deterministic tests.
|
|
352
|
+
*/
|
|
353
|
+
readonly messageSecret?: Uint8Array;
|
|
354
|
+
/**
|
|
355
|
+
* Extra attributes merged into the outgoing `<message>` stanza. Keys provided
|
|
356
|
+
* here override protocol-managed ones (`to`, `type`, `id`, `edit`, `phash`,
|
|
357
|
+
* `addressing_mode`) – use with care: bad overrides can break the send.
|
|
358
|
+
*/
|
|
359
|
+
readonly additionalAttributes?: Readonly<Record<string, string>>;
|
|
149
360
|
}
|
|
150
361
|
export interface WaClearChatOptions {
|
|
151
362
|
readonly deleteStarred?: boolean;
|
|
@@ -154,6 +365,11 @@ export interface WaClearChatOptions {
|
|
|
154
365
|
export interface WaDeleteChatOptions {
|
|
155
366
|
readonly deleteMedia?: boolean;
|
|
156
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Subset of `proto.IMessageKey` used in app-state events. Field names differ:
|
|
370
|
+
* `chatJid` aliases `remoteJid`, `participantJid` aliases `participant`. Kept
|
|
371
|
+
* separate from the proto type because callers want non-optional `id`/`fromMe`.
|
|
372
|
+
*/
|
|
157
373
|
export interface WaAppStateMessageKey {
|
|
158
374
|
readonly chatJid: string;
|
|
159
375
|
readonly id: string;
|
|
@@ -164,6 +380,11 @@ export interface WaDeleteMessageForMeOptions {
|
|
|
164
380
|
readonly deleteMedia?: boolean;
|
|
165
381
|
readonly messageTimestampMs?: number;
|
|
166
382
|
}
|
|
383
|
+
export interface WaDownloadMediaOptions {
|
|
384
|
+
readonly maxBytes?: number;
|
|
385
|
+
readonly timeoutMs?: number;
|
|
386
|
+
readonly signal?: AbortSignal;
|
|
387
|
+
}
|
|
167
388
|
export type WaIncomingNodeHandler = (node: BinaryNode) => Promise<boolean>;
|
|
168
389
|
export interface WaIncomingNodeHandlerRegistration {
|
|
169
390
|
readonly tag: string;
|
|
@@ -171,83 +392,390 @@ export interface WaIncomingNodeHandlerRegistration {
|
|
|
171
392
|
readonly handler: WaIncomingNodeHandler;
|
|
172
393
|
readonly prepend?: boolean;
|
|
173
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Predicate evaluated against every inbound stanza. Return `true` to drop the
|
|
397
|
+
* stanza before any handler runs – the coordinator still sends the appropriate
|
|
398
|
+
* ack for `message`/`receipt`/`notification` so the server stops re-delivering.
|
|
399
|
+
*
|
|
400
|
+
* Stream-control nodes and the connection-critical `success`/`failure` tags
|
|
401
|
+
* bypass filters to keep the auth flow intact.
|
|
402
|
+
*/
|
|
403
|
+
export type WaIncomingStanzaFilter = (node: BinaryNode) => boolean | Promise<boolean>;
|
|
404
|
+
/** Stanza tags addressable through {@link WaIgnoreKey}. */
|
|
405
|
+
export type WaIgnoreStanzaKind = 'message' | 'receipt' | 'notification' | 'presence' | 'chatstate' | 'call';
|
|
406
|
+
/**
|
|
407
|
+
* Match descriptor for {@link WaClient.ignoreKey}. Fields AND; `remoteJid`
|
|
408
|
+
* array ORs. `remoteJid` and `participant` also match the `sender_pn` /
|
|
409
|
+
* `sender_lid` / `participant_pn` / `participant_lid` alt attrs on `<message>`
|
|
410
|
+
* (and `sender_lid` on `<call>`), so one JID form catches the other for those
|
|
411
|
+
* tags. At least one of `remoteJid` / `fromMe` / `id` / `participant` required.
|
|
412
|
+
*/
|
|
413
|
+
export interface WaIgnoreKey {
|
|
414
|
+
readonly remoteJid?: string | readonly string[];
|
|
415
|
+
readonly fromMe?: boolean;
|
|
416
|
+
readonly id?: string;
|
|
417
|
+
readonly participant?: string;
|
|
418
|
+
/** Restrict to specific kinds. Default: all six. */
|
|
419
|
+
readonly only?: readonly WaIgnoreStanzaKind[];
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Parsed view of an inbound stanza passed to {@link WaIgnoreKeyPredicate}.
|
|
423
|
+
* Lib derives `kind` from the stanza tag and resolves `fromMe` by comparing
|
|
424
|
+
* every from-candidate (`from`, `sender_pn`, `sender_lid`) against `meJid`.
|
|
425
|
+
*
|
|
426
|
+
* `remoteJid` and `participant` expose the **raw** `from` / `participant`
|
|
427
|
+
* attrs verbatim and do NOT include the descriptor-style alt-attr lookups
|
|
428
|
+
* (`sender_pn` / `sender_lid` / `participant_pn` / `participant_lid`) or
|
|
429
|
+
* PN↔LID normalization. If the predicate needs to match by user identity
|
|
430
|
+
* regardless of addressing mode, run the raw JID through `parseJidFull` and
|
|
431
|
+
* compare on `userJid`, or use the descriptor form which handles it.
|
|
432
|
+
*/
|
|
433
|
+
export interface WaIgnoreKeyContext {
|
|
434
|
+
readonly kind: WaIgnoreStanzaKind;
|
|
435
|
+
/** Raw `from` attr (group JID for groups, PN or LID device JID for 1:1). */
|
|
436
|
+
readonly remoteJid: string | null;
|
|
437
|
+
readonly fromMe: boolean;
|
|
438
|
+
readonly id: string | undefined;
|
|
439
|
+
/** Raw `participant` attr; `null` for non-group stanzas. */
|
|
440
|
+
readonly participant: string | null;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Predicate form of {@link WaClient.ignoreKey}. Return `true` to drop the
|
|
444
|
+
* stanza, `false` to let it through. Receives a {@link WaIgnoreKeyContext}
|
|
445
|
+
* with the raw `from`/`participant` attrs (see the context's JSDoc for the
|
|
446
|
+
* PN↔LID caveat) plus lib-resolved `kind` and `fromMe`.
|
|
447
|
+
*/
|
|
448
|
+
export type WaIgnoreKeyPredicate = (ctx: WaIgnoreKeyContext) => boolean;
|
|
174
449
|
export interface WaIncomingBaseEvent {
|
|
450
|
+
/** The raw decoded stanza, kept for forward-compat parsing of fields the typed event does not expose. */
|
|
175
451
|
readonly rawNode: BinaryNode;
|
|
176
452
|
readonly stanzaId?: string;
|
|
453
|
+
/** Resolved from the stanza's `from` attr. */
|
|
177
454
|
readonly chatJid?: string;
|
|
455
|
+
/** Inner-payload discriminator (notification subtype, message kind, ...). */
|
|
178
456
|
readonly stanzaType?: string;
|
|
457
|
+
/** `true` when the stanza arrived as part of an offline catch-up batch rather than live. */
|
|
458
|
+
readonly offline?: boolean;
|
|
179
459
|
}
|
|
180
|
-
|
|
460
|
+
/**
|
|
461
|
+
* A received message's key. Extends the proto {@link WaMessageKey}
|
|
462
|
+
* (`remoteJid`/`id`/`fromMe`/`participant`) with the message's addressing and
|
|
463
|
+
* sender metadata. It stays assignable to `Proto.IMessageKey` (the extra fields
|
|
464
|
+
* are ignored there) and can be passed verbatim to reply / edit / react /
|
|
465
|
+
* revoke / pin / quote.
|
|
466
|
+
*/
|
|
467
|
+
export interface WaIncomingMessageKey extends WaMessageKey {
|
|
468
|
+
readonly isGroup: boolean;
|
|
469
|
+
readonly isBroadcast: boolean;
|
|
470
|
+
readonly isNewsletter: boolean;
|
|
471
|
+
/** The `remoteJid`'s alternate addressing — the pn when addressed by lid, or vice-versa (1:1 chats). */
|
|
472
|
+
readonly remoteJidAlt?: string;
|
|
473
|
+
/** The `participant`'s alternate addressing — the pn when addressed by lid, or vice-versa (group chats). */
|
|
474
|
+
readonly participantAlt?: string;
|
|
475
|
+
/** Sender's device id — `0` when the source JID has no `:device` segment. */
|
|
476
|
+
readonly senderDevice: number;
|
|
477
|
+
readonly senderUsername?: string;
|
|
478
|
+
readonly recipientJid?: string;
|
|
479
|
+
readonly recipientAlt?: string;
|
|
480
|
+
/** Server-assigned message id (newsletters / channel messages). */
|
|
481
|
+
readonly serverId?: number;
|
|
482
|
+
}
|
|
483
|
+
export interface WaIncomingMessageEvent extends Omit<WaIncomingBaseEvent, 'chatJid' | 'stanzaId'> {
|
|
484
|
+
/**
|
|
485
|
+
* The message key: the proto fields (`remoteJid` = chat, `id` = stanza id,
|
|
486
|
+
* `fromMe`, `participant` = author) plus chat/sender addressing metadata
|
|
487
|
+
* (`isGroup`, `participantAlt`, ...). Pass it (or the whole event) verbatim to
|
|
488
|
+
* reply / edit / react / revoke / pin / quote. `remoteJid`/`id` supersede the
|
|
489
|
+
* old top-level `chatJid`/`stanzaId`.
|
|
490
|
+
*/
|
|
491
|
+
readonly key: WaIncomingMessageKey;
|
|
492
|
+
/** Stanza `t` attr (seconds since epoch). */
|
|
181
493
|
readonly timestampSeconds?: number;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Disappearing-message TTL the sender attached to this message, in seconds.
|
|
496
|
+
* Read from the first submessage carrying `contextInfo.expiration`
|
|
497
|
+
* (`extendedTextMessage`, `imageMessage`, …). Undefined when the message is
|
|
498
|
+
* not ephemeral.
|
|
499
|
+
*/
|
|
500
|
+
readonly expirationSeconds?: number;
|
|
501
|
+
/** Sender's display name from the stanza's `notify` attr. */
|
|
502
|
+
readonly pushName?: string;
|
|
187
503
|
readonly message?: Proto.IMessage;
|
|
188
504
|
}
|
|
189
505
|
export interface WaIncomingProtocolMessageEvent extends WaIncomingMessageEvent {
|
|
190
506
|
readonly protocolMessage: Proto.Message.IProtocolMessage;
|
|
191
507
|
}
|
|
508
|
+
export type WaReceiptStatus = 'delivered' | 'read' | 'played' | 'inactive';
|
|
192
509
|
export interface WaIncomingReceiptEvent extends WaIncomingBaseEvent {
|
|
510
|
+
readonly status: WaReceiptStatus;
|
|
511
|
+
/** True when the receipt came from another device of the current user (multi-device sync). */
|
|
512
|
+
readonly fromSelfDevice: boolean;
|
|
193
513
|
readonly participantJid?: string;
|
|
194
514
|
readonly recipientJid?: string;
|
|
195
515
|
}
|
|
196
516
|
export interface WaIncomingPresenceEvent extends WaIncomingBaseEvent {
|
|
517
|
+
readonly type: IncomingPresenceType;
|
|
518
|
+
/** Only populated for 1:1 chats when `type === 'unavailable'` and the peer ships a `last` attr. */
|
|
519
|
+
readonly lastSeen?: PresenceLastSeen;
|
|
520
|
+
/** Only populated for group JIDs. Falls back to `0` when the server marks the group `unavailable`. */
|
|
521
|
+
readonly groupOnlineCount?: number;
|
|
197
522
|
}
|
|
198
523
|
export interface WaIncomingChatstateEvent extends WaIncomingBaseEvent {
|
|
524
|
+
readonly state: ChatstateState;
|
|
525
|
+
readonly media?: ChatstateMedia;
|
|
199
526
|
readonly participantJid?: string;
|
|
200
527
|
}
|
|
201
528
|
export interface WaIncomingCallEvent extends WaIncomingBaseEvent {
|
|
529
|
+
/** Discriminator from the inner child tag (e.g. `offer`, `accept`, `terminate`). `unknown` when the child tag is missing or not recognized. */
|
|
530
|
+
readonly type: WaCallType;
|
|
531
|
+
/** Original inner child tag, useful when `type === 'unknown'`. */
|
|
532
|
+
readonly payloadTag?: string;
|
|
533
|
+
/** WhatsApp call identifier (from inner child `call-id`). */
|
|
534
|
+
readonly callId?: string;
|
|
535
|
+
/** JID of the device that initiated the call. */
|
|
536
|
+
readonly callCreatorJid?: string;
|
|
537
|
+
/** `sender_lid` attr from the outer `<call>` stanza – distinct from `callCreatorJid` which lives on the inner payload. */
|
|
538
|
+
readonly senderLidJid?: string;
|
|
539
|
+
/** Phone-number JID of the caller, when present. */
|
|
540
|
+
readonly callerPnJid?: string;
|
|
541
|
+
/** Group JID for group calls. */
|
|
542
|
+
readonly groupJid?: string;
|
|
543
|
+
/** True when the call payload has a `<video/>` marker. */
|
|
544
|
+
readonly isVideo: boolean;
|
|
545
|
+
readonly callerUsername?: string;
|
|
546
|
+
readonly callerCountryCode?: string;
|
|
547
|
+
readonly callerPushName?: string;
|
|
548
|
+
/** Peer platform string from the outer call stanza. */
|
|
549
|
+
readonly peerPlatform?: string;
|
|
550
|
+
/** Peer app version string from the outer call stanza. */
|
|
551
|
+
readonly peerAppVersion?: string;
|
|
552
|
+
/** Stanza timestamp (`t` attr, seconds since epoch). */
|
|
553
|
+
readonly timestampSeconds?: number;
|
|
554
|
+
/** Stanza end-of-validity timestamp (`e` attr, seconds since epoch). */
|
|
555
|
+
readonly endTimestampSeconds?: number;
|
|
556
|
+
/** Optional silence reason (e.g. `vc_wave_all`). */
|
|
557
|
+
readonly silenceReason?: string;
|
|
558
|
+
/** Group participant snapshot, when the stanza includes `<group_info>`. */
|
|
559
|
+
readonly groupInfo?: readonly WaCallGroupParticipant[];
|
|
202
560
|
}
|
|
203
561
|
export interface WaIncomingNotificationEvent extends WaIncomingBaseEvent {
|
|
204
562
|
readonly notificationType?: string;
|
|
563
|
+
/**
|
|
564
|
+
* Routing bucket the lib chose: `'core'` (a typed handler exists – this debug event
|
|
565
|
+
* mirrors it), `'out_of_scope'` (recognized server type intentionally not modeled),
|
|
566
|
+
* `'unknown'` (server type the lib has not seen), or `'info_bulletin'` (the dedicated
|
|
567
|
+
* `info_bulletin` notification type).
|
|
568
|
+
*/
|
|
205
569
|
readonly classification?: 'core' | 'out_of_scope' | 'unknown' | 'info_bulletin';
|
|
570
|
+
/** Decoded payload bag for notifications without a dedicated typed event. */
|
|
206
571
|
readonly details?: Readonly<Record<string, unknown>>;
|
|
207
572
|
}
|
|
573
|
+
export interface WaMexNotificationGraphQlError {
|
|
574
|
+
readonly message?: string;
|
|
575
|
+
readonly path?: readonly string[];
|
|
576
|
+
readonly extensions?: {
|
|
577
|
+
readonly error_code?: number;
|
|
578
|
+
readonly severity?: string;
|
|
579
|
+
readonly is_summary?: boolean;
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
export type WaMexNotificationOperationName = 'UsernameSetNotification' | 'UsernameDeleteNotification' | 'UsernameUpdateNotification' | 'AccountSyncUsernameNotification' | 'TextStatusUpdateNotification' | 'TextStatusUpdateNotificationSideSub' | 'LidChangeNotification' | 'MessageCappingInfoNotification' | 'NotificationCommunityOwnerUpdate' | 'NotificationUserBrigadingUpdate' | 'NotificationUserReachoutTimelockUpdate' | 'NotificationIntegrityChallengeRequest' | 'NotificationScheduledMessagePost' | 'NotificationScheduledMessageReveal' | 'NotificationGroupPropertyUpdate' | 'NotificationGroupHiddenPropertyUpdate' | 'NotificationGroupSafetyCheckPropertyUpdate' | 'NotificationGroupMemberLinkPropertyUpdate' | 'NotificationGroupMemberShareGroupHistoryModePropertyUpdate' | 'NotificationGroupAppealStatusUpdate' | 'NotificationGroupLimitSharingPropertyUpdate' | 'NotificationNewsletterUserSettingChange' | 'NotificationNewsletterJoin' | 'NotificationNewsletterLeave' | 'NotificationNewsletterStateChange' | 'NotificationNewsletterAdminProfileUpdate' | 'NotificationNewsletterAdminMetadataUpdate' | 'NotificationNewsletterOwnerUpdate' | 'NotificationNewsletterUpdate' | 'NotificationNewsletterAdminPromote' | 'NotificationNewsletterAdminDemote' | 'NotificationNewsletterAdminInviteRevoke' | 'NotificationNewsletterWamoSubStatusChange' | 'NewsletterResponseStateUpdate' | 'NotificationNewsletterBlockUser' | 'NotificationNewsletterPaidPartnershipUpdate' | 'NotificationNewsletterMilestone' | 'MexNotificationEvent' | (string & {});
|
|
583
|
+
interface WaMexNotificationBaseFields extends WaIncomingBaseEvent {
|
|
584
|
+
readonly operationName: WaMexNotificationOperationName;
|
|
585
|
+
readonly errors: readonly WaMexNotificationGraphQlError[];
|
|
586
|
+
}
|
|
587
|
+
export interface WaMexUsernameSetEvent extends WaMexNotificationBaseFields {
|
|
588
|
+
readonly kind: 'username_set';
|
|
589
|
+
readonly operationName: 'UsernameSetNotification';
|
|
590
|
+
readonly lidJid: string;
|
|
591
|
+
readonly username: string;
|
|
592
|
+
}
|
|
593
|
+
export interface WaMexUsernameDeleteEvent extends WaMexNotificationBaseFields {
|
|
594
|
+
readonly kind: 'username_delete';
|
|
595
|
+
readonly operationName: 'UsernameDeleteNotification';
|
|
596
|
+
readonly lidJid: string;
|
|
597
|
+
/** `null` when the server omits the fallback display name (treat as cleared). */
|
|
598
|
+
readonly displayName: string | null;
|
|
599
|
+
}
|
|
600
|
+
export interface WaMexUsernameUpdateHintEvent extends WaMexNotificationBaseFields {
|
|
601
|
+
readonly kind: 'username_update_hint';
|
|
602
|
+
readonly operationName: 'UsernameUpdateNotification';
|
|
603
|
+
readonly contactHash: string;
|
|
604
|
+
}
|
|
605
|
+
export interface WaMexOwnUsernameSyncEvent extends WaMexNotificationBaseFields {
|
|
606
|
+
readonly kind: 'own_username_sync';
|
|
607
|
+
readonly operationName: 'AccountSyncUsernameNotification';
|
|
608
|
+
readonly ownLidJid: string;
|
|
609
|
+
/** `null` means the username was removed. */
|
|
610
|
+
readonly username: string | null;
|
|
611
|
+
readonly state: string | null;
|
|
612
|
+
readonly pin: string | null;
|
|
613
|
+
}
|
|
614
|
+
export interface WaMexTextStatusUpdateEvent extends WaMexNotificationBaseFields {
|
|
615
|
+
readonly kind: 'text_status_update';
|
|
616
|
+
readonly operationName: 'TextStatusUpdateNotification';
|
|
617
|
+
readonly jid: string;
|
|
618
|
+
/** `null` clears the status. */
|
|
619
|
+
readonly text: string | null;
|
|
620
|
+
/** `null` clears the emoji. */
|
|
621
|
+
readonly emoji: string | null;
|
|
622
|
+
readonly ephemeralDurationSec: number | null;
|
|
623
|
+
readonly lastUpdateTime: number | null;
|
|
624
|
+
}
|
|
625
|
+
export interface WaMexTextStatusUpdateHintEvent extends WaMexNotificationBaseFields {
|
|
626
|
+
readonly kind: 'text_status_update_hint';
|
|
627
|
+
readonly operationName: 'TextStatusUpdateNotificationSideSub';
|
|
628
|
+
readonly contactHash: string;
|
|
629
|
+
}
|
|
630
|
+
export interface WaMexLidChangeEvent extends WaMexNotificationBaseFields {
|
|
631
|
+
readonly kind: 'lid_change';
|
|
632
|
+
readonly operationName: 'LidChangeNotification';
|
|
633
|
+
readonly oldLidJid: string;
|
|
634
|
+
readonly newLidJid: string;
|
|
635
|
+
}
|
|
636
|
+
export type WaMexMessageCappingStatus = 'NONE' | 'FIRST_WARNING' | 'SECOND_WARNING' | 'CAPPED' | (string & {});
|
|
637
|
+
export interface WaMexMessageCappingEvent extends WaMexNotificationBaseFields {
|
|
638
|
+
readonly kind: 'message_capping';
|
|
639
|
+
readonly operationName: 'MessageCappingInfoNotification';
|
|
640
|
+
readonly cappingStatus: WaMexMessageCappingStatus;
|
|
641
|
+
readonly oteStatus: string | null;
|
|
642
|
+
readonly mvStatus: string | null;
|
|
643
|
+
readonly totalQuota: number | null;
|
|
644
|
+
readonly usedQuota: number | null;
|
|
645
|
+
readonly cycleStartTimestamp: number | null;
|
|
646
|
+
readonly cycleEndTimestamp: number | null;
|
|
647
|
+
readonly serverSentTimestamp: number | null;
|
|
648
|
+
}
|
|
649
|
+
export interface WaMexNotificationUnknownEvent extends WaMexNotificationBaseFields {
|
|
650
|
+
/** Catch-all bucket for any `operationName` without a typed variant. */
|
|
651
|
+
readonly kind: 'unknown';
|
|
652
|
+
readonly data: unknown;
|
|
653
|
+
}
|
|
654
|
+
export type WaMexNotificationEvent = WaMexUsernameSetEvent | WaMexUsernameDeleteEvent | WaMexUsernameUpdateHintEvent | WaMexOwnUsernameSyncEvent | WaMexTextStatusUpdateEvent | WaMexTextStatusUpdateHintEvent | WaMexLidChangeEvent | WaMexMessageCappingEvent | WaMexNotificationUnknownEvent;
|
|
208
655
|
export interface WaRegistrationCodeEvent extends WaIncomingBaseEvent {
|
|
209
656
|
readonly code: string;
|
|
657
|
+
/** Expiry deadline (ms since epoch). */
|
|
210
658
|
readonly expiryTimestampMs: number;
|
|
211
659
|
readonly fromDeviceId: string;
|
|
212
660
|
}
|
|
213
661
|
export interface WaAccountTakeoverNoticeEvent extends WaIncomingBaseEvent {
|
|
662
|
+
/** Opaque token to feed back into the takeover-decision API. */
|
|
214
663
|
readonly serverToken: string;
|
|
664
|
+
/** Ms since epoch. */
|
|
215
665
|
readonly attemptTimestampMs: number;
|
|
216
666
|
readonly newDeviceName?: string;
|
|
217
667
|
readonly newDevicePlatform?: string;
|
|
218
668
|
readonly newDeviceAppVersion?: string;
|
|
219
669
|
}
|
|
220
|
-
export type WaAddonKind = 'reaction' | 'poll_vote' | 'event_response' | 'comment';
|
|
221
|
-
export interface WaIncomingAddonEvent extends WaIncomingBaseEvent {
|
|
670
|
+
export type WaAddonKind = 'reaction' | 'poll_vote' | 'event_response' | 'comment' | 'message_edit' | 'event_edit' | 'poll_edit' | 'poll_add_option';
|
|
671
|
+
export interface WaIncomingAddonEvent extends Omit<WaIncomingBaseEvent, 'chatJid' | 'stanzaId'> {
|
|
672
|
+
/**
|
|
673
|
+
* The addon message's key (proto fields + addressing metadata). The sender is
|
|
674
|
+
* `key.participant ?? key.remoteJid`. Supersedes the old `chatJid` / `stanzaId`
|
|
675
|
+
* / `senderJid`.
|
|
676
|
+
*/
|
|
677
|
+
readonly key: WaIncomingMessageKey;
|
|
222
678
|
readonly kind: WaAddonKind;
|
|
679
|
+
/** Stanza id of the parent message this addon attaches to. */
|
|
223
680
|
readonly targetMessageId: string;
|
|
224
|
-
|
|
681
|
+
/** Decoded addon payload (shape varies per `kind`). */
|
|
225
682
|
readonly decrypted: WaDecodedAddon;
|
|
683
|
+
/** Parent proto message the addon was extracted from. */
|
|
684
|
+
readonly raw: Proto.IMessage;
|
|
685
|
+
}
|
|
686
|
+
export interface WaIncomingBotChunkEvent extends Omit<WaIncomingBaseEvent, 'chatJid' | 'stanzaId'> {
|
|
687
|
+
/**
|
|
688
|
+
* The chunk message's key (proto fields + addressing metadata). The sender is
|
|
689
|
+
* `key.participant ?? key.remoteJid`. Supersedes the old `chatJid` / `stanzaId`
|
|
690
|
+
* / `senderJid`.
|
|
691
|
+
*/
|
|
692
|
+
readonly key: WaIncomingMessageKey;
|
|
693
|
+
/** Stanza id of the parent bot reply the chunks reassemble into. */
|
|
694
|
+
readonly targetMessageId: string;
|
|
695
|
+
readonly editType: WaBotMsgEditType;
|
|
696
|
+
readonly editTargetId?: string;
|
|
697
|
+
readonly saltId: string;
|
|
698
|
+
/** Decrypted bytes for this chunk – concat in arrival order until `editType` is `'full'` or `'last'`. */
|
|
699
|
+
readonly plaintext: Uint8Array;
|
|
700
|
+
readonly message: Proto.IMessage;
|
|
226
701
|
readonly raw: Proto.IMessage;
|
|
227
702
|
}
|
|
228
703
|
export interface WaIncomingFailureEvent extends WaIncomingBaseEvent {
|
|
704
|
+
/** Server-side reason number (`reason` attr). Drives the client's logout/disconnect behavior – specific values trigger credential wipe. */
|
|
229
705
|
readonly failureReason?: number;
|
|
230
706
|
readonly failureCode?: number;
|
|
231
707
|
readonly failureMessage?: string;
|
|
232
708
|
readonly failureUrl?: string;
|
|
233
709
|
}
|
|
234
710
|
export interface WaIncomingUnhandledStanzaEvent extends WaIncomingBaseEvent {
|
|
711
|
+
/** Short reason describing why the dispatcher did not match a typed handler. */
|
|
235
712
|
readonly reason: string;
|
|
236
713
|
}
|
|
714
|
+
export interface WaIncomingErrorStanzaEvent extends WaIncomingBaseEvent {
|
|
715
|
+
readonly code?: number;
|
|
716
|
+
readonly text?: string;
|
|
717
|
+
}
|
|
718
|
+
export interface WaNewsletterPollVoteEntry {
|
|
719
|
+
/** Hash to match against `pollCreation.options[].optionHash`. */
|
|
720
|
+
readonly optionHash: Uint8Array;
|
|
721
|
+
readonly count?: number;
|
|
722
|
+
}
|
|
723
|
+
export interface WaNewsletterReactionEntry {
|
|
724
|
+
readonly code?: string;
|
|
725
|
+
readonly count?: number;
|
|
726
|
+
}
|
|
727
|
+
export type WaNewsletterMessageUpdate = {
|
|
728
|
+
readonly kind: 'reaction';
|
|
729
|
+
readonly isSender: boolean;
|
|
730
|
+
readonly revoked: boolean;
|
|
731
|
+
readonly reactions: ReadonlyArray<WaNewsletterReactionEntry>;
|
|
732
|
+
} | {
|
|
733
|
+
readonly kind: 'revoke';
|
|
734
|
+
} | {
|
|
735
|
+
readonly kind: 'edit';
|
|
736
|
+
readonly plaintext: Uint8Array;
|
|
737
|
+
readonly message: Proto.IMessage;
|
|
738
|
+
} | {
|
|
739
|
+
readonly kind: 'poll_vote';
|
|
740
|
+
readonly isSender: boolean;
|
|
741
|
+
readonly votes: ReadonlyArray<WaNewsletterPollVoteEntry>;
|
|
742
|
+
} | {
|
|
743
|
+
readonly kind: 'counters';
|
|
744
|
+
readonly views?: number;
|
|
745
|
+
readonly forwards?: number;
|
|
746
|
+
readonly responses?: number;
|
|
747
|
+
};
|
|
748
|
+
export interface WaIncomingNewsletterMessageUpdateEvent extends WaIncomingBaseEvent {
|
|
749
|
+
readonly timestampSeconds?: number;
|
|
750
|
+
readonly parentMessageServerId?: number;
|
|
751
|
+
readonly update: WaNewsletterMessageUpdate;
|
|
752
|
+
}
|
|
753
|
+
export type WaNewsletterEventAction = 'subscribers_count_change' | 'live_updates' | 'membership_revoke' | 'admin_metadata_update' | 'unknown';
|
|
754
|
+
export interface WaIncomingNewsletterEvent extends WaIncomingBaseEvent {
|
|
755
|
+
readonly newsletterJid: string;
|
|
756
|
+
readonly action: WaNewsletterEventAction;
|
|
757
|
+
readonly subType?: string;
|
|
758
|
+
/** Decoded payload bag for actions without dedicated fields. */
|
|
759
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
760
|
+
}
|
|
237
761
|
export type WaGroupEventAction = 'create' | 'add' | 'delete' | 'remove' | 'promote' | 'demote' | 'linked_group_promote' | 'linked_group_demote' | 'modify' | 'subject' | 'description' | 'restrict' | 'announce' | 'no_frequently_forwarded' | 'invite' | 'ephemeral' | 'revoke_invite' | 'suspend' | 'growth_locked' | 'growth_unlocked' | 'link' | 'unlink' | 'membership_approval_mode' | 'membership_approval_request' | 'created_membership_requests' | 'revoked_membership_requests' | 'allow_non_admin_sub_group_creation' | 'allow_admin_reports' | 'admin_reports' | 'created_sub_group_suggestion' | 'revoked_sub_group_suggestions' | 'change_number' | 'member_add_mode' | 'auto_add_disabled' | 'is_capi_hosted_group' | 'group_safety_check' | 'limit_sharing_enabled' | 'missing_participant_identification';
|
|
238
762
|
export interface WaGroupEventParticipant {
|
|
763
|
+
/** Primary participant addressing as carried in the stanza – LID or PN. */
|
|
239
764
|
readonly jid?: string;
|
|
765
|
+
/** Role label from the participant's `type` attr (`'admin'`, `'superadmin'`, or absent for plain members). */
|
|
240
766
|
readonly role?: string;
|
|
241
767
|
readonly lidJid?: string;
|
|
242
768
|
readonly phoneJid?: string;
|
|
243
769
|
readonly displayName?: string;
|
|
244
770
|
readonly username?: string;
|
|
771
|
+
/** Ephemeral TTL the participant joined under, in seconds (set on `add`). */
|
|
245
772
|
readonly expirationSeconds?: number;
|
|
246
773
|
}
|
|
247
774
|
export interface WaGroupEventLinkedGroup {
|
|
248
775
|
readonly jid?: string;
|
|
249
776
|
readonly subject?: string;
|
|
250
777
|
readonly subjectTimestampSeconds?: number;
|
|
778
|
+
/** `true` when the linked subgroup stanza carries a `<hidden_group/>` marker. */
|
|
251
779
|
readonly hiddenSubgroup?: boolean;
|
|
252
780
|
}
|
|
253
781
|
export interface WaGroupEventMembershipRequest {
|
|
@@ -261,145 +789,389 @@ export interface WaGroupEventSubgroupSuggestion {
|
|
|
261
789
|
readonly subject?: string;
|
|
262
790
|
readonly description?: string;
|
|
263
791
|
readonly timestampSeconds?: number;
|
|
792
|
+
/** `true` when the suggestion points at an existing group; `false` when it would create one. */
|
|
264
793
|
readonly isExistingGroup?: boolean;
|
|
265
794
|
readonly participantCount?: number;
|
|
266
795
|
readonly reason?: string;
|
|
267
796
|
}
|
|
797
|
+
export type WaBusinessEventAction = 'verified_name_update' | 'verified_name_stale' | 'business_removed' | 'profile_update' | 'product_update' | 'collection_update' | 'subscriptions_update';
|
|
798
|
+
export interface WaBusinessCategory {
|
|
799
|
+
readonly id: string;
|
|
800
|
+
readonly name: string;
|
|
801
|
+
}
|
|
802
|
+
export interface WaBusinessHoursEntry {
|
|
803
|
+
readonly dayOfWeek: WaBusinessHoursDay;
|
|
804
|
+
readonly mode: WaBusinessHoursMode;
|
|
805
|
+
readonly openTime?: number;
|
|
806
|
+
readonly closeTime?: number;
|
|
807
|
+
}
|
|
808
|
+
export interface WaBusinessHours {
|
|
809
|
+
readonly timezone?: string;
|
|
810
|
+
readonly config: readonly WaBusinessHoursEntry[];
|
|
811
|
+
}
|
|
812
|
+
export interface WaBusinessWebsite {
|
|
813
|
+
readonly url: string;
|
|
814
|
+
}
|
|
815
|
+
export interface WaBusinessProfileResult {
|
|
816
|
+
readonly jid: string;
|
|
817
|
+
readonly tag?: string;
|
|
818
|
+
readonly description?: string;
|
|
819
|
+
readonly address?: string;
|
|
820
|
+
readonly email?: string;
|
|
821
|
+
readonly websites?: readonly WaBusinessWebsite[];
|
|
822
|
+
readonly categories?: readonly WaBusinessCategory[];
|
|
823
|
+
readonly businessHours?: WaBusinessHours;
|
|
824
|
+
readonly latitude?: number;
|
|
825
|
+
readonly longitude?: number;
|
|
826
|
+
readonly profileOptions?: Readonly<Record<string, string>>;
|
|
827
|
+
}
|
|
828
|
+
export interface WaVerifiedNamePrivacyMode {
|
|
829
|
+
readonly actualActors: number;
|
|
830
|
+
readonly hostStorage: number;
|
|
831
|
+
readonly privacyModeTs: number;
|
|
832
|
+
}
|
|
833
|
+
export interface WaVerifiedNameResult {
|
|
834
|
+
readonly name?: string;
|
|
835
|
+
readonly level?: string;
|
|
836
|
+
readonly serial?: string;
|
|
837
|
+
readonly isApi: boolean;
|
|
838
|
+
readonly isSmb: boolean;
|
|
839
|
+
readonly privacyMode?: WaVerifiedNamePrivacyMode;
|
|
840
|
+
}
|
|
841
|
+
export interface WaBusinessCollectionUpdate {
|
|
842
|
+
readonly id: string;
|
|
843
|
+
readonly reviewStatus?: string;
|
|
844
|
+
readonly rejectReason?: string;
|
|
845
|
+
readonly commerceUrl?: string;
|
|
846
|
+
}
|
|
847
|
+
export interface WaBusinessSubscription {
|
|
848
|
+
readonly id: string;
|
|
849
|
+
readonly status: string;
|
|
850
|
+
readonly tier?: number;
|
|
851
|
+
readonly source?: string;
|
|
852
|
+
readonly startTime?: number;
|
|
853
|
+
readonly creationTime?: number;
|
|
854
|
+
readonly expirationDate?: number;
|
|
855
|
+
}
|
|
856
|
+
export interface WaBusinessFeatureFlag {
|
|
857
|
+
readonly name: string;
|
|
858
|
+
readonly enabled: boolean;
|
|
859
|
+
readonly expirationTime?: number;
|
|
860
|
+
readonly limit?: number;
|
|
861
|
+
}
|
|
862
|
+
export interface WaBusinessEvent extends WaIncomingBaseEvent {
|
|
863
|
+
readonly action: WaBusinessEventAction;
|
|
864
|
+
readonly timestampSeconds?: number;
|
|
865
|
+
/** Set on `verified_name_update`, `business_removed` (when the stanza identifies the business by JID), and `profile_update` (falls back to the stanza's `from` attr). */
|
|
866
|
+
readonly bizJid?: string;
|
|
867
|
+
/** Certificate / payload hash on `verified_name_stale`, `business_removed` (when identified by hash), and `profile_update` (when the server signals just an unchanged hash). */
|
|
868
|
+
readonly bizHash?: string;
|
|
869
|
+
/** Set on `verified_name_update`. */
|
|
870
|
+
readonly verifiedName?: WaVerifiedNameResult;
|
|
871
|
+
/** Set on `product_update`. */
|
|
872
|
+
readonly productIds?: readonly string[];
|
|
873
|
+
/** Set on `collection_update`. */
|
|
874
|
+
readonly collections?: readonly WaBusinessCollectionUpdate[];
|
|
875
|
+
/** Set on `subscriptions_update`. Empty array when the stanza only carries feature flags. */
|
|
876
|
+
readonly subscriptions?: readonly WaBusinessSubscription[];
|
|
877
|
+
/** Set on `subscriptions_update`. Empty array when the stanza only carries subscriptions. */
|
|
878
|
+
readonly featureFlags?: readonly WaBusinessFeatureFlag[];
|
|
879
|
+
}
|
|
880
|
+
export type WaPictureEventAction = 'set' | 'delete' | 'request' | 'set_avatar';
|
|
881
|
+
export interface WaPictureEvent extends WaIncomingBaseEvent {
|
|
882
|
+
readonly action: WaPictureEventAction;
|
|
883
|
+
/** Entity whose picture changed (contact, group, community). */
|
|
884
|
+
readonly targetJid?: string;
|
|
885
|
+
/** Actor that performed the change, when distinct from `targetJid`. */
|
|
886
|
+
readonly authorJid?: string;
|
|
887
|
+
readonly timestampSeconds?: number;
|
|
888
|
+
/** Only populated on `action === 'set'`. Pass to the picture-fetch API to download the new bytes. */
|
|
889
|
+
readonly pictureId?: number;
|
|
890
|
+
readonly contactHash?: string;
|
|
891
|
+
}
|
|
268
892
|
export interface WaGroupEvent extends WaIncomingBaseEvent {
|
|
893
|
+
/** Inner action node, kept for forward-compat parsing of fields the typed event does not expose. */
|
|
269
894
|
readonly rawActionNode: BinaryNode;
|
|
895
|
+
/** Same value as `chatJid` – exposed under the group-specific name for clarity. */
|
|
270
896
|
readonly groupJid?: string;
|
|
897
|
+
/** Actor that triggered the action (`participant` attr on the notification). */
|
|
271
898
|
readonly authorJid?: string;
|
|
272
899
|
readonly timestampSeconds?: number;
|
|
273
900
|
readonly action: WaGroupEventAction;
|
|
901
|
+
/** Set on add / remove / promote / demote / invite. */
|
|
274
902
|
readonly participants?: readonly WaGroupEventParticipant[];
|
|
903
|
+
/** Set on `linked_group_*` / `link` / `unlink`. */
|
|
275
904
|
readonly linkedGroups?: readonly WaGroupEventLinkedGroup[];
|
|
905
|
+
/** Set on `created_membership_requests` / `revoked_membership_requests`. */
|
|
276
906
|
readonly membershipRequests?: readonly WaGroupEventMembershipRequest[];
|
|
907
|
+
/** Set on `created_sub_group_suggestion` / `revoked_sub_group_suggestions`. */
|
|
277
908
|
readonly subgroupSuggestions?: readonly WaGroupEventSubgroupSuggestion[];
|
|
278
909
|
readonly contextGroupJid?: string;
|
|
279
910
|
readonly requestMethod?: string;
|
|
911
|
+
/** Set on `subject`. */
|
|
280
912
|
readonly subject?: string;
|
|
281
913
|
readonly subjectOwnerJid?: string;
|
|
914
|
+
/** Set on `description`. */
|
|
282
915
|
readonly description?: string;
|
|
283
916
|
readonly descriptionId?: string;
|
|
917
|
+
/** Set on `invite` / `revoke_invite`. */
|
|
284
918
|
readonly code?: string;
|
|
919
|
+
/** Set on `ephemeral`. */
|
|
285
920
|
readonly expirationSeconds?: number;
|
|
286
921
|
readonly mode?: string;
|
|
287
922
|
readonly enabled?: boolean;
|
|
288
923
|
readonly reason?: string;
|
|
924
|
+
/** Decoded payload bag for actions without dedicated fields above. */
|
|
289
925
|
readonly details?: Readonly<Record<string, unknown>>;
|
|
290
926
|
}
|
|
291
927
|
export interface WaHistorySyncChunkEvent {
|
|
928
|
+
/** Numeric value of `proto.Message.HistorySyncType` (`RECENT`, `ON_DEMAND`, …). */
|
|
292
929
|
readonly syncType: number;
|
|
293
930
|
readonly messagesCount: number;
|
|
294
931
|
readonly conversationsCount: number;
|
|
295
932
|
readonly pushnamesCount: number;
|
|
933
|
+
readonly inlineContactsCount: number;
|
|
296
934
|
readonly chunkOrder?: number;
|
|
935
|
+
/** Server-reported progress, 0–100. */
|
|
297
936
|
readonly progress?: number;
|
|
298
937
|
}
|
|
299
|
-
export type
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
readonly action: WaChatEventAction;
|
|
303
|
-
readonly source: WaChatEventSource;
|
|
938
|
+
export type WaAppStateMutationSource = 'snapshot' | 'patch';
|
|
939
|
+
type MutationEventBase = {
|
|
940
|
+
readonly source: WaAppStateMutationSource;
|
|
304
941
|
readonly collection: AppStateCollectionName;
|
|
305
|
-
readonly operation: 'set' | 'remove';
|
|
306
|
-
readonly mutationIndex: string;
|
|
307
|
-
readonly indexAction?: string;
|
|
308
|
-
readonly indexParts?: readonly string[];
|
|
309
|
-
readonly syncActionValueKey?: string;
|
|
310
|
-
readonly chatJid?: string;
|
|
311
|
-
readonly timestamp: number;
|
|
312
942
|
readonly version: number;
|
|
313
|
-
readonly
|
|
314
|
-
readonly
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
readonly
|
|
322
|
-
|
|
943
|
+
readonly timestamp: number;
|
|
944
|
+
readonly _raw: {
|
|
945
|
+
readonly index: string;
|
|
946
|
+
readonly indexParts: readonly string[];
|
|
947
|
+
readonly value: Proto.ISyncActionValue | null;
|
|
948
|
+
};
|
|
949
|
+
};
|
|
950
|
+
export type WaAppStateMutationEvent = {
|
|
951
|
+
readonly [K in WaAppstateActionKey]: ({
|
|
952
|
+
readonly schema: K;
|
|
953
|
+
readonly operation: 'set';
|
|
954
|
+
} & MutationEventBase & WaAppstateIndexArgs<K> & Partial<DataForKey<K>>) | ({
|
|
955
|
+
readonly schema: K;
|
|
956
|
+
readonly operation: 'remove';
|
|
957
|
+
} & MutationEventBase & WaAppstateIndexArgs<K>);
|
|
958
|
+
}[WaAppstateActionKey];
|
|
323
959
|
export type WaConnectionEvent = {
|
|
324
960
|
readonly status: 'open';
|
|
325
961
|
readonly reason: WaConnectionOpenReason;
|
|
326
962
|
readonly code: null;
|
|
327
963
|
readonly isLogout: false;
|
|
964
|
+
/** `true` for the first session after a fresh pair, `false` on resume. */
|
|
328
965
|
readonly isNewLogin: boolean;
|
|
329
966
|
} | {
|
|
330
967
|
readonly status: 'close';
|
|
331
968
|
readonly reason: WaDisconnectReason;
|
|
969
|
+
/** `null` for client-initiated closes; populated when the server / transport emits one. */
|
|
332
970
|
readonly code: WaConnectionCode | null;
|
|
971
|
+
/** `true` means the device was unlinked – do not reconnect, re-pair. */
|
|
333
972
|
readonly isLogout: boolean;
|
|
334
973
|
readonly isNewLogin: false;
|
|
335
974
|
};
|
|
975
|
+
/**
|
|
976
|
+
* Type-safe event map for {@link WaClient}. Subscribe with
|
|
977
|
+
* `client.on('event_name', (event) => ...)` and the payload is inferred.
|
|
978
|
+
*
|
|
979
|
+
* Events fall into a few groups: **auth** (`auth_*` – pairing flow),
|
|
980
|
+
* **connection** (`connection`, `offline_resume`, `stream_failure`),
|
|
981
|
+
* **messaging** (`message`, `message_addon`, `message_bot_chunk`,
|
|
982
|
+
* `message_protocol`, `receipt`), **chat/presence**, per-feature
|
|
983
|
+
* (`newsletter*`, `group`, `business`, `picture`, `mutation`,
|
|
984
|
+
* `history_sync_chunk`, `mex_notification`, `call`), **mobile-only**
|
|
985
|
+
* (`mobile_*`), and **debug_** (raw stanzas/frames – opt-in observability).
|
|
986
|
+
*/
|
|
336
987
|
export interface WaClientEventMap {
|
|
988
|
+
/**
|
|
989
|
+
* Pairing QR refresh – emitted while {@link WaClient.connect} runs and the
|
|
990
|
+
* device has not been linked yet. `qr` is the string the phone scans;
|
|
991
|
+
* `ttlMs` is the time until the next refresh (a new event will fire then).
|
|
992
|
+
*/
|
|
337
993
|
readonly auth_qr: (event: {
|
|
338
994
|
readonly qr: string;
|
|
339
995
|
readonly ttlMs: number;
|
|
340
996
|
}) => void;
|
|
997
|
+
/** 8-character pairing code (link-code flow) – emitted after `requestPairingCode` returns. */
|
|
341
998
|
readonly auth_pairing_code: (event: {
|
|
342
999
|
readonly code: string;
|
|
343
1000
|
}) => void;
|
|
344
|
-
|
|
1001
|
+
/**
|
|
1002
|
+
* The server is ready to receive pairing input. `forceManual: true` means
|
|
1003
|
+
* the QR refresh budget was exhausted and the user must request a fresh
|
|
1004
|
+
* one (e.g. via the link-code flow).
|
|
1005
|
+
*/
|
|
1006
|
+
readonly auth_pairing_required: (event: {
|
|
345
1007
|
readonly forceManual: boolean;
|
|
346
1008
|
}) => void;
|
|
1009
|
+
/**
|
|
1010
|
+
* Pairing succeeded – `credentials.meJid` is now populated. The client
|
|
1011
|
+
* persists the credentials before this event fires; `connect()` resolves
|
|
1012
|
+
* shortly after.
|
|
1013
|
+
*/
|
|
347
1014
|
readonly auth_paired: (event: {
|
|
348
1015
|
readonly credentials: WaAuthCredentials;
|
|
349
1016
|
}) => void;
|
|
350
|
-
|
|
1017
|
+
/**
|
|
1018
|
+
* Connection-state transitions: `'open'` (handshake + auth complete),
|
|
1019
|
+
* `'connecting'`, or `'close'` (with a `reason` and optional `code`). The
|
|
1020
|
+
* client does **not** auto-reconnect on close – call {@link WaClient.connect} again.
|
|
1021
|
+
*/
|
|
1022
|
+
readonly connection: (event: WaConnectionEvent) => void;
|
|
1023
|
+
/**
|
|
1024
|
+
* An inbound `<message>` stanza was decrypted. The payload includes the
|
|
1025
|
+
* raw stanza, the decrypted {@link Proto.IMessage}, and resolved sender/
|
|
1026
|
+
* chat JIDs. Reply with {@link WaMessageCoordinator.send} (use
|
|
1027
|
+
* `options.quote` for threads).
|
|
1028
|
+
*/
|
|
1029
|
+
readonly message: (event: WaIncomingMessageEvent) => void;
|
|
1030
|
+
/**
|
|
1031
|
+
* A decrypted addon (poll vote, reaction, edit, comment, ...) attached to
|
|
1032
|
+
* a previous message. Fires unless `addons.autoDecrypt` is explicitly
|
|
1033
|
+
* set to `false`, and the parent message secret is available in the
|
|
1034
|
+
* `messageSecret` cache or the `messages` store.
|
|
1035
|
+
*/
|
|
1036
|
+
readonly message_addon: (event: WaIncomingAddonEvent) => void;
|
|
1037
|
+
/**
|
|
1038
|
+
* A streaming bot chunk (Meta-AI reply piece). Fires per chunk – concat
|
|
1039
|
+
* the `plaintext` in arrival order until you see the `editType === 'full'`
|
|
1040
|
+
* or `'last'` terminator.
|
|
1041
|
+
*/
|
|
1042
|
+
readonly message_bot_chunk: (event: WaIncomingBotChunkEvent) => void;
|
|
1043
|
+
/**
|
|
1044
|
+
* A decoded `protocolMessage` (revoke, ephemeral-setting change, history
|
|
1045
|
+
* sync notification, etc.) extracted from an incoming message. The plain
|
|
1046
|
+
* `message` event also fires for the same stanza; this one gives you the
|
|
1047
|
+
* typed protocol payload directly.
|
|
1048
|
+
*/
|
|
1049
|
+
readonly message_protocol: (event: WaIncomingProtocolMessageEvent) => void;
|
|
1050
|
+
/**
|
|
1051
|
+
* Inbound `<receipt>` for an outgoing message – delivery, read, played,
|
|
1052
|
+
* server, etc. Use this to track message ACK progression.
|
|
1053
|
+
*/
|
|
1054
|
+
readonly receipt: (event: WaIncomingReceiptEvent) => void;
|
|
1055
|
+
/** A newsletter (channel) event – create/update/follow/etc. or admin actions. */
|
|
1056
|
+
readonly newsletter: (event: WaIncomingNewsletterEvent) => void;
|
|
1057
|
+
/** Newsletter message update – edit, react, view-count, poll-vote changes. */
|
|
1058
|
+
readonly newsletter_message_update: (event: WaIncomingNewsletterMessageUpdateEvent) => void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Peer presence (online / offline / last-seen). Only delivered for JIDs
|
|
1061
|
+
* the client previously subscribed via {@link WaPresenceCoordinator.subscribe}.
|
|
1062
|
+
*/
|
|
1063
|
+
readonly presence: (event: WaIncomingPresenceEvent) => void;
|
|
1064
|
+
/** Peer chatstate (typing / recording / paused) – also requires an active presence subscription. */
|
|
1065
|
+
readonly chatstate: (event: WaIncomingChatstateEvent) => void;
|
|
1066
|
+
/** Incoming call signaling (offer / accept / reject / terminate). Read-only – this client doesn't place calls. */
|
|
1067
|
+
readonly call: (event: WaIncomingCallEvent) => void;
|
|
1068
|
+
/**
|
|
1069
|
+
* MEX (GraphQL-over-noise) push notification – typed shape varies per
|
|
1070
|
+
* operation. Use the discriminator (`event.operationName`) or fall back
|
|
1071
|
+
* to the unknown variant for forward-compat.
|
|
1072
|
+
*/
|
|
1073
|
+
readonly mex_notification: (event: WaMexNotificationEvent) => void;
|
|
1074
|
+
/** Group lifecycle event – create, subject/description change, participant add/remove/promote/demote, leave, etc. */
|
|
1075
|
+
readonly group: (event: WaGroupEvent) => void;
|
|
1076
|
+
/** Business profile change – verified name, profile updates, cover photo changes. */
|
|
1077
|
+
readonly business: (event: WaBusinessEvent) => void;
|
|
1078
|
+
/** Profile/group/community picture change notification – the new picture must still be fetched explicitly. */
|
|
1079
|
+
readonly picture: (event: WaPictureEvent) => void;
|
|
1080
|
+
/**
|
|
1081
|
+
* A parsed app-state mutation crossed the sync boundary – chat mute/star/
|
|
1082
|
+
* read/pin/archive/contact/label/etc. Use the discriminator
|
|
1083
|
+
* (`event.action`) to branch on the mutation kind.
|
|
1084
|
+
*/
|
|
1085
|
+
readonly mutation: (event: WaAppStateMutationEvent) => void;
|
|
1086
|
+
/**
|
|
1087
|
+
* One chunk of history-sync data, fired both during the initial
|
|
1088
|
+
* bootstrap that the primary device pushes after pairing and for any
|
|
1089
|
+
* on-demand backfill triggered by `message.requestHistorySync`.
|
|
1090
|
+
* Multiple chunks per sync; track `event.progress` for completion.
|
|
1091
|
+
* Skipped only when `history.enabled` is explicitly `false`.
|
|
1092
|
+
*/
|
|
1093
|
+
readonly history_sync_chunk: (event: WaHistorySyncChunkEvent) => void;
|
|
1094
|
+
/**
|
|
1095
|
+
* Offline-message queue progress after a reconnect (`'resuming'` ticks
|
|
1096
|
+
* with `remainingStanzas`, then `'complete'`). Useful to defer UI updates
|
|
1097
|
+
* until the catch-up finishes.
|
|
1098
|
+
*/
|
|
1099
|
+
readonly offline_resume: (event: WaOfflineResumeEvent) => void;
|
|
1100
|
+
/**
|
|
1101
|
+
* Fatal stream-level error from the server (e.g. logged out from another
|
|
1102
|
+
* device, stream conflict). The connection will close right after.
|
|
1103
|
+
*/
|
|
1104
|
+
readonly stream_failure: (event: WaIncomingFailureEvent) => void;
|
|
1105
|
+
/**
|
|
1106
|
+
* Server-sent error on a specific outgoing stanza – id mismatch, bad
|
|
1107
|
+
* request, throttling. The matching pending operation will already have
|
|
1108
|
+
* rejected; this event surfaces context for diagnostics.
|
|
1109
|
+
*/
|
|
1110
|
+
readonly stanza_error: (event: WaIncomingErrorStanzaEvent) => void;
|
|
1111
|
+
/**
|
|
1112
|
+
* SMS/voice verification code prompt during mobile-flow registration -
|
|
1113
|
+
* only fires when using `mobileTransport`. Read the code from the
|
|
1114
|
+
* phone and feed it back via the registration API.
|
|
1115
|
+
*/
|
|
1116
|
+
readonly mobile_registration_code: (event: WaRegistrationCodeEvent) => void;
|
|
1117
|
+
/**
|
|
1118
|
+
* Account-takeover warning sent during mobile-flow registration when the
|
|
1119
|
+
* number is already linked to another device. Only relevant under
|
|
1120
|
+
* `mobileTransport`.
|
|
1121
|
+
*/
|
|
1122
|
+
readonly mobile_account_takeover_notice: (event: WaAccountTakeoverNoticeEvent) => void;
|
|
1123
|
+
/** **debug** – the success node closing the noise handshake; emitted before `connection: { status: 'open' }`. */
|
|
1124
|
+
readonly debug_connection_success: (event: {
|
|
351
1125
|
readonly node: BinaryNode;
|
|
352
1126
|
}) => void;
|
|
353
|
-
|
|
1127
|
+
/** **debug** – every inbound `<notification>` stanza, regardless of whether a typed handler matched. */
|
|
1128
|
+
readonly debug_notification: (event: WaIncomingNotificationEvent) => void;
|
|
1129
|
+
/** **debug** – trusted-contact-token cache updates (issue / refresh / clear). */
|
|
1130
|
+
readonly debug_privacy_token: (event: WaPrivacyTokenUpdateEvent) => void;
|
|
1131
|
+
/** **debug** – any error surfaced through the client error pipeline (already logged). */
|
|
1132
|
+
readonly debug_client_error: (event: {
|
|
354
1133
|
readonly error: Error;
|
|
355
1134
|
}) => void;
|
|
356
|
-
|
|
357
|
-
readonly
|
|
1135
|
+
/** **debug** – incoming stanzas with no registered handler (lets you spot protocol features the lib doesn't model yet). */
|
|
1136
|
+
readonly debug_unhandled_stanza: (event: WaIncomingUnhandledStanzaEvent) => void;
|
|
1137
|
+
/** **debug** – raw inbound noise frame bytes (before binary-node decode). */
|
|
1138
|
+
readonly debug_transport_frame_in: (event: {
|
|
358
1139
|
readonly frame: Uint8Array;
|
|
359
1140
|
}) => void;
|
|
360
|
-
|
|
1141
|
+
/** **debug** – raw outbound noise frame bytes (after binary-node encode). */
|
|
1142
|
+
readonly debug_transport_frame_out: (event: {
|
|
361
1143
|
readonly frame: Uint8Array;
|
|
362
1144
|
}) => void;
|
|
363
|
-
|
|
1145
|
+
/** **debug** – decoded inbound {@link BinaryNode} plus its source frame. */
|
|
1146
|
+
readonly debug_transport_node_in: (event: {
|
|
364
1147
|
readonly node: BinaryNode;
|
|
365
1148
|
readonly frame: Uint8Array;
|
|
366
1149
|
}) => void;
|
|
367
|
-
|
|
1150
|
+
/** **debug** – outbound {@link BinaryNode} plus the encoded frame about to ship. */
|
|
1151
|
+
readonly debug_transport_node_out: (event: {
|
|
368
1152
|
readonly node: BinaryNode;
|
|
369
1153
|
readonly frame: Uint8Array;
|
|
370
1154
|
}) => void;
|
|
371
|
-
|
|
1155
|
+
/** **debug** – a frame that failed binary-node decoding (corrupted/unsupported). */
|
|
1156
|
+
readonly debug_transport_decode_error: (event: {
|
|
372
1157
|
readonly error: Error;
|
|
373
1158
|
readonly frame: Uint8Array;
|
|
374
1159
|
}) => void;
|
|
375
|
-
readonly message: (event: WaIncomingMessageEvent) => void;
|
|
376
|
-
readonly message_addon: (event: WaIncomingAddonEvent) => void;
|
|
377
|
-
readonly message_protocol: (event: WaIncomingProtocolMessageEvent) => void;
|
|
378
|
-
readonly message_receipt: (event: WaIncomingReceiptEvent) => void;
|
|
379
|
-
readonly presence: (event: WaIncomingPresenceEvent) => void;
|
|
380
|
-
readonly chatstate: (event: WaIncomingChatstateEvent) => void;
|
|
381
|
-
readonly call: (event: WaIncomingCallEvent) => void;
|
|
382
|
-
readonly notification: (event: WaIncomingNotificationEvent) => void;
|
|
383
|
-
readonly registration_code_received: (event: WaRegistrationCodeEvent) => void;
|
|
384
|
-
readonly account_takeover_notice: (event: WaAccountTakeoverNoticeEvent) => void;
|
|
385
|
-
readonly failure: (event: WaIncomingFailureEvent) => void;
|
|
386
|
-
readonly stanza_error: (event: WaIncomingBaseEvent) => void;
|
|
387
|
-
readonly stanza_unhandled: (event: WaIncomingUnhandledStanzaEvent) => void;
|
|
388
|
-
readonly group_event: (event: WaGroupEvent) => void;
|
|
389
|
-
readonly chat_event: (event: WaChatEvent) => void;
|
|
390
|
-
readonly history_sync_chunk: (event: WaHistorySyncChunkEvent) => void;
|
|
391
|
-
readonly privacy_token_update: (event: WaPrivacyTokenUpdateEvent) => void;
|
|
392
|
-
readonly offline_resume: (event: WaOfflineResumeEvent) => void;
|
|
393
1160
|
}
|
|
394
1161
|
export interface WaOfflineResumeEvent {
|
|
395
1162
|
readonly status: 'resuming' | 'complete';
|
|
396
1163
|
readonly totalStanzas: number;
|
|
1164
|
+
/** `0` on the terminal `'complete'` event. */
|
|
397
1165
|
readonly remainingStanzas: number;
|
|
1166
|
+
/** `true` when triggered by an explicit catch-up request rather than auto-resume on reconnect. */
|
|
398
1167
|
readonly forced: boolean;
|
|
399
1168
|
}
|
|
400
1169
|
export interface WaPrivacyTokenUpdateEvent {
|
|
1170
|
+
/** Peer whose trusted-contact-token (TC token) changed. */
|
|
401
1171
|
readonly jid: string;
|
|
402
1172
|
readonly timestampS: number;
|
|
403
1173
|
readonly type: string;
|
|
1174
|
+
/** Live `'notification'` vs. backfill via `'history_sync'`. */
|
|
404
1175
|
readonly source: 'notification' | 'history_sync';
|
|
405
1176
|
}
|
|
1177
|
+
export {};
|