Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@sigfox/redux-api-middleware
Advanced tools
Redux middleware handling api calls.
Send api request calling a custom promise.
Depending on the api response, an action will be dispatched containing response data or error.
npm install @sigfox/redux-api-middleware
Provide a http client to the middleware, this client will be given to you in order to build your request.
"type: 'api'" is necessary, otherwise, the action will go directly to the next middleware
"types" must be an array of three elements of format: [request, success, failure], correponding action will be dispatched depending on the status of the api call.
"reject: true" means that in the case of an error, the error will be thrown
const axios = require('axios');
const apiMiddleware = require('@sigfox/redux-api-middleware');
const reducer = (state = {}, action) => {
switch (action.type) {
case 'SUCCESS':
return action;
case 'FAILURE':
return action;
default:
return state;
}
};
// Provide an api client to the middleware
const store = createStore(reducer, applyMiddleware(apiMiddleware(axios.create())));
store.dispatch({
type: 'api',
types: ['REQUEST', 'SUCCESS', 'FAILURE'],
promise: client => client.request({ url: 'http://localhost:3000/data', method: 'get' })
});
// Example using dispatch + getState in the promise.
store.dispatch({
type: 'api',
types: ['REQUEST', 'SUCCESS', 'FAILURE'],
promise: async (client, dispatch, getState) => {
const state = getState();
if (!state.isLoading) {
dispatch({ type: 'START_LOADER' });
}
return client.request({ url: 'http://localhost:3000/data', method: 'get' });
},
// In the case of an error, this option will throw the error instead of just dispatching an action.
reject: true
});
npm test
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Redux API middleware.
We found that @sigfox/redux-api-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.