app enc and dec self images, but not from web
This commit is contained in:
parent
fe1ea5678c
commit
56404bcab1
|
@ -202,22 +202,26 @@ const ImageContainer = ({
|
|||
showAttachment(imageCached);
|
||||
};
|
||||
|
||||
const image = (
|
||||
<Button onPress={onPress}>
|
||||
<MessageImage
|
||||
imgUri={file.encryption && imageCached.title_link ? imageCached.title_link : img}
|
||||
cached={cached}
|
||||
loading={loading}
|
||||
/>
|
||||
</Button>
|
||||
);
|
||||
|
||||
if (msg) {
|
||||
return (
|
||||
<View>
|
||||
<Markdown msg={msg} style={[isReply && style]} username={user.username} getCustomEmoji={getCustomEmoji} theme={theme} />
|
||||
<Button onPress={onPress}>
|
||||
<MessageImage imgUri={img} cached={cached} loading={loading} />
|
||||
</Button>
|
||||
{image}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Button onPress={onPress}>
|
||||
<MessageImage imgUri={img} cached={cached} loading={loading} />
|
||||
</Button>
|
||||
);
|
||||
return image;
|
||||
};
|
||||
|
||||
ImageContainer.displayName = 'MessageImageContainer';
|
||||
|
|
|
@ -232,14 +232,14 @@ export function downloadMediaFile({
|
|||
// const vector = b64ToBuffer(encryption.iv);
|
||||
// const vector = Base64.decode(encryption.iv);
|
||||
// const vector = Base64.decode(encryption.iv);
|
||||
const vector = base64Decode(encryption.iv);
|
||||
const vector = b64ToBuffer(encryption.iv);
|
||||
console.log('🚀 ~ returnnewPromise ~ vector:', vector);
|
||||
|
||||
const decryptedFile = await decryptAESCTR(result.uri.substring(7), exportedKeyArrayBuffer, vector);
|
||||
console.log('🚀 ~ handleMediaDownload ~ decryptedFile:', decryptedFile);
|
||||
|
||||
if (result?.uri) {
|
||||
return resolve(result.uri);
|
||||
if (decryptedFile) {
|
||||
return resolve(`file://${decryptedFile}`);
|
||||
}
|
||||
return reject();
|
||||
} catch (e) {
|
||||
|
|
|
@ -123,10 +123,10 @@ export function sendFileMessage(
|
|||
|
||||
// const { version: serverVersion } = store.getState().server;
|
||||
// if (encryptedFileInfo.t === E2E_MESSAGE_TYPE && compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.8.0')) {
|
||||
// formData.push({
|
||||
// name: 't',
|
||||
// data: encryptedFileInfo.t
|
||||
// });
|
||||
formData.push({
|
||||
name: 't',
|
||||
data: 'e2e'
|
||||
});
|
||||
// formData.push({
|
||||
// name: 'e2e',
|
||||
// data: encryptedFileInfo.e2e
|
||||
|
@ -139,6 +139,7 @@ export function sendFileMessage(
|
|||
'X-Auth-Token': token,
|
||||
'X-User-Id': id
|
||||
};
|
||||
console.log('🚀 ~ returnnewPromise ~ RocketChatSettings.customHeaders:', RocketChatSettings.customHeaders);
|
||||
|
||||
try {
|
||||
const data = formData.map(item => {
|
||||
|
@ -168,12 +169,16 @@ export function sendFileMessage(
|
|||
|
||||
const mediaConfirm = await fetch(`${server}/api/v1/rooms.mediaConfirm/${rid}/${json.file._id}`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Auth-Token': token,
|
||||
'X-User-Id': id
|
||||
},
|
||||
body: JSON.stringify({
|
||||
msg: fileInfo.msg,
|
||||
tmid: fileInfo.tmid,
|
||||
description: fileInfo.description,
|
||||
t: fileInfo.t,
|
||||
msg: '',
|
||||
// tmid: fileInfo.tmid,
|
||||
// description: fileInfo.description,
|
||||
t: 'e2e',
|
||||
content
|
||||
})
|
||||
});
|
||||
|
|
|
@ -7,6 +7,7 @@ import ShareExtension from 'rn-extensions-share';
|
|||
import { Q } from '@nozbe/watermelondb';
|
||||
import SimpleCrypto from 'react-native-simple-crypto';
|
||||
import EJSON from 'ejson';
|
||||
import { sha256 } from 'js-sha256';
|
||||
|
||||
import { IMessageComposerRef, MessageComposerContainer } from '../../containers/MessageComposer';
|
||||
import { InsideStackParamList } from '../../stacks/types';
|
||||
|
@ -276,21 +277,22 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
const key = await generateAESCTRKey();
|
||||
|
||||
const exportedKey = await exportAESCTR(key);
|
||||
console.log('🚀 ~ ShareView ~ send= ~ exportedKey:', exportedKey, exportedKey.k);
|
||||
// console.log('🚀 ~ ShareView ~ send= ~ exportedKey:', exportedKey, exportedKey.k);
|
||||
|
||||
const exportedKeyArrayBuffer = b64URIToBuffer(exportedKey.k);
|
||||
console.log('🚀 ~ ShareView ~ send= ~ exportedKeyArrayBuffer:', exportedKeyArrayBuffer);
|
||||
console.log('BASE64 BASE64 BASE64 key:', exportedKey, exportedKey.k);
|
||||
console.log('BASE64 BASE64 BASE64 vector:', bufferToB64(vector));
|
||||
|
||||
const encryptedFile = await encryptAESCTR(path, exportedKeyArrayBuffer, vector);
|
||||
console.log('🚀 ~ ShareView ~ send= ~ encryptedFile:', encryptedFile);
|
||||
// console.log('🚀 ~ ShareView ~ send= ~ encryptedFile:', encryptedFile);
|
||||
|
||||
const decryptedFile = await decryptAESCTR(encryptedFile, exportedKeyArrayBuffer, vector);
|
||||
console.log('🚀 ~ ShareView ~ send= ~ decryptedFile:', decryptedFile);
|
||||
// const decryptedFile = await decryptAESCTR(encryptedFile, exportedKeyArrayBuffer, vector);
|
||||
// console.log('🚀 ~ ShareView ~ send= ~ decryptedFile:', decryptedFile);
|
||||
|
||||
const getContent = async (_id: string, fileUrl: string) => {
|
||||
console.log('🚀 ~ ShareView ~ getContent ~ _id:', _id, fileUrl);
|
||||
// console.log('🚀 ~ ShareView ~ getContent ~ _id:', _id, fileUrl);
|
||||
const attachments = [];
|
||||
console.log('🚀 ~ ShareView ~ getContent ~ attachment.encryption.exportedKey:', vector, exportedKey);
|
||||
// console.log('🚀 ~ ShareView ~ getContent ~ attachment.encryption.exportedKey:', vector, exportedKey);
|
||||
|
||||
const attachment = {
|
||||
title: name,
|
||||
|
@ -311,7 +313,7 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
const data = EJSON.stringify({
|
||||
attachments
|
||||
});
|
||||
console.log('🚀 ~ ShareView ~ getContent ~ attachments:', attachments, data);
|
||||
// console.log('🚀 ~ ShareView ~ getContent ~ attachments:', attachments, data);
|
||||
|
||||
return {
|
||||
algorithm: 'rc.v1.aes-sha2',
|
||||
|
@ -324,7 +326,7 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
room.rid,
|
||||
{
|
||||
rid: room.rid,
|
||||
// name,
|
||||
name: sha256(name),
|
||||
description,
|
||||
size,
|
||||
type: 'file',
|
||||
|
|
Loading…
Reference in New Issue