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

nakapay-sdk

v0.1.4

Published

Node.js SDK for the NakaPay API to integrate Bitcoin Lightning payments.

Readme

NakaPay Node.js SDK

npm version

The official Node.js SDK for interacting with the NakaPay API. Easily integrate Bitcoin Lightning Network payments into your Node.js applications.

⚠️ SECURITY WARNING: This SDK is designed for SERVER-SIDE use only. Never expose your API keys in client-side code, frontend applications, or environment variables with public prefixes like NEXT_PUBLIC_.

Features

  • Create and manage Lightning payment requests.
  • Check the status of payments.
  • Retrieve payment history.
  • Register webhooks for real-time payment notifications.
  • Typed interfaces for robust development with TypeScript.
  • Simple error handling.

Security Best Practices

🔒 API Key Security:

  • Store API keys in server environment variables only
  • Never use NEXT_PUBLIC_ prefix in Next.js applications
  • Never commit API keys to version control
  • Use different API keys for development and production
  • Rotate API keys regularly

Installation

Install the SDK using npm:

npm install nakapay-sdk

Or using yarn:

yarn add nakapay-sdk

Getting Started

First, you'll need an API key from your NakaPay dashboard.

import { NakaPay } from 'nakapay-sdk';

// SECURE: Initialize the client with your API key from environment variable
// NEVER hardcode API keys or use client-side environment variables
const nakaPay = new NakaPay(process.env.NAKAPAY_API_KEY); // NOT NEXT_PUBLIC_NAKAPAY_API_KEY

async function createPayment() {
  try {
    // Input validation is recommended
    const amount = 100; // Amount in satoshis
    
    if (!amount || amount <= 0) {
      throw new Error('Invalid payment amount');
    }

    // First, get your business profile to use the configured destination wallet
    const businessProfile = await nakaPay.getBusinessProfile();
    console.log('Business Name:', businessProfile.name);
    console.log('Lightning Address:', businessProfile.lightningAddress);

    const paymentRequest = await nakaPay.createPaymentRequest({
      amount: amount,
      description: 'Payment for Order #123',
      destinationWallet: businessProfile.lightningAddress, // Use your configured lightning address
      metadata: { orderId: '123', customerId: '456' }
    });

    console.log('Payment Request Created:', paymentRequest);
    console.log(`Invoice: ${paymentRequest.invoice}`);
    console.log(`Pay this invoice or show QR code for: ${paymentRequest.invoice}`);

    // You can then poll for payment status or use webhooks
    // For example, to check status after a delay:
    setTimeout(async () => {
      const status = await nakaPay.getPaymentStatus(paymentRequest.id);
      console.log(`Payment ID ${paymentRequest.id} Status:`, status.status);
    }, 30000); // Check after 30 seconds

  } catch (error) {
    console.error('Error creating payment request:', error.message);
  }
}

createPayment();

API

The SDK provides the following methods:

  • new NakaPay(apiKey: string, options?: { baseUrl?: string }): Constructor to initialize the client.
  • createPaymentRequest(options: PaymentRequestOptions): Promise<PaymentRequest>
  • getPaymentRequest(id: string): Promise<PaymentRequest>
  • getPaymentStatus(id: string): Promise<PaymentStatus>
  • getBusinessProfile(): Promise<Business>: Get current business profile information
  • getPayments(businessId: string, options?: { limit?: number; offset?: number }): Promise<PaymentRequest[]>
  • registerWebhook(businessId: string, options: WebhookOptions): Promise<{ success: boolean; message: string }>

Refer to the index.ts file or the main NakaPay API documentation for detailed information on request/response types.

Testing

The SDK includes both unit and integration tests.

Running Unit Tests

Unit tests test the basic functionality without external dependencies:

npm test
# or specifically
npm run test:unit

Running Integration Tests

Integration tests require a running NakaPay API server and Supabase setup:

  1. Copy the environment file: cp .env.example .env
  2. Fill in your test environment variables in .env
  3. Run integration tests: npm run test:integration

CI/CD

The project includes GitHub Actions CI that:

  • Tests the SDK across Node.js versions 16.x, 18.x, and 20.x
  • Runs unit tests (integration tests are skipped in CI)
  • Builds the TypeScript code
  • Verifies the build artifacts

Contributing

Contributions are welcome! Please open an issue or submit a pull request to the NakaPay SDK repository.

License

MIT