npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ip-reputation-js-client

v6.0.4

Published

A node.js client library to the IP reputation service/iprepd

Downloads

3,142

Readme

iprepd (IP Reputation Service) node.js client library

Client library to send object reputations to the iprepd service.

npm version Coverage Status CircleCI

Overview

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.

Usage

Functions

Create a client:

const IPReputationClient = require('ip-reputation-service-client-js')

const client = new IPReputationClient({
    serviceUrl: 'http://<iprepd service host without trailing slash>',
    id: '<a hawk ID>',
    key: '<a hawk key>',
    timeout: <number in ms>
})

Get the reputation for an IP:

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:

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:

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:

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:

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:

client.update('127.0.0.1', 79).then(function (response) {
    console.log('Set reputation for 127.0.0.1 to 79.');
});

Remove an IP:

client.remove('127.0.0.1').then(function (response) {
    console.log('Removed reputation for 127.0.0.1.');
});

Send a violation for an IP:

client.sendViolation('127.0.0.1', 'exceeded-password-reset-failure-rate-limit').then(function (response) {
    console.log('Applied violation to 127.0.0.1.');
});

Development

Tests run against the iprepd service with docker-compose from the ip-reputation-js-client repo root:

  1. Install docker and docker-compose
  2. Run docker-compose build.
  3. Run docker-compose run --rm test npm install to collect package dependencies.
  4. Run docker-compose run --rm test to test.
  5. Open coverage/lcov-report/index.html to see the coverage report
  6. Run docker-compose down when you are finished running tests to remove cache and web containers.