@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,12 @@
|
|
|
1
|
+
const major = parseInt(
|
|
2
|
+
process.versions.node.split('.')[0],
|
|
3
|
+
10
|
|
4
|
+
);
|
|
5
|
+
if (major < 20) {
|
|
6
|
+
console.error(
|
|
7
|
+
`\n❌ This package requires Node.js 20+ to run reliably.\n` +
|
|
8
|
+
` You are using Node.js ${process.versions.node}.\n` +
|
|
9
|
+
` Please upgrade to Node.js 20+ to proceed.\n`
|
|
10
|
+
);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class HttpError extends Error {
|
|
2
|
+
static getStatusText(statusCode: any): any;
|
|
3
|
+
constructor(message: any, options?: {});
|
|
4
|
+
isHttpError: boolean;
|
|
5
|
+
isBoom: boolean;
|
|
6
|
+
isServer: boolean;
|
|
7
|
+
data: any;
|
|
8
|
+
output: {
|
|
9
|
+
statusCode: any;
|
|
10
|
+
payload: {
|
|
11
|
+
statusCode: any;
|
|
12
|
+
error: any;
|
|
13
|
+
message: any;
|
|
14
|
+
};
|
|
15
|
+
headers: {};
|
|
16
|
+
};
|
|
17
|
+
get statusCode(): any;
|
|
18
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 http_error_exports = {};
|
|
19
|
+
__export(http_error_exports, {
|
|
20
|
+
HttpError: () => HttpError
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(http_error_exports);
|
|
23
|
+
class HttpError extends Error {
|
|
24
|
+
constructor(message, options = {}) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = this.constructor.name;
|
|
27
|
+
this.isHttpError = true;
|
|
28
|
+
this.isBoom = true;
|
|
29
|
+
this.isServer = true;
|
|
30
|
+
const statusCode = options?.statusCode || 400;
|
|
31
|
+
this.data = options?.data || null;
|
|
32
|
+
this.output = {
|
|
33
|
+
statusCode,
|
|
34
|
+
payload: {
|
|
35
|
+
statusCode,
|
|
36
|
+
error: HttpError.getStatusText(statusCode),
|
|
37
|
+
message
|
|
38
|
+
},
|
|
39
|
+
headers: {}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
get statusCode() {
|
|
43
|
+
return this.output.statusCode;
|
|
44
|
+
}
|
|
45
|
+
static getStatusText(statusCode) {
|
|
46
|
+
const statuses = {
|
|
47
|
+
400: "Bad Request",
|
|
48
|
+
401: "Unauthorized",
|
|
49
|
+
403: "Forbidden",
|
|
50
|
+
404: "Not Found",
|
|
51
|
+
405: "Method Not Allowed",
|
|
52
|
+
409: "Conflict",
|
|
53
|
+
422: "Unprocessable Entity",
|
|
54
|
+
429: "Too Many Requests",
|
|
55
|
+
500: "Internal Server Error",
|
|
56
|
+
501: "Not Implemented",
|
|
57
|
+
502: "Bad Gateway",
|
|
58
|
+
503: "Service Unavailable"
|
|
59
|
+
};
|
|
60
|
+
return statuses[statusCode] || "Internal Server Error";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
HttpError
|
|
66
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
createCache: () => import_starforge.createCache,
|
|
22
|
+
createMutex: () => import_starforge.createMutex,
|
|
23
|
+
createQueue: () => import_starforge.createQueue,
|
|
24
|
+
createZip: () => import_starforge.createZip,
|
|
25
|
+
detectFileType: () => import_starforge.detectFileType,
|
|
26
|
+
detectMediaInfo: () => import_starforge.detectMediaInfo,
|
|
27
|
+
encodeQR: () => import_starforge.encodeQR,
|
|
28
|
+
getAudioWaveform: () => import_starforge.getAudioWaveform,
|
|
29
|
+
getFile: () => import_starforge.getFile
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
|
+
var import_starforge = require("@itsliaaa/starforge");
|
|
33
|
+
__reExport(index_exports, require("./http-error.js"), module.exports);
|
|
34
|
+
__reExport(index_exports, require("./keyed-db.js"), module.exports);
|
|
35
|
+
__reExport(index_exports, require("./link-preview.js"), module.exports);
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
createCache,
|
|
39
|
+
createMutex,
|
|
40
|
+
createQueue,
|
|
41
|
+
createZip,
|
|
42
|
+
detectFileType,
|
|
43
|
+
detectMediaInfo,
|
|
44
|
+
encodeQR,
|
|
45
|
+
getAudioWaveform,
|
|
46
|
+
getFile,
|
|
47
|
+
...require("./http-error.js"),
|
|
48
|
+
...require("./keyed-db.js"),
|
|
49
|
+
...require("./link-preview.js")
|
|
50
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class KeyedDB {
|
|
2
|
+
constructor(key: any, id: any);
|
|
3
|
+
clear(): void;
|
|
4
|
+
insertIfAbsent(...values: any[]): any[];
|
|
5
|
+
upsert(...values: any[]): any[];
|
|
6
|
+
update(id: any, callback: any): 1 | 2 | undefined;
|
|
7
|
+
get(id: any): any;
|
|
8
|
+
deleteById(id: any, assertPresent?: boolean): any;
|
|
9
|
+
delete(value: any): any;
|
|
10
|
+
filter(predicate?: () => boolean): KeyedDB;
|
|
11
|
+
all(): any[];
|
|
12
|
+
toJSON(): any[];
|
|
13
|
+
#private;
|
|
14
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
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 keyed_db_exports = {};
|
|
19
|
+
__export(keyed_db_exports, {
|
|
20
|
+
KeyedDB: () => KeyedDB
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(keyed_db_exports);
|
|
23
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
24
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
25
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
26
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
27
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
28
|
+
};
|
|
29
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
30
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
31
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
32
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
33
|
+
};
|
|
34
|
+
var _KeyedDB_instances, _KeyedDB_spec, _KeyedDB_idGetter, _KeyedDB_items, _KeyedDB_byId, _KeyedDB_key, _KeyedDB_id, _KeyedDB_lowerBound, _KeyedDB_sameKey, _KeyedDB_insertNew;
|
|
35
|
+
function snapshotProperties(value) {
|
|
36
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return Object.getOwnPropertyDescriptors(value);
|
|
40
|
+
}
|
|
41
|
+
function restoreProperties(value, snapshot) {
|
|
42
|
+
if (!snapshot) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
46
|
+
if (!Object.prototype.hasOwnProperty.call(snapshot, key)) {
|
|
47
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
48
|
+
if (descriptor?.configurable) {
|
|
49
|
+
Reflect.deleteProperty(value, key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
Object.defineProperties(value, snapshot);
|
|
54
|
+
}
|
|
55
|
+
class KeyedDB {
|
|
56
|
+
constructor(key, id) {
|
|
57
|
+
_KeyedDB_instances.add(this);
|
|
58
|
+
_KeyedDB_spec.set(this, void 0);
|
|
59
|
+
_KeyedDB_idGetter.set(this, void 0);
|
|
60
|
+
_KeyedDB_items.set(this, []);
|
|
61
|
+
_KeyedDB_byId.set(this, /* @__PURE__ */ new Map());
|
|
62
|
+
if (typeof key?.key !== "function" || typeof key?.compare !== "function") {
|
|
63
|
+
throw new TypeError("key must provide key(value) and compare(a, b) functions");
|
|
64
|
+
}
|
|
65
|
+
if (id !== void 0 && typeof id !== "function") {
|
|
66
|
+
throw new TypeError("id must be a function");
|
|
67
|
+
}
|
|
68
|
+
__classPrivateFieldSet(this, _KeyedDB_spec, key, "f");
|
|
69
|
+
__classPrivateFieldSet(this, _KeyedDB_idGetter, id, "f");
|
|
70
|
+
}
|
|
71
|
+
clear() {
|
|
72
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").length = 0;
|
|
73
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").clear();
|
|
74
|
+
}
|
|
75
|
+
insertIfAbsent(...values) {
|
|
76
|
+
const inserted = [];
|
|
77
|
+
for (const value of values) {
|
|
78
|
+
if (!value) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const id = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
82
|
+
if (__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
86
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
87
|
+
if (index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 0, value);
|
|
91
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
92
|
+
inserted.push(value);
|
|
93
|
+
}
|
|
94
|
+
return inserted;
|
|
95
|
+
}
|
|
96
|
+
upsert(...values) {
|
|
97
|
+
const updated = [];
|
|
98
|
+
for (const value of values) {
|
|
99
|
+
if (!value) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const id = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
103
|
+
const previous = __classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id);
|
|
104
|
+
const exists = __classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id);
|
|
105
|
+
const key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
106
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
107
|
+
if (index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key) && __classPrivateFieldGet(this, _KeyedDB_items, "f")[index] !== previous) {
|
|
108
|
+
throw new Error(`duplicate key: ${String(key)}`);
|
|
109
|
+
}
|
|
110
|
+
if (!exists) {
|
|
111
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 0, value);
|
|
112
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const oldKey = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, previous);
|
|
116
|
+
const oldIndex = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, oldKey);
|
|
117
|
+
if (__classPrivateFieldGet(this, _KeyedDB_items, "f")[oldIndex] !== previous) {
|
|
118
|
+
throw new Error("KeyedDB index is inconsistent");
|
|
119
|
+
}
|
|
120
|
+
if (__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, oldKey, key)) {
|
|
121
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f")[oldIndex] = value;
|
|
122
|
+
} else {
|
|
123
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(oldIndex, 1);
|
|
124
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key), 0, value);
|
|
125
|
+
}
|
|
126
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
127
|
+
updated.push(value);
|
|
128
|
+
}
|
|
129
|
+
return updated;
|
|
130
|
+
}
|
|
131
|
+
update(id, callback) {
|
|
132
|
+
if (typeof callback !== "function") {
|
|
133
|
+
throw new TypeError("update must be a function");
|
|
134
|
+
}
|
|
135
|
+
if (!__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
const value = __classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id);
|
|
139
|
+
const oldId = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
140
|
+
const oldKey = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
141
|
+
const oldIndex = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, oldKey);
|
|
142
|
+
if (__classPrivateFieldGet(this, _KeyedDB_items, "f")[oldIndex] !== value) {
|
|
143
|
+
throw new Error("KeyedDB index is inconsistent");
|
|
144
|
+
}
|
|
145
|
+
const snapshot = snapshotProperties(value);
|
|
146
|
+
let removed = false;
|
|
147
|
+
try {
|
|
148
|
+
callback(value);
|
|
149
|
+
const nextId = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
150
|
+
const nextKey = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
151
|
+
if (!Object.is(nextId, oldId) && __classPrivateFieldGet(this, _KeyedDB_byId, "f").has(nextId)) {
|
|
152
|
+
throw new Error(`duplicate ID: ${String(nextId)}`);
|
|
153
|
+
}
|
|
154
|
+
if (__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, oldKey, nextKey)) {
|
|
155
|
+
if (!Object.is(nextId, oldId)) {
|
|
156
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").delete(oldId);
|
|
157
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(nextId, value);
|
|
158
|
+
}
|
|
159
|
+
return 1;
|
|
160
|
+
}
|
|
161
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(oldIndex, 1);
|
|
162
|
+
removed = true;
|
|
163
|
+
const nextIndex = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, nextKey);
|
|
164
|
+
if (nextIndex < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[nextIndex]), nextKey)) {
|
|
165
|
+
throw new Error(`duplicate key: ${String(nextKey)}`);
|
|
166
|
+
}
|
|
167
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(nextIndex, 0, value);
|
|
168
|
+
removed = false;
|
|
169
|
+
if (!Object.is(nextId, oldId)) {
|
|
170
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").delete(oldId);
|
|
171
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(nextId, value);
|
|
172
|
+
}
|
|
173
|
+
return 2;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
restoreProperties(value, snapshot);
|
|
176
|
+
if (removed) {
|
|
177
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(oldIndex, 0, value);
|
|
178
|
+
}
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
get(id) {
|
|
183
|
+
return __classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id);
|
|
184
|
+
}
|
|
185
|
+
deleteById(id, assertPresent = true) {
|
|
186
|
+
if (!__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
187
|
+
if (assertPresent) {
|
|
188
|
+
throw new Error("Value not found");
|
|
189
|
+
}
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
return this.delete(__classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id));
|
|
193
|
+
}
|
|
194
|
+
delete(value) {
|
|
195
|
+
if (value == null) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
const key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
199
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
200
|
+
if (index >= __classPrivateFieldGet(this, _KeyedDB_items, "f").length || !__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key)) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
const removed = __classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 1)[0];
|
|
204
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").delete(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, removed));
|
|
205
|
+
return removed;
|
|
206
|
+
}
|
|
207
|
+
filter(predicate = () => true) {
|
|
208
|
+
if (typeof predicate !== "function") {
|
|
209
|
+
throw new TypeError("predicate must be a function");
|
|
210
|
+
}
|
|
211
|
+
const result = new KeyedDB(__classPrivateFieldGet(this, _KeyedDB_spec, "f"), __classPrivateFieldGet(this, _KeyedDB_idGetter, "f"));
|
|
212
|
+
for (let index = 0; index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length; index++) {
|
|
213
|
+
const value = __classPrivateFieldGet(this, _KeyedDB_items, "f")[index];
|
|
214
|
+
if (predicate(value, index)) {
|
|
215
|
+
__classPrivateFieldGet(result, _KeyedDB_items, "f").push(value);
|
|
216
|
+
__classPrivateFieldGet(result, _KeyedDB_byId, "f").set(__classPrivateFieldGet(result, _KeyedDB_instances, "m", _KeyedDB_id).call(result, value), value);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
all() {
|
|
222
|
+
return __classPrivateFieldGet(this, _KeyedDB_items, "f").slice();
|
|
223
|
+
}
|
|
224
|
+
toJSON() {
|
|
225
|
+
return __classPrivateFieldGet(this, _KeyedDB_items, "f");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
_KeyedDB_spec = /* @__PURE__ */ new WeakMap(), _KeyedDB_idGetter = /* @__PURE__ */ new WeakMap(), _KeyedDB_items = /* @__PURE__ */ new WeakMap(), _KeyedDB_byId = /* @__PURE__ */ new WeakMap(), _KeyedDB_instances = /* @__PURE__ */ new WeakSet(), _KeyedDB_key = function _KeyedDB_key2(value) {
|
|
229
|
+
return __classPrivateFieldGet(this, _KeyedDB_spec, "f").key(value);
|
|
230
|
+
}, _KeyedDB_id = function _KeyedDB_id2(value) {
|
|
231
|
+
const id = __classPrivateFieldGet(this, _KeyedDB_idGetter, "f") ? __classPrivateFieldGet(this, _KeyedDB_idGetter, "f").call(this, value) : String(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value));
|
|
232
|
+
if (id == null) {
|
|
233
|
+
throw new TypeError("ID must not be null or undefined");
|
|
234
|
+
}
|
|
235
|
+
return id;
|
|
236
|
+
}, _KeyedDB_lowerBound = function _KeyedDB_lowerBound2(key) {
|
|
237
|
+
let low = 0;
|
|
238
|
+
let high = __classPrivateFieldGet(this, _KeyedDB_items, "f").length;
|
|
239
|
+
while (low < high) {
|
|
240
|
+
const mid = low + (high - low >>> 1);
|
|
241
|
+
if (__classPrivateFieldGet(this, _KeyedDB_spec, "f").compare(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[mid]), key) < 0) {
|
|
242
|
+
low = mid + 1;
|
|
243
|
+
} else {
|
|
244
|
+
high = mid;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return low;
|
|
248
|
+
}, _KeyedDB_sameKey = function _KeyedDB_sameKey2(a, b) {
|
|
249
|
+
return __classPrivateFieldGet(this, _KeyedDB_spec, "f").compare(a, b) === 0;
|
|
250
|
+
}, _KeyedDB_insertNew = function _KeyedDB_insertNew2(value, id = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value), key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value)) {
|
|
251
|
+
if (__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
252
|
+
throw new Error(`duplicate ID: ${String(id)}`);
|
|
253
|
+
}
|
|
254
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
255
|
+
if (index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key)) {
|
|
256
|
+
throw new Error(`duplicate key: ${String(key)}`);
|
|
257
|
+
}
|
|
258
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 0, value);
|
|
259
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
260
|
+
};
|
|
261
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
262
|
+
0 && (module.exports = {
|
|
263
|
+
KeyedDB
|
|
264
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getLinkPreview(url: any, timeout?: number): Promise<{
|
|
2
|
+
url: string;
|
|
3
|
+
title?: undefined;
|
|
4
|
+
description?: undefined;
|
|
5
|
+
favicon?: undefined;
|
|
6
|
+
image?: undefined;
|
|
7
|
+
video?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
url: string;
|
|
10
|
+
title: any;
|
|
11
|
+
description: any;
|
|
12
|
+
favicon: any;
|
|
13
|
+
image: any;
|
|
14
|
+
video: any;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,104 @@
|
|
|
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 link_preview_exports = {};
|
|
19
|
+
__export(link_preview_exports, {
|
|
20
|
+
getLinkPreview: () => getLinkPreview
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(link_preview_exports);
|
|
23
|
+
var import_Defaults = require("../Defaults/index.js");
|
|
24
|
+
var import_http_error = require("./http-error.js");
|
|
25
|
+
const MAX = 262144;
|
|
26
|
+
const TAG = /<(meta|link)\b([^>]*)>|<title[^>]*>([^<]*)/gi;
|
|
27
|
+
const ATTR = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/g;
|
|
28
|
+
const ENT = /&(?:#(\d+)|#x([\da-f]+)|(amp|lt|gt|quot|apos));/gi;
|
|
29
|
+
const MAP = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
|
|
30
|
+
const txt = (s) => s && s.replace(ENT, (_, d, h, n) => {
|
|
31
|
+
if (n)
|
|
32
|
+
return MAP[n.toLowerCase()];
|
|
33
|
+
const c = d ? +d : parseInt(h, 16);
|
|
34
|
+
return c <= 1114111 ? String.fromCodePoint(c) : "";
|
|
35
|
+
}).replace(/\s+/g, " ").trim();
|
|
36
|
+
async function readHead(res) {
|
|
37
|
+
let html = "";
|
|
38
|
+
for await (const chunk of res.body) {
|
|
39
|
+
html += import_Defaults.TEXT_DECODER.decode(chunk, { stream: true });
|
|
40
|
+
const i = html.search(/<\/head>|<body/i);
|
|
41
|
+
if (i !== -1)
|
|
42
|
+
return html.slice(0, i);
|
|
43
|
+
if (html.length > MAX)
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return html;
|
|
47
|
+
}
|
|
48
|
+
async function getLinkPreview(url, timeout = 3e3) {
|
|
49
|
+
const res = await fetch(url, {
|
|
50
|
+
signal: AbortSignal.timeout(timeout),
|
|
51
|
+
headers: {
|
|
52
|
+
Accept: "text/html",
|
|
53
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
54
|
+
"User-Agent": "Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (!res.ok)
|
|
58
|
+
throw new import_http_error.HttpError(`HTTP ${res.status} ${res.statusText}`);
|
|
59
|
+
if (!/html/i.test(res.headers.get("content-type") ?? "")) {
|
|
60
|
+
await res.body?.cancel();
|
|
61
|
+
return { url: res.url };
|
|
62
|
+
}
|
|
63
|
+
const base = res.url;
|
|
64
|
+
const abs = (v) => {
|
|
65
|
+
try {
|
|
66
|
+
return v && new URL(v, base).href;
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const m = {};
|
|
71
|
+
let title, icon;
|
|
72
|
+
for (const [, kind, attrs, t] of (await readHead(res)).matchAll(TAG)) {
|
|
73
|
+
if (t !== void 0) {
|
|
74
|
+
title ?? (title = t);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const a = {};
|
|
78
|
+
for (const x of attrs.matchAll(ATTR))
|
|
79
|
+
a[x[1].toLowerCase()] = x[2] ?? x[3] ?? x[4];
|
|
80
|
+
if (kind.toLowerCase() === "meta") {
|
|
81
|
+
const k = (a.property ?? a.name ?? a.itemprop)?.toLowerCase();
|
|
82
|
+
if (k && a.content)
|
|
83
|
+
m[k] ?? (m[k] = a.content);
|
|
84
|
+
} else if (a.href) {
|
|
85
|
+
const r = a.rel?.toLowerCase() ?? "";
|
|
86
|
+
if (/(^|\s)icon(\s|$)/.test(r))
|
|
87
|
+
icon ?? (icon = a.href);
|
|
88
|
+
else if (r === "image_src")
|
|
89
|
+
m.image_src ?? (m.image_src = a.href);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
url: base,
|
|
94
|
+
title: txt(m["og:title"] ?? m["twitter:title"] ?? title),
|
|
95
|
+
description: txt(m["og:description"] ?? m["twitter:description"] ?? m.description),
|
|
96
|
+
favicon: abs(icon ?? "/favicon.ico"),
|
|
97
|
+
image: abs(m["og:image"] ?? m["og:image:secure_url"] ?? m["twitter:image"] ?? m["twitter:image:src"] ?? m.image ?? m.image_src),
|
|
98
|
+
video: abs(m["og:video"] ?? m["og:video:secure_url"] ?? m["og:video:url"] ?? m["twitter:player:stream"])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
getLinkPreview
|
|
104
|
+
});
|