2026-01-07 14:20:21 -05:00
|
|
|
# Motr Enclave
|
|
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
Extism WASM plugin providing encrypted key storage for Nebula wallet. Built with Go 1.25+ for `wasip1`.
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
## Quick Start
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
```bash
|
|
|
|
|
make start
|
|
|
|
|
```
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
This single command:
|
|
|
|
|
1. Installs dependencies (Go, Bun)
|
|
|
|
|
2. Builds the WASM plugin
|
|
|
|
|
3. Builds the TypeScript SDK
|
|
|
|
|
4. Starts the dev server at http://localhost:8080
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
## Manual Setup
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
```bash
|
|
|
|
|
make deps # Install tooling
|
|
|
|
|
make build # Build WASM plugin
|
|
|
|
|
make sdk # Build TypeScript SDK
|
|
|
|
|
make dev # Start dev server
|
|
|
|
|
```
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
## Usage
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
### TypeScript/ESM
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
```typescript
|
|
|
|
|
import { createEnclave } from '@sonr/motr-enclave';
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
const enclave = await createEnclave('/enclave.wasm');
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
const { did, database } = await enclave.generate(credential);
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
await enclave.load(database);
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
const accounts = await enclave.exec('resource:accounts action:list');
|
2026-01-07 14:26:24 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
const didDoc = await enclave.query();
|
|
|
|
|
```
|
2026-01-07 14:20:21 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
### CLI
|
2026-01-07 14:20:21 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
```bash
|
|
|
|
|
make test-plugin
|
|
|
|
|
```
|
2026-01-07 14:20:21 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
## Plugin Functions
|
2026-01-07 14:20:21 -05:00
|
|
|
|
2026-01-07 18:33:57 -05:00
|
|
|
| Function | Input | Output |
|
|
|
|
|
|----------|-------|--------|
|
|
|
|
|
| `generate` | WebAuthn credential (base64) | DID + database buffer |
|
|
|
|
|
| `load` | Database buffer | Success status |
|
|
|
|
|
| `exec` | Filter string + optional UCAN | Action result |
|
|
|
|
|
| `query` | DID (optional) | DID document |
|
2026-01-07 14:20:21 -05:00
|
|
|
|
|
|
|
|
## Project Structure
|
|
|
|
|
|
2026-01-07 14:26:24 -05:00
|
|
|
```
|
|
|
|
|
motr-enclave/
|
2026-01-07 18:33:57 -05:00
|
|
|
├── main.go # Go plugin source
|
|
|
|
|
├── src/ # TypeScript SDK
|
|
|
|
|
├── dist/ # Built SDK
|
|
|
|
|
├── example/ # Browser test app
|
|
|
|
|
├── db/ # SQLite schema
|
|
|
|
|
└── Makefile
|
2026-01-07 14:26:24 -05:00
|
|
|
```
|
2026-01-07 14:20:21 -05:00
|
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-01-07 18:33:57 -05:00
|
|
|
make test # Run Go tests
|
|
|
|
|
make lint # Run linter
|
|
|
|
|
make clean # Remove build artifacts
|
2026-01-07 14:20:21 -05:00
|
|
|
```
|