Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@twilio/voice-sdk

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@twilio/voice-sdk - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

10

CHANGELOG.md

@@ -0,1 +1,11 @@

2.3.0 (January 23, 2023)
===================
Changes
-------
This release includes updated DNS names for [Twilio Edge Locations](https://www.twilio.com/docs/global-infrastructure/edge-locations). The Voice JS SDK uses these Edge Locations to connect to Twilio’s infrastructure via the parameter `Device.Options.edge`. The current usage of this parameter does not change as the SDK automatically maps the edge value to the new DNS names.
Additionally, you need to update your [Content Security Policies (CSP)](README.md#content-security-policy-csp) if you have it enabled for your application. You also need to update your network configuration such as firewalls, if necessary, to allow connections to the new [DNS names and IP addresses](https://www.twilio.com/docs/voice/sdks/network-connectivity-requirements).
2.2.0 (December 5, 2022)

@@ -2,0 +12,0 @@ ===================

8

es5/twilio/call.d.ts

@@ -628,6 +628,2 @@ /// <reference types="node" />

/**
* The Region currently connected to.
*/
region?: string;
/**
* An RTCConfiguration to pass to the RTCPeerConnection constructor.

@@ -642,6 +638,2 @@ */

/**
* The region passed to {@link Device} on setup.
*/
selectedRegion?: string;
/**
* Whether the disconnect sound should be played.

@@ -648,0 +640,0 @@ */

4

es5/twilio/call.js

@@ -1122,3 +1122,2 @@ "use strict";

sdk_version: C.RELEASE_VERSION,
selected_region: this._options.selectedRegion,
};

@@ -1128,5 +1127,2 @@ if (this._options.gateway) {

}
if (this._options.region) {
payload.region = this._options.region;
}
payload.direction = this._direction;

@@ -1133,0 +1129,0 @@ return payload;

@@ -5,3 +5,3 @@ /**

var PACKAGE_NAME = '@twilio/voice-sdk';
var RELEASE_VERSION = '2.2.0';
var RELEASE_VERSION = '2.3.0';
var SOUNDS_BASE_URL = 'https://sdk.twilio.com/js/client/sounds/releases/1.0.0';

@@ -8,0 +8,0 @@ module.exports.COWBELL_AUDIO_URL = SOUNDS_BASE_URL + "/cowbell.mp3?cache=" + RELEASE_VERSION;

@@ -289,3 +289,3 @@ "use strict";

}
var preferredURIs = regions_1.getChunderURIs(_this._edge, undefined, _this._log.warn.bind(_this._log));
var preferredURIs = regions_1.getChunderURIs(_this._edge);
if (preferredURIs.length > 0) {

@@ -833,3 +833,3 @@ var preferredURI = preferredURIs[0];

: Array.isArray(this._options.chunderw) && this._options.chunderw;
var newChunderURIs = this._chunderURIs = (chunderw || regions_1.getChunderURIs(this._options.edge, undefined, this._log.warn.bind(this._log))).map(regions_1.createSignalingEndpointURL);
var newChunderURIs = this._chunderURIs = (chunderw || regions_1.getChunderURIs(this._options.edge)).map(regions_1.createSignalingEndpointURL);
var hasChunderURIsChanged = originalChunderURIs.size !== newChunderURIs.length;

@@ -836,0 +836,0 @@ if (!hasChunderURIsChanged) {

/**
* Valid deprecated regions.
* @private
*/
export declare enum DeprecatedRegion {
Au = "au",
Br = "br",
Ie = "ie",
Jp = "jp",
Sg = "sg",
UsOr = "us-or",
UsVa = "us-va"
}
/**
* Valid edges.

@@ -81,12 +68,2 @@ * @private

/**
* All valid regions
* @private
*/
export declare type ValidRegion = Region | DeprecatedRegion;
/**
* Deprecated regions. Maps the deprecated region to its equivalent up-to-date region.
* @private
*/
export declare const deprecatedRegions: Record<DeprecatedRegion, Region>;
/**
* Region shortcodes. Maps the full region name from AWS to the Twilio shortcode.

@@ -99,8 +76,2 @@ * @private

/**
* Edge to region mapping, as part of Phase 1 Regional (CLIENT-7519).
* Temporary.
* @private
*/
export declare const edgeToRegion: Record<Edge, Region>;
/**
* Region to edge mapping, as part of Phase 1 Regional (CLIENT-7519).

@@ -112,9 +83,2 @@ * Temporary.

/**
* The default region to connect to and create a chunder uri from if region is
* not defined.
* @constant
* @private
*/
export declare const defaultRegion: string;
/**
* The default edge to connect to and create a chunder uri from, if the edge

@@ -126,8 +90,2 @@ * parameter is not specified during setup in `Device`.

/**
* The default chunder URI to connect to, should map to region `gll`.
* @constant
* @private
*/
export declare const defaultChunderRegionURI: string;
/**
* String template for a region insights URI

@@ -143,15 +101,8 @@ * @param region - The region.

/**
* Get the URI associated with the passed region or edge. If both are passed,
* then we want to fail `Device` setup, so we throw an error.
* As of CLIENT-7519, Regions are deprecated in favor of edges as part of
* Phase 1 Regional.
*
* Get the URI associated with the passed edge.
* @private
* @param edge - A string or an array of edge values
* @param region - The region shortcode.
* @param [onDeprecated] - A callback containing the deprecation message to be
* warned when the passed parameters are deprecated.
* @returns An array of chunder URIs
*/
export declare function getChunderURIs(edge: string[] | string | undefined, region: string | undefined, onDeprecated?: (message: string) => void): string[];
export declare function getChunderURIs(edge?: string[] | string): string[];
/**

@@ -158,0 +109,0 @@ * Get the region shortcode by its full AWS region string.

"use strict";
var _a, _b, _c, _d;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -11,16 +11,2 @@ /**

/**
* Valid deprecated regions.
* @private
*/
var DeprecatedRegion;
(function (DeprecatedRegion) {
DeprecatedRegion["Au"] = "au";
DeprecatedRegion["Br"] = "br";
DeprecatedRegion["Ie"] = "ie";
DeprecatedRegion["Jp"] = "jp";
DeprecatedRegion["Sg"] = "sg";
DeprecatedRegion["UsOr"] = "us-or";
DeprecatedRegion["UsVa"] = "us-va";
})(DeprecatedRegion = exports.DeprecatedRegion || (exports.DeprecatedRegion = {}));
/**
* Valid edges.

@@ -94,15 +80,2 @@ * @private

/**
* Deprecated regions. Maps the deprecated region to its equivalent up-to-date region.
* @private
*/
exports.deprecatedRegions = (_a = {},
_a[DeprecatedRegion.Au] = Region.Au1,
_a[DeprecatedRegion.Br] = Region.Br1,
_a[DeprecatedRegion.Ie] = Region.Ie1,
_a[DeprecatedRegion.Jp] = Region.Jp1,
_a[DeprecatedRegion.Sg] = Region.Sg1,
_a[DeprecatedRegion.UsOr] = Region.Us1,
_a[DeprecatedRegion.UsVa] = Region.Us1,
_a);
/**
* Region shortcodes. Maps the full region name from AWS to the Twilio shortcode.

@@ -122,54 +95,2 @@ * @private

/**
* Region URIs. Maps the Twilio shortcode to its Twilio endpoint URI.
* @private
*/
var regionURIs = (_b = {},
_b[Region.Au1] = 'chunderw-vpc-gll-au1.twilio.com',
_b[Region.Au1Ix] = 'chunderw-vpc-gll-au1-ix.twilio.com',
_b[Region.Br1] = 'chunderw-vpc-gll-br1.twilio.com',
_b[Region.De1] = 'chunderw-vpc-gll-de1.twilio.com',
_b[Region.De1Ix] = 'chunderw-vpc-gll-de1-ix.twilio.com',
_b[Region.Gll] = 'chunderw-vpc-gll.twilio.com',
_b[Region.Ie1] = 'chunderw-vpc-gll-ie1.twilio.com',
_b[Region.Ie1Ix] = 'chunderw-vpc-gll-ie1-ix.twilio.com',
_b[Region.Ie1Tnx] = 'chunderw-vpc-gll-ie1-tnx.twilio.com',
_b[Region.Jp1] = 'chunderw-vpc-gll-jp1.twilio.com',
_b[Region.Jp1Ix] = 'chunderw-vpc-gll-jp1-ix.twilio.com',
_b[Region.Sg1] = 'chunderw-vpc-gll-sg1.twilio.com',
_b[Region.Sg1Ix] = 'chunderw-vpc-gll-sg1-ix.twilio.com',
_b[Region.Sg1Tnx] = 'chunderw-vpc-gll-sg1-tnx.twilio.com',
_b[Region.Us1] = 'chunderw-vpc-gll-us1.twilio.com',
_b[Region.Us1Ix] = 'chunderw-vpc-gll-us1-ix.twilio.com',
_b[Region.Us1Tnx] = 'chunderw-vpc-gll-us1-tnx.twilio.com',
_b[Region.Us2] = 'chunderw-vpc-gll-us2.twilio.com',
_b[Region.Us2Ix] = 'chunderw-vpc-gll-us2-ix.twilio.com',
_b[Region.Us2Tnx] = 'chunderw-vpc-gll-us2-tnx.twilio.com',
_b);
/**
* Edge to region mapping, as part of Phase 1 Regional (CLIENT-7519).
* Temporary.
* @private
*/
exports.edgeToRegion = (_c = {},
_c[Edge.Sydney] = Region.Au1,
_c[Edge.SaoPaulo] = Region.Br1,
_c[Edge.Dublin] = Region.Ie1,
_c[Edge.Frankfurt] = Region.De1,
_c[Edge.Tokyo] = Region.Jp1,
_c[Edge.Singapore] = Region.Sg1,
_c[Edge.Ashburn] = Region.Us1,
_c[Edge.Umatilla] = Region.Us2,
_c[Edge.Roaming] = Region.Gll,
/**
* Interconnect edges
*/
_c[Edge.AshburnIx] = Region.Us1Ix,
_c[Edge.SanJoseIx] = Region.Us2Ix,
_c[Edge.LondonIx] = Region.Ie1Ix,
_c[Edge.FrankfurtIx] = Region.De1Ix,
_c[Edge.SingaporeIx] = Region.Sg1Ix,
_c[Edge.SydneyIx] = Region.Au1Ix,
_c[Edge.TokyoIx] = Region.Jp1Ix,
_c);
/**
* Region to edge mapping, as part of Phase 1 Regional (CLIENT-7519).

@@ -179,38 +100,31 @@ * Temporary.

*/
exports.regionToEdge = (_d = {},
_d[Region.Au1] = Edge.Sydney,
_d[Region.Br1] = Edge.SaoPaulo,
_d[Region.Ie1] = Edge.Dublin,
_d[Region.De1] = Edge.Frankfurt,
_d[Region.Jp1] = Edge.Tokyo,
_d[Region.Sg1] = Edge.Singapore,
_d[Region.Us1] = Edge.Ashburn,
_d[Region.Us2] = Edge.Umatilla,
_d[Region.Gll] = Edge.Roaming,
exports.regionToEdge = (_a = {},
_a[Region.Au1] = Edge.Sydney,
_a[Region.Br1] = Edge.SaoPaulo,
_a[Region.Ie1] = Edge.Dublin,
_a[Region.De1] = Edge.Frankfurt,
_a[Region.Jp1] = Edge.Tokyo,
_a[Region.Sg1] = Edge.Singapore,
_a[Region.Us1] = Edge.Ashburn,
_a[Region.Us2] = Edge.Umatilla,
_a[Region.Gll] = Edge.Roaming,
/**
* Interconnect edges
*/
_d[Region.Us1Ix] = Edge.AshburnIx,
_d[Region.Us2Ix] = Edge.SanJoseIx,
_d[Region.Ie1Ix] = Edge.LondonIx,
_d[Region.De1Ix] = Edge.FrankfurtIx,
_d[Region.Sg1Ix] = Edge.SingaporeIx,
_d[Region.Au1Ix] = Edge.SydneyIx,
_d[Region.Jp1Ix] = Edge.TokyoIx,
_a[Region.Us1Ix] = Edge.AshburnIx,
_a[Region.Us2Ix] = Edge.SanJoseIx,
_a[Region.Ie1Ix] = Edge.LondonIx,
_a[Region.De1Ix] = Edge.FrankfurtIx,
_a[Region.Sg1Ix] = Edge.SingaporeIx,
_a[Region.Au1Ix] = Edge.SydneyIx,
_a[Region.Jp1Ix] = Edge.TokyoIx,
/**
* Tnx regions
*/
_d[Region.Us1Tnx] = Edge.AshburnIx,
_d[Region.Us2Tnx] = Edge.AshburnIx,
_d[Region.Ie1Tnx] = Edge.LondonIx,
_d[Region.Sg1Tnx] = Edge.SingaporeIx,
_d);
_a[Region.Us1Tnx] = Edge.AshburnIx,
_a[Region.Us2Tnx] = Edge.AshburnIx,
_a[Region.Ie1Tnx] = Edge.LondonIx,
_a[Region.Sg1Tnx] = Edge.SingaporeIx,
_a);
/**
* The default region to connect to and create a chunder uri from if region is
* not defined.
* @constant
* @private
*/
exports.defaultRegion = 'gll';
/**
* The default edge to connect to and create a chunder uri from, if the edge

@@ -222,8 +136,2 @@ * parameter is not specified during setup in `Device`.

/**
* The default chunder URI to connect to, should map to region `gll`.
* @constant
* @private
*/
exports.defaultChunderRegionURI = 'chunderw-vpc-gll.twilio.com';
/**
* The default event gateway URI to publish to.

@@ -235,11 +143,2 @@ * @constant

/**
* String template for a region chunder URI
* @param region - The region.
*/
function createChunderRegionURI(region) {
return region === exports.defaultRegion
? exports.defaultChunderRegionURI
: "chunderw-vpc-gll-" + region + ".twilio.com";
}
/**
* String template for an edge chunder URI

@@ -270,56 +169,19 @@ * @param edge - The edge.

/**
* Get the URI associated with the passed region or edge. If both are passed,
* then we want to fail `Device` setup, so we throw an error.
* As of CLIENT-7519, Regions are deprecated in favor of edges as part of
* Phase 1 Regional.
*
* Get the URI associated with the passed edge.
* @private
* @param edge - A string or an array of edge values
* @param region - The region shortcode.
* @param [onDeprecated] - A callback containing the deprecation message to be
* warned when the passed parameters are deprecated.
* @returns An array of chunder URIs
*/
function getChunderURIs(edge, region, onDeprecated) {
if (!!region && typeof region !== 'string') {
throw new errors_1.InvalidArgumentError('If `region` is provided, it must be of type `string`.');
}
function getChunderURIs(edge) {
if (!!edge && typeof edge !== 'string' && !Array.isArray(edge)) {
throw new errors_1.InvalidArgumentError('If `edge` is provided, it must be of type `string` or an array of strings.');
}
var deprecatedMessages = [];
var uris;
if (region && edge) {
throw new errors_1.InvalidArgumentError('You cannot specify `region` when `edge` is specified in' +
'`Twilio.Device.Options`.');
}
else if (region) {
var chunderRegion = region;
deprecatedMessages.push('Regions are deprecated in favor of edges. Please see this page for ' +
'documentation: https://www.twilio.com/docs/voice/client/edges.');
var isDeprecatedRegion = Object.values(DeprecatedRegion).includes(chunderRegion);
if (isDeprecatedRegion) {
chunderRegion = exports.deprecatedRegions[chunderRegion];
}
var isKnownRegion = Object.values(Region).includes(chunderRegion);
if (isKnownRegion) {
var preferredEdge = exports.regionToEdge[chunderRegion];
deprecatedMessages.push("Region \"" + chunderRegion + "\" is deprecated, please use `edge` " +
("\"" + preferredEdge + "\"."));
}
uris = [createChunderRegionURI(chunderRegion)];
}
else if (edge) {
var edgeValues_1 = Object.values(Edge);
if (edge) {
var edgeParams = Array.isArray(edge) ? edge : [edge];
uris = edgeParams.map(function (param) { return edgeValues_1.includes(param)
? createChunderRegionURI(exports.edgeToRegion[param])
: createChunderEdgeURI(param); });
uris = edgeParams.map(function (param) { return createChunderEdgeURI(param); });
}
else {
uris = [exports.defaultChunderRegionURI];
uris = [createChunderEdgeURI(exports.defaultEdge)];
}
if (onDeprecated && deprecatedMessages.length) {
setTimeout(function () { return onDeprecated(deprecatedMessages.join('\n')); });
}
return uris;

@@ -326,0 +188,0 @@ }

The following license applies to all parts of this software except as
documented below.
Copyright (C) 2015-2021 Twilio, inc.
Copyright (C) 2015-2023 Twilio, inc.

@@ -6,0 +6,0 @@ Licensed under the Apache License, Version 2.0 (the "License");

{
"name": "@twilio/voice-sdk",
"version": "2.2.0",
"version": "2.3.0",
"description": "Twilio's JavaScript Voice SDK",

@@ -5,0 +5,0 @@ "main": "./es5/twilio.js",

@@ -140,6 +140,6 @@ ## Migration from twilio-client.js 1.x

media-src mediastream https://media.twiliocdn.com https://sdk.twilio.com
connect-src https://eventgw.twilio.com wss://chunderw-vpc-gll.twilio.com 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://chunderw-vpc-gll-{regionId}.twilio.com` in your `connect-src` directive where `regionId` is the `Region ID` as defined in this [page](https://www.twilio.com/docs/global-infrastructure/edge-locations/legacy-regions). See examples below.
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](https://www.twilio.com/docs/global-infrastructure/edge-locations). See examples below.

@@ -149,3 +149,3 @@ **If `Device.ConnectOptions.edge` is `ashburn`**

```
connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://chunderw-vpc-gll-us1.twilio.com
connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://voice-js.ashburn.twilio.com
```

@@ -156,3 +156,3 @@

```
connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://chunderw-vpc-gll-us1.twilio.com wss://chunderw-vpc-gll-au1.twilio.com wss://chunderw-vpc-gll.twilio.com
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
```

@@ -163,3 +163,3 @@

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

@@ -166,0 +166,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc