pdf-oxide-wasm 0.3.49 → 0.3.50

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.
@@ -45,6 +45,93 @@ export class ArtifactStyle {
45
45
  constructor();
46
46
  }
47
47
 
48
+ /**
49
+ * A parsed Document Security Store (`/DSS`, ISO 32000-2 §12.8.4.3).
50
+ * Count + index accessors mirror `WasmCertificate`'s flat shape
51
+ * (wasm-bindgen cannot return `Uint8Array[]` directly).
52
+ */
53
+ export class Dss {
54
+ private constructor();
55
+ free(): void;
56
+ [Symbol.dispose](): void;
57
+ /**
58
+ * The `i`-th DER certificate, or `undefined` if out of range.
59
+ */
60
+ getCert(i: number): Uint8Array | undefined;
61
+ /**
62
+ * The `i`-th DER CRL, or `undefined` if out of range.
63
+ */
64
+ getCrl(i: number): Uint8Array | undefined;
65
+ /**
66
+ * The `i`-th DER OCSP response, or `undefined` if out of range.
67
+ */
68
+ getOcsp(i: number): Uint8Array | undefined;
69
+ /**
70
+ * Number of DER X.509 certificates in the DSS.
71
+ */
72
+ readonly certCount: number;
73
+ /**
74
+ * Number of DER CRLs in the DSS.
75
+ */
76
+ readonly crlCount: number;
77
+ /**
78
+ * Number of DER OCSP responses in the DSS.
79
+ */
80
+ readonly ocspCount: number;
81
+ /**
82
+ * Per-signature VRI keys (uppercase-hex SHA-1 of `/Contents`).
83
+ */
84
+ readonly vri: string[];
85
+ }
86
+
87
+ /**
88
+ * PAdES baseline level. Frozen integer mapping (BB=0, BT=1, BLt=2,
89
+ * BLta=3) shared with the C ABI and every binding — never renumber.
90
+ */
91
+ export enum PadesLevel {
92
+ /**
93
+ * B-B: signed attrs incl. the ESS signing-certificate-v2.
94
+ */
95
+ BB = 0,
96
+ /**
97
+ * B-T: B-B + an RFC 3161 signature-time-stamp unsigned attr.
98
+ */
99
+ BT = 1,
100
+ /**
101
+ * B-LT: B-T + a Document Security Store (DSS/VRI).
102
+ */
103
+ BLt = 2,
104
+ /**
105
+ * B-LTA: B-LT + a document-scoped `/DocTimeStamp`.
106
+ */
107
+ BLta = 3,
108
+ }
109
+
110
+ /**
111
+ * Offline B-LT validation material (DER certs / CRLs / OCSP
112
+ * responses). Build with `new()` then `addCert`/`addCrl`/`addOcsp`.
113
+ */
114
+ export class RevocationMaterial {
115
+ free(): void;
116
+ [Symbol.dispose](): void;
117
+ /**
118
+ * Add a DER X.509 certificate.
119
+ */
120
+ addCert(der: Uint8Array): void;
121
+ /**
122
+ * Add a DER CRL.
123
+ */
124
+ addCrl(der: Uint8Array): void;
125
+ /**
126
+ * Add a DER OCSP response.
127
+ */
128
+ addOcsp(der: Uint8Array): void;
129
+ /**
130
+ * Create an empty revocation-material set.
131
+ */
132
+ constructor();
133
+ }
134
+
48
135
  /**
49
136
  * WASM handle to a streaming-table building session. Created by
50
137
  * `FluentPageBuilder.streamingTable()`; rows are pushed via `pushRow`,
@@ -703,6 +790,11 @@ export class WasmPdf {
703
790
  export class WasmPdfDocument {
704
791
  free(): void;
705
792
  [Symbol.dispose](): void;
793
+ /**
794
+ * Queue an explicit destructive redaction rectangle on a page
795
+ * (page user space; `fill` is an optional DeviceRGB `[r,g,b]`).
796
+ */
797
+ addRedaction(page: number, x0: number, y0: number, x1: number, y1: number, fill?: Float32Array | null): void;
706
798
  /**
707
799
  * Apply all redactions in the document.
708
800
  */
