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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hapi-authy

v1.0.5

Published

Authy 2FA with hapi

Downloads

36

Readme

hapi-authy Build Status

Two-Factor Authentication with Authy and hapi

This is a plugin that you can use to add 2fa to your hapi apps with ease. It works with the Authy service. Head over to Authy and register for an account.

Check out the example under examples/basic for a full working example of form based email/password and authy authentication (Authy API Key required)

Getting started

  1. Register with Authy
  2. Create an app
  3. Grab your api key

Installation

npm install --save hapi-authy

Usage

This would normally be used to implement the second step in a login process. After a successful step 1 (usually username/password login), a user with a 2fa-enabled account would be redirected to the 2fa route. Everything is then handled by the plugin.

This plugins defines a hapi auth scheme called authy. To get started, create a strategy from this scheme:

server.auth.strategy('authy', 'authy', {
    apiKey: 'your api key',
    sandbox: false,
    cookieOptions: {
        isSecure: false,
        path: '/',
        encoding: 'iron',
        password: 'cookiepass'
    }
});

Then define the 2FA route where you will redirect users to:

server.route({
    method: ['GET', 'POST'],
    path: '/authy',
    config: {
        auth: {
            strategies: ['authy'],
            payload: true
        },
        handler: function (request, reply) {

            const credentials = request.auth.credentials; // user's email and authyId
            const user = users[credentials.email];
            user.requireTfa = true;                       // user's account updated to use 2fa
            user.authyId = credentials.authyId;           // authyId saved for future logins
            request.auth.session.set(user);               // user logged in
            return reply.redirect('/');
        }
    }
});

The plugin will then take over fetching the relevant information from the user. The handler for this route will be finally executed once the user has successfully entered their 2FA token, either via SMS or the vis from the Authy app.

step1 step2 step3

Configuration/customisation

Section coming soon. Please checkout examples for now.