@ryuhan/baileys 1.0.9 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{README.MD → README.md} +63 -7
- package/WAProto/GenerateStatics.sh +3 -4
- package/WAProto/WAProto.proto +1215 -511
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +14017 -0
- package/WAProto/index.js +65471 -137445
- package/index.cjs +196 -0
- package/index.d.ts +30 -0
- package/lib/Defaults/index.d.ts +74 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +79 -65
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -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 +2 -5
- 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 +7 -41
- 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 +37 -51
- 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 -57
- 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 +7 -44
- 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 +7 -15
- 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 +8 -11
- 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 +9 -12
- 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 +2 -5
- 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 +9 -21
- 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 +27 -42
- 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/lib/Signal/Group/sender-message-key.js +4 -7
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +352 -88
- 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 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -18
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +4 -6
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +21 -78
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +202 -0
- 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 +111 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +475 -273
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +258 -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/community.js +361 -0
- package/lib/Socket/groups.d.ts +150 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +228 -101
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +245 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +11 -9
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +187 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +1011 -468
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +183 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +1149 -386
- 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 +160 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +229 -209
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +55 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +517 -233
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Socket/usync.js +19 -13
- package/lib/Store/index.js +4 -8
- package/lib/Store/make-cache-manager-store.js +77 -0
- package/lib/Store/make-in-memory-store.js +59 -98
- package/lib/Store/make-ordered-dictionary.js +1 -4
- package/lib/Store/object-repository.js +1 -5
- package/lib/Types/Auth.d.ts +116 -0
- 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 +15 -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 +123 -0
- 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 +24 -0
- 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 +237 -0
- 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 +67 -0
- 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 +47 -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 +30 -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 +305 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -7
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/MexUpdates.js +9 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +38 -13
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +79 -0
- 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 +76 -0
- 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 +133 -0
- 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 +39 -0
- 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 +26 -0
- 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 +65 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +16 -31
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/apocalypse-api.js +196 -0
- package/lib/Utils/apocalypse.d.ts +116 -0
- package/lib/Utils/apocalypse.js +275 -0
- package/lib/Utils/audioToBuffer.js +31 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +228 -137
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/baileys-event-stream.js +54 -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 +37 -31
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +23 -0
- 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 +70 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +315 -233
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +41 -116
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +139 -63
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +128 -72
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +91 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +178 -234
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +22 -0
- 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 +10 -13
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +23 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +28 -36
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +15 -56
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +13 -0
- 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 -0
- 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 +9 -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 +148 -58
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +130 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +468 -517
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages-newsletter.d.ts +84 -0
- package/lib/Utils/messages-newsletter.js +316 -0
- package/lib/Utils/messages.d.ts +92 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +1115 -466
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +149 -98
- package/lib/Utils/noise-handler.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 +60 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +316 -202
- 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/resolve-jid.d.ts +43 -0
- package/lib/Utils/resolve-jid.js +101 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +70 -64
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/streamToBuffer.js +17 -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-mongo-file-auth-state.js +77 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +25 -27
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/use-single-file-auth-state.js +74 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +70 -99
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +9 -11
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +49 -52
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +19 -49
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +61 -43
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +7 -21
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +73 -60
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +19 -0
- 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 +9 -0
- 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 +40 -0
- 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 -0
- 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 -0
- 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/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- 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 +23 -0
- 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 +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +8 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- 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 +26 -0
- 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 +10 -0
- 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 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +6 -20
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- 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 +13 -0
- 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 -0
- 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 +30 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +57 -83
- package/lib/index.js.map +1 -0
- package/package.json +52 -81
- package/lib/Defaults/wileys-version.json +0 -3
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Utils/wileys-event-stream.js +0 -63
|
@@ -1,55 +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, meLid) => {
|
|
16
|
+
export const cleanMessage = (message, meId, meLid) => {
|
|
23
17
|
// ensure remoteJid and participant doesn't have device or agent in it
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
message.key.remoteJid = (0, WABinary_1.jidEncode)((0, WABinary_1.jidDecode)(message.key === null || message.key === void 0 ? void 0 : message.key.remoteJid) === null || (0, WABinary_1.jidDecode)(message.key === null || message.key === void 0 ? void 0 : message.key.remoteJid) === void 0 ? void 0 : (0, WABinary_1.jidDecode)(message.key === null || message.key === void 0 ? void 0 : message.key.remoteJid).user, (0, WABinary_1.isHostedPnUser)(message.key.remoteJid) ? 's.whatsapp.net' : 'lid');
|
|
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');
|
|
27
20
|
}
|
|
28
21
|
else {
|
|
29
|
-
|
|
30
|
-
message.key.remoteJid = (0, WABinary_1.jidNormalizedUser)(message.key.remoteJid);
|
|
31
|
-
}
|
|
32
|
-
catch (_e) {
|
|
33
|
-
// if normalization fails, retain original remoteJid
|
|
34
|
-
}
|
|
22
|
+
message.key.remoteJid = jidNormalizedUser(message.key.remoteJid);
|
|
35
23
|
}
|
|
36
|
-
if ((
|
|
37
|
-
message.key.participant =
|
|
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');
|
|
38
26
|
}
|
|
39
|
-
else
|
|
40
|
-
|
|
41
|
-
message.key.participant = (0, WABinary_1.jidNormalizedUser)(message.key.participant);
|
|
42
|
-
}
|
|
43
|
-
catch (_e) {
|
|
44
|
-
// ignore if can't normalize participant
|
|
45
|
-
}
|
|
27
|
+
else {
|
|
28
|
+
message.key.participant = jidNormalizedUser(message.key.participant);
|
|
46
29
|
}
|
|
47
|
-
const content =
|
|
30
|
+
const content = normalizeMessageContent(message.message);
|
|
48
31
|
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
|
49
|
-
if (content
|
|
32
|
+
if (content?.reactionMessage) {
|
|
50
33
|
normaliseKey(content.reactionMessage.key);
|
|
51
34
|
}
|
|
52
|
-
if (content
|
|
35
|
+
if (content?.pollUpdateMessage) {
|
|
53
36
|
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey);
|
|
54
37
|
}
|
|
55
38
|
function normaliseKey(msgKey) {
|
|
@@ -59,11 +42,11 @@ const cleanMessage = (message, meId, meLid) => {
|
|
|
59
42
|
// if the sender believed the message being reacted to is not from them
|
|
60
43
|
// we've to correct the key to be from them, or some other participant
|
|
61
44
|
msgKey.fromMe = !msgKey.fromMe
|
|
62
|
-
?
|
|
63
|
-
|
|
64
|
-
// if the message being reacted to, was from them
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
|
67
50
|
// set the remoteJid to being the same as the chat the message came from
|
|
68
51
|
// TODO: investigate inconsistencies
|
|
69
52
|
msgKey.remoteJid = message.key.remoteJid;
|
|
@@ -72,43 +55,36 @@ const cleanMessage = (message, meId, meLid) => {
|
|
|
72
55
|
}
|
|
73
56
|
}
|
|
74
57
|
};
|
|
75
|
-
|
|
76
|
-
const isRealMessage = (message
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
&&
|
|
85
|
-
|
|
86
|
-
&& !(normalizedContent === null || normalizedContent === void 0 ? void 0 : normalizedContent.reactionMessage)
|
|
87
|
-
&& !(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);
|
|
88
69
|
};
|
|
89
|
-
|
|
90
|
-
const shouldIncrementChatUnread = (message) => (!message.key.fromMe && !message.messageStubType);
|
|
91
|
-
exports.shouldIncrementChatUnread = shouldIncrementChatUnread;
|
|
70
|
+
export const shouldIncrementChatUnread = (message) => !message.key.fromMe && !message.messageStubType;
|
|
92
71
|
/**
|
|
93
72
|
* Get the ID of the chat from the given key.
|
|
94
73
|
* Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
|
|
95
74
|
*/
|
|
96
|
-
const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
97
|
-
if ((
|
|
98
|
-
&& !(0, WABinary_1.isJidStatusBroadcast)(remoteJid)
|
|
99
|
-
&& !fromMe) {
|
|
75
|
+
export const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
76
|
+
if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
|
|
100
77
|
return participant;
|
|
101
78
|
}
|
|
102
79
|
return remoteJid;
|
|
103
80
|
};
|
|
104
|
-
exports.getChatId = getChatId;
|
|
105
81
|
/**
|
|
106
82
|
* Decrypt a poll vote
|
|
107
83
|
* @param vote encrypted vote
|
|
108
84
|
* @param ctx additional info about the poll required for decryption
|
|
109
85
|
* @returns list of SHA256 options
|
|
110
86
|
*/
|
|
111
|
-
function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid
|
|
87
|
+
export function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }) {
|
|
112
88
|
const sign = Buffer.concat([
|
|
113
89
|
toBinary(pollMsgId),
|
|
114
90
|
toBinary(pollCreatorJid),
|
|
@@ -116,71 +92,74 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
|
|
|
116
92
|
toBinary('Poll Vote'),
|
|
117
93
|
new Uint8Array([1])
|
|
118
94
|
]);
|
|
119
|
-
const key0 =
|
|
120
|
-
const decKey =
|
|
95
|
+
const key0 = hmacSign(pollEncKey, new Uint8Array(32), 'sha256');
|
|
96
|
+
const decKey = hmacSign(sign, key0, 'sha256');
|
|
121
97
|
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`);
|
|
122
|
-
const decrypted =
|
|
123
|
-
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);
|
|
124
123
|
function toBinary(txt) {
|
|
125
124
|
return Buffer.from(txt);
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
|
-
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options, getMessage }) => {
|
|
129
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
127
|
+
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }) => {
|
|
130
128
|
const meId = creds.me.id;
|
|
131
129
|
const { accountSettings } = creds;
|
|
132
|
-
const chat = { id:
|
|
133
|
-
const isRealMsg =
|
|
130
|
+
const chat = { id: jidNormalizedUser(getChatId(message.key)) };
|
|
131
|
+
const isRealMsg = isRealMessage(message);
|
|
134
132
|
if (isRealMsg) {
|
|
135
133
|
chat.messages = [{ message }];
|
|
136
|
-
chat.conversationTimestamp =
|
|
134
|
+
chat.conversationTimestamp = toNumber(message.messageTimestamp);
|
|
137
135
|
// only increment unread count if not CIPHERTEXT and from another person
|
|
138
|
-
if (
|
|
136
|
+
if (shouldIncrementChatUnread(message)) {
|
|
139
137
|
chat.unreadCount = (chat.unreadCount || 0) + 1;
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
|
-
const content =
|
|
143
|
-
const senderId = message.key.participant || message.key.remoteJid;
|
|
144
|
-
if ((0, WABinary_1.isLidUser)(senderId)) {
|
|
145
|
-
const jid = (0, WABinary_1.lidToJid)(senderId);
|
|
146
|
-
if (message.key.participant) {
|
|
147
|
-
message.key.participant = jid;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
message.key.remoteJid = jid;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const mJids = content && content.contextInfo && content.contextInfo.mentionedJid ? content.contextInfo.mentionedJid : [];
|
|
154
|
-
for (let i = 0; i < mJids.length; i++) {
|
|
155
|
-
if ((0, WABinary_1.isLidUser)(mJids[i])) {
|
|
156
|
-
mJids[i] = (0, WABinary_1.lidToJid)(mJids[i]);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (content && content.contextInfo && content.contextInfo.participant && (0, WABinary_1.isLidUser)(content.contextInfo.participant)) {
|
|
160
|
-
content.contextInfo.participant = (0, WABinary_1.lidToJid)(content.contextInfo.participant);
|
|
161
|
-
}
|
|
140
|
+
const content = normalizeMessageContent(message.message);
|
|
162
141
|
// unarchive chat if it's a real message, or someone reacted to our message
|
|
163
142
|
// and we've the unarchive chats setting on
|
|
164
|
-
if ((isRealMsg ||
|
|
165
|
-
&& (accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.unarchiveChats)) {
|
|
143
|
+
if ((isRealMsg || content?.reactionMessage?.key?.fromMe) && accountSettings?.unarchiveChats) {
|
|
166
144
|
chat.archived = false;
|
|
167
145
|
chat.readOnly = false;
|
|
168
146
|
}
|
|
169
|
-
const protocolMsg = content
|
|
147
|
+
const protocolMsg = content?.protocolMessage;
|
|
170
148
|
if (protocolMsg) {
|
|
171
149
|
switch (protocolMsg.type) {
|
|
172
|
-
case
|
|
150
|
+
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
|
173
151
|
const histNotification = protocolMsg.historySyncNotification;
|
|
174
152
|
const process = shouldProcessHistoryMsg;
|
|
175
|
-
const isLatest = !
|
|
176
|
-
logger
|
|
153
|
+
const isLatest = !creds.processedHistoryMessages?.length;
|
|
154
|
+
logger?.info({
|
|
177
155
|
histNotification,
|
|
178
156
|
process,
|
|
179
157
|
id: message.key.id,
|
|
180
|
-
isLatest
|
|
158
|
+
isLatest
|
|
181
159
|
}, 'got history notification');
|
|
182
160
|
if (process) {
|
|
183
|
-
|
|
161
|
+
// TODO: investigate
|
|
162
|
+
if (histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
184
163
|
ev.emit('creds.update', {
|
|
185
164
|
processedHistoryMessages: [
|
|
186
165
|
...(creds.processedHistoryMessages || []),
|
|
@@ -188,19 +167,23 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
188
167
|
]
|
|
189
168
|
});
|
|
190
169
|
}
|
|
191
|
-
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
|
+
}
|
|
192
177
|
ev.emit('messaging-history.set', {
|
|
193
178
|
...data,
|
|
194
|
-
isLatest: histNotification.syncType !==
|
|
195
|
-
? isLatest
|
|
196
|
-
: undefined,
|
|
179
|
+
isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
|
|
197
180
|
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
198
181
|
});
|
|
199
182
|
}
|
|
200
183
|
break;
|
|
201
|
-
case
|
|
184
|
+
case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
|
|
202
185
|
const keys = protocolMsg.appStateSyncKeyShare.keys;
|
|
203
|
-
if (keys
|
|
186
|
+
if (keys?.length) {
|
|
204
187
|
let newAppStateSyncKeyId = '';
|
|
205
188
|
await keyStore.transaction(async () => {
|
|
206
189
|
const newKeys = [];
|
|
@@ -210,57 +193,85 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
210
193
|
await keyStore.set({ 'app-state-sync-key': { [strKeyId]: keyData } });
|
|
211
194
|
newAppStateSyncKeyId = strKeyId;
|
|
212
195
|
}
|
|
213
|
-
logger
|
|
214
|
-
});
|
|
196
|
+
logger?.info({ newAppStateSyncKeyId, newKeys }, 'injecting new app state sync keys');
|
|
197
|
+
}, meId);
|
|
215
198
|
ev.emit('creds.update', { myAppStateKeyId: newAppStateSyncKeyId });
|
|
216
199
|
}
|
|
217
200
|
else {
|
|
218
|
-
logger
|
|
201
|
+
logger?.info({ protocolMsg }, 'recv app state sync with 0 keys');
|
|
219
202
|
}
|
|
220
203
|
break;
|
|
221
|
-
case
|
|
204
|
+
case proto.Message.ProtocolMessage.Type.REVOKE:
|
|
222
205
|
ev.emit('messages.update', [
|
|
223
206
|
{
|
|
224
207
|
key: {
|
|
225
208
|
...message.key,
|
|
226
209
|
id: protocolMsg.key.id
|
|
227
210
|
},
|
|
228
|
-
update: { message: null, messageStubType:
|
|
211
|
+
update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
|
|
229
212
|
}
|
|
230
213
|
]);
|
|
231
214
|
break;
|
|
232
|
-
case
|
|
215
|
+
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
|
233
216
|
Object.assign(chat, {
|
|
234
|
-
ephemeralSettingTimestamp:
|
|
217
|
+
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
|
|
235
218
|
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
|
236
219
|
});
|
|
237
220
|
break;
|
|
238
|
-
case
|
|
221
|
+
case proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
|
|
239
222
|
const response = protocolMsg.peerDataOperationRequestResponseMessage;
|
|
240
223
|
if (response) {
|
|
241
|
-
placeholderResendCache === null || placeholderResendCache === void 0 ? void 0 : placeholderResendCache.del(response.stanzaId);
|
|
242
224
|
// TODO: IMPLEMENT HISTORY SYNC ETC (sticker uploads etc.).
|
|
243
|
-
const
|
|
225
|
+
const peerDataOperationResult = response.peerDataOperationResult || [];
|
|
244
226
|
for (const result of peerDataOperationResult) {
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
227
|
+
const retryResponse = result?.placeholderMessageResendResponse;
|
|
228
|
+
//eslint-disable-next-line max-depth
|
|
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');
|
|
256
266
|
}
|
|
257
267
|
}
|
|
258
268
|
}
|
|
259
|
-
|
|
269
|
+
break;
|
|
270
|
+
case proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
|
|
260
271
|
ev.emit('messages.update', [
|
|
261
272
|
{
|
|
262
273
|
// flip the sender / fromMe properties because they're in the perspective of the sender
|
|
263
|
-
key: { ...message.key, id:
|
|
274
|
+
key: { ...message.key, id: protocolMsg.key?.id },
|
|
264
275
|
update: {
|
|
265
276
|
message: {
|
|
266
277
|
editedMessage: {
|
|
@@ -268,122 +279,220 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
268
279
|
}
|
|
269
280
|
},
|
|
270
281
|
messageTimestamp: protocolMsg.timestampMs
|
|
271
|
-
? Math.floor(
|
|
282
|
+
? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
|
|
272
283
|
: message.messageTimestamp
|
|
273
284
|
}
|
|
274
285
|
}
|
|
275
286
|
]);
|
|
276
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
|
+
}
|
|
277
315
|
}
|
|
278
316
|
}
|
|
279
|
-
else if (content
|
|
317
|
+
else if (content?.reactionMessage) {
|
|
280
318
|
const reaction = {
|
|
281
319
|
...content.reactionMessage,
|
|
282
|
-
key: message.key
|
|
320
|
+
key: message.key
|
|
283
321
|
};
|
|
284
|
-
ev.emit('messages.reaction', [
|
|
322
|
+
ev.emit('messages.reaction', [
|
|
323
|
+
{
|
|
285
324
|
reaction,
|
|
286
|
-
key:
|
|
287
|
-
}
|
|
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
|
+
}
|
|
288
377
|
}
|
|
289
378
|
else if (message.messageStubType) {
|
|
290
|
-
const jid =
|
|
379
|
+
const jid = message.key?.remoteJid;
|
|
291
380
|
//let actor = whatsappID (message.participant)
|
|
292
381
|
let participants;
|
|
293
|
-
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
|
+
});
|
|
294
389
|
const emitGroupUpdate = (update) => {
|
|
295
|
-
|
|
296
|
-
|
|
390
|
+
ev.emit('groups.update', [
|
|
391
|
+
{ id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
|
|
392
|
+
]);
|
|
297
393
|
};
|
|
298
394
|
const emitGroupRequestJoin = (participant, action, method) => {
|
|
299
|
-
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
|
+
});
|
|
300
404
|
};
|
|
301
|
-
const participantsIncludesMe = () => participants.find(jid =>
|
|
405
|
+
const participantsIncludesMe = () => participants.find(jid => areJidsSameUser(meId, jid.phoneNumber)); // ADD SUPPORT FOR LID
|
|
302
406
|
switch (message.messageStubType) {
|
|
303
|
-
case
|
|
304
|
-
participants = message.messageStubParameters || [];
|
|
407
|
+
case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
|
|
408
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
305
409
|
emitParticipantsUpdate('modify');
|
|
306
410
|
break;
|
|
307
|
-
case
|
|
308
|
-
case
|
|
309
|
-
participants = message.messageStubParameters || [];
|
|
411
|
+
case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
412
|
+
case WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
413
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
310
414
|
emitParticipantsUpdate('remove');
|
|
311
415
|
// mark the chat read only if you left the group
|
|
312
416
|
if (participantsIncludesMe()) {
|
|
313
417
|
chat.readOnly = true;
|
|
314
418
|
}
|
|
315
419
|
break;
|
|
316
|
-
case
|
|
317
|
-
case
|
|
318
|
-
case
|
|
319
|
-
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)) || [];
|
|
320
424
|
if (participantsIncludesMe()) {
|
|
321
425
|
chat.readOnly = false;
|
|
322
426
|
}
|
|
323
427
|
emitParticipantsUpdate('add');
|
|
324
428
|
break;
|
|
325
|
-
case
|
|
326
|
-
participants = message.messageStubParameters || [];
|
|
429
|
+
case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
430
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
327
431
|
emitParticipantsUpdate('demote');
|
|
328
432
|
break;
|
|
329
|
-
case
|
|
330
|
-
participants = message.messageStubParameters || [];
|
|
433
|
+
case WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
|
|
434
|
+
participants = message.messageStubParameters.map((a) => JSON.parse(a)) || [];
|
|
331
435
|
emitParticipantsUpdate('promote');
|
|
332
436
|
break;
|
|
333
|
-
case
|
|
334
|
-
const announceValue =
|
|
437
|
+
case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
438
|
+
const announceValue = message.messageStubParameters?.[0];
|
|
335
439
|
emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' });
|
|
336
440
|
break;
|
|
337
|
-
case
|
|
338
|
-
const restrictValue =
|
|
441
|
+
case WAMessageStubType.GROUP_CHANGE_RESTRICT:
|
|
442
|
+
const restrictValue = message.messageStubParameters?.[0];
|
|
339
443
|
emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' });
|
|
340
444
|
break;
|
|
341
|
-
case
|
|
342
|
-
const name =
|
|
445
|
+
case WAMessageStubType.GROUP_CHANGE_SUBJECT:
|
|
446
|
+
const name = message.messageStubParameters?.[0];
|
|
343
447
|
chat.name = name;
|
|
344
448
|
emitGroupUpdate({ subject: name });
|
|
345
449
|
break;
|
|
346
|
-
case
|
|
347
|
-
const description =
|
|
450
|
+
case WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
|
|
451
|
+
const description = message.messageStubParameters?.[0];
|
|
348
452
|
chat.description = description;
|
|
349
453
|
emitGroupUpdate({ desc: description });
|
|
350
454
|
break;
|
|
351
|
-
case
|
|
352
|
-
const code =
|
|
455
|
+
case WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
|
|
456
|
+
const code = message.messageStubParameters?.[0];
|
|
353
457
|
emitGroupUpdate({ inviteCode: code });
|
|
354
458
|
break;
|
|
355
|
-
case
|
|
356
|
-
const memberAddValue =
|
|
459
|
+
case WAMessageStubType.GROUP_MEMBER_ADD_MODE:
|
|
460
|
+
const memberAddValue = message.messageStubParameters?.[0];
|
|
357
461
|
emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' });
|
|
358
462
|
break;
|
|
359
|
-
case
|
|
360
|
-
const approvalMode =
|
|
463
|
+
case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
|
|
464
|
+
const approvalMode = message.messageStubParameters?.[0];
|
|
361
465
|
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' });
|
|
362
466
|
break;
|
|
363
|
-
case
|
|
364
|
-
const participant = (
|
|
365
|
-
const action =
|
|
366
|
-
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];
|
|
367
471
|
emitGroupRequestJoin(participant, action, method);
|
|
368
472
|
break;
|
|
369
473
|
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey;
|
|
474
|
+
} /* else if(content?.pollUpdateMessage) {
|
|
475
|
+
const creationMsgKey = content.pollUpdateMessage.pollCreationMessageKey!
|
|
373
476
|
// we need to fetch the poll creation message to get the poll enc key
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
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
|
+
|
|
380
486
|
try {
|
|
381
|
-
const voteMsg = decryptPollVote(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
487
|
+
const voteMsg = decryptPollVote(
|
|
488
|
+
content.pollUpdateMessage.vote!,
|
|
489
|
+
{
|
|
490
|
+
pollEncKey,
|
|
491
|
+
pollCreatorJid,
|
|
492
|
+
pollMsgId: creationMsgKey.id!,
|
|
493
|
+
voterJid,
|
|
494
|
+
}
|
|
495
|
+
)
|
|
387
496
|
ev.emit('messages.update', [
|
|
388
497
|
{
|
|
389
498
|
key: creationMsgKey,
|
|
@@ -392,23 +501,28 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
392
501
|
{
|
|
393
502
|
pollUpdateMessageKey: message.key,
|
|
394
503
|
vote: voteMsg,
|
|
395
|
-
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber(),
|
|
504
|
+
senderTimestampMs: (content.pollUpdateMessage.senderTimestampMs! as Long).toNumber(),
|
|
396
505
|
}
|
|
397
506
|
]
|
|
398
507
|
}
|
|
399
508
|
}
|
|
400
|
-
])
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
|
|
509
|
+
])
|
|
510
|
+
} catch(err) {
|
|
511
|
+
logger?.warn(
|
|
512
|
+
{ err, creationMsgKey },
|
|
513
|
+
'failed to decrypt poll vote'
|
|
514
|
+
)
|
|
404
515
|
}
|
|
516
|
+
} else {
|
|
517
|
+
logger?.warn(
|
|
518
|
+
{ creationMsgKey },
|
|
519
|
+
'poll creation message not found, cannot decrypt update'
|
|
520
|
+
)
|
|
405
521
|
}
|
|
406
|
-
|
|
407
|
-
logger === null || logger === void 0 ? void 0 : logger.warn({ creationMsgKey }, 'poll creation message not found, cannot decrypt update');
|
|
408
|
-
}
|
|
409
|
-
}
|
|
522
|
+
} */
|
|
410
523
|
if (Object.keys(chat).length > 1) {
|
|
411
524
|
ev.emit('chats.update', [chat]);
|
|
412
525
|
}
|
|
413
526
|
};
|
|
414
|
-
|
|
527
|
+
export default processMessage;
|
|
528
|
+
//# sourceMappingURL=process-message.js.map
|