@dora-cell/sdk
v4.1.6
Published
VoIP calling SDK for Dora Cell - Make calls from any JavaScript application
Maintainers
Readme
@dora-cell/sdk
VoIP calling SDK for Dora Cell - Make calls from any JavaScript application without logging into the Dora Cell web app.
Features
✅ Framework-agnostic - Works with vanilla JS, React, Vue, Angular, etc.
✅ TypeScript support - Full type definitions included
✅ WebRTC-based - High-quality voice calls using JsSIP
✅ Event-driven API - Listen to call state changes
✅ API Token Auth - Securely authenticate with Public & Secret keys
✅ Dynamic Extensions - Fetch and switch between DID numbers
✅ Wallet Integration - Check credit balance directly from the SDK
✅ React bindings - Premium UI components and hooks included
Installation
npm install @dora-cell/sdk
# or
yarn add @dora-cell/sdk
# or
pnpm add @dora-cell/sdk[!NOTE]
jssipis a dependency of this SDK and will be installed automatically. You only need to install it manually if you want to use a specific version.
Quick Start
1. Initialize the SDK
Choose your preferred authentication method:
Option A: Extension Authentication (Recommended for Testing)
Best for quick testing or internal apps where default credentials are used.
import { DoraCell } from "@dora-cell/sdk";
const sdk = new DoraCell({
auth: {
type: "extension",
extension: "1001",
},
});Option B: API Token Authentication (Production)
Best for production apps. The SDK will verify keys and fetch SIP credentials automatically.
const sdk = new DoraCell({
auth: {
type: "api-token",
publicKey: "pk_live_...",
secretKey: "sk_live_...",
},
});Option C: Direct Credentials (Advanced)
If you already have SIP credentials.
const sdk = new DoraCell({
auth: {
type: "direct",
sipUri: "sip:[email protected]",
password: "your-password",
wsUrl: "wss://voice.example.com:8089/ws",
},
});2. Connect and Register
// Listen for registration
sdk.on("connection:status", (state) => {
if (state.status === "registered") {
console.log("SIP Ready to make calls!");
}
});
// Initialize connection
await sdk.initialize();3. Make a Call
try {
const call = await sdk.call("+2348012345678");
// Mute/unmute
call.mute();
// Hang up
call.hangup();
} catch (error) {
console.error("Call failed:", error.message);
}API Reference
DoraCell Class
new DoraCell(config)
config.auth(Required)type: 'api-token' | 'extension' | 'direct'publicKey/secretKey(for api-token)extension(for extension type)
config.environment?: 'dev' | 'staging' | 'production'- Shortcut for API URLs (default: 'production')config.autoSelectExtension?: boolean- Register first available DID (default: true)config.debug?: boolean- Enable JsSIP debug logs (default: false)
Methods
initialize(): Promise<void>- Authenticate and register with the SIP server.call(number, extension?): Promise<Call>- Initiate an outbound call.getWallet(): Promise<{ balance: number, currency: string }>- Get current credit balance.fetchExtensions(): Promise<Extension[]>- Fetch available DID numbers/extensions.setExtension(ext): Promise<void>- Switch active extension and re-register SIP.answerCall(): void- Answer a pending incoming call.hangup(): void- End the current active call.on(event, handler): void- Listen for events (see below).destroy(): void- Cleanup and disconnect.
Call Object
Returned by call() and emitted in events.
id: Unique call ID.status:'idle' | 'connecting' | 'ringing' | 'ongoing' | 'ended'.direction:'inbound' | 'outbound'.remoteNumber: The other party's number.duration: Call duration in seconds.mute()/unmute(): Control microphone.hangup(): End this specific call.getRemoteStream(): Returns the WebRTCMediaStreamfor audio playback.
Events
| Event | Description | Data |
| ------------------- | ------------------------------ | ---------------------------------- |
| connection:status | SIP registration status change | { status: string, extension?: string, error?: string } |
| call:incoming | New incoming call detected | Call object |
| call:outgoing | New outbound call started | Call object |
| call:ringing | Remote party is ringing | Call object |
| call:connected | Call answered and connected | Call object |
| call:ended | Call terminated | Call object, reason: string |
| call:failed | Call failed to connect | Call object, error: string |
| error | General SDK error | Error object |
Browser Requirements
- HTTPS: WebRTC and microphone access require a secure context (HTTPS or localhost).
- Environment: Modern browsers with WebRTC support (Chrome, Firefox, Safari, Edge).
Examples
Check the examples/ directory in the main repository:
next-js-demo/- Complete Next.js implementation with React components
License
MIT
