@neelegirl/baileys 1.5.2 → 1.5.4
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 +26 -18
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +291 -665
- package/WAProto/fix-imports.js +29 -0
- package/WAProto/index.d.ts +2297 -48040
- package/WAProto/index.js +45500 -140101
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.d.ts +58 -64
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +74 -96
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +82 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/{WASignalGroup/sender_message_key.js → Group/sender-message-key.js} +3 -16
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -4
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +292 -112
- 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 -22
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +8 -15
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +24 -36
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +178 -177
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +179 -71
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +93 -93
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +474 -625
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +83 -62
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +412 -414
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts +118 -112
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +146 -171
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +222 -182
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +12 -17
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +165 -169
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +1185 -1721
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +161 -159
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +650 -991
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +4 -9
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +139 -139
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +153 -258
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +42 -36
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +623 -507
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +87 -96
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -3
- 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 +13 -13
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -3
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +79 -94
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -9
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +13 -9
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -3
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +152 -179
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -3
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +49 -48
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -3
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +13 -14
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +24 -30
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +15 -20
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +6 -12
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +234 -404
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -13
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +130 -104
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +31 -40
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +58 -71
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -3
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +63 -55
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -3
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +78 -65
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +17 -19
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +13 -14
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -3
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +47 -61
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +26 -48
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/auth-utils.d.ts +8 -10
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +206 -154
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/baileys-event-stream.d.ts +6 -7
- package/lib/Utils/baileys-event-stream.d.ts.map +1 -0
- package/lib/Utils/baileys-event-stream.js +29 -43
- 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 +14 -20
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +110 -134
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +57 -69
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +362 -380
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +30 -45
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +141 -178
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +42 -35
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +176 -150
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +12 -17
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +269 -286
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +60 -99
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +244 -487
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +18 -22
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +54 -80
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/index.d.ts +20 -19
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +19 -39
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +12 -14
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +40 -75
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +10 -11
- 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 +12 -13
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +27 -37
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +6 -7
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +20 -29
- 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 +87 -102
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +427 -570
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +37 -64
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +511 -1270
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +18 -18
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +101 -109
- 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 +25 -32
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +266 -281
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/signal.d.ts +24 -32
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +98 -105
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +5 -10
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +69 -186
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +11 -13
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +124 -116
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +25 -27
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1277 -1292
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -9
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +139 -189
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +105 -154
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +14 -27
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +62 -102
- 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 -25
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +41 -46
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +84 -80
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +10 -13
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -3
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -15
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +7 -14
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +30 -37
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +19193 -11711
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +95 -110
- 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 -23
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +12 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +19 -22
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +18 -26
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +11 -12
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -20
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +11 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +16 -24
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -6
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +5 -26
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -28
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +64 -62
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +11 -10
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +12 -19
- 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 -23
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +10 -11
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -33
- package/lib/index.js.map +1 -0
- package/package.json +48 -43
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/WASignalGroup/GroupProtocol.js +0 -1909
- package/lib/Signal/WASignalGroup/ciphertext_message.js +0 -16
- package/lib/Signal/WASignalGroup/generate-proto.sh +0 -1
- package/lib/Signal/WASignalGroup/group.proto +0 -42
- package/lib/Signal/WASignalGroup/group_cipher.js +0 -120
- package/lib/Signal/WASignalGroup/group_session_builder.js +0 -46
- package/lib/Signal/WASignalGroup/index.js +0 -6
- package/lib/Signal/WASignalGroup/keyhelper.js +0 -21
- package/lib/Signal/WASignalGroup/protobufs.js +0 -3
- package/lib/Signal/WASignalGroup/queue_job.js +0 -69
- package/lib/Signal/WASignalGroup/readme.md +0 -6
- package/lib/Signal/WASignalGroup/sender_chain_key.js +0 -50
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/lib/Signal/WASignalGroup/sender_key_message.js +0 -92
- package/lib/Signal/WASignalGroup/sender_key_name.js +0 -70
- package/lib/Signal/WASignalGroup/sender_key_record.js +0 -56
- package/lib/Signal/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -266
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -83
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/index.js +0 -24
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -90
- package/lib/Store/make-in-memory-store.d.ts +0 -123
- package/lib/Store/make-in-memory-store.js +0 -429
- package/lib/Store/make-ordered-dictionary.d.ts +0 -12
- package/lib/Store/make-ordered-dictionary.js +0 -86
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Store/object-repository.js +0 -31
- package/lib/Types/MexUpdates.d.ts +0 -9
- package/lib/Types/MexUpdates.js +0 -18
- package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-mongo-file-auth-state.js +0 -84
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.js +0 -80
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -69
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -30
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
8
|
-
|
|
9
|
-
const async_mutex_1 = __importDefault(require("async-mutex"))
|
|
10
|
-
const promises_1 = require("fs/promises")
|
|
11
|
-
const path_1 = require("path")
|
|
12
|
-
const WAProto_1 = require("../../WAProto")
|
|
13
|
-
const auth_utils_1 = require("./auth-utils")
|
|
14
|
-
const generics_1 = require("./generics")
|
|
1
|
+
import { Mutex } from 'async-mutex';
|
|
2
|
+
import { mkdir, readFile, stat, unlink, writeFile } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { proto } from '../../WAProto/index.js';
|
|
5
|
+
import { initAuthCreds } from './auth-utils.js';
|
|
6
|
+
import { BufferJSON } from './generics.js';
|
|
15
7
|
// We need to lock files due to the fact that we are using async functions to read and write files
|
|
16
8
|
// https://github.com/WhiskeySockets/Baileys/issues/794
|
|
17
9
|
// https://github.com/nodejs/node/issues/26338
|
|
18
10
|
// Use a Map to store mutexes for each file path
|
|
19
|
-
const fileLocks = new Map()
|
|
20
|
-
|
|
11
|
+
const fileLocks = new Map();
|
|
21
12
|
// Get or create a mutex for a specific file path
|
|
22
13
|
const getFileLock = (path) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
14
|
+
let mutex = fileLocks.get(path);
|
|
15
|
+
if (!mutex) {
|
|
16
|
+
mutex = new Mutex();
|
|
17
|
+
fileLocks.set(path, mutex);
|
|
18
|
+
}
|
|
19
|
+
return mutex;
|
|
20
|
+
};
|
|
32
21
|
/**
|
|
33
22
|
* stores the full authentication state in a single folder.
|
|
34
23
|
* Far more efficient than singlefileauthstate
|
|
@@ -36,203 +25,97 @@ const getFileLock = (path) => {
|
|
|
36
25
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
37
26
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
38
27
|
* */
|
|
39
|
-
const useMultiFileAuthState = async (folder) => {
|
|
28
|
+
export const useMultiFileAuthState = async (folder) => {
|
|
40
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
30
|
const writeData = async (data, file) => {
|
|
42
|
-
const filePath =
|
|
43
|
-
const mutex = getFileLock(filePath)
|
|
31
|
+
const filePath = join(folder, fixFileName(file));
|
|
32
|
+
const mutex = getFileLock(filePath);
|
|
44
33
|
return mutex.acquire().then(async (release) => {
|
|
45
34
|
try {
|
|
46
|
-
|
|
47
|
-
} finally {
|
|
48
|
-
release()
|
|
35
|
+
await writeFile(filePath, JSON.stringify(data, BufferJSON.replacer));
|
|
49
36
|
}
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
finally {
|
|
38
|
+
release();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
52
42
|
const readData = async (file) => {
|
|
53
43
|
try {
|
|
54
|
-
const filePath =
|
|
55
|
-
const mutex = getFileLock(filePath)
|
|
56
|
-
|
|
44
|
+
const filePath = join(folder, fixFileName(file));
|
|
45
|
+
const mutex = getFileLock(filePath);
|
|
46
|
+
return await mutex.acquire().then(async (release) => {
|
|
57
47
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
release()
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
return JSON.parse(data, generics_1.BufferJSON.reviver)
|
|
65
|
-
} catch (error) {
|
|
66
|
-
return null
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const removeData = async (file) => {
|
|
70
|
-
try {
|
|
71
|
-
const filePath = path_1.join(folder, fixFileName(file))
|
|
72
|
-
const mutex = getFileLock(filePath)
|
|
73
|
-
await mutex.acquire().then(async (release) => {
|
|
74
|
-
try {
|
|
75
|
-
await promises_1.unlink(filePath)
|
|
76
|
-
} finally {
|
|
77
|
-
release()
|
|
48
|
+
const data = await readFile(filePath, { encoding: 'utf-8' });
|
|
49
|
+
return JSON.parse(data, BufferJSON.reviver);
|
|
78
50
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
const folderInfo = await promises_1.stat(folder).catch(() => { })
|
|
83
|
-
if (folderInfo) {
|
|
84
|
-
if (!folderInfo.isDirectory()) {
|
|
85
|
-
throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
await promises_1.mkdir(folder, { recursive: true })
|
|
90
|
-
}
|
|
91
|
-
const fixFileName = (file) => {
|
|
92
|
-
return file?.replace(/\//g, '__')?.replace(/:/g, '-')
|
|
93
|
-
}
|
|
94
|
-
const creds = await readData('creds.json') || auth_utils_1.initAuthCreds()
|
|
95
|
-
return {
|
|
96
|
-
state: {
|
|
97
|
-
creds,
|
|
98
|
-
keys: {
|
|
99
|
-
get: async (type, ids) => {
|
|
100
|
-
const data = {}
|
|
101
|
-
await Promise.all(ids.map(async (id) => {
|
|
102
|
-
let value = await readData(`${type}-${id}.json`)
|
|
103
|
-
if (type === 'app-state-sync-key' && value) {
|
|
104
|
-
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value)
|
|
105
|
-
}
|
|
106
|
-
data[id] = value
|
|
107
|
-
}))
|
|
108
|
-
return data
|
|
109
|
-
},
|
|
110
|
-
set: async (data) => {
|
|
111
|
-
const tasks = []
|
|
112
|
-
for (const category in data) {
|
|
113
|
-
for (const id in data[category]) {
|
|
114
|
-
const value = data[category][id]
|
|
115
|
-
const file = `${category}-${id}.json`
|
|
116
|
-
tasks.push(value ? writeData(value, file) : removeData(file))
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
await Promise.all(tasks)
|
|
51
|
+
finally {
|
|
52
|
+
release();
|
|
120
53
|
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
saveCreds: async () => {
|
|
124
|
-
return writeData(creds, 'creds.json')
|
|
54
|
+
});
|
|
125
55
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* stores the full authentication state in a single folder.
|
|
131
|
-
* Far more efficient than singlefileauthstate
|
|
132
|
-
*
|
|
133
|
-
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
134
|
-
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
135
|
-
* */
|
|
136
|
-
const useMultiFileAuthStateV2 = async (folder) => {
|
|
137
|
-
const fixFileName = (file) => {
|
|
138
|
-
return file?.replace(/\//g, '__')?.replace(/:/g, '-')
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
const writeData = async (data, file) => {
|
|
143
|
-
const filePath = path_1.join(folder, fixFileName(file))
|
|
144
|
-
const mutex = getFileLock(filePath)
|
|
145
|
-
return mutex.acquire().then(async (release) => {
|
|
146
|
-
try {
|
|
147
|
-
await promises_1.writeFile(
|
|
148
|
-
filePath,
|
|
149
|
-
JSON.stringify(data, generics_1.BufferJSON.replacer, 2) // <-- lesbar formatiert
|
|
150
|
-
)
|
|
151
|
-
} finally {
|
|
152
|
-
release()
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const readData = async (file) => {
|
|
158
|
-
try {
|
|
159
|
-
const filePath = path_1.join(folder, fixFileName(file))
|
|
160
|
-
const mutex = getFileLock(filePath)
|
|
161
|
-
const data = await mutex.acquire().then(async (release) => {
|
|
162
|
-
try {
|
|
163
|
-
return await promises_1.readFile(filePath, { encoding: 'utf-8' })
|
|
164
|
-
} finally {
|
|
165
|
-
release()
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
return JSON.parse(data, generics_1.BufferJSON.reviver)
|
|
170
|
-
} catch (error) {
|
|
171
|
-
return null
|
|
56
|
+
catch (error) {
|
|
57
|
+
return null;
|
|
172
58
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
59
|
+
};
|
|
175
60
|
const removeData = async (file) => {
|
|
176
61
|
try {
|
|
177
|
-
const filePath =
|
|
178
|
-
const mutex = getFileLock(filePath)
|
|
179
|
-
|
|
62
|
+
const filePath = join(folder, fixFileName(file));
|
|
63
|
+
const mutex = getFileLock(filePath);
|
|
64
|
+
return mutex.acquire().then(async (release) => {
|
|
180
65
|
try {
|
|
181
|
-
await
|
|
182
|
-
} finally {
|
|
183
|
-
release()
|
|
66
|
+
await unlink(filePath);
|
|
184
67
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
68
|
+
catch {
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
release();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch { }
|
|
76
|
+
};
|
|
77
|
+
const folderInfo = await stat(folder).catch(() => { });
|
|
190
78
|
if (folderInfo) {
|
|
191
79
|
if (!folderInfo.isDirectory()) {
|
|
192
|
-
throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`)
|
|
80
|
+
throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
|
|
193
81
|
}
|
|
194
|
-
} else {
|
|
195
|
-
await promises_1.mkdir(folder, { recursive: true })
|
|
196
82
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
83
|
+
else {
|
|
84
|
+
await mkdir(folder, { recursive: true });
|
|
85
|
+
}
|
|
86
|
+
const fixFileName = (file) => file?.replace(/\//g, '__')?.replace(/:/g, '-');
|
|
87
|
+
const creds = (await readData('creds.json')) || initAuthCreds();
|
|
200
88
|
return {
|
|
201
89
|
state: {
|
|
202
90
|
creds,
|
|
203
91
|
keys: {
|
|
204
92
|
get: async (type, ids) => {
|
|
205
|
-
const data = {}
|
|
93
|
+
const data = {};
|
|
206
94
|
await Promise.all(ids.map(async (id) => {
|
|
207
|
-
let value = await readData(`${type}-${id}.json`)
|
|
95
|
+
let value = await readData(`${type}-${id}.json`);
|
|
208
96
|
if (type === 'app-state-sync-key' && value) {
|
|
209
|
-
value =
|
|
97
|
+
value = proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
210
98
|
}
|
|
211
|
-
data[id] = value
|
|
212
|
-
}))
|
|
213
|
-
return data
|
|
99
|
+
data[id] = value;
|
|
100
|
+
}));
|
|
101
|
+
return data;
|
|
214
102
|
},
|
|
215
103
|
set: async (data) => {
|
|
216
|
-
const tasks = []
|
|
104
|
+
const tasks = [];
|
|
217
105
|
for (const category in data) {
|
|
218
106
|
for (const id in data[category]) {
|
|
219
|
-
const value = data[category][id]
|
|
220
|
-
const file = `${category}-${id}.json
|
|
221
|
-
tasks.push(value ? writeData(value, file) : removeData(file))
|
|
107
|
+
const value = data[category][id];
|
|
108
|
+
const file = `${category}-${id}.json`;
|
|
109
|
+
tasks.push(value ? writeData(value, file) : removeData(file));
|
|
222
110
|
}
|
|
223
111
|
}
|
|
224
|
-
await Promise.all(tasks)
|
|
112
|
+
await Promise.all(tasks);
|
|
225
113
|
}
|
|
226
114
|
}
|
|
227
115
|
},
|
|
228
116
|
saveCreds: async () => {
|
|
229
|
-
return writeData(creds, 'creds.json')
|
|
117
|
+
return writeData(creds, 'creds.json');
|
|
230
118
|
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
module.exports = {
|
|
236
|
-
useMultiFileAuthState,
|
|
237
|
-
useMultiFileAuthStateV2
|
|
238
|
-
}
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=use-multi-file-auth-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-multi-file-auth-state.js","sourceRoot":"","sources":["../../src/Utils/use-multi-file-auth-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,kGAAkG;AAClG,uD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4BAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,QAAmC,CAAE,CAAC,EAAE,CAAC,CAAA;4BAC5D,MAAM,IAAI,GAAG,GAAG,QAAQ,IAAI,EAAE,OAAO,CAAA;4BACrC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;wBAC9D,CAAC;oBACF,CAAC;oBAED,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBACzB,CAAC;aACD;SACD;QACD,SAAS,EAAE,KAAK,IAAI,EAAE;YACrB,OAAO,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;QACtC,CAAC;KACD,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { proto } from '../../WAProto'
|
|
2
|
-
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types'
|
|
3
|
-
import { BinaryNode } from '../WABinary'
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types/index.js';
|
|
3
|
+
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
|
+
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
|
5
|
+
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
|
6
|
+
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, "advSecretKey" | "signedIdentityKey" | "signalIdentities">) => {
|
|
7
|
+
creds: Partial<AuthenticationCreds>;
|
|
8
|
+
reply: BinaryNode;
|
|
9
|
+
};
|
|
10
|
+
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array<ArrayBufferLike>;
|
|
11
|
+
//# sourceMappingURL=validate-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-connection.d.ts","sourceRoot":"","sources":["../../src/Utils/validate-connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAO9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC9E,OAAO,EAAE,KAAK,UAAU,EAAiD,MAAM,aAAa,CAAA;AAuD5F,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,EAAE,QAAQ,YAAY,KAAG,KAAK,CAAC,cAY/E,CAAA;AAUD,eAAO,MAAM,wBAAwB,GACpC,qDAAqD,WAAW,EAChE,QAAQ,YAAY,wBAkDpB,CAAA;AAED,eAAO,MAAM,0BAA0B,GACtC,QAAQ,UAAU,EAClB,uDAIG,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;;;CAyFvF,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,SAAS,KAAK,CAAC,wBAAwB,EAAE,qBAAqB,OAAO,gCAS/G,CAAA"}
|
|
@@ -1,89 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const WABinary_1 = require("../WABinary")
|
|
10
|
-
const crypto_2 = require("./crypto")
|
|
11
|
-
const generics_1 = require("./generics")
|
|
12
|
-
const signal_1 = require("./signal")
|
|
13
|
-
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { createHash } from 'crypto';
|
|
3
|
+
import { proto } from '../../WAProto/index.js';
|
|
4
|
+
import { KEY_BUNDLE_TYPE, WA_ADV_ACCOUNT_SIG_PREFIX, WA_ADV_DEVICE_SIG_PREFIX, WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX } from '../Defaults/index.js';
|
|
5
|
+
import { getBinaryNodeChild, jidDecode, S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
6
|
+
import { Curve, hmacSign } from './crypto.js';
|
|
7
|
+
import { encodeBigEndian } from './generics.js';
|
|
8
|
+
import { createSignalIdentity } from './signal.js';
|
|
14
9
|
const getUserAgent = (config) => {
|
|
15
10
|
return {
|
|
16
11
|
appVersion: {
|
|
17
12
|
primary: config.version[0],
|
|
18
13
|
secondary: config.version[1],
|
|
19
|
-
tertiary: config.version[2]
|
|
14
|
+
tertiary: config.version[2]
|
|
20
15
|
},
|
|
21
|
-
platform:
|
|
22
|
-
releaseChannel:
|
|
16
|
+
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
17
|
+
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
23
18
|
osVersion: '0.1',
|
|
24
19
|
device: 'Desktop',
|
|
25
|
-
deviceType: WAProto_1.proto.ClientPayload.UserAgent.DeviceType.DESKTOP,
|
|
26
20
|
osBuildNumber: '0.1',
|
|
27
21
|
localeLanguageIso6391: 'en',
|
|
28
22
|
mnc: '000',
|
|
29
23
|
mcc: '000',
|
|
30
|
-
localeCountryIso31661Alpha2: config.countryCode
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
24
|
+
localeCountryIso31661Alpha2: config.countryCode
|
|
25
|
+
};
|
|
26
|
+
};
|
|
34
27
|
const PLATFORM_MAP = {
|
|
35
|
-
'Mac OS':
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
28
|
+
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
29
|
+
Windows: proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
30
|
+
};
|
|
40
31
|
const getWebInfo = (config) => {
|
|
41
|
-
let webSubPlatform =
|
|
42
|
-
if (config.syncFullHistory &&
|
|
43
|
-
|
|
32
|
+
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
33
|
+
if (config.syncFullHistory &&
|
|
34
|
+
PLATFORM_MAP[config.browser[0]] &&
|
|
35
|
+
config.browser[1] === 'Desktop') {
|
|
36
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
44
37
|
}
|
|
45
|
-
return { webSubPlatform }
|
|
46
|
-
}
|
|
47
|
-
|
|
38
|
+
return { webSubPlatform };
|
|
39
|
+
};
|
|
48
40
|
const getClientPayload = (config) => {
|
|
49
41
|
const payload = {
|
|
50
|
-
connectType:
|
|
51
|
-
connectReason:
|
|
52
|
-
userAgent: getUserAgent(config)
|
|
53
|
-
}
|
|
54
|
-
payload.webInfo = getWebInfo(config)
|
|
55
|
-
return payload
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const { user, device } = WABinary_1.jidDecode(userJid)
|
|
42
|
+
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
43
|
+
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
44
|
+
userAgent: getUserAgent(config)
|
|
45
|
+
};
|
|
46
|
+
payload.webInfo = getWebInfo(config);
|
|
47
|
+
return payload;
|
|
48
|
+
};
|
|
49
|
+
export const generateLoginNode = (userJid, config) => {
|
|
50
|
+
const { user, device } = jidDecode(userJid);
|
|
60
51
|
const payload = {
|
|
61
52
|
...getClientPayload(config),
|
|
62
|
-
passive:
|
|
53
|
+
passive: true,
|
|
63
54
|
pull: true,
|
|
64
55
|
username: +user,
|
|
65
56
|
device: device,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
57
|
+
// TODO: investigate (hard set as false atm)
|
|
58
|
+
lidDbMigrated: false
|
|
59
|
+
};
|
|
60
|
+
return proto.ClientPayload.fromObject(payload);
|
|
61
|
+
};
|
|
70
62
|
const getPlatformType = (platform) => {
|
|
71
|
-
const platformType = platform.toUpperCase()
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
63
|
+
const platformType = platform.toUpperCase();
|
|
64
|
+
return (proto.DeviceProps.PlatformType[platformType] ||
|
|
65
|
+
proto.DeviceProps.PlatformType.CHROME);
|
|
66
|
+
};
|
|
67
|
+
export const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
76
68
|
// the app version needs to be md5 hashed
|
|
77
69
|
// and passed in
|
|
78
|
-
const appVersionBuf =
|
|
70
|
+
const appVersionBuf = createHash('md5')
|
|
79
71
|
.update(config.version.join('.')) // join as string
|
|
80
|
-
.digest()
|
|
72
|
+
.digest();
|
|
81
73
|
const companion = {
|
|
82
74
|
os: config.browser[0],
|
|
83
75
|
platformType: getPlatformType(config.browser[1]),
|
|
84
76
|
requireFullSync: config.syncFullHistory,
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
historySyncConfig: {
|
|
78
|
+
storageQuotaMb: 569150,
|
|
79
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
80
|
+
supportCallLogHistory: false,
|
|
81
|
+
supportBotUserAgentChatHistory: true,
|
|
82
|
+
supportCagReactionsAndPolls: true,
|
|
83
|
+
supportBizHostedMsg: true,
|
|
84
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
85
|
+
supportHostedGroupMsg: true,
|
|
86
|
+
supportFbidBotChatHistory: true,
|
|
87
|
+
supportMessageAssociation: true
|
|
88
|
+
},
|
|
89
|
+
version: {
|
|
90
|
+
primary: 10,
|
|
91
|
+
secondary: 15,
|
|
92
|
+
tertiary: 7
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const companionProto = proto.DeviceProps.encode(companion).finish();
|
|
87
96
|
const registerPayload = {
|
|
88
97
|
...getClientPayload(config),
|
|
89
98
|
passive: false,
|
|
@@ -91,54 +100,63 @@ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentity
|
|
|
91
100
|
devicePairingData: {
|
|
92
101
|
buildHash: appVersionBuf,
|
|
93
102
|
deviceProps: companionProto,
|
|
94
|
-
eRegid:
|
|
95
|
-
eKeytype:
|
|
103
|
+
eRegid: encodeBigEndian(registrationId),
|
|
104
|
+
eKeytype: KEY_BUNDLE_TYPE,
|
|
96
105
|
eIdent: signedIdentityKey.public,
|
|
97
|
-
eSkeyId:
|
|
106
|
+
eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
|
|
98
107
|
eSkeyVal: signedPreKey.keyPair.public,
|
|
99
|
-
eSkeySig: signedPreKey.signature
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const businessNode = WABinary_1.getBinaryNodeChild(pairSuccessNode, 'biz')
|
|
108
|
+
eSkeySig: signedPreKey.signature
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return proto.ClientPayload.fromObject(registerPayload);
|
|
112
|
+
};
|
|
113
|
+
export const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
114
|
+
const msgId = stanza.attrs.id;
|
|
115
|
+
const pairSuccessNode = getBinaryNodeChild(stanza, 'pair-success');
|
|
116
|
+
const deviceIdentityNode = getBinaryNodeChild(pairSuccessNode, 'device-identity');
|
|
117
|
+
const platformNode = getBinaryNodeChild(pairSuccessNode, 'platform');
|
|
118
|
+
const deviceNode = getBinaryNodeChild(pairSuccessNode, 'device');
|
|
119
|
+
const businessNode = getBinaryNodeChild(pairSuccessNode, 'biz');
|
|
112
120
|
if (!deviceIdentityNode || !deviceNode) {
|
|
113
|
-
throw new
|
|
121
|
+
throw new Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
122
|
+
}
|
|
123
|
+
const bizName = businessNode?.attrs.name;
|
|
124
|
+
const jid = deviceNode.attrs.jid;
|
|
125
|
+
const lid = deviceNode.attrs.lid;
|
|
126
|
+
const { details, hmac, accountType } = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
127
|
+
let hmacPrefix = Buffer.from([]);
|
|
128
|
+
if (accountType !== undefined && accountType === proto.ADVEncryptionType.HOSTED) {
|
|
129
|
+
hmacPrefix = WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX;
|
|
114
130
|
}
|
|
115
|
-
const
|
|
116
|
-
const jid = deviceNode.attrs.jid
|
|
117
|
-
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content)
|
|
118
|
-
const isHostedAccount = accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED
|
|
119
|
-
const hmacPrefix = isHostedAccount ? Buffer.from([6, 5]) : Buffer.alloc(0)
|
|
120
|
-
const advSign = crypto_2.hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'))
|
|
131
|
+
const advSign = hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
121
132
|
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
122
|
-
throw new
|
|
133
|
+
throw new Boom('Invalid account signature');
|
|
123
134
|
}
|
|
124
|
-
const account =
|
|
125
|
-
const { accountSignatureKey, accountSignature, details: deviceDetails } = account
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
const account = proto.ADVSignedDeviceIdentity.decode(details);
|
|
136
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
137
|
+
const deviceIdentity = proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
138
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === proto.ADVEncryptionType.HOSTED
|
|
139
|
+
? WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX
|
|
140
|
+
: WA_ADV_ACCOUNT_SIG_PREFIX;
|
|
141
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
142
|
+
if (!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
143
|
+
throw new Boom('Failed to verify account signature');
|
|
129
144
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
const deviceMsg = Buffer.concat([
|
|
146
|
+
WA_ADV_DEVICE_SIG_PREFIX,
|
|
147
|
+
deviceDetails,
|
|
148
|
+
signedIdentityKey.public,
|
|
149
|
+
accountSignatureKey
|
|
150
|
+
]);
|
|
151
|
+
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
152
|
+
const identity = createSignalIdentity(lid, accountSignatureKey);
|
|
153
|
+
const accountEnc = encodeSignedDeviceIdentity(account, false);
|
|
136
154
|
const reply = {
|
|
137
155
|
tag: 'iq',
|
|
138
156
|
attrs: {
|
|
139
|
-
to:
|
|
157
|
+
to: S_WHATSAPP_NET,
|
|
140
158
|
type: 'result',
|
|
141
|
-
id: msgId
|
|
159
|
+
id: msgId
|
|
142
160
|
},
|
|
143
161
|
content: [
|
|
144
162
|
{
|
|
@@ -153,35 +171,25 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
153
171
|
]
|
|
154
172
|
}
|
|
155
173
|
]
|
|
156
|
-
}
|
|
174
|
+
};
|
|
157
175
|
const authUpdate = {
|
|
158
176
|
account,
|
|
159
|
-
me: { id: jid, name: bizName },
|
|
160
|
-
signalIdentities: [
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
],
|
|
164
|
-
platform: platformNode?.attrs?.name
|
|
165
|
-
}
|
|
177
|
+
me: { id: jid, name: bizName, lid },
|
|
178
|
+
signalIdentities: [...(signalIdentities || []), identity],
|
|
179
|
+
platform: platformNode?.attrs.name
|
|
180
|
+
};
|
|
166
181
|
return {
|
|
167
182
|
creds: authUpdate,
|
|
168
183
|
reply
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
account = { ...account }
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
export const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
187
|
+
account = { ...account };
|
|
174
188
|
// set to null if we are not to include the signature key
|
|
175
189
|
// or if we are including the signature key but it is empty
|
|
176
190
|
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
177
|
-
account.accountSignatureKey = null
|
|
191
|
+
account.accountSignatureKey = null;
|
|
178
192
|
}
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
module.exports = {
|
|
183
|
-
generateLoginNode,
|
|
184
|
-
generateRegistrationNode,
|
|
185
|
-
configureSuccessfulPairing,
|
|
186
|
-
encodeSignedDeviceIdentity
|
|
187
|
-
}
|
|
193
|
+
return proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
194
|
+
};
|
|
195
|
+
//# sourceMappingURL=validate-connection.js.map
|