A node.js client library to the IP reputation service/iprepd
npm install ip-reputation-js-clientClient library to send object reputations to the iprepd service.
  
iprepd is a service that supports storing and retrieving reputations associated with various object
types, the most common being IP addresses but including others such as account names and email
addresses. This library can be used by Node applications to integrate directly with this API.
#### Functions
Create a client:
``js
const IPReputationClient = require('ip-reputation-service-client-js')
const client = new IPReputationClient({
serviceUrl: 'http://
id: '',
key: '',
timeout:
})
`
Get the reputation for an IP:
`js`
client.getTyped('ip', '127.0.0.1').then(function (response) {
if (response && response.statusCode === 404) {
console.log('No reputation found for 127.0.0.1');
} else {
console.log('127.0.0.1 has reputation: ', response.body.reputation);
}
});
Set the reputation for an IP:
`js`
client.updateTyped('ip', '127.0.0.1', 79).then(function (response) {
console.log('Set reputation for 127.0.0.1 to 79.');
});
Remove an IP:
`js`
client.removeTyped('ip', '127.0.0.1').then(function (response) {
console.log('Removed reputation for 127.0.0.1.');
});
Send a violation for an IP:
`js`
client.sendViolationTyped('ip', '127.0.0.1', 'exceeded-password-reset-failure-rate-limit').then(function (response) {
console.log('Applied violation to 127.0.0.1.');
});
#### Legacy functions
Previous versions of iprepd only supported IP addresses; these functions remain as a compatibility
layer for applications that still make use of them, and are essentially wrappers around the typed
function calls.
Get the reputation for an IP:
`js`
client.get('127.0.0.1').then(function (response) {
if (response && response.statusCode === 404) {
console.log('No reputation found for 127.0.0.1');
} else {
console.log('127.0.0.1 has reputation: ', response.body.reputation);
}
});
Set the reputation for an IP:
`js`
client.update('127.0.0.1', 79).then(function (response) {
console.log('Set reputation for 127.0.0.1 to 79.');
});
Remove an IP:
`js`
client.remove('127.0.0.1').then(function (response) {
console.log('Removed reputation for 127.0.0.1.');
});
Send a violation for an IP:
`js`
client.sendViolation('127.0.0.1', 'exceeded-password-reset-failure-rate-limit').then(function (response) {
console.log('Applied violation to 127.0.0.1.');
});
Tests run against the iprepd service with docker-compose from the ip-reputation-js-client repo root:
1. Install docker and docker-compose
1. Run docker-compose build.docker-compose run --rm test npm install
1. Run to collect package dependencies.docker-compose run --rm test
1. Run to test.coverage/lcov-report/index.html
1. Open to see the coverage reportdocker-compose down` when you are finished running tests to remove cache and web containers.
1. Run