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

@tormentalabs/floyd-webhooks

v1.0.4

Published

Webhook handling SDK for the Floyd Blockchain API

Readme

@tormentalabs/floyd-webhooks

npm version License: MIT

Webhook handling SDK for the Floyd Blockchain API.

Features

  • Signature verification - HMAC-SHA256 validation
  • Timestamp validation - Replay attack prevention
  • Type-safe events - Full TypeScript support
  • Framework adapters - Express, raw Node.js HTTP
  • Event routing - Subscribe to specific event types
  • Testing utilities - Generate signed test events

Installation

npm install @tormentalabs/floyd-webhooks

Quick Start

import express from 'express';
import { WebhookHandler } from '@tormentalabs/floyd-webhooks';

const app = express();
const webhooks = new WebhookHandler({
  secret: process.env.FLOYD_WEBHOOK_SECRET,
});

// Type-safe event handlers
webhooks.on('asset.created', async (event) => {
  console.log(`New asset: ${event.data.name}`);
});

webhooks.on('asset.blockchain.confirmed', async (event) => {
  console.log(`Confirmed: ${event.data.transactionHash}`);
});

webhooks.on('asset.transferred', async (event) => {
  console.log(`Transferred from ${event.data.previousOwner}`);
});

// Handle all events
webhooks.onAny(async (event) => {
  await logToAuditTrail(event);
});

// Express middleware
app.post('/webhooks',
  express.raw({ type: 'application/json' }),
  async (req, res) => {
    try {
      await webhooks.handleRequest(
        req.body,
        req.headers['x-floyd-signature'] as string
      );
      res.json({ received: true });
    } catch (err) {
      res.status(400).json({ error: err.message });
    }
  }
);

Express Middleware

import { createExpressMiddleware } from '@tormentalabs/floyd-webhooks';

app.post('/webhooks',
  express.raw({ type: 'application/json' }),
  createExpressMiddleware({
    secret: process.env.FLOYD_WEBHOOK_SECRET,
    onEvent: async (event, req, res) => {
      console.log(`Received: ${event.type}`);
    },
    onError: async (error, req, res) => {
      console.error('Webhook error:', error);
    },
  })
);

Raw Node.js HTTP

import { createServer } from 'node:http';
import { createNodeHttpHandler } from '@tormentalabs/floyd-webhooks';

const handler = createNodeHttpHandler({
  secret: process.env.FLOYD_WEBHOOK_SECRET,
  onEvent: async (event) => {
    console.log(`Received: ${event.type}`);
  },
});

const server = createServer(handler);
server.listen(3000);

Manual Verification

import { verifySignature, parseSignatureHeader } from '@tormentalabs/floyd-webhooks';

// Parse signature header
const { timestamp, signature } = parseSignatureHeader(
  req.headers['x-floyd-signature']
);

// Verify manually
verifySignature(
  { payload: req.body, signature, timestamp },
  secret,
  { tolerance: 300 } // 5 minutes
);

Event Types

type WebhookEventType =
  | 'asset.created'
  | 'asset.updated'
  | 'asset.deleted'
  | 'asset.transferred'
  | 'asset.blockchain.pending'
  | 'asset.blockchain.processing'
  | 'asset.blockchain.confirmed'
  | 'asset.blockchain.failed'
  | 'asset.accessory.attached'
  | 'asset.accessory.detached'
  | 'wallet.created'
  | 'wallet.suspended'
  | 'wallet.activated'
  | 'wallet.revoked';

Error Handling

import {
  SignatureVerificationError,
  TimestampError,
  PayloadParseError,
} from '@tormentalabs/floyd-webhooks';

try {
  await webhooks.handleRequest(payload, signature);
} catch (error) {
  if (error instanceof SignatureVerificationError) {
    // Invalid signature
  } else if (error instanceof TimestampError) {
    // Timestamp too old (possible replay attack)
  } else if (error instanceof PayloadParseError) {
    // Invalid JSON
  }
}

Testing

import { 
  generateSignedPayload,
  generateAssetCreatedEvent,
  generateBlockchainConfirmedEvent,
} from '@tormentalabs/floyd-webhooks/testing';

// Generate signed payload for supertest
const { body, headers } = generateSignedPayload(
  'asset.created',
  { id: 'test-123', name: 'Test Asset' },
  'test-secret'
);

const response = await request(app)
  .post('/webhooks')
  .set(headers)
  .send(body);

// Generate typed events
const event = generateAssetCreatedEvent({
  name: 'Custom Asset',
});

const confirmedEvent = generateBlockchainConfirmedEvent({
  transactionHash: '0x123...',
});

Related Packages

License

MIT