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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@twilio/voice-sdk

v2.12.2

Published

Twilio's JavaScript Voice SDK

Downloads

397,758

Readme

Migration from twilio-client.js 1.x

This product, Twilio's JavaScript Voice SDK, is the next version of Twilio's Javascript Client SDK. It is now in GA and we recommend all customers migrate in order to continue receiving future feature additions. For help on migrating from 1.x, see our migration guide.

@twilio/voice-sdk

NPM CircleCI

Twilio's Voice SDK allows you to add real-time voice and PSTN calling to your web apps.

Issues and Support

Please check out our common issues page or file any issues you find here on Github. For general inquiries related to the Voice SDK you can file a support ticket. Please ensure that you are not sharing any Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Installation

NPM

We recommend using npm to add the Voice SDK as a dependency.

npm install @twilio/voice-sdk --save

Using this method, you can import the Voice SDK using ES Module or TypeScript syntax:

import { Device } from '@twilio/voice-sdk';

Or using CommonJS:

const Device = require('@twilio/voice-sdk').Device;

CDN

As of 2.0, the Twilio Voice SDK is no longer hosted via CDN.

GitHub

Although we recommend using npm to add the Voice SDK as a dependency, you can also get the Twilio Voice SDK code from GitHub and include it in your project directly. To do so, navigate to "Tags" and find the most recent release, or the particular release version you'd like to use.

Note: releases tagged with "-rc" are "Release Candidate" versions and are still being tested. Unless you specifically know that you want to use a release candidate version, you should not use a release with "-rc" in the name.

Download either the zip or the tar.gz and then extract the files. For example, if you downloaded the tarball for the 2.0.0 release, you could then extract the files with the tar command:

tar -xvzf twilio-voice.js-2.0.0.tar.gz
cd twilio-voice.js-2.0.0

Once you've extracted the folder, the twilio.js and twilio.min.js files that you can include in your project will be in the /dist directory. twilio.min.js is the minified version of the code.

You can copy either the twilio.js or the twilio.min.js file into your project and then provide a link to it in your html. For example:

<script type="text/javascript" src="twilio.min.js"></script>

Using this method, you can access the SDK through the browser global:

const Device = Twilio.Device;

Testing

Running unit tests requires no setup aside from installation (above). You can run unit tests via:

npm run test:unit

Integration tests require some set up:

  1. If the account you want to use doesn't already have a TwiML app set up, create one using the TwiML code below.
  2. Copy config.example.yaml to config.yaml, replacing the placeholder information with valid credentials.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial>
    <Client>
      <Identity>{{To}}</Identity>
      <Parameter name="duplicate" value="12345" />
      <Parameter name="duplicate" value="123456" />
      <Parameter name="custom + param" value="我不吃蛋" />
      <Parameter name="foobar" value="some + value" />
      <Parameter name="custom1" value="{{Custom1}}" />
      <Parameter name="custom2" value="{{Custom2}}" />
      <Parameter name="custom3" value="{{Custom3}}" />
    </Client>
  </Dial>
</Response>

Integration tests can be run via:

npm run test:integration

These tests will run via karma, one at a time, in your system's default Chrome and then Firefox.

Network tests have been split out into their own docker processes, and can be run via

npm run test:docker

Content Security Policy (CSP)

Use the following policy directives to enable CSP that is compatible with twilio-voice.js.

script-src https://media.twiliocdn.com https://sdk.twilio.com
media-src mediastream: https://media.twiliocdn.com https://sdk.twilio.com
connect-src https://eventgw.twilio.com wss://voice-js.roaming.twilio.com https://media.twiliocdn.com https://sdk.twilio.com

If you are providing a non-default value for Device.ConnectOptions.edge parameter, you need to add the Signaling URI wss://voice-js.{edgeId}.twilio.com in your connect-src directive where edgeId is the Edge ID as defined in this page. See examples below.

If Device.ConnectOptions.edge is ashburn

connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://voice-js.ashburn.twilio.com

If Device.ConnectOptions.edge is ['ashburn', 'sydney', 'roaming']

connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://voice-js.ashburn.twilio.com wss://voice-js.sydney.twilio.com wss://voice-js.roaming.twilio.com

If you are providing a home region grant into your Twilio access token, you need to add the insights endpoint in your connect-src directive using eventgw.{homeRegion}.twilio.com format. Below is an example if your home region grant is sg1.

connect-src https://eventgw.sg1.twilio.com wss://voice-js.roaming.twilio.com https://media.twiliocdn.com https://sdk.twilio.com

License

See LICENSE.md