@lynovratech/baileys 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1312 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +5479 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +14017 -0
- package/WAProto/index.js +97687 -0
- package/engine-requirements.js +10 -0
- package/lib/cjs/Defaults/index.d.ts +74 -0
- package/lib/cjs/Defaults/index.d.ts.map +1 -0
- package/lib/cjs/Defaults/index.js +134 -0
- package/lib/cjs/Defaults/index.js.map +1 -0
- package/lib/cjs/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/cjs/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/ciphertext-message.js +16 -0
- package/lib/cjs/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/cjs/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/cjs/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/group-session-builder.js +65 -0
- package/lib/cjs/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/cjs/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/cjs/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/group_cipher.js +83 -0
- package/lib/cjs/Signal/Group/group_cipher.js.map +1 -0
- package/lib/cjs/Signal/Group/index.d.ts +12 -0
- package/lib/cjs/Signal/Group/index.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/index.js +58 -0
- package/lib/cjs/Signal/Group/index.js.map +1 -0
- package/lib/cjs/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/cjs/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/keyhelper.js +56 -0
- package/lib/cjs/Signal/Group/keyhelper.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/cjs/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-chain-key.js +30 -0
- package/lib/cjs/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/cjs/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-distribution-message.js +67 -0
- package/lib/cjs/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/cjs/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-message.js +70 -0
- package/lib/cjs/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/cjs/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-name.js +52 -0
- package/lib/cjs/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/cjs/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-record.js +45 -0
- package/lib/cjs/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/cjs/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-key-state.js +88 -0
- package/lib/cjs/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/cjs/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/cjs/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/cjs/Signal/Group/sender-message-key.js +30 -0
- package/lib/cjs/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/cjs/Signal/jid-mapping.d.ts +50 -0
- package/lib/cjs/Signal/jid-mapping.d.ts.map +1 -0
- package/lib/cjs/Signal/jid-mapping.js +218 -0
- package/lib/cjs/Signal/jid-mapping.js.map +1 -0
- package/lib/cjs/Signal/libsignal.d.ts +7 -0
- package/lib/cjs/Signal/libsignal.d.ts.map +1 -0
- package/lib/cjs/Signal/libsignal.js +447 -0
- package/lib/cjs/Signal/libsignal.js.map +1 -0
- package/lib/cjs/Signal/lid-mapping.d.ts +6 -0
- package/lib/cjs/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/cjs/Signal/lid-mapping.js +10 -0
- package/lib/cjs/Signal/lid-mapping.js.map +1 -0
- package/lib/cjs/Socket/Client/index.d.ts +3 -0
- package/lib/cjs/Socket/Client/index.d.ts.map +1 -0
- package/lib/cjs/Socket/Client/index.js +19 -0
- package/lib/cjs/Socket/Client/index.js.map +1 -0
- package/lib/cjs/Socket/Client/types.d.ts +16 -0
- package/lib/cjs/Socket/Client/types.d.ts.map +1 -0
- package/lib/cjs/Socket/Client/types.js +14 -0
- package/lib/cjs/Socket/Client/types.js.map +1 -0
- package/lib/cjs/Socket/Client/websocket.d.ts +13 -0
- package/lib/cjs/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/cjs/Socket/Client/websocket.js +61 -0
- package/lib/cjs/Socket/Client/websocket.js.map +1 -0
- package/lib/cjs/Socket/business.d.ts +202 -0
- package/lib/cjs/Socket/business.d.ts.map +1 -0
- package/lib/cjs/Socket/business.js +383 -0
- package/lib/cjs/Socket/business.js.map +1 -0
- package/lib/cjs/Socket/chats.d.ts +111 -0
- package/lib/cjs/Socket/chats.d.ts.map +1 -0
- package/lib/cjs/Socket/chats.js +1006 -0
- package/lib/cjs/Socket/chats.js.map +1 -0
- package/lib/cjs/Socket/communities.d.ts +258 -0
- package/lib/cjs/Socket/communities.d.ts.map +1 -0
- package/lib/cjs/Socket/communities.js +439 -0
- package/lib/cjs/Socket/communities.js.map +1 -0
- package/lib/cjs/Socket/groups.d.ts +150 -0
- package/lib/cjs/Socket/groups.d.ts.map +1 -0
- package/lib/cjs/Socket/groups.js +335 -0
- package/lib/cjs/Socket/groups.js.map +1 -0
- package/lib/cjs/Socket/index.d.ts +245 -0
- package/lib/cjs/Socket/index.d.ts.map +1 -0
- package/lib/cjs/Socket/index.js +14 -0
- package/lib/cjs/Socket/index.js.map +1 -0
- package/lib/cjs/Socket/messages-recv.d.ts +187 -0
- package/lib/cjs/Socket/messages-recv.d.ts.map +1 -0
- package/lib/cjs/Socket/messages-recv.js +1325 -0
- package/lib/cjs/Socket/messages-recv.js.map +1 -0
- package/lib/cjs/Socket/messages-send.d.ts +183 -0
- package/lib/cjs/Socket/messages-send.d.ts.map +1 -0
- package/lib/cjs/Socket/messages-send.js +1046 -0
- package/lib/cjs/Socket/messages-send.js.map +1 -0
- package/lib/cjs/Socket/mex.d.ts +3 -0
- package/lib/cjs/Socket/mex.d.ts.map +1 -0
- package/lib/cjs/Socket/mex.js +46 -0
- package/lib/cjs/Socket/mex.js.map +1 -0
- package/lib/cjs/Socket/newsletter.d.ts +160 -0
- package/lib/cjs/Socket/newsletter.d.ts.map +1 -0
- package/lib/cjs/Socket/newsletter.js +185 -0
- package/lib/cjs/Socket/newsletter.js.map +1 -0
- package/lib/cjs/Socket/socket.d.ts +55 -0
- package/lib/cjs/Socket/socket.d.ts.map +1 -0
- package/lib/cjs/Socket/socket.js +940 -0
- package/lib/cjs/Socket/socket.js.map +1 -0
- package/lib/cjs/Types/Auth.d.ts +126 -0
- package/lib/cjs/Types/Auth.d.ts.map +1 -0
- package/lib/cjs/Types/Auth.js +3 -0
- package/lib/cjs/Types/Auth.js.map +1 -0
- package/lib/cjs/Types/Bussines.d.ts +25 -0
- package/lib/cjs/Types/Bussines.d.ts.map +1 -0
- package/lib/cjs/Types/Bussines.js +3 -0
- package/lib/cjs/Types/Bussines.js.map +1 -0
- package/lib/cjs/Types/Call.d.ts +15 -0
- package/lib/cjs/Types/Call.d.ts.map +1 -0
- package/lib/cjs/Types/Call.js +3 -0
- package/lib/cjs/Types/Call.js.map +1 -0
- package/lib/cjs/Types/Chat.d.ts +123 -0
- package/lib/cjs/Types/Chat.d.ts.map +1 -0
- package/lib/cjs/Types/Chat.js +11 -0
- package/lib/cjs/Types/Chat.js.map +1 -0
- package/lib/cjs/Types/Contact.d.ts +24 -0
- package/lib/cjs/Types/Contact.d.ts.map +1 -0
- package/lib/cjs/Types/Contact.js +3 -0
- package/lib/cjs/Types/Contact.js.map +1 -0
- package/lib/cjs/Types/Events.d.ts +241 -0
- package/lib/cjs/Types/Events.d.ts.map +1 -0
- package/lib/cjs/Types/Events.js +3 -0
- package/lib/cjs/Types/Events.js.map +1 -0
- package/lib/cjs/Types/GroupMetadata.d.ts +67 -0
- package/lib/cjs/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/cjs/Types/GroupMetadata.js +3 -0
- package/lib/cjs/Types/GroupMetadata.js.map +1 -0
- package/lib/cjs/Types/Label.d.ts +47 -0
- package/lib/cjs/Types/Label.d.ts.map +1 -0
- package/lib/cjs/Types/Label.js +28 -0
- package/lib/cjs/Types/Label.js.map +1 -0
- package/lib/cjs/Types/LabelAssociation.d.ts +30 -0
- package/lib/cjs/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/cjs/Types/LabelAssociation.js +10 -0
- package/lib/cjs/Types/LabelAssociation.js.map +1 -0
- package/lib/cjs/Types/Message.d.ts +310 -0
- package/lib/cjs/Types/Message.d.ts.map +1 -0
- package/lib/cjs/Types/Message.js +16 -0
- package/lib/cjs/Types/Message.js.map +1 -0
- package/lib/cjs/Types/Newsletter.d.ts +135 -0
- package/lib/cjs/Types/Newsletter.d.ts.map +1 -0
- package/lib/cjs/Types/Newsletter.js +34 -0
- package/lib/cjs/Types/Newsletter.js.map +1 -0
- package/lib/cjs/Types/Product.d.ts +79 -0
- package/lib/cjs/Types/Product.d.ts.map +1 -0
- package/lib/cjs/Types/Product.js +3 -0
- package/lib/cjs/Types/Product.js.map +1 -0
- package/lib/cjs/Types/Signal.d.ts +76 -0
- package/lib/cjs/Types/Signal.d.ts.map +1 -0
- package/lib/cjs/Types/Signal.js +3 -0
- package/lib/cjs/Types/Signal.js.map +1 -0
- package/lib/cjs/Types/Socket.d.ts +135 -0
- package/lib/cjs/Types/Socket.d.ts.map +1 -0
- package/lib/cjs/Types/Socket.js +3 -0
- package/lib/cjs/Types/Socket.js.map +1 -0
- package/lib/cjs/Types/State.d.ts +39 -0
- package/lib/cjs/Types/State.d.ts.map +1 -0
- package/lib/cjs/Types/State.js +15 -0
- package/lib/cjs/Types/State.js.map +1 -0
- package/lib/cjs/Types/USync.d.ts +26 -0
- package/lib/cjs/Types/USync.d.ts.map +1 -0
- package/lib/cjs/Types/USync.js +3 -0
- package/lib/cjs/Types/USync.js.map +1 -0
- package/lib/cjs/Types/index.d.ts +65 -0
- package/lib/cjs/Types/index.d.ts.map +1 -0
- package/lib/cjs/Types/index.js +43 -0
- package/lib/cjs/Types/index.js.map +1 -0
- package/lib/cjs/Utils/auth-utils.d.ts +19 -0
- package/lib/cjs/Utils/auth-utils.d.ts.map +1 -0
- package/lib/cjs/Utils/auth-utils.js +299 -0
- package/lib/cjs/Utils/auth-utils.js.map +1 -0
- package/lib/cjs/Utils/browser-utils.d.ts +4 -0
- package/lib/cjs/Utils/browser-utils.d.ts.map +1 -0
- package/lib/cjs/Utils/browser-utils.js +32 -0
- package/lib/cjs/Utils/browser-utils.js.map +1 -0
- package/lib/cjs/Utils/business.d.ts +23 -0
- package/lib/cjs/Utils/business.d.ts.map +1 -0
- package/lib/cjs/Utils/business.js +241 -0
- package/lib/cjs/Utils/business.js.map +1 -0
- package/lib/cjs/Utils/chat-utils.d.ts +70 -0
- package/lib/cjs/Utils/chat-utils.d.ts.map +1 -0
- package/lib/cjs/Utils/chat-utils.js +826 -0
- package/lib/cjs/Utils/chat-utils.js.map +1 -0
- package/lib/cjs/Utils/crypto.d.ts +37 -0
- package/lib/cjs/Utils/crypto.d.ts.map +1 -0
- package/lib/cjs/Utils/crypto.js +169 -0
- package/lib/cjs/Utils/crypto.js.map +1 -0
- package/lib/cjs/Utils/decode-wa-message.d.ts +48 -0
- package/lib/cjs/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/cjs/Utils/decode-wa-message.js +291 -0
- package/lib/cjs/Utils/decode-wa-message.js.map +1 -0
- package/lib/cjs/Utils/event-buffer.d.ts +34 -0
- package/lib/cjs/Utils/event-buffer.d.ts.map +1 -0
- package/lib/cjs/Utils/event-buffer.js +581 -0
- package/lib/cjs/Utils/event-buffer.js.map +1 -0
- package/lib/cjs/Utils/generics.d.ts +91 -0
- package/lib/cjs/Utils/generics.d.ts.map +1 -0
- package/lib/cjs/Utils/generics.js +416 -0
- package/lib/cjs/Utils/generics.js.map +1 -0
- package/lib/cjs/Utils/history.d.ts +22 -0
- package/lib/cjs/Utils/history.d.ts.map +1 -0
- package/lib/cjs/Utils/history.js +138 -0
- package/lib/cjs/Utils/history.js.map +1 -0
- package/lib/cjs/Utils/identity-change-handler.d.ts +38 -0
- package/lib/cjs/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/cjs/Utils/identity-change-handler.js +52 -0
- package/lib/cjs/Utils/identity-change-handler.js.map +1 -0
- package/lib/cjs/Utils/index.d.ts +21 -0
- package/lib/cjs/Utils/index.d.ts.map +1 -0
- package/lib/cjs/Utils/index.js +37 -0
- package/lib/cjs/Utils/index.js.map +1 -0
- package/lib/cjs/Utils/link-preview.d.ts +21 -0
- package/lib/cjs/Utils/link-preview.d.ts.map +1 -0
- package/lib/cjs/Utils/link-preview.js +122 -0
- package/lib/cjs/Utils/link-preview.js.map +1 -0
- package/lib/cjs/Utils/logger.d.ts +13 -0
- package/lib/cjs/Utils/logger.d.ts.map +1 -0
- package/lib/cjs/Utils/logger.js +8 -0
- package/lib/cjs/Utils/logger.js.map +1 -0
- package/lib/cjs/Utils/lt-hash.d.ts +8 -0
- package/lib/cjs/Utils/lt-hash.d.ts.map +1 -0
- package/lib/cjs/Utils/lt-hash.js +11 -0
- package/lib/cjs/Utils/lt-hash.js.map +1 -0
- package/lib/cjs/Utils/make-mutex.d.ts +9 -0
- package/lib/cjs/Utils/make-mutex.d.ts.map +1 -0
- package/lib/cjs/Utils/make-mutex.js +38 -0
- package/lib/cjs/Utils/make-mutex.js.map +1 -0
- package/lib/cjs/Utils/message-retry-manager.d.ts +110 -0
- package/lib/cjs/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/cjs/Utils/message-retry-manager.js +229 -0
- package/lib/cjs/Utils/message-retry-manager.js.map +1 -0
- package/lib/cjs/Utils/messages-media.d.ts +130 -0
- package/lib/cjs/Utils/messages-media.d.ts.map +1 -0
- package/lib/cjs/Utils/messages-media.js +835 -0
- package/lib/cjs/Utils/messages-media.js.map +1 -0
- package/lib/cjs/Utils/messages.d.ts +91 -0
- package/lib/cjs/Utils/messages.d.ts.map +1 -0
- package/lib/cjs/Utils/messages.js +902 -0
- package/lib/cjs/Utils/messages.js.map +1 -0
- package/lib/cjs/Utils/noise-handler.d.ts +20 -0
- package/lib/cjs/Utils/noise-handler.d.ts.map +1 -0
- package/lib/cjs/Utils/noise-handler.js +205 -0
- package/lib/cjs/Utils/noise-handler.js.map +1 -0
- package/lib/cjs/Utils/offline-node-processor.d.ts +17 -0
- package/lib/cjs/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/cjs/Utils/offline-node-processor.js +43 -0
- package/lib/cjs/Utils/offline-node-processor.js.map +1 -0
- package/lib/cjs/Utils/pre-key-manager.d.ts +28 -0
- package/lib/cjs/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/cjs/Utils/pre-key-manager.js +113 -0
- package/lib/cjs/Utils/pre-key-manager.js.map +1 -0
- package/lib/cjs/Utils/process-message.d.ts +60 -0
- package/lib/cjs/Utils/process-message.d.ts.map +1 -0
- package/lib/cjs/Utils/process-message.js +539 -0
- package/lib/cjs/Utils/process-message.js.map +1 -0
- package/lib/cjs/Utils/reporting-utils.d.ts +11 -0
- package/lib/cjs/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/cjs/Utils/reporting-utils.js +262 -0
- package/lib/cjs/Utils/reporting-utils.js.map +1 -0
- package/lib/cjs/Utils/signal.d.ts +34 -0
- package/lib/cjs/Utils/signal.d.ts.map +1 -0
- package/lib/cjs/Utils/signal.js +171 -0
- package/lib/cjs/Utils/signal.js.map +1 -0
- package/lib/cjs/Utils/stanza-ack.d.ts +11 -0
- package/lib/cjs/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/cjs/Utils/stanza-ack.js +41 -0
- package/lib/cjs/Utils/stanza-ack.js.map +1 -0
- package/lib/cjs/Utils/sync-action-utils.d.ts +19 -0
- package/lib/cjs/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/cjs/Utils/sync-action-utils.js +52 -0
- package/lib/cjs/Utils/sync-action-utils.js.map +1 -0
- package/lib/cjs/Utils/tc-token-utils.d.ts +12 -0
- package/lib/cjs/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/cjs/Utils/tc-token-utils.js +21 -0
- package/lib/cjs/Utils/tc-token-utils.js.map +1 -0
- package/lib/cjs/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/cjs/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/cjs/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/cjs/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/cjs/Utils/validate-connection.d.ts +11 -0
- package/lib/cjs/Utils/validate-connection.d.ts.map +1 -0
- package/lib/cjs/Utils/validate-connection.js +209 -0
- package/lib/cjs/Utils/validate-connection.js.map +1 -0
- package/lib/cjs/WABinary/constants.d.ts +28 -0
- package/lib/cjs/WABinary/constants.d.ts.map +1 -0
- package/lib/cjs/WABinary/constants.js +1304 -0
- package/lib/cjs/WABinary/constants.js.map +1 -0
- package/lib/cjs/WABinary/decode.d.ts +7 -0
- package/lib/cjs/WABinary/decode.d.ts.map +1 -0
- package/lib/cjs/WABinary/decode.js +301 -0
- package/lib/cjs/WABinary/decode.js.map +1 -0
- package/lib/cjs/WABinary/encode.d.ts +3 -0
- package/lib/cjs/WABinary/encode.d.ts.map +1 -0
- package/lib/cjs/WABinary/encode.js +257 -0
- package/lib/cjs/WABinary/encode.js.map +1 -0
- package/lib/cjs/WABinary/generic-utils.d.ts +15 -0
- package/lib/cjs/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/cjs/WABinary/generic-utils.js +125 -0
- package/lib/cjs/WABinary/generic-utils.js.map +1 -0
- package/lib/cjs/WABinary/index.d.ts +6 -0
- package/lib/cjs/WABinary/index.d.ts.map +1 -0
- package/lib/cjs/WABinary/index.js +22 -0
- package/lib/cjs/WABinary/index.js.map +1 -0
- package/lib/cjs/WABinary/jid-utils.d.ts +48 -0
- package/lib/cjs/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/cjs/WABinary/jid-utils.js +115 -0
- package/lib/cjs/WABinary/jid-utils.js.map +1 -0
- package/lib/cjs/WABinary/types.d.ts +19 -0
- package/lib/cjs/WABinary/types.d.ts.map +1 -0
- package/lib/cjs/WABinary/types.js +3 -0
- package/lib/cjs/WABinary/types.js.map +1 -0
- package/lib/cjs/WAM/BinaryInfo.d.ts +9 -0
- package/lib/cjs/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/cjs/WAM/BinaryInfo.js +14 -0
- package/lib/cjs/WAM/BinaryInfo.js.map +1 -0
- package/lib/cjs/WAM/constants.d.ts +40 -0
- package/lib/cjs/WAM/constants.d.ts.map +1 -0
- package/lib/cjs/WAM/constants.js +22856 -0
- package/lib/cjs/WAM/constants.js.map +1 -0
- package/lib/cjs/WAM/encode.d.ts +3 -0
- package/lib/cjs/WAM/encode.d.ts.map +1 -0
- package/lib/cjs/WAM/encode.js +153 -0
- package/lib/cjs/WAM/encode.js.map +1 -0
- package/lib/cjs/WAM/index.d.ts +4 -0
- package/lib/cjs/WAM/index.d.ts.map +1 -0
- package/lib/cjs/WAM/index.js +20 -0
- package/lib/cjs/WAM/index.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/cjs/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/cjs/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/cjs/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncDeviceProtocol.js +58 -0
- package/lib/cjs/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/cjs/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncDisappearingModeProtocol.js +31 -0
- package/lib/cjs/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/cjs/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/cjs/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/cjs/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/UsyncBotProfileProtocol.js +54 -0
- package/lib/cjs/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/UsyncLIDProtocol.d.ts +17 -0
- package/lib/cjs/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/UsyncLIDProtocol.js +33 -0
- package/lib/cjs/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/cjs/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/cjs/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/cjs/WAUSync/Protocols/index.js +21 -0
- package/lib/cjs/WAUSync/Protocols/index.js.map +1 -0
- package/lib/cjs/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/cjs/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/cjs/WAUSync/USyncQuery.js +97 -0
- package/lib/cjs/WAUSync/USyncQuery.js.map +1 -0
- package/lib/cjs/WAUSync/USyncUser.d.ts +13 -0
- package/lib/cjs/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/cjs/WAUSync/USyncUser.js +27 -0
- package/lib/cjs/WAUSync/USyncUser.js.map +1 -0
- package/lib/cjs/WAUSync/index.d.ts +4 -0
- package/lib/cjs/WAUSync/index.d.ts.map +1 -0
- package/lib/cjs/WAUSync/index.js +20 -0
- package/lib/cjs/WAUSync/index.js.map +1 -0
- package/lib/cjs/index.d.ts +12 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +31 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/esm/Defaults/index.d.ts +74 -0
- package/lib/esm/Defaults/index.d.ts.map +1 -0
- package/lib/esm/Defaults/index.js +128 -0
- package/lib/esm/Defaults/index.js.map +1 -0
- package/lib/esm/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/esm/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/esm/Signal/Group/ciphertext-message.js +12 -0
- package/lib/esm/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/esm/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/esm/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/esm/Signal/Group/group-session-builder.js +30 -0
- package/lib/esm/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/esm/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/esm/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/esm/Signal/Group/group_cipher.js +82 -0
- package/lib/esm/Signal/Group/group_cipher.js.map +1 -0
- package/lib/esm/Signal/Group/index.d.ts +12 -0
- package/lib/esm/Signal/Group/index.d.ts.map +1 -0
- package/lib/esm/Signal/Group/index.js +12 -0
- package/lib/esm/Signal/Group/index.js.map +1 -0
- package/lib/esm/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/esm/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/esm/Signal/Group/keyhelper.js +18 -0
- package/lib/esm/Signal/Group/keyhelper.js.map +1 -0
- package/lib/esm/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/esm/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-chain-key.js +26 -0
- package/lib/esm/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/esm/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/esm/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/esm/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/esm/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/esm/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-key-message.js +66 -0
- package/lib/esm/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/esm/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/esm/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-key-name.js +48 -0
- package/lib/esm/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/esm/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/esm/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-key-record.js +41 -0
- package/lib/esm/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/esm/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/esm/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-key-state.js +84 -0
- package/lib/esm/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/esm/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/esm/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/esm/Signal/Group/sender-message-key.js +26 -0
- package/lib/esm/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/esm/Signal/jid-mapping.d.ts +50 -0
- package/lib/esm/Signal/jid-mapping.d.ts.map +1 -0
- package/lib/esm/Signal/jid-mapping.js +214 -0
- package/lib/esm/Signal/jid-mapping.js.map +1 -0
- package/lib/esm/Signal/libsignal.d.ts +7 -0
- package/lib/esm/Signal/libsignal.d.ts.map +1 -0
- package/lib/esm/Signal/libsignal.js +413 -0
- package/lib/esm/Signal/libsignal.js.map +1 -0
- package/lib/esm/Signal/lid-mapping.d.ts +6 -0
- package/lib/esm/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/esm/Signal/lid-mapping.js +6 -0
- package/lib/esm/Signal/lid-mapping.js.map +1 -0
- package/lib/esm/Socket/Client/index.d.ts +3 -0
- package/lib/esm/Socket/Client/index.d.ts.map +1 -0
- package/lib/esm/Socket/Client/index.js +3 -0
- package/lib/esm/Socket/Client/index.js.map +1 -0
- package/lib/esm/Socket/Client/types.d.ts +16 -0
- package/lib/esm/Socket/Client/types.d.ts.map +1 -0
- package/lib/esm/Socket/Client/types.js +11 -0
- package/lib/esm/Socket/Client/types.js.map +1 -0
- package/lib/esm/Socket/Client/websocket.d.ts +13 -0
- package/lib/esm/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/esm/Socket/Client/websocket.js +54 -0
- package/lib/esm/Socket/Client/websocket.js.map +1 -0
- package/lib/esm/Socket/business.d.ts +202 -0
- package/lib/esm/Socket/business.d.ts.map +1 -0
- package/lib/esm/Socket/business.js +379 -0
- package/lib/esm/Socket/business.js.map +1 -0
- package/lib/esm/Socket/chats.d.ts +111 -0
- package/lib/esm/Socket/chats.d.ts.map +1 -0
- package/lib/esm/Socket/chats.js +999 -0
- package/lib/esm/Socket/chats.js.map +1 -0
- package/lib/esm/Socket/communities.d.ts +258 -0
- package/lib/esm/Socket/communities.d.ts.map +1 -0
- package/lib/esm/Socket/communities.js +431 -0
- package/lib/esm/Socket/communities.js.map +1 -0
- package/lib/esm/Socket/groups.d.ts +150 -0
- package/lib/esm/Socket/groups.d.ts.map +1 -0
- package/lib/esm/Socket/groups.js +330 -0
- package/lib/esm/Socket/groups.js.map +1 -0
- package/lib/esm/Socket/index.d.ts +245 -0
- package/lib/esm/Socket/index.d.ts.map +1 -0
- package/lib/esm/Socket/index.js +12 -0
- package/lib/esm/Socket/index.js.map +1 -0
- package/lib/esm/Socket/messages-recv.d.ts +187 -0
- package/lib/esm/Socket/messages-recv.d.ts.map +1 -0
- package/lib/esm/Socket/messages-recv.js +1319 -0
- package/lib/esm/Socket/messages-recv.js.map +1 -0
- package/lib/esm/Socket/messages-send.d.ts +183 -0
- package/lib/esm/Socket/messages-send.d.ts.map +1 -0
- package/lib/esm/Socket/messages-send.js +1039 -0
- package/lib/esm/Socket/messages-send.js.map +1 -0
- package/lib/esm/Socket/mex.d.ts +3 -0
- package/lib/esm/Socket/mex.d.ts.map +1 -0
- package/lib/esm/Socket/mex.js +42 -0
- package/lib/esm/Socket/mex.js.map +1 -0
- package/lib/esm/Socket/newsletter.d.ts +160 -0
- package/lib/esm/Socket/newsletter.d.ts.map +1 -0
- package/lib/esm/Socket/newsletter.js +181 -0
- package/lib/esm/Socket/newsletter.js.map +1 -0
- package/lib/esm/Socket/socket.d.ts +55 -0
- package/lib/esm/Socket/socket.d.ts.map +1 -0
- package/lib/esm/Socket/socket.js +936 -0
- package/lib/esm/Socket/socket.js.map +1 -0
- package/lib/esm/Types/Auth.d.ts +126 -0
- package/lib/esm/Types/Auth.d.ts.map +1 -0
- package/lib/esm/Types/Auth.js +2 -0
- package/lib/esm/Types/Auth.js.map +1 -0
- package/lib/esm/Types/Bussines.d.ts +25 -0
- package/lib/esm/Types/Bussines.d.ts.map +1 -0
- package/lib/esm/Types/Bussines.js +2 -0
- package/lib/esm/Types/Bussines.js.map +1 -0
- package/lib/esm/Types/Call.d.ts +15 -0
- package/lib/esm/Types/Call.d.ts.map +1 -0
- package/lib/esm/Types/Call.js +2 -0
- package/lib/esm/Types/Call.js.map +1 -0
- package/lib/esm/Types/Chat.d.ts +123 -0
- package/lib/esm/Types/Chat.d.ts.map +1 -0
- package/lib/esm/Types/Chat.js +8 -0
- package/lib/esm/Types/Chat.js.map +1 -0
- package/lib/esm/Types/Contact.d.ts +24 -0
- package/lib/esm/Types/Contact.d.ts.map +1 -0
- package/lib/esm/Types/Contact.js +2 -0
- package/lib/esm/Types/Contact.js.map +1 -0
- package/lib/esm/Types/Events.d.ts +241 -0
- package/lib/esm/Types/Events.d.ts.map +1 -0
- package/lib/esm/Types/Events.js +2 -0
- package/lib/esm/Types/Events.js.map +1 -0
- package/lib/esm/Types/GroupMetadata.d.ts +67 -0
- package/lib/esm/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/esm/Types/GroupMetadata.js +2 -0
- package/lib/esm/Types/GroupMetadata.js.map +1 -0
- package/lib/esm/Types/Label.d.ts +47 -0
- package/lib/esm/Types/Label.d.ts.map +1 -0
- package/lib/esm/Types/Label.js +25 -0
- package/lib/esm/Types/Label.js.map +1 -0
- package/lib/esm/Types/LabelAssociation.d.ts +30 -0
- package/lib/esm/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/esm/Types/LabelAssociation.js +7 -0
- package/lib/esm/Types/LabelAssociation.js.map +1 -0
- package/lib/esm/Types/Message.d.ts +310 -0
- package/lib/esm/Types/Message.d.ts.map +1 -0
- package/lib/esm/Types/Message.js +14 -0
- package/lib/esm/Types/Message.js.map +1 -0
- package/lib/esm/Types/Newsletter.d.ts +135 -0
- package/lib/esm/Types/Newsletter.d.ts.map +1 -0
- package/lib/esm/Types/Newsletter.js +31 -0
- package/lib/esm/Types/Newsletter.js.map +1 -0
- package/lib/esm/Types/Product.d.ts +79 -0
- package/lib/esm/Types/Product.d.ts.map +1 -0
- package/lib/esm/Types/Product.js +2 -0
- package/lib/esm/Types/Product.js.map +1 -0
- package/lib/esm/Types/Signal.d.ts +76 -0
- package/lib/esm/Types/Signal.d.ts.map +1 -0
- package/lib/esm/Types/Signal.js +2 -0
- package/lib/esm/Types/Signal.js.map +1 -0
- package/lib/esm/Types/Socket.d.ts +135 -0
- package/lib/esm/Types/Socket.d.ts.map +1 -0
- package/lib/esm/Types/Socket.js +3 -0
- package/lib/esm/Types/Socket.js.map +1 -0
- package/lib/esm/Types/State.d.ts +39 -0
- package/lib/esm/Types/State.d.ts.map +1 -0
- package/lib/esm/Types/State.js +13 -0
- package/lib/esm/Types/State.js.map +1 -0
- package/lib/esm/Types/USync.d.ts +26 -0
- package/lib/esm/Types/USync.d.ts.map +1 -0
- package/lib/esm/Types/USync.js +2 -0
- package/lib/esm/Types/USync.js.map +1 -0
- package/lib/esm/Types/index.d.ts +65 -0
- package/lib/esm/Types/index.d.ts.map +1 -0
- package/lib/esm/Types/index.js +26 -0
- package/lib/esm/Types/index.js.map +1 -0
- package/lib/esm/Utils/auth-utils.d.ts +19 -0
- package/lib/esm/Utils/auth-utils.d.ts.map +1 -0
- package/lib/esm/Utils/auth-utils.js +290 -0
- package/lib/esm/Utils/auth-utils.js.map +1 -0
- package/lib/esm/Utils/browser-utils.d.ts +4 -0
- package/lib/esm/Utils/browser-utils.d.ts.map +1 -0
- package/lib/esm/Utils/browser-utils.js +28 -0
- package/lib/esm/Utils/browser-utils.js.map +1 -0
- package/lib/esm/Utils/business.d.ts +23 -0
- package/lib/esm/Utils/business.d.ts.map +1 -0
- package/lib/esm/Utils/business.js +231 -0
- package/lib/esm/Utils/business.js.map +1 -0
- package/lib/esm/Utils/chat-utils.d.ts +70 -0
- package/lib/esm/Utils/chat-utils.d.ts.map +1 -0
- package/lib/esm/Utils/chat-utils.js +812 -0
- package/lib/esm/Utils/chat-utils.js.map +1 -0
- package/lib/esm/Utils/crypto.d.ts +37 -0
- package/lib/esm/Utils/crypto.d.ts.map +1 -0
- package/lib/esm/Utils/crypto.js +118 -0
- package/lib/esm/Utils/crypto.js.map +1 -0
- package/lib/esm/Utils/decode-wa-message.d.ts +48 -0
- package/lib/esm/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/esm/Utils/decode-wa-message.js +286 -0
- package/lib/esm/Utils/decode-wa-message.js.map +1 -0
- package/lib/esm/Utils/event-buffer.d.ts +34 -0
- package/lib/esm/Utils/event-buffer.d.ts.map +1 -0
- package/lib/esm/Utils/event-buffer.js +574 -0
- package/lib/esm/Utils/event-buffer.js.map +1 -0
- package/lib/esm/Utils/generics.d.ts +91 -0
- package/lib/esm/Utils/generics.d.ts.map +1 -0
- package/lib/esm/Utils/generics.js +384 -0
- package/lib/esm/Utils/generics.js.map +1 -0
- package/lib/esm/Utils/history.d.ts +22 -0
- package/lib/esm/Utils/history.d.ts.map +1 -0
- package/lib/esm/Utils/history.js +131 -0
- package/lib/esm/Utils/history.js.map +1 -0
- package/lib/esm/Utils/identity-change-handler.d.ts +38 -0
- package/lib/esm/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/esm/Utils/identity-change-handler.js +50 -0
- package/lib/esm/Utils/identity-change-handler.js.map +1 -0
- package/lib/esm/Utils/index.d.ts +21 -0
- package/lib/esm/Utils/index.d.ts.map +1 -0
- package/lib/esm/Utils/index.js +21 -0
- package/lib/esm/Utils/index.js.map +1 -0
- package/lib/esm/Utils/link-preview.d.ts +21 -0
- package/lib/esm/Utils/link-preview.d.ts.map +1 -0
- package/lib/esm/Utils/link-preview.js +85 -0
- package/lib/esm/Utils/link-preview.js.map +1 -0
- package/lib/esm/Utils/logger.d.ts +13 -0
- package/lib/esm/Utils/logger.d.ts.map +1 -0
- package/lib/esm/Utils/logger.js +3 -0
- package/lib/esm/Utils/logger.js.map +1 -0
- package/lib/esm/Utils/lt-hash.d.ts +8 -0
- package/lib/esm/Utils/lt-hash.d.ts.map +1 -0
- package/lib/esm/Utils/lt-hash.js +8 -0
- package/lib/esm/Utils/lt-hash.js.map +1 -0
- package/lib/esm/Utils/make-mutex.d.ts +9 -0
- package/lib/esm/Utils/make-mutex.d.ts.map +1 -0
- package/lib/esm/Utils/make-mutex.js +33 -0
- package/lib/esm/Utils/make-mutex.js.map +1 -0
- package/lib/esm/Utils/message-retry-manager.d.ts +110 -0
- package/lib/esm/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/esm/Utils/message-retry-manager.js +225 -0
- package/lib/esm/Utils/message-retry-manager.js.map +1 -0
- package/lib/esm/Utils/messages-media.d.ts +130 -0
- package/lib/esm/Utils/messages-media.d.ts.map +1 -0
- package/lib/esm/Utils/messages-media.js +774 -0
- package/lib/esm/Utils/messages-media.js.map +1 -0
- package/lib/esm/Utils/messages.d.ts +91 -0
- package/lib/esm/Utils/messages.d.ts.map +1 -0
- package/lib/esm/Utils/messages.js +878 -0
- package/lib/esm/Utils/messages.js.map +1 -0
- package/lib/esm/Utils/noise-handler.d.ts +20 -0
- package/lib/esm/Utils/noise-handler.d.ts.map +1 -0
- package/lib/esm/Utils/noise-handler.js +201 -0
- package/lib/esm/Utils/noise-handler.js.map +1 -0
- package/lib/esm/Utils/offline-node-processor.d.ts +17 -0
- package/lib/esm/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/esm/Utils/offline-node-processor.js +40 -0
- package/lib/esm/Utils/offline-node-processor.js.map +1 -0
- package/lib/esm/Utils/pre-key-manager.d.ts +28 -0
- package/lib/esm/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/esm/Utils/pre-key-manager.js +106 -0
- package/lib/esm/Utils/pre-key-manager.js.map +1 -0
- package/lib/esm/Utils/process-message.d.ts +60 -0
- package/lib/esm/Utils/process-message.d.ts.map +1 -0
- package/lib/esm/Utils/process-message.js +530 -0
- package/lib/esm/Utils/process-message.js.map +1 -0
- package/lib/esm/Utils/reporting-utils.d.ts +11 -0
- package/lib/esm/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/esm/Utils/reporting-utils.js +258 -0
- package/lib/esm/Utils/reporting-utils.js.map +1 -0
- package/lib/esm/Utils/signal.d.ts +34 -0
- package/lib/esm/Utils/signal.d.ts.map +1 -0
- package/lib/esm/Utils/signal.js +159 -0
- package/lib/esm/Utils/signal.js.map +1 -0
- package/lib/esm/Utils/stanza-ack.d.ts +11 -0
- package/lib/esm/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/esm/Utils/stanza-ack.js +38 -0
- package/lib/esm/Utils/stanza-ack.js.map +1 -0
- package/lib/esm/Utils/sync-action-utils.d.ts +19 -0
- package/lib/esm/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/esm/Utils/sync-action-utils.js +48 -0
- package/lib/esm/Utils/sync-action-utils.js.map +1 -0
- package/lib/esm/Utils/tc-token-utils.d.ts +12 -0
- package/lib/esm/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/esm/Utils/tc-token-utils.js +18 -0
- package/lib/esm/Utils/tc-token-utils.js.map +1 -0
- package/lib/esm/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/esm/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/esm/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/esm/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/esm/Utils/validate-connection.d.ts +11 -0
- package/lib/esm/Utils/validate-connection.d.ts.map +1 -0
- package/lib/esm/Utils/validate-connection.js +202 -0
- package/lib/esm/Utils/validate-connection.js.map +1 -0
- package/lib/esm/WABinary/constants.d.ts +28 -0
- package/lib/esm/WABinary/constants.d.ts.map +1 -0
- package/lib/esm/WABinary/constants.js +1301 -0
- package/lib/esm/WABinary/constants.js.map +1 -0
- package/lib/esm/WABinary/decode.d.ts +7 -0
- package/lib/esm/WABinary/decode.d.ts.map +1 -0
- package/lib/esm/WABinary/decode.js +262 -0
- package/lib/esm/WABinary/decode.js.map +1 -0
- package/lib/esm/WABinary/encode.d.ts +3 -0
- package/lib/esm/WABinary/encode.d.ts.map +1 -0
- package/lib/esm/WABinary/encode.js +220 -0
- package/lib/esm/WABinary/encode.js.map +1 -0
- package/lib/esm/WABinary/generic-utils.d.ts +15 -0
- package/lib/esm/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/esm/WABinary/generic-utils.js +113 -0
- package/lib/esm/WABinary/generic-utils.js.map +1 -0
- package/lib/esm/WABinary/index.d.ts +6 -0
- package/lib/esm/WABinary/index.d.ts.map +1 -0
- package/lib/esm/WABinary/index.js +6 -0
- package/lib/esm/WABinary/index.js.map +1 -0
- package/lib/esm/WABinary/jid-utils.d.ts +48 -0
- package/lib/esm/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/esm/WABinary/jid-utils.js +96 -0
- package/lib/esm/WABinary/jid-utils.js.map +1 -0
- package/lib/esm/WABinary/types.d.ts +19 -0
- package/lib/esm/WABinary/types.d.ts.map +1 -0
- package/lib/esm/WABinary/types.js +2 -0
- package/lib/esm/WABinary/types.js.map +1 -0
- package/lib/esm/WAM/BinaryInfo.d.ts +9 -0
- package/lib/esm/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/esm/WAM/BinaryInfo.js +10 -0
- package/lib/esm/WAM/BinaryInfo.js.map +1 -0
- package/lib/esm/WAM/constants.d.ts +40 -0
- package/lib/esm/WAM/constants.d.ts.map +1 -0
- package/lib/esm/WAM/constants.js +22853 -0
- package/lib/esm/WAM/constants.js.map +1 -0
- package/lib/esm/WAM/encode.d.ts +3 -0
- package/lib/esm/WAM/encode.d.ts.map +1 -0
- package/lib/esm/WAM/encode.js +150 -0
- package/lib/esm/WAM/encode.js.map +1 -0
- package/lib/esm/WAM/index.d.ts +4 -0
- package/lib/esm/WAM/index.d.ts.map +1 -0
- package/lib/esm/WAM/index.js +4 -0
- package/lib/esm/WAM/index.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/esm/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncContactProtocol.js +29 -0
- package/lib/esm/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/esm/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/esm/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/esm/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/esm/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/esm/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/esm/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/esm/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/esm/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/UsyncLIDProtocol.d.ts +17 -0
- package/lib/esm/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/esm/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/esm/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/esm/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/esm/WAUSync/Protocols/index.js +5 -0
- package/lib/esm/WAUSync/Protocols/index.js.map +1 -0
- package/lib/esm/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/esm/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/esm/WAUSync/USyncQuery.js +94 -0
- package/lib/esm/WAUSync/USyncQuery.js.map +1 -0
- package/lib/esm/WAUSync/USyncUser.d.ts +13 -0
- package/lib/esm/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/esm/WAUSync/USyncUser.js +23 -0
- package/lib/esm/WAUSync/USyncUser.js.map +1 -0
- package/lib/esm/WAUSync/index.d.ts +4 -0
- package/lib/esm/WAUSync/index.d.ts.map +1 -0
- package/lib/esm/WAUSync/index.js +4 -0
- package/lib/esm/WAUSync/index.js.map +1 -0
- package/lib/esm/index.d.ts +12 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +11 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/package.json +129 -0
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processSyncAction = exports.chatModificationToAppPatch = exports.decodePatches = exports.decodeSyncdSnapshot = exports.downloadExternalPatch = exports.downloadExternalBlob = exports.extractSyncdPatches = exports.decodeSyncdPatch = exports.decodeSyncdMutations = exports.encodeSyncdPatch = exports.newLTHashState = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const whatsapp_rust_bridge_1 = require("whatsapp-rust-bridge");
|
|
6
|
+
const index_js_1 = require("../../WAProto/index.js");
|
|
7
|
+
const LabelAssociation_1 = require("../Types/LabelAssociation");
|
|
8
|
+
const WABinary_1 = require("../WABinary");
|
|
9
|
+
const crypto_1 = require("./crypto");
|
|
10
|
+
const generics_1 = require("./generics");
|
|
11
|
+
const lt_hash_1 = require("./lt-hash");
|
|
12
|
+
const messages_media_1 = require("./messages-media");
|
|
13
|
+
const sync_action_utils_1 = require("./sync-action-utils");
|
|
14
|
+
const mutationKeys = (keydata) => {
|
|
15
|
+
const keys = (0, whatsapp_rust_bridge_1.expandAppStateKeys)(keydata);
|
|
16
|
+
return {
|
|
17
|
+
indexKey: keys.indexKey,
|
|
18
|
+
valueEncryptionKey: keys.valueEncryptionKey,
|
|
19
|
+
valueMacKey: keys.valueMacKey,
|
|
20
|
+
snapshotMacKey: keys.snapshotMacKey,
|
|
21
|
+
patchMacKey: keys.patchMacKey
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const generateMac = (operation, data, keyId, key) => {
|
|
25
|
+
const opByte = operation === index_js_1.proto.SyncdMutation.SyncdOperation.SET ? 0x01 : 0x02;
|
|
26
|
+
const keyIdBuffer = typeof keyId === 'string' ? Buffer.from(keyId, 'base64') : keyId;
|
|
27
|
+
const keyData = new Uint8Array(1 + keyIdBuffer.length);
|
|
28
|
+
keyData[0] = opByte;
|
|
29
|
+
keyData.set(keyIdBuffer, 1);
|
|
30
|
+
const last = new Uint8Array(8);
|
|
31
|
+
last[7] = keyData.length;
|
|
32
|
+
const total = new Uint8Array(keyData.length + data.length + last.length);
|
|
33
|
+
total.set(keyData, 0);
|
|
34
|
+
total.set(data, keyData.length);
|
|
35
|
+
total.set(last, keyData.length + data.length);
|
|
36
|
+
const hmac = (0, crypto_1.hmacSign)(total, key, 'sha512');
|
|
37
|
+
return hmac.subarray(0, 32);
|
|
38
|
+
};
|
|
39
|
+
const to64BitNetworkOrder = (e) => {
|
|
40
|
+
const buff = Buffer.alloc(8);
|
|
41
|
+
buff.writeUint32BE(e, 4);
|
|
42
|
+
return buff;
|
|
43
|
+
};
|
|
44
|
+
const makeLtHashGenerator = ({ indexValueMap, hash }) => {
|
|
45
|
+
indexValueMap = { ...indexValueMap };
|
|
46
|
+
const addBuffs = [];
|
|
47
|
+
const subBuffs = [];
|
|
48
|
+
return {
|
|
49
|
+
mix: ({ indexMac, valueMac, operation }) => {
|
|
50
|
+
const indexMacBase64 = Buffer.from(indexMac).toString('base64');
|
|
51
|
+
const prevOp = indexValueMap[indexMacBase64];
|
|
52
|
+
if (operation === index_js_1.proto.SyncdMutation.SyncdOperation.REMOVE) {
|
|
53
|
+
if (!prevOp) {
|
|
54
|
+
throw new boom_1.Boom('tried remove, but no previous op', { data: { indexMac, valueMac } });
|
|
55
|
+
}
|
|
56
|
+
// remove from index value mac, since this mutation is erased
|
|
57
|
+
delete indexValueMap[indexMacBase64];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
addBuffs.push(valueMac);
|
|
61
|
+
// add this index into the history map
|
|
62
|
+
indexValueMap[indexMacBase64] = { valueMac };
|
|
63
|
+
}
|
|
64
|
+
if (prevOp) {
|
|
65
|
+
subBuffs.push(prevOp.valueMac);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
finish: () => {
|
|
69
|
+
const result = lt_hash_1.LT_HASH_ANTI_TAMPERING.subtractThenAdd(hash, subBuffs, addBuffs);
|
|
70
|
+
return {
|
|
71
|
+
hash: Buffer.from(result),
|
|
72
|
+
indexValueMap
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const generateSnapshotMac = (lthash, version, name, key) => {
|
|
78
|
+
const total = Buffer.concat([lthash, to64BitNetworkOrder(version), Buffer.from(name, 'utf-8')]);
|
|
79
|
+
return (0, crypto_1.hmacSign)(total, key, 'sha256');
|
|
80
|
+
};
|
|
81
|
+
const generatePatchMac = (snapshotMac, valueMacs, version, type, key) => {
|
|
82
|
+
const total = Buffer.concat([snapshotMac, ...valueMacs, to64BitNetworkOrder(version), Buffer.from(type, 'utf-8')]);
|
|
83
|
+
return (0, crypto_1.hmacSign)(total, key);
|
|
84
|
+
};
|
|
85
|
+
const newLTHashState = () => ({ version: 0, hash: Buffer.alloc(128), indexValueMap: {} });
|
|
86
|
+
exports.newLTHashState = newLTHashState;
|
|
87
|
+
const encodeSyncdPatch = async ({ type, index, syncAction, apiVersion, operation }, myAppStateKeyId, state, getAppStateSyncKey) => {
|
|
88
|
+
const key = !!myAppStateKeyId ? await getAppStateSyncKey(myAppStateKeyId) : undefined;
|
|
89
|
+
if (!key) {
|
|
90
|
+
throw new boom_1.Boom(`myAppStateKey ("${myAppStateKeyId}") not present`, { statusCode: 404 });
|
|
91
|
+
}
|
|
92
|
+
const encKeyId = Buffer.from(myAppStateKeyId, 'base64');
|
|
93
|
+
state = { ...state, indexValueMap: { ...state.indexValueMap } };
|
|
94
|
+
const indexBuffer = Buffer.from(JSON.stringify(index));
|
|
95
|
+
const dataProto = index_js_1.proto.SyncActionData.fromObject({
|
|
96
|
+
index: indexBuffer,
|
|
97
|
+
value: syncAction,
|
|
98
|
+
padding: new Uint8Array(0),
|
|
99
|
+
version: apiVersion
|
|
100
|
+
});
|
|
101
|
+
const encoded = index_js_1.proto.SyncActionData.encode(dataProto).finish();
|
|
102
|
+
const keyValue = mutationKeys(key.keyData);
|
|
103
|
+
const encValue = (0, crypto_1.aesEncrypt)(encoded, keyValue.valueEncryptionKey);
|
|
104
|
+
const valueMac = generateMac(operation, encValue, encKeyId, keyValue.valueMacKey);
|
|
105
|
+
const indexMac = (0, crypto_1.hmacSign)(indexBuffer, keyValue.indexKey);
|
|
106
|
+
// update LT hash
|
|
107
|
+
const generator = makeLtHashGenerator(state);
|
|
108
|
+
generator.mix({ indexMac, valueMac, operation });
|
|
109
|
+
Object.assign(state, generator.finish());
|
|
110
|
+
state.version += 1;
|
|
111
|
+
const snapshotMac = generateSnapshotMac(state.hash, state.version, type, keyValue.snapshotMacKey);
|
|
112
|
+
const patch = {
|
|
113
|
+
patchMac: generatePatchMac(snapshotMac, [valueMac], state.version, type, keyValue.patchMacKey),
|
|
114
|
+
snapshotMac: snapshotMac,
|
|
115
|
+
keyId: { id: encKeyId },
|
|
116
|
+
mutations: [
|
|
117
|
+
{
|
|
118
|
+
operation: operation,
|
|
119
|
+
record: {
|
|
120
|
+
index: {
|
|
121
|
+
blob: indexMac
|
|
122
|
+
},
|
|
123
|
+
value: {
|
|
124
|
+
blob: Buffer.concat([encValue, valueMac])
|
|
125
|
+
},
|
|
126
|
+
keyId: { id: encKeyId }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
const base64Index = indexMac.toString('base64');
|
|
132
|
+
state.indexValueMap[base64Index] = { valueMac };
|
|
133
|
+
return { patch, state };
|
|
134
|
+
};
|
|
135
|
+
exports.encodeSyncdPatch = encodeSyncdPatch;
|
|
136
|
+
const decodeSyncdMutations = async (msgMutations, initialState, getAppStateSyncKey, onMutation, validateMacs) => {
|
|
137
|
+
const ltGenerator = makeLtHashGenerator(initialState);
|
|
138
|
+
const derivedKeyCache = new Map();
|
|
139
|
+
// indexKey used to HMAC sign record.index.blob
|
|
140
|
+
// valueEncryptionKey used to AES-256-CBC encrypt record.value.blob[0:-32]
|
|
141
|
+
// the remaining record.value.blob[0:-32] is the mac, it the HMAC sign of key.keyId + decoded proto data + length of bytes in keyId
|
|
142
|
+
for (const msgMutation of msgMutations) {
|
|
143
|
+
// if it's a syncdmutation, get the operation property
|
|
144
|
+
// otherwise, if it's only a record -- it'll be a SET mutation
|
|
145
|
+
const operation = 'operation' in msgMutation ? msgMutation.operation : index_js_1.proto.SyncdMutation.SyncdOperation.SET;
|
|
146
|
+
const record = 'record' in msgMutation && !!msgMutation.record ? msgMutation.record : msgMutation;
|
|
147
|
+
const key = await getKey(record.keyId.id);
|
|
148
|
+
const content = record.value.blob;
|
|
149
|
+
const encContent = content.subarray(0, -32);
|
|
150
|
+
const ogValueMac = content.subarray(-32);
|
|
151
|
+
if (validateMacs) {
|
|
152
|
+
const contentHmac = generateMac(operation, encContent, record.keyId.id, key.valueMacKey);
|
|
153
|
+
if (Buffer.compare(contentHmac, ogValueMac) !== 0) {
|
|
154
|
+
throw new boom_1.Boom('HMAC content verification failed');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const result = (0, crypto_1.aesDecrypt)(encContent, key.valueEncryptionKey);
|
|
158
|
+
const syncAction = index_js_1.proto.SyncActionData.decode(result);
|
|
159
|
+
if (validateMacs) {
|
|
160
|
+
const hmac = (0, crypto_1.hmacSign)(syncAction.index, key.indexKey);
|
|
161
|
+
if (Buffer.compare(hmac, record.index.blob) !== 0) {
|
|
162
|
+
throw new boom_1.Boom('HMAC index verification failed');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const indexStr = Buffer.from(syncAction.index).toString();
|
|
166
|
+
onMutation({ syncAction, index: JSON.parse(indexStr) });
|
|
167
|
+
ltGenerator.mix({
|
|
168
|
+
indexMac: record.index.blob,
|
|
169
|
+
valueMac: ogValueMac,
|
|
170
|
+
operation: operation
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return ltGenerator.finish();
|
|
174
|
+
async function getKey(keyId) {
|
|
175
|
+
const base64Key = Buffer.from(keyId).toString('base64');
|
|
176
|
+
const cached = derivedKeyCache.get(base64Key);
|
|
177
|
+
if (cached) {
|
|
178
|
+
return cached;
|
|
179
|
+
}
|
|
180
|
+
const keyEnc = await getAppStateSyncKey(base64Key);
|
|
181
|
+
if (!keyEnc) {
|
|
182
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`, {
|
|
183
|
+
statusCode: 404,
|
|
184
|
+
data: { msgMutations }
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const keys = mutationKeys(keyEnc.keyData);
|
|
188
|
+
derivedKeyCache.set(base64Key, keys);
|
|
189
|
+
return keys;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
exports.decodeSyncdMutations = decodeSyncdMutations;
|
|
193
|
+
const decodeSyncdPatch = async (msg, name, initialState, getAppStateSyncKey, onMutation, validateMacs) => {
|
|
194
|
+
if (validateMacs) {
|
|
195
|
+
const base64Key = Buffer.from(msg.keyId.id).toString('base64');
|
|
196
|
+
const mainKeyObj = await getAppStateSyncKey(base64Key);
|
|
197
|
+
if (!mainKeyObj) {
|
|
198
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode patch`, { statusCode: 404, data: { msg } });
|
|
199
|
+
}
|
|
200
|
+
const mainKey = mutationKeys(mainKeyObj.keyData);
|
|
201
|
+
const mutationmacs = msg.mutations.map(mutation => mutation.record.value.blob.slice(-32));
|
|
202
|
+
const patchMac = generatePatchMac(msg.snapshotMac, mutationmacs, (0, generics_1.toNumber)(msg.version.version), name, mainKey.patchMacKey);
|
|
203
|
+
if (Buffer.compare(patchMac, msg.patchMac) !== 0) {
|
|
204
|
+
throw new boom_1.Boom('Invalid patch mac');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const result = await (0, exports.decodeSyncdMutations)(msg.mutations, initialState, getAppStateSyncKey, onMutation, validateMacs);
|
|
208
|
+
return result;
|
|
209
|
+
};
|
|
210
|
+
exports.decodeSyncdPatch = decodeSyncdPatch;
|
|
211
|
+
const extractSyncdPatches = async (result, options) => {
|
|
212
|
+
const syncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'sync');
|
|
213
|
+
const collectionNodes = (0, WABinary_1.getBinaryNodeChildren)(syncNode, 'collection');
|
|
214
|
+
const final = {};
|
|
215
|
+
await Promise.all(collectionNodes.map(async (collectionNode) => {
|
|
216
|
+
const patchesNode = (0, WABinary_1.getBinaryNodeChild)(collectionNode, 'patches');
|
|
217
|
+
const patches = (0, WABinary_1.getBinaryNodeChildren)(patchesNode || collectionNode, 'patch');
|
|
218
|
+
const snapshotNode = (0, WABinary_1.getBinaryNodeChild)(collectionNode, 'snapshot');
|
|
219
|
+
const syncds = [];
|
|
220
|
+
const name = collectionNode.attrs.name;
|
|
221
|
+
const hasMorePatches = collectionNode.attrs.has_more_patches === 'true';
|
|
222
|
+
let snapshot = undefined;
|
|
223
|
+
if (snapshotNode && !!snapshotNode.content) {
|
|
224
|
+
if (!Buffer.isBuffer(snapshotNode)) {
|
|
225
|
+
snapshotNode.content = Buffer.from(Object.values(snapshotNode.content));
|
|
226
|
+
}
|
|
227
|
+
const blobRef = index_js_1.proto.ExternalBlobReference.decode(snapshotNode.content);
|
|
228
|
+
const data = await (0, exports.downloadExternalBlob)(blobRef, options);
|
|
229
|
+
snapshot = index_js_1.proto.SyncdSnapshot.decode(data);
|
|
230
|
+
}
|
|
231
|
+
for (let { content } of patches) {
|
|
232
|
+
if (content) {
|
|
233
|
+
if (!Buffer.isBuffer(content)) {
|
|
234
|
+
content = Buffer.from(Object.values(content));
|
|
235
|
+
}
|
|
236
|
+
const syncd = index_js_1.proto.SyncdPatch.decode(content);
|
|
237
|
+
if (!syncd.version) {
|
|
238
|
+
syncd.version = { version: +collectionNode.attrs.version + 1 };
|
|
239
|
+
}
|
|
240
|
+
syncds.push(syncd);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
final[name] = { patches: syncds, hasMorePatches, snapshot };
|
|
244
|
+
}));
|
|
245
|
+
return final;
|
|
246
|
+
};
|
|
247
|
+
exports.extractSyncdPatches = extractSyncdPatches;
|
|
248
|
+
const downloadExternalBlob = async (blob, options) => {
|
|
249
|
+
const stream = await (0, messages_media_1.downloadContentFromMessage)(blob, 'md-app-state', { options });
|
|
250
|
+
const bufferArray = [];
|
|
251
|
+
for await (const chunk of stream) {
|
|
252
|
+
bufferArray.push(chunk);
|
|
253
|
+
}
|
|
254
|
+
return Buffer.concat(bufferArray);
|
|
255
|
+
};
|
|
256
|
+
exports.downloadExternalBlob = downloadExternalBlob;
|
|
257
|
+
const downloadExternalPatch = async (blob, options) => {
|
|
258
|
+
const buffer = await (0, exports.downloadExternalBlob)(blob, options);
|
|
259
|
+
const syncData = index_js_1.proto.SyncdMutations.decode(buffer);
|
|
260
|
+
return syncData;
|
|
261
|
+
};
|
|
262
|
+
exports.downloadExternalPatch = downloadExternalPatch;
|
|
263
|
+
const decodeSyncdSnapshot = async (name, snapshot, getAppStateSyncKey, minimumVersionNumber, validateMacs = true) => {
|
|
264
|
+
const newState = (0, exports.newLTHashState)();
|
|
265
|
+
newState.version = (0, generics_1.toNumber)(snapshot.version.version);
|
|
266
|
+
const mutationMap = {};
|
|
267
|
+
const areMutationsRequired = typeof minimumVersionNumber === 'undefined' || newState.version > minimumVersionNumber;
|
|
268
|
+
const { hash, indexValueMap } = await (0, exports.decodeSyncdMutations)(snapshot.records, newState, getAppStateSyncKey, areMutationsRequired
|
|
269
|
+
? mutation => {
|
|
270
|
+
const index = mutation.syncAction.index?.toString();
|
|
271
|
+
mutationMap[index] = mutation;
|
|
272
|
+
}
|
|
273
|
+
: () => { }, validateMacs);
|
|
274
|
+
newState.hash = hash;
|
|
275
|
+
newState.indexValueMap = indexValueMap;
|
|
276
|
+
if (validateMacs) {
|
|
277
|
+
const base64Key = Buffer.from(snapshot.keyId.id).toString('base64');
|
|
278
|
+
const keyEnc = await getAppStateSyncKey(base64Key);
|
|
279
|
+
if (!keyEnc) {
|
|
280
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`);
|
|
281
|
+
}
|
|
282
|
+
const result = mutationKeys(keyEnc.keyData);
|
|
283
|
+
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey);
|
|
284
|
+
if (Buffer.compare(snapshot.mac, computedSnapshotMac) !== 0) {
|
|
285
|
+
throw new boom_1.Boom(`failed to verify LTHash at ${newState.version} of ${name} from snapshot`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
state: newState,
|
|
290
|
+
mutationMap
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
exports.decodeSyncdSnapshot = decodeSyncdSnapshot;
|
|
294
|
+
const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options, minimumVersionNumber, logger, validateMacs = true) => {
|
|
295
|
+
const newState = {
|
|
296
|
+
...initial,
|
|
297
|
+
indexValueMap: { ...initial.indexValueMap }
|
|
298
|
+
};
|
|
299
|
+
const mutationMap = {};
|
|
300
|
+
for (const syncd of syncds) {
|
|
301
|
+
const { version, keyId, snapshotMac } = syncd;
|
|
302
|
+
if (syncd.externalMutations) {
|
|
303
|
+
logger?.trace({ name, version }, 'downloading external patch');
|
|
304
|
+
const ref = await (0, exports.downloadExternalPatch)(syncd.externalMutations, options);
|
|
305
|
+
logger?.debug({ name, version, mutations: ref.mutations.length }, 'downloaded external patch');
|
|
306
|
+
syncd.mutations?.push(...ref.mutations);
|
|
307
|
+
}
|
|
308
|
+
const patchVersion = (0, generics_1.toNumber)(version.version);
|
|
309
|
+
newState.version = patchVersion;
|
|
310
|
+
const shouldMutate = typeof minimumVersionNumber === 'undefined' || patchVersion > minimumVersionNumber;
|
|
311
|
+
const decodeResult = await (0, exports.decodeSyncdPatch)(syncd, name, newState, getAppStateSyncKey, shouldMutate
|
|
312
|
+
? mutation => {
|
|
313
|
+
const index = mutation.syncAction.index?.toString();
|
|
314
|
+
mutationMap[index] = mutation;
|
|
315
|
+
}
|
|
316
|
+
: () => { }, true);
|
|
317
|
+
newState.hash = decodeResult.hash;
|
|
318
|
+
newState.indexValueMap = decodeResult.indexValueMap;
|
|
319
|
+
if (validateMacs) {
|
|
320
|
+
const base64Key = Buffer.from(keyId.id).toString('base64');
|
|
321
|
+
const keyEnc = await getAppStateSyncKey(base64Key);
|
|
322
|
+
if (!keyEnc) {
|
|
323
|
+
throw new boom_1.Boom(`failed to find key "${base64Key}" to decode mutation`);
|
|
324
|
+
}
|
|
325
|
+
const result = mutationKeys(keyEnc.keyData);
|
|
326
|
+
const computedSnapshotMac = generateSnapshotMac(newState.hash, newState.version, name, result.snapshotMacKey);
|
|
327
|
+
if (Buffer.compare(snapshotMac, computedSnapshotMac) !== 0) {
|
|
328
|
+
throw new boom_1.Boom(`failed to verify LTHash at ${newState.version} of ${name}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// clear memory used up by the mutations
|
|
332
|
+
syncd.mutations = [];
|
|
333
|
+
}
|
|
334
|
+
return { state: newState, mutationMap };
|
|
335
|
+
};
|
|
336
|
+
exports.decodePatches = decodePatches;
|
|
337
|
+
const chatModificationToAppPatch = (mod, jid) => {
|
|
338
|
+
const OP = index_js_1.proto.SyncdMutation.SyncdOperation;
|
|
339
|
+
const getMessageRange = (lastMessages) => {
|
|
340
|
+
let messageRange;
|
|
341
|
+
if (Array.isArray(lastMessages)) {
|
|
342
|
+
const lastMsg = lastMessages[lastMessages.length - 1];
|
|
343
|
+
messageRange = {
|
|
344
|
+
lastMessageTimestamp: lastMsg?.messageTimestamp,
|
|
345
|
+
messages: lastMessages?.length
|
|
346
|
+
? lastMessages.map(m => {
|
|
347
|
+
if (!m.key?.id || !m.key?.remoteJid) {
|
|
348
|
+
throw new boom_1.Boom('Incomplete key', { statusCode: 400, data: m });
|
|
349
|
+
}
|
|
350
|
+
if ((0, WABinary_1.isJidGroup)(m.key.remoteJid) && !m.key.fromMe && !m.key.participant) {
|
|
351
|
+
throw new boom_1.Boom('Expected not from me message to have participant', { statusCode: 400, data: m });
|
|
352
|
+
}
|
|
353
|
+
if (!m.messageTimestamp || !(0, generics_1.toNumber)(m.messageTimestamp)) {
|
|
354
|
+
throw new boom_1.Boom('Missing timestamp in last message list', { statusCode: 400, data: m });
|
|
355
|
+
}
|
|
356
|
+
if (m.key.participant) {
|
|
357
|
+
m.key.participant = (0, WABinary_1.jidNormalizedUser)(m.key.participant);
|
|
358
|
+
}
|
|
359
|
+
return m;
|
|
360
|
+
})
|
|
361
|
+
: undefined
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
messageRange = lastMessages;
|
|
366
|
+
}
|
|
367
|
+
return messageRange;
|
|
368
|
+
};
|
|
369
|
+
let patch;
|
|
370
|
+
if ('mute' in mod) {
|
|
371
|
+
patch = {
|
|
372
|
+
syncAction: {
|
|
373
|
+
muteAction: {
|
|
374
|
+
muted: !!mod.mute,
|
|
375
|
+
muteEndTimestamp: mod.mute || undefined
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
index: ['mute', jid],
|
|
379
|
+
type: 'regular_high',
|
|
380
|
+
apiVersion: 2,
|
|
381
|
+
operation: OP.SET
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
else if ('archive' in mod) {
|
|
385
|
+
patch = {
|
|
386
|
+
syncAction: {
|
|
387
|
+
archiveChatAction: {
|
|
388
|
+
archived: !!mod.archive,
|
|
389
|
+
messageRange: getMessageRange(mod.lastMessages)
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
index: ['archive', jid],
|
|
393
|
+
type: 'regular_low',
|
|
394
|
+
apiVersion: 3,
|
|
395
|
+
operation: OP.SET
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
else if ('markRead' in mod) {
|
|
399
|
+
patch = {
|
|
400
|
+
syncAction: {
|
|
401
|
+
markChatAsReadAction: {
|
|
402
|
+
read: mod.markRead,
|
|
403
|
+
messageRange: getMessageRange(mod.lastMessages)
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
index: ['markChatAsRead', jid],
|
|
407
|
+
type: 'regular_low',
|
|
408
|
+
apiVersion: 3,
|
|
409
|
+
operation: OP.SET
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
else if ('deleteForMe' in mod) {
|
|
413
|
+
const { timestamp, key, deleteMedia } = mod.deleteForMe;
|
|
414
|
+
patch = {
|
|
415
|
+
syncAction: {
|
|
416
|
+
deleteMessageForMeAction: {
|
|
417
|
+
deleteMedia,
|
|
418
|
+
messageTimestamp: timestamp
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
|
422
|
+
type: 'regular_high',
|
|
423
|
+
apiVersion: 3,
|
|
424
|
+
operation: OP.SET
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
else if ('clear' in mod) {
|
|
428
|
+
patch = {
|
|
429
|
+
syncAction: {
|
|
430
|
+
clearChatAction: {
|
|
431
|
+
messageRange: getMessageRange(mod.lastMessages)
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
index: ['clearChat', jid, '1' /*the option here is 0 when keep starred messages is enabled*/, '0'],
|
|
435
|
+
type: 'regular_high',
|
|
436
|
+
apiVersion: 6,
|
|
437
|
+
operation: OP.SET
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
else if ('pin' in mod) {
|
|
441
|
+
patch = {
|
|
442
|
+
syncAction: {
|
|
443
|
+
pinAction: {
|
|
444
|
+
pinned: !!mod.pin
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
index: ['pin_v1', jid],
|
|
448
|
+
type: 'regular_low',
|
|
449
|
+
apiVersion: 5,
|
|
450
|
+
operation: OP.SET
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
else if ('contact' in mod) {
|
|
454
|
+
patch = {
|
|
455
|
+
syncAction: {
|
|
456
|
+
contactAction: mod.contact || {}
|
|
457
|
+
},
|
|
458
|
+
index: ['contact', jid],
|
|
459
|
+
type: 'critical_unblock_low',
|
|
460
|
+
apiVersion: 2,
|
|
461
|
+
operation: mod.contact ? OP.SET : OP.REMOVE
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
else if ('disableLinkPreviews' in mod) {
|
|
465
|
+
patch = {
|
|
466
|
+
syncAction: {
|
|
467
|
+
privacySettingDisableLinkPreviewsAction: mod.disableLinkPreviews || {}
|
|
468
|
+
},
|
|
469
|
+
index: ['setting_disableLinkPreviews'],
|
|
470
|
+
type: 'regular',
|
|
471
|
+
apiVersion: 8,
|
|
472
|
+
operation: OP.SET
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
else if ('star' in mod) {
|
|
476
|
+
const key = mod.star.messages[0];
|
|
477
|
+
patch = {
|
|
478
|
+
syncAction: {
|
|
479
|
+
starAction: {
|
|
480
|
+
starred: !!mod.star.star
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
index: ['star', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
|
484
|
+
type: 'regular_low',
|
|
485
|
+
apiVersion: 2,
|
|
486
|
+
operation: OP.SET
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
else if ('delete' in mod) {
|
|
490
|
+
patch = {
|
|
491
|
+
syncAction: {
|
|
492
|
+
deleteChatAction: {
|
|
493
|
+
messageRange: getMessageRange(mod.lastMessages)
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
index: ['deleteChat', jid, '1'],
|
|
497
|
+
type: 'regular_high',
|
|
498
|
+
apiVersion: 6,
|
|
499
|
+
operation: OP.SET
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
else if ('pushNameSetting' in mod) {
|
|
503
|
+
patch = {
|
|
504
|
+
syncAction: {
|
|
505
|
+
pushNameSetting: {
|
|
506
|
+
name: mod.pushNameSetting
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
index: ['setting_pushName'],
|
|
510
|
+
type: 'critical_block',
|
|
511
|
+
apiVersion: 1,
|
|
512
|
+
operation: OP.SET
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
else if ('quickReply' in mod) {
|
|
516
|
+
patch = {
|
|
517
|
+
syncAction: {
|
|
518
|
+
quickReplyAction: {
|
|
519
|
+
count: 0,
|
|
520
|
+
deleted: mod.quickReply.deleted || false,
|
|
521
|
+
keywords: [],
|
|
522
|
+
message: mod.quickReply.message || '',
|
|
523
|
+
shortcut: mod.quickReply.shortcut || ''
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
index: ['quick_reply', mod.quickReply.timestamp || String(Math.floor(Date.now() / 1000))],
|
|
527
|
+
type: 'regular',
|
|
528
|
+
apiVersion: 2,
|
|
529
|
+
operation: OP.SET
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
else if ('addLabel' in mod) {
|
|
533
|
+
patch = {
|
|
534
|
+
syncAction: {
|
|
535
|
+
labelEditAction: {
|
|
536
|
+
name: mod.addLabel.name,
|
|
537
|
+
color: mod.addLabel.color,
|
|
538
|
+
predefinedId: mod.addLabel.predefinedId,
|
|
539
|
+
deleted: mod.addLabel.deleted
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
index: ['label_edit', mod.addLabel.id],
|
|
543
|
+
type: 'regular',
|
|
544
|
+
apiVersion: 3,
|
|
545
|
+
operation: OP.SET
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
else if ('addChatLabel' in mod) {
|
|
549
|
+
patch = {
|
|
550
|
+
syncAction: {
|
|
551
|
+
labelAssociationAction: {
|
|
552
|
+
labeled: true
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
index: [LabelAssociation_1.LabelAssociationType.Chat, mod.addChatLabel.labelId, jid],
|
|
556
|
+
type: 'regular',
|
|
557
|
+
apiVersion: 3,
|
|
558
|
+
operation: OP.SET
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
else if ('removeChatLabel' in mod) {
|
|
562
|
+
patch = {
|
|
563
|
+
syncAction: {
|
|
564
|
+
labelAssociationAction: {
|
|
565
|
+
labeled: false
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
index: [LabelAssociation_1.LabelAssociationType.Chat, mod.removeChatLabel.labelId, jid],
|
|
569
|
+
type: 'regular',
|
|
570
|
+
apiVersion: 3,
|
|
571
|
+
operation: OP.SET
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
else if ('addMessageLabel' in mod) {
|
|
575
|
+
patch = {
|
|
576
|
+
syncAction: {
|
|
577
|
+
labelAssociationAction: {
|
|
578
|
+
labeled: true
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
index: [LabelAssociation_1.LabelAssociationType.Message, mod.addMessageLabel.labelId, jid, mod.addMessageLabel.messageId, '0', '0'],
|
|
582
|
+
type: 'regular',
|
|
583
|
+
apiVersion: 3,
|
|
584
|
+
operation: OP.SET
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
else if ('removeMessageLabel' in mod) {
|
|
588
|
+
patch = {
|
|
589
|
+
syncAction: {
|
|
590
|
+
labelAssociationAction: {
|
|
591
|
+
labeled: false
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
index: [
|
|
595
|
+
LabelAssociation_1.LabelAssociationType.Message,
|
|
596
|
+
mod.removeMessageLabel.labelId,
|
|
597
|
+
jid,
|
|
598
|
+
mod.removeMessageLabel.messageId,
|
|
599
|
+
'0',
|
|
600
|
+
'0'
|
|
601
|
+
],
|
|
602
|
+
type: 'regular',
|
|
603
|
+
apiVersion: 3,
|
|
604
|
+
operation: OP.SET
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
throw new boom_1.Boom('not supported');
|
|
609
|
+
}
|
|
610
|
+
patch.syncAction.timestamp = Date.now();
|
|
611
|
+
return patch;
|
|
612
|
+
};
|
|
613
|
+
exports.chatModificationToAppPatch = chatModificationToAppPatch;
|
|
614
|
+
const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) => {
|
|
615
|
+
const isInitialSync = !!initialSyncOpts;
|
|
616
|
+
const accountSettings = initialSyncOpts?.accountSettings;
|
|
617
|
+
logger?.trace({ syncAction, initialSync: !!initialSyncOpts }, 'processing sync action');
|
|
618
|
+
const { syncAction: { value: action }, index: [type, id, msgId, fromMe] } = syncAction;
|
|
619
|
+
if (action?.muteAction) {
|
|
620
|
+
ev.emit('chats.update', [
|
|
621
|
+
{
|
|
622
|
+
id,
|
|
623
|
+
muteEndTime: action.muteAction?.muted ? (0, generics_1.toNumber)(action.muteAction.muteEndTimestamp) : null,
|
|
624
|
+
conditional: getChatUpdateConditional(id, undefined)
|
|
625
|
+
}
|
|
626
|
+
]);
|
|
627
|
+
}
|
|
628
|
+
else if (action?.archiveChatAction || type === 'archive' || type === 'unarchive') {
|
|
629
|
+
// okay so we've to do some annoying computation here
|
|
630
|
+
// when we're initially syncing the app state
|
|
631
|
+
// there are a few cases we need to handle
|
|
632
|
+
// 1. if the account unarchiveChats setting is true
|
|
633
|
+
// a. if the chat is archived, and no further messages have been received -- simple, keep archived
|
|
634
|
+
// b. if the chat was archived, and the user received messages from the other person afterwards
|
|
635
|
+
// then the chat should be marked unarchved --
|
|
636
|
+
// we compare the timestamp of latest message from the other person to determine this
|
|
637
|
+
// 2. if the account unarchiveChats setting is false -- then it doesn't matter,
|
|
638
|
+
// it'll always take an app state action to mark in unarchived -- which we'll get anyway
|
|
639
|
+
const archiveAction = action?.archiveChatAction;
|
|
640
|
+
const isArchived = archiveAction ? archiveAction.archived : type === 'archive';
|
|
641
|
+
// // basically we don't need to fire an "archive" update if the chat is being marked unarchvied
|
|
642
|
+
// // this only applies for the initial sync
|
|
643
|
+
// if(isInitialSync && !isArchived) {
|
|
644
|
+
// isArchived = false
|
|
645
|
+
// }
|
|
646
|
+
const msgRange = !accountSettings?.unarchiveChats ? undefined : archiveAction?.messageRange;
|
|
647
|
+
// logger?.debug({ chat: id, syncAction }, 'message range archive')
|
|
648
|
+
ev.emit('chats.update', [
|
|
649
|
+
{
|
|
650
|
+
id,
|
|
651
|
+
archived: isArchived,
|
|
652
|
+
conditional: getChatUpdateConditional(id, msgRange)
|
|
653
|
+
}
|
|
654
|
+
]);
|
|
655
|
+
}
|
|
656
|
+
else if (action?.markChatAsReadAction) {
|
|
657
|
+
const markReadAction = action.markChatAsReadAction;
|
|
658
|
+
// basically we don't need to fire an "read" update if the chat is being marked as read
|
|
659
|
+
// because the chat is read by default
|
|
660
|
+
// this only applies for the initial sync
|
|
661
|
+
const isNullUpdate = isInitialSync && markReadAction.read;
|
|
662
|
+
ev.emit('chats.update', [
|
|
663
|
+
{
|
|
664
|
+
id,
|
|
665
|
+
unreadCount: isNullUpdate ? null : !!markReadAction?.read ? 0 : -1,
|
|
666
|
+
conditional: getChatUpdateConditional(id, markReadAction?.messageRange)
|
|
667
|
+
}
|
|
668
|
+
]);
|
|
669
|
+
}
|
|
670
|
+
else if (action?.deleteMessageForMeAction || type === 'deleteMessageForMe') {
|
|
671
|
+
ev.emit('messages.delete', {
|
|
672
|
+
keys: [
|
|
673
|
+
{
|
|
674
|
+
remoteJid: id,
|
|
675
|
+
id: msgId,
|
|
676
|
+
fromMe: fromMe === '1'
|
|
677
|
+
}
|
|
678
|
+
]
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
else if (action?.contactAction) {
|
|
682
|
+
const results = (0, sync_action_utils_1.processContactAction)(action.contactAction, id, logger);
|
|
683
|
+
(0, sync_action_utils_1.emitSyncActionResults)(ev, results);
|
|
684
|
+
}
|
|
685
|
+
else if (action?.pushNameSetting) {
|
|
686
|
+
const name = action?.pushNameSetting?.name;
|
|
687
|
+
if (name && me?.name !== name) {
|
|
688
|
+
ev.emit('creds.update', { me: { ...me, name } });
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
else if (action?.pinAction) {
|
|
692
|
+
ev.emit('chats.update', [
|
|
693
|
+
{
|
|
694
|
+
id,
|
|
695
|
+
pinned: action.pinAction?.pinned ? (0, generics_1.toNumber)(action.timestamp) : null,
|
|
696
|
+
conditional: getChatUpdateConditional(id, undefined)
|
|
697
|
+
}
|
|
698
|
+
]);
|
|
699
|
+
}
|
|
700
|
+
else if (action?.unarchiveChatsSetting) {
|
|
701
|
+
const unarchiveChats = !!action.unarchiveChatsSetting.unarchiveChats;
|
|
702
|
+
ev.emit('creds.update', { accountSettings: { unarchiveChats } });
|
|
703
|
+
logger?.info(`archive setting updated => '${action.unarchiveChatsSetting.unarchiveChats}'`);
|
|
704
|
+
if (accountSettings) {
|
|
705
|
+
accountSettings.unarchiveChats = unarchiveChats;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
else if (action?.starAction || type === 'star') {
|
|
709
|
+
let starred = action?.starAction?.starred;
|
|
710
|
+
if (typeof starred !== 'boolean') {
|
|
711
|
+
starred = syncAction.index[syncAction.index.length - 1] === '1';
|
|
712
|
+
}
|
|
713
|
+
ev.emit('messages.update', [
|
|
714
|
+
{
|
|
715
|
+
key: { remoteJid: id, id: msgId, fromMe: fromMe === '1' },
|
|
716
|
+
update: { starred }
|
|
717
|
+
}
|
|
718
|
+
]);
|
|
719
|
+
}
|
|
720
|
+
else if (action?.deleteChatAction || type === 'deleteChat') {
|
|
721
|
+
if (!isInitialSync) {
|
|
722
|
+
ev.emit('chats.delete', [id]);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
else if (action?.labelEditAction) {
|
|
726
|
+
const { name, color, deleted, predefinedId } = action.labelEditAction;
|
|
727
|
+
ev.emit('labels.edit', {
|
|
728
|
+
id: id,
|
|
729
|
+
name: name,
|
|
730
|
+
color: color,
|
|
731
|
+
deleted: deleted,
|
|
732
|
+
predefinedId: predefinedId ? String(predefinedId) : undefined
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
else if (action?.labelAssociationAction) {
|
|
736
|
+
ev.emit('labels.association', {
|
|
737
|
+
type: action.labelAssociationAction.labeled ? 'add' : 'remove',
|
|
738
|
+
association: type === LabelAssociation_1.LabelAssociationType.Chat
|
|
739
|
+
? {
|
|
740
|
+
type: LabelAssociation_1.LabelAssociationType.Chat,
|
|
741
|
+
chatId: syncAction.index[2],
|
|
742
|
+
labelId: syncAction.index[1]
|
|
743
|
+
}
|
|
744
|
+
: {
|
|
745
|
+
type: LabelAssociation_1.LabelAssociationType.Message,
|
|
746
|
+
chatId: syncAction.index[2],
|
|
747
|
+
messageId: syncAction.index[3],
|
|
748
|
+
labelId: syncAction.index[1]
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
else if (action?.localeSetting?.locale) {
|
|
753
|
+
ev.emit('settings.update', { setting: 'locale', value: action.localeSetting.locale });
|
|
754
|
+
}
|
|
755
|
+
else if (action?.timeFormatAction) {
|
|
756
|
+
ev.emit('settings.update', { setting: 'timeFormat', value: action.timeFormatAction });
|
|
757
|
+
}
|
|
758
|
+
else if (action?.pnForLidChatAction) {
|
|
759
|
+
if (action.pnForLidChatAction.pnJid) {
|
|
760
|
+
ev.emit('lid-mapping.update', { jid: id, pn: action.pnForLidChatAction.pnJid });
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
else if (action?.privacySettingRelayAllCalls) {
|
|
764
|
+
ev.emit('settings.update', {
|
|
765
|
+
setting: 'privacySettingRelayAllCalls',
|
|
766
|
+
value: action.privacySettingRelayAllCalls
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
else if (action?.statusPrivacy) {
|
|
770
|
+
ev.emit('settings.update', { setting: 'statusPrivacy', value: action.statusPrivacy });
|
|
771
|
+
}
|
|
772
|
+
else if (action?.lockChatAction) {
|
|
773
|
+
ev.emit('chats.lock', { id: id, locked: !!action.lockChatAction.locked });
|
|
774
|
+
}
|
|
775
|
+
else if (action?.privacySettingDisableLinkPreviewsAction) {
|
|
776
|
+
ev.emit('settings.update', {
|
|
777
|
+
setting: 'disableLinkPreviews',
|
|
778
|
+
value: action.privacySettingDisableLinkPreviewsAction
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
else if (action?.notificationActivitySettingAction?.notificationActivitySetting) {
|
|
782
|
+
ev.emit('settings.update', {
|
|
783
|
+
setting: 'notificationActivitySetting',
|
|
784
|
+
value: action.notificationActivitySettingAction.notificationActivitySetting
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
else if (action?.lidContactAction) {
|
|
788
|
+
ev.emit('contacts.upsert', [
|
|
789
|
+
{
|
|
790
|
+
id: id,
|
|
791
|
+
name: action.lidContactAction.fullName ||
|
|
792
|
+
action.lidContactAction.firstName ||
|
|
793
|
+
action.lidContactAction.username ||
|
|
794
|
+
undefined,
|
|
795
|
+
lid: id,
|
|
796
|
+
phoneNumber: undefined
|
|
797
|
+
}
|
|
798
|
+
]);
|
|
799
|
+
}
|
|
800
|
+
else if (action?.privacySettingChannelsPersonalisedRecommendationAction) {
|
|
801
|
+
ev.emit('settings.update', {
|
|
802
|
+
setting: 'channelsPersonalisedRecommendation',
|
|
803
|
+
value: action.privacySettingChannelsPersonalisedRecommendationAction
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
logger?.debug({ syncAction, id }, 'unprocessable update');
|
|
808
|
+
}
|
|
809
|
+
function getChatUpdateConditional(id, msgRange) {
|
|
810
|
+
return isInitialSync
|
|
811
|
+
? data => {
|
|
812
|
+
const chat = data.historySets.chats[id] || data.chatUpserts[id];
|
|
813
|
+
if (chat) {
|
|
814
|
+
return msgRange ? isValidPatchBasedOnMessageRange(chat, msgRange) : true;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
: undefined;
|
|
818
|
+
}
|
|
819
|
+
function isValidPatchBasedOnMessageRange(chat, msgRange) {
|
|
820
|
+
const lastMsgTimestamp = Number(msgRange?.lastMessageTimestamp || msgRange?.lastSystemMessageTimestamp || 0);
|
|
821
|
+
const chatLastMsgTimestamp = Number(chat?.lastMessageRecvTimestamp || 0);
|
|
822
|
+
return lastMsgTimestamp >= chatLastMsgTimestamp;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
exports.processSyncAction = processSyncAction;
|
|
826
|
+
//# sourceMappingURL=chat-utils.js.map
|