@tinyfiles/decoder
v0.1.0
Published
AT-1 (Atom Teleporter) verified-lossless decoder, compiled to WebAssembly. Decode .at1 files in the browser, Node, or at the edge.
Maintainers
Readme
AT-1 WASM decoder
The AT-1 reference decoder compiled to WebAssembly (~196 KB .wasm + ~15 KB JS
glue, with xz+zstd linked in). Decodes .at1 files byte-for-byte in the browser,
Node, Deno, or at the edge — the same fuzz-hardened C decoder used natively, so
malformed input is rejected cleanly (a thrown error), never a crash. Verified against
all committed vectors (every backend + codec) plus a malformed-input check: 11/11.
Use
import { decode, version } from '@at1/decoder';
console.log(await version()); // "AT-1 reference decoder 0.1.0"
const original = await decode(at1Bytes); // Uint8Array -> Uint8Array (the exact source bytes)In the browser: open index.html (served over http) and drop a .at1 file — it is
reconstructed locally; nothing is uploaded.
Scope
The full build supports all backends (xz, zstd, stored) and all codecs (including
qcolumnar) — full parity with the native decoder — by linking a cross-compiled
liblzma. The committed at1_decode.wasm is this full build (~196 KB).
If liblzma for wasm isn't present, build_wasm.sh falls back to a -DAT1_NO_XZ
build (zstd + stored backends, all codecs except qcolumnar); for that mode, produce
wasm-decodable files with at1 compress <domain> --backend zstd ....
Build
Requires Emscripten (emcc on PATH, or EMCC=...) and the
zstd source tree at tools/zstd (or ZSTD_SRC).
For full xz support, first cross-compile liblzma to wasm (needs the xz source at
tools/xz and the em-tools on PATH):
bash build_liblzma_wasm.sh # -> tools/xz/src/liblzma/liblzma.a
bash build_wasm.sh # -> at1_decode.mjs + at1_decode.wasm (FULL build)build_wasm.sh auto-detects the liblzma archive; without it you get the zstd/stored
fallback build.
Test
python make_zstd_vectors.py # generate zstd-backend vectors into ./vectors
node demo_node.mjs # decode each in a JS runtime, assert byte-identityThe committed build is verified against the columnar, log, ssh, and json codecs (byte-identical) plus a malformed-input rejection check (5/5).
