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

redux-token-api-middleware

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-token-api-middleware - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1-alpha

21

lib/index.js

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

exports.shouldRequestNewToken = shouldRequestNewToken;
exports.createResponseHandlerWithMeta = createResponseHandlerWithMeta;
exports.createApiAction = createApiAction;

@@ -41,2 +42,6 @@ exports.actionAsPromise = actionAsPromise;

var _lodash7 = _interopRequireDefault(require("lodash.curryright"));
var _lodash8 = _interopRequireDefault(require("lodash.identity"));
var _jwtDecode = _interopRequireDefault(require("jwt-decode"));

@@ -191,2 +196,12 @@

function createResponseHandlerWithMeta(meta) {
var baseHandler = meta.responseHandler || _lodash8.default;
var handlerToCurry = function handlerToCurry(response, meta) {
return baseHandler(response, meta);
};
return (0, _lodash7.default)(handlerToCurry)(meta);
}
var TokenApiService =

@@ -281,3 +296,3 @@ /*#__PURE__*/

var preserveHeaderValues = this.preserveHeaderValues.bind(this, this.meta);
return _crossFetch.default.apply(this, fetchArgs).then(this.checkResponseIsOk).then(preserveHeaderValues).then(responseToCompletion).then(meta.responseHandler).then(completeApiRequest).catch(catchApiRequestError);
return _crossFetch.default.apply(this, fetchArgs).then(this.checkResponseIsOk).then(preserveHeaderValues).then(responseToCompletion).then(createResponseHandlerWithMeta(meta)).then(completeApiRequest).catch(catchApiRequestError);
}

@@ -314,3 +329,3 @@ }, {

this.dispatch(createStartAction(action.type, action.payload));
return Promise.all(promises).then(meta.responseHandler).then(completeApiRequest).catch(catchApiRequestError);
return Promise.all(promises).then(createResponseHandlerWithMeta(meta)).then(completeApiRequest).catch(catchApiRequestError);
}

@@ -486,3 +501,3 @@ }, {

refreshArgs = this.getApiFetchArgsFromActionPayload(refreshApiAction.payload, token, refreshApiActionMeta.authenticate);
return _context3.abrupt("return", _crossFetch.default.apply(null, refreshArgs).then(this.checkResponseIsOk).then(responseToCompletion).then(refreshApiActionMeta.responseHandler).then(this.curriedApiCallMethod).catch(function (error) {
return _context3.abrupt("return", _crossFetch.default.apply(null, refreshArgs).then(this.checkResponseIsOk).then(responseToCompletion).then(createResponseHandlerWithMeta(refreshApiActionMeta)).then(this.curriedApiCallMethod).catch(function (error) {
_this2.dispatch(createFailureAction(_this2.apiAction.type, error));

@@ -489,0 +504,0 @@ }));

4

package.json
{
"name": "redux-token-api-middleware",
"version": "0.9.0",
"version": "0.9.1-alpha",
"description": "Redux middleware for calling APIs with token-based auth",

@@ -32,2 +32,4 @@ "main": "lib/index.js",

"jwt-decode": "^2.2.0",
"lodash.curryright": "^4.1.1",
"lodash.identity": "^3.0.0",
"lodash.isarraylikeobject": "^4.2.0",

@@ -34,0 +36,0 @@ "lodash.isfunction": "^3.0.8",

@@ -7,2 +7,4 @@ import startsWith from 'lodash.startswith';

import omitBy from 'lodash.omitby';
import curryRight from 'lodash.curryright';
import identity from 'lodash.identity';
import jwt_decode from 'jwt-decode';

@@ -115,2 +117,10 @@ import moment from 'moment';

export function createResponseHandlerWithMeta(meta) {
const baseHandler = meta.responseHandler || identity;
const handlerToCurry = (response, meta) => (
baseHandler(response, meta)
);
return curryRight(handlerToCurry)(meta);
}
export class TokenApiService {

@@ -211,3 +221,3 @@

.then(responseToCompletion)
.then(meta.responseHandler)
.then(createResponseHandlerWithMeta(meta))
.then(completeApiRequest)

@@ -245,3 +255,3 @@ .catch(catchApiRequestError);

return Promise.all(promises)
.then(meta.responseHandler)
.then(createResponseHandlerWithMeta(meta))
.then(completeApiRequest)

@@ -330,3 +340,3 @@ .catch(catchApiRequestError);

.then(responseToCompletion)
.then(refreshApiActionMeta.responseHandler)
.then(createResponseHandlerWithMeta(refreshApiActionMeta))
.then(this.curriedApiCallMethod)

@@ -333,0 +343,0 @@ .catch(error => {

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