@neelegirl/baileys 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +195 -195
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +478 -1153
- package/WAProto/fix-imports.js +29 -0
- package/WAProto/index.d.ts +2645 -51971
- package/WAProto/index.js +48649 -154035
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.d.ts +62 -78
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +115 -149
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/{WASignalGroup → Group}/group-session-builder.d.ts +11 -13
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/{WASignalGroup → Group}/group_cipher.js +41 -70
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/{WASignalGroup/sender_message_key.js → Group/sender-message-key.js} +26 -39
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/libsignal.d.ts +5 -8
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +342 -391
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +23 -28
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +171 -184
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -22
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +8 -15
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +24 -36
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +178 -177
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +81 -120
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +93 -92
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +462 -618
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +244 -223
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +431 -433
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts +118 -110
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +148 -181
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +222 -182
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +12 -18
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +165 -166
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +753 -1031
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +161 -157
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +564 -1396
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +3 -2
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +42 -47
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +139 -137
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +181 -295
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +42 -36
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +487 -557
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Types/Auth.d.ts +87 -97
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -3
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -3
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +13 -13
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -3
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +77 -97
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -9
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +10 -9
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -3
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +151 -175
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -3
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +49 -48
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -3
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +13 -14
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +24 -30
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +15 -20
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +6 -12
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +231 -412
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +11 -19
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Newsletter.d.ts +130 -104
- package/lib/Types/Newsletter.d.ts.map +1 -0
- package/lib/Types/Newsletter.js +31 -40
- package/lib/Types/Newsletter.js.map +1 -0
- package/lib/Types/Product.d.ts +58 -71
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -3
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Signal.d.ts +60 -82
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -3
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +73 -81
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +17 -19
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +13 -14
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -3
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +47 -62
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +26 -50
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/auth-utils.d.ts +19 -21
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +257 -528
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/baileys-event-stream.d.ts +17 -18
- package/lib/Utils/baileys-event-stream.d.ts.map +1 -0
- package/lib/Utils/baileys-event-stream.js +56 -70
- package/lib/Utils/baileys-event-stream.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +23 -29
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +231 -255
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +70 -82
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +763 -809
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +41 -56
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +142 -189
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -53
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +279 -323
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +34 -39
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +548 -595
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +90 -131
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +381 -630
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +19 -23
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +84 -104
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/index.d.ts +20 -20
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +19 -40
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +21 -23
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +85 -120
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +12 -13
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -7
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +13 -14
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +48 -58
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +8 -9
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +40 -49
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-retry-manager.d.ts +82 -88
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +149 -160
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +114 -135
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +663 -869
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +76 -105
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +820 -1745
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +20 -21
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +147 -165
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +42 -49
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +413 -427
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/signal.d.ts +34 -42
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +159 -166
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -18
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -238
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +11 -13
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +195 -220
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +28 -30
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1301 -1316
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +7 -9
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +238 -288
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +216 -265
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +15 -28
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +102 -142
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -5
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +6 -25
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +48 -58
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +96 -104
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +19 -22
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -3
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -16
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +10 -17
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +40 -47
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +22853 -15371
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +150 -164
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -3
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -23
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +12 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +19 -22
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +18 -26
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +11 -12
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -20
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +11 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +16 -24
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -6
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +5 -26
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -28
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +64 -62
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +11 -10
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +12 -19
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -3
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -23
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +12 -13
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -33
- package/lib/index.js.map +1 -0
- package/package.json +99 -96
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/WASignalGroup/GroupProtocol.js +0 -1909
- package/lib/Signal/WASignalGroup/ciphertext-message.d.ts +0 -9
- package/lib/Signal/WASignalGroup/ciphertext-message.js +0 -19
- package/lib/Signal/WASignalGroup/ciphertext_message.js +0 -16
- package/lib/Signal/WASignalGroup/generate-proto.sh +0 -1
- package/lib/Signal/WASignalGroup/group-session-builder.js +0 -72
- package/lib/Signal/WASignalGroup/group.proto +0 -42
- package/lib/Signal/WASignalGroup/group_cipher.d.ts +0 -19
- package/lib/Signal/WASignalGroup/group_session_builder.js +0 -46
- package/lib/Signal/WASignalGroup/index.d.ts +0 -11
- package/lib/Signal/WASignalGroup/index.js +0 -61
- package/lib/Signal/WASignalGroup/keyhelper.d.ts +0 -16
- package/lib/Signal/WASignalGroup/keyhelper.js +0 -66
- package/lib/Signal/WASignalGroup/protobufs.js +0 -3
- package/lib/Signal/WASignalGroup/queue_job.js +0 -69
- package/lib/Signal/WASignalGroup/readme.md +0 -6
- package/lib/Signal/WASignalGroup/sender-chain-key.d.ts +0 -14
- package/lib/Signal/WASignalGroup/sender-chain-key.js +0 -47
- package/lib/Signal/WASignalGroup/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/WASignalGroup/sender-key-distribution-message.js +0 -71
- package/lib/Signal/WASignalGroup/sender-key-message.d.ts +0 -19
- package/lib/Signal/WASignalGroup/sender-key-message.js +0 -73
- package/lib/Signal/WASignalGroup/sender-key-name.d.ts +0 -19
- package/lib/Signal/WASignalGroup/sender-key-name.js +0 -59
- package/lib/Signal/WASignalGroup/sender-key-record.d.ts +0 -32
- package/lib/Signal/WASignalGroup/sender-key-record.js +0 -58
- package/lib/Signal/WASignalGroup/sender-key-state.d.ts +0 -44
- package/lib/Signal/WASignalGroup/sender-key-state.js +0 -147
- package/lib/Signal/WASignalGroup/sender-message-key.d.ts +0 -11
- package/lib/Signal/WASignalGroup/sender-message-key.js +0 -33
- package/lib/Signal/WASignalGroup/sender_chain_key.js +0 -50
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/lib/Signal/WASignalGroup/sender_key_message.js +0 -92
- package/lib/Signal/WASignalGroup/sender_key_name.js +0 -70
- package/lib/Signal/WASignalGroup/sender_key_record.js +0 -56
- package/lib/Signal/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -83
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/index.js +0 -24
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -90
- package/lib/Store/make-in-memory-store.d.ts +0 -123
- package/lib/Store/make-in-memory-store.js +0 -429
- package/lib/Store/make-ordered-dictionary.d.ts +0 -12
- package/lib/Store/make-ordered-dictionary.js +0 -86
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Store/object-repository.js +0 -31
- package/lib/Types/Bussiness.d.ts +0 -28
- package/lib/Types/MexUpdates.d.ts +0 -9
- package/lib/Types/MexUpdates.js +0 -18
- package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-mongo-file-auth-state.js +0 -84
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.js +0 -80
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -69
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -38
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
|
-
|
|
4
|
-
const curve_1 = require("@neelegirl/libsignal/src/curve")
|
|
5
|
-
const WAProto_1 = require("../../../WAProto")
|
|
6
|
-
const ciphertext_message_1 = require("./ciphertext-message")
|
|
7
|
-
|
|
8
|
-
class SenderKeyMessage extends ciphertext_message_1.CiphertextMessage {
|
|
9
|
-
constructor(keyId, iteration, ciphertext, signatureKey, serialized) {
|
|
10
|
-
super()
|
|
11
|
-
this.SIGNATURE_LENGTH = 64
|
|
12
|
-
if (serialized) {
|
|
13
|
-
const version = serialized[0]
|
|
14
|
-
const message = serialized.slice(1, serialized.length - this.SIGNATURE_LENGTH)
|
|
15
|
-
const signature = serialized.slice(-1 * this.SIGNATURE_LENGTH)
|
|
16
|
-
const senderKeyMessage = WAProto_1.proto.SenderKeyMessage.decode(message).toJSON()
|
|
17
|
-
this.serialized = serialized
|
|
18
|
-
this.messageVersion = (version & 0xff) >> 4
|
|
19
|
-
this.keyId = senderKeyMessage.id
|
|
20
|
-
this.iteration = senderKeyMessage.iteration
|
|
21
|
-
this.ciphertext =
|
|
22
|
-
typeof senderKeyMessage.ciphertext === 'string'
|
|
23
|
-
? Buffer.from(senderKeyMessage.ciphertext, 'base64')
|
|
24
|
-
: senderKeyMessage.ciphertext
|
|
25
|
-
this.signature = signature
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const version = (((this.CURRENT_VERSION << 4) | this.CURRENT_VERSION) & 0xff) % 256
|
|
29
|
-
const ciphertextBuffer = Buffer.from(ciphertext)
|
|
30
|
-
const message = WAProto_1.proto.SenderKeyMessage.encode(WAProto_1.proto.SenderKeyMessage.create({
|
|
31
|
-
id: keyId,
|
|
32
|
-
iteration: iteration,
|
|
33
|
-
ciphertext: ciphertextBuffer
|
|
34
|
-
})).finish()
|
|
35
|
-
const signature = this.getSignature(signatureKey, Buffer.concat([Buffer.from([version]), message]))
|
|
36
|
-
this.serialized = Buffer.concat([Buffer.from([version]), message, Buffer.from(signature)])
|
|
37
|
-
this.messageVersion = this.CURRENT_VERSION
|
|
38
|
-
this.keyId = keyId
|
|
39
|
-
this.iteration = iteration
|
|
40
|
-
this.ciphertext = ciphertextBuffer
|
|
41
|
-
this.signature = signature
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
getKeyId() {
|
|
45
|
-
return this.keyId
|
|
46
|
-
}
|
|
47
|
-
getIteration() {
|
|
48
|
-
return this.iteration
|
|
49
|
-
}
|
|
50
|
-
getCipherText() {
|
|
51
|
-
return this.ciphertext
|
|
52
|
-
}
|
|
53
|
-
verifySignature(signatureKey) {
|
|
54
|
-
const part1 = this.serialized.slice(0, this.serialized.length - this.SIGNATURE_LENGTH)
|
|
55
|
-
const part2 = this.serialized.slice(-1 * this.SIGNATURE_LENGTH)
|
|
56
|
-
const res = curve_1.verifySignature(signatureKey, part1, part2)
|
|
57
|
-
if (!res)
|
|
58
|
-
throw new Error('Invalid signature!')
|
|
59
|
-
}
|
|
60
|
-
getSignature(signatureKey, serialized) {
|
|
61
|
-
return Buffer.from(curve_1.calculateSignature(signatureKey, serialized))
|
|
62
|
-
}
|
|
63
|
-
serialize() {
|
|
64
|
-
return this.serialized
|
|
65
|
-
}
|
|
66
|
-
getType() {
|
|
67
|
-
return 4
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = {
|
|
72
|
-
SenderKeyMessage
|
|
73
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
interface Sender {
|
|
2
|
-
id: string
|
|
3
|
-
deviceId: number
|
|
4
|
-
toString(): string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export declare class SenderKeyName {
|
|
8
|
-
private readonly groupId
|
|
9
|
-
private readonly sender
|
|
10
|
-
constructor(groupId: string, sender: Sender)
|
|
11
|
-
getGroupId(): string
|
|
12
|
-
getSender(): Sender
|
|
13
|
-
serialize(): string
|
|
14
|
-
toString(): string
|
|
15
|
-
equals(other: SenderKeyName | null): boolean
|
|
16
|
-
hashCode(): number
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
-
|
|
5
|
-
function isNull(str) {
|
|
6
|
-
return str === null || str === ''
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function intValue(num) {
|
|
10
|
-
const MAX_VALUE = 0x7fffffff
|
|
11
|
-
const MIN_VALUE = -0x80000000
|
|
12
|
-
if (num > MAX_VALUE || num < MIN_VALUE) {
|
|
13
|
-
return num & 0xffffffff
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return num
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function hashCode(strKey) {
|
|
20
|
-
let hash = 0
|
|
21
|
-
if (!isNull(strKey)) {
|
|
22
|
-
for (let i = 0; i < strKey.length; i++) {
|
|
23
|
-
hash = hash * 31 + strKey.charCodeAt(i)
|
|
24
|
-
hash = intValue(hash)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return hash
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class SenderKeyName {
|
|
31
|
-
constructor(groupId, sender) {
|
|
32
|
-
this.groupId = groupId
|
|
33
|
-
this.sender = sender
|
|
34
|
-
}
|
|
35
|
-
getGroupId() {
|
|
36
|
-
return this.groupId
|
|
37
|
-
}
|
|
38
|
-
getSender() {
|
|
39
|
-
return this.sender
|
|
40
|
-
}
|
|
41
|
-
serialize() {
|
|
42
|
-
return `${this.groupId}::${this.sender.id}::${this.sender.deviceId}`
|
|
43
|
-
}
|
|
44
|
-
toString() {
|
|
45
|
-
return this.serialize()
|
|
46
|
-
}
|
|
47
|
-
equals(other) {
|
|
48
|
-
if (other === null)
|
|
49
|
-
return false
|
|
50
|
-
return this.groupId === other.groupId && this.sender.toString() === other.sender.toString()
|
|
51
|
-
}
|
|
52
|
-
hashCode() {
|
|
53
|
-
return hashCode(this.groupId) ^ hashCode(this.sender.toString())
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = {
|
|
58
|
-
SenderKeyName
|
|
59
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { SenderKeyState } from './sender-key-state'
|
|
2
|
-
|
|
3
|
-
export interface SenderKeyStateStructure {
|
|
4
|
-
senderKeyId: number
|
|
5
|
-
senderChainKey: {
|
|
6
|
-
iteration: number
|
|
7
|
-
seed: Uint8Array
|
|
8
|
-
}
|
|
9
|
-
senderSigningKey: {
|
|
10
|
-
public: Uint8Array
|
|
11
|
-
private?: Uint8Array
|
|
12
|
-
}
|
|
13
|
-
senderMessageKeys: Array<{
|
|
14
|
-
iteration: number
|
|
15
|
-
seed: Uint8Array
|
|
16
|
-
}>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export declare class SenderKeyRecord {
|
|
20
|
-
private readonly MAX_STATES
|
|
21
|
-
private readonly senderKeyStates
|
|
22
|
-
constructor(serialized?: SenderKeyStateStructure[])
|
|
23
|
-
isEmpty(): boolean
|
|
24
|
-
getSenderKeyState(keyId?: number): SenderKeyState | undefined
|
|
25
|
-
addSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, signatureKey: Uint8Array): void
|
|
26
|
-
setSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, keyPair: {
|
|
27
|
-
public: Uint8Array
|
|
28
|
-
private: Uint8Array
|
|
29
|
-
}): void
|
|
30
|
-
serialize(): SenderKeyStateStructure[]
|
|
31
|
-
static deserialize(data: Uint8Array | string | SenderKeyStateStructure[]): SenderKeyRecord
|
|
32
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
-
|
|
5
|
-
const generics_1 = require("../../Utils/generics")
|
|
6
|
-
const sender_key_state_1 = require("./sender-key-state")
|
|
7
|
-
|
|
8
|
-
class SenderKeyRecord {
|
|
9
|
-
constructor(serialized) {
|
|
10
|
-
this.MAX_STATES = 5
|
|
11
|
-
this.senderKeyStates = []
|
|
12
|
-
if (serialized) {
|
|
13
|
-
for (const structure of serialized) {
|
|
14
|
-
this.senderKeyStates.push(new sender_key_state_1.SenderKeyState(null, null, null, null, null, null, structure))
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
isEmpty() {
|
|
19
|
-
return this.senderKeyStates.length === 0
|
|
20
|
-
}
|
|
21
|
-
getSenderKeyState(keyId) {
|
|
22
|
-
if (keyId === undefined && this.senderKeyStates.length) {
|
|
23
|
-
return this.senderKeyStates[this.senderKeyStates.length - 1]
|
|
24
|
-
}
|
|
25
|
-
return this.senderKeyStates.find(state => state.getKeyId() === keyId)
|
|
26
|
-
}
|
|
27
|
-
addSenderKeyState(id, iteration, chainKey, signatureKey) {
|
|
28
|
-
this.senderKeyStates.push(new sender_key_state_1.SenderKeyState(id, iteration, chainKey, null, signatureKey))
|
|
29
|
-
if (this.senderKeyStates.length > this.MAX_STATES) {
|
|
30
|
-
this.senderKeyStates.shift()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
setSenderKeyState(id, iteration, chainKey, keyPair) {
|
|
34
|
-
this.senderKeyStates.length = 0
|
|
35
|
-
this.senderKeyStates.push(new sender_key_state_1.SenderKeyState(id, iteration, chainKey, keyPair))
|
|
36
|
-
}
|
|
37
|
-
serialize() {
|
|
38
|
-
return this.senderKeyStates.map(state => state.getStructure())
|
|
39
|
-
}
|
|
40
|
-
static deserialize(data) {
|
|
41
|
-
let parsed
|
|
42
|
-
if (typeof data === 'string') {
|
|
43
|
-
parsed = JSON.parse(data, generics_1.BufferJSON.reviver)
|
|
44
|
-
}
|
|
45
|
-
else if (data instanceof Uint8Array) {
|
|
46
|
-
const str = Buffer.from(data).toString('utf-8')
|
|
47
|
-
parsed = JSON.parse(str, generics_1.BufferJSON.reviver)
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
parsed = data
|
|
51
|
-
}
|
|
52
|
-
return new SenderKeyRecord(parsed)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = {
|
|
57
|
-
SenderKeyRecord
|
|
58
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SenderChainKey } from './sender-chain-key'
|
|
2
|
-
import { SenderMessageKey } from './sender-message-key'
|
|
3
|
-
|
|
4
|
-
interface SenderChainKeyStructure {
|
|
5
|
-
iteration: number
|
|
6
|
-
seed: Uint8Array
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface SenderSigningKeyStructure {
|
|
10
|
-
public: Uint8Array
|
|
11
|
-
private?: Uint8Array
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface SenderMessageKeyStructure {
|
|
15
|
-
iteration: number
|
|
16
|
-
seed: Uint8Array
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface SenderKeyStateStructure {
|
|
20
|
-
senderKeyId: number
|
|
21
|
-
senderChainKey: SenderChainKeyStructure
|
|
22
|
-
senderSigningKey: SenderSigningKeyStructure
|
|
23
|
-
senderMessageKeys: SenderMessageKeyStructure[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export declare class SenderKeyState {
|
|
27
|
-
private readonly MAX_MESSAGE_KEYS
|
|
28
|
-
private readonly senderKeyStateStructure
|
|
29
|
-
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKeyPair?: {
|
|
30
|
-
public: Uint8Array
|
|
31
|
-
private: Uint8Array
|
|
32
|
-
} | null, signatureKeyPublic?: Uint8Array | null, signatureKeyPrivate?: Uint8Array | null, senderKeyStateStructure?: SenderKeyStateStructure | null)
|
|
33
|
-
getKeyId(): number
|
|
34
|
-
getSenderChainKey(): SenderChainKey
|
|
35
|
-
setSenderChainKey(chainKey: SenderChainKey): void
|
|
36
|
-
getSigningKeyPublic(): Buffer
|
|
37
|
-
getSigningKeyPrivate(): Buffer | undefined
|
|
38
|
-
hasSenderMessageKey(iteration: number): boolean
|
|
39
|
-
addSenderMessageKey(senderMessageKey: SenderMessageKey): void
|
|
40
|
-
removeSenderMessageKey(iteration: number): SenderMessageKey | null
|
|
41
|
-
getStructure(): SenderKeyStateStructure
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export {}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
-
|
|
5
|
-
const sender_chain_key_1 = require("./sender-chain-key")
|
|
6
|
-
const sender_message_key_1 = require("./sender-message-key")
|
|
7
|
-
|
|
8
|
-
class SenderKeyState {
|
|
9
|
-
constructor(id, iteration, chainKey, signatureKeyPair, signatureKeyPublic, signatureKeyPrivate, senderKeyStateStructure) {
|
|
10
|
-
this.MAX_MESSAGE_KEYS = 2000
|
|
11
|
-
|
|
12
|
-
const toBuffer = (val) => {
|
|
13
|
-
if (!val)
|
|
14
|
-
return Buffer.alloc(0)
|
|
15
|
-
if (typeof val === 'string')
|
|
16
|
-
return Buffer.from(val, 'base64')
|
|
17
|
-
if (val instanceof Uint8Array || Array.isArray(val))
|
|
18
|
-
return Buffer.from(val)
|
|
19
|
-
return Buffer.alloc(0)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (senderKeyStateStructure) {
|
|
23
|
-
this.senderKeyStateStructure = {
|
|
24
|
-
...senderKeyStateStructure,
|
|
25
|
-
senderMessageKeys: Array.isArray(senderKeyStateStructure.senderMessageKeys)
|
|
26
|
-
? senderKeyStateStructure.senderMessageKeys
|
|
27
|
-
: []
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
if (signatureKeyPair) {
|
|
32
|
-
signatureKeyPublic = signatureKeyPair.public
|
|
33
|
-
signatureKeyPrivate = signatureKeyPair.private
|
|
34
|
-
}
|
|
35
|
-
chainKey = typeof chainKey === 'string' ? Buffer.from(chainKey, 'base64') : chainKey
|
|
36
|
-
|
|
37
|
-
const senderChainKeyStructure = {
|
|
38
|
-
iteration: iteration || 0,
|
|
39
|
-
seed: chainKey ? toBuffer(chainKey) : Buffer.alloc(0)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const signingKeyStructure = {
|
|
43
|
-
public: toBuffer(signatureKeyPublic),
|
|
44
|
-
private: signatureKeyPrivate ? toBuffer(signatureKeyPrivate) : undefined
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.senderKeyStateStructure = {
|
|
48
|
-
senderKeyId: id || 0,
|
|
49
|
-
senderChainKey: senderChainKeyStructure,
|
|
50
|
-
senderSigningKey: signingKeyStructure,
|
|
51
|
-
senderMessageKeys: []
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
getKeyId() {
|
|
56
|
-
return this.senderKeyStateStructure.senderKeyId
|
|
57
|
-
}
|
|
58
|
-
getSenderChainKey() {
|
|
59
|
-
return new sender_chain_key_1.SenderChainKey(this.senderKeyStateStructure.senderChainKey.iteration, this.senderKeyStateStructure.senderChainKey.seed)
|
|
60
|
-
}
|
|
61
|
-
setSenderChainKey(chainKey) {
|
|
62
|
-
this.senderKeyStateStructure.senderChainKey = {
|
|
63
|
-
iteration: chainKey.getIteration(),
|
|
64
|
-
seed: chainKey.getSeed()
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
getSigningKeyPublic() {
|
|
68
|
-
let key = this.senderKeyStateStructure.senderSigningKey.public
|
|
69
|
-
|
|
70
|
-
// normalize into Buffer
|
|
71
|
-
if (!Buffer.isBuffer(key)) {
|
|
72
|
-
if (key instanceof Uint8Array) {
|
|
73
|
-
key = Buffer.from(key)
|
|
74
|
-
}
|
|
75
|
-
else if (typeof key === 'string') {
|
|
76
|
-
key = Buffer.from(key, 'base64')
|
|
77
|
-
}
|
|
78
|
-
else if (key && typeof key === 'object') {
|
|
79
|
-
return Buffer.from(Object.values(key)) // temp fix // inspired by @MartinSchere 's #1741
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
key = Buffer.from(key || [])
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const publicKey = key
|
|
87
|
-
|
|
88
|
-
if (publicKey.length === 32) {
|
|
89
|
-
const fixed = Buffer.alloc(33)
|
|
90
|
-
|
|
91
|
-
fixed[0] = 0x05
|
|
92
|
-
publicKey.copy(fixed, 1)
|
|
93
|
-
|
|
94
|
-
return fixed
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return publicKey
|
|
98
|
-
}
|
|
99
|
-
getSigningKeyPrivate() {
|
|
100
|
-
const privateKey = this.senderKeyStateStructure.senderSigningKey.private
|
|
101
|
-
if (!privateKey) {
|
|
102
|
-
return undefined
|
|
103
|
-
}
|
|
104
|
-
if (Buffer.isBuffer(privateKey)) {
|
|
105
|
-
return privateKey
|
|
106
|
-
}
|
|
107
|
-
else if (privateKey instanceof Uint8Array) {
|
|
108
|
-
return Buffer.from(privateKey)
|
|
109
|
-
}
|
|
110
|
-
else if (privateKey && typeof privateKey === 'object') {
|
|
111
|
-
return Buffer.from(Object.values(privateKey)) // temp fix // inspired by @MartinSchere 's #1741
|
|
112
|
-
}
|
|
113
|
-
else if (typeof privateKey === 'string') {
|
|
114
|
-
return Buffer.from(privateKey, 'base64')
|
|
115
|
-
}
|
|
116
|
-
return Buffer.from(privateKey || [])
|
|
117
|
-
}
|
|
118
|
-
hasSenderMessageKey(iteration) {
|
|
119
|
-
return this.senderKeyStateStructure.senderMessageKeys.some(key => key.iteration === iteration)
|
|
120
|
-
}
|
|
121
|
-
addSenderMessageKey(senderMessageKey) {
|
|
122
|
-
this.senderKeyStateStructure.senderMessageKeys.push({
|
|
123
|
-
iteration: senderMessageKey.getIteration(),
|
|
124
|
-
seed: senderMessageKey.getSeed()
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
if (this.senderKeyStateStructure.senderMessageKeys.length > this.MAX_MESSAGE_KEYS) {
|
|
128
|
-
this.senderKeyStateStructure.senderMessageKeys.shift()
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
removeSenderMessageKey(iteration) {
|
|
132
|
-
const index = this.senderKeyStateStructure.senderMessageKeys.findIndex(key => key.iteration === iteration)
|
|
133
|
-
if (index !== -1) {
|
|
134
|
-
const messageKey = this.senderKeyStateStructure.senderMessageKeys[index]
|
|
135
|
-
this.senderKeyStateStructure.senderMessageKeys.splice(index, 1)
|
|
136
|
-
return new sender_message_key_1.SenderMessageKey(messageKey.iteration, messageKey.seed)
|
|
137
|
-
}
|
|
138
|
-
return null
|
|
139
|
-
}
|
|
140
|
-
getStructure() {
|
|
141
|
-
return this.senderKeyStateStructure
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
module.exports = {
|
|
146
|
-
SenderKeyState
|
|
147
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class SenderMessageKey {
|
|
2
|
-
private readonly iteration
|
|
3
|
-
private readonly iv
|
|
4
|
-
private readonly cipherKey
|
|
5
|
-
private readonly seed
|
|
6
|
-
constructor(iteration: number, seed: Uint8Array)
|
|
7
|
-
getIteration(): number
|
|
8
|
-
getIv(): Uint8Array
|
|
9
|
-
getCipherKey(): Uint8Array
|
|
10
|
-
getSeed(): Uint8Array
|
|
11
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
|
-
|
|
4
|
-
const crypto_1 = require("@neelegirl/libsignal/src/crypto")
|
|
5
|
-
|
|
6
|
-
class SenderMessageKey {
|
|
7
|
-
constructor(iteration, seed) {
|
|
8
|
-
const derivative = (0, crypto_1.deriveSecrets)(seed, Buffer.alloc(32), Buffer.from('WhisperGroup'))
|
|
9
|
-
const keys = new Uint8Array(32)
|
|
10
|
-
keys.set(new Uint8Array(derivative[0].slice(16)))
|
|
11
|
-
keys.set(new Uint8Array(derivative[1].slice(0, 16)), 16)
|
|
12
|
-
this.iv = Buffer.from(derivative[0].slice(0, 16))
|
|
13
|
-
this.cipherKey = Buffer.from(keys.buffer)
|
|
14
|
-
this.iteration = iteration
|
|
15
|
-
this.seed = seed
|
|
16
|
-
}
|
|
17
|
-
getIteration() {
|
|
18
|
-
return this.iteration
|
|
19
|
-
}
|
|
20
|
-
getIv() {
|
|
21
|
-
return this.iv
|
|
22
|
-
}
|
|
23
|
-
getCipherKey() {
|
|
24
|
-
return this.cipherKey
|
|
25
|
-
}
|
|
26
|
-
getSeed() {
|
|
27
|
-
return this.seed
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
SenderMessageKey
|
|
33
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const SenderMessageKey = require('./sender_message_key');
|
|
2
|
-
//const HKDF = require('./hkdf');
|
|
3
|
-
const crypto = require('@neelegirl/libsignal/src/crypto');
|
|
4
|
-
|
|
5
|
-
class SenderChainKey {
|
|
6
|
-
MESSAGE_KEY_SEED = Buffer.from([0x01]);
|
|
7
|
-
|
|
8
|
-
CHAIN_KEY_SEED = Buffer.from([0x02]);
|
|
9
|
-
|
|
10
|
-
iteration = 0;
|
|
11
|
-
|
|
12
|
-
chainKey = Buffer.alloc(0);
|
|
13
|
-
|
|
14
|
-
constructor(iteration, chainKey) {
|
|
15
|
-
this.iteration = iteration;
|
|
16
|
-
this.chainKey = chainKey;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getIteration() {
|
|
20
|
-
return this.iteration;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getSenderMessageKey() {
|
|
24
|
-
return new SenderMessageKey(
|
|
25
|
-
this.iteration,
|
|
26
|
-
this.getDerivative(this.MESSAGE_KEY_SEED, this.chainKey)
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getNext() {
|
|
31
|
-
return new SenderChainKey(
|
|
32
|
-
this.iteration + 1,
|
|
33
|
-
this.getDerivative(this.CHAIN_KEY_SEED, this.chainKey)
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getSeed() {
|
|
38
|
-
return typeof this.chainKey === 'string' ? Buffer.from(this.chainKey, 'base64') : this.chainKey;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getDerivative(seed, key) {
|
|
42
|
-
key = typeof key === 'string' ? Buffer.from(key, 'base64') : key;
|
|
43
|
-
const hash = crypto.calculateMAC(key, seed);
|
|
44
|
-
//const hash = new Hash().hmac_hash(key, seed, 'sha256', '');
|
|
45
|
-
|
|
46
|
-
return hash;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
module.exports = SenderChainKey;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
const CiphertextMessage = require('./ciphertext_message');
|
|
2
|
-
const protobufs = require('./protobufs');
|
|
3
|
-
|
|
4
|
-
class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
5
|
-
constructor(
|
|
6
|
-
id = null,
|
|
7
|
-
iteration = null,
|
|
8
|
-
chainKey = null,
|
|
9
|
-
signatureKey = null,
|
|
10
|
-
serialized = null
|
|
11
|
-
) {
|
|
12
|
-
super();
|
|
13
|
-
if (serialized) {
|
|
14
|
-
try {
|
|
15
|
-
const version = serialized[0];
|
|
16
|
-
const message = serialized.slice(1);
|
|
17
|
-
|
|
18
|
-
const distributionMessage = protobufs.SenderKeyDistributionMessage.decode(
|
|
19
|
-
message
|
|
20
|
-
).toJSON();
|
|
21
|
-
this.serialized = serialized;
|
|
22
|
-
this.id = distributionMessage.id;
|
|
23
|
-
this.iteration = distributionMessage.iteration;
|
|
24
|
-
this.chainKey = distributionMessage.chainKey;
|
|
25
|
-
this.signatureKey = distributionMessage.signingKey;
|
|
26
|
-
} catch (e) {
|
|
27
|
-
throw new Error(e);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
const version = this.intsToByteHighAndLow(this.CURRENT_VERSION, this.CURRENT_VERSION);
|
|
31
|
-
this.id = id;
|
|
32
|
-
this.iteration = iteration;
|
|
33
|
-
this.chainKey = chainKey;
|
|
34
|
-
this.signatureKey = signatureKey;
|
|
35
|
-
const message = protobufs.SenderKeyDistributionMessage.encode(
|
|
36
|
-
protobufs.SenderKeyDistributionMessage.create({
|
|
37
|
-
id,
|
|
38
|
-
iteration,
|
|
39
|
-
chainKey,
|
|
40
|
-
signingKey: this.signatureKey,
|
|
41
|
-
})
|
|
42
|
-
).finish();
|
|
43
|
-
this.serialized = Buffer.concat([Buffer.from([version]), message]);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
intsToByteHighAndLow(highValue, lowValue) {
|
|
48
|
-
return (((highValue << 4) | lowValue) & 0xff) % 256;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
serialize() {
|
|
52
|
-
return this.serialized;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
getType() {
|
|
56
|
-
return this.SENDERKEY_DISTRIBUTION_TYPE;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getIteration() {
|
|
60
|
-
return this.iteration;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getChainKey() {
|
|
64
|
-
return typeof this.chainKey === 'string' ? Buffer.from(this.chainKey, 'base64') : this.chainKey;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
getSignatureKey() {
|
|
68
|
-
return typeof this.signatureKey === 'string'
|
|
69
|
-
? Buffer.from(this.signatureKey, 'base64')
|
|
70
|
-
: this.signatureKey;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getId() {
|
|
74
|
-
return this.id;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
module.exports = SenderKeyDistributionMessage;
|