mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 03:01:59 +10:00
feat: add prisma json types (#1583)
This commit is contained in:
@ -26,9 +26,9 @@ export const updateSigningPlaceholder = ({ pdf }: UpdateSigningPlaceholderOption
|
||||
const newByteRange = `[${byteRange.join(' ')}]`.padEnd(byteRangeSlice.length, ' ');
|
||||
|
||||
const updatedPdf = Buffer.concat([
|
||||
pdf.subarray(0, byteRangeStart),
|
||||
Buffer.from(newByteRange),
|
||||
pdf.subarray(byteRangeEnd + 1),
|
||||
new Uint8Array(pdf.subarray(0, byteRangeStart)),
|
||||
new Uint8Array(Buffer.from(newByteRange)),
|
||||
new Uint8Array(pdf.subarray(byteRangeEnd + 1)),
|
||||
]);
|
||||
|
||||
if (updatedPdf.length !== length) {
|
||||
|
||||
@ -23,13 +23,14 @@ export const signWithGoogleCloudHSM = async ({ pdf }: SignWithGoogleCloudHSMOpti
|
||||
process.env.NEXT_PRIVATE_SIGNING_GCLOUD_APPLICATION_CREDENTIALS_CONTENTS
|
||||
) {
|
||||
if (!fs.existsSync(process.env.GOOGLE_APPLICATION_CREDENTIALS)) {
|
||||
fs.writeFileSync(
|
||||
process.env.GOOGLE_APPLICATION_CREDENTIALS,
|
||||
const contents = new Uint8Array(
|
||||
Buffer.from(
|
||||
process.env.NEXT_PRIVATE_SIGNING_GCLOUD_APPLICATION_CREDENTIALS_CONTENTS,
|
||||
'base64',
|
||||
),
|
||||
);
|
||||
|
||||
fs.writeFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, contents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,8 +39,8 @@ export const signWithGoogleCloudHSM = async ({ pdf }: SignWithGoogleCloudHSMOpti
|
||||
});
|
||||
|
||||
const pdfWithoutSignature = Buffer.concat([
|
||||
pdfWithPlaceholder.subarray(0, byteRange[1]),
|
||||
pdfWithPlaceholder.subarray(byteRange[2]),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(0, byteRange[1])),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(byteRange[2])),
|
||||
]);
|
||||
|
||||
const signatureLength = byteRange[2] - byteRange[1];
|
||||
@ -70,9 +71,9 @@ export const signWithGoogleCloudHSM = async ({ pdf }: SignWithGoogleCloudHSMOpti
|
||||
const signatureAsHex = signature.toString('hex');
|
||||
|
||||
const signedPdf = Buffer.concat([
|
||||
pdfWithPlaceholder.subarray(0, byteRange[1]),
|
||||
Buffer.from(`<${signatureAsHex.padEnd(signatureLength - 2, '0')}>`),
|
||||
pdfWithPlaceholder.subarray(byteRange[2]),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(0, byteRange[1])),
|
||||
new Uint8Array(Buffer.from(`<${signatureAsHex.padEnd(signatureLength - 2, '0')}>`)),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(byteRange[2])),
|
||||
]);
|
||||
|
||||
return signedPdf;
|
||||
|
||||
@ -15,8 +15,8 @@ export const signWithLocalCert = async ({ pdf }: SignWithLocalCertOptions) => {
|
||||
});
|
||||
|
||||
const pdfWithoutSignature = Buffer.concat([
|
||||
pdfWithPlaceholder.subarray(0, byteRange[1]),
|
||||
pdfWithPlaceholder.subarray(byteRange[2]),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(0, byteRange[1])),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(byteRange[2])),
|
||||
]);
|
||||
|
||||
const signatureLength = byteRange[2] - byteRange[1];
|
||||
@ -51,9 +51,9 @@ export const signWithLocalCert = async ({ pdf }: SignWithLocalCertOptions) => {
|
||||
const signatureAsHex = signature.toString('hex');
|
||||
|
||||
const signedPdf = Buffer.concat([
|
||||
pdfWithPlaceholder.subarray(0, byteRange[1]),
|
||||
Buffer.from(`<${signatureAsHex.padEnd(signatureLength - 2, '0')}>`),
|
||||
pdfWithPlaceholder.subarray(byteRange[2]),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(0, byteRange[1])),
|
||||
new Uint8Array(Buffer.from(`<${signatureAsHex.padEnd(signatureLength - 2, '0')}>`)),
|
||||
new Uint8Array(pdfWithPlaceholder.subarray(byteRange[2])),
|
||||
]);
|
||||
|
||||
return signedPdf;
|
||||
|
||||
Reference in New Issue
Block a user