feat(pdf): @faunosteo/pdf engine — explicit inputs, envelope v1 attachment, layered reader, xmldom composition, allowlist SVG sanitiser, WinAnsi guard, rasterizer adapter; goldens reproduced
This commit is contained in:
1 parent
e7419cb4cb
commit
c17956031d
46 files changed
+4396
-1
No files matched your search
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Typed failures of the engine. The app maps the kinds to its messages; no
|
||||
* message here echoes untrusted input.
|
||||
*/
|
||||
|
||||
export type ArchiveReadErrorKind =
|
||||
| 'invalid_pdf'
|
||||
| 'no_attachment'
|
||||
| 'attachment_stripped'
|
||||
| 'incompatible_version'
|
||||
|
||||
export class ArchiveReadError extends Error {
|
||||
constructor(
|
||||
public readonly kind: ArchiveReadErrorKind,
|
||||
/** The report version found, for `incompatible_version`. */
|
||||
public readonly foundVersion?: number | null,
|
||||
) {
|
||||
super(kind)
|
||||
this.name = 'ArchiveReadError'
|
||||
}
|
||||
}
|
||||
|
||||
export type ArchiveExportErrorKind =
|
||||
| 'snapshot_invalid'
|
||||
| 'snapshot_too_large'
|
||||
| 'sheet_mismatch'
|
||||
| 'too_many_pages'
|
||||
|
||||
export class ArchiveExportError extends Error {
|
||||
constructor(
|
||||
public readonly kind: ArchiveExportErrorKind,
|
||||
detail = '',
|
||||
) {
|
||||
super(detail ? `${kind}: ${detail}` : kind)
|
||||
this.name = 'ArchiveExportError'
|
||||
}
|
||||
}
|
||||
|
||||
export type SvgRejection =
|
||||
| 'doctype'
|
||||
| 'malformed'
|
||||
| 'not_svg'
|
||||
| 'too_many_elements'
|
||||
| 'too_deep'
|
||||
| 'too_many_uses'
|
||||
|
||||
/** An SVG text the sanitiser refuses outright (STEP6 §15). */
|
||||
export class SvgRejectedError extends Error {
|
||||
constructor(public readonly reason: SvgRejection) {
|
||||
super(`svg rejected: ${reason}`)
|
||||
this.name = 'SvgRejectedError'
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user