Socket
Socket
Sign inDemoInstall

@papercups-io/chat-widget

Package Overview
Dependencies
Maintainers
2
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@papercups-io/chat-widget - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

6

dist/api.d.ts

@@ -1,3 +0,3 @@

export declare const createNewCustomer: (accountId: string) => Promise<any>;
export declare const createNewConversation: (accountId: string, customerId: string) => Promise<any>;
export declare const fetchCustomerConversations: (customerId: string, accountId: string) => Promise<any>;
export declare const createNewCustomer: (accountId: string, baseUrl?: string) => Promise<any>;
export declare const createNewConversation: (accountId: string, customerId: string, baseUrl?: string) => Promise<any>;
export declare const fetchCustomerConversations: (customerId: string, accountId: string, baseUrl?: string) => Promise<any>;

@@ -12,2 +12,3 @@ import React from 'react';

subtitle?: string;
baseUrl?: string;
};

@@ -14,0 +15,0 @@ declare type State = {

@@ -7,4 +7,5 @@ /// <reference types="react" />

accountId: string;
baseUrl?: string;
};
declare const EmbeddableWidget: ({ accountId, title, subtitle, primaryColor, }: Props) => JSX.Element;
declare const EmbeddableWidget: ({ accountId, title, subtitle, primaryColor, baseUrl, }: Props) => JSX.Element;
export default EmbeddableWidget;

@@ -1,3 +0,2 @@

export declare const isProd: boolean;
export declare const API_BASE_URL: string;
export declare const WS_URL: string;
export declare const DEFAULT_BASE_URL = "https://app.papercups.io";
export declare const getWebsocketUrl: (baseUrl?: string) => string;

