How to use the hibp.pwnedPassword 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 / pw.ts View on Github external
export const handler = async ({
  password,
  raw,
}: PwHandlerOptions): Promise => {
  if (!raw) {
    spinner.start();
  }

  try {
    const pwnCount = await pwnedPassword(password, { userAgent });
    if (pwnCount) {
      const pwnedMessage = `Oh no — pwned ${pwnCount} times!`;
      if (!raw) {
        spinner.warn(pwnedMessage);
      } else {
        logger.log(pwnedMessage);
      }
    } else {
      const successMessage = 'Good news — no pwnage found!';
      if (!raw) {
        spinner.succeed(successMessage);
      } else {
        logger.log(successMessage);
      }
    }
  } catch (err) {

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