refactor(signature): save only decrypted signature files on export

This commit is contained in:
enes 2024-11-18 13:49:39 +01:00
parent a1c308727f
commit f72ad37ec0

View File

@ -1,4 +1,3 @@
import axios from 'axios'
import { MARK_TYPE_CONFIG } from '../components/getMarkComponents.tsx' import { MARK_TYPE_CONFIG } from '../components/getMarkComponents.tsx'
import { NostrController } from '../controllers/NostrController.ts' import { NostrController } from '../controllers/NostrController.ts'
import store from '../store/store.ts' import store from '../store/store.ts'
@ -51,20 +50,13 @@ export const getZipWithFiles = async (
m.value && m.value &&
encryptionKey encryptionKey
) { ) {
// Save the original file // Fetch and decrypt the original file
const encryptedArrayBuffer = await axios.get(m.value, {
responseType: 'arraybuffer'
})
const link = m.value.split('/') const link = m.value.split('/')
zip.file(
`blossom/encrypted/${link[link.length - 1]}`,
new Blob([encryptedArrayBuffer.data])
)
const decrypted = await fetchAndDecrypt(m.value, encryptionKey) const decrypted = await fetchAndDecrypt(m.value, encryptionKey)
// Save decrypted // Save decrypted
zip.file( zip.file(
`blossom/decrypted/${link[link.length - 1]}.json`, `signatures/${link[link.length - 1]}.json`,
new Blob([decrypted]) new Blob([decrypted])
) )
marks[i].value = decrypted marks[i].value = decrypted