fix: update verify to use file signature check

This commit is contained in:
enes 2024-08-20 11:44:34 +02:00
parent eca31cea4f
commit 18637bbbc1

View File

@ -170,17 +170,23 @@ export const VerifyPage = () => {
const [currentFileHashes, setCurrentFileHashes] = useState<{ const [currentFileHashes, setCurrentFileHashes] = useState<{
[key: string]: string | null [key: string]: string | null
}>(fileHashes) }>({})
const [files, setFiles] = useState<{ [filename: string]: PdfFile }>({}) const [files, setFiles] = useState<{ [filename: string]: PdfFile }>({})
const [currentFile, setCurrentFile] = useState<CurrentUserFile | null>(null) const [currentFile, setCurrentFile] = useState<CurrentUserFile | null>(null)
const [signatureFileHashes, setSignatureFileHashes] = useState<{
[key: string]: string
}>(fileHashes)
useEffect(() => {
setSignatureFileHashes(fileHashes)
}, [fileHashes])
useEffect(() => { useEffect(() => {
if (Object.entries(files).length > 0) { if (Object.entries(files).length > 0) {
const tmp = getCurrentUserFiles(files, fileHashes) const tmp = getCurrentUserFiles(files, fileHashes, signatureFileHashes)
setCurrentFile(tmp[0]) setCurrentFile(tmp[0])
} }
}, [fileHashes, files]) }, [signatureFileHashes, fileHashes, files])
const usersPubkey = useSelector((state: State) => state.auth.usersPubkey) const usersPubkey = useSelector((state: State) => state.auth.usersPubkey)
const nostrController = NostrController.getInstance() const nostrController = NostrController.getInstance()
@ -524,7 +530,11 @@ export const VerifyPage = () => {
<> <>
{currentFile !== null && ( {currentFile !== null && (
<FileList <FileList
files={getCurrentUserFiles(files, currentFileHashes)} files={getCurrentUserFiles(
files,
currentFileHashes,
signatureFileHashes
)}
currentFile={currentFile} currentFile={currentFile}
setCurrentFile={setCurrentFile} setCurrentFile={setCurrentFile}
handleDownload={handleExport} handleDownload={handleExport}
@ -537,7 +547,11 @@ export const VerifyPage = () => {
> >
<SlimPdfView <SlimPdfView
currentFile={currentFile} currentFile={currentFile}
files={getCurrentUserFiles(files, currentFileHashes)} files={getCurrentUserFiles(
files,
currentFileHashes,
signatureFileHashes
)}
parsedSignatureEvents={parsedSignatureEvents} parsedSignatureEvents={parsedSignatureEvents}
/> />
</StickySideColumns> </StickySideColumns>