xypriss 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +13 -13
  2. package/dist/cjs/index.js +2 -0
  3. package/dist/cjs/mods/security/src/index.js +35 -12
  4. package/dist/cjs/mods/security/src/index.js.map +1 -1
  5. package/dist/cjs/src/plugins/modules/PluginEngine.js +378 -0
  6. package/dist/cjs/src/plugins/modules/PluginEngine.js.map +1 -0
  7. package/dist/cjs/src/plugins/modules/PluginRegistry.js +339 -0
  8. package/dist/cjs/src/plugins/modules/PluginRegistry.js.map +1 -0
  9. package/dist/cjs/src/plugins/modules/builtin/JWTAuthPlugin.js +591 -0
  10. package/dist/cjs/src/plugins/modules/builtin/JWTAuthPlugin.js.map +1 -0
  11. package/dist/cjs/src/plugins/modules/builtin/ResponseTimePlugin.js +413 -0
  12. package/dist/cjs/src/plugins/modules/builtin/ResponseTimePlugin.js.map +1 -0
  13. package/dist/cjs/src/plugins/modules/builtin/SmartCachePlugin.js +843 -0
  14. package/dist/cjs/src/plugins/modules/builtin/SmartCachePlugin.js.map +1 -0
  15. package/dist/cjs/src/plugins/modules/core/CachePlugin.js +1975 -0
  16. package/dist/cjs/src/plugins/modules/core/CachePlugin.js.map +1 -0
  17. package/dist/cjs/src/plugins/modules/core/PerformancePlugin.js +894 -0
  18. package/dist/cjs/src/plugins/modules/core/PerformancePlugin.js.map +1 -0
  19. package/dist/cjs/src/plugins/modules/core/SecurityPlugin.js +799 -0
  20. package/dist/cjs/src/plugins/modules/core/SecurityPlugin.js.map +1 -0
  21. package/dist/cjs/src/plugins/modules/types/PluginTypes.js +47 -0
  22. package/dist/cjs/src/plugins/modules/types/PluginTypes.js.map +1 -0
  23. package/dist/cjs/src/server/FastServer.js +22 -3
  24. package/dist/cjs/src/server/FastServer.js.map +1 -1
  25. package/dist/cjs/src/server/components/fastapi/PluginManager.js +5 -5
  26. package/dist/cjs/src/server/components/fastapi/PluginManager.js.map +1 -1
  27. package/dist/cjs/src/server/components/fastapi/RequestProcessor.js +1 -1
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/mods/security/src/index.js +14 -10
  30. package/dist/esm/mods/security/src/index.js.map +1 -1
  31. package/dist/esm/src/plugins/modules/PluginEngine.js +376 -0
  32. package/dist/esm/src/plugins/modules/PluginEngine.js.map +1 -0
  33. package/dist/esm/src/plugins/modules/PluginRegistry.js +337 -0
  34. package/dist/esm/src/plugins/modules/PluginRegistry.js.map +1 -0
  35. package/dist/esm/src/plugins/modules/builtin/JWTAuthPlugin.js +589 -0
  36. package/dist/esm/src/plugins/modules/builtin/JWTAuthPlugin.js.map +1 -0
  37. package/dist/esm/src/plugins/modules/builtin/ResponseTimePlugin.js +411 -0
  38. package/dist/esm/src/plugins/modules/builtin/ResponseTimePlugin.js.map +1 -0
  39. package/dist/esm/src/plugins/modules/builtin/SmartCachePlugin.js +841 -0
  40. package/dist/esm/src/plugins/modules/builtin/SmartCachePlugin.js.map +1 -0
  41. package/dist/esm/src/plugins/modules/core/CachePlugin.js +1973 -0
  42. package/dist/esm/src/plugins/modules/core/CachePlugin.js.map +1 -0
  43. package/dist/esm/src/plugins/modules/core/PerformancePlugin.js +872 -0
  44. package/dist/esm/src/plugins/modules/core/PerformancePlugin.js.map +1 -0
  45. package/dist/esm/src/plugins/modules/core/SecurityPlugin.js +797 -0
  46. package/dist/esm/src/plugins/modules/core/SecurityPlugin.js.map +1 -0
  47. package/dist/esm/src/plugins/modules/types/PluginTypes.js +47 -0
  48. package/dist/esm/src/plugins/modules/types/PluginTypes.js.map +1 -0
  49. package/dist/esm/src/server/FastServer.js +22 -3
  50. package/dist/esm/src/server/FastServer.js.map +1 -1
  51. package/dist/esm/src/server/components/fastapi/PluginManager.js +5 -5
  52. package/dist/esm/src/server/components/fastapi/PluginManager.js.map +1 -1
  53. package/dist/esm/src/server/components/fastapi/RequestProcessor.js +1 -1
  54. package/dist/index.d.ts +5 -0
  55. package/package.json +4 -4
