@violetix/baileys 0.0.0-stage → 0.4.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 +22 -0
- package/README.md +3017 -2
- package/WAProto/index.d.ts +15932 -0
- package/WAProto/index.js +115856 -0
- package/engine-requirements.js +13 -0
- package/lib/Defaults/index.d.ts +145 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +157 -0
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +8 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +11 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +82 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +7 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +12 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +13 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +17 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +26 -0
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +55 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +403 -0
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +21 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +277 -0
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +6 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +93 -0
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +57 -0
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +428 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +380 -0
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +176 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +1238 -0
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +595 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +432 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/graphql.js +908 -0
- package/lib/Socket/groups.d.ts +318 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +364 -0
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +947 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +19 -0
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/interop.js +562 -0
- package/lib/Socket/managed-account.js +210 -0
- package/lib/Socket/messages-recv.d.ts +367 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +2199 -0
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +364 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +1631 -0
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +42 -0
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +315 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +235 -0
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/privacy.js +448 -0
- package/lib/Socket/registration.js +430 -0
- package/lib/Socket/socket.d.ts +99 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +1290 -0
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.d.ts.map +1 -0
- package/lib/Store/index.js +4 -0
- package/lib/Store/index.js.map +1 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.d.ts.map +1 -0
- package/lib/Store/make-in-memory-store.js +462 -0
- package/lib/Store/make-in-memory-store.js.map +1 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.d.ts.map +1 -0
- package/lib/Store/make-ordered-dictionary.js +79 -0
- package/lib/Store/make-ordered-dictionary.js.map +1 -0
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.d.ts.map +1 -0
- package/lib/Store/object-repository.js +24 -0
- package/lib/Store/object-repository.js.map +1 -0
- package/lib/Types/Auth.d.ts +60 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +9 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +22 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +3 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +11 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +41 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +36 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +3 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +3 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +22 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +18 -0
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Mex.d.ts +3 -0
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +49 -0
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Product.d.ts +5 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/RichType.d.ts +3 -0
- package/lib/Types/RichType.d.ts.map +1 -0
- package/lib/Types/RichType.js +23 -0
- package/lib/Types/RichType.js.map +1 -0
- package/lib/Types/Signal.d.ts +10 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +33 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +6 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +56 -0
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +9 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +16 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +26 -0
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/a2ui.d.ts +50 -0
- package/lib/Utils/a2ui.js +168 -0
- package/lib/Utils/anchor-guard.d.ts +71 -0
- package/lib/Utils/anchor-guard.js +404 -0
- package/lib/Utils/async-utils.js +7 -0
- package/lib/Utils/auth-utils.d.ts +59 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +10 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +29 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +50 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +245 -0
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +409 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +872 -0
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +10 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +69 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto-worker.js +20 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +118 -0
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +85 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +467 -0
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +13 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +651 -0
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +64 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +442 -0
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +77 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +188 -0
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +14 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +50 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/ignore-key.d.ts +51 -0
- package/lib/Utils/ignore-key.js +174 -0
- package/lib/Utils/index.d.ts +29 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +29 -0
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +13 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +85 -0
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/listener-guard.js +48 -0
- package/lib/Utils/logger.d.ts +3 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +7 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +8 -0
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +33 -0
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +80 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +285 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +166 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +979 -0
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +47 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +1959 -0
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/meta-ai-msmsg.d.ts +12 -0
- package/lib/Utils/meta-ai-msmsg.js +124 -0
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +206 -0
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts +10 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +26 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +102 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +798 -0
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +13 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/rich-message-utils.d.ts +49 -0
- package/lib/Utils/rich-message-utils.d.ts.map +1 -0
- package/lib/Utils/rich-message-utils.js +369 -0
- package/lib/Utils/rich-message-utils.js.map +1 -0
- package/lib/Utils/session-queue.js +33 -0
- package/lib/Utils/signal.d.ts +83 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +201 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +22 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +72 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +3 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +49 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +30 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +164 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +196 -0
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-single-file-auth-state.js +118 -0
- package/lib/Utils/use-single-file-auth-state.js.map +1 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-sqlite-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +44 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +210 -0
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/Utils/worker-pool.js +73 -0
- package/lib/WABinary/constants.d.ts +62 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1467 -0
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +10 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +262 -0
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +220 -0
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +77 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +226 -0
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +6 -0
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +29 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +96 -0
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +6 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +34927 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -0
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +99 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +70 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.d.ts +11 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +34 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +31 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +11 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +11 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +32 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +185 -0
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +25 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +48 -0
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/package.json +122 -5
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
// Anti force-close guard: detects payloads that crash WhatsApp clients — combining/invisible
|
|
2
|
+
// char floods, mention bombs, oversized native-flow/list/carousel payloads, broken
|
|
3
|
+
// buttonParamsJson, over-deep or circular message structures — then deletes them and optionally
|
|
4
|
+
// blocks the sender.
|
|
5
|
+
//
|
|
6
|
+
// Ported from @rennzsync/baileys' anchor-guard, itself a port of
|
|
7
|
+
// @rexxhayanasi/elaina-anchorguard (MIT).
|
|
8
|
+
import { META_AI_JID } from '../WABinary/index.js';
|
|
9
|
+
export const ANCHORGUARD_DEFAULTS = {
|
|
10
|
+
maxText: 65536,
|
|
11
|
+
maxCaption: 32768,
|
|
12
|
+
maxMentions: 1500,
|
|
13
|
+
maxGroupMentions: 200,
|
|
14
|
+
maxButtons: 100,
|
|
15
|
+
maxSections: 100,
|
|
16
|
+
maxRows: 300,
|
|
17
|
+
maxCards: 60,
|
|
18
|
+
maxDepth: 12,
|
|
19
|
+
maxNodes: 20000,
|
|
20
|
+
maxBytes: 3 * 1024 * 1024,
|
|
21
|
+
maxParamsJson: 262144,
|
|
22
|
+
maxInvisibleRun: 500,
|
|
23
|
+
maxCombiningRun: 100,
|
|
24
|
+
maxNewlines: 20000
|
|
25
|
+
};
|
|
26
|
+
// Escaped on purpose: literal invisible/combining characters make the source unreadable
|
|
27
|
+
// and easy to corrupt on the next edit.
|
|
28
|
+
const INVISIBLE = /[\u200b-\u200f\u202a-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb]/;
|
|
29
|
+
const COMBINING = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\uaa70\uaaf6\uabed\ufe20-\ufe2f]/;
|
|
30
|
+
/** Longest consecutive run of characters matching `matcher`. */
|
|
31
|
+
const longestRun = (text, matcher) => {
|
|
32
|
+
let run = 0;
|
|
33
|
+
let best = 0;
|
|
34
|
+
for (const ch of text) {
|
|
35
|
+
if (matcher.test(ch)) {
|
|
36
|
+
run += 1;
|
|
37
|
+
if (run > best) {
|
|
38
|
+
best = run;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
run = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return best;
|
|
46
|
+
};
|
|
47
|
+
const countChar = (text, ch) => {
|
|
48
|
+
let n = 0;
|
|
49
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
50
|
+
if (text[i] === ch) {
|
|
51
|
+
n += 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return n;
|
|
55
|
+
};
|
|
56
|
+
const WRAPPERS = [
|
|
57
|
+
'ephemeralMessage',
|
|
58
|
+
'viewOnceMessage',
|
|
59
|
+
'viewOnceMessageV2',
|
|
60
|
+
'viewOnceMessageV2Extension',
|
|
61
|
+
'documentWithCaptionMessage',
|
|
62
|
+
'editedMessage',
|
|
63
|
+
'deviceSentMessage',
|
|
64
|
+
'botInvokeMessage'
|
|
65
|
+
];
|
|
66
|
+
const unwrapContent = (message) => {
|
|
67
|
+
let current = message;
|
|
68
|
+
let depth = 0;
|
|
69
|
+
while (current && typeof current === 'object' && depth < 64) {
|
|
70
|
+
const wrapper = WRAPPERS.find(w => current[w]?.message);
|
|
71
|
+
if (!wrapper) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
current = current[wrapper].message;
|
|
75
|
+
depth += 1;
|
|
76
|
+
}
|
|
77
|
+
return { content: current, wrapDepth: depth };
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Inspects a message content object and reports why it looks like a crash payload.
|
|
81
|
+
* Pure — no I/O, no mutation of the input.
|
|
82
|
+
*/
|
|
83
|
+
export const detectBug = (message, options = {}) => {
|
|
84
|
+
const limits = { ...ANCHORGUARD_DEFAULTS, ...options };
|
|
85
|
+
const reasons = [];
|
|
86
|
+
if (!message || typeof message !== 'object') {
|
|
87
|
+
return { flagged: false, reasons };
|
|
88
|
+
}
|
|
89
|
+
const { content, wrapDepth } = unwrapContent(message);
|
|
90
|
+
if (wrapDepth >= 6) {
|
|
91
|
+
reasons.push(`wrapper nesting ${wrapDepth}`);
|
|
92
|
+
}
|
|
93
|
+
let nodes = 0;
|
|
94
|
+
const seen = new WeakSet();
|
|
95
|
+
// One traversal. The mention checks used to be a second full walk of the same tree, which
|
|
96
|
+
// doubled the cost of the guard on the path it is meant to protect: every inbound message.
|
|
97
|
+
const walk = (value, depth) => {
|
|
98
|
+
if (reasons.length > 40) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
nodes += 1;
|
|
102
|
+
if (nodes > limits.maxNodes) {
|
|
103
|
+
reasons.push(`node count > ${limits.maxNodes}`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (depth > limits.maxDepth) {
|
|
107
|
+
reasons.push(`structure depth > ${limits.maxDepth}`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (typeof value === 'string') {
|
|
111
|
+
if (value.length > limits.maxText) {
|
|
112
|
+
reasons.push(`string length ${value.length} > ${limits.maxText}`);
|
|
113
|
+
}
|
|
114
|
+
if (countChar(value, '\n') > limits.maxNewlines) {
|
|
115
|
+
reasons.push('excessive newlines');
|
|
116
|
+
}
|
|
117
|
+
const invisibleRun = longestRun(value, INVISIBLE);
|
|
118
|
+
if (invisibleRun > limits.maxInvisibleRun) {
|
|
119
|
+
reasons.push(`invisible-char run ${invisibleRun}`);
|
|
120
|
+
}
|
|
121
|
+
const combiningRun = longestRun(value, COMBINING);
|
|
122
|
+
if (combiningRun > limits.maxCombiningRun) {
|
|
123
|
+
reasons.push(`combining-char run ${combiningRun}`);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(value)) {
|
|
128
|
+
for (const item of value) {
|
|
129
|
+
walk(item, depth + 1);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (value && typeof value === 'object') {
|
|
134
|
+
if (seen.has(value)) {
|
|
135
|
+
reasons.push('circular structure');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
seen.add(value);
|
|
139
|
+
for (const key of Object.keys(value)) {
|
|
140
|
+
const child = value[key];
|
|
141
|
+
if (key === 'contextInfo' && child && typeof child === 'object') {
|
|
142
|
+
if (Array.isArray(child.mentionedJid) && child.mentionedJid.length > limits.maxMentions) {
|
|
143
|
+
reasons.push(`mentionedJid ${child.mentionedJid.length} > ${limits.maxMentions}`);
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(child.groupMentions) && child.groupMentions.length > limits.maxGroupMentions) {
|
|
146
|
+
reasons.push(`groupMentions ${child.groupMentions.length} > ${limits.maxGroupMentions}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
walk(child, depth + 1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
walk(content, 0);
|
|
154
|
+
const inspectInteractive = (node) => {
|
|
155
|
+
if (!node || typeof node !== 'object') {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const nativeFlow = node.nativeFlowMessage || node.interactiveMessage?.nativeFlowMessage;
|
|
159
|
+
if (nativeFlow?.buttons) {
|
|
160
|
+
if (nativeFlow.buttons.length > limits.maxButtons) {
|
|
161
|
+
reasons.push(`nativeFlow buttons ${nativeFlow.buttons.length} > ${limits.maxButtons}`);
|
|
162
|
+
}
|
|
163
|
+
for (const button of nativeFlow.buttons) {
|
|
164
|
+
const params = button?.buttonParamsJson;
|
|
165
|
+
if (typeof params !== 'string') {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (params.length > limits.maxParamsJson) {
|
|
169
|
+
reasons.push(`buttonParamsJson length ${params.length}`);
|
|
170
|
+
}
|
|
171
|
+
else if (params.length) {
|
|
172
|
+
try {
|
|
173
|
+
JSON.parse(params);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
reasons.push('buttonParamsJson invalid');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const list = node.listMessage || node.interactiveMessage?.carouselMessage;
|
|
182
|
+
if (list?.sections && list.sections.length > limits.maxSections) {
|
|
183
|
+
reasons.push(`list sections ${list.sections.length} > ${limits.maxSections}`);
|
|
184
|
+
}
|
|
185
|
+
if (Array.isArray(list?.sections)) {
|
|
186
|
+
let rows = 0;
|
|
187
|
+
for (const section of list.sections) {
|
|
188
|
+
rows += Array.isArray(section?.rows) ? section.rows.length : 0;
|
|
189
|
+
}
|
|
190
|
+
if (rows > limits.maxRows) {
|
|
191
|
+
reasons.push(`list rows ${rows} > ${limits.maxRows}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const cards = node.interactiveMessage?.carouselMessage?.cards;
|
|
195
|
+
if (Array.isArray(cards) && cards.length > limits.maxCards) {
|
|
196
|
+
reasons.push(`carousel cards ${cards.length} > ${limits.maxCards}`);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
inspectInteractive(content);
|
|
200
|
+
if (typeof options.byteLength === 'number' && options.byteLength > limits.maxBytes) {
|
|
201
|
+
reasons.push(`encoded size ${options.byteLength} > ${limits.maxBytes}`);
|
|
202
|
+
}
|
|
203
|
+
if (options.proto?.Message) {
|
|
204
|
+
try {
|
|
205
|
+
const encoded = options.proto.Message.encode(options.proto.Message.fromObject(message)).finish();
|
|
206
|
+
if (encoded.length > limits.maxBytes) {
|
|
207
|
+
reasons.push(`encoded size ${encoded.length} > ${limits.maxBytes}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
reasons.push(`proto encode failed: ${error.message}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { flagged: reasons.length > 0, reasons };
|
|
215
|
+
};
|
|
216
|
+
const META_AI_USER = META_AI_JID.split('@')[0];
|
|
217
|
+
const isMetaAiJid = (jid) => typeof jid === 'string' && jid.startsWith(META_AI_USER);
|
|
218
|
+
/** Bounded so a bot in busy groups cannot grow the burst log without limit. */
|
|
219
|
+
const MAX_BURST_SENDERS = 5000;
|
|
220
|
+
/**
|
|
221
|
+
* Attaches the guard to a socket: flags inbound crash payloads, optionally blocks the sender,
|
|
222
|
+
* and rejects outgoing messages that would crash the recipient.
|
|
223
|
+
*/
|
|
224
|
+
export const createAnchorGuard = (sock, options = {}) => {
|
|
225
|
+
const config = {
|
|
226
|
+
autoDelete: true,
|
|
227
|
+
deleteMode: 'auto',
|
|
228
|
+
guardIncoming: true,
|
|
229
|
+
// Off by default: this one replaces `sock.sendMessage` with a wrapper, which a host that
|
|
230
|
+
// also wraps `sendMessage` needs to know about. Opt in explicitly.
|
|
231
|
+
guardOutgoing: false,
|
|
232
|
+
blockOnBug: false,
|
|
233
|
+
selfOnly: false,
|
|
234
|
+
thresholds: {},
|
|
235
|
+
onDetect: null,
|
|
236
|
+
proto: null,
|
|
237
|
+
/** messages from one sender within burstWindowMs before it counts as a burst; 0 = off */
|
|
238
|
+
burstThreshold: 0,
|
|
239
|
+
burstWindowMs: 4000,
|
|
240
|
+
/** remove the sender from the group on burst (needs admin) */
|
|
241
|
+
kickOnBurst: false,
|
|
242
|
+
/** flag/kick when a burst-flagged inviter adds this account to a group */
|
|
243
|
+
guardGroupAdds: false,
|
|
244
|
+
/** guard Meta AI's own numbers instead of exempting them */
|
|
245
|
+
metaAiNumbers: false,
|
|
246
|
+
logger: sock?.logger,
|
|
247
|
+
...options
|
|
248
|
+
};
|
|
249
|
+
const ownJid = config.ownJid || sock?.user?.id;
|
|
250
|
+
const detectOptions = { ...config.thresholds, proto: config.proto };
|
|
251
|
+
const burstLog = new Map();
|
|
252
|
+
const removeMessage = async (jid, key) => {
|
|
253
|
+
if (!config.autoDelete) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const revoke = config.deleteMode === 'everyone' || (config.deleteMode === 'auto' && key?.fromMe);
|
|
257
|
+
try {
|
|
258
|
+
if (revoke) {
|
|
259
|
+
await sock.sendMessage(jid, { delete: key });
|
|
260
|
+
}
|
|
261
|
+
else if (typeof sock.chatModify === 'function') {
|
|
262
|
+
await sock.chatModify({ deleteForMe: { key, timestamp: Date.now(), deleteMedia: false } }, jid);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
config.logger?.warn?.({ error: error.message }, 'anchorguard delete failed');
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const maybeBlock = async (jid, key) => {
|
|
270
|
+
if (!config.blockOnBug || key?.fromMe || typeof sock.updateBlockStatus !== 'function') {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
await sock.updateBlockStatus(jid, 'block');
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
config.logger?.warn?.({ error: error.message }, 'anchorguard block failed');
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const maybeKickBurst = async (groupJid, sender) => {
|
|
281
|
+
if (!config.kickOnBurst || !groupJid?.endsWith('@g.us') || typeof sock.groupParticipantsUpdate !== 'function') {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
await sock.groupParticipantsUpdate(groupJid, [sender], 'remove');
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
config.logger?.warn?.({ error: error.message }, 'anchorguard kick-on-burst failed');
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const checkBurst = (sender) => {
|
|
292
|
+
if (!config.burstThreshold || !sender) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const now = Date.now();
|
|
296
|
+
const stamps = (burstLog.get(sender) || []).filter(t => now - t < config.burstWindowMs);
|
|
297
|
+
stamps.push(now);
|
|
298
|
+
burstLog.set(sender, stamps);
|
|
299
|
+
// Senders whose window has fully expired are dropped, so the map tracks active senders
|
|
300
|
+
// only. Without this it keeps one entry per sender seen for the lifetime of the socket.
|
|
301
|
+
if (burstLog.size > MAX_BURST_SENDERS) {
|
|
302
|
+
for (const [key, times] of burstLog) {
|
|
303
|
+
if (!times.some(t => now - t < config.burstWindowMs)) {
|
|
304
|
+
burstLog.delete(key);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return stamps.length > config.burstThreshold;
|
|
309
|
+
};
|
|
310
|
+
const handleUpsert = async ({ messages }) => {
|
|
311
|
+
if (!config.guardIncoming || !Array.isArray(messages)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
for (const msg of messages) {
|
|
315
|
+
const content = msg?.message;
|
|
316
|
+
if (!content) {
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const jid = msg.key?.remoteJid;
|
|
320
|
+
const sender = msg.key?.participant || jid;
|
|
321
|
+
if (config.selfOnly && jid !== ownJid && !msg.key?.fromMe) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (!config.metaAiNumbers && isMetaAiJid(sender)) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
const result = detectBug(content, detectOptions);
|
|
328
|
+
const burst = checkBurst(sender);
|
|
329
|
+
if (!result.flagged && !burst) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const reasons = burst
|
|
333
|
+
? [...result.reasons, `burst > ${config.burstThreshold}/${config.burstWindowMs}ms`]
|
|
334
|
+
: result.reasons;
|
|
335
|
+
config.logger?.warn?.({ jid, sender, reasons }, 'anchorguard flagged incoming message');
|
|
336
|
+
await config.onDetect?.({ direction: 'incoming', message: msg, jid, sender, reasons, burst });
|
|
337
|
+
if (result.flagged) {
|
|
338
|
+
await removeMessage(jid, msg.key);
|
|
339
|
+
}
|
|
340
|
+
await maybeBlock(sender, msg.key);
|
|
341
|
+
if (burst) {
|
|
342
|
+
await maybeKickBurst(jid, sender);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const handleGroupParticipantsUpdate = async (update) => {
|
|
347
|
+
if (!config.guardGroupAdds || update?.action !== 'add') {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const inviter = update?.author;
|
|
351
|
+
if (!inviter || (!config.metaAiNumbers && isMetaAiJid(inviter))) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (checkBurst(inviter)) {
|
|
355
|
+
config.logger?.warn?.({ group: update.id, inviter }, 'anchorguard flagged burst group-add');
|
|
356
|
+
await config.onDetect?.({ direction: 'group-add', jid: update.id, sender: inviter, reasons: ['burst group-add'], burst: true });
|
|
357
|
+
await maybeKickBurst(update.id, inviter);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
if (config.guardIncoming && sock?.ev?.on) {
|
|
361
|
+
sock.ev.on('messages.upsert', handleUpsert);
|
|
362
|
+
}
|
|
363
|
+
if (config.guardGroupAdds && sock?.ev?.on) {
|
|
364
|
+
sock.ev.on('group-participants.update', handleGroupParticipantsUpdate);
|
|
365
|
+
}
|
|
366
|
+
let originalSend = null;
|
|
367
|
+
let patchedSend = null;
|
|
368
|
+
if (config.guardOutgoing && typeof sock?.sendMessage === 'function') {
|
|
369
|
+
// Keep the unbound reference so `stop()` restores the exact function that was there.
|
|
370
|
+
// Restoring a bound copy instead stacks a `bind` layer per guard/stop cycle and makes
|
|
371
|
+
// the socket's own method unrecognisable to a host comparing identities.
|
|
372
|
+
originalSend = sock.sendMessage;
|
|
373
|
+
const callOriginal = originalSend.bind(sock);
|
|
374
|
+
patchedSend = async (jid, content, sendOptions) => {
|
|
375
|
+
const probe = detectBug(content, detectOptions);
|
|
376
|
+
if (probe.flagged) {
|
|
377
|
+
config.logger?.warn?.({ jid, reasons: probe.reasons }, 'anchorguard blocked outgoing message');
|
|
378
|
+
await config.onDetect?.({ direction: 'outgoing', jid, content, reasons: probe.reasons });
|
|
379
|
+
throw new Error(`anchorguard blocked outgoing message: ${probe.reasons.join('; ')}`);
|
|
380
|
+
}
|
|
381
|
+
return callOriginal(jid, content, sendOptions);
|
|
382
|
+
};
|
|
383
|
+
sock.sendMessage = patchedSend;
|
|
384
|
+
}
|
|
385
|
+
return {
|
|
386
|
+
detect: message => detectBug(message, detectOptions),
|
|
387
|
+
stop: () => {
|
|
388
|
+
if (config.guardIncoming && sock?.ev?.off) {
|
|
389
|
+
sock.ev.off('messages.upsert', handleUpsert);
|
|
390
|
+
}
|
|
391
|
+
if (config.guardGroupAdds && sock?.ev?.off) {
|
|
392
|
+
sock.ev.off('group-participants.update', handleGroupParticipantsUpdate);
|
|
393
|
+
}
|
|
394
|
+
// Only unwind our own wrapper. Restoring unconditionally would throw away a wrapper
|
|
395
|
+
// the host installed after this guard did.
|
|
396
|
+
if (patchedSend && sock.sendMessage === patchedSend) {
|
|
397
|
+
sock.sendMessage = originalSend;
|
|
398
|
+
}
|
|
399
|
+
burstLog.clear();
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
// kept for drop-in parity with @rexxhayanasi/elaina-anchorguard's export name
|
|
404
|
+
export const createAntiBugGuard = createAnchorGuard;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds caching capability to a SignalKeyStore
|
|
3
|
+
* @param store the store to add caching to
|
|
4
|
+
* @param logger to log trace events
|
|
5
|
+
* @param _cache cache store to use
|
|
6
|
+
*/
|
|
7
|
+
export function makeCacheableSignalKeyStore(store: any, logger: any, _cache?: any): {
|
|
8
|
+
get(type: any, ids: any): Promise<any>;
|
|
9
|
+
set(data: any): Promise<any>;
|
|
10
|
+
clear(): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export function addTransactionCapability(state: any, logger: any, { maxCommitRetries, delayBetweenTriesMs }: {
|
|
13
|
+
maxCommitRetries: any;
|
|
14
|
+
delayBetweenTriesMs: any;
|
|
15
|
+
}): {
|
|
16
|
+
get: (type: any, ids: any) => Promise<any>;
|
|
17
|
+
set: (data: any) => Promise<void>;
|
|
18
|
+
isInTransaction: () => boolean;
|
|
19
|
+
transaction: (work: any, key: any) => Promise<any>;
|
|
20
|
+
flush: () => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export function assertMeId(creds: any): any;
|
|
23
|
+
export function initAuthCreds(): {
|
|
24
|
+
noiseKey: {
|
|
25
|
+
private: any;
|
|
26
|
+
public: any;
|
|
27
|
+
};
|
|
28
|
+
pairingEphemeralKeyPair: {
|
|
29
|
+
private: any;
|
|
30
|
+
public: any;
|
|
31
|
+
};
|
|
32
|
+
signedIdentityKey: {
|
|
33
|
+
private: any;
|
|
34
|
+
public: any;
|
|
35
|
+
};
|
|
36
|
+
signedPreKey: {
|
|
37
|
+
keyPair: {
|
|
38
|
+
private: any;
|
|
39
|
+
public: any;
|
|
40
|
+
};
|
|
41
|
+
signature: any;
|
|
42
|
+
keyId: any;
|
|
43
|
+
};
|
|
44
|
+
registrationId: number;
|
|
45
|
+
advSecretKey: any;
|
|
46
|
+
processedHistoryMessages: never[];
|
|
47
|
+
nextPreKeyId: number;
|
|
48
|
+
firstUnuploadedPreKeyId: number;
|
|
49
|
+
accountSyncCounter: number;
|
|
50
|
+
accountSettings: {
|
|
51
|
+
unarchiveChats: boolean;
|
|
52
|
+
};
|
|
53
|
+
registered: boolean;
|
|
54
|
+
pairingCode: undefined;
|
|
55
|
+
lastPropHash: undefined;
|
|
56
|
+
routingInfo: undefined;
|
|
57
|
+
additionalData: undefined;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=auth-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/Utils/auth-utils.js"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH;;;;EA2DC;AAQM;;;;;;;;EAsLN;AAKM,4CAMN;AACM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBN"}
|