lordceaser-baileys 2.0.37 → 2.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +660 -1073
- package/WAProto/GenerateStatics.sh +4 -3
- package/WAProto/WAProto.proto +359 -2494
- package/WAProto/index.d.ts +31460 -8461
- package/WAProto/index.js +96236 -92883
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -3
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +245 -37
- package/lib/Defaults/index.js +74 -82
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/libsignal.d.ts +3 -5
- package/lib/Signal/libsignal.js +80 -359
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +5 -4
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -3
- package/lib/Socket/Client/index.js +19 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +2 -3
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +87 -156
- package/lib/Socket/business.js +43 -162
- package/lib/Socket/chats.d.ts +40 -82
- package/lib/Socket/chats.js +284 -603
- package/lib/Socket/groups.d.ts +58 -96
- package/lib/Socket/groups.js +82 -115
- package/lib/Socket/index.d.ts +94 -204
- package/lib/Socket/index.js +9 -11
- package/lib/Socket/messages-recv.d.ts +77 -145
- package/lib/Socket/messages-recv.js +400 -1305
- package/lib/Socket/messages-send.d.ts +70 -141
- package/lib/Socket/messages-send.js +249 -717
- package/lib/Socket/registration.d.ts +242 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +18 -34
- package/lib/Socket/socket.js +206 -557
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +10 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +422 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +12 -19
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.d.ts +1 -3
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.d.ts +14 -31
- package/lib/Types/Chat.js +4 -8
- package/lib/Types/Contact.d.ts +1 -8
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.d.ts +17 -101
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.d.ts +3 -18
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.d.ts +0 -1
- package/lib/Types/Label.js +5 -3
- package/lib/Types/LabelAssociation.d.ts +0 -1
- package/lib/Types/LabelAssociation.js +5 -3
- package/lib/Types/Message.d.ts +29 -81
- package/lib/Types/Message.js +9 -11
- package/lib/Types/Product.d.ts +1 -2
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.d.ts +2 -32
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.d.ts +26 -46
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.d.ts +2 -72
- package/lib/Types/State.js +2 -56
- package/lib/Types/index.d.ts +13 -16
- package/lib/Types/index.js +30 -15
- package/lib/Utils/auth-utils.d.ts +6 -12
- package/lib/Utils/auth-utils.js +143 -239
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +2 -3
- package/lib/Utils/business.js +69 -66
- package/lib/Utils/chat-utils.d.ts +23 -52
- package/lib/Utils/chat-utils.js +248 -380
- package/lib/Utils/crypto.d.ts +21 -17
- package/lib/Utils/crypto.js +92 -57
- package/lib/Utils/decode-wa-message.d.ts +8 -54
- package/lib/Utils/decode-wa-message.js +57 -186
- package/lib/Utils/event-buffer.d.ts +8 -9
- package/lib/Utils/event-buffer.js +76 -178
- package/lib/Utils/generics.d.ts +23 -26
- package/lib/Utils/generics.js +166 -165
- package/lib/Utils/history.d.ts +11 -16
- package/lib/Utils/history.js +53 -93
- package/lib/Utils/index.d.ts +17 -22
- package/lib/Utils/index.js +33 -22
- package/lib/Utils/link-preview.d.ts +5 -5
- package/lib/Utils/link-preview.js +24 -16
- package/lib/Utils/logger.d.ts +3 -11
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +12 -8
- package/lib/Utils/lt-hash.js +46 -3
- package/lib/Utils/make-mutex.d.ts +2 -4
- package/lib/Utils/make-mutex.js +34 -24
- package/lib/Utils/messages-media.d.ts +35 -61
- package/lib/Utils/messages-media.js +301 -415
- package/lib/Utils/messages.d.ts +18 -32
- package/lib/Utils/messages.js +261 -396
- package/lib/Utils/noise-handler.d.ts +13 -12
- package/lib/Utils/noise-handler.js +98 -144
- package/lib/Utils/process-message.d.ts +12 -30
- package/lib/Utils/process-message.js +163 -439
- package/lib/Utils/signal.d.ts +5 -20
- package/lib/Utils/signal.js +74 -114
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +33 -61
- package/lib/Utils/validate-connection.d.ts +6 -6
- package/lib/Utils/validate-connection.js +114 -119
- package/lib/WABinary/constants.d.ts +4 -5
- package/lib/WABinary/constants.js +20 -1281
- package/lib/WABinary/decode.d.ts +4 -4
- package/lib/WABinary/decode.js +43 -51
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +44 -32
- package/lib/WABinary/generic-utils.d.ts +6 -6
- package/lib/WABinary/generic-utils.js +43 -46
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +21 -6
- package/lib/WABinary/jid-utils.d.ts +6 -23
- package/lib/WABinary/jid-utils.js +39 -73
- package/lib/WABinary/types.d.ts +1 -2
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.d.ts +11 -3
- package/lib/WAM/BinaryInfo.js +5 -2
- package/lib/WAM/constants.d.ts +3 -5
- package/lib/WAM/constants.js +11958 -19461
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.js +22 -17
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +19 -4
- package/lib/index.d.ts +8 -9
- package/lib/index.js +30 -11
- package/package.json +2 -2
- package/WAProto/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/WAProto/WAProto.proto +0 -5479
- package/WAProto/WAProto/fix-imports.js +0 -85
- package/WAProto/WAProto/index.d.ts +0 -14017
- package/WAProto/WAProto/index.js +0 -97691
- package/WAProto/fix-imports.js +0 -85
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js +0 -12
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts +0 -15
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js +0 -30
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js +0 -82
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts +0 -12
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js +0 -12
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js +0 -18
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js +0 -26
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -63
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js +0 -66
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js +0 -48
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts +0 -31
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js +0 -41
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts +0 -39
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js +0 -84
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts +0 -12
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts +0 -23
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js +0 -277
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js +0 -11
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js +0 -54
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts +0 -273
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js +0 -431
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts +0 -3
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js +0 -42
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts +0 -170
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js +0 -181
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -25
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Mex.d.ts +0 -141
- package/lib/Types/Mex.d.ts.map +0 -1
- package/lib/Types/Mex.js +0 -37
- package/lib/Types/Mex.js.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts +0 -26
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js +0 -2
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts +0 -4
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js +0 -29
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
- package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-utils.js +0 -35
- package/lib/Utils/companion-reg-client-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/identity-change-handler.d.ts +0 -44
- package/lib/Utils/identity-change-handler.d.ts.map +0 -1
- package/lib/Utils/identity-change-handler.js +0 -50
- package/lib/Utils/identity-change-handler.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts +0 -115
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js +0 -265
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/offline-node-processor.d.ts +0 -17
- package/lib/Utils/offline-node-processor.d.ts.map +0 -1
- package/lib/Utils/offline-node-processor.js +0 -40
- package/lib/Utils/offline-node-processor.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts +0 -28
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js +0 -106
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/reporting-utils.d.ts +0 -11
- package/lib/Utils/reporting-utils.d.ts.map +0 -1
- package/lib/Utils/reporting-utils.js +0 -258
- package/lib/Utils/reporting-utils.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/stanza-ack.d.ts +0 -11
- package/lib/Utils/stanza-ack.d.ts.map +0 -1
- package/lib/Utils/stanza-ack.js +0 -38
- package/lib/Utils/stanza-ack.js.map +0 -1
- package/lib/Utils/sync-action-utils.d.ts +0 -19
- package/lib/Utils/sync-action-utils.d.ts.map +0 -1
- package/lib/Utils/sync-action-utils.js +0 -49
- package/lib/Utils/sync-action-utils.js.map +0 -1
- package/lib/Utils/tc-token-utils.d.ts +0 -37
- package/lib/Utils/tc-token-utils.d.ts.map +0 -1
- package/lib/Utils/tc-token-utils.js +0 -164
- package/lib/Utils/tc-token-utils.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts.map +0 -1
- package/lib/WABinary/generic-utils.js.map +0 -1
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts.map +0 -1
- package/lib/WABinary/jid-utils.js.map +0 -1
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -52
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -54
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -27
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -38
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -25
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts +0 -6
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js +0 -6
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts +0 -30
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js +0 -98
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts +0 -17
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js +0 -31
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts +0 -4
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js +0 -4
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Utils/signal.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import type { USyncQueryResultList } from '../WAUSync/index.js';
|
|
1
|
+
import { SignalRepository } from '../Types';
|
|
2
|
+
import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
|
|
3
|
+
import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
5
4
|
export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
|
|
6
5
|
export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
|
|
7
6
|
[id: string]: KeyPair;
|
|
@@ -15,21 +14,8 @@ export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: n
|
|
|
15
14
|
};
|
|
16
15
|
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
|
|
17
16
|
export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
identityKey: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
21
|
-
signedPreKey: {
|
|
22
|
-
keyId: number;
|
|
23
|
-
publicKey: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
24
|
-
signature: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
25
|
-
};
|
|
26
|
-
preKey: {
|
|
27
|
-
keyId: number;
|
|
28
|
-
publicKey: Uint8Array;
|
|
29
|
-
} | undefined;
|
|
30
|
-
} | null;
|
|
31
|
-
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepositoryWithLIDStore) => Promise<void>;
|
|
32
|
-
export declare const extractDeviceJids: (result: USyncQueryResultList[], myJid: string, myLid: string, excludeZeroDevices: boolean) => FullJid[];
|
|
17
|
+
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>;
|
|
18
|
+
export declare const extractDeviceJids: (result: BinaryNode, myJid: string, excludeZeroDevices: boolean) => JidWithDevice[];
|
|
33
19
|
/**
|
|
34
20
|
* get the next N keys for upload or processing
|
|
35
21
|
* @param count number of pre-keys to get or generate
|
|
@@ -44,4 +30,3 @@ export declare const getNextPreKeysNode: (state: AuthenticationState, count: num
|
|
|
44
30
|
update: Partial<AuthenticationCreds>;
|
|
45
31
|
node: BinaryNode;
|
|
46
32
|
}>;
|
|
47
|
-
//# sourceMappingURL=signal.d.ts.map
|
package/lib/Utils/signal.js
CHANGED
|
@@ -1,113 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return chunks;
|
|
11
|
-
}
|
|
12
|
-
export const createSignalIdentity = (wid, accountSignatureKey) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNextPreKeysNode = exports.getNextPreKeys = exports.extractDeviceJids = exports.parseAndInjectE2ESessions = exports.xmppPreKey = exports.xmppSignedPreKey = exports.generateOrGetPreKeys = exports.getPreKeys = exports.createSignalIdentity = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const Defaults_1 = require("../Defaults");
|
|
6
|
+
const WABinary_1 = require("../WABinary");
|
|
7
|
+
const crypto_1 = require("./crypto");
|
|
8
|
+
const generics_1 = require("./generics");
|
|
9
|
+
const createSignalIdentity = (wid, accountSignatureKey) => {
|
|
13
10
|
return {
|
|
14
11
|
identifier: { name: wid, deviceId: 0 },
|
|
15
|
-
identifierKey: generateSignalPubKey(accountSignatureKey)
|
|
12
|
+
identifierKey: (0, crypto_1.generateSignalPubKey)(accountSignatureKey)
|
|
16
13
|
};
|
|
17
14
|
};
|
|
18
|
-
|
|
15
|
+
exports.createSignalIdentity = createSignalIdentity;
|
|
16
|
+
const getPreKeys = async ({ get }, min, limit) => {
|
|
19
17
|
const idList = [];
|
|
20
18
|
for (let id = min; id < limit; id++) {
|
|
21
19
|
idList.push(id.toString());
|
|
22
20
|
}
|
|
23
21
|
return get('pre-key', idList);
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
exports.getPreKeys = getPreKeys;
|
|
24
|
+
const generateOrGetPreKeys = (creds, range) => {
|
|
26
25
|
const avaliable = creds.nextPreKeyId - creds.firstUnuploadedPreKeyId;
|
|
27
26
|
const remaining = range - avaliable;
|
|
28
27
|
const lastPreKeyId = creds.nextPreKeyId + remaining - 1;
|
|
29
28
|
const newPreKeys = {};
|
|
30
29
|
if (remaining > 0) {
|
|
31
30
|
for (let i = creds.nextPreKeyId; i <= lastPreKeyId; i++) {
|
|
32
|
-
newPreKeys[i] = Curve.generateKeyPair();
|
|
31
|
+
newPreKeys[i] = crypto_1.Curve.generateKeyPair();
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
return {
|
|
36
35
|
newPreKeys,
|
|
37
36
|
lastPreKeyId,
|
|
38
|
-
preKeysRange: [creds.firstUnuploadedPreKeyId, range]
|
|
37
|
+
preKeysRange: [creds.firstUnuploadedPreKeyId, range],
|
|
39
38
|
};
|
|
40
39
|
};
|
|
41
|
-
|
|
40
|
+
exports.generateOrGetPreKeys = generateOrGetPreKeys;
|
|
41
|
+
const xmppSignedPreKey = (key) => ({
|
|
42
42
|
tag: 'skey',
|
|
43
43
|
attrs: {},
|
|
44
44
|
content: [
|
|
45
|
-
{ tag: 'id', attrs: {}, content: encodeBigEndian(key.keyId, 3) },
|
|
45
|
+
{ tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(key.keyId, 3) },
|
|
46
46
|
{ tag: 'value', attrs: {}, content: key.keyPair.public },
|
|
47
47
|
{ tag: 'signature', attrs: {}, content: key.signature }
|
|
48
48
|
]
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
exports.xmppSignedPreKey = xmppSignedPreKey;
|
|
51
|
+
const xmppPreKey = (pair, id) => ({
|
|
51
52
|
tag: 'key',
|
|
52
53
|
attrs: {},
|
|
53
54
|
content: [
|
|
54
|
-
{ tag: 'id', attrs: {}, content: encodeBigEndian(id, 3) },
|
|
55
|
+
{ tag: 'id', attrs: {}, content: (0, generics_1.encodeBigEndian)(id, 3) },
|
|
55
56
|
{ tag: 'value', attrs: {}, content: pair.public }
|
|
56
57
|
]
|
|
57
58
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const identity = getBinaryNodeChildBuffer(keysNode, 'identity');
|
|
67
|
-
const skey = getBinaryNodeChild(keysNode, 'skey');
|
|
68
|
-
if (!identity || identity.length !== 32 || !skey)
|
|
69
|
-
return null;
|
|
70
|
-
const registrationId = getBinaryNodeChildUInt(receipt, 'registration', 4);
|
|
71
|
-
if (!isValidUInt(registrationId))
|
|
72
|
-
return null;
|
|
73
|
-
const signedPubKey = getBinaryNodeChildBuffer(skey, 'value');
|
|
74
|
-
const signedSig = getBinaryNodeChildBuffer(skey, 'signature');
|
|
75
|
-
const signedKeyId = getBinaryNodeChildUInt(skey, 'id', 3);
|
|
76
|
-
if (!signedPubKey || signedPubKey.length !== 32 || !signedSig || !isValidUInt(signedKeyId)) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const preKeyNode = getBinaryNodeChild(keysNode, 'key');
|
|
80
|
-
let preKey;
|
|
81
|
-
if (preKeyNode) {
|
|
82
|
-
const preKeyPub = getBinaryNodeChildBuffer(preKeyNode, 'value');
|
|
83
|
-
const preKeyId = getBinaryNodeChildUInt(preKeyNode, 'id', 3);
|
|
84
|
-
if (!preKeyPub || preKeyPub.length !== 32 || !isValidUInt(preKeyId)) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
preKey = { keyId: preKeyId, publicKey: generateSignalPubKey(preKeyPub) };
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
registrationId,
|
|
91
|
-
identityKey: generateSignalPubKey(identity),
|
|
92
|
-
signedPreKey: {
|
|
93
|
-
keyId: signedKeyId,
|
|
94
|
-
publicKey: generateSignalPubKey(signedPubKey),
|
|
95
|
-
signature: signedSig
|
|
96
|
-
},
|
|
97
|
-
preKey
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export const parseAndInjectE2ESessions = async (node, repository) => {
|
|
101
|
-
const extractKey = (key) => key
|
|
102
|
-
? {
|
|
103
|
-
keyId: getBinaryNodeChildUInt(key, 'id', 3),
|
|
104
|
-
publicKey: generateSignalPubKey(getBinaryNodeChildBuffer(key, 'value')),
|
|
105
|
-
signature: getBinaryNodeChildBuffer(key, 'signature')
|
|
106
|
-
}
|
|
107
|
-
: undefined;
|
|
108
|
-
const nodes = getBinaryNodeChildren(getBinaryNodeChild(node, 'list'), 'user');
|
|
59
|
+
exports.xmppPreKey = xmppPreKey;
|
|
60
|
+
const parseAndInjectE2ESessions = async (node, repository) => {
|
|
61
|
+
const extractKey = (key) => (key ? ({
|
|
62
|
+
keyId: (0, WABinary_1.getBinaryNodeChildUInt)(key, 'id', 3),
|
|
63
|
+
publicKey: (0, crypto_1.generateSignalPubKey)((0, WABinary_1.getBinaryNodeChildBuffer)(key, 'value')),
|
|
64
|
+
signature: (0, WABinary_1.getBinaryNodeChildBuffer)(key, 'signature'),
|
|
65
|
+
}) : undefined);
|
|
66
|
+
const nodes = (0, WABinary_1.getBinaryNodeChildren)((0, WABinary_1.getBinaryNodeChild)(node, 'list'), 'user');
|
|
109
67
|
for (const node of nodes) {
|
|
110
|
-
assertNodeErrorFree(node);
|
|
68
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
111
69
|
}
|
|
112
70
|
// Most of the work in repository.injectE2ESession is CPU intensive, not IO
|
|
113
71
|
// So Promise.all doesn't really help here,
|
|
@@ -115,87 +73,89 @@ export const parseAndInjectE2ESessions = async (node, repository) => {
|
|
|
115
73
|
// This way we chunk it in smaller parts and between those parts we can yield to the event loop
|
|
116
74
|
// It's rare case when you need to E2E sessions for so many users, but it's possible
|
|
117
75
|
const chunkSize = 100;
|
|
118
|
-
const chunks = chunk(nodes, chunkSize);
|
|
76
|
+
const chunks = (0, lodash_1.chunk)(nodes, chunkSize);
|
|
119
77
|
for (const nodesChunk of chunks) {
|
|
120
|
-
|
|
121
|
-
const signedKey = getBinaryNodeChild(node, 'skey');
|
|
122
|
-
const key = getBinaryNodeChild(node, 'key');
|
|
123
|
-
const identity = getBinaryNodeChildBuffer(node, 'identity');
|
|
78
|
+
await Promise.all(nodesChunk.map(async (node) => {
|
|
79
|
+
const signedKey = (0, WABinary_1.getBinaryNodeChild)(node, 'skey');
|
|
80
|
+
const key = (0, WABinary_1.getBinaryNodeChild)(node, 'key');
|
|
81
|
+
const identity = (0, WABinary_1.getBinaryNodeChildBuffer)(node, 'identity');
|
|
124
82
|
const jid = node.attrs.jid;
|
|
125
|
-
const registrationId = getBinaryNodeChildUInt(node, 'registration', 4);
|
|
83
|
+
const registrationId = (0, WABinary_1.getBinaryNodeChildUInt)(node, 'registration', 4);
|
|
126
84
|
await repository.injectE2ESession({
|
|
127
85
|
jid,
|
|
128
86
|
session: {
|
|
129
87
|
registrationId: registrationId,
|
|
130
|
-
identityKey: generateSignalPubKey(identity),
|
|
88
|
+
identityKey: (0, crypto_1.generateSignalPubKey)(identity),
|
|
131
89
|
signedPreKey: extractKey(signedKey),
|
|
132
90
|
preKey: extractKey(key)
|
|
133
91
|
}
|
|
134
92
|
});
|
|
135
|
-
}
|
|
93
|
+
}));
|
|
136
94
|
}
|
|
137
95
|
};
|
|
138
|
-
|
|
139
|
-
|
|
96
|
+
exports.parseAndInjectE2ESessions = parseAndInjectE2ESessions;
|
|
97
|
+
const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const { user: myUser, device: myDevice } = (0, WABinary_1.jidDecode)(myJid);
|
|
140
100
|
const extracted = [];
|
|
141
|
-
for (const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
101
|
+
for (const node of result.content) {
|
|
102
|
+
const list = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'list')) === null || _a === void 0 ? void 0 : _a.content;
|
|
103
|
+
if (list && Array.isArray(list)) {
|
|
104
|
+
for (const item of list) {
|
|
105
|
+
const { user } = (0, WABinary_1.jidDecode)(item.attrs.jid);
|
|
106
|
+
const devicesNode = (0, WABinary_1.getBinaryNodeChild)(item, 'devices');
|
|
107
|
+
const deviceListNode = (0, WABinary_1.getBinaryNodeChild)(devicesNode, 'device-list');
|
|
108
|
+
if (Array.isArray(deviceListNode === null || deviceListNode === void 0 ? void 0 : deviceListNode.content)) {
|
|
109
|
+
for (const { tag, attrs } of deviceListNode.content) {
|
|
110
|
+
const device = +attrs.id;
|
|
111
|
+
if (tag === 'device' && // ensure the "device" tag
|
|
112
|
+
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
|
113
|
+
(myUser !== user || myDevice !== device) && // either different user or if me user, not this device
|
|
114
|
+
(device === 0 || !!attrs['key-index']) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
|
|
115
|
+
) {
|
|
116
|
+
extracted.push({ user, device });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
155
119
|
}
|
|
156
|
-
extracted.push({
|
|
157
|
-
user,
|
|
158
|
-
device,
|
|
159
|
-
domainType,
|
|
160
|
-
server: getServerFromDomainType(server, domainType)
|
|
161
|
-
});
|
|
162
120
|
}
|
|
163
121
|
}
|
|
164
122
|
}
|
|
165
123
|
return extracted;
|
|
166
124
|
};
|
|
125
|
+
exports.extractDeviceJids = extractDeviceJids;
|
|
167
126
|
/**
|
|
168
127
|
* get the next N keys for upload or processing
|
|
169
128
|
* @param count number of pre-keys to get or generate
|
|
170
129
|
*/
|
|
171
|
-
|
|
172
|
-
const { newPreKeys, lastPreKeyId, preKeysRange } = generateOrGetPreKeys(creds, count);
|
|
130
|
+
const getNextPreKeys = async ({ creds, keys }, count) => {
|
|
131
|
+
const { newPreKeys, lastPreKeyId, preKeysRange } = (0, exports.generateOrGetPreKeys)(creds, count);
|
|
173
132
|
const update = {
|
|
174
133
|
nextPreKeyId: Math.max(lastPreKeyId + 1, creds.nextPreKeyId),
|
|
175
134
|
firstUnuploadedPreKeyId: Math.max(creds.firstUnuploadedPreKeyId, lastPreKeyId + 1)
|
|
176
135
|
};
|
|
177
136
|
await keys.set({ 'pre-key': newPreKeys });
|
|
178
|
-
const preKeys = await getPreKeys(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
|
|
137
|
+
const preKeys = await (0, exports.getPreKeys)(keys, preKeysRange[0], preKeysRange[0] + preKeysRange[1]);
|
|
179
138
|
return { update, preKeys };
|
|
180
139
|
};
|
|
181
|
-
|
|
140
|
+
exports.getNextPreKeys = getNextPreKeys;
|
|
141
|
+
const getNextPreKeysNode = async (state, count) => {
|
|
182
142
|
const { creds } = state;
|
|
183
|
-
const { update, preKeys } = await getNextPreKeys(state, count);
|
|
143
|
+
const { update, preKeys } = await (0, exports.getNextPreKeys)(state, count);
|
|
184
144
|
const node = {
|
|
185
145
|
tag: 'iq',
|
|
186
146
|
attrs: {
|
|
187
147
|
xmlns: 'encrypt',
|
|
188
148
|
type: 'set',
|
|
189
|
-
to: S_WHATSAPP_NET
|
|
149
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
190
150
|
},
|
|
191
151
|
content: [
|
|
192
|
-
{ tag: 'registration', attrs: {}, content: encodeBigEndian(creds.registrationId) },
|
|
193
|
-
{ tag: 'type', attrs: {}, content: KEY_BUNDLE_TYPE },
|
|
152
|
+
{ tag: 'registration', attrs: {}, content: (0, generics_1.encodeBigEndian)(creds.registrationId) },
|
|
153
|
+
{ tag: 'type', attrs: {}, content: Defaults_1.KEY_BUNDLE_TYPE },
|
|
194
154
|
{ tag: 'identity', attrs: {}, content: creds.signedIdentityKey.public },
|
|
195
|
-
{ tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => xmppPreKey(preKeys[+k], +k)) },
|
|
196
|
-
xmppSignedPreKey(creds.signedPreKey)
|
|
155
|
+
{ tag: 'list', attrs: {}, content: Object.keys(preKeys).map(k => (0, exports.xmppPreKey)(preKeys[+k], +k)) },
|
|
156
|
+
(0, exports.xmppSignedPreKey)(creds.signedPreKey)
|
|
197
157
|
]
|
|
198
158
|
};
|
|
199
159
|
return { update, node };
|
|
200
160
|
};
|
|
201
|
-
|
|
161
|
+
exports.getNextPreKeysNode = getNextPreKeysNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AuthenticationState } from '../Types';
|
|
2
2
|
/**
|
|
3
3
|
* stores the full authentication state in a single folder.
|
|
4
4
|
* Far more efficient than singlefileauthstate
|
|
@@ -10,4 +10,3 @@ export declare const useMultiFileAuthState: (folder: string) => Promise<{
|
|
|
10
10
|
state: AuthenticationState;
|
|
11
11
|
saveCreds: () => Promise<void>;
|
|
12
12
|
}>;
|
|
13
|
-
//# sourceMappingURL=use-multi-file-auth-state.d.ts.map
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useMultiFileAuthState = void 0;
|
|
7
|
+
const async_lock_1 = __importDefault(require("async-lock"));
|
|
8
|
+
const promises_1 = require("fs/promises");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const WAProto_1 = require("../../WAProto");
|
|
11
|
+
const auth_utils_1 = require("./auth-utils");
|
|
12
|
+
const generics_1 = require("./generics");
|
|
7
13
|
// We need to lock files due to the fact that we are using async functions to read and write files
|
|
8
14
|
// https://github.com/WhiskeySockets/Baileys/issues/794
|
|
9
15
|
// https://github.com/nodejs/node/issues/26338
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const getFileLock = (path) => {
|
|
14
|
-
let mutex = fileLocks.get(path);
|
|
15
|
-
if (!mutex) {
|
|
16
|
-
mutex = new Mutex();
|
|
17
|
-
fileLocks.set(path, mutex);
|
|
18
|
-
}
|
|
19
|
-
return mutex;
|
|
20
|
-
};
|
|
16
|
+
// Default pending is 1000, set it to infinity
|
|
17
|
+
// https://github.com/rogierschouten/async-lock/issues/63
|
|
18
|
+
const fileLock = new async_lock_1.default({ maxPending: Infinity });
|
|
21
19
|
/**
|
|
22
20
|
* stores the full authentication state in a single folder.
|
|
23
21
|
* Far more efficient than singlefileauthstate
|
|
@@ -25,33 +23,16 @@ const getFileLock = (path) => {
|
|
|
25
23
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
26
24
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
27
25
|
* */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const mutex = getFileLock(filePath);
|
|
33
|
-
return mutex.acquire().then(async (release) => {
|
|
34
|
-
try {
|
|
35
|
-
await writeFile(filePath, JSON.stringify(data, BufferJSON.replacer));
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
release();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
26
|
+
const useMultiFileAuthState = async (folder) => {
|
|
27
|
+
const writeData = (data, file) => {
|
|
28
|
+
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
29
|
+
return fileLock.acquire(filePath, () => (0, promises_1.writeFile)((0, path_1.join)(filePath), JSON.stringify(data, generics_1.BufferJSON.replacer)));
|
|
41
30
|
};
|
|
42
31
|
const readData = async (file) => {
|
|
43
32
|
try {
|
|
44
|
-
const filePath = join(folder, fixFileName(file));
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
-
try {
|
|
48
|
-
const data = await readFile(filePath, { encoding: 'utf-8' });
|
|
49
|
-
return JSON.parse(data, BufferJSON.reviver);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
release();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
33
|
+
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
34
|
+
const data = await fileLock.acquire(filePath, () => (0, promises_1.readFile)(filePath, { encoding: 'utf-8' }));
|
|
35
|
+
return JSON.parse(data, generics_1.BufferJSON.reviver);
|
|
55
36
|
}
|
|
56
37
|
catch (error) {
|
|
57
38
|
return null;
|
|
@@ -59,32 +40,23 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
59
40
|
};
|
|
60
41
|
const removeData = async (file) => {
|
|
61
42
|
try {
|
|
62
|
-
const filePath = join(folder, fixFileName(file));
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
await unlink(filePath);
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
release();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
43
|
+
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
44
|
+
await fileLock.acquire(filePath, () => (0, promises_1.unlink)(filePath));
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
74
47
|
}
|
|
75
|
-
catch { }
|
|
76
48
|
};
|
|
77
|
-
const folderInfo = await stat(folder).catch(() => { });
|
|
49
|
+
const folderInfo = await (0, promises_1.stat)(folder).catch(() => { });
|
|
78
50
|
if (folderInfo) {
|
|
79
51
|
if (!folderInfo.isDirectory()) {
|
|
80
52
|
throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
|
|
81
53
|
}
|
|
82
54
|
}
|
|
83
55
|
else {
|
|
84
|
-
await mkdir(folder, { recursive: true });
|
|
56
|
+
await (0, promises_1.mkdir)(folder, { recursive: true });
|
|
85
57
|
}
|
|
86
|
-
const fixFileName = (file) => file
|
|
87
|
-
const creds =
|
|
58
|
+
const fixFileName = (file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.replace(/\//g, '__')) === null || _a === void 0 ? void 0 : _a.replace(/:/g, '-'); };
|
|
59
|
+
const creds = await readData('creds.json') || (0, auth_utils_1.initAuthCreds)();
|
|
88
60
|
return {
|
|
89
61
|
state: {
|
|
90
62
|
creds,
|
|
@@ -94,7 +66,7 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
94
66
|
await Promise.all(ids.map(async (id) => {
|
|
95
67
|
let value = await readData(`${type}-${id}.json`);
|
|
96
68
|
if (type === 'app-state-sync-key' && value) {
|
|
97
|
-
value = proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
69
|
+
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
98
70
|
}
|
|
99
71
|
data[id] = value;
|
|
100
72
|
}));
|
|
@@ -113,9 +85,9 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
113
85
|
}
|
|
114
86
|
}
|
|
115
87
|
},
|
|
116
|
-
saveCreds:
|
|
88
|
+
saveCreds: () => {
|
|
117
89
|
return writeData(creds, 'creds.json');
|
|
118
90
|
}
|
|
119
91
|
};
|
|
120
92
|
};
|
|
121
|
-
|
|
93
|
+
exports.useMultiFileAuthState = useMultiFileAuthState;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { proto } from '../../WAProto
|
|
2
|
-
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types
|
|
3
|
-
import {
|
|
1
|
+
import { proto } from '../../WAProto';
|
|
2
|
+
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
export declare const generateMobileNode: (config: SocketConfig) => proto.IClientPayload;
|
|
4
5
|
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
|
5
6
|
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
|
6
|
-
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds,
|
|
7
|
+
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
|
7
8
|
creds: Partial<AuthenticationCreds>;
|
|
8
9
|
reply: BinaryNode;
|
|
9
10
|
};
|
|
10
|
-
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array
|
|
11
|
-
//# sourceMappingURL=validate-connection.d.ts.map
|
|
11
|
+
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array;
|