![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
A simple network request helper that is geared towards crawling. (a few keywords GZIP, XML, JSON, PROXIES)
$ npm install requester
var Requester = require('requester'),
requester = new Requester({debug: 1});
requester.get(/* URL */, function (body) {
console.log(this.statusCode, body);
});
requester.get(/* URL */, /* REQUEST_OBJECT */, function (body) {
console.log(this.statusCode, body);
});
you can even use this simple request translation tool
var Requester = ('requester');
var requester = new Requester({
cookiejar: true, // basic cookie support, currently doesnt care about domain or path rules
cookies: {},
headers: {},
timeout: 4000,
retries: 3,
encoding 'utf8',
// didRequestFail: null, (this has its own section)
// signRequest: null, (this has its own section)
// processResponse: null, (this has its own section)
dataType: 'RAW' // JSON or XML,
auth: {username: 'username', password: 'password'}, // basic auth for all requests
proxies: [{ip: '127.0.0.1', port: 1337}, {ip: '127.0.0.2', port: 1337}, {ip: '127.0.0.3', port: 1337}] // rotating proxy array
});
if you initialize the request object with any of the above properties every request will default to those settings, you can over ride them on a per request basis
var options = {
encoding: 'binary',
proxy: {ip: '127.0.0.1', port: 1337},
data: {foo: 'bar'},
cookies: {foo: 'bar'},
auth: {username: 'username', password: 'password'} // basic auth for request
};
requester.get(/* URL */, options, function (body) {
console.log(body)
});
they support the following properties
you can set debug to the following
request objects support proxies but you also can add / remove them from the proxy rotation like this
var requester = new Requester({
proxies: [{ip: 127.0.0.1, port: 1337}]
});
requester.addProxies({ip: 127.0.0.1, port: 1337}, {ip: 127.0.0.2, port: 1337}, {ip: 127.0.0.1, port: 1337, auth: {username: 'foo', password: 'bar'}});
requester.removeProxies({ip: 127.0.0.1, port: 1337});
this allows you to do custom checking outside of requester to maintain the proxy list
this is a method that gets ran before the actual response callback gets run to ensure that the content is what you're expecting, for example if the content rotates and you're looking for something special you can do
requester.get(
/ * URL */,
{
didRequestFail: function (data) {
return !data.match(/something/);
},
retries: 10
},
function (data) {
console.log(data);
}
);
this would request the url until it matches the string 'something' in the response (up to 10 attempts)
lets say the server responds back with invalid JSON
var json = {foo: 'bar'}
you can use a processResponse function to clean it up like this
requester.get(
/* URL */,
{
dataType: 'JSON',
processResponse: function (body) {
return body.replace(/^var json = /, '');
}
},
function (body) {
console.log(body);
}
);
this is really useful if you want to not repeat response cleanup code
you can create a custom request signature function like this
var qs = require('querystring');
var requester = new Requester({
signRequest: function (data) {
// do something with the data
return qs.stringify(data);
}
});
requester.post(/* URL */, {data: {foo: 'bar', bar: 'foo'}}, function (body) {
console.log(body)
});
the multipart request works a little different, in the data object you can prefix a values key with '@' like this
requester.multipart(/* URL */, {data: {'@file': /* FILEPATH */, '@file2': /* FILEPATH */, bar: 'foo'}}, function (body) {
console.log(body)
});
this will create a multipart request and upload files
FAQs
swiss army knife for requests
The npm package requester receives a total of 144 weekly downloads. As such, requester popularity was classified as not popular.
We found that requester 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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.