How to use the hibp.breach function in hibp

To help you get started, we’ve selected a few hibp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wKovacs64 / hibp / example / runkit.js View on Github external
const hibp = require('hibp');

hibp
  .breach('Adobe')
  .then(data => {
    if (data) {
      // Breach data found
      console.log(data);
    } else {
      console.log('No breach data found by that name.');
    }
  })
  .catch(err => {
    // Something went wrong.
    console.log(err.message);
  });
github wKovacs64 / pwned / src / commands / breach.ts View on Github external
export const handler = async ({
  name,
  raw,
}: BreachHandlerOptions): Promise => {
  if (!raw) {
    spinner.start();
  }

  try {
    const breachData = await breach(name, { userAgent });
    if (breachData && raw) {
      logger.log(JSON.stringify(breachData));
    } else if (breachData) {
      spinner.stop();
      logger.log(prettyjson.render(breachData));
    } else if (!breachData && !raw) {
      spinner.succeed('No breach found by that name.');
    }
  } catch (err) {
    if (!raw) {
      spinner.fail(err.message);
    } else {
      logger.error(err.message);
    }
  }
};
github wKovacs64 / pwned / src / api / getBreach.js View on Github external
export default (name, raw) => {
  if (!raw && process.stdout.isTTY) {
    spinner.start();
  }
  return Promise.resolve(breach(name))
    .then((breachData) => {
      if (!raw && process.stdout.isTTY) {
        spinner.stop(true);
      }
      if (breachData && raw) {
        logger.log(JSON.stringify(breachData));
      } else if (breachData) {
        logger.log(prettyjson.render(breachData));
      } else if (!breachData && !raw) {
        logger.log('No breach found by that name.');
      }
    })
    .catch((err) => {
      if (!raw && process.stdout.isTTY) {
        spinner.stop(true);
      }

hibp

An unofficial TypeScript SDK for the 'Have I been pwned?' service.

MIT
Latest version published 4 months ago

Package Health Score

72 / 100
Full package analysis