Quick Start
A minimal integration requires three things: a client initialization, a server token-exchange endpoint, and a public-key directory endpoint.
import { initialize } from '@droponair/sdk-js';
const client = await initialize({
appId: 'your-app-id',
publicApiKey: 'your-public-api-key',
getUserJwt: async () => {
const res = await fetch('/api/auth/me', { credentials: 'include' });
return (await res.json()).jwt;
},
keyDirectoryEndpoint: '/api/droponair/keys',
tokenExchangeEndpoint: '/api/droponair/token',
});
client.onMessage((msg) => console.log(msg.fromUserId, msg.plaintext));
await client.sendMessage('recipient-user-id', 'Hello!');
client.disconnect();