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

twilio-chat

Package Overview
Dependencies
Maintainers
2
Versions
367
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twilio-chat - npm Package Compare versions

Comparing version 0.13.0-rc5 to 1.2.3-build.369

5

browser/channel.js

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

_this2.entity.on('updated', function (value) {
_this2._update(value);
return _this2._update(value);
});

@@ -214,3 +214,2 @@ _this2.entity.on('removed', function () {

}).catch(function (err) {
_this2.entity = null;
_this2.entityPromise = null;

@@ -282,3 +281,3 @@ log.error('Failed to get channel object', err);

case 0:
if (!(this.isPrivate && this.entity)) {
if (!this.entity) {
_context2.next = 5;

@@ -285,0 +284,0 @@ break;

98

browser/client.js

@@ -129,7 +129,2 @@ "use strict";

_this.options.productId = 'ip_messaging';
// Disable local storage for Sync now
_this.options.Sync = _this.options.Sync || {};
if (!_this.options.Sync.enableSessionStorage) {
_this.options.Sync.enableSessionStorage = false;
}
if (!token) {

@@ -142,6 +137,5 @@ throw new Error(MSG_NO_TOKEN);

_this.options.transport = _this.options.transport || new twilio_transport_1.Transport(_this.options.twilsockClient, _this.options);
_this.options.emsClient = _this.options.emsClient || new twilio_ems_client_1.EmsClient(_this.options);
_this.emsClient = _this.options.emsClient || new twilio_ems_client_1.EmsClient(_this.options);
_this.options.notificationsClient = _this.options.notificationsClient || new NotificationClient(token, _this.options);
_this.options.syncClient = _this.options.syncClient || new twilio_sync_1.SyncClient(token, _this.options);
_this.emsClient = _this.options.emsClient;
_this.datasync = _this.options.syncClient;

@@ -216,4 +210,2 @@ _this.transport = _this.options.transport;

return __awaiter(this, void 0, void 0, _regenerator2.default.mark(function _callee() {
var _this2 = this;
var response, links;

@@ -235,16 +227,16 @@ return _regenerator2.default.wrap(function _callee$(_context) {

case 6:
Client.supportedPushChannels.forEach(function (channelType) {
return _this2.subscribeToPushNotifications(channelType);
});
_context.next = 9;
this.notifications.subscribe('twilio.channel.new_message', 'fcm');
this.notifications.subscribe('twilio.channel.added_to_channel', 'fcm');
this.notifications.subscribe('twilio.channel.invited_to_channel', 'fcm');
_context.next = 11;
return this.session.getSessionLinks();
case 9:
case 11:
links = _context.sent;
this.publicChannels = new publicchannels_1.PublicChannels(this.config, this, this.network, links.publicChannelsUrl);
_context.next = 13;
_context.next = 15;
return this.typingIndicator.initialize();
case 13:
case 15:
case "end":

@@ -257,11 +249,2 @@ return _context.stop();

}
}, {
key: "subscribeToPushNotifications",
value: function subscribeToPushNotifications(channelType) {
var _this3 = this;
['twilio.channel.new_message', 'twilio.channel.added_to_channel', 'twilio.channel.invited_to_channel', 'twilio.channel.removed_from_channel', 'twilio.ipmsg.typing_indicator', 'twilio.channel.consumption_update'].forEach(function (messageType) {
_this3.notifications.subscribe(messageType, channelType);
});
}
/**

@@ -280,6 +263,6 @@ * Initializes library

value: function initialize() {
var _this4 = this;
var _this2 = this;
return this.initializePromise.then(function () {
return _this4;
return _this2;
});

@@ -307,3 +290,3 @@ }

return __awaiter(this, void 0, void 0, _regenerator2.default.mark(function _callee2() {
var _this5 = this;
var _this3 = this;

@@ -339,10 +322,10 @@ return _regenerator2.default.wrap(function _callee2$(_context2) {

}).then(function (rtdToken) {
return _this5.twilsock.updateToken(fpaToken).then(function () {
return _this5.datasync.updateToken(fpaToken);
return _this3.twilsock.updateToken(fpaToken).then(function () {
return _this3.datasync.updateToken(fpaToken);
}).then(function () {
return _this5.notifications.updateToken(fpaToken);
return _this3.notifications.updateToken(fpaToken);
}).then(function () {
return _this5.sessionPromise;
return _this3.sessionPromise;
}).then(function () {
return _this5.session.updateToken(rtdToken);
return _this3.session.updateToken(rtdToken);
}).then(function () {

@@ -352,5 +335,5 @@ return rtdToken;

}).then(function (rtdToken) {
_this5.config.updateToken(rtdToken);
_this5.fpaToken = fpaToken;
return _this5;
_this3.config.updateToken(rtdToken);
_this3.fpaToken = fpaToken;
return _this3;
}));

@@ -376,3 +359,3 @@

return __awaiter(this, void 0, void 0, _regenerator2.default.mark(function _callee3() {
var _this6 = this;
var _this4 = this;

@@ -392,4 +375,4 @@ return _regenerator2.default.wrap(function _callee3$(_context3) {

return _context3.abrupt("return", this.channels.getChannel(channelSid).then(function (channel) {
return channel || _this6.publicChannels.getChannelBySid(channelSid).then(function (x) {
return _this6.channels.pushChannel(x);
return channel || _this4.publicChannels.getChannelBySid(channelSid).then(function (x) {
return _this4.channels.pushChannel(x);
});

@@ -416,3 +399,3 @@ }));

return __awaiter(this, void 0, void 0, _regenerator2.default.mark(function _callee4() {
var _this7 = this;
var _this5 = this;

@@ -432,3 +415,3 @@ return _regenerator2.default.wrap(function _callee4$(_context4) {

return _context4.abrupt("return", this.publicChannels.getChannelByUniqueName(uniqueName).then(function (x) {
return _this7.channels.pushChannel(x);
return _this5.channels.pushChannel(x);
}));

@@ -482,4 +465,5 @@

* Registers for push notifications
* @param {string} channelType - 'gcm', 'apn' and 'fcm' are supported
* @param {string} registrationId - Push notification id provided by platform
* @param {string} channelType - 'gcm' or 'apn' for now
* @private
*/

@@ -489,31 +473,22 @@

key: "setPushRegistrationId",
value: function setPushRegistrationId(channelType, registrationId) {
if (Client.supportedPushChannels.indexOf(channelType) === -1) {
throw new Error('Invalid or unsupported channelType: ' + channelType);
}
this.notifications.setPushRegistrationId(registrationId, channelType);
value: function setPushRegistrationId(registrationId, type) {
this.notifications.setPushRegistrationId(registrationId, type || 'gcm'); // notification? TBD
}
/**
* Incoming push notification handler
* @param {string} notificationPayload - Push notification payload
* Push notification payload handler
* @private
*/
}, {
key: "handlePushNotification",
value: function handlePushNotification(notification) {
var payload = notification.additionalData;
switch (payload.type) {
case 'twilio.ipmsg.typing_indicator':
{
this.typingIndicator.handleRemoteTyping(payload.data);
break;
}
key: "putPushNotificationPayload",
value: function putPushNotificationPayload(notification) {
var data = notification.additionalData;
switch (data.type) {
case 'twilio.channel.new_message':
{
var channelId = payload.data.channel_id;
var messageSid = payload.data.message_id;
var channelId = data.data.channel_id;
var messageSid = data.data.message_id;
this.getChannelBySid(channelId).then(function (channel) {
return channel.getMessages(10, messageSid);
});
break;
}

@@ -537,4 +512,3 @@ }

Client.version = SDK_VERSION;
Client.supportedPushChannels = ['fcm', 'apn', 'gcm'];
exports.Client = Client;
exports.default = Client;

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

channel = new channel_1.Channel(this.services, data, sid);
this.registerForEvents(channel);
this.channels.set(sid, channel);

@@ -346,3 +345,5 @@ }

}
_this7.emit('channelAdded', channel);
if (channel.isPrivate) {
_this7.emit('channelAdded', channel);
}
return channel;

@@ -349,0 +350,0 @@ });

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

this.entity = entity;
this.entity.on('updated', value => { this._update(value); });
this.entity.on('updated', value => this._update(value));
this.entity.on('removed', () => this.emit('removed', this));

@@ -148,3 +148,2 @@ this._update(this.entity.value);

.catch(err => {
this.entity = null;
this.entityPromise = null;

@@ -187,4 +186,3 @@ log.error('Failed to get channel object', err);

return __awaiter(this, void 0, void 0, function* () {
// Keep our subscription to public channels objects
if (this.isPrivate && this.entity) {
if (this.entity) {
yield this.entity.close();

@@ -191,0 +189,0 @@ this.entity = null;

@@ -78,3 +78,2 @@ /// <reference types="node" />

static readonly version: any;
private static readonly supportedPushChannels;
constructor(token: string, options?: Options);

@@ -88,3 +87,2 @@ readonly userInfo: UserInfo;

private _initialize();
private subscribeToPushNotifications(channelType);
/**

@@ -141,11 +139,12 @@ * Initializes library

* Registers for push notifications
* @param {string} channelType - 'gcm', 'apn' and 'fcm' are supported
* @param {string} registrationId - Push notification id provided by platform
* @param {string} channelType - 'gcm' or 'apn' for now
* @private
*/
setPushRegistrationId(channelType: string, registrationId: any): void;
setPushRegistrationId(registrationId: any, type: any): void;
/**
* Incoming push notification handler
* @param {string} notificationPayload - Push notification payload
* Push notification payload handler
* @private
*/
handlePushNotification(notification: any): void;
putPushNotificationPayload(notification: any): void;
}

@@ -152,0 +151,0 @@ /**

@@ -73,10 +73,5 @@ "use strict";

this.publicChannels = null;
this.options = (options || {});
this.options = options || {};
this.options.logLevel = this.options.logLevel || 'error';
this.options.productId = 'ip_messaging';
// Disable local storage for Sync now
this.options.Sync = this.options.Sync || {};
if (!this.options.Sync.enableSessionStorage) {
this.options.Sync.enableSessionStorage = false;
}
if (!token) {

@@ -89,6 +84,5 @@ throw new Error(MSG_NO_TOKEN);

this.options.transport = this.options.transport || new twilio_transport_1.Transport(this.options.twilsockClient, this.options);
this.options.emsClient = this.options.emsClient || new twilio_ems_client_1.EmsClient(this.options);
this.emsClient = this.options.emsClient || new twilio_ems_client_1.EmsClient(this.options);
this.options.notificationsClient = this.options.notificationsClient || new NotificationClient(token, this.options);
this.options.syncClient = this.options.syncClient || new twilio_sync_1.SyncClient(token, this.options);
this.emsClient = this.options.emsClient;
this.datasync = this.options.syncClient;

@@ -162,3 +156,5 @@ this.transport = this.options.transport;

yield this.sessionPromise;
Client.supportedPushChannels.forEach(channelType => this.subscribeToPushNotifications(channelType));
this.notifications.subscribe('twilio.channel.new_message', 'fcm');
this.notifications.subscribe('twilio.channel.added_to_channel', 'fcm');
this.notifications.subscribe('twilio.channel.invited_to_channel', 'fcm');
let links = yield this.session.getSessionLinks();

@@ -169,13 +165,2 @@ this.publicChannels = new publicchannels_1.PublicChannels(this.config, this, this.network, links.publicChannelsUrl);

}
subscribeToPushNotifications(channelType) {
['twilio.channel.new_message',
'twilio.channel.added_to_channel',
'twilio.channel.invited_to_channel',
'twilio.channel.removed_from_channel',
'twilio.ipmsg.typing_indicator',
'twilio.channel.consumption_update']
.forEach(messageType => {
this.notifications.subscribe(messageType, channelType);
});
}
/**

@@ -290,28 +275,21 @@ * Initializes library

* Registers for push notifications
* @param {string} channelType - 'gcm', 'apn' and 'fcm' are supported
* @param {string} registrationId - Push notification id provided by platform
* @param {string} channelType - 'gcm' or 'apn' for now
* @private
*/
setPushRegistrationId(channelType, registrationId) {
if (Client.supportedPushChannels.indexOf(channelType) === -1) {
throw new Error('Invalid or unsupported channelType: ' + channelType);
}
this.notifications.setPushRegistrationId(registrationId, channelType);
setPushRegistrationId(registrationId, type) {
this.notifications.setPushRegistrationId(registrationId, type || 'gcm'); // notification? TBD
}
/**
* Incoming push notification handler
* @param {string} notificationPayload - Push notification payload
* Push notification payload handler
* @private
*/
handlePushNotification(notification) {
let payload = notification.additionalData;
switch (payload.type) {
case 'twilio.ipmsg.typing_indicator': {
this.typingIndicator.handleRemoteTyping(payload.data);
break;
}
putPushNotificationPayload(notification) {
let data = notification.additionalData;
switch (data.type) {
case 'twilio.channel.new_message': {
const channelId = payload.data.channel_id;
const messageSid = payload.data.message_id;
const channelId = data.data.channel_id;
const messageSid = data.data.message_id;
this.getChannelBySid(channelId)
.then(channel => channel.getMessages(10, messageSid));
break;
}

@@ -322,4 +300,3 @@ }

Client.version = SDK_VERSION;
Client.supportedPushChannels = ['fcm', 'apn', 'gcm'];
exports.Client = Client;
exports.default = Client;

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

channel = new channel_1.Channel(this.services, data, sid);
this.registerForEvents(channel);
this.channels.set(sid, channel);

@@ -198,3 +197,5 @@ }

}
this.emit('channelAdded', channel);
if (channel.isPrivate) {
this.emit('channelAdded', channel);
}
return channel;

@@ -201,0 +202,0 @@ });

@@ -26,3 +26,3 @@ /**

*/
handleRemoteTyping(message: any): void;
private handleRemoteTyping(message);
/**

@@ -29,0 +29,0 @@ * Send typing event for the given channel sid

{
"name": "twilio-chat",
"version": "0.13.0-rc5",
"version": "1.2.3-build.369",
"description": "Twilio Chat service client library",

@@ -19,3 +19,3 @@ "main": "lib/index.js",

"twilio-notifications": "^0.4.0",
"twilio-sync": "^0.5.0",
"twilio-sync": "^0.5.0-dev",
"twilio-transport": "^0.1.1",

@@ -22,0 +22,0 @@ "twilsock": "^0.3.0",

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

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