@eduh_dev021/baileys 0.0.0-stage → 1.0.0
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/LICENSE +23 -0
- package/README.md +495 -2
- package/WAProto/index.d.ts +22220 -0
- package/WAProto/index.js +5 -0
- package/cjs/WAProto/index.d.ts +22220 -0
- package/cjs/WAProto/index.js +60125 -0
- package/cjs/engine-requirements.js +12 -0
- package/cjs/lib/Addon/http-error.d.ts +18 -0
- package/cjs/lib/Addon/http-error.js +66 -0
- package/cjs/lib/Addon/index.d.ts +3 -0
- package/cjs/lib/Addon/index.js +50 -0
- package/cjs/lib/Addon/keyed-db.d.ts +14 -0
- package/cjs/lib/Addon/keyed-db.js +264 -0
- package/cjs/lib/Addon/link-preview.d.ts +15 -0
- package/cjs/lib/Addon/link-preview.js +104 -0
- package/cjs/lib/Defaults/index.d.ts +184 -0
- package/cjs/lib/Defaults/index.js +292 -0
- package/cjs/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/cjs/lib/Signal/Group/ciphertext-message.js +37 -0
- package/cjs/lib/Signal/Group/group-cipher.d.ts +10 -0
- package/cjs/lib/Signal/Group/group-cipher.js +105 -0
- package/cjs/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/cjs/lib/Signal/Group/group-session-builder.js +65 -0
- package/cjs/lib/Signal/Group/index.d.ts +11 -0
- package/cjs/lib/Signal/Group/index.js +67 -0
- package/cjs/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/cjs/lib/Signal/Group/keyhelper.js +47 -0
- package/cjs/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/cjs/lib/Signal/Group/sender-chain-key.js +51 -0
- package/cjs/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/cjs/lib/Signal/Group/sender-key-distribution-message.js +80 -0
- package/cjs/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/cjs/lib/Signal/Group/sender-key-message.js +87 -0
- package/cjs/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/cjs/lib/Signal/Group/sender-key-name.js +73 -0
- package/cjs/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/cjs/lib/Signal/Group/sender-key-record.js +66 -0
- package/cjs/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/cjs/lib/Signal/Group/sender-key-state.js +106 -0
- package/cjs/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/cjs/lib/Signal/Group/sender-message-key.js +51 -0
- package/cjs/lib/Signal/libsignal.d.ts +54 -0
- package/cjs/lib/Signal/libsignal.js +421 -0
- package/cjs/lib/Signal/lid-mapping.d.ts +20 -0
- package/cjs/lib/Signal/lid-mapping.js +292 -0
- package/cjs/lib/Socket/Client/index.d.ts +2 -0
- package/cjs/lib/Socket/Client/index.js +23 -0
- package/cjs/lib/Socket/Client/types.d.ts +5 -0
- package/cjs/lib/Socket/Client/types.js +36 -0
- package/cjs/lib/Socket/Client/websocket.d.ts +12 -0
- package/cjs/lib/Socket/Client/websocket.js +143 -0
- package/cjs/lib/Socket/business.d.ts +387 -0
- package/cjs/lib/Socket/business.js +402 -0
- package/cjs/lib/Socket/chats.d.ts +144 -0
- package/cjs/lib/Socket/chats.js +1118 -0
- package/cjs/lib/Socket/communities.d.ts +554 -0
- package/cjs/lib/Socket/communities.js +456 -0
- package/cjs/lib/Socket/groups.d.ts +286 -0
- package/cjs/lib/Socket/groups.js +366 -0
- package/cjs/lib/Socket/index.d.ts +522 -0
- package/cjs/lib/Socket/index.js +32 -0
- package/cjs/lib/Socket/messages-recv.d.ts +326 -0
- package/cjs/lib/Socket/messages-recv.js +1670 -0
- package/cjs/lib/Socket/messages-send.d.ts +321 -0
- package/cjs/lib/Socket/messages-send.js +1252 -0
- package/cjs/lib/Socket/mex.d.ts +1 -0
- package/cjs/lib/Socket/mex.js +65 -0
- package/cjs/lib/Socket/newsletter.d.ts +283 -0
- package/cjs/lib/Socket/newsletter.js +243 -0
- package/cjs/lib/Socket/socket.d.ts +61 -0
- package/cjs/lib/Socket/socket.js +908 -0
- package/cjs/lib/Store/index.d.ts +3 -0
- package/cjs/lib/Store/index.js +25 -0
- package/cjs/lib/Store/make-in-memory-store.d.ts +63 -0
- package/cjs/lib/Store/make-in-memory-store.js +431 -0
- package/cjs/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/cjs/lib/Store/make-ordered-dictionary.js +101 -0
- package/cjs/lib/Store/object-repository.d.ts +10 -0
- package/cjs/lib/Store/object-repository.js +49 -0
- package/cjs/lib/Transport/crypto.d.ts +6 -0
- package/cjs/lib/Transport/crypto.js +107 -0
- package/cjs/lib/Transport/curve.d.ts +8 -0
- package/cjs/lib/Transport/curve.js +94 -0
- package/cjs/lib/Transport/index.d.ts +16 -0
- package/cjs/lib/Transport/index.js +67 -0
- package/cjs/lib/Transport/internals.d.ts +57 -0
- package/cjs/lib/Transport/internals.js +203 -0
- package/cjs/lib/Transport/session-builder.d.ts +40 -0
- package/cjs/lib/Transport/session-builder.js +169 -0
- package/cjs/lib/Transport/session-cipher.d.ts +26 -0
- package/cjs/lib/Transport/session-cipher.js +328 -0
- package/cjs/lib/Transport/session-record.d.ts +55 -0
- package/cjs/lib/Transport/session-record.js +289 -0
- package/cjs/lib/Types/Auth.d.ts +1 -0
- package/cjs/lib/Types/Auth.js +15 -0
- package/cjs/lib/Types/Bussines.d.ts +1 -0
- package/cjs/lib/Types/Bussines.js +15 -0
- package/cjs/lib/Types/Call.d.ts +1 -0
- package/cjs/lib/Types/Call.js +15 -0
- package/cjs/lib/Types/Chat.d.ts +1 -0
- package/cjs/lib/Types/Chat.js +33 -0
- package/cjs/lib/Types/Contact.d.ts +1 -0
- package/cjs/lib/Types/Contact.js +15 -0
- package/cjs/lib/Types/Events.d.ts +1 -0
- package/cjs/lib/Types/Events.js +1 -0
- package/cjs/lib/Types/GroupMetadata.d.ts +1 -0
- package/cjs/lib/Types/GroupMetadata.js +15 -0
- package/cjs/lib/Types/Label.d.ts +2 -0
- package/cjs/lib/Types/Label.js +49 -0
- package/cjs/lib/Types/LabelAssociation.d.ts +2 -0
- package/cjs/lib/Types/LabelAssociation.js +31 -0
- package/cjs/lib/Types/Message.d.ts +11 -0
- package/cjs/lib/Types/Message.js +58 -0
- package/cjs/lib/Types/Mex.d.ts +2 -0
- package/cjs/lib/Types/Mex.js +66 -0
- package/cjs/lib/Types/Product.d.ts +1 -0
- package/cjs/lib/Types/Product.js +15 -0
- package/cjs/lib/Types/RichType.d.ts +2 -0
- package/cjs/lib/Types/RichType.js +50 -0
- package/cjs/lib/Types/Signal.d.ts +1 -0
- package/cjs/lib/Types/Signal.js +1 -0
- package/cjs/lib/Types/Socket.d.ts +1 -0
- package/cjs/lib/Types/Socket.js +1 -0
- package/cjs/lib/Types/State.d.ts +5 -0
- package/cjs/lib/Types/State.js +83 -0
- package/cjs/lib/Types/USync.d.ts +1 -0
- package/cjs/lib/Types/USync.js +1 -0
- package/cjs/lib/Types/index.d.ts +13 -0
- package/cjs/lib/Types/index.js +64 -0
- package/cjs/lib/Utils/auth-utils.d.ts +58 -0
- package/cjs/lib/Utils/auth-utils.js +275 -0
- package/cjs/lib/Utils/browser-utils.d.ts +9 -0
- package/cjs/lib/Utils/browser-utils.js +56 -0
- package/cjs/lib/Utils/business.d.ts +49 -0
- package/cjs/lib/Utils/business.js +259 -0
- package/cjs/lib/Utils/chat-utils.d.ts +408 -0
- package/cjs/lib/Utils/chat-utils.js +821 -0
- package/cjs/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/cjs/lib/Utils/companion-reg-client-utils.js +71 -0
- package/cjs/lib/Utils/crypto.d.ts +39 -0
- package/cjs/lib/Utils/crypto.js +155 -0
- package/cjs/lib/Utils/decode-wa-message.d.ts +83 -0
- package/cjs/lib/Utils/decode-wa-message.js +316 -0
- package/cjs/lib/Utils/event-buffer.d.ts +12 -0
- package/cjs/lib/Utils/event-buffer.js +605 -0
- package/cjs/lib/Utils/generics.d.ts +63 -0
- package/cjs/lib/Utils/generics.js +440 -0
- package/cjs/lib/Utils/history.d.ts +75 -0
- package/cjs/lib/Utils/history.js +153 -0
- package/cjs/lib/Utils/identity-change-handler.d.ts +13 -0
- package/cjs/lib/Utils/identity-change-handler.js +73 -0
- package/cjs/lib/Utils/index.d.ts +24 -0
- package/cjs/lib/Utils/index.js +67 -0
- package/cjs/lib/Utils/link-preview.d.ts +13 -0
- package/cjs/lib/Utils/link-preview.js +87 -0
- package/cjs/lib/Utils/logger.d.ts +12 -0
- package/cjs/lib/Utils/logger.js +40 -0
- package/cjs/lib/Utils/lt-hash.d.ts +6 -0
- package/cjs/lib/Utils/lt-hash.js +28 -0
- package/cjs/lib/Utils/make-mutex.d.ts +6 -0
- package/cjs/lib/Utils/make-mutex.js +58 -0
- package/cjs/lib/Utils/message-retry-manager.d.ts +79 -0
- package/cjs/lib/Utils/message-retry-manager.js +274 -0
- package/cjs/lib/Utils/messages-media.d.ts +134 -0
- package/cjs/lib/Utils/messages-media.js +799 -0
- package/cjs/lib/Utils/messages.d.ts +47 -0
- package/cjs/lib/Utils/messages.js +1667 -0
- package/cjs/lib/Utils/noise-handler.d.ts +20 -0
- package/cjs/lib/Utils/noise-handler.js +223 -0
- package/cjs/lib/Utils/offline-node-processor.d.ts +10 -0
- package/cjs/lib/Utils/offline-node-processor.js +60 -0
- package/cjs/lib/Utils/pre-key-manager.d.ts +25 -0
- package/cjs/lib/Utils/pre-key-manager.js +116 -0
- package/cjs/lib/Utils/process-message.d.ts +83 -0
- package/cjs/lib/Utils/process-message.js +607 -0
- package/cjs/lib/Utils/reporting-utils.d.ts +12 -0
- package/cjs/lib/Utils/reporting-utils.js +282 -0
- package/cjs/lib/Utils/rich-message-utils.d.ts +48 -0
- package/cjs/lib/Utils/rich-message-utils.js +381 -0
- package/cjs/lib/Utils/signal.d.ts +82 -0
- package/cjs/lib/Utils/signal.js +232 -0
- package/cjs/lib/Utils/stanza-ack.d.ts +16 -0
- package/cjs/lib/Utils/stanza-ack.js +53 -0
- package/cjs/lib/Utils/sync-action-utils.d.ts +2 -0
- package/cjs/lib/Utils/sync-action-utils.js +68 -0
- package/cjs/lib/Utils/tc-token-utils.d.ts +29 -0
- package/cjs/lib/Utils/tc-token-utils.js +182 -0
- package/cjs/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/cjs/lib/Utils/use-multi-file-auth-state.js +135 -0
- package/cjs/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/cjs/lib/Utils/use-single-file-auth-state.js +115 -0
- package/cjs/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/cjs/lib/Utils/use-sqlite-auth-state.js +140 -0
- package/cjs/lib/Utils/validate-connection.d.ts +44 -0
- package/cjs/lib/Utils/validate-connection.js +229 -0
- package/cjs/lib/WABinary/constants.d.ts +61 -0
- package/cjs/lib/WABinary/constants.js +1992 -0
- package/cjs/lib/WABinary/decode.d.ts +9 -0
- package/cjs/lib/WABinary/decode.js +292 -0
- package/cjs/lib/WABinary/encode.d.ts +2 -0
- package/cjs/lib/WABinary/encode.js +240 -0
- package/cjs/lib/WABinary/generic-utils.d.ts +79 -0
- package/cjs/lib/WABinary/generic-utils.js +252 -0
- package/cjs/lib/WABinary/index.d.ts +5 -0
- package/cjs/lib/WABinary/index.js +29 -0
- package/cjs/lib/WABinary/jid-utils.d.ts +28 -0
- package/cjs/lib/WABinary/jid-utils.js +151 -0
- package/cjs/lib/WABinary/types.d.ts +1 -0
- package/cjs/lib/WABinary/types.js +23 -0
- package/cjs/lib/WACrypto/appstate-keys.js +39 -0
- package/cjs/lib/WACrypto/curves/constants.js +37 -0
- package/cjs/lib/WACrypto/hkdf.js +38 -0
- package/cjs/lib/WACrypto/index.js +51 -0
- package/cjs/lib/WACrypto/lthash.js +59 -0
- package/cjs/lib/WACrypto/math/constants.js +53 -0
- package/cjs/lib/WACrypto/math/edwards.js +206 -0
- package/cjs/lib/WACrypto/math/fe.js +449 -0
- package/cjs/lib/WACrypto/math/le.js +44 -0
- package/cjs/lib/WACrypto/math/mod.js +36 -0
- package/cjs/lib/WACrypto/util/bytes.js +348 -0
- package/cjs/lib/WACrypto/x25519.js +157 -0
- package/cjs/lib/WACrypto/xeddsa.js +134 -0
- package/cjs/lib/WAM/BinaryInfo.d.ts +7 -0
- package/cjs/lib/WAM/BinaryInfo.js +35 -0
- package/cjs/lib/WAM/constants.d.ts +34926 -0
- package/cjs/lib/WAM/constants.js +22890 -0
- package/cjs/lib/WAM/encode.d.ts +1 -0
- package/cjs/lib/WAM/encode.js +162 -0
- package/cjs/lib/WAM/index.d.ts +3 -0
- package/cjs/lib/WAM/index.js +25 -0
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.js +77 -0
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.js +76 -0
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +52 -0
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.js +61 -0
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.js +50 -0
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +76 -0
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.js +53 -0
- package/cjs/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/cjs/lib/WAUSync/Protocols/index.js +29 -0
- package/cjs/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/cjs/lib/WAUSync/USyncQuery.js +113 -0
- package/cjs/lib/WAUSync/USyncUser.d.ts +16 -0
- package/cjs/lib/WAUSync/USyncUser.js +56 -0
- package/cjs/lib/WAUSync/index.d.ts +3 -0
- package/cjs/lib/WAUSync/index.js +25 -0
- package/cjs/lib/index.d.ts +11 -0
- package/cjs/lib/index.js +56 -0
- package/cjs/package.json +3 -0
- package/engine-requirements.js +12 -0
- package/lib/Addon/http-error.d.ts +18 -0
- package/lib/Addon/http-error.js +40 -0
- package/lib/Addon/index.d.ts +3 -0
- package/lib/Addon/index.js +4 -0
- package/lib/Addon/keyed-db.d.ts +14 -0
- package/lib/Addon/keyed-db.js +241 -0
- package/lib/Addon/link-preview.d.ts +15 -0
- package/lib/Addon/link-preview.js +79 -0
- package/lib/Defaults/index.d.ts +184 -0
- package/lib/Defaults/index.js +181 -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-cipher.d.ts +10 -0
- package/lib/Signal/Group/group-cipher.js +81 -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/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 +54 -0
- package/lib/Signal/libsignal.js +426 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +274 -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 +119 -0
- package/lib/Socket/business.d.ts +387 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +144 -0
- package/lib/Socket/chats.js +1216 -0
- package/lib/Socket/communities.d.ts +554 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/groups.d.ts +286 -0
- package/lib/Socket/groups.js +347 -0
- package/lib/Socket/index.d.ts +522 -0
- package/lib/Socket/index.js +11 -0
- package/lib/Socket/messages-recv.d.ts +326 -0
- package/lib/Socket/messages-recv.js +1822 -0
- package/lib/Socket/messages-send.d.ts +321 -0
- package/lib/Socket/messages-send.js +1378 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.d.ts +283 -0
- package/lib/Socket/newsletter.js +225 -0
- package/lib/Socket/socket.d.ts +61 -0
- package/lib/Socket/socket.js +992 -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 +63 -0
- package/lib/Store/make-in-memory-store.js +419 -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/Transport/crypto.d.ts +6 -0
- package/lib/Transport/crypto.js +61 -0
- package/lib/Transport/curve.d.ts +8 -0
- package/lib/Transport/curve.js +66 -0
- package/lib/Transport/index.d.ts +16 -0
- package/lib/Transport/index.js +9 -0
- package/lib/Transport/internals.d.ts +57 -0
- package/lib/Transport/internals.js +155 -0
- package/lib/Transport/session-builder.d.ts +40 -0
- package/lib/Transport/session-builder.js +143 -0
- package/lib/Transport/session-cipher.d.ts +26 -0
- package/lib/Transport/session-cipher.js +301 -0
- package/lib/Transport/session-record.d.ts +55 -0
- package/lib/Transport/session-record.js +272 -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 +54 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +13 -0
- package/lib/Types/index.js +25 -0
- package/lib/Utils/auth-utils.d.ts +58 -0
- package/lib/Utils/auth-utils.js +316 -0
- package/lib/Utils/browser-utils.d.ts +9 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.d.ts +408 -0
- package/lib/Utils/chat-utils.js +871 -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/crypto.d.ts +39 -0
- package/lib/Utils/crypto.js +117 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +316 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +621 -0
- package/lib/Utils/generics.d.ts +63 -0
- package/lib/Utils/generics.js +394 -0
- package/lib/Utils/history.d.ts +75 -0
- package/lib/Utils/history.js +133 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.d.ts +24 -0
- package/lib/Utils/index.js +24 -0
- package/lib/Utils/link-preview.d.ts +13 -0
- package/lib/Utils/link-preview.js +73 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.js +12 -0
- package/lib/Utils/lt-hash.d.ts +6 -0
- package/lib/Utils/lt-hash.js +7 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +259 -0
- package/lib/Utils/messages-media.d.ts +134 -0
- package/lib/Utils/messages-media.js +802 -0
- package/lib/Utils/messages.d.ts +47 -0
- package/lib/Utils/messages.js +1911 -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 +10 -0
- package/lib/Utils/offline-node-processor.js +40 -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 +83 -0
- package/lib/Utils/process-message.js +748 -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 +48 -0
- package/lib/Utils/rich-message-utils.js +369 -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/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +163 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-multi-file-auth-state.js +116 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +94 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +109 -0
- package/lib/Utils/validate-connection.d.ts +44 -0
- package/lib/Utils/validate-connection.js +210 -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 +79 -0
- package/lib/WABinary/generic-utils.js +228 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WACrypto/appstate-keys.js +26 -0
- package/lib/WACrypto/curves/constants.js +12 -0
- package/lib/WACrypto/hkdf.js +27 -0
- package/lib/WACrypto/index.js +20 -0
- package/lib/WACrypto/lthash.js +54 -0
- package/lib/WACrypto/math/constants.js +24 -0
- package/lib/WACrypto/math/edwards.js +194 -0
- package/lib/WACrypto/math/fe.js +698 -0
- package/lib/WACrypto/math/le.js +23 -0
- package/lib/WACrypto/math/mod.js +15 -0
- package/lib/WACrypto/util/bytes.js +339 -0
- package/lib/WACrypto/x25519.js +145 -0
- package/lib/WACrypto/xeddsa.js +92 -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/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -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 +50 -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 +5 -0
- package/lib/WAUSync/Protocols/index.js +5 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +97 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/USyncUser.js +30 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/package.json +79 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rajeh Taher/WhiskeySockets
|
|
4
|
+
Copyright (c) 2026 Lia Wynn
|
|
5
|
+
Copyright (c) 2026 eduh_dev021
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,496 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @eduh_dev021/baileys
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A WhatsApp library for Node.js. It lets your code talk to WhatsApp directly — no browser, no WhatsApp Business API, no extra accounts. You can send and receive messages, media, stickers, polls, buttons and much more, all from a regular Node.js script or bot.
|
|
4
|
+
|
|
5
|
+
This package is a fixed and maintained build of the Baileys v7 you already know. It keeps the same functions and the same API, so code written for `@whiskeysockets/baileys` or `@itsliaaa/baileys` keeps working — you only change the import line.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @eduh_dev021/baileys
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What was fixed in this version
|
|
14
|
+
|
|
15
|
+
The previous fork depended on a large compiled WebAssembly file (`whatsapp-rust-bridge`, ~2 MB) to do its cryptographic work. That made installs heavy and fragile: it could fail on hosts with limited WASM support, on unusual platforms, and it added a hard-to-maintain binary dependency.
|
|
16
|
+
|
|
17
|
+
In this version **all of that WASM code was removed** and replaced by plain TypeScript that uses the crypto functions already built into Node.js. The new crypto layer was written based on the well-maintained [zapo-js](https://github.com/vinikjkkj/zapo) project, and every function was tested byte-for-byte against the old implementation:
|
|
18
|
+
|
|
19
|
+
| Function area | What it does | Tested result |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| Curve25519 (key agreement) | Creates key pairs and shared secrets | Identical output |
|
|
22
|
+
| XEdDSA (signatures) | Signs and verifies messages | Fully compatible both ways |
|
|
23
|
+
| HKDF / MD5 | Key derivation and hashing | Identical output |
|
|
24
|
+
| LT-Hash | Detects tampering in synced state | Identical output |
|
|
25
|
+
| App-state keys | Expands sync keys for chat backup | Identical output |
|
|
26
|
+
|
|
27
|
+
The public API is unchanged: the package exports exactly the same 301 names as the previous version. The package now ships both ESM and CommonJS builds, so `import` and `require` both work.
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
- Node.js 20 or newer (Node 22/24 recommended)
|
|
32
|
+
- For media features (video thumbnails, audio waveforms): `ffmpeg` and `ffprobe` installed on the system
|
|
33
|
+
|
|
34
|
+
Some optional features use optional peer dependencies, installed only if you want them:
|
|
35
|
+
|
|
36
|
+
- `ws` — WebSocket client (needed on Node.js below 22; install it unless you are sure you don't need it)
|
|
37
|
+
- `sharp`, `jimp` or `@napi-rs/image` — image processing for thumbnails (install at least one)
|
|
38
|
+
- `better-sqlite3` — only for `useSqliteAuthState` on Node.js below 22.13
|
|
39
|
+
- `qr` — only for the `printQRInTerminal` option
|
|
40
|
+
|
|
41
|
+
Simplest setup for most users:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
npm install @eduh_dev021/baileys ws sharp
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# npm
|
|
51
|
+
npm install @eduh_dev021/baileys
|
|
52
|
+
|
|
53
|
+
# yarn
|
|
54
|
+
yarn add @eduh_dev021/baileys
|
|
55
|
+
|
|
56
|
+
# pnpm
|
|
57
|
+
pnpm add @eduh_dev021/baileys
|
|
58
|
+
|
|
59
|
+
# bun
|
|
60
|
+
bun add @eduh_dev021/baileys
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Importing
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// --- ESM (import)
|
|
67
|
+
import { makeWASocket } from '@eduh_dev021/baileys'
|
|
68
|
+
|
|
69
|
+
// --- CommonJS (require) — works on Node.js 22+ natively
|
|
70
|
+
const { makeWASocket } = require('@eduh_dev021/baileys')
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Quick start: connect to WhatsApp
|
|
74
|
+
|
|
75
|
+
This complete example connects using a **pairing code** (you type your phone number and WhatsApp shows a code to confirm). It also shows how to answer messages automatically.
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
import {
|
|
79
|
+
makeWASocket,
|
|
80
|
+
useMultiFileAuthState,
|
|
81
|
+
delay,
|
|
82
|
+
DisconnectReason
|
|
83
|
+
} from '@eduh_dev021/baileys'
|
|
84
|
+
|
|
85
|
+
const myPhoneNumber = '5511999999999' // your number, with country code, no + or spaces
|
|
86
|
+
|
|
87
|
+
const connectToWhatsApp = async () => {
|
|
88
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
89
|
+
|
|
90
|
+
const sock = makeWASocket({
|
|
91
|
+
auth: state,
|
|
92
|
+
printQRInTerminal: true // also shows a QR code, if the "qr" package is installed
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
sock.ev.on('creds.update', saveCreds)
|
|
96
|
+
|
|
97
|
+
sock.ev.on('connection.update', async (update) => {
|
|
98
|
+
const { connection, lastDisconnect, qr } = update
|
|
99
|
+
|
|
100
|
+
if (qr && !sock.authState.creds.registered) {
|
|
101
|
+
await delay(1500)
|
|
102
|
+
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
103
|
+
console.log('Pairing code:', code)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (connection === 'close') {
|
|
107
|
+
const shouldReconnect =
|
|
108
|
+
lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
|
|
109
|
+
if (shouldReconnect) connectToWhatsApp()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (connection === 'open') {
|
|
113
|
+
console.log('Connected to WhatsApp!')
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
118
|
+
for (const message of messages) {
|
|
119
|
+
if (!message.message) continue // ignore status and empty messages
|
|
120
|
+
console.log('New message:', message)
|
|
121
|
+
await sock.sendMessage(message.key.remoteJid, { text: 'Hello! 👋' })
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
connectToWhatsApp()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The first run asks WhatsApp for a pairing code. Type it in the WhatsApp app on your phone (Linked devices → Link a device → Link with phone number instead). After that, the `session` folder stores your login and you stay connected.
|
|
130
|
+
|
|
131
|
+
## Saving your login (auth state)
|
|
132
|
+
|
|
133
|
+
Three ready-made options are included:
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
import {
|
|
137
|
+
useMultiFileAuthState,
|
|
138
|
+
useSingleFileAuthState,
|
|
139
|
+
useSqliteAuthState
|
|
140
|
+
} from '@eduh_dev021/baileys'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- `useMultiFileAuthState(folder?)` — saves the login as several JSON files inside a folder. Traditional and easy to back up. This is the most used option.
|
|
144
|
+
- `useSingleFileAuthState(fileName?)` — saves everything in one JSON file. Simple to copy or move.
|
|
145
|
+
- `useSqliteAuthState(dbPath?, ownedDatabase?)` — saves in an SQLite database. On Node.js 22.13+ and Bun it works with no extra package; on older versions install `better-sqlite3`.
|
|
146
|
+
|
|
147
|
+
All three return `{ state, saveCreds }`. Always connect `saveCreds` to the `creds.update` event, as the quick start shows — that is what keeps the session saved between restarts.
|
|
148
|
+
|
|
149
|
+
## Remembering chats and contacts (store)
|
|
150
|
+
|
|
151
|
+
Baileys does not keep a list of your chats and contacts. If you want one, you can use the built-in in-memory store:
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
import { makeWASocket, makeInMemoryStore, useMultiFileAuthState } from '@eduh_dev021/baileys'
|
|
155
|
+
|
|
156
|
+
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
157
|
+
const sock = makeWASocket({ auth: state })
|
|
158
|
+
|
|
159
|
+
const store = makeInMemoryStore({ socket: sock })
|
|
160
|
+
store.bind(sock.ev)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Note: keeping every chat in memory can use a lot of RAM on busy bots. For big bots it is better to build your own storage from the events you receive.
|
|
164
|
+
|
|
165
|
+
## Sending messages
|
|
166
|
+
|
|
167
|
+
Every example below uses `sock` from the quick start and `jid` as the chat address. A `jid` looks like:
|
|
168
|
+
|
|
169
|
+
- `5511999999999@s.whatsapp.net` — a person
|
|
170
|
+
- `120363...@g.us` — a group
|
|
171
|
+
- `123456789@newsletter` — a channel (newsletter)
|
|
172
|
+
- `status@broadcast` — status/stories
|
|
173
|
+
|
|
174
|
+
### Text
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
await sock.sendMessage(jid, { text: 'Hello from my bot!' })
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
With formatting and a link preview:
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
await sock.sendMessage(jid, {
|
|
184
|
+
text: '*bold* _italic_ ~strikethrough~ ```code```\nhttps://example.com'
|
|
185
|
+
})
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Replying to a specific message:
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
await sock.sendMessage(jid, { text: 'Great message!' }, { quoted: receivedMessage })
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Mention
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
await sock.sendMessage(jid, {
|
|
198
|
+
text: 'Hey @5511999999999, look at this!',
|
|
199
|
+
mentions: ['5511999999999@s.whatsapp.net']
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Reaction
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
await sock.sendMessage(jid, {
|
|
207
|
+
react: { text: '👍', key: receivedMessage.key }
|
|
208
|
+
})
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Pin and unpin a message
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
// pin for 86400 seconds (1 day); 604800 = 1 week
|
|
215
|
+
await sock.sendMessage(jid, { pin: { type: 1, key: receivedMessage.key, time: 86400 } })
|
|
216
|
+
|
|
217
|
+
// unpin
|
|
218
|
+
await sock.sendMessage(jid, { pin: { type: 0, key: receivedMessage.key, time: 0 } })
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Keep a message in the chat
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
await sock.sendMessage(jid, { keep: { type: 1, key: receivedMessage.key, time: 0 } })
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Forward a message
|
|
228
|
+
|
|
229
|
+
```javascript
|
|
230
|
+
await sock.sendMessage(jid, { forward: receivedMessage })
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Contact
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
await sock.sendMessage(jid, {
|
|
237
|
+
contacts: {
|
|
238
|
+
displayName: 'Maria',
|
|
239
|
+
contacts: [{ vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:Maria\nTEL;type=CELL:+5511999999999\nEND:VCARD' }]
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Location
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
await sock.sendMessage(jid, {
|
|
248
|
+
location: { degreesLatitude: -23.5505, degreesLongitude: -46.6333 }
|
|
249
|
+
})
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Event (calendar invitation)
|
|
253
|
+
|
|
254
|
+
```javascript
|
|
255
|
+
await sock.sendMessage(jid, {
|
|
256
|
+
event: {
|
|
257
|
+
name: 'Team meeting',
|
|
258
|
+
description: 'Weekly sync',
|
|
259
|
+
startTime: Date.now() + 3600000,
|
|
260
|
+
endTime: Date.now() + 7200000,
|
|
261
|
+
isCanceled: false
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Group invite
|
|
267
|
+
|
|
268
|
+
```javascript
|
|
269
|
+
await sock.sendMessage(jid, {
|
|
270
|
+
groupInvite: {
|
|
271
|
+
inviteCode: 'abc123def456',
|
|
272
|
+
inviteExpiration: Date.now() + 86400000,
|
|
273
|
+
groupName: 'My group',
|
|
274
|
+
caption: 'Join us!'
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Product
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
await sock.sendMessage(jid, {
|
|
283
|
+
product: {
|
|
284
|
+
productImage: imageBuffer,
|
|
285
|
+
productId: '123456789',
|
|
286
|
+
title: 'Nice shoes',
|
|
287
|
+
description: 'Size 42, blue',
|
|
288
|
+
currencyCode: 'BRL',
|
|
289
|
+
priceAmount1000: 29990, // price × 1000
|
|
290
|
+
retailerId: 'store-001',
|
|
291
|
+
url: 'https://mystore.com/item/123456789'
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Poll
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
await sock.sendMessage(jid, {
|
|
300
|
+
poll: {
|
|
301
|
+
name: 'Pizza or burger?',
|
|
302
|
+
values: ['Pizza', 'Burger'],
|
|
303
|
+
selectableCount: 1
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Sending media
|
|
309
|
+
|
|
310
|
+
For media, pass a Buffer, a local file path, or a URL in the `url` field of each type.
|
|
311
|
+
|
|
312
|
+
### Image
|
|
313
|
+
|
|
314
|
+
```javascript
|
|
315
|
+
await sock.sendMessage(jid, {
|
|
316
|
+
image: { url: './photo.jpg' },
|
|
317
|
+
caption: 'Check this out!'
|
|
318
|
+
})
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Video
|
|
322
|
+
|
|
323
|
+
```javascript
|
|
324
|
+
await sock.sendMessage(jid, {
|
|
325
|
+
video: { url: './clip.mp4' },
|
|
326
|
+
caption: 'Watch this',
|
|
327
|
+
gifPlayback: false
|
|
328
|
+
})
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Sticker
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
await sock.sendMessage(jid, {
|
|
335
|
+
sticker: { url: './funny.webp' }
|
|
336
|
+
})
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Audio (voice note)
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
await sock.sendMessage(jid, {
|
|
343
|
+
audio: { url: './voice.ogg' },
|
|
344
|
+
mimetype: 'audio/ogg; codecs=opus',
|
|
345
|
+
ptt: true // set true to show it as a voice note with waveform
|
|
346
|
+
})
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Document
|
|
350
|
+
|
|
351
|
+
```javascript
|
|
352
|
+
await sock.sendMessage(jid, {
|
|
353
|
+
document: { url: './report.pdf' },
|
|
354
|
+
mimetype: 'application/pdf',
|
|
355
|
+
fileName: 'Quarterly report.pdf'
|
|
356
|
+
})
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Album (several images/videos in one message)
|
|
360
|
+
|
|
361
|
+
```javascript
|
|
362
|
+
await sock.sendMessage(jid, {
|
|
363
|
+
album: {
|
|
364
|
+
caption: 'My album',
|
|
365
|
+
images: [{ url: './photo1.jpg' }, { url: './photo2.jpg' }],
|
|
366
|
+
videos: [{ url: './clip.mp4' }]
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## Interactive messages (buttons and lists)
|
|
372
|
+
|
|
373
|
+
### Buttons
|
|
374
|
+
|
|
375
|
+
```javascript
|
|
376
|
+
await sock.sendMessage(jid, {
|
|
377
|
+
buttons: [
|
|
378
|
+
{ buttonId: '#help', buttonText: { displayText: 'Help' }, type: 1 },
|
|
379
|
+
{ buttonId: '#menu', buttonText: { displayText: 'Menu' }, type: 1 }
|
|
380
|
+
],
|
|
381
|
+
headerType: 1,
|
|
382
|
+
contentText: 'What do you want to do?',
|
|
383
|
+
footerText: 'My bot'
|
|
384
|
+
})
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### List
|
|
388
|
+
|
|
389
|
+
```javascript
|
|
390
|
+
await sock.sendMessage(jid, {
|
|
391
|
+
list: {
|
|
392
|
+
listType: 1,
|
|
393
|
+
title: 'Options',
|
|
394
|
+
buttonText: 'Choose',
|
|
395
|
+
description: 'Pick an option',
|
|
396
|
+
sections: [{
|
|
397
|
+
title: 'Main',
|
|
398
|
+
rows: [
|
|
399
|
+
{ title: 'Help', rowId: '#help', description: 'How to use' },
|
|
400
|
+
{ title: 'Menu', rowId: '#menu', description: 'Show the menu' }
|
|
401
|
+
]
|
|
402
|
+
}]
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Modifying messages
|
|
408
|
+
|
|
409
|
+
### Delete a message
|
|
410
|
+
|
|
411
|
+
```javascript
|
|
412
|
+
// delete for everyone
|
|
413
|
+
await sock.sendMessage(jid, { delete: receivedMessage.key })
|
|
414
|
+
|
|
415
|
+
// delete only for yourself
|
|
416
|
+
await sock.sendMessage(jid, { delete: { ...receivedMessage.key, fromMe: false, participant: sock.user.id } })
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Edit a sent message
|
|
420
|
+
|
|
421
|
+
```javascript
|
|
422
|
+
await sock.sendMessage(jid, { text: 'Corrected text' }, { edit: sentMessage.key })
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
## Events you can listen to
|
|
426
|
+
|
|
427
|
+
The main events on `sock.ev`:
|
|
428
|
+
|
|
429
|
+
| Event | When it fires |
|
|
430
|
+
| --- | --- |
|
|
431
|
+
| `connection.update` | Connection state changed (connecting, open, close, qr received) |
|
|
432
|
+
| `creds.update` | Login credentials changed — save them here |
|
|
433
|
+
| `messages.upsert` | New message arrived (or message history loaded) |
|
|
434
|
+
| `messages.update` | Message status changed (delivered, read, edited) |
|
|
435
|
+
| `message-receipt.update` | Delivery/read receipts in bulk |
|
|
436
|
+
| `groups.update` | Group info changed |
|
|
437
|
+
| `group-participants.update` | Someone joined or left a group |
|
|
438
|
+
| `presence.update` | Contact online/typing status |
|
|
439
|
+
| `chats.update` / `chats.delete` | Chat list changed |
|
|
440
|
+
| `contact.update` | Contact info changed |
|
|
441
|
+
|
|
442
|
+
```javascript
|
|
443
|
+
sock.ev.on('messages.update', (updates) => {
|
|
444
|
+
for (const { key, update } of updates) {
|
|
445
|
+
if (update.status) console.log('Message status:', key.id, update.status)
|
|
446
|
+
}
|
|
447
|
+
})
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## Groups, channels and communities
|
|
451
|
+
|
|
452
|
+
All the management functions are on the socket. The most used ones:
|
|
453
|
+
|
|
454
|
+
```javascript
|
|
455
|
+
// Groups
|
|
456
|
+
await sock.groupCreate('My group', ['5511999999999@s.whatsapp.net'])
|
|
457
|
+
await sock.groupAdd(jid, ['5511999999999@s.whatsapp.net'])
|
|
458
|
+
await sock.groupParticipantsUpdate(jid, ['5511999999999@s.whatsapp.net'], 'promote')
|
|
459
|
+
await sock.groupMetadata(jid)
|
|
460
|
+
await sock.groupInviteCode(jid)
|
|
461
|
+
await sock.groupSettingUpdate(jid, 'announcement') // only admins can post
|
|
462
|
+
|
|
463
|
+
// Channels (newsletters)
|
|
464
|
+
await sock.newsletterCreate('My channel', 'Description')
|
|
465
|
+
await sock.newsletterFollow(jid)
|
|
466
|
+
await sock.newsletterMetadata('invite', inviteCode)
|
|
467
|
+
await sock.newsletterReact(jid, messageId, '👍')
|
|
468
|
+
|
|
469
|
+
// Communities
|
|
470
|
+
await sock.communityCreate('My community', description)
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
## Useful details
|
|
474
|
+
|
|
475
|
+
- **WhatsApp IDs**: person chats use `@s.whatsapp.net`, groups use `@g.us`, channels use `@newsletter`. Newer accounts also have a `@lid` companion ID — the library handles the mapping for you in most cases.
|
|
476
|
+
- **Custom pairing code**: `sock.requestPairingCode(phoneNumber, 'MYBOT123')` shows a custom code instead of a random one.
|
|
477
|
+
- **Fetch latest version info**: `fetchLatestBaileysVersion()` returns the current WhatsApp Web version the library should announce.
|
|
478
|
+
- **Media retry**: `decryptMediaRetryData` and `encryptMediaRetryRequest` are exported for advanced media-download recovery.
|
|
479
|
+
|
|
480
|
+
## Common problems
|
|
481
|
+
|
|
482
|
+
**"Connection closed" right after connecting** — usually the session expired or WhatsApp logged you out. Delete the session folder and pair again.
|
|
483
|
+
|
|
484
|
+
**Send fails with a thumbnail error** — install one of the image libraries (`sharp` is the most common) and make sure `ffmpeg`/`ffprobe` are on your system PATH for videos and audio.
|
|
485
|
+
|
|
486
|
+
**Node version error on install** — this package needs Node.js 20 or newer. Check with `node -v`.
|
|
487
|
+
|
|
488
|
+
**Stickers not converting** — sticker conversion needs `ffmpeg` for animated stickers.
|
|
489
|
+
|
|
490
|
+
**Cannot require the package on Node.js 18** — the CommonJS build requires Node.js 20+ (the package states `engines: >=20`). Upgrade Node.js.
|
|
491
|
+
|
|
492
|
+
## License
|
|
493
|
+
|
|
494
|
+
Released under the [MIT License](LICENSE).
|
|
495
|
+
|
|
496
|
+
The underlying protocol implementation descends from the Baileys family of libraries; parts of the internal crypto layer are derived from zapo-js (MIT). See the headers of the files in `lib/WACrypto/` for details.
|