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

@nofrills/scrubs

v11.0.1

Published

Scrubs an object of sensitive data.

Downloads

355

Readme

@nofrills/scrubs

npm

No frills data scrubbing to help remove sensitive data from object properties and strings.

Install

npm install --save @nofrills/scrubs

Quick Start

Javascript

const scrubs = require('@nofrills/scrubs')
const data = {
  password: 'password123'
}
const scrubbed = scrubs.scrub(data)
// -> should return { password: "<secured>" }

Typescript

import { scrub } from '@nofrills/scrubs'
const data = {
  password: 'password123'
}
const scrubbed = scrub(data)
// -> should return { password: "<secured>" }

NOTE: From here on, we'll use Javascript in examples.

Options

You can also use an options object to inject some customizations and extensions.

{
  properties: ['apikey', 'api_key', 'password'],
  text: '<secured>'
}

Once you've created your options, you can pass it to the Scrubs class.

const Scrubs = require('@nofrills/scrubs').Scrubs
const scrubber = new Scrubs({
  secured: {
    properties: ['apikey', 'api_key', 'password'],
    text: '<password>'
  }
scrubber.scrub({ password: "password123" })
// -> will replace password with "<password>"
})

Properties

Properties are an array of strings representing the properties on an object that require securing. By default, apikey, api_key, and password are secured.

Extensibility

You can extend how scrubs works by registering custom handlers to scrub a provided value.

In Typescript parlance, we define a callback via the Scrubber<T> type.

type Scrubber<T> = (value: T, options: ScrubsOptions, instance: Scrubs) => T

Simply create your handler and register it before scrubbing, like so:

Javascript

const R = require('@nofrills/scrubs').Registry

const Handler = (value, options, scrubs) => {
  // TODO: Something super fantastic that scrubs
  // the value of sensitive data.
  return value
}

R.register('string', Handler)

License

Copyright 2018 NativeCode Development [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.