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

quiq-chat

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quiq-chat - npm Package Compare versions

Comparing version 1.7.1 to 1.8.1

77

build/quiq-chat.js

@@ -258,3 +258,3 @@ 'use strict';

var version = "1.7.1";
var version = "1.8.1";

@@ -373,2 +373,17 @@ //

//
var setQuiqChatContainerVisibleCookie = function setQuiqChatContainerVisibleCookie(visible) {
jsCookie.set('quiq-chat-container-visible', visible, { expires: 1 });
};
var setQuiqUserTakenMeaningfulActionCookie = function setQuiqUserTakenMeaningfulActionCookie(visible) {
jsCookie.set('quiq-user-taken-meaningful-action', visible, { expires: 1 });
};
var getQuiqChatContainerVisibleCookie = function getQuiqChatContainerVisibleCookie() {
return jsCookie.get('quiq-chat-container-visible') === 'true';
};
var getQuiqUserTakenMeaningfulActionCookie = function getQuiqUserTakenMeaningfulActionCookie() {
return jsCookie.get('quiq-user-taken-meaningful-action') === 'true';
};
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -458,6 +473,23 @@

message = atmosphere.util.parseJSON(res.responseBody);
if (message.messageType === 'BurnItDown') {
burnItDown(message.data);
if (callbacks$1.onBurn) callbacks$1.onBurn();
return;
switch (message.messageType) {
case 'BurnItDown':
{
burnItDown(message.data);
if (callbacks$1.onBurn) callbacks$1.onBurn();
return;
}
case 'ChatMessage':
{
var _message = message,
data = _message.data;
// If we took a meaninful action in an undocked window, ensure we update the parent
if (data && data.type && (data.type === 'Register' || data.type === 'Text')) {
setQuiqUserTakenMeaningfulActionCookie(true);
if (data.type === 'Register' && callbacks$1.onRegistration) {
callbacks$1.onRegistration();
}
}
}
}

@@ -500,17 +532,2 @@

//
var setQuiqChatContainerVisibleCookie = function setQuiqChatContainerVisibleCookie(visible) {
jsCookie.set('quiq-chat-container-visible', visible, { expires: 1 });
};
var setQuiqUserTakenMeaningfulActionCookie = function setQuiqUserTakenMeaningfulActionCookie(visible) {
jsCookie.set('quiq-user-taken-meaningful-action', visible, { expires: 1 });
};
var getQuiqChatContainerVisibleCookie = function getQuiqChatContainerVisibleCookie() {
return jsCookie.get('quiq-chat-container-visible') === 'true';
};
var getQuiqUserTakenMeaningfulActionCookie = function getQuiqUserTakenMeaningfulActionCookie() {
return jsCookie.get('quiq-user-taken-meaningful-action') === 'true';
};
var _this$1 = undefined;

@@ -574,2 +591,7 @@

this.onRegistration = function (callback) {
_this2.callbacks.onRegistration = callback;
return _this2;
};
this.onRetryableError = function (callback) {

@@ -714,2 +736,3 @@ _this2.callbacks.onRetryableError = callback;

setQuiqChatContainerVisibleCookie(true);
return joinChat$1();

@@ -807,5 +830,10 @@ };

case MessageTypes.LEAVE:
case MessageTypes.REGISTER:
_this2._processNewMessagesAndEvents([], [message.data]);
break;
case MessageTypes.REGISTER:
if (_this2.callbacks.onRegistration) {
_this2.callbacks.onRegistration();
}
_this2.userIsRegistered = true;
break;
case MessageTypes.AGENT_TYPING:

@@ -881,3 +909,3 @@ if (_this2.callbacks.onAgentTyping) {

var sortedMessages = sortByTimestamp(_this2.textMessages.concat(newMessages));
var sortedEvents = sortByTimestamp(_this2.textMessages.concat(newEvents));
var sortedEvents = sortByTimestamp(_this2.events.concat(newEvents));

@@ -890,7 +918,2 @@ _this2.textMessages = sortedMessages;

}
// Update user registration status
_this2.userIsRegistered = _this2.events.some(function (e) {
return e.type === MessageTypes.REGISTER;
});
};

@@ -897,0 +920,0 @@

{
"name": "quiq-chat",
"version": "1.7.1",
"version": "1.8.1",
"description": "Library to help with network requests to create a webchat client for Quiq Messaging",

@@ -24,11 +24,6 @@ "main": "build/quiq-chat.js",

"jest": {
"modulePaths": [
"src",
"node_modules"
],
"modulePaths": ["src", "node_modules"],
"rootDir": "src"
},
"keywords": [
"quiq"
],
"keywords": ["quiq"],
"author": "nate.norberg@goquiq.com",

@@ -35,0 +30,0 @@ "license": "MIT",

@@ -40,2 +40,3 @@ // @flow

const onBurn = jest.fn();
const onRegistration = jest.fn();
const host = 'https://test.goquiq.fake';

@@ -59,2 +60,3 @@ const contactPoint = 'test';

.onConnectionStatusChange(onConnectionStatusChange)
.onRegistration(onRegistration)
.onBurn(onBurn);

@@ -189,2 +191,3 @@

expect(client.isRegistered()).toBe(true);
expect(onRegistration).toBeCalled();
});

