@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,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var index_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(index_exports);
|
|
17
|
+
__reExport(index_exports, require("./make-in-memory-store.js"), module.exports);
|
|
18
|
+
__reExport(index_exports, require("./make-ordered-dictionary.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./object-repository.js"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./make-in-memory-store.js"),
|
|
23
|
+
...require("./make-ordered-dictionary.js"),
|
|
24
|
+
...require("./object-repository.js")
|
|
25
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export function waChatKey(pin: any): {
|
|
2
|
+
key: (c: any) => string;
|
|
3
|
+
compare: (k1: any, k2: any) => any;
|
|
4
|
+
};
|
|
5
|
+
export function waMessageID(m: any): any;
|
|
6
|
+
export namespace waLabelAssociationKey {
|
|
7
|
+
function key(la: any): any;
|
|
8
|
+
function compare(k1: any, k2: any): any;
|
|
9
|
+
}
|
|
10
|
+
export function makeInMemoryStore(config?: {}): {
|
|
11
|
+
chats: KeyedDB;
|
|
12
|
+
contacts: {};
|
|
13
|
+
messages: {};
|
|
14
|
+
groupMetadata: {};
|
|
15
|
+
state: {
|
|
16
|
+
connection: string;
|
|
17
|
+
};
|
|
18
|
+
presences: {};
|
|
19
|
+
labels: ObjectRepository;
|
|
20
|
+
labelAssociations: KeyedDB;
|
|
21
|
+
bind: (ev: any) => void;
|
|
22
|
+
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
23
|
+
loadMessages: (jid: any, count: any, cursor: any) => Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Get all available labels for profile
|
|
26
|
+
*
|
|
27
|
+
* Keep in mind that the list is formed from predefined tags and tags
|
|
28
|
+
* that were "caught" during their editing.
|
|
29
|
+
*/
|
|
30
|
+
getLabels: () => ObjectRepository;
|
|
31
|
+
/**
|
|
32
|
+
* Get labels for chat
|
|
33
|
+
*
|
|
34
|
+
* @returns Label IDs
|
|
35
|
+
**/
|
|
36
|
+
getChatLabels: (chatId: any) => any[];
|
|
37
|
+
/**
|
|
38
|
+
* Get labels for message
|
|
39
|
+
*
|
|
40
|
+
* @returns Label IDs
|
|
41
|
+
**/
|
|
42
|
+
getMessageLabels: (messageId: any) => any[];
|
|
43
|
+
loadMessage: (jid: any, id: any) => Promise<any>;
|
|
44
|
+
mostRecentMessage: (jid: any) => Promise<any>;
|
|
45
|
+
fetchImageUrl: (jid: any, sock: any) => Promise<any>;
|
|
46
|
+
fetchGroupMetadata: (jid: any, sock: any) => Promise<any>;
|
|
47
|
+
fetchMessageReceipts: ({ remoteJid, id }: {
|
|
48
|
+
remoteJid: any;
|
|
49
|
+
id: any;
|
|
50
|
+
}) => Promise<any>;
|
|
51
|
+
toJSON: () => {
|
|
52
|
+
chats: KeyedDB;
|
|
53
|
+
contacts: {};
|
|
54
|
+
messages: {};
|
|
55
|
+
labels: ObjectRepository;
|
|
56
|
+
labelAssociations: KeyedDB;
|
|
57
|
+
};
|
|
58
|
+
fromJSON: (json: any) => void;
|
|
59
|
+
writeToFile: (path: any) => void;
|
|
60
|
+
readFromFile: (path: any) => void;
|
|
61
|
+
};
|
|
62
|
+
import { KeyedDB } from '../Addon/index.js';
|
|
63
|
+
import { ObjectRepository } from './object-repository.js';
|
|
@@ -0,0 +1,431 @@
|
|
|
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 make_in_memory_store_exports = {};
|
|
19
|
+
__export(make_in_memory_store_exports, {
|
|
20
|
+
makeInMemoryStore: () => makeInMemoryStore,
|
|
21
|
+
waChatKey: () => waChatKey,
|
|
22
|
+
waLabelAssociationKey: () => waLabelAssociationKey,
|
|
23
|
+
waMessageID: () => waMessageID
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(make_in_memory_store_exports);
|
|
26
|
+
var import_node_fs = require("node:fs");
|
|
27
|
+
var import_Addon = require("../Addon/index.js");
|
|
28
|
+
var import_Types = require("../Types/index.js");
|
|
29
|
+
var import_LabelAssociation = require("../Types/LabelAssociation.js");
|
|
30
|
+
var import_Defaults = require("../Defaults/index.js");
|
|
31
|
+
var import_Utils = require("../Utils/index.js");
|
|
32
|
+
var import_WABinary = require("../WABinary/index.js");
|
|
33
|
+
var import_make_ordered_dictionary = require("./make-ordered-dictionary.js");
|
|
34
|
+
var import_object_repository = require("./object-repository.js");
|
|
35
|
+
const waChatKey = (pin) => ({
|
|
36
|
+
key: (c) => (pin ? c.pinned ? "1" : "0" : "") + (c.archived ? "0" : "1") + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, "0") : "") + c.id,
|
|
37
|
+
compare: (k1, k2) => k2.localeCompare(k1)
|
|
38
|
+
});
|
|
39
|
+
const waMessageID = (m) => m.key.id || "";
|
|
40
|
+
const waLabelAssociationKey = {
|
|
41
|
+
key: (la) => la.type === import_LabelAssociation.LabelAssociationType.Chat ? la.chatId + la.labelId : la.chatId + la.messageId + la.labelId,
|
|
42
|
+
compare: (k1, k2) => k2.localeCompare(k1)
|
|
43
|
+
};
|
|
44
|
+
const makeMessagesDictionary = () => (0, import_make_ordered_dictionary.makeOrderedDictionary)(waMessageID);
|
|
45
|
+
const makeInMemoryStore = (config = {}) => {
|
|
46
|
+
const socket = config.socket;
|
|
47
|
+
const chatKey = config.chatKey || waChatKey(true);
|
|
48
|
+
const labelAssociationKey = config.labelAssociationKey || waLabelAssociationKey;
|
|
49
|
+
const logger = config.logger || import_Defaults.DEFAULT_CONNECTION_CONFIG.logger.child({ stream: "in-mem-store" });
|
|
50
|
+
const chats = new import_Addon.KeyedDB(chatKey, (c) => c.id);
|
|
51
|
+
const messages = {};
|
|
52
|
+
const contacts = {};
|
|
53
|
+
const groupMetadata = {};
|
|
54
|
+
const presences = {};
|
|
55
|
+
const state = { connection: "close" };
|
|
56
|
+
const labels = new import_object_repository.ObjectRepository();
|
|
57
|
+
const labelAssociations = new import_Addon.KeyedDB(labelAssociationKey, labelAssociationKey.key);
|
|
58
|
+
const assertMessageList = (jid) => {
|
|
59
|
+
if (!messages[jid]) {
|
|
60
|
+
messages[jid] = makeMessagesDictionary();
|
|
61
|
+
}
|
|
62
|
+
return messages[jid];
|
|
63
|
+
};
|
|
64
|
+
const contactsUpsert = (newContacts) => {
|
|
65
|
+
const oldContacts = new Set(Object.keys(contacts));
|
|
66
|
+
for (const contact of newContacts) {
|
|
67
|
+
oldContacts.delete(contact.id);
|
|
68
|
+
contacts[contact.id] = Object.assign(contacts[contact.id] || {}, contact);
|
|
69
|
+
}
|
|
70
|
+
return oldContacts;
|
|
71
|
+
};
|
|
72
|
+
const labelsUpsert = (newLabels) => {
|
|
73
|
+
for (const label of newLabels) {
|
|
74
|
+
labels.upsertById(label.id, label);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const bind = (ev) => {
|
|
78
|
+
ev.on("connection.update", (update) => {
|
|
79
|
+
Object.assign(state, update);
|
|
80
|
+
});
|
|
81
|
+
ev.on("messaging-history.set", ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
|
|
82
|
+
if (syncType === import_Types.WAProto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (isLatest) {
|
|
86
|
+
chats.clear();
|
|
87
|
+
for (const id in messages) {
|
|
88
|
+
delete messages[id];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const chatsAdded = chats.insertIfAbsent(...newChats).length;
|
|
92
|
+
logger.debug({ chatsAdded }, "synced chats");
|
|
93
|
+
const oldContacts = contactsUpsert(newContacts);
|
|
94
|
+
if (isLatest) {
|
|
95
|
+
for (const jid of oldContacts) {
|
|
96
|
+
delete contacts[jid];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
logger.debug({ deletedContacts: isLatest ? oldContacts.size : 0, newContacts }, "synced contacts");
|
|
100
|
+
for (const msg of newMessages) {
|
|
101
|
+
const jid = msg.key.remoteJidAlt || msg.key.remoteJid;
|
|
102
|
+
const list = assertMessageList(jid);
|
|
103
|
+
list.upsert(msg, "prepend");
|
|
104
|
+
}
|
|
105
|
+
logger.debug({ messages: newMessages.length }, "synced messages");
|
|
106
|
+
});
|
|
107
|
+
ev.on("contacts.upsert", (contacts2) => {
|
|
108
|
+
contactsUpsert(contacts2);
|
|
109
|
+
});
|
|
110
|
+
ev.on("contacts.update", async (updates) => {
|
|
111
|
+
var _a;
|
|
112
|
+
for (const update of updates) {
|
|
113
|
+
let contact;
|
|
114
|
+
if (contacts[update.id]) {
|
|
115
|
+
contact = contacts[update.id];
|
|
116
|
+
} else {
|
|
117
|
+
const contactHashes = await Promise.all(Object.keys(contacts).map(async (contactId) => {
|
|
118
|
+
const { user } = (0, import_WABinary.jidDecode)(contactId);
|
|
119
|
+
return [contactId, (await (0, import_Utils.md5)(Buffer.from(user + "WA_ADD_NOTIF", "utf8"))).toString("base64").slice(0, 3)];
|
|
120
|
+
}));
|
|
121
|
+
contact = contacts[((_a = contactHashes.find(([, b]) => b === update.id)) === null || _a === void 0 ? void 0 : _a[0]) || ""];
|
|
122
|
+
}
|
|
123
|
+
if (contact) {
|
|
124
|
+
if (update.imgUrl === "changed") {
|
|
125
|
+
contact.imgUrl = socket ? await (socket === null || socket === void 0 ? void 0 : socket.profilePictureUrl(contact.id)) : void 0;
|
|
126
|
+
} else if (update.imgUrl === "removed") {
|
|
127
|
+
delete contact.imgUrl;
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
return logger.debug({ update }, "got update for non-existant contact");
|
|
131
|
+
}
|
|
132
|
+
Object.assign(contacts[contact.id], contact);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
ev.on("chats.upsert", (newChats) => {
|
|
136
|
+
chats.upsert(...newChats);
|
|
137
|
+
});
|
|
138
|
+
ev.on("chats.update", (updates) => {
|
|
139
|
+
for (let update of updates) {
|
|
140
|
+
const result = chats.update(update.id, (chat) => {
|
|
141
|
+
if (update.unreadCount > 0) {
|
|
142
|
+
update = { ...update };
|
|
143
|
+
update.unreadCount = (chat.unreadCount || 0) + update.unreadCount;
|
|
144
|
+
}
|
|
145
|
+
Object.assign(chat, update);
|
|
146
|
+
});
|
|
147
|
+
if (!result) {
|
|
148
|
+
logger.debug({ update }, "got update for non-existant chat");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
ev.on("labels.edit", (label) => {
|
|
153
|
+
if (label.deleted) {
|
|
154
|
+
return labels.deleteById(label.id);
|
|
155
|
+
}
|
|
156
|
+
if (labels.count() < 20) {
|
|
157
|
+
return labels.upsertById(label.id, label);
|
|
158
|
+
}
|
|
159
|
+
logger.error("Labels count exceed");
|
|
160
|
+
});
|
|
161
|
+
ev.on("labels.association", ({ type, association }) => {
|
|
162
|
+
switch (type) {
|
|
163
|
+
case "add":
|
|
164
|
+
labelAssociations.upsert(association);
|
|
165
|
+
break;
|
|
166
|
+
case "remove":
|
|
167
|
+
labelAssociations.delete(association);
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
console.error(`unknown operation type [${type}]`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
ev.on("presence.update", ({ id, presences: update }) => {
|
|
174
|
+
presences[id] = presences[id] || {};
|
|
175
|
+
Object.assign(presences[id], update);
|
|
176
|
+
});
|
|
177
|
+
ev.on("chats.delete", (deletions) => {
|
|
178
|
+
for (const item of deletions) {
|
|
179
|
+
if (chats.get(item)) {
|
|
180
|
+
chats.deleteById(item);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
ev.on("messages.upsert", ({ messages: newMessages, type }) => {
|
|
185
|
+
switch (type) {
|
|
186
|
+
case "append":
|
|
187
|
+
case "notify":
|
|
188
|
+
for (const msg of newMessages) {
|
|
189
|
+
const jid = (0, import_WABinary.jidNormalizedUser)(msg.key.remoteJidAlt || msg.key.remoteJid);
|
|
190
|
+
const list = assertMessageList(jid);
|
|
191
|
+
list.upsert(msg, "append");
|
|
192
|
+
if (type === "notify" && !chats.get(jid)) {
|
|
193
|
+
ev.emit("chats.upsert", [
|
|
194
|
+
{
|
|
195
|
+
id: jid,
|
|
196
|
+
conversationTimestamp: (0, import_Utils.toNumber)(msg.messageTimestamp),
|
|
197
|
+
unreadCount: 1
|
|
198
|
+
}
|
|
199
|
+
]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
ev.on("messages.update", (updates) => {
|
|
206
|
+
var _a;
|
|
207
|
+
for (const { update, key } of updates) {
|
|
208
|
+
const list = assertMessageList((0, import_WABinary.jidNormalizedUser)(key.remoteJid));
|
|
209
|
+
if (update === null || update === void 0 ? void 0 : update.status) {
|
|
210
|
+
const listStatus = (_a = list.get(key.id)) === null || _a === void 0 ? void 0 : _a.status;
|
|
211
|
+
if (listStatus && (update === null || update === void 0 ? void 0 : update.status) <= listStatus) {
|
|
212
|
+
logger.debug({ update, storedStatus: listStatus }, "status stored newer then update");
|
|
213
|
+
delete update.status;
|
|
214
|
+
logger.debug({ update }, "new update object");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const result = list.updateAssign(key.id, update);
|
|
218
|
+
if (!result) {
|
|
219
|
+
logger.debug({ update }, "got update for non-existent message");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
ev.on("messages.delete", (item) => {
|
|
224
|
+
if ("all" in item) {
|
|
225
|
+
const list = messages[item.jid];
|
|
226
|
+
list === null || list === void 0 ? void 0 : list.clear();
|
|
227
|
+
} else {
|
|
228
|
+
const jid = item.keys[0].remoteJidAlt || item.keys[0].remoteJid;
|
|
229
|
+
const list = messages[jid];
|
|
230
|
+
if (list) {
|
|
231
|
+
const idSet = new Set(item.keys.map((k) => k.id));
|
|
232
|
+
list.filter((m) => !idSet.has(m.key.id));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
ev.on("groups.update", (updates) => {
|
|
237
|
+
for (const update of updates) {
|
|
238
|
+
const id = update.id;
|
|
239
|
+
if (groupMetadata[id]) {
|
|
240
|
+
Object.assign(groupMetadata[id], update);
|
|
241
|
+
} else {
|
|
242
|
+
logger.debug({ update }, "got update for non-existant group metadata");
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
ev.on("group-participants.update", ({ id, participants, action }) => {
|
|
247
|
+
const metadata = groupMetadata[id];
|
|
248
|
+
if (metadata) {
|
|
249
|
+
switch (action) {
|
|
250
|
+
case "add":
|
|
251
|
+
metadata.participants.push(...participants.map((participant) => ({ id: participant.id, phoneNumber: participant.phoneNumber, admin: participant.admin })));
|
|
252
|
+
break;
|
|
253
|
+
case "demote":
|
|
254
|
+
case "promote":
|
|
255
|
+
for (const participant of metadata.participants) {
|
|
256
|
+
for (const participantData of participants) {
|
|
257
|
+
if (participantData.id === participant.id || participantData.phoneNumber === participant.phoneNumber) {
|
|
258
|
+
participant.admin = action === "promote" && "admin";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
case "remove":
|
|
264
|
+
const removeSet = /* @__PURE__ */ new Set();
|
|
265
|
+
for (const p of participants) {
|
|
266
|
+
if (p.id)
|
|
267
|
+
removeSet.add(p.id);
|
|
268
|
+
if (p.phoneNumber)
|
|
269
|
+
removeSet.add(p.phoneNumber);
|
|
270
|
+
}
|
|
271
|
+
metadata.participants = metadata.participants.reduce((acc, p) => {
|
|
272
|
+
if (!removeSet.has(p.id) && !removeSet.has(p.phoneNumber))
|
|
273
|
+
acc.push(p);
|
|
274
|
+
return acc;
|
|
275
|
+
}, []);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
ev.on("message-receipt.update", (updates) => {
|
|
281
|
+
for (const { key, receipt } of updates) {
|
|
282
|
+
const obj = messages[key.remoteJidAlt || key.remoteJid];
|
|
283
|
+
const msg = obj === null || obj === void 0 ? void 0 : obj.get(key.id);
|
|
284
|
+
if (msg) {
|
|
285
|
+
(0, import_Utils.updateMessageWithReceipt)(msg, receipt);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
ev.on("messages.reaction", (reactions) => {
|
|
290
|
+
for (const { key, reaction } of reactions) {
|
|
291
|
+
const obj = messages[key.remoteJidAlt || key.remoteJid];
|
|
292
|
+
const msg = obj === null || obj === void 0 ? void 0 : obj.get(key.id);
|
|
293
|
+
if (msg) {
|
|
294
|
+
(0, import_Utils.updateMessageWithReaction)(msg, reaction);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
const toJSON = () => ({
|
|
300
|
+
chats,
|
|
301
|
+
contacts,
|
|
302
|
+
messages,
|
|
303
|
+
labels,
|
|
304
|
+
labelAssociations
|
|
305
|
+
});
|
|
306
|
+
const fromJSON = (json) => {
|
|
307
|
+
chats.upsert(...json.chats);
|
|
308
|
+
labelAssociations.upsert(...json.labelAssociations || []);
|
|
309
|
+
contactsUpsert(Object.values(json.contacts));
|
|
310
|
+
labelsUpsert(Object.values(json.labels || {}));
|
|
311
|
+
for (const jid in json.messages) {
|
|
312
|
+
const list = assertMessageList(jid);
|
|
313
|
+
for (const msg of json.messages[jid]) {
|
|
314
|
+
list.upsert(import_Types.WAProto.WebMessageInfo.fromObject(msg), "append");
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
chats,
|
|
320
|
+
contacts,
|
|
321
|
+
messages,
|
|
322
|
+
groupMetadata,
|
|
323
|
+
state,
|
|
324
|
+
presences,
|
|
325
|
+
labels,
|
|
326
|
+
labelAssociations,
|
|
327
|
+
bind,
|
|
328
|
+
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
329
|
+
loadMessages: async (jid, count, cursor) => {
|
|
330
|
+
const list = assertMessageList(jid);
|
|
331
|
+
const mode = !cursor || "before" in cursor ? "before" : "after";
|
|
332
|
+
const cursorKey = !!cursor ? "before" in cursor ? cursor.before : cursor.after : void 0;
|
|
333
|
+
const cursorValue = cursorKey ? list.get(cursorKey.id) : void 0;
|
|
334
|
+
let messages2;
|
|
335
|
+
if (list && mode === "before" && (!cursorKey || cursorValue)) {
|
|
336
|
+
if (cursorValue) {
|
|
337
|
+
const msgIdx = list.array.findIndex((m) => m.key.id === (cursorKey === null || cursorKey === void 0 ? void 0 : cursorKey.id));
|
|
338
|
+
messages2 = list.array.slice(0, msgIdx);
|
|
339
|
+
} else {
|
|
340
|
+
messages2 = list.array;
|
|
341
|
+
}
|
|
342
|
+
const diff = count - messages2.length;
|
|
343
|
+
if (diff < 0) {
|
|
344
|
+
messages2 = messages2.slice(-count);
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
messages2 = [];
|
|
348
|
+
}
|
|
349
|
+
return messages2;
|
|
350
|
+
},
|
|
351
|
+
/**
|
|
352
|
+
* Get all available labels for profile
|
|
353
|
+
*
|
|
354
|
+
* Keep in mind that the list is formed from predefined tags and tags
|
|
355
|
+
* that were "caught" during their editing.
|
|
356
|
+
*/
|
|
357
|
+
getLabels: () => {
|
|
358
|
+
return labels;
|
|
359
|
+
},
|
|
360
|
+
/**
|
|
361
|
+
* Get labels for chat
|
|
362
|
+
*
|
|
363
|
+
* @returns Label IDs
|
|
364
|
+
**/
|
|
365
|
+
getChatLabels: (chatId) => {
|
|
366
|
+
return labelAssociations.filter((la) => la.chatId === chatId).all();
|
|
367
|
+
},
|
|
368
|
+
/**
|
|
369
|
+
* Get labels for message
|
|
370
|
+
*
|
|
371
|
+
* @returns Label IDs
|
|
372
|
+
**/
|
|
373
|
+
getMessageLabels: (messageId) => {
|
|
374
|
+
const associations = labelAssociations.filter((la) => la.messageId === messageId).all();
|
|
375
|
+
return associations.map(({ labelId }) => labelId);
|
|
376
|
+
},
|
|
377
|
+
loadMessage: async (jid, id) => {
|
|
378
|
+
var _a;
|
|
379
|
+
return (_a = messages[jid]) === null || _a === void 0 ? void 0 : _a.get(id);
|
|
380
|
+
},
|
|
381
|
+
mostRecentMessage: async (jid) => {
|
|
382
|
+
var _a;
|
|
383
|
+
const message = (_a = messages[jid]) === null || _a === void 0 ? void 0 : _a.array.slice(-1)[0];
|
|
384
|
+
return message;
|
|
385
|
+
},
|
|
386
|
+
fetchImageUrl: async (jid, sock) => {
|
|
387
|
+
const contact = contacts[jid];
|
|
388
|
+
if (!contact) {
|
|
389
|
+
return sock === null || sock === void 0 ? void 0 : sock.profilePictureUrl(jid);
|
|
390
|
+
}
|
|
391
|
+
if (typeof contact.imgUrl === "undefined") {
|
|
392
|
+
contact.imgUrl = await (sock === null || sock === void 0 ? void 0 : sock.profilePictureUrl(jid));
|
|
393
|
+
}
|
|
394
|
+
return contact.imgUrl;
|
|
395
|
+
},
|
|
396
|
+
fetchGroupMetadata: async (jid, sock) => {
|
|
397
|
+
if (!groupMetadata[jid]) {
|
|
398
|
+
const metadata = await (sock === null || sock === void 0 ? void 0 : sock.groupMetadata(jid));
|
|
399
|
+
if (metadata) {
|
|
400
|
+
groupMetadata[jid] = metadata;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return groupMetadata[jid];
|
|
404
|
+
},
|
|
405
|
+
fetchMessageReceipts: async ({ remoteJid, id }) => {
|
|
406
|
+
const list = messages[remoteJid];
|
|
407
|
+
const msg = list === null || list === void 0 ? void 0 : list.get(id);
|
|
408
|
+
return msg === null || msg === void 0 ? void 0 : msg.userReceipt;
|
|
409
|
+
},
|
|
410
|
+
toJSON,
|
|
411
|
+
fromJSON,
|
|
412
|
+
writeToFile: (path) => {
|
|
413
|
+
(0, import_node_fs.writeFileSync)(path, JSON.stringify(toJSON()));
|
|
414
|
+
},
|
|
415
|
+
readFromFile: (path) => {
|
|
416
|
+
if ((0, import_node_fs.existsSync)(path)) {
|
|
417
|
+
logger.debug({ path }, "reading from file");
|
|
418
|
+
const jsonStr = (0, import_node_fs.readFileSync)(path, { encoding: "utf-8" });
|
|
419
|
+
const json = JSON.parse(jsonStr);
|
|
420
|
+
fromJSON(json);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
426
|
+
0 && (module.exports = {
|
|
427
|
+
makeInMemoryStore,
|
|
428
|
+
waChatKey,
|
|
429
|
+
waLabelAssociationKey,
|
|
430
|
+
waMessageID
|
|
431
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function makeOrderedDictionary(idGetter: any): {
|
|
2
|
+
array: any[];
|
|
3
|
+
get: (id: any) => any;
|
|
4
|
+
upsert: (item: any, mode: any) => void;
|
|
5
|
+
update: (item: any) => boolean;
|
|
6
|
+
remove: (item: any) => boolean;
|
|
7
|
+
updateAssign: (id: any, update: any) => boolean;
|
|
8
|
+
clear: () => void;
|
|
9
|
+
filter: (contain: any) => void;
|
|
10
|
+
toJSON: () => any[];
|
|
11
|
+
fromJSON: (newItems: any) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
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 make_ordered_dictionary_exports = {};
|
|
19
|
+
__export(make_ordered_dictionary_exports, {
|
|
20
|
+
makeOrderedDictionary: () => makeOrderedDictionary
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(make_ordered_dictionary_exports);
|
|
23
|
+
function makeOrderedDictionary(idGetter) {
|
|
24
|
+
const array = [];
|
|
25
|
+
const dict = {};
|
|
26
|
+
const get = (id) => dict[id];
|
|
27
|
+
const update = (item) => {
|
|
28
|
+
const id = idGetter(item);
|
|
29
|
+
const idx = array.findIndex((i) => idGetter(i) === id);
|
|
30
|
+
if (idx >= 0) {
|
|
31
|
+
array[idx] = item;
|
|
32
|
+
dict[id] = item;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
const upsert = (item, mode) => {
|
|
37
|
+
const id = idGetter(item);
|
|
38
|
+
if (get(id)) {
|
|
39
|
+
update(item);
|
|
40
|
+
} else {
|
|
41
|
+
if (mode === "append") {
|
|
42
|
+
array.push(item);
|
|
43
|
+
} else {
|
|
44
|
+
array.splice(0, 0, item);
|
|
45
|
+
}
|
|
46
|
+
dict[id] = item;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const remove = (item) => {
|
|
50
|
+
const id = idGetter(item);
|
|
51
|
+
const idx = array.findIndex((i) => idGetter(i) === id);
|
|
52
|
+
if (idx >= 0) {
|
|
53
|
+
array.splice(idx, 1);
|
|
54
|
+
delete dict[id];
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
array,
|
|
61
|
+
get,
|
|
62
|
+
upsert,
|
|
63
|
+
update,
|
|
64
|
+
remove,
|
|
65
|
+
updateAssign: (id, update2) => {
|
|
66
|
+
const item = get(id);
|
|
67
|
+
if (item) {
|
|
68
|
+
Object.assign(item, update2);
|
|
69
|
+
delete dict[id];
|
|
70
|
+
dict[idGetter(item)] = item;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
},
|
|
75
|
+
clear: () => {
|
|
76
|
+
array.splice(0, array.length);
|
|
77
|
+
for (const key of Object.keys(dict)) {
|
|
78
|
+
delete dict[key];
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
filter: (contain) => {
|
|
82
|
+
let i = 0;
|
|
83
|
+
while (i < array.length) {
|
|
84
|
+
if (!contain(array[i])) {
|
|
85
|
+
delete dict[idGetter(array[i])];
|
|
86
|
+
array.splice(i, 1);
|
|
87
|
+
} else {
|
|
88
|
+
i += 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
toJSON: () => array,
|
|
93
|
+
fromJSON: (newItems) => {
|
|
94
|
+
array.splice(0, array.length, ...newItems);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
makeOrderedDictionary
|
|
101
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class ObjectRepository {
|
|
2
|
+
constructor(entities?: {});
|
|
3
|
+
entityMap: Map<string, any>;
|
|
4
|
+
findById(id: any): any;
|
|
5
|
+
findAll(): any[];
|
|
6
|
+
upsertById(id: any, entity: any): Map<string, any>;
|
|
7
|
+
deleteById(id: any): boolean;
|
|
8
|
+
count(): number;
|
|
9
|
+
toJSON(): any[];
|
|
10
|
+
}
|