chore: sign document

This commit is contained in:
Mythie
2023-09-25 15:57:10 +10:00
parent 9164d301fd
commit 5904f6c5a8
12 changed files with 217 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import { PDFDocument } from 'pdf-lib';
import { prisma } from '@documenso/prisma';
import { DocumentStatus, SigningStatus } from '@documenso/prisma/client';
import { signPdf } from '@documenso/signing';
import { getFile } from '../../universal/upload/get-file';
import { putFile } from '../../universal/upload/put-file';
@ -71,12 +72,14 @@ export const sealDocument = async ({ documentId }: SealDocumentOptions) => {
const pdfBytes = await doc.save();
const pdfBuffer = await signPdf({ pdf: Buffer.from(pdfBytes) });
const { name, ext } = path.parse(document.title);
const { data: newData } = await putFile({
name: `${name}_signed${ext}`,
type: 'application/pdf',
arrayBuffer: async () => Promise.resolve(Buffer.from(pdfBytes)),
arrayBuffer: async () => Promise.resolve(pdfBuffer),
});
await prisma.documentData.update({