lordceaser-baileys 3.3.5 → 3.3.7
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/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/fix-imports.js +85 -0
- package/index.js +15 -6
- package/lib/Defaults/index.d.ts +75 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +15 -44
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +2 -1
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +2 -1
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +2 -1
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +1 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +2 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +2 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +2 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +2 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +2 -1
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +2 -1
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +2 -1
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +2 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +4 -1
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +23 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +6 -9
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +1 -0
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +2 -1
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +2 -1
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/Socket/Client/index.js +2 -0
- package/lib/Socket/Socket/Client/types.js +10 -0
- package/lib/Socket/Socket/Client/websocket.js +53 -0
- package/lib/Socket/Socket/business.js +407 -0
- package/lib/Socket/Socket/chats.js +1908 -0
- package/lib/Socket/Socket/communities.js +431 -0
- package/lib/Socket/Socket/groups.js +549 -0
- package/lib/Socket/Socket/index.js +37 -0
- package/lib/Socket/Socket/messages-recv.js +2144 -0
- package/lib/Socket/Socket/messages-send.js +3177 -0
- package/lib/Socket/Socket/mex.js +41 -0
- package/lib/Socket/Socket/newsletter.js +260 -0
- package/lib/Socket/Socket/socket.js +1017 -0
- package/lib/Socket/business.d.ts +217 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +42 -70
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +125 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +21 -731
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +273 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +1 -1
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts +161 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +5 -207
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +260 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +3 -28
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +203 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +9 -381
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +199 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +157 -2189
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +2 -1
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +170 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +19 -98
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +59 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +17 -64
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -1
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -1
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -1
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +2 -1
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +26 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -1
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -1
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -1
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +2 -1
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +2 -1
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +320 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +1 -8
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Mex.d.ts +141 -0
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +1 -3
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -1
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -1
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +136 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +2 -1
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +97 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +8 -0
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -1
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +2 -1
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/_crypto_orig.js +118 -0
- package/lib/Utils/auth-utils.d.ts +24 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +1 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +3 -2
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +2 -1
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +100 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +1 -22
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +17 -14
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +8 -117
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +66 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +2 -169
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +36 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +34 -1
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +30 -27
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +24 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +13 -29
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +44 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +3 -1
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +1 -17
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +4 -3
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +2 -1
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +2 -1
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +2 -1
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +115 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +26 -2
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +133 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +33 -251
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +91 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +69 -1328
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +2 -1
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +2 -1
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +2 -1
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +151 -114
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +2 -1
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/signal.d.ts +47 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +1 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +2 -1
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +3 -1
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +37 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +4 -2
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +2 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +6 -4
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1 -163
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +2 -1
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +2 -1
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +1 -115
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/{WABinary/index.js → lib/WABinary/index.d.ts} +1 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +1 -0
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +3 -2
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -1
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +2 -1
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +2 -1
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +2 -1
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +1 -0
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -7
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +3 -2
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +1 -7
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +30 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +23 -126
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +17 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +1 -24
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncContactProtocol.js +56 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/WAUSync/Protocols/index.js +12 -0
- package/lib/WAUSync/WAUSync/USyncQuery.js +201 -0
- package/lib/WAUSync/WAUSync/USyncUser.js +54 -0
- package/lib/WAUSync/WAUSync/index.js +3 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +2 -1
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +10 -648
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -0
- package/package.json +4 -3
- package/WABinary/constants.js +0 -1463
- package/WABinary/decode.js +0 -261
- package/WABinary/encode.js +0 -219
- package/WABinary/generic-utils.js +0 -227
- package/WABinary/jid-utils.js +0 -95
- package/WABinary/types.js +0 -1
- package/lib/Defaults/ban-checker.js +0 -44
- package/lib/Store/index.js +0 -4
- package/lib/Store/make-cache-manager-store.js +0 -89
- package/lib/Store/make-in-memory-store.js +0 -420
- package/lib/Store/make-ordered-dictionary.js +0 -78
- package/lib/Store/object-repository.js +0 -23
- package/lib/Types/RichType.js +0 -22
- package/lib/Utils/bot-capabilities.js +0 -84
- package/lib/Utils/bot-planning-replay.js +0 -165
- package/lib/Utils/channel-policy.js +0 -25
- package/lib/Utils/chat-utils.js[old] +0 -871
- package/lib/Utils/consumer-application.js +0 -102
- package/lib/Utils/games/miniapp.js +0 -5
- package/lib/Utils/games/slot-machine.js +0 -258
- package/lib/Utils/games/website-preview.js +0 -294
- package/lib/Utils/games/website-preview.js[bug] +0 -293
- package/lib/Utils/generics.js@old +0 -385
- package/lib/Utils/group-history.js +0 -56
- package/lib/Utils/jid-display-normalization.js +0 -209
- package/lib/Utils/message-composer.js +0 -467
- package/lib/Utils/message-inspect.js +0 -67
- package/lib/Utils/messages-media.js[old] +0 -916
- package/lib/Utils/messages.js[old] +0 -1902
- package/lib/Utils/meta-ai-msmsg.js +0 -203
- package/lib/Utils/meta-compositing.js +0 -227
- package/lib/Utils/native-flow.js +0 -100
- package/lib/Utils/rich-message-utils.js +0 -1895
- package/lib/Utils/rich-message-utils.js[Old] +0 -387
- package/lib/Utils/source-grep.js +0 -45
- package/lib/Utils/use-single-file-auth-state.js +0 -96
- package/lib/Utils/use-sqlite-auth-state.js +0 -108
- package/lib/Utils/view-once-utils.js +0 -206
- package/lib/Utils/voip-rekey.js +0 -20
- package/lib/Utils/welcome-flow.js +0 -216
- /package/lib/Socket/{aigroups.js → Socket/aigroups.js} +0 -0
- /package/lib/Socket/{ban-checker.js → Socket/ban-checker.js} +0 -0
- /package/lib/Socket/{chats.js[old] → Socket/chats.js[old]} +0 -0
- /package/lib/Socket/{graphql.js → Socket/graphql.js} +0 -0
- /package/lib/Socket/{groups.js[old] → Socket/groups.js[old]} +0 -0
- /package/lib/Socket/{interactive-handler.js → Socket/interactive-handler.js} +0 -0
- /package/lib/Socket/{interop.js → Socket/interop.js} +0 -0
- /package/lib/Socket/{managed-account.js → Socket/managed-account.js} +0 -0
- /package/lib/Socket/{privacy.js → Socket/privacy.js} +0 -0
- /package/lib/Socket/{registration.js → Socket/registration.js} +0 -0
- /package/lib/Socket/{username.js → Socket/username.js} +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncBusinessProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncFeatureProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncPictureProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncSidelistProtocol.js +0 -0
- /package/lib/WAUSync/{Protocols → WAUSync/Protocols}/USyncTextStatusProtocol.js +0 -0
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Website Preview — Mirror any website inside WhatsApp chat
|
|
3
|
-
*
|
|
4
|
-
* Fetches an external website and renders it directly inside the chat bubble
|
|
5
|
-
* using FOAHtmlPrimitiveDemoDONOTUSE. The content is inlined (no iframe)
|
|
6
|
-
* so it works in WhatsApp's sandboxed WebView.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* const { generateWebsitePreviewHtml } = require('./website-preview');
|
|
10
|
-
* const html = await generateWebsitePreviewHtml('https://example.com');
|
|
11
|
-
* await sock.sendHtmlMessage(jid, { html });
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Fetch a website and return a self-contained HTML string
|
|
16
|
-
* that renders directly inside WhatsApp's chat bubble.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} url - The website URL to mirror
|
|
19
|
-
* @param {Object} [options]
|
|
20
|
-
* @param {string} [options.height='600px'] - Preview height
|
|
21
|
-
* @param {boolean} [options.showUrl=true] - Show the URL bar
|
|
22
|
-
* @param {boolean} [options.showToolbar=true] - Show toolbar with open link button
|
|
23
|
-
* @param {string} [options.theme='dark'] - 'dark' or 'light'
|
|
24
|
-
* @returns {string} Self-contained HTML string
|
|
25
|
-
*/
|
|
26
|
-
export const generateWebsitePreviewHtml = async (url, options = {}) => {
|
|
27
|
-
const { height = '600px', showUrl = true, showToolbar = true, theme = 'dark' } = options;
|
|
28
|
-
const baseUrl = new URL(url);
|
|
29
|
-
const isDark = theme === 'dark';
|
|
30
|
-
|
|
31
|
-
let fetchedHtml = '';
|
|
32
|
-
let fetchError = false;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const response = await fetch(url, {
|
|
36
|
-
headers: {
|
|
37
|
-
'User-Agent': 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
|
|
38
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
39
|
-
'Accept-Language': 'en-US,en;q=0.5'
|
|
40
|
-
},
|
|
41
|
-
redirect: 'follow',
|
|
42
|
-
signal: AbortSignal.timeout(10000)
|
|
43
|
-
});
|
|
44
|
-
fetchedHtml = await response.text();
|
|
45
|
-
} catch (err) {
|
|
46
|
-
fetchError = true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Extract useful parts from fetched HTML
|
|
50
|
-
const extracted = extractContent(fetchedHtml, url);
|
|
51
|
-
|
|
52
|
-
const bg = isDark ? '#0a0a0a' : '#ffffff';
|
|
53
|
-
const text = isDark ? '#e0e0e0' : '#1a1a1a';
|
|
54
|
-
const textMuted = isDark ? '#888' : '#666';
|
|
55
|
-
const border = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)';
|
|
56
|
-
const barBg = isDark ? '#1a1a2e' : '#f5f5f5';
|
|
57
|
-
const linkColor = '#4CAF50';
|
|
58
|
-
|
|
59
|
-
return `<html><head><style>
|
|
60
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
61
|
-
html,body{width:100%;height:100%;overflow:hidden;background:${bg};font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif}
|
|
62
|
-
.webview{width:100%;height:${height};position:relative;border-radius:12px;overflow:hidden;border:1px solid ${border};background:${bg}}
|
|
63
|
-
|
|
64
|
-
/* URL Bar */
|
|
65
|
-
.url-bar{display:flex;align-items:center;gap:8px;padding:8px 12px;background:${barBg};border-bottom:1px solid ${border};font-size:12px}
|
|
66
|
-
.url-bar .lock{color:${linkColor};font-size:11px}
|
|
67
|
-
.url-bar .url{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:${textMuted}}
|
|
68
|
-
.url-bar .refresh{cursor:pointer;color:${linkColor};padding:4px;font-size:14px}
|
|
69
|
-
|
|
70
|
-
/* Content Area */
|
|
71
|
-
.content{width:100%;height:calc(100% - ${showUrl ? '36px' : '0px'} - ${showToolbar ? '44px' : '0px'});overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:thin;scrollbar-color:${isDark ? '#333' : '#ccc'} transparent}
|
|
72
|
-
.content::-webkit-scrollbar{width:4px}
|
|
73
|
-
.content::-webkit-scrollbar-thumb{background:${isDark ? '#333' : '#ccc'};border-radius:2px}
|
|
74
|
-
|
|
75
|
-
/* Extracted site content */
|
|
76
|
-
.site-title{font-size:18px;font-weight:700;color:${text};margin-bottom:8px}
|
|
77
|
-
.site-desc{font-size:13px;color:${textMuted};line-height:1.5;margin-bottom:12px}
|
|
78
|
-
.site-text{font-size:14px;color:${text};line-height:1.7}
|
|
79
|
-
.site-text a{color:${linkColor};text-decoration:none}
|
|
80
|
-
.site-text img{max-width:100%;height:auto;border-radius:8px;margin:8px 0;display:block}
|
|
81
|
-
.site-headings{font-size:15px;font-weight:600;color:${text};margin:16px 0 6px}
|
|
82
|
-
.site-list{padding-left:18px;font-size:13px;color:${text};line-height:1.8}
|
|
83
|
-
.site-links{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
|
84
|
-
.site-link{display:inline-block;padding:4px 10px;background:${barBg};border:1px solid ${border};border-radius:6px;font-size:12px;color:${linkColor};text-decoration:none}
|
|
85
|
-
.site-images{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;margin:10px 0}
|
|
86
|
-
.site-images img{width:100%;height:80px;object-fit:cover;border-radius:6px;background:${barBg}}
|
|
87
|
-
|
|
88
|
-
/* Error / Fallback state */
|
|
89
|
-
.error-state{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:30px;text-align:center}
|
|
90
|
-
.error-state .icon{font-size:48px;margin-bottom:12px}
|
|
91
|
-
.error-state h3{font-size:16px;color:${text};margin-bottom:6px}
|
|
92
|
-
.error-state p{font-size:13px;color:${textMuted};margin-bottom:16px;line-height:1.5}
|
|
93
|
-
|
|
94
|
-
/* Toolbar */
|
|
95
|
-
.toolbar{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-top:1px solid ${border};background:${barBg}}
|
|
96
|
-
.toolbar .site-info{display:flex;align-items:center;gap:6px;font-size:11px;color:${textMuted}}
|
|
97
|
-
.toolbar .site-favicon{width:14px;height:14px;border-radius:3px;background:${border}}
|
|
98
|
-
.toolbar .open-btn{display:inline-flex;align-items:center;gap:5px;padding:6px 14px;background:${linkColor};color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:600;text-decoration:none;cursor:pointer}
|
|
99
|
-
</style></head><body>
|
|
100
|
-
<div class="webview">
|
|
101
|
-
${showUrl ? `
|
|
102
|
-
<div class="url-bar">
|
|
103
|
-
<span class="lock">🔒</span>
|
|
104
|
-
<span class="url">${baseUrl.hostname}${baseUrl.pathname.length > 1 ? baseUrl.pathname.substring(0, 30) + '...' : ''}</span>
|
|
105
|
-
<span class="refresh" onclick="location.reload()">↻</span>
|
|
106
|
-
</div>` : ''}
|
|
107
|
-
|
|
108
|
-
<div class="content">
|
|
109
|
-
${fetchError ? `
|
|
110
|
-
<div class="error-state">
|
|
111
|
-
<div class="icon">🌐</div>
|
|
112
|
-
<h3>${baseUrl.hostname}</h3>
|
|
113
|
-
<p>Could not load this website directly. Tap the button below to open it in your browser.</p>
|
|
114
|
-
<a href="${url}" style="display:inline-flex;align-items:center;gap:5px;padding:10px 20px;background:${linkColor};color:#fff;border-radius:8px;text-decoration:none;font-size:13px;font-weight:600">🔗 Open Website</a>
|
|
115
|
-
</div>` : `
|
|
116
|
-
${extracted.title ? `<div style="padding:16px">` : `<div style="padding:16px">`}
|
|
117
|
-
${extracted.favicon ? `<img src="${extracted.favicon}" style="width:20px;height:20px;border-radius:4px;margin-bottom:8px" onerror="this.style.display='none'">` : ''}
|
|
118
|
-
${extracted.title ? `<div class="site-title">${escapeHtml(extracted.title)}</div>` : ''}
|
|
119
|
-
${extracted.description ? `<div class="site-desc">${escapeHtml(extracted.description)}</div>` : ''}
|
|
120
|
-
${extracted.heroImage ? `<img src="${escapeHtml(extracted.heroImage)}" style="width:100%;border-radius:8px;margin-bottom:12px" onerror="this.style.display='none'">` : ''}
|
|
121
|
-
${extracted.images.length > 0 ? `
|
|
122
|
-
<div class="site-images">
|
|
123
|
-
${extracted.images.slice(0, 6).map(img => `<img src="${escapeHtml(img)}" onerror="this.style.display='none'" loading="lazy">`).join('')}
|
|
124
|
-
</div>` : ''}
|
|
125
|
-
${extracted.headings.length > 0 ? extracted.headings.slice(0, 5).map(h => `<div class="site-headings">${escapeHtml(h)}</div>`).join('') : ''}
|
|
126
|
-
${extracted.text ? `<div class="site-text">${escapeHtml(extracted.text).substring(0, 2000)}</div>` : ''}
|
|
127
|
-
${extracted.links.length > 0 ? `
|
|
128
|
-
<div class="site-links">
|
|
129
|
-
${extracted.links.slice(0, 8).map(l => `<a href="${escapeHtml(l.url)}" class="site-link">${escapeHtml(l.text)}</a>`).join('')}
|
|
130
|
-
</div>` : ''}
|
|
131
|
-
</div>`}
|
|
132
|
-
</div>
|
|
133
|
-
|
|
134
|
-
${showToolbar ? `
|
|
135
|
-
<div class="toolbar">
|
|
136
|
-
<div class="site-info">
|
|
137
|
-
<div class="site-favicon"></div>
|
|
138
|
-
<span>${baseUrl.hostname}</span>
|
|
139
|
-
</div>
|
|
140
|
-
<a href="${url}" class="open-btn">🔗 Open Site</a>
|
|
141
|
-
</div>` : ''}
|
|
142
|
-
</div>
|
|
143
|
-
</body></html>`;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Extract meaningful content from fetched HTML
|
|
148
|
-
*/
|
|
149
|
-
function extractContent(html, baseUrl) {
|
|
150
|
-
if (!html) return { title: '', description: '', text: '', headings: [], links: [], images: [], favicon: '', heroImage: '' };
|
|
151
|
-
|
|
152
|
-
const base = new URL(baseUrl);
|
|
153
|
-
|
|
154
|
-
// Title
|
|
155
|
-
const titleMatch = html.match(/<title[^>]*>([^<]+)<\/title>/i);
|
|
156
|
-
let title = titleMatch ? titleMatch[1].trim() : '';
|
|
157
|
-
|
|
158
|
-
// Meta description
|
|
159
|
-
const descMatch = html.match(/<meta[^>]*name=["']description["'][^>]*content=["']([^"']+)["']/i)
|
|
160
|
-
|| html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*name=["']description["']/i);
|
|
161
|
-
const description = descMatch ? descMatch[1].trim() : '';
|
|
162
|
-
|
|
163
|
-
// Favicon
|
|
164
|
-
const faviconMatch = html.match(/<link[^>]*rel=["'](?:shortcut )?icon["'][^>]*href=["']([^"']+)["']/i);
|
|
165
|
-
let favicon = faviconMatch ? resolveUrl(faviconMatch[1], base) : `${base.origin}/favicon.ico`;
|
|
166
|
-
|
|
167
|
-
// Hero image (og:image)
|
|
168
|
-
const ogImageMatch = html.match(/<meta[^>]*property=["']og:image["'][^>]*content=["']([^"']+)["']/i)
|
|
169
|
-
|| html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*property=["']og:image["']/i);
|
|
170
|
-
const heroImage = ogImageMatch ? resolveUrl(ogImageMatch[1], base) : '';
|
|
171
|
-
|
|
172
|
-
// Extract headings
|
|
173
|
-
const headings = [];
|
|
174
|
-
const headingRegex = /<h[1-6][^>]*>([^<]+)<\/h[1-6]>/gi;
|
|
175
|
-
let hm;
|
|
176
|
-
while ((hm = headingRegex.exec(html)) !== null) {
|
|
177
|
-
headings.push(hm[1].trim());
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Extract links
|
|
181
|
-
const links = [];
|
|
182
|
-
const linkRegex = /<a[^>]*href=["']([^"']+)["'][^>]*>([^<]*)<\/a>/gi;
|
|
183
|
-
let lm;
|
|
184
|
-
while ((lm = linkRegex.exec(html)) !== null) {
|
|
185
|
-
const href = lm[1].trim();
|
|
186
|
-
const text = lm[2].trim();
|
|
187
|
-
if (text && href && !href.startsWith('#') && !href.startsWith('javascript:')) {
|
|
188
|
-
links.push({ text: text.substring(0, 50), url: resolveUrl(href, base) });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Extract images
|
|
193
|
-
const images = [];
|
|
194
|
-
const imgRegex = /<img[^>]*src=["']([^"']+)["'][^>]*>/gi;
|
|
195
|
-
let im;
|
|
196
|
-
while ((im = imgRegex.exec(html)) !== null) {
|
|
197
|
-
const src = im[1].trim();
|
|
198
|
-
if (src && !src.startsWith('data:')) {
|
|
199
|
-
images.push(resolveUrl(src, base));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Extract text content (strip tags)
|
|
204
|
-
let text = html
|
|
205
|
-
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
|
206
|
-
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
|
|
207
|
-
.replace(/<nav[^>]*>[\s\S]*?<\/nav>/gi, '')
|
|
208
|
-
.replace(/<footer[^>]*>[\s\S]*?<\/footer>/gi, '')
|
|
209
|
-
.replace(/<header[^>]*>[\s\S]*?<\/header>/gi, '')
|
|
210
|
-
.replace(/<[^>]+>/g, ' ')
|
|
211
|
-
.replace(/ /g, ' ')
|
|
212
|
-
.replace(/&/g, '&')
|
|
213
|
-
.replace(/</g, '<')
|
|
214
|
-
.replace(/>/g, '>')
|
|
215
|
-
.replace(/"/g, '"')
|
|
216
|
-
.replace(/'/g, "'")
|
|
217
|
-
.replace(/\s+/g, ' ')
|
|
218
|
-
.trim();
|
|
219
|
-
|
|
220
|
-
// Take a reasonable chunk of text
|
|
221
|
-
if (text.length > 2000) {
|
|
222
|
-
text = text.substring(0, 2000) + '...';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return { title, description, text, headings: headings.slice(0, 10), links: links.slice(0, 20), images: images.slice(0, 12), favicon, heroImage };
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Resolve a relative URL against a base
|
|
230
|
-
*/
|
|
231
|
-
function resolveUrl(href, base) {
|
|
232
|
-
try {
|
|
233
|
-
if (href.startsWith('http://') || href.startsWith('https://')) return href;
|
|
234
|
-
if (href.startsWith('//')) return base.protocol + href;
|
|
235
|
-
return new URL(href, base).href;
|
|
236
|
-
} catch {
|
|
237
|
-
return href;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Escape HTML entities for safe embedding
|
|
243
|
-
*/
|
|
244
|
-
function escapeHtml(str) {
|
|
245
|
-
if (!str) return '';
|
|
246
|
-
return String(str)
|
|
247
|
-
.replace(/&/g, '&')
|
|
248
|
-
.replace(/</g, '<')
|
|
249
|
-
.replace(/>/g, '>')
|
|
250
|
-
.replace(/"/g, '"')
|
|
251
|
-
.replace(/'/g, ''');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Generate a simple link preview (thumbnail + title + description)
|
|
256
|
-
* without fetching — lighter weight alternative.
|
|
257
|
-
*
|
|
258
|
-
* @param {string} url - The URL to preview
|
|
259
|
-
* @param {Object} [options]
|
|
260
|
-
* @param {string} [options.title] - Override title
|
|
261
|
-
* @param {string} [options.description] - Override description
|
|
262
|
-
* @param {string} [options.image] - Override image URL
|
|
263
|
-
* @returns {string} HTML string for link preview card
|
|
264
|
-
*/
|
|
265
|
-
export const generateLinkPreviewHtml = (url, options = {}) => {
|
|
266
|
-
const { title, description, image } = options;
|
|
267
|
-
const baseUrl = new URL(url);
|
|
268
|
-
|
|
269
|
-
return `<html><head><style>
|
|
270
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
271
|
-
body{background:transparent;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;padding:0}
|
|
272
|
-
.card{background:#1a1a2e;border:1px solid rgba(255,255,255,0.1);border-radius:12px;overflow:hidden;max-width:100%}
|
|
273
|
-
.card-image{width:100%;height:160px;object-fit:cover;background:linear-gradient(135deg,#1a1a2e,#2d2d44)}
|
|
274
|
-
.card-body{padding:14px}
|
|
275
|
-
.card-title{font-size:16px;font-weight:600;color:#fff;margin-bottom:4px}
|
|
276
|
-
.card-desc{font-size:13px;color:#aaa;line-height:1.4;margin-bottom:8px}
|
|
277
|
-
.card-url{font-size:11px;color:#4CAF50;display:flex;align-items:center;gap:4px}
|
|
278
|
-
</style></head><body>
|
|
279
|
-
<a href="${url}" target="_blank" style="text-decoration:none">
|
|
280
|
-
<div class="card">
|
|
281
|
-
${image ? `<img class="card-image" src="${image}" alt="" onerror="this.style.display='none'">` :
|
|
282
|
-
`<div class="card-image" style="display:flex;align-items:center;justify-content:center;font-size:48px">🌐</div>`}
|
|
283
|
-
<div class="card-body">
|
|
284
|
-
<div class="card-title">${escapeHtml(title || baseUrl.hostname)}</div>
|
|
285
|
-
<div class="card-desc">${escapeHtml(description || 'Click to visit ' + baseUrl.hostname)}</div>
|
|
286
|
-
<div class="card-url">🔒 ${baseUrl.hostname}</div>
|
|
287
|
-
</div>
|
|
288
|
-
</div>
|
|
289
|
-
</a>
|
|
290
|
-
</body></html>`;
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export default generateWebsitePreviewHtml;
|
|
294
|
-
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Website Preview — Mirror any website inside WhatsApp chat
|
|
3
|
-
*
|
|
4
|
-
* Fetches an external website and renders it directly inside the chat bubble
|
|
5
|
-
* using FOAHtmlPrimitiveDemoDONOTUSE. The content is inlined (no iframe)
|
|
6
|
-
* so it works in WhatsApp's sandboxed WebView.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* const { generateWebsitePreviewHtml } = require('./website-preview');
|
|
10
|
-
* const html = await generateWebsitePreviewHtml('https://example.com');
|
|
11
|
-
* await sock.sendHtmlMessage(jid, { html });
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Fetch a website and return a self-contained HTML string
|
|
16
|
-
* that renders directly inside WhatsApp's chat bubble.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} url - The website URL to mirror
|
|
19
|
-
* @param {Object} [options]
|
|
20
|
-
* @param {string} [options.height='600px'] - Preview height
|
|
21
|
-
* @param {boolean} [options.showUrl=true] - Show the URL bar
|
|
22
|
-
* @param {boolean} [options.showToolbar=true] - Show toolbar with open link button
|
|
23
|
-
* @param {string} [options.theme='dark'] - 'dark' or 'light'
|
|
24
|
-
* @returns {string} Self-contained HTML string
|
|
25
|
-
*/
|
|
26
|
-
export const generateWebsitePreviewHtml = async (url, options = {}) => {
|
|
27
|
-
const { height = '600px', showUrl = true, showToolbar = true, theme = 'dark' } = options;
|
|
28
|
-
const baseUrl = new URL(url);
|
|
29
|
-
const isDark = theme === 'dark';
|
|
30
|
-
|
|
31
|
-
let fetchedHtml = '';
|
|
32
|
-
let fetchError = false;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const response = await fetch(url, {
|
|
36
|
-
headers: {
|
|
37
|
-
'User-Agent': 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
|
|
38
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
39
|
-
'Accept-Language': 'en-US,en;q=0.5'
|
|
40
|
-
},
|
|
41
|
-
redirect: 'follow',
|
|
42
|
-
signal: AbortSignal.timeout(10000)
|
|
43
|
-
});
|
|
44
|
-
fetchedHtml = await response.text();
|
|
45
|
-
} catch (err) {
|
|
46
|
-
fetchError = true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Extract useful parts from fetched HTML
|
|
50
|
-
const extracted = extractContent(fetchedHtml, url);
|
|
51
|
-
|
|
52
|
-
const bg = isDark ? '#0a0a0a' : '#ffffff';
|
|
53
|
-
const text = isDark ? '#e0e0e0' : '#1a1a1a';
|
|
54
|
-
const textMuted = isDark ? '#888' : '#666';
|
|
55
|
-
const border = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)';
|
|
56
|
-
const barBg = isDark ? '#1a1a2e' : '#f5f5f5';
|
|
57
|
-
const linkColor = '#4CAF50';
|
|
58
|
-
|
|
59
|
-
return `<html><head><style>
|
|
60
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
61
|
-
html,body{width:100%;height:100%;overflow:hidden;background:${bg};font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif}
|
|
62
|
-
.webview{width:100%;height:${height};position:relative;border-radius:12px;overflow:hidden;border:1px solid ${border};background:${bg}}
|
|
63
|
-
|
|
64
|
-
/* URL Bar */
|
|
65
|
-
.url-bar{display:flex;align-items:center;gap:8px;padding:8px 12px;background:${barBg};border-bottom:1px solid ${border};font-size:12px}
|
|
66
|
-
.url-bar .lock{color:${linkColor};font-size:11px}
|
|
67
|
-
.url-bar .url{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:${textMuted}}
|
|
68
|
-
.url-bar .refresh{cursor:pointer;color:${linkColor};padding:4px;font-size:14px}
|
|
69
|
-
|
|
70
|
-
/* Content Area */
|
|
71
|
-
.content{width:100%;height:calc(100% - ${showUrl ? '36px' : '0px'} - ${showToolbar ? '44px' : '0px'});overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:thin;scrollbar-color:${isDark ? '#333' : '#ccc'} transparent}
|
|
72
|
-
.content::-webkit-scrollbar{width:4px}
|
|
73
|
-
.content::-webkit-scrollbar-thumb{background:${isDark ? '#333' : '#ccc'};border-radius:2px}
|
|
74
|
-
|
|
75
|
-
/* Extracted site content */
|
|
76
|
-
.site-title{font-size:18px;font-weight:700;color:${text};margin-bottom:8px}
|
|
77
|
-
.site-desc{font-size:13px;color:${textMuted};line-height:1.5;margin-bottom:12px}
|
|
78
|
-
.site-text{font-size:14px;color:${text};line-height:1.7}
|
|
79
|
-
.site-text a{color:${linkColor};text-decoration:none}
|
|
80
|
-
.site-text img{max-width:100%;height:auto;border-radius:8px;margin:8px 0;display:block}
|
|
81
|
-
.site-headings{font-size:15px;font-weight:600;color:${text};margin:16px 0 6px}
|
|
82
|
-
.site-list{padding-left:18px;font-size:13px;color:${text};line-height:1.8}
|
|
83
|
-
.site-links{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
|
84
|
-
.site-link{display:inline-block;padding:4px 10px;background:${barBg};border:1px solid ${border};border-radius:6px;font-size:12px;color:${linkColor};text-decoration:none}
|
|
85
|
-
.site-images{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;margin:10px 0}
|
|
86
|
-
.site-images img{width:100%;height:80px;object-fit:cover;border-radius:6px;background:${barBg}}
|
|
87
|
-
|
|
88
|
-
/* Error / Fallback state */
|
|
89
|
-
.error-state{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:30px;text-align:center}
|
|
90
|
-
.error-state .icon{font-size:48px;margin-bottom:12px}
|
|
91
|
-
.error-state h3{font-size:16px;color:${text};margin-bottom:6px}
|
|
92
|
-
.error-state p{font-size:13px;color:${textMuted};margin-bottom:16px;line-height:1.5}
|
|
93
|
-
|
|
94
|
-
/* Toolbar */
|
|
95
|
-
.toolbar{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-top:1px solid ${border};background:${barBg}}
|
|
96
|
-
.toolbar .site-info{display:flex;align-items:center;gap:6px;font-size:11px;color:${textMuted]}
|
|
97
|
-
.toolbar .site-favicon{width:14px;height:14px;border-radius:3px;background:${border}}
|
|
98
|
-
.toolbar .open-btn{display:inline-flex;align-items:center;gap:5px;padding:6px 14px;background:${linkColor};color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:600;text-decoration:none;cursor:pointer}
|
|
99
|
-
</style></head><body>
|
|
100
|
-
<div class="webview">
|
|
101
|
-
${showUrl ? `
|
|
102
|
-
<div class="url-bar">
|
|
103
|
-
<span class="lock">🔒</span>
|
|
104
|
-
<span class="url">${baseUrl.hostname}${baseUrl.pathname.length > 1 ? baseUrl.pathname.substring(0, 30) + '...' : ''}</span>
|
|
105
|
-
<span class="refresh" onclick="location.reload()">↻</span>
|
|
106
|
-
</div>` : ''}
|
|
107
|
-
|
|
108
|
-
<div class="content">
|
|
109
|
-
${fetchError ? `
|
|
110
|
-
<div class="error-state">
|
|
111
|
-
<div class="icon">🌐</div>
|
|
112
|
-
<h3>${baseUrl.hostname}</h3>
|
|
113
|
-
<p>Could not load this website directly. Tap the button below to open it in your browser.</p>
|
|
114
|
-
<a href="${url}" style="display:inline-flex;align-items:center;gap:5px;padding:10px 20px;background:${linkColor};color:#fff;border-radius:8px;text-decoration:none;font-size:13px;font-weight:600">🔗 Open Website</a>
|
|
115
|
-
</div>` : `
|
|
116
|
-
${extracted.title ? `<div style="padding:16px">` : `<div style="padding:16px">`}
|
|
117
|
-
${extracted.favicon ? `<img src="${extracted.favicon}" style="width:20px;height:20px;border-radius:4px;margin-bottom:8px" onerror="this.style.display='none'">` : ''}
|
|
118
|
-
${extracted.title ? `<div class="site-title">${escapeHtml(extracted.title)}</div>` : ''}
|
|
119
|
-
${extracted.description ? `<div class="site-desc">${escapeHtml(extracted.description)}</div>` : ''}
|
|
120
|
-
${extracted.heroImage ? `<img src="${escapeHtml(extracted.heroImage)}" style="width:100%;border-radius:8px;margin-bottom:12px" onerror="this.style.display='none'">` : ''}
|
|
121
|
-
${extracted.images.length > 0 ? `
|
|
122
|
-
<div class="site-images">
|
|
123
|
-
${extracted.images.slice(0, 6).map(img => `<img src="${escapeHtml(img)}" onerror="this.style.display='none'" loading="lazy">`).join('')}
|
|
124
|
-
</div>` : ''}
|
|
125
|
-
${extracted.headings.length > 0 ? extracted.headings.slice(0, 5).map(h => `<div class="site-headings">${escapeHtml(h)}</div>`).join('') : ''}
|
|
126
|
-
${extracted.text ? `<div class="site-text">${escapeHtml(extracted.text).substring(0, 2000)}</div>` : ''}
|
|
127
|
-
${extracted.links.length > 0 ? `
|
|
128
|
-
<div class="site-links">
|
|
129
|
-
${extracted.links.slice(0, 8).map(l => `<a href="${escapeHtml(l.url)}" class="site-link">${escapeHtml(l.text)}</a>`).join('')}
|
|
130
|
-
</div>` : ''}
|
|
131
|
-
</div>`}
|
|
132
|
-
</div>
|
|
133
|
-
|
|
134
|
-
${showToolbar ? `
|
|
135
|
-
<div class="toolbar">
|
|
136
|
-
<div class="site-info">
|
|
137
|
-
<div class="site-favicon"></div>
|
|
138
|
-
<span>${baseUrl.hostname}</span>
|
|
139
|
-
</div>
|
|
140
|
-
<a href="${url}" class="open-btn">🔗 Open Site</a>
|
|
141
|
-
</div>` : ''}
|
|
142
|
-
</div>
|
|
143
|
-
</body></html>`;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Extract meaningful content from fetched HTML
|
|
148
|
-
*/
|
|
149
|
-
function extractContent(html, baseUrl) {
|
|
150
|
-
if (!html) return { title: '', description: '', text: '', headings: [], links: [], images: [], favicon: '', heroImage: '' };
|
|
151
|
-
|
|
152
|
-
const base = new URL(baseUrl);
|
|
153
|
-
|
|
154
|
-
// Title
|
|
155
|
-
const titleMatch = html.match(/<title[^>]*>([^<]+)<\/title>/i);
|
|
156
|
-
let title = titleMatch ? titleMatch[1].trim() : '';
|
|
157
|
-
|
|
158
|
-
// Meta description
|
|
159
|
-
const descMatch = html.match(/<meta[^>]*name=["']description["'][^>]*content=["']([^"']+)["']/i)
|
|
160
|
-
|| html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*name=["']description["']/i);
|
|
161
|
-
const description = descMatch ? descMatch[1].trim() : '';
|
|
162
|
-
|
|
163
|
-
// Favicon
|
|
164
|
-
const faviconMatch = html.match(/<link[^>]*rel=["'](?:shortcut )?icon["'][^>]*href=["']([^"']+)["']/i);
|
|
165
|
-
let favicon = faviconMatch ? resolveUrl(faviconMatch[1], base) : `${base.origin}/favicon.ico`;
|
|
166
|
-
|
|
167
|
-
// Hero image (og:image)
|
|
168
|
-
const ogImageMatch = html.match(/<meta[^>]*property=["']og:image["'][^>]*content=["']([^"']+)["']/i)
|
|
169
|
-
|| html.match(/<meta[^>]*content=["']([^"']+)["'][^>]*property=["']og:image["']/i);
|
|
170
|
-
const heroImage = ogImageMatch ? resolveUrl(ogImageMatch[1], base) : '';
|
|
171
|
-
|
|
172
|
-
// Extract headings
|
|
173
|
-
const headings = [];
|
|
174
|
-
const headingRegex = /<h[1-6][^>]*>([^<]+)<\/h[1-6]>/gi;
|
|
175
|
-
let hm;
|
|
176
|
-
while ((hm = headingRegex.exec(html)) !== null) {
|
|
177
|
-
headings.push(hm[1].trim());
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Extract links
|
|
181
|
-
const links = [];
|
|
182
|
-
const linkRegex = /<a[^>]*href=["']([^"']+)["'][^>]*>([^<]*)<\/a>/gi;
|
|
183
|
-
let lm;
|
|
184
|
-
while ((lm = linkRegex.exec(html)) !== null) {
|
|
185
|
-
const href = lm[1].trim();
|
|
186
|
-
const text = lm[2].trim();
|
|
187
|
-
if (text && href && !href.startsWith('#') && !href.startsWith('javascript:')) {
|
|
188
|
-
links.push({ text: text.substring(0, 50), url: resolveUrl(href, base) });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Extract images
|
|
193
|
-
const images = [];
|
|
194
|
-
const imgRegex = /<img[^>]*src=["']([^"']+)["'][^>]*>/gi;
|
|
195
|
-
let im;
|
|
196
|
-
while ((im = imgRegex.exec(html)) !== null) {
|
|
197
|
-
const src = im[1].trim();
|
|
198
|
-
if (src && !src.startsWith('data:')) {
|
|
199
|
-
images.push(resolveUrl(src, base));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Extract text content (strip tags)
|
|
204
|
-
let text = html
|
|
205
|
-
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
|
206
|
-
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
|
|
207
|
-
.replace(/<nav[^>]*>[\s\S]*?<\/nav>/gi, '')
|
|
208
|
-
.replace(/<footer[^>]*>[\s\S]*?<\/footer>/gi, '')
|
|
209
|
-
.replace(/<header[^>]*>[\s\S]*?<\/header>/gi, '')
|
|
210
|
-
.replace(/<[^>]+>/g, ' ')
|
|
211
|
-
.replace(/ /g, ' ')
|
|
212
|
-
.replace(/&/g, '&')
|
|
213
|
-
.replace(/</g, '<')
|
|
214
|
-
.replace(/>/g, '>')
|
|
215
|
-
.replace(/"/g, '"')
|
|
216
|
-
.replace(/'/g, "'")
|
|
217
|
-
.replace(/\s+/g, ' ')
|
|
218
|
-
.trim();
|
|
219
|
-
|
|
220
|
-
// Take a reasonable chunk of text
|
|
221
|
-
if (text.length > 2000) {
|
|
222
|
-
text = text.substring(0, 2000) + '...';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return { title, description, text, headings: headings.slice(0, 10), links: links.slice(0, 20), images: images.slice(0, 12), favicon, heroImage };
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Resolve a relative URL against a base
|
|
230
|
-
*/
|
|
231
|
-
function resolveUrl(href, base) {
|
|
232
|
-
try {
|
|
233
|
-
if (href.startsWith('http://') || href.startsWith('https://')) return href;
|
|
234
|
-
if (href.startsWith('//')) return base.protocol + href;
|
|
235
|
-
return new URL(href, base).href;
|
|
236
|
-
} catch {
|
|
237
|
-
return href;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Escape HTML entities for safe embedding
|
|
243
|
-
*/
|
|
244
|
-
function escapeHtml(str) {
|
|
245
|
-
if (!str) return '';
|
|
246
|
-
return String(str)
|
|
247
|
-
.replace(/&/g, '&')
|
|
248
|
-
.replace(/</g, '<')
|
|
249
|
-
.replace(/>/g, '>')
|
|
250
|
-
.replace(/"/g, '"')
|
|
251
|
-
.replace(/'/g, ''');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Generate a simple link preview (thumbnail + title + description)
|
|
256
|
-
* without fetching — lighter weight alternative.
|
|
257
|
-
*
|
|
258
|
-
* @param {string} url - The URL to preview
|
|
259
|
-
* @param {Object} [options]
|
|
260
|
-
* @param {string} [options.title] - Override title
|
|
261
|
-
* @param {string} [options.description] - Override description
|
|
262
|
-
* @param {string} [options.image] - Override image URL
|
|
263
|
-
* @returns {string} HTML string for link preview card
|
|
264
|
-
*/
|
|
265
|
-
export const generateLinkPreviewHtml = (url, options = {}) => {
|
|
266
|
-
const { title, description, image } = options;
|
|
267
|
-
const baseUrl = new URL(url);
|
|
268
|
-
|
|
269
|
-
return `<html><head><style>
|
|
270
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
271
|
-
body{background:transparent;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;padding:0}
|
|
272
|
-
.card{background:#1a1a2e;border:1px solid rgba(255,255,255,0.1);border-radius:12px;overflow:hidden;max-width:100%}
|
|
273
|
-
.card-image{width:100%;height:160px;object-fit:cover;background:linear-gradient(135deg,#1a1a2e,#2d2d44)}
|
|
274
|
-
.card-body{padding:14px}
|
|
275
|
-
.card-title{font-size:16px;font-weight:600;color:#fff;margin-bottom:4px}
|
|
276
|
-
.card-desc{font-size:13px;color:#aaa;line-height:1.4;margin-bottom:8px}
|
|
277
|
-
.card-url{font-size:11px;color:#4CAF50;display:flex;align-items:center;gap:4px}
|
|
278
|
-
</style></head><body>
|
|
279
|
-
<a href="${url}" target="_blank" style="text-decoration:none">
|
|
280
|
-
<div class="card">
|
|
281
|
-
${image ? `<img class="card-image" src="${image}" alt="" onerror="this.style.display='none'">` :
|
|
282
|
-
`<div class="card-image" style="display:flex;align-items:center;justify-content:center;font-size:48px">🌐</div>`}
|
|
283
|
-
<div class="card-body">
|
|
284
|
-
<div class="card-title">${escapeHtml(title || baseUrl.hostname)}</div>
|
|
285
|
-
<div class="card-desc">${escapeHtml(description || 'Click to visit ' + baseUrl.hostname)}</div>
|
|
286
|
-
<div class="card-url">🔒 ${baseUrl.hostname}</div>
|
|
287
|
-
</div>
|
|
288
|
-
</div>
|
|
289
|
-
</a>
|
|
290
|
-
</body></html>`;
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export default generateWebsitePreviewHtml;
|