Compare commits

..

No commits in common. "7f172178a15d1b2f07f06ba43f3f7d5ab9818671" and "b6846c000669b3a424d08f99e7f95a0b7156090d" have entirely different histories.

4 changed files with 37 additions and 22 deletions

View File

@ -24,7 +24,7 @@
}
.container {
color: black;
color: black
}
.left {
@ -51,8 +51,7 @@
}
.image-placeholder {
width: 100%;
height: auto;
width: 150px;
}
.link {

View File

@ -804,7 +804,7 @@ export const SignPage = () => {
navigate(appPublicRoutes.verify)
}
const handleEncryptedExport = async () => {
const handleExportSigit = async () => {
if (Object.entries(files).length === 0 || !meta) return
const zip = new JSZip()
@ -943,7 +943,7 @@ export const SignPage = () => {
{signedStatus === SignedStatus.Fully_Signed && (
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
<Button onClick={handleExport} variant="contained">
Export Sigit
Export
</Button>
</Box>
)}
@ -958,8 +958,8 @@ export const SignPage = () => {
{isSignerOrCreator && (
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
<Button onClick={handleEncryptedExport} variant="contained">
Export Encrypted Sigit
<Button onClick={handleExportSigit} variant="contained">
Export Sigit
</Button>
</Box>
)}

View File

@ -8,6 +8,7 @@ import { NostrController } from '../../controllers'
import { DocSignatureEvent, Meta } from '../../types'
import {
decryptArrayBuffer,
extractMarksFromSignedMeta,
getHash,
hexToNpub,
unixNow,
@ -19,7 +20,13 @@ import {
import styles from './style.module.scss'
import { useLocation } from 'react-router-dom'
import axios from 'axios'
import { FONT_SIZE, FONT_TYPE, inPx } from '../../utils/pdf.ts'
import {
addMarks,
FONT_SIZE,
FONT_TYPE,
groupMarksByFileNamePage,
inPx
} from '../../utils/pdf.ts'
import { useAppSelector } from '../../hooks/store'
import { getLastSignersSig } from '../../utils/sign.ts'
import { saveAs } from 'file-saver'
@ -31,11 +38,7 @@ import FileList from '../../components/FileList'
import { CurrentUserFile } from '../../types/file.ts'
import { Mark } from '../../types/mark.ts'
import React from 'react'
import {
convertToSigitFile,
getZipWithFiles,
SigitFile
} from '../../utils/file.ts'
import { convertToSigitFile, SigitFile } from '../../utils/file.ts'
import { FileDivider } from '../../components/FileDivider.tsx'
import { ExtensionFileBox } from '../../components/ExtensionFileBox.tsx'
import { useScale } from '../../hooks/useScale.tsx'
@ -355,7 +358,7 @@ export const VerifyPage = () => {
setIsLoading(false)
}
const handleMarkedExport = async () => {
const handleExport = async () => {
if (Object.entries(files).length === 0 || !meta || !usersPubkey) return
const usersNpub = hexToNpub(usersPubkey)
@ -385,9 +388,22 @@ export const VerifyPage = () => {
const updatedMeta = { ...meta, exportSignature }
const stringifiedMeta = JSON.stringify(updatedMeta, null, 2)
const zip = await getZipWithFiles(updatedMeta, files)
const zip = new JSZip()
zip.file('meta.json', stringifiedMeta)
const marks = extractMarksFromSignedMeta(updatedMeta)
const marksByPage = groupMarksByFileNamePage(marks)
for (const [fileName, file] of Object.entries(files)) {
if (file.isPdf) {
// Draw marks into PDF file and generate a brand new blob
const blob = await addMarks(file, marksByPage[fileName])
zip.file(`files/${fileName}`, blob)
} else {
zip.file(`files/${fileName}`, file)
}
}
const arrayBuffer = await zip
.generateAsync({
type: 'arraybuffer',
@ -454,7 +470,7 @@ export const VerifyPage = () => {
)}
currentFile={currentFile}
setCurrentFile={setCurrentFile}
handleDownload={handleMarkedExport}
handleDownload={handleExport}
downloadLabel="Download Sigit"
/>
)

View File

@ -19,14 +19,14 @@ export const getZipWithFiles = async (
const marksByFileNamePage = groupMarksByFileNamePage(marks)
for (const [fileName, file] of Object.entries(files)) {
// Handle PDF Files, add marks
if (file.isPdf) {
// Handle PDF Files
const blob = await addMarks(file, marksByFileNamePage[fileName])
zip.file(`marked/${fileName}`, blob)
zip.file(`files/${fileName}`, blob)
} else {
// Handle other files
zip.file(`files/${fileName}`, file)
}
// Save original files
zip.file(`files/${fileName}`, file)
}
return zip