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

@miinded/nestjs-auth-blockchain

v1.1.1

Published

Production-ready NestJS module for blockchain-based authentication. Supports Web3 signature verification with JWT tokens.

Readme

@miinded/nestjs-auth-blockchain

Production-ready NestJS module for blockchain-based authentication. Supports Web3 signature verification with JWT tokens.

Installation

npm i @miinded/nestjs-auth-blockchain

Features

  • Multi-signature support: SIMPLE, ADVANCED (EIP-712), and SIWE (Sign-In with Ethereum)
  • JWT integration: Automatic JWT token generation after successful authentication
  • Refresh token support: Built-in refresh token strategy with configurable transport (header or cookie)
  • Passport integration: Works with NestJS guards and middleware
  • Type-safe: Full TypeScript support

Usage

1. Create a user service implementing IBlockchainAuth

import { Injectable } from '@nestjs/common';
import { IBlockchainAuth, IBlockchainAuthRefresh } from '@miinded/nestjs-auth-blockchain';
import { SignatureType } from '@miinded/nestjs-web3-signature';
import * as crypto from 'crypto';

@Injectable()
export class BlockchainUserService implements IBlockchainAuth, IBlockchainAuthRefresh {
  async getOneUserByWallet(wallet: string): Promise<unknown> {
    // Find user by wallet address
  }

  async nonce(
    signatureType: SignatureType,
    networkId: number,
    wallet: string,
    domain: string,
    uri: string,
    message: any,
  ) {
    const nonce = crypto.randomBytes(16).toString('hex');
    const issuedAt = new Date().toISOString();
    // Store nonce in cache
    return { nonce, issuedAt };
  }

  async get<T>(networkId: number, wallet: string, nonce: string): Promise<T> {
    // Retrieve stored nonce data
  }

  // Optional: Implement for refresh token support
  async getOneUserByUserId(userId: string): Promise<unknown> {
    // Find user by ID
  }

  async refreshTokenIsValid(userId: string, token: string): Promise<boolean> {
    // Validate refresh token
  }

  async invalidateRefreshToken(userId: string): Promise<void> {
    // Invalidate refresh token
  }

  async generateTokens(user: { userId: string; wallet?: string }) {
    // Generate new access and refresh tokens
    return { accessToken: '...', refreshAccessToken: '...' };
  }
}

2. Configure the module

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AuthBlockchainModule } from '@miinded/nestjs-auth-blockchain';
import { BlockchainUserService } from './blockchain-user.service';

@Module({
  imports: [
    AuthBlockchainModule.registerAsync({
      imports: [ConfigModule],
      userService: BlockchainUserService,
      useFactory: (config: ConfigService) => ({
        domains: config.get<string>('BLOCKCHAIN_DOMAIN').split('|'),
        token: {
          secret: config.get('BLOCKCHAIN_JWT_SECRET'),
          signOptions: { expiresIn: '8h' },
          transport: 'header', // 'header' or 'cookie'
        },
        refreshToken: {
          secret: config.get('BLOCKCHAIN_REFRESH_SECRET'),
          signOptions: { expiresIn: '7d' },
          transport: 'cookie', // 'header' or 'cookie'
          cookieName: 'refresh_token',
        },
      }),
      inject: [ConfigService],
    }),
  ],
  providers: [BlockchainUserService],
})
export class AppModule {}

3. Use with guards

import { Controller, Get, UseGuards, Request } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { BlockchainRefreshTokenGuard } from '@miinded/nestjs-auth-blockchain';

@Controller()
export class AppController {
  // Protect route with blockchain JWT
  @UseGuards(AuthGuard('blockchain-jwt'))
  @Get('protected')
  protected(@Request() req) {
    return req.user;
  }

  // Refresh token endpoint
  @UseGuards(BlockchainRefreshTokenGuard)
  @Get('auth/refresh')
  refresh(@Request() req) {
    return req.user; // Returns new tokens
  }
}

Configuration

JwtTokenOptions

| Property | Type | Default | Description | | ------------- | ---------------------- | ------------------------------------ | --------------------------------------- | | secret | string | - | JWT secret key | | signOptions | SignOptions | - | JWT sign options (expiresIn, etc.) | | transport | 'header' \| 'cookie' | 'header' | How to extract the token | | cookieName | string | 'access_token' / 'refresh_token' | Cookie name when using cookie transport |

AuthBlockchainConfig

| Property | Type | Required | Description | | -------------- | ------------------------- | -------- | ------------------------------------------ | | domains | string[] | Yes | Allowed domains for signature verification | | token | JwtTokenOptions | Yes | Access token configuration | | refreshToken | JwtTokenOptions | Yes | Refresh token configuration | | providers | AuthBlockchainSignature | No | Custom signature providers | | chainIds | number[] | No | Allowed chain IDs |

License

MIT