quiq-chat
Advanced tools
Comparing version 1.19.0 to 1.19.1
@@ -12,2 +12,3 @@ 'use strict'; | ||
var expirePlugin = _interopDefault(require('store/plugins/expire')); | ||
var jwt_decode = _interopDefault(require('jwt-decode')); | ||
var atmosphere = _interopDefault(require('atmosphere.js')); | ||
@@ -222,6 +223,2 @@ var qs = _interopDefault(require('qs')); | ||
var expireInMinutes = function expireInMinutes(numberOfMinutes) { | ||
return new Date().getTime() + numberOfMinutes * 1000 * 60; | ||
}; | ||
var setQuiqChatContainerVisible = function setQuiqChatContainerVisible(visible) { | ||
@@ -236,6 +233,2 @@ store.set('quiq-chat-container-visible', visible, expireInDays(1)); | ||
}; | ||
var setTrackingId = function setTrackingId(trackingId) { | ||
store.set('quiq-tracking-id', trackingId, expireInMinutes(60)); | ||
}; | ||
var getQuiqChatContainerVisible = function getQuiqChatContainerVisible() { | ||
@@ -254,3 +247,10 @@ return store.get('quiq-chat-container-visible') === true; | ||
var getTrackingId = function getTrackingId() { | ||
return store.get('quiq-tracking-id'); | ||
var accessToken = getAccessToken(); | ||
if (accessToken && accessToken !== null) { | ||
var accessJwt = jwt_decode(accessToken); | ||
return accessJwt.sub; | ||
} | ||
return null; | ||
}; | ||
@@ -278,3 +278,3 @@ | ||
var version = "1.19.0"; | ||
var version = "1.19.1"; | ||
@@ -1188,5 +1188,4 @@ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
setAccessToken(res.accessToken); | ||
setTrackingId(res.tokenId); | ||
if (getAccessToken() !== res.accessToken || getTrackingId() !== res.tokenId) { | ||
if (getAccessToken() !== res.accessToken) { | ||
burnItDown(); | ||
@@ -1203,3 +1202,3 @@ return Promise.reject(); | ||
Raven.setUserContext({ | ||
id: res.tokenId | ||
id: getTrackingId() | ||
}); | ||
@@ -1206,0 +1205,0 @@ |
{ | ||
"name": "quiq-chat", | ||
"version": "1.19.0", | ||
"version": "1.19.1", | ||
"description": | ||
@@ -35,2 +35,3 @@ "Library to help with network requests to create a webchat client for Quiq Messaging", | ||
"isomorphic-fetch": "2.2.1", | ||
"jwt-decode": "2.2.0", | ||
"lodash": "4.17.4", | ||
@@ -37,0 +38,0 @@ "loglevel": "1.4.1", |
@@ -11,3 +11,3 @@ // @flow | ||
import quiqFetch from './quiqFetch'; | ||
import {setAccessToken, getAccessToken, setTrackingId, getTrackingId} from './storage'; | ||
import {setAccessToken, getAccessToken, getTrackingId} from './storage'; | ||
import type {Conversation, ChatMetadata} from 'types'; | ||
@@ -87,5 +87,4 @@ import logger from './logging'; | ||
setAccessToken(res.accessToken); | ||
setTrackingId(res.tokenId); | ||
if (getAccessToken() !== res.accessToken || getTrackingId() !== res.tokenId) { | ||
if (getAccessToken() !== res.accessToken) { | ||
burnItDown(); | ||
@@ -102,3 +101,3 @@ return Promise.reject(); | ||
Raven.setUserContext({ | ||
id: res.tokenId, | ||
id: getTrackingId(), | ||
}); | ||
@@ -105,0 +104,0 @@ |
export const setQuiqChatContainerVisible = jest.fn(); | ||
export const setQuiqUserTakenMeaningfulAction = jest.fn(); | ||
export const setAccessToken = jest.fn(); | ||
export const setTrackingId = jest.fn(); | ||
export const getQuiqChatContainerVisible = jest.fn(() => true); | ||
@@ -6,0 +5,0 @@ export const getQuiqUserTakenMeaningfulAction = jest.fn(() => true); |
@@ -6,2 +6,3 @@ // @flow | ||
import contactPointNamespacePlugin from './contactPointNamespacePlugin'; | ||
import jwt_decode from 'jwt-decode'; | ||
@@ -17,5 +18,2 @@ // NOTE: These plugins must be applied in exactly this order, to ensure that contact point namespacing | ||
const expireInMinutes = (numberOfMinutes: number) => | ||
new Date().getTime() + numberOfMinutes * 1000 * 60; | ||
export const setQuiqChatContainerVisible = (visible: boolean) => { | ||
@@ -30,6 +28,2 @@ store.set('quiq-chat-container-visible', visible, expireInDays(1)); | ||
}; | ||
export const setTrackingId = (trackingId?: string) => { | ||
store.set('quiq-tracking-id', trackingId, expireInMinutes(60)); | ||
}; | ||
export const getQuiqChatContainerVisible = () => store.get('quiq-chat-container-visible') === true; | ||
@@ -40,4 +34,13 @@ export const getQuiqUserTakenMeaningfulAction = () => | ||
export const getAccessToken = () => store.get('X-Quiq-Access-Token'); | ||
export const getTrackingId = () => store.get('quiq-tracking-id'); | ||
export const getTrackingId = () => { | ||
const accessToken = getAccessToken(); | ||
if (accessToken && accessToken !== null) { | ||
const accessJwt = jwt_decode(accessToken); | ||
return accessJwt.sub; | ||
} | ||
return null; | ||
}; | ||
let storageEnabled; | ||
@@ -44,0 +47,0 @@ export const isStorageEnabled = () => { |
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 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 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 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 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 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 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 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 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 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 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 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 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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1366757
10
109
6277
+ Addedjwt-decode@2.2.0
+ Addedjwt-decode@2.2.0(transitive)