package/README.md CHANGED
@@ -54,7 +54,7 @@ npm i --save-dev @types/express
54
54
  import { createServer } from "xypriss";
55
55
 
56
56
  // Create a new XyPriss server
57
- const server = createServer({
57
+ const app = createServer({
58
58
  server: {
59
59
  port: 3000,
60
60
  host: "localhost",
@@ -71,18 +71,20 @@ const server = createServer({
71
71
  });
72
72
 
73
73
  // Define routes using standard Express.js syntax
74
- server.get("/", (req, res) => {
74
+ app.get("/", (req, res) => {
75
75
  res.json({ message: "Hello from XyPriss!" });
76
76
  });
77
77
 
78
- server.get("/api/users/:id", (req, res) => {
78
+ app.get("/api/users/:id", (req, res) => {
79
79
  const userId = req.params.id;
80
80
  res.json({ userId, data: "User data" });
81
81
  });
82
82
 
83
83
  // Start the server
84
- server.listen(3000, () => {
85
- console.log("XyPriss server running on port 3000");
84
+ app.start(undefined, () => {
85
+ console.log(
86
+ "Secure XyPriss server running at http://localhost:" + app.getPort()
87
+ );
86
88
  });
87
89
  ```
88
90
 
@@ -152,7 +154,7 @@ const server = createServer({
152
154
 
153
155
  ```typescript
154
156
  import { createServer } from "xypriss";
155
- import { XyPrissSecurity, fString, fArray } from "xypriss-security";
157
+ import { XyPrissSecurity as security, fString, fArray } from "xypriss-security";
156
158
 
157
159
  const server = createServer({
158
160
  server: {
@@ -161,9 +163,6 @@ const server = createServer({
161
163
  },
162
164
  });
163
165
 
164
- // Initialize security module
165
- const security = new XyPrissSecurity();
166
-
167
166
  // Secure route with encryption
168
167
  server.post("/api/secure-data", async (req, res) => {
169
168
  try {
@@ -190,8 +189,10 @@ server.post("/api/secure-data", async (req, res) => {
190
189
  }
191
190
  });
192
191
 
193
- server.listen(3000, () => {
194
- console.log("Secure XyPriss server running");
192
+ server.start(undefined, () => {
193
+ console.log(
194
+ "Secure XyPriss server running at http://localhost:" + server.getPort()
195
+ );
195
196
  });
196
197
  ```
197
198
 
@@ -219,7 +220,7 @@ XyPriss integrates with the XyPriss Security toolkit, providing:
219
220
  ```typescript
220
221
  import { createServer } from "xypriss";
221
222
  import {
222
- XyPrissSecurity,
223
+ XyPrissSecurity as security, // or just import XyPriss
223
224
  fArray,
224
225
  fString,
225
226
  fObject,
@@ -230,7 +231,6 @@ import {
230
231
  const server = createServer({
231
232
  /* config */
232
233
  });
233
- const security = new XyPrissSecurity();
234
234
  ```
235
235
 
236
236
  ## Documentation
@@ -0,0 +1,2 @@
1
+ // CommonJS re-export from src directory
2
+ module.exports = require('./src/index.js');
@@ -2,18 +2,18 @@
2
2
 
3
3
  var types = require('./types.js');
4
4
  var hashCore = require('./core/hash/hash-core.js');
5
- require('./core/hash/hash-types.js');
5
+ var hashTypes = require('./core/hash/hash-types.js');
6
6
  require('crypto');
7
- require('./core/hash/hash-security.js');
8
- require('./core/hash/hash-advanced.js');
9
- require('./algorithms/hash-algorithms.js');
7
+ var hashSecurity = require('./core/hash/hash-security.js');
8
+ var hashAdvanced = require('./core/hash/hash-advanced.js');
9
+ var hashAlgorithms = require('./algorithms/hash-algorithms.js');
10
10
  require('./core/keys/keys-types.js');
11
11
  require('./core/keys/keys-logger.js');
12
12
  require('./core/keys/keys-utils.js');
13
13
  require('./core/keys/algorithms/mods/PBKDF2Algo.js');
14
14
  var randomCore = require('./core/random/random-core.js');
15
- require('./core/random/random-types.js');
16
- require('./core/random/random-sources.js');
15
+ var randomTypes = require('./core/random/random-types.js');
16
+ var randomSources = require('./core/random/random-sources.js');
17
17
  require('nehonix-uri-processor');
18
18
  require('./utils/memory/index.js');
19
19
  require('argon2');
@@ -25,10 +25,10 @@ var tamperEvidentLogging = require('./components/tamper-evident-logging.js');
25
25
  require('./components/secure-string/advanced/entropy-analyzer.js');
26
26
  require('./components/secure-string/advanced/quantum-safe.js');
27
27
  require('./components/secure-string/advanced/performance-monitor.js');
28
- var index$1 = require('./components/secure-object/index.js');
28
+ var index$2 = require('./components/secure-object/index.js');
29
29
  require('./components/secure-array/utils/id-generator.js');
30
30
  var passwordTypes = require('./core/password/password-types.js');
31
- require('./core/password/index.js');
31
+ var index$1 = require('./core/password/index.js');
32
32
  require('./components/fortified-function/core/fortified-function-core.js');
33
33
  require('./components/fortified-function/core/fortified-config.js');
34
34
  require('./components/fortified-function/core/fortified-logger.js');
@@ -40,7 +40,7 @@ require('./components/fortified-function/UFA/ultra-fast-allocator.js');
40
40
  var passwordCore = require('./core/password/password-core.js');
41
41
 
42
42
  /***************************************************************************
43
- * XyPrissSecurity - Ex xypriss2-js is an Advanced JavaScript Security Library designed for XyPriss
43
+ * XyPrissSecurity - Ex fortify2-js is an Advanced JavaScript Security Library designed for XyPriss
44
44
  *
45
45
  * This file contains the main entry point for the XyPrissSecurity library.
46
46
  *
@@ -117,7 +117,11 @@ var passwordCore = require('./core/password/password-core.js');
117
117
  * console.log(apiKey); // "aK7mN9pQ2rS8tU3vW6xY1zB4cD5eF7gH"
118
118
  *
119
119
  * // Quick token generation
120
- * const sessionToken = generateSecureToken(64, "base64url");
120
+ * const sessionToken = generateSecureToken({
121
+ length: 32,
122
+ entropy: "maximum",
123
+
124
+ });
121
125
  * ```
122
126
  *
123
127
  * ### Secure Data Structures
@@ -369,7 +373,7 @@ passwordCore.PasswordManager.getInstance();
369
373
  * @since 1.0.0
370
374
  */
371
375
  function fObject(...args) {
372
- return index$1.createSecureObject(...args);
376
+ return index$2.createSecureObject(...args);
373
377
  }
374
378
 
375
379
  Object.defineProperty(exports, 'EntropySource', {
@@ -393,7 +397,24 @@ Object.defineProperty(exports, 'TokenType', {
393
397
  get: function () { return types.TokenType; }
394
398
  });
395
399
  exports.Hash = hashCore.Hash;
400
+ Object.defineProperty(exports, 'HashStrength', {
401
+ enumerable: true,
402
+ get: function () { return hashTypes.HashStrength; }
403
+ });
404
+ exports.HashSecurity = hashSecurity.HashSecurity;
405
+ exports.HashAdvanced = hashAdvanced.HashAdvanced;
406
+ exports.HashAlgorithms = hashAlgorithms.HashAlgorithms;
396
407
  exports.Random = randomCore.SecureRandom;
408
+ exports.SecureRandom = randomCore.SecureRandom;
409
+ Object.defineProperty(exports, 'EntropyQuality', {
410
+ enumerable: true,
411
+ get: function () { return randomTypes.EntropyQuality; }
412
+ });
413
+ Object.defineProperty(exports, 'RNGState', {
414
+ enumerable: true,
415
+ get: function () { return randomTypes.RNGState; }
416
+ });
417
+ exports.RandomSources = randomSources.RandomSources;
397
418
  Object.defineProperty(exports, 'SecurityIssueType', {
398
419
  enumerable: true,
399
420
  get: function () { return runtimeVerification.SecurityIssueType; }
@@ -404,7 +425,7 @@ Object.defineProperty(exports, 'LogLevel', {
404
425
  get: function () { return tamperEvidentLogging.LogLevel; }
405
426
  });
406
427
  exports.TamperEvidentLogger = tamperEvidentLogging.TamperEvidentLogger;
407
- exports.createSecureObject = index$1.createSecureObject;
428
+ exports.createSecureObject = index$2.createSecureObject;
408
429
  Object.defineProperty(exports, 'PasswordAlgorithm', {
409
430
  enumerable: true,
410
431
  get: function () { return passwordTypes.PasswordAlgorithm; }
@@ -413,6 +434,8 @@ Object.defineProperty(exports, 'PasswordSecurityLevel', {
413
434
  enumerable: true,
414
435
  get: function () { return passwordTypes.PasswordSecurityLevel; }
415
436
  });
437
+ exports.getDefaultPasswordPolicy = index$1.getDefaultPasswordPolicy;
438
+ exports.getRecommendedConfig = index$1.getRecommendedConfig;
416
439
  exports.PasswordManager = passwordCore.PasswordManager;
417
440
  exports.fObject = fObject;
418
441
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../mods/security/src/index.ts"],"sourcesContent":[null],"names":["SecureRandom","Hash","PasswordManager","fObjectUtils.createSecureObject"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4JG;AAkgBH;;;;;;;;;;;;;;;AAeG;AAEH;AAC8BA,uBAAY,CAAC,eAAe;AAE1D;AACkCA,uBAAY,CAAC,mBAAmB;AAmBlE;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AAEH;AACgCC,aAAI,CAAC,iBAAiB;AAEtD;AACgCA,aAAI,CAAC,iBAAiB;AAEtD;AAC0BA,aAAI,CAAC,WAAW;AAyL1C;;;;;;;;;;;;;;;;;;;;AAoBG;AACeC,4BAAe,CAAC,WAAW,GAAG;AA0EhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEG;AACa,SAAA,OAAO,CACnB,GAAG,IAA2D,EAAA;AAE9D,IAAA,OAAOC,0BAA+B,CAAI,GAAG,IAAI,CAAC,CAAC;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../mods/security/src/index.ts"],"sourcesContent":[null],"names":["SecureRandom","Hash","PasswordManager","fObjectUtils.createSecureObject"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgKG;AAogBH;;;;;;;;;;;;;;;AAeG;AAEH;AAC8BA,uBAAY,CAAC,eAAe;AAE1D;AACkCA,uBAAY,CAAC,mBAAmB;AAmBlE;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AAEH;AACgCC,aAAI,CAAC,iBAAiB;AAEtD;AACgCA,aAAI,CAAC,iBAAiB;AAEtD;AAC0BA,aAAI,CAAC,WAAW;AAyL1C;;;;;;;;;;;;;;;;;;;;AAoBG;AACeC,4BAAe,CAAC,WAAW,GAAG;AA0EhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEG;AACa,SAAA,OAAO,CACnB,GAAG,IAA2D,EAAA;AAE9D,IAAA,OAAOC,0BAA+B,CAAI,GAAG,IAAI,CAAC,CAAC;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,378 @@
1
+ 'use strict';
2
+
3
+ var events = require('events');
4
+ var nehoid = require('nehoid');
5
+ var PluginTypes = require('./types/PluginTypes.js');
6
+
7
+ /**
8
+ * Ultra-Fast Plugin Execution Engine
9
+ *
10
+ * High-performance plugin execution engine designed to achieve <1ms overhead
11
+ * while maintaining security and comprehensive error handling.
12
+ */
13
+ /**
14
+ * Ultra-fast plugin execution engine with intelligent optimization
15
+ */
16
+ class PluginEngine extends events.EventEmitter {
17
+ constructor(registry, cache, cluster) {
18
+ super();
19
+ this.executionPool = new Map();
20
+ this.warmupCache = new Map();
21
+ // Performance optimization: Object pooling for contexts
22
+ this.contextPool = [];
23
+ this.MAX_POOL_SIZE = 100;
24
+ // Circuit breaker for failing plugins
25
+ this.circuitBreakers = new Map();
26
+ this.registry = registry;
27
+ this.cache = cache;
28
+ this.cluster = cluster;
29
+ // Listen to registry events
30
+ this.setupRegistryEventHandlers();
31
+ }
32
+ /**
33
+ * Execute plugins for a specific type with ultra-fast performance
34
+ */
35
+ async executePlugins(type, req, res, next) {
36
+ const startTime = performance.now();
37
+ const executionId = nehoid.NehoID.generate({ prefix: "plug.exec", size: 8 });
38
+ try {
39
+ // Get plugins for this type (pre-sorted by priority)
40
+ const plugins = this.registry.getPluginsByType(type);
41
+ if (plugins.length === 0) {
42
+ return true; // Continue execution if no plugins
43
+ }
44
+ // Create or reuse execution context
45
+ const context = this.createExecutionContext(req, res, next, executionId, startTime);
46
+ // Execute plugins based on type strategy
47
+ const success = await this.executePluginChain(plugins, context);
48
+ // Update performance metrics
49
+ const totalExecutionTime = performance.now() - startTime;
50
+ this.updatePerformanceMetrics(type, totalExecutionTime, success);
51
+ // Return context to pool
52
+ this.returnContextToPool(context);
53
+ return success;
54
+ }
55
+ catch (error) {
56
+ const executionTime = performance.now() - startTime;
57
+ this.handleExecutionError(type, executionId, error, executionTime);
58
+ return false;
59
+ }
60
+ }
61
+ /**
62
+ * Execute a single plugin with comprehensive error handling
63
+ */
64
+ async executePlugin(plugin, context) {
65
+ const startTime = performance.now();
66
+ try {
67
+ // Check circuit breaker
68
+ if (this.isCircuitBreakerOpen(plugin.id)) {
69
+ return {
70
+ success: false,
71
+ executionTime: 0,
72
+ error: new Error(`Circuit breaker open for plugin ${plugin.id}`),
73
+ shouldContinue: true,
74
+ };
75
+ }
76
+ // Warm up plugin if needed
77
+ await this.warmupPlugin(plugin, context);
78
+ // Execute plugin with timeout
79
+ const result = await this.executeWithTimeout(plugin, context);
80
+ const executionTime = performance.now() - startTime;
81
+ result.executionTime = executionTime;
82
+ // Update plugin statistics
83
+ this.registry.updateStats(plugin.id, executionTime, result.success);
84
+ // Reset circuit breaker on success
85
+ if (result.success) {
86
+ this.resetCircuitBreaker(plugin.id);
87
+ }
88
+ else {
89
+ this.updateCircuitBreaker(plugin.id);
90
+ }
91
+ // Emit execution event
92
+ this.emitPluginEvent(PluginTypes.PluginEventType.PLUGIN_EXECUTED, plugin.id, {
93
+ executionTime,
94
+ success: result.success,
95
+ type: plugin.type,
96
+ });
97
+ return result;
98
+ }
99
+ catch (error) {
100
+ const executionTime = performance.now() - startTime;
101
+ // Update circuit breaker
102
+ this.updateCircuitBreaker(plugin.id);
103
+ // Update error statistics
104
+ this.registry.updateStats(plugin.id, executionTime, false);
105
+ // Emit error event
106
+ this.emitPluginEvent(PluginTypes.PluginEventType.PLUGIN_ERROR, plugin.id, {
107
+ error: error.message,
108
+ executionTime,
109
+ type: plugin.type,
110
+ });
111
+ return {
112
+ success: false,
113
+ executionTime,
114
+ error,
115
+ shouldContinue: true,
116
+ };
117
+ }
118
+ }
119
+ /**
120
+ * Execute plugin chain with intelligent optimization
121
+ */
122
+ async executePluginChain(plugins, context) {
123
+ // For critical performance plugins, execute in parallel
124
+ if (plugins.length > 0 && plugins[0].type === PluginTypes.PluginType.PERFORMANCE) {
125
+ return await this.executePluginsParallel(plugins, context);
126
+ }
127
+ // For security and cache plugins, execute sequentially
128
+ return await this.executePluginsSequential(plugins, context);
129
+ }
130
+ /**
131
+ * Execute plugins sequentially (for security, cache operations)
132
+ */
133
+ async executePluginsSequential(plugins, context) {
134
+ for (const plugin of plugins) {
135
+ const result = await this.executePlugin(plugin, context);
136
+ if (!result.success && plugin.type === PluginTypes.PluginType.SECURITY) {
137
+ // Security plugins must succeed
138
+ return false;
139
+ }
140
+ if (!result.shouldContinue) {
141
+ // Plugin requested to stop execution
142
+ return false;
143
+ }
144
+ // Store plugin result data
145
+ if (result.data) {
146
+ context.pluginData.set(plugin.id, result.data);
147
+ }
148
+ // Handle cache data
149
+ if (result.cacheData) {
150
+ await this.cache.set(result.cacheData.key, result.cacheData.value, { ttl: result.cacheData.ttl });
151
+ }
152
+ }
153
+ return true;
154
+ }
155
+ /**
156
+ * Execute plugins in parallel (for performance monitoring)
157
+ */
158
+ async executePluginsParallel(plugins, context) {
159
+ const promises = plugins.map((plugin) => this.executePlugin(plugin, context));
160
+ const results = await Promise.allSettled(promises);
161
+ let allSuccessful = true;
162
+ results.forEach((result, index) => {
163
+ if (result.status === "fulfilled") {
164
+ const pluginResult = result.value;
165
+ if (!pluginResult.success) {
166
+ allSuccessful = false;
167
+ }
168
+ // Store plugin result data
169
+ if (pluginResult.data) {
170
+ context.pluginData.set(plugins[index].id, pluginResult.data);
171
+ }
172
+ }
173
+ else {
174
+ allSuccessful = false;
175
+ }
176
+ });
177
+ return allSuccessful;
178
+ }
179
+ /**
180
+ * Execute plugin with timeout protection
181
+ */
182
+ async executeWithTimeout(plugin, context) {
183
+ const timeoutMs = plugin.maxExecutionTime;
184
+ return new Promise((resolve, reject) => {
185
+ const timeout = setTimeout(() => {
186
+ this.emitPluginEvent(PluginTypes.PluginEventType.PLUGIN_TIMEOUT, plugin.id, {
187
+ timeout: timeoutMs,
188
+ type: plugin.type,
189
+ });
190
+ reject(new Error(`Plugin ${plugin.id} timed out after ${timeoutMs}ms`));
191
+ }, timeoutMs);
192
+ // Execute plugin
193
+ const execution = plugin.isAsync
194
+ ? plugin.execute(context)
195
+ : Promise.resolve(plugin.execute(context));
196
+ execution
197
+ .then((result) => {
198
+ clearTimeout(timeout);
199
+ resolve(result);
200
+ })
201
+ .catch((error) => {
202
+ clearTimeout(timeout);
203
+ reject(error);
204
+ });
205
+ });
206
+ }
207
+ /**
208
+ * Create optimized execution context with object pooling
209
+ */
210
+ createExecutionContext(req, res, next, executionId, startTime) {
211
+ // Try to reuse context from pool
212
+ let context = this.contextPool.pop();
213
+ if (!context) {
214
+ context = {
215
+ req,
216
+ res,
217
+ next,
218
+ startTime,
219
+ executionId,
220
+ cache: this.cache,
221
+ cluster: this.cluster,
222
+ pluginData: new Map(),
223
+ security: {
224
+ isAuthenticated: false,
225
+ roles: [],
226
+ permissions: [],
227
+ },
228
+ metrics: {
229
+ requestStartTime: startTime,
230
+ pluginExecutionTimes: new Map(),
231
+ cacheHits: 0,
232
+ cacheMisses: 0,
233
+ },
234
+ };
235
+ }
236
+ else {
237
+ // Reset reused context
238
+ context.req = req;
239
+ context.res = res;
240
+ context.next = next;
241
+ context.startTime = startTime;
242
+ context.executionId = executionId;
243
+ context.pluginData.clear();
244
+ context.metrics.pluginExecutionTimes.clear();
245
+ context.metrics.requestStartTime = startTime;
246
+ context.metrics.cacheHits = 0;
247
+ context.metrics.cacheMisses = 0;
248
+ }
249
+ return context;
250
+ }
251
+ /**
252
+ * Return context to pool for reuse
253
+ */
254
+ returnContextToPool(context) {
255
+ if (this.contextPool.length < this.MAX_POOL_SIZE) {
256
+ // Clear sensitive data before returning to pool
257
+ context.pluginData.clear();
258
+ context.metrics.pluginExecutionTimes.clear();
259
+ this.contextPool.push(context);
260
+ }
261
+ }
262
+ /**
263
+ * Warm up plugin for optimal performance
264
+ */
265
+ async warmupPlugin(plugin, context) {
266
+ if (this.warmupCache.has(plugin.id)) {
267
+ return; // Already warmed up
268
+ }
269
+ if (plugin.warmup) {
270
+ try {
271
+ await plugin.warmup(context);
272
+ this.warmupCache.set(plugin.id, true);
273
+ }
274
+ catch (error) {
275
+ // Warmup failure is not critical
276
+ console.warn(`Plugin ${plugin.id} warmup failed:`, error);
277
+ }
278
+ }
279
+ }
280
+ /**
281
+ * Circuit breaker management
282
+ */
283
+ isCircuitBreakerOpen(pluginId) {
284
+ const breaker = this.circuitBreakers.get(pluginId);
285
+ if (!breaker)
286
+ return false;
287
+ // Reset circuit breaker after 60 seconds
288
+ if (breaker.isOpen && Date.now() - breaker.lastFailure > 60000) {
289
+ breaker.isOpen = false;
290
+ breaker.failures = 0;
291
+ }
292
+ return breaker.isOpen;
293
+ }
294
+ updateCircuitBreaker(pluginId) {
295
+ const breaker = this.circuitBreakers.get(pluginId) || {
296
+ failures: 0,
297
+ lastFailure: 0,
298
+ isOpen: false,
299
+ };
300
+ breaker.failures++;
301
+ breaker.lastFailure = Date.now();
302
+ // Open circuit breaker after 5 failures
303
+ if (breaker.failures >= 5) {
304
+ breaker.isOpen = true;
305
+ }
306
+ this.circuitBreakers.set(pluginId, breaker);
307
+ }
308
+ resetCircuitBreaker(pluginId) {
309
+ this.circuitBreakers.delete(pluginId);
310
+ }
311
+ /**
312
+ * Setup registry event handlers
313
+ */
314
+ setupRegistryEventHandlers() {
315
+ this.registry.on(PluginTypes.PluginEventType.PLUGIN_UNREGISTERED, (event) => {
316
+ // Clean up plugin-specific data
317
+ this.circuitBreakers.delete(event.pluginId);
318
+ this.warmupCache.delete(event.pluginId);
319
+ });
320
+ }
321
+ /**
322
+ * Update performance metrics
323
+ */
324
+ updatePerformanceMetrics(type, executionTime, success) {
325
+ // Emit performance metrics for monitoring
326
+ this.emit("performance", {
327
+ type,
328
+ executionTime,
329
+ success,
330
+ timestamp: Date.now(),
331
+ });
332
+ }
333
+ /**
334
+ * Handle execution errors
335
+ */
336
+ handleExecutionError(type, executionId, error, executionTime) {
337
+ console.error(`Plugin execution error [${type}] [${executionId}]:`, error);
338
+ this.emit("error", {
339
+ type,
340
+ executionId,
341
+ error,
342
+ executionTime,
343
+ timestamp: Date.now(),
344
+ });
345
+ }
346
+ /**
347
+ * Emit plugin event
348
+ */
349
+ emitPluginEvent(type, pluginId, data) {
350
+ const event = {
351
+ type,
352
+ pluginId,
353
+ timestamp: new Date(),
354
+ data,
355
+ };
356
+ this.emit(type, event);
357
+ }
358
+ /**
359
+ * Get engine statistics (ultra-fast optimized)
360
+ */
361
+ getEngineStats() {
362
+ // Ultra-fast: Count open circuit breakers without creating arrays
363
+ let circuitBreakersOpen = 0;
364
+ this.circuitBreakers.forEach((breaker) => {
365
+ if (breaker.isOpen)
366
+ circuitBreakersOpen++;
367
+ });
368
+ return {
369
+ contextPoolSize: this.contextPool.length,
370
+ circuitBreakersOpen,
371
+ warmedUpPlugins: this.warmupCache.size,
372
+ activeExecutions: this.executionPool.size,
373
+ };
374
+ }
375
+ }
376
+
377
+ exports.PluginEngine = PluginEngine;
378
+ //# sourceMappingURL=PluginEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginEngine.js","sources":["../../../../../src/plugins/modules/PluginEngine.ts"],"sourcesContent":[null],"names":["EventEmitter","NehoID","PluginEventType","PluginType"],"mappings":";;;;;;AAAA;;;;;AAKG;AAkBH;;AAEG;AACG,MAAO,YAAa,SAAQA,mBAAY,CAAA;AAsB1C,IAAA,WAAA,CACI,QAAwB,EACxB,KAAyB,EACzB,OAAwB,EAAA;AAExB,QAAA,KAAK,EAAE,CAAC;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