@ethora/chat-component-rn 26.8.6 → 26.8.7
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/CHANGELOG.md +26 -0
- package/README.md +40 -0
- package/lib/commonjs/assets/icons.js +4 -2
- package/lib/commonjs/assets/icons.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatHeader.js +28 -6
- package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatRoom.js +9 -1
- package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/commonjs/components/MainComponents/EncryptedSendNotice.js +47 -0
- package/lib/commonjs/components/MainComponents/EncryptedSendNotice.js.map +1 -0
- package/lib/commonjs/components/MainComponents/EncryptionCard.js +286 -0
- package/lib/commonjs/components/MainComponents/EncryptionCard.js.map +1 -0
- package/lib/commonjs/components/MainComponents/MediaMessage.js +7 -0
- package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js +5 -0
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/SealedAttachment.js +231 -0
- package/lib/commonjs/components/MainComponents/SealedAttachment.js.map +1 -0
- package/lib/commonjs/components/MessageBubble/BottomReplyContainer.js +2 -1
- package/lib/commonjs/components/MessageBubble/BottomReplyContainer.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/Message.js +66 -6
- package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/MessageInteractions.js +2 -1
- package/lib/commonjs/components/MessageBubble/MessageInteractions.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +7 -4
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +159 -16
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js +4 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +29 -6
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +5 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +32 -9
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/LastMessageItem.js +6 -0
- package/lib/commonjs/components/RoomComponents/LastMessageItem.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js +2 -2
- package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js +4 -6
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js +2 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageSealed.js +41 -0
- package/lib/commonjs/components/RoomComponents/styled/LastMessageSealed.js.map +1 -0
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js +2 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/commonjs/components/Thread/ThreadWrapper.js +53 -45
- package/lib/commonjs/components/Thread/ThreadWrapper.js.map +1 -1
- package/lib/commonjs/components/UsersList/UsersList.js +2 -1
- package/lib/commonjs/components/UsersList/UsersList.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +4 -2
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/e2ee/crypto.js +207 -0
- package/lib/commonjs/e2ee/crypto.js.map +1 -0
- package/lib/commonjs/e2ee/deviceStore.js +84 -0
- package/lib/commonjs/e2ee/deviceStore.js.map +1 -0
- package/lib/commonjs/e2ee/fileCipher.js +95 -0
- package/lib/commonjs/e2ee/fileCipher.js.map +1 -0
- package/lib/commonjs/e2ee/fileEnvelope.js +79 -0
- package/lib/commonjs/e2ee/fileEnvelope.js.map +1 -0
- package/lib/commonjs/e2ee/index.js +210 -0
- package/lib/commonjs/e2ee/index.js.map +1 -0
- package/lib/commonjs/e2ee/limits.js +9 -0
- package/lib/commonjs/e2ee/limits.js.map +1 -0
- package/lib/commonjs/e2ee/ns.js +8 -0
- package/lib/commonjs/e2ee/ns.js.map +1 -0
- package/lib/commonjs/e2ee/omemo.js +622 -0
- package/lib/commonjs/e2ee/omemo.js.map +1 -0
- package/lib/commonjs/e2ee/protobuf.js +149 -0
- package/lib/commonjs/e2ee/protobuf.js.map +1 -0
- package/lib/commonjs/e2ee/ratchet.js +238 -0
- package/lib/commonjs/e2ee/ratchet.js.map +1 -0
- package/lib/commonjs/e2ee/sealedBody.js +23 -0
- package/lib/commonjs/e2ee/sealedBody.js.map +1 -0
- package/lib/commonjs/e2ee/sealedFiles.js +174 -0
- package/lib/commonjs/e2ee/sealedFiles.js.map +1 -0
- package/lib/commonjs/e2ee/send.js +54 -0
- package/lib/commonjs/e2ee/send.js.map +1 -0
- package/lib/commonjs/e2ee/stanza.js +114 -0
- package/lib/commonjs/e2ee/stanza.js.map +1 -0
- package/lib/commonjs/e2ee/store.js +43 -0
- package/lib/commonjs/e2ee/store.js.map +1 -0
- package/lib/commonjs/helpers/accountName.js +23 -0
- package/lib/commonjs/helpers/accountName.js.map +1 -0
- package/lib/commonjs/helpers/createMessageFromXml.js +19 -4
- package/lib/commonjs/helpers/createMessageFromXml.js.map +1 -1
- package/lib/commonjs/helpers/createUserNameFromSetUser.js +2 -1
- package/lib/commonjs/helpers/createUserNameFromSetUser.js.map +1 -1
- package/lib/commonjs/helpers/displayName.js +16 -0
- package/lib/commonjs/helpers/displayName.js.map +1 -0
- package/lib/commonjs/helpers/persistCrypto.js +5 -0
- package/lib/commonjs/helpers/persistCrypto.js.map +1 -1
- package/lib/commonjs/helpers/secureKeyValue.js +20 -0
- package/lib/commonjs/helpers/secureKeyValue.js.map +1 -1
- package/lib/commonjs/helpers/videoCache.js +136 -0
- package/lib/commonjs/helpers/videoCache.js.map +1 -0
- package/lib/commonjs/hooks/useLogout.js +8 -0
- package/lib/commonjs/hooks/useLogout.js.map +1 -1
- package/lib/commonjs/hooks/useSendMessage.js +71 -7
- package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +180 -0
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js +13 -0
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/auth.api.js +4 -1
- package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
- package/lib/commonjs/networking/api-requests/rooms.api.js +111 -17
- package/lib/commonjs/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js +40 -0
- package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js +16 -3
- package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendTextMessage.xmpp.js +13 -6
- package/lib/commonjs/networking/xmpp/sendTextMessage.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js +14 -6
- package/lib/commonjs/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmppClient.js +6 -0
- package/lib/commonjs/networking/xmppClient.js.map +1 -1
- package/lib/commonjs/roomStore/persistBackend.js +9 -12
- package/lib/commonjs/roomStore/persistBackend.js.map +1 -1
- package/lib/commonjs/roomStore/persistence.js +8 -1
- package/lib/commonjs/roomStore/persistence.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/assets/icons.js +3 -1
- package/lib/module/assets/icons.js.map +1 -1
- package/lib/module/components/MainComponents/ChatHeader.js +29 -7
- package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/module/components/MainComponents/ChatRoom.js +9 -1
- package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/module/components/MainComponents/EncryptedSendNotice.js +42 -0
- package/lib/module/components/MainComponents/EncryptedSendNotice.js.map +1 -0
- package/lib/module/components/MainComponents/EncryptionCard.js +281 -0
- package/lib/module/components/MainComponents/EncryptionCard.js.map +1 -0
- package/lib/module/components/MainComponents/MediaMessage.js +7 -0
- package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/module/components/MainComponents/ReduxWrapper.js +5 -0
- package/lib/module/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/SealedAttachment.js +224 -0
- package/lib/module/components/MainComponents/SealedAttachment.js.map +1 -0
- package/lib/module/components/MessageBubble/BottomReplyContainer.js +2 -1
- package/lib/module/components/MessageBubble/BottomReplyContainer.js.map +1 -1
- package/lib/module/components/MessageBubble/Message.js +69 -9
- package/lib/module/components/MessageBubble/Message.js.map +1 -1
- package/lib/module/components/MessageBubble/MessageInteractions.js +2 -1
- package/lib/module/components/MessageBubble/MessageInteractions.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +7 -4
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +161 -18
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/PdfView.js +4 -0
- package/lib/module/components/Modals/FilePreviewModal/PdfView.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +32 -8
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +4 -0
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/module/components/RoomComponents/ChatRoomItem.js +32 -9
- package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/module/components/RoomComponents/LastMessageItem.js +6 -0
- package/lib/module/components/RoomComponents/LastMessageItem.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastAudioMessage.js +2 -2
- package/lib/module/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js +4 -6
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +2 -2
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageSealed.js +36 -0
- package/lib/module/components/RoomComponents/styled/LastMessageSealed.js.map +1 -0
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +2 -2
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/module/components/Thread/ThreadWrapper.js +54 -46
- package/lib/module/components/Thread/ThreadWrapper.js.map +1 -1
- package/lib/module/components/UsersList/UsersList.js +2 -1
- package/lib/module/components/UsersList/UsersList.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +4 -2
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/e2ee/crypto.js +170 -0
- package/lib/module/e2ee/crypto.js.map +1 -0
- package/lib/module/e2ee/deviceStore.js +77 -0
- package/lib/module/e2ee/deviceStore.js.map +1 -0
- package/lib/module/e2ee/fileCipher.js +90 -0
- package/lib/module/e2ee/fileCipher.js.map +1 -0
- package/lib/module/e2ee/fileEnvelope.js +66 -0
- package/lib/module/e2ee/fileEnvelope.js.map +1 -0
- package/lib/module/e2ee/index.js +185 -0
- package/lib/module/e2ee/index.js.map +1 -0
- package/lib/module/e2ee/limits.js +5 -0
- package/lib/module/e2ee/limits.js.map +1 -0
- package/lib/module/e2ee/ns.js +4 -0
- package/lib/module/e2ee/ns.js.map +1 -0
- package/lib/module/e2ee/omemo.js +610 -0
- package/lib/module/e2ee/omemo.js.map +1 -0
- package/lib/module/e2ee/protobuf.js +140 -0
- package/lib/module/e2ee/protobuf.js.map +1 -0
- package/lib/module/e2ee/ratchet.js +228 -0
- package/lib/module/e2ee/ratchet.js.map +1 -0
- package/lib/module/e2ee/sealedBody.js +19 -0
- package/lib/module/e2ee/sealedBody.js.map +1 -0
- package/lib/module/e2ee/sealedFiles.js +154 -0
- package/lib/module/e2ee/sealedFiles.js.map +1 -0
- package/lib/module/e2ee/send.js +48 -0
- package/lib/module/e2ee/send.js.map +1 -0
- package/lib/module/e2ee/stanza.js +107 -0
- package/lib/module/e2ee/stanza.js.map +1 -0
- package/lib/module/e2ee/store.js +35 -0
- package/lib/module/e2ee/store.js.map +1 -0
- package/lib/module/helpers/accountName.js +18 -0
- package/lib/module/helpers/accountName.js.map +1 -0
- package/lib/module/helpers/createMessageFromXml.js +19 -4
- package/lib/module/helpers/createMessageFromXml.js.map +1 -1
- package/lib/module/helpers/createUserNameFromSetUser.js +3 -1
- package/lib/module/helpers/createUserNameFromSetUser.js.map +1 -1
- package/lib/module/helpers/displayName.js +11 -0
- package/lib/module/helpers/displayName.js.map +1 -0
- package/lib/module/helpers/persistCrypto.js +4 -0
- package/lib/module/helpers/persistCrypto.js.map +1 -1
- package/lib/module/helpers/secureKeyValue.js +19 -0
- package/lib/module/helpers/secureKeyValue.js.map +1 -1
- package/lib/module/helpers/videoCache.js +125 -0
- package/lib/module/helpers/videoCache.js.map +1 -0
- package/lib/module/hooks/useLogout.js +8 -0
- package/lib/module/hooks/useLogout.js.map +1 -1
- package/lib/module/hooks/useSendMessage.js +71 -7
- package/lib/module/hooks/useSendMessage.js.map +1 -1
- package/lib/module/i18n/strings.js +180 -0
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js +1 -0
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/auth.api.js +4 -1
- package/lib/module/networking/api-requests/auth.api.js.map +1 -1
- package/lib/module/networking/api-requests/rooms.api.js +109 -18
- package/lib/module/networking/api-requests/rooms.api.js.map +1 -1
- package/lib/module/networking/xmpp/handleStanzas.xmpp.js +38 -0
- package/lib/module/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js +16 -3
- package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendTextMessage.xmpp.js +13 -6
- package/lib/module/networking/xmpp/sendTextMessage.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js +14 -6
- package/lib/module/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.js.map +1 -1
- package/lib/module/networking/xmppClient.js +6 -0
- package/lib/module/networking/xmppClient.js.map +1 -1
- package/lib/module/roomStore/persistBackend.js +10 -13
- package/lib/module/roomStore/persistBackend.js.map +1 -1
- package/lib/module/roomStore/persistence.js +8 -1
- package/lib/module/roomStore/persistence.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/assets/icons.d.ts +8 -0
- package/lib/typescript/assets/icons.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/EncryptedSendNotice.d.ts +4 -0
- package/lib/typescript/components/MainComponents/EncryptedSendNotice.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/EncryptionCard.d.ts +10 -0
- package/lib/typescript/components/MainComponents/EncryptionCard.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ReduxWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/SealedAttachment.d.ts +13 -0
- package/lib/typescript/components/MainComponents/SealedAttachment.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble/BottomReplyContainer.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/MessageInteractions.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/PdfView.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/LastMessageItem.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageSealed.d.ts +7 -0
- package/lib/typescript/components/RoomComponents/styled/LastMessageSealed.d.ts.map +1 -0
- package/lib/typescript/components/Thread/ThreadWrapper.d.ts.map +1 -1
- package/lib/typescript/components/UsersList/UsersList.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts +1 -0
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/e2ee/crypto.d.ts +28 -0
- package/lib/typescript/e2ee/crypto.d.ts.map +1 -0
- package/lib/typescript/e2ee/deviceStore.d.ts +4 -0
- package/lib/typescript/e2ee/deviceStore.d.ts.map +1 -0
- package/lib/typescript/e2ee/fileCipher.d.ts +7 -0
- package/lib/typescript/e2ee/fileCipher.d.ts.map +1 -0
- package/lib/typescript/e2ee/fileEnvelope.d.ts +27 -0
- package/lib/typescript/e2ee/fileEnvelope.d.ts.map +1 -0
- package/lib/typescript/e2ee/index.d.ts +23 -0
- package/lib/typescript/e2ee/index.d.ts.map +1 -0
- package/lib/typescript/e2ee/limits.d.ts +3 -0
- package/lib/typescript/e2ee/limits.d.ts.map +1 -0
- package/lib/typescript/e2ee/ns.d.ts +2 -0
- package/lib/typescript/e2ee/ns.d.ts.map +1 -0
- package/lib/typescript/e2ee/omemo.d.ts +64 -0
- package/lib/typescript/e2ee/omemo.d.ts.map +1 -0
- package/lib/typescript/e2ee/protobuf.d.ts +25 -0
- package/lib/typescript/e2ee/protobuf.d.ts.map +1 -0
- package/lib/typescript/e2ee/ratchet.d.ts +39 -0
- package/lib/typescript/e2ee/ratchet.d.ts.map +1 -0
- package/lib/typescript/e2ee/sealedBody.d.ts +2 -0
- package/lib/typescript/e2ee/sealedBody.d.ts.map +1 -0
- package/lib/typescript/e2ee/sealedFiles.d.ts +31 -0
- package/lib/typescript/e2ee/sealedFiles.d.ts.map +1 -0
- package/lib/typescript/e2ee/send.d.ts +6 -0
- package/lib/typescript/e2ee/send.d.ts.map +1 -0
- package/lib/typescript/e2ee/stanza.d.ts +8 -0
- package/lib/typescript/e2ee/stanza.d.ts.map +1 -0
- package/lib/typescript/e2ee/store.d.ts +16 -0
- package/lib/typescript/e2ee/store.d.ts.map +1 -0
- package/lib/typescript/helpers/accountName.d.ts +7 -0
- package/lib/typescript/helpers/accountName.d.ts.map +1 -0
- package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
- package/lib/typescript/helpers/createUserNameFromSetUser.d.ts.map +1 -1
- package/lib/typescript/helpers/displayName.d.ts +2 -0
- package/lib/typescript/helpers/displayName.d.ts.map +1 -0
- package/lib/typescript/helpers/persistCrypto.d.ts +1 -0
- package/lib/typescript/helpers/persistCrypto.d.ts.map +1 -1
- package/lib/typescript/helpers/secureKeyValue.d.ts +4 -0
- package/lib/typescript/helpers/secureKeyValue.d.ts.map +1 -1
- package/lib/typescript/helpers/videoCache.d.ts +19 -0
- package/lib/typescript/helpers/videoCache.d.ts.map +1 -0
- package/lib/typescript/hooks/useLogout.d.ts.map +1 -1
- package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +2 -0
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts +4 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/rooms.api.d.ts +22 -1
- package/lib/typescript/networking/api-requests/rooms.api.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts +1 -0
- package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendTextMessage.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
- package/lib/typescript/roomStore/persistBackend.d.ts.map +1 -1
- package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
- package/lib/typescript/types/models/message.model.d.ts +5 -0
- package/lib/typescript/types/models/message.model.d.ts.map +1 -1
- package/lib/typescript/types/models/room.model.d.ts +5 -0
- package/lib/typescript/types/models/room.model.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +4 -0
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +8 -4
- package/src/assets/icons.tsx +27 -0
- package/src/components/MainComponents/ChatHeader.tsx +30 -9
- package/src/components/MainComponents/ChatRoom.tsx +11 -1
- package/src/components/MainComponents/EncryptedSendNotice.tsx +35 -0
- package/src/components/MainComponents/EncryptionCard.tsx +287 -0
- package/src/components/MainComponents/MediaMessage.tsx +5 -0
- package/src/components/MainComponents/ReduxWrapper.tsx +5 -0
- package/src/components/MainComponents/SealedAttachment.tsx +251 -0
- package/src/components/MessageBubble/BottomReplyContainer.tsx +2 -1
- package/src/components/MessageBubble/Message.tsx +96 -6
- package/src/components/MessageBubble/MessageInteractions.tsx +2 -3
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +7 -4
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +181 -35
- package/src/components/Modals/FilePreviewModal/PdfView.tsx +4 -0
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +53 -8
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +5 -0
- package/src/components/RoomComponents/ChatRoomItem.tsx +23 -11
- package/src/components/RoomComponents/LastMessageItem.tsx +5 -0
- package/src/components/RoomComponents/styled/LastAudioMessage.tsx +3 -1
- package/src/components/RoomComponents/styled/LastMessageFile.tsx +2 -2
- package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +1 -1
- package/src/components/RoomComponents/styled/LastMessageSealed.tsx +31 -0
- package/src/components/RoomComponents/styled/LastMessageVideo.tsx +1 -1
- package/src/components/Thread/ThreadWrapper.tsx +13 -0
- package/src/components/UsersList/UsersList.tsx +2 -1
- package/src/components/styled/SendInput.tsx +5 -2
- package/src/e2ee/crypto.ts +194 -0
- package/src/e2ee/deviceStore.ts +80 -0
- package/src/e2ee/fileCipher.ts +86 -0
- package/src/e2ee/fileEnvelope.ts +115 -0
- package/src/e2ee/index.ts +192 -0
- package/src/e2ee/limits.ts +2 -0
- package/src/e2ee/ns.ts +1 -0
- package/src/e2ee/omemo.ts +802 -0
- package/src/e2ee/protobuf.ts +188 -0
- package/src/e2ee/ratchet.ts +271 -0
- package/src/e2ee/sealedBody.ts +17 -0
- package/src/e2ee/sealedFiles.ts +181 -0
- package/src/e2ee/send.ts +70 -0
- package/src/e2ee/stanza.ts +133 -0
- package/src/e2ee/store.ts +54 -0
- package/src/helpers/accountName.ts +15 -0
- package/src/helpers/createMessageFromXml.ts +31 -6
- package/src/helpers/createUserNameFromSetUser.ts +2 -1
- package/src/helpers/displayName.ts +9 -0
- package/src/helpers/persistCrypto.ts +5 -0
- package/src/helpers/secureKeyValue.ts +15 -0
- package/src/helpers/videoCache.ts +138 -0
- package/src/hooks/useLogout.tsx +9 -0
- package/src/hooks/useSendMessage.tsx +71 -5
- package/src/i18n/strings.ts +180 -0
- package/src/main.ts +2 -0
- package/src/networking/api-requests/auth.api.ts +9 -1
- package/src/networking/api-requests/rooms.api.ts +121 -18
- package/src/networking/xmpp/handleStanzas.xmpp.ts +49 -0
- package/src/networking/xmpp/sendMediaMessage.xmpp.ts +19 -1
- package/src/networking/xmpp/sendTextMessage.xmpp.ts +17 -10
- package/src/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.ts +23 -10
- package/src/networking/xmppClient.ts +6 -0
- package/src/roomStore/persistBackend.ts +8 -11
- package/src/roomStore/persistence.ts +15 -0
- package/src/types/models/message.model.ts +5 -0
- package/src/types/models/room.model.ts +5 -0
- package/src/types/types.ts +4 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeAuthenticated = decodeAuthenticated;
|
|
7
|
+
exports.decodeKeyExchange = decodeKeyExchange;
|
|
8
|
+
exports.decodeMessage = decodeMessage;
|
|
9
|
+
exports.encodeAuthenticated = encodeAuthenticated;
|
|
10
|
+
exports.encodeKeyExchange = encodeKeyExchange;
|
|
11
|
+
exports.encodeMessage = encodeMessage;
|
|
12
|
+
var _crypto = require("./crypto");
|
|
13
|
+
const VARINT = 0;
|
|
14
|
+
const FIXED64 = 1;
|
|
15
|
+
const BYTES = 2;
|
|
16
|
+
const FIXED32 = 5;
|
|
17
|
+
function varint(value) {
|
|
18
|
+
if (!Number.isInteger(value) || value < 0 || value > 0xffffffff) {
|
|
19
|
+
throw new Error(`Invalid uint32: ${value}`);
|
|
20
|
+
}
|
|
21
|
+
const out = [];
|
|
22
|
+
while (value > 0x7f) {
|
|
23
|
+
out.push(value % 0x80 | 0x80);
|
|
24
|
+
value = Math.floor(value / 0x80);
|
|
25
|
+
}
|
|
26
|
+
out.push(value);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
class Writer {
|
|
30
|
+
parts = [];
|
|
31
|
+
uint(field, value) {
|
|
32
|
+
this.parts.push(Uint8Array.from([...varint(field << 3 | VARINT), ...varint(value)]));
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
bytes(field, value) {
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
this.parts.push(Uint8Array.from([...varint(field << 3 | BYTES), ...varint(value.length)]), value);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
finish() {
|
|
43
|
+
return (0, _crypto.concatBytes)(...this.parts);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function read(buf) {
|
|
47
|
+
const fields = new Map();
|
|
48
|
+
let pos = 0;
|
|
49
|
+
const readVarint = () => {
|
|
50
|
+
let result = 0;
|
|
51
|
+
let scale = 1;
|
|
52
|
+
for (let i = 0; i < 10; i++) {
|
|
53
|
+
if (pos >= buf.length) {
|
|
54
|
+
throw new Error('Truncated varint');
|
|
55
|
+
}
|
|
56
|
+
const b = buf[pos++];
|
|
57
|
+
result += (b & 0x7f) * scale;
|
|
58
|
+
if (!(b & 0x80)) {
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
scale *= 0x80;
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Varint too long');
|
|
64
|
+
};
|
|
65
|
+
const skip = length => {
|
|
66
|
+
if (pos + length > buf.length) {
|
|
67
|
+
throw new Error('Truncated field');
|
|
68
|
+
}
|
|
69
|
+
pos += length;
|
|
70
|
+
};
|
|
71
|
+
while (pos < buf.length) {
|
|
72
|
+
const tag = readVarint();
|
|
73
|
+
const field = Math.floor(tag / 8);
|
|
74
|
+
switch (tag % 8) {
|
|
75
|
+
case VARINT:
|
|
76
|
+
fields.set(field, readVarint());
|
|
77
|
+
break;
|
|
78
|
+
case BYTES:
|
|
79
|
+
{
|
|
80
|
+
const length = readVarint();
|
|
81
|
+
const start = pos;
|
|
82
|
+
skip(length);
|
|
83
|
+
fields.set(field, buf.subarray(start, pos));
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case FIXED64:
|
|
87
|
+
skip(8);
|
|
88
|
+
break;
|
|
89
|
+
case FIXED32:
|
|
90
|
+
skip(4);
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
throw new Error('Unsupported wire type');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return fields;
|
|
97
|
+
}
|
|
98
|
+
function requireUint(fields, field) {
|
|
99
|
+
const value = fields.get(field);
|
|
100
|
+
if (typeof value !== 'number' || value > 0xffffffff) {
|
|
101
|
+
throw new Error(`Missing field ${field}`);
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
function requireBytes(fields, field) {
|
|
106
|
+
const value = fields.get(field);
|
|
107
|
+
if (!(value instanceof Uint8Array)) {
|
|
108
|
+
throw new Error(`Missing field ${field}`);
|
|
109
|
+
}
|
|
110
|
+
// Copy, so stored values don't keep the whole input buffer alive
|
|
111
|
+
return value.slice();
|
|
112
|
+
}
|
|
113
|
+
function encodeMessage(m) {
|
|
114
|
+
return new Writer().uint(1, m.n).uint(2, m.pn).bytes(3, m.dhPub).bytes(4, m.ciphertext).finish();
|
|
115
|
+
}
|
|
116
|
+
function decodeMessage(buf) {
|
|
117
|
+
const f = read(buf);
|
|
118
|
+
const ciphertext = f.get(4);
|
|
119
|
+
return {
|
|
120
|
+
n: requireUint(f, 1),
|
|
121
|
+
pn: requireUint(f, 2),
|
|
122
|
+
dhPub: requireBytes(f, 3),
|
|
123
|
+
ciphertext: ciphertext instanceof Uint8Array ? ciphertext.slice() : undefined
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function encodeAuthenticated(m) {
|
|
127
|
+
return new Writer().bytes(1, m.mac).bytes(2, m.message).finish();
|
|
128
|
+
}
|
|
129
|
+
function decodeAuthenticated(buf) {
|
|
130
|
+
const f = read(buf);
|
|
131
|
+
return {
|
|
132
|
+
mac: requireBytes(f, 1),
|
|
133
|
+
message: requireBytes(f, 2)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function encodeKeyExchange(m) {
|
|
137
|
+
return new Writer().uint(1, m.pkId).uint(2, m.spkId).bytes(3, m.ik).bytes(4, m.ek).bytes(5, m.message).finish();
|
|
138
|
+
}
|
|
139
|
+
function decodeKeyExchange(buf) {
|
|
140
|
+
const f = read(buf);
|
|
141
|
+
return {
|
|
142
|
+
pkId: requireUint(f, 1),
|
|
143
|
+
spkId: requireUint(f, 2),
|
|
144
|
+
ik: requireBytes(f, 3),
|
|
145
|
+
ek: requireBytes(f, 4),
|
|
146
|
+
message: requireBytes(f, 5)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=protobuf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_crypto","require","VARINT","FIXED64","BYTES","FIXED32","varint","value","Number","isInteger","Error","out","push","Math","floor","Writer","parts","uint","field","Uint8Array","from","bytes","undefined","length","finish","concatBytes","read","buf","fields","Map","pos","readVarint","result","scale","i","b","skip","tag","set","start","subarray","requireUint","get","requireBytes","slice","encodeMessage","m","n","pn","dhPub","ciphertext","decodeMessage","f","encodeAuthenticated","mac","message","decodeAuthenticated","encodeKeyExchange","pkId","spkId","ik","ek","decodeKeyExchange"],"sourceRoot":"../../../src","sources":["e2ee/protobuf.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,MAAM,GAAG,CAAC;AAChB,MAAMC,OAAO,GAAG,CAAC;AACjB,MAAMC,KAAK,GAAG,CAAC;AACf,MAAMC,OAAO,GAAG,CAA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EyB,CAAC,CAACc,EAAE,CAAC,CACdvC,KAAK,CAAC,CAAC,EAAEyB,CAAC,CAACe,EAAE,CAAC,CACdxC,KAAK,CAAC,CAAC,EAAEyB,CAAC,CAACS,OAAO,CAAC,CACnB/B,MAAM,CAAC,CAAC;AACb;AAEO,SAASsC,iBAAiBA,CAACnC,GAAe,EAAe;EAC9D,MAAMyB,CAAC,GAAG1B,IAAI,CAACC,GAAG,CAAC;EACnB,OAAO;IACL+B,IAAI,EAAEjB,WAAW,CAACW,CAAC,EAAE,CAAC,CAAC;IACvBO,KAAK,EAAElB,WAAW,CAACW,CAAC,EAAE,CAAC,CAAC;IACxBQ,EAAE,EAAEjB,YAAY,CAACS,CAAC,EAAE,CAAC,CAAC;IACtBS,EAAE,EAAElB,YAAY,CAACS,CAAC,EAAE,CAAC,CAAC;IACtBG,OAAO,EAAEZ,YAAY,CAACS,CAAC,EAAE,CAAC;EAC5B,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.acceptSession = acceptSession;
|
|
7
|
+
exports.cloneSession = cloneSession;
|
|
8
|
+
exports.decryptPayload = decryptPayload;
|
|
9
|
+
exports.encryptPayload = encryptPayload;
|
|
10
|
+
exports.initiateSession = initiateSession;
|
|
11
|
+
exports.ratchetDecrypt = ratchetDecrypt;
|
|
12
|
+
exports.ratchetEncrypt = ratchetEncrypt;
|
|
13
|
+
var _crypto = require("./crypto");
|
|
14
|
+
var _protobuf = require("./protobuf");
|
|
15
|
+
const MAX_SKIP = 1000;
|
|
16
|
+
const X3DH_PREFIX = new Uint8Array(32).fill(0xff);
|
|
17
|
+
function cloneSession(session) {
|
|
18
|
+
const skipped = {};
|
|
19
|
+
for (const id of Object.keys(session.skipped)) {
|
|
20
|
+
skipped[id] = session.skipped[id].slice();
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
rk: session.rk.slice(),
|
|
24
|
+
dhs: {
|
|
25
|
+
priv: session.dhs.priv.slice(),
|
|
26
|
+
pub: session.dhs.pub.slice()
|
|
27
|
+
},
|
|
28
|
+
...(session.dhr ? {
|
|
29
|
+
dhr: session.dhr.slice()
|
|
30
|
+
} : {}),
|
|
31
|
+
...(session.cks ? {
|
|
32
|
+
cks: session.cks.slice()
|
|
33
|
+
} : {}),
|
|
34
|
+
...(session.ckr ? {
|
|
35
|
+
ckr: session.ckr.slice()
|
|
36
|
+
} : {}),
|
|
37
|
+
ns: session.ns,
|
|
38
|
+
nr: session.nr,
|
|
39
|
+
pn: session.pn,
|
|
40
|
+
skipped,
|
|
41
|
+
ad: session.ad.slice(),
|
|
42
|
+
peerIk: session.peerIk.slice(),
|
|
43
|
+
...(session.pendingKex ? {
|
|
44
|
+
pendingKex: {
|
|
45
|
+
pkId: session.pendingKex.pkId,
|
|
46
|
+
spkId: session.pendingKex.spkId,
|
|
47
|
+
ek: session.pendingKex.ek.slice()
|
|
48
|
+
}
|
|
49
|
+
} : {}),
|
|
50
|
+
...(session.kexEk ? {
|
|
51
|
+
kexEk: session.kexEk.slice()
|
|
52
|
+
} : {})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function kdfRk(rk, dhOut) {
|
|
56
|
+
const out = (0, _crypto.hkdfSha256)(dhOut, rk, 'OMEMO Root Chain', 64);
|
|
57
|
+
return [out.slice(0, 32), out.slice(32)];
|
|
58
|
+
}
|
|
59
|
+
function kdfCk(ck) {
|
|
60
|
+
return [(0, _crypto.hmacSha256)(ck, Uint8Array.of(0x02)), (0, _crypto.hmacSha256)(ck, Uint8Array.of(0x01))];
|
|
61
|
+
}
|
|
62
|
+
function messageKeys(mk) {
|
|
63
|
+
const km = (0, _crypto.hkdfSha256)(mk, undefined, 'OMEMO Message Key Material', 80);
|
|
64
|
+
return {
|
|
65
|
+
enc: km.slice(0, 32),
|
|
66
|
+
auth: km.slice(32, 64),
|
|
67
|
+
iv: km.slice(64)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function x3dhSecret(...dhs) {
|
|
71
|
+
return (0, _crypto.hkdfSha256)((0, _crypto.concatBytes)(X3DH_PREFIX, ...dhs), undefined, 'OMEMO X3DH', 32);
|
|
72
|
+
}
|
|
73
|
+
function initiateSession(own, bundle) {
|
|
74
|
+
if (!(0, _crypto.verify)(bundle.spkSignature, bundle.spk, bundle.ik)) {
|
|
75
|
+
throw new Error('Invalid signed prekey signature');
|
|
76
|
+
}
|
|
77
|
+
const ek = (0, _crypto.generateKeyPair)();
|
|
78
|
+
const sk = x3dhSecret((0, _crypto.dh)((0, _crypto.identityDhPrivate)(own), bundle.spk), (0, _crypto.dh)(ek.priv, (0, _crypto.identityDhPublic)(bundle.ik)), (0, _crypto.dh)(ek.priv, bundle.spk), (0, _crypto.dh)(ek.priv, bundle.pk));
|
|
79
|
+
const dhs = (0, _crypto.generateKeyPair)();
|
|
80
|
+
const [rk, cks] = kdfRk(sk, (0, _crypto.dh)(dhs.priv, bundle.spk));
|
|
81
|
+
return {
|
|
82
|
+
rk,
|
|
83
|
+
dhs,
|
|
84
|
+
dhr: bundle.spk,
|
|
85
|
+
cks,
|
|
86
|
+
ns: 0,
|
|
87
|
+
nr: 0,
|
|
88
|
+
pn: 0,
|
|
89
|
+
skipped: {},
|
|
90
|
+
ad: (0, _crypto.concatBytes)(own.pub, bundle.ik),
|
|
91
|
+
peerIk: bundle.ik,
|
|
92
|
+
pendingKex: {
|
|
93
|
+
pkId: bundle.pkId,
|
|
94
|
+
spkId: bundle.spkId,
|
|
95
|
+
ek: ek.pub
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function acceptSession(own, spk, pk, peerIk, ek) {
|
|
100
|
+
const sk = x3dhSecret((0, _crypto.dh)(spk.priv, (0, _crypto.identityDhPublic)(peerIk)), (0, _crypto.dh)((0, _crypto.identityDhPrivate)(own), ek), (0, _crypto.dh)(spk.priv, ek), (0, _crypto.dh)(pk.priv, ek));
|
|
101
|
+
return {
|
|
102
|
+
rk: sk,
|
|
103
|
+
dhs: spk,
|
|
104
|
+
ns: 0,
|
|
105
|
+
nr: 0,
|
|
106
|
+
pn: 0,
|
|
107
|
+
skipped: {},
|
|
108
|
+
ad: (0, _crypto.concatBytes)(peerIk, own.pub),
|
|
109
|
+
peerIk,
|
|
110
|
+
kexEk: ek
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function ratchetEncrypt(session, plaintext) {
|
|
114
|
+
if (!session.cks) {
|
|
115
|
+
throw new Error('Session cannot send yet');
|
|
116
|
+
}
|
|
117
|
+
const s = cloneSession(session);
|
|
118
|
+
const [cks, mk] = kdfCk(s.cks);
|
|
119
|
+
s.cks = cks;
|
|
120
|
+
const {
|
|
121
|
+
enc,
|
|
122
|
+
auth,
|
|
123
|
+
iv
|
|
124
|
+
} = messageKeys(mk);
|
|
125
|
+
const message = (0, _protobuf.encodeMessage)({
|
|
126
|
+
n: s.ns,
|
|
127
|
+
pn: s.pn,
|
|
128
|
+
dhPub: s.dhs.pub,
|
|
129
|
+
ciphertext: (0, _crypto.aesEncrypt)(enc, iv, plaintext)
|
|
130
|
+
});
|
|
131
|
+
s.ns++;
|
|
132
|
+
const mac = (0, _crypto.hmacSha256)(auth, (0, _crypto.concatBytes)(s.ad, message)).slice(0, 16);
|
|
133
|
+
return [s, (0, _protobuf.encodeAuthenticated)({
|
|
134
|
+
mac,
|
|
135
|
+
message
|
|
136
|
+
})];
|
|
137
|
+
}
|
|
138
|
+
function ratchetDecrypt(session, data) {
|
|
139
|
+
const {
|
|
140
|
+
mac,
|
|
141
|
+
message
|
|
142
|
+
} = (0, _protobuf.decodeAuthenticated)(data);
|
|
143
|
+
const header = (0, _protobuf.decodeMessage)(message);
|
|
144
|
+
if (!header.ciphertext) {
|
|
145
|
+
throw new Error('Message without ciphertext');
|
|
146
|
+
}
|
|
147
|
+
const s = cloneSession(session);
|
|
148
|
+
const decrypt = mk => {
|
|
149
|
+
const {
|
|
150
|
+
enc,
|
|
151
|
+
auth,
|
|
152
|
+
iv
|
|
153
|
+
} = messageKeys(mk);
|
|
154
|
+
const expected = (0, _crypto.hmacSha256)(auth, (0, _crypto.concatBytes)(s.ad, message)).slice(0, 16);
|
|
155
|
+
if (!(0, _crypto.bytesEqual)(expected, mac)) {
|
|
156
|
+
throw new Error('Message authentication failed');
|
|
157
|
+
}
|
|
158
|
+
return (0, _crypto.aesDecrypt)(enc, iv, header.ciphertext);
|
|
159
|
+
};
|
|
160
|
+
const skippedId = `${(0, _crypto.toBase64)(header.dhPub)}:${header.n}`;
|
|
161
|
+
const skippedKey = s.skipped[skippedId];
|
|
162
|
+
if (skippedKey) {
|
|
163
|
+
delete s.skipped[skippedId];
|
|
164
|
+
return [s, decrypt(skippedKey)];
|
|
165
|
+
}
|
|
166
|
+
if (!s.dhr || !(0, _crypto.bytesEqual)(header.dhPub, s.dhr)) {
|
|
167
|
+
skipMessageKeys(s, header.pn);
|
|
168
|
+
s.pn = s.ns;
|
|
169
|
+
s.ns = 0;
|
|
170
|
+
s.nr = 0;
|
|
171
|
+
s.dhr = header.dhPub;
|
|
172
|
+
[s.rk, s.ckr] = kdfRk(s.rk, (0, _crypto.dh)(s.dhs.priv, s.dhr));
|
|
173
|
+
s.dhs = (0, _crypto.generateKeyPair)();
|
|
174
|
+
[s.rk, s.cks] = kdfRk(s.rk, (0, _crypto.dh)(s.dhs.priv, s.dhr));
|
|
175
|
+
}
|
|
176
|
+
skipMessageKeys(s, header.n);
|
|
177
|
+
const [ckr, mk] = kdfCk(s.ckr);
|
|
178
|
+
s.ckr = ckr;
|
|
179
|
+
s.nr++;
|
|
180
|
+
return [s, decrypt(mk)];
|
|
181
|
+
}
|
|
182
|
+
function skipMessageKeys(s, until) {
|
|
183
|
+
if (!s.ckr || !s.dhr) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (until - s.nr > MAX_SKIP) {
|
|
187
|
+
throw new Error('Too many skipped messages');
|
|
188
|
+
}
|
|
189
|
+
const dhr = (0, _crypto.toBase64)(s.dhr);
|
|
190
|
+
while (s.nr < until) {
|
|
191
|
+
const [ckr, mk] = kdfCk(s.ckr);
|
|
192
|
+
s.ckr = ckr;
|
|
193
|
+
s.skipped[`${dhr}:${s.nr}`] = mk;
|
|
194
|
+
s.nr++;
|
|
195
|
+
}
|
|
196
|
+
const ids = Object.keys(s.skipped);
|
|
197
|
+
for (const id of ids.slice(0, Math.max(0, ids.length - MAX_SKIP))) {
|
|
198
|
+
delete s.skipped[id];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function payloadKeys(key) {
|
|
202
|
+
const km = (0, _crypto.hkdfSha256)(key, undefined, 'OMEMO Payload', 80);
|
|
203
|
+
return {
|
|
204
|
+
enc: km.slice(0, 32),
|
|
205
|
+
auth: km.slice(32, 64),
|
|
206
|
+
iv: km.slice(64)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function encryptPayload(plaintext) {
|
|
210
|
+
const key = (0, _crypto.randomBytes)(32);
|
|
211
|
+
const {
|
|
212
|
+
enc,
|
|
213
|
+
auth,
|
|
214
|
+
iv
|
|
215
|
+
} = payloadKeys(key);
|
|
216
|
+
const payload = (0, _crypto.aesEncrypt)(enc, iv, plaintext);
|
|
217
|
+
const mac = (0, _crypto.hmacSha256)(auth, payload).slice(0, 16);
|
|
218
|
+
return {
|
|
219
|
+
keyMaterial: (0, _crypto.concatBytes)(key, mac),
|
|
220
|
+
payload
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function decryptPayload(keyMaterial, payload) {
|
|
224
|
+
if (keyMaterial.length !== 48) {
|
|
225
|
+
throw new Error('Invalid key material');
|
|
226
|
+
}
|
|
227
|
+
const {
|
|
228
|
+
enc,
|
|
229
|
+
auth,
|
|
230
|
+
iv
|
|
231
|
+
} = payloadKeys(keyMaterial.slice(0, 32));
|
|
232
|
+
const expected = (0, _crypto.hmacSha256)(auth, payload).slice(0, 16);
|
|
233
|
+
if (!(0, _crypto.bytesEqual)(expected, keyMaterial.slice(32))) {
|
|
234
|
+
throw new Error('Payload authentication failed');
|
|
235
|
+
}
|
|
236
|
+
return (0, _crypto.aesDecrypt)(enc, iv, payload);
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=ratchet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_crypto","require","_protobuf","MAX_SKIP","X3DH_PREFIX","Uint8Array","fill","cloneSession","session","skipped","id","Object","keys","slice","rk","dhs","priv","pub","dhr","cks","ckr","ns","nr","pn","ad","peerIk","pendingKex","pkId","spkId","ek","kexEk","kdfRk","dhOut","out","hkdfSha256","kdfCk","ck","hmacSha256","of","messageKeys","mk","km","undefined","enc","auth","iv","x3dhSecret","concatBytes","initiateSession","own","bundle","verify","spkSignature","spk","ik","Error","generateKeyPair","sk","dh","identityDhPrivate","identityDhPublic","pk","acceptSession","ratchetEncrypt","plaintext","s","message","encodeMessage","n","dhPub","ciphertext","aesEncrypt","mac","encodeAuthenticated","ratchetDecrypt","data","decodeAuthenticated","header","decodeMessage","decrypt","expected","bytesEqual","aesDecrypt","skippedId","toBase64","skippedKey","skipMessageKeys","until","ids","Math","max","length","payloadKeys","key","encryptPayload","randomBytes","payload","keyMaterial","decryptPayload"],"sourceRoot":"../../../src","sources":["e2ee/ratchet.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAiBA,IAAAC,SAAA,GAAAD,OAAA;AAOA,MAAME,QAAQ,GAAG,IAAI;AACrB,MAAMC,WAAW,GAAG,IAAIC,UAAU,CAAC,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AA2B1C,SAASC,YAAYA,CAACC,OAAgB,EAAW;EACtD,MAAMC,OAAmC,GAAG,CAAC,CAAC;EAC9C,KAAK,MAAMC,EAAE,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CA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AAEO,SAASE,cAAcA,CAC5BD,WAAuB,EACvBD,OAAmB,EACP;EACZ,IAAIC,WAAW,CAACN,MAAM,KAAK,EAAE,EAAE;IAAC,MAAM,IAAIpC,KAAK,CAAC,sBAAsB,CAAC;EAAC;EACxE,MAAM;IAAEZ,GAAG;IAAEC,IAAI;IAAEC;EAAG,CAAC,GAAG+C,WAAW,CAACK,WAAW,CAACpF,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;EAC/D,MAAMmE,QAAQ,GAAG,IAAA3C,kBAAU,EAACO,IAAI,EAAEoD,OAAO,CAAC,CAACnF,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;EACvD,IAAI,CAAC,IAAAoE,kBAAU,EAACD,QAAQ,EAAEiB,WAAW,CAACpF,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE;IAChD,MAAM,IAAI0C,KAAK,CAAC,+BAA+B,CAAC;EAClD;EACA,OAAO,IAAA2B,kBAAU,EAACvC,GAAG,EAAEE,EAAE,EAAEmD,OAAO,CAAC;AACrC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseSealedMediaBody = parseSealedMediaBody;
|
|
7
|
+
function parseSealedMediaBody(body) {
|
|
8
|
+
const text = String(body || '').trim();
|
|
9
|
+
if (!text.startsWith('{')) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(text);
|
|
14
|
+
if (parsed?.v !== 1 || !Array.isArray(parsed.keys)) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const keys = parsed.keys.filter(k => typeof k === 'string' && k.length > 0);
|
|
18
|
+
return keys.length === parsed.keys.length && keys.length > 0 ? keys : undefined;
|
|
19
|
+
} catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=sealedBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseSealedMediaBody","body","text","String","trim","startsWith","undefined","parsed","JSON","parse","v","Array","isArray","keys","filter","k","length"],"sourceRoot":"../../../src","sources":["e2ee/sealedBody.ts"],"mappings":";;;;;;AAAO,SAASA,oBAAoBA,CAACC,IAAa,EAAwB;EACxE,MAAMC,IAAI,GAAGC,MAAM,CAACF,IAAI,IAAI,EAAE,CAAC,CAACG,IAAI,CAAC,CAAC;EACtC,IAAI,CAACF,IAAI,CAACG,UAAU,CAAC,GAAG,CAAC,EAAE;IAAC,OAAOC,SAAS;EAAC;EAE7C,IAAI;IACF,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACP,IAAI,CAAoC;IAClE,IAAIK,MAAM,EAAEG,CAAC,KAAK,CAAC,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,MAAM,CAACM,IAAI,CAAC,EAAE;MAAC,OAAOP,SAAS;IAAC;IACtE,MAAMO,IAAI,GAAGN,MAAM,CAACM,IAAI,CAACC,MAAM,CAC5BC,CAAC,IAAkB,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,CAACC,MAAM,GAAG,CAC1D,CAAC;IACD,OAAOH,IAAI,CAACG,MAAM,KAAKT,MAAM,CAACM,IAAI,CAACG,MAAM,IAAIH,IAAI,CAACG,MAAM,GAAG,CAAC,GACxDH,IAAI,GACJP,SAAS;EACf,CAAC,CAAC,MAAM;IACN,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "MAX_OPEN_BYTES", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _limits.MAX_OPEN_BYTES;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "MAX_SEAL_BYTES", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _limits.MAX_SEAL_BYTES;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.clearOpenedFiles = clearOpenedFiles;
|
|
19
|
+
exports.findOpened = findOpened;
|
|
20
|
+
exports.openSealedAttachment = openSealedAttachment;
|
|
21
|
+
exports.rememberOpened = rememberOpened;
|
|
22
|
+
exports.sealPickedFile = sealPickedFile;
|
|
23
|
+
var _expoFileSystem = require("expo-file-system");
|
|
24
|
+
var LegacyFileSystem = _interopRequireWildcard(require("expo-file-system/legacy"));
|
|
25
|
+
var _mimeToExtension = require("../helpers/mimeToExtension");
|
|
26
|
+
var _getDisplayFileName = require("../helpers/getDisplayFileName");
|
|
27
|
+
var _fileEnvelope = require("./fileEnvelope");
|
|
28
|
+
var _limits = require("./limits");
|
|
29
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
30
|
+
const OPENED_DIR = 'ethora-sealed';
|
|
31
|
+
const hashString = value => {
|
|
32
|
+
let hash = 5381;
|
|
33
|
+
for (let i = 0; i < value.length; i++) {
|
|
34
|
+
hash = hash * 33 ^ value.charCodeAt(i);
|
|
35
|
+
}
|
|
36
|
+
return (hash >>> 0).toString(36);
|
|
37
|
+
};
|
|
38
|
+
async function sealPickedFile(picked, onProgress) {
|
|
39
|
+
if (typeof picked.size === 'number' && picked.size > _limits.MAX_SEAL_BYTES) {
|
|
40
|
+
throw new Error('sealed_attachment_too_large');
|
|
41
|
+
}
|
|
42
|
+
const bytes = await new _expoFileSystem.File(picked.uri).bytes();
|
|
43
|
+
if (bytes.length > _limits.MAX_SEAL_BYTES) {
|
|
44
|
+
throw new Error('sealed_attachment_too_large');
|
|
45
|
+
}
|
|
46
|
+
const sealed = await (0, _fileEnvelope.sealFileForUpload)({
|
|
47
|
+
bytes,
|
|
48
|
+
name: picked.name,
|
|
49
|
+
type: picked.type
|
|
50
|
+
}, onProgress);
|
|
51
|
+
const parked = new _expoFileSystem.File(_expoFileSystem.Paths.cache, `ethora-seal-${sealed.filename}`);
|
|
52
|
+
parked.write(sealed.ciphertext);
|
|
53
|
+
return {
|
|
54
|
+
uri: parked.uri,
|
|
55
|
+
name: sealed.filename,
|
|
56
|
+
keyMaterial: sealed.keyMaterial,
|
|
57
|
+
dispose: () => {
|
|
58
|
+
try {
|
|
59
|
+
if (parked.exists) {
|
|
60
|
+
parked.delete();
|
|
61
|
+
}
|
|
62
|
+
} catch {}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const folderFor = location => new _expoFileSystem.Directory(_expoFileSystem.Paths.cache, OPENED_DIR, hashString(location.split('#')[0].split('?')[0]));
|
|
67
|
+
const noteIn = folder => new _expoFileSystem.File(folder, 'meta.json');
|
|
68
|
+
async function findOpened(location) {
|
|
69
|
+
if (!location) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const folder = folderFor(location);
|
|
74
|
+
const note = noteIn(folder);
|
|
75
|
+
if (!note.exists) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const opened = JSON.parse(await note.text());
|
|
79
|
+
return new _expoFileSystem.File(opened.uri).exists ? opened : null;
|
|
80
|
+
} catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function keep(location, meta, write) {
|
|
85
|
+
return (async () => {
|
|
86
|
+
const folder = folderFor(location);
|
|
87
|
+
folder.create({
|
|
88
|
+
intermediates: true,
|
|
89
|
+
idempotent: true
|
|
90
|
+
});
|
|
91
|
+
const name = (0, _getDisplayFileName.sanitizeFileNameForPath)((0, _mimeToExtension.ensureFilenameHasExtension)(meta.name, meta.mimetype)).replace(/^\.+/, '') || 'file';
|
|
92
|
+
const target = new _expoFileSystem.File(folder, name);
|
|
93
|
+
if (target.exists) {
|
|
94
|
+
target.delete();
|
|
95
|
+
}
|
|
96
|
+
await write(target);
|
|
97
|
+
const opened = {
|
|
98
|
+
uri: target.uri,
|
|
99
|
+
name: meta.name,
|
|
100
|
+
mimetype: meta.mimetype,
|
|
101
|
+
size: meta.size
|
|
102
|
+
};
|
|
103
|
+
const note = noteIn(folder);
|
|
104
|
+
if (note.exists) {
|
|
105
|
+
note.delete();
|
|
106
|
+
}
|
|
107
|
+
note.write(JSON.stringify(opened));
|
|
108
|
+
return opened;
|
|
109
|
+
})();
|
|
110
|
+
}
|
|
111
|
+
const opening = new Map();
|
|
112
|
+
function openSealedAttachment(location, url, keyMaterial, onProgress) {
|
|
113
|
+
const running = opening.get(location);
|
|
114
|
+
if (running) {
|
|
115
|
+
return running;
|
|
116
|
+
}
|
|
117
|
+
const task = (async () => {
|
|
118
|
+
const kept = await findOpened(location);
|
|
119
|
+
if (kept) {
|
|
120
|
+
return kept;
|
|
121
|
+
}
|
|
122
|
+
const parked = new _expoFileSystem.File(_expoFileSystem.Paths.cache, `ethora-open-${hashString(location)}`);
|
|
123
|
+
try {
|
|
124
|
+
if (parked.exists) {
|
|
125
|
+
parked.delete();
|
|
126
|
+
}
|
|
127
|
+
const download = await LegacyFileSystem.downloadAsync(url, parked.uri);
|
|
128
|
+
if (download.status < 200 || download.status >= 300) {
|
|
129
|
+
throw new Error(`sealed_attachment_http_${download.status}`);
|
|
130
|
+
}
|
|
131
|
+
if ((parked.size ?? 0) > _limits.MAX_OPEN_BYTES) {
|
|
132
|
+
throw new Error('sealed_attachment_too_large');
|
|
133
|
+
}
|
|
134
|
+
const ciphertext = await parked.bytes();
|
|
135
|
+
const {
|
|
136
|
+
meta,
|
|
137
|
+
bytes
|
|
138
|
+
} = await (0, _fileEnvelope.openSealedFile)(ciphertext, keyMaterial, onProgress);
|
|
139
|
+
return await keep(location, {
|
|
140
|
+
name: meta.originalname,
|
|
141
|
+
mimetype: meta.mimetype,
|
|
142
|
+
size: bytes.length
|
|
143
|
+
}, target => target.write(bytes));
|
|
144
|
+
} finally {
|
|
145
|
+
try {
|
|
146
|
+
if (parked.exists) {
|
|
147
|
+
parked.delete();
|
|
148
|
+
}
|
|
149
|
+
} catch {}
|
|
150
|
+
}
|
|
151
|
+
})().finally(() => opening.delete(location));
|
|
152
|
+
opening.set(location, task);
|
|
153
|
+
return task;
|
|
154
|
+
}
|
|
155
|
+
async function rememberOpened(location, source) {
|
|
156
|
+
if (!location || !source?.uri) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const original = new _expoFileSystem.File(source.uri);
|
|
160
|
+
await keep(location, {
|
|
161
|
+
name: source.name || 'blob',
|
|
162
|
+
mimetype: source.type || 'application/octet-stream',
|
|
163
|
+
size: source.size ?? original.size ?? 0
|
|
164
|
+
}, target => original.copy(target));
|
|
165
|
+
}
|
|
166
|
+
function clearOpenedFiles() {
|
|
167
|
+
try {
|
|
168
|
+
const root = new _expoFileSystem.Directory(_expoFileSystem.Paths.cache, OPENED_DIR);
|
|
169
|
+
if (root.exists) {
|
|
170
|
+
root.delete();
|
|
171
|
+
}
|
|
172
|
+
} catch {}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=sealedFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_expoFileSystem","require","LegacyFileSystem","_interopRequireWildcard","_mimeToExtension","_getDisplayFileName","_fileEnvelope","_limits","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","OPENED_DIR","hashString","value","hash","length","charCodeAt","toString","sealPickedFile","picked","onProgress","size","MAX_SEAL_BYTES","Error","bytes","FsFile","uri","sealed","sealFileForUpload","name","type","parked","Paths","cache","filename","write","ciphertext","keyMaterial","dispose","exists","delete","folderFor","location","Directory","split","noteIn","folder","findOpened","note","opened","JSON","parse","text","keep","meta","create","intermediates","idempotent","sanitizeFileNameForPath","ensureFilenameHasExtension","mimetype","replace","target","stringify","opening","Map","openSealedAttachment","url","running","task","kept","download","downloadAsync","status","MAX_OPEN_BYTES","openSealedFile","originalname","finally","rememberOpened","source","original","copy","clearOpenedFiles","root"],"sourceRoot":"../../../src","sources":["e2ee/sealedFiles.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AAA0D,SAAAE,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CA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