@iota-big3/sdk-gateway
Version:
Universal API Gateway with protocol translation, intelligent routing, rate limiting, health checking, and caching
261 lines • 10.2 kB
JavaScript
;
/**
* Compliance and Regulatory Type Definitions
*
* @module compliance-types
* @description Comprehensive types for regulatory compliance including:
* - FERPA (Family Educational Rights and Privacy Act)
* - HIPAA (Health Insurance Portability and Accountability Act)
* - GDPR (General Data Protection Regulation)
* - PCI-DSS (Payment Card Industry Data Security Standard)
* - SOX (Sarbanes-Oxley Act)
*
* All types are designed to be AI/debugging friendly with:
* - Descriptive names that explain their purpose
* - Comprehensive JSDoc comments
* - Built-in validation helpers
* - Clear error messages
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.complianceTypes = exports.SOXControlCategory = exports.GDPRDataCategory = exports.PHICategory = exports.FERPARecordType = exports.DataSubjectRight = exports.LawfulBasis = exports.DataClassification = exports.ComplianceFramework = void 0;
exports.requiresEncryption = requiresEncryption;
exports.calculateRetentionPeriod = calculateRetentionPeriod;
exports.validateConsent = validateConsent;
// ============================================
// Core Compliance Types
// ============================================
/**
* Compliance framework identifier
* Each framework has specific requirements and validation rules
*/
var ComplianceFramework;
(function (ComplianceFramework) {
ComplianceFramework["FERPA"] = "FERPA";
ComplianceFramework["HIPAA"] = "HIPAA";
ComplianceFramework["GDPR"] = "GDPR";
ComplianceFramework["PCI_DSS"] = "PCI_DSS";
ComplianceFramework["SOX"] = "SOX";
ComplianceFramework["COPPA"] = "COPPA";
ComplianceFramework["CCPA"] = "CCPA";
ComplianceFramework["ISO27001"] = "ISO27001";
ComplianceFramework["SOC2"] = "SOC2";
})(ComplianceFramework || (exports.ComplianceFramework = ComplianceFramework = {}));
/**
* Data classification levels
* Determines handling requirements and access controls
*/
var DataClassification;
(function (DataClassification) {
/** Publicly available information */
DataClassification["Public"] = "PUBLIC";
/** Internal use only */
DataClassification["Internal"] = "INTERNAL";
/** Confidential business information */
DataClassification["Confidential"] = "CONFIDENTIAL";
/** Restricted - highest security (PII, PHI, payment data) */
DataClassification["Restricted"] = "RESTRICTED";
})(DataClassification || (exports.DataClassification = DataClassification = {}));
/**
* Lawful basis for data processing under GDPR
*/
var LawfulBasis;
(function (LawfulBasis) {
LawfulBasis["Consent"] = "CONSENT";
LawfulBasis["Contract"] = "CONTRACT";
LawfulBasis["LegalObligation"] = "LEGAL_OBLIGATION";
LawfulBasis["VitalInterests"] = "VITAL_INTERESTS";
LawfulBasis["PublicTask"] = "PUBLIC_TASK";
LawfulBasis["LegitimateInterests"] = "LEGITIMATE_INTERESTS";
})(LawfulBasis || (exports.LawfulBasis = LawfulBasis = {}));
/**
* Data subject rights under various regulations
*/
var DataSubjectRight;
(function (DataSubjectRight) {
// GDPR Rights
DataSubjectRight["Access"] = "ACCESS";
DataSubjectRight["Rectification"] = "RECTIFICATION";
DataSubjectRight["Erasure"] = "ERASURE";
DataSubjectRight["Portability"] = "PORTABILITY";
DataSubjectRight["Restriction"] = "RESTRICTION";
DataSubjectRight["Object"] = "OBJECT";
DataSubjectRight["AutomatedDecisionMaking"] = "AUTOMATED_DECISION_MAKING";
// FERPA Rights
DataSubjectRight["InspectRecords"] = "INSPECT_RECORDS";
DataSubjectRight["RequestAmendment"] = "REQUEST_AMENDMENT";
DataSubjectRight["ConsentToDisclosure"] = "CONSENT_TO_DISCLOSURE";
// CCPA Rights
DataSubjectRight["OptOut"] = "OPT_OUT";
DataSubjectRight["KnowAboutInfo"] = "KNOW_ABOUT_INFO";
DataSubjectRight["Delete"] = "DELETE";
DataSubjectRight["NonDiscrimination"] = "NON_DISCRIMINATION";
})(DataSubjectRight || (exports.DataSubjectRight = DataSubjectRight = {}));
/**
* Types of education records under FERPA
*/
var FERPARecordType;
(function (FERPARecordType) {
FERPARecordType["AcademicTranscript"] = "ACADEMIC_TRANSCRIPT";
FERPARecordType["DisciplinaryRecord"] = "DISCIPLINARY_RECORD";
FERPARecordType["FinancialRecord"] = "FINANCIAL_RECORD";
FERPARecordType["MedicalRecord"] = "MEDICAL_RECORD";
FERPARecordType["CounselingRecord"] = "COUNSELING_RECORD";
FERPARecordType["AttendanceRecord"] = "ATTENDANCE_RECORD";
FERPARecordType["GradeReport"] = "GRADE_REPORT";
FERPARecordType["StandardizedTestScore"] = "STANDARDIZED_TEST_SCORE";
FERPARecordType["IEP"] = "IEP";
FERPARecordType["BehavioralAssessment"] = "BEHAVIORAL_ASSESSMENT";
})(FERPARecordType || (exports.FERPARecordType = FERPARecordType = {}));
/**
* Categories of Protected Health Information
*/
var PHICategory;
(function (PHICategory) {
PHICategory["Demographics"] = "DEMOGRAPHICS";
PHICategory["MedicalHistory"] = "MEDICAL_HISTORY";
PHICategory["TestResults"] = "TEST_RESULTS";
PHICategory["MentalHealthRecords"] = "MENTAL_HEALTH_RECORDS";
PHICategory["Insurance"] = "INSURANCE";
PHICategory["Billing"] = "BILLING";
PHICategory["ClinicalNotes"] = "CLINICAL_NOTES";
PHICategory["Prescriptions"] = "PRESCRIPTIONS";
PHICategory["DeviceData"] = "DEVICE_DATA";
PHICategory["GeneticInformation"] = "GENETIC_INFORMATION";
})(PHICategory || (exports.PHICategory = PHICategory = {}));
/**
* GDPR data categories
*/
var GDPRDataCategory;
(function (GDPRDataCategory) {
GDPRDataCategory["Identification"] = "IDENTIFICATION";
GDPRDataCategory["Contact"] = "CONTACT";
GDPRDataCategory["Financial"] = "FINANCIAL";
GDPRDataCategory["Location"] = "LOCATION";
GDPRDataCategory["Online"] = "ONLINE";
GDPRDataCategory["Professional"] = "PROFESSIONAL";
GDPRDataCategory["Special"] = "SPECIAL";
GDPRDataCategory["Criminal"] = "CRIMINAL";
GDPRDataCategory["Children"] = "CHILDREN"; // Under 16 years
})(GDPRDataCategory || (exports.GDPRDataCategory = GDPRDataCategory = {}));
/**
* SOX control categories
*/
var SOXControlCategory;
(function (SOXControlCategory) {
SOXControlCategory["EntityLevel"] = "ENTITY_LEVEL";
SOXControlCategory["ITGeneral"] = "IT_GENERAL";
SOXControlCategory["Application"] = "APPLICATION";
SOXControlCategory["EndUserComputing"] = "END_USER_COMPUTING";
SOXControlCategory["FinancialReporting"] = "FINANCIAL_REPORTING";
SOXControlCategory["DisclosureControls"] = "DISCLOSURE_CONTROLS";
})(SOXControlCategory || (exports.SOXControlCategory = SOXControlCategory = {}));
// ============================================
// Compliance Validation Functions
// ============================================
/**
* Check if data requires encryption under compliance rules
*/
function requiresEncryption(classification, framework) {
// Restricted always requires encryption
if (classification === DataClassification.Restricted) {
return true;
}
// HIPAA and PCI-DSS require encryption for confidential data
if (classification === DataClassification.Confidential) {
return framework.some(f => f === ComplianceFramework.HIPAA ||
f === ComplianceFramework.PCI_DSS);
}
return false;
}
/**
* Calculate data retention period based on compliance requirements
*/
function calculateRetentionPeriod(dataType, frameworks) {
// This is a simplified example - real implementation would be more complex
const retentionRules = {
'financial-records': {
[ComplianceFramework.SOX]: 'P7Y', // 7 years
[ComplianceFramework.PCI_DSS]: 'P1Y', // 1 year minimum
},
'education-records': {
[ComplianceFramework.FERPA]: 'P5Y', // 5 years after graduation
},
'health-records': {
[ComplianceFramework.HIPAA]: 'P6Y', // 6 years
}
};
// Return the longest retention period required
let maxPeriod = 'P1Y'; // Default 1 year
for (const framework of frameworks) {
const rule = retentionRules[dataType]?.[framework];
if (rule && rule > maxPeriod) {
maxPeriod = rule;
}
}
return maxPeriod;
}
/**
* Validate consent adequacy for data processing
*/
function validateConsent(consent, purpose, framework) {
if (framework === ComplianceFramework.GDPR && 'purposes' in consent) {
const gdprConsent = consent;
const hasPurpose = gdprConsent.purposes.some(p => p.purpose === purpose && p.granted);
if (!hasPurpose) {
return {
success: false,
error: `No valid consent for purpose: ${purpose}`
};
}
if (gdprConsent.withdrawnAt) {
return {
success: false,
error: 'Consent has been withdrawn'
};
}
}
if (framework === ComplianceFramework.FERPA && 'recordsToDisclose' in consent) {
const ferpaConsent = consent;
if (ferpaConsent.revoked) {
return {
success: false,
error: 'Consent has been revoked'
};
}
const now = new Date();
const validFrom = new Date(ferpaConsent.validFrom);
const validUntil = ferpaConsent.validUntil ? new Date(ferpaConsent.validUntil) : null;
if (now < validFrom) {
return {
success: false,
error: 'Consent not yet valid'
};
}
if (validUntil && now > validUntil) {
return {
success: false,
error: 'Consent has expired'
};
}
}
return { success: true, data: true };
}
// ============================================
// Export Compliance Types
// ============================================
exports.complianceTypes = {
// Enums
ComplianceFramework,
DataClassification,
LawfulBasis,
DataSubjectRight,
FERPARecordType,
PHICategory,
GDPRDataCategory,
SOXControlCategory,
// Functions
requiresEncryption,
calculateRetentionPeriod,
validateConsent
};
//# sourceMappingURL=compliance-types.js.map