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

kno

v0.2.0

Published

The simplest way to add passwordless authentication to your application.

Downloads

4

Readme

Kno nodejs

Go Passwordless

Use trykno.com for the simplest way to add passwordless authentication to your application.

Kno is a service for implementing passwordless authentication, it handles sending emails so you don't have too. It also allows users to set up device based authentication so they don't have to wait for any email, after the first.

Installation

Add Kno to your project, it can be fetched from npm as follows.

$ npm install --save kno

Usage

This library integrates Kno into any express based web application. So it works with most frameworks,

Configure middleware

Use the kno.Session middleware in your application. This middleware requires a session middleware to already be used, if in doubt express-session works well.

app.use(kno.Session({
  signInRedirect: "/dashboard"
}))

Modify templates

Using the Kno middleware adds some helpers that can be used when rendering responses. Add the sign in/out button to your page.

header !{kno.sessionButton()}

Check user is authenticated

Any route or middleware that follows the Kno middleware can check if the request comes from an authenticated user. Kno adds the personaID id to the express request object. If the request is unauthenticated then the personaID is undefined.

If you don't want to keep checking for undefined a simple middleware to require authentication can be created as follows.

function protected(req, res, next) {
  if (req.personaID) {
    next();
  } else {
    res.status(403);
    res.send("Authentication required to access this page");
  }
}

app.get("/protected", protected, function(req, res) {
  // ... Show the protected page
});

Local development

Authentication is now setup for local development. Run locally and click the sign in button and you should see a sign in modal.

Enter your real email address. Kno runs a service for local development that sends a limited number of emails.

Get production keys

Create an account at trykno.com and follow the guidance to create your first space. This will direct you to create a site_token and api_token. Add these to your environment and edit the middleware configuration.

app.use(kno.Session({
  signInRedirect: "/dashboard",
  siteToken: process.env.KNO_SITE_TOKEN,
  apiToken: process.env.KNO_API_TOKEN
}))

NOTE: The tokens do not have to be stored in the environment. However the api token MUST be kept secure and should not be committed to your applications source code.

Contributing

Contributions are very welcome. Please do open an issue or pull request or reach out to us at [email protected]

Docker

If you do not have node installed you can run locally in Docker with the following command.

docker run \
  -it \
  --rm \
  -w="/opt/app" \
  -v="$(pwd):/opt/app" \
  -p="3000:3000" \
  --network="host" \
  node:12.14.0 bash