Files
documenso/packages/signing/helpers/tsa.ts
T
Lucas Smith 9035240b4d refactor: replace pdf-sign with libpdf/core for PDF operations (#2403)
Migrate from @documenso/pdf-sign and @cantoo/pdf-lib to @libpdf/core
for all PDF manipulation and signing operations. This includes:

- New signing transports for Google Cloud KMS and local certificates
- Consolidated PDF operations using libpdf API
- Added TSA (timestamp authority) helper for digital signatures
- Removed deprecated flatten and insert utilities
- Updated tests to use new PDF library
2026-01-21 15:16:23 +11:00

34 lines
802 B
TypeScript

import { HttpTimestampAuthority } from '@libpdf/core';
import { once } from 'remeda';
import { NEXT_PRIVATE_SIGNING_TIMESTAMP_AUTHORITY } from '@documenso/lib/constants/app';
const setupTimestampAuthorities = once(() => {
const timestampAuthority = NEXT_PRIVATE_SIGNING_TIMESTAMP_AUTHORITY();
if (!timestampAuthority) {
return null;
}
const timestampAuthorities = timestampAuthority
.trim()
.split(',')
.filter(Boolean)
.map((url) => {
return new HttpTimestampAuthority(url);
});
return timestampAuthorities;
});
export const getTimestampAuthority = () => {
const authorities = setupTimestampAuthorities();
if (!authorities) {
return null;
}
// Pick a random authority
return authorities[Math.floor(Math.random() * authorities.length)];
};