chore: sign document

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

17
packages/signing/index.ts Normal file
View File

@ -0,0 +1,17 @@
import { match } from 'ts-pattern';
import { signWithLocalCert } from './transports/local-cert';
export type SignOptions = {
pdf: Buffer;
};
export const signPdf = async ({ pdf }: SignOptions) => {
const transport = process.env.NEXT_PRIVATE_SIGNING_TRANSPORT || 'local';
return await match(transport)
.with('local', async () => signWithLocalCert({ pdf }))
.otherwise(() => {
throw new Error(`Unsupported signing transport: ${transport}`);
});
};