Browser, end-to-end encrypted client SDK for the unimo secure-platform. https://www.npmjs.com/package/unimo-sdk
  • TypeScript 89.4%
  • JavaScript 10.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jolly Good 70c71fc690
All checks were successful
ci / test (push) Successful in 18s
rebuild
2026-10-07 00:21:51 +02:00
.forgejo/workflows added local cache, CI test, prettier reformat, 2026-09-12 15:17:10 +02:00
dist rebuild 2026-10-07 00:21:51 +02:00
src_ts add llm ws support 2026-10-07 00:15:06 +02:00
tests add llm ws support 2026-10-07 00:15:06 +02:00
tools added local cache, CI test, prettier reformat, 2026-09-12 15:17:10 +02:00
.gitignore add dist (temporary fix) 2026-08-20 01:20:08 +02:00
.prettierignore added local cache, CI test, prettier reformat, 2026-09-12 15:17:10 +02:00
bun.lock add recover method 2026-09-19 17:20:19 +02:00
LICENSE mit license update 2026-06-11 07:29:25 +02:00
package.json fix bugs of merging collections, bump version 2026-09-16 13:28:03 +02:00
README.md add llm ws support 2026-10-07 00:15:06 +02:00
tsconfig.json init 2026-06-08 10:39:35 +02:00
tsdown.cdn.mjs update readme and package json 2026-06-15 23:30:58 +02:00
tsdown.config.mjs gitignore dist, rename class, update readme, bump version, fix bundling 2026-06-28 16:54:00 +02:00

unimo-sdk

Browser, end-to-end encrypted client SDK for the unimo secure-platform.

All confidentiality and integrity are enforced client-side — the server is treated as untrusted and only ever sees ciphertext, signed manifests, and opaque handles.

  • Key encapsulation: ML-KEM-1024 (FIPS 203)
  • Signatures: ML-DSA-87 (FIPS 204)
  • Symmetric: AES-256-GCM (WebCrypto)
  • KDF / hashing: cSHAKE256, SHA-256

Status: pre-1.0 (0.0.x). APIs may change between minor versions, and the crypto has not yet been independently audited. Use accordingly.

Install

npm install unimo-sdk
# or: bun add unimo-sdk / pnpm add unimo-sdk

The published bundle is self-contained (ESM, post-quantum dependencies inlined) and has no runtime dependencies.

With a bundler

Vite, webpack, esbuild, Rollup, etc. resolve and tree-shake the package automatically — just import it; no import map is needed.

Without a bundler (import maps)

Because the bundle is self-contained, no transitive dependencies need mapping — a single entry is enough:

<script type="importmap">
  { "imports": { "unimo-sdk": "/node_modules/unimo-sdk/dist/client.js" } }
</script>
<script type="module">
  import { UnimoClient } from 'unimo-sdk';
  // ...
</script>

Requirements

  • A modern browser with WebCrypto (crypto.subtle).
  • A secure context (HTTPS or localhost).
  • A cross-origin-isolated context (COOP/COEP headers) is recommended; the client warns when it is missing.

Usage (in progress)

The public entry point:

import { UnimoClient } from 'unimo-sdk';

const client = new UnimoClient('https://your-gateway.example.com');

// Register a new account. The device seed is your credential — store it safely.
await client.requestEmailCode('me@example.com'); // mails a 6-digit code
await client.verifyEmailCode('me@example.com', '123456');
const reg = await client.register('my-account', 'me@example.com', 'my-device');
// reg.thisDeviceSeed   → seed for this device (needed to log in again)
// reg.recoverySeed     → recovery-device seed (store offline)

// Log in with the account name + device seed.
const account = await client.login('my-account', reg.thisDeviceSeed);
if (!account) throw new Error('login failed');

// Collections are named, per-collection-encrypted containers.
const notes = await account.getCollection('notes', 'KV', /* autoCreate */ true);
notes?.set('greeting', 'hello');

Model turns

On an account with a live connection (persistent login), account.llm streams one text turn through the gateway's model proxy. No tools; a turn cut at the token cap ends with finishReason === 'length', a gateway fault rejects with CodedError carrying its code, and an AbortSignal in the options cancels the turn on the gateway too.

const turn = await account.llm!.complete(
  [
    { role: 'system', content: 'Answer briefly.' },
    { role: 'user', content: 'What is unimo?' },
  ],
  { onDelta: piece => render(piece) },
);
turn.text; // every delta, joined

Offline cache

With a cache (localStorage fits as is; any { getItem, setItem, removeItem }, sync or async) the SDK keeps an AEAD-encrypted copy of the login manifest and every loaded KV collection. A login whose request never reaches the server then succeeds from the cache: reads work, edits stay on disk, the next online login replays them. Creating a collection still needs the network; a server keyEpoch below the cached one throws CodedError MANIFEST_ROLLBACK.

const client = new UnimoClient('https://your-gateway.example.com', { cache: localStorage });
const account = await client.login('my-account', seed);
account.isOffline; // true when served from the cache: no token, no live connection

See the published type declarations (dist/client.d.ts) for the full surface (collections, members, invites, file upload/download/delete, billing, live connection events).

License

MIT © thinking.tools