Expand description
WebAssembly bindings for IPFRS
This module provides browser-compatible bindings for IPFRS using wasm-bindgen. Two storage backends are available:
IpfrsClient: in-memory (HashMap-backed), ephemeral — data is lost on page refresh.IpfrsClientPersistent: IndexedDB-backed, browser-persistent (wasm32 only).
§Quick Start (JavaScript)
import init, { IpfrsClient, compute_cid, verify_cid, version } from './ipfrs_wasm.js';
const _wasm = await init();
// Ephemeral in-memory client
const client = new IpfrsClient();
const cid = await client.add(new TextEncoder().encode("hello ipfrs"));
const bytes = await client.get(cid);
console.log(new TextDecoder().decode(bytes));
// Persistent IndexedDB client (browser only)
const persistent = await IpfrsClientPersistent.new("ipfrs-blocks");
const cid2 = await persistent.add(new TextEncoder().encode("persisted data"));Modules§
- async_
api - Async-friendly API types for IPFRS WASM bindings.
- peer_
state - WebRTC peer connection state machine.
- storage
- IndexedDB-compatible in-memory block store for wasm32.
- webrtc
- WebRTC transport for browser-to-browser peer connectivity.
Structs§
- Ipfrs
Client - IPFRS in-memory client for WebAssembly.
Functions§
- add_
bytes - Add bytes using a temporary in-memory client and return the CID.
- compute_
cid - Compute the CIDv1 (base32-lower, SHA2-256, raw codec) for the given bytes without storing them.
- get_
bytes - Retrieve bytes from an
IpfrsClientby CID. - start
- Initialise the IPFRS WASM module.
- verify_
cid - Verify that
datamatchescid(i.e., recomputing the CID yields the same string). - version
- Return the ipfrs-wasm version string.