Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@aofl/api-request
Advanced tools
A module for making api calls easier. Key features include caching responses and request/response formatters.
Caching is implemented using @aofl/cache-manager and uses MemoryCache. @aofl/api-request caches the promises created by fetch api.
Request/response formatting refers to constructing a request payload and parsing the response payload. A formatter object should implement pack()
and unpack()
properties. pack()
is to construct the request payload and unpack()
is used to parse the response. Any number of formatters can be added to apiRequestInstance
using the addFromatter()
method. E.g. GetFormatter
, PostFormatter
, CorsFormatter
, FileUploadFormatter
, GoogleMapsFormatter
, ....
npm i -S @aofl/api-request
import {ApiRequest} from '@aofl/api-request';
class PostFormatter {
static pack(payload) {
const headers = new Headers();
const body = new FormData();
if (typeof payload !== 'undefined') {
body.append('arguments', JSON.stringify(payload));
}
return {
method: 'POST',
headers,
body,
mode: 'cors',
credentials: 'include'
};
}
static unpack(response) {
return response.json()
.then((data) => {
if (data.status !== 'success') {
return Promise.reject(data);
}
return data;
});
}
}
const apiRequestInstance = new ApiRequest();
apiRequestInstance.addFormatter('post', PostFormatter);
apiRequestInstance.request('https://example.org/', {}, 'post', true, 'sample-namespace')
.then((jsonResponse) => {
})
.catch((jsonResponse) => {
});
FAQs
A module for simplifying api calls
The npm package @aofl/api-request receives a total of 101 weekly downloads. As such, @aofl/api-request popularity was classified as not popular.
We found that @aofl/api-request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.