@nanorix/sdk
v0.3.0
Published
Nanorix TypeScript SDK — sealed processing with cryptographic destruction proofs
Maintainers
Readme
@nanorix/sdk
Sealed processing with cryptographic destruction proofs.
Installation
npm install @nanorix/sdkRequires Node.js >= 18.
Quick Start
import { NanorixClient } from "@nanorix/sdk";
import { readFileSync } from "node:fs";
const client = new NanorixClient({ apiKey: "nrx_live_..." });
// Create a capsulefile (one-time setup)
const capsulefile = await client.capsulefiles.create({
name: "patient-risk-scorer",
runtime: "python3.11",
entrypoint: "python model.py",
files: ["model.py", "requirements.txt"],
});
await client.capsulefiles.waitUntilFinalized(capsulefile.id);
// Process data — capsule auto-destroyed after completion
const [outputs, cdp] = await client.capsules.run({
capsulefile: capsulefile.id,
inputs: { "patient.csv": readFileSync("patient.csv") },
});
// The proof
console.log(cdp.verifyUrl); // https://nanorix.io/verify/cap_...Workspace Mode
For multi-step workflows with full control:
const capsule = await client.capsules.create({ capsulefile: "cf_..." });
await capsule.upload("patient.csv", data);
await capsule.execute("python preprocess.py");
await capsule.execute("python model.py");
const prediction = await capsule.download("prediction.json");
const cdp = await capsule.destroy();
// Share the proof with auditors
const verification = cdp.verification();Error Handling
import { ExecutionError, NanorixError } from "@nanorix/sdk";
try {
const [outputs, cdp] = await client.capsules.run({ capsulefile: "cf_...", inputs });
} catch (err) {
if (err instanceof ExecutionError) {
console.log(`Exit code: ${err.exitCode}`);
console.log(`CDP still generated: ${err.cdp?.capsule_id}`);
}
}Destruction errors always carry the CDP — the proof exists even when execution fails.
