@ubedsockets/baileys 1.6.9 → 1.7.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/WAProto/GenerateStatics.sh +26 -3
- package/WAProto/WAProto.proto +432 -180
- package/WAProto/add-missing-proto-deps.js +134 -0
- package/WAProto/imports-elaina.js +48 -0
- package/WAProto/index.js +78044 -140686
- package/WAProto/merge-elaina-ai-proto.js +187 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/elaina-version.json +3 -0
- package/lib/Defaults/index.js +57 -55
- package/lib/Signal/Group/group_cipher.js +1 -1
- package/lib/Signal/Group/keyhelper.js +1 -1
- package/lib/Signal/Group/sender-chain-key.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +1 -1
- package/lib/Signal/libsignal.js +1 -1
- package/lib/Signal/libsignalnode/LICENSE +621 -0
- package/lib/Signal/libsignalnode/README.md +11 -0
- package/lib/Signal/libsignalnode/generate-proto.sh +1 -0
- package/lib/Signal/libsignalnode/index.js +10 -0
- package/lib/Signal/libsignalnode/protos/WhisperTextProtocol.proto +28 -0
- package/lib/Signal/libsignalnode/src/.eslintrc.json +31 -0
- package/lib/Signal/libsignalnode/src/WhisperTextProtocol.js +948 -0
- package/lib/Signal/libsignalnode/src/base_key_type.js +6 -0
- package/lib/Signal/libsignalnode/src/chain_type.js +6 -0
- package/lib/Signal/libsignalnode/src/crypto.js +98 -0
- package/lib/Signal/libsignalnode/src/curve.js +142 -0
- package/lib/Signal/libsignalnode/src/errors.js +33 -0
- package/lib/Signal/libsignalnode/src/keyhelper.js +45 -0
- package/lib/Signal/libsignalnode/src/numeric_fingerprint.js +70 -0
- package/lib/Signal/libsignalnode/src/protobufs.js +10 -0
- package/lib/Signal/libsignalnode/src/protocol_address.js +40 -0
- package/lib/Signal/libsignalnode/src/queue_job.js +70 -0
- package/lib/Signal/libsignalnode/src/session_builder.js +164 -0
- package/lib/Signal/libsignalnode/src/session_cipher.js +332 -0
- package/lib/Signal/libsignalnode/src/session_record.js +325 -0
- package/lib/Socket/Client/websocket.js +2 -41
- package/lib/Socket/Rhandler.js +533 -0
- package/lib/Socket/chats.js +249 -123
- package/lib/Socket/index.js +1 -1
- package/lib/Socket/messages-recv.js +57 -5
- package/lib/Socket/messages-send.js +47 -280
- package/lib/Socket/newsletter.js +100 -132
- package/lib/Socket/socket.js +79 -87
- package/lib/Socket/usync.js +0 -2
- package/lib/Store/make-in-memory-store.js +1 -1
- package/lib/Utils/browser-utils.js +30 -23
- package/lib/Utils/crypto.js +22 -18
- package/lib/Utils/decode-wa-message.js +12 -2
- package/lib/Utils/{baileys-event-stream.js → elaina-event-stream.js} +1 -1
- package/lib/Utils/event-buffer.js +2 -2
- package/lib/Utils/generics.js +36 -10
- package/lib/Utils/index.js +3 -1
- package/lib/Utils/message-retry-manager.js +48 -185
- package/lib/Utils/messages-media.js +127 -236
- package/lib/Utils/messages.js +746 -232
- package/lib/Utils/noise-handler.js +1 -2
- package/lib/Utils/process-message.js +108 -25
- package/lib/Utils/signal.js +1 -10
- package/lib/Utils/use-multi-file-auth-state.js +1 -1
- package/lib/Utils/validate-connection.js +3 -7
- package/lib/Voip/audio-feeder.js +166 -0
- package/lib/Voip/index.js +639 -0
- package/lib/Voip/relay-transport.js +829 -0
- package/lib/Voip/signaling.js +1102 -0
- package/lib/Voip/types.js +23 -0
- package/lib/Voip/wasm-engine.js +1255 -0
- package/lib/Voip/worker-bootstrap.js +1078 -0
- package/lib/WABinary/jid-utils.js +17 -1
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/index.js +21 -18
- package/package.json +32 -18
- package/WAProto/AICommon.js +0 -27981
- package/WAProto/AICommon.proto +0 -713
- package/WAProto/Ephemeral.js +0 -295
- package/WAProto/Ephemeral.proto +0 -7
- package/WAProto/fix-imports.js +0 -85
- package/WAProto/index.d.ts +0 -14017
- package/WAProto/vyzen.js +0 -7
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -75
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts +0 -15
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts +0 -12
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts +0 -31
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts +0 -39
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts +0 -12
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts +0 -5
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts +0 -23
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js +0 -277
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts +0 -16
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts +0 -217
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts +0 -124
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts +0 -273
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js +0 -431
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts +0 -161
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts +0 -260
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts +0 -203
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts +0 -199
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts +0 -3
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js +0 -42
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts +0 -170
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/setup.js +0 -433
- package/lib/Socket/socket.d.ts +0 -59
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Types/Auth.d.ts +0 -117
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -25
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts +0 -15
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts +0 -124
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts +0 -26
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts +0 -256
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts +0 -71
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts +0 -47
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts +0 -30
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts +0 -320
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Mex.d.ts +0 -141
- package/lib/Types/Mex.d.ts.map +0 -1
- package/lib/Types/Mex.js +0 -37
- package/lib/Types/Mex.js.map +0 -1
- package/lib/Types/Product.d.ts +0 -79
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/RichType.d.ts +0 -3
- package/lib/Types/RichType.d.ts.map +0 -1
- package/lib/Types/RichType.js +0 -31
- package/lib/Types/Signal.d.ts +0 -87
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts +0 -136
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts +0 -97
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts +0 -26
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts +0 -65
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/Tiktok.js +0 -80
- package/lib/Utils/auth-utils.d.ts +0 -24
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts +0 -4
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts +0 -23
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chaanel/vyzen.js +0 -0
- package/lib/Utils/chat-utils.d.ts +0 -100
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
- package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-utils.js +0 -35
- package/lib/Utils/companion-reg-client-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts +0 -37
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts +0 -66
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts +0 -36
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/facebook.js +0 -48
- package/lib/Utils/generics.d.ts +0 -91
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts +0 -24
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/identity-change-handler.d.ts +0 -44
- package/lib/Utils/identity-change-handler.d.ts.map +0 -1
- package/lib/Utils/identity-change-handler.js +0 -50
- package/lib/Utils/identity-change-handler.js.map +0 -1
- package/lib/Utils/index.d.ts +0 -22
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/instagram.js +0 -50
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts +0 -12
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts +0 -8
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts +0 -9
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts +0 -115
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts +0 -133
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts +0 -91
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts +0 -20
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/offline-node-processor.d.ts +0 -17
- package/lib/Utils/offline-node-processor.d.ts.map +0 -1
- package/lib/Utils/offline-node-processor.js +0 -40
- package/lib/Utils/offline-node-processor.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts +0 -28
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js +0 -106
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts +0 -60
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/reporting-utils.d.ts +0 -11
- package/lib/Utils/reporting-utils.d.ts.map +0 -1
- package/lib/Utils/reporting-utils.js +0 -258
- package/lib/Utils/reporting-utils.js.map +0 -1
- package/lib/Utils/rich-message-utils.js +0 -387
- package/lib/Utils/signal.d.ts +0 -47
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/stanza-ack.d.ts +0 -11
- package/lib/Utils/stanza-ack.d.ts.map +0 -1
- package/lib/Utils/stanza-ack.js +0 -38
- package/lib/Utils/stanza-ack.js.map +0 -1
- package/lib/Utils/sync-action-utils.d.ts +0 -19
- package/lib/Utils/sync-action-utils.d.ts.map +0 -1
- package/lib/Utils/sync-action-utils.js +0 -49
- package/lib/Utils/sync-action-utils.js.map +0 -1
- package/lib/Utils/tc-token-utils.d.ts +0 -37
- package/lib/Utils/tc-token-utils.d.ts.map +0 -1
- package/lib/Utils/tc-token-utils.js +0 -163
- package/lib/Utils/tc-token-utils.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/Utils/youtube.js +0 -44
- package/lib/WABinary/constants.d.ts +0 -28
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts +0 -15
- package/lib/WABinary/generic-utils.d.ts.map +0 -1
- package/lib/WABinary/generic-utils.js.map +0 -1
- package/lib/WABinary/index.d.ts +0 -6
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts +0 -48
- package/lib/WABinary/jid-utils.d.ts.map +0 -1
- package/lib/WABinary/jid-utils.js.map +0 -1
- package/lib/WABinary/types.d.ts +0 -19
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts +0 -9
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts +0 -40
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts +0 -4
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -25
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts +0 -6
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts +0 -30
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts +0 -17
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts +0 -4
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts +0 -12
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -15,24 +15,35 @@ const process_message_1 = __importDefault(require("../Utils/process-message"));
|
|
|
15
15
|
const WABinary_1 = require("../WABinary");
|
|
16
16
|
const WAUSync_1 = require("../WAUSync");
|
|
17
17
|
const usync_1 = require("./usync");
|
|
18
|
+
const chalk = require('chalk');
|
|
18
19
|
const MAX_SYNC_ATTEMPTS = 2;
|
|
20
|
+
const SyncState = {
|
|
21
|
+
Connecting: 'connecting',
|
|
22
|
+
AwaitingInitialSync: 'awaiting_initial_sync',
|
|
23
|
+
Syncing: 'syncing',
|
|
24
|
+
Online: 'online'
|
|
25
|
+
};
|
|
19
26
|
const makeChatsSocket = (config) => {
|
|
20
27
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config;
|
|
21
28
|
const sock = (0, usync_1.makeUSyncSocket)(config);
|
|
22
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, } = sock;
|
|
29
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, signalRepository, onUnexpectedError, } = sock;
|
|
23
30
|
let privacySettings;
|
|
31
|
+
let syncState = SyncState.Connecting;
|
|
24
32
|
let needToFlushWithAppStateSync = false;
|
|
25
33
|
let pendingAppStateSync = false;
|
|
26
|
-
|
|
34
|
+
let awaitingSyncTimeout;
|
|
27
35
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
28
36
|
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
29
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
37
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
38
|
+
useClones: false
|
|
39
|
+
});
|
|
40
|
+
const receivedMessageDedupCache = new node_cache_1.default({
|
|
41
|
+
stdTTL: 3 * 60,
|
|
30
42
|
useClones: false
|
|
31
43
|
});
|
|
32
44
|
if (!config.placeholderResendCache) {
|
|
33
45
|
config.placeholderResendCache = placeholderResendCache;
|
|
34
46
|
}
|
|
35
|
-
/** helper function to fetch the given app state sync key */
|
|
36
47
|
const getAppStateSyncKey = async (keyId) => {
|
|
37
48
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
38
49
|
return key;
|
|
@@ -54,7 +65,6 @@ const makeChatsSocket = (config) => {
|
|
|
54
65
|
}
|
|
55
66
|
return privacySettings;
|
|
56
67
|
};
|
|
57
|
-
/** helper function to run a privacy IQ query */
|
|
58
68
|
const privacyQuery = async (name, value) => {
|
|
59
69
|
await query({
|
|
60
70
|
tag: 'iq',
|
|
@@ -99,6 +109,9 @@ const makeChatsSocket = (config) => {
|
|
|
99
109
|
const updateGroupsAddPrivacy = async (value) => {
|
|
100
110
|
await privacyQuery('groupadd', value);
|
|
101
111
|
};
|
|
112
|
+
const updateDisableLinkPreviewsPrivacy = async (isPreviewsDisabled) => {
|
|
113
|
+
return chatModify({ disableLinkPreviews: { isPreviewsDisabled } }, '');
|
|
114
|
+
};
|
|
102
115
|
const updateDefaultDisappearingMode = async (duration) => {
|
|
103
116
|
await query({
|
|
104
117
|
tag: 'iq',
|
|
@@ -179,16 +192,15 @@ const makeChatsSocket = (config) => {
|
|
|
179
192
|
return result.list;
|
|
180
193
|
}
|
|
181
194
|
};
|
|
182
|
-
|
|
183
|
-
const updateProfilePicture = async (jid, content) => {
|
|
195
|
+
const updateProfilePicture = async (jid, content, dimensions) => {
|
|
184
196
|
let targetJid;
|
|
185
197
|
if (!jid) {
|
|
186
198
|
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
187
199
|
}
|
|
188
200
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
189
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
201
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
190
202
|
}
|
|
191
|
-
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
203
|
+
const { img } = await (0, Utils_1.generateProfilePicture)(content, dimensions);
|
|
192
204
|
await query({
|
|
193
205
|
tag: 'iq',
|
|
194
206
|
attrs: {
|
|
@@ -206,14 +218,13 @@ const makeChatsSocket = (config) => {
|
|
|
206
218
|
]
|
|
207
219
|
});
|
|
208
220
|
};
|
|
209
|
-
/** remove the profile picture for yourself or a group */
|
|
210
221
|
const removeProfilePicture = async (jid) => {
|
|
211
222
|
let targetJid;
|
|
212
223
|
if (!jid) {
|
|
213
224
|
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
214
225
|
}
|
|
215
226
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
216
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
227
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
217
228
|
}
|
|
218
229
|
await query({
|
|
219
230
|
tag: 'iq',
|
|
@@ -225,7 +236,6 @@ const makeChatsSocket = (config) => {
|
|
|
225
236
|
}
|
|
226
237
|
});
|
|
227
238
|
};
|
|
228
|
-
/** update the profile status for yourself */
|
|
229
239
|
const updateProfileStatus = async (status) => {
|
|
230
240
|
await query({
|
|
231
241
|
tag: 'iq',
|
|
@@ -352,18 +362,12 @@ const makeChatsSocket = (config) => {
|
|
|
352
362
|
};
|
|
353
363
|
};
|
|
354
364
|
const resyncAppState = ev.createBufferedFunction(async (collections, isInitialSync) => {
|
|
355
|
-
// we use this to determine which events to fire
|
|
356
|
-
// otherwise when we resync from scratch -- all notifications will fire
|
|
357
365
|
const initialVersionMap = {};
|
|
358
366
|
const globalMutationMap = {};
|
|
359
367
|
await authState.keys.transaction(async () => {
|
|
360
368
|
var _a;
|
|
361
369
|
const collectionsToHandle = new Set(collections);
|
|
362
|
-
// in case something goes wrong -- ensure we don't enter a loop that cannot be exited from
|
|
363
370
|
const attemptsMap = {};
|
|
364
|
-
// keep executing till all collections are done
|
|
365
|
-
// sometimes a single patch request will not return all the patches (God knows why)
|
|
366
|
-
// so we fetch till they're all done (this is determined by the "has_more_patches" flag)
|
|
367
371
|
while (collectionsToHandle.size) {
|
|
368
372
|
const states = {};
|
|
369
373
|
const nodes = [];
|
|
@@ -385,7 +389,6 @@ const makeChatsSocket = (config) => {
|
|
|
385
389
|
attrs: {
|
|
386
390
|
name,
|
|
387
391
|
version: state.version.toString(),
|
|
388
|
-
// return snapshot if being synced from scratch
|
|
389
392
|
'return_snapshot': (!state.version).toString()
|
|
390
393
|
}
|
|
391
394
|
});
|
|
@@ -405,7 +408,6 @@ const makeChatsSocket = (config) => {
|
|
|
405
408
|
}
|
|
406
409
|
]
|
|
407
410
|
});
|
|
408
|
-
// extract from binary node
|
|
409
411
|
const decoded = await (0, Utils_1.extractSyncdPatches)(result, config === null || config === void 0 ? void 0 : config.options);
|
|
410
412
|
for (const key in decoded) {
|
|
411
413
|
const name = key;
|
|
@@ -418,7 +420,6 @@ const makeChatsSocket = (config) => {
|
|
|
418
420
|
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
|
|
419
421
|
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
|
|
420
422
|
}
|
|
421
|
-
// only process if there are syncd patches
|
|
422
423
|
if (patches.length) {
|
|
423
424
|
const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
|
|
424
425
|
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
|
|
@@ -429,22 +430,18 @@ const makeChatsSocket = (config) => {
|
|
|
429
430
|
if (hasMorePatches) {
|
|
430
431
|
logger.info(`${name} has more patches...`);
|
|
431
432
|
}
|
|
432
|
-
else {
|
|
433
|
+
else {
|
|
433
434
|
collectionsToHandle.delete(name);
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
catch (error) {
|
|
437
|
-
// if retry attempts overshoot
|
|
438
|
-
// or key not found
|
|
439
438
|
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
|
|
440
439
|
|| ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404
|
|
441
440
|
|| error.name === 'TypeError';
|
|
442
441
|
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
|
|
443
442
|
await authState.keys.set({ 'app-state-sync-version': { [name]: null } });
|
|
444
|
-
// increment number of retries
|
|
445
443
|
attemptsMap[name] = (attemptsMap[name] || 0) + 1;
|
|
446
444
|
if (isIrrecoverableError) {
|
|
447
|
-
// stop retrying
|
|
448
445
|
collectionsToHandle.delete(name);
|
|
449
446
|
}
|
|
450
447
|
}
|
|
@@ -456,28 +453,56 @@ const makeChatsSocket = (config) => {
|
|
|
456
453
|
onMutation(globalMutationMap[key]);
|
|
457
454
|
}
|
|
458
455
|
});
|
|
459
|
-
/**
|
|
460
|
-
* fetch the profile picture of a user/group
|
|
461
|
-
* type = "preview" for a low res picture
|
|
462
|
-
* type = "image for the high res picture"
|
|
463
|
-
*/
|
|
464
456
|
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
|
465
457
|
var _a;
|
|
466
458
|
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
459
|
+
try {
|
|
460
|
+
const result = await query({
|
|
461
|
+
tag: 'iq',
|
|
462
|
+
attrs: {
|
|
463
|
+
target: jid,
|
|
464
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
465
|
+
type: 'get',
|
|
466
|
+
xmlns: 'w:profile:picture'
|
|
467
|
+
},
|
|
468
|
+
content: [
|
|
469
|
+
{ tag: 'picture', attrs: { type, query: 'url' } }
|
|
470
|
+
]
|
|
471
|
+
}, timeoutMs);
|
|
472
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
|
|
473
|
+
return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
|
|
474
|
+
} catch (error) {
|
|
475
|
+
if (error.message?.includes('item-not-found') ||
|
|
476
|
+
error.output?.payload?.statusCode === 404 ||
|
|
477
|
+
error.statusCode === 404) {
|
|
478
|
+
logger.info(chalk.gray(`[INFO] Profile pic not found for ${jid}, using fallback`));
|
|
479
|
+
return {
|
|
480
|
+
eurl: undefined,
|
|
481
|
+
id: jid.split('@')[0],
|
|
482
|
+
status: null,
|
|
483
|
+
img: null
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
throw error;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
const createCallLink = async (type, event, timeoutMs) => {
|
|
467
490
|
const result = await query({
|
|
468
|
-
tag: '
|
|
491
|
+
tag: 'call',
|
|
469
492
|
attrs: {
|
|
470
|
-
|
|
471
|
-
to:
|
|
472
|
-
type: 'get',
|
|
473
|
-
xmlns: 'w:profile:picture'
|
|
493
|
+
id: generateMessageTag(),
|
|
494
|
+
to: '@call'
|
|
474
495
|
},
|
|
475
496
|
content: [
|
|
476
|
-
{
|
|
497
|
+
{
|
|
498
|
+
tag: 'link_create',
|
|
499
|
+
attrs: { media: type },
|
|
500
|
+
content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
|
|
501
|
+
}
|
|
477
502
|
]
|
|
478
503
|
}, timeoutMs);
|
|
479
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, '
|
|
480
|
-
return
|
|
504
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'link_create');
|
|
505
|
+
return child?.attrs?.token;
|
|
481
506
|
};
|
|
482
507
|
const sendPresenceUpdate = async (type, toJid) => {
|
|
483
508
|
const me = authState.creds.me;
|
|
@@ -513,10 +538,6 @@ const makeChatsSocket = (config) => {
|
|
|
513
538
|
});
|
|
514
539
|
}
|
|
515
540
|
};
|
|
516
|
-
/**
|
|
517
|
-
* @param toJid the jid to subscribe to
|
|
518
|
-
* @param tcToken token for subscription, use if present
|
|
519
|
-
*/
|
|
520
541
|
const presenceSubscribe = (toJid, tcToken) => (sendNode({
|
|
521
542
|
tag: 'presence',
|
|
522
543
|
attrs: {
|
|
@@ -625,7 +646,6 @@ const makeChatsSocket = (config) => {
|
|
|
625
646
|
}
|
|
626
647
|
}
|
|
627
648
|
};
|
|
628
|
-
/** sending non-abt props may fix QR scan fail if server expects */
|
|
629
649
|
const fetchProps = async () => {
|
|
630
650
|
var _a, _b, _c;
|
|
631
651
|
const resultNode = await query({
|
|
@@ -645,7 +665,7 @@ const makeChatsSocket = (config) => {
|
|
|
645
665
|
const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
|
|
646
666
|
let props = {};
|
|
647
667
|
if (propsNode) {
|
|
648
|
-
if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) {
|
|
668
|
+
if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) {
|
|
649
669
|
authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
|
|
650
670
|
ev.emit('creds.update', authState.creds);
|
|
651
671
|
}
|
|
@@ -654,18 +674,10 @@ const makeChatsSocket = (config) => {
|
|
|
654
674
|
logger.debug('fetched props');
|
|
655
675
|
return props;
|
|
656
676
|
};
|
|
657
|
-
/**
|
|
658
|
-
* modify a chat -- mark unread, read etc.
|
|
659
|
-
* lastMessages must be sorted in reverse chronologically
|
|
660
|
-
* requires the last messages till the last message received; required for archive & unread
|
|
661
|
-
*/
|
|
662
677
|
const chatModify = (mod, jid) => {
|
|
663
678
|
const patch = (0, Utils_1.chatModificationToAppPatch)(mod, jid);
|
|
664
679
|
return appPatch(patch);
|
|
665
680
|
};
|
|
666
|
-
/**
|
|
667
|
-
* Star or Unstar a message
|
|
668
|
-
*/
|
|
669
681
|
const star = (jid, messages, star) => {
|
|
670
682
|
return chatModify({
|
|
671
683
|
star: {
|
|
@@ -674,9 +686,15 @@ const makeChatsSocket = (config) => {
|
|
|
674
686
|
}
|
|
675
687
|
}, jid);
|
|
676
688
|
};
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
689
|
+
const addOrEditContact = (jid, contact) => {
|
|
690
|
+
return chatModify({ contact }, jid);
|
|
691
|
+
};
|
|
692
|
+
const removeContact = (jid) => {
|
|
693
|
+
return chatModify({ contact: null }, jid);
|
|
694
|
+
};
|
|
695
|
+
const addLabel = (jid, labels) => {
|
|
696
|
+
return chatModify({ addLabel: { ...labels } }, jid);
|
|
697
|
+
};
|
|
680
698
|
const addChatLabel = (jid, labelId) => {
|
|
681
699
|
return chatModify({
|
|
682
700
|
addChatLabel: {
|
|
@@ -684,9 +702,6 @@ const makeChatsSocket = (config) => {
|
|
|
684
702
|
}
|
|
685
703
|
}, jid);
|
|
686
704
|
};
|
|
687
|
-
/**
|
|
688
|
-
* Removes label for the chat
|
|
689
|
-
*/
|
|
690
705
|
const removeChatLabel = (jid, labelId) => {
|
|
691
706
|
return chatModify({
|
|
692
707
|
removeChatLabel: {
|
|
@@ -694,9 +709,6 @@ const makeChatsSocket = (config) => {
|
|
|
694
709
|
}
|
|
695
710
|
}, jid);
|
|
696
711
|
};
|
|
697
|
-
/**
|
|
698
|
-
* Adds label for the message
|
|
699
|
-
*/
|
|
700
712
|
const addMessageLabel = (jid, messageId, labelId) => {
|
|
701
713
|
return chatModify({
|
|
702
714
|
addMessageLabel: {
|
|
@@ -705,9 +717,6 @@ const makeChatsSocket = (config) => {
|
|
|
705
717
|
}
|
|
706
718
|
}, jid);
|
|
707
719
|
};
|
|
708
|
-
/**
|
|
709
|
-
* Removes label for the message
|
|
710
|
-
*/
|
|
711
720
|
const removeMessageLabel = (jid, messageId, labelId) => {
|
|
712
721
|
return chatModify({
|
|
713
722
|
removeMessageLabel: {
|
|
@@ -716,10 +725,6 @@ const makeChatsSocket = (config) => {
|
|
|
716
725
|
}
|
|
717
726
|
}, jid);
|
|
718
727
|
};
|
|
719
|
-
/**
|
|
720
|
-
* queries need to be fired on connection open
|
|
721
|
-
* help ensure parity with WA Web
|
|
722
|
-
* */
|
|
723
728
|
const executeInitQueries = async () => {
|
|
724
729
|
await Promise.all([
|
|
725
730
|
fetchProps(),
|
|
@@ -727,64 +732,155 @@ const makeChatsSocket = (config) => {
|
|
|
727
732
|
fetchPrivacySettings(),
|
|
728
733
|
]);
|
|
729
734
|
};
|
|
735
|
+
const canonicalizeUserJid = (jid) => {
|
|
736
|
+
if (!jid) {
|
|
737
|
+
return jid;
|
|
738
|
+
}
|
|
739
|
+
if ((0, WABinary_1.isLidUser)(jid)) {
|
|
740
|
+
return (0, WABinary_1.lidToJid)(jid);
|
|
741
|
+
}
|
|
742
|
+
return jid;
|
|
743
|
+
};
|
|
744
|
+
const extractStanzaId = (msg) => {
|
|
745
|
+
var _a, _b;
|
|
746
|
+
const topLevelStanzaId = (_a = msg.messageContextInfo) === null || _a === void 0 ? void 0 : _a.stanzaId;
|
|
747
|
+
if (topLevelStanzaId) {
|
|
748
|
+
return topLevelStanzaId;
|
|
749
|
+
}
|
|
750
|
+
const messageContextStanzaId = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.messageContextInfo;
|
|
751
|
+
if (messageContextStanzaId === null || messageContextStanzaId === void 0 ? void 0 : messageContextStanzaId.stanzaId) {
|
|
752
|
+
return messageContextStanzaId.stanzaId;
|
|
753
|
+
}
|
|
754
|
+
const normalizedContent = (0, Utils_1.normalizeMessageContent)(msg.message);
|
|
755
|
+
const contentType = normalizedContent ? (0, Utils_1.getContentType)(normalizedContent) : undefined;
|
|
756
|
+
const contentContextStanzaId = contentType
|
|
757
|
+
? normalizedContent[contentType].contextInfo && normalizedContent[contentType].contextInfo.stanzaId
|
|
758
|
+
: undefined;
|
|
759
|
+
return contentContextStanzaId;
|
|
760
|
+
};
|
|
761
|
+
const buildMessageDedupKeys = (msg) => {
|
|
762
|
+
const remoteJid = canonicalizeUserJid(msg.key.remoteJid);
|
|
763
|
+
const participant = canonicalizeUserJid(msg.key.participant);
|
|
764
|
+
const stanzaId = extractStanzaId(msg);
|
|
765
|
+
const primaryKey = [remoteJid, participant, msg.key.id, msg.key.fromMe ? '1' : '0', stanzaId || ''].join('|');
|
|
766
|
+
const keys = [primaryKey];
|
|
767
|
+
// fallback alias key to collapse LID->PN duplicate deliveries for the same incoming user message ID
|
|
768
|
+
if (!msg.key.fromMe && ((0, WABinary_1.isJidUser)(msg.key.remoteJid) || (0, WABinary_1.isLidUser)(msg.key.remoteJid))) {
|
|
769
|
+
keys.push(`incoming-user-id|${msg.key.id}|${stanzaId || ''}`);
|
|
770
|
+
}
|
|
771
|
+
return keys;
|
|
772
|
+
};
|
|
773
|
+
const getDedupState = (msg) => msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT
|
|
774
|
+
? 'ciphertext'
|
|
775
|
+
: 'final';
|
|
776
|
+
const getPendingDedupState = (dedupState) => dedupState === 'final' ? 'processing' : dedupState;
|
|
730
777
|
const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
|
|
731
778
|
var _a, _b, _c;
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
779
|
+
const dedupKeys = buildMessageDedupKeys(msg);
|
|
780
|
+
const dedupState = getDedupState(msg);
|
|
781
|
+
const dedupStateBeforeProcess = new Map();
|
|
782
|
+
const previousDedupState = dedupKeys
|
|
783
|
+
.map(key => receivedMessageDedupCache.get(key))
|
|
784
|
+
.find(state => !!state);
|
|
785
|
+
if (previousDedupState === 'final'
|
|
786
|
+
|| previousDedupState === 'processing'
|
|
787
|
+
|| (previousDedupState === 'ciphertext' && dedupState === 'ciphertext')) {
|
|
788
|
+
logger.debug({ dedupKeys, messageId: msg.key.id, type, dedupState, previousDedupState }, 'skipping duplicate messages.upsert');
|
|
789
|
+
return;
|
|
743
790
|
}
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
&& Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
|
|
748
|
-
: false;
|
|
749
|
-
if (historyMsg && !authState.creds.myAppStateKeyId) {
|
|
750
|
-
logger.warn('skipping app state sync, as myAppStateKeyId is not set');
|
|
751
|
-
pendingAppStateSync = true;
|
|
791
|
+
for (const key of dedupKeys) {
|
|
792
|
+
dedupStateBeforeProcess.set(key, receivedMessageDedupCache.get(key));
|
|
793
|
+
receivedMessageDedupCache.set(key, getPendingDedupState(dedupState));
|
|
752
794
|
}
|
|
753
|
-
|
|
754
|
-
(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
795
|
+
try {
|
|
796
|
+
ev.emit('messages.upsert', { messages: [msg], type });
|
|
797
|
+
if (!!msg.pushName) {
|
|
798
|
+
let jid = msg.key.fromMe ? authState.creds.me.id : (msg.key.participant || msg.key.remoteJid);
|
|
799
|
+
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
800
|
+
if (!msg.key.fromMe) {
|
|
801
|
+
ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }]);
|
|
759
802
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
|
|
781
|
-
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
|
|
782
|
-
ev.emit('creds.update', { accountSyncCounter });
|
|
783
|
-
if (needToFlushWithAppStateSync) {
|
|
784
|
-
logger.debug('flushing with app state sync');
|
|
803
|
+
if (msg.key.fromMe && msg.pushName && ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.name) !== msg.pushName) {
|
|
804
|
+
ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
const historyMsg = (0, Utils_1.getHistoryMsg)(msg.message);
|
|
808
|
+
const shouldProcessHistoryMsg = historyMsg
|
|
809
|
+
? (shouldSyncHistoryMessage(historyMsg)
|
|
810
|
+
&& Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
|
|
811
|
+
: false;
|
|
812
|
+
if (historyMsg && syncState === SyncState.AwaitingInitialSync) {
|
|
813
|
+
if (awaitingSyncTimeout) {
|
|
814
|
+
clearTimeout(awaitingSyncTimeout);
|
|
815
|
+
awaitingSyncTimeout = undefined;
|
|
816
|
+
}
|
|
817
|
+
if (shouldProcessHistoryMsg) {
|
|
818
|
+
syncState = SyncState.Syncing;
|
|
819
|
+
logger.info('Transitioned to Syncing state');
|
|
820
|
+
} else {
|
|
821
|
+
syncState = SyncState.Online;
|
|
822
|
+
logger.info('History sync skipped, transitioning to Online state and flushing buffer');
|
|
785
823
|
ev.flush();
|
|
786
824
|
}
|
|
787
825
|
}
|
|
826
|
+
const doAppStateSync = async () => {
|
|
827
|
+
if (syncState === SyncState.Syncing) {
|
|
828
|
+
logger.info('Doing app state sync');
|
|
829
|
+
await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
|
|
830
|
+
syncState = SyncState.Online;
|
|
831
|
+
logger.info('App state sync complete, transitioning to Online state and flushing buffer');
|
|
832
|
+
ev.flush();
|
|
833
|
+
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
|
|
834
|
+
ev.emit('creds.update', { accountSyncCounter });
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
if (historyMsg && !authState.creds.myAppStateKeyId) {
|
|
838
|
+
logger.warn('skipping app state sync, as myAppStateKeyId is not set');
|
|
839
|
+
pendingAppStateSync = true;
|
|
840
|
+
}
|
|
841
|
+
await Promise.all([
|
|
842
|
+
(async () => {
|
|
843
|
+
if (historyMsg
|
|
844
|
+
&& authState.creds.myAppStateKeyId) {
|
|
845
|
+
pendingAppStateSync = false;
|
|
846
|
+
await doAppStateSync();
|
|
847
|
+
}
|
|
848
|
+
})(),
|
|
849
|
+
(0, process_message_1.default)(msg, {
|
|
850
|
+
signalRepository,
|
|
851
|
+
shouldProcessHistoryMsg,
|
|
852
|
+
placeholderResendCache,
|
|
853
|
+
ev,
|
|
854
|
+
creds: authState.creds,
|
|
855
|
+
keyStore: authState.keys,
|
|
856
|
+
logger,
|
|
857
|
+
options: config.options,
|
|
858
|
+
getMessage: config.getMessage,
|
|
859
|
+
})
|
|
860
|
+
]);
|
|
861
|
+
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare)
|
|
862
|
+
&& pendingAppStateSync) {
|
|
863
|
+
await doAppStateSync();
|
|
864
|
+
pendingAppStateSync = false;
|
|
865
|
+
}
|
|
866
|
+
for (const key of dedupKeys) {
|
|
867
|
+
receivedMessageDedupCache.set(key, dedupState);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
catch (error) {
|
|
871
|
+
for (const key of dedupKeys) {
|
|
872
|
+
const currentState = receivedMessageDedupCache.get(key);
|
|
873
|
+
if (currentState === 'processing') {
|
|
874
|
+
const previousState = dedupStateBeforeProcess.get(key);
|
|
875
|
+
if (previousState) {
|
|
876
|
+
receivedMessageDedupCache.set(key, previousState);
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
receivedMessageDedupCache.del(key);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
throw error;
|
|
788
884
|
}
|
|
789
885
|
});
|
|
790
886
|
ws.on('CB:presence', handlePresenceUpdate);
|
|
@@ -804,7 +900,6 @@ const makeChatsSocket = (config) => {
|
|
|
804
900
|
}
|
|
805
901
|
break;
|
|
806
902
|
case 'groups':
|
|
807
|
-
// handled in groups.ts
|
|
808
903
|
break;
|
|
809
904
|
default:
|
|
810
905
|
logger.info({ node }, 'received unknown sync');
|
|
@@ -821,16 +916,43 @@ const makeChatsSocket = (config) => {
|
|
|
821
916
|
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
822
917
|
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
823
918
|
}
|
|
824
|
-
if (receivedPendingNotifications &&
|
|
825
|
-
// we keep buffering events until we finally have
|
|
826
|
-
// the key and can sync the messages
|
|
919
|
+
if (receivedPendingNotifications &&
|
|
827
920
|
!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
|
|
828
921
|
ev.buffer();
|
|
829
922
|
needToFlushWithAppStateSync = true;
|
|
830
923
|
}
|
|
924
|
+
if (!receivedPendingNotifications || syncState !== SyncState.Connecting) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
syncState = SyncState.AwaitingInitialSync;
|
|
928
|
+
logger.info('Connection is now AwaitingInitialSync, buffering events');
|
|
929
|
+
ev.buffer();
|
|
930
|
+
const willSyncHistory = shouldSyncHistoryMessage(
|
|
931
|
+
WAProto_1.proto.Message.HistorySyncNotification.create({
|
|
932
|
+
syncType: WAProto_1.proto.HistorySync.HistorySyncType.RECENT
|
|
933
|
+
})
|
|
934
|
+
);
|
|
935
|
+
if (!willSyncHistory) {
|
|
936
|
+
logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.');
|
|
937
|
+
syncState = SyncState.Online;
|
|
938
|
+
setTimeout(() => ev.flush(), 0);
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
logger.info('History sync is enabled, awaiting notification with a 20s timeout.');
|
|
942
|
+
if (awaitingSyncTimeout) {
|
|
943
|
+
clearTimeout(awaitingSyncTimeout);
|
|
944
|
+
}
|
|
945
|
+
awaitingSyncTimeout = setTimeout(() => {
|
|
946
|
+
if (syncState === SyncState.AwaitingInitialSync) {
|
|
947
|
+
logger.warn('Timeout in AwaitingInitialSync, forcing state to Online and flushing buffer');
|
|
948
|
+
syncState = SyncState.Online;
|
|
949
|
+
ev.flush();
|
|
950
|
+
}
|
|
951
|
+
}, 20000);
|
|
831
952
|
});
|
|
832
953
|
return {
|
|
833
954
|
...sock,
|
|
955
|
+
createCallLink,
|
|
834
956
|
getBotListV2,
|
|
835
957
|
processingMutex,
|
|
836
958
|
fetchPrivacySettings,
|
|
@@ -848,6 +970,7 @@ const makeChatsSocket = (config) => {
|
|
|
848
970
|
updateProfileStatus,
|
|
849
971
|
updateProfileName,
|
|
850
972
|
updateBlockStatus,
|
|
973
|
+
updateDisableLinkPreviewsPrivacy,
|
|
851
974
|
updateCallPrivacy,
|
|
852
975
|
updateMessagesPrivacy,
|
|
853
976
|
updateLastSeenPrivacy,
|
|
@@ -861,6 +984,9 @@ const makeChatsSocket = (config) => {
|
|
|
861
984
|
resyncAppState,
|
|
862
985
|
chatModify,
|
|
863
986
|
cleanDirtyBits,
|
|
987
|
+
addOrEditContact,
|
|
988
|
+
removeContact,
|
|
989
|
+
addLabel,
|
|
864
990
|
addChatLabel,
|
|
865
991
|
removeChatLabel,
|
|
866
992
|
addMessageLabel,
|
package/lib/Socket/index.js
CHANGED