Scan your whole stack
From OX Research Newsroom
Are you using chapaa?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.2.7
chapaa was last scanned on 29 Nov 2026 at version 0.2.7. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.2.7 LATEST | 29 Nov 2026 | No rules fired |
| 0.2.6 | 28 Nov 2026 | No rules fired |
| 0.2.5 | 28 Nov 2026 | No rules fired |
| 0.2.4 | 28 Nov 2026 | Not shown |
| 0.2.3 | 28 Nov 2026 | Not shown |
Findings for v0.2.7. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.2.7; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
A local emulator for African mobile-money APIs. Point your existing M-Pesa (Daraja) code at localhost and get realistic callbacks and failures. No KYC, no sandbox credentials, no internet.
Website and live demo: https://godanaemiru.github.io/chapaa/: press a test phone number and see the exact callback chapaa sends.
Alpha. chapaa has not yet been checked against the real sandboxes. The Daraja response shapes follow the Daraja v3 docs (read through a third-party mirror); the MTN MoMo shapes are mostly from memory and unconfirmed. Treat a passing test against chapaa as "matches what we believe", and still test against the real sandbox before going live. See Contract tests for exactly what is verified, and issues and recorded fixtures are very welcome.
Supported: Daraja (STK Push, C2B, B2C, Transaction Status, Reversal, Account Balance) and MTN MoMo (Collections, Disbursements).
Checked against real client code: the Daraja flows run unmodified through the npm libraries mpesa-api, @kepas/daraja-js, daraja.js and daraja-sdk-ts (pointed at chapaa with a network redirect, since none of them has a base-URL option), including their callback parsers. That shows chapaa is compatible with what typical clients send and parse, not that it matches the real sandbox.
npx chapaa # http://localhost:8080
From a clone:
npm install
npm run dev
Inspector UI: http://localhost:8080/__chapaa/
Pick the outcome with a magic phone number or the X-Chapaa-Scenario header (header wins).
| Phone | Scenario | Behaviour |
|---|---|---|
254700000001 |
user_cancelled |
callback ResultCode 1032 |
254700000002 |
insufficient_funds |
callback ResultCode 1 |
254700000003 |
timeout |
no callback; query returns 1037 |
254700000004 |
duplicate_callback |
success callback delivered twice |
254700000005 |
delayed_callback |
success state now, callback after 90s |
46733123451–55 |
same five, for MTN MoMo | MoMo callbacks are POST (without payerMessage); a failure's reason is a string such as APPROVAL_REJECTED, NOT_ENOUGH_FUNDS or EXPIRED |
254700000006 / 46733123456 |
early_callback |
the callback is delivered before the API call returns, to catch code that stores the transaction id only after the response |
| anything else | success |
success callback after 2s |
| Variable | Default | |
|---|---|---|
PORT |
8080 |
|
CHAPAA_CALLBACK_DELAY_MS |
2000 |
delay before the outcome is final |
CHAPAA_DELAYED_CALLBACK_MS |
90000 |
delay for delayed_callback |
CHAPAA_DB |
unset | SQLite file path; see Persistence |
CHAPAA_REWRITE_LOCALHOST_TO |
unset | e.g. host.docker.internal, so callbacks to localhost reach the host from inside Docker |
Run the emulator in CI next to your tests. It works on Linux, macOS and Windows runners.
steps:
- uses: actions/checkout@v4
- uses: godanaemiru/chapaa@v0.2.7
id: chapaa
with:
callback-delay-ms: 200
chaos-seed: 1
- run: npm test
env:
DARAJA_BASE_URL: ${{ steps.chapaa.outputs.url }} # also exported to every later step as CHAPAA_URL
- if: failure()
run: cat "${{ steps.chapaa.outputs.log-file }}"
http://127.0.0.1:8080 (change with port). Callback URLs pointing at localhost work as they are, because everything runs on the same machine.POST $CHAPAA_URL/__chapaa/reset between test files so they start clean, and PUT $CHAPAA_URL/__chapaa/chaos to turn faults on for one test.port, db, callback-delay-ms, delayed-callback-ms, rewrite-localhost-to, chaos-http-error-rate, chaos-outcome-failure-rate, chaos-latency-ms, chaos-callback-jitter-ms, chaos-seed, retry-max-attempts, retry-base-delay-ms, retry-factor, plus node-version (default 22), wait-timeout (default 30 s) and package.package: local (the default) builds the chapaa source that ships with the action, which takes about 20 s. Once chapaa is published to npm, package: chapaa@x.y.z skips the build.By default all state is in memory and lost on exit. Set CHAPAA_DB=./chapaa.db to keep it in a SQLite file: transactions with their callback history, C2B URL registrations and MoMo API users survive restarts.
docker run -p 8080:8080 -v chapaa-data:/data -e CHAPAA_DB=/data/chapaa.db chapaa
docker run command with MSYS_NO_PATHCONV=1, or Git Bash rewrites /data/chapaa.db into a Windows path.node:sqlite, which prints an experimental warning). Without CHAPAA_DB it still runs on Node 20.ResultCode 1037, MoMo FAILED/EXPIRED), since their timers are gone. Callbacks that were scheduled but not yet sent, such as a 90 s delayed_callback, are dropped.POST /__chapaa/reset clears the stored transactions too. Registrations and API users are kept.Off by default. Faults apply to provider routes only, never to /__chapaa/*.
| Variable | Effect |
|---|---|
CHAPAA_CHAOS_HTTP_ERROR_RATE |
fraction (0–1) of API requests answered 503 before processing |
CHAPAA_CHAOS_OUTCOME_FAILURE_RATE |
fraction of transactions with no magic phone or header that get a random non-success scenario |
CHAPAA_CHAOS_CALLBACK_JITTER_MS |
each callback is delayed by a random 0–N ms extra, so callbacks for transactions started close together arrive in a different order than they were created |
CHAPAA_CHAOS_LATENCY_MS |
min-max (or a single value) added to every API request |
CHAPAA_CHAOS_SEED |
makes the random choices reproducible, for CI |
Change it while running, e.g. per test: PUT /__chapaa/chaos with {"httpErrorRate": 0.2, "latencyMs": {"min": 100, "max": 800}}; GET shows the current values. Explicit scenarios (magic phone, header) are never overridden by chaos.
By default each callback is sent once. Set CHAPAA_RETRY_MAX_ATTEMPTS above 1 to retry on connection errors and non-2xx responses, waiting CHAPAA_RETRY_BASE_DELAY_MS (default 1000) × CHAPAA_RETRY_FACTOR (default 2) to the power of the attempt. Each attempt is listed in the inspector. Whether and how the real providers retry is unverified, so match it to your own provider's docs. Validation calls and manual resends are never retried.
GET /oauth/v1/generate, POST /mpesa/stkpush/v1/processrequest, POST /mpesa/stkpushquery/v1/queryPOST /mpesa/c2b/{v1,v2}/registerurl, POST /mpesa/c2b/v1/simulate. Simulate calls your ValidationURL first (reply {"ResultCode":"0"} to accept), then your ConfirmationURL. If validation is unreachable, ResponseType decides (Completed accepts, Cancelled rejects).POST /mpesa/b2c/{v1,v3}/paymentrequest with an async result to ResultURL. user_cancelled maps to ResultCode 2001, insufficient_funds to 1.POST /mpesa/transactionstatus/v1/query and Reversal POST /mpesa/reversal/v1/request: look up the original by receipt number (from an STK callback, C2B TransID or B2C result). An unknown id returns 400. A second reversal returns result code 11.POST /v1_0/apiuser, POST /v1_0/apiuser/:id/apikey, GET /v1_0/apiuser/:id, POST /{collection,disbursement}/token, POST /collection/v1_0/requesttopay + GET …/:ref, POST /disbursement/v1_0/transfer + GET …/:ref, GET /{collection,disbursement}/v1_0/account/balance (static 1000 EUR for now). Duplicate X-Reference-Id returns 409. Credentials and subscription keys are accepted without checking.GET /__chapaa/transactions, GET/PUT /__chapaa/chaos, POST /__chapaa/reset, POST /__chapaa/transactions/:id/resendSee the MVP scope: Daraja C2B/B2C/Reversal/Transaction Status, MTN MoMo collections and disbursements, contract tests against real sandboxes.
npm test includes a contract suite (test/contract.test.ts) that drives chapaa and compares every response and callback with a fixture in contracts/: same keys, same JSON types, and a few exact values such as ResponseCode: "0". It catches emulator drift, for example a missing ResultParameter or a number where the real API sends a string.
Each fixture says where it came from:
source |
Meaning | Count |
|---|---|---|
sandbox |
observed on the real Daraja and MTN MoMo sandboxes (2026-11-28 and 2026-11-29) | 21 |
docs-mirror |
written from the Daraja v3 docs, read through a third-party GitHub mirror of the Safaricom pages, not the official portal | 8 |
unverified |
written from memory; the suite only pins current behaviour | 6 |
Seven of the 21 sandbox fixtures are MoMo: the API user, API key and token calls, the request to pay (HTTP 202), the duplicate-reference error (HTTP 409), the status of a failed payment, and its callback. The other fourteen are Daraja: the OAuth token, the STK Push response, the STK query both while pending (HTTP 200 with result code 4999) and once settled, a real STK callback (a cancelled payment, code 1032), the C2B simulate response, the B2C, Account Balance and Reversal responses, three error bodies (missing Authorization header on STK Push and on OAuth, and a bad request), and two failure results: B2C with 2001 ("The initiator information is invalid.") and a reversal of an unknown transaction with R000002. The B2C failure and the reversal failure match what the docs mirror showed. Successful B2C, Transaction Status and Reversal results, and the Account Balance result, are not recorded: the sandbox rejected our initiator security credential in two runs (2001), and the balance result's ErrorMsg says why: "The current security credential of the user has expired." Recording them needs a sandbox initiator whose credential is still valid. The five unverified MoMo fixtures are the successful payment and its callback, Disbursements and the balance. Treat a green run as "matches what we believe", not "matches the provider", until a full recording has been made.
Real recordings have corrected chapaa twice so far. A pending STK query was emulated as an HTTP 500 error, and the sandbox usually returns a normal 200 with result code 4999 ("The transaction is still under processing"). A cancelled payment's description was "Request cancelled by user", and the sandbox sends "Request Cancelled by user." with a capital C and a full stop.
Behaviour that chapaa does not reproduce yet:
errorCode 500.001.1001 and an empty errorMessage, instead of the usual 200 with 4999. It is not deterministic, and chapaa always returns the 200 form.2001 with parameters ActionType, ErrorMsg and BOCompletedTime. chapaa has no failing balance scenario.500.003.1001, "Service is currently unreachable") in every recording run, so it isn't recorded, and neither is the C2B confirmation callback that depends on it.Needs sandbox credentials (not included). The recorder writes contracts/recorded/<id>.json, which overrides the matching fixture on the next test run, and prints which fixtures it could not record. Its request flow was exercised only against chapaa itself (as a stand-in server), never against the live sandboxes, so expect to adjust it on the first real run.
# Daraja
DARAJA_CONSUMER_KEY=... DARAJA_CONSUMER_SECRET=... DARAJA_PASSKEY=... DARAJA_PHONE=2547... \
npm run contract:record -- daraja
# MTN MoMo (the callback host must be a hostname, not an IP)
MOMO_COLLECTION_KEY=... MOMO_CALLBACK_HOST=example.com npm run contract:record -- momo
What each extra variable unlocks:
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.