diff --git a/src/App.tsx b/src/App.tsx index cb008bd..4dab8a1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { hot } from 'react-hot-loader/root'; -import { Layout } from 'antd'; +import { Layout, Menu } from 'antd'; import { GithubProvider } from './contexts/Github'; import { EncryptionProvider } from './contexts/Encryption'; import { DecryptionProvider } from './contexts/Decryption'; @@ -11,6 +11,8 @@ const App: React.FC = () => ( + + diff --git a/src/contexts/Decryption.tsx b/src/contexts/Decryption.tsx index e7232ea..f2778cf 100644 --- a/src/contexts/Decryption.tsx +++ b/src/contexts/Decryption.tsx @@ -8,6 +8,7 @@ interface DecryptionContextType { publicKey: string | undefined; privateKey: string | undefined; createKey: (name: string, email: string) => void; + deleteKey: () => void; files: {[id: string]: FileType}; addFile: (file: File) => Promise; deleteFile: (id: string) => void; @@ -24,6 +25,7 @@ const DecryptionContext = createContext({ privateKey: undefined, files: {}, createKey: async () => { throw new Error('Not using provider'); }, + deleteKey: async () => { throw new Error('Not using provider'); }, addFile: async () => { throw new Error('Not using provider'); }, deleteFile: async () => { throw new Error('Not using provider'); }, }); @@ -71,6 +73,12 @@ const DecryptionProvider: React.FC = ({ run(); }, []); + const deleteKey = () => { + setPublicKey(undefined); + setPrivateKey(undefined); + localStorage.removeItem('key'); + }; + const createKey = async () => { const key = await openpgp.generateKey({ userIds: [{ name: 'unknown unknown', email: 'unknown@unknown.foo'}], @@ -103,6 +111,7 @@ const DecryptionProvider: React.FC = ({ publicKey, privateKey, createKey, + deleteKey, files, addFile, deleteFile, diff --git a/src/screens/SetupKey.tsx b/src/screens/SetupKey.tsx index 2527cc5..46d53be 100644 --- a/src/screens/SetupKey.tsx +++ b/src/screens/SetupKey.tsx @@ -1,5 +1,5 @@ import React, { useContext, useState, useCallback } from 'react'; -import { Space, Typography, Input, Button, Form } from 'antd'; +import { Popconfirm, Space, Typography, Input, Button, Form } from 'antd'; import DecryptionContext from '../contexts/Decryption'; import { downloadLink } from '../helpers/files'; import { @@ -12,6 +12,7 @@ import { const SetupKey: React.FC = () => { const { createKey, + deleteKey, publicKey, } = useContext(DecryptionContext); @@ -86,15 +87,28 @@ const SetupKey: React.FC = () => {

Remember that you need to go to this website on this device to decrypt the files after receiving them

- - + + + + + + ); }