lordceaser-baileys 2.0.0 → 2.0.2
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/index.js +136901 -78899
- 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/index.js +17 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +15 -37
- package/lib/Defaults/index.js +60 -81
- 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 +100 -147
- package/lib/Socket/business.js +43 -162
- package/lib/Socket/chats.d.ts +41 -85
- package/lib/Socket/chats.js +321 -569
- package/lib/Socket/groups.d.ts +57 -103
- package/lib/Socket/groups.js +84 -116
- package/lib/Socket/index.d.ts +106 -194
- package/lib/Socket/index.js +9 -11
- package/lib/Socket/messages-recv.d.ts +89 -134
- package/lib/Socket/messages-recv.js +475 -1275
- package/lib/Socket/messages-send.d.ts +97 -141
- package/lib/Socket/messages-send.js +633 -691
- package/lib/Socket/newsletter.d.ts +74 -112
- package/lib/Socket/newsletter.js +202 -147
- package/lib/Socket/registration.d.ts +264 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +19 -34
- package/lib/Socket/socket.js +219 -547
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- 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 +431 -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 +11 -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 +8 -25
- 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 +204 -91
- package/lib/Types/Message.js +9 -11
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Newsletter.js +32 -0
- 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 +24 -44
- 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/USync.d.ts +2 -3
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.d.ts +16 -16
- package/lib/Types/index.js +31 -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 +3 -4
- package/lib/Utils/business.js +69 -66
- package/lib/Utils/c4-compat.js +0 -8
- package/lib/Utils/chat-utils.d.ts +17 -47
- package/lib/Utils/chat-utils.js +237 -364
- package/lib/Utils/crypto.d.ts +21 -18
- package/lib/Utils/crypto.js +125 -44
- package/lib/Utils/decode-wa-message.d.ts +8 -38
- package/lib/Utils/decode-wa-message.js +90 -173
- package/lib/Utils/event-buffer.d.ts +8 -9
- package/lib/Utils/event-buffer.js +71 -176
- package/lib/Utils/generics.d.ts +22 -26
- package/lib/Utils/generics.js +175 -166
- 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 +34 -22
- package/lib/Utils/link-preview.d.ts +5 -5
- package/lib/Utils/link-preview.js +24 -16
- package/lib/Utils/logger.d.ts +1 -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 +0 -2
- package/lib/Utils/make-mutex.js +34 -24
- package/lib/Utils/messages-media.d.ts +45 -65
- package/lib/Utils/messages-media.js +358 -425
- package/lib/Utils/messages.d.ts +18 -32
- package/lib/Utils/messages.js +720 -392
- package/lib/Utils/noise-handler.d.ts +13 -13
- package/lib/Utils/noise-handler.js +108 -149
- package/lib/Utils/process-message.d.ts +11 -30
- package/lib/Utils/process-message.js +166 -423
- package/lib/Utils/signal.d.ts +6 -20
- package/lib/Utils/signal.js +65 -107
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +103 -57
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-single-file-auth-state.js +76 -0
- 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 +3 -4
- package/lib/WABinary/decode.js +53 -51
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +44 -12
- package/lib/WABinary/generic-utils.d.ts +6 -7
- 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 +7 -24
- package/lib/WABinary/jid-utils.js +40 -74
- package/lib/WABinary/types.d.ts +1 -2
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.d.ts +1 -2
- 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 +2 -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/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +13 -33
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -9
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -5
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +8 -13
- package/lib/WAUSync/Protocols/index.d.ts +4 -6
- package/lib/WAUSync/Protocols/index.js +20 -6
- package/lib/WAUSync/USyncQuery.d.ts +4 -6
- package/lib/WAUSync/USyncQuery.js +35 -44
- package/lib/WAUSync/USyncUser.d.ts +4 -11
- package/lib/WAUSync/USyncUser.js +5 -10
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +19 -4
- package/lib/index.js +31 -13
- package/package.json +19 -10
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/WAProto.proto +0 -5479
- package/WAProto/fix-imports.js +0 -85
- package/WAProto/index.d.ts +0 -14017
- 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.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -25
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/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.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/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.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/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.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts +0 -12
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Signal/libsignal.js
CHANGED
|
@@ -1,391 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser, jidDecode, transferDevice, WAJIDDomains } from '../WABinary/index.js';
|
|
8
|
-
import { SenderKeyName } from './Group/sender-key-name.js';
|
|
9
|
-
import { SenderKeyRecord } from './Group/sender-key-record.js';
|
|
10
|
-
import { GroupCipher, GroupSessionBuilder, SenderKeyDistributionMessage } from './Group/index.js';
|
|
11
|
-
import { LIDMappingStore } from './lid-mapping.js';
|
|
12
|
-
/** Extract identity key from PreKeyWhisperMessage for identity change detection */
|
|
13
|
-
function extractIdentityFromPkmsg(ciphertext) {
|
|
14
|
-
try {
|
|
15
|
-
if (!ciphertext || ciphertext.length < 2) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
// Version byte check (version 3)
|
|
19
|
-
const version = ciphertext[0];
|
|
20
|
-
if ((version & 0xf) !== 3) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
// Parse protobuf (skip version byte)
|
|
24
|
-
const preKeyProto = PreKeyWhisperMessage.decode(ciphertext.slice(1));
|
|
25
|
-
if (preKeyProto.identityKey?.length === 33) {
|
|
26
|
-
return new Uint8Array(preKeyProto.identityKey);
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
7
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.makeLibSignalRepository = void 0;
|
|
27
|
+
const libsignal = __importStar(require("libsignal"));
|
|
28
|
+
const WASignalGroup_1 = require("../../WASignalGroup");
|
|
29
|
+
const Utils_1 = require("../Utils");
|
|
30
|
+
const WABinary_1 = require("../WABinary");
|
|
31
|
+
function makeLibSignalRepository(auth) {
|
|
32
|
+
const storage = signalStorage(auth);
|
|
33
|
+
return {
|
|
54
34
|
decryptGroupMessage({ group, authorJid, msg }) {
|
|
55
35
|
const senderName = jidToSignalSenderKeyName(group, authorJid);
|
|
56
|
-
const cipher = new GroupCipher(storage, senderName);
|
|
57
|
-
|
|
58
|
-
return parsedKeys.transaction(async () => {
|
|
59
|
-
return cipher.decrypt(msg);
|
|
60
|
-
}, group);
|
|
36
|
+
const cipher = new WASignalGroup_1.GroupCipher(storage, senderName);
|
|
37
|
+
return cipher.decrypt(msg);
|
|
61
38
|
},
|
|
62
39
|
async processSenderKeyDistributionMessage({ item, authorJid }) {
|
|
63
|
-
const builder = new GroupSessionBuilder(storage);
|
|
64
|
-
if (!item.groupId) {
|
|
65
|
-
throw new Error('Group ID is required for sender key distribution message');
|
|
66
|
-
}
|
|
40
|
+
const builder = new WASignalGroup_1.GroupSessionBuilder(storage);
|
|
67
41
|
const senderName = jidToSignalSenderKeyName(item.groupId, authorJid);
|
|
68
|
-
const senderMsg = new SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
|
|
69
|
-
const
|
|
70
|
-
const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
|
|
42
|
+
const senderMsg = new WASignalGroup_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
|
|
43
|
+
const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName]);
|
|
71
44
|
if (!senderKey) {
|
|
72
|
-
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
45
|
+
await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord());
|
|
73
46
|
}
|
|
74
|
-
|
|
75
|
-
const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
|
|
76
|
-
if (!senderKey) {
|
|
77
|
-
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
78
|
-
}
|
|
79
|
-
await builder.process(senderName, senderMsg);
|
|
80
|
-
}, item.groupId);
|
|
47
|
+
await builder.process(senderName, senderMsg);
|
|
81
48
|
},
|
|
82
49
|
async decryptMessage({ jid, type, ciphertext }) {
|
|
83
50
|
const addr = jidToSignalProtocolAddress(jid);
|
|
84
51
|
const session = new libsignal.SessionCipher(storage, addr);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
}
|
|
52
|
+
let result;
|
|
53
|
+
switch (type) {
|
|
54
|
+
case 'pkmsg':
|
|
55
|
+
result = await session.decryptPreKeyWhisperMessage(ciphertext);
|
|
56
|
+
break;
|
|
57
|
+
case 'msg':
|
|
58
|
+
result = await session.decryptWhisperMessage(ciphertext);
|
|
59
|
+
break;
|
|
95
60
|
}
|
|
96
|
-
|
|
97
|
-
let result;
|
|
98
|
-
switch (type) {
|
|
99
|
-
case 'pkmsg':
|
|
100
|
-
result = await session.decryptPreKeyWhisperMessage(ciphertext);
|
|
101
|
-
break;
|
|
102
|
-
case 'msg':
|
|
103
|
-
result = await session.decryptWhisperMessage(ciphertext);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
// If it's not a sync message, we need to ensure atomicity
|
|
109
|
-
// For regular messages, we use a transaction to ensure atomicity
|
|
110
|
-
return parsedKeys.transaction(async () => {
|
|
111
|
-
return await doDecrypt();
|
|
112
|
-
}, jid);
|
|
61
|
+
return result;
|
|
113
62
|
},
|
|
114
63
|
async encryptMessage({ jid, data }) {
|
|
115
64
|
const addr = jidToSignalProtocolAddress(jid);
|
|
116
65
|
const cipher = new libsignal.SessionCipher(storage, addr);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const type = sigType === 3 ? 'pkmsg' : 'msg';
|
|
121
|
-
return { type, ciphertext: Buffer.from(body, 'binary') };
|
|
122
|
-
}, jid);
|
|
66
|
+
const { type: sigType, body } = await cipher.encrypt(data);
|
|
67
|
+
const type = sigType === 3 ? 'pkmsg' : 'msg';
|
|
68
|
+
return { type, ciphertext: Buffer.from(body, 'binary') };
|
|
123
69
|
},
|
|
124
70
|
async encryptGroupMessage({ group, meId, data }) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
async getSenderKeyDistributionMessage({ group, meId }) {
|
|
132
|
-
return parsedKeys.transaction(async () => {
|
|
133
|
-
const { skdm } = await ensureSenderKeyAndCreateSkdm(group, meId);
|
|
134
|
-
return skdm.serialize();
|
|
135
|
-
}, group);
|
|
136
|
-
},
|
|
137
|
-
async hasSenderKey({ group, meId }) {
|
|
138
|
-
const senderName = jidToSignalSenderKeyName(group, meId).toString();
|
|
139
|
-
const { [senderName]: key } = await auth.keys.get('sender-key', [senderName]);
|
|
140
|
-
return !!key;
|
|
141
|
-
},
|
|
142
|
-
async getSessionInfo(jid) {
|
|
143
|
-
const addr = jidToSignalProtocolAddress(jid).toString();
|
|
144
|
-
const session = (await storage.loadSession(addr));
|
|
145
|
-
if (!session) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
const open = session.getOpenSession?.();
|
|
149
|
-
const baseKey = open?.indexInfo?.baseKey;
|
|
150
|
-
const registrationId = open?.registrationId;
|
|
151
|
-
if (!baseKey || typeof registrationId !== 'number') {
|
|
152
|
-
return null;
|
|
71
|
+
const senderName = jidToSignalSenderKeyName(group, meId);
|
|
72
|
+
const builder = new WASignalGroup_1.GroupSessionBuilder(storage);
|
|
73
|
+
const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName]);
|
|
74
|
+
if (!senderKey) {
|
|
75
|
+
await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord());
|
|
153
76
|
}
|
|
154
|
-
|
|
77
|
+
const senderKeyDistributionMessage = await builder.create(senderName);
|
|
78
|
+
const session = new WASignalGroup_1.GroupCipher(storage, senderName);
|
|
79
|
+
const ciphertext = await session.encrypt(data);
|
|
80
|
+
return {
|
|
81
|
+
ciphertext,
|
|
82
|
+
senderKeyDistributionMessage: senderKeyDistributionMessage.serialize(),
|
|
83
|
+
};
|
|
155
84
|
},
|
|
156
85
|
async injectE2ESession({ jid, session }) {
|
|
157
|
-
logger.trace({ jid }, 'injecting E2EE session');
|
|
158
86
|
const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid));
|
|
159
|
-
|
|
160
|
-
// libsignal runtime accepts an absent prekey (initOutgoing checks `device.preKey && ...`)
|
|
161
|
-
// but the bundled .d.ts marks it required.
|
|
162
|
-
await cipher.initOutgoing(session);
|
|
163
|
-
}, jid);
|
|
87
|
+
await cipher.initOutgoing(session);
|
|
164
88
|
},
|
|
165
89
|
jidToSignalProtocolAddress(jid) {
|
|
166
90
|
return jidToSignalProtocolAddress(jid).toString();
|
|
167
91
|
},
|
|
168
|
-
// Optimized direct access to LID mapping store
|
|
169
|
-
lidMapping,
|
|
170
|
-
async validateSession(jid) {
|
|
171
|
-
try {
|
|
172
|
-
const addr = jidToSignalProtocolAddress(jid);
|
|
173
|
-
const session = await storage.loadSession(addr.toString());
|
|
174
|
-
if (!session) {
|
|
175
|
-
return { exists: false, reason: 'no session' };
|
|
176
|
-
}
|
|
177
|
-
if (!session.haveOpenSession()) {
|
|
178
|
-
return { exists: false, reason: 'no open session' };
|
|
179
|
-
}
|
|
180
|
-
return { exists: true };
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
return { exists: false, reason: 'validation error' };
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
async deleteSession(jids) {
|
|
187
|
-
if (!jids.length)
|
|
188
|
-
return;
|
|
189
|
-
// Convert JIDs to signal addresses and prepare for bulk deletion
|
|
190
|
-
const sessionUpdates = {};
|
|
191
|
-
jids.forEach(jid => {
|
|
192
|
-
const addr = jidToSignalProtocolAddress(jid);
|
|
193
|
-
sessionUpdates[addr.toString()] = null;
|
|
194
|
-
});
|
|
195
|
-
// Single transaction for all deletions
|
|
196
|
-
return parsedKeys.transaction(async () => {
|
|
197
|
-
await auth.keys.set({ session: sessionUpdates });
|
|
198
|
-
}, `delete-${jids.length}-sessions`);
|
|
199
|
-
},
|
|
200
|
-
close() {
|
|
201
|
-
migratedSessionCache.clear();
|
|
202
|
-
lidMapping.close();
|
|
203
|
-
},
|
|
204
|
-
async migrateSession(fromJid, toJid) {
|
|
205
|
-
// TODO: use usync to handle this entire mess
|
|
206
|
-
if (!fromJid || (!isLidUser(toJid) && !isHostedLidUser(toJid)))
|
|
207
|
-
return { migrated: 0, skipped: 0, total: 0 };
|
|
208
|
-
// Only support PN to LID migration
|
|
209
|
-
if (!isPnUser(fromJid) && !isHostedPnUser(fromJid)) {
|
|
210
|
-
return { migrated: 0, skipped: 0, total: 1 };
|
|
211
|
-
}
|
|
212
|
-
const { user } = jidDecode(fromJid);
|
|
213
|
-
logger.debug({ fromJid }, 'bulk device migration - loading all user devices');
|
|
214
|
-
// Get user's device list from storage
|
|
215
|
-
const { [user]: userDevices } = await parsedKeys.get('device-list', [user]);
|
|
216
|
-
if (!userDevices) {
|
|
217
|
-
return { migrated: 0, skipped: 0, total: 0 };
|
|
218
|
-
}
|
|
219
|
-
const { device: fromDevice } = jidDecode(fromJid);
|
|
220
|
-
const fromDeviceStr = fromDevice?.toString() || '0';
|
|
221
|
-
if (!userDevices.includes(fromDeviceStr)) {
|
|
222
|
-
userDevices.push(fromDeviceStr);
|
|
223
|
-
}
|
|
224
|
-
// Filter out cached devices before database fetch
|
|
225
|
-
const uncachedDevices = userDevices.filter(device => {
|
|
226
|
-
const deviceKey = `${user}.${device}`;
|
|
227
|
-
return !migratedSessionCache.has(deviceKey);
|
|
228
|
-
});
|
|
229
|
-
// Bulk check session existence only for uncached devices
|
|
230
|
-
const deviceSessionKeys = uncachedDevices.map(device => `${user}.${device}`);
|
|
231
|
-
const existingSessions = await parsedKeys.get('session', deviceSessionKeys);
|
|
232
|
-
// Step 3: Convert existing sessions to JIDs (only migrate sessions that exist)
|
|
233
|
-
const deviceJids = [];
|
|
234
|
-
for (const [sessionKey, sessionData] of Object.entries(existingSessions)) {
|
|
235
|
-
if (sessionData) {
|
|
236
|
-
// Session exists in storage
|
|
237
|
-
const deviceStr = sessionKey.split('.')[1];
|
|
238
|
-
if (!deviceStr)
|
|
239
|
-
continue;
|
|
240
|
-
const deviceNum = parseInt(deviceStr);
|
|
241
|
-
let jid = deviceNum === 0 ? `${user}@s.whatsapp.net` : `${user}:${deviceNum}@s.whatsapp.net`;
|
|
242
|
-
if (deviceNum === 99) {
|
|
243
|
-
jid = `${user}:99@hosted`;
|
|
244
|
-
}
|
|
245
|
-
deviceJids.push(jid);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
logger.debug({
|
|
249
|
-
fromJid,
|
|
250
|
-
totalDevices: userDevices.length,
|
|
251
|
-
devicesWithSessions: deviceJids.length,
|
|
252
|
-
devices: deviceJids
|
|
253
|
-
}, 'bulk device migration complete - all user devices processed');
|
|
254
|
-
// Single transaction for all migrations
|
|
255
|
-
return parsedKeys.transaction(async () => {
|
|
256
|
-
const migrationOps = deviceJids.map(jid => {
|
|
257
|
-
const lidWithDevice = transferDevice(jid, toJid);
|
|
258
|
-
const fromDecoded = jidDecode(jid);
|
|
259
|
-
const toDecoded = jidDecode(lidWithDevice);
|
|
260
|
-
return {
|
|
261
|
-
fromJid: jid,
|
|
262
|
-
toJid: lidWithDevice,
|
|
263
|
-
pnUser: fromDecoded.user,
|
|
264
|
-
lidUser: toDecoded.user,
|
|
265
|
-
deviceId: fromDecoded.device || 0,
|
|
266
|
-
fromAddr: jidToSignalProtocolAddress(jid),
|
|
267
|
-
toAddr: jidToSignalProtocolAddress(lidWithDevice)
|
|
268
|
-
};
|
|
269
|
-
});
|
|
270
|
-
const totalOps = migrationOps.length;
|
|
271
|
-
let migratedCount = 0;
|
|
272
|
-
// Bulk fetch PN sessions - already exist (verified during device discovery)
|
|
273
|
-
const pnAddrStrings = Array.from(new Set(migrationOps.map(op => op.fromAddr.toString())));
|
|
274
|
-
const pnSessions = await parsedKeys.get('session', pnAddrStrings);
|
|
275
|
-
// Prepare bulk session updates (PN → LID migration + deletion)
|
|
276
|
-
const sessionUpdates = {};
|
|
277
|
-
for (const op of migrationOps) {
|
|
278
|
-
const pnAddrStr = op.fromAddr.toString();
|
|
279
|
-
const lidAddrStr = op.toAddr.toString();
|
|
280
|
-
const pnSession = pnSessions[pnAddrStr];
|
|
281
|
-
if (pnSession) {
|
|
282
|
-
// Session exists (guaranteed from device discovery)
|
|
283
|
-
const fromSession = libsignal.SessionRecord.deserialize(pnSession);
|
|
284
|
-
if (fromSession.haveOpenSession()) {
|
|
285
|
-
// Queue for bulk update: copy to LID, delete from PN
|
|
286
|
-
sessionUpdates[lidAddrStr] = fromSession.serialize();
|
|
287
|
-
sessionUpdates[pnAddrStr] = null;
|
|
288
|
-
migratedCount++;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
// Single bulk session update for all migrations
|
|
293
|
-
if (Object.keys(sessionUpdates).length > 0) {
|
|
294
|
-
await parsedKeys.set({ session: sessionUpdates });
|
|
295
|
-
logger.debug({ migratedSessions: migratedCount }, 'bulk session migration complete');
|
|
296
|
-
// Cache device-level migrations
|
|
297
|
-
for (const op of migrationOps) {
|
|
298
|
-
if (sessionUpdates[op.toAddr.toString()]) {
|
|
299
|
-
const deviceKey = `${op.pnUser}.${op.deviceId}`;
|
|
300
|
-
migratedSessionCache.set(deviceKey, true);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
const skippedCount = totalOps - migratedCount;
|
|
305
|
-
return { migrated: migratedCount, skipped: skippedCount, total: totalOps };
|
|
306
|
-
}, `migrate-${deviceJids.length}-sessions-${jidDecode(toJid)?.user}`);
|
|
307
|
-
}
|
|
308
92
|
};
|
|
309
|
-
return repository;
|
|
310
93
|
}
|
|
94
|
+
exports.makeLibSignalRepository = makeLibSignalRepository;
|
|
311
95
|
const jidToSignalProtocolAddress = (jid) => {
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
if (!user) {
|
|
315
|
-
throw new Error(`JID decoded but user is empty: "${jid}" -> user: "${user}", server: "${server}", device: ${device}`);
|
|
316
|
-
}
|
|
317
|
-
const signalUser = domainType !== WAJIDDomains.WHATSAPP ? `${user}_${domainType}` : user;
|
|
318
|
-
const finalDevice = device || 0;
|
|
319
|
-
if (device === 99 && decoded.server !== 'hosted' && decoded.server !== 'hosted.lid') {
|
|
320
|
-
throw new Error('Unexpected non-hosted device JID with device 99. This ID seems invalid. ID:' + jid);
|
|
321
|
-
}
|
|
322
|
-
return new libsignal.ProtocolAddress(signalUser, finalDevice);
|
|
96
|
+
const { user, device } = (0, WABinary_1.jidDecode)(jid);
|
|
97
|
+
return new libsignal.ProtocolAddress(user, device || 0);
|
|
323
98
|
};
|
|
324
99
|
const jidToSignalSenderKeyName = (group, user) => {
|
|
325
|
-
return new SenderKeyName(group, jidToSignalProtocolAddress(user));
|
|
100
|
+
return new WASignalGroup_1.SenderKeyName(group, jidToSignalProtocolAddress(user)).toString();
|
|
326
101
|
};
|
|
327
|
-
function signalStorage({ creds, keys }
|
|
328
|
-
// Shared function to resolve PN signal address to LID if mapping exists
|
|
329
|
-
const resolveLIDSignalAddress = async (id) => {
|
|
330
|
-
if (id.includes('.')) {
|
|
331
|
-
const [deviceId, device] = id.split('.');
|
|
332
|
-
const [user, domainType_] = deviceId.split('_');
|
|
333
|
-
const domainType = parseInt(domainType_ || '0');
|
|
334
|
-
if (domainType === WAJIDDomains.LID || domainType === WAJIDDomains.HOSTED_LID)
|
|
335
|
-
return id;
|
|
336
|
-
const pnJid = `${user}${device !== '0' ? `:${device}` : ''}@${domainType === WAJIDDomains.HOSTED ? 'hosted' : 's.whatsapp.net'}`;
|
|
337
|
-
const lidForPN = await lidMapping.getLIDForPN(pnJid);
|
|
338
|
-
if (lidForPN) {
|
|
339
|
-
const lidAddr = jidToSignalProtocolAddress(lidForPN);
|
|
340
|
-
return lidAddr.toString();
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return id;
|
|
344
|
-
};
|
|
102
|
+
function signalStorage({ creds, keys }) {
|
|
345
103
|
return {
|
|
346
104
|
loadSession: async (id) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (sess) {
|
|
351
|
-
return libsignal.SessionRecord.deserialize(sess);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
catch (e) {
|
|
355
|
-
return null;
|
|
105
|
+
const { [id]: sess } = await keys.get('session', [id]);
|
|
106
|
+
if (sess) {
|
|
107
|
+
return libsignal.SessionRecord.deserialize(sess);
|
|
356
108
|
}
|
|
357
|
-
return null;
|
|
358
109
|
},
|
|
359
110
|
storeSession: async (id, session) => {
|
|
360
|
-
|
|
361
|
-
await keys.set({ session: { [wireJid]: session.serialize() } });
|
|
111
|
+
await keys.set({ 'session': { [id]: session.serialize() } });
|
|
362
112
|
},
|
|
363
113
|
isTrustedIdentity: () => {
|
|
364
|
-
return true;
|
|
365
|
-
},
|
|
366
|
-
loadIdentityKey: async (id) => {
|
|
367
|
-
const wireJid = await resolveLIDSignalAddress(id);
|
|
368
|
-
const { [wireJid]: key } = await keys.get('identity-key', [wireJid]);
|
|
369
|
-
return key || undefined;
|
|
370
|
-
},
|
|
371
|
-
saveIdentity: async (id, identityKey) => {
|
|
372
|
-
const wireJid = await resolveLIDSignalAddress(id);
|
|
373
|
-
const { [wireJid]: existingKey } = await keys.get('identity-key', [wireJid]);
|
|
374
|
-
const keysMatch = existingKey?.length === identityKey.length && existingKey.every((byte, i) => byte === identityKey[i]);
|
|
375
|
-
if (existingKey && !keysMatch) {
|
|
376
|
-
// Identity changed - clear session and update key
|
|
377
|
-
await keys.set({
|
|
378
|
-
session: { [wireJid]: null },
|
|
379
|
-
'identity-key': { [wireJid]: identityKey }
|
|
380
|
-
});
|
|
381
|
-
return true;
|
|
382
|
-
}
|
|
383
|
-
if (!existingKey) {
|
|
384
|
-
// New contact - Trust on First Use (TOFU)
|
|
385
|
-
await keys.set({ 'identity-key': { [wireJid]: identityKey } });
|
|
386
|
-
return true;
|
|
387
|
-
}
|
|
388
|
-
return false;
|
|
114
|
+
return true;
|
|
389
115
|
},
|
|
390
116
|
loadPreKey: async (id) => {
|
|
391
117
|
const keyId = id.toString();
|
|
@@ -405,27 +131,22 @@ function signalStorage({ creds, keys }, lidMapping) {
|
|
|
405
131
|
pubKey: Buffer.from(key.keyPair.public)
|
|
406
132
|
};
|
|
407
133
|
},
|
|
408
|
-
loadSenderKey: async (
|
|
409
|
-
const keyId = senderKeyName.toString();
|
|
134
|
+
loadSenderKey: async (keyId) => {
|
|
410
135
|
const { [keyId]: key } = await keys.get('sender-key', [keyId]);
|
|
411
136
|
if (key) {
|
|
412
|
-
return SenderKeyRecord
|
|
137
|
+
return new WASignalGroup_1.SenderKeyRecord(key);
|
|
413
138
|
}
|
|
414
|
-
return new SenderKeyRecord();
|
|
415
139
|
},
|
|
416
|
-
storeSenderKey: async (
|
|
417
|
-
|
|
418
|
-
const serialized = JSON.stringify(key.serialize());
|
|
419
|
-
await keys.set({ 'sender-key': { [keyId]: Buffer.from(serialized, 'utf-8') } });
|
|
140
|
+
storeSenderKey: async (keyId, key) => {
|
|
141
|
+
await keys.set({ 'sender-key': { [keyId]: key.serialize() } });
|
|
420
142
|
},
|
|
421
|
-
getOurRegistrationId: () => creds.registrationId,
|
|
143
|
+
getOurRegistrationId: () => (creds.registrationId),
|
|
422
144
|
getOurIdentity: () => {
|
|
423
145
|
const { signedIdentityKey } = creds;
|
|
424
146
|
return {
|
|
425
147
|
privKey: Buffer.from(signedIdentityKey.private),
|
|
426
|
-
pubKey:
|
|
148
|
+
pubKey: (0, Utils_1.generateSignalPubKey)(signedIdentityKey.public),
|
|
427
149
|
};
|
|
428
150
|
}
|
|
429
151
|
};
|
|
430
152
|
}
|
|
431
|
-
//# sourceMappingURL=libsignal.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import { EventEmitter } from 'events';
|
|
2
4
|
import { URL } from 'url';
|
|
3
|
-
import
|
|
5
|
+
import { SocketConfig } from '../../Types';
|
|
4
6
|
export declare abstract class AbstractSocketClient extends EventEmitter {
|
|
5
7
|
url: URL;
|
|
6
8
|
config: SocketConfig;
|
|
@@ -9,8 +11,7 @@ export declare abstract class AbstractSocketClient extends EventEmitter {
|
|
|
9
11
|
abstract get isClosing(): boolean;
|
|
10
12
|
abstract get isConnecting(): boolean;
|
|
11
13
|
constructor(url: URL, config: SocketConfig);
|
|
12
|
-
abstract connect(): void
|
|
13
|
-
abstract close(): void
|
|
14
|
+
abstract connect(): Promise<void>;
|
|
15
|
+
abstract close(): Promise<void>;
|
|
14
16
|
abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
|
15
17
|
}
|
|
16
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractSocketClient = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
class AbstractSocketClient extends events_1.EventEmitter {
|
|
6
|
+
constructor(url, config) {
|
|
7
|
+
super();
|
|
8
|
+
this.url = url;
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.setMaxListeners(0);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.AbstractSocketClient = AbstractSocketClient;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
|
|
1
|
+
export * from './abstract-socket-client';
|
|
2
|
+
export * from './mobile-socket-client';
|
|
3
|
+
export * from './web-socket-client';
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./abstract-socket-client"), exports);
|
|
18
|
+
__exportStar(require("./mobile-socket-client"), exports);
|
|
19
|
+
__exportStar(require("./web-socket-client"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Socket } from 'net';
|
|
3
|
+
import { AbstractSocketClient } from './abstract-socket-client';
|
|
4
|
+
export declare class MobileSocketClient extends AbstractSocketClient {
|
|
5
|
+
protected socket: Socket | null;
|
|
6
|
+
get isOpen(): boolean;
|
|
7
|
+
get isClosed(): boolean;
|
|
8
|
+
get isClosing(): boolean;
|
|
9
|
+
get isConnecting(): boolean;
|
|
10
|
+
connect(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MobileSocketClient = void 0;
|
|
4
|
+
const net_1 = require("net");
|
|
5
|
+
const abstract_socket_client_1 = require("./abstract-socket-client");
|
|
6
|
+
class MobileSocketClient extends abstract_socket_client_1.AbstractSocketClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.socket = null;
|
|
10
|
+
}
|
|
11
|
+
get isOpen() {
|
|
12
|
+
var _a;
|
|
13
|
+
return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'open';
|
|
14
|
+
}
|
|
15
|
+
get isClosed() {
|
|
16
|
+
var _a;
|
|
17
|
+
return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'closed';
|
|
18
|
+
}
|
|
19
|
+
get isClosing() {
|
|
20
|
+
var _a;
|
|
21
|
+
return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'closed';
|
|
22
|
+
}
|
|
23
|
+
get isConnecting() {
|
|
24
|
+
var _a;
|
|
25
|
+
return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'opening';
|
|
26
|
+
}
|
|
27
|
+
async connect() {
|
|
28
|
+
var _a;
|
|
29
|
+
if (this.socket) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (this.config.agent) {
|
|
33
|
+
throw new Error('There are not support for proxy agent for mobile connection');
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.socket = (0, net_1.connect)({
|
|
37
|
+
host: this.url.hostname,
|
|
38
|
+
port: Number(this.url.port) || 443
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
this.socket.setMaxListeners(0);
|
|
42
|
+
const events = ['close', 'connect', 'data', 'drain', 'end', 'error', 'lookup', 'ready', 'timeout'];
|
|
43
|
+
for (const event of events) {
|
|
44
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.on(event, (...args) => this.emit(event, ...args));
|
|
45
|
+
}
|
|
46
|
+
this.socket.on('data', (...args) => this.emit('message', ...args));
|
|
47
|
+
this.socket.on('ready', (...args) => this.emit('open', ...args));
|
|
48
|
+
}
|
|
49
|
+
async close() {
|
|
50
|
+
if (!this.socket) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
return new Promise(resolve => {
|
|
54
|
+
this.socket.end(resolve);
|
|
55
|
+
this.socket = null;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
send(str, cb) {
|
|
59
|
+
if (this.socket === null) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return this.socket.write(str, undefined, cb);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.MobileSocketClient = MobileSocketClient;
|