aeglis-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Aeglis Node.js SDK 🛡️
|
|
2
|
+
|
|
3
|
+
The official Node.js SDK for **Aeglis** — The Hybrid AI Security Engine.
|
|
4
|
+
Protect your platform from zero-day phishing, malicious payloads, and macro-viruses in milliseconds. Built for FinTech, HR-Tech, EdTech, and Enterprise Gateways.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## 📦 Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install aeglis-sdk
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 🚀 Quick Start
|
|
17
|
+
|
|
18
|
+
Get your API Key and Webhook Secret from the [Aeglis Developer Dashboard](https://developer.aeglis.com).
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
const Aeglis = require('aeglis-sdk');
|
|
22
|
+
|
|
23
|
+
// Initialize with your API Key
|
|
24
|
+
const aeglis = new Aeglis('sk_live_YourApiKeyHere');
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 💻 API Methods
|
|
31
|
+
|
|
32
|
+
### 1. Quick Scan (Synchronous)
|
|
33
|
+
|
|
34
|
+
Best for short text, URLs, and chat moderation. Evaluates intent instantly.
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
async function moderateChat() {
|
|
38
|
+
try {
|
|
39
|
+
const result = await aeglis.scan(
|
|
40
|
+
"Claim your free prize here: [http://suspicious-link.com](http://suspicious-link.com)",
|
|
41
|
+
"user_9982" // (Optional) Your internal tracking ID
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
console.log(result.risk_level); // "DANGER", "WARNING", or "SAFE"
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(error.message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Deep File Scan (Asynchronous)
|
|
53
|
+
|
|
54
|
+
Best for KYC documents, resumes, and user uploads. Scans for hidden macros and zero-day malware.
|
|
55
|
+
*Note: This triggers a background task. The final result is pushed to your configured Webhook.*
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
async function scanUpload() {
|
|
59
|
+
try {
|
|
60
|
+
const task = await aeglis.deepScan(
|
|
61
|
+
'./uploads/candidate_resume.pdf', // Path to the file
|
|
62
|
+
{
|
|
63
|
+
inputText: "Candidate CV for Software Engineer", // (Optional) Context
|
|
64
|
+
endUserId: "candidate_id_5548" // (Optional) Returned in your webhook
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
console.log(task.status); // "processing"
|
|
69
|
+
console.log(task.message); // "File accepted. Result will be dispatched to your Webhook."
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error(error.message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## ⚡ Webhook Verification (Security)
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
The SDK makes this a 1-line process.
|
|
84
|
+
|
|
85
|
+
**⚠️ IMPORTANT:** You must pass the **Raw Body** to the verifier. Do not parse it to JSON before verification.
|
|
86
|
+
|
|
87
|
+
### Express.js Example:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
const express = require('express');
|
|
91
|
+
const app = express();
|
|
92
|
+
const Aeglis = require('aeglis-sdk');
|
|
93
|
+
const aeglis = new Aeglis('sk_live_YourApiKeyHere');
|
|
94
|
+
|
|
95
|
+
const WEBHOOK_SECRET = 'whsec_YourDashboardSecretHere';
|
|
96
|
+
|
|
97
|
+
// Use express.raw() to preserve the exact payload for hashing
|
|
98
|
+
app.post('/aeglis-webhook', express.raw({ type: 'application/json' }), (req, res) => {
|
|
99
|
+
const signature = req.headers['x-aeglis-signature'];
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
// The SDK verifies the HMAC signature securely
|
|
103
|
+
const event = aeglis.verifyWebhook(req.body, signature, WEBHOOK_SECRET);
|
|
104
|
+
|
|
105
|
+
console.log("Verified Event Received!");
|
|
106
|
+
console.log(`Risk Level: ${event.risk_level}`);
|
|
107
|
+
console.log(`Your Tracking ID: ${event.user_id}`);
|
|
108
|
+
|
|
109
|
+
// Action based on result
|
|
110
|
+
if (event.risk_level === 'DANGER') {
|
|
111
|
+
// Block the file in your database
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
res.status(200).send("Webhook Processed");
|
|
115
|
+
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error("Webhook Hacker Blocked:", error.message);
|
|
118
|
+
res.status(400).send("Invalid Signature");
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 🛠️ Error Handling
|
|
127
|
+
|
|
128
|
+
The SDK automatically parses backend errors and throws clean, readable JavaScript Errors. Always wrap your calls in `try/catch` blocks.
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
try {
|
|
132
|
+
await aeglis.scan(""); // Missing payload
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.log(error.message); // "Aeglis API Error: inputText is required..."
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 🔗 Resources
|
|
140
|
+
|
|
141
|
+
* [Developer Documentation](https://www.google.com/search?q=https://docs.aeglis.com)
|
|
142
|
+
* [Aeglis Main Website](https://aeglis.com)
|
|
143
|
+
* [Report a Bug / Support]()
|
|
144
|
+
|
|
145
|
+
**Engineered in India. Built for the World.**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aeglis-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "The official Node.js SDK for **Aeglis** — The Hybrid AI Security Engine. \r Protect your platform from zero-day phishing, malicious payloads, and macro-viruses in milliseconds. Built for FinTech, HR-Tech, EdTech, and Enterprise Gateways.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|