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

node.js-sip

v1.0.9

Published

Node.js VOIP Library

Downloads

144

Readme

node.js-sip

node.js-sip is a comprehensive VoIP framework for Node.js. Despite its name, this library goes beyond SIP (Session Initiation Protocol) and offers a full-fledged toolkit for building robust VoIP applications. Leverage its extensive capabilities for SIP transport, registration, messaging, call handling, and more.

Features

  • SIP Transport: Built-in transport layer supporting UDP.
  • Client and Server Modes: Easily switch between User Agent Client (UAC) and User Agent Server (UAS).
  • Call Handling: Initiate, accept, reject, and terminate calls.
  • Message Handling: Send and receive SIP messages.
  • Customizable: Built with modularity and extensibility in mind.

Installation

npm install node.js-sip

Getting Started

Basic Usage

Here's a quick example to demonstrate how to set up a client and make a SIP call.

const VOIP = require('node.js-sip');

const voipClient = new VOIP({
    type: 'client',
    transport: {
        type: 'UDP',
        port: 5060,
    },
    username: '1000',
    register_password: 'yourPassword',
    register_ip: '192.168.1.2',
    register_port: 5060,
}, (response) => {
    if (response.type === 'REGISTERED') {
        console.log('Successfully registered with the SIP server.');
        v.call({
            to:'14444444444',
            ip:'192.168.1.12',
            port:'5060',
            callId:'1234567890',
            username:'1001',
            client_callback:(m) => {
                console.log(`client_callback`)
                console.log(m)
            }
        })
    }
});

Setting Up a SIP Server

//Nik Hendricks 10/13/23
const SIP = require('../SIP')
const VOIP = require('../')

const USERS = {
    '1000':{
        password:'rootPassword',
        name:'test testerson',
        ip:undefined,
        port:undefined,
        registered:false,
        call_id:undefined,  
        extension: '1000'
    },
    '1001':{
        password:'rootPassword',
        name:'Bill Billerson',
        ip:undefined,
        port:undefined,
        registered:false,
        call_id:undefined,  
        extension: '1001'
    }
}


var server = new VOIP({
    type:'server',
    transport:{
        type: 'UDP',
        port: 5060,
    },
},
(d) => {
    if(d.type == 'UAS_READY'){
    }else if(d.message !== undefined){
        let parsed_headers = SIP.Parser.ParseHeaders(d.message.headers);
        if(d.type == 'REGISTER'){
            server.uas_handle_registration(d.message, USERS, (response) => {
                console.log('response')
                console.log(response)
            })
        }else if(d.type == 'INVITE'){
            server.uas_handle_invite(d.message, USERS, (response) => {
                console.log('response')
                console.log(response)
            })
            
        }
    }
})

server.TrunkManager.addTrunk({
    name:'trunk1',
    type:'SIP',
    username:'1001',
    password:'rootPassword',
    ip:'192.168.1.2',
    port:5060,
    callId:'1234567890'
})

server.Router.addRoute({
    name: 'Main Trunk Route',
    type: 'trunk',
    match: '^[0-9]{11}$',
    endpoint: 'trunk:trunk1', //will decide if i want the prefix or to use the type property
})

setTimeout(() => {
    server.TrunkManager.trunks['trunk1'].register();
}, 1000)

API Reference

Constructor

new VOIP(props, callback)

  • props: Configuration object for the VOIP instance.
    • type: 'client' or 'server'.
    • transport: Transport configuration.
      • type: 'UDP' (currently supported).
      • ip: Local IP address for the transport.
      • port: Port for the transport.
    • username: SIP username (for client).
    • register_password: SIP password (for client).
    • register_ip: Registrar IP (for client).
    • register_port: Registrar port (default: 5060).
  • callback(response): Callback invoked on significant events.

Methods

call(props)

Initiates a SIP call.

  • props: Call properties.
    • to: Destination phone number.
    • ip: Destination IP address.
    • port: Destination port.
    • callId: Call ID.
    • username: SIP username.
    • client_callback: Callback for client events.

accept(message)

Accepts an incoming SIP INVITE message.

reject(message)

Rejects an incoming SIP INVITE message.

bye(message)

Terminates an ongoing call.

message(extension, body)

Sends a SIP MESSAGE to the specified extension.

  • extension: The SIP extension to message.
  • body: The message body.

TODO / Known Issues

  • Further orginization of the codebase is needed.
  • Finish RTP implementation.
  • Finish SDPParser implementation.
  • When making a call from a UAS in a b2bua configuration bye messages recived from the UAS Trunk UAC are not being associated with the originating messages.

License

MIT License. See the LICENSE file for more details.


For detailed usage and advanced configurations, refer to the full documentation (coming soon).