npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

itl-webrtc

v1.0.1

Published

WebRTC SIP client library (ITooLabs) with TypeScript types

Readme

itl-webrtc

WebRTC SIP client library (ITooLabs) с поддержкой TypeScript типов.

Установка

npm install itl-webrtc

Подключение

Библиотека монтируется в глобальный объект window.ITooLabs. Для использования в Next.js или других SPA импортируйте скрипт только на клиенте.

import "itl-webrtc";
// window.ITooLabs теперь доступен в браузере

Быстрый старт

const client = window.ITooLabs.WebRTC.Factory.getInstance();

client.init({
  APIHostName: "centrex.domain",
  domain: "my.domain.name",
  debug: (direction, data) => {
    // direction: "in" | "out"
    // data: объект сообщения
    console.log(direction, data);
  },
  bind: true // по умолчанию true
});

client.addEventListener("SDKReady", () => {
  client.connect();
});

client.addEventListener("ConnectionEstablished", () => {
  client.login("user", "password");
});

client.addEventListener("AuthResult", (event) => {
  if (event.result) {
    const call = client.call("123456789", { dn: "Имя" }, { "P-Preferred-Identity": "sip:caller@host" });
    call.addEventListener("Connected", () => {
      // Звонок установлен
    });
  }
});

Основные классы и методы

ITooLabs.WebRTC.Client

  • init(config) — инициализация клиента.
    config:
    • APIHostName — адрес WebSocket сервера
    • domain — домен клиента
    • debug(direction, data) — функция логирования
    • bind — автосоздание SIP регистрации (по умолчанию true)
  • addEventListener(event, handler) — подписка на событие (см. раздел "События")
  • removeEventListener(event, handler) — отписка от события
  • connect() / disconnect() — установить/разорвать соединение
  • login(username, password, createAuthToken?) — авторизация по логину/паролю
  • loginByToken(id, token), loginBySession(s), loginByAuthToken(username, token) — альтернативные способы авторизации
  • call(num, customData?, extraHeaders?) — начать исходящий звонок
  • getCallById(id) — получить звонок по идентификатору
  • getActiveCall() — получить текущий активный звонок

ITooLabs.WebRTC.Call

  • addEventListener(event, handler) — подписка на событие звонка
  • removeEventListener(event, handler) — отписка от события звонка
  • hangup() — завершить звонок
  • cancel() — отменить исходящий звонок до соединения
  • dial() — начать исходящий звонок (если noDial=true)
  • provision() — подтвердить входящий звонок
  • answer() — ответить на входящий звонок
  • decline() / reject() — отклонить входящий звонок
  • hold() — удержание звонка
  • transfer(address, leg?) — перевод звонка
  • sendTone(n), sendDTMF(n) — отправить DTMF-тон
  • muteMicrophone() / unmuteMicrophone() — отключить/включить микрофон
  • mutePlayback() / unmutePlayback() — отключить/включить динамики

Пример передачи АОНа

const headers = {};
if (callerId) {
  headers["P-Preferred-Identity"] = "sip:" + callerId + "@" + location.host;
}
const call = client.call(phone, { dn: "Tester" }, headers);

События

События клиента (ITooLabs.WebRTC.Events)

  • SDKReady
  • ConnectionEstablished
  • ConnectionFailed
  • ConnectionClosed
  • AuthResult
  • BindResult
  • UnbindResult
  • IncomingCall
  • SourcesInfoUpdated
  • OnMessage

События звонка (ITooLabs.WebRTC.CallEvents)

  • Connected
  • Disconnected
  • Failed
  • InfoReceived

Состояния звонка (ITooLabs.WebRTC.CallState)

  • Initialized
  • Dial
  • Provisioned
  • Hold
  • Connected
  • Disconnected

Типы

TypeScript типы доступны в types/itl_webrtc.d.ts.

Документация

Класс: ITooLabs.WebRTC.Client

  • init(config) — инициализация клиента.
    • APIHostName: адрес WebSocket сервера
    • domain: домен клиента
    • debug(direction, data): функция логирования
    • bind: автосоздание SIP регистрации (по умолчанию true)
  • addEventListener(event, handler) — подписка на событие (см. раздел "События")
  • removeEventListener(event, handler) — отписка от события
  • connect() / disconnect() — установить/разорвать соединение
  • connected() / isConnected() — проверить соединение
  • initialized() / isInitialized() — проверить инициализацию
  • login(username, password, createAuthToken?) — авторизация по логину/паролю
  • loginByToken(id, token), loginBySession(s), loginByAuthToken(username, token) — альтернативные способы авторизации
  • bind() / unbind() — управление SIP регистрацией
  • audioSources() — список аудиоустройств
  • setAudioCodecPriority(codecs) — приоритет кодеков
  • call(num, customData?, extraHeaders?) — начать исходящий звонок
  • makeCall(num, customData?, extraHeaders?) — синоним call
  • getCallById(id) — получить звонок по идентификатору
  • getActiveCall() — получить текущий активный звонок

Класс: ITooLabs.WebRTC.Call

  • addEventListener(event, handler) — подписка на событие звонка
  • removeEventListener(event, handler) — отписка от события звонка
  • hangup() — завершить звонок
  • cancel() — отменить исходящий звонок до соединения
  • dial() — начать исходящий звонок (если noDial=true)
  • provision() — подтвердить входящий звонок
  • answer() — ответить на входящий звонок
  • decline() / reject() — отклонить входящий звонок
  • hold() — удержание звонка
  • transfer(address, leg?) — перевод звонка
  • sendTone(n), sendDTMF(n) — отправить DTMF-тон
  • muteMicrophone() / unmuteMicrophone() — отключить/включить микрофон
  • mutePlayback() / unmutePlayback() — отключить/включить динамики
  • cdr() / getCdr() — получить информацию о звонке

Пример передачи АОНа

const headers = {};
if (callerId) {
  headers["P-Preferred-Identity"] = "sip:" + callerId + "@" + location.host;
}
const call = client.call(phone, { dn: "Tester" }, headers);

События клиента (ITooLabs.WebRTC.Events)

  • SDKReady
  • ConnectionEstablished
  • ConnectionFailed
  • ConnectionClosed
  • AuthResult
  • BindResult
  • UnbindResult
  • IncomingCall
  • SourcesInfoUpdated
  • OnMessage

События звонка (ITooLabs.WebRTC.CallEvents)

  • Connected
  • Disconnected
  • Failed
  • InfoReceived

Состояния звонка (ITooLabs.WebRTC.CallState)

  • Initialized
  • Dial
  • Provisioned
  • Hold
  • Connected
  • Disconnected

Лицензия

MIT