@tsgwarp/warp-voice-sdk
v0.1.2
Published
Twilio Voice JS SDK v2-compatible browser calling adapter for TSG WARP. Verify the features your app uses before migration.
Maintainers
Readme
@tsgwarp/warp-voice-sdk — Twilio Voice JS migration adapter
This adapter provides a Twilio-shaped Device and Call over TSG WARP browser calling.
Change the frontend import and the backend token route, then test the methods your app uses.
Only the methods marked implemented below are supported; a successful build does not prove
two-way audio or feature parity for your application.
Under the hood it drives WARP's production browser-calling engine (@tsgwarp/webrtc: SIP-over-WSS
to the WARP SBC, per-session ephemeral credentials, TURN) — the same stack behind the WARP portal
softphone. Your app never sees any of that.
Line 1 — the frontend import
Install it with npm install @tsgwarp/warp-voice-sdk after checking the published version.
- import { Device } from '@twilio/voice-sdk';
+ import { Device } from '@tsgwarp/warp-voice-sdk';(Script-tag apps: load dist/warp-voice-sdk.umd.js — it also installs window.Twilio.Device
if Twilio isn't already defined, so legacy new Twilio.Device(...) code works.)
Line 2 — the backend token route
Your app already has a route that returns { token } for the SDK. Point its internals at WARP:
// before: twilio.jwt.AccessToken + VoiceGrant ...
// after:
app.get('/token', async (req, res) => {
const r = await fetch(
`https://api.warp.tsgglobal.net/v1/connections/${WARP_CONNECTION_ID}/tokens`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${WARP_API_KEY}` },
body: JSON.stringify({ ttl_seconds: 3600 }),
},
);
const warp = await r.json(); // { identity, password, sip_domain, wss, ice, expires_in, caller_id }
res.json({ token: JSON.stringify(warp) }); // ← keep the { token } shape your frontend expects
});For the implemented methods, the frontend keeps the same Device/Call pattern:
const { token } = await (await fetch('/token')).json();
const device = new Device(token);
device.on('incoming', (call) => call.accept());
await device.register();
const call = await device.connect({ params: { To: '+15551234567' } });
call.on('accept', () => console.log('connected'));
call.on('disconnect', () => console.log('ended'));
call.sendDigits('1');
call.mute(true);
call.disconnect();WARP_CONNECTION_ID is a WebRTC Connection on your WARP account
(POST /v1/connections { name, type: "webrtc" }); WARP_API_KEY is a server-side API key
(POST /v1/api-keys). The browser never holds the API key — only the short-lived per-session
credential, exactly like a Twilio access token. Optional: pass caller_id_e164 in the token mint
to set the outbound caller ID per user/agent session.
The token response includes short-lived TURN/STUN settings. Pass the complete WARP response through
the existing { token } field; the browser does not need a separate ICE request.
What's implemented vs stubbed
| Twilio surface | Status |
|---|---|
| new Device(token, options), register(), unregister(), updateToken(), destroy(), disconnectAll(), device.calls, device.state, Device.isSupported | implemented |
| Device events: registered, registering, unregistered, incoming, error, tokenWillExpire, destroyed | implemented |
| device.connect({ params: { To } }) → Call | implemented (auto-registers first if needed) |
| Call: accept, disconnect, reject, ignore, mute, isMuted, sendDigits, status(), getLocalStream(), getRemoteStream(), parameters (From/To/CallSid), events accept/disconnect/cancel/reject/ringing/error/mute | implemented (CallSid = the SIP Call-ID — the same ID you can search in WARP CDRs/PCAPs) |
| device.audio: output/input device lists, speakerDevices.set, setInputDevice (live-call mic switch), deviceChange event | implemented |
| Call.hold (not in Twilio JS SDK, but present here) | bonus via the underlying engine |
| Insights/Preflight (runPreflight, postFeedback), volume meters | stub (warn once, no-op). WARP has call records and on-demand SIP signaling captures, without audio. |
| edge, codecPreferences, built-in sounds/ringtones | stub (warn once) — single WARP edge + TURN; browser leg negotiates Opus/PCMU, the WARP gateway bridges to the carrier |
| Token = Twilio AccessToken JWT | n/a — the token is WARP's envelope passed through your existing { token } field (JSON string, base64-JSON, or the raw object all accepted) |
device.connect({ params }) currently uses To for outbound routing. Twilio sends other custom
parameters to the customer's TwiML application; WARP has no equivalent application callback yet.
Do not assume those parameters reach a server-side handler. TwiML, status callbacks, conferences,
Insights/Preflight, and Call Message Events need separate compatibility work if your app uses them.
Notes
- Incoming calls ring while the page is open and registered — the same constraint as the Twilio JS SDK (their docs: browsers don't reliably receive background calls).
- Tokens are short-TTL. Handle
device.on('tokenWillExpire', ...)by fetching/tokenagain and callingdevice.updateToken(token)— identical to the Twilio pattern. - Customer downloads are limited to their own SIP signaling leg. They contain no RTP/audio or carrier
leg. For an outbound call,
GET /v1/cdr/{id}/carrier-responsesreturns codes and phrases from known carrier endpoints when a matching capture exists. TSG NOC can inspect both signaling legs. Capture availability is checked at lookup time and is not guaranteed for every call. - Outbound and inbound calls with two-way audio passed the admin SDK pilot on 2026-10-02. The durable SBC image was rolled afterward; post-roll audio, customer-token minting, mute, receiving-side DTMF, and renewal across token expiry still need customer-path proof.
- Build:
npm install && npm run build→dist/warp-voice-sdk.{esm.js,cjs,umd.js}.
