Giter VIP home page Giter VIP logo

nodejs-haveibeenpwned's Introduction

haveibeenpwned

API methods for Have I been pwned (unofficial)

npm Build Status Coverage Status

Example

const hibp = require ('haveibeenpwned') ();

hibp.breachedAccount ('[email protected]', (err, data) => {
  if (err) {
    return console.log (err);
  }

  console.log (data);
});

Installation

npm i haveibeenpwned

Configuration

name type required default description
timeout number no 5000 Request wait timeout in ms
const pwned = require ('haveibeenpwned') ({
  timeout: 10000
});

Have I Been Pwned

Below are the methods for the main Have I Been Pwned API.

For simplicity no error handling is included in the callback examples. It's straightforward: when there is a problem err is an instance of Error and data is undefined, otherwise err is null and data is set to the result.

.breachedAccount

( account, [params], callback )

All breaches for an account.

argument type required description
account string yes Email or username to check
params object no Additional parameters to include
callback function yes function (err, data) {}
hibp.breachedAccount ('[email protected]', yourCallback);

Example output

.breaches

( [params], callback )

All breaches in the system.

argument type required description
params object no Additional parameters to include
callback function yes function (err, data) {}
hibp.breaches (yourCallback);

Example output

.breach

( name, [params], callback )

A single breached site.

argument type required description
name string yes Site name to check, i.e. linkedin
params object no Additional parameters to include
callback function yes function (err, data) {}
hibp.breach ('Adobe', yourCallback);

Example output

.pasteAccount

( account, callback )

All pastes for an account.

argument type required description
account string yes Email or username to check
callback function yes function (err, data) {}
hibp.pasteAccount ('[email protected]', yourCallback);

Example output

.dataclasses

( callback )

All pastes for an account.

argument type required description
callback function yes function (err, data) {}
hibp.dataclasses (yourCallback);

Example output

Pwned Passwords

Below are the methods for the Pwned Passwords API.

.pwnedpasswords.byPassword

( password, [hashed], callback )

Check if a password was leaked. The data is 0 (int) when none were found.

argument type default description
password string The password to check
hashed bool false Is the password already SHA-1 hashed
callback function (err, data)
hibp.pwnedpasswords.byPassword ('secret', (err, count) => {
  if (!count) {
    console.log ('Great! Password is not found.');
  } else {
    console.log ('Oops! Password was found ' + count + ' times!');
  }
});

// -> Oops! Password was found 195263 times!

.pwnedpasswords.byRange

( hash, [sort], callback )

Get password hashes similar to the first 5 characters of the SHA-1 hash provided. The callback data is an object where the keys are the lowercase hashes and the values are the number of times they were used. When nothing is found data is 0 (int).

A hash longer then 5 characters is truncated before being sent to the API and can be in uppercase or lowercase.

argument type default description
hash string The SHA-1 hash to check
sort bool false Sort by counts in descending order
callback function (err, data)

Sorted by key (default)

hibp.pwnedpasswords.byRange ('abcdef', (err, data) => {
  for (sha in data) {
    console.log ('%s  %i x', sha, data[sha]);
  }
});

Sorted by use counts

hibp.pwnedpasswords.byRange ('abcdef', true, (err, data) => {
  const count = Object.keys (data).length;
  let i = 1;

  console.log ('Found %i matches', count);
  console.log ('Top 3:');

  for (sha in data) {
    console.log ('%i  %s  %i x', i, sha, data[sha]);

    // stop after 3
    if (i === 3) { break; }
    i++;
  }
});

// ->
// Found 511 matches
// Top 3:
// 1  3b8a55c2b3bf42b83e41f0f95a4149043f6  336 x
// 2  6a7fc410810db77855d9dfe5b94b95196f7  304 x
// 3  73a1a21a7b13b50536df19fd586abdf3145  193 x

Unicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org

Author

Franklin | Buy me a coffee

