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