pdf-oxide-wasm 0.3.49 → 0.3.51

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.
@@ -89,6 +89,216 @@ class ArtifactStyle {
89
89
  if (Symbol.dispose) ArtifactStyle.prototype[Symbol.dispose] = ArtifactStyle.prototype.free;
90
90
  exports.ArtifactStyle = ArtifactStyle;
91
91
 
92
+ /**
93
+ * A parsed Document Security Store (`/DSS`, ISO 32000-2 §12.8.4.3).
94
+ * Count + index accessors mirror `WasmCertificate`'s flat shape
95
+ * (wasm-bindgen cannot return `Uint8Array[]` directly).
96
+ */
97
+ class Dss {
98
+ static __wrap(ptr) {
99
+ const obj = Object.create(Dss.prototype);
100
+ obj.__wbg_ptr = ptr;
101
+ DssFinalization.register(obj, obj.__wbg_ptr, obj);
102
+ return obj;
103
+ }
104
+ __destroy_into_raw() {
105
+ const ptr = this.__wbg_ptr;
106
+ this.__wbg_ptr = 0;
107
+ DssFinalization.unregister(this);
108
+ return ptr;
109
+ }
110
+ free() {
111
+ const ptr = this.__destroy_into_raw();
112
+ wasm.__wbg_dss_free(ptr, 0);
113
+ }
114
+ /**
115
+ * Number of DER X.509 certificates in the DSS.
116
+ * @returns {number}
117
+ */
118
+ get certCount() {
119
+ const ret = wasm.wasmdss_certCount(this.__wbg_ptr);
120
+ return ret >>> 0;
121
+ }
122
+ /**
123
+ * Number of DER CRLs in the DSS.
124
+ * @returns {number}
125
+ */
126
+ get crlCount() {
127
+ const ret = wasm.wasmdss_crlCount(this.__wbg_ptr);
128
+ return ret >>> 0;
129
+ }
130
+ /**
131
+ * The `i`-th DER certificate, or `undefined` if out of range.
132
+ * @param {number} i
133
+ * @returns {Uint8Array | undefined}
134
+ */
135
+ getCert(i) {
136
+ try {
137
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
138
+ wasm.wasmdss_getCert(retptr, this.__wbg_ptr, i);
139
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
140
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
141
+ let v1;
142
+ if (r0 !== 0) {
143
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
144
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
145
+ }
146
+ return v1;
147
+ } finally {
148
+ wasm.__wbindgen_add_to_stack_pointer(16);
149
+ }
150
+ }
151
+ /**
152
+ * The `i`-th DER CRL, or `undefined` if out of range.
153
+ * @param {number} i
154
+ * @returns {Uint8Array | undefined}
155
+ */
156
+ getCrl(i) {
157
+ try {
158
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
159
+ wasm.wasmdss_getCrl(retptr, this.__wbg_ptr, i);
160
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
161
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
162
+ let v1;
163
+ if (r0 !== 0) {
164
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
165
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
166
+ }
167
+ return v1;
168
+ } finally {
169
+ wasm.__wbindgen_add_to_stack_pointer(16);
170
+ }
171
+ }
172
+ /**
173
+ * The `i`-th DER OCSP response, or `undefined` if out of range.
174
+ * @param {number} i
175
+ * @returns {Uint8Array | undefined}
176
+ */
177
+ getOcsp(i) {
178
+ try {
179
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
180
+ wasm.wasmdss_getOcsp(retptr, this.__wbg_ptr, i);
181
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
182
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
183
+ let v1;
184
+ if (r0 !== 0) {
185
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
186
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
187
+ }
188
+ return v1;
189
+ } finally {
190
+ wasm.__wbindgen_add_to_stack_pointer(16);
191
+ }
192
+ }
193
+ /**
194
+ * Number of DER OCSP responses in the DSS.
195
+ * @returns {number}
196
+ */
197
+ get ocspCount() {
198
+ const ret = wasm.wasmdss_ocspCount(this.__wbg_ptr);
199
+ return ret >>> 0;
200
+ }
201
+ /**
202
+ * Per-signature VRI keys (uppercase-hex SHA-1 of `/Contents`).
203
+ * @returns {string[]}
204
+ */
205
+ get vri() {
206
+ try {
207
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
208
+ wasm.wasmdss_vri(retptr, this.__wbg_ptr);
209
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
210
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
211
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
212
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
213
+ return v1;
214
+ } finally {
215
+ wasm.__wbindgen_add_to_stack_pointer(16);
216
+ }
217
+ }
218
+ }
219
+ if (Symbol.dispose) Dss.prototype[Symbol.dispose] = Dss.prototype.free;
220
+ exports.Dss = Dss;
221
+
222
+ /**
223
+ * PAdES baseline level. Frozen integer mapping (BB=0, BT=1, BLt=2,
224
+ * BLta=3) shared with the C ABI and every binding — never renumber.
225
+ * @enum {0 | 1 | 2 | 3}
226
+ */
227
+ const PadesLevel = Object.freeze({
228
+ /**
229
+ * B-B: signed attrs incl. the ESS signing-certificate-v2.
230
+ */
231
+ BB: 0, "0": "BB",
232
+ /**
233
+ * B-T: B-B + an RFC 3161 signature-time-stamp unsigned attr.
234
+ */
235
+ BT: 1, "1": "BT",
236
+ /**
237
+ * B-LT: B-T + a Document Security Store (DSS/VRI).
238
+ */
239
+ BLt: 2, "2": "BLt",
240
+ /**
241
+ * B-LTA: B-LT + a document-scoped `/DocTimeStamp`.
242
+ */
243
+ BLta: 3, "3": "BLta",
244
+ });
245
+ exports.PadesLevel = PadesLevel;
246
+
247
+ /**
248
+ * Offline B-LT validation material (DER certs / CRLs / OCSP
249
+ * responses). Build with `new()` then `addCert`/`addCrl`/`addOcsp`.
250
+ */
251
+ class RevocationMaterial {
252
+ __destroy_into_raw() {
253
+ const ptr = this.__wbg_ptr;
254
+ this.__wbg_ptr = 0;
255
+ RevocationMaterialFinalization.unregister(this);
256
+ return ptr;
257
+ }
258
+ free() {
259
+ const ptr = this.__destroy_into_raw();
260
+ wasm.__wbg_revocationmaterial_free(ptr, 0);
261
+ }
262
+ /**
263
+ * Add a DER X.509 certificate.
264
+ * @param {Uint8Array} der
265
+ */
266
+ addCert(der) {
267
+ const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_export);
268
+ const len0 = WASM_VECTOR_LEN;
269
+ wasm.wasmrevocationmaterial_addCert(this.__wbg_ptr, ptr0, len0);
270
+ }
271
+ /**
272
+ * Add a DER CRL.
273
+ * @param {Uint8Array} der
274
+ */
275
+ addCrl(der) {
276
+ const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_export);
277
+ const len0 = WASM_VECTOR_LEN;
278
+ wasm.wasmrevocationmaterial_addCrl(this.__wbg_ptr, ptr0, len0);
279
+ }
280
+ /**
281
+ * Add a DER OCSP response.
282
+ * @param {Uint8Array} der
283
+ */
284
+ addOcsp(der) {
285
+ const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_export);
286
+ const len0 = WASM_VECTOR_LEN;
287
+ wasm.wasmrevocationmaterial_addOcsp(this.__wbg_ptr, ptr0, len0);
288
+ }
289
+ /**
290
+ * Create an empty revocation-material set.
291
+ */
292
+ constructor() {
293
+ const ret = wasm.wasmrevocationmaterial_new();
294
+ this.__wbg_ptr = ret;
295
+ RevocationMaterialFinalization.register(this, this.__wbg_ptr, this);
296
+ return this;
297
+ }
298
+ }
299
+ if (Symbol.dispose) RevocationMaterial.prototype[Symbol.dispose] = RevocationMaterial.prototype.free;
300
+ exports.RevocationMaterial = RevocationMaterial;
301
+
92
302
  /**
93
303
  * WASM handle to a streaming-table building session. Created by
94
304
  * `FluentPageBuilder.streamingTable()`; rows are pushed via `pushRow`,
@@ -2830,6 +3040,31 @@ class WasmPdfDocument {
2830
3040
  const ptr = this.__destroy_into_raw();
2831
3041
  wasm.__wbg_wasmpdfdocument_free(ptr, 0);
2832
3042
  }
3043
+ /**
3044
+ * Queue an explicit destructive redaction rectangle on a page
3045
+ * (page user space; `fill` is an optional DeviceRGB `[r,g,b]`).
3046
+ * @param {number} page
3047
+ * @param {number} x0
3048
+ * @param {number} y0
3049
+ * @param {number} x1
3050
+ * @param {number} y1
3051
+ * @param {Float32Array | null} [fill]
3052
+ */
3053
+ addRedaction(page, x0, y0, x1, y1, fill) {
3054
+ try {
3055
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3056
+ var ptr0 = isLikeNone(fill) ? 0 : passArrayF32ToWasm0(fill, wasm.__wbindgen_export);
3057
+ var len0 = WASM_VECTOR_LEN;
3058
+ wasm.wasmpdfdocument_addRedaction(retptr, this.__wbg_ptr, page, x0, y0, x1, y1, ptr0, len0);
3059
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3060
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3061
+ if (r1) {
3062
+ throw takeObject(r0);
3063
+ }
3064
+ } finally {
3065
+ wasm.__wbindgen_add_to_stack_pointer(16);
3066
+ }
3067
+ }
2833
3068
  /**
2834
3069
  * Apply all redactions in the document.
2835
3070
  */
