Unofficial javascript client for HaveIBeenPwned API
You can use it as a nodejs module:
npm install --save pwned-api
Or also install it globally and use it as cli tool:
npm install --global pwned-api
Load the pwned-api module into your script than init the class to use its methods. It accept a callback but also return a promise so you can use it also with async.
const Pwned = require('pwned-api');
const pwner = new Pwned();
pwner.breaches({}, (err, results) => {
console.log('Results:', results);
});
Using new await/async functionalities:
import Pwned from 'pwned-api'
const pwner = new Pwned();
(async () => {
const res = await pwner.breaches();
// Do whatever you need to do
})()
The pwner constructor takes two arguments, so you can customize the requests beheviour:
const pwner = new Pwned({
timeout: 2500,
headers: {
'User-Agent': 'My App'
}
});
List all the available breaches
pwner.breaches({}, (err, results) => {
console.log('Results:', results);
});
Return a list of all breaches a particular account has been involved in.
pwner.breachedAccount('john.doe@example.com', {}, (err, results) => {
console.log('Results:', results);
});
Return single breach retrieved by the breach "name".
pwner.breach('AshleyMadison', (err, results) => {
console.log('Results:', results);
});
Return all the data classes in the system.
pwner.dataClasses((err, results) => {
console.log('Results:', results);
});
Return all pastes for an account, takes a single parameter which is the email address to be searched for.
pwner.pasteAccount('john.doe@example.com', (err, results) => {
console.log('Results:', results);
});
Check if a password been exposed in data breaches and exists on HIBP database.
pwner.pwnedPassword('admin1234', {}, (err) => {
console.log('Error;', err );
});
For details in depth about the API please consult the official HaveIBeenPwned page.
MIT © b4dnewz