Skip to content

fix(signatures): ensure crypto engine is always installed before use#36

Merged
Mythie merged 2 commits intomainfrom
fix/always-install-crypto-engine
Feb 23, 2026
Merged

fix(signatures): ensure crypto engine is always installed before use#36
Mythie merged 2 commits intomainfrom
fix/always-install-crypto-engine

Conversation

@Mythie
Copy link
Contributor

@Mythie Mythie commented Feb 23, 2026

Replace the fire-once installCryptoEngine() and module-level
pkijs.getCrypto() calls with a lazy getCrypto() accessor that
installs the engine on first use. This avoids initialization-order
issues where the crypto engine was not yet set when users called
into the signing APIs.

Resolves #35

Replace the fire-once installCryptoEngine() and module-level
pkijs.getCrypto() calls with a lazy getCrypto() accessor that
installs the engine on first use. This avoids initialization-order
issues where the crypto engine was not yet set when users called
into the signing APIs.
@vercel
Copy link
Contributor

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
core Ready Ready Preview, Comment Feb 23, 2026 9:41pm

@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

Benchmark Results

Comparison

Load PDF

Benchmark Mean p99 RME Samples
libpdf 2.34ms 3.23ms ±1.5% 214
pdf-lib 39.10ms 44.62ms ±4.7% 13

Create blank PDF

Benchmark Mean p99 RME Samples
libpdf 56μs 116μs ±1.6% 8965
pdf-lib 412μs 1.47ms ±2.4% 1215

Add 10 pages

Benchmark Mean p99 RME Samples
libpdf 100μs 178μs ±1.3% 4991
pdf-lib 546μs 2.16ms ±3.2% 918

Draw 50 rectangles

Benchmark Mean p99 RME Samples
libpdf 330μs 889μs ±1.6% 1517
pdf-lib 1.88ms 7.27ms ±7.9% 266

Load and save PDF

Benchmark Mean p99 RME Samples
libpdf 2.58ms 4.31ms ±3.0% 194
pdf-lib 88.74ms 95.52ms ±3.5% 10

Load, modify, and save PDF

Benchmark Mean p99 RME Samples
libpdf 41.85ms 45.55ms ±2.7% 13
pdf-lib 88.53ms 94.66ms ±3.5% 10

Extract single page from 100-page PDF

Benchmark Mean p99 RME Samples
libpdf 3.67ms 6.05ms ±1.8% 137
pdf-lib 9.53ms 14.96ms ±3.4% 53

Split 100-page PDF into single-page PDFs

Benchmark Mean p99 RME Samples
libpdf 33.67ms 39.11ms ±2.9% 15
pdf-lib 88.55ms 92.66ms ±4.2% 6

Split 2000-page PDF into single-page PDFs (0.9MB)

Benchmark Mean p99 RME Samples
libpdf 628.41ms 628.41ms ±0.0% 1
pdf-lib 1.67s 1.67s ±0.0% 1

Copy 10 pages between documents

Benchmark Mean p99 RME Samples
libpdf 4.60ms 5.44ms ±1.3% 109
pdf-lib 12.06ms 14.47ms ±1.9% 42

Merge 2 x 100-page PDFs

Benchmark Mean p99 RME Samples
libpdf 14.52ms 17.90ms ±1.7% 35
pdf-lib 55.00ms 56.30ms ±1.1% 10
Copying

Copy pages between documents

Benchmark Mean p99 RME Samples
copy 1 page 940μs 1.82ms ±2.0% 533
copy 10 pages from 100-page PDF 4.55ms 8.73ms ±3.1% 110
copy all 100 pages 7.58ms 8.62ms ±1.1% 66

Duplicate pages within same document

Benchmark Mean p99 RME Samples
duplicate page 0 960μs 1.67ms ±2.2% 522
duplicate all pages (double the document) 893μs 1.53ms ±1.5% 561

Merge PDFs

Benchmark Mean p99 RME Samples
merge 2 small PDFs 1.41ms 2.54ms ±1.3% 355
merge 10 small PDFs 7.27ms 9.96ms ±1.3% 69
merge 2 x 100-page PDFs 13.68ms 14.34ms ±0.7% 37
Drawing

benchmarks/drawing.bench.ts

Benchmark Mean p99 RME Samples
draw 100 rectangles 578μs 1.45ms ±2.6% 865
draw 100 circles 1.29ms 3.09ms ±2.9% 388
draw 100 lines 511μs 1.19ms ±1.6% 979
draw 100 text lines (standard font) 1.58ms 2.51ms ±1.4% 317
create 10 pages with mixed content 1.35ms 2.43ms ±2.0% 372
Forms

benchmarks/forms.bench.ts

Benchmark Mean p99 RME Samples
get form fields 3.29ms 6.19ms ±3.2% 152
fill text fields 11.44ms 16.12ms ±4.7% 44
read field values 2.93ms 5.36ms ±1.7% 171
flatten form 8.72ms 13.71ms ±3.4% 58
Loading

benchmarks/loading.bench.ts

Benchmark Mean p99 RME Samples
load small PDF (888B) 70μs 162μs ±4.3% 7098
load medium PDF (19KB) 109μs 162μs ±4.8% 4590
load form PDF (116KB) 1.49ms 3.06ms ±2.6% 336
load heavy PDF (9.9MB) 2.40ms 3.78ms ±1.8% 209
Saving

benchmarks/saving.bench.ts

Benchmark Mean p99 RME Samples
save unmodified (19KB) 110μs 262μs ±1.1% 4550
save with modifications (19KB) 755μs 1.41ms ±1.7% 663
incremental save (19KB) 167μs 362μs ±1.2% 3001
save heavy PDF (9.9MB) 2.26ms 2.94ms ±1.1% 221
incremental save heavy PDF (9.9MB) 8.07ms 9.38ms ±3.0% 62
Splitting

Extract single page

Benchmark Mean p99 RME Samples
extractPages (1 page from small PDF) 976μs 2.01ms ±2.5% 513
extractPages (1 page from 100-page PDF) 3.66ms 5.21ms ±2.6% 137
extractPages (1 page from 2000-page PDF) 60.36ms 69.62ms ±4.2% 10

Split into single-page PDFs

Benchmark Mean p99 RME Samples
split 100-page PDF (0.1MB) 33.81ms 39.35ms ±4.5% 15
split 2000-page PDF (0.9MB) 594.92ms 594.92ms ±0.0% 1

Batch page extraction

Benchmark Mean p99 RME Samples
extract first 10 pages from 2000-page PDF 58.74ms 60.07ms ±1.0% 9
extract first 100 pages from 2000-page PDF 63.04ms 64.65ms ±2.0% 8
extract every 10th page from 2000-page PDF (200 pages) 67.28ms 69.52ms ±1.4% 8
Environment
  • Runner: Linux (X64)
  • Runtime: Bun 1.3.9

Results are machine-dependent.

Add saveTestOutput calls for AES-128, 3DES, and RC2 P12 signing
tests so the signed PDFs can be manually verified in a viewer.
@Mythie Mythie merged commit 2e7ee0f into main Feb 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please call "setEngine" before call to "getEngine"

1 participant