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