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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hive-authentication-server-side-nodejs

v1.0.0

Published

Server-side authentication library for Hive blockchain using JWT tokens. Validates Hive signatures and provides middleware for Express.js applications.

Downloads

6

Readme

Hive Authentication Server-Side Node.js

A server-side authentication library for Hive blockchain that validates Hive signatures and provides JWT-based authentication middleware for Express.js applications.

Installation

npm install hive-authentication-server-side-nodejs

Features

  • ✅ Validate Hive blockchain signatures
  • ✅ Verify Hive username and public key ownership
  • ✅ JWT token generation and validation
  • ✅ Express.js middleware for protected routes
  • ✅ Proof expiration validation (30 seconds)

Usage

Basic Setup

const { getDataToSign, tokenValidation, dhiveClient } = require('hive-authentication-server-side-nodejs');
const express = require('express');
const jwt = require('jsonwebtoken');
const app = express();

// Your JWT secret key
const JWT_SECRET = 'your-secret-key';

Validate Hive Signature and Generate JWT

app.post('/auth/login', async (req, res) => {
  try {
    const { challenge, username, pubkey, proof } = req.body;
    
    // Validate signature and get user data
    const userData = await getDataToSign(challenge, username, pubkey, proof);
    
    // Generate JWT token
    const token = jwt.sign(
      { username: userData.username },
      JWT_SECRET,
      { expiresIn: '7d' } // Token expires in 7 days
    );
    
    res.json({ token, username: userData.username });
  } catch (error) {
    res.status(401).json({ error: error.toString() });
  }
});

Protect Routes with Middleware

// Protected route - pass your JWT secret to tokenValidation
app.get('/api/profile', tokenValidation(JWT_SECRET), (req, res) => {
  // req.user contains { username: 'hive-username' }
  res.json({ 
    message: `Hello ${req.user.username}`,
    user: req.user 
  });
});

Access Hive Client

const { dhiveClient } = require('hive-authentication-server-side-nodejs');

// Use dhiveClient to interact with Hive blockchain
const accounts = await dhiveClient.database.getAccounts(['username']);

API Reference

getDataToSign(challenge, username, pubkey, proof)

Validates a Hive signature and returns user data if valid.

Parameters:

  • challenge (string): The challenge string that was signed
  • username (string): Hive username
  • pubkey (string): Hive public key
  • proof (string): Timestamp proof (must be within 30 seconds)

Returns:

  • Promise<{ username: string }>: User data object

Throws:

  • Error if username is invalid
  • Error if public key doesn't belong to the username
  • Error if signature is invalid
  • Error if proof has expired

tokenValidation(jwtSecret)

Returns an Express.js middleware function to validate JWT tokens.

Parameters:

  • jwtSecret (string): Your JWT secret key used to sign tokens

Returns:

  • Function: Express middleware function (req, res, next) => {}

Headers Required:

  • Authorization: Bearer <token>

Sets:

  • req.user: Object containing { username: string }

Requirements

  • Node.js >= 12.0.0
  • Express.js (for middleware usage)

Dependencies

  • @hiveio/dhive: Hive blockchain client
  • dayjs: Date manipulation
  • jsonwebtoken: JWT token handling
  • node-color-log: Logging utility

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

If you encounter any issues, please report them on the GitHub Issues page.