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

private-input

v3.4.1

Published

This Angular Materail component that allows you to have a input contol for private input

Downloads

24

Readme

Private-Input (Form Element)

image

This Angular Module (Component) allows you to have a input contol for private input.

The value recieved by the component will always remain in its encypted state as long the the key (privateKey) is supplied. Once registered with the component, the service can be used to decrypt the final value. The encryption is AES from Crypto.

This component can take an input from a formContorl and mask it displaying only the last n digits.

A custom mask or formatter may also be provided to control the formatting of the input as the user enteres the value.

You can have a user access the encrypted data to display the contents of the hidden value or not. Also the input can be editbale and only when valid does it replace the current value.

Installation

npm install private-input

Scaffolding

Import the module into your project under imports

imports: [
    BrowserModule,
    AppRoutingModule,
    PrivateInputModule
  ],

Use

To use in your component, use the following tag

<wav-private-input></wav-private-input>

Inputs

The following Inputs are available

| Input | Type | Defaut | Description | | ----- | ---- | ------ | ----------- | | private | BOOLEAN | false | Encrypt the input using the token | | allowAccess | BOOLEAN | false | Allows the user to view the encrypted string | | label | STRING | NULL | Label for the input field | | format | STRING | NULL | This is a mask to format the value in the input (XXX-XXX) | | lastVisible | NUMBER | 3 | digits at the end to make visible | | disabled | BOOLEAN | false | disable input | | key | STRING | NULL | encryption key to use for the input | | displayChar | STRING | # | char to use for masking | | maxlen | NUMBER | NULL | min length for entry validation | | minlen | NUMBER | NULL | max length and limit for entry validation | | appearence | STRING | NULL | field style |

Sample Configurations

Here is the same tag with options defined with Formbuilder:

format = "XXX-XXX-XXXXXXX-X"
encryptionKey = 'sampletoken123!'
fb.control({value: '0011-234512-345678', disabled: true})
<wav-private-input
    [private]="true"
    [allowAccess]="true"
    [label]="'Account Number'"
    [format]="format"
    [lastVisible]="4"
    [disabled]="false"
    [key]="encryptionKey"
    [formControl]="account"
  ></wav-private-input>

Here is the same component inside a formGroup

<div [formGroup]="privateForm" *ngIf="selected.value">
  <wav-private-input
    [private]="true"
    [allowAccess]="true"
    [label]="'Account Number'"
    [format]="format"
    [lastVisible]="4"
    [disabled]="false"
    [key]="'sampletoken123!'"
    formControlName="account"
  ></wav-private-input>
</div>

Here is the same component but now using a select to select the format of the control dynamically

<mat-form-field appearance="fill">
  <mat-label>Country</mat-label>
  <mat-select #selected>
    <mat-option *ngFor="let country of countries" [value]="country.mask">
      {{country.name}}
    </mat-option>
  </mat-select>
</mat-form-field>

<div [formGroup]="privateForm" *ngIf="selected.value">
  <wav-private-input
    [private]="true"
    [allowAccess]="true"
    [label]="'Account Number'"
    [format]="selected.value"
    [lastVisible]="4"
    [disabled]="false"
    [key]="'sampletoken123!'"
    formControlName="account"
  ></wav-private-input>
</div>

Input return

You will note that the control will return an encrypted string of the entered value To decrypt this value, import the decryptionService and decrypt the string

Below is a sample of the implementation

import { DecryptService } from 'private-input';

privateForm = this.fb.group({
  account: [this.accountNumber]
})

constructor(
  private decrypt: DecryptService
) {}

ngOnInit() {

  this.privateForm.get('account')?.valueChanges.subscribe(data => {
    console.log('value:', data, this.decrypt.string(data))
  })

}