@@ -2863,6 +3098,27 @@ class WasmPdfDocument {
2863
3098
  wasm.__wbindgen_add_to_stack_pointer(16);
2864
3099
  }
2865
3100
  }
3101
+ /**
3102
+ * Destructively apply all queued redactions (true content removal,
3103
+ * ISO 32000-1:2008 §12.5.6.23). Returns a `RedactionReport` object.
3104
+ * @param {boolean | null} [scrub_metadata]
3105
+ * @returns {any}
3106
+ */
3107
+ applyRedactionsDestructive(scrub_metadata) {
3108
+ try {
3109
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3110
+ wasm.wasmpdfdocument_applyRedactionsDestructive(retptr, this.__wbg_ptr, isLikeNone(scrub_metadata) ? 0xFFFFFF : scrub_metadata ? 1 : 0);
3111
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3112
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3113
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3114
+ if (r2) {
3115
+ throw takeObject(r1);
3116
+ }
3117
+ return takeObject(r0);
3118
+ } finally {
3119
+ wasm.__wbindgen_add_to_stack_pointer(16);
3120
+ }
3121
+ }
2866
3122
  /**
2867
3123
  * Authenticate with a password to decrypt an encrypted PDF.
2868
3124
  *
@@ -2888,6 +3144,64 @@ class WasmPdfDocument {
2888
3144
  wasm.__wbindgen_add_to_stack_pointer(16);
2889
3145
  }
2890
3146
  }
3147
+ /**
3148
+ * Cheap per-page text-vs-OCR classification → JSON
3149
+ * `DocumentClassification`.
3150
+ * @returns {string}
3151
+ */
3152
+ classifyDocument() {
3153
+ let deferred2_0;
3154
+ let deferred2_1;
3155
+ try {
3156
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3157
+ wasm.wasmpdfdocument_classifyDocument(retptr, this.__wbg_ptr);
3158
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3159
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3160
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3161
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3162
+ var ptr1 = r0;
3163
+ var len1 = r1;
3164
+ if (r3) {
3165
+ ptr1 = 0; len1 = 0;
3166
+ throw takeObject(r2);
3167
+ }
3168
+ deferred2_0 = ptr1;
3169
+ deferred2_1 = len1;
3170
+ return getStringFromWasm0(ptr1, len1);
3171
+ } finally {
3172
+ wasm.__wbindgen_add_to_stack_pointer(16);
3173
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
3174
+ }
3175
+ }
3176
+ /**
3177
+ * Cheap per-page classification → JSON `PageClassification`.
3178
+ * @param {number} page_index
3179
+ * @returns {string}
3180
+ */
3181
+ classifyPage(page_index) {
3182
+ let deferred2_0;
3183
+ let deferred2_1;
3184
+ try {
3185
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3186
+ wasm.wasmpdfdocument_classifyPage(retptr, this.__wbg_ptr, page_index);
3187
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3188
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3189
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3190
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3191
+ var ptr1 = r0;
3192
+ var len1 = r1;
3193
+ if (r3) {
3194
+ ptr1 = 0; len1 = 0;
3195
+ throw takeObject(r2);
3196
+ }
3197
+ deferred2_0 = ptr1;
3198
+ deferred2_1 = len1;
3199
+ return getStringFromWasm0(ptr1, len1);
3200
+ } finally {
3201
+ wasm.__wbindgen_add_to_stack_pointer(16);
3202
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
3203
+ }
3204
+ }
2891
3205
  /**
2892
3206
  * Clear all pending erase operations for a page.
2893
3207
  * @param {number} page_index
@@ -2967,6 +3281,26 @@ class WasmPdfDocument {
2967
3281
  wasm.__wbindgen_add_to_stack_pointer(16);
2968
3282
  }
2969
3283
  }
3284
+ /**
3285
+ * The document's Document Security Store (`/DSS`) as a `Dss`, or
3286
+ * `undefined` if absent. Mirrors Rust `signatures::read_dss`.
3287
+ * @returns {Dss | undefined}
3288
+ */
3289
+ dss() {
3290
+ try {
3291
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3292
+ wasm.wasmpdfdocument_dss(retptr, this.__wbg_ptr);
3293
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3294
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3295
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3296
+ if (r2) {
3297
+ throw takeObject(r1);
3298
+ }
3299
+ return r0 === 0 ? undefined : Dss.__wrap(r0);
3300
+ } finally {
3301
+ wasm.__wbindgen_add_to_stack_pointer(16);
3302
+ }
3303
+ }
2970
3304
  /**
2971
3305
  * Deprecated: Use eraseFooter instead.
2972
3306
  * @param {number} page_index
@@ -3296,6 +3630,40 @@ class WasmPdfDocument {
3296
3630
  wasm.__wbindgen_add_to_stack_pointer(16);
3297
3631
  }
3298
3632
  }
3633
+ /**
3634
+ * Rich per-page extraction → JSON `PageExtraction` (per-region
3635
+ * bbox + typed reason). `optionsJson` is `{}`-tolerant
3636
+ * `AutoExtractOptions`; undefined/empty → defaults.
3637
+ * @param {number} page_index
3638
+ * @param {string | null} [options_json]
3639
+ * @returns {string}
3640
+ */
3641
+ extractPageAuto(page_index, options_json) {
3642
+ let deferred3_0;
3643
+ let deferred3_1;
3644
+ try {
3645
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3646
+ var ptr0 = isLikeNone(options_json) ? 0 : passStringToWasm0(options_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3647
+ var len0 = WASM_VECTOR_LEN;
3648
+ wasm.wasmpdfdocument_extractPageAuto(retptr, this.__wbg_ptr, page_index, ptr0, len0);
3649
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3650
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3651
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3652
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3653
+ var ptr2 = r0;
3654
+ var len2 = r1;
3655
+ if (r3) {
3656
+ ptr2 = 0; len2 = 0;
3657
+ throw takeObject(r2);
3658
+ }
3659
+ deferred3_0 = ptr2;
3660
+ deferred3_1 = len2;
3661
+ return getStringFromWasm0(ptr2, len2);
3662
+ } finally {
3663
+ wasm.__wbindgen_add_to_stack_pointer(16);
3664
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
3665
+ }
3666
+ }
3299
3667
  /**
3300
3668
  * Extract complete page text data in a single call.
3301
3669
  *
@@ -3497,6 +3865,36 @@ class WasmPdfDocument {
3497
3865
  wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
3498
3866
  }
3499
3867
  }
3868
+ /**
3869
+ * One-shot auto text extraction — graceful native fallback (never
3870
+ * the opaque OCR error #513).
3871
+ * @param {number} page_index
3872
+ * @returns {string}
3873
+ */
3874
+ extractTextAuto(page_index) {
3875
+ let deferred2_0;
3876
+ let deferred2_1;
3877
+ try {
3878
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3879
+ wasm.wasmpdfdocument_extractTextAuto(retptr, this.__wbg_ptr, page_index);
3880
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3881
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3882
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3883
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
3884
+ var ptr1 = r0;
3885
+ var len1 = r1;
3886
+ if (r3) {
3887
+ ptr1 = 0; len1 = 0;
3888
+ throw takeObject(r2);
3889
+ }
3890
+ deferred2_0 = ptr1;
3891
+ deferred2_1 = len1;
3892
+ return getStringFromWasm0(ptr1, len1);
3893
+ } finally {
3894
+ wasm.__wbindgen_add_to_stack_pointer(16);
3895
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
3896
+ }
3897
+ }
3500
3898
  /**
3501
3899
  * Extract text lines from a page.
3502
3900
  *
@@ -4110,6 +4508,26 @@ class WasmPdfDocument {
4110
4508
  wasm.__wbindgen_add_to_stack_pointer(16);
4111
4509
  }
4112
4510
  }
4511
+ /**
4512
+ * Number of redaction regions queued for `page`.
4513
+ * @param {number} page
4514
+ * @returns {number}
4515
+ */
4516
+ redactionCount(page) {
4517
+ try {
4518
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4519
+ wasm.wasmpdfdocument_redactionCount(retptr, this.__wbg_ptr, page);
4520
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4521
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4522
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4523
+ if (r2) {
4524
+ throw takeObject(r1);
4525
+ }
4526
+ return r0 >>> 0;
4527
+ } finally {
4528
+ wasm.__wbindgen_add_to_stack_pointer(16);
4529
+ }
4530
+ }
4113
4531
  /**
4114
4532
  * Identify and remove both headers and footers.
4115
4533
  *
@@ -4294,6 +4712,30 @@ class WasmPdfDocument {
4294
4712
  wasm.__wbindgen_add_to_stack_pointer(16);
4295
4713
  }
4296
4714
  }
4715
+ /**
4716
+ * Standalone document sanitization (#231 T10): strip `/Info`,
4717
+ * catalog XMP `/Metadata`, document JavaScript and embedded files
4718
+ * without geometric redaction. Returns a `RedactionReport` object.
4719
+ * @param {boolean | null} [scrub_metadata]
4720
+ * @param {boolean | null} [remove_javascript]
4721
+ * @param {boolean | null} [remove_embedded_files]
4722
+ * @returns {any}
4723
+ */
4724
+ sanitizeDocument(scrub_metadata, remove_javascript, remove_embedded_files) {
4725
+ try {
4726
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4727
+ wasm.wasmpdfdocument_sanitizeDocument(retptr, this.__wbg_ptr, isLikeNone(scrub_metadata) ? 0xFFFFFF : scrub_metadata ? 1 : 0, isLikeNone(remove_javascript) ? 0xFFFFFF : remove_javascript ? 1 : 0, isLikeNone(remove_embedded_files) ? 0xFFFFFF : remove_embedded_files ? 1 : 0);
4728
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4729
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4730
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4731
+ if (r2) {
4732
+ throw takeObject(r1);
4733
+ }
4734
+ return takeObject(r0);
4735
+ } finally {
4736
+ wasm.__wbindgen_add_to_stack_pointer(16);
4737
+ }
4738
+ }
4297
4739
  /**
4298
4740
  * Save all edits and return the resulting PDF as bytes.
4299
4741
  *
@@ -5400,6 +5842,16 @@ class WasmSignature {
5400
5842
  wasm.__wbindgen_add_to_stack_pointer(16);
5401
5843
  }
5402
5844
  }
5845
+ /**
5846
+ * PAdES baseline level from this signature's CMS attributes alone
5847
+ * (`BB` vs `BT`). `BLt` additionally needs the document `/DSS` —
5848
+ * read it via `WasmPdfDocument.dss()` and re-classify there.
5849
+ * @returns {PadesLevel}
5850
+ */
5851
+ get padesLevel() {
5852
+ const ret = wasm.wasmsignature_padesLevel(this.__wbg_ptr);
5853
+ return ret;
5854
+ }
5403
5855
  /**
5404
5856
  * `/Reason` entry from the signature dictionary, if present.
5405
5857
  * @returns {string | undefined}
@@ -5688,6 +6140,73 @@ class WasmTimestamp {
5688
6140
  if (Symbol.dispose) WasmTimestamp.prototype[Symbol.dispose] = WasmTimestamp.prototype.free;
5689
6141
  exports.WasmTimestamp = WasmTimestamp;
5690
6142
 
6143
+ /**
6144
+ * A CycloneDX 1.6 Cryptographic Bill of Materials (JSON string) of the
6145
+ * algorithms exercised so far this process (#230 Phase F).
6146
+ * @returns {string}
6147
+ */
6148
+ function cryptoCbom() {
6149
+ let deferred1_0;
6150
+ let deferred1_1;
6151
+ try {
6152
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6153
+ wasm.cryptoCbom(retptr);
6154
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6155
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6156
+ deferred1_0 = r0;
6157
+ deferred1_1 = r1;
6158
+ return getStringFromWasm0(r0, r1);
6159
+ } finally {
6160
+ wasm.__wbindgen_add_to_stack_pointer(16);
6161
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
6162
+ }
6163
+ }
6164
+ exports.cryptoCbom = cryptoCbom;
6165
+
6166
+ /**
6167
+ * The cryptographic algorithm tokens exercised so far this process
6168
+ * (governance report), as a JSON string array.
6169
+ * @returns {any}
6170
+ */
6171
+ function cryptoInventory() {
6172
+ try {
6173
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6174
+ wasm.cryptoInventory(retptr);
6175
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6176
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6177
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6178
+ if (r2) {
6179
+ throw takeObject(r1);
6180
+ }
6181
+ return takeObject(r0);
6182
+ } finally {
6183
+ wasm.__wbindgen_add_to_stack_pointer(16);
6184
+ }
6185
+ }
6186
+ exports.cryptoInventory = cryptoInventory;
6187
+
6188
+ /**
6189
+ * The active crypto policy as its canonical grammar string.
6190
+ * @returns {string}
6191
+ */
6192
+ function cryptoPolicy() {
6193
+ let deferred1_0;
6194
+ let deferred1_1;
6195
+ try {
6196
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6197
+ wasm.cryptoPolicy(retptr);
6198
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6199
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6200
+ deferred1_0 = r0;
6201
+ deferred1_1 = r1;
6202
+ return getStringFromWasm0(r0, r1);
6203
+ } finally {
6204
+ wasm.__wbindgen_add_to_stack_pointer(16);
6205
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
6206
+ }
6207
+ }
6208
+ exports.cryptoPolicy = cryptoPolicy;
6209
+
5691
6210
  /**
5692
6211
  * Disable all pdf_oxide log output — convenience wrapper for
5693
6212
  * `setLogLevel("off")`.
@@ -5770,6 +6289,121 @@ function generateQrSvg(data, error_correction, size) {
5770
6289
  }
5771
6290
  exports.generateQrSvg = generateQrSvg;
5772
6291
 
6292
+ /**
6293
+ * Whether `pdf_data` carries a document-scoped RFC 3161
6294
+ * `/DocTimeStamp` archival timestamp (PAdES-B-LTA). This is the
6295
+ * document-level reader signal; a `WasmSignature`'s `padesLevel`
6296
+ * getter is signature-scoped and tops out at B-LT by design.
6297
+ * @param {Uint8Array} pdf_data
6298
+ * @returns {boolean}
6299
+ */
6300
+ function hasDocumentTimestamp(pdf_data) {
6301
+ const ptr0 = passArray8ToWasm0(pdf_data, wasm.__wbindgen_export);
6302
+ const len0 = WASM_VECTOR_LEN;
6303
+ const ret = wasm.hasDocumentTimestamp(ptr0, len0);
6304
+ return ret !== 0;
6305
+ }
6306
+ exports.hasDocumentTimestamp = hasDocumentTimestamp;
6307
+
6308
+ /**
6309
+ * #519: Air-gapped OCR model manifest — JSON (detector + every
6310
+ * supported language's cache filenames and source URLs).
6311
+ *
6312
+ * WASM provisioning is **host-side**: browser/WASM has no filesystem
6313
+ * or network-to-disk, so a download-to-cache prefetch cannot run
6314
+ * here. This manifest is informational — it lets the JS host learn
6315
+ * which model files/URLs to fetch and bundle (or ship out of band)
6316
+ * before driving OCR. There is intentionally no `prefetchModels` in
6317
+ * the WASM surface (see `prefetchAvailable`, which always returns
6318
+ * `false`).
6319
+ * @returns {string}
6320
+ */
6321
+ function modelManifest() {
6322
+ let deferred1_0;
6323
+ let deferred1_1;
6324
+ try {
6325
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6326
+ wasm.modelManifest(retptr);
6327
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6328
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6329
+ deferred1_0 = r0;
6330
+ deferred1_1 = r1;
6331
+ return getStringFromWasm0(r0, r1);
6332
+ } finally {
6333
+ wasm.__wbindgen_add_to_stack_pointer(16);
6334
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
6335
+ }
6336
+ }
6337
+ exports.modelManifest = modelManifest;
6338
+
6339
+ /**
6340
+ * Plan a bookmark split without producing PDFs. Returns a JSON array
6341
+ * of segment objects (`index, startPage…` shape from
6342
+ * `BookmarkSegment`). `level`: 0 = all depths, 1 = top-level.
6343
+ * @param {Uint8Array} src_bytes
6344
+ * @param {string | null | undefined} title_prefix
6345
+ * @param {boolean} ignore_case
6346
+ * @param {number} level
6347
+ * @param {boolean} include_front_matter
6348
+ * @returns {any}
6349
+ */
6350
+ function planSplitByBookmarks(src_bytes, title_prefix, ignore_case, level, include_front_matter) {
6351
+ try {
6352
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6353
+ const ptr0 = passArray8ToWasm0(src_bytes, wasm.__wbindgen_export);
6354
+ const len0 = WASM_VECTOR_LEN;
6355
+ var ptr1 = isLikeNone(title_prefix) ? 0 : passStringToWasm0(title_prefix, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6356
+ var len1 = WASM_VECTOR_LEN;
6357
+ wasm.planSplitByBookmarks(retptr, ptr0, len0, ptr1, len1, ignore_case, level, include_front_matter);
6358
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6359
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6360
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6361
+ if (r2) {
6362
+ throw takeObject(r1);
6363
+ }
6364
+ return takeObject(r0);
6365
+ } finally {
6366
+ wasm.__wbindgen_add_to_stack_pointer(16);
6367
+ }
6368
+ }
6369
+ exports.planSplitByBookmarks = planSplitByBookmarks;
6370
+
6371
+ /**
6372
+ * #519: Whether this build can download OCR models to a local cache.
6373
+ * Always `false` in WASM — provisioning is host-side (see
6374
+ * `modelManifest`).
6375
+ * @returns {boolean}
6376
+ */
6377
+ function prefetchAvailable() {
6378
+ const ret = wasm.prefetchAvailable();
6379
+ return ret !== 0;
6380
+ }
6381
+ exports.prefetchAvailable = prefetchAvailable;
6382
+
6383
+ /**
6384
+ * Install the process-wide runtime crypto policy from its grammar
6385
+ * string (`"compat"|"strict"|"fips-strict"[;…]`). Fail-closed:
6386
+ * throws on an unparseable spec (policy NOT installed) or if a
6387
+ * policy is already set. Default (never set) is `compat`.
6388
+ * @param {string} spec
6389
+ */
6390
+ function setCryptoPolicy(spec) {
6391
+ try {
6392
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6393
+ const ptr0 = passStringToWasm0(spec, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6394
+ const len0 = WASM_VECTOR_LEN;
6395
+ wasm.setCryptoPolicy(retptr, ptr0, len0);
6396
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6397
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6398
+ if (r1) {
6399
+ throw takeObject(r0);
6400
+ }
6401
+ } finally {
6402
+ wasm.__wbindgen_add_to_stack_pointer(16);
6403
+ }
6404
+ }
6405
+ exports.setCryptoPolicy = setCryptoPolicy;
6406
+
5773
6407
  /**
5774
6408
  * Set the maximum log level for pdf_oxide messages.
5775
6409
  *
@@ -5842,6 +6476,90 @@ function signPdfBytes(pdf_data, cert, reason, location) {
5842
6476
  }
5843
6477
  }
5844
6478
  exports.signPdfBytes = signPdfBytes;
6479
+
6480
+ /**
6481
+ * Sign raw PDF bytes at a PAdES baseline level and return the signed
6482
+ * PDF as a `Uint8Array`.
6483
+ *
6484
+ * `level` `BLTA` is reserved (→ error). For `BT`/`BLt` pass a
6485
+ * pre-fetched RFC 3161 `timestampToken` (DER): WASM intentionally
6486
+ * omits the online TSA client (same `ureq`-incompat carve-out as
6487
+ * v0.3.38) — without a token the core fail-closes with `Unsupported`.
6488
+ * `revocation` supplies the B-LT DSS material.
6489
+ * @param {Uint8Array} pdf_data
6490
+ * @param {WasmCertificate} cert
6491
+ * @param {PadesLevel} level
6492
+ * @param {Uint8Array | null} [timestamp_token]
6493
+ * @param {RevocationMaterial | null} [revocation]
6494
+ * @param {string | null} [reason]
6495
+ * @param {string | null} [location]
6496
+ * @returns {Uint8Array}
6497
+ */
6498
+ function signPdfBytesPades(pdf_data, cert, level, timestamp_token, revocation, reason, location) {
6499
+ try {
6500
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6501
+ const ptr0 = passArray8ToWasm0(pdf_data, wasm.__wbindgen_export);
6502
+ const len0 = WASM_VECTOR_LEN;
6503
+ _assertClass(cert, WasmCertificate);
6504
+ var ptr1 = isLikeNone(timestamp_token) ? 0 : passArray8ToWasm0(timestamp_token, wasm.__wbindgen_export);
6505
+ var len1 = WASM_VECTOR_LEN;
6506
+ let ptr2 = 0;
6507
+ if (!isLikeNone(revocation)) {
6508
+ _assertClass(revocation, RevocationMaterial);
6509
+ ptr2 = revocation.__destroy_into_raw();
6510
+ }
6511
+ var ptr3 = isLikeNone(reason) ? 0 : passStringToWasm0(reason, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6512
+ var len3 = WASM_VECTOR_LEN;
6513
+ var ptr4 = isLikeNone(location) ? 0 : passStringToWasm0(location, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6514
+ var len4 = WASM_VECTOR_LEN;
6515
+ wasm.signPdfBytesPades(retptr, ptr0, len0, cert.__wbg_ptr, level, ptr1, len1, ptr2, ptr3, len3, ptr4, len4);
6516
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6517
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6518
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6519
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
6520
+ if (r3) {
6521
+ throw takeObject(r2);
6522
+ }
6523
+ var v6 = getArrayU8FromWasm0(r0, r1).slice();
6524
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6525
+ return v6;
6526
+ } finally {
6527
+ wasm.__wbindgen_add_to_stack_pointer(16);
6528
+ }
6529
+ }
6530
+ exports.signPdfBytesPades = signPdfBytesPades;
6531
+
6532
+ /**
6533
+ * Split at bookmark boundaries. Returns a JSON array of
6534
+ * `[segment, bytes]` pairs (bytes as a number array; source
6535
+ * unmodified).
6536
+ * @param {Uint8Array} src_bytes
6537
+ * @param {string | null | undefined} title_prefix
6538
+ * @param {boolean} ignore_case
6539
+ * @param {number} level
6540
+ * @param {boolean} include_front_matter
6541
+ * @returns {any}
6542
+ */
6543
+ function splitByBookmarks(src_bytes, title_prefix, ignore_case, level, include_front_matter) {
6544
+ try {
6545
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6546
+ const ptr0 = passArray8ToWasm0(src_bytes, wasm.__wbindgen_export);
6547
+ const len0 = WASM_VECTOR_LEN;
6548
+ var ptr1 = isLikeNone(title_prefix) ? 0 : passStringToWasm0(title_prefix, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6549
+ var len1 = WASM_VECTOR_LEN;
6550
+ wasm.splitByBookmarks(retptr, ptr0, len0, ptr1, len1, ignore_case, level, include_front_matter);
6551
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6552
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6553
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6554
+ if (r2) {
6555
+ throw takeObject(r1);
6556
+ }
6557
+ return takeObject(r0);
6558
+ } finally {
6559
+ wasm.__wbindgen_add_to_stack_pointer(16);
6560
+ }
6561
+ }
6562
+ exports.splitByBookmarks = splitByBookmarks;
5845
6563
  function __wbg_get_imports() {
5846
6564
  const import0 = {
5847
6565
  __proto__: null,
@@ -6166,6 +6884,9 @@ const WasmCertificateFinalization = (typeof FinalizationRegistry === 'undefined'
6166
6884
  const WasmDocumentBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
6167
6885
  ? { register: () => {}, unregister: () => {} }
6168
6886
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmdocumentbuilder_free(ptr, 1));
6887
+ const DssFinalization = (typeof FinalizationRegistry === 'undefined')
6888
+ ? { register: () => {}, unregister: () => {} }
6889
+ : new FinalizationRegistry(ptr => wasm.__wbg_dss_free(ptr, 1));
6169
6890
  const WasmEmbeddedFontFinalization = (typeof FinalizationRegistry === 'undefined')
6170
6891
  ? { register: () => {}, unregister: () => {} }
6171
6892
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmembeddedfont_free(ptr, 1));
@@ -6196,6 +6917,9 @@ const WasmPdfDocumentFinalization = (typeof FinalizationRegistry === 'undefined'
6196
6917
  const WasmPdfPageRegionFinalization = (typeof FinalizationRegistry === 'undefined')
6197
6918
  ? { register: () => {}, unregister: () => {} }
6198
6919
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmpdfpageregion_free(ptr, 1));
6920
+ const RevocationMaterialFinalization = (typeof FinalizationRegistry === 'undefined')
6921
+ ? { register: () => {}, unregister: () => {} }
6922
+ : new FinalizationRegistry(ptr => wasm.__wbg_revocationmaterial_free(ptr, 1));
6199
6923
  const WasmSignatureFinalization = (typeof FinalizationRegistry === 'undefined')
6200
6924
  ? { register: () => {}, unregister: () => {} }
6201
6925
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmsignature_free(ptr, 1));