@kyyinfinite/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 +1550 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +6035 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +2 -0
- package/WAProto/index.js +132326 -0
- package/lib/Defaults/index.d.ts +74 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +137 -0
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +82 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +26 -0
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +403 -0
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +19 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +271 -0
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +54 -0
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +536 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +422 -0
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +111 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +991 -0
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +645 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/dugong.d.ts +130 -0
- package/lib/Socket/dugong.d.ts.map +1 -0
- package/lib/Socket/dugong.js +768 -0
- package/lib/Socket/dugong.js.map +1 -0
- package/lib/Socket/groups.d.ts +150 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +327 -0
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +636 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +13 -0
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +238 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +1308 -0
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +579 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +1595 -0
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +48 -0
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +177 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +316 -0
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +55 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +936 -0
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +116 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +37 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +123 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +24 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +237 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +68 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +422 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +31 -0
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +76 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +158 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +3 -0
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +39 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +13 -0
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +33 -0
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +290 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +231 -0
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +812 -0
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +118 -0
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +283 -0
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +574 -0
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +91 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +384 -0
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +22 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +131 -0
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +37 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +25 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +24 -0
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/kyy-features.d.ts +158 -0
- package/lib/Utils/kyy-features.js +365 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +85 -0
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +8 -0
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +33 -0
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +110 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +225 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +130 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +782 -0
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +91 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +1238 -0
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +201 -0
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +528 -0
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/rich-messages.d.ts +277 -0
- package/lib/Utils/rich-messages.d.ts.map +1 -0
- package/lib/Utils/rich-messages.js +1144 -0
- package/lib/Utils/rich-messages.js.map +1 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +159 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sticker-pack.d.ts +10 -0
- package/lib/Utils/sticker-pack.js +111 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +12 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +18 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +200 -0
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1301 -0
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +262 -0
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +220 -0
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +191 -0
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +6 -0
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +96 -0
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -0
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +5 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +94 -0
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +23 -0
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kyy-features.js — kyyinfinite extra features
|
|
3
|
+
*
|
|
4
|
+
* Fitur tambahan yang di-export langsung dari kyyinfinite:
|
|
5
|
+
* 1. withTyping() — auto presence indicator
|
|
6
|
+
* 2. downloadMedia() — one-shot media downloader
|
|
7
|
+
* 3. mentionAll() — mention semua member group
|
|
8
|
+
* 4. setupAntiDelete() — tangkap pesan yang dihapus
|
|
9
|
+
* 5. batchSend() — kirim ke banyak JID dengan throttle
|
|
10
|
+
* 6. MessageBuilder — fluent API untuk build pesan
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { downloadMediaMessage } from './messages.js';
|
|
14
|
+
|
|
15
|
+
// ─── 1. withTyping ────────────────────────────────────────────────────────────
|
|
16
|
+
/**
|
|
17
|
+
* Tampilkan indikator typing/recording selama fungsi berjalan,
|
|
18
|
+
* lalu otomatis berhenti setelah selesai.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const result = await withTyping(sock, jid, async () => {
|
|
22
|
+
* const data = await fetchSomething();
|
|
23
|
+
* await sock.sendMessage(jid, { text: data });
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example // recording indicator
|
|
27
|
+
* await withTyping(sock, jid, async () => { ... }, 'recording');
|
|
28
|
+
*/
|
|
29
|
+
export async function withTyping(sock, jid, fn, type = 'composing') {
|
|
30
|
+
try {
|
|
31
|
+
await sock.sendPresenceUpdate(type, jid);
|
|
32
|
+
} catch {}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
return await fn();
|
|
36
|
+
} finally {
|
|
37
|
+
try {
|
|
38
|
+
await sock.sendPresenceUpdate('paused', jid);
|
|
39
|
+
} catch {}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ─── 2. downloadMedia ────────────────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* Download media dari pesan WA secara otomatis — auto-detect tipe media.
|
|
46
|
+
* Return Buffer langsung, siap dipakai.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const buffer = await downloadMedia(ctx.raw);
|
|
50
|
+
* // lalu: await sock.sendMessage(jid, { image: buffer });
|
|
51
|
+
*
|
|
52
|
+
* @example // dengan output stream
|
|
53
|
+
* const stream = await downloadMedia(ctx.raw, 'stream');
|
|
54
|
+
*/
|
|
55
|
+
export async function downloadMedia(message, outputType = 'buffer') {
|
|
56
|
+
const msg = message?.message;
|
|
57
|
+
if (!msg) throw new Error('downloadMedia: pesan tidak valid');
|
|
58
|
+
|
|
59
|
+
const MEDIA_TYPES = {
|
|
60
|
+
imageMessage: 'image',
|
|
61
|
+
videoMessage: 'video',
|
|
62
|
+
audioMessage: 'audio',
|
|
63
|
+
stickerMessage: 'sticker',
|
|
64
|
+
documentMessage: 'document',
|
|
65
|
+
ptvMessage: 'video',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Cari tipe media
|
|
69
|
+
const msgType = Object.keys(msg).find(k => MEDIA_TYPES[k]);
|
|
70
|
+
if (!msgType) throw new Error('downloadMedia: pesan bukan media');
|
|
71
|
+
|
|
72
|
+
const mediaType = MEDIA_TYPES[msgType];
|
|
73
|
+
|
|
74
|
+
return downloadMediaMessage(
|
|
75
|
+
message,
|
|
76
|
+
outputType,
|
|
77
|
+
{},
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Helper: deteksi apakah pesan mengandung media
|
|
83
|
+
*/
|
|
84
|
+
export function isMediaMessage(message) {
|
|
85
|
+
const msg = message?.message;
|
|
86
|
+
if (!msg) return false;
|
|
87
|
+
const MEDIA_KEYS = ['imageMessage','videoMessage','audioMessage','stickerMessage','documentMessage','ptvMessage'];
|
|
88
|
+
return MEDIA_KEYS.some(k => k in msg);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Helper: ambil mime type dari pesan media
|
|
93
|
+
*/
|
|
94
|
+
export function getMediaMimetype(message) {
|
|
95
|
+
const msg = message?.message;
|
|
96
|
+
if (!msg) return null;
|
|
97
|
+
const MEDIA_KEYS = ['imageMessage','videoMessage','audioMessage','stickerMessage','documentMessage','ptvMessage'];
|
|
98
|
+
const key = MEDIA_KEYS.find(k => k in msg);
|
|
99
|
+
if (!key) return null;
|
|
100
|
+
return msg[key]?.mimetype ?? null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ─── 3. mentionAll ───────────────────────────────────────────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Kirim pesan yang mention semua anggota group.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* await mentionAll(sock, ctx.chat, '📢 Perhatian semua!');
|
|
109
|
+
*
|
|
110
|
+
* @example // dengan quoted
|
|
111
|
+
* await mentionAll(sock, ctx.chat, 'Halo semua!', { quoted: ctx.raw });
|
|
112
|
+
*/
|
|
113
|
+
export async function mentionAll(sock, jid, text = '', opts = {}) {
|
|
114
|
+
const meta = await sock.groupMetadata(jid);
|
|
115
|
+
const participants = meta.participants ?? [];
|
|
116
|
+
const mentions = participants.map(p => p.id ?? p);
|
|
117
|
+
|
|
118
|
+
const mentionText = text
|
|
119
|
+
|| mentions.map(m => `@${m.split('@')[0]}`).join(' ');
|
|
120
|
+
|
|
121
|
+
return sock.sendMessage(jid, {
|
|
122
|
+
text: mentionText,
|
|
123
|
+
mentions,
|
|
124
|
+
...opts,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Build daftar mention tanpa langsung mengirim.
|
|
130
|
+
* Berguna kalau mau embed mentions ke pesan yang lebih kompleks.
|
|
131
|
+
*
|
|
132
|
+
* @returns {{ mentions: string[], mentionText: string }}
|
|
133
|
+
*/
|
|
134
|
+
export async function buildMentionAll(sock, jid) {
|
|
135
|
+
const meta = await sock.groupMetadata(jid);
|
|
136
|
+
const mentions = (meta.participants ?? []).map(p => p.id ?? p);
|
|
137
|
+
const mentionText = mentions.map(m => `@${m.split('@')[0]}`).join(' ');
|
|
138
|
+
return { mentions, mentionText };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ─── 4. setupAntiDelete ──────────────────────────────────────────────────────
|
|
142
|
+
/**
|
|
143
|
+
* Setup listener anti-delete. Tangkap pesan yang dihapus sebelum hilang.
|
|
144
|
+
* Butuh store yang sudah di-bind ke socket.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* setupAntiDelete(sock, store, async (deletedMsg, key) => {
|
|
148
|
+
* const body = deletedMsg.message?.conversation ?? '(media)';
|
|
149
|
+
* await sock.sendMessage(key.remoteJid, {
|
|
150
|
+
* text: `🗑️ *Pesan dihapus oleh @${key.participant?.split('@')[0]}:*\n${body}`,
|
|
151
|
+
* mentions: [key.participant],
|
|
152
|
+
* });
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* @param {Function} onDelete - callback(originalMessage, key)
|
|
156
|
+
* @param {object} options
|
|
157
|
+
* @param {boolean} options.ignoreOwn - abaikan pesan diri sendiri (default: true)
|
|
158
|
+
* @param {boolean} options.groupOnly - hanya group (default: false)
|
|
159
|
+
*/
|
|
160
|
+
export function setupAntiDelete(sock, store, onDelete, options = {}) {
|
|
161
|
+
const { ignoreOwn = true, groupOnly = false } = options;
|
|
162
|
+
|
|
163
|
+
sock.ev.on('messages.update', async (updates) => {
|
|
164
|
+
for (const update of updates) {
|
|
165
|
+
try {
|
|
166
|
+
const isRevoked = update.update?.messageStubType === 1; // REVOKE = 1
|
|
167
|
+
if (!isRevoked) continue;
|
|
168
|
+
|
|
169
|
+
const { remoteJid, id, participant, fromMe } = update.key;
|
|
170
|
+
|
|
171
|
+
if (ignoreOwn && fromMe) continue;
|
|
172
|
+
if (groupOnly && !remoteJid?.endsWith('@g.us')) continue;
|
|
173
|
+
|
|
174
|
+
// Cari pesan original dari store
|
|
175
|
+
const original = store?.messages
|
|
176
|
+
?.get(remoteJid)
|
|
177
|
+
?.get(id);
|
|
178
|
+
|
|
179
|
+
if (!original) continue;
|
|
180
|
+
|
|
181
|
+
await onDelete(original, update.key);
|
|
182
|
+
} catch {}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ─── 5. batchSend ────────────────────────────────────────────────────────────
|
|
188
|
+
/**
|
|
189
|
+
* Kirim pesan ke banyak JID dengan delay antar pesan (anti-ban).
|
|
190
|
+
* Return array hasil per JID.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* const groups = Object.keys(await sock.groupFetchAllParticipating());
|
|
194
|
+
* const results = await batchSend(sock, groups, { text: '📢 Pengumuman!' });
|
|
195
|
+
* console.log(`Berhasil: ${results.filter(r => r.success).length}`);
|
|
196
|
+
*
|
|
197
|
+
* @example // custom delay & quoted
|
|
198
|
+
* await batchSend(sock, targets, { text: 'Halo!' }, {
|
|
199
|
+
* delayMs: 3000,
|
|
200
|
+
* onProgress: (done, total, jid) => console.log(`${done}/${total}: ${jid}`),
|
|
201
|
+
* });
|
|
202
|
+
*/
|
|
203
|
+
export async function batchSend(sock, targets, content, options = {}) {
|
|
204
|
+
const {
|
|
205
|
+
delayMs = 2000,
|
|
206
|
+
onProgress = null,
|
|
207
|
+
onError = null,
|
|
208
|
+
} = options;
|
|
209
|
+
|
|
210
|
+
const results = [];
|
|
211
|
+
|
|
212
|
+
for (let i = 0; i < targets.length; i++) {
|
|
213
|
+
const jid = targets[i];
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
const msg = await sock.sendMessage(jid, content);
|
|
217
|
+
results.push({ jid, success: true, msg });
|
|
218
|
+
} catch (err) {
|
|
219
|
+
results.push({ jid, success: false, error: err.message });
|
|
220
|
+
if (onError) {
|
|
221
|
+
try { await onError(jid, err); } catch {}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (onProgress) {
|
|
226
|
+
try { await onProgress(i + 1, targets.length, jid); } catch {}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Delay antar pesan (kecuali pesan terakhir)
|
|
230
|
+
if (i < targets.length - 1) {
|
|
231
|
+
await new Promise(r => setTimeout(r, delayMs));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return results;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ─── 6. MessageBuilder ───────────────────────────────────────────────────────
|
|
239
|
+
/**
|
|
240
|
+
* Fluent API untuk build dan kirim pesan.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* await new MessageBuilder(sock)
|
|
244
|
+
* .to(ctx.chat)
|
|
245
|
+
* .text('Halo!')
|
|
246
|
+
* .quote(ctx.raw)
|
|
247
|
+
* .mentions([ctx.sender])
|
|
248
|
+
* .send();
|
|
249
|
+
*
|
|
250
|
+
* @example // kirim gambar
|
|
251
|
+
* await new MessageBuilder(sock)
|
|
252
|
+
* .to(jid)
|
|
253
|
+
* .image(buffer, 'Caption gambar')
|
|
254
|
+
* .send();
|
|
255
|
+
*
|
|
256
|
+
* @example // kirim lalu react
|
|
257
|
+
* const sent = await new MessageBuilder(sock)
|
|
258
|
+
* .to(jid)
|
|
259
|
+
* .text('Pesan penting!')
|
|
260
|
+
* .send();
|
|
261
|
+
* await new MessageBuilder(sock).to(jid).react('✅', sent).send();
|
|
262
|
+
*/
|
|
263
|
+
export class MessageBuilder {
|
|
264
|
+
constructor(sock) {
|
|
265
|
+
this.sock = sock;
|
|
266
|
+
this._jid = null;
|
|
267
|
+
this._content = {};
|
|
268
|
+
this._opts = {};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Target JID (chat/group/nomor) */
|
|
272
|
+
to(jid) {
|
|
273
|
+
this._jid = jid;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Pesan teks */
|
|
278
|
+
text(str) {
|
|
279
|
+
this._content.text = str;
|
|
280
|
+
return this;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Gambar — buffer atau URL */
|
|
284
|
+
image(source, caption = '') {
|
|
285
|
+
if (typeof source === 'string') {
|
|
286
|
+
this._content.image = { url: source };
|
|
287
|
+
} else {
|
|
288
|
+
this._content.image = source;
|
|
289
|
+
}
|
|
290
|
+
if (caption) this._content.caption = caption;
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** Video — buffer atau URL */
|
|
295
|
+
video(source, caption = '') {
|
|
296
|
+
if (typeof source === 'string') {
|
|
297
|
+
this._content.video = { url: source };
|
|
298
|
+
} else {
|
|
299
|
+
this._content.video = source;
|
|
300
|
+
}
|
|
301
|
+
if (caption) this._content.caption = caption;
|
|
302
|
+
return this;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Audio */
|
|
306
|
+
audio(source, ptt = false) {
|
|
307
|
+
if (typeof source === 'string') {
|
|
308
|
+
this._content.audio = { url: source };
|
|
309
|
+
} else {
|
|
310
|
+
this._content.audio = source;
|
|
311
|
+
}
|
|
312
|
+
this._content.ptt = ptt;
|
|
313
|
+
return this;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Stiker */
|
|
317
|
+
sticker(source) {
|
|
318
|
+
if (typeof source === 'string') {
|
|
319
|
+
this._content.sticker = { url: source };
|
|
320
|
+
} else {
|
|
321
|
+
this._content.sticker = source;
|
|
322
|
+
}
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** React ke pesan */
|
|
327
|
+
react(emoji, targetMessage) {
|
|
328
|
+
this._content.react = {
|
|
329
|
+
text: emoji,
|
|
330
|
+
key: targetMessage?.key ?? targetMessage,
|
|
331
|
+
};
|
|
332
|
+
return this;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** Quote pesan lain */
|
|
336
|
+
quote(message) {
|
|
337
|
+
this._opts.quoted = message;
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Mentions */
|
|
342
|
+
mentions(jids) {
|
|
343
|
+
this._content.mentions = jids;
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Footer (hanya untuk pesan interaktif) */
|
|
348
|
+
footer(text) {
|
|
349
|
+
this._content.footer = text;
|
|
350
|
+
return this;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** Ephemeral / disappearing message (detik) */
|
|
354
|
+
disappear(seconds = 86400) {
|
|
355
|
+
this._opts.ephemeralExpiration = seconds;
|
|
356
|
+
return this;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Kirim pesan */
|
|
360
|
+
async send() {
|
|
361
|
+
if (!this._jid) throw new Error('MessageBuilder: .to(jid) belum dipanggil');
|
|
362
|
+
if (!Object.keys(this._content).length) throw new Error('MessageBuilder: konten pesan kosong');
|
|
363
|
+
return this.sock.sendMessage(this._jid, this._content, this._opts);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WAMediaUploadFunction, WAUrlInfo } from '../Types/index.js';
|
|
2
|
+
import type { ILogger } from './logger.js';
|
|
3
|
+
export type URLGenerationOptions = {
|
|
4
|
+
thumbnailWidth: number;
|
|
5
|
+
fetchOpts: {
|
|
6
|
+
/** Timeout in ms */
|
|
7
|
+
timeout: number;
|
|
8
|
+
proxyUrl?: string;
|
|
9
|
+
headers?: HeadersInit;
|
|
10
|
+
};
|
|
11
|
+
uploadImage?: WAMediaUploadFunction;
|
|
12
|
+
logger?: ILogger;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Given a piece of text, checks for any URL present, generates link preview for the same and returns it
|
|
16
|
+
* Return undefined if the fetch failed or no URL was found
|
|
17
|
+
* @param text first matched URL in text
|
|
18
|
+
* @returns the URL info required to generate link preview
|
|
19
|
+
*/
|
|
20
|
+
export declare const getUrlInfo: (text: string, opts?: URLGenerationOptions) => Promise<WAUrlInfo | undefined>;
|
|
21
|
+
//# sourceMappingURL=link-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-preview.d.ts","sourceRoot":"","sources":["../../src/Utils/link-preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAavC,MAAM,MAAM,oBAAoB,GAAG;IAClC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE;QACV,oBAAoB;QACpB,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,WAAW,CAAA;KACrB,CAAA;IACD,WAAW,CAAC,EAAE,qBAAqB,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACtB,MAAM,MAAM,EACZ,OAAM,oBAGL,KACC,OAAO,CAAC,SAAS,GAAG,SAAS,CAwE/B,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { prepareWAMessageMedia } from './messages.js';
|
|
2
|
+
import { extractImageThumb, getHttpStream } from './messages-media.js';
|
|
3
|
+
const THUMBNAIL_WIDTH_PX = 192;
|
|
4
|
+
/** Fetches an image and generates a thumbnail for it */
|
|
5
|
+
const getCompressedJpegThumbnail = async (url, { thumbnailWidth, fetchOpts }) => {
|
|
6
|
+
const stream = await getHttpStream(url, fetchOpts);
|
|
7
|
+
const result = await extractImageThumb(stream, thumbnailWidth);
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Given a piece of text, checks for any URL present, generates link preview for the same and returns it
|
|
12
|
+
* Return undefined if the fetch failed or no URL was found
|
|
13
|
+
* @param text first matched URL in text
|
|
14
|
+
* @returns the URL info required to generate link preview
|
|
15
|
+
*/
|
|
16
|
+
export const getUrlInfo = async (text, opts = {
|
|
17
|
+
thumbnailWidth: THUMBNAIL_WIDTH_PX,
|
|
18
|
+
fetchOpts: { timeout: 3000 }
|
|
19
|
+
}) => {
|
|
20
|
+
try {
|
|
21
|
+
// retries
|
|
22
|
+
const retries = 0;
|
|
23
|
+
const maxRetry = 5;
|
|
24
|
+
const { getLinkPreview } = await import('link-preview-js');
|
|
25
|
+
let previewLink = text;
|
|
26
|
+
if (!text.startsWith('https://') && !text.startsWith('http://')) {
|
|
27
|
+
previewLink = 'https://' + previewLink;
|
|
28
|
+
}
|
|
29
|
+
const info = await getLinkPreview(previewLink, {
|
|
30
|
+
...opts.fetchOpts,
|
|
31
|
+
followRedirects: 'follow',
|
|
32
|
+
handleRedirects: (baseURL, forwardedURL) => {
|
|
33
|
+
const urlObj = new URL(baseURL);
|
|
34
|
+
const forwardedURLObj = new URL(forwardedURL);
|
|
35
|
+
if (retries >= maxRetry) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (forwardedURLObj.hostname === urlObj.hostname ||
|
|
39
|
+
forwardedURLObj.hostname === 'www.' + urlObj.hostname ||
|
|
40
|
+
'www.' + forwardedURLObj.hostname === urlObj.hostname) {
|
|
41
|
+
retries + 1;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
headers: opts.fetchOpts?.headers
|
|
49
|
+
});
|
|
50
|
+
if (info && 'title' in info && info.title) {
|
|
51
|
+
const [image] = info.images;
|
|
52
|
+
const urlInfo = {
|
|
53
|
+
'canonical-url': info.url,
|
|
54
|
+
'matched-text': text,
|
|
55
|
+
title: info.title,
|
|
56
|
+
description: info.description,
|
|
57
|
+
originalThumbnailUrl: image
|
|
58
|
+
};
|
|
59
|
+
if (opts.uploadImage) {
|
|
60
|
+
const { imageMessage } = await prepareWAMessageMedia({ image: { url: image } }, {
|
|
61
|
+
upload: opts.uploadImage,
|
|
62
|
+
mediaTypeOverride: 'thumbnail-link',
|
|
63
|
+
options: opts.fetchOpts
|
|
64
|
+
});
|
|
65
|
+
urlInfo.jpegThumbnail = imageMessage?.jpegThumbnail ? Buffer.from(imageMessage.jpegThumbnail) : undefined;
|
|
66
|
+
urlInfo.highQualityThumbnail = imageMessage || undefined;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
try {
|
|
70
|
+
urlInfo.jpegThumbnail = image ? (await getCompressedJpegThumbnail(image, opts)).buffer : undefined;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
opts.logger?.debug({ err: error.stack, url: previewLink }, 'error in generating thumbnail');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return urlInfo;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!error.message.includes('receive a valid')) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=link-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-preview.js","sourceRoot":"","sources":["../../src/Utils/link-preview.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEnE,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAE9B,wDAAwD;AACxD,MAAM,0BAA0B,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE,cAAc,EAAE,SAAS,EAAwB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,0BAA0B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;gBACnG,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACrB,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,+BAA+B,CAAC,CAAA;gBAC5F,CAAC;YACF,CAAC;YAED,OAAO,OAAO,CAAA;QACf,CAAC;IACF,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAChD,MAAM,KAAK,CAAA;QACZ,CAAC;IACF,CAAC;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import P from 'pino';
|
|
2
|
+
export interface ILogger {
|
|
3
|
+
level: string;
|
|
4
|
+
child(obj: Record<string, unknown>): ILogger;
|
|
5
|
+
trace(obj: unknown, msg?: string): void;
|
|
6
|
+
debug(obj: unknown, msg?: string): void;
|
|
7
|
+
info(obj: unknown, msg?: string): void;
|
|
8
|
+
warn(obj: unknown, msg?: string): void;
|
|
9
|
+
error(obj: unknown, msg?: string): void;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: P.Logger<never, boolean>;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/Utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,MAAM,CAAA;AAEpB,MAAM,WAAW,OAAO;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAA;IAC5C,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvC;;AAED,wBAAyE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/Utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,MAAM,CAAA;AAYpB,eAAe,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LTHashAntiTampering } from 'whatsapp-rust-bridge';
|
|
2
|
+
/**
|
|
3
|
+
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
4
|
+
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
5
|
+
* if the same series of mutations was made sequentially.
|
|
6
|
+
*/
|
|
7
|
+
export declare const LT_HASH_ANTI_TAMPERING: LTHashAntiTampering;
|
|
8
|
+
//# sourceMappingURL=lt-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lt-hash.d.ts","sourceRoot":"","sources":["../../src/Utils/lt-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,qBAA4B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LTHashAntiTampering } from 'whatsapp-rust-bridge';
|
|
2
|
+
/**
|
|
3
|
+
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
4
|
+
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
5
|
+
* if the same series of mutations was made sequentially.
|
|
6
|
+
*/
|
|
7
|
+
export const LT_HASH_ANTI_TAMPERING = new LTHashAntiTampering();
|
|
8
|
+
//# sourceMappingURL=lt-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lt-hash.js","sourceRoot":"","sources":["../../src/Utils/lt-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const makeMutex: () => {
|
|
2
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
3
|
+
};
|
|
4
|
+
export type Mutex = ReturnType<typeof makeMutex>;
|
|
5
|
+
export declare const makeKeyedMutex: () => {
|
|
6
|
+
mutex<T>(key: string, task: () => Promise<T> | T): Promise<T>;
|
|
7
|
+
};
|
|
8
|
+
export type KeyedMutex = ReturnType<typeof makeKeyedMutex>;
|
|
9
|
+
//# sourceMappingURL=make-mutex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mutex.d.ts","sourceRoot":"","sources":["../../src/Utils/make-mutex.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;UAId,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAIjD,CAAA;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;AAEhD,eAAO,MAAM,cAAc;UAIb,CAAC,OAAO,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAqBpE,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Mutex as AsyncMutex } from 'async-mutex';
|
|
2
|
+
export const makeMutex = () => {
|
|
3
|
+
const mutex = new AsyncMutex();
|
|
4
|
+
return {
|
|
5
|
+
mutex(code) {
|
|
6
|
+
return mutex.runExclusive(code);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export const makeKeyedMutex = () => {
|
|
11
|
+
const map = new Map();
|
|
12
|
+
return {
|
|
13
|
+
async mutex(key, task) {
|
|
14
|
+
let entry = map.get(key);
|
|
15
|
+
if (!entry) {
|
|
16
|
+
entry = { mutex: new AsyncMutex(), refCount: 0 };
|
|
17
|
+
map.set(key, entry);
|
|
18
|
+
}
|
|
19
|
+
entry.refCount++;
|
|
20
|
+
try {
|
|
21
|
+
return await entry.mutex.runExclusive(task);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
entry.refCount--;
|
|
25
|
+
// only delete it if this is still the current entry
|
|
26
|
+
if (entry.refCount === 0 && map.get(key) === entry) {
|
|
27
|
+
map.delete(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=make-mutex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mutex.js","sourceRoot":"","sources":["../../src/Utils/make-mutex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC7B,MAAM,KAAK,GA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