Appearance
Wish SDK
Node.js SDK for building peer-to-peer applications on the Wish protocol.
What you get
- Cryptographic identity — Ed25519 keys managed by wish-core
- Peer discovery — find peers on local network, via relay, or directory
- Encrypted connections — end-to-end encrypted, multiplexed across apps
- Protocol matching — your app only sees peers running the same protocol
Install
sh
npm install @wishcore/wish-sdkThe SDK is a native package — a Rust core (napi) with TypeScript framework layers — and pulls @wishcore/document-store (also Rust-backed) in with it. Prebuilt binaries ship for macOS and Linux (x64 + arm64); no Rust toolchain needed to install.
Before your first app
Apps don't mint identities. Identities are created and managed by the Wish app (Dashboard). Your app calls app.requestIdentity() and the user approves it from the tray. Until that happens, app.identities is empty. The exception is admin tools (Dashboard, the wish-rs CLI) — they pass permissions: { admin: true } and have direct access to identity.create and related RPCs.
A Wish app is a long-running process. Peer connections, document sync, and presence live inside the running app. The typical shape is a daemon that exposes a createWebRpc endpoint for a UI or CLI to attach to — not a one-shot App per command.
jsonc
// package.json — top-level await needs "type": "module"
{ "type": "module", "dependencies": { "@wishcore/wish-sdk": "^0.5.0" } }Building in Rust?
The same kernel surface — identical endpoint names and semantics — is available from Rust via wish-sdk-rs, and Tauri apps get the full framework via wish-app-base. See the App API (Rust) section: Overview, Identity, Peers, and the Rust first-app walkthrough.
Two levels of API
App — direct control
Low-level access to wish-core. You handle peer events, send frames, manage state yourself.
typescript
import { App } from '@wishcore/wish-sdk';
const app = new App({
name: 'MyApp',
// Connects to wish-core automatically (~/.wish/core.sock)
protocols: ['myprotocol'],
});
app.on('ready', () => {
console.log('Connected to wish-core');
});
app.on('online', (peer) => {
console.log('Peer online:', peer.toString());
app.send(peer, Buffer.from('hello'));
});
app.on('frame', (peer, data) => {
console.log('Received from', peer.toString(), ':', data);
});RpcApp — structured protocols
Higher-level wrapper for building RPC-based protocols. Uses the Protocol class pattern for typed peer sessions with request/response handlers.
typescript
import { RpcApp, Protocol } from '@wishcore/wish-sdk';
import { Client, Server } from '@wishcore/wish-rpc';
class NotesProtocol extends Protocol {
peerNotes: Map<string, string[]> = new Map();
constructor() {
super();
this.endpoint('list', { doc: 'List notes' }, (req, res) => {
res.send(myNotes);
});
}
online(peer, client) {
client.request('list', [], (err, notes) => {
this.peerNotes.set(peer.toUrl(), notes);
});
}
offline(peer) {
this.peerNotes.delete(peer.toUrl());
}
}
const app = new RpcApp({
name: 'Notes',
// Connects to wish-core automatically (~/.wish/core.sock)
protocols: {
notes: new NotesProtocol(),
}
});
await app.whenReady;
console.log('Identities:', app.identities);Prerequisites
Wish SDK connects to a running wish-core instance. Download the Wish app — it includes wish-core and the Dashboard for managing identities, contacts, and app permissions.
Next steps
- App reference — events, identity API, peer lifecycle
- Identity API — list, get, sign, verify
- Peers API — signals, sending data, peer pins