npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-pass-strength

v1.0.0

Published

This is a small Angular Library which checks your password strength and also whether it's breached or not.

Downloads

28

Readme

NGX Pass Strength

Build Status npm

npm

This is a small library I created which lets you measure password strength and also checks it against Have I Been Pwned APIs created by Troy Hunt to see if is found in a breach before or not.

Demo

Try out the demo on Stackblitz!

Install

npm i ngx-pass-strength --save

Since npm doesn't install the peer dependencies automatically, you will need to install sha1 npm package which is needed to calculate the password hash:

npm i sha1 --save

Setup

You will need to import NgxPassStrengthModule into your application module. Then use <ngx-pass-strength> component for your password field.

Also do not forget to import HttpClientModule as well since it's required to make the HTTP call to the HIBP API.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { NgxPassStrengthModule } from 'ngx-pass-strength';

@NgModule({
  imports:      [ 
    BrowserModule, 
    FormsModule,
    NgxPassStrengthModule,
    HttpClientModule
  ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

After this you can use the component in your form or even outside if you prefer.

<form>
    <input class="form-control" type="password" name="password" [(ngModel)]="password"  minlength="5" maxlength="50" required />
    <ngx-pass-strength [passwordToCheck]="password"></ngx-pass-strength>
</form>

If you are using reactive forms you can use the form control to bind to the passwordToCheck. The component also gets a callback to give you the strength changes when the password is updated.

Note: This callback is updated on every change to the password whereas API is only called when the user hasn't typed for a minimum of 1000ms. This is to prevent many calls to the API.

<ngx-pass-strength [passwordToCheck]="password" (onStrengthChanged)="countChange($event)"></ngx-pass-strength>

And in your component:

export class AppComponent  {
  countChange($event) {
    console.log($event);
  }
}

Customisation

You can customise the font family and label if you would like to. Simply pass them as inputs.

<ngx-pass-strength [passwordToCheck]="password" (onStrengthChanged)="countChange($event)" [fontFamily]="'Open Sans'"></ngx-pass-strength>

And you can change the label too.

<ngx-pass-strength [passwordToCheck]="password" (onStrengthChanged)="countChange($event)" [barLabel]="'Strength'"></ngx-pass-strength>

Development

Run locally

This project uses [Angular CLI] as base. However if you want to run the library you need to have an application and reference the package. To do so, simply package the library first using:

npm run package

And then in your application add a reference to the generated package to your package.json like a normal package and run npm i.

{
    ...,
    "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "ngx-pass-strength": "file:../angular-libs/dist/ngx-pass-strength/ngx-pass-strength-0.0.2.tgz",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "sha1": "^1.1.1",
    "zone.js": "~0.8.26"
  }
}

Contribute

For any type of contribution, please follow the instructions in CONTRIBUTION and read the Code of Conduct file too.

Author

Yaser Adel Mehraban (yashints)