@eduh_dev021/baileys 0.0.0-stage → 1.1.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 +1843 -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/cache.js +179 -0
- package/cjs/lib/Addon/crc32.js +41 -0
- package/cjs/lib/Addon/file-type.js +217 -0
- package/cjs/lib/Addon/get-file.js +99 -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 +96 -0
- package/cjs/lib/Addon/index.js +58 -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/Addon/media-info.js +98 -0
- package/cjs/lib/Addon/mutex.js +78 -0
- package/cjs/lib/Addon/qr.js +464 -0
- package/cjs/lib/Addon/queue.js +54 -0
- package/cjs/lib/Addon/waveform.js +130 -0
- package/cjs/lib/Addon/zip.js +136 -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/cache.js +201 -0
- package/lib/Addon/crc32.js +21 -0
- package/lib/Addon/file-type.js +198 -0
- package/lib/Addon/get-file.js +98 -0
- package/lib/Addon/http-error.d.ts +18 -0
- package/lib/Addon/http-error.js +40 -0
- package/lib/Addon/index.d.ts +96 -0
- package/lib/Addon/index.js +26 -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/Addon/media-info.js +96 -0
- package/lib/Addon/mutex.js +76 -0
- package/lib/Addon/qr.js +531 -0
- package/lib/Addon/queue.js +44 -0
- package/lib/Addon/waveform.js +135 -0
- package/lib/Addon/zip.js +144 -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 +1907 -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 +366 -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 +226 -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 +74 -5
- package/tests/addon-test.mjs +162 -0
- package/tests/differential-test.mjs +90 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function makeNoiseHandler({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }: {
|
|
2
|
+
keyPair: {
|
|
3
|
+
private: any;
|
|
4
|
+
public: any;
|
|
5
|
+
};
|
|
6
|
+
NOISE_HEADER: any;
|
|
7
|
+
logger: any;
|
|
8
|
+
routingInfo: any;
|
|
9
|
+
}): {
|
|
10
|
+
encrypt: (plaintext: any) => any;
|
|
11
|
+
decrypt: (ciphertext: any) => any;
|
|
12
|
+
authenticate: (data: any) => void;
|
|
13
|
+
mixIntoKey: (data: any) => void;
|
|
14
|
+
finishInit: () => Promise<void>;
|
|
15
|
+
processHandshake: ({ serverHello }: {
|
|
16
|
+
serverHello: any;
|
|
17
|
+
}, noiseKey: any) => any;
|
|
18
|
+
encodeFrame: (data: any) => any;
|
|
19
|
+
decodeFrame: (newData: any, onFrame: any) => Promise<void>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
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 noise_handler_exports = {};
|
|
19
|
+
__export(noise_handler_exports, {
|
|
20
|
+
makeNoiseHandler: () => makeNoiseHandler
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(noise_handler_exports);
|
|
23
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
24
|
+
var import_Addon = require("../Addon/index.js");
|
|
25
|
+
var import_Defaults = require("../Defaults/index.js");
|
|
26
|
+
var import_WABinary = require("../WABinary/index.js");
|
|
27
|
+
var import_crypto = require("./crypto.js");
|
|
28
|
+
const IV_LENGTH = 12;
|
|
29
|
+
const EMPTY_BUFFER = Buffer.alloc(0);
|
|
30
|
+
const generateIV = (counter) => {
|
|
31
|
+
const iv = new ArrayBuffer(IV_LENGTH);
|
|
32
|
+
new DataView(iv).setUint32(8, counter);
|
|
33
|
+
return new Uint8Array(iv);
|
|
34
|
+
};
|
|
35
|
+
class TransportState {
|
|
36
|
+
constructor(encKey, decKey) {
|
|
37
|
+
this.encKey = encKey;
|
|
38
|
+
this.decKey = decKey;
|
|
39
|
+
this.readCounter = 0;
|
|
40
|
+
this.writeCounter = 0;
|
|
41
|
+
this.iv = new Uint8Array(IV_LENGTH);
|
|
42
|
+
}
|
|
43
|
+
encrypt(plaintext) {
|
|
44
|
+
const c = this.writeCounter++;
|
|
45
|
+
this.iv[8] = c >>> 24 & 255;
|
|
46
|
+
this.iv[9] = c >>> 16 & 255;
|
|
47
|
+
this.iv[10] = c >>> 8 & 255;
|
|
48
|
+
this.iv[11] = c & 255;
|
|
49
|
+
return (0, import_crypto.aesEncryptGCM)(plaintext, this.encKey, this.iv, EMPTY_BUFFER);
|
|
50
|
+
}
|
|
51
|
+
decrypt(ciphertext) {
|
|
52
|
+
const c = this.readCounter++;
|
|
53
|
+
this.iv[8] = c >>> 24 & 255;
|
|
54
|
+
this.iv[9] = c >>> 16 & 255;
|
|
55
|
+
this.iv[10] = c >>> 8 & 255;
|
|
56
|
+
this.iv[11] = c & 255;
|
|
57
|
+
return (0, import_crypto.aesDecryptGCM)(ciphertext, this.decKey, this.iv, EMPTY_BUFFER);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }) => {
|
|
61
|
+
logger = logger.child({ class: "ns" });
|
|
62
|
+
const data = Buffer.from(import_Defaults.NOISE_MODE);
|
|
63
|
+
let hash = data.byteLength === 32 ? data : (0, import_crypto.sha256)(data);
|
|
64
|
+
let salt = hash;
|
|
65
|
+
let encKey = hash;
|
|
66
|
+
let decKey = hash;
|
|
67
|
+
let counter = 0;
|
|
68
|
+
let sentIntro = false;
|
|
69
|
+
let inBytes = Buffer.alloc(0);
|
|
70
|
+
let transport = null;
|
|
71
|
+
let isWaitingForTransport = false;
|
|
72
|
+
let pendingOnFrame = null;
|
|
73
|
+
let introHeader;
|
|
74
|
+
if (routingInfo) {
|
|
75
|
+
introHeader = Buffer.alloc(7 + routingInfo.byteLength + NOISE_HEADER.length);
|
|
76
|
+
introHeader.write("ED", 0, "utf8");
|
|
77
|
+
introHeader.writeUint8(0, 2);
|
|
78
|
+
introHeader.writeUint8(1, 3);
|
|
79
|
+
introHeader.writeUint8(routingInfo.byteLength >> 16, 4);
|
|
80
|
+
introHeader.writeUint16BE(routingInfo.byteLength & 65535, 5);
|
|
81
|
+
introHeader.set(routingInfo, 7);
|
|
82
|
+
introHeader.set(NOISE_HEADER, 7 + routingInfo.byteLength);
|
|
83
|
+
} else {
|
|
84
|
+
introHeader = Buffer.from(NOISE_HEADER);
|
|
85
|
+
}
|
|
86
|
+
const authenticate = (data2) => {
|
|
87
|
+
if (!transport) {
|
|
88
|
+
hash = (0, import_crypto.sha256)(Buffer.concat([hash, data2]));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const encrypt = (plaintext) => {
|
|
92
|
+
if (transport) {
|
|
93
|
+
return transport.encrypt(plaintext);
|
|
94
|
+
}
|
|
95
|
+
const result = (0, import_crypto.aesEncryptGCM)(plaintext, encKey, generateIV(counter++), hash);
|
|
96
|
+
authenticate(result);
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
const decrypt = (ciphertext) => {
|
|
100
|
+
if (transport) {
|
|
101
|
+
return transport.decrypt(ciphertext);
|
|
102
|
+
}
|
|
103
|
+
const result = (0, import_crypto.aesDecryptGCM)(ciphertext, decKey, generateIV(counter++), hash);
|
|
104
|
+
authenticate(ciphertext);
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
const localHKDF = (data2) => {
|
|
108
|
+
const key = (0, import_crypto.hkdf)(Buffer.from(data2), 64, { salt, info: "" });
|
|
109
|
+
return [key.subarray(0, 32), key.subarray(32)];
|
|
110
|
+
};
|
|
111
|
+
const mixIntoKey = (data2) => {
|
|
112
|
+
const [write, read] = localHKDF(data2);
|
|
113
|
+
salt = write;
|
|
114
|
+
encKey = read;
|
|
115
|
+
decKey = read;
|
|
116
|
+
counter = 0;
|
|
117
|
+
};
|
|
118
|
+
const finishInit = async () => {
|
|
119
|
+
isWaitingForTransport = true;
|
|
120
|
+
const [write, read] = localHKDF(new Uint8Array(0));
|
|
121
|
+
transport = new TransportState(write, read);
|
|
122
|
+
isWaitingForTransport = false;
|
|
123
|
+
logger.trace("Noise handler transitioned to Transport state");
|
|
124
|
+
if (pendingOnFrame) {
|
|
125
|
+
logger.trace({ length: inBytes.length }, "Flushing buffered frames after transport ready");
|
|
126
|
+
await processData(pendingOnFrame);
|
|
127
|
+
pendingOnFrame = null;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const processData = async (onFrame) => {
|
|
131
|
+
let size;
|
|
132
|
+
while (true) {
|
|
133
|
+
if (inBytes.length < 3)
|
|
134
|
+
return;
|
|
135
|
+
size = inBytes[0] << 16 | inBytes[1] << 8 | inBytes[2];
|
|
136
|
+
if (inBytes.length < size + 3)
|
|
137
|
+
return;
|
|
138
|
+
let frame = inBytes.subarray(3, size + 3);
|
|
139
|
+
inBytes = inBytes.subarray(size + 3);
|
|
140
|
+
if (transport) {
|
|
141
|
+
const result = transport.decrypt(frame);
|
|
142
|
+
frame = await (0, import_WABinary.decodeBinaryNode)(result);
|
|
143
|
+
}
|
|
144
|
+
if (logger.level === "trace") {
|
|
145
|
+
logger.trace({ msg: frame?.attrs?.id }, "recv frame");
|
|
146
|
+
}
|
|
147
|
+
onFrame(frame);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
authenticate(NOISE_HEADER);
|
|
151
|
+
authenticate(publicKey);
|
|
152
|
+
return {
|
|
153
|
+
encrypt,
|
|
154
|
+
decrypt,
|
|
155
|
+
authenticate,
|
|
156
|
+
mixIntoKey,
|
|
157
|
+
finishInit,
|
|
158
|
+
processHandshake: ({ serverHello }, noiseKey) => {
|
|
159
|
+
authenticate(serverHello.ephemeral);
|
|
160
|
+
mixIntoKey(import_crypto.Curve.sharedKey(privateKey, serverHello.ephemeral));
|
|
161
|
+
const decStaticContent = decrypt(serverHello.static);
|
|
162
|
+
mixIntoKey(import_crypto.Curve.sharedKey(privateKey, decStaticContent));
|
|
163
|
+
const certDecoded = decrypt(serverHello.payload);
|
|
164
|
+
const { intermediate: certIntermediate, leaf } = import_WAProto.proto.CertChain.decode(certDecoded);
|
|
165
|
+
if (!leaf?.details || !leaf?.signature) {
|
|
166
|
+
throw new import_Addon.HttpError("invalid noise leaf certificate", { statusCode: 400 });
|
|
167
|
+
}
|
|
168
|
+
if (!certIntermediate?.details || !certIntermediate?.signature) {
|
|
169
|
+
throw new import_Addon.HttpError("invalid noise intermediate certificate", { statusCode: 400 });
|
|
170
|
+
}
|
|
171
|
+
const details = import_WAProto.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
|
|
172
|
+
const { issuerSerial } = details;
|
|
173
|
+
const verify = import_crypto.Curve.verify(details.key, leaf.details, leaf.signature);
|
|
174
|
+
const verifyIntermediate = import_crypto.Curve.verify(import_Defaults.WA_CERT_DETAILS.PUBLIC_KEY, certIntermediate.details, certIntermediate.signature);
|
|
175
|
+
if (!verify) {
|
|
176
|
+
throw new import_Addon.HttpError("noise certificate signature invalid", { statusCode: 400 });
|
|
177
|
+
}
|
|
178
|
+
if (!verifyIntermediate) {
|
|
179
|
+
throw new import_Addon.HttpError("noise intermediate certificate signature invalid", { statusCode: 400 });
|
|
180
|
+
}
|
|
181
|
+
if (issuerSerial !== import_Defaults.WA_CERT_DETAILS.SERIAL) {
|
|
182
|
+
throw new import_Addon.HttpError("certification match failed", { statusCode: 400 });
|
|
183
|
+
}
|
|
184
|
+
const keyEnc = encrypt(noiseKey.public);
|
|
185
|
+
mixIntoKey(import_crypto.Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
|
|
186
|
+
return keyEnc;
|
|
187
|
+
},
|
|
188
|
+
encodeFrame: (data2) => {
|
|
189
|
+
if (transport) {
|
|
190
|
+
data2 = transport.encrypt(data2);
|
|
191
|
+
}
|
|
192
|
+
const dataLen = data2.byteLength;
|
|
193
|
+
const introSize = sentIntro ? 0 : introHeader.length;
|
|
194
|
+
const frame = Buffer.allocUnsafe(introSize + 3 + dataLen);
|
|
195
|
+
if (!sentIntro) {
|
|
196
|
+
frame.set(introHeader);
|
|
197
|
+
sentIntro = true;
|
|
198
|
+
}
|
|
199
|
+
frame[introSize] = dataLen >>> 16 & 255;
|
|
200
|
+
frame[introSize + 1] = dataLen >>> 8 & 255;
|
|
201
|
+
frame[introSize + 2] = dataLen & 255;
|
|
202
|
+
frame.set(data2, introSize + 3);
|
|
203
|
+
return frame;
|
|
204
|
+
},
|
|
205
|
+
decodeFrame: async (newData, onFrame) => {
|
|
206
|
+
if (isWaitingForTransport) {
|
|
207
|
+
inBytes = Buffer.concat([inBytes, newData]);
|
|
208
|
+
pendingOnFrame = onFrame;
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (inBytes.length === 0) {
|
|
212
|
+
inBytes = Buffer.from(newData);
|
|
213
|
+
} else {
|
|
214
|
+
inBytes = Buffer.concat([inBytes, newData]);
|
|
215
|
+
}
|
|
216
|
+
await processData(onFrame);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
makeNoiseHandler
|
|
223
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a processor for offline stanza nodes that:
|
|
3
|
+
* - Queues nodes for sequential processing
|
|
4
|
+
* - Yields to the event loop periodically to avoid blocking
|
|
5
|
+
* - Catches handler errors to prevent the processing loop from crashing
|
|
6
|
+
*/
|
|
7
|
+
export function makeOfflineNodeProcessor(nodeProcessorMap: any, deps: any, batchSize?: number): {
|
|
8
|
+
enqueue: (type: any, node: any) => void;
|
|
9
|
+
};
|
|
10
|
+
export function isOfflineNode(node: any): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 offline_node_processor_exports = {};
|
|
19
|
+
__export(offline_node_processor_exports, {
|
|
20
|
+
isOfflineNode: () => isOfflineNode,
|
|
21
|
+
makeOfflineNodeProcessor: () => makeOfflineNodeProcessor
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(offline_node_processor_exports);
|
|
24
|
+
const isOfflineNode = (node) => node?.attrs?.offline === "1";
|
|
25
|
+
function makeOfflineNodeProcessor(nodeProcessorMap, deps, batchSize = 10) {
|
|
26
|
+
const nodes = [];
|
|
27
|
+
let isProcessing = false;
|
|
28
|
+
const enqueue = (type, node) => {
|
|
29
|
+
nodes.push({ type, node });
|
|
30
|
+
if (isProcessing) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
isProcessing = true;
|
|
34
|
+
const promise = async () => {
|
|
35
|
+
let processedInBatch = 0;
|
|
36
|
+
while (nodes.length && deps.isWsOpen()) {
|
|
37
|
+
const { type: type2, node: node2 } = nodes.shift();
|
|
38
|
+
const nodeProcessor = nodeProcessorMap.get(type2);
|
|
39
|
+
if (!nodeProcessor) {
|
|
40
|
+
deps.onUnexpectedError(new Error(`unknown offline node type: ${type2}`), "processing offline node");
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
await nodeProcessor(node2).catch((err) => deps.onUnexpectedError(err, `processing offline ${type2}`));
|
|
44
|
+
processedInBatch++;
|
|
45
|
+
if (processedInBatch >= batchSize) {
|
|
46
|
+
processedInBatch = 0;
|
|
47
|
+
await deps.yieldToEventLoop();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
isProcessing = false;
|
|
51
|
+
};
|
|
52
|
+
promise().catch((error) => deps.onUnexpectedError(error, "processing offline nodes"));
|
|
53
|
+
};
|
|
54
|
+
return { enqueue };
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
isOfflineNode,
|
|
59
|
+
makeOfflineNodeProcessor
|
|
60
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages pre-key operations with proper concurrency control
|
|
3
|
+
*/
|
|
4
|
+
export class PreKeyManager {
|
|
5
|
+
constructor(store: any, logger: any);
|
|
6
|
+
store: any;
|
|
7
|
+
logger: any;
|
|
8
|
+
queues: Map<any, any>;
|
|
9
|
+
/**
|
|
10
|
+
* Get or create a queue for a specific key type
|
|
11
|
+
*/
|
|
12
|
+
getQueue(keyType: any): any;
|
|
13
|
+
/**
|
|
14
|
+
* Process pre-key operations (updates and deletions)
|
|
15
|
+
*/
|
|
16
|
+
processOperations(data: any, keyType: any, transactionCache: any, mutations: any, isInTransaction: any): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Process deletions with validation
|
|
19
|
+
*/
|
|
20
|
+
processDeletions(keyType: any, ids: any, transactionCache: any, mutations: any, isInTransaction: any): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Validate and process pre-key deletions outside transactions
|
|
23
|
+
*/
|
|
24
|
+
validateDeletions(data: any, keyType: any): Promise<any>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 pre_key_manager_exports = {};
|
|
19
|
+
__export(pre_key_manager_exports, {
|
|
20
|
+
PreKeyManager: () => PreKeyManager
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pre_key_manager_exports);
|
|
23
|
+
var import_Addon = require("../Addon/index.js");
|
|
24
|
+
class PreKeyManager {
|
|
25
|
+
constructor(store, logger) {
|
|
26
|
+
this.store = store;
|
|
27
|
+
this.logger = logger;
|
|
28
|
+
this.queues = /* @__PURE__ */ new Map();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get or create a queue for a specific key type
|
|
32
|
+
*/
|
|
33
|
+
getQueue(keyType) {
|
|
34
|
+
if (!this.queues.has(keyType)) {
|
|
35
|
+
this.queues.set(keyType, (0, import_Addon.createQueue)(1));
|
|
36
|
+
}
|
|
37
|
+
return this.queues.get(keyType);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Process pre-key operations (updates and deletions)
|
|
41
|
+
*/
|
|
42
|
+
async processOperations(data, keyType, transactionCache, mutations, isInTransaction) {
|
|
43
|
+
const keyData = data[keyType];
|
|
44
|
+
if (!keyData)
|
|
45
|
+
return;
|
|
46
|
+
return this.getQueue(keyType).add(async () => {
|
|
47
|
+
transactionCache[keyType] = transactionCache[keyType] || {};
|
|
48
|
+
mutations[keyType] = mutations[keyType] || {};
|
|
49
|
+
const deletions = [];
|
|
50
|
+
const updates = {};
|
|
51
|
+
for (const keyId in keyData) {
|
|
52
|
+
if (keyData[keyId] === null) {
|
|
53
|
+
deletions.push(keyId);
|
|
54
|
+
} else {
|
|
55
|
+
updates[keyId] = keyData[keyId];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (Object.keys(updates).length > 0) {
|
|
59
|
+
Object.assign(transactionCache[keyType], updates);
|
|
60
|
+
Object.assign(mutations[keyType], updates);
|
|
61
|
+
}
|
|
62
|
+
if (deletions.length > 0) {
|
|
63
|
+
await this.processDeletions(keyType, deletions, transactionCache, mutations, isInTransaction);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Process deletions with validation
|
|
69
|
+
*/
|
|
70
|
+
async processDeletions(keyType, ids, transactionCache, mutations, isInTransaction) {
|
|
71
|
+
if (isInTransaction) {
|
|
72
|
+
for (const keyId of ids) {
|
|
73
|
+
if (transactionCache[keyType]?.[keyId]) {
|
|
74
|
+
transactionCache[keyType][keyId] = null;
|
|
75
|
+
mutations[keyType][keyId] = null;
|
|
76
|
+
} else {
|
|
77
|
+
this.logger.warn(`Skipping deletion of non-existent ${keyType} in transaction: ${keyId}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
const existingKeys = await this.store.get(keyType, ids);
|
|
82
|
+
for (const keyId of ids) {
|
|
83
|
+
if (existingKeys[keyId]) {
|
|
84
|
+
transactionCache[keyType][keyId] = null;
|
|
85
|
+
mutations[keyType][keyId] = null;
|
|
86
|
+
} else {
|
|
87
|
+
this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate and process pre-key deletions outside transactions
|
|
94
|
+
*/
|
|
95
|
+
async validateDeletions(data, keyType) {
|
|
96
|
+
const keyData = data[keyType];
|
|
97
|
+
if (!keyData)
|
|
98
|
+
return;
|
|
99
|
+
return this.getQueue(keyType).add(async () => {
|
|
100
|
+
const deletionIds = Object.keys(keyData).filter((id) => keyData[id] === null);
|
|
101
|
+
if (deletionIds.length === 0)
|
|
102
|
+
return;
|
|
103
|
+
const existingKeys = await this.store.get(keyType, deletionIds);
|
|
104
|
+
for (const keyId of deletionIds) {
|
|
105
|
+
if (!existingKeys[keyId]) {
|
|
106
|
+
this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`);
|
|
107
|
+
delete data[keyType][keyId];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
+
0 && (module.exports = {
|
|
115
|
+
PreKeyManager
|
|
116
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decrypt a poll vote
|
|
3
|
+
* @param vote encrypted vote
|
|
4
|
+
* @param ctx additional info about the poll required for decryption
|
|
5
|
+
* @returns list of SHA256 options
|
|
6
|
+
*/
|
|
7
|
+
export function decryptPollVote({ encPayload, encIv }: {
|
|
8
|
+
encPayload: any;
|
|
9
|
+
encIv: any;
|
|
10
|
+
}, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }: {
|
|
11
|
+
pollCreatorJid: any;
|
|
12
|
+
pollMsgId: any;
|
|
13
|
+
pollEncKey: any;
|
|
14
|
+
voterJid: any;
|
|
15
|
+
}): proto.Message.PollVoteMessage & proto.Message.PollVoteMessage.$Properties;
|
|
16
|
+
/**
|
|
17
|
+
* Decrypt an event response
|
|
18
|
+
* @param response encrypted event response
|
|
19
|
+
* @param ctx additional info about the event required for decryption
|
|
20
|
+
* @returns event response message
|
|
21
|
+
*/
|
|
22
|
+
export function decryptEventResponse({ encPayload, encIv }: {
|
|
23
|
+
encPayload: any;
|
|
24
|
+
encIv: any;
|
|
25
|
+
}, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }: {
|
|
26
|
+
eventCreatorJid: any;
|
|
27
|
+
eventMsgId: any;
|
|
28
|
+
eventEncKey: any;
|
|
29
|
+
responderJid: any;
|
|
30
|
+
}): proto.Message.EventResponseMessage & proto.Message.EventResponseMessage.$Properties;
|
|
31
|
+
/**
|
|
32
|
+
* Decrypt a `secretEncryptedMessage` carrying a `MESSAGE_EDIT` payload.
|
|
33
|
+
*
|
|
34
|
+
* WhatsApp started wrapping message edits in an E2EE envelope (May 2026).
|
|
35
|
+
* The new content is encrypted with a key derived from the original
|
|
36
|
+
* message's `messageContextInfo.messageSecret` using HKDF-SHA256
|
|
37
|
+
* + AES-256-GCM, same family as polls and event responses but with
|
|
38
|
+
* different constants (validated against live WhatsApp Android traffic):
|
|
39
|
+
*
|
|
40
|
+
* info = msgId || origSenderJid || editorJid || "Message Edit"
|
|
41
|
+
* aad = (empty) <-- differs from Poll Vote / Event Response
|
|
42
|
+
* key = HKDF-SHA256(salt=zeros, ikm=messageSecret, info, L=32)
|
|
43
|
+
*
|
|
44
|
+
* The decrypted plaintext is a regular `proto.Message` whose
|
|
45
|
+
* `protocolMessage.editedMessage` field holds the new content — same
|
|
46
|
+
* shape as the legacy `protocolMessage.editedMessage` edit path, so
|
|
47
|
+
* consumers can treat the result identically.
|
|
48
|
+
*
|
|
49
|
+
* @param edit encrypted edit payload (encPayload + encIv from SecretEncryptedMessage)
|
|
50
|
+
* @param ctx info about the original message required for decryption
|
|
51
|
+
* @returns decoded outer `Message` whose `protocolMessage.editedMessage`
|
|
52
|
+
* carries the new content (extendedTextMessage / conversation / etc.)
|
|
53
|
+
*/
|
|
54
|
+
export function decryptMessageEdit({ encPayload, encIv }: {
|
|
55
|
+
encPayload: any;
|
|
56
|
+
encIv: any;
|
|
57
|
+
}, { originalSenderJid, originalMsgId, editEncKey, editorJid }: {
|
|
58
|
+
originalSenderJid: any;
|
|
59
|
+
originalMsgId: any;
|
|
60
|
+
editEncKey: any;
|
|
61
|
+
editorJid: any;
|
|
62
|
+
}): proto.Message & proto.Message.$Shape;
|
|
63
|
+
export function cleanMessage(message: any, meId: any, meLid: any): void;
|
|
64
|
+
export function isRealMessage(message: any): boolean;
|
|
65
|
+
export function shouldIncrementChatUnread(message: any): boolean;
|
|
66
|
+
export function getChatId({ remoteJid, participant, fromMe }: {
|
|
67
|
+
remoteJid: any;
|
|
68
|
+
participant: any;
|
|
69
|
+
fromMe: any;
|
|
70
|
+
}): any;
|
|
71
|
+
export default processMessage;
|
|
72
|
+
import { proto } from '../../WAProto/index.js';
|
|
73
|
+
declare function processMessage(message: any, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }: {
|
|
74
|
+
shouldProcessHistoryMsg: any;
|
|
75
|
+
placeholderResendCache: any;
|
|
76
|
+
ev: any;
|
|
77
|
+
creds: any;
|
|
78
|
+
signalRepository: any;
|
|
79
|
+
keyStore: any;
|
|
80
|
+
logger: any;
|
|
81
|
+
options: any;
|
|
82
|
+
getMessage: any;
|
|
83
|
+
}): Promise<void>;
|