@wishcore/wish-sdk
v0.4.0-beta-21
Published
Wish API for node. Used for building Wish Apps.
Maintainers
Readme
Wish SDK
Node.js SDK for building peer-to-peer applications on the Wish protocol.
Features:
- Cryptographic identity-based P2P networking
- Protocol-based service discovery
- End-to-end encrypted communication
Install
npm install @wishcore/wish-sdkQuick Start
const { App, WishCoreRunner } = require('@wishcore/wish-sdk');
// Start wish-core (bundles pre-built binaries for macOS/Linux)
await WishCoreRunner.start({ appPort: 9094 });
const app = new App({
name: 'MyApp',
corePort: 9094,
protocols: ['chat']
});
app.on('ready', async () => {
// Create or get identity
const identities = await app.request('identity.list', []);
const identity = identities[0] || await app.request('identity.create', ['Alice']);
console.log('Ready as:', identity.alias);
});
app.on('online', async (peer) => {
// Send message to peer
await app.request('services.send', [peer, Buffer.from('Hello!')]);
});
app.on('frame', async (peer, data) => {
// Receive message from peer
const identity = await app.request('identity.get', [peer.ruid]);
console.log(`${identity.alias}: ${data.toString()}`);
});Common API Methods
identity.create(alias)- Create new identityidentity.list()- List identitiesidentity.get(uid)- Get identity detailsservices.send(peer, buffer)- Send data to peer
Events
ready- Connected to wish-coreonline(peer)- Peer came onlineoffline(peer)- Peer went offlineframe(peer, data)- Received data from peer
