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

salti-admin

v0.1.8

Published

Simple Admin Authentication for Thali IoT

Downloads

10

Readme

SALTI-Admin

Build Status Coverage Status

Simple Authentication/Authentication Library for Thali IoT

Provides a simple Express Middleware implementation that checks a simple Authorization header.

A supporting sample that utilizes PouchDB and express-pouchdb

Using the library..

npm install --save salti-admin

Server side setup.

You should have an Express site available.

var adminAcl = require('salti-admin');

Determine a secret.

You can use any secret - but, there is a utility method to generate one.

The example below - this generates a secret - then sets the secret for the salti-admin library, then also sets the Express app property (optional).

Then this inserts the middleware, and the final call here sets up express-pouchdb app.


adminAcl.generateSecret(function (err, secret) {

  adminAcl.setSecret(secret);
  
  //also setting this in the App - see above for the API route
  app.set('secret', secret);
  
  //inject our middleware.. - needs to be BEFORE the express-pouchdb app setup.
  app.use(adminAcl.isAdminOk);

  app.use('/', require('express-pouchdb')(PouchDB, pouchOptions));
 
});

Client setup

This just requires that the same secret is shared on the client.

For example, here we're setting the PouchDB client options.

The secret is the same from above with the word CLEAR as a prefix

  pouchDbOptions.ajax.headers = {
    'User-Agent': 'request',
    'Authorization' : 'CLEAR ' + secret
  }
  
  var remoteDB = new PouchDB('https://localhost:3001/_validate', pouchDbOptions)

Setting up..

  • [ ] First - clone - then run npm install on both the root and the sample
  • [ ] Then move to the directory
  • [ ] run npm install
  • [ ] run the tests with mocha
  • [ ] move to the sample directory
  • [ ] run npm install
  • [ ] run the sample app
git clone https://github.com/cicorias/salti-admin
cd salti-admin
npm install
mocha
cd sample
npm install
node ./server.js

Running Tests

You first should have mocha installed.

npm install -g mocha

Then from the root, just run mocha

Running solution

There is a sample solution that sets up 3 Express sites.

cd sample
npm install
node ./server

At this point, you have 3 sites running.

Go to the main site at https://localhost:3000

From there other links are visible: PouchDB / Fauxton site: http://localhost:3002

Validation Page.

Validation page demonstrates the creation of a document - check the code for the calling pattern.

The field that shows the current secret it set automatcially at startup.

Try a few "create docs" and you should see the response in the green box.

Then, change the key to something else - then again try to create docs - at this point you should see messages on each failure in the red box.