@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,135 @@
|
|
|
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 use_multi_file_auth_state_exports = {};
|
|
19
|
+
__export(use_multi_file_auth_state_exports, {
|
|
20
|
+
useMultiFileAuthState: () => useMultiFileAuthState
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(use_multi_file_auth_state_exports);
|
|
23
|
+
var import_promises = require("node:fs/promises");
|
|
24
|
+
var import_node_path = require("node:path");
|
|
25
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
26
|
+
var import_Addon = require("../Addon/index.js");
|
|
27
|
+
var import_auth_utils = require("./auth-utils.js");
|
|
28
|
+
var import_generics = require("./generics.js");
|
|
29
|
+
const WRITE_BATCH = 32;
|
|
30
|
+
const locks = /* @__PURE__ */ new Map();
|
|
31
|
+
const noop = () => {
|
|
32
|
+
};
|
|
33
|
+
const withLock = async (path, fn) => {
|
|
34
|
+
let entry = locks.get(path);
|
|
35
|
+
if (!entry)
|
|
36
|
+
locks.set(path, entry = { mutex: (0, import_Addon.createMutex)(), refs: 0 });
|
|
37
|
+
entry.refs++;
|
|
38
|
+
try {
|
|
39
|
+
return await entry.mutex.runExclusive(fn);
|
|
40
|
+
} finally {
|
|
41
|
+
if (!--entry.refs)
|
|
42
|
+
locks.delete(path);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const writeAtomic = async (path, json, durable) => {
|
|
46
|
+
const tmp = path + ".tmp";
|
|
47
|
+
const fh = await (0, import_promises.open)(tmp, "w");
|
|
48
|
+
try {
|
|
49
|
+
await fh.writeFile(json);
|
|
50
|
+
if (durable)
|
|
51
|
+
await fh.datasync();
|
|
52
|
+
} finally {
|
|
53
|
+
await fh.close();
|
|
54
|
+
}
|
|
55
|
+
await (0, import_promises.rename)(tmp, path);
|
|
56
|
+
};
|
|
57
|
+
const readJson = (path, quarantine) => withLock(path, async () => {
|
|
58
|
+
let raw;
|
|
59
|
+
try {
|
|
60
|
+
raw = await (0, import_promises.readFile)(path, "utf-8");
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (err.code === "ENOENT")
|
|
63
|
+
return null;
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(raw, import_generics.BufferJSON.reviver);
|
|
68
|
+
} catch {
|
|
69
|
+
if (quarantine)
|
|
70
|
+
await (0, import_promises.rename)(path, path + ".corrupt").catch(noop);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const fixFileName = (file) => file.replace(/\//g, "__").replace(/:/g, "-");
|
|
75
|
+
const useMultiFileAuthState = async (folder) => {
|
|
76
|
+
try {
|
|
77
|
+
await (0, import_promises.mkdir)(folder, { recursive: true });
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err.code === "EEXIST" || err.code === "ENOTDIR")
|
|
80
|
+
throw new Error(`Found something that is not a directory at ${folder}, either delete it or specify a different location`);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
const pathOf = (file) => (0, import_node_path.join)(folder, fixFileName(file));
|
|
84
|
+
const credsPath = pathOf("creds.json");
|
|
85
|
+
const creds = await readJson(credsPath, true) ?? (0, import_auth_utils.initAuthCreds)();
|
|
86
|
+
let lastCreds;
|
|
87
|
+
return {
|
|
88
|
+
state: {
|
|
89
|
+
creds,
|
|
90
|
+
keys: {
|
|
91
|
+
get: async (type, ids) => {
|
|
92
|
+
const data = {};
|
|
93
|
+
await Promise.all(ids.map(async (id) => {
|
|
94
|
+
let value = await readJson(pathOf(`${type}-${id}.json`));
|
|
95
|
+
if (type === "app-state-sync-key" && value) {
|
|
96
|
+
value = import_WAProto.proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
97
|
+
}
|
|
98
|
+
data[id] = value;
|
|
99
|
+
}));
|
|
100
|
+
return data;
|
|
101
|
+
},
|
|
102
|
+
set: async (data) => {
|
|
103
|
+
const tasks = [];
|
|
104
|
+
for (const category in data) {
|
|
105
|
+
const items = data[category];
|
|
106
|
+
for (const id in items) {
|
|
107
|
+
const value = items[id];
|
|
108
|
+
const path = pathOf(`${category}-${id}.json`);
|
|
109
|
+
tasks.push(value ? () => withLock(path, () => writeAtomic(path, JSON.stringify(value, import_generics.BufferJSON.replacer), false)) : () => withLock(path, () => (0, import_promises.unlink)(path).catch((err) => {
|
|
110
|
+
if (err.code !== "ENOENT")
|
|
111
|
+
throw err;
|
|
112
|
+
})));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (let i = 0; i < tasks.length; i += WRITE_BATCH) {
|
|
116
|
+
await Promise.all(tasks.slice(i, i + WRITE_BATCH).map((run) => run()));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
saveCreds: () => {
|
|
122
|
+
const json = JSON.stringify(creds, import_generics.BufferJSON.replacer);
|
|
123
|
+
if (json === lastCreds)
|
|
124
|
+
return Promise.resolve();
|
|
125
|
+
return withLock(credsPath, async () => {
|
|
126
|
+
await writeAtomic(credsPath, json, true);
|
|
127
|
+
lastCreds = json;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
useMultiFileAuthState
|
|
135
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
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 use_single_file_auth_state_exports = {};
|
|
19
|
+
__export(use_single_file_auth_state_exports, {
|
|
20
|
+
useSingleFileAuthState: () => useSingleFileAuthState
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(use_single_file_auth_state_exports);
|
|
23
|
+
var import_promises = require("node:fs/promises");
|
|
24
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
25
|
+
var import_Addon = require("../Addon/index.js");
|
|
26
|
+
var import_auth_utils = require("./auth-utils.js");
|
|
27
|
+
var import_generics = require("./generics.js");
|
|
28
|
+
const FLUSH_DELAY_MS = 3e3;
|
|
29
|
+
const files = /* @__PURE__ */ new Map();
|
|
30
|
+
const useSingleFileAuthState = async (fileName) => {
|
|
31
|
+
let shared = files.get(fileName);
|
|
32
|
+
if (!shared)
|
|
33
|
+
files.set(fileName, shared = { mutex: (0, import_Addon.createMutex)(), flush: null });
|
|
34
|
+
const { mutex } = shared;
|
|
35
|
+
await shared.flush?.();
|
|
36
|
+
const tempFile = fileName + ".temp";
|
|
37
|
+
const store = /* @__PURE__ */ Object.create(null);
|
|
38
|
+
let ver = 0, saved = 0, timer = null;
|
|
39
|
+
await mutex.runExclusive(async () => {
|
|
40
|
+
try {
|
|
41
|
+
Object.assign(store, JSON.parse(await (0, import_promises.readFile)(fileName, "utf-8"), import_generics.BufferJSON.reviver));
|
|
42
|
+
} catch (err) {
|
|
43
|
+
if (err.code === "EISDIR")
|
|
44
|
+
throw new Error(`found something that is not a file at ${fileName}, either delete it or specify a different location`);
|
|
45
|
+
if (err.code !== "ENOENT")
|
|
46
|
+
await (0, import_promises.rename)(fileName, fileName + ".corrupt").catch(() => {
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const flush = () => {
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
timer = null;
|
|
53
|
+
return mutex.runExclusive(async () => {
|
|
54
|
+
if (ver === saved)
|
|
55
|
+
return;
|
|
56
|
+
const v = ver;
|
|
57
|
+
try {
|
|
58
|
+
const fh = await (0, import_promises.open)(tempFile, "w");
|
|
59
|
+
try {
|
|
60
|
+
await fh.writeFile(JSON.stringify(store, import_generics.BufferJSON.replacer));
|
|
61
|
+
await fh.datasync();
|
|
62
|
+
} finally {
|
|
63
|
+
await fh.close();
|
|
64
|
+
}
|
|
65
|
+
await (0, import_promises.rename)(tempFile, fileName);
|
|
66
|
+
saved = v;
|
|
67
|
+
} catch {
|
|
68
|
+
schedule();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const schedule = () => {
|
|
73
|
+
timer ?? (timer = setTimeout(flush, FLUSH_DELAY_MS));
|
|
74
|
+
};
|
|
75
|
+
shared.flush = flush;
|
|
76
|
+
const creds = store.creds ?? (store.creds = (0, import_auth_utils.initAuthCreds)());
|
|
77
|
+
return {
|
|
78
|
+
state: {
|
|
79
|
+
creds,
|
|
80
|
+
keys: {
|
|
81
|
+
get: (type, ids) => {
|
|
82
|
+
const data = {};
|
|
83
|
+
for (const id of ids) {
|
|
84
|
+
const value = store[type + id];
|
|
85
|
+
data[id] = value && type === "app-state-sync-key" ? import_WAProto.proto.Message.AppStateSyncKeyData.fromObject(value) : value;
|
|
86
|
+
}
|
|
87
|
+
return data;
|
|
88
|
+
},
|
|
89
|
+
set: (data) => {
|
|
90
|
+
for (const type in data) {
|
|
91
|
+
const items = data[type];
|
|
92
|
+
for (const id in items) {
|
|
93
|
+
const value = items[id];
|
|
94
|
+
if (value)
|
|
95
|
+
store[type + id] = value;
|
|
96
|
+
else
|
|
97
|
+
delete store[type + id];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
ver++;
|
|
101
|
+
schedule();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
saveCreds: () => {
|
|
106
|
+
ver++;
|
|
107
|
+
return flush();
|
|
108
|
+
},
|
|
109
|
+
flush
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
useSingleFileAuthState
|
|
115
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
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 use_sqlite_auth_state_exports = {};
|
|
29
|
+
__export(use_sqlite_auth_state_exports, {
|
|
30
|
+
useSqliteAuthState: () => useSqliteAuthState
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(use_sqlite_auth_state_exports);
|
|
33
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
34
|
+
var import_auth_utils = require("./auth-utils.js");
|
|
35
|
+
var import_generics = require("./generics.js");
|
|
36
|
+
const CREDS_KEY = "__creds__";
|
|
37
|
+
const SCHEMA = `
|
|
38
|
+
PRAGMA busy_timeout = 5000;
|
|
39
|
+
PRAGMA journal_mode = WAL;
|
|
40
|
+
PRAGMA synchronous = NORMAL;
|
|
41
|
+
CREATE TABLE IF NOT EXISTS creds (
|
|
42
|
+
key TEXT PRIMARY KEY,
|
|
43
|
+
value TEXT NOT NULL
|
|
44
|
+
) WITHOUT ROWID;
|
|
45
|
+
CREATE TABLE IF NOT EXISTS signal_keys (
|
|
46
|
+
type TEXT NOT NULL,
|
|
47
|
+
id TEXT NOT NULL,
|
|
48
|
+
value TEXT NOT NULL,
|
|
49
|
+
PRIMARY KEY (type, id)
|
|
50
|
+
) WITHOUT ROWID;
|
|
51
|
+
DROP INDEX IF EXISTS signal_keys_type_idx;
|
|
52
|
+
`;
|
|
53
|
+
const loadDriver = async () => {
|
|
54
|
+
if (process.versions.bun)
|
|
55
|
+
return (await import("bun:sqlite")).Database;
|
|
56
|
+
try {
|
|
57
|
+
return (await import("node:sqlite")).DatabaseSync;
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const mod = await import("better-sqlite3");
|
|
62
|
+
return mod.default ?? mod;
|
|
63
|
+
} catch (cause) {
|
|
64
|
+
throw new Error('No SQLite driver found. Use Bun, Node >= 22.13, or install "better-sqlite3".', { cause });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
async function useSqliteAuthState(dbPath, ownedDatabase) {
|
|
68
|
+
const owned = !ownedDatabase;
|
|
69
|
+
let db = ownedDatabase;
|
|
70
|
+
if (owned) {
|
|
71
|
+
const Database = await loadDriver();
|
|
72
|
+
db = new Database(dbPath);
|
|
73
|
+
}
|
|
74
|
+
db.exec(SCHEMA);
|
|
75
|
+
const acts = {
|
|
76
|
+
credsGet: db.prepare("SELECT value FROM creds WHERE key = ?"),
|
|
77
|
+
credsSet: db.prepare("INSERT OR REPLACE INTO creds (key, value) VALUES (?, ?)"),
|
|
78
|
+
keyGet: db.prepare("SELECT value FROM signal_keys WHERE type = ? AND id = ?"),
|
|
79
|
+
keySet: db.prepare("INSERT OR REPLACE INTO signal_keys (type, id, value) VALUES (?, ?, ?)"),
|
|
80
|
+
keyDel: db.prepare("DELETE FROM signal_keys WHERE type = ? AND id = ?"),
|
|
81
|
+
begin: db.prepare("BEGIN IMMEDIATE"),
|
|
82
|
+
commit: db.prepare("COMMIT"),
|
|
83
|
+
rollback: db.prepare("ROLLBACK")
|
|
84
|
+
};
|
|
85
|
+
const row = acts.credsGet.get(CREDS_KEY);
|
|
86
|
+
const creds = row ? JSON.parse(row.value, import_generics.BufferJSON.reviver) : (0, import_auth_utils.initAuthCreds)();
|
|
87
|
+
let lastCreds = row?.value;
|
|
88
|
+
return {
|
|
89
|
+
state: {
|
|
90
|
+
creds,
|
|
91
|
+
keys: {
|
|
92
|
+
get: (type, ids) => {
|
|
93
|
+
const data = {};
|
|
94
|
+
for (const id of ids) {
|
|
95
|
+
const r = acts.keyGet.get(type, id);
|
|
96
|
+
if (!r)
|
|
97
|
+
continue;
|
|
98
|
+
const value = JSON.parse(r.value, import_generics.BufferJSON.reviver);
|
|
99
|
+
data[id] = type === "app-state-sync-key" ? import_WAProto.proto.Message.AppStateSyncKeyData.fromObject(value) : value;
|
|
100
|
+
}
|
|
101
|
+
return data;
|
|
102
|
+
},
|
|
103
|
+
set: (data) => {
|
|
104
|
+
acts.begin.run();
|
|
105
|
+
try {
|
|
106
|
+
for (const type in data) {
|
|
107
|
+
const items = data[type];
|
|
108
|
+
for (const id in items) {
|
|
109
|
+
const value = items[id];
|
|
110
|
+
if (value)
|
|
111
|
+
acts.keySet.run(type, id, JSON.stringify(value, import_generics.BufferJSON.replacer));
|
|
112
|
+
else
|
|
113
|
+
acts.keyDel.run(type, id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
acts.commit.run();
|
|
117
|
+
} catch (err) {
|
|
118
|
+
try {
|
|
119
|
+
acts.rollback.run();
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
saveCreds: () => {
|
|
128
|
+
const json = JSON.stringify(creds, import_generics.BufferJSON.replacer);
|
|
129
|
+
if (json === lastCreds)
|
|
130
|
+
return;
|
|
131
|
+
acts.credsSet.run(CREDS_KEY, json);
|
|
132
|
+
lastCreds = json;
|
|
133
|
+
},
|
|
134
|
+
close: () => owned && db.close()
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
+
0 && (module.exports = {
|
|
139
|
+
useSqliteAuthState
|
|
140
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function generateLoginNode(userJid: any, config: any): proto.ClientPayload;
|
|
2
|
+
export function generateRegistrationNode({ registrationId, signedPreKey, signedIdentityKey }: {
|
|
3
|
+
registrationId: any;
|
|
4
|
+
signedPreKey: any;
|
|
5
|
+
signedIdentityKey: any;
|
|
6
|
+
}, config: any): proto.ClientPayload;
|
|
7
|
+
export function configureSuccessfulPairing(stanza: any, { advSecretKey, signedIdentityKey, signalIdentities }: {
|
|
8
|
+
advSecretKey: any;
|
|
9
|
+
signedIdentityKey: any;
|
|
10
|
+
signalIdentities: any;
|
|
11
|
+
}): {
|
|
12
|
+
creds: {
|
|
13
|
+
account: proto.ADVSignedDeviceIdentity & proto.ADVSignedDeviceIdentity.$Properties;
|
|
14
|
+
me: {
|
|
15
|
+
id: any;
|
|
16
|
+
name: any;
|
|
17
|
+
lid: any;
|
|
18
|
+
};
|
|
19
|
+
signalIdentities: any[];
|
|
20
|
+
platform: any;
|
|
21
|
+
registered: boolean;
|
|
22
|
+
};
|
|
23
|
+
reply: {
|
|
24
|
+
tag: string;
|
|
25
|
+
attrs: {
|
|
26
|
+
to: string;
|
|
27
|
+
type: string;
|
|
28
|
+
id: any;
|
|
29
|
+
};
|
|
30
|
+
content: {
|
|
31
|
+
tag: string;
|
|
32
|
+
attrs: {};
|
|
33
|
+
content: {
|
|
34
|
+
tag: string;
|
|
35
|
+
attrs: {
|
|
36
|
+
'key-index': string;
|
|
37
|
+
};
|
|
38
|
+
content: Uint8Array<ArrayBufferLike>;
|
|
39
|
+
}[];
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export function encodeSignedDeviceIdentity(account: any, includeSignatureKey: any): Uint8Array<ArrayBufferLike>;
|
|
44
|
+
import { proto } from '../../WAProto/index.js';
|
|
@@ -0,0 +1,229 @@
|
|
|
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 validate_connection_exports = {};
|
|
19
|
+
__export(validate_connection_exports, {
|
|
20
|
+
configureSuccessfulPairing: () => configureSuccessfulPairing,
|
|
21
|
+
encodeSignedDeviceIdentity: () => encodeSignedDeviceIdentity,
|
|
22
|
+
generateLoginNode: () => generateLoginNode,
|
|
23
|
+
generateRegistrationNode: () => generateRegistrationNode
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(validate_connection_exports);
|
|
26
|
+
var import_node_crypto = require("node:crypto");
|
|
27
|
+
var import_WAProto = require("../../WAProto/index.js");
|
|
28
|
+
var import_Addon = require("../Addon/index.js");
|
|
29
|
+
var import_Defaults = require("../Defaults/index.js");
|
|
30
|
+
var import_WABinary = require("../WABinary/index.js");
|
|
31
|
+
var import_crypto = require("./crypto.js");
|
|
32
|
+
var import_generics = require("./generics.js");
|
|
33
|
+
var import_signal = require("./signal.js");
|
|
34
|
+
const getUserAgent = (config) => {
|
|
35
|
+
return {
|
|
36
|
+
appVersion: {
|
|
37
|
+
primary: config.version[0],
|
|
38
|
+
secondary: config.version[1],
|
|
39
|
+
tertiary: config.version[2]
|
|
40
|
+
},
|
|
41
|
+
platform: config.browser[1].toLocaleLowerCase().includes("android") ? import_WAProto.proto.ClientPayload.UserAgent.Platform.ANDROID : import_WAProto.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
42
|
+
releaseChannel: import_WAProto.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
43
|
+
osVersion: "0.1",
|
|
44
|
+
device: "Desktop",
|
|
45
|
+
osBuildNumber: "0.1",
|
|
46
|
+
localeLanguageIso6391: "en",
|
|
47
|
+
mnc: "000",
|
|
48
|
+
mcc: "000",
|
|
49
|
+
localeCountryIso31661Alpha2: config.countryCode
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const PLATFORM_MAP = {
|
|
53
|
+
"Mac OS": import_WAProto.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
54
|
+
Windows: import_WAProto.proto.ClientPayload.WebInfo.WebSubPlatform.WIN_HYBRID
|
|
55
|
+
};
|
|
56
|
+
const getWebInfo = (config) => {
|
|
57
|
+
let webSubPlatform = import_WAProto.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
58
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === "Desktop") {
|
|
59
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
60
|
+
}
|
|
61
|
+
return { webSubPlatform };
|
|
62
|
+
};
|
|
63
|
+
const getClientPayload = (config) => {
|
|
64
|
+
const payload = {
|
|
65
|
+
connectType: import_WAProto.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
66
|
+
connectReason: import_WAProto.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
67
|
+
userAgent: getUserAgent(config)
|
|
68
|
+
};
|
|
69
|
+
if (!config.browser[1].toLocaleLowerCase().includes("android")) {
|
|
70
|
+
payload.webInfo = getWebInfo(config);
|
|
71
|
+
}
|
|
72
|
+
if (config.pushName) {
|
|
73
|
+
payload.pushName = config.pushName;
|
|
74
|
+
}
|
|
75
|
+
return payload;
|
|
76
|
+
};
|
|
77
|
+
const generateLoginNode = (userJid, config) => {
|
|
78
|
+
const { user, device } = (0, import_WABinary.jidDecode)(userJid);
|
|
79
|
+
const payload = {
|
|
80
|
+
...getClientPayload(config),
|
|
81
|
+
passive: true,
|
|
82
|
+
pull: true,
|
|
83
|
+
username: +user,
|
|
84
|
+
device,
|
|
85
|
+
// TODO: investigate (hard set as false atm)
|
|
86
|
+
lidDbMigrated: false
|
|
87
|
+
};
|
|
88
|
+
return import_WAProto.proto.ClientPayload.fromObject(payload);
|
|
89
|
+
};
|
|
90
|
+
const getPlatformType = (platform) => {
|
|
91
|
+
const platformType = platform.toUpperCase();
|
|
92
|
+
if (platformType === "ANDROID") {
|
|
93
|
+
return import_WAProto.proto.DeviceProps.PlatformType.ANDROID_PHONE;
|
|
94
|
+
}
|
|
95
|
+
return import_WAProto.proto.DeviceProps.PlatformType[platformType] || import_WAProto.proto.DeviceProps.PlatformType.CHROME;
|
|
96
|
+
};
|
|
97
|
+
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
98
|
+
const appVersionBuf = (0, import_node_crypto.createHash)("md5").update(config.version.join(".")).digest();
|
|
99
|
+
const companion = {
|
|
100
|
+
os: config.browser[0],
|
|
101
|
+
platformType: getPlatformType(config.browser[1]),
|
|
102
|
+
requireFullSync: config.syncFullHistory,
|
|
103
|
+
historySyncConfig: {
|
|
104
|
+
storageQuotaMb: 10240,
|
|
105
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
106
|
+
recentSyncDaysLimit: void 0,
|
|
107
|
+
supportCallLogHistory: false,
|
|
108
|
+
supportBotUserAgentChatHistory: true,
|
|
109
|
+
supportCagReactionsAndPolls: true,
|
|
110
|
+
supportBizHostedMsg: true,
|
|
111
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
112
|
+
supportHostedGroupMsg: true,
|
|
113
|
+
supportFbidBotChatHistory: true,
|
|
114
|
+
supportAddOnHistorySyncMigration: void 0,
|
|
115
|
+
supportMessageAssociation: true,
|
|
116
|
+
supportGroupHistory: false,
|
|
117
|
+
onDemandReady: void 0,
|
|
118
|
+
supportGuestChat: void 0
|
|
119
|
+
},
|
|
120
|
+
version: {
|
|
121
|
+
primary: 10,
|
|
122
|
+
secondary: 15,
|
|
123
|
+
tertiary: 7
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const companionProto = import_WAProto.proto.DeviceProps.encode(companion).finish();
|
|
127
|
+
const registerPayload = {
|
|
128
|
+
...getClientPayload(config),
|
|
129
|
+
passive: false,
|
|
130
|
+
pull: false,
|
|
131
|
+
devicePairingData: {
|
|
132
|
+
buildHash: appVersionBuf,
|
|
133
|
+
deviceProps: companionProto,
|
|
134
|
+
eRegid: (0, import_generics.encodeBigEndian)(registrationId),
|
|
135
|
+
eKeytype: import_Defaults.KEY_BUNDLE_TYPE,
|
|
136
|
+
eIdent: signedIdentityKey.public,
|
|
137
|
+
eSkeyId: (0, import_generics.encodeBigEndian)(signedPreKey.keyId, 3),
|
|
138
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
139
|
+
eSkeySig: signedPreKey.signature
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return import_WAProto.proto.ClientPayload.fromObject(registerPayload);
|
|
143
|
+
};
|
|
144
|
+
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
145
|
+
const msgId = stanza.attrs.id;
|
|
146
|
+
const pairSuccessNode = (0, import_WABinary.getBinaryNodeChild)(stanza, "pair-success");
|
|
147
|
+
const deviceIdentityNode = (0, import_WABinary.getBinaryNodeChild)(pairSuccessNode, "device-identity");
|
|
148
|
+
const platformNode = (0, import_WABinary.getBinaryNodeChild)(pairSuccessNode, "platform");
|
|
149
|
+
const deviceNode = (0, import_WABinary.getBinaryNodeChild)(pairSuccessNode, "device");
|
|
150
|
+
const businessNode = (0, import_WABinary.getBinaryNodeChild)(pairSuccessNode, "biz");
|
|
151
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
152
|
+
throw new import_Addon.HttpError("Missing device-identity or device in pair success node", { data: stanza });
|
|
153
|
+
}
|
|
154
|
+
const bizName = businessNode?.attrs.name;
|
|
155
|
+
const jid = deviceNode.attrs.jid;
|
|
156
|
+
const lid = deviceNode.attrs.lid;
|
|
157
|
+
const { details, hmac, accountType } = import_WAProto.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
158
|
+
let hmacPrefix = Buffer.from([]);
|
|
159
|
+
if (accountType !== void 0 && accountType === import_WAProto.proto.ADVEncryptionType.HOSTED) {
|
|
160
|
+
hmacPrefix = import_Defaults.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX;
|
|
161
|
+
}
|
|
162
|
+
const advSign = (0, import_crypto.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, "base64"));
|
|
163
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
164
|
+
throw new import_Addon.HttpError("Invalid account signature");
|
|
165
|
+
}
|
|
166
|
+
const account = import_WAProto.proto.ADVSignedDeviceIdentity.decode(details);
|
|
167
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
168
|
+
const deviceIdentity = import_WAProto.proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
169
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === import_WAProto.proto.ADVEncryptionType.HOSTED ? import_Defaults.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX : import_Defaults.WA_ADV_ACCOUNT_SIG_PREFIX;
|
|
170
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
171
|
+
if (!import_crypto.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
172
|
+
throw new import_Addon.HttpError("Failed to verify account signature");
|
|
173
|
+
}
|
|
174
|
+
const deviceMsg = Buffer.concat([
|
|
175
|
+
import_Defaults.WA_ADV_DEVICE_SIG_PREFIX,
|
|
176
|
+
deviceDetails,
|
|
177
|
+
signedIdentityKey.public,
|
|
178
|
+
accountSignatureKey
|
|
179
|
+
]);
|
|
180
|
+
account.deviceSignature = import_crypto.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
181
|
+
const identity = (0, import_signal.createSignalIdentity)(lid, accountSignatureKey);
|
|
182
|
+
const accountEnc = encodeSignedDeviceIdentity(account, false);
|
|
183
|
+
const reply = {
|
|
184
|
+
tag: "iq",
|
|
185
|
+
attrs: {
|
|
186
|
+
to: import_WABinary.S_WHATSAPP_NET,
|
|
187
|
+
type: "result",
|
|
188
|
+
id: msgId
|
|
189
|
+
},
|
|
190
|
+
content: [
|
|
191
|
+
{
|
|
192
|
+
tag: "pair-device-sign",
|
|
193
|
+
attrs: {},
|
|
194
|
+
content: [
|
|
195
|
+
{
|
|
196
|
+
tag: "device-identity",
|
|
197
|
+
attrs: { "key-index": deviceIdentity.keyIndex.toString() },
|
|
198
|
+
content: accountEnc
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
};
|
|
204
|
+
const authUpdate = {
|
|
205
|
+
account,
|
|
206
|
+
me: { id: jid, name: bizName, lid },
|
|
207
|
+
signalIdentities: [...signalIdentities || [], identity],
|
|
208
|
+
platform: platformNode?.attrs.name,
|
|
209
|
+
registered: true
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
creds: authUpdate,
|
|
213
|
+
reply
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
217
|
+
account = { ...account };
|
|
218
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
219
|
+
account.accountSignatureKey = null;
|
|
220
|
+
}
|
|
221
|
+
return import_WAProto.proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
222
|
+
};
|
|
223
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
224
|
+
0 && (module.exports = {
|
|
225
|
+
configureSuccessfulPairing,
|
|
226
|
+
encodeSignedDeviceIdentity,
|
|
227
|
+
generateLoginNode,
|
|
228
|
+
generateRegistrationNode
|
|
229
|
+
});
|