/** * @lanonasis/privacy-sdk * * Enterprise-grade privacy utilities for data masking, PII detection, * tokenization, and GDPR compliance. * * Part of the LanOnasis Security Suite. */ type PIIType = 'email' | 'phone' | 'ssn' | 'credit-card' | 'name' | 'address' | 'dob' | 'ip-address' | 'iban' | 'passport' | 'driver-license' | 'uk-nino' | 'uk-postcode' | 'custom'; type Locale = 'US' | 'UK' | 'DE' | 'FR' | 'EU' | 'JP' | 'AU' | 'CA'; type SensitivityLevel = 'low' | 'medium' | 'high' | 'critical'; interface MaskingOptions { type: PIIType; maskChar?: string; showFirst?: number; showLast?: number; preserveFormat?: boolean; preserveLength?: boolean; locale?: Locale; pattern?: string | RegExp; } interface DetectionResult { type: PIIType; value: string; masked: string; position: number; length: number; confidence: number; sensitivity: SensitivityLevel; regulations: string[]; } interface ScanOptions { deep?: boolean; includeFieldNames?: boolean; confidenceThreshold?: number; autoMask?: boolean; } interface PrivacyConfig { enableMasking: boolean; defaultMaskChar: string; preserveFormat: boolean; enableAutoDetect: boolean; confidenceThreshold: number; detectFieldNames: boolean; gdprMode: boolean; auditLog: boolean; logLevel: 'none' | 'basic' | 'verbose'; /** Optional: Onasis Gateway URL for due-diligence (KYC/KYB) – central point for verification */ gatewayUrl?: string; /** Optional: API key for gateway (e.g. x-api-key); set with gatewayUrl to enable verifyIdentity / getVerificationStatus */ apiKey?: string; } interface AuditEntry { timestamp: Date; operation: 'mask' | 'detect' | 'tokenize' | 'detokenize' | 'scan'; dataType?: PIIType; field?: string; actor?: string; reason?: string; success: boolean; } interface PatternDefinition { type: PIIType; pattern: RegExp; sensitivity: SensitivityLevel; regulations: string[]; validate?: (value: string) => boolean; locale?: Locale[]; } declare const DEFAULT_CONFIG: PrivacyConfig; declare class PrivacySDK { private config; private crypto; private customPatterns; private auditLog; constructor(config?: Partial); /** * Mask sensitive data based on type */ mask(data: string, type: PIIType, options?: Partial): string; /** * Batch mask multiple values */ maskBatch(items: Array<{ value: string; type: PIIType; options?: Partial; }>): string[]; private maskEmail; private maskPhone; private maskSSN; private maskCreditCard; private maskIBAN; private maskIP; private maskUKNINO; private maskUKPostcode; private maskName; private maskCustom; private maskGeneric; /** * Detect PII in text */ detect(text: string, options?: { locale?: Locale; }): DetectionResult[]; /** * Detect PII and return masked text */ detectAndMask(text: string, options?: { locale?: Locale; }): string; /** * Scan an object recursively for PII */ scan(obj: unknown, options?: ScanOptions): { piiFound: boolean; results: Array<{ path: string; type: PIIType; value: string; masked: string; }>; sanitized?: unknown; }; /** * Classify a single value */ classify(value: string): { type: PIIType | 'unknown'; sensitivity: SensitivityLevel; confidence: number; regulations: string[]; }; /** * Sanitize object by masking specified fields */ sanitizeObject>(obj: T, fieldMappings: Record): T; /** * Generate deterministic anonymous ID */ generateAnonymousId(originalId: string, salt?: string): string; /** * Generate random token */ generateToken(length?: number): string; /** * Hash sensitive data (one-way) */ hash(data: string, salt?: string): string; /** * Register custom PII pattern */ registerPattern(definition: Omit & { type: string; }): void; /** * Get all registered patterns */ getPatterns(): PatternDefinition[]; private log; /** * Get audit log */ getAuditLog(filter?: Partial>): AuditEntry[]; /** * Clear audit log */ clearAuditLog(): void; /** * Update configuration */ configure(config: Partial): void; /** * Get current configuration */ getConfig(): PrivacyConfig; /** Call gateway verification; no-op if gatewayUrl/apiKey not set. */ private gatewayFetch; /** Verify identity via Onasis Gateway (KYC). Returns null if gateway not configured. */ verifyIdentity(args: { document_type: string; document_number: string; customer_id: string; country?: string; }): Promise<{ success: boolean; data?: unknown; error?: { message: string; }; } | null>; /** Get verification status via gateway. Returns null if gateway not configured. */ getVerificationStatus(args: { reference?: string; verification_id?: string; }): Promise<{ success: boolean; data?: unknown; error?: { message: string; }; } | null>; } declare const privacy: PrivacySDK; declare const mask: (data: string, type: PIIType, options?: Partial) => string; declare const detect: (text: string, options?: { locale?: Locale; }) => DetectionResult[]; declare const detectAndMask: (text: string, options?: { locale?: Locale; }) => string; declare const scan: (obj: unknown, options?: ScanOptions) => { piiFound: boolean; results: Array<{ path: string; type: PIIType; value: string; masked: string; }>; sanitized?: unknown; }; declare const sanitize: >(obj: T, fieldMappings: Record) => T; export { type AuditEntry, DEFAULT_CONFIG, type DetectionResult, type Locale, type MaskingOptions, type PIIType, type PrivacyConfig, PrivacySDK, type ScanOptions, type SensitivityLevel, detect, detectAndMask, mask, privacy, sanitize, scan };