@@ -711,6 +803,11 @@ export class WasmPdfDocument {
711
803
  * Apply redactions on a page (removes redacted content permanently).
712
804
  */
713
805
  applyPageRedactions(page_index: number): void;
806
+ /**
807
+ * Destructively apply all queued redactions (true content removal,
808
+ * ISO 32000-1:2008 §12.5.6.23). Returns a `RedactionReport` object.
809
+ */
810
+ applyRedactionsDestructive(scrub_metadata?: boolean | null): any;
714
811
  /**
715
812
  * Authenticate with a password to decrypt an encrypted PDF.
716
813
  *
@@ -737,6 +834,11 @@ export class WasmPdfDocument {
737
834
  * Delete a page by index (0-based).
738
835
  */
739
836
  deletePage(index: number): void;
837
+ /**
838
+ * The document's Document Security Store (`/DSS`) as a `Dss`, or
839
+ * `undefined` if absent. Mirrors Rust `signatures::read_dss`.
840
+ */
841
+ dss(): Dss | undefined;
740
842
  /**
741
843
  * Deprecated: Use eraseFooter instead.
742
844
  */
@@ -1051,6 +1153,10 @@ export class WasmPdfDocument {
1051
1153
  * Get the rotation of a page in degrees (0, 90, 180, 270).
1052
1154
  */
1053
1155
  pageRotation(page_index: number): number;
1156
+ /**
1157
+ * Number of redaction regions queued for `page`.
1158
+ */
1159
+ redactionCount(page: number): number;
1054
1160
  /**
1055
1161
  * Identify and remove both headers and footers.
1056
1162
  *
@@ -1104,6 +1210,12 @@ export class WasmPdfDocument {
1104
1210
  * Rotate a page by the given degrees (adds to current rotation).
1105
1211
  */
1106
1212
  rotatePage(page_index: number, degrees: number): void;
1213
+ /**
1214
+ * Standalone document sanitization (#231 T10): strip `/Info`,
1215
+ * catalog XMP `/Metadata`, document JavaScript and embedded files
1216
+ * without geometric redaction. Returns a `RedactionReport` object.
1217
+ */
1218
+ sanitizeDocument(scrub_metadata?: boolean | null, remove_javascript?: boolean | null, remove_embedded_files?: boolean | null): any;
1107
1219
  /**
1108
1220
  * Save all edits and return the resulting PDF as bytes.
1109
1221
  *
@@ -1374,6 +1486,12 @@ export class WasmSignature {
1374
1486
  * `/Location` entry from the signature dictionary, if present.
1375
1487
  */
1376
1488
  readonly location: string | undefined;
1489
+ /**
1490
+ * PAdES baseline level from this signature's CMS attributes alone
1491
+ * (`BB` vs `BT`). `BLt` additionally needs the document `/DSS` —
1492
+ * read it via `WasmPdfDocument.dss()` and re-classify there.
1493
+ */
1494
+ readonly padesLevel: PadesLevel;
1377
1495
  /**
1378
1496
  * `/Reason` entry from the signature dictionary, if present.
1379
1497
  */
@@ -1437,6 +1555,23 @@ export class WasmTimestamp {
1437
1555
  readonly tsaName: string;
1438
1556
  }
1439
1557
 
1558
+ /**
1559
+ * A CycloneDX 1.6 Cryptographic Bill of Materials (JSON string) of the
1560
+ * algorithms exercised so far this process (#230 Phase F).
1561
+ */
1562
+ export function cryptoCbom(): string;
1563
+
1564
+ /**
1565
+ * The cryptographic algorithm tokens exercised so far this process
1566
+ * (governance report), as a JSON string array.
1567
+ */
1568
+ export function cryptoInventory(): any;
1569
+
1570
+ /**
1571
+ * The active crypto policy as its canonical grammar string.
1572
+ */
1573
+ export function cryptoPolicy(): string;
1574
+
1440
1575
  /**
1441
1576
  * Disable all pdf_oxide log output — convenience wrapper for
1442
1577
  * `setLogLevel("off")`.
@@ -1457,6 +1592,29 @@ export function generateBarcodeSvg(barcode_type: number, data: string): string;
1457
1592
  */
1458
1593
  export function generateQrSvg(data: string, error_correction: number, size: number): string;
1459
1594
 
1595
+ /**
1596
+ * Whether `pdf_data` carries a document-scoped RFC 3161
1597
+ * `/DocTimeStamp` archival timestamp (PAdES-B-LTA). This is the
1598
+ * document-level reader signal; a `WasmSignature`'s `padesLevel`
1599
+ * getter is signature-scoped and tops out at B-LT by design.
1600
+ */
1601
+ export function hasDocumentTimestamp(pdf_data: Uint8Array): boolean;
1602
+
1603
+ /**
1604
+ * Plan a bookmark split without producing PDFs. Returns a JSON array
1605
+ * of segment objects (`index, startPage…` shape from
1606
+ * `BookmarkSegment`). `level`: 0 = all depths, 1 = top-level.
1607
+ */
1608
+ export function planSplitByBookmarks(src_bytes: Uint8Array, title_prefix: string | null | undefined, ignore_case: boolean, level: number, include_front_matter: boolean): any;
1609
+
1610
+ /**
1611
+ * Install the process-wide runtime crypto policy from its grammar
1612
+ * string (`"compat"|"strict"|"fips-strict"[;…]`). Fail-closed:
1613
+ * throws on an unparseable spec (policy NOT installed) or if a
1614
+ * policy is already set. Default (never set) is `compat`.
1615
+ */
1616
+ export function setCryptoPolicy(spec: string): void;
1617
+
1460
1618
  /**
1461
1619
  * Set the maximum log level for pdf_oxide messages.
1462
1620
  *
@@ -1483,3 +1641,22 @@ export function setLogLevel(level: string): void;
1483
1641
  * `Certificate.loadPkcs12`).
1484
1642
  */
1485
1643
  export function signPdfBytes(pdf_data: Uint8Array, cert: WasmCertificate, reason?: string | null, location?: string | null): Uint8Array;
1644
+
1645
+ /**
1646
+ * Sign raw PDF bytes at a PAdES baseline level and return the signed
1647
+ * PDF as a `Uint8Array`.
1648
+ *
1649
+ * `level` `BLTA` is reserved (→ error). For `BT`/`BLt` pass a
1650
+ * pre-fetched RFC 3161 `timestampToken` (DER): WASM intentionally
1651
+ * omits the online TSA client (same `ureq`-incompat carve-out as
1652
+ * v0.3.38) — without a token the core fail-closes with `Unsupported`.
1653
+ * `revocation` supplies the B-LT DSS material.
1654
+ */
1655
+ export function signPdfBytesPades(pdf_data: Uint8Array, cert: WasmCertificate, level: PadesLevel, timestamp_token?: Uint8Array | null, revocation?: RevocationMaterial | null, reason?: string | null, location?: string | null): Uint8Array;
1656
+
1657
+ /**
1658
+ * Split at bookmark boundaries. Returns a JSON array of
1659
+ * `[segment, bytes]` pairs (bytes as a number array; source
1660
+ * unmodified).
1661
+ */
1662
+ export function splitByBookmarks(src_bytes: Uint8Array, title_prefix: string | null | undefined, ignore_case: boolean, level: number, include_front_matter: boolean): any;
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./pdf_oxide_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
 
7
7
  export {
8
- Align, ArtifactStyle, StreamingTable, WasmArtifact, WasmCertificate, WasmDocumentBuilder, WasmEmbeddedFont, WasmFluentPageBuilder, WasmFooter, WasmHeader, WasmOcrConfig, WasmOcrEngine, WasmPageTemplate, WasmPdf, WasmPdfDocument, WasmPdfPageRegion, WasmSignature, WasmTimestamp, disableLogging, generateBarcodeSvg, generateQrSvg, setLogLevel, signPdfBytes
8
+ Align, ArtifactStyle, Dss, PadesLevel, RevocationMaterial, StreamingTable, WasmArtifact, WasmCertificate, WasmDocumentBuilder, WasmEmbeddedFont, WasmFluentPageBuilder, WasmFooter, WasmHeader, WasmOcrConfig, WasmOcrEngine, WasmPageTemplate, WasmPdf, WasmPdfDocument, WasmPdfPageRegion, WasmSignature, WasmTimestamp, cryptoCbom, cryptoInventory, cryptoPolicy, disableLogging, generateBarcodeSvg, generateQrSvg, hasDocumentTimestamp, planSplitByBookmarks, setCryptoPolicy, setLogLevel, signPdfBytes, signPdfBytesPades, splitByBookmarks
9
9
  } from "./pdf_oxide_bg.js";