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

vertojs

v0.0.5

Published

Verto FreeSWITCH interface

Downloads

1,039

Readme

vertojs

Verto (VER-to) RTC is a FreeSWITCH endpoint that implements a subset of a JSON-RPC connection designed for use over secure websockets. The initial target is WebRTC to simplify coding and implementing calls from web browsers and devices to FreeSWITCH. This allows a web browser or other WebRTC client to originate a call using Verto into a FreeSWITCH installation and then out to the PSTN using SIP, SS7, or other supported protocol.

This is a zero-dependency implementation that is no need to include jquery as in an original one. It doesn't contain any html stuff inside or media handlers as well. You should take care of fetch media tracks yourself (I think it is better not to hide useful features of you, browser provides a great API to handle media)

Status

This is a work in progress code. However, it is stable enough to use basic functions (calls).

Pull requests are welcomed.

Get started

Package directory content

/dist — contains a minified bundle exporting Verto symbol to a global namespace

/src — contains source Typescript files

To use this package you can either include dist/verto.js as a html <script> tag or import it using webpack like that

import { Verto } from 'vertojs'

Check index.html in the package directory to find out how to use this code with a html <script> tag

Create a client instance

let verto = new Verto(options: VertoOptions)
interface VertoOptions {
  transportConfig : JsonRpcClientParams 
  	// Verto transport configuration, check below
  
  rtcConfig?      : RTCConfiguration    
    // RTCConfiguration object, as described here 
  	// https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration
  	// The most important thing is iceServers item that should be set to go over NAT
  
  debug?          : boolean
  	// Set true to get some useful debug info in browser console 
  
  ice_timeout?    : number
  	// Milliseconds to stop waiting for ice candidates, default to 3000ms
}

interface JsonRpcClientParams {
  socketUrl       : string
  	// The URL where the verto interface lives
  	// wss://server.example.com:8082

  login           : string
  passwd          : string
}

Receive calls

You should register to verto to receive calls.

The following code is a simplified example of using the handler function to auto answer the first incoming call and add first received audio track to some <video> element.

try {
  let data = await verto.login()
} catch (error) {
  alert("Access denied")
  return
}

let local_stream = await navigator.mediaDevices.getUserMedia({audio:true})

verto.subscribeEvent('invite', call => {

  call.subscribeEvent('track', (track) => {
    if(track.kind!='audio') return
    
    let stream = new MediaStream()
    stream.addTrack(track)
    
    let el = document.getElementById('video')
    el.srcObject = stream
  })

  call.answer(local_stream.getTracks())
})

Place calls

let local_stream = await navigator.mediaDevices.getUserMedia({audio:true})

let call = verto.call(local_stream.getTracks(), "9664")

call.subscribeEvent('track', (track) => {
  if(track.kind!='audio') return
  
  let stream = new MediaStream()
  stream.addTrack(track)

  let el = document.getElementById('video')
  el.srcObject = stream
})

API description

There's a number (pretty small number) of Classes and Interfaces provided.

Verto

Methods

constructor

let verto = new Verto(options: VertoOptions)
interface VertoOptions {
  transportConfig : JsonRpcClientParams 
  	// Verto transport configuration, check below
  
  rtcConfig?      : RTCConfiguration    
    // RTCConfiguration object, as described here 
  	// https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration
  	// The most important thing is iceServers item that should be set to go over NAT
  
  debug?          : boolean
  	// Set true to get some useful debug info in browser console 
  
  ice_timeout?    : number
  	// Milliseconds to stop waiting for ice candidates, default to 3000ms
}

interface JsonRpcClientParams {
  socketUrl       : string
  	// The URL where the verto interface lives
  	// wss://server.example.com:8082

  login           : string
  passwd          : string
}

login

Parameters

  • None

Returns

  • Promise, that will be resolved if the login process succeed or threw an exception otherwise.
verto.login()

call

Parameters

  • tracks: Array<MediaStreamTrack> represents tracks to be sent to the remote call side
  • destination: string an extension to be dialed
  • options?: VertoCallOptions call options

Returns

let call = verto.call(tracks, destination, options)

isLogged

Parameters

  • None

Returns

  • Boolean
let isLogged = verto.isLogged()

logout

Parameters

  • None

Returns

  • Void
verto.logout()

Events

invite

Fires on incoming call. As a parameter handler will receive a VertoCall instance.

verto.subscribeEvent('invite', call => {

  call.subscribeEvent('track', (track) => {
    if(track.kind!='audio') return
    
    let stream = new MediaStream()
    stream.addTrack(track)
    
    let el = document.getElementById('video')
    el.srcObject = stream
  })

  call.answer(local_stream.getTracks())
})

VertoCall

This class instances should never be built manually, but using verto.call or incoming call handler.

Methods

answer

Parameters

  • tracks: Array<MediaStreamTrack> represents tracks to be sent to the remote call side

Returns

  • None
call.answer(tracks)

hangup

Parameters

  • None

Returns

  • None
call.hangup()

dtmf

Parameters

  • String

Returns

  • None
call.dtmf('5')

hold

Parameters

  • None

Returns

  • None
call.hold()

unhold

Parameters

  • None

Returns

  • None
call.unhold()

toggleHold

Parameters

  • None

Returns

  • None
call.toggleHold()

getStats

Parameters

  • None

Returns

https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats

Instance variables

id

  • String — the call id

options

direction

Events

answer

Fires when the call is answered.

call.subscribeEvent('answer', () => {
    // Do something on answer
})

track

Fires when a MediaStreamTrack is received

verto.subscribeEvent('invite', call => {

  call.subscribeEvent('track', (track) => {
    if(track.kind!='audio') return
    
    let stream = new MediaStream()
    stream.addTrack(track)
    
    let el = document.getElementById('video')
    el.srcObject = stream
  })

  call.answer(local_stream.getTracks())
})

bye

Fires when the call is ended.

call.subscribeEvent('bye', cause => {
    // Do something on call end
})

Interfaces

VertoCallOptions

interface VertoCallOptions {
  caller_id_number?   : string
  caller_id_name?     : string
  callee_id_number?   : string
  callee_id_name?     : string
}

VertoOptions

interface VertoOptions {
  transportConfig : JsonRpcClientParams 
  	// Verto transport configuration, check below
  
  rtcConfig?      : RTCConfiguration    
    // RTCConfiguration object, as described here 
  	// https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration
  	// The most important thing is iceServers item that should be set to go over NAT
  
  debug?          : boolean
  	// Set true to get some useful debug info in browser console 
  
  ice_timeout?    : number
  	// Milliseconds to stop waiting for ice candidates, default to 3000ms
}

JsonRpcClientParams

interface JsonRpcClientParams {
  socketUrl       : string
  	// The URL where the verto interface lives
  	// wss://server.example.com:8082

  login           : string
  passwd          : string
}

CallDirection

enum CallDirection {
  Incoming,
  Outgoing
}

Event handling

Both Verto and VertoCall classes uses the same event handling system.

subscribeEvent

Parameters

  • name : string
  • handler : {(data:any):void}

Returns

  • String identifies the handler
let handler_id = verto.subscribeEvent(name, handler)

unsubscribeEvent

Parameters

  • name : string
  • handler_id? : string if ommited, all the handlers for name event will be deleted

Returns

  • None
verto.unsubscribeEvent(name, handler_id)

License

Copyright (c) 2019–2022 Roman Yerin <[email protected]>

Licensed under the 3-clause BSD license.