@@ -191,0 +194,0 @@ });

// @flow
jest.mock('atmosphere.js');
jest.mock('../utils');
jest.mock('../cookies.js');
import * as Websockets from '../websockets';
import * as Utils from '../utils';
import atmosphere from 'atmosphere.js';
import {setQuiqUserTakenMeaningfulActionCookie} from '../cookies';

@@ -15,2 +17,3 @@ describe('Websockets', () => {

onTransportFailure: jest.fn(),
onRegistration: jest.fn(),
onClose: jest.fn(),

@@ -74,4 +77,4 @@ onBurn: jest.fn(),

message = {
data: {favoriteNumber: 7},
messageType: 'Text',
data: {type: 'Text'},
messageType: 'ChatMessage',
tenantId: 'test',

@@ -88,2 +91,27 @@ };

describe('ChatMessage', () => {
it('sets cookie', () => {
message.messageType = 'ChatMessage';
message.data = {
type: 'Text',
};
buildRequest.onMessage({
responseBody: JSON.stringify(message),
});
expect(setQuiqUserTakenMeaningfulActionCookie).toBeCalled();
});
it('calls onRegistration for register event', () => {
message.messageType = 'ChatMessage';
message.data = {
type: 'Register',
};
buildRequest.onMessage({
responseBody: JSON.stringify(message),
});
expect(setQuiqUserTakenMeaningfulActionCookie).toBeCalled();
expect(callbacks.onRegistration).toBeCalled();
});
});
describe('burnItDown message', () => {

@@ -90,0 +118,0 @@ it('calls burnItDown', () => {

@@ -77,2 +77,7 @@ // @flow

onRegistration = (callback: () => void): QuiqChatClient => {
this.callbacks.onRegistration = callback;
return this;
};
onRetryableError = (callback: (error: ?ApiError) => void): QuiqChatClient => {

@@ -157,2 +162,3 @@ this.callbacks.onRetryableError = callback;

cookies.setQuiqChatContainerVisibleCookie(true);
return API.joinChat();

@@ -215,5 +221,10 @@ };

case MessageTypes.LEAVE:
case MessageTypes.REGISTER:
this._processNewMessagesAndEvents([], [message.data]);
break;
case MessageTypes.REGISTER:
if (this.callbacks.onRegistration) {
this.callbacks.onRegistration();
}
this.userIsRegistered = true;
break;
case MessageTypes.AGENT_TYPING:

@@ -270,3 +281,3 @@ if (this.callbacks.onAgentTyping) {

const sortedMessages = sortByTimestamp(this.textMessages.concat(newMessages));
const sortedEvents = sortByTimestamp(this.textMessages.concat(newEvents));
const sortedEvents = sortByTimestamp(this.events.concat(newEvents));

@@ -279,5 +290,2 @@ this.textMessages = sortedMessages;

}
// Update user registration status
this.userIsRegistered = this.events.some(e => e.type === MessageTypes.REGISTER);
};

@@ -284,0 +292,0 @@ }

@@ -52,2 +52,3 @@ // @flow

onConnectionStatusChange?: (connected: boolean) => void,
onRegistration?: () => void,
onBurn?: () => void,

@@ -167,2 +168,3 @@ };

onTransportFailure?: (errorMsg: string, req: AtmosphereRequest) => void,
onRegistration?: () => void,
onClose?: () => void,

@@ -169,0 +171,0 @@ onBurn?: () => void,

@@ -5,2 +5,3 @@ // @flow

import {isIE9, burnItDown} from './utils';
import * as cookies from './cookies';
import type {

@@ -93,6 +94,19 @@ AtmosphereRequest,

message = atmosphere.util.parseJSON(res.responseBody);
if (message.messageType === 'BurnItDown') {
burnItDown(message.data);
if (callbacks.onBurn) callbacks.onBurn();
return;
switch (message.messageType) {
case 'BurnItDown': {
burnItDown(message.data);
if (callbacks.onBurn) callbacks.onBurn();
return;
}
case 'ChatMessage': {
const {data} = message;
// If we took a meaninful action in an undocked window, ensure we update the parent
if (data && data.type && (data.type === 'Register' || data.type === 'Text')) {
cookies.setQuiqUserTakenMeaningfulActionCookie(true);
if (data.type === 'Register' && callbacks.onRegistration) {
callbacks.onRegistration();
}
}
}
}

@@ -99,0 +113,0 @@

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