properly display encrypted text
This commit is contained in:
parent
621cbe867b
commit
8330bb420e
|
@ -88,6 +88,9 @@ const JustPage = (props: JustPageProps) => {
|
||||||
form.append("file_content", blobData, fileName);
|
form.append("file_content", blobData, fileName);
|
||||||
form.append("filename", fileName);
|
form.append("filename", fileName);
|
||||||
form.append("filetype", fileType);
|
form.append("filetype", fileType);
|
||||||
|
HexMix.arrayBufferToString(encrypted, (result: string) => {
|
||||||
|
sessionStorage.setItem("encoded_file", result);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const textFormData = async (form: FormData, aesKey: AESKey) => {
|
const textFormData = async (form: FormData, aesKey: AESKey) => {
|
||||||
|
@ -102,6 +105,9 @@ const JustPage = (props: JustPageProps) => {
|
||||||
);
|
);
|
||||||
const blobData = new Blob([encrypted]);
|
const blobData = new Blob([encrypted]);
|
||||||
form.append("text_content", blobData, "secret_message.txt");
|
form.append("text_content", blobData, "secret_message.txt");
|
||||||
|
HexMix.arrayBufferToString(encrypted, (result: string) => {
|
||||||
|
sessionStorage.setItem("encoded_message", result);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const createKey = async (): Promise<AESKey> => {
|
const createKey = async (): Promise<AESKey> => {
|
||||||
|
|
|
@ -1,8 +1,29 @@
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { ProgressIndicator, Header2, Button, IconArrow, InputButtonWithIcon, Label, Input, CenteredContainer, SpaceBetweenContainer, Spacer, TextAlignWrapper, GlobalStyle } from "@intended/intended-ui";
|
import {
|
||||||
|
ProgressIndicator,
|
||||||
|
Header2,
|
||||||
|
Button,
|
||||||
|
IconArrow,
|
||||||
|
InputButtonWithIcon,
|
||||||
|
Label,
|
||||||
|
Input,
|
||||||
|
CenteredContainer,
|
||||||
|
SpaceBetweenContainer,
|
||||||
|
Spacer,
|
||||||
|
TextAlignWrapper,
|
||||||
|
GlobalStyle,
|
||||||
|
} from "@intended/intended-ui";
|
||||||
|
|
||||||
const YouPage = () => {
|
const YouPage = () => {
|
||||||
|
const [url, setUrl] = useState("#");
|
||||||
|
const [encoded, setEncoded] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setUrl(calculateUrl());
|
||||||
|
setEncoded(calculateEncoded());
|
||||||
|
}, []);
|
||||||
|
|
||||||
const calculateUrl = () => {
|
const calculateUrl = () => {
|
||||||
const linkId = sessionStorage.getItem("link_id");
|
const linkId = sessionStorage.getItem("link_id");
|
||||||
const keyHex = sessionStorage.getItem("key_hex");
|
const keyHex = sessionStorage.getItem("key_hex");
|
||||||
|
@ -11,15 +32,19 @@ const YouPage = () => {
|
||||||
return `${window.location.origin}/just/for/you/${linkId}#${keyHex}.${ivHex}`;
|
return `${window.location.origin}/just/for/you/${linkId}#${keyHex}.${ivHex}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const [url, _setUrl] = useState(calculateUrl());
|
const calculateEncoded = () => {
|
||||||
|
const encodedFile = sessionStorage.getItem("encoded_file");
|
||||||
|
const encodedMessage = sessionStorage.getItem("encoded_message");
|
||||||
|
return `${encodedMessage}${encodedFile}`;
|
||||||
|
};
|
||||||
|
|
||||||
const copyUrl = async () => {
|
const copyUrl = async () => {
|
||||||
try {
|
try {
|
||||||
navigator.clipboard.writeText(url);
|
navigator.clipboard.writeText(url);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
alert("Could not copy url to clipboard.");
|
alert("Could not copy url to clipboard.");
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
@ -47,20 +72,23 @@ const YouPage = () => {
|
||||||
looking eh?:
|
looking eh?:
|
||||||
</Label>
|
</Label>
|
||||||
</TextAlignWrapper>
|
</TextAlignWrapper>
|
||||||
<Input
|
<Input variant="disabled-light" id="encodedSecret" value={encoded} />
|
||||||
variant="disabled-light"
|
|
||||||
id="encodedSecret"
|
|
||||||
value={url}
|
|
||||||
/>
|
|
||||||
<Spacer space="3rem" />
|
<Spacer space="3rem" />
|
||||||
<SpaceBetweenContainer>
|
<SpaceBetweenContainer>
|
||||||
<Button variant="secondary" onClick={() => window.location.href = "/just/for"}>
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() => (window.location.href = "/just/for")}
|
||||||
|
>
|
||||||
<IconArrow arrowDirection="left" />
|
<IconArrow arrowDirection="left" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => {
|
<Button
|
||||||
sessionStorage.clear();
|
onClick={() => {
|
||||||
window.location.href = "/just";
|
sessionStorage.clear();
|
||||||
}}>Create Another Secret</Button>
|
window.location.href = "/just";
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Create Another Secret
|
||||||
|
</Button>
|
||||||
</SpaceBetweenContainer>
|
</SpaceBetweenContainer>
|
||||||
</CenteredContainer>
|
</CenteredContainer>
|
||||||
</CenteredContainer>
|
</CenteredContainer>
|
||||||
|
|
Loading…
Reference in New Issue