Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
hmpo-model
Advanced tools
Simple model for interacting with http/rest apis.
Normally this would be used as an abstract class and extended with your own implementation.
Implementations would normally define at least a url
method to define the target of API calls.
There are three methods for API interaction corresponding to GET, POST, and DELETE http methods:
fetch
var model = new Model();
model.fetch(function (err, data) {
console.log(data);
});
save
var model = new Model();
model.set({
property: 'properties are sent as JSON request body by default'
});
model.save(function (err, data) {
console.log(data);
});
The method can also be overwritten by passing options
var model = new Model();
model.set({
property: 'this will be sent as a PUT request'
});
model.save({ method: 'PUT' }, function (err, data) {
console.log(data);
});
delete
var model = new Model();
model.delete(function (err, data) {
console.log(data);
});
If no url
method is defined then the model will use the options parameter and Node's url.format method to construct a URL.
var model = new Model();
// make a GET request to http://example.com:3000/foo/bar
model.fetch({
protocol: 'http',
hostname: 'example.com',
port: 3000,
path: '/foo/bar'
}, function (err, data) {
console.log(data);
});
API requests will emit events as part of their lifecycle.
sync
is emitted when an API request is sentsuccess
is emitted when an API request successfully completesfail
is emitted when an API request failsAll events are emitted with the response data, the request settings and the response status as arguments. The fail event has an additional error argument.
FAQs
Simple model for interacting with http/rest apis.
The npm package hmpo-model receives a total of 1,042 weekly downloads. As such, hmpo-model popularity was classified as popular.
We found that hmpo-model demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.