@zip.js/zip.js 2.13.0 → 2.14.0

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 (50) hide show
  1. package/BENCHMARKS.md +46 -1
  2. package/deno.json +1 -1
  3. package/dist/zip-core-external.js +594 -935
  4. package/dist/zip-core-external.min.js +1 -1
  5. package/dist/zip-core.js +461 -908
  6. package/dist/zip-core.min.js +1 -1
  7. package/dist/zip-fs-core-external.js +601 -938
  8. package/dist/zip-fs-core-external.min.js +1 -1
  9. package/dist/zip-fs-core.js +468 -911
  10. package/dist/zip-fs-core.min.js +1 -1
  11. package/dist/zip-fs-external.js +601 -938
  12. package/dist/zip-fs-external.min.js +1 -1
  13. package/dist/zip-fs-native.js +470 -913
  14. package/dist/zip-fs-native.min.js +1 -1
  15. package/dist/zip-fs.js +604 -941
  16. package/dist/zip-fs.min.js +1 -1
  17. package/dist/zip-legacy.js +463 -910
  18. package/dist/zip-legacy.min.js +1 -1
  19. package/dist/zip-module.wasm +0 -0
  20. package/dist/zip-native.js +463 -910
  21. package/dist/zip-native.min.js +1 -1
  22. package/dist/zip-web-worker-native.js +1 -1
  23. package/dist/zip-web-worker.js +1 -1
  24. package/dist/zip.js +597 -938
  25. package/dist/zip.min.js +1 -1
  26. package/index-native.cjs +470 -913
  27. package/index-native.min.js +1 -1
  28. package/index.cjs +604 -941
  29. package/index.d.cts +58 -12
  30. package/index.d.ts +58 -12
  31. package/index.min.js +1 -1
  32. package/lib/core/codec-worker-web.js +35 -11
  33. package/lib/core/codec-worker.js +33 -23
  34. package/lib/core/io.js +29 -21
  35. package/lib/core/streams/aes-crypto-stream.js +58 -99
  36. package/lib/core/streams/codecs/aes-hmac-sha1.js +348 -0
  37. package/lib/core/streams/zlib-wasm/aes-hmac-sha1-wasm.js +106 -0
  38. package/lib/core/streams/zlib-wasm/zlib-streams-loader.js +4 -0
  39. package/lib/core/streams/zlib-wasm/zlib-streams.wasm +0 -0
  40. package/lib/core/version.js +1 -1
  41. package/lib/core/web-worker-base.js +15 -9
  42. package/lib/core/web-worker-inline-native.js +1 -1
  43. package/lib/core/web-worker-inline-wasm.js +1 -1
  44. package/lib/core/web-worker-wasm.js +2 -0
  45. package/lib/core/zip-fs.js +7 -3
  46. package/lib/core/zip-writer.js +1 -2
  47. package/lib/core/zlib-streams-inline.js +1 -1
  48. package/lib/zip-module-wasm-base.js +3 -1
  49. package/package.json +1 -1
  50. package/lib/core/streams/codecs/sjcl.js +0 -795
package/BENCHMARKS.md CHANGED
@@ -33,7 +33,7 @@ should not trust anyone's benchmark (including this one) without reproducing it.
33
33
  | jszip | 3.10.1 |
34
34
  | fflate | 0.8.3 |
35
35
  | archiver | 8.0.0 |
36
- | Measured | 2026-09-06 — the 7-Zip section under Deno 2.9.6, everything else on Node |
36
+ | Measured | 2026-09-06 — the 7-Zip section under Deno 2.9.6, everything else on Node; the encryption section on 2026-09-09, also under Bun 1.4.2, Deno 2.9.6, Firefox 154 and Chrome 153 |
37
37
 
38
38
  ## Method
39
39
 
@@ -219,6 +219,50 @@ zip.js has the fastest large-stream decompression. On thousands of tiny entries
219
219
  per-entry setup cost dominates and **fflate is dramatically faster and lighter** — again
220
220
  the right tool when you are unpacking many small files.
221
221
 
