Skip to main content

Crate vcp_wasm

Crate vcp_wasm 

Source
Expand description

§vcp-wasm

WebAssembly bindings for the VCP SDK, exposing core parsing and encoding functions to JavaScript/TypeScript via wasm-bindgen.

§Usage from JS

import init, { parse_csm1, encode_csm1, parse_context_wire, validate_token } from 'vcp-wasm';

await init();

const code = parse_csm1("N5+F+E");
console.log(code.persona); // "Nanny"

const wire = parse_context_wire("⏰🌅|📍🏡‖🧠focused:4|💭calm:3");
console.log(wire.personal.cognitive.value); // "focused"

Functions§

encode_context_wire
Encode a full context object to wire format.
encode_csm1
Encode a CSM-1 compact code from a JS object back to a string.
encode_csm1_token
Encode a CSM-1 8-line token from a JS object back to a string.
hash_content
Compute the SHA-256 content hash of constitution text.
parse_context_wire
Parse the full context wire format (situational + personal, separated by ‖).
parse_csm1
Parse a CSM-1 compact code (e.g. "N5+F+E") and return it as a JS object.
parse_csm1_token
Parse a CSM-1 8-line token string and return it as a JS object.
validate_token
Validate a VCP/I identity token (e.g. "family.safe.guide@1.2.0").
verify_bundle
Verify a bundle (manifest JSON + content).
verify_hash
Verify that content matches an expected hash.