@officialunofficial/mkit-wasm
v0.0.0-init
Published
WebAssembly bindings for mkit — content-addressed VCS primitives (BLAKE3 hashing, Ed25519 commit signing, in-toto attestations, FastCDC chunking, delta encoding, and Bao verified streaming) for use from JavaScript bundlers, browsers, and edge runtimes.
Maintainers
Readme
mkit-wasm
WebAssembly bindings for mkit — a content-addressed VCS for creative work. The package exposes the pure byte-format and crypto paths from mkit-core and mkit-attest so they can run anywhere a modern JS runtime can: browsers, Cloudflare Workers, Bun, Deno, Node.
No filesystem or network access is performed inside the wasm module. It is a stateless library of object encoders, hashers, signers, verifiers, FastCDC chunkers, delta encoders, and Bao streaming primitives.
Install
bun add @officialunofficial/mkit-wasm
# or
npm i @officialunofficial/mkit-wasm
# or
pnpm add @officialunofficial/mkit-wasmThe published package is built with wasm-pack --target bundler. It works out of the box with esbuild, Wrangler, Vite, webpack, and Rollup. For direct <script type="module"> usage without a bundler, build the crate yourself with --target web.
Usage
The package is built --target bundler, so it auto-initializes on import
— there is no default init export and nothing to await. Just import the
functions you need:
import {
blake3_hex,
commit_verify,
attest_build,
attest_verify,
} from "@officialunofficial/mkit-wasm";
const id = blake3_hex(new TextEncoder().encode("hello"));
console.log(id); // 64-char lowercase hexThis works out of the box with esbuild, Vite, webpack, Rollup, and Wrangler (Cloudflare Workers).
Explicit init (Bun/some Workers setups)
A few bundlers don't auto-instantiate the wasm at import time, leaving every
export throwing __wbindgen_add_to_stack_pointer is not a function. For those,
the package also exports mkit_wasm_init(module): compile a
WebAssembly.Module yourself and inject it once before the first call.
import { mkit_wasm_init, blake3_hex } from "@officialunofficial/mkit-wasm";
// `wasmModule` is a WebAssembly.Module you compiled/imported for your runtime.
mkit_wasm_init(wasmModule);
const id = blake3_hex(new TextEncoder().encode("hello"));For direct <script type="module"> use without a bundler, build the crate
yourself with wasm-pack --target web (that variant exports the classic
await init() default).
Exported functions
Content-addressing and objects:
blake3_hex(bytes) -> string— BLAKE3 of arbitrary bytes as 64-char hex.blob_encode(bytes) -> { bytes, hash_hex }— canonical blob object.tree_encode(entries_json) -> { bytes, hash_hex }— canonical tree object.commit_encode_and_sign(...)— encode and sign a commit object.commit_verify(commit_bytes) -> bool— verify a signed commit.
Signing primitives:
keypair_from_seed(seed_hex)/keypair_generate()— Ed25519 keys.sign_bytes_commit_domain(seed_hex, bytes) -> sig_hex.verify_bytes_commit_domain(pubkey_hex, bytes, sig_hex) -> bool.
Attestations (in-toto/DSSE-style envelopes):
attest_keypair(seed_hex, algo)— ed25519, secp256k1, or p256.attest_build(...)— build and sign an envelope.attest_verify(envelope_json, pubkey_hex, algo) -> bool.
Chunking, delta, and streaming:
chunk_boundaries(bytes)— FastCDC chunk boundary report.chunked_blob_encode(bytes)— chunked-blob object construction.delta_encode(base, target)— produce a delta summary.bao_encode(bytes)— produce a BLAKE3 Bao outboard tree.bao_slice(...)/bao_verify_slice(...)— verified streaming.
The exact JS surface is generated by wasm-bindgen; refer to the
TypeScript declarations shipped in the package for full signatures.
Versioning
This package is generated from the mkit-wasm crate inside the mkit Rust
workspace (rust/crates/mkit-wasm). Each npm release is built from a tagged
commit, so @officialunofficial/[email protected] on npm corresponds to tag vX.Y.Z.
The wasm bundle wraps the same Rust crates the native mkit CLI uses,
so on-disk objects produced here are byte-identical to those produced
by the CLI.
Provenance
Releases are published from GitHub Actions with
npm publish --provenance,
producing a Sigstore-backed attestation tied to the workflow run.
Verify on the npm package page or with npm audit signatures.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
