pdf-oxide-wasm 0.3.37 → 0.3.39

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.
package/README.md CHANGED
@@ -167,7 +167,7 @@ const pngBytes = doc.extractImageBytes(0);
167
167
 
168
168
  ```javascript
169
169
  doc.setTitle("Quarterly Report");
170
- doc.setAuthor("Finance Team");
170
+ doc.setAuthor("Example Author");
171
171
  doc.setPageRotation(0, 90);
172
172
  doc.cropMargins(36, 36, 36, 36);
173
173
  doc.eraseRegion(0, 50, 50, 200, 100);
@@ -0,0 +1 @@
1
+ {"type":"module","sideEffects":false}
@@ -1,6 +1,26 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Horizontal-alignment enum shared by `textInRect`, buffered `table`, and
6
+ * `streamingTable`. Maps 1:1 onto [`crate::writer::TextAlign`] /
7
+ * [`crate::writer::CellAlign`]. Exported to JS as `Align` via `js_name`.
8
+ */
9
+ export enum Align {
10
+ /**
11
+ * Align to the left edge.
12
+ */
13
+ Left = 0,
14
+ /**
15
+ * Center horizontally.
16
+ */
17
+ Center = 1,
18
+ /**
19
+ * Align to the right edge.
20
+ */
21
+ Right = 2,
22
+ }
23
+
4
24
  /**
5
25
  * Style configuration for header/footer text.
6
26
  */
@@ -26,25 +46,42 @@ export class ArtifactStyle {
26
46
  }
27
47
 
28
48
  /**
29
- * Chroma subsampling format
49
+ * WASM handle to a streaming-table building session. Created by
50
+ * `FluentPageBuilder.streamingTable()`; rows are pushed via `pushRow`,
51
+ * and the session is sealed with `finish()`.
52
+ *
53
+ * Single-use: `finish()` twice throws, and `pushRow` after `finish()`
54
+ * throws. The rows are buffered and replayed against the real Rust
55
+ * `StreamingTable` at `WasmFluentPageBuilder.done()` commit time —
56
+ * preserving the FluentPageBuilder borrow-lifetime invariant that can't
57
+ * cross the wasm-bindgen boundary.
30
58
  */
31
- export enum ChromaSampling {
59
+ export class StreamingTable {
60
+ private constructor();
61
+ free(): void;
62
+ [Symbol.dispose](): void;
32
63
  /**
33
- * Both vertically and horizontally subsampled.
64
+ * Number of columns configured on this streaming table.
34
65
  */
35
- Cs420 = 0,
66
+ columnCount(): number;
36
67
  /**
37
- * Horizontally subsampled.
68
+ * Seal the streaming table — the buffered rows are flushed onto the
69
+ * parent page's op queue, to be replayed against the real Rust
70
+ * `StreamingTable` at `done()` commit time. Calling `finish()` twice
71
+ * throws.
38
72
  */
39
- Cs422 = 1,
73
+ finish(): void;
40
74
  /**
41
- * Not subsampled.
75
+ * Push one row as an array of cell strings (all rowspan=1). Returns an
76
+ * error if the table has already been finished or if the row's cell count
77
+ * does not match the column count.
42
78
  */
43
- Cs444 = 2,
79
+ pushRow(cells: string[]): void;
44
80
  /**
45
- * Monochrome.
81
+ * Push one row with per-cell rowspan values. `cells` is a JS array of
82
+ * `[text, rowspan]` two-element arrays. `rowspan == 1` is a normal cell.
46
83
  */
47
- Cs400 = 3,
84
+ pushRowSpan(cells: any): void;
48
85
  }
49
86
 
50
87
  /**
@@ -79,6 +116,376 @@ export class WasmArtifact {
79
116
  withStyle(style: ArtifactStyle): WasmArtifact;
80
117
  }
81
118
 
119
+ /**
120
+ * X.509 certificate parsed from a raw DER blob. Mirrors the C#,
121
+ * Node, Python, and Go `Certificate` surfaces — `subject` / `issuer`
122
+ * / `serial` / `validity` / `isValid` getters only.
123
+ */
124
+ export class WasmCertificate {
125
+ private constructor();
126
+ free(): void;
127
+ [Symbol.dispose](): void;
128
+ /**
129
+ * Load a certificate from a DER-encoded X.509 blob. Throws if
130
+ * the DER doesn't parse.
131
+ */
132
+ static load(data: Uint8Array): WasmCertificate;
133
+ /**
134
+ * Load a signer certificate + private key from PEM strings.
135
+ * `certPem` must begin `-----BEGIN CERTIFICATE-----`.
136
+ * `keyPem` must begin `-----BEGIN PRIVATE KEY-----` or `-----BEGIN RSA PRIVATE KEY-----`.
137
+ */
138
+ static loadPem(cert_pem: string, key_pem: string): WasmCertificate;
139
+ /**
140
+ * Load a signer certificate + private key from a PKCS#12 (.p12/.pfx) blob.
141
+ * `password` is the passphrase protecting the key bag.
142
+ */
143
+ static loadPkcs12(data: Uint8Array, password: string): WasmCertificate;
144
+ /**
145
+ * Whether the certificate is currently within its validity
146
+ * window. Does NOT verify chain, trust-root, or revocation.
147
+ */
148
+ readonly isValid: boolean;
149
+ /**
150
+ * Issuer distinguished name.
151
+ */
152
+ readonly issuer: string;
153
+ /**
154
+ * Serial number as a hex string (no `0x` prefix).
155
+ */
156
+ readonly serial: string;
157
+ /**
158
+ * Subject distinguished name.
159
+ */
160
+ readonly subject: string;
161
+ /**
162
+ * Validity window as `[notBefore, notAfter]` Unix epoch seconds.
163
+ * JavaScript: `new Date(notBefore * 1000)` for a Date.
164
+ */
165
+ readonly validity: BigInt64Array;
166
+ }
167
+
168
+ /**
169
+ * WASM wrapper for [`crate::writer::DocumentBuilder`]. Fluent API for
170
+ * programmatic multi-page PDF construction with embedded fonts and
171
+ * annotations.
172
+ *
173
+ * The terminal methods (`build`, `toBytesEncrypted`) **consume** the
174
+ * builder; subsequent calls throw `Error: DocumentBuilder already
175
+ * consumed`.
176
+ */
177
+ export class WasmDocumentBuilder {
178
+ free(): void;
179
+ [Symbol.dispose](): void;
180
+ /**
181
+ * Start a new A4 page. Returns a `FluentPageBuilder` that must be
182
+ * committed with `.done()` before calling another page method or a
183
+ * terminal (`build`, etc.).
184
+ */
185
+ a4Page(): WasmFluentPageBuilder;
186
+ /**
187
+ * Set document author.
188
+ */
189
+ author(author: string): void;
190
+ /**
191
+ * Build the PDF and return it as a `Uint8Array`. **Consumes** the
192
+ * builder.
193
+ */
194
+ build(): Uint8Array;
195
+ /**
196
+ * Commit a completed `FluentPageBuilder` back to this builder.
197
+ * Takes the place of the Rust `page.done()` re-parenting.
198
+ *
199
+ * JS users typically don't call this directly — the ergonomic
200
+ * pattern is `builder.a4Page();` for each page, then
201
+ * `builder.commitPage(page)` once ops are queued. For more fluent
202
+ * code, see the `FluentPageBuilder.done(builder)` helper which
203
+ * delegates to this method.
204
+ */
205
+ commitPage(page: WasmFluentPageBuilder): void;
206
+ /**
207
+ * Set the creator application name recorded in the PDF.
208
+ */
209
+ creator(creator: string): void;
210
+ /**
211
+ * Set document keywords (comma-separated per PDF convention).
212
+ */
213
+ keywords(keywords: string): void;
214
+ /**
215
+ * Set the document's natural language tag (e.g. `"en-US"`).
216
+ *
217
+ * Emitted as `/Lang` in the catalog when `taggedPdfUa1()` is set.
218
+ */
219
+ language(lang: string): void;
220
+ /**
221
+ * Start a new US Letter page.
222
+ */
223
+ letterPage(): WasmFluentPageBuilder;
224
+ /**
225
+ * Create a new empty document builder. Equivalent to the Rust
226
+ * [`crate::writer::DocumentBuilder::new`] — every other method
227
+ * chains off the instance returned here.
228
+ */
229
+ constructor();
230
+ /**
231
+ * Run a JavaScript script when the document is opened (`/OpenAction`).
232
+ */
233
+ onOpen(script: string): void;
234
+ /**
235
+ * Start a new page with custom dimensions in PDF points
236
+ * (72 pt = 1 inch).
237
+ */
238
+ page(width: number, height: number): WasmFluentPageBuilder;
239
+ /**
240
+ * Register a TTF / OTF font the pages can reference by name.
241
+ * **Consumes** `font` — reusing the `WasmEmbeddedFont` throws.
242
+ */
243
+ registerEmbeddedFont(name: string, font: WasmEmbeddedFont): void;
244
+ /**
245
+ * Add a role-map entry: custom structure type → standard PDF structure type.
246
+ *
247
+ * Emitted in `/RoleMap` inside the StructTreeRoot when `taggedPdfUa1()`
248
+ * is set. Multiple calls accumulate entries.
249
+ */
250
+ roleMap(custom: string, standard: string): void;
251
+ /**
252
+ * Set document subject.
253
+ */
254
+ subject(subject: string): void;
255
+ /**
256
+ * Enable PDF/UA-1 tagged PDF mode.
257
+ *
258
+ * When enabled, `build()` emits `/MarkInfo`, `/StructTreeRoot`, `/Lang`,
259
+ * and `/ViewerPreferences` in the catalog. Opt-in — no effect unless called.
260
+ */
261
+ taggedPdfUa1(): void;
262
+ /**
263
+ * Set document title.
264
+ */
265
+ title(title: string): void;
266
+ /**
267
+ * Build the PDF with AES-256 encryption and return it as a
268
+ * `Uint8Array`. Granted permissions default to all. **Consumes**
269
+ * the builder.
270
+ */
271
+ toBytesEncrypted(user_password: string, owner_password: string): Uint8Array;
272
+ }
273
+
274
+ /**
275
+ * Embedded TTF/OTF font usable by `WasmDocumentBuilder`. Single-use: once
276
+ * passed to `registerEmbeddedFont`, the underlying Rust `EmbeddedFont` is
277
+ * moved into the builder and this handle becomes empty.
278
+ */
279
+ export class WasmEmbeddedFont {
280
+ private constructor();
281
+ free(): void;
282
+ [Symbol.dispose](): void;
283
+ /**
284
+ * Load an embedded font from raw TTF/OTF bytes. Pass `name` to
285
+ * override the PostScript name baked into the font file.
286
+ */
287
+ static fromBytes(data: Uint8Array, name?: string | null): WasmEmbeddedFont;
288
+ /**
289
+ * The font's PostScript name (or the override). Empty once consumed.
290
+ */
291
+ readonly name: string;
292
+ }
293
+
294
+ /**
295
+ * Per-page fluent builder. Buffers operations until `done(builder)` is
296
+ * called, which commits them to the parent `WasmDocumentBuilder`. Each
297
+ * instance is single-use — `done()` twice throws.
298
+ */
299
+ export class WasmFluentPageBuilder {
300
+ private constructor();
301
+ free(): void;
302
+ [Symbol.dispose](): void;
303
+ at(x: number, y: number): void;
304
+ /**
305
+ * Place a 1-D barcode image at `(x, y, w, h)` on the page.
306
+ * `barcodeType`: 0=Code128 1=Code39 2=EAN13 3=EAN8 4=UPCA 5=ITF
307
+ * 6=Code93 7=Codabar.
308
+ */
309
+ barcode1d(barcode_type: number, data: string, x: number, y: number, w: number, h: number): void;
310
+ /**
311
+ * Place a QR-code image at `(x, y, size, size)` on the page.
312
+ */
313
+ barcodeQr(data: string, x: number, y: number, size: number): void;
314
+ checkbox(name: string, x: number, y: number, w: number, h: number, checked: boolean): void;
315
+ /**
316
+ * Lay out `text` as balanced multi-column flow (`columnCount` columns,
317
+ * `gapPt` points between columns). Paragraphs in `text` are separated by `"\n\n"`.
318
+ */
319
+ columns(column_count: number, gap_pt: number, text: string): void;
320
+ /**
321
+ * Add a dropdown combo-box.
322
+ */
323
+ comboBox(name: string, x: number, y: number, w: number, h: number, options: string[], selected?: string | null): void;
324
+ /**
325
+ * Convenience: commit this page's buffered ops to `builder`. Same
326
+ * as `builder.commitPage(this)` but lets JS users keep the
327
+ * chain-like flow:
328
+ *
329
+ * ```javascript
330
+ * const page = builder.a4Page();
331
+ * page.at(72, 720); page.text("Hi");
332
+ * page.done(builder);
333
+ * ```
334
+ */
335
+ done(builder: WasmDocumentBuilder): void;
336
+ fieldCalculate(script: string): void;
337
+ fieldFormat(script: string): void;
338
+ fieldKeystroke(script: string): void;
339
+ fieldValidate(script: string): void;
340
+ /**
341
+ * Draw a filled rectangle. RGB channels in 0.0-1.0.
342
+ */
343
+ filledRect(x: number, y: number, w: number, h: number, r: number, g: number, b: number): void;
344
+ font(name: string, size: number): void;
345
+ /**
346
+ * Add a footnote: inline `refMark` at the cursor and `noteText` body
347
+ * near the page bottom with a separator artifact line.
348
+ */
349
+ footnote(ref_mark: string, note_text: string): void;
350
+ freeText(x: number, y: number, w: number, h: number, text: string): void;
351
+ heading(level: number, text: string): void;
352
+ highlight(r: number, g: number, b: number): void;
353
+ horizontalRule(): void;
354
+ /**
355
+ * Embed a decorative image (JPEG/PNG/WebP bytes) as an /Artifact (no alt text).
356
+ */
357
+ imageArtifact(bytes: Uint8Array, x: number, y: number, w: number, h: number): void;
358
+ /**
359
+ * Embed an image (JPEG/PNG/WebP bytes) with an accessibility alt text.
360
+ */
361
+ imageWithAlt(bytes: Uint8Array, x: number, y: number, w: number, h: number, alt_text: string): void;
362
+ /**
363
+ * Emit `text` inline (advances cursorX only, not cursorY).
364
+ */
365
+ inline(text: string): void;
366
+ /**
367
+ * Inline bold run.
368
+ */
369
+ inlineBold(text: string): void;
370
+ /**
371
+ * Inline colored run (RGB 0.0–1.0).
372
+ */
373
+ inlineColor(r: number, g: number, b: number, text: string): void;
374
+ /**
375
+ * Inline italic run.
376
+ */
377
+ inlineItalic(text: string): void;
378
+ /**
379
+ * Draw a line from (x1, y1) to (x2, y2) with 1pt black stroke.
380
+ */
381
+ line(x1: number, y1: number, x2: number, y2: number): void;
382
+ linkJavascript(script: string): void;
383
+ linkNamed(destination: string): void;
384
+ linkPage(page: number): void;
385
+ linkUrl(url: string): void;
386
+ /**
387
+ * Measure the rendered width of `text` in the builder's current font
388
+ * and size, in PDF points. Pure query — does not mutate state.
389
+ *
390
+ * Thin JS view over [`crate::writer::FluentPageBuilder::measure`]. The
391
+ * WASM class tracks the current font/size independently of the
392
+ * buffered ops so this query is served without a live builder.
393
+ */
394
+ measure(text: string): number;
395
+ /**
396
+ * Finish the current page and start a new one with the same page
397
+ * size. Cursor resets to the top-left margin (72, height-72). The
398
+ * builder's font carries over.
399
+ */
400
+ newPageSameSize(): void;
401
+ /**
402
+ * Advance cursorY by one line-height and reset cursorX to 72 pt.
403
+ */
404
+ newline(): void;
405
+ onClose(script: string): void;
406
+ onOpen(script: string): void;
407
+ paragraph(text: string): void;
408
+ /**
409
+ * Add a clickable push button with a visible caption.
410
+ */
411
+ pushButton(name: string, x: number, y: number, w: number, h: number, caption: string): void;
412
+ /**
413
+ * Add a radio-button group. `values`, `xs`, `ys`, `ws`, `hs` are
414
+ * parallel arrays of length N describing each option's export
415
+ * value and rectangle. `selected` picks the initial value.
416
+ */
417
+ radioGroup(name: string, values: string[], xs: Float32Array, ys: Float32Array, ws: Float32Array, hs: Float32Array, selected?: string | null): void;
418
+ /**
419
+ * Draw a stroked rectangle outline (1pt black).
420
+ */
421
+ rect(x: number, y: number, w: number, h: number): void;
422
+ /**
423
+ * Points remaining on the current page below the cursor (down to the
424
+ * 72 pt bottom margin). Mirrors
425
+ * [`crate::writer::FluentPageBuilder::remaining_space`] using the WASM
426
+ * class's independently-tracked cursor — accurate after `at`, `text`,
427
+ * `space`, `newPageSameSize`, `textInRect` and the table helpers.
428
+ */
429
+ remainingSpace(): number;
430
+ /**
431
+ * Add an unsigned signature placeholder field at the given bounds.
432
+ */
433
+ signatureField(name: string, x: number, y: number, w: number, h: number): void;
434
+ space(points: number): void;
435
+ squiggly(r: number, g: number, b: number): void;
436
+ stamp(name: string): void;
437
+ stickyNote(text: string): void;
438
+ stickyNoteAt(x: number, y: number, text: string): void;
439
+ /**
440
+ * Open a streaming table. Returns a `StreamingTable` handle the caller
441
+ * pushes rows into; call `finish()` when done. The streamed rows are
442
+ * buffered per-table and replayed against the real Rust
443
+ * `StreamingTable` at `done()` commit time — avoiding the
444
+ * FluentPageBuilder-lifetime problem that otherwise can't cross the
445
+ * wasm-bindgen boundary.
446
+ */
447
+ streamingTable(spec: any): StreamingTable;
448
+ strikeout(r: number, g: number, b: number): void;
449
+ /**
450
+ * Draw a straight line with explicit stroke width and RGB colour.
451
+ */
452
+ strokeLine(x1: number, y1: number, x2: number, y2: number, width: number, r: number, g: number, b: number): void;
453
+ /**
454
+ * Draw a stroked rectangle with explicit stroke width and RGB colour.
455
+ */
456
+ strokeRect(x: number, y: number, w: number, h: number, width: number, r: number, g: number, b: number): void;
457
+ /**
458
+ * Render a buffered table from a JS object:
459
+ *
460
+ * ```javascript
461
+ * page.table({
462
+ * columns: [
463
+ * { header: "SKU", width: 100, align: Align.Left },
464
+ * { header: "Qty", width: 60, align: Align.Right },
465
+ * ],
466
+ * rows: [["A-1","12"], ["B-2","3"]],
467
+ * hasHeader: true,
468
+ * });
469
+ * ```
470
+ *
471
+ * Uses `serde-wasm-bindgen` for deserialisation. Replays against the
472
+ * Rust `Table` builder at `done()` commit time.
473
+ */
474
+ table(spec: any): void;
475
+ text(text: string): void;
476
+ textField(name: string, x: number, y: number, w: number, h: number, default_value?: string | null): void;
477
+ /**
478
+ * Place wrapped text inside a rectangle with horizontal alignment.
479
+ * `align` is the `Align` enum (0 = Left, 1 = Center, 2 = Right) — also
480
+ * accepts a raw integer for JS callers that pre-date the enum import.
481
+ */
482
+ textInRect(x: number, y: number, w: number, h: number, text: string, align: number): void;
483
+ underline(r: number, g: number, b: number): void;
484
+ watermark(text: string): void;
485
+ watermarkConfidential(): void;
486
+ watermarkDraft(): void;
487
+ }
488
+
82
489
  /**
83
490
  * A footer definition.
84
491
  */
@@ -203,6 +610,21 @@ export class WasmPdf {
203
610
  * @param author - Optional document author
204
611
  */
205
612
  static fromHtml(content: string, title?: string | null, author?: string | null): WasmPdf;
613
+ /**
614
+ * Render `html` with `css` applied, embedding `font_bytes` for the
615
+ * body text. The font must cover every codepoint used by `html` or
616
+ * unknown glyphs fall back to `.notdef`. See
617
+ * [`Self::from_html_css_with_fonts`] for a multi-font cascade.
618
+ */
619
+ static fromHtmlCss(html: string, css: string, font_bytes: Uint8Array): WasmPdf;
620
+ /**
621
+ * Render `html` + `css` with a multi-font cascade. `families` and
622
+ * `fonts` are parallel arrays: `families[i]` names the CSS
623
+ * `font-family` that resolves to `fonts[i]` bytes. The first entry
624
+ * is the default used whenever a CSS `font-family` doesn't match a
625
+ * registered family.
626
+ */
627
+ static fromHtmlCssWithFonts(html: string, css: string, families: string[], fonts: Uint8Array[]): WasmPdf;
206
628
  /**
207
629
  * Create a PDF from image bytes (PNG, JPEG, etc.).
208
630
  *
@@ -477,6 +899,15 @@ export class WasmPdfDocument {
477
899
  * Flatten annotations on a page into the page content.
478
900
  */
479
901
  flattenPageAnnotations(page_index: number): void;
902
+ /**
903
+ * Return warnings collected during the last form-flattening save.
904
+ *
905
+ * Each entry names a widget field that had no `/AP` appearance stream;
906
+ * flattening such a field produces a blank rectangle.
907
+ *
908
+ * @returns Array of warning strings
909
+ */
910
+ flattenWarnings(): string[];
480
911
  /**
481
912
  * Get annotations from a page.
482
913
  *
@@ -530,6 +961,13 @@ export class WasmPdfDocument {
530
961
  * @returns Number of pages merged
531
962
  */
532
963
  mergeFrom(data: Uint8Array): number;
964
+ /**
965
+ * Move a page within the document. Zero-based; `from_index` and
966
+ * `to_index` refer to positions **before** the move, matching the
967
+ * Python (`PyPdfDocument.move_page`) / Go (`DocumentEditor.MovePage`) /
968
+ * C# contracts.
969
+ */
970
+ movePage(from_index: number, to_index: number): void;
533
971
  /**
534
972
  * Load a PDF document from raw bytes.
535
973
  *
@@ -626,6 +1064,16 @@ export class WasmPdfDocument {
626
1064
  * @returns Uint8Array containing the modified PDF
627
1065
  */
628
1066
  saveToBytes(): Uint8Array;
1067
+ /**
1068
+ * Save with options (compress, garbage_collect, linearize) and return bytes.
1069
+ *
1070
+ * @param {Object} [options] - Optional save options.
1071
+ * @param {boolean} [options.compress=true] - Compress raw streams with FlateDecode.
1072
+ * @param {boolean} [options.garbageCollect=true] - Remove unreachable objects.
1073
+ * @param {boolean} [options.linearize=false] - Linearize (reserved, no-op).
1074
+ * @returns Uint8Array containing the modified PDF
1075
+ */
1076
+ saveWithOptions(compress?: boolean | null, garbage_collect?: boolean | null, linearize?: boolean | null): Uint8Array;
629
1077
  /**
630
1078
  * Search for text across all pages.
631
1079
  *
@@ -681,6 +1129,17 @@ export class WasmPdfDocument {
681
1129
  * Set the document title.
682
1130
  */
683
1131
  setTitle(title: string): void;
1132
+ /**
1133
+ * Count existing PDF signatures. Returns 0 when the document has
1134
+ * no AcroForm or no signed signature fields.
1135
+ */
1136
+ signatureCount(): number;
1137
+ /**
1138
+ * Enumerate existing PDF signatures. Each entry is a
1139
+ * `WasmSignature` (inspection-only) mirroring the C# and Python
1140
+ * Signature surfaces.
1141
+ */
1142
+ signatures(): WasmSignature[];
684
1143
  /**
685
1144
  * Convert a single page to HTML.
686
1145
  *
@@ -793,6 +1252,119 @@ export class WasmPdfPageRegion {
793
1252
  extractWords(): any;
794
1253
  }
795
1254
 
1255
+ /**
1256
+ * A single existing PDF signature surfaced by
1257
+ * `WasmPdfDocument.signatures()`. `verify()` runs the RSA-PKCS#1 v1.5
1258
+ * signer-attributes check; `verifyDetached()` adds the
1259
+ * `messageDigest` content-hash check. RSA-PSS / ECDSA signers still
1260
+ * throw an `UnsupportedFeature`-mapped JS error.
1261
+ */
1262
+ export class WasmSignature {
1263
+ private constructor();
1264
+ free(): void;
1265
+ [Symbol.dispose](): void;
1266
+ /**
1267
+ * Run the RFC 5652 §5.4 signer-attributes crypto check. Today
1268
+ * this covers RSA-PKCS#1 v1.5 over SHA-1/256/384/512 — the
1269
+ * padding used by essentially every PDF signature.
1270
+ *
1271
+ * A `true` return proves the signer held the private key matching
1272
+ * the embedded certificate and that the signed-attribute bundle
1273
+ * is authentic. It does **not** verify the `messageDigest`
1274
+ * attribute against the document's byte-range content hash —
1275
+ * call `verifyDetached()` for that end-to-end check.
1276
+ *
1277
+ * Throws for RSA-PSS, ECDSA, unknown digest OIDs, or signatures
1278
+ * without signed_attrs.
1279
+ */
1280
+ verify(): boolean;
1281
+ /**
1282
+ * End-to-end detached-signature verification. Runs both the
1283
+ * signer-attributes RSA-PKCS#1 v1.5 crypto check AND the RFC 5652
1284
+ * §11.2 `messageDigest` check against the segment of `pdfData`
1285
+ * this signature covers (extracted via `/ByteRange`).
1286
+ *
1287
+ * `pdfData` must be the full PDF file. A `true` result proves
1288
+ * both the signer is authentic and that the document's byte-range
1289
+ * content has not been altered since signing. `false` means one
1290
+ * of the two checks failed (wrong key or tampered content).
1291
+ *
1292
+ * Throws for RSA-PSS, ECDSA, unknown digest OIDs, or CMS blobs
1293
+ * missing `signed_attrs` / `messageDigest`.
1294
+ */
1295
+ verifyDetached(pdf_data: Uint8Array): boolean;
1296
+ /**
1297
+ * `/ContactInfo` entry from the signature dictionary, if present.
1298
+ */
1299
+ readonly contactInfo: string | undefined;
1300
+ /**
1301
+ * True iff `/ByteRange` is a 4-element array covering the whole
1302
+ * document (i.e. the signature protects every byte of the file).
1303
+ */
1304
+ readonly coversWholeDocument: boolean;
1305
+ /**
1306
+ * `/Location` entry from the signature dictionary, if present.
1307
+ */
1308
+ readonly location: string | undefined;
1309
+ /**
1310
+ * `/Reason` entry from the signature dictionary, if present.
1311
+ */
1312
+ readonly reason: string | undefined;
1313
+ /**
1314
+ * `/Name` entry from the signature dictionary, if present.
1315
+ */
1316
+ readonly signerName: string | undefined;
1317
+ /**
1318
+ * Unix epoch (seconds). `None` if the `/M` entry is missing or
1319
+ * unparseable.
1320
+ */
1321
+ readonly signingTime: bigint | undefined;
1322
+ }
1323
+
1324
+ /**
1325
+ * RFC 3161 timestamp parsed from a DER TimeStampToken or bare
1326
+ * TSTInfo. Mirrors the C#, Go, and Python `Timestamp` surfaces.
1327
+ */
1328
+ export class WasmTimestamp {
1329
+ private constructor();
1330
+ free(): void;
1331
+ [Symbol.dispose](): void;
1332
+ /**
1333
+ * Parse a DER blob that may be either a full TimeStampToken or
1334
+ * the bare TSTInfo SEQUENCE.
1335
+ */
1336
+ static parse(data: Uint8Array): WasmTimestamp;
1337
+ /**
1338
+ * Cryptographic verify — not yet implemented.
1339
+ */
1340
+ verify(): boolean;
1341
+ /**
1342
+ * Hash algorithm enum value (1=SHA1, 2=SHA256, 3=SHA384,
1343
+ * 4=SHA512, 0=unknown).
1344
+ */
1345
+ readonly hashAlgorithm: number;
1346
+ /**
1347
+ * Raw message-imprint hash bytes.
1348
+ */
1349
+ readonly messageImprint: Uint8Array;
1350
+ /**
1351
+ * TSA policy OID in dotted-decimal form.
1352
+ */
1353
+ readonly policyOid: string;
1354
+ /**
1355
+ * Serial number as a hex string (no `0x` prefix).
1356
+ */
1357
+ readonly serial: string;
1358
+ /**
1359
+ * Generation time as Unix epoch seconds.
1360
+ */
1361
+ readonly time: bigint;
1362
+ /**
1363
+ * TSA name from the token (may be empty).
1364
+ */
1365
+ readonly tsaName: string;
1366
+ }
1367
+
796
1368
  /**
797
1369
  * Disable all pdf_oxide log output — convenience wrapper for
798
1370
  * `setLogLevel("off")`.
@@ -817,3 +1389,11 @@ export function disableLogging(): void;
817
1389
  * ```
818
1390
  */
819
1391
  export function setLogLevel(level: string): void;
1392
+
1393
+ /**
1394
+ * Sign raw PDF bytes and return the signed PDF as a `Uint8Array`.
1395
+ *
1396
+ * `cert` must carry a private key (loaded via `Certificate.loadPem` or
1397
+ * `Certificate.loadPkcs12`).
1398
+ */
1399
+ export function signPdfBytes(pdf_data: Uint8Array, cert: WasmCertificate, reason?: string | null, location?: string | null): Uint8Array;
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./pdf_oxide.d.ts" */
2
+ import * as wasm from "./pdf_oxide_bg.wasm";
3
+ import { __wbg_set_wasm } from "./pdf_oxide_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+
7
+ export {
8
+ Align, ArtifactStyle, StreamingTable, WasmArtifact, WasmCertificate, WasmDocumentBuilder, WasmEmbeddedFont, WasmFluentPageBuilder, WasmFooter, WasmHeader, WasmOcrConfig, WasmOcrEngine, WasmPageTemplate, WasmPdf, WasmPdfDocument, WasmPdfPageRegion, WasmSignature, WasmTimestamp, disableLogging, setLogLevel, signPdfBytes
9
+ } from "./pdf_oxide_bg.js";