mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
d5ce222482
Adds Cloud Signature Consortium (CSC) integration for AES/QES signing against a configured TSP. v1 ships as instance-wide configuration via environment variables, with per-envelope signature level selection, license gating, and an OAuth-driven signing flow (capture + FIFO signers, SAD session, blocking/in-progress recipient pages). Includes signature level compatibility checks (role, signing order, dictate next signer), envelope mutability assertions, Prisma migration for signature level and CSC tables, and docs for the new signing certificate options.
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { DocumentSigningOrder } from '@prisma/client';
|
|
|
|
import { isTspEnvelope } from '../../types/signature-level';
|
|
import { assertCompatibleSigningOrder } from './assert-compatible-signing-order';
|
|
|
|
type ResolveSigningOrderOptions = {
|
|
signatureLevel: string;
|
|
requested?: DocumentSigningOrder | null;
|
|
};
|
|
|
|
/**
|
|
* Resolve the persisted `signingOrder` for a new envelope's meta.
|
|
*
|
|
* - Explicit `requested` value: validated via
|
|
* {@link assertCompatibleSigningOrder} (throws on TSP + `PARALLEL`) and
|
|
* returned as-is.
|
|
* - Omitted `requested`: returns the level-appropriate default —
|
|
* `SEQUENTIAL` for AES/QES (the TSP `/ByteRange` invariant requires it),
|
|
* `PARALLEL` for SES (preserves existing SES default behaviour).
|
|
*
|
|
* Use at every create-time call site instead of the bare `|| PARALLEL`
|
|
* fallback. Mirrors {@link resolveSignatureLevel} in shape — the two pair
|
|
* up to keep create-time defaulting + TSP-mode coercion uniform.
|
|
*/
|
|
export const resolveSigningOrder = ({
|
|
signatureLevel,
|
|
requested,
|
|
}: ResolveSigningOrderOptions): DocumentSigningOrder => {
|
|
if (requested) {
|
|
assertCompatibleSigningOrder({ signatureLevel, signingOrder: requested });
|
|
|
|
return requested;
|
|
}
|
|
|
|
return isTspEnvelope({ signatureLevel }) ? DocumentSigningOrder.SEQUENTIAL : DocumentSigningOrder.PARALLEL;
|
|
};
|