@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,878 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import {} from 'stream';
|
|
5
|
+
import { proto } from '../../WAProto/index.js';
|
|
6
|
+
import { CALL_AUDIO_PREFIX, CALL_VIDEO_PREFIX, MEDIA_KEYS, URL_REGEX, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
|
|
7
|
+
import { WAMessageStatus, WAProto } from '../Types/index.js';
|
|
8
|
+
import { isJidGroup, isJidNewsletter, isJidStatusBroadcast, jidNormalizedUser } from '../WABinary/index.js';
|
|
9
|
+
import { sha256 } from './crypto.js';
|
|
10
|
+
import { generateMessageIDV2, getKeyAuthor, unixTimestampSeconds } from './generics.js';
|
|
11
|
+
import { downloadContentFromMessage, encryptedStream, generateThumbnail, getAudioDuration, getAudioWaveform, getRawMediaUploadData } from './messages-media.js';
|
|
12
|
+
import { shouldIncludeReportingToken } from './reporting-utils.js';
|
|
13
|
+
const MIMETYPE_MAP = {
|
|
14
|
+
image: 'image/jpeg',
|
|
15
|
+
video: 'video/mp4',
|
|
16
|
+
document: 'application/pdf',
|
|
17
|
+
audio: 'audio/ogg; codecs=opus',
|
|
18
|
+
sticker: 'image/webp',
|
|
19
|
+
'product-catalog-image': 'image/jpeg'
|
|
20
|
+
};
|
|
21
|
+
const MessageTypeProto = {
|
|
22
|
+
image: WAProto.Message.ImageMessage,
|
|
23
|
+
video: WAProto.Message.VideoMessage,
|
|
24
|
+
audio: WAProto.Message.AudioMessage,
|
|
25
|
+
sticker: WAProto.Message.StickerMessage,
|
|
26
|
+
document: WAProto.Message.DocumentMessage
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Uses a regex to test whether the string contains a URL, and returns the URL if it does.
|
|
30
|
+
* @param text eg. hello https://google.com
|
|
31
|
+
* @returns the URL, eg. https://google.com
|
|
32
|
+
*/
|
|
33
|
+
export const extractUrlFromText = (text) => text.match(URL_REGEX)?.[0];
|
|
34
|
+
export const generateLinkPreviewIfRequired = async (text, getUrlInfo, logger) => {
|
|
35
|
+
const url = extractUrlFromText(text);
|
|
36
|
+
if (!!getUrlInfo && url) {
|
|
37
|
+
try {
|
|
38
|
+
const urlInfo = await getUrlInfo(url);
|
|
39
|
+
return urlInfo;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
// ignore if fails
|
|
43
|
+
logger?.warn({ trace: error.stack }, 'url generation failed');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const assertColor = async (color) => {
|
|
48
|
+
let assertedColor;
|
|
49
|
+
if (typeof color === 'number') {
|
|
50
|
+
assertedColor = color > 0 ? color : 0xffffffff + Number(color) + 1;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
let hex = color.trim().replace('#', '');
|
|
54
|
+
if (hex.length <= 6) {
|
|
55
|
+
hex = 'FF' + hex.padStart(6, '0');
|
|
56
|
+
}
|
|
57
|
+
assertedColor = parseInt(hex, 16);
|
|
58
|
+
return assertedColor;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export const prepareWAMessageMedia = async (message, options) => {
|
|
62
|
+
const logger = options.logger;
|
|
63
|
+
let mediaType;
|
|
64
|
+
for (const key of MEDIA_KEYS) {
|
|
65
|
+
if (key in message) {
|
|
66
|
+
mediaType = key;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!mediaType) {
|
|
70
|
+
throw new Boom('Invalid media type', { statusCode: 400 });
|
|
71
|
+
}
|
|
72
|
+
const uploadData = {
|
|
73
|
+
...message,
|
|
74
|
+
media: message[mediaType]
|
|
75
|
+
};
|
|
76
|
+
delete uploadData[mediaType];
|
|
77
|
+
// check if cacheable + generate cache key
|
|
78
|
+
const cacheableKey = typeof uploadData.media === 'object' &&
|
|
79
|
+
'url' in uploadData.media &&
|
|
80
|
+
!!uploadData.media.url &&
|
|
81
|
+
!!options.mediaCache &&
|
|
82
|
+
mediaType + ':' + uploadData.media.url.toString();
|
|
83
|
+
if (mediaType === 'document' && !uploadData.fileName) {
|
|
84
|
+
uploadData.fileName = 'file';
|
|
85
|
+
}
|
|
86
|
+
if (!uploadData.mimetype) {
|
|
87
|
+
uploadData.mimetype = MIMETYPE_MAP[mediaType];
|
|
88
|
+
}
|
|
89
|
+
if (cacheableKey) {
|
|
90
|
+
const mediaBuff = await options.mediaCache.get(cacheableKey);
|
|
91
|
+
if (mediaBuff) {
|
|
92
|
+
logger?.debug({ cacheableKey }, 'got media cache hit');
|
|
93
|
+
const obj = proto.Message.decode(mediaBuff);
|
|
94
|
+
const key = `${mediaType}Message`;
|
|
95
|
+
Object.assign(obj[key], { ...uploadData, media: undefined });
|
|
96
|
+
return obj;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const isNewsletter = !!options.jid && isJidNewsletter(options.jid);
|
|
100
|
+
if (isNewsletter) {
|
|
101
|
+
logger?.info({ key: cacheableKey }, 'Preparing raw media for newsletter');
|
|
102
|
+
const { filePath, fileSha256, fileLength } = await getRawMediaUploadData(uploadData.media, options.mediaTypeOverride || mediaType, logger);
|
|
103
|
+
const fileSha256B64 = fileSha256.toString('base64');
|
|
104
|
+
const { mediaUrl, directPath } = await options.upload(filePath, {
|
|
105
|
+
fileEncSha256B64: fileSha256B64,
|
|
106
|
+
mediaType: mediaType,
|
|
107
|
+
timeoutMs: options.mediaUploadTimeoutMs
|
|
108
|
+
});
|
|
109
|
+
await fs.unlink(filePath);
|
|
110
|
+
const obj = WAProto.Message.fromObject({
|
|
111
|
+
// todo: add more support here
|
|
112
|
+
[`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
|
|
113
|
+
url: mediaUrl,
|
|
114
|
+
directPath,
|
|
115
|
+
fileSha256,
|
|
116
|
+
fileLength,
|
|
117
|
+
...uploadData,
|
|
118
|
+
media: undefined
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
if (uploadData.ptv) {
|
|
122
|
+
obj.ptvMessage = obj.videoMessage;
|
|
123
|
+
delete obj.videoMessage;
|
|
124
|
+
}
|
|
125
|
+
if (obj.stickerMessage) {
|
|
126
|
+
obj.stickerMessage.stickerSentTs = Date.now();
|
|
127
|
+
}
|
|
128
|
+
if (cacheableKey) {
|
|
129
|
+
logger?.debug({ cacheableKey }, 'set cache');
|
|
130
|
+
await options.mediaCache.set(cacheableKey, WAProto.Message.encode(obj).finish());
|
|
131
|
+
}
|
|
132
|
+
return obj;
|
|
133
|
+
}
|
|
134
|
+
const requiresDurationComputation = mediaType === 'audio' && typeof uploadData.seconds === 'undefined';
|
|
135
|
+
const requiresThumbnailComputation = (mediaType === 'image' || mediaType === 'video') && typeof uploadData['jpegThumbnail'] === 'undefined';
|
|
136
|
+
const requiresWaveformProcessing = mediaType === 'audio' && uploadData.ptt === true && typeof uploadData.waveform === 'undefined';
|
|
137
|
+
const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
|
|
138
|
+
const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
|
|
139
|
+
const { mediaKey, encFilePath, originalFilePath, fileEncSha256, fileSha256, fileLength } = await encryptedStream(uploadData.media, options.mediaTypeOverride || mediaType, {
|
|
140
|
+
logger,
|
|
141
|
+
saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
|
|
142
|
+
opts: options.options
|
|
143
|
+
});
|
|
144
|
+
const fileEncSha256B64 = fileEncSha256.toString('base64');
|
|
145
|
+
const [{ mediaUrl, directPath }] = await Promise.all([
|
|
146
|
+
(async () => {
|
|
147
|
+
const result = await options.upload(encFilePath, {
|
|
148
|
+
fileEncSha256B64,
|
|
149
|
+
mediaType,
|
|
150
|
+
timeoutMs: options.mediaUploadTimeoutMs
|
|
151
|
+
});
|
|
152
|
+
logger?.debug({ mediaType, cacheableKey }, 'uploaded media');
|
|
153
|
+
return result;
|
|
154
|
+
})(),
|
|
155
|
+
(async () => {
|
|
156
|
+
try {
|
|
157
|
+
if (requiresThumbnailComputation) {
|
|
158
|
+
const { thumbnail, originalImageDimensions } = await generateThumbnail(originalFilePath, mediaType, options);
|
|
159
|
+
uploadData.jpegThumbnail = thumbnail;
|
|
160
|
+
if (!uploadData.width && originalImageDimensions) {
|
|
161
|
+
uploadData.width = originalImageDimensions.width;
|
|
162
|
+
uploadData.height = originalImageDimensions.height;
|
|
163
|
+
logger?.debug('set dimensions');
|
|
164
|
+
}
|
|
165
|
+
logger?.debug('generated thumbnail');
|
|
166
|
+
}
|
|
167
|
+
if (requiresDurationComputation) {
|
|
168
|
+
uploadData.seconds = await getAudioDuration(originalFilePath);
|
|
169
|
+
logger?.debug('computed audio duration');
|
|
170
|
+
}
|
|
171
|
+
if (requiresWaveformProcessing) {
|
|
172
|
+
uploadData.waveform = await getAudioWaveform(originalFilePath, logger);
|
|
173
|
+
logger?.debug('processed waveform');
|
|
174
|
+
}
|
|
175
|
+
if (requiresAudioBackground) {
|
|
176
|
+
uploadData.backgroundArgb = await assertColor(options.backgroundColor);
|
|
177
|
+
logger?.debug('computed backgroundColor audio status');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
logger?.warn({ trace: error.stack }, 'failed to obtain extra info');
|
|
182
|
+
}
|
|
183
|
+
})()
|
|
184
|
+
]).finally(async () => {
|
|
185
|
+
try {
|
|
186
|
+
await fs.unlink(encFilePath);
|
|
187
|
+
if (originalFilePath) {
|
|
188
|
+
await fs.unlink(originalFilePath);
|
|
189
|
+
}
|
|
190
|
+
logger?.debug('removed tmp files');
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
logger?.warn('failed to remove tmp file');
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
const obj = WAProto.Message.fromObject({
|
|
197
|
+
[`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
|
|
198
|
+
url: mediaUrl,
|
|
199
|
+
directPath,
|
|
200
|
+
mediaKey,
|
|
201
|
+
fileEncSha256,
|
|
202
|
+
fileSha256,
|
|
203
|
+
fileLength,
|
|
204
|
+
mediaKeyTimestamp: unixTimestampSeconds(),
|
|
205
|
+
...uploadData,
|
|
206
|
+
media: undefined
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
if (uploadData.ptv) {
|
|
210
|
+
obj.ptvMessage = obj.videoMessage;
|
|
211
|
+
delete obj.videoMessage;
|
|
212
|
+
}
|
|
213
|
+
if (cacheableKey) {
|
|
214
|
+
logger?.debug({ cacheableKey }, 'set cache');
|
|
215
|
+
await options.mediaCache.set(cacheableKey, WAProto.Message.encode(obj).finish());
|
|
216
|
+
}
|
|
217
|
+
return obj;
|
|
218
|
+
};
|
|
219
|
+
export const prepareDisappearingMessageSettingContent = (ephemeralExpiration) => {
|
|
220
|
+
ephemeralExpiration = ephemeralExpiration || 0;
|
|
221
|
+
const content = {
|
|
222
|
+
ephemeralMessage: {
|
|
223
|
+
message: {
|
|
224
|
+
protocolMessage: {
|
|
225
|
+
type: WAProto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
|
|
226
|
+
ephemeralExpiration
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return WAProto.Message.fromObject(content);
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Generate forwarded message content like WA does
|
|
235
|
+
* @param message the message to forward
|
|
236
|
+
* @param options.forceForward will show the message as forwarded even if it is from you
|
|
237
|
+
*/
|
|
238
|
+
export const generateForwardMessageContent = (message, forceForward) => {
|
|
239
|
+
let content = message.message;
|
|
240
|
+
if (!content) {
|
|
241
|
+
throw new Boom('no content in message', { statusCode: 400 });
|
|
242
|
+
}
|
|
243
|
+
// hacky copy
|
|
244
|
+
content = normalizeMessageContent(content);
|
|
245
|
+
content = proto.Message.decode(proto.Message.encode(content).finish());
|
|
246
|
+
let key = Object.keys(content)[0];
|
|
247
|
+
let score = content?.[key]?.contextInfo?.forwardingScore || 0;
|
|
248
|
+
score += message.key.fromMe && !forceForward ? 0 : 1;
|
|
249
|
+
if (key === 'conversation') {
|
|
250
|
+
content.extendedTextMessage = { text: content[key] };
|
|
251
|
+
delete content.conversation;
|
|
252
|
+
key = 'extendedTextMessage';
|
|
253
|
+
}
|
|
254
|
+
const key_ = content?.[key];
|
|
255
|
+
if (score > 0) {
|
|
256
|
+
key_.contextInfo = { forwardingScore: score, isForwarded: true };
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
key_.contextInfo = {};
|
|
260
|
+
}
|
|
261
|
+
return content;
|
|
262
|
+
};
|
|
263
|
+
export const hasNonNullishProperty = (message, key) => {
|
|
264
|
+
return (typeof message === 'object' &&
|
|
265
|
+
message !== null &&
|
|
266
|
+
key in message &&
|
|
267
|
+
message[key] !== null &&
|
|
268
|
+
message[key] !== undefined);
|
|
269
|
+
};
|
|
270
|
+
function hasOptionalProperty(obj, key) {
|
|
271
|
+
return typeof obj === 'object' && obj !== null && key in obj && obj[key] !== null;
|
|
272
|
+
}
|
|
273
|
+
export const generateWAMessageContent = async (message, options) => {
|
|
274
|
+
var _a, _b;
|
|
275
|
+
let m = {};
|
|
276
|
+
if (hasNonNullishProperty(message, 'text')) {
|
|
277
|
+
const extContent = { text: message.text };
|
|
278
|
+
let urlInfo = message.linkPreview;
|
|
279
|
+
if (typeof urlInfo === 'undefined') {
|
|
280
|
+
urlInfo = await generateLinkPreviewIfRequired(message.text, options.getUrlInfo, options.logger);
|
|
281
|
+
}
|
|
282
|
+
if (urlInfo) {
|
|
283
|
+
extContent.matchedText = urlInfo['matched-text'];
|
|
284
|
+
extContent.jpegThumbnail = urlInfo.jpegThumbnail;
|
|
285
|
+
extContent.description = urlInfo.description;
|
|
286
|
+
extContent.title = urlInfo.title;
|
|
287
|
+
extContent.previewType = 0;
|
|
288
|
+
const img = urlInfo.highQualityThumbnail;
|
|
289
|
+
if (img) {
|
|
290
|
+
extContent.thumbnailDirectPath = img.directPath;
|
|
291
|
+
extContent.mediaKey = img.mediaKey;
|
|
292
|
+
extContent.mediaKeyTimestamp = img.mediaKeyTimestamp;
|
|
293
|
+
extContent.thumbnailWidth = img.width;
|
|
294
|
+
extContent.thumbnailHeight = img.height;
|
|
295
|
+
extContent.thumbnailSha256 = img.fileSha256;
|
|
296
|
+
extContent.thumbnailEncSha256 = img.fileEncSha256;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (options.backgroundColor) {
|
|
300
|
+
extContent.backgroundArgb = await assertColor(options.backgroundColor);
|
|
301
|
+
}
|
|
302
|
+
if (options.font) {
|
|
303
|
+
extContent.font = options.font;
|
|
304
|
+
}
|
|
305
|
+
m.extendedTextMessage = extContent;
|
|
306
|
+
}
|
|
307
|
+
else if (hasNonNullishProperty(message, 'contacts')) {
|
|
308
|
+
const contactLen = message.contacts.contacts.length;
|
|
309
|
+
if (!contactLen) {
|
|
310
|
+
throw new Boom('require atleast 1 contact', { statusCode: 400 });
|
|
311
|
+
}
|
|
312
|
+
if (contactLen === 1) {
|
|
313
|
+
m.contactMessage = WAProto.Message.ContactMessage.create(message.contacts.contacts[0]);
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
m.contactsArrayMessage = WAProto.Message.ContactsArrayMessage.create(message.contacts);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else if (hasNonNullishProperty(message, 'location')) {
|
|
320
|
+
m.locationMessage = WAProto.Message.LocationMessage.create(message.location);
|
|
321
|
+
}
|
|
322
|
+
else if (hasNonNullishProperty(message, 'react')) {
|
|
323
|
+
if (!message.react.senderTimestampMs) {
|
|
324
|
+
message.react.senderTimestampMs = Date.now();
|
|
325
|
+
}
|
|
326
|
+
m.reactionMessage = WAProto.Message.ReactionMessage.create(message.react);
|
|
327
|
+
}
|
|
328
|
+
else if (hasNonNullishProperty(message, 'delete')) {
|
|
329
|
+
m.protocolMessage = {
|
|
330
|
+
key: message.delete,
|
|
331
|
+
type: WAProto.Message.ProtocolMessage.Type.REVOKE
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
else if (hasNonNullishProperty(message, 'forward')) {
|
|
335
|
+
m = generateForwardMessageContent(message.forward, message.force);
|
|
336
|
+
}
|
|
337
|
+
else if (hasNonNullishProperty(message, 'disappearingMessagesInChat')) {
|
|
338
|
+
const exp = typeof message.disappearingMessagesInChat === 'boolean'
|
|
339
|
+
? message.disappearingMessagesInChat
|
|
340
|
+
? WA_DEFAULT_EPHEMERAL
|
|
341
|
+
: 0
|
|
342
|
+
: message.disappearingMessagesInChat;
|
|
343
|
+
m = prepareDisappearingMessageSettingContent(exp);
|
|
344
|
+
}
|
|
345
|
+
else if (hasNonNullishProperty(message, 'groupInvite')) {
|
|
346
|
+
m.groupInviteMessage = {};
|
|
347
|
+
m.groupInviteMessage.inviteCode = message.groupInvite.inviteCode;
|
|
348
|
+
m.groupInviteMessage.inviteExpiration = message.groupInvite.inviteExpiration;
|
|
349
|
+
m.groupInviteMessage.caption = message.groupInvite.text;
|
|
350
|
+
m.groupInviteMessage.groupJid = message.groupInvite.jid;
|
|
351
|
+
m.groupInviteMessage.groupName = message.groupInvite.subject;
|
|
352
|
+
//TODO: use built-in interface and get disappearing mode info etc.
|
|
353
|
+
//TODO: cache / use store!?
|
|
354
|
+
if (options.getProfilePicUrl) {
|
|
355
|
+
const pfpUrl = await options.getProfilePicUrl(message.groupInvite.jid, 'preview');
|
|
356
|
+
if (pfpUrl) {
|
|
357
|
+
const resp = await fetch(pfpUrl, { method: 'GET', dispatcher: options?.options?.dispatcher });
|
|
358
|
+
if (resp.ok) {
|
|
359
|
+
const buf = Buffer.from(await resp.arrayBuffer());
|
|
360
|
+
m.groupInviteMessage.jpegThumbnail = buf;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
else if (hasNonNullishProperty(message, 'pin')) {
|
|
366
|
+
m.pinInChatMessage = {};
|
|
367
|
+
m.messageContextInfo = {};
|
|
368
|
+
m.pinInChatMessage.key = message.pin;
|
|
369
|
+
m.pinInChatMessage.type = message.type;
|
|
370
|
+
m.pinInChatMessage.senderTimestampMs = Date.now();
|
|
371
|
+
m.messageContextInfo.messageAddOnDurationInSecs = message.type === 1 ? message.time || 86400 : 0;
|
|
372
|
+
}
|
|
373
|
+
else if (hasNonNullishProperty(message, 'buttonReply')) {
|
|
374
|
+
switch (message.type) {
|
|
375
|
+
case 'template':
|
|
376
|
+
m.templateButtonReplyMessage = {
|
|
377
|
+
selectedDisplayText: message.buttonReply.displayText,
|
|
378
|
+
selectedId: message.buttonReply.id,
|
|
379
|
+
selectedIndex: message.buttonReply.index
|
|
380
|
+
};
|
|
381
|
+
break;
|
|
382
|
+
case 'plain':
|
|
383
|
+
m.buttonsResponseMessage = {
|
|
384
|
+
selectedButtonId: message.buttonReply.id,
|
|
385
|
+
selectedDisplayText: message.buttonReply.displayText,
|
|
386
|
+
type: proto.Message.ButtonsResponseMessage.Type.DISPLAY_TEXT
|
|
387
|
+
};
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
else if (hasOptionalProperty(message, 'ptv') && message.ptv) {
|
|
392
|
+
const { videoMessage } = await prepareWAMessageMedia({ video: message.video }, options);
|
|
393
|
+
m.ptvMessage = videoMessage;
|
|
394
|
+
}
|
|
395
|
+
else if (hasNonNullishProperty(message, 'product')) {
|
|
396
|
+
const { imageMessage } = await prepareWAMessageMedia({ image: message.product.productImage }, options);
|
|
397
|
+
m.productMessage = WAProto.Message.ProductMessage.create({
|
|
398
|
+
...message,
|
|
399
|
+
product: {
|
|
400
|
+
...message.product,
|
|
401
|
+
productImage: imageMessage
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
else if (hasNonNullishProperty(message, 'listReply')) {
|
|
406
|
+
m.listResponseMessage = { ...message.listReply };
|
|
407
|
+
}
|
|
408
|
+
else if (hasNonNullishProperty(message, 'event')) {
|
|
409
|
+
m.eventMessage = {};
|
|
410
|
+
const startTime = Math.floor(message.event.startDate.getTime() / 1000);
|
|
411
|
+
if (message.event.call && options.getCallLink) {
|
|
412
|
+
const token = await options.getCallLink(message.event.call, { startTime });
|
|
413
|
+
m.eventMessage.joinLink = (message.event.call === 'audio' ? CALL_AUDIO_PREFIX : CALL_VIDEO_PREFIX) + token;
|
|
414
|
+
}
|
|
415
|
+
m.messageContextInfo = {
|
|
416
|
+
// encKey
|
|
417
|
+
messageSecret: message.event.messageSecret || randomBytes(32)
|
|
418
|
+
};
|
|
419
|
+
m.eventMessage.name = message.event.name;
|
|
420
|
+
m.eventMessage.description = message.event.description;
|
|
421
|
+
m.eventMessage.startTime = startTime;
|
|
422
|
+
m.eventMessage.endTime = message.event.endDate ? message.event.endDate.getTime() / 1000 : undefined;
|
|
423
|
+
m.eventMessage.isCanceled = message.event.isCancelled ?? false;
|
|
424
|
+
m.eventMessage.extraGuestsAllowed = message.event.extraGuestsAllowed;
|
|
425
|
+
m.eventMessage.isScheduleCall = message.event.isScheduleCall ?? false;
|
|
426
|
+
m.eventMessage.location = message.event.location;
|
|
427
|
+
}
|
|
428
|
+
else if (hasNonNullishProperty(message, 'poll')) {
|
|
429
|
+
(_a = message.poll).selectableCount || (_a.selectableCount = 0);
|
|
430
|
+
(_b = message.poll).toAnnouncementGroup || (_b.toAnnouncementGroup = false);
|
|
431
|
+
if (!Array.isArray(message.poll.values)) {
|
|
432
|
+
throw new Boom('Invalid poll values', { statusCode: 400 });
|
|
433
|
+
}
|
|
434
|
+
if (message.poll.selectableCount < 0 || message.poll.selectableCount > message.poll.values.length) {
|
|
435
|
+
throw new Boom(`poll.selectableCount in poll should be >= 0 and <= ${message.poll.values.length}`, {
|
|
436
|
+
statusCode: 400
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
m.messageContextInfo = {
|
|
440
|
+
// encKey
|
|
441
|
+
messageSecret: message.poll.messageSecret || randomBytes(32)
|
|
442
|
+
};
|
|
443
|
+
const pollCreationMessage = {
|
|
444
|
+
name: message.poll.name,
|
|
445
|
+
selectableOptionsCount: message.poll.selectableCount,
|
|
446
|
+
options: message.poll.values.map(optionName => ({ optionName }))
|
|
447
|
+
};
|
|
448
|
+
if (message.poll.toAnnouncementGroup) {
|
|
449
|
+
// poll v2 is for community announcement groups (single select and multiple)
|
|
450
|
+
m.pollCreationMessageV2 = pollCreationMessage;
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
if (message.poll.selectableCount === 1) {
|
|
454
|
+
//poll v3 is for single select polls
|
|
455
|
+
m.pollCreationMessageV3 = pollCreationMessage;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
// poll for multiple choice polls
|
|
459
|
+
m.pollCreationMessage = pollCreationMessage;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else if (hasNonNullishProperty(message, 'sharePhoneNumber')) {
|
|
464
|
+
m.protocolMessage = {
|
|
465
|
+
type: proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
else if (hasNonNullishProperty(message, 'requestPhoneNumber')) {
|
|
469
|
+
m.requestPhoneNumberMessage = {};
|
|
470
|
+
}
|
|
471
|
+
else if (hasNonNullishProperty(message, 'limitSharing')) {
|
|
472
|
+
m.protocolMessage = {
|
|
473
|
+
type: proto.Message.ProtocolMessage.Type.LIMIT_SHARING,
|
|
474
|
+
limitSharing: {
|
|
475
|
+
sharingLimited: message.limitSharing === true,
|
|
476
|
+
trigger: 1,
|
|
477
|
+
limitSharingSettingTimestamp: Date.now(),
|
|
478
|
+
initiatedByMe: true
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
m = await prepareWAMessageMedia(message, options);
|
|
484
|
+
}
|
|
485
|
+
if (hasOptionalProperty(message, 'viewOnce') && !!message.viewOnce) {
|
|
486
|
+
m = { viewOnceMessage: { message: m } };
|
|
487
|
+
}
|
|
488
|
+
if ((hasOptionalProperty(message, 'mentions') && message.mentions?.length) ||
|
|
489
|
+
(hasOptionalProperty(message, 'mentionAll') && message.mentionAll)) {
|
|
490
|
+
const messageType = Object.keys(m)[0];
|
|
491
|
+
const key = m[messageType];
|
|
492
|
+
if (key && 'contextInfo' in key) {
|
|
493
|
+
key.contextInfo = key.contextInfo || {};
|
|
494
|
+
if (message.mentions?.length) {
|
|
495
|
+
key.contextInfo.mentionedJid = message.mentions;
|
|
496
|
+
}
|
|
497
|
+
if (message.mentionAll) {
|
|
498
|
+
key.contextInfo.nonJidMentions = 1;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
else if (key) {
|
|
502
|
+
key.contextInfo = {
|
|
503
|
+
mentionedJid: message.mentions,
|
|
504
|
+
nonJidMentions: message.mentionAll ? 1 : 0
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (hasOptionalProperty(message, 'edit')) {
|
|
509
|
+
m = {
|
|
510
|
+
protocolMessage: {
|
|
511
|
+
key: message.edit,
|
|
512
|
+
editedMessage: m,
|
|
513
|
+
timestampMs: Date.now(),
|
|
514
|
+
type: WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
if (hasOptionalProperty(message, 'contextInfo') && !!message.contextInfo) {
|
|
519
|
+
const messageType = Object.keys(m)[0];
|
|
520
|
+
const key = m[messageType];
|
|
521
|
+
if ('contextInfo' in key && !!key.contextInfo) {
|
|
522
|
+
key.contextInfo = { ...key.contextInfo, ...message.contextInfo };
|
|
523
|
+
}
|
|
524
|
+
else if (key) {
|
|
525
|
+
key.contextInfo = message.contextInfo;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (shouldIncludeReportingToken(m)) {
|
|
529
|
+
m.messageContextInfo = m.messageContextInfo || {};
|
|
530
|
+
if (!m.messageContextInfo.messageSecret) {
|
|
531
|
+
m.messageContextInfo.messageSecret = randomBytes(32);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return WAProto.Message.create(m);
|
|
535
|
+
};
|
|
536
|
+
export const generateWAMessageFromContent = (jid, message, options) => {
|
|
537
|
+
// set timestamp to now
|
|
538
|
+
// if not specified
|
|
539
|
+
if (!options.timestamp) {
|
|
540
|
+
options.timestamp = new Date();
|
|
541
|
+
}
|
|
542
|
+
const innerMessage = normalizeMessageContent(message);
|
|
543
|
+
const key = getContentType(innerMessage);
|
|
544
|
+
const timestamp = unixTimestampSeconds(options.timestamp);
|
|
545
|
+
const { quoted, userJid } = options;
|
|
546
|
+
if (quoted && !isJidNewsletter(jid)) {
|
|
547
|
+
const participant = quoted.key.fromMe
|
|
548
|
+
? userJid // TODO: Add support for LIDs
|
|
549
|
+
: quoted.participant || quoted.key.participant || quoted.key.remoteJid;
|
|
550
|
+
let quotedMsg = normalizeMessageContent(quoted.message);
|
|
551
|
+
const msgType = getContentType(quotedMsg);
|
|
552
|
+
// strip any redundant properties
|
|
553
|
+
quotedMsg = proto.Message.create({ [msgType]: quotedMsg[msgType] });
|
|
554
|
+
const quotedContent = quotedMsg[msgType];
|
|
555
|
+
if (typeof quotedContent === 'object' && quotedContent && 'contextInfo' in quotedContent) {
|
|
556
|
+
delete quotedContent.contextInfo;
|
|
557
|
+
}
|
|
558
|
+
const contextInfo = ('contextInfo' in innerMessage[key] && innerMessage[key]?.contextInfo) || {};
|
|
559
|
+
contextInfo.participant = jidNormalizedUser(participant);
|
|
560
|
+
contextInfo.stanzaId = quoted.key.id;
|
|
561
|
+
contextInfo.quotedMessage = quotedMsg;
|
|
562
|
+
// if a participant is quoted, then it must be a group
|
|
563
|
+
// hence, remoteJid of group must also be entered
|
|
564
|
+
if (jid !== quoted.key.remoteJid) {
|
|
565
|
+
contextInfo.remoteJid = quoted.key.remoteJid;
|
|
566
|
+
}
|
|
567
|
+
if (contextInfo && innerMessage[key]) {
|
|
568
|
+
/* @ts-ignore */
|
|
569
|
+
innerMessage[key].contextInfo = contextInfo;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (
|
|
573
|
+
// if we want to send a disappearing message
|
|
574
|
+
!!options?.ephemeralExpiration &&
|
|
575
|
+
// and it's not a protocol message -- delete, toggle disappear message
|
|
576
|
+
key !== 'protocolMessage' &&
|
|
577
|
+
// already not converted to disappearing message
|
|
578
|
+
key !== 'ephemeralMessage' &&
|
|
579
|
+
// newsletters don't support ephemeral messages
|
|
580
|
+
!isJidNewsletter(jid)) {
|
|
581
|
+
/* @ts-ignore */
|
|
582
|
+
innerMessage[key].contextInfo = {
|
|
583
|
+
...(innerMessage[key].contextInfo || {}),
|
|
584
|
+
expiration: options.ephemeralExpiration || WA_DEFAULT_EPHEMERAL
|
|
585
|
+
//ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString()
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
message = WAProto.Message.create(message);
|
|
589
|
+
const messageJSON = {
|
|
590
|
+
key: {
|
|
591
|
+
remoteJid: jid,
|
|
592
|
+
fromMe: true,
|
|
593
|
+
id: options?.messageId || generateMessageIDV2()
|
|
594
|
+
},
|
|
595
|
+
message: message,
|
|
596
|
+
messageTimestamp: timestamp,
|
|
597
|
+
messageStubParameters: [],
|
|
598
|
+
participant: isJidGroup(jid) || isJidStatusBroadcast(jid) ? userJid : undefined, // TODO: Add support for LIDs
|
|
599
|
+
status: WAMessageStatus.PENDING
|
|
600
|
+
};
|
|
601
|
+
return WAProto.WebMessageInfo.fromObject(messageJSON);
|
|
602
|
+
};
|
|
603
|
+
export const generateWAMessage = async (jid, content, options) => {
|
|
604
|
+
// ensure msg ID is with every log
|
|
605
|
+
options.logger = options?.logger?.child({ msgId: options.messageId });
|
|
606
|
+
// Pass jid in the options to generateWAMessageContent
|
|
607
|
+
return generateWAMessageFromContent(jid, await generateWAMessageContent(content, { ...options, jid }), options);
|
|
608
|
+
};
|
|
609
|
+
/** Get the key to access the true type of content */
|
|
610
|
+
export const getContentType = (content) => {
|
|
611
|
+
if (content) {
|
|
612
|
+
const keys = Object.keys(content);
|
|
613
|
+
const key = keys.find(k => (k === 'conversation' || k.includes('Message')) && k !== 'senderKeyDistributionMessage');
|
|
614
|
+
return key;
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* Normalizes ephemeral, view once messages to regular message content
|
|
619
|
+
* Eg. image messages in ephemeral messages, in view once messages etc.
|
|
620
|
+
* @param content
|
|
621
|
+
* @returns
|
|
622
|
+
*/
|
|
623
|
+
export const normalizeMessageContent = (content) => {
|
|
624
|
+
if (!content) {
|
|
625
|
+
return undefined;
|
|
626
|
+
}
|
|
627
|
+
// set max iterations to prevent an infinite loop
|
|
628
|
+
for (let i = 0; i < 5; i++) {
|
|
629
|
+
const inner = getFutureProofMessage(content);
|
|
630
|
+
if (!inner) {
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
content = inner.message;
|
|
634
|
+
}
|
|
635
|
+
return content;
|
|
636
|
+
function getFutureProofMessage(message) {
|
|
637
|
+
return (message?.ephemeralMessage ||
|
|
638
|
+
message?.viewOnceMessage ||
|
|
639
|
+
message?.documentWithCaptionMessage ||
|
|
640
|
+
message?.viewOnceMessageV2 ||
|
|
641
|
+
message?.viewOnceMessageV2Extension ||
|
|
642
|
+
message?.editedMessage ||
|
|
643
|
+
message?.associatedChildMessage ||
|
|
644
|
+
message?.groupStatusMessage ||
|
|
645
|
+
message?.groupStatusMessageV2);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* Extract the true message content from a message
|
|
650
|
+
* Eg. extracts the inner message from a disappearing message/view once message
|
|
651
|
+
*/
|
|
652
|
+
export const extractMessageContent = (content) => {
|
|
653
|
+
const extractFromTemplateMessage = (msg) => {
|
|
654
|
+
if (msg.imageMessage) {
|
|
655
|
+
return { imageMessage: msg.imageMessage };
|
|
656
|
+
}
|
|
657
|
+
else if (msg.documentMessage) {
|
|
658
|
+
return { documentMessage: msg.documentMessage };
|
|
659
|
+
}
|
|
660
|
+
else if (msg.videoMessage) {
|
|
661
|
+
return { videoMessage: msg.videoMessage };
|
|
662
|
+
}
|
|
663
|
+
else if (msg.locationMessage) {
|
|
664
|
+
return { locationMessage: msg.locationMessage };
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
return {
|
|
668
|
+
conversation: 'contentText' in msg ? msg.contentText : 'hydratedContentText' in msg ? msg.hydratedContentText : ''
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
content = normalizeMessageContent(content);
|
|
673
|
+
if (content?.buttonsMessage) {
|
|
674
|
+
return extractFromTemplateMessage(content.buttonsMessage);
|
|
675
|
+
}
|
|
676
|
+
if (content?.templateMessage?.hydratedFourRowTemplate) {
|
|
677
|
+
return extractFromTemplateMessage(content?.templateMessage?.hydratedFourRowTemplate);
|
|
678
|
+
}
|
|
679
|
+
if (content?.templateMessage?.hydratedTemplate) {
|
|
680
|
+
return extractFromTemplateMessage(content?.templateMessage?.hydratedTemplate);
|
|
681
|
+
}
|
|
682
|
+
if (content?.templateMessage?.fourRowTemplate) {
|
|
683
|
+
return extractFromTemplateMessage(content?.templateMessage?.fourRowTemplate);
|
|
684
|
+
}
|
|
685
|
+
return content;
|
|
686
|
+
};
|
|
687
|
+
/**
|
|
688
|
+
* Returns the device predicted by message ID
|
|
689
|
+
*/
|
|
690
|
+
export const getDevice = (id) => /^3A.{18}$/.test(id)
|
|
691
|
+
? 'ios'
|
|
692
|
+
: /^3E.{20}$/.test(id)
|
|
693
|
+
? 'web'
|
|
694
|
+
: /^(.{21}|.{32})$/.test(id)
|
|
695
|
+
? 'android'
|
|
696
|
+
: /^(3F|.{18}$)/.test(id)
|
|
697
|
+
? 'desktop'
|
|
698
|
+
: 'unknown';
|
|
699
|
+
/** Upserts a receipt in the message */
|
|
700
|
+
export const updateMessageWithReceipt = (msg, receipt) => {
|
|
701
|
+
msg.userReceipt = msg.userReceipt || [];
|
|
702
|
+
const recp = msg.userReceipt.find(m => m.userJid === receipt.userJid);
|
|
703
|
+
if (recp) {
|
|
704
|
+
Object.assign(recp, receipt);
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
msg.userReceipt.push(receipt);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
/** Update the message with a new reaction */
|
|
711
|
+
export const updateMessageWithReaction = (msg, reaction) => {
|
|
712
|
+
const authorID = getKeyAuthor(reaction.key);
|
|
713
|
+
const reactions = (msg.reactions || []).filter(r => getKeyAuthor(r.key) !== authorID);
|
|
714
|
+
reaction.text = reaction.text || '';
|
|
715
|
+
reactions.push(reaction);
|
|
716
|
+
msg.reactions = reactions;
|
|
717
|
+
};
|
|
718
|
+
/** Update the message with a new poll update */
|
|
719
|
+
export const updateMessageWithPollUpdate = (msg, update) => {
|
|
720
|
+
const authorID = getKeyAuthor(update.pollUpdateMessageKey);
|
|
721
|
+
const reactions = (msg.pollUpdates || []).filter(r => getKeyAuthor(r.pollUpdateMessageKey) !== authorID);
|
|
722
|
+
if (update.vote?.selectedOptions?.length) {
|
|
723
|
+
reactions.push(update);
|
|
724
|
+
}
|
|
725
|
+
msg.pollUpdates = reactions;
|
|
726
|
+
};
|
|
727
|
+
/** Update the message with a new event response */
|
|
728
|
+
export const updateMessageWithEventResponse = (msg, update) => {
|
|
729
|
+
const authorID = getKeyAuthor(update.eventResponseMessageKey);
|
|
730
|
+
const responses = (msg.eventResponses || []).filter(r => getKeyAuthor(r.eventResponseMessageKey) !== authorID);
|
|
731
|
+
responses.push(update);
|
|
732
|
+
msg.eventResponses = responses;
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Aggregates all poll updates in a poll.
|
|
736
|
+
* @param msg the poll creation message
|
|
737
|
+
* @param meId your jid
|
|
738
|
+
* @returns A list of options & their voters
|
|
739
|
+
*/
|
|
740
|
+
export function getAggregateVotesInPollMessage({ message, pollUpdates }, meId) {
|
|
741
|
+
const opts = message?.pollCreationMessage?.options ||
|
|
742
|
+
message?.pollCreationMessageV2?.options ||
|
|
743
|
+
message?.pollCreationMessageV3?.options ||
|
|
744
|
+
[];
|
|
745
|
+
const voteHashMap = opts.reduce((acc, opt) => {
|
|
746
|
+
const hash = sha256(Buffer.from(opt.optionName || '')).toString();
|
|
747
|
+
acc[hash] = {
|
|
748
|
+
name: opt.optionName || '',
|
|
749
|
+
voters: []
|
|
750
|
+
};
|
|
751
|
+
return acc;
|
|
752
|
+
}, {});
|
|
753
|
+
for (const update of pollUpdates || []) {
|
|
754
|
+
const { vote } = update;
|
|
755
|
+
if (!vote) {
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
for (const option of vote.selectedOptions || []) {
|
|
759
|
+
const hash = option.toString();
|
|
760
|
+
let data = voteHashMap[hash];
|
|
761
|
+
if (!data) {
|
|
762
|
+
voteHashMap[hash] = {
|
|
763
|
+
name: 'Unknown',
|
|
764
|
+
voters: []
|
|
765
|
+
};
|
|
766
|
+
data = voteHashMap[hash];
|
|
767
|
+
}
|
|
768
|
+
voteHashMap[hash].voters.push(getKeyAuthor(update.pollUpdateMessageKey, meId));
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return Object.values(voteHashMap);
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Aggregates all event responses in an event message.
|
|
775
|
+
* @param msg the event creation message
|
|
776
|
+
* @param meId your jid
|
|
777
|
+
* @returns A list of response types & their responders
|
|
778
|
+
*/
|
|
779
|
+
export function getAggregateResponsesInEventMessage({ eventResponses }, meId) {
|
|
780
|
+
const responseTypes = ['GOING', 'NOT_GOING', 'MAYBE'];
|
|
781
|
+
const responseMap = {};
|
|
782
|
+
for (const type of responseTypes) {
|
|
783
|
+
responseMap[type] = {
|
|
784
|
+
response: type,
|
|
785
|
+
responders: []
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
for (const update of eventResponses || []) {
|
|
789
|
+
const responseType = update.eventResponse || 'UNKNOWN';
|
|
790
|
+
if (responseType !== 'UNKNOWN' && responseMap[responseType]) {
|
|
791
|
+
responseMap[responseType].responders.push(getKeyAuthor(update.eventResponseMessageKey, meId));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return Object.values(responseMap);
|
|
795
|
+
}
|
|
796
|
+
/** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
|
|
797
|
+
export const aggregateMessageKeysNotFromMe = (keys) => {
|
|
798
|
+
const keyMap = {};
|
|
799
|
+
for (const { remoteJid, id, participant, fromMe } of keys) {
|
|
800
|
+
if (!fromMe) {
|
|
801
|
+
const uqKey = `${remoteJid}:${participant || ''}`;
|
|
802
|
+
if (!keyMap[uqKey]) {
|
|
803
|
+
keyMap[uqKey] = {
|
|
804
|
+
jid: remoteJid,
|
|
805
|
+
participant: participant,
|
|
806
|
+
messageIds: []
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
keyMap[uqKey].messageIds.push(id);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return Object.values(keyMap);
|
|
813
|
+
};
|
|
814
|
+
const REUPLOAD_REQUIRED_STATUS = [410, 404];
|
|
815
|
+
/**
|
|
816
|
+
* Downloads the given message. Throws an error if it's not a media message
|
|
817
|
+
*/
|
|
818
|
+
export const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
819
|
+
const result = await downloadMsg().catch(async (error) => {
|
|
820
|
+
if (ctx &&
|
|
821
|
+
typeof error?.status === 'number' && // treat errors with status as HTTP failures requiring reupload
|
|
822
|
+
REUPLOAD_REQUIRED_STATUS.includes(error.status)) {
|
|
823
|
+
ctx.logger.info({ key: message.key }, 'sending reupload media request...');
|
|
824
|
+
// request reupload
|
|
825
|
+
message = await ctx.reuploadRequest(message);
|
|
826
|
+
const result = await downloadMsg();
|
|
827
|
+
return result;
|
|
828
|
+
}
|
|
829
|
+
throw error;
|
|
830
|
+
});
|
|
831
|
+
return result;
|
|
832
|
+
async function downloadMsg() {
|
|
833
|
+
const mContent = extractMessageContent(message.message);
|
|
834
|
+
if (!mContent) {
|
|
835
|
+
throw new Boom('No message present', { statusCode: 400, data: message });
|
|
836
|
+
}
|
|
837
|
+
const contentType = getContentType(mContent);
|
|
838
|
+
let mediaType = contentType?.replace('Message', '');
|
|
839
|
+
const media = mContent[contentType];
|
|
840
|
+
if (!media || typeof media !== 'object' || (!('url' in media) && !('thumbnailDirectPath' in media))) {
|
|
841
|
+
throw new Boom(`"${contentType}" message is not a media message`);
|
|
842
|
+
}
|
|
843
|
+
let download;
|
|
844
|
+
if ('thumbnailDirectPath' in media && !('url' in media)) {
|
|
845
|
+
download = {
|
|
846
|
+
directPath: media.thumbnailDirectPath,
|
|
847
|
+
mediaKey: media.mediaKey
|
|
848
|
+
};
|
|
849
|
+
mediaType = 'thumbnail-link';
|
|
850
|
+
}
|
|
851
|
+
else {
|
|
852
|
+
download = media;
|
|
853
|
+
}
|
|
854
|
+
const stream = await downloadContentFromMessage(download, mediaType, options);
|
|
855
|
+
if (type === 'buffer') {
|
|
856
|
+
const bufferArray = [];
|
|
857
|
+
for await (const chunk of stream) {
|
|
858
|
+
bufferArray.push(chunk);
|
|
859
|
+
}
|
|
860
|
+
return Buffer.concat(bufferArray);
|
|
861
|
+
}
|
|
862
|
+
return stream;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
/** Checks whether the given message is a media message; if it is returns the inner content */
|
|
866
|
+
export const assertMediaContent = (content) => {
|
|
867
|
+
content = extractMessageContent(content);
|
|
868
|
+
const mediaContent = content?.documentMessage ||
|
|
869
|
+
content?.imageMessage ||
|
|
870
|
+
content?.videoMessage ||
|
|
871
|
+
content?.audioMessage ||
|
|
872
|
+
content?.stickerMessage;
|
|
873
|
+
if (!mediaContent) {
|
|
874
|
+
throw new Boom('given message is not a media message', { statusCode: 400, data: content });
|
|
875
|
+
}
|
|
876
|
+
return mediaContent;
|
|
877
|
+
};
|
|
878
|
+
//# sourceMappingURL=messages.js.map
|