@@ -148,6 +148,16 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var isProd = window.location.hostname !== 'localhost';
var API_BASE_URL = isProd ? 'https://taro-chat-v1.herokuapp.com' : 'http://localhost:4000';
var WS_URL = isProd ? 'wss://taro-chat-v1.herokuapp.com/socket' : 'ws://localhost:4000/socket';
var DEFAULT_BASE_URL = 'https://app.papercups.io';
var getWebsocketUrl = function getWebsocketUrl(baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
var _baseUrl$split = baseUrl.split('://'),
protocol = _baseUrl$split[0],
host = _baseUrl$split[1];
var isHttps = protocol === 'https';
return (isHttps ? 'wss' : 'ws') + "://" + host + "/socket";
};
function now() {

@@ -158,5 +168,9 @@ var date = new Date();

var createNewCustomer = function createNewCustomer(accountId) {
var createNewCustomer = function createNewCustomer(accountId, baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
try {
return Promise.resolve(request.post(API_BASE_URL + "/api/customers").send({
return Promise.resolve(request.post(baseUrl + "/api/customers").send({
customer: {

@@ -174,5 +188,9 @@ account_id: accountId,

};
var createNewConversation = function createNewConversation(accountId, customerId) {
var createNewConversation = function createNewConversation(accountId, customerId, baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
try {
return Promise.resolve(request.post(API_BASE_URL + "/api/conversations").send({
return Promise.resolve(request.post(baseUrl + "/api/conversations").send({
conversation: {

@@ -189,5 +207,9 @@ account_id: accountId,

};
var fetchCustomerConversations = function fetchCustomerConversations(customerId, accountId) {
var fetchCustomerConversations = function fetchCustomerConversations(customerId, accountId, baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
try {
return Promise.resolve(request.get(API_BASE_URL + "/api/conversations/customer").query({
return Promise.resolve(request.get(baseUrl + "/api/conversations/customer").query({
customer_id: customerId,

@@ -250,5 +272,7 @@ account_id: accountId

var accountId = _this.props.accountId;
var _this$props = _this.props,
accountId = _this$props.accountId,
baseUrl = _this$props.baseUrl;
console.log('Fetching conversations for customer:', customerId);
return fetchCustomerConversations(customerId, accountId).then(function (conversations) {
return fetchCustomerConversations(customerId, accountId, baseUrl).then(function (conversations) {
console.log('Found existing conversations:', conversations);

@@ -284,3 +308,4 @@

try {
return Promise.resolve(createNewCustomer(accountId)).then(function (_ref) {
var baseUrl = _this.props.baseUrl;
return Promise.resolve(createNewCustomer(accountId, baseUrl)).then(function (_ref) {
var customerId = _ref.id;

@@ -297,5 +322,7 @@ setCustomerId(customerId);

try {
var accountId = _this.props.accountId;
var _this$props2 = _this.props,
accountId = _this$props2.accountId,
baseUrl = _this$props2.baseUrl;
return Promise.resolve(_this.createNewCustomerId(accountId)).then(function (customerId) {
return Promise.resolve(createNewConversation(accountId, customerId)).then(function (_ref2) {
return Promise.resolve(createNewConversation(accountId, customerId, baseUrl)).then(function (_ref2) {
var conversationId = _ref2.id;

@@ -411,3 +438,4 @@

_proto.componentDidMount = function componentDidMount() {
this.socket = new phoenix.Socket(WS_URL);
var websocketUrl = getWebsocketUrl(this.props.baseUrl);
this.socket = new phoenix.Socket(websocketUrl);
this.socket.connect();

@@ -424,7 +452,7 @@ this.fetchLatestConversation(this.state.customerId);

var _this$props = this.props,
_this$props$title = _this$props.title,
title = _this$props$title === void 0 ? 'Welcome!' : _this$props$title,
_this$props$subtitle = _this$props.subtitle,
subtitle = _this$props$subtitle === void 0 ? 'How can we help you?' : _this$props$subtitle;
var _this$props3 = this.props,
_this$props3$title = _this$props3.title,
title = _this$props3$title === void 0 ? 'Welcome!' : _this$props3$title,
_this$props3$subtitle = _this$props3.subtitle,
subtitle = _this$props3$subtitle === void 0 ? 'How can we help you?' : _this$props3$subtitle;
var _this$state2 = this.state,

@@ -517,2 +545,3 @@ customerId = _this$state2.customerId,

className: 'TextArea--transparent',
placeholder: 'Start typing...',
rows: 1,

@@ -811,3 +840,4 @@ autoFocus: true,

subtitle = _ref.subtitle,
primaryColor = _ref.primaryColor;
primaryColor = _ref.primaryColor,
baseUrl = _ref.baseUrl;

@@ -860,3 +890,4 @@ var _React$useState = React.useState(false),

subtitle: subtitle,
accountId: accountId
accountId: accountId,
baseUrl: baseUrl
})), React.createElement(framerMotion.motion.div, {

@@ -863,0 +894,0 @@ initial: false,

@@ -146,6 +146,16 @@ import React from 'react';

var isProd = window.location.hostname !== 'localhost';
var API_BASE_URL = isProd ? 'https://taro-chat-v1.herokuapp.com' : 'http://localhost:4000';
var WS_URL = isProd ? 'wss://taro-chat-v1.herokuapp.com/socket' : 'ws://localhost:4000/socket';
var DEFAULT_BASE_URL = 'https://app.papercups.io';
var getWebsocketUrl = function getWebsocketUrl(baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
var _baseUrl$split = baseUrl.split('://'),
protocol = _baseUrl$split[0],
host = _baseUrl$split[1];
var isHttps = protocol === 'https';
return (isHttps ? 'wss' : 'ws') + "://" + host + "/socket";
};
function now() {

@@ -156,5 +166,9 @@ var date = new Date();

var createNewCustomer = function createNewCustomer(accountId) {
var createNewCustomer = function createNewCustomer(accountId, baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
try {
return Promise.resolve(request.post(API_BASE_URL + "/api/customers").send({
return Promise.resolve(request.post(baseUrl + "/api/customers").send({
customer: {

@@ -172,5 +186,9 @@ account_id: accountId,

};
var createNewConversation = function createNewConversation(accountId, customerId) {
var createNewConversation = function createNewConversation(accountId, customerId, baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
try {
return Promise.resolve(request.post(API_BASE_URL + "/api/conversations").send({
return Promise.resolve(request.post(baseUrl + "/api/conversations").send({
conversation: {

@@ -187,5 +205,9 @@ account_id: accountId,

};
var fetchCustomerConversations = function fetchCustomerConversations(customerId, accountId) {
var fetchCustomerConversations = function fetchCustomerConversations(customerId, accountId, baseUrl) {
if (baseUrl === void 0) {
baseUrl = DEFAULT_BASE_URL;
}
try {
return Promise.resolve(request.get(API_BASE_URL + "/api/conversations/customer").query({
return Promise.resolve(request.get(baseUrl + "/api/conversations/customer").query({
customer_id: customerId,

@@ -248,5 +270,7 @@ account_id: accountId

var accountId = _this.props.accountId;
var _this$props = _this.props,
accountId = _this$props.accountId,
baseUrl = _this$props.baseUrl;
console.log('Fetching conversations for customer:', customerId);
return fetchCustomerConversations(customerId, accountId).then(function (conversations) {
return fetchCustomerConversations(customerId, accountId, baseUrl).then(function (conversations) {
console.log('Found existing conversations:', conversations);

@@ -282,3 +306,4 @@

try {
return Promise.resolve(createNewCustomer(accountId)).then(function (_ref) {
var baseUrl = _this.props.baseUrl;
return Promise.resolve(createNewCustomer(accountId, baseUrl)).then(function (_ref) {
var customerId = _ref.id;

@@ -295,5 +320,7 @@ setCustomerId(customerId);

try {
var accountId = _this.props.accountId;
var _this$props2 = _this.props,
accountId = _this$props2.accountId,
baseUrl = _this$props2.baseUrl;
return Promise.resolve(_this.createNewCustomerId(accountId)).then(function (customerId) {
return Promise.resolve(createNewConversation(accountId, customerId)).then(function (_ref2) {
return Promise.resolve(createNewConversation(accountId, customerId, baseUrl)).then(function (_ref2) {
var conversationId = _ref2.id;

@@ -409,3 +436,4 @@

_proto.componentDidMount = function componentDidMount() {
this.socket = new Socket(WS_URL);
var websocketUrl = getWebsocketUrl(this.props.baseUrl);
this.socket = new Socket(websocketUrl);
this.socket.connect();

@@ -422,7 +450,7 @@ this.fetchLatestConversation(this.state.customerId);

var _this$props = this.props,
_this$props$title = _this$props.title,
title = _this$props$title === void 0 ? 'Welcome!' : _this$props$title,
_this$props$subtitle = _this$props.subtitle,
subtitle = _this$props$subtitle === void 0 ? 'How can we help you?' : _this$props$subtitle;
var _this$props3 = this.props,
_this$props3$title = _this$props3.title,
title = _this$props3$title === void 0 ? 'Welcome!' : _this$props3$title,
_this$props3$subtitle = _this$props3.subtitle,
subtitle = _this$props3$subtitle === void 0 ? 'How can we help you?' : _this$props3$subtitle;
var _this$state2 = this.state,

@@ -515,2 +543,3 @@ customerId = _this$state2.customerId,

className: 'TextArea--transparent',
placeholder: 'Start typing...',
rows: 1,

@@ -809,3 +838,4 @@ autoFocus: true,

subtitle = _ref.subtitle,
primaryColor = _ref.primaryColor;
primaryColor = _ref.primaryColor,
baseUrl = _ref.baseUrl;

@@ -858,3 +888,4 @@ var _React$useState = React.useState(false),

subtitle: subtitle,
accountId: accountId
accountId: accountId,
baseUrl: baseUrl
})), React.createElement(motion.div, {

@@ -861,0 +892,0 @@ initial: false,

{
"name": "@papercups-io/chat-widget",
"version": "1.0.5",
"version": "1.0.6",
"description": "Papercups chat widget",

@@ -5,0 +5,0 @@ "author": "reichert621",

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