phantom-baileys 0.0.9 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +592 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +5479 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +5147 -41513
- package/WAProto/index.js +84008 -142014
- package/lib/Defaults/index.d.ts +29 -8
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +80 -60
- 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 +12 -0
- 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 +30 -0
- 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 +82 -0
- 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 +12 -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 +18 -0
- 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 +26 -0
- 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 +63 -0
- 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 +66 -0
- 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 +48 -0
- 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 +41 -0
- 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 +84 -0
- 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/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +3 -16
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -3
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +331 -80
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +19 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +271 -0
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -3
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -19
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +4 -5
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +3 -2
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +54 -0
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +184 -101
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +162 -43
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +72 -42
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +340 -299
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +309 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +431 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/dugong.d.ts +79 -0
- package/lib/Socket/dugong.d.ts.map +1 -0
- package/lib/Socket/dugong.js +527 -0
- package/lib/Socket/dugong.js.map +1 -0
- package/lib/Socket/groups.d.ts +93 -58
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +96 -84
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +232 -107
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +13 -10
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +170 -90
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +798 -462
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +180 -99
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +833 -709
- 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 +42 -0
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +120 -75
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +227 -198
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +31 -20
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +508 -215
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +18 -11
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -2
- 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 -0
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +2 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +24 -8
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -4
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +6 -1
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +82 -17
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -2
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +15 -3
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +1 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +3 -5
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +1 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +3 -5
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +77 -202
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -9
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +128 -85
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +25 -26
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +2 -1
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +20 -1
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +41 -24
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +14 -2
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +13 -2
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +3 -2
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -2
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +15 -16
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +15 -31
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/auth-utils.d.ts +7 -6
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +228 -165
- 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 +28 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +4 -3
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +66 -69
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +16 -16
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +299 -232
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +18 -21
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +44 -125
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +20 -8
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +139 -90
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +7 -8
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +129 -72
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +25 -22
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +157 -175
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +14 -11
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +83 -46
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +37 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +22 -17
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +22 -33
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +5 -5
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +14 -22
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +12 -1
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -7
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +8 -12
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +3 -46
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +2 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +24 -34
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +110 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +225 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +59 -42
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +411 -356
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +32 -18
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +412 -723
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +13 -13
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +149 -108
- 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 +40 -0
- 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 +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +30 -11
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +321 -166
- 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 +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/rich-messages.d.ts +129 -0
- package/lib/Utils/rich-messages.d.ts.map +1 -0
- package/lib/Utils/rich-messages.js +455 -0
- package/lib/Utils/rich-messages.js.map +1 -0
- package/lib/Utils/signal.d.ts +7 -6
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +65 -65
- 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 +38 -0
- 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 +48 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +12 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +18 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +79 -253
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +6 -6
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +111 -116
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +5 -4
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1281 -20
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +51 -53
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +12 -44
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +9 -6
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +124 -43
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -5
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +6 -21
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +24 -7
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +74 -40
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +2 -1
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -2
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +2 -1
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +2 -5
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +5 -3
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +19071 -11568
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -2
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +17 -22
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -3
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -19
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAProto/fix-imports.d.ts +1 -0
- package/lib/WAProto/fix-imports.js +71 -0
- package/lib/WAProto/index.js +89345 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -11
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +3 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -14
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +3 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -12
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +3 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -22
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +5 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -8
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -4
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +5 -20
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +5 -4
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +40 -35
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +7 -4
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +2 -5
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -3
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -19
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -31
- package/lib/index.js.map +1 -0
- package/package.json +35 -75
- package/Readme.md +0 -1
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/index.js +0 -10
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-in-memory-store.js +0 -431
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/make-ordered-dictionary.js +0 -81
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Store/object-repository.js +0 -27
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/baileys-event-stream.js +0 -63
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
package/lib/Utils/lt-hash.js
CHANGED
|
@@ -1,51 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LT_HASH_ANTI_TAMPERING = void 0;
|
|
4
|
-
const crypto_1 = require("./crypto");
|
|
1
|
+
import { LTHashAntiTampering } from 'whatsapp-rust-bridge';
|
|
5
2
|
/**
|
|
6
3
|
* LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
|
|
7
4
|
* over a series of mutations. You can add/remove mutations and it'll return a hash equal to
|
|
8
5
|
* if the same series of mutations was made sequentially.
|
|
9
6
|
*/
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
constructor(e) {
|
|
13
|
-
this.salt = e;
|
|
14
|
-
}
|
|
15
|
-
async add(e, t) {
|
|
16
|
-
var r = this;
|
|
17
|
-
for (const item of t) {
|
|
18
|
-
e = await r._addSingle(e, item);
|
|
19
|
-
}
|
|
20
|
-
return e;
|
|
21
|
-
}
|
|
22
|
-
async subtract(e, t) {
|
|
23
|
-
var r = this;
|
|
24
|
-
for (const item of t) {
|
|
25
|
-
e = await r._subtractSingle(e, item);
|
|
26
|
-
}
|
|
27
|
-
return e;
|
|
28
|
-
}
|
|
29
|
-
async subtractThenAdd(e, t, r) {
|
|
30
|
-
var n = this;
|
|
31
|
-
return n.add(await n.subtract(e, r), t);
|
|
32
|
-
}
|
|
33
|
-
async _addSingle(e, t) {
|
|
34
|
-
var r = this;
|
|
35
|
-
const n = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
36
|
-
return r.performPointwiseWithOverflow(await e, n, ((e, t) => e + t));
|
|
37
|
-
}
|
|
38
|
-
async _subtractSingle(e, t) {
|
|
39
|
-
var r = this;
|
|
40
|
-
const n = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
|
|
41
|
-
return r.performPointwiseWithOverflow(await e, n, ((e, t) => e - t));
|
|
42
|
-
}
|
|
43
|
-
performPointwiseWithOverflow(e, t, r) {
|
|
44
|
-
const n = new DataView(e), i = new DataView(t), a = new ArrayBuffer(n.byteLength), s = new DataView(a);
|
|
45
|
-
for (let e = 0; e < n.byteLength; e += 2) {
|
|
46
|
-
s.setUint16(e, r(n.getUint16(e, !0), i.getUint16(e, !0)), !0);
|
|
47
|
-
}
|
|
48
|
-
return a;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity');
|
|
7
|
+
export const LT_HASH_ANTI_TAMPERING = new LTHashAntiTampering();
|
|
8
|
+
//# sourceMappingURL=lt-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lt-hash.js","sourceRoot":"","sources":["../../src/Utils/lt-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mutex.d.ts","sourceRoot":"","sources":["../../src/Utils/make-mutex.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;UAId,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAIjD,CAAA;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA;AAEhD,eAAO,MAAM,cAAc;UAIb,CAAC,OAAO,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAqBpE,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
package/lib/Utils/make-mutex.js
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const makeMutex = () => {
|
|
5
|
-
let task = Promise.resolve();
|
|
6
|
-
let taskTimeout;
|
|
1
|
+
import { Mutex as AsyncMutex } from 'async-mutex';
|
|
2
|
+
export const makeMutex = () => {
|
|
3
|
+
const mutex = new AsyncMutex();
|
|
7
4
|
return {
|
|
8
5
|
mutex(code) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// if there is an error, we swallow so as to not block the queue
|
|
12
|
-
try {
|
|
13
|
-
await task;
|
|
14
|
-
}
|
|
15
|
-
catch (_a) { }
|
|
16
|
-
try {
|
|
17
|
-
// execute the current task
|
|
18
|
-
const result = await code();
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
finally {
|
|
22
|
-
clearTimeout(taskTimeout);
|
|
23
|
-
}
|
|
24
|
-
})();
|
|
25
|
-
// we replace the existing task, appending the new piece of execution to it
|
|
26
|
-
// so the next task will have to wait for this one to finish
|
|
27
|
-
return task;
|
|
28
|
-
},
|
|
6
|
+
return mutex.runExclusive(code);
|
|
7
|
+
}
|
|
29
8
|
};
|
|
30
9
|
};
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const map = {};
|
|
10
|
+
export const makeKeyedMutex = () => {
|
|
11
|
+
const map = new Map();
|
|
34
12
|
return {
|
|
35
|
-
mutex(key, task) {
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
async mutex(key, task) {
|
|
14
|
+
let entry = map.get(key);
|
|
15
|
+
if (!entry) {
|
|
16
|
+
entry = { mutex: new AsyncMutex(), refCount: 0 };
|
|
17
|
+
map.set(key, entry);
|
|
18
|
+
}
|
|
19
|
+
entry.refCount++;
|
|
20
|
+
try {
|
|
21
|
+
return await entry.mutex.runExclusive(task);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
entry.refCount--;
|
|
25
|
+
// only delete it if this is still the current entry
|
|
26
|
+
if (entry.refCount === 0 && map.get(key) === entry) {
|
|
27
|
+
map.delete(key);
|
|
28
|
+
}
|
|
38
29
|
}
|
|
39
|
-
return map[key].mutex(task);
|
|
40
30
|
}
|
|
41
31
|
};
|
|
42
32
|
};
|
|
43
|
-
|
|
33
|
+
//# sourceMappingURL=make-mutex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mutex.js","sourceRoot":"","sources":["../../src/Utils/make-mutex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC7B,MAAM,KAAK,GAAG,IAAI,UAAU,EAAE,CAAA;IAE9B,OAAO;QACN,KAAK,CAAI,IAA0B;YAClC,OAAO,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;KACD,CAAA;AACF,CAAC,CAAA;AAID,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IAClC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAmD,CAAA;IAEtE,OAAO;QACN,KAAK,CAAC,KAAK,CAAI,GAAW,EAAE,IAA0B;YACrD,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAExB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACZ,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;gBAChD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YACpB,CAAC;YAED,KAAK,CAAC,QAAQ,EAAE,CAAA;YAEhB,IAAI,CAAC;gBACJ,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;YAC5C,CAAC;oBAAS,CAAC;gBACV,KAAK,CAAC,QAAQ,EAAE,CAAA;gBAChB,oDAAoD;gBACpD,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;oBACpD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAChB,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { ILogger } from './logger.js';
|
|
3
|
+
export interface RecentMessageKey {
|
|
4
|
+
to: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RecentMessage {
|
|
8
|
+
message: proto.IMessage;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SessionRecreateHistory {
|
|
12
|
+
[jid: string]: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RetryCounter {
|
|
15
|
+
[messageId: string]: number;
|
|
16
|
+
}
|
|
17
|
+
export type PendingPhoneRequest = Record<string, ReturnType<typeof setTimeout>>;
|
|
18
|
+
export interface RetryStatistics {
|
|
19
|
+
totalRetries: number;
|
|
20
|
+
successfulRetries: number;
|
|
21
|
+
failedRetries: number;
|
|
22
|
+
mediaRetries: number;
|
|
23
|
+
sessionRecreations: number;
|
|
24
|
+
phoneRequests: number;
|
|
25
|
+
}
|
|
26
|
+
export declare enum RetryReason {
|
|
27
|
+
UnknownError = 0,
|
|
28
|
+
SignalErrorNoSession = 1,
|
|
29
|
+
SignalErrorInvalidKey = 2,
|
|
30
|
+
SignalErrorInvalidKeyId = 3,
|
|
31
|
+
/** MAC verification failed - most common cause of decryption failures */
|
|
32
|
+
SignalErrorInvalidMessage = 4,
|
|
33
|
+
SignalErrorInvalidSignature = 5,
|
|
34
|
+
SignalErrorFutureMessage = 6,
|
|
35
|
+
/** Explicit MAC failure - session is definitely out of sync */
|
|
36
|
+
SignalErrorBadMac = 7,
|
|
37
|
+
SignalErrorInvalidSession = 8,
|
|
38
|
+
SignalErrorInvalidMsgKey = 9,
|
|
39
|
+
BadBroadcastEphemeralSetting = 10,
|
|
40
|
+
UnknownCompanionNoPrekey = 11,
|
|
41
|
+
AdvFailure = 12,
|
|
42
|
+
StatusRevokeDelay = 13
|
|
43
|
+
}
|
|
44
|
+
export declare class MessageRetryManager {
|
|
45
|
+
private logger;
|
|
46
|
+
private recentMessagesMap;
|
|
47
|
+
private messageKeyIndex;
|
|
48
|
+
private sessionRecreateHistory;
|
|
49
|
+
private retryCounters;
|
|
50
|
+
private pendingPhoneRequests;
|
|
51
|
+
private readonly maxMsgRetryCount;
|
|
52
|
+
private statistics;
|
|
53
|
+
constructor(logger: ILogger, maxMsgRetryCount: number);
|
|
54
|
+
/**
|
|
55
|
+
* Add a recent message to the cache for retry handling
|
|
56
|
+
*/
|
|
57
|
+
addRecentMessage(to: string, id: string, message: proto.IMessage): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get a recent message from the cache
|
|
60
|
+
*/
|
|
61
|
+
getRecentMessage(to: string, id: string): RecentMessage | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a session should be recreated based on retry count, history, and error code.
|
|
64
|
+
* MAC errors (codes 4 and 7) trigger immediate session recreation regardless of timeout.
|
|
65
|
+
*/
|
|
66
|
+
shouldRecreateSession(jid: string, hasSession: boolean, errorCode?: RetryReason): {
|
|
67
|
+
reason: string;
|
|
68
|
+
recreate: boolean;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Parse error code from retry receipt's retry node.
|
|
72
|
+
* Returns undefined if no error code is present.
|
|
73
|
+
*/
|
|
74
|
+
parseRetryErrorCode(errorAttr: string | undefined): RetryReason | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Check if an error code indicates a MAC failure
|
|
77
|
+
*/
|
|
78
|
+
isMacError(errorCode: RetryReason | undefined): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Increment retry counter for a message
|
|
81
|
+
*/
|
|
82
|
+
incrementRetryCount(messageId: string): number;
|
|
83
|
+
/**
|
|
84
|
+
* Get retry count for a message
|
|
85
|
+
*/
|
|
86
|
+
getRetryCount(messageId: string): number;
|
|
87
|
+
/**
|
|
88
|
+
* Check if message has exceeded maximum retry attempts
|
|
89
|
+
*/
|
|
90
|
+
hasExceededMaxRetries(messageId: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Mark retry as successful
|
|
93
|
+
*/
|
|
94
|
+
markRetrySuccess(messageId: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Mark retry as failed
|
|
97
|
+
*/
|
|
98
|
+
markRetryFailed(messageId: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Schedule a phone request with delay
|
|
101
|
+
*/
|
|
102
|
+
schedulePhoneRequest(messageId: string, callback: () => void, delay?: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* Cancel pending phone request
|
|
105
|
+
*/
|
|
106
|
+
cancelPendingPhoneRequest(messageId: string): void;
|
|
107
|
+
private keyToString;
|
|
108
|
+
private removeRecentMessage;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=message-retry-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-retry-manager.d.ts","sourceRoot":"","sources":["../../src/Utils/message-retry-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAUvC,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAA;IACvB,SAAS,EAAE,MAAM,C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,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI;IAcvE;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAMnE;;;OAGG;IACH,qBAAqB,CACpB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,OAAO,EACnB,SAAS,CAAC,EAAE,WAAW,GACrB;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE;IAyCxC;;;OAGG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS;IAkB3E;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO;IAIvD;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAM9C;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIxC;;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIjD;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAQzC;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAOxC;;OAEG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,GAAE,MAA4B,GAAG,IAAI;IAaxG;;OAEG;IACH,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IASlD,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,mBAAmB;CAS3B"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { LRUCache } from 'lru-cache';
|
|
2
|
+
/** Number of sent messages to cache in memory for handling retry receipts */
|
|
3
|
+
const RECENT_MESSAGES_SIZE = 512;
|
|
4
|
+
const MESSAGE_KEY_SEPARATOR = '\u0000';
|
|
5
|
+
/** Timeout for session recreation - 1 hour */
|
|
6
|
+
const RECREATE_SESSION_TIMEOUT = 60 * 60 * 1000; // 1 hour in milliseconds
|
|
7
|
+
const PHONE_REQUEST_DELAY = 3000;
|
|
8
|
+
// Retry reason codes matching WhatsApp Web's Signal error codes.
|
|
9
|
+
export var RetryReason;
|
|
10
|
+
(function (RetryReason) {
|
|
11
|
+
RetryReason[RetryReason["UnknownError"] = 0] = "UnknownError";
|
|
12
|
+
RetryReason[RetryReason["SignalErrorNoSession"] = 1] = "SignalErrorNoSession";
|
|
13
|
+
RetryReason[RetryReason["SignalErrorInvalidKey"] = 2] = "SignalErrorInvalidKey";
|
|
14
|
+
RetryReason[RetryReason["SignalErrorInvalidKeyId"] = 3] = "SignalErrorInvalidKeyId";
|
|
15
|
+
/** MAC verification failed - most common cause of decryption failures */
|
|
16
|
+
RetryReason[RetryReason["SignalErrorInvalidMessage"] = 4] = "SignalErrorInvalidMessage";
|
|
17
|
+
RetryReason[RetryReason["SignalErrorInvalidSignature"] = 5] = "SignalErrorInvalidSignature";
|
|
18
|
+
RetryReason[RetryReason["SignalErrorFutureMessage"] = 6] = "SignalErrorFutureMessage";
|
|
19
|
+
/** Explicit MAC failure - session is definitely out of sync */
|
|
20
|
+
RetryReason[RetryReason["SignalErrorBadMac"] = 7] = "SignalErrorBadMac";
|
|
21
|
+
RetryReason[RetryReason["SignalErrorInvalidSession"] = 8] = "SignalErrorInvalidSession";
|
|
22
|
+
RetryReason[RetryReason["SignalErrorInvalidMsgKey"] = 9] = "SignalErrorInvalidMsgKey";
|
|
23
|
+
RetryReason[RetryReason["BadBroadcastEphemeralSetting"] = 10] = "BadBroadcastEphemeralSetting";
|
|
24
|
+
RetryReason[RetryReason["UnknownCompanionNoPrekey"] = 11] = "UnknownCompanionNoPrekey";
|
|
25
|
+
RetryReason[RetryReason["AdvFailure"] = 12] = "AdvFailure";
|
|
26
|
+
RetryReason[RetryReason["StatusRevokeDelay"] = 13] = "StatusRevokeDelay";
|
|
27
|
+
})(RetryReason || (RetryReason = {}));
|
|
28
|
+
/** Error codes that indicate a MAC failure and require immediate session recreation */
|
|
29
|
+
const MAC_ERROR_CODES = new Set([RetryReason.SignalErrorInvalidMessage, RetryReason.SignalErrorBadMac]);
|
|
30
|
+
export class MessageRetryManager {
|
|
31
|
+
constructor(logger, maxMsgRetryCount) {
|
|
32
|
+
this.logger = logger;
|
|
33
|
+
this.recentMessagesMap = new LRUCache({
|
|
34
|
+
max: RECENT_MESSAGES_SIZE,
|
|
35
|
+
ttl: 5 * 60 * 1000,
|
|
36
|
+
ttlAutopurge: true,
|
|
37
|
+
dispose: (_value, key) => {
|
|
38
|
+
const separatorIndex = key.lastIndexOf(MESSAGE_KEY_SEPARATOR);
|
|
39
|
+
if (separatorIndex > -1) {
|
|
40
|
+
const messageId = key.slice(separatorIndex + MESSAGE_KEY_SEPARATOR.length);
|
|
41
|
+
this.messageKeyIndex.delete(messageId);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this.messageKeyIndex = new Map();
|
|
46
|
+
this.sessionRecreateHistory = new LRUCache({
|
|
47
|
+
ttl: RECREATE_SESSION_TIMEOUT * 2,
|
|
48
|
+
ttlAutopurge: true
|
|
49
|
+
});
|
|
50
|
+
this.retryCounters = new LRUCache({
|
|
51
|
+
ttl: 15 * 60 * 1000,
|
|
52
|
+
ttlAutopurge: true,
|
|
53
|
+
updateAgeOnGet: true
|
|
54
|
+
}); // 15 minutes TTL
|
|
55
|
+
this.pendingPhoneRequests = {};
|
|
56
|
+
this.maxMsgRetryCount = 5;
|
|
57
|
+
this.statistics = {
|
|
58
|
+
totalRetries: 0,
|
|
59
|
+
successfulRetries: 0,
|
|
60
|
+
failedRetries: 0,
|
|
61
|
+
mediaRetries: 0,
|
|
62
|
+
sessionRecreations: 0,
|
|
63
|
+
phoneRequests: 0
|
|
64
|
+
};
|
|
65
|
+
this.maxMsgRetryCount = maxMsgRetryCount;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Add a recent message to the cache for retry handling
|
|
69
|
+
*/
|
|
70
|
+
addRecentMessage(to, id, message) {
|
|
71
|
+
const key = { to, id };
|
|
72
|
+
const keyStr = this.keyToString(key);
|
|
73
|
+
// Add new message
|
|
74
|
+
this.recentMessagesMap.set(keyStr, {
|
|
75
|
+
message,
|
|
76
|
+
timestamp: Date.now()
|
|
77
|
+
});
|
|
78
|
+
this.messageKeyIndex.set(id, keyStr);
|
|
79
|
+
this.logger.debug(`Added message to retry cache: ${to}/${id}`);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get a recent message from the cache
|
|
83
|
+
*/
|
|
84
|
+
getRecentMessage(to, id) {
|
|
85
|
+
const key = { to, id };
|
|
86
|
+
const keyStr = this.keyToString(key);
|
|
87
|
+
return this.recentMessagesMap.get(keyStr);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if a session should be recreated based on retry count, history, and error code.
|
|
91
|
+
* MAC errors (codes 4 and 7) trigger immediate session recreation regardless of timeout.
|
|
92
|
+
*/
|
|
93
|
+
shouldRecreateSession(jid, hasSession, errorCode) {
|
|
94
|
+
// If we don't have a session, always recreate
|
|
95
|
+
if (!hasSession) {
|
|
96
|
+
this.sessionRecreateHistory.set(jid, Date.now());
|
|
97
|
+
this.statistics.sessionRecreations++;
|
|
98
|
+
return {
|
|
99
|
+
reason: "we don't have a Signal session with them",
|
|
100
|
+
recreate: true
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// IMMEDIATE recreation for MAC errors - session is definitely out of sync
|
|
104
|
+
if (errorCode !== undefined && MAC_ERROR_CODES.has(errorCode)) {
|
|
105
|
+
this.sessionRecreateHistory.set(jid, Date.now());
|
|
106
|
+
this.statistics.sessionRecreations++;
|
|
107
|
+
this.logger.warn({ jid, errorCode: RetryReason[errorCode] }, 'MAC error detected, forcing immediate session recreation');
|
|
108
|
+
return {
|
|
109
|
+
reason: `MAC error (code ${errorCode}: ${RetryReason[errorCode]}), immediate session recreation`,
|
|
110
|
+
recreate: true
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const now = Date.now();
|
|
114
|
+
const prevTime = this.sessionRecreateHistory.get(jid);
|
|
115
|
+
// If no previous recreation or it's been more than an hour
|
|
116
|
+
if (!prevTime || now - prevTime > RECREATE_SESSION_TIMEOUT) {
|
|
117
|
+
this.sessionRecreateHistory.set(jid, now);
|
|
118
|
+
this.statistics.sessionRecreations++;
|
|
119
|
+
return {
|
|
120
|
+
reason: 'retry count > 1 and over an hour since last recreation',
|
|
121
|
+
recreate: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return { reason: '', recreate: false };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Parse error code from retry receipt's retry node.
|
|
128
|
+
* Returns undefined if no error code is present.
|
|
129
|
+
*/
|
|
130
|
+
parseRetryErrorCode(errorAttr) {
|
|
131
|
+
if (errorAttr === undefined || errorAttr === '') {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
const code = parseInt(errorAttr, 10);
|
|
135
|
+
if (Number.isNaN(code)) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
// Validate it's a known RetryReason
|
|
139
|
+
if (code >= RetryReason.UnknownError && code <= RetryReason.StatusRevokeDelay) {
|
|
140
|
+
return code;
|
|
141
|
+
}
|
|
142
|
+
return RetryReason.UnknownError;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Check if an error code indicates a MAC failure
|
|
146
|
+
*/
|
|
147
|
+
isMacError(errorCode) {
|
|
148
|
+
return errorCode !== undefined && MAC_ERROR_CODES.has(errorCode);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Increment retry counter for a message
|
|
152
|
+
*/
|
|
153
|
+
incrementRetryCount(messageId) {
|
|
154
|
+
this.retryCounters.set(messageId, (this.retryCounters.get(messageId) || 0) + 1);
|
|
155
|
+
this.statistics.totalRetries++;
|
|
156
|
+
return this.retryCounters.get(messageId);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get retry count for a message
|
|
160
|
+
*/
|
|
161
|
+
getRetryCount(messageId) {
|
|
162
|
+
return this.retryCounters.get(messageId) || 0;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Check if message has exceeded maximum retry attempts
|
|
166
|
+
*/
|
|
167
|
+
hasExceededMaxRetries(messageId) {
|
|
168
|
+
return this.getRetryCount(messageId) >= this.maxMsgRetryCount;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Mark retry as successful
|
|
172
|
+
*/
|
|
173
|
+
markRetrySuccess(messageId) {
|
|
174
|
+
this.statistics.successfulRetries++;
|
|
175
|
+
// Clean up retry counter for successful message
|
|
176
|
+
this.retryCounters.delete(messageId);
|
|
177
|
+
this.cancelPendingPhoneRequest(messageId);
|
|
178
|
+
this.removeRecentMessage(messageId);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Mark retry as failed
|
|
182
|
+
*/
|
|
183
|
+
markRetryFailed(messageId) {
|
|
184
|
+
this.statistics.failedRetries++;
|
|
185
|
+
this.retryCounters.delete(messageId);
|
|
186
|
+
this.cancelPendingPhoneRequest(messageId);
|
|
187
|
+
this.removeRecentMessage(messageId);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Schedule a phone request with delay
|
|
191
|
+
*/
|
|
192
|
+
schedulePhoneRequest(messageId, callback, delay = PHONE_REQUEST_DELAY) {
|
|
193
|
+
// Cancel any existing request for this message
|
|
194
|
+
this.cancelPendingPhoneRequest(messageId);
|
|
195
|
+
this.pendingPhoneRequests[messageId] = setTimeout(() => {
|
|
196
|
+
delete this.pendingPhoneRequests[messageId];
|
|
197
|
+
this.statistics.phoneRequests++;
|
|
198
|
+
callback();
|
|
199
|
+
}, delay);
|
|
200
|
+
this.logger.debug(`Scheduled phone request for message ${messageId} with ${delay}ms delay`);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Cancel pending phone request
|
|
204
|
+
*/
|
|
205
|
+
cancelPendingPhoneRequest(messageId) {
|
|
206
|
+
const timeout = this.pendingPhoneRequests[messageId];
|
|
207
|
+
if (timeout) {
|
|
208
|
+
clearTimeout(timeout);
|
|
209
|
+
delete this.pendingPhoneRequests[messageId];
|
|
210
|
+
this.logger.debug(`Cancelled pending phone request for message ${messageId}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
keyToString(key) {
|
|
214
|
+
return `${key.to}${MESSAGE_KEY_SEPARATOR}${key.id}`;
|
|
215
|
+
}
|
|
216
|
+
removeRecentMessage(messageId) {
|
|
217
|
+
const keyStr = this.messageKeyIndex.get(messageId);
|
|
218
|
+
if (!keyStr) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this.recentMessagesMap.delete(keyStr);
|
|
222
|
+
this.messageKeyIndex.delete(messageId);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=message-retry-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-retry-manager.js","sourceRoot":"","sources":["../../src/Utils/message-retry-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,6EAA6E;AAC7E,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC,MAAM,qBAAqB,GAAG,QAAQ,CAAA;AAEtC,8CAA8C;AAC9C,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,yBAAyB;AACzE,MAAM,mBAAmB,GAAG,IAAI,CAAA;AA8BhC,iEAAiE;AACjE,MAAM,CAAN,IAAY,WAiBX;AAjBD,WAAY,WAAW;IACtB,6DAAgB,CAAA;IAChB,6EAAwB,CAAA;IACxB,+EAAyB,CAAA;IACzB,mFAA2B,CAAA;IAC3B,yEA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C,OAAO,CAAC,CAAA;YACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;YAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+CAA+C,SAAS,EAAE,CAAC,CAAA;QAC9E,CAAC;IACF,CAAC;IAEO,WAAW,CAAC,GAAqB;QACxC,OAAO,GAAG,GAAG,CAAC,EAAE,GAAG,qBAAqB,GAAG,GAAG,CAAC,EAAE,EAAE,CAAA;IACpD,CAAC;IAEO,mBAAmB,CAAC,SAAiB;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAClD,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAM;QACP,CAAC;QAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACrC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACvC,CAAC;CACD"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
|
-
import {
|
|
3
|
-
import type { Logger } from 'pino';
|
|
2
|
+
import type { Agent } from 'https';
|
|
4
3
|
import { Readable } from 'stream';
|
|
5
4
|
import { URL } from 'url';
|
|
6
|
-
import { proto } from '../../WAProto';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { proto } from '../../WAProto/index.js';
|
|
6
|
+
import { type MediaType } from '../Defaults/index.js';
|
|
7
|
+
import type { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent, WAMessageKey } from '../Types/index.js';
|
|
8
|
+
import { type BinaryNode } from '../WABinary/index.js';
|
|
9
|
+
import type { ILogger } from './logger.js';
|
|
9
10
|
export declare const hkdfInfoKey: (type: MediaType) => string;
|
|
11
|
+
export declare const getRawMediaUploadData: (media: WAMediaUpload, mediaType: MediaType, logger?: ILogger) => Promise<{
|
|
12
|
+
filePath: string;
|
|
13
|
+
fileSha256: Buffer;
|
|
14
|
+
fileLength: number;
|
|
15
|
+
}>;
|
|
10
16
|
/** generates all the keys required to encrypt/decrypt & sign a media message */
|
|
11
|
-
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo
|
|
17
|
+
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): Promise<MediaDecryptionKeyInfo>;
|
|
12
18
|
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
13
19
|
buffer: any;
|
|
14
20
|
original: {
|
|
@@ -17,34 +23,39 @@ export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | s
|
|
|
17
23
|
};
|
|
18
24
|
}>;
|
|
19
25
|
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
|
|
20
|
-
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload
|
|
26
|
+
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload, dimensions?: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}) => Promise<{
|
|
21
30
|
img: Buffer;
|
|
22
31
|
}>;
|
|
23
32
|
/** gets the SHA256 of the given media message */
|
|
24
|
-
export declare const mediaMessageSHA256B64: (message: WAMessageContent) =>
|
|
25
|
-
export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<
|
|
33
|
+
export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
|
|
34
|
+
export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>;
|
|
26
35
|
/**
|
|
27
36
|
referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
|
|
28
37
|
*/
|
|
29
|
-
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?:
|
|
30
|
-
export declare const toReadable: (buffer: Buffer) =>
|
|
31
|
-
export declare const toBuffer: (stream: Readable) => Promise<
|
|
32
|
-
export declare const getStream: (item: WAMediaUpload, opts?:
|
|
33
|
-
|
|
38
|
+
export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array<ArrayBuffer> | undefined>;
|
|
39
|
+
export declare const toReadable: (buffer: Buffer) => Readable;
|
|
40
|
+
export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
|
|
41
|
+
export declare const getStream: (item: WAMediaUpload, opts?: RequestInit & {
|
|
42
|
+
maxContentLength?: number;
|
|
43
|
+
}) => Promise<{
|
|
44
|
+
readonly stream: Readable;
|
|
34
45
|
readonly type: "buffer";
|
|
35
46
|
} | {
|
|
36
|
-
readonly stream:
|
|
47
|
+
readonly stream: Readable;
|
|
37
48
|
readonly type: "readable";
|
|
38
49
|
} | {
|
|
39
|
-
readonly stream:
|
|
50
|
+
readonly stream: any;
|
|
40
51
|
readonly type: "remote";
|
|
41
52
|
} | {
|
|
42
|
-
readonly stream:
|
|
53
|
+
readonly stream: import("fs").ReadStream;
|
|
43
54
|
readonly type: "file";
|
|
44
55
|
}>;
|
|
45
56
|
/** generates a thumbnail for a given media, if required */
|
|
46
57
|
export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
|
|
47
|
-
logger?:
|
|
58
|
+
logger?: ILogger;
|
|
48
59
|
}): Promise<{
|
|
49
60
|
thumbnail: string | undefined;
|
|
50
61
|
originalImageDimensions: {
|
|
@@ -52,37 +63,27 @@ export declare function generateThumbnail(file: string, mediaType: 'video' | 'im
|
|
|
52
63
|
height: number;
|
|
53
64
|
} | undefined;
|
|
54
65
|
}>;
|
|
55
|
-
export declare const getHttpStream: (url: string | URL, options?:
|
|
66
|
+
export declare const getHttpStream: (url: string | URL, options?: RequestInit & {
|
|
56
67
|
isStream?: true;
|
|
57
|
-
}) => Promise<
|
|
68
|
+
}) => Promise<any>;
|
|
58
69
|
type EncryptedStreamOptions = {
|
|
59
70
|
saveOriginalFileIfRequired?: boolean;
|
|
60
|
-
logger?:
|
|
61
|
-
opts?:
|
|
71
|
+
logger?: ILogger;
|
|
72
|
+
opts?: RequestInit;
|
|
62
73
|
};
|
|
63
|
-
export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
64
|
-
mediaKey: undefined;
|
|
65
|
-
encWriteStream: any;
|
|
66
|
-
fileLength: any;
|
|
67
|
-
fileSha256: any;
|
|
68
|
-
fileEncSha256: undefined;
|
|
69
|
-
bodyPath: string | undefined;
|
|
70
|
-
didSaveToTmpPath: boolean;
|
|
71
|
-
}>;
|
|
72
74
|
export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
|
|
73
|
-
mediaKey:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
mac:
|
|
77
|
-
fileEncSha256:
|
|
78
|
-
fileSha256:
|
|
75
|
+
mediaKey: Buffer;
|
|
76
|
+
originalFilePath: string | undefined;
|
|
77
|
+
encFilePath: string;
|
|
78
|
+
mac: Buffer;
|
|
79
|
+
fileEncSha256: Buffer;
|
|
80
|
+
fileSha256: Buffer;
|
|
79
81
|
fileLength: number;
|
|
80
|
-
didSaveToTmpPath: boolean;
|
|
81
82
|
}>;
|
|
82
83
|
export type MediaDownloadOptions = {
|
|
83
84
|
startByte?: number;
|
|
84
85
|
endByte?: number;
|
|
85
|
-
options?:
|
|
86
|
+
options?: RequestInit;
|
|
86
87
|
};
|
|
87
88
|
export declare const getUrlFromDirectPath: (directPath: string) => string;
|
|
88
89
|
export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<any>;
|
|
@@ -92,13 +93,28 @@ export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }:
|
|
|
92
93
|
* */
|
|
93
94
|
export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<any>;
|
|
94
95
|
export declare function extensionForMediaMessage(message: WAMessageContent): string;
|
|
96
|
+
type MediaUploadResult = {
|
|
97
|
+
url?: string;
|
|
98
|
+
direct_path?: string;
|
|
99
|
+
meta_hmac?: string;
|
|
100
|
+
ts?: number;
|
|
101
|
+
fbid?: number;
|
|
102
|
+
};
|
|
103
|
+
export type UploadParams = {
|
|
104
|
+
url: string;
|
|
105
|
+
filePath: string;
|
|
106
|
+
headers: Record<string, string>;
|
|
107
|
+
timeoutMs?: number;
|
|
108
|
+
agent?: Agent;
|
|
109
|
+
};
|
|
110
|
+
export declare const uploadWithNodeHttp: ({ url, filePath, headers, timeoutMs, agent }: UploadParams, redirectCount?: number) => Promise<MediaUploadResult | undefined>;
|
|
95
111
|
export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;
|
|
96
112
|
/**
|
|
97
113
|
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
|
98
114
|
*/
|
|
99
|
-
export declare const encryptMediaRetryRequest: (key:
|
|
115
|
+
export declare const encryptMediaRetryRequest: (key: WAMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
|
|
100
116
|
export declare const decodeMediaRetryNode: (node: BinaryNode) => {
|
|
101
|
-
key:
|
|
117
|
+
key: WAMessageKey;
|
|
102
118
|
media?: {
|
|
103
119
|
ciphertext: Uint8Array;
|
|
104
120
|
iv: Uint8Array;
|
|
@@ -109,5 +125,6 @@ export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
|
|
|
109
125
|
ciphertext: Uint8Array;
|
|
110
126
|
iv: Uint8Array;
|
|
111
127
|
}, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
|
|
112
|
-
export declare const getStatusCodeForMediaRetry: (code: number) =>
|
|
128
|
+
export declare const getStatusCodeForMediaRetry: (code: number) => 200 | 412 | 404 | 418;
|
|
113
129
|
export {};
|
|
130
|
+
//# sourceMappingURL=messages-media.d.ts.map
|