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

react-bald-auth

v0.1.1

Published

Simplest auth ever, yet powerful enough to lock up your app.

Downloads

3

Readme

BaldAuth for react apps

Tiny simple auth, done in browser, with password hashed by webpack during build process and not visible to app users.

Installation

npm i react-bald-auth --save

How it works

Wrap any component with <BaldAuth /> and it will not be rendered until [passwordHash] match entered password sha256 hash.

Usage

Setup webpack

In order to avoid exposing plain password in your app bundle you need to create password hash during webpack build process. Maybe you use other bundler, but I use webpack in example below.

Also, usually you will setup environment variable (can be done with any modern CI platform) holding plain password.

With that said, typically you will setup DefinePlugin within .plugins section of webpack config:

const
	crypto = require('crypto-js');
 
module.exports = {
  plugins: [
    new webpack.DefinePlugin({
      // Empty password disables auth
      __PASSWORD_HASH__: JSON.stringify(
        process.env.APP_PASSWORD && crypto.SHA256(process.env.APP_PASSWORD).toString()
      )
    })
  ]
}

Apply BaldAuth to your code

Now you can apply BaldAuth passed with password hash. Using composition it can be done with any component. If you use React Router in your app then most reliable way will be wrapping <Router />:

// Now until passwords hashes match nothing of your app structure will be exposed to user by dev tools
// like Chrome DOM inspector
<BaldAuth passwordHash={__PASSWORD_HASH__}>
  <Router history={syncHistoryWithStore(browserHistory, store)}>
    <Route component={App} path="/" />
  </Router>
</BaldAuth>

Properties

passwordHash mandatory

Sha256 hash to be matched to entered password hash.

title optional

Message to be shown over auth form.

buttonTitle optional

Submit button title.