@superid-chain/superid-agent-sdk
v0.1.0
Published
High-level JS/TS SDK for SuperID agent core (crypto, DID, DIDComm, VC, PoA, vault, IPFS) built on top of the WASM crate.
Downloads
99
Readme
SuperID JavaScript SDK Unified JS/TS Wrapper for SuperID Agent Core (WASM)
Package: @superid-chain/superid-sdk
SuperID SDK provides a universal JavaScript interface over the SuperID Agent Core (Rust → WASM).
It works seamlessly in:
Node.js (backend, servers, AWS Lambda)
Browser (React + Vite + Tailwind)
Secure DID-based workflows
DIDComm v2 encrypted messaging
PoA blockchain signing / verification
Vault-based key management
IPFS CID generation
Verifiable Credentials (partial)
This SDK wraps the complex WASM calls with safe JSON APIs, including automatic error normalization, WASM panic handling, and BigInt-safe serialization.
Installation Node.js / AWS Lambda npm install @superid-chain/superid-sdk
React / Vite npm install @superid-chain/superid-sdk buffer
Add buffer polyfill for browser:
vite.config.js import { defineConfig } from "vite";
export default defineConfig({ resolve: { alias: { buffer: "buffer" } } });
In your React entry file (main.tsx / index.tsx): import { Buffer } from "buffer"; window.Buffer = Buffer;
Quick Start (Node.js) import * as superid from "@superid-chain/superid-sdk";
// Generate Ed25519 keypair const kp = superid.ed25519Keygen();
// Sign + verify const sig = superid.ed25519Sign(kp.handle, "hello superid"); const ok = superid.ed25519Verify({ public_b64u: kp.public_b64u, sig_b64u: sig.sig_b64u, plaintext_utf8: "hello superid" });
Core Features
- Cryptography Ed25519 const kp = superid.ed25519Keygen(); const sig = superid.ed25519Sign(kp.handle, "hello"); const verify = superid.ed25519Verify({ public_b64u: kp.public_b64u, sig_b64u: sig.sig_b64u, plaintext_utf8: "hello", });
X25519 const xkp = superid.x25519Keygen();
- DIDComm v2 Messaging Anoncrypt const enc = superid.didcommAnonEncrypt({ recipient_x25519_pub_b64u: xkp.public_b64u, plaintext_utf8: "hello didcomm" });
Decrypt const dec = superid.didcommAnonDecrypt({ recipient_x25519_secret_b64u: xkp.secret_b64u, jwe_json: JSON.stringify(enc) });
Authcrypt const auth = superid.didcommAuthEncrypt({ sender_x25519_handle: xkp.handle, recipient_x25519_pub_b64u: xkp.public_b64u, plaintext_utf8: "secure hello" });
- DID & DID Document
Create DID from Ed25519 key:
const did = superid.didFromEd25519Pub(kp.public_b64u);
Build DID Document:
const doc = superid.didSuperidBuildDoc({ ed25519_public: kp.public_b64u, x25519_public: xkp.public_b64u, serviceEndpoint: "https://example.superid.dev/didcomm" });
- Secure Vault (XC20P AEAD) Create VMK const vmk = superid.vaultVmkRandom();
Create vault const vault = superid.vaultCreate(vmk.vmk_b64u);
Add key const updated = superid.vaultAddKey({ vmk_b64u: vmk.vmk_b64u, state_json: vault.state_json, label: "org-signing-key", key_type: "ed25519", secret_b64u: kp.secret_seed_b64u });
- PoA Blockchain Transaction Signing Transaction hash const tx = { kind: "demo-tx", payload: { from: did, nonce: 1, timestamp: Date.now() } };
const hash = superid.txHash(tx);
Sign block header const sig = superid.blockSign(kp.handle, { height: 1, timestamp: Date.now(), tx_root: hash.sha256_b64u });
Verify block const verify = superid.blockVerify( { header: { ... }, signature: sig.sig_b64u }, { requiredSigners: [did], threshold: 1 } );
IPFS CID Generation const cid = superid.ipfsCidFromHash(hash.sha256_b64u);
DIDComm Message Create + Validate Build message const msg = superid.didcommBuildMessage({ typ: "https://didcomm.org/basicmessage/1.0/message", body: { hello: "world", did } });
Validate superid.didcommValidateMessage(JSON.stringify(msg));
Known Limitations (from WASM Core)
Some functions in Rust core are not implemented or return WASM panics:
Feature Status DIDDoc sign Not implemented DIDDoc verify Not implemented StatusList VC Partial Manifest Sign Partial DIDComm unpack w/ handles May require import
Your SDK safely normalizes and returns:
{ "error": { "code": "wasm_panic", "message": "unreachable" } }
Project Structure /src index.ts superidAgentCore.ts
/dist index.js (ESM) index.cjs (CommonJS) index.d.ts (TypeScript Types)
/examples /node-smoke-test
Contributing
Pull requests and issues are welcome.
Support
SuperID & DIDComm enterprise integration support [email protected]
