@seckav/security-sdk
Version:
SecKav Security SDK - Enterprise-grade security platform with AI-powered threat detection, LLM-powered misconfiguration scanning (Gemini/GPT-4/Claude), end-to-end encryption, behavioral analysis, enhanced file scanning, adaptive rate limiting, GDPR/DPDP/C
191 lines • 6.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComplianceModule = void 0;
const axios_1 = __importDefault(require("axios"));
/**
* Compliance Module - GDPR, DPDP, and CERT-IN compliance reporting
* Provides comprehensive compliance assessment and reporting capabilities
*/
class ComplianceModule {
constructor(config) {
this.config = config;
}
/**
* Generate a new compliance report
*/
async generateComplianceReport(token, reportType, period) {
try {
const response = await axios_1.default.post(`${this.config.apiUrl}/api/compliance/reports`, {
reportType,
period,
}, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
timeout: this.config.timeout || 30000, // Longer timeout for report generation
});
return response.data.report;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to generate compliance report: ${error}`);
}
}
/**
* Get compliance reports with filtering options
*/
async getComplianceReports(token, options = {}) {
try {
const response = await axios_1.default.get(`${this.config.apiUrl}/api/compliance/reports`, {
headers: {
Authorization: `Bearer ${token}`,
},
params: options,
timeout: this.config.timeout || 10000,
});
return response.data;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to fetch compliance reports: ${error}`);
}
}
/**
* Get a specific compliance report by ID
*/
async getComplianceReport(token, reportId) {
try {
const response = await axios_1.default.get(`${this.config.apiUrl}/api/compliance/reports/${reportId}`, {
headers: {
Authorization: `Bearer ${token}`,
},
timeout: this.config.timeout || 10000,
});
return response.data.report;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to fetch compliance report: ${error}`);
}
}
/**
* Get compliance dashboard data
*/
async getComplianceDashboard(token) {
try {
const response = await axios_1.default.get(`${this.config.apiUrl}/api/compliance/dashboard`, {
headers: {
Authorization: `Bearer ${token}`,
},
timeout: this.config.timeout || 10000,
});
return response.data.dashboard;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to fetch compliance dashboard: ${error}`);
}
}
/**
* Scan OpenAPI/Swagger specification for security issues
*/
async scanApiSpecification(token, file) {
try {
const response = await axios_1.default.post(`${this.config.apiUrl}/api/compliance/api-scan`, {
fileName: file.name,
fileContent: file.content,
scanType: file.type,
}, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
timeout: this.config.timeout || 20000, // Longer timeout for API scanning
});
return response.data.scan;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to scan API specification: ${error}`);
}
}
/**
* Get API security scans
*/
async getApiSecurityScans(token, options = {}) {
try {
const response = await axios_1.default.get(`${this.config.apiUrl}/api/compliance/api-scans`, {
headers: {
Authorization: `Bearer ${token}`,
},
params: options,
timeout: this.config.timeout || 10000,
});
return response.data;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to fetch API security scans: ${error}`);
}
}
/**
* Export compliance report in various formats
*/
async exportComplianceReport(token, reportId, format = 'pdf') {
try {
const response = await axios_1.default.post(`${this.config.apiUrl}/api/compliance/reports/${reportId}/export`, { format }, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
timeout: this.config.timeout || 15000,
});
return response.data;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to export compliance report: ${error}`);
}
}
/**
* Get compliance status for specific standards
*/
async getComplianceStatus(token, standards) {
try {
const response = await axios_1.default.post(`${this.config.apiUrl}/api/compliance/status`, { standards }, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
timeout: this.config.timeout || 10000,
});
return response.data.status;
}
catch (error) {
if (this.config.onError) {
this.config.onError(error);
}
throw new Error(`Failed to fetch compliance status: ${error}`);
}
}
}
exports.ComplianceModule = ComplianceModule;
//# sourceMappingURL=Compliance.js.map