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

edahab

v1.0.1

Published

Production-ready JavaScript/TypeScript SDK for eDahab payments

Readme

edahab

Production-ready JavaScript/TypeScript SDK for eDahab payments.

Features

  • eDahab request hash generation (SHA-256(body + apiSecret))
  • Issue invoice (Issueinvoice)
  • Verify invoice (CheckInvoiceStatus)
  • Credit payment (agentPayment)
  • Strong TypeScript types and custom EdahabError
  • ESM + CommonJS builds

Install

npm install edahab

Quick Start

import { createEdahabClient } from "edahab";

const client = createEdahabClient({
  apiKey: process.env.EDAHAB_API_KEY!,
  apiSecret: process.env.EDAHAB_API_SECRET!,
});

const invoice = await client.issueInvoice({
  edahabNumber: "65XXXXXXXX",
  amount: 10,
  agentCode: "5555",
  currency: "USD",
});

if (invoice.InvoiceStatus === "Paid") {
  console.log("Payment successful:", invoice.TransactionId);
}

API

createEdahabClient(options)

Creates an EdahabClient.

Options:

  • apiKey: string (required)
  • apiSecret: string (required)
  • baseUrl?: string (default: https://edahab.net/api/api)
  • fetchFn?: typeof fetch (optional custom fetch for testing/runtime adapters)
  • timeoutMs?: number (default: 20000)

client.issueInvoice(request)

Request:

  • edahabNumber: string
  • amount: number
  • agentCode: string
  • currency?: "USD" | "SLSH" (default: "USD")

client.verifyInvoice(request)

Request:

  • invoiceId: string

client.creditPayment(request)

Request:

  • transactionAmount: number
  • phoneNumber: string
  • transactionId: string | number
  • currency?: "USD" | "SLSH" (default: "USD")

client.isInvoicePaid(invoiceId)

Convenience helper that returns true only when invoice status is Paid.

generateRequestHash(body, apiSecret)

Returns the documented eDahab hash:

sha256(JSON.stringify(body) + apiSecret)

Error Handling

The SDK throws EdahabError for:

  • HTTP errors
  • API status failures (StatusCode !== 0)
  • Request timeout
  • Network failures
  • Invalid JSON responses
import { EdahabError } from "edahab";

try {
  await client.verifyInvoice({ invoiceId: "INV123" });
} catch (error) {
  if (error instanceof EdahabError) {
    console.error(error.message, error.statusCode, error.endpoint);
  }
}

eDahab Status Codes

The underlying API may return:

  • 0: Success
  • 1: Api_Error
  • 2: Invalid_Json
  • 3: Validation_Error
  • 4: Invalid_Api_Credentials
  • 5: Insufficient_Customer_Balance
  • 6: Invoice_Not_Found
  • 7: Invalid

Reference docs:

edahab

Production-ready JavaScript/TypeScript SDK for eDahab payments.

  • Purchase via push/pop-up (Issueinvoice)
  • Credit payment (agentPayment)
  • Invoice verification (CheckInvoiceStatus)
  • Automatic request hash signing (SHA-256)
  • Strong TypeScript types and robust error handling

Install

npm install edahab

Quick Start

import { createEdahabClient } from "edahab";

const edahab = createEdahabClient({
  apiKey: process.env.EDAHAB_API_KEY!,
  apiSecret: process.env.EDAHAB_API_SECRET!,
});

const invoice = await edahab.issueInvoice({
  edahabNumber: "65XXXXXXXX",
  amount: 10,
  agentCode: "5555",
  currency: "USD",
});

if (invoice.InvoiceStatus === "Paid") {
  console.log("Payment success", invoice.TransactionId);
}

API

createEdahabClient(options)

Creates a new EdahabClient instance.

Options:

  • apiKey (required)
  • apiSecret (required)
  • baseUrl (optional, default: https://edahab.net/api/api)
  • fetchFn (optional custom fetch implementation)
  • timeoutMs (optional request timeout, default: 20000)

client.issueInvoice(payload)

Uses POST /Issueinvoice?hash={{hash}}.

const result = await client.issueInvoice({
  edahabNumber: "65XXXXXXXX",
  amount: 1,
  agentCode: "5555",
  currency: "USD", // or "SLSH"
});

client.creditPayment(payload)

Uses POST /agentPayment?hash={{hash}}.

const result = await client.creditPayment({
  transactionAmount: 1,
  phoneNumber: "65XXXXXXXX",
  transactionId: "ORDER-1001",
  currency: "SLSH",
});

client.verifyInvoice(payload)

Uses POST /CheckInvoiceStatus?hash={{hash}}.

const result = await client.verifyInvoice({
  invoiceId: "INV123456789",
});

client.isInvoicePaid(invoiceId)

Convenience method that returns true only when InvoiceStatus === "Paid".

generateRequestHash(body, apiSecret)

Utility helper if you need to generate the eDahab hash manually.

Error Handling

The SDK throws EdahabError for:

  • HTTP errors
  • API status failures (StatusCode !== 0)
  • Timeouts
  • JSON parse/network failures
import { EdahabError } from "edahab";

try {
  await client.issueInvoice({ edahabNumber: "65", amount: 1, agentCode: "5555" });
} catch (error) {
  if (error instanceof EdahabError) {
    console.error(error.message, error.statusCode, error.endpoint, error.responseBody);
  }
}

Notes

  • According to eDahab docs, focus on InvoiceStatus and treat only "Paid" as successful.
  • Request hash is generated as sha256(JSON.stringify(body) + apiSecret).

References