Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
api_request
Advanced tools
Simple library for defining API requests asynchronously. Creates readable requests using a fuild chainable interface. Detects the content type and decodes it accordingy (currently available for application/json and application/x-www-form-urlencoded). Also, if one specifies the content type, a JS object may be passed in and it will be converted to the proper format by the proper content encoder.
At your command prompt type:
npm install api_request
Just include the library and start building requests:
var api_request = require('api_request');
var r = new api_request('http', 'themarg.in');
r.get('/').on('reply', function(reply, res) {
console.log(reply);
});
Also, you could make a request over SSL with basic authentication:
var r = new api_request('https', 'auth.themarg.in');
r.with_basic_auth('ada', '4d4').
get('/index.php').on('reply', function(reply, res) {
console.log(reply.greeting);
});
Or, you could post a JSON object over HTTPS with basic authentication:
var r = new api_request('https', 'auth.themarg.in');
r.with_content_type('application/json').
with_basic_auth('ada', '4d4').
with_payload({'greeting': 'hi'}).
post('/index.php').on('reply', function(reply, res) {
console.log(reply.greeting);
});
Currently the only supported protocols are http or https. If someone wrote a module for another protocol that could be used as well, since it loads the module via a require statement.
It supports the four basic http verbs: 'GET', 'POST'. 'PUT', 'DELETE'.
Headers can be set like so:
var r = new api_request('http', 'themarg.in');
r.add_headers({'X-Orginating-IP': '192.168.5.3'}).
get('/index.php').on('reply', function(reply, res) {
console.log(reply);
});
Multiple headers can be set at once.
If the API you use this with requests or replies with a different format from x-www-form-urlencoded or json, the library can be extended by providing a content encoder or content handler object. It's quite simple, actually:
var r = new api_request('https', 'auth.themarg.in');
r.add_content_handlers({
'appplication/rss+xml': function(data) {
return decoded_data;
}
});
To send a different encoding, it goes like this:
var r = new api_request('https', 'auth.themarg.in');
r.add_content_encoders({
'appplication/rss+xml': function(data) {
return encoded_data;
}
});
More than one type of encoder or handler can be added at a time.
FAQs
Wrapper for the http client to make beautiful, readable requests.
The npm package api_request receives a total of 6 weekly downloads. As such, api_request popularity was classified as not popular.
We found that api_request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.