primedefender-client
v0.1.5
Published
TypeScript types and helpers for PrimeDefender bridge /ingest incident payloads.
Downloads
74
Maintainers
Readme
primedefender-client
TypeScript types and a small fetch helper to POST incidents to a PrimeDefender bridge (/ingest), aligned with the Python package primedefender-fastapi.
Install
npm install primedefender-clientUsage
import {
postIncident,
resolveIngestUrl,
type PrimeDefenderIncidentPayload,
} from "primedefender-client";
const payload: PrimeDefenderIncidentPayload = {
from: { lat: 35.0, lon: 139.0 },
to: { lat: -8.67, lon: 115.21 },
category: "intrusion",
severity: "high",
sourceLabel: "Japan, Tokyo",
targetLabel: "my-site · Indonesia, Bali",
siteId: "my-site",
createdAt: Date.now(),
blocked: true,
action: "blocked",
path: "/api/x",
method: "GET",
attackerIp: "203.0.113.1",
userAgent: "curl/8",
detection: "sqli",
requestId: "req-123",
forwardedFor: "203.0.113.1",
targetService: "primestudio-api",
detectType: "sqli",
detectConfidence: 0.96,
responseStatus: 403,
responseTimeMs: 12,
mitigation: "request_block",
ipIntelIsp: "Example ISP",
requestsLast1m: 25,
};
const ingestUrl = resolveIngestUrl(process.env.PRIMEDEFENDER_BRIDGE_URL!);
const result = await postIncident({
ingestUrl,
apiKey: process.env.PRIMEDEFENDER_API_KEY!,
payload,
});
console.log(result.ok, result.status, result.bodyText);Browser
The bridge must send CORS headers allowing your web app origin. Server-side (Node/BFF) avoids CORS issues.
Publish to npm (maintainers)
- Login once:
npm login(npm account + 2FA if enabled). - Bump
versioninpackage.jsonfor each release. - From this folder:
npm install
npm run build
npm publish --access publicScoped packages (@scope/name) need --access public on first publish; unscoped primedefender-client is public by default.
License
MIT
