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,385 +0,0 @@
|
|
|
1
|
-
import { Boom } from '@hapi/boom';
|
|
2
|
-
import { createHash, randomBytes, randomFillSync } from 'crypto';
|
|
3
|
-
import { proto } from '../../WAProto/index.js';
|
|
4
|
-
const baileysVersion = [2, 3000, 1037013887];
|
|
5
|
-
import { DisconnectReason } from '../Types/index.js';
|
|
6
|
-
import { getAllBinaryNodeChildren, jidDecode } from '../WABinary/index.js';
|
|
7
|
-
import { sha256 } from './crypto.js';
|
|
8
|
-
export const BufferJSON = {
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
replacer: (k, value) => {
|
|
11
|
-
if (Buffer.isBuffer(value) || value instanceof Uint8Array || value?.type === 'Buffer') {
|
|
12
|
-
return { type: 'Buffer', data: Buffer.from(value?.data || value).toString('base64') };
|
|
13
|
-
}
|
|
14
|
-
return value;
|
|
15
|
-
},
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
reviver: (_, value) => {
|
|
18
|
-
if (typeof value === 'object' && value !== null && value.type === 'Buffer' && typeof value.data === 'string') {
|
|
19
|
-
return Buffer.from(value.data, 'base64');
|
|
20
|
-
}
|
|
21
|
-
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
22
|
-
const keys = Object.keys(value);
|
|
23
|
-
if (keys.length > 0 && keys.every(k => !isNaN(parseInt(k, 10)))) {
|
|
24
|
-
const values = Object.values(value);
|
|
25
|
-
if (values.every(v => typeof v === 'number')) {
|
|
26
|
-
return Buffer.from(values);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export const getKeyAuthor = (key, meId = 'me') => (key?.fromMe ? meId : key?.participantAlt || key?.remoteJidAlt || key?.participant || key?.remoteJid) || '';
|
|
34
|
-
export const isStringNullOrEmpty = (value) =>
|
|
35
|
-
// eslint-disable-next-line eqeqeq
|
|
36
|
-
value == null || value === '';
|
|
37
|
-
export const writeRandomPadMax16 = (msg) => {
|
|
38
|
-
const pad = randomBytes(1);
|
|
39
|
-
const padLength = (pad[0] & 0x0f) + 1;
|
|
40
|
-
return Buffer.concat([msg, Buffer.alloc(padLength, padLength)]);
|
|
41
|
-
};
|
|
42
|
-
export const unpadRandomMax16 = (e) => {
|
|
43
|
-
const t = new Uint8Array(e);
|
|
44
|
-
if (0 === t.length) {
|
|
45
|
-
throw new Error('unpadPkcs7 given empty bytes');
|
|
46
|
-
}
|
|
47
|
-
var r = t[t.length - 1];
|
|
48
|
-
if (r > t.length) {
|
|
49
|
-
throw new Error(`unpad given ${t.length} bytes, but pad is ${r}`);
|
|
50
|
-
}
|
|
51
|
-
return new Uint8Array(t.buffer, t.byteOffset, t.length - r);
|
|
52
|
-
};
|
|
53
|
-
// code is inspired by whatsmeow
|
|
54
|
-
export const generateParticipantHashV2 = (participants) => {
|
|
55
|
-
participants.sort();
|
|
56
|
-
const sha256Hash = sha256(Buffer.from(participants.join(''))).toString('base64');
|
|
57
|
-
return '2:' + sha256Hash.slice(0, 6);
|
|
58
|
-
};
|
|
59
|
-
export const encodeWAMessage = (message) => writeRandomPadMax16(proto.Message.encode(message).finish());
|
|
60
|
-
export const generateRegistrationId = () => {
|
|
61
|
-
return Uint16Array.from(randomBytes(2))[0] & 16383;
|
|
62
|
-
};
|
|
63
|
-
export const encodeBigEndian = (e, t = 4) => {
|
|
64
|
-
let r = e;
|
|
65
|
-
const a = new Uint8Array(t);
|
|
66
|
-
for (let i = t - 1; i >= 0; i--) {
|
|
67
|
-
a[i] = 255 & r;
|
|
68
|
-
r >>>= 8;
|
|
69
|
-
}
|
|
70
|
-
return a;
|
|
71
|
-
};
|
|
72
|
-
export const toNumber = (t) => typeof t === 'object' && t ? ('toNumber' in t ? t.toNumber() : t.low) : t || 0;
|
|
73
|
-
/** unix timestamp of a date in seconds */
|
|
74
|
-
export const unixTimestampSeconds = (date = Date.now()) => date / 1000 | 0; // Changed from new Date → Date.now for faster operation
|
|
75
|
-
export const debouncedTimeout = (intervalMs = 1000, task) => {
|
|
76
|
-
let timeout;
|
|
77
|
-
return {
|
|
78
|
-
start: (newIntervalMs, newTask) => {
|
|
79
|
-
task = newTask || task;
|
|
80
|
-
intervalMs = newIntervalMs || intervalMs;
|
|
81
|
-
timeout && clearTimeout(timeout);
|
|
82
|
-
timeout = setTimeout(() => task?.(), intervalMs);
|
|
83
|
-
},
|
|
84
|
-
cancel: () => {
|
|
85
|
-
timeout && clearTimeout(timeout);
|
|
86
|
-
timeout = undefined;
|
|
87
|
-
},
|
|
88
|
-
setTask: (newTask) => (task = newTask),
|
|
89
|
-
setInterval: (newInterval) => (intervalMs = newInterval)
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
export const delay = (ms) => delayCancellable(ms).delay;
|
|
93
|
-
export const delayCancellable = (ms) => {
|
|
94
|
-
const stack = new Error().stack;
|
|
95
|
-
let timeout;
|
|
96
|
-
let reject;
|
|
97
|
-
const delay = new Promise((resolve, _reject) => {
|
|
98
|
-
timeout = setTimeout(resolve, ms);
|
|
99
|
-
reject = _reject;
|
|
100
|
-
});
|
|
101
|
-
const cancel = () => {
|
|
102
|
-
clearTimeout(timeout);
|
|
103
|
-
reject(new Boom('Cancelled', {
|
|
104
|
-
statusCode: 500,
|
|
105
|
-
data: {
|
|
106
|
-
stack
|
|
107
|
-
}
|
|
108
|
-
}));
|
|
109
|
-
};
|
|
110
|
-
return { delay, cancel };
|
|
111
|
-
};
|
|
112
|
-
export async function promiseTimeout(ms, promise) {
|
|
113
|
-
if (!ms) {
|
|
114
|
-
return new Promise(promise);
|
|
115
|
-
}
|
|
116
|
-
const stack = new Error().stack;
|
|
117
|
-
// Create a promise that rejects in <ms> milliseconds
|
|
118
|
-
const { delay, cancel } = delayCancellable(ms);
|
|
119
|
-
const p = new Promise((resolve, reject) => {
|
|
120
|
-
delay
|
|
121
|
-
.then(() => reject(new Boom('Timed Out', {
|
|
122
|
-
statusCode: DisconnectReason.timedOut,
|
|
123
|
-
data: {
|
|
124
|
-
stack
|
|
125
|
-
}
|
|
126
|
-
})))
|
|
127
|
-
.catch(err => reject(err));
|
|
128
|
-
promise(resolve, reject);
|
|
129
|
-
}).finally(cancel);
|
|
130
|
-
return p;
|
|
131
|
-
}
|
|
132
|
-
// inspired from whatsmeow code
|
|
133
|
-
// https://github.com/tulir/whatsmeow/blob/64bc969fbe78d31ae0dd443b8d4c80a5d026d07a/send.go#L42
|
|
134
|
-
export const generateMessageIDV2 = (userId) => {
|
|
135
|
-
const data = Buffer.allocUnsafe(44);
|
|
136
|
-
data.writeBigUInt64BE(BigInt(Date.now() / 1000 | 0), 0);
|
|
137
|
-
if (userId) {
|
|
138
|
-
const userStr = userId.split('@')[0].split(':')[0];
|
|
139
|
-
if (userStr) {
|
|
140
|
-
const len = data.write(userStr, 8);
|
|
141
|
-
data.write('@c.us', 8 + len);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
randomFillSync(data, 28, 16);
|
|
145
|
-
const hash = createHash('sha256').update(data).digest();
|
|
146
|
-
const hex = hash.toString('hex', 0, 9).toUpperCase();
|
|
147
|
-
const baseId = '3EB0' + hex;
|
|
148
|
-
const pos = 4 + (hash[0] & 15);
|
|
149
|
-
return baseId.slice(0, pos) + 'STARFALL' + baseId.slice(pos);
|
|
150
|
-
};
|
|
151
|
-
// generate a random ID to attach to a message
|
|
152
|
-
export const generateMessageID = () => '3EB0' + randomBytes(18).toString('hex').toUpperCase();
|
|
153
|
-
export function bindWaitForEvent(ev, event) {
|
|
154
|
-
return async (check, timeoutMs) => {
|
|
155
|
-
let listener;
|
|
156
|
-
let closeListener;
|
|
157
|
-
await promiseTimeout(timeoutMs, (resolve, reject) => {
|
|
158
|
-
closeListener = ({ connection, lastDisconnect }) => {
|
|
159
|
-
if (connection === 'close') {
|
|
160
|
-
reject(lastDisconnect?.error || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }));
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
ev.on('connection.update', closeListener);
|
|
164
|
-
listener = async (update) => {
|
|
165
|
-
if (await check(update)) {
|
|
166
|
-
resolve();
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
ev.on(event, listener);
|
|
170
|
-
}).finally(() => {
|
|
171
|
-
ev.off(event, listener);
|
|
172
|
-
ev.off('connection.update', closeListener);
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
export const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
|
|
177
|
-
/**
|
|
178
|
-
* utility that fetches latest baileys version from the master branch.
|
|
179
|
-
* Use to ensure your WA connection is always on the latest version
|
|
180
|
-
*/
|
|
181
|
-
export const fetchLatestBaileysVersion = async (options = {}) => {
|
|
182
|
-
const URL = 'https://pair.crysnovax.link';
|
|
183
|
-
try {
|
|
184
|
-
const response = await fetch(URL, {
|
|
185
|
-
dispatcher: options.dispatcher,
|
|
186
|
-
method: 'GET',
|
|
187
|
-
headers: options.headers
|
|
188
|
-
});
|
|
189
|
-
if (!response.ok) {
|
|
190
|
-
throw new Boom(`Failed to fetch latest crysnovax/bailey version: ${response.statusText}`, { statusCode: response.status });
|
|
191
|
-
}
|
|
192
|
-
const text = await response.text();
|
|
193
|
-
// Extract version from line 5 (const version = [...])
|
|
194
|
-
const lines = text.split('\n');
|
|
195
|
-
const versionLine = lines[4]; // Line 5 (0-indexed)
|
|
196
|
-
const versionMatch = versionLine.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/);
|
|
197
|
-
if (versionMatch) {
|
|
198
|
-
const version = [parseInt(versionMatch[1]), parseInt(versionMatch[2]), parseInt(versionMatch[3])];
|
|
199
|
-
return {
|
|
200
|
-
version,
|
|
201
|
-
isLatest: true
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
throw new Error('Could not parse version from Defaults/index.ts');
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
return {
|
|
210
|
-
version: baileysVersion,
|
|
211
|
-
isLatest: false,
|
|
212
|
-
error
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* A utility that fetches the latest web version of whatsapp.
|
|
218
|
-
* Use to ensure your WA connection is always on the latest version
|
|
219
|
-
*/
|
|
220
|
-
export const fetchLatestWaWebVersion = async (options = {}) => {
|
|
221
|
-
try {
|
|
222
|
-
// Absolute minimal headers required to bypass anti-bot detection
|
|
223
|
-
const defaultHeaders = {
|
|
224
|
-
'sec-fetch-site': 'none',
|
|
225
|
-
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
|
|
226
|
-
};
|
|
227
|
-
const headers = { ...defaultHeaders, ...options.headers };
|
|
228
|
-
const response = await fetch('https://web.whatsapp.com/sw.js', {
|
|
229
|
-
...options,
|
|
230
|
-
method: 'GET',
|
|
231
|
-
headers
|
|
232
|
-
});
|
|
233
|
-
if (!response.ok) {
|
|
234
|
-
throw new Boom(`Failed to fetch sw.js: ${response.statusText}`, { statusCode: response.status });
|
|
235
|
-
}
|
|
236
|
-
const data = await response.text();
|
|
237
|
-
const regex = /\\?"client_revision\\?":\s*(\d+)/;
|
|
238
|
-
const match = data.match(regex);
|
|
239
|
-
if (!match?.[1]) {
|
|
240
|
-
return {
|
|
241
|
-
version: baileysVersion,
|
|
242
|
-
isLatest: false,
|
|
243
|
-
error: {
|
|
244
|
-
message: 'Could not find client revision in the fetched content'
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
const clientRevision = match[1];
|
|
249
|
-
return {
|
|
250
|
-
version: [2, 3000, +clientRevision],
|
|
251
|
-
isLatest: true
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
catch (error) {
|
|
255
|
-
return {
|
|
256
|
-
version: baileysVersion,
|
|
257
|
-
isLatest: false,
|
|
258
|
-
error
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
/** unique message tag prefix for MD clients */
|
|
263
|
-
export const generateMdTagPrefix = () => {
|
|
264
|
-
const bytes = randomBytes(4);
|
|
265
|
-
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`;
|
|
266
|
-
};
|
|
267
|
-
const STATUS_MAP = {
|
|
268
|
-
sender: proto.WebMessageInfo.Status.SERVER_ACK,
|
|
269
|
-
played: proto.WebMessageInfo.Status.PLAYED,
|
|
270
|
-
read: proto.WebMessageInfo.Status.READ,
|
|
271
|
-
'read-self': proto.WebMessageInfo.Status.READ
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Given a type of receipt, returns what the new status of the message should be
|
|
275
|
-
* @param type type from receipt
|
|
276
|
-
*/
|
|
277
|
-
export const getStatusFromReceiptType = (type) => {
|
|
278
|
-
const status = STATUS_MAP[type];
|
|
279
|
-
if (typeof type === 'undefined') {
|
|
280
|
-
return proto.WebMessageInfo.Status.DELIVERY_ACK;
|
|
281
|
-
}
|
|
282
|
-
return status;
|
|
283
|
-
};
|
|
284
|
-
const CODE_MAP = {
|
|
285
|
-
conflict: DisconnectReason.connectionReplaced
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Stream errors generally provide a reason, map that to a baileys DisconnectReason
|
|
289
|
-
* @param reason the string reason given, eg. "conflict"
|
|
290
|
-
*/
|
|
291
|
-
export const getErrorCodeFromStreamError = (node) => {
|
|
292
|
-
const [reasonNode] = getAllBinaryNodeChildren(node);
|
|
293
|
-
let reason = reasonNode?.tag || 'unknown';
|
|
294
|
-
const statusCode = +(node.attrs.code || CODE_MAP[reason] || DisconnectReason.badSession);
|
|
295
|
-
if (statusCode === DisconnectReason.restartRequired) {
|
|
296
|
-
reason = 'restart required';
|
|
297
|
-
}
|
|
298
|
-
return {
|
|
299
|
-
reason,
|
|
300
|
-
statusCode
|
|
301
|
-
};
|
|
302
|
-
};
|
|
303
|
-
export const getCallStatusFromNode = ({ tag, attrs }) => {
|
|
304
|
-
let status;
|
|
305
|
-
switch (tag) {
|
|
306
|
-
case 'offer':
|
|
307
|
-
case 'offer_notice':
|
|
308
|
-
status = 'offer';
|
|
309
|
-
break;
|
|
310
|
-
case 'terminate':
|
|
311
|
-
if (attrs.reason === 'timeout') {
|
|
312
|
-
status = 'timeout';
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
//fired when accepted/rejected/timeout/caller hangs up
|
|
316
|
-
status = 'terminate';
|
|
317
|
-
}
|
|
318
|
-
break;
|
|
319
|
-
case 'reject':
|
|
320
|
-
status = 'reject';
|
|
321
|
-
break;
|
|
322
|
-
case 'accept':
|
|
323
|
-
status = 'accept';
|
|
324
|
-
break;
|
|
325
|
-
default:
|
|
326
|
-
status = 'ringing';
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
return status;
|
|
330
|
-
};
|
|
331
|
-
const UNEXPECTED_SERVER_CODE_TEXT = 'Unexpected server response: ';
|
|
332
|
-
export const getCodeFromWSError = (error) => {
|
|
333
|
-
let statusCode = 500;
|
|
334
|
-
if (error?.message?.includes(UNEXPECTED_SERVER_CODE_TEXT)) {
|
|
335
|
-
const code = +error?.message.slice(UNEXPECTED_SERVER_CODE_TEXT.length);
|
|
336
|
-
if (!Number.isNaN(code) && code >= 400) {
|
|
337
|
-
statusCode = code;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
else if (
|
|
341
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
342
|
-
error?.code?.startsWith('E') ||
|
|
343
|
-
error?.message?.includes('timed out')) {
|
|
344
|
-
// handle ETIMEOUT, ENOTFOUND etc
|
|
345
|
-
statusCode = 408;
|
|
346
|
-
}
|
|
347
|
-
return statusCode;
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* Is the given platform WA business
|
|
351
|
-
* @param platform AuthenticationCreds.platform
|
|
352
|
-
*/
|
|
353
|
-
export const isWABusinessPlatform = (platform) => {
|
|
354
|
-
return platform === 'smbi' || platform === 'smba';
|
|
355
|
-
};
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
357
|
-
export function trimUndefined(obj) {
|
|
358
|
-
for (const key in obj) {
|
|
359
|
-
if (typeof obj[key] === 'undefined') {
|
|
360
|
-
delete obj[key];
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return obj;
|
|
364
|
-
}
|
|
365
|
-
const CROCKFORD_CHARACTERS = '123456789ABCDEFGHJKLMNPQRSTVWXYZ';
|
|
366
|
-
export function bytesToCrockford(buffer) {
|
|
367
|
-
let value = 0;
|
|
368
|
-
let bitCount = 0;
|
|
369
|
-
const crockford = [];
|
|
370
|
-
for (const element of buffer) {
|
|
371
|
-
value = (value << 8) | (element & 0xff);
|
|
372
|
-
bitCount += 8;
|
|
373
|
-
while (bitCount >= 5) {
|
|
374
|
-
crockford.push(CROCKFORD_CHARACTERS.charAt((value >>> (bitCount - 5)) & 31));
|
|
375
|
-
bitCount -= 5;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
if (bitCount > 0) {
|
|
379
|
-
crockford.push(CROCKFORD_CHARACTERS.charAt((value << (5 - bitCount)) & 31));
|
|
380
|
-
}
|
|
381
|
-
return crockford.join('');
|
|
382
|
-
}
|
|
383
|
-
export function encodeNewsletterMessage(message) {
|
|
384
|
-
return proto.Message.encode(message).finish();
|
|
385
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { inflateSync } from 'zlib';
|
|
2
|
-
import { proto } from '../../WAProto/index.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Decode a GroupHistory protobuf blob (community/group history container).
|
|
6
|
-
* @param buffer raw bytes, optionally zlib-compressed
|
|
7
|
-
* @param options.inflate try zlib.inflateSync first, falling back to raw bytes (default true)
|
|
8
|
-
* @param options.withMessageBytes decode the GroupHistoryWithMessageBytes variant,
|
|
9
|
-
* expanding each entry's messageBytes into a WebMessageInfo (default false)
|
|
10
|
-
*/
|
|
11
|
-
export const decodeGroupHistory = (buffer, options = {}) => {
|
|
12
|
-
const { inflate = true, withMessageBytes = false } = options;
|
|
13
|
-
if (!Buffer.isBuffer(buffer) && !(buffer instanceof Uint8Array)) {
|
|
14
|
-
throw new TypeError('decodeGroupHistory: buffer must be Buffer or Uint8Array');
|
|
15
|
-
}
|
|
16
|
-
let data = Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
|
|
17
|
-
if (inflate) {
|
|
18
|
-
try {
|
|
19
|
-
data = inflateSync(data);
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
// not zlib-compressed — use raw bytes
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (withMessageBytes) {
|
|
26
|
-
const decoded = proto.GroupHistoryWithMessageBytes.decode(data);
|
|
27
|
-
const expand = list =>
|
|
28
|
-
(list || []).map(entry =>
|
|
29
|
-
entry?.messageBytes ? proto.WebMessageInfo.decode(entry.messageBytes) : { key: entry?.key }
|
|
30
|
-
);
|
|
31
|
-
return {
|
|
32
|
-
messages: expand(decoded.messages),
|
|
33
|
-
commentMessages: expand(decoded.commentMessages),
|
|
34
|
-
outOfWindowPinnedMessages: expand(decoded.outOfWindowPinnedMessages),
|
|
35
|
-
uncountedAssociatedMessageLists: (decoded.uncountedAssociatedMessageLists || []).map(l => ({
|
|
36
|
-
parentMessage: l.parentMessage,
|
|
37
|
-
messages: expand(l.messages)
|
|
38
|
-
}))
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return proto.GroupHistory.decode(data);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Normalize a decoded GroupHistory into stable message buckets.
|
|
46
|
-
* @param groupHistory a decoded proto.GroupHistory (or the withMessageBytes shape)
|
|
47
|
-
*/
|
|
48
|
-
export const processGroupHistory = (groupHistory) => {
|
|
49
|
-
const gh = groupHistory || {};
|
|
50
|
-
return {
|
|
51
|
-
messages: gh.messages || [],
|
|
52
|
-
commentMessages: gh.commentMessages || [],
|
|
53
|
-
outOfWindowPinnedMessages: gh.outOfWindowPinnedMessages || [],
|
|
54
|
-
uncountedAssociatedMessageLists: gh.uncountedAssociatedMessageLists || []
|
|
55
|
-
};
|
|
56
|
-
};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser, jidDecode } from '../WABinary/index.js';
|
|
2
|
-
|
|
3
|
-
const createLidPnDebug = (logger) => {
|
|
4
|
-
const enabled = process.env.LID_PN_DEBUG === '1' || process.env.LID_PN_DEBUG === 'true';
|
|
5
|
-
return (phase, payload) => {
|
|
6
|
-
if (!enabled) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
logger?.debug({ ...payload, phase }, 'lid->pn normalization trace');
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const fallbackPnFromLidJid = (jid) => {
|
|
14
|
-
const decoded = jidDecode(jid);
|
|
15
|
-
const rawUser = decoded?.user || (typeof jid === 'string' ? jid.split('@')[0] : '');
|
|
16
|
-
const user = rawUser.split(':')[0];
|
|
17
|
-
if (!user) {
|
|
18
|
-
return jid;
|
|
19
|
-
}
|
|
20
|
-
return `${user}@s.whatsapp.net`;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const toDisplayPnJid = (jid) => {
|
|
24
|
-
if (!jid || typeof jid !== 'string') {
|
|
25
|
-
return jid;
|
|
26
|
-
}
|
|
27
|
-
const decoded = jidDecode(jid);
|
|
28
|
-
if (!decoded?.user) {
|
|
29
|
-
return jid;
|
|
30
|
-
}
|
|
31
|
-
if (!isPnUser(jid) && !isHostedPnUser(jid)) {
|
|
32
|
-
return jid;
|
|
33
|
-
}
|
|
34
|
-
const user = decoded.user.split(':')[0];
|
|
35
|
-
if (!user) {
|
|
36
|
-
return jid;
|
|
37
|
-
}
|
|
38
|
-
const server = decoded.server === 'hosted' ? 'hosted' : 's.whatsapp.net';
|
|
39
|
-
return `${user}@${server}`;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const buildLidPnHints = (key) => {
|
|
43
|
-
const hints = new Map();
|
|
44
|
-
if (!key) {
|
|
45
|
-
return hints;
|
|
46
|
-
}
|
|
47
|
-
const addHint = (lid, pn) => {
|
|
48
|
-
if (!isLidUser(lid) && !isHostedLidUser(lid)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (!isPnUser(pn) && !isHostedPnUser(pn)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
hints.set(lid, pn);
|
|
55
|
-
const lidDecoded = jidDecode(lid);
|
|
56
|
-
const pnDecoded = jidDecode(pn);
|
|
57
|
-
if (lidDecoded?.user && pnDecoded?.user) {
|
|
58
|
-
hints.set(`${lidDecoded.user}@lid`, `${pnDecoded.user}@s.whatsapp.net`);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
addHint(key.participant, key.participantAlt);
|
|
62
|
-
addHint(key.remoteJid, key.remoteJidAlt);
|
|
63
|
-
addHint(key.participantAlt, key.participant);
|
|
64
|
-
addHint(key.remoteJidAlt, key.remoteJid);
|
|
65
|
-
return hints;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const mergeGroupDataHints = (hints, groupData, debug) => {
|
|
69
|
-
if (!groupData?.participants?.length) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
debug?.('groupData-size', { participants: groupData.participants.length });
|
|
73
|
-
for (const participant of groupData.participants) {
|
|
74
|
-
const lidCandidate = participant?.lid;
|
|
75
|
-
const idCandidate = participant?.id;
|
|
76
|
-
const pnCandidate = participant?.phoneNumber;
|
|
77
|
-
const lid =
|
|
78
|
-
((isLidUser(lidCandidate) || isHostedLidUser(lidCandidate)
|
|
79
|
-
? lidCandidate
|
|
80
|
-
: undefined)) ||
|
|
81
|
-
((isLidUser(idCandidate) || isHostedLidUser(idCandidate) ? idCandidate : undefined));
|
|
82
|
-
const pn =
|
|
83
|
-
((isPnUser(pnCandidate) || isHostedPnUser(pnCandidate)
|
|
84
|
-
? pnCandidate
|
|
85
|
-
: undefined)) ||
|
|
86
|
-
((isPnUser(idCandidate) || isHostedPnUser(idCandidate) ? idCandidate : undefined));
|
|
87
|
-
if (!lid || !pn) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (
|
|
91
|
-
(isLidUser(lid) || isHostedLidUser(lid)) &&
|
|
92
|
-
(isPnUser(pn) || isHostedPnUser(pn))
|
|
93
|
-
) {
|
|
94
|
-
const displayPn = toDisplayPnJid(pn);
|
|
95
|
-
hints.set(lid, displayPn);
|
|
96
|
-
const lidDecoded = jidDecode(lid);
|
|
97
|
-
if (lidDecoded?.user) {
|
|
98
|
-
hints.set(`${lidDecoded.user}@lid`, displayPn);
|
|
99
|
-
}
|
|
100
|
-
debug?.('group-hint', { lid, pn: displayPn });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const normalizeToPnJid = async (jid, hints, signalRepository, debug) => {
|
|
106
|
-
if (!jid || typeof jid !== 'string') {
|
|
107
|
-
return jid;
|
|
108
|
-
}
|
|
109
|
-
if (!isLidUser(jid) && !isHostedLidUser(jid)) {
|
|
110
|
-
return jid;
|
|
111
|
-
}
|
|
112
|
-
debug?.('input', { lid: jid });
|
|
113
|
-
const hinted = hints.get(jid);
|
|
114
|
-
if (hinted) {
|
|
115
|
-
const normalized = toDisplayPnJid(hinted);
|
|
116
|
-
debug?.('hint-exact', { lid: jid, hinted, normalized });
|
|
117
|
-
return normalized;
|
|
118
|
-
}
|
|
119
|
-
const decoded = jidDecode(jid);
|
|
120
|
-
if (decoded?.user) {
|
|
121
|
-
const userHint = hints.get(`${decoded.user}@lid`);
|
|
122
|
-
if (userHint) {
|
|
123
|
-
const normalized = toDisplayPnJid(userHint);
|
|
124
|
-
debug?.('hint-user', { lid: jid, userHint, normalized });
|
|
125
|
-
return normalized;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const mapped = await signalRepository?.lidMapping?.getPNForLID?.(jid);
|
|
129
|
-
if (mapped) {
|
|
130
|
-
const normalized = toDisplayPnJid(mapped);
|
|
131
|
-
debug?.('mapping', { lid: jid, mapped, normalized });
|
|
132
|
-
return normalized;
|
|
133
|
-
}
|
|
134
|
-
const fallback = fallbackPnFromLidJid(jid);
|
|
135
|
-
debug?.('fallback', { lid: jid, fallback });
|
|
136
|
-
return fallback;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const normalizeMentionedJidsToPn = async (node, hints, signalRepository, debug) => {
|
|
140
|
-
if (!node || typeof node !== 'object') {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (Array.isArray(node)) {
|
|
144
|
-
for (const item of node) {
|
|
145
|
-
await normalizeMentionedJidsToPn(item, hints, signalRepository, debug);
|
|
146
|
-
}
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(node.mentionedJid)) {
|
|
150
|
-
const before = [...node.mentionedJid];
|
|
151
|
-
node.mentionedJid = await Promise.all(
|
|
152
|
-
node.mentionedJid.map(jid => normalizeToPnJid(jid, hints, signalRepository, debug))
|
|
153
|
-
);
|
|
154
|
-
debug?.('mentions', { before, after: node.mentionedJid });
|
|
155
|
-
}
|
|
156
|
-
if (typeof node.participant === 'string') {
|
|
157
|
-
const before = node.participant;
|
|
158
|
-
node.participant = await normalizeToPnJid(node.participant, hints, signalRepository, debug);
|
|
159
|
-
if (before !== node.participant) {
|
|
160
|
-
debug?.('participant-field', { before, after: node.participant });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (typeof node.remoteJid === 'string') {
|
|
164
|
-
const before = node.remoteJid;
|
|
165
|
-
node.remoteJid = await normalizeToPnJid(node.remoteJid, hints, signalRepository, debug);
|
|
166
|
-
if (before !== node.remoteJid) {
|
|
167
|
-
debug?.('remoteJid-field', { before, after: node.remoteJid });
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
for (const value of Object.values(node)) {
|
|
171
|
-
if (value && typeof value === 'object') {
|
|
172
|
-
await normalizeMentionedJidsToPn(value, hints, signalRepository, debug);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
export const normalizeMentionedJidsForSend = async (mentions, groupData, signalRepository, logger) => {
|
|
178
|
-
if (!Array.isArray(mentions)) {
|
|
179
|
-
return mentions;
|
|
180
|
-
}
|
|
181
|
-
const debug = createLidPnDebug(logger);
|
|
182
|
-
const hints = new Map();
|
|
183
|
-
mergeGroupDataHints(hints, groupData, debug);
|
|
184
|
-
const normalized = await Promise.all(mentions.map(jid => normalizeToPnJid(jid, hints, signalRepository, debug)));
|
|
185
|
-
debug('send-mentions-result', { before: mentions, after: normalized });
|
|
186
|
-
return normalized;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export const normalizeMessageForDisplayJids = async (messageInfo, signalRepository, logger, groupData) => {
|
|
190
|
-
if (!messageInfo?.key) {
|
|
191
|
-
return messageInfo;
|
|
192
|
-
}
|
|
193
|
-
const debug = createLidPnDebug(logger);
|
|
194
|
-
const hints = buildLidPnHints(messageInfo.key);
|
|
195
|
-
mergeGroupDataHints(hints, groupData, debug);
|
|
196
|
-
const beforeKey = { ...messageInfo.key };
|
|
197
|
-
messageInfo.key.participant = await normalizeToPnJid(messageInfo.key.participant, hints, signalRepository, debug);
|
|
198
|
-
messageInfo.key.participantAlt = await normalizeToPnJid(
|
|
199
|
-
messageInfo.key.participantAlt,
|
|
200
|
-
hints,
|
|
201
|
-
signalRepository,
|
|
202
|
-
debug
|
|
203
|
-
);
|
|
204
|
-
messageInfo.key.remoteJid = await normalizeToPnJid(messageInfo.key.remoteJid, hints, signalRepository, debug);
|
|
205
|
-
messageInfo.key.remoteJidAlt = await normalizeToPnJid(messageInfo.key.remoteJidAlt, hints, signalRepository, debug);
|
|
206
|
-
await normalizeMentionedJidsToPn(messageInfo.message, hints, signalRepository, debug);
|
|
207
|
-
debug('display-key-result', { before: beforeKey, after: messageInfo.key });
|
|
208
|
-
return messageInfo;
|
|
209
|
-
};
|