@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,9 @@
|
|
|
1
|
+
export function decompressingIfRequired(buffer: any): Promise<any>;
|
|
2
|
+
export function decodeDecompressedBinaryNode(buffer: any, opts: any, indexRef?: {
|
|
3
|
+
index: number;
|
|
4
|
+
}): {
|
|
5
|
+
tag: any;
|
|
6
|
+
attrs: {};
|
|
7
|
+
content: any;
|
|
8
|
+
};
|
|
9
|
+
export function decodeBinaryNode(buff: any): Promise<any>;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var decode_exports = {};
|
|
29
|
+
__export(decode_exports, {
|
|
30
|
+
decodeBinaryNode: () => decodeBinaryNode,
|
|
31
|
+
decodeDecompressedBinaryNode: () => decodeDecompressedBinaryNode,
|
|
32
|
+
decompressingIfRequired: () => decompressingIfRequired
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(decode_exports);
|
|
35
|
+
var import_node_util = require("node:util");
|
|
36
|
+
var import_node_zlib = require("node:zlib");
|
|
37
|
+
var constants = __toESM(require("./constants.js"));
|
|
38
|
+
var import_jid_utils = require("./jid-utils.js");
|
|
39
|
+
const inflatePromise = (0, import_node_util.promisify)(import_node_zlib.inflate);
|
|
40
|
+
const decompressingIfRequired = async (buffer) => {
|
|
41
|
+
if (2 & buffer.readUInt8()) {
|
|
42
|
+
buffer = await inflatePromise(buffer.slice(1));
|
|
43
|
+
} else {
|
|
44
|
+
buffer = buffer.slice(1);
|
|
45
|
+
}
|
|
46
|
+
return buffer;
|
|
47
|
+
};
|
|
48
|
+
const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
|
|
49
|
+
const { DOUBLE_BYTE_TOKENS, SINGLE_BYTE_TOKENS, TAGS } = opts;
|
|
50
|
+
const checkEOS = (length) => {
|
|
51
|
+
if (indexRef.index + length > buffer.length) {
|
|
52
|
+
throw new Error("end of stream");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const next = () => {
|
|
56
|
+
const value = buffer[indexRef.index];
|
|
57
|
+
indexRef.index += 1;
|
|
58
|
+
return value;
|
|
59
|
+
};
|
|
60
|
+
const readByte = () => {
|
|
61
|
+
checkEOS(1);
|
|
62
|
+
return next();
|
|
63
|
+
};
|
|
64
|
+
const readBytes = (n) => {
|
|
65
|
+
checkEOS(n);
|
|
66
|
+
const value = buffer.slice(indexRef.index, indexRef.index + n);
|
|
67
|
+
indexRef.index += n;
|
|
68
|
+
return value;
|
|
69
|
+
};
|
|
70
|
+
const readStringFromChars = (length) => {
|
|
71
|
+
return readBytes(length).toString("utf-8");
|
|
72
|
+
};
|
|
73
|
+
const readInt = (n, littleEndian = false) => {
|
|
74
|
+
checkEOS(n);
|
|
75
|
+
let val = 0;
|
|
76
|
+
for (let i = 0; i < n; i++) {
|
|
77
|
+
const shift = littleEndian ? i : n - 1 - i;
|
|
78
|
+
val |= next() << shift * 8;
|
|
79
|
+
}
|
|
80
|
+
return val;
|
|
81
|
+
};
|
|
82
|
+
const readInt20 = () => {
|
|
83
|
+
checkEOS(3);
|
|
84
|
+
return ((next() & 15) << 16) + (next() << 8) + next();
|
|
85
|
+
};
|
|
86
|
+
const unpackHex = (value) => {
|
|
87
|
+
if (value >= 0 && value < 16) {
|
|
88
|
+
return value < 10 ? "0".charCodeAt(0) + value : "A".charCodeAt(0) + value - 10;
|
|
89
|
+
}
|
|
90
|
+
throw new Error("invalid hex: " + value);
|
|
91
|
+
};
|
|
92
|
+
const unpackNibble = (value) => {
|
|
93
|
+
if (value >= 0 && value <= 9) {
|
|
94
|
+
return "0".charCodeAt(0) + value;
|
|
95
|
+
}
|
|
96
|
+
switch (value) {
|
|
97
|
+
case 10:
|
|
98
|
+
return "-".charCodeAt(0);
|
|
99
|
+
case 11:
|
|
100
|
+
return ".".charCodeAt(0);
|
|
101
|
+
case 15:
|
|
102
|
+
return "\0".charCodeAt(0);
|
|
103
|
+
default:
|
|
104
|
+
throw new Error("invalid nibble: " + value);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const unpackByte = (tag, value) => {
|
|
108
|
+
if (tag === TAGS.NIBBLE_8) {
|
|
109
|
+
return unpackNibble(value);
|
|
110
|
+
} else if (tag === TAGS.HEX_8) {
|
|
111
|
+
return unpackHex(value);
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error("unknown tag: " + tag);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const readPacked8 = (tag) => {
|
|
117
|
+
const startByte = readByte();
|
|
118
|
+
let value = "";
|
|
119
|
+
for (let i = 0; i < (startByte & 127); i++) {
|
|
120
|
+
const curByte = readByte();
|
|
121
|
+
value += String.fromCharCode(unpackByte(tag, (curByte & 240) >> 4));
|
|
122
|
+
value += String.fromCharCode(unpackByte(tag, curByte & 15));
|
|
123
|
+
}
|
|
124
|
+
if (startByte >> 7 !== 0) {
|
|
125
|
+
value = value.slice(0, -1);
|
|
126
|
+
}
|
|
127
|
+
return value;
|
|
128
|
+
};
|
|
129
|
+
const isListTag = (tag) => {
|
|
130
|
+
return tag === TAGS.LIST_EMPTY || tag === TAGS.LIST_8 || tag === TAGS.LIST_16;
|
|
131
|
+
};
|
|
132
|
+
const readListSize = (tag) => {
|
|
133
|
+
switch (tag) {
|
|
134
|
+
case TAGS.LIST_EMPTY:
|
|
135
|
+
return 0;
|
|
136
|
+
case TAGS.LIST_8:
|
|
137
|
+
return readByte();
|
|
138
|
+
case TAGS.LIST_16:
|
|
139
|
+
return readInt(2);
|
|
140
|
+
default:
|
|
141
|
+
throw new Error("invalid tag for list size: " + tag);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const readJidPair = () => {
|
|
145
|
+
const i = readString(readByte());
|
|
146
|
+
const j = readString(readByte());
|
|
147
|
+
if (j) {
|
|
148
|
+
return (i || "") + "@" + j;
|
|
149
|
+
}
|
|
150
|
+
throw new Error("invalid jid pair: " + i + ", " + j);
|
|
151
|
+
};
|
|
152
|
+
const readAdJid = () => {
|
|
153
|
+
const rawDomainType = readByte();
|
|
154
|
+
const domainType = Number(rawDomainType);
|
|
155
|
+
const device = readByte();
|
|
156
|
+
const user = readString(readByte());
|
|
157
|
+
let server = "s.whatsapp.net";
|
|
158
|
+
if (domainType === import_jid_utils.WAJIDDomains.LID) {
|
|
159
|
+
server = "lid";
|
|
160
|
+
} else if (domainType === import_jid_utils.WAJIDDomains.HOSTED) {
|
|
161
|
+
server = "hosted";
|
|
162
|
+
} else if (domainType === import_jid_utils.WAJIDDomains.HOSTED_LID) {
|
|
163
|
+
server = "hosted.lid";
|
|
164
|
+
}
|
|
165
|
+
return (0, import_jid_utils.jidEncode)(user, server, device);
|
|
166
|
+
};
|
|
167
|
+
const readFbJid = () => {
|
|
168
|
+
const user = readString(readByte());
|
|
169
|
+
const device = readInt(2);
|
|
170
|
+
const server = readString(readByte());
|
|
171
|
+
return `${user}:${device}@${server}`;
|
|
172
|
+
};
|
|
173
|
+
const readInteropJid = () => {
|
|
174
|
+
const user = readString(readByte());
|
|
175
|
+
const device = readInt(2);
|
|
176
|
+
const integrator = readInt(2);
|
|
177
|
+
let server = "interop";
|
|
178
|
+
const beforeServer = indexRef.index;
|
|
179
|
+
try {
|
|
180
|
+
server = readString(readByte());
|
|
181
|
+
} catch (err) {
|
|
182
|
+
indexRef.index = beforeServer;
|
|
183
|
+
}
|
|
184
|
+
return `${integrator}-${user}:${device}@${server}`;
|
|
185
|
+
};
|
|
186
|
+
const readString = (tag) => {
|
|
187
|
+
if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
|
|
188
|
+
return SINGLE_BYTE_TOKENS[tag] || "";
|
|
189
|
+
}
|
|
190
|
+
switch (tag) {
|
|
191
|
+
case TAGS.DICTIONARY_0:
|
|
192
|
+
case TAGS.DICTIONARY_1:
|
|
193
|
+
case TAGS.DICTIONARY_2:
|
|
194
|
+
case TAGS.DICTIONARY_3:
|
|
195
|
+
return getTokenDouble(tag - TAGS.DICTIONARY_0, readByte());
|
|
196
|
+
case TAGS.LIST_EMPTY:
|
|
197
|
+
return "";
|
|
198
|
+
case TAGS.BINARY_8:
|
|
199
|
+
return readStringFromChars(readByte());
|
|
200
|
+
case TAGS.BINARY_20:
|
|
201
|
+
return readStringFromChars(readInt20());
|
|
202
|
+
case TAGS.BINARY_32:
|
|
203
|
+
return readStringFromChars(readInt(4));
|
|
204
|
+
case TAGS.JID_PAIR:
|
|
205
|
+
return readJidPair();
|
|
206
|
+
case TAGS.FB_JID:
|
|
207
|
+
return readFbJid();
|
|
208
|
+
case TAGS.INTEROP_JID:
|
|
209
|
+
return readInteropJid();
|
|
210
|
+
case TAGS.AD_JID:
|
|
211
|
+
return readAdJid();
|
|
212
|
+
case TAGS.HEX_8:
|
|
213
|
+
case TAGS.NIBBLE_8:
|
|
214
|
+
return readPacked8(tag);
|
|
215
|
+
default:
|
|
216
|
+
throw new Error("invalid string with tag: " + tag);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const readList = (tag) => {
|
|
220
|
+
const items = [];
|
|
221
|
+
const size = readListSize(tag);
|
|
222
|
+
for (let i = 0; i < size; i++) {
|
|
223
|
+
items.push(decodeDecompressedBinaryNode(buffer, opts, indexRef));
|
|
224
|
+
}
|
|
225
|
+
return items;
|
|
226
|
+
};
|
|
227
|
+
const getTokenDouble = (index1, index2) => {
|
|
228
|
+
const dict = DOUBLE_BYTE_TOKENS[index1];
|
|
229
|
+
if (!dict) {
|
|
230
|
+
throw new Error(`Invalid double token dict (${index1})`);
|
|
231
|
+
}
|
|
232
|
+
const value = dict[index2];
|
|
233
|
+
if (typeof value === "undefined") {
|
|
234
|
+
throw new Error(`Invalid double token (${index2})`);
|
|
235
|
+
}
|
|
236
|
+
return value;
|
|
237
|
+
};
|
|
238
|
+
const listSize = readListSize(readByte());
|
|
239
|
+
const header = readString(readByte());
|
|
240
|
+
if (!listSize || !header.length) {
|
|
241
|
+
throw new Error("invalid node");
|
|
242
|
+
}
|
|
243
|
+
const attrs = {};
|
|
244
|
+
let data;
|
|
245
|
+
if (listSize === 0 || !header) {
|
|
246
|
+
throw new Error("invalid node");
|
|
247
|
+
}
|
|
248
|
+
const attributesLength = listSize - 1 >> 1;
|
|
249
|
+
for (let i = 0; i < attributesLength; i++) {
|
|
250
|
+
const key = readString(readByte());
|
|
251
|
+
const value = readString(readByte());
|
|
252
|
+
attrs[key] = value;
|
|
253
|
+
}
|
|
254
|
+
if (listSize % 2 === 0) {
|
|
255
|
+
const tag = readByte();
|
|
256
|
+
if (isListTag(tag)) {
|
|
257
|
+
data = readList(tag);
|
|
258
|
+
} else {
|
|
259
|
+
let decoded;
|
|
260
|
+
switch (tag) {
|
|
261
|
+
case TAGS.BINARY_8:
|
|
262
|
+
decoded = readBytes(readByte());
|
|
263
|
+
break;
|
|
264
|
+
case TAGS.BINARY_20:
|
|
265
|
+
decoded = readBytes(readInt20());
|
|
266
|
+
break;
|
|
267
|
+
case TAGS.BINARY_32:
|
|
268
|
+
decoded = readBytes(readInt(4));
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
decoded = readString(tag);
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
data = decoded;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
tag: header,
|
|
279
|
+
attrs,
|
|
280
|
+
content: data
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const decodeBinaryNode = async (buff) => {
|
|
284
|
+
const decompBuff = await decompressingIfRequired(buff);
|
|
285
|
+
return decodeDecompressedBinaryNode(decompBuff, constants);
|
|
286
|
+
};
|
|
287
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
288
|
+
0 && (module.exports = {
|
|
289
|
+
decodeBinaryNode,
|
|
290
|
+
decodeDecompressedBinaryNode,
|
|
291
|
+
decompressingIfRequired
|
|
292
|
+
});
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var encode_exports = {};
|
|
29
|
+
__export(encode_exports, {
|
|
30
|
+
encodeBinaryNode: () => encodeBinaryNode
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(encode_exports);
|
|
33
|
+
var constants = __toESM(require("./constants.js"));
|
|
34
|
+
var import_jid_utils = require("./jid-utils.js");
|
|
35
|
+
const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
|
|
36
|
+
const encoded = encodeBinaryNodeInner(node, opts, buffer);
|
|
37
|
+
return Buffer.from(encoded);
|
|
38
|
+
};
|
|
39
|
+
const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
40
|
+
const { TAGS, TOKEN_MAP } = opts;
|
|
41
|
+
const pushByte = (value) => buffer.push(value & 255);
|
|
42
|
+
const pushInt = (value, n, littleEndian = false) => {
|
|
43
|
+
for (let i = 0; i < n; i++) {
|
|
44
|
+
const curShift = littleEndian ? i : n - 1 - i;
|
|
45
|
+
buffer.push(value >> curShift * 8 & 255);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const pushBytes = (bytes) => {
|
|
49
|
+
for (const b of bytes) {
|
|
50
|
+
buffer.push(b);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const pushInt16 = (value) => {
|
|
54
|
+
pushBytes([value >> 8 & 255, value & 255]);
|
|
55
|
+
};
|
|
56
|
+
const pushInt20 = (value) => pushBytes([value >> 16 & 15, value >> 8 & 255, value & 255]);
|
|
57
|
+
const writeByteLength = (length) => {
|
|
58
|
+
if (length >= 4294967296) {
|
|
59
|
+
throw new Error("string too large to encode: " + length);
|
|
60
|
+
}
|
|
61
|
+
if (length >= 1 << 20) {
|
|
62
|
+
pushByte(TAGS.BINARY_32);
|
|
63
|
+
pushInt(length, 4);
|
|
64
|
+
} else if (length >= 256) {
|
|
65
|
+
pushByte(TAGS.BINARY_20);
|
|
66
|
+
pushInt20(length);
|
|
67
|
+
} else {
|
|
68
|
+
pushByte(TAGS.BINARY_8);
|
|
69
|
+
pushByte(length);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const writeStringRaw = (str) => {
|
|
73
|
+
const bytes = Buffer.from(str, "utf-8");
|
|
74
|
+
writeByteLength(bytes.length);
|
|
75
|
+
pushBytes(bytes);
|
|
76
|
+
};
|
|
77
|
+
const writeJid = ({ domainType, device, user, server }) => {
|
|
78
|
+
if (typeof device !== "undefined") {
|
|
79
|
+
pushByte(TAGS.AD_JID);
|
|
80
|
+
pushByte(domainType || 0);
|
|
81
|
+
pushByte(device || 0);
|
|
82
|
+
writeString(user);
|
|
83
|
+
} else {
|
|
84
|
+
pushByte(TAGS.JID_PAIR);
|
|
85
|
+
if (user.length) {
|
|
86
|
+
writeString(user);
|
|
87
|
+
} else {
|
|
88
|
+
pushByte(TAGS.LIST_EMPTY);
|
|
89
|
+
}
|
|
90
|
+
writeString(server);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const packNibble = (char) => {
|
|
94
|
+
switch (char) {
|
|
95
|
+
case "-":
|
|
96
|
+
return 10;
|
|
97
|
+
case ".":
|
|
98
|
+
return 11;
|
|
99
|
+
case "\0":
|
|
100
|
+
return 15;
|
|
101
|
+
default:
|
|
102
|
+
if (char >= "0" && char <= "9") {
|
|
103
|
+
return char.charCodeAt(0) - "0".charCodeAt(0);
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`invalid byte for nibble "${char}"`);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const packHex = (char) => {
|
|
109
|
+
if (char >= "0" && char <= "9") {
|
|
110
|
+
return char.charCodeAt(0) - "0".charCodeAt(0);
|
|
111
|
+
}
|
|
112
|
+
if (char >= "A" && char <= "F") {
|
|
113
|
+
return 10 + char.charCodeAt(0) - "A".charCodeAt(0);
|
|
114
|
+
}
|
|
115
|
+
if (char >= "a" && char <= "f") {
|
|
116
|
+
return 10 + char.charCodeAt(0) - "a".charCodeAt(0);
|
|
117
|
+
}
|
|
118
|
+
if (char === "\0") {
|
|
119
|
+
return 15;
|
|
120
|
+
}
|
|
121
|
+
throw new Error(`Invalid hex char "${char}"`);
|
|
122
|
+
};
|
|
123
|
+
const writePackedBytes = (str, type) => {
|
|
124
|
+
if (str.length > TAGS.PACKED_MAX) {
|
|
125
|
+
throw new Error("Too many bytes to pack");
|
|
126
|
+
}
|
|
127
|
+
pushByte(type === "nibble" ? TAGS.NIBBLE_8 : TAGS.HEX_8);
|
|
128
|
+
let roundedLength = Math.ceil(str.length / 2);
|
|
129
|
+
if (str.length % 2 !== 0) {
|
|
130
|
+
roundedLength |= 128;
|
|
131
|
+
}
|
|
132
|
+
pushByte(roundedLength);
|
|
133
|
+
const packFunction = type === "nibble" ? packNibble : packHex;
|
|
134
|
+
const packBytePair = (v1, v2) => {
|
|
135
|
+
const result = packFunction(v1) << 4 | packFunction(v2);
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
const strLengthHalf = Math.floor(str.length / 2);
|
|
139
|
+
for (let i = 0; i < strLengthHalf; i++) {
|
|
140
|
+
pushByte(packBytePair(str[2 * i], str[2 * i + 1]));
|
|
141
|
+
}
|
|
142
|
+
if (str.length % 2 !== 0) {
|
|
143
|
+
pushByte(packBytePair(str[str.length - 1], "\0"));
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const isNibble = (str) => {
|
|
147
|
+
if (!str || str.length > TAGS.PACKED_MAX) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
for (const char of str) {
|
|
151
|
+
const isInNibbleRange = char >= "0" && char <= "9";
|
|
152
|
+
if (!isInNibbleRange && char !== "-" && char !== ".") {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
};
|
|
158
|
+
const isHex = (str) => {
|
|
159
|
+
if (!str || str.length > TAGS.PACKED_MAX) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
for (const char of str) {
|
|
163
|
+
const isInNibbleRange = char >= "0" && char <= "9";
|
|
164
|
+
if (!isInNibbleRange && !(char >= "A" && char <= "F")) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
};
|
|
170
|
+
const writeString = (str) => {
|
|
171
|
+
if (str === void 0 || str === null) {
|
|
172
|
+
pushByte(TAGS.LIST_EMPTY);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (str === "") {
|
|
176
|
+
writeStringRaw(str);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const tokenIndex = TOKEN_MAP[str];
|
|
180
|
+
if (tokenIndex) {
|
|
181
|
+
if (typeof tokenIndex.dict === "number") {
|
|
182
|
+
pushByte(TAGS.DICTIONARY_0 + tokenIndex.dict);
|
|
183
|
+
}
|
|
184
|
+
pushByte(tokenIndex.index);
|
|
185
|
+
} else if (isNibble(str)) {
|
|
186
|
+
writePackedBytes(str, "nibble");
|
|
187
|
+
} else if (isHex(str)) {
|
|
188
|
+
writePackedBytes(str, "hex");
|
|
189
|
+
} else {
|
|
190
|
+
const decodedJid = (0, import_jid_utils.jidDecode)(str);
|
|
191
|
+
if (decodedJid) {
|
|
192
|
+
writeJid(decodedJid);
|
|
193
|
+
} else {
|
|
194
|
+
writeStringRaw(str);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const writeListStart = (listSize) => {
|
|
199
|
+
if (listSize === 0) {
|
|
200
|
+
pushByte(TAGS.LIST_EMPTY);
|
|
201
|
+
} else if (listSize < 256) {
|
|
202
|
+
pushBytes([TAGS.LIST_8, listSize]);
|
|
203
|
+
} else {
|
|
204
|
+
pushByte(TAGS.LIST_16);
|
|
205
|
+
pushInt16(listSize);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
if (!tag) {
|
|
209
|
+
throw new Error("Invalid node: tag cannot be undefined");
|
|
210
|
+
}
|
|
211
|
+
const validAttributes = Object.keys(attrs || {}).filter((k) => typeof attrs[k] !== "undefined" && attrs[k] !== null);
|
|
212
|
+
writeListStart(2 * validAttributes.length + 1 + (typeof content !== "undefined" ? 1 : 0));
|
|
213
|
+
writeString(tag);
|
|
214
|
+
for (const key of validAttributes) {
|
|
215
|
+
if (typeof attrs[key] === "string") {
|
|
216
|
+
writeString(key);
|
|
217
|
+
writeString(attrs[key]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (typeof content === "string") {
|
|
221
|
+
writeString(content);
|
|
222
|
+
} else if (Buffer.isBuffer(content) || content instanceof Uint8Array) {
|
|
223
|
+
writeByteLength(content.length);
|
|
224
|
+
pushBytes(content);
|
|
225
|
+
} else if (Array.isArray(content)) {
|
|
226
|
+
const validContent = content.filter((item) => item && (item.tag || Buffer.isBuffer(item) || item instanceof Uint8Array || typeof item === "string"));
|
|
227
|
+
writeListStart(validContent.length);
|
|
228
|
+
for (const item of validContent) {
|
|
229
|
+
encodeBinaryNodeInner(item, opts, buffer);
|
|
230
|
+
}
|
|
231
|
+
} else if (typeof content === "undefined") {
|
|
232
|
+
} else {
|
|
233
|
+
throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`);
|
|
234
|
+
}
|
|
235
|
+
return buffer;
|
|
236
|
+
};
|
|
237
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
238
|
+
0 && (module.exports = {
|
|
239
|
+
encodeBinaryNode
|
|
240
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export function binaryNodeToString(node: any, i?: number): any;
|
|
2
|
+
export function getBinaryNodeChildren(node: any, childTag: any): any;
|
|
3
|
+
export function getBinaryNodeChild(node: any, childTag: any): any;
|
|
4
|
+
export function getAllBinaryNodeChildren({ content }: {
|
|
5
|
+
content: any;
|
|
6
|
+
}): any[];
|
|
7
|
+
export function getBinaryNodeChildBuffer(node: any, childTag: any): any;
|
|
8
|
+
export function getBinaryNodeChildString(node: any, childTag: any): any;
|
|
9
|
+
export function getBinaryNodeChildUInt(node: any, childTag: any, length: any): number | undefined;
|
|
10
|
+
export function assertNodeErrorFree(node: any): void;
|
|
11
|
+
export function reduceBinaryNodeToDictionary(node: any, tag: any): any;
|
|
12
|
+
export function getBinaryNodeMessages({ content }: {
|
|
13
|
+
content: any;
|
|
14
|
+
}): {
|
|
15
|
+
[k: string]: any;
|
|
16
|
+
}[];
|
|
17
|
+
export function getBizBinaryNode(message: any): {
|
|
18
|
+
tag: string;
|
|
19
|
+
attrs: {
|
|
20
|
+
actual_actors: string;
|
|
21
|
+
host_storage: string;
|
|
22
|
+
privacy_mode_ts: string;
|
|
23
|
+
};
|
|
24
|
+
content: ({
|
|
25
|
+
tag: string;
|
|
26
|
+
attrs: {
|
|
27
|
+
decision_id: any;
|
|
28
|
+
source_type: string;
|
|
29
|
+
};
|
|
30
|
+
content: {
|
|
31
|
+
tag: string;
|
|
32
|
+
attrs: {
|
|
33
|
+
value: string;
|
|
34
|
+
};
|
|
35
|
+
}[];
|
|
36
|
+
} | {
|
|
37
|
+
tag: string;
|
|
38
|
+
attrs: {
|
|
39
|
+
type: string;
|
|
40
|
+
v: string;
|
|
41
|
+
};
|
|
42
|
+
content: {
|
|
43
|
+
tag: string;
|
|
44
|
+
attrs: {
|
|
45
|
+
name: any;
|
|
46
|
+
v?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
v: string;
|
|
49
|
+
name: any;
|
|
50
|
+
};
|
|
51
|
+
}[];
|
|
52
|
+
})[];
|
|
53
|
+
} | {
|
|
54
|
+
tag: string;
|
|
55
|
+
attrs: {
|
|
56
|
+
actual_actors: string;
|
|
57
|
+
host_storage: string;
|
|
58
|
+
privacy_mode_ts: string;
|
|
59
|
+
};
|
|
60
|
+
content: ({
|
|
61
|
+
tag: string;
|
|
62
|
+
attrs: {
|
|
63
|
+
decision_id: any;
|
|
64
|
+
source_type: string;
|
|
65
|
+
};
|
|
66
|
+
content: {
|
|
67
|
+
tag: string;
|
|
68
|
+
attrs: {
|
|
69
|
+
value: string;
|
|
70
|
+
};
|
|
71
|
+
}[];
|
|
72
|
+
} | {
|
|
73
|
+
tag: string;
|
|
74
|
+
attrs: {
|
|
75
|
+
v: string;
|
|
76
|
+
type: string;
|
|
77
|
+
};
|
|
78
|
+
})[];
|
|
79
|
+
};
|