@neelegirl/baileys 1.5.6 → 1.5.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/README.md +21 -27
- package/WAProto/WAProto.proto +665 -291
- package/WAProto/index.d.ts +48037 -2294
- package/WAProto/index.js +139804 -45203
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +64 -58
- package/lib/Defaults/index.js +96 -74
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/WASignalGroup/GroupProtocol.js +1909 -0
- package/lib/Signal/WASignalGroup/ciphertext_message.js +16 -0
- package/lib/Signal/WASignalGroup/generate-proto.sh +1 -0
- package/lib/Signal/WASignalGroup/group.proto +42 -0
- package/lib/Signal/WASignalGroup/group_cipher.js +120 -0
- package/lib/Signal/WASignalGroup/group_session_builder.js +46 -0
- package/lib/Signal/WASignalGroup/index.js +6 -0
- package/lib/Signal/WASignalGroup/keyhelper.js +21 -0
- package/lib/Signal/WASignalGroup/protobufs.js +3 -0
- package/lib/Signal/WASignalGroup/queue_job.js +69 -0
- package/lib/Signal/WASignalGroup/readme.md +6 -0
- package/lib/Signal/WASignalGroup/sender_chain_key.js +50 -0
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/lib/Signal/WASignalGroup/sender_key_message.js +92 -0
- package/lib/Signal/WASignalGroup/sender_key_name.js +70 -0
- package/lib/Signal/WASignalGroup/sender_key_record.js +56 -0
- package/lib/Signal/WASignalGroup/sender_key_state.js +129 -0
- package/lib/Signal/{Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -3
- package/lib/Signal/libsignal.d.ts +4 -5
- package/lib/Signal/libsignal.js +112 -292
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +22 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.js +15 -8
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.js +36 -24
- package/lib/Socket/business.d.ts +177 -178
- package/lib/Socket/business.js +71 -179
- package/lib/Socket/chats.d.ts +93 -93
- package/lib/Socket/chats.js +625 -474
- package/lib/Socket/communities.d.ts +62 -83
- package/lib/Socket/communities.js +414 -412
- package/lib/Socket/groups.d.ts +112 -118
- package/lib/Socket/groups.js +171 -146
- package/lib/Socket/index.d.ts +182 -222
- package/lib/Socket/index.js +17 -12
- package/lib/Socket/messages-recv.d.ts +169 -165
- package/lib/Socket/messages-recv.js +1721 -1185
- package/lib/Socket/messages-send.d.ts +160 -161
- package/lib/Socket/messages-send.js +992 -642
- package/lib/Socket/mex.d.ts +0 -1
- package/lib/Socket/mex.js +9 -4
- package/lib/Socket/newsletter.d.ts +139 -139
- package/lib/Socket/newsletter.js +258 -153
- package/lib/Socket/registration.d.ts +266 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +36 -42
- package/lib/Socket/socket.js +525 -623
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +83 -0
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +24 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +90 -0
- package/lib/Store/make-in-memory-store.d.ts +123 -0
- package/lib/Store/make-in-memory-store.js +429 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +86 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +31 -0
- package/lib/Types/Auth.d.ts +96 -87
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Call.d.ts +13 -13
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.d.ts +94 -79
- package/lib/Types/Chat.js +9 -8
- package/lib/Types/Contact.d.ts +9 -13
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.d.ts +179 -152
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.d.ts +48 -49
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.d.ts +14 -13
- package/lib/Types/Label.js +30 -24
- package/lib/Types/LabelAssociation.d.ts +20 -15
- package/lib/Types/LabelAssociation.js +12 -6
- package/lib/Types/Message.d.ts +404 -234
- package/lib/Types/Message.js +13 -11
- package/lib/Types/MexUpdates.d.ts +9 -0
- package/lib/Types/MexUpdates.js +18 -0
- package/lib/Types/Newsletter.d.ts +104 -130
- package/lib/Types/Newsletter.js +40 -31
- package/lib/Types/Product.d.ts +71 -58
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.d.ts +55 -63
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.d.ts +66 -77
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/State.d.ts +19 -17
- package/lib/Types/State.js +14 -13
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.d.ts +61 -47
- package/lib/Types/index.js +48 -26
- package/lib/Utils/auth-utils.d.ts +10 -8
- package/lib/Utils/auth-utils.js +154 -206
- package/lib/Utils/baileys-event-stream.d.ts +7 -6
- package/lib/Utils/baileys-event-stream.js +43 -29
- package/lib/Utils/business.d.ts +20 -14
- package/lib/Utils/business.js +134 -110
- package/lib/Utils/chat-utils.d.ts +69 -57
- package/lib/Utils/chat-utils.js +380 -362
- package/lib/Utils/check-npm-version.d.ts +15 -0
- package/lib/Utils/check-npm-version.js +52 -0
- package/lib/Utils/crypto.d.ts +45 -30
- package/lib/Utils/crypto.js +178 -141
- package/lib/Utils/decode-wa-message.d.ts +35 -42
- package/lib/Utils/decode-wa-message.js +150 -176
- package/lib/Utils/event-buffer.d.ts +17 -12
- package/lib/Utils/event-buffer.js +286 -269
- package/lib/Utils/generics.d.ts +99 -60
- package/lib/Utils/generics.js +481 -244
- package/lib/Utils/history.d.ts +22 -18
- package/lib/Utils/history.js +80 -54
- package/lib/Utils/index.d.ts +19 -20
- package/lib/Utils/index.js +41 -19
- package/lib/Utils/link-preview.d.ts +14 -12
- package/lib/Utils/link-preview.js +75 -40
- package/lib/Utils/logger.d.ts +11 -10
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +13 -12
- package/lib/Utils/lt-hash.js +37 -27
- package/lib/Utils/make-mutex.d.ts +7 -6
- package/lib/Utils/make-mutex.js +29 -20
- package/lib/Utils/message-retry-manager.d.ts +6 -6
- package/lib/Utils/message-retry-manager.js +36 -8
- package/lib/Utils/messages-media.d.ts +102 -87
- package/lib/Utils/messages-media.js +570 -427
- package/lib/Utils/messages.d.ts +64 -37
- package/lib/Utils/messages.js +1270 -511
- package/lib/Utils/noise-handler.d.ts +18 -18
- package/lib/Utils/noise-handler.js +109 -101
- package/lib/Utils/process-message.d.ts +32 -25
- package/lib/Utils/process-message.js +281 -266
- package/lib/Utils/signal.d.ts +32 -24
- package/lib/Utils/signal.js +105 -98
- package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
- package/lib/Utils/use-mongo-file-auth-state.js +84 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -5
- package/lib/Utils/use-multi-file-auth-state.js +186 -69
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-single-file-auth-state.js +80 -0
- package/lib/Utils/validate-connection.d.ts +13 -11
- package/lib/Utils/validate-connection.js +116 -124
- package/lib/WABinary/constants.d.ts +27 -25
- package/lib/WABinary/constants.js +1292 -1277
- package/lib/WABinary/decode.d.ts +9 -7
- package/lib/WABinary/decode.js +189 -139
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +154 -105
- package/lib/WABinary/generic-utils.d.ts +27 -14
- package/lib/WABinary/generic-utils.js +102 -62
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +25 -6
- package/lib/WABinary/jid-utils.d.ts +46 -41
- package/lib/WABinary/jid-utils.js +80 -84
- package/lib/WABinary/types.d.ts +13 -10
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -8
- package/lib/WAM/BinaryInfo.js +14 -7
- package/lib/WAM/constants.d.ts +37 -30
- package/lib/WAM/constants.js +11983 -19465
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.js +110 -95
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +23 -4
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +28 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +69 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +19 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
- package/lib/WAUSync/Protocols/index.d.ts +6 -5
- package/lib/WAUSync/Protocols/index.js +26 -5
- package/lib/WAUSync/USyncQuery.d.ts +28 -26
- package/lib/WAUSync/USyncQuery.js +62 -64
- package/lib/WAUSync/USyncUser.d.ts +10 -11
- package/lib/WAUSync/USyncUser.js +19 -12
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +23 -4
- package/lib/index.d.ts +11 -10
- package/lib/index.js +33 -11
- package/package.json +43 -48
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/fix-imports.js +0 -29
- package/engine-requirements.js +0 -10
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js +0 -12
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts +0 -15
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js +0 -30
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js +0 -82
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts +0 -12
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js +0 -12
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js +0 -18
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js +0 -26
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -63
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js +0 -66
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js +0 -48
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts +0 -31
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js +0 -41
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts +0 -39
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js +0 -84
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts +0 -12
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts +0 -23
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js +0 -171
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -25
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
- package/lib/Utils/baileys-event-stream.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts +0 -4
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js +0 -28
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts +0 -28
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js +0 -106
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts.map +0 -1
- package/lib/WABinary/generic-utils.js.map +0 -1
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts.map +0 -1
- package/lib/WABinary/jid-utils.js.map +0 -1
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -1,65 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
8
|
+
|
|
9
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"))
|
|
10
|
+
const boom_1 = require("@hapi/boom")
|
|
11
|
+
const WAProto_1 = require("../../WAProto")
|
|
12
|
+
const Defaults_1 = require("../Defaults")
|
|
13
|
+
const Types_1 = require("../Types")
|
|
14
|
+
const Utils_1 = require("../Utils")
|
|
15
|
+
const make_mutex_1 = require("../Utils/make-mutex")
|
|
16
|
+
const WABinary_1 = require("../WABinary")
|
|
17
|
+
const WAUSync_1 = require("../WAUSync")
|
|
18
|
+
const usync_1 = require("./usync")
|
|
19
|
+
const MAX_SYNC_ATTEMPTS = 2
|
|
20
|
+
|
|
21
|
+
const makeChatsSocket = (config) => {
|
|
22
|
+
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config
|
|
23
|
+
const Neele = usync_1.makeUSyncSocket(config)
|
|
24
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, groupFetchAllParticipating } = Neele
|
|
25
|
+
|
|
26
|
+
let privacySettings
|
|
27
|
+
let syncState = Types_1.SyncState.Connecting
|
|
28
|
+
|
|
20
29
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
21
|
-
const processingMutex = makeMutex()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const processingMutex = make_mutex_1.makeMutex()
|
|
31
|
+
|
|
32
|
+
// Timeout for AwaitingInitialSync State
|
|
33
|
+
let awaitingSyncTimeout
|
|
34
|
+
|
|
35
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
36
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
37
|
+
useClones: false
|
|
38
|
+
})
|
|
39
|
+
|
|
29
40
|
if (!config.placeholderResendCache) {
|
|
30
|
-
config.placeholderResendCache = placeholderResendCache
|
|
41
|
+
config.placeholderResendCache = placeholderResendCache
|
|
31
42
|
}
|
|
43
|
+
|
|
32
44
|
/** helper function to fetch the given app state sync key */
|
|
33
45
|
const getAppStateSyncKey = async (keyId) => {
|
|
34
|
-
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId])
|
|
35
|
-
return key
|
|
36
|
-
}
|
|
46
|
+
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId])
|
|
47
|
+
return key
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
const fetchPrivacySettings = async (force = false) => {
|
|
38
51
|
if (!privacySettings || force) {
|
|
39
52
|
const { content } = await query({
|
|
40
53
|
tag: 'iq',
|
|
41
54
|
attrs: {
|
|
42
55
|
xmlns: 'privacy',
|
|
43
|
-
to: S_WHATSAPP_NET,
|
|
56
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
44
57
|
type: 'get'
|
|
45
58
|
},
|
|
46
|
-
content: [
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
content: [
|
|
60
|
+
{ tag: 'privacy', attrs: {} }
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
privacySettings = WABinary_1.reduceBinaryNodeToDictionary(content?.[0], 'category')
|
|
49
64
|
}
|
|
50
|
-
return privacySettings
|
|
51
|
-
}
|
|
65
|
+
return privacySettings
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
/** helper function to run a privacy IQ query */
|
|
53
69
|
const privacyQuery = async (name, value) => {
|
|
54
70
|
await query({
|
|
55
71
|
tag: 'iq',
|
|
56
72
|
attrs: {
|
|
57
73
|
xmlns: 'privacy',
|
|
58
|
-
to: S_WHATSAPP_NET,
|
|
74
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
59
75
|
type: 'set'
|
|
60
76
|
},
|
|
61
|
-
content: [
|
|
62
|
-
{
|
|
77
|
+
content: [{
|
|
63
78
|
tag: 'privacy',
|
|
64
79
|
attrs: {},
|
|
65
80
|
content: [
|
|
@@ -68,123 +83,187 @@ export const makeChatsSocket = (config) => {
|
|
|
68
83
|
attrs: { name, value }
|
|
69
84
|
}
|
|
70
85
|
]
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
}]
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
const updateMessagesPrivacy = async (value) => {
|
|
76
|
-
await privacyQuery('messages', value)
|
|
77
|
-
}
|
|
91
|
+
await privacyQuery('messages', value)
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
const updateCallPrivacy = async (value) => {
|
|
79
|
-
await privacyQuery('calladd', value)
|
|
80
|
-
}
|
|
95
|
+
await privacyQuery('calladd', value)
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
const updateLastSeenPrivacy = async (value) => {
|
|
82
|
-
await privacyQuery('last', value)
|
|
83
|
-
}
|
|
99
|
+
await privacyQuery('last', value)
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
const updateOnlinePrivacy = async (value) => {
|
|
85
|
-
await privacyQuery('online', value)
|
|
86
|
-
}
|
|
103
|
+
await privacyQuery('online', value)
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
const updateProfilePicturePrivacy = async (value) => {
|
|
88
|
-
await privacyQuery('profile', value)
|
|
89
|
-
}
|
|
107
|
+
await privacyQuery('profile', value)
|
|
108
|
+
}
|
|
109
|
+
|
|
90
110
|
const updateStatusPrivacy = async (value) => {
|
|
91
|
-
await privacyQuery('status', value)
|
|
92
|
-
}
|
|
111
|
+
await privacyQuery('status', value)
|
|
112
|
+
}
|
|
113
|
+
|
|
93
114
|
const updateReadReceiptsPrivacy = async (value) => {
|
|
94
|
-
await privacyQuery('readreceipts', value)
|
|
95
|
-
}
|
|
115
|
+
await privacyQuery('readreceipts', value)
|
|
116
|
+
}
|
|
117
|
+
|
|
96
118
|
const updateGroupsAddPrivacy = async (value) => {
|
|
97
|
-
await privacyQuery('groupadd', value)
|
|
98
|
-
}
|
|
119
|
+
await privacyQuery('groupadd', value)
|
|
120
|
+
}
|
|
121
|
+
|
|
99
122
|
const updateDefaultDisappearingMode = async (duration) => {
|
|
100
123
|
await query({
|
|
101
124
|
tag: 'iq',
|
|
102
125
|
attrs: {
|
|
103
126
|
xmlns: 'disappearing_mode',
|
|
104
|
-
to: S_WHATSAPP_NET,
|
|
127
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
105
128
|
type: 'set'
|
|
106
129
|
},
|
|
107
|
-
content: [
|
|
108
|
-
{
|
|
130
|
+
content: [{
|
|
109
131
|
tag: 'disappearing_mode',
|
|
110
132
|
attrs: {
|
|
111
133
|
duration: duration.toString()
|
|
112
134
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
135
|
+
}]
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
117
139
|
const getBotListV2 = async () => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
const resp = await query({
|
|
141
|
+
tag: 'iq',
|
|
142
|
+
attrs: {
|
|
143
|
+
xmlns: 'bot',
|
|
144
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
145
|
+
type: 'get'
|
|
146
|
+
},
|
|
147
|
+
content: [{
|
|
148
|
+
tag: 'bot',
|
|
149
|
+
attrs: {
|
|
150
|
+
v: '2'
|
|
151
|
+
}
|
|
152
|
+
}]
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
const botNode = WABinary_1.getBinaryNodeChild(resp, 'bot')
|
|
156
|
+
|
|
157
|
+
const botList = []
|
|
158
|
+
|
|
159
|
+
for(const section of WABinary_1.getBinaryNodeChildren(botNode, 'section')) {
|
|
160
|
+
if(section.attrs.type === 'all') {
|
|
161
|
+
for(const bot of WABinary_1.getBinaryNodeChildren(section, 'bot')) {
|
|
162
|
+
botList.push({
|
|
163
|
+
jid: bot.attrs.jid,
|
|
164
|
+
personaId: bot.attrs['persona_id']
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return botList
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const getLidUser = async (jid) => {
|
|
173
|
+
if (!jid) {
|
|
174
|
+
throw new boom_1.Boom('Please input a jid user')
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!WABinary_1.isJidUser(jid)) {
|
|
178
|
+
throw new boom_1.Boom('Invalid JID: Not a user JID!')
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const targetJid = WABinary_1.jidNormalizedUser(jid)
|
|
182
|
+
|
|
183
|
+
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
184
|
+
usyncQuery.protocols.push({
|
|
185
|
+
name: 'lid',
|
|
186
|
+
getQueryElement: () => ({
|
|
187
|
+
tag: 'lid',
|
|
188
|
+
attrs: {},
|
|
189
|
+
content: undefined
|
|
190
|
+
}),
|
|
191
|
+
getUserElement: () => null,
|
|
192
|
+
parser: (node) => node.attrs.val
|
|
193
|
+
})
|
|
194
|
+
usyncQuery.users.push({
|
|
195
|
+
id: targetJid
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
const result = await Neele.executeUSyncQuery(usyncQuery)
|
|
199
|
+
|
|
200
|
+
if (result) {
|
|
201
|
+
return result.list
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const onWhatsApp = async (...jids) => {
|
|
206
|
+
const usyncQuery = new WAUSync_1.USyncQuery().withContactProtocol().withLIDProtocol()
|
|
207
|
+
|
|
208
|
+
for (const jid of jids) {
|
|
209
|
+
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`
|
|
210
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone))
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const results = await Neele.executeUSyncQuery(usyncQuery)
|
|
214
|
+
|
|
215
|
+
if (results) {
|
|
216
|
+
return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }))
|
|
145
217
|
}
|
|
146
|
-
|
|
147
|
-
|
|
218
|
+
}
|
|
219
|
+
|
|
148
220
|
const fetchStatus = async (...jids) => {
|
|
149
|
-
const usyncQuery = new USyncQuery().withStatusProtocol()
|
|
221
|
+
const usyncQuery = new WAUSync_1.USyncQuery().withStatusProtocol()
|
|
222
|
+
|
|
150
223
|
for (const jid of jids) {
|
|
151
|
-
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
224
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid))
|
|
152
225
|
}
|
|
153
|
-
|
|
226
|
+
|
|
227
|
+
const result = await Neele.executeUSyncQuery(usyncQuery)
|
|
228
|
+
|
|
154
229
|
if (result) {
|
|
155
|
-
return result.list
|
|
230
|
+
return result.list
|
|
156
231
|
}
|
|
157
|
-
}
|
|
158
|
-
const fetchDisappearingDuration = async (...jids) => {
|
|
159
|
-
const usyncQuery = new USyncQuery().withDisappearingModeProtocol()
|
|
232
|
+
}
|
|
233
|
+
const fetchDisappearingDuration = async (...jids) => {
|
|
234
|
+
const usyncQuery = new WAUSync_1.USyncQuery().withDisappearingModeProtocol()
|
|
235
|
+
|
|
160
236
|
for (const jid of jids) {
|
|
161
|
-
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
237
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid))
|
|
162
238
|
}
|
|
163
|
-
|
|
239
|
+
|
|
240
|
+
const result = await Neele.executeUSyncQuery(usyncQuery)
|
|
164
241
|
if (result) {
|
|
165
|
-
return result.list
|
|
242
|
+
return result.list
|
|
166
243
|
}
|
|
167
|
-
}
|
|
244
|
+
}
|
|
245
|
+
|
|
168
246
|
/** update the profile picture for yourself or a group */
|
|
169
|
-
const updateProfilePicture = async (jid, content
|
|
170
|
-
let targetJid
|
|
247
|
+
const updateProfilePicture = async (jid, content) => {
|
|
248
|
+
let targetJid
|
|
249
|
+
|
|
171
250
|
if (!jid) {
|
|
172
|
-
throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update')
|
|
173
|
-
}
|
|
174
|
-
if (jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me.id)) {
|
|
175
|
-
targetJid = jidNormalizedUser(jid); // in case it is someone other than us
|
|
251
|
+
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update')
|
|
176
252
|
}
|
|
177
|
-
|
|
178
|
-
|
|
253
|
+
|
|
254
|
+
if (WABinary_1.jidNormalizedUser(jid) !== WABinary_1.jidNormalizedUser(authState.creds.me.id)) {
|
|
255
|
+
targetJid = WABinary_1.jidNormalizedUser(jid) // in case it is someone other than us
|
|
179
256
|
}
|
|
180
|
-
|
|
257
|
+
|
|
258
|
+
const { img } = await Utils_1.generateProfilePicture(content)
|
|
259
|
+
|
|
181
260
|
await query({
|
|
182
261
|
tag: 'iq',
|
|
183
262
|
attrs: {
|
|
184
|
-
|
|
263
|
+
target: targetJid,
|
|
264
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
185
265
|
type: 'set',
|
|
186
|
-
xmlns: 'w:profile:picture'
|
|
187
|
-
...(targetJid ? { target: targetJid } : {})
|
|
266
|
+
xmlns: 'w:profile:picture'
|
|
188
267
|
},
|
|
189
268
|
content: [
|
|
190
269
|
{
|
|
@@ -193,36 +272,38 @@ export const makeChatsSocket = (config) => {
|
|
|
193
272
|
content: img
|
|
194
273
|
}
|
|
195
274
|
]
|
|
196
|
-
})
|
|
197
|
-
}
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
|
|
198
278
|
/** remove the profile picture for yourself or a group */
|
|
199
279
|
const removeProfilePicture = async (jid) => {
|
|
200
|
-
let targetJid
|
|
280
|
+
let targetJid
|
|
281
|
+
|
|
201
282
|
if (!jid) {
|
|
202
|
-
throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update')
|
|
203
|
-
}
|
|
204
|
-
if (jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me.id)) {
|
|
205
|
-
targetJid = jidNormalizedUser(jid); // in case it is someone other than us
|
|
283
|
+
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update')
|
|
206
284
|
}
|
|
207
|
-
|
|
208
|
-
|
|
285
|
+
|
|
286
|
+
if (WABinary_1.jidNormalizedUser(jid) !== WABinary_1.jidNormalizedUser(authState.creds.me.id)) {
|
|
287
|
+
targetJid = WABinary_1.jidNormalizedUser(jid) // in case it is someone other than us
|
|
209
288
|
}
|
|
289
|
+
|
|
210
290
|
await query({
|
|
211
291
|
tag: 'iq',
|
|
212
292
|
attrs: {
|
|
213
|
-
|
|
293
|
+
target: targetJid,
|
|
294
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
214
295
|
type: 'set',
|
|
215
|
-
xmlns: 'w:profile:picture'
|
|
216
|
-
...(targetJid ? { target: targetJid } : {})
|
|
296
|
+
xmlns: 'w:profile:picture'
|
|
217
297
|
}
|
|
218
|
-
})
|
|
219
|
-
}
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
|
|
220
301
|
/** update the profile status for yourself */
|
|
221
302
|
const updateProfileStatus = async (status) => {
|
|
222
303
|
await query({
|
|
223
304
|
tag: 'iq',
|
|
224
305
|
attrs: {
|
|
225
|
-
to: S_WHATSAPP_NET,
|
|
306
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
226
307
|
type: 'set',
|
|
227
308
|
xmlns: 'status'
|
|
228
309
|
},
|
|
@@ -233,29 +314,34 @@ export const makeChatsSocket = (config) => {
|
|
|
233
314
|
content: Buffer.from(status, 'utf-8')
|
|
234
315
|
}
|
|
235
316
|
]
|
|
236
|
-
})
|
|
237
|
-
}
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
|
|
238
320
|
const updateProfileName = async (name) => {
|
|
239
|
-
await chatModify({ pushNameSetting: name }, '')
|
|
240
|
-
}
|
|
321
|
+
await chatModify({ pushNameSetting: name }, '')
|
|
322
|
+
}
|
|
323
|
+
|
|
241
324
|
const fetchBlocklist = async () => {
|
|
242
325
|
const result = await query({
|
|
243
326
|
tag: 'iq',
|
|
244
327
|
attrs: {
|
|
245
328
|
xmlns: 'blocklist',
|
|
246
|
-
to: S_WHATSAPP_NET,
|
|
329
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
247
330
|
type: 'get'
|
|
248
331
|
}
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
const listNode = WABinary_1.getBinaryNodeChild(result, 'list')
|
|
335
|
+
|
|
336
|
+
return WABinary_1.getBinaryNodeChildren(listNode, 'item').map((n) => n.attrs.jid)
|
|
337
|
+
}
|
|
338
|
+
|
|
253
339
|
const updateBlockStatus = async (jid, action) => {
|
|
254
340
|
await query({
|
|
255
341
|
tag: 'iq',
|
|
256
342
|
attrs: {
|
|
257
343
|
xmlns: 'blocklist',
|
|
258
|
-
to: S_WHATSAPP_NET,
|
|
344
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
259
345
|
type: 'set'
|
|
260
346
|
},
|
|
261
347
|
content: [
|
|
@@ -267,8 +353,9 @@ export const makeChatsSocket = (config) => {
|
|
|
267
353
|
}
|
|
268
354
|
}
|
|
269
355
|
]
|
|
270
|
-
})
|
|
271
|
-
}
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
|
|
272
359
|
const getBusinessProfile = async (jid) => {
|
|
273
360
|
const results = await query({
|
|
274
361
|
tag: 'iq',
|
|
@@ -277,116 +364,121 @@ export const makeChatsSocket = (config) => {
|
|
|
277
364
|
xmlns: 'w:biz',
|
|
278
365
|
type: 'get'
|
|
279
366
|
},
|
|
280
|
-
content: [
|
|
281
|
-
{
|
|
367
|
+
content: [{
|
|
282
368
|
tag: 'business_profile',
|
|
283
369
|
attrs: { v: '244' },
|
|
284
|
-
content: [
|
|
285
|
-
{
|
|
370
|
+
content: [{
|
|
286
371
|
tag: 'profile',
|
|
287
372
|
attrs: { jid }
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const profiles = getBinaryNodeChild(profileNode, 'profile')
|
|
373
|
+
}]
|
|
374
|
+
}]
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
const profileNode = WABinary_1.getBinaryNodeChild(results, 'business_profile')
|
|
378
|
+
|
|
379
|
+
const profiles = WABinary_1.getBinaryNodeChild(profileNode, 'profile')
|
|
380
|
+
|
|
295
381
|
if (profiles) {
|
|
296
|
-
const address = getBinaryNodeChild(profiles, 'address')
|
|
297
|
-
const description = getBinaryNodeChild(profiles, 'description')
|
|
298
|
-
const website = getBinaryNodeChild(profiles, 'website')
|
|
299
|
-
const email = getBinaryNodeChild(profiles, 'email')
|
|
300
|
-
const category = getBinaryNodeChild(getBinaryNodeChild(profiles, 'categories'), 'category')
|
|
301
|
-
const businessHours = getBinaryNodeChild(profiles, 'business_hours')
|
|
382
|
+
const address = WABinary_1.getBinaryNodeChild(profiles, 'address')
|
|
383
|
+
const description = WABinary_1.getBinaryNodeChild(profiles, 'description')
|
|
384
|
+
const website = WABinary_1.getBinaryNodeChild(profiles, 'website')
|
|
385
|
+
const email = WABinary_1.getBinaryNodeChild(profiles, 'email')
|
|
386
|
+
const category = WABinary_1.getBinaryNodeChild(WABinary_1.getBinaryNodeChild(profiles, 'categories'), 'category')
|
|
387
|
+
const businessHours = WABinary_1.getBinaryNodeChild(profiles, 'business_hours')
|
|
302
388
|
const businessHoursConfig = businessHours
|
|
303
|
-
? getBinaryNodeChildren(businessHours, 'business_hours_config')
|
|
304
|
-
: undefined
|
|
305
|
-
const websiteStr = website?.content?.toString()
|
|
389
|
+
? WABinary_1.getBinaryNodeChildren(businessHours, 'business_hours_config')
|
|
390
|
+
: undefined
|
|
391
|
+
const websiteStr = website?.content?.toString()
|
|
392
|
+
|
|
306
393
|
return {
|
|
307
|
-
wid: profiles
|
|
394
|
+
wid: profiles?.attrs?.jid,
|
|
308
395
|
address: address?.content?.toString(),
|
|
309
396
|
description: description?.content?.toString() || '',
|
|
310
397
|
website: websiteStr ? [websiteStr] : [],
|
|
311
398
|
email: email?.content?.toString(),
|
|
312
399
|
category: category?.content?.toString(),
|
|
313
|
-
business_hours: {
|
|
400
|
+
'business_hours': {
|
|
314
401
|
timezone: businessHours?.attrs?.timezone,
|
|
315
|
-
business_config: businessHoursConfig?.map(({ attrs }) => attrs)
|
|
402
|
+
'business_config': businessHoursConfig?.map(({ attrs }) => attrs)
|
|
316
403
|
}
|
|
317
|
-
}
|
|
404
|
+
}
|
|
318
405
|
}
|
|
319
|
-
}
|
|
406
|
+
}
|
|
407
|
+
|
|
320
408
|
const cleanDirtyBits = async (type, fromTimestamp) => {
|
|
321
|
-
logger.info({ fromTimestamp }, 'clean dirty bits ' + type)
|
|
409
|
+
logger.info({ fromTimestamp }, 'clean dirty bits ' + type)
|
|
322
410
|
await sendNode({
|
|
323
411
|
tag: 'iq',
|
|
324
412
|
attrs: {
|
|
325
|
-
to: S_WHATSAPP_NET,
|
|
413
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
326
414
|
type: 'set',
|
|
327
415
|
xmlns: 'urn:xmpp:whatsapp:dirty',
|
|
328
|
-
id: generateMessageTag()
|
|
416
|
+
id: generateMessageTag(),
|
|
329
417
|
},
|
|
330
418
|
content: [
|
|
331
419
|
{
|
|
332
420
|
tag: 'clean',
|
|
333
421
|
attrs: {
|
|
334
422
|
type,
|
|
335
|
-
...(fromTimestamp ? { timestamp: fromTimestamp.toString() } : null)
|
|
423
|
+
...(fromTimestamp ? { timestamp: fromTimestamp.toString() } : null),
|
|
336
424
|
}
|
|
337
425
|
}
|
|
338
426
|
]
|
|
339
|
-
})
|
|
340
|
-
}
|
|
427
|
+
})
|
|
428
|
+
}
|
|
429
|
+
|
|
341
430
|
const newAppStateChunkHandler = (isInitialSync) => {
|
|
342
431
|
return {
|
|
343
432
|
onMutation(mutation) {
|
|
344
|
-
processSyncAction(mutation, ev, authState.creds.me, isInitialSync ? { accountSettings: authState.creds.accountSettings } : undefined, logger)
|
|
433
|
+
Utils_1.processSyncAction(mutation, ev, authState.creds.me, isInitialSync ? { accountSettings: authState.creds.accountSettings } : undefined, logger)
|
|
345
434
|
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
348
438
|
const resyncAppState = ev.createBufferedFunction(async (collections, isInitialSync) => {
|
|
349
439
|
// we use this to determine which events to fire
|
|
350
440
|
// otherwise when we resync from scratch -- all notifications will fire
|
|
351
|
-
const initialVersionMap = {}
|
|
352
|
-
const globalMutationMap = {}
|
|
441
|
+
const initialVersionMap = {}
|
|
442
|
+
const globalMutationMap = {}
|
|
353
443
|
await authState.keys.transaction(async () => {
|
|
354
|
-
const collectionsToHandle = new Set(collections)
|
|
444
|
+
const collectionsToHandle = new Set(collections)
|
|
355
445
|
// in case something goes wrong -- ensure we don't enter a loop that cannot be exited from
|
|
356
|
-
const attemptsMap = {}
|
|
446
|
+
const attemptsMap = {}
|
|
357
447
|
// keep executing till all collections are done
|
|
358
448
|
// sometimes a single patch request will not return all the patches (God knows why)
|
|
359
449
|
// so we fetch till they're all done (this is determined by the "has_more_patches" flag)
|
|
360
450
|
while (collectionsToHandle.size) {
|
|
361
|
-
const states = {}
|
|
362
|
-
const nodes = []
|
|
451
|
+
const states = {}
|
|
452
|
+
const nodes = []
|
|
453
|
+
|
|
363
454
|
for (const name of collectionsToHandle) {
|
|
364
|
-
const result = await authState.keys.get('app-state-sync-version', [name])
|
|
365
|
-
let state = result[name]
|
|
455
|
+
const result = await authState.keys.get('app-state-sync-version', [name])
|
|
456
|
+
let state = result[name]
|
|
366
457
|
if (state) {
|
|
367
458
|
if (typeof initialVersionMap[name] === 'undefined') {
|
|
368
|
-
initialVersionMap[name] = state.version
|
|
459
|
+
initialVersionMap[name] = state.version
|
|
369
460
|
}
|
|
370
461
|
}
|
|
371
462
|
else {
|
|
372
|
-
state = newLTHashState()
|
|
463
|
+
state = Utils_1.newLTHashState()
|
|
373
464
|
}
|
|
374
|
-
states[name] = state
|
|
375
|
-
logger.info(`resyncing ${name} from v${state.version}`)
|
|
465
|
+
states[name] = state
|
|
466
|
+
logger.info(`resyncing ${name} from v${state.version}`)
|
|
376
467
|
nodes.push({
|
|
377
468
|
tag: 'collection',
|
|
378
469
|
attrs: {
|
|
379
470
|
name,
|
|
380
471
|
version: state.version.toString(),
|
|
381
472
|
// return snapshot if being synced from scratch
|
|
382
|
-
return_snapshot: (!state.version).toString()
|
|
473
|
+
'return_snapshot': (!state.version).toString()
|
|
383
474
|
}
|
|
384
|
-
})
|
|
475
|
+
})
|
|
385
476
|
}
|
|
477
|
+
|
|
386
478
|
const result = await query({
|
|
387
479
|
tag: 'iq',
|
|
388
480
|
attrs: {
|
|
389
|
-
to: S_WHATSAPP_NET,
|
|
481
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
390
482
|
xmlns: 'w:sync:app:state',
|
|
391
483
|
type: 'set'
|
|
392
484
|
},
|
|
@@ -397,121 +489,125 @@ export const makeChatsSocket = (config) => {
|
|
|
397
489
|
content: nodes
|
|
398
490
|
}
|
|
399
491
|
]
|
|
400
|
-
})
|
|
492
|
+
})
|
|
493
|
+
|
|
401
494
|
// extract from binary node
|
|
402
|
-
const decoded = await extractSyncdPatches(result, config?.options)
|
|
495
|
+
const decoded = await Utils_1.extractSyncdPatches(result, config?.options)
|
|
496
|
+
|
|
403
497
|
for (const key in decoded) {
|
|
404
|
-
const name = key
|
|
405
|
-
const { patches, hasMorePatches, snapshot } = decoded[name]
|
|
498
|
+
const name = key
|
|
499
|
+
const { patches, hasMorePatches, snapshot } = decoded[name]
|
|
406
500
|
try {
|
|
407
501
|
if (snapshot) {
|
|
408
|
-
const { state: newState, mutationMap } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot)
|
|
409
|
-
states[name] = newState
|
|
410
|
-
Object.assign(globalMutationMap, mutationMap)
|
|
411
|
-
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`)
|
|
412
|
-
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })
|
|
502
|
+
const { state: newState, mutationMap } = await Utils_1.decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot)
|
|
503
|
+
states[name] = newState
|
|
504
|
+
Object.assign(globalMutationMap, mutationMap)
|
|
505
|
+
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`)
|
|
506
|
+
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })
|
|
413
507
|
}
|
|
508
|
+
|
|
414
509
|
// only process if there are syncd patches
|
|
415
510
|
if (patches.length) {
|
|
416
|
-
const { state: newState, mutationMap } = await decodePatches(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch)
|
|
417
|
-
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })
|
|
418
|
-
logger.info(`synced ${name} to v${newState.version}`)
|
|
419
|
-
initialVersionMap[name] = newState.version
|
|
420
|
-
Object.assign(globalMutationMap, mutationMap)
|
|
511
|
+
const { state: newState, mutationMap } = await Utils_1.decodePatches(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch)
|
|
512
|
+
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })
|
|
513
|
+
logger.info(`synced ${name} to v${newState.version}`)
|
|
514
|
+
initialVersionMap[name] = newState.version
|
|
515
|
+
Object.assign(globalMutationMap, mutationMap)
|
|
421
516
|
}
|
|
517
|
+
|
|
422
518
|
if (hasMorePatches) {
|
|
423
|
-
logger.info(`${name} has more patches...`)
|
|
519
|
+
logger.info(`${name} has more patches...`)
|
|
520
|
+
}
|
|
521
|
+
else { // collection is done with sync
|
|
522
|
+
collectionsToHandle.delete(name)
|
|
424
523
|
}
|
|
425
|
-
|
|
426
|
-
// collection is done with sync
|
|
427
|
-
collectionsToHandle.delete(name);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
524
|
+
}
|
|
430
525
|
catch (error) {
|
|
431
526
|
// if retry attempts overshoot
|
|
432
527
|
// or key not found
|
|
433
|
-
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
|
|
434
|
-
error.output?.statusCode === 404
|
|
435
|
-
error.name === 'TypeError'
|
|
436
|
-
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`)
|
|
437
|
-
await authState.keys.set({ 'app-state-sync-version': { [name]: null } })
|
|
528
|
+
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
|
|
529
|
+
|| error.output?.statusCode === 404
|
|
530
|
+
|| error.name === 'TypeError'
|
|
531
|
+
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`)
|
|
532
|
+
await authState.keys.set({ 'app-state-sync-version': { [name]: null } })
|
|
438
533
|
// increment number of retries
|
|
439
|
-
attemptsMap[name] = (attemptsMap[name] || 0) + 1
|
|
534
|
+
attemptsMap[name] = (attemptsMap[name] || 0) + 1
|
|
535
|
+
|
|
440
536
|
if (isIrrecoverableError) {
|
|
441
537
|
// stop retrying
|
|
442
|
-
collectionsToHandle.delete(name)
|
|
538
|
+
collectionsToHandle.delete(name)
|
|
443
539
|
}
|
|
444
540
|
}
|
|
445
541
|
}
|
|
446
542
|
}
|
|
447
|
-
}
|
|
448
|
-
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
const { onMutation } = newAppStateChunkHandler(isInitialSync)
|
|
546
|
+
|
|
449
547
|
for (const key in globalMutationMap) {
|
|
450
|
-
onMutation(globalMutationMap[key])
|
|
548
|
+
onMutation(globalMutationMap[key])
|
|
451
549
|
}
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
* type = "preview" for a low res picture
|
|
456
|
-
* type = "image for the high res picture"
|
|
457
|
-
*/
|
|
458
|
-
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
|
459
|
-
// TOOD: Add support for tctoken, existingID, and newsletter + group options
|
|
460
|
-
jid = jidNormalizedUser(jid);
|
|
461
|
-
const result = await query({
|
|
462
|
-
tag: 'iq',
|
|
463
|
-
attrs: {
|
|
464
|
-
target: jid,
|
|
465
|
-
to: S_WHATSAPP_NET,
|
|
466
|
-
type: 'get',
|
|
467
|
-
xmlns: 'w:profile:picture'
|
|
468
|
-
},
|
|
469
|
-
content: [{ tag: 'picture', attrs: { type, query: 'url' } }]
|
|
470
|
-
}, timeoutMs);
|
|
471
|
-
const child = getBinaryNodeChild(result, 'picture');
|
|
472
|
-
return child?.attrs?.url;
|
|
473
|
-
};
|
|
550
|
+
})
|
|
551
|
+
|
|
552
|
+
// source: https://github.com/WhiskeySockets/Baileys/pull/1677
|
|
474
553
|
const createCallLink = async (type, event, timeoutMs) => {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
554
|
+
type = type?.toLowerCase()
|
|
555
|
+
|
|
556
|
+
if (!type || (type !== 'audio' && type !== 'video')) {
|
|
557
|
+
throw new Error('Make sure the type is audio or video!')
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const result = await query({
|
|
561
|
+
tag: 'call',
|
|
562
|
+
attrs: {
|
|
563
|
+
id: generateMessageTag(),
|
|
564
|
+
to: '@call'
|
|
565
|
+
},
|
|
566
|
+
content: [{
|
|
567
|
+
tag: 'link_create',
|
|
568
|
+
attrs: {
|
|
569
|
+
media: type
|
|
570
|
+
},
|
|
571
|
+
content: event ? [{
|
|
572
|
+
tag: 'event',
|
|
573
|
+
attrs: {
|
|
574
|
+
start_time: String(event)
|
|
575
|
+
}
|
|
576
|
+
}] : undefined
|
|
577
|
+
}]
|
|
578
|
+
}, timeoutMs)
|
|
579
|
+
|
|
580
|
+
const child = WABinary_1.getBinaryNodeChild(result, 'link_create')
|
|
581
|
+
const token = child?.attrs?.token
|
|
582
|
+
|
|
583
|
+
return type === 'audio' ? Defaults_1.CALL_AUDIO_PREFIX + token : Defaults_1.CALL_VIDEO_PREFIX + token
|
|
584
|
+
}
|
|
585
|
+
|
|
492
586
|
const sendPresenceUpdate = async (type, toJid) => {
|
|
493
|
-
const me = authState.creds.me
|
|
587
|
+
const me = authState.creds.me
|
|
588
|
+
|
|
494
589
|
if (type === 'available' || type === 'unavailable') {
|
|
495
590
|
if (!me.name) {
|
|
496
|
-
logger.warn('no name present, ignoring presence update request...')
|
|
497
|
-
return
|
|
591
|
+
logger.warn('no name present, ignoring presence update request...')
|
|
592
|
+
return
|
|
498
593
|
}
|
|
499
|
-
|
|
594
|
+
|
|
595
|
+
ev.emit('connection.update', { isOnline: type === 'available' })
|
|
500
596
|
await sendNode({
|
|
501
597
|
tag: 'presence',
|
|
502
598
|
attrs: {
|
|
503
599
|
name: me.name.replace(/@/g, ''),
|
|
504
600
|
type
|
|
505
601
|
}
|
|
506
|
-
})
|
|
602
|
+
})
|
|
507
603
|
}
|
|
508
604
|
else {
|
|
509
|
-
|
|
510
|
-
|
|
605
|
+
const { server } = WABinary_1.jidDecode(toJid)
|
|
606
|
+
|
|
511
607
|
await sendNode({
|
|
512
608
|
tag: 'chatstate',
|
|
513
609
|
attrs: {
|
|
514
|
-
from:
|
|
610
|
+
from: server === 'lid' ? me.lid : me.id,
|
|
515
611
|
to: toJid
|
|
516
612
|
},
|
|
517
613
|
content: [
|
|
@@ -520,14 +616,15 @@ export const makeChatsSocket = (config) => {
|
|
|
520
616
|
attrs: type === 'recording' ? { media: 'audio' } : {}
|
|
521
617
|
}
|
|
522
618
|
]
|
|
523
|
-
})
|
|
619
|
+
})
|
|
524
620
|
}
|
|
525
|
-
}
|
|
621
|
+
}
|
|
622
|
+
|
|
526
623
|
/**
|
|
527
624
|
* @param toJid the jid to subscribe to
|
|
528
625
|
* @param tcToken token for subscription, use if present
|
|
529
626
|
*/
|
|
530
|
-
const presenceSubscribe = (toJid, tcToken) => sendNode({
|
|
627
|
+
const presenceSubscribe = (toJid, tcToken) => (sendNode({
|
|
531
628
|
tag: 'presence',
|
|
532
629
|
attrs: {
|
|
533
630
|
to: toJid,
|
|
@@ -543,58 +640,72 @@ export const makeChatsSocket = (config) => {
|
|
|
543
640
|
}
|
|
544
641
|
]
|
|
545
642
|
: undefined
|
|
546
|
-
})
|
|
643
|
+
}))
|
|
644
|
+
|
|
547
645
|
const handlePresenceUpdate = ({ tag, attrs, content }) => {
|
|
548
|
-
let presence
|
|
549
|
-
const jid = attrs.from
|
|
550
|
-
const participant = attrs.participant || attrs.from
|
|
551
|
-
|
|
552
|
-
|
|
646
|
+
let presence
|
|
647
|
+
const jid = attrs.from
|
|
648
|
+
const participant = attrs.participant || attrs.from
|
|
649
|
+
|
|
650
|
+
if (shouldIgnoreJid(jid) && jid !== '@s.whatsapp.net') {
|
|
651
|
+
return
|
|
553
652
|
}
|
|
653
|
+
|
|
554
654
|
if (tag === 'presence') {
|
|
555
655
|
presence = {
|
|
556
656
|
lastKnownPresence: attrs.type === 'unavailable' ? 'unavailable' : 'available',
|
|
557
657
|
lastSeen: attrs.last && attrs.last !== 'deny' ? +attrs.last : undefined
|
|
558
|
-
}
|
|
658
|
+
}
|
|
559
659
|
}
|
|
660
|
+
|
|
560
661
|
else if (Array.isArray(content)) {
|
|
561
|
-
const [firstChild] = content
|
|
562
|
-
let type = firstChild.tag
|
|
662
|
+
const [firstChild] = content
|
|
663
|
+
let type = firstChild.tag
|
|
664
|
+
|
|
563
665
|
if (type === 'paused') {
|
|
564
|
-
type = 'available'
|
|
666
|
+
type = 'available'
|
|
565
667
|
}
|
|
668
|
+
|
|
566
669
|
if (firstChild.attrs?.media === 'audio') {
|
|
567
|
-
type = 'recording'
|
|
670
|
+
type = 'recording'
|
|
568
671
|
}
|
|
569
|
-
|
|
672
|
+
|
|
673
|
+
presence = { lastKnownPresence: type }
|
|
570
674
|
}
|
|
675
|
+
|
|
571
676
|
else {
|
|
572
|
-
logger.error({ tag, attrs, content }, 'recv invalid presence node')
|
|
677
|
+
logger.error({ tag, attrs, content }, 'recv invalid presence node')
|
|
573
678
|
}
|
|
679
|
+
|
|
574
680
|
if (presence) {
|
|
575
|
-
ev.emit('presence.update', { id: jid, presences: { [participant]: presence } })
|
|
681
|
+
ev.emit('presence.update', { id: jid, presences: { [participant]: presence } })
|
|
576
682
|
}
|
|
577
|
-
}
|
|
683
|
+
}
|
|
684
|
+
|
|
578
685
|
const appPatch = async (patchCreate) => {
|
|
579
|
-
const name = patchCreate.type
|
|
580
|
-
const myAppStateKeyId = authState.creds.myAppStateKeyId
|
|
686
|
+
const name = patchCreate.type
|
|
687
|
+
const myAppStateKeyId = authState.creds.myAppStateKeyId
|
|
688
|
+
|
|
581
689
|
if (!myAppStateKeyId) {
|
|
582
|
-
throw new Boom('App state key not present!', { statusCode: 400 })
|
|
690
|
+
throw new boom_1.Boom('App state key not present!', { statusCode: 400 })
|
|
583
691
|
}
|
|
584
|
-
|
|
585
|
-
let
|
|
692
|
+
|
|
693
|
+
let initial
|
|
694
|
+
let encodeResult
|
|
695
|
+
|
|
586
696
|
await processingMutex.mutex(async () => {
|
|
587
697
|
await authState.keys.transaction(async () => {
|
|
588
|
-
logger.debug({ patch: patchCreate }, 'applying app patch')
|
|
589
|
-
await resyncAppState([name], false)
|
|
590
|
-
const { [name]: currentSyncVersion } = await authState.keys.get('app-state-sync-version', [name])
|
|
591
|
-
initial = currentSyncVersion || newLTHashState()
|
|
592
|
-
encodeResult = await encodeSyncdPatch(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey)
|
|
593
|
-
const { patch, state } = encodeResult
|
|
698
|
+
logger.debug({ patch: patchCreate }, 'applying app patch')
|
|
699
|
+
await resyncAppState([name], false)
|
|
700
|
+
const { [name]: currentSyncVersion } = await authState.keys.get('app-state-sync-version', [name])
|
|
701
|
+
initial = currentSyncVersion || Utils_1.newLTHashState()
|
|
702
|
+
encodeResult = await Utils_1.encodeSyncdPatch(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey)
|
|
703
|
+
const { patch, state } = encodeResult
|
|
704
|
+
|
|
594
705
|
const node = {
|
|
595
706
|
tag: 'iq',
|
|
596
707
|
attrs: {
|
|
597
|
-
to: S_WHATSAPP_NET,
|
|
708
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
598
709
|
type: 'set',
|
|
599
710
|
xmlns: 'w:sync:app:state'
|
|
600
711
|
},
|
|
@@ -608,82 +719,88 @@ export const makeChatsSocket = (config) => {
|
|
|
608
719
|
attrs: {
|
|
609
720
|
name,
|
|
610
721
|
version: (state.version - 1).toString(),
|
|
611
|
-
return_snapshot: 'false'
|
|
722
|
+
'return_snapshot': 'false'
|
|
612
723
|
},
|
|
613
724
|
content: [
|
|
614
725
|
{
|
|
615
726
|
tag: 'patch',
|
|
616
727
|
attrs: {},
|
|
617
|
-
content: proto.SyncdPatch.encode(patch).finish()
|
|
728
|
+
content: WAProto_1.proto.SyncdPatch.encode(patch).finish()
|
|
618
729
|
}
|
|
619
730
|
]
|
|
620
731
|
}
|
|
621
732
|
]
|
|
622
733
|
}
|
|
623
734
|
]
|
|
624
|
-
}
|
|
625
|
-
await query(node)
|
|
626
|
-
await authState.keys.set({ 'app-state-sync-version': { [name]: state } })
|
|
627
|
-
}
|
|
628
|
-
})
|
|
735
|
+
}
|
|
736
|
+
await query(node)
|
|
737
|
+
await authState.keys.set({ 'app-state-sync-version': { [name]: state } })
|
|
738
|
+
})
|
|
739
|
+
})
|
|
740
|
+
|
|
629
741
|
if (config.emitOwnEvents) {
|
|
630
|
-
const { onMutation } = newAppStateChunkHandler(false)
|
|
631
|
-
const { mutationMap } = await decodePatches(name, [{ ...encodeResult.patch, version: { version: encodeResult.state.version } }], initial, getAppStateSyncKey, config.options, undefined, logger)
|
|
742
|
+
const { onMutation } = newAppStateChunkHandler(false)
|
|
743
|
+
const { mutationMap } = await Utils_1.decodePatches(name, [{ ...encodeResult.patch, version: { version: encodeResult.state.version }, }], initial, getAppStateSyncKey, config.options, undefined, logger)
|
|
744
|
+
|
|
632
745
|
for (const key in mutationMap) {
|
|
633
|
-
onMutation(mutationMap[key])
|
|
746
|
+
onMutation(mutationMap[key])
|
|
634
747
|
}
|
|
635
748
|
}
|
|
636
|
-
}
|
|
749
|
+
}
|
|
750
|
+
|
|
637
751
|
/** sending non-abt props may fix QR scan fail if server expects */
|
|
638
752
|
const fetchProps = async () => {
|
|
639
|
-
//TODO: implement both protocol 1 and protocol 2 prop fetching, specially for abKey for WM
|
|
640
753
|
const resultNode = await query({
|
|
641
754
|
tag: 'iq',
|
|
642
755
|
attrs: {
|
|
643
|
-
to: S_WHATSAPP_NET,
|
|
756
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
644
757
|
xmlns: 'w',
|
|
645
|
-
type: 'get'
|
|
758
|
+
type: 'get',
|
|
646
759
|
},
|
|
647
760
|
content: [
|
|
648
|
-
{
|
|
649
|
-
tag: 'props',
|
|
650
|
-
attrs: {
|
|
761
|
+
{ tag: 'props', attrs: {
|
|
651
762
|
protocol: '2',
|
|
652
763
|
hash: authState?.creds?.lastPropHash || ''
|
|
653
|
-
}
|
|
654
|
-
}
|
|
764
|
+
} }
|
|
655
765
|
]
|
|
656
|
-
})
|
|
657
|
-
|
|
658
|
-
|
|
766
|
+
})
|
|
767
|
+
|
|
768
|
+
const propsNode = WABinary_1.getBinaryNodeChild(resultNode, 'props')
|
|
769
|
+
let props = {}
|
|
770
|
+
|
|
659
771
|
if (propsNode) {
|
|
660
|
-
if (propsNode.attrs?.hash) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
ev.emit('creds.update', authState.creds);
|
|
772
|
+
if (propsNode.attrs?.hash) { // on some clients, the hash is returning as undefined
|
|
773
|
+
authState.creds.lastPropHash = propsNode?.attrs?.hash
|
|
774
|
+
ev.emit('creds.update', authState.creds)
|
|
664
775
|
}
|
|
665
|
-
|
|
776
|
+
|
|
777
|
+
props = WABinary_1.reduceBinaryNodeToDictionary(propsNode, 'prop')
|
|
666
778
|
}
|
|
667
|
-
logger.debug('fetched props')
|
|
668
|
-
return props
|
|
669
|
-
}
|
|
779
|
+
logger.debug('fetched props')
|
|
780
|
+
return props
|
|
781
|
+
}
|
|
782
|
+
|
|
670
783
|
/**
|
|
671
784
|
* modify a chat -- mark unread, read etc.
|
|
672
785
|
* lastMessages must be sorted in reverse chronologically
|
|
673
|
-
* requires the last messages till the last message received
|
|
674
|
-
|
|
786
|
+
* requires the last messages till the last message received required for archive & unread
|
|
787
|
+
*/
|
|
675
788
|
const chatModify = (mod, jid) => {
|
|
676
|
-
const patch = chatModificationToAppPatch(mod, jid)
|
|
677
|
-
return appPatch(patch)
|
|
678
|
-
}
|
|
789
|
+
const patch = Utils_1.chatModificationToAppPatch(mod, jid)
|
|
790
|
+
return appPatch(patch)
|
|
791
|
+
}
|
|
792
|
+
|
|
679
793
|
/**
|
|
680
794
|
* Enable/Disable link preview privacy, not related to baileys link preview generation
|
|
681
795
|
*/
|
|
682
796
|
const updateDisableLinkPreviewsPrivacy = (isPreviewsDisabled) => {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
797
|
+
return chatModify({
|
|
798
|
+
disableLinkPreviews: {
|
|
799
|
+
isPreviewsDisabled
|
|
800
|
+
}
|
|
801
|
+
}, '')
|
|
802
|
+
}
|
|
803
|
+
|
|
687
804
|
/**
|
|
688
805
|
* Star or Unstar a message
|
|
689
806
|
*/
|
|
@@ -693,24 +810,27 @@ export const makeChatsSocket = (config) => {
|
|
|
693
810
|
messages,
|
|
694
811
|
star
|
|
695
812
|
}
|
|
696
|
-
}, jid)
|
|
697
|
-
}
|
|
813
|
+
}, jid)
|
|
814
|
+
}
|
|
815
|
+
|
|
698
816
|
/**
|
|
699
|
-
* Add
|
|
817
|
+
* Add Or Edit Contact
|
|
700
818
|
*/
|
|
701
819
|
const addOrEditContact = (jid, contact) => {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}, jid)
|
|
705
|
-
}
|
|
820
|
+
return chatModify({
|
|
821
|
+
contact
|
|
822
|
+
}, jid)
|
|
823
|
+
}
|
|
824
|
+
|
|
706
825
|
/**
|
|
707
826
|
* Remove Contact
|
|
708
827
|
*/
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
828
|
+
const removeContact = (jid) => {
|
|
829
|
+
return chatModify({
|
|
830
|
+
contact: null
|
|
831
|
+
}, jid)
|
|
832
|
+
}
|
|
833
|
+
|
|
714
834
|
/**
|
|
715
835
|
* Adds label
|
|
716
836
|
*/
|
|
@@ -719,8 +839,9 @@ export const makeChatsSocket = (config) => {
|
|
|
719
839
|
addLabel: {
|
|
720
840
|
...labels
|
|
721
841
|
}
|
|
722
|
-
}, jid)
|
|
723
|
-
}
|
|
842
|
+
}, jid)
|
|
843
|
+
}
|
|
844
|
+
|
|
724
845
|
/**
|
|
725
846
|
* Adds label for the chats
|
|
726
847
|
*/
|
|
@@ -729,8 +850,9 @@ export const makeChatsSocket = (config) => {
|
|
|
729
850
|
addChatLabel: {
|
|
730
851
|
labelId
|
|
731
852
|
}
|
|
732
|
-
}, jid)
|
|
733
|
-
}
|
|
853
|
+
}, jid)
|
|
854
|
+
}
|
|
855
|
+
|
|
734
856
|
/**
|
|
735
857
|
* Removes label for the chat
|
|
736
858
|
*/
|
|
@@ -739,8 +861,9 @@ export const makeChatsSocket = (config) => {
|
|
|
739
861
|
removeChatLabel: {
|
|
740
862
|
labelId
|
|
741
863
|
}
|
|
742
|
-
}, jid)
|
|
743
|
-
}
|
|
864
|
+
}, jid)
|
|
865
|
+
}
|
|
866
|
+
|
|
744
867
|
/**
|
|
745
868
|
* Adds label for the message
|
|
746
869
|
*/
|
|
@@ -750,8 +873,9 @@ export const makeChatsSocket = (config) => {
|
|
|
750
873
|
messageId,
|
|
751
874
|
labelId
|
|
752
875
|
}
|
|
753
|
-
}, jid)
|
|
754
|
-
}
|
|
876
|
+
}, jid)
|
|
877
|
+
}
|
|
878
|
+
|
|
755
879
|
/**
|
|
756
880
|
* Removes label for the message
|
|
757
881
|
*/
|
|
@@ -761,170 +885,198 @@ export const makeChatsSocket = (config) => {
|
|
|
761
885
|
messageId,
|
|
762
886
|
labelId
|
|
763
887
|
}
|
|
764
|
-
}, jid)
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
* Add or Edit Quick Reply
|
|
768
|
-
*/
|
|
769
|
-
const addOrEditQuickReply = (quickReply) => {
|
|
770
|
-
return chatModify({
|
|
771
|
-
quickReply
|
|
772
|
-
}, '');
|
|
773
|
-
};
|
|
888
|
+
}, jid)
|
|
889
|
+
}
|
|
890
|
+
|
|
774
891
|
/**
|
|
775
|
-
*
|
|
892
|
+
* Removes Chats
|
|
776
893
|
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
894
|
+
const clearMessage = (jid, key, timeStamp) => {
|
|
895
|
+
return chatModify({
|
|
896
|
+
delete: true,
|
|
897
|
+
lastMessages: [{
|
|
898
|
+
key: key,
|
|
899
|
+
messageTimestamp: timeStamp
|
|
900
|
+
}],
|
|
901
|
+
}, jid)
|
|
902
|
+
}
|
|
903
|
+
|
|
782
904
|
/**
|
|
783
905
|
* queries need to be fired on connection open
|
|
784
906
|
* help ensure parity with WA Web
|
|
785
907
|
* */
|
|
786
908
|
const executeInitQueries = async () => {
|
|
787
|
-
await Promise.all([
|
|
788
|
-
|
|
909
|
+
await Promise.all([
|
|
910
|
+
fetchProps(),
|
|
911
|
+
fetchBlocklist(),
|
|
912
|
+
fetchPrivacySettings(),
|
|
913
|
+
])
|
|
914
|
+
}
|
|
915
|
+
|
|
789
916
|
const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
|
|
790
|
-
ev.emit('messages.upsert', { messages: [msg], type })
|
|
917
|
+
ev.emit('messages.upsert', { messages: [msg], type })
|
|
791
918
|
if (!!msg.pushName) {
|
|
792
|
-
let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid
|
|
793
|
-
jid = jidNormalizedUser(jid)
|
|
919
|
+
let jid = msg.key.fromMe ? authState.creds.me.id : (msg.key.participant || msg.key.remoteJid)
|
|
920
|
+
jid = WABinary_1.jidNormalizedUser(jid)
|
|
921
|
+
|
|
794
922
|
if (!msg.key.fromMe) {
|
|
795
|
-
ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }])
|
|
923
|
+
ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }])
|
|
796
924
|
}
|
|
925
|
+
|
|
797
926
|
// update our pushname too
|
|
798
927
|
if (msg.key.fromMe && msg.pushName && authState.creds.me?.name !== msg.pushName) {
|
|
799
|
-
ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } })
|
|
928
|
+
ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } })
|
|
800
929
|
}
|
|
801
930
|
}
|
|
802
|
-
|
|
931
|
+
|
|
932
|
+
const historyMsg = Utils_1.getHistoryMsg(msg.message)
|
|
803
933
|
const shouldProcessHistoryMsg = historyMsg
|
|
804
|
-
? shouldSyncHistoryMessage(historyMsg)
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
934
|
+
? (shouldSyncHistoryMessage(historyMsg)
|
|
935
|
+
&& Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
|
|
936
|
+
: false
|
|
937
|
+
|
|
938
|
+
if (historyMsg && syncState === Types_1.SyncState.AwaitingInitialSync) {
|
|
808
939
|
if (awaitingSyncTimeout) {
|
|
809
|
-
|
|
810
|
-
|
|
940
|
+
clearTimeout(awaitingSyncTimeout)
|
|
941
|
+
awaitingSyncTimeout = undefined
|
|
811
942
|
}
|
|
943
|
+
|
|
812
944
|
if (shouldProcessHistoryMsg) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
ev.flush();
|
|
945
|
+
syncState = Types_1.SyncState.Syncing
|
|
946
|
+
logger.info('Transitioned to Syncing state')
|
|
947
|
+
// Let doAppStateSync handle the final flush after it`s done
|
|
948
|
+
} else {
|
|
949
|
+
syncState = Types_1.SyncState.Online
|
|
950
|
+
logger.info('History sync skipped, transitioning to Online state and flushing buffer')
|
|
951
|
+
ev.flush()
|
|
821
952
|
}
|
|
822
953
|
}
|
|
954
|
+
|
|
823
955
|
const doAppStateSync = async () => {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
956
|
+
if (syncState === Types_1.SyncState.Syncing) {
|
|
957
|
+
logger.info('Doing app state sync')
|
|
958
|
+
await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true)
|
|
959
|
+
|
|
960
|
+
// Sync is complete, go online and flush everything
|
|
961
|
+
syncState = Types_1.SyncState.Online
|
|
962
|
+
logger.info('App state sync complete, transitioning to Online state and flushing buffer')
|
|
963
|
+
ev.flush()
|
|
964
|
+
|
|
965
|
+
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1
|
|
966
|
+
ev.emit('creds.update', { accountSyncCounter })
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
835
970
|
await Promise.all([
|
|
836
971
|
(async () => {
|
|
837
972
|
if (shouldProcessHistoryMsg) {
|
|
838
|
-
await doAppStateSync()
|
|
973
|
+
await doAppStateSync()
|
|
839
974
|
}
|
|
840
975
|
})(),
|
|
841
|
-
processMessage(msg, {
|
|
842
|
-
signalRepository,
|
|
976
|
+
Utils_1.processMessage(msg, {
|
|
843
977
|
shouldProcessHistoryMsg,
|
|
844
978
|
placeholderResendCache,
|
|
845
979
|
ev,
|
|
846
980
|
creds: authState.creds,
|
|
847
981
|
keyStore: authState.keys,
|
|
848
982
|
logger,
|
|
849
|
-
options: config.options
|
|
983
|
+
options: config.options,
|
|
984
|
+
getMessage: config.getMessage,
|
|
850
985
|
})
|
|
851
|
-
])
|
|
852
|
-
|
|
853
|
-
if (msg.message?.protocolMessage?.appStateSyncKeyShare && syncState === SyncState.Syncing) {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
})
|
|
858
|
-
|
|
859
|
-
ws.on('CB:
|
|
986
|
+
])
|
|
987
|
+
|
|
988
|
+
if (msg.message?.protocolMessage?.appStateSyncKeyShare && syncState === Types_1.SyncState.Syncing) {
|
|
989
|
+
logger.info('App state sync key arrived, triggering app state sync')
|
|
990
|
+
await doAppStateSync()
|
|
991
|
+
}
|
|
992
|
+
})
|
|
993
|
+
|
|
994
|
+
ws.on('CB:presence', handlePresenceUpdate)
|
|
995
|
+
ws.on('CB:chatstate', handlePresenceUpdate)
|
|
860
996
|
ws.on('CB:ib,,dirty', async (node) => {
|
|
861
|
-
const { attrs } = getBinaryNodeChild(node, 'dirty')
|
|
862
|
-
const type = attrs.type
|
|
997
|
+
const { attrs } = WABinary_1.getBinaryNodeChild(node, 'dirty')
|
|
998
|
+
const type = attrs.type
|
|
999
|
+
|
|
863
1000
|
switch (type) {
|
|
864
1001
|
case 'account_sync':
|
|
865
1002
|
if (attrs.timestamp) {
|
|
866
|
-
let { lastAccountSyncTimestamp } = authState.creds
|
|
1003
|
+
let { lastAccountSyncTimestamp } = authState.creds
|
|
867
1004
|
if (lastAccountSyncTimestamp) {
|
|
868
|
-
await cleanDirtyBits('account_sync', lastAccountSyncTimestamp)
|
|
1005
|
+
await cleanDirtyBits('account_sync', lastAccountSyncTimestamp)
|
|
869
1006
|
}
|
|
870
|
-
lastAccountSyncTimestamp = +attrs.timestamp
|
|
871
|
-
ev.emit('creds.update', { lastAccountSyncTimestamp })
|
|
1007
|
+
lastAccountSyncTimestamp = +attrs.timestamp
|
|
1008
|
+
ev.emit('creds.update', { lastAccountSyncTimestamp })
|
|
872
1009
|
}
|
|
873
|
-
break
|
|
1010
|
+
break
|
|
874
1011
|
case 'groups':
|
|
875
|
-
|
|
876
|
-
|
|
1012
|
+
await groupFetchAllParticipating()
|
|
1013
|
+
await cleanDirtyBits('groups')
|
|
1014
|
+
break
|
|
877
1015
|
default:
|
|
878
|
-
logger.info({ node }, 'received unknown sync')
|
|
879
|
-
break
|
|
1016
|
+
logger.info({ node }, 'received unknown sync')
|
|
1017
|
+
break
|
|
880
1018
|
}
|
|
881
|
-
})
|
|
1019
|
+
})
|
|
1020
|
+
|
|
882
1021
|
ev.on('connection.update', ({ connection, receivedPendingNotifications }) => {
|
|
883
1022
|
if (connection === 'open') {
|
|
884
1023
|
if (fireInitQueries) {
|
|
885
|
-
executeInitQueries()
|
|
1024
|
+
executeInitQueries()
|
|
1025
|
+
.catch(error => onUnexpectedError(error, 'init queries'))
|
|
886
1026
|
}
|
|
887
|
-
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
1027
|
+
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
1028
|
+
.catch(error => onUnexpectedError(error, 'presence update requests'))
|
|
888
1029
|
}
|
|
889
|
-
|
|
890
|
-
|
|
1030
|
+
|
|
1031
|
+
if (!receivedPendingNotifications || syncState !== Types_1.SyncState.Connecting) {
|
|
1032
|
+
return
|
|
891
1033
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1034
|
+
|
|
1035
|
+
syncState = Types_1.AwaitingInitialSync
|
|
1036
|
+
logger.info('Connection is now AwaitingInitialSync, buffering events')
|
|
1037
|
+
ev.buffer()
|
|
1038
|
+
|
|
1039
|
+
const willSyncHistory = shouldSyncHistoryMessage(WAProto_1.proto.Message.HistorySyncNotification.fromObject({
|
|
1040
|
+
syncType: WAProto_1.proto.HistorySync.HistorySyncType.RECENT
|
|
1041
|
+
}))
|
|
1042
|
+
|
|
898
1043
|
if (!willSyncHistory) {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1044
|
+
logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.')
|
|
1045
|
+
syncState = Types_1.SyncState.Online
|
|
1046
|
+
setTimeout(() => ev.flush(), 0)
|
|
1047
|
+
return
|
|
903
1048
|
}
|
|
904
|
-
|
|
1049
|
+
|
|
1050
|
+
logger.info('History sync is enabled, awaiting notification with a 20s timeout.')
|
|
1051
|
+
|
|
905
1052
|
if (awaitingSyncTimeout) {
|
|
906
|
-
|
|
1053
|
+
clearTimeout(awaitingSyncTimeout)
|
|
907
1054
|
}
|
|
1055
|
+
|
|
908
1056
|
awaitingSyncTimeout = setTimeout(() => {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1057
|
+
if (syncState === Types_1.SyncState.AwaitingInitialSync) {
|
|
1058
|
+
logger.warn('Timeout in AwaitingInitialSync, forcing state to Online and flushing buffer')
|
|
1059
|
+
syncState = Types_1.SyncState.Online
|
|
1060
|
+
ev.flush()
|
|
1061
|
+
}
|
|
1062
|
+
}, 20_000)
|
|
1063
|
+
})
|
|
1064
|
+
|
|
917
1065
|
return {
|
|
918
|
-
...
|
|
919
|
-
|
|
920
|
-
|
|
1066
|
+
...Neele,
|
|
1067
|
+
star,
|
|
1068
|
+
addOrEditContact,
|
|
1069
|
+
removeContact,
|
|
921
1070
|
processingMutex,
|
|
922
1071
|
fetchPrivacySettings,
|
|
923
1072
|
upsertMessage,
|
|
924
1073
|
appPatch,
|
|
1074
|
+
createCallLink,
|
|
925
1075
|
sendPresenceUpdate,
|
|
926
|
-
presenceSubscribe,
|
|
927
|
-
|
|
1076
|
+
presenceSubscribe,
|
|
1077
|
+
getBotListV2,
|
|
1078
|
+
getLidUser,
|
|
1079
|
+
onWhatsApp,
|
|
928
1080
|
fetchBlocklist,
|
|
929
1081
|
fetchStatus,
|
|
930
1082
|
fetchDisappearingDuration,
|
|
@@ -933,9 +1085,8 @@ export const makeChatsSocket = (config) => {
|
|
|
933
1085
|
updateProfileStatus,
|
|
934
1086
|
updateProfileName,
|
|
935
1087
|
updateBlockStatus,
|
|
936
|
-
updateDisableLinkPreviewsPrivacy,
|
|
937
1088
|
updateCallPrivacy,
|
|
938
|
-
updateMessagesPrivacy,
|
|
1089
|
+
updateMessagesPrivacy,
|
|
939
1090
|
updateLastSeenPrivacy,
|
|
940
1091
|
updateOnlinePrivacy,
|
|
941
1092
|
updateProfilePicturePrivacy,
|
|
@@ -943,20 +1094,20 @@ export const makeChatsSocket = (config) => {
|
|
|
943
1094
|
updateReadReceiptsPrivacy,
|
|
944
1095
|
updateGroupsAddPrivacy,
|
|
945
1096
|
updateDefaultDisappearingMode,
|
|
1097
|
+
updateDisableLinkPreviewsPrivacy,
|
|
946
1098
|
getBusinessProfile,
|
|
947
1099
|
resyncAppState,
|
|
948
1100
|
chatModify,
|
|
949
1101
|
cleanDirtyBits,
|
|
950
|
-
addOrEditContact,
|
|
951
|
-
removeContact,
|
|
952
1102
|
addLabel,
|
|
953
1103
|
addChatLabel,
|
|
954
1104
|
removeChatLabel,
|
|
955
1105
|
addMessageLabel,
|
|
956
1106
|
removeMessageLabel,
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1107
|
+
clearMessage
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
module.exports = {
|
|
1112
|
+
makeChatsSocket
|
|
1113
|
+
}
|