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 🙏

© 2026 – Pkg Stats / Ryan Hefner

easy-sipjs

v2.4.1

Published

Abstração simplificada do SIP.js para projetos WebRTC.

Downloads

383

Readme

easy-sipjs

Uma camada de abstração de alto nível e unificada sobre SIP.js e JsSIP. Projetada especificamente para eliminar o boilerplate exaustivo em aplicações WebRTC de produção, garantindo uma API consistente, moderna e 100% agnóstica de provedor.


Instalação

npm install easy-sipjs

Recursos Principais

  • 🔌 Provedor Agnóstico: Mude de SIP.js para JsSIP em tempo de execução sem mexer na sua UI.
  • 🔀 URI Auto-Normalizado: Funciona passando "4002", "sip:4002" ou "[email protected]".
  • 👥 Multi-Chamadas (Stack): Rastreamento automático de múltiplas sessões simultâneas e sessão ativa (activeSession).
  • 🔄 Status Reativo: Ciclo de estados integrado (connecting ➡️ connected ➡️ registered).
  • 🛡️ Helpers WebRTC: Métodos prontos para solicitar permissões e listar dispositivos (câmeras, fones, caixas de som).
  • 🎥 Upgrade de Vídeo Mid-Call: A vinculação de mídia se adapta automaticamente se você ligar a câmera durante a chamada.
  • 🌐 Suporte a STUN/TURN (ICE): Adicione servidores ICE de forma nativa nas credenciais de registro.
  • ✉️ Extra Headers SIP: Envie cabeçalhos personalizados nas chamadas e respostas com facilidade.
  • 🔌 Reconexão de Rede Ativa: Lógica resiliente para quedas de internet e monitoramento online do browser.
  • 🔔 Tons de Chamada Automáticos: Toca sons de Ringtone (entrada) e Ringback (saída) nativamente.
  • 🔊 Speaker Selection: Altere a saída de áudio usando SinkId nativamente.
  • 💬 DTMF: Envio e recepção de tons via SIP INFO (application/dtmf-relay).

Começo Rápido

1. Permissões e Dispositivos

import { SipClient } from 'easy-sipjs';

// Solicitar microfone
await SipClient.requestPermissions({ audio: true });

// Listar alto-falantes
const speakers = await SipClient.getAudioOutputDevices();
console.log("Speakers:", speakers);

2. Inicialização & Registro

const client = new SipClient({
  domain: "sip.meudominio.com",
  phone: "4001",
  secret: "minhasenhasecreta",
  server: "wss://rtc.meudominio.com:8089/ws",
  // Suporte a ICE/STUN
  iceServers: [{ urls: "stun:stun.l.google.com:19302" }]
}, {
  provider: 'sipjs',
  // Sons automatizados
  sounds: {
    ringtone: "/sounds/incoming.mp3",
    ringback: "/sounds/outgoing.mp3"
  }
});

client.onConnectionStateChange = (state) => {
  console.log(`Status de Conexão: ${state}`);
};

await client.register();

3. Chamada de Saída & Entrada

// Fazer chamada
const session = await client.call({
  destination: "4002",
  remoteElement: document.getElementById('remoteAudio') as HTMLMediaElement,
  extraHeaders: ["X-Agent-ID: 102"] // Cabeçalhos adicionais
});

// Receber e atender chamada
client.onUserAgent.onInvite = async (invitation) => {
  const session = await client.answer(invitation, {
    remoteElement: document.getElementById('remoteAudio') as HTMLMediaElement,
    extraHeaders: ["X-Answered-By: WebUI"]
  });
};

Controle de Chamadas (ISipSession)

session.mute();         // Muta microfone local
session.unmute();
session.muteVideo();    // Desliga câmera local
session.unmuteVideo();

await session.hold();   // Coloca em espera
await session.unhold();

await session.setAudioOutput("id-alto-falante"); // Muda saída de áudio
await session.sendDTMF("1");                    // Envia tom DTMF

await session.transfer("4003");                 // Transferência cega
await session.transfer(outraSessionAtiva);      // Transferência atendida

await session.bye();                            // Desconecta chamada

Gerenciamento Multi-Linha no SipClient

const calls = client.getSessions(); // Lista de chamadas em andamento
client.setActiveSession(calls[0]);   // Focar em uma chamada específica

client.mute();         // Executa mute na chamada em foco
await client.hangup(); // Desconecta chamada em foco

Licença

MIT