nodejs-haveibeenpwned's People

Contributors

0xflotus avatar fvdm avatar greenkeeper[bot] avatar greenkeeperio-bot avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nodejs-haveibeenpwned's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

An in-range update of dotest is breaking the build 🚨

Version 2.4.0 of dotest was just published.

Branch Build failing 🚨
Dependency dotest
Current Version 2.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

dotest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • coverage/coveralls: First build on greenkeeper/dotest-2.4.0 at 99.502% (Details).

Commits

The new version differs by 13 commits.

  • ca2400a 2.4.0
  • 7c7a599 Docs(changelog): Update changelog
  • f1f9c87 Feat(main): Added .isClass check
  • 897b271 Feat(main): Added .isInstanceOf check
  • dbdf504 Chore(runner): Removed nsp
  • d220c70 Chore(package): Removed nsp
  • b3ac972 Chore(package): Update dependencies
  • 02e3755 Docs(badges): Removed bitHound
  • 38a5ce6 Test(config): bitHound is gone
  • 7ca110a Test(config): Replaced node v9 with v10
  • 181058f Chore(package): Update dependencies
  • ecc4be5 Style(example): Modernized code style
  • 0f1eee3 Refactor(run): Change Module to Package

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

You have been blocked from accessing this resource on Have I Been Pwned

Hi, i try to run this library but i have the following error in the callback

<title>Request Blocked</title>\r\n \r\n \r\n\r\n\r\n

You have been blocked from accessing this resource on Have I Been Pwned

\r\n\r\n

This may be due to violating one or more of the acceptable use terms of the API or for not complying with the API specifications. It may also be due to your traffic patterns being similar to other users who may have violated the acceptable use terms.

\r\n\r\n

Tips to avoid requests being blocked include:

\r\n
    \r\n
  1. Stick well within the published rate limit
  2. \r\n
  3. Don't distribute requests over multiple IP addresses in an attempt to circumvent the rate limit
  4. \r\n
  5. Only query the email addresses of people who have a reasonable expectation that you should do so
  6. \r\n
  7. Avoid prolonged querying of the API over an extended period of time
  8. \r\n
  9. Clearly identify your app in the user agent string per the API docs
  10. \r\n
  11. If you reach out to ask for help after seeing this message and need to be directed to the previous point, you agree to make a donation
  12. \r\n
\r\n

If you believe your request meets these requirements and was still blocked, please send this entire response body along with any communication you send regarding the error.

\r\n
\n

Access denied

\n

This website is using a security service to protect itself from online attacks.

\n
    \n
  • Ray ID: 4d69586dad60b91d
  • \n
  • Timestamp: 2019-05-14 02:12:07 UTC
  • \n
  • Your IP address: 190.148.45.242
  • \n
  • Requested URL: haveibeenpwned.com/api/v2/breachedaccount/[email protected]?
  • \n
  • Error reference number: 1020
  • \n
  • Server ID: FL_17F130
  • \n
  • User-Agent: nodejs-haveibeenpwned (https://github.com/fvdm/nodejs-haveibeenpwned)
  • \n
\n
\n\r\n\r\n

An in-range update of dotest is breaking the build 🚨

Version 2.1.0 of dotest was just published.

Branch Build failing 🚨
Dependency dotest
Current Version 2.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

dotest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • bitHound - Code No failing files. Details
  • bitHound - Dependencies No failing dependencies. Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
  • coverage/coveralls First build on greenkeeper/dotest-2.1.0 at 100.0% Details

Commits

The new version differs by 6 commits.

  • 3b70113 2.1.0
  • ad673a7 Docs(changelog): update changelog
  • 0dceea5 Refactor: Revert devdeps to dotest
  • d7267d8 Chore(package): Update dependencies to enable Greenkeeper (#23)
  • 67bd924 Test(config): Update Travis CI node versions
  • b6489bb Docs(readme): Replaced coffee link with a button

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.