@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,132 @@
|
|
|
1
|
+
// Vanz@Port (v2.0.3) --- ported from @nexustechpro/baileys 2.2.7 (MIT, Copyright (c) 2026 nexustechpro2), lib/Utils/meta-ai-msmsg.js. See NOTICE.md.
|
|
2
|
+
//
|
|
3
|
+
// EXPERIMENTAL / NOT WIRED INTO THE SOCKET. These are pure helpers only. Two reasons this is not hooked into
|
|
4
|
+
// messages-recv.js:
|
|
5
|
+
// 1. The `messageKey` field names (botEditTargetId, targetId, ...) and the HKDF `info`/AAD layout come from the
|
|
6
|
+
// source fork and are unverified against a real Meta AI `msmsg` stanza.
|
|
7
|
+
// 2. nexustech feeds `authState.creds.myAppStateKeyId` in as the message secret, which is an app-state key ID and
|
|
8
|
+
// not a per-message secret (that would be `messageContextInfo.messageSecret` of the message you sent).
|
|
9
|
+
// Use them to experiment with a secret you obtained yourself; the socket still NACKs `msmsg` as before.
|
|
10
|
+
import { hkdf, aesDecryptGCM } from './crypto.js'
|
|
11
|
+
import { unpadRandomMax16 } from './generics.js'
|
|
12
|
+
import { jidNormalizedUser } from '../WABinary/index.js'
|
|
13
|
+
import { proto } from '../../WAProto/index.js'
|
|
14
|
+
|
|
15
|
+
const BOT_MESSAGE_INFO = 'Bot Message'
|
|
16
|
+
const KEY_LENGTH = 32
|
|
17
|
+
const AUTH_TAG_LENGTH = 16
|
|
18
|
+
const MSG_ID_HEX_RE = /^[0-9A-Fa-f]{32}$/
|
|
19
|
+
|
|
20
|
+
const toBuffer = value => {
|
|
21
|
+
if (Buffer.isBuffer(value)) return value
|
|
22
|
+
if (value instanceof Uint8Array) return Buffer.from(value.buffer, value.byteOffset, value.byteLength)
|
|
23
|
+
return Buffer.from(value)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const buildMessageIdRepresentations = messageId => {
|
|
27
|
+
const ascii = Buffer.from(messageId)
|
|
28
|
+
const binary = MSG_ID_HEX_RE.test(messageId) ? Buffer.from(messageId, 'hex') : ascii
|
|
29
|
+
return [{ label: 'msgIdAscii', value: ascii }, ...(binary.equals(ascii) ? [] : [{ label: 'msgIdBinary', value: binary }])]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const pushUnique = (items, seen, item) => {
|
|
33
|
+
const key = JSON.stringify([item.messageId, item.idSource, item.idSources, item.infoSource, item.aadSource, item.info.toString('hex'), item.aad.toString('hex')])
|
|
34
|
+
if (!seen.has(key)) { seen.add(key); items.push(item) }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getCandidateIds = messageKey => {
|
|
38
|
+
const ordered = [
|
|
39
|
+
messageKey?.botType === 'full' ? { source: 'stanzaId', messageId: messageKey?.stanzaId } : { source: 'botEditTargetId', messageId: messageKey?.botEditTargetId },
|
|
40
|
+
{ source: 'targetId', messageId: messageKey?.targetId },
|
|
41
|
+
{ source: 'metaTargetId', messageId: messageKey?.metaTargetId },
|
|
42
|
+
{ source: 'stanzaId', messageId: messageKey?.stanzaId }
|
|
43
|
+
]
|
|
44
|
+
const candidates = Array.isArray(messageKey?.targetIdCandidates) ? messageKey.targetIdCandidates : []
|
|
45
|
+
for (let i = 0; i < candidates.length; i++) ordered.push({ source: `targetIdCandidates[${i}]`, messageId: candidates[i] })
|
|
46
|
+
const grouped = new Map()
|
|
47
|
+
for (const c of ordered) {
|
|
48
|
+
if (!c.messageId) continue
|
|
49
|
+
const id = String(c.messageId)
|
|
50
|
+
const existing = grouped.get(id)
|
|
51
|
+
if (existing) { if (!existing.idSources.includes(c.source)) existing.idSources.push(c.source) }
|
|
52
|
+
else grouped.set(id, { messageId: id, idSource: c.source, idSources: [c.source] })
|
|
53
|
+
}
|
|
54
|
+
return Array.from(grouped.values())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const getJidCandidates = messageKey => {
|
|
58
|
+
const ordered = [
|
|
59
|
+
{ source: 'meId', jid: messageKey?.meId },
|
|
60
|
+
{ source: 'conversationJid', jid: messageKey?.conversationJid },
|
|
61
|
+
{ source: 'senderJid', jid: messageKey?.senderJid },
|
|
62
|
+
{ source: 'meLidNormalized', jid: jidNormalizedUser(messageKey?.meLid) }
|
|
63
|
+
]
|
|
64
|
+
const seen = new Set()
|
|
65
|
+
const result = []
|
|
66
|
+
for (const c of ordered) {
|
|
67
|
+
if (!c.jid) continue
|
|
68
|
+
const jid = String(c.jid)
|
|
69
|
+
if (!seen.has(jid)) { seen.add(jid); result.push({ source: c.source, jid, value: Buffer.from(jid) }) }
|
|
70
|
+
}
|
|
71
|
+
return result
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const buildMsmsgDecryptionStrategies = messageKey => {
|
|
75
|
+
const botJid = String(messageKey?.participant || '')
|
|
76
|
+
const botJidBuffer = Buffer.from(botJid)
|
|
77
|
+
const targetIds = getCandidateIds(messageKey)
|
|
78
|
+
const jidCandidates = getJidCandidates(messageKey)
|
|
79
|
+
const primaryJid = jidCandidates[0]
|
|
80
|
+
const alternateJid = jidCandidates.find(c => c.source !== primaryJid?.source && c.jid !== botJid)
|
|
81
|
+
const strategies = [], seen = new Set()
|
|
82
|
+
for (const idCandidate of targetIds) {
|
|
83
|
+
for (const idForm of buildMessageIdRepresentations(idCandidate.messageId)) {
|
|
84
|
+
pushUnique(strategies, seen, { mode: '2step', idSource: idCandidate.idSource, idSources: idCandidate.idSources, infoSource: `${idForm.label}+meId+botJid`, aadSource: `${idForm.label}+0+botJid`, authTagLayout: 'trailing', messageId: idCandidate.messageId, info: Buffer.concat([idForm.value, primaryJid.value, botJidBuffer, Buffer.alloc(0)]), aad: Buffer.concat([idForm.value, Buffer.from([0]), botJidBuffer]), attemptLabel: `${idCandidate.idSource}:${idForm.label}:primary` })
|
|
85
|
+
if (alternateJid) pushUnique(strategies, seen, { mode: '2step', idSource: idCandidate.idSource, idSources: idCandidate.idSources, infoSource: `${idForm.label}+${alternateJid.source}+botJid`, aadSource: `${idForm.label}+0+${alternateJid.source}`, authTagLayout: 'trailing', messageId: idCandidate.messageId, info: Buffer.concat([idForm.value, alternateJid.value, botJidBuffer, Buffer.alloc(0)]), aad: Buffer.concat([idForm.value, Buffer.from([0]), alternateJid.value]), attemptLabel: `${idCandidate.idSource}:${idForm.label}:${alternateJid.source}` })
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return strategies.slice(0, 12)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const assertRequired = (value, label) => {
|
|
92
|
+
if (!value || (Buffer.isBuffer(value) && value.length === 0) || (value instanceof Uint8Array && value.byteLength === 0)) throw new Error(`Missing required ${label} for msmsg decryption`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const decryptWithStrategy = (messageSecret, msMsg, strategy) => {
|
|
96
|
+
const baseSecret = Buffer.from(hkdf(toBuffer(messageSecret), KEY_LENGTH, { info: BOT_MESSAGE_INFO }))
|
|
97
|
+
const key = Buffer.from(hkdf(baseSecret, KEY_LENGTH, { info: strategy.info }))
|
|
98
|
+
const payload = toBuffer(msMsg.encPayload)
|
|
99
|
+
const ciphertextWithTag = Buffer.concat([payload.slice(0, -AUTH_TAG_LENGTH), payload.slice(-AUTH_TAG_LENGTH)])
|
|
100
|
+
return Buffer.from(aesDecryptGCM(ciphertextWithTag, key, toBuffer(msMsg.encIv), strategy.aad))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const decodeDecryptedMsmsgMessage = decrypted => {
|
|
104
|
+
const messageBuffer = toBuffer(decrypted)
|
|
105
|
+
try {
|
|
106
|
+
const unpadded = Buffer.from(unpadRandomMax16(messageBuffer))
|
|
107
|
+
const decoded = proto.Message.decode(unpadded)
|
|
108
|
+
const hasContent = Object.keys(decoded).some(key => key !== 'messageContextInfo' && decoded[key] != null)
|
|
109
|
+
if (hasContent) return decoded
|
|
110
|
+
} catch { }
|
|
111
|
+
return proto.Message.decode(messageBuffer)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const decryptMsmsgBotMessage = async (messageSecret, messageKey, msMsg) => {
|
|
115
|
+
assertRequired(messageSecret, 'messageSecret')
|
|
116
|
+
assertRequired(messageKey?.participant, 'participant')
|
|
117
|
+
assertRequired(messageKey?.meId, 'meId')
|
|
118
|
+
assertRequired(msMsg?.encIv, 'encIv')
|
|
119
|
+
assertRequired(msMsg?.encPayload, 'encPayload')
|
|
120
|
+
if (getCandidateIds(messageKey).length === 0) throw new Error('Missing required target message id for msmsg decryption')
|
|
121
|
+
const strategies = buildMsmsgDecryptionStrategies(messageKey)
|
|
122
|
+
const attemptedStrategies = []
|
|
123
|
+
let lastError
|
|
124
|
+
for (const strategy of strategies) {
|
|
125
|
+
try { return decryptWithStrategy(messageSecret, msMsg, strategy) }
|
|
126
|
+
catch (error) { attemptedStrategies.push({ idSource: strategy.idSource, idSources: strategy.idSources, infoSource: strategy.infoSource, aadSource: strategy.aadSource, messageId: strategy.messageId }); lastError = error }
|
|
127
|
+
}
|
|
128
|
+
const error = new Error('Failed to decrypt msmsg with bounded deterministic strategies')
|
|
129
|
+
error.attemptedStrategies = attemptedStrategies
|
|
130
|
+
error.cause = lastError
|
|
131
|
+
throw error
|
|
132
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Vanz@Port (v2.0.3) --- ported from @japofc/baileys 2.4.1 (MIT, author JAPofc / J.AP), lib/Utils/meta-ai.js. See NOTICE.md.
|
|
2
|
+
/**
|
|
3
|
+
* JAP@Add --- Meta AI chat helper (EXPERIMENTAL).
|
|
4
|
+
*
|
|
5
|
+
* Sends a prompt to Meta AI's official JID (`13135550002@c.us`, override via
|
|
6
|
+
* `opts.jid` — e.g. the newer `11111111111@bot`) and waits for its reply.
|
|
7
|
+
* This relies on Meta AI being available for the linked account/region —
|
|
8
|
+
* expect timeouts where Meta AI is not rolled out.
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* const { text } = await askMetaAI(sock, 'Jelaskan black hole!')
|
|
12
|
+
* // or: await sock.askMetaAI('...')
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import { Boom } from '@hapi/boom';
|
|
16
|
+
import { META_AI_JID } from '../WABinary/index.js';
|
|
17
|
+
import { normalizeMessageContent } from './messages.js';
|
|
18
|
+
const extractReplyText = (webMessage) => {
|
|
19
|
+
if (!webMessage?.message) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
const content = normalizeMessageContent(webMessage.message);
|
|
23
|
+
return content?.conversation
|
|
24
|
+
|| content?.extendedTextMessage?.text
|
|
25
|
+
|| content?.imageMessage?.caption
|
|
26
|
+
|| content?.videoMessage?.caption
|
|
27
|
+
|| '';
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Ask Meta AI something. Resolves `{ sent, reply, text }`.
|
|
31
|
+
* Rejects with 408 on timeout (default 60s).
|
|
32
|
+
*/
|
|
33
|
+
export const askMetaAI = async (sock, prompt, { timeoutMs = 60000, jid = META_AI_JID } = {}) => {
|
|
34
|
+
if (!sock || typeof sock.sendMessage !== 'function' || typeof sock.ev?.on !== 'function') {
|
|
35
|
+
throw new Boom('askMetaAI(sock, ...) requires an active Baileys socket', { statusCode: 400 });
|
|
36
|
+
}
|
|
37
|
+
if (!prompt || typeof prompt !== 'string') {
|
|
38
|
+
throw new Boom('askMetaAI(prompt) requires a non-empty string', { statusCode: 400 });
|
|
39
|
+
}
|
|
40
|
+
const sent = await sock.sendMessage(jid, { text: prompt });
|
|
41
|
+
const sentId = sent?.key?.id;
|
|
42
|
+
const startedAt = Date.now();
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const done = (fn) => (...args) => {
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
try {
|
|
47
|
+
sock.ev.off('messages.upsert', onUpsert);
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
fn(...args);
|
|
51
|
+
};
|
|
52
|
+
const timer = setTimeout(done(() => reject(new Boom('askMetaAI: timed out waiting for Meta AI reply', { statusCode: 408 }))), timeoutMs);
|
|
53
|
+
const succeed = done(resolve);
|
|
54
|
+
const onUpsert = ({ messages } = {}) => {
|
|
55
|
+
for (const m of messages || []) {
|
|
56
|
+
if (!m || m.key?.fromMe || m.key?.remoteJid !== jid || !m.message) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// Ignore stale history replayed on (re)connect.
|
|
60
|
+
const msgMs = Number(m.messageTimestamp || 0) * 1000;
|
|
61
|
+
if (msgMs && msgMs < startedAt - 5000) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Prefer a reply that quotes our prompt; otherwise take the first fresh message.
|
|
65
|
+
const quotedId = m.message?.extendedTextMessage?.contextInfo?.stanzaId;
|
|
66
|
+
if (quotedId && sentId && quotedId !== sentId) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
succeed({ sent, reply: m, text: extractReplyText(m) });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
sock.ev.on('messages.upsert', onUpsert);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function migrateAuthState(opts1: { [key: string]: any;
|
|
2
|
+
from: any;
|
|
3
|
+
to: any;
|
|
4
|
+
batchSize?: number;
|
|
5
|
+
skipExisting?: boolean;
|
|
6
|
+
logger: any;
|
|
7
|
+
verify?: boolean;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
creds: {
|
|
10
|
+
copied: boolean;
|
|
11
|
+
};
|
|
12
|
+
counts: {};
|
|
13
|
+
verified: boolean;
|
|
14
|
+
warnings: any[];
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Full AuthenticationState migration helper.
|
|
18
|
+
*
|
|
19
|
+
* Adapted from the MIT-licensed WhiskeySockets/Baileys migration utility.
|
|
20
|
+
* Vanzxy version is intentionally JS/runtime-focused and only relies on the
|
|
21
|
+
* optional list/listIds methods added to SignalKeyStore.
|
|
22
|
+
*/
|
|
23
|
+
export const ALL_TYPES: string[];
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full AuthenticationState migration helper.
|
|
3
|
+
*
|
|
4
|
+
* Adapted from the MIT-licensed WhiskeySockets/Baileys migration utility.
|
|
5
|
+
* Vanzxy version is intentionally JS/runtime-focused and only relies on the
|
|
6
|
+
* optional list/listIds methods added to SignalKeyStore.
|
|
7
|
+
*/
|
|
8
|
+
const ALL_TYPES = [
|
|
9
|
+
'pre-key',
|
|
10
|
+
'session',
|
|
11
|
+
'sender-key',
|
|
12
|
+
'sender-key-memory',
|
|
13
|
+
'app-state-sync-key',
|
|
14
|
+
'app-state-sync-version',
|
|
15
|
+
'lid-mapping',
|
|
16
|
+
'device-list',
|
|
17
|
+
'tctoken',
|
|
18
|
+
'identity-key'
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export async function migrateAuthState({ from, to, batchSize = 100, skipExisting = true, logger, verify = true }) {
|
|
22
|
+
if (!from?.keys?.list && !from?.keys?.listIds) {
|
|
23
|
+
throw new Error('migrateAuthState: source store does not implement list(type) or listIds(type)');
|
|
24
|
+
}
|
|
25
|
+
if (!to?.keys?.set) {
|
|
26
|
+
throw new Error('migrateAuthState: destination store does not implement set(data)');
|
|
27
|
+
}
|
|
28
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
29
|
+
throw new TypeError('migrateAuthState: batchSize must be a positive integer');
|
|
30
|
+
}
|
|
31
|
+
const result = { creds: { copied: false }, counts: {}, verified: false, warnings: [] };
|
|
32
|
+
Object.assign(to.creds, from.creds);
|
|
33
|
+
result.creds.copied = true;
|
|
34
|
+
logger?.info?.('migrateAuthState: creds copied');
|
|
35
|
+
|
|
36
|
+
for (const type of ALL_TYPES) {
|
|
37
|
+
let existingIds = null;
|
|
38
|
+
if (skipExisting && to.keys.listIds) {
|
|
39
|
+
existingIds = new Set();
|
|
40
|
+
try {
|
|
41
|
+
for await (const id of to.keys.listIds(type)) existingIds.add(id);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
result.warnings.push(`failed to enumerate existing destination ids for ${type}: ${String(error)}`);
|
|
45
|
+
existingIds = null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const batch = {};
|
|
49
|
+
let total = 0;
|
|
50
|
+
const flush = async () => {
|
|
51
|
+
const ids = Object.keys(batch);
|
|
52
|
+
if (!ids.length) return;
|
|
53
|
+
await to.keys.set({ [type]: { ...batch } });
|
|
54
|
+
for (const id of ids) delete batch[id];
|
|
55
|
+
total += ids.length;
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
if (from.keys.list) {
|
|
59
|
+
for await (const [id, value] of from.keys.list(type)) {
|
|
60
|
+
if (existingIds?.has(id)) continue;
|
|
61
|
+
batch[id] = value;
|
|
62
|
+
if (Object.keys(batch).length >= batchSize) await flush();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
for await (const id of from.keys.listIds(type)) {
|
|
67
|
+
if (existingIds?.has(id)) continue;
|
|
68
|
+
const data = await from.keys.get(type, [id]);
|
|
69
|
+
if (data[id] !== undefined) batch[id] = data[id];
|
|
70
|
+
if (Object.keys(batch).length >= batchSize) await flush();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
result.warnings.push(`failed to enumerate source records for ${type}: ${String(error)}`);
|
|
76
|
+
}
|
|
77
|
+
await flush();
|
|
78
|
+
result.counts[type] = total;
|
|
79
|
+
logger?.info?.({ type, count: total }, 'migrateAuthState: copied type');
|
|
80
|
+
}
|
|
81
|
+
if (verify) result.verified = await verifyMigration(from, to, result.warnings, logger);
|
|
82
|
+
logger?.info?.({ counts: result.counts, verified: result.verified, warnings: result.warnings.length }, 'migrateAuthState: done');
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function collectIds(state, type) {
|
|
87
|
+
try {
|
|
88
|
+
const out = new Set();
|
|
89
|
+
if (state.keys.listIds) {
|
|
90
|
+
for await (const id of state.keys.listIds(type)) out.add(id);
|
|
91
|
+
}
|
|
92
|
+
else if (state.keys.list) {
|
|
93
|
+
for await (const [id] of state.keys.list(type)) out.add(id);
|
|
94
|
+
}
|
|
95
|
+
else return null;
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function verifyMigration(from, to, warnings, logger) {
|
|
104
|
+
let ok = true;
|
|
105
|
+
for (const type of ALL_TYPES) {
|
|
106
|
+
const fromIds = await collectIds(from, type);
|
|
107
|
+
const toIds = await collectIds(to, type);
|
|
108
|
+
if (!fromIds || !toIds) {
|
|
109
|
+
warnings.push(`verification skipped for ${type}: unable to enumerate one side`);
|
|
110
|
+
ok = false;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
for (const id of fromIds) if (!toIds.has(id)) {
|
|
114
|
+
warnings.push(`destination missing ${type}:${id}`);
|
|
115
|
+
ok = false;
|
|
116
|
+
}
|
|
117
|
+
for (const id of toIds) if (!fromIds.has(id)) {
|
|
118
|
+
warnings.push(`destination has unexpected ${type}:${id}`);
|
|
119
|
+
ok = false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
logger?.info?.({ ok }, 'migrateAuthState: verification complete');
|
|
123
|
+
return ok;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { ALL_TYPES };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const MINI_APP_DEFAULT_BUTTON_TEXT: "\uD83D\uDE80 Open App";
|
|
2
|
+
export function buildMiniAppContent(opts4?: { [key: string]: any;
|
|
3
|
+
buttons?: any[];
|
|
4
|
+
useWebview?: boolean;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
text: string;
|
|
7
|
+
footer: any;
|
|
8
|
+
nativeFlow: any[];
|
|
9
|
+
}>;
|
|
10
|
+
export function sendMiniApp(sock: any, jid: any, miniApp: any, options?: {}): Promise<any>;
|
|
11
|
+
export function createMiniAppLink(baseUrl: any, params?: {}, opts1?: { [key: string]: any; }): string;
|
|
12
|
+
export function parseMiniAppParams(link: any, opts2?: { [key: string]: any; }): {};
|
|
13
|
+
export function buildFlowDataExchange(action: any, data?: {}, opts3?: { [key: string]: any;
|
|
14
|
+
version?: string;
|
|
15
|
+
}): {
|
|
16
|
+
token?: any;
|
|
17
|
+
version: string;
|
|
18
|
+
action: string;
|
|
19
|
+
data: {};
|
|
20
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// Vanz@Port --- ported from @japofc/baileys 2.4.1 (mini-app.js). Creator credits untouched. See NOTICE.md.
|
|
2
|
+
/**
|
|
3
|
+
* JAP@Add --- "Mini App" sender.
|
|
4
|
+
*
|
|
5
|
+
* Two delivery modes (both are real WhatsApp "mini app" patterns):
|
|
6
|
+
*
|
|
7
|
+
* 1. `url` — rich interactive card + CTA button opening your web app
|
|
8
|
+
* (in-app webview when supported, else the system browser). Optional
|
|
9
|
+
* `params` are appended as query string, so the app knows who opened it.
|
|
10
|
+
* 2. `flow` — WhatsApp Flows button (`flow_action`): a TRUE native in-chat
|
|
11
|
+
* mini app (forms/screens rendered inside WhatsApp, no browser at all).
|
|
12
|
+
* Requires a flow ID registered & published in Flows Manager. Both modes
|
|
13
|
+
* can be combined — the card then carries two buttons.
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* import { sendMiniApp } from '@japofc/baileys'
|
|
17
|
+
* await sendMiniApp(sock, jid, {
|
|
18
|
+
* title: 'My Mini App',
|
|
19
|
+
* body: 'Tap the button to open the app 👇',
|
|
20
|
+
* url: 'https://myapp.example.com',
|
|
21
|
+
* params: { ref: 'wa-bot' }, // → ?ref=wa-bot
|
|
22
|
+
* flow: { id: '123456789', cta: '📝 Isi Form', screen: 'WELCOME' }, // optional
|
|
23
|
+
* thumbnail: 'https://myapp.example.com/icon.png', // url or Buffer (optional)
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { Boom } from '@hapi/boom';
|
|
28
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
29
|
+
import { fetchWithTimeout } from './fetch-timeout.js';
|
|
30
|
+
export const MINI_APP_DEFAULT_BUTTON_TEXT = '🚀 Open App';
|
|
31
|
+
const MAX_THUMBNAIL_BYTES = 512 * 1024;
|
|
32
|
+
const resolveThumbnail = async (thumbnail) => {
|
|
33
|
+
if (!thumbnail) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (Buffer.isBuffer(thumbnail)) {
|
|
37
|
+
return thumbnail;
|
|
38
|
+
}
|
|
39
|
+
if (typeof thumbnail === 'string') {
|
|
40
|
+
let res;
|
|
41
|
+
try {
|
|
42
|
+
res = await fetchWithTimeout(thumbnail);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
throw new Boom(`miniApp.thumbnail: failed to fetch ${thumbnail} (${err?.message || err})`, { statusCode: 400 });
|
|
46
|
+
}
|
|
47
|
+
if (!res.ok) {
|
|
48
|
+
throw new Boom(`miniApp.thumbnail: fetch failed with HTTP ${res.status}`, { statusCode: 400 });
|
|
49
|
+
}
|
|
50
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
51
|
+
if (!buf.length || buf.length > MAX_THUMBNAIL_BYTES) {
|
|
52
|
+
throw new Boom(`miniApp.thumbnail: must be 1–${MAX_THUMBNAIL_BYTES} bytes`, { statusCode: 400 });
|
|
53
|
+
}
|
|
54
|
+
return buf;
|
|
55
|
+
}
|
|
56
|
+
throw new Boom('miniApp.thumbnail must be a Buffer or a URL string', { statusCode: 400 });
|
|
57
|
+
};
|
|
58
|
+
const normalizeFlowConfig = (flow) => {
|
|
59
|
+
if (!flow) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const cfg = typeof flow === 'string' ? { id: flow } : flow;
|
|
63
|
+
if (!cfg || typeof cfg !== 'object' || !cfg.id || typeof cfg.id !== 'string') {
|
|
64
|
+
throw new Boom('miniApp.flow.id is required (your published WhatsApp Flow ID)', { statusCode: 400 });
|
|
65
|
+
}
|
|
66
|
+
return cfg;
|
|
67
|
+
};
|
|
68
|
+
const appendUrlParams = (link, params) => {
|
|
69
|
+
if (!params || typeof params !== 'object' || !Object.keys(params).length) {
|
|
70
|
+
return link;
|
|
71
|
+
}
|
|
72
|
+
let u;
|
|
73
|
+
try {
|
|
74
|
+
u = new URL(link);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Boom(`miniApp.url is not a valid URL: ${link}`, { statusCode: 400 });
|
|
78
|
+
}
|
|
79
|
+
for (const [k, v] of Object.entries(params)) {
|
|
80
|
+
u.searchParams.set(k, String(v));
|
|
81
|
+
}
|
|
82
|
+
return u.toString();
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Build `sendMessage`-ready content for a Mini App card.
|
|
86
|
+
* Needs `url`, `flow`, or both. Thumbnail failures are non-fatal: the card is
|
|
87
|
+
* still built, just without the image.
|
|
88
|
+
*/
|
|
89
|
+
export const buildMiniAppContent = async ({ title, body, text, url, appUrl, flow, params, buttonText, buttons = [], footer, thumbnail, useWebview = true, onThumbnailError, ...passthrough } = {}) => {
|
|
90
|
+
const link = url || appUrl;
|
|
91
|
+
const flowCfg = normalizeFlowConfig(flow);
|
|
92
|
+
if ((!link || typeof link !== 'string') && !flowCfg) {
|
|
93
|
+
throw new Boom('miniApp needs either `url` (webview app) or `flow` (WhatsApp Flow) — or both', { statusCode: 400 });
|
|
94
|
+
}
|
|
95
|
+
const mainText = body || text;
|
|
96
|
+
if (!mainText || typeof mainText !== 'string') {
|
|
97
|
+
throw new Boom('miniApp.body (or text) is required', { statusCode: 400 });
|
|
98
|
+
}
|
|
99
|
+
const finalUrl = link ? appendUrlParams(link, params) : undefined;
|
|
100
|
+
let thumb;
|
|
101
|
+
try {
|
|
102
|
+
thumb = await resolveThumbnail(thumbnail);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
if (typeof onThumbnailError === 'function') {
|
|
106
|
+
try {
|
|
107
|
+
onThumbnailError(err);
|
|
108
|
+
}
|
|
109
|
+
catch { }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const cardTitle = title || 'Mini App';
|
|
113
|
+
const nativeFlow = [
|
|
114
|
+
...(finalUrl ? [{ buttonText: buttonText || MINI_APP_DEFAULT_BUTTON_TEXT, url: finalUrl, useWebview }] : []),
|
|
115
|
+
...(flowCfg ? [{ buttonText: flowCfg.cta || '📝 Open', flow: flowCfg }] : []),
|
|
116
|
+
...buttons
|
|
117
|
+
];
|
|
118
|
+
const content = {
|
|
119
|
+
text: mainText,
|
|
120
|
+
footer: footer ?? cardTitle,
|
|
121
|
+
nativeFlow,
|
|
122
|
+
...passthrough
|
|
123
|
+
};
|
|
124
|
+
// NOTE: only attach `thumbnail` when we actually have one — the ad-reply
|
|
125
|
+
// builder throws on a present-but-non-Buffer thumbnail value.
|
|
126
|
+
if (finalUrl) {
|
|
127
|
+
const externalAdReply = {
|
|
128
|
+
title: cardTitle,
|
|
129
|
+
body: mainText.slice(0, 120),
|
|
130
|
+
url: finalUrl,
|
|
131
|
+
mediaType: 1,
|
|
132
|
+
largeThumbnail: !!thumb
|
|
133
|
+
};
|
|
134
|
+
if (thumb) {
|
|
135
|
+
externalAdReply.thumbnail = thumb;
|
|
136
|
+
}
|
|
137
|
+
content.externalAdReply = content.externalAdReply || externalAdReply;
|
|
138
|
+
}
|
|
139
|
+
return content;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Standalone sender (same style as `sendButtons` / `sendInteractiveMessage`):
|
|
143
|
+
* `sendMiniApp(sock, jid, miniApp, options?)`. A `sock.sendMiniApp` alias exists too.
|
|
144
|
+
*/
|
|
145
|
+
export const sendMiniApp = async (sock, jid, miniApp, options = {}) => {
|
|
146
|
+
if (!sock || typeof sock.sendMessage !== 'function') {
|
|
147
|
+
throw new Boom('sendMiniApp(sock, ...) requires an active Baileys socket', { statusCode: 400 });
|
|
148
|
+
}
|
|
149
|
+
return sock.sendMessage(jid, await buildMiniAppContent(miniApp), options);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* JAP@Add --- build a mini-app deep link with optional HMAC-signed params, so
|
|
154
|
+
* your web app can verify the opener came from your bot untampered.
|
|
155
|
+
* `createMiniAppLink('https://app.example.com', { uid: '123' }, { secret })`
|
|
156
|
+
* → `'https://app.example.com/?uid=123&sig=…'`.
|
|
157
|
+
*/
|
|
158
|
+
export const createMiniAppLink = (baseUrl, params = {}, { secret } = {}) => {
|
|
159
|
+
let u;
|
|
160
|
+
try {
|
|
161
|
+
u = new URL(baseUrl);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
throw new Boom(`miniApp.url is not a valid URL: ${baseUrl}`, { statusCode: 400 });
|
|
165
|
+
}
|
|
166
|
+
for (const [k, v] of Object.entries(params || {})) {
|
|
167
|
+
u.searchParams.set(k, String(v));
|
|
168
|
+
}
|
|
169
|
+
if (secret) {
|
|
170
|
+
const payload = [...u.searchParams.entries()].sort(([a], [b]) => (a < b ? -1 : 1)).map(([k, v]) => `${k}=${v}`).join('&');
|
|
171
|
+
u.searchParams.set('sig', createHmac('sha256', secret).update(payload).digest('hex'));
|
|
172
|
+
}
|
|
173
|
+
return u.toString();
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* JAP@Add --- parse + (optionally) verify a mini-app link's params.
|
|
178
|
+
* Throws when `secret` is given and the signature is missing/invalid.
|
|
179
|
+
*/
|
|
180
|
+
export const parseMiniAppParams = (link, { secret } = {}) => {
|
|
181
|
+
let u;
|
|
182
|
+
try {
|
|
183
|
+
u = new URL(link);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
throw new Boom(`miniApp.url is not a valid URL: ${link}`, { statusCode: 400 });
|
|
187
|
+
}
|
|
188
|
+
const out = {};
|
|
189
|
+
for (const [k, v] of u.searchParams.entries()) {
|
|
190
|
+
if (k !== 'sig') {
|
|
191
|
+
out[k] = v;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (secret) {
|
|
195
|
+
const sig = u.searchParams.get('sig') || '';
|
|
196
|
+
const payload = Object.entries(out).sort(([a], [b]) => (a < b ? -1 : 1)).map(([k, v]) => `${k}=${v}`).join('&');
|
|
197
|
+
const expect = createHmac('sha256', secret).update(payload).digest('hex');
|
|
198
|
+
const ok = sig.length === expect.length && (() => { try { return timingSafeEqual(Buffer.from(sig), Buffer.from(expect)); } catch { return false; } })();
|
|
199
|
+
if (!ok) {
|
|
200
|
+
throw new Boom('miniApp.params: invalid signature', { statusCode: 403 });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* JAP@Add --- build a WhatsApp Flows `data_exchange` action payload
|
|
208
|
+
* (`{ version, action, data, token? }`) for the `flow.actionPayload` shortcut.
|
|
209
|
+
*/
|
|
210
|
+
export const buildFlowDataExchange = (action, data = {}, { version = '3.0', token } = {}) => {
|
|
211
|
+
if (!action || typeof action !== 'string') {
|
|
212
|
+
throw new Boom('flow action is required (e.g. navigate, data_exchange)', { statusCode: 400 });
|
|
213
|
+
}
|
|
214
|
+
return { version, action, data, ...(token ? { token } : {}) };
|
|
215
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export function createMockSocket(options?: {}): {
|
|
2
|
+
sock: {
|
|
3
|
+
ev: {
|
|
4
|
+
on: (event: any, listener: any) => /*elided*/ any;
|
|
5
|
+
off: (event: any, listener: any) => /*elided*/ any;
|
|
6
|
+
once: (event: any, listener: any) => /*elided*/ any;
|
|
7
|
+
removeAllListeners: (event: any) => /*elided*/ any;
|
|
8
|
+
emit: (event: any, data: any) => any;
|
|
9
|
+
process: (handler: any) => () => any;
|
|
10
|
+
buffer: () => void;
|
|
11
|
+
flush: () => boolean;
|
|
12
|
+
isBuffering: () => boolean;
|
|
13
|
+
};
|
|
14
|
+
user: {
|
|
15
|
+
id: any;
|
|
16
|
+
name: any;
|
|
17
|
+
};
|
|
18
|
+
authState: {
|
|
19
|
+
creds: {
|
|
20
|
+
me: {
|
|
21
|
+
id: any;
|
|
22
|
+
name: any;
|
|
23
|
+
};
|
|
24
|
+
registered: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type: string;
|
|
28
|
+
ws: {
|
|
29
|
+
readyState: number;
|
|
30
|
+
close: () => void;
|
|
31
|
+
};
|
|
32
|
+
sendMessage: (jid: any, content: any, opts?: {}) => Promise<import("../index.js").proto.WebMessageInfo>;
|
|
33
|
+
readMessages: (keys: any) => Promise<void>;
|
|
34
|
+
sendPresenceUpdate: (type: any, toJid: any) => Promise<void>;
|
|
35
|
+
presenceSubscribe: () => Promise<void>;
|
|
36
|
+
groupMetadata: (jid: any) => Promise<{
|
|
37
|
+
id: any;
|
|
38
|
+
subject: string;
|
|
39
|
+
owner: any;
|
|
40
|
+
participants: {
|
|
41
|
+
id: any;
|
|
42
|
+
admin: string;
|
|
43
|
+
}[];
|
|
44
|
+
creation: number;
|
|
45
|
+
}>;
|
|
46
|
+
onWhatsApp: (...jids: any[]) => Promise<{
|
|
47
|
+
jid: any;
|
|
48
|
+
exists: boolean;
|
|
49
|
+
}[]>;
|
|
50
|
+
profilePictureUrl: () => Promise<any>;
|
|
51
|
+
updateMediaMessage: (msg: any) => Promise<any>;
|
|
52
|
+
relayMessage: (jid: any, content: any, opts?: {}) => Promise<any>;
|
|
53
|
+
end: () => void;
|
|
54
|
+
logout: () => Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
outbox: any[];
|
|
57
|
+
eventLog: any[];
|
|
58
|
+
readReceipts: any[];
|
|
59
|
+
presenceLog: any[];
|
|
60
|
+
receiveText: (fromJid: any, text: any, opts?: {}) => Promise<any>;
|
|
61
|
+
receiveMessage: (msg: any) => Promise<any>;
|
|
62
|
+
waitForReply: (filter: any, timeoutMs?: number) => Promise<any>;
|
|
63
|
+
connect: () => void;
|
|
64
|
+
disconnect: (error: any) => void;
|
|
65
|
+
reset: () => void;
|
|
66
|
+
readonly connectionState: string;
|
|
67
|
+
};
|