Core admin SDK for Paanj platform - provides authentication and connection management
This SDK is designed exclusively for server-side use. It requires a secret API key and should never be exposed to client-side code or browsers.
@paanj/admin is the core package that provides:
- 🔐 Authentication - Secret key-based authentication
- 🔌 Connection Management - WebSocket and HTTP client infrastructure
- 🔄 Auto-Reconnection - Built-in reconnection with exponential backoff
- 🎯 Base for Feature Packages - Foundation for
@paanj/chat-admin,@paanj/voice-admin, etc.
npm install @paanj/adminRequirements:
- Node.js 18.0.0 or higher
- Server-side environment only
import { PaanjAdmin } from '@paanj/admin';
const admin = new PaanjAdmin('sk_live_your_secret_key', {
apiUrl: 'http://localhost:3000',
wsUrl: 'ws://localhost:8090'
});
// Connect to WebSocket
await admin.connect();
// Check connection status
console.log(admin.isConnected()); // true
// Disconnect
admin.disconnect();The core package is typically used with feature packages:
import { PaanjAdmin } from '@paanj/admin';
import { AdminChat } from '@paanj/chat-admin';
const admin = new PaanjAdmin('sk_live_your_secret_key');
await admin.connect();
// Initialize chat features
const chat = new AdminChat(admin);
chat.messages.onCreate((msg) => {
console.log('New message:', msg);
});new PaanjAdmin(secretKey: string, options?: AdminOptions)Options:
apiUrl?: string- API server URL (default:http://localhost:3000)wsUrl?: string- WebSocket server URL (default:ws://localhost:8090)autoReconnect?: boolean- Enable auto-reconnection (default:true)reconnectInterval?: number- Reconnect interval in ms (default:5000)maxReconnectAttempts?: number- Max reconnect attempts (default:10)
connect(): Promise<void>
Connect to the WebSocket server.
disconnect(): void
Disconnect from the WebSocket server.
isConnected(): boolean
Check if connected to WebSocket.
const admin = new PaanjAdmin(secretKey, {
apiUrl: 'https://api.paanj.com',
wsUrl: 'wss://ws.paanj.com',
autoReconnect: true,
reconnectInterval: 5000,
maxReconnectAttempts: 10
});- Never expose secret keys - Store them in environment variables or secure vaults
- Server-side only - This SDK includes runtime checks to prevent browser usage
- Rotate keys regularly - Implement key rotation policies
- Monitor usage - Track API key usage for suspicious activity
- Use HTTPS/WSS - Always use secure connections in production
Build on top of @paanj/admin with feature packages:
@paanj/chat-admin- Chat management and monitoring@paanj/voice-admin- Voice call management (coming soon)@paanj/video-admin- Video call management (coming soon)@paanj/storage-admin- File storage management (coming soon)
This SDK is written in TypeScript and provides complete type definitions:
import { PaanjAdmin, AdminOptions } from '@paanj/admin';
const options: AdminOptions = {
apiUrl: 'https://api.paanj.com',
autoReconnect: true
};
const admin = new PaanjAdmin(secretKey, options);try {
await admin.connect();
} catch (error) {
console.error('Connection failed:', error.message);
}# Install dependencies
npm install
# Build the package
npm run build
# Watch mode for development
npm run watchThis project is licensed under a custom license. See the LICENSE file for details.
- 📧 Email: support@paanj.com
- 📖 Documentation: https://docs.paanj.com
- 🐛 Issues: https://github.com/paanj-cloud/admin-js/issues
Made with ❤️ by the Paanj team