zapo-js 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/appstate/WaAppStateCrypto.js +49 -41
- package/dist/appstate/WaAppStateSyncClient.js +79 -42
- package/dist/appstate/index.js +2 -2
- package/dist/auth/WaAuthClient.js +20 -11
- package/dist/auth/{flow/WaAuthCredentialsFlow.js → credentials-flow.js} +83 -18
- package/dist/auth/pairing/WaPairingFlow.js +26 -29
- package/dist/auth/pairing/{WaPairingCodeCrypto.js → pairing-code-crypto.js} +29 -13
- package/dist/client/WaClient.js +115 -75
- package/dist/client/WaClientFactory.js +113 -30
- package/dist/client/connection/WaConnectionManager.js +4 -1
- package/dist/client/coordinators/WaAbPropsCoordinator.js +141 -0
- package/dist/client/coordinators/WaBusinessCoordinator.js +3 -12
- package/dist/client/coordinators/WaEmailCoordinator.js +63 -0
- package/dist/client/coordinators/WaIncomingNodeCoordinator.js +33 -8
- package/dist/client/coordinators/WaMessageDispatchCoordinator.js +55 -25
- package/dist/client/coordinators/WaOfflineResumeCoordinator.js +114 -0
- package/dist/client/coordinators/WaPassiveTasksCoordinator.js +38 -20
- package/dist/client/coordinators/WaProfileCoordinator.js +3 -1
- package/dist/client/coordinators/WaRetryCoordinator.js +11 -9
- package/dist/client/coordinators/WaTrustedContactTokenCoordinator.js +22 -4
- package/dist/client/dirty.js +1 -1
- package/dist/client/events/abprops.js +43 -0
- package/dist/client/events/privacy-token.js +1 -2
- package/dist/client/events/registration.js +42 -0
- package/dist/client/incoming.js +37 -0
- package/dist/client/mailbox.js +17 -1
- package/dist/client/media.js +243 -0
- package/dist/client/messages.js +163 -86
- package/dist/crypto/core/index.js +4 -1
- package/dist/crypto/core/random.js +3 -9
- package/dist/crypto/core/xeddsa.js +57 -0
- package/dist/crypto/curves/X25519.js +18 -0
- package/dist/crypto/curves/constants.js +2 -1
- package/dist/esm/appstate/WaAppStateCrypto.js +39 -31
- package/dist/esm/appstate/WaAppStateSyncClient.js +68 -31
- package/dist/esm/appstate/index.js +1 -1
- package/dist/esm/appstate/{WaAppStateSyncResponseParser.js → response-parser.js} +1 -1
- package/dist/esm/auth/WaAuthClient.js +17 -8
- package/dist/esm/auth/{flow/WaAuthCredentialsFlow.js → credentials-flow.js} +83 -18
- package/dist/esm/auth/pairing/WaPairingFlow.js +25 -28
- package/dist/esm/auth/pairing/{WaPairingCodeCrypto.js → pairing-code-crypto.js} +20 -6
- package/dist/esm/client/WaClient.js +116 -76
- package/dist/esm/client/WaClientFactory.js +114 -31
- package/dist/esm/client/connection/WaConnectionManager.js +4 -1
- package/dist/esm/client/coordinators/WaAbPropsCoordinator.js +137 -0
- package/dist/esm/client/coordinators/WaBusinessCoordinator.js +4 -13
- package/dist/esm/client/coordinators/WaEmailCoordinator.js +60 -0
- package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +35 -10
- package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +47 -17
- package/dist/esm/client/coordinators/WaOfflineResumeCoordinator.js +110 -0
- package/dist/esm/client/coordinators/WaPassiveTasksCoordinator.js +38 -20
- package/dist/esm/client/coordinators/WaProfileCoordinator.js +3 -1
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +11 -9
- package/dist/esm/client/coordinators/WaTrustedContactTokenCoordinator.js +24 -6
- package/dist/esm/client/dirty.js +1 -1
- package/dist/esm/client/events/abprops.js +40 -0
- package/dist/esm/client/events/privacy-token.js +1 -2
- package/dist/esm/client/events/registration.js +39 -0
- package/dist/esm/client/incoming.js +36 -0
- package/dist/esm/client/mailbox.js +17 -1
- package/dist/esm/client/media.js +234 -0
- package/dist/esm/client/messages.js +162 -85
- package/dist/esm/crypto/core/index.js +1 -0
- package/dist/esm/crypto/core/random.js +2 -7
- package/dist/esm/crypto/core/xeddsa.js +53 -0
- package/dist/esm/crypto/curves/X25519.js +20 -2
- package/dist/esm/crypto/curves/constants.js +1 -0
- package/dist/esm/infra/perf/StoreLock.js +7 -4
- package/dist/esm/media/WaMediaCrypto.js +257 -62
- package/dist/esm/media/WaMediaTransferClient.js +47 -190
- package/dist/esm/media/constants.js +2 -0
- package/dist/esm/media/processor.js +1 -0
- package/dist/esm/message/addon-crypto.js +130 -3
- package/dist/esm/message/content.js +12 -6
- package/dist/esm/message/icdc.js +8 -8
- package/dist/esm/message/incoming.js +14 -12
- package/dist/esm/message/phash.js +32 -12
- package/dist/esm/message/reporting-token.js +3 -3
- package/dist/esm/message/use-case-secret.js +1 -1
- package/dist/esm/protocol/abprops.js +159 -0
- package/dist/esm/protocol/browser.js +14 -0
- package/dist/esm/protocol/constants.js +3 -1
- package/dist/esm/protocol/email.js +30 -0
- package/dist/esm/protocol/jid.js +44 -10
- package/dist/esm/protocol/nodes.js +6 -2
- package/dist/esm/protocol/notification.js +7 -1
- package/dist/esm/retry/reason.js +1 -1
- package/dist/esm/signal/api/SignalDeviceSyncApi.js +5 -2
- package/dist/esm/signal/api/SignalDigestSyncApi.js +8 -6
- package/dist/esm/signal/api/SignalIdentitySyncApi.js +4 -4
- package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +1 -1
- package/dist/esm/signal/api/SignalSessionSyncApi.js +1 -1
- package/dist/esm/signal/crypto/WaAdvSignature.js +5 -51
- package/dist/esm/signal/crypto/constants.js +0 -4
- package/dist/esm/signal/encoding.js +11 -54
- package/dist/esm/signal/group/SenderKeyChain.js +3 -3
- package/dist/esm/signal/group/SenderKeyCodec.js +5 -6
- package/dist/esm/signal/group/SenderKeyManager.js +13 -10
- package/dist/esm/signal/registration/keygen.js +2 -3
- package/dist/esm/signal/registration/utils.js +2 -2
- package/dist/esm/signal/session/SignalProtocol.js +18 -17
- package/dist/esm/signal/session/SignalRatchet.js +21 -10
- package/dist/esm/signal/session/SignalSerializer.js +5 -6
- package/dist/esm/signal/session/SignalSession.js +11 -9
- package/dist/esm/signal/session/resolver.js +6 -6
- package/dist/esm/store/contracts/identity.store.js +1 -0
- package/dist/esm/store/contracts/message-secret.store.js +1 -0
- package/dist/esm/store/contracts/pre-key.store.js +1 -0
- package/dist/esm/store/contracts/session.store.js +1 -0
- package/dist/esm/store/createStore.js +48 -12
- package/dist/esm/store/index.js +4 -0
- package/dist/esm/store/locks/identity.lock.js +16 -0
- package/dist/esm/store/locks/message-secret.lock.js +17 -0
- package/dist/esm/store/locks/pre-key.lock.js +27 -0
- package/dist/esm/store/locks/session.lock.js +19 -0
- package/dist/esm/store/locks/signal.lock.js +0 -24
- package/dist/esm/store/noop.store.js +20 -0
- package/dist/esm/store/providers/memory/device-list.store.js +3 -0
- package/dist/esm/store/providers/memory/identity.store.js +31 -0
- package/dist/esm/store/providers/memory/message-secret.store.js +81 -0
- package/dist/esm/store/providers/memory/participants.store.js +3 -0
- package/dist/esm/store/providers/memory/pre-key.store.js +97 -0
- package/dist/esm/store/providers/memory/retry.store.js +25 -11
- package/dist/esm/store/providers/memory/session.store.js +45 -0
- package/dist/esm/store/providers/memory/signal.store.js +1 -164
- package/dist/esm/transport/WaComms.js +4 -3
- package/dist/esm/transport/WaWebSocket.js +9 -1
- package/dist/esm/transport/index.js +6 -0
- package/dist/esm/transport/keepalive/WaKeepAlive.js +17 -8
- package/dist/esm/transport/node/WaMobileTcpSocket.js +114 -0
- package/dist/esm/transport/node/WaNodeOrchestrator.js +17 -8
- package/dist/esm/transport/node/builders/abprops.js +20 -0
- package/dist/esm/transport/node/builders/device.js +11 -0
- package/dist/esm/transport/node/builders/email.js +65 -0
- package/dist/esm/transport/node/builders/offline.js +14 -0
- package/dist/esm/transport/node/builders/prekeys.js +37 -40
- package/dist/esm/transport/node/builders/presence.js +13 -0
- package/dist/esm/transport/node/builders/privacy-token.js +19 -23
- package/dist/esm/transport/node/builders/retry.js +1 -1
- package/dist/esm/transport/node/helpers.js +24 -0
- package/dist/esm/transport/node/mex/argo-decoder.js +152 -0
- package/dist/esm/transport/node/mex/client.js +83 -0
- package/dist/esm/transport/node/mex/persist-ids.js +10 -0
- package/dist/esm/transport/noise/WaClientPayload.js +15 -10
- package/dist/esm/transport/noise/WaFrameCodec.js +2 -2
- package/dist/esm/transport/noise/WaMobileClientPayload.js +53 -0
- package/dist/esm/transport/noise/WaNoiseCert.js +9 -27
- package/dist/esm/transport/noise/WaNoiseSession.js +12 -11
- package/dist/infra/perf/StoreLock.js +7 -4
- package/dist/media/WaMediaCrypto.js +253 -58
- package/dist/media/WaMediaTransferClient.js +50 -223
- package/dist/media/constants.js +3 -1
- package/dist/media/processor.js +2 -0
- package/dist/message/addon-crypto.js +131 -0
- package/dist/message/content.js +13 -5
- package/dist/message/icdc.js +8 -8
- package/dist/message/incoming.js +14 -12
- package/dist/message/phash.js +32 -12
- package/dist/message/reporting-token.js +2 -2
- package/dist/message/use-case-secret.js +1 -1
- package/dist/protocol/abprops.js +163 -0
- package/dist/protocol/browser.js +15 -0
- package/dist/protocol/constants.js +14 -2
- package/dist/protocol/email.js +33 -0
- package/dist/protocol/jid.js +45 -10
- package/dist/protocol/nodes.js +6 -2
- package/dist/protocol/notification.js +8 -2
- package/dist/retry/reason.js +1 -1
- package/dist/signal/api/SignalDeviceSyncApi.js +5 -2
- package/dist/signal/api/SignalDigestSyncApi.js +8 -6
- package/dist/signal/api/SignalIdentitySyncApi.js +4 -4
- package/dist/signal/crypto/WaAdvSignature.js +2 -50
- package/dist/signal/crypto/constants.js +1 -5
- package/dist/signal/encoding.js +11 -49
- package/dist/signal/group/SenderKeyChain.js +2 -2
- package/dist/signal/group/SenderKeyCodec.js +4 -5
- package/dist/signal/group/SenderKeyManager.js +12 -9
- package/dist/signal/registration/keygen.js +1 -2
- package/dist/signal/registration/utils.js +2 -2
- package/dist/signal/session/SignalProtocol.js +18 -17
- package/dist/signal/session/SignalRatchet.js +19 -8
- package/dist/signal/session/SignalSerializer.js +5 -6
- package/dist/signal/session/SignalSession.js +11 -9
- package/dist/signal/session/resolver.js +6 -6
- package/dist/store/contracts/identity.store.js +2 -0
- package/dist/store/contracts/message-secret.store.js +2 -0
- package/dist/store/contracts/pre-key.store.js +2 -0
- package/dist/store/contracts/session.store.js +2 -0
- package/dist/store/createStore.js +47 -11
- package/dist/store/index.js +9 -1
- package/dist/store/locks/identity.lock.js +19 -0
- package/dist/store/locks/message-secret.lock.js +20 -0
- package/dist/store/locks/pre-key.lock.js +30 -0
- package/dist/store/locks/session.lock.js +22 -0
- package/dist/store/locks/signal.lock.js +0 -24
- package/dist/store/noop.store.js +21 -1
- package/dist/store/providers/memory/device-list.store.js +3 -0
- package/dist/store/providers/memory/identity.store.js +35 -0
- package/dist/store/providers/memory/message-secret.store.js +85 -0
- package/dist/store/providers/memory/participants.store.js +3 -0
- package/dist/store/providers/memory/pre-key.store.js +101 -0
- package/dist/store/providers/memory/retry.store.js +24 -10
- package/dist/store/providers/memory/session.store.js +49 -0
- package/dist/store/providers/memory/signal.store.js +1 -164
- package/dist/transport/WaComms.js +4 -3
- package/dist/transport/WaWebSocket.js +9 -1
- package/dist/transport/index.js +17 -1
- package/dist/transport/keepalive/WaKeepAlive.js +17 -8
- package/dist/transport/node/WaMobileTcpSocket.js +118 -0
- package/dist/transport/node/WaNodeOrchestrator.js +16 -7
- package/dist/transport/node/builders/abprops.js +23 -0
- package/dist/transport/node/builders/device.js +14 -0
- package/dist/transport/node/builders/email.js +72 -0
- package/dist/transport/node/builders/offline.js +17 -0
- package/dist/transport/node/builders/prekeys.js +36 -39
- package/dist/transport/node/builders/presence.js +16 -0
- package/dist/transport/node/builders/privacy-token.js +18 -22
- package/dist/transport/node/builders/retry.js +1 -1
- package/dist/transport/node/helpers.js +26 -0
- package/dist/transport/node/mex/argo-decoder.js +189 -0
- package/dist/transport/node/mex/client.js +86 -0
- package/dist/transport/node/mex/persist-ids.js +13 -0
- package/dist/transport/noise/WaClientPayload.js +14 -9
- package/dist/transport/noise/WaFrameCodec.js +1 -1
- package/dist/transport/noise/WaMobileClientPayload.js +56 -0
- package/dist/transport/noise/WaNoiseCert.js +8 -26
- package/dist/transport/noise/WaNoiseSession.js +11 -10
- package/dist/types/appstate/WaAppStateCrypto.d.ts +11 -8
- package/dist/types/appstate/WaAppStateSyncClient.d.ts +6 -2
- package/dist/types/appstate/index.d.ts +1 -1
- package/dist/types/appstate/{WaAppStateSyncResponseParser.d.ts → response-parser.d.ts} +1 -1
- package/dist/types/appstate/types.d.ts +1 -1
- package/dist/types/auth/WaAuthClient.d.ts +9 -3
- package/dist/types/auth/credentials-flow.d.ts +20 -0
- package/dist/types/auth/pairing/WaPairingFlow.d.ts +3 -2
- package/dist/types/auth/pairing/{WaPairingCodeCrypto.d.ts → pairing-code-crypto.d.ts} +6 -1
- package/dist/types/auth/types.d.ts +40 -0
- package/dist/types/client/WaClient.d.ts +19 -8
- package/dist/types/client/WaClientFactory.d.ts +10 -4
- package/dist/types/client/coordinators/WaAbPropsCoordinator.d.ts +26 -0
- package/dist/types/client/coordinators/WaBusinessCoordinator.d.ts +1 -1
- package/dist/types/client/coordinators/WaEmailCoordinator.d.ts +24 -0
- package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +6 -1
- package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +15 -2
- package/dist/types/client/coordinators/WaOfflineResumeCoordinator.d.ts +31 -0
- package/dist/types/client/coordinators/WaPassiveTasksCoordinator.d.ts +13 -2
- package/dist/types/client/coordinators/WaPrivacyCoordinator.d.ts +1 -1
- package/dist/types/client/coordinators/WaProfileCoordinator.d.ts +4 -2
- package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +6 -0
- package/dist/types/client/coordinators/WaTrustedContactTokenCoordinator.d.ts +11 -1
- package/dist/types/client/dirty.d.ts +3 -1
- package/dist/types/client/events/abprops.d.ts +14 -0
- package/dist/types/client/events/registration.d.ts +17 -0
- package/dist/types/client/incoming.d.ts +6 -1
- package/dist/types/client/mailbox.d.ts +2 -0
- package/dist/types/client/media.d.ts +31 -0
- package/dist/types/client/messages.d.ts +2 -0
- package/dist/types/client/persistence/WriteBehindPersistence.d.ts +1 -1
- package/dist/types/client/types.d.ts +100 -1
- package/dist/types/crypto/core/index.d.ts +1 -0
- package/dist/types/crypto/core/primitives.d.ts +1 -1
- package/dist/types/crypto/core/random.d.ts +1 -1
- package/dist/types/crypto/core/xeddsa.d.ts +2 -0
- package/dist/types/crypto/curves/constants.d.ts +1 -0
- package/dist/types/crypto/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/infra/log/ConsoleLogger.d.ts +1 -1
- package/dist/types/infra/log/PinoLogger.d.ts +1 -1
- package/dist/types/infra/perf/StoreLock.d.ts +1 -0
- package/dist/types/media/WaMediaCrypto.d.ts +15 -6
- package/dist/types/media/WaMediaTransferClient.d.ts +3 -11
- package/dist/types/media/constants.d.ts +2 -0
- package/dist/types/media/index.d.ts +1 -0
- package/dist/types/media/processor.d.ts +28 -0
- package/dist/types/media/types.d.ts +9 -3
- package/dist/types/message/addon-crypto.d.ts +34 -3
- package/dist/types/message/content.d.ts +3 -1
- package/dist/types/message/icdc.d.ts +4 -4
- package/dist/types/message/types.d.ts +16 -24
- package/dist/types/protocol/abprops.d.ts +142 -0
- package/dist/types/protocol/browser.d.ts +1 -0
- package/dist/types/protocol/constants.d.ts +5 -1
- package/dist/types/protocol/email.d.ts +32 -0
- package/dist/types/protocol/jid.d.ts +1 -0
- package/dist/types/protocol/nodes.d.ts +4 -0
- package/dist/types/protocol/notification.d.ts +6 -0
- package/dist/types/protocol/stream.d.ts +1 -0
- package/dist/types/retry/reason.d.ts +1 -1
- package/dist/types/signal/api/SignalDigestSyncApi.d.ts +3 -0
- package/dist/types/signal/api/SignalIdentitySyncApi.d.ts +3 -3
- package/dist/types/signal/crypto/WaAdvSignature.d.ts +0 -2
- package/dist/types/signal/crypto/constants.d.ts +0 -1
- package/dist/types/signal/encoding.d.ts +7 -1
- package/dist/types/signal/group/SenderKeyChain.d.ts +1 -1
- package/dist/types/signal/group/SenderKeyManager.d.ts +7 -2
- package/dist/types/signal/registration/utils.d.ts +2 -1
- package/dist/types/signal/session/SignalProtocol.d.ts +11 -2
- package/dist/types/signal/session/SignalSerializer.d.ts +2 -1
- package/dist/types/signal/session/resolver.d.ts +4 -2
- package/dist/types/signal/types.d.ts +16 -4
- package/dist/types/store/contracts/identity.store.d.ts +11 -0
- package/dist/types/store/contracts/message-secret.store.d.ts +16 -0
- package/dist/types/store/contracts/pre-key.store.d.ts +13 -0
- package/dist/types/store/contracts/session.store.d.ts +14 -0
- package/dist/types/store/contracts/signal.store.d.ts +1 -34
- package/dist/types/store/index.d.ts +9 -1
- package/dist/types/store/locks/identity.lock.d.ts +3 -0
- package/dist/types/store/locks/message-secret.lock.d.ts +3 -0
- package/dist/types/store/locks/pre-key.lock.d.ts +3 -0
- package/dist/types/store/locks/session.lock.d.ts +3 -0
- package/dist/types/store/noop.store.d.ts +4 -0
- package/dist/types/store/providers/memory/identity.store.d.ts +18 -0
- package/dist/types/store/providers/memory/message-secret.store.d.ts +21 -0
- package/dist/types/store/providers/memory/pre-key.store.d.ts +23 -0
- package/dist/types/store/providers/memory/retry.store.d.ts +7 -1
- package/dist/types/store/providers/memory/session.store.d.ts +21 -0
- package/dist/types/store/providers/memory/signal.store.d.ts +3 -45
- package/dist/types/store/providers/memory/thread.store.d.ts +1 -1
- package/dist/types/store/types.d.ts +21 -1
- package/dist/types/transport/WaWebSocket.d.ts +1 -0
- package/dist/types/transport/index.d.ts +8 -1
- package/dist/types/transport/keepalive/WaKeepAlive.d.ts +4 -1
- package/dist/types/transport/node/WaMobileTcpSocket.d.ts +18 -0
- package/dist/types/transport/node/WaNodeOrchestrator.d.ts +6 -2
- package/dist/types/transport/node/builders/abprops.d.ts +5 -0
- package/dist/types/transport/node/builders/device.d.ts +2 -0
- package/dist/types/transport/node/builders/email.d.ts +11 -0
- package/dist/types/transport/node/builders/offline.d.ts +2 -0
- package/dist/types/transport/node/builders/prekeys.d.ts +4 -3
- package/dist/types/transport/node/builders/presence.d.ts +6 -0
- package/dist/types/transport/node/helpers.d.ts +3 -0
- package/dist/types/transport/node/mex/argo-decoder.d.ts +11 -0
- package/dist/types/transport/node/mex/client.d.ts +18 -0
- package/dist/types/transport/node/mex/persist-ids.d.ts +14 -0
- package/dist/types/transport/noise/WaMobileClientPayload.d.ts +29 -0
- package/dist/types/transport/noise/WaNoiseCert.d.ts +7 -1
- package/dist/types/transport/noise/WaNoiseSession.d.ts +1 -0
- package/dist/types/transport/types.d.ts +8 -0
- package/package.json +6 -4
- package/dist/auth/pairing/constants.js +0 -5
- package/dist/client/connection/WaKeyShareCoordinator.js +0 -63
- package/dist/esm/auth/pairing/constants.js +0 -2
- package/dist/esm/client/connection/WaKeyShareCoordinator.js +0 -59
- package/dist/esm/transport/node/builders/index.js +0 -11
- package/dist/transport/node/builders/index.js +0 -51
- package/dist/types/auth/flow/WaAuthCredentialsFlow.d.ts +0 -14
- package/dist/types/auth/pairing/constants.d.ts +0 -2
- package/dist/types/client/connection/WaKeyShareCoordinator.d.ts +0 -14
- package/dist/types/transport/node/builders/index.d.ts +0 -11
- /package/dist/appstate/{WaAppStateSyncResponseParser.js → response-parser.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BinaryNode } from '../../transport/types';
|
|
2
|
+
export interface AbPropResponseEntry {
|
|
3
|
+
readonly configCode: number;
|
|
4
|
+
readonly configValue: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface AbPropSyncResult {
|
|
7
|
+
readonly abKey: string | null;
|
|
8
|
+
readonly hash: string | null;
|
|
9
|
+
readonly refresh: number | null;
|
|
10
|
+
readonly refreshId: number | null;
|
|
11
|
+
readonly isDeltaUpdate: boolean;
|
|
12
|
+
readonly props: readonly AbPropResponseEntry[];
|
|
13
|
+
}
|
|
14
|
+
export declare function parseAbPropsIqResult(node: BinaryNode): AbPropSyncResult;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BinaryNode } from '../../transport/types';
|
|
2
|
+
export interface ParsedRegistrationCode {
|
|
3
|
+
readonly kind: 'registration_code';
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly expiryTimestampMs: number;
|
|
6
|
+
readonly fromDeviceId: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ParsedAccountTakeoverNotice {
|
|
9
|
+
readonly kind: 'account_takeover_notice';
|
|
10
|
+
readonly serverToken: string;
|
|
11
|
+
readonly attemptTimestampMs: number;
|
|
12
|
+
readonly newDeviceName?: string;
|
|
13
|
+
readonly newDevicePlatform?: string;
|
|
14
|
+
readonly newDeviceAppVersion?: string;
|
|
15
|
+
}
|
|
16
|
+
export type ParsedRegistrationNotification = ParsedRegistrationCode | ParsedAccountTakeoverNotice | null;
|
|
17
|
+
export declare function parseRegistrationNotification(node: BinaryNode): ParsedRegistrationNotification;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WaIncomingBaseEvent, WaIncomingFailureEvent, WaIncomingNotificationEvent, WaIncomingReceiptEvent, WaIncomingUnhandledStanzaEvent,
|
|
1
|
+
import type { WaAccountTakeoverNoticeEvent, WaGroupEvent, WaIncomingBaseEvent, WaIncomingFailureEvent, WaIncomingNotificationEvent, WaIncomingReceiptEvent, WaIncomingUnhandledStanzaEvent, WaRegistrationCodeEvent } from './types';
|
|
2
2
|
import type { Logger } from '../infra/log/types';
|
|
3
3
|
import type { WaConnectionCode, WaDisconnectReason } from '../protocol/stream';
|
|
4
4
|
import type { BinaryNode } from '../transport/types';
|
|
@@ -27,10 +27,15 @@ type IncomingGroupNotificationHandlerOptions = IncomingAckRuntime & {
|
|
|
27
27
|
readonly emitGroupEvent: (event: WaGroupEvent) => void;
|
|
28
28
|
readonly emitUnhandledStanza: (event: WaIncomingUnhandledStanzaEvent) => void;
|
|
29
29
|
};
|
|
30
|
+
type IncomingRegistrationNotificationHandlerOptions = IncomingAckRuntime & {
|
|
31
|
+
readonly emitRegistrationCode: (event: WaRegistrationCodeEvent) => void;
|
|
32
|
+
readonly emitAccountTakeoverNotice: (event: WaAccountTakeoverNoticeEvent) => void;
|
|
33
|
+
};
|
|
30
34
|
export declare function createIncomingBaseEvent(node: BinaryNode): WaIncomingBaseEvent;
|
|
31
35
|
export declare function createIncomingReceiptHandler(options: IncomingReceiptHandlerOptions): (node: BinaryNode) => Promise<boolean>;
|
|
32
36
|
export declare function createIncomingFailureHandler(options: IncomingFailureHandlerOptions): (node: BinaryNode) => Promise<boolean>;
|
|
33
37
|
export declare function createIncomingNotificationHandler(options: IncomingNotificationHandlerOptions): (node: BinaryNode) => Promise<boolean>;
|
|
38
|
+
export declare function createIncomingRegistrationNotificationHandler(options: IncomingRegistrationNotificationHandlerOptions): (node: BinaryNode) => Promise<boolean>;
|
|
34
39
|
export declare function createIncomingGroupNotificationHandler(options: IncomingGroupNotificationHandlerOptions): (node: BinaryNode) => Promise<boolean>;
|
|
35
40
|
export declare function createInfoBulletinNotificationEvent(node: BinaryNode, type: string, details?: Readonly<Record<string, unknown>>): WaIncomingNotificationEvent;
|
|
36
41
|
export declare function createUnhandledIncomingNodeEvent(node: BinaryNode, reason?: string): WaIncomingUnhandledStanzaEvent;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { WriteBehindPersistence } from './persistence/WriteBehindPersistence';
|
|
2
2
|
import type { WaIncomingMessageEvent } from './types';
|
|
3
3
|
import type { Logger } from '../infra/log/types';
|
|
4
|
+
import type { WaMessageSecretStore } from '../store/contracts/message-secret.store';
|
|
4
5
|
interface WaPersistIncomingMailboxOptions {
|
|
5
6
|
readonly logger: Logger;
|
|
6
7
|
readonly writeBehind: WriteBehindPersistence;
|
|
8
|
+
readonly messageSecretStore: WaMessageSecretStore;
|
|
7
9
|
readonly event: WaIncomingMessageEvent;
|
|
8
10
|
}
|
|
9
11
|
export declare function persistIncomingMailboxEntities(options: WaPersistIncomingMailboxOptions): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { WaMediaOptions } from './types';
|
|
3
|
+
import type { Logger } from '../infra/log/types';
|
|
4
|
+
import type { WaSendMediaMessage } from '../message/types';
|
|
5
|
+
export interface ProcessedMediaFields {
|
|
6
|
+
readonly jpegThumbnail?: Uint8Array;
|
|
7
|
+
readonly pngThumbnail?: Uint8Array;
|
|
8
|
+
readonly width?: number;
|
|
9
|
+
readonly height?: number;
|
|
10
|
+
readonly seconds?: number;
|
|
11
|
+
readonly waveform?: Uint8Array;
|
|
12
|
+
readonly isAnimated?: boolean;
|
|
13
|
+
readonly firstFrameLength?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function readFileHead(filePath: string, bytes: number): Promise<Uint8Array>;
|
|
16
|
+
interface WebpAnimInfo {
|
|
17
|
+
readonly isAnimated: true;
|
|
18
|
+
readonly firstFrameLength: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseWebpAnimation(data: Uint8Array): WebpAnimInfo | null;
|
|
21
|
+
export declare function isReadableStream(value: unknown): value is Readable;
|
|
22
|
+
export declare function cleanupTempFile(filePath: string): Promise<void>;
|
|
23
|
+
export interface ResolvedMediaInputs {
|
|
24
|
+
readonly processorInput?: Uint8Array | string;
|
|
25
|
+
readonly uploadMedia: Uint8Array | Readable;
|
|
26
|
+
readonly tempFilePath?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function resolveMediaInputs(shouldProcess: boolean, raw: Uint8Array | ArrayBuffer | Readable | string): Promise<ResolvedMediaInputs>;
|
|
29
|
+
export declare function hasMediaProcessingTasks(media: WaMediaOptions | undefined, content: WaSendMediaMessage): boolean;
|
|
30
|
+
export declare function runMediaProcessor(media: WaMediaOptions | undefined, input: Uint8Array | string | undefined, content: WaSendMediaMessage, logger: Logger): Promise<ProcessedMediaFields>;
|
|
31
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WaMediaOptions } from './types';
|
|
1
2
|
import type { Logger } from '../infra/log/types';
|
|
2
3
|
import type { WaMediaConn } from '../media/types';
|
|
3
4
|
import type { WaMediaTransferClient } from '../media/WaMediaTransferClient';
|
|
@@ -11,6 +12,7 @@ export interface WaMediaMessageOptions {
|
|
|
11
12
|
readonly queryWithContext: (context: string, node: BinaryNode, timeoutMs?: number, contextData?: Readonly<Record<string, unknown>>) => Promise<BinaryNode>;
|
|
12
13
|
readonly getMediaConnCache: () => WaMediaConn | null;
|
|
13
14
|
readonly setMediaConnCache: (mediaConn: WaMediaConn | null) => void;
|
|
15
|
+
readonly media?: WaMediaOptions;
|
|
14
16
|
}
|
|
15
17
|
export declare function buildMediaMessageContent(options: WaMediaMessageOptions, content: WaSendMessageContent): Promise<Proto.IMessage>;
|
|
16
18
|
export declare function getMediaConn(options: WaMediaMessageOptions, forceRefresh?: boolean): Promise<WaMediaConn>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WaWriteBehindOptions } from '../types';
|
|
2
2
|
import type { Logger } from '../../infra/log/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type BackgroundQueueFlushResult } from '../../infra/perf/BackgroundQueue';
|
|
4
4
|
import type { WaContactStore, WaStoredContactRecord } from '../../store/contracts/contact.store';
|
|
5
5
|
import type { WaMessageStore, WaStoredMessageRecord } from '../../store/contracts/message.store';
|
|
6
6
|
import type { WaStoredThreadRecord, WaThreadStore } from '../../store/contracts/thread.store';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AppStateCollectionName } from '../appstate/types';
|
|
2
|
-
import type { WaAuthClientOptions, WaAuthCredentials, WaAuthSocketOptions } from '../auth/types';
|
|
2
|
+
import type { WaAuthClientOptions, WaAuthCredentials, WaAuthDangerousOptions, WaAuthSocketOptions } from '../auth/types';
|
|
3
|
+
import type { WaMediaProcessor } from '../media/processor';
|
|
4
|
+
import type { WaDecodedAddon } from '../message/addon-crypto';
|
|
3
5
|
import type { WaMessagePublishOptions } from '../message/types';
|
|
4
6
|
import type { Proto } from '..';
|
|
5
7
|
import type { WaConnectionCode, WaConnectionOpenReason, WaDisconnectReason } from '../protocol/stream';
|
|
@@ -13,12 +15,16 @@ export interface WaClientProxyOptions {
|
|
|
13
15
|
export interface WaLogoutStoreClearOptions {
|
|
14
16
|
readonly auth?: boolean;
|
|
15
17
|
readonly signal?: boolean;
|
|
18
|
+
readonly preKey?: boolean;
|
|
19
|
+
readonly session?: boolean;
|
|
20
|
+
readonly identity?: boolean;
|
|
16
21
|
readonly senderKey?: boolean;
|
|
17
22
|
readonly appState?: boolean;
|
|
18
23
|
readonly retry?: boolean;
|
|
19
24
|
readonly participants?: boolean;
|
|
20
25
|
readonly deviceList?: boolean;
|
|
21
26
|
readonly messages?: boolean;
|
|
27
|
+
readonly messageSecret?: boolean;
|
|
22
28
|
readonly threads?: boolean;
|
|
23
29
|
readonly contacts?: boolean;
|
|
24
30
|
readonly privacyToken?: boolean;
|
|
@@ -44,7 +50,70 @@ export interface WaClientOptions extends WaAuthClientOptions, WaAuthSocketOption
|
|
|
44
50
|
readonly emitSnapshotMutations?: boolean;
|
|
45
51
|
};
|
|
46
52
|
readonly privacyToken?: WaPrivacyTokenOptions;
|
|
53
|
+
readonly addons?: WaAddonOptions;
|
|
47
54
|
readonly logoutStoreClear?: WaLogoutStoreClearOptions;
|
|
55
|
+
readonly media?: WaMediaOptions;
|
|
56
|
+
/**
|
|
57
|
+
* Test-only overrides intended for running against a fake server.
|
|
58
|
+
*
|
|
59
|
+
* These hooks **do not** bypass any security checks — they only swap in
|
|
60
|
+
* test fixtures (e.g. a different root CA) so the full verification code
|
|
61
|
+
* path still runs end-to-end. If you actually need to skip a check, use
|
|
62
|
+
* `dangerous` instead.
|
|
63
|
+
*/
|
|
64
|
+
readonly testHooks?: WaClientTestHooks;
|
|
65
|
+
/**
|
|
66
|
+
* Dangerous escape hatches. **Do not enable in production.** Each flag here
|
|
67
|
+
* disables a security check the production code path enforces.
|
|
68
|
+
*/
|
|
69
|
+
readonly dangerous?: WaClientDangerousOptions;
|
|
70
|
+
}
|
|
71
|
+
export interface WaClientDangerousOptions extends WaAuthDangerousOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Skip the XEdDSA signature check on incoming group sender-key messages.
|
|
74
|
+
* Ciphertexts will be decrypted even if the trailing signature does not
|
|
75
|
+
* verify against the stored sender signing public key.
|
|
76
|
+
*/
|
|
77
|
+
readonly disableSenderKeySignatureVerification?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Skip HMAC verification across the app-state sync pipeline: per-mutation
|
|
80
|
+
* value and index MACs, snapshot MACs, and patch MACs. Tampered server
|
|
81
|
+
* payloads will be accepted as long as the ciphertext decrypts cleanly.
|
|
82
|
+
*/
|
|
83
|
+
readonly disableAppStateMacVerification?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Skip the truncated HMAC-SHA256 check on encrypted media payloads
|
|
86
|
+
* during download. Tampered ciphertexts will still be decrypted.
|
|
87
|
+
*/
|
|
88
|
+
readonly disableMediaMacVerification?: boolean;
|
|
89
|
+
}
|
|
90
|
+
export interface WaClientTestHooks {
|
|
91
|
+
/**
|
|
92
|
+
* Override the noise certificate-chain root CA used to verify the
|
|
93
|
+
* server's static key during the handshake.
|
|
94
|
+
*
|
|
95
|
+
* The default is the production WhatsApp root. Tests against a fake
|
|
96
|
+
* server inject the fake server's ephemeral root here so that the lib
|
|
97
|
+
* still runs the full certificate-verification code path against a
|
|
98
|
+
* chain signed by a known key — no validation logic is bypassed.
|
|
99
|
+
*/
|
|
100
|
+
readonly noiseRootCa?: WaNoiseRootCaOverride;
|
|
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;
|
|
107
|
+
}
|
|
108
|
+
export interface WaMediaOptions {
|
|
109
|
+
readonly processor?: WaMediaProcessor;
|
|
110
|
+
readonly generateThumbnail?: boolean;
|
|
111
|
+
readonly generateProbe?: boolean;
|
|
112
|
+
readonly generateWaveform?: boolean;
|
|
113
|
+
readonly generateStickerThumbnail?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface WaAddonOptions {
|
|
116
|
+
readonly autoDecrypt?: boolean;
|
|
48
117
|
}
|
|
49
118
|
export interface WaPrivacyTokenOptions {
|
|
50
119
|
readonly tcTokenDurationS?: number;
|
|
@@ -136,6 +205,26 @@ export interface WaIncomingNotificationEvent extends WaIncomingBaseEvent {
|
|
|
136
205
|
readonly classification?: 'core' | 'out_of_scope' | 'unknown' | 'info_bulletin';
|
|
137
206
|
readonly details?: Readonly<Record<string, unknown>>;
|
|
138
207
|
}
|
|
208
|
+
export interface WaRegistrationCodeEvent extends WaIncomingBaseEvent {
|
|
209
|
+
readonly code: string;
|
|
210
|
+
readonly expiryTimestampMs: number;
|
|
211
|
+
readonly fromDeviceId: string;
|
|
212
|
+
}
|
|
213
|
+
export interface WaAccountTakeoverNoticeEvent extends WaIncomingBaseEvent {
|
|
214
|
+
readonly serverToken: string;
|
|
215
|
+
readonly attemptTimestampMs: number;
|
|
216
|
+
readonly newDeviceName?: string;
|
|
217
|
+
readonly newDevicePlatform?: string;
|
|
218
|
+
readonly newDeviceAppVersion?: string;
|
|
219
|
+
}
|
|
220
|
+
export type WaAddonKind = 'reaction' | 'poll_vote' | 'event_response' | 'comment';
|
|
221
|
+
export interface WaIncomingAddonEvent extends WaIncomingBaseEvent {
|
|
222
|
+
readonly kind: WaAddonKind;
|
|
223
|
+
readonly targetMessageId: string;
|
|
224
|
+
readonly senderJid: string;
|
|
225
|
+
readonly decrypted: WaDecodedAddon;
|
|
226
|
+
readonly raw: Proto.IMessage;
|
|
227
|
+
}
|
|
139
228
|
export interface WaIncomingFailureEvent extends WaIncomingBaseEvent {
|
|
140
229
|
readonly failureReason?: number;
|
|
141
230
|
readonly failureCode?: number;
|
|
@@ -284,12 +373,15 @@ export interface WaClientEventMap {
|
|
|
284
373
|
readonly frame: Uint8Array;
|
|
285
374
|
}) => void;
|
|
286
375
|
readonly message: (event: WaIncomingMessageEvent) => void;
|
|
376
|
+
readonly message_addon: (event: WaIncomingAddonEvent) => void;
|
|
287
377
|
readonly message_protocol: (event: WaIncomingProtocolMessageEvent) => void;
|
|
288
378
|
readonly message_receipt: (event: WaIncomingReceiptEvent) => void;
|
|
289
379
|
readonly presence: (event: WaIncomingPresenceEvent) => void;
|
|
290
380
|
readonly chatstate: (event: WaIncomingChatstateEvent) => void;
|
|
291
381
|
readonly call: (event: WaIncomingCallEvent) => void;
|
|
292
382
|
readonly notification: (event: WaIncomingNotificationEvent) => void;
|
|
383
|
+
readonly registration_code_received: (event: WaRegistrationCodeEvent) => void;
|
|
384
|
+
readonly account_takeover_notice: (event: WaAccountTakeoverNoticeEvent) => void;
|
|
293
385
|
readonly failure: (event: WaIncomingFailureEvent) => void;
|
|
294
386
|
readonly stanza_error: (event: WaIncomingBaseEvent) => void;
|
|
295
387
|
readonly stanza_unhandled: (event: WaIncomingUnhandledStanzaEvent) => void;
|
|
@@ -297,6 +389,13 @@ export interface WaClientEventMap {
|
|
|
297
389
|
readonly chat_event: (event: WaChatEvent) => void;
|
|
298
390
|
readonly history_sync_chunk: (event: WaHistorySyncChunkEvent) => void;
|
|
299
391
|
readonly privacy_token_update: (event: WaPrivacyTokenUpdateEvent) => void;
|
|
392
|
+
readonly offline_resume: (event: WaOfflineResumeEvent) => void;
|
|
393
|
+
}
|
|
394
|
+
export interface WaOfflineResumeEvent {
|
|
395
|
+
readonly status: 'resuming' | 'complete';
|
|
396
|
+
readonly totalStanzas: number;
|
|
397
|
+
readonly remainingStanzas: number;
|
|
398
|
+
readonly forced: boolean;
|
|
300
399
|
}
|
|
301
400
|
export interface WaPrivacyTokenUpdateEvent {
|
|
302
401
|
readonly jid: string;
|
|
@@ -8,3 +8,4 @@ export { toSerializedPubKey, toRawPubKey, prependVersion, readVersionedContent }
|
|
|
8
8
|
export { buildNonce } from '../core/nonce';
|
|
9
9
|
export { randomBytesAsync, randomFillAsync, randomIntAsync } from '../core/random';
|
|
10
10
|
export { type CryptoKey, sha1, sha256, sha512, importAesGcmKey, aesGcmEncrypt, aesGcmDecrypt, importAesCbcKey, aesCbcEncrypt, aesCbcDecrypt, importHmacKey, importHmacSha512Key, hmacSign, pbkdf2DeriveAesCtrKey, aesCtrEncrypt, aesCtrDecrypt } from '../core/primitives';
|
|
11
|
+
export { xeddsaSign, xeddsaVerify } from '../core/xeddsa';
|
|
@@ -9,7 +9,7 @@ export type CryptoKey = webcrypto.CryptoKey;
|
|
|
9
9
|
export declare function sha256(value: Uint8Array): Promise<Uint8Array>;
|
|
10
10
|
export declare function sha1(value: Uint8Array): Promise<Uint8Array>;
|
|
11
11
|
export declare function sha512(value: Uint8Array): Promise<Uint8Array>;
|
|
12
|
-
export declare function md5Bytes(input: string): Uint8Array;
|
|
12
|
+
export declare function md5Bytes(input: string | Uint8Array): Uint8Array;
|
|
13
13
|
export declare function importAesGcmKey(raw: Uint8Array, usages: ('encrypt' | 'decrypt')[]): Promise<webcrypto.CryptoKey>;
|
|
14
14
|
export declare function aesGcmEncrypt(key: webcrypto.CryptoKey, nonce: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
15
15
|
export declare function aesGcmDecrypt(key: webcrypto.CryptoKey, nonce: Uint8Array, ciphertext: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function randomBytesAsync(size: number): Promise<Uint8Array>;
|
|
2
1
|
export declare function randomFillAsync(target: Uint8Array, offset?: number, size?: number): Promise<Uint8Array>;
|
|
3
2
|
export declare const randomIntAsync: (min: number, max: number) => Promise<number>;
|
|
3
|
+
export declare const randomBytesAsync: (size: number) => Promise<Uint8Array>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { WaClient } from '@client';
|
|
2
2
|
export type { WaClientEventMap, WaClientOptions, WaClientProxyOptions, WaHistorySyncChunkEvent, WaHistorySyncOptions, WaWriteBehindOptions } from '@client';
|
|
3
3
|
export type { WaBlocklistResult, WaPrivacyCoordinator, WaPrivacyDisallowedListResult, WaPrivacySettings } from './client/coordinators/WaPrivacyCoordinator';
|
|
4
|
+
export type { WaAuthCredentials } from './auth/types';
|
|
4
5
|
export { ConsoleLogger } from './infra/log/ConsoleLogger';
|
|
5
6
|
export { PinoLogger, createPinoLogger } from './infra/log/PinoLogger';
|
|
6
7
|
export type { PinoLoggerOptions } from './infra/log/PinoLogger';
|
|
7
8
|
export type { Logger, LogLevel } from './infra/log/types';
|
|
8
9
|
export { createStore } from '@store';
|
|
9
|
-
export type { WaAppStateCollectionStoreState, WaAppStateStore, WaAuthStore, WaContactStore, WaCreateStoreOptions, WaDeviceListSnapshot, WaDeviceListStore, WaMessageStore, WaParticipantsSnapshot, WaParticipantsStore, WaRetryStore, WaSenderKeyStore, WaSignalStore, WaStoredContactRecord, WaStoredMessageRecord, WaStoredThreadRecord, WaStore, WaStoreBackend, WaStoreSession, WaThreadStore } from '@store';
|
|
10
|
+
export type { WaAppStateCollectionStoreState, WaAppStateStore, WaAuthStore, WaContactStore, WaCreateStoreOptions, WaDeviceListSnapshot, WaDeviceListStore, WaMessageStore, WaParticipantsSnapshot, WaParticipantsStore, WaRetryStore, WaSenderKeyStore, WaSessionStore, WaSignalStore, WaIdentityStore, WaPreKeyStore, WaStoredContactRecord, WaStoredMessageRecord, WaStoredThreadRecord, WaStore, WaStoreBackend, WaStoreSession, WaThreadStore } from '@store';
|
|
10
11
|
export { getLoginIdentity, getWaCompanionPlatformId, getWaMediaHkdfInfo, isGroupJid, normalizeDeviceJid, normalizeRecipientJid, parsePhoneJid, parseSignalAddressFromJid, splitJid, toUserJid, WA_ACCOUNT_SYNC_PROTOCOLS, WA_APP_STATE_COLLECTIONS, WA_APP_STATE_COLLECTION_STATES, WA_APP_STATE_ERROR_CODES, WA_APP_STATE_KDF_INFO, WA_APP_STATE_KEY_TYPES, WA_APP_STATE_SYNC_DATA_TYPE, WA_BROWSERS, WA_COMPANION_PLATFORM_IDS, WA_DEFAULTS, WA_DIRTY_PROTOCOLS, WA_DIRTY_TYPES, WA_DISCONNECT_REASONS, WA_IQ_TYPES, WA_LOGOUT_REASONS, WA_MESSAGE_TAGS, WA_MESSAGE_TYPES, WA_MEDIA_HKDF_INFO, WA_NODE_TAGS, WA_PAIRING_KDF_INFO, WA_PREVIEW_MEDIA_HKDF_INFO, WA_READY_STATES, WA_RETRYABLE_ACK_CODES, WA_SIGNALING, WA_STREAM_SIGNALING, WA_SUPPORTED_DIRTY_TYPES, WA_PRIVACY_CATEGORIES, WA_PRIVACY_CATEGORY_TO_SETTING, WA_PRIVACY_DISALLOWED_LIST_CATEGORIES, WA_PRIVACY_SETTING_TO_CATEGORY, WA_PRIVACY_TAGS, WA_PRIVACY_VALUES, WA_XMLNS } from '@protocol';
|
|
11
12
|
export type { WaPrivacyCategory, WaPrivacySettingName, WaPrivacyValue } from '@protocol';
|
|
12
13
|
export { proto } from '.';
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { MediaCryptoType,
|
|
1
|
+
import { type Readable } from 'node:stream';
|
|
2
|
+
import type { MediaCryptoType, WaMediaDecryptionResult, WaMediaDecryptReadableOptions, WaMediaDerivedKeys, WaMediaEncryptionResult, WaMediaFileEncryptionResult, WaMediaReadableDecryptionResult, WaMediaReadableEncryptionResult } from './types';
|
|
3
3
|
export declare class WaMediaCrypto {
|
|
4
4
|
static generateMediaKey(): Promise<Uint8Array>;
|
|
5
5
|
static deriveKeys(mediaType: MediaCryptoType, mediaKey: Uint8Array): Promise<WaMediaDerivedKeys>;
|
|
6
|
-
static encryptBytes(mediaType: MediaCryptoType, mediaKey: Uint8Array, plaintext: Uint8Array
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
static encryptBytes(mediaType: MediaCryptoType, mediaKey: Uint8Array, plaintext: Uint8Array, options?: {
|
|
7
|
+
readonly sidecar?: boolean;
|
|
8
|
+
readonly firstFrameLength?: number;
|
|
9
|
+
}): Promise<WaMediaEncryptionResult>;
|
|
10
|
+
static decryptBytes(mediaType: MediaCryptoType, mediaKey: Uint8Array, ciphertextHmac: Uint8Array, expectedFileSha256?: Uint8Array, expectedFileEncSha256?: Uint8Array, skipMacVerification?: boolean): Promise<WaMediaDecryptionResult>;
|
|
11
|
+
static encryptReadable(mediaType: MediaCryptoType, mediaKey: Uint8Array, plaintext: Readable, options?: {
|
|
12
|
+
readonly sidecar?: boolean;
|
|
13
|
+
readonly firstFrameLength?: number;
|
|
14
|
+
}): Promise<WaMediaReadableEncryptionResult>;
|
|
15
|
+
static encryptToFile(mediaType: MediaCryptoType, mediaKey: Uint8Array, plaintext: Readable, options?: {
|
|
16
|
+
readonly sidecar?: boolean;
|
|
17
|
+
readonly firstFrameLength?: number;
|
|
18
|
+
}): Promise<WaMediaFileEncryptionResult>;
|
|
10
19
|
static cleanupEncryptedFile(filePath: string): Promise<void>;
|
|
11
20
|
static decryptReadable(encrypted: Readable, options: WaMediaDecryptReadableOptions): Promise<WaMediaReadableDecryptionResult>;
|
|
12
21
|
static encryptedLength(plaintextLength: number): number;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
2
|
import type { MediaCryptoType, WaMediaReadableDecryptionResult, WaMediaTransferClientOptions } from './types';
|
|
3
3
|
interface StreamDownloadRequest {
|
|
4
4
|
readonly url?: string;
|
|
5
5
|
readonly directPath?: string;
|
|
6
6
|
readonly hosts?: readonly string[];
|
|
7
7
|
readonly headers?: Readonly<Record<string, string>>;
|
|
8
|
-
readonly dispatcher?: WaMediaTransferClientOptions['defaultDownloadDispatcher'];
|
|
9
8
|
readonly agent?: WaMediaTransferClientOptions['defaultDownloadAgent'];
|
|
10
9
|
readonly timeoutMs?: number;
|
|
11
10
|
readonly signal?: AbortSignal;
|
|
@@ -51,11 +50,9 @@ export declare class WaMediaTransferClient {
|
|
|
51
50
|
private readonly defaultTimeoutMs;
|
|
52
51
|
private readonly defaultMaxReadBytes;
|
|
53
52
|
private readonly defaultHeaders;
|
|
54
|
-
private readonly defaultUploadDispatcher;
|
|
55
|
-
private readonly defaultDownloadDispatcher;
|
|
56
53
|
private readonly defaultUploadAgent;
|
|
57
54
|
private readonly defaultDownloadAgent;
|
|
58
|
-
private
|
|
55
|
+
private readonly skipMacVerification;
|
|
59
56
|
constructor(options?: WaMediaTransferClientOptions);
|
|
60
57
|
downloadStream(request: StreamDownloadRequest): Promise<StreamTransferResponse>;
|
|
61
58
|
downloadBytes(request: StreamDownloadRequest): Promise<Uint8Array>;
|
|
@@ -64,12 +61,7 @@ export declare class WaMediaTransferClient {
|
|
|
64
61
|
downloadAndDecrypt(request: EncryptedDownloadRequest): Promise<Uint8Array>;
|
|
65
62
|
downloadAndDecryptStream(request: EncryptedDownloadRequest): Promise<WaMediaReadableDecryptionResult>;
|
|
66
63
|
readResponseBytes(response: StreamTransferResponse, maxBytes?: number): Promise<Uint8Array>;
|
|
67
|
-
private
|
|
68
|
-
private fetchWithDispatcher;
|
|
69
|
-
private toFetchTransferResponse;
|
|
70
|
-
private gotWithAgent;
|
|
71
|
-
private loadGotModule;
|
|
72
|
-
private toGotTransferResponse;
|
|
64
|
+
private httpRequest;
|
|
73
65
|
private resolveTransferRequest;
|
|
74
66
|
private prepareEncryptedUpload;
|
|
75
67
|
private assertSuccessfulResponse;
|
|
@@ -7,4 +7,6 @@ export declare const ENC_KEY_END = 48;
|
|
|
7
7
|
export declare const MAC_KEY_START = 48;
|
|
8
8
|
export declare const MAC_KEY_END = 80;
|
|
9
9
|
export declare const HMAC_TRUNCATED_SIZE = 10;
|
|
10
|
+
export declare const SIDECAR_CHUNK_SIZE = 65536;
|
|
11
|
+
export declare const SIDECAR_HMAC_SIZE = 10;
|
|
10
12
|
export declare const MEDIA_UPLOAD_PATHS: Readonly<Record<'image' | 'video' | 'audio' | 'document' | 'sticker' | 'gif' | 'ptt' | 'ptv', string>>;
|
|
@@ -2,3 +2,4 @@ export { WaMediaTransferClient } from './WaMediaTransferClient';
|
|
|
2
2
|
export { parseMediaConnResponse } from './conn';
|
|
3
3
|
export type { WaMediaConn } from './types';
|
|
4
4
|
export { WaMediaCrypto } from './WaMediaCrypto';
|
|
5
|
+
export type { WaMediaProcessor, WaMediaProcessorImageResult, WaMediaProcessorInput, WaMediaProcessorProbeResult, WaMediaProcessorStickerThumbnailResult, WaMediaProcessorWaveformResult } from './processor';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
export interface WaMediaProcessorImageResult {
|
|
3
|
+
readonly jpegThumbnail: Uint8Array;
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface WaMediaProcessorStickerThumbnailResult {
|
|
8
|
+
readonly pngThumbnail: Uint8Array;
|
|
9
|
+
readonly width: number;
|
|
10
|
+
readonly height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface WaMediaProcessorProbeResult {
|
|
13
|
+
readonly durationSeconds?: number;
|
|
14
|
+
readonly width?: number;
|
|
15
|
+
readonly height?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface WaMediaProcessorWaveformResult {
|
|
18
|
+
readonly waveform: Uint8Array;
|
|
19
|
+
readonly durationSeconds: number;
|
|
20
|
+
}
|
|
21
|
+
export type WaMediaProcessorInput = Uint8Array | Readable | string;
|
|
22
|
+
export interface WaMediaProcessor {
|
|
23
|
+
readonly generateImageThumbnail?: (input: WaMediaProcessorInput, maxEdge: number) => Promise<WaMediaProcessorImageResult>;
|
|
24
|
+
readonly generateVideoThumbnail?: (input: WaMediaProcessorInput, maxEdge: number) => Promise<WaMediaProcessorImageResult | null>;
|
|
25
|
+
readonly probeMedia?: (input: WaMediaProcessorInput) => Promise<WaMediaProcessorProbeResult>;
|
|
26
|
+
readonly computeWaveform?: (input: WaMediaProcessorInput) => Promise<WaMediaProcessorWaveformResult | null>;
|
|
27
|
+
readonly generateStickerThumbnail?: (input: WaMediaProcessorInput, maxEdge: number) => Promise<WaMediaProcessorStickerThumbnailResult>;
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
2
|
import type { Logger } from '../infra/log/types';
|
|
3
|
-
import type { WaProxyAgent
|
|
3
|
+
import type { WaProxyAgent } from '../transport/types';
|
|
4
4
|
export type MediaKind = 'image' | 'video' | 'audio' | 'document' | 'sticker' | 'ptv';
|
|
5
5
|
export type MediaCryptoType = MediaKind | 'ptt' | 'gif' | 'history' | 'md-app-state';
|
|
6
6
|
export interface WaMediaConnHost {
|
|
@@ -18,10 +18,9 @@ export interface WaMediaTransferClientOptions {
|
|
|
18
18
|
readonly defaultTimeoutMs?: number;
|
|
19
19
|
readonly defaultMaxReadBytes?: number;
|
|
20
20
|
readonly defaultHeaders?: Readonly<Record<string, string>>;
|
|
21
|
-
readonly defaultUploadDispatcher?: WaProxyDispatcher;
|
|
22
|
-
readonly defaultDownloadDispatcher?: WaProxyDispatcher;
|
|
23
21
|
readonly defaultUploadAgent?: WaProxyAgent;
|
|
24
22
|
readonly defaultDownloadAgent?: WaProxyAgent;
|
|
23
|
+
readonly skipMacVerification?: boolean;
|
|
25
24
|
}
|
|
26
25
|
export interface WaMediaDerivedKeys {
|
|
27
26
|
readonly iv: Uint8Array;
|
|
@@ -33,6 +32,8 @@ export interface WaMediaEncryptionResult {
|
|
|
33
32
|
readonly ciphertextHmac: Uint8Array;
|
|
34
33
|
readonly fileSha256: Uint8Array;
|
|
35
34
|
readonly fileEncSha256: Uint8Array;
|
|
35
|
+
readonly streamingSidecar?: Uint8Array;
|
|
36
|
+
readonly firstFrameSidecar?: Uint8Array;
|
|
36
37
|
}
|
|
37
38
|
export interface WaMediaDecryptionResult {
|
|
38
39
|
readonly plaintext: Uint8Array;
|
|
@@ -45,6 +46,8 @@ export interface WaMediaReadableEncryptionResult {
|
|
|
45
46
|
readonly fileSha256: Uint8Array;
|
|
46
47
|
readonly fileEncSha256: Uint8Array;
|
|
47
48
|
readonly plaintextLength: number;
|
|
49
|
+
readonly streamingSidecar?: Uint8Array;
|
|
50
|
+
readonly firstFrameSidecar?: Uint8Array;
|
|
48
51
|
}>;
|
|
49
52
|
}
|
|
50
53
|
export interface WaMediaReadableDecryptionResult {
|
|
@@ -60,10 +63,13 @@ export interface WaMediaFileEncryptionResult {
|
|
|
60
63
|
readonly fileSha256: Uint8Array;
|
|
61
64
|
readonly fileEncSha256: Uint8Array;
|
|
62
65
|
readonly plaintextLength: number;
|
|
66
|
+
readonly streamingSidecar?: Uint8Array;
|
|
67
|
+
readonly firstFrameSidecar?: Uint8Array;
|
|
63
68
|
}
|
|
64
69
|
export interface WaMediaDecryptReadableOptions {
|
|
65
70
|
readonly mediaType: MediaCryptoType;
|
|
66
71
|
readonly mediaKey: Uint8Array;
|
|
67
72
|
readonly expectedFileSha256?: Uint8Array;
|
|
68
73
|
readonly expectedFileEncSha256?: Uint8Array;
|
|
74
|
+
readonly skipMacVerification?: boolean;
|
|
69
75
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import type { WaAddonKind } from '../client/types';
|
|
1
2
|
import { WA_USE_CASE_SECRET_MODIFICATION_TYPES } from './use-case-secret';
|
|
3
|
+
import { type Proto } from '..';
|
|
4
|
+
import type { WaMessageSecretEntry, WaMessageSecretStore } from '../store/contracts/message-secret.store';
|
|
5
|
+
import type { WaMessageStore } from '../store/contracts/message.store';
|
|
2
6
|
type WaAddonBytes = Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
3
|
-
|
|
7
|
+
type ModificationType = (typeof WA_USE_CASE_SECRET_MODIFICATION_TYPES)[keyof typeof WA_USE_CASE_SECRET_MODIFICATION_TYPES];
|
|
8
|
+
export declare function shouldUseAddonAdditionalData(modificationType: ModificationType): boolean;
|
|
4
9
|
export declare function buildAddonAdditionalData(stanzaId: string, addOnSenderJid: string): Uint8Array;
|
|
5
10
|
export declare function encryptAddonPayload(input: {
|
|
6
11
|
readonly messageSecret: WaAddonBytes;
|
|
7
12
|
readonly stanzaId: string;
|
|
8
13
|
readonly parentMsgOriginalSender: string;
|
|
9
14
|
readonly modificationSender: string;
|
|
10
|
-
readonly modificationType:
|
|
15
|
+
readonly modificationType: ModificationType;
|
|
11
16
|
readonly payload: WaAddonBytes;
|
|
12
17
|
readonly iv: WaAddonBytes;
|
|
13
18
|
readonly additionalData?: WaAddonBytes;
|
|
@@ -17,9 +22,35 @@ export declare function decryptAddonPayload(input: {
|
|
|
17
22
|
readonly stanzaId: string;
|
|
18
23
|
readonly parentMsgOriginalSender: string;
|
|
19
24
|
readonly modificationSender: string;
|
|
20
|
-
readonly modificationType:
|
|
25
|
+
readonly modificationType: ModificationType;
|
|
21
26
|
readonly ciphertext: WaAddonBytes;
|
|
22
27
|
readonly iv: WaAddonBytes;
|
|
23
28
|
readonly additionalData?: WaAddonBytes;
|
|
24
29
|
}): Promise<Uint8Array>;
|
|
30
|
+
export interface WaIdentifiedEncAddon {
|
|
31
|
+
readonly kind: WaAddonKind;
|
|
32
|
+
readonly targetMessageKey: Proto.IMessageKey;
|
|
33
|
+
readonly encPayload: Uint8Array;
|
|
34
|
+
readonly encIv: Uint8Array;
|
|
35
|
+
readonly modificationType: ModificationType;
|
|
36
|
+
readonly raw: Proto.IMessage;
|
|
37
|
+
}
|
|
38
|
+
export declare function identifyEncryptedAddon(message: Proto.IMessage): WaIdentifiedEncAddon | null;
|
|
39
|
+
export type WaDecodedAddon = {
|
|
40
|
+
readonly kind: 'reaction';
|
|
41
|
+
readonly reaction: Proto.Message.IReactionMessage;
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: 'poll_vote';
|
|
44
|
+
readonly pollVote: Proto.Message.IPollVoteMessage;
|
|
45
|
+
readonly selectedOptionNames: readonly string[] | null;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: 'event_response';
|
|
48
|
+
readonly eventResponse: Proto.Message.IEventResponseMessage;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'comment';
|
|
51
|
+
readonly comment: Proto.Message.ICommentMessage;
|
|
52
|
+
};
|
|
53
|
+
export declare function decodeAddonPlaintext(kind: WaAddonKind, plaintext: Uint8Array): WaDecodedAddon;
|
|
54
|
+
export declare function resolveParentMessageSecret(targetMessageId: string, messageSecretStore: WaMessageSecretStore, messageStore: WaMessageStore): Promise<WaMessageSecretEntry | null>;
|
|
55
|
+
export declare function resolvePollOptionNames(selectedOptions: readonly Uint8Array[], pollCreationMessageId: string, messageStore: WaMessageStore): Promise<readonly string[] | null>;
|
|
25
56
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { WaSendMediaMessage } from './types';
|
|
2
|
-
import type
|
|
2
|
+
import { type Proto } from '..';
|
|
3
3
|
export declare function isSendMediaMessage(content: unknown): content is WaSendMediaMessage;
|
|
4
|
+
export declare function unwrapMessage(message: Proto.IMessage): Proto.IMessage;
|
|
4
5
|
export declare function resolveMessageTypeAttr(message: Proto.IMessage): string;
|
|
6
|
+
export declare function needsSecretPersistence(message: Proto.IMessage): boolean;
|
|
5
7
|
export declare function resolveEditAttr(message: Proto.IMessage, subtype?: string): string | null;
|
|
6
8
|
export declare function resolveEncMediaType(message: Proto.IMessage): string | null;
|
|
7
9
|
export interface MessageMetaAttrs {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Proto } from '..';
|
|
2
2
|
import type { SignalAddress } from '../signal/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { WaIdentityStore } from '../store/contracts/identity.store';
|
|
4
4
|
export interface IcdcMeta {
|
|
5
5
|
readonly keyHash: Uint8Array;
|
|
6
6
|
readonly timestamp: number | undefined;
|
|
7
7
|
}
|
|
8
|
-
export declare function computeDeviceKeyHash(identityKeys: readonly Uint8Array[]): Promise<Uint8Array>;
|
|
9
|
-
export declare function resolveIcdcMeta(deviceJids: readonly string[],
|
|
8
|
+
export declare function computeDeviceKeyHash(identityKeys: readonly Uint8Array[], hashLength?: number): Promise<Uint8Array>;
|
|
9
|
+
export declare function resolveIcdcMeta(deviceJids: readonly string[], identityStore: WaIdentityStore, updatedAtMs: number | undefined, localIdentity?: {
|
|
10
10
|
readonly address: SignalAddress;
|
|
11
11
|
readonly pubKey: Uint8Array;
|
|
12
|
-
}): Promise<IcdcMeta | null>;
|
|
12
|
+
}, hashLength?: number): Promise<IcdcMeta | null>;
|
|
13
13
|
export declare function injectDeviceListMetadata(message: Proto.IMessage, senderIcdc: IcdcMeta | null, recipientIcdc: IcdcMeta | null): Proto.IMessage;
|