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

umojasdk

v0.1.1

Published

One SDK. Every African payment. TypeScript SDK for M-Pesa, Airtel Money, and more.

Readme

umojasdk

One SDK. Every African payment.

UmojaSDK is the unified TypeScript/Node.js SDK for African mobile money integrations — M-Pesa (Safaricom Daraja 3.0), Airtel Money, and more.

Built by Synapse Softwares.

Installation

npm install umojasdk

Quickstart — M-Pesa STK Push

import { UmojaMpesa } from 'umojasdk';

const mpesa = new UmojaMpesa({
  consumerKey: process.env.MPESA_CONSUMER_KEY!,
  consumerSecret: process.env.MPESA_CONSUMER_SECRET!,
  shortcode: process.env.MPESA_SHORTCODE!,
  passkey: process.env.MPESA_PASSKEY!,
  callbackUrl: 'https://yourapp.com/api/mpesa/callback',
  env: 'sandbox'
});

// Trigger STK Push — prompts customer on their phone
const result = await mpesa.stkPush({
  phone: '0712345678',   // accepts 07XX, +2547XX, 2547XX — auto-normalized
  amount: 1500,
  reference: 'ORDER-001'
});

console.log(result.checkoutRequestId);
// Parse incoming Daraja callback — one line
const payment = mpesa.parseCallback(req.body);

if (payment.success) {
  console.log(payment.mpesaReceiptNumber); // e.g. "NLJ7RT61SV"
  console.log(payment.amount);             // e.g. 1500
}

// CRITICAL: Always return 200 to stop Daraja retries
res.json({ ResultCode: 0, ResultDesc: 'Accepted' });

Quickstart — Airtel Money

import { UmojaAirtel } from 'umojasdk';

const airtel = new UmojaAirtel({
  clientId: process.env.AIRTEL_CLIENT_ID!,
  clientSecret: process.env.AIRTEL_CLIENT_SECRET!,
  env: 'sandbox'
});

const result = await airtel.requestToPay({
  phone: '0733123456',
  amount: 500,
  reference: 'ORDER-002'
});

Features

| Feature | Status | |---------|--------| | STK Push (Lipa Na M-Pesa) | ✓ | | STK Push status query | ✓ | | C2B URL registration & callbacks | ✓ | | B2C disbursements | ✓ | | B2B transfers | ✓ | | Transaction status query | ✓ | | Transaction reversal | ✓ | | SIM Swap detection (Daraja 3.0) | ✓ | | Tax remittance to KRA (Daraja 3.0) | ✓ | | Airtel Money collections | ✓ | | Airtel Money disbursements | ✓ | | Webhook parsing | ✓ | | Phone number normalization | ✓ | | Automatic token refresh | ✓ | | Exponential backoff retry | ✓ | | Typed errors | ✓ |

Error Handling

import { UmojaAuthError, UmojaValidationError, UmojaApiError } from 'umojasdk';

try {
  const result = await mpesa.stkPush({ phone, amount, reference });
} catch (err) {
  if (err instanceof UmojaAuthError)            { /* bad credentials */ }
  else if (err instanceof UmojaValidationError) { /* bad input */ }
  else if (err instanceof UmojaApiError)        { /* Daraja/Airtel error — check err.raw */ }
}

SIM Swap Fraud Prevention (Daraja 3.0)

async function securePayment(phone: string, amount: number) {
  if (amount >= 10_000) {
    const check = await mpesa.checkSimSwap({ phone, daysToCheck: 30 });
    if (check.swapped) {
      return { blocked: true, reason: 'Additional verification required.' };
    }
  }
  return mpesa.stkPush({ phone, amount, reference: 'ORDER-001' });
}

Multi-Carrier Routing

import { UmojaMpesa, UmojaAirtel, normalizeKenyanPhone } from 'umojasdk';

async function pay(phone: string, amount: number, orderId: string) {
  const prefix = normalizeKenyanPhone(phone).slice(3, 6);
  const safaricomPrefixes = ['712', '722', '700', '711', '710'];

  if (safaricomPrefixes.includes(prefix)) {
    return mpesa.stkPush({ phone, amount, reference: orderId });
  }
  return airtel.requestToPay({ phone, amount, reference: orderId });
}

Environment Variables

MPESA_CONSUMER_KEY=
MPESA_CONSUMER_SECRET=
MPESA_SHORTCODE=174379
MPESA_PASSKEY=
MPESA_CALLBACK_URL=
MPESA_ENV=sandbox         # "sandbox" | "production"

AIRTEL_CLIENT_ID=
AIRTEL_CLIENT_SECRET=
AIRTEL_ENV=sandbox

Related

  • Python SDK: pip install umojasdk
  • CLI: npx @umojasdk/cli init
  • Docs: umojasdk.dev

License

MIT — github.com/Knelso/Umoja_SDK

Built with precision in Nairobi, Kenya. For Africa, by Africa.