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

umang_logger_module

v1.1.4

Published

Simple winston based logger that produces coloured logs on the console and provides masking of PII Fields.

Downloads

5

Readme

Umang_Logger_Module

Simple winston based logging module with colured logs and also the functionality to handle masking of PII data. [npm package]

Features

  • Standard logging based on environment, example: Production, Staging etc. using ‘winston’ module

  • Various log levels supported – info, warn, verbose, error, debug

  • Configuration for logging based on severity of log.

  • For prod and different environment

  • Different colours for levels of log using ‘chalk’ module.

  • Configuration for saving the logs in file.

  • Configurable log file path from home directory.

  • Identifying PII in simple string using regexes, example: card, phone, email.

  • Configurable file for identifying PII using fieldname in JSON

  • Masking identified PII using node module ‘maskdata’

  • Configurable file for how we want to mask the PII example by using * or x or $ etc.

  • Configurable file for how many characters needs to be masked at the start or end of the PII

Identifying PII using Regexes:

Email:

  • Emails are picked from the given string using the regex provided in the table below

  • Match function is used to return the array of emails fetched in this case which is masked further.

Phone:

  • Match function is used to return the array of phone numbers fetched in this case which is masked further
  • Regex used for phone picks up phone number in the following formats:
  • +1 717-716-7676
  • 7177167676
  • (717) 716-7676
  • +917177167676
  • +91 7177167676
  • +91-7177167676
  • 717-716-7676

Card:

  • Regex used for card number picks up card in the following formats:
    • 4111111111111111
    • 4111-1111-1111-1111
    • 4111 1111 1111 1111
    • 378282246310005
    • 3782-822463-10005
    • 3782 822463 10005
  • These picked up numbers are validated by a node module ‘node-luhn’.
  • If the card number picked is a valid card number, then the masking is done otherwise no masking is done.

Identifying PII using fieldnames in JSON:

We can mask the PII if we are provided with fieldname of the data that needs to be masked using the node module ‘maskdata’.

Installation and set up

  • Installing umang_logger_module

    Link: https://www.npmjs.com/package/umang_logger_module Command: npm i umang_logger_module

  • Creating pii-fields.json file

    • More fileds can be added or removed as per the masking requirement.
      	{
              "gender": "",
              "age": "",
              "name": "",
              "email": "",
              "phone": "",
              "cc":"",
              "_id":"",
              "access_token":""
          } 

Creating maskConfig.json file

  • PII identified by regexes will be masked in the following fashion.

  • “maskWith”: Character to mask the data.

  • “unmaskedStartCharacters”: If the starting 'n' characters needs to be unmasked. Should be positive Integer

  • “unmaskedEndCharacters”: If the ending 'n' characters needs to be unmasked. Should be positive Integer

  • “maskAtTheRate”: If '@' needs to be masked. Default value is false (Will not mask). Should be Boolean

  • “maxMaskedCharactersBeforeAtTheRate”: To limit the *s in the response (Max *s before '@'). Should be positive Integer

  • “maxMaskedCharactersAfterAtTheRate”: To limit the *s in the response (Max *s after '@'). Should be positive Integer

      {
      "email": {
    
          "maskWith" : "x",
    
          "unmaskedStartCharacters" : "1", 
    
          "unmaskedEndCharacters" : "2", 
    
          "maskAtTheRate ": "false",
    
          "maxMaskedCharactersBeforeAtTheRate" : "10",
    
          "maxMaskedCharactersAfterAtTheRate" : "10"
      },
    
      "phone": {
           
          "maskWith" : "x",
    
          "unmaskedStartDigits" : "5", 
    
          "unmaskedEndDigits" : "1"
      },
    
      "card": {
            
          "maskWith" : "x",
    
          "unmaskedStartDigits" : "4",
            
          "unmaskedEndDigits" : "1"
      },
    
      "json": {
            
          "maskWith" : "x"
      }

} ```

Addition in .env file

  • #Environment identifier (setting default environment)

  • NODE_ENV="dev"

  • #identifier for choosing masking or no masking (default is set as true)

  • MASKING_FOR_PII_FLAG="true"

PII File Name

  • PII_FILENAME = "pii-fields.json"

Log File Name (mandatory field)

  • LOG_FILENAME = "master_"

Log File Path (mandatory field)

  • LOG_FILEPATH = ''

identifier for saving in FILE (default is set as false)

  • SAVE_IN_FILE = 'true'

Identifier for Log Level for current environment (default set to info)

  • LOG_LEVEL = "debug"

Identifier for Log Level for production environment (default set to error)

  • PRODUCTION_LOG_LEVEL = ‘error’