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

react-isomorphic-tools

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-isomorphic-tools - npm Package Compare versions

Comparing version 1.3.8 to 1.4.0

104

lib/Fetcher.js

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

var headers_data, body, i, query, name, values, value, headers, data, error, refreshToken, refresh, response, token, _refreshToken, _data, _response, _data2, _data3, _response2;
var headers_data, body, normalizeParams, i, query, name, values, value, headers, data, error, refreshToken, refresh, response, token, _refreshToken, _data, _response, _data2, _data3, _response2;

@@ -63,2 +63,6 @@ return _regenerator2.default.wrap(function _callee$(_context) {

normalizeParams = function normalizeParams(data) {
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) == 'object') return (0, _stringify2.default)(data);
return data;
};

@@ -76,3 +80,3 @@ if (method == 'GET' || method == 'DELETE') {

if (values.hasOwnProperty(value)) {
query += '' + (i > 0 ? '&' : '?') + name + '=' + values[value];
query += '' + (i > 0 ? '&' : '?') + name + '=' + normalizeParams(values[value]);
i++;

@@ -82,3 +86,3 @@ }

} else if ((0, _typeof3.default)(params[name] == 'number' || typeof params[name] == 'string')) {
query += '' + (i > 0 ? '&' : '?') + name + '=' + params[name];
query += '' + (i > 0 ? '&' : '?') + name + '=' + normalizeParams(params[name]);
i++;

@@ -93,10 +97,10 @@ }

_context.t0 = type;
_context.next = _context.t0 === 'form-data' ? 6 : 8;
_context.next = _context.t0 === 'form-data' ? 7 : 9;
break;
case 6:
case 7:
body = params;
return _context.abrupt('break', 10);
return _context.abrupt('break', 11);
case 8:
case 9:
headers_data = {

@@ -108,3 +112,3 @@ 'Accept': 'application/json',

case 10:
case 11:
headers = new Headers(headers_data);

@@ -117,22 +121,22 @@

_context.prev = 12;
_context.next = 15;
_context.prev = 13;
_context.next = 16;
return fetch('' + baseUrl + url, { method: method, headers: headers, body: body, mode: 'cors' });
case 15:
case 16:
data = _context.sent;
if (!(data.status >= 400)) {
_context.next = 67;
_context.next = 68;
break;
}
_context.next = 19;
_context.next = 20;
return data.json();
case 19:
case 20:
error = _context.sent;
if (!(data.status == 401 && (0, _Auth.isAuthenticated)())) {
_context.next = 66;
_context.next = 67;
break;

@@ -144,7 +148,7 @@ }

if (!refreshToken) {
_context.next = 55;
_context.next = 56;
break;
}
_context.next = 25;
_context.next = 26;
return fetch(baseUrl + '/token/refresh', {

@@ -155,8 +159,8 @@ method: 'POST',

case 25:
case 26:
refresh = _context.sent;
_context.next = 28;
_context.next = 29;
return refresh.json();
case 28:
case 29:
response = _context.sent;

@@ -166,3 +170,3 @@ token = response.token, _refreshToken = response.refreshToken;

if (!(refresh.status == 401)) {
_context.next = 44;
_context.next = 45;
break;

@@ -173,3 +177,3 @@ }

headers.delete('Authorization');
_context.next = 35;
_context.next = 36;
return fetch('' + baseUrl + url, {

@@ -182,12 +186,12 @@ method: method,

case 35:
case 36:
_data = _context.sent;
_context.next = 38;
_context.next = 39;
return _data.json();
case 38:
case 39:
_response = _context.sent;
if (!(_data.status == 401)) {
_context.next = 41;
_context.next = 42;
break;

@@ -198,10 +202,10 @@ }

case 41:
case 42:
return _context.abrupt('return', _response);
case 44:
case 45:
(0, _Auth.setToken)(token);
(0, _Auth.setRefreshToken)(_refreshToken);
headers.set('Authorization', 'Bearer ' + (0, _Auth.getToken)());
_context.next = 49;
_context.next = 50;
return fetch('' + baseUrl + url, {

@@ -214,18 +218,18 @@ method: method,

case 49:
case 50:
_data2 = _context.sent;
_context.next = 52;
_context.next = 53;
return _data2.json();
case 52:
case 53:
return _context.abrupt('return', _context.sent);
case 53:
_context.next = 66;
case 54:
_context.next = 67;
break;
case 55:
case 56:
(0, _Auth.logout)();
headers.delete('Authorization');
_context.next = 59;
_context.next = 60;
return fetch('' + baseUrl + url, {

@@ -238,12 +242,12 @@ method: method,

case 59:
case 60:
_data3 = _context.sent;
_context.next = 62;
_context.next = 63;
return _data3.json();
case 62:
case 63:
_response2 = _context.sent;
if (!(_data3.status == 401)) {
_context.next = 65;
_context.next = 66;
break;

@@ -254,18 +258,18 @@ }

case 65:
case 66:
return _context.abrupt('return', _response2);
case 66:
case 67:
throw error;
case 67:
_context.next = 69;
case 68:
_context.next = 70;
return data.json();
case 69:
case 70:
return _context.abrupt('return', _context.sent);
case 72:
_context.prev = 72;
_context.t1 = _context['catch'](12);
case 73:
_context.prev = 73;
_context.t1 = _context['catch'](13);

@@ -275,3 +279,3 @@ console.warn('apiCall [error] - ' + method + ' ' + baseUrl + url + ' -', _context.t1, '- params ' + params);

case 76:
case 77:
case 'end':

@@ -281,3 +285,3 @@ return _context.stop();

}
}, _callee, undefined, [[12, 72]]);
}, _callee, undefined, [[13, 73]]);
}));

@@ -284,0 +288,0 @@

{
"name": "react-isomorphic-tools",
"version": "1.3.8",
"version": "1.4.0",
"description": "Authorization, Fetcher, Preload. Tools for ServerSide rendering",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -11,2 +11,7 @@ import {getTokenPrefix, isAuthenticated, getToken, getRefreshToken, logout, setToken, setRefreshToken} from './Auth'

const normalizeParams = (data) => {
if(typeof (data) == 'object') return JSON.stringify(data)
return data
}
if (method == 'GET' || method == 'DELETE') {

@@ -21,3 +26,3 @@ let i = 0

if (values.hasOwnProperty(value)) {
query += `${i > 0 ? '&' : '?'}${name}=${values[value]}`
query += `${i > 0 ? '&' : '?'}${name}=${normalizeParams(values[value])}`
i++

@@ -27,3 +32,3 @@ }

} else if (typeof (params[name] == 'number' || typeof (params[name]) == 'string')) {
query += `${i > 0 ? '&' : '?'}${name}=${params[name]}`
query += `${i > 0 ? '&' : '?'}${name}=${normalizeParams(params[name])}`
i++

@@ -30,0 +35,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