@ohxxx/wedts
v0.1.1
Published
Typed npm wrapper for the WED Rust/WASM crypto package
Readme
@ohxxx/wedts
@ohxxx/wedts is the TypeScript-friendly npm package for the WED symmetric encryption protocol.
It wraps the generated WASM output from crypto-wasm and adds a stable JavaScript entrypoint plus TypeScript declarations.
Install
npm install @ohxxx/wedtsAPI
The package exports:
encryptText(passphrase: string, plaintext: string): stringdecryptText(passphrase: string, token: string): stringencryptJson(passphrase: string, value: unknown): stringdecryptJson<T = unknown>(passphrase: string, token: string): T
Text example:
import { decryptText, encryptText } from "@ohxxx/wedts";
const token = encryptText("shared-passphrase", "hello");
const plaintext = decryptText("shared-passphrase", token);JSON example with type inference:
import { decryptJson, encryptJson } from "@ohxxx/wedts";
const token = encryptJson("shared-passphrase", { message: "hello" });
const payload = decryptJson<{ message: string }>("shared-passphrase", token);Local Development
Install dependencies and rebuild the WASM output:
cd packages/wedts
npm install
npm run build:wasmThe build script compiles crates/crypto-wasm with wasm-pack and copies the generated assets into dist/wasm.
Test
Runtime test:
cd packages/wedts
npm testType test:
cd packages/wedts
npm run typecheckFor an end-to-end consumer example, see examples/react/README.md.
