aeglis-sdk
v1.0.3
Published
The official Node.js SDK for **Aeglis** — The Hybrid AI Security Engine. Protect your platform from zero-day phishing, malicious payloads, and macro-viruses in milliseconds. Built for FinTech, HR-Tech, EdTech, and Enterprise Gateways.
Readme
Aeglis Node.js SDK 🛡️
The official Node.js SDK for Aeglis — The Hybrid AI Security Engine. Protect your platform from zero-day phishing, malicious payloads, and macro-viruses in milliseconds. Built for FinTech, HR-Tech, EdTech, and Enterprise Gateways.
📦 Installation
npm install aeglis-sdk
🚀 Quick Start
Get your API Key and Webhook Secret from the Aeglis Developer Dashboard.
const Aeglis = require('aeglis-sdk');
// Initialize with your API Key
const aeglis = new Aeglis('sk_live_YourApiKeyHere');
💻 API Methods
1. Quick Scan (Synchronous)
Best for short text, URLs, and chat moderation. Evaluates intent instantly.
async function moderateChat() {
try {
const result = await aeglis.scan(
"Claim your free prize here: [http://suspicious-link.com](http://suspicious-link.com)",
"user_9982" // (Optional) Your internal tracking ID
);
console.log(result.risk_level); // "DANGER", "WARNING", or "SAFE"
} catch (error) {
console.error(error.message);
}
}
2. Deep File Scan (Asynchronous)
Best for KYC documents, resumes, and user uploads. Scans for hidden macros and zero-day malware. Note: This triggers a background task. The final result is pushed to your configured Webhook.
async function scanUpload() {
try {
const task = await aeglis.deepScan(
'./uploads/candidate_resume.pdf', // Path to the file
{
inputText: "Candidate CV for Software Engineer", // (Optional) Context
endUserId: "candidate_id_5548" // (Optional) Returned in your webhook
}
);
console.log(task.status); // "processing"
console.log(task.message); // "File accepted. Result will be dispatched to your Webhook."
} catch (error) {
console.error(error.message);
}
}
⚡ Webhook Verification (Security)
Aeglis pushes the result of deepScan to your server. To prevent spoofing attacks, you must verify the HMAC SHA-256 signature attached to the request.
The SDK makes this a 1-line process.
⚠️ IMPORTANT: You must pass the Raw Body to the verifier. Do not parse it to JSON before verification.
Express.js Example:
const express = require('express');
const app = express();
const Aeglis = require('aeglis-sdk');
const aeglis = new Aeglis('sk_live_YourApiKeyHere');
const WEBHOOK_SECRET = 'whsec_YourDashboardSecretHere';
// Use express.raw() to preserve the exact payload for hashing
app.post('/aeglis-webhook', express.raw({ type: 'application/json' }), (req, res) => {
// Check both standard header formats
const signature = req.headers['x-aeglis-signature'] || req.headers['aeglis-signature'];
try {
// The SDK verifies the HMAC signature securely
const event = aeglis.verifyWebhook(req.body, signature, WEBHOOK_SECRET);
// Extract parameters from the nested 'data' wrapper
const eventData = event.data || {};
console.log("Verified Event Received!");
console.log(`Risk Level: ${eventData.risk_level}`);
console.log(`Your Tracking ID: ${eventData.user_id}`);
// Action based on result
if (eventData.risk_level === 'DANGER') {
// Block the file in your database
}
res.status(200).send("Webhook Processed");
} catch (error) {
console.error("Webhook Hacker Blocked:", error.message);
res.status(400).send("Invalid Signature");
}
});
🛠️ Error Handling
The SDK automatically parses backend errors and throws clean, readable JavaScript Errors. Always wrap your calls in try/catch blocks.
try {
await aeglis.scan(""); // Missing payload
} catch (error) {
console.log(error.message); // "Aeglis API Error: inputText is required..."
}
🔗 Resources
Engineered in India. Built for the World.
