📦 Node.js SDK
Integrate CyberVault's AI-powered threat detection, real-time monitoring, and automated compliance checks directly into your Node.js applications.
Installation
Install the CyberVault SDK using your preferred package manager. The package supports both CommonJS and ES Modules.
Install via Package Manager
npm install @cybervault/node-sdk
crypto module.
Quick Start
Initialize the SDK with your API key and start detecting threats in just a few lines of code.
import { CyberVault } from '@cybervault/node-sdk';
// Initialize the client with your API key
const cv = new CyberVault({
apiKey: process.env.CV_API_KEY,
environment: 'production', // or 'sandbox'
timeout: 5000 // milliseconds
});
// Scan a payload for threats
async function analyzePayload(data: string) {
try {
const result = await cv.threats.scan({
content: data,
mode: 'deep'
});
if (result.isThreat) {
console.warn(`Threat detected: ${result.threatType}`);
// Trigger incident response
await cv.incidents.report(result);
}
return result;
} catch (error) {
console.error('Scan failed:', error);
throw error;
}
}
// Usage
analyzePayload('Suspicious input string...');
ConfigurationError if no key is provided.
Configuration
The SDK accepts a configuration object during initialization. All options are optional except apiKey.
| Parameter | Type | Required | Description |
|---|---|---|---|
| apiKey | string | Required | Your CyberVault API key obtained from the dashboard. |
| environment | 'production' | 'sandbox' | Optional | Target environment. Defaults to production. |
| timeout | number | Optional | Request timeout in milliseconds. Defaults to 10000. |
| retries | number | Optional | Number of retry attempts on failure. Defaults to 3. |
| logger | Logger | boolean | Optional | Custom logger instance or false to disable. Defaults to console. |
| webhooks | WebhookConfig | Optional | Configuration for local webhook listeners for real-time events. |
API Reference
threats.scan()
Performs a comprehensive threat analysis on the provided content using CyberVault's AI engine.
interface ScanOptions {
content: string | Buffer; // Data to scan
mode: 'quick' | 'deep' | 'full'; // Scan depth
tags?: string[]; // Custom metadata tags
}
interface ScanResult {
scanId: string;
isThreat: boolean;
threatType: string | null;
confidence: number; // 0.0 to 1.0
indicators: Indicator[];
timestamp: Date;
}
compliance.check()
Validates data or system configurations against specified compliance frameworks (SOC2, GDPR, HIPAA, etc.).
const report = await cv.compliance.check({
framework: 'SOC2',
target: 'user-data-pipeline',
includeRemediation: true
});
console.log(report.score); // e.g., 94.5
console.log(report.violations); // Array of violations
TypeScript Support
The SDK is written in TypeScript and ships with complete type definitions. No additional @types package is required.
// Full type safety out of the box
import type { ScanOptions, CyberVaultError } from '@cybervault/node-sdk';
Error Handling
The SDK throws specific error classes to help you handle failures gracefully.
| Error Class | Description | Common Cause |
|---|---|---|
CyberVaultAuthenticationError |
Invalid or missing API key. | Typo in key, expired token. |
CyberVaultRateLimitError |
Too many requests. | Exceeded plan limits. |
CyberVaultNetworkError |
Connection timeout or DNS failure. | Network issues, firewall blocking. |
CyberVaultValidationError |
Invalid input parameters. | Wrong data types, missing fields. |
import { CyberVaultRateLimitError } from '@cybervault/node-sdk';
try {
await cv.threats.scan('...');
} catch (error) {
if (error instanceof CyberVaultRateLimitError) {
console.warn('Rate limited. Retrying in 5s...');
// Implement exponential backoff
}
}
Resources
Explore additional resources to get the most out of the CyberVault Node.js SDK.