Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ackee-http-client
Advanced tools
The HTTP client uses [axios](https://github.com/axios/axios) for making all HTTP requests and [ackee-redux-token-auth](https://www.npmjs.com/package/ackee-redux-token-auth) for setting a access token to HTTP Authorization header.
The HTTP client uses axios for making all HTTP requests and ackee-redux-token-auth for setting a access token to HTTP Authorization header.
Using yarn:
$ yarn add ackee-http-client
Using npm:
$ npm install ackee-http-client
Initialization is a simple 2 steps process.
By creating new instance of HttpClient
, you will get api
and authApi
objects. Then you will launch a httpClient
's saga. That's all.
httpClient
instanceCreate one httpClient
instance object per project.
import { create } from 'ackee-http-client';
const httpClient = create({
baseURL: 'https://base-url.com/api/',
});
export const api = httpClient.api;
export const authApi = httpClient.api;
import { saga as httpClient } from 'ackee-http-client';
export default function*() {
yield all([httpClient()]);
}
api
- unauthorized requestsSee available properties of the api
object.
import { api } from 'Config/http-client';
async function fetchTodo(todoId) {
const response = await api.get(`/todos/${todoId}`, {
// overwrite the default baseURL
baseURL: 'https://jsonplaceholder.typicode.com/',
});
return response.data;
}
authApi
- authorized requestsBy using methods under authApi
object, it's guarantee that each HTTP request is going to have access token in its Authorization
header.
See available properties of the authApi
object.
import { authApi } from 'Config/http-client';
async function fetchPost(postId) {
const response = await authApi.get(`/posts/${postId}`);
return response.data;
}
create(axiosRequestConfig: Object, customConfig: Object) => httpClient:Object
This method receives two objects as arguments.
axiosRequestConfig
The axiosRequestConfig
is reserved for axios default request configuration, see available options.
customConfig
The customConfig
object offers following default options:
{
// If `managaAuthHeader` is true, then when access token state changes,
// the `setAuthHeader` is triggered.
// If it's false, `setAuthHeader` won't be ever triggered.
managaAuthHeader: true,
// If `managaAuthHeader` is enabled, `setAuthHeader` receives object with default headers,
// when access token state changes.
/**
* @param {Object} headers - reference to axios default request headers object (https://github.com/axios/axios#custom-instance-defaults)
* @param {String|null} accessToken
*/
setAuthHeader(headers, accessToken) {
if (accessToken) {
// `common` indicates that it's a default header for all HTTP methods
headers.common.Authorization = `Bearer ${accessToken}`;
} else {
delete headers.common.Authorization;
}
}
}
The httpClient
object contains two axios instances: api
and authApi
with the same properties:
api.request(config)
api.get(url[, config])
api.delete(url[, config])
api.head(url[, config])
api.options(url[, config])
api.post(url[, data[, config]])
api.put(url[, data[, config]])
api.patch(url[, data[, config]])
api.getUri([config])
api.defaults
api.interceptors
import { create } from 'ackee-http-client';
const { authApi } = create(
{
baseURL: 'https://jsonplaceholder.typicode.com/',
},
{
// Customize setting of the authorization header
// by providing a custom setAuthHeader method:
setAuthHeader(headers, accessToken) {
if (accessToken) {
headers.common.Authorization = accessToken;
} else {
delete headers.common.Authorization;
}
},
},
);
async function fetchTodo() {
const response = await authApi.get('/todos/1');
return response.data;
}
saga(void) => ReduxSaga
Initializes the saga handlers generator. This should be passed along with your other sagas.
import { all } from 'redux-saga/effects';
import { saga as httpClient } from 'ackee-http-client';
export default function*() {
yield all([httpClient()]);
}
Custom Saga effects with built-in cancelation of API requests, see the docs.
FAQs
> # IMPORTANT > > `ackee-http-client` was renamed to [`@ackee/antonio`](https://www.npmjs.com/package/@ackee/antonio). The repository is available on [Github](https://github.com/AckeeCZ/antonio).
The npm package ackee-http-client receives a total of 6 weekly downloads. As such, ackee-http-client popularity was classified as not popular.
We found that ackee-http-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.