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.

205 lines (201 loc) 6.85 kB
'use strict'; var secureStringCore = require('./core/secure-string-core.js'); var cryptoOperations = require('./crypto/crypto-operations.js'); var comparisonOperations = require('./operations/comparison-operations.js'); var stringValidator = require('./validation/string-validator.js'); var bufferManager = require('./buffer/buffer-manager.js'); var stringOperations = require('./operations/string-operations.js'); var entropyAnalyzer = require('./advanced/entropy-analyzer.js'); var quantumSafe = require('./advanced/quantum-safe.js'); var performanceMonitor = require('./advanced/performance-monitor.js'); var index = require('./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 secureStringCore.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 secureStringCore.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 secureStringCore.SecureString(value, maximumOptions); } /** * Creates a SecureString from a buffer */ function createSecureStringFromBuffer(buffer, options, encoding = "utf-8") { return secureStringCore.SecureString.fromBuffer(buffer, options, encoding); } /** * Creates a SecureString from another SecureString (clone) */ function cloneSecureString(source) { return secureStringCore.SecureString.from(source); } /** * Creates a temporary SecureString that auto-destroys after use */ function createTemporarySecureString(value, options) { const tempString = new secureStringCore.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.ComparisonOperations.constantTimeEquals(str1, str2).isEqual; } /** * Calculates string similarity */ function calculateStringSimilarity(str1, str2, algorithm = "levenshtein") { return comparisonOperations.ComparisonOperations.fuzzyMatch(str1, str2, algorithm); } /** * Validates a password with default requirements */ function validatePassword(password) { return stringValidator.StringValidator.validatePassword(password); } /** * Validates an email address */ function validateEmail(email) { return stringValidator.StringValidator.validateEmail(email); } /** * Generates a cryptographically secure salt */ function generateSalt(length = 32, format = "hex") { if (format === "uint8array") { return cryptoOperations.CryptoOperations.generateSalt(length); } else if (format === "base64") { return cryptoOperations.CryptoOperations.generateSaltBase64(length); } else { return cryptoOperations.CryptoOperations.generateSaltHex(length); } } /** * Hashes a string with the specified algorithm */ async function hashString(content, algorithm = "SHA-256", format = "hex") { return cryptoOperations.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.CryptoOperations.getSupportedHashAlgorithms(), hmac: cryptoOperations.CryptoOperations.getSupportedHMACAlgorithms(), algorithms: cryptoOperations.CryptoOperations.getAlgorithmInfo(), }; } exports.SecureString = secureStringCore.SecureString; exports.default = secureStringCore.SecureString; exports.CryptoOperations = cryptoOperations.CryptoOperations; exports.ComparisonOperations = comparisonOperations.ComparisonOperations; exports.StringValidator = stringValidator.StringValidator; exports.BufferManager = bufferManager.BufferManager; exports.StringOperations = stringOperations.StringOperations; exports.EntropyAnalyzer = entropyAnalyzer.EntropyAnalyzer; exports.QuantumSafeOperations = quantumSafe.QuantumSafeOperations; exports.PerformanceMonitor = performanceMonitor.PerformanceMonitor; exports.DEFAULT_SEARCH_OPTIONS = index.DEFAULT_SEARCH_OPTIONS; exports.DEFAULT_SECURE_STRING_OPTIONS = index.DEFAULT_SECURE_STRING_OPTIONS; exports.DEFAULT_SPLIT_OPTIONS = index.DEFAULT_SPLIT_OPTIONS; exports.MODULE_INFO = MODULE_INFO; exports.SECURE_STRING_VERSION = SECURE_STRING_VERSION; exports.calculateStringSimilarity = calculateStringSimilarity; exports.cloneSecureString = cloneSecureString; exports.constantTimeCompare = constantTimeCompare; exports.createEnhancedSecureString = createEnhancedSecureString; exports.createMaximumSecureString = createMaximumSecureString; exports.createSecureString = createSecureString; exports.createSecureStringFromBuffer = createSecureStringFromBuffer; exports.createTemporarySecureString = createTemporarySecureString; exports.generateSalt = generateSalt; exports.getModuleInfo = getModuleInfo; exports.getSupportedAlgorithms = getSupportedAlgorithms; exports.hashString = hashString; exports.validateEmail = validateEmail; exports.validatePassword = validatePassword; //# sourceMappingURL=index.js.map