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) 8.83 kB
import { FortifiedFunctionCore } from './core/fortified-function-core.js'; import './core/fortified-config.js'; import './core/fortified-logger.js'; import 'events'; import '../../integrations/express/cache/CacheFactory.js'; export { generateSafeCacheKey } from './serializer/safe-serializer.js'; import 'nehoid'; import '../../utils/memory/index.js'; import 'crypto'; import '../../types/secure-memory.js'; import '../secure-string/advanced/entropy-analyzer.js'; import '../secure-string/advanced/quantum-safe.js'; import '../secure-string/advanced/performance-monitor.js'; import '../../core/hash/hash-core.js'; import '../../core/hash/hash-types.js'; import '../../core/hash/hash-security.js'; import '../../core/hash/hash-advanced.js'; import '../../algorithms/hash-algorithms.js'; import '../../core/random/random-types.js'; import '../../core/random/random-sources.js'; import 'nehonix-uri-processor'; import '../../types.js'; import '../secure-array/utils/id-generator.js'; import '../../integrations/express/server/utils/Logger.js'; import 'argon2'; import 'child_process'; import 'https'; import '../runtime-verification.js'; import '../tamper-evident-logging.js'; import '../../core/keys/keys-types.js'; import '../../core/keys/keys-logger.js'; import '../../core/keys/keys-utils.js'; import '../../core/keys/algorithms/mods/PBKDF2Algo.js'; import '../../core/password/index.js'; export { UltraFastAllocator } from './UFA/ultra-fast-allocator.js'; /*************************************************************************** * FortifyJS - Secure Array Types * * This file contains type definitions for the SecureArrayarchitecture * * @author Nehonix * @license MIT * * Copyright (c) 2025 Nehonix. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. ***************************************************************************** */ // Export main optimized class from modular system (migrated to minimal architecture) /** * Zero-Configuration Smart Function Factory - EXTREME PERFORMANCE EDITION * * Creates ultra-fast fortified functions with enterprise-grade security, * extreme performance optimization, and intelligent caching enabled by default. * Optimized for sub-millisecond execution times while maintaining security. * * @param fn - The function to be fortified with extreme performance capabilities * @param options - Optional configuration overrides (performance-first defaults) * @returns A fortified function with extreme performance and security features * * @example * ```typescript * import { func } from 'fortify2-js'; * * // Zero configuration needed - extreme performance enabled by default * const ultraFastFunction = func(async (data: string) => { * return processData(data); * }); * * // Execute with sub-millisecond performance * const result = await ultraFastFunction('sensitive data'); * * // Optional: Override specific settings if needed * const customFunction = func(myFunction, { * ultraFast: "maximum", * maxCacheSize: 10000, * enableJIT: true * }); * * * const syncFn = func((x: number) => x * 2); // Returns number * syncFn(5).toFixed(2); // Type inference works! * const asyncFn = func(async (x: number) => x * 2); // Returns Promise<number> * asyncFn(5).then((result) => result.toFixed(2)); // Type inference works! * * ``` */ function func(fn, options = {}) { // Use the optimized modular system const fortifiedFunction = FortifiedFunctionCore.create(fn, { // EXTREME PERFORMANCE DEFAULTS ultraFast: "maximum", autoEncrypt: false, // Disabled for maximum speed, enable if needed smartCaching: true, predictiveAnalytics: false, // Disabled for speed, enable for analytics detailedMetrics: false, // Disabled for speed, enable for monitoring enableJIT: true, // NEW: Enable JIT compilation enableSIMD: true, // NEW: Enable SIMD optimizations enableWebAssembly: true, // NEW: Enable WebAssembly acceleration memoryOptimization: "aggressive", // NEW: Aggressive memory optimization cacheStrategy: "adaptive", // Adaptive caching for best performance maxCacheSize: 5000, // Larger cache for better hit rates cacheTTL: 600000, // 10 minutes for better cache utilization ...options, }); const enhancedFunc = ((...args) => { return fortifiedFunction.execute(...args); }); Object.assign(enhancedFunc, { getStats: () => fortifiedFunction.getStats(), getAnalyticsData: () => fortifiedFunction.getAnalyticsData(), getOptimizationSuggestions: () => fortifiedFunction.getOptimizationSuggestions(), getPerformanceTrends: () => fortifiedFunction.getPerformanceTrends(), detectAnomalies: () => fortifiedFunction.detectAnomalies(), getDetailedMetrics: () => fortifiedFunction.getDetailedMetrics(), clearCache: () => fortifiedFunction.clearCache(), getCacheStats: () => ({ hits: fortifiedFunction.getStats().cacheHits, misses: fortifiedFunction.getStats().cacheMisses, size: fortifiedFunction.getCacheStats().size || 0, }), warmCache: async (args) => { for (const argSet of args) { await fortifiedFunction.execute(...argSet); } }, handleMemoryPressure: (level) => fortifiedFunction.handleMemoryPressure(level), optimizePerformance: () => { fortifiedFunction.warmCache(); const suggestions = fortifiedFunction.getOptimizationSuggestions(); suggestions .filter((s) => s.priority === "high" || s.priority === "critical") .forEach(() => fortifiedFunction.warmCache()); }, updateOptions: (newOptions) => fortifiedFunction.updateOptions(newOptions), getConfiguration: () => ({ ...options }), startTimer: (label, metadata) => fortifiedFunction.startTimer(label, metadata), endTimer: (label, additionalMetadata) => fortifiedFunction.endTimer(label, additionalMetadata), measureDelay: (startPoint, endPoint) => fortifiedFunction.measureDelay(startPoint, endPoint), timeFunction: (label, fn, metadata) => fortifiedFunction.timeFunction(label, fn, metadata), getTimingStats: () => fortifiedFunction.getTimingStats(), clearTimings: () => fortifiedFunction.clearTimings(), _fortified: fortifiedFunction, }); return enhancedFunc; } /** * Create a fortified function with full access to smart analytics and optimization * Provides complete access to performance metrics, analytics, and optimization features * * @example * ```typescript * import { createFortifiedFunction } from 'fortify2-js'; * * const fortified = createFortifiedFunction(myFunction, { * autoEncrypt: true, * smartCaching: true, * predictiveAnalytics: true, * detailedMetrics: true * }); * * // Execute * const result = await fortified.execute('data'); * * // Access enhanced analytics * const analytics = fortified.getAnalyticsData(); * const suggestions = fortified.getOptimizationSuggestions(); * const trends = fortified.getPerformanceTrends(); * const anomalies = fortified.detectAnomalies(); * * // Smart actions * fortified.warmCache(); * fortified.handleMemoryPressure('medium'); * * // Get comprehensive metrics * const detailedMetrics = fortified.getDetailedMetrics(); * * // Clean up when done * fortified.destroy(); * ``` */ function createFortifiedFunction(fn, options = {}) { return FortifiedFunctionCore.create(fn, options); } export { FortifiedFunctionCore, FortifiedFunctionCore as OptimizedFortifiedFunction, createFortifiedFunction, func as default, func }; //# sourceMappingURL=index.js.map