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

digiid-ts

v1.1.1

Published

A modern TypeScript implementation of the DigiID authentication protocol.

Readme

digiid-ts

A modern TypeScript implementation of the Digi-ID authentication protocol, inspired by the original digiid-js.

Provides utilities for generating Digi-ID URIs for QR code display and verifying the callback data signed by a user's Digi-ID-compatible wallet.

Features

  • Generates Digi-ID URIs according to the specification.
  • Verifies Digi-ID callback signatures and data.
  • Verifies signatures from all standard DigiByte address types (Legacy, SegWit P2SH, Native SegWit/Bech32).
  • Full TypeScript support with comprehensive type definitions.
  • Modern ES modules support.
  • Minimal dependencies, relying on standard cryptographic libraries.
  • Comprehensive test coverage.
  • Detailed error messages for debugging.

Installation

# Using npm
npm install digiid-ts

# Using yarn
yarn add digiid-ts

# Using pnpm
pnpm add digiid-ts

The package provides both ESM and UMD builds, with full TypeScript type definitions.

Requirements

  • Node.js 16.0.0 or higher
  • TypeScript 4.5 or higher (for TypeScript users)

Usage

Generating a Digi-ID URI

import { generateDigiIDUri, DigiIDError } from 'digiid-ts';

const options = {
  callbackUrl: 'https://your-site.com/auth/callback',
  // Optional parameters:
  nonce: 'custom-nonce', // Defaults to random UUID
  unsecure: false, // Defaults to false (requires HTTPS)
};

try {
  const digiidUri = generateDigiIDUri(options);
  console.log('Generated Digi-ID URI:', digiidUri);
  // Display this URI as a QR code for the user to scan
} catch (error) {
  if (error instanceof DigiIDError) {
    console.error('Failed to generate Digi-ID URI:', error.message);
  }
}

Verifying the Digi-ID Callback

import { verifyDigiIDCallback, DigiIDError, DigiIDCallbackData } from 'digiid-ts';

// In your Express route handler:
app.post('/auth/callback', async (req, res) => {
  const callbackData: DigiIDCallbackData = req.body; // { address, uri, signature }
  
  const verifyOptions = {
    expectedCallbackUrl: 'https://your-site.com/auth/callback',
    expectedNonce: 'your-stored-nonce', // The nonce you generated earlier
  };

  try {
    const verificationResult = await verifyDigiIDCallback(callbackData, verifyOptions);
    
    // Verification successful!
    console.log(`Successfully verified Digi-ID login for address: ${verificationResult.address}`);
    
    // Store the verified address in your session/database
    // Redirect to success page
    res.redirect('/dashboard');
  } catch (error) {
    if (error instanceof DigiIDError) {
      // Specific Digi-ID error (e.g., signature invalid, nonce mismatch, URL mismatch)
      console.error('Digi-ID verification failed:', error.message);
      res.status(400).json({ error: error.message });
    } else {
      // Unexpected error
      console.error('Unexpected error:', error);
      res.status(500).json({ error: 'Internal server error' });
    }
  }
});

API Reference

Core Functions

  • generateDigiIDUri(options: DigiIDUriOptions): string
    • Generates a Digi-ID URI for QR code display.
  • verifyDigiIDCallback(callbackData: DigiIDCallbackData, verifyOptions: DigiIDVerifyOptions): Promise<DigiIDVerificationResult>
    • Verifies the data received from the wallet callback. Resolves on success, throws DigiIDError on failure.

Type Definitions

  • DigiIDUriOptions: Options for generateDigiIDUri.
  • DigiIDCallbackData: Shape of data expected from the wallet callback.
  • DigiIDVerifyOptions: Options for verifyDigiIDCallback.
  • DigiIDVerificationResult: Shape of the success result from verifyDigiIDCallback.
  • DigiIDError: Custom error class thrown on failures.

Development

Prerequisites

  • Node.js 18+
  • npm 9+

Setup

  1. Clone the repository
  2. Install dependencies: npm install
  3. Run tests: npm test

Project Structure

  • src/ - Source code
    • digiid.ts - Core implementation
    • types.ts - TypeScript type definitions
  • test/ - Test files
  • examples/ - Usage examples
  • dist/ - Built files (generated)

License

MIT

Contributing

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