How to use the hibp.search 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 / api / getSearch.js View on Github external
export default (account, domain, truncate, raw) => {
  if (!raw && process.stdout.isTTY) {
    spinner.start();
  }
  return Promise.resolve(search(account, { domain, truncate }))
    .then((searchData) => {
      const foundData = !!(searchData.breaches || searchData.pastes);
      if (!raw && process.stdout.isTTY) {
        spinner.stop(true);
      }
      if (foundData && raw) {
        logger.log(JSON.stringify(searchData));
      } else if (foundData) {
        logger.log(prettyjson.render(searchData));
      } else if (!foundData && !raw) {
        logger.log('Good news — no pwnage found!');
      }
    })
    .catch((err) => {
      if (!raw && process.stdout.isTTY) {
        spinner.stop(true);
github wKovacs64 / pwned / src / commands / search.ts View on Github external
export const handler = async ({
  account,
  domainFilter: domain,
  truncate,
  raw,
}: SearchHandlerOptions): Promise => {
  if (!raw) {
    spinner.start();
  }

  try {
    const searchData = await search(account, { domain, truncate, userAgent });
    const foundData = !!(searchData.breaches || searchData.pastes);
    if (foundData && raw) {
      logger.log(JSON.stringify(searchData));
    } else if (foundData) {
      spinner.stop();
      logger.log(prettyjson.render(searchData));
    } else if (!foundData && !raw) {
      spinner.succeed('Good news — no pwnage found!');
    }
  } catch (err) {
    if (!raw) {
      spinner.fail(err.message);
    } else {
      logger.error(err.message);
    }
  }

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