@vanzxysenpai/baileys 0.0.0-stage → 0.0.2
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/CHANGELOG.md +30 -0
- package/LICENSE +25 -0
- package/NOTICE.md +158 -0
- package/README.md +5294 -2
- package/VanzxyBanner.js +134 -0
- package/WAProto/index.d.ts +13317 -0
- package/WAProto/index.js +147553 -0
- package/lib/Builders/A2UI.d.ts +131 -0
- package/lib/Builders/A2UI.js +343 -0
- package/lib/Builders/AIRich.d.ts +1021 -0
- package/lib/Builders/AIRich.js +2889 -0
- package/lib/Builders/Album.d.ts +51 -0
- package/lib/Builders/Album.js +99 -0
- package/lib/Builders/Button.d.ts +137449 -0
- package/lib/Builders/Button.js +1054 -0
- package/lib/Builders/ButtonV2.d.ts +43 -0
- package/lib/Builders/ButtonV2.js +175 -0
- package/lib/Builders/ButtonV3.d.ts +35 -0
- package/lib/Builders/ButtonV3.js +189 -0
- package/lib/Builders/Carousel.d.ts +68 -0
- package/lib/Builders/Carousel.js +161 -0
- package/lib/Builders/Event.d.ts +61 -0
- package/lib/Builders/Event.js +118 -0
- package/lib/Builders/Expiring.d.ts +17 -0
- package/lib/Builders/Expiring.js +27 -0
- package/lib/Builders/Poll.d.ts +63 -0
- package/lib/Builders/Poll.js +139 -0
- package/lib/Builders/VanzxyBaileys.d.ts +42 -0
- package/lib/Builders/VanzxyBaileys.js +110 -0
- package/lib/Builders/errors.d.ts +25 -0
- package/lib/Builders/errors.js +29 -0
- package/lib/Builders/index.d.ts +14 -0
- package/lib/Builders/index.js +23 -0
- package/lib/Builders/shared.d.ts +395 -0
- package/lib/Builders/shared.js +738 -0
- package/lib/Defaults/bot-jid.d.ts +1 -0
- package/lib/Defaults/bot-jid.js +1 -0
- package/lib/Defaults/index.d.ts +161 -0
- package/lib/Defaults/index.js +165 -0
- package/lib/Defaults/version.d.ts +1 -0
- package/lib/Defaults/version.js +1 -0
- package/lib/Framework/Bot.d.ts +865 -0
- package/lib/Framework/Bot.js +230 -0
- package/lib/Framework/Context.d.ts +17 -0
- package/lib/Framework/Context.js +90 -0
- package/lib/Framework/MediaManager.d.ts +15 -0
- package/lib/Framework/MediaManager.js +154 -0
- package/lib/Framework/SessionManager.d.ts +10 -0
- package/lib/Framework/SessionManager.js +34 -0
- package/lib/Framework/StatsManager.d.ts +20 -0
- package/lib/Framework/StatsManager.js +117 -0
- package/lib/Framework/Store/SQLiteStore.d.ts +13 -0
- package/lib/Framework/Store/SQLiteStore.js +68 -0
- package/lib/Framework/index.d.ts +6 -0
- package/lib/Framework/index.js +11 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +58 -0
- package/lib/Signal/libsignal.js +436 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +276 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.d.ts +674 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +137 -0
- package/lib/Socket/chats.js +1299 -0
- package/lib/Socket/communities.d.ts +805 -0
- package/lib/Socket/communities.js +454 -0
- package/lib/Socket/dugong.d.ts +118 -0
- package/lib/Socket/dugong.js +810 -0
- package/lib/Socket/groups.d.ts +287 -0
- package/lib/Socket/groups.js +386 -0
- package/lib/Socket/index.d.ts +826 -0
- package/lib/Socket/index.js +35 -0
- package/lib/Socket/messages-recv.d.ts +613 -0
- package/lib/Socket/messages-recv.js +1851 -0
- package/lib/Socket/messages-send.d.ts +608 -0
- package/lib/Socket/messages-send.js +1574 -0
- package/lib/Socket/mex-fallback.d.ts +51 -0
- package/lib/Socket/mex-fallback.js +97 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter-ext.d.ts +47 -0
- package/lib/Socket/newsletter-ext.js +262 -0
- package/lib/Socket/newsletter.d.ts +285 -0
- package/lib/Socket/newsletter.js +223 -0
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Socket/socket.js +1001 -0
- package/lib/Socket/username.d.ts +842 -0
- package/lib/Socket/username.js +156 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-in-memory-store.js +425 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +1 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +11 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +1 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +1 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +1 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +5 -0
- package/lib/Types/State.js +55 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +15 -0
- package/lib/Types/index.js +27 -0
- package/lib/Utils/PersistentStore.d.ts +83 -0
- package/lib/Utils/PersistentStore.js +592 -0
- package/lib/Utils/anchor-guard.d.ts +31 -0
- package/lib/Utils/anchor-guard.js +329 -0
- package/lib/Utils/android-stanza-id.d.ts +4 -0
- package/lib/Utils/android-stanza-id.js +21 -0
- package/lib/Utils/anti-delete.d.ts +62 -0
- package/lib/Utils/anti-delete.js +212 -0
- package/lib/Utils/auth-secure.d.ts +180 -0
- package/lib/Utils/auth-secure.js +791 -0
- package/lib/Utils/auth-utils.d.ts +59 -0
- package/lib/Utils/auth-utils.js +326 -0
- package/lib/Utils/auto-reconnect.d.ts +8 -0
- package/lib/Utils/auto-reconnect.js +204 -0
- package/lib/Utils/auto-reply.d.ts +35 -0
- package/lib/Utils/auto-reply.js +152 -0
- package/lib/Utils/bad-mac-handler.d.ts +59 -0
- package/lib/Utils/bad-mac-handler.js +119 -0
- package/lib/Utils/baileys-event-stream.d.ts +5 -0
- package/lib/Utils/baileys-event-stream.js +62 -0
- package/lib/Utils/browser-utils.d.ts +9 -0
- package/lib/Utils/browser-utils.js +29 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +236 -0
- package/lib/Utils/button-helper-utils.d.ts +59 -0
- package/lib/Utils/button-helper-utils.js +266 -0
- package/lib/Utils/button-sender.d.ts +164 -0
- package/lib/Utils/button-sender.js +845 -0
- package/lib/Utils/chat-control.d.ts +98 -0
- package/lib/Utils/chat-control.js +231 -0
- package/lib/Utils/chat-history-helpers.d.ts +4 -0
- package/lib/Utils/chat-history-helpers.js +70 -0
- package/lib/Utils/chat-utils.d.ts +408 -0
- package/lib/Utils/chat-utils.js +879 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/connection-watchdog.d.ts +10 -0
- package/lib/Utils/connection-watchdog.js +74 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +145 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +315 -0
- package/lib/Utils/disconnect-reason.d.ts +13 -0
- package/lib/Utils/disconnect-reason.js +36 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +640 -0
- package/lib/Utils/fetch-timeout.d.ts +4 -0
- package/lib/Utils/fetch-timeout.js +14 -0
- package/lib/Utils/ffmpeg-path.d.ts +5 -0
- package/lib/Utils/ffmpeg-path.js +130 -0
- package/lib/Utils/generics.d.ts +79 -0
- package/lib/Utils/generics.js +426 -0
- package/lib/Utils/group-metadata-cache.d.ts +3 -0
- package/lib/Utils/group-metadata-cache.js +25 -0
- package/lib/Utils/group-status-detection.d.ts +5 -0
- package/lib/Utils/group-status-detection.js +114 -0
- package/lib/Utils/history.d.ts +91 -0
- package/lib/Utils/history.js +144 -0
- package/lib/Utils/html-app.d.ts +14 -0
- package/lib/Utils/html-app.js +97 -0
- package/lib/Utils/html-multiplayer.d.ts +8 -0
- package/lib/Utils/html-multiplayer.js +90 -0
- package/lib/Utils/humanizer.d.ts +8 -0
- package/lib/Utils/humanizer.js +74 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/index.d.ts +88 -0
- package/lib/Utils/index.js +93 -0
- package/lib/Utils/jid-tools.d.ts +3 -0
- package/lib/Utils/jid-tools.js +78 -0
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +90 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/lock-manager.d.ts +5 -0
- package/lib/Utils/lock-manager.js +50 -0
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +26 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/media-messages.d.ts +35 -0
- package/lib/Utils/media-messages.js +70 -0
- package/lib/Utils/media-processor.d.ts +6 -0
- package/lib/Utils/media-processor.js +174 -0
- package/lib/Utils/media-set.d.ts +6 -0
- package/lib/Utils/media-set.js +169 -0
- package/lib/Utils/message-kind.d.ts +26 -0
- package/lib/Utils/message-kind.js +138 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +264 -0
- package/lib/Utils/message-search.d.ts +40 -0
- package/lib/Utils/message-search.js +181 -0
- package/lib/Utils/messages-media.d.ts +136 -0
- package/lib/Utils/messages-media.js +867 -0
- package/lib/Utils/messages.d.ts +66 -0
- package/lib/Utils/messages.js +2271 -0
- package/lib/Utils/meta-ai-msmsg.d.ts +3 -0
- package/lib/Utils/meta-ai-msmsg.js +132 -0
- package/lib/Utils/meta-ai.d.ts +4 -0
- package/lib/Utils/meta-ai.js +75 -0
- package/lib/Utils/migrate-auth-state.d.ts +23 -0
- package/lib/Utils/migrate-auth-state.js +126 -0
- package/lib/Utils/mini-app.d.ts +20 -0
- package/lib/Utils/mini-app.js +215 -0
- package/lib/Utils/mock-socket.d.ts +67 -0
- package/lib/Utils/mock-socket.js +254 -0
- package/lib/Utils/modern-messages.d.ts +64 -0
- package/lib/Utils/modern-messages.js +497 -0
- package/lib/Utils/native-flow.d.ts +19 -0
- package/lib/Utils/native-flow.js +112 -0
- package/lib/Utils/newsletter-status.d.ts +157 -0
- package/lib/Utils/newsletter-status.js +652 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/pairing-utils.d.ts +5 -0
- package/lib/Utils/pairing-utils.js +29 -0
- package/lib/Utils/passkey.d.ts +4 -0
- package/lib/Utils/passkey.js +11 -0
- package/lib/Utils/past-participants.d.ts +2 -0
- package/lib/Utils/past-participants.js +40 -0
- package/lib/Utils/payment-detection.d.ts +40 -0
- package/lib/Utils/payment-detection.js +213 -0
- package/lib/Utils/payment-guard.d.ts +28 -0
- package/lib/Utils/payment-guard.js +143 -0
- package/lib/Utils/payment-messages.d.ts +42 -0
- package/lib/Utils/payment-messages.js +161 -0
- package/lib/Utils/payment-utils.d.ts +75 -0
- package/lib/Utils/payment-utils.js +145 -0
- package/lib/Utils/phone-utils.d.ts +3 -0
- package/lib/Utils/phone-utils.js +29 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +103 -0
- package/lib/Utils/process-message.js +868 -0
- package/lib/Utils/qr-terminal.d.ts +1 -0
- package/lib/Utils/qr-terminal.js +16 -0
- package/lib/Utils/reconnect-backoff.d.ts +25 -0
- package/lib/Utils/reconnect-backoff.js +47 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +54 -0
- package/lib/Utils/rich-message-utils.js +435 -0
- package/lib/Utils/rich-messages.d.ts +298 -0
- package/lib/Utils/rich-messages.js +1145 -0
- package/lib/Utils/scheduled-message.d.ts +81 -0
- package/lib/Utils/scheduled-message.js +101 -0
- package/lib/Utils/scheduling.d.ts +59 -0
- package/lib/Utils/scheduling.js +139 -0
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/signal.js +200 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/status-stickers.d.ts +79 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/status.d.ts +107 -0
- package/lib/Utils/status.js +131 -0
- package/lib/Utils/sticker-pack-maker.d.ts +20 -0
- package/lib/Utils/sticker-pack-maker.js +112 -0
- package/lib/Utils/stickerpack.d.ts +18 -0
- package/lib/Utils/stickerpack.js +316 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tag.d.ts +8 -0
- package/lib/Utils/tag.js +45 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/Utils/templates.d.ts +86 -0
- package/lib/Utils/templates.js +148 -0
- package/lib/Utils/text-format.d.ts +13 -0
- package/lib/Utils/text-format.js +81 -0
- package/lib/Utils/text-tools.d.ts +3 -0
- package/lib/Utils/text-tools.js +38 -0
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +123 -0
- package/lib/Utils/use-cache-manager-auth-state.d.ts +22 -0
- package/lib/Utils/use-cache-manager-auth-state.js +86 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +20 -0
- package/lib/Utils/use-multi-file-auth-state.js +201 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +111 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +171 -0
- package/lib/Utils/username.d.ts +22 -0
- package/lib/Utils/username.js +59 -0
- package/lib/Utils/validate-connection.d.ts +43 -0
- package/lib/Utils/validate-connection.js +197 -0
- package/lib/Utils/vcard.d.ts +40 -0
- package/lib/Utils/vcard.js +92 -0
- package/lib/Utils/voice-note.d.ts +13 -0
- package/lib/Utils/voice-note.js +47 -0
- package/lib/VoIP/audio-feeder.d.ts +15 -0
- package/lib/VoIP/audio-feeder.js +132 -0
- package/lib/VoIP/index.d.ts +22 -0
- package/lib/VoIP/index.js +277 -0
- package/lib/VoIP/relay-transport.d.ts +16 -0
- package/lib/VoIP/relay-transport.js +559 -0
- package/lib/VoIP/signaling.d.ts +16 -0
- package/lib/VoIP/signaling.js +624 -0
- package/lib/VoIP/types.d.ts +11 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +28 -0
- package/lib/VoIP/wasm-engine.js +1214 -0
- package/lib/VoIP/worker-bootstrap.d.ts +1 -0
- package/lib/VoIP/worker-bootstrap.js +1042 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +45 -0
- package/lib/WABinary/generic-utils.js +285 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +32 -0
- package/lib/WABinary/jid-utils.js +102 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.d.ts +43 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +60 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.d.ts +20 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +23 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +24 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +49 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +12 -0
- package/lib/WAUSync/Protocols/index.js +12 -0
- package/lib/WAUSync/USyncQuery.d.ts +25 -0
- package/lib/WAUSync/USyncQuery.js +140 -0
- package/lib/WAUSync/USyncUser.d.ts +24 -0
- package/lib/WAUSync/USyncUser.js +47 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/exports-extra.d.ts +45 -0
- package/lib/exports-extra.js +47 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +24 -0
- package/package.json +161 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import NodeCache from '@cacheable/node-cache';
|
|
2
|
+
import { areJidsSameUser, getBinaryNodeChild, jidDecode } from '../WABinary/index.js';
|
|
3
|
+
import { isStringNullOrEmpty } from './generics.js';
|
|
4
|
+
export async function handleIdentityChange(node, ctx) {
|
|
5
|
+
const from = node.attrs.from;
|
|
6
|
+
if (!from) {
|
|
7
|
+
return { action: 'invalid_notification' };
|
|
8
|
+
}
|
|
9
|
+
const identityNode = getBinaryNodeChild(node, 'identity');
|
|
10
|
+
if (!identityNode) {
|
|
11
|
+
return { action: 'no_identity_node' };
|
|
12
|
+
}
|
|
13
|
+
ctx.logger.info({ jid: from }, 'identity changed');
|
|
14
|
+
const decoded = jidDecode(from);
|
|
15
|
+
if (decoded?.device && decoded.device !== 0) {
|
|
16
|
+
ctx.logger.debug({ jid: from, device: decoded.device }, 'ignoring identity change from companion device');
|
|
17
|
+
return { action: 'skipped_companion_device', device: decoded.device };
|
|
18
|
+
}
|
|
19
|
+
const isSelfPrimary = ctx.meId && (areJidsSameUser(from, ctx.meId) || (ctx.meLid && areJidsSameUser(from, ctx.meLid)));
|
|
20
|
+
if (isSelfPrimary) {
|
|
21
|
+
ctx.logger.info({ jid: from }, 'self primary identity changed');
|
|
22
|
+
return { action: 'skipped_self_primary' };
|
|
23
|
+
}
|
|
24
|
+
if (ctx.debounceCache.get(from)) {
|
|
25
|
+
ctx.logger.debug({ jid: from }, 'skipping identity assert (debounced)');
|
|
26
|
+
return { action: 'debounced' };
|
|
27
|
+
}
|
|
28
|
+
ctx.debounceCache.set(from, true);
|
|
29
|
+
const isOfflineNotification = !isStringNullOrEmpty(node.attrs.offline);
|
|
30
|
+
const hasExistingSession = await ctx.validateSession(from);
|
|
31
|
+
if (!hasExistingSession.exists) {
|
|
32
|
+
ctx.logger.debug({ jid: from }, 'no old session, skipping session refresh');
|
|
33
|
+
return { action: 'skipped_no_session' };
|
|
34
|
+
}
|
|
35
|
+
ctx.logger.debug({ jid: from }, 'old session exists, will refresh session');
|
|
36
|
+
if (isOfflineNotification) {
|
|
37
|
+
ctx.logger.debug({ jid: from }, 'skipping session refresh during offline processing');
|
|
38
|
+
return { action: 'skipped_offline' };
|
|
39
|
+
}
|
|
40
|
+
ctx.onBeforeSessionRefresh?.(from);
|
|
41
|
+
try {
|
|
42
|
+
await ctx.assertSessions([from], true);
|
|
43
|
+
return { action: 'session_refreshed' };
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
ctx.logger.warn({ error, jid: from }, 'failed to assert sessions after identity change');
|
|
47
|
+
return { action: 'session_refresh_failed', error };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export * from "./generics.js";
|
|
2
|
+
export * from "./decode-wa-message.js";
|
|
3
|
+
export * from "./messages.js";
|
|
4
|
+
export * from "./messages-media.js";
|
|
5
|
+
export * from "./validate-connection.js";
|
|
6
|
+
export * from "./crypto.js";
|
|
7
|
+
export * from "./signal.js";
|
|
8
|
+
export * from "./noise-handler.js";
|
|
9
|
+
export * from "./history.js";
|
|
10
|
+
export * from "./chat-utils.js";
|
|
11
|
+
export * from "./lt-hash.js";
|
|
12
|
+
export * from "./auth-utils.js";
|
|
13
|
+
export * from "./use-multi-file-auth-state.js";
|
|
14
|
+
export * from "./use-single-file-auth-state.js";
|
|
15
|
+
export * from "./use-sqlite-auth-state.js";
|
|
16
|
+
export * from "./link-preview.js";
|
|
17
|
+
export * from "./event-buffer.js";
|
|
18
|
+
export * from "./process-message.js";
|
|
19
|
+
export * from "./group-metadata-cache.js";
|
|
20
|
+
export * from "./username.js";
|
|
21
|
+
export * from "./disconnect-reason.js";
|
|
22
|
+
export * from "./phone-utils.js";
|
|
23
|
+
export * from "./text-tools.js";
|
|
24
|
+
export * from "./pairing-utils.js";
|
|
25
|
+
export * from "./jid-tools.js";
|
|
26
|
+
export * from "./tag.js";
|
|
27
|
+
export * from "./ffmpeg-path.js";
|
|
28
|
+
export * from "./voice-note.js";
|
|
29
|
+
export * from "./text-format.js";
|
|
30
|
+
export * from "./rich-message-utils.js";
|
|
31
|
+
export * from "./PersistentStore.js";
|
|
32
|
+
export * from "./message-kind.js";
|
|
33
|
+
export * from "./message-retry-manager.js";
|
|
34
|
+
export * from "./browser-utils.js";
|
|
35
|
+
export * from "./companion-reg-client-utils.js";
|
|
36
|
+
export * from "./identity-change-handler.js";
|
|
37
|
+
export * from "./stanza-ack.js";
|
|
38
|
+
export * from "./button-helper-utils.js";
|
|
39
|
+
export * from "./button-sender.js";
|
|
40
|
+
export * from "./fetch-timeout.js";
|
|
41
|
+
export * from "./anti-delete.js";
|
|
42
|
+
export * from "./message-search.js";
|
|
43
|
+
export * from "./chat-history-helpers.js";
|
|
44
|
+
export * from "./scheduling.js";
|
|
45
|
+
export * from "./auto-reply.js";
|
|
46
|
+
export * from "./templates.js";
|
|
47
|
+
export * from "./vcard.js";
|
|
48
|
+
export * from "./media-messages.js";
|
|
49
|
+
export * from "./stickerpack.js";
|
|
50
|
+
export * from "./media-set.js";
|
|
51
|
+
export * from "./status.js";
|
|
52
|
+
export * from "./use-cache-manager-auth-state.js";
|
|
53
|
+
export * from "./baileys-event-stream.js";
|
|
54
|
+
export * from "./past-participants.js";
|
|
55
|
+
export * from "./chat-control.js";
|
|
56
|
+
export * from "./payment-utils.js";
|
|
57
|
+
export * from "./native-flow.js";
|
|
58
|
+
export * from "./payment-messages.js";
|
|
59
|
+
export * from "./modern-messages.js";
|
|
60
|
+
export * from "./status-stickers.js";
|
|
61
|
+
export * from "./html-app.js";
|
|
62
|
+
export * from "./newsletter-status.js";
|
|
63
|
+
export * from "./rich-messages.js";
|
|
64
|
+
export * from "./sticker-pack-maker.js";
|
|
65
|
+
export * from "./html-multiplayer.js";
|
|
66
|
+
export * from "./scheduled-message.js";
|
|
67
|
+
export * from "./mini-app.js";
|
|
68
|
+
export * from "./payment-detection.js";
|
|
69
|
+
export * from "./payment-guard.js";
|
|
70
|
+
export * from "./group-status-detection.js";
|
|
71
|
+
export * from "./reconnect-backoff.js";
|
|
72
|
+
export * from "./bad-mac-handler.js";
|
|
73
|
+
export * from "./connection-watchdog.js";
|
|
74
|
+
export * from "./auto-reconnect.js";
|
|
75
|
+
export * from "./humanizer.js";
|
|
76
|
+
export * from "./auth-secure.js";
|
|
77
|
+
export * from "./mock-socket.js";
|
|
78
|
+
export * from "./meta-ai.js";
|
|
79
|
+
export * from "./meta-ai-msmsg.js";
|
|
80
|
+
export * from "./qr-terminal.js";
|
|
81
|
+
export * from "./lock-manager.js";
|
|
82
|
+
export * from "./passkey.js";
|
|
83
|
+
export * from "./migrate-auth-state.js";
|
|
84
|
+
export * from "./android-stanza-id.js";
|
|
85
|
+
export * from "./anchor-guard.js";
|
|
86
|
+
export * from "./media-processor.js";
|
|
87
|
+
export * from "./link-preview-metadata.js";
|
|
88
|
+
export * from "./ttl-cache.js";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export * from './generics.js';
|
|
2
|
+
export * from './decode-wa-message.js';
|
|
3
|
+
export * from './messages.js';
|
|
4
|
+
export * from './messages-media.js';
|
|
5
|
+
export * from './validate-connection.js';
|
|
6
|
+
export * from './crypto.js';
|
|
7
|
+
export * from './signal.js';
|
|
8
|
+
export * from './noise-handler.js';
|
|
9
|
+
export * from './history.js';
|
|
10
|
+
export * from './chat-utils.js';
|
|
11
|
+
export * from './lt-hash.js';
|
|
12
|
+
export * from './auth-utils.js';
|
|
13
|
+
export * from './use-multi-file-auth-state.js';
|
|
14
|
+
export * from './use-single-file-auth-state.js';
|
|
15
|
+
export * from './use-sqlite-auth-state.js';
|
|
16
|
+
export * from './link-preview.js';
|
|
17
|
+
export * from './event-buffer.js';
|
|
18
|
+
export * from './process-message.js';
|
|
19
|
+
export * from './group-metadata-cache.js';
|
|
20
|
+
export * from './username.js';
|
|
21
|
+
export * from './disconnect-reason.js';
|
|
22
|
+
export * from './phone-utils.js';
|
|
23
|
+
export * from './text-tools.js';
|
|
24
|
+
export * from './pairing-utils.js';
|
|
25
|
+
export * from './jid-tools.js';
|
|
26
|
+
export * from './tag.js';
|
|
27
|
+
export * from './ffmpeg-path.js';
|
|
28
|
+
export * from './voice-note.js';
|
|
29
|
+
export * from './text-format.js';
|
|
30
|
+
export * from './rich-message-utils.js';
|
|
31
|
+
export * from './PersistentStore.js';
|
|
32
|
+
export * from './message-kind.js';
|
|
33
|
+
export * from './message-retry-manager.js';
|
|
34
|
+
export * from './browser-utils.js';
|
|
35
|
+
export * from './companion-reg-client-utils.js';
|
|
36
|
+
export * from './identity-change-handler.js';
|
|
37
|
+
export * from './stanza-ack.js';
|
|
38
|
+
export * from './button-helper-utils.js';
|
|
39
|
+
export * from './button-sender.js';
|
|
40
|
+
export * from './fetch-timeout.js';
|
|
41
|
+
export * from './anti-delete.js';
|
|
42
|
+
export * from './message-search.js';
|
|
43
|
+
export * from './chat-history-helpers.js';
|
|
44
|
+
export * from './scheduling.js';
|
|
45
|
+
export * from './auto-reply.js';
|
|
46
|
+
export * from './templates.js';
|
|
47
|
+
export * from './vcard.js';
|
|
48
|
+
export * from './media-messages.js';
|
|
49
|
+
export * from './stickerpack.js';
|
|
50
|
+
export * from './media-set.js';
|
|
51
|
+
export * from './status.js';
|
|
52
|
+
export * from './use-cache-manager-auth-state.js';
|
|
53
|
+
export * from './baileys-event-stream.js';
|
|
54
|
+
export * from './past-participants.js';
|
|
55
|
+
export * from './chat-control.js';
|
|
56
|
+
export * from './payment-utils.js';
|
|
57
|
+
// Vanz@Port (v2.1.6) --- ports from reference forks (elaina/vinzsocket/blurose/japofc/lpzeravk)
|
|
58
|
+
export * from './native-flow.js';
|
|
59
|
+
export * from './payment-messages.js';
|
|
60
|
+
export * from './modern-messages.js';
|
|
61
|
+
export * from './status-stickers.js';
|
|
62
|
+
export * from './html-app.js';
|
|
63
|
+
export * from './newsletter-status.js';
|
|
64
|
+
export * from './rich-messages.js';
|
|
65
|
+
export * from './sticker-pack-maker.js';
|
|
66
|
+
export * from './html-multiplayer.js';
|
|
67
|
+
export * from './scheduled-message.js';
|
|
68
|
+
export * from './mini-app.js';
|
|
69
|
+
export * from './payment-detection.js';
|
|
70
|
+
export * from './payment-guard.js';
|
|
71
|
+
export * from './group-status-detection.js';
|
|
72
|
+
// Vanz@Port (v2.1.14) --- stability helpers from lpzeravk/systemzero
|
|
73
|
+
export * from './reconnect-backoff.js';
|
|
74
|
+
export * from './bad-mac-handler.js';
|
|
75
|
+
export * from './connection-watchdog.js';
|
|
76
|
+
// Vanz@Port (v2.0.3) --- japofc: auto-reconnect manager, humanized sender, encrypted auth state + security pack, offline mock socket
|
|
77
|
+
export * from './auto-reconnect.js';
|
|
78
|
+
export * from './humanizer.js';
|
|
79
|
+
export * from './auth-secure.js';
|
|
80
|
+
export * from './mock-socket.js';
|
|
81
|
+
export * from './meta-ai.js';
|
|
82
|
+
export * from './meta-ai-msmsg.js';
|
|
83
|
+
export * from './qr-terminal.js';
|
|
84
|
+
export * from './lock-manager.js';
|
|
85
|
+
export * from './passkey.js';
|
|
86
|
+
export * from './migrate-auth-state.js';
|
|
87
|
+
export * from './android-stanza-id.js';
|
|
88
|
+
|
|
89
|
+
// Vanz@Port (0.0.1) --- from rennzsync/elaina references
|
|
90
|
+
export * from './anchor-guard.js';
|
|
91
|
+
export * from './media-processor.js';
|
|
92
|
+
export * from './link-preview-metadata.js';
|
|
93
|
+
export * from './ttl-cache.js';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Vanz@Port (2.0.3) --- from @japofc/baileys 2.4.1 (MIT, author JAPofc / J.AP), lib/Utils/jid-tools.js. See NOTICE.md.
|
|
2
|
+
/**
|
|
3
|
+
* JAP@Add --- JID helpers: LID ↔ phone-number resolution.
|
|
4
|
+
*
|
|
5
|
+
* Since WhatsApp's LID migration, events (call offers, group updates, ...) often
|
|
6
|
+
* carry only an opaque `@lid` JID. These helpers resolve it to a phone number
|
|
7
|
+
* through the socket's signal-repository mapping (cached + USYNC-backed).
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* await getPhoneNumber(sock, '123456@lid') // → '62812xxxx' | null
|
|
11
|
+
* await getLidForPhone(sock, '62812xxxx') // → '123456@lid' | null
|
|
12
|
+
* // or: sock.getPhoneNumber(jid), sock.getLidForPhone(phone)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import { Boom } from '@hapi/boom';
|
|
16
|
+
import { jidDecode } from '../WABinary/index.js';
|
|
17
|
+
/** Resolve any JID to a phone-number string. Returns `null` when unresolvable (never throws for that). */
|
|
18
|
+
export const getPhoneNumber = async (sock, jid) => {
|
|
19
|
+
if (typeof jid !== 'string' || !jid.includes('@')) {
|
|
20
|
+
throw new Boom('getPhoneNumber(jid) requires a JID string', { statusCode: 400 });
|
|
21
|
+
}
|
|
22
|
+
let decoded;
|
|
23
|
+
try {
|
|
24
|
+
decoded = jidDecode(jid);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw new Boom(`getPhoneNumber: invalid JID ${jid}`, { statusCode: 400 });
|
|
28
|
+
}
|
|
29
|
+
const { user, server } = decoded;
|
|
30
|
+
if (server === 's.whatsapp.net') {
|
|
31
|
+
return user;
|
|
32
|
+
}
|
|
33
|
+
if (server === 'lid') {
|
|
34
|
+
const store = sock?.signalRepository?.lidMapping;
|
|
35
|
+
if (!store || typeof store.getPNForLID !== 'function') {
|
|
36
|
+
throw new Boom('getPhoneNumber: LID resolution needs an active socket', { statusCode: 400 });
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const pn = await store.getPNForLID(`${user}@lid`);
|
|
40
|
+
return typeof pn === 'string' && pn.includes('@') ? pn.split('@')[0] : null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null; // best-effort: offline/USYNC failure → unknown, not fatal
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null; // groups, channels, status, bots have no phone number
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Resolve an incoming message's sender to a phone number.
|
|
50
|
+
* One-liner fix for LID-only events (e.g. call offers without `caller_pn`):
|
|
51
|
+
* `await sock.resolveSenderPn(msg)` → `'62812…'` | `null`.
|
|
52
|
+
*/
|
|
53
|
+
export const resolveSenderPn = async (sock, webMessage) => {
|
|
54
|
+
const sender = webMessage?.key?.participant || webMessage?.key?.remoteJid;
|
|
55
|
+
if (!sender || typeof sender !== 'string') {
|
|
56
|
+
throw new Boom('resolveSenderPn(msg) needs a message with key.participant/remoteJid', { statusCode: 400 });
|
|
57
|
+
}
|
|
58
|
+
return getPhoneNumber(sock, sender);
|
|
59
|
+
};
|
|
60
|
+
/** Reverse lookup: phone number (or PN JID) → `@lid` JID. Returns `null` when unknown. */
|
|
61
|
+
export const getLidForPhone = async (sock, phone) => {
|
|
62
|
+
const store = sock?.signalRepository?.lidMapping;
|
|
63
|
+
if (!store || typeof store.getLIDForPN !== 'function') {
|
|
64
|
+
throw new Boom('getLidForPhone(sock, ...) requires an active socket', { statusCode: 400 });
|
|
65
|
+
}
|
|
66
|
+
const pn = typeof phone === 'string' && phone.includes('@')
|
|
67
|
+
? phone
|
|
68
|
+
: `${String(phone || '').replace(/\D/g, '')}@s.whatsapp.net`;
|
|
69
|
+
if (!pn.split('@')[0]) {
|
|
70
|
+
throw new Boom('getLidForPhone(phone) requires a phone number', { statusCode: 400 });
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return (await store.getLIDForPN(pn)) || null;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto/index.js';
|
|
2
|
+
|
|
3
|
+
export declare const SocialMediaPostType: Readonly<{
|
|
4
|
+
NONE: 0;
|
|
5
|
+
REEL: 1;
|
|
6
|
+
LIVE_VIDEO: 2;
|
|
7
|
+
LONG_VIDEO: 3;
|
|
8
|
+
SINGLE_IMAGE: 4;
|
|
9
|
+
CAROUSEL: 5;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export declare function videoEndCard(options?: {
|
|
13
|
+
username?: string;
|
|
14
|
+
caption?: string;
|
|
15
|
+
thumbnailUrl?: string;
|
|
16
|
+
profilePictureUrl?: string;
|
|
17
|
+
}): proto.Message.IVideoEndCard;
|
|
18
|
+
|
|
19
|
+
export interface SocialPreviewOptions {
|
|
20
|
+
postType?: number;
|
|
21
|
+
videoUrl?: string;
|
|
22
|
+
videoCaption?: string;
|
|
23
|
+
muted?: boolean;
|
|
24
|
+
/** Seconds, not milliseconds — the client stores link_media_duration_seconds. */
|
|
25
|
+
durationSeconds?: number;
|
|
26
|
+
experimentId?: number;
|
|
27
|
+
music?: proto.IEmbeddedMusic;
|
|
28
|
+
endCards?: proto.Message.IVideoEndCard[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare function buildSocialPreview(options?: SocialPreviewOptions): {
|
|
32
|
+
linkPreviewMetadata?: proto.Message.ILinkPreviewMetadata;
|
|
33
|
+
videoContentUrl?: string;
|
|
34
|
+
musicMetadata?: proto.IEmbeddedMusic;
|
|
35
|
+
endCardTiles?: proto.Message.IVideoEndCard[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export declare function readSocialPreview(msg: any): {
|
|
39
|
+
postType?: number;
|
|
40
|
+
durationSeconds?: number;
|
|
41
|
+
muted?: boolean;
|
|
42
|
+
videoUrl?: string;
|
|
43
|
+
videoCaption?: string;
|
|
44
|
+
music?: proto.IEmbeddedMusic;
|
|
45
|
+
experimentId?: number;
|
|
46
|
+
endCards?: proto.Message.IVideoEndCard[];
|
|
47
|
+
} | null;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Ported into @vanzxysenpai/baileys 0.0.1 from @rexxhayanasi/elaina-baileys 1.4.7, MIT. See NOTICE.md.
|
|
2
|
+
/* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
|
|
3
|
+
|
|
4
|
+
export const SocialMediaPostType = Object.freeze({
|
|
5
|
+
NONE: 0,
|
|
6
|
+
REEL: 1,
|
|
7
|
+
LIVE_VIDEO: 2,
|
|
8
|
+
LONG_VIDEO: 3,
|
|
9
|
+
SINGLE_IMAGE: 4,
|
|
10
|
+
CAROUSEL: 5
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const drop = (object) => {
|
|
14
|
+
for (const key of Object.keys(object)) {
|
|
15
|
+
if (object[key] === undefined || object[key] === null) {
|
|
16
|
+
delete object[key]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return object
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const videoEndCard = ({ username, caption, thumbnailUrl, profilePictureUrl } = {}) =>
|
|
23
|
+
drop({
|
|
24
|
+
username,
|
|
25
|
+
caption,
|
|
26
|
+
thumbnailImageUrl: thumbnailUrl,
|
|
27
|
+
profilePictureUrl
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The same video url and music node exist twice, once nested in
|
|
32
|
+
* LinkPreviewMetadata and once directly on ExtendedTextMessage. Which one the
|
|
33
|
+
* client reads is not visible from the client, so both carry the same value.
|
|
34
|
+
*/
|
|
35
|
+
export const buildSocialPreview = ({
|
|
36
|
+
postType,
|
|
37
|
+
videoUrl,
|
|
38
|
+
videoCaption,
|
|
39
|
+
muted,
|
|
40
|
+
durationSeconds,
|
|
41
|
+
experimentId,
|
|
42
|
+
music,
|
|
43
|
+
endCards
|
|
44
|
+
} = {}) => {
|
|
45
|
+
if (postType !== undefined && !Object.values(SocialMediaPostType).includes(postType)) {
|
|
46
|
+
throw new TypeError(`postType ${postType} is not one of ${Object.keys(SocialMediaPostType).join(', ')}`)
|
|
47
|
+
}
|
|
48
|
+
if (durationSeconds !== undefined && (!Number.isFinite(Number(durationSeconds)) || Number(durationSeconds) < 0)) {
|
|
49
|
+
throw new TypeError('durationSeconds must be a non-negative number of seconds, not milliseconds')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const metadata = drop({
|
|
53
|
+
socialMediaPostType: postType,
|
|
54
|
+
linkMediaDuration: durationSeconds === undefined ? undefined : Math.round(Number(durationSeconds)),
|
|
55
|
+
linkInlineVideoMuted: muted === undefined ? undefined : !!muted,
|
|
56
|
+
videoContentUrl: videoUrl,
|
|
57
|
+
videoContentCaption: videoCaption,
|
|
58
|
+
musicMetadata: music,
|
|
59
|
+
fbExperimentId: experimentId
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return drop({
|
|
63
|
+
linkPreviewMetadata: Object.keys(metadata).length ? metadata : undefined,
|
|
64
|
+
videoContentUrl: videoUrl,
|
|
65
|
+
musicMetadata: music,
|
|
66
|
+
endCardTiles: endCards?.length ? endCards : undefined
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const readSocialPreview = (msg) => {
|
|
71
|
+
const message = msg?.message ?? msg
|
|
72
|
+
const text = message?.extendedTextMessage
|
|
73
|
+
if (!text) {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
const metadata = text.linkPreviewMetadata
|
|
77
|
+
if (!metadata && !text.endCardTiles?.length && !text.videoContentUrl) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
return drop({
|
|
81
|
+
postType: metadata?.socialMediaPostType,
|
|
82
|
+
durationSeconds: metadata?.linkMediaDuration,
|
|
83
|
+
muted: metadata?.linkInlineVideoMuted,
|
|
84
|
+
videoUrl: metadata?.videoContentUrl ?? text.videoContentUrl,
|
|
85
|
+
videoCaption: metadata?.videoContentCaption,
|
|
86
|
+
music: metadata?.musicMetadata ?? text.musicMetadata,
|
|
87
|
+
experimentId: metadata?.fbExperimentId,
|
|
88
|
+
endCards: text.endCardTiles?.length ? text.endCardTiles : undefined
|
|
89
|
+
})
|
|
90
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
let 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
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { makeKeyedMutex } from './make-mutex.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deterministic multi-key locking built on the existing keyed mutex.
|
|
5
|
+
* Locks are sorted before acquisition so overlapping multi-lock operations
|
|
6
|
+
* cannot deadlock because callers supplied keys in different orders.
|
|
7
|
+
*/
|
|
8
|
+
const refKey = ({ namespace, id }) => `${String(namespace)}\0${String(id)}`;
|
|
9
|
+
const compareRefs = (a, b) => refKey(a).localeCompare(refKey(b));
|
|
10
|
+
|
|
11
|
+
export const makeLockManager = () => {
|
|
12
|
+
const keyed = makeKeyedMutex();
|
|
13
|
+
const held = new Map();
|
|
14
|
+
const mark = (key, delta) => {
|
|
15
|
+
const next = (held.get(key) || 0) + delta;
|
|
16
|
+
if (next > 0) held.set(key, next);
|
|
17
|
+
else held.delete(key);
|
|
18
|
+
};
|
|
19
|
+
const withOne = async (ref, work) => {
|
|
20
|
+
if (!ref || ref.namespace == null || ref.id == null) throw new TypeError('lock ref requires namespace and id');
|
|
21
|
+
if (typeof work !== 'function') throw new TypeError('lock work must be a function');
|
|
22
|
+
const key = refKey(ref);
|
|
23
|
+
return keyed.mutex(key, async () => {
|
|
24
|
+
mark(key, 1);
|
|
25
|
+
try { return await work(); }
|
|
26
|
+
finally { mark(key, -1); }
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
withLock: withOne,
|
|
31
|
+
withLocks(refs, work) {
|
|
32
|
+
if (!Array.isArray(refs)) throw new TypeError('refs must be an array');
|
|
33
|
+
if (typeof work !== 'function') throw new TypeError('lock work must be a function');
|
|
34
|
+
const unique = new Map();
|
|
35
|
+
for (const ref of refs) {
|
|
36
|
+
if (!ref || ref.namespace == null || ref.id == null) throw new TypeError('lock ref requires namespace and id');
|
|
37
|
+
unique.set(refKey(ref), ref);
|
|
38
|
+
}
|
|
39
|
+
const sorted = [...unique.values()].sort(compareRefs);
|
|
40
|
+
const acquire = (i) => i >= sorted.length
|
|
41
|
+
? Promise.resolve().then(work)
|
|
42
|
+
: withOne(sorted[i], () => acquire(i + 1));
|
|
43
|
+
return acquire(0);
|
|
44
|
+
},
|
|
45
|
+
isLocked(ref) {
|
|
46
|
+
if (!ref || ref.namespace == null || ref.id == null) return false;
|
|
47
|
+
return held.has(refKey(ref));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
3
|
+
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
4
|
+
* if the same series of mutations was made sequentially.
|
|
5
|
+
*
|
|
6
|
+
* whatsapp-rust-bridge is a native module and was previously
|
|
7
|
+
* statically imported here, which crashed the *entire* library at import time on platforms
|
|
8
|
+
* without a prebuilt binary (ARM musl/Alpine/Termux/some Pterodactyl nodes) — even for bots
|
|
9
|
+
* that never touch app-state sync. Same top-level-await try/catch pattern as crypto.js:
|
|
10
|
+
* only throws (with a clear message) if app-state sync (LT hash) is actually used.
|
|
11
|
+
*/
|
|
12
|
+
export let LT_HASH_ANTI_TAMPERING: any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
3
|
+
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
4
|
+
* if the same series of mutations was made sequentially.
|
|
5
|
+
*
|
|
6
|
+
* whatsapp-rust-bridge is a native module and was previously
|
|
7
|
+
* statically imported here, which crashed the *entire* library at import time on platforms
|
|
8
|
+
* without a prebuilt binary (ARM musl/Alpine/Termux/some Pterodactyl nodes) — even for bots
|
|
9
|
+
* that never touch app-state sync. Same top-level-await try/catch pattern as crypto.js:
|
|
10
|
+
* only throws (with a clear message) if app-state sync (LT hash) is actually used.
|
|
11
|
+
*/
|
|
12
|
+
let LT_HASH_ANTI_TAMPERING;
|
|
13
|
+
try {
|
|
14
|
+
const { LTHashAntiTampering } = await import('whatsapp-rust-bridge');
|
|
15
|
+
LT_HASH_ANTI_TAMPERING = new LTHashAntiTampering();
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
const message = '`whatsapp-rust-bridge` failed to load (no prebuilt binary for this platform/arch). ' +
|
|
19
|
+
'App-state sync (LT hash) is unavailable here. Original error: ' + (err?.message || err);
|
|
20
|
+
LT_HASH_ANTI_TAMPERING = new Proxy({}, {
|
|
21
|
+
get() {
|
|
22
|
+
throw new Error(message);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { LT_HASH_ANTI_TAMPERING };
|