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

quiq-chat

Package Overview
Dependencies
Maintainers
3
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.62.0 to 1.63.0

coverage/lcov-report/block-navigation.js

4

package.json
{
"name": "quiq-chat",
"version": "1.62.0",
"version": "1.63.0",
"descri1tion": "Library to help with network requests to create a webchat client for Quiq Messaging",

@@ -48,3 +48,3 @@ "main": "build/quiq-chat.js",

"store": "2.0.12",
"stubborn-fetch": "0.0.5",
"stubborn-fetch": "0.1.0",
"ua-parser-js": "0.7.18"

@@ -51,0 +51,0 @@ },

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

import {version} from '../package';
import {registerCallbacks as registerQuiqFetchCallbacks} from './quiqFetch';

@@ -133,3 +134,3 @@ Senty.init();

this.callbacks.onError = callback;
StubbornFetch.registerCallbacks({onError: callback});
registerQuiqFetchCallbacks({onError: callback});
return this;

@@ -136,0 +137,0 @@ };

// @flow
import oldStubbornFetch from './stubbornFetch';
import oldStubbornFetch, {registerCallbacks as oldRegisterCallbacks} from './stubbornFetch';
import StubbornFetch, {StubbornFetchError} from 'stubborn-fetch';

@@ -11,3 +11,9 @@ import {checkRequiredSettings, getSessionApiUrl, getGenerateUrl, getBurned} from './globals';

import logging from './logging';
import type {ApiError} from './types';
type FetchCallbacks = {
onError?: (error: ?ApiError | ?StubbornFetchError) => void,
onErrorResolved?: () => void,
};
const messages = {

@@ -23,21 +29,43 @@ burned: 'Client in bad state. Aborting call.',

const quiqFetchLog = logging('QuiqFetch');
const scrubRequest = (req: Object): Object => {
const reqCopy = Object.assign({}, req);
// Redact access token
if (reqCopy.headers && reqCopy.headers['X-Quiq-Access-Token']) {
reqCopy.headers['X-Quiq-Access-Token'] = '<redacted>';
}
return reqCopy;
};
const scrubError = (e: StubbornFetchError): StubbornFetchError => {
const dataCopy = Object.assign({}, e.data);
if (dataCopy.request) {
dataCopy.request = scrubRequest(dataCopy.request);
}
return {...e, data: dataCopy};
};
const logger = {
log: quiqFetchLog.log,
debug: quiqFetchLog.debug,
info: quiqFetchLog.info,
warn: quiqFetchLog.warn,
error: (msg: string, e: StubbornFetchError) =>
error: (msg: string, data: Object) => {
quiqFetchLog.error(
msg,
e,
e &&
e.error &&
e.error.data &&
e.error.data.response &&
e.error.data.response.status &&
e.error.data.response.status >= 400 &&
e.error.data.response.status < 500,
),
data.error && scrubError(data.error),
data &&
data.error &&
data.error.data &&
data.error.data.response &&
data.error.data.response.status &&
data.error.data.response.status === 401,
);
},
};
let fetchMode;
let callbacks: FetchCallbacks = {};
export const setFetchMode = (mode?: 'edge' | 'legacy') => {

@@ -47,2 +75,9 @@ fetchMode = mode;

export const registerCallbacks = (cbs: FetchCallbacks) => {
callbacks = Object.assign({}, callbacks, cbs);
// Assign these callbacks to old school stubborn fetch, until we remove it
oldRegisterCallbacks(cbs);
};
const quiqFetch = (

@@ -113,2 +148,3 @@ url: string,

/******** Old Stubborn Fetch *********/
if (!fetchMode || fetchMode === 'legacy') {

@@ -136,3 +172,11 @@ return oldStubbornFetch(parsedUrl, request)

/******** New Stubborn Fetch *********/
const failures = [];
const onError = (e: StubbornFetchError) => {
failures.push({
statusCode: e.data && e.data.response && e.data.response.status,
errorType: e.type,
});
if (e.data && e.data.response && e.data.response.status) {

@@ -167,6 +211,19 @@ const {status} = e.data.response;

logger,
minimumStatusCodeForRetry: 402,
minimumStatusCodeForRetry: 500,
})
.send()
.then((res: Promise<Response> | Response): any => {
.then((res: Response): any => {
// Log this request to sentry
const data = {
statusCode: res.status,
reason: res.statusText,
request: scrubRequest(request),
url: parsedUrl,
failures,
};
quiqFetchLog.debug(`[${data.statusCode}] (${data.reason}) ${data.url}`, {
data,
capture: true,
});
if (options.responseType === 'JSON' && res && res.json) {

@@ -190,2 +247,3 @@ return ((res: any): Response)

if (onError(error)) {
if (callbacks.onError) callbacks.onError(error);
return Promise.reject(new Error(messages.burned));

@@ -214,2 +272,3 @@ }

if (callbacks.onError) callbacks.onError(error);
return Promise.reject(error);

@@ -216,0 +275,0 @@ });

@@ -10,4 +10,4 @@ import Raven from 'raven-js';

autoBreadcrumbs: {
xhr: true, // XMLHttpRequest
console: true, // console logging
xhr: false, // XMLHttpRequest
console: false, // console logging
dom: true, // DOM interactions, i.e. clicks/typing

@@ -14,0 +14,0 @@ location: true, // url changes, including pushState/popState

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

import logger from 'logging';
import StubbornFetch from 'stubborn-fetch';
import type {BrowserNames, BurnItDownResponse} from 'types';

@@ -61,2 +62,3 @@

QuiqSocket.disconnect();
StubbornFetch.disable();

@@ -63,0 +65,0 @@ if (_onBurn) _onBurn();

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 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

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