222
+ ## Encryption — AES-256, stored entry
223
+
224
+ An AES entry pays the cipher on every byte, so this section measures the engines zip.js can run
225
+ the WinZip cipher on (AES-CTR with the Gladman counter, HMAC-SHA1) against the sjcl code they
226
+ replaced after 2.13.1. The entry is stored (level 0) so no codec sits in the pipeline, and the
227
+ "before" row is the 2.13.1 bundle measured by the same script. 20 MB of incompressible data,
228
+ in-process, single thread, median of 5; the two numbers are one archive written, then read back.
229
+
230
+ | Engine | Node.js | Bun | Deno |
231
+ |---|--:|--:|--:|
232
+ | WebAssembly, linked into the module of the WebAssembly builds | **111 / 111 MB/s** | **115 / 115** | 99 / 100 |
233
+ | JavaScript, the fallback of those builds and the engine of the native and core builds | 91 / 86 | 102 / 102 | **109 / 103** |
234
+ | 2.13.1, sjcl | 26 / 25 | 29 / 29 | 19 / 19 |
235
+
236
+ The same entry at 32 MB in a browser, through the Web Worker pool, median of 3 passes
237
+ ([`benchmarks/bench-aes.html`](benchmarks/bench-aes.html)):
238
+
239
+ | Engine | Firefox 154 | Chrome 153 |
240
+ |---|--:|--:|
241
+ | WebAssembly | **87 / 89 MB/s** | **99 / 101** |
242
+ | JavaScript | 55 / 59 | 77 / 77 |
243
+ | 2.13.1, sjcl | 17 / 17 | 22 / 22 |
244
+
245
+ What to take from it:
246
+
247
+ - **The JavaScript engine alone is 3.5× sjcl on Node and 3 to 4× in browsers.** sjcl ran the
248
+ cipher 16 bytes at a time through a generic bit-array layer; the new engine works on typed
249
+ arrays and is fed whole chunks. Every build has it.
250
+ - **The WebAssembly kernel is the same code in C, and it is flat across hosts: 100 to 115 MB/s
251
+ everywhere.** What varies is the JavaScript engine, within 20 % of the kernel either way on
252
+ Node, Bun and Deno, whose JITs run typed-array code about as fast as wasm, and 1.3 to 1.6×
253
+ slower in browsers (Safari 26.6, measured at the engine level only, sits with Chrome at 1.3×).
254
+ The WebAssembly builds use the kernel whenever their module loads and fall back to the
255
+ JavaScript engine when it cannot, for instance under a Content Security Policy without
256
+ `'wasm-unsafe-eval'`, which is why the fallback stays in the bundle.
257
+ - **Neither is hardware AES, and nothing in a browser can be.** OpenSSL on this machine encrypts
258
+ AES-256-CTR at 5.8 GB/s with the ARMv8 instructions and at 245 MB/s with them disabled
259
+ (`OPENSSL_armcap=0`). WebAssembly has no access to them, and Web Crypto cannot run this counter
260
+ mode: it increments the last byte where WinZip increments the first, and it offers no ECB to
261
+ build the keystream from. Software AES in the 100 to 120 MB/s range is the ceiling until a
262
+ platform API exposes the instructions.
263
+ - The kernel costs the default bundle 2.1 KB gzipped; the native and core builds carry only the
264
+ JavaScript engine and grew by 0.1 KB.
265
+
222
266
  ## Streaming a large file — 256 MB, disk → zip → disk
223
267
 
224
268
  The input is streamed from disk and the archive is streamed back to disk; neither is
@@ -446,6 +490,7 @@ npm run corpus # generate the deterministic datasets under .corpus/
446
490
  node bench.js # the head-to-head tables (compress / decompress / disk streaming)
447
491
  node bench-backends.js # the parallelism & codec-backend matrix
448
492
  node bench-codecs.js # the codecs alone, sorted by output size
493
+ node bench-aes.js # the AES engines on a stored entry (also: bun / deno run -A); bench-aes.html is the browser page
449
494
  deno run -A bench-7z.js # zip.js vs the 7zz CLI (also: bun bench-7z.js)
450
495
  ```
451
496
 
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zip-js/zip-js",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "exports": {
5
5
  ".": "./index.js",
6
6
  "./external": "./lib/zip-fs-external.js",