pretext-pdf 1.8.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +234 -0
  2. package/dist/allowed-props.d.ts +24 -9
  3. package/dist/allowed-props.d.ts.map +1 -1
  4. package/dist/allowed-props.js +38 -6
  5. package/dist/allowed-props.js.map +1 -1
  6. package/dist/assets/index.d.ts +1 -1
  7. package/dist/assets/index.d.ts.map +1 -1
  8. package/dist/assets/index.js +1 -1
  9. package/dist/assets/index.js.map +1 -1
  10. package/dist/assets/svg/sanitize.d.ts +2 -0
  11. package/dist/assets/svg/sanitize.d.ts.map +1 -1
  12. package/dist/assets/svg/sanitize.js +41 -10
  13. package/dist/assets/svg/sanitize.js.map +1 -1
  14. package/dist/builder.js +1 -1
  15. package/dist/builder.js.map +1 -1
  16. package/dist/errors.d.ts +37 -0
  17. package/dist/errors.d.ts.map +1 -1
  18. package/dist/errors.js +77 -0
  19. package/dist/errors.js.map +1 -1
  20. package/dist/fonts.d.ts.map +1 -1
  21. package/dist/fonts.js +7 -5
  22. package/dist/fonts.js.map +1 -1
  23. package/dist/index.d.ts +5 -4
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +5 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/measure-blocks/simple-blocks.js +3 -3
  28. package/dist/measure-blocks/simple-blocks.js.map +1 -1
  29. package/dist/measure-text.d.ts.map +1 -1
  30. package/dist/measure-text.js +7 -0
  31. package/dist/measure-text.js.map +1 -1
  32. package/dist/pipeline.d.ts.map +1 -1
  33. package/dist/pipeline.js +42 -13
  34. package/dist/pipeline.js.map +1 -1
  35. package/dist/plugin-types.d.ts +41 -20
  36. package/dist/plugin-types.d.ts.map +1 -1
  37. package/dist/plugin-types.js +11 -5
  38. package/dist/plugin-types.js.map +1 -1
  39. package/dist/render-blocks/hr.d.ts.map +1 -1
  40. package/dist/render-blocks/hr.js +2 -3
  41. package/dist/render-blocks/hr.js.map +1 -1
  42. package/dist/render-extras.d.ts +0 -2
  43. package/dist/render-extras.d.ts.map +1 -1
  44. package/dist/render-extras.js +15 -78
  45. package/dist/render-extras.js.map +1 -1
  46. package/dist/render-utils.d.ts.map +1 -1
  47. package/dist/render-utils.js +10 -6
  48. package/dist/render-utils.js.map +1 -1
  49. package/dist/render.d.ts +2 -0
  50. package/dist/render.d.ts.map +1 -1
  51. package/dist/render.js +10 -2
  52. package/dist/render.js.map +1 -1
  53. package/dist/schema.d.ts +335 -88
  54. package/dist/schema.d.ts.map +1 -1
  55. package/dist/schema.js +94 -35
  56. package/dist/schema.js.map +1 -1
  57. package/dist/signing/index.d.ts +3 -0
  58. package/dist/signing/index.d.ts.map +1 -0
  59. package/dist/signing/index.js +3 -0
  60. package/dist/signing/index.js.map +1 -0
  61. package/dist/signing/placeholder.d.ts +5 -0
  62. package/dist/signing/placeholder.d.ts.map +1 -0
  63. package/dist/signing/placeholder.js +75 -0
  64. package/dist/signing/placeholder.js.map +1 -0
  65. package/dist/signing/post-process.d.ts +16 -0
  66. package/dist/signing/post-process.d.ts.map +1 -0
  67. package/dist/signing/post-process.js +125 -0
  68. package/dist/signing/post-process.js.map +1 -0
  69. package/dist/types-public/document.d.ts +7 -9
  70. package/dist/types-public/document.d.ts.map +1 -1
  71. package/dist/types-public/elements-block.d.ts +56 -31
  72. package/dist/types-public/elements-block.d.ts.map +1 -1
  73. package/dist/types-public/render-options.d.ts +0 -1
  74. package/dist/types-public/render-options.d.ts.map +1 -1
  75. package/dist/types-public/validation.d.ts +9 -11
  76. package/dist/types-public/validation.d.ts.map +1 -1
  77. package/dist/types.d.ts +1 -1
  78. package/dist/types.d.ts.map +1 -1
  79. package/dist/validate/elements/forms-floats.d.ts +1 -1
  80. package/dist/validate/elements/forms-floats.d.ts.map +1 -1
  81. package/dist/validate/elements/forms-floats.js +44 -6
  82. package/dist/validate/elements/forms-floats.js.map +1 -1
  83. package/dist/validate/elements/structural-simple.js +4 -4
  84. package/dist/validate/elements/structural-simple.js.map +1 -1
  85. package/dist/validate/index.d.ts.map +1 -1
  86. package/dist/validate/index.js +4 -6
  87. package/dist/validate/index.js.map +1 -1
  88. package/package.json +7 -3
package/CHANGELOG.md CHANGED
@@ -7,6 +7,240 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/)
7
7
 
8
8
  ---
9
9
 
