@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,59 @@
|
|
|
1
|
+
// Vanz@Port (2.0.3) --- from rexxhayanasi/elaina-baileys 1.3.10 (username.js). Creator credits untouched. See NOTICE.md.
|
|
2
|
+
export const USERNAME_MIN_LENGTH = 3;
|
|
3
|
+
export const USERNAME_MAX_LENGTH = 35;
|
|
4
|
+
export const USERNAME_PIN_LENGTH = 4;
|
|
5
|
+
const LETTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
6
|
+
const DIGITS = '0123456789';
|
|
7
|
+
const LETTER_SET = new Set(LETTERS.split(''));
|
|
8
|
+
const ALLOWED_SET = new Set([...LETTERS.split(''), ...DIGITS.split(''), '_', '.']);
|
|
9
|
+
const RESERVED_SUFFIXES = ['.com', '.org', '.net', '.int', '.edu', '.gov', '.mil', '.arpa', '.html', '.htm', '.txt', '.xml'];
|
|
10
|
+
const RESERVED_WORDS = ['whatsapp', 'instagram', 'facebook', 'oculus'];
|
|
11
|
+
const PIN_PATTERN = /^[0-9]{4}$/;
|
|
12
|
+
export const UsernameValidationError = {
|
|
13
|
+
INVALID_CHARACTER: 'INVALID_CHARACTER',
|
|
14
|
+
INVALID_LENGTH: 'INVALID_LENGTH',
|
|
15
|
+
INVALID_NO_LETTERS: 'INVALID_NO_LETTERS',
|
|
16
|
+
INVALID_PERIODS: 'INVALID_PERIODS',
|
|
17
|
+
INVALID_DOMAIN_SUFFIX: 'INVALID_DOMAIN_SUFFIX',
|
|
18
|
+
INVALID_WWW_PREFIX: 'INVALID_WWW_PREFIX',
|
|
19
|
+
INVALID_WORD: 'INVALID_WORD'
|
|
20
|
+
};
|
|
21
|
+
export const stripUsernamePrefix = (username) => {
|
|
22
|
+
return typeof username === 'string' && username.startsWith('@') ? username.slice(1) : username;
|
|
23
|
+
};
|
|
24
|
+
export const displayUsername = (username) => {
|
|
25
|
+
return '@' + stripUsernamePrefix(username);
|
|
26
|
+
};
|
|
27
|
+
export const validateUsername = (username) => {
|
|
28
|
+
const value = stripUsernamePrefix(username);
|
|
29
|
+
if (typeof value !== 'string') {
|
|
30
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_CHARACTER };
|
|
31
|
+
}
|
|
32
|
+
const characters = Array.from(value);
|
|
33
|
+
if (!characters.every(character => ALLOWED_SET.has(character))) {
|
|
34
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_CHARACTER };
|
|
35
|
+
}
|
|
36
|
+
if (value.length < USERNAME_MIN_LENGTH || value.length > USERNAME_MAX_LENGTH) {
|
|
37
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_LENGTH };
|
|
38
|
+
}
|
|
39
|
+
if (!characters.some(character => LETTER_SET.has(character))) {
|
|
40
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_NO_LETTERS };
|
|
41
|
+
}
|
|
42
|
+
if (value.startsWith('.') || value.endsWith('.') || value.includes('..')) {
|
|
43
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_PERIODS };
|
|
44
|
+
}
|
|
45
|
+
const lowered = value.toLowerCase();
|
|
46
|
+
if (lowered.startsWith('www.')) {
|
|
47
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_WWW_PREFIX };
|
|
48
|
+
}
|
|
49
|
+
if (RESERVED_SUFFIXES.some(suffix => lowered.endsWith(suffix))) {
|
|
50
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_DOMAIN_SUFFIX };
|
|
51
|
+
}
|
|
52
|
+
if (RESERVED_WORDS.some(word => lowered.includes(word))) {
|
|
53
|
+
return { isValid: false, errorType: UsernameValidationError.INVALID_WORD };
|
|
54
|
+
}
|
|
55
|
+
return { isValid: true };
|
|
56
|
+
};
|
|
57
|
+
export const isUsernamePin = (pin) => {
|
|
58
|
+
return typeof pin === 'string' && PIN_PATTERN.test(pin);
|
|
59
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export function generateLoginNode(userJid: any, config: any): proto.ClientPayload;
|
|
2
|
+
export function generateRegistrationNode(opts2: { [key: string]: any;
|
|
3
|
+
registrationId: any;
|
|
4
|
+
signedPreKey: any;
|
|
5
|
+
signedIdentityKey: any;
|
|
6
|
+
}, config: any): proto.ClientPayload;
|
|
7
|
+
export function configureSuccessfulPairing(stanza: any, opts1: { [key: string]: any;
|
|
8
|
+
advSecretKey: any;
|
|
9
|
+
signedIdentityKey: any;
|
|
10
|
+
signalIdentities: any;
|
|
11
|
+
}): {
|
|
12
|
+
creds: {
|
|
13
|
+
account: proto.ADVSignedDeviceIdentity;
|
|
14
|
+
me: {
|
|
15
|
+
id: any;
|
|
16
|
+
name: any;
|
|
17
|
+
lid: any;
|
|
18
|
+
};
|
|
19
|
+
signalIdentities: any[];
|
|
20
|
+
platform: any;
|
|
21
|
+
};
|
|
22
|
+
reply: {
|
|
23
|
+
tag: string;
|
|
24
|
+
attrs: {
|
|
25
|
+
to: "@s.whatsapp.net";
|
|
26
|
+
type: string;
|
|
27
|
+
id: any;
|
|
28
|
+
};
|
|
29
|
+
content: {
|
|
30
|
+
tag: string;
|
|
31
|
+
attrs: {};
|
|
32
|
+
content: {
|
|
33
|
+
tag: string;
|
|
34
|
+
attrs: {
|
|
35
|
+
'key-index': any;
|
|
36
|
+
};
|
|
37
|
+
content: any;
|
|
38
|
+
}[];
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export function encodeSignedDeviceIdentity(account: any, includeSignatureKey: any): any;
|
|
43
|
+
import { proto } from '../../WAProto/index.js';
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { createHash } from 'crypto';
|
|
3
|
+
import { proto } from '../../WAProto/index.js';
|
|
4
|
+
import { KEY_BUNDLE_TYPE, WA_ADV_ACCOUNT_SIG_PREFIX, WA_ADV_DEVICE_SIG_PREFIX, WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX, COMPANION_DEVICE_VERSION } from '../Defaults/index.js';
|
|
5
|
+
import { getBinaryNodeChild, jidDecode, S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
6
|
+
import { Curve, hmacSign } from './crypto.js';
|
|
7
|
+
import { encodeBigEndian } from './generics.js';
|
|
8
|
+
import { createSignalIdentity } from './signal.js';
|
|
9
|
+
const getUserAgent = (config) => {
|
|
10
|
+
return {
|
|
11
|
+
appVersion: {
|
|
12
|
+
primary: config.version[0],
|
|
13
|
+
secondary: config.version[1],
|
|
14
|
+
tertiary: config.version[2]
|
|
15
|
+
},
|
|
16
|
+
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
17
|
+
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
18
|
+
osVersion: '0.1',
|
|
19
|
+
device: 'Desktop',
|
|
20
|
+
osBuildNumber: '0.1',
|
|
21
|
+
localeLanguageIso6391: 'en',
|
|
22
|
+
mnc: '000',
|
|
23
|
+
mcc: '000',
|
|
24
|
+
localeCountryIso31661Alpha2: config.countryCode
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const PLATFORM_MAP = {
|
|
28
|
+
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
29
|
+
Windows: proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
30
|
+
};
|
|
31
|
+
const getWebInfo = (config) => {
|
|
32
|
+
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
33
|
+
if (config.syncFullHistory &&
|
|
34
|
+
PLATFORM_MAP[config.browser[0]] &&
|
|
35
|
+
config.browser[1] === 'Desktop') {
|
|
36
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
37
|
+
}
|
|
38
|
+
return { webSubPlatform };
|
|
39
|
+
};
|
|
40
|
+
const getClientPayload = (config) => {
|
|
41
|
+
const payload = {
|
|
42
|
+
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
43
|
+
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
44
|
+
userAgent: getUserAgent(config)
|
|
45
|
+
};
|
|
46
|
+
payload.webInfo = getWebInfo(config);
|
|
47
|
+
if (config.pushName) {
|
|
48
|
+
payload.pushName = config.pushName;
|
|
49
|
+
}
|
|
50
|
+
return payload;
|
|
51
|
+
};
|
|
52
|
+
export const generateLoginNode = (userJid, config) => {
|
|
53
|
+
const { user, device } = jidDecode(userJid);
|
|
54
|
+
const payload = {
|
|
55
|
+
...getClientPayload(config),
|
|
56
|
+
passive: true,
|
|
57
|
+
pull: true,
|
|
58
|
+
username: +user,
|
|
59
|
+
device: device,
|
|
60
|
+
lidDbMigrated: config.lidDbMigrated ?? false
|
|
61
|
+
};
|
|
62
|
+
return proto.ClientPayload.fromObject(payload);
|
|
63
|
+
};
|
|
64
|
+
const getPlatformType = (platform) => {
|
|
65
|
+
const platformType = platform.toUpperCase();
|
|
66
|
+
return (proto.DeviceProps.PlatformType[platformType] ||
|
|
67
|
+
proto.DeviceProps.PlatformType.CHROME);
|
|
68
|
+
};
|
|
69
|
+
export const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
70
|
+
// the app version needs to be md5 hashed
|
|
71
|
+
// and passed in
|
|
72
|
+
const appVersionBuf = createHash('md5')
|
|
73
|
+
.update(config.version.join('.')) // join as string
|
|
74
|
+
.digest();
|
|
75
|
+
const companion = {
|
|
76
|
+
os: config.browser[0],
|
|
77
|
+
platformType: getPlatformType(config.browser[1]),
|
|
78
|
+
requireFullSync: config.syncFullHistory,
|
|
79
|
+
historySyncConfig: {
|
|
80
|
+
storageQuotaMb: 10240,
|
|
81
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
82
|
+
recentSyncDaysLimit: undefined,
|
|
83
|
+
supportCallLogHistory: false,
|
|
84
|
+
supportBotUserAgentChatHistory: true,
|
|
85
|
+
supportCagReactionsAndPolls: true,
|
|
86
|
+
supportBizHostedMsg: true,
|
|
87
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
88
|
+
supportHostedGroupMsg: true,
|
|
89
|
+
supportFbidBotChatHistory: true,
|
|
90
|
+
supportAddOnHistorySyncMigration: undefined,
|
|
91
|
+
supportMessageAssociation: true,
|
|
92
|
+
supportGroupHistory: false,
|
|
93
|
+
onDemandReady: undefined,
|
|
94
|
+
supportGuestChat: undefined
|
|
95
|
+
},
|
|
96
|
+
version: COMPANION_DEVICE_VERSION
|
|
97
|
+
};
|
|
98
|
+
const companionProto = proto.DeviceProps.encode(companion).finish();
|
|
99
|
+
const registerPayload = {
|
|
100
|
+
...getClientPayload(config),
|
|
101
|
+
passive: false,
|
|
102
|
+
pull: false,
|
|
103
|
+
devicePairingData: {
|
|
104
|
+
buildHash: appVersionBuf,
|
|
105
|
+
deviceProps: companionProto,
|
|
106
|
+
eRegid: encodeBigEndian(registrationId),
|
|
107
|
+
eKeytype: KEY_BUNDLE_TYPE,
|
|
108
|
+
eIdent: signedIdentityKey.public,
|
|
109
|
+
eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
|
|
110
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
111
|
+
eSkeySig: signedPreKey.signature
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return proto.ClientPayload.fromObject(registerPayload);
|
|
115
|
+
};
|
|
116
|
+
export const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
117
|
+
const msgId = stanza.attrs.id;
|
|
118
|
+
const pairSuccessNode = getBinaryNodeChild(stanza, 'pair-success');
|
|
119
|
+
const deviceIdentityNode = getBinaryNodeChild(pairSuccessNode, 'device-identity');
|
|
120
|
+
const platformNode = getBinaryNodeChild(pairSuccessNode, 'platform');
|
|
121
|
+
const deviceNode = getBinaryNodeChild(pairSuccessNode, 'device');
|
|
122
|
+
const businessNode = getBinaryNodeChild(pairSuccessNode, 'biz');
|
|
123
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
124
|
+
throw new Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
125
|
+
}
|
|
126
|
+
const bizName = businessNode?.attrs.name;
|
|
127
|
+
const jid = deviceNode.attrs.jid;
|
|
128
|
+
const lid = deviceNode.attrs.lid;
|
|
129
|
+
const { details, hmac, accountType } = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
130
|
+
let hmacPrefix = Buffer.from([]);
|
|
131
|
+
if (accountType !== undefined && accountType === proto.ADVEncryptionType.HOSTED) {
|
|
132
|
+
hmacPrefix = WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX;
|
|
133
|
+
}
|
|
134
|
+
const advSign = hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
135
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
136
|
+
throw new Boom('Invalid account signature');
|
|
137
|
+
}
|
|
138
|
+
const account = proto.ADVSignedDeviceIdentity.decode(details);
|
|
139
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
140
|
+
const deviceIdentity = proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
141
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === proto.ADVEncryptionType.HOSTED
|
|
142
|
+
? WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX
|
|
143
|
+
: WA_ADV_ACCOUNT_SIG_PREFIX;
|
|
144
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
145
|
+
if (!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
146
|
+
throw new Boom('Failed to verify account signature');
|
|
147
|
+
}
|
|
148
|
+
const deviceMsg = Buffer.concat([
|
|
149
|
+
WA_ADV_DEVICE_SIG_PREFIX,
|
|
150
|
+
deviceDetails,
|
|
151
|
+
signedIdentityKey.public,
|
|
152
|
+
accountSignatureKey
|
|
153
|
+
]);
|
|
154
|
+
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
155
|
+
const identity = createSignalIdentity(lid, accountSignatureKey);
|
|
156
|
+
const accountEnc = encodeSignedDeviceIdentity(account, false);
|
|
157
|
+
const reply = {
|
|
158
|
+
tag: 'iq',
|
|
159
|
+
attrs: {
|
|
160
|
+
to: S_WHATSAPP_NET,
|
|
161
|
+
type: 'result',
|
|
162
|
+
id: msgId
|
|
163
|
+
},
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
tag: 'pair-device-sign',
|
|
167
|
+
attrs: {},
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
tag: 'device-identity',
|
|
171
|
+
attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
|
|
172
|
+
content: accountEnc
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
const authUpdate = {
|
|
179
|
+
account,
|
|
180
|
+
me: { id: jid, name: bizName, lid },
|
|
181
|
+
signalIdentities: [...(signalIdentities || []), identity],
|
|
182
|
+
platform: platformNode?.attrs.name
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
creds: authUpdate,
|
|
186
|
+
reply
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
export const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
190
|
+
account = { ...account };
|
|
191
|
+
// set to null if we are not to include the signature key
|
|
192
|
+
// or if we are including the signature key but it is empty
|
|
193
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
194
|
+
account.accountSignatureKey = null;
|
|
195
|
+
}
|
|
196
|
+
return proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
197
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function escapeVCard(s: any): any;
|
|
2
|
+
export function unescapeVCard(s: any): any;
|
|
3
|
+
export function formatPhone(p: any): any;
|
|
4
|
+
export function generateVCard(c: any): string;
|
|
5
|
+
export function generateVCards(contacts: any): any;
|
|
6
|
+
export function parseVCard(vcard: any): {
|
|
7
|
+
fullName: any;
|
|
8
|
+
organization: any;
|
|
9
|
+
title: any;
|
|
10
|
+
phones: any;
|
|
11
|
+
emails: any;
|
|
12
|
+
birthday: any;
|
|
13
|
+
note: any;
|
|
14
|
+
};
|
|
15
|
+
export function createContactCard(contact: any): {
|
|
16
|
+
contacts: {
|
|
17
|
+
displayName: any;
|
|
18
|
+
contacts: {
|
|
19
|
+
vcard: string;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export function createContactCards(contacts: any): {
|
|
24
|
+
contacts: {
|
|
25
|
+
displayName: any;
|
|
26
|
+
contacts: any;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export function quickContact(name: any, phone: any, options: any): {
|
|
30
|
+
fullName: any;
|
|
31
|
+
phones: {
|
|
32
|
+
number: any;
|
|
33
|
+
type: string;
|
|
34
|
+
}[];
|
|
35
|
+
organization: any;
|
|
36
|
+
emails: {
|
|
37
|
+
email: any;
|
|
38
|
+
type: string;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export const escapeVCard = (s) => s.replace(/\\/g, '\\\\').replace(/;/g, '\\;').replace(/,/g, '\\,').replace(/\n/g, '\\n');
|
|
2
|
+
export const unescapeVCard = (s) => s.replace(/\\(.)/g, (_, ch) => (ch === 'n' ? '\n' : ch));
|
|
3
|
+
export const formatPhone = (p) => p.replace(/[^\d+]/g, '');
|
|
4
|
+
/** Build a VCARD 3.0 string from structured contact data. */
|
|
5
|
+
export const generateVCard = (c) => {
|
|
6
|
+
const lines = ['BEGIN:VCARD', 'VERSION:3.0', `FN:${escapeVCard(c.fullName)}`];
|
|
7
|
+
const parts = c.fullName.split(' ');
|
|
8
|
+
if (parts.length >= 2) {
|
|
9
|
+
const last = parts[parts.length - 1] || '';
|
|
10
|
+
const first = parts.slice(0, -1).join(' ');
|
|
11
|
+
lines.push(`N:${escapeVCard(last)};${escapeVCard(first)};;;`);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
lines.push(`N:${escapeVCard(c.fullName)};;;;`);
|
|
15
|
+
}
|
|
16
|
+
if (c.organization)
|
|
17
|
+
lines.push(`ORG:${escapeVCard(c.organization)}`);
|
|
18
|
+
if (c.title)
|
|
19
|
+
lines.push(`TITLE:${escapeVCard(c.title)}`);
|
|
20
|
+
for (const p of c.phones ?? []) {
|
|
21
|
+
const t = p.type || 'CELL';
|
|
22
|
+
const n = formatPhone(p.number);
|
|
23
|
+
lines.push(p.label ? `TEL;type=${t};type=VOICE;X-ABLabel=${escapeVCard(p.label)}:${n}` : `TEL;type=${t};type=VOICE:${n}`);
|
|
24
|
+
}
|
|
25
|
+
for (const e of c.emails ?? [])
|
|
26
|
+
lines.push(`EMAIL;type=${e.type || 'OTHER'}:${e.email}`);
|
|
27
|
+
for (const u of c.urls ?? [])
|
|
28
|
+
lines.push(`URL;type=${u.type || 'OTHER'}:${u.url}`);
|
|
29
|
+
for (const a of c.addresses ?? []) {
|
|
30
|
+
const t = a.type || 'OTHER';
|
|
31
|
+
const parts = ['', '', a.street || '', a.city || '', a.state || '', a.postalCode || '', a.country || ''].map((v) => escapeVCard(v));
|
|
32
|
+
lines.push(`ADR;type=${t}:${parts.join(';')}`);
|
|
33
|
+
}
|
|
34
|
+
if (c.birthday)
|
|
35
|
+
lines.push(`BDAY:${c.birthday}`);
|
|
36
|
+
if (c.note)
|
|
37
|
+
lines.push(`NOTE:${escapeVCard(c.note)}`);
|
|
38
|
+
lines.push('END:VCARD');
|
|
39
|
+
return lines.join('\r\n');
|
|
40
|
+
};
|
|
41
|
+
export const generateVCards = (contacts) => contacts.map(generateVCard).join('\r\n');
|
|
42
|
+
/** Parse a subset of VCARD fields back into structured data. */
|
|
43
|
+
export const parseVCard = (vcard) => {
|
|
44
|
+
const contact = {};
|
|
45
|
+
for (const line of vcard.split(/\r?\n/)) {
|
|
46
|
+
const [key, ...vp] = line.split(':');
|
|
47
|
+
if (!key)
|
|
48
|
+
continue;
|
|
49
|
+
const value = vp.join(':');
|
|
50
|
+
if (key.startsWith('FN'))
|
|
51
|
+
contact.fullName = unescapeVCard(value);
|
|
52
|
+
else if (key.startsWith('ORG'))
|
|
53
|
+
contact.organization = unescapeVCard(value);
|
|
54
|
+
else if (key.startsWith('TITLE'))
|
|
55
|
+
contact.title = unescapeVCard(value);
|
|
56
|
+
else if (key.startsWith('TEL')) {
|
|
57
|
+
contact.phones = contact.phones || [];
|
|
58
|
+
const tm = key.match(/type=(\w+)/i);
|
|
59
|
+
contact.phones.push({ number: value, type: tm?.[1]?.toUpperCase() || 'CELL' });
|
|
60
|
+
}
|
|
61
|
+
else if (key.startsWith('EMAIL')) {
|
|
62
|
+
contact.emails = contact.emails || [];
|
|
63
|
+
const tm = key.match(/type=(\w+)/i);
|
|
64
|
+
contact.emails.push({ email: value, type: tm?.[1]?.toUpperCase() || 'OTHER' });
|
|
65
|
+
}
|
|
66
|
+
else if (key.startsWith('BDAY'))
|
|
67
|
+
contact.birthday = value;
|
|
68
|
+
else if (key.startsWith('NOTE'))
|
|
69
|
+
contact.note = unescapeVCard(value);
|
|
70
|
+
}
|
|
71
|
+
return contact;
|
|
72
|
+
};
|
|
73
|
+
/** Ready-to-send `contacts` message content for a single contact. */
|
|
74
|
+
export const createContactCard = (contact) => ({
|
|
75
|
+
contacts: {
|
|
76
|
+
displayName: contact.displayName || contact.fullName,
|
|
77
|
+
contacts: [{ vcard: generateVCard(contact) }]
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
/** Ready-to-send `contacts` message content for multiple contacts. */
|
|
81
|
+
export const createContactCards = (contacts) => ({
|
|
82
|
+
contacts: {
|
|
83
|
+
displayName: contacts.length === 1 ? contacts[0]?.displayName || contacts[0]?.fullName || '' : `${contacts.length} Contacts`,
|
|
84
|
+
contacts: contacts.map((c) => ({ vcard: generateVCard(c) }))
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
export const quickContact = (name, phone, options) => ({
|
|
88
|
+
fullName: name,
|
|
89
|
+
phones: [{ number: phone, type: 'CELL' }],
|
|
90
|
+
organization: options?.organization,
|
|
91
|
+
emails: options?.email ? [{ email: options.email, type: 'WORK' }] : undefined
|
|
92
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Upper bound for a buffered voice note before conversion (WhatsApp voice notes are short; this only stops runaway inputs). */
|
|
2
|
+
export const MAX_VOICE_NOTE_BYTES: number;
|
|
3
|
+
export function isOggBuffer(buf: any): boolean;
|
|
4
|
+
export function buildVoiceNoteContent(audio: any, opts1?: { [key: string]: any;
|
|
5
|
+
convert?: boolean;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
audio: any;
|
|
8
|
+
ptt: boolean;
|
|
9
|
+
mimetype: string;
|
|
10
|
+
waveform: any;
|
|
11
|
+
seconds: any;
|
|
12
|
+
}>;
|
|
13
|
+
export function sendVoiceNote(sock: any, jid: any, audio: any, opts2?: { [key: string]: any; }): Promise<any>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Vanz@Port (2.0.3) --- from @japofc/baileys 2.4.1 (MIT, author JAPofc / J.AP), lib/Utils/voice-note.js. See NOTICE.md.
|
|
2
|
+
// Changed vs donor: URL/file/stream inputs go through this fork's getStream() (same fetch path as every other media input) instead of
|
|
3
|
+
// a bare fetch() with no timeout or size limit, and the buffered audio is capped (MAX_VOICE_NOTE_BYTES).
|
|
4
|
+
import { Boom } from '@hapi/boom';
|
|
5
|
+
import { getStream, toBuffer } from './messages-media.js';
|
|
6
|
+
/** Upper bound for a buffered voice note before conversion (WhatsApp voice notes are short; this only stops runaway inputs). */
|
|
7
|
+
export const MAX_VOICE_NOTE_BYTES = 64 * 1024 * 1024;
|
|
8
|
+
/** True when the buffer starts with the OGG container magic ('OggS'). */
|
|
9
|
+
export const isOggBuffer = (buf) => Buffer.isBuffer(buf) && buf.length > 4 && buf.subarray(0, 4).toString('latin1') === 'OggS';
|
|
10
|
+
const resolveAudioBuffer = async (audio) => {
|
|
11
|
+
if (Buffer.isBuffer(audio)) {
|
|
12
|
+
return audio;
|
|
13
|
+
}
|
|
14
|
+
if (audio == null || (typeof audio !== 'string' && typeof audio !== 'object')) {
|
|
15
|
+
throw new Boom('voice note audio must be a Buffer, a file path, a URL, { url } or a stream', { statusCode: 400 });
|
|
16
|
+
}
|
|
17
|
+
const input = typeof audio === 'string' ? { url: audio } : audio;
|
|
18
|
+
let buf;
|
|
19
|
+
try {
|
|
20
|
+
const { stream } = await getStream(input, { maxContentLength: MAX_VOICE_NOTE_BYTES });
|
|
21
|
+
buf = await toBuffer(stream);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
throw new Boom(`voice note: cannot read audio (${err?.message || err})`, { statusCode: 400 });
|
|
25
|
+
}
|
|
26
|
+
if (buf.length > MAX_VOICE_NOTE_BYTES) {
|
|
27
|
+
throw new Boom(`voice note: audio exceeds ${MAX_VOICE_NOTE_BYTES} bytes`, { statusCode: 413 });
|
|
28
|
+
}
|
|
29
|
+
return buf;
|
|
30
|
+
};
|
|
31
|
+
/** Build `sendMessage`-ready voice-note content (converts to mono 16 kHz Opus/OGG unless already OGG or `convert: false`). */
|
|
32
|
+
export const buildVoiceNoteContent = async (audio, { convert = true, waveform, seconds, ...passthrough } = {}) => {
|
|
33
|
+
let buf = await resolveAudioBuffer(audio);
|
|
34
|
+
if (convert && !isOggBuffer(buf)) {
|
|
35
|
+
// Dynamic import: Framework is not imported by Socket/Utils statically (cycle-safe).
|
|
36
|
+
const { MediaManager } = await import('../Framework/MediaManager.js');
|
|
37
|
+
buf = await MediaManager.convertToVoiceNote(buf);
|
|
38
|
+
}
|
|
39
|
+
return { audio: buf, ptt: true, mimetype: 'audio/ogg; codecs=opus', waveform, seconds, ...passthrough };
|
|
40
|
+
};
|
|
41
|
+
/** Standalone sender: `sendVoiceNote(sock, jid, audio, opts?)`. */
|
|
42
|
+
export const sendVoiceNote = async (sock, jid, audio, { convert, waveform, seconds, ...sendOptions } = {}) => {
|
|
43
|
+
if (!sock || typeof sock.sendMessage !== 'function') {
|
|
44
|
+
throw new Boom('sendVoiceNote(sock, ...) requires an active Baileys socket', { statusCode: 400 });
|
|
45
|
+
}
|
|
46
|
+
return sock.sendMessage(jid, await buildVoiceNoteContent(audio, { convert, waveform, seconds }), sendOptions);
|
|
47
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AudioFeeder {
|
|
2
|
+
constructor(sampleRate: any, channels: any, framesPerChunk: any, onChunk: any, source?: string);
|
|
3
|
+
sampleRate: any;
|
|
4
|
+
channels: any;
|
|
5
|
+
framesPerChunk: any;
|
|
6
|
+
onChunk: any;
|
|
7
|
+
source: string;
|
|
8
|
+
droppedChunks: number;
|
|
9
|
+
underflowChunks: number;
|
|
10
|
+
bytesProduced: number;
|
|
11
|
+
chunksEmitted: number;
|
|
12
|
+
start: () => void;
|
|
13
|
+
stop: () => void;
|
|
14
|
+
#private;
|
|
15
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio feeder.
|
|
3
|
+
*
|
|
4
|
+
* Spawns ffmpeg to decode `source` into f32le PCM at the requested rate, then
|
|
5
|
+
* meters frames out at chunk-cadence to the WASM uplink.
|
|
6
|
+
*
|
|
7
|
+
* @author ShellTear
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
const LOW_WATERMARK_CHUNKS = 16;
|
|
11
|
+
const MAX_QUEUED_CHUNKS = 1024;
|
|
12
|
+
const DEFAULT_WARMUP_MS = 500;
|
|
13
|
+
export class AudioFeeder {
|
|
14
|
+
sampleRate;
|
|
15
|
+
channels;
|
|
16
|
+
framesPerChunk;
|
|
17
|
+
onChunk;
|
|
18
|
+
source;
|
|
19
|
+
#proc = null;
|
|
20
|
+
#pending = Buffer.alloc(0);
|
|
21
|
+
#queue = [];
|
|
22
|
+
#emitTimer = null;
|
|
23
|
+
#nextEmitAtMs = 0;
|
|
24
|
+
#warmupUntilMs = 0;
|
|
25
|
+
droppedChunks = 0;
|
|
26
|
+
underflowChunks = 0;
|
|
27
|
+
bytesProduced = 0;
|
|
28
|
+
chunksEmitted = 0;
|
|
29
|
+
constructor(sampleRate, channels, framesPerChunk, onChunk, source = "silence") {
|
|
30
|
+
this.sampleRate = sampleRate;
|
|
31
|
+
this.channels = channels;
|
|
32
|
+
this.framesPerChunk = framesPerChunk;
|
|
33
|
+
this.onChunk = onChunk;
|
|
34
|
+
this.source = source;
|
|
35
|
+
}
|
|
36
|
+
start = () => {
|
|
37
|
+
if (this.#proc)
|
|
38
|
+
return;
|
|
39
|
+
const chunkSamples = this.framesPerChunk * this.channels;
|
|
40
|
+
const chunkBytes = chunkSamples * Float32Array.BYTES_PER_ELEMENT;
|
|
41
|
+
const chunkIntervalMs = (this.framesPerChunk / this.sampleRate) * 1000;
|
|
42
|
+
const inputArgs = this.#resolveInputArgs();
|
|
43
|
+
this.#proc = spawn("ffmpeg", [
|
|
44
|
+
"-hide_banner",
|
|
45
|
+
"-loglevel", "error",
|
|
46
|
+
"-thread_queue_size", "512",
|
|
47
|
+
...inputArgs,
|
|
48
|
+
"-f", "f32le",
|
|
49
|
+
"-ac", String(this.channels),
|
|
50
|
+
"-ar", String(this.sampleRate),
|
|
51
|
+
"pipe:1",
|
|
52
|
+
]);
|
|
53
|
+
this.#proc.stdout.on("data", (chunk) => {
|
|
54
|
+
this.#pending = Buffer.concat([this.#pending, chunk]);
|
|
55
|
+
while (this.#pending.length >= chunkBytes) {
|
|
56
|
+
if (this.#queue.length >= MAX_QUEUED_CHUNKS) {
|
|
57
|
+
this.#proc?.stdout.pause();
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
const frame = this.#pending.subarray(0, chunkBytes);
|
|
61
|
+
this.#pending = this.#pending.subarray(chunkBytes);
|
|
62
|
+
const out = new Float32Array(chunkSamples);
|
|
63
|
+
out.set(new Float32Array(frame.buffer, frame.byteOffset, chunkSamples));
|
|
64
|
+
this.bytesProduced += chunkBytes;
|
|
65
|
+
this.#queue.push(out);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
this.#proc.stderr.on("data", (chunk) => {
|
|
69
|
+
process.stderr.write(`[AudioFeeder] ${chunk.toString().trim()}\n`);
|
|
70
|
+
});
|
|
71
|
+
this.#proc.on("exit", (code) => {
|
|
72
|
+
if (code !== 0 && code !== null) {
|
|
73
|
+
process.stderr.write(`[AudioFeeder] ffmpeg exited with code=${code}\n`);
|
|
74
|
+
}
|
|
75
|
+
this.#proc = null;
|
|
76
|
+
});
|
|
77
|
+
this.#nextEmitAtMs = 0;
|
|
78
|
+
this.#warmupUntilMs = Date.now() + DEFAULT_WARMUP_MS;
|
|
79
|
+
this.#scheduleNext(chunkSamples, chunkIntervalMs);
|
|
80
|
+
};
|
|
81
|
+
stop = () => {
|
|
82
|
+
if (this.#emitTimer) {
|
|
83
|
+
clearTimeout(this.#emitTimer);
|
|
84
|
+
this.#emitTimer = null;
|
|
85
|
+
}
|
|
86
|
+
this.#proc?.kill("SIGTERM");
|
|
87
|
+
this.#proc = null;
|
|
88
|
+
this.#pending = Buffer.alloc(0);
|
|
89
|
+
this.#queue = [];
|
|
90
|
+
this.#warmupUntilMs = 0;
|
|
91
|
+
};
|
|
92
|
+
#resolveInputArgs = () => {
|
|
93
|
+
if (!this.source || this.source === "silence") {
|
|
94
|
+
return ["-f", "lavfi", "-i", `aevalsrc=0:d=3600:s=${this.sampleRate}`];
|
|
95
|
+
}
|
|
96
|
+
if (this.source.startsWith("lavfi:")) {
|
|
97
|
+
return ["-f", "lavfi", "-i", this.source.slice("lavfi:".length)];
|
|
98
|
+
}
|
|
99
|
+
return ["-i", this.source];
|
|
100
|
+
};
|
|
101
|
+
#scheduleNext = (chunkSamples, chunkIntervalMs) => {
|
|
102
|
+
if (!this.#proc)
|
|
103
|
+
return;
|
|
104
|
+
const now = Date.now();
|
|
105
|
+
if (this.#nextEmitAtMs === 0)
|
|
106
|
+
this.#nextEmitAtMs = now;
|
|
107
|
+
const delayMs = Math.max(0, this.#nextEmitAtMs - now);
|
|
108
|
+
this.#emitTimer = setTimeout(() => {
|
|
109
|
+
this.#emitTimer = null;
|
|
110
|
+
if (this.#queue.length < LOW_WATERMARK_CHUNKS && Date.now() < this.#warmupUntilMs) {
|
|
111
|
+
this.#nextEmitAtMs = Date.now() + 10;
|
|
112
|
+
this.#scheduleNext(chunkSamples, chunkIntervalMs);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this.#flushOne(chunkSamples);
|
|
116
|
+
this.#nextEmitAtMs += chunkIntervalMs;
|
|
117
|
+
this.#scheduleNext(chunkSamples, chunkIntervalMs);
|
|
118
|
+
}, delayMs);
|
|
119
|
+
};
|
|
120
|
+
#flushOne = (chunkSamples) => {
|
|
121
|
+
let nextChunk = this.#queue.shift();
|
|
122
|
+
if (!nextChunk) {
|
|
123
|
+
nextChunk = new Float32Array(chunkSamples);
|
|
124
|
+
this.underflowChunks += 1;
|
|
125
|
+
}
|
|
126
|
+
this.chunksEmitted += 1;
|
|
127
|
+
this.onChunk(nextChunk);
|
|
128
|
+
if (this.#proc?.stdout.isPaused() && this.#queue.length <= MAX_QUEUED_CHUNKS / 4) {
|
|
129
|
+
this.#proc.stdout.resume();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { CallState } from "./types.js";
|
|
2
|
+
export class ActiveCall {
|
|
3
|
+
constructor(callId: any, engine: any, durationMs: any);
|
|
4
|
+
_audioSource: string;
|
|
5
|
+
callId: any;
|
|
6
|
+
engine: any;
|
|
7
|
+
get state(): number;
|
|
8
|
+
end: () => void;
|
|
9
|
+
mute: (muted: any) => void;
|
|
10
|
+
waitForEnd: () => Promise<any>;
|
|
11
|
+
_updateState: (state: any) => void;
|
|
12
|
+
_emitAudio: (pcm: any) => void;
|
|
13
|
+
_forceEnd: (reason: any) => void;
|
|
14
|
+
#private;
|
|
15
|
+
}
|
|
16
|
+
export class VoipClient {
|
|
17
|
+
constructor(config?: {});
|
|
18
|
+
connectWithSocket: (existingSock: any) => Promise<void>;
|
|
19
|
+
call: (phoneNumber: any, opts?: {}) => Promise<ActiveCall>;
|
|
20
|
+
disconnect: () => void;
|
|
21
|
+
#private;
|
|
22
|
+
}
|