@aethex.os/connect
v1.0.1
Published
AeThex Connect SDK — typed API client for auth, messaging, calls, friends, and subscriptions with automatic token refresh
Maintainers
Readme
@aethex.os/connect
Typed API client for AeThex Connect — messaging, friend requests, voice/video calls, and subscriptions. Auto-refreshes access tokens on 401.
Install
npm install @aethex.os/connectUsage
import { ConnectClient } from '@aethex.os/connect';
const client = new ConnectClient({ baseURL: 'https://api.aethex.network' });Auth
const { user, tokens } = await client.login('[email protected]', 'password');
client.setTokens(tokens); // subsequent requests use these automatically
const me = await client.getCurrentUser();Messaging
const conversations = await client.getConversations();
const messages = await client.getMessages('conv_123', 50);
const sent = await client.sendMessage('conv_123', 'hey!');Friends
const friends = await client.getFriends();
await client.sendFriendRequest('user_456');
await client.acceptFriendRequest('req_789');
const pending = await client.getPendingFriendRequests();Calls
const call = await client.initiateCall('user_456', 'voice');
await client.joinCall(call.id);
await client.leaveCall(call.id);Subscriptions
const sub = await client.getSubscription();
await client.subscribe('pro', paymentMethodId, 'monthly');
const { available, price } = await client.checkDomainAvailability('myname.aethex');Custom requests
// Escape hatch for any endpoint
const data = await client.request<MyType>({
method: 'GET',
url: '/custom/endpoint',
});Token refresh
Access tokens are refreshed automatically. On 401, the client retries with a new token using the stored refreshToken. If refresh fails, tokens are cleared.
client.setTokens({ accessToken: '...', refreshToken: '...' });
client.clearTokens();Part of the @aethex.os ecosystem
See @aethex.os/core for the full package list.
