@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
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var generics_exports = {};
|
|
19
|
+
__export(generics_exports, {
|
|
20
|
+
BufferJSON: () => BufferJSON,
|
|
21
|
+
bindWaitForConnectionUpdate: () => bindWaitForConnectionUpdate,
|
|
22
|
+
bindWaitForEvent: () => bindWaitForEvent,
|
|
23
|
+
bytesToCrockford: () => bytesToCrockford,
|
|
24
|
+
debouncedTimeout: () => debouncedTimeout,
|
|
25
|
+
delay: () => delay,
|
|
26
|
+
delayCancellable: () => delayCancellable,
|
|
27
|
+
encodeBigEndian: () => encodeBigEndian,
|
|
28
|
+
encodeNewsletterMessage: () => encodeNewsletterMessage,
|
|
29
|
+
encodeWAMessage: () => encodeWAMessage,
|
|
30
|
+
fetchLatestBaileysVersion: () => fetchLatestBaileysVersion,
|
|
31
|
+
fetchLatestWaWebVersion: () => fetchLatestWaWebVersion,
|
|
32
|
+
generateMdTagPrefix: () => generateMdTagPrefix,
|
|
33
|
+
generateMessageID: () => generateMessageID,
|
|
34
|
+
generateMessageIDV2: () => generateMessageIDV2,
|
|
35
|
+
generateParticipantHashV2: () => generateParticipantHashV2,
|
|
36
|
+
generateRegistrationId: () => generateRegistrationId,
|
|
37
|
+
getCallStatusFromNode: () => getCallStatusFromNode,
|
|
38
|
+
getCodeFromWSError: () => getCodeFromWSError,
|
|
39
|
+
getErrorCodeFromStreamError: () => getErrorCodeFromStreamError,
|
|
40
|
+
getKeyAuthor: () => getKeyAuthor,
|
|
41
|
+
getStatusFromReceiptType: () => getStatusFromReceiptType,
|
|
42
|
+
isStringNullOrEmpty: () => isStringNullOrEmpty,
|
|
43
|
+
isWABusinessPlatform: () => isWABusinessPlatform,
|
|
44
|
+
promiseTimeout: () => promiseTimeout,
|
|
45
|
+
toNumber: () => toNumber,
|
|
46
|
+
trimUndefined: () => trimUndefined,
|
|
47
|
+
unixTimestampSeconds: () => unixTimestampSeconds,
|
|
48
|
+
unpadRandomMax16: () => unpadRandomMax16,
|
|
49
|
+
writeRandomPadMax16: () => writeRandomPadMax16
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(generics_exports);
|
|
52
|
+
var import_node_crypto = require("node:crypto");
|
|
53
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
54
|
+
var import_Addon = require("../Addon/index.js");
|
|
55
|
+
var import_Types = require("../Types/index.js");
|
|
56
|
+
var import_WABinary = require("../WABinary/index.js");
|
|
57
|
+
var import_crypto = require("./crypto.js");
|
|
58
|
+
const baileysVersion = [2, 3e3, 1054623785];
|
|
59
|
+
const BufferJSON = {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
replacer: (k, value) => {
|
|
62
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array || value?.type === "Buffer") {
|
|
63
|
+
return { type: "Buffer", data: Buffer.from(value?.data || value).toString("base64") };
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
},
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
reviver: (_, value) => {
|
|
69
|
+
if (typeof value === "object" && value !== null && value.type === "Buffer" && typeof value.data === "string") {
|
|
70
|
+
return Buffer.from(value.data, "base64");
|
|
71
|
+
}
|
|
72
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
73
|
+
const keys = Object.keys(value);
|
|
74
|
+
if (keys.length > 0 && keys.every((k) => !isNaN(parseInt(k, 10)))) {
|
|
75
|
+
const values = Object.values(value);
|
|
76
|
+
if (values.every((v) => typeof v === "number")) {
|
|
77
|
+
return Buffer.from(values);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const getKeyAuthor = (key, meId = "me") => (key?.fromMe ? meId : key?.participantAlt || key?.remoteJidAlt || key?.participant || key?.remoteJid) || "";
|
|
85
|
+
const isStringNullOrEmpty = (value) => (
|
|
86
|
+
// eslint-disable-next-line eqeqeq
|
|
87
|
+
value == null || value === ""
|
|
88
|
+
);
|
|
89
|
+
const writeRandomPadMax16 = (msg) => {
|
|
90
|
+
const pad = (0, import_node_crypto.randomBytes)(1);
|
|
91
|
+
const padLength = (pad[0] & 15) + 1;
|
|
92
|
+
return Buffer.concat([msg, Buffer.alloc(padLength, padLength)]);
|
|
93
|
+
};
|
|
94
|
+
const unpadRandomMax16 = (e) => {
|
|
95
|
+
const t = new Uint8Array(e);
|
|
96
|
+
if (0 === t.length) {
|
|
97
|
+
throw new Error("unpadPkcs7 given empty bytes");
|
|
98
|
+
}
|
|
99
|
+
var r = t[t.length - 1];
|
|
100
|
+
if (r > t.length) {
|
|
101
|
+
throw new Error(`unpad given ${t.length} bytes, but pad is ${r}`);
|
|
102
|
+
}
|
|
103
|
+
return new Uint8Array(t.buffer, t.byteOffset, t.length - r);
|
|
104
|
+
};
|
|
105
|
+
const generateParticipantHashV2 = (participants) => {
|
|
106
|
+
participants.sort();
|
|
107
|
+
const sha256Hash = (0, import_crypto.sha256)(Buffer.from(participants.join(""))).toString("base64");
|
|
108
|
+
return "2:" + sha256Hash.slice(0, 6);
|
|
109
|
+
};
|
|
110
|
+
const encodeWAMessage = (message) => writeRandomPadMax16(import_WAProto.proto.Message.encode(message).finish());
|
|
111
|
+
const generateRegistrationId = () => {
|
|
112
|
+
return Uint16Array.from((0, import_node_crypto.randomBytes)(2))[0] & 16383;
|
|
113
|
+
};
|
|
114
|
+
const encodeBigEndian = (e, t = 4) => {
|
|
115
|
+
let r = e;
|
|
116
|
+
const a = new Uint8Array(t);
|
|
117
|
+
for (let i = t - 1; i >= 0; i--) {
|
|
118
|
+
a[i] = 255 & r;
|
|
119
|
+
r >>>= 8;
|
|
120
|
+
}
|
|
121
|
+
return a;
|
|
122
|
+
};
|
|
123
|
+
const toNumber = (t) => typeof t === "object" && t ? "toNumber" in t ? t.toNumber() : t.low : t || 0;
|
|
124
|
+
const unixTimestampSeconds = (date = /* @__PURE__ */ new Date()) => date.getTime() / 1e3 | 0;
|
|
125
|
+
const debouncedTimeout = (intervalMs = 1e3, task) => {
|
|
126
|
+
let timeout;
|
|
127
|
+
return {
|
|
128
|
+
start: (newIntervalMs, newTask) => {
|
|
129
|
+
task = newTask || task;
|
|
130
|
+
intervalMs = newIntervalMs || intervalMs;
|
|
131
|
+
timeout && clearTimeout(timeout);
|
|
132
|
+
timeout = setTimeout(() => task?.(), intervalMs);
|
|
133
|
+
},
|
|
134
|
+
cancel: () => {
|
|
135
|
+
timeout && clearTimeout(timeout);
|
|
136
|
+
timeout = void 0;
|
|
137
|
+
},
|
|
138
|
+
setTask: (newTask) => task = newTask,
|
|
139
|
+
setInterval: (newInterval) => intervalMs = newInterval
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const delay = (ms) => delayCancellable(ms).delay;
|
|
143
|
+
const delayCancellable = (ms) => {
|
|
144
|
+
const stack = new Error().stack;
|
|
145
|
+
let timeout;
|
|
146
|
+
let reject;
|
|
147
|
+
const delay2 = new Promise((resolve, _reject) => {
|
|
148
|
+
timeout = setTimeout(resolve, ms);
|
|
149
|
+
reject = _reject;
|
|
150
|
+
});
|
|
151
|
+
const cancel = () => {
|
|
152
|
+
clearTimeout(timeout);
|
|
153
|
+
reject(new import_Addon.HttpError("Cancelled", {
|
|
154
|
+
statusCode: 500,
|
|
155
|
+
data: {
|
|
156
|
+
stack
|
|
157
|
+
}
|
|
158
|
+
}));
|
|
159
|
+
};
|
|
160
|
+
return { delay: delay2, cancel };
|
|
161
|
+
};
|
|
162
|
+
async function promiseTimeout(ms, promise) {
|
|
163
|
+
if (!ms) {
|
|
164
|
+
return new Promise(promise);
|
|
165
|
+
}
|
|
166
|
+
const stack = new Error().stack;
|
|
167
|
+
const { delay: delay2, cancel } = delayCancellable(ms);
|
|
168
|
+
const p = new Promise((resolve, reject) => {
|
|
169
|
+
delay2.then(() => reject(new import_Addon.HttpError("Timed Out", {
|
|
170
|
+
statusCode: import_Types.DisconnectReason.timedOut,
|
|
171
|
+
data: {
|
|
172
|
+
stack
|
|
173
|
+
}
|
|
174
|
+
}))).catch((err) => reject(err));
|
|
175
|
+
promise(resolve, reject);
|
|
176
|
+
}).finally(cancel);
|
|
177
|
+
return p;
|
|
178
|
+
}
|
|
179
|
+
const generateMessageIDV2 = (userId) => {
|
|
180
|
+
const data = Buffer.allocUnsafe(44);
|
|
181
|
+
data.writeBigUInt64BE(BigInt(Date.now() / 1e3 | 0), 0);
|
|
182
|
+
if (userId) {
|
|
183
|
+
const userStr = userId.split("@")[0].split(":")[0];
|
|
184
|
+
if (userStr) {
|
|
185
|
+
const len = data.write(userStr, 8);
|
|
186
|
+
data.write("@c.us", 8 + len);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
(0, import_node_crypto.randomFillSync)(data, 28, 16);
|
|
190
|
+
const hash = (0, import_node_crypto.createHash)("sha256").update(data).digest();
|
|
191
|
+
const hex = hash.toString("hex", 0, 9).toUpperCase();
|
|
192
|
+
const baseId = "3EB0" + hex;
|
|
193
|
+
const pos = 4 + (hash[0] & 15);
|
|
194
|
+
return baseId.slice(0, pos) + "STARFALL" + baseId.slice(pos);
|
|
195
|
+
};
|
|
196
|
+
const generateMessageID = () => "3EB0" + (0, import_node_crypto.randomBytes)(18).toString("hex").toUpperCase();
|
|
197
|
+
function bindWaitForEvent(ev, event) {
|
|
198
|
+
return async (check, timeoutMs) => {
|
|
199
|
+
let listener;
|
|
200
|
+
let closeListener;
|
|
201
|
+
await promiseTimeout(timeoutMs, (resolve, reject) => {
|
|
202
|
+
closeListener = ({ connection, lastDisconnect }) => {
|
|
203
|
+
if (connection === "close") {
|
|
204
|
+
reject(lastDisconnect?.error || new import_Addon.HttpError("Connection Closed", { statusCode: import_Types.DisconnectReason.connectionClosed }));
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
ev.on("connection.update", closeListener);
|
|
208
|
+
listener = async (update) => {
|
|
209
|
+
if (await check(update)) {
|
|
210
|
+
resolve();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
ev.on(event, listener);
|
|
214
|
+
}).finally(() => {
|
|
215
|
+
ev.off(event, listener);
|
|
216
|
+
ev.off("connection.update", closeListener);
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, "connection.update");
|
|
221
|
+
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
222
|
+
const URL = "https://raw.githubusercontent.com/itsliaaa/baileys/main/lib/Defaults/index.js";
|
|
223
|
+
try {
|
|
224
|
+
const response = await fetch(URL, {
|
|
225
|
+
dispatcher: options.dispatcher,
|
|
226
|
+
method: "GET",
|
|
227
|
+
headers: options.headers
|
|
228
|
+
});
|
|
229
|
+
if (!response.ok) {
|
|
230
|
+
throw new import_Addon.HttpError(`Failed to fetch latest Baileys version: ${response.statusText}`, { statusCode: response.status });
|
|
231
|
+
}
|
|
232
|
+
const text = await response.text();
|
|
233
|
+
const lines = text.split("\n");
|
|
234
|
+
const versionLine = lines[4];
|
|
235
|
+
const versionMatch = versionLine.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/);
|
|
236
|
+
if (versionMatch) {
|
|
237
|
+
const version = [parseInt(versionMatch[1]), parseInt(versionMatch[2]), parseInt(versionMatch[3])];
|
|
238
|
+
return {
|
|
239
|
+
version,
|
|
240
|
+
isLatest: true
|
|
241
|
+
};
|
|
242
|
+
} else {
|
|
243
|
+
throw new Error("Could not parse version from Defaults/index.ts");
|
|
244
|
+
}
|
|
245
|
+
} catch (error) {
|
|
246
|
+
return {
|
|
247
|
+
version: baileysVersion,
|
|
248
|
+
isLatest: false,
|
|
249
|
+
error
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const fetchLatestWaWebVersion = async (options = {}) => {
|
|
254
|
+
try {
|
|
255
|
+
const defaultHeaders = {
|
|
256
|
+
"sec-fetch-site": "none",
|
|
257
|
+
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
|
258
|
+
};
|
|
259
|
+
const headers = { ...defaultHeaders, ...options.headers };
|
|
260
|
+
const response = await fetch("https://web.whatsapp.com/sw.js", {
|
|
261
|
+
...options,
|
|
262
|
+
method: "GET",
|
|
263
|
+
headers
|
|
264
|
+
});
|
|
265
|
+
if (!response.ok) {
|
|
266
|
+
throw new import_Addon.HttpError(`Failed to fetch sw.js: ${response.statusText}`, { statusCode: response.status });
|
|
267
|
+
}
|
|
268
|
+
const data = await response.text();
|
|
269
|
+
const regex = /\\?"client_revision\\?":\s*(\d+)/;
|
|
270
|
+
const match = data.match(regex);
|
|
271
|
+
if (!match?.[1]) {
|
|
272
|
+
return {
|
|
273
|
+
version: baileysVersion,
|
|
274
|
+
isLatest: false,
|
|
275
|
+
error: {
|
|
276
|
+
message: "Could not find client revision in the fetched content"
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const clientRevision = match[1];
|
|
281
|
+
return {
|
|
282
|
+
version: [2, 3e3, +clientRevision],
|
|
283
|
+
isLatest: true
|
|
284
|
+
};
|
|
285
|
+
} catch (error) {
|
|
286
|
+
return {
|
|
287
|
+
version: baileysVersion,
|
|
288
|
+
isLatest: false,
|
|
289
|
+
error
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const generateMdTagPrefix = () => {
|
|
294
|
+
const bytes = (0, import_node_crypto.randomBytes)(4);
|
|
295
|
+
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`;
|
|
296
|
+
};
|
|
297
|
+
const STATUS_MAP = {
|
|
298
|
+
sender: import_WAProto.proto.WebMessageInfo.Status.SERVER_ACK,
|
|
299
|
+
played: import_WAProto.proto.WebMessageInfo.Status.PLAYED,
|
|
300
|
+
read: import_WAProto.proto.WebMessageInfo.Status.READ,
|
|
301
|
+
"read-self": import_WAProto.proto.WebMessageInfo.Status.READ
|
|
302
|
+
};
|
|
303
|
+
const getStatusFromReceiptType = (type) => {
|
|
304
|
+
const status = STATUS_MAP[type];
|
|
305
|
+
if (typeof type === "undefined") {
|
|
306
|
+
return import_WAProto.proto.WebMessageInfo.Status.DELIVERY_ACK;
|
|
307
|
+
}
|
|
308
|
+
return status;
|
|
309
|
+
};
|
|
310
|
+
const CODE_MAP = {
|
|
311
|
+
conflict: import_Types.DisconnectReason.connectionReplaced
|
|
312
|
+
};
|
|
313
|
+
const getErrorCodeFromStreamError = (node) => {
|
|
314
|
+
const [reasonNode] = (0, import_WABinary.getAllBinaryNodeChildren)(node);
|
|
315
|
+
let reason = reasonNode?.tag || "unknown";
|
|
316
|
+
const statusCode = +(node.attrs.code || CODE_MAP[reason] || import_Types.DisconnectReason.badSession);
|
|
317
|
+
if (statusCode === import_Types.DisconnectReason.restartRequired) {
|
|
318
|
+
reason = "restart required";
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
reason,
|
|
322
|
+
statusCode
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
const getCallStatusFromNode = ({ tag, attrs }) => {
|
|
326
|
+
let status;
|
|
327
|
+
switch (tag) {
|
|
328
|
+
case "offer":
|
|
329
|
+
case "offer_notice":
|
|
330
|
+
status = "offer";
|
|
331
|
+
break;
|
|
332
|
+
case "terminate":
|
|
333
|
+
if (attrs.reason === "timeout") {
|
|
334
|
+
status = "timeout";
|
|
335
|
+
} else {
|
|
336
|
+
status = "terminate";
|
|
337
|
+
}
|
|
338
|
+
break;
|
|
339
|
+
case "preaccept":
|
|
340
|
+
status = "preaccept";
|
|
341
|
+
break;
|
|
342
|
+
case "transport":
|
|
343
|
+
status = "transport";
|
|
344
|
+
break;
|
|
345
|
+
case "relaylatency":
|
|
346
|
+
status = "relaylatency";
|
|
347
|
+
break;
|
|
348
|
+
case "reject":
|
|
349
|
+
status = "reject";
|
|
350
|
+
break;
|
|
351
|
+
case "accept":
|
|
352
|
+
status = "accept";
|
|
353
|
+
break;
|
|
354
|
+
default:
|
|
355
|
+
status = "ringing";
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
return status;
|
|
359
|
+
};
|
|
360
|
+
const UNEXPECTED_SERVER_CODE_TEXT = "Unexpected server response: ";
|
|
361
|
+
const getCodeFromWSError = (error) => {
|
|
362
|
+
let statusCode = 500;
|
|
363
|
+
if (error?.message?.includes(UNEXPECTED_SERVER_CODE_TEXT)) {
|
|
364
|
+
const code = +error?.message.slice(UNEXPECTED_SERVER_CODE_TEXT.length);
|
|
365
|
+
if (!Number.isNaN(code) && code >= 400) {
|
|
366
|
+
statusCode = code;
|
|
367
|
+
}
|
|
368
|
+
} else if (
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
370
|
+
error?.code?.startsWith("E") || error?.message?.includes("timed out")
|
|
371
|
+
) {
|
|
372
|
+
statusCode = 408;
|
|
373
|
+
}
|
|
374
|
+
return statusCode;
|
|
375
|
+
};
|
|
376
|
+
const isWABusinessPlatform = (platform) => {
|
|
377
|
+
return platform === "smbi" || platform === "smba";
|
|
378
|
+
};
|
|
379
|
+
function trimUndefined(obj) {
|
|
380
|
+
for (const key in obj) {
|
|
381
|
+
if (typeof obj[key] === "undefined") {
|
|
382
|
+
delete obj[key];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return obj;
|
|
386
|
+
}
|
|
387
|
+
const CROCKFORD_CHARACTERS = "123456789ABCDEFGHJKLMNPQRSTVWXYZ";
|
|
388
|
+
function bytesToCrockford(buffer) {
|
|
389
|
+
let value = 0;
|
|
390
|
+
let bitCount = 0;
|
|
391
|
+
const crockford = [];
|
|
392
|
+
for (const element of buffer) {
|
|
393
|
+
value = value << 8 | element & 255;
|
|
394
|
+
bitCount += 8;
|
|
395
|
+
while (bitCount >= 5) {
|
|
396
|
+
crockford.push(CROCKFORD_CHARACTERS.charAt(value >>> bitCount - 5 & 31));
|
|
397
|
+
bitCount -= 5;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (bitCount > 0) {
|
|
401
|
+
crockford.push(CROCKFORD_CHARACTERS.charAt(value << 5 - bitCount & 31));
|
|
402
|
+
}
|
|
403
|
+
return crockford.join("");
|
|
404
|
+
}
|
|
405
|
+
function encodeNewsletterMessage(message) {
|
|
406
|
+
return import_WAProto.proto.Message.encode(message).finish();
|
|
407
|
+
}
|
|
408
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
409
|
+
0 && (module.exports = {
|
|
410
|
+
BufferJSON,
|
|
411
|
+
bindWaitForConnectionUpdate,
|
|
412
|
+
bindWaitForEvent,
|
|
413
|
+
bytesToCrockford,
|
|
414
|
+
debouncedTimeout,
|
|
415
|
+
delay,
|
|
416
|
+
delayCancellable,
|
|
417
|
+
encodeBigEndian,
|
|
418
|
+
encodeNewsletterMessage,
|
|
419
|
+
encodeWAMessage,
|
|
420
|
+
fetchLatestBaileysVersion,
|
|
421
|
+
fetchLatestWaWebVersion,
|
|
422
|
+
generateMdTagPrefix,
|
|
423
|
+
generateMessageID,
|
|
424
|
+
generateMessageIDV2,
|
|
425
|
+
generateParticipantHashV2,
|
|
426
|
+
generateRegistrationId,
|
|
427
|
+
getCallStatusFromNode,
|
|
428
|
+
getCodeFromWSError,
|
|
429
|
+
getErrorCodeFromStreamError,
|
|
430
|
+
getKeyAuthor,
|
|
431
|
+
getStatusFromReceiptType,
|
|
432
|
+
isStringNullOrEmpty,
|
|
433
|
+
isWABusinessPlatform,
|
|
434
|
+
promiseTimeout,
|
|
435
|
+
toNumber,
|
|
436
|
+
trimUndefined,
|
|
437
|
+
unixTimestampSeconds,
|
|
438
|
+
unpadRandomMax16,
|
|
439
|
+
writeRandomPadMax16
|
|
440
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export function downloadHistory(msg: any, options: any): Promise<proto.HistorySync & proto.HistorySync.$Shape>;
|
|
2
|
+
export function processHistoryMessage(item: any, logger: any): {
|
|
3
|
+
chats: any[];
|
|
4
|
+
contacts: ({
|
|
5
|
+
id: any;
|
|
6
|
+
name: any;
|
|
7
|
+
username: any;
|
|
8
|
+
lid: any;
|
|
9
|
+
phoneNumber: any;
|
|
10
|
+
verifiedName?: undefined;
|
|
11
|
+
notify?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
id: any;
|
|
14
|
+
verifiedName: any;
|
|
15
|
+
name?: undefined;
|
|
16
|
+
username?: undefined;
|
|
17
|
+
lid?: undefined;
|
|
18
|
+
phoneNumber?: undefined;
|
|
19
|
+
notify?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
id: any;
|
|
22
|
+
notify: any;
|
|
23
|
+
name?: undefined;
|
|
24
|
+
username?: undefined;
|
|
25
|
+
lid?: undefined;
|
|
26
|
+
phoneNumber?: undefined;
|
|
27
|
+
verifiedName?: undefined;
|
|
28
|
+
})[];
|
|
29
|
+
messages: any[];
|
|
30
|
+
lidPnMappings: {
|
|
31
|
+
lid: any;
|
|
32
|
+
pn: any;
|
|
33
|
+
}[];
|
|
34
|
+
pastParticipants: any;
|
|
35
|
+
syncType: any;
|
|
36
|
+
progress: any;
|
|
37
|
+
};
|
|
38
|
+
export function downloadAndProcessHistorySyncNotification(msg: any, options: any, logger: any): Promise<{
|
|
39
|
+
chats: any[];
|
|
40
|
+
contacts: ({
|
|
41
|
+
id: any;
|
|
42
|
+
name: any;
|
|
43
|
+
username: any;
|
|
44
|
+
lid: any;
|
|
45
|
+
phoneNumber: any;
|
|
46
|
+
verifiedName?: undefined;
|
|
47
|
+
notify?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
id: any;
|
|
50
|
+
verifiedName: any;
|
|
51
|
+
name?: undefined;
|
|
52
|
+
username?: undefined;
|
|
53
|
+
lid?: undefined;
|
|
54
|
+
phoneNumber?: undefined;
|
|
55
|
+
notify?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
id: any;
|
|
58
|
+
notify: any;
|
|
59
|
+
name?: undefined;
|
|
60
|
+
username?: undefined;
|
|
61
|
+
lid?: undefined;
|
|
62
|
+
phoneNumber?: undefined;
|
|
63
|
+
verifiedName?: undefined;
|
|
64
|
+
})[];
|
|
65
|
+
messages: any[];
|
|
66
|
+
lidPnMappings: {
|
|
67
|
+
lid: any;
|
|
68
|
+
pn: any;
|
|
69
|
+
}[];
|
|
70
|
+
pastParticipants: any;
|
|
71
|
+
syncType: any;
|
|
72
|
+
progress: any;
|
|
73
|
+
}>;
|
|
74
|
+
export function getHistoryMsg(message: any): any;
|
|
75
|
+
import { proto } from '../../WAProto/index.js';
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var history_exports = {};
|
|
19
|
+
__export(history_exports, {
|
|
20
|
+
downloadAndProcessHistorySyncNotification: () => downloadAndProcessHistorySyncNotification,
|
|
21
|
+
downloadHistory: () => downloadHistory,
|
|
22
|
+
getHistoryMsg: () => getHistoryMsg,
|
|
23
|
+
processHistoryMessage: () => processHistoryMessage
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(history_exports);
|
|
26
|
+
var import_promises = require("node:stream/promises");
|
|
27
|
+
var import_node_util = require("node:util");
|
|
28
|
+
var import_node_zlib = require("node:zlib");
|
|
29
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
30
|
+
var import_Types = require("../Types/index.js");
|
|
31
|
+
var import_WABinary = require("../WABinary/index.js");
|
|
32
|
+
var import_generics = require("./generics.js");
|
|
33
|
+
var import_messages = require("./messages.js");
|
|
34
|
+
var import_messages_media = require("./messages-media.js");
|
|
35
|
+
const inflatePromise = (0, import_node_util.promisify)(import_node_zlib.inflate);
|
|
36
|
+
const extractPnFromMessages = (messages) => {
|
|
37
|
+
for (const msgItem of messages) {
|
|
38
|
+
const message = msgItem.message;
|
|
39
|
+
if (!message?.key?.fromMe || !message.userReceipt?.length) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const userJid = message.userReceipt[0]?.userJid;
|
|
43
|
+
if (userJid && ((0, import_WABinary.isPnUser)(userJid) || (0, import_WABinary.isHostedPnUser)(userJid))) {
|
|
44
|
+
return userJid;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
};
|
|
49
|
+
const downloadHistory = async (msg, options) => {
|
|
50
|
+
const stream = await (0, import_messages_media.downloadContentFromMessage)(msg, "md-msg-hist", { options });
|
|
51
|
+
const inflater = (0, import_node_zlib.createInflate)();
|
|
52
|
+
const chunks = [];
|
|
53
|
+
inflater.on("data", (chunk) => chunks.push(chunk));
|
|
54
|
+
await (0, import_promises.pipeline)(stream, inflater);
|
|
55
|
+
const buffer = Buffer.concat(chunks);
|
|
56
|
+
const syncData = import_WAProto.proto.HistorySync.decode(buffer);
|
|
57
|
+
return syncData;
|
|
58
|
+
};
|
|
59
|
+
const processHistoryMessage = (item, logger) => {
|
|
60
|
+
const messages = [];
|
|
61
|
+
const contacts = [];
|
|
62
|
+
const chats = [];
|
|
63
|
+
const lidPnMappings = [];
|
|
64
|
+
logger?.trace({ progress: item.progress }, "processing history of type " + item.syncType?.toString());
|
|
65
|
+
for (const m of item.phoneNumberToLidMappings || []) {
|
|
66
|
+
if (m.lidJid && m.pnJid) {
|
|
67
|
+
lidPnMappings.push({ lid: m.lidJid, pn: m.pnJid });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
switch (item.syncType) {
|
|
71
|
+
case import_WAProto.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
|
72
|
+
case import_WAProto.proto.HistorySync.HistorySyncType.RECENT:
|
|
73
|
+
case import_WAProto.proto.HistorySync.HistorySyncType.FULL:
|
|
74
|
+
case import_WAProto.proto.HistorySync.HistorySyncType.ON_DEMAND:
|
|
75
|
+
for (const chat of item.conversations) {
|
|
76
|
+
contacts.push({
|
|
77
|
+
id: chat.id,
|
|
78
|
+
name: chat.displayName || chat.name || chat.username || void 0,
|
|
79
|
+
username: chat.username || void 0,
|
|
80
|
+
lid: chat.lidJid || chat.accountLid || void 0,
|
|
81
|
+
phoneNumber: chat.pnJid || void 0
|
|
82
|
+
});
|
|
83
|
+
const chatId = chat.id;
|
|
84
|
+
const isLid = (0, import_WABinary.isLidUser)(chatId) || (0, import_WABinary.isHostedLidUser)(chatId);
|
|
85
|
+
const isPn = (0, import_WABinary.isPnUser)(chatId) || (0, import_WABinary.isHostedPnUser)(chatId);
|
|
86
|
+
if (isLid && chat.pnJid) {
|
|
87
|
+
lidPnMappings.push({ lid: chatId, pn: chat.pnJid });
|
|
88
|
+
} else if (isPn && chat.lidJid) {
|
|
89
|
+
lidPnMappings.push({ lid: chat.lidJid, pn: chatId });
|
|
90
|
+
} else if (isLid && !chat.pnJid) {
|
|
91
|
+
const pnFromReceipt = extractPnFromMessages(chat.messages || []);
|
|
92
|
+
if (pnFromReceipt) {
|
|
93
|
+
lidPnMappings.push({ lid: chatId, pn: pnFromReceipt });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const msgs = chat.messages || [];
|
|
97
|
+
delete chat.messages;
|
|
98
|
+
for (const item2 of msgs) {
|
|
99
|
+
const message = item2.message;
|
|
100
|
+
messages.push(message);
|
|
101
|
+
if (!chat.messages?.length) {
|
|
102
|
+
chat.messages = [{ message }];
|
|
103
|
+
}
|
|
104
|
+
if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
105
|
+
chat.lastMessageRecvTimestamp = (0, import_generics.toNumber)(message.messageTimestamp);
|
|
106
|
+
}
|
|
107
|
+
if ((message.messageStubType === import_Types.WAMessageStubType.BIZ_PRIVACY_MODE_TO_BSP || message.messageStubType === import_Types.WAMessageStubType.BIZ_PRIVACY_MODE_TO_FB) && message.messageStubParameters?.[0]) {
|
|
108
|
+
contacts.push({
|
|
109
|
+
id: message.key.participant || message.key.remoteJid,
|
|
110
|
+
verifiedName: message.messageStubParameters?.[0]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
chats.push(chat);
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case import_WAProto.proto.HistorySync.HistorySyncType.PUSH_NAME:
|
|
118
|
+
for (const c of item.pushnames) {
|
|
119
|
+
contacts.push({ id: c.id, notify: c.pushname });
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
chats,
|
|
125
|
+
contacts,
|
|
126
|
+
messages,
|
|
127
|
+
lidPnMappings,
|
|
128
|
+
pastParticipants: item.pastParticipants,
|
|
129
|
+
syncType: item.syncType,
|
|
130
|
+
progress: item.progress
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const downloadAndProcessHistorySyncNotification = async (msg, options, logger) => {
|
|
134
|
+
let historyMsg;
|
|
135
|
+
if (msg.initialHistBootstrapInlinePayload) {
|
|
136
|
+
historyMsg = import_WAProto.proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload));
|
|
137
|
+
} else {
|
|
138
|
+
historyMsg = await downloadHistory(msg, options);
|
|
139
|
+
}
|
|
140
|
+
return processHistoryMessage(historyMsg, logger);
|
|
141
|
+
};
|
|
142
|
+
const getHistoryMsg = (message) => {
|
|
143
|
+
const normalizedContent = !!message ? (0, import_messages.normalizeMessageContent)(message) : void 0;
|
|
144
|
+
const anyHistoryMsg = normalizedContent?.protocolMessage?.historySyncNotification;
|
|
145
|
+
return anyHistoryMsg;
|
|
146
|
+
};
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
downloadAndProcessHistorySyncNotification,
|
|
150
|
+
downloadHistory,
|
|
151
|
+
getHistoryMsg,
|
|
152
|
+
processHistoryMessage
|
|
153
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function handleIdentityChange(node: any, ctx: any): Promise<{
|
|
2
|
+
action: string;
|
|
3
|
+
device?: undefined;
|
|
4
|
+
error?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
action: string;
|
|
7
|
+
device: number;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
action: string;
|
|
11
|
+
error: unknown;
|
|
12
|
+
device?: undefined;
|
|
13
|
+
}>;
|