From 32bb0ce48b1c2553e5b35d94a7cb1316b1038c4f Mon Sep 17 00:00:00 2001 From: John Shaw Date: Wed, 17 Apr 2024 10:07:39 +0200 Subject: [PATCH] refactor: removing unused components --- web/components/NotaryKey/index.scss | 45 ------- web/components/NotaryKey/index.tsx | 89 ------------- web/components/ProofDetails/index.scss | 45 ------- web/components/ProofDetails/index.tsx | 177 ------------------------- web/components/ProofViewer/index.tsx | 3 +- web/pages/FileDrop/index.tsx | 4 +- web/utils/index.tsx | 2 +- 7 files changed, 5 insertions(+), 360 deletions(-) delete mode 100644 web/components/NotaryKey/index.scss delete mode 100644 web/components/NotaryKey/index.tsx delete mode 100644 web/components/ProofDetails/index.scss delete mode 100644 web/components/ProofDetails/index.tsx diff --git a/web/components/NotaryKey/index.scss b/web/components/NotaryKey/index.scss deleted file mode 100644 index 9a0e07c..0000000 --- a/web/components/NotaryKey/index.scss +++ /dev/null @@ -1,45 +0,0 @@ -.button { - @apply bg-slate-100; - @apply text-slate-500; - @apply font-bold; - @apply px-2 py-0.5; - user-select: none; - - &:hover { - @apply text-slate-600; - @apply bg-slate-200; - } - - &:active { - @apply text-slate-700; - @apply bg-slate-300; - } - - &--primary { - @apply bg-primary/[0.8]; - @apply text-white; - - &:hover { - @apply bg-primary/[0.9]; - @apply text-white; - } - - &:active { - @apply bg-primary; - @apply text-white; - } - } - - &:disabled { - @apply opacity-50; - @apply select-none; - - &:hover { - @apply text-slate-400; - } - - &:active { - @apply text-slate-400; - } - } -} \ No newline at end of file diff --git a/web/components/NotaryKey/index.tsx b/web/components/NotaryKey/index.tsx deleted file mode 100644 index 31fad16..0000000 --- a/web/components/NotaryKey/index.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import React, { FormEvent, ReactElement, useState } from 'react'; -import { useDispatch } from 'react-redux'; -import { setKey } from '../../store/notaryKey'; -import keys from '../../utils/keys.json'; - -export default function NotaryKey(): ReactElement { - const dispatch = useDispatch(); - - const defaultKey: string = keys.defaultKey; - const notaryPseKey: string = keys.notaryPseKey; - - const [notaryKey, setNotaryKey] = useState(notaryPseKey); - const [errors, setError] = useState(null); - - const isValidPEMKey = (key: string): boolean => { - try { - const trimmedKey = key.trim(); - if ( - !trimmedKey.startsWith('-----BEGIN PUBLIC KEY-----') || - !trimmedKey.endsWith('-----END PUBLIC KEY-----') - ) { - setError('Invalid PEM format: header or footer missing'); - return false; - } - const keyContent = trimmedKey - .replace('-----BEGIN PUBLIC KEY-----', '') - .replace('-----END PUBLIC KEY-----', '') - .trim(); - - try { - atob(keyContent); - } catch (err) { - setError('Invalid Base64 encoding'); - return false; - } - - return true; - } catch (err) { - console.error('Error validating key:', err); - return false; - } - }; - - const handleInput = ( - e: - | FormEvent - | React.MouseEvent, - key?: string | undefined, - ) => { - setError(null); - const keyInput = - key !== undefined - ? key - : e.currentTarget instanceof HTMLTextAreaElement - ? e.currentTarget.value - : ''; - if (isValidPEMKey(keyInput)) { - setNotaryKey(keyInput); - dispatch(setKey(keyInput)); - } else { - setNotaryKey(keyInput); - } - }; - - return ( -
- - Change Notary Public Key: - -