10
+ ## [2.0.2] — 2026-05-28
11
+
12
+ Second post-release audit patch: PDF injection hardening (metadata, AcroForm names), PDFHexString encoding correctness, signing field escaping, annotation array safety.
13
+
14
+ ### Fixed
15
+
16
+ - **Metadata Info dict fields now use `PDFHexString.fromText()` (correct UTF-16BE encoding)** —
17
+ The v2.0.1 fix used `PDFHexString.of()` which stored raw bytes between `<>` delimiters (not
18
+ valid hex). `fromText` correctly produces `<FEFF...>` UTF-16BE hex, the same encoding used by
19
+ pdf-lib's built-in `setTitle()` etc. Injection protection is now both correct AND effective.
20
+
21
+ - **Form field `name` and option `value` restricted to AcroForm-safe characters** — Field names
22
+ and radio/dropdown option export values are written as PDF literal strings by pdf-lib. Characters
23
+ like `)`, `\`, and null bytes that could corrupt the AcroForm `/T` dictionary are now rejected
24
+ at validation time with a clear error message. Allowed: `[a-zA-Z0-9_.@-]+` (`HIGH-2`).
25
+
26
+ - **Signing placeholder fields escaped for PDF literal strings** — `sig.reason`, `sig.location`,
27
+ `sig.contactInfo`, and `sig.signerName` are passed to `@signpdf/placeholder-pdf-lib` which
28
+ writes them as PDF literal strings. Backslashes and parentheses are now escaped with `\` before
29
+ passing, so values like "New York (USA)" are preserved correctly without breaking the dict.
30
+
31
+ - **Annotation array push guarded with `instanceof PDFArray`** — The previous `as any` cast on
32
+ `pdfDoc.context.lookup(existingAnnots)` allowed silent no-ops if the value wasn't a PDFArray.
33
+ All three annotation functions now check `instanceof PDFArray` and fall back to creating a new
34
+ array rather than silently dropping the annotation.
35
+
36
+ - **Bookmark `Title` and AcroForm `/TU` use `PDFHexString.fromText()`** — Same `of()` → `fromText()`
37
+ correction applied to bookmark headings and all five AcroForm `/TU` (accessibility tooltip) writes.
38
+
39
+ - **Sticky note `Contents` and author `T` use `PDFHexString.fromText()`** — Human-readable text in
40
+ sticky note annotations now uses proper UTF-16BE encoding.
41
+
42
+ - **Signature placeholder `signerName` truncated to 100 chars** — Prevents glyph overflow outside
43
+ the visual signature box for very long signer names.
44
+
45
+ - **Schema `content.items` changed from `anyOf` to `oneOf`** — JSON Schema validators and AI agent
46
+ code generators now get exclusive-match semantics, preventing multi-schema ambiguity.
47
+
48
+ ### Tests
49
+
50
+ - Added T6: `/TU` accessibilityLabel byte-level injection guard in `test/forms.test.ts`.
51
+ - Added T7: metadata title/author/accessibility UTF-16BE hex-encoding byte checks in `test/metadata.test.ts`.
52
+ - Added field name and option value AcroForm-safety tests in `test/forms.test.ts`.
53
+
54
+ ---
55
+
56
+ ## [2.0.1] — 2026-05-28
57
+
58
+ Post-release patch: audit-driven hardening of every change introduced in v2.0.0.
59
+
60
+ ### Fixed
61
+
62
+ - **SVG sanitizer: `on*` handlers with whitespace in attribute name now stripped** — Attackers
63
+ could inject `on\nload=` or `on\tclick=` to bypass the previous `\w+` name regex. The pattern
64
+ now uses `[\w\r\n\t ]+` for the attribute name portion (`H3`).
65
+
66
+ - **SVG sanitizer: `expression()` strips arguments with nested parens** — `expression(alert(1))`
67
+ and `expression(eval(x))` are now stripped in a single pass. The inner-parens pattern
68
+ `(?:[^()]*|\([^()]*\))*` handles one level of argument nesting; multi-pass unwinds deeper
69
+ nesting (`M6`).
70
+
71
+ - **SVG sanitizer: size/element-count guards now throw `PretextPdfError('SVG_LOAD_FAILED')`** —
72
+ Previously both guards returned the raw unstripped SVG on overflow, silently bypassing
73
+ script/event stripping. Now both throw, so callers always receive a typed error (`H1`).
74
+
75
+ - **Form-field strict mode no longer flags cross-variant props as unknown** — `ALLOWED_PROPS`
76
+ entry for `form-field` now covers the union of all variant-specific keys so the first strict
77
+ check never fires false positives. Per-variant narrowing still runs inside `validateFormField`
78
+ to catch cross-contamination (`B1`).
79
+
80
+ - **Bookmark `Title` and AcroForm `/TU` now use `PDFHexString`** — Previously `PDFString` was
81
+ used, which is vulnerable to unbalanced-parenthesis injection in user-controlled strings. All
82
+ five `/TU` writes and the outline `Title` write now use the hex-encoded form (`B3`).
83
+
84
+ - **Link URI annotation and sticky-note `Contents`/`T` use `PDFHexString`** — Same injection
85
+ guard extended to `addLinkAnnotation` and `addStickyNoteAnnotation` (`B3`).
86
+
87
+ - **`getInfoDict()` private-API call is now try/caught** — Accessibility and semantic metadata
88
+ are silently omitted (rather than throwing) if the `@cantoo/pdf-lib` internal API is removed
89
+ in a future library version (`M7`).
90
+
91
+ - **`SignPdf`/`P12Signer` dynamic imports typed via local interfaces** — Removes `any` casts
92
+ on the signpdf module destructuring, catching future API drift at compile time (`M4`).
93
+
94
+ - **Signing error message scrubbed of certificate details** — `SIGNATURE_FAILED` no longer
95
+ leaks P12 structural details or ASN.1 internals; only the first 120 chars of the underlying
96
+ error message are included (`F9`).
97
+
98
+ - **`FORM_FIELD_VARIANT_PROPS` type narrowed** — The export type is now
99
+ `Record<'text'|'checkbox'|'radio'|'dropdown'|'button', ReadonlySet<string>>` so callers that
100
+ iterate the map get exhaustive narrowing rather than a plain string index (`M1`).
101
+
102
+ - **`fieldType` validation is now derived from `FORM_FIELD_VARIANT_PROPS`** — The allowed-values
103
+ list and the dispatch map are now the same object, removing the risk of one going stale (`M2`).
104
+
105
+ - **Form-field options arrays are structurally validated** — Each item in `options` for `radio`
106
+ and `dropdown` is now checked to be a `{value: string, label: string}` object. Invalid items
107
+ throw `VALIDATION_ERROR` with an indexed path like `options[1].value` (`H2`).
108
+
109
+ - **`accessibilityLabel` validated as non-empty string** — Empty or non-string values now
110
+ throw `VALIDATION_ERROR` rather than embedding an empty `/TU` annotation (`H2`).
111
+
112
+ - **`signing/placeholder.ts` uses `buildFontKey()` instead of hardcoded literal** — Keeps the
113
+ font lookup in sync with the canonical key format if the naming convention ever changes (`L1`).
114
+
115
+ - **`PluginMeasureResult.spaceBefore/spaceAfter` marked readonly** — Plugins cannot mutate the
116
+ pipeline's spacing side-table; callers can still construct the object with literal values (`L2`).
117
+
118
+ - **`package.json` `mcpCompat` range updated** — Was `>=1.4.0 <2.0.0` (excluded v2.0.0 itself);
119
+ now `>=1.5.0 <3.0.0` (`B2`).
120
+
121
+ - **`pdfDocumentSchema`: `form-field` now a `oneOf` discriminated union** — The flat single-object
122
+ schema was replaced with five variant schemas keyed by `fieldType: { const: '...' }`, with
123
+ correct per-variant `required` arrays (radio/dropdown require `options`) (`M3`).
124
+
125
+ ### Tests
126
+
127
+ - Added T1: `on\nload` and `on\tclick` attribute-name injection regression guard in
128
+ `test/svg-sanitizer.test.ts`.
129
+ - Added T2: Per-variant strict-mode unknown-props tests for form-field in
130
+ `test/validate-strict.test.ts` (Group 8).
131
+ - Added T3: `./signing` entry point added to `test/public-api-surface.test.ts` tripwire.
132
+ - Added T4: `MAX_SVG_ELEMENTS` boundary tests (at-limit sanitizes, over-limit throws) in
133
+ `test/svg-sanitizer.test.ts`.
134
+ - Added T5: `fieldType: 'textarea'` (unknown value) test triggering `VALIDATION_ERROR`.
135
+
136
+ ---
137
+
138
+ ## [2.0.0] — 2026-05-28
139
+
140
+ Major release. Three breaking changes, six improvements, and two security fixes.
141
+
142
+ ### Breaking Changes
143
+
144
+ - **`FormFieldElement` is now a discriminated union** — Replace the single flat interface with
145
+ five per-variant types (`TextFormField | CheckboxFormField | RadioFormField | DropdownFormField |
146
+ ButtonFormField`) that narrow available properties by `fieldType`. The `BaseFormField` interface
147
+ holds all shared fields and is also exported. Callers that assign into `FormFieldElement` without
148
+ narrowing will need to specify the concrete variant. **Migration:** narrow on `fieldType` or
149
+ import the specific variant type.
150
+
151
+ - **`HorizontalRuleElement.spaceAbove` / `spaceBelow` removed** — Use `spaceBefore` / `spaceAfter`
152
+ (stable since v0.9). The deprecated aliases were present in v1.x with `@deprecated` JSDoc.
153
+ **Migration:** replace `spaceAbove` → `spaceBefore`, `spaceBelow` → `spaceAfter`.
154
+
155
+ - **`ValidationResult.warningCount` removed** — The field was always `0` in v1.x (validator emits
156
+ errors only). **Migration:** use `result.errors.filter(e => e.severity === 'warning').length` if
157
+ you need a count — returns `0` until warning-severity issues are introduced.
158
+
159
+ ### Added
160
+
161
+ - **`./signing` export** — New subpath export `pretext-pdf/signing` exposes `applySignature`,
162
+ `applyEncryption`, `applyPostProcessing`, and `renderSignaturePlaceholder` as a standalone
163
+ signing module. Useful for post-render pipeline composition without importing the full library.
164
+
165
+ - **`MAX_SVG_ELEMENTS` constant** — Exported from `dist/assets.js` alongside `SVG_MAX_BYTES`.
166
+ Heuristic element-count guard (5,000 open tags) that skips sanitization of pathologically deep
167
+ SVGs to prevent memory exhaustion during rasterization.
168
+
169
+ - **Per-variant `accessibilityLabel` wired to AcroForm `/TU`** — `accessibilityLabel` on form
170
+ fields is now written to the PDF annotation `/TU` (tooltip/alt-text) dictionary entry.
171
+ Screen readers and assistive technology that consume AcroForm annotations will pick it up.
172
+
173
+ - **`metadata.accessibility` / `metadata.semantic` written to Info dict** — Both reserved fields
174
+ are now serialized as JSON strings into the PDF Info dictionary (`Accessibility` and `Semantic`
175
+ keys). Previously they were accepted but ignored at render time.
176
+
177
+ ### Changed
178
+
179
+ - **`ValidationError` and `ValidationResult` fields are `readonly`** — All fields on both
180
+ interfaces are now `readonly`. This is technically breaking for callers that mutate validation
181
+ results directly (which should be none in practice).
182
+
183
+ - **`PluginMeasureResult.height` is `readonly`** — Prevents accidental mutation of the measured
184
+ height by render hooks.
185
+
186
+ ### Fixed (security)
187
+
188
+ - **SVG `on*` handler regex now catches newline-injected attributes** — The previous pattern
189
+ `\bon\w+\s*=` missed attributes like `on\nload=`. Fixed to `\bon\w+[\s\n\r]*=`.
190
+
191
+ - **`allowed-props` strict mode now covers `accessibilityLabel`, `accessibility`, `semantic`** —
192
+ These fields were missing from their respective key arrays; strict-mode validation would
193
+ incorrectly report them as unknown properties. Fixed.
194
+
195
+ ---
196
+
197
+ ## [1.9.0] — 2026-05-28
198
+
199
+ Additive release: error categorisation, typed plugin generics, beta graduations, soft deprecations, and a 100 MB output size guard.
200
+
201
+ ### Added
202
+
203
+ - **`PretextPdfError.category`** — New readonly field on every thrown error. Groups all 50+
204
+ error codes into 8 high-level categories (`'validation' | 'font' | 'image' | 'layout' |
205
+ 'security' | 'dependency' | 'signature' | 'render'`). Lets callers branch on class of
206
+ failure without exhaustive switches. Also exported as the `ErrorCategory` type.
207
+
208
+ - **`LEGACY_ERROR_CODE_MAP`** — `Record<string, ErrorCode>` exported from the main entry
209
+ point. Documents the canonical code for any renamed or aliased error strings. Currently
210
+ maps `FONT_ENCODE_FAIL → FONT_ENCODE_FAIL` (no renames have occurred yet); future renames
211
+ will be recorded here before the old string is removed.
212
+
213
+ - **`PluginDefinition<T>` generic** — `PluginDefinition`, `PluginMeasureResult`, and
214
+ `PluginRenderContext` are now generic over a `T` type parameter (default `unknown`).
215
+ `pluginData` in `measure` and `render` is now typed as `T` instead of `unknown`. Fully
216
+ backward compatible — existing plugins without a type argument continue to compile.
217
+
218
+ - **`MAX_PDF_BYTES` constant** — Exported from the main entry point. Value: `100 * 1024 * 1024`
219
+ (100 MB). `render()` now throws `RENDER_FAILED` if the serialized PDF exceeds this limit,
220
+ preventing runaway memory use from pathological documents.
221
+
222
+ ### Changed (promotions — no breaking changes)
223
+
224
+ - **`PluginDefinition`, `PluginMeasureContext`, `PluginMeasureResult`, `PluginRenderContext`**
225
+ — Promoted from `@beta` to `@public`. The plugin API is stable.
226
+
227
+ - **`RenderOptions.plugins`** — `@beta` tag removed. Stable.
228
+
229
+ - **`createFootnoteSet()`** — `@beta` tag removed. Stable.
230
+
231
+ ### Deprecated
232
+
233
+ - **`HorizontalRuleElement.spaceAbove`** and **`.spaceBelow`** — Use `spaceBefore` and
234
+ `spaceAfter` instead (consistent with paragraph/heading naming). Both aliases remain
235
+ functional in v1.x. Will be removed in v2.0.
236
+
237
+ - **`ValidationResult.warningCount`** — Always `0` in v1.x (the validator emits errors
238
+ only). Will be removed in v2.0. Use
239
+ `result.errors.filter(e => e.severity === 'warning').length` directly when
240
+ warning-severity items are introduced.
241
+
242
+ ---
243
+
10
244
  ## [1.8.0] — 2026-05-28
11
245
 
12
246
  Additive release: type narrowing, shared leaf modules, 5 new test coverage points, and a Windows font-path validation bugfix.
@@ -3,12 +3,12 @@
3
3
  * Enforced at runtime by strict: true validation.
4
4
  * Compile-time drift guards via Exact<T, Keys> ensure types stay synchronized.
5
5
  */
6
- import type { PdfDocument, ParagraphElement, HeadingElement, SpacerElement, TableElement, TableCell, ColumnDef, ImageElement, SvgElement, QrCodeElement, BarcodeElement, ChartElement, ListElement, ListItem, HorizontalRuleElement, PageBreakElement, CodeBlockElement, RichParagraphElement, InlineSpan, BlockquoteElement, CalloutElement, CommentElement, FormFieldElement, FootnoteDefElement, TocElement, FloatGroupElement, AnnotationSpec, TableRow, DocumentMetadata, EncryptionSpec } from './types.js';
6
+ import type { PdfDocument, ParagraphElement, HeadingElement, SpacerElement, TableElement, TableCell, ColumnDef, ImageElement, SvgElement, QrCodeElement, BarcodeElement, ChartElement, ListElement, ListItem, HorizontalRuleElement, PageBreakElement, CodeBlockElement, RichParagraphElement, InlineSpan, BlockquoteElement, CalloutElement, CommentElement, TextFormField, CheckboxFormField, RadioFormField, DropdownFormField, ButtonFormField, FootnoteDefElement, TocElement, FloatGroupElement, AnnotationSpec, TableRow, DocumentMetadata, EncryptionSpec } from './types.js';
7
7
  import type { TocEntryElement } from './types-internal.js';
8
8
  /** Compile-time assertion that T has exactly the keys in Keys (no more, no less) */
9
9
  type Exact<T, Keys extends readonly (keyof T)[]> = T & Record<Exclude<keyof T, Keys[number]>, never>;
10
10
  declare const DOC_KEYS: readonly ["pageSize", "margins", "defaultFont", "defaultFontSize", "defaultLineHeight", "fonts", "header", "footer", "watermark", "encryption", "signature", "bookmarks", "hyphenation", "metadata", "defaultParagraphStyle", "sections", "content", "flattenForms", "onImageLoadError", "onFormFieldError", "renderDate", "allowedFileDirs"];
11
- declare const METADATA_KEYS: readonly ["title", "author", "subject", "keywords", "creator", "language", "producer"];
11
+ declare const METADATA_KEYS: readonly ["title", "author", "subject", "keywords", "creator", "language", "producer", "accessibility", "semantic"];
12
12
  declare const PARAGRAPH_KEYS: readonly ["type", "text", "dir", "fontSize", "lineHeight", "fontFamily", "fontWeight", "color", "align", "bgColor", "spaceAfter", "spaceBefore", "keepTogether", "underline", "strikethrough", "url", "columns", "columnGap", "hyphenate", "letterSpacing", "smallCaps", "tabularNumbers", "annotation"];
13
13
  declare const HEADING_KEYS: readonly ["type", "level", "text", "dir", "fontFamily", "fontWeight", "fontSize", "lineHeight", "align", "color", "bgColor", "spaceBefore", "spaceAfter", "keepTogether", "underline", "strikethrough", "bookmark", "hyphenate", "url", "anchor", "letterSpacing", "smallCaps", "tabularNumbers", "annotation"];
14
14
  declare const SPACER_KEYS: readonly ["type", "height"];
@@ -23,7 +23,7 @@ declare const BARCODE_KEYS: readonly ["type", "symbology", "data", "width", "hei
23
23
  declare const CHART_KEYS: readonly ["type", "spec", "width", "height", "caption", "align", "spaceBefore", "spaceAfter"];
24
24
  declare const LIST_KEYS: readonly ["type", "style", "items", "marker", "indent", "markerWidth", "fontSize", "lineHeight", "itemSpaceAfter", "spaceAfter", "spaceBefore", "color", "nestedNumberingStyle"];
25
25
  declare const LIST_ITEM_KEYS: readonly ["text", "dir", "fontWeight", "items"];
26
- declare const HR_KEYS: readonly ["type", "thickness", "color", "spaceAbove", "spaceBelow", "spaceBefore", "spaceAfter"];
26
+ declare const HR_KEYS: readonly ["type", "thickness", "color", "spaceBefore", "spaceAfter"];
27
27
  declare const PAGE_BREAK_KEYS: readonly ["type"];
28
28
  declare const CODE_KEYS: readonly ["type", "text", "dir", "fontFamily", "fontSize", "lineHeight", "bgColor", "color", "padding", "spaceAfter", "spaceBefore", "keepTogether", "language", "highlightTheme"];
29
29
  declare const RICH_PARAGRAPH_KEYS: readonly ["type", "spans", "dir", "fontSize", "lineHeight", "align", "bgColor", "spaceBefore", "spaceAfter", "keepTogether", "columns", "columnGap", "letterSpacing", "smallCaps", "tabularNumbers"];
@@ -31,7 +31,11 @@ declare const INLINE_SPAN_KEYS: readonly ["text", "dir", "fontFamily", "fontWeig
31
31
  declare const BLOCKQUOTE_KEYS: readonly ["type", "text", "dir", "borderColor", "borderWidth", "bgColor", "color", "fontFamily", "fontWeight", "fontStyle", "fontSize", "lineHeight", "padding", "paddingH", "paddingV", "align", "spaceBefore", "spaceAfter", "keepTogether", "underline", "strikethrough"];
32
32
  declare const CALLOUT_KEYS: readonly ["type", "content", "style", "title", "backgroundColor", "borderColor", "color", "titleColor", "fontFamily", "fontWeight", "fontSize", "lineHeight", "padding", "paddingH", "paddingV", "spaceAfter", "spaceBefore", "keepTogether", "dir"];
33
33
  declare const COMMENT_KEYS: readonly ["type", "contents", "author", "color", "open", "spaceAfter"];
34
- declare const FORM_FIELD_KEYS: readonly ["type", "fieldType", "name", "label", "placeholder", "defaultValue", "multiline", "maxLength", "checked", "options", "defaultSelected", "width", "height", "fontSize", "borderColor", "backgroundColor", "spaceAfter", "spaceBefore", "keepTogether"];
34
+ declare const TEXT_FORM_FIELD_KEYS: readonly ["type", "fieldType", "name", "label", "width", "height", "fontSize", "borderColor", "backgroundColor", "spaceAfter", "spaceBefore", "keepTogether", "accessibilityLabel", "placeholder", "defaultValue", "multiline", "maxLength"];
35
+ declare const CHECKBOX_FORM_FIELD_KEYS: readonly ["type", "fieldType", "name", "label", "width", "height", "fontSize", "borderColor", "backgroundColor", "spaceAfter", "spaceBefore", "keepTogether", "accessibilityLabel", "checked"];
36
+ declare const RADIO_FORM_FIELD_KEYS: readonly ["type", "fieldType", "name", "label", "width", "height", "fontSize", "borderColor", "backgroundColor", "spaceAfter", "spaceBefore", "keepTogether", "accessibilityLabel", "options", "defaultSelected"];
37
+ declare const DROPDOWN_FORM_FIELD_KEYS: readonly ["type", "fieldType", "name", "label", "width", "height", "fontSize", "borderColor", "backgroundColor", "spaceAfter", "spaceBefore", "keepTogether", "accessibilityLabel", "options", "defaultSelected"];
38
+ declare const BUTTON_FORM_FIELD_KEYS: readonly ["type", "fieldType", "name", "label", "width", "height", "fontSize", "borderColor", "backgroundColor", "spaceAfter", "spaceBefore", "keepTogether", "accessibilityLabel"];
35
39
  declare const FOOTNOTE_DEF_KEYS: readonly ["type", "id", "text", "fontSize", "fontFamily", "spaceAfter"];
36
40
  declare const TOC_KEYS: readonly ["type", "title", "showTitle", "minLevel", "maxLevel", "fontSize", "titleFontSize", "levelIndent", "leader", "entrySpacing", "fontFamily", "spaceBefore", "spaceAfter"];
37
41
  declare const TOC_ENTRY_KEYS: readonly ["type", "text", "pageNumber", "level", "levelIndent", "leader", "fontFamily", "fontWeight"];
@@ -70,7 +74,11 @@ export type _AllowedPropsDriftGuard = [
70
74
  Exact<BlockquoteElement, typeof BLOCKQUOTE_KEYS>,
71
75
  Exact<CalloutElement, typeof CALLOUT_KEYS>,
72
76
  Exact<CommentElement, typeof COMMENT_KEYS>,
73
- Exact<FormFieldElement, typeof FORM_FIELD_KEYS>,
77
+ Exact<TextFormField, typeof TEXT_FORM_FIELD_KEYS>,
78
+ Exact<CheckboxFormField, typeof CHECKBOX_FORM_FIELD_KEYS>,
79
+ Exact<RadioFormField, typeof RADIO_FORM_FIELD_KEYS>,
80
+ Exact<DropdownFormField, typeof DROPDOWN_FORM_FIELD_KEYS>,
81
+ Exact<ButtonFormField, typeof BUTTON_FORM_FIELD_KEYS>,
74
82
  Exact<FootnoteDefElement, typeof FOOTNOTE_DEF_KEYS>,
75
83
  Exact<TocElement, typeof TOC_KEYS>,
76
84
  Exact<TocEntryElement, typeof TOC_ENTRY_KEYS>,
@@ -89,7 +97,7 @@ export declare const ALLOWED_PROPS: {
89
97
  readonly barcode: Set<"type" | "align" | "spaceAfter" | "spaceBefore" | "height" | "width" | "data" | "symbology" | "includeText">;
90
98
  readonly chart: Set<"type" | "align" | "spaceAfter" | "spaceBefore" | "height" | "width" | "spec" | "caption">;
91
99
  readonly list: Set<"type" | "fontSize" | "lineHeight" | "color" | "spaceAfter" | "spaceBefore" | "style" | "items" | "marker" | "indent" | "markerWidth" | "itemSpaceAfter" | "nestedNumberingStyle">;
92
- readonly hr: Set<"type" | "color" | "spaceAfter" | "spaceBefore" | "thickness" | "spaceAbove" | "spaceBelow">;
100
+ readonly hr: Set<"type" | "color" | "spaceAfter" | "spaceBefore" | "thickness">;
93
101
  readonly 'page-break': Set<"type">;
94
102
  readonly code: Set<"text" | "language" | "type" | "dir" | "fontSize" | "lineHeight" | "fontFamily" | "color" | "bgColor" | "spaceAfter" | "spaceBefore" | "keepTogether" | "padding" | "highlightTheme">;
95
103
  readonly 'rich-paragraph': Set<"type" | "dir" | "fontSize" | "lineHeight" | "align" | "bgColor" | "spaceAfter" | "spaceBefore" | "keepTogether" | "columns" | "columnGap" | "letterSpacing" | "smallCaps" | "tabularNumbers" | "spans">;
@@ -97,14 +105,21 @@ export declare const ALLOWED_PROPS: {
97
105
  readonly toc: Set<"title" | "type" | "fontSize" | "fontFamily" | "spaceAfter" | "spaceBefore" | "showTitle" | "minLevel" | "maxLevel" | "titleFontSize" | "levelIndent" | "leader" | "entrySpacing">;
98
106
  readonly 'toc-entry': Set<"text" | "type" | "fontFamily" | "fontWeight" | "level" | "levelIndent" | "leader" | "pageNumber">;
99
107
  readonly comment: Set<"author" | "type" | "color" | "spaceAfter" | "contents" | "open">;
100
- readonly 'form-field': Set<"type" | "fontSize" | "spaceAfter" | "spaceBefore" | "keepTogether" | "height" | "borderColor" | "width" | "backgroundColor" | "fieldType" | "name" | "label" | "placeholder" | "defaultValue" | "multiline" | "maxLength" | "checked" | "options" | "defaultSelected">;
101
108
  readonly callout: Set<"content" | "title" | "type" | "dir" | "fontSize" | "lineHeight" | "fontFamily" | "fontWeight" | "color" | "spaceAfter" | "spaceBefore" | "keepTogether" | "borderColor" | "style" | "padding" | "paddingH" | "paddingV" | "backgroundColor" | "titleColor">;
102
109
  readonly 'footnote-def': Set<"text" | "type" | "fontSize" | "fontFamily" | "spaceAfter" | "id">;
103
110
  readonly 'float-group': Set<"image" | "content" | "type" | "spaceAfter" | "spaceBefore" | "float" | "floatWidth" | "floatGap">;
111
+ readonly 'form-field': Set<"type" | "fontSize" | "spaceAfter" | "spaceBefore" | "keepTogether" | "height" | "borderColor" | "width" | "backgroundColor" | "fieldType" | "name" | "label" | "accessibilityLabel" | "placeholder" | "defaultValue" | "multiline" | "maxLength" | "checked" | "options" | "defaultSelected">;
104
112
  };
113
+ /**
114
+ * Per-variant allowed-property sets for form-field strict validation.
115
+ * Typed as a closed record over the exact fieldType literals so TypeScript
116
+ * will fail the build if a new variant is added to FormFieldElement without
117
+ * a corresponding entry here.
118
+ */
119
+ export declare const FORM_FIELD_VARIANT_PROPS: Record<'text' | 'checkbox' | 'radio' | 'dropdown' | 'button', ReadonlySet<string>>;
105
120
  export declare const ALLOWED_PROPS_SUB: {
106
- readonly document: Set<"header" | "footer" | "pageSize" | "margins" | "defaultFont" | "defaultFontSize" | "defaultLineHeight" | "fonts" | "watermark" | "encryption" | "signature" | "bookmarks" | "hyphenation" | "metadata" | "defaultParagraphStyle" | "sections" | "content" | "flattenForms" | "onImageLoadError" | "onFormFieldError" | "renderDate" | "allowedFileDirs">;
107
- readonly metadata: Set<"title" | "author" | "subject" | "keywords" | "creator" | "language" | "producer">;
121
+ readonly document: Set<"header" | "footer" | "signature" | "pageSize" | "margins" | "defaultFont" | "defaultFontSize" | "defaultLineHeight" | "fonts" | "watermark" | "encryption" | "bookmarks" | "hyphenation" | "metadata" | "defaultParagraphStyle" | "sections" | "content" | "flattenForms" | "onImageLoadError" | "onFormFieldError" | "renderDate" | "allowedFileDirs">;
122
+ readonly metadata: Set<"title" | "author" | "subject" | "keywords" | "creator" | "language" | "producer" | "accessibility" | "semantic">;
108
123
  readonly 'column-def': Set<"align" | "width">;
109
124
  readonly 'table-row': Set<"cells" | "isHeader">;
110
125
  readonly 'table-cell': Set<"text" | "dir" | "fontSize" | "fontFamily" | "fontWeight" | "color" | "align" | "bgColor" | "tabularNumbers" | "colspan" | "rowspan">;
@@ -1 +1 @@
1
- {"version":3,"file":"allowed-props.d.ts","sourceRoot":"","sources":["../src/allowed-props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACf,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,oFAAoF;AACpF,KAAK,KAAK,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAIpG,QAAA,MAAM,QAAQ,+UAKJ,CAAA;AAEV,QAAA,MAAM,aAAa,wFAAyF,CAAA;AAE5G,QAAA,MAAM,cAAc,0SAKV,CAAA;AAEV,QAAA,MAAM,YAAY,iTAKR,CAAA;AAEV,QAAA,MAAM,WAAW,6BAA8B,CAAA;AAE/C,QAAA,MAAM,UAAU,mLAGN,CAAA;AAEV,QAAA,MAAM,eAAe,6BAA8B,CAAA;AAEnD,QAAA,MAAM,cAAc,gCAAiC,CAAA;AAErD,QAAA,MAAM,eAAe,uIAGX,CAA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AO,qBAAqB,CAAC;IACnD,KAAK,CAAC,iBAAiB,EAAE,OAAO,wBAAwB,CAAC;IACzD,KAAK,CAAC,eAAe,EAAE,OAAO,sBAAsB,CAAC;IACrD,KAAK,CAAC,kBAAkB,EAAE,OAAO,iBAAiB,CAAC;IACnD,KAAK,CAAC,UAAU,EAAE,OAAO,QAAQ,CAAC;IAClC,KAAK,CAAC,eAAe,EAAE,OAAO,cAAc,CAAC;IAC7C,KAAK,CAAC,iBAAiB,EAAE,OAAO,gBAAgB,CAAC;IACjD,KAAK,CAAC,cAAc,EAAE,OAAO,eAAe,CAAC;IAC7C,KAAK,CAAC,cAAc,EAAE,OAAO,eAAe,CAAC;CAC9C,CAAA;AAID,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;CAuBhB,CAAA;AAEV;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAC3C,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,EACrD,WAAW,CAAC,MAAM,CAAC,CAOpB,CAAA;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;CAUpB,CAAA"}
@@ -10,7 +10,7 @@ const DOC_KEYS = [
10
10
  'hyphenation', 'metadata', 'defaultParagraphStyle', 'sections', 'content',
11
11
  'flattenForms', 'onImageLoadError', 'onFormFieldError', 'renderDate', 'allowedFileDirs',
12
12
  ];
13
- const METADATA_KEYS = ['title', 'author', 'subject', 'keywords', 'creator', 'language', 'producer'];
13
+ const METADATA_KEYS = ['title', 'author', 'subject', 'keywords', 'creator', 'language', 'producer', 'accessibility', 'semantic'];
14
14
  const PARAGRAPH_KEYS = [
15
15
  'type', 'text', 'dir', 'fontSize', 'lineHeight', 'fontFamily', 'fontWeight', 'color',
16
16
  'align', 'bgColor', 'spaceAfter', 'spaceBefore', 'keepTogether', 'underline',
@@ -53,7 +53,7 @@ const LIST_KEYS = [
53
53
  'itemSpaceAfter', 'spaceAfter', 'spaceBefore', 'color', 'nestedNumberingStyle',
54
54
  ];
55
55
  const LIST_ITEM_KEYS = ['text', 'dir', 'fontWeight', 'items'];
56
- const HR_KEYS = ['type', 'thickness', 'color', 'spaceAbove', 'spaceBelow', 'spaceBefore', 'spaceAfter'];
56
+ const HR_KEYS = ['type', 'thickness', 'color', 'spaceBefore', 'spaceAfter'];
57
57
  const PAGE_BREAK_KEYS = ['type'];
58
58
  const CODE_KEYS = [
59
59
  'type', 'text', 'dir', 'fontFamily', 'fontSize', 'lineHeight', 'bgColor', 'color',
@@ -79,10 +79,29 @@ const CALLOUT_KEYS = [
79
79
  'spaceAfter', 'spaceBefore', 'keepTogether', 'dir',
80
80
  ];
81
81
  const COMMENT_KEYS = ['type', 'contents', 'author', 'color', 'open', 'spaceAfter'];
82
- const FORM_FIELD_KEYS = [
83
- 'type', 'fieldType', 'name', 'label', 'placeholder', 'defaultValue', 'multiline',
84
- 'maxLength', 'checked', 'options', 'defaultSelected', 'width', 'height', 'fontSize',
82
+ const FORM_FIELD_BASE_KEYS = [
83
+ 'type', 'fieldType', 'name', 'label', 'width', 'height', 'fontSize',
85
84
  'borderColor', 'backgroundColor', 'spaceAfter', 'spaceBefore', 'keepTogether',
85
+ 'accessibilityLabel',
86
+ ];
87
+ const TEXT_FORM_FIELD_KEYS = [...FORM_FIELD_BASE_KEYS, 'placeholder', 'defaultValue', 'multiline', 'maxLength'];
88
+ const CHECKBOX_FORM_FIELD_KEYS = [...FORM_FIELD_BASE_KEYS, 'checked'];
89
+ const RADIO_FORM_FIELD_KEYS = [...FORM_FIELD_BASE_KEYS, 'options', 'defaultSelected'];
90
+ const DROPDOWN_FORM_FIELD_KEYS = [...FORM_FIELD_BASE_KEYS, 'options', 'defaultSelected'];
91
+ const BUTTON_FORM_FIELD_KEYS = [...FORM_FIELD_BASE_KEYS];
92
+ /**
93
+ * Union of every field that can appear on *any* FormFieldElement variant.
94
+ * Used for the top-level ALLOWED_PROPS dispatch so the generic strict check in
95
+ * validate/index.ts never false-flags a valid variant-specific key (e.g.
96
+ * `placeholder` on a text field). The per-variant check inside
97
+ * validateFormField then narrows further and rejects cross-variant
98
+ * contamination (e.g. `checked` on a text field).
99
+ */
100
+ const FORM_FIELD_ALL_KEYS = [
101
+ ...FORM_FIELD_BASE_KEYS,
102
+ 'placeholder', 'defaultValue', 'multiline', 'maxLength', // text only
103
+ 'checked', // checkbox only
104
+ 'options', 'defaultSelected', // radio + dropdown
86
105
  ];
87
106
  const FOOTNOTE_DEF_KEYS = ['type', 'id', 'text', 'fontSize', 'fontFamily', 'spaceAfter'];
88
107
  const TOC_KEYS = [
@@ -113,10 +132,23 @@ export const ALLOWED_PROPS = {
113
132
  'toc': new Set(TOC_KEYS),
114
133
  'toc-entry': new Set(TOC_ENTRY_KEYS),
115
134
  'comment': new Set(COMMENT_KEYS),
116
- 'form-field': new Set(FORM_FIELD_KEYS),
117
135
  'callout': new Set(CALLOUT_KEYS),
118
136
  'footnote-def': new Set(FOOTNOTE_DEF_KEYS),
119
137
  'float-group': new Set(FLOAT_GROUP_KEYS),
138
+ 'form-field': new Set(FORM_FIELD_ALL_KEYS),
139
+ };
140
+ /**
141
+ * Per-variant allowed-property sets for form-field strict validation.
142
+ * Typed as a closed record over the exact fieldType literals so TypeScript
143
+ * will fail the build if a new variant is added to FormFieldElement without
144
+ * a corresponding entry here.
145
+ */
146
+ export const FORM_FIELD_VARIANT_PROPS = {
147
+ text: new Set(TEXT_FORM_FIELD_KEYS),
148
+ checkbox: new Set(CHECKBOX_FORM_FIELD_KEYS),
149
+ radio: new Set(RADIO_FORM_FIELD_KEYS),
150
+ dropdown: new Set(DROPDOWN_FORM_FIELD_KEYS),
151
+ button: new Set(BUTTON_FORM_FIELD_KEYS),
120
152
  };
121
153
  export const ALLOWED_PROPS_SUB = {
122
154
  'document': new Set(DOC_KEYS),
@@ -1 +1 @@
1
- {"version":3,"file":"allowed-props.js","sourceRoot":"","sources":["../src/allowed-props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuCH,iFA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';
13
13
  export { normalizeIpv4Hostname } from './security/ipv4-normalize.js';
14
14
  export { resolveAndValidateUrl, assertSafeUrl, type ResolvedSafeUrl, } from './security/url-validation.js';
15
15
  export { fetchWithTimeout } from './security/fetch.js';
16
- export { sanitizeSvg } from './svg/sanitize.js';
16
+ export { sanitizeSvg, SVG_MAX_BYTES, MAX_SVG_ELEMENTS } from './svg/sanitize.js';
17
17
  export { VECTOR_RASTER_CONCURRENCY } from './loaders/vectors.js';
18
18
  export { loadImages } from './loaders/orchestrator.js';
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,KAAK,eAAe,GACrB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,KAAK,eAAe,GACrB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
@@ -13,7 +13,7 @@ export { assertPathAllowed } from './security/path-allowlist.js';
13
13
  export { normalizeIpv4Hostname } from './security/ipv4-normalize.js';
14
14
  export { resolveAndValidateUrl, assertSafeUrl, } from './security/url-validation.js';
15
15
  export { fetchWithTimeout } from './security/fetch.js';
16
- export { sanitizeSvg } from './svg/sanitize.js';
16
+ export { sanitizeSvg, SVG_MAX_BYTES, MAX_SVG_ELEMENTS } from './svg/sanitize.js';
17
17
  export { VECTOR_RASTER_CONCURRENCY } from './loaders/vectors.js';
18
18
  export { loadImages } from './loaders/orchestrator.js';
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EACL,qBAAqB,EACrB,aAAa,GAEd,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EACL,qBAAqB,EACrB,aAAa,GAEd,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
@@ -23,5 +23,7 @@
23
23
  */
24
24
  /** Maximum SVG string length (5 MB) — prevents ReDoS on oversized inputs. */
25
25
  export declare const SVG_MAX_BYTES: number;
26
+ /** Maximum number of XML elements (open tags) — heuristic DoS guard for deeply nested SVGs. */
27
+ export declare const MAX_SVG_ELEMENTS = 5000;
26
28
  export declare function sanitizeSvg(svg: string): string;
27
29
  //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/assets/svg/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,aAAa,QAAkB,CAAA;AAE5C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsC/C"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/assets/svg/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,6EAA6E;AAC7E,eAAO,MAAM,aAAa,QAAkB,CAAA;AAE5C,+FAA+F;AAC/F,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmE/C"}
@@ -21,19 +21,41 @@
21
21
  * `dist/assets.js` consumers (test/svg-sanitizer.test.ts, the snapshot
22
22
  * tripwire) keep working unchanged.
23
23
  */
24
+ import { PretextPdfError } from '../../errors.js';
24
25
  /** Maximum SVG string length (5 MB) — prevents ReDoS on oversized inputs. */
25
26
  export const SVG_MAX_BYTES = 5 * 1024 * 1024;
27
+ /** Maximum number of XML elements (open tags) — heuristic DoS guard for deeply nested SVGs. */
28
+ export const MAX_SVG_ELEMENTS = 5000;
26
29
  export function sanitizeSvg(svg) {
27
- // Skip regex passes on oversized strings canvas will reject them anyway
28
- if (svg.length > SVG_MAX_BYTES)
29
- return svg;
30
+ // Guard oversized inputs — regex passes on 5 MB+ strings create ReDoS risk.
31
+ // Throw rather than pass through: an oversized SVG must never reach the
32
+ // rasterizer with unstripped script/event content intact.
33
+ if (svg.length > SVG_MAX_BYTES) {
34
+ throw new PretextPdfError('SVG_LOAD_FAILED', `SVG exceeds maximum size of ${SVG_MAX_BYTES} bytes (got ${svg.length})`);
35
+ }
36
+ // Heuristic element count guard — deeply nested SVGs can exhaust rasterizer
37
+ // memory. Count open tags as a cheap proxy. Throw rather than return raw:
38
+ // passing unsanitized content downstream is worse than rejecting the input.
39
+ const elementCount = (svg.match(/<[a-zA-Z]/g) ?? []).length;
40
+ if (elementCount > MAX_SVG_ELEMENTS) {
41
+ throw new PretextPdfError('SVG_LOAD_FAILED', `SVG exceeds maximum element count of ${MAX_SVG_ELEMENTS} (got ${elementCount})`);
42
+ }
30
43
  // Remove self-closing <script/> then paired <script>...</script> blocks
31
44
  let s = svg.replace(/<script\b[^>]*\/>/gi, '');
32
45
  s = s.replace(/<script[\s\S]*?<\/script>/gi, '');
33
46
  // Remove event handler attributes (onload, onclick, onerror, etc.)
34
- s = s.replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi, '');
35
- // Remove <image> and <use> hrefs pointing to unsafe schemes
36
- s = s.replace(/(<(?:image|use)\b[^>]*?)\s+(?:xlink:)?href\s*=\s*["'](?:file|data|javascript):[^"']*["']/gi, '$1');
47
+ // Use [\w\r\n\t ]+ for the name portion so that whitespace injected INSIDE the
48
+ // attribute name (e.g. on\nload=, on\tclick=) is also stripped. The original
49
+ // \w+ stopped at non-word chars, leaving split names unmatched. The \s* before
50
+ // = stays to catch normal spacing between the name and the assignment operator.
51
+ s = s.replace(/\bon[\w\r\n\t ]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi, '');
52
+ // Strip any non-local href from <image> and <use>.
53
+ // Only fragment refs (#id) are safe in an embedded SVG — they point to elements
54
+ // within the same SVG document. Any external URL (https://, http://, //,
55
+ // file://, data:, javascript:, relative paths to disk files) would cause the
56
+ // SVG rasterizer to make an outbound network or filesystem request at render
57
+ // time — an SSRF-class vector. Deny everything that doesn't start with '#'.
58
+ s = s.replace(/(<(?:image|use)\b[^>]*?)\s+(?:xlink:)?href\s*=\s*["'](?!#)[^"']*["']/gi, '$1');
37
59
  // v1.6.0: strip <foreignObject> entirely — it's an HTML escape hatch and
38
60
  // the only XML-in-SVG construct that can host arbitrary tags.
39
61
  s = s.replace(/<foreignObject\b[^>]*\/>/gi, '');
@@ -42,10 +64,19 @@ export function sanitizeSvg(svg) {
42
64
  // Drop only the attribute, not the whole <a>, so the surrounding text content
43
65
  // (children of <a>) still renders.
44
66
  s = s.replace(/\s+(?:xlink:)?href\s*=\s*["'](?:javascript|vbscript|data):[^"']*["']/gi, '');
45
- // v1.6.0: strip CSS expression(...) inside <style> blocks. Replace just the
46
- // expression call with an empty string so the surrounding stylesheet stays
47
- // parseable.
48
- s = s.replace(/expression\s*\([^)]*\)/gi, '');
67
+ // v1.6.0: strip CSS expression(...) inside <style> blocks.
68
+ // Multi-pass to handle nested parens. Each pass strips expression() calls
69
+ // whose arguments contain at most one level of paren nesting — e.g.
70
+ // expression(alert(1)) and expression(eval(x)) are handled in one pass.
71
+ // Deeper nesting (e.g. expression(f(g(x)))) unwinds over multiple passes:
72
+ // the innermost expression()-shaped call is consumed first, then the outer.
73
+ // Pattern: (?:[^()]*|\([^()]*\))* matches argument content with one level
74
+ // of inner parens — e.g. "alert(1)" = [^()]* + \([^()]*\) + [^()]*.
75
+ let prev;
76
+ do {
77
+ prev = s;
78
+ s = s.replace(/expression\s*\((?:[^()]*|\([^()]*\))*\)/gi, '');
79
+ } while (s !== prev);
49
80
  // v1.7.1: strip @import rules — SVGs embedded in PDFs have no business
50
81
  // importing external stylesheets; also an outbound network-leak vector.
51
82
  s = s.replace(/@import\s+[^;{}]*/gi, '');
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../../src/assets/svg/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAE5C,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,0EAA0E;IAC1E,IAAI,GAAG,CAAC,MAAM,GAAG,aAAa;QAAE,OAAO,GAAG,CAAA;IAC1C,wEAAwE;IACxE,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAA;IAC9C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAA;IAChD,mEAAmE;IACnE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,6CAA6C,EAAE,EAAE,CAAC,CAAA;IAChE,4DAA4D;IAC5D,CAAC,GAAG,CAAC,CAAC,OAAO,CACX,4FAA4F,EAC5F,IAAI,CACL,CAAA;IACD,yEAAyE;IACzE,8DAA8D;IAC9D,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAA;IAC/C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,2CAA2C,EAAE,EA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AC,CAAC,OAAO,CAAC,2CAA2C,EAAE,EAAE,CAAC,CAAA;IAChE,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAC;IACpB,uEAAuE;IACvE,wEAAwE;IACxE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAA;IACxC,2EAA2E;IAC3E,2DAA2D;IAC3D,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,kEAAkE,EAAE,EAAE,CAAC,CAAA;IACrF,2EAA2E;IAC3E,oEAAoE;IACpE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,gDAAgD,EAAE,EAAE,CAAC,CAAA;IACnE,OAAO,CAAC,CAAA;AACV,CAAC"}
package/dist/builder.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Accumulates ContentElement[] and delegates final rendering to render().
6
6
  */
7
7
  import { runPipeline } from './pipeline.js';
8
- import { applyPostProcessing } from './post-process.js';
8
+ import { applyPostProcessing } from './signing/index.js';
9
9
  /**
10
10
  * Create a new PDF document using the fluent builder API.
11
11
  *