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

@afriex/webhooks

v1.0.3

Published

Webhook service for Afriex SDK

Readme

@afriex/webhooks

Webhook verification for the Afriex SDK. Verify webhook signatures using RSA public key.

Installation

npm install @afriex/webhooks
# or
pnpm add @afriex/webhooks

Usage

import { WebhookVerifier, WEBHOOK_SIGNATURE_HEADER } from '@afriex/webhooks';

const verifier = new WebhookVerifier('-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----');

// Verify a webhook signature
const isValid = verifier.verify(payload, signature);

// Verify and parse webhook payload (throws if invalid)
const event = verifier.verifyAndParse(payload, signature);
console.log('Event type:', event.event);
console.log('Event data:', event.data);

Express.js Example

import express from 'express';
import { WebhookVerifier, WEBHOOK_SIGNATURE_HEADER } from '@afriex/webhooks';

const app = express();
const verifier = new WebhookVerifier(process.env.AFRIEX_WEBHOOK_PUBLIC_KEY!);

app.post('/webhooks/afriex', express.raw({ type: 'application/json' }), (req, res) => {
    const signature = req.headers[WEBHOOK_SIGNATURE_HEADER] as string;
    const payload = req.body.toString();

    try {
        const event = verifier.verifyAndParse(payload, signature);
        
        switch (event.event) {
            case 'TRANSACTION.CREATED':
            case 'TRANSACTION.UPDATED':
                // Handle transaction events
                break;
            case 'customer.created':
            case 'customer.updated':
            case 'customer.deleted':
                // Handle customer events
                break;
            case 'PAYMENT_METHOD.CREATED':
            case 'PAYMENT_METHOD.UPDATED':
            case 'PAYMENT_METHOD.DELETED':
                // Handle payment method events
                break;
        }

        res.status(200).send('OK');
    } catch (error) {
        res.status(401).send('Invalid signature');
    }
});

Webhook Event Types

Customer Events

  • customer.created
  • customer.updated
  • customer.deleted

Transaction Events

  • TRANSACTION.CREATED
  • TRANSACTION.UPDATED

Payment Method Events

  • PAYMENT_METHOD.CREATED
  • PAYMENT_METHOD.UPDATED
  • PAYMENT_METHOD.DELETED

API Reference

verify(payload: string, signature: string): boolean

Verify a webhook signature using RSA SHA256.

Parameters:

  • payload: Raw webhook payload string
  • signature: Base64-encoded signature from x-webhook-signature header

Returns: boolean - Whether signature is valid

verifyAndParse(payload: string, signature: string): WebhookPayload

Verify signature and parse the webhook event.

Throws: Error if signature is invalid

Returns: Parsed WebhookPayload object with event and data properties

Constants

  • WEBHOOK_SIGNATURE_HEADER - The header name: 'x-webhook-signature'

License

MIT