lordceaser-baileys 2.0.0 → 2.0.2
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/index.js +136901 -78899
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -3
- package/index.js +17 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +15 -37
- package/lib/Defaults/index.js +60 -81
- package/lib/Signal/libsignal.d.ts +3 -5
- package/lib/Signal/libsignal.js +80 -359
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +5 -4
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -3
- package/lib/Socket/Client/index.js +19 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +2 -3
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +100 -147
- package/lib/Socket/business.js +43 -162
- package/lib/Socket/chats.d.ts +41 -85
- package/lib/Socket/chats.js +321 -569
- package/lib/Socket/groups.d.ts +57 -103
- package/lib/Socket/groups.js +84 -116
- package/lib/Socket/index.d.ts +106 -194
- package/lib/Socket/index.js +9 -11
- package/lib/Socket/messages-recv.d.ts +89 -134
- package/lib/Socket/messages-recv.js +475 -1275
- package/lib/Socket/messages-send.d.ts +97 -141
- package/lib/Socket/messages-send.js +633 -691
- package/lib/Socket/newsletter.d.ts +74 -112
- package/lib/Socket/newsletter.js +202 -147
- package/lib/Socket/registration.d.ts +264 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +19 -34
- package/lib/Socket/socket.js +219 -547
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +10 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +431 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +11 -19
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.d.ts +1 -3
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.d.ts +8 -25
- package/lib/Types/Chat.js +4 -8
- package/lib/Types/Contact.d.ts +1 -8
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.d.ts +17 -101
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.d.ts +3 -18
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.d.ts +0 -1
- package/lib/Types/Label.js +5 -3
- package/lib/Types/LabelAssociation.d.ts +0 -1
- package/lib/Types/LabelAssociation.js +5 -3
- package/lib/Types/Message.d.ts +204 -91
- package/lib/Types/Message.js +9 -11
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Newsletter.js +32 -0
- package/lib/Types/Product.d.ts +1 -2
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.d.ts +2 -32
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.d.ts +24 -44
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.d.ts +2 -72
- package/lib/Types/State.js +2 -56
- package/lib/Types/USync.d.ts +2 -3
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.d.ts +16 -16
- package/lib/Types/index.js +31 -15
- package/lib/Utils/auth-utils.d.ts +6 -12
- package/lib/Utils/auth-utils.js +143 -239
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +3 -4
- package/lib/Utils/business.js +69 -66
- package/lib/Utils/c4-compat.js +0 -8
- package/lib/Utils/chat-utils.d.ts +17 -47
- package/lib/Utils/chat-utils.js +237 -364
- package/lib/Utils/crypto.d.ts +21 -18
- package/lib/Utils/crypto.js +125 -44
- package/lib/Utils/decode-wa-message.d.ts +8 -38
- package/lib/Utils/decode-wa-message.js +90 -173
- package/lib/Utils/event-buffer.d.ts +8 -9
- package/lib/Utils/event-buffer.js +71 -176
- package/lib/Utils/generics.d.ts +22 -26
- package/lib/Utils/generics.js +175 -166
- package/lib/Utils/history.d.ts +11 -16
- package/lib/Utils/history.js +53 -93
- package/lib/Utils/index.d.ts +17 -22
- package/lib/Utils/index.js +34 -22
- package/lib/Utils/link-preview.d.ts +5 -5
- package/lib/Utils/link-preview.js +24 -16
- package/lib/Utils/logger.d.ts +1 -11
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +12 -8
- package/lib/Utils/lt-hash.js +46 -3
- package/lib/Utils/make-mutex.d.ts +0 -2
- package/lib/Utils/make-mutex.js +34 -24
- package/lib/Utils/messages-media.d.ts +45 -65
- package/lib/Utils/messages-media.js +358 -425
- package/lib/Utils/messages.d.ts +18 -32
- package/lib/Utils/messages.js +720 -392
- package/lib/Utils/noise-handler.d.ts +13 -13
- package/lib/Utils/noise-handler.js +108 -149
- package/lib/Utils/process-message.d.ts +11 -30
- package/lib/Utils/process-message.js +166 -423
- package/lib/Utils/signal.d.ts +6 -20
- package/lib/Utils/signal.js +65 -107
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +103 -57
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-single-file-auth-state.js +76 -0
- package/lib/Utils/validate-connection.d.ts +6 -6
- package/lib/Utils/validate-connection.js +114 -119
- package/lib/WABinary/constants.d.ts +4 -5
- package/lib/WABinary/constants.js +20 -1281
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +53 -51
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +44 -12
- package/lib/WABinary/generic-utils.d.ts +6 -7
- package/lib/WABinary/generic-utils.js +43 -46
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +21 -6
- package/lib/WABinary/jid-utils.d.ts +7 -24
- package/lib/WABinary/jid-utils.js +40 -74
- package/lib/WABinary/types.d.ts +1 -2
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.d.ts +1 -2
- package/lib/WAM/BinaryInfo.js +5 -2
- package/lib/WAM/constants.d.ts +3 -5
- package/lib/WAM/constants.js +11958 -19461
- package/lib/WAM/encode.d.ts +2 -3
- package/lib/WAM/encode.js +22 -17
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +19 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +13 -33
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -9
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -5
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +8 -13
- package/lib/WAUSync/Protocols/index.d.ts +4 -6
- package/lib/WAUSync/Protocols/index.js +20 -6
- package/lib/WAUSync/USyncQuery.d.ts +4 -6
- package/lib/WAUSync/USyncQuery.js +35 -44
- package/lib/WAUSync/USyncUser.d.ts +4 -11
- package/lib/WAUSync/USyncUser.js +5 -10
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +19 -4
- package/lib/index.js +31 -13
- package/package.json +19 -10
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/WAProto.proto +0 -5479
- package/WAProto/fix-imports.js +0 -85
- package/WAProto/index.d.ts +0 -14017
- 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 -277
- 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 +0 -11
- 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 +0 -54
- 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 +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.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 +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.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/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.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/browser-utils.d.ts +0 -4
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js +0 -29
- 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/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.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/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.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 +0 -115
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js +0 -265
- 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/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.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/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 -164
- package/lib/Utils/tc-token-utils.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/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.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- 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.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 +0 -12
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
|
@@ -1,87 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChatId = exports.shouldIncrementChatUnread = exports.isRealMessage = exports.cleanMessage = void 0;
|
|
4
|
+
exports.decryptPollVote = decryptPollVote;
|
|
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");
|
|
10
12
|
const REAL_MSG_STUB_TYPES = new Set([
|
|
11
|
-
WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
12
|
-
WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
13
|
-
WAMessageStubType.CALL_MISSED_VIDEO,
|
|
14
|
-
WAMessageStubType.CALL_MISSED_VOICE
|
|
13
|
+
Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
14
|
+
Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
15
|
+
Types_1.WAMessageStubType.CALL_MISSED_VIDEO,
|
|
16
|
+
Types_1.WAMessageStubType.CALL_MISSED_VOICE
|
|
17
|
+
]);
|
|
18
|
+
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([
|
|
19
|
+
Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD
|
|
15
20
|
]);
|
|
16
|
-
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([WAMessageStubType.GROUP_PARTICIPANT_ADD]);
|
|
17
|
-
async function storeTcTokensFromHistorySync(chats, signalRepository, keyStore, logger) {
|
|
18
|
-
const getLIDForPN = signalRepository.lidMapping.getLIDForPN.bind(signalRepository.lidMapping);
|
|
19
|
-
const candidates = [];
|
|
20
|
-
for (const chat of chats) {
|
|
21
|
-
const ts = chat.tcTokenTimestamp ? toNumber(chat.tcTokenTimestamp) : 0;
|
|
22
|
-
if (chat.tcToken?.length && ts > 0) {
|
|
23
|
-
const jid = jidNormalizedUser(chat.id);
|
|
24
|
-
const storageJid = await resolveTcTokenJid(jid, getLIDForPN);
|
|
25
|
-
candidates.push({
|
|
26
|
-
storageJid,
|
|
27
|
-
token: Buffer.from(chat.tcToken),
|
|
28
|
-
ts,
|
|
29
|
-
senderTs: chat.tcTokenSenderTimestamp ? toNumber(chat.tcTokenSenderTimestamp) : undefined
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!candidates.length) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const jids = candidates.map(c => c.storageJid);
|
|
37
|
-
const existing = await keyStore.get('tctoken', jids);
|
|
38
|
-
const entries = {};
|
|
39
|
-
for (const c of candidates) {
|
|
40
|
-
const existingEntry = existing[c.storageJid];
|
|
41
|
-
const existingTs = existingEntry?.timestamp ? Number(existingEntry.timestamp) : 0;
|
|
42
|
-
if (existingTs > 0 && existingTs >= c.ts) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
entries[c.storageJid] = {
|
|
46
|
-
...existingEntry,
|
|
47
|
-
token: c.token,
|
|
48
|
-
timestamp: String(c.ts),
|
|
49
|
-
...(c.senderTs !== undefined ? { senderTimestamp: c.senderTs } : {})
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (Object.keys(entries).length) {
|
|
53
|
-
logger?.debug({ count: Object.keys(entries).length }, 'storing tctokens from history sync');
|
|
54
|
-
try {
|
|
55
|
-
// Include updated __index so cross-session pruning picks these JIDs up.
|
|
56
|
-
const indexWrite = await buildMergedTcTokenIndexWrite(keyStore, Object.keys(entries));
|
|
57
|
-
await keyStore.set({ tctoken: { ...entries, ...indexWrite } });
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
logger?.warn({ err }, 'failed to store tctokens from history sync');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
21
|
/** Cleans a received message to further processing */
|
|
65
|
-
|
|
22
|
+
const cleanMessage = (message, meId) => {
|
|
66
23
|
// ensure remoteJid and participant doesn't have device or agent in it
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
else {
|
|
71
|
-
message.key.remoteJid = jidNormalizedUser(message.key.remoteJid);
|
|
72
|
-
}
|
|
73
|
-
if (isHostedPnUser(message.key.participant) || isHostedLidUser(message.key.participant)) {
|
|
74
|
-
message.key.participant = jidEncode(jidDecode(message.key.participant)?.user, isHostedPnUser(message.key.participant) ? 's.whatsapp.net' : 'lid');
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
message.key.participant = jidNormalizedUser(message.key.participant);
|
|
78
|
-
}
|
|
79
|
-
const content = normalizeMessageContent(message.message);
|
|
24
|
+
message.key.remoteJid = (0, WABinary_1.jidNormalizedUser)(message.key.remoteJid);
|
|
25
|
+
message.key.participant = message.key.participant ? (0, WABinary_1.jidNormalizedUser)(message.key.participant) : undefined;
|
|
26
|
+
const content = (0, messages_1.normalizeMessageContent)(message.message);
|
|
80
27
|
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
|
81
|
-
if (content
|
|
28
|
+
if (content === null || content === void 0 ? void 0 : content.reactionMessage) {
|
|
82
29
|
normaliseKey(content.reactionMessage.key);
|
|
83
30
|
}
|
|
84
|
-
if (content
|
|
31
|
+
if (content === null || content === void 0 ? void 0 : content.pollUpdateMessage) {
|
|
85
32
|
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey);
|
|
86
33
|
}
|
|
87
34
|
function normaliseKey(msgKey) {
|
|
@@ -91,59 +38,54 @@ export const cleanMessage = (message, meId, meLid) => {
|
|
|
91
38
|
// if the sender believed the message being reacted to is not from them
|
|
92
39
|
// we've to correct the key to be from them, or some other participant
|
|
93
40
|
msgKey.fromMe = !msgKey.fromMe
|
|
94
|
-
? areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
false;
|
|
41
|
+
? (0, WABinary_1.areJidsSameUser)(msgKey.participant || msgKey.remoteJid, meId)
|
|
42
|
+
// if the message being reacted to, was from them
|
|
43
|
+
// fromMe automatically becomes false
|
|
44
|
+
: false;
|
|
99
45
|
// set the remoteJid to being the same as the chat the message came from
|
|
100
|
-
// TODO: investigate inconsistencies
|
|
101
46
|
msgKey.remoteJid = message.key.remoteJid;
|
|
102
47
|
// set participant of the message
|
|
103
48
|
msgKey.participant = msgKey.participant || message.key.participant;
|
|
104
49
|
}
|
|
105
50
|
}
|
|
106
51
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
!normalizedContent
|
|
52
|
+
exports.cleanMessage = cleanMessage;
|
|
53
|
+
const isRealMessage = (message, meId) => {
|
|
54
|
+
var _a;
|
|
55
|
+
const normalizedContent = (0, messages_1.normalizeMessageContent)(message.message);
|
|
56
|
+
const hasSomeContent = !!(0, messages_1.getContentType)(normalizedContent);
|
|
57
|
+
return (!!normalizedContent
|
|
58
|
+
|| REAL_MSG_STUB_TYPES.has(message.messageStubType)
|
|
59
|
+
|| (REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType)
|
|
60
|
+
&& ((_a = message.messageStubParameters) === null || _a === void 0 ? void 0 : _a.some(p => (0, WABinary_1.areJidsSameUser)(meId, p)))))
|
|
61
|
+
&& hasSomeContent
|
|
62
|
+
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.protocolMessage)
|
|
63
|
+
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.reactionMessage)
|
|
64
|
+
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.pollUpdateMessage);
|
|
118
65
|
};
|
|
119
|
-
|
|
66
|
+
exports.isRealMessage = isRealMessage;
|
|
67
|
+
const shouldIncrementChatUnread = (message) => (!message.key.fromMe && !message.messageStubType);
|
|
68
|
+
exports.shouldIncrementChatUnread = shouldIncrementChatUnread;
|
|
120
69
|
/**
|
|
121
70
|
* Get the ID of the chat from the given key.
|
|
122
71
|
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
123
72
|
*/
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
|
|
131
|
-
if (!participant) {
|
|
132
|
-
throw new Boom('Cannot derive chat id: broadcast message key is missing participant', {
|
|
133
|
-
data: { remoteJid, fromMe }
|
|
134
|
-
});
|
|
135
|
-
}
|
|
73
|
+
const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
74
|
+
if ((0, WABinary_1.isJidBroadcast)(remoteJid)
|
|
75
|
+
&& !(0, WABinary_1.isJidStatusBroadcast)(remoteJid)
|
|
76
|
+
&& !fromMe) {
|
|
136
77
|
return participant;
|
|
137
78
|
}
|
|
138
79
|
return remoteJid;
|
|
139
80
|
};
|
|
81
|
+
exports.getChatId = getChatId;
|
|
140
82
|
/**
|
|
141
83
|
* Decrypt a poll vote
|
|
142
84
|
* @param vote encrypted vote
|
|
143
85
|
* @param ctx additional info about the poll required for decryption
|
|
144
86
|
* @returns list of SHA256 options
|
|
145
87
|
*/
|
|
146
|
-
|
|
88
|
+
function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }) {
|
|
147
89
|
const sign = Buffer.concat([
|
|
148
90
|
toBinary(pollMsgId),
|
|
149
91
|
toBinary(pollCreatorJid),
|
|
@@ -151,107 +93,52 @@ export function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsg
|
|
|
151
93
|
toBinary('Poll Vote'),
|
|
152
94
|
new Uint8Array([1])
|
|
153
95
|
]);
|
|
154
|
-
const key0 = hmacSign(pollEncKey, new Uint8Array(32), 'sha256');
|
|
155
|
-
const decKey = hmacSign(sign, key0, 'sha256');
|
|
96
|
+
const key0 = (0, crypto_1.hmacSign)(pollEncKey, new Uint8Array(32), 'sha256');
|
|
97
|
+
const decKey = (0, crypto_1.hmacSign)(sign, key0, 'sha256');
|
|
156
98
|
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`);
|
|
157
|
-
const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad);
|
|
158
|
-
return proto.Message.PollVoteMessage.decode(decrypted);
|
|
99
|
+
const decrypted = (0, crypto_1.aesDecryptGCM)(encPayload, decKey, encIv, aad);
|
|
100
|
+
return WAProto_1.proto.Message.PollVoteMessage.decode(decrypted);
|
|
159
101
|
function toBinary(txt) {
|
|
160
102
|
return Buffer.from(txt);
|
|
161
103
|
}
|
|
162
104
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
* @param response encrypted event response
|
|
166
|
-
* @param ctx additional info about the event required for decryption
|
|
167
|
-
* @returns event response message
|
|
168
|
-
*/
|
|
169
|
-
export function decryptEventResponse({ encPayload, encIv }, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }) {
|
|
170
|
-
const sign = Buffer.concat([
|
|
171
|
-
toBinary(eventMsgId),
|
|
172
|
-
toBinary(eventCreatorJid),
|
|
173
|
-
toBinary(responderJid),
|
|
174
|
-
toBinary('Event Response'),
|
|
175
|
-
new Uint8Array([1])
|
|
176
|
-
]);
|
|
177
|
-
const key0 = hmacSign(eventEncKey, new Uint8Array(32), 'sha256');
|
|
178
|
-
const decKey = hmacSign(sign, key0, 'sha256');
|
|
179
|
-
const aad = toBinary(`${eventMsgId}\u0000${responderJid}`);
|
|
180
|
-
const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad);
|
|
181
|
-
return proto.Message.EventResponseMessage.decode(decrypted);
|
|
182
|
-
function toBinary(txt) {
|
|
183
|
-
return Buffer.from(txt);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }) => {
|
|
105
|
+
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options }) => {
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
187
107
|
const meId = creds.me.id;
|
|
188
108
|
const { accountSettings } = creds;
|
|
189
|
-
const chat = { id: jidNormalizedUser(getChatId(message.key)) };
|
|
190
|
-
const isRealMsg = isRealMessage(message);
|
|
109
|
+
const chat = { id: (0, WABinary_1.jidNormalizedUser)((0, exports.getChatId)(message.key)) };
|
|
110
|
+
const isRealMsg = (0, exports.isRealMessage)(message, meId);
|
|
191
111
|
if (isRealMsg) {
|
|
192
112
|
chat.messages = [{ message }];
|
|
193
|
-
chat.conversationTimestamp = toNumber(message.messageTimestamp);
|
|
113
|
+
chat.conversationTimestamp = (0, generics_1.toNumber)(message.messageTimestamp);
|
|
194
114
|
// only increment unread count if not CIPHERTEXT and from another person
|
|
195
|
-
if (shouldIncrementChatUnread(message)) {
|
|
115
|
+
if ((0, exports.shouldIncrementChatUnread)(message)) {
|
|
196
116
|
chat.unreadCount = (chat.unreadCount || 0) + 1;
|
|
197
117
|
}
|
|
198
118
|
}
|
|
199
|
-
const content = normalizeMessageContent(message.message);
|
|
119
|
+
const content = (0, messages_1.normalizeMessageContent)(message.message);
|
|
200
120
|
// unarchive chat if it's a real message, or someone reacted to our message
|
|
201
121
|
// and we've the unarchive chats setting on
|
|
202
|
-
if ((isRealMsg || content
|
|
122
|
+
if ((isRealMsg || ((_b = (_a = content === null || content === void 0 ? void 0 : content.reactionMessage) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.fromMe))
|
|
123
|
+
&& (accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.unarchiveChats)) {
|
|
203
124
|
chat.archived = false;
|
|
204
125
|
chat.readOnly = false;
|
|
205
126
|
}
|
|
206
|
-
const protocolMsg = content
|
|
127
|
+
const protocolMsg = content === null || content === void 0 ? void 0 : content.protocolMessage;
|
|
207
128
|
if (protocolMsg) {
|
|
208
|
-
// Mirror whatsmeow's `handleProtocolMessage` guard, but applied only to
|
|
209
|
-
// the protocol message types that originate from our own device — an
|
|
210
|
-
// attacker could otherwise spoof any of these to manipulate local state.
|
|
211
|
-
//
|
|
212
|
-
// Self-only types (drop if `!fromMe`):
|
|
213
|
-
// - HISTORY_SYNC_NOTIFICATION (our phone driving history sync)
|
|
214
|
-
// - APP_STATE_SYNC_KEY_SHARE (key share between our devices)
|
|
215
|
-
// - LID_MIGRATION_MAPPING_SYNC (server-initiated via our phone)
|
|
216
|
-
// - PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE (response from our phone to our PDO request)
|
|
217
|
-
//
|
|
218
|
-
// Cross-user types (must NOT be dropped — legitimately arrive from others):
|
|
219
|
-
// - REVOKE
|
|
220
|
-
// - MESSAGE_EDIT
|
|
221
|
-
// - EPHEMERAL_SETTING
|
|
222
|
-
// - GROUP_MEMBER_LABEL_CHANGE
|
|
223
|
-
//
|
|
224
|
-
// See https://github.com/tulir/whatsmeow/blob/8d3700152a/message.go#L842-L845
|
|
225
|
-
// for the reference architecture — whatsmeow's `handleProtocolMessage`
|
|
226
|
-
// only contains self-only types because edits are unwrapped from
|
|
227
|
-
// `EditedMessage` BEFORE this dispatch and revokes aren't routed here.
|
|
228
|
-
const SELF_ONLY_TYPES = new Set([
|
|
229
|
-
proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION,
|
|
230
|
-
proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE,
|
|
231
|
-
proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC,
|
|
232
|
-
proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE
|
|
233
|
-
]);
|
|
234
|
-
if (protocolMsg.type !== null &&
|
|
235
|
-
protocolMsg.type !== undefined &&
|
|
236
|
-
SELF_ONLY_TYPES.has(protocolMsg.type) &&
|
|
237
|
-
!message.key.fromMe) {
|
|
238
|
-
logger?.warn({ msgId: message.key.id, type: protocolMsg.type, from: message.key.participant || message.key.remoteJid }, 'dropping spoofed self-only protocolMessage from non-self origin');
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
129
|
switch (protocolMsg.type) {
|
|
242
|
-
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
130
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
243
131
|
const histNotification = protocolMsg.historySyncNotification;
|
|
244
132
|
const process = shouldProcessHistoryMsg;
|
|
245
|
-
const isLatest = !creds.processedHistoryMessages
|
|
246
|
-
logger
|
|
133
|
+
const isLatest = !((_c = creds.processedHistoryMessages) === null || _c === void 0 ? void 0 : _c.length);
|
|
134
|
+
logger === null || logger === void 0 ? void 0 : logger.info({
|
|
247
135
|
histNotification,
|
|
248
136
|
process,
|
|
249
137
|
id: message.key.id,
|
|
250
|
-
isLatest
|
|
138
|
+
isLatest,
|
|
251
139
|
}, 'got history notification');
|
|
252
140
|
if (process) {
|
|
253
|
-
|
|
254
|
-
if (histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
141
|
+
if (histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
255
142
|
ev.emit('creds.update', {
|
|
256
143
|
processedHistoryMessages: [
|
|
257
144
|
...(creds.processedHistoryMessages || []),
|
|
@@ -259,25 +146,19 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
259
146
|
]
|
|
260
147
|
});
|
|
261
148
|
}
|
|
262
|
-
const data = await downloadAndProcessHistorySyncNotification(histNotification, options
|
|
263
|
-
if (data.lidPnMappings?.length) {
|
|
264
|
-
logger?.debug({ count: data.lidPnMappings.length }, 'processing LID-PN mappings from history sync');
|
|
265
|
-
await signalRepository.lidMapping
|
|
266
|
-
.storeLIDPNMappings(data.lidPnMappings)
|
|
267
|
-
.catch(err => logger?.warn({ err }, 'failed to store LID-PN mappings from history sync'));
|
|
268
|
-
}
|
|
269
|
-
await storeTcTokensFromHistorySync(data.chats, signalRepository, keyStore, logger);
|
|
149
|
+
const data = await (0, history_1.downloadAndProcessHistorySyncNotification)(histNotification, options);
|
|
270
150
|
ev.emit('messaging-history.set', {
|
|
271
151
|
...data,
|
|
272
|
-
isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
273
|
-
|
|
152
|
+
isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
153
|
+
? isLatest
|
|
154
|
+
: undefined,
|
|
274
155
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
275
156
|
});
|
|
276
157
|
}
|
|
277
158
|
break;
|
|
278
|
-
case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
159
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
279
160
|
const keys = protocolMsg.appStateSyncKeyShare.keys;
|
|
280
|
-
if (keys
|
|
161
|
+
if (keys === null || keys === void 0 ? void 0 : keys.length) {
|
|
281
162
|
let newAppStateSyncKeyId = '';
|
|
282
163
|
await keyStore.transaction(async () => {
|
|
283
164
|
const newKeys = [];
|
|
@@ -287,85 +168,58 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
287
168
|
await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } });
|
|
288
169
|
newAppStateSyncKeyId = strKeyId;
|
|
289
170
|
}
|
|
290
|
-
logger
|
|
291
|
-
}
|
|
171
|
+
logger === null || logger === void 0 ? void 0 : logger.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys');
|
|
172
|
+
});
|
|
292
173
|
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId });
|
|
293
174
|
}
|
|
294
175
|
else {
|
|
295
|
-
logger
|
|
176
|
+
logger === null || logger === void 0 ? void 0 : logger.info({ protocolMsg }, 'recv app state sync with 0 keys');
|
|
296
177
|
}
|
|
297
178
|
break;
|
|
298
|
-
case proto.Message.ProtocolMessage.Type.REVOKE:
|
|
179
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE:
|
|
299
180
|
ev.emit('messages.update', [
|
|
300
181
|
{
|
|
301
182
|
key: {
|
|
302
183
|
...message.key,
|
|
303
184
|
id: protocolMsg.key.id
|
|
304
185
|
},
|
|
305
|
-
update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
|
|
186
|
+
update: { message: null, messageStubType: Types_1.WAMessageStubType.REVOKE, key: message.key }
|
|
306
187
|
}
|
|
307
188
|
]);
|
|
308
189
|
break;
|
|
309
|
-
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
190
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
310
191
|
Object.assign(chat, {
|
|
311
|
-
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
|
|
192
|
+
ephemeralSettingTimestamp: (0, generics_1.toNumber)(message.messageTimestamp),
|
|
312
193
|
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
|
313
194
|
});
|
|
314
195
|
break;
|
|
315
|
-
case proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
196
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
316
197
|
const response = protocolMsg.peerDataOperationRequestResponseMessage;
|
|
317
198
|
if (response) {
|
|
199
|
+
placeholderResendCache === null || placeholderResendCache === void 0 ? void 0 : placeholderResendCache.del(response.stanzaId);
|
|
318
200
|
// TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
|
|
319
|
-
const peerDataOperationResult = response
|
|
201
|
+
const { peerDataOperationResult } = response;
|
|
320
202
|
for (const result of peerDataOperationResult) {
|
|
321
|
-
const retryResponse = result
|
|
203
|
+
const { placeholderMessageResendResponse: retryResponse } = result;
|
|
322
204
|
//eslint-disable-next-line max-depth
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
//eslint-disable-next-line max-depth
|
|
334
|
-
if (msgId) {
|
|
335
|
-
await placeholderResendCache?.del(msgId);
|
|
336
|
-
}
|
|
337
|
-
let finalMsg;
|
|
338
|
-
//eslint-disable-next-line max-depth
|
|
339
|
-
if (cachedData && typeof cachedData === 'object') {
|
|
340
|
-
// Apply decoded message content onto cached metadata (preserves LID etc.)
|
|
341
|
-
cachedData.message = webMessageInfo.message;
|
|
342
|
-
//eslint-disable-next-line max-depth
|
|
343
|
-
if (webMessageInfo.messageTimestamp) {
|
|
344
|
-
cachedData.messageTimestamp = webMessageInfo.messageTimestamp;
|
|
345
|
-
}
|
|
346
|
-
finalMsg = cachedData;
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
finalMsg = webMessageInfo;
|
|
350
|
-
}
|
|
351
|
-
logger?.debug({ msgId, requestId: response.stanzaId }, 'received placeholder resend');
|
|
352
|
-
ev.emit('messages.upsert', {
|
|
353
|
-
messages: [finalMsg],
|
|
354
|
-
type: 'notify',
|
|
355
|
-
requestId: response.stanzaId
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
catch (err) {
|
|
359
|
-
logger?.warn({ err, stanzaId: response.stanzaId }, 'failed to decode placeholder resend response');
|
|
205
|
+
if (retryResponse) {
|
|
206
|
+
const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
|
|
207
|
+
// wait till another upsert event is available, don't want it to be part of the PDO response message
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
ev.emit('messages.upsert', {
|
|
210
|
+
messages: [webMessageInfo],
|
|
211
|
+
type: 'notify',
|
|
212
|
+
requestId: response.stanzaId
|
|
213
|
+
});
|
|
214
|
+
}, 500);
|
|
360
215
|
}
|
|
361
216
|
}
|
|
362
217
|
}
|
|
363
|
-
|
|
364
|
-
case proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
218
|
+
case WAProto_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
365
219
|
ev.emit('messages.update', [
|
|
366
220
|
{
|
|
367
221
|
// flip the sender / fromMe properties because they're in the perspective of the sender
|
|
368
|
-
key: { ...message.key, id: protocolMsg.key
|
|
222
|
+
key: { ...message.key, id: (_d = protocolMsg.key) === null || _d === void 0 ? void 0 : _d.id },
|
|
369
223
|
update: {
|
|
370
224
|
message: {
|
|
371
225
|
editedMessage: {
|
|
@@ -373,228 +227,122 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
373
227
|
}
|
|
374
228
|
},
|
|
375
229
|
messageTimestamp: protocolMsg.timestampMs
|
|
376
|
-
? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
|
|
230
|
+
? Math.floor((0, generics_1.toNumber)(protocolMsg.timestampMs) / 1000)
|
|
377
231
|
: message.messageTimestamp
|
|
378
232
|
}
|
|
379
233
|
}
|
|
380
234
|
]);
|
|
381
235
|
break;
|
|
382
|
-
case proto.Message.ProtocolMessage.Type.GROUP_MEMBER_LABEL_CHANGE:
|
|
383
|
-
const labelAssociationMsg = protocolMsg.memberLabel;
|
|
384
|
-
if (labelAssociationMsg?.label) {
|
|
385
|
-
ev.emit('group.member-tag.update', {
|
|
386
|
-
groupId: chat.id,
|
|
387
|
-
label: labelAssociationMsg.label,
|
|
388
|
-
participant: message.key.participant,
|
|
389
|
-
participantAlt: message.key.participantAlt,
|
|
390
|
-
messageTimestamp: Number(message.messageTimestamp)
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
break;
|
|
394
|
-
case proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
|
|
395
|
-
const encodedPayload = protocolMsg.lidMigrationMappingSyncMessage?.encodedMappingPayload;
|
|
396
|
-
const { pnToLidMappings, chatDbMigrationTimestamp } = proto.LIDMigrationMappingSyncPayload.decode(encodedPayload);
|
|
397
|
-
logger?.debug({ pnToLidMappings, chatDbMigrationTimestamp }, 'got lid mappings and chat db migration timestamp');
|
|
398
|
-
const pairs = [];
|
|
399
|
-
for (const { pn, latestLid, assignedLid } of pnToLidMappings) {
|
|
400
|
-
const lid = latestLid || assignedLid;
|
|
401
|
-
pairs.push({ lid: `${lid}@lid`, pn: `${pn}@s.whatsapp.net` });
|
|
402
|
-
}
|
|
403
|
-
await signalRepository.lidMapping.storeLIDPNMappings(pairs);
|
|
404
|
-
if (pairs.length) {
|
|
405
|
-
for (const { pn, lid } of pairs) {
|
|
406
|
-
await signalRepository.migrateSession(pn, lid);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
236
|
}
|
|
410
237
|
}
|
|
411
|
-
else if (content
|
|
238
|
+
else if (content === null || content === void 0 ? void 0 : content.reactionMessage) {
|
|
412
239
|
const reaction = {
|
|
413
240
|
...content.reactionMessage,
|
|
414
|
-
key: message.key
|
|
241
|
+
key: message.key,
|
|
415
242
|
};
|
|
416
|
-
ev.emit('messages.reaction', [
|
|
417
|
-
{
|
|
243
|
+
ev.emit('messages.reaction', [{
|
|
418
244
|
reaction,
|
|
419
|
-
key: content.reactionMessage
|
|
420
|
-
}
|
|
421
|
-
]);
|
|
422
|
-
}
|
|
423
|
-
else if (content?.encEventResponseMessage) {
|
|
424
|
-
const encEventResponse = content.encEventResponseMessage;
|
|
425
|
-
const creationMsgKey = encEventResponse.eventCreationMessageKey;
|
|
426
|
-
// we need to fetch the event creation message to get the event enc key
|
|
427
|
-
const eventMsg = await getMessage(creationMsgKey);
|
|
428
|
-
if (eventMsg) {
|
|
429
|
-
try {
|
|
430
|
-
const meIdNormalised = jidNormalizedUser(meId);
|
|
431
|
-
// all jids need to be PN
|
|
432
|
-
const eventCreatorKey = creationMsgKey.participant || creationMsgKey.remoteJid;
|
|
433
|
-
const eventCreatorPn = isLidUser(eventCreatorKey)
|
|
434
|
-
? await signalRepository.lidMapping.getPNForLID(eventCreatorKey)
|
|
435
|
-
: eventCreatorKey;
|
|
436
|
-
const eventCreatorJid = getKeyAuthor({ remoteJid: jidNormalizedUser(eventCreatorPn), fromMe: meIdNormalised === eventCreatorPn }, meIdNormalised);
|
|
437
|
-
const responderJid = getKeyAuthor(message.key, meIdNormalised);
|
|
438
|
-
const eventEncKey = eventMsg?.messageContextInfo?.messageSecret;
|
|
439
|
-
if (!eventEncKey) {
|
|
440
|
-
logger?.warn({ creationMsgKey }, 'event response: missing messageSecret for decryption');
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
const responseMsg = decryptEventResponse(encEventResponse, {
|
|
444
|
-
eventEncKey,
|
|
445
|
-
eventCreatorJid,
|
|
446
|
-
eventMsgId: creationMsgKey.id,
|
|
447
|
-
responderJid
|
|
448
|
-
});
|
|
449
|
-
const eventResponse = {
|
|
450
|
-
eventResponseMessageKey: message.key,
|
|
451
|
-
senderTimestampMs: responseMsg.timestampMs,
|
|
452
|
-
response: responseMsg
|
|
453
|
-
};
|
|
454
|
-
ev.emit('messages.update', [
|
|
455
|
-
{
|
|
456
|
-
key: creationMsgKey,
|
|
457
|
-
update: {
|
|
458
|
-
eventResponses: [eventResponse]
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
]);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
catch (err) {
|
|
465
|
-
logger?.warn({ err, creationMsgKey }, 'failed to decrypt event response');
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
logger?.warn({ creationMsgKey }, 'event creation message not found, cannot decrypt response');
|
|
470
|
-
}
|
|
245
|
+
key: (_e = content.reactionMessage) === null || _e === void 0 ? void 0 : _e.key,
|
|
246
|
+
}]);
|
|
471
247
|
}
|
|
472
248
|
else if (message.messageStubType) {
|
|
473
|
-
const jid = message.key
|
|
249
|
+
const jid = (_f = message.key) === null || _f === void 0 ? void 0 : _f.remoteJid;
|
|
474
250
|
//let actor = whatsappID (message.participant)
|
|
475
251
|
let participants;
|
|
476
|
-
const emitParticipantsUpdate = (action) => ev.emit('group-participants.update', {
|
|
477
|
-
id: jid,
|
|
478
|
-
author: message.key.participant,
|
|
479
|
-
authorPn: message.key.participantAlt,
|
|
480
|
-
authorUsername: message.key.participantUsername,
|
|
481
|
-
participants,
|
|
482
|
-
action
|
|
483
|
-
});
|
|
252
|
+
const emitParticipantsUpdate = (action) => (ev.emit('group-participants.update', { id: jid, author: message.participant, participants, action }));
|
|
484
253
|
const emitGroupUpdate = (update) => {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
id: jid,
|
|
488
|
-
...update,
|
|
489
|
-
author: message.key.participant ?? undefined,
|
|
490
|
-
authorPn: message.key.participantAlt,
|
|
491
|
-
authorUsername: message.key.participantUsername
|
|
492
|
-
}
|
|
493
|
-
]);
|
|
254
|
+
var _a;
|
|
255
|
+
ev.emit('groups.update', [{ id: jid, ...update, author: (_a = message.participant) !== null && _a !== void 0 ? _a : undefined }]);
|
|
494
256
|
};
|
|
495
257
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
496
|
-
ev.emit('group.join-request', {
|
|
497
|
-
id: jid,
|
|
498
|
-
author: message.key.participant,
|
|
499
|
-
authorPn: message.key.participantAlt,
|
|
500
|
-
authorUsername: message.key.participantUsername,
|
|
501
|
-
participant: participant.lid,
|
|
502
|
-
participantPn: participant.pn,
|
|
503
|
-
action,
|
|
504
|
-
method: method
|
|
505
|
-
});
|
|
258
|
+
ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method });
|
|
506
259
|
};
|
|
507
|
-
const participantsIncludesMe = () => participants.find(jid => areJidsSameUser(meId, jid
|
|
260
|
+
const participantsIncludesMe = () => participants.find(jid => (0, WABinary_1.areJidsSameUser)(meId, jid));
|
|
508
261
|
switch (message.messageStubType) {
|
|
509
|
-
case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
510
|
-
participants = message.messageStubParameters
|
|
262
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
263
|
+
participants = message.messageStubParameters || [];
|
|
511
264
|
emitParticipantsUpdate('modify');
|
|
512
265
|
break;
|
|
513
|
-
case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
514
|
-
case WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
515
|
-
participants = message.messageStubParameters
|
|
266
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
267
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
268
|
+
participants = message.messageStubParameters || [];
|
|
516
269
|
emitParticipantsUpdate('remove');
|
|
517
270
|
// mark the chat read only if you left the group
|
|
518
271
|
if (participantsIncludesMe()) {
|
|
519
272
|
chat.readOnly = true;
|
|
520
273
|
}
|
|
521
274
|
break;
|
|
522
|
-
case WAMessageStubType.GROUP_PARTICIPANT_ADD:
|
|
523
|
-
case WAMessageStubType.GROUP_PARTICIPANT_INVITE:
|
|
524
|
-
case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
|
|
525
|
-
participants = message.messageStubParameters
|
|
275
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD:
|
|
276
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_INVITE:
|
|
277
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
|
|
278
|
+
participants = message.messageStubParameters || [];
|
|
526
279
|
if (participantsIncludesMe()) {
|
|
527
280
|
chat.readOnly = false;
|
|
528
281
|
}
|
|
529
282
|
emitParticipantsUpdate('add');
|
|
530
283
|
break;
|
|
531
|
-
case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
532
|
-
participants = message.messageStubParameters
|
|
284
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
285
|
+
participants = message.messageStubParameters || [];
|
|
533
286
|
emitParticipantsUpdate('demote');
|
|
534
287
|
break;
|
|
535
|
-
case WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
|
|
536
|
-
participants = message.messageStubParameters
|
|
288
|
+
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
|
|
289
|
+
participants = message.messageStubParameters || [];
|
|
537
290
|
emitParticipantsUpdate('promote');
|
|
538
291
|
break;
|
|
539
|
-
case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
540
|
-
const announceValue = message.messageStubParameters
|
|
292
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
293
|
+
const announceValue = (_g = message.messageStubParameters) === null || _g === void 0 ? void 0 : _g[0];
|
|
541
294
|
emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' });
|
|
542
295
|
break;
|
|
543
|
-
case WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
|
544
|
-
const restrictValue = message.messageStubParameters
|
|
296
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
|
297
|
+
const restrictValue = (_h = message.messageStubParameters) === null || _h === void 0 ? void 0 : _h[0];
|
|
545
298
|
emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' });
|
|
546
299
|
break;
|
|
547
|
-
case WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
|
548
|
-
const name = message.messageStubParameters
|
|
300
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
|
301
|
+
const name = (_j = message.messageStubParameters) === null || _j === void 0 ? void 0 : _j[0];
|
|
549
302
|
chat.name = name;
|
|
550
303
|
emitGroupUpdate({ subject: name });
|
|
551
304
|
break;
|
|
552
|
-
case WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
|
|
553
|
-
const description = message.messageStubParameters
|
|
305
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
|
|
306
|
+
const description = (_k = message.messageStubParameters) === null || _k === void 0 ? void 0 : _k[0];
|
|
554
307
|
chat.description = description;
|
|
555
308
|
emitGroupUpdate({ desc: description });
|
|
556
309
|
break;
|
|
557
|
-
case WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
|
|
558
|
-
const code = message.messageStubParameters
|
|
310
|
+
case Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
|
|
311
|
+
const code = (_l = message.messageStubParameters) === null || _l === void 0 ? void 0 : _l[0];
|
|
559
312
|
emitGroupUpdate({ inviteCode: code });
|
|
560
313
|
break;
|
|
561
|
-
case WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
562
|
-
const memberAddValue = message.messageStubParameters
|
|
314
|
+
case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
315
|
+
const memberAddValue = (_m = message.messageStubParameters) === null || _m === void 0 ? void 0 : _m[0];
|
|
563
316
|
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
|
|
564
317
|
break;
|
|
565
|
-
case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
566
|
-
const approvalMode = message.messageStubParameters
|
|
318
|
+
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
319
|
+
const approvalMode = (_o = message.messageStubParameters) === null || _o === void 0 ? void 0 : _o[0];
|
|
567
320
|
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
|
|
568
321
|
break;
|
|
569
|
-
case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
|
|
570
|
-
const participant =
|
|
571
|
-
const action = message.messageStubParameters
|
|
572
|
-
const method = message.messageStubParameters
|
|
322
|
+
case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
|
|
323
|
+
const participant = (_p = message.messageStubParameters) === null || _p === void 0 ? void 0 : _p[0];
|
|
324
|
+
const action = (_q = message.messageStubParameters) === null || _q === void 0 ? void 0 : _q[1];
|
|
325
|
+
const method = (_r = message.messageStubParameters) === null || _r === void 0 ? void 0 : _r[2];
|
|
573
326
|
emitGroupRequestJoin(participant, action, method);
|
|
574
327
|
break;
|
|
575
328
|
}
|
|
576
|
-
}
|
|
577
|
-
|
|
329
|
+
}
|
|
330
|
+
else if (content === null || content === void 0 ? void 0 : content.pollUpdateMessage) {
|
|
331
|
+
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey;
|
|
578
332
|
// we need to fetch the poll creation message to get the poll enc key
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
const voterJid = getKeyAuthor(message.key, meIdNormalised)
|
|
586
|
-
const pollEncKey = pollMsg.messageContextInfo?.messageSecret!
|
|
587
|
-
|
|
333
|
+
const pollMsg = await getMessage(creationMsgKey);
|
|
334
|
+
if (pollMsg) {
|
|
335
|
+
const meIdNormalised = (0, WABinary_1.jidNormalizedUser)(meId);
|
|
336
|
+
const pollCreatorJid = (0, generics_1.getKeyAuthor)(creationMsgKey, meIdNormalised);
|
|
337
|
+
const voterJid = (0, generics_1.getKeyAuthor)(message.key, meIdNormalised);
|
|
338
|
+
const pollEncKey = (_s = pollMsg.messageContextInfo) === null || _s === void 0 ? void 0 : _s.messageSecret;
|
|
588
339
|
try {
|
|
589
|
-
const voteMsg = decryptPollVote(
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
voterJid,
|
|
596
|
-
}
|
|
597
|
-
)
|
|
340
|
+
const voteMsg = decryptPollVote(content.pollUpdateMessage.vote, {
|
|
341
|
+
pollEncKey,
|
|
342
|
+
pollCreatorJid,
|
|
343
|
+
pollMsgId: creationMsgKey.id,
|
|
344
|
+
voterJid,
|
|
345
|
+
});
|
|
598
346
|
ev.emit('messages.update', [
|
|
599
347
|
{
|
|
600
348
|
key: creationMsgKey,
|
|
@@ -603,28 +351,23 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
603
351
|
{
|
|
604
352
|
pollUpdateMessageKey: message.key,
|
|
605
353
|
vote: voteMsg,
|
|
606
|
-
senderTimestampMs:
|
|
354
|
+
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
|
|
607
355
|
}
|
|
608
356
|
]
|
|
609
357
|
}
|
|
610
358
|
}
|
|
611
|
-
])
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
'failed to decrypt poll vote'
|
|
616
|
-
)
|
|
359
|
+
]);
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
logger === null || logger === void 0 ? void 0 : logger.warn({ err, creationMsgKey }, 'failed to decrypt poll vote');
|
|
617
363
|
}
|
|
618
|
-
} else {
|
|
619
|
-
logger?.warn(
|
|
620
|
-
{ creationMsgKey },
|
|
621
|
-
'poll creation message not found, cannot decrypt update'
|
|
622
|
-
)
|
|
623
364
|
}
|
|
624
|
-
|
|
365
|
+
else {
|
|
366
|
+
logger === null || logger === void 0 ? void 0 : logger.warn({ creationMsgKey }, 'poll creation message not found, cannot decrypt update');
|
|
367
|
+
}
|
|
368
|
+
}
|
|
625
369
|
if (Object.keys(chat).length > 1) {
|
|
626
370
|
ev.emit('chats.update', [chat]);
|
|
627
371
|
}
|
|
628
372
|
};
|
|
629
|
-
|
|
630
|
-
//# sourceMappingURL=process-message.js.map
|
|
373
|
+
exports.default = processMessage;
|