@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,254 @@
|
|
|
1
|
+
// Vanz@Port (v2.0.3) --- ported from @japofc/baileys 2.4.1 (MIT, author JAPofc / J.AP), lib/Utils/mock-socket.js. See NOTICE.md.
|
|
2
|
+
// JAP@Add --- MockWASocket: offline test harness for WhatsApp bots.
|
|
3
|
+
//
|
|
4
|
+
// Test bot logic without a real WhatsApp account: no network, no ban risk,
|
|
5
|
+
// no phone nearby, fully CI-safe.
|
|
6
|
+
//
|
|
7
|
+
// What this IS: a stand-in for the `sock` object your bot code receives —
|
|
8
|
+
// same event surface (`sock.ev`), same `sendMessage()` signature, producing
|
|
9
|
+
// REAL proto.WebMessageInfo objects via the same generateWAMessage() pipeline
|
|
10
|
+
// the live socket uses. Inject incoming messages, capture outgoing ones,
|
|
11
|
+
// assert on the conversation — fully offline, CI-safe.
|
|
12
|
+
//
|
|
13
|
+
// What this is NOT (honest scope): it does not talk to WhatsApp, does not
|
|
14
|
+
// validate server behaviour (rate limits, session state, encryption), and
|
|
15
|
+
// media messages are built with a stub uploader (fake URLs, real structure).
|
|
16
|
+
//
|
|
17
|
+
// ```js
|
|
18
|
+
// import { createMockSocket } from '@japofc/baileys'
|
|
19
|
+
//
|
|
20
|
+
// const mock = createMockSocket()
|
|
21
|
+
// myBotSetup(mock.sock) // your real bot code, unchanged
|
|
22
|
+
// await mock.receiveText('628@s.whatsapp.net', '!ping')
|
|
23
|
+
// const out = await mock.waitForReply()
|
|
24
|
+
// assert.equal(out.content.text, 'pong! 🏓')
|
|
25
|
+
// ```
|
|
26
|
+
import { EventEmitter } from 'events';
|
|
27
|
+
import { randomBytes } from 'crypto';
|
|
28
|
+
import { generateWAMessage, generateWAMessageFromContent } from './messages.js';
|
|
29
|
+
import { unixTimestampSeconds } from './generics.js';
|
|
30
|
+
const DEFAULT_ME = '628000000000@s.whatsapp.net';
|
|
31
|
+
const genId = () => 'MOCK' + randomBytes(8).toString('hex').toUpperCase();
|
|
32
|
+
// Stub uploader so image/video/etc. content builds offline with real structure.
|
|
33
|
+
const stubUpload = async () => ({
|
|
34
|
+
mediaUrl: 'https://mock.local/media',
|
|
35
|
+
directPath: '/mock/direct-path',
|
|
36
|
+
handle: undefined
|
|
37
|
+
});
|
|
38
|
+
const stubMediaOptions = {
|
|
39
|
+
upload: stubUpload,
|
|
40
|
+
mediaCache: undefined,
|
|
41
|
+
options: {}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Create an offline mock WhatsApp socket for testing bot logic.
|
|
45
|
+
*
|
|
46
|
+
* Options:
|
|
47
|
+
* - `me` own jid (default '628000000000@s.whatsapp.net')
|
|
48
|
+
* - `pushName` own display name for outgoing messages (default 'MockBot')
|
|
49
|
+
* - `autoConnect` emit a connection.update open event on creation (default true)
|
|
50
|
+
*/
|
|
51
|
+
export const createMockSocket = (options = {}) => {
|
|
52
|
+
const { me = DEFAULT_ME, pushName = 'MockBot', autoConnect = true } = options;
|
|
53
|
+
const emitter = new EventEmitter();
|
|
54
|
+
emitter.setMaxListeners(0);
|
|
55
|
+
/** Every message "sent" by the bot, in order: { jid, content, options, message } */
|
|
56
|
+
const outbox = [];
|
|
57
|
+
/** Every raw event emitted, in order: { event, data } — full audit trail */
|
|
58
|
+
const eventLog = [];
|
|
59
|
+
/** Read receipts requested via readMessages */
|
|
60
|
+
const readReceipts = [];
|
|
61
|
+
/** Presence updates sent via sendPresenceUpdate */
|
|
62
|
+
const presenceLog = [];
|
|
63
|
+
let connectionState = 'close';
|
|
64
|
+
let waiters = [];
|
|
65
|
+
const ev = {
|
|
66
|
+
on: (event, listener) => { emitter.on(event, listener); return ev; },
|
|
67
|
+
off: (event, listener) => { emitter.off(event, listener); return ev; },
|
|
68
|
+
once: (event, listener) => { emitter.once(event, listener); return ev; },
|
|
69
|
+
removeAllListeners: (event) => { emitter.removeAllListeners(event); return ev; },
|
|
70
|
+
emit: (event, data) => {
|
|
71
|
+
eventLog.push({ event, data });
|
|
72
|
+
return emitter.emit(event, data);
|
|
73
|
+
},
|
|
74
|
+
// parity helpers some consumers use
|
|
75
|
+
process: (handler) => {
|
|
76
|
+
const listener = (map) => handler(map);
|
|
77
|
+
emitter.on('event', listener);
|
|
78
|
+
return () => emitter.off('event', listener);
|
|
79
|
+
},
|
|
80
|
+
buffer: () => { },
|
|
81
|
+
flush: () => false,
|
|
82
|
+
isBuffering: () => false
|
|
83
|
+
};
|
|
84
|
+
const settleWaiters = () => {
|
|
85
|
+
if (!waiters.length || !outbox.length) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const pending = waiters;
|
|
89
|
+
waiters = [];
|
|
90
|
+
for (const w of pending) {
|
|
91
|
+
const idx = outbox.findIndex((entry, i) => i >= w.fromIndex && (!w.filter || w.filter(entry)));
|
|
92
|
+
if (idx !== -1) {
|
|
93
|
+
clearTimeout(w.timer);
|
|
94
|
+
w.resolve(outbox[idx]);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
waiters.push(w);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/** The mock `sock` — hand this to your bot code in place of makeWASocket(). */
|
|
102
|
+
const sock = {
|
|
103
|
+
ev,
|
|
104
|
+
user: { id: me, name: pushName },
|
|
105
|
+
authState: { creds: { me: { id: me, name: pushName }, registered: true } },
|
|
106
|
+
type: 'md',
|
|
107
|
+
ws: { readyState: 1, close: () => { } },
|
|
108
|
+
sendMessage: async (jid, content, opts = {}) => {
|
|
109
|
+
if (!jid || typeof jid !== 'string') {
|
|
110
|
+
throw new Error('mock sendMessage: jid must be a string');
|
|
111
|
+
}
|
|
112
|
+
// Build a REAL WAMessage through the same pipeline as the live socket
|
|
113
|
+
const message = await generateWAMessage(jid, content, {
|
|
114
|
+
userJid: me,
|
|
115
|
+
logger: undefined,
|
|
116
|
+
...stubMediaOptions,
|
|
117
|
+
...opts
|
|
118
|
+
});
|
|
119
|
+
message.pushName = pushName;
|
|
120
|
+
message.key.fromMe = true;
|
|
121
|
+
const entry = { jid, content, options: opts, message };
|
|
122
|
+
outbox.push(entry);
|
|
123
|
+
// mirror what the live socket does: our own send comes back as an upsert
|
|
124
|
+
ev.emit('messages.upsert', { messages: [message], type: 'notify' });
|
|
125
|
+
settleWaiters();
|
|
126
|
+
return message;
|
|
127
|
+
},
|
|
128
|
+
readMessages: async (keys) => {
|
|
129
|
+
readReceipts.push(...(keys || []));
|
|
130
|
+
},
|
|
131
|
+
sendPresenceUpdate: async (type, toJid) => {
|
|
132
|
+
presenceLog.push({ type, toJid: toJid ?? null });
|
|
133
|
+
},
|
|
134
|
+
presenceSubscribe: async () => { },
|
|
135
|
+
groupMetadata: async (jid) => ({
|
|
136
|
+
id: jid,
|
|
137
|
+
subject: 'Mock Group',
|
|
138
|
+
owner: me,
|
|
139
|
+
participants: [{ id: me, admin: 'superadmin' }],
|
|
140
|
+
creation: unixTimestampSeconds(new Date())
|
|
141
|
+
}),
|
|
142
|
+
onWhatsApp: async (...jids) => jids.map((jid) => ({
|
|
143
|
+
jid: jid.includes('@') ? jid : `${jid}@s.whatsapp.net`,
|
|
144
|
+
exists: true
|
|
145
|
+
})),
|
|
146
|
+
profilePictureUrl: async () => undefined,
|
|
147
|
+
updateMediaMessage: async (msg) => msg,
|
|
148
|
+
relayMessage: async (jid, content, opts = {}) => {
|
|
149
|
+
const message = generateWAMessageFromContent(jid, content, {
|
|
150
|
+
userJid: me,
|
|
151
|
+
messageId: opts.messageId ?? genId()
|
|
152
|
+
});
|
|
153
|
+
outbox.push({ jid, content, options: opts, message });
|
|
154
|
+
settleWaiters();
|
|
155
|
+
return message.key.id;
|
|
156
|
+
},
|
|
157
|
+
end: () => {
|
|
158
|
+
connectionState = 'close';
|
|
159
|
+
ev.emit('connection.update', { connection: 'close' });
|
|
160
|
+
},
|
|
161
|
+
logout: async () => {
|
|
162
|
+
connectionState = 'close';
|
|
163
|
+
ev.emit('connection.update', { connection: 'close' });
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
// ---------- test-driver API ----------
|
|
167
|
+
/** Inject an incoming message built from raw WAMessage fields. */
|
|
168
|
+
const receiveMessage = async (msg) => {
|
|
169
|
+
if (!msg?.key?.remoteJid) {
|
|
170
|
+
throw new Error('receiveMessage: msg.key.remoteJid is required');
|
|
171
|
+
}
|
|
172
|
+
ev.emit('messages.upsert', { messages: [msg], type: 'notify' });
|
|
173
|
+
// give handlers a microtask turn so awaited bot logic runs
|
|
174
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
175
|
+
return msg;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Inject an incoming TEXT message from `fromJid`.
|
|
179
|
+
* In a group, pass `{ groupJid }` — `fromJid` becomes the participant.
|
|
180
|
+
*/
|
|
181
|
+
const receiveText = async (fromJid, text, opts = {}) => {
|
|
182
|
+
const { groupJid, pushName: senderName = 'Tester', quoted } = opts;
|
|
183
|
+
const remoteJid = groupJid ?? fromJid;
|
|
184
|
+
const msg = {
|
|
185
|
+
key: {
|
|
186
|
+
remoteJid,
|
|
187
|
+
fromMe: false,
|
|
188
|
+
id: genId(),
|
|
189
|
+
...(groupJid ? { participant: fromJid } : {})
|
|
190
|
+
},
|
|
191
|
+
pushName: senderName,
|
|
192
|
+
messageTimestamp: unixTimestampSeconds(new Date()),
|
|
193
|
+
message: quoted
|
|
194
|
+
? { extendedTextMessage: { text, contextInfo: { quotedMessage: quoted.message, stanzaId: quoted.key?.id, participant: quoted.key?.participant ?? quoted.key?.remoteJid } } }
|
|
195
|
+
: { conversation: text }
|
|
196
|
+
};
|
|
197
|
+
return receiveMessage(msg);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Wait for the next outgoing message (optionally matching `filter`),
|
|
201
|
+
* starting AFTER messages already in the outbox. Rejects after `timeoutMs`.
|
|
202
|
+
*/
|
|
203
|
+
const waitForReply = (filter, timeoutMs = 2000) => new Promise((resolve, reject) => {
|
|
204
|
+
const fromIndex = 0;
|
|
205
|
+
const existing = outbox.findIndex((entry) => !filter || filter(entry));
|
|
206
|
+
if (existing !== -1) {
|
|
207
|
+
resolve(outbox[existing]);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const timer = setTimeout(() => {
|
|
211
|
+
waiters = waiters.filter((w) => w.timer !== timer);
|
|
212
|
+
reject(new Error(`waitForReply: no matching outgoing message within ${timeoutMs}ms`));
|
|
213
|
+
}, timeoutMs);
|
|
214
|
+
waiters.push({ filter, fromIndex, resolve, reject, timer });
|
|
215
|
+
});
|
|
216
|
+
/** Simulate connection lifecycle events. */
|
|
217
|
+
const connect = () => {
|
|
218
|
+
connectionState = 'open';
|
|
219
|
+
ev.emit('connection.update', { connection: 'open' });
|
|
220
|
+
};
|
|
221
|
+
const disconnect = (error) => {
|
|
222
|
+
connectionState = 'close';
|
|
223
|
+
ev.emit('connection.update', { connection: 'close', lastDisconnect: { error, date: new Date() } });
|
|
224
|
+
};
|
|
225
|
+
/** Reset captured state between tests (listeners stay attached). */
|
|
226
|
+
const reset = () => {
|
|
227
|
+
outbox.length = 0;
|
|
228
|
+
eventLog.length = 0;
|
|
229
|
+
readReceipts.length = 0;
|
|
230
|
+
presenceLog.length = 0;
|
|
231
|
+
for (const w of waiters) {
|
|
232
|
+
clearTimeout(w.timer);
|
|
233
|
+
w.reject(new Error('mock reset'));
|
|
234
|
+
}
|
|
235
|
+
waiters = [];
|
|
236
|
+
};
|
|
237
|
+
if (autoConnect) {
|
|
238
|
+
connect();
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
sock,
|
|
242
|
+
outbox,
|
|
243
|
+
eventLog,
|
|
244
|
+
readReceipts,
|
|
245
|
+
presenceLog,
|
|
246
|
+
receiveText,
|
|
247
|
+
receiveMessage,
|
|
248
|
+
waitForReply,
|
|
249
|
+
connect,
|
|
250
|
+
disconnect,
|
|
251
|
+
reset,
|
|
252
|
+
get connectionState() { return connectionState; }
|
|
253
|
+
};
|
|
254
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const STATUS_NOTIFICATION_TYPES: Readonly<{
|
|
2
|
+
STATUS_GROUP_STATUS_REPLY: 4;
|
|
3
|
+
UNKNOWN: proto.Message.StatusNotificationMessage.StatusNotificationType.UNKNOWN;
|
|
4
|
+
STATUS_ADD_YOURS: proto.Message.StatusNotificationMessage.StatusNotificationType.STATUS_ADD_YOURS;
|
|
5
|
+
STATUS_RESHARE: proto.Message.StatusNotificationMessage.StatusNotificationType.STATUS_RESHARE;
|
|
6
|
+
STATUS_QUESTION_ANSWER_RESHARE: proto.Message.StatusNotificationMessage.StatusNotificationType.STATUS_QUESTION_ANSWER_RESHARE;
|
|
7
|
+
}>;
|
|
8
|
+
export function makeQuestionMessage(input: any): {
|
|
9
|
+
questionMessage: proto.Message.FutureProofMessage;
|
|
10
|
+
};
|
|
11
|
+
export function makeQuestionResponseMessage(input: any): {
|
|
12
|
+
questionResponseMessage: proto.Message.QuestionResponseMessage;
|
|
13
|
+
};
|
|
14
|
+
export function makeQuestionReplyMessage(input: any): {
|
|
15
|
+
questionReplyMessage: proto.Message.FutureProofMessage;
|
|
16
|
+
};
|
|
17
|
+
export function makeStatusQuestionAnswerMessage(input: any): {
|
|
18
|
+
statusQuestionAnswerMessage: proto.Message.StatusQuestionAnswerMessage;
|
|
19
|
+
};
|
|
20
|
+
export function makeStatusQuotedMessage(input: any): {
|
|
21
|
+
statusQuotedMessage: proto.Message.StatusQuotedMessage;
|
|
22
|
+
};
|
|
23
|
+
export function makeStatusStickerInteractionMessage(input: any): {
|
|
24
|
+
statusStickerInteractionMessage: proto.Message.StatusStickerInteractionMessage;
|
|
25
|
+
};
|
|
26
|
+
export function makeStatusNotificationMessage(input: any): {
|
|
27
|
+
statusNotificationMessage: proto.Message.StatusNotificationMessage;
|
|
28
|
+
};
|
|
29
|
+
export function makeNewsletterAdminInviteMessage(input: any): {
|
|
30
|
+
newsletterAdminInviteMessage: proto.Message.NewsletterAdminInviteMessage;
|
|
31
|
+
};
|
|
32
|
+
export function makeNewsletterFollowerInviteMessage(input: any): {
|
|
33
|
+
newsletterFollowerInviteMessageV2: proto.Message.NewsletterFollowerInviteMessage;
|
|
34
|
+
};
|
|
35
|
+
export function makePollAddOptionMessage(input: any): {
|
|
36
|
+
pollAddOptionMessage: proto.Message.PollAddOptionMessage;
|
|
37
|
+
};
|
|
38
|
+
export function makeCommentMessage(input: any): {
|
|
39
|
+
commentMessage: proto.Message.CommentMessage;
|
|
40
|
+
};
|
|
41
|
+
export function makeEventInviteMessage(input: any): {
|
|
42
|
+
eventInviteMessage: proto.Message.EventInviteMessage;
|
|
43
|
+
};
|
|
44
|
+
export function makeScheduledCallCreationMessage(input: any): {
|
|
45
|
+
scheduledCallCreationMessage: proto.Message.ScheduledCallCreationMessage;
|
|
46
|
+
};
|
|
47
|
+
export function makeScheduledCallEditMessage(input: any): {
|
|
48
|
+
scheduledCallEditMessage: proto.Message.ScheduledCallEditMessage;
|
|
49
|
+
};
|
|
50
|
+
export function makeGroupStatusReactionMessage(input: any): {
|
|
51
|
+
groupStatusMessageV2: proto.Message.FutureProofMessage;
|
|
52
|
+
};
|
|
53
|
+
export function makeNewsletterStatusAttribution(input: any): proto.StatusAttribution;
|
|
54
|
+
export function makeGroupStatusAttribution(input: any): proto.StatusAttribution;
|
|
55
|
+
export const STATUS_AUDIENCE_DEFAULT_LIST_NAME: "Close friends";
|
|
56
|
+
export const STATUS_AUDIENCE_DEFAULT_EMOJI: "\u2B50";
|
|
57
|
+
export function makeStatusAudienceMetadata(input: any): proto.ContextInfo.StatusAudienceMetadata;
|
|
58
|
+
export function makeMessageAssociation(input: any): proto.MessageAssociation;
|
|
59
|
+
export function makeStatusAddYoursAssociation(input: any): proto.MessageAssociation;
|
|
60
|
+
export function makeStatusMentionMessage(input: any): {
|
|
61
|
+
[x: string]: proto.Message.FutureProofMessage;
|
|
62
|
+
};
|
|
63
|
+
export function prepareModernMessageContent(content: any): any;
|
|
64
|
+
import { proto } from '../../WAProto/index.js';
|