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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { proto } from '../../proto.js';
|
|
2
|
+
import { WA_DEFAULTS } from '../../protocol/defaults.js';
|
|
3
|
+
/** Builds a {@link WaStatusCoordinator} from its dependencies. */
|
|
4
|
+
export function createStatusCoordinator(options) {
|
|
5
|
+
return {
|
|
6
|
+
setPrivacy: (input) => options.appStateMutations.setStatusPrivacy(input),
|
|
7
|
+
setUserMuted: (jid, muted) => options.appStateMutations.setUserStatusMute(jid, muted),
|
|
8
|
+
send: async (input) => {
|
|
9
|
+
const built = await options.buildMessageContent(input.content);
|
|
10
|
+
const message = built.message.conversation && !built.message.extendedTextMessage
|
|
11
|
+
? {
|
|
12
|
+
...built.message,
|
|
13
|
+
conversation: null,
|
|
14
|
+
extendedTextMessage: {
|
|
15
|
+
text: built.message.conversation
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
: built.message;
|
|
19
|
+
const published = await options.publishStatusMessage({
|
|
20
|
+
message,
|
|
21
|
+
recipients: input.recipients,
|
|
22
|
+
statusSetting: input.statusSetting,
|
|
23
|
+
options: input.options
|
|
24
|
+
});
|
|
25
|
+
return built.upload ? { ...published, upload: built.upload } : published;
|
|
26
|
+
},
|
|
27
|
+
revokeStatus: async (input) => {
|
|
28
|
+
const message = {
|
|
29
|
+
protocolMessage: {
|
|
30
|
+
type: proto.Message.ProtocolMessage.Type.REVOKE,
|
|
31
|
+
key: {
|
|
32
|
+
remoteJid: WA_DEFAULTS.STATUS_BROADCAST_JID,
|
|
33
|
+
fromMe: true,
|
|
34
|
+
id: input.messageId
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return options.publishStatusMessage({
|
|
39
|
+
message,
|
|
40
|
+
recipients: input.recipients,
|
|
41
|
+
statusSetting: input.statusSetting,
|
|
42
|
+
options: input.options
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -82,7 +82,7 @@ export function createStreamControlHandler(options) {
|
|
|
82
82
|
return {
|
|
83
83
|
handleStreamControlResult: async (result) => {
|
|
84
84
|
switch (result.kind) {
|
|
85
|
-
case
|
|
85
|
+
case WA_STREAM_SIGNALING.XML_STREAM_END_TAG:
|
|
86
86
|
logger.info('received xmlstreamend stanza');
|
|
87
87
|
return;
|
|
88
88
|
case 'stream_error_code':
|
|
@@ -99,23 +99,23 @@ export function createStreamControlHandler(options) {
|
|
|
99
99
|
}
|
|
100
100
|
await resumeSocketDueToStreamError(`stream_error_code_${result.code}`);
|
|
101
101
|
return;
|
|
102
|
-
case
|
|
102
|
+
case WA_DISCONNECT_REASONS.STREAM_ERROR_REPLACED:
|
|
103
103
|
logger.warn('received stream:error replaced, stopping client');
|
|
104
104
|
await disconnectDueToStreamError(WA_DISCONNECT_REASONS.STREAM_ERROR_REPLACED, null);
|
|
105
105
|
return;
|
|
106
|
-
case
|
|
106
|
+
case WA_DISCONNECT_REASONS.STREAM_ERROR_DEVICE_REMOVED:
|
|
107
107
|
logger.warn('received stream:error device removed, logging out');
|
|
108
108
|
await logoutDueToStreamError(WA_DISCONNECT_REASONS.STREAM_ERROR_DEVICE_REMOVED, null, false);
|
|
109
109
|
return;
|
|
110
|
-
case
|
|
110
|
+
case WA_DISCONNECT_REASONS.STREAM_ERROR_ACK:
|
|
111
111
|
logger.warn('received stream:error ack', { id: result.id });
|
|
112
112
|
await resumeSocketDueToStreamError(WA_DISCONNECT_REASONS.STREAM_ERROR_ACK);
|
|
113
113
|
return;
|
|
114
|
-
case
|
|
114
|
+
case WA_DISCONNECT_REASONS.STREAM_ERROR_XML_NOT_WELL_FORMED:
|
|
115
115
|
logger.warn('received stream:error xml-not-well-formed');
|
|
116
116
|
await resumeSocketDueToStreamError(WA_DISCONNECT_REASONS.STREAM_ERROR_XML_NOT_WELL_FORMED);
|
|
117
117
|
return;
|
|
118
|
-
case
|
|
118
|
+
case WA_DISCONNECT_REASONS.STREAM_ERROR_OTHER:
|
|
119
119
|
logger.warn('received stream:error other');
|
|
120
120
|
await resumeSocketDueToStreamError(WA_DISCONNECT_REASONS.STREAM_ERROR_OTHER);
|
|
121
121
|
return;
|
|
@@ -10,6 +10,7 @@ export class WaTrustedContactTokenCoordinator {
|
|
|
10
10
|
this.logger = options.logger;
|
|
11
11
|
this.store = options.store;
|
|
12
12
|
this.runtime = options.runtime;
|
|
13
|
+
this.serverClock = options.serverClock;
|
|
13
14
|
const maxDurationS = options.maxDurationS ?? WA_TC_TOKEN_DEFAULTS.MAX_DURATION_S;
|
|
14
15
|
this.baseConfig = {
|
|
15
16
|
durationS: clampDuration(options.durationS ?? WA_TC_TOKEN_DEFAULTS.DURATION_S, maxDurationS),
|
|
@@ -40,7 +41,7 @@ export class WaTrustedContactTokenCoordinator {
|
|
|
40
41
|
}
|
|
41
42
|
async resolveTokenForMessage(recipientJid) {
|
|
42
43
|
const record = await this.store.getByJid(recipientJid);
|
|
43
|
-
const nowS =
|
|
44
|
+
const nowS = this.serverClock.nowSeconds();
|
|
44
45
|
const config = this.resolveConfig();
|
|
45
46
|
if (record?.tcToken &&
|
|
46
47
|
record.tcTokenTimestamp !== undefined &&
|
|
@@ -51,11 +52,11 @@ export class WaTrustedContactTokenCoordinator {
|
|
|
51
52
|
if (!nctSalt) {
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
|
-
const meLid = this.runtime.
|
|
55
|
+
const meLid = this.runtime.getCurrentCredentials()?.meLid;
|
|
55
56
|
if (!meLid) {
|
|
56
57
|
return null;
|
|
57
58
|
}
|
|
58
|
-
const hash =
|
|
59
|
+
const hash = this.csTokenGenerator.generate(nctSalt, meLid);
|
|
59
60
|
return buildCsTokenMessageNode(hash);
|
|
60
61
|
}
|
|
61
62
|
async handleIncomingToken(fromJid, tokens) {
|
|
@@ -72,7 +73,7 @@ export class WaTrustedContactTokenCoordinator {
|
|
|
72
73
|
tcTokenTimestamp: token.timestampS,
|
|
73
74
|
updatedAtMs: nowMs
|
|
74
75
|
});
|
|
75
|
-
this.runtime.emitEvent('
|
|
76
|
+
this.runtime.emitEvent('debug_privacy_token', {
|
|
76
77
|
jid: fromJid,
|
|
77
78
|
timestampS: token.timestampS,
|
|
78
79
|
type: token.type,
|
|
@@ -82,7 +83,7 @@ export class WaTrustedContactTokenCoordinator {
|
|
|
82
83
|
}
|
|
83
84
|
async maybeIssueSenderToken(recipientJid) {
|
|
84
85
|
return this.senderTokenDedup.run(recipientJid, async () => {
|
|
85
|
-
const nowS =
|
|
86
|
+
const nowS = this.serverClock.nowSeconds();
|
|
86
87
|
const record = await this.store.getByJid(recipientJid);
|
|
87
88
|
const senderTimestampS = record?.tcTokenSenderTimestamp;
|
|
88
89
|
const config = this.resolveConfig();
|
|
@@ -104,7 +105,7 @@ export class WaTrustedContactTokenCoordinator {
|
|
|
104
105
|
if (!record?.tcTokenSenderTimestamp) {
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
|
-
const nowS =
|
|
108
|
+
const nowS = this.serverClock.nowSeconds();
|
|
108
109
|
const config = this.resolveConfig();
|
|
109
110
|
if (isTokenExpired(record.tcTokenSenderTimestamp, nowS, config.senderDurationS, config.senderNumBuckets)) {
|
|
110
111
|
return;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { decodeEnumValue, decodeIndexArgsFromSchema, getAppstateSchemaByActionName } from '../../appstate-spec.js';
|
|
2
|
+
export function parseAppStateMutationEvent(mutation) {
|
|
3
|
+
const parts = parseIndexParts(mutation.index);
|
|
4
|
+
if (!parts || parts.length === 0) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const resolved = getAppstateSchemaByActionName(parts[0]);
|
|
8
|
+
if (!resolved) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const indexArgs = decodeIndexArgsFromSchema(resolved.schema, parts);
|
|
12
|
+
if (!indexArgs) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const valueRaw = mutation.value ?? null;
|
|
16
|
+
const base = {
|
|
17
|
+
source: mutation.source,
|
|
18
|
+
collection: mutation.collection,
|
|
19
|
+
version: mutation.version,
|
|
20
|
+
timestamp: mutation.timestamp,
|
|
21
|
+
_raw: { index: mutation.index, indexParts: parts, value: valueRaw }
|
|
22
|
+
};
|
|
23
|
+
if (mutation.operation === 'remove') {
|
|
24
|
+
return {
|
|
25
|
+
schema: resolved.key,
|
|
26
|
+
operation: 'remove',
|
|
27
|
+
...indexArgs,
|
|
28
|
+
...base
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const data = unwrapData(resolved.schema, valueRaw);
|
|
32
|
+
return {
|
|
33
|
+
schema: resolved.key,
|
|
34
|
+
operation: 'set',
|
|
35
|
+
...indexArgs,
|
|
36
|
+
...(data ?? {}),
|
|
37
|
+
...base
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function unwrapData(schema, value) {
|
|
41
|
+
if (!value) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const field = schema.valueField;
|
|
45
|
+
let inner;
|
|
46
|
+
if (field === null) {
|
|
47
|
+
const rest = {};
|
|
48
|
+
for (const key of Object.keys(value)) {
|
|
49
|
+
if (key === 'timestamp')
|
|
50
|
+
continue;
|
|
51
|
+
rest[key] = value[key];
|
|
52
|
+
}
|
|
53
|
+
inner = rest;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const sub = value[field];
|
|
57
|
+
if (sub === null || sub === undefined || typeof sub !== 'object') {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
inner = { ...sub };
|
|
61
|
+
}
|
|
62
|
+
applyEnumDecodeToData(schema.valueEnumFields, inner);
|
|
63
|
+
return inner;
|
|
64
|
+
}
|
|
65
|
+
function applyEnumDecodeToData(enumFields, data) {
|
|
66
|
+
if (!enumFields)
|
|
67
|
+
return;
|
|
68
|
+
for (const [fieldPath, enumPath] of Object.entries(enumFields)) {
|
|
69
|
+
applyDecodeAtPath(data, fieldPath.split('.'), (raw) => {
|
|
70
|
+
if (typeof raw !== 'number')
|
|
71
|
+
return raw;
|
|
72
|
+
const name = decodeEnumValue(enumPath, raw);
|
|
73
|
+
return name ?? raw;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function applyDecodeAtPath(obj, segments, transform) {
|
|
78
|
+
if (segments.length === 0)
|
|
79
|
+
return;
|
|
80
|
+
const [head, ...rest] = segments;
|
|
81
|
+
if (rest.length === 0) {
|
|
82
|
+
if (head in obj) {
|
|
83
|
+
const value = obj[head];
|
|
84
|
+
if (Array.isArray(value)) {
|
|
85
|
+
obj[head] = value.map(transform);
|
|
86
|
+
}
|
|
87
|
+
else if (value !== null && value !== undefined) {
|
|
88
|
+
obj[head] = transform(value);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const next = obj[head];
|
|
94
|
+
if (Array.isArray(next)) {
|
|
95
|
+
for (const item of next) {
|
|
96
|
+
if (item && typeof item === 'object') {
|
|
97
|
+
applyDecodeAtPath(item, rest, transform);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (next && typeof next === 'object') {
|
|
103
|
+
applyDecodeAtPath(next, rest, transform);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function parseIndexParts(index) {
|
|
107
|
+
let parsed;
|
|
108
|
+
try {
|
|
109
|
+
parsed = JSON.parse(index);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
if (!Array.isArray(parsed)) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const parts = [];
|
|
118
|
+
for (const item of parsed) {
|
|
119
|
+
if (typeof item === 'string') {
|
|
120
|
+
parts.push(item);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (typeof item === 'number' || typeof item === 'boolean') {
|
|
124
|
+
parts.push(String(item));
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return parts;
|
|
130
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { createUnhandledIncomingNodeEvent } from '../events/incoming.js';
|
|
2
|
+
import { proto } from '../../proto.js';
|
|
3
|
+
import { WA_BUSINESS_NOTIFICATION_TAGS, WA_NOTIFICATION_TYPES } from '../../protocol/constants.js';
|
|
4
|
+
import { WA_NODE_TAGS } from '../../protocol/nodes.js';
|
|
5
|
+
import { findNodeChild, getNodeChildren, getNodeChildrenByTag, getNodeTextContent } from '../../transport/node/helpers.js';
|
|
6
|
+
import { parseOptionalInt } from '../../util/primitives.js';
|
|
7
|
+
const VN_ISSUER_API = 'ent:wa';
|
|
8
|
+
const VN_ISSUER_SMB = 'smb:wa';
|
|
9
|
+
function parseCertificateContent(contentBytes) {
|
|
10
|
+
try {
|
|
11
|
+
const cert = proto.VerifiedNameCertificate.decode(contentBytes);
|
|
12
|
+
if (!cert.details)
|
|
13
|
+
return null;
|
|
14
|
+
const details = proto.VerifiedNameCertificate.Details.decode(cert.details);
|
|
15
|
+
return {
|
|
16
|
+
name: details.verifiedName ?? undefined,
|
|
17
|
+
serial: details.serial !== null && details.serial !== undefined
|
|
18
|
+
? details.serial.toString()
|
|
19
|
+
: undefined,
|
|
20
|
+
isApi: details.issuer === VN_ISSUER_API,
|
|
21
|
+
isSmb: details.issuer === VN_ISSUER_SMB
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function parseVerifiedNameNode(node) {
|
|
29
|
+
if (node.tag !== WA_BUSINESS_NOTIFICATION_TAGS.VERIFIED_NAME)
|
|
30
|
+
return null;
|
|
31
|
+
const level = node.attrs.verified_level;
|
|
32
|
+
const attrSerial = node.attrs.serial;
|
|
33
|
+
const contentBytes = node.content instanceof Uint8Array ? node.content : undefined;
|
|
34
|
+
const certData = contentBytes !== undefined ? parseCertificateContent(contentBytes) : null;
|
|
35
|
+
const entry = {
|
|
36
|
+
name: certData?.name,
|
|
37
|
+
level,
|
|
38
|
+
serial: attrSerial ?? certData?.serial,
|
|
39
|
+
isApi: certData?.isApi === true,
|
|
40
|
+
isSmb: certData?.isSmb === true
|
|
41
|
+
};
|
|
42
|
+
const actualActors = node.attrs.actual_actors;
|
|
43
|
+
const hostStorage = node.attrs.host_storage;
|
|
44
|
+
const privacyModeTs = node.attrs.privacy_mode_ts;
|
|
45
|
+
if (actualActors !== undefined && hostStorage !== undefined && privacyModeTs !== undefined) {
|
|
46
|
+
entry.privacyMode = {
|
|
47
|
+
actualActors: Number.parseInt(actualActors, 10),
|
|
48
|
+
hostStorage: Number.parseInt(hostStorage, 10),
|
|
49
|
+
privacyModeTs: Number.parseInt(privacyModeTs, 10)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return entry;
|
|
53
|
+
}
|
|
54
|
+
function parseBusinessCategories(node) {
|
|
55
|
+
const children = getNodeChildren(node);
|
|
56
|
+
const categories = new Array(children.length);
|
|
57
|
+
let count = 0;
|
|
58
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
59
|
+
const child = children[i];
|
|
60
|
+
if (child.tag !== 'category')
|
|
61
|
+
continue;
|
|
62
|
+
const id = child.attrs.id;
|
|
63
|
+
if (!id)
|
|
64
|
+
continue;
|
|
65
|
+
categories[count] = { id, name: getNodeTextContent(child) ?? '' };
|
|
66
|
+
count += 1;
|
|
67
|
+
}
|
|
68
|
+
categories.length = count;
|
|
69
|
+
return categories;
|
|
70
|
+
}
|
|
71
|
+
function parseBusinessHoursNode(node) {
|
|
72
|
+
const timezone = node.attrs.timezone;
|
|
73
|
+
const children = getNodeChildren(node);
|
|
74
|
+
const config = new Array(children.length);
|
|
75
|
+
let count = 0;
|
|
76
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
77
|
+
const child = children[i];
|
|
78
|
+
if (child.tag !== 'business_hours_config')
|
|
79
|
+
continue;
|
|
80
|
+
const dayOfWeek = child.attrs.day_of_week;
|
|
81
|
+
const mode = child.attrs.mode;
|
|
82
|
+
if (!dayOfWeek || !mode)
|
|
83
|
+
continue;
|
|
84
|
+
const entry = { dayOfWeek, mode };
|
|
85
|
+
const openTime = child.attrs.open_time;
|
|
86
|
+
const closeTime = child.attrs.close_time;
|
|
87
|
+
if (openTime)
|
|
88
|
+
entry.openTime = Number.parseInt(openTime, 10);
|
|
89
|
+
if (closeTime)
|
|
90
|
+
entry.closeTime = Number.parseInt(closeTime, 10);
|
|
91
|
+
config[count] = entry;
|
|
92
|
+
count += 1;
|
|
93
|
+
}
|
|
94
|
+
config.length = count;
|
|
95
|
+
return { timezone, config };
|
|
96
|
+
}
|
|
97
|
+
function parseProfileOptions(node) {
|
|
98
|
+
const children = getNodeChildren(node);
|
|
99
|
+
const options = {};
|
|
100
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
101
|
+
const child = children[i];
|
|
102
|
+
const text = getNodeTextContent(child);
|
|
103
|
+
if (text !== undefined) {
|
|
104
|
+
options[child.tag] = text;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return options;
|
|
108
|
+
}
|
|
109
|
+
export function parseBusinessProfileNode(node) {
|
|
110
|
+
if (node.tag !== WA_BUSINESS_NOTIFICATION_TAGS.PROFILE)
|
|
111
|
+
return null;
|
|
112
|
+
const jid = node.attrs.jid;
|
|
113
|
+
if (!jid)
|
|
114
|
+
return null;
|
|
115
|
+
const entry = { jid };
|
|
116
|
+
const tag = node.attrs.tag;
|
|
117
|
+
if (tag)
|
|
118
|
+
entry.tag = tag;
|
|
119
|
+
const children = node.content;
|
|
120
|
+
if (!Array.isArray(children)) {
|
|
121
|
+
return entry;
|
|
122
|
+
}
|
|
123
|
+
const websites = [];
|
|
124
|
+
for (let j = 0; j < children.length; j += 1) {
|
|
125
|
+
const child = children[j];
|
|
126
|
+
const text = getNodeTextContent(child);
|
|
127
|
+
switch (child.tag) {
|
|
128
|
+
case 'description':
|
|
129
|
+
if (text !== undefined)
|
|
130
|
+
entry.description = text;
|
|
131
|
+
break;
|
|
132
|
+
case 'address':
|
|
133
|
+
if (text !== undefined)
|
|
134
|
+
entry.address = text;
|
|
135
|
+
break;
|
|
136
|
+
case 'email':
|
|
137
|
+
if (text !== undefined)
|
|
138
|
+
entry.email = text;
|
|
139
|
+
break;
|
|
140
|
+
case 'website':
|
|
141
|
+
if (text !== undefined)
|
|
142
|
+
websites.push({ url: text });
|
|
143
|
+
break;
|
|
144
|
+
case 'latitude':
|
|
145
|
+
if (text !== undefined) {
|
|
146
|
+
const val = Number.parseFloat(text);
|
|
147
|
+
if (!Number.isNaN(val))
|
|
148
|
+
entry.latitude = val;
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case 'longitude':
|
|
152
|
+
if (text !== undefined) {
|
|
153
|
+
const val = Number.parseFloat(text);
|
|
154
|
+
if (!Number.isNaN(val))
|
|
155
|
+
entry.longitude = val;
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case 'categories':
|
|
159
|
+
entry.categories = parseBusinessCategories(child);
|
|
160
|
+
break;
|
|
161
|
+
case 'business_hours':
|
|
162
|
+
entry.businessHours = parseBusinessHoursNode(child);
|
|
163
|
+
break;
|
|
164
|
+
case 'profile_options':
|
|
165
|
+
entry.profileOptions = parseProfileOptions(child);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (websites.length > 0)
|
|
170
|
+
entry.websites = websites;
|
|
171
|
+
return entry;
|
|
172
|
+
}
|
|
173
|
+
function parseSubscriptionsList(node) {
|
|
174
|
+
const subs = [];
|
|
175
|
+
for (const sub of getNodeChildrenByTag(node, 'subscription')) {
|
|
176
|
+
const id = sub.attrs.id;
|
|
177
|
+
const status = sub.attrs.status;
|
|
178
|
+
if (!id || !status)
|
|
179
|
+
continue;
|
|
180
|
+
subs.push({
|
|
181
|
+
id,
|
|
182
|
+
status,
|
|
183
|
+
tier: parseOptionalInt(sub.attrs.subscription_tier),
|
|
184
|
+
source: sub.attrs.source,
|
|
185
|
+
startTime: parseOptionalInt(sub.attrs.subscription_start_time),
|
|
186
|
+
creationTime: parseOptionalInt(sub.attrs.subscription_creation_time),
|
|
187
|
+
expirationDate: parseOptionalInt(sub.attrs.subscription_end_time)
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return subs;
|
|
191
|
+
}
|
|
192
|
+
function parseFeatureFlagsList(node) {
|
|
193
|
+
const flags = [];
|
|
194
|
+
for (const flag of getNodeChildrenByTag(node, 'feature_flag')) {
|
|
195
|
+
const name = flag.attrs.name;
|
|
196
|
+
if (!name)
|
|
197
|
+
continue;
|
|
198
|
+
const enabled = (flag.attrs.enabled ?? '').toLowerCase() === 'true';
|
|
199
|
+
flags.push({
|
|
200
|
+
name,
|
|
201
|
+
enabled,
|
|
202
|
+
expirationTime: parseOptionalInt(flag.attrs.expiration_time),
|
|
203
|
+
limit: parseOptionalInt(flag.attrs.limit)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return flags;
|
|
207
|
+
}
|
|
208
|
+
function parseProductIds(catalogNode) {
|
|
209
|
+
const ids = [];
|
|
210
|
+
for (const product of getNodeChildrenByTag(catalogNode, 'product')) {
|
|
211
|
+
const idNode = findNodeChild(product, WA_NODE_TAGS.ID);
|
|
212
|
+
if (!idNode)
|
|
213
|
+
continue;
|
|
214
|
+
const text = getNodeTextContent(idNode);
|
|
215
|
+
if (text)
|
|
216
|
+
ids.push(text);
|
|
217
|
+
}
|
|
218
|
+
return ids;
|
|
219
|
+
}
|
|
220
|
+
function parseCollectionUpdates(catalogNode) {
|
|
221
|
+
const collections = [];
|
|
222
|
+
for (const collection of getNodeChildrenByTag(catalogNode, 'collection')) {
|
|
223
|
+
const id = collection.attrs.id;
|
|
224
|
+
if (!id)
|
|
225
|
+
continue;
|
|
226
|
+
const entry = { id };
|
|
227
|
+
const statusInfo = findNodeChild(collection, 'status_info');
|
|
228
|
+
if (statusInfo) {
|
|
229
|
+
const statusNode = findNodeChild(statusInfo, WA_NODE_TAGS.STATUS);
|
|
230
|
+
if (statusNode) {
|
|
231
|
+
const text = getNodeTextContent(statusNode);
|
|
232
|
+
if (text)
|
|
233
|
+
entry.reviewStatus = text;
|
|
234
|
+
}
|
|
235
|
+
const rejectNode = findNodeChild(statusInfo, 'reject_reason');
|
|
236
|
+
if (rejectNode) {
|
|
237
|
+
const text = getNodeTextContent(rejectNode);
|
|
238
|
+
if (text)
|
|
239
|
+
entry.rejectReason = text;
|
|
240
|
+
}
|
|
241
|
+
const commerceNode = findNodeChild(statusInfo, 'commerce_url');
|
|
242
|
+
if (commerceNode) {
|
|
243
|
+
const text = getNodeTextContent(commerceNode);
|
|
244
|
+
if (text)
|
|
245
|
+
entry.commerceUrl = text;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
collections.push(entry);
|
|
249
|
+
}
|
|
250
|
+
return collections;
|
|
251
|
+
}
|
|
252
|
+
function createBaseBusinessEvent(notificationNode) {
|
|
253
|
+
return {
|
|
254
|
+
rawNode: notificationNode,
|
|
255
|
+
stanzaId: notificationNode.attrs.id,
|
|
256
|
+
chatJid: notificationNode.attrs.from,
|
|
257
|
+
stanzaType: notificationNode.attrs.type,
|
|
258
|
+
offline: notificationNode.attrs.offline !== undefined,
|
|
259
|
+
timestampSeconds: parseOptionalInt(notificationNode.attrs.t)
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function parseSingleBusinessEvent(notificationNode) {
|
|
263
|
+
const base = createBaseBusinessEvent(notificationNode);
|
|
264
|
+
const verifiedName = findNodeChild(notificationNode, WA_BUSINESS_NOTIFICATION_TAGS.VERIFIED_NAME);
|
|
265
|
+
if (verifiedName) {
|
|
266
|
+
const vnJid = verifiedName.attrs.jid;
|
|
267
|
+
if (vnJid) {
|
|
268
|
+
const parsed = parseVerifiedNameNode(verifiedName);
|
|
269
|
+
if (!parsed)
|
|
270
|
+
return null;
|
|
271
|
+
return {
|
|
272
|
+
...base,
|
|
273
|
+
action: 'verified_name_update',
|
|
274
|
+
bizJid: vnJid,
|
|
275
|
+
verifiedName: parsed
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const vnHash = verifiedName.attrs.hash;
|
|
279
|
+
if (vnHash) {
|
|
280
|
+
return {
|
|
281
|
+
...base,
|
|
282
|
+
action: 'verified_name_stale',
|
|
283
|
+
bizHash: vnHash
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const remove = findNodeChild(notificationNode, WA_BUSINESS_NOTIFICATION_TAGS.REMOVE);
|
|
289
|
+
if (remove) {
|
|
290
|
+
const rmJid = remove.attrs.jid;
|
|
291
|
+
if (rmJid) {
|
|
292
|
+
return { ...base, action: 'business_removed', bizJid: rmJid };
|
|
293
|
+
}
|
|
294
|
+
const rmHash = remove.attrs.hash;
|
|
295
|
+
if (rmHash) {
|
|
296
|
+
return { ...base, action: 'business_removed', bizHash: rmHash };
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const profile = findNodeChild(notificationNode, WA_BUSINESS_NOTIFICATION_TAGS.PROFILE);
|
|
301
|
+
if (profile) {
|
|
302
|
+
const hash = profile.attrs.hash;
|
|
303
|
+
if (hash) {
|
|
304
|
+
return { ...base, action: 'profile_update', bizHash: hash };
|
|
305
|
+
}
|
|
306
|
+
const fromJid = notificationNode.attrs.from;
|
|
307
|
+
return { ...base, action: 'profile_update', bizJid: fromJid };
|
|
308
|
+
}
|
|
309
|
+
const catalog = findNodeChild(notificationNode, WA_BUSINESS_NOTIFICATION_TAGS.PRODUCT_CATALOG);
|
|
310
|
+
if (catalog) {
|
|
311
|
+
const fromJid = notificationNode.attrs.from;
|
|
312
|
+
if (findNodeChild(catalog, 'product')) {
|
|
313
|
+
return {
|
|
314
|
+
...base,
|
|
315
|
+
action: 'product_update',
|
|
316
|
+
bizJid: fromJid,
|
|
317
|
+
productIds: parseProductIds(catalog)
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
if (findNodeChild(catalog, 'collection')) {
|
|
321
|
+
return {
|
|
322
|
+
...base,
|
|
323
|
+
action: 'collection_update',
|
|
324
|
+
bizJid: fromJid,
|
|
325
|
+
collections: parseCollectionUpdates(catalog)
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
const subscriptions = findNodeChild(notificationNode, WA_BUSINESS_NOTIFICATION_TAGS.SUBSCRIPTIONS);
|
|
331
|
+
const featureFlags = findNodeChild(notificationNode, WA_BUSINESS_NOTIFICATION_TAGS.FEATURE_FLAGS);
|
|
332
|
+
if (subscriptions || featureFlags) {
|
|
333
|
+
return {
|
|
334
|
+
...base,
|
|
335
|
+
action: 'subscriptions_update',
|
|
336
|
+
bizJid: notificationNode.attrs.from,
|
|
337
|
+
subscriptions: subscriptions ? parseSubscriptionsList(subscriptions) : [],
|
|
338
|
+
featureFlags: featureFlags ? parseFeatureFlagsList(featureFlags) : []
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
export function parseBusinessNotificationEvents(notificationNode) {
|
|
344
|
+
if (notificationNode.tag !== WA_NODE_TAGS.NOTIFICATION ||
|
|
345
|
+
notificationNode.attrs.type !== WA_NOTIFICATION_TYPES.BUSINESS) {
|
|
346
|
+
return { events: [], unhandled: [] };
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
const event = parseSingleBusinessEvent(notificationNode);
|
|
350
|
+
if (event) {
|
|
351
|
+
return { events: [event], unhandled: [] };
|
|
352
|
+
}
|
|
353
|
+
const firstChild = getNodeChildren(notificationNode)[0];
|
|
354
|
+
const childTag = firstChild?.tag ?? 'empty';
|
|
355
|
+
return {
|
|
356
|
+
events: [],
|
|
357
|
+
unhandled: [
|
|
358
|
+
createUnhandledIncomingNodeEvent(notificationNode, `notification.${WA_NOTIFICATION_TYPES.BUSINESS}.${childTag}.not_supported`)
|
|
359
|
+
]
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
return {
|
|
364
|
+
events: [],
|
|
365
|
+
unhandled: [
|
|
366
|
+
createUnhandledIncomingNodeEvent(notificationNode, `notification.${WA_NOTIFICATION_TYPES.BUSINESS}.parse_failed`)
|
|
367
|
+
]
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WA_CALL_CHILD_TAGS, WA_CALL_NODE_ATTRS, WA_CALL_PAYLOAD_TAGS } from '../../protocol/call.js';
|
|
2
|
+
import { findNodeChild, getFirstNodeChild, getNodeChildren, hasNodeChild } from '../../transport/node/helpers.js';
|
|
3
|
+
import { parseOptionalInt } from '../../util/primitives.js';
|
|
4
|
+
const KNOWN_CALL_PAYLOAD_TAGS = new Set(Object.values(WA_CALL_PAYLOAD_TAGS));
|
|
5
|
+
function parseGroupInfo(node) {
|
|
6
|
+
const children = getNodeChildren(node);
|
|
7
|
+
if (children.length === 0) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const out = [];
|
|
11
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
12
|
+
const child = children[i];
|
|
13
|
+
const jid = child.attrs.jid;
|
|
14
|
+
if (!jid)
|
|
15
|
+
continue;
|
|
16
|
+
out.push({
|
|
17
|
+
jid,
|
|
18
|
+
userPnJid: child.attrs[WA_CALL_NODE_ATTRS.USER_PN],
|
|
19
|
+
username: child.attrs[WA_CALL_NODE_ATTRS.USERNAME],
|
|
20
|
+
guestName: child.attrs[WA_CALL_NODE_ATTRS.GUEST_NAME]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return out.length > 0 ? out : undefined;
|
|
24
|
+
}
|
|
25
|
+
export function parseCallNode(node) {
|
|
26
|
+
const payload = getFirstNodeChild(node);
|
|
27
|
+
if (!payload) {
|
|
28
|
+
return { type: 'unknown', isVideo: false };
|
|
29
|
+
}
|
|
30
|
+
const payloadTag = payload.tag;
|
|
31
|
+
const type = KNOWN_CALL_PAYLOAD_TAGS.has(payloadTag)
|
|
32
|
+
? payloadTag
|
|
33
|
+
: 'unknown';
|
|
34
|
+
const groupInfoNode = findNodeChild(payload, WA_CALL_CHILD_TAGS.GROUP_INFO);
|
|
35
|
+
const silenceNode = findNodeChild(payload, WA_CALL_CHILD_TAGS.SILENCE);
|
|
36
|
+
return {
|
|
37
|
+
type,
|
|
38
|
+
payloadTag,
|
|
39
|
+
callId: payload.attrs[WA_CALL_NODE_ATTRS.CALL_ID],
|
|
40
|
+
callCreatorJid: payload.attrs[WA_CALL_NODE_ATTRS.CALL_CREATOR],
|
|
41
|
+
senderLidJid: node.attrs[WA_CALL_NODE_ATTRS.SENDER_LID],
|
|
42
|
+
callerPnJid: payload.attrs[WA_CALL_NODE_ATTRS.CALLER_PN],
|
|
43
|
+
groupJid: payload.attrs[WA_CALL_NODE_ATTRS.GROUP_JID],
|
|
44
|
+
isVideo: hasNodeChild(payload, WA_CALL_CHILD_TAGS.VIDEO),
|
|
45
|
+
callerUsername: payload.attrs[WA_CALL_NODE_ATTRS.USERNAME],
|
|
46
|
+
callerCountryCode: payload.attrs[WA_CALL_NODE_ATTRS.CALLER_COUNTRY_CODE],
|
|
47
|
+
callerPushName: payload.attrs[WA_CALL_NODE_ATTRS.NOTIFY],
|
|
48
|
+
peerPlatform: node.attrs[WA_CALL_NODE_ATTRS.PLATFORM],
|
|
49
|
+
peerAppVersion: node.attrs[WA_CALL_NODE_ATTRS.VERSION],
|
|
50
|
+
timestampSeconds: parseOptionalInt(node.attrs.t),
|
|
51
|
+
endTimestampSeconds: parseOptionalInt(node.attrs.e),
|
|
52
|
+
silenceReason: silenceNode?.attrs[WA_CALL_NODE_ATTRS.REASON],
|
|
53
|
+
groupInfo: groupInfoNode ? parseGroupInfo(groupInfoNode) : undefined
|
|
54
|
+
};
|
|
55
|
+
}
|