mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
9035240b4d
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
34 lines
802 B
TypeScript
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)];
|
|
};
|