- TypeScript 89.4%
- JavaScript 10.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| dist | ||
| src_ts | ||
| tests | ||
| tools | ||
| .gitignore | ||
| .prettierignore | ||
| bun.lock | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsdown.cdn.mjs | ||
| tsdown.config.mjs | ||
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/COEPheaders) 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