From cdf26b6614fc33f840a20596a064b20cc503275a Mon Sep 17 00:00:00 2001 From: enes Date: Fri, 15 Nov 2024 18:04:40 +0100 Subject: [PATCH] feat(signature): export signature files --- src/utils/file.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/utils/file.ts b/src/utils/file.ts index 38dd0f1..ec118df 100644 --- a/src/utils/file.ts +++ b/src/utils/file.ts @@ -1,3 +1,4 @@ +import axios from 'axios' import { MARK_TYPE_CONFIG } from '../components/getMarkComponents.tsx' import { NostrController } from '../controllers/NostrController.ts' import store from '../store/store.ts' @@ -50,11 +51,22 @@ export const getZipWithFiles = async ( m.value && encryptionKey ) { - // TODO - // extract draw with proper values - // save both pdf with marking and original hash files for signature - // ... + // Save the original file + const encryptedArrayBuffer = await axios.get(m.value, { + responseType: 'arraybuffer' + }) + const link = m.value.split('/') + zip.file( + `blossom/encrypted/${link[link.length - 1]}`, + new Blob([encryptedArrayBuffer.data]) + ) const decrypted = await fetchAndDecrypt(m.value, encryptionKey) + + // Save decrypted + zip.file( + `blossom/decrypted/${link[link.length - 1]}.json`, + new Blob([decrypted]) + ) marks[i].value = decrypted } } catch (error) {