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

twilio-mcs-client

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twilio-mcs-client - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0-rc1

20

browser/client.js

@@ -48,8 +48,12 @@ "use strict";

/**
* Base URLs must be full URLs with host. If host is not provided it will be generated from a default configuration
* template using options.region.
*
* @param {String} token - Access token
* @param {String} baseUrl - Base URL for Media Content Service, i.e. /v1/Services/{serviceSid}/Media
* @param {String} baseUrl - Base URL for Media Content Service Media resource, i.e. /v1/Services/{serviceSid}/Media
* @param {String} baseSetUrl - Base URL for Media Content Service MediaSet resource, i.e. /v1/Services/{serviceSid}/MediaSet
* @param {Client#ClientOptions} [options] - Options to customize the Client
*/
function Client(token, baseUrl) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
function Client(token, baseUrl, baseSetUrl) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
(0, _classCallCheck3.default)(this, Client);

@@ -59,3 +63,3 @@

this.options.logLevel = this.options.logLevel || 'silent';
this.config = new configuration_1.Configuration(token, baseUrl, this.options);
this.config = new configuration_1.Configuration(token, baseUrl, baseSetUrl, this.options);
if (!token) {

@@ -109,3 +113,3 @@ throw new Error(MSG_NO_TOKEN);

_context.next = 2;
return this.network.get(this.config.baseUrl + "/" + sid);
return this.network.get(this.config.mediaUrl + "/" + sid);

@@ -148,3 +152,3 @@ case 2:

_context2.next = 2;
return this.network.post(this.config.baseUrl, media, contentType);
return this.network.post(this.config.mediaUrl, media, contentType);

@@ -188,3 +192,3 @@ case 2:

_context3.next = 2;
return this.network.post(this.config.baseUrl, formData);
return this.network.post(this.config.mediaUrl, formData);

@@ -232,3 +236,3 @@ case 2:

_context4.next = 3;
return this.network.post(this.config.baseUrl + "Set", (0, _stringify2.default)(query), 'application/json');
return this.network.post("" + this.config.mediaSetUrl, (0, _stringify2.default)(query), 'application/json');

@@ -235,0 +239,0 @@ case 3:

14

browser/configuration.js

@@ -19,5 +19,14 @@ "use strict";

var RETRY_WHEN_THROTTLED = true;
var regionalMcsHost = function regionalMcsHost(region) {
return "https://mcs." + (region ? region + "." : '') + "twilio.com";
};
var isFullUrl = function isFullUrl(url) {
return url.startsWith('http');
};
var fullUrl = function fullUrl(partUrl, region) {
return "" + (!isFullUrl(partUrl) ? regionalMcsHost(region) : '') + partUrl;
};
var Configuration = function () {
function Configuration(token, baseUrl, options) {
function Configuration(token, baseUrl, baseSetUrl, options) {
(0, _classCallCheck3.default)(this, Configuration);

@@ -27,3 +36,4 @@

this.region = constructorOptions.region || options.region;
this.baseUrl = baseUrl;
this.mediaUrl = fullUrl(baseUrl, this.region);
this.mediaSetUrl = baseSetUrl ? fullUrl(baseSetUrl) : this.mediaUrl + "Set";
this.token = token;

@@ -30,0 +40,0 @@ this.retryWhenThrottledOverride = constructorOptions.retryWhenThrottledOverride;

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

_context.next = 2;
return this.network.get(this.config.baseUrl + "/" + this.sid);
return this.network.get(this.config.mediaUrl + "/" + this.sid);

@@ -72,0 +72,0 @@ case 2:

@@ -20,7 +20,11 @@ /// <reference types="node" />

/**
* Base URLs must be full URLs with host. If host is not provided it will be generated from a default configuration
* template using options.region.
*
* @param {String} token - Access token
* @param {String} baseUrl - Base URL for Media Content Service, i.e. /v1/Services/{serviceSid}/Media
* @param {String} baseUrl - Base URL for Media Content Service Media resource, i.e. /v1/Services/{serviceSid}/Media
* @param {String} baseSetUrl - Base URL for Media Content Service MediaSet resource, i.e. /v1/Services/{serviceSid}/MediaSet
* @param {Client#ClientOptions} [options] - Options to customize the Client
*/
constructor(token: string, baseUrl: string, options?: Options);
constructor(token: string, baseUrl: string, baseSetUrl: string, options?: Options);
/**

@@ -27,0 +31,0 @@ * These options can be passed to Client constructor

@@ -20,10 +20,14 @@ "use strict";

/**
* Base URLs must be full URLs with host. If host is not provided it will be generated from a default configuration
* template using options.region.
*
* @param {String} token - Access token
* @param {String} baseUrl - Base URL for Media Content Service, i.e. /v1/Services/{serviceSid}/Media
* @param {String} baseUrl - Base URL for Media Content Service Media resource, i.e. /v1/Services/{serviceSid}/Media
* @param {String} baseSetUrl - Base URL for Media Content Service MediaSet resource, i.e. /v1/Services/{serviceSid}/MediaSet
* @param {Client#ClientOptions} [options] - Options to customize the Client
*/
constructor(token, baseUrl, options = {}) {
constructor(token, baseUrl, baseSetUrl, options = {}) {
this.options = options;
this.options.logLevel = this.options.logLevel || 'silent';
this.config = new configuration_1.Configuration(token, baseUrl, this.options);
this.config = new configuration_1.Configuration(token, baseUrl, baseSetUrl, this.options);
if (!token) {

@@ -63,3 +67,3 @@ throw new Error(MSG_NO_TOKEN);

async get(sid) {
const response = await this.network.get(`${this.config.baseUrl}/${sid}`);
const response = await this.network.get(`${this.config.mediaUrl}/${sid}`);
return new media_1.Media(this.config, this.network, response.body);

@@ -75,3 +79,3 @@ }

async post(contentType, media) {
const response = await this.network.post(this.config.baseUrl, media, contentType);
const response = await this.network.post(this.config.mediaUrl, media, contentType);
return new media_1.Media(this.config, this.network, response.body);

@@ -88,3 +92,3 @@ }

async postFormData(formData) {
const response = await this.network.post(this.config.baseUrl, formData);
const response = await this.network.post(this.config.mediaUrl, formData);
return new media_1.Media(this.config, this.network, response.body);

@@ -101,3 +105,3 @@ }

};
const response = (await this.network.post(`${this.config.baseUrl}Set`, JSON.stringify(query), 'application/json'));
const response = (await this.network.post(`${this.config.mediaSetUrl}`, JSON.stringify(query), 'application/json'));
return response.map((item) => {

@@ -104,0 +108,0 @@ if (item.code !== 200) {

@@ -5,5 +5,6 @@ declare class Configuration {

readonly backoffConfigOverride: any;
readonly baseUrl: string;
private region;
constructor(token: string, baseUrl: string, options: any);
readonly mediaUrl: string;
readonly mediaSetUrl: string;
private readonly region;
constructor(token: string, baseUrl: string, baseSetUrl: string, options: any);
static get backoffConfigDefault(): any;

@@ -10,0 +11,0 @@ static get retryWhenThrottledDefault(): boolean;

@@ -8,7 +8,11 @@ "use strict";

const RETRY_WHEN_THROTTLED = true;
const regionalMcsHost = (region) => `https://mcs.${region ? `${region}.` : ''}twilio.com`;
const isFullUrl = (url) => url.startsWith('http');
const fullUrl = (partUrl, region) => `${!isFullUrl(partUrl) ? regionalMcsHost(region) : ''}${partUrl}`;
class Configuration {
constructor(token, baseUrl, options) {
constructor(token, baseUrl, baseSetUrl, options) {
let constructorOptions = options.MCS || options || {};
this.region = constructorOptions.region || options.region;
this.baseUrl = baseUrl;
this.mediaUrl = fullUrl(baseUrl, this.region);
this.mediaSetUrl = baseSetUrl ? fullUrl(baseSetUrl) : `${this.mediaUrl}Set`;
this.token = token;

@@ -15,0 +19,0 @@ this.retryWhenThrottledOverride = constructorOptions.retryWhenThrottledOverride;

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

async getContentUrl() {
let response = await this.network.get(`${this.config.baseUrl}/${this.sid}`);
let response = await this.network.get(`${this.config.mediaUrl}/${this.sid}`);
this._update(response.body);

@@ -45,0 +45,0 @@ return Promise.resolve(this.state.contentDirectUrl);

{
"name": "twilio-mcs-client",
"version": "0.4.3",
"version": "0.5.0-rc1",
"description": "Twilio Media Content Service client library",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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

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

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