phantom-baileys 0.0.9 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +592 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +5479 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +5147 -41513
- package/WAProto/index.js +84008 -142014
- package/lib/Defaults/index.d.ts +29 -8
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +80 -60
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +82 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +3 -16
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -3
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +331 -80
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +19 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +271 -0
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -3
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -19
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +4 -5
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +3 -2
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +54 -0
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +184 -101
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +162 -43
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +72 -42
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +340 -299
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +309 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/dugong.d.ts +79 -0
- package/lib/Socket/dugong.d.ts.map +1 -0
- package/lib/Socket/dugong.js +527 -0
- package/lib/Socket/dugong.js.map +1 -0
- package/lib/Socket/groups.d.ts +93 -58
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +96 -84
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +232 -107
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +13 -10
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +170 -90
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +798 -462
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +180 -99
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +833 -709
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +42 -0
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +120 -75
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +227 -198
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +31 -20
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +508 -215
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +18 -11
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +2 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +24 -8
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -4
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +6 -1
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +82 -17
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -2
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +15 -3
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +1 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +3 -5
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +1 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +3 -5
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +77 -202
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -9
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +128 -85
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +25 -26
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +2 -1
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +20 -1
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +41 -24
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +14 -2
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +13 -2
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +3 -2
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -2
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +15 -16
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +15 -31
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/auth-utils.d.ts +7 -6
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +228 -165
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +4 -3
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +66 -69
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +16 -16
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +299 -232
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +18 -21
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +44 -125
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +20 -8
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +139 -90
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +7 -8
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +129 -72
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +25 -22
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +157 -175
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +14 -11
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +83 -46
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +37 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +22 -17
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +22 -33
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +5 -5
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +14 -22
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +12 -1
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -7
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +8 -12
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +3 -46
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +2 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +24 -34
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +110 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +225 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +59 -42
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +411 -356
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +32 -18
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +412 -723
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +13 -13
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +149 -108
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +30 -11
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +321 -166
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/rich-messages.d.ts +129 -0
- package/lib/Utils/rich-messages.d.ts.map +1 -0
- package/lib/Utils/rich-messages.js +455 -0
- package/lib/Utils/rich-messages.js.map +1 -0
- package/lib/Utils/signal.d.ts +7 -6
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +65 -65
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +12 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +18 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +79 -253
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +6 -6
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +111 -116
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +5 -4
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1281 -20
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +51 -53
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +12 -44
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +9 -6
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +124 -43
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -5
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +6 -21
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +24 -7
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +74 -40
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +2 -1
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -2
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +2 -1
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +2 -5
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +5 -3
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +19071 -11568
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -2
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +17 -22
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -3
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -19
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAProto/fix-imports.d.ts +1 -0
- package/lib/WAProto/fix-imports.js +71 -0
- package/lib/WAProto/index.js +89345 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -11
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +3 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -14
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +3 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -12
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +3 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -22
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +5 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -8
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -4
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +5 -20
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +5 -4
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +40 -35
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +7 -4
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +2 -5
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -3
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -19
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -31
- package/lib/index.js.map +1 -0
- package/package.json +35 -75
- package/Readme.md +0 -1
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/index.js +0 -10
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-in-memory-store.js +0 -431
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/make-ordered-dictionary.js +0 -81
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Store/object-repository.js +0 -27
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/baileys-event-stream.js +0 -63
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const WABinary_1 = require("../WABinary");
|
|
9
|
-
const crypto_1 = require("./crypto");
|
|
10
|
-
const generics_1 = require("./generics");
|
|
11
|
-
const history_1 = require("./history");
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { WAMessageStubType } from '../Types/index.js';
|
|
3
|
+
import { getContentType, normalizeMessageContent } from '../Utils/messages.js';
|
|
4
|
+
import { areJidsSameUser, isHostedLidUser, isHostedPnUser, isJidBroadcast, isJidStatusBroadcast, isLidUser, jidDecode, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
|
|
5
|
+
import { aesDecryptGCM, hmacSign } from './crypto.js';
|
|
6
|
+
import { getKeyAuthor, toNumber } from './generics.js';
|
|
7
|
+
import { downloadAndProcessHistorySyncNotification } from './history.js';
|
|
12
8
|
const REAL_MSG_STUB_TYPES = new Set([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
18
|
-
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([
|
|
19
|
-
Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD
|
|
9
|
+
WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
10
|
+
WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
11
|
+
WAMessageStubType.CALL_MISSED_VIDEO,
|
|
12
|
+
WAMessageStubType.CALL_MISSED_VOICE
|
|
20
13
|
]);
|
|
14
|
+
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([WAMessageStubType.GROUP_PARTICIPANT_ADD]);
|
|
21
15
|
/** Cleans a received message to further processing */
|
|
22
|
-
const cleanMessage = (message, meId) => {
|
|
16
|
+
export const cleanMessage = (message, meId, meLid) => {
|
|
23
17
|
// ensure remoteJid and participant doesn't have device or agent in it
|
|
24
|
-
message.key.remoteJid
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
if (isHostedPnUser(message.key.remoteJid) || isHostedLidUser(message.key.remoteJid)) {
|
|
19
|
+
message.key.remoteJid = jidEncode(jidDecode(message.key?.remoteJid)?.user, isHostedPnUser(message.key.remoteJid) ? 's.whatsapp.net' : 'lid');
|
|
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
31
|
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
|
28
|
-
if (content
|
|
32
|
+
if (content?.reactionMessage) {
|
|
29
33
|
normaliseKey(content.reactionMessage.key);
|
|
30
34
|
}
|
|
31
|
-
if (content
|
|
35
|
+
if (content?.pollUpdateMessage) {
|
|
32
36
|
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey);
|
|
33
37
|
}
|
|
34
38
|
function normaliseKey(msgKey) {
|
|
@@ -38,54 +42,49 @@ const cleanMessage = (message, meId) => {
|
|
|
38
42
|
// if the sender believed the message being reacted to is not from them
|
|
39
43
|
// we've to correct the key to be from them, or some other participant
|
|
40
44
|
msgKey.fromMe = !msgKey.fromMe
|
|
41
|
-
?
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
+
? areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId) ||
|
|
46
|
+
areJidsSameUser(msgKey.participant || msgKey.remoteJid, meLid)
|
|
47
|
+
: // if the message being reacted to, was from them
|
|
48
|
+
// fromMe automatically becomes false
|
|
49
|
+
false;
|
|
45
50
|
// set the remoteJid to being the same as the chat the message came from
|
|
51
|
+
// TODO: investigate inconsistencies
|
|
46
52
|
msgKey.remoteJid = message.key.remoteJid;
|
|
47
53
|
// set participant of the message
|
|
48
54
|
msgKey.participant = msgKey.participant || message.key.participant;
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
};
|
|
52
|
-
|
|
53
|
-
const isRealMessage = (message
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
&&
|
|
62
|
-
|
|
63
|
-
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.reactionMessage)
|
|
64
|
-
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.pollUpdateMessage);
|
|
58
|
+
// TODO: target:audit AUDIT THIS FUNCTION AGAIN
|
|
59
|
+
export const isRealMessage = (message) => {
|
|
60
|
+
const normalizedContent = normalizeMessageContent(message.message);
|
|
61
|
+
const hasSomeContent = !!getContentType(normalizedContent);
|
|
62
|
+
return ((!!normalizedContent ||
|
|
63
|
+
REAL_MSG_STUB_TYPES.has(message.messageStubType) ||
|
|
64
|
+
REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType)) &&
|
|
65
|
+
hasSomeContent &&
|
|
66
|
+
!normalizedContent?.protocolMessage &&
|
|
67
|
+
!normalizedContent?.reactionMessage &&
|
|
68
|
+
!normalizedContent?.pollUpdateMessage);
|
|
65
69
|
};
|
|
66
|
-
|
|
67
|
-
const shouldIncrementChatUnread = (message) => (!message.key.fromMe && !message.messageStubType);
|
|
68
|
-
exports.shouldIncrementChatUnread = shouldIncrementChatUnread;
|
|
70
|
+
export const shouldIncrementChatUnread = (message) => !message.key.fromMe && !message.messageStubType;
|
|
69
71
|
/**
|
|
70
72
|
* Get the ID of the chat from the given key.
|
|
71
73
|
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
72
74
|
*/
|
|
73
|
-
const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
74
|
-
if ((
|
|
75
|
-
&& !(0, WABinary_1.isJidStatusBroadcast)(remoteJid)
|
|
76
|
-
&& !fromMe) {
|
|
75
|
+
export const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
76
|
+
if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
|
|
77
77
|
return participant;
|
|
78
78
|
}
|
|
79
79
|
return remoteJid;
|
|
80
80
|
};
|
|
81
|
-
exports.getChatId = getChatId;
|
|
82
81
|
/**
|
|
83
82
|
* Decrypt a poll vote
|
|
84
83
|
* @param vote encrypted vote
|
|
85
84
|
* @param ctx additional info about the poll required for decryption
|
|
86
85
|
* @returns list of SHA256 options
|
|
87
86
|
*/
|
|
88
|
-
function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid
|
|
87
|
+
export function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }) {
|
|
89
88
|
const sign = Buffer.concat([
|
|
90
89
|
toBinary(pollMsgId),
|
|
91
90
|
toBinary(pollCreatorJid),
|
|
@@ -93,52 +92,74 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
|
|
|
93
92
|
toBinary('Poll Vote'),
|
|
94
93
|
new Uint8Array([1])
|
|
95
94
|
]);
|
|
96
|
-
const key0 =
|
|
97
|
-
const decKey =
|
|
95
|
+
const key0 = hmacSign(pollEncKey, new Uint8Array(32), 'sha256');
|
|
96
|
+
const decKey = hmacSign(sign, key0, 'sha256');
|
|
98
97
|
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`);
|
|
99
|
-
const decrypted =
|
|
100
|
-
return
|
|
98
|
+
const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad);
|
|
99
|
+
return proto.Message.PollVoteMessage.decode(decrypted);
|
|
100
|
+
function toBinary(txt) {
|
|
101
|
+
return Buffer.from(txt);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Decrypt an event response
|
|
106
|
+
* @param response encrypted event response
|
|
107
|
+
* @param ctx additional info about the event required for decryption
|
|
108
|
+
* @returns event response message
|
|
109
|
+
*/
|
|
110
|
+
export function decryptEventResponse({ encPayload, encIv }, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }) {
|
|
111
|
+
const sign = Buffer.concat([
|
|
112
|
+
toBinary(eventMsgId),
|
|
113
|
+
toBinary(eventCreatorJid),
|
|
114
|
+
toBinary(responderJid),
|
|
115
|
+
toBinary('Event Response'),
|
|
116
|
+
new Uint8Array([1])
|
|
117
|
+
]);
|
|
118
|
+
const key0 = hmacSign(eventEncKey, new Uint8Array(32), 'sha256');
|
|
119
|
+
const decKey = hmacSign(sign, key0, 'sha256');
|
|
120
|
+
const aad = toBinary(`${eventMsgId}\u0000${responderJid}`);
|
|
121
|
+
const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad);
|
|
122
|
+
return proto.Message.EventResponseMessage.decode(decrypted);
|
|
101
123
|
function toBinary(txt) {
|
|
102
124
|
return Buffer.from(txt);
|
|
103
125
|
}
|
|
104
126
|
}
|
|
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;
|
|
127
|
+
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }) => {
|
|
107
128
|
const meId = creds.me.id;
|
|
108
129
|
const { accountSettings } = creds;
|
|
109
|
-
const chat = { id:
|
|
110
|
-
const isRealMsg =
|
|
130
|
+
const chat = { id: jidNormalizedUser(getChatId(message.key)) };
|
|
131
|
+
const isRealMsg = isRealMessage(message);
|
|
111
132
|
if (isRealMsg) {
|
|
112
133
|
chat.messages = [{ message }];
|
|
113
|
-
chat.conversationTimestamp =
|
|
134
|
+
chat.conversationTimestamp = toNumber(message.messageTimestamp);
|
|
114
135
|
// only increment unread count if not CIPHERTEXT and from another person
|
|
115
|
-
if (
|
|
136
|
+
if (shouldIncrementChatUnread(message)) {
|
|
116
137
|
chat.unreadCount = (chat.unreadCount || 0) + 1;
|
|
117
138
|
}
|
|
118
139
|
}
|
|
119
|
-
const content =
|
|
140
|
+
const content = normalizeMessageContent(message.message);
|
|
120
141
|
// unarchive chat if it's a real message, or someone reacted to our message
|
|
121
142
|
// and we've the unarchive chats setting on
|
|
122
|
-
if ((isRealMsg ||
|
|
123
|
-
&& (accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.unarchiveChats)) {
|
|
143
|
+
if ((isRealMsg || content?.reactionMessage?.key?.fromMe) && accountSettings?.unarchiveChats) {
|
|
124
144
|
chat.archived = false;
|
|
125
145
|
chat.readOnly = false;
|
|
126
146
|
}
|
|
127
|
-
const protocolMsg = content
|
|
147
|
+
const protocolMsg = content?.protocolMessage;
|
|
128
148
|
if (protocolMsg) {
|
|
129
149
|
switch (protocolMsg.type) {
|
|
130
|
-
case
|
|
150
|
+
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
131
151
|
const histNotification = protocolMsg.historySyncNotification;
|
|
132
152
|
const process = shouldProcessHistoryMsg;
|
|
133
|
-
const isLatest = !
|
|
134
|
-
logger
|
|
153
|
+
const isLatest = !creds.processedHistoryMessages?.length;
|
|
154
|
+
logger?.info({
|
|
135
155
|
histNotification,
|
|
136
156
|
process,
|
|
137
157
|
id: message.key.id,
|
|
138
|
-
isLatest
|
|
158
|
+
isLatest
|
|
139
159
|
}, 'got history notification');
|
|
140
160
|
if (process) {
|
|
141
|
-
|
|
161
|
+
// TODO: investigate
|
|
162
|
+
if (histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
142
163
|
ev.emit('creds.update', {
|
|
143
164
|
processedHistoryMessages: [
|
|
144
165
|
...(creds.processedHistoryMessages || []),
|
|
@@ -146,19 +167,23 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
146
167
|
]
|
|
147
168
|
});
|
|
148
169
|
}
|
|
149
|
-
const data = await
|
|
170
|
+
const data = await downloadAndProcessHistorySyncNotification(histNotification, options, logger);
|
|
171
|
+
if (data.lidPnMappings?.length) {
|
|
172
|
+
logger?.debug({ count: data.lidPnMappings.length }, 'processing LID-PN mappings from history sync');
|
|
173
|
+
await signalRepository.lidMapping
|
|
174
|
+
.storeLIDPNMappings(data.lidPnMappings)
|
|
175
|
+
.catch(err => logger?.warn({ err }, 'failed to store LID-PN mappings from history sync'));
|
|
176
|
+
}
|
|
150
177
|
ev.emit('messaging-history.set', {
|
|
151
178
|
...data,
|
|
152
|
-
isLatest: histNotification.syncType !==
|
|
153
|
-
? isLatest
|
|
154
|
-
: undefined,
|
|
179
|
+
isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
|
|
155
180
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
156
181
|
});
|
|
157
182
|
}
|
|
158
183
|
break;
|
|
159
|
-
case
|
|
184
|
+
case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
160
185
|
const keys = protocolMsg.appStateSyncKeyShare.keys;
|
|
161
|
-
if (keys
|
|
186
|
+
if (keys?.length) {
|
|
162
187
|
let newAppStateSyncKeyId = '';
|
|
163
188
|
await keyStore.transaction(async () => {
|
|
164
189
|
const newKeys = [];
|
|
@@ -168,58 +193,85 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
168
193
|
await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } });
|
|
169
194
|
newAppStateSyncKeyId = strKeyId;
|
|
170
195
|
}
|
|
171
|
-
logger
|
|
172
|
-
});
|
|
196
|
+
logger?.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys');
|
|
197
|
+
}, meId);
|
|
173
198
|
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId });
|
|
174
199
|
}
|
|
175
200
|
else {
|
|
176
|
-
logger
|
|
201
|
+
logger?.info({ protocolMsg }, 'recv app state sync with 0 keys');
|
|
177
202
|
}
|
|
178
203
|
break;
|
|
179
|
-
case
|
|
204
|
+
case proto.Message.ProtocolMessage.Type.REVOKE:
|
|
180
205
|
ev.emit('messages.update', [
|
|
181
206
|
{
|
|
182
207
|
key: {
|
|
183
208
|
...message.key,
|
|
184
209
|
id: protocolMsg.key.id
|
|
185
210
|
},
|
|
186
|
-
update: { message: null, messageStubType:
|
|
211
|
+
update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
|
|
187
212
|
}
|
|
188
213
|
]);
|
|
189
214
|
break;
|
|
190
|
-
case
|
|
215
|
+
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
191
216
|
Object.assign(chat, {
|
|
192
|
-
ephemeralSettingTimestamp:
|
|
217
|
+
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
|
|
193
218
|
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
|
194
219
|
});
|
|
195
220
|
break;
|
|
196
|
-
case
|
|
221
|
+
case proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
197
222
|
const response = protocolMsg.peerDataOperationRequestResponseMessage;
|
|
198
223
|
if (response) {
|
|
199
|
-
placeholderResendCache === null || placeholderResendCache === void 0 ? void 0 : placeholderResendCache.del(response.stanzaId);
|
|
200
224
|
// TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
|
|
201
|
-
const
|
|
225
|
+
const peerDataOperationResult = response.peerDataOperationResult || [];
|
|
202
226
|
for (const result of peerDataOperationResult) {
|
|
203
|
-
const
|
|
227
|
+
const retryResponse = result?.placeholderMessageResendResponse;
|
|
204
228
|
//eslint-disable-next-line max-depth
|
|
205
|
-
if (retryResponse) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
229
|
+
if (!retryResponse?.webMessageInfoBytes) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
//eslint-disable-next-line max-depth
|
|
233
|
+
try {
|
|
234
|
+
const webMessageInfo = proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
|
|
235
|
+
const msgId = webMessageInfo.key?.id;
|
|
236
|
+
// Retrieve cached original message data (preserves LID details,
|
|
237
|
+
// timestamps, etc. that the phone may omit in its PDO response)
|
|
238
|
+
const cachedData = msgId ? await placeholderResendCache?.get(msgId) : undefined;
|
|
239
|
+
//eslint-disable-next-line max-depth
|
|
240
|
+
if (msgId) {
|
|
241
|
+
await placeholderResendCache?.del(msgId);
|
|
242
|
+
}
|
|
243
|
+
let finalMsg;
|
|
244
|
+
//eslint-disable-next-line max-depth
|
|
245
|
+
if (cachedData && typeof cachedData === 'object') {
|
|
246
|
+
// Apply decoded message content onto cached metadata (preserves LID etc.)
|
|
247
|
+
cachedData.message = webMessageInfo.message;
|
|
248
|
+
//eslint-disable-next-line max-depth
|
|
249
|
+
if (webMessageInfo.messageTimestamp) {
|
|
250
|
+
cachedData.messageTimestamp = webMessageInfo.messageTimestamp;
|
|
251
|
+
}
|
|
252
|
+
finalMsg = cachedData;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
finalMsg = webMessageInfo;
|
|
256
|
+
}
|
|
257
|
+
logger?.debug({ msgId, requestId: response.stanzaId }, 'received placeholder resend');
|
|
258
|
+
ev.emit('messages.upsert', {
|
|
259
|
+
messages: [finalMsg],
|
|
260
|
+
type: 'notify',
|
|
261
|
+
requestId: response.stanzaId
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
logger?.warn({ err, stanzaId: response.stanzaId }, 'failed to decode placeholder resend response');
|
|
215
266
|
}
|
|
216
267
|
}
|
|
217
268
|
}
|
|
218
|
-
|
|
269
|
+
break;
|
|
270
|
+
case proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
219
271
|
ev.emit('messages.update', [
|
|
220
272
|
{
|
|
221
273
|
// flip the sender / fromMe properties because they're in the perspective of the sender
|
|
222
|
-
key: { ...message.key, id:
|
|
274
|
+
key: { ...message.key, id: protocolMsg.key?.id },
|
|
223
275
|
update: {
|
|
224
276
|
message: {
|
|
225
277
|
editedMessage: {
|
|
@@ -227,122 +279,220 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
227
279
|
}
|
|
228
280
|
},
|
|
229
281
|
messageTimestamp: protocolMsg.timestampMs
|
|
230
|
-
? Math.floor(
|
|
282
|
+
? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
|
|
231
283
|
: message.messageTimestamp
|
|
232
284
|
}
|
|
233
285
|
}
|
|
234
286
|
]);
|
|
235
287
|
break;
|
|
288
|
+
case proto.Message.ProtocolMessage.Type.GROUP_MEMBER_LABEL_CHANGE:
|
|
289
|
+
const labelAssociationMsg = protocolMsg.memberLabel;
|
|
290
|
+
if (labelAssociationMsg?.label) {
|
|
291
|
+
ev.emit('group.member-tag.update', {
|
|
292
|
+
groupId: chat.id,
|
|
293
|
+
label: labelAssociationMsg.label,
|
|
294
|
+
participant: message.key.participant,
|
|
295
|
+
participantAlt: message.key.participantAlt,
|
|
296
|
+
messageTimestamp: Number(message.messageTimestamp)
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
case proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
|
|
301
|
+
const encodedPayload = protocolMsg.lidMigrationMappingSyncMessage?.encodedMappingPayload;
|
|
302
|
+
const { pnToLidMappings, chatDbMigrationTimestamp } = proto.LIDMigrationMappingSyncPayload.decode(encodedPayload);
|
|
303
|
+
logger?.debug({ pnToLidMappings, chatDbMigrationTimestamp }, 'got lid mappings and chat db migration timestamp');
|
|
304
|
+
const pairs = [];
|
|
305
|
+
for (const { pn, latestLid, assignedLid } of pnToLidMappings) {
|
|
306
|
+
const lid = latestLid || assignedLid;
|
|
307
|
+
pairs.push({ lid: `${lid}@lid`, pn: `${pn}@s.whatsapp.net` });
|
|
308
|
+
}
|
|
309
|
+
await signalRepository.lidMapping.storeLIDPNMappings(pairs);
|
|
310
|
+
if (pairs.length) {
|
|
311
|
+
for (const { pn, lid } of pairs) {
|
|
312
|
+
await signalRepository.migrateSession(pn, lid);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
236
315
|
}
|
|
237
316
|
}
|
|
238
|
-
else if (content
|
|
317
|
+
else if (content?.reactionMessage) {
|
|
239
318
|
const reaction = {
|
|
240
319
|
...content.reactionMessage,
|
|
241
|
-
key: message.key
|
|
320
|
+
key: message.key
|
|
242
321
|
};
|
|
243
|
-
ev.emit('messages.reaction', [
|
|
322
|
+
ev.emit('messages.reaction', [
|
|
323
|
+
{
|
|
244
324
|
reaction,
|
|
245
|
-
key:
|
|
246
|
-
}
|
|
325
|
+
key: content.reactionMessage?.key
|
|
326
|
+
}
|
|
327
|
+
]);
|
|
328
|
+
}
|
|
329
|
+
else if (content?.encEventResponseMessage) {
|
|
330
|
+
const encEventResponse = content.encEventResponseMessage;
|
|
331
|
+
const creationMsgKey = encEventResponse.eventCreationMessageKey;
|
|
332
|
+
// we need to fetch the event creation message to get the event enc key
|
|
333
|
+
const eventMsg = await getMessage(creationMsgKey);
|
|
334
|
+
if (eventMsg) {
|
|
335
|
+
try {
|
|
336
|
+
const meIdNormalised = jidNormalizedUser(meId);
|
|
337
|
+
// all jids need to be PN
|
|
338
|
+
const eventCreatorKey = creationMsgKey.participant || creationMsgKey.remoteJid;
|
|
339
|
+
const eventCreatorPn = isLidUser(eventCreatorKey)
|
|
340
|
+
? await signalRepository.lidMapping.getPNForLID(eventCreatorKey)
|
|
341
|
+
: eventCreatorKey;
|
|
342
|
+
const eventCreatorJid = getKeyAuthor({ remoteJid: jidNormalizedUser(eventCreatorPn), fromMe: meIdNormalised === eventCreatorPn }, meIdNormalised);
|
|
343
|
+
const responderJid = getKeyAuthor(message.key, meIdNormalised);
|
|
344
|
+
const eventEncKey = eventMsg?.messageContextInfo?.messageSecret;
|
|
345
|
+
if (!eventEncKey) {
|
|
346
|
+
logger?.warn({ creationMsgKey }, 'event response: missing messageSecret for decryption');
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
const responseMsg = decryptEventResponse(encEventResponse, {
|
|
350
|
+
eventEncKey,
|
|
351
|
+
eventCreatorJid,
|
|
352
|
+
eventMsgId: creationMsgKey.id,
|
|
353
|
+
responderJid
|
|
354
|
+
});
|
|
355
|
+
const eventResponse = {
|
|
356
|
+
eventResponseMessageKey: message.key,
|
|
357
|
+
senderTimestampMs: responseMsg.timestampMs,
|
|
358
|
+
response: responseMsg
|
|
359
|
+
};
|
|
360
|
+
ev.emit('messages.update', [
|
|
361
|
+
{
|
|
362
|
+
key: creationMsgKey,
|
|
363
|
+
update: {
|
|
364
|
+
eventResponses: [eventResponse]
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
]);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
catch (err) {
|
|
371
|
+
logger?.warn({ err, creationMsgKey }, 'failed to decrypt event response');
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
logger?.warn({ creationMsgKey }, 'event creation message not found, cannot decrypt response');
|
|
376
|
+
}
|
|
247
377
|
}
|
|
248
378
|
else if (message.messageStubType) {
|
|
249
|
-
const jid =
|
|
379
|
+
const jid = message.key?.remoteJid;
|
|
250
380
|
//let actor = whatsappID (message.participant)
|
|
251
381
|
let participants;
|
|
252
|
-
const emitParticipantsUpdate = (action) =>
|
|
382
|
+
const emitParticipantsUpdate = (action) => ev.emit('group-participants.update', {
|
|
383
|
+
id: jid,
|
|
384
|
+
author: message.key.participant,
|
|
385
|
+
authorPn: message.key.participantAlt,
|
|
386
|
+
participants,
|
|
387
|
+
action
|
|
388
|
+
});
|
|
253
389
|
const emitGroupUpdate = (update) => {
|
|
254
|
-
|
|
255
|
-
|
|
390
|
+
ev.emit('groups.update', [
|
|
391
|
+
{ id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
|
|
392
|
+
]);
|
|
256
393
|
};
|
|
257
394
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
258
|
-
ev.emit('group.join-request', {
|
|
395
|
+
ev.emit('group.join-request', {
|
|
396
|
+
id: jid,
|
|
397
|
+
author: message.key.participant,
|
|
398
|
+
authorPn: message.key.participantAlt,
|
|
399
|
+
participant: participant.lid,
|
|
400
|
+
participantPn: participant.pn,
|
|
401
|
+
action,
|
|
402
|
+
method: method
|
|
403
|
+
});
|
|
259
404
|
};
|
|
260
|
-
const participantsIncludesMe = () => participants.find(jid =>
|
|
405
|
+
const participantsIncludesMe = () => participants.find(jid => areJidsSameUser(meId, jid.phoneNumber)); // ADD SUPPORT FOR LID
|
|
261
406
|
switch (message.messageStubType) {
|
|
262
|
-
case
|
|
263
|
-
participants = message.messageStubParameters || [];
|
|
407
|
+
case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
408
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
264
409
|
emitParticipantsUpdate('modify');
|
|
265
410
|
break;
|
|
266
|
-
case
|
|
267
|
-
case
|
|
268
|
-
participants = message.messageStubParameters || [];
|
|
411
|
+
case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
412
|
+
case WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
413
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
269
414
|
emitParticipantsUpdate('remove');
|
|
270
415
|
// mark the chat read only if you left the group
|
|
271
416
|
if (participantsIncludesMe()) {
|
|
272
417
|
chat.readOnly = true;
|
|
273
418
|
}
|
|
274
419
|
break;
|
|
275
|
-
case
|
|
276
|
-
case
|
|
277
|
-
case
|
|
278
|
-
participants = message.messageStubParameters || [];
|
|
420
|
+
case WAMessageStubType.GROUP_PARTICIPANT_ADD:
|
|
421
|
+
case WAMessageStubType.GROUP_PARTICIPANT_INVITE:
|
|
422
|
+
case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
|
|
423
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
279
424
|
if (participantsIncludesMe()) {
|
|
280
425
|
chat.readOnly = false;
|
|
281
426
|
}
|
|
282
427
|
emitParticipantsUpdate('add');
|
|
283
428
|
break;
|
|
284
|
-
case
|
|
285
|
-
participants = message.messageStubParameters || [];
|
|
429
|
+
case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
430
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
286
431
|
emitParticipantsUpdate('demote');
|
|
287
432
|
break;
|
|
288
|
-
case
|
|
289
|
-
participants = message.messageStubParameters || [];
|
|
433
|
+
case WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
|
|
434
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
290
435
|
emitParticipantsUpdate('promote');
|
|
291
436
|
break;
|
|
292
|
-
case
|
|
293
|
-
const announceValue =
|
|
437
|
+
case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
438
|
+
const announceValue = message.messageStubParameters?.[0];
|
|
294
439
|
emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' });
|
|
295
440
|
break;
|
|
296
|
-
case
|
|
297
|
-
const restrictValue =
|
|
441
|
+
case WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
|
442
|
+
const restrictValue = message.messageStubParameters?.[0];
|
|
298
443
|
emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' });
|
|
299
444
|
break;
|
|
300
|
-
case
|
|
301
|
-
const name =
|
|
445
|
+
case WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
|
446
|
+
const name = message.messageStubParameters?.[0];
|
|
302
447
|
chat.name = name;
|
|
303
448
|
emitGroupUpdate({ subject: name });
|
|
304
449
|
break;
|
|
305
|
-
case
|
|
306
|
-
const description =
|
|
450
|
+
case WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
|
|
451
|
+
const description = message.messageStubParameters?.[0];
|
|
307
452
|
chat.description = description;
|
|
308
453
|
emitGroupUpdate({ desc: description });
|
|
309
454
|
break;
|
|
310
|
-
case
|
|
311
|
-
const code =
|
|
455
|
+
case WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
|
|
456
|
+
const code = message.messageStubParameters?.[0];
|
|
312
457
|
emitGroupUpdate({ inviteCode: code });
|
|
313
458
|
break;
|
|
314
|
-
case
|
|
315
|
-
const memberAddValue =
|
|
459
|
+
case WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
460
|
+
const memberAddValue = message.messageStubParameters?.[0];
|
|
316
461
|
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
|
|
317
462
|
break;
|
|
318
|
-
case
|
|
319
|
-
const approvalMode =
|
|
463
|
+
case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
464
|
+
const approvalMode = message.messageStubParameters?.[0];
|
|
320
465
|
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
|
|
321
466
|
break;
|
|
322
|
-
case
|
|
323
|
-
const participant = (
|
|
324
|
-
const action =
|
|
325
|
-
const method =
|
|
467
|
+
case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD: // TODO: Add other events
|
|
468
|
+
const participant = JSON.parse(message.messageStubParameters?.[0]);
|
|
469
|
+
const action = message.messageStubParameters?.[1];
|
|
470
|
+
const method = message.messageStubParameters?.[2];
|
|
326
471
|
emitGroupRequestJoin(participant, action, method);
|
|
327
472
|
break;
|
|
328
473
|
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey;
|
|
474
|
+
} /* else if(content?.pollUpdateMessage) {
|
|
475
|
+
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey!
|
|
332
476
|
// we need to fetch the poll creation message to get the poll enc key
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
const
|
|
477
|
+
// TODO: make standalone, remove getMessage reference
|
|
478
|
+
// TODO: Remove entirely
|
|
479
|
+
const pollMsg = await getMessage(creationMsgKey)
|
|
480
|
+
if(pollMsg) {
|
|
481
|
+
const meIdNormalised = jidNormalizedUser(meId)
|
|
482
|
+
const pollCreatorJid = getKeyAuthor(creationMsgKey, meIdNormalised)
|
|
483
|
+
const voterJid = getKeyAuthor(message.key, meIdNormalised)
|
|
484
|
+
const pollEncKey = pollMsg.messageContextInfo?.messageSecret!
|
|
485
|
+
|
|
339
486
|
try {
|
|
340
|
-
const voteMsg = decryptPollVote(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
487
|
+
const voteMsg = decryptPollVote(
|
|
488
|
+
content.pollUpdateMessage.vote!,
|
|
489
|
+
{
|
|
490
|
+
pollEncKey,
|
|
491
|
+
pollCreatorJid,
|
|
492
|
+
pollMsgId: creationMsgKey.id!,
|
|
493
|
+
voterJid,
|
|
494
|
+
}
|
|
495
|
+
)
|
|
346
496
|
ev.emit('messages.update', [
|
|
347
497
|
{
|
|
348
498
|
key: creationMsgKey,
|
|
@@ -351,23 +501,28 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
351
501
|
{
|
|
352
502
|
pollUpdateMessageKey: message.key,
|
|
353
503
|
vote: voteMsg,
|
|
354
|
-
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
|
|
504
|
+
senderTimestampMs: (content.pollUpdateMessage.senderTimestampMs! as Long).toNumber(),
|
|
355
505
|
}
|
|
356
506
|
]
|
|
357
507
|
}
|
|
358
508
|
}
|
|
359
|
-
])
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
509
|
+
])
|
|
510
|
+
} catch(err) {
|
|
511
|
+
logger?.warn(
|
|
512
|
+
{ err, creationMsgKey },
|
|
513
|
+
'failed to decrypt poll vote'
|
|
514
|
+
)
|
|
363
515
|
}
|
|
516
|
+
} else {
|
|
517
|
+
logger?.warn(
|
|
518
|
+
{ creationMsgKey },
|
|
519
|
+
'poll creation message not found, cannot decrypt update'
|
|
520
|
+
)
|
|
364
521
|
}
|
|
365
|
-
|
|
366
|
-
logger === null || logger === void 0 ? void 0 : logger.warn({ creationMsgKey }, 'poll creation message not found, cannot decrypt update');
|
|
367
|
-
}
|
|
368
|
-
}
|
|
522
|
+
} */
|
|
369
523
|
if (Object.keys(chat).length > 1) {
|
|
370
524
|
ev.emit('chats.update', [chat]);
|
|
371
525
|
}
|
|
372
526
|
};
|
|
373
|
-
|
|
527
|
+
export default processMessage;
|
|
528
|
+
//# sourceMappingURL=process-message.js.map
|