Code Monkey home page Code Monkey logo

password-leak's Introduction

password-leak

Version Downloads Standardjs PRs Welcome GitHub license

Build Status Known Vulnerabilities

Also check out the password-leak-monitor browser extension!



Introduction

password-leak is a JavaScript module that can be used to determine if a password is compromised by checking with the Have I Been Pwned API.

How is this safe?

Your passwords are NEVER transmitted to any other system. This library makes use of the Have I Been Pwned API, which implements a k-Anonymity Model so your password can be checked without ever having to give it to any other party.

Installation

npm install @mathiscode/password-leak

Usage in Browser

<script src="https://cdn.jsdelivr.net/npm/@mathiscode/password-leak@latest"></script>

<script>
  isPasswordCompromised('myPassword').then(isCompromised => {
    console.log('Is compromised?', isCompromised)
  })
</script>

Usage in Node.js

With import/await

import isPasswordCompromised from '@mathiscode/password-leak'

const isCompromised = await isPasswordCompromised('myPassword')
console.log('Is compromised?', isCompromised)

With require/promises

const isPasswordCompromised = require('@mathiscode/password-leak').default

isPasswordCompromised('myPassword').then(isCompromised => {
  console.log('Is compromised?', isCompromised)
})

Usage in Command Line

Install globally, or use npx @mathiscode/password-leak

npm install -g @mathiscode/password-leak

You can then run password-leak to interactively enter the masked password, or provide the password as an argument, eg. password-leak myPassword

The exit status will be 0 (not compromised) or 1 (compromised).

password-leak's People

Contributors

dependabot[bot] avatar mathiscode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

password-leak's Issues

Don't use babel shims... (138kb payload on jsdelivr)

Most modern browsers support async, and have fetch. It would be better to convert to commonjs imports, without the use of corejs, regenerator, axios, and crypto. The bundle size is likely really huge here.

For the sha1, can use https://www.npmjs.com/package/sha1 since Edge doesn't support SHA1 via SubtleCrypto.

For IE: would need to shim/polyfill Promises, and Fetch

const sha1 = require('sha1');

module.exports = function(password) {
  if (!password || password === '') throw new Error('You must provide a password')
  if (typeof Promise === 'undefined') throw new Error('Missing Promise');
  if (typeof fetch === 'undefined') throw new Error('Missing fetch');

  var digest = sha1(password)
  var firstFive = digest.substr(0, 5)

  return fetch(`https://api.pwnedpasswords.com/range/${firstFive}`)
    .then(function(r) { return r.text() })
    .then(function (t) { return { t.split('\r\n') })
    .then(function (results) {
      return !!results.filter(function (end) { 
        return digest === (firstFive + part);
      }).length;
    });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.