@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,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an ACK stanza for a received node.
|
|
3
|
+
* Pure function -- no I/O, no side effects.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors WhatsApp Web's ACK construction:
|
|
6
|
+
* - WAWebHandleMsgSendAck.sendAck / sendNack
|
|
7
|
+
* - WAWebCreateNackFromStanza.createNackFromStanza
|
|
8
|
+
*/
|
|
9
|
+
export function buildAckStanza(node, errorCode, meId) {
|
|
10
|
+
const { tag, attrs } = node;
|
|
11
|
+
const stanza = {
|
|
12
|
+
tag: 'ack',
|
|
13
|
+
attrs: {
|
|
14
|
+
id: attrs.id,
|
|
15
|
+
to: attrs.from,
|
|
16
|
+
class: tag
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
if (errorCode) {
|
|
20
|
+
stanza.attrs.error = errorCode.toString();
|
|
21
|
+
}
|
|
22
|
+
if (attrs.participant) {
|
|
23
|
+
stanza.attrs.participant = attrs.participant;
|
|
24
|
+
}
|
|
25
|
+
if (attrs.recipient) {
|
|
26
|
+
stanza.attrs.recipient = attrs.recipient;
|
|
27
|
+
}
|
|
28
|
+
// WA Web always includes type when present: `n.type || DROP_ATTR`
|
|
29
|
+
if (attrs.type) {
|
|
30
|
+
stanza.attrs.type = attrs.type;
|
|
31
|
+
}
|
|
32
|
+
// WA Web WAWebHandleMsgSendAck.sendAck/sendNack always include `from` for message-class ACKs
|
|
33
|
+
if (tag === 'message' && meId) {
|
|
34
|
+
stanza.attrs.from = meId;
|
|
35
|
+
}
|
|
36
|
+
return stanza;
|
|
37
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export const StatusLinkType: Readonly<{
|
|
2
|
+
RASTERIZED_LINK_PREVIEW: 1;
|
|
3
|
+
RASTERIZED_LINK_TRUNCATED: 2;
|
|
4
|
+
RASTERIZED_LINK_FULL_URL: 3;
|
|
5
|
+
}>;
|
|
6
|
+
export const STICKER_DEFAULT_AREA: Readonly<{
|
|
7
|
+
x: 0.25;
|
|
8
|
+
y: 0.4;
|
|
9
|
+
width: 0.5;
|
|
10
|
+
height: 0.2;
|
|
11
|
+
}>;
|
|
12
|
+
export function stickerArea(opts1?: Readonly<{
|
|
13
|
+
x: 0.25;
|
|
14
|
+
y: 0.4;
|
|
15
|
+
width: 0.5;
|
|
16
|
+
height: 0.2;
|
|
17
|
+
}>): {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}[];
|
|
21
|
+
export function locationSticker(opts2?: { [key: string]: any; }): any;
|
|
22
|
+
export function channelSticker(opts3?: { [key: string]: any;
|
|
23
|
+
serverMessageId?: number;
|
|
24
|
+
}): any;
|
|
25
|
+
export function linkSticker(opts4?: { [key: string]: any;
|
|
26
|
+
linkType?: 1;
|
|
27
|
+
}): any;
|
|
28
|
+
export function musicSticker(opts5?: { [key: string]: any;
|
|
29
|
+
startTimeMs?: number;
|
|
30
|
+
}): any;
|
|
31
|
+
export function messageSticker(opts6?: { [key: string]: any; }): any;
|
|
32
|
+
export function normalizeStickers(stickers: any): proto.InteractiveAnnotation[];
|
|
33
|
+
export function readStickers(message: any): {
|
|
34
|
+
kind: string;
|
|
35
|
+
area: {
|
|
36
|
+
x: any;
|
|
37
|
+
y: any;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
location: any;
|
|
42
|
+
channel: any;
|
|
43
|
+
link: {
|
|
44
|
+
url: any;
|
|
45
|
+
title: any;
|
|
46
|
+
linkType: any;
|
|
47
|
+
};
|
|
48
|
+
music: {
|
|
49
|
+
songId: any;
|
|
50
|
+
title: any;
|
|
51
|
+
author: any;
|
|
52
|
+
};
|
|
53
|
+
message: any;
|
|
54
|
+
annotation: any;
|
|
55
|
+
}[];
|
|
56
|
+
export const MusicMessageStyle: Readonly<{
|
|
57
|
+
UNKNOWN: 0;
|
|
58
|
+
VINYL: 1;
|
|
59
|
+
}>;
|
|
60
|
+
export const MUSIC_ALLOWED_HOSTS: readonly string[];
|
|
61
|
+
export function isMusicHostAllowed(value: any): boolean;
|
|
62
|
+
export function buildMusicMessage(opts7?: { [key: string]: any;
|
|
63
|
+
style?: 1;
|
|
64
|
+
}): any;
|
|
65
|
+
export function readMusicMessage(msg: any): {
|
|
66
|
+
songId: any;
|
|
67
|
+
mediaId: any;
|
|
68
|
+
title: any;
|
|
69
|
+
author: any;
|
|
70
|
+
artistAttribution: any;
|
|
71
|
+
isExplicit: any;
|
|
72
|
+
startTimeMs: any;
|
|
73
|
+
durationMs: any;
|
|
74
|
+
songUri: any;
|
|
75
|
+
artworkUri: any;
|
|
76
|
+
style: any;
|
|
77
|
+
embeddedMusic: any;
|
|
78
|
+
};
|
|
79
|
+
import { proto } from '../../WAProto/index.js';
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// Vanz@Port --- ported from @rexxhayanasi/elaina-baileys 1.3.10 (status-stickers.js). Creator credits untouched. See NOTICE.md.
|
|
2
|
+
import { proto } from '../../WAProto/index.js'
|
|
3
|
+
|
|
4
|
+
export const StatusLinkType = Object.freeze({
|
|
5
|
+
RASTERIZED_LINK_PREVIEW: 1,
|
|
6
|
+
RASTERIZED_LINK_TRUNCATED: 2,
|
|
7
|
+
RASTERIZED_LINK_FULL_URL: 3
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
export const STICKER_DEFAULT_AREA = Object.freeze({ x: 0.25, y: 0.4, width: 0.5, height: 0.2 })
|
|
11
|
+
|
|
12
|
+
const trimUndefined = (object) => {
|
|
13
|
+
for (const key of Object.keys(object)) {
|
|
14
|
+
if (object[key] === undefined) {
|
|
15
|
+
delete object[key]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return object
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const fraction = (value, name) => {
|
|
22
|
+
const number = Number(value)
|
|
23
|
+
if (!Number.isFinite(number) || number < 0 || number > 1) {
|
|
24
|
+
throw new TypeError(`${name} must be between 0 and 1, the client reads these as a fraction of the media`)
|
|
25
|
+
}
|
|
26
|
+
return number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const stickerArea = ({ x, y, width, height } = STICKER_DEFAULT_AREA) => {
|
|
30
|
+
const left = fraction(x, 'x')
|
|
31
|
+
const top = fraction(y, 'y')
|
|
32
|
+
const right = fraction(left + Number(width), 'x + width')
|
|
33
|
+
const bottom = fraction(top + Number(height), 'y + height')
|
|
34
|
+
if (right <= left || bottom <= top) {
|
|
35
|
+
throw new TypeError('a sticker area needs a positive width and height')
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
{ x: left, y: top },
|
|
39
|
+
{ x: right, y: top },
|
|
40
|
+
{ x: right, y: bottom },
|
|
41
|
+
{ x: left, y: bottom }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const annotation = (area, fields) => ({
|
|
46
|
+
polygonVertices: Array.isArray(area) ? area : stickerArea(area),
|
|
47
|
+
...fields
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export const locationSticker = ({ latitude, longitude, name, area, skipConfirmation } = {}) => {
|
|
51
|
+
const degreesLatitude = Number(latitude)
|
|
52
|
+
const degreesLongitude = Number(longitude)
|
|
53
|
+
if (!Number.isFinite(degreesLatitude) || !Number.isFinite(degreesLongitude)) {
|
|
54
|
+
throw new TypeError('locationSticker needs a numeric latitude and longitude')
|
|
55
|
+
}
|
|
56
|
+
return annotation(area, {
|
|
57
|
+
location: { degreesLatitude, degreesLongitude, ...(name ? { name } : {}) },
|
|
58
|
+
...(skipConfirmation === undefined ? {} : { shouldSkipConfirmation: !!skipConfirmation })
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const channelSticker = ({ jid, name, serverMessageId = 0, accessibilityText, area } = {}) => {
|
|
63
|
+
if (typeof jid !== 'string' || !jid.endsWith('@newsletter')) {
|
|
64
|
+
throw new TypeError('channelSticker needs the channel jid, the one ending in @newsletter')
|
|
65
|
+
}
|
|
66
|
+
return annotation(area, {
|
|
67
|
+
newsletter: {
|
|
68
|
+
newsletterJid: jid,
|
|
69
|
+
serverMessageId: Number(serverMessageId),
|
|
70
|
+
...(name ? { newsletterName: name } : {}),
|
|
71
|
+
...(accessibilityText ? { accessibilityText } : {})
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const linkSticker = ({ url, title, area, linkType = StatusLinkType.RASTERIZED_LINK_PREVIEW } = {}) => {
|
|
77
|
+
if (typeof url !== 'string' || !url) {
|
|
78
|
+
throw new TypeError('linkSticker needs a url')
|
|
79
|
+
}
|
|
80
|
+
return annotation(area, {
|
|
81
|
+
tapAction: { tapUrl: url, ...(title ? { title } : {}) },
|
|
82
|
+
statusLinkType: linkType
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const musicSticker = ({
|
|
87
|
+
songId,
|
|
88
|
+
title,
|
|
89
|
+
author,
|
|
90
|
+
mediaId,
|
|
91
|
+
artworkDirectPath,
|
|
92
|
+
artworkSha256,
|
|
93
|
+
artworkEncSha256,
|
|
94
|
+
artworkMediaKey,
|
|
95
|
+
artistAttribution,
|
|
96
|
+
countryBlocklist,
|
|
97
|
+
isExplicit,
|
|
98
|
+
startTimeMs = 0,
|
|
99
|
+
derivedStartTimeMs,
|
|
100
|
+
durationMs,
|
|
101
|
+
area
|
|
102
|
+
} = {}) => {
|
|
103
|
+
if (!songId && !mediaId) {
|
|
104
|
+
throw new TypeError('musicSticker needs at least a songId or a musicContentMediaId')
|
|
105
|
+
}
|
|
106
|
+
const bytes = value => (value === undefined ? undefined : Buffer.isBuffer(value) ? value : Buffer.from(value, 'base64'))
|
|
107
|
+
const embeddedMusic = {
|
|
108
|
+
...(songId ? { songId: String(songId) } : {}),
|
|
109
|
+
...(mediaId ? { musicContentMediaId: String(mediaId) } : {}),
|
|
110
|
+
...(title ? { title } : {}),
|
|
111
|
+
...(author ? { author } : {}),
|
|
112
|
+
...(artistAttribution ? { artistAttribution } : {}),
|
|
113
|
+
...(artworkDirectPath ? { artworkDirectPath } : {}),
|
|
114
|
+
...(isExplicit === undefined ? {} : { isExplicit: !!isExplicit }),
|
|
115
|
+
musicSongStartTimeInMs: Number(startTimeMs),
|
|
116
|
+
...(derivedStartTimeMs === undefined ? {} : { derivedContentStartTimeInMs: Number(derivedStartTimeMs) }),
|
|
117
|
+
...(durationMs === undefined ? {} : { overlapDurationInMs: Number(durationMs) })
|
|
118
|
+
}
|
|
119
|
+
for (const [key, value] of [
|
|
120
|
+
['artworkSha256', artworkSha256],
|
|
121
|
+
['artworkEncSha256', artworkEncSha256],
|
|
122
|
+
['artworkMediaKey', artworkMediaKey],
|
|
123
|
+
['countryBlocklist', countryBlocklist]
|
|
124
|
+
]) {
|
|
125
|
+
const buffer = bytes(value)
|
|
126
|
+
if (buffer) {
|
|
127
|
+
embeddedMusic[key] = buffer
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return annotation(area, { embeddedContent: { embeddedMusic } })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const messageSticker = ({ stanzaId, message, area } = {}) => {
|
|
134
|
+
if (!message) {
|
|
135
|
+
throw new TypeError('messageSticker needs the message it embeds')
|
|
136
|
+
}
|
|
137
|
+
return annotation(area, {
|
|
138
|
+
embeddedContent: { embeddedMessage: { ...(stanzaId ? { stanzaId } : {}), message } }
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const ACTIONS = ['location', 'newsletter', 'embeddedAction', 'tapAction']
|
|
143
|
+
|
|
144
|
+
export const normalizeStickers = (stickers) => {
|
|
145
|
+
const list = Array.isArray(stickers) ? stickers : [stickers]
|
|
146
|
+
return list.filter(Boolean).map((sticker, index) => {
|
|
147
|
+
const vertices = sticker.polygonVertices
|
|
148
|
+
if (!Array.isArray(vertices) || vertices.length !== 4) {
|
|
149
|
+
throw new TypeError(`sticker ${index} needs four polygonVertices, the client reads corner 0 and corner 2`)
|
|
150
|
+
}
|
|
151
|
+
const actions = ACTIONS.filter(name => sticker[name] !== undefined && sticker[name] !== null)
|
|
152
|
+
if (actions.length > 1) {
|
|
153
|
+
throw new TypeError(`sticker ${index} sets ${actions.join(' and ')}, but the client reads only one action per sticker`)
|
|
154
|
+
}
|
|
155
|
+
return proto.InteractiveAnnotation.fromObject(sticker)
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const readStickers = (message) => {
|
|
160
|
+
const media = message?.imageMessage ?? message?.videoMessage ?? message
|
|
161
|
+
const annotations = media?.interactiveAnnotations
|
|
162
|
+
if (!Array.isArray(annotations) || !annotations.length) {
|
|
163
|
+
return []
|
|
164
|
+
}
|
|
165
|
+
return annotations.map(item => {
|
|
166
|
+
const [topLeft, , bottomRight] = item.polygonVertices ?? []
|
|
167
|
+
const music = item.embeddedContent?.embeddedMusic
|
|
168
|
+
return {
|
|
169
|
+
kind: item.location
|
|
170
|
+
? 'location'
|
|
171
|
+
: item.newsletter
|
|
172
|
+
? 'channel'
|
|
173
|
+
: item.tapAction
|
|
174
|
+
? 'link'
|
|
175
|
+
: music
|
|
176
|
+
? 'music'
|
|
177
|
+
: item.embeddedContent?.embeddedMessage
|
|
178
|
+
? 'message'
|
|
179
|
+
: 'unknown',
|
|
180
|
+
area: topLeft && bottomRight
|
|
181
|
+
? { x: topLeft.x, y: topLeft.y, width: bottomRight.x - topLeft.x, height: bottomRight.y - topLeft.y }
|
|
182
|
+
: undefined,
|
|
183
|
+
location: item.location ?? undefined,
|
|
184
|
+
channel: item.newsletter ?? undefined,
|
|
185
|
+
link: item.tapAction ? { url: item.tapAction.tapUrl, title: item.tapAction.title, linkType: item.statusLinkType } : undefined,
|
|
186
|
+
music: music ? { songId: music.songId, title: music.title, author: music.author } : undefined,
|
|
187
|
+
message: item.embeddedContent?.embeddedMessage ?? undefined,
|
|
188
|
+
annotation: item
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const MusicMessageStyle = Object.freeze({ UNKNOWN: 0, VINYL: 1 })
|
|
194
|
+
|
|
195
|
+
export const MUSIC_ALLOWED_HOSTS = Object.freeze([
|
|
196
|
+
'.whatsapp.net',
|
|
197
|
+
'.whatsapp.com',
|
|
198
|
+
'.fbcdn.net',
|
|
199
|
+
'.facebook.com',
|
|
200
|
+
'.instagram.com',
|
|
201
|
+
'.cdninstagram.com'
|
|
202
|
+
])
|
|
203
|
+
|
|
204
|
+
export const isMusicHostAllowed = (value) => {
|
|
205
|
+
let host
|
|
206
|
+
try {
|
|
207
|
+
host = new URL(String(value)).hostname.toLowerCase()
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return false
|
|
211
|
+
}
|
|
212
|
+
return MUSIC_ALLOWED_HOSTS.some(suffix => host.endsWith(suffix) || host === suffix.slice(1))
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const assertMusicHost = (value, label) => {
|
|
216
|
+
if (value === undefined) {
|
|
217
|
+
return undefined
|
|
218
|
+
}
|
|
219
|
+
if (!isMusicHostAllowed(value)) {
|
|
220
|
+
throw new TypeError(
|
|
221
|
+
`${label} must be hosted on ${MUSIC_ALLOWED_HOSTS.join(', ')} — the client refuses any other host `
|
|
222
|
+
+ 'and draws nothing. Both uris come from Meta music catalog entries, so carry them over from a '
|
|
223
|
+
+ 'message you received rather than pointing at your own file'
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
return value
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const embeddedMusicOf = (options) => musicSticker(options).embeddedContent.embeddedMusic
|
|
230
|
+
|
|
231
|
+
export const buildMusicMessage = ({ songUri, artworkUri, style = MusicMessageStyle.VINYL, contextInfo, ...music } = {}) =>
|
|
232
|
+
trimUndefined({
|
|
233
|
+
embeddedMusic: embeddedMusicOf(music),
|
|
234
|
+
songUri: assertMusicHost(songUri, 'songUri'),
|
|
235
|
+
artworkUri: assertMusicHost(artworkUri, 'artworkUri'),
|
|
236
|
+
style,
|
|
237
|
+
contextInfo
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
export const readMusicMessage = (msg) => {
|
|
241
|
+
const message = msg?.message ?? msg
|
|
242
|
+
const music = message?.musicMessage
|
|
243
|
+
if (!music) {
|
|
244
|
+
return null
|
|
245
|
+
}
|
|
246
|
+
const embedded = music.embeddedMusic ?? {}
|
|
247
|
+
return {
|
|
248
|
+
songId: embedded.songId,
|
|
249
|
+
mediaId: embedded.musicContentMediaId,
|
|
250
|
+
title: embedded.title,
|
|
251
|
+
author: embedded.author,
|
|
252
|
+
artistAttribution: embedded.artistAttribution,
|
|
253
|
+
isExplicit: embedded.isExplicit,
|
|
254
|
+
startTimeMs: embedded.musicSongStartTimeInMs,
|
|
255
|
+
durationMs: embedded.overlapDurationInMs,
|
|
256
|
+
songUri: music.songUri,
|
|
257
|
+
artworkUri: music.artworkUri,
|
|
258
|
+
style: music.style,
|
|
259
|
+
embeddedMusic: embedded
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const STATUS_BROADCAST_JID: "status@broadcast";
|
|
2
|
+
export namespace STATUS_BACKGROUNDS {
|
|
3
|
+
namespace solid {
|
|
4
|
+
let green: string;
|
|
5
|
+
let blue: string;
|
|
6
|
+
let purple: string;
|
|
7
|
+
let red: string;
|
|
8
|
+
let orange: string;
|
|
9
|
+
let yellow: string;
|
|
10
|
+
let pink: string;
|
|
11
|
+
let teal: string;
|
|
12
|
+
let gray: string;
|
|
13
|
+
let black: string;
|
|
14
|
+
let white: string;
|
|
15
|
+
}
|
|
16
|
+
namespace gradient {
|
|
17
|
+
export let sunset: string[];
|
|
18
|
+
export let ocean: string[];
|
|
19
|
+
export let forest: string[];
|
|
20
|
+
let purple_1: string[];
|
|
21
|
+
export { purple_1 as purple };
|
|
22
|
+
export let midnight: string[];
|
|
23
|
+
export let aurora: string[];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export namespace STATUS_FONTS {
|
|
27
|
+
let SANS_SERIF: number;
|
|
28
|
+
let SERIF: number;
|
|
29
|
+
let NORICAN: number;
|
|
30
|
+
let BRYNDAN: number;
|
|
31
|
+
let BEBASNEUE: number;
|
|
32
|
+
let OSWALD: number;
|
|
33
|
+
let DAMION: number;
|
|
34
|
+
let DANCING: number;
|
|
35
|
+
let COMFORTAA: number;
|
|
36
|
+
let EXOTWO: number;
|
|
37
|
+
}
|
|
38
|
+
export function generateStatusMessageId(): string;
|
|
39
|
+
export function createTextStatus(options: any): {
|
|
40
|
+
text: any;
|
|
41
|
+
backgroundColor: any;
|
|
42
|
+
font: any;
|
|
43
|
+
textColor: any;
|
|
44
|
+
contextInfo: {
|
|
45
|
+
mentionedJid: any;
|
|
46
|
+
isForwarded: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export function createImageStatus(media: any, options: any): {
|
|
50
|
+
image: any;
|
|
51
|
+
caption: any;
|
|
52
|
+
};
|
|
53
|
+
export function createVideoStatus(media: any, options: any): {
|
|
54
|
+
video: any;
|
|
55
|
+
caption: any;
|
|
56
|
+
gifPlayback: any;
|
|
57
|
+
};
|
|
58
|
+
export function createAudioStatus(media: any, options: any): {
|
|
59
|
+
audio: any;
|
|
60
|
+
ptt: boolean;
|
|
61
|
+
mimetype: string;
|
|
62
|
+
waveform: any;
|
|
63
|
+
};
|
|
64
|
+
export function getStatusJid(): string;
|
|
65
|
+
export namespace StatusHelper {
|
|
66
|
+
function text(text: any, backgroundColor: any, font: any): {
|
|
67
|
+
text: any;
|
|
68
|
+
backgroundColor: any;
|
|
69
|
+
font: any;
|
|
70
|
+
textColor: any;
|
|
71
|
+
contextInfo: {
|
|
72
|
+
mentionedJid: any;
|
|
73
|
+
isForwarded: boolean;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
function image(buffer: any, caption: any): {
|
|
77
|
+
image: any;
|
|
78
|
+
caption: any;
|
|
79
|
+
};
|
|
80
|
+
function imageUrl(url: any, caption: any): {
|
|
81
|
+
image: any;
|
|
82
|
+
caption: any;
|
|
83
|
+
};
|
|
84
|
+
function video(buffer: any, caption: any): {
|
|
85
|
+
video: any;
|
|
86
|
+
caption: any;
|
|
87
|
+
gifPlayback: any;
|
|
88
|
+
};
|
|
89
|
+
function videoUrl(url: any, caption: any): {
|
|
90
|
+
video: any;
|
|
91
|
+
caption: any;
|
|
92
|
+
gifPlayback: any;
|
|
93
|
+
};
|
|
94
|
+
function gif(buffer: any, caption: any): {
|
|
95
|
+
video: any;
|
|
96
|
+
caption: any;
|
|
97
|
+
gifPlayback: any;
|
|
98
|
+
};
|
|
99
|
+
function voiceNote(buffer: any): {
|
|
100
|
+
audio: any;
|
|
101
|
+
ptt: boolean;
|
|
102
|
+
mimetype: string;
|
|
103
|
+
waveform: any;
|
|
104
|
+
};
|
|
105
|
+
function send(sock: any, content: any, jidList?: any[]): Promise<any>;
|
|
106
|
+
}
|
|
107
|
+
export function withMusicAttribution(content: any, music?: {}): any;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { randomBytes } from 'crypto';
|
|
2
|
+
export const STATUS_BROADCAST_JID = 'status@broadcast';
|
|
3
|
+
export const STATUS_BACKGROUNDS = {
|
|
4
|
+
solid: {
|
|
5
|
+
green: '#25D366',
|
|
6
|
+
blue: '#34B7F1',
|
|
7
|
+
purple: '#8B5CF6',
|
|
8
|
+
red: '#EF4444',
|
|
9
|
+
orange: '#F97316',
|
|
10
|
+
yellow: '#EAB308',
|
|
11
|
+
pink: '#EC4899',
|
|
12
|
+
teal: '#14B8A6',
|
|
13
|
+
gray: '#6B7280',
|
|
14
|
+
black: '#000000',
|
|
15
|
+
white: '#FFFFFF'
|
|
16
|
+
},
|
|
17
|
+
gradient: {
|
|
18
|
+
sunset: ['#F97316', '#EF4444'],
|
|
19
|
+
ocean: ['#3B82F6', '#06B6D4'],
|
|
20
|
+
forest: ['#22C55E', '#10B981'],
|
|
21
|
+
purple: ['#8B5CF6', '#EC4899'],
|
|
22
|
+
midnight: ['#1E3A8A', '#4C1D95'],
|
|
23
|
+
aurora: ['#06B6D4', '#8B5CF6', '#EC4899']
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const STATUS_FONTS = {
|
|
27
|
+
SANS_SERIF: 0,
|
|
28
|
+
SERIF: 1,
|
|
29
|
+
NORICAN: 2,
|
|
30
|
+
BRYNDAN: 3,
|
|
31
|
+
BEBASNEUE: 4,
|
|
32
|
+
OSWALD: 5,
|
|
33
|
+
DAMION: 6,
|
|
34
|
+
DANCING: 7,
|
|
35
|
+
COMFORTAA: 8,
|
|
36
|
+
EXOTWO: 9
|
|
37
|
+
};
|
|
38
|
+
/** Generate a status message ID with a 4NY4W3B prefix. */
|
|
39
|
+
export const generateStatusMessageId = () => `4NY4W3B${randomBytes(16).toString('hex').toUpperCase()}`;
|
|
40
|
+
export const createTextStatus = (options) => ({
|
|
41
|
+
text: options.text,
|
|
42
|
+
backgroundColor: options.backgroundColor || STATUS_BACKGROUNDS.solid.green,
|
|
43
|
+
font: options.font ?? STATUS_FONTS.SANS_SERIF,
|
|
44
|
+
textColor: options.textColor || '#FFFFFF',
|
|
45
|
+
contextInfo: { mentionedJid: options.mentions || [], isForwarded: false }
|
|
46
|
+
});
|
|
47
|
+
export const createImageStatus = (media, options) => ({
|
|
48
|
+
image: typeof media === 'string' ? { url: media } : media,
|
|
49
|
+
caption: options?.caption || ''
|
|
50
|
+
});
|
|
51
|
+
export const createVideoStatus = (media, options) => ({
|
|
52
|
+
video: typeof media === 'string' ? { url: media } : media,
|
|
53
|
+
caption: options?.caption || '',
|
|
54
|
+
gifPlayback: options?.gifPlayback || false
|
|
55
|
+
});
|
|
56
|
+
export const createAudioStatus = (media, options) => ({
|
|
57
|
+
audio: typeof media === 'string' ? { url: media } : media,
|
|
58
|
+
ptt: true,
|
|
59
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
60
|
+
waveform: options?.waveform
|
|
61
|
+
});
|
|
62
|
+
export const getStatusJid = () => STATUS_BROADCAST_JID;
|
|
63
|
+
/** Convenience wrappers + a `send()` that routes group vs. individual/broadcast status delivery. */
|
|
64
|
+
export const StatusHelper = {
|
|
65
|
+
text: (text, backgroundColor, font) => createTextStatus({ text, backgroundColor, font }),
|
|
66
|
+
image: (buffer, caption) => createImageStatus(buffer, { caption }),
|
|
67
|
+
imageUrl: (url, caption) => createImageStatus(url, { caption }),
|
|
68
|
+
video: (buffer, caption) => createVideoStatus(buffer, { caption }),
|
|
69
|
+
videoUrl: (url, caption) => createVideoStatus(url, { caption }),
|
|
70
|
+
gif: (buffer, caption) => createVideoStatus(buffer, { caption, gifPlayback: true }),
|
|
71
|
+
voiceNote: (buffer) => createAudioStatus(buffer),
|
|
72
|
+
/**
|
|
73
|
+
* Send a status to specific JIDs (groups and/or individuals).
|
|
74
|
+
* Handles group status (groupStatus:true) and broadcast (status@broadcast) separately.
|
|
75
|
+
* Pass an empty jidList (or omit it) to broadcast to everyone.
|
|
76
|
+
*/
|
|
77
|
+
send: async (sock, content, jidList = []) => {
|
|
78
|
+
const groups = jidList.filter((j) => j?.endsWith('@g.us'));
|
|
79
|
+
const individuals = jidList.filter((j) => j?.endsWith('@s.whatsapp.net') || j?.endsWith('@lid'));
|
|
80
|
+
let lastResult;
|
|
81
|
+
if (groups.length > 0) {
|
|
82
|
+
const groupContent = { ...content, groupStatus: true };
|
|
83
|
+
for (const groupJid of groups) {
|
|
84
|
+
lastResult = await sock.sendMessage(groupJid, groupContent, { messageId: generateStatusMessageId() });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (individuals.length > 0 || jidList.length === 0) {
|
|
88
|
+
const result = await sock.sendMessage(STATUS_BROADCAST_JID, content, {
|
|
89
|
+
statusJidList: individuals.length > 0 ? individuals : undefined,
|
|
90
|
+
messageId: generateStatusMessageId()
|
|
91
|
+
});
|
|
92
|
+
if (!lastResult)
|
|
93
|
+
lastResult = result;
|
|
94
|
+
}
|
|
95
|
+
return lastResult;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Vanz@Port (2.0.3) --- from @japofc/baileys 2.4.1 (MIT, author JAPofc / J.AP), lib/Utils/status.js (withMusicAttribution).
|
|
100
|
+
* Attach music metadata (title / artist / catalog id) to a status content object. This is METADATA only, not an audio stream.
|
|
101
|
+
* Proto-checked here: StatusAttribution.Type 3 = MUSIC and StatusAttribution.Music { title, authorName, songId, artistAttribution, isExplicit }
|
|
102
|
+
* exist in WAProto; whether a given WhatsApp client RENDERS the badge is client-unverified.
|
|
103
|
+
*/
|
|
104
|
+
export const withMusicAttribution = (content, music = {}) => {
|
|
105
|
+
if (!content || typeof content !== 'object') {
|
|
106
|
+
throw new Error('withMusicAttribution: content must be a status content object');
|
|
107
|
+
}
|
|
108
|
+
const { title, authorName, songId, artistAttribution, isExplicit, actionUrl } = music || {};
|
|
109
|
+
if (!title && !songId) {
|
|
110
|
+
throw new Error('withMusicAttribution: music needs at least { title } or { songId }');
|
|
111
|
+
}
|
|
112
|
+
const attribution = {
|
|
113
|
+
type: 3, // StatusAttribution.Type.MUSIC
|
|
114
|
+
...(actionUrl ? { actionUrl } : {}),
|
|
115
|
+
music: {
|
|
116
|
+
...(title ? { title } : {}),
|
|
117
|
+
...(authorName ? { authorName } : {}),
|
|
118
|
+
...(songId ? { songId } : {}),
|
|
119
|
+
...(artistAttribution ? { artistAttribution } : {}),
|
|
120
|
+
...(typeof isExplicit === 'boolean' ? { isExplicit } : {})
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
...content,
|
|
125
|
+
contextInfo: {
|
|
126
|
+
...(content.contextInfo || {}),
|
|
127
|
+
statusAttributionType: 3,
|
|
128
|
+
statusAttributions: [...(content.contextInfo?.statusAttributions || []), attribution]
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function makeStickerPack(opts1?: { [key: string]: any;
|
|
2
|
+
name: string;
|
|
3
|
+
publisher?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
packId?: string;
|
|
6
|
+
stickers: Array<Buffer | {
|
|
7
|
+
url: string;
|
|
8
|
+
} | {
|
|
9
|
+
sticker: Buffer | {
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
emojis?: string[];
|
|
13
|
+
}>;
|
|
14
|
+
cover?: Buffer | {
|
|
15
|
+
url: string;
|
|
16
|
+
};
|
|
17
|
+
contextInfo?: object;
|
|
18
|
+
}): {
|
|
19
|
+
stickerPack: object;
|
|
20
|
+
};
|