@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,114 @@
|
|
|
1
|
+
// Vanz@Port --- ported from @lpzeravk/baileys 1.0.0 (group-status-detection.js). Creator credits untouched. See NOTICE.md.
|
|
2
|
+
/**
|
|
3
|
+
* Detecção robusta de mensagens de status-em-grupo (marcação de status no grupo).
|
|
4
|
+
*
|
|
5
|
+
* Cobre:
|
|
6
|
+
* - groupStatusMentionMessage / groupStatusMessage / groupStatusMessageV2
|
|
7
|
+
* - isGroupStatus: true | 1 em qualquer nível
|
|
8
|
+
* - statusAttributions com type GROUP_STATUS / type 5 / groupStatus: true
|
|
9
|
+
* - mensagens aninhadas em wrappers (ephemeral, viewOnce, etc)
|
|
10
|
+
*
|
|
11
|
+
* Integrado na @lpzeravk/baileys.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const MAX_MESSAGE_UNWRAP_DEPTH = 5;
|
|
15
|
+
const MAX_FLAG_SCAN_DEPTH = 8;
|
|
16
|
+
|
|
17
|
+
const STRONG_GROUP_STATUS_MESSAGE_KEYS = new Set([
|
|
18
|
+
'groupStatusMentionMessage',
|
|
19
|
+
'groupStatusMessage',
|
|
20
|
+
'groupStatusMessageV2',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const WRAPPED_MESSAGE_KEYS = [
|
|
24
|
+
'ephemeralMessage',
|
|
25
|
+
'viewOnceMessage',
|
|
26
|
+
'viewOnceMessageV2',
|
|
27
|
+
'viewOnceMessageV2Extension',
|
|
28
|
+
'documentWithCaptionMessage',
|
|
29
|
+
'statusMentionMessage',
|
|
30
|
+
'groupStatusMentionMessage',
|
|
31
|
+
'groupStatusMessage',
|
|
32
|
+
'groupStatusMessageV2',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
export function isGroupStatusValue(value) {
|
|
36
|
+
return value === true || value === 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function canScanObject(value) {
|
|
40
|
+
return value && typeof value === 'object' && !(value instanceof ArrayBuffer) && !ArrayBuffer.isView(value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function hasGroupStatusAttribution(statusAttributions) {
|
|
44
|
+
if (!Array.isArray(statusAttributions)) return false;
|
|
45
|
+
|
|
46
|
+
return statusAttributions.some(
|
|
47
|
+
(sa) =>
|
|
48
|
+
canScanObject(sa) &&
|
|
49
|
+
(Boolean(sa.groupStatus) || sa.attributionData === 'groupStatus' || sa.type === 'GROUP_STATUS' || sa.type === 5)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function hasGroupStatusContextInfo(contextInfo) {
|
|
54
|
+
return (
|
|
55
|
+
canScanObject(contextInfo) &&
|
|
56
|
+
(isGroupStatusValue(contextInfo.isGroupStatus) || hasGroupStatusAttribution(contextInfo.statusAttributions))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function hasGroupStatusFlag(value, depth = 0, seenObjects = new WeakSet()) {
|
|
61
|
+
if (!canScanObject(value) || depth > MAX_FLAG_SCAN_DEPTH || seenObjects.has(value)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
seenObjects.add(value);
|
|
66
|
+
|
|
67
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
68
|
+
if (key === 'quotedMessage') continue;
|
|
69
|
+
|
|
70
|
+
if (STRONG_GROUP_STATUS_MESSAGE_KEYS.has(key) && canScanObject(childValue)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (key === 'isGroupStatus' && isGroupStatusValue(childValue)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (key === 'statusAttributions' && hasGroupStatusAttribution(childValue)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (key === 'contextInfo' && hasGroupStatusContextInfo(childValue)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (hasGroupStatusFlag(childValue, depth + 1, seenObjects)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function getCurrentMessageContentVariants(message, depth = 0, seenObjects = new WeakSet()) {
|
|
95
|
+
if (!canScanObject(message) || depth > MAX_MESSAGE_UNWRAP_DEPTH || seenObjects.has(message)) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
seenObjects.add(message);
|
|
100
|
+
|
|
101
|
+
const variants = [message];
|
|
102
|
+
|
|
103
|
+
for (const key of WRAPPED_MESSAGE_KEYS) {
|
|
104
|
+
const wrappedMessage = message[key]?.message;
|
|
105
|
+
variants.push(...getCurrentMessageContentVariants(wrappedMessage, depth + 1, seenObjects));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return variants;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Verifica se a webMessage é uma marcação de status em grupo, inclusive em wrappers ou níveis profundos. */
|
|
112
|
+
export function hasGroupStatusMessage(webMessage) {
|
|
113
|
+
return getCurrentMessageContentVariants(webMessage?.message).some((message) => hasGroupStatusFlag(message));
|
|
114
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export function downloadHistory(msg: any, options: any): Promise<proto.HistorySync>;
|
|
2
|
+
export function processHistoryMessage(item: any, logger: any): {
|
|
3
|
+
messages: any[];
|
|
4
|
+
contacts: any[];
|
|
5
|
+
chats: any[];
|
|
6
|
+
lidPnMappings: any[];
|
|
7
|
+
pastParticipants?: undefined;
|
|
8
|
+
syncType?: undefined;
|
|
9
|
+
progress?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
chats: any[];
|
|
12
|
+
contacts: ({
|
|
13
|
+
id: any;
|
|
14
|
+
name: any;
|
|
15
|
+
username: any;
|
|
16
|
+
lid: any;
|
|
17
|
+
phoneNumber: any;
|
|
18
|
+
verifiedName?: undefined;
|
|
19
|
+
notify?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
id: any;
|
|
22
|
+
verifiedName: any;
|
|
23
|
+
name?: undefined;
|
|
24
|
+
username?: undefined;
|
|
25
|
+
lid?: undefined;
|
|
26
|
+
phoneNumber?: undefined;
|
|
27
|
+
notify?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
id: any;
|
|
30
|
+
notify: any;
|
|
31
|
+
name?: undefined;
|
|
32
|
+
username?: undefined;
|
|
33
|
+
lid?: undefined;
|
|
34
|
+
phoneNumber?: undefined;
|
|
35
|
+
verifiedName?: undefined;
|
|
36
|
+
})[];
|
|
37
|
+
messages: any[];
|
|
38
|
+
lidPnMappings: {
|
|
39
|
+
lid: any;
|
|
40
|
+
pn: any;
|
|
41
|
+
}[];
|
|
42
|
+
pastParticipants: any;
|
|
43
|
+
syncType: any;
|
|
44
|
+
progress: any;
|
|
45
|
+
};
|
|
46
|
+
export function downloadAndProcessHistorySyncNotification(msg: any, options: any, logger: any): Promise<{
|
|
47
|
+
messages: any[];
|
|
48
|
+
contacts: any[];
|
|
49
|
+
chats: any[];
|
|
50
|
+
lidPnMappings: any[];
|
|
51
|
+
pastParticipants?: undefined;
|
|
52
|
+
syncType?: undefined;
|
|
53
|
+
progress?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
chats: any[];
|
|
56
|
+
contacts: ({
|
|
57
|
+
id: any;
|
|
58
|
+
name: any;
|
|
59
|
+
username: any;
|
|
60
|
+
lid: any;
|
|
61
|
+
phoneNumber: any;
|
|
62
|
+
verifiedName?: undefined;
|
|
63
|
+
notify?: undefined;
|
|
64
|
+
} | {
|
|
65
|
+
id: any;
|
|
66
|
+
verifiedName: any;
|
|
67
|
+
name?: undefined;
|
|
68
|
+
username?: undefined;
|
|
69
|
+
lid?: undefined;
|
|
70
|
+
phoneNumber?: undefined;
|
|
71
|
+
notify?: undefined;
|
|
72
|
+
} | {
|
|
73
|
+
id: any;
|
|
74
|
+
notify: any;
|
|
75
|
+
name?: undefined;
|
|
76
|
+
username?: undefined;
|
|
77
|
+
lid?: undefined;
|
|
78
|
+
phoneNumber?: undefined;
|
|
79
|
+
verifiedName?: undefined;
|
|
80
|
+
})[];
|
|
81
|
+
messages: any[];
|
|
82
|
+
lidPnMappings: {
|
|
83
|
+
lid: any;
|
|
84
|
+
pn: any;
|
|
85
|
+
}[];
|
|
86
|
+
pastParticipants: any;
|
|
87
|
+
syncType: any;
|
|
88
|
+
progress: any;
|
|
89
|
+
}>;
|
|
90
|
+
export function getHistoryMsg(message: any): any;
|
|
91
|
+
import { proto } from '../../WAProto/index.js';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { pipeline } from 'stream/promises';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { createInflate, inflate } from 'zlib';
|
|
4
|
+
import { proto } from '../../WAProto/index.js';
|
|
5
|
+
import { WAMessageStubType } from '../Types/index.js';
|
|
6
|
+
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser } from '../WABinary/index.js';
|
|
7
|
+
import { toNumber } from './generics.js';
|
|
8
|
+
import { normalizeMessageContent } from './messages.js';
|
|
9
|
+
import { downloadContentFromMessage } from './messages-media.js';
|
|
10
|
+
const inflatePromise = promisify(inflate);
|
|
11
|
+
const extractPnFromMessages = (messages) => {
|
|
12
|
+
for (const msgItem of messages) {
|
|
13
|
+
const message = msgItem.message;
|
|
14
|
+
// Only extract from outgoing messages (fromMe: true) in 1:1 chats
|
|
15
|
+
// because userReceipt.userJid is the recipient's JID
|
|
16
|
+
if (!message?.key?.fromMe || !message.userReceipt?.length) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const userJid = message.userReceipt[0]?.userJid;
|
|
20
|
+
if (userJid && (isPnUser(userJid) || isHostedPnUser(userJid))) {
|
|
21
|
+
return userJid;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
export const downloadHistory = async (msg, options) => {
|
|
27
|
+
const stream = await downloadContentFromMessage(msg, 'md-msg-hist', { options });
|
|
28
|
+
// Pipe decrypted stream directly through zlib inflate
|
|
29
|
+
// This avoids allocating an intermediate buffer for the compressed data
|
|
30
|
+
const inflater = createInflate();
|
|
31
|
+
const chunks = [];
|
|
32
|
+
inflater.on('data', (chunk) => chunks.push(chunk));
|
|
33
|
+
await pipeline(stream, inflater);
|
|
34
|
+
const buffer = Buffer.concat(chunks);
|
|
35
|
+
const syncData = proto.HistorySync.decode(buffer);
|
|
36
|
+
return syncData;
|
|
37
|
+
};
|
|
38
|
+
export const processHistoryMessage = (item, logger) => {
|
|
39
|
+
const messages = [];
|
|
40
|
+
const contacts = [];
|
|
41
|
+
const chats = [];
|
|
42
|
+
const lidPnMappings = [];
|
|
43
|
+
|
|
44
|
+
if (!item || typeof item !== 'object') {
|
|
45
|
+
logger?.warn('invalid history sync message: null or not object');
|
|
46
|
+
return { messages, contacts, chats, lidPnMappings };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!item.syncType) {
|
|
50
|
+
logger?.warn('invalid history sync message: missing syncType');
|
|
51
|
+
return { messages, contacts, chats, lidPnMappings };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
logger?.trace({ progress: item.progress }, 'processing history of type ' + item.syncType?.toString());
|
|
55
|
+
// Extract LID-PN mappings for all sync types
|
|
56
|
+
for (const m of item.phoneNumberToLidMappings || []) {
|
|
57
|
+
if (m.lidJid && m.pnJid) {
|
|
58
|
+
lidPnMappings.push({ lid: m.lidJid, pn: m.pnJid });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
switch (item.syncType) {
|
|
62
|
+
case proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
|
63
|
+
case proto.HistorySync.HistorySyncType.RECENT:
|
|
64
|
+
case proto.HistorySync.HistorySyncType.FULL:
|
|
65
|
+
case proto.HistorySync.HistorySyncType.ON_DEMAND:
|
|
66
|
+
for (const chat of item.conversations) {
|
|
67
|
+
contacts.push({
|
|
68
|
+
id: chat.id,
|
|
69
|
+
name: chat.displayName || chat.name || chat.username || undefined,
|
|
70
|
+
username: chat.username || undefined,
|
|
71
|
+
lid: chat.lidJid || chat.accountLid || undefined,
|
|
72
|
+
phoneNumber: chat.pnJid || undefined
|
|
73
|
+
});
|
|
74
|
+
const chatId = chat.id;
|
|
75
|
+
const isLid = isLidUser(chatId) || isHostedLidUser(chatId);
|
|
76
|
+
const isPn = isPnUser(chatId) || isHostedPnUser(chatId);
|
|
77
|
+
if (isLid && chat.pnJid) {
|
|
78
|
+
lidPnMappings.push({ lid: chatId, pn: chat.pnJid });
|
|
79
|
+
}
|
|
80
|
+
else if (isPn && chat.lidJid) {
|
|
81
|
+
lidPnMappings.push({ lid: chat.lidJid, pn: chatId });
|
|
82
|
+
}
|
|
83
|
+
else if (isLid && !chat.pnJid) {
|
|
84
|
+
// Fallback: extract PN from userReceipt in messages when pnJid is missing
|
|
85
|
+
const pnFromReceipt = extractPnFromMessages(chat.messages || []);
|
|
86
|
+
if (pnFromReceipt) {
|
|
87
|
+
lidPnMappings.push({ lid: chatId, pn: pnFromReceipt });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const msgs = chat.messages || [];
|
|
91
|
+
delete chat.messages;
|
|
92
|
+
for (const item of msgs) {
|
|
93
|
+
const message = item.message;
|
|
94
|
+
messages.push(message);
|
|
95
|
+
if (!chat.messages?.length) {
|
|
96
|
+
// keep only the most recent message in the chat array
|
|
97
|
+
chat.messages = [{ message }];
|
|
98
|
+
}
|
|
99
|
+
if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
100
|
+
chat.lastMessageRecvTimestamp = toNumber(message.messageTimestamp);
|
|
101
|
+
}
|
|
102
|
+
if ((message.messageStubType === WAMessageStubType.BIZ_PRIVACY_MODE_TO_BSP ||
|
|
103
|
+
message.messageStubType === WAMessageStubType.BIZ_PRIVACY_MODE_TO_FB) &&
|
|
104
|
+
message.messageStubParameters?.[0]) {
|
|
105
|
+
contacts.push({
|
|
106
|
+
id: message.key.participant || message.key.remoteJid,
|
|
107
|
+
verifiedName: message.messageStubParameters?.[0]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
chats.push(chat);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
115
|
+
for (const c of item.pushnames) {
|
|
116
|
+
contacts.push({ id: c.id, notify: c.pushname });
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
chats,
|
|
122
|
+
contacts,
|
|
123
|
+
messages,
|
|
124
|
+
lidPnMappings,
|
|
125
|
+
pastParticipants: item.pastParticipants,
|
|
126
|
+
syncType: item.syncType,
|
|
127
|
+
progress: item.progress
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export const downloadAndProcessHistorySyncNotification = async (msg, options, logger) => {
|
|
131
|
+
let historyMsg;
|
|
132
|
+
if (msg.initialHistBootstrapInlinePayload) {
|
|
133
|
+
historyMsg = proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
historyMsg = await downloadHistory(msg, options);
|
|
137
|
+
}
|
|
138
|
+
return processHistoryMessage(historyMsg, logger);
|
|
139
|
+
};
|
|
140
|
+
export const getHistoryMsg = (message) => {
|
|
141
|
+
const normalizedContent = !!message ? normalizeMessageContent(message) : undefined;
|
|
142
|
+
const anyHistoryMsg = normalizedContent?.protocolMessage?.historySyncNotification;
|
|
143
|
+
return anyHistoryMsg;
|
|
144
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const HTML_APP_MESSAGE_CEILING: number;
|
|
2
|
+
export const HTML_APP_BYTE_BUDGET: number;
|
|
3
|
+
export const HTML_APP_BYTE_LIMIT: number;
|
|
4
|
+
export function wireBytes(html: any): any;
|
|
5
|
+
export function checkHtmlApp(html: any, opts1?: { [key: string]: any;
|
|
6
|
+
maxBytes?: number;
|
|
7
|
+
}): {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
bytes: any;
|
|
10
|
+
wireBytes: any;
|
|
11
|
+
embeddedBytes: number;
|
|
12
|
+
problems: string[];
|
|
13
|
+
warnings: string[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Vanz@Port --- ported from @rexxhayanasi/elaina-baileys 1.3.10 (html-app.js). Creator credits untouched. See NOTICE.md.
|
|
2
|
+
|
|
3
|
+
export const HTML_APP_MESSAGE_CEILING = 1024 * 1024;
|
|
4
|
+
|
|
5
|
+
export const HTML_APP_BYTE_BUDGET = 960 * 1024;
|
|
6
|
+
|
|
7
|
+
export const HTML_APP_BYTE_LIMIT = HTML_APP_BYTE_BUDGET;
|
|
8
|
+
|
|
9
|
+
export const wireBytes = (html) => Buffer.byteLength(
|
|
10
|
+
JSON.stringify(String(html)).replace(/[\u007f-\uffff]/g, (c) => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0')),
|
|
11
|
+
'utf-8'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const STORAGE_APIS = ['localStorage', 'sessionStorage', 'indexedDB', 'document.cookie', 'caches'];
|
|
15
|
+
|
|
16
|
+
const strip = (html) => html
|
|
17
|
+
.replace(/<!--[\s\S]*?-->/g, '')
|
|
18
|
+
.replace(/data:[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]*;base64,[A-Za-z0-9+/=]+/gi, 'data:');
|
|
19
|
+
|
|
20
|
+
const hasVisibilityGuard = (source) => /document\.(hidden|visibilityState)|visibilitychange|IntersectionObserver|cancelAnimationFrame|clearInterval/.test(source);
|
|
21
|
+
|
|
22
|
+
export const checkHtmlApp = (html, { height, maxBytes = HTML_APP_BYTE_BUDGET } = {}) => {
|
|
23
|
+
if (typeof html !== 'string') {
|
|
24
|
+
throw new TypeError('checkHtmlApp requires an HTML string');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const bytes = Buffer.byteLength(html, 'utf-8');
|
|
28
|
+
const wire = wireBytes(html);
|
|
29
|
+
const source = strip(html);
|
|
30
|
+
const problems = [];
|
|
31
|
+
const warnings = [];
|
|
32
|
+
|
|
33
|
+
if (wire > maxBytes) {
|
|
34
|
+
problems.push(`${Math.round(wire / 1024)}KB on the wire, over the ${Math.round(maxBytes / 1024)}KB budget — a message past ${Math.round(HTML_APP_MESSAGE_CEILING / 1024)}KB is dropped by the receiving client, which logs it and renders nothing, so this one would arrive as silence`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (wire > bytes * 1.15) {
|
|
38
|
+
warnings.push(`escaping inflates this page from ${Math.round(bytes / 1024)}KB to ${Math.round(wire / 1024)}KB — every non-ASCII character is rewritten as \\uXXXX, so emoji and accents cost up to three times their size`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const remote = [...source.matchAll(/\b(?:src|href)\s*=\s*["']?(https?:)?\/\//gi)];
|
|
42
|
+
if (remote.length) {
|
|
43
|
+
problems.push(`${remote.length} remote subresource${remote.length === 1 ? '' : 's'} — the page runs in an opaque origin with no network, so every one of them fails silently; embed as data: URIs instead`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (/\bfetch\s*\(|XMLHttpRequest|navigator\.sendBeacon|new\s+EventSource/.test(source)) {
|
|
47
|
+
problems.push('a call over the HTTP stack — fetch, XHR, sendBeacon and EventSource were measured dead in this WebView, and no securitypolicyviolation fires to tell the page why');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const socket = /new\s+WebSocket/.test(source);
|
|
51
|
+
const peer = /RTCPeerConnection/.test(source);
|
|
52
|
+
if (socket && !/wss:\/\//.test(source)) {
|
|
53
|
+
problems.push('a WebSocket on something other than wss:// — the page is not a secure context, and a cleartext ws:// endpoint sends the room and every move in the open');
|
|
54
|
+
}
|
|
55
|
+
if ((socket || peer) && !hasVisibilityGuard(source)) {
|
|
56
|
+
warnings.push('a live connection with nothing closing it — the bubble outlives the screen, so close or pause the socket on visibilitychange');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const storage = STORAGE_APIS.filter(api => source.includes(api));
|
|
60
|
+
if (storage.length) {
|
|
61
|
+
problems.push(`${storage.join(', ')} — every storage API throws SecurityError in an opaque origin, so the catch branch always runs`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (/crypto\.subtle/.test(source)) {
|
|
65
|
+
problems.push('crypto.subtle needs a secure context and this page is not one');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const rafLoop = /requestAnimationFrame/.test(source);
|
|
69
|
+
const interval = /setInterval\s*\(/.test(source);
|
|
70
|
+
if ((rafLoop || interval) && !hasVisibilityGuard(source)) {
|
|
71
|
+
problems.push('an animation or timer loop with nothing to stop it — the bubble stays alive while the chat scrolls, so it keeps burning CPU and battery off-screen; gate it on document.hidden or an IntersectionObserver');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const reportsHeight = /AndroidBridge\s*\.\s*updateSize/.test(source);
|
|
75
|
+
if (height === undefined && !reportsHeight) {
|
|
76
|
+
const pinned = /(?:html|body)[^{}]*\{[^{}]*height\s*:\s*\d/i.test(source);
|
|
77
|
+
if (!pinned) {
|
|
78
|
+
warnings.push('no height settled — pass height or autoHeight to sendHtmlApp, or call AndroidBridge.updateSize yourself, or the host and the page measure each other and the card shudders');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (/aspect-ratio\s*:/i.test(source)) {
|
|
83
|
+
warnings.push('aspect-ratio makes the height depend on the width, which is the layout chase the host cannot settle');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (/<canvas[^>]*style\s*=\s*["'][^"']*height\s*:\s*auto/i.test(source)) {
|
|
87
|
+
warnings.push('a canvas at height:auto resizes with the bubble; give it pixel dimensions');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const dataUris = [...html.matchAll(/data:[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]*;base64,([A-Za-z0-9+/=]+)/gi)];
|
|
91
|
+
const embedded = dataUris.reduce((total, match) => total + match[1].length, 0);
|
|
92
|
+
if (embedded > bytes * 0.6 && dataUris.length) {
|
|
93
|
+
warnings.push(`${Math.round(embedded / 1024)}KB of the page is embedded media — shrink it before the byte budget forces you to`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return { ok: problems.length === 0, bytes, wireBytes: wire, embeddedBytes: embedded, problems, warnings };
|
|
97
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Vanz@Port --- ported from @blurose/baileys 1.1.23 (html-multiplayer.js). Creator credits untouched. See NOTICE.md.
|
|
2
|
+
const escapeForScript = (value) => JSON.stringify(value).replace(/</g, '\\u003c').replace(/>/g, '\\u003e');
|
|
3
|
+
export const htmlMultiplayerPrelude = ({ url, room, seat, reconnectMs = 1500, maxReconnectMs = 15000 }) => {
|
|
4
|
+
if (typeof url !== 'string' || !url.startsWith('wss://')) {
|
|
5
|
+
throw new TypeError('htmlMultiplayerPrelude requires a wss:// url, since the page is not a secure context');
|
|
6
|
+
}
|
|
7
|
+
if (typeof room !== 'string' || room.trim() === '') {
|
|
8
|
+
throw new TypeError('htmlMultiplayerPrelude requires a non-empty room id');
|
|
9
|
+
}
|
|
10
|
+
const config = escapeForScript({ url, room, seat: seat ?? null, reconnectMs, maxReconnectMs });
|
|
11
|
+
return `<script>
|
|
12
|
+
(function () {
|
|
13
|
+
var cfg = ${config};
|
|
14
|
+
var listeners = [];
|
|
15
|
+
var queue = [];
|
|
16
|
+
var sock = null;
|
|
17
|
+
var backoff = cfg.reconnectMs;
|
|
18
|
+
var closed = false;
|
|
19
|
+
|
|
20
|
+
var api = {
|
|
21
|
+
room: cfg.room,
|
|
22
|
+
seat: cfg.seat,
|
|
23
|
+
connected: false,
|
|
24
|
+
send: function (payload) {
|
|
25
|
+
var frame = JSON.stringify({ room: cfg.room, seat: cfg.seat, data: payload });
|
|
26
|
+
if (sock && sock.readyState === 1) sock.send(frame); else queue.push(frame);
|
|
27
|
+
},
|
|
28
|
+
on: function (fn) { listeners.push(fn); return function () { listeners = listeners.filter(function (f) { return f !== fn }) } },
|
|
29
|
+
close: function () { closed = true; if (sock) try { sock.close() } catch (e) {} }
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function emit(kind, detail) {
|
|
33
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
34
|
+
try { listeners[i](kind, detail) } catch (e) {}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function open() {
|
|
39
|
+
if (closed || (sock && (sock.readyState === 0 || sock.readyState === 1))) return;
|
|
40
|
+
try { sock = new WebSocket(cfg.url) } catch (e) { emit('error', e); return schedule() }
|
|
41
|
+
|
|
42
|
+
sock.onopen = function () {
|
|
43
|
+
backoff = cfg.reconnectMs;
|
|
44
|
+
api.connected = true;
|
|
45
|
+
sock.send(JSON.stringify({ join: cfg.room, seat: cfg.seat }));
|
|
46
|
+
while (queue.length && sock.readyState === 1) sock.send(queue.shift());
|
|
47
|
+
emit('open', null);
|
|
48
|
+
};
|
|
49
|
+
sock.onmessage = function (event) {
|
|
50
|
+
var parsed = event.data;
|
|
51
|
+
try { parsed = JSON.parse(event.data) } catch (e) {}
|
|
52
|
+
emit('message', parsed);
|
|
53
|
+
};
|
|
54
|
+
sock.onclose = function (event) {
|
|
55
|
+
api.connected = false;
|
|
56
|
+
emit('close', event.code);
|
|
57
|
+
schedule();
|
|
58
|
+
};
|
|
59
|
+
sock.onerror = function () { api.connected = false };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function schedule() {
|
|
63
|
+
if (closed || document.hidden) return;
|
|
64
|
+
setTimeout(open, backoff);
|
|
65
|
+
backoff = Math.min(backoff * 2, cfg.maxReconnectMs);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
document.addEventListener('visibilitychange', function () {
|
|
69
|
+
if (document.hidden) {
|
|
70
|
+
if (sock) try { sock.close() } catch (e) {}
|
|
71
|
+
} else if (!closed) {
|
|
72
|
+
backoff = cfg.reconnectMs;
|
|
73
|
+
open();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
window.addEventListener('pagehide', function () { api.close() });
|
|
78
|
+
|
|
79
|
+
window.room = api;
|
|
80
|
+
open();
|
|
81
|
+
})();
|
|
82
|
+
</script>
|
|
83
|
+
`;
|
|
84
|
+
};
|
|
85
|
+
export const withHtmlMultiplayer = (html, options) => {
|
|
86
|
+
if (typeof html !== 'string' || html.trim() === '') {
|
|
87
|
+
throw new TypeError('withHtmlMultiplayer requires an HTML string');
|
|
88
|
+
}
|
|
89
|
+
return htmlMultiplayerPrelude(options) + html;
|
|
90
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Vanz@Port (v2.0.3) --- ported from @japofc/baileys 2.4.1 (MIT, author JAPofc / J.AP), lib/Utils/humanizer.js. See NOTICE.md.
|
|
2
|
+
/**
|
|
3
|
+
* JAP@Add --- Humanized sender (anti-ban friendly).
|
|
4
|
+
*
|
|
5
|
+
* Sends like a human: shows `typing...` presence, waits proportionally to the
|
|
6
|
+
* message length (words-per-minute + jitter), and serializes sends per chat so
|
|
7
|
+
* bursts never fire at once. Presence failures never break the send.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* await sendHumanized(sock, jid, { text: 'Hello, how are you?' })
|
|
11
|
+
* // or: await sock.sendHumanized(jid, { text: '...' })
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
import { Boom } from '@hapi/boom';
|
|
15
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
16
|
+
// Per-chat promise chains (no dependency on makeKeyedMutex API shape).
|
|
17
|
+
const chains = new Map();
|
|
18
|
+
const enqueue = (jid, fn) => {
|
|
19
|
+
const prev = chains.get(jid) || Promise.resolve();
|
|
20
|
+
const next = prev.catch(() => { }).then(fn);
|
|
21
|
+
chains.set(jid, next);
|
|
22
|
+
next.finally(() => {
|
|
23
|
+
if (chains.get(jid) === next) {
|
|
24
|
+
chains.delete(jid);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return next;
|
|
28
|
+
};
|
|
29
|
+
const extractText = (content) => {
|
|
30
|
+
if (!content || typeof content !== 'object') {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
return content.text || content.caption || '';
|
|
34
|
+
};
|
|
35
|
+
const computeDelayMs = (text, { wpm, minDelayMs, maxDelayMs, jitter }) => {
|
|
36
|
+
const words = text.trim().split(/\s+/).filter(Boolean).length;
|
|
37
|
+
const natural = words <= 0 ? minDelayMs : (words / Math.max(1, wpm)) * 60000;
|
|
38
|
+
const clamped = Math.min(Math.max(natural, minDelayMs), maxDelayMs);
|
|
39
|
+
const wobble = 1 + (Math.random() * 2 - 1) * Math.max(0, Math.min(1, jitter));
|
|
40
|
+
return Math.round(clamped * wobble);
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Humanized send. `humanOpts`: wpm (default 200), minDelayMs (900),
|
|
44
|
+
* maxDelayMs (12000), jitter (0.25), typing (true), queue (true).
|
|
45
|
+
*/
|
|
46
|
+
export const sendHumanized = async (sock, jid, content, { wpm = 200, minDelayMs = 900, maxDelayMs = 12000, jitter = 0.25, typing = true, queue = true } = {}, sendOptions = {}) => {
|
|
47
|
+
if (!sock || typeof sock.sendMessage !== 'function') {
|
|
48
|
+
throw new Boom('sendHumanized(sock, ...) requires an active Baileys socket', { statusCode: 400 });
|
|
49
|
+
}
|
|
50
|
+
const run = async () => {
|
|
51
|
+
if (typing && typeof sock.sendPresenceUpdate === 'function') {
|
|
52
|
+
try {
|
|
53
|
+
if (typeof sock.presenceSubscribe === 'function') {
|
|
54
|
+
await sock.presenceSubscribe(jid).catch(() => { });
|
|
55
|
+
}
|
|
56
|
+
await sock.sendPresenceUpdate('composing', jid);
|
|
57
|
+
}
|
|
58
|
+
catch { }
|
|
59
|
+
}
|
|
60
|
+
await sleep(computeDelayMs(extractText(content), { wpm, minDelayMs, maxDelayMs, jitter }));
|
|
61
|
+
try {
|
|
62
|
+
return await sock.sendMessage(jid, content, sendOptions);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
if (typing && typeof sock.sendPresenceUpdate === 'function') {
|
|
66
|
+
try {
|
|
67
|
+
await sock.sendPresenceUpdate('paused', jid);
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return queue ? enqueue(jid, run) : run();
|
|
74
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function handleIdentityChange(node: any, ctx: any): Promise<{
|
|
2
|
+
action: string;
|
|
3
|
+
device?: undefined;
|
|
4
|
+
error?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
action: string;
|
|
7
|
+
device: number;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
action: string;
|
|
11
|
+
error: any;
|
|
12
|
+
device?: undefined;
|
|
13
|
+
}>;
|