@eduh_dev021/baileys 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +495 -2
- package/WAProto/index.d.ts +22220 -0
- package/WAProto/index.js +5 -0
- package/cjs/WAProto/index.d.ts +22220 -0
- package/cjs/WAProto/index.js +60125 -0
- package/cjs/engine-requirements.js +12 -0
- package/cjs/lib/Addon/http-error.d.ts +18 -0
- package/cjs/lib/Addon/http-error.js +66 -0
- package/cjs/lib/Addon/index.d.ts +3 -0
- package/cjs/lib/Addon/index.js +50 -0
- package/cjs/lib/Addon/keyed-db.d.ts +14 -0
- package/cjs/lib/Addon/keyed-db.js +264 -0
- package/cjs/lib/Addon/link-preview.d.ts +15 -0
- package/cjs/lib/Addon/link-preview.js +104 -0
- package/cjs/lib/Defaults/index.d.ts +184 -0
- package/cjs/lib/Defaults/index.js +292 -0
- package/cjs/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/cjs/lib/Signal/Group/ciphertext-message.js +37 -0
- package/cjs/lib/Signal/Group/group-cipher.d.ts +10 -0
- package/cjs/lib/Signal/Group/group-cipher.js +105 -0
- package/cjs/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/cjs/lib/Signal/Group/group-session-builder.js +65 -0
- package/cjs/lib/Signal/Group/index.d.ts +11 -0
- package/cjs/lib/Signal/Group/index.js +67 -0
- package/cjs/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/cjs/lib/Signal/Group/keyhelper.js +47 -0
- package/cjs/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/cjs/lib/Signal/Group/sender-chain-key.js +51 -0
- package/cjs/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/cjs/lib/Signal/Group/sender-key-distribution-message.js +80 -0
- package/cjs/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/cjs/lib/Signal/Group/sender-key-message.js +87 -0
- package/cjs/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/cjs/lib/Signal/Group/sender-key-name.js +73 -0
- package/cjs/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/cjs/lib/Signal/Group/sender-key-record.js +66 -0
- package/cjs/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/cjs/lib/Signal/Group/sender-key-state.js +106 -0
- package/cjs/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/cjs/lib/Signal/Group/sender-message-key.js +51 -0
- package/cjs/lib/Signal/libsignal.d.ts +54 -0
- package/cjs/lib/Signal/libsignal.js +421 -0
- package/cjs/lib/Signal/lid-mapping.d.ts +20 -0
- package/cjs/lib/Signal/lid-mapping.js +292 -0
- package/cjs/lib/Socket/Client/index.d.ts +2 -0
- package/cjs/lib/Socket/Client/index.js +23 -0
- package/cjs/lib/Socket/Client/types.d.ts +5 -0
- package/cjs/lib/Socket/Client/types.js +36 -0
- package/cjs/lib/Socket/Client/websocket.d.ts +12 -0
- package/cjs/lib/Socket/Client/websocket.js +143 -0
- package/cjs/lib/Socket/business.d.ts +387 -0
- package/cjs/lib/Socket/business.js +402 -0
- package/cjs/lib/Socket/chats.d.ts +144 -0
- package/cjs/lib/Socket/chats.js +1118 -0
- package/cjs/lib/Socket/communities.d.ts +554 -0
- package/cjs/lib/Socket/communities.js +456 -0
- package/cjs/lib/Socket/groups.d.ts +286 -0
- package/cjs/lib/Socket/groups.js +366 -0
- package/cjs/lib/Socket/index.d.ts +522 -0
- package/cjs/lib/Socket/index.js +32 -0
- package/cjs/lib/Socket/messages-recv.d.ts +326 -0
- package/cjs/lib/Socket/messages-recv.js +1670 -0
- package/cjs/lib/Socket/messages-send.d.ts +321 -0
- package/cjs/lib/Socket/messages-send.js +1252 -0
- package/cjs/lib/Socket/mex.d.ts +1 -0
- package/cjs/lib/Socket/mex.js +65 -0
- package/cjs/lib/Socket/newsletter.d.ts +283 -0
- package/cjs/lib/Socket/newsletter.js +243 -0
- package/cjs/lib/Socket/socket.d.ts +61 -0
- package/cjs/lib/Socket/socket.js +908 -0
- package/cjs/lib/Store/index.d.ts +3 -0
- package/cjs/lib/Store/index.js +25 -0
- package/cjs/lib/Store/make-in-memory-store.d.ts +63 -0
- package/cjs/lib/Store/make-in-memory-store.js +431 -0
- package/cjs/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/cjs/lib/Store/make-ordered-dictionary.js +101 -0
- package/cjs/lib/Store/object-repository.d.ts +10 -0
- package/cjs/lib/Store/object-repository.js +49 -0
- package/cjs/lib/Transport/crypto.d.ts +6 -0
- package/cjs/lib/Transport/crypto.js +107 -0
- package/cjs/lib/Transport/curve.d.ts +8 -0
- package/cjs/lib/Transport/curve.js +94 -0
- package/cjs/lib/Transport/index.d.ts +16 -0
- package/cjs/lib/Transport/index.js +67 -0
- package/cjs/lib/Transport/internals.d.ts +57 -0
- package/cjs/lib/Transport/internals.js +203 -0
- package/cjs/lib/Transport/session-builder.d.ts +40 -0
- package/cjs/lib/Transport/session-builder.js +169 -0
- package/cjs/lib/Transport/session-cipher.d.ts +26 -0
- package/cjs/lib/Transport/session-cipher.js +328 -0
- package/cjs/lib/Transport/session-record.d.ts +55 -0
- package/cjs/lib/Transport/session-record.js +289 -0
- package/cjs/lib/Types/Auth.d.ts +1 -0
- package/cjs/lib/Types/Auth.js +15 -0
- package/cjs/lib/Types/Bussines.d.ts +1 -0
- package/cjs/lib/Types/Bussines.js +15 -0
- package/cjs/lib/Types/Call.d.ts +1 -0
- package/cjs/lib/Types/Call.js +15 -0
- package/cjs/lib/Types/Chat.d.ts +1 -0
- package/cjs/lib/Types/Chat.js +33 -0
- package/cjs/lib/Types/Contact.d.ts +1 -0
- package/cjs/lib/Types/Contact.js +15 -0
- package/cjs/lib/Types/Events.d.ts +1 -0
- package/cjs/lib/Types/Events.js +1 -0
- package/cjs/lib/Types/GroupMetadata.d.ts +1 -0
- package/cjs/lib/Types/GroupMetadata.js +15 -0
- package/cjs/lib/Types/Label.d.ts +2 -0
- package/cjs/lib/Types/Label.js +49 -0
- package/cjs/lib/Types/LabelAssociation.d.ts +2 -0
- package/cjs/lib/Types/LabelAssociation.js +31 -0
- package/cjs/lib/Types/Message.d.ts +11 -0
- package/cjs/lib/Types/Message.js +58 -0
- package/cjs/lib/Types/Mex.d.ts +2 -0
- package/cjs/lib/Types/Mex.js +66 -0
- package/cjs/lib/Types/Product.d.ts +1 -0
- package/cjs/lib/Types/Product.js +15 -0
- package/cjs/lib/Types/RichType.d.ts +2 -0
- package/cjs/lib/Types/RichType.js +50 -0
- package/cjs/lib/Types/Signal.d.ts +1 -0
- package/cjs/lib/Types/Signal.js +1 -0
- package/cjs/lib/Types/Socket.d.ts +1 -0
- package/cjs/lib/Types/Socket.js +1 -0
- package/cjs/lib/Types/State.d.ts +5 -0
- package/cjs/lib/Types/State.js +83 -0
- package/cjs/lib/Types/USync.d.ts +1 -0
- package/cjs/lib/Types/USync.js +1 -0
- package/cjs/lib/Types/index.d.ts +13 -0
- package/cjs/lib/Types/index.js +64 -0
- package/cjs/lib/Utils/auth-utils.d.ts +58 -0
- package/cjs/lib/Utils/auth-utils.js +275 -0
- package/cjs/lib/Utils/browser-utils.d.ts +9 -0
- package/cjs/lib/Utils/browser-utils.js +56 -0
- package/cjs/lib/Utils/business.d.ts +49 -0
- package/cjs/lib/Utils/business.js +259 -0
- package/cjs/lib/Utils/chat-utils.d.ts +408 -0
- package/cjs/lib/Utils/chat-utils.js +821 -0
- package/cjs/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/cjs/lib/Utils/companion-reg-client-utils.js +71 -0
- package/cjs/lib/Utils/crypto.d.ts +39 -0
- package/cjs/lib/Utils/crypto.js +155 -0
- package/cjs/lib/Utils/decode-wa-message.d.ts +83 -0
- package/cjs/lib/Utils/decode-wa-message.js +316 -0
- package/cjs/lib/Utils/event-buffer.d.ts +12 -0
- package/cjs/lib/Utils/event-buffer.js +605 -0
- package/cjs/lib/Utils/generics.d.ts +63 -0
- package/cjs/lib/Utils/generics.js +440 -0
- package/cjs/lib/Utils/history.d.ts +75 -0
- package/cjs/lib/Utils/history.js +153 -0
- package/cjs/lib/Utils/identity-change-handler.d.ts +13 -0
- package/cjs/lib/Utils/identity-change-handler.js +73 -0
- package/cjs/lib/Utils/index.d.ts +24 -0
- package/cjs/lib/Utils/index.js +67 -0
- package/cjs/lib/Utils/link-preview.d.ts +13 -0
- package/cjs/lib/Utils/link-preview.js +87 -0
- package/cjs/lib/Utils/logger.d.ts +12 -0
- package/cjs/lib/Utils/logger.js +40 -0
- package/cjs/lib/Utils/lt-hash.d.ts +6 -0
- package/cjs/lib/Utils/lt-hash.js +28 -0
- package/cjs/lib/Utils/make-mutex.d.ts +6 -0
- package/cjs/lib/Utils/make-mutex.js +58 -0
- package/cjs/lib/Utils/message-retry-manager.d.ts +79 -0
- package/cjs/lib/Utils/message-retry-manager.js +274 -0
- package/cjs/lib/Utils/messages-media.d.ts +134 -0
- package/cjs/lib/Utils/messages-media.js +799 -0
- package/cjs/lib/Utils/messages.d.ts +47 -0
- package/cjs/lib/Utils/messages.js +1667 -0
- package/cjs/lib/Utils/noise-handler.d.ts +20 -0
- package/cjs/lib/Utils/noise-handler.js +223 -0
- package/cjs/lib/Utils/offline-node-processor.d.ts +10 -0
- package/cjs/lib/Utils/offline-node-processor.js +60 -0
- package/cjs/lib/Utils/pre-key-manager.d.ts +25 -0
- package/cjs/lib/Utils/pre-key-manager.js +116 -0
- package/cjs/lib/Utils/process-message.d.ts +83 -0
- package/cjs/lib/Utils/process-message.js +607 -0
- package/cjs/lib/Utils/reporting-utils.d.ts +12 -0
- package/cjs/lib/Utils/reporting-utils.js +282 -0
- package/cjs/lib/Utils/rich-message-utils.d.ts +48 -0
- package/cjs/lib/Utils/rich-message-utils.js +381 -0
- package/cjs/lib/Utils/signal.d.ts +82 -0
- package/cjs/lib/Utils/signal.js +232 -0
- package/cjs/lib/Utils/stanza-ack.d.ts +16 -0
- package/cjs/lib/Utils/stanza-ack.js +53 -0
- package/cjs/lib/Utils/sync-action-utils.d.ts +2 -0
- package/cjs/lib/Utils/sync-action-utils.js +68 -0
- package/cjs/lib/Utils/tc-token-utils.d.ts +29 -0
- package/cjs/lib/Utils/tc-token-utils.js +182 -0
- package/cjs/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/cjs/lib/Utils/use-multi-file-auth-state.js +135 -0
- package/cjs/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/cjs/lib/Utils/use-single-file-auth-state.js +115 -0
- package/cjs/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/cjs/lib/Utils/use-sqlite-auth-state.js +140 -0
- package/cjs/lib/Utils/validate-connection.d.ts +44 -0
- package/cjs/lib/Utils/validate-connection.js +229 -0
- package/cjs/lib/WABinary/constants.d.ts +61 -0
- package/cjs/lib/WABinary/constants.js +1992 -0
- package/cjs/lib/WABinary/decode.d.ts +9 -0
- package/cjs/lib/WABinary/decode.js +292 -0
- package/cjs/lib/WABinary/encode.d.ts +2 -0
- package/cjs/lib/WABinary/encode.js +240 -0
- package/cjs/lib/WABinary/generic-utils.d.ts +79 -0
- package/cjs/lib/WABinary/generic-utils.js +252 -0
- package/cjs/lib/WABinary/index.d.ts +5 -0
- package/cjs/lib/WABinary/index.js +29 -0
- package/cjs/lib/WABinary/jid-utils.d.ts +28 -0
- package/cjs/lib/WABinary/jid-utils.js +151 -0
- package/cjs/lib/WABinary/types.d.ts +1 -0
- package/cjs/lib/WABinary/types.js +23 -0
- package/cjs/lib/WACrypto/appstate-keys.js +39 -0
- package/cjs/lib/WACrypto/curves/constants.js +37 -0
- package/cjs/lib/WACrypto/hkdf.js +38 -0
- package/cjs/lib/WACrypto/index.js +51 -0
- package/cjs/lib/WACrypto/lthash.js +59 -0
- package/cjs/lib/WACrypto/math/constants.js +53 -0
- package/cjs/lib/WACrypto/math/edwards.js +206 -0
- package/cjs/lib/WACrypto/math/fe.js +449 -0
- package/cjs/lib/WACrypto/math/le.js +44 -0
- package/cjs/lib/WACrypto/math/mod.js +36 -0
- package/cjs/lib/WACrypto/util/bytes.js +348 -0
- package/cjs/lib/WACrypto/x25519.js +157 -0
- package/cjs/lib/WACrypto/xeddsa.js +134 -0
- package/cjs/lib/WAM/BinaryInfo.d.ts +7 -0
- package/cjs/lib/WAM/BinaryInfo.js +35 -0
- package/cjs/lib/WAM/constants.d.ts +34926 -0
- package/cjs/lib/WAM/constants.js +22890 -0
- package/cjs/lib/WAM/encode.d.ts +1 -0
- package/cjs/lib/WAM/encode.js +162 -0
- package/cjs/lib/WAM/index.d.ts +3 -0
- package/cjs/lib/WAM/index.js +25 -0
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.js +77 -0
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.js +76 -0
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +52 -0
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.js +61 -0
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.js +50 -0
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +76 -0
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.js +53 -0
- package/cjs/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/cjs/lib/WAUSync/Protocols/index.js +29 -0
- package/cjs/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/cjs/lib/WAUSync/USyncQuery.js +113 -0
- package/cjs/lib/WAUSync/USyncUser.d.ts +16 -0
- package/cjs/lib/WAUSync/USyncUser.js +56 -0
- package/cjs/lib/WAUSync/index.d.ts +3 -0
- package/cjs/lib/WAUSync/index.js +25 -0
- package/cjs/lib/index.d.ts +11 -0
- package/cjs/lib/index.js +56 -0
- package/cjs/package.json +3 -0
- package/engine-requirements.js +12 -0
- package/lib/Addon/http-error.d.ts +18 -0
- package/lib/Addon/http-error.js +40 -0
- package/lib/Addon/index.d.ts +3 -0
- package/lib/Addon/index.js +4 -0
- package/lib/Addon/keyed-db.d.ts +14 -0
- package/lib/Addon/keyed-db.js +241 -0
- package/lib/Addon/link-preview.d.ts +15 -0
- package/lib/Addon/link-preview.js +79 -0
- package/lib/Defaults/index.d.ts +184 -0
- package/lib/Defaults/index.js +181 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-cipher.d.ts +10 -0
- package/lib/Signal/Group/group-cipher.js +81 -0
- package/lib/Signal/Group/group-session-builder.d.ts +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +6 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +54 -0
- package/lib/Signal/libsignal.js +426 -0
- package/lib/Signal/lid-mapping.d.ts +20 -0
- package/lib/Signal/lid-mapping.js +274 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +5 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +119 -0
- package/lib/Socket/business.d.ts +387 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +144 -0
- package/lib/Socket/chats.js +1216 -0
- package/lib/Socket/communities.d.ts +554 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/groups.d.ts +286 -0
- package/lib/Socket/groups.js +347 -0
- package/lib/Socket/index.d.ts +522 -0
- package/lib/Socket/index.js +11 -0
- package/lib/Socket/messages-recv.d.ts +326 -0
- package/lib/Socket/messages-recv.js +1822 -0
- package/lib/Socket/messages-send.d.ts +321 -0
- package/lib/Socket/messages-send.js +1378 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.d.ts +283 -0
- package/lib/Socket/newsletter.js +225 -0
- package/lib/Socket/socket.d.ts +61 -0
- package/lib/Socket/socket.js +992 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.js +419 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Transport/crypto.d.ts +6 -0
- package/lib/Transport/crypto.js +61 -0
- package/lib/Transport/curve.d.ts +8 -0
- package/lib/Transport/curve.js +66 -0
- package/lib/Transport/index.d.ts +16 -0
- package/lib/Transport/index.js +9 -0
- package/lib/Transport/internals.d.ts +57 -0
- package/lib/Transport/internals.js +155 -0
- package/lib/Transport/session-builder.d.ts +40 -0
- package/lib/Transport/session-builder.js +143 -0
- package/lib/Transport/session-cipher.d.ts +26 -0
- package/lib/Transport/session-cipher.js +301 -0
- package/lib/Transport/session-record.d.ts +55 -0
- package/lib/Transport/session-record.js +272 -0
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +1 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +2 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +2 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +11 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +1 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +1 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +1 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +5 -0
- package/lib/Types/State.js +54 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +13 -0
- package/lib/Types/index.js +25 -0
- package/lib/Utils/auth-utils.d.ts +58 -0
- package/lib/Utils/auth-utils.js +316 -0
- package/lib/Utils/browser-utils.d.ts +9 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.d.ts +408 -0
- package/lib/Utils/chat-utils.js +871 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/crypto.d.ts +39 -0
- package/lib/Utils/crypto.js +117 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +316 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +621 -0
- package/lib/Utils/generics.d.ts +63 -0
- package/lib/Utils/generics.js +394 -0
- package/lib/Utils/history.d.ts +75 -0
- package/lib/Utils/history.js +133 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.d.ts +24 -0
- package/lib/Utils/index.js +24 -0
- package/lib/Utils/link-preview.d.ts +13 -0
- package/lib/Utils/link-preview.js +73 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.js +12 -0
- package/lib/Utils/lt-hash.d.ts +6 -0
- package/lib/Utils/lt-hash.js +7 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +259 -0
- package/lib/Utils/messages-media.d.ts +134 -0
- package/lib/Utils/messages-media.js +802 -0
- package/lib/Utils/messages.d.ts +47 -0
- package/lib/Utils/messages.js +1911 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +10 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +83 -0
- package/lib/Utils/process-message.js +748 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +369 -0
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/signal.js +200 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +163 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-multi-file-auth-state.js +116 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +94 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +109 -0
- package/lib/Utils/validate-connection.d.ts +44 -0
- package/lib/Utils/validate-connection.js +210 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +79 -0
- package/lib/WABinary/generic-utils.js +228 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WACrypto/appstate-keys.js +26 -0
- package/lib/WACrypto/curves/constants.js +12 -0
- package/lib/WACrypto/hkdf.js +27 -0
- package/lib/WACrypto/index.js +20 -0
- package/lib/WACrypto/lthash.js +54 -0
- package/lib/WACrypto/math/constants.js +24 -0
- package/lib/WACrypto/math/edwards.js +194 -0
- package/lib/WACrypto/math/fe.js +698 -0
- package/lib/WACrypto/math/le.js +23 -0
- package/lib/WACrypto/math/mod.js +15 -0
- package/lib/WACrypto/util/bytes.js +339 -0
- package/lib/WACrypto/x25519.js +145 -0
- package/lib/WACrypto/xeddsa.js +92 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.js +5 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +97 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/USyncUser.js +30 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/package.json +79 -5
|
@@ -0,0 +1,348 @@
|
|
|
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 bytes_exports = {};
|
|
19
|
+
__export(bytes_exports, {
|
|
20
|
+
EMPTY_BYTES: () => EMPTY_BYTES,
|
|
21
|
+
TEXT_DECODER: () => TEXT_DECODER,
|
|
22
|
+
TEXT_ENCODER: () => TEXT_ENCODER,
|
|
23
|
+
ZERO_BYTES: () => ZERO_BYTES,
|
|
24
|
+
assertByteLength: () => assertByteLength,
|
|
25
|
+
base64ToBytes: () => base64ToBytes,
|
|
26
|
+
base64ToBytesChecked: () => base64ToBytesChecked,
|
|
27
|
+
bytesToBase64: () => bytesToBase64,
|
|
28
|
+
bytesToBase64UrlSafe: () => bytesToBase64UrlSafe,
|
|
29
|
+
bytesToHex: () => bytesToHex,
|
|
30
|
+
concatBytes: () => concatBytes,
|
|
31
|
+
decodeBase64Url: () => decodeBase64Url,
|
|
32
|
+
decodeProtoBytes: () => decodeProtoBytes,
|
|
33
|
+
hexToBytes: () => hexToBytes,
|
|
34
|
+
intToBytes: () => intToBytes,
|
|
35
|
+
readAllBytes: () => readAllBytes,
|
|
36
|
+
removeAt: () => removeAt,
|
|
37
|
+
toBytesView: () => toBytesView,
|
|
38
|
+
toChunkBytes: () => toChunkBytes,
|
|
39
|
+
uint8Equal: () => uint8Equal,
|
|
40
|
+
uint8TimingSafeEqual: () => uint8TimingSafeEqual
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(bytes_exports);
|
|
43
|
+
var import_node_crypto = require("node:crypto");
|
|
44
|
+
const TEXT_ENCODER = new TextEncoder();
|
|
45
|
+
const TEXT_DECODER = new TextDecoder();
|
|
46
|
+
const ZERO_BYTES = new Uint8Array([0]);
|
|
47
|
+
const EMPTY_BYTES = Object.freeze(new Uint8Array(0));
|
|
48
|
+
const HEX_CHARS = "0123456789abcdef";
|
|
49
|
+
const HEX_TABLE = /* @__PURE__ */ (() => {
|
|
50
|
+
const table = new Array(256);
|
|
51
|
+
for (let i = 0; i < 256; i += 1) {
|
|
52
|
+
table[i] = HEX_CHARS[i >> 4] + HEX_CHARS[i & 15];
|
|
53
|
+
}
|
|
54
|
+
return table;
|
|
55
|
+
})();
|
|
56
|
+
const HEX_LOOKUP = /* @__PURE__ */ (() => {
|
|
57
|
+
const table = new Int8Array(128).fill(-1);
|
|
58
|
+
for (let i = 48; i <= 57; i += 1)
|
|
59
|
+
table[i] = i - 48;
|
|
60
|
+
for (let i = 65; i <= 70; i += 1)
|
|
61
|
+
table[i] = i - 65 + 10;
|
|
62
|
+
for (let i = 97; i <= 102; i += 1)
|
|
63
|
+
table[i] = i - 97 + 10;
|
|
64
|
+
return table;
|
|
65
|
+
})();
|
|
66
|
+
const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
67
|
+
const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
68
|
+
const BASE64_LOOKUP = /* @__PURE__ */ (() => {
|
|
69
|
+
const table = new Uint8Array(128).fill(255);
|
|
70
|
+
for (let i = 0; i < BASE64_CHARS.length; i += 1) {
|
|
71
|
+
table[BASE64_CHARS.charCodeAt(i)] = i;
|
|
72
|
+
}
|
|
73
|
+
table[61] = 0;
|
|
74
|
+
return table;
|
|
75
|
+
})();
|
|
76
|
+
function bytesToHex(value) {
|
|
77
|
+
let out = "";
|
|
78
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
79
|
+
out += HEX_TABLE[value[i]];
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
function hexToBytes(value) {
|
|
84
|
+
const len = value.length;
|
|
85
|
+
if (len & 1) {
|
|
86
|
+
throw new Error("hex string must have even length");
|
|
87
|
+
}
|
|
88
|
+
const out = new Uint8Array(len >> 1);
|
|
89
|
+
for (let i = 0; i < len; i += 2) {
|
|
90
|
+
const hiCode = value.charCodeAt(i);
|
|
91
|
+
const loCode = value.charCodeAt(i + 1);
|
|
92
|
+
const hi = hiCode < 128 ? HEX_LOOKUP[hiCode] : -1;
|
|
93
|
+
const lo = loCode < 128 ? HEX_LOOKUP[loCode] : -1;
|
|
94
|
+
if ((hi | lo) < 0) {
|
|
95
|
+
throw new Error("invalid hex character");
|
|
96
|
+
}
|
|
97
|
+
out[i >> 1] = hi << 4 | lo;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
function bytesToBase64(value) {
|
|
102
|
+
return encodeBase64(value, BASE64_CHARS, true);
|
|
103
|
+
}
|
|
104
|
+
function base64ToBytes(value) {
|
|
105
|
+
const len = value.length;
|
|
106
|
+
if (len === 0)
|
|
107
|
+
return EMPTY_BYTES;
|
|
108
|
+
if ((len & 3) !== 0) {
|
|
109
|
+
throw new Error("base64 string length must be multiple of 4");
|
|
110
|
+
}
|
|
111
|
+
let padding = 0;
|
|
112
|
+
if (value.charCodeAt(len - 1) === 61)
|
|
113
|
+
padding += 1;
|
|
114
|
+
if (value.charCodeAt(len - 2) === 61)
|
|
115
|
+
padding += 1;
|
|
116
|
+
const outLen = (len * 3 >> 2) - padding;
|
|
117
|
+
const out = new Uint8Array(outLen);
|
|
118
|
+
let j = 0;
|
|
119
|
+
const mainLen = len - 4;
|
|
120
|
+
let i = 0;
|
|
121
|
+
for (; i < mainLen; i += 4) {
|
|
122
|
+
const a2 = lookupBase64(value.charCodeAt(i));
|
|
123
|
+
const b2 = lookupBase64(value.charCodeAt(i + 1));
|
|
124
|
+
const c = lookupBase64(value.charCodeAt(i + 2));
|
|
125
|
+
const d = lookupBase64(value.charCodeAt(i + 3));
|
|
126
|
+
out[j++] = a2 << 2 | b2 >> 4;
|
|
127
|
+
out[j++] = (b2 & 15) << 4 | c >> 2;
|
|
128
|
+
out[j++] = (c & 3) << 6 | d;
|
|
129
|
+
}
|
|
130
|
+
const a = lookupBase64(value.charCodeAt(i));
|
|
131
|
+
const b = lookupBase64(value.charCodeAt(i + 1));
|
|
132
|
+
out[j++] = a << 2 | b >> 4;
|
|
133
|
+
if (j < outLen) {
|
|
134
|
+
const c = lookupBase64(value.charCodeAt(i + 2));
|
|
135
|
+
out[j++] = (b & 15) << 4 | c >> 2;
|
|
136
|
+
if (j < outLen) {
|
|
137
|
+
const d = lookupBase64(value.charCodeAt(i + 3));
|
|
138
|
+
out[j++] = (c & 3) << 6 | d;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
function base64ToBytesChecked(value, field) {
|
|
144
|
+
if (value.length === 0) {
|
|
145
|
+
throw new Error(`invalid base64 payload for ${field}`);
|
|
146
|
+
}
|
|
147
|
+
return base64ToBytes(value);
|
|
148
|
+
}
|
|
149
|
+
function decodeBase64Url(value, field) {
|
|
150
|
+
if (!value) {
|
|
151
|
+
throw new Error(`missing ${field}`);
|
|
152
|
+
}
|
|
153
|
+
const padded = value.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(value.length / 4) * 4, "=");
|
|
154
|
+
return base64ToBytesChecked(padded, field);
|
|
155
|
+
}
|
|
156
|
+
function assertByteLength(value, expectedLength, errorMessage) {
|
|
157
|
+
if (value.length !== expectedLength) {
|
|
158
|
+
throw new Error(errorMessage);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function decodeProtoBytes(value, field) {
|
|
162
|
+
if (value === null || value === void 0) {
|
|
163
|
+
throw new Error(`missing protobuf bytes field ${field}`);
|
|
164
|
+
}
|
|
165
|
+
if (value instanceof Uint8Array) {
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
return base64ToBytes(value);
|
|
169
|
+
}
|
|
170
|
+
function lookupBase64(code) {
|
|
171
|
+
if (code > 127) {
|
|
172
|
+
throw new Error("invalid base64 character");
|
|
173
|
+
}
|
|
174
|
+
const v = BASE64_LOOKUP[code];
|
|
175
|
+
if (v === 255) {
|
|
176
|
+
throw new Error("invalid base64 character");
|
|
177
|
+
}
|
|
178
|
+
return v;
|
|
179
|
+
}
|
|
180
|
+
function bytesToBase64UrlSafe(value) {
|
|
181
|
+
return encodeBase64(value, BASE64URL_CHARS, false);
|
|
182
|
+
}
|
|
183
|
+
function encodeBase64(value, alphabet, pad) {
|
|
184
|
+
const len = value.length;
|
|
185
|
+
if (len === 0)
|
|
186
|
+
return "";
|
|
187
|
+
const remainder = len % 3;
|
|
188
|
+
const mainLen = len - remainder;
|
|
189
|
+
const chunks = Math.ceil(len / 3);
|
|
190
|
+
const out = new Array(pad ? chunks * 4 : Math.ceil(len * 4 / 3));
|
|
191
|
+
let k = 0;
|
|
192
|
+
for (let i = 0; i < mainLen; i += 3) {
|
|
193
|
+
const a = value[i];
|
|
194
|
+
const b = value[i + 1];
|
|
195
|
+
const c = value[i + 2];
|
|
196
|
+
out[k++] = alphabet[a >> 2];
|
|
197
|
+
out[k++] = alphabet[(a & 3) << 4 | b >> 4];
|
|
198
|
+
out[k++] = alphabet[(b & 15) << 2 | c >> 6];
|
|
199
|
+
out[k++] = alphabet[c & 63];
|
|
200
|
+
}
|
|
201
|
+
if (remainder === 1) {
|
|
202
|
+
const a = value[mainLen];
|
|
203
|
+
out[k++] = alphabet[a >> 2];
|
|
204
|
+
out[k++] = alphabet[(a & 3) << 4];
|
|
205
|
+
if (pad) {
|
|
206
|
+
out[k++] = "=";
|
|
207
|
+
out[k++] = "=";
|
|
208
|
+
}
|
|
209
|
+
} else if (remainder === 2) {
|
|
210
|
+
const a = value[mainLen];
|
|
211
|
+
const b = value[mainLen + 1];
|
|
212
|
+
out[k++] = alphabet[a >> 2];
|
|
213
|
+
out[k++] = alphabet[(a & 3) << 4 | b >> 4];
|
|
214
|
+
out[k++] = alphabet[(b & 15) << 2];
|
|
215
|
+
if (pad) {
|
|
216
|
+
out[k++] = "=";
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return out.join("");
|
|
220
|
+
}
|
|
221
|
+
function concatBytes(parts) {
|
|
222
|
+
let total = 0;
|
|
223
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
224
|
+
total += parts[i].length;
|
|
225
|
+
}
|
|
226
|
+
const out = new Uint8Array(total);
|
|
227
|
+
let offset = 0;
|
|
228
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
229
|
+
out.set(parts[i], offset);
|
|
230
|
+
offset += parts[i].length;
|
|
231
|
+
}
|
|
232
|
+
return out;
|
|
233
|
+
}
|
|
234
|
+
function toBytesView(value) {
|
|
235
|
+
if (value instanceof Uint8Array) {
|
|
236
|
+
return value.constructor === Uint8Array ? value : new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
237
|
+
}
|
|
238
|
+
if (value instanceof ArrayBuffer) {
|
|
239
|
+
return new Uint8Array(value);
|
|
240
|
+
}
|
|
241
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
242
|
+
}
|
|
243
|
+
function toChunkBytes(chunk) {
|
|
244
|
+
if (typeof chunk === "string") {
|
|
245
|
+
return TEXT_ENCODER.encode(chunk);
|
|
246
|
+
}
|
|
247
|
+
if (chunk instanceof Uint8Array || chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
|
|
248
|
+
return toBytesView(chunk);
|
|
249
|
+
}
|
|
250
|
+
throw new Error(`unsupported stream chunk type: ${typeof chunk}`);
|
|
251
|
+
}
|
|
252
|
+
function uint8TimingSafeEqual(left, right) {
|
|
253
|
+
if (left.byteLength !== right.byteLength) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
return (0, import_node_crypto.timingSafeEqual)(left, right);
|
|
257
|
+
}
|
|
258
|
+
function uint8Equal(a, b) {
|
|
259
|
+
if (a.length !== b.length) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
let diff = 0;
|
|
263
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
264
|
+
diff |= a[i] ^ b[i];
|
|
265
|
+
}
|
|
266
|
+
return diff === 0;
|
|
267
|
+
}
|
|
268
|
+
function removeAt(items, index) {
|
|
269
|
+
if (items.length === 0) {
|
|
270
|
+
return [];
|
|
271
|
+
}
|
|
272
|
+
if (index < 0 || index >= items.length) {
|
|
273
|
+
const out2 = new Array(items.length);
|
|
274
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
275
|
+
out2[i] = items[i];
|
|
276
|
+
}
|
|
277
|
+
return out2;
|
|
278
|
+
}
|
|
279
|
+
const out = new Array(items.length - 1);
|
|
280
|
+
let k = 0;
|
|
281
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
282
|
+
if (i !== index) {
|
|
283
|
+
out[k++] = items[i];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
function intToBytes(byteLength, value) {
|
|
289
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
290
|
+
throw new Error(`invalid integer value: ${value}`);
|
|
291
|
+
}
|
|
292
|
+
const out = new Uint8Array(byteLength);
|
|
293
|
+
let current = value;
|
|
294
|
+
for (let i = byteLength - 1; i >= 0; i -= 1) {
|
|
295
|
+
out[i] = current & 255;
|
|
296
|
+
current = Math.floor(current / 256);
|
|
297
|
+
}
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
async function readAllBytes(stream, options = {}) {
|
|
301
|
+
const maxBytes = options.maxBytes;
|
|
302
|
+
if (maxBytes !== void 0 && (!Number.isSafeInteger(maxBytes) || maxBytes < 0)) {
|
|
303
|
+
throw new Error(`invalid max bytes limit: ${maxBytes}`);
|
|
304
|
+
}
|
|
305
|
+
const chunks = [];
|
|
306
|
+
let total = 0;
|
|
307
|
+
for await (const chunk of stream) {
|
|
308
|
+
const bytes = toChunkBytes(chunk);
|
|
309
|
+
chunks.push(bytes);
|
|
310
|
+
total += bytes.byteLength;
|
|
311
|
+
if (maxBytes !== void 0 && total > maxBytes) {
|
|
312
|
+
const error = new Error(`stream exceeded max bytes limit (${maxBytes})`);
|
|
313
|
+
stream.destroy(error);
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (total === 0) {
|
|
318
|
+
return EMPTY_BYTES;
|
|
319
|
+
}
|
|
320
|
+
if (chunks.length === 1) {
|
|
321
|
+
return chunks[0];
|
|
322
|
+
}
|
|
323
|
+
return concatBytes(chunks);
|
|
324
|
+
}
|
|
325
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
326
|
+
0 && (module.exports = {
|
|
327
|
+
EMPTY_BYTES,
|
|
328
|
+
TEXT_DECODER,
|
|
329
|
+
TEXT_ENCODER,
|
|
330
|
+
ZERO_BYTES,
|
|
331
|
+
assertByteLength,
|
|
332
|
+
base64ToBytes,
|
|
333
|
+
base64ToBytesChecked,
|
|
334
|
+
bytesToBase64,
|
|
335
|
+
bytesToBase64UrlSafe,
|
|
336
|
+
bytesToHex,
|
|
337
|
+
concatBytes,
|
|
338
|
+
decodeBase64Url,
|
|
339
|
+
decodeProtoBytes,
|
|
340
|
+
hexToBytes,
|
|
341
|
+
intToBytes,
|
|
342
|
+
readAllBytes,
|
|
343
|
+
removeAt,
|
|
344
|
+
toBytesView,
|
|
345
|
+
toChunkBytes,
|
|
346
|
+
uint8Equal,
|
|
347
|
+
uint8TimingSafeEqual
|
|
348
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
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 x25519_exports = {};
|
|
19
|
+
__export(x25519_exports, {
|
|
20
|
+
calculateAgreement: () => calculateAgreement,
|
|
21
|
+
clampCurvePrivateKeyInPlace: () => clampCurvePrivateKeyInPlace,
|
|
22
|
+
deriveEdwardsKeyMaterial: () => deriveEdwardsKeyMaterial,
|
|
23
|
+
generateKeyPair: () => generateKeyPair,
|
|
24
|
+
getPublicFromPrivateKey: () => getPublicFromPrivateKey,
|
|
25
|
+
montgomeryToEdwardsPublic: () => montgomeryToEdwardsPublic
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(x25519_exports);
|
|
28
|
+
var import_node_crypto = require("node:crypto");
|
|
29
|
+
var import_fe = require("./math/fe.js");
|
|
30
|
+
var import_constants = require("./math/constants.js");
|
|
31
|
+
var import_edwards = require("./math/edwards.js");
|
|
32
|
+
var import_le = require("./math/le.js");
|
|
33
|
+
var import_bytes = require("./util/bytes.js");
|
|
34
|
+
const X25519_PKCS8_PREFIX = Uint8Array.from([
|
|
35
|
+
48,
|
|
36
|
+
46,
|
|
37
|
+
2,
|
|
38
|
+
1,
|
|
39
|
+
0,
|
|
40
|
+
48,
|
|
41
|
+
5,
|
|
42
|
+
6,
|
|
43
|
+
3,
|
|
44
|
+
43,
|
|
45
|
+
101,
|
|
46
|
+
110,
|
|
47
|
+
4,
|
|
48
|
+
34,
|
|
49
|
+
4,
|
|
50
|
+
32
|
|
51
|
+
]);
|
|
52
|
+
const X25519_SPKI_PREFIX = Uint8Array.from([
|
|
53
|
+
48,
|
|
54
|
+
42,
|
|
55
|
+
48,
|
|
56
|
+
5,
|
|
57
|
+
6,
|
|
58
|
+
3,
|
|
59
|
+
43,
|
|
60
|
+
101,
|
|
61
|
+
110,
|
|
62
|
+
3,
|
|
63
|
+
33,
|
|
64
|
+
0
|
|
65
|
+
]);
|
|
66
|
+
const VERSION_BYTE = 5;
|
|
67
|
+
function clampCurvePrivateKeyInPlace(privateKey) {
|
|
68
|
+
(0, import_bytes.assertByteLength)(privateKey, 32, `invalid curve25519 private key length ${privateKey.length}`);
|
|
69
|
+
privateKey[0] &= 248;
|
|
70
|
+
privateKey[31] &= 127;
|
|
71
|
+
privateKey[31] |= 64;
|
|
72
|
+
return privateKey;
|
|
73
|
+
}
|
|
74
|
+
function isFieldPMinus1(b) {
|
|
75
|
+
if (b[0] !== 236 || (b[31] & 127) !== 127)
|
|
76
|
+
return false;
|
|
77
|
+
for (let i = 1; i < 31; i++)
|
|
78
|
+
if (b[i] !== 255)
|
|
79
|
+
return false;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const _mx = (0, import_fe.fe)();
|
|
83
|
+
const _m1 = (0, import_fe.fe)();
|
|
84
|
+
const _m2 = (0, import_fe.fe)();
|
|
85
|
+
const _m3 = (0, import_fe.fe)();
|
|
86
|
+
function montgomeryToEdwardsPublic(curvePublicKey, signBit) {
|
|
87
|
+
(0, import_bytes.assertByteLength)(curvePublicKey, 32, `invalid curve25519 public key length ${curvePublicKey.length}`);
|
|
88
|
+
if (isFieldPMinus1(curvePublicKey)) {
|
|
89
|
+
throw new Error("invalid curve25519 low-order public key");
|
|
90
|
+
}
|
|
91
|
+
(0, import_fe.feFromBytes)(_mx, curvePublicKey);
|
|
92
|
+
(0, import_fe.feSub)(_m1, _mx, import_constants.FE_ONE);
|
|
93
|
+
(0, import_fe.feAdd)(_m2, _mx, import_constants.FE_ONE);
|
|
94
|
+
(0, import_fe.feInv)(_m3, _m2);
|
|
95
|
+
(0, import_fe.feMul)(_m1, _m1, _m3);
|
|
96
|
+
const encoded = new Uint8Array(32);
|
|
97
|
+
(0, import_fe.fePack)(encoded, _m1);
|
|
98
|
+
encoded[31] = encoded[31] & 127 | signBit & 128;
|
|
99
|
+
return encoded;
|
|
100
|
+
}
|
|
101
|
+
function deriveEdwardsKeyMaterial(privateKey) {
|
|
102
|
+
const clamped = Uint8Array.from(privateKey);
|
|
103
|
+
clampCurvePrivateKeyInPlace(clamped);
|
|
104
|
+
const privateScalar = (0, import_le.bytesToBigIntLE)(clamped);
|
|
105
|
+
const encodedPublic = (0, import_edwards.encodeExtendedPoint)((0, import_edwards.scalarMultBase)(privateScalar));
|
|
106
|
+
return { clamped, privateScalar, encodedPublic };
|
|
107
|
+
}
|
|
108
|
+
function privateToKeyObject(privKey) {
|
|
109
|
+
return (0, import_node_crypto.createPrivateKey)({
|
|
110
|
+
key: (0, import_bytes.concatBytes)([X25519_PKCS8_PREFIX, privKey]),
|
|
111
|
+
format: "der",
|
|
112
|
+
type: "pkcs8"
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function publicToKeyObject(pubKey) {
|
|
116
|
+
return (0, import_node_crypto.createPublicKey)({
|
|
117
|
+
key: (0, import_bytes.concatBytes)([X25519_SPKI_PREFIX, pubKey]),
|
|
118
|
+
format: "der",
|
|
119
|
+
type: "spki"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function normalizePublicKey(pubKey) {
|
|
123
|
+
if (pubKey.byteLength === 33 && pubKey[0] === VERSION_BYTE) {
|
|
124
|
+
return pubKey.subarray(1);
|
|
125
|
+
}
|
|
126
|
+
(0, import_bytes.assertByteLength)(pubKey, 32, `invalid curve25519 public key length ${pubKey.byteLength}`);
|
|
127
|
+
return pubKey;
|
|
128
|
+
}
|
|
129
|
+
function generateKeyPair() {
|
|
130
|
+
const { publicKey, privateKey } = (0, import_node_crypto.generateKeyPairSync)("x25519");
|
|
131
|
+
const rawPub = publicKey.export({ format: "der", type: "spki" }).subarray(X25519_SPKI_PREFIX.length);
|
|
132
|
+
const rawPriv = privateKey.export({ format: "der", type: "pkcs8" }).subarray(X25519_PKCS8_PREFIX.length);
|
|
133
|
+
clampCurvePrivateKeyInPlace(rawPriv);
|
|
134
|
+
return {
|
|
135
|
+
pubKey: (0, import_bytes.concatBytes)([Uint8Array.of(VERSION_BYTE), rawPub]),
|
|
136
|
+
privKey: rawPriv
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function getPublicFromPrivateKey(privKey) {
|
|
140
|
+
const { encodedPublic } = deriveEdwardsKeyMaterial(privKey);
|
|
141
|
+
return (0, import_bytes.concatBytes)([Uint8Array.of(VERSION_BYTE), encodedPublic]);
|
|
142
|
+
}
|
|
143
|
+
function calculateAgreement(pubKey, privKey) {
|
|
144
|
+
(0, import_bytes.assertByteLength)(privKey, 32, `invalid curve25519 private key length ${privKey.byteLength}`);
|
|
145
|
+
const priv = privateToKeyObject(privKey);
|
|
146
|
+
const pub = publicToKeyObject(normalizePublicKey(pubKey));
|
|
147
|
+
return (0, import_node_crypto.diffieHellman)({ privateKey: priv, publicKey: pub });
|
|
148
|
+
}
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
calculateAgreement,
|
|
152
|
+
clampCurvePrivateKeyInPlace,
|
|
153
|
+
deriveEdwardsKeyMaterial,
|
|
154
|
+
generateKeyPair,
|
|
155
|
+
getPublicFromPrivateKey,
|
|
156
|
+
montgomeryToEdwardsPublic
|
|
157
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
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 xeddsa_exports = {};
|
|
19
|
+
__export(xeddsa_exports, {
|
|
20
|
+
calculateSignature: () => calculateSignature,
|
|
21
|
+
verifySignature: () => verifySignature
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(xeddsa_exports);
|
|
24
|
+
var import_node_crypto = require("node:crypto");
|
|
25
|
+
var import_edwards = require("./math/edwards.js");
|
|
26
|
+
var import_le = require("./math/le.js");
|
|
27
|
+
var import_mod = require("./math/mod.js");
|
|
28
|
+
var import_bytes = require("./util/bytes.js");
|
|
29
|
+
var import_x25519 = require("./x25519.js");
|
|
30
|
+
const ED25519_SPKI_PREFIX = Uint8Array.from([
|
|
31
|
+
48,
|
|
32
|
+
42,
|
|
33
|
+
48,
|
|
34
|
+
5,
|
|
35
|
+
6,
|
|
36
|
+
3,
|
|
37
|
+
43,
|
|
38
|
+
101,
|
|
39
|
+
112,
|
|
40
|
+
3,
|
|
41
|
+
33,
|
|
42
|
+
0
|
|
43
|
+
]);
|
|
44
|
+
const PREFIX_SIGNATURE_RANDOM = Uint8Array.from([
|
|
45
|
+
254,
|
|
46
|
+
255,
|
|
47
|
+
255,
|
|
48
|
+
255,
|
|
49
|
+
255,
|
|
50
|
+
255,
|
|
51
|
+
255,
|
|
52
|
+
255,
|
|
53
|
+
255,
|
|
54
|
+
255,
|
|
55
|
+
255,
|
|
56
|
+
255,
|
|
57
|
+
255,
|
|
58
|
+
255,
|
|
59
|
+
255,
|
|
60
|
+
255,
|
|
61
|
+
255,
|
|
62
|
+
255,
|
|
63
|
+
255,
|
|
64
|
+
255,
|
|
65
|
+
255,
|
|
66
|
+
255,
|
|
67
|
+
255,
|
|
68
|
+
255,
|
|
69
|
+
255,
|
|
70
|
+
255,
|
|
71
|
+
255,
|
|
72
|
+
255,
|
|
73
|
+
255,
|
|
74
|
+
255,
|
|
75
|
+
255,
|
|
76
|
+
255
|
|
77
|
+
]);
|
|
78
|
+
function sha512Chunks(chunks) {
|
|
79
|
+
const hash = (0, import_node_crypto.createHash)("sha512");
|
|
80
|
+
for (const chunk of chunks) {
|
|
81
|
+
hash.update(chunk);
|
|
82
|
+
}
|
|
83
|
+
return hash.digest();
|
|
84
|
+
}
|
|
85
|
+
function calculateSignature(privateKey, message) {
|
|
86
|
+
(0, import_bytes.assertByteLength)(privateKey, 32, `invalid curve25519 private key length ${privateKey.length}`);
|
|
87
|
+
const { clamped, privateScalar, encodedPublic } = (0, import_x25519.deriveEdwardsKeyMaterial)(privateKey);
|
|
88
|
+
const pubKeySignBit = encodedPublic[31] & 128;
|
|
89
|
+
const randomSuffix = (0, import_node_crypto.randomBytes)(64);
|
|
90
|
+
const r = (0, import_mod.modGroup)((0, import_le.bytesToBigIntLE)(sha512Chunks([
|
|
91
|
+
PREFIX_SIGNATURE_RANDOM,
|
|
92
|
+
clamped,
|
|
93
|
+
message,
|
|
94
|
+
randomSuffix
|
|
95
|
+
])));
|
|
96
|
+
const encodedR = (0, import_edwards.encodeExtendedPoint)((0, import_edwards.scalarMultBase)(r));
|
|
97
|
+
const h = (0, import_mod.modGroup)((0, import_le.bytesToBigIntLE)(sha512Chunks([encodedR, encodedPublic, message])));
|
|
98
|
+
const s = (0, import_mod.modGroup)(r + h * privateScalar);
|
|
99
|
+
const encodedS = (0, import_le.bigIntToBytesLE)(s, 32);
|
|
100
|
+
encodedS[31] = encodedS[31] & 127 | pubKeySignBit;
|
|
101
|
+
return (0, import_bytes.concatBytes)([encodedR, encodedS]);
|
|
102
|
+
}
|
|
103
|
+
function verifySignature(publicKey, message, signature) {
|
|
104
|
+
let sig = Uint8Array.from(signature);
|
|
105
|
+
if (sig.byteLength !== 64) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if ((sig[63] & 96) !== 0) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const lastByteIndex = 63;
|
|
112
|
+
const originalLastByte = sig[lastByteIndex];
|
|
113
|
+
const signBit = originalLastByte & 128;
|
|
114
|
+
sig[lastByteIndex] = originalLastByte & 127;
|
|
115
|
+
try {
|
|
116
|
+
const pubKey = publicKey.byteLength === 33 && publicKey[0] === 5 ? publicKey.subarray(1) : publicKey;
|
|
117
|
+
const edPublic = (0, import_x25519.montgomeryToEdwardsPublic)(pubKey, signBit);
|
|
118
|
+
const keyObject = (0, import_node_crypto.createPublicKey)({
|
|
119
|
+
key: (0, import_bytes.concatBytes)([ED25519_SPKI_PREFIX, edPublic]),
|
|
120
|
+
format: "der",
|
|
121
|
+
type: "spki"
|
|
122
|
+
});
|
|
123
|
+
return (0, import_node_crypto.verify)(null, message, keyObject, sig);
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
} finally {
|
|
127
|
+
sig[lastByteIndex] = originalLastByte;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
calculateSignature,
|
|
133
|
+
verifySignature
|
|
134
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
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 BinaryInfo_exports = {};
|
|
19
|
+
__export(BinaryInfo_exports, {
|
|
20
|
+
BinaryInfo: () => BinaryInfo
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(BinaryInfo_exports);
|
|
23
|
+
class BinaryInfo {
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
this.protocolVersion = 5;
|
|
26
|
+
this.sequence = 0;
|
|
27
|
+
this.events = [];
|
|
28
|
+
this.buffer = [];
|
|
29
|
+
Object.assign(this, options);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
BinaryInfo
|
|
35
|
+
});
|