diff --git a/src/components/DrawPDFFields/index.tsx b/src/components/DrawPDFFields/index.tsx index c23bf70..7d25996 100644 --- a/src/components/DrawPDFFields/index.tsx +++ b/src/components/DrawPDFFields/index.tsx @@ -8,10 +8,11 @@ import { ProfileMetadata, User } from '../../types'; import { PdfFile, DrawTool, MouseState, PdfPage, DrawnField, MarkType } from '../../types/drawing'; import { truncate } from 'lodash'; import { hexToNpub } from '../../utils'; +import { toPdfFiles } from '../../utils/pdf.ts' PDFJS.GlobalWorkerOptions.workerSrc = 'node_modules/pdfjs-dist/build/pdf.worker.mjs'; interface Props { - selectedFiles: any[] + selectedFiles: File[] users: User[] metadata: { [key: string]: ProfileMetadata } onDrawFieldsChange: (pdfFiles: PdfFile[]) => void @@ -100,7 +101,7 @@ export const DrawPDFFields = (props: Props) => { * It is re rendered and visible right away * * @param event Mouse event - * @param page PdfPage where press happened + * @param page PdfItem where press happened */ const onMouseDown = (event: any, page: PdfPage) => { // Proceed only if left click @@ -153,7 +154,7 @@ export const DrawPDFFields = (props: Props) => { * After {@link onMouseDown} create an drawing element, this function gets called on every pixel moved * which alters the newly created drawing element, resizing it while mouse move * @param event Mouse event - * @param page PdfPage where moving is happening + * @param page PdfItem where moving is happening */ const onMouseMove = (event: any, page: PdfPage) => { if (mouseState.clicked && selectedTool) { @@ -315,73 +316,12 @@ export const DrawPDFFields = (props: Props) => { * creates the pdfFiles object and sets to a state */ const parsePdfPages = async () => { - const pdfFiles: PdfFile[] = [] - - for (const file of selectedFiles) { - if (file.type.toLowerCase().includes('pdf')) { - const data = await readPdf(file) - const pages = await pdfToImages(data) - - pdfFiles.push({ - file: file, - pages: pages, - expanded: false - }) - } - } + const pdfFiles: PdfFile[] = await toPdfFiles(selectedFiles); + console.log('pdf files: ', pdfFiles); setPdfFiles(pdfFiles) } - /** - * Converts pdf to the images - * @param data pdf file bytes - */ - const pdfToImages = async (data: any): Promise => { - const images: string[] = []; - const pdf = await PDFJS.getDocument(data).promise; - const canvas = document.createElement("canvas"); - - for (let i = 0; i < pdf.numPages; i++) { - const page = await pdf.getPage(i + 1); - const viewport = page.getViewport({ scale: 3 }); - const context = canvas.getContext("2d"); - canvas.height = viewport.height; - canvas.width = viewport.width; - await page.render({ canvasContext: context!, viewport: viewport }).promise; - images.push(canvas.toDataURL()); - } - - return Promise.resolve(images.map((image) => { - return { - image, - drawnFields: [] - } - })) - } - - /** - * Reads the pdf file binaries - */ - const readPdf = (file: File) => { - return new Promise((resolve, reject) => { - const reader = new FileReader(); - - reader.onload = (e: any) => { - const data = e.target.result - - resolve(data) - }; - - reader.onerror = (err) => { - console.error('err', err) - reject(err) - }; - - reader.readAsDataURL(file); - }) - } - /** * * @returns if expanded pdf accordion is present diff --git a/src/components/DrawPDFFields/style.module.scss b/src/components/DrawPDFFields/style.module.scss index 4793f44..e3e7856 100644 --- a/src/components/DrawPDFFields/style.module.scss +++ b/src/components/DrawPDFFields/style.module.scss @@ -59,13 +59,17 @@ .drawingRectangle { position: absolute; border: 1px solid #01aaad; - width: 40px; - height: 40px; z-index: 50; background-color: #01aaad4b; cursor: pointer; display: flex; justify-content: center; + align-items: center; + + &.nonEditable { + cursor: default; + visibility: hidden; + } .resizeHandle { position: absolute; diff --git a/src/components/PDFView/Mark.tsx b/src/components/PDFView/Mark.tsx new file mode 100644 index 0000000..e69de29 diff --git a/src/components/PDFView/PdfItem.tsx b/src/components/PDFView/PdfItem.tsx new file mode 100644 index 0000000..23bbff7 --- /dev/null +++ b/src/components/PDFView/PdfItem.tsx @@ -0,0 +1,32 @@ +import { PdfFile } from '../../types/drawing.ts' +import { CurrentUserMark } from '../../types/mark.ts' +import PdfPageItem from './PdfPageItem.tsx'; + +interface PdfItemProps { + pdfFile: PdfFile + currentUserMarks: CurrentUserMark[] + handleMarkClick: (id: number) => void + selectedMarkValue: string + selectedMark: CurrentUserMark | null +} + +const PdfItem = ({ pdfFile, currentUserMarks, handleMarkClick, selectedMarkValue, selectedMark }: PdfItemProps) => { + const filterByPage = (marks: CurrentUserMark[], page: number): CurrentUserMark[] => { + return marks.filter((m) => m.mark.location.page === page); + } + return ( + pdfFile.pages.map((page, i) => { + return ( + + ) + })) +} + +export default PdfItem \ No newline at end of file diff --git a/src/components/PDFView/PdfMarkItem.tsx b/src/components/PDFView/PdfMarkItem.tsx new file mode 100644 index 0000000..bb4cdb9 --- /dev/null +++ b/src/components/PDFView/PdfMarkItem.tsx @@ -0,0 +1,38 @@ +import { CurrentUserMark } from '../../types/mark.ts' +import styles from '../DrawPDFFields/style.module.scss' +import { inPx } from '../../utils/pdf.ts' + +interface PdfMarkItemProps { + userMark: CurrentUserMark + handleMarkClick: (id: number) => void + selectedMarkValue: string + selectedMark: CurrentUserMark | null +} + +//selectedMark represents the mark that the user is actively editing +// selectedMarkValue representsnthe edited value +// userMark is part of the overall currentUserMark array + +const PdfMarkItem = ({ selectedMark, handleMarkClick, selectedMarkValue, userMark }: PdfMarkItemProps) => { + const { location } = userMark.mark; + const handleClick = () => handleMarkClick(userMark.mark.id); + const getMarkValue = () => ( + selectedMark?.mark.id === userMark.mark.id + ? selectedMarkValue + : userMark.mark.value + ) + return ( +
{getMarkValue()}
+ ) +} + +export default PdfMarkItem \ No newline at end of file diff --git a/src/components/PDFView/PdfMarking.tsx b/src/components/PDFView/PdfMarking.tsx new file mode 100644 index 0000000..8dc0489 --- /dev/null +++ b/src/components/PDFView/PdfMarking.tsx @@ -0,0 +1,95 @@ +import { Box } from '@mui/material' +import styles from '../../pages/sign/style.module.scss' +import PdfView from './index.tsx' +import MarkFormField from '../../pages/sign/MarkFormField.tsx' +import { PdfFile } from '../../types/drawing.ts' +import { CurrentUserMark, Mark } from '../../types/mark.ts' +import { useState, useEffect } from 'react' +import { + findNextCurrentUserMark, + isCurrentUserMarksComplete, + updateCurrentUserMarks, +} from '../../utils/mark.ts' + +import { EMPTY } from '../../utils/const.ts' + +interface PdfMarkingProps { + files: { pdfFile: PdfFile, filename: string, hash: string | null }[], + currentUserMarks: CurrentUserMark[], + setIsReadyToSign: (isReadyToSign: boolean) => void, + setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void, + setUpdatedMarks: (markToUpdate: Mark) => void +} + +const PdfMarking = (props: PdfMarkingProps) => { + const { + files, + currentUserMarks, + setIsReadyToSign, + setCurrentUserMarks, + setUpdatedMarks + } = props + const [selectedMark, setSelectedMark] = useState(null) + const [selectedMarkValue, setSelectedMarkValue] = useState("") + + useEffect(() => { + setSelectedMark(findNextCurrentUserMark(currentUserMarks) || null) + }, [currentUserMarks]) + + const handleMarkClick = (id: number) => { + const nextMark = currentUserMarks.find((mark) => mark.mark.id === id); + setSelectedMark(nextMark!); + setSelectedMarkValue(nextMark?.mark.value ?? EMPTY); + } + + const handleSubmit = (event: any) => { + event.preventDefault(); + if (!selectedMarkValue || !selectedMark) return; + + const updatedMark: CurrentUserMark = { + ...selectedMark, + mark: { + ...selectedMark.mark, + value: selectedMarkValue + }, + isCompleted: true + } + + setSelectedMarkValue(EMPTY) + const updatedCurrentUserMarks = updateCurrentUserMarks(currentUserMarks, updatedMark); + setCurrentUserMarks(updatedCurrentUserMarks) + setSelectedMark(findNextCurrentUserMark(updatedCurrentUserMarks) || null) + console.log(isCurrentUserMarksComplete(updatedCurrentUserMarks)) + setIsReadyToSign(isCurrentUserMarksComplete(updatedCurrentUserMarks)) + setUpdatedMarks(updatedMark.mark) + } + + const handleChange = (event: any) => setSelectedMarkValue(event.target.value) + + return ( + <> + + { + currentUserMarks?.length > 0 && ( + )} + { + selectedMark !== null && ( + + )} + + + ) +} + +export default PdfMarking \ No newline at end of file diff --git a/src/components/PDFView/PdfPageItem.tsx b/src/components/PDFView/PdfPageItem.tsx new file mode 100644 index 0000000..20a3cce --- /dev/null +++ b/src/components/PDFView/PdfPageItem.tsx @@ -0,0 +1,43 @@ +import styles from '../DrawPDFFields/style.module.scss' +import { PdfPage } from '../../types/drawing.ts' +import { CurrentUserMark } from '../../types/mark.ts' +import PdfMarkItem from './PdfMarkItem.tsx' +interface PdfPageProps { + page: PdfPage + currentUserMarks: CurrentUserMark[] + handleMarkClick: (id: number) => void + selectedMarkValue: string + selectedMark: CurrentUserMark | null +} + +const PdfPageItem = ({ page, currentUserMarks, handleMarkClick, selectedMarkValue, selectedMark }: PdfPageProps) => { + return ( +
+ + { + currentUserMarks.map((m, i) => ( + + ))} +
+ ) +} + +export default PdfPageItem \ No newline at end of file diff --git a/src/components/PDFView/index.tsx b/src/components/PDFView/index.tsx new file mode 100644 index 0000000..d9cd1fe --- /dev/null +++ b/src/components/PDFView/index.tsx @@ -0,0 +1,39 @@ +import { PdfFile } from '../../types/drawing.ts' +import { Box } from '@mui/material' +import PdfItem from './PdfItem.tsx' +import { CurrentUserMark } from '../../types/mark.ts' + +interface PdfViewProps { + files: { pdfFile: PdfFile, filename: string, hash: string | null }[] + currentUserMarks: CurrentUserMark[] + handleMarkClick: (id: number) => void + selectedMarkValue: string + selectedMark: CurrentUserMark | null +} + +const PdfView = ({ files, currentUserMarks, handleMarkClick, selectedMarkValue, selectedMark }: PdfViewProps) => { + const filterByFile = (currentUserMarks: CurrentUserMark[], hash: string): CurrentUserMark[] => { + return currentUserMarks.filter((currentUserMark) => currentUserMark.mark.pdfFileHash === hash) + } + return ( + + { + files.map(({ pdfFile, hash }, i) => { + if (!hash) return + return ( + + ) + }) + } + + ) +} + +export default PdfView; \ No newline at end of file diff --git a/src/components/PDFView/style.module.scss b/src/components/PDFView/style.module.scss new file mode 100644 index 0000000..2e6e519 --- /dev/null +++ b/src/components/PDFView/style.module.scss @@ -0,0 +1,16 @@ +.imageWrapper { + display: flex; + justify-content: center; + align-items: center; + width: 100%; /* Adjust as needed */ + height: 100%; /* Adjust as needed */ + overflow: hidden; /* Ensure no overflow */ + border: 1px solid #ccc; /* Optional: for visual debugging */ + background-color: #e0f7fa; /* Optional: for visual debugging */ +} + +.image { + max-width: 100%; + max-height: 100%; + object-fit: contain; /* Ensure the image fits within the container */ +} \ No newline at end of file diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index 63df583..fd77258 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -62,6 +62,8 @@ import { import styles from './style.module.scss' import { PdfFile } from '../../types/drawing' import { DrawPDFFields } from '../../components/DrawPDFFields' +import { Mark } from '../../types/mark.ts' +import { v4 as uuidv4 } from 'uuid'; export const CreatePage = () => { const navigate = useNavigate() @@ -339,26 +341,29 @@ export const CreatePage = () => { return fileHashes } - const createMarkConfig = (fileHashes: { [key: string]: string }) => { - let markConfig: any = {} - - drawnPdfs.forEach(drawnPdf => { - const fileHash = fileHashes[drawnPdf.file.name] - - drawnPdf.pages.forEach((page, pageIndex) => { - page.drawnFields.forEach(drawnField => { - if (!markConfig[drawnField.counterpart]) markConfig[drawnField.counterpart] = {} - if (!markConfig[drawnField.counterpart][fileHash]) markConfig[drawnField.counterpart][fileHash] = [] - - markConfig[drawnField.counterpart][fileHash].push({ - markType: drawnField.type, - markLocation: `P:${pageIndex};X:${drawnField.left};Y:${drawnField.top}` - }) + const createMarkConfig = (fileHashes: { [key: string]: string }) : Mark[] => { + return drawnPdfs.flatMap((drawnPdf) => { + const fileHash = fileHashes[drawnPdf.file.name]; + return drawnPdf.pages.flatMap((page, index) => { + return page.drawnFields.map((drawnField) => { + return { + type: drawnField.type, + location: { + page: index, + top: drawnField.top, + left: drawnField.left, + height: drawnField.height, + width: drawnField.width, + }, + npub: drawnField.counterpart, + pdfFileHash: fileHash + } }) }) }) - - return markConfig + .map((mark, index) => { + return {...mark, id: index } + }); } // Handle errors during zip file generation @@ -510,6 +515,8 @@ export const CreatePage = () => { const viewers = users.filter((user) => user.role === UserRole.viewer) const markConfig = createMarkConfig(fileHashes) + console.log('mark config: ', markConfig) + const content: CreateSignatureEventContent = { signers: signers.map((signer) => hexToNpub(signer.pubkey)), viewers: viewers.map((viewer) => hexToNpub(viewer.pubkey)), diff --git a/src/pages/sign/MarkFormField.tsx b/src/pages/sign/MarkFormField.tsx new file mode 100644 index 0000000..aee4c29 --- /dev/null +++ b/src/pages/sign/MarkFormField.tsx @@ -0,0 +1,34 @@ +import { CurrentUserMark, Mark } from '../../types/mark.ts' +import styles from './style.module.scss' +import { Box, Button, TextField } from '@mui/material' + +import { MARK_TYPE_TRANSLATION } from '../../utils/const.ts' + +interface MarkFormFieldProps { + handleSubmit: (event: any) => void + handleChange: (event: any) => void + selectedMark: CurrentUserMark + selectedMarkValue: string +} + +const MarkFormField = (props: MarkFormFieldProps) => { + const { handleSubmit, handleChange, selectedMark, selectedMarkValue } = props; + const getSubmitButton = () => selectedMark.isLast ? 'Complete' : 'Next'; + return ( +
+ + + + +
+ ) +} + +export default MarkFormField; \ No newline at end of file diff --git a/src/pages/sign/index.tsx b/src/pages/sign/index.tsx index 5204ea7..02631dc 100644 --- a/src/pages/sign/index.tsx +++ b/src/pages/sign/index.tsx @@ -16,13 +16,13 @@ import { State } from '../../store/rootReducer' import { CreateSignatureEventContent, Meta, SignedEvent } from '../../types' import { decryptArrayBuffer, - encryptArrayBuffer, + encryptArrayBuffer, extractMarksFromSignedMeta, extractZipUrlAndEncryptionKey, generateEncryptionKey, - generateKeysFile, + generateKeysFile, getFilesWithHashes, getHash, hexToNpub, - isOnline, + isOnline, loadZip, now, npubToHex, parseJson, @@ -33,6 +33,17 @@ import { } from '../../utils' import { DisplayMeta } from './internal/displayMeta' import styles from './style.module.scss' +import { PdfFile } from '../../types/drawing.ts' +import { convertToPdfFile } from '../../utils/pdf.ts' +// import PdfView from '../../components/PDFView' +import { CurrentUserMark, Mark } from '../../types/mark.ts' +import { getLastSignersSig } from '../../utils/sign.ts' +import { + filterMarksByPubkey, + getCurrentUserMarks, + isCurrentUserMarksComplete, updateMarks +} from '../../utils/mark.ts' +import PdfMarking from '../../components/PDFView/PdfMarking.tsx' enum SignedStatus { Fully_Signed, User_Is_Next_Signer, @@ -58,7 +69,7 @@ export const SignPage = () => { const [selectedFile, setSelectedFile] = useState(null) - const [files, setFiles] = useState<{ [filename: string]: ArrayBuffer }>({}) + const [files, setFiles] = useState<{ [filename: string]: PdfFile }>({}) const [isLoading, setIsLoading] = useState(true) const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('') @@ -70,6 +81,7 @@ export const SignPage = () => { const [signers, setSigners] = useState<`npub1${string}`[]>([]) const [viewers, setViewers] = useState<`npub1${string}`[]>([]) + const [marks, setMarks] = useState([]) const [creatorFileHashes, setCreatorFileHashes] = useState<{ [key: string]: string }>({}) @@ -88,6 +100,8 @@ export const SignPage = () => { const [authUrl, setAuthUrl] = useState() const nostrController = NostrController.getInstance() + const [currentUserMarks, setCurrentUserMarks] = useState([]); + const [isReadyToSign, setIsReadyToSign] = useState(false); useEffect(() => { if (signers.length > 0) { @@ -178,6 +192,16 @@ export const SignPage = () => { setViewers(createSignatureContent.viewers) setCreatorFileHashes(createSignatureContent.fileHashes) setSubmittedBy(createSignatureEvent.pubkey) + setMarks(createSignatureContent.markConfig); + + if (usersPubkey) { + const metaMarks = filterMarksByPubkey(createSignatureContent.markConfig, usersPubkey!) + const signedMarks = extractMarksFromSignedMeta(meta) + const currentUserMarks = getCurrentUserMarks(metaMarks, signedMarks); + setCurrentUserMarks(currentUserMarks); + // setCurrentUserMark(findNextCurrentUserMark(currentUserMarks) || null) + setIsReadyToSign(isCurrentUserMarksComplete(currentUserMarks)) + } setSignedBy(Object.keys(meta.docSignatures) as `npub1${string}`[]) } @@ -188,6 +212,7 @@ export const SignPage = () => { }, [meta]) useEffect(() => { + // online mode - from create and home page views if (metaInNavState) { const processSigit = async () => { setIsLoading(true) @@ -209,6 +234,7 @@ export const SignPage = () => { .then((res) => { handleArrayBufferFromBlossom(res.data, encryptionKey) setMeta(metaInNavState) + console.log('meta in nav state runs.') }) .catch((err) => { console.error(`error occurred in getting file from ${zipUrl}`, err) @@ -262,16 +288,13 @@ export const SignPage = () => { if (!decrypted) return - const zip = await JSZip.loadAsync(decrypted).catch((err) => { - console.log('err in loading zip file :>> ', err) - toast.error(err.message || 'An error occurred in loading zip file.') + const zip = await loadZip(decrypted) + if (!zip) { setIsLoading(false) - return null - }) + return + } - if (!zip) return - - const files: { [filename: string]: ArrayBuffer } = {} + const files: { [filename: string]: PdfFile } = {} const fileHashes: { [key: string]: string | null } = {} const fileNames = Object.values(zip.files).map((entry) => entry.name) @@ -285,7 +308,7 @@ export const SignPage = () => { ) if (arrayBuffer) { - files[fileName] = arrayBuffer + files[fileName] = await convertToPdfFile(arrayBuffer, fileName); const hash = await getHash(arrayBuffer) if (hash) { @@ -300,6 +323,11 @@ export const SignPage = () => { setCurrentFileHashes(fileHashes) } + const setUpdatedMarks = (markToUpdate: Mark) => { + const updatedMarks = updateMarks(marks, markToUpdate) + setMarks(updatedMarks) + } + const parseKeysJson = async (zip: JSZip) => { const keysFileContent = await readContentOfZipEntry( zip, @@ -323,11 +351,7 @@ export const SignPage = () => { const decrypt = async (file: File) => { setLoadingSpinnerDesc('Decrypting file') - const zip = await JSZip.loadAsync(file).catch((err) => { - console.log('err in loading zip file :>> ', err) - toast.error(err.message || 'An error occurred in loading zip file.') - return null - }) + const zip = await loadZip(file); if (!zip) return const parsedKeysJson = await parseKeysJson(zip) @@ -398,32 +422,27 @@ export const SignPage = () => { setLoadingSpinnerDesc('Parsing zip file') - const zip = await JSZip.loadAsync(decryptedZipFile).catch((err) => { - console.log('err in loading zip file :>> ', err) - toast.error(err.message || 'An error occurred in loading zip file.') - return null - }) - + const zip = await loadZip(decryptedZipFile) if (!zip) return - const files: { [filename: string]: ArrayBuffer } = {} + const files: { [filename: string]: PdfFile } = {} const fileHashes: { [key: string]: string | null } = {} const fileNames = Object.values(zip.files) .filter((entry) => entry.name.startsWith('files/') && !entry.dir) .map((entry) => entry.name) + .map((entry) => entry.replace(/^files\//, '')) // generate hashes for all entries in files folder of zipArchive // these hashes can be used to verify the originality of files - for (let fileName of fileNames) { + for (const fileName of fileNames) { const arrayBuffer = await readContentOfZipEntry( zip, fileName, 'arraybuffer' ) - fileName = fileName.replace(/^files\//, '') if (arrayBuffer) { - files[fileName] = arrayBuffer + files[fileName] = await convertToPdfFile(arrayBuffer, fileName); const hash = await getHash(arrayBuffer) if (hash) { @@ -487,7 +506,10 @@ export const SignPage = () => { const prevSig = getPrevSignersSig(hexToNpub(usersPubkey!)) if (!prevSig) return - const signedEvent = await signEventForMeta(prevSig) + const marks = getSignerMarksForMeta() + if (!marks) return + + const signedEvent = await signEventForMeta({ prevSig, marks }) if (!signedEvent) return const updatedMeta = updateMetaSignatures(meta, signedEvent) @@ -501,14 +523,19 @@ export const SignPage = () => { } // Sign the event for the meta file - const signEventForMeta = async (prevSig: string) => { + const signEventForMeta = async (signerContent: { prevSig: string, marks: Mark[] }) => { return await signEventForMetaFile( - JSON.stringify({ prevSig }), + JSON.stringify(signerContent), nostrController, setIsLoading ) } + const getSignerMarksForMeta = (): Mark[] | undefined => { + if (currentUserMarks.length === 0) return; + return currentUserMarks.map(( { mark }: CurrentUserMark) => mark); + } + // Update the meta signatures const updateMetaSignatures = (meta: Meta, signedEvent: SignedEvent): Meta => { const metaCopy = _.cloneDeep(meta) @@ -526,7 +553,7 @@ export const SignPage = () => { encryptionKey: string ): Promise => { // Get the current timestamp in seconds - const unixNow = Math.floor(Date.now() / 1000) + const unixNow = now() const blob = new Blob([encryptedArrayBuffer]) // Create a File object with the Blob data const file = new File([blob], `compressed.sigit`, { @@ -672,7 +699,9 @@ export const SignPage = () => { setIsLoading(true) setLoadingSpinnerDesc('Signing nostr event') - const prevSig = getLastSignersSig() + if (!meta) return; + + const prevSig = getLastSignersSig(meta, signers) if (!prevSig) return const signedEvent = await signEventForMetaFile( @@ -722,7 +751,7 @@ export const SignPage = () => { if (!arrayBuffer) return const blob = new Blob([arrayBuffer]) - const unixNow = Math.floor(Date.now() / 1000) + const unixNow = now() saveAs(blob, `exported-${unixNow}.sigit.zip`) setIsLoading(false) @@ -768,7 +797,7 @@ export const SignPage = () => { const finalZipFile = await createFinalZipFile(encryptedArrayBuffer, key) if (!finalZipFile) return - const unixNow = Math.floor(Date.now() / 1000) + const unixNow = now() saveAs(finalZipFile, `exported-${unixNow}.sigit.zip`) } @@ -805,37 +834,6 @@ export const SignPage = () => { } } - /** - * This function returns the signature of last signer - * It will be used in the content of export signature's signedEvent - */ - const getLastSignersSig = () => { - if (!meta) return null - - // if there're no signers then use creator's signature - if (signers.length === 0) { - try { - const createSignatureEvent: Event = JSON.parse(meta.createSignature) - return createSignatureEvent.sig - } catch (error) { - return null - } - } - - // get last signer - const lastSigner = signers[signers.length - 1] - - // get the signature of last signer - try { - const lastSignatureEvent: Event = JSON.parse( - meta.docSignatures[lastSigner] - ) - return lastSignatureEvent.sig - } catch (error) { - return null - } - } - if (authUrl) { return (