xypriss 1.1.3 → 1.2.0
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.
- package/README.md +13 -13
- package/dist/cjs/mods/security/src/index.js +35 -12
- package/dist/cjs/mods/security/src/index.js.map +1 -1
- package/dist/cjs/src/index.js +56 -0
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/plugins/modules/PluginEngine.js +378 -0
- package/dist/cjs/src/plugins/modules/PluginEngine.js.map +1 -0
- package/dist/cjs/src/plugins/modules/PluginRegistry.js +339 -0
- package/dist/cjs/src/plugins/modules/PluginRegistry.js.map +1 -0
- package/dist/cjs/src/plugins/modules/builtin/JWTAuthPlugin.js +591 -0
- package/dist/cjs/src/plugins/modules/builtin/JWTAuthPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/builtin/ResponseTimePlugin.js +413 -0
- package/dist/cjs/src/plugins/modules/builtin/ResponseTimePlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/builtin/SmartCachePlugin.js +843 -0
- package/dist/cjs/src/plugins/modules/builtin/SmartCachePlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/core/CachePlugin.js +1975 -0
- package/dist/cjs/src/plugins/modules/core/CachePlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/core/PerformancePlugin.js +894 -0
- package/dist/cjs/src/plugins/modules/core/PerformancePlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/core/SecurityPlugin.js +799 -0
- package/dist/cjs/src/plugins/modules/core/SecurityPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/index.js +304 -0
- package/dist/cjs/src/plugins/modules/index.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/builtin/CompressionPlugin.js +410 -0
- package/dist/cjs/src/plugins/modules/network/builtin/CompressionPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/builtin/ConnectionPlugin.js +797 -0
- package/dist/cjs/src/plugins/modules/network/builtin/ConnectionPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/builtin/ProxyPlugin.js +409 -0
- package/dist/cjs/src/plugins/modules/network/builtin/ProxyPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/builtin/RateLimitPlugin.js +606 -0
- package/dist/cjs/src/plugins/modules/network/builtin/RateLimitPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/core/NetworkPlugin.js +225 -0
- package/dist/cjs/src/plugins/modules/network/core/NetworkPlugin.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/core/NetworkPluginFactory.js +40 -0
- package/dist/cjs/src/plugins/modules/network/core/NetworkPluginFactory.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/index.js +120 -0
- package/dist/cjs/src/plugins/modules/network/index.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/types/NetworkTypes.js +24 -0
- package/dist/cjs/src/plugins/modules/network/types/NetworkTypes.js.map +1 -0
- package/dist/cjs/src/plugins/modules/network/utils/NetworkPluginUtils.js +63 -0
- package/dist/cjs/src/plugins/modules/network/utils/NetworkPluginUtils.js.map +1 -0
- package/dist/cjs/src/plugins/modules/types/PluginTypes.js +48 -0
- package/dist/cjs/src/plugins/modules/types/PluginTypes.js.map +1 -0
- package/dist/cjs/src/server/FastServer.js +133 -5
- package/dist/cjs/src/server/FastServer.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/PluginManager.js +5 -5
- package/dist/cjs/src/server/components/fastapi/PluginManager.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/RequestProcessor.js +1 -1
- package/dist/cjs/src/server/conf/networkConnectionConf.js +25 -0
- package/dist/cjs/src/server/conf/networkConnectionConf.js.map +1 -0
- package/dist/cjs/src/server/conf/proxyConfig.js +23 -0
- package/dist/cjs/src/server/conf/proxyConfig.js.map +1 -0
- package/dist/cjs/src/server/conf/rateLimitConfig.js +35 -0
- package/dist/cjs/src/server/conf/rateLimitConfig.js.map +1 -0
- package/dist/cjs/src/server/const/default.js +6 -0
- package/dist/cjs/src/server/const/default.js.map +1 -1
- package/dist/cjs/src/server/handlers/NotFoundHandler.js +217 -0
- package/dist/cjs/src/server/handlers/NotFoundHandler.js.map +1 -0
- package/dist/cjs/src/server/handlers/templates/notFoundTemp.js +163 -0
- package/dist/cjs/src/server/handlers/templates/notFoundTemp.js.map +1 -0
- package/dist/esm/mods/security/src/components/cache/UFSIMC.js +5 -5
- package/dist/esm/mods/security/src/components/cache/UFSIMC.js.map +1 -1
- package/dist/esm/mods/security/src/components/cache/cacheSys.utils.js +3 -3
- package/dist/esm/mods/security/src/components/cache/cacheSys.utils.js.map +1 -1
- package/dist/esm/mods/security/src/index.js +14 -10
- package/dist/esm/mods/security/src/index.js.map +1 -1
- package/dist/esm/src/index.js +18 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/plugins/modules/PluginEngine.js +376 -0
- package/dist/esm/src/plugins/modules/PluginEngine.js.map +1 -0
- package/dist/esm/src/plugins/modules/PluginRegistry.js +337 -0
- package/dist/esm/src/plugins/modules/PluginRegistry.js.map +1 -0
- package/dist/esm/src/plugins/modules/builtin/JWTAuthPlugin.js +589 -0
- package/dist/esm/src/plugins/modules/builtin/JWTAuthPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/builtin/ResponseTimePlugin.js +411 -0
- package/dist/esm/src/plugins/modules/builtin/ResponseTimePlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/builtin/SmartCachePlugin.js +841 -0
- package/dist/esm/src/plugins/modules/builtin/SmartCachePlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/core/CachePlugin.js +1973 -0
- package/dist/esm/src/plugins/modules/core/CachePlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/core/PerformancePlugin.js +872 -0
- package/dist/esm/src/plugins/modules/core/PerformancePlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/core/SecurityPlugin.js +797 -0
- package/dist/esm/src/plugins/modules/core/SecurityPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/index.js +275 -0
- package/dist/esm/src/plugins/modules/index.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/builtin/CompressionPlugin.js +389 -0
- package/dist/esm/src/plugins/modules/network/builtin/CompressionPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/builtin/ConnectionPlugin.js +776 -0
- package/dist/esm/src/plugins/modules/network/builtin/ConnectionPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/builtin/ProxyPlugin.js +407 -0
- package/dist/esm/src/plugins/modules/network/builtin/ProxyPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/builtin/RateLimitPlugin.js +585 -0
- package/dist/esm/src/plugins/modules/network/builtin/RateLimitPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/core/NetworkPlugin.js +223 -0
- package/dist/esm/src/plugins/modules/network/core/NetworkPlugin.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/core/NetworkPluginFactory.js +38 -0
- package/dist/esm/src/plugins/modules/network/core/NetworkPluginFactory.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/index.js +109 -0
- package/dist/esm/src/plugins/modules/network/index.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/types/NetworkTypes.js +24 -0
- package/dist/esm/src/plugins/modules/network/types/NetworkTypes.js.map +1 -0
- package/dist/esm/src/plugins/modules/network/utils/NetworkPluginUtils.js +61 -0
- package/dist/esm/src/plugins/modules/network/utils/NetworkPluginUtils.js.map +1 -0
- package/dist/esm/src/plugins/modules/types/PluginTypes.js +48 -0
- package/dist/esm/src/plugins/modules/types/PluginTypes.js.map +1 -0
- package/dist/esm/src/server/FastServer.js +133 -5
- package/dist/esm/src/server/FastServer.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/PluginManager.js +5 -5
- package/dist/esm/src/server/components/fastapi/PluginManager.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/RequestProcessor.js +1 -1
- package/dist/esm/src/server/conf/networkConnectionConf.js +23 -0
- package/dist/esm/src/server/conf/networkConnectionConf.js.map +1 -0
- package/dist/esm/src/server/conf/proxyConfig.js +21 -0
- package/dist/esm/src/server/conf/proxyConfig.js.map +1 -0
- package/dist/esm/src/server/conf/rateLimitConfig.js +33 -0
- package/dist/esm/src/server/conf/rateLimitConfig.js.map +1 -0
- package/dist/esm/src/server/const/default.js +6 -0
- package/dist/esm/src/server/const/default.js.map +1 -1
- package/dist/esm/src/server/handlers/NotFoundHandler.js +194 -0
- package/dist/esm/src/server/handlers/NotFoundHandler.js.map +1 -0
- package/dist/esm/src/server/handlers/templates/notFoundTemp.js +161 -0
- package/dist/esm/src/server/handlers/templates/notFoundTemp.js.map +1 -0
- package/dist/index.d.ts +5104 -14
- package/package.json +8 -7
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
|
|
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
|
-
|
|
74
|
+
app.get("/", (req, res) => {
|
|
75
75
|
res.json({ message: "Hello from XyPriss!" });
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
|
|
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
|
-
|
|
85
|
-
console.log(
|
|
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.
|
|
194
|
-
console.log(
|
|
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
|
|
@@ -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$
|
|
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
|
|
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(
|
|
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$
|
|
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$
|
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var CacheFactory = require('./cache/CacheFactory.js');
|
|
|
6
6
|
var securityMiddleware = require('./middleware/security-middleware.js');
|
|
7
7
|
var performanceMonitor = require('./server/optimization/performance-monitor.js');
|
|
8
8
|
var index = require('./cluster/index.js');
|
|
9
|
+
var index$1 = require('./plugins/modules/index.js');
|
|
9
10
|
var quickStart = require('./quick-start.js');
|
|
10
11
|
var safeJsonMiddleware = require('./middleware/safe-json-middleware.js');
|
|
11
12
|
var safeSerializer = require('../mods/security/src/components/fortified-function/serializer/safe-serializer.js');
|
|
@@ -18,6 +19,23 @@ var IPCManager = require('./cluster/modules/IPCManager.js');
|
|
|
18
19
|
var MetricsCollector = require('./cluster/modules/MetricsCollector.js');
|
|
19
20
|
var AutoScaler = require('./cluster/modules/AutoScaler.js');
|
|
20
21
|
var ClusterFactory = require('./cluster/modules/ClusterFactory.js');
|
|
22
|
+
var PluginRegistry = require('./plugins/modules/PluginRegistry.js');
|
|
23
|
+
var PluginEngine = require('./plugins/modules/PluginEngine.js');
|
|
24
|
+
var PluginTypes = require('./plugins/modules/types/PluginTypes.js');
|
|
25
|
+
var SecurityPlugin = require('./plugins/modules/core/SecurityPlugin.js');
|
|
26
|
+
var PerformancePlugin = require('./plugins/modules/core/PerformancePlugin.js');
|
|
27
|
+
var CachePlugin = require('./plugins/modules/core/CachePlugin.js');
|
|
28
|
+
var JWTAuthPlugin = require('./plugins/modules/builtin/JWTAuthPlugin.js');
|
|
29
|
+
var ResponseTimePlugin = require('./plugins/modules/builtin/ResponseTimePlugin.js');
|
|
30
|
+
var SmartCachePlugin = require('./plugins/modules/builtin/SmartCachePlugin.js');
|
|
31
|
+
var NetworkPlugin = require('./plugins/modules/network/core/NetworkPlugin.js');
|
|
32
|
+
var ConnectionPlugin = require('./plugins/modules/network/builtin/ConnectionPlugin.js');
|
|
33
|
+
var CompressionPlugin = require('./plugins/modules/network/builtin/CompressionPlugin.js');
|
|
34
|
+
var ProxyPlugin = require('./plugins/modules/network/builtin/ProxyPlugin.js');
|
|
35
|
+
var RateLimitPlugin = require('./plugins/modules/network/builtin/RateLimitPlugin.js');
|
|
36
|
+
var NetworkTypes = require('./plugins/modules/network/types/NetworkTypes.js');
|
|
37
|
+
var NetworkPluginFactory = require('./plugins/modules/network/core/NetworkPluginFactory.js');
|
|
38
|
+
var NetworkPluginUtils = require('./plugins/modules/network/utils/NetworkPluginUtils.js');
|
|
21
39
|
|
|
22
40
|
|
|
23
41
|
|
|
@@ -43,6 +61,13 @@ exports.mergeClusterConfigs = index.mergeClusterConfigs;
|
|
|
43
61
|
exports.setClusterDefaults = index.setClusterDefaults;
|
|
44
62
|
exports.validateClusterConfig = index.validateClusterConfig;
|
|
45
63
|
exports.withClusterSupport = index.withClusterSupport;
|
|
64
|
+
exports.DEFAULT_PLUGIN_CONFIG = index$1.DEFAULT_PLUGIN_CONFIG;
|
|
65
|
+
exports.PERFORMANCE_TARGETS = index$1.PERFORMANCE_TARGETS;
|
|
66
|
+
exports.PLUGIN_SYSTEM_NAME = index$1.PLUGIN_SYSTEM_NAME;
|
|
67
|
+
exports.PLUGIN_SYSTEM_VERSION = index$1.PLUGIN_SYSTEM_VERSION;
|
|
68
|
+
exports.PluginDevelopmentHelpers = index$1.PluginDevelopmentHelpers;
|
|
69
|
+
exports.PluginSystemFactory = index$1.PluginSystemFactory;
|
|
70
|
+
exports.PluginSystemUtils = index$1.PluginSystemUtils;
|
|
46
71
|
exports.quickServer = quickStart.quickServer;
|
|
47
72
|
exports.createCircularRefDebugger = safeJsonMiddleware.createCircularRefDebugger;
|
|
48
73
|
exports.createSafeJsonMiddleware = safeJsonMiddleware.createSafeJsonMiddleware;
|
|
@@ -71,4 +96,35 @@ exports.clusterBuilderFactory = ClusterFactory.clusterBuilderFactory;
|
|
|
71
96
|
exports.clusterFactory = ClusterFactory.clusterFactory;
|
|
72
97
|
exports.createCluster = ClusterFactory.createCluster;
|
|
73
98
|
exports.createClusterForEnvironment = ClusterFactory.createClusterForEnvironment;
|
|
99
|
+
exports.PluginRegistry = PluginRegistry.PluginRegistry;
|
|
100
|
+
exports.PluginEngine = PluginEngine.PluginEngine;
|
|
101
|
+
Object.defineProperty(exports, 'PluginEventType', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () { return PluginTypes.PluginEventType; }
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, 'PluginPriority', {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () { return PluginTypes.PluginPriority; }
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, 'PluginType', {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () { return PluginTypes.PluginType; }
|
|
112
|
+
});
|
|
113
|
+
exports.SecurityPluginBase = SecurityPlugin.SecurityPlugin;
|
|
114
|
+
exports.PerformancePluginBase = PerformancePlugin.PerformancePlugin;
|
|
115
|
+
exports.CachePluginBase = CachePlugin.CachePlugin;
|
|
116
|
+
exports.JWTAuthPlugin = JWTAuthPlugin.JWTAuthPlugin;
|
|
117
|
+
exports.ResponseTimePlugin = ResponseTimePlugin.ResponseTimePlugin;
|
|
118
|
+
exports.SmartCachePlugin = SmartCachePlugin.SmartCachePlugin;
|
|
119
|
+
exports.NetworkPlugin = NetworkPlugin.NetworkPlugin;
|
|
120
|
+
exports.ConnectionPlugin = ConnectionPlugin.ConnectionPlugin;
|
|
121
|
+
exports.CompressionPlugin = CompressionPlugin.CompressionPlugin;
|
|
122
|
+
exports.ProxyPlugin = ProxyPlugin.ProxyPlugin;
|
|
123
|
+
exports.RateLimitPlugin = RateLimitPlugin.RateLimitPlugin;
|
|
124
|
+
Object.defineProperty(exports, 'NetworkCategory', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () { return NetworkTypes.NetworkCategory; }
|
|
127
|
+
});
|
|
128
|
+
exports.NetworkPluginFactory = NetworkPluginFactory.NetworkPluginFactory;
|
|
129
|
+
exports.NetworkPluginUtils = NetworkPluginUtils.NetworkPluginUtils;
|
|
74
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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
|