Add encryption (#642)

* Add encryption

In order to avoid the server being able to read the content of the scene, this PR implements local encryption and decryption. This implements the algorithm described in #610.

Right now the server doesn't support uploading binary files. I mocked the server with comments. @lipis, could you add support on the server and update this PR? I added a bunch of TODO: that tell you where to comment/uncomment in order to get the server flow going.

To test locally right now:
- Import: Open http://localhost:3000/#json=1234,5oYVOnGpWYPPTz19-PMYYw and see a square
- Export: Click the export link and see the right url with the private key + the encrypted binary in the console

Fixes #610

* backend_v2

* v2
This commit is contained in:
Christopher Chedeau 2020-02-05 07:35:51 -08:00 committed by GitHub
parent c7d7d65e1b
commit 2dd1796351
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 137 additions and 49 deletions

View file

@ -5,7 +5,7 @@ import { t } from "../i18n";
interface StoredScenesListProps {
scenes: PreviousScene[];
currentId?: string;
onChange: (selectedId: string) => {};
onChange: (selectedId: string, k?: string) => {};
}
export function StoredScenesList({
@ -14,19 +14,20 @@ export function StoredScenesList({
onChange,
}: StoredScenesListProps) {
return (
<React.Fragment>
<select
className="stored-ids-select"
onChange={({ currentTarget }) => onChange(currentTarget.value)}
value={currentId}
title={t("buttons.previouslyLoadedScenes")}
>
{scenes.map(scene => (
<option key={scene.id} value={scene.id}>
id={scene.id}
</option>
))}
</select>
</React.Fragment>
<select
className="stored-ids-select"
onChange={({ currentTarget }) => {
const scene = scenes[(currentTarget.value as unknown) as number];
onChange(scene.id, scene.k);
}}
value={currentId}
title={t("buttons.previouslyLoadedScenes")}
>
{scenes.map((scene, i) => (
<option key={i} value={i}>
id={scene.id}
</option>
))}
</select>
);
}