@sievefraud/node
v0.1.1
Published
Official Node.js client for the Sieve fraud-prevention API.
Readme
@sievefraud/node
Official Node.js client for Sieve, which provides real-time fraud prevention, transaction monitoring and sanctions screening.
npm install @sievefraud/nodeimport { Sieve, verifyWebhook } from '@sievefraud/node'
const sieve = new Sieve(process.env.SIEVE_KEY)
const d = await sieve.events.create({
type: 'payout.requested',
customer_id: user.id,
amount: 48000,
destination: { type: 'mpesa', account: payout.phone },
})
if (d.decision === 'block') return res.status(403).json({ error: 'Payout held for review' })- Zero dependencies; Node 18+; TypeScript types included.
- Retries network errors, 429 and 5xx responses with backoff, and honours
Retry-After. - Adds an idempotency key to every event, so retries never count twice.
API
| Method | Calls |
| --- | --- |
| sieve.events.create(event) | POST /v1/events: returns the decision, reasons and probability of fraud |
| sieve.customers.get(id) | GET /v1/customers/:id |
| sieve.feedback({ event_id, label }) | POST /v1/feedback: tell Sieve whether it was right |
| sieve.screen({ name, dob?, nationality? }) | POST /v1/screen: sanctions and PEP check for a name |
| verifyWebhook(rawBody, signature, secret) | Checks the Sieve-Signature header on a webhook delivery (pass the raw body) |
Options: new Sieve(key, { timeout: 5000, maxRetries: 2, baseUrl }). Set baseUrl only when Sieve runs on your own servers.
Failed calls throw a SieveError with status, code, message and details. status is 0 when Sieve can't be reached after retries.
Full documentation: sievefraud.com/docs/sdk.
Renamed from Snare
Sieve was called Snare before. The old exports (Snare, SnareError, SnareOptions, SnareEvent) remain as deprecated aliases, keys issued as snr_live_… / snr_test_… keep working, and webhook deliveries still carry the legacy Snare-Signature header with the same value.
