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

@qlean/york-core

Package Overview
Dependencies
Maintainers
10
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qlean/york-core - npm Package Compare versions

Comparing version 4.1.1 to 4.4.2

182

lib/fetcher/index.js

@@ -14,2 +14,4 @@ "use strict";

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _utils = require("./utils");

@@ -19,3 +21,3 @@

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

@@ -77,96 +79,116 @@ var isTokenRefreshing = false;

var request = function request(method, url, payload) {
var config,
fetchConfig,
originalRequest,
response,
errorData,
_args2 = arguments;
return _regenerator["default"].async(function request$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
config = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
fetchConfig = _objectSpread({}, config, {
headers: _objectSpread({
'content-type': 'application/json'
}, config.headers),
method: method,
body: payload ? JSON.stringify(requestDataTransformer ? requestDataTransformer(payload) : payload) : null
});
var request =
/*#__PURE__*/
function () {
var _ref4 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(method, url, payload) {
var config,
fetchConfig,
originalRequest,
response,
errorData,
_args2 = arguments;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
config = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
fetchConfig = _objectSpread({}, config, {
headers: _objectSpread({
'content-type': 'application/json'
}, config.headers),
method: method,
body: payload ? JSON.stringify(requestDataTransformer ? requestDataTransformer(payload) : payload) : null
});
originalRequest = function originalRequest(token) {
return fetch("".concat(baseUrl).concat(url), _objectSpread({}, fetchConfig, {
headers: _objectSpread({}, token ? {
Authorization: token
} : {}, {}, fetchConfig.headers)
}));
};
originalRequest = function originalRequest(token) {
return fetch("".concat(baseUrl).concat(url), _objectSpread({}, fetchConfig, {
headers: _objectSpread({}, token ? {
Authorization: token
} : {}, {}, fetchConfig.headers)
}));
};
if (!isTokenRefreshing) {
_context2.next = 5;
break;
}
if (!isTokenRefreshing) {
_context2.next = 5;
break;
}
return _context2.abrupt("return", pushToFailedRequests(originalRequest));
return _context2.abrupt("return", pushToFailedRequests(originalRequest));
case 5:
_context2.next = 7;
return _regenerator["default"].awrap(originalRequest(originalAccessToken).then(function (res) {
if (res.status === 419) {
if (isTokenRefreshing) return pushToFailedRequests(originalRequest);
isTokenRefreshing = true;
return getNewAccessToken(originalRefreshToken).then(function _callee(_ref4) {
var accessToken, newResponse;
return _regenerator["default"].async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
accessToken = _ref4.accessToken;
_context.next = 3;
return _regenerator["default"].awrap(originalRequest(accessToken));
case 5:
_context2.next = 7;
return originalRequest(originalAccessToken).then(function (res) {
if (res.status === 419) {
if (isTokenRefreshing) return pushToFailedRequests(originalRequest);
isTokenRefreshing = true;
return getNewAccessToken(originalRefreshToken).then(
/*#__PURE__*/
function () {
var _ref6 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref5) {
var accessToken, newResponse;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
accessToken = _ref5.accessToken;
_context.next = 3;
return originalRequest(accessToken);
case 3:
newResponse = _context.sent;
processQueue(null, accessToken);
return _context.abrupt("return", newResponse);
case 3:
newResponse = _context.sent;
processQueue(null, accessToken);
return _context.abrupt("return", newResponse);
case 6:
case "end":
return _context.stop();
}
}
});
});
}
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return res;
}));
return function (_x4) {
return _ref6.apply(this, arguments);
};
}());
}
case 7:
response = _context2.sent;
return res;
});
if (!response.ok) {
_context2.next = 10;
break;
}
case 7:
response = _context2.sent;
return _context2.abrupt("return", (0, _utils.getResponseBody)(response, responseDataTransformer));
if (!response.ok) {
_context2.next = 10;
break;
}
case 10:
_context2.next = 12;
return _regenerator["default"].awrap((0, _utils.getResponseBody)(response, responseDataTransformer));
return _context2.abrupt("return", (0, _utils.getResponseBody)(response, responseDataTransformer));
case 12:
errorData = _context2.sent;
throw new _utils.NetworkError(response, errorData);
case 10:
_context2.next = 12;
return (0, _utils.getResponseBody)(response, responseDataTransformer);
case 14:
case "end":
return _context2.stop();
case 12:
errorData = _context2.sent;
throw new _utils.NetworkError(response, errorData);
case 14:
case "end":
return _context2.stop();
}
}
}
});
};
}, _callee2);
}));
return function request(_x, _x2, _x3) {
return _ref4.apply(this, arguments);
};
}();
return {

@@ -173,0 +195,0 @@ get: function get(url, config) {

@@ -13,2 +13,4 @@ "use strict";

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
function NetworkError() {

@@ -34,33 +36,43 @@ var response = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var getResponseBody = function getResponseBody(response, responseDataTransformer) {
var contentType, json;
return _regenerator["default"].async(function getResponseBody$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
contentType = response.headers.get('content-type') || '';
var getResponseBody =
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(response, responseDataTransformer) {
var contentType, json;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
contentType = response.headers.get('content-type') || '';
if (!contentType.includes('application/json')) {
_context.next = 6;
break;
}
if (!contentType.includes('application/json')) {
_context.next = 6;
break;
}
_context.next = 4;
return _regenerator["default"].awrap(response.json());
_context.next = 4;
return response.json();
case 4:
json = _context.sent;
return _context.abrupt("return", responseDataTransformer ? responseDataTransformer(json) : json);
case 4:
json = _context.sent;
return _context.abrupt("return", responseDataTransformer ? responseDataTransformer(json) : json);
case 6:
return _context.abrupt("return", response.text());
case 6:
return _context.abrupt("return", response.text());
case 7:
case "end":
return _context.stop();
case 7:
case "end":
return _context.stop();
}
}
}
});
};
}, _callee);
}));
return function getResponseBody(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
exports.getResponseBody = getResponseBody;

@@ -67,0 +79,0 @@

{
"name": "@qlean/york-core",
"version": "4.1.1",
"version": "4.4.2",
"description": "",

@@ -14,4 +14,3 @@ "license": "MIT",

"build": "npm run clean && babel src -d lib --ignore test.js",
"clean": "rimraf coverage lib",
"lint": "eslint . --ext .js"
"clean": "rimraf coverage lib"
},

@@ -21,3 +20,3 @@ "peerDependencies": {

},
"gitHead": "9b5416063af045e24d5fa295f744d9d10b682612"
"gitHead": "ed08396c605605c94a88c3bc6f0b76f223b180b2"
}
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