@dialstack/sdk-webrtc
v3.5.0
Published
Headless WebRTC softphone core for the DialStack SDK — no React, no runtime dependencies
Readme
@dialstack/sdk-webrtc
Headless WebRTC softphone for the DialStack SDK.
- No runtime dependencies. Nothing is installed alongside it, and nothing third-party is compiled into it. CI fails the build if that stops being true.
- No React, no DOM UI. Use it from vanilla JS, Angular, Vue, Svelte, or any
framework. React components live in
@dialstack/sdk-react.
Install
npm install @dialstack/sdk-webrtcThat is the whole install: one package, nothing transitive.
Usage
import { DialStackPhone } from '@dialstack/sdk-webrtc';
const phone = new DialStackPhone({ token: userSessionToken });
await phone.connect();
phone.on('incoming', (call) => call.accept());
const call = await phone.call('+14155550123');
call.hangup();It authenticates with a short-lived user-session token over a WebSocket, so it
needs no initializer and no publishable key — unlike the REST-backed packages,
which mint a client secret. Your backend issues the token; refresh it from
onTokenExpiring.
Which package do I want?
| You are building | Install |
| ----------------------------- | -------------------------------------------- |
| A softphone in any framework | this package alone |
| A React app with DialStack UI | @dialstack/sdk-js + @dialstack/sdk-react |
| A plain HTML page | @dialstack/sdk-js |
| A Node backend | @dialstack/sdk-server |
@dialstack/sdk-react depends on this package at an exact version, so a React
app that also embeds the softphone gets one copy of the phone, not two.
Building
Plain tsc, no bundler — npm run build. Unbundled compilation is the point: it
emits one output file per input with imports left intact, so no third-party code
can be inlined and an empty dependencies field cannot drift from what the
package actually needs.
Two consequences worth knowing before editing:
tsconfig.jsonusesmoduleResolution: NodeNext, so relative imports insrc/must end in.js(e.g.from './phone.js'), naming the emitted sibling rather than the.tssource. UnderBundlerresolution the emitted.d.tsfiles keep extensionless specifiers, which bundlers tolerate but Node's own ESM resolver does not —attwreports an internal resolution error fornode16consumers.- The package is ESM-only.
attwreportsCJSResolvesToESMfor CommonJS consumers, who need a dynamicimport(); that is expected and is why the rule is ignored incheck:package.
Documentation
Full documentation: https://docs.dialstack.ai/sdks
License
MIT
