UNPKG

fortify2-js

Version:

MOST POWERFUL JavaScript Security Library! Military-grade cryptography + 19 enhanced object methods + quantum-resistant algorithms + perfect TypeScript support. More powerful than Lodash with built-in security.

175 lines (172 loc) 5.45 kB
import { SecureString } from './core/secure-string-core.js'; import { CryptoOperations } from './crypto/crypto-operations.js'; import { ComparisonOperations } from './operations/comparison-operations.js'; import { StringValidator } from './validation/string-validator.js'; export { BufferManager } from './buffer/buffer-manager.js'; export { StringOperations } from './operations/string-operations.js'; export { EntropyAnalyzer } from './advanced/entropy-analyzer.js'; export { QuantumSafeOperations } from './advanced/quantum-safe.js'; export { PerformanceMonitor } from './advanced/performance-monitor.js'; export { DEFAULT_SEARCH_OPTIONS, DEFAULT_SECURE_STRING_OPTIONS, DEFAULT_SPLIT_OPTIONS } from './types/index.js'; /** * SecureString Modular Architecture * Main export file for the refactored SecureString */ /** * Factory functions for common use cases */ /** * Creates a new SecureString with default settings */ function createSecureString(...args) { return new SecureString(...args); } /** * Creates a SecureString with enhanced protection */ function createEnhancedSecureString(value = "", customOptions) { const enhancedOptions = { protectionLevel: "enhanced", enableEncryption: true, enableCanaries: true, enableObfuscation: true, ...customOptions, }; return new SecureString(value, enhancedOptions); } /** * Creates a SecureString with maximum protection */ function createMaximumSecureString(value = "", customOptions) { const maximumOptions = { protectionLevel: "maximum", enableEncryption: true, enableFragmentation: true, enableCanaries: true, enableObfuscation: true, autoLock: true, quantumSafe: true, ...customOptions, }; return new SecureString(value, maximumOptions); } /** * Creates a SecureString from a buffer */ function createSecureStringFromBuffer(buffer, options, encoding = "utf-8") { return SecureString.fromBuffer(buffer, options, encoding); } /** * Creates a SecureString from another SecureString (clone) */ function cloneSecureString(source) { return SecureString.from(source); } /** * Creates a temporary SecureString that auto-destroys after use */ function createTemporarySecureString(value, options) { const tempString = new SecureString(value, options); // Auto-destroy after a timeout (default 5 minutes) setTimeout(() => { if (!tempString.isDestroyed()) { tempString.destroy(); } }, 5 * 60 * 1000); return tempString; } /** * Utility functions */ /** * Compares two strings in constant time */ function constantTimeCompare(str1, str2) { return ComparisonOperations.constantTimeEquals(str1, str2).isEqual; } /** * Calculates string similarity */ function calculateStringSimilarity(str1, str2, algorithm = "levenshtein") { return ComparisonOperations.fuzzyMatch(str1, str2, algorithm); } /** * Validates a password with default requirements */ function validatePassword(password) { return StringValidator.validatePassword(password); } /** * Validates an email address */ function validateEmail(email) { return StringValidator.validateEmail(email); } /** * Generates a cryptographically secure salt */ function generateSalt(length = 32, format = "hex") { if (format === "uint8array") { return CryptoOperations.generateSalt(length); } else if (format === "base64") { return CryptoOperations.generateSaltBase64(length); } else { return CryptoOperations.generateSaltHex(length); } } /** * Hashes a string with the specified algorithm */ async function hashString(content, algorithm = "SHA-256", format = "hex") { return CryptoOperations.hash(content, algorithm, format); } /** * Version information */ const SECURE_STRING_VERSION = "2.0.0-modular"; /** * Module information for debugging */ const MODULE_INFO = { version: SECURE_STRING_VERSION, architecture: "modular", components: [ "core/secure-string-core", "buffer/buffer-manager", "operations/string-operations", "operations/comparison-operations", "crypto/crypto-operations", "validation/string-validator", ], features: [ "Modular architecture", "Enhanced buffer management", "Constant-time comparisons", "Advanced string operations", "Cryptographic operations", "String validation", "Event system", "Memory protection", "Multiple protection levels", ], }; /** * Gets information about the modular SecureString */ function getModuleInfo() { return MODULE_INFO; } /** * Gets supported algorithms */ function getSupportedAlgorithms() { return { hash: CryptoOperations.getSupportedHashAlgorithms(), hmac: CryptoOperations.getSupportedHMACAlgorithms(), algorithms: CryptoOperations.getAlgorithmInfo(), }; } export { ComparisonOperations, CryptoOperations, MODULE_INFO, SECURE_STRING_VERSION, SecureString, StringValidator, calculateStringSimilarity, cloneSecureString, constantTimeCompare, createEnhancedSecureString, createMaximumSecureString, createSecureString, createSecureStringFromBuffer, createTemporarySecureString, SecureString as default, generateSalt, getModuleInfo, getSupportedAlgorithms, hashString, validateEmail, validatePassword }; //# sourceMappingURL=index.js.map