@neelegirl/baileys 1.5.6 → 1.5.8
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 +24 -27
- package/WAProto/WAProto.proto +665 -291
- package/WAProto/index.d.ts +48037 -2294
- package/WAProto/index.js +139804 -45203
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +64 -58
- package/lib/Defaults/index.js +96 -74
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/WASignalGroup/GroupProtocol.js +1909 -0
- package/lib/Signal/WASignalGroup/ciphertext_message.js +16 -0
- package/lib/Signal/WASignalGroup/generate-proto.sh +1 -0
- package/lib/Signal/WASignalGroup/group.proto +42 -0
- package/lib/Signal/WASignalGroup/group_cipher.js +120 -0
- package/lib/Signal/WASignalGroup/group_session_builder.js +46 -0
- package/lib/Signal/WASignalGroup/index.js +6 -0
- package/lib/Signal/WASignalGroup/keyhelper.js +21 -0
- package/lib/Signal/WASignalGroup/protobufs.js +3 -0
- package/lib/Signal/WASignalGroup/queue_job.js +69 -0
- package/lib/Signal/WASignalGroup/readme.md +6 -0
- package/lib/Signal/WASignalGroup/sender_chain_key.js +50 -0
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/lib/Signal/WASignalGroup/sender_key_message.js +92 -0
- package/lib/Signal/WASignalGroup/sender_key_name.js +70 -0
- package/lib/Signal/WASignalGroup/sender_key_record.js +56 -0
- package/lib/Signal/WASignalGroup/sender_key_state.js +129 -0
- package/lib/Signal/{Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -3
- package/lib/Signal/libsignal.d.ts +4 -5
- package/lib/Signal/libsignal.js +112 -292
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +22 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.js +15 -8
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.js +36 -24
- package/lib/Socket/business.d.ts +177 -178
- package/lib/Socket/business.js +71 -179
- package/lib/Socket/chats.d.ts +93 -93
- package/lib/Socket/chats.js +625 -474
- package/lib/Socket/communities.d.ts +62 -83
- package/lib/Socket/communities.js +414 -412
- package/lib/Socket/groups.d.ts +112 -118
- package/lib/Socket/groups.js +171 -146
- package/lib/Socket/index.d.ts +182 -222
- package/lib/Socket/index.js +17 -12
- package/lib/Socket/messages-recv.d.ts +169 -165
- package/lib/Socket/messages-recv.js +1721 -1185
- package/lib/Socket/messages-send.d.ts +160 -161
- package/lib/Socket/messages-send.js +992 -642
- package/lib/Socket/mex.d.ts +0 -1
- package/lib/Socket/mex.js +9 -4
- package/lib/Socket/newsletter.d.ts +139 -139
- package/lib/Socket/newsletter.js +258 -153
- package/lib/Socket/registration.d.ts +266 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +36 -42
- package/lib/Socket/socket.js +615 -533
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +83 -0
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +24 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +90 -0
- package/lib/Store/make-in-memory-store.d.ts +123 -0
- package/lib/Store/make-in-memory-store.js +429 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +86 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +31 -0
- package/lib/Types/Auth.d.ts +96 -87
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Call.d.ts +13 -13
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.d.ts +94 -79
- package/lib/Types/Chat.js +9 -8
- package/lib/Types/Contact.d.ts +9 -13
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.d.ts +179 -152
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.d.ts +48 -49
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.d.ts +14 -13
- package/lib/Types/Label.js +30 -24
- package/lib/Types/LabelAssociation.d.ts +20 -15
- package/lib/Types/LabelAssociation.js +12 -6
- package/lib/Types/Message.d.ts +404 -234
- package/lib/Types/Message.js +13 -11
- package/lib/Types/MexUpdates.d.ts +9 -0
- package/lib/Types/MexUpdates.js +18 -0
- package/lib/Types/Newsletter.d.ts +104 -130
- package/lib/Types/Newsletter.js +40 -31
- package/lib/Types/Product.d.ts +71 -58
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.d.ts +55 -63
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.d.ts +66 -77
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/State.d.ts +19 -17
- package/lib/Types/State.js +14 -13
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.d.ts +61 -47
- package/lib/Types/index.js +48 -26
- package/lib/Utils/auth-utils.d.ts +10 -8
- package/lib/Utils/auth-utils.js +154 -206
- package/lib/Utils/baileys-event-stream.d.ts +7 -6
- package/lib/Utils/baileys-event-stream.js +43 -29
- package/lib/Utils/business.d.ts +20 -14
- package/lib/Utils/business.js +134 -110
- package/lib/Utils/chat-utils.d.ts +69 -57
- package/lib/Utils/chat-utils.js +380 -362
- package/lib/Utils/check-npm-version.d.ts +15 -0
- package/lib/Utils/check-npm-version.js +52 -0
- package/lib/Utils/crypto.d.ts +45 -30
- package/lib/Utils/crypto.js +178 -141
- package/lib/Utils/decode-wa-message.d.ts +35 -42
- package/lib/Utils/decode-wa-message.js +150 -176
- package/lib/Utils/event-buffer.d.ts +17 -12
- package/lib/Utils/event-buffer.js +286 -269
- package/lib/Utils/generics.d.ts +99 -60
- package/lib/Utils/generics.js +481 -244
- package/lib/Utils/history.d.ts +22 -18
- package/lib/Utils/history.js +80 -54
- package/lib/Utils/index.d.ts +19 -20
- package/lib/Utils/index.js +41 -19
- package/lib/Utils/link-preview.d.ts +14 -12
- package/lib/Utils/link-preview.js +75 -40
- package/lib/Utils/logger.d.ts +11 -10
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +13 -12
- package/lib/Utils/lt-hash.js +37 -27
- package/lib/Utils/make-mutex.d.ts +7 -6
- package/lib/Utils/make-mutex.js +29 -20
- package/lib/Utils/message-retry-manager.d.ts +6 -6
- package/lib/Utils/message-retry-manager.js +36 -8
- package/lib/Utils/messages-media.d.ts +102 -87
- package/lib/Utils/messages-media.js +570 -427
- package/lib/Utils/messages.d.ts +64 -37
- package/lib/Utils/messages.js +1270 -511
- package/lib/Utils/noise-handler.d.ts +18 -18
- package/lib/Utils/noise-handler.js +109 -101
- package/lib/Utils/process-message.d.ts +32 -25
- package/lib/Utils/process-message.js +281 -266
- package/lib/Utils/signal.d.ts +32 -24
- package/lib/Utils/signal.js +105 -98
- package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
- package/lib/Utils/use-mongo-file-auth-state.js +84 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -5
- package/lib/Utils/use-multi-file-auth-state.js +186 -69
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-single-file-auth-state.js +80 -0
- package/lib/Utils/validate-connection.d.ts +13 -11
- package/lib/Utils/validate-connection.js +116 -124
- package/lib/WABinary/constants.d.ts +27 -25
- package/lib/WABinary/constants.js +1292 -1277
- package/lib/WABinary/decode.d.ts +9 -7
- package/lib/WABinary/decode.js +189 -139
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +154 -105
- package/lib/WABinary/generic-utils.d.ts +27 -14
- package/lib/WABinary/generic-utils.js +102 -62
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +25 -6
- package/lib/WABinary/jid-utils.d.ts +46 -41
- package/lib/WABinary/jid-utils.js +80 -84
- package/lib/WABinary/types.d.ts +13 -10
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -8
- package/lib/WAM/BinaryInfo.js +14 -7
- package/lib/WAM/constants.d.ts +37 -30
- package/lib/WAM/constants.js +11983 -19465
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.js +110 -95
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +23 -4
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +28 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +69 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +19 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
- package/lib/WAUSync/Protocols/index.d.ts +6 -5
- package/lib/WAUSync/Protocols/index.js +26 -5
- package/lib/WAUSync/USyncQuery.d.ts +28 -26
- package/lib/WAUSync/USyncQuery.js +62 -64
- package/lib/WAUSync/USyncUser.d.ts +10 -11
- package/lib/WAUSync/USyncUser.js +19 -12
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +23 -4
- package/lib/index.d.ts +11 -10
- package/lib/index.js +33 -11
- package/package.json +43 -48
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/fix-imports.js +0 -29
- package/engine-requirements.js +0 -10
- 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 +0 -12
- 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 +0 -30
- 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 +0 -82
- 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 +0 -12
- 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 +0 -18
- 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 +0 -26
- 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 +0 -63
- 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 +0 -66
- 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 +0 -48
- 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 +0 -41
- 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 +0 -84
- 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.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 -171
- package/lib/Signal/lid-mapping.js.map +0 -1
- 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.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- 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.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- 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.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- 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.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
- package/lib/Utils/baileys-event-stream.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 +0 -28
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- 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.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- 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.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- 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.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- 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.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.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.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- 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.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- 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.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- 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.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- 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.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- 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.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.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 +0 -51
- 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 +0 -29
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- 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.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const WAProto_1 = require("../../WAProto")
|
|
6
|
+
const Types_1 = require("../Types")
|
|
7
|
+
const messages_1 = require("../Utils/messages")
|
|
8
|
+
const WABinary_1 = require("../WABinary")
|
|
9
|
+
const crypto_1 = require("./crypto")
|
|
10
|
+
const generics_1 = require("./generics")
|
|
11
|
+
const history_1 = require("./history")
|
|
12
|
+
const chats_1 = require("../Socket/chats")
|
|
8
13
|
const REAL_MSG_STUB_TYPES = new Set([
|
|
9
|
-
WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
10
|
-
WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
11
|
-
WAMessageStubType.CALL_MISSED_VIDEO,
|
|
12
|
-
WAMessageStubType.CALL_MISSED_VOICE
|
|
13
|
-
])
|
|
14
|
-
|
|
14
|
+
Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
15
|
+
Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
16
|
+
Types_1.WAMessageStubType.CALL_MISSED_VIDEO,
|
|
17
|
+
Types_1.WAMessageStubType.CALL_MISSED_VOICE
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([
|
|
21
|
+
Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD
|
|
22
|
+
])
|
|
23
|
+
|
|
15
24
|
/** Cleans a received message to further processing */
|
|
16
|
-
|
|
25
|
+
const cleanMessage = (message, meId) => {
|
|
17
26
|
// ensure remoteJid and participant doesn't have device or agent in it
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
else {
|
|
22
|
-
message.key.remoteJid = jidNormalizedUser(message.key.remoteJid);
|
|
23
|
-
}
|
|
24
|
-
if (isHostedPnUser(message.key.participant) || isHostedLidUser(message.key.participant)) {
|
|
25
|
-
message.key.participant = jidEncode(jidDecode(message.key.participant)?.user, isHostedPnUser(message.key.participant) ? 's.whatsapp.net' : 'lid');
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
message.key.participant = jidNormalizedUser(message.key.participant);
|
|
29
|
-
}
|
|
30
|
-
const content = normalizeMessageContent(message.message);
|
|
27
|
+
message.key.remoteJid = WABinary_1.jidNormalizedUser(message.key.remoteJid)
|
|
28
|
+
message.key.participant = message.key.participant ? WABinary_1.jidNormalizedUser(message.key.participant) : undefined
|
|
29
|
+
const content = messages_1.normalizeMessageContent(message.message)
|
|
31
30
|
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
|
32
31
|
if (content?.reactionMessage) {
|
|
33
|
-
normaliseKey(content.reactionMessage.key)
|
|
32
|
+
normaliseKey(content.reactionMessage.key)
|
|
34
33
|
}
|
|
35
34
|
if (content?.pollUpdateMessage) {
|
|
36
|
-
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey)
|
|
35
|
+
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey)
|
|
37
36
|
}
|
|
38
37
|
function normaliseKey(msgKey) {
|
|
39
38
|
// if the reaction is from another user
|
|
@@ -42,178 +41,188 @@ export const cleanMessage = (message, meId, meLid) => {
|
|
|
42
41
|
// if the sender believed the message being reacted to is not from them
|
|
43
42
|
// we've to correct the key to be from them, or some other participant
|
|
44
43
|
msgKey.fromMe = !msgKey.fromMe
|
|
45
|
-
? areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
false;
|
|
44
|
+
? WABinary_1.areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
|
|
45
|
+
// if the message being reacted to, was from them
|
|
46
|
+
// fromMe automatically becomes false
|
|
47
|
+
: false
|
|
50
48
|
// set the remoteJid to being the same as the chat the message came from
|
|
51
|
-
|
|
52
|
-
msgKey.remoteJid = message.key.remoteJid;
|
|
49
|
+
msgKey.remoteJid = message.key.remoteJid
|
|
53
50
|
// set participant of the message
|
|
54
|
-
msgKey.participant = msgKey.participant || message.key.participant
|
|
51
|
+
msgKey.participant = msgKey.participant || message.key.participant
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const normalizedContent = normalizeMessageContent(message.message)
|
|
61
|
-
const hasSomeContent = !!getContentType(normalizedContent)
|
|
62
|
-
return (
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const isRealMessage = (message, meId) => {
|
|
57
|
+
const normalizedContent = messages_1.normalizeMessageContent(message.message)
|
|
58
|
+
const hasSomeContent = !!messages_1.getContentType(normalizedContent)
|
|
59
|
+
return (
|
|
60
|
+
!!normalizedContent ||
|
|
63
61
|
REAL_MSG_STUB_TYPES.has(message.messageStubType) ||
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
(
|
|
63
|
+
REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType) &&
|
|
64
|
+
message.messageStubParameters?.some(p => WABinary_1.areJidsSameUser(meId, p))
|
|
65
|
+
)
|
|
66
|
+
) &&
|
|
67
|
+
hasSomeContent &&
|
|
68
|
+
!normalizedContent?.protocolMessage &&
|
|
69
|
+
!normalizedContent?.reactionMessage &&
|
|
70
|
+
!normalizedContent?.pollUpdateMessage
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const shouldIncrementChatUnread = (message) => (!message.key.fromMe && !message.messageStubType)
|
|
74
|
+
|
|
71
75
|
/**
|
|
72
76
|
* Get the ID of the chat from the given key.
|
|
73
77
|
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
74
78
|
*/
|
|
75
|
-
|
|
76
|
-
if (isJidBroadcast(remoteJid)
|
|
77
|
-
|
|
79
|
+
const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
80
|
+
if (WABinary_1.isJidBroadcast(remoteJid)
|
|
81
|
+
&& !WABinary_1.isJidStatusBroadcast(remoteJid)
|
|
82
|
+
&& !fromMe) {
|
|
83
|
+
return participant
|
|
78
84
|
}
|
|
79
|
-
return remoteJid
|
|
80
|
-
}
|
|
85
|
+
return remoteJid
|
|
86
|
+
}
|
|
87
|
+
|
|
81
88
|
/**
|
|
82
89
|
* Decrypt a poll vote
|
|
83
90
|
* @param vote encrypted vote
|
|
84
91
|
* @param ctx additional info about the poll required for decryption
|
|
85
92
|
* @returns list of SHA256 options
|
|
86
93
|
*/
|
|
87
|
-
|
|
94
|
+
function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }) {
|
|
88
95
|
const sign = Buffer.concat([
|
|
89
96
|
toBinary(pollMsgId),
|
|
90
97
|
toBinary(pollCreatorJid),
|
|
91
98
|
toBinary(voterJid),
|
|
92
99
|
toBinary('Poll Vote'),
|
|
93
100
|
new Uint8Array([1])
|
|
94
|
-
])
|
|
95
|
-
const key0 = hmacSign(pollEncKey, new Uint8Array(32), 'sha256')
|
|
96
|
-
const decKey = hmacSign(sign, key0, 'sha256')
|
|
97
|
-
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`)
|
|
98
|
-
const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad)
|
|
99
|
-
return proto.Message.PollVoteMessage.decode(decrypted)
|
|
101
|
+
])
|
|
102
|
+
const key0 = crypto_1.hmacSign(pollEncKey, new Uint8Array(32), 'sha256')
|
|
103
|
+
const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
|
|
104
|
+
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`)
|
|
105
|
+
const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, aad)
|
|
106
|
+
return WAProto_1.proto.Message.PollVoteMessage.decode(decrypted)
|
|
100
107
|
function toBinary(txt) {
|
|
101
|
-
return Buffer.from(txt)
|
|
108
|
+
return Buffer.from(txt)
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
111
|
+
|
|
112
|
+
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options, getMessage }) => {
|
|
113
|
+
const meId = creds.me.id
|
|
114
|
+
const { accountSettings } = creds
|
|
115
|
+
const chat = { id: WABinary_1.jidNormalizedUser(getChatId(message.key)) }
|
|
116
|
+
const isRealMsg = isRealMessage(message, meId)
|
|
109
117
|
if (isRealMsg) {
|
|
110
|
-
chat.messages = [{ message }]
|
|
111
|
-
chat.conversationTimestamp = toNumber(message.messageTimestamp)
|
|
118
|
+
chat.messages = [{ message }]
|
|
119
|
+
chat.conversationTimestamp = generics_1.toNumber(message.messageTimestamp)
|
|
112
120
|
// only increment unread count if not CIPHERTEXT and from another person
|
|
113
121
|
if (shouldIncrementChatUnread(message)) {
|
|
114
|
-
chat.unreadCount = (chat.unreadCount || 0) + 1
|
|
122
|
+
chat.unreadCount = (chat.unreadCount || 0) + 1
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
|
-
const content = normalizeMessageContent(message.message)
|
|
125
|
+
const content = messages_1.normalizeMessageContent(message.message)
|
|
118
126
|
// unarchive chat if it's a real message, or someone reacted to our message
|
|
119
127
|
// and we've the unarchive chats setting on
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
chat.
|
|
128
|
+
if (isRealMsg || content?.reactionMessage?.key?.fromMe
|
|
129
|
+
&& accountSettings?.unarchiveChats) {
|
|
130
|
+
chat.archived = false
|
|
131
|
+
chat.readOnly = false
|
|
123
132
|
}
|
|
124
|
-
const protocolMsg = content?.protocolMessage
|
|
133
|
+
const protocolMsg = content?.protocolMessage
|
|
125
134
|
if (protocolMsg) {
|
|
126
135
|
switch (protocolMsg.type) {
|
|
127
|
-
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
128
|
-
const histNotification = protocolMsg.historySyncNotification
|
|
129
|
-
const process = shouldProcessHistoryMsg
|
|
130
|
-
const isLatest = !creds.processedHistoryMessages?.length
|
|
136
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
137
|
+
const histNotification = protocolMsg.historySyncNotification
|
|
138
|
+
const process = shouldProcessHistoryMsg
|
|
139
|
+
const isLatest = !creds.processedHistoryMessages?.length
|
|
131
140
|
logger?.info({
|
|
132
141
|
histNotification,
|
|
133
142
|
process,
|
|
134
143
|
id: message.key.id,
|
|
135
|
-
isLatest
|
|
136
|
-
}, 'got history notification')
|
|
144
|
+
isLatest,
|
|
145
|
+
}, 'got history notification')
|
|
137
146
|
if (process) {
|
|
138
|
-
|
|
139
|
-
if (histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
147
|
+
if (histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
140
148
|
ev.emit('creds.update', {
|
|
141
149
|
processedHistoryMessages: [
|
|
142
150
|
...(creds.processedHistoryMessages || []),
|
|
143
151
|
{ key: message.key, messageTimestamp: message.messageTimestamp }
|
|
144
152
|
]
|
|
145
|
-
})
|
|
153
|
+
})
|
|
146
154
|
}
|
|
147
|
-
const data = await downloadAndProcessHistorySyncNotification(histNotification, options)
|
|
155
|
+
const data = await history_1.downloadAndProcessHistorySyncNotification(histNotification, options)
|
|
148
156
|
ev.emit('messaging-history.set', {
|
|
149
157
|
...data,
|
|
150
|
-
isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
158
|
+
isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
159
|
+
? isLatest
|
|
160
|
+
: undefined,
|
|
151
161
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
152
|
-
})
|
|
162
|
+
})
|
|
153
163
|
}
|
|
154
|
-
break
|
|
155
|
-
case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
156
|
-
const keys = protocolMsg.appStateSyncKeyShare.keys
|
|
164
|
+
break
|
|
165
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
166
|
+
const keys = protocolMsg.appStateSyncKeyShare.keys
|
|
157
167
|
if (keys?.length) {
|
|
158
|
-
let newAppStateSyncKeyId = ''
|
|
168
|
+
let newAppStateSyncKeyId = ''
|
|
159
169
|
await keyStore.transaction(async () => {
|
|
160
|
-
const newKeys = []
|
|
170
|
+
const newKeys = []
|
|
161
171
|
for (const { keyData, keyId } of keys) {
|
|
162
|
-
const strKeyId = Buffer.from(keyId.keyId).toString('base64')
|
|
163
|
-
newKeys.push(strKeyId)
|
|
164
|
-
await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } })
|
|
165
|
-
newAppStateSyncKeyId = strKeyId
|
|
172
|
+
const strKeyId = Buffer.from(keyId.keyId).toString('base64')
|
|
173
|
+
newKeys.push(strKeyId)
|
|
174
|
+
await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } })
|
|
175
|
+
newAppStateSyncKeyId = strKeyId
|
|
166
176
|
}
|
|
167
|
-
logger?.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys')
|
|
168
|
-
}
|
|
169
|
-
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId })
|
|
177
|
+
logger?.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys')
|
|
178
|
+
})
|
|
179
|
+
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId })
|
|
170
180
|
}
|
|
171
181
|
else {
|
|
172
|
-
logger?.info({ protocolMsg }, 'recv app state sync with 0 keys')
|
|
182
|
+
logger?.info({ protocolMsg }, 'recv app state sync with 0 keys')
|
|
173
183
|
}
|
|
174
|
-
break
|
|
175
|
-
case proto.Message.ProtocolMessage.Type.REVOKE:
|
|
184
|
+
break
|
|
185
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE:
|
|
176
186
|
ev.emit('messages.update', [
|
|
177
187
|
{
|
|
178
188
|
key: {
|
|
179
189
|
...message.key,
|
|
180
190
|
id: protocolMsg.key.id
|
|
181
191
|
},
|
|
182
|
-
update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
|
|
192
|
+
update: { message: null, messageStubType: Types_1.WAMessageStubType.REVOKE, key: message.key }
|
|
183
193
|
}
|
|
184
|
-
])
|
|
185
|
-
break
|
|
186
|
-
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
194
|
+
])
|
|
195
|
+
break
|
|
196
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
187
197
|
Object.assign(chat, {
|
|
188
|
-
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
|
|
198
|
+
ephemeralSettingTimestamp: generics_1.toNumber(message.messageTimestamp),
|
|
189
199
|
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
|
190
|
-
})
|
|
191
|
-
break
|
|
192
|
-
case proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
193
|
-
const response = protocolMsg.peerDataOperationRequestResponseMessage
|
|
200
|
+
})
|
|
201
|
+
break
|
|
202
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
203
|
+
const response = protocolMsg.peerDataOperationRequestResponseMessage
|
|
194
204
|
if (response) {
|
|
195
|
-
|
|
205
|
+
placeholderResendCache?.del(response.stanzaId)
|
|
196
206
|
// TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
|
|
197
|
-
const { peerDataOperationResult } = response
|
|
207
|
+
const { peerDataOperationResult } = response
|
|
198
208
|
for (const result of peerDataOperationResult) {
|
|
199
|
-
const { placeholderMessageResendResponse: retryResponse } = result
|
|
209
|
+
const { placeholderMessageResendResponse: retryResponse } = result
|
|
200
210
|
//eslint-disable-next-line max-depth
|
|
201
211
|
if (retryResponse) {
|
|
202
|
-
const webMessageInfo = proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes)
|
|
212
|
+
const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes)
|
|
203
213
|
// wait till another upsert event is available, don't want it to be part of the PDO response message
|
|
204
|
-
// TODO: parse through proper message handling utilities (to add relevant key fields)
|
|
205
214
|
setTimeout(() => {
|
|
206
215
|
ev.emit('messages.upsert', {
|
|
207
216
|
messages: [webMessageInfo],
|
|
208
217
|
type: 'notify',
|
|
209
218
|
requestId: response.stanzaId
|
|
210
|
-
})
|
|
211
|
-
}, 500)
|
|
219
|
+
})
|
|
220
|
+
}, 500)
|
|
212
221
|
}
|
|
213
222
|
}
|
|
214
223
|
}
|
|
215
|
-
break
|
|
216
|
-
case proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
224
|
+
break
|
|
225
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
217
226
|
ev.emit('messages.update', [
|
|
218
227
|
{
|
|
219
228
|
// flip the sender / fromMe properties because they're in the perspective of the sender
|
|
@@ -225,159 +234,162 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
225
234
|
}
|
|
226
235
|
},
|
|
227
236
|
messageTimestamp: protocolMsg.timestampMs
|
|
228
|
-
? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
|
|
237
|
+
? Math.floor(generics_1.toNumber(protocolMsg.timestampMs) / 1000)
|
|
229
238
|
: message.messageTimestamp
|
|
230
239
|
}
|
|
231
240
|
}
|
|
232
|
-
])
|
|
233
|
-
break
|
|
234
|
-
case proto.Message.ProtocolMessage.Type.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
await signalRepository.lidMapping.storeLIDPNMappings(pairs);
|
|
244
|
-
if (pairs.length) {
|
|
245
|
-
for (const { pn, lid } of pairs) {
|
|
246
|
-
await signalRepository.migrateSession(pn, lid);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
241
|
+
])
|
|
242
|
+
break
|
|
243
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.LIMIT_SHARING:
|
|
244
|
+
ev.emit('limit-sharing.update', {
|
|
245
|
+
id: protocolMsg.key.remoteJid,
|
|
246
|
+
author: WABinary_1.areJidsSameUser(message.key.remoteJid, protocolMsg.key.remoteJid) ? WABinary_1.jidNormalizedUser(meId) : message.key.remoteJid,
|
|
247
|
+
action: `${protocolMsg.limitSharing.sharingLimited ? 'on' : 'off'}`,
|
|
248
|
+
trigger: protocolMsg.limitSharing.trigger,
|
|
249
|
+
update_time: protocolMsg.limitSharing.limitSharingSettingTimestamp
|
|
250
|
+
})
|
|
251
|
+
break
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
else if (content?.reactionMessage) {
|
|
252
255
|
const reaction = {
|
|
253
256
|
...content.reactionMessage,
|
|
254
|
-
key: message.key
|
|
255
|
-
}
|
|
256
|
-
ev.emit('messages.reaction', [
|
|
257
|
-
{
|
|
257
|
+
key: message.key,
|
|
258
|
+
}
|
|
259
|
+
ev.emit('messages.reaction', [{
|
|
258
260
|
reaction,
|
|
259
261
|
key: content.reactionMessage?.key
|
|
260
|
-
}
|
|
261
|
-
]);
|
|
262
|
+
}])
|
|
262
263
|
}
|
|
263
264
|
else if (message.messageStubType) {
|
|
264
|
-
const jid = message.key?.remoteJid
|
|
265
|
+
const jid = message.key?.remoteJid
|
|
266
|
+
|
|
265
267
|
//let actor = whatsappID (message.participant)
|
|
266
|
-
let participants
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
authorPn: message.key.participantAlt,
|
|
271
|
-
participants,
|
|
272
|
-
action
|
|
273
|
-
});
|
|
268
|
+
let participants
|
|
269
|
+
|
|
270
|
+
const jid2 = message.key.participant;
|
|
271
|
+
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: jid2, participants, action}))
|
|
274
272
|
const emitGroupUpdate = (update) => {
|
|
275
|
-
ev.emit('groups.update', [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
273
|
+
ev.emit('groups.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined }])
|
|
274
|
+
}
|
|
275
|
+
const emitCommunityUpdate = (update) => {
|
|
276
|
+
ev.emit('communities.update', [{ id: jid, ...update, author: message.participant ? message.participant : undefined }])
|
|
277
|
+
}
|
|
279
278
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
280
|
-
ev.emit('group.join-request', {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
authorPn: message.key.participantAlt,
|
|
284
|
-
participant: participant.lid,
|
|
285
|
-
participantPn: participant.pn,
|
|
286
|
-
action,
|
|
287
|
-
method: method
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
const participantsIncludesMe = () => participants.find(jid => areJidsSameUser(meId, jid.phoneNumber)); // ADD SUPPORT FOR LID
|
|
279
|
+
ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method })
|
|
280
|
+
}
|
|
281
|
+
const participantsIncludesMe = () => participants.find(jid => WABinary_1.areJidsSameUser(meId, jid))
|
|
291
282
|
switch (message.messageStubType) {
|
|
292
|
-
case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
293
|
-
participants = message.messageStubParameters
|
|
294
|
-
emitParticipantsUpdate('modify')
|
|
295
|
-
break
|
|
296
|
-
case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
283
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
284
|
+
participants = message.messageStubParameters || []
|
|
285
|
+
emitParticipantsUpdate('modify')
|
|
286
|
+
break
|
|
287
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
288
|
+
participants = message.messageStubParameters || [];
|
|
289
|
+
emitParticipantsUpdate('leave');
|
|
290
|
+
// mark the chat read only if you left the group
|
|
291
|
+
if (participantsIncludesMe()) {
|
|
292
|
+
chat.readOnly = true;
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
296
|
+
participants = message.messageStubParameters || []
|
|
297
|
+
emitParticipantsUpdate('remove')
|
|
300
298
|
// mark the chat read only if you left the group
|
|
301
299
|
if (participantsIncludesMe()) {
|
|
302
|
-
chat.readOnly = true
|
|
300
|
+
chat.readOnly = true
|
|
303
301
|
}
|
|
304
|
-
break
|
|
305
|
-
case WAMessageStubType.GROUP_PARTICIPANT_ADD:
|
|
306
|
-
case WAMessageStubType.GROUP_PARTICIPANT_INVITE:
|
|
307
|
-
|
|
308
|
-
|
|
302
|
+
break
|
|
303
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD:
|
|
304
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_INVITE:
|
|
305
|
+
let actionGp = 'invite'
|
|
306
|
+
participants = message.messageStubParameters || []
|
|
307
|
+
if (participantsIncludesMe()) chat.readOnly = false;
|
|
308
|
+
if (message?.key?.participant && !participants.includes(message?.key?.participant)) {
|
|
309
|
+
actionGp = 'approval-invite'
|
|
310
|
+
}
|
|
311
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
|
|
312
|
+
participants = message.messageStubParameters || []
|
|
309
313
|
if (participantsIncludesMe()) {
|
|
310
|
-
chat.readOnly = false
|
|
314
|
+
chat.readOnly = false
|
|
311
315
|
}
|
|
312
|
-
emitParticipantsUpdate('add')
|
|
313
|
-
break
|
|
314
|
-
case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
break
|
|
352
|
-
case WAMessageStubType.
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
316
|
+
emitParticipantsUpdate('add')
|
|
317
|
+
break
|
|
318
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
319
|
+
case Types_1.WAMessageStubType.COMMUNITY_PARTICIPANT_DEMOTE:
|
|
320
|
+
participants = message.messageStubParameters || []
|
|
321
|
+
emitParticipantsUpdate('demote')
|
|
322
|
+
break
|
|
323
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
|
|
324
|
+
case Types_1.WAMessageStubType.COMMUNITY_PARTICIPANT_PROMOTE:
|
|
325
|
+
participants = message.messageStubParameters || []
|
|
326
|
+
emitParticipantsUpdate('promote')
|
|
327
|
+
break
|
|
328
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
329
|
+
const announceValue = message.messageStubParameters?.[0]
|
|
330
|
+
emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' })
|
|
331
|
+
break
|
|
332
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
|
333
|
+
const restrictValue = message.messageStubParameters?.[0]
|
|
334
|
+
emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' })
|
|
335
|
+
break
|
|
336
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
|
337
|
+
const name = message.messageStubParameters?.[0]
|
|
338
|
+
chat.name = name
|
|
339
|
+
emitGroupUpdate({ subject: name })
|
|
340
|
+
break
|
|
341
|
+
case Types_1.WAMessageStubType.COMMUNITY_PARENT_GROUP_SUBJECT_CHANGED:
|
|
342
|
+
const name2 = message.messageStubParameters?.[0]
|
|
343
|
+
chat.name2 = name2
|
|
344
|
+
emitCommunityUpdate({ subject: name2 })
|
|
345
|
+
break
|
|
346
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
|
|
347
|
+
const description = message.messageStubParameters?.[0]
|
|
348
|
+
chat.description = description
|
|
349
|
+
emitGroupUpdate({ desc: description })
|
|
350
|
+
break
|
|
351
|
+
case Types_1.WAMessageStubType.COMMUNITY_CHANGE_DESCRIPTION:
|
|
352
|
+
const description2 = message.messageStubParameters?.[0]
|
|
353
|
+
chat.description2 = description2
|
|
354
|
+
emitCommunityUpdate({ desc: description2 })
|
|
355
|
+
break
|
|
356
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
|
|
357
|
+
const code = message.messageStubParameters?.[0]
|
|
358
|
+
emitGroupUpdate({ inviteCode: code })
|
|
359
|
+
break
|
|
360
|
+
case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
361
|
+
const memberAddValue = message.messageStubParameters?.[0]
|
|
362
|
+
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' })
|
|
363
|
+
break
|
|
364
|
+
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
365
|
+
const approvalMode = message.messageStubParameters?.[0]
|
|
366
|
+
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' })
|
|
367
|
+
break
|
|
368
|
+
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
|
|
369
|
+
const participant = message.messageStubParameters?.[0]
|
|
370
|
+
const action = message.messageStubParameters?.[1]
|
|
371
|
+
const method = message.messageStubParameters?.[2]
|
|
372
|
+
emitGroupRequestJoin(participant, action, method)
|
|
373
|
+
break
|
|
358
374
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
375
|
+
}
|
|
376
|
+
else if (content?.pollUpdateMessage) {
|
|
377
|
+
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey
|
|
361
378
|
// we need to fetch the poll creation message to get the poll enc key
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
-
const pollEncKey = pollMsg.messageContextInfo?.messageSecret!
|
|
370
|
-
|
|
379
|
+
const pollMsg2 = await getMessage(creationMsgKey);
|
|
380
|
+
const pollMsg = pollMsg.botInvokeMessage?.message || pollMsg2;
|
|
381
|
+
if (pollMsg) {
|
|
382
|
+
const meIdNormalised = WABinary_1.jidNormalizedUser(meId)
|
|
383
|
+
const pollCreatorJid = generics_1.getKeyAuthor(creationMsgKey, meIdNormalised)
|
|
384
|
+
const voterJid = generics_1.getKeyAuthor(message.key, meIdNormalised)
|
|
385
|
+
const pollEncKey = pollMsg.messageContextInfo?.messageSecret
|
|
371
386
|
try {
|
|
372
|
-
const voteMsg = decryptPollVote(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
voterJid,
|
|
379
|
-
}
|
|
380
|
-
)
|
|
387
|
+
const voteMsg = decryptPollVote(content.pollUpdateMessage.vote, {
|
|
388
|
+
pollEncKey,
|
|
389
|
+
pollCreatorJid,
|
|
390
|
+
pollMsgId: creationMsgKey.id,
|
|
391
|
+
voterJid,
|
|
392
|
+
})
|
|
381
393
|
ev.emit('messages.update', [
|
|
382
394
|
{
|
|
383
395
|
key: creationMsgKey,
|
|
@@ -386,28 +398,31 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
386
398
|
{
|
|
387
399
|
pollUpdateMessageKey: message.key,
|
|
388
400
|
vote: voteMsg,
|
|
389
|
-
senderTimestampMs:
|
|
401
|
+
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
|
|
390
402
|
}
|
|
391
403
|
]
|
|
392
404
|
}
|
|
393
405
|
}
|
|
394
406
|
])
|
|
395
|
-
} catch(err) {
|
|
396
|
-
logger?.warn(
|
|
397
|
-
{ err, creationMsgKey },
|
|
398
|
-
'failed to decrypt poll vote'
|
|
399
|
-
)
|
|
400
407
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
408
|
+
catch (err) {
|
|
409
|
+
logger?.warn({ err, creationMsgKey }, 'failed to decrypt poll vote')
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
logger?.warn({ creationMsgKey }, 'poll creation message not found, cannot decrypt update')
|
|
406
414
|
}
|
|
407
|
-
|
|
415
|
+
}
|
|
408
416
|
if (Object.keys(chat).length > 1) {
|
|
409
|
-
ev.emit('chats.update', [chat])
|
|
417
|
+
ev.emit('chats.update', [chat])
|
|
410
418
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
module.exports = {
|
|
422
|
+
cleanMessage,
|
|
423
|
+
isRealMessage,
|
|
424
|
+
shouldIncrementChatUnread,
|
|
425
|
+
getChatId,
|
|
426
|
+
decryptPollVote,
|
|
427
|
+
processMessage
|
|
428
|
+
}
|