How to use the hibp.breachedAccount 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 / pwned / src / commands / ba.ts View on Github external
export const handler = async ({
  account,
  domainFilter: domain,
  includeUnverified,
  truncate,
  raw,
}: BaHandlerOptions): Promise => {
  if (!raw) {
    spinner.start();
  }

  try {
    const breachData = await breachedAccount(account.trim(), {
      domain,
      includeUnverified,
      truncate,
      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('Good news — no pwnage found!');
    }
  } catch (err) {
    if (!raw) {
      spinner.fail(err.message);
github wKovacs64 / pwned / src / api / getBreachedAccount.js View on Github external
export default (account, domain, truncate, raw) => {
  if (!raw && process.stdout.isTTY) {
    spinner.start();
  }
  return Promise.resolve(breachedAccount(account, { domain, truncate }))
    .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('Good news — no pwnage found!');
      }
    })
    .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 5 months ago

Package Health Score

74 / 100
Full package analysis