@queenanya/baileys 8.6.0-beta → 9.0.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/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +4633 -0
- package/WAProto/fix-imports.js +29 -0
- package/WAProto/index.d.ts +2165 -45253
- package/WAProto/index.js +45236 -130529
- package/lib/Defaults/index.d.ts +14 -3
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +64 -55
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +2 -5
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +4 -3
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +7 -41
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +4 -4
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +37 -51
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -11
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -57
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +2 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +7 -44
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +3 -2
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +7 -15
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +2 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +8 -11
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +2 -1
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +9 -12
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +2 -5
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +3 -2
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +9 -21
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +7 -6
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +27 -42
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +4 -7
- 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 +258 -90
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +23 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +171 -0
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -18
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +2 -2
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +4 -6
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +2 -2
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +15 -37
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +106 -94
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +159 -43
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +39 -27
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +271 -261
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +111 -86
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +138 -70
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts +53 -43
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +94 -99
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +133 -108
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +17 -9
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +90 -82
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +635 -480
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +90 -76
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +476 -402
- 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 +83 -73
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +181 -202
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +24 -16
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +402 -196
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +13 -5
- 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 +1 -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 +18 -9
- 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 +5 -4
- 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 +36 -33
- 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 +12 -11
- 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 +12 -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 +51 -148
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -7
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +173 -71
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +54 -11
- 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 +34 -20
- 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 -14
- 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 +5 -4
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +199 -141
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/baileys-event-stream.d.ts +2 -1
- package/lib/Utils/baileys-event-stream.d.ts.map +1 -0
- package/lib/Utils/baileys-event-stream.js +15 -22
- package/lib/Utils/baileys-event-stream.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 +3 -2
- 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 +11 -11
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +203 -194
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +8 -7
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +50 -101
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +18 -5
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +134 -62
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +6 -7
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +99 -69
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +57 -68
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +179 -356
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +10 -10
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +37 -50
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/index.d.ts +21 -17
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +21 -33
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +15 -56
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +8 -6
- 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 +9 -8
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +23 -26
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +1 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +7 -10
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +82 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +149 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +32 -38
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +283 -496
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +11 -10
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +309 -519
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +5 -4
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +23 -26
- package/lib/Utils/noise-handler.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 +12 -12
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +196 -155
- package/lib/Utils/process-message.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 +70 -64
- package/lib/Utils/signal.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 +23 -27
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +3 -2
- package/lib/Utils/use-single-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-single-file-auth-state.js +63 -41
- package/lib/Utils/use-single-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +4 -3
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +99 -77
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +1 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +9 -11
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +2 -1
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +25 -52
- 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 +14 -48
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +4 -3
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +31 -39
- 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 +23 -10
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +75 -60
- 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 +2 -1
- 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/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 +8 -11
- 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 +6 -5
- 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 +10 -12
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -34
- package/lib/index.js.map +1 -0
- package/package.json +55 -65
- package/CHANGELOG.md +0 -4
- package/README-anya.md +0 -459
- package/README-shizo.md +0 -445
- package/README-whiskey.md +0 -44
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -2
- package/lib/Store/index.js +0 -8
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-in-memory-store.js +0 -429
- 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/WAMedia/index.d.ts +0 -2
- package/lib/WAMedia/index.js +0 -18
- package/lib/WAMedia/media-messages.d.ts +0 -18
- package/lib/WAMedia/media-messages.js +0 -102
- package/lib/WAMedia/media-set.d.ts +0 -9
- package/lib/WAMedia/media-set.js +0 -312
package/lib/Socket/chats.js
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const make_mutex_1 = require("../Utils/make-mutex");
|
|
14
|
-
const process_message_1 = __importDefault(require("../Utils/process-message"));
|
|
15
|
-
const WABinary_1 = require("../WABinary");
|
|
16
|
-
const WAMedia_1 = require("../WAMedia");
|
|
17
|
-
const WAUSync_1 = require("../WAUSync");
|
|
18
|
-
const usync_1 = require("./usync");
|
|
1
|
+
import NodeCache from '@cacheable/node-cache';
|
|
2
|
+
import { Boom } from '@hapi/boom';
|
|
3
|
+
import { proto } from '../../WAProto/index.js';
|
|
4
|
+
import { DEFAULT_CACHE_TTLS, PROCESSABLE_HISTORY_TYPES } from '../Defaults/index.js';
|
|
5
|
+
import { ALL_WA_PATCH_NAMES } from '../Types/index.js';
|
|
6
|
+
import { SyncState } from '../Types/State.js';
|
|
7
|
+
import { chatModificationToAppPatch, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, extractSyncdPatches, generateProfilePicture, getHistoryMsg, newLTHashState, processSyncAction } from '../Utils/index.js';
|
|
8
|
+
import { makeMutex } from '../Utils/make-mutex.js';
|
|
9
|
+
import processMessage from '../Utils/process-message.js';
|
|
10
|
+
import { getBinaryNodeChild, getBinaryNodeChildren, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
11
|
+
import { USyncQuery, USyncUser } from '../WAUSync/index.js';
|
|
12
|
+
import { makeSocket } from './socket.js';
|
|
19
13
|
const MAX_SYNC_ATTEMPTS = 2;
|
|
20
|
-
const makeChatsSocket = (config) => {
|
|
21
|
-
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage
|
|
22
|
-
const sock = (
|
|
23
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query,
|
|
14
|
+
export const makeChatsSocket = (config) => {
|
|
15
|
+
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage } = config;
|
|
16
|
+
const sock = makeSocket(config);
|
|
17
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, signalRepository, onUnexpectedError } = sock;
|
|
24
18
|
let privacySettings;
|
|
25
|
-
let
|
|
26
|
-
let pendingAppStateSync = false;
|
|
19
|
+
let syncState = SyncState.Connecting;
|
|
27
20
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
28
|
-
const processingMutex =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
const processingMutex = makeMutex();
|
|
22
|
+
// Timeout for AwaitingInitialSync state
|
|
23
|
+
let awaitingSyncTimeout;
|
|
24
|
+
const placeholderResendCache = config.placeholderResendCache ||
|
|
25
|
+
new NodeCache({
|
|
26
|
+
stdTTL: DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
|
|
27
|
+
useClones: false
|
|
28
|
+
});
|
|
33
29
|
if (!config.placeholderResendCache) {
|
|
34
30
|
config.placeholderResendCache = placeholderResendCache;
|
|
35
31
|
}
|
|
@@ -44,14 +40,12 @@ const makeChatsSocket = (config) => {
|
|
|
44
40
|
tag: 'iq',
|
|
45
41
|
attrs: {
|
|
46
42
|
xmlns: 'privacy',
|
|
47
|
-
to:
|
|
43
|
+
to: S_WHATSAPP_NET,
|
|
48
44
|
type: 'get'
|
|
49
45
|
},
|
|
50
|
-
content: [
|
|
51
|
-
{ tag: 'privacy', attrs: {} }
|
|
52
|
-
]
|
|
46
|
+
content: [{ tag: 'privacy', attrs: {} }]
|
|
53
47
|
});
|
|
54
|
-
privacySettings =
|
|
48
|
+
privacySettings = reduceBinaryNodeToDictionary(content?.[0], 'category');
|
|
55
49
|
}
|
|
56
50
|
return privacySettings;
|
|
57
51
|
};
|
|
@@ -61,10 +55,11 @@ const makeChatsSocket = (config) => {
|
|
|
61
55
|
tag: 'iq',
|
|
62
56
|
attrs: {
|
|
63
57
|
xmlns: 'privacy',
|
|
64
|
-
to:
|
|
58
|
+
to: S_WHATSAPP_NET,
|
|
65
59
|
type: 'set'
|
|
66
60
|
},
|
|
67
|
-
content: [
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
68
63
|
tag: 'privacy',
|
|
69
64
|
attrs: {},
|
|
70
65
|
content: [
|
|
@@ -73,7 +68,8 @@ const makeChatsSocket = (config) => {
|
|
|
73
68
|
attrs: { name, value }
|
|
74
69
|
}
|
|
75
70
|
]
|
|
76
|
-
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
77
73
|
});
|
|
78
74
|
};
|
|
79
75
|
const updateMessagesPrivacy = async (value) => {
|
|
@@ -105,15 +101,17 @@ const makeChatsSocket = (config) => {
|
|
|
105
101
|
tag: 'iq',
|
|
106
102
|
attrs: {
|
|
107
103
|
xmlns: 'disappearing_mode',
|
|
108
|
-
to:
|
|
104
|
+
to: S_WHATSAPP_NET,
|
|
109
105
|
type: 'set'
|
|
110
106
|
},
|
|
111
|
-
content: [
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
112
109
|
tag: 'disappearing_mode',
|
|
113
110
|
attrs: {
|
|
114
111
|
duration: duration.toString()
|
|
115
112
|
}
|
|
116
|
-
}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
117
115
|
});
|
|
118
116
|
};
|
|
119
117
|
const getBotListV2 = async () => {
|
|
@@ -121,21 +119,23 @@ const makeChatsSocket = (config) => {
|
|
|
121
119
|
tag: 'iq',
|
|
122
120
|
attrs: {
|
|
123
121
|
xmlns: 'bot',
|
|
124
|
-
to:
|
|
122
|
+
to: S_WHATSAPP_NET,
|
|
125
123
|
type: 'get'
|
|
126
124
|
},
|
|
127
|
-
content: [
|
|
125
|
+
content: [
|
|
126
|
+
{
|
|
128
127
|
tag: 'bot',
|
|
129
128
|
attrs: {
|
|
130
129
|
v: '2'
|
|
131
130
|
}
|
|
132
|
-
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
133
|
});
|
|
134
|
-
const botNode =
|
|
134
|
+
const botNode = getBinaryNodeChild(resp, 'bot');
|
|
135
135
|
const botList = [];
|
|
136
|
-
for (const section of
|
|
136
|
+
for (const section of getBinaryNodeChildren(botNode, 'section')) {
|
|
137
137
|
if (section.attrs.type === 'all') {
|
|
138
|
-
for (const bot of
|
|
138
|
+
for (const bot of getBinaryNodeChildren(section, 'bot')) {
|
|
139
139
|
botList.push({
|
|
140
140
|
jid: bot.attrs.jid,
|
|
141
141
|
personaId: bot.attrs['persona_id']
|
|
@@ -145,24 +145,10 @@ const makeChatsSocket = (config) => {
|
|
|
145
145
|
}
|
|
146
146
|
return botList;
|
|
147
147
|
};
|
|
148
|
-
const onWhatsApp = async (...jids) => {
|
|
149
|
-
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
150
|
-
.withContactProtocol()
|
|
151
|
-
.withLIDProtocol();
|
|
152
|
-
for (const jid of jids) {
|
|
153
|
-
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
|
|
154
|
-
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
|
|
155
|
-
}
|
|
156
|
-
const results = await sock.executeUSyncQuery(usyncQuery);
|
|
157
|
-
if (results) {
|
|
158
|
-
return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
148
|
const fetchStatus = async (...jids) => {
|
|
162
|
-
const usyncQuery = new
|
|
163
|
-
.withStatusProtocol();
|
|
149
|
+
const usyncQuery = new USyncQuery().withStatusProtocol();
|
|
164
150
|
for (const jid of jids) {
|
|
165
|
-
usyncQuery.withUser(new
|
|
151
|
+
usyncQuery.withUser(new USyncUser().withId(jid));
|
|
166
152
|
}
|
|
167
153
|
const result = await sock.executeUSyncQuery(usyncQuery);
|
|
168
154
|
if (result) {
|
|
@@ -170,10 +156,9 @@ const makeChatsSocket = (config) => {
|
|
|
170
156
|
}
|
|
171
157
|
};
|
|
172
158
|
const fetchDisappearingDuration = async (...jids) => {
|
|
173
|
-
const usyncQuery = new
|
|
174
|
-
.withDisappearingModeProtocol();
|
|
159
|
+
const usyncQuery = new USyncQuery().withDisappearingModeProtocol();
|
|
175
160
|
for (const jid of jids) {
|
|
176
|
-
usyncQuery.withUser(new
|
|
161
|
+
usyncQuery.withUser(new USyncUser().withId(jid));
|
|
177
162
|
}
|
|
178
163
|
const result = await sock.executeUSyncQuery(usyncQuery);
|
|
179
164
|
if (result) {
|
|
@@ -181,49 +166,25 @@ const makeChatsSocket = (config) => {
|
|
|
181
166
|
}
|
|
182
167
|
};
|
|
183
168
|
/** update the profile picture for yourself or a group */
|
|
184
|
-
const updateProfilePicture = async (jid, content) => {
|
|
169
|
+
const updateProfilePicture = async (jid, content, dimensions) => {
|
|
185
170
|
let targetJid;
|
|
186
171
|
if (!jid) {
|
|
187
|
-
throw new
|
|
172
|
+
throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
188
173
|
}
|
|
189
|
-
if (
|
|
190
|
-
targetJid =
|
|
174
|
+
if (jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me.id)) {
|
|
175
|
+
targetJid = jidNormalizedUser(jid); // in case it is someone other than us
|
|
191
176
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
tag: 'iq',
|
|
195
|
-
attrs: {
|
|
196
|
-
target: targetJid,
|
|
197
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
198
|
-
type: 'set',
|
|
199
|
-
xmlns: 'w:profile:picture'
|
|
200
|
-
},
|
|
201
|
-
content: [
|
|
202
|
-
{
|
|
203
|
-
tag: 'picture',
|
|
204
|
-
attrs: { type: 'image' },
|
|
205
|
-
content: img
|
|
206
|
-
}
|
|
207
|
-
]
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
/** update the full profile picture for yourself or a group */
|
|
211
|
-
const updateProfilePictureFull = async (jid, content) => {
|
|
212
|
-
let targetJid;
|
|
213
|
-
if (!jid) {
|
|
214
|
-
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');
|
|
215
|
-
}
|
|
216
|
-
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
217
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
177
|
+
else {
|
|
178
|
+
targetJid = undefined;
|
|
218
179
|
}
|
|
219
|
-
const { img } = await (
|
|
180
|
+
const { img } = await generateProfilePicture(content, dimensions);
|
|
220
181
|
await query({
|
|
221
182
|
tag: 'iq',
|
|
222
183
|
attrs: {
|
|
223
|
-
|
|
224
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
184
|
+
to: S_WHATSAPP_NET,
|
|
225
185
|
type: 'set',
|
|
226
|
-
xmlns: 'w:profile:picture'
|
|
186
|
+
xmlns: 'w:profile:picture',
|
|
187
|
+
...(targetJid ? { target: targetJid } : {})
|
|
227
188
|
},
|
|
228
189
|
content: [
|
|
229
190
|
{
|
|
@@ -234,48 +195,25 @@ const makeChatsSocket = (config) => {
|
|
|
234
195
|
]
|
|
235
196
|
});
|
|
236
197
|
};
|
|
237
|
-
const updateProfilePictureFullV2 = async (jid, content) => {
|
|
238
|
-
let targetJid;
|
|
239
|
-
if (!jid) {
|
|
240
|
-
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');
|
|
241
|
-
}
|
|
242
|
-
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
243
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
244
|
-
}
|
|
245
|
-
const { preview } = await (0, WAMedia_1.generatePP)(content);
|
|
246
|
-
await query({
|
|
247
|
-
tag: 'iq',
|
|
248
|
-
attrs: {
|
|
249
|
-
target: targetJid,
|
|
250
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
251
|
-
type: 'set',
|
|
252
|
-
xmlns: 'w:profile:picture'
|
|
253
|
-
},
|
|
254
|
-
content: [
|
|
255
|
-
{
|
|
256
|
-
tag: 'picture',
|
|
257
|
-
attrs: { type: 'image' },
|
|
258
|
-
content: preview
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
});
|
|
262
|
-
};
|
|
263
198
|
/** remove the profile picture for yourself or a group */
|
|
264
199
|
const removeProfilePicture = async (jid) => {
|
|
265
200
|
let targetJid;
|
|
266
201
|
if (!jid) {
|
|
267
|
-
throw new
|
|
202
|
+
throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
268
203
|
}
|
|
269
|
-
if (
|
|
270
|
-
targetJid =
|
|
204
|
+
if (jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me.id)) {
|
|
205
|
+
targetJid = jidNormalizedUser(jid); // in case it is someone other than us
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
targetJid = undefined;
|
|
271
209
|
}
|
|
272
210
|
await query({
|
|
273
211
|
tag: 'iq',
|
|
274
212
|
attrs: {
|
|
275
|
-
|
|
276
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
213
|
+
to: S_WHATSAPP_NET,
|
|
277
214
|
type: 'set',
|
|
278
|
-
xmlns: 'w:profile:picture'
|
|
215
|
+
xmlns: 'w:profile:picture',
|
|
216
|
+
...(targetJid ? { target: targetJid } : {})
|
|
279
217
|
}
|
|
280
218
|
});
|
|
281
219
|
};
|
|
@@ -284,7 +222,7 @@ const makeChatsSocket = (config) => {
|
|
|
284
222
|
await query({
|
|
285
223
|
tag: 'iq',
|
|
286
224
|
attrs: {
|
|
287
|
-
to:
|
|
225
|
+
to: S_WHATSAPP_NET,
|
|
288
226
|
type: 'set',
|
|
289
227
|
xmlns: 'status'
|
|
290
228
|
},
|
|
@@ -305,20 +243,19 @@ const makeChatsSocket = (config) => {
|
|
|
305
243
|
tag: 'iq',
|
|
306
244
|
attrs: {
|
|
307
245
|
xmlns: 'blocklist',
|
|
308
|
-
to:
|
|
246
|
+
to: S_WHATSAPP_NET,
|
|
309
247
|
type: 'get'
|
|
310
248
|
}
|
|
311
249
|
});
|
|
312
|
-
const listNode =
|
|
313
|
-
return
|
|
314
|
-
.map(n => n.attrs.jid);
|
|
250
|
+
const listNode = getBinaryNodeChild(result, 'list');
|
|
251
|
+
return getBinaryNodeChildren(listNode, 'item').map(n => n.attrs.jid);
|
|
315
252
|
};
|
|
316
253
|
const updateBlockStatus = async (jid, action) => {
|
|
317
254
|
await query({
|
|
318
255
|
tag: 'iq',
|
|
319
256
|
attrs: {
|
|
320
257
|
xmlns: 'blocklist',
|
|
321
|
-
to:
|
|
258
|
+
to: S_WHATSAPP_NET,
|
|
322
259
|
type: 'set'
|
|
323
260
|
},
|
|
324
261
|
content: [
|
|
@@ -333,7 +270,6 @@ const makeChatsSocket = (config) => {
|
|
|
333
270
|
});
|
|
334
271
|
};
|
|
335
272
|
const getBusinessProfile = async (jid) => {
|
|
336
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
337
273
|
const results = await query({
|
|
338
274
|
tag: 'iq',
|
|
339
275
|
attrs: {
|
|
@@ -341,38 +277,42 @@ const makeChatsSocket = (config) => {
|
|
|
341
277
|
xmlns: 'w:biz',
|
|
342
278
|
type: 'get'
|
|
343
279
|
},
|
|
344
|
-
content: [
|
|
280
|
+
content: [
|
|
281
|
+
{
|
|
345
282
|
tag: 'business_profile',
|
|
346
283
|
attrs: { v: '244' },
|
|
347
|
-
content: [
|
|
284
|
+
content: [
|
|
285
|
+
{
|
|
348
286
|
tag: 'profile',
|
|
349
287
|
attrs: { jid }
|
|
350
|
-
}
|
|
351
|
-
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
]
|
|
352
292
|
});
|
|
353
|
-
const profileNode =
|
|
354
|
-
const profiles =
|
|
293
|
+
const profileNode = getBinaryNodeChild(results, 'business_profile');
|
|
294
|
+
const profiles = getBinaryNodeChild(profileNode, 'profile');
|
|
355
295
|
if (profiles) {
|
|
356
|
-
const address =
|
|
357
|
-
const description =
|
|
358
|
-
const website =
|
|
359
|
-
const email =
|
|
360
|
-
const category =
|
|
361
|
-
const businessHours =
|
|
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');
|
|
362
302
|
const businessHoursConfig = businessHours
|
|
363
|
-
?
|
|
303
|
+
? getBinaryNodeChildren(businessHours, 'business_hours_config')
|
|
364
304
|
: undefined;
|
|
365
|
-
const websiteStr =
|
|
305
|
+
const websiteStr = website?.content?.toString();
|
|
366
306
|
return {
|
|
367
|
-
wid:
|
|
368
|
-
address:
|
|
369
|
-
description:
|
|
307
|
+
wid: profiles.attrs?.jid,
|
|
308
|
+
address: address?.content?.toString(),
|
|
309
|
+
description: description?.content?.toString() || '',
|
|
370
310
|
website: websiteStr ? [websiteStr] : [],
|
|
371
|
-
email:
|
|
372
|
-
category:
|
|
373
|
-
|
|
374
|
-
timezone:
|
|
375
|
-
|
|
311
|
+
email: email?.content?.toString(),
|
|
312
|
+
category: category?.content?.toString(),
|
|
313
|
+
business_hours: {
|
|
314
|
+
timezone: businessHours?.attrs?.timezone,
|
|
315
|
+
business_config: businessHoursConfig?.map(({ attrs }) => attrs)
|
|
376
316
|
}
|
|
377
317
|
};
|
|
378
318
|
}
|
|
@@ -382,17 +322,17 @@ const makeChatsSocket = (config) => {
|
|
|
382
322
|
await sendNode({
|
|
383
323
|
tag: 'iq',
|
|
384
324
|
attrs: {
|
|
385
|
-
to:
|
|
325
|
+
to: S_WHATSAPP_NET,
|
|
386
326
|
type: 'set',
|
|
387
327
|
xmlns: 'urn:xmpp:whatsapp:dirty',
|
|
388
|
-
id: generateMessageTag()
|
|
328
|
+
id: generateMessageTag()
|
|
389
329
|
},
|
|
390
330
|
content: [
|
|
391
331
|
{
|
|
392
332
|
tag: 'clean',
|
|
393
333
|
attrs: {
|
|
394
334
|
type,
|
|
395
|
-
...(fromTimestamp ? { timestamp: fromTimestamp.toString() } : null)
|
|
335
|
+
...(fromTimestamp ? { timestamp: fromTimestamp.toString() } : null)
|
|
396
336
|
}
|
|
397
337
|
}
|
|
398
338
|
]
|
|
@@ -401,7 +341,7 @@ const makeChatsSocket = (config) => {
|
|
|
401
341
|
const newAppStateChunkHandler = (isInitialSync) => {
|
|
402
342
|
return {
|
|
403
343
|
onMutation(mutation) {
|
|
404
|
-
|
|
344
|
+
processSyncAction(mutation, ev, authState.creds.me, isInitialSync ? { accountSettings: authState.creds.accountSettings } : undefined, logger);
|
|
405
345
|
}
|
|
406
346
|
};
|
|
407
347
|
};
|
|
@@ -411,7 +351,6 @@ const makeChatsSocket = (config) => {
|
|
|
411
351
|
const initialVersionMap = {};
|
|
412
352
|
const globalMutationMap = {};
|
|
413
353
|
await authState.keys.transaction(async () => {
|
|
414
|
-
var _a;
|
|
415
354
|
const collectionsToHandle = new Set(collections);
|
|
416
355
|
// in case something goes wrong -- ensure we don't enter a loop that cannot be exited from
|
|
417
356
|
const attemptsMap = {};
|
|
@@ -430,7 +369,7 @@ const makeChatsSocket = (config) => {
|
|
|
430
369
|
}
|
|
431
370
|
}
|
|
432
371
|
else {
|
|
433
|
-
state =
|
|
372
|
+
state = newLTHashState();
|
|
434
373
|
}
|
|
435
374
|
states[name] = state;
|
|
436
375
|
logger.info(`resyncing ${name} from v${state.version}`);
|
|
@@ -440,14 +379,14 @@ const makeChatsSocket = (config) => {
|
|
|
440
379
|
name,
|
|
441
380
|
version: state.version.toString(),
|
|
442
381
|
// return snapshot if being synced from scratch
|
|
443
|
-
|
|
382
|
+
return_snapshot: (!state.version).toString()
|
|
444
383
|
}
|
|
445
384
|
});
|
|
446
385
|
}
|
|
447
386
|
const result = await query({
|
|
448
387
|
tag: 'iq',
|
|
449
388
|
attrs: {
|
|
450
|
-
to:
|
|
389
|
+
to: S_WHATSAPP_NET,
|
|
451
390
|
xmlns: 'w:sync:app:state',
|
|
452
391
|
type: 'set'
|
|
453
392
|
},
|
|
@@ -460,13 +399,13 @@ const makeChatsSocket = (config) => {
|
|
|
460
399
|
]
|
|
461
400
|
});
|
|
462
401
|
// extract from binary node
|
|
463
|
-
const decoded = await
|
|
402
|
+
const decoded = await extractSyncdPatches(result, config?.options);
|
|
464
403
|
for (const key in decoded) {
|
|
465
404
|
const name = key;
|
|
466
405
|
const { patches, hasMorePatches, snapshot } = decoded[name];
|
|
467
406
|
try {
|
|
468
407
|
if (snapshot) {
|
|
469
|
-
const { state: newState, mutationMap } = await
|
|
408
|
+
const { state: newState, mutationMap } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot);
|
|
470
409
|
states[name] = newState;
|
|
471
410
|
Object.assign(globalMutationMap, mutationMap);
|
|
472
411
|
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
|
|
@@ -474,7 +413,7 @@ const makeChatsSocket = (config) => {
|
|
|
474
413
|
}
|
|
475
414
|
// only process if there are syncd patches
|
|
476
415
|
if (patches.length) {
|
|
477
|
-
const { state: newState, mutationMap } = await
|
|
416
|
+
const { state: newState, mutationMap } = await decodePatches(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
|
|
478
417
|
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
|
|
479
418
|
logger.info(`synced ${name} to v${newState.version}`);
|
|
480
419
|
initialVersionMap[name] = newState.version;
|
|
@@ -483,16 +422,17 @@ const makeChatsSocket = (config) => {
|
|
|
483
422
|
if (hasMorePatches) {
|
|
484
423
|
logger.info(`${name} has more patches...`);
|
|
485
424
|
}
|
|
486
|
-
else {
|
|
425
|
+
else {
|
|
426
|
+
// collection is done with sync
|
|
487
427
|
collectionsToHandle.delete(name);
|
|
488
428
|
}
|
|
489
429
|
}
|
|
490
430
|
catch (error) {
|
|
491
431
|
// if retry attempts overshoot
|
|
492
432
|
// or key not found
|
|
493
|
-
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
|
|
494
|
-
|
|
495
|
-
|
|
433
|
+
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS ||
|
|
434
|
+
error.output?.statusCode === 404 ||
|
|
435
|
+
error.name === 'TypeError';
|
|
496
436
|
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
|
|
497
437
|
await authState.keys.set({ 'app-state-sync-version': { [name]: null } });
|
|
498
438
|
// increment number of retries
|
|
@@ -504,7 +444,7 @@ const makeChatsSocket = (config) => {
|
|
|
504
444
|
}
|
|
505
445
|
}
|
|
506
446
|
}
|
|
507
|
-
});
|
|
447
|
+
}, authState?.creds?.me?.id || 'resync-app-state');
|
|
508
448
|
const { onMutation } = newAppStateChunkHandler(isInitialSync);
|
|
509
449
|
for (const key in globalMutationMap) {
|
|
510
450
|
onMutation(globalMutationMap[key]);
|
|
@@ -516,22 +456,38 @@ const makeChatsSocket = (config) => {
|
|
|
516
456
|
* type = "image for the high res picture"
|
|
517
457
|
*/
|
|
518
458
|
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
|
519
|
-
|
|
520
|
-
jid =
|
|
459
|
+
// TOOD: Add support for tctoken, existingID, and newsletter + group options
|
|
460
|
+
jid = jidNormalizedUser(jid);
|
|
521
461
|
const result = await query({
|
|
522
462
|
tag: 'iq',
|
|
523
463
|
attrs: {
|
|
524
464
|
target: jid,
|
|
525
|
-
to:
|
|
465
|
+
to: S_WHATSAPP_NET,
|
|
526
466
|
type: 'get',
|
|
527
467
|
xmlns: 'w:profile:picture'
|
|
528
468
|
},
|
|
469
|
+
content: [{ tag: 'picture', attrs: { type, query: 'url' } }]
|
|
470
|
+
}, timeoutMs);
|
|
471
|
+
const child = getBinaryNodeChild(result, 'picture');
|
|
472
|
+
return child?.attrs?.url;
|
|
473
|
+
};
|
|
474
|
+
const createCallLink = async (type, event, timeoutMs) => {
|
|
475
|
+
const result = await query({
|
|
476
|
+
tag: 'call',
|
|
477
|
+
attrs: {
|
|
478
|
+
id: generateMessageTag(),
|
|
479
|
+
to: '@call'
|
|
480
|
+
},
|
|
529
481
|
content: [
|
|
530
|
-
{
|
|
482
|
+
{
|
|
483
|
+
tag: 'link_create',
|
|
484
|
+
attrs: { media: type },
|
|
485
|
+
content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
|
|
486
|
+
}
|
|
531
487
|
]
|
|
532
488
|
}, timeoutMs);
|
|
533
|
-
const child =
|
|
534
|
-
return
|
|
489
|
+
const child = getBinaryNodeChild(result, 'link_create');
|
|
490
|
+
return child?.attrs?.token;
|
|
535
491
|
};
|
|
536
492
|
const sendPresenceUpdate = async (type, toJid) => {
|
|
537
493
|
const me = authState.creds.me;
|
|
@@ -550,13 +506,13 @@ const makeChatsSocket = (config) => {
|
|
|
550
506
|
});
|
|
551
507
|
}
|
|
552
508
|
else {
|
|
553
|
-
const { server } =
|
|
509
|
+
const { server } = jidDecode(toJid);
|
|
554
510
|
const isLid = server === 'lid';
|
|
555
511
|
await sendNode({
|
|
556
512
|
tag: 'chatstate',
|
|
557
513
|
attrs: {
|
|
558
514
|
from: isLid ? me.lid : me.id,
|
|
559
|
-
to: toJid
|
|
515
|
+
to: toJid
|
|
560
516
|
},
|
|
561
517
|
content: [
|
|
562
518
|
{
|
|
@@ -571,7 +527,7 @@ const makeChatsSocket = (config) => {
|
|
|
571
527
|
* @param toJid the jid to subscribe to
|
|
572
528
|
* @param tcToken token for subscription, use if present
|
|
573
529
|
*/
|
|
574
|
-
const presenceSubscribe = (toJid, tcToken) =>
|
|
530
|
+
const presenceSubscribe = (toJid, tcToken) => sendNode({
|
|
575
531
|
tag: 'presence',
|
|
576
532
|
attrs: {
|
|
577
533
|
to: toJid,
|
|
@@ -587,13 +543,12 @@ const makeChatsSocket = (config) => {
|
|
|
587
543
|
}
|
|
588
544
|
]
|
|
589
545
|
: undefined
|
|
590
|
-
})
|
|
546
|
+
});
|
|
591
547
|
const handlePresenceUpdate = ({ tag, attrs, content }) => {
|
|
592
|
-
var _a;
|
|
593
548
|
let presence;
|
|
594
549
|
const jid = attrs.from;
|
|
595
550
|
const participant = attrs.participant || attrs.from;
|
|
596
|
-
if (shouldIgnoreJid(jid) && jid
|
|
551
|
+
if (shouldIgnoreJid(jid) && jid !== S_WHATSAPP_NET) {
|
|
597
552
|
return;
|
|
598
553
|
}
|
|
599
554
|
if (tag === 'presence') {
|
|
@@ -608,7 +563,7 @@ const makeChatsSocket = (config) => {
|
|
|
608
563
|
if (type === 'paused') {
|
|
609
564
|
type = 'available';
|
|
610
565
|
}
|
|
611
|
-
if (
|
|
566
|
+
if (firstChild.attrs?.media === 'audio') {
|
|
612
567
|
type = 'recording';
|
|
613
568
|
}
|
|
614
569
|
presence = { lastKnownPresence: type };
|
|
@@ -624,7 +579,7 @@ const makeChatsSocket = (config) => {
|
|
|
624
579
|
const name = patchCreate.type;
|
|
625
580
|
const myAppStateKeyId = authState.creds.myAppStateKeyId;
|
|
626
581
|
if (!myAppStateKeyId) {
|
|
627
|
-
throw new
|
|
582
|
+
throw new Boom('App state key not present!', { statusCode: 400 });
|
|
628
583
|
}
|
|
629
584
|
let initial;
|
|
630
585
|
let encodeResult;
|
|
@@ -633,13 +588,13 @@ const makeChatsSocket = (config) => {
|
|
|
633
588
|
logger.debug({ patch: patchCreate }, 'applying app patch');
|
|
634
589
|
await resyncAppState([name], false);
|
|
635
590
|
const { [name]: currentSyncVersion } = await authState.keys.get('app-state-sync-version', [name]);
|
|
636
|
-
initial = currentSyncVersion ||
|
|
637
|
-
encodeResult = await
|
|
591
|
+
initial = currentSyncVersion || newLTHashState();
|
|
592
|
+
encodeResult = await encodeSyncdPatch(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey);
|
|
638
593
|
const { patch, state } = encodeResult;
|
|
639
594
|
const node = {
|
|
640
595
|
tag: 'iq',
|
|
641
596
|
attrs: {
|
|
642
|
-
to:
|
|
597
|
+
to: S_WHATSAPP_NET,
|
|
643
598
|
type: 'set',
|
|
644
599
|
xmlns: 'w:sync:app:state'
|
|
645
600
|
},
|
|
@@ -653,13 +608,13 @@ const makeChatsSocket = (config) => {
|
|
|
653
608
|
attrs: {
|
|
654
609
|
name,
|
|
655
610
|
version: (state.version - 1).toString(),
|
|
656
|
-
|
|
611
|
+
return_snapshot: 'false'
|
|
657
612
|
},
|
|
658
613
|
content: [
|
|
659
614
|
{
|
|
660
615
|
tag: 'patch',
|
|
661
616
|
attrs: {},
|
|
662
|
-
content:
|
|
617
|
+
content: proto.SyncdPatch.encode(patch).finish()
|
|
663
618
|
}
|
|
664
619
|
]
|
|
665
620
|
}
|
|
@@ -669,11 +624,11 @@ const makeChatsSocket = (config) => {
|
|
|
669
624
|
};
|
|
670
625
|
await query(node);
|
|
671
626
|
await authState.keys.set({ 'app-state-sync-version': { [name]: state } });
|
|
672
|
-
});
|
|
627
|
+
}, authState?.creds?.me?.id || 'app-patch');
|
|
673
628
|
});
|
|
674
629
|
if (config.emitOwnEvents) {
|
|
675
630
|
const { onMutation } = newAppStateChunkHandler(false);
|
|
676
|
-
const { mutationMap } = await
|
|
631
|
+
const { mutationMap } = await decodePatches(name, [{ ...encodeResult.patch, version: { version: encodeResult.state.version } }], initial, getAppStateSyncKey, config.options, undefined, logger);
|
|
677
632
|
for (const key in mutationMap) {
|
|
678
633
|
onMutation(mutationMap[key]);
|
|
679
634
|
}
|
|
@@ -681,29 +636,33 @@ const makeChatsSocket = (config) => {
|
|
|
681
636
|
};
|
|
682
637
|
/** sending non-abt props may fix QR scan fail if server expects */
|
|
683
638
|
const fetchProps = async () => {
|
|
684
|
-
|
|
639
|
+
//TODO: implement both protocol 1 and protocol 2 prop fetching, specially for abKey for WM
|
|
685
640
|
const resultNode = await query({
|
|
686
641
|
tag: 'iq',
|
|
687
642
|
attrs: {
|
|
688
|
-
to:
|
|
643
|
+
to: S_WHATSAPP_NET,
|
|
689
644
|
xmlns: 'w',
|
|
690
|
-
type: 'get'
|
|
645
|
+
type: 'get'
|
|
691
646
|
},
|
|
692
647
|
content: [
|
|
693
|
-
{
|
|
648
|
+
{
|
|
649
|
+
tag: 'props',
|
|
650
|
+
attrs: {
|
|
694
651
|
protocol: '2',
|
|
695
|
-
hash:
|
|
696
|
-
}
|
|
652
|
+
hash: authState?.creds?.lastPropHash || ''
|
|
653
|
+
}
|
|
654
|
+
}
|
|
697
655
|
]
|
|
698
656
|
});
|
|
699
|
-
const propsNode =
|
|
657
|
+
const propsNode = getBinaryNodeChild(resultNode, 'props');
|
|
700
658
|
let props = {};
|
|
701
659
|
if (propsNode) {
|
|
702
|
-
if (
|
|
703
|
-
|
|
660
|
+
if (propsNode.attrs?.hash) {
|
|
661
|
+
// on some clients, the hash is returning as undefined
|
|
662
|
+
authState.creds.lastPropHash = propsNode?.attrs?.hash;
|
|
704
663
|
ev.emit('creds.update', authState.creds);
|
|
705
664
|
}
|
|
706
|
-
props =
|
|
665
|
+
props = reduceBinaryNodeToDictionary(propsNode, 'prop');
|
|
707
666
|
}
|
|
708
667
|
logger.debug('fetched props');
|
|
709
668
|
return props;
|
|
@@ -712,9 +671,9 @@ const makeChatsSocket = (config) => {
|
|
|
712
671
|
* modify a chat -- mark unread, read etc.
|
|
713
672
|
* lastMessages must be sorted in reverse chronologically
|
|
714
673
|
* requires the last messages till the last message received; required for archive & unread
|
|
715
|
-
|
|
674
|
+
*/
|
|
716
675
|
const chatModify = (mod, jid) => {
|
|
717
|
-
const patch =
|
|
676
|
+
const patch = chatModificationToAppPatch(mod, jid);
|
|
718
677
|
return appPatch(patch);
|
|
719
678
|
};
|
|
720
679
|
/**
|
|
@@ -752,6 +711,16 @@ const makeChatsSocket = (config) => {
|
|
|
752
711
|
contact: null
|
|
753
712
|
}, jid);
|
|
754
713
|
};
|
|
714
|
+
/**
|
|
715
|
+
* Adds label
|
|
716
|
+
*/
|
|
717
|
+
const addLabel = (jid, labels) => {
|
|
718
|
+
return chatModify({
|
|
719
|
+
addLabel: {
|
|
720
|
+
...labels
|
|
721
|
+
}
|
|
722
|
+
}, jid);
|
|
723
|
+
};
|
|
755
724
|
/**
|
|
756
725
|
* Adds label for the chats
|
|
757
726
|
*/
|
|
@@ -794,81 +763,102 @@ const makeChatsSocket = (config) => {
|
|
|
794
763
|
}
|
|
795
764
|
}, jid);
|
|
796
765
|
};
|
|
766
|
+
/**
|
|
767
|
+
* Add or Edit Quick Reply
|
|
768
|
+
*/
|
|
769
|
+
const addOrEditQuickReply = (quickReply) => {
|
|
770
|
+
return chatModify({
|
|
771
|
+
quickReply
|
|
772
|
+
}, '');
|
|
773
|
+
};
|
|
774
|
+
/**
|
|
775
|
+
* Remove Quick Reply
|
|
776
|
+
*/
|
|
777
|
+
const removeQuickReply = (timestamp) => {
|
|
778
|
+
return chatModify({
|
|
779
|
+
quickReply: { timestamp, deleted: true }
|
|
780
|
+
}, '');
|
|
781
|
+
};
|
|
797
782
|
/**
|
|
798
783
|
* queries need to be fired on connection open
|
|
799
784
|
* help ensure parity with WA Web
|
|
800
785
|
* */
|
|
801
786
|
const executeInitQueries = async () => {
|
|
802
|
-
await Promise.all([
|
|
803
|
-
fetchProps(),
|
|
804
|
-
fetchBlocklist(),
|
|
805
|
-
fetchPrivacySettings(),
|
|
806
|
-
]);
|
|
787
|
+
await Promise.all([fetchProps(), fetchBlocklist(), fetchPrivacySettings()]);
|
|
807
788
|
};
|
|
808
789
|
const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
|
|
809
|
-
var _a, _b, _c;
|
|
810
790
|
ev.emit('messages.upsert', { messages: [msg], type });
|
|
811
791
|
if (!!msg.pushName) {
|
|
812
|
-
let jid = msg.key.fromMe ? authState.creds.me.id :
|
|
813
|
-
jid =
|
|
792
|
+
let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid;
|
|
793
|
+
jid = jidNormalizedUser(jid);
|
|
814
794
|
if (!msg.key.fromMe) {
|
|
815
795
|
ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }]);
|
|
816
796
|
}
|
|
817
797
|
// update our pushname too
|
|
818
|
-
if (msg.key.fromMe && msg.pushName &&
|
|
798
|
+
if (msg.key.fromMe && msg.pushName && authState.creds.me?.name !== msg.pushName) {
|
|
819
799
|
ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
|
|
820
800
|
}
|
|
821
801
|
}
|
|
822
|
-
const historyMsg =
|
|
802
|
+
const historyMsg = getHistoryMsg(msg.message);
|
|
823
803
|
const shouldProcessHistoryMsg = historyMsg
|
|
824
|
-
?
|
|
825
|
-
&& Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
|
|
804
|
+
? shouldSyncHistoryMessage(historyMsg) && PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType)
|
|
826
805
|
: false;
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
806
|
+
// State machine: decide on sync and flush
|
|
807
|
+
if (historyMsg && syncState === SyncState.AwaitingInitialSync) {
|
|
808
|
+
if (awaitingSyncTimeout) {
|
|
809
|
+
clearTimeout(awaitingSyncTimeout);
|
|
810
|
+
awaitingSyncTimeout = undefined;
|
|
811
|
+
}
|
|
812
|
+
if (shouldProcessHistoryMsg) {
|
|
813
|
+
syncState = SyncState.Syncing;
|
|
814
|
+
logger.info('Transitioned to Syncing state');
|
|
815
|
+
// Let doAppStateSync handle the final flush after it's done
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
syncState = SyncState.Online;
|
|
819
|
+
logger.info('History sync skipped, transitioning to Online state and flushing buffer');
|
|
820
|
+
ev.flush();
|
|
821
|
+
}
|
|
830
822
|
}
|
|
823
|
+
const doAppStateSync = async () => {
|
|
824
|
+
if (syncState === SyncState.Syncing) {
|
|
825
|
+
logger.info('Doing app state sync');
|
|
826
|
+
await resyncAppState(ALL_WA_PATCH_NAMES, true);
|
|
827
|
+
// Sync is complete, go online and flush everything
|
|
828
|
+
syncState = SyncState.Online;
|
|
829
|
+
logger.info('App state sync complete, transitioning to Online state and flushing buffer');
|
|
830
|
+
ev.flush();
|
|
831
|
+
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
|
|
832
|
+
ev.emit('creds.update', { accountSyncCounter });
|
|
833
|
+
}
|
|
834
|
+
};
|
|
831
835
|
await Promise.all([
|
|
832
836
|
(async () => {
|
|
833
|
-
if (
|
|
834
|
-
&& authState.creds.myAppStateKeyId) {
|
|
835
|
-
pendingAppStateSync = false;
|
|
837
|
+
if (shouldProcessHistoryMsg) {
|
|
836
838
|
await doAppStateSync();
|
|
837
839
|
}
|
|
838
840
|
})(),
|
|
839
|
-
(
|
|
841
|
+
processMessage(msg, {
|
|
842
|
+
signalRepository,
|
|
840
843
|
shouldProcessHistoryMsg,
|
|
841
844
|
placeholderResendCache,
|
|
842
845
|
ev,
|
|
843
846
|
creds: authState.creds,
|
|
844
847
|
keyStore: authState.keys,
|
|
845
848
|
logger,
|
|
846
|
-
options: config.options
|
|
847
|
-
getMessage: config.getMessage,
|
|
849
|
+
options: config.options
|
|
848
850
|
})
|
|
849
851
|
]);
|
|
850
|
-
|
|
851
|
-
|
|
852
|
+
// If the app state key arrives and we are waiting to sync, trigger the sync now.
|
|
853
|
+
if (msg.message?.protocolMessage?.appStateSyncKeyShare && syncState === SyncState.Syncing) {
|
|
854
|
+
logger.info('App state sync key arrived, triggering app state sync');
|
|
852
855
|
await doAppStateSync();
|
|
853
|
-
pendingAppStateSync = false;
|
|
854
|
-
}
|
|
855
|
-
async function doAppStateSync() {
|
|
856
|
-
if (!authState.creds.accountSyncCounter) {
|
|
857
|
-
logger.info('doing initial app state sync');
|
|
858
|
-
await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
|
|
859
|
-
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
|
|
860
|
-
ev.emit('creds.update', { accountSyncCounter });
|
|
861
|
-
if (needToFlushWithAppStateSync) {
|
|
862
|
-
logger.debug('flushing with app state sync');
|
|
863
|
-
ev.flush();
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
856
|
}
|
|
867
857
|
});
|
|
868
858
|
ws.on('CB:presence', handlePresenceUpdate);
|
|
869
859
|
ws.on('CB:chatstate', handlePresenceUpdate);
|
|
870
860
|
ws.on('CB:ib,,dirty', async (node) => {
|
|
871
|
-
const { attrs } =
|
|
861
|
+
const { attrs } = getBinaryNodeChild(node, 'dirty');
|
|
872
862
|
const type = attrs.type;
|
|
873
863
|
switch (type) {
|
|
874
864
|
case 'account_sync':
|
|
@@ -890,25 +880,43 @@ const makeChatsSocket = (config) => {
|
|
|
890
880
|
}
|
|
891
881
|
});
|
|
892
882
|
ev.on('connection.update', ({ connection, receivedPendingNotifications }) => {
|
|
893
|
-
var _a;
|
|
894
883
|
if (connection === 'open') {
|
|
895
884
|
if (fireInitQueries) {
|
|
896
|
-
executeInitQueries()
|
|
897
|
-
.catch(error => onUnexpectedError(error, 'init queries'));
|
|
885
|
+
executeInitQueries().catch(error => onUnexpectedError(error, 'init queries'));
|
|
898
886
|
}
|
|
899
|
-
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
900
|
-
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
887
|
+
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable').catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
901
888
|
}
|
|
902
|
-
if (receivedPendingNotifications
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
889
|
+
if (!receivedPendingNotifications || syncState !== SyncState.Connecting) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
syncState = SyncState.AwaitingInitialSync;
|
|
893
|
+
logger.info('Connection is now AwaitingInitialSync, buffering events');
|
|
894
|
+
ev.buffer();
|
|
895
|
+
const willSyncHistory = shouldSyncHistoryMessage(proto.Message.HistorySyncNotification.create({
|
|
896
|
+
syncType: proto.HistorySync.HistorySyncType.RECENT
|
|
897
|
+
}));
|
|
898
|
+
if (!willSyncHistory) {
|
|
899
|
+
logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.');
|
|
900
|
+
syncState = SyncState.Online;
|
|
901
|
+
setTimeout(() => ev.flush(), 0);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
logger.info('History sync is enabled, awaiting notification with a 20s timeout.');
|
|
905
|
+
if (awaitingSyncTimeout) {
|
|
906
|
+
clearTimeout(awaitingSyncTimeout);
|
|
908
907
|
}
|
|
908
|
+
awaitingSyncTimeout = setTimeout(() => {
|
|
909
|
+
if (syncState === SyncState.AwaitingInitialSync) {
|
|
910
|
+
// TODO: investigate
|
|
911
|
+
logger.warn('Timeout in AwaitingInitialSync, forcing state to Online and flushing buffer');
|
|
912
|
+
syncState = SyncState.Online;
|
|
913
|
+
ev.flush();
|
|
914
|
+
}
|
|
915
|
+
}, 20000);
|
|
909
916
|
});
|
|
910
917
|
return {
|
|
911
918
|
...sock,
|
|
919
|
+
createCallLink,
|
|
912
920
|
getBotListV2,
|
|
913
921
|
processingMutex,
|
|
914
922
|
fetchPrivacySettings,
|
|
@@ -917,10 +925,9 @@ const makeChatsSocket = (config) => {
|
|
|
917
925
|
sendPresenceUpdate,
|
|
918
926
|
presenceSubscribe,
|
|
919
927
|
profilePictureUrl,
|
|
920
|
-
onWhatsApp,
|
|
921
928
|
fetchBlocklist,
|
|
922
|
-
fetchDisappearingDuration,
|
|
923
929
|
fetchStatus,
|
|
930
|
+
fetchDisappearingDuration,
|
|
924
931
|
updateProfilePicture,
|
|
925
932
|
removeProfilePicture,
|
|
926
933
|
updateProfileStatus,
|
|
@@ -942,11 +949,14 @@ const makeChatsSocket = (config) => {
|
|
|
942
949
|
cleanDirtyBits,
|
|
943
950
|
addOrEditContact,
|
|
944
951
|
removeContact,
|
|
952
|
+
addLabel,
|
|
945
953
|
addChatLabel,
|
|
946
954
|
removeChatLabel,
|
|
947
955
|
addMessageLabel,
|
|
948
956
|
removeMessageLabel,
|
|
949
|
-
star
|
|
957
|
+
star,
|
|
958
|
+
addOrEditQuickReply,
|
|
959
|
+
removeQuickReply
|
|
950
960
|
};
|
|
951
961
|
};
|
|
952
|
-
|
|
962
|
+
//# sourceMappingURL=chats.js.map
|